@@ -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 | class Attachments |
20 | 21 | { |
@@ -70,16 +71,18 @@ discard block |
||
70 | 71 | |
71 | 72 | $this->_sa = !empty($_REQUEST['sa']) ? $smcFunc['htmlspecialchars']($smcFunc['htmltrim']($_REQUEST['sa'])) : false; |
72 | 73 | |
73 | - if ($this->_canPostAttachment && $this->_sa && in_array($this->_sa, $this->_subActions)) |
|
74 | - $this->{$this->_sa}(); |
|
74 | + if ($this->_canPostAttachment && $this->_sa && in_array($this->_sa, $this->_subActions)) { |
|
75 | + $this->{$this->_sa}(); |
|
76 | + } |
|
75 | 77 | |
76 | 78 | // Just send a generic message. |
77 | - else |
|
78 | - $this->setResponse(array( |
|
79 | + else { |
|
80 | + $this->setResponse(array( |
|
79 | 81 | 'text' => $this->_sa == 'add' ? 'attach_error_title' : 'attached_file_deleted_error', |
80 | 82 | 'type' => 'error', |
81 | 83 | 'data' => false, |
82 | 84 | )); |
85 | + } |
|
83 | 86 | |
84 | 87 | // Back to the future, oh, to the browser! |
85 | 88 | $this->sendResponse(); |
@@ -95,12 +98,13 @@ discard block |
||
95 | 98 | $attachID = !empty($_REQUEST['attach']) && is_numeric($_REQUEST['attach']) ? (int) $_REQUEST['attach'] : 0; |
96 | 99 | |
97 | 100 | // Need something to work with. |
98 | - if (!$attachID || (!empty($_SESSION['already_attached']) && !isset($_SESSION['already_attached'][$attachID]))) |
|
99 | - return $this->setResponse(array( |
|
101 | + if (!$attachID || (!empty($_SESSION['already_attached']) && !isset($_SESSION['already_attached'][$attachID]))) { |
|
102 | + return $this->setResponse(array( |
|
100 | 103 | 'text' => 'attached_file_deleted_error', |
101 | 104 | 'type' => 'error', |
102 | 105 | 'data' => false, |
103 | 106 | )); |
107 | + } |
|
104 | 108 | |
105 | 109 | // Lets pass some params and see what happens :P |
106 | 110 | $affectedMessage = removeAttachments(array('id_attach' => $attachID), '', true, true); |
@@ -119,19 +123,21 @@ discard block |
||
119 | 123 | public function add() |
120 | 124 | { |
121 | 125 | // You gotta be able to post attachments. |
122 | - if (!$this->_canPostAttachment) |
|
123 | - return $this->setResponse(array( |
|
126 | + if (!$this->_canPostAttachment) { |
|
127 | + return $this->setResponse(array( |
|
124 | 128 | 'text' => 'attached_file_cannot', |
125 | 129 | 'type' => 'error', |
126 | 130 | 'data' => false, |
127 | 131 | )); |
132 | + } |
|
128 | 133 | |
129 | 134 | // Process them at once! |
130 | 135 | $this->processAttachments(); |
131 | 136 | |
132 | 137 | // The attachments was created and moved the the right folder, time to update the DB. |
133 | - if (!empty($_SESSION['temp_attachments'])) |
|
134 | - $this->createAtttach(); |
|
138 | + if (!empty($_SESSION['temp_attachments'])) { |
|
139 | + $this->createAtttach(); |
|
140 | + } |
|
135 | 141 | |
136 | 142 | // Set the response. |
137 | 143 | $this->setResponse(); |
@@ -144,8 +150,9 @@ discard block |
||
144 | 150 | { |
145 | 151 | global $context, $modSettings, $smcFunc, $user_info, $txt; |
146 | 152 | |
147 | - if (!isset($_FILES['attachment']['name'])) |
|
148 | - $_FILES['attachment']['tmp_name'] = array(); |
|
153 | + if (!isset($_FILES['attachment']['name'])) { |
|
154 | + $_FILES['attachment']['tmp_name'] = array(); |
|
155 | + } |
|
149 | 156 | |
150 | 157 | // If there are attachments, calculate the total size and how many. |
151 | 158 | $context['attachments']['total_size'] = 0; |
@@ -155,25 +162,30 @@ discard block |
||
155 | 162 | if (isset($_REQUEST['msg'])) |
156 | 163 | { |
157 | 164 | $context['attachments']['quantity'] = count($context['current_attachments']); |
158 | - foreach ($context['current_attachments'] as $attachment) |
|
159 | - $context['attachments']['total_size'] += $attachment['size']; |
|
165 | + foreach ($context['current_attachments'] as $attachment) { |
|
166 | + $context['attachments']['total_size'] += $attachment['size']; |
|
167 | + } |
|
160 | 168 | } |
161 | 169 | |
162 | 170 | // A bit of house keeping first. |
163 | - if (!empty($_SESSION['temp_attachments']) && count($_SESSION['temp_attachments']) == 1) |
|
164 | - unset($_SESSION['temp_attachments']); |
|
171 | + if (!empty($_SESSION['temp_attachments']) && count($_SESSION['temp_attachments']) == 1) { |
|
172 | + unset($_SESSION['temp_attachments']); |
|
173 | + } |
|
165 | 174 | |
166 | 175 | // Our infamous SESSION var, we are gonna have soo much fun with it! |
167 | - if (!isset($_SESSION['temp_attachments'])) |
|
168 | - $_SESSION['temp_attachments'] = array(); |
|
176 | + if (!isset($_SESSION['temp_attachments'])) { |
|
177 | + $_SESSION['temp_attachments'] = array(); |
|
178 | + } |
|
169 | 179 | |
170 | 180 | // Make sure we're uploading to the right place. |
171 | - if (!empty($modSettings['automanage_attachments'])) |
|
172 | - automanage_attachments_check_directory(); |
|
181 | + if (!empty($modSettings['automanage_attachments'])) { |
|
182 | + automanage_attachments_check_directory(); |
|
183 | + } |
|
173 | 184 | |
174 | 185 | // Is the attachments folder actually there? |
175 | - if (!empty($context['dir_creation_error'])) |
|
176 | - $this->_generalErrors[] = $context['dir_creation_error']; |
|
186 | + if (!empty($context['dir_creation_error'])) { |
|
187 | + $this->_generalErrors[] = $context['dir_creation_error']; |
|
188 | + } |
|
177 | 189 | |
178 | 190 | // The current attach folder ha some issues... |
179 | 191 | elseif (!is_dir($this->_attchDir)) |
@@ -198,13 +210,12 @@ discard block |
||
198 | 210 | ); |
199 | 211 | list ($context['attachments']['quantity'], $context['attachments']['total_size']) = $smcFunc['db_fetch_row']($request); |
200 | 212 | $smcFunc['db_free_result']($request); |
201 | - } |
|
202 | - |
|
203 | - else |
|
204 | - $context['attachments'] = array( |
|
213 | + } else { |
|
214 | + $context['attachments'] = array( |
|
205 | 215 | 'quantity' => 0, |
206 | 216 | 'total_size' => 0, |
207 | 217 | ); |
218 | + } |
|
208 | 219 | |
209 | 220 | // Check for other general errors here. |
210 | 221 | |
@@ -212,9 +223,10 @@ discard block |
||
212 | 223 | if (!empty($this->_generalErrors)) |
213 | 224 | { |
214 | 225 | // And delete the files 'cos they ain't going nowhere. |
215 | - foreach ($_FILES['attachment']['tmp_name'] as $n => $dummy) |
|
216 | - if (file_exists($_FILES['attachment']['tmp_name'][$n])) |
|
226 | + foreach ($_FILES['attachment']['tmp_name'] as $n => $dummy) { |
|
227 | + if (file_exists($_FILES['attachment']['tmp_name'][$n])) |
|
217 | 228 | unlink($_FILES['attachment']['tmp_name'][$n]); |
229 | + } |
|
218 | 230 | |
219 | 231 | $_FILES['attachment']['tmp_name'] = array(); |
220 | 232 | |
@@ -225,26 +237,29 @@ discard block |
||
225 | 237 | // Loop through $_FILES['attachment'] array and move each file to the current attachments folder. |
226 | 238 | foreach ($_FILES['attachment']['tmp_name'] as $n => $dummy) |
227 | 239 | { |
228 | - if ($_FILES['attachment']['name'][$n] == '') |
|
229 | - continue; |
|
240 | + if ($_FILES['attachment']['name'][$n] == '') { |
|
241 | + continue; |
|
242 | + } |
|
230 | 243 | |
231 | 244 | // First, let's first check for PHP upload errors. |
232 | 245 | $errors = array(); |
233 | 246 | if (!empty($_FILES['attachment']['error'][$n])) |
234 | 247 | { |
235 | - if ($_FILES['attachment']['error'][$n] == 2) |
|
236 | - $errors[] = array('file_too_big', array($modSettings['attachmentSizeLimit'])); |
|
237 | - |
|
238 | - else |
|
239 | - log_error($_FILES['attachment']['name'][$n] . ': ' . $txt['php_upload_error_' . $_FILES['attachment']['error'][$n]]); |
|
248 | + if ($_FILES['attachment']['error'][$n] == 2) { |
|
249 | + $errors[] = array('file_too_big', array($modSettings['attachmentSizeLimit'])); |
|
250 | + } else { |
|
251 | + log_error($_FILES['attachment']['name'][$n] . ': ' . $txt['php_upload_error_' . $_FILES['attachment']['error'][$n]]); |
|
252 | + } |
|
240 | 253 | |
241 | 254 | // Log this one, because... |
242 | - if ($_FILES['attachment']['error'][$n] == 6) |
|
243 | - log_error($_FILES['attachment']['name'][$n] . ': ' . $txt['php_upload_error_6'], 'critical'); |
|
255 | + if ($_FILES['attachment']['error'][$n] == 6) { |
|
256 | + log_error($_FILES['attachment']['name'][$n] . ': ' . $txt['php_upload_error_6'], 'critical'); |
|
257 | + } |
|
244 | 258 | |
245 | 259 | // Weird, no errors were cached, still fill out a generic one. |
246 | - if (empty($errors)) |
|
247 | - $errors[] = 'attach_php_error'; |
|
260 | + if (empty($errors)) { |
|
261 | + $errors[] = 'attach_php_error'; |
|
262 | + } |
|
248 | 263 | } |
249 | 264 | |
250 | 265 | // Try to move and rename the file before doing any more checks on it. |
@@ -256,8 +271,9 @@ discard block |
||
256 | 271 | { |
257 | 272 | // The reported MIME type of the attachment might not be reliable. |
258 | 273 | // Fortunately, PHP 5.3+ lets us easily verify the real MIME type. |
259 | - if (function_exists('mime_content_type')) |
|
260 | - $_FILES['attachment']['type'][$n] = mime_content_type($_FILES['attachment']['tmp_name'][$n]); |
|
274 | + if (function_exists('mime_content_type')) { |
|
275 | + $_FILES['attachment']['type'][$n] = mime_content_type($_FILES['attachment']['tmp_name'][$n]); |
|
276 | + } |
|
261 | 277 | |
262 | 278 | $_SESSION['temp_attachments'][$attachID] = array( |
263 | 279 | 'name' => $smcFunc['htmlspecialchars'](basename($_FILES['attachment']['name'][$n])), |
@@ -269,16 +285,18 @@ discard block |
||
269 | 285 | ); |
270 | 286 | |
271 | 287 | // Move the file to the attachments folder with a temp name for now. |
272 | - if (@move_uploaded_file($_FILES['attachment']['tmp_name'][$n], $destName)) |
|
273 | - smf_chmod($destName, 0644); |
|
288 | + if (@move_uploaded_file($_FILES['attachment']['tmp_name'][$n], $destName)) { |
|
289 | + smf_chmod($destName, 0644); |
|
290 | + } |
|
274 | 291 | |
275 | 292 | // This is madness!! |
276 | 293 | else |
277 | 294 | { |
278 | 295 | // File couldn't be moved. |
279 | 296 | $_SESSION['temp_attachments'][$attachID]['errors'][] = 'attach_timeout'; |
280 | - if (file_exists($_FILES['attachment']['tmp_name'][$n])) |
|
281 | - unlink($_FILES['attachment']['tmp_name'][$n]); |
|
297 | + if (file_exists($_FILES['attachment']['tmp_name'][$n])) { |
|
298 | + unlink($_FILES['attachment']['tmp_name'][$n]); |
|
299 | + } |
|
282 | 300 | } |
283 | 301 | } |
284 | 302 | |
@@ -291,13 +309,15 @@ discard block |
||
291 | 309 | 'errors' => $errors, |
292 | 310 | ); |
293 | 311 | |
294 | - if (file_exists($_FILES['attachment']['tmp_name'][$n])) |
|
295 | - unlink($_FILES['attachment']['tmp_name'][$n]); |
|
312 | + if (file_exists($_FILES['attachment']['tmp_name'][$n])) { |
|
313 | + unlink($_FILES['attachment']['tmp_name'][$n]); |
|
314 | + } |
|
296 | 315 | } |
297 | 316 | |
298 | 317 | // If there's no errors to this point. We still do need to apply some additional checks before we are finished. |
299 | - if (empty($_SESSION['temp_attachments'][$attachID]['errors'])) |
|
300 | - attachmentChecks($attachID); |
|
318 | + if (empty($_SESSION['temp_attachments'][$attachID]['errors'])) { |
|
319 | + attachmentChecks($attachID); |
|
320 | + } |
|
301 | 321 | } |
302 | 322 | |
303 | 323 | // Mod authors, finally a hook to hang an alternate attachment upload system upon |
@@ -344,14 +364,15 @@ discard block |
||
344 | 364 | |
345 | 365 | $_SESSION['already_attached'][$attachmentOptions['attachID']] = $attachmentOptions['attachID']; |
346 | 366 | |
347 | - if (!empty($attachmentOptions['thumb'])) |
|
348 | - $_SESSION['already_attached'][$attachmentOptions['thumb']] = $attachmentOptions['thumb']; |
|
367 | + if (!empty($attachmentOptions['thumb'])) { |
|
368 | + $_SESSION['already_attached'][$attachmentOptions['thumb']] = $attachmentOptions['thumb']; |
|
369 | + } |
|
349 | 370 | |
350 | - if ($this->_msg) |
|
351 | - assignAttachments($_SESSION['already_attached'], $this->_msg); |
|
371 | + if ($this->_msg) { |
|
372 | + assignAttachments($_SESSION['already_attached'], $this->_msg); |
|
373 | + } |
|
352 | 374 | } |
353 | - } |
|
354 | - else |
|
375 | + } else |
|
355 | 376 | { |
356 | 377 | // Sort out the errors for display and delete any associated files. |
357 | 378 | $log_these = array('attachments_no_create', 'attachments_no_write', 'attach_timeout', 'ran_out_of_space', 'cant_access_upload_path', 'attach_0_byte_file'); |
@@ -363,14 +384,16 @@ discard block |
||
363 | 384 | if (!is_array($error)) |
364 | 385 | { |
365 | 386 | $attachmentOptions['errors'][] = $txt[$error]; |
366 | - if (in_array($error, $log_these)) |
|
367 | - log_error($attachment['name'] . ': ' . $txt[$error], 'critical'); |
|
387 | + if (in_array($error, $log_these)) { |
|
388 | + log_error($attachment['name'] . ': ' . $txt[$error], 'critical'); |
|
389 | + } |
|
390 | + } else { |
|
391 | + $attachmentOptions['errors'][] = vsprintf($txt[$error[0]], $error[1]); |
|
368 | 392 | } |
369 | - else |
|
370 | - $attachmentOptions['errors'][] = vsprintf($txt[$error[0]], $error[1]); |
|
371 | 393 | } |
372 | - if (file_exists($attachment['tmp_name'])) |
|
373 | - unlink($attachment['tmp_name']); |
|
394 | + if (file_exists($attachment['tmp_name'])) { |
|
395 | + unlink($attachment['tmp_name']); |
|
396 | + } |
|
374 | 397 | } |
375 | 398 | |
376 | 399 | // You don't need to know. |
@@ -382,8 +405,9 @@ discard block |
||
382 | 405 | } |
383 | 406 | |
384 | 407 | // Temp save this on the db. |
385 | - if (!empty($_SESSION['already_attached'])) |
|
386 | - $this->_attachSuccess = $_SESSION['already_attached']; |
|
408 | + if (!empty($_SESSION['already_attached'])) { |
|
409 | + $this->_attachSuccess = $_SESSION['already_attached']; |
|
410 | + } |
|
387 | 411 | |
388 | 412 | unset($_SESSION['temp_attachments']); |
389 | 413 | } |
@@ -403,14 +427,16 @@ discard block |
||
403 | 427 | if ($this->_sa == 'add') |
404 | 428 | { |
405 | 429 | // Is there any generic errors? made some sense out of them! |
406 | - if ($this->_generalErrors) |
|
407 | - foreach ($this->_generalErrors as $k => $v) |
|
430 | + if ($this->_generalErrors) { |
|
431 | + foreach ($this->_generalErrors as $k => $v) |
|
408 | 432 | $this->_generalErrors[$k] = (is_array($v) ? vsprintf($txt[$v[0]], $v[1]) : $txt[$v]); |
433 | + } |
|
409 | 434 | |
410 | 435 | // Gotta urlencode the filename. |
411 | - if ($this->_attachResults) |
|
412 | - foreach ($this->_attachResults as $k => $v) |
|
436 | + if ($this->_attachResults) { |
|
437 | + foreach ($this->_attachResults as $k => $v) |
|
413 | 438 | $this->_attachResults[$k]['name'] = urlencode($this->_attachResults[$k]['name']); |
439 | + } |
|
414 | 440 | |
415 | 441 | $this->_response = array( |
416 | 442 | 'files' => $this->_attachResults ? $this->_attachResults : false, |
@@ -419,9 +445,10 @@ discard block |
||
419 | 445 | } |
420 | 446 | |
421 | 447 | // Rest of us mere mortals gets no special treatment... |
422 | - elseif (!empty($data)) |
|
423 | - if (!empty($data['text']) && !empty($txt[$data['text']])) |
|
448 | + elseif (!empty($data)) { |
|
449 | + if (!empty($data['text']) && !empty($txt[$data['text']])) |
|
424 | 450 | $this->_response['text'] = $txt[$data['text']]; |
451 | + } |
|
425 | 452 | } |
426 | 453 | |
427 | 454 | protected function sendResponse() |
@@ -430,11 +457,11 @@ discard block |
||
430 | 457 | |
431 | 458 | ob_end_clean(); |
432 | 459 | |
433 | - if (!empty($modSettings['CompressedOutput'])) |
|
434 | - @ob_start('ob_gzhandler'); |
|
435 | - |
|
436 | - else |
|
437 | - ob_start(); |
|
460 | + if (!empty($modSettings['CompressedOutput'])) { |
|
461 | + @ob_start('ob_gzhandler'); |
|
462 | + } else { |
|
463 | + ob_start(); |
|
464 | + } |
|
438 | 465 | |
439 | 466 | // Set the header. |
440 | 467 | header('content-type: application/json; charset='. $context['character_set'] .''); |
@@ -12,8 +12,9 @@ discard block |
||
12 | 12 | */ |
13 | 13 | |
14 | 14 | // Don't do anything if SMF is already loaded. |
15 | -if (defined('SMF')) |
|
15 | +if (defined('SMF')) { |
|
16 | 16 | return true; |
17 | +} |
|
17 | 18 | |
18 | 19 | define('SMF', 'SSI'); |
19 | 20 | |
@@ -28,16 +29,18 @@ discard block |
||
28 | 29 | $time_start = microtime(true); |
29 | 30 | |
30 | 31 | // Just being safe... |
31 | -foreach (array('db_character_set', 'cachedir') as $variable) |
|
32 | +foreach (array('db_character_set', 'cachedir') as $variable) { |
|
32 | 33 | if (isset($GLOBALS[$variable])) |
33 | 34 | unset($GLOBALS[$variable]); |
35 | +} |
|
34 | 36 | |
35 | 37 | // Get the forum's settings for database and file paths. |
36 | 38 | require_once(dirname(__FILE__) . '/Settings.php'); |
37 | 39 | |
38 | 40 | // Make absolutely sure the cache directory is defined. |
39 | -if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache')) |
|
41 | +if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache')) { |
|
40 | 42 | $cachedir = $boarddir . '/cache'; |
43 | +} |
|
41 | 44 | |
42 | 45 | $ssi_error_reporting = error_reporting(E_ALL); |
43 | 46 | /* Set this to one of three values depending on what you want to happen in the case of a fatal error. |
@@ -48,12 +51,14 @@ discard block |
||
48 | 51 | $ssi_on_error_method = false; |
49 | 52 | |
50 | 53 | // Don't do john didley if the forum's been shut down completely. |
51 | -if ($maintenance == 2 && (!isset($ssi_maintenance_off) || $ssi_maintenance_off !== true)) |
|
54 | +if ($maintenance == 2 && (!isset($ssi_maintenance_off) || $ssi_maintenance_off !== true)) { |
|
52 | 55 | die($mmessage); |
56 | +} |
|
53 | 57 | |
54 | 58 | // Fix for using the current directory as a path. |
55 | -if (substr($sourcedir, 0, 1) == '.' && substr($sourcedir, 1, 1) != '.') |
|
59 | +if (substr($sourcedir, 0, 1) == '.' && substr($sourcedir, 1, 1) != '.') { |
|
56 | 60 | $sourcedir = dirname(__FILE__) . substr($sourcedir, 1); |
61 | +} |
|
57 | 62 | |
58 | 63 | // Load the important includes. |
59 | 64 | require_once($sourcedir . '/QueryString.php'); |
@@ -78,26 +83,30 @@ discard block |
||
78 | 83 | cleanRequest(); |
79 | 84 | |
80 | 85 | // Seed the random generator? |
81 | -if (empty($modSettings['rand_seed']) || mt_rand(1, 250) == 69) |
|
86 | +if (empty($modSettings['rand_seed']) || mt_rand(1, 250) == 69) { |
|
82 | 87 | smf_seed_generator(); |
88 | +} |
|
83 | 89 | |
84 | 90 | // Check on any hacking attempts. |
85 | -if (isset($_REQUEST['GLOBALS']) || isset($_COOKIE['GLOBALS'])) |
|
91 | +if (isset($_REQUEST['GLOBALS']) || isset($_COOKIE['GLOBALS'])) { |
|
86 | 92 | die('No direct access...'); |
87 | -elseif (isset($_REQUEST['ssi_theme']) && (int) $_REQUEST['ssi_theme'] == (int) $ssi_theme) |
|
93 | +} elseif (isset($_REQUEST['ssi_theme']) && (int) $_REQUEST['ssi_theme'] == (int) $ssi_theme) { |
|
88 | 94 | die('No direct access...'); |
89 | -elseif (isset($_COOKIE['ssi_theme']) && (int) $_COOKIE['ssi_theme'] == (int) $ssi_theme) |
|
95 | +} elseif (isset($_COOKIE['ssi_theme']) && (int) $_COOKIE['ssi_theme'] == (int) $ssi_theme) { |
|
90 | 96 | die('No direct access...'); |
91 | -elseif (isset($_REQUEST['ssi_layers'], $ssi_layers) && (@get_magic_quotes_gpc() ? stripslashes($_REQUEST['ssi_layers']) : $_REQUEST['ssi_layers']) == $ssi_layers) |
|
97 | +} elseif (isset($_REQUEST['ssi_layers'], $ssi_layers) && (@get_magic_quotes_gpc() ? stripslashes($_REQUEST['ssi_layers']) : $_REQUEST['ssi_layers']) == $ssi_layers) { |
|
92 | 98 | die('No direct access...'); |
93 | -if (isset($_REQUEST['context'])) |
|
99 | +} |
|
100 | +if (isset($_REQUEST['context'])) { |
|
94 | 101 | die('No direct access...'); |
102 | +} |
|
95 | 103 | |
96 | 104 | // Gzip output? (because it must be boolean and true, this can't be hacked.) |
97 | -if (isset($ssi_gzip) && $ssi_gzip === true && ini_get('zlib.output_compression') != '1' && ini_get('output_handler') != 'ob_gzhandler' && version_compare(PHP_VERSION, '4.2.0', '>=')) |
|
105 | +if (isset($ssi_gzip) && $ssi_gzip === true && ini_get('zlib.output_compression') != '1' && ini_get('output_handler') != 'ob_gzhandler' && version_compare(PHP_VERSION, '4.2.0', '>=')) { |
|
98 | 106 | ob_start('ob_gzhandler'); |
99 | -else |
|
107 | +} else { |
|
100 | 108 | $modSettings['enableCompressedOutput'] = '0'; |
109 | +} |
|
101 | 110 | |
102 | 111 | /** |
103 | 112 | * An autoloader for certain classes. |
@@ -146,9 +155,9 @@ discard block |
||
146 | 155 | ob_start('ob_sessrewrite'); |
147 | 156 | |
148 | 157 | // Start the session... known to scramble SSI includes in cases... |
149 | -if (!headers_sent()) |
|
158 | +if (!headers_sent()) { |
|
150 | 159 | loadSession(); |
151 | -else |
|
160 | +} else |
|
152 | 161 | { |
153 | 162 | if (isset($_COOKIE[session_name()]) || isset($_REQUEST[session_name()])) |
154 | 163 | { |
@@ -182,12 +191,14 @@ discard block |
||
182 | 191 | loadTheme(isset($ssi_theme) ? (int) $ssi_theme : 0); |
183 | 192 | |
184 | 193 | // @todo: probably not the best place, but somewhere it should be set... |
185 | -if (!headers_sent()) |
|
194 | +if (!headers_sent()) { |
|
186 | 195 | header('content-type: text/html; charset=' . (empty($modSettings['global_character_set']) ? (empty($txt['lang_character_set']) ? 'ISO-8859-1' : $txt['lang_character_set']) : $modSettings['global_character_set'])); |
196 | +} |
|
187 | 197 | |
188 | 198 | // Take care of any banning that needs to be done. |
189 | -if (isset($_REQUEST['ssi_ban']) || (isset($ssi_ban) && $ssi_ban === true)) |
|
199 | +if (isset($_REQUEST['ssi_ban']) || (isset($ssi_ban) && $ssi_ban === true)) { |
|
190 | 200 | is_not_banned(); |
201 | +} |
|
191 | 202 | |
192 | 203 | // Do we allow guests in here? |
193 | 204 | if (empty($ssi_guest_access) && empty($modSettings['allow_guestAccess']) && $user_info['is_guest'] && basename($_SERVER['PHP_SELF']) != 'SSI.php') |
@@ -202,17 +213,19 @@ discard block |
||
202 | 213 | { |
203 | 214 | $context['template_layers'] = $ssi_layers; |
204 | 215 | template_header(); |
205 | -} |
|
206 | -else |
|
216 | +} else { |
|
207 | 217 | setupThemeContext(); |
218 | +} |
|
208 | 219 | |
209 | 220 | // Make sure they didn't muss around with the settings... but only if it's not cli. |
210 | -if (isset($_SERVER['REMOTE_ADDR']) && !isset($_SERVER['is_cli']) && session_id() == '') |
|
221 | +if (isset($_SERVER['REMOTE_ADDR']) && !isset($_SERVER['is_cli']) && session_id() == '') { |
|
211 | 222 | trigger_error($txt['ssi_session_broken'], E_USER_NOTICE); |
223 | +} |
|
212 | 224 | |
213 | 225 | // Without visiting the forum this session variable might not be set on submit. |
214 | -if (!isset($_SESSION['USER_AGENT']) && (!isset($_GET['ssi_function']) || $_GET['ssi_function'] !== 'pollVote')) |
|
226 | +if (!isset($_SESSION['USER_AGENT']) && (!isset($_GET['ssi_function']) || $_GET['ssi_function'] !== 'pollVote')) { |
|
215 | 227 | $_SESSION['USER_AGENT'] = $_SERVER['HTTP_USER_AGENT']; |
228 | +} |
|
216 | 229 | |
217 | 230 | // Have the ability to easily add functions to SSI. |
218 | 231 | call_integration_hook('integrate_SSI'); |
@@ -221,11 +234,13 @@ discard block |
||
221 | 234 | if (basename($_SERVER['PHP_SELF']) == 'SSI.php') |
222 | 235 | { |
223 | 236 | // You shouldn't just access SSI.php directly by URL!! |
224 | - if (!isset($_GET['ssi_function'])) |
|
225 | - die(sprintf($txt['ssi_not_direct'], $user_info['is_admin'] ? '\'' . addslashes(__FILE__) . '\'' : '\'SSI.php\'')); |
|
237 | + if (!isset($_GET['ssi_function'])) { |
|
238 | + die(sprintf($txt['ssi_not_direct'], $user_info['is_admin'] ? '\'' . addslashes(__FILE__) . '\'' : '\'SSI.php\'')); |
|
239 | + } |
|
226 | 240 | // Call a function passed by GET. |
227 | - if (function_exists('ssi_' . $_GET['ssi_function']) && (!empty($modSettings['allow_guestAccess']) || !$user_info['is_guest'])) |
|
228 | - call_user_func('ssi_' . $_GET['ssi_function']); |
|
241 | + if (function_exists('ssi_' . $_GET['ssi_function']) && (!empty($modSettings['allow_guestAccess']) || !$user_info['is_guest'])) { |
|
242 | + call_user_func('ssi_' . $_GET['ssi_function']); |
|
243 | + } |
|
229 | 244 | exit; |
230 | 245 | } |
231 | 246 | |
@@ -242,9 +257,10 @@ discard block |
||
242 | 257 | */ |
243 | 258 | function ssi_shutdown() |
244 | 259 | { |
245 | - if (!isset($_GET['ssi_function']) || $_GET['ssi_function'] != 'shutdown') |
|
246 | - template_footer(); |
|
247 | -} |
|
260 | + if (!isset($_GET['ssi_function']) || $_GET['ssi_function'] != 'shutdown') { |
|
261 | + template_footer(); |
|
262 | + } |
|
263 | + } |
|
248 | 264 | |
249 | 265 | /** |
250 | 266 | * Display a welcome message, like: Hey, User, you have 0 messages, 0 are new. |
@@ -257,15 +273,17 @@ discard block |
||
257 | 273 | |
258 | 274 | if ($output_method == 'echo') |
259 | 275 | { |
260 | - if ($context['user']['is_guest']) |
|
261 | - echo sprintf($txt[$context['can_register'] ? 'welcome_guest_register' : 'welcome_guest'], $txt['guest_title'], $context['forum_name_html_safe'], $scripturl . '?action=login', 'return reqOverlayDiv(this.href, ' . JavaScriptEscape($txt['login']) . ');', $scripturl . '?action=signup'); |
|
262 | - else |
|
263 | - echo $txt['hello_member'], ' <strong>', $context['user']['name'], '</strong>', allowedTo('pm_read') ? ', ' . (empty($context['user']['messages']) ? $txt['msg_alert_no_messages'] : (($context['user']['messages'] == 1 ? sprintf($txt['msg_alert_one_message'], $scripturl . '?action=pm') : sprintf($txt['msg_alert_many_message'], $scripturl . '?action=pm', $context['user']['messages'])) . ', ' . ($context['user']['unread_messages'] == 1 ? $txt['msg_alert_one_new'] : sprintf($txt['msg_alert_many_new'], $context['user']['unread_messages'])))) : ''; |
|
276 | + if ($context['user']['is_guest']) { |
|
277 | + echo sprintf($txt[$context['can_register'] ? 'welcome_guest_register' : 'welcome_guest'], $txt['guest_title'], $context['forum_name_html_safe'], $scripturl . '?action=login', 'return reqOverlayDiv(this.href, ' . JavaScriptEscape($txt['login']) . ');', $scripturl . '?action=signup'); |
|
278 | + } else { |
|
279 | + echo $txt['hello_member'], ' <strong>', $context['user']['name'], '</strong>', allowedTo('pm_read') ? ', ' . (empty($context['user']['messages']) ? $txt['msg_alert_no_messages'] : (($context['user']['messages'] == 1 ? sprintf($txt['msg_alert_one_message'], $scripturl . '?action=pm') : sprintf($txt['msg_alert_many_message'], $scripturl . '?action=pm', $context['user']['messages'])) . ', ' . ($context['user']['unread_messages'] == 1 ? $txt['msg_alert_one_new'] : sprintf($txt['msg_alert_many_new'], $context['user']['unread_messages'])))) : ''; |
|
280 | + } |
|
264 | 281 | } |
265 | 282 | // Don't echo... then do what?! |
266 | - else |
|
267 | - return $context['user']; |
|
268 | -} |
|
283 | + else { |
|
284 | + return $context['user']; |
|
285 | + } |
|
286 | + } |
|
269 | 287 | |
270 | 288 | /** |
271 | 289 | * Display a menu bar, like is displayed at the top of the forum. |
@@ -276,12 +294,14 @@ discard block |
||
276 | 294 | { |
277 | 295 | global $context; |
278 | 296 | |
279 | - if ($output_method == 'echo') |
|
280 | - template_menu(); |
|
297 | + if ($output_method == 'echo') { |
|
298 | + template_menu(); |
|
299 | + } |
|
281 | 300 | // What else could this do? |
282 | - else |
|
283 | - return $context['menu_buttons']; |
|
284 | -} |
|
301 | + else { |
|
302 | + return $context['menu_buttons']; |
|
303 | + } |
|
304 | + } |
|
285 | 305 | |
286 | 306 | /** |
287 | 307 | * Show a logout link. |
@@ -293,20 +313,23 @@ discard block |
||
293 | 313 | { |
294 | 314 | global $context, $txt, $scripturl; |
295 | 315 | |
296 | - if ($redirect_to != '') |
|
297 | - $_SESSION['logout_url'] = $redirect_to; |
|
316 | + if ($redirect_to != '') { |
|
317 | + $_SESSION['logout_url'] = $redirect_to; |
|
318 | + } |
|
298 | 319 | |
299 | 320 | // Guests can't log out. |
300 | - if ($context['user']['is_guest']) |
|
301 | - return false; |
|
321 | + if ($context['user']['is_guest']) { |
|
322 | + return false; |
|
323 | + } |
|
302 | 324 | |
303 | 325 | $link = '<a href="' . $scripturl . '?action=logout;' . $context['session_var'] . '=' . $context['session_id'] . '">' . $txt['logout'] . '</a>'; |
304 | 326 | |
305 | - if ($output_method == 'echo') |
|
306 | - echo $link; |
|
307 | - else |
|
308 | - return $link; |
|
309 | -} |
|
327 | + if ($output_method == 'echo') { |
|
328 | + echo $link; |
|
329 | + } else { |
|
330 | + return $link; |
|
331 | + } |
|
332 | + } |
|
310 | 333 | |
311 | 334 | /** |
312 | 335 | * Recent post list: [board] Subject by Poster Date |
@@ -322,17 +345,17 @@ discard block |
||
322 | 345 | global $modSettings, $context; |
323 | 346 | |
324 | 347 | // Excluding certain boards... |
325 | - if ($exclude_boards === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0) |
|
326 | - $exclude_boards = array($modSettings['recycle_board']); |
|
327 | - else |
|
328 | - $exclude_boards = empty($exclude_boards) ? array() : (is_array($exclude_boards) ? $exclude_boards : array($exclude_boards)); |
|
348 | + if ($exclude_boards === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0) { |
|
349 | + $exclude_boards = array($modSettings['recycle_board']); |
|
350 | + } else { |
|
351 | + $exclude_boards = empty($exclude_boards) ? array() : (is_array($exclude_boards) ? $exclude_boards : array($exclude_boards)); |
|
352 | + } |
|
329 | 353 | |
330 | 354 | // What about including certain boards - note we do some protection here as pre-2.0 didn't have this parameter. |
331 | 355 | if (is_array($include_boards) || (int) $include_boards === $include_boards) |
332 | 356 | { |
333 | 357 | $include_boards = is_array($include_boards) ? $include_boards : array($include_boards); |
334 | - } |
|
335 | - elseif ($include_boards != null) |
|
358 | + } elseif ($include_boards != null) |
|
336 | 359 | { |
337 | 360 | $include_boards = array(); |
338 | 361 | } |
@@ -369,8 +392,9 @@ discard block |
||
369 | 392 | { |
370 | 393 | global $modSettings; |
371 | 394 | |
372 | - if (empty($post_ids)) |
|
373 | - return; |
|
395 | + if (empty($post_ids)) { |
|
396 | + return; |
|
397 | + } |
|
374 | 398 | |
375 | 399 | // Allow the user to request more than one - why not? |
376 | 400 | $post_ids = is_array($post_ids) ? $post_ids : array($post_ids); |
@@ -405,8 +429,9 @@ discard block |
||
405 | 429 | global $scripturl, $txt, $user_info; |
406 | 430 | global $modSettings, $smcFunc, $context; |
407 | 431 | |
408 | - if (!empty($modSettings['enable_likes'])) |
|
409 | - $context['can_like'] = allowedTo('likes_like'); |
|
432 | + if (!empty($modSettings['enable_likes'])) { |
|
433 | + $context['can_like'] = allowedTo('likes_like'); |
|
434 | + } |
|
410 | 435 | |
411 | 436 | // Find all the posts. Newer ones will have higher IDs. |
412 | 437 | $request = $smcFunc['db_query']('substring', ' |
@@ -472,12 +497,13 @@ discard block |
||
472 | 497 | ); |
473 | 498 | |
474 | 499 | // Get the likes for each message. |
475 | - if (!empty($modSettings['enable_likes'])) |
|
476 | - $posts[$row['id_msg']]['likes'] = array( |
|
500 | + if (!empty($modSettings['enable_likes'])) { |
|
501 | + $posts[$row['id_msg']]['likes'] = array( |
|
477 | 502 | 'count' => $row['likes'], |
478 | 503 | 'you' => in_array($row['id_msg'], prepareLikesContext($row['id_topic'])), |
479 | 504 | 'can_like' => !$context['user']['is_guest'] && $row['id_member'] != $context['user']['id'] && !empty($context['can_like']), |
480 | 505 | ); |
506 | + } |
|
481 | 507 | } |
482 | 508 | $smcFunc['db_free_result']($request); |
483 | 509 | |
@@ -485,13 +511,14 @@ discard block |
||
485 | 511 | call_integration_hook('integrate_ssi_queryPosts', array(&$posts)); |
486 | 512 | |
487 | 513 | // Just return it. |
488 | - if ($output_method != 'echo' || empty($posts)) |
|
489 | - return $posts; |
|
514 | + if ($output_method != 'echo' || empty($posts)) { |
|
515 | + return $posts; |
|
516 | + } |
|
490 | 517 | |
491 | 518 | echo ' |
492 | 519 | <table style="border: none" class="ssi_table">'; |
493 | - foreach ($posts as $post) |
|
494 | - echo ' |
|
520 | + foreach ($posts as $post) { |
|
521 | + echo ' |
|
495 | 522 | <tr> |
496 | 523 | <td style="text-align: right; vertical-align: top; white-space: nowrap"> |
497 | 524 | [', $post['board']['link'], '] |
@@ -505,6 +532,7 @@ discard block |
||
505 | 532 | ', $post['time'], ' |
506 | 533 | </td> |
507 | 534 | </tr>'; |
535 | + } |
|
508 | 536 | echo ' |
509 | 537 | </table>'; |
510 | 538 | } |
@@ -522,25 +550,26 @@ discard block |
||
522 | 550 | global $settings, $scripturl, $txt, $user_info; |
523 | 551 | global $modSettings, $smcFunc, $context; |
524 | 552 | |
525 | - if ($exclude_boards === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0) |
|
526 | - $exclude_boards = array($modSettings['recycle_board']); |
|
527 | - else |
|
528 | - $exclude_boards = empty($exclude_boards) ? array() : (is_array($exclude_boards) ? $exclude_boards : array($exclude_boards)); |
|
553 | + if ($exclude_boards === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0) { |
|
554 | + $exclude_boards = array($modSettings['recycle_board']); |
|
555 | + } else { |
|
556 | + $exclude_boards = empty($exclude_boards) ? array() : (is_array($exclude_boards) ? $exclude_boards : array($exclude_boards)); |
|
557 | + } |
|
529 | 558 | |
530 | 559 | // Only some boards?. |
531 | 560 | if (is_array($include_boards) || (int) $include_boards === $include_boards) |
532 | 561 | { |
533 | 562 | $include_boards = is_array($include_boards) ? $include_boards : array($include_boards); |
534 | - } |
|
535 | - elseif ($include_boards != null) |
|
563 | + } elseif ($include_boards != null) |
|
536 | 564 | { |
537 | 565 | $output_method = $include_boards; |
538 | 566 | $include_boards = array(); |
539 | 567 | } |
540 | 568 | |
541 | 569 | $icon_sources = array(); |
542 | - foreach ($context['stable_icons'] as $icon) |
|
543 | - $icon_sources[$icon] = 'images_url'; |
|
570 | + foreach ($context['stable_icons'] as $icon) { |
|
571 | + $icon_sources[$icon] = 'images_url'; |
|
572 | + } |
|
544 | 573 | |
545 | 574 | // Find all the posts in distinct topics. Newer ones will have higher IDs. |
546 | 575 | $request = $smcFunc['db_query']('substring', ' |
@@ -565,13 +594,15 @@ discard block |
||
565 | 594 | ) |
566 | 595 | ); |
567 | 596 | $topics = array(); |
568 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
569 | - $topics[$row['id_topic']] = $row; |
|
597 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
598 | + $topics[$row['id_topic']] = $row; |
|
599 | + } |
|
570 | 600 | $smcFunc['db_free_result']($request); |
571 | 601 | |
572 | 602 | // Did we find anything? If not, bail. |
573 | - if (empty($topics)) |
|
574 | - return array(); |
|
603 | + if (empty($topics)) { |
|
604 | + return array(); |
|
605 | + } |
|
575 | 606 | |
576 | 607 | $recycle_board = !empty($modSettings['recycle_enable']) && !empty($modSettings['recycle_board']) ? (int) $modSettings['recycle_board'] : 0; |
577 | 608 | |
@@ -599,19 +630,22 @@ discard block |
||
599 | 630 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
600 | 631 | { |
601 | 632 | $row['body'] = strip_tags(strtr(parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']), array('<br>' => ' '))); |
602 | - if ($smcFunc['strlen']($row['body']) > 128) |
|
603 | - $row['body'] = $smcFunc['substr']($row['body'], 0, 128) . '...'; |
|
633 | + if ($smcFunc['strlen']($row['body']) > 128) { |
|
634 | + $row['body'] = $smcFunc['substr']($row['body'], 0, 128) . '...'; |
|
635 | + } |
|
604 | 636 | |
605 | 637 | // Censor the subject. |
606 | 638 | censorText($row['subject']); |
607 | 639 | censorText($row['body']); |
608 | 640 | |
609 | 641 | // Recycled icon |
610 | - if (!empty($recycle_board) && $topics[$row['id_topic']]['id_board']) |
|
611 | - $row['icon'] = 'recycled'; |
|
642 | + if (!empty($recycle_board) && $topics[$row['id_topic']]['id_board']) { |
|
643 | + $row['icon'] = 'recycled'; |
|
644 | + } |
|
612 | 645 | |
613 | - if (!empty($modSettings['messageIconChecks_enable']) && !isset($icon_sources[$row['icon']])) |
|
614 | - $icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
646 | + if (!empty($modSettings['messageIconChecks_enable']) && !isset($icon_sources[$row['icon']])) { |
|
647 | + $icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
648 | + } |
|
615 | 649 | |
616 | 650 | // Build the array. |
617 | 651 | $posts[] = array( |
@@ -650,13 +684,14 @@ discard block |
||
650 | 684 | call_integration_hook('integrate_ssi_recentTopics', array(&$posts)); |
651 | 685 | |
652 | 686 | // Just return it. |
653 | - if ($output_method != 'echo' || empty($posts)) |
|
654 | - return $posts; |
|
687 | + if ($output_method != 'echo' || empty($posts)) { |
|
688 | + return $posts; |
|
689 | + } |
|
655 | 690 | |
656 | 691 | echo ' |
657 | 692 | <table style="border: none" class="ssi_table">'; |
658 | - foreach ($posts as $post) |
|
659 | - echo ' |
|
693 | + foreach ($posts as $post) { |
|
694 | + echo ' |
|
660 | 695 | <tr> |
661 | 696 | <td style="text-align: right; vertical-align: top; white-space: nowrap"> |
662 | 697 | [', $post['board']['link'], '] |
@@ -670,6 +705,7 @@ discard block |
||
670 | 705 | ', $post['time'], ' |
671 | 706 | </td> |
672 | 707 | </tr>'; |
708 | + } |
|
673 | 709 | echo ' |
674 | 710 | </table>'; |
675 | 711 | } |
@@ -694,27 +730,30 @@ discard block |
||
694 | 730 | ) |
695 | 731 | ); |
696 | 732 | $return = array(); |
697 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
698 | - $return[] = array( |
|
733 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
734 | + $return[] = array( |
|
699 | 735 | 'id' => $row['id_member'], |
700 | 736 | 'name' => $row['real_name'], |
701 | 737 | 'href' => $scripturl . '?action=profile;u=' . $row['id_member'], |
702 | 738 | 'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>', |
703 | 739 | 'posts' => $row['posts'] |
704 | 740 | ); |
741 | + } |
|
705 | 742 | $smcFunc['db_free_result']($request); |
706 | 743 | |
707 | 744 | // If mods want to do somthing with this list of members, let them do that now. |
708 | 745 | call_integration_hook('integrate_ssi_topPoster', array(&$return)); |
709 | 746 | |
710 | 747 | // Just return all the top posters. |
711 | - if ($output_method != 'echo') |
|
712 | - return $return; |
|
748 | + if ($output_method != 'echo') { |
|
749 | + return $return; |
|
750 | + } |
|
713 | 751 | |
714 | 752 | // Make a quick array to list the links in. |
715 | 753 | $temp_array = array(); |
716 | - foreach ($return as $member) |
|
717 | - $temp_array[] = $member['link']; |
|
754 | + foreach ($return as $member) { |
|
755 | + $temp_array[] = $member['link']; |
|
756 | + } |
|
718 | 757 | |
719 | 758 | echo implode(', ', $temp_array); |
720 | 759 | } |
@@ -746,8 +785,8 @@ discard block |
||
746 | 785 | ) |
747 | 786 | ); |
748 | 787 | $boards = array(); |
749 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
750 | - $boards[] = array( |
|
788 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
789 | + $boards[] = array( |
|
751 | 790 | 'id' => $row['id_board'], |
752 | 791 | 'num_posts' => $row['num_posts'], |
753 | 792 | 'num_topics' => $row['num_topics'], |
@@ -756,14 +795,16 @@ discard block |
||
756 | 795 | 'href' => $scripturl . '?board=' . $row['id_board'] . '.0', |
757 | 796 | 'link' => '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>' |
758 | 797 | ); |
798 | + } |
|
759 | 799 | $smcFunc['db_free_result']($request); |
760 | 800 | |
761 | 801 | // If mods want to do somthing with this list of boards, let them do that now. |
762 | 802 | call_integration_hook('integrate_ssi_topBoards', array(&$boards)); |
763 | 803 | |
764 | 804 | // If we shouldn't output or have nothing to output, just jump out. |
765 | - if ($output_method != 'echo' || empty($boards)) |
|
766 | - return $boards; |
|
805 | + if ($output_method != 'echo' || empty($boards)) { |
|
806 | + return $boards; |
|
807 | + } |
|
767 | 808 | |
768 | 809 | echo ' |
769 | 810 | <table class="ssi_table"> |
@@ -772,13 +813,14 @@ discard block |
||
772 | 813 | <th style="text-align: left">', $txt['board_topics'], '</th> |
773 | 814 | <th style="text-align: left">', $txt['posts'], '</th> |
774 | 815 | </tr>'; |
775 | - foreach ($boards as $sBoard) |
|
776 | - echo ' |
|
816 | + foreach ($boards as $sBoard) { |
|
817 | + echo ' |
|
777 | 818 | <tr> |
778 | 819 | <td>', $sBoard['link'], $sBoard['new'] ? ' <a href="' . $sBoard['href'] . '"><span class="new_posts">' . $txt['new'] . '</span></a>' : '', '</td> |
779 | 820 | <td style="text-align: right">', comma_format($sBoard['num_topics']), '</td> |
780 | 821 | <td style="text-align: right">', comma_format($sBoard['num_posts']), '</td> |
781 | 822 | </tr>'; |
823 | + } |
|
782 | 824 | echo ' |
783 | 825 | </table>'; |
784 | 826 | } |
@@ -811,12 +853,13 @@ discard block |
||
811 | 853 | ) |
812 | 854 | ); |
813 | 855 | $topic_ids = array(); |
814 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
815 | - $topic_ids[] = $row['id_topic']; |
|
856 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
857 | + $topic_ids[] = $row['id_topic']; |
|
858 | + } |
|
816 | 859 | $smcFunc['db_free_result']($request); |
860 | + } else { |
|
861 | + $topic_ids = array(); |
|
817 | 862 | } |
818 | - else |
|
819 | - $topic_ids = array(); |
|
820 | 863 | |
821 | 864 | $request = $smcFunc['db_query']('', ' |
822 | 865 | SELECT m.subject, m.id_topic, t.num_views, t.num_replies |
@@ -855,8 +898,9 @@ discard block |
||
855 | 898 | // If mods want to do somthing with this list of topics, let them do that now. |
856 | 899 | call_integration_hook('integrate_ssi_topTopics', array(&$topics, $type)); |
857 | 900 | |
858 | - if ($output_method != 'echo' || empty($topics)) |
|
859 | - return $topics; |
|
901 | + if ($output_method != 'echo' || empty($topics)) { |
|
902 | + return $topics; |
|
903 | + } |
|
860 | 904 | |
861 | 905 | echo ' |
862 | 906 | <table class="ssi_table"> |
@@ -865,8 +909,8 @@ discard block |
||
865 | 909 | <th style="text-align: left">', $txt['views'], '</th> |
866 | 910 | <th style="text-align: left">', $txt['replies'], '</th> |
867 | 911 | </tr>'; |
868 | - foreach ($topics as $sTopic) |
|
869 | - echo ' |
|
912 | + foreach ($topics as $sTopic) { |
|
913 | + echo ' |
|
870 | 914 | <tr> |
871 | 915 | <td style="text-align: left"> |
872 | 916 | ', $sTopic['link'], ' |
@@ -874,6 +918,7 @@ discard block |
||
874 | 918 | <td style="text-align: right">', comma_format($sTopic['num_views']), '</td> |
875 | 919 | <td style="text-align: right">', comma_format($sTopic['num_replies']), '</td> |
876 | 920 | </tr>'; |
921 | + } |
|
877 | 922 | echo ' |
878 | 923 | </table>'; |
879 | 924 | } |
@@ -909,12 +954,13 @@ discard block |
||
909 | 954 | { |
910 | 955 | global $txt, $context; |
911 | 956 | |
912 | - if ($output_method == 'echo') |
|
913 | - echo ' |
|
957 | + if ($output_method == 'echo') { |
|
958 | + echo ' |
|
914 | 959 | ', sprintf($txt['welcome_newest_member'], $context['common_stats']['latest_member']['link']), '<br>'; |
915 | - else |
|
916 | - return $context['common_stats']['latest_member']; |
|
917 | -} |
|
960 | + } else { |
|
961 | + return $context['common_stats']['latest_member']; |
|
962 | + } |
|
963 | + } |
|
918 | 964 | |
919 | 965 | /** |
920 | 966 | * Fetches a random member. |
@@ -963,8 +1009,9 @@ discard block |
||
963 | 1009 | } |
964 | 1010 | |
965 | 1011 | // Just to be sure put the random generator back to something... random. |
966 | - if ($random_type != '') |
|
967 | - mt_srand(time()); |
|
1012 | + if ($random_type != '') { |
|
1013 | + mt_srand(time()); |
|
1014 | + } |
|
968 | 1015 | |
969 | 1016 | return $result; |
970 | 1017 | } |
@@ -977,8 +1024,9 @@ discard block |
||
977 | 1024 | */ |
978 | 1025 | function ssi_fetchMember($member_ids = array(), $output_method = 'echo') |
979 | 1026 | { |
980 | - if (empty($member_ids)) |
|
981 | - return; |
|
1027 | + if (empty($member_ids)) { |
|
1028 | + return; |
|
1029 | + } |
|
982 | 1030 | |
983 | 1031 | // Can have more than one member if you really want... |
984 | 1032 | $member_ids = is_array($member_ids) ? $member_ids : array($member_ids); |
@@ -1003,8 +1051,9 @@ discard block |
||
1003 | 1051 | */ |
1004 | 1052 | function ssi_fetchGroupMembers($group_id = null, $output_method = 'echo') |
1005 | 1053 | { |
1006 | - if ($group_id === null) |
|
1007 | - return; |
|
1054 | + if ($group_id === null) { |
|
1055 | + return; |
|
1056 | + } |
|
1008 | 1057 | |
1009 | 1058 | $query_where = ' |
1010 | 1059 | id_group = {int:id_group} |
@@ -1031,8 +1080,9 @@ discard block |
||
1031 | 1080 | { |
1032 | 1081 | global $smcFunc, $memberContext; |
1033 | 1082 | |
1034 | - if ($query_where === null) |
|
1035 | - return; |
|
1083 | + if ($query_where === null) { |
|
1084 | + return; |
|
1085 | + } |
|
1036 | 1086 | |
1037 | 1087 | // Fetch the members in question. |
1038 | 1088 | $request = $smcFunc['db_query']('', ' |
@@ -1045,12 +1095,14 @@ discard block |
||
1045 | 1095 | )) |
1046 | 1096 | ); |
1047 | 1097 | $members = array(); |
1048 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1049 | - $members[] = $row['id_member']; |
|
1098 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1099 | + $members[] = $row['id_member']; |
|
1100 | + } |
|
1050 | 1101 | $smcFunc['db_free_result']($request); |
1051 | 1102 | |
1052 | - if (empty($members)) |
|
1053 | - return array(); |
|
1103 | + if (empty($members)) { |
|
1104 | + return array(); |
|
1105 | + } |
|
1054 | 1106 | |
1055 | 1107 | // If mods want to do somthing with this list of members, let them do that now. |
1056 | 1108 | call_integration_hook('integrate_ssi_queryMembers', array(&$members)); |
@@ -1059,23 +1111,25 @@ discard block |
||
1059 | 1111 | loadMemberData($members); |
1060 | 1112 | |
1061 | 1113 | // Draw the table! |
1062 | - if ($output_method == 'echo') |
|
1063 | - echo ' |
|
1114 | + if ($output_method == 'echo') { |
|
1115 | + echo ' |
|
1064 | 1116 | <table style="border: none" class="ssi_table">'; |
1117 | + } |
|
1065 | 1118 | |
1066 | 1119 | $query_members = array(); |
1067 | 1120 | foreach ($members as $member) |
1068 | 1121 | { |
1069 | 1122 | // Load their context data. |
1070 | - if (!loadMemberContext($member)) |
|
1071 | - continue; |
|
1123 | + if (!loadMemberContext($member)) { |
|
1124 | + continue; |
|
1125 | + } |
|
1072 | 1126 | |
1073 | 1127 | // Store this member's information. |
1074 | 1128 | $query_members[$member] = $memberContext[$member]; |
1075 | 1129 | |
1076 | 1130 | // Only do something if we're echo'ing. |
1077 | - if ($output_method == 'echo') |
|
1078 | - echo ' |
|
1131 | + if ($output_method == 'echo') { |
|
1132 | + echo ' |
|
1079 | 1133 | <tr> |
1080 | 1134 | <td style="text-align: right; vertical-align: top; white-space: nowrap"> |
1081 | 1135 | ', $query_members[$member]['link'], ' |
@@ -1083,12 +1137,14 @@ discard block |
||
1083 | 1137 | <br>', $query_members[$member]['avatar']['image'], ' |
1084 | 1138 | </td> |
1085 | 1139 | </tr>'; |
1140 | + } |
|
1086 | 1141 | } |
1087 | 1142 | |
1088 | 1143 | // End the table if appropriate. |
1089 | - if ($output_method == 'echo') |
|
1090 | - echo ' |
|
1144 | + if ($output_method == 'echo') { |
|
1145 | + echo ' |
|
1091 | 1146 | </table>'; |
1147 | + } |
|
1092 | 1148 | |
1093 | 1149 | // Send back the data. |
1094 | 1150 | return $query_members; |
@@ -1103,8 +1159,9 @@ discard block |
||
1103 | 1159 | { |
1104 | 1160 | global $txt, $scripturl, $modSettings, $smcFunc; |
1105 | 1161 | |
1106 | - if (!allowedTo('view_stats')) |
|
1107 | - return; |
|
1162 | + if (!allowedTo('view_stats')) { |
|
1163 | + return; |
|
1164 | + } |
|
1108 | 1165 | |
1109 | 1166 | $totals = array( |
1110 | 1167 | 'members' => $modSettings['totalMembers'], |
@@ -1133,8 +1190,9 @@ discard block |
||
1133 | 1190 | // If mods want to do somthing with the board stats, let them do that now. |
1134 | 1191 | call_integration_hook('integrate_ssi_boardStats', array(&$totals)); |
1135 | 1192 | |
1136 | - if ($output_method != 'echo') |
|
1137 | - return $totals; |
|
1193 | + if ($output_method != 'echo') { |
|
1194 | + return $totals; |
|
1195 | + } |
|
1138 | 1196 | |
1139 | 1197 | echo ' |
1140 | 1198 | ', $txt['total_members'], ': <a href="', $scripturl . '?action=mlist">', comma_format($totals['members']), '</a><br> |
@@ -1163,8 +1221,8 @@ discard block |
||
1163 | 1221 | call_integration_hook('integrate_ssi_whosOnline', array(&$return)); |
1164 | 1222 | |
1165 | 1223 | // Add some redundancy for backwards compatibility reasons. |
1166 | - if ($output_method != 'echo') |
|
1167 | - return $return + array( |
|
1224 | + if ($output_method != 'echo') { |
|
1225 | + return $return + array( |
|
1168 | 1226 | 'users' => $return['users_online'], |
1169 | 1227 | 'guests' => $return['num_guests'], |
1170 | 1228 | 'hidden' => $return['num_users_hidden'], |
@@ -1172,29 +1230,35 @@ discard block |
||
1172 | 1230 | 'num_users' => $return['num_users_online'], |
1173 | 1231 | 'total_users' => $return['num_users_online'] + $return['num_guests'], |
1174 | 1232 | ); |
1233 | + } |
|
1175 | 1234 | |
1176 | 1235 | echo ' |
1177 | 1236 | ', comma_format($return['num_guests']), ' ', $return['num_guests'] == 1 ? $txt['guest'] : $txt['guests'], ', ', comma_format($return['num_users_online']), ' ', $return['num_users_online'] == 1 ? $txt['user'] : $txt['users']; |
1178 | 1237 | |
1179 | 1238 | $bracketList = array(); |
1180 | - if (!empty($user_info['buddies'])) |
|
1181 | - $bracketList[] = comma_format($return['num_buddies']) . ' ' . ($return['num_buddies'] == 1 ? $txt['buddy'] : $txt['buddies']); |
|
1182 | - if (!empty($return['num_spiders'])) |
|
1183 | - $bracketList[] = comma_format($return['num_spiders']) . ' ' . ($return['num_spiders'] == 1 ? $txt['spider'] : $txt['spiders']); |
|
1184 | - if (!empty($return['num_users_hidden'])) |
|
1185 | - $bracketList[] = comma_format($return['num_users_hidden']) . ' ' . $txt['hidden']; |
|
1239 | + if (!empty($user_info['buddies'])) { |
|
1240 | + $bracketList[] = comma_format($return['num_buddies']) . ' ' . ($return['num_buddies'] == 1 ? $txt['buddy'] : $txt['buddies']); |
|
1241 | + } |
|
1242 | + if (!empty($return['num_spiders'])) { |
|
1243 | + $bracketList[] = comma_format($return['num_spiders']) . ' ' . ($return['num_spiders'] == 1 ? $txt['spider'] : $txt['spiders']); |
|
1244 | + } |
|
1245 | + if (!empty($return['num_users_hidden'])) { |
|
1246 | + $bracketList[] = comma_format($return['num_users_hidden']) . ' ' . $txt['hidden']; |
|
1247 | + } |
|
1186 | 1248 | |
1187 | - if (!empty($bracketList)) |
|
1188 | - echo ' (' . implode(', ', $bracketList) . ')'; |
|
1249 | + if (!empty($bracketList)) { |
|
1250 | + echo ' (' . implode(', ', $bracketList) . ')'; |
|
1251 | + } |
|
1189 | 1252 | |
1190 | 1253 | echo '<br> |
1191 | 1254 | ', implode(', ', $return['list_users_online']); |
1192 | 1255 | |
1193 | 1256 | // Showing membergroups? |
1194 | - if (!empty($settings['show_group_key']) && !empty($return['membergroups'])) |
|
1195 | - echo '<br> |
|
1257 | + if (!empty($settings['show_group_key']) && !empty($return['membergroups'])) { |
|
1258 | + echo '<br> |
|
1196 | 1259 | [' . implode('] [', $return['membergroups']) . ']'; |
1197 | -} |
|
1260 | + } |
|
1261 | + } |
|
1198 | 1262 | |
1199 | 1263 | /** |
1200 | 1264 | * Just like whosOnline except it also logs the online presence. |
@@ -1205,11 +1269,12 @@ discard block |
||
1205 | 1269 | { |
1206 | 1270 | writeLog(); |
1207 | 1271 | |
1208 | - if ($output_method != 'echo') |
|
1209 | - return ssi_whosOnline($output_method); |
|
1210 | - else |
|
1211 | - ssi_whosOnline($output_method); |
|
1212 | -} |
|
1272 | + if ($output_method != 'echo') { |
|
1273 | + return ssi_whosOnline($output_method); |
|
1274 | + } else { |
|
1275 | + ssi_whosOnline($output_method); |
|
1276 | + } |
|
1277 | + } |
|
1213 | 1278 | |
1214 | 1279 | // Shows a login box. |
1215 | 1280 | /** |
@@ -1222,11 +1287,13 @@ discard block |
||
1222 | 1287 | { |
1223 | 1288 | global $scripturl, $txt, $user_info, $context; |
1224 | 1289 | |
1225 | - if ($redirect_to != '') |
|
1226 | - $_SESSION['login_url'] = $redirect_to; |
|
1290 | + if ($redirect_to != '') { |
|
1291 | + $_SESSION['login_url'] = $redirect_to; |
|
1292 | + } |
|
1227 | 1293 | |
1228 | - if ($output_method != 'echo' || !$user_info['is_guest']) |
|
1229 | - return $user_info['is_guest']; |
|
1294 | + if ($output_method != 'echo' || !$user_info['is_guest']) { |
|
1295 | + return $user_info['is_guest']; |
|
1296 | + } |
|
1230 | 1297 | |
1231 | 1298 | // Create a login token |
1232 | 1299 | createToken('login'); |
@@ -1278,8 +1345,9 @@ discard block |
||
1278 | 1345 | |
1279 | 1346 | $boardsAllowed = array_intersect(boardsAllowedTo('poll_view'), boardsAllowedTo('poll_vote')); |
1280 | 1347 | |
1281 | - if (empty($boardsAllowed)) |
|
1282 | - return array(); |
|
1348 | + if (empty($boardsAllowed)) { |
|
1349 | + return array(); |
|
1350 | + } |
|
1283 | 1351 | |
1284 | 1352 | $request = $smcFunc['db_query']('', ' |
1285 | 1353 | SELECT p.id_poll, p.question, t.id_topic, p.max_votes, p.guest_vote, p.hide_results, p.expire_time |
@@ -1312,12 +1380,14 @@ discard block |
||
1312 | 1380 | $smcFunc['db_free_result']($request); |
1313 | 1381 | |
1314 | 1382 | // This user has voted on all the polls. |
1315 | - if (empty($row) || !is_array($row)) |
|
1316 | - return array(); |
|
1383 | + if (empty($row) || !is_array($row)) { |
|
1384 | + return array(); |
|
1385 | + } |
|
1317 | 1386 | |
1318 | 1387 | // If this is a guest who's voted we'll through ourselves to show poll to show the results. |
1319 | - if ($user_info['is_guest'] && (!$row['guest_vote'] || (isset($_COOKIE['guest_poll_vote']) && in_array($row['id_poll'], explode(',', $_COOKIE['guest_poll_vote']))))) |
|
1320 | - return ssi_showPoll($row['id_topic'], $output_method); |
|
1388 | + if ($user_info['is_guest'] && (!$row['guest_vote'] || (isset($_COOKIE['guest_poll_vote']) && in_array($row['id_poll'], explode(',', $_COOKIE['guest_poll_vote']))))) { |
|
1389 | + return ssi_showPoll($row['id_topic'], $output_method); |
|
1390 | + } |
|
1321 | 1391 | |
1322 | 1392 | $request = $smcFunc['db_query']('', ' |
1323 | 1393 | SELECT COUNT(DISTINCT id_member) |
@@ -1381,8 +1451,9 @@ discard block |
||
1381 | 1451 | // If mods want to do somthing with this list of polls, let them do that now. |
1382 | 1452 | call_integration_hook('integrate_ssi_recentPoll', array(&$return, $topPollInstead)); |
1383 | 1453 | |
1384 | - if ($output_method != 'echo') |
|
1385 | - return $return; |
|
1454 | + if ($output_method != 'echo') { |
|
1455 | + return $return; |
|
1456 | + } |
|
1386 | 1457 | |
1387 | 1458 | if ($allow_view_results) |
1388 | 1459 | { |
@@ -1391,19 +1462,20 @@ discard block |
||
1391 | 1462 | <strong>', $return['question'], '</strong><br> |
1392 | 1463 | ', !empty($return['allowed_warning']) ? $return['allowed_warning'] . '<br>' : ''; |
1393 | 1464 | |
1394 | - foreach ($return['options'] as $option) |
|
1395 | - echo ' |
|
1465 | + foreach ($return['options'] as $option) { |
|
1466 | + echo ' |
|
1396 | 1467 | <label for="', $option['id'], '">', $option['vote_button'], ' ', $option['option'], '</label><br>'; |
1468 | + } |
|
1397 | 1469 | |
1398 | 1470 | echo ' |
1399 | 1471 | <input type="submit" value="', $txt['poll_vote'], '" class="button"> |
1400 | 1472 | <input type="hidden" name="poll" value="', $return['id'], '"> |
1401 | 1473 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
1402 | 1474 | </form>'; |
1475 | + } else { |
|
1476 | + echo $txt['poll_cannot_see']; |
|
1477 | + } |
|
1403 | 1478 | } |
1404 | - else |
|
1405 | - echo $txt['poll_cannot_see']; |
|
1406 | -} |
|
1407 | 1479 | |
1408 | 1480 | /** |
1409 | 1481 | * Shows the poll from the specified topic |
@@ -1417,13 +1489,15 @@ discard block |
||
1417 | 1489 | |
1418 | 1490 | $boardsAllowed = boardsAllowedTo('poll_view'); |
1419 | 1491 | |
1420 | - if (empty($boardsAllowed)) |
|
1421 | - return array(); |
|
1492 | + if (empty($boardsAllowed)) { |
|
1493 | + return array(); |
|
1494 | + } |
|
1422 | 1495 | |
1423 | - if ($topic === null && isset($_REQUEST['ssi_topic'])) |
|
1424 | - $topic = (int) $_REQUEST['ssi_topic']; |
|
1425 | - else |
|
1426 | - $topic = (int) $topic; |
|
1496 | + if ($topic === null && isset($_REQUEST['ssi_topic'])) { |
|
1497 | + $topic = (int) $_REQUEST['ssi_topic']; |
|
1498 | + } else { |
|
1499 | + $topic = (int) $topic; |
|
1500 | + } |
|
1427 | 1501 | |
1428 | 1502 | $request = $smcFunc['db_query']('', ' |
1429 | 1503 | SELECT |
@@ -1444,17 +1518,18 @@ discard block |
||
1444 | 1518 | ); |
1445 | 1519 | |
1446 | 1520 | // Either this topic has no poll, or the user cannot view it. |
1447 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
1448 | - return array(); |
|
1521 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
1522 | + return array(); |
|
1523 | + } |
|
1449 | 1524 | |
1450 | 1525 | $row = $smcFunc['db_fetch_assoc']($request); |
1451 | 1526 | $smcFunc['db_free_result']($request); |
1452 | 1527 | |
1453 | 1528 | // Check if they can vote. |
1454 | 1529 | $already_voted = false; |
1455 | - if (!empty($row['expire_time']) && $row['expire_time'] < time()) |
|
1456 | - $allow_vote = false; |
|
1457 | - elseif ($user_info['is_guest']) |
|
1530 | + if (!empty($row['expire_time']) && $row['expire_time'] < time()) { |
|
1531 | + $allow_vote = false; |
|
1532 | + } elseif ($user_info['is_guest']) |
|
1458 | 1533 | { |
1459 | 1534 | // There's a difference between "allowed to vote" and "already voted"... |
1460 | 1535 | $allow_vote = $row['guest_vote']; |
@@ -1464,10 +1539,9 @@ discard block |
||
1464 | 1539 | { |
1465 | 1540 | $already_voted = true; |
1466 | 1541 | } |
1467 | - } |
|
1468 | - elseif (!empty($row['voting_locked']) || !allowedTo('poll_vote', $row['id_board'])) |
|
1469 | - $allow_vote = false; |
|
1470 | - else |
|
1542 | + } elseif (!empty($row['voting_locked']) || !allowedTo('poll_vote', $row['id_board'])) { |
|
1543 | + $allow_vote = false; |
|
1544 | + } else |
|
1471 | 1545 | { |
1472 | 1546 | $request = $smcFunc['db_query']('', ' |
1473 | 1547 | SELECT id_member |
@@ -1549,8 +1623,9 @@ discard block |
||
1549 | 1623 | // If mods want to do somthing with this poll, let them do that now. |
1550 | 1624 | call_integration_hook('integrate_ssi_showPoll', array(&$return)); |
1551 | 1625 | |
1552 | - if ($output_method != 'echo') |
|
1553 | - return $return; |
|
1626 | + if ($output_method != 'echo') { |
|
1627 | + return $return; |
|
1628 | + } |
|
1554 | 1629 | |
1555 | 1630 | if ($return['allow_vote']) |
1556 | 1631 | { |
@@ -1559,17 +1634,17 @@ discard block |
||
1559 | 1634 | <strong>', $return['question'], '</strong><br> |
1560 | 1635 | ', !empty($return['allowed_warning']) ? $return['allowed_warning'] . '<br>' : ''; |
1561 | 1636 | |
1562 | - foreach ($return['options'] as $option) |
|
1563 | - echo ' |
|
1637 | + foreach ($return['options'] as $option) { |
|
1638 | + echo ' |
|
1564 | 1639 | <label for="', $option['id'], '">', $option['vote_button'], ' ', $option['option'], '</label><br>'; |
1640 | + } |
|
1565 | 1641 | |
1566 | 1642 | echo ' |
1567 | 1643 | <input type="submit" value="', $txt['poll_vote'], '" class="button"> |
1568 | 1644 | <input type="hidden" name="poll" value="', $return['id'], '"> |
1569 | 1645 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
1570 | 1646 | </form>'; |
1571 | - } |
|
1572 | - else |
|
1647 | + } else |
|
1573 | 1648 | { |
1574 | 1649 | echo ' |
1575 | 1650 | <div class="ssi_poll"> |
@@ -1649,27 +1724,32 @@ discard block |
||
1649 | 1724 | 'is_approved' => 1, |
1650 | 1725 | ) |
1651 | 1726 | ); |
1652 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
1653 | - die; |
|
1727 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
1728 | + die; |
|
1729 | + } |
|
1654 | 1730 | $row = $smcFunc['db_fetch_assoc']($request); |
1655 | 1731 | $smcFunc['db_free_result']($request); |
1656 | 1732 | |
1657 | - if (!empty($row['voting_locked']) || ($row['selected'] != -1 && !$user_info['is_guest']) || (!empty($row['expire_time']) && time() > $row['expire_time'])) |
|
1658 | - redirectexit('topic=' . $row['id_topic'] . '.0'); |
|
1733 | + if (!empty($row['voting_locked']) || ($row['selected'] != -1 && !$user_info['is_guest']) || (!empty($row['expire_time']) && time() > $row['expire_time'])) { |
|
1734 | + redirectexit('topic=' . $row['id_topic'] . '.0'); |
|
1735 | + } |
|
1659 | 1736 | |
1660 | 1737 | // Too many options checked? |
1661 | - if (count($_REQUEST['options']) > $row['max_votes']) |
|
1662 | - redirectexit('topic=' . $row['id_topic'] . '.0'); |
|
1738 | + if (count($_REQUEST['options']) > $row['max_votes']) { |
|
1739 | + redirectexit('topic=' . $row['id_topic'] . '.0'); |
|
1740 | + } |
|
1663 | 1741 | |
1664 | 1742 | // It's a guest who has already voted? |
1665 | 1743 | if ($user_info['is_guest']) |
1666 | 1744 | { |
1667 | 1745 | // Guest voting disabled? |
1668 | - if (!$row['guest_vote']) |
|
1669 | - redirectexit('topic=' . $row['id_topic'] . '.0'); |
|
1746 | + if (!$row['guest_vote']) { |
|
1747 | + redirectexit('topic=' . $row['id_topic'] . '.0'); |
|
1748 | + } |
|
1670 | 1749 | // Already voted? |
1671 | - elseif (isset($_COOKIE['guest_poll_vote']) && in_array($row['id_poll'], explode(',', $_COOKIE['guest_poll_vote']))) |
|
1672 | - redirectexit('topic=' . $row['id_topic'] . '.0'); |
|
1750 | + elseif (isset($_COOKIE['guest_poll_vote']) && in_array($row['id_poll'], explode(',', $_COOKIE['guest_poll_vote']))) { |
|
1751 | + redirectexit('topic=' . $row['id_topic'] . '.0'); |
|
1752 | + } |
|
1673 | 1753 | } |
1674 | 1754 | |
1675 | 1755 | $sOptions = array(); |
@@ -1723,11 +1803,13 @@ discard block |
||
1723 | 1803 | { |
1724 | 1804 | global $scripturl, $txt, $context; |
1725 | 1805 | |
1726 | - if (!allowedTo('search_posts')) |
|
1727 | - return; |
|
1806 | + if (!allowedTo('search_posts')) { |
|
1807 | + return; |
|
1808 | + } |
|
1728 | 1809 | |
1729 | - if ($output_method != 'echo') |
|
1730 | - return $scripturl . '?action=search'; |
|
1810 | + if ($output_method != 'echo') { |
|
1811 | + return $scripturl . '?action=search'; |
|
1812 | + } |
|
1731 | 1813 | |
1732 | 1814 | echo ' |
1733 | 1815 | <form action="', $scripturl, '?action=search2" method="post" accept-charset="', $context['character_set'], '"> |
@@ -1749,8 +1831,9 @@ discard block |
||
1749 | 1831 | // If mods want to do somthing with the news, let them do that now. Don't need to pass the news line itself, since it is already in $context. |
1750 | 1832 | call_integration_hook('integrate_ssi_news'); |
1751 | 1833 | |
1752 | - if ($output_method != 'echo') |
|
1753 | - return $context['random_news_line']; |
|
1834 | + if ($output_method != 'echo') { |
|
1835 | + return $context['random_news_line']; |
|
1836 | + } |
|
1754 | 1837 | |
1755 | 1838 | echo $context['random_news_line']; |
1756 | 1839 | } |
@@ -1764,8 +1847,9 @@ discard block |
||
1764 | 1847 | { |
1765 | 1848 | global $scripturl, $modSettings, $user_info; |
1766 | 1849 | |
1767 | - if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view') || !allowedTo('profile_view')) |
|
1768 | - return; |
|
1850 | + if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view') || !allowedTo('profile_view')) { |
|
1851 | + return; |
|
1852 | + } |
|
1769 | 1853 | |
1770 | 1854 | $eventOptions = array( |
1771 | 1855 | 'include_birthdays' => true, |
@@ -1776,13 +1860,15 @@ discard block |
||
1776 | 1860 | // The ssi_todaysCalendar variants all use the same hook and just pass on $eventOptions so the hooked code can distinguish different cases if necessary |
1777 | 1861 | call_integration_hook('integrate_ssi_calendar', array(&$return, $eventOptions)); |
1778 | 1862 | |
1779 | - if ($output_method != 'echo') |
|
1780 | - return $return['calendar_birthdays']; |
|
1863 | + if ($output_method != 'echo') { |
|
1864 | + return $return['calendar_birthdays']; |
|
1865 | + } |
|
1781 | 1866 | |
1782 | - foreach ($return['calendar_birthdays'] as $member) |
|
1783 | - echo ' |
|
1867 | + foreach ($return['calendar_birthdays'] as $member) { |
|
1868 | + echo ' |
|
1784 | 1869 | <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'] ? ', ' : ''); |
1785 | -} |
|
1870 | + } |
|
1871 | + } |
|
1786 | 1872 | |
1787 | 1873 | /** |
1788 | 1874 | * Shows today's holidays. |
@@ -1793,8 +1879,9 @@ discard block |
||
1793 | 1879 | { |
1794 | 1880 | global $modSettings, $user_info; |
1795 | 1881 | |
1796 | - if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) |
|
1797 | - return; |
|
1882 | + if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) { |
|
1883 | + return; |
|
1884 | + } |
|
1798 | 1885 | |
1799 | 1886 | $eventOptions = array( |
1800 | 1887 | 'include_holidays' => true, |
@@ -1805,8 +1892,9 @@ discard block |
||
1805 | 1892 | // The ssi_todaysCalendar variants all use the same hook and just pass on $eventOptions so the hooked code can distinguish different cases if necessary |
1806 | 1893 | call_integration_hook('integrate_ssi_calendar', array(&$return, $eventOptions)); |
1807 | 1894 | |
1808 | - if ($output_method != 'echo') |
|
1809 | - return $return['calendar_holidays']; |
|
1895 | + if ($output_method != 'echo') { |
|
1896 | + return $return['calendar_holidays']; |
|
1897 | + } |
|
1810 | 1898 | |
1811 | 1899 | echo ' |
1812 | 1900 | ', implode(', ', $return['calendar_holidays']); |
@@ -1820,8 +1908,9 @@ discard block |
||
1820 | 1908 | { |
1821 | 1909 | global $modSettings, $user_info; |
1822 | 1910 | |
1823 | - if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) |
|
1824 | - return; |
|
1911 | + if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) { |
|
1912 | + return; |
|
1913 | + } |
|
1825 | 1914 | |
1826 | 1915 | $eventOptions = array( |
1827 | 1916 | 'include_events' => true, |
@@ -1832,14 +1921,16 @@ discard block |
||
1832 | 1921 | // The ssi_todaysCalendar variants all use the same hook and just pass on $eventOptions so the hooked code can distinguish different cases if necessary |
1833 | 1922 | call_integration_hook('integrate_ssi_calendar', array(&$return, $eventOptions)); |
1834 | 1923 | |
1835 | - if ($output_method != 'echo') |
|
1836 | - return $return['calendar_events']; |
|
1924 | + if ($output_method != 'echo') { |
|
1925 | + return $return['calendar_events']; |
|
1926 | + } |
|
1837 | 1927 | |
1838 | 1928 | foreach ($return['calendar_events'] as $event) |
1839 | 1929 | { |
1840 | - if ($event['can_edit']) |
|
1841 | - echo ' |
|
1930 | + if ($event['can_edit']) { |
|
1931 | + echo ' |
|
1842 | 1932 | <a href="' . $event['modify_href'] . '" style="color: #ff0000;">*</a> '; |
1933 | + } |
|
1843 | 1934 | echo ' |
1844 | 1935 | ' . $event['link'] . (!$event['is_last'] ? ', ' : ''); |
1845 | 1936 | } |
@@ -1854,8 +1945,9 @@ discard block |
||
1854 | 1945 | { |
1855 | 1946 | global $modSettings, $txt, $scripturl, $user_info; |
1856 | 1947 | |
1857 | - if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) |
|
1858 | - return; |
|
1948 | + if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) { |
|
1949 | + return; |
|
1950 | + } |
|
1859 | 1951 | |
1860 | 1952 | $eventOptions = array( |
1861 | 1953 | 'include_birthdays' => allowedTo('profile_view'), |
@@ -1868,19 +1960,22 @@ discard block |
||
1868 | 1960 | // The ssi_todaysCalendar variants all use the same hook and just pass on $eventOptions so the hooked code can distinguish different cases if necessary |
1869 | 1961 | call_integration_hook('integrate_ssi_calendar', array(&$return, $eventOptions)); |
1870 | 1962 | |
1871 | - if ($output_method != 'echo') |
|
1872 | - return $return; |
|
1963 | + if ($output_method != 'echo') { |
|
1964 | + return $return; |
|
1965 | + } |
|
1873 | 1966 | |
1874 | - if (!empty($return['calendar_holidays'])) |
|
1875 | - echo ' |
|
1967 | + if (!empty($return['calendar_holidays'])) { |
|
1968 | + echo ' |
|
1876 | 1969 | <span class="holiday">' . $txt['calendar_prompt'] . ' ' . implode(', ', $return['calendar_holidays']) . '<br></span>'; |
1970 | + } |
|
1877 | 1971 | if (!empty($return['calendar_birthdays'])) |
1878 | 1972 | { |
1879 | 1973 | echo ' |
1880 | 1974 | <span class="birthday">' . $txt['birthdays_upcoming'] . '</span> '; |
1881 | - foreach ($return['calendar_birthdays'] as $member) |
|
1882 | - echo ' |
|
1975 | + foreach ($return['calendar_birthdays'] as $member) { |
|
1976 | + echo ' |
|
1883 | 1977 | <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'] ? ', ' : ''; |
1978 | + } |
|
1884 | 1979 | echo ' |
1885 | 1980 | <br>'; |
1886 | 1981 | } |
@@ -1890,9 +1985,10 @@ discard block |
||
1890 | 1985 | <span class="event">' . $txt['events_upcoming'] . '</span> '; |
1891 | 1986 | foreach ($return['calendar_events'] as $event) |
1892 | 1987 | { |
1893 | - if ($event['can_edit']) |
|
1894 | - echo ' |
|
1988 | + if ($event['can_edit']) { |
|
1989 | + echo ' |
|
1895 | 1990 | <a href="' . $event['modify_href'] . '" style="color: #ff0000;">*</a> '; |
1991 | + } |
|
1896 | 1992 | echo ' |
1897 | 1993 | ' . $event['link'] . (!$event['is_last'] ? ', ' : ''); |
1898 | 1994 | } |
@@ -1916,25 +2012,29 @@ discard block |
||
1916 | 2012 | loadLanguage('Stats'); |
1917 | 2013 | |
1918 | 2014 | // Must be integers.... |
1919 | - if ($limit === null) |
|
1920 | - $limit = isset($_GET['limit']) ? (int) $_GET['limit'] : 5; |
|
1921 | - else |
|
1922 | - $limit = (int) $limit; |
|
1923 | - |
|
1924 | - if ($start === null) |
|
1925 | - $start = isset($_GET['start']) ? (int) $_GET['start'] : 0; |
|
1926 | - else |
|
1927 | - $start = (int) $start; |
|
1928 | - |
|
1929 | - if ($board !== null) |
|
1930 | - $board = (int) $board; |
|
1931 | - elseif (isset($_GET['board'])) |
|
1932 | - $board = (int) $_GET['board']; |
|
1933 | - |
|
1934 | - if ($length === null) |
|
1935 | - $length = isset($_GET['length']) ? (int) $_GET['length'] : 0; |
|
1936 | - else |
|
1937 | - $length = (int) $length; |
|
2015 | + if ($limit === null) { |
|
2016 | + $limit = isset($_GET['limit']) ? (int) $_GET['limit'] : 5; |
|
2017 | + } else { |
|
2018 | + $limit = (int) $limit; |
|
2019 | + } |
|
2020 | + |
|
2021 | + if ($start === null) { |
|
2022 | + $start = isset($_GET['start']) ? (int) $_GET['start'] : 0; |
|
2023 | + } else { |
|
2024 | + $start = (int) $start; |
|
2025 | + } |
|
2026 | + |
|
2027 | + if ($board !== null) { |
|
2028 | + $board = (int) $board; |
|
2029 | + } elseif (isset($_GET['board'])) { |
|
2030 | + $board = (int) $_GET['board']; |
|
2031 | + } |
|
2032 | + |
|
2033 | + if ($length === null) { |
|
2034 | + $length = isset($_GET['length']) ? (int) $_GET['length'] : 0; |
|
2035 | + } else { |
|
2036 | + $length = (int) $length; |
|
2037 | + } |
|
1938 | 2038 | |
1939 | 2039 | $limit = max(0, $limit); |
1940 | 2040 | $start = max(0, $start); |
@@ -1952,17 +2052,19 @@ discard block |
||
1952 | 2052 | ); |
1953 | 2053 | if ($smcFunc['db_num_rows']($request) == 0) |
1954 | 2054 | { |
1955 | - if ($output_method == 'echo') |
|
1956 | - die($txt['ssi_no_guests']); |
|
1957 | - else |
|
1958 | - return array(); |
|
2055 | + if ($output_method == 'echo') { |
|
2056 | + die($txt['ssi_no_guests']); |
|
2057 | + } else { |
|
2058 | + return array(); |
|
2059 | + } |
|
1959 | 2060 | } |
1960 | 2061 | list ($board) = $smcFunc['db_fetch_row']($request); |
1961 | 2062 | $smcFunc['db_free_result']($request); |
1962 | 2063 | |
1963 | 2064 | $icon_sources = array(); |
1964 | - foreach ($context['stable_icons'] as $icon) |
|
1965 | - $icon_sources[$icon] = 'images_url'; |
|
2065 | + foreach ($context['stable_icons'] as $icon) { |
|
2066 | + $icon_sources[$icon] = 'images_url'; |
|
2067 | + } |
|
1966 | 2068 | |
1967 | 2069 | if (!empty($modSettings['enable_likes'])) |
1968 | 2070 | { |
@@ -1985,12 +2087,14 @@ discard block |
||
1985 | 2087 | ) |
1986 | 2088 | ); |
1987 | 2089 | $posts = array(); |
1988 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1989 | - $posts[] = $row['id_first_msg']; |
|
2090 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2091 | + $posts[] = $row['id_first_msg']; |
|
2092 | + } |
|
1990 | 2093 | $smcFunc['db_free_result']($request); |
1991 | 2094 | |
1992 | - if (empty($posts)) |
|
1993 | - return array(); |
|
2095 | + if (empty($posts)) { |
|
2096 | + return array(); |
|
2097 | + } |
|
1994 | 2098 | |
1995 | 2099 | // Find the posts. |
1996 | 2100 | $request = $smcFunc['db_query']('', ' |
@@ -2020,24 +2124,28 @@ discard block |
||
2020 | 2124 | $last_space = strrpos($row['body'], ' '); |
2021 | 2125 | $last_open = strrpos($row['body'], '<'); |
2022 | 2126 | $last_close = strrpos($row['body'], '>'); |
2023 | - if (empty($last_space) || ($last_space == $last_open + 3 && (empty($last_close) || (!empty($last_close) && $last_close < $last_open))) || $last_space < $last_open || $last_open == $length - 6) |
|
2024 | - $cutoff = $last_open; |
|
2025 | - elseif (empty($last_close) || $last_close < $last_open) |
|
2026 | - $cutoff = $last_space; |
|
2127 | + if (empty($last_space) || ($last_space == $last_open + 3 && (empty($last_close) || (!empty($last_close) && $last_close < $last_open))) || $last_space < $last_open || $last_open == $length - 6) { |
|
2128 | + $cutoff = $last_open; |
|
2129 | + } elseif (empty($last_close) || $last_close < $last_open) { |
|
2130 | + $cutoff = $last_space; |
|
2131 | + } |
|
2027 | 2132 | |
2028 | - if ($cutoff !== false) |
|
2029 | - $row['body'] = $smcFunc['substr']($row['body'], 0, $cutoff); |
|
2133 | + if ($cutoff !== false) { |
|
2134 | + $row['body'] = $smcFunc['substr']($row['body'], 0, $cutoff); |
|
2135 | + } |
|
2030 | 2136 | $row['body'] .= '...'; |
2031 | 2137 | } |
2032 | 2138 | |
2033 | 2139 | $row['body'] = parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']); |
2034 | 2140 | |
2035 | - if (!empty($recycle_board) && $row['id_board'] == $recycle_board) |
|
2036 | - $row['icon'] = 'recycled'; |
|
2141 | + if (!empty($recycle_board) && $row['id_board'] == $recycle_board) { |
|
2142 | + $row['icon'] = 'recycled'; |
|
2143 | + } |
|
2037 | 2144 | |
2038 | 2145 | // Check that this message icon is there... |
2039 | - if (!empty($modSettings['messageIconChecks_enable']) && !isset($icon_sources[$row['icon']])) |
|
2040 | - $icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
2146 | + if (!empty($modSettings['messageIconChecks_enable']) && !isset($icon_sources[$row['icon']])) { |
|
2147 | + $icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
2148 | + } |
|
2041 | 2149 | |
2042 | 2150 | censorText($row['subject']); |
2043 | 2151 | censorText($row['body']); |
@@ -2074,16 +2182,18 @@ discard block |
||
2074 | 2182 | } |
2075 | 2183 | $smcFunc['db_free_result']($request); |
2076 | 2184 | |
2077 | - if (empty($return)) |
|
2078 | - return $return; |
|
2185 | + if (empty($return)) { |
|
2186 | + return $return; |
|
2187 | + } |
|
2079 | 2188 | |
2080 | 2189 | $return[count($return) - 1]['is_last'] = true; |
2081 | 2190 | |
2082 | 2191 | // If mods want to do somthing with this list of posts, let them do that now. |
2083 | 2192 | call_integration_hook('integrate_ssi_boardNews', array(&$return)); |
2084 | 2193 | |
2085 | - if ($output_method != 'echo') |
|
2086 | - return $return; |
|
2194 | + if ($output_method != 'echo') { |
|
2195 | + return $return; |
|
2196 | + } |
|
2087 | 2197 | |
2088 | 2198 | foreach ($return as $news) |
2089 | 2199 | { |
@@ -2135,9 +2245,10 @@ discard block |
||
2135 | 2245 | echo ' |
2136 | 2246 | </div>'; |
2137 | 2247 | |
2138 | - if (!$news['is_last']) |
|
2139 | - echo ' |
|
2248 | + if (!$news['is_last']) { |
|
2249 | + echo ' |
|
2140 | 2250 | <hr>'; |
2251 | + } |
|
2141 | 2252 | } |
2142 | 2253 | } |
2143 | 2254 | |
@@ -2151,8 +2262,9 @@ discard block |
||
2151 | 2262 | { |
2152 | 2263 | global $user_info, $scripturl, $modSettings, $txt, $context, $smcFunc; |
2153 | 2264 | |
2154 | - if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) |
|
2155 | - return; |
|
2265 | + if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) { |
|
2266 | + return; |
|
2267 | + } |
|
2156 | 2268 | |
2157 | 2269 | // Find all events which are happening in the near future that the member can see. |
2158 | 2270 | $request = $smcFunc['db_query']('', ' |
@@ -2178,20 +2290,23 @@ discard block |
||
2178 | 2290 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
2179 | 2291 | { |
2180 | 2292 | // Check if we've already come by an event linked to this same topic with the same title... and don't display it if we have. |
2181 | - if (!empty($duplicates[$row['title'] . $row['id_topic']])) |
|
2182 | - continue; |
|
2293 | + if (!empty($duplicates[$row['title'] . $row['id_topic']])) { |
|
2294 | + continue; |
|
2295 | + } |
|
2183 | 2296 | |
2184 | 2297 | // Censor the title. |
2185 | 2298 | censorText($row['title']); |
2186 | 2299 | |
2187 | - if ($row['start_date'] < strftime('%Y-%m-%d', forum_time(false))) |
|
2188 | - $date = strftime('%Y-%m-%d', forum_time(false)); |
|
2189 | - else |
|
2190 | - $date = $row['start_date']; |
|
2300 | + if ($row['start_date'] < strftime('%Y-%m-%d', forum_time(false))) { |
|
2301 | + $date = strftime('%Y-%m-%d', forum_time(false)); |
|
2302 | + } else { |
|
2303 | + $date = $row['start_date']; |
|
2304 | + } |
|
2191 | 2305 | |
2192 | 2306 | // If the topic it is attached to is not approved then don't link it. |
2193 | - if (!empty($row['id_first_msg']) && !$row['approved']) |
|
2194 | - $row['id_board'] = $row['id_topic'] = $row['id_first_msg'] = 0; |
|
2307 | + if (!empty($row['id_first_msg']) && !$row['approved']) { |
|
2308 | + $row['id_board'] = $row['id_topic'] = $row['id_first_msg'] = 0; |
|
2309 | + } |
|
2195 | 2310 | |
2196 | 2311 | $allday = (empty($row['start_time']) || empty($row['end_time']) || empty($row['timezone']) || !in_array($row['timezone'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) ? true : false; |
2197 | 2312 | |
@@ -2217,24 +2332,27 @@ discard block |
||
2217 | 2332 | } |
2218 | 2333 | $smcFunc['db_free_result']($request); |
2219 | 2334 | |
2220 | - foreach ($return as $mday => $array) |
|
2221 | - $return[$mday][count($array) - 1]['is_last'] = true; |
|
2335 | + foreach ($return as $mday => $array) { |
|
2336 | + $return[$mday][count($array) - 1]['is_last'] = true; |
|
2337 | + } |
|
2222 | 2338 | |
2223 | 2339 | // If mods want to do somthing with this list of events, let them do that now. |
2224 | 2340 | call_integration_hook('integrate_ssi_recentEvents', array(&$return)); |
2225 | 2341 | |
2226 | - if ($output_method != 'echo' || empty($return)) |
|
2227 | - return $return; |
|
2342 | + if ($output_method != 'echo' || empty($return)) { |
|
2343 | + return $return; |
|
2344 | + } |
|
2228 | 2345 | |
2229 | 2346 | // Well the output method is echo. |
2230 | 2347 | echo ' |
2231 | 2348 | <span class="event">' . $txt['events'] . '</span> '; |
2232 | - foreach ($return as $mday => $array) |
|
2233 | - foreach ($array as $event) |
|
2349 | + foreach ($return as $mday => $array) { |
|
2350 | + foreach ($array as $event) |
|
2234 | 2351 | { |
2235 | 2352 | if ($event['can_edit']) |
2236 | 2353 | echo ' |
2237 | 2354 | <a href="' . $event['modify_href'] . '" style="color: #ff0000;">*</a> '; |
2355 | + } |
|
2238 | 2356 | |
2239 | 2357 | echo ' |
2240 | 2358 | ' . $event['link'] . (!$event['is_last'] ? ', ' : ''); |
@@ -2253,8 +2371,9 @@ discard block |
||
2253 | 2371 | global $smcFunc; |
2254 | 2372 | |
2255 | 2373 | // If $id is null, this was most likely called from a query string and should do nothing. |
2256 | - if ($id === null) |
|
2257 | - return; |
|
2374 | + if ($id === null) { |
|
2375 | + return; |
|
2376 | + } |
|
2258 | 2377 | |
2259 | 2378 | $request = $smcFunc['db_query']('', ' |
2260 | 2379 | SELECT passwd, member_name, is_activated |
@@ -2286,8 +2405,9 @@ discard block |
||
2286 | 2405 | $attachments_boards = boardsAllowedTo('view_attachments'); |
2287 | 2406 | |
2288 | 2407 | // No boards? Adios amigo. |
2289 | - if (empty($attachments_boards)) |
|
2290 | - return array(); |
|
2408 | + if (empty($attachments_boards)) { |
|
2409 | + return array(); |
|
2410 | + } |
|
2291 | 2411 | |
2292 | 2412 | // Is it an array? |
2293 | 2413 | $attachment_ext = (array) $attachment_ext; |
@@ -2371,8 +2491,9 @@ discard block |
||
2371 | 2491 | call_integration_hook('integrate_ssi_recentAttachments', array(&$attachments)); |
2372 | 2492 | |
2373 | 2493 | // So you just want an array? Here you can have it. |
2374 | - if ($output_method == 'array' || empty($attachments)) |
|
2375 | - return $attachments; |
|
2494 | + if ($output_method == 'array' || empty($attachments)) { |
|
2495 | + return $attachments; |
|
2496 | + } |
|
2376 | 2497 | |
2377 | 2498 | // Give them the default. |
2378 | 2499 | echo ' |
@@ -2383,14 +2504,15 @@ discard block |
||
2383 | 2504 | <th style="text-align: left; padding: 2">', $txt['downloads'], '</th> |
2384 | 2505 | <th style="text-align: left; padding: 2">', $txt['filesize'], '</th> |
2385 | 2506 | </tr>'; |
2386 | - foreach ($attachments as $attach) |
|
2387 | - echo ' |
|
2507 | + foreach ($attachments as $attach) { |
|
2508 | + echo ' |
|
2388 | 2509 | <tr> |
2389 | 2510 | <td>', $attach['file']['link'], '</td> |
2390 | 2511 | <td>', $attach['member']['link'], '</td> |
2391 | 2512 | <td style="text-align: center">', $attach['file']['downloads'], '</td> |
2392 | 2513 | <td>', $attach['file']['filesize'], '</td> |
2393 | 2514 | </tr>'; |
2515 | + } |
|
2394 | 2516 | echo ' |
2395 | 2517 | </table>'; |
2396 | 2518 | } |
@@ -20,8 +20,9 @@ discard block |
||
20 | 20 | // ><html dir="ltr"><head><title>Error!</title></head><body>Sorry, this installer requires PHP!<div style="display: none;"> |
21 | 21 | |
22 | 22 | // Let's pull in useful classes |
23 | -if (!defined('SMF')) |
|
23 | +if (!defined('SMF')) { |
|
24 | 24 | define('SMF', 1); |
25 | +} |
|
25 | 26 | |
26 | 27 | require_once('Sources/Class-Package.php'); |
27 | 28 | |
@@ -63,10 +64,11 @@ discard block |
||
63 | 64 | |
64 | 65 | list ($charcode) = pg_fetch_row($request); |
65 | 66 | |
66 | - if ($charcode == 'UTF8') |
|
67 | - return true; |
|
68 | - else |
|
69 | - return false; |
|
67 | + if ($charcode == 'UTF8') { |
|
68 | + return true; |
|
69 | + } else { |
|
70 | + return false; |
|
71 | + } |
|
70 | 72 | }, |
71 | 73 | 'utf8_version' => '8.0', |
72 | 74 | 'utf8_version_check' => '$request = pg_query(\'SELECT version()\'); list ($version) = pg_fetch_row($request); list($pgl, $version) = explode(" ", $version); return $version;', |
@@ -76,12 +78,14 @@ discard block |
||
76 | 78 | $value = preg_replace('~[^A-Za-z0-9_\$]~', '', $value); |
77 | 79 | |
78 | 80 | // Is it reserved? |
79 | - if ($value == 'pg_') |
|
80 | - return $txt['error_db_prefix_reserved']; |
|
81 | + if ($value == 'pg_') { |
|
82 | + return $txt['error_db_prefix_reserved']; |
|
83 | + } |
|
81 | 84 | |
82 | 85 | // Is the prefix numeric? |
83 | - if (preg_match('~^\d~', $value)) |
|
84 | - return $txt['error_db_prefix_numeric']; |
|
86 | + if (preg_match('~^\d~', $value)) { |
|
87 | + return $txt['error_db_prefix_numeric']; |
|
88 | + } |
|
85 | 89 | |
86 | 90 | return true; |
87 | 91 | }, |
@@ -128,10 +132,11 @@ discard block |
||
128 | 132 | $incontext['skip'] = false; |
129 | 133 | |
130 | 134 | // Call the step and if it returns false that means pause! |
131 | - if (function_exists($step[2]) && $step[2]() === false) |
|
132 | - break; |
|
133 | - elseif (function_exists($step[2])) |
|
134 | - $incontext['current_step']++; |
|
135 | + if (function_exists($step[2]) && $step[2]() === false) { |
|
136 | + break; |
|
137 | + } elseif (function_exists($step[2])) { |
|
138 | + $incontext['current_step']++; |
|
139 | + } |
|
135 | 140 | |
136 | 141 | // No warnings pass on. |
137 | 142 | $incontext['warning'] = ''; |
@@ -147,8 +152,9 @@ discard block |
||
147 | 152 | global $databases; |
148 | 153 | |
149 | 154 | // Just so people using older versions of PHP aren't left in the cold. |
150 | - if (!isset($_SERVER['PHP_SELF'])) |
|
151 | - $_SERVER['PHP_SELF'] = isset($GLOBALS['HTTP_SERVER_VARS']['PHP_SELF']) ? $GLOBALS['HTTP_SERVER_VARS']['PHP_SELF'] : 'install.php'; |
|
155 | + if (!isset($_SERVER['PHP_SELF'])) { |
|
156 | + $_SERVER['PHP_SELF'] = isset($GLOBALS['HTTP_SERVER_VARS']['PHP_SELF']) ? $GLOBALS['HTTP_SERVER_VARS']['PHP_SELF'] : 'install.php'; |
|
157 | + } |
|
152 | 158 | |
153 | 159 | // Enable error reporting for fatal errors. |
154 | 160 | error_reporting(E_ERROR | E_PARSE); |
@@ -164,21 +170,23 @@ discard block |
||
164 | 170 | { |
165 | 171 | ob_start(); |
166 | 172 | |
167 | - if (ini_get('session.save_handler') == 'user') |
|
168 | - @ini_set('session.save_handler', 'files'); |
|
169 | - if (function_exists('session_start')) |
|
170 | - @session_start(); |
|
171 | - } |
|
172 | - else |
|
173 | + if (ini_get('session.save_handler') == 'user') { |
|
174 | + @ini_set('session.save_handler', 'files'); |
|
175 | + } |
|
176 | + if (function_exists('session_start')) { |
|
177 | + @session_start(); |
|
178 | + } |
|
179 | + } else |
|
173 | 180 | { |
174 | 181 | ob_start('ob_gzhandler'); |
175 | 182 | |
176 | - if (ini_get('session.save_handler') == 'user') |
|
177 | - @ini_set('session.save_handler', 'files'); |
|
183 | + if (ini_get('session.save_handler') == 'user') { |
|
184 | + @ini_set('session.save_handler', 'files'); |
|
185 | + } |
|
178 | 186 | session_start(); |
179 | 187 | |
180 | - if (!headers_sent()) |
|
181 | - echo '<!DOCTYPE html> |
|
188 | + if (!headers_sent()) { |
|
189 | + echo '<!DOCTYPE html> |
|
182 | 190 | <html> |
183 | 191 | <head> |
184 | 192 | <title>', htmlspecialchars($_GET['pass_string']), '</title> |
@@ -187,14 +195,16 @@ discard block |
||
187 | 195 | <strong>', htmlspecialchars($_GET['pass_string']), '</strong> |
188 | 196 | </body> |
189 | 197 | </html>'; |
198 | + } |
|
190 | 199 | exit; |
191 | 200 | } |
192 | 201 | |
193 | 202 | // Add slashes, as long as they aren't already being added. |
194 | - if (!function_exists('get_magic_quotes_gpc') || @get_magic_quotes_gpc() == 0) |
|
195 | - foreach ($_POST as $k => $v) |
|
203 | + if (!function_exists('get_magic_quotes_gpc') || @get_magic_quotes_gpc() == 0) { |
|
204 | + foreach ($_POST as $k => $v) |
|
196 | 205 | if (strpos($k, 'password') === false && strpos($k, 'db_passwd') === false) |
197 | 206 | $_POST[$k] = addslashes($v); |
207 | + } |
|
198 | 208 | |
199 | 209 | // This is really quite simple; if ?delete is on the URL, delete the installer... |
200 | 210 | if (isset($_GET['delete'])) |
@@ -215,8 +225,7 @@ discard block |
||
215 | 225 | $ftp->close(); |
216 | 226 | |
217 | 227 | unset($_SESSION['installer_temp_ftp']); |
218 | - } |
|
219 | - else |
|
228 | + } else |
|
220 | 229 | { |
221 | 230 | @unlink(__FILE__); |
222 | 231 | |
@@ -230,10 +239,11 @@ discard block |
||
230 | 239 | // Now just redirect to a blank.png... |
231 | 240 | $secure = false; |
232 | 241 | |
233 | - if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') |
|
234 | - $secure = true; |
|
235 | - elseif (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' || !empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on') |
|
236 | - $secure = true; |
|
242 | + if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') { |
|
243 | + $secure = true; |
|
244 | + } elseif (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' || !empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on') { |
|
245 | + $secure = true; |
|
246 | + } |
|
237 | 247 | |
238 | 248 | header('location: http' . ($secure ? 's' : '') . '://' . (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : $_SERVER['SERVER_NAME'] . ':' . $_SERVER['SERVER_PORT']) . dirname($_SERVER['PHP_SELF']) . '/Themes/default/images/blank.png'); |
239 | 249 | exit; |
@@ -244,10 +254,11 @@ discard block |
||
244 | 254 | { |
245 | 255 | // Get PHP's default timezone, if set |
246 | 256 | $ini_tz = ini_get('date.timezone'); |
247 | - if (!empty($ini_tz)) |
|
248 | - $timezone_id = $ini_tz; |
|
249 | - else |
|
250 | - $timezone_id = ''; |
|
257 | + if (!empty($ini_tz)) { |
|
258 | + $timezone_id = $ini_tz; |
|
259 | + } else { |
|
260 | + $timezone_id = ''; |
|
261 | + } |
|
251 | 262 | |
252 | 263 | // If date.timezone is unset, invalid, or just plain weird, make a best guess |
253 | 264 | if (!in_array($timezone_id, timezone_identifiers_list())) |
@@ -277,8 +288,9 @@ discard block |
||
277 | 288 | $dir = dir(dirname(__FILE__) . '/Themes/default/languages'); |
278 | 289 | while ($entry = $dir->read()) |
279 | 290 | { |
280 | - if (substr($entry, 0, 8) == 'Install.' && substr($entry, -4) == '.php') |
|
281 | - $incontext['detected_languages'][$entry] = ucfirst(substr($entry, 8, strlen($entry) - 12)); |
|
291 | + if (substr($entry, 0, 8) == 'Install.' && substr($entry, -4) == '.php') { |
|
292 | + $incontext['detected_languages'][$entry] = ucfirst(substr($entry, 8, strlen($entry) - 12)); |
|
293 | + } |
|
282 | 294 | } |
283 | 295 | $dir->close(); |
284 | 296 | } |
@@ -313,10 +325,11 @@ discard block |
||
313 | 325 | } |
314 | 326 | |
315 | 327 | // Override the language file? |
316 | - if (isset($_GET['lang_file'])) |
|
317 | - $_SESSION['installer_temp_lang'] = $_GET['lang_file']; |
|
318 | - elseif (isset($GLOBALS['HTTP_GET_VARS']['lang_file'])) |
|
319 | - $_SESSION['installer_temp_lang'] = $GLOBALS['HTTP_GET_VARS']['lang_file']; |
|
328 | + if (isset($_GET['lang_file'])) { |
|
329 | + $_SESSION['installer_temp_lang'] = $_GET['lang_file']; |
|
330 | + } elseif (isset($GLOBALS['HTTP_GET_VARS']['lang_file'])) { |
|
331 | + $_SESSION['installer_temp_lang'] = $GLOBALS['HTTP_GET_VARS']['lang_file']; |
|
332 | + } |
|
320 | 333 | |
321 | 334 | // Make sure it exists, if it doesn't reset it. |
322 | 335 | if (!isset($_SESSION['installer_temp_lang']) || preg_match('~[^\\w_\\-.]~', $_SESSION['installer_temp_lang']) === 1 || !file_exists(dirname(__FILE__) . '/Themes/default/languages/' . $_SESSION['installer_temp_lang'])) |
@@ -325,8 +338,9 @@ discard block |
||
325 | 338 | list ($_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']); |
326 | 339 | |
327 | 340 | // If we have english and some other language, use the other language. We Americans hate english :P. |
328 | - if ($_SESSION['installer_temp_lang'] == 'Install.english.php' && count($incontext['detected_languages']) > 1) |
|
329 | - list (, $_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']); |
|
341 | + if ($_SESSION['installer_temp_lang'] == 'Install.english.php' && count($incontext['detected_languages']) > 1) { |
|
342 | + list (, $_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']); |
|
343 | + } |
|
330 | 344 | } |
331 | 345 | |
332 | 346 | // And now include the actual language file itself. |
@@ -343,15 +357,18 @@ discard block |
||
343 | 357 | global $db_prefix, $db_connection, $sourcedir, $smcFunc, $modSettings; |
344 | 358 | global $db_server, $db_passwd, $db_type, $db_name, $db_user, $db_persist; |
345 | 359 | |
346 | - if (empty($sourcedir)) |
|
347 | - $sourcedir = dirname(__FILE__) . '/Sources'; |
|
360 | + if (empty($sourcedir)) { |
|
361 | + $sourcedir = dirname(__FILE__) . '/Sources'; |
|
362 | + } |
|
348 | 363 | |
349 | 364 | // Need this to check whether we need the database password. |
350 | 365 | require(dirname(__FILE__) . '/Settings.php'); |
351 | - if (!defined('SMF')) |
|
352 | - define('SMF', 1); |
|
353 | - if (empty($smcFunc)) |
|
354 | - $smcFunc = array(); |
|
366 | + if (!defined('SMF')) { |
|
367 | + define('SMF', 1); |
|
368 | + } |
|
369 | + if (empty($smcFunc)) { |
|
370 | + $smcFunc = array(); |
|
371 | + } |
|
355 | 372 | |
356 | 373 | $modSettings['disableQueryCheck'] = true; |
357 | 374 | |
@@ -359,8 +376,9 @@ discard block |
||
359 | 376 | if (!$db_connection) |
360 | 377 | { |
361 | 378 | require_once($sourcedir . '/Subs-Db-' . $db_type . '.php'); |
362 | - if (version_compare(PHP_VERSION, '5', '<')) |
|
363 | - require_once($sourcedir . '/Subs-Compat.php'); |
|
379 | + if (version_compare(PHP_VERSION, '5', '<')) { |
|
380 | + require_once($sourcedir . '/Subs-Compat.php'); |
|
381 | + } |
|
364 | 382 | |
365 | 383 | $db_options = array('persist' => $db_persist); |
366 | 384 | $port = ''; |
@@ -371,19 +389,20 @@ discard block |
||
371 | 389 | if ($db_type == 'mysql') |
372 | 390 | { |
373 | 391 | $port = ((int) $_POST['db_port'] == ini_get($db_type . 'default_port')) ? '' : (int) $_POST['db_port']; |
374 | - } |
|
375 | - elseif ($db_type == 'postgresql') |
|
392 | + } elseif ($db_type == 'postgresql') |
|
376 | 393 | { |
377 | 394 | // PostgreSQL doesn't have a default port setting in php.ini, so just check against the default |
378 | 395 | $port = ((int) $_POST['db_port'] == 5432) ? '' : (int) $_POST['db_port']; |
379 | 396 | } |
380 | 397 | } |
381 | 398 | |
382 | - if (!empty($port)) |
|
383 | - $db_options['port'] = $port; |
|
399 | + if (!empty($port)) { |
|
400 | + $db_options['port'] = $port; |
|
401 | + } |
|
384 | 402 | |
385 | - if (!$db_connection) |
|
386 | - $db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, $db_options); |
|
403 | + if (!$db_connection) { |
|
404 | + $db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, $db_options); |
|
405 | + } |
|
387 | 406 | } |
388 | 407 | } |
389 | 408 | |
@@ -411,8 +430,9 @@ discard block |
||
411 | 430 | // @todo REMOVE THIS!! |
412 | 431 | else |
413 | 432 | { |
414 | - if (function_exists('doStep' . $_GET['step'])) |
|
415 | - call_user_func('doStep' . $_GET['step']); |
|
433 | + if (function_exists('doStep' . $_GET['step'])) { |
|
434 | + call_user_func('doStep' . $_GET['step']); |
|
435 | + } |
|
416 | 436 | } |
417 | 437 | // Show the footer. |
418 | 438 | template_install_below(); |
@@ -430,8 +450,9 @@ discard block |
||
430 | 450 | $incontext['sub_template'] = 'welcome_message'; |
431 | 451 | |
432 | 452 | // Done the submission? |
433 | - if (isset($_POST['contbutt'])) |
|
434 | - return true; |
|
453 | + if (isset($_POST['contbutt'])) { |
|
454 | + return true; |
|
455 | + } |
|
435 | 456 | |
436 | 457 | // See if we think they have already installed it? |
437 | 458 | if (is_readable(dirname(__FILE__) . '/Settings.php')) |
@@ -439,14 +460,17 @@ discard block |
||
439 | 460 | $probably_installed = 0; |
440 | 461 | foreach (file(dirname(__FILE__) . '/Settings.php') as $line) |
441 | 462 | { |
442 | - if (preg_match('~^\$db_passwd\s=\s\'([^\']+)\';$~', $line)) |
|
443 | - $probably_installed++; |
|
444 | - if (preg_match('~^\$boardurl\s=\s\'([^\']+)\';~', $line) && !preg_match('~^\$boardurl\s=\s\'http://127\.0\.0\.1/smf\';~', $line)) |
|
445 | - $probably_installed++; |
|
463 | + if (preg_match('~^\$db_passwd\s=\s\'([^\']+)\';$~', $line)) { |
|
464 | + $probably_installed++; |
|
465 | + } |
|
466 | + if (preg_match('~^\$boardurl\s=\s\'([^\']+)\';~', $line) && !preg_match('~^\$boardurl\s=\s\'http://127\.0\.0\.1/smf\';~', $line)) { |
|
467 | + $probably_installed++; |
|
468 | + } |
|
446 | 469 | } |
447 | 470 | |
448 | - if ($probably_installed == 2) |
|
449 | - $incontext['warning'] = $txt['error_already_installed']; |
|
471 | + if ($probably_installed == 2) { |
|
472 | + $incontext['warning'] = $txt['error_already_installed']; |
|
473 | + } |
|
450 | 474 | } |
451 | 475 | |
452 | 476 | // Is some database support even compiled in? |
@@ -461,45 +485,54 @@ discard block |
||
461 | 485 | $databases[$key]['supported'] = false; |
462 | 486 | $notFoundSQLFile = true; |
463 | 487 | $txt['error_db_script_missing'] = sprintf($txt['error_db_script_missing'], 'install_' . $GLOBALS['db_script_version'] . '_' . $type . '.sql'); |
488 | + } else { |
|
489 | + $incontext['supported_databases'][] = $db; |
|
464 | 490 | } |
465 | - else |
|
466 | - $incontext['supported_databases'][] = $db; |
|
467 | 491 | } |
468 | 492 | } |
469 | 493 | |
470 | 494 | // Check the PHP version. |
471 | - if ((!function_exists('version_compare') || version_compare($GLOBALS['required_php_version'], PHP_VERSION, '>='))) |
|
472 | - $error = 'error_php_too_low'; |
|
495 | + if ((!function_exists('version_compare') || version_compare($GLOBALS['required_php_version'], PHP_VERSION, '>='))) { |
|
496 | + $error = 'error_php_too_low'; |
|
497 | + } |
|
473 | 498 | // Make sure we have a supported database |
474 | - elseif (empty($incontext['supported_databases'])) |
|
475 | - $error = empty($notFoundSQLFile) ? 'error_db_missing' : 'error_db_script_missing'; |
|
499 | + elseif (empty($incontext['supported_databases'])) { |
|
500 | + $error = empty($notFoundSQLFile) ? 'error_db_missing' : 'error_db_script_missing'; |
|
501 | + } |
|
476 | 502 | // How about session support? Some crazy sysadmin remove it? |
477 | - elseif (!function_exists('session_start')) |
|
478 | - $error = 'error_session_missing'; |
|
503 | + elseif (!function_exists('session_start')) { |
|
504 | + $error = 'error_session_missing'; |
|
505 | + } |
|
479 | 506 | // Make sure they uploaded all the files. |
480 | - elseif (!file_exists(dirname(__FILE__) . '/index.php')) |
|
481 | - $error = 'error_missing_files'; |
|
507 | + elseif (!file_exists(dirname(__FILE__) . '/index.php')) { |
|
508 | + $error = 'error_missing_files'; |
|
509 | + } |
|
482 | 510 | // Very simple check on the session.save_path for Windows. |
483 | 511 | // @todo Move this down later if they don't use database-driven sessions? |
484 | - elseif (@ini_get('session.save_path') == '/tmp' && substr(__FILE__, 1, 2) == ':\\') |
|
485 | - $error = 'error_session_save_path'; |
|
512 | + elseif (@ini_get('session.save_path') == '/tmp' && substr(__FILE__, 1, 2) == ':\\') { |
|
513 | + $error = 'error_session_save_path'; |
|
514 | + } |
|
486 | 515 | |
487 | 516 | // Since each of the three messages would look the same, anyway... |
488 | - if (isset($error)) |
|
489 | - $incontext['error'] = $txt[$error]; |
|
517 | + if (isset($error)) { |
|
518 | + $incontext['error'] = $txt[$error]; |
|
519 | + } |
|
490 | 520 | |
491 | 521 | // Mod_security blocks everything that smells funny. Let SMF handle security. |
492 | - if (!fixModSecurity() && !isset($_GET['overmodsecurity'])) |
|
493 | - $incontext['error'] = $txt['error_mod_security'] . '<br><br><a href="' . $installurl . '?overmodsecurity=true">' . $txt['error_message_click'] . '</a> ' . $txt['error_message_bad_try_again']; |
|
522 | + if (!fixModSecurity() && !isset($_GET['overmodsecurity'])) { |
|
523 | + $incontext['error'] = $txt['error_mod_security'] . '<br><br><a href="' . $installurl . '?overmodsecurity=true">' . $txt['error_message_click'] . '</a> ' . $txt['error_message_bad_try_again']; |
|
524 | + } |
|
494 | 525 | |
495 | 526 | // Confirm mbstring is loaded... |
496 | - if (!extension_loaded('mbstring')) |
|
497 | - $incontext['error'] = $txt['install_no_mbstring']; |
|
527 | + if (!extension_loaded('mbstring')) { |
|
528 | + $incontext['error'] = $txt['install_no_mbstring']; |
|
529 | + } |
|
498 | 530 | |
499 | 531 | // Check for https stream support. |
500 | 532 | $supported_streams = stream_get_wrappers(); |
501 | - if (!in_array('https', $supported_streams)) |
|
502 | - $incontext['warning'] = $txt['install_no_https']; |
|
533 | + if (!in_array('https', $supported_streams)) { |
|
534 | + $incontext['warning'] = $txt['install_no_https']; |
|
535 | + } |
|
503 | 536 | |
504 | 537 | return false; |
505 | 538 | } |
@@ -524,12 +557,14 @@ discard block |
||
524 | 557 | 'Settings_bak.php', |
525 | 558 | ); |
526 | 559 | |
527 | - foreach ($incontext['detected_languages'] as $lang => $temp) |
|
528 | - $extra_files[] = 'Themes/default/languages/' . $lang; |
|
560 | + foreach ($incontext['detected_languages'] as $lang => $temp) { |
|
561 | + $extra_files[] = 'Themes/default/languages/' . $lang; |
|
562 | + } |
|
529 | 563 | |
530 | 564 | // With mod_security installed, we could attempt to fix it with .htaccess. |
531 | - if (function_exists('apache_get_modules') && in_array('mod_security', apache_get_modules())) |
|
532 | - $writable_files[] = file_exists(dirname(__FILE__) . '/.htaccess') ? '.htaccess' : '.'; |
|
565 | + if (function_exists('apache_get_modules') && in_array('mod_security', apache_get_modules())) { |
|
566 | + $writable_files[] = file_exists(dirname(__FILE__) . '/.htaccess') ? '.htaccess' : '.'; |
|
567 | + } |
|
533 | 568 | |
534 | 569 | $failed_files = array(); |
535 | 570 | |
@@ -541,20 +576,23 @@ discard block |
||
541 | 576 | foreach ($writable_files as $file) |
542 | 577 | { |
543 | 578 | // Some files won't exist, try to address up front |
544 | - if (!file_exists(dirname(__FILE__) . '/' . $file)) |
|
545 | - @touch(dirname(__FILE__) . '/' . $file); |
|
579 | + if (!file_exists(dirname(__FILE__) . '/' . $file)) { |
|
580 | + @touch(dirname(__FILE__) . '/' . $file); |
|
581 | + } |
|
546 | 582 | // NOW do the writable check... |
547 | 583 | if (!is_writable(dirname(__FILE__) . '/' . $file)) |
548 | 584 | { |
549 | 585 | @chmod(dirname(__FILE__) . '/' . $file, 0755); |
550 | 586 | |
551 | 587 | // Well, 755 hopefully worked... if not, try 777. |
552 | - if (!is_writable(dirname(__FILE__) . '/' . $file) && !@chmod(dirname(__FILE__) . '/' . $file, 0777)) |
|
553 | - $failed_files[] = $file; |
|
588 | + if (!is_writable(dirname(__FILE__) . '/' . $file) && !@chmod(dirname(__FILE__) . '/' . $file, 0777)) { |
|
589 | + $failed_files[] = $file; |
|
590 | + } |
|
554 | 591 | } |
555 | 592 | } |
556 | - foreach ($extra_files as $file) |
|
557 | - @chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777); |
|
593 | + foreach ($extra_files as $file) { |
|
594 | + @chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777); |
|
595 | + } |
|
558 | 596 | } |
559 | 597 | // Windows is trickier. Let's try opening for r+... |
560 | 598 | else |
@@ -564,30 +602,35 @@ discard block |
||
564 | 602 | foreach ($writable_files as $file) |
565 | 603 | { |
566 | 604 | // Folders can't be opened for write... but the index.php in them can ;) |
567 | - if (is_dir(dirname(__FILE__) . '/' . $file)) |
|
568 | - $file .= '/index.php'; |
|
605 | + if (is_dir(dirname(__FILE__) . '/' . $file)) { |
|
606 | + $file .= '/index.php'; |
|
607 | + } |
|
569 | 608 | |
570 | 609 | // Funny enough, chmod actually does do something on windows - it removes the read only attribute. |
571 | 610 | @chmod(dirname(__FILE__) . '/' . $file, 0777); |
572 | 611 | $fp = @fopen(dirname(__FILE__) . '/' . $file, 'r+'); |
573 | 612 | |
574 | 613 | // Hmm, okay, try just for write in that case... |
575 | - if (!is_resource($fp)) |
|
576 | - $fp = @fopen(dirname(__FILE__) . '/' . $file, 'w'); |
|
614 | + if (!is_resource($fp)) { |
|
615 | + $fp = @fopen(dirname(__FILE__) . '/' . $file, 'w'); |
|
616 | + } |
|
577 | 617 | |
578 | - if (!is_resource($fp)) |
|
579 | - $failed_files[] = $file; |
|
618 | + if (!is_resource($fp)) { |
|
619 | + $failed_files[] = $file; |
|
620 | + } |
|
580 | 621 | |
581 | 622 | @fclose($fp); |
582 | 623 | } |
583 | - foreach ($extra_files as $file) |
|
584 | - @chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777); |
|
624 | + foreach ($extra_files as $file) { |
|
625 | + @chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777); |
|
626 | + } |
|
585 | 627 | } |
586 | 628 | |
587 | 629 | $failure = count($failed_files) >= 1; |
588 | 630 | |
589 | - if (!isset($_SERVER)) |
|
590 | - return !$failure; |
|
631 | + if (!isset($_SERVER)) { |
|
632 | + return !$failure; |
|
633 | + } |
|
591 | 634 | |
592 | 635 | // Put the list into context. |
593 | 636 | $incontext['failed_files'] = $failed_files; |
@@ -635,19 +678,23 @@ discard block |
||
635 | 678 | |
636 | 679 | if (!isset($ftp) || $ftp->error !== false) |
637 | 680 | { |
638 | - if (!isset($ftp)) |
|
639 | - $ftp = new ftp_connection(null); |
|
681 | + if (!isset($ftp)) { |
|
682 | + $ftp = new ftp_connection(null); |
|
683 | + } |
|
640 | 684 | // Save the error so we can mess with listing... |
641 | - elseif ($ftp->error !== false && empty($incontext['ftp_errors']) && !empty($ftp->last_message)) |
|
642 | - $incontext['ftp_errors'][] = $ftp->last_message; |
|
685 | + elseif ($ftp->error !== false && empty($incontext['ftp_errors']) && !empty($ftp->last_message)) { |
|
686 | + $incontext['ftp_errors'][] = $ftp->last_message; |
|
687 | + } |
|
643 | 688 | |
644 | 689 | list ($username, $detect_path, $found_path) = $ftp->detect_path(dirname(__FILE__)); |
645 | 690 | |
646 | - if (empty($_POST['ftp_path']) && $found_path) |
|
647 | - $_POST['ftp_path'] = $detect_path; |
|
691 | + if (empty($_POST['ftp_path']) && $found_path) { |
|
692 | + $_POST['ftp_path'] = $detect_path; |
|
693 | + } |
|
648 | 694 | |
649 | - if (!isset($_POST['ftp_username'])) |
|
650 | - $_POST['ftp_username'] = $username; |
|
695 | + if (!isset($_POST['ftp_username'])) { |
|
696 | + $_POST['ftp_username'] = $username; |
|
697 | + } |
|
651 | 698 | |
652 | 699 | // Set the username etc, into context. |
653 | 700 | $incontext['ftp'] = array( |
@@ -659,8 +706,7 @@ discard block |
||
659 | 706 | ); |
660 | 707 | |
661 | 708 | return false; |
662 | - } |
|
663 | - else |
|
709 | + } else |
|
664 | 710 | { |
665 | 711 | $_SESSION['installer_temp_ftp'] = array( |
666 | 712 | 'server' => $_POST['ftp_server'], |
@@ -674,10 +720,12 @@ discard block |
||
674 | 720 | |
675 | 721 | foreach ($failed_files as $file) |
676 | 722 | { |
677 | - if (!is_writable(dirname(__FILE__) . '/' . $file)) |
|
678 | - $ftp->chmod($file, 0755); |
|
679 | - if (!is_writable(dirname(__FILE__) . '/' . $file)) |
|
680 | - $ftp->chmod($file, 0777); |
|
723 | + if (!is_writable(dirname(__FILE__) . '/' . $file)) { |
|
724 | + $ftp->chmod($file, 0755); |
|
725 | + } |
|
726 | + if (!is_writable(dirname(__FILE__) . '/' . $file)) { |
|
727 | + $ftp->chmod($file, 0777); |
|
728 | + } |
|
681 | 729 | if (!is_writable(dirname(__FILE__) . '/' . $file)) |
682 | 730 | { |
683 | 731 | $failed_files_updated[] = $file; |
@@ -733,15 +781,17 @@ discard block |
||
733 | 781 | |
734 | 782 | if (!$foundOne) |
735 | 783 | { |
736 | - if (isset($db['default_host'])) |
|
737 | - $incontext['db']['server'] = ini_get($db['default_host']) or $incontext['db']['server'] = 'localhost'; |
|
784 | + if (isset($db['default_host'])) { |
|
785 | + $incontext['db']['server'] = ini_get($db['default_host']) or $incontext['db']['server'] = 'localhost'; |
|
786 | + } |
|
738 | 787 | if (isset($db['default_user'])) |
739 | 788 | { |
740 | 789 | $incontext['db']['user'] = ini_get($db['default_user']); |
741 | 790 | $incontext['db']['name'] = ini_get($db['default_user']); |
742 | 791 | } |
743 | - if (isset($db['default_password'])) |
|
744 | - $incontext['db']['pass'] = ini_get($db['default_password']); |
|
792 | + if (isset($db['default_password'])) { |
|
793 | + $incontext['db']['pass'] = ini_get($db['default_password']); |
|
794 | + } |
|
745 | 795 | |
746 | 796 | // For simplicity and less confusion, leave the port blank by default |
747 | 797 | $incontext['db']['port'] = ''; |
@@ -760,10 +810,10 @@ discard block |
||
760 | 810 | $incontext['db']['server'] = $_POST['db_server']; |
761 | 811 | $incontext['db']['prefix'] = $_POST['db_prefix']; |
762 | 812 | |
763 | - if (!empty($_POST['db_port'])) |
|
764 | - $incontext['db']['port'] = $_POST['db_port']; |
|
765 | - } |
|
766 | - else |
|
813 | + if (!empty($_POST['db_port'])) { |
|
814 | + $incontext['db']['port'] = $_POST['db_port']; |
|
815 | + } |
|
816 | + } else |
|
767 | 817 | { |
768 | 818 | $incontext['db']['prefix'] = 'smf_'; |
769 | 819 | } |
@@ -799,10 +849,11 @@ discard block |
||
799 | 849 | if (!empty($_POST['db_port'])) |
800 | 850 | { |
801 | 851 | // For MySQL, we can get the "default port" from PHP. PostgreSQL has no such option though. |
802 | - if (($db_type == 'mysql' || $db_type == 'mysqli') && $_POST['db_port'] != ini_get($db_type . '.default_port')) |
|
803 | - $vars['db_port'] = (int) $_POST['db_port']; |
|
804 | - elseif ($db_type == 'postgresql' && $_POST['db_port'] != 5432) |
|
805 | - $vars['db_port'] = (int) $_POST['db_port']; |
|
852 | + if (($db_type == 'mysql' || $db_type == 'mysqli') && $_POST['db_port'] != ini_get($db_type . '.default_port')) { |
|
853 | + $vars['db_port'] = (int) $_POST['db_port']; |
|
854 | + } elseif ($db_type == 'postgresql' && $_POST['db_port'] != 5432) { |
|
855 | + $vars['db_port'] = (int) $_POST['db_port']; |
|
856 | + } |
|
806 | 857 | } |
807 | 858 | |
808 | 859 | // God I hope it saved! |
@@ -815,8 +866,9 @@ discard block |
||
815 | 866 | // Make sure it works. |
816 | 867 | require(dirname(__FILE__) . '/Settings.php'); |
817 | 868 | |
818 | - if (empty($sourcedir)) |
|
819 | - $sourcedir = dirname(__FILE__) . '/Sources'; |
|
869 | + if (empty($sourcedir)) { |
|
870 | + $sourcedir = dirname(__FILE__) . '/Sources'; |
|
871 | + } |
|
820 | 872 | |
821 | 873 | // Better find the database file! |
822 | 874 | if (!file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php')) |
@@ -826,18 +878,21 @@ discard block |
||
826 | 878 | } |
827 | 879 | |
828 | 880 | // Now include it for database functions! |
829 | - if (!defined('SMF')) |
|
830 | - define('SMF', 1); |
|
881 | + if (!defined('SMF')) { |
|
882 | + define('SMF', 1); |
|
883 | + } |
|
831 | 884 | |
832 | 885 | $modSettings['disableQueryCheck'] = true; |
833 | - if (empty($smcFunc)) |
|
834 | - $smcFunc = array(); |
|
886 | + if (empty($smcFunc)) { |
|
887 | + $smcFunc = array(); |
|
888 | + } |
|
835 | 889 | |
836 | 890 | require_once($sourcedir . '/Subs-Db-' . $db_type . '.php'); |
837 | 891 | |
838 | 892 | // What - running PHP4? The shame! |
839 | - if (version_compare(PHP_VERSION, '5', '<')) |
|
840 | - require_once($sourcedir . '/Subs-Compat.php'); |
|
893 | + if (version_compare(PHP_VERSION, '5', '<')) { |
|
894 | + require_once($sourcedir . '/Subs-Compat.php'); |
|
895 | + } |
|
841 | 896 | |
842 | 897 | // Attempt a connection. |
843 | 898 | $needsDB = !empty($databases[$db_type]['always_has_db']); |
@@ -925,12 +980,14 @@ discard block |
||
925 | 980 | $incontext['page_title'] = $txt['install_settings']; |
926 | 981 | |
927 | 982 | // Let's see if we got the database type correct. |
928 | - if (isset($_POST['db_type'], $databases[$_POST['db_type']])) |
|
929 | - $db_type = $_POST['db_type']; |
|
983 | + if (isset($_POST['db_type'], $databases[$_POST['db_type']])) { |
|
984 | + $db_type = $_POST['db_type']; |
|
985 | + } |
|
930 | 986 | |
931 | 987 | // Else we'd better be able to get the connection. |
932 | - else |
|
933 | - load_database(); |
|
988 | + else { |
|
989 | + load_database(); |
|
990 | + } |
|
934 | 991 | |
935 | 992 | $db_type = isset($_POST['db_type']) ? $_POST['db_type'] : $db_type; |
936 | 993 | |
@@ -939,10 +996,11 @@ discard block |
||
939 | 996 | |
940 | 997 | $secure = false; |
941 | 998 | |
942 | - if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') |
|
943 | - $secure = true; |
|
944 | - elseif (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' || !empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on') |
|
945 | - $secure = true; |
|
999 | + if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') { |
|
1000 | + $secure = true; |
|
1001 | + } elseif (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' || !empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on') { |
|
1002 | + $secure = true; |
|
1003 | + } |
|
946 | 1004 | |
947 | 1005 | // Now, to put what we've learned together... and add a path. |
948 | 1006 | $incontext['detected_url'] = 'http' . ($secure ? 's' : '') . '://' . $host . substr($_SERVER['PHP_SELF'], 0, strrpos($_SERVER['PHP_SELF'], '/')); |
@@ -974,18 +1032,21 @@ discard block |
||
974 | 1032 | // Submitting? |
975 | 1033 | if (isset($_POST['boardurl'])) |
976 | 1034 | { |
977 | - if (substr($_POST['boardurl'], -10) == '/index.php') |
|
978 | - $_POST['boardurl'] = substr($_POST['boardurl'], 0, -10); |
|
979 | - elseif (substr($_POST['boardurl'], -1) == '/') |
|
980 | - $_POST['boardurl'] = substr($_POST['boardurl'], 0, -1); |
|
981 | - if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://') |
|
982 | - $_POST['boardurl'] = 'http://' . $_POST['boardurl']; |
|
1035 | + if (substr($_POST['boardurl'], -10) == '/index.php') { |
|
1036 | + $_POST['boardurl'] = substr($_POST['boardurl'], 0, -10); |
|
1037 | + } elseif (substr($_POST['boardurl'], -1) == '/') { |
|
1038 | + $_POST['boardurl'] = substr($_POST['boardurl'], 0, -1); |
|
1039 | + } |
|
1040 | + if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://') { |
|
1041 | + $_POST['boardurl'] = 'http://' . $_POST['boardurl']; |
|
1042 | + } |
|
983 | 1043 | |
984 | 1044 | //Make sure boardurl is aligned with ssl setting |
985 | - if (empty($_POST['force_ssl'])) |
|
986 | - $_POST['boardurl'] = strtr($_POST['boardurl'], array('https://' => 'http://')); |
|
987 | - else |
|
988 | - $_POST['boardurl'] = strtr($_POST['boardurl'], array('http://' => 'https://')); |
|
1045 | + if (empty($_POST['force_ssl'])) { |
|
1046 | + $_POST['boardurl'] = strtr($_POST['boardurl'], array('https://' => 'http://')); |
|
1047 | + } else { |
|
1048 | + $_POST['boardurl'] = strtr($_POST['boardurl'], array('http://' => 'https://')); |
|
1049 | + } |
|
989 | 1050 | |
990 | 1051 | // Save these variables. |
991 | 1052 | $vars = array( |
@@ -1024,10 +1085,10 @@ discard block |
||
1024 | 1085 | { |
1025 | 1086 | $incontext['error'] = sprintf($txt['error_utf8_version'], $databases[$db_type]['utf8_version']); |
1026 | 1087 | return false; |
1027 | - } |
|
1028 | - else |
|
1029 | - // Set the character set here. |
|
1088 | + } else { |
|
1089 | + // Set the character set here. |
|
1030 | 1090 | updateSettingsFile(array('db_character_set' => 'utf8')); |
1091 | + } |
|
1031 | 1092 | } |
1032 | 1093 | |
1033 | 1094 | // Good, skip on. |
@@ -1047,8 +1108,9 @@ discard block |
||
1047 | 1108 | $incontext['continue'] = 1; |
1048 | 1109 | |
1049 | 1110 | // Already done? |
1050 | - if (isset($_POST['pop_done'])) |
|
1051 | - return true; |
|
1111 | + if (isset($_POST['pop_done'])) { |
|
1112 | + return true; |
|
1113 | + } |
|
1052 | 1114 | |
1053 | 1115 | // Reload settings. |
1054 | 1116 | require(dirname(__FILE__) . '/Settings.php'); |
@@ -1066,8 +1128,9 @@ discard block |
||
1066 | 1128 | $modSettings = array(); |
1067 | 1129 | if ($result !== false) |
1068 | 1130 | { |
1069 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
1070 | - $modSettings[$row['variable']] = $row['value']; |
|
1131 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
1132 | + $modSettings[$row['variable']] = $row['value']; |
|
1133 | + } |
|
1071 | 1134 | $smcFunc['db_free_result']($result); |
1072 | 1135 | |
1073 | 1136 | // Do they match? If so, this is just a refresh so charge on! |
@@ -1080,20 +1143,22 @@ discard block |
||
1080 | 1143 | $modSettings['disableQueryCheck'] = true; |
1081 | 1144 | |
1082 | 1145 | // If doing UTF8, select it. PostgreSQL requires passing it as a string... |
1083 | - if (!empty($db_character_set) && $db_character_set == 'utf8' && !empty($databases[$db_type]['utf8_support'])) |
|
1084 | - $smcFunc['db_query']('', ' |
|
1146 | + if (!empty($db_character_set) && $db_character_set == 'utf8' && !empty($databases[$db_type]['utf8_support'])) { |
|
1147 | + $smcFunc['db_query']('', ' |
|
1085 | 1148 | SET NAMES {string:utf8}', |
1086 | 1149 | array( |
1087 | 1150 | 'db_error_skip' => true, |
1088 | 1151 | 'utf8' => 'utf8', |
1089 | 1152 | ) |
1090 | 1153 | ); |
1154 | + } |
|
1091 | 1155 | |
1092 | 1156 | // Windows likes to leave the trailing slash, which yields to C:\path\to\SMF\/attachments... |
1093 | - if (substr(__DIR__, -1) == '\\') |
|
1094 | - $attachdir = __DIR__ . 'attachments'; |
|
1095 | - else |
|
1096 | - $attachdir = __DIR__ . '/attachments'; |
|
1157 | + if (substr(__DIR__, -1) == '\\') { |
|
1158 | + $attachdir = __DIR__ . 'attachments'; |
|
1159 | + } else { |
|
1160 | + $attachdir = __DIR__ . '/attachments'; |
|
1161 | + } |
|
1097 | 1162 | |
1098 | 1163 | $replaces = array( |
1099 | 1164 | '{$db_prefix}' => $db_prefix, |
@@ -1110,8 +1175,9 @@ discard block |
||
1110 | 1175 | |
1111 | 1176 | foreach ($txt as $key => $value) |
1112 | 1177 | { |
1113 | - if (substr($key, 0, 8) == 'default_') |
|
1114 | - $replaces['{$' . $key . '}'] = $smcFunc['db_escape_string']($value); |
|
1178 | + if (substr($key, 0, 8) == 'default_') { |
|
1179 | + $replaces['{$' . $key . '}'] = $smcFunc['db_escape_string']($value); |
|
1180 | + } |
|
1115 | 1181 | } |
1116 | 1182 | $replaces['{$default_reserved_names}'] = strtr($replaces['{$default_reserved_names}'], array('\\\\n' => '\\n')); |
1117 | 1183 | |
@@ -1126,8 +1192,9 @@ discard block |
||
1126 | 1192 | |
1127 | 1193 | while ($row = $smcFunc['db_fetch_assoc']($get_engines)) |
1128 | 1194 | { |
1129 | - if ($row['Support'] == 'YES' || $row['Support'] == 'DEFAULT') |
|
1130 | - $engines[] = $row['Engine']; |
|
1195 | + if ($row['Support'] == 'YES' || $row['Support'] == 'DEFAULT') { |
|
1196 | + $engines[] = $row['Engine']; |
|
1197 | + } |
|
1131 | 1198 | } |
1132 | 1199 | |
1133 | 1200 | // Done with this now |
@@ -1151,8 +1218,7 @@ discard block |
||
1151 | 1218 | $replaces['START TRANSACTION;'] = ''; |
1152 | 1219 | $replaces['COMMIT;'] = ''; |
1153 | 1220 | } |
1154 | - } |
|
1155 | - else |
|
1221 | + } else |
|
1156 | 1222 | { |
1157 | 1223 | $has_innodb = false; |
1158 | 1224 | } |
@@ -1174,21 +1240,24 @@ discard block |
||
1174 | 1240 | foreach ($sql_lines as $count => $line) |
1175 | 1241 | { |
1176 | 1242 | // No comments allowed! |
1177 | - if (substr(trim($line), 0, 1) != '#') |
|
1178 | - $current_statement .= "\n" . rtrim($line); |
|
1243 | + if (substr(trim($line), 0, 1) != '#') { |
|
1244 | + $current_statement .= "\n" . rtrim($line); |
|
1245 | + } |
|
1179 | 1246 | |
1180 | 1247 | // Is this the end of the query string? |
1181 | - if (empty($current_statement) || (preg_match('~;[\s]*$~s', $line) == 0 && $count != count($sql_lines))) |
|
1182 | - continue; |
|
1248 | + if (empty($current_statement) || (preg_match('~;[\s]*$~s', $line) == 0 && $count != count($sql_lines))) { |
|
1249 | + continue; |
|
1250 | + } |
|
1183 | 1251 | |
1184 | 1252 | // Does this table already exist? If so, don't insert more data into it! |
1185 | 1253 | if (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) != 0 && in_array($match[1], $exists)) |
1186 | 1254 | { |
1187 | 1255 | preg_match_all('~\)[,;]~', $current_statement, $matches); |
1188 | - if (!empty($matches[0])) |
|
1189 | - $incontext['sql_results']['insert_dups'] += count($matches[0]); |
|
1190 | - else |
|
1191 | - $incontext['sql_results']['insert_dups']++; |
|
1256 | + if (!empty($matches[0])) { |
|
1257 | + $incontext['sql_results']['insert_dups'] += count($matches[0]); |
|
1258 | + } else { |
|
1259 | + $incontext['sql_results']['insert_dups']++; |
|
1260 | + } |
|
1192 | 1261 | |
1193 | 1262 | $current_statement = ''; |
1194 | 1263 | continue; |
@@ -1197,8 +1266,9 @@ discard block |
||
1197 | 1266 | if ($smcFunc['db_query']('', $current_statement, array('security_override' => true, 'db_error_skip' => true), $db_connection) === false) |
1198 | 1267 | { |
1199 | 1268 | // Use the appropriate function based on the DB type |
1200 | - if ($db_type == 'mysql' || $db_type == 'mysqli') |
|
1201 | - $db_errorno = $db_type . '_errno'; |
|
1269 | + if ($db_type == 'mysql' || $db_type == 'mysqli') { |
|
1270 | + $db_errorno = $db_type . '_errno'; |
|
1271 | + } |
|
1202 | 1272 | |
1203 | 1273 | // Error 1050: Table already exists! |
1204 | 1274 | // @todo Needs to be made better! |
@@ -1213,18 +1283,18 @@ discard block |
||
1213 | 1283 | // MySQLi requires a connection object. It's optional with MySQL and Postgres |
1214 | 1284 | $incontext['failures'][$count] = $smcFunc['db_error']($db_connection); |
1215 | 1285 | } |
1216 | - } |
|
1217 | - else |
|
1286 | + } else |
|
1218 | 1287 | { |
1219 | - if (preg_match('~^\s*CREATE TABLE ([^\s\n\r]+?)~', $current_statement, $match) == 1) |
|
1220 | - $incontext['sql_results']['tables']++; |
|
1221 | - elseif (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) == 1) |
|
1288 | + if (preg_match('~^\s*CREATE TABLE ([^\s\n\r]+?)~', $current_statement, $match) == 1) { |
|
1289 | + $incontext['sql_results']['tables']++; |
|
1290 | + } elseif (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) == 1) |
|
1222 | 1291 | { |
1223 | 1292 | preg_match_all('~\)[,;]~', $current_statement, $matches); |
1224 | - if (!empty($matches[0])) |
|
1225 | - $incontext['sql_results']['inserts'] += count($matches[0]); |
|
1226 | - else |
|
1227 | - $incontext['sql_results']['inserts']++; |
|
1293 | + if (!empty($matches[0])) { |
|
1294 | + $incontext['sql_results']['inserts'] += count($matches[0]); |
|
1295 | + } else { |
|
1296 | + $incontext['sql_results']['inserts']++; |
|
1297 | + } |
|
1228 | 1298 | } |
1229 | 1299 | } |
1230 | 1300 | |
@@ -1237,15 +1307,17 @@ discard block |
||
1237 | 1307 | // Sort out the context for the SQL. |
1238 | 1308 | foreach ($incontext['sql_results'] as $key => $number) |
1239 | 1309 | { |
1240 | - if ($number == 0) |
|
1241 | - unset($incontext['sql_results'][$key]); |
|
1242 | - else |
|
1243 | - $incontext['sql_results'][$key] = sprintf($txt['db_populate_' . $key], $number); |
|
1310 | + if ($number == 0) { |
|
1311 | + unset($incontext['sql_results'][$key]); |
|
1312 | + } else { |
|
1313 | + $incontext['sql_results'][$key] = sprintf($txt['db_populate_' . $key], $number); |
|
1314 | + } |
|
1244 | 1315 | } |
1245 | 1316 | |
1246 | 1317 | // Make sure UTF will be used globally. |
1247 | - if ((!empty($databases[$db_type]['utf8_support']) && !empty($databases[$db_type]['utf8_required'])) || (empty($databases[$db_type]['utf8_required']) && !empty($databases[$db_type]['utf8_support']) && isset($_POST['utf8']))) |
|
1248 | - $newSettings[] = array('global_character_set', 'UTF-8'); |
|
1318 | + if ((!empty($databases[$db_type]['utf8_support']) && !empty($databases[$db_type]['utf8_required'])) || (empty($databases[$db_type]['utf8_required']) && !empty($databases[$db_type]['utf8_support']) && isset($_POST['utf8']))) { |
|
1319 | + $newSettings[] = array('global_character_set', 'UTF-8'); |
|
1320 | + } |
|
1249 | 1321 | |
1250 | 1322 | // Auto-detect local & global cookie settings |
1251 | 1323 | $url_parts = parse_url($boardurl); |
@@ -1274,15 +1346,19 @@ discard block |
||
1274 | 1346 | |
1275 | 1347 | // Look for subfolder, if found, set localCookie |
1276 | 1348 | // Checking for len > 1 ensures you don't have just a slash... |
1277 | - if (!empty($url_parts['path']) && strlen($url_parts['path']) > 1) |
|
1278 | - $localCookies = '1'; |
|
1349 | + if (!empty($url_parts['path']) && strlen($url_parts['path']) > 1) { |
|
1350 | + $localCookies = '1'; |
|
1351 | + } |
|
1279 | 1352 | |
1280 | - if (isset($globalCookies)) |
|
1281 | - $newSettings[] = array('globalCookies', $globalCookies); |
|
1282 | - if (isset($globalCookiesDomain)) |
|
1283 | - $newSettings[] = array('globalCookiesDomain', $globalCookiesDomain); |
|
1284 | - if (isset($localCookies)) |
|
1285 | - $newSettings[] = array('localCookies', $localCookies); |
|
1353 | + if (isset($globalCookies)) { |
|
1354 | + $newSettings[] = array('globalCookies', $globalCookies); |
|
1355 | + } |
|
1356 | + if (isset($globalCookiesDomain)) { |
|
1357 | + $newSettings[] = array('globalCookiesDomain', $globalCookiesDomain); |
|
1358 | + } |
|
1359 | + if (isset($localCookies)) { |
|
1360 | + $newSettings[] = array('localCookies', $localCookies); |
|
1361 | + } |
|
1286 | 1362 | } |
1287 | 1363 | |
1288 | 1364 | // Are we allowing stat collection? |
@@ -1300,16 +1376,17 @@ discard block |
||
1300 | 1376 | fwrite($fp, $out); |
1301 | 1377 | |
1302 | 1378 | $return_data = ''; |
1303 | - while (!feof($fp)) |
|
1304 | - $return_data .= fgets($fp, 128); |
|
1379 | + while (!feof($fp)) { |
|
1380 | + $return_data .= fgets($fp, 128); |
|
1381 | + } |
|
1305 | 1382 | |
1306 | 1383 | fclose($fp); |
1307 | 1384 | |
1308 | 1385 | // Get the unique site ID. |
1309 | 1386 | preg_match('~SITE-ID:\s(\w{10})~', $return_data, $ID); |
1310 | 1387 | |
1311 | - if (!empty($ID[1])) |
|
1312 | - $smcFunc['db_insert']('replace', |
|
1388 | + if (!empty($ID[1])) { |
|
1389 | + $smcFunc['db_insert']('replace', |
|
1313 | 1390 | $db_prefix . 'settings', |
1314 | 1391 | array('variable' => 'string', 'value' => 'string'), |
1315 | 1392 | array( |
@@ -1318,11 +1395,12 @@ discard block |
||
1318 | 1395 | ), |
1319 | 1396 | array('variable') |
1320 | 1397 | ); |
1398 | + } |
|
1321 | 1399 | } |
1322 | 1400 | } |
1323 | 1401 | // Don't remove stat collection unless we unchecked the box for real, not from the loop. |
1324 | - elseif (empty($_POST['stats']) && empty($upcontext['allow_sm_stats'])) |
|
1325 | - $smcFunc['db_query']('', ' |
|
1402 | + elseif (empty($_POST['stats']) && empty($upcontext['allow_sm_stats'])) { |
|
1403 | + $smcFunc['db_query']('', ' |
|
1326 | 1404 | DELETE FROM {db_prefix}settings |
1327 | 1405 | WHERE variable = {string:enable_sm_stats}', |
1328 | 1406 | array( |
@@ -1330,20 +1408,23 @@ discard block |
||
1330 | 1408 | 'db_error_skip' => true, |
1331 | 1409 | ) |
1332 | 1410 | ); |
1411 | + } |
|
1333 | 1412 | |
1334 | 1413 | // Are we enabling SSL? |
1335 | - if (!empty($_POST['force_ssl'])) |
|
1336 | - $newSettings[] = array('force_ssl', 1); |
|
1414 | + if (!empty($_POST['force_ssl'])) { |
|
1415 | + $newSettings[] = array('force_ssl', 1); |
|
1416 | + } |
|
1337 | 1417 | |
1338 | 1418 | // Setting a timezone is required. |
1339 | 1419 | if (!isset($modSettings['default_timezone']) && function_exists('date_default_timezone_set')) |
1340 | 1420 | { |
1341 | 1421 | // Get PHP's default timezone, if set |
1342 | 1422 | $ini_tz = ini_get('date.timezone'); |
1343 | - if (!empty($ini_tz)) |
|
1344 | - $timezone_id = $ini_tz; |
|
1345 | - else |
|
1346 | - $timezone_id = ''; |
|
1423 | + if (!empty($ini_tz)) { |
|
1424 | + $timezone_id = $ini_tz; |
|
1425 | + } else { |
|
1426 | + $timezone_id = ''; |
|
1427 | + } |
|
1347 | 1428 | |
1348 | 1429 | // If date.timezone is unset, invalid, or just plain weird, make a best guess |
1349 | 1430 | if (!in_array($timezone_id, timezone_identifiers_list())) |
@@ -1352,8 +1433,9 @@ discard block |
||
1352 | 1433 | $timezone_id = timezone_name_from_abbr('', $server_offset, 0); |
1353 | 1434 | } |
1354 | 1435 | |
1355 | - if (date_default_timezone_set($timezone_id)) |
|
1356 | - $newSettings[] = array('default_timezone', $timezone_id); |
|
1436 | + if (date_default_timezone_set($timezone_id)) { |
|
1437 | + $newSettings[] = array('default_timezone', $timezone_id); |
|
1438 | + } |
|
1357 | 1439 | } |
1358 | 1440 | |
1359 | 1441 | if (!empty($newSettings)) |
@@ -1384,16 +1466,18 @@ discard block |
||
1384 | 1466 | } |
1385 | 1467 | |
1386 | 1468 | // MySQL specific stuff |
1387 | - if (substr($db_type, 0, 5) != 'mysql') |
|
1388 | - return false; |
|
1469 | + if (substr($db_type, 0, 5) != 'mysql') { |
|
1470 | + return false; |
|
1471 | + } |
|
1389 | 1472 | |
1390 | 1473 | // Find database user privileges. |
1391 | 1474 | $privs = array(); |
1392 | 1475 | $get_privs = $smcFunc['db_query']('', 'SHOW PRIVILEGES', array()); |
1393 | 1476 | while ($row = $smcFunc['db_fetch_assoc']($get_privs)) |
1394 | 1477 | { |
1395 | - if ($row['Privilege'] == 'Alter') |
|
1396 | - $privs[] = $row['Privilege']; |
|
1478 | + if ($row['Privilege'] == 'Alter') { |
|
1479 | + $privs[] = $row['Privilege']; |
|
1480 | + } |
|
1397 | 1481 | } |
1398 | 1482 | $smcFunc['db_free_result']($get_privs); |
1399 | 1483 | |
@@ -1423,8 +1507,9 @@ discard block |
||
1423 | 1507 | $incontext['continue'] = 1; |
1424 | 1508 | |
1425 | 1509 | // Skipping? |
1426 | - if (!empty($_POST['skip'])) |
|
1427 | - return true; |
|
1510 | + if (!empty($_POST['skip'])) { |
|
1511 | + return true; |
|
1512 | + } |
|
1428 | 1513 | |
1429 | 1514 | // Need this to check whether we need the database password. |
1430 | 1515 | require(dirname(__FILE__) . '/Settings.php'); |
@@ -1441,18 +1526,22 @@ discard block |
||
1441 | 1526 | // We need this to properly hash the password for Admin |
1442 | 1527 | $smcFunc['strtolower'] = $db_character_set != 'utf8' && $txt['lang_character_set'] != 'UTF-8' ? 'strtolower' : function($string) { |
1443 | 1528 | global $sourcedir; |
1444 | - if (function_exists('mb_strtolower')) |
|
1445 | - return mb_strtolower($string, 'UTF-8'); |
|
1529 | + if (function_exists('mb_strtolower')) { |
|
1530 | + return mb_strtolower($string, 'UTF-8'); |
|
1531 | + } |
|
1446 | 1532 | require_once($sourcedir . '/Subs-Charset.php'); |
1447 | 1533 | return utf8_strtolower($string); |
1448 | 1534 | }; |
1449 | 1535 | |
1450 | - if (!isset($_POST['username'])) |
|
1451 | - $_POST['username'] = ''; |
|
1452 | - if (!isset($_POST['email'])) |
|
1453 | - $_POST['email'] = ''; |
|
1454 | - if (!isset($_POST['server_email'])) |
|
1455 | - $_POST['server_email'] = ''; |
|
1536 | + if (!isset($_POST['username'])) { |
|
1537 | + $_POST['username'] = ''; |
|
1538 | + } |
|
1539 | + if (!isset($_POST['email'])) { |
|
1540 | + $_POST['email'] = ''; |
|
1541 | + } |
|
1542 | + if (!isset($_POST['server_email'])) { |
|
1543 | + $_POST['server_email'] = ''; |
|
1544 | + } |
|
1456 | 1545 | |
1457 | 1546 | $incontext['username'] = htmlspecialchars(stripslashes($_POST['username'])); |
1458 | 1547 | $incontext['email'] = htmlspecialchars(stripslashes($_POST['email'])); |
@@ -1471,8 +1560,9 @@ discard block |
||
1471 | 1560 | 'admin_group' => 1, |
1472 | 1561 | ) |
1473 | 1562 | ); |
1474 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
1475 | - $incontext['skip'] = 1; |
|
1563 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
1564 | + $incontext['skip'] = 1; |
|
1565 | + } |
|
1476 | 1566 | $smcFunc['db_free_result']($request); |
1477 | 1567 | |
1478 | 1568 | // Trying to create an account? |
@@ -1503,8 +1593,9 @@ discard block |
||
1503 | 1593 | } |
1504 | 1594 | |
1505 | 1595 | // Update the webmaster's email? |
1506 | - if (!empty($_POST['server_email']) && (empty($webmaster_email) || $webmaster_email == '[email protected]')) |
|
1507 | - updateSettingsFile(array('webmaster_email' => $_POST['server_email'])); |
|
1596 | + if (!empty($_POST['server_email']) && (empty($webmaster_email) || $webmaster_email == '[email protected]')) { |
|
1597 | + updateSettingsFile(array('webmaster_email' => $_POST['server_email'])); |
|
1598 | + } |
|
1508 | 1599 | |
1509 | 1600 | // Work out whether we're going to have dodgy characters and remove them. |
1510 | 1601 | $invalid_characters = preg_match('~[<>&"\'=\\\]~', $_POST['username']) != 0; |
@@ -1527,32 +1618,27 @@ discard block |
||
1527 | 1618 | $smcFunc['db_free_result']($result); |
1528 | 1619 | |
1529 | 1620 | $incontext['account_existed'] = $txt['error_user_settings_taken']; |
1530 | - } |
|
1531 | - elseif ($_POST['username'] == '' || strlen($_POST['username']) > 25) |
|
1621 | + } elseif ($_POST['username'] == '' || strlen($_POST['username']) > 25) |
|
1532 | 1622 | { |
1533 | 1623 | // Try the previous step again. |
1534 | 1624 | $incontext['error'] = $_POST['username'] == '' ? $txt['error_username_left_empty'] : $txt['error_username_too_long']; |
1535 | 1625 | return false; |
1536 | - } |
|
1537 | - elseif ($invalid_characters || $_POST['username'] == '_' || $_POST['username'] == '|' || strpos($_POST['username'], '[code') !== false || strpos($_POST['username'], '[/code') !== false) |
|
1626 | + } elseif ($invalid_characters || $_POST['username'] == '_' || $_POST['username'] == '|' || strpos($_POST['username'], '[code') !== false || strpos($_POST['username'], '[/code') !== false) |
|
1538 | 1627 | { |
1539 | 1628 | // Try the previous step again. |
1540 | 1629 | $incontext['error'] = $txt['error_invalid_characters_username']; |
1541 | 1630 | return false; |
1542 | - } |
|
1543 | - elseif (empty($_POST['email']) || !filter_var(stripslashes($_POST['email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['email'])) > 255) |
|
1631 | + } elseif (empty($_POST['email']) || !filter_var(stripslashes($_POST['email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['email'])) > 255) |
|
1544 | 1632 | { |
1545 | 1633 | // One step back, this time fill out a proper admin email address. |
1546 | 1634 | $incontext['error'] = sprintf($txt['error_valid_admin_email_needed'], $_POST['username']); |
1547 | 1635 | return false; |
1548 | - } |
|
1549 | - elseif (empty($_POST['server_email']) || !filter_var(stripslashes($_POST['server_email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['server_email'])) > 255) |
|
1636 | + } elseif (empty($_POST['server_email']) || !filter_var(stripslashes($_POST['server_email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['server_email'])) > 255) |
|
1550 | 1637 | { |
1551 | 1638 | // One step back, this time fill out a proper admin email address. |
1552 | 1639 | $incontext['error'] = $txt['error_valid_server_email_needed']; |
1553 | 1640 | return false; |
1554 | - } |
|
1555 | - elseif ($_POST['username'] != '') |
|
1641 | + } elseif ($_POST['username'] != '') |
|
1556 | 1642 | { |
1557 | 1643 | $incontext['member_salt'] = substr(md5(mt_rand()), 0, 4); |
1558 | 1644 | |
@@ -1620,17 +1706,19 @@ discard block |
||
1620 | 1706 | reloadSettings(); |
1621 | 1707 | |
1622 | 1708 | // Bring a warning over. |
1623 | - if (!empty($incontext['account_existed'])) |
|
1624 | - $incontext['warning'] = $incontext['account_existed']; |
|
1709 | + if (!empty($incontext['account_existed'])) { |
|
1710 | + $incontext['warning'] = $incontext['account_existed']; |
|
1711 | + } |
|
1625 | 1712 | |
1626 | - if (!empty($db_character_set) && !empty($databases[$db_type]['utf8_support'])) |
|
1627 | - $smcFunc['db_query']('', ' |
|
1713 | + if (!empty($db_character_set) && !empty($databases[$db_type]['utf8_support'])) { |
|
1714 | + $smcFunc['db_query']('', ' |
|
1628 | 1715 | SET NAMES {string:db_character_set}', |
1629 | 1716 | array( |
1630 | 1717 | 'db_character_set' => $db_character_set, |
1631 | 1718 | 'db_error_skip' => true, |
1632 | 1719 | ) |
1633 | 1720 | ); |
1721 | + } |
|
1634 | 1722 | |
1635 | 1723 | // As track stats is by default enabled let's add some activity. |
1636 | 1724 | $smcFunc['db_insert']('ignore', |
@@ -1651,14 +1739,16 @@ discard block |
||
1651 | 1739 | // Only proceed if we can load the data. |
1652 | 1740 | if ($request) |
1653 | 1741 | { |
1654 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
1655 | - $modSettings[$row[0]] = $row[1]; |
|
1742 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
1743 | + $modSettings[$row[0]] = $row[1]; |
|
1744 | + } |
|
1656 | 1745 | $smcFunc['db_free_result']($request); |
1657 | 1746 | } |
1658 | 1747 | |
1659 | 1748 | // Automatically log them in ;) |
1660 | - if (isset($incontext['member_id']) && isset($incontext['member_salt'])) |
|
1661 | - setLoginCookie(3153600 * 60, $incontext['member_id'], hash_salt($_POST['password1'], $incontext['member_salt'])); |
|
1749 | + if (isset($incontext['member_id']) && isset($incontext['member_salt'])) { |
|
1750 | + setLoginCookie(3153600 * 60, $incontext['member_id'], hash_salt($_POST['password1'], $incontext['member_salt'])); |
|
1751 | + } |
|
1662 | 1752 | |
1663 | 1753 | $result = $smcFunc['db_query']('', ' |
1664 | 1754 | SELECT value |
@@ -1669,13 +1759,14 @@ discard block |
||
1669 | 1759 | 'db_error_skip' => true, |
1670 | 1760 | ) |
1671 | 1761 | ); |
1672 | - if ($smcFunc['db_num_rows']($result) != 0) |
|
1673 | - list ($db_sessions) = $smcFunc['db_fetch_row']($result); |
|
1762 | + if ($smcFunc['db_num_rows']($result) != 0) { |
|
1763 | + list ($db_sessions) = $smcFunc['db_fetch_row']($result); |
|
1764 | + } |
|
1674 | 1765 | $smcFunc['db_free_result']($result); |
1675 | 1766 | |
1676 | - if (empty($db_sessions)) |
|
1677 | - $_SESSION['admin_time'] = time(); |
|
1678 | - else |
|
1767 | + if (empty($db_sessions)) { |
|
1768 | + $_SESSION['admin_time'] = time(); |
|
1769 | + } else |
|
1679 | 1770 | { |
1680 | 1771 | $_SERVER['HTTP_USER_AGENT'] = substr($_SERVER['HTTP_USER_AGENT'], 0, 211); |
1681 | 1772 | |
@@ -1699,8 +1790,9 @@ discard block |
||
1699 | 1790 | $smcFunc['strtolower'] = $db_character_set != 'utf8' && $txt['lang_character_set'] != 'UTF-8' ? 'strtolower' : |
1700 | 1791 | function($string){ |
1701 | 1792 | global $sourcedir; |
1702 | - if (function_exists('mb_strtolower')) |
|
1703 | - return mb_strtolower($string, 'UTF-8'); |
|
1793 | + if (function_exists('mb_strtolower')) { |
|
1794 | + return mb_strtolower($string, 'UTF-8'); |
|
1795 | + } |
|
1704 | 1796 | require_once($sourcedir . '/Subs-Charset.php'); |
1705 | 1797 | return utf8_strtolower($string); |
1706 | 1798 | }; |
@@ -1716,8 +1808,9 @@ discard block |
||
1716 | 1808 | ) |
1717 | 1809 | ); |
1718 | 1810 | $context['utf8'] = $db_character_set === 'utf8' || $txt['lang_character_set'] === 'UTF-8'; |
1719 | - if ($smcFunc['db_num_rows']($request) > 0) |
|
1720 | - updateStats('subject', 1, htmlspecialchars($txt['default_topic_subject'])); |
|
1811 | + if ($smcFunc['db_num_rows']($request) > 0) { |
|
1812 | + updateStats('subject', 1, htmlspecialchars($txt['default_topic_subject'])); |
|
1813 | + } |
|
1721 | 1814 | $smcFunc['db_free_result']($request); |
1722 | 1815 | |
1723 | 1816 | // Now is the perfect time to fetch the SM files. |
@@ -1736,8 +1829,9 @@ discard block |
||
1736 | 1829 | |
1737 | 1830 | // Check if we need some stupid MySQL fix. |
1738 | 1831 | $server_version = $smcFunc['db_server_info'](); |
1739 | - if (($db_type == 'mysql' || $db_type == 'mysqli') && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) |
|
1740 | - updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
1832 | + if (($db_type == 'mysql' || $db_type == 'mysqli') && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) { |
|
1833 | + updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
1834 | + } |
|
1741 | 1835 | |
1742 | 1836 | // Some final context for the template. |
1743 | 1837 | $incontext['dir_still_writable'] = is_writable(dirname(__FILE__)) && substr(__FILE__, 1, 2) != ':\\'; |
@@ -1757,8 +1851,9 @@ discard block |
||
1757 | 1851 | $settingsArray = file(dirname(__FILE__) . '/Settings.php'); |
1758 | 1852 | |
1759 | 1853 | // @todo Do we just want to read the file in clean, and split it this way always? |
1760 | - if (count($settingsArray) == 1) |
|
1761 | - $settingsArray = preg_split('~[\r\n]~', $settingsArray[0]); |
|
1854 | + if (count($settingsArray) == 1) { |
|
1855 | + $settingsArray = preg_split('~[\r\n]~', $settingsArray[0]); |
|
1856 | + } |
|
1762 | 1857 | |
1763 | 1858 | for ($i = 0, $n = count($settingsArray); $i < $n; $i++) |
1764 | 1859 | { |
@@ -1766,25 +1861,29 @@ discard block |
||
1766 | 1861 | if (trim($settingsArray[$i]) == 'if (file_exists(dirname(__FILE__) . \'/install.php\'))' && trim($settingsArray[$i + 1]) == '{' && trim($settingsArray[$i + 9]) == '}') |
1767 | 1862 | { |
1768 | 1863 | // Set the ten lines to nothing. |
1769 | - for ($j=0; $j < 10; $j++) |
|
1770 | - $settingsArray[$i++] = ''; |
|
1864 | + for ($j=0; $j < 10; $j++) { |
|
1865 | + $settingsArray[$i++] = ''; |
|
1866 | + } |
|
1771 | 1867 | |
1772 | 1868 | continue; |
1773 | 1869 | } |
1774 | 1870 | |
1775 | - if (trim($settingsArray[$i]) == '?' . '>') |
|
1776 | - $settingsArray[$i] = ''; |
|
1871 | + if (trim($settingsArray[$i]) == '?' . '>') { |
|
1872 | + $settingsArray[$i] = ''; |
|
1873 | + } |
|
1777 | 1874 | |
1778 | 1875 | // Don't trim or bother with it if it's not a variable. |
1779 | - if (substr($settingsArray[$i], 0, 1) != '$') |
|
1780 | - continue; |
|
1876 | + if (substr($settingsArray[$i], 0, 1) != '$') { |
|
1877 | + continue; |
|
1878 | + } |
|
1781 | 1879 | |
1782 | 1880 | $settingsArray[$i] = rtrim($settingsArray[$i]) . "\n"; |
1783 | 1881 | |
1784 | - foreach ($vars as $var => $val) |
|
1785 | - if (strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0) |
|
1882 | + foreach ($vars as $var => $val) { |
|
1883 | + if (strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0) |
|
1786 | 1884 | { |
1787 | 1885 | $comment = strstr($settingsArray[$i], '#'); |
1886 | + } |
|
1788 | 1887 | $settingsArray[$i] = '$' . $var . ' = \'' . $val . '\';' . ($comment != '' ? "\t\t" . $comment : "\n"); |
1789 | 1888 | unset($vars[$var]); |
1790 | 1889 | } |
@@ -1794,36 +1893,41 @@ discard block |
||
1794 | 1893 | if (!empty($vars)) |
1795 | 1894 | { |
1796 | 1895 | $settingsArray[$i++] = ''; |
1797 | - foreach ($vars as $var => $val) |
|
1798 | - $settingsArray[$i++] = '$' . $var . ' = \'' . $val . '\';' . "\n"; |
|
1896 | + foreach ($vars as $var => $val) { |
|
1897 | + $settingsArray[$i++] = '$' . $var . ' = \'' . $val . '\';' . "\n"; |
|
1898 | + } |
|
1799 | 1899 | } |
1800 | 1900 | |
1801 | 1901 | // Blank out the file - done to fix a oddity with some servers. |
1802 | 1902 | $fp = @fopen(dirname(__FILE__) . '/Settings.php', 'w'); |
1803 | - if (!$fp) |
|
1804 | - return false; |
|
1903 | + if (!$fp) { |
|
1904 | + return false; |
|
1905 | + } |
|
1805 | 1906 | fclose($fp); |
1806 | 1907 | |
1807 | 1908 | $fp = fopen(dirname(__FILE__) . '/Settings.php', 'r+'); |
1808 | 1909 | |
1809 | 1910 | // Gotta have one of these ;) |
1810 | - if (trim($settingsArray[0]) != '<?php') |
|
1811 | - fwrite($fp, "<?php\n"); |
|
1911 | + if (trim($settingsArray[0]) != '<?php') { |
|
1912 | + fwrite($fp, "<?php\n"); |
|
1913 | + } |
|
1812 | 1914 | |
1813 | 1915 | $lines = count($settingsArray); |
1814 | 1916 | for ($i = 0; $i < $lines - 1; $i++) |
1815 | 1917 | { |
1816 | 1918 | // Don't just write a bunch of blank lines. |
1817 | - if ($settingsArray[$i] != '' || @$settingsArray[$i - 1] != '') |
|
1818 | - fwrite($fp, strtr($settingsArray[$i], "\r", '')); |
|
1919 | + if ($settingsArray[$i] != '' || @$settingsArray[$i - 1] != '') { |
|
1920 | + fwrite($fp, strtr($settingsArray[$i], "\r", '')); |
|
1921 | + } |
|
1819 | 1922 | } |
1820 | 1923 | fwrite($fp, $settingsArray[$i] . '?' . '>'); |
1821 | 1924 | fclose($fp); |
1822 | 1925 | |
1823 | 1926 | // Even though on normal installations the filemtime should prevent this being used by the installer incorrectly |
1824 | 1927 | // it seems that there are times it might not. So let's MAKE it dump the cache. |
1825 | - if (function_exists('opcache_invalidate')) |
|
1826 | - opcache_invalidate(dirname(__FILE__) . '/Settings.php', true); |
|
1928 | + if (function_exists('opcache_invalidate')) { |
|
1929 | + opcache_invalidate(dirname(__FILE__) . '/Settings.php', true); |
|
1930 | + } |
|
1827 | 1931 | |
1828 | 1932 | return true; |
1829 | 1933 | } |
@@ -1833,10 +1937,11 @@ discard block |
||
1833 | 1937 | global $cachedir; |
1834 | 1938 | |
1835 | 1939 | // Write out the db_last_error file with the error timestamp |
1836 | - if (!empty($cachedir) && is_writable($cachedir)) |
|
1837 | - file_put_contents($cachedir . '/db_last_error.php', '<' . '?' . "php\n" . '$db_last_error = 0;' . "\n" . '?' . '>'); |
|
1838 | - else |
|
1839 | - file_put_contents(dirname(__FILE__) . '/cache/db_last_error.php', '<' . '?' . "php\n" . '$db_last_error = 0;' . "\n" . '?' . '>'); |
|
1940 | + if (!empty($cachedir) && is_writable($cachedir)) { |
|
1941 | + file_put_contents($cachedir . '/db_last_error.php', '<' . '?' . "php\n" . '$db_last_error = 0;' . "\n" . '?' . '>'); |
|
1942 | + } else { |
|
1943 | + file_put_contents(dirname(__FILE__) . '/cache/db_last_error.php', '<' . '?' . "php\n" . '$db_last_error = 0;' . "\n" . '?' . '>'); |
|
1944 | + } |
|
1840 | 1945 | |
1841 | 1946 | return true; |
1842 | 1947 | } |
@@ -1853,9 +1958,9 @@ discard block |
||
1853 | 1958 | SecFilterScanPOST Off |
1854 | 1959 | </IfModule>'; |
1855 | 1960 | |
1856 | - if (!function_exists('apache_get_modules') || !in_array('mod_security', apache_get_modules())) |
|
1857 | - return true; |
|
1858 | - elseif (file_exists(dirname(__FILE__) . '/.htaccess') && is_writable(dirname(__FILE__) . '/.htaccess')) |
|
1961 | + if (!function_exists('apache_get_modules') || !in_array('mod_security', apache_get_modules())) { |
|
1962 | + return true; |
|
1963 | + } elseif (file_exists(dirname(__FILE__) . '/.htaccess') && is_writable(dirname(__FILE__) . '/.htaccess')) |
|
1859 | 1964 | { |
1860 | 1965 | $current_htaccess = implode('', file(dirname(__FILE__) . '/.htaccess')); |
1861 | 1966 | |
@@ -1867,29 +1972,28 @@ discard block |
||
1867 | 1972 | fwrite($ht_handle, $htaccess_addition); |
1868 | 1973 | fclose($ht_handle); |
1869 | 1974 | return true; |
1975 | + } else { |
|
1976 | + return false; |
|
1870 | 1977 | } |
1871 | - else |
|
1872 | - return false; |
|
1978 | + } else { |
|
1979 | + return true; |
|
1873 | 1980 | } |
1874 | - else |
|
1875 | - return true; |
|
1876 | - } |
|
1877 | - elseif (file_exists(dirname(__FILE__) . '/.htaccess')) |
|
1878 | - return strpos(implode('', file(dirname(__FILE__) . '/.htaccess')), '<IfModule mod_security.c>') !== false; |
|
1879 | - elseif (is_writable(dirname(__FILE__))) |
|
1981 | + } elseif (file_exists(dirname(__FILE__) . '/.htaccess')) { |
|
1982 | + return strpos(implode('', file(dirname(__FILE__) . '/.htaccess')), '<IfModule mod_security.c>') !== false; |
|
1983 | + } elseif (is_writable(dirname(__FILE__))) |
|
1880 | 1984 | { |
1881 | 1985 | if ($ht_handle = fopen(dirname(__FILE__) . '/.htaccess', 'w')) |
1882 | 1986 | { |
1883 | 1987 | fwrite($ht_handle, $htaccess_addition); |
1884 | 1988 | fclose($ht_handle); |
1885 | 1989 | return true; |
1990 | + } else { |
|
1991 | + return false; |
|
1886 | 1992 | } |
1887 | - else |
|
1993 | + } else { |
|
1888 | 1994 | return false; |
1889 | 1995 | } |
1890 | - else |
|
1891 | - return false; |
|
1892 | -} |
|
1996 | + } |
|
1893 | 1997 | |
1894 | 1998 | function template_install_above() |
1895 | 1999 | { |
@@ -1927,9 +2031,10 @@ discard block |
||
1927 | 2031 | <label for="installer_language">', $txt['installer_language'], ':</label> |
1928 | 2032 | <select id="installer_language" name="lang_file" onchange="location.href = \'', $installurl, '?lang_file=\' + this.options[this.selectedIndex].value;">'; |
1929 | 2033 | |
1930 | - foreach ($incontext['detected_languages'] as $lang => $name) |
|
1931 | - echo ' |
|
2034 | + foreach ($incontext['detected_languages'] as $lang => $name) { |
|
2035 | + echo ' |
|
1932 | 2036 | <option', isset($_SESSION['installer_temp_lang']) && $_SESSION['installer_temp_lang'] == $lang ? ' selected' : '', ' value="', $lang, '">', $name, '</option>'; |
2037 | + } |
|
1933 | 2038 | |
1934 | 2039 | echo ' |
1935 | 2040 | </select> |
@@ -1949,9 +2054,10 @@ discard block |
||
1949 | 2054 | <h2>', $txt['upgrade_progress'], '</h2> |
1950 | 2055 | <ul>'; |
1951 | 2056 | |
1952 | - foreach ($incontext['steps'] as $num => $step) |
|
1953 | - echo ' |
|
2057 | + foreach ($incontext['steps'] as $num => $step) { |
|
2058 | + echo ' |
|
1954 | 2059 | <li class="', $num < $incontext['current_step'] ? 'stepdone' : ($num == $incontext['current_step'] ? 'stepcurrent' : 'stepwaiting'), '">', $txt['upgrade_step'], ' ', $step[0], ': ', $step[1], '</li>'; |
2060 | + } |
|
1955 | 2061 | |
1956 | 2062 | echo ' |
1957 | 2063 | </ul> |
@@ -1976,20 +2082,23 @@ discard block |
||
1976 | 2082 | echo ' |
1977 | 2083 | <div class="floatright">'; |
1978 | 2084 | |
1979 | - if (!empty($incontext['continue'])) |
|
1980 | - echo ' |
|
2085 | + if (!empty($incontext['continue'])) { |
|
2086 | + echo ' |
|
1981 | 2087 | <input type="submit" id="contbutt" name="contbutt" value="', $txt['upgrade_continue'], '" onclick="return submitThisOnce(this);" class="button" />'; |
1982 | - if (!empty($incontext['skip'])) |
|
1983 | - echo ' |
|
2088 | + } |
|
2089 | + if (!empty($incontext['skip'])) { |
|
2090 | + echo ' |
|
1984 | 2091 | <input type="submit" id="skip" name="skip" value="', $txt['upgrade_skip'], '" onclick="return submitThisOnce(this);" class="button" />'; |
2092 | + } |
|
1985 | 2093 | echo ' |
1986 | 2094 | </div>'; |
1987 | 2095 | } |
1988 | 2096 | |
1989 | 2097 | // Show the closing form tag and other data only if not in the last step |
1990 | - if (count($incontext['steps']) - 1 !== (int) $incontext['current_step']) |
|
1991 | - echo ' |
|
2098 | + if (count($incontext['steps']) - 1 !== (int) $incontext['current_step']) { |
|
2099 | + echo ' |
|
1992 | 2100 | </form>'; |
2101 | + } |
|
1993 | 2102 | |
1994 | 2103 | echo ' |
1995 | 2104 | </div> |
@@ -2024,13 +2133,15 @@ discard block |
||
2024 | 2133 | </div>'; |
2025 | 2134 | |
2026 | 2135 | // Show the warnings, or not. |
2027 | - if (template_warning_divs()) |
|
2028 | - echo ' |
|
2136 | + if (template_warning_divs()) { |
|
2137 | + echo ' |
|
2029 | 2138 | <h3>', $txt['install_all_lovely'], '</h3>'; |
2139 | + } |
|
2030 | 2140 | |
2031 | 2141 | // Say we want the continue button! |
2032 | - if (empty($incontext['error'])) |
|
2033 | - $incontext['continue'] = 1; |
|
2142 | + if (empty($incontext['error'])) { |
|
2143 | + $incontext['continue'] = 1; |
|
2144 | + } |
|
2034 | 2145 | |
2035 | 2146 | // For the latest version stuff. |
2036 | 2147 | echo ' |
@@ -2064,8 +2175,8 @@ discard block |
||
2064 | 2175 | global $txt, $incontext; |
2065 | 2176 | |
2066 | 2177 | // Errors are very serious.. |
2067 | - if (!empty($incontext['error'])) |
|
2068 | - echo ' |
|
2178 | + if (!empty($incontext['error'])) { |
|
2179 | + echo ' |
|
2069 | 2180 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
2070 | 2181 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
2071 | 2182 | <strong style="text-decoration: underline;">', $txt['upgrade_critical_error'], '</strong><br> |
@@ -2073,9 +2184,10 @@ discard block |
||
2073 | 2184 | ', $incontext['error'], ' |
2074 | 2185 | </div> |
2075 | 2186 | </div>'; |
2187 | + } |
|
2076 | 2188 | // A warning message? |
2077 | - elseif (!empty($incontext['warning'])) |
|
2078 | - echo ' |
|
2189 | + elseif (!empty($incontext['warning'])) { |
|
2190 | + echo ' |
|
2079 | 2191 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
2080 | 2192 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
2081 | 2193 | <strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br> |
@@ -2083,6 +2195,7 @@ discard block |
||
2083 | 2195 | ', $incontext['warning'], ' |
2084 | 2196 | </div> |
2085 | 2197 | </div>'; |
2198 | + } |
|
2086 | 2199 | |
2087 | 2200 | return empty($incontext['error']) && empty($incontext['warning']); |
2088 | 2201 | } |
@@ -2098,27 +2211,30 @@ discard block |
||
2098 | 2211 | <li>', $incontext['failed_files']), '</li> |
2099 | 2212 | </ul>'; |
2100 | 2213 | |
2101 | - if (isset($incontext['systemos'], $incontext['detected_path']) && $incontext['systemos'] == 'linux') |
|
2102 | - echo ' |
|
2214 | + if (isset($incontext['systemos'], $incontext['detected_path']) && $incontext['systemos'] == 'linux') { |
|
2215 | + echo ' |
|
2103 | 2216 | <hr> |
2104 | 2217 | <p>', $txt['chmod_linux_info'], '</p> |
2105 | 2218 | <tt># chmod a+w ', implode(' ' . $incontext['detected_path'] . '/', $incontext['failed_files']), '</tt>'; |
2219 | + } |
|
2106 | 2220 | |
2107 | 2221 | // This is serious! |
2108 | - if (!template_warning_divs()) |
|
2109 | - return; |
|
2222 | + if (!template_warning_divs()) { |
|
2223 | + return; |
|
2224 | + } |
|
2110 | 2225 | |
2111 | 2226 | echo ' |
2112 | 2227 | <hr> |
2113 | 2228 | <p>', $txt['ftp_setup_info'], '</p>'; |
2114 | 2229 | |
2115 | - if (!empty($incontext['ftp_errors'])) |
|
2116 | - echo ' |
|
2230 | + if (!empty($incontext['ftp_errors'])) { |
|
2231 | + echo ' |
|
2117 | 2232 | <div class="error_message"> |
2118 | 2233 | ', $txt['error_ftp_no_connect'], '<br><br> |
2119 | 2234 | <code>', implode('<br>', $incontext['ftp_errors']), '</code> |
2120 | 2235 | </div> |
2121 | 2236 | <br>'; |
2237 | + } |
|
2122 | 2238 | |
2123 | 2239 | echo ' |
2124 | 2240 | <form action="', $incontext['form_url'], '" method="post"> |
@@ -2178,17 +2294,17 @@ discard block |
||
2178 | 2294 | <td> |
2179 | 2295 | <select name="db_type" id="db_type_input" onchange="toggleDBInput();">'; |
2180 | 2296 | |
2181 | - foreach ($incontext['supported_databases'] as $key => $db) |
|
2182 | - echo ' |
|
2297 | + foreach ($incontext['supported_databases'] as $key => $db) { |
|
2298 | + echo ' |
|
2183 | 2299 | <option value="', $key, '"', isset($_POST['db_type']) && $_POST['db_type'] == $key ? ' selected' : '', '>', $db['name'], '</option>'; |
2300 | + } |
|
2184 | 2301 | |
2185 | 2302 | echo ' |
2186 | 2303 | </select> |
2187 | 2304 | <div class="smalltext block">', $txt['db_settings_type_info'], '</div> |
2188 | 2305 | </td> |
2189 | 2306 | </tr>'; |
2190 | - } |
|
2191 | - else |
|
2307 | + } else |
|
2192 | 2308 | { |
2193 | 2309 | echo ' |
2194 | 2310 | <tr style="display: none;"> |
@@ -2381,9 +2497,10 @@ discard block |
||
2381 | 2497 | <div style="color: red;">', $txt['error_db_queries'], '</div> |
2382 | 2498 | <ul>'; |
2383 | 2499 | |
2384 | - foreach ($incontext['failures'] as $line => $fail) |
|
2385 | - echo ' |
|
2500 | + foreach ($incontext['failures'] as $line => $fail) { |
|
2501 | + echo ' |
|
2386 | 2502 | <li><strong>', $txt['error_db_queries_line'], $line + 1, ':</strong> ', nl2br(htmlspecialchars($fail)), '</li>'; |
2503 | + } |
|
2387 | 2504 | |
2388 | 2505 | echo ' |
2389 | 2506 | </ul>'; |
@@ -2444,15 +2561,16 @@ discard block |
||
2444 | 2561 | </tr> |
2445 | 2562 | </table>'; |
2446 | 2563 | |
2447 | - if ($incontext['require_db_confirm']) |
|
2448 | - echo ' |
|
2564 | + if ($incontext['require_db_confirm']) { |
|
2565 | + echo ' |
|
2449 | 2566 | <h2>', $txt['user_settings_database'], '</h2> |
2450 | 2567 | <p>', $txt['user_settings_database_info'], '</p> |
2451 | 2568 | |
2452 | 2569 | <div style="margin-bottom: 2ex; padding-', $txt['lang_rtl'] == false ? 'left' : 'right', ': 50px;"> |
2453 | 2570 | <input type="password" name="password3" size="30" /> |
2454 | 2571 | </div>'; |
2455 | -} |
|
2572 | + } |
|
2573 | + } |
|
2456 | 2574 | |
2457 | 2575 | // Tell them it's done, and to delete. |
2458 | 2576 | function template_delete_install() |
@@ -2465,14 +2583,15 @@ discard block |
||
2465 | 2583 | template_warning_divs(); |
2466 | 2584 | |
2467 | 2585 | // Install directory still writable? |
2468 | - if ($incontext['dir_still_writable']) |
|
2469 | - echo ' |
|
2586 | + if ($incontext['dir_still_writable']) { |
|
2587 | + echo ' |
|
2470 | 2588 | <em>', $txt['still_writable'], '</em><br> |
2471 | 2589 | <br>'; |
2590 | + } |
|
2472 | 2591 | |
2473 | 2592 | // Don't show the box if it's like 99% sure it won't work :P. |
2474 | - if ($incontext['probably_delete_install']) |
|
2475 | - echo ' |
|
2593 | + if ($incontext['probably_delete_install']) { |
|
2594 | + echo ' |
|
2476 | 2595 | <div style="margin: 1ex; font-weight: bold;"> |
2477 | 2596 | <label for="delete_self"><input type="checkbox" id="delete_self" onclick="doTheDelete();" /> ', $txt['delete_installer'], !isset($_SESSION['installer_temp_ftp']) ? ' ' . $txt['delete_installer_maybe'] : '', '</label> |
2478 | 2597 | </div> |
@@ -2488,6 +2607,7 @@ discard block |
||
2488 | 2607 | } |
2489 | 2608 | </script> |
2490 | 2609 | <br>'; |
2610 | + } |
|
2491 | 2611 | |
2492 | 2612 | echo ' |
2493 | 2613 | ', sprintf($txt['go_to_your_forum'], $boardurl . '/index.php'), '<br> |
@@ -185,17 +185,21 @@ discard block |
||
185 | 185 | $tasksdir = $sourcedir . '/tasks'; |
186 | 186 | |
187 | 187 | # Make sure the paths are correct... at least try to fix them. |
188 | -if (!file_exists($boarddir) && file_exists(dirname(__FILE__) . '/agreement.txt')) |
|
188 | +if (!file_exists($boarddir) && file_exists(dirname(__FILE__) . '/agreement.txt')) { |
|
189 | 189 | $boarddir = dirname(__FILE__); |
190 | -if (!file_exists($sourcedir) && file_exists($boarddir . '/Sources')) |
|
190 | +} |
|
191 | +if (!file_exists($sourcedir) && file_exists($boarddir . '/Sources')) { |
|
191 | 192 | $sourcedir = $boarddir . '/Sources'; |
192 | -if (!file_exists($cachedir) && file_exists($boarddir . '/cache')) |
|
193 | +} |
|
194 | +if (!file_exists($cachedir) && file_exists($boarddir . '/cache')) { |
|
193 | 195 | $cachedir = $boarddir . '/cache'; |
196 | +} |
|
194 | 197 | |
195 | 198 | ########## Error-Catching ########## |
196 | 199 | # Note: You shouldn't touch these settings. |
197 | -if (file_exists((isset($cachedir) ? $cachedir : dirname(__FILE__)) . '/db_last_error.php')) |
|
200 | +if (file_exists((isset($cachedir) ? $cachedir : dirname(__FILE__)) . '/db_last_error.php')) { |
|
198 | 201 | include((isset($cachedir) ? $cachedir : dirname(__FILE__)) . '/db_last_error.php'); |
202 | +} |
|
199 | 203 | |
200 | 204 | if (!isset($db_last_error)) |
201 | 205 | { |
@@ -207,10 +211,11 @@ discard block |
||
207 | 211 | if (file_exists(dirname(__FILE__) . '/install.php')) |
208 | 212 | { |
209 | 213 | $secure = false; |
210 | - if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') |
|
211 | - $secure = true; |
|
212 | - elseif (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' || !empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on') |
|
213 | - $secure = true; |
|
214 | + if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') { |
|
215 | + $secure = true; |
|
216 | + } elseif (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' || !empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on') { |
|
217 | + $secure = true; |
|
218 | + } |
|
214 | 219 | |
215 | 220 | header('location: http' . ($secure ? 's' : '') . '://' . (empty($_SERVER['HTTP_HOST']) ? $_SERVER['SERVER_NAME'] . (empty($_SERVER['SERVER_PORT']) || $_SERVER['SERVER_PORT'] == '80' ? '' : ':' . $_SERVER['SERVER_PORT']) : $_SERVER['HTTP_HOST']) . (strtr(dirname($_SERVER['PHP_SELF']), '\\', '/') == '/' ? '' : strtr(dirname($_SERVER['PHP_SELF']), '\\', '/')) . '/install.php'); exit; |
216 | 221 | } |
@@ -12,7 +12,8 @@ |
||
12 | 12 | header('location: ' . $boardurl); |
13 | 13 | } |
14 | 14 | // Can't find it... just forget it. |
15 | -else |
|
15 | +else { |
|
16 | 16 | exit; |
17 | +} |
|
17 | 18 | |
18 | 19 | ?> |
19 | 20 | \ No newline at end of file |
@@ -12,7 +12,8 @@ |
||
12 | 12 | header('location: ' . $boardurl); |
13 | 13 | } |
14 | 14 | // Can't find it... just forget it. |
15 | -else |
|
15 | +else { |
|
16 | 16 | exit; |
17 | +} |
|
17 | 18 | |
18 | 19 | ?> |
19 | 20 | \ No newline at end of file |
@@ -12,7 +12,8 @@ |
||
12 | 12 | header('location: ' . $boardurl); |
13 | 13 | } |
14 | 14 | // Can't find it... just forget it. |
15 | -else |
|
15 | +else { |
|
16 | 16 | exit; |
17 | +} |
|
17 | 18 | |
18 | 19 | ?> |
19 | 20 | \ No newline at end of file |
@@ -12,7 +12,8 @@ |
||
12 | 12 | header('location: ' . $boardurl); |
13 | 13 | } |
14 | 14 | // Can't find it... just forget it. |
15 | -else |
|
15 | +else { |
|
16 | 16 | exit; |
17 | +} |
|
17 | 18 | |
18 | 19 | ?> |
19 | 20 | \ No newline at end of file |
@@ -12,7 +12,8 @@ |
||
12 | 12 | header('location: ' . $boardurl); |
13 | 13 | } |
14 | 14 | // Can't find it... just forget it. |
15 | -else |
|
15 | +else { |
|
16 | 16 | exit; |
17 | +} |
|
17 | 18 | |
18 | 19 | ?> |
19 | 20 | \ No newline at end of file |