@@ -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 | } |
@@ -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,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 | } |
@@ -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 | } |
@@ -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 | } |
@@ -393,6 +393,9 @@ discard block |
||
393 | 393 | } |
394 | 394 | |
395 | 395 | // Used to direct the user to another location. |
396 | +/** |
|
397 | + * @param string $location |
|
398 | + */ |
|
396 | 399 | function redirectLocation($location, $addForm = true) |
397 | 400 | { |
398 | 401 | global $upgradeurl, $upcontext, $command_line; |
@@ -1573,6 +1576,9 @@ discard block |
||
1573 | 1576 | return addslashes(preg_replace(array('~^\.([/\\\]|$)~', '~[/]+~', '~[\\\]+~', '~[/\\\]$~'), array($install_path . '$1', '/', '\\', ''), $path)); |
1574 | 1577 | } |
1575 | 1578 | |
1579 | +/** |
|
1580 | + * @param string $filename |
|
1581 | + */ |
|
1576 | 1582 | function parse_sql($filename) |
1577 | 1583 | { |
1578 | 1584 | global $db_prefix, $db_collation, $boarddir, $boardurl, $command_line, $file_steps, $step_progress, $custom_warning; |
@@ -1607,6 +1613,10 @@ discard block |
||
1607 | 1613 | |
1608 | 1614 | // Our custom error handler - does nothing but does stop public errors from XML! |
1609 | 1615 | set_error_handler( |
1616 | + |
|
1617 | + /** |
|
1618 | + * @param string $errno |
|
1619 | + */ |
|
1610 | 1620 | function ($errno, $errstr, $errfile, $errline) use ($support_js) |
1611 | 1621 | { |
1612 | 1622 | if ($support_js) |
@@ -1853,6 +1863,9 @@ discard block |
||
1853 | 1863 | return true; |
1854 | 1864 | } |
1855 | 1865 | |
1866 | +/** |
|
1867 | + * @param string $string |
|
1868 | + */ |
|
1856 | 1869 | function upgrade_query($string, $unbuffered = false) |
1857 | 1870 | { |
1858 | 1871 | global $db_connection, $db_server, $db_user, $db_passwd, $db_type, $command_line, $upcontext, $upgradeurl, $modSettings; |
@@ -4512,7 +4525,7 @@ discard block |
||
4512 | 4525 | * @param int $setSize The amount of entries after which to update the database. |
4513 | 4526 | * |
4514 | 4527 | * newCol needs to be a varbinary(16) null able field |
4515 | - * @return bool |
|
4528 | + * @return boolean|null |
|
4516 | 4529 | */ |
4517 | 4530 | function MySQLConvertOldIp($targetTable, $oldCol, $newCol, $limit = 50000, $setSize = 100) |
4518 | 4531 | { |
@@ -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 |
@@ -1625,7 +1625,7 @@ discard block |
||
1625 | 1625 | |
1626 | 1626 | // Our custom error handler - does nothing but does stop public errors from XML! |
1627 | 1627 | set_error_handler( |
1628 | - function ($errno, $errstr, $errfile, $errline) use ($support_js) |
|
1628 | + function($errno, $errstr, $errfile, $errline) use ($support_js) |
|
1629 | 1629 | { |
1630 | 1630 | if ($support_js) |
1631 | 1631 | return true; |
@@ -2610,94 +2610,94 @@ discard block |
||
2610 | 2610 | // Translation table for the character sets not native for MySQL. |
2611 | 2611 | $translation_tables = array( |
2612 | 2612 | 'windows-1255' => array( |
2613 | - '0x81' => '\'\'', '0x8A' => '\'\'', '0x8C' => '\'\'', |
|
2614 | - '0x8D' => '\'\'', '0x8E' => '\'\'', '0x8F' => '\'\'', |
|
2615 | - '0x90' => '\'\'', '0x9A' => '\'\'', '0x9C' => '\'\'', |
|
2616 | - '0x9D' => '\'\'', '0x9E' => '\'\'', '0x9F' => '\'\'', |
|
2617 | - '0xCA' => '\'\'', '0xD9' => '\'\'', '0xDA' => '\'\'', |
|
2618 | - '0xDB' => '\'\'', '0xDC' => '\'\'', '0xDD' => '\'\'', |
|
2619 | - '0xDE' => '\'\'', '0xDF' => '\'\'', '0xFB' => '0xD792', |
|
2620 | - '0xFC' => '0xE282AC', '0xFF' => '0xD6B2', '0xC2' => '0xFF', |
|
2621 | - '0x80' => '0xFC', '0xE2' => '0xFB', '0xA0' => '0xC2A0', |
|
2622 | - '0xA1' => '0xC2A1', '0xA2' => '0xC2A2', '0xA3' => '0xC2A3', |
|
2623 | - '0xA5' => '0xC2A5', '0xA6' => '0xC2A6', '0xA7' => '0xC2A7', |
|
2624 | - '0xA8' => '0xC2A8', '0xA9' => '0xC2A9', '0xAB' => '0xC2AB', |
|
2625 | - '0xAC' => '0xC2AC', '0xAD' => '0xC2AD', '0xAE' => '0xC2AE', |
|
2626 | - '0xAF' => '0xC2AF', '0xB0' => '0xC2B0', '0xB1' => '0xC2B1', |
|
2627 | - '0xB2' => '0xC2B2', '0xB3' => '0xC2B3', '0xB4' => '0xC2B4', |
|
2628 | - '0xB5' => '0xC2B5', '0xB6' => '0xC2B6', '0xB7' => '0xC2B7', |
|
2629 | - '0xB8' => '0xC2B8', '0xB9' => '0xC2B9', '0xBB' => '0xC2BB', |
|
2630 | - '0xBC' => '0xC2BC', '0xBD' => '0xC2BD', '0xBE' => '0xC2BE', |
|
2631 | - '0xBF' => '0xC2BF', '0xD7' => '0xD7B3', '0xD1' => '0xD781', |
|
2632 | - '0xD4' => '0xD7B0', '0xD5' => '0xD7B1', '0xD6' => '0xD7B2', |
|
2633 | - '0xE0' => '0xD790', '0xEA' => '0xD79A', '0xEC' => '0xD79C', |
|
2634 | - '0xED' => '0xD79D', '0xEE' => '0xD79E', '0xEF' => '0xD79F', |
|
2635 | - '0xF0' => '0xD7A0', '0xF1' => '0xD7A1', '0xF2' => '0xD7A2', |
|
2636 | - '0xF3' => '0xD7A3', '0xF5' => '0xD7A5', '0xF6' => '0xD7A6', |
|
2637 | - '0xF7' => '0xD7A7', '0xF8' => '0xD7A8', '0xF9' => '0xD7A9', |
|
2638 | - '0x82' => '0xE2809A', '0x84' => '0xE2809E', '0x85' => '0xE280A6', |
|
2639 | - '0x86' => '0xE280A0', '0x87' => '0xE280A1', '0x89' => '0xE280B0', |
|
2640 | - '0x8B' => '0xE280B9', '0x93' => '0xE2809C', '0x94' => '0xE2809D', |
|
2641 | - '0x95' => '0xE280A2', '0x97' => '0xE28094', '0x99' => '0xE284A2', |
|
2642 | - '0xC0' => '0xD6B0', '0xC1' => '0xD6B1', '0xC3' => '0xD6B3', |
|
2643 | - '0xC4' => '0xD6B4', '0xC5' => '0xD6B5', '0xC6' => '0xD6B6', |
|
2644 | - '0xC7' => '0xD6B7', '0xC8' => '0xD6B8', '0xC9' => '0xD6B9', |
|
2645 | - '0xCB' => '0xD6BB', '0xCC' => '0xD6BC', '0xCD' => '0xD6BD', |
|
2646 | - '0xCE' => '0xD6BE', '0xCF' => '0xD6BF', '0xD0' => '0xD780', |
|
2647 | - '0xD2' => '0xD782', '0xE3' => '0xD793', '0xE4' => '0xD794', |
|
2648 | - '0xE5' => '0xD795', '0xE7' => '0xD797', '0xE9' => '0xD799', |
|
2649 | - '0xFD' => '0xE2808E', '0xFE' => '0xE2808F', '0x92' => '0xE28099', |
|
2650 | - '0x83' => '0xC692', '0xD3' => '0xD783', '0x88' => '0xCB86', |
|
2651 | - '0x98' => '0xCB9C', '0x91' => '0xE28098', '0x96' => '0xE28093', |
|
2652 | - '0xBA' => '0xC3B7', '0x9B' => '0xE280BA', '0xAA' => '0xC397', |
|
2653 | - '0xA4' => '0xE282AA', '0xE1' => '0xD791', '0xE6' => '0xD796', |
|
2654 | - '0xE8' => '0xD798', '0xEB' => '0xD79B', '0xF4' => '0xD7A4', |
|
2613 | + '0x81' => '\'\'', '0x8A' => '\'\'', '0x8C' => '\'\'', |
|
2614 | + '0x8D' => '\'\'', '0x8E' => '\'\'', '0x8F' => '\'\'', |
|
2615 | + '0x90' => '\'\'', '0x9A' => '\'\'', '0x9C' => '\'\'', |
|
2616 | + '0x9D' => '\'\'', '0x9E' => '\'\'', '0x9F' => '\'\'', |
|
2617 | + '0xCA' => '\'\'', '0xD9' => '\'\'', '0xDA' => '\'\'', |
|
2618 | + '0xDB' => '\'\'', '0xDC' => '\'\'', '0xDD' => '\'\'', |
|
2619 | + '0xDE' => '\'\'', '0xDF' => '\'\'', '0xFB' => '0xD792', |
|
2620 | + '0xFC' => '0xE282AC', '0xFF' => '0xD6B2', '0xC2' => '0xFF', |
|
2621 | + '0x80' => '0xFC', '0xE2' => '0xFB', '0xA0' => '0xC2A0', |
|
2622 | + '0xA1' => '0xC2A1', '0xA2' => '0xC2A2', '0xA3' => '0xC2A3', |
|
2623 | + '0xA5' => '0xC2A5', '0xA6' => '0xC2A6', '0xA7' => '0xC2A7', |
|
2624 | + '0xA8' => '0xC2A8', '0xA9' => '0xC2A9', '0xAB' => '0xC2AB', |
|
2625 | + '0xAC' => '0xC2AC', '0xAD' => '0xC2AD', '0xAE' => '0xC2AE', |
|
2626 | + '0xAF' => '0xC2AF', '0xB0' => '0xC2B0', '0xB1' => '0xC2B1', |
|
2627 | + '0xB2' => '0xC2B2', '0xB3' => '0xC2B3', '0xB4' => '0xC2B4', |
|
2628 | + '0xB5' => '0xC2B5', '0xB6' => '0xC2B6', '0xB7' => '0xC2B7', |
|
2629 | + '0xB8' => '0xC2B8', '0xB9' => '0xC2B9', '0xBB' => '0xC2BB', |
|
2630 | + '0xBC' => '0xC2BC', '0xBD' => '0xC2BD', '0xBE' => '0xC2BE', |
|
2631 | + '0xBF' => '0xC2BF', '0xD7' => '0xD7B3', '0xD1' => '0xD781', |
|
2632 | + '0xD4' => '0xD7B0', '0xD5' => '0xD7B1', '0xD6' => '0xD7B2', |
|
2633 | + '0xE0' => '0xD790', '0xEA' => '0xD79A', '0xEC' => '0xD79C', |
|
2634 | + '0xED' => '0xD79D', '0xEE' => '0xD79E', '0xEF' => '0xD79F', |
|
2635 | + '0xF0' => '0xD7A0', '0xF1' => '0xD7A1', '0xF2' => '0xD7A2', |
|
2636 | + '0xF3' => '0xD7A3', '0xF5' => '0xD7A5', '0xF6' => '0xD7A6', |
|
2637 | + '0xF7' => '0xD7A7', '0xF8' => '0xD7A8', '0xF9' => '0xD7A9', |
|
2638 | + '0x82' => '0xE2809A', '0x84' => '0xE2809E', '0x85' => '0xE280A6', |
|
2639 | + '0x86' => '0xE280A0', '0x87' => '0xE280A1', '0x89' => '0xE280B0', |
|
2640 | + '0x8B' => '0xE280B9', '0x93' => '0xE2809C', '0x94' => '0xE2809D', |
|
2641 | + '0x95' => '0xE280A2', '0x97' => '0xE28094', '0x99' => '0xE284A2', |
|
2642 | + '0xC0' => '0xD6B0', '0xC1' => '0xD6B1', '0xC3' => '0xD6B3', |
|
2643 | + '0xC4' => '0xD6B4', '0xC5' => '0xD6B5', '0xC6' => '0xD6B6', |
|
2644 | + '0xC7' => '0xD6B7', '0xC8' => '0xD6B8', '0xC9' => '0xD6B9', |
|
2645 | + '0xCB' => '0xD6BB', '0xCC' => '0xD6BC', '0xCD' => '0xD6BD', |
|
2646 | + '0xCE' => '0xD6BE', '0xCF' => '0xD6BF', '0xD0' => '0xD780', |
|
2647 | + '0xD2' => '0xD782', '0xE3' => '0xD793', '0xE4' => '0xD794', |
|
2648 | + '0xE5' => '0xD795', '0xE7' => '0xD797', '0xE9' => '0xD799', |
|
2649 | + '0xFD' => '0xE2808E', '0xFE' => '0xE2808F', '0x92' => '0xE28099', |
|
2650 | + '0x83' => '0xC692', '0xD3' => '0xD783', '0x88' => '0xCB86', |
|
2651 | + '0x98' => '0xCB9C', '0x91' => '0xE28098', '0x96' => '0xE28093', |
|
2652 | + '0xBA' => '0xC3B7', '0x9B' => '0xE280BA', '0xAA' => '0xC397', |
|
2653 | + '0xA4' => '0xE282AA', '0xE1' => '0xD791', '0xE6' => '0xD796', |
|
2654 | + '0xE8' => '0xD798', '0xEB' => '0xD79B', '0xF4' => '0xD7A4', |
|
2655 | 2655 | '0xFA' => '0xD7AA', |
2656 | 2656 | ), |
2657 | 2657 | 'windows-1253' => array( |
2658 | - '0x81' => '\'\'', '0x88' => '\'\'', '0x8A' => '\'\'', |
|
2659 | - '0x8C' => '\'\'', '0x8D' => '\'\'', '0x8E' => '\'\'', |
|
2660 | - '0x8F' => '\'\'', '0x90' => '\'\'', '0x98' => '\'\'', |
|
2661 | - '0x9A' => '\'\'', '0x9C' => '\'\'', '0x9D' => '\'\'', |
|
2662 | - '0x9E' => '\'\'', '0x9F' => '\'\'', '0xAA' => '\'\'', |
|
2663 | - '0xD2' => '0xE282AC', '0xFF' => '0xCE92', '0xCE' => '0xCE9E', |
|
2664 | - '0xB8' => '0xCE88', '0xBA' => '0xCE8A', '0xBC' => '0xCE8C', |
|
2665 | - '0xBE' => '0xCE8E', '0xBF' => '0xCE8F', '0xC0' => '0xCE90', |
|
2666 | - '0xC8' => '0xCE98', '0xCA' => '0xCE9A', '0xCC' => '0xCE9C', |
|
2667 | - '0xCD' => '0xCE9D', '0xCF' => '0xCE9F', '0xDA' => '0xCEAA', |
|
2668 | - '0xE8' => '0xCEB8', '0xEA' => '0xCEBA', '0xEC' => '0xCEBC', |
|
2669 | - '0xEE' => '0xCEBE', '0xEF' => '0xCEBF', '0xC2' => '0xFF', |
|
2670 | - '0xBD' => '0xC2BD', '0xED' => '0xCEBD', '0xB2' => '0xC2B2', |
|
2671 | - '0xA0' => '0xC2A0', '0xA3' => '0xC2A3', '0xA4' => '0xC2A4', |
|
2672 | - '0xA5' => '0xC2A5', '0xA6' => '0xC2A6', '0xA7' => '0xC2A7', |
|
2673 | - '0xA8' => '0xC2A8', '0xA9' => '0xC2A9', '0xAB' => '0xC2AB', |
|
2674 | - '0xAC' => '0xC2AC', '0xAD' => '0xC2AD', '0xAE' => '0xC2AE', |
|
2675 | - '0xB0' => '0xC2B0', '0xB1' => '0xC2B1', '0xB3' => '0xC2B3', |
|
2676 | - '0xB5' => '0xC2B5', '0xB6' => '0xC2B6', '0xB7' => '0xC2B7', |
|
2677 | - '0xBB' => '0xC2BB', '0xE2' => '0xCEB2', '0x80' => '0xD2', |
|
2678 | - '0x82' => '0xE2809A', '0x84' => '0xE2809E', '0x85' => '0xE280A6', |
|
2679 | - '0x86' => '0xE280A0', '0xA1' => '0xCE85', '0xA2' => '0xCE86', |
|
2680 | - '0x87' => '0xE280A1', '0x89' => '0xE280B0', '0xB9' => '0xCE89', |
|
2681 | - '0x8B' => '0xE280B9', '0x91' => '0xE28098', '0x99' => '0xE284A2', |
|
2682 | - '0x92' => '0xE28099', '0x93' => '0xE2809C', '0x94' => '0xE2809D', |
|
2683 | - '0x95' => '0xE280A2', '0x96' => '0xE28093', '0x97' => '0xE28094', |
|
2684 | - '0x9B' => '0xE280BA', '0xAF' => '0xE28095', '0xB4' => '0xCE84', |
|
2685 | - '0xC1' => '0xCE91', '0xC3' => '0xCE93', '0xC4' => '0xCE94', |
|
2686 | - '0xC5' => '0xCE95', '0xC6' => '0xCE96', '0x83' => '0xC692', |
|
2687 | - '0xC7' => '0xCE97', '0xC9' => '0xCE99', '0xCB' => '0xCE9B', |
|
2688 | - '0xD0' => '0xCEA0', '0xD1' => '0xCEA1', '0xD3' => '0xCEA3', |
|
2689 | - '0xD4' => '0xCEA4', '0xD5' => '0xCEA5', '0xD6' => '0xCEA6', |
|
2690 | - '0xD7' => '0xCEA7', '0xD8' => '0xCEA8', '0xD9' => '0xCEA9', |
|
2691 | - '0xDB' => '0xCEAB', '0xDC' => '0xCEAC', '0xDD' => '0xCEAD', |
|
2692 | - '0xDE' => '0xCEAE', '0xDF' => '0xCEAF', '0xE0' => '0xCEB0', |
|
2693 | - '0xE1' => '0xCEB1', '0xE3' => '0xCEB3', '0xE4' => '0xCEB4', |
|
2694 | - '0xE5' => '0xCEB5', '0xE6' => '0xCEB6', '0xE7' => '0xCEB7', |
|
2695 | - '0xE9' => '0xCEB9', '0xEB' => '0xCEBB', '0xF0' => '0xCF80', |
|
2696 | - '0xF1' => '0xCF81', '0xF2' => '0xCF82', '0xF3' => '0xCF83', |
|
2697 | - '0xF4' => '0xCF84', '0xF5' => '0xCF85', '0xF6' => '0xCF86', |
|
2698 | - '0xF7' => '0xCF87', '0xF8' => '0xCF88', '0xF9' => '0xCF89', |
|
2699 | - '0xFA' => '0xCF8A', '0xFB' => '0xCF8B', '0xFC' => '0xCF8C', |
|
2700 | - '0xFD' => '0xCF8D', '0xFE' => '0xCF8E', |
|
2658 | + '0x81' => '\'\'', '0x88' => '\'\'', '0x8A' => '\'\'', |
|
2659 | + '0x8C' => '\'\'', '0x8D' => '\'\'', '0x8E' => '\'\'', |
|
2660 | + '0x8F' => '\'\'', '0x90' => '\'\'', '0x98' => '\'\'', |
|
2661 | + '0x9A' => '\'\'', '0x9C' => '\'\'', '0x9D' => '\'\'', |
|
2662 | + '0x9E' => '\'\'', '0x9F' => '\'\'', '0xAA' => '\'\'', |
|
2663 | + '0xD2' => '0xE282AC', '0xFF' => '0xCE92', '0xCE' => '0xCE9E', |
|
2664 | + '0xB8' => '0xCE88', '0xBA' => '0xCE8A', '0xBC' => '0xCE8C', |
|
2665 | + '0xBE' => '0xCE8E', '0xBF' => '0xCE8F', '0xC0' => '0xCE90', |
|
2666 | + '0xC8' => '0xCE98', '0xCA' => '0xCE9A', '0xCC' => '0xCE9C', |
|
2667 | + '0xCD' => '0xCE9D', '0xCF' => '0xCE9F', '0xDA' => '0xCEAA', |
|
2668 | + '0xE8' => '0xCEB8', '0xEA' => '0xCEBA', '0xEC' => '0xCEBC', |
|
2669 | + '0xEE' => '0xCEBE', '0xEF' => '0xCEBF', '0xC2' => '0xFF', |
|
2670 | + '0xBD' => '0xC2BD', '0xED' => '0xCEBD', '0xB2' => '0xC2B2', |
|
2671 | + '0xA0' => '0xC2A0', '0xA3' => '0xC2A3', '0xA4' => '0xC2A4', |
|
2672 | + '0xA5' => '0xC2A5', '0xA6' => '0xC2A6', '0xA7' => '0xC2A7', |
|
2673 | + '0xA8' => '0xC2A8', '0xA9' => '0xC2A9', '0xAB' => '0xC2AB', |
|
2674 | + '0xAC' => '0xC2AC', '0xAD' => '0xC2AD', '0xAE' => '0xC2AE', |
|
2675 | + '0xB0' => '0xC2B0', '0xB1' => '0xC2B1', '0xB3' => '0xC2B3', |
|
2676 | + '0xB5' => '0xC2B5', '0xB6' => '0xC2B6', '0xB7' => '0xC2B7', |
|
2677 | + '0xBB' => '0xC2BB', '0xE2' => '0xCEB2', '0x80' => '0xD2', |
|
2678 | + '0x82' => '0xE2809A', '0x84' => '0xE2809E', '0x85' => '0xE280A6', |
|
2679 | + '0x86' => '0xE280A0', '0xA1' => '0xCE85', '0xA2' => '0xCE86', |
|
2680 | + '0x87' => '0xE280A1', '0x89' => '0xE280B0', '0xB9' => '0xCE89', |
|
2681 | + '0x8B' => '0xE280B9', '0x91' => '0xE28098', '0x99' => '0xE284A2', |
|
2682 | + '0x92' => '0xE28099', '0x93' => '0xE2809C', '0x94' => '0xE2809D', |
|
2683 | + '0x95' => '0xE280A2', '0x96' => '0xE28093', '0x97' => '0xE28094', |
|
2684 | + '0x9B' => '0xE280BA', '0xAF' => '0xE28095', '0xB4' => '0xCE84', |
|
2685 | + '0xC1' => '0xCE91', '0xC3' => '0xCE93', '0xC4' => '0xCE94', |
|
2686 | + '0xC5' => '0xCE95', '0xC6' => '0xCE96', '0x83' => '0xC692', |
|
2687 | + '0xC7' => '0xCE97', '0xC9' => '0xCE99', '0xCB' => '0xCE9B', |
|
2688 | + '0xD0' => '0xCEA0', '0xD1' => '0xCEA1', '0xD3' => '0xCEA3', |
|
2689 | + '0xD4' => '0xCEA4', '0xD5' => '0xCEA5', '0xD6' => '0xCEA6', |
|
2690 | + '0xD7' => '0xCEA7', '0xD8' => '0xCEA8', '0xD9' => '0xCEA9', |
|
2691 | + '0xDB' => '0xCEAB', '0xDC' => '0xCEAC', '0xDD' => '0xCEAD', |
|
2692 | + '0xDE' => '0xCEAE', '0xDF' => '0xCEAF', '0xE0' => '0xCEB0', |
|
2693 | + '0xE1' => '0xCEB1', '0xE3' => '0xCEB3', '0xE4' => '0xCEB4', |
|
2694 | + '0xE5' => '0xCEB5', '0xE6' => '0xCEB6', '0xE7' => '0xCEB7', |
|
2695 | + '0xE9' => '0xCEB9', '0xEB' => '0xCEBB', '0xF0' => '0xCF80', |
|
2696 | + '0xF1' => '0xCF81', '0xF2' => '0xCF82', '0xF3' => '0xCF83', |
|
2697 | + '0xF4' => '0xCF84', '0xF5' => '0xCF85', '0xF6' => '0xCF86', |
|
2698 | + '0xF7' => '0xCF87', '0xF8' => '0xCF88', '0xF9' => '0xCF89', |
|
2699 | + '0xFA' => '0xCF8A', '0xFB' => '0xCF8B', '0xFC' => '0xCF8C', |
|
2700 | + '0xFD' => '0xCF8D', '0xFE' => '0xCF8E', |
|
2701 | 2701 | ), |
2702 | 2702 | ); |
2703 | 2703 | |
@@ -3799,7 +3799,7 @@ discard block |
||
3799 | 3799 | <form action="', $upcontext['form_url'], '" name="upform" id="upform" method="post"> |
3800 | 3800 | <input type="hidden" name="backup_done" id="backup_done" value="0"> |
3801 | 3801 | <strong>Completed <span id="tab_done">', $upcontext['cur_table_num'], '</span> out of ', $upcontext['table_count'], ' tables.</strong> |
3802 | - <div id="debug_section" style="height: ', ($is_debug ? '115' : '12') , 'px; overflow: auto;"> |
|
3802 | + <div id="debug_section" style="height: ', ($is_debug ? '115' : '12'), 'px; overflow: auto;"> |
|
3803 | 3803 | <span id="debuginfo"></span> |
3804 | 3804 | </div>'; |
3805 | 3805 | |
@@ -4300,7 +4300,7 @@ discard block |
||
4300 | 4300 | <form action="', $upcontext['form_url'], '" name="upform" id="upform" method="post"> |
4301 | 4301 | <input type="hidden" name="utf8_done" id="utf8_done" value="0"> |
4302 | 4302 | <strong>Completed <span id="tab_done">', $upcontext['cur_table_num'], '</span> out of ', $upcontext['table_count'], ' tables.</strong> |
4303 | - <div id="debug_section" style="height: ', ($is_debug ? '97' : '12') , 'px; overflow: auto;"> |
|
4303 | + <div id="debug_section" style="height: ', ($is_debug ? '97' : '12'), 'px; overflow: auto;"> |
|
4304 | 4304 | <span id="debuginfo"></span> |
4305 | 4305 | </div>'; |
4306 | 4306 | |
@@ -4401,7 +4401,7 @@ discard block |
||
4401 | 4401 | <form action="', $upcontext['form_url'], '" name="upform" id="upform" method="post"> |
4402 | 4402 | <input type="hidden" name="json_done" id="json_done" value="0"> |
4403 | 4403 | <strong>Completed <span id="tab_done">', $upcontext['cur_table_num'], '</span> out of ', $upcontext['table_count'], ' tables.</strong> |
4404 | - <div id="debug_section" style="height: ', ($is_debug ? '115' : '12') , 'px; overflow: auto;"> |
|
4404 | + <div id="debug_section" style="height: ', ($is_debug ? '115' : '12'), 'px; overflow: auto;"> |
|
4405 | 4405 | <span id="debuginfo"></span> |
4406 | 4406 | </div>'; |
4407 | 4407 |
@@ -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']; |
@@ -197,8 +204,9 @@ discard block |
||
197 | 204 | 'db_error_skip' => true, |
198 | 205 | ) |
199 | 206 | ); |
200 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
201 | - $modSettings[$row['variable']] = $row['value']; |
|
207 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
208 | + $modSettings[$row['variable']] = $row['value']; |
|
209 | + } |
|
202 | 210 | $smcFunc['db_free_result']($request); |
203 | 211 | } |
204 | 212 | |
@@ -208,10 +216,12 @@ discard block |
||
208 | 216 | $modSettings['theme_url'] = 'Themes/default'; |
209 | 217 | $modSettings['images_url'] = 'Themes/default/images'; |
210 | 218 | } |
211 | -if (!isset($settings['default_theme_url'])) |
|
219 | +if (!isset($settings['default_theme_url'])) { |
|
212 | 220 | $settings['default_theme_url'] = $modSettings['theme_url']; |
213 | -if (!isset($settings['default_theme_dir'])) |
|
221 | +} |
|
222 | +if (!isset($settings['default_theme_dir'])) { |
|
214 | 223 | $settings['default_theme_dir'] = $modSettings['theme_dir']; |
224 | +} |
|
215 | 225 | |
216 | 226 | $upcontext['is_large_forum'] = (empty($modSettings['smfVersion']) || $modSettings['smfVersion'] <= '1.1 RC1') && !empty($modSettings['totalMessages']) && $modSettings['totalMessages'] > 75000; |
217 | 227 | // Default title... |
@@ -229,13 +239,15 @@ discard block |
||
229 | 239 | $support_js = $upcontext['upgrade_status']['js']; |
230 | 240 | |
231 | 241 | // Only set this if the upgrader status says so. |
232 | - if (empty($is_debug)) |
|
233 | - $is_debug = $upcontext['upgrade_status']['debug']; |
|
242 | + if (empty($is_debug)) { |
|
243 | + $is_debug = $upcontext['upgrade_status']['debug']; |
|
244 | + } |
|
234 | 245 | |
235 | 246 | // Load the language. |
236 | - if (file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) |
|
237 | - require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
238 | -} |
|
247 | + if (file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) { |
|
248 | + require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
249 | + } |
|
250 | + } |
|
239 | 251 | // Set the defaults. |
240 | 252 | else |
241 | 253 | { |
@@ -253,15 +265,18 @@ discard block |
||
253 | 265 | } |
254 | 266 | |
255 | 267 | // If this isn't the first stage see whether they are logging in and resuming. |
256 | -if ($upcontext['current_step'] != 0 || !empty($upcontext['user']['step'])) |
|
268 | +if ($upcontext['current_step'] != 0 || !empty($upcontext['user']['step'])) { |
|
257 | 269 | checkLogin(); |
270 | +} |
|
258 | 271 | |
259 | -if ($command_line) |
|
272 | +if ($command_line) { |
|
260 | 273 | cmdStep0(); |
274 | +} |
|
261 | 275 | |
262 | 276 | // Don't error if we're using xml. |
263 | -if (isset($_GET['xml'])) |
|
277 | +if (isset($_GET['xml'])) { |
|
264 | 278 | $upcontext['return_error'] = true; |
279 | +} |
|
265 | 280 | |
266 | 281 | // Loop through all the steps doing each one as required. |
267 | 282 | $upcontext['overall_percent'] = 0; |
@@ -282,9 +297,9 @@ discard block |
||
282 | 297 | } |
283 | 298 | |
284 | 299 | // Call the step and if it returns false that means pause! |
285 | - if (function_exists($step[2]) && $step[2]() === false) |
|
286 | - break; |
|
287 | - elseif (function_exists($step[2])) { |
|
300 | + if (function_exists($step[2]) && $step[2]() === false) { |
|
301 | + break; |
|
302 | + } elseif (function_exists($step[2])) { |
|
288 | 303 | //Start each new step with this unset, so the 'normal' template is called first |
289 | 304 | unset($_GET['xml']); |
290 | 305 | //Clear out warnings at the start of each step |
@@ -330,17 +345,18 @@ discard block |
||
330 | 345 | // This should not happen my dear... HELP ME DEVELOPERS!! |
331 | 346 | if (!empty($command_line)) |
332 | 347 | { |
333 | - if (function_exists('debug_print_backtrace')) |
|
334 | - debug_print_backtrace(); |
|
348 | + if (function_exists('debug_print_backtrace')) { |
|
349 | + debug_print_backtrace(); |
|
350 | + } |
|
335 | 351 | |
336 | 352 | 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.'; |
337 | 353 | flush(); |
338 | 354 | die(); |
339 | 355 | } |
340 | 356 | |
341 | - if (!isset($_GET['xml'])) |
|
342 | - template_upgrade_above(); |
|
343 | - else |
|
357 | + if (!isset($_GET['xml'])) { |
|
358 | + template_upgrade_above(); |
|
359 | + } else |
|
344 | 360 | { |
345 | 361 | header('Content-Type: text/xml; charset=UTF-8'); |
346 | 362 | // Sadly we need to retain the $_GET data thanks to the old upgrade scripts. |
@@ -362,25 +378,29 @@ discard block |
||
362 | 378 | $upcontext['form_url'] = $upgradeurl . '?step=' . $upcontext['current_step'] . '&substep=' . $_GET['substep'] . '&data=' . base64_encode(json_encode($upcontext['upgrade_status'])); |
363 | 379 | |
364 | 380 | // Custom stuff to pass back? |
365 | - if (!empty($upcontext['query_string'])) |
|
366 | - $upcontext['form_url'] .= $upcontext['query_string']; |
|
381 | + if (!empty($upcontext['query_string'])) { |
|
382 | + $upcontext['form_url'] .= $upcontext['query_string']; |
|
383 | + } |
|
367 | 384 | |
368 | 385 | // Call the appropriate subtemplate |
369 | - if (is_callable('template_' . $upcontext['sub_template'])) |
|
370 | - call_user_func('template_' . $upcontext['sub_template']); |
|
371 | - else |
|
372 | - die('Upgrade aborted! Invalid template: template_' . $upcontext['sub_template']); |
|
386 | + if (is_callable('template_' . $upcontext['sub_template'])) { |
|
387 | + call_user_func('template_' . $upcontext['sub_template']); |
|
388 | + } else { |
|
389 | + die('Upgrade aborted! Invalid template: template_' . $upcontext['sub_template']); |
|
390 | + } |
|
373 | 391 | } |
374 | 392 | |
375 | 393 | // Was there an error? |
376 | - if (!empty($upcontext['forced_error_message'])) |
|
377 | - echo $upcontext['forced_error_message']; |
|
394 | + if (!empty($upcontext['forced_error_message'])) { |
|
395 | + echo $upcontext['forced_error_message']; |
|
396 | + } |
|
378 | 397 | |
379 | 398 | // Show the footer. |
380 | - if (!isset($_GET['xml'])) |
|
381 | - template_upgrade_below(); |
|
382 | - else |
|
383 | - template_xml_below(); |
|
399 | + if (!isset($_GET['xml'])) { |
|
400 | + template_upgrade_below(); |
|
401 | + } else { |
|
402 | + template_xml_below(); |
|
403 | + } |
|
384 | 404 | } |
385 | 405 | |
386 | 406 | |
@@ -392,15 +412,19 @@ discard block |
||
392 | 412 | $seconds = intval($active % 60); |
393 | 413 | |
394 | 414 | $totalTime = ''; |
395 | - if ($hours > 0) |
|
396 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
397 | - if ($minutes > 0) |
|
398 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
399 | - if ($seconds > 0) |
|
400 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
415 | + if ($hours > 0) { |
|
416 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
417 | + } |
|
418 | + if ($minutes > 0) { |
|
419 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
420 | + } |
|
421 | + if ($seconds > 0) { |
|
422 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
423 | + } |
|
401 | 424 | |
402 | - if (!empty($totalTime)) |
|
403 | - echo "\n" . 'Upgrade completed in ' . $totalTime . "\n"; |
|
425 | + if (!empty($totalTime)) { |
|
426 | + echo "\n" . 'Upgrade completed in ' . $totalTime . "\n"; |
|
427 | + } |
|
404 | 428 | } |
405 | 429 | |
406 | 430 | // Bang - gone! |
@@ -413,8 +437,9 @@ discard block |
||
413 | 437 | global $upgradeurl, $upcontext, $command_line; |
414 | 438 | |
415 | 439 | // Command line users can't be redirected. |
416 | - if ($command_line) |
|
417 | - upgradeExit(true); |
|
440 | + if ($command_line) { |
|
441 | + upgradeExit(true); |
|
442 | + } |
|
418 | 443 | |
419 | 444 | // Are we providing the core info? |
420 | 445 | if ($addForm) |
@@ -440,12 +465,14 @@ discard block |
||
440 | 465 | define('SMF', 1); |
441 | 466 | |
442 | 467 | // Start the session. |
443 | - if (@ini_get('session.save_handler') == 'user') |
|
444 | - @ini_set('session.save_handler', 'files'); |
|
468 | + if (@ini_get('session.save_handler') == 'user') { |
|
469 | + @ini_set('session.save_handler', 'files'); |
|
470 | + } |
|
445 | 471 | @session_start(); |
446 | 472 | |
447 | - if (empty($smcFunc)) |
|
448 | - $smcFunc = array(); |
|
473 | + if (empty($smcFunc)) { |
|
474 | + $smcFunc = array(); |
|
475 | + } |
|
449 | 476 | |
450 | 477 | // We need this for authentication and some upgrade code |
451 | 478 | require_once($sourcedir . '/Subs-Auth.php'); |
@@ -472,24 +499,27 @@ discard block |
||
472 | 499 | require_once($sourcedir . '/Subs-Db-' . $db_type . '.php'); |
473 | 500 | |
474 | 501 | // Make the connection... |
475 | - if (empty($db_connection)) |
|
476 | - $db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, array('non_fatal' => true)); |
|
477 | - else |
|
478 | - // If we've returned here, ping/reconnect to be safe |
|
502 | + if (empty($db_connection)) { |
|
503 | + $db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, array('non_fatal' => true)); |
|
504 | + } else { |
|
505 | + // If we've returned here, ping/reconnect to be safe |
|
479 | 506 | $smcFunc['db_ping']($db_connection); |
507 | + } |
|
480 | 508 | |
481 | 509 | // Oh dear god!! |
482 | - if ($db_connection === null) |
|
483 | - die('Unable to connect to database - please check username and password are correct in Settings.php'); |
|
510 | + if ($db_connection === null) { |
|
511 | + die('Unable to connect to database - please check username and password are correct in Settings.php'); |
|
512 | + } |
|
484 | 513 | |
485 | - if ($db_type == 'mysql' && isset($db_character_set) && preg_match('~^\w+$~', $db_character_set) === 1) |
|
486 | - $smcFunc['db_query']('', ' |
|
514 | + if ($db_type == 'mysql' && isset($db_character_set) && preg_match('~^\w+$~', $db_character_set) === 1) { |
|
515 | + $smcFunc['db_query']('', ' |
|
487 | 516 | SET NAMES {string:db_character_set}', |
488 | 517 | array( |
489 | 518 | 'db_error_skip' => true, |
490 | 519 | 'db_character_set' => $db_character_set, |
491 | 520 | ) |
492 | 521 | ); |
522 | + } |
|
493 | 523 | |
494 | 524 | // Load the modSettings data... |
495 | 525 | $request = $smcFunc['db_query']('', ' |
@@ -500,11 +530,11 @@ discard block |
||
500 | 530 | ) |
501 | 531 | ); |
502 | 532 | $modSettings = array(); |
503 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
504 | - $modSettings[$row['variable']] = $row['value']; |
|
533 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
534 | + $modSettings[$row['variable']] = $row['value']; |
|
535 | + } |
|
505 | 536 | $smcFunc['db_free_result']($request); |
506 | - } |
|
507 | - else |
|
537 | + } else |
|
508 | 538 | { |
509 | 539 | 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.'); |
510 | 540 | } |
@@ -518,9 +548,10 @@ discard block |
||
518 | 548 | cleanRequest(); |
519 | 549 | } |
520 | 550 | |
521 | - if (!isset($_GET['substep'])) |
|
522 | - $_GET['substep'] = 0; |
|
523 | -} |
|
551 | + if (!isset($_GET['substep'])) { |
|
552 | + $_GET['substep'] = 0; |
|
553 | + } |
|
554 | + } |
|
524 | 555 | |
525 | 556 | function initialize_inputs() |
526 | 557 | { |
@@ -550,8 +581,9 @@ discard block |
||
550 | 581 | $dh = opendir(dirname(__FILE__)); |
551 | 582 | while ($file = readdir($dh)) |
552 | 583 | { |
553 | - if (preg_match('~upgrade_\d-\d_([A-Za-z])+\.sql~i', $file, $matches) && isset($matches[1])) |
|
554 | - @unlink(dirname(__FILE__) . '/' . $file); |
|
584 | + if (preg_match('~upgrade_\d-\d_([A-Za-z])+\.sql~i', $file, $matches) && isset($matches[1])) { |
|
585 | + @unlink(dirname(__FILE__) . '/' . $file); |
|
586 | + } |
|
555 | 587 | } |
556 | 588 | closedir($dh); |
557 | 589 | |
@@ -580,8 +612,9 @@ discard block |
||
580 | 612 | $temp = 'upgrade_php?step'; |
581 | 613 | while (strlen($temp) > 4) |
582 | 614 | { |
583 | - if (isset($_GET[$temp])) |
|
584 | - unset($_GET[$temp]); |
|
615 | + if (isset($_GET[$temp])) { |
|
616 | + unset($_GET[$temp]); |
|
617 | + } |
|
585 | 618 | $temp = substr($temp, 1); |
586 | 619 | } |
587 | 620 | |
@@ -608,32 +641,39 @@ discard block |
||
608 | 641 | && @file_exists(dirname(__FILE__) . '/upgrade_2-1_' . $db_type . '.sql'); |
609 | 642 | |
610 | 643 | // Need legacy scripts? |
611 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.1) |
|
612 | - $check &= @file_exists(dirname(__FILE__) . '/upgrade_2-0_' . $db_type . '.sql'); |
|
613 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.0) |
|
614 | - $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-1.sql'); |
|
615 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 1.1) |
|
616 | - $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-0.sql'); |
|
644 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.1) { |
|
645 | + $check &= @file_exists(dirname(__FILE__) . '/upgrade_2-0_' . $db_type . '.sql'); |
|
646 | + } |
|
647 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.0) { |
|
648 | + $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-1.sql'); |
|
649 | + } |
|
650 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 1.1) { |
|
651 | + $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-0.sql'); |
|
652 | + } |
|
617 | 653 | |
618 | 654 | // We don't need "-utf8" files anymore... |
619 | 655 | $upcontext['language'] = str_ireplace('-utf8', '', $upcontext['language']); |
620 | 656 | |
621 | 657 | // This needs to exist! |
622 | - if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) |
|
623 | - 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>]'); |
|
624 | - else |
|
625 | - require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
658 | + if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) { |
|
659 | + 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>]'); |
|
660 | + } else { |
|
661 | + require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
662 | + } |
|
626 | 663 | |
627 | - if (!$check) |
|
628 | - // 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. |
|
664 | + if (!$check) { |
|
665 | + // 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. |
|
629 | 666 | 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.'); |
667 | + } |
|
630 | 668 | |
631 | 669 | // Do they meet the install requirements? |
632 | - if (!php_version_check()) |
|
633 | - 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.'); |
|
670 | + if (!php_version_check()) { |
|
671 | + 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.'); |
|
672 | + } |
|
634 | 673 | |
635 | - if (!db_version_check()) |
|
636 | - 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.'); |
|
674 | + if (!db_version_check()) { |
|
675 | + 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.'); |
|
676 | + } |
|
637 | 677 | |
638 | 678 | // Do some checks to make sure they have proper privileges |
639 | 679 | db_extend('packages'); |
@@ -648,14 +688,16 @@ discard block |
||
648 | 688 | $drop = $smcFunc['db_drop_table']('{db_prefix}priv_check'); |
649 | 689 | |
650 | 690 | // Sorry... we need CREATE, ALTER and DROP |
651 | - if (!$create || !$alter || !$drop) |
|
652 | - 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.'); |
|
691 | + if (!$create || !$alter || !$drop) { |
|
692 | + 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.'); |
|
693 | + } |
|
653 | 694 | |
654 | 695 | // Do a quick version spot check. |
655 | 696 | $temp = substr(@implode('', @file($boarddir . '/index.php')), 0, 4096); |
656 | 697 | preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $temp, $match); |
657 | - if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) |
|
658 | - 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.'); |
|
698 | + if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) { |
|
699 | + 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.'); |
|
700 | + } |
|
659 | 701 | |
660 | 702 | // What absolutely needs to be writable? |
661 | 703 | $writable_files = array( |
@@ -677,12 +719,13 @@ discard block |
||
677 | 719 | quickFileWritable($custom_av_dir); |
678 | 720 | |
679 | 721 | // Are we good now? |
680 | - if (!is_writable($custom_av_dir)) |
|
681 | - 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)); |
|
682 | - elseif ($need_settings_update) |
|
722 | + if (!is_writable($custom_av_dir)) { |
|
723 | + 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)); |
|
724 | + } elseif ($need_settings_update) |
|
683 | 725 | { |
684 | - if (!function_exists('cache_put_data')) |
|
685 | - require_once($sourcedir . '/Load.php'); |
|
726 | + if (!function_exists('cache_put_data')) { |
|
727 | + require_once($sourcedir . '/Load.php'); |
|
728 | + } |
|
686 | 729 | updateSettings(array('custom_avatar_dir' => $custom_av_dir)); |
687 | 730 | updateSettings(array('custom_avatar_url' => $custom_av_url)); |
688 | 731 | } |
@@ -691,28 +734,33 @@ discard block |
||
691 | 734 | |
692 | 735 | // Check the cache directory. |
693 | 736 | $cachedir_temp = empty($cachedir) ? $boarddir . '/cache' : $cachedir; |
694 | - if (!file_exists($cachedir_temp)) |
|
695 | - @mkdir($cachedir_temp); |
|
696 | - if (!file_exists($cachedir_temp)) |
|
697 | - 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.'); |
|
698 | - |
|
699 | - if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) |
|
700 | - 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>.'); |
|
701 | - elseif (!isset($_GET['skiplang'])) |
|
737 | + if (!file_exists($cachedir_temp)) { |
|
738 | + @mkdir($cachedir_temp); |
|
739 | + } |
|
740 | + if (!file_exists($cachedir_temp)) { |
|
741 | + 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.'); |
|
742 | + } |
|
743 | + |
|
744 | + if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) { |
|
745 | + 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>.'); |
|
746 | + } elseif (!isset($_GET['skiplang'])) |
|
702 | 747 | { |
703 | 748 | $temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php')), 0, 4096); |
704 | 749 | preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match); |
705 | 750 | |
706 | - if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) |
|
707 | - 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>]'); |
|
751 | + if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) { |
|
752 | + 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>]'); |
|
753 | + } |
|
708 | 754 | } |
709 | 755 | |
710 | - if (!makeFilesWritable($writable_files)) |
|
711 | - return false; |
|
756 | + if (!makeFilesWritable($writable_files)) { |
|
757 | + return false; |
|
758 | + } |
|
712 | 759 | |
713 | 760 | // Check agreement.txt. (it may not exist, in which case $boarddir must be writable.) |
714 | - if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) |
|
715 | - 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.'); |
|
761 | + if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) { |
|
762 | + 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.'); |
|
763 | + } |
|
716 | 764 | |
717 | 765 | // Upgrade the agreement. |
718 | 766 | elseif (isset($modSettings['agreement'])) |
@@ -723,8 +771,8 @@ discard block |
||
723 | 771 | } |
724 | 772 | |
725 | 773 | // We're going to check that their board dir setting is right in case they've been moving stuff around. |
726 | - if (strtr($boarddir, array('/' => '', '\\' => '')) != strtr(dirname(__FILE__), array('/' => '', '\\' => ''))) |
|
727 | - $upcontext['warning'] = ' |
|
774 | + if (strtr($boarddir, array('/' => '', '\\' => '')) != strtr(dirname(__FILE__), array('/' => '', '\\' => ''))) { |
|
775 | + $upcontext['warning'] = ' |
|
728 | 776 | 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> |
729 | 777 | <ul> |
730 | 778 | <li>Board Directory: ' . $boarddir . '</li> |
@@ -732,19 +780,23 @@ discard block |
||
732 | 780 | <li>Cache Directory: ' . $cachedir_temp . '</li> |
733 | 781 | </ul> |
734 | 782 | 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.'; |
783 | + } |
|
735 | 784 | |
736 | 785 | // Confirm mbstring is loaded... |
737 | - if (!extension_loaded('mbstring')) |
|
738 | - return throw_error($txt['install_no_mbstring']); |
|
786 | + if (!extension_loaded('mbstring')) { |
|
787 | + return throw_error($txt['install_no_mbstring']); |
|
788 | + } |
|
739 | 789 | |
740 | 790 | // Check for https stream support. |
741 | 791 | $supported_streams = stream_get_wrappers(); |
742 | - if (!in_array('https', $supported_streams)) |
|
743 | - $upcontext['custom_warning'] = $txt['install_no_https']; |
|
792 | + if (!in_array('https', $supported_streams)) { |
|
793 | + $upcontext['custom_warning'] = $txt['install_no_https']; |
|
794 | + } |
|
744 | 795 | |
745 | 796 | // Either we're logged in or we're going to present the login. |
746 | - if (checkLogin()) |
|
747 | - return true; |
|
797 | + if (checkLogin()) { |
|
798 | + return true; |
|
799 | + } |
|
748 | 800 | |
749 | 801 | $upcontext += createToken('login'); |
750 | 802 | |
@@ -758,15 +810,17 @@ discard block |
||
758 | 810 | global $smcFunc, $db_type, $support_js; |
759 | 811 | |
760 | 812 | // Don't bother if the security is disabled. |
761 | - if ($disable_security) |
|
762 | - return true; |
|
813 | + if ($disable_security) { |
|
814 | + return true; |
|
815 | + } |
|
763 | 816 | |
764 | 817 | // Are we trying to login? |
765 | 818 | if (isset($_POST['contbutt']) && (!empty($_POST['user']))) |
766 | 819 | { |
767 | 820 | // If we've disabled security pick a suitable name! |
768 | - if (empty($_POST['user'])) |
|
769 | - $_POST['user'] = 'Administrator'; |
|
821 | + if (empty($_POST['user'])) { |
|
822 | + $_POST['user'] = 'Administrator'; |
|
823 | + } |
|
770 | 824 | |
771 | 825 | // Before 2.0 these column names were different! |
772 | 826 | $oldDB = false; |
@@ -781,16 +835,17 @@ discard block |
||
781 | 835 | 'db_error_skip' => true, |
782 | 836 | ) |
783 | 837 | ); |
784 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
785 | - $oldDB = true; |
|
838 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
839 | + $oldDB = true; |
|
840 | + } |
|
786 | 841 | $smcFunc['db_free_result']($request); |
787 | 842 | } |
788 | 843 | |
789 | 844 | // Get what we believe to be their details. |
790 | 845 | if (!$disable_security) |
791 | 846 | { |
792 | - if ($oldDB) |
|
793 | - $request = $smcFunc['db_query']('', ' |
|
847 | + if ($oldDB) { |
|
848 | + $request = $smcFunc['db_query']('', ' |
|
794 | 849 | SELECT id_member, memberName AS member_name, passwd, id_group, |
795 | 850 | additionalGroups AS additional_groups, lngfile |
796 | 851 | FROM {db_prefix}members |
@@ -800,8 +855,8 @@ discard block |
||
800 | 855 | 'db_error_skip' => true, |
801 | 856 | ) |
802 | 857 | ); |
803 | - else |
|
804 | - $request = $smcFunc['db_query']('', ' |
|
858 | + } else { |
|
859 | + $request = $smcFunc['db_query']('', ' |
|
805 | 860 | SELECT id_member, member_name, passwd, id_group, additional_groups, lngfile |
806 | 861 | FROM {db_prefix}members |
807 | 862 | WHERE member_name = {string:member_name}', |
@@ -810,6 +865,7 @@ discard block |
||
810 | 865 | 'db_error_skip' => true, |
811 | 866 | ) |
812 | 867 | ); |
868 | + } |
|
813 | 869 | if ($smcFunc['db_num_rows']($request) != 0) |
814 | 870 | { |
815 | 871 | list ($id_member, $name, $password, $id_group, $addGroups, $user_language) = $smcFunc['db_fetch_row']($request); |
@@ -817,16 +873,17 @@ discard block |
||
817 | 873 | $groups = explode(',', $addGroups); |
818 | 874 | $groups[] = $id_group; |
819 | 875 | |
820 | - foreach ($groups as $k => $v) |
|
821 | - $groups[$k] = (int) $v; |
|
876 | + foreach ($groups as $k => $v) { |
|
877 | + $groups[$k] = (int) $v; |
|
878 | + } |
|
822 | 879 | |
823 | 880 | $sha_passwd = sha1(strtolower($name) . un_htmlspecialchars($_REQUEST['passwrd'])); |
824 | 881 | |
825 | 882 | // We don't use "-utf8" anymore... |
826 | 883 | $user_language = str_ireplace('-utf8', '', $user_language); |
884 | + } else { |
|
885 | + $upcontext['username_incorrect'] = true; |
|
827 | 886 | } |
828 | - else |
|
829 | - $upcontext['username_incorrect'] = true; |
|
830 | 887 | $smcFunc['db_free_result']($request); |
831 | 888 | } |
832 | 889 | $upcontext['username'] = $_POST['user']; |
@@ -836,13 +893,14 @@ discard block |
||
836 | 893 | { |
837 | 894 | $upcontext['upgrade_status']['js'] = 1; |
838 | 895 | $support_js = 1; |
896 | + } else { |
|
897 | + $support_js = 0; |
|
839 | 898 | } |
840 | - else |
|
841 | - $support_js = 0; |
|
842 | 899 | |
843 | 900 | // Note down the version we are coming from. |
844 | - if (!empty($modSettings['smfVersion']) && empty($upcontext['user']['version'])) |
|
845 | - $upcontext['user']['version'] = $modSettings['smfVersion']; |
|
901 | + if (!empty($modSettings['smfVersion']) && empty($upcontext['user']['version'])) { |
|
902 | + $upcontext['user']['version'] = $modSettings['smfVersion']; |
|
903 | + } |
|
846 | 904 | |
847 | 905 | // Didn't get anywhere? |
848 | 906 | 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'])) |
@@ -876,15 +934,15 @@ discard block |
||
876 | 934 | 'db_error_skip' => true, |
877 | 935 | ) |
878 | 936 | ); |
879 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
880 | - return throw_error('You need to be an admin to perform an upgrade!'); |
|
937 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
938 | + return throw_error('You need to be an admin to perform an upgrade!'); |
|
939 | + } |
|
881 | 940 | $smcFunc['db_free_result']($request); |
882 | 941 | } |
883 | 942 | |
884 | 943 | $upcontext['user']['id'] = $id_member; |
885 | 944 | $upcontext['user']['name'] = $name; |
886 | - } |
|
887 | - else |
|
945 | + } else |
|
888 | 946 | { |
889 | 947 | $upcontext['user']['id'] = 1; |
890 | 948 | $upcontext['user']['name'] = 'Administrator'; |
@@ -900,11 +958,11 @@ discard block |
||
900 | 958 | $temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $user_language . '.php')), 0, 4096); |
901 | 959 | preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match); |
902 | 960 | |
903 | - if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) |
|
904 | - $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'] . '.'; |
|
905 | - elseif (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . basename($user_language, '.lng') . '.php')) |
|
906 | - $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'] . '.'; |
|
907 | - else |
|
961 | + if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) { |
|
962 | + $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'] . '.'; |
|
963 | + } elseif (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . basename($user_language, '.lng') . '.php')) { |
|
964 | + $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'] . '.'; |
|
965 | + } else |
|
908 | 966 | { |
909 | 967 | // Set this as the new language. |
910 | 968 | $upcontext['language'] = $user_language; |
@@ -948,8 +1006,9 @@ discard block |
||
948 | 1006 | unset($member_columns); |
949 | 1007 | |
950 | 1008 | // If we've not submitted then we're done. |
951 | - if (empty($_POST['upcont'])) |
|
952 | - return false; |
|
1009 | + if (empty($_POST['upcont'])) { |
|
1010 | + return false; |
|
1011 | + } |
|
953 | 1012 | |
954 | 1013 | // Firstly, if they're enabling SM stat collection just do it. |
955 | 1014 | if (!empty($_POST['stats']) && substr($boardurl, 0, 16) != 'http://localhost' && empty($modSettings['allow_sm_stats']) && empty($modSettings['enable_sm_stats'])) |
@@ -969,16 +1028,17 @@ discard block |
||
969 | 1028 | fwrite($fp, $out); |
970 | 1029 | |
971 | 1030 | $return_data = ''; |
972 | - while (!feof($fp)) |
|
973 | - $return_data .= fgets($fp, 128); |
|
1031 | + while (!feof($fp)) { |
|
1032 | + $return_data .= fgets($fp, 128); |
|
1033 | + } |
|
974 | 1034 | |
975 | 1035 | fclose($fp); |
976 | 1036 | |
977 | 1037 | // Get the unique site ID. |
978 | 1038 | preg_match('~SITE-ID:\s(\w{10})~', $return_data, $ID); |
979 | 1039 | |
980 | - if (!empty($ID[1])) |
|
981 | - $smcFunc['db_insert']('replace', |
|
1040 | + if (!empty($ID[1])) { |
|
1041 | + $smcFunc['db_insert']('replace', |
|
982 | 1042 | $db_prefix . 'settings', |
983 | 1043 | array('variable' => 'string', 'value' => 'string'), |
984 | 1044 | array( |
@@ -987,9 +1047,9 @@ discard block |
||
987 | 1047 | ), |
988 | 1048 | array('variable') |
989 | 1049 | ); |
1050 | + } |
|
990 | 1051 | } |
991 | - } |
|
992 | - else |
|
1052 | + } else |
|
993 | 1053 | { |
994 | 1054 | $smcFunc['db_insert']('replace', |
995 | 1055 | $db_prefix . 'settings', |
@@ -1000,8 +1060,8 @@ discard block |
||
1000 | 1060 | } |
1001 | 1061 | } |
1002 | 1062 | // Don't remove stat collection unless we unchecked the box for real, not from the loop. |
1003 | - elseif (empty($_POST['stats']) && empty($upcontext['allow_sm_stats'])) |
|
1004 | - $smcFunc['db_query']('', ' |
|
1063 | + elseif (empty($_POST['stats']) && empty($upcontext['allow_sm_stats'])) { |
|
1064 | + $smcFunc['db_query']('', ' |
|
1005 | 1065 | DELETE FROM {db_prefix}settings |
1006 | 1066 | WHERE variable = {string:enable_sm_stats}', |
1007 | 1067 | array( |
@@ -1009,6 +1069,7 @@ discard block |
||
1009 | 1069 | 'db_error_skip' => true, |
1010 | 1070 | ) |
1011 | 1071 | ); |
1072 | + } |
|
1012 | 1073 | |
1013 | 1074 | // Deleting old karma stuff? |
1014 | 1075 | if (!empty($_POST['delete_karma'])) |
@@ -1023,20 +1084,22 @@ discard block |
||
1023 | 1084 | ); |
1024 | 1085 | |
1025 | 1086 | // Cleaning up old karma member settings. |
1026 | - if ($upcontext['karma_installed']['good']) |
|
1027 | - $smcFunc['db_query']('', ' |
|
1087 | + if ($upcontext['karma_installed']['good']) { |
|
1088 | + $smcFunc['db_query']('', ' |
|
1028 | 1089 | ALTER TABLE {db_prefix}members |
1029 | 1090 | DROP karma_good', |
1030 | 1091 | array() |
1031 | 1092 | ); |
1093 | + } |
|
1032 | 1094 | |
1033 | 1095 | // Does karma bad was enable? |
1034 | - if ($upcontext['karma_installed']['bad']) |
|
1035 | - $smcFunc['db_query']('', ' |
|
1096 | + if ($upcontext['karma_installed']['bad']) { |
|
1097 | + $smcFunc['db_query']('', ' |
|
1036 | 1098 | ALTER TABLE {db_prefix}members |
1037 | 1099 | DROP karma_bad', |
1038 | 1100 | array() |
1039 | 1101 | ); |
1102 | + } |
|
1040 | 1103 | |
1041 | 1104 | // Cleaning up old karma permissions. |
1042 | 1105 | $smcFunc['db_query']('', ' |
@@ -1049,26 +1112,29 @@ discard block |
||
1049 | 1112 | } |
1050 | 1113 | |
1051 | 1114 | // Emptying the error log? |
1052 | - if (!empty($_POST['empty_error'])) |
|
1053 | - $smcFunc['db_query']('truncate_table', ' |
|
1115 | + if (!empty($_POST['empty_error'])) { |
|
1116 | + $smcFunc['db_query']('truncate_table', ' |
|
1054 | 1117 | TRUNCATE {db_prefix}log_errors', |
1055 | 1118 | array( |
1056 | 1119 | ) |
1057 | 1120 | ); |
1121 | + } |
|
1058 | 1122 | |
1059 | 1123 | $changes = array(); |
1060 | 1124 | |
1061 | 1125 | // Add proxy settings. |
1062 | - if (!isset($GLOBALS['image_proxy_maxsize'])) |
|
1063 | - $changes += array( |
|
1126 | + if (!isset($GLOBALS['image_proxy_maxsize'])) { |
|
1127 | + $changes += array( |
|
1064 | 1128 | 'image_proxy_secret' => '\'' . substr(sha1(mt_rand()), 0, 20) . '\'', |
1065 | 1129 | 'image_proxy_maxsize' => 5190, |
1066 | 1130 | 'image_proxy_enabled' => 0, |
1067 | 1131 | ); |
1132 | + } |
|
1068 | 1133 | |
1069 | 1134 | // If we're overriding the language follow it through. |
1070 | - if (isset($_GET['lang']) && file_exists($modSettings['theme_dir'] . '/languages/index.' . $_GET['lang'] . '.php')) |
|
1071 | - $changes['language'] = '\'' . $_GET['lang'] . '\''; |
|
1135 | + if (isset($_GET['lang']) && file_exists($modSettings['theme_dir'] . '/languages/index.' . $_GET['lang'] . '.php')) { |
|
1136 | + $changes['language'] = '\'' . $_GET['lang'] . '\''; |
|
1137 | + } |
|
1072 | 1138 | |
1073 | 1139 | if (!empty($_POST['maint'])) |
1074 | 1140 | { |
@@ -1080,26 +1146,29 @@ discard block |
||
1080 | 1146 | { |
1081 | 1147 | $changes['mtitle'] = '\'' . addslashes($_POST['maintitle']) . '\''; |
1082 | 1148 | $changes['mmessage'] = '\'' . addslashes($_POST['mainmessage']) . '\''; |
1083 | - } |
|
1084 | - else |
|
1149 | + } else |
|
1085 | 1150 | { |
1086 | 1151 | $changes['mtitle'] = '\'Upgrading the forum...\''; |
1087 | 1152 | $changes['mmessage'] = '\'Don\\\'t worry, we will be back shortly with an updated forum. It will only be a minute ;).\''; |
1088 | 1153 | } |
1089 | 1154 | } |
1090 | 1155 | |
1091 | - if ($command_line) |
|
1092 | - echo ' * Updating Settings.php...'; |
|
1156 | + if ($command_line) { |
|
1157 | + echo ' * Updating Settings.php...'; |
|
1158 | + } |
|
1093 | 1159 | |
1094 | 1160 | // Fix some old paths. |
1095 | - if (substr($boarddir, 0, 1) == '.') |
|
1096 | - $changes['boarddir'] = '\'' . fixRelativePath($boarddir) . '\''; |
|
1161 | + if (substr($boarddir, 0, 1) == '.') { |
|
1162 | + $changes['boarddir'] = '\'' . fixRelativePath($boarddir) . '\''; |
|
1163 | + } |
|
1097 | 1164 | |
1098 | - if (substr($sourcedir, 0, 1) == '.') |
|
1099 | - $changes['sourcedir'] = '\'' . fixRelativePath($sourcedir) . '\''; |
|
1165 | + if (substr($sourcedir, 0, 1) == '.') { |
|
1166 | + $changes['sourcedir'] = '\'' . fixRelativePath($sourcedir) . '\''; |
|
1167 | + } |
|
1100 | 1168 | |
1101 | - if (empty($cachedir) || substr($cachedir, 0, 1) == '.') |
|
1102 | - $changes['cachedir'] = '\'' . fixRelativePath($boarddir) . '/cache\''; |
|
1169 | + if (empty($cachedir) || substr($cachedir, 0, 1) == '.') { |
|
1170 | + $changes['cachedir'] = '\'' . fixRelativePath($boarddir) . '/cache\''; |
|
1171 | + } |
|
1103 | 1172 | |
1104 | 1173 | // If they have a "host:port" setup for the host, split that into separate values |
1105 | 1174 | // You should never have a : in the hostname if you're not on MySQL, but better safe than sorry |
@@ -1110,32 +1179,36 @@ discard block |
||
1110 | 1179 | $changes['db_server'] = '\'' . $db_server . '\''; |
1111 | 1180 | |
1112 | 1181 | // Only set this if we're not using the default port |
1113 | - if ($db_port != ini_get('mysqli.default_port')) |
|
1114 | - $changes['db_port'] = (int) $db_port; |
|
1115 | - } |
|
1116 | - elseif (!empty($db_port)) |
|
1182 | + if ($db_port != ini_get('mysqli.default_port')) { |
|
1183 | + $changes['db_port'] = (int) $db_port; |
|
1184 | + } |
|
1185 | + } elseif (!empty($db_port)) |
|
1117 | 1186 | { |
1118 | 1187 | // If db_port is set and is the same as the default, set it to '' |
1119 | 1188 | if ($db_type == 'mysql') |
1120 | 1189 | { |
1121 | - if ($db_port == ini_get('mysqli.default_port')) |
|
1122 | - $changes['db_port'] = '\'\''; |
|
1123 | - elseif ($db_type == 'postgresql' && $db_port == 5432) |
|
1124 | - $changes['db_port'] = '\'\''; |
|
1190 | + if ($db_port == ini_get('mysqli.default_port')) { |
|
1191 | + $changes['db_port'] = '\'\''; |
|
1192 | + } elseif ($db_type == 'postgresql' && $db_port == 5432) { |
|
1193 | + $changes['db_port'] = '\'\''; |
|
1194 | + } |
|
1125 | 1195 | } |
1126 | 1196 | } |
1127 | 1197 | |
1128 | 1198 | // Maybe we haven't had this option yet? |
1129 | - if (empty($packagesdir)) |
|
1130 | - $changes['packagesdir'] = '\'' . fixRelativePath($boarddir) . '/Packages\''; |
|
1199 | + if (empty($packagesdir)) { |
|
1200 | + $changes['packagesdir'] = '\'' . fixRelativePath($boarddir) . '/Packages\''; |
|
1201 | + } |
|
1131 | 1202 | |
1132 | 1203 | // Add support for $tasksdir var. |
1133 | - if (empty($tasksdir)) |
|
1134 | - $changes['tasksdir'] = '\'' . fixRelativePath($sourcedir) . '/tasks\''; |
|
1204 | + if (empty($tasksdir)) { |
|
1205 | + $changes['tasksdir'] = '\'' . fixRelativePath($sourcedir) . '/tasks\''; |
|
1206 | + } |
|
1135 | 1207 | |
1136 | 1208 | // Make sure we fix the language as well. |
1137 | - if (stristr($language, '-utf8')) |
|
1138 | - $changes['language'] = '\'' . str_ireplace('-utf8', '', $language) . '\''; |
|
1209 | + if (stristr($language, '-utf8')) { |
|
1210 | + $changes['language'] = '\'' . str_ireplace('-utf8', '', $language) . '\''; |
|
1211 | + } |
|
1139 | 1212 | |
1140 | 1213 | // @todo Maybe change the cookie name if going to 1.1, too? |
1141 | 1214 | |
@@ -1143,8 +1216,9 @@ discard block |
||
1143 | 1216 | require_once($sourcedir . '/Subs-Admin.php'); |
1144 | 1217 | updateSettingsFile($changes); |
1145 | 1218 | |
1146 | - if ($command_line) |
|
1147 | - echo ' Successful.' . "\n"; |
|
1219 | + if ($command_line) { |
|
1220 | + echo ' Successful.' . "\n"; |
|
1221 | + } |
|
1148 | 1222 | |
1149 | 1223 | // Are we doing debug? |
1150 | 1224 | if (isset($_POST['debug'])) |
@@ -1154,8 +1228,9 @@ discard block |
||
1154 | 1228 | } |
1155 | 1229 | |
1156 | 1230 | // If we're not backing up then jump one. |
1157 | - if (empty($_POST['backup'])) |
|
1158 | - $upcontext['current_step']++; |
|
1231 | + if (empty($_POST['backup'])) { |
|
1232 | + $upcontext['current_step']++; |
|
1233 | + } |
|
1159 | 1234 | |
1160 | 1235 | // If we've got here then let's proceed to the next step! |
1161 | 1236 | return true; |
@@ -1170,8 +1245,9 @@ discard block |
||
1170 | 1245 | $upcontext['page_title'] = 'Backup Database'; |
1171 | 1246 | |
1172 | 1247 | // Done it already - js wise? |
1173 | - if (!empty($_POST['backup_done'])) |
|
1174 | - return true; |
|
1248 | + if (!empty($_POST['backup_done'])) { |
|
1249 | + return true; |
|
1250 | + } |
|
1175 | 1251 | |
1176 | 1252 | // Some useful stuff here. |
1177 | 1253 | db_extend(); |
@@ -1185,9 +1261,10 @@ discard block |
||
1185 | 1261 | $tables = $smcFunc['db_list_tables']($db, $filter); |
1186 | 1262 | |
1187 | 1263 | $table_names = array(); |
1188 | - foreach ($tables as $table) |
|
1189 | - if (substr($table, 0, 7) !== 'backup_') |
|
1264 | + foreach ($tables as $table) { |
|
1265 | + if (substr($table, 0, 7) !== 'backup_') |
|
1190 | 1266 | $table_names[] = $table; |
1267 | + } |
|
1191 | 1268 | |
1192 | 1269 | $upcontext['table_count'] = count($table_names); |
1193 | 1270 | $upcontext['cur_table_num'] = $_GET['substep']; |
@@ -1197,12 +1274,14 @@ discard block |
||
1197 | 1274 | $file_steps = $upcontext['table_count']; |
1198 | 1275 | |
1199 | 1276 | // What ones have we already done? |
1200 | - foreach ($table_names as $id => $table) |
|
1201 | - if ($id < $_GET['substep']) |
|
1277 | + foreach ($table_names as $id => $table) { |
|
1278 | + if ($id < $_GET['substep']) |
|
1202 | 1279 | $upcontext['previous_tables'][] = $table; |
1280 | + } |
|
1203 | 1281 | |
1204 | - if ($command_line) |
|
1205 | - echo 'Backing Up Tables.'; |
|
1282 | + if ($command_line) { |
|
1283 | + echo 'Backing Up Tables.'; |
|
1284 | + } |
|
1206 | 1285 | |
1207 | 1286 | // If we don't support javascript we backup here. |
1208 | 1287 | if (!$support_js || isset($_GET['xml'])) |
@@ -1221,8 +1300,9 @@ discard block |
||
1221 | 1300 | backupTable($table_names[$substep]); |
1222 | 1301 | |
1223 | 1302 | // If this is XML to keep it nice for the user do one table at a time anyway! |
1224 | - if (isset($_GET['xml'])) |
|
1225 | - return upgradeExit(); |
|
1303 | + if (isset($_GET['xml'])) { |
|
1304 | + return upgradeExit(); |
|
1305 | + } |
|
1226 | 1306 | } |
1227 | 1307 | |
1228 | 1308 | if ($command_line) |
@@ -1255,9 +1335,10 @@ discard block |
||
1255 | 1335 | |
1256 | 1336 | $smcFunc['db_backup_table']($table, 'backup_' . $table); |
1257 | 1337 | |
1258 | - if ($command_line) |
|
1259 | - echo ' done.'; |
|
1260 | -} |
|
1338 | + if ($command_line) { |
|
1339 | + echo ' done.'; |
|
1340 | + } |
|
1341 | + } |
|
1261 | 1342 | |
1262 | 1343 | // Step 2: Everything. |
1263 | 1344 | function DatabaseChanges() |
@@ -1266,8 +1347,9 @@ discard block |
||
1266 | 1347 | global $upcontext, $support_js, $db_type; |
1267 | 1348 | |
1268 | 1349 | // Have we just completed this? |
1269 | - if (!empty($_POST['database_done'])) |
|
1270 | - return true; |
|
1350 | + if (!empty($_POST['database_done'])) { |
|
1351 | + return true; |
|
1352 | + } |
|
1271 | 1353 | |
1272 | 1354 | $upcontext['sub_template'] = isset($_GET['xml']) ? 'database_xml' : 'database_changes'; |
1273 | 1355 | $upcontext['page_title'] = 'Database Changes'; |
@@ -1282,15 +1364,16 @@ discard block |
||
1282 | 1364 | ); |
1283 | 1365 | |
1284 | 1366 | // How many files are there in total? |
1285 | - if (isset($_GET['filecount'])) |
|
1286 | - $upcontext['file_count'] = (int) $_GET['filecount']; |
|
1287 | - else |
|
1367 | + if (isset($_GET['filecount'])) { |
|
1368 | + $upcontext['file_count'] = (int) $_GET['filecount']; |
|
1369 | + } else |
|
1288 | 1370 | { |
1289 | 1371 | $upcontext['file_count'] = 0; |
1290 | 1372 | foreach ($files as $file) |
1291 | 1373 | { |
1292 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < $file[1]) |
|
1293 | - $upcontext['file_count']++; |
|
1374 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < $file[1]) { |
|
1375 | + $upcontext['file_count']++; |
|
1376 | + } |
|
1294 | 1377 | } |
1295 | 1378 | } |
1296 | 1379 | |
@@ -1300,9 +1383,9 @@ discard block |
||
1300 | 1383 | $upcontext['cur_file_num'] = 0; |
1301 | 1384 | foreach ($files as $file) |
1302 | 1385 | { |
1303 | - if ($did_not_do) |
|
1304 | - $did_not_do--; |
|
1305 | - else |
|
1386 | + if ($did_not_do) { |
|
1387 | + $did_not_do--; |
|
1388 | + } else |
|
1306 | 1389 | { |
1307 | 1390 | $upcontext['cur_file_num']++; |
1308 | 1391 | $upcontext['cur_file_name'] = $file[0]; |
@@ -1329,12 +1412,13 @@ discard block |
||
1329 | 1412 | // Flag to move on to the next. |
1330 | 1413 | $upcontext['completed_step'] = true; |
1331 | 1414 | // Did we complete the whole file? |
1332 | - if ($nextFile) |
|
1333 | - $upcontext['current_debug_item_num'] = -1; |
|
1415 | + if ($nextFile) { |
|
1416 | + $upcontext['current_debug_item_num'] = -1; |
|
1417 | + } |
|
1334 | 1418 | return upgradeExit(); |
1419 | + } elseif ($support_js) { |
|
1420 | + break; |
|
1335 | 1421 | } |
1336 | - elseif ($support_js) |
|
1337 | - break; |
|
1338 | 1422 | } |
1339 | 1423 | // Set the progress bar to be right as if we had - even if we hadn't... |
1340 | 1424 | $upcontext['step_progress'] = ($upcontext['cur_file_num'] / $upcontext['file_count']) * 100; |
@@ -1359,8 +1443,9 @@ discard block |
||
1359 | 1443 | global $command_line, $language, $upcontext, $sourcedir, $forum_version, $user_info, $maintenance, $smcFunc, $db_type; |
1360 | 1444 | |
1361 | 1445 | // Now it's nice to have some of the basic SMF source files. |
1362 | - if (!isset($_GET['ssi']) && !$command_line) |
|
1363 | - redirectLocation('&ssi=1'); |
|
1446 | + if (!isset($_GET['ssi']) && !$command_line) { |
|
1447 | + redirectLocation('&ssi=1'); |
|
1448 | + } |
|
1364 | 1449 | |
1365 | 1450 | $upcontext['sub_template'] = 'upgrade_complete'; |
1366 | 1451 | $upcontext['page_title'] = 'Upgrade Complete'; |
@@ -1376,14 +1461,16 @@ discard block |
||
1376 | 1461 | // Are we in maintenance mode? |
1377 | 1462 | if (isset($upcontext['user']['main'])) |
1378 | 1463 | { |
1379 | - if ($command_line) |
|
1380 | - echo ' * '; |
|
1464 | + if ($command_line) { |
|
1465 | + echo ' * '; |
|
1466 | + } |
|
1381 | 1467 | $upcontext['removed_maintenance'] = true; |
1382 | 1468 | $changes['maintenance'] = $upcontext['user']['main']; |
1383 | 1469 | } |
1384 | 1470 | // Otherwise if somehow we are in 2 let's go to 1. |
1385 | - elseif (!empty($maintenance) && $maintenance == 2) |
|
1386 | - $changes['maintenance'] = 1; |
|
1471 | + elseif (!empty($maintenance) && $maintenance == 2) { |
|
1472 | + $changes['maintenance'] = 1; |
|
1473 | + } |
|
1387 | 1474 | |
1388 | 1475 | // Wipe this out... |
1389 | 1476 | $upcontext['user'] = array(); |
@@ -1398,9 +1485,9 @@ discard block |
||
1398 | 1485 | $upcontext['can_delete_script'] = is_writable(dirname(__FILE__)) || is_writable(__FILE__); |
1399 | 1486 | |
1400 | 1487 | // Now is the perfect time to fetch the SM files. |
1401 | - if ($command_line) |
|
1402 | - cli_scheduled_fetchSMfiles(); |
|
1403 | - else |
|
1488 | + if ($command_line) { |
|
1489 | + cli_scheduled_fetchSMfiles(); |
|
1490 | + } else |
|
1404 | 1491 | { |
1405 | 1492 | require_once($sourcedir . '/ScheduledTasks.php'); |
1406 | 1493 | $forum_version = SMF_VERSION; // The variable is usually defined in index.php so lets just use the constant to do it for us. |
@@ -1408,8 +1495,9 @@ discard block |
||
1408 | 1495 | } |
1409 | 1496 | |
1410 | 1497 | // Log what we've done. |
1411 | - if (empty($user_info['id'])) |
|
1412 | - $user_info['id'] = !empty($upcontext['user']['id']) ? $upcontext['user']['id'] : 0; |
|
1498 | + if (empty($user_info['id'])) { |
|
1499 | + $user_info['id'] = !empty($upcontext['user']['id']) ? $upcontext['user']['id'] : 0; |
|
1500 | + } |
|
1413 | 1501 | |
1414 | 1502 | // Log the action manually, so CLI still works. |
1415 | 1503 | $smcFunc['db_insert']('', |
@@ -1428,8 +1516,9 @@ discard block |
||
1428 | 1516 | |
1429 | 1517 | // Save the current database version. |
1430 | 1518 | $server_version = $smcFunc['db_server_info'](); |
1431 | - if ($db_type == 'mysql' && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) |
|
1432 | - updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
1519 | + if ($db_type == 'mysql' && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) { |
|
1520 | + updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
1521 | + } |
|
1433 | 1522 | |
1434 | 1523 | if ($command_line) |
1435 | 1524 | { |
@@ -1441,8 +1530,9 @@ discard block |
||
1441 | 1530 | |
1442 | 1531 | // Make sure it says we're done. |
1443 | 1532 | $upcontext['overall_percent'] = 100; |
1444 | - if (isset($upcontext['step_progress'])) |
|
1445 | - unset($upcontext['step_progress']); |
|
1533 | + if (isset($upcontext['step_progress'])) { |
|
1534 | + unset($upcontext['step_progress']); |
|
1535 | + } |
|
1446 | 1536 | |
1447 | 1537 | $_GET['substep'] = 0; |
1448 | 1538 | return false; |
@@ -1453,8 +1543,9 @@ discard block |
||
1453 | 1543 | { |
1454 | 1544 | global $sourcedir, $language, $forum_version, $modSettings, $smcFunc; |
1455 | 1545 | |
1456 | - if (empty($modSettings['time_format'])) |
|
1457 | - $modSettings['time_format'] = '%B %d, %Y, %I:%M:%S %p'; |
|
1546 | + if (empty($modSettings['time_format'])) { |
|
1547 | + $modSettings['time_format'] = '%B %d, %Y, %I:%M:%S %p'; |
|
1548 | + } |
|
1458 | 1549 | |
1459 | 1550 | // What files do we want to get |
1460 | 1551 | $request = $smcFunc['db_query']('', ' |
@@ -1488,8 +1579,9 @@ discard block |
||
1488 | 1579 | $file_data = fetch_web_data($url); |
1489 | 1580 | |
1490 | 1581 | // If we got an error - give up - the site might be down. |
1491 | - if ($file_data === false) |
|
1492 | - return throw_error(sprintf('Could not retrieve the file %1$s.', $url)); |
|
1582 | + if ($file_data === false) { |
|
1583 | + return throw_error(sprintf('Could not retrieve the file %1$s.', $url)); |
|
1584 | + } |
|
1493 | 1585 | |
1494 | 1586 | // Save the file to the database. |
1495 | 1587 | $smcFunc['db_query']('substring', ' |
@@ -1531,8 +1623,9 @@ discard block |
||
1531 | 1623 | $themeData = array(); |
1532 | 1624 | foreach ($values as $variable => $value) |
1533 | 1625 | { |
1534 | - if (!isset($value) || $value === null) |
|
1535 | - $value = 0; |
|
1626 | + if (!isset($value) || $value === null) { |
|
1627 | + $value = 0; |
|
1628 | + } |
|
1536 | 1629 | |
1537 | 1630 | $themeData[] = array(0, 1, $variable, $value); |
1538 | 1631 | } |
@@ -1561,8 +1654,9 @@ discard block |
||
1561 | 1654 | |
1562 | 1655 | foreach ($values as $variable => $value) |
1563 | 1656 | { |
1564 | - if (empty($modSettings[$value[0]])) |
|
1565 | - continue; |
|
1657 | + if (empty($modSettings[$value[0]])) { |
|
1658 | + continue; |
|
1659 | + } |
|
1566 | 1660 | |
1567 | 1661 | $smcFunc['db_query']('', ' |
1568 | 1662 | INSERT IGNORE INTO {db_prefix}themes |
@@ -1648,19 +1742,21 @@ discard block |
||
1648 | 1742 | set_error_handler( |
1649 | 1743 | function ($errno, $errstr, $errfile, $errline) use ($support_js) |
1650 | 1744 | { |
1651 | - if ($support_js) |
|
1652 | - return true; |
|
1653 | - else |
|
1654 | - echo 'Error: ' . $errstr . ' File: ' . $errfile . ' Line: ' . $errline; |
|
1745 | + if ($support_js) { |
|
1746 | + return true; |
|
1747 | + } else { |
|
1748 | + echo 'Error: ' . $errstr . ' File: ' . $errfile . ' Line: ' . $errline; |
|
1749 | + } |
|
1655 | 1750 | } |
1656 | 1751 | ); |
1657 | 1752 | |
1658 | 1753 | // If we're on MySQL, set {db_collation}; this approach is used throughout upgrade_2-0_mysql.php to set new tables to utf8 |
1659 | 1754 | // Note it is expected to be in the format: ENGINE=MyISAM{$db_collation}; |
1660 | - if ($db_type == 'mysql') |
|
1661 | - $db_collation = ' DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci'; |
|
1662 | - else |
|
1663 | - $db_collation = ''; |
|
1755 | + if ($db_type == 'mysql') { |
|
1756 | + $db_collation = ' DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci'; |
|
1757 | + } else { |
|
1758 | + $db_collation = ''; |
|
1759 | + } |
|
1664 | 1760 | |
1665 | 1761 | $endl = $command_line ? "\n" : '<br>' . "\n"; |
1666 | 1762 | |
@@ -1672,8 +1768,9 @@ discard block |
||
1672 | 1768 | $last_step = ''; |
1673 | 1769 | |
1674 | 1770 | // Make sure all newly created tables will have the proper characters set; this approach is used throughout upgrade_2-1_mysql.php |
1675 | - if (isset($db_character_set) && $db_character_set === 'utf8') |
|
1676 | - $lines = str_replace(') ENGINE=MyISAM;', ') ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;', $lines); |
|
1771 | + if (isset($db_character_set) && $db_character_set === 'utf8') { |
|
1772 | + $lines = str_replace(') ENGINE=MyISAM;', ') ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;', $lines); |
|
1773 | + } |
|
1677 | 1774 | |
1678 | 1775 | // Count the total number of steps within this file - for progress. |
1679 | 1776 | $file_steps = substr_count(implode('', $lines), '---#'); |
@@ -1693,15 +1790,18 @@ discard block |
||
1693 | 1790 | $do_current = $substep >= $_GET['substep']; |
1694 | 1791 | |
1695 | 1792 | // Get rid of any comments in the beginning of the line... |
1696 | - if (substr(trim($line), 0, 2) === '/*') |
|
1697 | - $line = preg_replace('~/\*.+?\*/~', '', $line); |
|
1793 | + if (substr(trim($line), 0, 2) === '/*') { |
|
1794 | + $line = preg_replace('~/\*.+?\*/~', '', $line); |
|
1795 | + } |
|
1698 | 1796 | |
1699 | 1797 | // Always flush. Flush, flush, flush. Flush, flush, flush, flush! FLUSH! |
1700 | - if ($is_debug && !$support_js && $command_line) |
|
1701 | - flush(); |
|
1798 | + if ($is_debug && !$support_js && $command_line) { |
|
1799 | + flush(); |
|
1800 | + } |
|
1702 | 1801 | |
1703 | - if (trim($line) === '') |
|
1704 | - continue; |
|
1802 | + if (trim($line) === '') { |
|
1803 | + continue; |
|
1804 | + } |
|
1705 | 1805 | |
1706 | 1806 | if (trim(substr($line, 0, 3)) === '---') |
1707 | 1807 | { |
@@ -1711,8 +1811,9 @@ discard block |
||
1711 | 1811 | if (trim($current_data) != '' && $type !== '}') |
1712 | 1812 | { |
1713 | 1813 | $upcontext['error_message'] = 'Error in upgrade script - line ' . $line_number . '!' . $endl; |
1714 | - if ($command_line) |
|
1715 | - echo $upcontext['error_message']; |
|
1814 | + if ($command_line) { |
|
1815 | + echo $upcontext['error_message']; |
|
1816 | + } |
|
1716 | 1817 | } |
1717 | 1818 | |
1718 | 1819 | if ($type == ' ') |
@@ -1730,17 +1831,18 @@ discard block |
||
1730 | 1831 | if ($do_current) |
1731 | 1832 | { |
1732 | 1833 | $upcontext['actioned_items'][] = $last_step; |
1733 | - if ($command_line) |
|
1734 | - echo ' * '; |
|
1834 | + if ($command_line) { |
|
1835 | + echo ' * '; |
|
1836 | + } |
|
1735 | 1837 | } |
1736 | - } |
|
1737 | - elseif ($type == '#') |
|
1838 | + } elseif ($type == '#') |
|
1738 | 1839 | { |
1739 | 1840 | $upcontext['step_progress'] += (100 / $upcontext['file_count']) / $file_steps; |
1740 | 1841 | |
1741 | 1842 | $upcontext['current_debug_item_num']++; |
1742 | - if (trim($line) != '---#') |
|
1743 | - $upcontext['current_debug_item_name'] = htmlspecialchars(rtrim(substr($line, 4))); |
|
1843 | + if (trim($line) != '---#') { |
|
1844 | + $upcontext['current_debug_item_name'] = htmlspecialchars(rtrim(substr($line, 4))); |
|
1845 | + } |
|
1744 | 1846 | |
1745 | 1847 | // Have we already done something? |
1746 | 1848 | if (isset($_GET['xml']) && $done_something) |
@@ -1751,34 +1853,36 @@ discard block |
||
1751 | 1853 | |
1752 | 1854 | if ($do_current) |
1753 | 1855 | { |
1754 | - if (trim($line) == '---#' && $command_line) |
|
1755 | - echo ' done.', $endl; |
|
1756 | - elseif ($command_line) |
|
1757 | - echo ' +++ ', rtrim(substr($line, 4)); |
|
1758 | - elseif (trim($line) != '---#') |
|
1856 | + if (trim($line) == '---#' && $command_line) { |
|
1857 | + echo ' done.', $endl; |
|
1858 | + } elseif ($command_line) { |
|
1859 | + echo ' +++ ', rtrim(substr($line, 4)); |
|
1860 | + } elseif (trim($line) != '---#') |
|
1759 | 1861 | { |
1760 | - if ($is_debug) |
|
1761 | - $upcontext['actioned_items'][] = htmlspecialchars(rtrim(substr($line, 4))); |
|
1862 | + if ($is_debug) { |
|
1863 | + $upcontext['actioned_items'][] = htmlspecialchars(rtrim(substr($line, 4))); |
|
1864 | + } |
|
1762 | 1865 | } |
1763 | 1866 | } |
1764 | 1867 | |
1765 | 1868 | if ($substep < $_GET['substep'] && $substep + 1 >= $_GET['substep']) |
1766 | 1869 | { |
1767 | - if ($command_line) |
|
1768 | - echo ' * '; |
|
1769 | - else |
|
1770 | - $upcontext['actioned_items'][] = $last_step; |
|
1870 | + if ($command_line) { |
|
1871 | + echo ' * '; |
|
1872 | + } else { |
|
1873 | + $upcontext['actioned_items'][] = $last_step; |
|
1874 | + } |
|
1771 | 1875 | } |
1772 | 1876 | |
1773 | 1877 | // Small step - only if we're actually doing stuff. |
1774 | - if ($do_current) |
|
1775 | - nextSubstep(++$substep); |
|
1776 | - else |
|
1777 | - $substep++; |
|
1778 | - } |
|
1779 | - elseif ($type == '{') |
|
1780 | - $current_type = 'code'; |
|
1781 | - elseif ($type == '}') |
|
1878 | + if ($do_current) { |
|
1879 | + nextSubstep(++$substep); |
|
1880 | + } else { |
|
1881 | + $substep++; |
|
1882 | + } |
|
1883 | + } elseif ($type == '{') { |
|
1884 | + $current_type = 'code'; |
|
1885 | + } elseif ($type == '}') |
|
1782 | 1886 | { |
1783 | 1887 | $current_type = 'sql'; |
1784 | 1888 | |
@@ -1791,8 +1895,9 @@ discard block |
||
1791 | 1895 | if (eval('global $db_prefix, $modSettings, $smcFunc; ' . $current_data) === false) |
1792 | 1896 | { |
1793 | 1897 | $upcontext['error_message'] = 'Error in upgrade script ' . basename($filename) . ' on line ' . $line_number . '!' . $endl; |
1794 | - if ($command_line) |
|
1795 | - echo $upcontext['error_message']; |
|
1898 | + if ($command_line) { |
|
1899 | + echo $upcontext['error_message']; |
|
1900 | + } |
|
1796 | 1901 | } |
1797 | 1902 | |
1798 | 1903 | // Done with code! |
@@ -1872,8 +1977,9 @@ discard block |
||
1872 | 1977 | $db_unbuffered = false; |
1873 | 1978 | |
1874 | 1979 | // Failure?! |
1875 | - if ($result !== false) |
|
1876 | - return $result; |
|
1980 | + if ($result !== false) { |
|
1981 | + return $result; |
|
1982 | + } |
|
1877 | 1983 | |
1878 | 1984 | $db_error_message = $smcFunc['db_error']($db_connection); |
1879 | 1985 | // If MySQL we do something more clever. |
@@ -1901,54 +2007,61 @@ discard block |
||
1901 | 2007 | { |
1902 | 2008 | mysqli_query($db_connection, 'REPAIR TABLE `' . $match[1] . '`'); |
1903 | 2009 | $result = mysqli_query($db_connection, $string); |
1904 | - if ($result !== false) |
|
1905 | - return $result; |
|
2010 | + if ($result !== false) { |
|
2011 | + return $result; |
|
2012 | + } |
|
1906 | 2013 | } |
1907 | - } |
|
1908 | - elseif ($mysqli_errno == 2013) |
|
2014 | + } elseif ($mysqli_errno == 2013) |
|
1909 | 2015 | { |
1910 | 2016 | $db_connection = mysqli_connect($db_server, $db_user, $db_passwd); |
1911 | 2017 | mysqli_select_db($db_connection, $db_name); |
1912 | 2018 | if ($db_connection) |
1913 | 2019 | { |
1914 | 2020 | $result = mysqli_query($db_connection, $string); |
1915 | - if ($result !== false) |
|
1916 | - return $result; |
|
2021 | + if ($result !== false) { |
|
2022 | + return $result; |
|
2023 | + } |
|
1917 | 2024 | } |
1918 | 2025 | } |
1919 | 2026 | // Duplicate column name... should be okay ;). |
1920 | - elseif (in_array($mysqli_errno, array(1060, 1061, 1068, 1091))) |
|
1921 | - return false; |
|
2027 | + elseif (in_array($mysqli_errno, array(1060, 1061, 1068, 1091))) { |
|
2028 | + return false; |
|
2029 | + } |
|
1922 | 2030 | // Duplicate insert... make sure it's the proper type of query ;). |
1923 | - elseif (in_array($mysqli_errno, array(1054, 1062, 1146)) && $error_query) |
|
1924 | - return false; |
|
2031 | + elseif (in_array($mysqli_errno, array(1054, 1062, 1146)) && $error_query) { |
|
2032 | + return false; |
|
2033 | + } |
|
1925 | 2034 | // Creating an index on a non-existent column. |
1926 | - elseif ($mysqli_errno == 1072) |
|
1927 | - return false; |
|
1928 | - elseif ($mysqli_errno == 1050 && substr(trim($string), 0, 12) == 'RENAME TABLE') |
|
1929 | - return false; |
|
2035 | + elseif ($mysqli_errno == 1072) { |
|
2036 | + return false; |
|
2037 | + } elseif ($mysqli_errno == 1050 && substr(trim($string), 0, 12) == 'RENAME TABLE') { |
|
2038 | + return false; |
|
2039 | + } |
|
1930 | 2040 | } |
1931 | 2041 | // If a table already exists don't go potty. |
1932 | 2042 | else |
1933 | 2043 | { |
1934 | 2044 | if (in_array(substr(trim($string), 0, 8), array('CREATE T', 'CREATE S', 'DROP TABL', 'ALTER TA', 'CREATE I', 'CREATE U'))) |
1935 | 2045 | { |
1936 | - if (strpos($db_error_message, 'exist') !== false) |
|
1937 | - return true; |
|
1938 | - } |
|
1939 | - elseif (strpos(trim($string), 'INSERT ') !== false) |
|
2046 | + if (strpos($db_error_message, 'exist') !== false) { |
|
2047 | + return true; |
|
2048 | + } |
|
2049 | + } elseif (strpos(trim($string), 'INSERT ') !== false) |
|
1940 | 2050 | { |
1941 | - if (strpos($db_error_message, 'duplicate') !== false) |
|
1942 | - return true; |
|
2051 | + if (strpos($db_error_message, 'duplicate') !== false) { |
|
2052 | + return true; |
|
2053 | + } |
|
1943 | 2054 | } |
1944 | 2055 | } |
1945 | 2056 | |
1946 | 2057 | // Get the query string so we pass everything. |
1947 | 2058 | $query_string = ''; |
1948 | - foreach ($_GET as $k => $v) |
|
1949 | - $query_string .= ';' . $k . '=' . $v; |
|
1950 | - if (strlen($query_string) != 0) |
|
1951 | - $query_string = '?' . substr($query_string, 1); |
|
2059 | + foreach ($_GET as $k => $v) { |
|
2060 | + $query_string .= ';' . $k . '=' . $v; |
|
2061 | + } |
|
2062 | + if (strlen($query_string) != 0) { |
|
2063 | + $query_string = '?' . substr($query_string, 1); |
|
2064 | + } |
|
1952 | 2065 | |
1953 | 2066 | if ($command_line) |
1954 | 2067 | { |
@@ -2003,16 +2116,18 @@ discard block |
||
2003 | 2116 | { |
2004 | 2117 | $found |= 1; |
2005 | 2118 | // Do some checks on the data if we have it set. |
2006 | - if (isset($change['col_type'])) |
|
2007 | - $found &= $change['col_type'] === $column['type']; |
|
2008 | - if (isset($change['null_allowed'])) |
|
2009 | - $found &= $column['null'] == $change['null_allowed']; |
|
2010 | - if (isset($change['default'])) |
|
2011 | - $found &= $change['default'] === $column['default']; |
|
2119 | + if (isset($change['col_type'])) { |
|
2120 | + $found &= $change['col_type'] === $column['type']; |
|
2121 | + } |
|
2122 | + if (isset($change['null_allowed'])) { |
|
2123 | + $found &= $column['null'] == $change['null_allowed']; |
|
2124 | + } |
|
2125 | + if (isset($change['default'])) { |
|
2126 | + $found &= $change['default'] === $column['default']; |
|
2127 | + } |
|
2012 | 2128 | } |
2013 | 2129 | } |
2014 | - } |
|
2015 | - elseif ($change['type'] === 'index') |
|
2130 | + } elseif ($change['type'] === 'index') |
|
2016 | 2131 | { |
2017 | 2132 | $request = upgrade_query(' |
2018 | 2133 | SHOW INDEX |
@@ -2021,9 +2136,10 @@ discard block |
||
2021 | 2136 | { |
2022 | 2137 | $cur_index = array(); |
2023 | 2138 | |
2024 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
2025 | - if ($row['Key_name'] === $change['name']) |
|
2139 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2140 | + if ($row['Key_name'] === $change['name']) |
|
2026 | 2141 | $cur_index[(int) $row['Seq_in_index']] = $row['Column_name']; |
2142 | + } |
|
2027 | 2143 | |
2028 | 2144 | ksort($cur_index, SORT_NUMERIC); |
2029 | 2145 | $found = array_values($cur_index) === $change['target_columns']; |
@@ -2033,14 +2149,17 @@ discard block |
||
2033 | 2149 | } |
2034 | 2150 | |
2035 | 2151 | // If we're trying to add and it's added, we're done. |
2036 | - if ($found && in_array($change['method'], array('add', 'change'))) |
|
2037 | - return true; |
|
2152 | + if ($found && in_array($change['method'], array('add', 'change'))) { |
|
2153 | + return true; |
|
2154 | + } |
|
2038 | 2155 | // Otherwise if we're removing and it wasn't found we're also done. |
2039 | - elseif (!$found && in_array($change['method'], array('remove', 'change_remove'))) |
|
2040 | - return true; |
|
2156 | + elseif (!$found && in_array($change['method'], array('remove', 'change_remove'))) { |
|
2157 | + return true; |
|
2158 | + } |
|
2041 | 2159 | // Otherwise is it just a test? |
2042 | - elseif ($is_test) |
|
2043 | - return false; |
|
2160 | + elseif ($is_test) { |
|
2161 | + return false; |
|
2162 | + } |
|
2044 | 2163 | |
2045 | 2164 | // Not found it yet? Bummer! How about we see if we're currently doing it? |
2046 | 2165 | $running = false; |
@@ -2051,8 +2170,9 @@ discard block |
||
2051 | 2170 | SHOW FULL PROCESSLIST'); |
2052 | 2171 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
2053 | 2172 | { |
2054 | - if (strpos($row['Info'], 'ALTER TABLE ' . $db_prefix . $change['table']) !== false && strpos($row['Info'], $change['text']) !== false) |
|
2055 | - $found = true; |
|
2173 | + if (strpos($row['Info'], 'ALTER TABLE ' . $db_prefix . $change['table']) !== false && strpos($row['Info'], $change['text']) !== false) { |
|
2174 | + $found = true; |
|
2175 | + } |
|
2056 | 2176 | } |
2057 | 2177 | |
2058 | 2178 | // Can't find it? Then we need to run it fools! |
@@ -2064,8 +2184,9 @@ discard block |
||
2064 | 2184 | ALTER TABLE ' . $db_prefix . $change['table'] . ' |
2065 | 2185 | ' . $change['text'], true) !== false; |
2066 | 2186 | |
2067 | - if (!$success) |
|
2068 | - return false; |
|
2187 | + if (!$success) { |
|
2188 | + return false; |
|
2189 | + } |
|
2069 | 2190 | |
2070 | 2191 | // Return |
2071 | 2192 | $running = true; |
@@ -2107,8 +2228,9 @@ discard block |
||
2107 | 2228 | 'db_error_skip' => true, |
2108 | 2229 | ) |
2109 | 2230 | ); |
2110 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
2111 | - die('Unable to find column ' . $change['column'] . ' inside table ' . $db_prefix . $change['table']); |
|
2231 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
2232 | + die('Unable to find column ' . $change['column'] . ' inside table ' . $db_prefix . $change['table']); |
|
2233 | + } |
|
2112 | 2234 | $table_row = $smcFunc['db_fetch_assoc']($request); |
2113 | 2235 | $smcFunc['db_free_result']($request); |
2114 | 2236 | |
@@ -2130,18 +2252,19 @@ discard block |
||
2130 | 2252 | ) |
2131 | 2253 | ); |
2132 | 2254 | // No results? Just forget it all together. |
2133 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
2134 | - unset($table_row['Collation']); |
|
2135 | - else |
|
2136 | - $collation_info = $smcFunc['db_fetch_assoc']($request); |
|
2255 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
2256 | + unset($table_row['Collation']); |
|
2257 | + } else { |
|
2258 | + $collation_info = $smcFunc['db_fetch_assoc']($request); |
|
2259 | + } |
|
2137 | 2260 | $smcFunc['db_free_result']($request); |
2138 | 2261 | } |
2139 | 2262 | |
2140 | 2263 | if ($column_fix) |
2141 | 2264 | { |
2142 | 2265 | // Make sure there are no NULL's left. |
2143 | - if ($null_fix) |
|
2144 | - $smcFunc['db_query']('', ' |
|
2266 | + if ($null_fix) { |
|
2267 | + $smcFunc['db_query']('', ' |
|
2145 | 2268 | UPDATE {db_prefix}' . $change['table'] . ' |
2146 | 2269 | SET ' . $change['column'] . ' = {string:default} |
2147 | 2270 | WHERE ' . $change['column'] . ' IS NULL', |
@@ -2150,6 +2273,7 @@ discard block |
||
2150 | 2273 | 'db_error_skip' => true, |
2151 | 2274 | ) |
2152 | 2275 | ); |
2276 | + } |
|
2153 | 2277 | |
2154 | 2278 | // Do the actual alteration. |
2155 | 2279 | $smcFunc['db_query']('', ' |
@@ -2178,8 +2302,9 @@ discard block |
||
2178 | 2302 | } |
2179 | 2303 | |
2180 | 2304 | // Not a column we need to check on? |
2181 | - if (!in_array($change['name'], array('memberGroups', 'passwordSalt'))) |
|
2182 | - return; |
|
2305 | + if (!in_array($change['name'], array('memberGroups', 'passwordSalt'))) { |
|
2306 | + return; |
|
2307 | + } |
|
2183 | 2308 | |
2184 | 2309 | // Break it up you (six|seven). |
2185 | 2310 | $temp = explode(' ', str_replace('NOT NULL', 'NOT_NULL', $change['text'])); |
@@ -2198,13 +2323,13 @@ discard block |
||
2198 | 2323 | 'new_name' => $temp[2], |
2199 | 2324 | )); |
2200 | 2325 | // !!! This doesn't technically work because we don't pass request into it, but it hasn't broke anything yet. |
2201 | - if ($smcFunc['db_num_rows'] != 1) |
|
2202 | - return; |
|
2326 | + if ($smcFunc['db_num_rows'] != 1) { |
|
2327 | + return; |
|
2328 | + } |
|
2203 | 2329 | |
2204 | 2330 | list (, $current_type) = $smcFunc['db_fetch_assoc']($request); |
2205 | 2331 | $smcFunc['db_free_result']($request); |
2206 | - } |
|
2207 | - else |
|
2332 | + } else |
|
2208 | 2333 | { |
2209 | 2334 | // Do this the old fashion, sure method way. |
2210 | 2335 | $request = $smcFunc['db_query']('', ' |
@@ -2215,21 +2340,24 @@ discard block |
||
2215 | 2340 | )); |
2216 | 2341 | // Mayday! |
2217 | 2342 | // !!! This doesn't technically work because we don't pass request into it, but it hasn't broke anything yet. |
2218 | - if ($smcFunc['db_num_rows'] == 0) |
|
2219 | - return; |
|
2343 | + if ($smcFunc['db_num_rows'] == 0) { |
|
2344 | + return; |
|
2345 | + } |
|
2220 | 2346 | |
2221 | 2347 | // Oh where, oh where has my little field gone. Oh where can it be... |
2222 | - while ($row = $smcFunc['db_query']($request)) |
|
2223 | - if ($row['Field'] == $temp[1] || $row['Field'] == $temp[2]) |
|
2348 | + while ($row = $smcFunc['db_query']($request)) { |
|
2349 | + if ($row['Field'] == $temp[1] || $row['Field'] == $temp[2]) |
|
2224 | 2350 | { |
2225 | 2351 | $current_type = $row['Type']; |
2352 | + } |
|
2226 | 2353 | break; |
2227 | 2354 | } |
2228 | 2355 | } |
2229 | 2356 | |
2230 | 2357 | // If this doesn't match, the column may of been altered for a reason. |
2231 | - if (trim($current_type) != trim($temp[3])) |
|
2232 | - $temp[3] = $current_type; |
|
2358 | + if (trim($current_type) != trim($temp[3])) { |
|
2359 | + $temp[3] = $current_type; |
|
2360 | + } |
|
2233 | 2361 | |
2234 | 2362 | // Piece this back together. |
2235 | 2363 | $change['text'] = str_replace('NOT_NULL', 'NOT NULL', implode(' ', $temp)); |
@@ -2241,8 +2369,9 @@ discard block |
||
2241 | 2369 | global $start_time, $timeLimitThreshold, $command_line, $custom_warning; |
2242 | 2370 | global $step_progress, $is_debug, $upcontext; |
2243 | 2371 | |
2244 | - if ($_GET['substep'] < $substep) |
|
2245 | - $_GET['substep'] = $substep; |
|
2372 | + if ($_GET['substep'] < $substep) { |
|
2373 | + $_GET['substep'] = $substep; |
|
2374 | + } |
|
2246 | 2375 | |
2247 | 2376 | if ($command_line) |
2248 | 2377 | { |
@@ -2255,29 +2384,33 @@ discard block |
||
2255 | 2384 | } |
2256 | 2385 | |
2257 | 2386 | @set_time_limit(300); |
2258 | - if (function_exists('apache_reset_timeout')) |
|
2259 | - @apache_reset_timeout(); |
|
2387 | + if (function_exists('apache_reset_timeout')) { |
|
2388 | + @apache_reset_timeout(); |
|
2389 | + } |
|
2260 | 2390 | |
2261 | - if (time() - $start_time <= $timeLimitThreshold) |
|
2262 | - return; |
|
2391 | + if (time() - $start_time <= $timeLimitThreshold) { |
|
2392 | + return; |
|
2393 | + } |
|
2263 | 2394 | |
2264 | 2395 | // Do we have some custom step progress stuff? |
2265 | 2396 | if (!empty($step_progress)) |
2266 | 2397 | { |
2267 | 2398 | $upcontext['substep_progress'] = 0; |
2268 | 2399 | $upcontext['substep_progress_name'] = $step_progress['name']; |
2269 | - if ($step_progress['current'] > $step_progress['total']) |
|
2270 | - $upcontext['substep_progress'] = 99.9; |
|
2271 | - else |
|
2272 | - $upcontext['substep_progress'] = ($step_progress['current'] / $step_progress['total']) * 100; |
|
2400 | + if ($step_progress['current'] > $step_progress['total']) { |
|
2401 | + $upcontext['substep_progress'] = 99.9; |
|
2402 | + } else { |
|
2403 | + $upcontext['substep_progress'] = ($step_progress['current'] / $step_progress['total']) * 100; |
|
2404 | + } |
|
2273 | 2405 | |
2274 | 2406 | // Make it nicely rounded. |
2275 | 2407 | $upcontext['substep_progress'] = round($upcontext['substep_progress'], 1); |
2276 | 2408 | } |
2277 | 2409 | |
2278 | 2410 | // If this is XML we just exit right away! |
2279 | - if (isset($_GET['xml'])) |
|
2280 | - return upgradeExit(); |
|
2411 | + if (isset($_GET['xml'])) { |
|
2412 | + return upgradeExit(); |
|
2413 | + } |
|
2281 | 2414 | |
2282 | 2415 | // We're going to pause after this! |
2283 | 2416 | $upcontext['pause'] = true; |
@@ -2285,13 +2418,15 @@ discard block |
||
2285 | 2418 | $upcontext['query_string'] = ''; |
2286 | 2419 | foreach ($_GET as $k => $v) |
2287 | 2420 | { |
2288 | - if ($k != 'data' && $k != 'substep' && $k != 'step') |
|
2289 | - $upcontext['query_string'] .= ';' . $k . '=' . $v; |
|
2421 | + if ($k != 'data' && $k != 'substep' && $k != 'step') { |
|
2422 | + $upcontext['query_string'] .= ';' . $k . '=' . $v; |
|
2423 | + } |
|
2290 | 2424 | } |
2291 | 2425 | |
2292 | 2426 | // Custom warning? |
2293 | - if (!empty($custom_warning)) |
|
2294 | - $upcontext['custom_warning'] = $custom_warning; |
|
2427 | + if (!empty($custom_warning)) { |
|
2428 | + $upcontext['custom_warning'] = $custom_warning; |
|
2429 | + } |
|
2295 | 2430 | |
2296 | 2431 | upgradeExit(); |
2297 | 2432 | } |
@@ -2306,25 +2441,26 @@ discard block |
||
2306 | 2441 | ob_implicit_flush(true); |
2307 | 2442 | @set_time_limit(600); |
2308 | 2443 | |
2309 | - if (!isset($_SERVER['argv'])) |
|
2310 | - $_SERVER['argv'] = array(); |
|
2444 | + if (!isset($_SERVER['argv'])) { |
|
2445 | + $_SERVER['argv'] = array(); |
|
2446 | + } |
|
2311 | 2447 | $_GET['maint'] = 1; |
2312 | 2448 | |
2313 | 2449 | foreach ($_SERVER['argv'] as $i => $arg) |
2314 | 2450 | { |
2315 | - if (preg_match('~^--language=(.+)$~', $arg, $match) != 0) |
|
2316 | - $_GET['lang'] = $match[1]; |
|
2317 | - elseif (preg_match('~^--path=(.+)$~', $arg) != 0) |
|
2318 | - continue; |
|
2319 | - elseif ($arg == '--no-maintenance') |
|
2320 | - $_GET['maint'] = 0; |
|
2321 | - elseif ($arg == '--debug') |
|
2322 | - $is_debug = true; |
|
2323 | - elseif ($arg == '--backup') |
|
2324 | - $_POST['backup'] = 1; |
|
2325 | - elseif ($arg == '--template' && (file_exists($boarddir . '/template.php') || file_exists($boarddir . '/template.html') && !file_exists($modSettings['theme_dir'] . '/converted'))) |
|
2326 | - $_GET['conv'] = 1; |
|
2327 | - elseif ($i != 0) |
|
2451 | + if (preg_match('~^--language=(.+)$~', $arg, $match) != 0) { |
|
2452 | + $_GET['lang'] = $match[1]; |
|
2453 | + } elseif (preg_match('~^--path=(.+)$~', $arg) != 0) { |
|
2454 | + continue; |
|
2455 | + } elseif ($arg == '--no-maintenance') { |
|
2456 | + $_GET['maint'] = 0; |
|
2457 | + } elseif ($arg == '--debug') { |
|
2458 | + $is_debug = true; |
|
2459 | + } elseif ($arg == '--backup') { |
|
2460 | + $_POST['backup'] = 1; |
|
2461 | + } elseif ($arg == '--template' && (file_exists($boarddir . '/template.php') || file_exists($boarddir . '/template.html') && !file_exists($modSettings['theme_dir'] . '/converted'))) { |
|
2462 | + $_GET['conv'] = 1; |
|
2463 | + } elseif ($i != 0) |
|
2328 | 2464 | { |
2329 | 2465 | echo 'SMF Command-line Upgrader |
2330 | 2466 | Usage: /path/to/php -f ' . basename(__FILE__) . ' -- [OPTION]... |
@@ -2338,10 +2474,12 @@ discard block |
||
2338 | 2474 | } |
2339 | 2475 | } |
2340 | 2476 | |
2341 | - if (!php_version_check()) |
|
2342 | - print_error('Error: PHP ' . PHP_VERSION . ' does not match version requirements.', true); |
|
2343 | - if (!db_version_check()) |
|
2344 | - print_error('Error: ' . $databases[$db_type]['name'] . ' ' . $databases[$db_type]['version'] . ' does not match minimum requirements.', true); |
|
2477 | + if (!php_version_check()) { |
|
2478 | + print_error('Error: PHP ' . PHP_VERSION . ' does not match version requirements.', true); |
|
2479 | + } |
|
2480 | + if (!db_version_check()) { |
|
2481 | + print_error('Error: ' . $databases[$db_type]['name'] . ' ' . $databases[$db_type]['version'] . ' does not match minimum requirements.', true); |
|
2482 | + } |
|
2345 | 2483 | |
2346 | 2484 | // Do some checks to make sure they have proper privileges |
2347 | 2485 | db_extend('packages'); |
@@ -2356,39 +2494,45 @@ discard block |
||
2356 | 2494 | $drop = $smcFunc['db_drop_table']('{db_prefix}priv_check'); |
2357 | 2495 | |
2358 | 2496 | // Sorry... we need CREATE, ALTER and DROP |
2359 | - if (!$create || !$alter || !$drop) |
|
2360 | - 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); |
|
2497 | + if (!$create || !$alter || !$drop) { |
|
2498 | + 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); |
|
2499 | + } |
|
2361 | 2500 | |
2362 | 2501 | $check = @file_exists($modSettings['theme_dir'] . '/index.template.php') |
2363 | 2502 | && @file_exists($sourcedir . '/QueryString.php') |
2364 | 2503 | && @file_exists($sourcedir . '/ManageBoards.php'); |
2365 | - if (!$check && !isset($modSettings['smfVersion'])) |
|
2366 | - print_error('Error: Some files are missing or out-of-date.', true); |
|
2504 | + if (!$check && !isset($modSettings['smfVersion'])) { |
|
2505 | + print_error('Error: Some files are missing or out-of-date.', true); |
|
2506 | + } |
|
2367 | 2507 | |
2368 | 2508 | // Do a quick version spot check. |
2369 | 2509 | $temp = substr(@implode('', @file($boarddir . '/index.php')), 0, 4096); |
2370 | 2510 | preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $temp, $match); |
2371 | - if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) |
|
2372 | - print_error('Error: Some files have not yet been updated properly.'); |
|
2511 | + if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) { |
|
2512 | + print_error('Error: Some files have not yet been updated properly.'); |
|
2513 | + } |
|
2373 | 2514 | |
2374 | 2515 | // Make sure Settings.php is writable. |
2375 | 2516 | quickFileWritable($boarddir . '/Settings.php'); |
2376 | - if (!is_writable($boarddir . '/Settings.php')) |
|
2377 | - print_error('Error: Unable to obtain write access to "Settings.php".', true); |
|
2517 | + if (!is_writable($boarddir . '/Settings.php')) { |
|
2518 | + print_error('Error: Unable to obtain write access to "Settings.php".', true); |
|
2519 | + } |
|
2378 | 2520 | |
2379 | 2521 | // Make sure Settings_bak.php is writable. |
2380 | 2522 | quickFileWritable($boarddir . '/Settings_bak.php'); |
2381 | - if (!is_writable($boarddir . '/Settings_bak.php')) |
|
2382 | - print_error('Error: Unable to obtain write access to "Settings_bak.php".'); |
|
2523 | + if (!is_writable($boarddir . '/Settings_bak.php')) { |
|
2524 | + print_error('Error: Unable to obtain write access to "Settings_bak.php".'); |
|
2525 | + } |
|
2383 | 2526 | |
2384 | 2527 | // Make sure db_last_error.php is writable. |
2385 | 2528 | quickFileWritable($boarddir . '/db_last_error.php'); |
2386 | - if (!is_writable($boarddir . '/db_last_error.php')) |
|
2387 | - print_error('Error: Unable to obtain write access to "db_last_error.php".'); |
|
2529 | + if (!is_writable($boarddir . '/db_last_error.php')) { |
|
2530 | + print_error('Error: Unable to obtain write access to "db_last_error.php".'); |
|
2531 | + } |
|
2388 | 2532 | |
2389 | - if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) |
|
2390 | - print_error('Error: Unable to obtain write access to "agreement.txt".'); |
|
2391 | - elseif (isset($modSettings['agreement'])) |
|
2533 | + if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) { |
|
2534 | + print_error('Error: Unable to obtain write access to "agreement.txt".'); |
|
2535 | + } elseif (isset($modSettings['agreement'])) |
|
2392 | 2536 | { |
2393 | 2537 | $fp = fopen($boarddir . '/agreement.txt', 'w'); |
2394 | 2538 | fwrite($fp, $modSettings['agreement']); |
@@ -2398,31 +2542,36 @@ discard block |
||
2398 | 2542 | // Make sure Themes is writable. |
2399 | 2543 | quickFileWritable($modSettings['theme_dir']); |
2400 | 2544 | |
2401 | - if (!is_writable($modSettings['theme_dir']) && !isset($modSettings['smfVersion'])) |
|
2402 | - print_error('Error: Unable to obtain write access to "Themes".'); |
|
2545 | + if (!is_writable($modSettings['theme_dir']) && !isset($modSettings['smfVersion'])) { |
|
2546 | + print_error('Error: Unable to obtain write access to "Themes".'); |
|
2547 | + } |
|
2403 | 2548 | |
2404 | 2549 | // Make sure cache directory exists and is writable! |
2405 | 2550 | $cachedir_temp = empty($cachedir) ? $boarddir . '/cache' : $cachedir; |
2406 | - if (!file_exists($cachedir_temp)) |
|
2407 | - @mkdir($cachedir_temp); |
|
2551 | + if (!file_exists($cachedir_temp)) { |
|
2552 | + @mkdir($cachedir_temp); |
|
2553 | + } |
|
2408 | 2554 | |
2409 | 2555 | // Make sure the cache temp dir is writable. |
2410 | 2556 | quickFileWritable($cachedir_temp); |
2411 | 2557 | |
2412 | - if (!is_writable($cachedir_temp)) |
|
2413 | - print_error('Error: Unable to obtain write access to "cache".', true); |
|
2558 | + if (!is_writable($cachedir_temp)) { |
|
2559 | + print_error('Error: Unable to obtain write access to "cache".', true); |
|
2560 | + } |
|
2414 | 2561 | |
2415 | - if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) |
|
2416 | - print_error('Error: Unable to find language files!', true); |
|
2417 | - else |
|
2562 | + if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) { |
|
2563 | + print_error('Error: Unable to find language files!', true); |
|
2564 | + } else |
|
2418 | 2565 | { |
2419 | 2566 | $temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php')), 0, 4096); |
2420 | 2567 | preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match); |
2421 | 2568 | |
2422 | - if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) |
|
2423 | - print_error('Error: Language files out of date.', true); |
|
2424 | - if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) |
|
2425 | - print_error('Error: Install language is missing for selected language.', true); |
|
2569 | + if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) { |
|
2570 | + print_error('Error: Language files out of date.', true); |
|
2571 | + } |
|
2572 | + if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) { |
|
2573 | + print_error('Error: Install language is missing for selected language.', true); |
|
2574 | + } |
|
2426 | 2575 | |
2427 | 2576 | // Otherwise include it! |
2428 | 2577 | require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
@@ -2441,8 +2590,9 @@ discard block |
||
2441 | 2590 | global $upcontext, $db_character_set, $sourcedir, $smcFunc, $modSettings, $language, $db_prefix, $db_type, $command_line, $support_js; |
2442 | 2591 | |
2443 | 2592 | // Done it already? |
2444 | - if (!empty($_POST['utf8_done'])) |
|
2445 | - return true; |
|
2593 | + if (!empty($_POST['utf8_done'])) { |
|
2594 | + return true; |
|
2595 | + } |
|
2446 | 2596 | |
2447 | 2597 | // First make sure they aren't already on UTF-8 before we go anywhere... |
2448 | 2598 | if ($db_type == 'postgresql' || ($db_character_set === 'utf8' && !empty($modSettings['global_character_set']) && $modSettings['global_character_set'] === 'UTF-8')) |
@@ -2455,8 +2605,7 @@ discard block |
||
2455 | 2605 | ); |
2456 | 2606 | |
2457 | 2607 | return true; |
2458 | - } |
|
2459 | - else |
|
2608 | + } else |
|
2460 | 2609 | { |
2461 | 2610 | $upcontext['page_title'] = 'Converting to UTF8'; |
2462 | 2611 | $upcontext['sub_template'] = isset($_GET['xml']) ? 'convert_xml' : 'convert_utf8'; |
@@ -2500,8 +2649,9 @@ discard block |
||
2500 | 2649 | ) |
2501 | 2650 | ); |
2502 | 2651 | $db_charsets = array(); |
2503 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
2504 | - $db_charsets[] = $row['Charset']; |
|
2652 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2653 | + $db_charsets[] = $row['Charset']; |
|
2654 | + } |
|
2505 | 2655 | |
2506 | 2656 | $smcFunc['db_free_result']($request); |
2507 | 2657 | |
@@ -2537,13 +2687,15 @@ discard block |
||
2537 | 2687 | // If there's a fulltext index, we need to drop it first... |
2538 | 2688 | if ($request !== false || $smcFunc['db_num_rows']($request) != 0) |
2539 | 2689 | { |
2540 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
2541 | - if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT')) |
|
2690 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2691 | + if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT')) |
|
2542 | 2692 | $upcontext['fulltext_index'][] = $row['Key_name']; |
2693 | + } |
|
2543 | 2694 | $smcFunc['db_free_result']($request); |
2544 | 2695 | |
2545 | - if (isset($upcontext['fulltext_index'])) |
|
2546 | - $upcontext['fulltext_index'] = array_unique($upcontext['fulltext_index']); |
|
2696 | + if (isset($upcontext['fulltext_index'])) { |
|
2697 | + $upcontext['fulltext_index'] = array_unique($upcontext['fulltext_index']); |
|
2698 | + } |
|
2547 | 2699 | } |
2548 | 2700 | |
2549 | 2701 | // Drop it and make a note... |
@@ -2733,8 +2885,9 @@ discard block |
||
2733 | 2885 | $replace = '%field%'; |
2734 | 2886 | |
2735 | 2887 | // Build a huge REPLACE statement... |
2736 | - foreach ($translation_tables[$upcontext['charset_detected']] as $from => $to) |
|
2737 | - $replace = 'REPLACE(' . $replace . ', ' . $from . ', ' . $to . ')'; |
|
2888 | + foreach ($translation_tables[$upcontext['charset_detected']] as $from => $to) { |
|
2889 | + $replace = 'REPLACE(' . $replace . ', ' . $from . ', ' . $to . ')'; |
|
2890 | + } |
|
2738 | 2891 | } |
2739 | 2892 | |
2740 | 2893 | // Get a list of table names ahead of time... This makes it easier to set our substep and such |
@@ -2744,9 +2897,10 @@ discard block |
||
2744 | 2897 | $upcontext['table_count'] = count($queryTables); |
2745 | 2898 | |
2746 | 2899 | // What ones have we already done? |
2747 | - foreach ($queryTables as $id => $table) |
|
2748 | - if ($id < $_GET['substep']) |
|
2900 | + foreach ($queryTables as $id => $table) { |
|
2901 | + if ($id < $_GET['substep']) |
|
2749 | 2902 | $upcontext['previous_tables'][] = $table; |
2903 | + } |
|
2750 | 2904 | |
2751 | 2905 | $upcontext['cur_table_num'] = $_GET['substep']; |
2752 | 2906 | $upcontext['cur_table_name'] = str_replace($db_prefix, '', $queryTables[$_GET['substep']]); |
@@ -2783,8 +2937,9 @@ discard block |
||
2783 | 2937 | nextSubstep($substep); |
2784 | 2938 | |
2785 | 2939 | // Just to make sure it doesn't time out. |
2786 | - if (function_exists('apache_reset_timeout')) |
|
2787 | - @apache_reset_timeout(); |
|
2940 | + if (function_exists('apache_reset_timeout')) { |
|
2941 | + @apache_reset_timeout(); |
|
2942 | + } |
|
2788 | 2943 | |
2789 | 2944 | $table_charsets = array(); |
2790 | 2945 | |
@@ -2807,8 +2962,9 @@ discard block |
||
2807 | 2962 | |
2808 | 2963 | // Build structure of columns to operate on organized by charset; only operate on columns not yet utf8 |
2809 | 2964 | if ($charset != 'utf8') { |
2810 | - if (!isset($table_charsets[$charset])) |
|
2811 | - $table_charsets[$charset] = array(); |
|
2965 | + if (!isset($table_charsets[$charset])) { |
|
2966 | + $table_charsets[$charset] = array(); |
|
2967 | + } |
|
2812 | 2968 | |
2813 | 2969 | $table_charsets[$charset][] = $column_info; |
2814 | 2970 | } |
@@ -2849,10 +3005,11 @@ discard block |
||
2849 | 3005 | if (isset($translation_tables[$upcontext['charset_detected']])) |
2850 | 3006 | { |
2851 | 3007 | $update = ''; |
2852 | - foreach ($table_charsets as $charset => $columns) |
|
2853 | - foreach ($columns as $column) |
|
3008 | + foreach ($table_charsets as $charset => $columns) { |
|
3009 | + foreach ($columns as $column) |
|
2854 | 3010 | $update .= ' |
2855 | 3011 | ' . $column['Field'] . ' = ' . strtr($replace, array('%field%' => $column['Field'])) . ','; |
3012 | + } |
|
2856 | 3013 | |
2857 | 3014 | $smcFunc['db_query']('', ' |
2858 | 3015 | UPDATE {raw:table_name} |
@@ -2877,8 +3034,9 @@ discard block |
||
2877 | 3034 | // Now do the actual conversion (if still needed). |
2878 | 3035 | if ($charsets[$upcontext['charset_detected']] !== 'utf8') |
2879 | 3036 | { |
2880 | - if ($command_line) |
|
2881 | - echo 'Converting table ' . $table_info['Name'] . ' to UTF-8...'; |
|
3037 | + if ($command_line) { |
|
3038 | + echo 'Converting table ' . $table_info['Name'] . ' to UTF-8...'; |
|
3039 | + } |
|
2882 | 3040 | |
2883 | 3041 | $smcFunc['db_query']('', ' |
2884 | 3042 | ALTER TABLE {raw:table_name} |
@@ -2888,12 +3046,14 @@ discard block |
||
2888 | 3046 | ) |
2889 | 3047 | ); |
2890 | 3048 | |
2891 | - if ($command_line) |
|
2892 | - echo " done.\n"; |
|
3049 | + if ($command_line) { |
|
3050 | + echo " done.\n"; |
|
3051 | + } |
|
2893 | 3052 | } |
2894 | 3053 | // If this is XML to keep it nice for the user do one table at a time anyway! |
2895 | - if (isset($_GET['xml']) && $upcontext['cur_table_num'] < $upcontext['table_count']) |
|
2896 | - return upgradeExit(); |
|
3054 | + if (isset($_GET['xml']) && $upcontext['cur_table_num'] < $upcontext['table_count']) { |
|
3055 | + return upgradeExit(); |
|
3056 | + } |
|
2897 | 3057 | } |
2898 | 3058 | |
2899 | 3059 | $prev_charset = empty($translation_tables[$upcontext['charset_detected']]) ? $charsets[$upcontext['charset_detected']] : $translation_tables[$upcontext['charset_detected']]; |
@@ -2922,8 +3082,8 @@ discard block |
||
2922 | 3082 | ); |
2923 | 3083 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
2924 | 3084 | { |
2925 | - 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) |
|
2926 | - $smcFunc['db_query']('', ' |
|
3085 | + 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) { |
|
3086 | + $smcFunc['db_query']('', ' |
|
2927 | 3087 | UPDATE {db_prefix}log_actions |
2928 | 3088 | SET extra = {string:extra} |
2929 | 3089 | WHERE id_action = {int:current_action}', |
@@ -2932,6 +3092,7 @@ discard block |
||
2932 | 3092 | 'extra' => $matches[1] . strlen($matches[3]) . ':"' . $matches[3] . '"' . $matches[4], |
2933 | 3093 | ) |
2934 | 3094 | ); |
3095 | + } |
|
2935 | 3096 | } |
2936 | 3097 | $smcFunc['db_free_result']($request); |
2937 | 3098 | |
@@ -2953,15 +3114,17 @@ discard block |
||
2953 | 3114 | // First thing's first - did we already do this? |
2954 | 3115 | if (!empty($modSettings['json_done'])) |
2955 | 3116 | { |
2956 | - if ($command_line) |
|
2957 | - return DeleteUpgrade(); |
|
2958 | - else |
|
2959 | - return true; |
|
3117 | + if ($command_line) { |
|
3118 | + return DeleteUpgrade(); |
|
3119 | + } else { |
|
3120 | + return true; |
|
3121 | + } |
|
2960 | 3122 | } |
2961 | 3123 | |
2962 | 3124 | // Done it already - js wise? |
2963 | - if (!empty($_POST['json_done'])) |
|
2964 | - return true; |
|
3125 | + if (!empty($_POST['json_done'])) { |
|
3126 | + return true; |
|
3127 | + } |
|
2965 | 3128 | |
2966 | 3129 | // List of tables affected by this function |
2967 | 3130 | // name => array('key', col1[,col2|true[,col3]]) |
@@ -2993,12 +3156,14 @@ discard block |
||
2993 | 3156 | $upcontext['cur_table_name'] = isset($keys[$_GET['substep']]) ? $keys[$_GET['substep']] : $keys[0]; |
2994 | 3157 | $upcontext['step_progress'] = (int) (($upcontext['cur_table_num'] / $upcontext['table_count']) * 100); |
2995 | 3158 | |
2996 | - foreach ($keys as $id => $table) |
|
2997 | - if ($id < $_GET['substep']) |
|
3159 | + foreach ($keys as $id => $table) { |
|
3160 | + if ($id < $_GET['substep']) |
|
2998 | 3161 | $upcontext['previous_tables'][] = $table; |
3162 | + } |
|
2999 | 3163 | |
3000 | - if ($command_line) |
|
3001 | - echo 'Converting data from serialize() to json_encode().'; |
|
3164 | + if ($command_line) { |
|
3165 | + echo 'Converting data from serialize() to json_encode().'; |
|
3166 | + } |
|
3002 | 3167 | |
3003 | 3168 | if (!$support_js || isset($_GET['xml'])) |
3004 | 3169 | { |
@@ -3038,8 +3203,9 @@ discard block |
||
3038 | 3203 | |
3039 | 3204 | // Loop through and fix these... |
3040 | 3205 | $new_settings = array(); |
3041 | - if ($command_line) |
|
3042 | - echo "\n" . 'Fixing some settings...'; |
|
3206 | + if ($command_line) { |
|
3207 | + echo "\n" . 'Fixing some settings...'; |
|
3208 | + } |
|
3043 | 3209 | |
3044 | 3210 | foreach ($serialized_settings as $var) |
3045 | 3211 | { |
@@ -3047,22 +3213,24 @@ discard block |
||
3047 | 3213 | { |
3048 | 3214 | // Attempt to unserialize the setting |
3049 | 3215 | $temp = @safe_unserialize($modSettings[$var]); |
3050 | - if (!$temp && $command_line) |
|
3051 | - echo "\n - Failed to unserialize the '" . $var . "' setting. Skipping."; |
|
3052 | - elseif ($temp !== false) |
|
3053 | - $new_settings[$var] = json_encode($temp); |
|
3216 | + if (!$temp && $command_line) { |
|
3217 | + echo "\n - Failed to unserialize the '" . $var . "' setting. Skipping."; |
|
3218 | + } elseif ($temp !== false) { |
|
3219 | + $new_settings[$var] = json_encode($temp); |
|
3220 | + } |
|
3054 | 3221 | } |
3055 | 3222 | } |
3056 | 3223 | |
3057 | 3224 | // Update everything at once |
3058 | - if (!function_exists('cache_put_data')) |
|
3059 | - require_once($sourcedir . '/Load.php'); |
|
3225 | + if (!function_exists('cache_put_data')) { |
|
3226 | + require_once($sourcedir . '/Load.php'); |
|
3227 | + } |
|
3060 | 3228 | updateSettings($new_settings, true); |
3061 | 3229 | |
3062 | - if ($command_line) |
|
3063 | - echo ' done.'; |
|
3064 | - } |
|
3065 | - elseif ($table == 'themes') |
|
3230 | + if ($command_line) { |
|
3231 | + echo ' done.'; |
|
3232 | + } |
|
3233 | + } elseif ($table == 'themes') |
|
3066 | 3234 | { |
3067 | 3235 | // Finally, fix the admin prefs. Unfortunately this is stored per theme, but hopefully they only have one theme installed at this point... |
3068 | 3236 | $query = $smcFunc['db_query']('', ' |
@@ -3081,10 +3249,11 @@ discard block |
||
3081 | 3249 | |
3082 | 3250 | if ($command_line) |
3083 | 3251 | { |
3084 | - if ($temp === false) |
|
3085 | - echo "\n" . 'Unserialize of admin_preferences for user ' . $row['id_member'] . ' failed. Skipping.'; |
|
3086 | - else |
|
3087 | - echo "\n" . 'Fixing admin preferences...'; |
|
3252 | + if ($temp === false) { |
|
3253 | + echo "\n" . 'Unserialize of admin_preferences for user ' . $row['id_member'] . ' failed. Skipping.'; |
|
3254 | + } else { |
|
3255 | + echo "\n" . 'Fixing admin preferences...'; |
|
3256 | + } |
|
3088 | 3257 | } |
3089 | 3258 | |
3090 | 3259 | if ($temp !== false) |
@@ -3106,15 +3275,15 @@ discard block |
||
3106 | 3275 | ) |
3107 | 3276 | ); |
3108 | 3277 | |
3109 | - if ($command_line) |
|
3110 | - echo ' done.'; |
|
3278 | + if ($command_line) { |
|
3279 | + echo ' done.'; |
|
3280 | + } |
|
3111 | 3281 | } |
3112 | 3282 | } |
3113 | 3283 | |
3114 | 3284 | $smcFunc['db_free_result']($query); |
3115 | 3285 | } |
3116 | - } |
|
3117 | - else |
|
3286 | + } else |
|
3118 | 3287 | { |
3119 | 3288 | // First item is always the key... |
3120 | 3289 | $key = $info[0]; |
@@ -3125,8 +3294,7 @@ discard block |
||
3125 | 3294 | { |
3126 | 3295 | $col_select = $info[1]; |
3127 | 3296 | $where = ' WHERE ' . $info[1] . ' != {empty}'; |
3128 | - } |
|
3129 | - else |
|
3297 | + } else |
|
3130 | 3298 | { |
3131 | 3299 | $col_select = implode(', ', $info); |
3132 | 3300 | } |
@@ -3159,8 +3327,7 @@ discard block |
||
3159 | 3327 | if ($temp === false && $command_line) |
3160 | 3328 | { |
3161 | 3329 | echo "\nFailed to unserialize " . $row[$col] . "... Skipping\n"; |
3162 | - } |
|
3163 | - else |
|
3330 | + } else |
|
3164 | 3331 | { |
3165 | 3332 | $row[$col] = json_encode($temp); |
3166 | 3333 | |
@@ -3185,16 +3352,18 @@ discard block |
||
3185 | 3352 | } |
3186 | 3353 | } |
3187 | 3354 | |
3188 | - if ($command_line) |
|
3189 | - echo ' done.'; |
|
3355 | + if ($command_line) { |
|
3356 | + echo ' done.'; |
|
3357 | + } |
|
3190 | 3358 | |
3191 | 3359 | // Free up some memory... |
3192 | 3360 | $smcFunc['db_free_result']($query); |
3193 | 3361 | } |
3194 | 3362 | } |
3195 | 3363 | // If this is XML to keep it nice for the user do one table at a time anyway! |
3196 | - if (isset($_GET['xml'])) |
|
3197 | - return upgradeExit(); |
|
3364 | + if (isset($_GET['xml'])) { |
|
3365 | + return upgradeExit(); |
|
3366 | + } |
|
3198 | 3367 | } |
3199 | 3368 | |
3200 | 3369 | if ($command_line) |
@@ -3209,8 +3378,9 @@ discard block |
||
3209 | 3378 | |
3210 | 3379 | $_GET['substep'] = 0; |
3211 | 3380 | // Make sure we move on! |
3212 | - if ($command_line) |
|
3213 | - return DeleteUpgrade(); |
|
3381 | + if ($command_line) { |
|
3382 | + return DeleteUpgrade(); |
|
3383 | + } |
|
3214 | 3384 | |
3215 | 3385 | return true; |
3216 | 3386 | } |
@@ -3230,14 +3400,16 @@ discard block |
||
3230 | 3400 | global $upcontext, $txt, $settings; |
3231 | 3401 | |
3232 | 3402 | // Don't call me twice! |
3233 | - if (!empty($upcontext['chmod_called'])) |
|
3234 | - return; |
|
3403 | + if (!empty($upcontext['chmod_called'])) { |
|
3404 | + return; |
|
3405 | + } |
|
3235 | 3406 | |
3236 | 3407 | $upcontext['chmod_called'] = true; |
3237 | 3408 | |
3238 | 3409 | // Nothing? |
3239 | - if (empty($upcontext['chmod']['files']) && empty($upcontext['chmod']['ftp_error'])) |
|
3240 | - return; |
|
3410 | + if (empty($upcontext['chmod']['files']) && empty($upcontext['chmod']['ftp_error'])) { |
|
3411 | + return; |
|
3412 | + } |
|
3241 | 3413 | |
3242 | 3414 | // Was it a problem with Windows? |
3243 | 3415 | if (!empty($upcontext['chmod']['ftp_error']) && $upcontext['chmod']['ftp_error'] == 'total_mess') |
@@ -3269,11 +3441,12 @@ discard block |
||
3269 | 3441 | 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\'); |
3270 | 3442 | content.write(\'<p>', implode('<br>\n\t\t\t', $upcontext['chmod']['files']), '</p>\n\t\t\t\');'; |
3271 | 3443 | |
3272 | - if (isset($upcontext['systemos']) && $upcontext['systemos'] == 'linux') |
|
3273 | - echo ' |
|
3444 | + if (isset($upcontext['systemos']) && $upcontext['systemos'] == 'linux') { |
|
3445 | + echo ' |
|
3274 | 3446 | content.write(\'<hr>\n\t\t\t\'); |
3275 | 3447 | 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\'); |
3276 | 3448 | content.write(\'<tt># chmod a+w ', implode(' ', $upcontext['chmod']['files']), '</tt>\n\t\t\t\');'; |
3449 | + } |
|
3277 | 3450 | |
3278 | 3451 | echo ' |
3279 | 3452 | content.write(\'<a href="javascript:self.close();">close</a>\n\t\t</div>\n\t</body>\n</html>\'); |
@@ -3281,17 +3454,19 @@ discard block |
||
3281 | 3454 | } |
3282 | 3455 | </script>'; |
3283 | 3456 | |
3284 | - if (!empty($upcontext['chmod']['ftp_error'])) |
|
3285 | - echo ' |
|
3457 | + if (!empty($upcontext['chmod']['ftp_error'])) { |
|
3458 | + echo ' |
|
3286 | 3459 | <div class="error_message red"> |
3287 | 3460 | The following error was encountered when trying to connect:<br><br> |
3288 | 3461 | <code>', $upcontext['chmod']['ftp_error'], '</code> |
3289 | 3462 | </div> |
3290 | 3463 | <br>'; |
3464 | + } |
|
3291 | 3465 | |
3292 | - if (empty($upcontext['chmod_in_form'])) |
|
3293 | - echo ' |
|
3466 | + if (empty($upcontext['chmod_in_form'])) { |
|
3467 | + echo ' |
|
3294 | 3468 | <form action="', $upcontext['form_url'], '" method="post">'; |
3469 | + } |
|
3295 | 3470 | |
3296 | 3471 | echo ' |
3297 | 3472 | <table width="520" border="0" align="center" style="margin-bottom: 1ex;"> |
@@ -3326,10 +3501,11 @@ discard block |
||
3326 | 3501 | <div class="righttext" style="margin: 1ex;"><input type="submit" value="', $txt['ftp_connect'], '" class="button_submit"></div> |
3327 | 3502 | </div>'; |
3328 | 3503 | |
3329 | - if (empty($upcontext['chmod_in_form'])) |
|
3330 | - echo ' |
|
3504 | + if (empty($upcontext['chmod_in_form'])) { |
|
3505 | + echo ' |
|
3331 | 3506 | </form>'; |
3332 | -} |
|
3507 | + } |
|
3508 | + } |
|
3333 | 3509 | |
3334 | 3510 | function template_upgrade_above() |
3335 | 3511 | { |
@@ -3389,9 +3565,10 @@ discard block |
||
3389 | 3565 | <h2>', $txt['upgrade_progress'], '</h2> |
3390 | 3566 | <ul>'; |
3391 | 3567 | |
3392 | - foreach ($upcontext['steps'] as $num => $step) |
|
3393 | - echo ' |
|
3568 | + foreach ($upcontext['steps'] as $num => $step) { |
|
3569 | + echo ' |
|
3394 | 3570 | <li class="', $num < $upcontext['current_step'] ? 'stepdone' : ($num == $upcontext['current_step'] ? 'stepcurrent' : 'stepwaiting'), '">', $txt['upgrade_step'], ' ', $step[0], ': ', $step[1], '</li>'; |
3571 | + } |
|
3395 | 3572 | |
3396 | 3573 | echo ' |
3397 | 3574 | </ul> |
@@ -3404,8 +3581,8 @@ discard block |
||
3404 | 3581 | </div> |
3405 | 3582 | </div>'; |
3406 | 3583 | |
3407 | - if (isset($upcontext['step_progress'])) |
|
3408 | - echo ' |
|
3584 | + if (isset($upcontext['step_progress'])) { |
|
3585 | + echo ' |
|
3409 | 3586 | <br> |
3410 | 3587 | <br> |
3411 | 3588 | <div id="progress_bar_step"> |
@@ -3414,6 +3591,7 @@ discard block |
||
3414 | 3591 | <span>', $txt['upgrade_step_progress'], '</span> |
3415 | 3592 | </div> |
3416 | 3593 | </div>'; |
3594 | + } |
|
3417 | 3595 | |
3418 | 3596 | echo ' |
3419 | 3597 | <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> |
@@ -3444,32 +3622,36 @@ discard block |
||
3444 | 3622 | { |
3445 | 3623 | global $upcontext, $txt; |
3446 | 3624 | |
3447 | - if (!empty($upcontext['pause'])) |
|
3448 | - echo ' |
|
3625 | + if (!empty($upcontext['pause'])) { |
|
3626 | + echo ' |
|
3449 | 3627 | <em>', $txt['upgrade_incomplete'], '.</em><br> |
3450 | 3628 | |
3451 | 3629 | <h2 style="margin-top: 2ex;">', $txt['upgrade_not_quite_done'], '</h2> |
3452 | 3630 | <h3> |
3453 | 3631 | ', $txt['upgrade_paused_overload'], ' |
3454 | 3632 | </h3>'; |
3633 | + } |
|
3455 | 3634 | |
3456 | - if (!empty($upcontext['custom_warning'])) |
|
3457 | - echo ' |
|
3635 | + if (!empty($upcontext['custom_warning'])) { |
|
3636 | + echo ' |
|
3458 | 3637 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
3459 | 3638 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
3460 | 3639 | <strong style="text-decoration: underline;">', $txt['upgrade_note'], '</strong><br> |
3461 | 3640 | <div style="padding-left: 6ex;">', $upcontext['custom_warning'], '</div> |
3462 | 3641 | </div>'; |
3642 | + } |
|
3463 | 3643 | |
3464 | 3644 | echo ' |
3465 | 3645 | <div class="righttext" style="margin: 1ex;">'; |
3466 | 3646 | |
3467 | - if (!empty($upcontext['continue'])) |
|
3468 | - echo ' |
|
3647 | + if (!empty($upcontext['continue'])) { |
|
3648 | + echo ' |
|
3469 | 3649 | <input type="submit" id="contbutt" name="contbutt" value="', $txt['upgrade_continue'], '"', $upcontext['continue'] == 2 ? ' disabled' : '', ' class="button_submit">'; |
3470 | - if (!empty($upcontext['skip'])) |
|
3471 | - echo ' |
|
3650 | + } |
|
3651 | + if (!empty($upcontext['skip'])) { |
|
3652 | + echo ' |
|
3472 | 3653 | <input type="submit" id="skip" name="skip" value="', $txt['upgrade_skip'], '" onclick="dontSubmit = true; document.getElementById(\'contbutt\').disabled = \'disabled\'; return true;" class="button_submit">'; |
3654 | + } |
|
3473 | 3655 | |
3474 | 3656 | echo ' |
3475 | 3657 | </div> |
@@ -3519,11 +3701,12 @@ discard block |
||
3519 | 3701 | echo '<', '?xml version="1.0" encoding="UTF-8"?', '> |
3520 | 3702 | <smf>'; |
3521 | 3703 | |
3522 | - if (!empty($upcontext['get_data'])) |
|
3523 | - foreach ($upcontext['get_data'] as $k => $v) |
|
3704 | + if (!empty($upcontext['get_data'])) { |
|
3705 | + foreach ($upcontext['get_data'] as $k => $v) |
|
3524 | 3706 | echo ' |
3525 | 3707 | <get key="', $k, '">', $v, '</get>'; |
3526 | -} |
|
3708 | + } |
|
3709 | + } |
|
3527 | 3710 | |
3528 | 3711 | function template_xml_below() |
3529 | 3712 | { |
@@ -3564,8 +3747,8 @@ discard block |
||
3564 | 3747 | template_chmod(); |
3565 | 3748 | |
3566 | 3749 | // For large, pre 1.1 RC2 forums give them a warning about the possible impact of this upgrade! |
3567 | - if ($upcontext['is_large_forum']) |
|
3568 | - echo ' |
|
3750 | + if ($upcontext['is_large_forum']) { |
|
3751 | + echo ' |
|
3569 | 3752 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
3570 | 3753 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
3571 | 3754 | <strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br> |
@@ -3573,10 +3756,11 @@ discard block |
||
3573 | 3756 | ', $txt['upgrade_warning_lots_data'], ' |
3574 | 3757 | </div> |
3575 | 3758 | </div>'; |
3759 | + } |
|
3576 | 3760 | |
3577 | 3761 | // A warning message? |
3578 | - if (!empty($upcontext['warning'])) |
|
3579 | - echo ' |
|
3762 | + if (!empty($upcontext['warning'])) { |
|
3763 | + echo ' |
|
3580 | 3764 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
3581 | 3765 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
3582 | 3766 | <strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br> |
@@ -3584,6 +3768,7 @@ discard block |
||
3584 | 3768 | ', $upcontext['warning'], ' |
3585 | 3769 | </div> |
3586 | 3770 | </div>'; |
3771 | + } |
|
3587 | 3772 | |
3588 | 3773 | // Paths are incorrect? |
3589 | 3774 | echo ' |
@@ -3599,20 +3784,22 @@ discard block |
||
3599 | 3784 | if (!empty($upcontext['user']['id']) && (time() - $upcontext['started'] < 72600 || time() - $upcontext['updated'] < 3600)) |
3600 | 3785 | { |
3601 | 3786 | $ago = time() - $upcontext['started']; |
3602 | - if ($ago < 60) |
|
3603 | - $ago = $ago . ' seconds'; |
|
3604 | - elseif ($ago < 3600) |
|
3605 | - $ago = (int) ($ago / 60) . ' minutes'; |
|
3606 | - else |
|
3607 | - $ago = (int) ($ago / 3600) . ' hours'; |
|
3787 | + if ($ago < 60) { |
|
3788 | + $ago = $ago . ' seconds'; |
|
3789 | + } elseif ($ago < 3600) { |
|
3790 | + $ago = (int) ($ago / 60) . ' minutes'; |
|
3791 | + } else { |
|
3792 | + $ago = (int) ($ago / 3600) . ' hours'; |
|
3793 | + } |
|
3608 | 3794 | |
3609 | 3795 | $active = time() - $upcontext['updated']; |
3610 | - if ($active < 60) |
|
3611 | - $updated = $active . ' seconds'; |
|
3612 | - elseif ($active < 3600) |
|
3613 | - $updated = (int) ($active / 60) . ' minutes'; |
|
3614 | - else |
|
3615 | - $updated = (int) ($active / 3600) . ' hours'; |
|
3796 | + if ($active < 60) { |
|
3797 | + $updated = $active . ' seconds'; |
|
3798 | + } elseif ($active < 3600) { |
|
3799 | + $updated = (int) ($active / 60) . ' minutes'; |
|
3800 | + } else { |
|
3801 | + $updated = (int) ($active / 3600) . ' hours'; |
|
3802 | + } |
|
3616 | 3803 | |
3617 | 3804 | echo ' |
3618 | 3805 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
@@ -3621,16 +3808,18 @@ discard block |
||
3621 | 3808 | <div style="padding-left: 6ex;"> |
3622 | 3809 | "', $upcontext['user']['name'], '" has been running the upgrade script for the last ', $ago, ' - and was last active ', $updated, ' ago.'; |
3623 | 3810 | |
3624 | - if ($active < 600) |
|
3625 | - echo ' |
|
3811 | + if ($active < 600) { |
|
3812 | + echo ' |
|
3626 | 3813 | We recommend that you do not run this script unless you are sure that ', $upcontext['user']['name'], ' has completed their upgrade.'; |
3814 | + } |
|
3627 | 3815 | |
3628 | - if ($active > $upcontext['inactive_timeout']) |
|
3629 | - echo ' |
|
3816 | + if ($active > $upcontext['inactive_timeout']) { |
|
3817 | + echo ' |
|
3630 | 3818 | <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.'; |
3631 | - else |
|
3632 | - echo ' |
|
3819 | + } else { |
|
3820 | + echo ' |
|
3633 | 3821 | <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!'); |
3822 | + } |
|
3634 | 3823 | |
3635 | 3824 | echo ' |
3636 | 3825 | </div> |
@@ -3646,9 +3835,10 @@ discard block |
||
3646 | 3835 | <td> |
3647 | 3836 | <input type="text" name="user" value="', !empty($upcontext['username']) ? $upcontext['username'] : '', '"', $disable_security ? ' disabled' : '', ' class="input_text">'; |
3648 | 3837 | |
3649 | - if (!empty($upcontext['username_incorrect'])) |
|
3650 | - echo ' |
|
3838 | + if (!empty($upcontext['username_incorrect'])) { |
|
3839 | + echo ' |
|
3651 | 3840 | <div class="smalltext" style="color: red;">Username Incorrect</div>'; |
3841 | + } |
|
3652 | 3842 | |
3653 | 3843 | echo ' |
3654 | 3844 | </td> |
@@ -3659,9 +3849,10 @@ discard block |
||
3659 | 3849 | <input type="password" name="passwrd" value=""', $disable_security ? ' disabled' : '', ' class="input_password"> |
3660 | 3850 | <input type="hidden" name="hash_passwrd" value="">'; |
3661 | 3851 | |
3662 | - if (!empty($upcontext['password_failed'])) |
|
3663 | - echo ' |
|
3852 | + if (!empty($upcontext['password_failed'])) { |
|
3853 | + echo ' |
|
3664 | 3854 | <div class="smalltext" style="color: red;">Password Incorrect</div>'; |
3855 | + } |
|
3665 | 3856 | |
3666 | 3857 | echo ' |
3667 | 3858 | </td> |
@@ -3732,8 +3923,8 @@ discard block |
||
3732 | 3923 | <form action="', $upcontext['form_url'], '" method="post" name="upform" id="upform">'; |
3733 | 3924 | |
3734 | 3925 | // Warning message? |
3735 | - if (!empty($upcontext['upgrade_options_warning'])) |
|
3736 | - echo ' |
|
3926 | + if (!empty($upcontext['upgrade_options_warning'])) { |
|
3927 | + echo ' |
|
3737 | 3928 | <div style="margin: 1ex; padding: 1ex; border: 1px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
3738 | 3929 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
3739 | 3930 | <strong style="text-decoration: underline;">Warning!</strong><br> |
@@ -3741,6 +3932,7 @@ discard block |
||
3741 | 3932 | ', $upcontext['upgrade_options_warning'], ' |
3742 | 3933 | </div> |
3743 | 3934 | </div>'; |
3935 | + } |
|
3744 | 3936 | |
3745 | 3937 | echo ' |
3746 | 3938 | <table> |
@@ -3783,8 +3975,8 @@ discard block |
||
3783 | 3975 | </td> |
3784 | 3976 | </tr>'; |
3785 | 3977 | |
3786 | - if (!empty($upcontext['karma_installed']['good']) || !empty($upcontext['karma_installed']['bad'])) |
|
3787 | - echo ' |
|
3978 | + if (!empty($upcontext['karma_installed']['good']) || !empty($upcontext['karma_installed']['bad'])) { |
|
3979 | + echo ' |
|
3788 | 3980 | <tr valign="top"> |
3789 | 3981 | <td width="2%"> |
3790 | 3982 | <input type="checkbox" name="delete_karma" id="delete_karma" value="1" class="input_check"> |
@@ -3793,6 +3985,7 @@ discard block |
||
3793 | 3985 | <label for="delete_karma">Delete all karma settings and info from the DB</label> |
3794 | 3986 | </td> |
3795 | 3987 | </tr>'; |
3988 | + } |
|
3796 | 3989 | |
3797 | 3990 | echo ' |
3798 | 3991 | <tr valign="top"> |
@@ -3830,10 +4023,11 @@ discard block |
||
3830 | 4023 | </div>'; |
3831 | 4024 | |
3832 | 4025 | // Dont any tables so far? |
3833 | - if (!empty($upcontext['previous_tables'])) |
|
3834 | - foreach ($upcontext['previous_tables'] as $table) |
|
4026 | + if (!empty($upcontext['previous_tables'])) { |
|
4027 | + foreach ($upcontext['previous_tables'] as $table) |
|
3835 | 4028 | echo ' |
3836 | 4029 | <br>Completed Table: "', $table, '".'; |
4030 | + } |
|
3837 | 4031 | |
3838 | 4032 | echo ' |
3839 | 4033 | <h3 id="current_tab_div">Current Table: "<span id="current_table">', $upcontext['cur_table_name'], '</span>"</h3> |
@@ -3870,12 +4064,13 @@ discard block |
||
3870 | 4064 | updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');'; |
3871 | 4065 | |
3872 | 4066 | // If debug flood the screen. |
3873 | - if ($is_debug) |
|
3874 | - echo ' |
|
4067 | + if ($is_debug) { |
|
4068 | + echo ' |
|
3875 | 4069 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: "\' + sCompletedTableName + \'".<span id="debuginfo"><\' + \'/span>\'); |
3876 | 4070 | |
3877 | 4071 | if (document.getElementById(\'debug_section\').scrollHeight) |
3878 | 4072 | document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight'; |
4073 | + } |
|
3879 | 4074 | |
3880 | 4075 | echo ' |
3881 | 4076 | // Get the next update... |
@@ -3908,8 +4103,9 @@ discard block |
||
3908 | 4103 | { |
3909 | 4104 | global $upcontext, $support_js, $is_debug, $timeLimitThreshold; |
3910 | 4105 | |
3911 | - if (empty($is_debug) && !empty($upcontext['upgrade_status']['debug'])) |
|
3912 | - $is_debug = true; |
|
4106 | + if (empty($is_debug) && !empty($upcontext['upgrade_status']['debug'])) { |
|
4107 | + $is_debug = true; |
|
4108 | + } |
|
3913 | 4109 | |
3914 | 4110 | echo ' |
3915 | 4111 | <h3>Executing database changes</h3> |
@@ -3924,8 +4120,9 @@ discard block |
||
3924 | 4120 | { |
3925 | 4121 | foreach ($upcontext['actioned_items'] as $num => $item) |
3926 | 4122 | { |
3927 | - if ($num != 0) |
|
3928 | - echo ' Successful!'; |
|
4123 | + if ($num != 0) { |
|
4124 | + echo ' Successful!'; |
|
4125 | + } |
|
3929 | 4126 | echo '<br>' . $item; |
3930 | 4127 | } |
3931 | 4128 | if (!empty($upcontext['changes_complete'])) |
@@ -3938,28 +4135,32 @@ discard block |
||
3938 | 4135 | $seconds = intval($active % 60); |
3939 | 4136 | |
3940 | 4137 | $totalTime = ''; |
3941 | - if ($hours > 0) |
|
3942 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
3943 | - if ($minutes > 0) |
|
3944 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
3945 | - if ($seconds > 0) |
|
3946 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
4138 | + if ($hours > 0) { |
|
4139 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
4140 | + } |
|
4141 | + if ($minutes > 0) { |
|
4142 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
4143 | + } |
|
4144 | + if ($seconds > 0) { |
|
4145 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
4146 | + } |
|
3947 | 4147 | } |
3948 | 4148 | |
3949 | - if ($is_debug && !empty($totalTime)) |
|
3950 | - echo ' Successful! Completed in ', $totalTime, '<br><br>'; |
|
3951 | - else |
|
3952 | - echo ' Successful!<br><br>'; |
|
4149 | + if ($is_debug && !empty($totalTime)) { |
|
4150 | + echo ' Successful! Completed in ', $totalTime, '<br><br>'; |
|
4151 | + } else { |
|
4152 | + echo ' Successful!<br><br>'; |
|
4153 | + } |
|
3953 | 4154 | |
3954 | 4155 | echo '<span id="commess" style="font-weight: bold;">1 Database Updates Complete! Click Continue to Proceed.</span><br>'; |
3955 | 4156 | } |
3956 | - } |
|
3957 | - else |
|
4157 | + } else |
|
3958 | 4158 | { |
3959 | 4159 | // Tell them how many files we have in total. |
3960 | - if ($upcontext['file_count'] > 1) |
|
3961 | - echo ' |
|
4160 | + if ($upcontext['file_count'] > 1) { |
|
4161 | + echo ' |
|
3962 | 4162 | <strong id="info1">Executing upgrade script <span id="file_done">', $upcontext['cur_file_num'], '</span> of ', $upcontext['file_count'], '.</strong>'; |
4163 | + } |
|
3963 | 4164 | |
3964 | 4165 | echo ' |
3965 | 4166 | <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> |
@@ -3975,19 +4176,23 @@ discard block |
||
3975 | 4176 | $seconds = intval($active % 60); |
3976 | 4177 | |
3977 | 4178 | $totalTime = ''; |
3978 | - if ($hours > 0) |
|
3979 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
3980 | - if ($minutes > 0) |
|
3981 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
3982 | - if ($seconds > 0) |
|
3983 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
4179 | + if ($hours > 0) { |
|
4180 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
4181 | + } |
|
4182 | + if ($minutes > 0) { |
|
4183 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
4184 | + } |
|
4185 | + if ($seconds > 0) { |
|
4186 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
4187 | + } |
|
3984 | 4188 | } |
3985 | 4189 | |
3986 | 4190 | echo ' |
3987 | 4191 | <br><span id="upgradeCompleted">'; |
3988 | 4192 | |
3989 | - if (!empty($totalTime)) |
|
3990 | - echo 'Completed in ', $totalTime, '<br>'; |
|
4193 | + if (!empty($totalTime)) { |
|
4194 | + echo 'Completed in ', $totalTime, '<br>'; |
|
4195 | + } |
|
3991 | 4196 | |
3992 | 4197 | echo '</span> |
3993 | 4198 | <div id="debug_section" style="height: 59px; overflow: auto;"> |
@@ -4024,9 +4229,10 @@ discard block |
||
4024 | 4229 | var getData = ""; |
4025 | 4230 | var debugItems = ', $upcontext['debug_items'], ';'; |
4026 | 4231 | |
4027 | - if ($is_debug) |
|
4028 | - echo ' |
|
4232 | + if ($is_debug) { |
|
4233 | + echo ' |
|
4029 | 4234 | var upgradeStartTime = ' . $upcontext['started'] . ';'; |
4235 | + } |
|
4030 | 4236 | |
4031 | 4237 | echo ' |
4032 | 4238 | function getNextItem() |
@@ -4066,9 +4272,10 @@ discard block |
||
4066 | 4272 | document.getElementById("error_block").style.display = ""; |
4067 | 4273 | setInnerHTML(document.getElementById("error_message"), "Error retrieving information on step: " + (sDebugName == "" ? sLastString : sDebugName));'; |
4068 | 4274 | |
4069 | - if ($is_debug) |
|
4070 | - echo ' |
|
4275 | + if ($is_debug) { |
|
4276 | + echo ' |
|
4071 | 4277 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<span style="color: red;">failed<\' + \'/span><span id="debuginfo"><\' + \'/span>\');'; |
4278 | + } |
|
4072 | 4279 | |
4073 | 4280 | echo ' |
4074 | 4281 | } |
@@ -4089,9 +4296,10 @@ discard block |
||
4089 | 4296 | document.getElementById("error_block").style.display = ""; |
4090 | 4297 | setInnerHTML(document.getElementById("error_message"), "Upgrade script appears to be going into a loop - step: " + sDebugName);'; |
4091 | 4298 | |
4092 | - if ($is_debug) |
|
4093 | - echo ' |
|
4299 | + if ($is_debug) { |
|
4300 | + echo ' |
|
4094 | 4301 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<span style="color: red;">failed<\' + \'/span><span id="debuginfo"><\' + \'/span>\');'; |
4302 | + } |
|
4095 | 4303 | |
4096 | 4304 | echo ' |
4097 | 4305 | } |
@@ -4150,8 +4358,8 @@ discard block |
||
4150 | 4358 | if (bIsComplete && iDebugNum == -1 && curFile >= ', $upcontext['file_count'], ') |
4151 | 4359 | {'; |
4152 | 4360 | |
4153 | - if ($is_debug) |
|
4154 | - echo ' |
|
4361 | + if ($is_debug) { |
|
4362 | + echo ' |
|
4155 | 4363 | document.getElementById(\'debug_section\').style.display = "none"; |
4156 | 4364 | |
4157 | 4365 | var upgradeFinishedTime = parseInt(oXMLDoc.getElementsByTagName("curtime")[0].childNodes[0].nodeValue); |
@@ -4169,6 +4377,7 @@ discard block |
||
4169 | 4377 | totalTime = totalTime + diffSeconds + " second" + (diffSeconds > 1 ? "s" : ""); |
4170 | 4378 | |
4171 | 4379 | setInnerHTML(document.getElementById("upgradeCompleted"), "Completed in " + totalTime);'; |
4380 | + } |
|
4172 | 4381 | |
4173 | 4382 | echo ' |
4174 | 4383 | |
@@ -4176,9 +4385,10 @@ discard block |
||
4176 | 4385 | document.getElementById(\'contbutt\').disabled = 0; |
4177 | 4386 | document.getElementById(\'database_done\').value = 1;'; |
4178 | 4387 | |
4179 | - if ($upcontext['file_count'] > 1) |
|
4180 | - echo ' |
|
4388 | + if ($upcontext['file_count'] > 1) { |
|
4389 | + echo ' |
|
4181 | 4390 | document.getElementById(\'info1\').style.display = "none";'; |
4391 | + } |
|
4182 | 4392 | |
4183 | 4393 | echo ' |
4184 | 4394 | document.getElementById(\'info2\').style.display = "none"; |
@@ -4191,9 +4401,10 @@ discard block |
||
4191 | 4401 | lastItem = 0; |
4192 | 4402 | prevFile = curFile;'; |
4193 | 4403 | |
4194 | - if ($is_debug) |
|
4195 | - echo ' |
|
4404 | + if ($is_debug) { |
|
4405 | + echo ' |
|
4196 | 4406 | setOuterHTML(document.getElementById(\'debuginfo\'), \'Moving to next script file...done<br><span id="debuginfo"><\' + \'/span>\');'; |
4407 | + } |
|
4197 | 4408 | |
4198 | 4409 | echo ' |
4199 | 4410 | getNextItem(); |
@@ -4201,8 +4412,8 @@ discard block |
||
4201 | 4412 | }'; |
4202 | 4413 | |
4203 | 4414 | // If debug scroll the screen. |
4204 | - if ($is_debug) |
|
4205 | - echo ' |
|
4415 | + if ($is_debug) { |
|
4416 | + echo ' |
|
4206 | 4417 | if (iLastSubStepProgress == -1) |
4207 | 4418 | { |
4208 | 4419 | // Give it consistent dots. |
@@ -4221,6 +4432,7 @@ discard block |
||
4221 | 4432 | |
4222 | 4433 | if (document.getElementById(\'debug_section\').scrollHeight) |
4223 | 4434 | document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight'; |
4435 | + } |
|
4224 | 4436 | |
4225 | 4437 | echo ' |
4226 | 4438 | // Update the page. |
@@ -4281,9 +4493,10 @@ discard block |
||
4281 | 4493 | }'; |
4282 | 4494 | |
4283 | 4495 | // Start things off assuming we've not errored. |
4284 | - if (empty($upcontext['error_message'])) |
|
4285 | - echo ' |
|
4496 | + if (empty($upcontext['error_message'])) { |
|
4497 | + echo ' |
|
4286 | 4498 | getNextItem();'; |
4499 | + } |
|
4287 | 4500 | |
4288 | 4501 | echo ' |
4289 | 4502 | //# sourceURL=dynamicScript-dbch.js |
@@ -4301,18 +4514,21 @@ discard block |
||
4301 | 4514 | <item num="', $upcontext['current_item_num'], '">', $upcontext['current_item_name'], '</item> |
4302 | 4515 | <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>'; |
4303 | 4516 | |
4304 | - if (!empty($upcontext['error_message'])) |
|
4305 | - echo ' |
|
4517 | + if (!empty($upcontext['error_message'])) { |
|
4518 | + echo ' |
|
4306 | 4519 | <error>', $upcontext['error_message'], '</error>'; |
4520 | + } |
|
4307 | 4521 | |
4308 | - if (!empty($upcontext['error_string'])) |
|
4309 | - echo ' |
|
4522 | + if (!empty($upcontext['error_string'])) { |
|
4523 | + echo ' |
|
4310 | 4524 | <sql>', $upcontext['error_string'], '</sql>'; |
4525 | + } |
|
4311 | 4526 | |
4312 | - if ($is_debug) |
|
4313 | - echo ' |
|
4527 | + if ($is_debug) { |
|
4528 | + echo ' |
|
4314 | 4529 | <curtime>', time(), '</curtime>'; |
4315 | -} |
|
4530 | + } |
|
4531 | + } |
|
4316 | 4532 | |
4317 | 4533 | // Template for the UTF-8 conversion step. Basically a copy of the backup stuff with slight modifications.... |
4318 | 4534 | function template_convert_utf8() |
@@ -4331,18 +4547,20 @@ discard block |
||
4331 | 4547 | </div>'; |
4332 | 4548 | |
4333 | 4549 | // Done any tables so far? |
4334 | - if (!empty($upcontext['previous_tables'])) |
|
4335 | - foreach ($upcontext['previous_tables'] as $table) |
|
4550 | + if (!empty($upcontext['previous_tables'])) { |
|
4551 | + foreach ($upcontext['previous_tables'] as $table) |
|
4336 | 4552 | echo ' |
4337 | 4553 | <br>Completed Table: "', $table, '".'; |
4554 | + } |
|
4338 | 4555 | |
4339 | 4556 | echo ' |
4340 | 4557 | <h3 id="current_tab_div">Current Table: "<span id="current_table">', $upcontext['cur_table_name'], '</span>"</h3>'; |
4341 | 4558 | |
4342 | 4559 | // If we dropped their index, let's let them know |
4343 | - if ($upcontext['dropping_index']) |
|
4344 | - echo ' |
|
4560 | + if ($upcontext['dropping_index']) { |
|
4561 | + echo ' |
|
4345 | 4562 | <br><span id="indexmsg" style="font-weight: bold; font-style: italic; display: ', $upcontext['cur_table_num'] == $upcontext['table_count'] ? 'inline' : 'none', ';">Please note that your fulltext index was dropped to facilitate the conversion and will need to be recreated in the admin area after the upgrade is complete.</span>'; |
4563 | + } |
|
4346 | 4564 | |
4347 | 4565 | // Completion notification |
4348 | 4566 | echo ' |
@@ -4379,12 +4597,13 @@ discard block |
||
4379 | 4597 | updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');'; |
4380 | 4598 | |
4381 | 4599 | // If debug flood the screen. |
4382 | - if ($is_debug) |
|
4383 | - echo ' |
|
4600 | + if ($is_debug) { |
|
4601 | + echo ' |
|
4384 | 4602 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: "\' + sCompletedTableName + \'".<span id="debuginfo"><\' + \'/span>\'); |
4385 | 4603 | |
4386 | 4604 | if (document.getElementById(\'debug_section\').scrollHeight) |
4387 | 4605 | document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight'; |
4606 | + } |
|
4388 | 4607 | |
4389 | 4608 | echo ' |
4390 | 4609 | // Get the next update... |
@@ -4432,19 +4651,21 @@ discard block |
||
4432 | 4651 | </div>'; |
4433 | 4652 | |
4434 | 4653 | // Dont any tables so far? |
4435 | - if (!empty($upcontext['previous_tables'])) |
|
4436 | - foreach ($upcontext['previous_tables'] as $table) |
|
4654 | + if (!empty($upcontext['previous_tables'])) { |
|
4655 | + foreach ($upcontext['previous_tables'] as $table) |
|
4437 | 4656 | echo ' |
4438 | 4657 | <br>Completed Table: "', $table, '".'; |
4658 | + } |
|
4439 | 4659 | |
4440 | 4660 | echo ' |
4441 | 4661 | <h3 id="current_tab_div">Current Table: "<span id="current_table">', $upcontext['cur_table_name'], '</span>"</h3> |
4442 | 4662 | <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>'; |
4443 | 4663 | |
4444 | 4664 | // Try to make sure substep was reset. |
4445 | - if ($upcontext['cur_table_num'] == $upcontext['table_count']) |
|
4446 | - echo ' |
|
4665 | + if ($upcontext['cur_table_num'] == $upcontext['table_count']) { |
|
4666 | + echo ' |
|
4447 | 4667 | <input type="hidden" name="substep" id="substep" value="0">'; |
4668 | + } |
|
4448 | 4669 | |
4449 | 4670 | // Continue please! |
4450 | 4671 | $upcontext['continue'] = $support_js ? 2 : 1; |
@@ -4477,12 +4698,13 @@ discard block |
||
4477 | 4698 | updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');'; |
4478 | 4699 | |
4479 | 4700 | // If debug flood the screen. |
4480 | - if ($is_debug) |
|
4481 | - echo ' |
|
4701 | + if ($is_debug) { |
|
4702 | + echo ' |
|
4482 | 4703 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: "\' + sCompletedTableName + \'".<span id="debuginfo"><\' + \'/span>\'); |
4483 | 4704 | |
4484 | 4705 | if (document.getElementById(\'debug_section\').scrollHeight) |
4485 | 4706 | document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight'; |
4707 | + } |
|
4486 | 4708 | |
4487 | 4709 | echo ' |
4488 | 4710 | // Get the next update... |
@@ -4518,8 +4740,8 @@ discard block |
||
4518 | 4740 | <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> |
4519 | 4741 | <form action="', $boardurl, '/index.php">'; |
4520 | 4742 | |
4521 | - if (!empty($upcontext['can_delete_script'])) |
|
4522 | - echo ' |
|
4743 | + if (!empty($upcontext['can_delete_script'])) { |
|
4744 | + echo ' |
|
4523 | 4745 | <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> |
4524 | 4746 | <script> |
4525 | 4747 | function doTheDelete(theCheck) |
@@ -4531,6 +4753,7 @@ discard block |
||
4531 | 4753 | } |
4532 | 4754 | </script> |
4533 | 4755 | <img src="', $settings['default_theme_url'], '/images/blank.png" alt="" id="delete_upgrader"><br>'; |
4756 | + } |
|
4534 | 4757 | |
4535 | 4758 | $active = time() - $upcontext['started']; |
4536 | 4759 | $hours = floor($active / 3600); |
@@ -4540,16 +4763,20 @@ discard block |
||
4540 | 4763 | if ($is_debug) |
4541 | 4764 | { |
4542 | 4765 | $totalTime = ''; |
4543 | - if ($hours > 0) |
|
4544 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
4545 | - if ($minutes > 0) |
|
4546 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
4547 | - if ($seconds > 0) |
|
4548 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
4766 | + if ($hours > 0) { |
|
4767 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
4768 | + } |
|
4769 | + if ($minutes > 0) { |
|
4770 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
4771 | + } |
|
4772 | + if ($seconds > 0) { |
|
4773 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
4774 | + } |
|
4549 | 4775 | } |
4550 | 4776 | |
4551 | - if ($is_debug && !empty($totalTime)) |
|
4552 | - echo '<br> Upgrade completed in ', $totalTime, '<br><br>'; |
|
4777 | + if ($is_debug && !empty($totalTime)) { |
|
4778 | + echo '<br> Upgrade completed in ', $totalTime, '<br><br>'; |
|
4779 | + } |
|
4553 | 4780 | |
4554 | 4781 | echo '<br> |
4555 | 4782 | 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> |
@@ -4576,8 +4803,9 @@ discard block |
||
4576 | 4803 | |
4577 | 4804 | $current_substep = $_GET['substep']; |
4578 | 4805 | |
4579 | - if (empty($_GET['a'])) |
|
4580 | - $_GET['a'] = 0; |
|
4806 | + if (empty($_GET['a'])) { |
|
4807 | + $_GET['a'] = 0; |
|
4808 | + } |
|
4581 | 4809 | $step_progress['name'] = 'Converting ips'; |
4582 | 4810 | $step_progress['current'] = $_GET['a']; |
4583 | 4811 | |
@@ -4620,16 +4848,19 @@ discard block |
||
4620 | 4848 | 'empty' => '', |
4621 | 4849 | 'limit' => $limit, |
4622 | 4850 | )); |
4623 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
4624 | - $arIp[] = $row[$oldCol]; |
|
4851 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
4852 | + $arIp[] = $row[$oldCol]; |
|
4853 | + } |
|
4625 | 4854 | $smcFunc['db_free_result']($request); |
4626 | 4855 | |
4627 | 4856 | // Special case, null ip could keep us in a loop. |
4628 | - if (is_null($arIp[0])) |
|
4629 | - unset($arIp[0]); |
|
4857 | + if (is_null($arIp[0])) { |
|
4858 | + unset($arIp[0]); |
|
4859 | + } |
|
4630 | 4860 | |
4631 | - if (empty($arIp)) |
|
4632 | - $is_done = true; |
|
4861 | + if (empty($arIp)) { |
|
4862 | + $is_done = true; |
|
4863 | + } |
|
4633 | 4864 | |
4634 | 4865 | $updates = array(); |
4635 | 4866 | $cases = array(); |
@@ -4638,16 +4869,18 @@ discard block |
||
4638 | 4869 | { |
4639 | 4870 | $arIp[$i] = trim($arIp[$i]); |
4640 | 4871 | |
4641 | - if (empty($arIp[$i])) |
|
4642 | - continue; |
|
4872 | + if (empty($arIp[$i])) { |
|
4873 | + continue; |
|
4874 | + } |
|
4643 | 4875 | |
4644 | 4876 | $updates['ip' . $i] = $arIp[$i]; |
4645 | 4877 | $cases[$arIp[$i]] = 'WHEN ' . $oldCol . ' = {string:ip' . $i . '} THEN {inet:ip' . $i . '}'; |
4646 | 4878 | |
4647 | 4879 | if ($setSize > 0 && $i % $setSize === 0) |
4648 | 4880 | { |
4649 | - if (count($updates) == 1) |
|
4650 | - continue; |
|
4881 | + if (count($updates) == 1) { |
|
4882 | + continue; |
|
4883 | + } |
|
4651 | 4884 | |
4652 | 4885 | $updates['whereSet'] = array_values($updates); |
4653 | 4886 | $smcFunc['db_query']('', ' |
@@ -4681,8 +4914,7 @@ discard block |
||
4681 | 4914 | 'ip' => $ip |
4682 | 4915 | )); |
4683 | 4916 | } |
4684 | - } |
|
4685 | - else |
|
4917 | + } else |
|
4686 | 4918 | { |
4687 | 4919 | $updates['whereSet'] = array_values($updates); |
4688 | 4920 | $smcFunc['db_query']('', ' |
@@ -4696,9 +4928,9 @@ discard block |
||
4696 | 4928 | $updates |
4697 | 4929 | ); |
4698 | 4930 | } |
4931 | + } else { |
|
4932 | + $is_done = true; |
|
4699 | 4933 | } |
4700 | - else |
|
4701 | - $is_done = true; |
|
4702 | 4934 | |
4703 | 4935 | $_GET['a'] += $limit; |
4704 | 4936 | $step_progress['current'] = $_GET['a']; |
@@ -4724,10 +4956,11 @@ discard block |
||
4724 | 4956 | |
4725 | 4957 | $columns = $smcFunc['db_list_columns']($targetTable, true); |
4726 | 4958 | |
4727 | - if (isset($columns[$column])) |
|
4728 | - return $columns[$column]; |
|
4729 | - else |
|
4730 | - return null; |
|
4731 | -} |
|
4959 | + if (isset($columns[$column])) { |
|
4960 | + return $columns[$column]; |
|
4961 | + } else { |
|
4962 | + return null; |
|
4963 | + } |
|
4964 | + } |
|
4732 | 4965 | |
4733 | 4966 | ?> |
4734 | 4967 | \ No newline at end of file |
@@ -540,6 +540,7 @@ |
||
540 | 540 | * @param string $xml_format The format to use ('atom', 'rss', 'rss2' or empty for plain XML) |
541 | 541 | * @param array $forceCdataKeys A list of keys on which to force cdata wrapping (used by mods, maybe) |
542 | 542 | * @param array $nsKeys Key-value pairs of namespace prefixes to pass to cdata_parse() (used by mods, maybe) |
543 | + * @param string $tag |
|
543 | 544 | */ |
544 | 545 | function dumpTags($data, $i, $tag = null, $xml_format = '', $forceCdataKeys = array(), $nsKeys = array()) |
545 | 546 | { |
@@ -862,7 +862,7 @@ discard block |
||
862 | 862 | { |
863 | 863 | uasort($loaded_attachments, function($a, $b) { |
864 | 864 | if ($a['filesize'] == $b['filesize']) |
865 | - return 0; |
|
865 | + return 0; |
|
866 | 866 | return ($a['filesize'] < $b['filesize']) ? -1 : 1; |
867 | 867 | }); |
868 | 868 | } |
@@ -1272,7 +1272,7 @@ discard block |
||
1272 | 1272 | { |
1273 | 1273 | uasort($loaded_attachments, function($a, $b) { |
1274 | 1274 | if ($a['filesize'] == $b['filesize']) |
1275 | - return 0; |
|
1275 | + return 0; |
|
1276 | 1276 | return ($a['filesize'] < $b['filesize']) ? -1 : 1; |
1277 | 1277 | }); |
1278 | 1278 | } |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | $smcFunc['db_free_result']($request); |
166 | 166 | |
167 | 167 | $feed_meta['title'] = ' - ' . strip_tags($board_info['name']); |
168 | - $feed_meta['source'] .= '?board=' . $board . '.0' ; |
|
168 | + $feed_meta['source'] .= '?board=' . $board . '.0'; |
|
169 | 169 | |
170 | 170 | $query_this_board = 'b.id_board = ' . $board; |
171 | 171 | |
@@ -389,7 +389,7 @@ discard block |
||
389 | 389 | |
390 | 390 | foreach ($xml_data as $item) |
391 | 391 | { |
392 | - $link = array_filter($item['content'], function ($e) { return ($e['tag'] == 'link'); }); |
|
392 | + $link = array_filter($item['content'], function($e) { return ($e['tag'] == 'link'); }); |
|
393 | 393 | $link = array_pop($link); |
394 | 394 | |
395 | 395 | echo ' |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 4 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * Outputs xml data representing recent information or a profile. |
@@ -37,8 +38,9 @@ discard block |
||
37 | 38 | global $query_this_board, $smcFunc, $forum_version, $settings; |
38 | 39 | |
39 | 40 | // If it's not enabled, die. |
40 | - if (empty($modSettings['xmlnews_enable'])) |
|
41 | - obExit(false); |
|
41 | + if (empty($modSettings['xmlnews_enable'])) { |
|
42 | + obExit(false); |
|
43 | + } |
|
42 | 44 | |
43 | 45 | loadLanguage('Stats'); |
44 | 46 | |
@@ -64,8 +66,9 @@ discard block |
||
64 | 66 | if (!empty($_REQUEST['c']) && empty($board)) |
65 | 67 | { |
66 | 68 | $_REQUEST['c'] = explode(',', $_REQUEST['c']); |
67 | - foreach ($_REQUEST['c'] as $i => $c) |
|
68 | - $_REQUEST['c'][$i] = (int) $c; |
|
69 | + foreach ($_REQUEST['c'] as $i => $c) { |
|
70 | + $_REQUEST['c'][$i] = (int) $c; |
|
71 | + } |
|
69 | 72 | |
70 | 73 | if (count($_REQUEST['c']) == 1) |
71 | 74 | { |
@@ -101,18 +104,20 @@ discard block |
||
101 | 104 | } |
102 | 105 | $smcFunc['db_free_result']($request); |
103 | 106 | |
104 | - if (!empty($boards)) |
|
105 | - $query_this_board = 'b.id_board IN (' . implode(', ', $boards) . ')'; |
|
107 | + if (!empty($boards)) { |
|
108 | + $query_this_board = 'b.id_board IN (' . implode(', ', $boards) . ')'; |
|
109 | + } |
|
106 | 110 | |
107 | 111 | // Try to limit the number of messages we look through. |
108 | - if ($total_cat_posts > 100 && $total_cat_posts > $modSettings['totalMessages'] / 15) |
|
109 | - $context['optimize_msg']['lowest'] = 'm.id_msg >= ' . max(0, $modSettings['maxMsgID'] - 400 - $_GET['limit'] * 5); |
|
110 | - } |
|
111 | - elseif (!empty($_REQUEST['boards'])) |
|
112 | + if ($total_cat_posts > 100 && $total_cat_posts > $modSettings['totalMessages'] / 15) { |
|
113 | + $context['optimize_msg']['lowest'] = 'm.id_msg >= ' . max(0, $modSettings['maxMsgID'] - 400 - $_GET['limit'] * 5); |
|
114 | + } |
|
115 | + } elseif (!empty($_REQUEST['boards'])) |
|
112 | 116 | { |
113 | 117 | $_REQUEST['boards'] = explode(',', $_REQUEST['boards']); |
114 | - foreach ($_REQUEST['boards'] as $i => $b) |
|
115 | - $_REQUEST['boards'][$i] = (int) $b; |
|
118 | + foreach ($_REQUEST['boards'] as $i => $b) { |
|
119 | + $_REQUEST['boards'][$i] = (int) $b; |
|
120 | + } |
|
116 | 121 | |
117 | 122 | $request = $smcFunc['db_query']('', ' |
118 | 123 | SELECT b.id_board, b.num_posts, b.name |
@@ -128,29 +133,32 @@ discard block |
||
128 | 133 | |
129 | 134 | // Either the board specified doesn't exist or you have no access. |
130 | 135 | $num_boards = $smcFunc['db_num_rows']($request); |
131 | - if ($num_boards == 0) |
|
132 | - fatal_lang_error('no_board'); |
|
136 | + if ($num_boards == 0) { |
|
137 | + fatal_lang_error('no_board'); |
|
138 | + } |
|
133 | 139 | |
134 | 140 | $total_posts = 0; |
135 | 141 | $boards = array(); |
136 | 142 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
137 | 143 | { |
138 | - if ($num_boards == 1) |
|
139 | - $feed_meta['title'] = ' - ' . strip_tags($row['name']); |
|
144 | + if ($num_boards == 1) { |
|
145 | + $feed_meta['title'] = ' - ' . strip_tags($row['name']); |
|
146 | + } |
|
140 | 147 | |
141 | 148 | $boards[] = $row['id_board']; |
142 | 149 | $total_posts += $row['num_posts']; |
143 | 150 | } |
144 | 151 | $smcFunc['db_free_result']($request); |
145 | 152 | |
146 | - if (!empty($boards)) |
|
147 | - $query_this_board = 'b.id_board IN (' . implode(', ', $boards) . ')'; |
|
153 | + if (!empty($boards)) { |
|
154 | + $query_this_board = 'b.id_board IN (' . implode(', ', $boards) . ')'; |
|
155 | + } |
|
148 | 156 | |
149 | 157 | // The more boards, the more we're going to look through... |
150 | - if ($total_posts > 100 && $total_posts > $modSettings['totalMessages'] / 12) |
|
151 | - $context['optimize_msg']['lowest'] = 'm.id_msg >= ' . max(0, $modSettings['maxMsgID'] - 500 - $_GET['limit'] * 5); |
|
152 | - } |
|
153 | - elseif (!empty($board)) |
|
158 | + if ($total_posts > 100 && $total_posts > $modSettings['totalMessages'] / 12) { |
|
159 | + $context['optimize_msg']['lowest'] = 'm.id_msg >= ' . max(0, $modSettings['maxMsgID'] - 500 - $_GET['limit'] * 5); |
|
160 | + } |
|
161 | + } elseif (!empty($board)) |
|
154 | 162 | { |
155 | 163 | $request = $smcFunc['db_query']('', ' |
156 | 164 | SELECT num_posts |
@@ -170,10 +178,10 @@ discard block |
||
170 | 178 | $query_this_board = 'b.id_board = ' . $board; |
171 | 179 | |
172 | 180 | // Try to look through just a few messages, if at all possible. |
173 | - if ($total_posts > 80 && $total_posts > $modSettings['totalMessages'] / 10) |
|
174 | - $context['optimize_msg']['lowest'] = 'm.id_msg >= ' . max(0, $modSettings['maxMsgID'] - 600 - $_GET['limit'] * 5); |
|
175 | - } |
|
176 | - else |
|
181 | + if ($total_posts > 80 && $total_posts > $modSettings['totalMessages'] / 10) { |
|
182 | + $context['optimize_msg']['lowest'] = 'm.id_msg >= ' . max(0, $modSettings['maxMsgID'] - 600 - $_GET['limit'] * 5); |
|
183 | + } |
|
184 | + } else |
|
177 | 185 | { |
178 | 186 | $query_this_board = '{query_see_board}' . (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0 ? ' |
179 | 187 | AND b.id_board != ' . $modSettings['recycle_board'] : ''); |
@@ -196,30 +204,35 @@ discard block |
||
196 | 204 | // Easy adding of sub actions |
197 | 205 | call_integration_hook('integrate_xmlfeeds', array(&$subActions)); |
198 | 206 | |
199 | - if (empty($_GET['sa']) || !isset($subActions[$_GET['sa']])) |
|
200 | - $_GET['sa'] = 'recent'; |
|
207 | + if (empty($_GET['sa']) || !isset($subActions[$_GET['sa']])) { |
|
208 | + $_GET['sa'] = 'recent'; |
|
209 | + } |
|
201 | 210 | |
202 | 211 | // We only want some information, not all of it. |
203 | 212 | $cachekey = array($xml_format, $_GET['action'], $_GET['limit'], $_GET['sa']); |
204 | - foreach (array('board', 'boards', 'c') as $var) |
|
205 | - if (isset($_REQUEST[$var])) |
|
213 | + foreach (array('board', 'boards', 'c') as $var) { |
|
214 | + if (isset($_REQUEST[$var])) |
|
206 | 215 | $cachekey[] = $_REQUEST[$var]; |
216 | + } |
|
207 | 217 | $cachekey = md5($smcFunc['json_encode']($cachekey) . (!empty($query_this_board) ? $query_this_board : '')); |
208 | 218 | $cache_t = microtime(); |
209 | 219 | |
210 | 220 | // Get the associative array representing the xml. |
211 | - if (!empty($modSettings['cache_enable']) && (!$user_info['is_guest'] || $modSettings['cache_enable'] >= 3)) |
|
212 | - $xml_data = cache_get_data('xmlfeed-' . $xml_format . ':' . ($user_info['is_guest'] ? '' : $user_info['id'] . '-') . $cachekey, 240); |
|
221 | + if (!empty($modSettings['cache_enable']) && (!$user_info['is_guest'] || $modSettings['cache_enable'] >= 3)) { |
|
222 | + $xml_data = cache_get_data('xmlfeed-' . $xml_format . ':' . ($user_info['is_guest'] ? '' : $user_info['id'] . '-') . $cachekey, 240); |
|
223 | + } |
|
213 | 224 | if (empty($xml_data)) |
214 | 225 | { |
215 | 226 | $call = call_helper($subActions[$_GET['sa']][0], true); |
216 | 227 | |
217 | - if (!empty($call)) |
|
218 | - $xml_data = call_user_func($call, $xml_format); |
|
228 | + if (!empty($call)) { |
|
229 | + $xml_data = call_user_func($call, $xml_format); |
|
230 | + } |
|
219 | 231 | |
220 | 232 | if (!empty($modSettings['cache_enable']) && (($user_info['is_guest'] && $modSettings['cache_enable'] >= 3) |
221 | - || (!$user_info['is_guest'] && (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $cache_t)) > 0.2)))) |
|
222 | - cache_put_data('xmlfeed-' . $xml_format . ':' . ($user_info['is_guest'] ? '' : $user_info['id'] . '-') . $cachekey, $xml_data, 240); |
|
233 | + || (!$user_info['is_guest'] && (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $cache_t)) > 0.2)))) { |
|
234 | + cache_put_data('xmlfeed-' . $xml_format . ':' . ($user_info['is_guest'] ? '' : $user_info['id'] . '-') . $cachekey, $xml_data, 240); |
|
235 | + } |
|
223 | 236 | } |
224 | 237 | |
225 | 238 | $feed_meta['title'] = $smcFunc['htmlspecialchars'](strip_tags($context['forum_name'])) . (isset($feed_meta['title']) ? $feed_meta['title'] : ''); |
@@ -259,43 +272,49 @@ discard block |
||
259 | 272 | call_integration_hook('integrate_xml_data', array(&$xml_data, &$feed_meta, &$namespaces, &$extraFeedTags, &$forceCdataKeys, &$nsKeys, $xml_format, $_GET['sa'])); |
260 | 273 | |
261 | 274 | // These can't be empty |
262 | - foreach (array('title', 'desc', 'source') as $mkey) |
|
263 | - $feed_meta[$mkey] = !empty($feed_meta[$mkey]) ? $feed_meta[$mkey] : $orig_feed_meta[$mkey]; |
|
275 | + foreach (array('title', 'desc', 'source') as $mkey) { |
|
276 | + $feed_meta[$mkey] = !empty($feed_meta[$mkey]) ? $feed_meta[$mkey] : $orig_feed_meta[$mkey]; |
|
277 | + } |
|
264 | 278 | |
265 | 279 | // Sanitize basic feed metadata values |
266 | - foreach ($feed_meta as $mkey => $mvalue) |
|
267 | - $feed_meta[$mkey] = cdata_parse(strip_tags(fix_possible_url($feed_meta[$mkey]))); |
|
280 | + foreach ($feed_meta as $mkey => $mvalue) { |
|
281 | + $feed_meta[$mkey] = cdata_parse(strip_tags(fix_possible_url($feed_meta[$mkey]))); |
|
282 | + } |
|
268 | 283 | |
269 | 284 | $ns_string = ''; |
270 | 285 | if (!empty($namespaces[$xml_format])) |
271 | 286 | { |
272 | - foreach ($namespaces[$xml_format] as $nsprefix => $nsurl) |
|
273 | - $ns_string .= ' xmlns' . ($nsprefix !== '' ? ':' : '') . $nsprefix . '="' . $nsurl . '"'; |
|
287 | + foreach ($namespaces[$xml_format] as $nsprefix => $nsurl) { |
|
288 | + $ns_string .= ' xmlns' . ($nsprefix !== '' ? ':' : '') . $nsprefix . '="' . $nsurl . '"'; |
|
289 | + } |
|
274 | 290 | } |
275 | 291 | |
276 | 292 | $extraFeedTags_string = ''; |
277 | 293 | if (!empty($extraFeedTags[$xml_format])) |
278 | 294 | { |
279 | 295 | $indent = "\t" . ($xml_format !== 'atom' ? "\t" : ''); |
280 | - foreach ($extraFeedTags[$xml_format] as $extraTag) |
|
281 | - $extraFeedTags_string .= "\n" . $indent . $extraTag; |
|
296 | + foreach ($extraFeedTags[$xml_format] as $extraTag) { |
|
297 | + $extraFeedTags_string .= "\n" . $indent . $extraTag; |
|
298 | + } |
|
282 | 299 | } |
283 | 300 | |
284 | 301 | // This is an xml file.... |
285 | 302 | ob_end_clean(); |
286 | - if (!empty($modSettings['enableCompressedOutput'])) |
|
287 | - @ob_start('ob_gzhandler'); |
|
288 | - else |
|
289 | - ob_start(); |
|
303 | + if (!empty($modSettings['enableCompressedOutput'])) { |
|
304 | + @ob_start('ob_gzhandler'); |
|
305 | + } else { |
|
306 | + ob_start(); |
|
307 | + } |
|
290 | 308 | |
291 | - if ($xml_format == 'smf' || isset($_REQUEST['debug'])) |
|
292 | - header('Content-Type: text/xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
293 | - elseif ($xml_format == 'rss' || $xml_format == 'rss2') |
|
294 | - header('Content-Type: application/rss+xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
295 | - elseif ($xml_format == 'atom') |
|
296 | - header('Content-Type: application/atom+xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
297 | - elseif ($xml_format == 'rdf') |
|
298 | - header('Content-Type: ' . (isBrowser('ie') ? 'text/xml' : 'application/rdf+xml') . '; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
309 | + if ($xml_format == 'smf' || isset($_REQUEST['debug'])) { |
|
310 | + header('Content-Type: text/xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
311 | + } elseif ($xml_format == 'rss' || $xml_format == 'rss2') { |
|
312 | + header('Content-Type: application/rss+xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
313 | + } elseif ($xml_format == 'atom') { |
|
314 | + header('Content-Type: application/atom+xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
315 | + } elseif ($xml_format == 'rdf') { |
|
316 | + header('Content-Type: ' . (isBrowser('ie') ? 'text/xml' : 'application/rdf+xml') . '; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
317 | + } |
|
299 | 318 | |
300 | 319 | // First, output the xml header. |
301 | 320 | echo '<?xml version="1.0" encoding="', $context['character_set'], '"?' . '>'; |
@@ -303,10 +322,11 @@ discard block |
||
303 | 322 | // Are we outputting an rss feed or one with more information? |
304 | 323 | if ($xml_format == 'rss' || $xml_format == 'rss2') |
305 | 324 | { |
306 | - if ($xml_format == 'rss2') |
|
307 | - foreach ($_REQUEST as $var => $val) |
|
325 | + if ($xml_format == 'rss2') { |
|
326 | + foreach ($_REQUEST as $var => $val) |
|
308 | 327 | if (in_array($var, array('action', 'sa', 'type', 'board', 'boards', 'c', 'u', 'limit'))) |
309 | 328 | $url_parts[] = $var . '=' . (is_array($val) ? implode(',', $val) : $val); |
329 | + } |
|
310 | 330 | |
311 | 331 | // Start with an RSS 2.0 header. |
312 | 332 | echo ' |
@@ -327,9 +347,10 @@ discard block |
||
327 | 347 | <language>' . $feed_meta['language'] . '</language>' : ''; |
328 | 348 | |
329 | 349 | // RSS2 calls for this. |
330 | - if ($xml_format == 'rss2') |
|
331 | - echo ' |
|
350 | + if ($xml_format == 'rss2') { |
|
351 | + echo ' |
|
332 | 352 | <atom:link rel="self" type="application/rss+xml" href="', $scripturl, !empty($url_parts) ? '?' . implode(';', $url_parts) : '', '" />'; |
353 | + } |
|
333 | 354 | |
334 | 355 | echo $extraFeedTags_string; |
335 | 356 | |
@@ -340,12 +361,12 @@ discard block |
||
340 | 361 | echo ' |
341 | 362 | </channel> |
342 | 363 | </rss>'; |
343 | - } |
|
344 | - elseif ($xml_format == 'atom') |
|
364 | + } elseif ($xml_format == 'atom') |
|
345 | 365 | { |
346 | - foreach ($_REQUEST as $var => $val) |
|
347 | - if (in_array($var, array('action', 'sa', 'type', 'board', 'boards', 'c', 'u', 'limit'))) |
|
366 | + foreach ($_REQUEST as $var => $val) { |
|
367 | + if (in_array($var, array('action', 'sa', 'type', 'board', 'boards', 'c', 'u', 'limit'))) |
|
348 | 368 | $url_parts[] = $var . '=' . (is_array($val) ? implode(',', $val) : $val); |
369 | + } |
|
349 | 370 | |
350 | 371 | echo ' |
351 | 372 | <feed', $ns_string, !empty($feed_meta['language']) ? ' xml:lang="' . $feed_meta['language'] . '"' : '', '> |
@@ -371,8 +392,7 @@ discard block |
||
371 | 392 | |
372 | 393 | echo ' |
373 | 394 | </feed>'; |
374 | - } |
|
375 | - elseif ($xml_format == 'rdf') |
|
395 | + } elseif ($xml_format == 'rdf') |
|
376 | 396 | { |
377 | 397 | echo ' |
378 | 398 | <rdf:RDF', $ns_string, '> |
@@ -437,13 +457,15 @@ discard block |
||
437 | 457 | { |
438 | 458 | global $modSettings, $context, $scripturl; |
439 | 459 | |
440 | - if (substr($val, 0, strlen($scripturl)) != $scripturl) |
|
441 | - return $val; |
|
460 | + if (substr($val, 0, strlen($scripturl)) != $scripturl) { |
|
461 | + return $val; |
|
462 | + } |
|
442 | 463 | |
443 | 464 | call_integration_hook('integrate_fix_url', array(&$val)); |
444 | 465 | |
445 | - if (empty($modSettings['queryless_urls']) || ($context['server']['is_cgi'] && ini_get('cgi.fix_pathinfo') == 0 && @get_cfg_var('cgi.fix_pathinfo') == 0) || (!$context['server']['is_apache'] && !$context['server']['is_lighttpd'])) |
|
446 | - return $val; |
|
466 | + if (empty($modSettings['queryless_urls']) || ($context['server']['is_cgi'] && ini_get('cgi.fix_pathinfo') == 0 && @get_cfg_var('cgi.fix_pathinfo') == 0) || (!$context['server']['is_apache'] && !$context['server']['is_lighttpd'])) { |
|
467 | + return $val; |
|
468 | + } |
|
447 | 469 | |
448 | 470 | $val = preg_replace_callback('~\b' . preg_quote($scripturl, '~') . '\?((?:board|topic)=[^#"]+)(#[^"]*)?$~', function($m) use ($scripturl) |
449 | 471 | { |
@@ -466,8 +488,9 @@ discard block |
||
466 | 488 | global $smcFunc; |
467 | 489 | |
468 | 490 | // Do we even need to do this? |
469 | - if (strpbrk($data, '<>&') == false && $force !== true) |
|
470 | - return $data; |
|
491 | + if (strpbrk($data, '<>&') == false && $force !== true) { |
|
492 | + return $data; |
|
493 | + } |
|
471 | 494 | |
472 | 495 | $cdata = '<, |
478 | 501 | $smcFunc['strpos']($data, ']', $pos), |
479 | 502 | ); |
480 | - if ($ns != '') |
|
481 | - $positions[] = $smcFunc['strpos']($data, '<', $pos); |
|
503 | + if ($ns != '') { |
|
504 | + $positions[] = $smcFunc['strpos']($data, '<', $pos); |
|
505 | + } |
|
482 | 506 | foreach ($positions as $k => $dummy) |
483 | 507 | { |
484 | - if ($dummy === false) |
|
485 | - unset($positions[$k]); |
|
508 | + if ($dummy === false) { |
|
509 | + unset($positions[$k]); |
|
510 | + } |
|
486 | 511 | } |
487 | 512 | |
488 | 513 | $old = $pos; |
489 | 514 | $pos = empty($positions) ? $n : min($positions); |
490 | 515 | |
491 | - if ($pos - $old > 0) |
|
492 | - $cdata .= $smcFunc['substr']($data, $old, $pos - $old); |
|
493 | - if ($pos >= $n) |
|
494 | - break; |
|
516 | + if ($pos - $old > 0) { |
|
517 | + $cdata .= $smcFunc['substr']($data, $old, $pos - $old); |
|
518 | + } |
|
519 | + if ($pos >= $n) { |
|
520 | + break; |
|
521 | + } |
|
495 | 522 | |
496 | 523 | if ($smcFunc['substr']($data, $pos, 1) == '<') |
497 | 524 | { |
498 | 525 | $pos2 = $smcFunc['strpos']($data, '>', $pos); |
499 | - if ($pos2 === false) |
|
500 | - $pos2 = $n; |
|
501 | - if ($smcFunc['substr']($data, $pos + 1, 1) == '/') |
|
502 | - $cdata .= ']]></' . $ns . ':' . $smcFunc['substr']($data, $pos + 2, $pos2 - $pos - 1) . '<![CDATA['; |
|
503 | - else |
|
504 | - $cdata .= ']]><' . $ns . ':' . $smcFunc['substr']($data, $pos + 1, $pos2 - $pos) . '< == '/') { |
|
530 | + $cdata .= ']]></' . $ns . ':' . $smcFunc['substr']($data, $pos + 2, $pos2 - $pos - 1) . '<![CDATA['; |
|
531 | + } else { |
|
532 | + $cdata .= ']]><' . $ns . ':' . $smcFunc['substr']($data, $pos + 1, $pos2 - $pos) . '< == ']') |
|
535 | + } elseif ($smcFunc['substr']($data, $pos, 1) == ']') |
|
508 | 536 | { |
509 | 537 | $cdata .= ']]>]< == '&') |
|
539 | + } elseif ($smcFunc['substr']($data, $pos, 1) == '&') |
|
513 | 540 | { |
514 | 541 | $pos2 = $smcFunc['strpos']($data, ';', $pos); |
515 | - if ($pos2 === false) |
|
516 | - $pos2 = $n; |
|
542 | + if ($pos2 === false) { |
|
543 | + $pos2 = $n; |
|
544 | + } |
|
517 | 545 | $ent = $smcFunc['substr']($data, $pos + 1, $pos2 - $pos - 1); |
518 | 546 | |
519 | - if ($smcFunc['substr']($data, $pos + 1, 1) == '#') |
|
520 | - $cdata .= ']]>' . $smcFunc['substr']($data, $pos, $pos2 - $pos + 1) . '<![CDATA['; |
|
521 | - elseif (in_array($ent, array('amp', 'lt', 'gt', 'quot'))) |
|
522 | - $cdata .= ']]>' . $smcFunc['substr']($data, $pos, $pos2 - $pos + 1) . '< == '#') { |
|
548 | + $cdata .= ']]>' . $smcFunc['substr']($data, $pos, $pos2 - $pos + 1) . '<![CDATA['; |
|
549 | + } elseif (in_array($ent, array('amp', 'lt', 'gt', 'quot'))) { |
|
550 | + $cdata .= ']]>' . $smcFunc['substr']($data, $pos, $pos2 - $pos + 1) . '<![CDATA['; |
|
551 | + } |
|
523 | 552 | |
524 | 553 | $pos = $pos2 + 1; |
525 | 554 | } |
@@ -558,8 +587,9 @@ discard block |
||
558 | 587 | 'gender', |
559 | 588 | 'blurb', |
560 | 589 | ); |
561 | - if ($xml_format != 'atom') |
|
562 | - $keysToCdata[] = 'category'; |
|
590 | + if ($xml_format != 'atom') { |
|
591 | + $keysToCdata[] = 'category'; |
|
592 | + } |
|
563 | 593 | |
564 | 594 | if (!empty($forceCdataKeys)) |
565 | 595 | { |
@@ -576,8 +606,9 @@ discard block |
||
576 | 606 | $attrs = isset($element['attributes']) ? $element['attributes'] : null; |
577 | 607 | |
578 | 608 | // Skip it, it's been set to null. |
579 | - if ($key === null || ($val === null && $attrs === null)) |
|
580 | - continue; |
|
609 | + if ($key === null || ($val === null && $attrs === null)) { |
|
610 | + continue; |
|
611 | + } |
|
581 | 612 | |
582 | 613 | $forceCdata = in_array($key, $forceCdataKeys); |
583 | 614 | $ns = !empty($nsKeys[$key]) ? $nsKeys[$key] : ''; |
@@ -590,16 +621,16 @@ discard block |
||
590 | 621 | |
591 | 622 | if (!empty($attrs)) |
592 | 623 | { |
593 | - foreach ($attrs as $attr_key => $attr_value) |
|
594 | - echo ' ', $attr_key, '="', fix_possible_url($attr_value), '"'; |
|
624 | + foreach ($attrs as $attr_key => $attr_value) { |
|
625 | + echo ' ', $attr_key, '="', fix_possible_url($attr_value), '"'; |
|
626 | + } |
|
595 | 627 | } |
596 | 628 | |
597 | 629 | // If it's empty, simply output an empty element. |
598 | 630 | if (empty($val)) |
599 | 631 | { |
600 | 632 | echo ' />'; |
601 | - } |
|
602 | - else |
|
633 | + } else |
|
603 | 634 | { |
604 | 635 | echo '>'; |
605 | 636 | |
@@ -611,11 +642,13 @@ discard block |
||
611 | 642 | echo "\n", str_repeat("\t", $i); |
612 | 643 | } |
613 | 644 | // A string with returns in it.... show this as a multiline element. |
614 | - elseif (strpos($val, "\n") !== false) |
|
615 | - echo "\n", in_array($key, $keysToCdata) ? cdata_parse(fix_possible_url($val), $ns, $forceCdata) : fix_possible_url($val), "\n", str_repeat("\t", $i); |
|
645 | + elseif (strpos($val, "\n") !== false) { |
|
646 | + echo "\n", in_array($key, $keysToCdata) ? cdata_parse(fix_possible_url($val), $ns, $forceCdata) : fix_possible_url($val), "\n", str_repeat("\t", $i); |
|
647 | + } |
|
616 | 648 | // A simple string. |
617 | - else |
|
618 | - echo in_array($key, $keysToCdata) ? cdata_parse(fix_possible_url($val), $ns, $forceCdata) : fix_possible_url($val); |
|
649 | + else { |
|
650 | + echo in_array($key, $keysToCdata) ? cdata_parse(fix_possible_url($val), $ns, $forceCdata) : fix_possible_url($val); |
|
651 | + } |
|
619 | 652 | |
620 | 653 | // Ending tag. |
621 | 654 | echo '</', $key, '>'; |
@@ -635,8 +668,9 @@ discard block |
||
635 | 668 | { |
636 | 669 | global $scripturl, $smcFunc; |
637 | 670 | |
638 | - if (!allowedTo('view_mlist')) |
|
639 | - return array(); |
|
671 | + if (!allowedTo('view_mlist')) { |
|
672 | + return array(); |
|
673 | + } |
|
640 | 674 | |
641 | 675 | // Find the most recent members. |
642 | 676 | $request = $smcFunc['db_query']('', ' |
@@ -655,8 +689,8 @@ discard block |
||
655 | 689 | $guid = 'tag:' . parse_url($scripturl, PHP_URL_HOST) . ',' . gmdate('Y-m-d', $row['date_registered']) . ':member=' . $row['id_member']; |
656 | 690 | |
657 | 691 | // Make the data look rss-ish. |
658 | - if ($xml_format == 'rss' || $xml_format == 'rss2') |
|
659 | - $data[] = array( |
|
692 | + if ($xml_format == 'rss' || $xml_format == 'rss2') { |
|
693 | + $data[] = array( |
|
660 | 694 | 'tag' => 'item', |
661 | 695 | 'content' => array( |
662 | 696 | array( |
@@ -684,8 +718,8 @@ discard block |
||
684 | 718 | ), |
685 | 719 | ), |
686 | 720 | ); |
687 | - elseif ($xml_format == 'rdf') |
|
688 | - $data[] = array( |
|
721 | + } elseif ($xml_format == 'rdf') { |
|
722 | + $data[] = array( |
|
689 | 723 | 'tag' => 'item', |
690 | 724 | 'attributes' => array('rdf:about' => $scripturl . '?action=profile;u=' . $row['id_member']), |
691 | 725 | 'content' => array( |
@@ -703,8 +737,8 @@ discard block |
||
703 | 737 | ), |
704 | 738 | ), |
705 | 739 | ); |
706 | - elseif ($xml_format == 'atom') |
|
707 | - $data[] = array( |
|
740 | + } elseif ($xml_format == 'atom') { |
|
741 | + $data[] = array( |
|
708 | 742 | 'tag' => 'entry', |
709 | 743 | 'content' => array( |
710 | 744 | array( |
@@ -733,9 +767,10 @@ discard block |
||
733 | 767 | ), |
734 | 768 | ), |
735 | 769 | ); |
770 | + } |
|
736 | 771 | // More logical format for the data, but harder to apply. |
737 | - else |
|
738 | - $data[] = array( |
|
772 | + else { |
|
773 | + $data[] = array( |
|
739 | 774 | 'tag' => 'member', |
740 | 775 | 'content' => array( |
741 | 776 | array( |
@@ -756,6 +791,7 @@ discard block |
||
756 | 791 | ), |
757 | 792 | ), |
758 | 793 | ); |
794 | + } |
|
759 | 795 | } |
760 | 796 | $smcFunc['db_free_result']($request); |
761 | 797 | |
@@ -816,22 +852,24 @@ discard block |
||
816 | 852 | if ($loops < 2 && $smcFunc['db_num_rows']($request) < $_GET['limit']) |
817 | 853 | { |
818 | 854 | $smcFunc['db_free_result']($request); |
819 | - if (empty($_REQUEST['boards']) && empty($board)) |
|
820 | - unset($context['optimize_msg']['lowest']); |
|
821 | - else |
|
822 | - $context['optimize_msg']['lowest'] = 'm.id_msg >= t.id_first_msg'; |
|
855 | + if (empty($_REQUEST['boards']) && empty($board)) { |
|
856 | + unset($context['optimize_msg']['lowest']); |
|
857 | + } else { |
|
858 | + $context['optimize_msg']['lowest'] = 'm.id_msg >= t.id_first_msg'; |
|
859 | + } |
|
823 | 860 | $context['optimize_msg']['highest'] = 'm.id_msg <= t.id_last_msg'; |
824 | 861 | $loops++; |
862 | + } else { |
|
863 | + $done = true; |
|
825 | 864 | } |
826 | - else |
|
827 | - $done = true; |
|
828 | 865 | } |
829 | 866 | $data = array(); |
830 | 867 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
831 | 868 | { |
832 | 869 | // Limit the length of the message, if the option is set. |
833 | - if (!empty($modSettings['xmlnews_maxlen']) && $smcFunc['strlen'](str_replace('<br>', "\n", $row['body'])) > $modSettings['xmlnews_maxlen']) |
|
834 | - $row['body'] = strtr($smcFunc['substr'](str_replace('<br>', "\n", $row['body']), 0, $modSettings['xmlnews_maxlen'] - 3), array("\n" => '<br>')) . '...'; |
|
870 | + if (!empty($modSettings['xmlnews_maxlen']) && $smcFunc['strlen'](str_replace('<br>', "\n", $row['body'])) > $modSettings['xmlnews_maxlen']) { |
|
871 | + $row['body'] = strtr($smcFunc['substr'](str_replace('<br>', "\n", $row['body']), 0, $modSettings['xmlnews_maxlen'] - 3), array("\n" => '<br>')) . '...'; |
|
872 | + } |
|
835 | 873 | |
836 | 874 | $row['body'] = parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']); |
837 | 875 | |
@@ -858,8 +896,9 @@ discard block |
||
858 | 896 | while ($attach = $smcFunc['db_fetch_assoc']($attach_request)) |
859 | 897 | { |
860 | 898 | // Include approved attachments only |
861 | - if ($attach['approved']) |
|
862 | - $loaded_attachments['attachment_' . $attach['id_attach']] = $attach; |
|
899 | + if ($attach['approved']) { |
|
900 | + $loaded_attachments['attachment_' . $attach['id_attach']] = $attach; |
|
901 | + } |
|
863 | 902 | } |
864 | 903 | $smcFunc['db_free_result']($attach_request); |
865 | 904 | |
@@ -867,16 +906,17 @@ discard block |
||
867 | 906 | if (!empty($loaded_attachments)) |
868 | 907 | { |
869 | 908 | uasort($loaded_attachments, function($a, $b) { |
870 | - if ($a['filesize'] == $b['filesize']) |
|
871 | - return 0; |
|
909 | + if ($a['filesize'] == $b['filesize']) { |
|
910 | + return 0; |
|
911 | + } |
|
872 | 912 | return ($a['filesize'] < $b['filesize']) ? -1 : 1; |
873 | 913 | }); |
914 | + } else { |
|
915 | + $loaded_attachments = null; |
|
874 | 916 | } |
875 | - else |
|
876 | - $loaded_attachments = null; |
|
917 | + } else { |
|
918 | + $loaded_attachments = null; |
|
877 | 919 | } |
878 | - else |
|
879 | - $loaded_attachments = null; |
|
880 | 920 | |
881 | 921 | // Create a GUID for this topic using the tag URI scheme |
882 | 922 | $guid = 'tag:' . parse_url($scripturl, PHP_URL_HOST) . ',' . gmdate('Y-m-d', $row['poster_time']) . ':topic=' . $row['id_topic']; |
@@ -893,9 +933,9 @@ discard block |
||
893 | 933 | 'length' => $attachment['filesize'], |
894 | 934 | 'type' => $attachment['mime_type'], |
895 | 935 | ); |
936 | + } else { |
|
937 | + $enclosure = null; |
|
896 | 938 | } |
897 | - else |
|
898 | - $enclosure = null; |
|
899 | 939 | |
900 | 940 | $data[] = array( |
901 | 941 | 'tag' => 'item', |
@@ -941,8 +981,7 @@ discard block |
||
941 | 981 | ), |
942 | 982 | ), |
943 | 983 | ); |
944 | - } |
|
945 | - elseif ($xml_format == 'rdf') |
|
984 | + } elseif ($xml_format == 'rdf') |
|
946 | 985 | { |
947 | 986 | $data[] = array( |
948 | 987 | 'tag' => 'item', |
@@ -966,8 +1005,7 @@ discard block |
||
966 | 1005 | ), |
967 | 1006 | ), |
968 | 1007 | ); |
969 | - } |
|
970 | - elseif ($xml_format == 'atom') |
|
1008 | + } elseif ($xml_format == 'atom') |
|
971 | 1009 | { |
972 | 1010 | // Only one attachment allowed |
973 | 1011 | if (!empty($loaded_attachments)) |
@@ -979,9 +1017,9 @@ discard block |
||
979 | 1017 | 'length' => $attachment['filesize'], |
980 | 1018 | 'type' => $attachment['mime_type'], |
981 | 1019 | ); |
1020 | + } else { |
|
1021 | + $enclosure = null; |
|
982 | 1022 | } |
983 | - else |
|
984 | - $enclosure = null; |
|
985 | 1023 | |
986 | 1024 | $data[] = array( |
987 | 1025 | 'tag' => 'entry', |
@@ -1081,9 +1119,9 @@ discard block |
||
1081 | 1119 | ) |
1082 | 1120 | ); |
1083 | 1121 | } |
1122 | + } else { |
|
1123 | + $attachments = null; |
|
1084 | 1124 | } |
1085 | - else |
|
1086 | - $attachments = null; |
|
1087 | 1125 | |
1088 | 1126 | $data[] = array( |
1089 | 1127 | 'tag' => 'article', |
@@ -1201,22 +1239,25 @@ discard block |
||
1201 | 1239 | if ($loops < 2 && $smcFunc['db_num_rows']($request) < $_GET['limit']) |
1202 | 1240 | { |
1203 | 1241 | $smcFunc['db_free_result']($request); |
1204 | - if (empty($_REQUEST['boards']) && empty($board)) |
|
1205 | - unset($context['optimize_msg']['lowest']); |
|
1206 | - else |
|
1207 | - $context['optimize_msg']['lowest'] = $loops ? 'm.id_msg >= t.id_first_msg' : 'm.id_msg >= (t.id_last_msg - t.id_first_msg) / 2'; |
|
1242 | + if (empty($_REQUEST['boards']) && empty($board)) { |
|
1243 | + unset($context['optimize_msg']['lowest']); |
|
1244 | + } else { |
|
1245 | + $context['optimize_msg']['lowest'] = $loops ? 'm.id_msg >= t.id_first_msg' : 'm.id_msg >= (t.id_last_msg - t.id_first_msg) / 2'; |
|
1246 | + } |
|
1208 | 1247 | $loops++; |
1248 | + } else { |
|
1249 | + $done = true; |
|
1209 | 1250 | } |
1210 | - else |
|
1211 | - $done = true; |
|
1212 | 1251 | } |
1213 | 1252 | $messages = array(); |
1214 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1215 | - $messages[] = $row['id_msg']; |
|
1253 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1254 | + $messages[] = $row['id_msg']; |
|
1255 | + } |
|
1216 | 1256 | $smcFunc['db_free_result']($request); |
1217 | 1257 | |
1218 | - if (empty($messages)) |
|
1219 | - return array(); |
|
1258 | + if (empty($messages)) { |
|
1259 | + return array(); |
|
1260 | + } |
|
1220 | 1261 | |
1221 | 1262 | // Find the most recent posts this user can see. |
1222 | 1263 | $request = $smcFunc['db_query']('', ' |
@@ -1246,8 +1287,9 @@ discard block |
||
1246 | 1287 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1247 | 1288 | { |
1248 | 1289 | // Limit the length of the message, if the option is set. |
1249 | - if (!empty($modSettings['xmlnews_maxlen']) && $smcFunc['strlen'](str_replace('<br>', "\n", $row['body'])) > $modSettings['xmlnews_maxlen']) |
|
1250 | - $row['body'] = strtr($smcFunc['substr'](str_replace('<br>', "\n", $row['body']), 0, $modSettings['xmlnews_maxlen'] - 3), array("\n" => '<br>')) . '...'; |
|
1290 | + if (!empty($modSettings['xmlnews_maxlen']) && $smcFunc['strlen'](str_replace('<br>', "\n", $row['body'])) > $modSettings['xmlnews_maxlen']) { |
|
1291 | + $row['body'] = strtr($smcFunc['substr'](str_replace('<br>', "\n", $row['body']), 0, $modSettings['xmlnews_maxlen'] - 3), array("\n" => '<br>')) . '...'; |
|
1292 | + } |
|
1251 | 1293 | |
1252 | 1294 | $row['body'] = parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']); |
1253 | 1295 | |
@@ -1274,8 +1316,9 @@ discard block |
||
1274 | 1316 | while ($attach = $smcFunc['db_fetch_assoc']($attach_request)) |
1275 | 1317 | { |
1276 | 1318 | // Include approved attachments only |
1277 | - if ($attach['approved']) |
|
1278 | - $loaded_attachments['attachment_' . $attach['id_attach']] = $attach; |
|
1319 | + if ($attach['approved']) { |
|
1320 | + $loaded_attachments['attachment_' . $attach['id_attach']] = $attach; |
|
1321 | + } |
|
1279 | 1322 | } |
1280 | 1323 | $smcFunc['db_free_result']($attach_request); |
1281 | 1324 | |
@@ -1283,16 +1326,17 @@ discard block |
||
1283 | 1326 | if (!empty($loaded_attachments)) |
1284 | 1327 | { |
1285 | 1328 | uasort($loaded_attachments, function($a, $b) { |
1286 | - if ($a['filesize'] == $b['filesize']) |
|
1287 | - return 0; |
|
1329 | + if ($a['filesize'] == $b['filesize']) { |
|
1330 | + return 0; |
|
1331 | + } |
|
1288 | 1332 | return ($a['filesize'] < $b['filesize']) ? -1 : 1; |
1289 | 1333 | }); |
1334 | + } else { |
|
1335 | + $loaded_attachments = null; |
|
1290 | 1336 | } |
1291 | - else |
|
1292 | - $loaded_attachments = null; |
|
1337 | + } else { |
|
1338 | + $loaded_attachments = null; |
|
1293 | 1339 | } |
1294 | - else |
|
1295 | - $loaded_attachments = null; |
|
1296 | 1340 | |
1297 | 1341 | // Create a GUID for this post using the tag URI scheme |
1298 | 1342 | $guid = 'tag:' . parse_url($scripturl, PHP_URL_HOST) . ',' . gmdate('Y-m-d', $row['poster_time']) . ':msg=' . $row['id_msg']; |
@@ -1309,9 +1353,9 @@ discard block |
||
1309 | 1353 | 'length' => $attachment['filesize'], |
1310 | 1354 | 'type' => $attachment['mime_type'], |
1311 | 1355 | ); |
1356 | + } else { |
|
1357 | + $enclosure = null; |
|
1312 | 1358 | } |
1313 | - else |
|
1314 | - $enclosure = null; |
|
1315 | 1359 | |
1316 | 1360 | $data[] = array( |
1317 | 1361 | 'tag' => 'item', |
@@ -1357,8 +1401,7 @@ discard block |
||
1357 | 1401 | ), |
1358 | 1402 | ), |
1359 | 1403 | ); |
1360 | - } |
|
1361 | - elseif ($xml_format == 'rdf') |
|
1404 | + } elseif ($xml_format == 'rdf') |
|
1362 | 1405 | { |
1363 | 1406 | $data[] = array( |
1364 | 1407 | 'tag' => 'item', |
@@ -1382,8 +1425,7 @@ discard block |
||
1382 | 1425 | ), |
1383 | 1426 | ), |
1384 | 1427 | ); |
1385 | - } |
|
1386 | - elseif ($xml_format == 'atom') |
|
1428 | + } elseif ($xml_format == 'atom') |
|
1387 | 1429 | { |
1388 | 1430 | // Only one attachment allowed |
1389 | 1431 | if (!empty($loaded_attachments)) |
@@ -1395,9 +1437,9 @@ discard block |
||
1395 | 1437 | 'length' => $attachment['filesize'], |
1396 | 1438 | 'type' => $attachment['mime_type'], |
1397 | 1439 | ); |
1440 | + } else { |
|
1441 | + $enclosure = null; |
|
1398 | 1442 | } |
1399 | - else |
|
1400 | - $enclosure = null; |
|
1401 | 1443 | |
1402 | 1444 | $data[] = array( |
1403 | 1445 | 'tag' => 'entry', |
@@ -1497,9 +1539,9 @@ discard block |
||
1497 | 1539 | ) |
1498 | 1540 | ); |
1499 | 1541 | } |
1542 | + } else { |
|
1543 | + $attachments = null; |
|
1500 | 1544 | } |
1501 | - else |
|
1502 | - $attachments = null; |
|
1503 | 1545 | |
1504 | 1546 | $data[] = array( |
1505 | 1547 | 'tag' => 'recent-post', |
@@ -1618,14 +1660,16 @@ discard block |
||
1618 | 1660 | global $scripturl, $memberContext, $user_profile, $user_info; |
1619 | 1661 | |
1620 | 1662 | // You must input a valid user.... |
1621 | - if (empty($_GET['u']) || !loadMemberData((int) $_GET['u'])) |
|
1622 | - return array(); |
|
1663 | + if (empty($_GET['u']) || !loadMemberData((int) $_GET['u'])) { |
|
1664 | + return array(); |
|
1665 | + } |
|
1623 | 1666 | |
1624 | 1667 | // Make sure the id is a number and not "I like trying to hack the database". |
1625 | 1668 | $_GET['u'] = (int) $_GET['u']; |
1626 | 1669 | // Load the member's contextual information! |
1627 | - if (!loadMemberContext($_GET['u']) || !allowedTo('profile_view')) |
|
1628 | - return array(); |
|
1670 | + if (!loadMemberContext($_GET['u']) || !allowedTo('profile_view')) { |
|
1671 | + return array(); |
|
1672 | + } |
|
1629 | 1673 | |
1630 | 1674 | // Okay, I admit it, I'm lazy. Stupid $_GET['u'] is long and hard to type. |
1631 | 1675 | $profile = &$memberContext[$_GET['u']]; |
@@ -1667,8 +1711,7 @@ discard block |
||
1667 | 1711 | ), |
1668 | 1712 | ) |
1669 | 1713 | ); |
1670 | - } |
|
1671 | - elseif ($xml_format == 'rdf') |
|
1714 | + } elseif ($xml_format == 'rdf') |
|
1672 | 1715 | { |
1673 | 1716 | $data[] = array( |
1674 | 1717 | 'tag' => 'item', |
@@ -1692,8 +1735,7 @@ discard block |
||
1692 | 1735 | ), |
1693 | 1736 | ) |
1694 | 1737 | ); |
1695 | - } |
|
1696 | - elseif ($xml_format == 'atom') |
|
1738 | + } elseif ($xml_format == 'atom') |
|
1697 | 1739 | { |
1698 | 1740 | $data[] = array( |
1699 | 1741 | 'tag' => 'entry', |
@@ -1746,8 +1788,7 @@ discard block |
||
1746 | 1788 | ), |
1747 | 1789 | ) |
1748 | 1790 | ); |
1749 | - } |
|
1750 | - else |
|
1791 | + } else |
|
1751 | 1792 | { |
1752 | 1793 | $data = array( |
1753 | 1794 | array( |
@@ -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'] == 'viewweek') |
|
43 | + } elseif ($context['calendar_view'] == 'viewweek') |
|
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,19 +405,21 @@ 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 | - elseif ($is_mini) |
|
398 | - echo '<a href="', $scripturl, '?action=calendar;', $context['calendar_view'], ';year=', $calendar_data['current_year'], ';month=', $calendar_data['current_month'], ';day=', $day['day'], '"><span class="day_text">', $title_prefix, $day['day'], '</span></a>'; |
|
399 | - else |
|
400 | - 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 | + } elseif ($is_mini) { |
|
411 | + echo '<a href="', $scripturl, '?action=calendar;', $context['calendar_view'], ';year=', $calendar_data['current_year'], ';month=', $calendar_data['current_month'], ';day=', $day['day'], '"><span class="day_text">', $title_prefix, $day['day'], '</span></a>'; |
|
412 | + } else { |
|
413 | + echo '<span class="day_text">', $title_prefix, $day['day'], '</span>'; |
|
414 | + } |
|
401 | 415 | |
402 | 416 | // A lot of stuff, we're not showing on mini-calendars to conserve space. |
403 | 417 | if ($is_mini === false) |
404 | 418 | { |
405 | 419 | // Holidays are always fun, let's show them! |
406 | - if (!empty($day['holidays'])) |
|
407 | - echo '<div class="smalltext holiday"><span>', $txt['calendar_prompt'], '</span> ', implode(', ', $day['holidays']), '</div>'; |
|
420 | + if (!empty($day['holidays'])) { |
|
421 | + echo '<div class="smalltext holiday"><span>', $txt['calendar_prompt'], '</span> ', implode(', ', $day['holidays']), '</div>'; |
|
422 | + } |
|
408 | 423 | |
409 | 424 | // Happy Birthday Dear, Member! |
410 | 425 | if (!empty($day['birthdays'])) |
@@ -422,14 +437,16 @@ discard block |
||
422 | 437 | 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) ? '' : ', '; |
423 | 438 | |
424 | 439 | // 9...10! Let's stop there. |
425 | - if ($birthday_count == 10 && $use_js_hide) |
|
426 | - // !!TODO - Inline CSS and JavaScript should be moved. |
|
440 | + if ($birthday_count == 10 && $use_js_hide) { |
|
441 | + // !!TODO - Inline CSS and JavaScript should be moved. |
|
427 | 442 | 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;">, '; |
443 | + } |
|
428 | 444 | |
429 | 445 | ++$birthday_count; |
430 | 446 | } |
431 | - if ($use_js_hide) |
|
432 | - echo '</span>'; |
|
447 | + if ($use_js_hide) { |
|
448 | + echo '</span>'; |
|
449 | + } |
|
433 | 450 | |
434 | 451 | echo '</div>'; |
435 | 452 | } |
@@ -439,8 +456,9 @@ discard block |
||
439 | 456 | { |
440 | 457 | // Sort events by start time (all day events will be listed first) |
441 | 458 | uasort($day['events'], function($a, $b) { |
442 | - if ($a['start_timestamp'] == $b['start_timestamp']) |
|
443 | - return 0; |
|
459 | + if ($a['start_timestamp'] == $b['start_timestamp']) { |
|
460 | + return 0; |
|
461 | + } |
|
444 | 462 | return ($a['start_timestamp'] < $b['start_timestamp']) ? -1 : 1; |
445 | 463 | }); |
446 | 464 | |
@@ -456,17 +474,19 @@ discard block |
||
456 | 474 | |
457 | 475 | 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' : '', '">'; |
458 | 476 | |
459 | - if (!empty($event['start_time_local']) && $event['starts_today'] == true) |
|
460 | - echo trim(str_replace(':00 ', ' ', $event['start_time_local'])); |
|
461 | - elseif (!empty($event['end_time_local']) && $event['ends_today'] == true) |
|
462 | - echo strtolower($txt['ends']), ' ', trim(str_replace(':00 ', ' ', $event['end_time_local'])); |
|
463 | - elseif (!empty($event['allday'])) |
|
464 | - echo $txt['calendar_allday']; |
|
477 | + if (!empty($event['start_time_local']) && $event['starts_today'] == true) { |
|
478 | + echo trim(str_replace(':00 ', ' ', $event['start_time_local'])); |
|
479 | + } elseif (!empty($event['end_time_local']) && $event['ends_today'] == true) { |
|
480 | + echo strtolower($txt['ends']), ' ', trim(str_replace(':00 ', ' ', $event['end_time_local'])); |
|
481 | + } elseif (!empty($event['allday'])) { |
|
482 | + echo $txt['calendar_allday']; |
|
483 | + } |
|
465 | 484 | |
466 | 485 | echo '</span>'; |
467 | 486 | |
468 | - if (!empty($event['location'])) |
|
469 | - echo '<br><span class="event_location', empty($event_icons_needed) ? ' floatright' : '', '">' . $event['location'] . '</span>'; |
|
487 | + if (!empty($event['location'])) { |
|
488 | + echo '<br><span class="event_location', empty($event_icons_needed) ? ' floatright' : '', '">' . $event['location'] . '</span>'; |
|
489 | + } |
|
470 | 490 | |
471 | 491 | if ($event['can_edit'] || $event['can_export']) |
472 | 492 | { |
@@ -503,10 +523,11 @@ discard block |
||
503 | 523 | // Otherwise, assuming it's not a mini-calendar, we can show previous / next month days! |
504 | 524 | elseif ($is_mini === false) |
505 | 525 | { |
506 | - if (empty($current_month_started) && !empty($context['calendar_grid_prev'])) |
|
507 | - 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>'; |
|
508 | - elseif (!empty($current_month_started) && !empty($context['calendar_grid_next'])) |
|
509 | - 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>'; |
|
526 | + if (empty($current_month_started) && !empty($context['calendar_grid_prev'])) { |
|
527 | + 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>'; |
|
528 | + } elseif (!empty($current_month_started) && !empty($context['calendar_grid_next'])) { |
|
529 | + 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>'; |
|
530 | + } |
|
510 | 531 | } |
511 | 532 | |
512 | 533 | // Close this day and increase var count. |
@@ -532,8 +553,9 @@ discard block |
||
532 | 553 | global $context, $txt, $scripturl, $modSettings; |
533 | 554 | |
534 | 555 | // We might have no reason to proceed, if the variable isn't there. |
535 | - if (!isset($context['calendar_grid_' . $grid_name])) |
|
536 | - return false; |
|
556 | + if (!isset($context['calendar_grid_' . $grid_name])) { |
|
557 | + return false; |
|
558 | + } |
|
537 | 559 | |
538 | 560 | // Handy pointer. |
539 | 561 | $calendar_data = &$context['calendar_grid_' . $grid_name]; |
@@ -568,8 +590,9 @@ discard block |
||
568 | 590 | } |
569 | 591 | |
570 | 592 | // The Month Title + Week Number... |
571 | - if (!empty($calendar_data['week_title'])) |
|
572 | - echo $calendar_data['week_title']; |
|
593 | + if (!empty($calendar_data['week_title'])) { |
|
594 | + echo $calendar_data['week_title']; |
|
595 | + } |
|
573 | 596 | |
574 | 597 | echo ' |
575 | 598 | </h3> |
@@ -608,10 +631,11 @@ discard block |
||
608 | 631 | <tr class="days_wrapper"> |
609 | 632 | <td class="', implode(' ', $classes), ' act_day">'; |
610 | 633 | // Should the day number be a link? |
611 | - if (!empty($modSettings['cal_daysaslink']) && $context['can_post']) |
|
612 | - 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>'; |
|
613 | - else |
|
614 | - echo $txt['days'][$day['day_of_week']], ' - ', $day['day']; |
|
634 | + if (!empty($modSettings['cal_daysaslink']) && $context['can_post']) { |
|
635 | + 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>'; |
|
636 | + } else { |
|
637 | + echo $txt['days'][$day['day_of_week']], ' - ', $day['day']; |
|
638 | + } |
|
615 | 639 | |
616 | 640 | echo '</td> |
617 | 641 | <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'] : '', '">'; |
@@ -620,8 +644,9 @@ discard block |
||
620 | 644 | { |
621 | 645 | // Sort events by start time (all day events will be listed first) |
622 | 646 | uasort($day['events'], function($a, $b) { |
623 | - if ($a['start_timestamp'] == $b['start_timestamp']) |
|
624 | - return 0; |
|
647 | + if ($a['start_timestamp'] == $b['start_timestamp']) { |
|
648 | + return 0; |
|
649 | + } |
|
625 | 650 | return ($a['start_timestamp'] < $b['start_timestamp']) ? -1 : 1; |
626 | 651 | }); |
627 | 652 | |
@@ -633,15 +658,17 @@ discard block |
||
633 | 658 | |
634 | 659 | echo $event['link'], '<br><span class="event_time', empty($event_icons_needed) ? ' floatright' : '', '">'; |
635 | 660 | |
636 | - if (!empty($event['start_time_local'])) |
|
637 | - echo trim($event['start_time_local']), !empty($event['end_time_local']) ? ' – ' . trim($event['end_time_local']) : ''; |
|
638 | - else |
|
639 | - echo $txt['calendar_allday']; |
|
661 | + if (!empty($event['start_time_local'])) { |
|
662 | + echo trim($event['start_time_local']), !empty($event['end_time_local']) ? ' – ' . trim($event['end_time_local']) : ''; |
|
663 | + } else { |
|
664 | + echo $txt['calendar_allday']; |
|
665 | + } |
|
640 | 666 | |
641 | 667 | echo '</span>'; |
642 | 668 | |
643 | - if (!empty($event['location'])) |
|
644 | - echo '<br><span class="event_location', empty($event_icons_needed) ? ' floatright' : '', '">' . $event['location'] . '</span>'; |
|
669 | + if (!empty($event['location'])) { |
|
670 | + echo '<br><span class="event_location', empty($event_icons_needed) ? ' floatright' : '', '">' . $event['location'] . '</span>'; |
|
671 | + } |
|
645 | 672 | |
646 | 673 | if (!empty($event_icons_needed)) |
647 | 674 | { |
@@ -678,8 +705,7 @@ discard block |
||
678 | 705 | </div> |
679 | 706 | <br class="clear">'; |
680 | 707 | } |
681 | - } |
|
682 | - else |
|
708 | + } else |
|
683 | 709 | { |
684 | 710 | if (!empty($context['can_post'])) |
685 | 711 | { |
@@ -692,8 +718,9 @@ discard block |
||
692 | 718 | echo '</td> |
693 | 719 | <td class="', implode(' ', $classes), !empty($day['holidays']) ? ' holidays' : ' disabled', ' holiday_col" data-css-prefix="' . $txt['calendar_prompt'] . ' ">'; |
694 | 720 | // Show any holidays! |
695 | - if (!empty($day['holidays'])) |
|
696 | - echo implode('<br>', $day['holidays']); |
|
721 | + if (!empty($day['holidays'])) { |
|
722 | + echo implode('<br>', $day['holidays']); |
|
723 | + } |
|
697 | 724 | |
698 | 725 | echo '</td> |
699 | 726 | <td class="', implode(' ', $classes), '', !empty($day['birthdays']) ? ' birthdays' : ' disabled', ' birthday_col" data-css-prefix="' . $txt['birthdays'] . ' ">'; |
@@ -751,8 +778,7 @@ discard block |
||
751 | 778 | <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"> |
752 | 779 | <input type="submit" class="button_submit" style="float:none" id="view_button" value="', $txt['view'], '"> |
753 | 780 | </form>'; |
754 | - } |
|
755 | - else |
|
781 | + } else |
|
756 | 782 | { |
757 | 783 | echo' |
758 | 784 | <form action="', $scripturl, '?action=calendar" id="calendar_navigation" method="post" accept-charset="', $context['character_set'], '"> |
@@ -794,8 +820,9 @@ discard block |
||
794 | 820 | echo ' |
795 | 821 | <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;">'; |
796 | 822 | |
797 | - if (!empty($context['event']['new'])) |
|
798 | - echo '<input type="hidden" name="eventid" value="', $context['event']['eventid'], '">'; |
|
823 | + if (!empty($context['event']['new'])) { |
|
824 | + echo '<input type="hidden" name="eventid" value="', $context['event']['eventid'], '">'; |
|
825 | + } |
|
799 | 826 | |
800 | 827 | // Start the main table. |
801 | 828 | echo ' |
@@ -845,9 +872,10 @@ discard block |
||
845 | 872 | { |
846 | 873 | echo ' |
847 | 874 | <optgroup label="', $category['name'], '">'; |
848 | - foreach ($category['boards'] as $board) |
|
849 | - echo ' |
|
875 | + foreach ($category['boards'] as $board) { |
|
876 | + echo ' |
|
850 | 877 | <option value="', $board['id'], '"', $board['selected'] ? ' selected' : '', '>', $board['child_level'] > 0 ? str_repeat('==', $board['child_level'] - 1) . '=>' : '', ' ', $board['name'], ' </option>'; |
878 | + } |
|
851 | 879 | echo ' |
852 | 880 | </optgroup>'; |
853 | 881 | } |
@@ -883,9 +911,10 @@ discard block |
||
883 | 911 | <span class="label">', $txt['calendar_timezone'], '</span> |
884 | 912 | <select name="tz" id="tz"', !empty($context['event']['allday']) ? ' disabled' : '', '>'; |
885 | 913 | |
886 | - foreach ($context['all_timezones'] as $tz => $tzname) |
|
887 | - echo ' |
|
914 | + foreach ($context['all_timezones'] as $tz => $tzname) { |
|
915 | + echo ' |
|
888 | 916 | <option value="', $tz, '"', $tz == $context['event']['tz'] ? ' selected' : '', '>', $tzname, '</option>'; |
917 | + } |
|
889 | 918 | |
890 | 919 | echo ' |
891 | 920 | </select> |
@@ -900,9 +929,10 @@ discard block |
||
900 | 929 | echo ' |
901 | 930 | <input type="submit" value="', empty($context['event']['new']) ? $txt['save'] : $txt['post'], '" class="button_submit">'; |
902 | 931 | // Delete button? |
903 | - if (empty($context['event']['new'])) |
|
904 | - echo ' |
|
932 | + if (empty($context['event']['new'])) { |
|
933 | + echo ' |
|
905 | 934 | <input type="submit" name="deleteevent" value="', $txt['event_delete'], '" data-confirm="', $txt['calendar_confirm_delete'], '" class="button_submit you_sure">'; |
935 | + } |
|
906 | 936 | |
907 | 937 | echo ' |
908 | 938 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -946,9 +976,10 @@ discard block |
||
946 | 976 | |
947 | 977 | foreach ($context['clockicons'] as $t => $v) |
948 | 978 | { |
949 | - foreach ($v as $i) |
|
950 | - echo ' |
|
979 | + foreach ($v as $i) { |
|
980 | + echo ' |
|
951 | 981 | icons[\'', $t, '_', $i, '\'] = document.getElementById(\'', $t, '_', $i, '\');'; |
982 | + } |
|
952 | 983 | } |
953 | 984 | |
954 | 985 | echo ' |
@@ -973,13 +1004,14 @@ discard block |
||
973 | 1004 | |
974 | 1005 | foreach ($context['clockicons'] as $t => $v) |
975 | 1006 | { |
976 | - foreach ($v as $i) |
|
977 | - echo ' |
|
1007 | + foreach ($v as $i) { |
|
1008 | + echo ' |
|
978 | 1009 | if (', $t, ' >= ', $i, ') |
979 | 1010 | { |
980 | 1011 | turnon.push("', $t, '_', $i, '"); |
981 | 1012 | ', $t, ' -= ', $i, '; |
982 | 1013 | }'; |
1014 | + } |
|
983 | 1015 | } |
984 | 1016 | |
985 | 1017 | echo ' |
@@ -1043,9 +1075,10 @@ discard block |
||
1043 | 1075 | |
1044 | 1076 | foreach ($context['clockicons'] as $t => $v) |
1045 | 1077 | { |
1046 | - foreach ($v as $i) |
|
1047 | - echo ' |
|
1078 | + foreach ($v as $i) { |
|
1079 | + echo ' |
|
1048 | 1080 | icons[\'', $t, '_', $i, '\'] = document.getElementById(\'', $t, '_', $i, '\');'; |
1081 | + } |
|
1049 | 1082 | } |
1050 | 1083 | |
1051 | 1084 | echo ' |
@@ -1062,13 +1095,14 @@ discard block |
||
1062 | 1095 | |
1063 | 1096 | foreach ($context['clockicons'] as $t => $v) |
1064 | 1097 | { |
1065 | - foreach ($v as $i) |
|
1066 | - echo ' |
|
1098 | + foreach ($v as $i) { |
|
1099 | + echo ' |
|
1067 | 1100 | if (', $t, ' >= ', $i, ') |
1068 | 1101 | { |
1069 | 1102 | turnon.push("', $t, '_', $i, '"); |
1070 | 1103 | ', $t, ' -= ', $i, '; |
1071 | 1104 | }'; |
1105 | + } |
|
1072 | 1106 | } |
1073 | 1107 | |
1074 | 1108 | echo ' |
@@ -1127,9 +1161,10 @@ discard block |
||
1127 | 1161 | |
1128 | 1162 | foreach ($context['clockicons'] as $t => $v) |
1129 | 1163 | { |
1130 | - foreach ($v as $i) |
|
1131 | - echo ' |
|
1164 | + foreach ($v as $i) { |
|
1165 | + echo ' |
|
1132 | 1166 | icons[\'', $t, '_', $i, '\'] = document.getElementById(\'', $t, '_', $i, '\');'; |
1167 | + } |
|
1133 | 1168 | } |
1134 | 1169 | |
1135 | 1170 | echo ' |
@@ -1150,13 +1185,14 @@ discard block |
||
1150 | 1185 | |
1151 | 1186 | foreach ($context['clockicons'] as $t => $v) |
1152 | 1187 | { |
1153 | - foreach ($v as $i) |
|
1154 | - echo ' |
|
1188 | + foreach ($v as $i) { |
|
1189 | + echo ' |
|
1155 | 1190 | if (', $t, ' >= ', $i, ') |
1156 | 1191 | { |
1157 | 1192 | turnon.push("', $t, '_', $i, '"); |
1158 | 1193 | ', $t, ' -= ', $i, '; |
1159 | 1194 | }'; |
1195 | + } |
|
1160 | 1196 | } |
1161 | 1197 | |
1162 | 1198 | echo ' |