@@ -31,73 +31,73 @@ |
||
31 | 31 | */ |
32 | 32 | class RequestParameters |
33 | 33 | { |
34 | - /** |
|
35 | - * Site secret. |
|
36 | - * @var string |
|
37 | - */ |
|
38 | - private $secret; |
|
34 | + /** |
|
35 | + * Site secret. |
|
36 | + * @var string |
|
37 | + */ |
|
38 | + private $secret; |
|
39 | 39 | |
40 | - /** |
|
41 | - * Form response. |
|
42 | - * @var string |
|
43 | - */ |
|
44 | - private $response; |
|
40 | + /** |
|
41 | + * Form response. |
|
42 | + * @var string |
|
43 | + */ |
|
44 | + private $response; |
|
45 | 45 | |
46 | - /** |
|
47 | - * Remote user's IP address. |
|
48 | - * @var string |
|
49 | - */ |
|
50 | - private $remoteIp; |
|
46 | + /** |
|
47 | + * Remote user's IP address. |
|
48 | + * @var string |
|
49 | + */ |
|
50 | + private $remoteIp; |
|
51 | 51 | |
52 | - /** |
|
53 | - * Client version. |
|
54 | - * @var string |
|
55 | - */ |
|
56 | - private $version; |
|
52 | + /** |
|
53 | + * Client version. |
|
54 | + * @var string |
|
55 | + */ |
|
56 | + private $version; |
|
57 | 57 | |
58 | - /** |
|
59 | - * Initialise parameters. |
|
60 | - * |
|
61 | - * @param string $secret Site secret. |
|
62 | - * @param string $response Value from g-captcha-response form field. |
|
63 | - * @param string $remoteIp User's IP address. |
|
64 | - * @param string $version Version of this client library. |
|
65 | - */ |
|
66 | - public function __construct($secret, $response, $remoteIp = null, $version = null) |
|
67 | - { |
|
68 | - $this->secret = $secret; |
|
69 | - $this->response = $response; |
|
70 | - $this->remoteIp = $remoteIp; |
|
71 | - $this->version = $version; |
|
72 | - } |
|
58 | + /** |
|
59 | + * Initialise parameters. |
|
60 | + * |
|
61 | + * @param string $secret Site secret. |
|
62 | + * @param string $response Value from g-captcha-response form field. |
|
63 | + * @param string $remoteIp User's IP address. |
|
64 | + * @param string $version Version of this client library. |
|
65 | + */ |
|
66 | + public function __construct($secret, $response, $remoteIp = null, $version = null) |
|
67 | + { |
|
68 | + $this->secret = $secret; |
|
69 | + $this->response = $response; |
|
70 | + $this->remoteIp = $remoteIp; |
|
71 | + $this->version = $version; |
|
72 | + } |
|
73 | 73 | |
74 | - /** |
|
75 | - * Array representation. |
|
76 | - * |
|
77 | - * @return array Array formatted parameters. |
|
78 | - */ |
|
79 | - public function toArray() |
|
80 | - { |
|
81 | - $params = array('secret' => $this->secret, 'response' => $this->response); |
|
74 | + /** |
|
75 | + * Array representation. |
|
76 | + * |
|
77 | + * @return array Array formatted parameters. |
|
78 | + */ |
|
79 | + public function toArray() |
|
80 | + { |
|
81 | + $params = array('secret' => $this->secret, 'response' => $this->response); |
|
82 | 82 | |
83 | - if (!is_null($this->remoteIp)) { |
|
84 | - $params['remoteip'] = $this->remoteIp; |
|
85 | - } |
|
83 | + if (!is_null($this->remoteIp)) { |
|
84 | + $params['remoteip'] = $this->remoteIp; |
|
85 | + } |
|
86 | 86 | |
87 | - if (!is_null($this->version)) { |
|
88 | - $params['version'] = $this->version; |
|
89 | - } |
|
87 | + if (!is_null($this->version)) { |
|
88 | + $params['version'] = $this->version; |
|
89 | + } |
|
90 | 90 | |
91 | - return $params; |
|
92 | - } |
|
91 | + return $params; |
|
92 | + } |
|
93 | 93 | |
94 | - /** |
|
95 | - * Query string representation for HTTP request. |
|
96 | - * |
|
97 | - * @return string Query string formatted parameters. |
|
98 | - */ |
|
99 | - public function toQueryString() |
|
100 | - { |
|
101 | - return http_build_query($this->toArray(), '', '&'); |
|
102 | - } |
|
94 | + /** |
|
95 | + * Query string representation for HTTP request. |
|
96 | + * |
|
97 | + * @return string Query string formatted parameters. |
|
98 | + */ |
|
99 | + public function toQueryString() |
|
100 | + { |
|
101 | + return http_build_query($this->toArray(), '', '&'); |
|
102 | + } |
|
103 | 103 | } |
@@ -32,11 +32,11 @@ |
||
32 | 32 | interface RequestMethod |
33 | 33 | { |
34 | 34 | |
35 | - /** |
|
36 | - * Submit the request with the specified parameters. |
|
37 | - * |
|
38 | - * @param RequestParameters $params Request parameters |
|
39 | - * @return string Body of the reCAPTCHA response |
|
40 | - */ |
|
41 | - public function submit(RequestParameters $params); |
|
35 | + /** |
|
36 | + * Submit the request with the specified parameters. |
|
37 | + * |
|
38 | + * @param RequestParameters $params Request parameters |
|
39 | + * @return string Body of the reCAPTCHA response |
|
40 | + */ |
|
41 | + public function submit(RequestParameters $params); |
|
42 | 42 | } |
@@ -36,53 +36,53 @@ |
||
36 | 36 | */ |
37 | 37 | class CurlPost implements RequestMethod |
38 | 38 | { |
39 | - /** |
|
40 | - * URL to which requests are sent via cURL. |
|
41 | - * @const string |
|
42 | - */ |
|
43 | - const SITE_VERIFY_URL = 'https://www.google.com/recaptcha/api/siteverify'; |
|
39 | + /** |
|
40 | + * URL to which requests are sent via cURL. |
|
41 | + * @const string |
|
42 | + */ |
|
43 | + const SITE_VERIFY_URL = 'https://www.google.com/recaptcha/api/siteverify'; |
|
44 | 44 | |
45 | - /** |
|
46 | - * Curl connection to the reCAPTCHA service |
|
47 | - * @var Curl |
|
48 | - */ |
|
49 | - private $curl; |
|
45 | + /** |
|
46 | + * Curl connection to the reCAPTCHA service |
|
47 | + * @var Curl |
|
48 | + */ |
|
49 | + private $curl; |
|
50 | 50 | |
51 | - public function __construct(Curl $curl = null) |
|
52 | - { |
|
53 | - if (!is_null($curl)) { |
|
54 | - $this->curl = $curl; |
|
55 | - } else { |
|
56 | - $this->curl = new Curl(); |
|
57 | - } |
|
58 | - } |
|
51 | + public function __construct(Curl $curl = null) |
|
52 | + { |
|
53 | + if (!is_null($curl)) { |
|
54 | + $this->curl = $curl; |
|
55 | + } else { |
|
56 | + $this->curl = new Curl(); |
|
57 | + } |
|
58 | + } |
|
59 | 59 | |
60 | - /** |
|
61 | - * Submit the cURL request with the specified parameters. |
|
62 | - * |
|
63 | - * @param RequestParameters $params Request parameters |
|
64 | - * @return string Body of the reCAPTCHA response |
|
65 | - */ |
|
66 | - public function submit(RequestParameters $params) |
|
67 | - { |
|
68 | - $handle = $this->curl->init(self::SITE_VERIFY_URL); |
|
60 | + /** |
|
61 | + * Submit the cURL request with the specified parameters. |
|
62 | + * |
|
63 | + * @param RequestParameters $params Request parameters |
|
64 | + * @return string Body of the reCAPTCHA response |
|
65 | + */ |
|
66 | + public function submit(RequestParameters $params) |
|
67 | + { |
|
68 | + $handle = $this->curl->init(self::SITE_VERIFY_URL); |
|
69 | 69 | |
70 | - $options = array( |
|
71 | - CURLOPT_POST => true, |
|
72 | - CURLOPT_POSTFIELDS => $params->toQueryString(), |
|
73 | - CURLOPT_HTTPHEADER => array( |
|
74 | - 'Content-Type: application/x-www-form-urlencoded' |
|
75 | - ), |
|
76 | - CURLINFO_HEADER_OUT => false, |
|
77 | - CURLOPT_HEADER => false, |
|
78 | - CURLOPT_RETURNTRANSFER => true, |
|
79 | - CURLOPT_SSL_VERIFYPEER => true |
|
80 | - ); |
|
81 | - $this->curl->setoptArray($handle, $options); |
|
70 | + $options = array( |
|
71 | + CURLOPT_POST => true, |
|
72 | + CURLOPT_POSTFIELDS => $params->toQueryString(), |
|
73 | + CURLOPT_HTTPHEADER => array( |
|
74 | + 'Content-Type: application/x-www-form-urlencoded' |
|
75 | + ), |
|
76 | + CURLINFO_HEADER_OUT => false, |
|
77 | + CURLOPT_HEADER => false, |
|
78 | + CURLOPT_RETURNTRANSFER => true, |
|
79 | + CURLOPT_SSL_VERIFYPEER => true |
|
80 | + ); |
|
81 | + $this->curl->setoptArray($handle, $options); |
|
82 | 82 | |
83 | - $response = $this->curl->exec($handle); |
|
84 | - $this->curl->close($handle); |
|
83 | + $response = $this->curl->exec($handle); |
|
84 | + $this->curl->close($handle); |
|
85 | 85 | |
86 | - return $response; |
|
87 | - } |
|
86 | + return $response; |
|
87 | + } |
|
88 | 88 | } |
@@ -34,37 +34,37 @@ |
||
34 | 34 | */ |
35 | 35 | class Post implements RequestMethod |
36 | 36 | { |
37 | - /** |
|
38 | - * URL to which requests are POSTed. |
|
39 | - * @const string |
|
40 | - */ |
|
41 | - const SITE_VERIFY_URL = 'https://www.google.com/recaptcha/api/siteverify'; |
|
37 | + /** |
|
38 | + * URL to which requests are POSTed. |
|
39 | + * @const string |
|
40 | + */ |
|
41 | + const SITE_VERIFY_URL = 'https://www.google.com/recaptcha/api/siteverify'; |
|
42 | 42 | |
43 | - /** |
|
44 | - * Submit the POST request with the specified parameters. |
|
45 | - * |
|
46 | - * @param RequestParameters $params Request parameters |
|
47 | - * @return string Body of the reCAPTCHA response |
|
48 | - */ |
|
49 | - public function submit(RequestParameters $params) |
|
50 | - { |
|
51 | - /** |
|
52 | - * PHP 5.6.0 changed the way you specify the peer name for SSL context options. |
|
53 | - * Using "CN_name" will still work, but it will raise deprecated errors. |
|
54 | - */ |
|
55 | - $peer_key = version_compare(PHP_VERSION, '5.6.0', '<') ? 'CN_name' : 'peer_name'; |
|
56 | - $options = array( |
|
57 | - 'http' => array( |
|
58 | - 'header' => "Content-type: application/x-www-form-urlencoded\r\n", |
|
59 | - 'method' => 'POST', |
|
60 | - 'content' => $params->toQueryString(), |
|
61 | - // Force the peer to validate (not needed in 5.6.0+, but still works |
|
62 | - 'verify_peer' => true, |
|
63 | - // Force the peer validation to use www.google.com |
|
64 | - $peer_key => 'www.google.com', |
|
65 | - ), |
|
66 | - ); |
|
67 | - $context = stream_context_create($options); |
|
68 | - return file_get_contents(self::SITE_VERIFY_URL, false, $context); |
|
69 | - } |
|
43 | + /** |
|
44 | + * Submit the POST request with the specified parameters. |
|
45 | + * |
|
46 | + * @param RequestParameters $params Request parameters |
|
47 | + * @return string Body of the reCAPTCHA response |
|
48 | + */ |
|
49 | + public function submit(RequestParameters $params) |
|
50 | + { |
|
51 | + /** |
|
52 | + * PHP 5.6.0 changed the way you specify the peer name for SSL context options. |
|
53 | + * Using "CN_name" will still work, but it will raise deprecated errors. |
|
54 | + */ |
|
55 | + $peer_key = version_compare(PHP_VERSION, '5.6.0', '<') ? 'CN_name' : 'peer_name'; |
|
56 | + $options = array( |
|
57 | + 'http' => array( |
|
58 | + 'header' => "Content-type: application/x-www-form-urlencoded\r\n", |
|
59 | + 'method' => 'POST', |
|
60 | + 'content' => $params->toQueryString(), |
|
61 | + // Force the peer to validate (not needed in 5.6.0+, but still works |
|
62 | + 'verify_peer' => true, |
|
63 | + // Force the peer validation to use www.google.com |
|
64 | + $peer_key => 'www.google.com', |
|
65 | + ), |
|
66 | + ); |
|
67 | + $context = stream_context_create($options); |
|
68 | + return file_get_contents(self::SITE_VERIFY_URL, false, $context); |
|
69 | + } |
|
70 | 70 | } |
@@ -36,86 +36,86 @@ |
||
36 | 36 | */ |
37 | 37 | class SocketPost implements RequestMethod |
38 | 38 | { |
39 | - /** |
|
40 | - * reCAPTCHA service host. |
|
41 | - * @const string |
|
42 | - */ |
|
43 | - const RECAPTCHA_HOST = 'www.google.com'; |
|
44 | - |
|
45 | - /** |
|
46 | - * @const string reCAPTCHA service path |
|
47 | - */ |
|
48 | - const SITE_VERIFY_PATH = '/recaptcha/api/siteverify'; |
|
49 | - |
|
50 | - /** |
|
51 | - * @const string Bad request error |
|
52 | - */ |
|
53 | - const BAD_REQUEST = '{"success": false, "error-codes": ["invalid-request"]}'; |
|
54 | - |
|
55 | - /** |
|
56 | - * @const string Bad response error |
|
57 | - */ |
|
58 | - const BAD_RESPONSE = '{"success": false, "error-codes": ["invalid-response"]}'; |
|
59 | - |
|
60 | - /** |
|
61 | - * Socket to the reCAPTCHA service |
|
62 | - * @var Socket |
|
63 | - */ |
|
64 | - private $socket; |
|
65 | - |
|
66 | - /** |
|
67 | - * Constructor |
|
68 | - * |
|
69 | - * @param \ReCaptcha\RequestMethod\Socket $socket optional socket, injectable for testing |
|
70 | - */ |
|
71 | - public function __construct(Socket $socket = null) |
|
72 | - { |
|
73 | - if (!is_null($socket)) { |
|
74 | - $this->socket = $socket; |
|
75 | - } else { |
|
76 | - $this->socket = new Socket(); |
|
77 | - } |
|
78 | - } |
|
79 | - |
|
80 | - /** |
|
81 | - * Submit the POST request with the specified parameters. |
|
82 | - * |
|
83 | - * @param RequestParameters $params Request parameters |
|
84 | - * @return string Body of the reCAPTCHA response |
|
85 | - */ |
|
86 | - public function submit(RequestParameters $params) |
|
87 | - { |
|
88 | - $errno = 0; |
|
89 | - $errstr = ''; |
|
90 | - |
|
91 | - if (false === $this->socket->fsockopen('ssl://' . self::RECAPTCHA_HOST, 443, $errno, $errstr, 30)) { |
|
92 | - return self::BAD_REQUEST; |
|
93 | - } |
|
94 | - |
|
95 | - $content = $params->toQueryString(); |
|
96 | - |
|
97 | - $request = "POST " . self::SITE_VERIFY_PATH . " HTTP/1.1\r\n"; |
|
98 | - $request .= "Host: " . self::RECAPTCHA_HOST . "\r\n"; |
|
99 | - $request .= "Content-Type: application/x-www-form-urlencoded\r\n"; |
|
100 | - $request .= "Content-length: " . strlen($content) . "\r\n"; |
|
101 | - $request .= "Connection: close\r\n\r\n"; |
|
102 | - $request .= $content . "\r\n\r\n"; |
|
103 | - |
|
104 | - $this->socket->fwrite($request); |
|
105 | - $response = ''; |
|
106 | - |
|
107 | - while (!$this->socket->feof()) { |
|
108 | - $response .= $this->socket->fgets(4096); |
|
109 | - } |
|
110 | - |
|
111 | - $this->socket->fclose(); |
|
112 | - |
|
113 | - if (0 !== strpos($response, 'HTTP/1.1 200 OK')) { |
|
114 | - return self::BAD_RESPONSE; |
|
115 | - } |
|
116 | - |
|
117 | - $parts = preg_split("#\n\s*\n#Uis", $response); |
|
118 | - |
|
119 | - return $parts[1]; |
|
120 | - } |
|
39 | + /** |
|
40 | + * reCAPTCHA service host. |
|
41 | + * @const string |
|
42 | + */ |
|
43 | + const RECAPTCHA_HOST = 'www.google.com'; |
|
44 | + |
|
45 | + /** |
|
46 | + * @const string reCAPTCHA service path |
|
47 | + */ |
|
48 | + const SITE_VERIFY_PATH = '/recaptcha/api/siteverify'; |
|
49 | + |
|
50 | + /** |
|
51 | + * @const string Bad request error |
|
52 | + */ |
|
53 | + const BAD_REQUEST = '{"success": false, "error-codes": ["invalid-request"]}'; |
|
54 | + |
|
55 | + /** |
|
56 | + * @const string Bad response error |
|
57 | + */ |
|
58 | + const BAD_RESPONSE = '{"success": false, "error-codes": ["invalid-response"]}'; |
|
59 | + |
|
60 | + /** |
|
61 | + * Socket to the reCAPTCHA service |
|
62 | + * @var Socket |
|
63 | + */ |
|
64 | + private $socket; |
|
65 | + |
|
66 | + /** |
|
67 | + * Constructor |
|
68 | + * |
|
69 | + * @param \ReCaptcha\RequestMethod\Socket $socket optional socket, injectable for testing |
|
70 | + */ |
|
71 | + public function __construct(Socket $socket = null) |
|
72 | + { |
|
73 | + if (!is_null($socket)) { |
|
74 | + $this->socket = $socket; |
|
75 | + } else { |
|
76 | + $this->socket = new Socket(); |
|
77 | + } |
|
78 | + } |
|
79 | + |
|
80 | + /** |
|
81 | + * Submit the POST request with the specified parameters. |
|
82 | + * |
|
83 | + * @param RequestParameters $params Request parameters |
|
84 | + * @return string Body of the reCAPTCHA response |
|
85 | + */ |
|
86 | + public function submit(RequestParameters $params) |
|
87 | + { |
|
88 | + $errno = 0; |
|
89 | + $errstr = ''; |
|
90 | + |
|
91 | + if (false === $this->socket->fsockopen('ssl://' . self::RECAPTCHA_HOST, 443, $errno, $errstr, 30)) { |
|
92 | + return self::BAD_REQUEST; |
|
93 | + } |
|
94 | + |
|
95 | + $content = $params->toQueryString(); |
|
96 | + |
|
97 | + $request = "POST " . self::SITE_VERIFY_PATH . " HTTP/1.1\r\n"; |
|
98 | + $request .= "Host: " . self::RECAPTCHA_HOST . "\r\n"; |
|
99 | + $request .= "Content-Type: application/x-www-form-urlencoded\r\n"; |
|
100 | + $request .= "Content-length: " . strlen($content) . "\r\n"; |
|
101 | + $request .= "Connection: close\r\n\r\n"; |
|
102 | + $request .= $content . "\r\n\r\n"; |
|
103 | + |
|
104 | + $this->socket->fwrite($request); |
|
105 | + $response = ''; |
|
106 | + |
|
107 | + while (!$this->socket->feof()) { |
|
108 | + $response .= $this->socket->fgets(4096); |
|
109 | + } |
|
110 | + |
|
111 | + $this->socket->fclose(); |
|
112 | + |
|
113 | + if (0 !== strpos($response, 'HTTP/1.1 200 OK')) { |
|
114 | + return self::BAD_RESPONSE; |
|
115 | + } |
|
116 | + |
|
117 | + $parts = preg_split("#\n\s*\n#Uis", $response); |
|
118 | + |
|
119 | + return $parts[1]; |
|
120 | + } |
|
121 | 121 | } |
@@ -31,72 +31,72 @@ |
||
31 | 31 | */ |
32 | 32 | class Response |
33 | 33 | { |
34 | - /** |
|
35 | - * Succes or failure. |
|
36 | - * @var boolean |
|
37 | - */ |
|
38 | - private $success = false; |
|
34 | + /** |
|
35 | + * Succes or failure. |
|
36 | + * @var boolean |
|
37 | + */ |
|
38 | + private $success = false; |
|
39 | 39 | |
40 | - /** |
|
41 | - * Error code strings. |
|
42 | - * @var array |
|
43 | - */ |
|
44 | - private $errorCodes = array(); |
|
40 | + /** |
|
41 | + * Error code strings. |
|
42 | + * @var array |
|
43 | + */ |
|
44 | + private $errorCodes = array(); |
|
45 | 45 | |
46 | - /** |
|
47 | - * Build the response from the expected JSON returned by the service. |
|
48 | - * |
|
49 | - * @param string $json |
|
50 | - * @return \ReCaptcha\Response |
|
51 | - */ |
|
52 | - public static function fromJson($json) |
|
53 | - { |
|
54 | - $responseData = json_decode($json, true); |
|
46 | + /** |
|
47 | + * Build the response from the expected JSON returned by the service. |
|
48 | + * |
|
49 | + * @param string $json |
|
50 | + * @return \ReCaptcha\Response |
|
51 | + */ |
|
52 | + public static function fromJson($json) |
|
53 | + { |
|
54 | + $responseData = json_decode($json, true); |
|
55 | 55 | |
56 | - if (!$responseData) { |
|
57 | - return new Response(false, array('invalid-json')); |
|
58 | - } |
|
56 | + if (!$responseData) { |
|
57 | + return new Response(false, array('invalid-json')); |
|
58 | + } |
|
59 | 59 | |
60 | - if (isset($responseData['success']) && $responseData['success'] == true) { |
|
61 | - return new Response(true); |
|
62 | - } |
|
60 | + if (isset($responseData['success']) && $responseData['success'] == true) { |
|
61 | + return new Response(true); |
|
62 | + } |
|
63 | 63 | |
64 | - if (isset($responseData['error-codes']) && is_array($responseData['error-codes'])) { |
|
65 | - return new Response(false, $responseData['error-codes']); |
|
66 | - } |
|
64 | + if (isset($responseData['error-codes']) && is_array($responseData['error-codes'])) { |
|
65 | + return new Response(false, $responseData['error-codes']); |
|
66 | + } |
|
67 | 67 | |
68 | - return new Response(false); |
|
69 | - } |
|
68 | + return new Response(false); |
|
69 | + } |
|
70 | 70 | |
71 | - /** |
|
72 | - * Constructor. |
|
73 | - * |
|
74 | - * @param boolean $success |
|
75 | - * @param array $errorCodes |
|
76 | - */ |
|
77 | - public function __construct($success, array $errorCodes = array()) |
|
78 | - { |
|
79 | - $this->success = $success; |
|
80 | - $this->errorCodes = $errorCodes; |
|
81 | - } |
|
71 | + /** |
|
72 | + * Constructor. |
|
73 | + * |
|
74 | + * @param boolean $success |
|
75 | + * @param array $errorCodes |
|
76 | + */ |
|
77 | + public function __construct($success, array $errorCodes = array()) |
|
78 | + { |
|
79 | + $this->success = $success; |
|
80 | + $this->errorCodes = $errorCodes; |
|
81 | + } |
|
82 | 82 | |
83 | - /** |
|
84 | - * Is success? |
|
85 | - * |
|
86 | - * @return boolean |
|
87 | - */ |
|
88 | - public function isSuccess() |
|
89 | - { |
|
90 | - return $this->success; |
|
91 | - } |
|
83 | + /** |
|
84 | + * Is success? |
|
85 | + * |
|
86 | + * @return boolean |
|
87 | + */ |
|
88 | + public function isSuccess() |
|
89 | + { |
|
90 | + return $this->success; |
|
91 | + } |
|
92 | 92 | |
93 | - /** |
|
94 | - * Get error codes. |
|
95 | - * |
|
96 | - * @return array |
|
97 | - */ |
|
98 | - public function getErrorCodes() |
|
99 | - { |
|
100 | - return $this->errorCodes; |
|
101 | - } |
|
93 | + /** |
|
94 | + * Get error codes. |
|
95 | + * |
|
96 | + * @return array |
|
97 | + */ |
|
98 | + public function getErrorCodes() |
|
99 | + { |
|
100 | + return $this->errorCodes; |
|
101 | + } |
|
102 | 102 | } |
@@ -11,8 +11,9 @@ discard block |
||
11 | 11 | * @version 2.1 Beta 3 |
12 | 12 | */ |
13 | 13 | |
14 | -if (!defined('SMF')) |
|
14 | +if (!defined('SMF')) { |
|
15 | 15 | die('Hacking attempt...'); |
16 | +} |
|
16 | 17 | |
17 | 18 | /** |
18 | 19 | * SQLite Cache API class |
@@ -153,8 +154,7 @@ discard block |
||
153 | 154 | if (is_null($dir) || !is_writable($dir)) |
154 | 155 | { |
155 | 156 | $this->cachedir = $cachedir_sqlite; |
156 | - } |
|
157 | - else |
|
157 | + } else |
|
158 | 158 | { |
159 | 159 | $this->cachedir = $dir; |
160 | 160 | } |
@@ -143,7 +143,7 @@ |
||
143 | 143 | * |
144 | 144 | * @param string $dir A valid path |
145 | 145 | * |
146 | - * @return boolean If this was successful or not. |
|
146 | + * @return boolean|null If this was successful or not. |
|
147 | 147 | */ |
148 | 148 | public function setCachedir($dir = null) |
149 | 149 | { |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | * Display a list of upcoming events, birthdays, and holidays. |
69 | 69 | * |
70 | 70 | * @param string $grid_name The grid name |
71 | - * @return void|bool Returns false if the grid doesn't exist. |
|
71 | + * @return false|null Returns false if the grid doesn't exist. |
|
72 | 72 | */ |
73 | 73 | function template_show_upcoming_list($grid_name) |
74 | 74 | { |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | * |
239 | 239 | * @param string $grid_name The grid name |
240 | 240 | * @param bool $is_mini Is this a mini grid? |
241 | - * @return void|bool Returns false if the grid doesn't exist. |
|
241 | + * @return false|null Returns false if the grid doesn't exist. |
|
242 | 242 | */ |
243 | 243 | function template_show_month_grid($grid_name, $is_mini = false) |
244 | 244 | { |
@@ -523,7 +523,7 @@ discard block |
||
523 | 523 | * Shows a weekly grid |
524 | 524 | * |
525 | 525 | * @param string $grid_name The name of the grid |
526 | - * @return void|bool Returns false if the grid doesn't exist |
|
526 | + * @return false|null Returns false if the grid doesn't exist |
|
527 | 527 | */ |
528 | 528 | function template_show_week_grid($grid_name) |
529 | 529 | { |
@@ -437,9 +437,9 @@ discard block |
||
437 | 437 | { |
438 | 438 | // Sort events by start time (all day events will be listed first) |
439 | 439 | uasort($day['events'], function($a, $b) { |
440 | - if ($a['start_timestamp'] == $b['start_timestamp']) |
|
441 | - return 0; |
|
442 | - return ($a['start_timestamp'] < $b['start_timestamp']) ? -1 : 1; |
|
440 | + if ($a['start_timestamp'] == $b['start_timestamp']) |
|
441 | + return 0; |
|
442 | + return ($a['start_timestamp'] < $b['start_timestamp']) ? -1 : 1; |
|
443 | 443 | }); |
444 | 444 | |
445 | 445 | echo ' |
@@ -619,9 +619,9 @@ discard block |
||
619 | 619 | { |
620 | 620 | // Sort events by start time (all day events will be listed first) |
621 | 621 | uasort($day['events'], function($a, $b) { |
622 | - if ($a['start_timestamp'] == $b['start_timestamp']) |
|
623 | - return 0; |
|
624 | - return ($a['start_timestamp'] < $b['start_timestamp']) ? -1 : 1; |
|
622 | + if ($a['start_timestamp'] == $b['start_timestamp']) |
|
623 | + return 0; |
|
624 | + return ($a['start_timestamp'] < $b['start_timestamp']) ? -1 : 1; |
|
625 | 625 | }); |
626 | 626 | |
627 | 627 | foreach ($day['events'] as $event) |
@@ -40,16 +40,14 @@ discard block |
||
40 | 40 | ', template_show_upcoming_list('main'), ' |
41 | 41 | </div> |
42 | 42 | '; |
43 | - } |
|
44 | - elseif ($context['calendar_view'] == 'view_week') |
|
43 | + } elseif ($context['calendar_view'] == 'view_week') |
|
45 | 44 | { |
46 | 45 | echo ' |
47 | 46 | <div id="main_grid"> |
48 | 47 | ', template_show_week_grid('main'), ' |
49 | 48 | </div> |
50 | 49 | '; |
51 | - } |
|
52 | - else |
|
50 | + } else |
|
53 | 51 | { |
54 | 52 | echo ' |
55 | 53 | <div id="main_grid"> |
@@ -75,8 +73,9 @@ discard block |
||
75 | 73 | global $context, $scripturl, $txt; |
76 | 74 | |
77 | 75 | // Bail out if we have nothing to work with |
78 | - if (!isset($context['calendar_grid_' . $grid_name])) |
|
79 | - return false; |
|
76 | + if (!isset($context['calendar_grid_' . $grid_name])) { |
|
77 | + return false; |
|
78 | + } |
|
80 | 79 | |
81 | 80 | // Protect programmer sanity |
82 | 81 | $calendar_data = &$context['calendar_grid_' . $grid_name]; |
@@ -113,11 +112,13 @@ discard block |
||
113 | 112 | <li class="windowbg"> |
114 | 113 | <b class="event_title">', $event['link'], '</b>'; |
115 | 114 | |
116 | - if ($event['can_edit']) |
|
117 | - echo ' <a href="' . $event['modify_href'] . '"><span class="generic_icons calendar_modify" title="', $txt['calendar_edit'], '"></span></a>'; |
|
115 | + if ($event['can_edit']) { |
|
116 | + echo ' <a href="' . $event['modify_href'] . '"><span class="generic_icons calendar_modify" title="', $txt['calendar_edit'], '"></span></a>'; |
|
117 | + } |
|
118 | 118 | |
119 | - if ($event['can_export']) |
|
120 | - echo ' <a href="' . $event['export_href'] . '"><span class="generic_icons calendar_export" title="', $txt['calendar_export'], '"></span></a>'; |
|
119 | + if ($event['can_export']) { |
|
120 | + echo ' <a href="' . $event['export_href'] . '"><span class="generic_icons calendar_export" title="', $txt['calendar_export'], '"></span></a>'; |
|
121 | + } |
|
121 | 122 | |
122 | 123 | echo ' |
123 | 124 | <br>'; |
@@ -125,14 +126,14 @@ discard block |
||
125 | 126 | if (!empty($event['allday'])) |
126 | 127 | { |
127 | 128 | echo '<time datetime="' . $event['start_iso_gmdate'] . '">', trim($event['start_date_local']), '</time>', ($event['start_date'] != $event['end_date']) ? ' – <time datetime="' . $event['end_iso_gmdate'] . '">' . trim($event['end_date_local']) . '</time>' : ''; |
128 | - } |
|
129 | - else |
|
129 | + } else |
|
130 | 130 | { |
131 | 131 | // Display event info relative to user's local timezone |
132 | 132 | echo '<time datetime="' . $event['start_iso_gmdate'] . '">', trim($event['start_date_local']), ', ', trim($event['start_time_local']), '</time> – <time datetime="' . $event['end_iso_gmdate'] . '">'; |
133 | 133 | |
134 | - if ($event['start_date_local'] != $event['end_date_local']) |
|
135 | - echo trim($event['end_date_local']) . ', '; |
|
134 | + if ($event['start_date_local'] != $event['end_date_local']) { |
|
135 | + echo trim($event['end_date_local']) . ', '; |
|
136 | + } |
|
136 | 137 | |
137 | 138 | echo trim($event['end_time_local']); |
138 | 139 | |
@@ -141,23 +142,27 @@ discard block |
||
141 | 142 | { |
142 | 143 | echo '</time> (<time datetime="' . $event['start_iso_gmdate'] . '">'; |
143 | 144 | |
144 | - if ($event['start_date_orig'] != $event['start_date_local'] || $event['end_date_orig'] != $event['end_date_local'] || $event['start_date_orig'] != $event['end_date_orig']) |
|
145 | - echo trim($event['start_date_orig']), ', '; |
|
145 | + if ($event['start_date_orig'] != $event['start_date_local'] || $event['end_date_orig'] != $event['end_date_local'] || $event['start_date_orig'] != $event['end_date_orig']) { |
|
146 | + echo trim($event['start_date_orig']), ', '; |
|
147 | + } |
|
146 | 148 | |
147 | 149 | echo trim($event['start_time_orig']), '</time> – <time datetime="' . $event['end_iso_gmdate'] . '">'; |
148 | 150 | |
149 | - if ($event['start_date_orig'] != $event['end_date_orig']) |
|
150 | - echo trim($event['end_date_orig']) . ', '; |
|
151 | + if ($event['start_date_orig'] != $event['end_date_orig']) { |
|
152 | + echo trim($event['end_date_orig']) . ', '; |
|
153 | + } |
|
151 | 154 | |
152 | 155 | echo trim($event['end_time_orig']), ' ', $event['tz_abbrev'], '</time>)'; |
153 | 156 | } |
154 | 157 | // Event is scheduled in the user's own timezone? Let 'em know, just to avoid confusion |
155 | - else |
|
156 | - echo ' ', $event['tz_abbrev'], '</time>'; |
|
158 | + else { |
|
159 | + echo ' ', $event['tz_abbrev'], '</time>'; |
|
160 | + } |
|
157 | 161 | } |
158 | 162 | |
159 | - if (!empty($event['location'])) |
|
160 | - echo '<br>', $event['location']; |
|
163 | + if (!empty($event['location'])) { |
|
164 | + echo '<br>', $event['location']; |
|
165 | + } |
|
161 | 166 | |
162 | 167 | echo ' |
163 | 168 | </li>'; |
@@ -189,8 +194,9 @@ discard block |
||
189 | 194 | |
190 | 195 | $birthdays = array(); |
191 | 196 | |
192 | - foreach ($date as $member) |
|
193 | - $birthdays[] = '<a href="' . $scripturl . '?action=profile;u=' . $member['id'] . '">' . $member['name'] . (isset($member['age']) ? ' (' . $member['age'] . ')' : '') . '</a>'; |
|
197 | + foreach ($date as $member) { |
|
198 | + $birthdays[] = '<a href="' . $scripturl . '?action=profile;u=' . $member['id'] . '">' . $member['name'] . (isset($member['age']) ? ' (' . $member['age'] . ')' : '') . '</a>'; |
|
199 | + } |
|
194 | 200 | |
195 | 201 | echo implode(', ', $birthdays); |
196 | 202 | |
@@ -221,8 +227,9 @@ discard block |
||
221 | 227 | $date_local = $date['date_local']; |
222 | 228 | unset($date['date_local']); |
223 | 229 | |
224 | - foreach ($date as $holiday) |
|
225 | - $holidays[] = $holiday . ' (' . $date_local . ')'; |
|
230 | + foreach ($date as $holiday) { |
|
231 | + $holidays[] = $holiday . ' (' . $date_local . ')'; |
|
232 | + } |
|
226 | 233 | } |
227 | 234 | |
228 | 235 | echo implode(', ', $holidays); |
@@ -245,17 +252,19 @@ discard block |
||
245 | 252 | global $context, $txt, $scripturl, $modSettings; |
246 | 253 | |
247 | 254 | // If the grid doesn't exist, no point in proceeding. |
248 | - if (!isset($context['calendar_grid_' . $grid_name])) |
|
249 | - return false; |
|
255 | + if (!isset($context['calendar_grid_' . $grid_name])) { |
|
256 | + return false; |
|
257 | + } |
|
250 | 258 | |
251 | 259 | // A handy little pointer variable. |
252 | 260 | $calendar_data = &$context['calendar_grid_' . $grid_name]; |
253 | 261 | |
254 | 262 | // Some conditions for whether or not we should show the week links *here*. |
255 | - if (isset($calendar_data['show_week_links']) && ($calendar_data['show_week_links'] == 3 || (($calendar_data['show_week_links'] == 1 && $is_mini === true) || $calendar_data['show_week_links'] == 2 && $is_mini === false))) |
|
256 | - $show_week_links = true; |
|
257 | - else |
|
258 | - $show_week_links = false; |
|
263 | + if (isset($calendar_data['show_week_links']) && ($calendar_data['show_week_links'] == 3 || (($calendar_data['show_week_links'] == 1 && $is_mini === true) || $calendar_data['show_week_links'] == 2 && $is_mini === false))) { |
|
264 | + $show_week_links = true; |
|
265 | + } else { |
|
266 | + $show_week_links = false; |
|
267 | + } |
|
259 | 268 | |
260 | 269 | // Assuming that we've not disabled it, show the title block! |
261 | 270 | if (empty($calendar_data['disable_title'])) |
@@ -294,8 +303,9 @@ discard block |
||
294 | 303 | } |
295 | 304 | |
296 | 305 | // Show the controls on main grids |
297 | - if ($is_mini === false) |
|
298 | - template_calendar_top($calendar_data); |
|
306 | + if ($is_mini === false) { |
|
307 | + template_calendar_top($calendar_data); |
|
308 | + } |
|
299 | 309 | |
300 | 310 | // Finally, the main calendar table. |
301 | 311 | echo '<table class="calendar_table">'; |
@@ -306,8 +316,9 @@ discard block |
||
306 | 316 | echo '<tr>'; |
307 | 317 | |
308 | 318 | // If we're showing week links, there's an extra column ahead of the week links, so let's think ahead and be prepared! |
309 | - if ($show_week_links === true) |
|
310 | - echo '<th> </th>'; |
|
319 | + if ($show_week_links === true) { |
|
320 | + echo '<th> </th>'; |
|
321 | + } |
|
311 | 322 | |
312 | 323 | // Now, loop through each actual day of the week. |
313 | 324 | foreach ($calendar_data['week_days'] as $day) |
@@ -354,27 +365,29 @@ discard block |
||
354 | 365 | // Additional classes are given for events, holidays, and birthdays. |
355 | 366 | if (!empty($day['events']) && !empty($calendar_data['highlight']['events'])) |
356 | 367 | { |
357 | - if ($is_mini === true && in_array($calendar_data['highlight']['events'], array(1, 3))) |
|
358 | - $classes[] = 'events'; |
|
359 | - elseif ($is_mini === false && in_array($calendar_data['highlight']['events'], array(2, 3))) |
|
360 | - $classes[] = 'events'; |
|
368 | + if ($is_mini === true && in_array($calendar_data['highlight']['events'], array(1, 3))) { |
|
369 | + $classes[] = 'events'; |
|
370 | + } elseif ($is_mini === false && in_array($calendar_data['highlight']['events'], array(2, 3))) { |
|
371 | + $classes[] = 'events'; |
|
372 | + } |
|
361 | 373 | } |
362 | 374 | if (!empty($day['holidays']) && !empty($calendar_data['highlight']['holidays'])) |
363 | 375 | { |
364 | - if ($is_mini === true && in_array($calendar_data['highlight']['holidays'], array(1, 3))) |
|
365 | - $classes[] = 'holidays'; |
|
366 | - elseif ($is_mini === false && in_array($calendar_data['highlight']['holidays'], array(2, 3))) |
|
367 | - $classes[] = 'holidays'; |
|
376 | + if ($is_mini === true && in_array($calendar_data['highlight']['holidays'], array(1, 3))) { |
|
377 | + $classes[] = 'holidays'; |
|
378 | + } elseif ($is_mini === false && in_array($calendar_data['highlight']['holidays'], array(2, 3))) { |
|
379 | + $classes[] = 'holidays'; |
|
380 | + } |
|
368 | 381 | } |
369 | 382 | if (!empty($day['birthdays']) && !empty($calendar_data['highlight']['birthdays'])) |
370 | 383 | { |
371 | - if ($is_mini === true && in_array($calendar_data['highlight']['birthdays'], array(1, 3))) |
|
372 | - $classes[] = 'birthdays'; |
|
373 | - elseif ($is_mini === false && in_array($calendar_data['highlight']['birthdays'], array(2, 3))) |
|
374 | - $classes[] = 'birthdays'; |
|
384 | + if ($is_mini === true && in_array($calendar_data['highlight']['birthdays'], array(1, 3))) { |
|
385 | + $classes[] = 'birthdays'; |
|
386 | + } elseif ($is_mini === false && in_array($calendar_data['highlight']['birthdays'], array(2, 3))) { |
|
387 | + $classes[] = 'birthdays'; |
|
388 | + } |
|
375 | 389 | } |
376 | - } |
|
377 | - else |
|
390 | + } else |
|
378 | 391 | { |
379 | 392 | // Default Classes (either compact or comfortable and disabled). |
380 | 393 | $classes[] = !empty($calendar_data['size']) && $calendar_data['size'] == 'small' ? 'compact' : 'comfortable'; |
@@ -392,17 +405,19 @@ discard block |
||
392 | 405 | $title_prefix = !empty($day['is_first_of_month']) && $context['current_month'] == $calendar_data['current_month'] && $is_mini === false ? (!empty($calendar_data['short_month_titles']) ? $txt['months_short'][$calendar_data['current_month']] . ' ' : $txt['months_titles'][$calendar_data['current_month']] . ' ') : ''; |
393 | 406 | |
394 | 407 | // The actual day number - be it a link, or just plain old text! |
395 | - if (!empty($modSettings['cal_daysaslink']) && $context['can_post']) |
|
396 | - echo '<a href="', $scripturl, '?action=calendar;sa=post;year=', $calendar_data['current_year'], ';month=', $calendar_data['current_month'], ';day=', $day['day'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="day_text">', $title_prefix, $day['day'], '</span></a>'; |
|
397 | - else |
|
398 | - echo '<span class="day_text">', $title_prefix, $day['day'], '</span>'; |
|
408 | + if (!empty($modSettings['cal_daysaslink']) && $context['can_post']) { |
|
409 | + echo '<a href="', $scripturl, '?action=calendar;sa=post;year=', $calendar_data['current_year'], ';month=', $calendar_data['current_month'], ';day=', $day['day'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="day_text">', $title_prefix, $day['day'], '</span></a>'; |
|
410 | + } else { |
|
411 | + echo '<span class="day_text">', $title_prefix, $day['day'], '</span>'; |
|
412 | + } |
|
399 | 413 | |
400 | 414 | // A lot of stuff, we're not showing on mini-calendars to conserve space. |
401 | 415 | if ($is_mini === false) |
402 | 416 | { |
403 | 417 | // Holidays are always fun, let's show them! |
404 | - if (!empty($day['holidays'])) |
|
405 | - echo '<div class="smalltext holiday"><span>', $txt['calendar_prompt'], '</span> ', implode(', ', $day['holidays']), '</div>'; |
|
418 | + if (!empty($day['holidays'])) { |
|
419 | + echo '<div class="smalltext holiday"><span>', $txt['calendar_prompt'], '</span> ', implode(', ', $day['holidays']), '</div>'; |
|
420 | + } |
|
406 | 421 | |
407 | 422 | // Happy Birthday Dear, Member! |
408 | 423 | if (!empty($day['birthdays'])) |
@@ -420,14 +435,16 @@ discard block |
||
420 | 435 | echo '<a href="', $scripturl, '?action=profile;u=', $member['id'], '"><span class="fix_rtl_names">', $member['name'], '</span>', isset($member['age']) ? ' (' . $member['age'] . ')' : '', '</a>', $member['is_last'] || ($count == 10 && $use_js_hide) ? '' : ', '; |
421 | 436 | |
422 | 437 | // 9...10! Let's stop there. |
423 | - if ($birthday_count == 10 && $use_js_hide) |
|
424 | - // !!TODO - Inline CSS and JavaScript should be moved. |
|
438 | + if ($birthday_count == 10 && $use_js_hide) { |
|
439 | + // !!TODO - Inline CSS and JavaScript should be moved. |
|
425 | 440 | echo '<span class="hidelink" id="bdhidelink_', $day['day'], '">...<br><a href="', $scripturl, '?action=calendar;month=', $calendar_data['current_month'], ';year=', $calendar_data['current_year'], ';showbd" onclick="document.getElementById(\'bdhide_', $day['day'], '\').style.display = \'\'; document.getElementById(\'bdhidelink_', $day['day'], '\').style.display = \'none\'; return false;">(', sprintf($txt['calendar_click_all'], count($day['birthdays'])), ')</a></span><span id="bdhide_', $day['day'], '" style="display: none;">, '; |
441 | + } |
|
426 | 442 | |
427 | 443 | ++$birthday_count; |
428 | 444 | } |
429 | - if ($use_js_hide) |
|
430 | - echo '</span>'; |
|
445 | + if ($use_js_hide) { |
|
446 | + echo '</span>'; |
|
447 | + } |
|
431 | 448 | |
432 | 449 | echo '</div>'; |
433 | 450 | } |
@@ -437,8 +454,9 @@ discard block |
||
437 | 454 | { |
438 | 455 | // Sort events by start time (all day events will be listed first) |
439 | 456 | uasort($day['events'], function($a, $b) { |
440 | - if ($a['start_timestamp'] == $b['start_timestamp']) |
|
441 | - return 0; |
|
457 | + if ($a['start_timestamp'] == $b['start_timestamp']) { |
|
458 | + return 0; |
|
459 | + } |
|
442 | 460 | return ($a['start_timestamp'] < $b['start_timestamp']) ? -1 : 1; |
443 | 461 | }); |
444 | 462 | |
@@ -454,17 +472,19 @@ discard block |
||
454 | 472 | |
455 | 473 | echo '<div class="event_wrapper', $event['starts_today'] == true ? ' event_starts_today' : '', $event['ends_today'] == true ? ' event_ends_today' : '', $event['allday'] == true ? ' allday' : '', $event['is_selected'] ? ' sel_event' : '', '">', $event['link'], '<br><span class="event_time', empty($event_icons_needed) ? ' floatright' : '', '">'; |
456 | 474 | |
457 | - if (!empty($event['start_time_local']) && $event['starts_today'] == true) |
|
458 | - echo trim(str_replace(':00 ', ' ', $event['start_time_local'])); |
|
459 | - elseif (!empty($event['end_time_local']) && $event['ends_today'] == true) |
|
460 | - echo strtolower($txt['ends']), ' ', trim(str_replace(':00 ', ' ', $event['end_time_local'])); |
|
461 | - elseif (!empty($event['allday'])) |
|
462 | - echo $txt['calendar_allday']; |
|
475 | + if (!empty($event['start_time_local']) && $event['starts_today'] == true) { |
|
476 | + echo trim(str_replace(':00 ', ' ', $event['start_time_local'])); |
|
477 | + } elseif (!empty($event['end_time_local']) && $event['ends_today'] == true) { |
|
478 | + echo strtolower($txt['ends']), ' ', trim(str_replace(':00 ', ' ', $event['end_time_local'])); |
|
479 | + } elseif (!empty($event['allday'])) { |
|
480 | + echo $txt['calendar_allday']; |
|
481 | + } |
|
463 | 482 | |
464 | 483 | echo '</span>'; |
465 | 484 | |
466 | - if (!empty($event['location'])) |
|
467 | - echo '<br><span class="event_location', empty($event_icons_needed) ? ' floatright' : '', '">' . $event['location'] . '</span>'; |
|
485 | + if (!empty($event['location'])) { |
|
486 | + echo '<br><span class="event_location', empty($event_icons_needed) ? ' floatright' : '', '">' . $event['location'] . '</span>'; |
|
487 | + } |
|
468 | 488 | |
469 | 489 | if ($event['can_edit'] || $event['can_export']) |
470 | 490 | { |
@@ -501,10 +521,11 @@ discard block |
||
501 | 521 | // Otherwise, assuming it's not a mini-calendar, we can show previous / next month days! |
502 | 522 | elseif ($is_mini === false) |
503 | 523 | { |
504 | - if (empty($current_month_started) && !empty($context['calendar_grid_prev'])) |
|
505 | - echo '<a href="', $scripturl, '?action=calendar;year=', $context['calendar_grid_prev']['current_year'], ';month=', $context['calendar_grid_prev']['current_month'], '">', $context['calendar_grid_prev']['last_of_month'] - $calendar_data['shift']-- +1, '</a>'; |
|
506 | - elseif (!empty($current_month_started) && !empty($context['calendar_grid_next'])) |
|
507 | - echo '<a href="', $scripturl, '?action=calendar;year=', $context['calendar_grid_next']['current_year'], ';month=', $context['calendar_grid_next']['current_month'], '">', $current_month_started + 1 == $count ? (!empty($calendar_data['short_month_titles']) ? $txt['months_short'][$context['calendar_grid_next']['current_month']] . ' ' : $txt['months_titles'][$context['calendar_grid_next']['current_month']] . ' ') : '', $final_count++, '</a>'; |
|
524 | + if (empty($current_month_started) && !empty($context['calendar_grid_prev'])) { |
|
525 | + echo '<a href="', $scripturl, '?action=calendar;year=', $context['calendar_grid_prev']['current_year'], ';month=', $context['calendar_grid_prev']['current_month'], '">', $context['calendar_grid_prev']['last_of_month'] - $calendar_data['shift']-- +1, '</a>'; |
|
526 | + } elseif (!empty($current_month_started) && !empty($context['calendar_grid_next'])) { |
|
527 | + echo '<a href="', $scripturl, '?action=calendar;year=', $context['calendar_grid_next']['current_year'], ';month=', $context['calendar_grid_next']['current_month'], '">', $current_month_started + 1 == $count ? (!empty($calendar_data['short_month_titles']) ? $txt['months_short'][$context['calendar_grid_next']['current_month']] . ' ' : $txt['months_titles'][$context['calendar_grid_next']['current_month']] . ' ') : '', $final_count++, '</a>'; |
|
528 | + } |
|
508 | 529 | } |
509 | 530 | |
510 | 531 | // Close this day and increase var count. |
@@ -530,8 +551,9 @@ discard block |
||
530 | 551 | global $context, $txt, $scripturl, $modSettings; |
531 | 552 | |
532 | 553 | // We might have no reason to proceed, if the variable isn't there. |
533 | - if (!isset($context['calendar_grid_' . $grid_name])) |
|
534 | - return false; |
|
554 | + if (!isset($context['calendar_grid_' . $grid_name])) { |
|
555 | + return false; |
|
556 | + } |
|
535 | 557 | |
536 | 558 | // Handy pointer. |
537 | 559 | $calendar_data = &$context['calendar_grid_' . $grid_name]; |
@@ -566,8 +588,9 @@ discard block |
||
566 | 588 | } |
567 | 589 | |
568 | 590 | // The Month Title + Week Number... |
569 | - if (!empty($calendar_data['week_title'])) |
|
570 | - echo $calendar_data['week_title']; |
|
591 | + if (!empty($calendar_data['week_title'])) { |
|
592 | + echo $calendar_data['week_title']; |
|
593 | + } |
|
571 | 594 | |
572 | 595 | echo ' |
573 | 596 | </h3> |
@@ -606,10 +629,11 @@ discard block |
||
606 | 629 | <tr class="days_wrapper"> |
607 | 630 | <td class="', implode(' ', $classes), ' act_day">'; |
608 | 631 | // Should the day number be a link? |
609 | - if (!empty($modSettings['cal_daysaslink']) && $context['can_post']) |
|
610 | - echo '<a href="', $scripturl, '?action=calendar;sa=post;month=', $month_data['current_month'], ';year=', $month_data['current_year'], ';day=', $day['day'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['days'][$day['day_of_week']], ' - ', $day['day'], '</a>'; |
|
611 | - else |
|
612 | - echo $txt['days'][$day['day_of_week']], ' - ', $day['day']; |
|
632 | + if (!empty($modSettings['cal_daysaslink']) && $context['can_post']) { |
|
633 | + echo '<a href="', $scripturl, '?action=calendar;sa=post;month=', $month_data['current_month'], ';year=', $month_data['current_year'], ';day=', $day['day'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['days'][$day['day_of_week']], ' - ', $day['day'], '</a>'; |
|
634 | + } else { |
|
635 | + echo $txt['days'][$day['day_of_week']], ' - ', $day['day']; |
|
636 | + } |
|
613 | 637 | |
614 | 638 | echo '</td> |
615 | 639 | <td class="', implode(' ', $classes), '', empty($day['events']) ? (' disabled' . ($context['can_post'] ? ' week_post' : '')) : ' events', ' event_col" data-css-prefix="' . $txt['events'] . ' ', (empty($day['events']) && empty($context['can_post'])) ? $txt['none'] : '', '">'; |
@@ -618,8 +642,9 @@ discard block |
||
618 | 642 | { |
619 | 643 | // Sort events by start time (all day events will be listed first) |
620 | 644 | uasort($day['events'], function($a, $b) { |
621 | - if ($a['start_timestamp'] == $b['start_timestamp']) |
|
622 | - return 0; |
|
645 | + if ($a['start_timestamp'] == $b['start_timestamp']) { |
|
646 | + return 0; |
|
647 | + } |
|
623 | 648 | return ($a['start_timestamp'] < $b['start_timestamp']) ? -1 : 1; |
624 | 649 | }); |
625 | 650 | |
@@ -631,15 +656,17 @@ discard block |
||
631 | 656 | |
632 | 657 | echo $event['link'], '<br><span class="event_time', empty($event_icons_needed) ? ' floatright' : '', '">'; |
633 | 658 | |
634 | - if (!empty($event['start_time_local'])) |
|
635 | - echo trim($event['start_time_local']), !empty($event['end_time_local']) ? ' – ' . trim($event['end_time_local']) : ''; |
|
636 | - else |
|
637 | - echo $txt['calendar_allday']; |
|
659 | + if (!empty($event['start_time_local'])) { |
|
660 | + echo trim($event['start_time_local']), !empty($event['end_time_local']) ? ' – ' . trim($event['end_time_local']) : ''; |
|
661 | + } else { |
|
662 | + echo $txt['calendar_allday']; |
|
663 | + } |
|
638 | 664 | |
639 | 665 | echo '</span>'; |
640 | 666 | |
641 | - if (!empty($event['location'])) |
|
642 | - echo '<br><span class="event_location', empty($event_icons_needed) ? ' floatright' : '', '">' . $event['location'] . '</span>'; |
|
667 | + if (!empty($event['location'])) { |
|
668 | + echo '<br><span class="event_location', empty($event_icons_needed) ? ' floatright' : '', '">' . $event['location'] . '</span>'; |
|
669 | + } |
|
643 | 670 | |
644 | 671 | if (!empty($event_icons_needed)) |
645 | 672 | { |
@@ -676,8 +703,7 @@ discard block |
||
676 | 703 | </div> |
677 | 704 | <br class="clear">'; |
678 | 705 | } |
679 | - } |
|
680 | - else |
|
706 | + } else |
|
681 | 707 | { |
682 | 708 | if (!empty($context['can_post'])) |
683 | 709 | { |
@@ -690,8 +716,9 @@ discard block |
||
690 | 716 | echo '</td> |
691 | 717 | <td class="', implode(' ', $classes), !empty($day['holidays']) ? ' holidays' : ' disabled', ' holiday_col" data-css-prefix="' . $txt['calendar_prompt'] . ' ">'; |
692 | 718 | // Show any holidays! |
693 | - if (!empty($day['holidays'])) |
|
694 | - echo implode('<br>', $day['holidays']); |
|
719 | + if (!empty($day['holidays'])) { |
|
720 | + echo implode('<br>', $day['holidays']); |
|
721 | + } |
|
695 | 722 | |
696 | 723 | echo '</td> |
697 | 724 | <td class="', implode(' ', $classes), '', !empty($day['birthdays']) ? ' birthdays' : ' disabled', ' birthday_col" data-css-prefix="' . $txt['birthdays'] . ' ">'; |
@@ -749,8 +776,7 @@ discard block |
||
749 | 776 | <input type="text" name="end_date" id="end_date" maxlength="10" value="', $calendar_data['end_date'], '" tabindex="', $context['tabindex']++, '" class="input_text date_input end" data-type="date"> |
750 | 777 | <input type="submit" class="button_submit" style="float:none" id="view_button" value="', $txt['view'], '"> |
751 | 778 | </form>'; |
752 | - } |
|
753 | - else |
|
779 | + } else |
|
754 | 780 | { |
755 | 781 | echo' |
756 | 782 | <form action="', $scripturl, '?action=calendar" id="calendar_navigation" method="post" accept-charset="', $context['character_set'], '"> |
@@ -792,8 +818,9 @@ discard block |
||
792 | 818 | echo ' |
793 | 819 | <form action="', $scripturl, '?action=calendar;sa=post" method="post" name="postevent" accept-charset="', $context['character_set'], '" onsubmit="submitonce(this);smc_saveEntities(\'postevent\', [\'evtitle\']);" style="margin: 0;">'; |
794 | 820 | |
795 | - if (!empty($context['event']['new'])) |
|
796 | - echo '<input type="hidden" name="eventid" value="', $context['event']['eventid'], '">'; |
|
821 | + if (!empty($context['event']['new'])) { |
|
822 | + echo '<input type="hidden" name="eventid" value="', $context['event']['eventid'], '">'; |
|
823 | + } |
|
797 | 824 | |
798 | 825 | // Start the main table. |
799 | 826 | echo ' |
@@ -843,9 +870,10 @@ discard block |
||
843 | 870 | { |
844 | 871 | echo ' |
845 | 872 | <optgroup label="', $category['name'], '">'; |
846 | - foreach ($category['boards'] as $board) |
|
847 | - echo ' |
|
873 | + foreach ($category['boards'] as $board) { |
|
874 | + echo ' |
|
848 | 875 | <option value="', $board['id'], '"', $board['selected'] ? ' selected' : '', '>', $board['child_level'] > 0 ? str_repeat('==', $board['child_level'] - 1) . '=>' : '', ' ', $board['name'], ' </option>'; |
876 | + } |
|
849 | 877 | echo ' |
850 | 878 | </optgroup>'; |
851 | 879 | } |
@@ -881,9 +909,10 @@ discard block |
||
881 | 909 | <span class="label">', $txt['calendar_timezone'], '</span> |
882 | 910 | <select name="tz" id="tz"', !empty($context['event']['allday']) ? ' disabled' : '', '>'; |
883 | 911 | |
884 | - foreach ($context['all_timezones'] as $tz => $tzname) |
|
885 | - echo ' |
|
912 | + foreach ($context['all_timezones'] as $tz => $tzname) { |
|
913 | + echo ' |
|
886 | 914 | <option value="', $tz, '"', $tz == $context['event']['tz'] ? ' selected' : '', '>', $tzname, '</option>'; |
915 | + } |
|
887 | 916 | |
888 | 917 | echo ' |
889 | 918 | </select> |
@@ -898,9 +927,10 @@ discard block |
||
898 | 927 | echo ' |
899 | 928 | <input type="submit" value="', empty($context['event']['new']) ? $txt['save'] : $txt['post'], '" class="button_submit">'; |
900 | 929 | // Delete button? |
901 | - if (empty($context['event']['new'])) |
|
902 | - echo ' |
|
930 | + if (empty($context['event']['new'])) { |
|
931 | + echo ' |
|
903 | 932 | <input type="submit" name="deleteevent" value="', $txt['event_delete'], '" data-confirm="', $txt['calendar_confirm_delete'], '" class="button_submit you_sure">'; |
933 | + } |
|
904 | 934 | |
905 | 935 | echo ' |
906 | 936 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -944,9 +974,10 @@ discard block |
||
944 | 974 | |
945 | 975 | foreach ($context['clockicons'] as $t => $v) |
946 | 976 | { |
947 | - foreach ($v as $i) |
|
948 | - echo ' |
|
977 | + foreach ($v as $i) { |
|
978 | + echo ' |
|
949 | 979 | icons[\'', $t, '_', $i, '\'] = document.getElementById(\'', $t, '_', $i, '\');'; |
980 | + } |
|
950 | 981 | } |
951 | 982 | |
952 | 983 | echo ' |
@@ -971,13 +1002,14 @@ discard block |
||
971 | 1002 | |
972 | 1003 | foreach ($context['clockicons'] as $t => $v) |
973 | 1004 | { |
974 | - foreach ($v as $i) |
|
975 | - echo ' |
|
1005 | + foreach ($v as $i) { |
|
1006 | + echo ' |
|
976 | 1007 | if (', $t, ' >= ', $i, ') |
977 | 1008 | { |
978 | 1009 | turnon.push("', $t, '_', $i, '"); |
979 | 1010 | ', $t, ' -= ', $i, '; |
980 | 1011 | }'; |
1012 | + } |
|
981 | 1013 | } |
982 | 1014 | |
983 | 1015 | echo ' |
@@ -1041,9 +1073,10 @@ discard block |
||
1041 | 1073 | |
1042 | 1074 | foreach ($context['clockicons'] as $t => $v) |
1043 | 1075 | { |
1044 | - foreach ($v as $i) |
|
1045 | - echo ' |
|
1076 | + foreach ($v as $i) { |
|
1077 | + echo ' |
|
1046 | 1078 | icons[\'', $t, '_', $i, '\'] = document.getElementById(\'', $t, '_', $i, '\');'; |
1079 | + } |
|
1047 | 1080 | } |
1048 | 1081 | |
1049 | 1082 | echo ' |
@@ -1060,13 +1093,14 @@ discard block |
||
1060 | 1093 | |
1061 | 1094 | foreach ($context['clockicons'] as $t => $v) |
1062 | 1095 | { |
1063 | - foreach ($v as $i) |
|
1064 | - echo ' |
|
1096 | + foreach ($v as $i) { |
|
1097 | + echo ' |
|
1065 | 1098 | if (', $t, ' >= ', $i, ') |
1066 | 1099 | { |
1067 | 1100 | turnon.push("', $t, '_', $i, '"); |
1068 | 1101 | ', $t, ' -= ', $i, '; |
1069 | 1102 | }'; |
1103 | + } |
|
1070 | 1104 | } |
1071 | 1105 | |
1072 | 1106 | echo ' |
@@ -1125,9 +1159,10 @@ discard block |
||
1125 | 1159 | |
1126 | 1160 | foreach ($context['clockicons'] as $t => $v) |
1127 | 1161 | { |
1128 | - foreach ($v as $i) |
|
1129 | - echo ' |
|
1162 | + foreach ($v as $i) { |
|
1163 | + echo ' |
|
1130 | 1164 | icons[\'', $t, '_', $i, '\'] = document.getElementById(\'', $t, '_', $i, '\');'; |
1165 | + } |
|
1131 | 1166 | } |
1132 | 1167 | |
1133 | 1168 | echo ' |
@@ -1148,13 +1183,14 @@ discard block |
||
1148 | 1183 | |
1149 | 1184 | foreach ($context['clockicons'] as $t => $v) |
1150 | 1185 | { |
1151 | - foreach ($v as $i) |
|
1152 | - echo ' |
|
1186 | + foreach ($v as $i) { |
|
1187 | + echo ' |
|
1153 | 1188 | if (', $t, ' >= ', $i, ') |
1154 | 1189 | { |
1155 | 1190 | turnon.push("', $t, '_', $i, '"); |
1156 | 1191 | ', $t, ' -= ', $i, '; |
1157 | 1192 | }'; |
1193 | + } |
|
1158 | 1194 | } |
1159 | 1195 | |
1160 | 1196 | echo ' |
@@ -388,6 +388,9 @@ discard block |
||
388 | 388 | } |
389 | 389 | |
390 | 390 | // Used to direct the user to another location. |
391 | +/** |
|
392 | + * @param string $location |
|
393 | + */ |
|
391 | 394 | function redirectLocation($location, $addForm = true) |
392 | 395 | { |
393 | 396 | global $upgradeurl, $upcontext, $command_line; |
@@ -1560,6 +1563,9 @@ discard block |
||
1560 | 1563 | return addslashes(preg_replace(array('~^\.([/\\\]|$)~', '~[/]+~', '~[\\\]+~', '~[/\\\]$~'), array($install_path . '$1', '/', '\\', ''), $path)); |
1561 | 1564 | } |
1562 | 1565 | |
1566 | +/** |
|
1567 | + * @param string $filename |
|
1568 | + */ |
|
1563 | 1569 | function parse_sql($filename) |
1564 | 1570 | { |
1565 | 1571 | global $db_prefix, $db_collation, $boarddir, $boardurl, $command_line, $file_steps, $step_progress, $custom_warning; |
@@ -1594,6 +1600,10 @@ discard block |
||
1594 | 1600 | |
1595 | 1601 | // Our custom error handler - does nothing but does stop public errors from XML! |
1596 | 1602 | set_error_handler( |
1603 | + |
|
1604 | + /** |
|
1605 | + * @param string $errno |
|
1606 | + */ |
|
1597 | 1607 | function ($errno, $errstr, $errfile, $errline) use ($support_js) |
1598 | 1608 | { |
1599 | 1609 | if ($support_js) |
@@ -1840,6 +1850,9 @@ discard block |
||
1840 | 1850 | return true; |
1841 | 1851 | } |
1842 | 1852 | |
1853 | +/** |
|
1854 | + * @param string $string |
|
1855 | + */ |
|
1843 | 1856 | function upgrade_query($string, $unbuffered = false) |
1844 | 1857 | { |
1845 | 1858 | global $db_connection, $db_server, $db_user, $db_passwd, $db_type, $command_line, $upcontext, $upgradeurl, $modSettings; |
@@ -4495,7 +4508,7 @@ discard block |
||
4495 | 4508 | * @param int $setSize The amount of entries after which to update the database. |
4496 | 4509 | * |
4497 | 4510 | * newCol needs to be a varbinary(16) null able field |
4498 | - * @return bool |
|
4511 | + * @return boolean|null |
|
4499 | 4512 | */ |
4500 | 4513 | function MySQLConvertOldIp($targetTable, $oldCol, $newCol, $limit = 50000, $setSize = 100) |
4501 | 4514 | { |
@@ -82,7 +82,7 @@ |
||
82 | 82 | |
83 | 83 | // The helper is crucial. Include it first thing. |
84 | 84 | if (!file_exists($upgrade_path . '/upgrade-helper.php')) |
85 | - die('upgrade-helper.php not found where it was expected: ' . $upgrade_path . '/upgrade-helper.php! Make sure you have uploaded ALL files from the upgrade package. The upgrader cannot continue.'); |
|
85 | + die('upgrade-helper.php not found where it was expected: ' . $upgrade_path . '/upgrade-helper.php! Make sure you have uploaded ALL files from the upgrade package. The upgrader cannot continue.'); |
|
86 | 86 | |
87 | 87 | require_once($upgrade_path . '/upgrade-helper.php'); |
88 | 88 |
@@ -1610,7 +1610,7 @@ discard block |
||
1610 | 1610 | |
1611 | 1611 | // Our custom error handler - does nothing but does stop public errors from XML! |
1612 | 1612 | set_error_handler( |
1613 | - function ($errno, $errstr, $errfile, $errline) use ($support_js) |
|
1613 | + function($errno, $errstr, $errfile, $errline) use ($support_js) |
|
1614 | 1614 | { |
1615 | 1615 | if ($support_js) |
1616 | 1616 | return true; |
@@ -2595,94 +2595,94 @@ discard block |
||
2595 | 2595 | // Translation table for the character sets not native for MySQL. |
2596 | 2596 | $translation_tables = array( |
2597 | 2597 | 'windows-1255' => array( |
2598 | - '0x81' => '\'\'', '0x8A' => '\'\'', '0x8C' => '\'\'', |
|
2599 | - '0x8D' => '\'\'', '0x8E' => '\'\'', '0x8F' => '\'\'', |
|
2600 | - '0x90' => '\'\'', '0x9A' => '\'\'', '0x9C' => '\'\'', |
|
2601 | - '0x9D' => '\'\'', '0x9E' => '\'\'', '0x9F' => '\'\'', |
|
2602 | - '0xCA' => '\'\'', '0xD9' => '\'\'', '0xDA' => '\'\'', |
|
2603 | - '0xDB' => '\'\'', '0xDC' => '\'\'', '0xDD' => '\'\'', |
|
2604 | - '0xDE' => '\'\'', '0xDF' => '\'\'', '0xFB' => '0xD792', |
|
2605 | - '0xFC' => '0xE282AC', '0xFF' => '0xD6B2', '0xC2' => '0xFF', |
|
2606 | - '0x80' => '0xFC', '0xE2' => '0xFB', '0xA0' => '0xC2A0', |
|
2607 | - '0xA1' => '0xC2A1', '0xA2' => '0xC2A2', '0xA3' => '0xC2A3', |
|
2608 | - '0xA5' => '0xC2A5', '0xA6' => '0xC2A6', '0xA7' => '0xC2A7', |
|
2609 | - '0xA8' => '0xC2A8', '0xA9' => '0xC2A9', '0xAB' => '0xC2AB', |
|
2610 | - '0xAC' => '0xC2AC', '0xAD' => '0xC2AD', '0xAE' => '0xC2AE', |
|
2611 | - '0xAF' => '0xC2AF', '0xB0' => '0xC2B0', '0xB1' => '0xC2B1', |
|
2612 | - '0xB2' => '0xC2B2', '0xB3' => '0xC2B3', '0xB4' => '0xC2B4', |
|
2613 | - '0xB5' => '0xC2B5', '0xB6' => '0xC2B6', '0xB7' => '0xC2B7', |
|
2614 | - '0xB8' => '0xC2B8', '0xB9' => '0xC2B9', '0xBB' => '0xC2BB', |
|
2615 | - '0xBC' => '0xC2BC', '0xBD' => '0xC2BD', '0xBE' => '0xC2BE', |
|
2616 | - '0xBF' => '0xC2BF', '0xD7' => '0xD7B3', '0xD1' => '0xD781', |
|
2617 | - '0xD4' => '0xD7B0', '0xD5' => '0xD7B1', '0xD6' => '0xD7B2', |
|
2618 | - '0xE0' => '0xD790', '0xEA' => '0xD79A', '0xEC' => '0xD79C', |
|
2619 | - '0xED' => '0xD79D', '0xEE' => '0xD79E', '0xEF' => '0xD79F', |
|
2620 | - '0xF0' => '0xD7A0', '0xF1' => '0xD7A1', '0xF2' => '0xD7A2', |
|
2621 | - '0xF3' => '0xD7A3', '0xF5' => '0xD7A5', '0xF6' => '0xD7A6', |
|
2622 | - '0xF7' => '0xD7A7', '0xF8' => '0xD7A8', '0xF9' => '0xD7A9', |
|
2623 | - '0x82' => '0xE2809A', '0x84' => '0xE2809E', '0x85' => '0xE280A6', |
|
2624 | - '0x86' => '0xE280A0', '0x87' => '0xE280A1', '0x89' => '0xE280B0', |
|
2625 | - '0x8B' => '0xE280B9', '0x93' => '0xE2809C', '0x94' => '0xE2809D', |
|
2626 | - '0x95' => '0xE280A2', '0x97' => '0xE28094', '0x99' => '0xE284A2', |
|
2627 | - '0xC0' => '0xD6B0', '0xC1' => '0xD6B1', '0xC3' => '0xD6B3', |
|
2628 | - '0xC4' => '0xD6B4', '0xC5' => '0xD6B5', '0xC6' => '0xD6B6', |
|
2629 | - '0xC7' => '0xD6B7', '0xC8' => '0xD6B8', '0xC9' => '0xD6B9', |
|
2630 | - '0xCB' => '0xD6BB', '0xCC' => '0xD6BC', '0xCD' => '0xD6BD', |
|
2631 | - '0xCE' => '0xD6BE', '0xCF' => '0xD6BF', '0xD0' => '0xD780', |
|
2632 | - '0xD2' => '0xD782', '0xE3' => '0xD793', '0xE4' => '0xD794', |
|
2633 | - '0xE5' => '0xD795', '0xE7' => '0xD797', '0xE9' => '0xD799', |
|
2634 | - '0xFD' => '0xE2808E', '0xFE' => '0xE2808F', '0x92' => '0xE28099', |
|
2635 | - '0x83' => '0xC692', '0xD3' => '0xD783', '0x88' => '0xCB86', |
|
2636 | - '0x98' => '0xCB9C', '0x91' => '0xE28098', '0x96' => '0xE28093', |
|
2637 | - '0xBA' => '0xC3B7', '0x9B' => '0xE280BA', '0xAA' => '0xC397', |
|
2638 | - '0xA4' => '0xE282AA', '0xE1' => '0xD791', '0xE6' => '0xD796', |
|
2639 | - '0xE8' => '0xD798', '0xEB' => '0xD79B', '0xF4' => '0xD7A4', |
|
2598 | + '0x81' => '\'\'', '0x8A' => '\'\'', '0x8C' => '\'\'', |
|
2599 | + '0x8D' => '\'\'', '0x8E' => '\'\'', '0x8F' => '\'\'', |
|
2600 | + '0x90' => '\'\'', '0x9A' => '\'\'', '0x9C' => '\'\'', |
|
2601 | + '0x9D' => '\'\'', '0x9E' => '\'\'', '0x9F' => '\'\'', |
|
2602 | + '0xCA' => '\'\'', '0xD9' => '\'\'', '0xDA' => '\'\'', |
|
2603 | + '0xDB' => '\'\'', '0xDC' => '\'\'', '0xDD' => '\'\'', |
|
2604 | + '0xDE' => '\'\'', '0xDF' => '\'\'', '0xFB' => '0xD792', |
|
2605 | + '0xFC' => '0xE282AC', '0xFF' => '0xD6B2', '0xC2' => '0xFF', |
|
2606 | + '0x80' => '0xFC', '0xE2' => '0xFB', '0xA0' => '0xC2A0', |
|
2607 | + '0xA1' => '0xC2A1', '0xA2' => '0xC2A2', '0xA3' => '0xC2A3', |
|
2608 | + '0xA5' => '0xC2A5', '0xA6' => '0xC2A6', '0xA7' => '0xC2A7', |
|
2609 | + '0xA8' => '0xC2A8', '0xA9' => '0xC2A9', '0xAB' => '0xC2AB', |
|
2610 | + '0xAC' => '0xC2AC', '0xAD' => '0xC2AD', '0xAE' => '0xC2AE', |
|
2611 | + '0xAF' => '0xC2AF', '0xB0' => '0xC2B0', '0xB1' => '0xC2B1', |
|
2612 | + '0xB2' => '0xC2B2', '0xB3' => '0xC2B3', '0xB4' => '0xC2B4', |
|
2613 | + '0xB5' => '0xC2B5', '0xB6' => '0xC2B6', '0xB7' => '0xC2B7', |
|
2614 | + '0xB8' => '0xC2B8', '0xB9' => '0xC2B9', '0xBB' => '0xC2BB', |
|
2615 | + '0xBC' => '0xC2BC', '0xBD' => '0xC2BD', '0xBE' => '0xC2BE', |
|
2616 | + '0xBF' => '0xC2BF', '0xD7' => '0xD7B3', '0xD1' => '0xD781', |
|
2617 | + '0xD4' => '0xD7B0', '0xD5' => '0xD7B1', '0xD6' => '0xD7B2', |
|
2618 | + '0xE0' => '0xD790', '0xEA' => '0xD79A', '0xEC' => '0xD79C', |
|
2619 | + '0xED' => '0xD79D', '0xEE' => '0xD79E', '0xEF' => '0xD79F', |
|
2620 | + '0xF0' => '0xD7A0', '0xF1' => '0xD7A1', '0xF2' => '0xD7A2', |
|
2621 | + '0xF3' => '0xD7A3', '0xF5' => '0xD7A5', '0xF6' => '0xD7A6', |
|
2622 | + '0xF7' => '0xD7A7', '0xF8' => '0xD7A8', '0xF9' => '0xD7A9', |
|
2623 | + '0x82' => '0xE2809A', '0x84' => '0xE2809E', '0x85' => '0xE280A6', |
|
2624 | + '0x86' => '0xE280A0', '0x87' => '0xE280A1', '0x89' => '0xE280B0', |
|
2625 | + '0x8B' => '0xE280B9', '0x93' => '0xE2809C', '0x94' => '0xE2809D', |
|
2626 | + '0x95' => '0xE280A2', '0x97' => '0xE28094', '0x99' => '0xE284A2', |
|
2627 | + '0xC0' => '0xD6B0', '0xC1' => '0xD6B1', '0xC3' => '0xD6B3', |
|
2628 | + '0xC4' => '0xD6B4', '0xC5' => '0xD6B5', '0xC6' => '0xD6B6', |
|
2629 | + '0xC7' => '0xD6B7', '0xC8' => '0xD6B8', '0xC9' => '0xD6B9', |
|
2630 | + '0xCB' => '0xD6BB', '0xCC' => '0xD6BC', '0xCD' => '0xD6BD', |
|
2631 | + '0xCE' => '0xD6BE', '0xCF' => '0xD6BF', '0xD0' => '0xD780', |
|
2632 | + '0xD2' => '0xD782', '0xE3' => '0xD793', '0xE4' => '0xD794', |
|
2633 | + '0xE5' => '0xD795', '0xE7' => '0xD797', '0xE9' => '0xD799', |
|
2634 | + '0xFD' => '0xE2808E', '0xFE' => '0xE2808F', '0x92' => '0xE28099', |
|
2635 | + '0x83' => '0xC692', '0xD3' => '0xD783', '0x88' => '0xCB86', |
|
2636 | + '0x98' => '0xCB9C', '0x91' => '0xE28098', '0x96' => '0xE28093', |
|
2637 | + '0xBA' => '0xC3B7', '0x9B' => '0xE280BA', '0xAA' => '0xC397', |
|
2638 | + '0xA4' => '0xE282AA', '0xE1' => '0xD791', '0xE6' => '0xD796', |
|
2639 | + '0xE8' => '0xD798', '0xEB' => '0xD79B', '0xF4' => '0xD7A4', |
|
2640 | 2640 | '0xFA' => '0xD7AA', |
2641 | 2641 | ), |
2642 | 2642 | 'windows-1253' => array( |
2643 | - '0x81' => '\'\'', '0x88' => '\'\'', '0x8A' => '\'\'', |
|
2644 | - '0x8C' => '\'\'', '0x8D' => '\'\'', '0x8E' => '\'\'', |
|
2645 | - '0x8F' => '\'\'', '0x90' => '\'\'', '0x98' => '\'\'', |
|
2646 | - '0x9A' => '\'\'', '0x9C' => '\'\'', '0x9D' => '\'\'', |
|
2647 | - '0x9E' => '\'\'', '0x9F' => '\'\'', '0xAA' => '\'\'', |
|
2648 | - '0xD2' => '0xE282AC', '0xFF' => '0xCE92', '0xCE' => '0xCE9E', |
|
2649 | - '0xB8' => '0xCE88', '0xBA' => '0xCE8A', '0xBC' => '0xCE8C', |
|
2650 | - '0xBE' => '0xCE8E', '0xBF' => '0xCE8F', '0xC0' => '0xCE90', |
|
2651 | - '0xC8' => '0xCE98', '0xCA' => '0xCE9A', '0xCC' => '0xCE9C', |
|
2652 | - '0xCD' => '0xCE9D', '0xCF' => '0xCE9F', '0xDA' => '0xCEAA', |
|
2653 | - '0xE8' => '0xCEB8', '0xEA' => '0xCEBA', '0xEC' => '0xCEBC', |
|
2654 | - '0xEE' => '0xCEBE', '0xEF' => '0xCEBF', '0xC2' => '0xFF', |
|
2655 | - '0xBD' => '0xC2BD', '0xED' => '0xCEBD', '0xB2' => '0xC2B2', |
|
2656 | - '0xA0' => '0xC2A0', '0xA3' => '0xC2A3', '0xA4' => '0xC2A4', |
|
2657 | - '0xA5' => '0xC2A5', '0xA6' => '0xC2A6', '0xA7' => '0xC2A7', |
|
2658 | - '0xA8' => '0xC2A8', '0xA9' => '0xC2A9', '0xAB' => '0xC2AB', |
|
2659 | - '0xAC' => '0xC2AC', '0xAD' => '0xC2AD', '0xAE' => '0xC2AE', |
|
2660 | - '0xB0' => '0xC2B0', '0xB1' => '0xC2B1', '0xB3' => '0xC2B3', |
|
2661 | - '0xB5' => '0xC2B5', '0xB6' => '0xC2B6', '0xB7' => '0xC2B7', |
|
2662 | - '0xBB' => '0xC2BB', '0xE2' => '0xCEB2', '0x80' => '0xD2', |
|
2663 | - '0x82' => '0xE2809A', '0x84' => '0xE2809E', '0x85' => '0xE280A6', |
|
2664 | - '0x86' => '0xE280A0', '0xA1' => '0xCE85', '0xA2' => '0xCE86', |
|
2665 | - '0x87' => '0xE280A1', '0x89' => '0xE280B0', '0xB9' => '0xCE89', |
|
2666 | - '0x8B' => '0xE280B9', '0x91' => '0xE28098', '0x99' => '0xE284A2', |
|
2667 | - '0x92' => '0xE28099', '0x93' => '0xE2809C', '0x94' => '0xE2809D', |
|
2668 | - '0x95' => '0xE280A2', '0x96' => '0xE28093', '0x97' => '0xE28094', |
|
2669 | - '0x9B' => '0xE280BA', '0xAF' => '0xE28095', '0xB4' => '0xCE84', |
|
2670 | - '0xC1' => '0xCE91', '0xC3' => '0xCE93', '0xC4' => '0xCE94', |
|
2671 | - '0xC5' => '0xCE95', '0xC6' => '0xCE96', '0x83' => '0xC692', |
|
2672 | - '0xC7' => '0xCE97', '0xC9' => '0xCE99', '0xCB' => '0xCE9B', |
|
2673 | - '0xD0' => '0xCEA0', '0xD1' => '0xCEA1', '0xD3' => '0xCEA3', |
|
2674 | - '0xD4' => '0xCEA4', '0xD5' => '0xCEA5', '0xD6' => '0xCEA6', |
|
2675 | - '0xD7' => '0xCEA7', '0xD8' => '0xCEA8', '0xD9' => '0xCEA9', |
|
2676 | - '0xDB' => '0xCEAB', '0xDC' => '0xCEAC', '0xDD' => '0xCEAD', |
|
2677 | - '0xDE' => '0xCEAE', '0xDF' => '0xCEAF', '0xE0' => '0xCEB0', |
|
2678 | - '0xE1' => '0xCEB1', '0xE3' => '0xCEB3', '0xE4' => '0xCEB4', |
|
2679 | - '0xE5' => '0xCEB5', '0xE6' => '0xCEB6', '0xE7' => '0xCEB7', |
|
2680 | - '0xE9' => '0xCEB9', '0xEB' => '0xCEBB', '0xF0' => '0xCF80', |
|
2681 | - '0xF1' => '0xCF81', '0xF2' => '0xCF82', '0xF3' => '0xCF83', |
|
2682 | - '0xF4' => '0xCF84', '0xF5' => '0xCF85', '0xF6' => '0xCF86', |
|
2683 | - '0xF7' => '0xCF87', '0xF8' => '0xCF88', '0xF9' => '0xCF89', |
|
2684 | - '0xFA' => '0xCF8A', '0xFB' => '0xCF8B', '0xFC' => '0xCF8C', |
|
2685 | - '0xFD' => '0xCF8D', '0xFE' => '0xCF8E', |
|
2643 | + '0x81' => '\'\'', '0x88' => '\'\'', '0x8A' => '\'\'', |
|
2644 | + '0x8C' => '\'\'', '0x8D' => '\'\'', '0x8E' => '\'\'', |
|
2645 | + '0x8F' => '\'\'', '0x90' => '\'\'', '0x98' => '\'\'', |
|
2646 | + '0x9A' => '\'\'', '0x9C' => '\'\'', '0x9D' => '\'\'', |
|
2647 | + '0x9E' => '\'\'', '0x9F' => '\'\'', '0xAA' => '\'\'', |
|
2648 | + '0xD2' => '0xE282AC', '0xFF' => '0xCE92', '0xCE' => '0xCE9E', |
|
2649 | + '0xB8' => '0xCE88', '0xBA' => '0xCE8A', '0xBC' => '0xCE8C', |
|
2650 | + '0xBE' => '0xCE8E', '0xBF' => '0xCE8F', '0xC0' => '0xCE90', |
|
2651 | + '0xC8' => '0xCE98', '0xCA' => '0xCE9A', '0xCC' => '0xCE9C', |
|
2652 | + '0xCD' => '0xCE9D', '0xCF' => '0xCE9F', '0xDA' => '0xCEAA', |
|
2653 | + '0xE8' => '0xCEB8', '0xEA' => '0xCEBA', '0xEC' => '0xCEBC', |
|
2654 | + '0xEE' => '0xCEBE', '0xEF' => '0xCEBF', '0xC2' => '0xFF', |
|
2655 | + '0xBD' => '0xC2BD', '0xED' => '0xCEBD', '0xB2' => '0xC2B2', |
|
2656 | + '0xA0' => '0xC2A0', '0xA3' => '0xC2A3', '0xA4' => '0xC2A4', |
|
2657 | + '0xA5' => '0xC2A5', '0xA6' => '0xC2A6', '0xA7' => '0xC2A7', |
|
2658 | + '0xA8' => '0xC2A8', '0xA9' => '0xC2A9', '0xAB' => '0xC2AB', |
|
2659 | + '0xAC' => '0xC2AC', '0xAD' => '0xC2AD', '0xAE' => '0xC2AE', |
|
2660 | + '0xB0' => '0xC2B0', '0xB1' => '0xC2B1', '0xB3' => '0xC2B3', |
|
2661 | + '0xB5' => '0xC2B5', '0xB6' => '0xC2B6', '0xB7' => '0xC2B7', |
|
2662 | + '0xBB' => '0xC2BB', '0xE2' => '0xCEB2', '0x80' => '0xD2', |
|
2663 | + '0x82' => '0xE2809A', '0x84' => '0xE2809E', '0x85' => '0xE280A6', |
|
2664 | + '0x86' => '0xE280A0', '0xA1' => '0xCE85', '0xA2' => '0xCE86', |
|
2665 | + '0x87' => '0xE280A1', '0x89' => '0xE280B0', '0xB9' => '0xCE89', |
|
2666 | + '0x8B' => '0xE280B9', '0x91' => '0xE28098', '0x99' => '0xE284A2', |
|
2667 | + '0x92' => '0xE28099', '0x93' => '0xE2809C', '0x94' => '0xE2809D', |
|
2668 | + '0x95' => '0xE280A2', '0x96' => '0xE28093', '0x97' => '0xE28094', |
|
2669 | + '0x9B' => '0xE280BA', '0xAF' => '0xE28095', '0xB4' => '0xCE84', |
|
2670 | + '0xC1' => '0xCE91', '0xC3' => '0xCE93', '0xC4' => '0xCE94', |
|
2671 | + '0xC5' => '0xCE95', '0xC6' => '0xCE96', '0x83' => '0xC692', |
|
2672 | + '0xC7' => '0xCE97', '0xC9' => '0xCE99', '0xCB' => '0xCE9B', |
|
2673 | + '0xD0' => '0xCEA0', '0xD1' => '0xCEA1', '0xD3' => '0xCEA3', |
|
2674 | + '0xD4' => '0xCEA4', '0xD5' => '0xCEA5', '0xD6' => '0xCEA6', |
|
2675 | + '0xD7' => '0xCEA7', '0xD8' => '0xCEA8', '0xD9' => '0xCEA9', |
|
2676 | + '0xDB' => '0xCEAB', '0xDC' => '0xCEAC', '0xDD' => '0xCEAD', |
|
2677 | + '0xDE' => '0xCEAE', '0xDF' => '0xCEAF', '0xE0' => '0xCEB0', |
|
2678 | + '0xE1' => '0xCEB1', '0xE3' => '0xCEB3', '0xE4' => '0xCEB4', |
|
2679 | + '0xE5' => '0xCEB5', '0xE6' => '0xCEB6', '0xE7' => '0xCEB7', |
|
2680 | + '0xE9' => '0xCEB9', '0xEB' => '0xCEBB', '0xF0' => '0xCF80', |
|
2681 | + '0xF1' => '0xCF81', '0xF2' => '0xCF82', '0xF3' => '0xCF83', |
|
2682 | + '0xF4' => '0xCF84', '0xF5' => '0xCF85', '0xF6' => '0xCF86', |
|
2683 | + '0xF7' => '0xCF87', '0xF8' => '0xCF88', '0xF9' => '0xCF89', |
|
2684 | + '0xFA' => '0xCF8A', '0xFB' => '0xCF8B', '0xFC' => '0xCF8C', |
|
2685 | + '0xFD' => '0xCF8D', '0xFE' => '0xCF8E', |
|
2686 | 2686 | ), |
2687 | 2687 | ); |
2688 | 2688 | |
@@ -3781,7 +3781,7 @@ discard block |
||
3781 | 3781 | <form action="', $upcontext['form_url'], '" name="upform" id="upform" method="post"> |
3782 | 3782 | <input type="hidden" name="backup_done" id="backup_done" value="0"> |
3783 | 3783 | <strong>Completed <span id="tab_done">', $upcontext['cur_table_num'], '</span> out of ', $upcontext['table_count'], ' tables.</strong> |
3784 | - <div id="debug_section" style="height: ', ($is_debug ? '115' : '12') , 'px; overflow: auto;"> |
|
3784 | + <div id="debug_section" style="height: ', ($is_debug ? '115' : '12'), 'px; overflow: auto;"> |
|
3785 | 3785 | <span id="debuginfo"></span> |
3786 | 3786 | </div>'; |
3787 | 3787 | |
@@ -4282,7 +4282,7 @@ discard block |
||
4282 | 4282 | <form action="', $upcontext['form_url'], '" name="upform" id="upform" method="post"> |
4283 | 4283 | <input type="hidden" name="utf8_done" id="utf8_done" value="0"> |
4284 | 4284 | <strong>Completed <span id="tab_done">', $upcontext['cur_table_num'], '</span> out of ', $upcontext['table_count'], ' tables.</strong> |
4285 | - <div id="debug_section" style="height: ', ($is_debug ? '115' : '12') , 'px; overflow: auto;"> |
|
4285 | + <div id="debug_section" style="height: ', ($is_debug ? '115' : '12'), 'px; overflow: auto;"> |
|
4286 | 4286 | <span id="debuginfo"></span> |
4287 | 4287 | </div>'; |
4288 | 4288 | |
@@ -4379,7 +4379,7 @@ discard block |
||
4379 | 4379 | <form action="', $upcontext['form_url'], '" name="upform" id="upform" method="post"> |
4380 | 4380 | <input type="hidden" name="json_done" id="json_done" value="0"> |
4381 | 4381 | <strong>Completed <span id="tab_done">', $upcontext['cur_table_num'], '</span> out of ', $upcontext['table_count'], ' tables.</strong> |
4382 | - <div id="debug_section" style="height: ', ($is_debug ? '115' : '12') , 'px; overflow: auto;"> |
|
4382 | + <div id="debug_section" style="height: ', ($is_debug ? '115' : '12'), 'px; overflow: auto;"> |
|
4383 | 4383 | <span id="debuginfo"></span> |
4384 | 4384 | </div>'; |
4385 | 4385 |
@@ -75,8 +75,9 @@ discard block |
||
75 | 75 | $upcontext['inactive_timeout'] = 10; |
76 | 76 | |
77 | 77 | // The helper is crucial. Include it first thing. |
78 | -if (!file_exists($upgrade_path . '/upgrade-helper.php')) |
|
78 | +if (!file_exists($upgrade_path . '/upgrade-helper.php')) { |
|
79 | 79 | die('upgrade-helper.php not found where it was expected: ' . $upgrade_path . '/upgrade-helper.php! Make sure you have uploaded ALL files from the upgrade package. The upgrader cannot continue.'); |
80 | +} |
|
80 | 81 | |
81 | 82 | require_once($upgrade_path . '/upgrade-helper.php'); |
82 | 83 | |
@@ -100,11 +101,14 @@ discard block |
||
100 | 101 | ini_set('default_socket_timeout', 900); |
101 | 102 | } |
102 | 103 | // Clean the upgrade path if this is from the client. |
103 | -if (!empty($_SERVER['argv']) && php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR'])) |
|
104 | - for ($i = 1; $i < $_SERVER['argc']; $i++) |
|
104 | +if (!empty($_SERVER['argv']) && php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR'])) { |
|
105 | + for ($i = 1; |
|
106 | +} |
|
107 | +$i < $_SERVER['argc']; $i++) |
|
105 | 108 | { |
106 | - if (preg_match('~^--path=(.+)$~', $_SERVER['argv'][$i], $match) != 0) |
|
107 | - $upgrade_path = substr($match[1], -1) == '/' ? substr($match[1], 0, -1) : $match[1]; |
|
109 | + if (preg_match('~^--path=(.+)$~', $_SERVER['argv'][$i], $match) != 0) { |
|
110 | + $upgrade_path = substr($match[1], -1) == '/' ? substr($match[1], 0, -1) : $match[1]; |
|
111 | + } |
|
108 | 112 | } |
109 | 113 | |
110 | 114 | // Are we from the client? |
@@ -112,16 +116,17 @@ discard block |
||
112 | 116 | { |
113 | 117 | $command_line = true; |
114 | 118 | $disable_security = true; |
115 | -} |
|
116 | -else |
|
119 | +} else { |
|
117 | 120 | $command_line = false; |
121 | +} |
|
118 | 122 | |
119 | 123 | // Load this now just because we can. |
120 | 124 | require_once($upgrade_path . '/Settings.php'); |
121 | 125 | |
122 | 126 | // We don't use "-utf8" anymore... Tweak the entry that may have been loaded by Settings.php |
123 | -if (isset($language)) |
|
127 | +if (isset($language)) { |
|
124 | 128 | $language = str_ireplace('-utf8', '', $language); |
129 | +} |
|
125 | 130 | |
126 | 131 | // Are we logged in? |
127 | 132 | if (isset($upgradeData)) |
@@ -129,10 +134,12 @@ discard block |
||
129 | 134 | $upcontext['user'] = json_decode(base64_decode($upgradeData), true); |
130 | 135 | |
131 | 136 | // Check for sensible values. |
132 | - if (empty($upcontext['user']['started']) || $upcontext['user']['started'] < time() - 86400) |
|
133 | - $upcontext['user']['started'] = time(); |
|
134 | - if (empty($upcontext['user']['updated']) || $upcontext['user']['updated'] < time() - 86400) |
|
135 | - $upcontext['user']['updated'] = 0; |
|
137 | + if (empty($upcontext['user']['started']) || $upcontext['user']['started'] < time() - 86400) { |
|
138 | + $upcontext['user']['started'] = time(); |
|
139 | + } |
|
140 | + if (empty($upcontext['user']['updated']) || $upcontext['user']['updated'] < time() - 86400) { |
|
141 | + $upcontext['user']['updated'] = 0; |
|
142 | + } |
|
136 | 143 | |
137 | 144 | $upcontext['started'] = $upcontext['user']['started']; |
138 | 145 | $upcontext['updated'] = $upcontext['user']['updated']; |
@@ -190,8 +197,9 @@ discard block |
||
190 | 197 | 'db_error_skip' => true, |
191 | 198 | ) |
192 | 199 | ); |
193 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
194 | - $modSettings[$row['variable']] = $row['value']; |
|
200 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
201 | + $modSettings[$row['variable']] = $row['value']; |
|
202 | + } |
|
195 | 203 | $smcFunc['db_free_result']($request); |
196 | 204 | } |
197 | 205 | |
@@ -201,10 +209,12 @@ discard block |
||
201 | 209 | $modSettings['theme_url'] = 'Themes/default'; |
202 | 210 | $modSettings['images_url'] = 'Themes/default/images'; |
203 | 211 | } |
204 | -if (!isset($settings['default_theme_url'])) |
|
212 | +if (!isset($settings['default_theme_url'])) { |
|
205 | 213 | $settings['default_theme_url'] = $modSettings['theme_url']; |
206 | -if (!isset($settings['default_theme_dir'])) |
|
214 | +} |
|
215 | +if (!isset($settings['default_theme_dir'])) { |
|
207 | 216 | $settings['default_theme_dir'] = $modSettings['theme_dir']; |
217 | +} |
|
208 | 218 | |
209 | 219 | $upcontext['is_large_forum'] = (empty($modSettings['smfVersion']) || $modSettings['smfVersion'] <= '1.1 RC1') && !empty($modSettings['totalMessages']) && $modSettings['totalMessages'] > 75000; |
210 | 220 | // Default title... |
@@ -222,13 +232,15 @@ discard block |
||
222 | 232 | $support_js = $upcontext['upgrade_status']['js']; |
223 | 233 | |
224 | 234 | // Only set this if the upgrader status says so. |
225 | - if (empty($is_debug)) |
|
226 | - $is_debug = $upcontext['upgrade_status']['debug']; |
|
235 | + if (empty($is_debug)) { |
|
236 | + $is_debug = $upcontext['upgrade_status']['debug']; |
|
237 | + } |
|
227 | 238 | |
228 | 239 | // Load the language. |
229 | - if (file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) |
|
230 | - require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
231 | -} |
|
240 | + if (file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) { |
|
241 | + require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
242 | + } |
|
243 | + } |
|
232 | 244 | // Set the defaults. |
233 | 245 | else |
234 | 246 | { |
@@ -246,15 +258,18 @@ discard block |
||
246 | 258 | } |
247 | 259 | |
248 | 260 | // If this isn't the first stage see whether they are logging in and resuming. |
249 | -if ($upcontext['current_step'] != 0 || !empty($upcontext['user']['step'])) |
|
261 | +if ($upcontext['current_step'] != 0 || !empty($upcontext['user']['step'])) { |
|
250 | 262 | checkLogin(); |
263 | +} |
|
251 | 264 | |
252 | -if ($command_line) |
|
265 | +if ($command_line) { |
|
253 | 266 | cmdStep0(); |
267 | +} |
|
254 | 268 | |
255 | 269 | // Don't error if we're using xml. |
256 | -if (isset($_GET['xml'])) |
|
270 | +if (isset($_GET['xml'])) { |
|
257 | 271 | $upcontext['return_error'] = true; |
272 | +} |
|
258 | 273 | |
259 | 274 | // Loop through all the steps doing each one as required. |
260 | 275 | $upcontext['overall_percent'] = 0; |
@@ -275,9 +290,9 @@ discard block |
||
275 | 290 | } |
276 | 291 | |
277 | 292 | // Call the step and if it returns false that means pause! |
278 | - if (function_exists($step[2]) && $step[2]() === false) |
|
279 | - break; |
|
280 | - elseif (function_exists($step[2])) { |
|
293 | + if (function_exists($step[2]) && $step[2]() === false) { |
|
294 | + break; |
|
295 | + } elseif (function_exists($step[2])) { |
|
281 | 296 | //Start each new step with this unset, so the 'normal' template is called first |
282 | 297 | unset($_GET['xml']); |
283 | 298 | $_GET['substep'] = 0; |
@@ -321,17 +336,18 @@ discard block |
||
321 | 336 | // This should not happen my dear... HELP ME DEVELOPERS!! |
322 | 337 | if (!empty($command_line)) |
323 | 338 | { |
324 | - if (function_exists('debug_print_backtrace')) |
|
325 | - debug_print_backtrace(); |
|
339 | + if (function_exists('debug_print_backtrace')) { |
|
340 | + debug_print_backtrace(); |
|
341 | + } |
|
326 | 342 | |
327 | 343 | echo "\n" . 'Error: Unexpected call to use the ' . (isset($upcontext['sub_template']) ? $upcontext['sub_template'] : '') . ' template. Please copy and paste all the text above and visit the SMF support forum to tell the Developers that they\'ve made a boo boo; they\'ll get you up and running again.'; |
328 | 344 | flush(); |
329 | 345 | die(); |
330 | 346 | } |
331 | 347 | |
332 | - if (!isset($_GET['xml'])) |
|
333 | - template_upgrade_above(); |
|
334 | - else |
|
348 | + if (!isset($_GET['xml'])) { |
|
349 | + template_upgrade_above(); |
|
350 | + } else |
|
335 | 351 | { |
336 | 352 | header('Content-Type: text/xml; charset=UTF-8'); |
337 | 353 | // Sadly we need to retain the $_GET data thanks to the old upgrade scripts. |
@@ -353,25 +369,29 @@ discard block |
||
353 | 369 | $upcontext['form_url'] = $upgradeurl . '?step=' . $upcontext['current_step'] . '&substep=' . $_GET['substep'] . '&data=' . base64_encode(json_encode($upcontext['upgrade_status'])); |
354 | 370 | |
355 | 371 | // Custom stuff to pass back? |
356 | - if (!empty($upcontext['query_string'])) |
|
357 | - $upcontext['form_url'] .= $upcontext['query_string']; |
|
372 | + if (!empty($upcontext['query_string'])) { |
|
373 | + $upcontext['form_url'] .= $upcontext['query_string']; |
|
374 | + } |
|
358 | 375 | |
359 | 376 | // Call the appropriate subtemplate |
360 | - if (is_callable('template_' . $upcontext['sub_template'])) |
|
361 | - call_user_func('template_' . $upcontext['sub_template']); |
|
362 | - else |
|
363 | - die('Upgrade aborted! Invalid template: template_' . $upcontext['sub_template']); |
|
377 | + if (is_callable('template_' . $upcontext['sub_template'])) { |
|
378 | + call_user_func('template_' . $upcontext['sub_template']); |
|
379 | + } else { |
|
380 | + die('Upgrade aborted! Invalid template: template_' . $upcontext['sub_template']); |
|
381 | + } |
|
364 | 382 | } |
365 | 383 | |
366 | 384 | // Was there an error? |
367 | - if (!empty($upcontext['forced_error_message'])) |
|
368 | - echo $upcontext['forced_error_message']; |
|
385 | + if (!empty($upcontext['forced_error_message'])) { |
|
386 | + echo $upcontext['forced_error_message']; |
|
387 | + } |
|
369 | 388 | |
370 | 389 | // Show the footer. |
371 | - if (!isset($_GET['xml'])) |
|
372 | - template_upgrade_below(); |
|
373 | - else |
|
374 | - template_xml_below(); |
|
390 | + if (!isset($_GET['xml'])) { |
|
391 | + template_upgrade_below(); |
|
392 | + } else { |
|
393 | + template_xml_below(); |
|
394 | + } |
|
375 | 395 | } |
376 | 396 | |
377 | 397 | |
@@ -383,15 +403,19 @@ discard block |
||
383 | 403 | $seconds = intval($active % 60); |
384 | 404 | |
385 | 405 | $totalTime = ''; |
386 | - if ($hours > 0) |
|
387 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
388 | - if ($minutes > 0) |
|
389 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
390 | - if ($seconds > 0) |
|
391 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
406 | + if ($hours > 0) { |
|
407 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
408 | + } |
|
409 | + if ($minutes > 0) { |
|
410 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
411 | + } |
|
412 | + if ($seconds > 0) { |
|
413 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
414 | + } |
|
392 | 415 | |
393 | - if (!empty($totalTime)) |
|
394 | - echo "\n" . 'Upgrade completed in ' . $totalTime . "\n"; |
|
416 | + if (!empty($totalTime)) { |
|
417 | + echo "\n" . 'Upgrade completed in ' . $totalTime . "\n"; |
|
418 | + } |
|
395 | 419 | } |
396 | 420 | |
397 | 421 | // Bang - gone! |
@@ -404,8 +428,9 @@ discard block |
||
404 | 428 | global $upgradeurl, $upcontext, $command_line; |
405 | 429 | |
406 | 430 | // Command line users can't be redirected. |
407 | - if ($command_line) |
|
408 | - upgradeExit(true); |
|
431 | + if ($command_line) { |
|
432 | + upgradeExit(true); |
|
433 | + } |
|
409 | 434 | |
410 | 435 | // Are we providing the core info? |
411 | 436 | if ($addForm) |
@@ -431,12 +456,14 @@ discard block |
||
431 | 456 | define('SMF', 1); |
432 | 457 | |
433 | 458 | // Start the session. |
434 | - if (@ini_get('session.save_handler') == 'user') |
|
435 | - @ini_set('session.save_handler', 'files'); |
|
459 | + if (@ini_get('session.save_handler') == 'user') { |
|
460 | + @ini_set('session.save_handler', 'files'); |
|
461 | + } |
|
436 | 462 | @session_start(); |
437 | 463 | |
438 | - if (empty($smcFunc)) |
|
439 | - $smcFunc = array(); |
|
464 | + if (empty($smcFunc)) { |
|
465 | + $smcFunc = array(); |
|
466 | + } |
|
440 | 467 | |
441 | 468 | // We need this for authentication and some upgrade code |
442 | 469 | require_once($sourcedir . '/Subs-Auth.php'); |
@@ -448,32 +475,36 @@ discard block |
||
448 | 475 | initialize_inputs(); |
449 | 476 | |
450 | 477 | // Get the database going! |
451 | - if (empty($db_type) || $db_type == 'mysqli') |
|
452 | - $db_type = 'mysql'; |
|
478 | + if (empty($db_type) || $db_type == 'mysqli') { |
|
479 | + $db_type = 'mysql'; |
|
480 | + } |
|
453 | 481 | |
454 | 482 | if (file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php')) |
455 | 483 | { |
456 | 484 | require_once($sourcedir . '/Subs-Db-' . $db_type . '.php'); |
457 | 485 | |
458 | 486 | // Make the connection... |
459 | - if (empty($db_connection)) |
|
460 | - $db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, array('non_fatal' => true)); |
|
461 | - else |
|
462 | - // If we've returned here, ping/reconnect to be safe |
|
487 | + if (empty($db_connection)) { |
|
488 | + $db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, array('non_fatal' => true)); |
|
489 | + } else { |
|
490 | + // If we've returned here, ping/reconnect to be safe |
|
463 | 491 | $smcFunc['db_ping']($db_connection); |
492 | + } |
|
464 | 493 | |
465 | 494 | // Oh dear god!! |
466 | - if ($db_connection === null) |
|
467 | - die('Unable to connect to database - please check username and password are correct in Settings.php'); |
|
495 | + if ($db_connection === null) { |
|
496 | + die('Unable to connect to database - please check username and password are correct in Settings.php'); |
|
497 | + } |
|
468 | 498 | |
469 | - if ($db_type == 'mysql' && isset($db_character_set) && preg_match('~^\w+$~', $db_character_set) === 1) |
|
470 | - $smcFunc['db_query']('', ' |
|
499 | + if ($db_type == 'mysql' && isset($db_character_set) && preg_match('~^\w+$~', $db_character_set) === 1) { |
|
500 | + $smcFunc['db_query']('', ' |
|
471 | 501 | SET NAMES {string:db_character_set}', |
472 | 502 | array( |
473 | 503 | 'db_error_skip' => true, |
474 | 504 | 'db_character_set' => $db_character_set, |
475 | 505 | ) |
476 | 506 | ); |
507 | + } |
|
477 | 508 | |
478 | 509 | // Load the modSettings data... |
479 | 510 | $request = $smcFunc['db_query']('', ' |
@@ -484,11 +515,11 @@ discard block |
||
484 | 515 | ) |
485 | 516 | ); |
486 | 517 | $modSettings = array(); |
487 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
488 | - $modSettings[$row['variable']] = $row['value']; |
|
518 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
519 | + $modSettings[$row['variable']] = $row['value']; |
|
520 | + } |
|
489 | 521 | $smcFunc['db_free_result']($request); |
490 | - } |
|
491 | - else |
|
522 | + } else |
|
492 | 523 | { |
493 | 524 | return throw_error('Cannot find ' . $sourcedir . '/Subs-Db-' . $db_type . '.php' . '. Please check you have uploaded all source files and have the correct paths set.'); |
494 | 525 | } |
@@ -502,9 +533,10 @@ discard block |
||
502 | 533 | cleanRequest(); |
503 | 534 | } |
504 | 535 | |
505 | - if (!isset($_GET['substep'])) |
|
506 | - $_GET['substep'] = 0; |
|
507 | -} |
|
536 | + if (!isset($_GET['substep'])) { |
|
537 | + $_GET['substep'] = 0; |
|
538 | + } |
|
539 | + } |
|
508 | 540 | |
509 | 541 | function initialize_inputs() |
510 | 542 | { |
@@ -534,8 +566,9 @@ discard block |
||
534 | 566 | $dh = opendir(dirname(__FILE__)); |
535 | 567 | while ($file = readdir($dh)) |
536 | 568 | { |
537 | - if (preg_match('~upgrade_\d-\d_([A-Za-z])+\.sql~i', $file, $matches) && isset($matches[1])) |
|
538 | - @unlink(dirname(__FILE__) . '/' . $file); |
|
569 | + if (preg_match('~upgrade_\d-\d_([A-Za-z])+\.sql~i', $file, $matches) && isset($matches[1])) { |
|
570 | + @unlink(dirname(__FILE__) . '/' . $file); |
|
571 | + } |
|
539 | 572 | } |
540 | 573 | closedir($dh); |
541 | 574 | |
@@ -564,8 +597,9 @@ discard block |
||
564 | 597 | $temp = 'upgrade_php?step'; |
565 | 598 | while (strlen($temp) > 4) |
566 | 599 | { |
567 | - if (isset($_GET[$temp])) |
|
568 | - unset($_GET[$temp]); |
|
600 | + if (isset($_GET[$temp])) { |
|
601 | + unset($_GET[$temp]); |
|
602 | + } |
|
569 | 603 | $temp = substr($temp, 1); |
570 | 604 | } |
571 | 605 | |
@@ -592,32 +626,39 @@ discard block |
||
592 | 626 | && @file_exists(dirname(__FILE__) . '/upgrade_2-1_' . $db_type . '.sql'); |
593 | 627 | |
594 | 628 | // Need legacy scripts? |
595 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.1) |
|
596 | - $check &= @file_exists(dirname(__FILE__) . '/upgrade_2-0_' . $db_type . '.sql'); |
|
597 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.0) |
|
598 | - $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-1.sql'); |
|
599 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 1.1) |
|
600 | - $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-0.sql'); |
|
629 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.1) { |
|
630 | + $check &= @file_exists(dirname(__FILE__) . '/upgrade_2-0_' . $db_type . '.sql'); |
|
631 | + } |
|
632 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.0) { |
|
633 | + $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-1.sql'); |
|
634 | + } |
|
635 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 1.1) { |
|
636 | + $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-0.sql'); |
|
637 | + } |
|
601 | 638 | |
602 | 639 | // We don't need "-utf8" files anymore... |
603 | 640 | $upcontext['language'] = str_ireplace('-utf8', '', $upcontext['language']); |
604 | 641 | |
605 | 642 | // This needs to exist! |
606 | - if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) |
|
607 | - return throw_error('The upgrader could not find the "Install" language file for the forum default language, ' . $upcontext['language'] . '.<br><br>Please make certain you uploaded all the files included in the package, even the theme and language files for the default theme.<br> [<a href="' . $upgradeurl . '?lang=english">Try English</a>]'); |
|
608 | - else |
|
609 | - require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
643 | + if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) { |
|
644 | + return throw_error('The upgrader could not find the "Install" language file for the forum default language, ' . $upcontext['language'] . '.<br><br>Please make certain you uploaded all the files included in the package, even the theme and language files for the default theme.<br> [<a href="' . $upgradeurl . '?lang=english">Try English</a>]'); |
|
645 | + } else { |
|
646 | + require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
647 | + } |
|
610 | 648 | |
611 | - if (!$check) |
|
612 | - // Don't tell them what files exactly because it's a spot check - just like teachers don't tell which problems they are spot checking, that's dumb. |
|
649 | + if (!$check) { |
|
650 | + // Don't tell them what files exactly because it's a spot check - just like teachers don't tell which problems they are spot checking, that's dumb. |
|
613 | 651 | return throw_error('The upgrader was unable to find some crucial files.<br><br>Please make sure you uploaded all of the files included in the package, including the Themes, Sources, and other directories.'); |
652 | + } |
|
614 | 653 | |
615 | 654 | // Do they meet the install requirements? |
616 | - if (!php_version_check()) |
|
617 | - return throw_error('Warning! You do not appear to have a version of PHP installed on your webserver that meets SMF\'s minimum installations requirements.<br><br>Please ask your host to upgrade.'); |
|
655 | + if (!php_version_check()) { |
|
656 | + return throw_error('Warning! You do not appear to have a version of PHP installed on your webserver that meets SMF\'s minimum installations requirements.<br><br>Please ask your host to upgrade.'); |
|
657 | + } |
|
618 | 658 | |
619 | - if (!db_version_check()) |
|
620 | - return throw_error('Your ' . $databases[$db_type]['name'] . ' version does not meet the minimum requirements of SMF.<br><br>Please ask your host to upgrade.'); |
|
659 | + if (!db_version_check()) { |
|
660 | + return throw_error('Your ' . $databases[$db_type]['name'] . ' version does not meet the minimum requirements of SMF.<br><br>Please ask your host to upgrade.'); |
|
661 | + } |
|
621 | 662 | |
622 | 663 | // Do some checks to make sure they have proper privileges |
623 | 664 | db_extend('packages'); |
@@ -632,14 +673,16 @@ discard block |
||
632 | 673 | $drop = $smcFunc['db_drop_table']('{db_prefix}priv_check'); |
633 | 674 | |
634 | 675 | // Sorry... we need CREATE, ALTER and DROP |
635 | - if (!$create || !$alter || !$drop) |
|
636 | - return throw_error('The ' . $databases[$db_type]['name'] . ' user you have set in Settings.php does not have proper privileges.<br><br>Please ask your host to give this user the ALTER, CREATE, and DROP privileges.'); |
|
676 | + if (!$create || !$alter || !$drop) { |
|
677 | + return throw_error('The ' . $databases[$db_type]['name'] . ' user you have set in Settings.php does not have proper privileges.<br><br>Please ask your host to give this user the ALTER, CREATE, and DROP privileges.'); |
|
678 | + } |
|
637 | 679 | |
638 | 680 | // Do a quick version spot check. |
639 | 681 | $temp = substr(@implode('', @file($boarddir . '/index.php')), 0, 4096); |
640 | 682 | preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $temp, $match); |
641 | - if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) |
|
642 | - return throw_error('The upgrader found some old or outdated files.<br><br>Please make certain you uploaded the new versions of all the files included in the package.'); |
|
683 | + if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) { |
|
684 | + return throw_error('The upgrader found some old or outdated files.<br><br>Please make certain you uploaded the new versions of all the files included in the package.'); |
|
685 | + } |
|
643 | 686 | |
644 | 687 | // What absolutely needs to be writable? |
645 | 688 | $writable_files = array( |
@@ -661,12 +704,13 @@ discard block |
||
661 | 704 | quickFileWritable($custom_av_dir); |
662 | 705 | |
663 | 706 | // Are we good now? |
664 | - if (!is_writable($custom_av_dir)) |
|
665 | - return throw_error(sprintf('The directory: %1$s has to be writable to continue the upgrade. Please make sure permissions are correctly set to allow this.', $custom_av_dir)); |
|
666 | - elseif ($need_settings_update) |
|
707 | + if (!is_writable($custom_av_dir)) { |
|
708 | + return throw_error(sprintf('The directory: %1$s has to be writable to continue the upgrade. Please make sure permissions are correctly set to allow this.', $custom_av_dir)); |
|
709 | + } elseif ($need_settings_update) |
|
667 | 710 | { |
668 | - if (!function_exists('cache_put_data')) |
|
669 | - require_once($sourcedir . '/Load.php'); |
|
711 | + if (!function_exists('cache_put_data')) { |
|
712 | + require_once($sourcedir . '/Load.php'); |
|
713 | + } |
|
670 | 714 | updateSettings(array('custom_avatar_dir' => $custom_av_dir)); |
671 | 715 | updateSettings(array('custom_avatar_url' => $custom_av_url)); |
672 | 716 | } |
@@ -675,28 +719,33 @@ discard block |
||
675 | 719 | |
676 | 720 | // Check the cache directory. |
677 | 721 | $cachedir_temp = empty($cachedir) ? $boarddir . '/cache' : $cachedir; |
678 | - if (!file_exists($cachedir_temp)) |
|
679 | - @mkdir($cachedir_temp); |
|
680 | - if (!file_exists($cachedir_temp)) |
|
681 | - return throw_error('The cache directory could not be found.<br><br>Please make sure you have a directory called "cache" in your forum directory before continuing.'); |
|
682 | - |
|
683 | - if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) |
|
684 | - return throw_error('The upgrader was unable to find language files for the language specified in Settings.php.<br>SMF will not work without the primary language files installed.<br><br>Please either install them, or <a href="' . $upgradeurl . '?step=0;lang=english">use english instead</a>.'); |
|
685 | - elseif (!isset($_GET['skiplang'])) |
|
722 | + if (!file_exists($cachedir_temp)) { |
|
723 | + @mkdir($cachedir_temp); |
|
724 | + } |
|
725 | + if (!file_exists($cachedir_temp)) { |
|
726 | + return throw_error('The cache directory could not be found.<br><br>Please make sure you have a directory called "cache" in your forum directory before continuing.'); |
|
727 | + } |
|
728 | + |
|
729 | + if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) { |
|
730 | + return throw_error('The upgrader was unable to find language files for the language specified in Settings.php.<br>SMF will not work without the primary language files installed.<br><br>Please either install them, or <a href="' . $upgradeurl . '?step=0;lang=english">use english instead</a>.'); |
|
731 | + } elseif (!isset($_GET['skiplang'])) |
|
686 | 732 | { |
687 | 733 | $temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php')), 0, 4096); |
688 | 734 | preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match); |
689 | 735 | |
690 | - if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) |
|
691 | - return throw_error('The upgrader found some old or outdated language files, for the forum default language, ' . $upcontext['language'] . '.<br><br>Please make certain you uploaded the new versions of all the files included in the package, even the theme and language files for the default theme.<br> [<a href="' . $upgradeurl . '?skiplang">SKIP</a>] [<a href="' . $upgradeurl . '?lang=english">Try English</a>]'); |
|
736 | + if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) { |
|
737 | + return throw_error('The upgrader found some old or outdated language files, for the forum default language, ' . $upcontext['language'] . '.<br><br>Please make certain you uploaded the new versions of all the files included in the package, even the theme and language files for the default theme.<br> [<a href="' . $upgradeurl . '?skiplang">SKIP</a>] [<a href="' . $upgradeurl . '?lang=english">Try English</a>]'); |
|
738 | + } |
|
692 | 739 | } |
693 | 740 | |
694 | - if (!makeFilesWritable($writable_files)) |
|
695 | - return false; |
|
741 | + if (!makeFilesWritable($writable_files)) { |
|
742 | + return false; |
|
743 | + } |
|
696 | 744 | |
697 | 745 | // Check agreement.txt. (it may not exist, in which case $boarddir must be writable.) |
698 | - if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) |
|
699 | - return throw_error('The upgrader was unable to obtain write access to agreement.txt.<br><br>If you are using a linux or unix based server, please ensure that the file is chmod\'d to 777, or if it does not exist that the directory this upgrader is in is 777.<br>If your server is running Windows, please ensure that the internet guest account has the proper permissions on it or its folder.'); |
|
746 | + if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) { |
|
747 | + return throw_error('The upgrader was unable to obtain write access to agreement.txt.<br><br>If you are using a linux or unix based server, please ensure that the file is chmod\'d to 777, or if it does not exist that the directory this upgrader is in is 777.<br>If your server is running Windows, please ensure that the internet guest account has the proper permissions on it or its folder.'); |
|
748 | + } |
|
700 | 749 | |
701 | 750 | // Upgrade the agreement. |
702 | 751 | elseif (isset($modSettings['agreement'])) |
@@ -707,8 +756,8 @@ discard block |
||
707 | 756 | } |
708 | 757 | |
709 | 758 | // We're going to check that their board dir setting is right in case they've been moving stuff around. |
710 | - if (strtr($boarddir, array('/' => '', '\\' => '')) != strtr(dirname(__FILE__), array('/' => '', '\\' => ''))) |
|
711 | - $upcontext['warning'] = ' |
|
759 | + if (strtr($boarddir, array('/' => '', '\\' => '')) != strtr(dirname(__FILE__), array('/' => '', '\\' => ''))) { |
|
760 | + $upcontext['warning'] = ' |
|
712 | 761 | It looks as if your board directory settings <em>might</em> be incorrect. Your board directory is currently set to "' . $boarddir . '" but should probably be "' . dirname(__FILE__) . '". Settings.php currently lists your paths as:<br> |
713 | 762 | <ul> |
714 | 763 | <li>Board Directory: ' . $boarddir . '</li> |
@@ -716,10 +765,12 @@ discard block |
||
716 | 765 | <li>Cache Directory: ' . $cachedir_temp . '</li> |
717 | 766 | </ul> |
718 | 767 | If these seem incorrect please open Settings.php in a text editor before proceeding with this upgrade. If they are incorrect due to you moving your forum to a new location please download and execute the <a href="https://download.simplemachines.org/?tools">Repair Settings</a> tool from the Simple Machines website before continuing.'; |
768 | + } |
|
719 | 769 | |
720 | 770 | // Either we're logged in or we're going to present the login. |
721 | - if (checkLogin()) |
|
722 | - return true; |
|
771 | + if (checkLogin()) { |
|
772 | + return true; |
|
773 | + } |
|
723 | 774 | |
724 | 775 | $upcontext += createToken('login'); |
725 | 776 | |
@@ -733,15 +784,17 @@ discard block |
||
733 | 784 | global $smcFunc, $db_type, $support_js; |
734 | 785 | |
735 | 786 | // Don't bother if the security is disabled. |
736 | - if ($disable_security) |
|
737 | - return true; |
|
787 | + if ($disable_security) { |
|
788 | + return true; |
|
789 | + } |
|
738 | 790 | |
739 | 791 | // Are we trying to login? |
740 | 792 | if (isset($_POST['contbutt']) && (!empty($_POST['user']))) |
741 | 793 | { |
742 | 794 | // If we've disabled security pick a suitable name! |
743 | - if (empty($_POST['user'])) |
|
744 | - $_POST['user'] = 'Administrator'; |
|
795 | + if (empty($_POST['user'])) { |
|
796 | + $_POST['user'] = 'Administrator'; |
|
797 | + } |
|
745 | 798 | |
746 | 799 | // Before 2.0 these column names were different! |
747 | 800 | $oldDB = false; |
@@ -756,16 +809,17 @@ discard block |
||
756 | 809 | 'db_error_skip' => true, |
757 | 810 | ) |
758 | 811 | ); |
759 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
760 | - $oldDB = true; |
|
812 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
813 | + $oldDB = true; |
|
814 | + } |
|
761 | 815 | $smcFunc['db_free_result']($request); |
762 | 816 | } |
763 | 817 | |
764 | 818 | // Get what we believe to be their details. |
765 | 819 | if (!$disable_security) |
766 | 820 | { |
767 | - if ($oldDB) |
|
768 | - $request = $smcFunc['db_query']('', ' |
|
821 | + if ($oldDB) { |
|
822 | + $request = $smcFunc['db_query']('', ' |
|
769 | 823 | SELECT id_member, memberName AS member_name, passwd, id_group, |
770 | 824 | additionalGroups AS additional_groups, lngfile |
771 | 825 | FROM {db_prefix}members |
@@ -775,8 +829,8 @@ discard block |
||
775 | 829 | 'db_error_skip' => true, |
776 | 830 | ) |
777 | 831 | ); |
778 | - else |
|
779 | - $request = $smcFunc['db_query']('', ' |
|
832 | + } else { |
|
833 | + $request = $smcFunc['db_query']('', ' |
|
780 | 834 | SELECT id_member, member_name, passwd, id_group, additional_groups, lngfile |
781 | 835 | FROM {db_prefix}members |
782 | 836 | WHERE member_name = {string:member_name}', |
@@ -785,6 +839,7 @@ discard block |
||
785 | 839 | 'db_error_skip' => true, |
786 | 840 | ) |
787 | 841 | ); |
842 | + } |
|
788 | 843 | if ($smcFunc['db_num_rows']($request) != 0) |
789 | 844 | { |
790 | 845 | list ($id_member, $name, $password, $id_group, $addGroups, $user_language) = $smcFunc['db_fetch_row']($request); |
@@ -792,16 +847,17 @@ discard block |
||
792 | 847 | $groups = explode(',', $addGroups); |
793 | 848 | $groups[] = $id_group; |
794 | 849 | |
795 | - foreach ($groups as $k => $v) |
|
796 | - $groups[$k] = (int) $v; |
|
850 | + foreach ($groups as $k => $v) { |
|
851 | + $groups[$k] = (int) $v; |
|
852 | + } |
|
797 | 853 | |
798 | 854 | $sha_passwd = sha1(strtolower($name) . un_htmlspecialchars($_REQUEST['passwrd'])); |
799 | 855 | |
800 | 856 | // We don't use "-utf8" anymore... |
801 | 857 | $user_language = str_ireplace('-utf8', '', $user_language); |
858 | + } else { |
|
859 | + $upcontext['username_incorrect'] = true; |
|
802 | 860 | } |
803 | - else |
|
804 | - $upcontext['username_incorrect'] = true; |
|
805 | 861 | $smcFunc['db_free_result']($request); |
806 | 862 | } |
807 | 863 | $upcontext['username'] = $_POST['user']; |
@@ -811,13 +867,14 @@ discard block |
||
811 | 867 | { |
812 | 868 | $upcontext['upgrade_status']['js'] = 1; |
813 | 869 | $support_js = 1; |
870 | + } else { |
|
871 | + $support_js = 0; |
|
814 | 872 | } |
815 | - else |
|
816 | - $support_js = 0; |
|
817 | 873 | |
818 | 874 | // Note down the version we are coming from. |
819 | - if (!empty($modSettings['smfVersion']) && empty($upcontext['user']['version'])) |
|
820 | - $upcontext['user']['version'] = $modSettings['smfVersion']; |
|
875 | + if (!empty($modSettings['smfVersion']) && empty($upcontext['user']['version'])) { |
|
876 | + $upcontext['user']['version'] = $modSettings['smfVersion']; |
|
877 | + } |
|
821 | 878 | |
822 | 879 | // Didn't get anywhere? |
823 | 880 | if (!$disable_security && (empty($sha_passwd) || (!empty($password) ? $password : '') != $sha_passwd) && !hash_verify_password((!empty($name) ? $name : ''), $_REQUEST['passwrd'], (!empty($password) ? $password : '')) && empty($upcontext['username_incorrect'])) |
@@ -851,15 +908,15 @@ discard block |
||
851 | 908 | 'db_error_skip' => true, |
852 | 909 | ) |
853 | 910 | ); |
854 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
855 | - return throw_error('You need to be an admin to perform an upgrade!'); |
|
911 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
912 | + return throw_error('You need to be an admin to perform an upgrade!'); |
|
913 | + } |
|
856 | 914 | $smcFunc['db_free_result']($request); |
857 | 915 | } |
858 | 916 | |
859 | 917 | $upcontext['user']['id'] = $id_member; |
860 | 918 | $upcontext['user']['name'] = $name; |
861 | - } |
|
862 | - else |
|
919 | + } else |
|
863 | 920 | { |
864 | 921 | $upcontext['user']['id'] = 1; |
865 | 922 | $upcontext['user']['name'] = 'Administrator'; |
@@ -875,11 +932,11 @@ discard block |
||
875 | 932 | $temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $user_language . '.php')), 0, 4096); |
876 | 933 | preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match); |
877 | 934 | |
878 | - if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) |
|
879 | - $upcontext['upgrade_options_warning'] = 'The language files for your selected language, ' . $user_language . ', have not been updated to the latest version. Upgrade will continue with the forum default, ' . $upcontext['language'] . '.'; |
|
880 | - elseif (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . basename($user_language, '.lng') . '.php')) |
|
881 | - $upcontext['upgrade_options_warning'] = 'The language files for your selected language, ' . $user_language . ', have not been uploaded/updated as the "Install" language file is missing. Upgrade will continue with the forum default, ' . $upcontext['language'] . '.'; |
|
882 | - else |
|
935 | + if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) { |
|
936 | + $upcontext['upgrade_options_warning'] = 'The language files for your selected language, ' . $user_language . ', have not been updated to the latest version. Upgrade will continue with the forum default, ' . $upcontext['language'] . '.'; |
|
937 | + } elseif (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . basename($user_language, '.lng') . '.php')) { |
|
938 | + $upcontext['upgrade_options_warning'] = 'The language files for your selected language, ' . $user_language . ', have not been uploaded/updated as the "Install" language file is missing. Upgrade will continue with the forum default, ' . $upcontext['language'] . '.'; |
|
939 | + } else |
|
883 | 940 | { |
884 | 941 | // Set this as the new language. |
885 | 942 | $upcontext['language'] = $user_language; |
@@ -923,8 +980,9 @@ discard block |
||
923 | 980 | unset($member_columns); |
924 | 981 | |
925 | 982 | // If we've not submitted then we're done. |
926 | - if (empty($_POST['upcont'])) |
|
927 | - return false; |
|
983 | + if (empty($_POST['upcont'])) { |
|
984 | + return false; |
|
985 | + } |
|
928 | 986 | |
929 | 987 | // Firstly, if they're enabling SM stat collection just do it. |
930 | 988 | if (!empty($_POST['stats']) && (substr($boardurl, 0, 16) != 'http://localhost' || substr($boardurl, 0, 16) != 'https://localhost') && empty($modSettings['allow_sm_stats'])) |
@@ -939,25 +997,26 @@ discard block |
||
939 | 997 | fwrite($fp, $out); |
940 | 998 | |
941 | 999 | $return_data = ''; |
942 | - while (!feof($fp)) |
|
943 | - $return_data .= fgets($fp, 128); |
|
1000 | + while (!feof($fp)) { |
|
1001 | + $return_data .= fgets($fp, 128); |
|
1002 | + } |
|
944 | 1003 | |
945 | 1004 | fclose($fp); |
946 | 1005 | |
947 | 1006 | // Get the unique site ID. |
948 | 1007 | preg_match('~SITE-ID:\s(\w{10})~', $return_data, $ID); |
949 | 1008 | |
950 | - if (!empty($ID[1])) |
|
951 | - $smcFunc['db_insert']('replace', |
|
1009 | + if (!empty($ID[1])) { |
|
1010 | + $smcFunc['db_insert']('replace', |
|
952 | 1011 | $db_prefix . 'settings', |
953 | 1012 | array('variable' => 'string', 'value' => 'string'), |
954 | 1013 | array('allow_sm_stats', $ID[1]), |
955 | 1014 | array('variable') |
956 | 1015 | ); |
1016 | + } |
|
957 | 1017 | } |
958 | - } |
|
959 | - else |
|
960 | - $smcFunc['db_query']('', ' |
|
1018 | + } else { |
|
1019 | + $smcFunc['db_query']('', ' |
|
961 | 1020 | DELETE FROM {db_prefix}settings |
962 | 1021 | WHERE variable = {string:allow_sm_stats}', |
963 | 1022 | array( |
@@ -965,6 +1024,7 @@ discard block |
||
965 | 1024 | 'db_error_skip' => true, |
966 | 1025 | ) |
967 | 1026 | ); |
1027 | + } |
|
968 | 1028 | |
969 | 1029 | // Deleting old karma stuff? |
970 | 1030 | if (!empty($_POST['delete_karma'])) |
@@ -979,20 +1039,22 @@ discard block |
||
979 | 1039 | ); |
980 | 1040 | |
981 | 1041 | // Cleaning up old karma member settings. |
982 | - if ($upcontext['karma_installed']['good']) |
|
983 | - $smcFunc['db_query']('', ' |
|
1042 | + if ($upcontext['karma_installed']['good']) { |
|
1043 | + $smcFunc['db_query']('', ' |
|
984 | 1044 | ALTER TABLE {db_prefix}members |
985 | 1045 | DROP karma_good', |
986 | 1046 | array() |
987 | 1047 | ); |
1048 | + } |
|
988 | 1049 | |
989 | 1050 | // Does karma bad was enable? |
990 | - if ($upcontext['karma_installed']['bad']) |
|
991 | - $smcFunc['db_query']('', ' |
|
1051 | + if ($upcontext['karma_installed']['bad']) { |
|
1052 | + $smcFunc['db_query']('', ' |
|
992 | 1053 | ALTER TABLE {db_prefix}members |
993 | 1054 | DROP karma_bad', |
994 | 1055 | array() |
995 | 1056 | ); |
1057 | + } |
|
996 | 1058 | |
997 | 1059 | // Cleaning up old karma permissions. |
998 | 1060 | $smcFunc['db_query']('', ' |
@@ -1005,26 +1067,29 @@ discard block |
||
1005 | 1067 | } |
1006 | 1068 | |
1007 | 1069 | // Emptying the error log? |
1008 | - if (!empty($_POST['empty_error'])) |
|
1009 | - $smcFunc['db_query']('truncate_table', ' |
|
1070 | + if (!empty($_POST['empty_error'])) { |
|
1071 | + $smcFunc['db_query']('truncate_table', ' |
|
1010 | 1072 | TRUNCATE {db_prefix}log_errors', |
1011 | 1073 | array( |
1012 | 1074 | ) |
1013 | 1075 | ); |
1076 | + } |
|
1014 | 1077 | |
1015 | 1078 | $changes = array(); |
1016 | 1079 | |
1017 | 1080 | // Add proxy settings. |
1018 | - if (!isset($GLOBALS['image_proxy_maxsize'])) |
|
1019 | - $changes += array( |
|
1081 | + if (!isset($GLOBALS['image_proxy_maxsize'])) { |
|
1082 | + $changes += array( |
|
1020 | 1083 | 'image_proxy_secret' => '\'' . substr(sha1(mt_rand()), 0, 20) . '\'', |
1021 | 1084 | 'image_proxy_maxsize' => 5190, |
1022 | 1085 | 'image_proxy_enabled' => 0, |
1023 | 1086 | ); |
1087 | + } |
|
1024 | 1088 | |
1025 | 1089 | // If we're overriding the language follow it through. |
1026 | - if (isset($_GET['lang']) && file_exists($modSettings['theme_dir'] . '/languages/index.' . $_GET['lang'] . '.php')) |
|
1027 | - $changes['language'] = '\'' . $_GET['lang'] . '\''; |
|
1090 | + if (isset($_GET['lang']) && file_exists($modSettings['theme_dir'] . '/languages/index.' . $_GET['lang'] . '.php')) { |
|
1091 | + $changes['language'] = '\'' . $_GET['lang'] . '\''; |
|
1092 | + } |
|
1028 | 1093 | |
1029 | 1094 | if (!empty($_POST['maint'])) |
1030 | 1095 | { |
@@ -1036,30 +1101,34 @@ discard block |
||
1036 | 1101 | { |
1037 | 1102 | $changes['mtitle'] = '\'' . addslashes($_POST['maintitle']) . '\''; |
1038 | 1103 | $changes['mmessage'] = '\'' . addslashes($_POST['mainmessage']) . '\''; |
1039 | - } |
|
1040 | - else |
|
1104 | + } else |
|
1041 | 1105 | { |
1042 | 1106 | $changes['mtitle'] = '\'Upgrading the forum...\''; |
1043 | 1107 | $changes['mmessage'] = '\'Don\\\'t worry, we will be back shortly with an updated forum. It will only be a minute ;).\''; |
1044 | 1108 | } |
1045 | 1109 | } |
1046 | 1110 | |
1047 | - if ($command_line) |
|
1048 | - echo ' * Updating Settings.php...'; |
|
1111 | + if ($command_line) { |
|
1112 | + echo ' * Updating Settings.php...'; |
|
1113 | + } |
|
1049 | 1114 | |
1050 | 1115 | // Fix some old paths. |
1051 | - if (substr($boarddir, 0, 1) == '.') |
|
1052 | - $changes['boarddir'] = '\'' . fixRelativePath($boarddir) . '\''; |
|
1116 | + if (substr($boarddir, 0, 1) == '.') { |
|
1117 | + $changes['boarddir'] = '\'' . fixRelativePath($boarddir) . '\''; |
|
1118 | + } |
|
1053 | 1119 | |
1054 | - if (substr($sourcedir, 0, 1) == '.') |
|
1055 | - $changes['sourcedir'] = '\'' . fixRelativePath($sourcedir) . '\''; |
|
1120 | + if (substr($sourcedir, 0, 1) == '.') { |
|
1121 | + $changes['sourcedir'] = '\'' . fixRelativePath($sourcedir) . '\''; |
|
1122 | + } |
|
1056 | 1123 | |
1057 | - if (empty($cachedir) || substr($cachedir, 0, 1) == '.') |
|
1058 | - $changes['cachedir'] = '\'' . fixRelativePath($boarddir) . '/cache\''; |
|
1124 | + if (empty($cachedir) || substr($cachedir, 0, 1) == '.') { |
|
1125 | + $changes['cachedir'] = '\'' . fixRelativePath($boarddir) . '/cache\''; |
|
1126 | + } |
|
1059 | 1127 | |
1060 | 1128 | // Not had the database type added before? |
1061 | - if (empty($db_type)) |
|
1062 | - $changes['db_type'] = 'mysql'; |
|
1129 | + if (empty($db_type)) { |
|
1130 | + $changes['db_type'] = 'mysql'; |
|
1131 | + } |
|
1063 | 1132 | |
1064 | 1133 | // If they have a "host:port" setup for the host, split that into separate values |
1065 | 1134 | // You should never have a : in the hostname if you're not on MySQL, but better safe than sorry |
@@ -1070,32 +1139,36 @@ discard block |
||
1070 | 1139 | $changes['db_server'] = '\'' . $db_server . '\''; |
1071 | 1140 | |
1072 | 1141 | // Only set this if we're not using the default port |
1073 | - if ($db_port != ini_get('mysqli.default_port')) |
|
1074 | - $changes['db_port'] = (int) $db_port; |
|
1075 | - } |
|
1076 | - elseif (!empty($db_port)) |
|
1142 | + if ($db_port != ini_get('mysqli.default_port')) { |
|
1143 | + $changes['db_port'] = (int) $db_port; |
|
1144 | + } |
|
1145 | + } elseif (!empty($db_port)) |
|
1077 | 1146 | { |
1078 | 1147 | // If db_port is set and is the same as the default, set it to '' |
1079 | 1148 | if ($db_type == 'mysql') |
1080 | 1149 | { |
1081 | - if ($db_port == ini_get('mysqli.default_port')) |
|
1082 | - $changes['db_port'] = '\'\''; |
|
1083 | - elseif ($db_type == 'postgresql' && $db_port == 5432) |
|
1084 | - $changes['db_port'] = '\'\''; |
|
1150 | + if ($db_port == ini_get('mysqli.default_port')) { |
|
1151 | + $changes['db_port'] = '\'\''; |
|
1152 | + } elseif ($db_type == 'postgresql' && $db_port == 5432) { |
|
1153 | + $changes['db_port'] = '\'\''; |
|
1154 | + } |
|
1085 | 1155 | } |
1086 | 1156 | } |
1087 | 1157 | |
1088 | 1158 | // Maybe we haven't had this option yet? |
1089 | - if (empty($packagesdir)) |
|
1090 | - $changes['packagesdir'] = '\'' . fixRelativePath($boarddir) . '/Packages\''; |
|
1159 | + if (empty($packagesdir)) { |
|
1160 | + $changes['packagesdir'] = '\'' . fixRelativePath($boarddir) . '/Packages\''; |
|
1161 | + } |
|
1091 | 1162 | |
1092 | 1163 | // Add support for $tasksdir var. |
1093 | - if (empty($tasksdir)) |
|
1094 | - $changes['tasksdir'] = '\'' . fixRelativePath($sourcedir) . '/tasks\''; |
|
1164 | + if (empty($tasksdir)) { |
|
1165 | + $changes['tasksdir'] = '\'' . fixRelativePath($sourcedir) . '/tasks\''; |
|
1166 | + } |
|
1095 | 1167 | |
1096 | 1168 | // Make sure we fix the language as well. |
1097 | - if (stristr($language, '-utf8')) |
|
1098 | - $changes['language'] = '\'' . str_ireplace('-utf8', '', $language) . '\''; |
|
1169 | + if (stristr($language, '-utf8')) { |
|
1170 | + $changes['language'] = '\'' . str_ireplace('-utf8', '', $language) . '\''; |
|
1171 | + } |
|
1099 | 1172 | |
1100 | 1173 | // @todo Maybe change the cookie name if going to 1.1, too? |
1101 | 1174 | |
@@ -1103,8 +1176,9 @@ discard block |
||
1103 | 1176 | require_once($sourcedir . '/Subs-Admin.php'); |
1104 | 1177 | updateSettingsFile($changes); |
1105 | 1178 | |
1106 | - if ($command_line) |
|
1107 | - echo ' Successful.' . "\n"; |
|
1179 | + if ($command_line) { |
|
1180 | + echo ' Successful.' . "\n"; |
|
1181 | + } |
|
1108 | 1182 | |
1109 | 1183 | // Are we doing debug? |
1110 | 1184 | if (isset($_POST['debug'])) |
@@ -1114,8 +1188,9 @@ discard block |
||
1114 | 1188 | } |
1115 | 1189 | |
1116 | 1190 | // If we're not backing up then jump one. |
1117 | - if (empty($_POST['backup'])) |
|
1118 | - $upcontext['current_step']++; |
|
1191 | + if (empty($_POST['backup'])) { |
|
1192 | + $upcontext['current_step']++; |
|
1193 | + } |
|
1119 | 1194 | |
1120 | 1195 | // If we've got here then let's proceed to the next step! |
1121 | 1196 | return true; |
@@ -1130,8 +1205,9 @@ discard block |
||
1130 | 1205 | $upcontext['page_title'] = 'Backup Database'; |
1131 | 1206 | |
1132 | 1207 | // Done it already - js wise? |
1133 | - if (!empty($_POST['backup_done'])) |
|
1134 | - return true; |
|
1208 | + if (!empty($_POST['backup_done'])) { |
|
1209 | + return true; |
|
1210 | + } |
|
1135 | 1211 | |
1136 | 1212 | // Some useful stuff here. |
1137 | 1213 | db_extend(); |
@@ -1145,9 +1221,10 @@ discard block |
||
1145 | 1221 | $tables = $smcFunc['db_list_tables']($db, $filter); |
1146 | 1222 | |
1147 | 1223 | $table_names = array(); |
1148 | - foreach ($tables as $table) |
|
1149 | - if (substr($table, 0, 7) !== 'backup_') |
|
1224 | + foreach ($tables as $table) { |
|
1225 | + if (substr($table, 0, 7) !== 'backup_') |
|
1150 | 1226 | $table_names[] = $table; |
1227 | + } |
|
1151 | 1228 | |
1152 | 1229 | $upcontext['table_count'] = count($table_names); |
1153 | 1230 | $upcontext['cur_table_num'] = $_GET['substep']; |
@@ -1157,12 +1234,14 @@ discard block |
||
1157 | 1234 | $file_steps = $upcontext['table_count']; |
1158 | 1235 | |
1159 | 1236 | // What ones have we already done? |
1160 | - foreach ($table_names as $id => $table) |
|
1161 | - if ($id < $_GET['substep']) |
|
1237 | + foreach ($table_names as $id => $table) { |
|
1238 | + if ($id < $_GET['substep']) |
|
1162 | 1239 | $upcontext['previous_tables'][] = $table; |
1240 | + } |
|
1163 | 1241 | |
1164 | - if ($command_line) |
|
1165 | - echo 'Backing Up Tables.'; |
|
1242 | + if ($command_line) { |
|
1243 | + echo 'Backing Up Tables.'; |
|
1244 | + } |
|
1166 | 1245 | |
1167 | 1246 | // If we don't support javascript we backup here. |
1168 | 1247 | if (!$support_js || isset($_GET['xml'])) |
@@ -1181,8 +1260,9 @@ discard block |
||
1181 | 1260 | backupTable($table_names[$substep]); |
1182 | 1261 | |
1183 | 1262 | // If this is XML to keep it nice for the user do one table at a time anyway! |
1184 | - if (isset($_GET['xml'])) |
|
1185 | - return upgradeExit(); |
|
1263 | + if (isset($_GET['xml'])) { |
|
1264 | + return upgradeExit(); |
|
1265 | + } |
|
1186 | 1266 | } |
1187 | 1267 | |
1188 | 1268 | if ($command_line) |
@@ -1215,9 +1295,10 @@ discard block |
||
1215 | 1295 | |
1216 | 1296 | $smcFunc['db_backup_table']($table, 'backup_' . $table); |
1217 | 1297 | |
1218 | - if ($command_line) |
|
1219 | - echo ' done.'; |
|
1220 | -} |
|
1298 | + if ($command_line) { |
|
1299 | + echo ' done.'; |
|
1300 | + } |
|
1301 | + } |
|
1221 | 1302 | |
1222 | 1303 | // Step 2: Everything. |
1223 | 1304 | function DatabaseChanges() |
@@ -1226,8 +1307,9 @@ discard block |
||
1226 | 1307 | global $upcontext, $support_js, $db_type; |
1227 | 1308 | |
1228 | 1309 | // Have we just completed this? |
1229 | - if (!empty($_POST['database_done'])) |
|
1230 | - return true; |
|
1310 | + if (!empty($_POST['database_done'])) { |
|
1311 | + return true; |
|
1312 | + } |
|
1231 | 1313 | |
1232 | 1314 | $upcontext['sub_template'] = isset($_GET['xml']) ? 'database_xml' : 'database_changes'; |
1233 | 1315 | $upcontext['page_title'] = 'Database Changes'; |
@@ -1242,15 +1324,16 @@ discard block |
||
1242 | 1324 | ); |
1243 | 1325 | |
1244 | 1326 | // How many files are there in total? |
1245 | - if (isset($_GET['filecount'])) |
|
1246 | - $upcontext['file_count'] = (int) $_GET['filecount']; |
|
1247 | - else |
|
1327 | + if (isset($_GET['filecount'])) { |
|
1328 | + $upcontext['file_count'] = (int) $_GET['filecount']; |
|
1329 | + } else |
|
1248 | 1330 | { |
1249 | 1331 | $upcontext['file_count'] = 0; |
1250 | 1332 | foreach ($files as $file) |
1251 | 1333 | { |
1252 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < $file[1]) |
|
1253 | - $upcontext['file_count']++; |
|
1334 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < $file[1]) { |
|
1335 | + $upcontext['file_count']++; |
|
1336 | + } |
|
1254 | 1337 | } |
1255 | 1338 | } |
1256 | 1339 | |
@@ -1260,9 +1343,9 @@ discard block |
||
1260 | 1343 | $upcontext['cur_file_num'] = 0; |
1261 | 1344 | foreach ($files as $file) |
1262 | 1345 | { |
1263 | - if ($did_not_do) |
|
1264 | - $did_not_do--; |
|
1265 | - else |
|
1346 | + if ($did_not_do) { |
|
1347 | + $did_not_do--; |
|
1348 | + } else |
|
1266 | 1349 | { |
1267 | 1350 | $upcontext['cur_file_num']++; |
1268 | 1351 | $upcontext['cur_file_name'] = $file[0]; |
@@ -1289,12 +1372,13 @@ discard block |
||
1289 | 1372 | // Flag to move on to the next. |
1290 | 1373 | $upcontext['completed_step'] = true; |
1291 | 1374 | // Did we complete the whole file? |
1292 | - if ($nextFile) |
|
1293 | - $upcontext['current_debug_item_num'] = -1; |
|
1375 | + if ($nextFile) { |
|
1376 | + $upcontext['current_debug_item_num'] = -1; |
|
1377 | + } |
|
1294 | 1378 | return upgradeExit(); |
1379 | + } elseif ($support_js) { |
|
1380 | + break; |
|
1295 | 1381 | } |
1296 | - elseif ($support_js) |
|
1297 | - break; |
|
1298 | 1382 | } |
1299 | 1383 | // Set the progress bar to be right as if we had - even if we hadn't... |
1300 | 1384 | $upcontext['step_progress'] = ($upcontext['cur_file_num'] / $upcontext['file_count']) * 100; |
@@ -1319,8 +1403,9 @@ discard block |
||
1319 | 1403 | global $command_line, $language, $upcontext, $sourcedir, $forum_version, $user_info, $maintenance, $smcFunc, $db_type; |
1320 | 1404 | |
1321 | 1405 | // Now it's nice to have some of the basic SMF source files. |
1322 | - if (!isset($_GET['ssi']) && !$command_line) |
|
1323 | - redirectLocation('&ssi=1'); |
|
1406 | + if (!isset($_GET['ssi']) && !$command_line) { |
|
1407 | + redirectLocation('&ssi=1'); |
|
1408 | + } |
|
1324 | 1409 | |
1325 | 1410 | $upcontext['sub_template'] = 'upgrade_complete'; |
1326 | 1411 | $upcontext['page_title'] = 'Upgrade Complete'; |
@@ -1336,14 +1421,16 @@ discard block |
||
1336 | 1421 | // Are we in maintenance mode? |
1337 | 1422 | if (isset($upcontext['user']['main'])) |
1338 | 1423 | { |
1339 | - if ($command_line) |
|
1340 | - echo ' * '; |
|
1424 | + if ($command_line) { |
|
1425 | + echo ' * '; |
|
1426 | + } |
|
1341 | 1427 | $upcontext['removed_maintenance'] = true; |
1342 | 1428 | $changes['maintenance'] = $upcontext['user']['main']; |
1343 | 1429 | } |
1344 | 1430 | // Otherwise if somehow we are in 2 let's go to 1. |
1345 | - elseif (!empty($maintenance) && $maintenance == 2) |
|
1346 | - $changes['maintenance'] = 1; |
|
1431 | + elseif (!empty($maintenance) && $maintenance == 2) { |
|
1432 | + $changes['maintenance'] = 1; |
|
1433 | + } |
|
1347 | 1434 | |
1348 | 1435 | // Wipe this out... |
1349 | 1436 | $upcontext['user'] = array(); |
@@ -1358,9 +1445,9 @@ discard block |
||
1358 | 1445 | $upcontext['can_delete_script'] = is_writable(dirname(__FILE__)) || is_writable(__FILE__); |
1359 | 1446 | |
1360 | 1447 | // Now is the perfect time to fetch the SM files. |
1361 | - if ($command_line) |
|
1362 | - cli_scheduled_fetchSMfiles(); |
|
1363 | - else |
|
1448 | + if ($command_line) { |
|
1449 | + cli_scheduled_fetchSMfiles(); |
|
1450 | + } else |
|
1364 | 1451 | { |
1365 | 1452 | require_once($sourcedir . '/ScheduledTasks.php'); |
1366 | 1453 | $forum_version = SMF_VERSION; // The variable is usually defined in index.php so lets just use the constant to do it for us. |
@@ -1368,8 +1455,9 @@ discard block |
||
1368 | 1455 | } |
1369 | 1456 | |
1370 | 1457 | // Log what we've done. |
1371 | - if (empty($user_info['id'])) |
|
1372 | - $user_info['id'] = !empty($upcontext['user']['id']) ? $upcontext['user']['id'] : 0; |
|
1458 | + if (empty($user_info['id'])) { |
|
1459 | + $user_info['id'] = !empty($upcontext['user']['id']) ? $upcontext['user']['id'] : 0; |
|
1460 | + } |
|
1373 | 1461 | |
1374 | 1462 | // Log the action manually, so CLI still works. |
1375 | 1463 | $smcFunc['db_insert']('', |
@@ -1388,8 +1476,9 @@ discard block |
||
1388 | 1476 | |
1389 | 1477 | // Save the current database version. |
1390 | 1478 | $server_version = $smcFunc['db_server_info'](); |
1391 | - if ($db_type == 'mysql' && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) |
|
1392 | - updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
1479 | + if ($db_type == 'mysql' && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) { |
|
1480 | + updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
1481 | + } |
|
1393 | 1482 | |
1394 | 1483 | if ($command_line) |
1395 | 1484 | { |
@@ -1401,8 +1490,9 @@ discard block |
||
1401 | 1490 | |
1402 | 1491 | // Make sure it says we're done. |
1403 | 1492 | $upcontext['overall_percent'] = 100; |
1404 | - if (isset($upcontext['step_progress'])) |
|
1405 | - unset($upcontext['step_progress']); |
|
1493 | + if (isset($upcontext['step_progress'])) { |
|
1494 | + unset($upcontext['step_progress']); |
|
1495 | + } |
|
1406 | 1496 | |
1407 | 1497 | $_GET['substep'] = 0; |
1408 | 1498 | return false; |
@@ -1413,8 +1503,9 @@ discard block |
||
1413 | 1503 | { |
1414 | 1504 | global $sourcedir, $language, $forum_version, $modSettings, $smcFunc; |
1415 | 1505 | |
1416 | - if (empty($modSettings['time_format'])) |
|
1417 | - $modSettings['time_format'] = '%B %d, %Y, %I:%M:%S %p'; |
|
1506 | + if (empty($modSettings['time_format'])) { |
|
1507 | + $modSettings['time_format'] = '%B %d, %Y, %I:%M:%S %p'; |
|
1508 | + } |
|
1418 | 1509 | |
1419 | 1510 | // What files do we want to get |
1420 | 1511 | $request = $smcFunc['db_query']('', ' |
@@ -1448,8 +1539,9 @@ discard block |
||
1448 | 1539 | $file_data = fetch_web_data($url); |
1449 | 1540 | |
1450 | 1541 | // If we got an error - give up - the site might be down. |
1451 | - if ($file_data === false) |
|
1452 | - return throw_error(sprintf('Could not retrieve the file %1$s.', $url)); |
|
1542 | + if ($file_data === false) { |
|
1543 | + return throw_error(sprintf('Could not retrieve the file %1$s.', $url)); |
|
1544 | + } |
|
1453 | 1545 | |
1454 | 1546 | // Save the file to the database. |
1455 | 1547 | $smcFunc['db_query']('substring', ' |
@@ -1491,8 +1583,9 @@ discard block |
||
1491 | 1583 | $themeData = array(); |
1492 | 1584 | foreach ($values as $variable => $value) |
1493 | 1585 | { |
1494 | - if (!isset($value) || $value === null) |
|
1495 | - $value = 0; |
|
1586 | + if (!isset($value) || $value === null) { |
|
1587 | + $value = 0; |
|
1588 | + } |
|
1496 | 1589 | |
1497 | 1590 | $themeData[] = array(0, 1, $variable, $value); |
1498 | 1591 | } |
@@ -1521,8 +1614,9 @@ discard block |
||
1521 | 1614 | |
1522 | 1615 | foreach ($values as $variable => $value) |
1523 | 1616 | { |
1524 | - if (empty($modSettings[$value[0]])) |
|
1525 | - continue; |
|
1617 | + if (empty($modSettings[$value[0]])) { |
|
1618 | + continue; |
|
1619 | + } |
|
1526 | 1620 | |
1527 | 1621 | $smcFunc['db_query']('', ' |
1528 | 1622 | INSERT IGNORE INTO {db_prefix}themes |
@@ -1608,19 +1702,21 @@ discard block |
||
1608 | 1702 | set_error_handler( |
1609 | 1703 | function ($errno, $errstr, $errfile, $errline) use ($support_js) |
1610 | 1704 | { |
1611 | - if ($support_js) |
|
1612 | - return true; |
|
1613 | - else |
|
1614 | - echo 'Error: ' . $errstr . ' File: ' . $errfile . ' Line: ' . $errline; |
|
1705 | + if ($support_js) { |
|
1706 | + return true; |
|
1707 | + } else { |
|
1708 | + echo 'Error: ' . $errstr . ' File: ' . $errfile . ' Line: ' . $errline; |
|
1709 | + } |
|
1615 | 1710 | } |
1616 | 1711 | ); |
1617 | 1712 | |
1618 | 1713 | // If we're on MySQL, set {db_collation}; this approach is used throughout upgrade_2-0_mysql.php to set new tables to utf8 |
1619 | 1714 | // Note it is expected to be in the format: ENGINE=MyISAM{$db_collation}; |
1620 | - if ($db_type == 'mysql') |
|
1621 | - $db_collation = ' DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci'; |
|
1622 | - else |
|
1623 | - $db_collation = ''; |
|
1715 | + if ($db_type == 'mysql') { |
|
1716 | + $db_collation = ' DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci'; |
|
1717 | + } else { |
|
1718 | + $db_collation = ''; |
|
1719 | + } |
|
1624 | 1720 | |
1625 | 1721 | $endl = $command_line ? "\n" : '<br>' . "\n"; |
1626 | 1722 | |
@@ -1632,8 +1728,9 @@ discard block |
||
1632 | 1728 | $last_step = ''; |
1633 | 1729 | |
1634 | 1730 | // Make sure all newly created tables will have the proper characters set; this approach is used throughout upgrade_2-1_mysql.php |
1635 | - if (isset($db_character_set) && $db_character_set === 'utf8') |
|
1636 | - $lines = str_replace(') ENGINE=MyISAM;', ') ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;', $lines); |
|
1731 | + if (isset($db_character_set) && $db_character_set === 'utf8') { |
|
1732 | + $lines = str_replace(') ENGINE=MyISAM;', ') ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;', $lines); |
|
1733 | + } |
|
1637 | 1734 | |
1638 | 1735 | // Count the total number of steps within this file - for progress. |
1639 | 1736 | $file_steps = substr_count(implode('', $lines), '---#'); |
@@ -1653,15 +1750,18 @@ discard block |
||
1653 | 1750 | $do_current = $substep >= $_GET['substep']; |
1654 | 1751 | |
1655 | 1752 | // Get rid of any comments in the beginning of the line... |
1656 | - if (substr(trim($line), 0, 2) === '/*') |
|
1657 | - $line = preg_replace('~/\*.+?\*/~', '', $line); |
|
1753 | + if (substr(trim($line), 0, 2) === '/*') { |
|
1754 | + $line = preg_replace('~/\*.+?\*/~', '', $line); |
|
1755 | + } |
|
1658 | 1756 | |
1659 | 1757 | // Always flush. Flush, flush, flush. Flush, flush, flush, flush! FLUSH! |
1660 | - if ($is_debug && !$support_js && $command_line) |
|
1661 | - flush(); |
|
1758 | + if ($is_debug && !$support_js && $command_line) { |
|
1759 | + flush(); |
|
1760 | + } |
|
1662 | 1761 | |
1663 | - if (trim($line) === '') |
|
1664 | - continue; |
|
1762 | + if (trim($line) === '') { |
|
1763 | + continue; |
|
1764 | + } |
|
1665 | 1765 | |
1666 | 1766 | if (trim(substr($line, 0, 3)) === '---') |
1667 | 1767 | { |
@@ -1671,8 +1771,9 @@ discard block |
||
1671 | 1771 | if (trim($current_data) != '' && $type !== '}') |
1672 | 1772 | { |
1673 | 1773 | $upcontext['error_message'] = 'Error in upgrade script - line ' . $line_number . '!' . $endl; |
1674 | - if ($command_line) |
|
1675 | - echo $upcontext['error_message']; |
|
1774 | + if ($command_line) { |
|
1775 | + echo $upcontext['error_message']; |
|
1776 | + } |
|
1676 | 1777 | } |
1677 | 1778 | |
1678 | 1779 | if ($type == ' ') |
@@ -1690,17 +1791,18 @@ discard block |
||
1690 | 1791 | if ($do_current) |
1691 | 1792 | { |
1692 | 1793 | $upcontext['actioned_items'][] = $last_step; |
1693 | - if ($command_line) |
|
1694 | - echo ' * '; |
|
1794 | + if ($command_line) { |
|
1795 | + echo ' * '; |
|
1796 | + } |
|
1695 | 1797 | } |
1696 | - } |
|
1697 | - elseif ($type == '#') |
|
1798 | + } elseif ($type == '#') |
|
1698 | 1799 | { |
1699 | 1800 | $upcontext['step_progress'] += (100 / $upcontext['file_count']) / $file_steps; |
1700 | 1801 | |
1701 | 1802 | $upcontext['current_debug_item_num']++; |
1702 | - if (trim($line) != '---#') |
|
1703 | - $upcontext['current_debug_item_name'] = htmlspecialchars(rtrim(substr($line, 4))); |
|
1803 | + if (trim($line) != '---#') { |
|
1804 | + $upcontext['current_debug_item_name'] = htmlspecialchars(rtrim(substr($line, 4))); |
|
1805 | + } |
|
1704 | 1806 | |
1705 | 1807 | // Have we already done something? |
1706 | 1808 | if (isset($_GET['xml']) && $done_something) |
@@ -1711,34 +1813,36 @@ discard block |
||
1711 | 1813 | |
1712 | 1814 | if ($do_current) |
1713 | 1815 | { |
1714 | - if (trim($line) == '---#' && $command_line) |
|
1715 | - echo ' done.', $endl; |
|
1716 | - elseif ($command_line) |
|
1717 | - echo ' +++ ', rtrim(substr($line, 4)); |
|
1718 | - elseif (trim($line) != '---#') |
|
1816 | + if (trim($line) == '---#' && $command_line) { |
|
1817 | + echo ' done.', $endl; |
|
1818 | + } elseif ($command_line) { |
|
1819 | + echo ' +++ ', rtrim(substr($line, 4)); |
|
1820 | + } elseif (trim($line) != '---#') |
|
1719 | 1821 | { |
1720 | - if ($is_debug) |
|
1721 | - $upcontext['actioned_items'][] = htmlspecialchars(rtrim(substr($line, 4))); |
|
1822 | + if ($is_debug) { |
|
1823 | + $upcontext['actioned_items'][] = htmlspecialchars(rtrim(substr($line, 4))); |
|
1824 | + } |
|
1722 | 1825 | } |
1723 | 1826 | } |
1724 | 1827 | |
1725 | 1828 | if ($substep < $_GET['substep'] && $substep + 1 >= $_GET['substep']) |
1726 | 1829 | { |
1727 | - if ($command_line) |
|
1728 | - echo ' * '; |
|
1729 | - else |
|
1730 | - $upcontext['actioned_items'][] = $last_step; |
|
1830 | + if ($command_line) { |
|
1831 | + echo ' * '; |
|
1832 | + } else { |
|
1833 | + $upcontext['actioned_items'][] = $last_step; |
|
1834 | + } |
|
1731 | 1835 | } |
1732 | 1836 | |
1733 | 1837 | // Small step - only if we're actually doing stuff. |
1734 | - if ($do_current) |
|
1735 | - nextSubstep(++$substep); |
|
1736 | - else |
|
1737 | - $substep++; |
|
1738 | - } |
|
1739 | - elseif ($type == '{') |
|
1740 | - $current_type = 'code'; |
|
1741 | - elseif ($type == '}') |
|
1838 | + if ($do_current) { |
|
1839 | + nextSubstep(++$substep); |
|
1840 | + } else { |
|
1841 | + $substep++; |
|
1842 | + } |
|
1843 | + } elseif ($type == '{') { |
|
1844 | + $current_type = 'code'; |
|
1845 | + } elseif ($type == '}') |
|
1742 | 1846 | { |
1743 | 1847 | $current_type = 'sql'; |
1744 | 1848 | |
@@ -1751,8 +1855,9 @@ discard block |
||
1751 | 1855 | if (eval('global $db_prefix, $modSettings, $smcFunc; ' . $current_data) === false) |
1752 | 1856 | { |
1753 | 1857 | $upcontext['error_message'] = 'Error in upgrade script ' . basename($filename) . ' on line ' . $line_number . '!' . $endl; |
1754 | - if ($command_line) |
|
1755 | - echo $upcontext['error_message']; |
|
1858 | + if ($command_line) { |
|
1859 | + echo $upcontext['error_message']; |
|
1860 | + } |
|
1756 | 1861 | } |
1757 | 1862 | |
1758 | 1863 | // Done with code! |
@@ -1832,8 +1937,9 @@ discard block |
||
1832 | 1937 | $db_unbuffered = false; |
1833 | 1938 | |
1834 | 1939 | // Failure?! |
1835 | - if ($result !== false) |
|
1836 | - return $result; |
|
1940 | + if ($result !== false) { |
|
1941 | + return $result; |
|
1942 | + } |
|
1837 | 1943 | |
1838 | 1944 | $db_error_message = $smcFunc['db_error']($db_connection); |
1839 | 1945 | // If MySQL we do something more clever. |
@@ -1861,54 +1967,61 @@ discard block |
||
1861 | 1967 | { |
1862 | 1968 | mysqli_query($db_connection, 'REPAIR TABLE `' . $match[1] . '`'); |
1863 | 1969 | $result = mysqli_query($db_connection, $string); |
1864 | - if ($result !== false) |
|
1865 | - return $result; |
|
1970 | + if ($result !== false) { |
|
1971 | + return $result; |
|
1972 | + } |
|
1866 | 1973 | } |
1867 | - } |
|
1868 | - elseif ($mysqli_errno == 2013) |
|
1974 | + } elseif ($mysqli_errno == 2013) |
|
1869 | 1975 | { |
1870 | 1976 | $db_connection = mysqli_connect($db_server, $db_user, $db_passwd); |
1871 | 1977 | mysqli_select_db($db_connection, $db_name); |
1872 | 1978 | if ($db_connection) |
1873 | 1979 | { |
1874 | 1980 | $result = mysqli_query($db_connection, $string); |
1875 | - if ($result !== false) |
|
1876 | - return $result; |
|
1981 | + if ($result !== false) { |
|
1982 | + return $result; |
|
1983 | + } |
|
1877 | 1984 | } |
1878 | 1985 | } |
1879 | 1986 | // Duplicate column name... should be okay ;). |
1880 | - elseif (in_array($mysqli_errno, array(1060, 1061, 1068, 1091))) |
|
1881 | - return false; |
|
1987 | + elseif (in_array($mysqli_errno, array(1060, 1061, 1068, 1091))) { |
|
1988 | + return false; |
|
1989 | + } |
|
1882 | 1990 | // Duplicate insert... make sure it's the proper type of query ;). |
1883 | - elseif (in_array($mysqli_errno, array(1054, 1062, 1146)) && $error_query) |
|
1884 | - return false; |
|
1991 | + elseif (in_array($mysqli_errno, array(1054, 1062, 1146)) && $error_query) { |
|
1992 | + return false; |
|
1993 | + } |
|
1885 | 1994 | // Creating an index on a non-existent column. |
1886 | - elseif ($mysqli_errno == 1072) |
|
1887 | - return false; |
|
1888 | - elseif ($mysqli_errno == 1050 && substr(trim($string), 0, 12) == 'RENAME TABLE') |
|
1889 | - return false; |
|
1995 | + elseif ($mysqli_errno == 1072) { |
|
1996 | + return false; |
|
1997 | + } elseif ($mysqli_errno == 1050 && substr(trim($string), 0, 12) == 'RENAME TABLE') { |
|
1998 | + return false; |
|
1999 | + } |
|
1890 | 2000 | } |
1891 | 2001 | // If a table already exists don't go potty. |
1892 | 2002 | else |
1893 | 2003 | { |
1894 | 2004 | if (in_array(substr(trim($string), 0, 8), array('CREATE T', 'CREATE S', 'DROP TABL', 'ALTER TA', 'CREATE I', 'CREATE U'))) |
1895 | 2005 | { |
1896 | - if (strpos($db_error_message, 'exist') !== false) |
|
1897 | - return true; |
|
1898 | - } |
|
1899 | - elseif (strpos(trim($string), 'INSERT ') !== false) |
|
2006 | + if (strpos($db_error_message, 'exist') !== false) { |
|
2007 | + return true; |
|
2008 | + } |
|
2009 | + } elseif (strpos(trim($string), 'INSERT ') !== false) |
|
1900 | 2010 | { |
1901 | - if (strpos($db_error_message, 'duplicate') !== false) |
|
1902 | - return true; |
|
2011 | + if (strpos($db_error_message, 'duplicate') !== false) { |
|
2012 | + return true; |
|
2013 | + } |
|
1903 | 2014 | } |
1904 | 2015 | } |
1905 | 2016 | |
1906 | 2017 | // Get the query string so we pass everything. |
1907 | 2018 | $query_string = ''; |
1908 | - foreach ($_GET as $k => $v) |
|
1909 | - $query_string .= ';' . $k . '=' . $v; |
|
1910 | - if (strlen($query_string) != 0) |
|
1911 | - $query_string = '?' . substr($query_string, 1); |
|
2019 | + foreach ($_GET as $k => $v) { |
|
2020 | + $query_string .= ';' . $k . '=' . $v; |
|
2021 | + } |
|
2022 | + if (strlen($query_string) != 0) { |
|
2023 | + $query_string = '?' . substr($query_string, 1); |
|
2024 | + } |
|
1912 | 2025 | |
1913 | 2026 | if ($command_line) |
1914 | 2027 | { |
@@ -1963,16 +2076,18 @@ discard block |
||
1963 | 2076 | { |
1964 | 2077 | $found |= 1; |
1965 | 2078 | // Do some checks on the data if we have it set. |
1966 | - if (isset($change['col_type'])) |
|
1967 | - $found &= $change['col_type'] === $column['type']; |
|
1968 | - if (isset($change['null_allowed'])) |
|
1969 | - $found &= $column['null'] == $change['null_allowed']; |
|
1970 | - if (isset($change['default'])) |
|
1971 | - $found &= $change['default'] === $column['default']; |
|
2079 | + if (isset($change['col_type'])) { |
|
2080 | + $found &= $change['col_type'] === $column['type']; |
|
2081 | + } |
|
2082 | + if (isset($change['null_allowed'])) { |
|
2083 | + $found &= $column['null'] == $change['null_allowed']; |
|
2084 | + } |
|
2085 | + if (isset($change['default'])) { |
|
2086 | + $found &= $change['default'] === $column['default']; |
|
2087 | + } |
|
1972 | 2088 | } |
1973 | 2089 | } |
1974 | - } |
|
1975 | - elseif ($change['type'] === 'index') |
|
2090 | + } elseif ($change['type'] === 'index') |
|
1976 | 2091 | { |
1977 | 2092 | $request = upgrade_query(' |
1978 | 2093 | SHOW INDEX |
@@ -1981,9 +2096,10 @@ discard block |
||
1981 | 2096 | { |
1982 | 2097 | $cur_index = array(); |
1983 | 2098 | |
1984 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1985 | - if ($row['Key_name'] === $change['name']) |
|
2099 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2100 | + if ($row['Key_name'] === $change['name']) |
|
1986 | 2101 | $cur_index[(int) $row['Seq_in_index']] = $row['Column_name']; |
2102 | + } |
|
1987 | 2103 | |
1988 | 2104 | ksort($cur_index, SORT_NUMERIC); |
1989 | 2105 | $found = array_values($cur_index) === $change['target_columns']; |
@@ -1993,14 +2109,17 @@ discard block |
||
1993 | 2109 | } |
1994 | 2110 | |
1995 | 2111 | // If we're trying to add and it's added, we're done. |
1996 | - if ($found && in_array($change['method'], array('add', 'change'))) |
|
1997 | - return true; |
|
2112 | + if ($found && in_array($change['method'], array('add', 'change'))) { |
|
2113 | + return true; |
|
2114 | + } |
|
1998 | 2115 | // Otherwise if we're removing and it wasn't found we're also done. |
1999 | - elseif (!$found && in_array($change['method'], array('remove', 'change_remove'))) |
|
2000 | - return true; |
|
2116 | + elseif (!$found && in_array($change['method'], array('remove', 'change_remove'))) { |
|
2117 | + return true; |
|
2118 | + } |
|
2001 | 2119 | // Otherwise is it just a test? |
2002 | - elseif ($is_test) |
|
2003 | - return false; |
|
2120 | + elseif ($is_test) { |
|
2121 | + return false; |
|
2122 | + } |
|
2004 | 2123 | |
2005 | 2124 | // Not found it yet? Bummer! How about we see if we're currently doing it? |
2006 | 2125 | $running = false; |
@@ -2011,8 +2130,9 @@ discard block |
||
2011 | 2130 | SHOW FULL PROCESSLIST'); |
2012 | 2131 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
2013 | 2132 | { |
2014 | - if (strpos($row['Info'], 'ALTER TABLE ' . $db_prefix . $change['table']) !== false && strpos($row['Info'], $change['text']) !== false) |
|
2015 | - $found = true; |
|
2133 | + if (strpos($row['Info'], 'ALTER TABLE ' . $db_prefix . $change['table']) !== false && strpos($row['Info'], $change['text']) !== false) { |
|
2134 | + $found = true; |
|
2135 | + } |
|
2016 | 2136 | } |
2017 | 2137 | |
2018 | 2138 | // Can't find it? Then we need to run it fools! |
@@ -2024,8 +2144,9 @@ discard block |
||
2024 | 2144 | ALTER TABLE ' . $db_prefix . $change['table'] . ' |
2025 | 2145 | ' . $change['text'], true) !== false; |
2026 | 2146 | |
2027 | - if (!$success) |
|
2028 | - return false; |
|
2147 | + if (!$success) { |
|
2148 | + return false; |
|
2149 | + } |
|
2029 | 2150 | |
2030 | 2151 | // Return |
2031 | 2152 | $running = true; |
@@ -2067,8 +2188,9 @@ discard block |
||
2067 | 2188 | 'db_error_skip' => true, |
2068 | 2189 | ) |
2069 | 2190 | ); |
2070 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
2071 | - die('Unable to find column ' . $change['column'] . ' inside table ' . $db_prefix . $change['table']); |
|
2191 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
2192 | + die('Unable to find column ' . $change['column'] . ' inside table ' . $db_prefix . $change['table']); |
|
2193 | + } |
|
2072 | 2194 | $table_row = $smcFunc['db_fetch_assoc']($request); |
2073 | 2195 | $smcFunc['db_free_result']($request); |
2074 | 2196 | |
@@ -2090,18 +2212,19 @@ discard block |
||
2090 | 2212 | ) |
2091 | 2213 | ); |
2092 | 2214 | // No results? Just forget it all together. |
2093 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
2094 | - unset($table_row['Collation']); |
|
2095 | - else |
|
2096 | - $collation_info = $smcFunc['db_fetch_assoc']($request); |
|
2215 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
2216 | + unset($table_row['Collation']); |
|
2217 | + } else { |
|
2218 | + $collation_info = $smcFunc['db_fetch_assoc']($request); |
|
2219 | + } |
|
2097 | 2220 | $smcFunc['db_free_result']($request); |
2098 | 2221 | } |
2099 | 2222 | |
2100 | 2223 | if ($column_fix) |
2101 | 2224 | { |
2102 | 2225 | // Make sure there are no NULL's left. |
2103 | - if ($null_fix) |
|
2104 | - $smcFunc['db_query']('', ' |
|
2226 | + if ($null_fix) { |
|
2227 | + $smcFunc['db_query']('', ' |
|
2105 | 2228 | UPDATE {db_prefix}' . $change['table'] . ' |
2106 | 2229 | SET ' . $change['column'] . ' = {string:default} |
2107 | 2230 | WHERE ' . $change['column'] . ' IS NULL', |
@@ -2110,6 +2233,7 @@ discard block |
||
2110 | 2233 | 'db_error_skip' => true, |
2111 | 2234 | ) |
2112 | 2235 | ); |
2236 | + } |
|
2113 | 2237 | |
2114 | 2238 | // Do the actual alteration. |
2115 | 2239 | $smcFunc['db_query']('', ' |
@@ -2138,8 +2262,9 @@ discard block |
||
2138 | 2262 | } |
2139 | 2263 | |
2140 | 2264 | // Not a column we need to check on? |
2141 | - if (!in_array($change['name'], array('memberGroups', 'passwordSalt'))) |
|
2142 | - return; |
|
2265 | + if (!in_array($change['name'], array('memberGroups', 'passwordSalt'))) { |
|
2266 | + return; |
|
2267 | + } |
|
2143 | 2268 | |
2144 | 2269 | // Break it up you (six|seven). |
2145 | 2270 | $temp = explode(' ', str_replace('NOT NULL', 'NOT_NULL', $change['text'])); |
@@ -2158,13 +2283,13 @@ discard block |
||
2158 | 2283 | 'new_name' => $temp[2], |
2159 | 2284 | )); |
2160 | 2285 | // !!! This doesn't technically work because we don't pass request into it, but it hasn't broke anything yet. |
2161 | - if ($smcFunc['db_num_rows'] != 1) |
|
2162 | - return; |
|
2286 | + if ($smcFunc['db_num_rows'] != 1) { |
|
2287 | + return; |
|
2288 | + } |
|
2163 | 2289 | |
2164 | 2290 | list (, $current_type) = $smcFunc['db_fetch_assoc']($request); |
2165 | 2291 | $smcFunc['db_free_result']($request); |
2166 | - } |
|
2167 | - else |
|
2292 | + } else |
|
2168 | 2293 | { |
2169 | 2294 | // Do this the old fashion, sure method way. |
2170 | 2295 | $request = $smcFunc['db_query']('', ' |
@@ -2175,21 +2300,24 @@ discard block |
||
2175 | 2300 | )); |
2176 | 2301 | // Mayday! |
2177 | 2302 | // !!! This doesn't technically work because we don't pass request into it, but it hasn't broke anything yet. |
2178 | - if ($smcFunc['db_num_rows'] == 0) |
|
2179 | - return; |
|
2303 | + if ($smcFunc['db_num_rows'] == 0) { |
|
2304 | + return; |
|
2305 | + } |
|
2180 | 2306 | |
2181 | 2307 | // Oh where, oh where has my little field gone. Oh where can it be... |
2182 | - while ($row = $smcFunc['db_query']($request)) |
|
2183 | - if ($row['Field'] == $temp[1] || $row['Field'] == $temp[2]) |
|
2308 | + while ($row = $smcFunc['db_query']($request)) { |
|
2309 | + if ($row['Field'] == $temp[1] || $row['Field'] == $temp[2]) |
|
2184 | 2310 | { |
2185 | 2311 | $current_type = $row['Type']; |
2312 | + } |
|
2186 | 2313 | break; |
2187 | 2314 | } |
2188 | 2315 | } |
2189 | 2316 | |
2190 | 2317 | // If this doesn't match, the column may of been altered for a reason. |
2191 | - if (trim($current_type) != trim($temp[3])) |
|
2192 | - $temp[3] = $current_type; |
|
2318 | + if (trim($current_type) != trim($temp[3])) { |
|
2319 | + $temp[3] = $current_type; |
|
2320 | + } |
|
2193 | 2321 | |
2194 | 2322 | // Piece this back together. |
2195 | 2323 | $change['text'] = str_replace('NOT_NULL', 'NOT NULL', implode(' ', $temp)); |
@@ -2201,8 +2329,9 @@ discard block |
||
2201 | 2329 | global $start_time, $timeLimitThreshold, $command_line, $custom_warning; |
2202 | 2330 | global $step_progress, $is_debug, $upcontext; |
2203 | 2331 | |
2204 | - if ($_GET['substep'] < $substep) |
|
2205 | - $_GET['substep'] = $substep; |
|
2332 | + if ($_GET['substep'] < $substep) { |
|
2333 | + $_GET['substep'] = $substep; |
|
2334 | + } |
|
2206 | 2335 | |
2207 | 2336 | if ($command_line) |
2208 | 2337 | { |
@@ -2215,29 +2344,33 @@ discard block |
||
2215 | 2344 | } |
2216 | 2345 | |
2217 | 2346 | @set_time_limit(300); |
2218 | - if (function_exists('apache_reset_timeout')) |
|
2219 | - @apache_reset_timeout(); |
|
2347 | + if (function_exists('apache_reset_timeout')) { |
|
2348 | + @apache_reset_timeout(); |
|
2349 | + } |
|
2220 | 2350 | |
2221 | - if (time() - $start_time <= $timeLimitThreshold) |
|
2222 | - return; |
|
2351 | + if (time() - $start_time <= $timeLimitThreshold) { |
|
2352 | + return; |
|
2353 | + } |
|
2223 | 2354 | |
2224 | 2355 | // Do we have some custom step progress stuff? |
2225 | 2356 | if (!empty($step_progress)) |
2226 | 2357 | { |
2227 | 2358 | $upcontext['substep_progress'] = 0; |
2228 | 2359 | $upcontext['substep_progress_name'] = $step_progress['name']; |
2229 | - if ($step_progress['current'] > $step_progress['total']) |
|
2230 | - $upcontext['substep_progress'] = 99.9; |
|
2231 | - else |
|
2232 | - $upcontext['substep_progress'] = ($step_progress['current'] / $step_progress['total']) * 100; |
|
2360 | + if ($step_progress['current'] > $step_progress['total']) { |
|
2361 | + $upcontext['substep_progress'] = 99.9; |
|
2362 | + } else { |
|
2363 | + $upcontext['substep_progress'] = ($step_progress['current'] / $step_progress['total']) * 100; |
|
2364 | + } |
|
2233 | 2365 | |
2234 | 2366 | // Make it nicely rounded. |
2235 | 2367 | $upcontext['substep_progress'] = round($upcontext['substep_progress'], 1); |
2236 | 2368 | } |
2237 | 2369 | |
2238 | 2370 | // If this is XML we just exit right away! |
2239 | - if (isset($_GET['xml'])) |
|
2240 | - return upgradeExit(); |
|
2371 | + if (isset($_GET['xml'])) { |
|
2372 | + return upgradeExit(); |
|
2373 | + } |
|
2241 | 2374 | |
2242 | 2375 | // We're going to pause after this! |
2243 | 2376 | $upcontext['pause'] = true; |
@@ -2245,13 +2378,15 @@ discard block |
||
2245 | 2378 | $upcontext['query_string'] = ''; |
2246 | 2379 | foreach ($_GET as $k => $v) |
2247 | 2380 | { |
2248 | - if ($k != 'data' && $k != 'substep' && $k != 'step') |
|
2249 | - $upcontext['query_string'] .= ';' . $k . '=' . $v; |
|
2381 | + if ($k != 'data' && $k != 'substep' && $k != 'step') { |
|
2382 | + $upcontext['query_string'] .= ';' . $k . '=' . $v; |
|
2383 | + } |
|
2250 | 2384 | } |
2251 | 2385 | |
2252 | 2386 | // Custom warning? |
2253 | - if (!empty($custom_warning)) |
|
2254 | - $upcontext['custom_warning'] = $custom_warning; |
|
2387 | + if (!empty($custom_warning)) { |
|
2388 | + $upcontext['custom_warning'] = $custom_warning; |
|
2389 | + } |
|
2255 | 2390 | |
2256 | 2391 | upgradeExit(); |
2257 | 2392 | } |
@@ -2266,25 +2401,26 @@ discard block |
||
2266 | 2401 | ob_implicit_flush(true); |
2267 | 2402 | @set_time_limit(600); |
2268 | 2403 | |
2269 | - if (!isset($_SERVER['argv'])) |
|
2270 | - $_SERVER['argv'] = array(); |
|
2404 | + if (!isset($_SERVER['argv'])) { |
|
2405 | + $_SERVER['argv'] = array(); |
|
2406 | + } |
|
2271 | 2407 | $_GET['maint'] = 1; |
2272 | 2408 | |
2273 | 2409 | foreach ($_SERVER['argv'] as $i => $arg) |
2274 | 2410 | { |
2275 | - if (preg_match('~^--language=(.+)$~', $arg, $match) != 0) |
|
2276 | - $_GET['lang'] = $match[1]; |
|
2277 | - elseif (preg_match('~^--path=(.+)$~', $arg) != 0) |
|
2278 | - continue; |
|
2279 | - elseif ($arg == '--no-maintenance') |
|
2280 | - $_GET['maint'] = 0; |
|
2281 | - elseif ($arg == '--debug') |
|
2282 | - $is_debug = true; |
|
2283 | - elseif ($arg == '--backup') |
|
2284 | - $_POST['backup'] = 1; |
|
2285 | - elseif ($arg == '--template' && (file_exists($boarddir . '/template.php') || file_exists($boarddir . '/template.html') && !file_exists($modSettings['theme_dir'] . '/converted'))) |
|
2286 | - $_GET['conv'] = 1; |
|
2287 | - elseif ($i != 0) |
|
2411 | + if (preg_match('~^--language=(.+)$~', $arg, $match) != 0) { |
|
2412 | + $_GET['lang'] = $match[1]; |
|
2413 | + } elseif (preg_match('~^--path=(.+)$~', $arg) != 0) { |
|
2414 | + continue; |
|
2415 | + } elseif ($arg == '--no-maintenance') { |
|
2416 | + $_GET['maint'] = 0; |
|
2417 | + } elseif ($arg == '--debug') { |
|
2418 | + $is_debug = true; |
|
2419 | + } elseif ($arg == '--backup') { |
|
2420 | + $_POST['backup'] = 1; |
|
2421 | + } elseif ($arg == '--template' && (file_exists($boarddir . '/template.php') || file_exists($boarddir . '/template.html') && !file_exists($modSettings['theme_dir'] . '/converted'))) { |
|
2422 | + $_GET['conv'] = 1; |
|
2423 | + } elseif ($i != 0) |
|
2288 | 2424 | { |
2289 | 2425 | echo 'SMF Command-line Upgrader |
2290 | 2426 | Usage: /path/to/php -f ' . basename(__FILE__) . ' -- [OPTION]... |
@@ -2298,10 +2434,12 @@ discard block |
||
2298 | 2434 | } |
2299 | 2435 | } |
2300 | 2436 | |
2301 | - if (!php_version_check()) |
|
2302 | - print_error('Error: PHP ' . PHP_VERSION . ' does not match version requirements.', true); |
|
2303 | - if (!db_version_check()) |
|
2304 | - print_error('Error: ' . $databases[$db_type]['name'] . ' ' . $databases[$db_type]['version'] . ' does not match minimum requirements.', true); |
|
2437 | + if (!php_version_check()) { |
|
2438 | + print_error('Error: PHP ' . PHP_VERSION . ' does not match version requirements.', true); |
|
2439 | + } |
|
2440 | + if (!db_version_check()) { |
|
2441 | + print_error('Error: ' . $databases[$db_type]['name'] . ' ' . $databases[$db_type]['version'] . ' does not match minimum requirements.', true); |
|
2442 | + } |
|
2305 | 2443 | |
2306 | 2444 | // Do some checks to make sure they have proper privileges |
2307 | 2445 | db_extend('packages'); |
@@ -2316,34 +2454,39 @@ discard block |
||
2316 | 2454 | $drop = $smcFunc['db_drop_table']('{db_prefix}priv_check'); |
2317 | 2455 | |
2318 | 2456 | // Sorry... we need CREATE, ALTER and DROP |
2319 | - if (!$create || !$alter || !$drop) |
|
2320 | - print_error("The " . $databases[$db_type]['name'] . " user you have set in Settings.php does not have proper privileges.\n\nPlease ask your host to give this user the ALTER, CREATE, and DROP privileges.", true); |
|
2457 | + if (!$create || !$alter || !$drop) { |
|
2458 | + print_error("The " . $databases[$db_type]['name'] . " user you have set in Settings.php does not have proper privileges.\n\nPlease ask your host to give this user the ALTER, CREATE, and DROP privileges.", true); |
|
2459 | + } |
|
2321 | 2460 | |
2322 | 2461 | $check = @file_exists($modSettings['theme_dir'] . '/index.template.php') |
2323 | 2462 | && @file_exists($sourcedir . '/QueryString.php') |
2324 | 2463 | && @file_exists($sourcedir . '/ManageBoards.php'); |
2325 | - if (!$check && !isset($modSettings['smfVersion'])) |
|
2326 | - print_error('Error: Some files are missing or out-of-date.', true); |
|
2464 | + if (!$check && !isset($modSettings['smfVersion'])) { |
|
2465 | + print_error('Error: Some files are missing or out-of-date.', true); |
|
2466 | + } |
|
2327 | 2467 | |
2328 | 2468 | // Do a quick version spot check. |
2329 | 2469 | $temp = substr(@implode('', @file($boarddir . '/index.php')), 0, 4096); |
2330 | 2470 | preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $temp, $match); |
2331 | - if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) |
|
2332 | - print_error('Error: Some files have not yet been updated properly.'); |
|
2471 | + if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) { |
|
2472 | + print_error('Error: Some files have not yet been updated properly.'); |
|
2473 | + } |
|
2333 | 2474 | |
2334 | 2475 | // Make sure Settings.php is writable. |
2335 | 2476 | quickFileWritable($boarddir . '/Settings.php'); |
2336 | - if (!is_writable($boarddir . '/Settings.php')) |
|
2337 | - print_error('Error: Unable to obtain write access to "Settings.php".', true); |
|
2477 | + if (!is_writable($boarddir . '/Settings.php')) { |
|
2478 | + print_error('Error: Unable to obtain write access to "Settings.php".', true); |
|
2479 | + } |
|
2338 | 2480 | |
2339 | 2481 | // Make sure Settings_bak.php is writable. |
2340 | 2482 | quickFileWritable($boarddir . '/Settings_bak.php'); |
2341 | - if (!is_writable($boarddir . '/Settings_bak.php')) |
|
2342 | - print_error('Error: Unable to obtain write access to "Settings_bak.php".'); |
|
2483 | + if (!is_writable($boarddir . '/Settings_bak.php')) { |
|
2484 | + print_error('Error: Unable to obtain write access to "Settings_bak.php".'); |
|
2485 | + } |
|
2343 | 2486 | |
2344 | - if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) |
|
2345 | - print_error('Error: Unable to obtain write access to "agreement.txt".'); |
|
2346 | - elseif (isset($modSettings['agreement'])) |
|
2487 | + if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) { |
|
2488 | + print_error('Error: Unable to obtain write access to "agreement.txt".'); |
|
2489 | + } elseif (isset($modSettings['agreement'])) |
|
2347 | 2490 | { |
2348 | 2491 | $fp = fopen($boarddir . '/agreement.txt', 'w'); |
2349 | 2492 | fwrite($fp, $modSettings['agreement']); |
@@ -2353,31 +2496,36 @@ discard block |
||
2353 | 2496 | // Make sure Themes is writable. |
2354 | 2497 | quickFileWritable($modSettings['theme_dir']); |
2355 | 2498 | |
2356 | - if (!is_writable($modSettings['theme_dir']) && !isset($modSettings['smfVersion'])) |
|
2357 | - print_error('Error: Unable to obtain write access to "Themes".'); |
|
2499 | + if (!is_writable($modSettings['theme_dir']) && !isset($modSettings['smfVersion'])) { |
|
2500 | + print_error('Error: Unable to obtain write access to "Themes".'); |
|
2501 | + } |
|
2358 | 2502 | |
2359 | 2503 | // Make sure cache directory exists and is writable! |
2360 | 2504 | $cachedir_temp = empty($cachedir) ? $boarddir . '/cache' : $cachedir; |
2361 | - if (!file_exists($cachedir_temp)) |
|
2362 | - @mkdir($cachedir_temp); |
|
2505 | + if (!file_exists($cachedir_temp)) { |
|
2506 | + @mkdir($cachedir_temp); |
|
2507 | + } |
|
2363 | 2508 | |
2364 | 2509 | // Make sure the cache temp dir is writable. |
2365 | 2510 | quickFileWritable($cachedir_temp); |
2366 | 2511 | |
2367 | - if (!is_writable($cachedir_temp)) |
|
2368 | - print_error('Error: Unable to obtain write access to "cache".', true); |
|
2512 | + if (!is_writable($cachedir_temp)) { |
|
2513 | + print_error('Error: Unable to obtain write access to "cache".', true); |
|
2514 | + } |
|
2369 | 2515 | |
2370 | - if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) |
|
2371 | - print_error('Error: Unable to find language files!', true); |
|
2372 | - else |
|
2516 | + if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) { |
|
2517 | + print_error('Error: Unable to find language files!', true); |
|
2518 | + } else |
|
2373 | 2519 | { |
2374 | 2520 | $temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php')), 0, 4096); |
2375 | 2521 | preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match); |
2376 | 2522 | |
2377 | - if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) |
|
2378 | - print_error('Error: Language files out of date.', true); |
|
2379 | - if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) |
|
2380 | - print_error('Error: Install language is missing for selected language.', true); |
|
2523 | + if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) { |
|
2524 | + print_error('Error: Language files out of date.', true); |
|
2525 | + } |
|
2526 | + if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) { |
|
2527 | + print_error('Error: Install language is missing for selected language.', true); |
|
2528 | + } |
|
2381 | 2529 | |
2382 | 2530 | // Otherwise include it! |
2383 | 2531 | require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
@@ -2396,8 +2544,9 @@ discard block |
||
2396 | 2544 | global $upcontext, $db_character_set, $sourcedir, $smcFunc, $modSettings, $language, $db_prefix, $db_type, $command_line, $support_js; |
2397 | 2545 | |
2398 | 2546 | // Done it already? |
2399 | - if (!empty($_POST['utf8_done'])) |
|
2400 | - return true; |
|
2547 | + if (!empty($_POST['utf8_done'])) { |
|
2548 | + return true; |
|
2549 | + } |
|
2401 | 2550 | |
2402 | 2551 | // First make sure they aren't already on UTF-8 before we go anywhere... |
2403 | 2552 | if ($db_type == 'postgresql' || ($db_character_set === 'utf8' && !empty($modSettings['global_character_set']) && $modSettings['global_character_set'] === 'UTF-8')) |
@@ -2410,8 +2559,7 @@ discard block |
||
2410 | 2559 | ); |
2411 | 2560 | |
2412 | 2561 | return true; |
2413 | - } |
|
2414 | - else |
|
2562 | + } else |
|
2415 | 2563 | { |
2416 | 2564 | $upcontext['page_title'] = 'Converting to UTF8'; |
2417 | 2565 | $upcontext['sub_template'] = isset($_GET['xml']) ? 'convert_xml' : 'convert_utf8'; |
@@ -2455,8 +2603,9 @@ discard block |
||
2455 | 2603 | ) |
2456 | 2604 | ); |
2457 | 2605 | $db_charsets = array(); |
2458 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
2459 | - $db_charsets[] = $row['Charset']; |
|
2606 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2607 | + $db_charsets[] = $row['Charset']; |
|
2608 | + } |
|
2460 | 2609 | |
2461 | 2610 | $smcFunc['db_free_result']($request); |
2462 | 2611 | |
@@ -2492,13 +2641,15 @@ discard block |
||
2492 | 2641 | // If there's a fulltext index, we need to drop it first... |
2493 | 2642 | if ($request !== false || $smcFunc['db_num_rows']($request) != 0) |
2494 | 2643 | { |
2495 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
2496 | - if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT')) |
|
2644 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2645 | + if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT')) |
|
2497 | 2646 | $upcontext['fulltext_index'][] = $row['Key_name']; |
2647 | + } |
|
2498 | 2648 | $smcFunc['db_free_result']($request); |
2499 | 2649 | |
2500 | - if (isset($upcontext['fulltext_index'])) |
|
2501 | - $upcontext['fulltext_index'] = array_unique($upcontext['fulltext_index']); |
|
2650 | + if (isset($upcontext['fulltext_index'])) { |
|
2651 | + $upcontext['fulltext_index'] = array_unique($upcontext['fulltext_index']); |
|
2652 | + } |
|
2502 | 2653 | } |
2503 | 2654 | |
2504 | 2655 | // Drop it and make a note... |
@@ -2688,8 +2839,9 @@ discard block |
||
2688 | 2839 | $replace = '%field%'; |
2689 | 2840 | |
2690 | 2841 | // Build a huge REPLACE statement... |
2691 | - foreach ($translation_tables[$upcontext['charset_detected']] as $from => $to) |
|
2692 | - $replace = 'REPLACE(' . $replace . ', ' . $from . ', ' . $to . ')'; |
|
2842 | + foreach ($translation_tables[$upcontext['charset_detected']] as $from => $to) { |
|
2843 | + $replace = 'REPLACE(' . $replace . ', ' . $from . ', ' . $to . ')'; |
|
2844 | + } |
|
2693 | 2845 | } |
2694 | 2846 | |
2695 | 2847 | // Get a list of table names ahead of time... This makes it easier to set our substep and such |
@@ -2699,9 +2851,10 @@ discard block |
||
2699 | 2851 | $upcontext['table_count'] = count($queryTables); |
2700 | 2852 | |
2701 | 2853 | // What ones have we already done? |
2702 | - foreach ($queryTables as $id => $table) |
|
2703 | - if ($id < $_GET['substep']) |
|
2854 | + foreach ($queryTables as $id => $table) { |
|
2855 | + if ($id < $_GET['substep']) |
|
2704 | 2856 | $upcontext['previous_tables'][] = $table; |
2857 | + } |
|
2705 | 2858 | |
2706 | 2859 | $upcontext['cur_table_num'] = $_GET['substep']; |
2707 | 2860 | $upcontext['cur_table_name'] = str_replace($db_prefix, '', $queryTables[$_GET['substep']]); |
@@ -2738,8 +2891,9 @@ discard block |
||
2738 | 2891 | nextSubstep($substep); |
2739 | 2892 | |
2740 | 2893 | // Just to make sure it doesn't time out. |
2741 | - if (function_exists('apache_reset_timeout')) |
|
2742 | - @apache_reset_timeout(); |
|
2894 | + if (function_exists('apache_reset_timeout')) { |
|
2895 | + @apache_reset_timeout(); |
|
2896 | + } |
|
2743 | 2897 | |
2744 | 2898 | $table_charsets = array(); |
2745 | 2899 | |
@@ -2760,8 +2914,9 @@ discard block |
||
2760 | 2914 | { |
2761 | 2915 | list($charset) = explode('_', $collation); |
2762 | 2916 | |
2763 | - if (!isset($table_charsets[$charset])) |
|
2764 | - $table_charsets[$charset] = array(); |
|
2917 | + if (!isset($table_charsets[$charset])) { |
|
2918 | + $table_charsets[$charset] = array(); |
|
2919 | + } |
|
2765 | 2920 | |
2766 | 2921 | $table_charsets[$charset][] = $column_info; |
2767 | 2922 | } |
@@ -2801,10 +2956,11 @@ discard block |
||
2801 | 2956 | if (isset($translation_tables[$upcontext['charset_detected']])) |
2802 | 2957 | { |
2803 | 2958 | $update = ''; |
2804 | - foreach ($table_charsets as $charset => $columns) |
|
2805 | - foreach ($columns as $column) |
|
2959 | + foreach ($table_charsets as $charset => $columns) { |
|
2960 | + foreach ($columns as $column) |
|
2806 | 2961 | $update .= ' |
2807 | 2962 | ' . $column['Field'] . ' = ' . strtr($replace, array('%field%' => $column['Field'])) . ','; |
2963 | + } |
|
2808 | 2964 | |
2809 | 2965 | $smcFunc['db_query']('', ' |
2810 | 2966 | UPDATE {raw:table_name} |
@@ -2829,8 +2985,9 @@ discard block |
||
2829 | 2985 | // Now do the actual conversion (if still needed). |
2830 | 2986 | if ($charsets[$upcontext['charset_detected']] !== 'utf8') |
2831 | 2987 | { |
2832 | - if ($command_line) |
|
2833 | - echo 'Converting table ' . $table_info['Name'] . ' to UTF-8...'; |
|
2988 | + if ($command_line) { |
|
2989 | + echo 'Converting table ' . $table_info['Name'] . ' to UTF-8...'; |
|
2990 | + } |
|
2834 | 2991 | |
2835 | 2992 | $smcFunc['db_query']('', ' |
2836 | 2993 | ALTER TABLE {raw:table_name} |
@@ -2840,12 +2997,14 @@ discard block |
||
2840 | 2997 | ) |
2841 | 2998 | ); |
2842 | 2999 | |
2843 | - if ($command_line) |
|
2844 | - echo " done.\n"; |
|
3000 | + if ($command_line) { |
|
3001 | + echo " done.\n"; |
|
3002 | + } |
|
2845 | 3003 | } |
2846 | 3004 | // If this is XML to keep it nice for the user do one table at a time anyway! |
2847 | - if (isset($_GET['xml'])) |
|
2848 | - return upgradeExit(); |
|
3005 | + if (isset($_GET['xml'])) { |
|
3006 | + return upgradeExit(); |
|
3007 | + } |
|
2849 | 3008 | } |
2850 | 3009 | |
2851 | 3010 | $prev_charset = empty($translation_tables[$upcontext['charset_detected']]) ? $charsets[$upcontext['charset_detected']] : $translation_tables[$upcontext['charset_detected']]; |
@@ -2874,8 +3033,8 @@ discard block |
||
2874 | 3033 | ); |
2875 | 3034 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
2876 | 3035 | { |
2877 | - if (@safe_unserialize($row['extra']) === false && preg_match('~^(a:3:{s:5:"topic";i:\d+;s:7:"subject";s:)(\d+):"(.+)"(;s:6:"member";s:5:"\d+";})$~', $row['extra'], $matches) === 1) |
|
2878 | - $smcFunc['db_query']('', ' |
|
3036 | + if (@safe_unserialize($row['extra']) === false && preg_match('~^(a:3:{s:5:"topic";i:\d+;s:7:"subject";s:)(\d+):"(.+)"(;s:6:"member";s:5:"\d+";})$~', $row['extra'], $matches) === 1) { |
|
3037 | + $smcFunc['db_query']('', ' |
|
2879 | 3038 | UPDATE {db_prefix}log_actions |
2880 | 3039 | SET extra = {string:extra} |
2881 | 3040 | WHERE id_action = {int:current_action}', |
@@ -2884,6 +3043,7 @@ discard block |
||
2884 | 3043 | 'extra' => $matches[1] . strlen($matches[3]) . ':"' . $matches[3] . '"' . $matches[4], |
2885 | 3044 | ) |
2886 | 3045 | ); |
3046 | + } |
|
2887 | 3047 | } |
2888 | 3048 | $smcFunc['db_free_result']($request); |
2889 | 3049 | |
@@ -2905,15 +3065,17 @@ discard block |
||
2905 | 3065 | // First thing's first - did we already do this? |
2906 | 3066 | if (!empty($modSettings['json_done'])) |
2907 | 3067 | { |
2908 | - if ($command_line) |
|
2909 | - return DeleteUpgrade(); |
|
2910 | - else |
|
2911 | - return true; |
|
3068 | + if ($command_line) { |
|
3069 | + return DeleteUpgrade(); |
|
3070 | + } else { |
|
3071 | + return true; |
|
3072 | + } |
|
2912 | 3073 | } |
2913 | 3074 | |
2914 | 3075 | // Done it already - js wise? |
2915 | - if (!empty($_POST['json_done'])) |
|
2916 | - return true; |
|
3076 | + if (!empty($_POST['json_done'])) { |
|
3077 | + return true; |
|
3078 | + } |
|
2917 | 3079 | |
2918 | 3080 | // List of tables affected by this function |
2919 | 3081 | // name => array('key', col1[,col2|true[,col3]]) |
@@ -2945,12 +3107,14 @@ discard block |
||
2945 | 3107 | $upcontext['cur_table_name'] = isset($keys[$_GET['substep']]) ? $keys[$_GET['substep']] : $keys[0]; |
2946 | 3108 | $upcontext['step_progress'] = (int) (($upcontext['cur_table_num'] / $upcontext['table_count']) * 100); |
2947 | 3109 | |
2948 | - foreach ($keys as $id => $table) |
|
2949 | - if ($id < $_GET['substep']) |
|
3110 | + foreach ($keys as $id => $table) { |
|
3111 | + if ($id < $_GET['substep']) |
|
2950 | 3112 | $upcontext['previous_tables'][] = $table; |
3113 | + } |
|
2951 | 3114 | |
2952 | - if ($command_line) |
|
2953 | - echo 'Converting data from serialize() to json_encode().'; |
|
3115 | + if ($command_line) { |
|
3116 | + echo 'Converting data from serialize() to json_encode().'; |
|
3117 | + } |
|
2954 | 3118 | |
2955 | 3119 | if (!$support_js || isset($_GET['xml'])) |
2956 | 3120 | { |
@@ -2990,8 +3154,9 @@ discard block |
||
2990 | 3154 | |
2991 | 3155 | // Loop through and fix these... |
2992 | 3156 | $new_settings = array(); |
2993 | - if ($command_line) |
|
2994 | - echo "\n" . 'Fixing some settings...'; |
|
3157 | + if ($command_line) { |
|
3158 | + echo "\n" . 'Fixing some settings...'; |
|
3159 | + } |
|
2995 | 3160 | |
2996 | 3161 | foreach ($serialized_settings as $var) |
2997 | 3162 | { |
@@ -2999,22 +3164,24 @@ discard block |
||
2999 | 3164 | { |
3000 | 3165 | // Attempt to unserialize the setting |
3001 | 3166 | $temp = @safe_unserialize($modSettings[$var]); |
3002 | - if (!$temp && $command_line) |
|
3003 | - echo "\n - Failed to unserialize the '" . $var . "' setting. Skipping."; |
|
3004 | - elseif ($temp !== false) |
|
3005 | - $new_settings[$var] = json_encode($temp); |
|
3167 | + if (!$temp && $command_line) { |
|
3168 | + echo "\n - Failed to unserialize the '" . $var . "' setting. Skipping."; |
|
3169 | + } elseif ($temp !== false) { |
|
3170 | + $new_settings[$var] = json_encode($temp); |
|
3171 | + } |
|
3006 | 3172 | } |
3007 | 3173 | } |
3008 | 3174 | |
3009 | 3175 | // Update everything at once |
3010 | - if (!function_exists('cache_put_data')) |
|
3011 | - require_once($sourcedir . '/Load.php'); |
|
3176 | + if (!function_exists('cache_put_data')) { |
|
3177 | + require_once($sourcedir . '/Load.php'); |
|
3178 | + } |
|
3012 | 3179 | updateSettings($new_settings, true); |
3013 | 3180 | |
3014 | - if ($command_line) |
|
3015 | - echo ' done.'; |
|
3016 | - } |
|
3017 | - elseif ($table == 'themes') |
|
3181 | + if ($command_line) { |
|
3182 | + echo ' done.'; |
|
3183 | + } |
|
3184 | + } elseif ($table == 'themes') |
|
3018 | 3185 | { |
3019 | 3186 | // Finally, fix the admin prefs. Unfortunately this is stored per theme, but hopefully they only have one theme installed at this point... |
3020 | 3187 | $query = $smcFunc['db_query']('', ' |
@@ -3033,10 +3200,11 @@ discard block |
||
3033 | 3200 | |
3034 | 3201 | if ($command_line) |
3035 | 3202 | { |
3036 | - if ($temp === false) |
|
3037 | - echo "\n" . 'Unserialize of admin_preferences for user ' . $row['id_member'] . ' failed. Skipping.'; |
|
3038 | - else |
|
3039 | - echo "\n" . 'Fixing admin preferences...'; |
|
3203 | + if ($temp === false) { |
|
3204 | + echo "\n" . 'Unserialize of admin_preferences for user ' . $row['id_member'] . ' failed. Skipping.'; |
|
3205 | + } else { |
|
3206 | + echo "\n" . 'Fixing admin preferences...'; |
|
3207 | + } |
|
3040 | 3208 | } |
3041 | 3209 | |
3042 | 3210 | if ($temp !== false) |
@@ -3058,15 +3226,15 @@ discard block |
||
3058 | 3226 | ) |
3059 | 3227 | ); |
3060 | 3228 | |
3061 | - if ($command_line) |
|
3062 | - echo ' done.'; |
|
3229 | + if ($command_line) { |
|
3230 | + echo ' done.'; |
|
3231 | + } |
|
3063 | 3232 | } |
3064 | 3233 | } |
3065 | 3234 | |
3066 | 3235 | $smcFunc['db_free_result']($query); |
3067 | 3236 | } |
3068 | - } |
|
3069 | - else |
|
3237 | + } else |
|
3070 | 3238 | { |
3071 | 3239 | // First item is always the key... |
3072 | 3240 | $key = $info[0]; |
@@ -3077,8 +3245,7 @@ discard block |
||
3077 | 3245 | { |
3078 | 3246 | $col_select = $info[1]; |
3079 | 3247 | $where = ' WHERE ' . $info[1] . ' != {empty}'; |
3080 | - } |
|
3081 | - else |
|
3248 | + } else |
|
3082 | 3249 | { |
3083 | 3250 | $col_select = implode(', ', $info); |
3084 | 3251 | } |
@@ -3111,8 +3278,7 @@ discard block |
||
3111 | 3278 | if ($temp === false && $command_line) |
3112 | 3279 | { |
3113 | 3280 | echo "\nFailed to unserialize " . $row[$col] . "... Skipping\n"; |
3114 | - } |
|
3115 | - else |
|
3281 | + } else |
|
3116 | 3282 | { |
3117 | 3283 | $row[$col] = json_encode($temp); |
3118 | 3284 | |
@@ -3137,16 +3303,18 @@ discard block |
||
3137 | 3303 | } |
3138 | 3304 | } |
3139 | 3305 | |
3140 | - if ($command_line) |
|
3141 | - echo ' done.'; |
|
3306 | + if ($command_line) { |
|
3307 | + echo ' done.'; |
|
3308 | + } |
|
3142 | 3309 | |
3143 | 3310 | // Free up some memory... |
3144 | 3311 | $smcFunc['db_free_result']($query); |
3145 | 3312 | } |
3146 | 3313 | } |
3147 | 3314 | // If this is XML to keep it nice for the user do one table at a time anyway! |
3148 | - if (isset($_GET['xml'])) |
|
3149 | - return upgradeExit(); |
|
3315 | + if (isset($_GET['xml'])) { |
|
3316 | + return upgradeExit(); |
|
3317 | + } |
|
3150 | 3318 | } |
3151 | 3319 | |
3152 | 3320 | if ($command_line) |
@@ -3161,8 +3329,9 @@ discard block |
||
3161 | 3329 | |
3162 | 3330 | $_GET['substep'] = 0; |
3163 | 3331 | // Make sure we move on! |
3164 | - if ($command_line) |
|
3165 | - return DeleteUpgrade(); |
|
3332 | + if ($command_line) { |
|
3333 | + return DeleteUpgrade(); |
|
3334 | + } |
|
3166 | 3335 | |
3167 | 3336 | return true; |
3168 | 3337 | } |
@@ -3182,14 +3351,16 @@ discard block |
||
3182 | 3351 | global $upcontext, $txt, $settings; |
3183 | 3352 | |
3184 | 3353 | // Don't call me twice! |
3185 | - if (!empty($upcontext['chmod_called'])) |
|
3186 | - return; |
|
3354 | + if (!empty($upcontext['chmod_called'])) { |
|
3355 | + return; |
|
3356 | + } |
|
3187 | 3357 | |
3188 | 3358 | $upcontext['chmod_called'] = true; |
3189 | 3359 | |
3190 | 3360 | // Nothing? |
3191 | - if (empty($upcontext['chmod']['files']) && empty($upcontext['chmod']['ftp_error'])) |
|
3192 | - return; |
|
3361 | + if (empty($upcontext['chmod']['files']) && empty($upcontext['chmod']['ftp_error'])) { |
|
3362 | + return; |
|
3363 | + } |
|
3193 | 3364 | |
3194 | 3365 | // Was it a problem with Windows? |
3195 | 3366 | if (!empty($upcontext['chmod']['ftp_error']) && $upcontext['chmod']['ftp_error'] == 'total_mess') |
@@ -3221,11 +3392,12 @@ discard block |
||
3221 | 3392 | content.write(\'<div class="windowbg description">\n\t\t\t<h4>The following files needs to be made writable to continue:</h4>\n\t\t\t\'); |
3222 | 3393 | content.write(\'<p>', implode('<br>\n\t\t\t', $upcontext['chmod']['files']), '</p>\n\t\t\t\');'; |
3223 | 3394 | |
3224 | - if (isset($upcontext['systemos']) && $upcontext['systemos'] == 'linux') |
|
3225 | - echo ' |
|
3395 | + if (isset($upcontext['systemos']) && $upcontext['systemos'] == 'linux') { |
|
3396 | + echo ' |
|
3226 | 3397 | content.write(\'<hr>\n\t\t\t\'); |
3227 | 3398 | content.write(\'<p>If you have a shell account, the convenient below command can automatically correct permissions on these files</p>\n\t\t\t\'); |
3228 | 3399 | content.write(\'<tt># chmod a+w ', implode(' ', $upcontext['chmod']['files']), '</tt>\n\t\t\t\');'; |
3400 | + } |
|
3229 | 3401 | |
3230 | 3402 | echo ' |
3231 | 3403 | content.write(\'<a href="javascript:self.close();">close</a>\n\t\t</div>\n\t</body>\n</html>\'); |
@@ -3233,17 +3405,19 @@ discard block |
||
3233 | 3405 | } |
3234 | 3406 | </script>'; |
3235 | 3407 | |
3236 | - if (!empty($upcontext['chmod']['ftp_error'])) |
|
3237 | - echo ' |
|
3408 | + if (!empty($upcontext['chmod']['ftp_error'])) { |
|
3409 | + echo ' |
|
3238 | 3410 | <div class="error_message red"> |
3239 | 3411 | The following error was encountered when trying to connect:<br><br> |
3240 | 3412 | <code>', $upcontext['chmod']['ftp_error'], '</code> |
3241 | 3413 | </div> |
3242 | 3414 | <br>'; |
3415 | + } |
|
3243 | 3416 | |
3244 | - if (empty($upcontext['chmod_in_form'])) |
|
3245 | - echo ' |
|
3417 | + if (empty($upcontext['chmod_in_form'])) { |
|
3418 | + echo ' |
|
3246 | 3419 | <form action="', $upcontext['form_url'], '" method="post">'; |
3420 | + } |
|
3247 | 3421 | |
3248 | 3422 | echo ' |
3249 | 3423 | <table width="520" border="0" align="center" style="margin-bottom: 1ex;"> |
@@ -3278,10 +3452,11 @@ discard block |
||
3278 | 3452 | <div class="righttext" style="margin: 1ex;"><input type="submit" value="', $txt['ftp_connect'], '" class="button_submit"></div> |
3279 | 3453 | </div>'; |
3280 | 3454 | |
3281 | - if (empty($upcontext['chmod_in_form'])) |
|
3282 | - echo ' |
|
3455 | + if (empty($upcontext['chmod_in_form'])) { |
|
3456 | + echo ' |
|
3283 | 3457 | </form>'; |
3284 | -} |
|
3458 | + } |
|
3459 | + } |
|
3285 | 3460 | |
3286 | 3461 | function template_upgrade_above() |
3287 | 3462 | { |
@@ -3341,9 +3516,10 @@ discard block |
||
3341 | 3516 | <h2>', $txt['upgrade_progress'], '</h2> |
3342 | 3517 | <ul>'; |
3343 | 3518 | |
3344 | - foreach ($upcontext['steps'] as $num => $step) |
|
3345 | - echo ' |
|
3519 | + foreach ($upcontext['steps'] as $num => $step) { |
|
3520 | + echo ' |
|
3346 | 3521 | <li class="', $num < $upcontext['current_step'] ? 'stepdone' : ($num == $upcontext['current_step'] ? 'stepcurrent' : 'stepwaiting'), '">', $txt['upgrade_step'], ' ', $step[0], ': ', $step[1], '</li>'; |
3522 | + } |
|
3347 | 3523 | |
3348 | 3524 | echo ' |
3349 | 3525 | </ul> |
@@ -3356,8 +3532,8 @@ discard block |
||
3356 | 3532 | </div> |
3357 | 3533 | </div>'; |
3358 | 3534 | |
3359 | - if (isset($upcontext['step_progress'])) |
|
3360 | - echo ' |
|
3535 | + if (isset($upcontext['step_progress'])) { |
|
3536 | + echo ' |
|
3361 | 3537 | <br> |
3362 | 3538 | <br> |
3363 | 3539 | <div id="progress_bar_step"> |
@@ -3366,6 +3542,7 @@ discard block |
||
3366 | 3542 | <span>', $txt['upgrade_step_progress'], '</span> |
3367 | 3543 | </div> |
3368 | 3544 | </div>'; |
3545 | + } |
|
3369 | 3546 | |
3370 | 3547 | echo ' |
3371 | 3548 | <div id="substep_bar_div" class="smalltext" style="float: left;width: 50%;margin-top: 0.6em;display: ', isset($upcontext['substep_progress']) ? '' : 'none', ';">', isset($upcontext['substep_progress_name']) ? trim(strtr($upcontext['substep_progress_name'], array('.' => ''))) : '', ':</div> |
@@ -3396,32 +3573,36 @@ discard block |
||
3396 | 3573 | { |
3397 | 3574 | global $upcontext, $txt; |
3398 | 3575 | |
3399 | - if (!empty($upcontext['pause'])) |
|
3400 | - echo ' |
|
3576 | + if (!empty($upcontext['pause'])) { |
|
3577 | + echo ' |
|
3401 | 3578 | <em>', $txt['upgrade_incomplete'], '.</em><br> |
3402 | 3579 | |
3403 | 3580 | <h2 style="margin-top: 2ex;">', $txt['upgrade_not_quite_done'], '</h2> |
3404 | 3581 | <h3> |
3405 | 3582 | ', $txt['upgrade_paused_overload'], ' |
3406 | 3583 | </h3>'; |
3584 | + } |
|
3407 | 3585 | |
3408 | - if (!empty($upcontext['custom_warning'])) |
|
3409 | - echo ' |
|
3586 | + if (!empty($upcontext['custom_warning'])) { |
|
3587 | + echo ' |
|
3410 | 3588 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
3411 | 3589 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
3412 | 3590 | <strong style="text-decoration: underline;">', $txt['upgrade_note'], '</strong><br> |
3413 | 3591 | <div style="padding-left: 6ex;">', $upcontext['custom_warning'], '</div> |
3414 | 3592 | </div>'; |
3593 | + } |
|
3415 | 3594 | |
3416 | 3595 | echo ' |
3417 | 3596 | <div class="righttext" style="margin: 1ex;">'; |
3418 | 3597 | |
3419 | - if (!empty($upcontext['continue'])) |
|
3420 | - echo ' |
|
3598 | + if (!empty($upcontext['continue'])) { |
|
3599 | + echo ' |
|
3421 | 3600 | <input type="submit" id="contbutt" name="contbutt" value="', $txt['upgrade_continue'], '"', $upcontext['continue'] == 2 ? ' disabled' : '', ' class="button_submit">'; |
3422 | - if (!empty($upcontext['skip'])) |
|
3423 | - echo ' |
|
3601 | + } |
|
3602 | + if (!empty($upcontext['skip'])) { |
|
3603 | + echo ' |
|
3424 | 3604 | <input type="submit" id="skip" name="skip" value="', $txt['upgrade_skip'], '" onclick="dontSubmit = true; document.getElementById(\'contbutt\').disabled = \'disabled\'; return true;" class="button_submit">'; |
3605 | + } |
|
3425 | 3606 | |
3426 | 3607 | echo ' |
3427 | 3608 | </div> |
@@ -3471,11 +3652,12 @@ discard block |
||
3471 | 3652 | echo '<', '?xml version="1.0" encoding="UTF-8"?', '> |
3472 | 3653 | <smf>'; |
3473 | 3654 | |
3474 | - if (!empty($upcontext['get_data'])) |
|
3475 | - foreach ($upcontext['get_data'] as $k => $v) |
|
3655 | + if (!empty($upcontext['get_data'])) { |
|
3656 | + foreach ($upcontext['get_data'] as $k => $v) |
|
3476 | 3657 | echo ' |
3477 | 3658 | <get key="', $k, '">', $v, '</get>'; |
3478 | -} |
|
3659 | + } |
|
3660 | + } |
|
3479 | 3661 | |
3480 | 3662 | function template_xml_below() |
3481 | 3663 | { |
@@ -3516,8 +3698,8 @@ discard block |
||
3516 | 3698 | template_chmod(); |
3517 | 3699 | |
3518 | 3700 | // For large, pre 1.1 RC2 forums give them a warning about the possible impact of this upgrade! |
3519 | - if ($upcontext['is_large_forum']) |
|
3520 | - echo ' |
|
3701 | + if ($upcontext['is_large_forum']) { |
|
3702 | + echo ' |
|
3521 | 3703 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
3522 | 3704 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
3523 | 3705 | <strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br> |
@@ -3525,10 +3707,11 @@ discard block |
||
3525 | 3707 | ', $txt['upgrade_warning_lots_data'], ' |
3526 | 3708 | </div> |
3527 | 3709 | </div>'; |
3710 | + } |
|
3528 | 3711 | |
3529 | 3712 | // A warning message? |
3530 | - if (!empty($upcontext['warning'])) |
|
3531 | - echo ' |
|
3713 | + if (!empty($upcontext['warning'])) { |
|
3714 | + echo ' |
|
3532 | 3715 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
3533 | 3716 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
3534 | 3717 | <strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br> |
@@ -3536,6 +3719,7 @@ discard block |
||
3536 | 3719 | ', $upcontext['warning'], ' |
3537 | 3720 | </div> |
3538 | 3721 | </div>'; |
3722 | + } |
|
3539 | 3723 | |
3540 | 3724 | // Paths are incorrect? |
3541 | 3725 | echo ' |
@@ -3551,20 +3735,22 @@ discard block |
||
3551 | 3735 | if (!empty($upcontext['user']['id']) && (time() - $upcontext['started'] < 72600 || time() - $upcontext['updated'] < 3600)) |
3552 | 3736 | { |
3553 | 3737 | $ago = time() - $upcontext['started']; |
3554 | - if ($ago < 60) |
|
3555 | - $ago = $ago . ' seconds'; |
|
3556 | - elseif ($ago < 3600) |
|
3557 | - $ago = (int) ($ago / 60) . ' minutes'; |
|
3558 | - else |
|
3559 | - $ago = (int) ($ago / 3600) . ' hours'; |
|
3738 | + if ($ago < 60) { |
|
3739 | + $ago = $ago . ' seconds'; |
|
3740 | + } elseif ($ago < 3600) { |
|
3741 | + $ago = (int) ($ago / 60) . ' minutes'; |
|
3742 | + } else { |
|
3743 | + $ago = (int) ($ago / 3600) . ' hours'; |
|
3744 | + } |
|
3560 | 3745 | |
3561 | 3746 | $active = time() - $upcontext['updated']; |
3562 | - if ($active < 60) |
|
3563 | - $updated = $active . ' seconds'; |
|
3564 | - elseif ($active < 3600) |
|
3565 | - $updated = (int) ($active / 60) . ' minutes'; |
|
3566 | - else |
|
3567 | - $updated = (int) ($active / 3600) . ' hours'; |
|
3747 | + if ($active < 60) { |
|
3748 | + $updated = $active . ' seconds'; |
|
3749 | + } elseif ($active < 3600) { |
|
3750 | + $updated = (int) ($active / 60) . ' minutes'; |
|
3751 | + } else { |
|
3752 | + $updated = (int) ($active / 3600) . ' hours'; |
|
3753 | + } |
|
3568 | 3754 | |
3569 | 3755 | echo ' |
3570 | 3756 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
@@ -3573,16 +3759,18 @@ discard block |
||
3573 | 3759 | <div style="padding-left: 6ex;"> |
3574 | 3760 | "', $upcontext['user']['name'], '" has been running the upgrade script for the last ', $ago, ' - and was last active ', $updated, ' ago.'; |
3575 | 3761 | |
3576 | - if ($active < 600) |
|
3577 | - echo ' |
|
3762 | + if ($active < 600) { |
|
3763 | + echo ' |
|
3578 | 3764 | We recommend that you do not run this script unless you are sure that ', $upcontext['user']['name'], ' has completed their upgrade.'; |
3765 | + } |
|
3579 | 3766 | |
3580 | - if ($active > $upcontext['inactive_timeout']) |
|
3581 | - echo ' |
|
3767 | + if ($active > $upcontext['inactive_timeout']) { |
|
3768 | + echo ' |
|
3582 | 3769 | <br><br>You can choose to either run the upgrade again from the beginning - or alternatively continue from the last step reached during the last upgrade.'; |
3583 | - else |
|
3584 | - echo ' |
|
3770 | + } else { |
|
3771 | + echo ' |
|
3585 | 3772 | <br><br>This upgrade script cannot be run until ', $upcontext['user']['name'], ' has been inactive for at least ', ($upcontext['inactive_timeout'] > 120 ? round($upcontext['inactive_timeout'] / 60, 1) . ' minutes!' : $upcontext['inactive_timeout'] . ' seconds!'); |
3773 | + } |
|
3586 | 3774 | |
3587 | 3775 | echo ' |
3588 | 3776 | </div> |
@@ -3598,9 +3786,10 @@ discard block |
||
3598 | 3786 | <td> |
3599 | 3787 | <input type="text" name="user" value="', !empty($upcontext['username']) ? $upcontext['username'] : '', '"', $disable_security ? ' disabled' : '', ' class="input_text">'; |
3600 | 3788 | |
3601 | - if (!empty($upcontext['username_incorrect'])) |
|
3602 | - echo ' |
|
3789 | + if (!empty($upcontext['username_incorrect'])) { |
|
3790 | + echo ' |
|
3603 | 3791 | <div class="smalltext" style="color: red;">Username Incorrect</div>'; |
3792 | + } |
|
3604 | 3793 | |
3605 | 3794 | echo ' |
3606 | 3795 | </td> |
@@ -3611,9 +3800,10 @@ discard block |
||
3611 | 3800 | <input type="password" name="passwrd" value=""', $disable_security ? ' disabled' : '', ' class="input_password"> |
3612 | 3801 | <input type="hidden" name="hash_passwrd" value="">'; |
3613 | 3802 | |
3614 | - if (!empty($upcontext['password_failed'])) |
|
3615 | - echo ' |
|
3803 | + if (!empty($upcontext['password_failed'])) { |
|
3804 | + echo ' |
|
3616 | 3805 | <div class="smalltext" style="color: red;">Password Incorrect</div>'; |
3806 | + } |
|
3617 | 3807 | |
3618 | 3808 | echo ' |
3619 | 3809 | </td> |
@@ -3684,8 +3874,8 @@ discard block |
||
3684 | 3874 | <form action="', $upcontext['form_url'], '" method="post" name="upform" id="upform">'; |
3685 | 3875 | |
3686 | 3876 | // Warning message? |
3687 | - if (!empty($upcontext['upgrade_options_warning'])) |
|
3688 | - echo ' |
|
3877 | + if (!empty($upcontext['upgrade_options_warning'])) { |
|
3878 | + echo ' |
|
3689 | 3879 | <div style="margin: 1ex; padding: 1ex; border: 1px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
3690 | 3880 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
3691 | 3881 | <strong style="text-decoration: underline;">Warning!</strong><br> |
@@ -3693,6 +3883,7 @@ discard block |
||
3693 | 3883 | ', $upcontext['upgrade_options_warning'], ' |
3694 | 3884 | </div> |
3695 | 3885 | </div>'; |
3886 | + } |
|
3696 | 3887 | |
3697 | 3888 | echo ' |
3698 | 3889 | <table> |
@@ -3735,8 +3926,8 @@ discard block |
||
3735 | 3926 | </td> |
3736 | 3927 | </tr>'; |
3737 | 3928 | |
3738 | - if (!empty($upcontext['karma_installed']['good']) || !empty($upcontext['karma_installed']['bad'])) |
|
3739 | - echo ' |
|
3929 | + if (!empty($upcontext['karma_installed']['good']) || !empty($upcontext['karma_installed']['bad'])) { |
|
3930 | + echo ' |
|
3740 | 3931 | <tr valign="top"> |
3741 | 3932 | <td width="2%"> |
3742 | 3933 | <input type="checkbox" name="delete_karma" id="delete_karma" value="1" class="input_check"> |
@@ -3745,6 +3936,7 @@ discard block |
||
3745 | 3936 | <label for="delete_karma">Delete all karma settings and info from the DB</label> |
3746 | 3937 | </td> |
3747 | 3938 | </tr>'; |
3939 | + } |
|
3748 | 3940 | |
3749 | 3941 | echo ' |
3750 | 3942 | <tr valign="top"> |
@@ -3782,10 +3974,11 @@ discard block |
||
3782 | 3974 | </div>'; |
3783 | 3975 | |
3784 | 3976 | // Dont any tables so far? |
3785 | - if (!empty($upcontext['previous_tables'])) |
|
3786 | - foreach ($upcontext['previous_tables'] as $table) |
|
3977 | + if (!empty($upcontext['previous_tables'])) { |
|
3978 | + foreach ($upcontext['previous_tables'] as $table) |
|
3787 | 3979 | echo ' |
3788 | 3980 | <br>Completed Table: "', $table, '".'; |
3981 | + } |
|
3789 | 3982 | |
3790 | 3983 | echo ' |
3791 | 3984 | <h3 id="current_tab_div">Current Table: "<span id="current_table">', $upcontext['cur_table_name'], '</span>"</h3> |
@@ -3822,12 +4015,13 @@ discard block |
||
3822 | 4015 | updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');'; |
3823 | 4016 | |
3824 | 4017 | // If debug flood the screen. |
3825 | - if ($is_debug) |
|
3826 | - echo ' |
|
4018 | + if ($is_debug) { |
|
4019 | + echo ' |
|
3827 | 4020 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: "\' + sCompletedTableName + \'".<span id="debuginfo"><\' + \'/span>\'); |
3828 | 4021 | |
3829 | 4022 | if (document.getElementById(\'debug_section\').scrollHeight) |
3830 | 4023 | document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight'; |
4024 | + } |
|
3831 | 4025 | |
3832 | 4026 | echo ' |
3833 | 4027 | // Get the next update... |
@@ -3860,8 +4054,9 @@ discard block |
||
3860 | 4054 | { |
3861 | 4055 | global $upcontext, $support_js, $is_debug, $timeLimitThreshold; |
3862 | 4056 | |
3863 | - if (empty($is_debug) && !empty($upcontext['upgrade_status']['debug'])) |
|
3864 | - $is_debug = true; |
|
4057 | + if (empty($is_debug) && !empty($upcontext['upgrade_status']['debug'])) { |
|
4058 | + $is_debug = true; |
|
4059 | + } |
|
3865 | 4060 | |
3866 | 4061 | echo ' |
3867 | 4062 | <h3>Executing database changes</h3> |
@@ -3876,8 +4071,9 @@ discard block |
||
3876 | 4071 | { |
3877 | 4072 | foreach ($upcontext['actioned_items'] as $num => $item) |
3878 | 4073 | { |
3879 | - if ($num != 0) |
|
3880 | - echo ' Successful!'; |
|
4074 | + if ($num != 0) { |
|
4075 | + echo ' Successful!'; |
|
4076 | + } |
|
3881 | 4077 | echo '<br>' . $item; |
3882 | 4078 | } |
3883 | 4079 | if (!empty($upcontext['changes_complete'])) |
@@ -3890,28 +4086,32 @@ discard block |
||
3890 | 4086 | $seconds = intval($active % 60); |
3891 | 4087 | |
3892 | 4088 | $totalTime = ''; |
3893 | - if ($hours > 0) |
|
3894 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
3895 | - if ($minutes > 0) |
|
3896 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
3897 | - if ($seconds > 0) |
|
3898 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
4089 | + if ($hours > 0) { |
|
4090 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
4091 | + } |
|
4092 | + if ($minutes > 0) { |
|
4093 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
4094 | + } |
|
4095 | + if ($seconds > 0) { |
|
4096 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
4097 | + } |
|
3899 | 4098 | } |
3900 | 4099 | |
3901 | - if ($is_debug && !empty($totalTime)) |
|
3902 | - echo ' Successful! Completed in ', $totalTime, '<br><br>'; |
|
3903 | - else |
|
3904 | - echo ' Successful!<br><br>'; |
|
4100 | + if ($is_debug && !empty($totalTime)) { |
|
4101 | + echo ' Successful! Completed in ', $totalTime, '<br><br>'; |
|
4102 | + } else { |
|
4103 | + echo ' Successful!<br><br>'; |
|
4104 | + } |
|
3905 | 4105 | |
3906 | 4106 | echo '<span id="commess" style="font-weight: bold;">1 Database Updates Complete! Click Continue to Proceed.</span><br>'; |
3907 | 4107 | } |
3908 | - } |
|
3909 | - else |
|
4108 | + } else |
|
3910 | 4109 | { |
3911 | 4110 | // Tell them how many files we have in total. |
3912 | - if ($upcontext['file_count'] > 1) |
|
3913 | - echo ' |
|
4111 | + if ($upcontext['file_count'] > 1) { |
|
4112 | + echo ' |
|
3914 | 4113 | <strong id="info1">Executing upgrade script <span id="file_done">', $upcontext['cur_file_num'], '</span> of ', $upcontext['file_count'], '.</strong>'; |
4114 | + } |
|
3915 | 4115 | |
3916 | 4116 | echo ' |
3917 | 4117 | <h3 id="info2"><strong>Executing:</strong> "<span id="cur_item_name">', $upcontext['current_item_name'], '</span>" (<span id="item_num">', $upcontext['current_item_num'], '</span> of <span id="total_items"><span id="item_count">', $upcontext['total_items'], '</span>', $upcontext['file_count'] > 1 ? ' - of this script' : '', ')</span></h3> |
@@ -3927,19 +4127,23 @@ discard block |
||
3927 | 4127 | $seconds = intval($active % 60); |
3928 | 4128 | |
3929 | 4129 | $totalTime = ''; |
3930 | - if ($hours > 0) |
|
3931 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
3932 | - if ($minutes > 0) |
|
3933 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
3934 | - if ($seconds > 0) |
|
3935 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
4130 | + if ($hours > 0) { |
|
4131 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
4132 | + } |
|
4133 | + if ($minutes > 0) { |
|
4134 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
4135 | + } |
|
4136 | + if ($seconds > 0) { |
|
4137 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
4138 | + } |
|
3936 | 4139 | } |
3937 | 4140 | |
3938 | 4141 | echo ' |
3939 | 4142 | <br><span id="upgradeCompleted">'; |
3940 | 4143 | |
3941 | - if (!empty($totalTime)) |
|
3942 | - echo 'Completed in ', $totalTime, '<br>'; |
|
4144 | + if (!empty($totalTime)) { |
|
4145 | + echo 'Completed in ', $totalTime, '<br>'; |
|
4146 | + } |
|
3943 | 4147 | |
3944 | 4148 | echo '</span> |
3945 | 4149 | <div id="debug_section" style="height: 59px; overflow: auto;"> |
@@ -3976,9 +4180,10 @@ discard block |
||
3976 | 4180 | var getData = ""; |
3977 | 4181 | var debugItems = ', $upcontext['debug_items'], ';'; |
3978 | 4182 | |
3979 | - if ($is_debug) |
|
3980 | - echo ' |
|
4183 | + if ($is_debug) { |
|
4184 | + echo ' |
|
3981 | 4185 | var upgradeStartTime = ' . $upcontext['started'] . ';'; |
4186 | + } |
|
3982 | 4187 | |
3983 | 4188 | echo ' |
3984 | 4189 | function getNextItem() |
@@ -4018,9 +4223,10 @@ discard block |
||
4018 | 4223 | document.getElementById("error_block").style.display = ""; |
4019 | 4224 | setInnerHTML(document.getElementById("error_message"), "Error retrieving information on step: " + (sDebugName == "" ? sLastString : sDebugName));'; |
4020 | 4225 | |
4021 | - if ($is_debug) |
|
4022 | - echo ' |
|
4226 | + if ($is_debug) { |
|
4227 | + echo ' |
|
4023 | 4228 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<span style="color: red;">failed<\' + \'/span><span id="debuginfo"><\' + \'/span>\');'; |
4229 | + } |
|
4024 | 4230 | |
4025 | 4231 | echo ' |
4026 | 4232 | } |
@@ -4041,9 +4247,10 @@ discard block |
||
4041 | 4247 | document.getElementById("error_block").style.display = ""; |
4042 | 4248 | setInnerHTML(document.getElementById("error_message"), "Upgrade script appears to be going into a loop - step: " + sDebugName);'; |
4043 | 4249 | |
4044 | - if ($is_debug) |
|
4045 | - echo ' |
|
4250 | + if ($is_debug) { |
|
4251 | + echo ' |
|
4046 | 4252 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<span style="color: red;">failed<\' + \'/span><span id="debuginfo"><\' + \'/span>\');'; |
4253 | + } |
|
4047 | 4254 | |
4048 | 4255 | echo ' |
4049 | 4256 | } |
@@ -4102,8 +4309,8 @@ discard block |
||
4102 | 4309 | if (bIsComplete && iDebugNum == -1 && curFile >= ', $upcontext['file_count'], ') |
4103 | 4310 | {'; |
4104 | 4311 | |
4105 | - if ($is_debug) |
|
4106 | - echo ' |
|
4312 | + if ($is_debug) { |
|
4313 | + echo ' |
|
4107 | 4314 | document.getElementById(\'debug_section\').style.display = "none"; |
4108 | 4315 | |
4109 | 4316 | var upgradeFinishedTime = parseInt(oXMLDoc.getElementsByTagName("curtime")[0].childNodes[0].nodeValue); |
@@ -4121,6 +4328,7 @@ discard block |
||
4121 | 4328 | totalTime = totalTime + diffSeconds + " second" + (diffSeconds > 1 ? "s" : ""); |
4122 | 4329 | |
4123 | 4330 | setInnerHTML(document.getElementById("upgradeCompleted"), "Completed in " + totalTime);'; |
4331 | + } |
|
4124 | 4332 | |
4125 | 4333 | echo ' |
4126 | 4334 | |
@@ -4128,9 +4336,10 @@ discard block |
||
4128 | 4336 | document.getElementById(\'contbutt\').disabled = 0; |
4129 | 4337 | document.getElementById(\'database_done\').value = 1;'; |
4130 | 4338 | |
4131 | - if ($upcontext['file_count'] > 1) |
|
4132 | - echo ' |
|
4339 | + if ($upcontext['file_count'] > 1) { |
|
4340 | + echo ' |
|
4133 | 4341 | document.getElementById(\'info1\').style.display = "none";'; |
4342 | + } |
|
4134 | 4343 | |
4135 | 4344 | echo ' |
4136 | 4345 | document.getElementById(\'info2\').style.display = "none"; |
@@ -4143,9 +4352,10 @@ discard block |
||
4143 | 4352 | lastItem = 0; |
4144 | 4353 | prevFile = curFile;'; |
4145 | 4354 | |
4146 | - if ($is_debug) |
|
4147 | - echo ' |
|
4355 | + if ($is_debug) { |
|
4356 | + echo ' |
|
4148 | 4357 | setOuterHTML(document.getElementById(\'debuginfo\'), \'Moving to next script file...done<br><span id="debuginfo"><\' + \'/span>\');'; |
4358 | + } |
|
4149 | 4359 | |
4150 | 4360 | echo ' |
4151 | 4361 | getNextItem(); |
@@ -4153,8 +4363,8 @@ discard block |
||
4153 | 4363 | }'; |
4154 | 4364 | |
4155 | 4365 | // If debug scroll the screen. |
4156 | - if ($is_debug) |
|
4157 | - echo ' |
|
4366 | + if ($is_debug) { |
|
4367 | + echo ' |
|
4158 | 4368 | if (iLastSubStepProgress == -1) |
4159 | 4369 | { |
4160 | 4370 | // Give it consistent dots. |
@@ -4173,6 +4383,7 @@ discard block |
||
4173 | 4383 | |
4174 | 4384 | if (document.getElementById(\'debug_section\').scrollHeight) |
4175 | 4385 | document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight'; |
4386 | + } |
|
4176 | 4387 | |
4177 | 4388 | echo ' |
4178 | 4389 | // Update the page. |
@@ -4233,9 +4444,10 @@ discard block |
||
4233 | 4444 | }'; |
4234 | 4445 | |
4235 | 4446 | // Start things off assuming we've not errored. |
4236 | - if (empty($upcontext['error_message'])) |
|
4237 | - echo ' |
|
4447 | + if (empty($upcontext['error_message'])) { |
|
4448 | + echo ' |
|
4238 | 4449 | getNextItem();'; |
4450 | + } |
|
4239 | 4451 | |
4240 | 4452 | echo ' |
4241 | 4453 | //# sourceURL=dynamicScript-dbch.js |
@@ -4253,18 +4465,21 @@ discard block |
||
4253 | 4465 | <item num="', $upcontext['current_item_num'], '">', $upcontext['current_item_name'], '</item> |
4254 | 4466 | <debug num="', $upcontext['current_debug_item_num'], '" percent="', isset($upcontext['substep_progress']) ? $upcontext['substep_progress'] : '-1', '" complete="', empty($upcontext['completed_step']) ? 0 : 1, '">', $upcontext['current_debug_item_name'], '</debug>'; |
4255 | 4467 | |
4256 | - if (!empty($upcontext['error_message'])) |
|
4257 | - echo ' |
|
4468 | + if (!empty($upcontext['error_message'])) { |
|
4469 | + echo ' |
|
4258 | 4470 | <error>', $upcontext['error_message'], '</error>'; |
4471 | + } |
|
4259 | 4472 | |
4260 | - if (!empty($upcontext['error_string'])) |
|
4261 | - echo ' |
|
4473 | + if (!empty($upcontext['error_string'])) { |
|
4474 | + echo ' |
|
4262 | 4475 | <sql>', $upcontext['error_string'], '</sql>'; |
4476 | + } |
|
4263 | 4477 | |
4264 | - if ($is_debug) |
|
4265 | - echo ' |
|
4478 | + if ($is_debug) { |
|
4479 | + echo ' |
|
4266 | 4480 | <curtime>', time(), '</curtime>'; |
4267 | -} |
|
4481 | + } |
|
4482 | + } |
|
4268 | 4483 | |
4269 | 4484 | // Template for the UTF-8 conversion step. Basically a copy of the backup stuff with slight modifications.... |
4270 | 4485 | function template_convert_utf8() |
@@ -4283,18 +4498,20 @@ discard block |
||
4283 | 4498 | </div>'; |
4284 | 4499 | |
4285 | 4500 | // Done any tables so far? |
4286 | - if (!empty($upcontext['previous_tables'])) |
|
4287 | - foreach ($upcontext['previous_tables'] as $table) |
|
4501 | + if (!empty($upcontext['previous_tables'])) { |
|
4502 | + foreach ($upcontext['previous_tables'] as $table) |
|
4288 | 4503 | echo ' |
4289 | 4504 | <br>Completed Table: "', $table, '".'; |
4505 | + } |
|
4290 | 4506 | |
4291 | 4507 | echo ' |
4292 | 4508 | <h3 id="current_tab_div">Current Table: "<span id="current_table">', $upcontext['cur_table_name'], '</span>"</h3>'; |
4293 | 4509 | |
4294 | 4510 | // If we dropped their index, let's let them know |
4295 | - if ($upcontext['cur_table_num'] == $upcontext['table_count'] && $upcontext['dropping_index']) |
|
4296 | - echo ' |
|
4511 | + if ($upcontext['cur_table_num'] == $upcontext['table_count'] && $upcontext['dropping_index']) { |
|
4512 | + echo ' |
|
4297 | 4513 | <br><span style="display:inline;">Please note that your fulltext index was dropped to facilitate the conversion and will need to be recreated.</span>'; |
4514 | + } |
|
4298 | 4515 | |
4299 | 4516 | echo ' |
4300 | 4517 | <br><span id="commess" style="font-weight: bold; display: ', $upcontext['cur_table_num'] == $upcontext['table_count'] ? 'inline' : 'none', ';">Conversion Complete! Click Continue to Proceed.</span>'; |
@@ -4330,12 +4547,13 @@ discard block |
||
4330 | 4547 | updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');'; |
4331 | 4548 | |
4332 | 4549 | // If debug flood the screen. |
4333 | - if ($is_debug) |
|
4334 | - echo ' |
|
4550 | + if ($is_debug) { |
|
4551 | + echo ' |
|
4335 | 4552 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: "\' + sCompletedTableName + \'".<span id="debuginfo"><\' + \'/span>\'); |
4336 | 4553 | |
4337 | 4554 | if (document.getElementById(\'debug_section\').scrollHeight) |
4338 | 4555 | document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight'; |
4556 | + } |
|
4339 | 4557 | |
4340 | 4558 | echo ' |
4341 | 4559 | // Get the next update... |
@@ -4380,19 +4598,21 @@ discard block |
||
4380 | 4598 | </div>'; |
4381 | 4599 | |
4382 | 4600 | // Dont any tables so far? |
4383 | - if (!empty($upcontext['previous_tables'])) |
|
4384 | - foreach ($upcontext['previous_tables'] as $table) |
|
4601 | + if (!empty($upcontext['previous_tables'])) { |
|
4602 | + foreach ($upcontext['previous_tables'] as $table) |
|
4385 | 4603 | echo ' |
4386 | 4604 | <br>Completed Table: "', $table, '".'; |
4605 | + } |
|
4387 | 4606 | |
4388 | 4607 | echo ' |
4389 | 4608 | <h3 id="current_tab_div">Current Table: "<span id="current_table">', $upcontext['cur_table_name'], '</span>"</h3> |
4390 | 4609 | <br><span id="commess" style="font-weight: bold; display: ', $upcontext['cur_table_num'] == $upcontext['table_count'] ? 'inline' : 'none', ';">Convert to JSON Complete! Click Continue to Proceed.</span>'; |
4391 | 4610 | |
4392 | 4611 | // Try to make sure substep was reset. |
4393 | - if ($upcontext['cur_table_num'] == $upcontext['table_count']) |
|
4394 | - echo ' |
|
4612 | + if ($upcontext['cur_table_num'] == $upcontext['table_count']) { |
|
4613 | + echo ' |
|
4395 | 4614 | <input type="hidden" name="substep" id="substep" value="0">'; |
4615 | + } |
|
4396 | 4616 | |
4397 | 4617 | // Continue please! |
4398 | 4618 | $upcontext['continue'] = $support_js ? 2 : 1; |
@@ -4425,12 +4645,13 @@ discard block |
||
4425 | 4645 | updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');'; |
4426 | 4646 | |
4427 | 4647 | // If debug flood the screen. |
4428 | - if ($is_debug) |
|
4429 | - echo ' |
|
4648 | + if ($is_debug) { |
|
4649 | + echo ' |
|
4430 | 4650 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: "\' + sCompletedTableName + \'".<span id="debuginfo"><\' + \'/span>\'); |
4431 | 4651 | |
4432 | 4652 | if (document.getElementById(\'debug_section\').scrollHeight) |
4433 | 4653 | document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight'; |
4654 | + } |
|
4434 | 4655 | |
4435 | 4656 | echo ' |
4436 | 4657 | // Get the next update... |
@@ -4466,8 +4687,8 @@ discard block |
||
4466 | 4687 | <h3>That wasn\'t so hard, was it? Now you are ready to use <a href="', $boardurl, '/index.php">your installation of SMF</a>. Hope you like it!</h3> |
4467 | 4688 | <form action="', $boardurl, '/index.php">'; |
4468 | 4689 | |
4469 | - if (!empty($upcontext['can_delete_script'])) |
|
4470 | - echo ' |
|
4690 | + if (!empty($upcontext['can_delete_script'])) { |
|
4691 | + echo ' |
|
4471 | 4692 | <label for="delete_self"><input type="checkbox" id="delete_self" onclick="doTheDelete(this);" class="input_check"> Delete upgrade.php and its data files now</label> <em>(doesn\'t work on all servers).</em> |
4472 | 4693 | <script> |
4473 | 4694 | function doTheDelete(theCheck) |
@@ -4479,6 +4700,7 @@ discard block |
||
4479 | 4700 | } |
4480 | 4701 | </script> |
4481 | 4702 | <img src="', $settings['default_theme_url'], '/images/blank.png" alt="" id="delete_upgrader"><br>'; |
4703 | + } |
|
4482 | 4704 | |
4483 | 4705 | $active = time() - $upcontext['started']; |
4484 | 4706 | $hours = floor($active / 3600); |
@@ -4488,16 +4710,20 @@ discard block |
||
4488 | 4710 | if ($is_debug) |
4489 | 4711 | { |
4490 | 4712 | $totalTime = ''; |
4491 | - if ($hours > 0) |
|
4492 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
4493 | - if ($minutes > 0) |
|
4494 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
4495 | - if ($seconds > 0) |
|
4496 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
4713 | + if ($hours > 0) { |
|
4714 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
4715 | + } |
|
4716 | + if ($minutes > 0) { |
|
4717 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
4718 | + } |
|
4719 | + if ($seconds > 0) { |
|
4720 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
4721 | + } |
|
4497 | 4722 | } |
4498 | 4723 | |
4499 | - if ($is_debug && !empty($totalTime)) |
|
4500 | - echo '<br> Upgrade completed in ', $totalTime, '<br><br>'; |
|
4724 | + if ($is_debug && !empty($totalTime)) { |
|
4725 | + echo '<br> Upgrade completed in ', $totalTime, '<br><br>'; |
|
4726 | + } |
|
4501 | 4727 | |
4502 | 4728 | echo '<br> |
4503 | 4729 | If you had any problems with this upgrade, or have any problems using SMF, please don\'t hesitate to <a href="https://www.simplemachines.org/community/index.php">look to us for assistance</a>.<br> |
@@ -4524,8 +4750,9 @@ discard block |
||
4524 | 4750 | |
4525 | 4751 | $current_substep = $_GET['substep']; |
4526 | 4752 | |
4527 | - if (empty($_GET['a'])) |
|
4528 | - $_GET['a'] = 0; |
|
4753 | + if (empty($_GET['a'])) { |
|
4754 | + $_GET['a'] = 0; |
|
4755 | + } |
|
4529 | 4756 | $step_progress['name'] = 'Converting ips'; |
4530 | 4757 | $step_progress['current'] = $_GET['a']; |
4531 | 4758 | |
@@ -4568,16 +4795,19 @@ discard block |
||
4568 | 4795 | 'empty' => '', |
4569 | 4796 | 'limit' => $limit, |
4570 | 4797 | )); |
4571 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
4572 | - $arIp[] = $row[$oldCol]; |
|
4798 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
4799 | + $arIp[] = $row[$oldCol]; |
|
4800 | + } |
|
4573 | 4801 | $smcFunc['db_free_result']($request); |
4574 | 4802 | |
4575 | 4803 | // Special case, null ip could keep us in a loop. |
4576 | - if (is_null($arIp[0])) |
|
4577 | - unset($arIp[0]); |
|
4804 | + if (is_null($arIp[0])) { |
|
4805 | + unset($arIp[0]); |
|
4806 | + } |
|
4578 | 4807 | |
4579 | - if (empty($arIp)) |
|
4580 | - $is_done = true; |
|
4808 | + if (empty($arIp)) { |
|
4809 | + $is_done = true; |
|
4810 | + } |
|
4581 | 4811 | |
4582 | 4812 | $updates = array(); |
4583 | 4813 | $cases = array(); |
@@ -4586,16 +4816,18 @@ discard block |
||
4586 | 4816 | { |
4587 | 4817 | $arIp[$i] = trim($arIp[$i]); |
4588 | 4818 | |
4589 | - if (empty($arIp[$i])) |
|
4590 | - continue; |
|
4819 | + if (empty($arIp[$i])) { |
|
4820 | + continue; |
|
4821 | + } |
|
4591 | 4822 | |
4592 | 4823 | $updates['ip' . $i] = $arIp[$i]; |
4593 | 4824 | $cases[$arIp[$i]] = 'WHEN ' . $oldCol . ' = {string:ip' . $i . '} THEN {inet:ip' . $i . '}'; |
4594 | 4825 | |
4595 | 4826 | if ($setSize > 0 && $i % $setSize === 0) |
4596 | 4827 | { |
4597 | - if (count($updates) == 1) |
|
4598 | - continue; |
|
4828 | + if (count($updates) == 1) { |
|
4829 | + continue; |
|
4830 | + } |
|
4599 | 4831 | |
4600 | 4832 | $updates['whereSet'] = array_values($updates); |
4601 | 4833 | $smcFunc['db_query']('', ' |
@@ -4629,8 +4861,7 @@ discard block |
||
4629 | 4861 | 'ip' => $ip |
4630 | 4862 | )); |
4631 | 4863 | } |
4632 | - } |
|
4633 | - else |
|
4864 | + } else |
|
4634 | 4865 | { |
4635 | 4866 | $updates['whereSet'] = array_values($updates); |
4636 | 4867 | $smcFunc['db_query']('', ' |
@@ -4644,9 +4875,9 @@ discard block |
||
4644 | 4875 | $updates |
4645 | 4876 | ); |
4646 | 4877 | } |
4878 | + } else { |
|
4879 | + $is_done = true; |
|
4647 | 4880 | } |
4648 | - else |
|
4649 | - $is_done = true; |
|
4650 | 4881 | |
4651 | 4882 | $_GET['a'] += $limit; |
4652 | 4883 | $step_progress['current'] = $_GET['a']; |
@@ -4672,10 +4903,11 @@ discard block |
||
4672 | 4903 | |
4673 | 4904 | $columns = $smcFunc['db_list_columns']($targetTable, true); |
4674 | 4905 | |
4675 | - if (isset($columns[$column])) |
|
4676 | - return $columns[$column]; |
|
4677 | - else |
|
4678 | - return null; |
|
4679 | -} |
|
4906 | + if (isset($columns[$column])) { |
|
4907 | + return $columns[$column]; |
|
4908 | + } else { |
|
4909 | + return null; |
|
4910 | + } |
|
4911 | + } |
|
4680 | 4912 | |
4681 | 4913 | ?> |
4682 | 4914 | \ No newline at end of file |