@@ -14,8 +14,9 @@ discard block |
||
14 | 14 | * @version 2.1 Beta 4 |
15 | 15 | */ |
16 | 16 | |
17 | -if (!defined('SMF')) |
|
17 | +if (!defined('SMF')) { |
|
18 | 18 | die('No direct access...'); |
19 | +} |
|
19 | 20 | |
20 | 21 | /** |
21 | 22 | * Check if the current directory is still valid or not. |
@@ -28,22 +29,24 @@ discard block |
||
28 | 29 | global $smcFunc, $boarddir, $modSettings, $context; |
29 | 30 | |
30 | 31 | // Not pretty, but since we don't want folders created for every post. It'll do unless a better solution can be found. |
31 | - if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'admin') |
|
32 | - $doit = true; |
|
33 | - elseif (empty($modSettings['automanage_attachments'])) |
|
34 | - return; |
|
35 | - elseif (!isset($_FILES)) |
|
36 | - return; |
|
37 | - elseif (isset($_FILES['attachment'])) |
|
38 | - foreach ($_FILES['attachment']['tmp_name'] as $dummy) |
|
32 | + if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'admin') { |
|
33 | + $doit = true; |
|
34 | + } elseif (empty($modSettings['automanage_attachments'])) { |
|
35 | + return; |
|
36 | + } elseif (!isset($_FILES)) { |
|
37 | + return; |
|
38 | + } elseif (isset($_FILES['attachment'])) { |
|
39 | + foreach ($_FILES['attachment']['tmp_name'] as $dummy) |
|
39 | 40 | if (!empty($dummy)) |
40 | 41 | { |
41 | 42 | $doit = true; |
43 | + } |
|
42 | 44 | break; |
43 | 45 | } |
44 | 46 | |
45 | - if (!isset($doit)) |
|
46 | - return; |
|
47 | + if (!isset($doit)) { |
|
48 | + return; |
|
49 | + } |
|
47 | 50 | |
48 | 51 | $year = date('Y'); |
49 | 52 | $month = date('m'); |
@@ -54,21 +57,25 @@ discard block |
||
54 | 57 | |
55 | 58 | if (!empty($modSettings['attachment_basedirectories']) && !empty($modSettings['use_subdirectories_for_attachments'])) |
56 | 59 | { |
57 | - if (!is_array($modSettings['attachment_basedirectories'])) |
|
58 | - $modSettings['attachment_basedirectories'] = $smcFunc['json_decode']($modSettings['attachment_basedirectories'], true); |
|
60 | + if (!is_array($modSettings['attachment_basedirectories'])) { |
|
61 | + $modSettings['attachment_basedirectories'] = $smcFunc['json_decode']($modSettings['attachment_basedirectories'], true); |
|
62 | + } |
|
59 | 63 | $base_dir = array_search($modSettings['basedirectory_for_attachments'], $modSettings['attachment_basedirectories']); |
64 | + } else { |
|
65 | + $base_dir = 0; |
|
60 | 66 | } |
61 | - else |
|
62 | - $base_dir = 0; |
|
63 | 67 | |
64 | 68 | if ($modSettings['automanage_attachments'] == 1) |
65 | 69 | { |
66 | - if (!isset($modSettings['last_attachments_directory'])) |
|
67 | - $modSettings['last_attachments_directory'] = array(); |
|
68 | - if (!is_array($modSettings['last_attachments_directory'])) |
|
69 | - $modSettings['last_attachments_directory'] = $smcFunc['json_decode']($modSettings['last_attachments_directory'], true); |
|
70 | - if (!isset($modSettings['last_attachments_directory'][$base_dir])) |
|
71 | - $modSettings['last_attachments_directory'][$base_dir] = 0; |
|
70 | + if (!isset($modSettings['last_attachments_directory'])) { |
|
71 | + $modSettings['last_attachments_directory'] = array(); |
|
72 | + } |
|
73 | + if (!is_array($modSettings['last_attachments_directory'])) { |
|
74 | + $modSettings['last_attachments_directory'] = $smcFunc['json_decode']($modSettings['last_attachments_directory'], true); |
|
75 | + } |
|
76 | + if (!isset($modSettings['last_attachments_directory'][$base_dir])) { |
|
77 | + $modSettings['last_attachments_directory'][$base_dir] = 0; |
|
78 | + } |
|
72 | 79 | } |
73 | 80 | |
74 | 81 | $basedirectory = (!empty($modSettings['use_subdirectories_for_attachments']) ? ($modSettings['basedirectory_for_attachments']) : $boarddir); |
@@ -97,12 +104,14 @@ discard block |
||
97 | 104 | $updir = ''; |
98 | 105 | } |
99 | 106 | |
100 | - if (!is_array($modSettings['attachmentUploadDir'])) |
|
101 | - $modSettings['attachmentUploadDir'] = $smcFunc['json_decode']($modSettings['attachmentUploadDir'], true); |
|
102 | - if (!in_array($updir, $modSettings['attachmentUploadDir']) && !empty($updir)) |
|
103 | - $outputCreation = automanage_attachments_create_directory($updir); |
|
104 | - elseif (in_array($updir, $modSettings['attachmentUploadDir'])) |
|
105 | - $outputCreation = true; |
|
107 | + if (!is_array($modSettings['attachmentUploadDir'])) { |
|
108 | + $modSettings['attachmentUploadDir'] = $smcFunc['json_decode']($modSettings['attachmentUploadDir'], true); |
|
109 | + } |
|
110 | + if (!in_array($updir, $modSettings['attachmentUploadDir']) && !empty($updir)) { |
|
111 | + $outputCreation = automanage_attachments_create_directory($updir); |
|
112 | + } elseif (in_array($updir, $modSettings['attachmentUploadDir'])) { |
|
113 | + $outputCreation = true; |
|
114 | + } |
|
106 | 115 | |
107 | 116 | if ($outputCreation) |
108 | 117 | { |
@@ -139,8 +148,9 @@ discard block |
||
139 | 148 | $count = count($tree); |
140 | 149 | |
141 | 150 | $directory = attachments_init_dir($tree, $count); |
142 | - if ($directory === false) |
|
143 | - return false; |
|
151 | + if ($directory === false) { |
|
152 | + return false; |
|
153 | + } |
|
144 | 154 | } |
145 | 155 | |
146 | 156 | $directory .= DIRECTORY_SEPARATOR . array_shift($tree); |
@@ -168,8 +178,9 @@ discard block |
||
168 | 178 | } |
169 | 179 | |
170 | 180 | // Everything seems fine...let's create the .htaccess |
171 | - if (!file_exists($directory . DIRECTORY_SEPARATOR . '.htaccess')) |
|
172 | - secureDirectory($updir, true); |
|
181 | + if (!file_exists($directory . DIRECTORY_SEPARATOR . '.htaccess')) { |
|
182 | + secureDirectory($updir, true); |
|
183 | + } |
|
173 | 184 | |
174 | 185 | $sep = (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') ? '\/' : DIRECTORY_SEPARATOR; |
175 | 186 | $updir = rtrim($updir, $sep); |
@@ -201,8 +212,9 @@ discard block |
||
201 | 212 | { |
202 | 213 | global $smcFunc, $modSettings, $boarddir; |
203 | 214 | |
204 | - if (!isset($modSettings['automanage_attachments']) || (!empty($modSettings['automanage_attachments']) && $modSettings['automanage_attachments'] != 1)) |
|
205 | - return; |
|
215 | + if (!isset($modSettings['automanage_attachments']) || (!empty($modSettings['automanage_attachments']) && $modSettings['automanage_attachments'] != 1)) { |
|
216 | + return; |
|
217 | + } |
|
206 | 218 | |
207 | 219 | $basedirectory = !empty($modSettings['use_subdirectories_for_attachments']) ? $modSettings['basedirectory_for_attachments'] : $boarddir; |
208 | 220 | // Just to be sure: I don't want directory separators at the end |
@@ -214,13 +226,14 @@ discard block |
||
214 | 226 | { |
215 | 227 | $base_dir = array_search($modSettings['basedirectory_for_attachments'], $modSettings['attachment_basedirectories']); |
216 | 228 | $base_dir = !empty($modSettings['automanage_attachments']) ? $base_dir : 0; |
229 | + } else { |
|
230 | + $base_dir = 0; |
|
217 | 231 | } |
218 | - else |
|
219 | - $base_dir = 0; |
|
220 | 232 | |
221 | 233 | // Get the last attachment directory for that base directory |
222 | - if (empty($modSettings['last_attachments_directory'][$base_dir])) |
|
223 | - $modSettings['last_attachments_directory'][$base_dir] = 0; |
|
234 | + if (empty($modSettings['last_attachments_directory'][$base_dir])) { |
|
235 | + $modSettings['last_attachments_directory'][$base_dir] = 0; |
|
236 | + } |
|
224 | 237 | // And increment it. |
225 | 238 | $modSettings['last_attachments_directory'][$base_dir]++; |
226 | 239 | |
@@ -235,10 +248,10 @@ discard block |
||
235 | 248 | $modSettings['last_attachments_directory'] = $smcFunc['json_decode']($modSettings['last_attachments_directory'], true); |
236 | 249 | |
237 | 250 | return true; |
251 | + } else { |
|
252 | + return false; |
|
253 | + } |
|
238 | 254 | } |
239 | - else |
|
240 | - return false; |
|
241 | -} |
|
242 | 255 | |
243 | 256 | /** |
244 | 257 | * Split a path into a list of all directories and subdirectories |
@@ -256,12 +269,13 @@ discard block |
||
256 | 269 | * in Windows we need to explode for both \ and / |
257 | 270 | * while in linux should be safe to explode only for / (aka DIRECTORY_SEPARATOR) |
258 | 271 | */ |
259 | - if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') |
|
260 | - $tree = preg_split('#[\\\/]#', $directory); |
|
261 | - else |
|
272 | + if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { |
|
273 | + $tree = preg_split('#[\\\/]#', $directory); |
|
274 | + } else |
|
262 | 275 | { |
263 | - if (substr($directory, 0, 1) != DIRECTORY_SEPARATOR) |
|
264 | - return false; |
|
276 | + if (substr($directory, 0, 1) != DIRECTORY_SEPARATOR) { |
|
277 | + return false; |
|
278 | + } |
|
265 | 279 | |
266 | 280 | $tree = explode(DIRECTORY_SEPARATOR, trim($directory, DIRECTORY_SEPARATOR)); |
267 | 281 | } |
@@ -285,10 +299,11 @@ discard block |
||
285 | 299 | //Better be sure that the first part of the path is actually a drive letter... |
286 | 300 | //...even if, I should check this in the admin page...isn't it? |
287 | 301 | //...NHAAA Let's leave space for users' complains! :P |
288 | - if (preg_match('/^[a-z]:$/i', $tree[0])) |
|
289 | - $directory = array_shift($tree); |
|
290 | - else |
|
291 | - return false; |
|
302 | + if (preg_match('/^[a-z]:$/i', $tree[0])) { |
|
303 | + $directory = array_shift($tree); |
|
304 | + } else { |
|
305 | + return false; |
|
306 | + } |
|
292 | 307 | |
293 | 308 | $count--; |
294 | 309 | } |
@@ -303,18 +318,20 @@ discard block |
||
303 | 318 | global $context, $modSettings, $smcFunc, $txt, $user_info; |
304 | 319 | |
305 | 320 | // Make sure we're uploading to the right place. |
306 | - if (!empty($modSettings['automanage_attachments'])) |
|
307 | - automanage_attachments_check_directory(); |
|
321 | + if (!empty($modSettings['automanage_attachments'])) { |
|
322 | + automanage_attachments_check_directory(); |
|
323 | + } |
|
308 | 324 | |
309 | - if (!is_array($modSettings['attachmentUploadDir'])) |
|
310 | - $modSettings['attachmentUploadDir'] = $smcFunc['json_decode']($modSettings['attachmentUploadDir'], true); |
|
325 | + if (!is_array($modSettings['attachmentUploadDir'])) { |
|
326 | + $modSettings['attachmentUploadDir'] = $smcFunc['json_decode']($modSettings['attachmentUploadDir'], true); |
|
327 | + } |
|
311 | 328 | |
312 | 329 | $context['attach_dir'] = $modSettings['attachmentUploadDir'][$modSettings['currentAttachmentUploadDir']]; |
313 | 330 | |
314 | 331 | // Is the attachments folder actualy there? |
315 | - if (!empty($context['dir_creation_error'])) |
|
316 | - $initial_error = $context['dir_creation_error']; |
|
317 | - elseif (!is_dir($context['attach_dir'])) |
|
332 | + if (!empty($context['dir_creation_error'])) { |
|
333 | + $initial_error = $context['dir_creation_error']; |
|
334 | + } elseif (!is_dir($context['attach_dir'])) |
|
318 | 335 | { |
319 | 336 | $initial_error = 'attach_folder_warning'; |
320 | 337 | log_error(sprintf($txt['attach_folder_admin_warning'], $context['attach_dir']), 'critical'); |
@@ -337,12 +354,12 @@ discard block |
||
337 | 354 | ); |
338 | 355 | list ($context['attachments']['quantity'], $context['attachments']['total_size']) = $smcFunc['db_fetch_row']($request); |
339 | 356 | $smcFunc['db_free_result']($request); |
340 | - } |
|
341 | - else |
|
342 | - $context['attachments'] = array( |
|
357 | + } else { |
|
358 | + $context['attachments'] = array( |
|
343 | 359 | 'quantity' => 0, |
344 | 360 | 'total_size' => 0, |
345 | 361 | ); |
362 | + } |
|
346 | 363 | } |
347 | 364 | |
348 | 365 | // Hmm. There are still files in session. |
@@ -352,39 +369,44 @@ discard block |
||
352 | 369 | // Let's try to keep them. But... |
353 | 370 | $ignore_temp = true; |
354 | 371 | // If new files are being added. We can't ignore those |
355 | - foreach ($_FILES['attachment']['tmp_name'] as $dummy) |
|
356 | - if (!empty($dummy)) |
|
372 | + foreach ($_FILES['attachment']['tmp_name'] as $dummy) { |
|
373 | + if (!empty($dummy)) |
|
357 | 374 | { |
358 | 375 | $ignore_temp = false; |
376 | + } |
|
359 | 377 | break; |
360 | 378 | } |
361 | 379 | |
362 | 380 | // Need to make space for the new files. So, bye bye. |
363 | 381 | if (!$ignore_temp) |
364 | 382 | { |
365 | - foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
|
366 | - if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false) |
|
383 | + foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) { |
|
384 | + if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false) |
|
367 | 385 | unlink($attachment['tmp_name']); |
386 | + } |
|
368 | 387 | |
369 | 388 | $context['we_are_history'] = $txt['error_temp_attachments_flushed']; |
370 | 389 | $_SESSION['temp_attachments'] = array(); |
371 | 390 | } |
372 | 391 | } |
373 | 392 | |
374 | - if (!isset($_FILES['attachment']['name'])) |
|
375 | - $_FILES['attachment']['tmp_name'] = array(); |
|
393 | + if (!isset($_FILES['attachment']['name'])) { |
|
394 | + $_FILES['attachment']['tmp_name'] = array(); |
|
395 | + } |
|
376 | 396 | |
377 | - if (!isset($_SESSION['temp_attachments'])) |
|
378 | - $_SESSION['temp_attachments'] = array(); |
|
397 | + if (!isset($_SESSION['temp_attachments'])) { |
|
398 | + $_SESSION['temp_attachments'] = array(); |
|
399 | + } |
|
379 | 400 | |
380 | 401 | // Remember where we are at. If it's anywhere at all. |
381 | - if (!$ignore_temp) |
|
382 | - $_SESSION['temp_attachments']['post'] = array( |
|
402 | + if (!$ignore_temp) { |
|
403 | + $_SESSION['temp_attachments']['post'] = array( |
|
383 | 404 | 'msg' => !empty($_REQUEST['msg']) ? $_REQUEST['msg'] : 0, |
384 | 405 | 'last_msg' => !empty($_REQUEST['last_msg']) ? $_REQUEST['last_msg'] : 0, |
385 | 406 | 'topic' => !empty($topic) ? $topic : 0, |
386 | 407 | 'board' => !empty($board) ? $board : 0, |
387 | 408 | ); |
409 | + } |
|
388 | 410 | |
389 | 411 | // If we have an initial error, lets just display it. |
390 | 412 | if (!empty($initial_error)) |
@@ -392,9 +414,10 @@ discard block |
||
392 | 414 | $_SESSION['temp_attachments']['initial_error'] = $initial_error; |
393 | 415 | |
394 | 416 | // And delete the files 'cos they ain't going nowhere. |
395 | - foreach ($_FILES['attachment']['tmp_name'] as $n => $dummy) |
|
396 | - if (file_exists($_FILES['attachment']['tmp_name'][$n])) |
|
417 | + foreach ($_FILES['attachment']['tmp_name'] as $n => $dummy) { |
|
418 | + if (file_exists($_FILES['attachment']['tmp_name'][$n])) |
|
397 | 419 | unlink($_FILES['attachment']['tmp_name'][$n]); |
420 | + } |
|
398 | 421 | |
399 | 422 | $_FILES['attachment']['tmp_name'] = array(); |
400 | 423 | } |
@@ -402,21 +425,24 @@ discard block |
||
402 | 425 | // Loop through $_FILES['attachment'] array and move each file to the current attachments folder. |
403 | 426 | foreach ($_FILES['attachment']['tmp_name'] as $n => $dummy) |
404 | 427 | { |
405 | - if ($_FILES['attachment']['name'][$n] == '') |
|
406 | - continue; |
|
428 | + if ($_FILES['attachment']['name'][$n] == '') { |
|
429 | + continue; |
|
430 | + } |
|
407 | 431 | |
408 | 432 | // First, let's first check for PHP upload errors. |
409 | 433 | $errors = array(); |
410 | 434 | if (!empty($_FILES['attachment']['error'][$n])) |
411 | 435 | { |
412 | - if ($_FILES['attachment']['error'][$n] == 2) |
|
413 | - $errors[] = array('file_too_big', array($modSettings['attachmentSizeLimit'])); |
|
414 | - elseif ($_FILES['attachment']['error'][$n] == 6) |
|
415 | - log_error($_FILES['attachment']['name'][$n] . ': ' . $txt['php_upload_error_6'], 'critical'); |
|
416 | - else |
|
417 | - log_error($_FILES['attachment']['name'][$n] . ': ' . $txt['php_upload_error_' . $_FILES['attachment']['error'][$n]]); |
|
418 | - if (empty($errors)) |
|
419 | - $errors[] = 'attach_php_error'; |
|
436 | + if ($_FILES['attachment']['error'][$n] == 2) { |
|
437 | + $errors[] = array('file_too_big', array($modSettings['attachmentSizeLimit'])); |
|
438 | + } elseif ($_FILES['attachment']['error'][$n] == 6) { |
|
439 | + log_error($_FILES['attachment']['name'][$n] . ': ' . $txt['php_upload_error_6'], 'critical'); |
|
440 | + } else { |
|
441 | + log_error($_FILES['attachment']['name'][$n] . ': ' . $txt['php_upload_error_' . $_FILES['attachment']['error'][$n]]); |
|
442 | + } |
|
443 | + if (empty($errors)) { |
|
444 | + $errors[] = 'attach_php_error'; |
|
445 | + } |
|
420 | 446 | } |
421 | 447 | |
422 | 448 | // Try to move and rename the file before doing any more checks on it. |
@@ -426,8 +452,9 @@ discard block |
||
426 | 452 | { |
427 | 453 | // The reported MIME type of the attachment might not be reliable. |
428 | 454 | // Fortunately, PHP 5.3+ lets us easily verify the real MIME type. |
429 | - if (function_exists('mime_content_type')) |
|
430 | - $_FILES['attachment']['type'][$n] = mime_content_type($_FILES['attachment']['tmp_name'][$n]); |
|
455 | + if (function_exists('mime_content_type')) { |
|
456 | + $_FILES['attachment']['type'][$n] = mime_content_type($_FILES['attachment']['tmp_name'][$n]); |
|
457 | + } |
|
431 | 458 | |
432 | 459 | $_SESSION['temp_attachments'][$attachID] = array( |
433 | 460 | 'name' => $smcFunc['htmlspecialchars'](basename($_FILES['attachment']['name'][$n])), |
@@ -439,16 +466,16 @@ discard block |
||
439 | 466 | ); |
440 | 467 | |
441 | 468 | // Move the file to the attachments folder with a temp name for now. |
442 | - if (@move_uploaded_file($_FILES['attachment']['tmp_name'][$n], $destName)) |
|
443 | - smf_chmod($destName, 0644); |
|
444 | - else |
|
469 | + if (@move_uploaded_file($_FILES['attachment']['tmp_name'][$n], $destName)) { |
|
470 | + smf_chmod($destName, 0644); |
|
471 | + } else |
|
445 | 472 | { |
446 | 473 | $_SESSION['temp_attachments'][$attachID]['errors'][] = 'attach_timeout'; |
447 | - if (file_exists($_FILES['attachment']['tmp_name'][$n])) |
|
448 | - unlink($_FILES['attachment']['tmp_name'][$n]); |
|
474 | + if (file_exists($_FILES['attachment']['tmp_name'][$n])) { |
|
475 | + unlink($_FILES['attachment']['tmp_name'][$n]); |
|
476 | + } |
|
449 | 477 | } |
450 | - } |
|
451 | - else |
|
478 | + } else |
|
452 | 479 | { |
453 | 480 | $_SESSION['temp_attachments'][$attachID] = array( |
454 | 481 | 'name' => $smcFunc['htmlspecialchars'](basename($_FILES['attachment']['name'][$n])), |
@@ -456,12 +483,14 @@ discard block |
||
456 | 483 | 'errors' => $errors, |
457 | 484 | ); |
458 | 485 | |
459 | - if (file_exists($_FILES['attachment']['tmp_name'][$n])) |
|
460 | - unlink($_FILES['attachment']['tmp_name'][$n]); |
|
486 | + if (file_exists($_FILES['attachment']['tmp_name'][$n])) { |
|
487 | + unlink($_FILES['attachment']['tmp_name'][$n]); |
|
488 | + } |
|
461 | 489 | } |
462 | 490 | // If there's no errors to this point. We still do need to apply some additional checks before we are finished. |
463 | - if (empty($_SESSION['temp_attachments'][$attachID]['errors'])) |
|
464 | - attachmentChecks($attachID); |
|
491 | + if (empty($_SESSION['temp_attachments'][$attachID]['errors'])) { |
|
492 | + attachmentChecks($attachID); |
|
493 | + } |
|
465 | 494 | } |
466 | 495 | // Mod authors, finally a hook to hang an alternate attachment upload system upon |
467 | 496 | // Upload to the current attachment folder with the file name $attachID or 'post_tmp_' . $user_info['id'] . '_' . md5(mt_rand()) |
@@ -488,21 +517,20 @@ discard block |
||
488 | 517 | global $modSettings, $context, $sourcedir, $smcFunc; |
489 | 518 | |
490 | 519 | // No data or missing data .... Not necessarily needed, but in case a mod author missed something. |
491 | - if (empty($_SESSION['temp_attachments'][$attachID])) |
|
492 | - $error = '$_SESSION[\'temp_attachments\'][$attachID]'; |
|
493 | - |
|
494 | - elseif (empty($attachID)) |
|
495 | - $error = '$attachID'; |
|
496 | - |
|
497 | - elseif (empty($context['attachments'])) |
|
498 | - $error = '$context[\'attachments\']'; |
|
499 | - |
|
500 | - elseif (empty($context['attach_dir'])) |
|
501 | - $error = '$context[\'attach_dir\']'; |
|
520 | + if (empty($_SESSION['temp_attachments'][$attachID])) { |
|
521 | + $error = '$_SESSION[\'temp_attachments\'][$attachID]'; |
|
522 | + } elseif (empty($attachID)) { |
|
523 | + $error = '$attachID'; |
|
524 | + } elseif (empty($context['attachments'])) { |
|
525 | + $error = '$context[\'attachments\']'; |
|
526 | + } elseif (empty($context['attach_dir'])) { |
|
527 | + $error = '$context[\'attach_dir\']'; |
|
528 | + } |
|
502 | 529 | |
503 | 530 | // Let's get their attention. |
504 | - if (!empty($error)) |
|
505 | - fatal_lang_error('attach_check_nag', 'debug', array($error)); |
|
531 | + if (!empty($error)) { |
|
532 | + fatal_lang_error('attach_check_nag', 'debug', array($error)); |
|
533 | + } |
|
506 | 534 | |
507 | 535 | // Just in case this slipped by the first checks, we stop it here and now |
508 | 536 | if ($_SESSION['temp_attachments'][$attachID]['size'] == 0) |
@@ -531,8 +559,9 @@ discard block |
||
531 | 559 | $size = @getimagesize($_SESSION['temp_attachments'][$attachID]['tmp_name']); |
532 | 560 | if (!(empty($size)) && ($size[2] != $old_format)) |
533 | 561 | { |
534 | - if (isset($context['valid_image_types'][$size[2]])) |
|
535 | - $_SESSION['temp_attachments'][$attachID]['type'] = 'image/' . $context['valid_image_types'][$size[2]]; |
|
562 | + if (isset($context['valid_image_types'][$size[2]])) { |
|
563 | + $_SESSION['temp_attachments'][$attachID]['type'] = 'image/' . $context['valid_image_types'][$size[2]]; |
|
564 | + } |
|
536 | 565 | } |
537 | 566 | } |
538 | 567 | } |
@@ -586,42 +615,48 @@ discard block |
||
586 | 615 | // Or, let the user know that it ain't gonna happen. |
587 | 616 | else |
588 | 617 | { |
589 | - if (isset($context['dir_creation_error'])) |
|
590 | - $_SESSION['temp_attachments'][$attachID]['errors'][] = $context['dir_creation_error']; |
|
591 | - else |
|
592 | - $_SESSION['temp_attachments'][$attachID]['errors'][] = 'ran_out_of_space'; |
|
618 | + if (isset($context['dir_creation_error'])) { |
|
619 | + $_SESSION['temp_attachments'][$attachID]['errors'][] = $context['dir_creation_error']; |
|
620 | + } else { |
|
621 | + $_SESSION['temp_attachments'][$attachID]['errors'][] = 'ran_out_of_space'; |
|
622 | + } |
|
593 | 623 | } |
624 | + } else { |
|
625 | + $_SESSION['temp_attachments'][$attachID]['errors'][] = 'ran_out_of_space'; |
|
594 | 626 | } |
595 | - else |
|
596 | - $_SESSION['temp_attachments'][$attachID]['errors'][] = 'ran_out_of_space'; |
|
597 | 627 | } |
598 | 628 | } |
599 | 629 | |
600 | 630 | // Is the file too big? |
601 | 631 | $context['attachments']['total_size'] += $_SESSION['temp_attachments'][$attachID]['size']; |
602 | - if (!empty($modSettings['attachmentSizeLimit']) && $_SESSION['temp_attachments'][$attachID]['size'] > $modSettings['attachmentSizeLimit'] * 1024) |
|
603 | - $_SESSION['temp_attachments'][$attachID]['errors'][] = array('file_too_big', array(comma_format($modSettings['attachmentSizeLimit'], 0))); |
|
632 | + if (!empty($modSettings['attachmentSizeLimit']) && $_SESSION['temp_attachments'][$attachID]['size'] > $modSettings['attachmentSizeLimit'] * 1024) { |
|
633 | + $_SESSION['temp_attachments'][$attachID]['errors'][] = array('file_too_big', array(comma_format($modSettings['attachmentSizeLimit'], 0))); |
|
634 | + } |
|
604 | 635 | |
605 | 636 | // Check the total upload size for this post... |
606 | - if (!empty($modSettings['attachmentPostLimit']) && $context['attachments']['total_size'] > $modSettings['attachmentPostLimit'] * 1024) |
|
607 | - $_SESSION['temp_attachments'][$attachID]['errors'][] = array('attach_max_total_file_size', array(comma_format($modSettings['attachmentPostLimit'], 0), comma_format($modSettings['attachmentPostLimit'] - (($context['attachments']['total_size'] - $_SESSION['temp_attachments'][$attachID]['size']) / 1024), 0))); |
|
637 | + if (!empty($modSettings['attachmentPostLimit']) && $context['attachments']['total_size'] > $modSettings['attachmentPostLimit'] * 1024) { |
|
638 | + $_SESSION['temp_attachments'][$attachID]['errors'][] = array('attach_max_total_file_size', array(comma_format($modSettings['attachmentPostLimit'], 0), comma_format($modSettings['attachmentPostLimit'] - (($context['attachments']['total_size'] - $_SESSION['temp_attachments'][$attachID]['size']) / 1024), 0))); |
|
639 | + } |
|
608 | 640 | |
609 | 641 | // Have we reached the maximum number of files we are allowed? |
610 | 642 | $context['attachments']['quantity']++; |
611 | 643 | |
612 | 644 | // Set a max limit if none exists |
613 | - if (empty($modSettings['attachmentNumPerPostLimit']) && $context['attachments']['quantity'] >= 50) |
|
614 | - $modSettings['attachmentNumPerPostLimit'] = 50; |
|
645 | + if (empty($modSettings['attachmentNumPerPostLimit']) && $context['attachments']['quantity'] >= 50) { |
|
646 | + $modSettings['attachmentNumPerPostLimit'] = 50; |
|
647 | + } |
|
615 | 648 | |
616 | - if (!empty($modSettings['attachmentNumPerPostLimit']) && $context['attachments']['quantity'] > $modSettings['attachmentNumPerPostLimit']) |
|
617 | - $_SESSION['temp_attachments'][$attachID]['errors'][] = array('attachments_limit_per_post', array($modSettings['attachmentNumPerPostLimit'])); |
|
649 | + if (!empty($modSettings['attachmentNumPerPostLimit']) && $context['attachments']['quantity'] > $modSettings['attachmentNumPerPostLimit']) { |
|
650 | + $_SESSION['temp_attachments'][$attachID]['errors'][] = array('attachments_limit_per_post', array($modSettings['attachmentNumPerPostLimit'])); |
|
651 | + } |
|
618 | 652 | |
619 | 653 | // File extension check |
620 | 654 | if (!empty($modSettings['attachmentCheckExtensions'])) |
621 | 655 | { |
622 | 656 | $allowed = explode(',', strtolower($modSettings['attachmentExtensions'])); |
623 | - foreach ($allowed as $k => $dummy) |
|
624 | - $allowed[$k] = trim($dummy); |
|
657 | + foreach ($allowed as $k => $dummy) { |
|
658 | + $allowed[$k] = trim($dummy); |
|
659 | + } |
|
625 | 660 | |
626 | 661 | if (!in_array(strtolower(substr(strrchr($_SESSION['temp_attachments'][$attachID]['name'], '.'), 1)), $allowed)) |
627 | 662 | { |
@@ -633,10 +668,12 @@ discard block |
||
633 | 668 | // Undo the math if there's an error |
634 | 669 | if (!empty($_SESSION['temp_attachments'][$attachID]['errors'])) |
635 | 670 | { |
636 | - if (isset($context['dir_size'])) |
|
637 | - $context['dir_size'] -= $_SESSION['temp_attachments'][$attachID]['size']; |
|
638 | - if (isset($context['dir_files'])) |
|
639 | - $context['dir_files']--; |
|
671 | + if (isset($context['dir_size'])) { |
|
672 | + $context['dir_size'] -= $_SESSION['temp_attachments'][$attachID]['size']; |
|
673 | + } |
|
674 | + if (isset($context['dir_files'])) { |
|
675 | + $context['dir_files']--; |
|
676 | + } |
|
640 | 677 | $context['attachments']['total_size'] -= $_SESSION['temp_attachments'][$attachID]['size']; |
641 | 678 | $context['attachments']['quantity']--; |
642 | 679 | return false; |
@@ -668,12 +705,14 @@ discard block |
||
668 | 705 | if (empty($attachmentOptions['mime_type']) && $attachmentOptions['width']) |
669 | 706 | { |
670 | 707 | // Got a proper mime type? |
671 | - if (!empty($size['mime'])) |
|
672 | - $attachmentOptions['mime_type'] = $size['mime']; |
|
708 | + if (!empty($size['mime'])) { |
|
709 | + $attachmentOptions['mime_type'] = $size['mime']; |
|
710 | + } |
|
673 | 711 | |
674 | 712 | // Otherwise a valid one? |
675 | - elseif (isset($context['valid_image_types'][$size[2]])) |
|
676 | - $attachmentOptions['mime_type'] = 'image/' . $context['valid_image_types'][$size[2]]; |
|
713 | + elseif (isset($context['valid_image_types'][$size[2]])) { |
|
714 | + $attachmentOptions['mime_type'] = 'image/' . $context['valid_image_types'][$size[2]]; |
|
715 | + } |
|
677 | 716 | } |
678 | 717 | |
679 | 718 | // It is possible we might have a MIME type that isn't actually an image but still have a size. |
@@ -685,15 +724,17 @@ discard block |
||
685 | 724 | } |
686 | 725 | |
687 | 726 | // Get the hash if no hash has been given yet. |
688 | - if (empty($attachmentOptions['file_hash'])) |
|
689 | - $attachmentOptions['file_hash'] = getAttachmentFilename($attachmentOptions['name'], false, null, true); |
|
727 | + if (empty($attachmentOptions['file_hash'])) { |
|
728 | + $attachmentOptions['file_hash'] = getAttachmentFilename($attachmentOptions['name'], false, null, true); |
|
729 | + } |
|
690 | 730 | |
691 | 731 | // Assuming no-one set the extension let's take a look at it. |
692 | 732 | if (empty($attachmentOptions['fileext'])) |
693 | 733 | { |
694 | 734 | $attachmentOptions['fileext'] = strtolower(strrpos($attachmentOptions['name'], '.') !== false ? substr($attachmentOptions['name'], strrpos($attachmentOptions['name'], '.') + 1) : ''); |
695 | - if (strlen($attachmentOptions['fileext']) > 8 || '.' . $attachmentOptions['fileext'] == $attachmentOptions['name']) |
|
696 | - $attachmentOptions['fileext'] = ''; |
|
735 | + if (strlen($attachmentOptions['fileext']) > 8 || '.' . $attachmentOptions['fileext'] == $attachmentOptions['name']) { |
|
736 | + $attachmentOptions['fileext'] = ''; |
|
737 | + } |
|
697 | 738 | } |
698 | 739 | |
699 | 740 | // Last chance to change stuff! |
@@ -702,8 +743,9 @@ discard block |
||
702 | 743 | // Make sure the folder is valid... |
703 | 744 | $tmp = is_array($modSettings['attachmentUploadDir']) ? $modSettings['attachmentUploadDir'] : $smcFunc['json_decode']($modSettings['attachmentUploadDir'], true); |
704 | 745 | $folders = array_keys($tmp); |
705 | - if (empty($attachmentOptions['id_folder']) || !in_array($attachmentOptions['id_folder'], $folders)) |
|
706 | - $attachmentOptions['id_folder'] = $modSettings['currentAttachmentUploadDir']; |
|
746 | + if (empty($attachmentOptions['id_folder']) || !in_array($attachmentOptions['id_folder'], $folders)) { |
|
747 | + $attachmentOptions['id_folder'] = $modSettings['currentAttachmentUploadDir']; |
|
748 | + } |
|
707 | 749 | |
708 | 750 | $attachmentOptions['id'] = $smcFunc['db_insert']('', |
709 | 751 | '{db_prefix}attachments', |
@@ -734,8 +776,8 @@ discard block |
||
734 | 776 | rename($attachmentOptions['tmp_name'], $attachmentOptions['destination']); |
735 | 777 | |
736 | 778 | // If it's not approved then add to the approval queue. |
737 | - if (!$attachmentOptions['approved']) |
|
738 | - $smcFunc['db_insert']('', |
|
779 | + if (!$attachmentOptions['approved']) { |
|
780 | + $smcFunc['db_insert']('', |
|
739 | 781 | '{db_prefix}approval_queue', |
740 | 782 | array( |
741 | 783 | 'id_attach' => 'int', 'id_msg' => 'int', |
@@ -745,9 +787,11 @@ discard block |
||
745 | 787 | ), |
746 | 788 | array() |
747 | 789 | ); |
790 | + } |
|
748 | 791 | |
749 | - if (empty($modSettings['attachmentThumbnails']) || (empty($attachmentOptions['width']) && empty($attachmentOptions['height']))) |
|
750 | - return true; |
|
792 | + if (empty($modSettings['attachmentThumbnails']) || (empty($attachmentOptions['width']) && empty($attachmentOptions['height']))) { |
|
793 | + return true; |
|
794 | + } |
|
751 | 795 | |
752 | 796 | // Like thumbnails, do we? |
753 | 797 | if (!empty($modSettings['attachmentThumbWidth']) && !empty($modSettings['attachmentThumbHeight']) && ($attachmentOptions['width'] > $modSettings['attachmentThumbWidth'] || $attachmentOptions['height'] > $modSettings['attachmentThumbHeight'])) |
@@ -758,13 +802,15 @@ discard block |
||
758 | 802 | $size = @getimagesize($attachmentOptions['destination'] . '_thumb'); |
759 | 803 | list ($thumb_width, $thumb_height) = $size; |
760 | 804 | |
761 | - if (!empty($size['mime'])) |
|
762 | - $thumb_mime = $size['mime']; |
|
763 | - elseif (isset($context['valid_image_types'][$size[2]])) |
|
764 | - $thumb_mime = 'image/' . $context['valid_image_types'][$size[2]]; |
|
805 | + if (!empty($size['mime'])) { |
|
806 | + $thumb_mime = $size['mime']; |
|
807 | + } elseif (isset($context['valid_image_types'][$size[2]])) { |
|
808 | + $thumb_mime = 'image/' . $context['valid_image_types'][$size[2]]; |
|
809 | + } |
|
765 | 810 | // Lord only knows how this happened... |
766 | - else |
|
767 | - $thumb_mime = ''; |
|
811 | + else { |
|
812 | + $thumb_mime = ''; |
|
813 | + } |
|
768 | 814 | |
769 | 815 | $thumb_filename = $attachmentOptions['name'] . '_thumb'; |
770 | 816 | $thumb_size = filesize($attachmentOptions['destination'] . '_thumb'); |
@@ -844,15 +890,17 @@ discard block |
||
844 | 890 | global $smcFunc; |
845 | 891 | |
846 | 892 | // Oh, come on! |
847 | - if (empty($attachIDs) || empty($msgID)) |
|
848 | - return false; |
|
893 | + if (empty($attachIDs) || empty($msgID)) { |
|
894 | + return false; |
|
895 | + } |
|
849 | 896 | |
850 | 897 | // "I see what is right and approve, but I do what is wrong." |
851 | 898 | call_integration_hook('integrate_assign_attachments', array(&$attachIDs, &$msgID)); |
852 | 899 | |
853 | 900 | // One last check |
854 | - if (empty($attachIDs)) |
|
855 | - return false; |
|
901 | + if (empty($attachIDs)) { |
|
902 | + return false; |
|
903 | + } |
|
856 | 904 | |
857 | 905 | // Perform. |
858 | 906 | $smcFunc['db_query']('', ' |
@@ -880,8 +928,9 @@ discard block |
||
880 | 928 | global $board, $modSettings, $context, $scripturl, $smcFunc; |
881 | 929 | |
882 | 930 | // Meh... |
883 | - if (empty($attachID)) |
|
884 | - return 'attachments_no_data_loaded'; |
|
931 | + if (empty($attachID)) { |
|
932 | + return 'attachments_no_data_loaded'; |
|
933 | + } |
|
885 | 934 | |
886 | 935 | // Make it easy. |
887 | 936 | $msgID = !empty($_REQUEST['msg']) ? (int) $_REQUEST['msg'] : 0; |
@@ -890,20 +939,23 @@ discard block |
||
890 | 939 | $externalParse = call_integration_hook('integrate_pre_parseAttachBBC', array($attachID, $msgID)); |
891 | 940 | |
892 | 941 | // "I am innocent of the blood of this just person: see ye to it." |
893 | - if (!empty($externalParse) && (is_string($externalParse) || is_array($externalParse))) |
|
894 | - return $externalParse; |
|
942 | + if (!empty($externalParse) && (is_string($externalParse) || is_array($externalParse))) { |
|
943 | + return $externalParse; |
|
944 | + } |
|
895 | 945 | |
896 | 946 | //Are attachments enable? |
897 | - if (empty($modSettings['attachmentEnable'])) |
|
898 | - return 'attachments_not_enable'; |
|
947 | + if (empty($modSettings['attachmentEnable'])) { |
|
948 | + return 'attachments_not_enable'; |
|
949 | + } |
|
899 | 950 | |
900 | 951 | // Previewing much? no msg ID has been set yet. |
901 | 952 | if (!empty($context['preview_message'])) |
902 | 953 | { |
903 | 954 | $allAttachments = getAttachsByMsg(0); |
904 | 955 | |
905 | - if (empty($allAttachments[0][$attachID])) |
|
906 | - return 'attachments_no_data_loaded'; |
|
956 | + if (empty($allAttachments[0][$attachID])) { |
|
957 | + return 'attachments_no_data_loaded'; |
|
958 | + } |
|
907 | 959 | |
908 | 960 | $attachLoaded = loadAttachmentContext(0, $allAttachments); |
909 | 961 | |
@@ -915,57 +967,66 @@ discard block |
||
915 | 967 | $attachContext['link'] = '<a href="' . $scripturl . '?action=dlattach;attach=' . $attachID . ';type=preview' . (empty($attachContext['is_image']) ? ';file' : '') . '">' . $smcFunc['htmlspecialchars']($attachContext['name']) . '</a>'; |
916 | 968 | |
917 | 969 | // Fix the thumbnail too, if the image has one. |
918 | - if (!empty($attachContext['thumbnail']) && !empty($attachContext['thumbnail']['has_thumb'])) |
|
919 | - $attachContext['thumbnail']['href'] = $scripturl . '?action=dlattach;attach=' . $attachContext['thumbnail']['id'] . ';image;type=preview'; |
|
970 | + if (!empty($attachContext['thumbnail']) && !empty($attachContext['thumbnail']['has_thumb'])) { |
|
971 | + $attachContext['thumbnail']['href'] = $scripturl . '?action=dlattach;attach=' . $attachContext['thumbnail']['id'] . ';image;type=preview'; |
|
972 | + } |
|
920 | 973 | |
921 | 974 | return $attachContext; |
922 | 975 | } |
923 | 976 | |
924 | 977 | // There is always the chance someone else has already done our dirty work... |
925 | 978 | // If so, all pertinent checks were already done. Hopefully... |
926 | - if (!empty($context['current_attachments']) && !empty($context['current_attachments'][$attachID])) |
|
927 | - return $context['current_attachments'][$attachID]; |
|
979 | + if (!empty($context['current_attachments']) && !empty($context['current_attachments'][$attachID])) { |
|
980 | + return $context['current_attachments'][$attachID]; |
|
981 | + } |
|
928 | 982 | |
929 | 983 | // If we are lucky enough to be in $board's scope then check it! |
930 | - if (!empty($board) && !allowedTo('view_attachments', $board)) |
|
931 | - return 'attachments_not_allowed_to_see'; |
|
984 | + if (!empty($board) && !allowedTo('view_attachments', $board)) { |
|
985 | + return 'attachments_not_allowed_to_see'; |
|
986 | + } |
|
932 | 987 | |
933 | 988 | // Get the message info associated with this particular attach ID. |
934 | 989 | $attachInfo = getAttachMsgInfo($attachID); |
935 | 990 | |
936 | 991 | // There is always the chance this attachment no longer exists or isn't associated to a message anymore... |
937 | - if (empty($attachInfo) || empty($attachInfo['msg'])) |
|
938 | - return 'attachments_no_msg_associated'; |
|
992 | + if (empty($attachInfo) || empty($attachInfo['msg'])) { |
|
993 | + return 'attachments_no_msg_associated'; |
|
994 | + } |
|
939 | 995 | |
940 | 996 | // Hold it! got the info now check if you can see this attachment. |
941 | - if (!allowedTo('view_attachments', $attachInfo['board'])) |
|
942 | - return 'attachments_not_allowed_to_see'; |
|
997 | + if (!allowedTo('view_attachments', $attachInfo['board'])) { |
|
998 | + return 'attachments_not_allowed_to_see'; |
|
999 | + } |
|
943 | 1000 | |
944 | 1001 | $allAttachments = getAttachsByMsg($attachInfo['msg']); |
945 | 1002 | $attachContext = $allAttachments[$attachInfo['msg']][$attachID]; |
946 | 1003 | |
947 | 1004 | // No point in keep going further. |
948 | - if (!allowedTo('view_attachments', $attachContext['board'])) |
|
949 | - return 'attachments_not_allowed_to_see'; |
|
1005 | + if (!allowedTo('view_attachments', $attachContext['board'])) { |
|
1006 | + return 'attachments_not_allowed_to_see'; |
|
1007 | + } |
|
950 | 1008 | |
951 | 1009 | // Load this particular attach's context. |
952 | - if (!empty($attachContext)) |
|
953 | - $attachLoaded = loadAttachmentContext($attachContext['id_msg'], $allAttachments); |
|
1010 | + if (!empty($attachContext)) { |
|
1011 | + $attachLoaded = loadAttachmentContext($attachContext['id_msg'], $allAttachments); |
|
1012 | + } |
|
954 | 1013 | |
955 | 1014 | // One last check, you know, gotta be paranoid... |
956 | - else |
|
957 | - return 'attachments_no_data_loaded'; |
|
1015 | + else { |
|
1016 | + return 'attachments_no_data_loaded'; |
|
1017 | + } |
|
958 | 1018 | |
959 | 1019 | // This is the last "if" I promise! |
960 | - if (empty($attachLoaded)) |
|
961 | - return 'attachments_no_data_loaded'; |
|
962 | - |
|
963 | - else |
|
964 | - $attachContext = $attachLoaded[$attachID]; |
|
1020 | + if (empty($attachLoaded)) { |
|
1021 | + return 'attachments_no_data_loaded'; |
|
1022 | + } else { |
|
1023 | + $attachContext = $attachLoaded[$attachID]; |
|
1024 | + } |
|
965 | 1025 | |
966 | 1026 | // You may or may not want to show this under the post. |
967 | - if (!empty($modSettings['dont_show_attach_under_post']) && !isset($context['show_attach_under_post'][$attachID])) |
|
968 | - $context['show_attach_under_post'][$attachID] = $attachID; |
|
1027 | + if (!empty($modSettings['dont_show_attach_under_post']) && !isset($context['show_attach_under_post'][$attachID])) { |
|
1028 | + $context['show_attach_under_post'][$attachID] = $attachID; |
|
1029 | + } |
|
969 | 1030 | |
970 | 1031 | // Last minute changes? |
971 | 1032 | call_integration_hook('integrate_post_parseAttachBBC', array(&$attachContext)); |
@@ -985,8 +1046,9 @@ discard block |
||
985 | 1046 | { |
986 | 1047 | global $smcFunc, $modSettings; |
987 | 1048 | |
988 | - if (empty($attachIDs)) |
|
989 | - return array(); |
|
1049 | + if (empty($attachIDs)) { |
|
1050 | + return array(); |
|
1051 | + } |
|
990 | 1052 | |
991 | 1053 | $return = array(); |
992 | 1054 | |
@@ -1002,11 +1064,12 @@ discard block |
||
1002 | 1064 | ) |
1003 | 1065 | ); |
1004 | 1066 | |
1005 | - if ($smcFunc['db_num_rows']($request) != 1) |
|
1006 | - return array(); |
|
1067 | + if ($smcFunc['db_num_rows']($request) != 1) { |
|
1068 | + return array(); |
|
1069 | + } |
|
1007 | 1070 | |
1008 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1009 | - $return[$row['id_attach']] = array( |
|
1071 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1072 | + $return[$row['id_attach']] = array( |
|
1010 | 1073 | 'name' => $smcFunc['htmlspecialchars']($row['filename']), |
1011 | 1074 | 'size' => $row['size'], |
1012 | 1075 | 'attachID' => $row['id_attach'], |
@@ -1015,6 +1078,7 @@ discard block |
||
1015 | 1078 | 'mime_type' => $row['mime_type'], |
1016 | 1079 | 'thumb' => $row['id_thumb'], |
1017 | 1080 | ); |
1081 | + } |
|
1018 | 1082 | $smcFunc['db_free_result']($request); |
1019 | 1083 | |
1020 | 1084 | return $return; |
@@ -1031,8 +1095,9 @@ discard block |
||
1031 | 1095 | { |
1032 | 1096 | global $smcFunc; |
1033 | 1097 | |
1034 | - if (empty($attachID)) |
|
1035 | - return array(); |
|
1098 | + if (empty($attachID)) { |
|
1099 | + return array(); |
|
1100 | + } |
|
1036 | 1101 | |
1037 | 1102 | $request = $smcFunc['db_query']('', ' |
1038 | 1103 | SELECT a.id_msg AS msg, m.id_topic AS topic, m.id_board AS board |
@@ -1045,8 +1110,9 @@ discard block |
||
1045 | 1110 | ) |
1046 | 1111 | ); |
1047 | 1112 | |
1048 | - if ($smcFunc['db_num_rows']($request) != 1) |
|
1049 | - return array(); |
|
1113 | + if ($smcFunc['db_num_rows']($request) != 1) { |
|
1114 | + return array(); |
|
1115 | + } |
|
1050 | 1116 | |
1051 | 1117 | $row = $smcFunc['db_fetch_assoc']($request); |
1052 | 1118 | $smcFunc['db_free_result']($request); |
@@ -1087,8 +1153,9 @@ discard block |
||
1087 | 1153 | $temp = array(); |
1088 | 1154 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1089 | 1155 | { |
1090 | - if (!$row['approved'] && $modSettings['postmod_active'] && !allowedTo('approve_posts') && (!isset($all_posters[$row['id_msg']]) || $all_posters[$row['id_msg']] != $user_info['id'])) |
|
1091 | - continue; |
|
1156 | + if (!$row['approved'] && $modSettings['postmod_active'] && !allowedTo('approve_posts') && (!isset($all_posters[$row['id_msg']]) || $all_posters[$row['id_msg']] != $user_info['id'])) { |
|
1157 | + continue; |
|
1158 | + } |
|
1092 | 1159 | |
1093 | 1160 | $temp[$row['id_attach']] = $row; |
1094 | 1161 | } |
@@ -1117,8 +1184,9 @@ discard block |
||
1117 | 1184 | { |
1118 | 1185 | global $modSettings, $txt, $scripturl, $sourcedir, $smcFunc; |
1119 | 1186 | |
1120 | - if (empty($attachments) || empty($attachments[$id_msg])) |
|
1121 | - return array(); |
|
1187 | + if (empty($attachments) || empty($attachments[$id_msg])) { |
|
1188 | + return array(); |
|
1189 | + } |
|
1122 | 1190 | |
1123 | 1191 | // Set up the attachment info - based on code by Meriadoc. |
1124 | 1192 | $attachmentData = array(); |
@@ -1142,11 +1210,13 @@ discard block |
||
1142 | 1210 | ); |
1143 | 1211 | |
1144 | 1212 | // If something is unapproved we'll note it so we can sort them. |
1145 | - if (!$attachment['approved']) |
|
1146 | - $have_unapproved = true; |
|
1213 | + if (!$attachment['approved']) { |
|
1214 | + $have_unapproved = true; |
|
1215 | + } |
|
1147 | 1216 | |
1148 | - if (!$attachmentData[$i]['is_image']) |
|
1149 | - continue; |
|
1217 | + if (!$attachmentData[$i]['is_image']) { |
|
1218 | + continue; |
|
1219 | + } |
|
1150 | 1220 | |
1151 | 1221 | $attachmentData[$i]['real_width'] = $attachment['width']; |
1152 | 1222 | $attachmentData[$i]['width'] = $attachment['width']; |
@@ -1167,11 +1237,11 @@ discard block |
||
1167 | 1237 | // So what folder are we putting this image in? |
1168 | 1238 | if (!empty($modSettings['currentAttachmentUploadDir'])) |
1169 | 1239 | { |
1170 | - if (!is_array($modSettings['attachmentUploadDir'])) |
|
1171 | - $modSettings['attachmentUploadDir'] = $smcFunc['json_decode']($modSettings['attachmentUploadDir'], true); |
|
1240 | + if (!is_array($modSettings['attachmentUploadDir'])) { |
|
1241 | + $modSettings['attachmentUploadDir'] = $smcFunc['json_decode']($modSettings['attachmentUploadDir'], true); |
|
1242 | + } |
|
1172 | 1243 | $id_folder_thumb = $modSettings['currentAttachmentUploadDir']; |
1173 | - } |
|
1174 | - else |
|
1244 | + } else |
|
1175 | 1245 | { |
1176 | 1246 | $id_folder_thumb = 1; |
1177 | 1247 | } |
@@ -1185,10 +1255,11 @@ discard block |
||
1185 | 1255 | $thumb_ext = isset($context['valid_image_types'][$size[2]]) ? $context['valid_image_types'][$size[2]] : ''; |
1186 | 1256 | |
1187 | 1257 | // Figure out the mime type. |
1188 | - if (!empty($size['mime'])) |
|
1189 | - $thumb_mime = $size['mime']; |
|
1190 | - else |
|
1191 | - $thumb_mime = 'image/' . $thumb_ext; |
|
1258 | + if (!empty($size['mime'])) { |
|
1259 | + $thumb_mime = $size['mime']; |
|
1260 | + } else { |
|
1261 | + $thumb_mime = 'image/' . $thumb_ext; |
|
1262 | + } |
|
1192 | 1263 | |
1193 | 1264 | $thumb_filename = $attachment['filename'] . '_thumb'; |
1194 | 1265 | $thumb_hash = getAttachmentFilename($thumb_filename, false, null, true); |
@@ -1236,11 +1307,12 @@ discard block |
||
1236 | 1307 | } |
1237 | 1308 | } |
1238 | 1309 | |
1239 | - if (!empty($attachment['id_thumb'])) |
|
1240 | - $attachmentData[$i]['thumbnail'] = array( |
|
1310 | + if (!empty($attachment['id_thumb'])) { |
|
1311 | + $attachmentData[$i]['thumbnail'] = array( |
|
1241 | 1312 | 'id' => $attachment['id_thumb'], |
1242 | 1313 | 'href' => $scripturl . '?action=dlattach;topic=' . $attachment['topic'] . '.0;attach=' . $attachment['id_thumb'] . ';image', |
1243 | 1314 | ); |
1315 | + } |
|
1244 | 1316 | $attachmentData[$i]['thumbnail']['has_thumb'] = !empty($attachment['id_thumb']); |
1245 | 1317 | |
1246 | 1318 | // If thumbnails are disabled, check the maximum size of the image. |
@@ -1250,30 +1322,31 @@ discard block |
||
1250 | 1322 | { |
1251 | 1323 | $attachmentData[$i]['width'] = $modSettings['max_image_width']; |
1252 | 1324 | $attachmentData[$i]['height'] = floor($attachment['height'] * $modSettings['max_image_width'] / $attachment['width']); |
1253 | - } |
|
1254 | - elseif (!empty($modSettings['max_image_width'])) |
|
1325 | + } elseif (!empty($modSettings['max_image_width'])) |
|
1255 | 1326 | { |
1256 | 1327 | $attachmentData[$i]['width'] = floor($attachment['width'] * $modSettings['max_image_height'] / $attachment['height']); |
1257 | 1328 | $attachmentData[$i]['height'] = $modSettings['max_image_height']; |
1258 | 1329 | } |
1259 | - } |
|
1260 | - elseif ($attachmentData[$i]['thumbnail']['has_thumb']) |
|
1330 | + } elseif ($attachmentData[$i]['thumbnail']['has_thumb']) |
|
1261 | 1331 | { |
1262 | 1332 | // If the image is too large to show inline, make it a popup. |
1263 | - if (((!empty($modSettings['max_image_width']) && $attachmentData[$i]['real_width'] > $modSettings['max_image_width']) || (!empty($modSettings['max_image_height']) && $attachmentData[$i]['real_height'] > $modSettings['max_image_height']))) |
|
1264 | - $attachmentData[$i]['thumbnail']['javascript'] = 'return reqWin(\'' . $attachmentData[$i]['href'] . ';image\', ' . ($attachment['width'] + 20) . ', ' . ($attachment['height'] + 20) . ', true);'; |
|
1265 | - else |
|
1266 | - $attachmentData[$i]['thumbnail']['javascript'] = 'return expandThumb(' . $attachment['id_attach'] . ');'; |
|
1333 | + if (((!empty($modSettings['max_image_width']) && $attachmentData[$i]['real_width'] > $modSettings['max_image_width']) || (!empty($modSettings['max_image_height']) && $attachmentData[$i]['real_height'] > $modSettings['max_image_height']))) { |
|
1334 | + $attachmentData[$i]['thumbnail']['javascript'] = 'return reqWin(\'' . $attachmentData[$i]['href'] . ';image\', ' . ($attachment['width'] + 20) . ', ' . ($attachment['height'] + 20) . ', true);'; |
|
1335 | + } else { |
|
1336 | + $attachmentData[$i]['thumbnail']['javascript'] = 'return expandThumb(' . $attachment['id_attach'] . ');'; |
|
1337 | + } |
|
1267 | 1338 | } |
1268 | 1339 | |
1269 | - if (!$attachmentData[$i]['thumbnail']['has_thumb']) |
|
1270 | - $attachmentData[$i]['downloads']++; |
|
1340 | + if (!$attachmentData[$i]['thumbnail']['has_thumb']) { |
|
1341 | + $attachmentData[$i]['downloads']++; |
|
1342 | + } |
|
1271 | 1343 | } |
1272 | 1344 | } |
1273 | 1345 | |
1274 | 1346 | // Do we need to instigate a sort? |
1275 | - if ($have_unapproved) |
|
1276 | - usort($attachmentData, 'approved_attach_sort'); |
|
1347 | + if ($have_unapproved) { |
|
1348 | + usort($attachmentData, 'approved_attach_sort'); |
|
1349 | + } |
|
1277 | 1350 | |
1278 | 1351 | return $attachmentData; |
1279 | 1352 | } |
@@ -21,9 +21,10 @@ discard block |
||
21 | 21 | <div id="admincenter"> |
22 | 22 | <form action="', $scripturl, '?action=admin;area=paidsubscribe;sa=modify;sid=', $context['sub_id'], '" method="post">'; |
23 | 23 | |
24 | - if (!empty($context['disable_groups'])) |
|
25 | - echo ' |
|
24 | + if (!empty($context['disable_groups'])) { |
|
25 | + echo ' |
|
26 | 26 | <div class="noticebox">', $txt['paid_mod_edit_note'], '</div>'; |
27 | + } |
|
27 | 28 | |
28 | 29 | echo ' |
29 | 30 | <div class="cat_bar"> |
@@ -67,9 +68,10 @@ discard block |
||
67 | 68 | <option value="0"', $context['sub']['prim_group'] == 0 ? ' selected' : '', '>', $txt['paid_mod_no_group'], '</option>'; |
68 | 69 | |
69 | 70 | // Put each group into the box. |
70 | - foreach ($context['groups'] as $id => $name) |
|
71 | - echo ' |
|
71 | + foreach ($context['groups'] as $id => $name) { |
|
72 | + echo ' |
|
72 | 73 | <option value="', $id, '"', $context['sub']['prim_group'] == $id ? ' selected' : '', '>', $name, '</option>'; |
74 | + } |
|
73 | 75 | |
74 | 76 | echo ' |
75 | 77 | </select> |
@@ -81,12 +83,13 @@ discard block |
||
81 | 83 | <dd>'; |
82 | 84 | |
83 | 85 | // Put a checkbox in for each group |
84 | - foreach ($context['groups'] as $id => $name) |
|
85 | - echo ' |
|
86 | + foreach ($context['groups'] as $id => $name) { |
|
87 | + echo ' |
|
86 | 88 | <label for="addgroup_', $id, '"> |
87 | 89 | <input type="checkbox" id="addgroup_', $id, '" name="addgroup[', $id, ']"', in_array($id, $context['sub']['add_groups']) ? ' checked' : '', !empty($context['disable_groups']) ? ' disabled' : '', '> |
88 | 90 | <span class="smalltext">', $name, '</span> |
89 | 91 | </label><br>'; |
92 | + } |
|
90 | 93 | |
91 | 94 | echo ' |
92 | 95 | </dd> |
@@ -236,8 +239,8 @@ discard block |
||
236 | 239 | <dl class="settings">'; |
237 | 240 | |
238 | 241 | // Do we need a username? |
239 | - if ($context['action_type'] == 'add') |
|
240 | - echo ' |
|
242 | + if ($context['action_type'] == 'add') { |
|
243 | + echo ' |
|
241 | 244 | <dt> |
242 | 245 | <strong>', $txt['paid_username'], ':</strong><br> |
243 | 246 | <span class="smalltext">', $txt['one_username'], '</span> |
@@ -245,6 +248,7 @@ discard block |
||
245 | 248 | <dd> |
246 | 249 | <input type="text" name="name" id="name_control" value="', $context['sub']['username'], '" size="30"> |
247 | 250 | </dd>'; |
251 | + } |
|
248 | 252 | |
249 | 253 | echo ' |
250 | 254 | <dt> |
@@ -262,9 +266,10 @@ discard block |
||
262 | 266 | <select name="year" id="year" onchange="generateDays();">'; |
263 | 267 | |
264 | 268 | // Show a list of all the years we allow... |
265 | - for ($year = 2005; $year <= 2030; $year++) |
|
266 | - echo ' |
|
269 | + for ($year = 2005; $year <= 2030; $year++) { |
|
270 | + echo ' |
|
267 | 271 | <option value="', $year, '"', $year == $context['sub']['start']['year'] ? ' selected' : '', '>', $year, '</option>'; |
272 | + } |
|
268 | 273 | |
269 | 274 | echo ' |
270 | 275 | </select> |
@@ -272,9 +277,10 @@ discard block |
||
272 | 277 | <select name="month" id="month" onchange="generateDays();">'; |
273 | 278 | |
274 | 279 | // There are 12 months per year - ensure that they all get listed. |
275 | - for ($month = 1; $month <= 12; $month++) |
|
276 | - echo ' |
|
280 | + for ($month = 1; $month <= 12; $month++) { |
|
281 | + echo ' |
|
277 | 282 | <option value="', $month, '"', $month == $context['sub']['start']['month'] ? ' selected' : '', '>', $txt['months'][$month], '</option>'; |
283 | + } |
|
278 | 284 | |
279 | 285 | echo ' |
280 | 286 | </select> |
@@ -282,9 +288,10 @@ discard block |
||
282 | 288 | <select name="day" id="day">'; |
283 | 289 | |
284 | 290 | // This prints out all the days in the current month - this changes dynamically as we switch months. |
285 | - for ($day = 1; $day <= $context['sub']['start']['last_day']; $day++) |
|
286 | - echo ' |
|
291 | + for ($day = 1; $day <= $context['sub']['start']['last_day']; $day++) { |
|
292 | + echo ' |
|
287 | 293 | <option value="', $day, '"', $day == $context['sub']['start']['day'] ? ' selected' : '', '>', $day, '</option>'; |
294 | + } |
|
288 | 295 | |
289 | 296 | echo ' |
290 | 297 | </select> |
@@ -296,9 +303,10 @@ discard block |
||
296 | 303 | <select name="yearend" id="yearend" onchange="generateDays(\'end\');">'; |
297 | 304 | |
298 | 305 | // Show a list of all the years we allow... |
299 | - for ($year = 2005; $year <= 2030; $year++) |
|
300 | - echo ' |
|
306 | + for ($year = 2005; $year <= 2030; $year++) { |
|
307 | + echo ' |
|
301 | 308 | <option value="', $year, '"', $year == $context['sub']['end']['year'] ? ' selected' : '', '>', $year, '</option>'; |
309 | + } |
|
302 | 310 | |
303 | 311 | echo ' |
304 | 312 | </select> |
@@ -306,9 +314,10 @@ discard block |
||
306 | 314 | <select name="monthend" id="monthend" onchange="generateDays(\'end\');">'; |
307 | 315 | |
308 | 316 | // There are 12 months per year - ensure that they all get listed. |
309 | - for ($month = 1; $month <= 12; $month++) |
|
310 | - echo ' |
|
317 | + for ($month = 1; $month <= 12; $month++) { |
|
318 | + echo ' |
|
311 | 319 | <option value="', $month, '"', $month == $context['sub']['end']['month'] ? ' selected' : '', '>', $txt['months'][$month], '</option>'; |
320 | + } |
|
312 | 321 | |
313 | 322 | echo ' |
314 | 323 | </select> |
@@ -316,9 +325,10 @@ discard block |
||
316 | 325 | <select name="dayend" id="dayend">'; |
317 | 326 | |
318 | 327 | // This prints out all the days in the current month - this changes dynamically as we switch months. |
319 | - for ($day = 1; $day <= $context['sub']['end']['last_day']; $day++) |
|
320 | - echo ' |
|
328 | + for ($day = 1; $day <= $context['sub']['end']['last_day']; $day++) { |
|
329 | + echo ' |
|
321 | 330 | <option value="', $day, '"', $day == $context['sub']['end']['day'] ? ' selected' : '', '>', $day, '</option>'; |
331 | + } |
|
322 | 332 | |
323 | 333 | echo ' |
324 | 334 | </select> |
@@ -357,8 +367,8 @@ discard block |
||
357 | 367 | <div class="windowbg"> |
358 | 368 | <ul>'; |
359 | 369 | |
360 | - foreach ($context['pending_payments'] as $id => $payment) |
|
361 | - echo ' |
|
370 | + foreach ($context['pending_payments'] as $id => $payment) { |
|
371 | + echo ' |
|
362 | 372 | <li> |
363 | 373 | ', $payment['desc'], ' |
364 | 374 | <span class="floatleft"> |
@@ -368,6 +378,7 @@ discard block |
||
368 | 378 | <a href="', $scripturl, '?action=admin;area=paidsubscribe;sa=modifyuser;lid=', $context['log_id'], ';pending=', $id, ';remove">', $txt['pending_payments_remove'], '</a> |
369 | 379 | </span> |
370 | 380 | </li>'; |
381 | + } |
|
371 | 382 | |
372 | 383 | echo ' |
373 | 384 | </ul> |
@@ -392,12 +403,12 @@ discard block |
||
392 | 403 | <h3 class="catbg">', $txt['subscriptions'], '</h3> |
393 | 404 | </div>'; |
394 | 405 | |
395 | - if (empty($context['subscriptions'])) |
|
396 | - echo ' |
|
406 | + if (empty($context['subscriptions'])) { |
|
407 | + echo ' |
|
397 | 408 | <div class="information"> |
398 | 409 | ', $txt['paid_subs_none'], ' |
399 | 410 | </div>'; |
400 | - else |
|
411 | + } else |
|
401 | 412 | { |
402 | 413 | echo ' |
403 | 414 | <div class="information"> |
@@ -408,8 +419,9 @@ discard block |
||
408 | 419 | foreach ($context['subscriptions'] as $id => $subscription) |
409 | 420 | { |
410 | 421 | // Ignore the inactive ones... |
411 | - if (empty($subscription['active'])) |
|
412 | - continue; |
|
422 | + if (empty($subscription['active'])) { |
|
423 | + continue; |
|
424 | + } |
|
413 | 425 | |
414 | 426 | echo ' |
415 | 427 | <div class="cat_bar"> |
@@ -419,9 +431,10 @@ discard block |
||
419 | 431 | <p><strong>', $subscription['name'], '</strong></p> |
420 | 432 | <p class="smalltext">', $subscription['desc'], '</p>'; |
421 | 433 | |
422 | - if (!$subscription['flexible']) |
|
423 | - echo ' |
|
434 | + if (!$subscription['flexible']) { |
|
435 | + echo ' |
|
424 | 436 | <div><strong>', $txt['paid_duration'], ':</strong> ', $subscription['length'], '</div>'; |
437 | + } |
|
425 | 438 | |
426 | 439 | if ($context['user']['is_owner']) |
427 | 440 | { |
@@ -434,24 +447,25 @@ discard block |
||
434 | 447 | <select name="cur[', $subscription['id'], ']">'; |
435 | 448 | |
436 | 449 | // Print out the costs for this one. |
437 | - foreach ($subscription['costs'] as $duration => $value) |
|
438 | - echo ' |
|
450 | + foreach ($subscription['costs'] as $duration => $value) { |
|
451 | + echo ' |
|
439 | 452 | <option value="', $duration, '">', sprintf($modSettings['paid_currency_symbol'], $value), '/', $txt[$duration], '</option>'; |
453 | + } |
|
440 | 454 | |
441 | 455 | echo ' |
442 | 456 | </select>'; |
443 | - } |
|
444 | - else |
|
445 | - echo ' |
|
457 | + } else { |
|
458 | + echo ' |
|
446 | 459 | ', sprintf($modSettings['paid_currency_symbol'], $subscription['costs']['fixed']); |
460 | + } |
|
447 | 461 | |
448 | 462 | echo ' |
449 | 463 | <hr> |
450 | 464 | <input type="submit" name="sub_id[', $subscription['id'], ']" value="', $txt['paid_order'], '" class="button">'; |
451 | - } |
|
452 | - else |
|
453 | - echo ' |
|
465 | + } else { |
|
466 | + echo ' |
|
454 | 467 | <a href="', $scripturl, '?action=admin;area=paidsubscribe;sa=modifyuser;sid=', $subscription['id'], ';uid=', $context['member']['id'], (empty($context['current'][$subscription['id']]) ? '' : ';lid=' . $context['current'][$subscription['id']]['id']), '">', empty($context['current'][$subscription['id']]) ? $txt['paid_admin_add'] : $txt['paid_edit_subscription'], '</a>'; |
468 | + } |
|
455 | 469 | |
456 | 470 | echo ' |
457 | 471 | </div><!-- .windowbg -->'; |
@@ -478,18 +492,19 @@ discard block |
||
478 | 492 | </thead> |
479 | 493 | <tbody>'; |
480 | 494 | |
481 | - if (empty($context['current'])) |
|
482 | - echo ' |
|
495 | + if (empty($context['current'])) { |
|
496 | + echo ' |
|
483 | 497 | <tr class="windowbg"> |
484 | 498 | <td colspan="4"> |
485 | 499 | ', $txt['paid_none_yet'], ' |
486 | 500 | </td> |
487 | 501 | </tr>'; |
502 | + } |
|
488 | 503 | |
489 | 504 | foreach ($context['current'] as $sub) |
490 | 505 | { |
491 | - if (!$sub['hide']) |
|
492 | - echo ' |
|
506 | + if (!$sub['hide']) { |
|
507 | + echo ' |
|
493 | 508 | <tr class="windowbg"> |
494 | 509 | <td> |
495 | 510 | ', ($context['user']['is_admin'] ? '<a href="' . $scripturl . '?action=admin;area=paidsubscribe;sa=modifyuser;lid=' . $sub['id'] . '">' . $sub['name'] . '</a>' : $sub['name']), ' |
@@ -500,6 +515,7 @@ discard block |
||
500 | 515 | <td>', $sub['start'], '</td> |
501 | 516 | <td>', $sub['end'], '</td> |
502 | 517 | </tr>'; |
518 | + } |
|
503 | 519 | } |
504 | 520 | |
505 | 521 | echo ' |
@@ -551,15 +567,17 @@ discard block |
||
551 | 567 | ', $gateway['desc'], '<br> |
552 | 568 | <form action="', $gateway['form'], '" method="post">'; |
553 | 569 | |
554 | - if (!empty($gateway['javascript'])) |
|
555 | - echo ' |
|
570 | + if (!empty($gateway['javascript'])) { |
|
571 | + echo ' |
|
556 | 572 | <script> |
557 | 573 | ', $gateway['javascript'], ' |
558 | 574 | </script>'; |
575 | + } |
|
559 | 576 | |
560 | - foreach ($gateway['hidden'] as $name => $value) |
|
561 | - echo ' |
|
577 | + foreach ($gateway['hidden'] as $name => $value) { |
|
578 | + echo ' |
|
562 | 579 | <input type="hidden" id="', $gateway['id'], '_', $name, '" name="', $name, '" value="', $value, '">'; |
580 | + } |
|
563 | 581 | |
564 | 582 | echo ' |
565 | 583 | <br> |
@@ -20,17 +20,19 @@ discard block |
||
20 | 20 | echo ' |
21 | 21 | <form action="', $scripturl, '?action=search2" method="post" accept-charset="', $context['character_set'], '" name="searchform" id="searchform">'; |
22 | 22 | |
23 | - if (!empty($context['search_errors'])) |
|
24 | - echo ' |
|
23 | + if (!empty($context['search_errors'])) { |
|
24 | + echo ' |
|
25 | 25 | <div class="errorbox"> |
26 | 26 | ', implode('<br>', $context['search_errors']['messages']), ' |
27 | 27 | </div>'; |
28 | + } |
|
28 | 29 | |
29 | - if (!empty($context['search_ignored'])) |
|
30 | - echo ' |
|
30 | + if (!empty($context['search_ignored'])) { |
|
31 | + echo ' |
|
31 | 32 | <div class="noticebox"> |
32 | 33 | ', $txt['search_warning_ignored_word' . (count($context['search_ignored']) == 1 ? '' : 's')], ': ', implode(', ', $context['search_ignored']), ' |
33 | 34 | </div>'; |
35 | + } |
|
34 | 36 | |
35 | 37 | echo ' |
36 | 38 | <div class="cat_bar"> |
@@ -48,9 +50,10 @@ discard block |
||
48 | 50 | <dd> |
49 | 51 | <input type="search" name="search" id="searchfor" ', !empty($context['search_params']['search']) ? ' value="' . $context['search_params']['search'] . '"' : '', ' maxlength="', $context['search_string_limit'], '" size="40">'; |
50 | 52 | |
51 | - if (empty($modSettings['search_simple_fulltext'])) |
|
52 | - echo ' |
|
53 | + if (empty($modSettings['search_simple_fulltext'])) { |
|
54 | + echo ' |
|
53 | 55 | <br><em class="smalltext">', $txt['search_example'], '</em>'; |
56 | + } |
|
54 | 57 | |
55 | 58 | echo ' |
56 | 59 | </dd> |
@@ -114,21 +117,23 @@ discard block |
||
114 | 117 | <input type="hidden" name="advanced" value="1">'; |
115 | 118 | |
116 | 119 | // Require an image to be typed to save spamming? |
117 | - if ($context['require_verification']) |
|
118 | - echo ' |
|
120 | + if ($context['require_verification']) { |
|
121 | + echo ' |
|
119 | 122 | <p> |
120 | 123 | <strong>', $txt['verification'], ':</strong> |
121 | 124 | ', template_control_verification($context['visual_verification_id'], 'all'), ' |
122 | 125 | </p>'; |
126 | + } |
|
123 | 127 | |
124 | 128 | // If $context['search_params']['topic'] is set, that means we're searching just one topic. |
125 | - if (!empty($context['search_params']['topic'])) |
|
126 | - echo ' |
|
129 | + if (!empty($context['search_params']['topic'])) { |
|
130 | + echo ' |
|
127 | 131 | <p> |
128 | 132 | ', $txt['search_specific_topic'], ' "', $context['search_topic']['link'], '". |
129 | 133 | </p> |
130 | 134 | <input type="hidden" name="topic" value="', $context['search_topic']['id'], '"> |
131 | 135 | <input type="submit" name="b_search" value="', $txt['search'], '" class="button">'; |
136 | + } |
|
132 | 137 | |
133 | 138 | echo ' |
134 | 139 | </div>'; |
@@ -238,17 +243,19 @@ discard block |
||
238 | 243 | <div class="roundframe">'; |
239 | 244 | |
240 | 245 | // Did they make any typos or mistakes, perhaps? |
241 | - if (isset($context['did_you_mean'])) |
|
242 | - echo ' |
|
246 | + if (isset($context['did_you_mean'])) { |
|
247 | + echo ' |
|
243 | 248 | <p> |
244 | 249 | ', $txt['search_did_you_mean'], ' <a href="', $scripturl, '?action=search2;params=', $context['did_you_mean_params'], '">', $context['did_you_mean'], '</a>. |
245 | 250 | </p>'; |
251 | + } |
|
246 | 252 | |
247 | - if (!empty($context['search_ignored'])) |
|
248 | - echo ' |
|
253 | + if (!empty($context['search_ignored'])) { |
|
254 | + echo ' |
|
249 | 255 | <p> |
250 | 256 | ', $txt['search_warning_ignored_word' . (count($context['search_ignored']) == 1 ? '' : 's')], ': ', implode(', ', $context['search_ignored']), ' |
251 | 257 | </p>'; |
258 | + } |
|
252 | 259 | |
253 | 260 | echo ' |
254 | 261 | <form action="', $scripturl, '?action=search2" method="post" accept-charset="', $context['character_set'], '"> |
@@ -271,10 +278,11 @@ discard block |
||
271 | 278 | <input type="hidden" name="sort" value="', !empty($context['search_params']['sort']) ? $context['search_params']['sort'] : 'relevance', '"> |
272 | 279 | </div>'; |
273 | 280 | |
274 | - if (!empty($context['search_params']['brd'])) |
|
275 | - foreach ($context['search_params']['brd'] as $board_id) |
|
281 | + if (!empty($context['search_params']['brd'])) { |
|
282 | + foreach ($context['search_params']['brd'] as $board_id) |
|
276 | 283 | echo ' |
277 | 284 | <input type="hidden" name="brd[', $board_id, ']" value="', $board_id, '">'; |
285 | + } |
|
278 | 286 | |
279 | 287 | echo ' |
280 | 288 | </form> |
@@ -285,18 +293,20 @@ discard block |
||
285 | 293 | if ($context['compact']) |
286 | 294 | { |
287 | 295 | // Quick moderation set to checkboxes? Oh, how fun :/ |
288 | - if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1) |
|
289 | - echo ' |
|
296 | + if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1) { |
|
297 | + echo ' |
|
290 | 298 | <form action="', $scripturl, '?action=quickmod" method="post" accept-charset="', $context['character_set'], '" name="topicForm">'; |
299 | + } |
|
291 | 300 | |
292 | 301 | echo ' |
293 | 302 | <div class="cat_bar"> |
294 | 303 | <h3 class="catbg"> |
295 | 304 | <span class="floatright">'; |
296 | 305 | |
297 | - if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1) |
|
298 | - echo ' |
|
306 | + if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1) { |
|
307 | + echo ' |
|
299 | 308 | <input type="checkbox" onclick="invertAll(this, this.form, \'topics[]\');">'; |
309 | + } |
|
300 | 310 | echo ' |
301 | 311 | </span> |
302 | 312 | <span class="generic_icons filter"></span> ', $txt['mlist_search_results'], ': ', $context['search_params']['search'], ' |
@@ -304,15 +314,15 @@ discard block |
||
304 | 314 | </div>'; |
305 | 315 | |
306 | 316 | // Was anything even found? |
307 | - if (!empty($context['topics'])) |
|
308 | - echo ' |
|
317 | + if (!empty($context['topics'])) { |
|
318 | + echo ' |
|
309 | 319 | <div class="pagesection"> |
310 | 320 | <span>', $context['page_index'], '</span> |
311 | 321 | </div>'; |
312 | - |
|
313 | - else |
|
314 | - echo ' |
|
322 | + } else { |
|
323 | + echo ' |
|
315 | 324 | <div class="roundframe noup">', $txt['find_no_results'], '</div>'; |
325 | + } |
|
316 | 326 | |
317 | 327 | // While we have results to show ... |
318 | 328 | while ($topic = $context['get_topics']()) |
@@ -335,31 +345,35 @@ discard block |
||
335 | 345 | echo ' |
336 | 346 | <span class="floatright">'; |
337 | 347 | |
338 | - if ($options['display_quick_mod'] == 1) |
|
339 | - echo ' |
|
348 | + if ($options['display_quick_mod'] == 1) { |
|
349 | + echo ' |
|
340 | 350 | <input type="checkbox" name="topics[]" value="', $topic['id'], '">'; |
341 | - |
|
342 | - else |
|
351 | + } else |
|
343 | 352 | { |
344 | - if ($topic['quick_mod']['remove']) |
|
345 | - echo ' |
|
353 | + if ($topic['quick_mod']['remove']) { |
|
354 | + echo ' |
|
346 | 355 | <a href="', $scripturl, '?action=quickmod;board=' . $topic['board']['id'] . '.0;actions%5B', $topic['id'], '%5D=remove;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons delete" title="', $txt['remove_topic'], '"></span></a>'; |
356 | + } |
|
347 | 357 | |
348 | - if ($topic['quick_mod']['lock']) |
|
349 | - echo ' |
|
358 | + if ($topic['quick_mod']['lock']) { |
|
359 | + echo ' |
|
350 | 360 | <a href="', $scripturl, '?action=quickmod;board=' . $topic['board']['id'] . '.0;actions%5B', $topic['id'], '%5D=lock;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons lock" title="', $topic['is_locked'] ? $txt['set_unlock'] : $txt['set_lock'], '"></span></a>'; |
361 | + } |
|
351 | 362 | |
352 | - if ($topic['quick_mod']['lock'] || $topic['quick_mod']['remove']) |
|
353 | - echo ' |
|
363 | + if ($topic['quick_mod']['lock'] || $topic['quick_mod']['remove']) { |
|
364 | + echo ' |
|
354 | 365 | <br>'; |
366 | + } |
|
355 | 367 | |
356 | - if ($topic['quick_mod']['sticky']) |
|
357 | - echo ' |
|
368 | + if ($topic['quick_mod']['sticky']) { |
|
369 | + echo ' |
|
358 | 370 | <a href="', $scripturl, '?action=quickmod;board=' . $topic['board']['id'] . '.0;actions%5B', $topic['id'], '%5D=sticky;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons sticky" title="', $topic['is_sticky'] ? $txt['set_nonsticky'] : $txt['set_sticky'], '"></span></a>'; |
371 | + } |
|
359 | 372 | |
360 | - if ($topic['quick_mod']['move']) |
|
361 | - echo ' |
|
373 | + if ($topic['quick_mod']['move']) { |
|
374 | + echo ' |
|
362 | 375 | <a href="', $scripturl, '?action=movetopic;topic=', $topic['id'], '.0"><span class="generic_icons move" title="', $txt['move_topic'], '"></span></a>'; |
376 | + } |
|
363 | 377 | } |
364 | 378 | |
365 | 379 | echo ' |
@@ -369,20 +383,22 @@ discard block |
||
369 | 383 | echo ' |
370 | 384 | </div><!-- .block -->'; |
371 | 385 | |
372 | - if ($message['body_highlighted'] != '') |
|
373 | - echo ' |
|
386 | + if ($message['body_highlighted'] != '') { |
|
387 | + echo ' |
|
374 | 388 | <div class="list_posts double_height">', $message['body_highlighted'], '</div>'; |
389 | + } |
|
375 | 390 | } |
376 | 391 | |
377 | 392 | echo ' |
378 | 393 | </div><!-- $topic[css_class] -->'; |
379 | 394 | } |
380 | 395 | |
381 | - if (!empty($context['topics'])) |
|
382 | - echo ' |
|
396 | + if (!empty($context['topics'])) { |
|
397 | + echo ' |
|
383 | 398 | <div class="pagesection"> |
384 | 399 | <span>', $context['page_index'], '</span> |
385 | 400 | </div>'; |
401 | + } |
|
386 | 402 | |
387 | 403 | if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics'])) |
388 | 404 | { |
@@ -391,17 +407,19 @@ discard block |
||
391 | 407 | <select class="qaction" name="qaction"', $context['can_move'] ? ' onchange="this.form.move_to.disabled = (this.options[this.selectedIndex].value != \'move\');"' : '', '> |
392 | 408 | <option value="">--------</option>'; |
393 | 409 | |
394 | - foreach ($context['qmod_actions'] as $qmod_action) |
|
395 | - if ($context['can_' . $qmod_action]) |
|
410 | + foreach ($context['qmod_actions'] as $qmod_action) { |
|
411 | + if ($context['can_' . $qmod_action]) |
|
396 | 412 | echo ' |
397 | 413 | <option value="' . $qmod_action . '">' . $txt['quick_mod_' . $qmod_action] . '</option>'; |
414 | + } |
|
398 | 415 | |
399 | 416 | echo ' |
400 | 417 | </select>'; |
401 | 418 | |
402 | - if ($context['can_move']) |
|
403 | - echo ' |
|
419 | + if ($context['can_move']) { |
|
420 | + echo ' |
|
404 | 421 | <span id="quick_mod_jump_to"></span>'; |
422 | + } |
|
405 | 423 | |
406 | 424 | echo ' |
407 | 425 | <input type="hidden" name="redirect_url" value="', $scripturl . '?action=search2;params=' . $context['params'], '"> |
@@ -410,12 +428,12 @@ discard block |
||
410 | 428 | } |
411 | 429 | |
412 | 430 | |
413 | - if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics'])) |
|
414 | - echo ' |
|
431 | + if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics'])) { |
|
432 | + echo ' |
|
415 | 433 | <input type="hidden" name="' . $context['session_var'] . '" value="' . $context['session_id'] . '"> |
416 | 434 | </form>'; |
417 | - } |
|
418 | - else |
|
435 | + } |
|
436 | + } else |
|
419 | 437 | { |
420 | 438 | echo ' |
421 | 439 | <div class="cat_bar"> |
@@ -427,9 +445,10 @@ discard block |
||
427 | 445 | <span>', $context['page_index'], '</span> |
428 | 446 | </div>'; |
429 | 447 | |
430 | - if (empty($context['topics'])) |
|
431 | - echo ' |
|
448 | + if (empty($context['topics'])) { |
|
449 | + echo ' |
|
432 | 450 | <div class="information">(', $txt['search_no_results'], ')</div>'; |
451 | + } |
|
433 | 452 | |
434 | 453 | while ($topic = $context['get_topics']()) |
435 | 454 | { |
@@ -464,8 +483,8 @@ discard block |
||
464 | 483 | <div class="smalltext righttext" id="search_jump_to"></div> |
465 | 484 | <script>'; |
466 | 485 | |
467 | - if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics']) && $context['can_move']) |
|
468 | - echo ' |
|
486 | + if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics']) && $context['can_move']) { |
|
487 | + echo ' |
|
469 | 488 | if (typeof(window.XMLHttpRequest) != "undefined") |
470 | 489 | aJumpTo[aJumpTo.length] = new JumpTo({ |
471 | 490 | sContainerId: "quick_mod_jump_to", |
@@ -480,6 +499,7 @@ discard block |
||
480 | 499 | bDisabled: true, |
481 | 500 | sCustomName: "move_to" |
482 | 501 | });'; |
502 | + } |
|
483 | 503 | |
484 | 504 | echo ' |
485 | 505 | if (typeof(window.XMLHttpRequest) != "undefined") |
@@ -14,8 +14,9 @@ discard block |
||
14 | 14 | * @version 2.1 Beta 4 |
15 | 15 | */ |
16 | 16 | |
17 | -if (!defined('SMF')) |
|
17 | +if (!defined('SMF')) { |
|
18 | 18 | die('No direct access...'); |
19 | +} |
|
19 | 20 | |
20 | 21 | /** |
21 | 22 | * !!!Compatibility!!! |
@@ -31,8 +32,9 @@ discard block |
||
31 | 32 | { |
32 | 33 | global $modSettings; |
33 | 34 | |
34 | - if (!$compat_mode) |
|
35 | - return $text; |
|
35 | + if (!$compat_mode) { |
|
36 | + return $text; |
|
37 | + } |
|
36 | 38 | |
37 | 39 | // Turn line breaks back into br's. |
38 | 40 | $text = strtr($text, array("\r" => '', "\n" => '<br>')); |
@@ -49,8 +51,9 @@ discard block |
||
49 | 51 | for ($i = 0, $n = count($parts); $i < $n; $i++) |
50 | 52 | { |
51 | 53 | // Value of 2 means we're inside the tag. |
52 | - if ($i % 4 == 2) |
|
53 | - $parts[$i] = strtr($parts[$i], array('[' => '[', ']' => ']', "'" => "'")); |
|
54 | + if ($i % 4 == 2) { |
|
55 | + $parts[$i] = strtr($parts[$i], array('[' => '[', ']' => ']', "'" => "'")); |
|
56 | + } |
|
54 | 57 | } |
55 | 58 | // Put our humpty dumpty message back together again. |
56 | 59 | $text = implode('', $parts); |
@@ -109,8 +112,9 @@ discard block |
||
109 | 112 | $text = preg_replace('~</p>\s*(?!<)~i', '</p><br>', $text); |
110 | 113 | |
111 | 114 | // Safari/webkit wraps lines in Wysiwyg in <div>'s. |
112 | - if (isBrowser('webkit')) |
|
113 | - $text = preg_replace(array('~<div(?:\s(?:[^<>]*?))?' . '>~i', '</div>'), array('<br>', ''), $text); |
|
115 | + if (isBrowser('webkit')) { |
|
116 | + $text = preg_replace(array('~<div(?:\s(?:[^<>]*?))?' . '>~i', '</div>'), array('<br>', ''), $text); |
|
117 | + } |
|
114 | 118 | |
115 | 119 | // If there's a trailing break get rid of it - Firefox tends to add one. |
116 | 120 | $text = preg_replace('~<br\s?/?' . '>$~i', '', $text); |
@@ -125,8 +129,9 @@ discard block |
||
125 | 129 | for ($i = 0, $n = count($parts); $i < $n; $i++) |
126 | 130 | { |
127 | 131 | // Value of 2 means we're inside the tag. |
128 | - if ($i % 4 == 2) |
|
129 | - $parts[$i] = strip_tags($parts[$i]); |
|
132 | + if ($i % 4 == 2) { |
|
133 | + $parts[$i] = strip_tags($parts[$i]); |
|
134 | + } |
|
130 | 135 | } |
131 | 136 | |
132 | 137 | $text = strtr(implode('', $parts), array('#smf_br_spec_grudge_cool!#' => '<br>')); |
@@ -152,18 +157,19 @@ discard block |
||
152 | 157 | { |
153 | 158 | $found = array_search($file, $smileysto); |
154 | 159 | // Note the weirdness here is to stop double spaces between smileys. |
155 | - if ($found) |
|
156 | - $matches[1][$k] = '-[]-smf_smily_start#|#' . $smcFunc['htmlspecialchars']($smileysfrom[$found]) . '-[]-smf_smily_end#|#'; |
|
157 | - else |
|
158 | - $matches[1][$k] = ''; |
|
160 | + if ($found) { |
|
161 | + $matches[1][$k] = '-[]-smf_smily_start#|#' . $smcFunc['htmlspecialchars']($smileysfrom[$found]) . '-[]-smf_smily_end#|#'; |
|
162 | + } else { |
|
163 | + $matches[1][$k] = ''; |
|
164 | + } |
|
159 | 165 | } |
160 | - } |
|
161 | - else |
|
166 | + } else |
|
162 | 167 | { |
163 | 168 | // Load all the smileys. |
164 | 169 | $names = array(); |
165 | - foreach ($matches[1] as $file) |
|
166 | - $names[] = $file; |
|
170 | + foreach ($matches[1] as $file) { |
|
171 | + $names[] = $file; |
|
172 | + } |
|
167 | 173 | $names = array_unique($names); |
168 | 174 | |
169 | 175 | if (!empty($names)) |
@@ -177,13 +183,15 @@ discard block |
||
177 | 183 | ) |
178 | 184 | ); |
179 | 185 | $mappings = array(); |
180 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
181 | - $mappings[$row['filename']] = $smcFunc['htmlspecialchars']($row['code']); |
|
186 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
187 | + $mappings[$row['filename']] = $smcFunc['htmlspecialchars']($row['code']); |
|
188 | + } |
|
182 | 189 | $smcFunc['db_free_result']($request); |
183 | 190 | |
184 | - foreach ($matches[1] as $k => $file) |
|
185 | - if (isset($mappings[$file])) |
|
191 | + foreach ($matches[1] as $k => $file) { |
|
192 | + if (isset($mappings[$file])) |
|
186 | 193 | $matches[1][$k] = '-[]-smf_smily_start#|#' . $mappings[$file] . '-[]-smf_smily_end#|#'; |
194 | + } |
|
187 | 195 | } |
188 | 196 | } |
189 | 197 | |
@@ -195,8 +203,9 @@ discard block |
||
195 | 203 | } |
196 | 204 | |
197 | 205 | // Only try to buy more time if the client didn't quit. |
198 | - if (connection_aborted() && $context['server']['is_apache']) |
|
199 | - @apache_reset_timeout(); |
|
206 | + if (connection_aborted() && $context['server']['is_apache']) { |
|
207 | + @apache_reset_timeout(); |
|
208 | + } |
|
200 | 209 | |
201 | 210 | $parts = preg_split('~(<[A-Za-z]+\s*[^<>]*?style="?[^<>"]+"?[^<>]*?(?:/?)>|</[A-Za-z]+>)~', $text, -1, PREG_SPLIT_DELIM_CAPTURE); |
202 | 211 | $replacement = ''; |
@@ -207,9 +216,9 @@ discard block |
||
207 | 216 | if (preg_match('~(<([A-Za-z]+)\s*[^<>]*?)style="?([^<>"]+)"?([^<>]*?(/?)>)~', $part, $matches) === 1) |
208 | 217 | { |
209 | 218 | // If it's being closed instantly, we can't deal with it...yet. |
210 | - if ($matches[5] === '/') |
|
211 | - continue; |
|
212 | - else |
|
219 | + if ($matches[5] === '/') { |
|
220 | + continue; |
|
221 | + } else |
|
213 | 222 | { |
214 | 223 | // Get an array of styles that apply to this element. (The strtr is there to combat HTML generated by Word.) |
215 | 224 | $styles = explode(';', strtr($matches[3], array('"' => ''))); |
@@ -225,8 +234,9 @@ discard block |
||
225 | 234 | $clean_type_value_pair = strtolower(strtr(trim($type_value_pair), '=', ':')); |
226 | 235 | |
227 | 236 | // Something like 'font-weight: bold' is expected here. |
228 | - if (strpos($clean_type_value_pair, ':') === false) |
|
229 | - continue; |
|
237 | + if (strpos($clean_type_value_pair, ':') === false) { |
|
238 | + continue; |
|
239 | + } |
|
230 | 240 | |
231 | 241 | // Capture the elements of a single style item (e.g. 'font-weight' and 'bold'). |
232 | 242 | list ($style_type, $style_value) = explode(':', $type_value_pair); |
@@ -248,8 +258,7 @@ discard block |
||
248 | 258 | { |
249 | 259 | $curCloseTags .= '[/u]'; |
250 | 260 | $replacement .= '[u]'; |
251 | - } |
|
252 | - elseif ($style_value == 'line-through') |
|
261 | + } elseif ($style_value == 'line-through') |
|
253 | 262 | { |
254 | 263 | $curCloseTags .= '[/s]'; |
255 | 264 | $replacement .= '[s]'; |
@@ -261,13 +270,11 @@ discard block |
||
261 | 270 | { |
262 | 271 | $curCloseTags .= '[/left]'; |
263 | 272 | $replacement .= '[left]'; |
264 | - } |
|
265 | - elseif ($style_value == 'center') |
|
273 | + } elseif ($style_value == 'center') |
|
266 | 274 | { |
267 | 275 | $curCloseTags .= '[/center]'; |
268 | 276 | $replacement .= '[center]'; |
269 | - } |
|
270 | - elseif ($style_value == 'right') |
|
277 | + } elseif ($style_value == 'right') |
|
271 | 278 | { |
272 | 279 | $curCloseTags .= '[/right]'; |
273 | 280 | $replacement .= '[right]'; |
@@ -289,8 +296,9 @@ discard block |
||
289 | 296 | |
290 | 297 | case 'font-size': |
291 | 298 | // Sometimes people put decimals where decimals should not be. |
292 | - if (preg_match('~(\d)+\.\d+(p[xt])~i', $style_value, $dec_matches) === 1) |
|
293 | - $style_value = $dec_matches[1] . $dec_matches[2]; |
|
299 | + if (preg_match('~(\d)+\.\d+(p[xt])~i', $style_value, $dec_matches) === 1) { |
|
300 | + $style_value = $dec_matches[1] . $dec_matches[2]; |
|
301 | + } |
|
294 | 302 | |
295 | 303 | $curCloseTags .= '[/size]'; |
296 | 304 | $replacement .= '[size=' . $style_value . ']'; |
@@ -298,8 +306,9 @@ discard block |
||
298 | 306 | |
299 | 307 | case 'font-family': |
300 | 308 | // Only get the first freaking font if there's a list! |
301 | - if (strpos($style_value, ',') !== false) |
|
302 | - $style_value = substr($style_value, 0, strpos($style_value, ',')); |
|
309 | + if (strpos($style_value, ',') !== false) { |
|
310 | + $style_value = substr($style_value, 0, strpos($style_value, ',')); |
|
311 | + } |
|
303 | 312 | |
304 | 313 | $curCloseTags .= '[/font]'; |
305 | 314 | $replacement .= '[font=' . strtr($style_value, array("'" => '')) . ']'; |
@@ -308,13 +317,15 @@ discard block |
||
308 | 317 | // This is a hack for images with dimensions embedded. |
309 | 318 | case 'width': |
310 | 319 | case 'height': |
311 | - if (preg_match('~[1-9]\d*~i', $style_value, $dimension) === 1) |
|
312 | - $extra_attr .= ' ' . $style_type . '="' . $dimension[0] . '"'; |
|
320 | + if (preg_match('~[1-9]\d*~i', $style_value, $dimension) === 1) { |
|
321 | + $extra_attr .= ' ' . $style_type . '="' . $dimension[0] . '"'; |
|
322 | + } |
|
313 | 323 | break; |
314 | 324 | |
315 | 325 | case 'list-style-type': |
316 | - if (preg_match('~none|disc|circle|square|decimal|decimal-leading-zero|lower-roman|upper-roman|lower-alpha|upper-alpha|lower-greek|lower-latin|upper-latin|hebrew|armenian|georgian|cjk-ideographic|hiragana|katakana|hiragana-iroha|katakana-iroha~i', $style_value, $listType) === 1) |
|
317 | - $extra_attr .= ' listtype="' . $listType[0] . '"'; |
|
326 | + if (preg_match('~none|disc|circle|square|decimal|decimal-leading-zero|lower-roman|upper-roman|lower-alpha|upper-alpha|lower-greek|lower-latin|upper-latin|hebrew|armenian|georgian|cjk-ideographic|hiragana|katakana|hiragana-iroha|katakana-iroha~i', $style_value, $listType) === 1) { |
|
327 | + $extra_attr .= ' listtype="' . $listType[0] . '"'; |
|
328 | + } |
|
318 | 329 | break; |
319 | 330 | } |
320 | 331 | } |
@@ -327,18 +338,17 @@ discard block |
||
327 | 338 | } |
328 | 339 | |
329 | 340 | // If there's something that still needs closing, push it to the stack. |
330 | - if (!empty($curCloseTags)) |
|
331 | - array_push($stack, array( |
|
341 | + if (!empty($curCloseTags)) { |
|
342 | + array_push($stack, array( |
|
332 | 343 | 'element' => strtolower($curElement), |
333 | 344 | 'closeTags' => $curCloseTags |
334 | 345 | ) |
335 | 346 | ); |
336 | - elseif (!empty($extra_attr)) |
|
337 | - $replacement .= $precedingStyle . $extra_attr . $afterStyle; |
|
347 | + } elseif (!empty($extra_attr)) { |
|
348 | + $replacement .= $precedingStyle . $extra_attr . $afterStyle; |
|
349 | + } |
|
338 | 350 | } |
339 | - } |
|
340 | - |
|
341 | - elseif (preg_match('~</([A-Za-z]+)>~', $part, $matches) === 1) |
|
351 | + } elseif (preg_match('~</([A-Za-z]+)>~', $part, $matches) === 1) |
|
342 | 352 | { |
343 | 353 | // Is this the element that we've been waiting for to be closed? |
344 | 354 | if (!empty($stack) && strtolower($matches[1]) === $stack[count($stack) - 1]['element']) |
@@ -348,28 +358,32 @@ discard block |
||
348 | 358 | } |
349 | 359 | |
350 | 360 | // Must've been something else. |
351 | - else |
|
352 | - $replacement .= $part; |
|
361 | + else { |
|
362 | + $replacement .= $part; |
|
363 | + } |
|
353 | 364 | } |
354 | 365 | // In all other cases, just add the part to the replacement. |
355 | - else |
|
356 | - $replacement .= $part; |
|
366 | + else { |
|
367 | + $replacement .= $part; |
|
368 | + } |
|
357 | 369 | } |
358 | 370 | |
359 | 371 | // Now put back the replacement in the text. |
360 | 372 | $text = $replacement; |
361 | 373 | |
362 | 374 | // We are not finished yet, request more time. |
363 | - if (connection_aborted() && $context['server']['is_apache']) |
|
364 | - @apache_reset_timeout(); |
|
375 | + if (connection_aborted() && $context['server']['is_apache']) { |
|
376 | + @apache_reset_timeout(); |
|
377 | + } |
|
365 | 378 | |
366 | 379 | // Let's pull out any legacy alignments. |
367 | 380 | while (preg_match('~<([A-Za-z]+)\s+[^<>]*?(align="*(left|center|right)"*)[^<>]*?(/?)>~i', $text, $matches) === 1) |
368 | 381 | { |
369 | 382 | // Find the position in the text of this tag over again. |
370 | 383 | $start_pos = strpos($text, $matches[0]); |
371 | - if ($start_pos === false) |
|
372 | - break; |
|
384 | + if ($start_pos === false) { |
|
385 | + break; |
|
386 | + } |
|
373 | 387 | |
374 | 388 | // End tag? |
375 | 389 | if ($matches[4] != '/' && strpos($text, '</' . $matches[1] . '>', $start_pos) !== false) |
@@ -383,8 +397,7 @@ discard block |
||
383 | 397 | |
384 | 398 | // Put the tags back into the body. |
385 | 399 | $text = substr($text, 0, $start_pos) . $tag . '[' . $matches[3] . ']' . $content . '[/' . $matches[3] . ']' . substr($text, $end_pos); |
386 | - } |
|
387 | - else |
|
400 | + } else |
|
388 | 401 | { |
389 | 402 | // Just get rid of this evil tag. |
390 | 403 | $text = substr($text, 0, $start_pos) . substr($text, $start_pos + strlen($matches[0])); |
@@ -397,8 +410,9 @@ discard block |
||
397 | 410 | // Find the position of this again. |
398 | 411 | $start_pos = strpos($text, $matches[0]); |
399 | 412 | $end_pos = false; |
400 | - if ($start_pos === false) |
|
401 | - break; |
|
413 | + if ($start_pos === false) { |
|
414 | + break; |
|
415 | + } |
|
402 | 416 | |
403 | 417 | // This must have an end tag - and we must find the right one. |
404 | 418 | $lower_text = strtolower($text); |
@@ -431,8 +445,9 @@ discard block |
||
431 | 445 | break; |
432 | 446 | } |
433 | 447 | } |
434 | - if ($end_pos === false) |
|
435 | - break; |
|
448 | + if ($end_pos === false) { |
|
449 | + break; |
|
450 | + } |
|
436 | 451 | |
437 | 452 | // Now work out what the attributes are. |
438 | 453 | $attribs = fetchTagAttributes($matches[1]); |
@@ -446,11 +461,11 @@ discard block |
||
446 | 461 | $v = (int) trim($v); |
447 | 462 | $v = empty($v) ? 1 : $v; |
448 | 463 | $tags[] = array('[size=' . $sizes_equivalence[$v] . ']', '[/size]'); |
464 | + } elseif ($s == 'face') { |
|
465 | + $tags[] = array('[font=' . trim(strtolower($v)) . ']', '[/font]'); |
|
466 | + } elseif ($s == 'color') { |
|
467 | + $tags[] = array('[color=' . trim(strtolower($v)) . ']', '[/color]'); |
|
449 | 468 | } |
450 | - elseif ($s == 'face') |
|
451 | - $tags[] = array('[font=' . trim(strtolower($v)) . ']', '[/font]'); |
|
452 | - elseif ($s == 'color') |
|
453 | - $tags[] = array('[color=' . trim(strtolower($v)) . ']', '[/color]'); |
|
454 | 469 | } |
455 | 470 | |
456 | 471 | // As before add in our tags. |
@@ -458,8 +473,9 @@ discard block |
||
458 | 473 | foreach ($tags as $tag) |
459 | 474 | { |
460 | 475 | $before .= $tag[0]; |
461 | - if (isset($tag[1])) |
|
462 | - $after = $tag[1] . $after; |
|
476 | + if (isset($tag[1])) { |
|
477 | + $after = $tag[1] . $after; |
|
478 | + } |
|
463 | 479 | } |
464 | 480 | |
465 | 481 | // Remove the tag so it's never checked again. |
@@ -470,8 +486,9 @@ discard block |
||
470 | 486 | } |
471 | 487 | |
472 | 488 | // Almost there, just a little more time. |
473 | - if (connection_aborted() && $context['server']['is_apache']) |
|
474 | - @apache_reset_timeout(); |
|
489 | + if (connection_aborted() && $context['server']['is_apache']) { |
|
490 | + @apache_reset_timeout(); |
|
491 | + } |
|
475 | 492 | |
476 | 493 | if (count($parts = preg_split('~<(/?)(li|ol|ul)([^>]*)>~i', $text, null, PREG_SPLIT_DELIM_CAPTURE)) > 1) |
477 | 494 | { |
@@ -527,12 +544,13 @@ discard block |
||
527 | 544 | { |
528 | 545 | $inList = true; |
529 | 546 | |
530 | - if ($tag === 'ol') |
|
531 | - $listType = 'decimal'; |
|
532 | - elseif (preg_match('~type="?(' . implode('|', array_keys($listTypeMapping)) . ')"?~', $parts[$i + 3], $match) === 1) |
|
533 | - $listType = $listTypeMapping[$match[1]]; |
|
534 | - else |
|
535 | - $listType = null; |
|
547 | + if ($tag === 'ol') { |
|
548 | + $listType = 'decimal'; |
|
549 | + } elseif (preg_match('~type="?(' . implode('|', array_keys($listTypeMapping)) . ')"?~', $parts[$i + 3], $match) === 1) { |
|
550 | + $listType = $listTypeMapping[$match[1]]; |
|
551 | + } else { |
|
552 | + $listType = null; |
|
553 | + } |
|
536 | 554 | |
537 | 555 | $listDepth++; |
538 | 556 | |
@@ -596,9 +614,7 @@ discard block |
||
596 | 614 | $parts[$i + 1] = ''; |
597 | 615 | $parts[$i + 2] = str_repeat("\t", $listDepth) . '[/list]'; |
598 | 616 | $parts[$i + 3] = ''; |
599 | - } |
|
600 | - |
|
601 | - else |
|
617 | + } else |
|
602 | 618 | { |
603 | 619 | // We're in a list item. |
604 | 620 | if ($listDepth > 0) |
@@ -635,9 +651,7 @@ discard block |
||
635 | 651 | $parts[$i + 1] = ''; |
636 | 652 | $parts[$i + 2] = ''; |
637 | 653 | $parts[$i + 3] = ''; |
638 | - } |
|
639 | - |
|
640 | - else |
|
654 | + } else |
|
641 | 655 | { |
642 | 656 | // Remove the trailing breaks from the list item. |
643 | 657 | $parts[$i] = preg_replace('~\s*<br\s*' . '/?' . '>\s*$~', '', $parts[$i]); |
@@ -675,8 +689,9 @@ discard block |
||
675 | 689 | $text .= str_repeat("\t", $listDepth) . '[/list]'; |
676 | 690 | } |
677 | 691 | |
678 | - for ($i = $listDepth; $i > 0; $i--) |
|
679 | - $text .= '[/li]' . "\n" . str_repeat("\t", $i - 1) . '[/list]'; |
|
692 | + for ($i = $listDepth; $i > 0; $i--) { |
|
693 | + $text .= '[/li]' . "\n" . str_repeat("\t", $i - 1) . '[/list]'; |
|
694 | + } |
|
680 | 695 | } |
681 | 696 | |
682 | 697 | // I love my own image... |
@@ -684,8 +699,9 @@ discard block |
||
684 | 699 | { |
685 | 700 | // Find the position of the image. |
686 | 701 | $start_pos = strpos($text, $matches[0]); |
687 | - if ($start_pos === false) |
|
688 | - break; |
|
702 | + if ($start_pos === false) { |
|
703 | + break; |
|
704 | + } |
|
689 | 705 | $end_pos = $start_pos + strlen($matches[0]); |
690 | 706 | |
691 | 707 | $params = ''; |
@@ -694,12 +710,13 @@ discard block |
||
694 | 710 | $attrs = fetchTagAttributes($matches[1]); |
695 | 711 | foreach ($attrs as $attrib => $value) |
696 | 712 | { |
697 | - if (in_array($attrib, array('width', 'height'))) |
|
698 | - $params .= ' ' . $attrib . '=' . (int) $value; |
|
699 | - elseif ($attrib == 'alt' && trim($value) != '') |
|
700 | - $params .= ' alt=' . trim($value); |
|
701 | - elseif ($attrib == 'src') |
|
702 | - $src = trim($value); |
|
713 | + if (in_array($attrib, array('width', 'height'))) { |
|
714 | + $params .= ' ' . $attrib . '=' . (int) $value; |
|
715 | + } elseif ($attrib == 'alt' && trim($value) != '') { |
|
716 | + $params .= ' alt=' . trim($value); |
|
717 | + } elseif ($attrib == 'src') { |
|
718 | + $src = trim($value); |
|
719 | + } |
|
703 | 720 | } |
704 | 721 | |
705 | 722 | $tag = ''; |
@@ -710,10 +727,11 @@ discard block |
||
710 | 727 | { |
711 | 728 | $baseURL = (isset($parsedURL['scheme']) ? $parsedURL['scheme'] : 'http') . '://' . $parsedURL['host'] . (empty($parsedURL['port']) ? '' : ':' . $parsedURL['port']); |
712 | 729 | |
713 | - if (substr($src, 0, 1) === '/') |
|
714 | - $src = $baseURL . $src; |
|
715 | - else |
|
716 | - $src = $baseURL . (empty($parsedURL['path']) ? '/' : preg_replace('~/(?:index\\.php)?$~', '', $parsedURL['path'])) . '/' . $src; |
|
730 | + if (substr($src, 0, 1) === '/') { |
|
731 | + $src = $baseURL . $src; |
|
732 | + } else { |
|
733 | + $src = $baseURL . (empty($parsedURL['path']) ? '/' : preg_replace('~/(?:index\\.php)?$~', '', $parsedURL['path'])) . '/' . $src; |
|
734 | + } |
|
717 | 735 | } |
718 | 736 | |
719 | 737 | $tag = '[img' . $params . ']' . $src . '[/img]'; |
@@ -891,20 +909,23 @@ discard block |
||
891 | 909 | }, |
892 | 910 | ); |
893 | 911 | |
894 | - foreach ($tags as $tag => $replace) |
|
895 | - $text = preg_replace_callback($tag, $replace, $text); |
|
912 | + foreach ($tags as $tag => $replace) { |
|
913 | + $text = preg_replace_callback($tag, $replace, $text); |
|
914 | + } |
|
896 | 915 | |
897 | 916 | // Please give us just a little more time. |
898 | - if (connection_aborted() && $context['server']['is_apache']) |
|
899 | - @apache_reset_timeout(); |
|
917 | + if (connection_aborted() && $context['server']['is_apache']) { |
|
918 | + @apache_reset_timeout(); |
|
919 | + } |
|
900 | 920 | |
901 | 921 | // What about URL's - the pain in the ass of the tag world. |
902 | 922 | while (preg_match('~<a\s+([^<>]*)>([^<>]*)</a>~i', $text, $matches) === 1) |
903 | 923 | { |
904 | 924 | // Find the position of the URL. |
905 | 925 | $start_pos = strpos($text, $matches[0]); |
906 | - if ($start_pos === false) |
|
907 | - break; |
|
926 | + if ($start_pos === false) { |
|
927 | + break; |
|
928 | + } |
|
908 | 929 | $end_pos = $start_pos + strlen($matches[0]); |
909 | 930 | |
910 | 931 | $tag_type = 'url'; |
@@ -918,8 +939,9 @@ discard block |
||
918 | 939 | $href = trim($value); |
919 | 940 | |
920 | 941 | // Are we dealing with an FTP link? |
921 | - if (preg_match('~^ftps?://~', $href) === 1) |
|
922 | - $tag_type = 'ftp'; |
|
942 | + if (preg_match('~^ftps?://~', $href) === 1) { |
|
943 | + $tag_type = 'ftp'; |
|
944 | + } |
|
923 | 945 | |
924 | 946 | // Or is this a link to an email address? |
925 | 947 | elseif (substr($href, 0, 7) == 'mailto:') |
@@ -933,28 +955,31 @@ discard block |
||
933 | 955 | { |
934 | 956 | $baseURL = (isset($parsedURL['scheme']) ? $parsedURL['scheme'] : 'http') . '://' . $parsedURL['host'] . (empty($parsedURL['port']) ? '' : ':' . $parsedURL['port']); |
935 | 957 | |
936 | - if (substr($href, 0, 1) === '/') |
|
937 | - $href = $baseURL . $href; |
|
938 | - else |
|
939 | - $href = $baseURL . (empty($parsedURL['path']) ? '/' : preg_replace('~/(?:index\\.php)?$~', '', $parsedURL['path'])) . '/' . $href; |
|
958 | + if (substr($href, 0, 1) === '/') { |
|
959 | + $href = $baseURL . $href; |
|
960 | + } else { |
|
961 | + $href = $baseURL . (empty($parsedURL['path']) ? '/' : preg_replace('~/(?:index\\.php)?$~', '', $parsedURL['path'])) . '/' . $href; |
|
962 | + } |
|
940 | 963 | } |
941 | 964 | } |
942 | 965 | |
943 | 966 | // External URL? |
944 | 967 | if ($attrib == 'target' && $tag_type == 'url') |
945 | 968 | { |
946 | - if (trim($value) == '_blank') |
|
947 | - $tag_type == 'iurl'; |
|
969 | + if (trim($value) == '_blank') { |
|
970 | + $tag_type == 'iurl'; |
|
971 | + } |
|
948 | 972 | } |
949 | 973 | } |
950 | 974 | |
951 | 975 | $tag = ''; |
952 | 976 | if ($href != '') |
953 | 977 | { |
954 | - if ($matches[2] == $href) |
|
955 | - $tag = '[' . $tag_type . ']' . $href . '[/' . $tag_type . ']'; |
|
956 | - else |
|
957 | - $tag = '[' . $tag_type . '=' . $href . ']' . $matches[2] . '[/' . $tag_type . ']'; |
|
978 | + if ($matches[2] == $href) { |
|
979 | + $tag = '[' . $tag_type . ']' . $href . '[/' . $tag_type . ']'; |
|
980 | + } else { |
|
981 | + $tag = '[' . $tag_type . '=' . $href . ']' . $matches[2] . '[/' . $tag_type . ']'; |
|
982 | + } |
|
958 | 983 | } |
959 | 984 | |
960 | 985 | // Replace the tag |
@@ -994,17 +1019,18 @@ discard block |
||
994 | 1019 | // We're either moving from the key to the attribute or we're in a string and this is fine. |
995 | 1020 | if ($text[$i] == '=') |
996 | 1021 | { |
997 | - if ($tag_state == 0) |
|
998 | - $tag_state = 1; |
|
999 | - elseif ($tag_state == 2) |
|
1000 | - $value .= '='; |
|
1022 | + if ($tag_state == 0) { |
|
1023 | + $tag_state = 1; |
|
1024 | + } elseif ($tag_state == 2) { |
|
1025 | + $value .= '='; |
|
1026 | + } |
|
1001 | 1027 | } |
1002 | 1028 | // A space is either moving from an attribute back to a potential key or in a string is fine. |
1003 | 1029 | elseif ($text[$i] == ' ') |
1004 | 1030 | { |
1005 | - if ($tag_state == 2) |
|
1006 | - $value .= ' '; |
|
1007 | - elseif ($tag_state == 1) |
|
1031 | + if ($tag_state == 2) { |
|
1032 | + $value .= ' '; |
|
1033 | + } elseif ($tag_state == 1) |
|
1008 | 1034 | { |
1009 | 1035 | $attribs[$key] = $value; |
1010 | 1036 | $key = $value = ''; |
@@ -1015,24 +1041,27 @@ discard block |
||
1015 | 1041 | elseif ($text[$i] == '"') |
1016 | 1042 | { |
1017 | 1043 | // Must be either going into or out of a string. |
1018 | - if ($tag_state == 1) |
|
1019 | - $tag_state = 2; |
|
1020 | - else |
|
1021 | - $tag_state = 1; |
|
1044 | + if ($tag_state == 1) { |
|
1045 | + $tag_state = 2; |
|
1046 | + } else { |
|
1047 | + $tag_state = 1; |
|
1048 | + } |
|
1022 | 1049 | } |
1023 | 1050 | // Otherwise it's fine. |
1024 | 1051 | else |
1025 | 1052 | { |
1026 | - if ($tag_state == 0) |
|
1027 | - $key .= $text[$i]; |
|
1028 | - else |
|
1029 | - $value .= $text[$i]; |
|
1053 | + if ($tag_state == 0) { |
|
1054 | + $key .= $text[$i]; |
|
1055 | + } else { |
|
1056 | + $value .= $text[$i]; |
|
1057 | + } |
|
1030 | 1058 | } |
1031 | 1059 | } |
1032 | 1060 | |
1033 | 1061 | // Anything left? |
1034 | - if ($key != '' && $value != '') |
|
1035 | - $attribs[$key] = $value; |
|
1062 | + if ($key != '' && $value != '') { |
|
1063 | + $attribs[$key] = $value; |
|
1064 | + } |
|
1036 | 1065 | |
1037 | 1066 | return $attribs; |
1038 | 1067 | } |
@@ -1050,15 +1079,17 @@ discard block |
||
1050 | 1079 | global $modSettings; |
1051 | 1080 | |
1052 | 1081 | // Don't care about the texts that are too short. |
1053 | - if (strlen($text) < 3) |
|
1054 | - return $text; |
|
1082 | + if (strlen($text) < 3) { |
|
1083 | + return $text; |
|
1084 | + } |
|
1055 | 1085 | |
1056 | 1086 | // A list of tags that's disabled by the admin. |
1057 | 1087 | $disabled = empty($modSettings['disabledBBC']) ? array() : array_flip(explode(',', strtolower($modSettings['disabledBBC']))); |
1058 | 1088 | |
1059 | 1089 | // Add flash if it's disabled as embedded tag. |
1060 | - if (empty($modSettings['enableEmbeddedFlash'])) |
|
1061 | - $disabled['flash'] = true; |
|
1090 | + if (empty($modSettings['enableEmbeddedFlash'])) { |
|
1091 | + $disabled['flash'] = true; |
|
1092 | + } |
|
1062 | 1093 | |
1063 | 1094 | // Get a list of all the tags that are not disabled. |
1064 | 1095 | $all_tags = parse_bbc(false); |
@@ -1066,10 +1097,12 @@ discard block |
||
1066 | 1097 | $self_closing_tags = array(); |
1067 | 1098 | foreach ($all_tags as $tag) |
1068 | 1099 | { |
1069 | - if (!isset($disabled[$tag['tag']])) |
|
1070 | - $valid_tags[$tag['tag']] = !empty($tag['block_level']); |
|
1071 | - if (isset($tag['type']) && $tag['type'] == 'closed') |
|
1072 | - $self_closing_tags[] = $tag['tag']; |
|
1100 | + if (!isset($disabled[$tag['tag']])) { |
|
1101 | + $valid_tags[$tag['tag']] = !empty($tag['block_level']); |
|
1102 | + } |
|
1103 | + if (isset($tag['type']) && $tag['type'] == 'closed') { |
|
1104 | + $self_closing_tags[] = $tag['tag']; |
|
1105 | + } |
|
1073 | 1106 | } |
1074 | 1107 | |
1075 | 1108 | // Right - we're going to start by going through the whole lot to make sure we don't have align stuff crossed as this happens load and is stupid! |
@@ -1096,16 +1129,19 @@ discard block |
||
1096 | 1129 | $tagName = substr($match, $isClosingTag ? 2 : 1, -1); |
1097 | 1130 | |
1098 | 1131 | // We're closing the exact same tag that we opened. |
1099 | - if ($isClosingTag && $insideTag === $tagName) |
|
1100 | - $insideTag = null; |
|
1132 | + if ($isClosingTag && $insideTag === $tagName) { |
|
1133 | + $insideTag = null; |
|
1134 | + } |
|
1101 | 1135 | |
1102 | 1136 | // We're opening a tag and we're not yet inside one either |
1103 | - elseif (!$isClosingTag && $insideTag === null) |
|
1104 | - $insideTag = $tagName; |
|
1137 | + elseif (!$isClosingTag && $insideTag === null) { |
|
1138 | + $insideTag = $tagName; |
|
1139 | + } |
|
1105 | 1140 | |
1106 | 1141 | // In all other cases, this tag must be invalid |
1107 | - else |
|
1108 | - unset($matches[$i]); |
|
1142 | + else { |
|
1143 | + unset($matches[$i]); |
|
1144 | + } |
|
1109 | 1145 | } |
1110 | 1146 | |
1111 | 1147 | // The next one is gonna be the other one. |
@@ -1113,8 +1149,9 @@ discard block |
||
1113 | 1149 | } |
1114 | 1150 | |
1115 | 1151 | // We're still inside a tag and had no chance for closure? |
1116 | - if ($insideTag !== null) |
|
1117 | - $matches[] = '[/' . $insideTag . ']'; |
|
1152 | + if ($insideTag !== null) { |
|
1153 | + $matches[] = '[/' . $insideTag . ']'; |
|
1154 | + } |
|
1118 | 1155 | |
1119 | 1156 | // And a complete text string again. |
1120 | 1157 | $text = implode('', $matches); |
@@ -1123,8 +1160,9 @@ discard block |
||
1123 | 1160 | // Quickly remove any tags which are back to back. |
1124 | 1161 | $backToBackPattern = '~\\[(' . implode('|', array_diff(array_keys($valid_tags), array('td', 'anchor'))) . ')[^<>\\[\\]]*\\]\s*\\[/\\1\\]~'; |
1125 | 1162 | $lastlen = 0; |
1126 | - while (strlen($text) !== $lastlen) |
|
1127 | - $lastlen = strlen($text = preg_replace($backToBackPattern, '', $text)); |
|
1163 | + while (strlen($text) !== $lastlen) { |
|
1164 | + $lastlen = strlen($text = preg_replace($backToBackPattern, '', $text)); |
|
1165 | + } |
|
1128 | 1166 | |
1129 | 1167 | // Need to sort the tags my name length. |
1130 | 1168 | uksort($valid_tags, 'sort_array_length'); |
@@ -1161,8 +1199,9 @@ discard block |
||
1161 | 1199 | $isCompetingTag = in_array($tag, $competing_tags); |
1162 | 1200 | |
1163 | 1201 | // Check if this might be one of those cleaned out tags. |
1164 | - if ($tag === '') |
|
1165 | - continue; |
|
1202 | + if ($tag === '') { |
|
1203 | + continue; |
|
1204 | + } |
|
1166 | 1205 | |
1167 | 1206 | // Special case: inside [code] blocks any code is left untouched. |
1168 | 1207 | elseif ($tag === 'code') |
@@ -1173,8 +1212,9 @@ discard block |
||
1173 | 1212 | $inCode = false; |
1174 | 1213 | |
1175 | 1214 | // Reopen tags that were closed before the code block. |
1176 | - if (!empty($inlineElements)) |
|
1177 | - $parts[$i + 4] .= '[' . implode('][', array_keys($inlineElements)) . ']'; |
|
1215 | + if (!empty($inlineElements)) { |
|
1216 | + $parts[$i + 4] .= '[' . implode('][', array_keys($inlineElements)) . ']'; |
|
1217 | + } |
|
1178 | 1218 | } |
1179 | 1219 | |
1180 | 1220 | // We're outside a coding and nobbc block and opening it. |
@@ -1203,8 +1243,9 @@ discard block |
||
1203 | 1243 | $inNoBbc = false; |
1204 | 1244 | |
1205 | 1245 | // Some inline elements might've been closed that need reopening. |
1206 | - if (!empty($inlineElements)) |
|
1207 | - $parts[$i + 4] .= '[' . implode('][', array_keys($inlineElements)) . ']'; |
|
1246 | + if (!empty($inlineElements)) { |
|
1247 | + $parts[$i + 4] .= '[' . implode('][', array_keys($inlineElements)) . ']'; |
|
1248 | + } |
|
1208 | 1249 | } |
1209 | 1250 | |
1210 | 1251 | // We're outside a nobbc and coding block and opening it. |
@@ -1224,8 +1265,9 @@ discard block |
||
1224 | 1265 | } |
1225 | 1266 | |
1226 | 1267 | // So, we're inside one of the special blocks: ignore any tag. |
1227 | - elseif ($inCode || $inNoBbc) |
|
1228 | - continue; |
|
1268 | + elseif ($inCode || $inNoBbc) { |
|
1269 | + continue; |
|
1270 | + } |
|
1229 | 1271 | |
1230 | 1272 | // We're dealing with an opening tag. |
1231 | 1273 | if ($isOpeningTag) |
@@ -1266,8 +1308,9 @@ discard block |
||
1266 | 1308 | if ($parts[$j + 3] === $tag) |
1267 | 1309 | { |
1268 | 1310 | // If it's an opening tag, increase the level. |
1269 | - if ($parts[$j + 2] === '') |
|
1270 | - $curLevel++; |
|
1311 | + if ($parts[$j + 2] === '') { |
|
1312 | + $curLevel++; |
|
1313 | + } |
|
1271 | 1314 | |
1272 | 1315 | // A closing tag, decrease the level. |
1273 | 1316 | else |
@@ -1290,13 +1333,15 @@ discard block |
||
1290 | 1333 | { |
1291 | 1334 | if ($isCompetingTag) |
1292 | 1335 | { |
1293 | - if (!isset($competingElements[$tag])) |
|
1294 | - $competingElements[$tag] = array(); |
|
1336 | + if (!isset($competingElements[$tag])) { |
|
1337 | + $competingElements[$tag] = array(); |
|
1338 | + } |
|
1295 | 1339 | |
1296 | 1340 | $competingElements[$tag][] = $parts[$i + 4]; |
1297 | 1341 | |
1298 | - if (count($competingElements[$tag]) > 1) |
|
1299 | - $parts[$i] .= '[/' . $tag . ']'; |
|
1342 | + if (count($competingElements[$tag]) > 1) { |
|
1343 | + $parts[$i] .= '[/' . $tag . ']'; |
|
1344 | + } |
|
1300 | 1345 | } |
1301 | 1346 | |
1302 | 1347 | $inlineElements[$elementContent] = $tag; |
@@ -1316,15 +1361,17 @@ discard block |
||
1316 | 1361 | $addClosingTags = array(); |
1317 | 1362 | while ($element = array_pop($blockElements)) |
1318 | 1363 | { |
1319 | - if ($element === $tag) |
|
1320 | - break; |
|
1364 | + if ($element === $tag) { |
|
1365 | + break; |
|
1366 | + } |
|
1321 | 1367 | |
1322 | 1368 | // Still a block tag was open not equal to this tag. |
1323 | 1369 | $addClosingTags[] = $element['type']; |
1324 | 1370 | } |
1325 | 1371 | |
1326 | - if (!empty($addClosingTags)) |
|
1327 | - $parts[$i + 1] = '[/' . implode('][/', array_reverse($addClosingTags)) . ']' . $parts[$i + 1]; |
|
1372 | + if (!empty($addClosingTags)) { |
|
1373 | + $parts[$i + 1] = '[/' . implode('][/', array_reverse($addClosingTags)) . ']' . $parts[$i + 1]; |
|
1374 | + } |
|
1328 | 1375 | |
1329 | 1376 | // Apparently the closing tag was not found on the stack. |
1330 | 1377 | if (!is_string($element) || $element !== $tag) |
@@ -1334,8 +1381,7 @@ discard block |
||
1334 | 1381 | $parts[$i + 2] = $parts[$i + 3] = $parts[$i + 4] = ''; |
1335 | 1382 | continue; |
1336 | 1383 | } |
1337 | - } |
|
1338 | - else |
|
1384 | + } else |
|
1339 | 1385 | { |
1340 | 1386 | // Get rid of this closing tag! |
1341 | 1387 | $parts[$i + 1] = $parts[$i + 2] = $parts[$i + 3] = $parts[$i + 4] = ''; |
@@ -1364,53 +1410,62 @@ discard block |
||
1364 | 1410 | unset($inlineElements[$tagContentToBeClosed]); |
1365 | 1411 | |
1366 | 1412 | // Was this the tag we were looking for? |
1367 | - if ($tagToBeClosed === $tag) |
|
1368 | - break; |
|
1413 | + if ($tagToBeClosed === $tag) { |
|
1414 | + break; |
|
1415 | + } |
|
1369 | 1416 | |
1370 | 1417 | // Nope, close it and look further! |
1371 | - else |
|
1372 | - $parts[$i] .= '[/' . $tagToBeClosed . ']'; |
|
1418 | + else { |
|
1419 | + $parts[$i] .= '[/' . $tagToBeClosed . ']'; |
|
1420 | + } |
|
1373 | 1421 | } |
1374 | 1422 | |
1375 | 1423 | if ($isCompetingTag && !empty($competingElements[$tag])) |
1376 | 1424 | { |
1377 | 1425 | array_pop($competingElements[$tag]); |
1378 | 1426 | |
1379 | - if (count($competingElements[$tag]) > 0) |
|
1380 | - $parts[$i + 5] = '[' . $tag . $competingElements[$tag][count($competingElements[$tag]) - 1] . $parts[$i + 5]; |
|
1427 | + if (count($competingElements[$tag]) > 0) { |
|
1428 | + $parts[$i + 5] = '[' . $tag . $competingElements[$tag][count($competingElements[$tag]) - 1] . $parts[$i + 5]; |
|
1429 | + } |
|
1381 | 1430 | } |
1382 | 1431 | } |
1383 | 1432 | |
1384 | 1433 | // Unexpected closing tag, ex-ter-mi-nate. |
1385 | - else |
|
1386 | - $parts[$i + 1] = $parts[$i + 2] = $parts[$i + 3] = $parts[$i + 4] = ''; |
|
1434 | + else { |
|
1435 | + $parts[$i + 1] = $parts[$i + 2] = $parts[$i + 3] = $parts[$i + 4] = ''; |
|
1436 | + } |
|
1387 | 1437 | } |
1388 | 1438 | } |
1389 | 1439 | } |
1390 | 1440 | |
1391 | 1441 | // Close the code tags. |
1392 | - if ($inCode) |
|
1393 | - $parts[$i] .= '[/code]'; |
|
1442 | + if ($inCode) { |
|
1443 | + $parts[$i] .= '[/code]'; |
|
1444 | + } |
|
1394 | 1445 | |
1395 | 1446 | // The same for nobbc tags. |
1396 | - elseif ($inNoBbc) |
|
1397 | - $parts[$i] .= '[/nobbc]'; |
|
1447 | + elseif ($inNoBbc) { |
|
1448 | + $parts[$i] .= '[/nobbc]'; |
|
1449 | + } |
|
1398 | 1450 | |
1399 | 1451 | // Still inline tags left unclosed? Close them now, better late than never. |
1400 | - elseif (!empty($inlineElements)) |
|
1401 | - $parts[$i] .= '[/' . implode('][/', array_reverse($inlineElements)) . ']'; |
|
1452 | + elseif (!empty($inlineElements)) { |
|
1453 | + $parts[$i] .= '[/' . implode('][/', array_reverse($inlineElements)) . ']'; |
|
1454 | + } |
|
1402 | 1455 | |
1403 | 1456 | // Now close the block elements. |
1404 | - if (!empty($blockElements)) |
|
1405 | - $parts[$i] .= '[/' . implode('][/', array_reverse($blockElements)) . ']'; |
|
1457 | + if (!empty($blockElements)) { |
|
1458 | + $parts[$i] .= '[/' . implode('][/', array_reverse($blockElements)) . ']'; |
|
1459 | + } |
|
1406 | 1460 | |
1407 | 1461 | $text = implode('', $parts); |
1408 | 1462 | } |
1409 | 1463 | |
1410 | 1464 | // Final clean up of back to back tags. |
1411 | 1465 | $lastlen = 0; |
1412 | - while (strlen($text) !== $lastlen) |
|
1413 | - $lastlen = strlen($text = preg_replace($backToBackPattern, '', $text)); |
|
1466 | + while (strlen($text) !== $lastlen) { |
|
1467 | + $lastlen = strlen($text = preg_replace($backToBackPattern, '', $text)); |
|
1468 | + } |
|
1414 | 1469 | |
1415 | 1470 | return $text; |
1416 | 1471 | } |
@@ -1441,22 +1496,25 @@ discard block |
||
1441 | 1496 | $context['template_layers'] = array(); |
1442 | 1497 | // Lets make sure we aren't going to output anything nasty. |
1443 | 1498 | @ob_end_clean(); |
1444 | - if (!empty($modSettings['enableCompressedOutput'])) |
|
1445 | - @ob_start('ob_gzhandler'); |
|
1446 | - else |
|
1447 | - @ob_start(); |
|
1499 | + if (!empty($modSettings['enableCompressedOutput'])) { |
|
1500 | + @ob_start('ob_gzhandler'); |
|
1501 | + } else { |
|
1502 | + @ob_start(); |
|
1503 | + } |
|
1448 | 1504 | |
1449 | 1505 | // If we don't have any locale better avoid broken js |
1450 | - if (empty($txt['lang_locale'])) |
|
1451 | - die(); |
|
1506 | + if (empty($txt['lang_locale'])) { |
|
1507 | + die(); |
|
1508 | + } |
|
1452 | 1509 | |
1453 | 1510 | $file_data = '(function ($) { |
1454 | 1511 | \'use strict\'; |
1455 | 1512 | |
1456 | 1513 | $.sceditor.locale[' . JavaScriptEscape($txt['lang_locale']) . '] = {'; |
1457 | - foreach ($editortxt as $key => $val) |
|
1458 | - $file_data .= ' |
|
1514 | + foreach ($editortxt as $key => $val) { |
|
1515 | + $file_data .= ' |
|
1459 | 1516 | ' . JavaScriptEscape($key) . ': ' . JavaScriptEscape($val) . ','; |
1517 | + } |
|
1460 | 1518 | |
1461 | 1519 | $file_data .= ' |
1462 | 1520 | dateFormat: "day.month.year" |
@@ -1524,8 +1582,9 @@ discard block |
||
1524 | 1582 | ) |
1525 | 1583 | ); |
1526 | 1584 | $icon_data = array(); |
1527 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1528 | - $icon_data[] = $row; |
|
1585 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1586 | + $icon_data[] = $row; |
|
1587 | + } |
|
1529 | 1588 | $smcFunc['db_free_result']($request); |
1530 | 1589 | |
1531 | 1590 | $icons = array(); |
@@ -1540,9 +1599,9 @@ discard block |
||
1540 | 1599 | } |
1541 | 1600 | |
1542 | 1601 | cache_put_data('posting_icons-' . $board_id, $icons, 480); |
1602 | + } else { |
|
1603 | + $icons = $temp; |
|
1543 | 1604 | } |
1544 | - else |
|
1545 | - $icons = $temp; |
|
1546 | 1605 | } |
1547 | 1606 | call_integration_hook('integrate_load_message_icons', array(&$icons)); |
1548 | 1607 | |
@@ -1585,8 +1644,9 @@ discard block |
||
1585 | 1644 | { |
1586 | 1645 | // Some general stuff. |
1587 | 1646 | $settings['smileys_url'] = $modSettings['smileys_url'] . '/' . $user_info['smiley_set']; |
1588 | - if (!empty($context['drafts_autosave'])) |
|
1589 | - $context['drafts_autosave_frequency'] = empty($modSettings['drafts_autosave_frequency']) ? 60000 : $modSettings['drafts_autosave_frequency'] * 1000; |
|
1647 | + if (!empty($context['drafts_autosave'])) { |
|
1648 | + $context['drafts_autosave_frequency'] = empty($modSettings['drafts_autosave_frequency']) ? 60000 : $modSettings['drafts_autosave_frequency'] * 1000; |
|
1649 | + } |
|
1590 | 1650 | |
1591 | 1651 | // This really has some WYSIWYG stuff. |
1592 | 1652 | loadCSSFile('jquery.sceditor.css', array('force_current' => false, 'validate' => true), 'smf_jquery_sceditor'); |
@@ -1603,8 +1663,9 @@ discard block |
||
1603 | 1663 | var bbc_quote = \'' . addcslashes($txt['quote'], "'") . '\'; |
1604 | 1664 | var bbc_search_on = \'' . addcslashes($txt['search_on'], "'") . '\';'); |
1605 | 1665 | // editor language file |
1606 | - if (!empty($txt['lang_locale']) && $txt['lang_locale'] != 'en_US') |
|
1607 | - loadJavaScriptFile($scripturl . '?action=loadeditorlocale', array('external' => true), 'sceditor_language'); |
|
1666 | + if (!empty($txt['lang_locale']) && $txt['lang_locale'] != 'en_US') { |
|
1667 | + loadJavaScriptFile($scripturl . '?action=loadeditorlocale', array('external' => true), 'sceditor_language'); |
|
1668 | + } |
|
1608 | 1669 | |
1609 | 1670 | $context['shortcuts_text'] = $txt['shortcuts' . (!empty($context['drafts_save']) ? '_drafts' : '') . (stripos($_SERVER['HTTP_USER_AGENT'], 'Macintosh') !== false ? '_mac' : (isBrowser('is_firefox') ? '_firefox' : ''))]; |
1610 | 1671 | $context['show_spellchecking'] = !empty($modSettings['enableSpellChecking']) && (function_exists('pspell_new') || (function_exists('enchant_broker_init') && ($txt['lang_character_set'] == 'UTF-8' || function_exists('iconv')))); |
@@ -1613,11 +1674,12 @@ discard block |
||
1613 | 1674 | loadJavaScriptFile('spellcheck.js', array('minimize' => true), 'smf_spellcheck'); |
1614 | 1675 | |
1615 | 1676 | // Some hidden information is needed in order to make the spell checking work. |
1616 | - if (!isset($_REQUEST['xml'])) |
|
1617 | - $context['insert_after_template'] .= ' |
|
1677 | + if (!isset($_REQUEST['xml'])) { |
|
1678 | + $context['insert_after_template'] .= ' |
|
1618 | 1679 | <form name="spell_form" id="spell_form" method="post" accept-charset="' . $context['character_set'] . '" target="spellWindow" action="' . $scripturl . '?action=spellcheck"> |
1619 | 1680 | <input type="hidden" name="spellstring" value=""> |
1620 | 1681 | </form>'; |
1682 | + } |
|
1621 | 1683 | } |
1622 | 1684 | } |
1623 | 1685 | |
@@ -1809,10 +1871,12 @@ discard block |
||
1809 | 1871 | |
1810 | 1872 | // Generate a list of buttons that shouldn't be shown - this should be the fastest way to do this. |
1811 | 1873 | $disabled_tags = array(); |
1812 | - if (!empty($modSettings['disabledBBC'])) |
|
1813 | - $disabled_tags = explode(',', $modSettings['disabledBBC']); |
|
1814 | - if (empty($modSettings['enableEmbeddedFlash'])) |
|
1815 | - $disabled_tags[] = 'flash'; |
|
1874 | + if (!empty($modSettings['disabledBBC'])) { |
|
1875 | + $disabled_tags = explode(',', $modSettings['disabledBBC']); |
|
1876 | + } |
|
1877 | + if (empty($modSettings['enableEmbeddedFlash'])) { |
|
1878 | + $disabled_tags[] = 'flash'; |
|
1879 | + } |
|
1816 | 1880 | |
1817 | 1881 | foreach ($disabled_tags as $tag) |
1818 | 1882 | { |
@@ -1824,9 +1888,10 @@ discard block |
||
1824 | 1888 | $context['disabled_tags']['orderedlist'] = true; |
1825 | 1889 | } |
1826 | 1890 | |
1827 | - foreach ($editor_tag_map as $thisTag => $tagNameBBC) |
|
1828 | - if ($tag === $thisTag) |
|
1891 | + foreach ($editor_tag_map as $thisTag => $tagNameBBC) { |
|
1892 | + if ($tag === $thisTag) |
|
1829 | 1893 | $context['disabled_tags'][$tagNameBBC] = true; |
1894 | + } |
|
1830 | 1895 | |
1831 | 1896 | $context['disabled_tags'][$tag] = true; |
1832 | 1897 | } |
@@ -1837,8 +1902,9 @@ discard block |
||
1837 | 1902 | |
1838 | 1903 | foreach ($context['bbc_tags'] as $row => $tagRow) |
1839 | 1904 | { |
1840 | - if (!isset($context['bbc_toolbar'][$row])) |
|
1841 | - $context['bbc_toolbar'][$row] = array(); |
|
1905 | + if (!isset($context['bbc_toolbar'][$row])) { |
|
1906 | + $context['bbc_toolbar'][$row] = array(); |
|
1907 | + } |
|
1842 | 1908 | |
1843 | 1909 | $tagsRow = array(); |
1844 | 1910 | |
@@ -1874,20 +1940,21 @@ discard block |
||
1874 | 1940 | |
1875 | 1941 | $context['bbcodes_handlers'] .= ' |
1876 | 1942 | });'; |
1877 | - } |
|
1878 | - else |
|
1943 | + } else |
|
1879 | 1944 | { |
1880 | 1945 | $context['bbc_toolbar'][$row][] = implode(',', $tagsRow); |
1881 | 1946 | $tagsRow = array(); |
1882 | 1947 | } |
1883 | 1948 | } |
1884 | 1949 | |
1885 | - if (!empty($tagsRow)) |
|
1886 | - $context['bbc_toolbar'][$row][] = implode(',', $tagsRow); |
|
1950 | + if (!empty($tagsRow)) { |
|
1951 | + $context['bbc_toolbar'][$row][] = implode(',', $tagsRow); |
|
1952 | + } |
|
1887 | 1953 | } |
1888 | 1954 | |
1889 | - if (!empty($bbcodes_styles)) |
|
1890 | - addInlineCss($bbcodes_styles); |
|
1955 | + if (!empty($bbcodes_styles)) { |
|
1956 | + addInlineCss($bbcodes_styles); |
|
1957 | + } |
|
1891 | 1958 | } |
1892 | 1959 | |
1893 | 1960 | // Initialize smiley array... if not loaded before. |
@@ -1899,8 +1966,8 @@ discard block |
||
1899 | 1966 | ); |
1900 | 1967 | |
1901 | 1968 | // Load smileys - don't bother to run a query if we're not using the database's ones anyhow. |
1902 | - if (empty($modSettings['smiley_enable']) && $user_info['smiley_set'] != 'none') |
|
1903 | - $context['smileys']['postform'][] = array( |
|
1969 | + if (empty($modSettings['smiley_enable']) && $user_info['smiley_set'] != 'none') { |
|
1970 | + $context['smileys']['postform'][] = array( |
|
1904 | 1971 | 'smileys' => array( |
1905 | 1972 | array( |
1906 | 1973 | 'code' => ':)', |
@@ -1986,7 +2053,7 @@ discard block |
||
1986 | 2053 | ), |
1987 | 2054 | 'isLast' => true, |
1988 | 2055 | ); |
1989 | - elseif ($user_info['smiley_set'] != 'none') |
|
2056 | + } elseif ($user_info['smiley_set'] != 'none') |
|
1990 | 2057 | { |
1991 | 2058 | if (($temp = cache_get_data('posting_smileys', 480)) == null) |
1992 | 2059 | { |
@@ -2009,17 +2076,19 @@ discard block |
||
2009 | 2076 | |
2010 | 2077 | foreach ($context['smileys'] as $section => $smileyRows) |
2011 | 2078 | { |
2012 | - foreach ($smileyRows as $rowIndex => $smileys) |
|
2013 | - $context['smileys'][$section][$rowIndex]['smileys'][count($smileys['smileys']) - 1]['isLast'] = true; |
|
2079 | + foreach ($smileyRows as $rowIndex => $smileys) { |
|
2080 | + $context['smileys'][$section][$rowIndex]['smileys'][count($smileys['smileys']) - 1]['isLast'] = true; |
|
2081 | + } |
|
2014 | 2082 | |
2015 | - if (!empty($smileyRows)) |
|
2016 | - $context['smileys'][$section][count($smileyRows) - 1]['isLast'] = true; |
|
2083 | + if (!empty($smileyRows)) { |
|
2084 | + $context['smileys'][$section][count($smileyRows) - 1]['isLast'] = true; |
|
2085 | + } |
|
2017 | 2086 | } |
2018 | 2087 | |
2019 | 2088 | cache_put_data('posting_smileys', $context['smileys'], 480); |
2089 | + } else { |
|
2090 | + $context['smileys'] = $temp; |
|
2020 | 2091 | } |
2021 | - else |
|
2022 | - $context['smileys'] = $temp; |
|
2023 | 2092 | } |
2024 | 2093 | } |
2025 | 2094 | |
@@ -2035,12 +2104,15 @@ discard block |
||
2035 | 2104 | 'plugins' => 'undo', |
2036 | 2105 | 'bbcodeTrim' => true, |
2037 | 2106 | ); |
2038 | - if (!empty($context['controls']['richedit'][$editorOptions['id']]['locale'])) |
|
2039 | - $sce_options['locale'] = $context['controls']['richedit'][$editorOptions['id']]['locale']; |
|
2040 | - if (!empty($context['right_to_left'])) |
|
2041 | - $sce_options['rtl'] = true; |
|
2042 | - if ($editorOptions['id'] != 'quickReply') |
|
2043 | - $sce_options['autofocus'] = true; |
|
2107 | + if (!empty($context['controls']['richedit'][$editorOptions['id']]['locale'])) { |
|
2108 | + $sce_options['locale'] = $context['controls']['richedit'][$editorOptions['id']]['locale']; |
|
2109 | + } |
|
2110 | + if (!empty($context['right_to_left'])) { |
|
2111 | + $sce_options['rtl'] = true; |
|
2112 | + } |
|
2113 | + if ($editorOptions['id'] != 'quickReply') { |
|
2114 | + $sce_options['autofocus'] = true; |
|
2115 | + } |
|
2044 | 2116 | |
2045 | 2117 | $sce_options['emoticons'] = array(); |
2046 | 2118 | $sce_options['emoticonsDescriptions'] = array(); |
@@ -2057,10 +2129,11 @@ discard block |
||
2057 | 2129 | $countLocations--; |
2058 | 2130 | |
2059 | 2131 | unset($smiley_location); |
2060 | - if ($location == 'postform') |
|
2061 | - $smiley_location = &$sce_options['emoticons']['dropdown']; |
|
2062 | - elseif ($location == 'popup') |
|
2063 | - $smiley_location = &$sce_options['emoticons']['popup']; |
|
2132 | + if ($location == 'postform') { |
|
2133 | + $smiley_location = &$sce_options['emoticons']['dropdown']; |
|
2134 | + } elseif ($location == 'popup') { |
|
2135 | + $smiley_location = &$sce_options['emoticons']['popup']; |
|
2136 | + } |
|
2064 | 2137 | |
2065 | 2138 | $numRows = count($smileyRows); |
2066 | 2139 | |
@@ -2074,8 +2147,9 @@ discard block |
||
2074 | 2147 | $sce_options['emoticonsDescriptions'][$smiley['code']] = $smiley['description']; |
2075 | 2148 | } |
2076 | 2149 | |
2077 | - if (empty($smileyRow['isLast']) && $numRows != 1) |
|
2078 | - $smiley_location['-' . $emptyPlaceholder++] = ''; |
|
2150 | + if (empty($smileyRow['isLast']) && $numRows != 1) { |
|
2151 | + $smiley_location['-' . $emptyPlaceholder++] = ''; |
|
2152 | + } |
|
2079 | 2153 | } |
2080 | 2154 | } |
2081 | 2155 | } |
@@ -2090,8 +2164,9 @@ discard block |
||
2090 | 2164 | |
2091 | 2165 | $count_tags--; |
2092 | 2166 | |
2093 | - if (!empty($count_tags)) |
|
2094 | - $sce_options['toolbar'] .= '||'; |
|
2167 | + if (!empty($count_tags)) { |
|
2168 | + $sce_options['toolbar'] .= '||'; |
|
2169 | + } |
|
2095 | 2170 | } |
2096 | 2171 | } |
2097 | 2172 | |
@@ -2119,8 +2194,9 @@ discard block |
||
2119 | 2194 | loadTemplate('GenericControls'); |
2120 | 2195 | |
2121 | 2196 | // Some javascript ma'am? |
2122 | - if (!empty($verificationOptions['override_visual']) || (!empty($modSettings['visual_verification_type']) && !isset($verificationOptions['override_visual']))) |
|
2123 | - loadJavaScriptFile('captcha.js', array('minimize' => true), 'smf_captcha'); |
|
2197 | + if (!empty($verificationOptions['override_visual']) || (!empty($modSettings['visual_verification_type']) && !isset($verificationOptions['override_visual']))) { |
|
2198 | + loadJavaScriptFile('captcha.js', array('minimize' => true), 'smf_captcha'); |
|
2199 | + } |
|
2124 | 2200 | |
2125 | 2201 | $context['use_graphic_library'] = in_array('gd', get_loaded_extensions()); |
2126 | 2202 | |
@@ -2133,8 +2209,8 @@ discard block |
||
2133 | 2209 | $isNew = !isset($context['controls']['verification'][$verificationOptions['id']]); |
2134 | 2210 | |
2135 | 2211 | // Log this into our collection. |
2136 | - if ($isNew) |
|
2137 | - $context['controls']['verification'][$verificationOptions['id']] = array( |
|
2212 | + if ($isNew) { |
|
2213 | + $context['controls']['verification'][$verificationOptions['id']] = array( |
|
2138 | 2214 | 'id' => $verificationOptions['id'], |
2139 | 2215 | 'empty_field' => empty($verificationOptions['no_empty_field']), |
2140 | 2216 | 'show_visual' => !empty($verificationOptions['override_visual']) || (!empty($modSettings['visual_verification_type']) && !isset($verificationOptions['override_visual'])), |
@@ -2145,13 +2221,15 @@ discard block |
||
2145 | 2221 | 'questions' => array(), |
2146 | 2222 | 'can_recaptcha' => !empty($modSettings['recaptcha_enabled']) && !empty($modSettings['recaptcha_site_key']) && !empty($modSettings['recaptcha_secret_key']), |
2147 | 2223 | ); |
2224 | + } |
|
2148 | 2225 | $thisVerification = &$context['controls']['verification'][$verificationOptions['id']]; |
2149 | 2226 | |
2150 | 2227 | // Is there actually going to be anything? |
2151 | - if (empty($thisVerification['show_visual']) && empty($thisVerification['number_questions']) && empty($thisVerification['can_recaptcha'])) |
|
2152 | - return false; |
|
2153 | - elseif (!$isNew && !$do_test) |
|
2154 | - return true; |
|
2228 | + if (empty($thisVerification['show_visual']) && empty($thisVerification['number_questions']) && empty($thisVerification['can_recaptcha'])) { |
|
2229 | + return false; |
|
2230 | + } elseif (!$isNew && !$do_test) { |
|
2231 | + return true; |
|
2232 | + } |
|
2155 | 2233 | |
2156 | 2234 | // Sanitize reCAPTCHA fields? |
2157 | 2235 | if ($thisVerification['can_recaptcha']) |
@@ -2164,11 +2242,12 @@ discard block |
||
2164 | 2242 | } |
2165 | 2243 | |
2166 | 2244 | // Add javascript for the object. |
2167 | - if ($context['controls']['verification'][$verificationOptions['id']]['show_visual']) |
|
2168 | - $context['insert_after_template'] .= ' |
|
2245 | + if ($context['controls']['verification'][$verificationOptions['id']]['show_visual']) { |
|
2246 | + $context['insert_after_template'] .= ' |
|
2169 | 2247 | <script> |
2170 | 2248 | var verification' . $verificationOptions['id'] . 'Handle = new smfCaptcha("' . $thisVerification['image_href'] . '", "' . $verificationOptions['id'] . '", ' . ($context['use_graphic_library'] ? 1 : 0) . '); |
2171 | 2249 | </script>'; |
2250 | + } |
|
2172 | 2251 | |
2173 | 2252 | // If we want questions do we have a cache of all the IDs? |
2174 | 2253 | if (!empty($thisVerification['number_questions']) && empty($modSettings['question_id_cache'])) |
@@ -2191,8 +2270,9 @@ discard block |
||
2191 | 2270 | unset ($row['id_question']); |
2192 | 2271 | // Make them all lowercase. We can't directly use $smcFunc['strtolower'] with array_walk, so do it manually, eh? |
2193 | 2272 | $row['answers'] = $smcFunc['json_decode']($row['answers'], true); |
2194 | - foreach ($row['answers'] as $k => $v) |
|
2195 | - $row['answers'][$k] = $smcFunc['strtolower']($v); |
|
2273 | + foreach ($row['answers'] as $k => $v) { |
|
2274 | + $row['answers'][$k] = $smcFunc['strtolower']($v); |
|
2275 | + } |
|
2196 | 2276 | |
2197 | 2277 | $modSettings['question_id_cache']['questions'][$id_question] = $row; |
2198 | 2278 | $modSettings['question_id_cache']['langs'][$row['lngfile']][] = $id_question; |
@@ -2203,35 +2283,42 @@ discard block |
||
2203 | 2283 | } |
2204 | 2284 | } |
2205 | 2285 | |
2206 | - if (!isset($_SESSION[$verificationOptions['id'] . '_vv'])) |
|
2207 | - $_SESSION[$verificationOptions['id'] . '_vv'] = array(); |
|
2286 | + if (!isset($_SESSION[$verificationOptions['id'] . '_vv'])) { |
|
2287 | + $_SESSION[$verificationOptions['id'] . '_vv'] = array(); |
|
2288 | + } |
|
2208 | 2289 | |
2209 | 2290 | // Do we need to refresh the verification? |
2210 | - if (!$do_test && (!empty($_SESSION[$verificationOptions['id'] . '_vv']['did_pass']) || empty($_SESSION[$verificationOptions['id'] . '_vv']['count']) || $_SESSION[$verificationOptions['id'] . '_vv']['count'] > 3) && empty($verificationOptions['dont_refresh'])) |
|
2211 | - $force_refresh = true; |
|
2212 | - else |
|
2213 | - $force_refresh = false; |
|
2291 | + if (!$do_test && (!empty($_SESSION[$verificationOptions['id'] . '_vv']['did_pass']) || empty($_SESSION[$verificationOptions['id'] . '_vv']['count']) || $_SESSION[$verificationOptions['id'] . '_vv']['count'] > 3) && empty($verificationOptions['dont_refresh'])) { |
|
2292 | + $force_refresh = true; |
|
2293 | + } else { |
|
2294 | + $force_refresh = false; |
|
2295 | + } |
|
2214 | 2296 | |
2215 | 2297 | // This can also force a fresh, although unlikely. |
2216 | - if (($thisVerification['show_visual'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['code'])) || ($thisVerification['number_questions'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['q']))) |
|
2217 | - $force_refresh = true; |
|
2298 | + if (($thisVerification['show_visual'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['code'])) || ($thisVerification['number_questions'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['q']))) { |
|
2299 | + $force_refresh = true; |
|
2300 | + } |
|
2218 | 2301 | |
2219 | 2302 | $verification_errors = array(); |
2220 | 2303 | // Start with any testing. |
2221 | 2304 | if ($do_test) |
2222 | 2305 | { |
2223 | 2306 | // This cannot happen! |
2224 | - if (!isset($_SESSION[$verificationOptions['id'] . '_vv']['count'])) |
|
2225 | - fatal_lang_error('no_access', false); |
|
2307 | + if (!isset($_SESSION[$verificationOptions['id'] . '_vv']['count'])) { |
|
2308 | + fatal_lang_error('no_access', false); |
|
2309 | + } |
|
2226 | 2310 | // ... nor this! |
2227 | - if ($thisVerification['number_questions'] && (!isset($_SESSION[$verificationOptions['id'] . '_vv']['q']) || !isset($_REQUEST[$verificationOptions['id'] . '_vv']['q']))) |
|
2228 | - fatal_lang_error('no_access', false); |
|
2311 | + if ($thisVerification['number_questions'] && (!isset($_SESSION[$verificationOptions['id'] . '_vv']['q']) || !isset($_REQUEST[$verificationOptions['id'] . '_vv']['q']))) { |
|
2312 | + fatal_lang_error('no_access', false); |
|
2313 | + } |
|
2229 | 2314 | // Hmm, it's requested but not actually declared. This shouldn't happen. |
2230 | - if ($thisVerification['empty_field'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field'])) |
|
2231 | - fatal_lang_error('no_access', false); |
|
2315 | + if ($thisVerification['empty_field'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field'])) { |
|
2316 | + fatal_lang_error('no_access', false); |
|
2317 | + } |
|
2232 | 2318 | // While we're here, did the user do something bad? |
2233 | - if ($thisVerification['empty_field'] && !empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field']) && !empty($_REQUEST[$_SESSION[$verificationOptions['id'] . '_vv']['empty_field']])) |
|
2234 | - $verification_errors[] = 'wrong_verification_answer'; |
|
2319 | + if ($thisVerification['empty_field'] && !empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field']) && !empty($_REQUEST[$_SESSION[$verificationOptions['id'] . '_vv']['empty_field']])) { |
|
2320 | + $verification_errors[] = 'wrong_verification_answer'; |
|
2321 | + } |
|
2235 | 2322 | |
2236 | 2323 | if ($thisVerification['can_recaptcha']) |
2237 | 2324 | { |
@@ -2242,22 +2329,25 @@ discard block |
||
2242 | 2329 | { |
2243 | 2330 | $resp = $reCaptcha->verify($_POST['g-recaptcha-response'], $user_info['ip']); |
2244 | 2331 | |
2245 | - if (!$resp->isSuccess()) |
|
2246 | - $verification_errors[] = 'wrong_verification_code'; |
|
2332 | + if (!$resp->isSuccess()) { |
|
2333 | + $verification_errors[] = 'wrong_verification_code'; |
|
2334 | + } |
|
2335 | + } else { |
|
2336 | + $verification_errors[] = 'wrong_verification_code'; |
|
2247 | 2337 | } |
2248 | - else |
|
2249 | - $verification_errors[] = 'wrong_verification_code'; |
|
2250 | 2338 | } |
2251 | - if ($thisVerification['show_visual'] && (empty($_REQUEST[$verificationOptions['id'] . '_vv']['code']) || empty($_SESSION[$verificationOptions['id'] . '_vv']['code']) || strtoupper($_REQUEST[$verificationOptions['id'] . '_vv']['code']) !== $_SESSION[$verificationOptions['id'] . '_vv']['code'])) |
|
2252 | - $verification_errors[] = 'wrong_verification_code'; |
|
2339 | + if ($thisVerification['show_visual'] && (empty($_REQUEST[$verificationOptions['id'] . '_vv']['code']) || empty($_SESSION[$verificationOptions['id'] . '_vv']['code']) || strtoupper($_REQUEST[$verificationOptions['id'] . '_vv']['code']) !== $_SESSION[$verificationOptions['id'] . '_vv']['code'])) { |
|
2340 | + $verification_errors[] = 'wrong_verification_code'; |
|
2341 | + } |
|
2253 | 2342 | if ($thisVerification['number_questions']) |
2254 | 2343 | { |
2255 | 2344 | $incorrectQuestions = array(); |
2256 | 2345 | foreach ($_SESSION[$verificationOptions['id'] . '_vv']['q'] as $q) |
2257 | 2346 | { |
2258 | 2347 | // We don't have this question any more, thus no answers. |
2259 | - if (!isset($modSettings['question_id_cache']['questions'][$q])) |
|
2260 | - continue; |
|
2348 | + if (!isset($modSettings['question_id_cache']['questions'][$q])) { |
|
2349 | + continue; |
|
2350 | + } |
|
2261 | 2351 | // This is quite complex. We have our question but it might have multiple answers. |
2262 | 2352 | // First, did they actually answer this question? |
2263 | 2353 | if (!isset($_REQUEST[$verificationOptions['id'] . '_vv']['q'][$q]) || trim($_REQUEST[$verificationOptions['id'] . '_vv']['q'][$q]) == '') |
@@ -2269,24 +2359,28 @@ discard block |
||
2269 | 2359 | else |
2270 | 2360 | { |
2271 | 2361 | $given_answer = trim($smcFunc['htmlspecialchars'](strtolower($_REQUEST[$verificationOptions['id'] . '_vv']['q'][$q]))); |
2272 | - if (!in_array($given_answer, $modSettings['question_id_cache']['questions'][$q]['answers'])) |
|
2273 | - $incorrectQuestions[] = $q; |
|
2362 | + if (!in_array($given_answer, $modSettings['question_id_cache']['questions'][$q]['answers'])) { |
|
2363 | + $incorrectQuestions[] = $q; |
|
2364 | + } |
|
2274 | 2365 | } |
2275 | 2366 | } |
2276 | 2367 | |
2277 | - if (!empty($incorrectQuestions)) |
|
2278 | - $verification_errors[] = 'wrong_verification_answer'; |
|
2368 | + if (!empty($incorrectQuestions)) { |
|
2369 | + $verification_errors[] = 'wrong_verification_answer'; |
|
2370 | + } |
|
2279 | 2371 | } |
2280 | 2372 | } |
2281 | 2373 | |
2282 | 2374 | // Any errors means we refresh potentially. |
2283 | 2375 | if (!empty($verification_errors)) |
2284 | 2376 | { |
2285 | - if (empty($_SESSION[$verificationOptions['id'] . '_vv']['errors'])) |
|
2286 | - $_SESSION[$verificationOptions['id'] . '_vv']['errors'] = 0; |
|
2377 | + if (empty($_SESSION[$verificationOptions['id'] . '_vv']['errors'])) { |
|
2378 | + $_SESSION[$verificationOptions['id'] . '_vv']['errors'] = 0; |
|
2379 | + } |
|
2287 | 2380 | // Too many errors? |
2288 | - elseif ($_SESSION[$verificationOptions['id'] . '_vv']['errors'] > $thisVerification['max_errors']) |
|
2289 | - $force_refresh = true; |
|
2381 | + elseif ($_SESSION[$verificationOptions['id'] . '_vv']['errors'] > $thisVerification['max_errors']) { |
|
2382 | + $force_refresh = true; |
|
2383 | + } |
|
2290 | 2384 | |
2291 | 2385 | // Keep a track of these. |
2292 | 2386 | $_SESSION[$verificationOptions['id'] . '_vv']['errors']++; |
@@ -2319,8 +2413,9 @@ discard block |
||
2319 | 2413 | // Are we overriding the range? |
2320 | 2414 | $character_range = !empty($verificationOptions['override_range']) ? $verificationOptions['override_range'] : $context['standard_captcha_range']; |
2321 | 2415 | |
2322 | - for ($i = 0; $i < 6; $i++) |
|
2323 | - $_SESSION[$verificationOptions['id'] . '_vv']['code'] .= $character_range[array_rand($character_range)]; |
|
2416 | + for ($i = 0; $i < 6; $i++) { |
|
2417 | + $_SESSION[$verificationOptions['id'] . '_vv']['code'] .= $character_range[array_rand($character_range)]; |
|
2418 | + } |
|
2324 | 2419 | } |
2325 | 2420 | |
2326 | 2421 | // Getting some new questions? |
@@ -2328,8 +2423,9 @@ discard block |
||
2328 | 2423 | { |
2329 | 2424 | // Attempt to try the current page's language, followed by the user's preference, followed by the site default. |
2330 | 2425 | $possible_langs = array(); |
2331 | - if (isset($_SESSION['language'])) |
|
2332 | - $possible_langs[] = strtr($_SESSION['language'], array('-utf8' => '')); |
|
2426 | + if (isset($_SESSION['language'])) { |
|
2427 | + $possible_langs[] = strtr($_SESSION['language'], array('-utf8' => '')); |
|
2428 | + } |
|
2333 | 2429 | if (!empty($user_info['language'])); |
2334 | 2430 | $possible_langs[] = $user_info['language']; |
2335 | 2431 | $possible_langs[] = $language; |
@@ -2348,8 +2444,7 @@ discard block |
||
2348 | 2444 | } |
2349 | 2445 | } |
2350 | 2446 | } |
2351 | - } |
|
2352 | - else |
|
2447 | + } else |
|
2353 | 2448 | { |
2354 | 2449 | // Same questions as before. |
2355 | 2450 | $questionIDs = !empty($_SESSION[$verificationOptions['id'] . '_vv']['q']) ? $_SESSION[$verificationOptions['id'] . '_vv']['q'] : array(); |
@@ -2359,8 +2454,9 @@ discard block |
||
2359 | 2454 | // If we do have an empty field, it would be nice to hide it from legitimate users who shouldn't be populating it anyway. |
2360 | 2455 | if (!empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field'])) |
2361 | 2456 | { |
2362 | - if (!isset($context['html_headers'])) |
|
2363 | - $context['html_headers'] = ''; |
|
2457 | + if (!isset($context['html_headers'])) { |
|
2458 | + $context['html_headers'] = ''; |
|
2459 | + } |
|
2364 | 2460 | $context['html_headers'] .= '<style>.vv_special { display:none; }</style>'; |
2365 | 2461 | } |
2366 | 2462 | |
@@ -2386,11 +2482,13 @@ discard block |
||
2386 | 2482 | $_SESSION[$verificationOptions['id'] . '_vv']['count'] = empty($_SESSION[$verificationOptions['id'] . '_vv']['count']) ? 1 : $_SESSION[$verificationOptions['id'] . '_vv']['count'] + 1; |
2387 | 2483 | |
2388 | 2484 | // Return errors if we have them. |
2389 | - if (!empty($verification_errors)) |
|
2390 | - return $verification_errors; |
|
2485 | + if (!empty($verification_errors)) { |
|
2486 | + return $verification_errors; |
|
2487 | + } |
|
2391 | 2488 | // If we had a test that one, make a note. |
2392 | - elseif ($do_test) |
|
2393 | - $_SESSION[$verificationOptions['id'] . '_vv']['did_pass'] = true; |
|
2489 | + elseif ($do_test) { |
|
2490 | + $_SESSION[$verificationOptions['id'] . '_vv']['did_pass'] = true; |
|
2491 | + } |
|
2394 | 2492 | |
2395 | 2493 | // Say that everything went well chaps. |
2396 | 2494 | return true; |
@@ -2415,8 +2513,9 @@ discard block |
||
2415 | 2513 | call_integration_hook('integrate_autosuggest', array(&$searchTypes)); |
2416 | 2514 | |
2417 | 2515 | // If we're just checking the callback function is registered return true or false. |
2418 | - if ($checkRegistered != null) |
|
2419 | - return isset($searchTypes[$checkRegistered]) && function_exists('AutoSuggest_Search_' . $checkRegistered); |
|
2516 | + if ($checkRegistered != null) { |
|
2517 | + return isset($searchTypes[$checkRegistered]) && function_exists('AutoSuggest_Search_' . $checkRegistered); |
|
2518 | + } |
|
2420 | 2519 | |
2421 | 2520 | checkSession('get'); |
2422 | 2521 | loadTemplate('Xml'); |
@@ -2567,24 +2666,27 @@ discard block |
||
2567 | 2666 | foreach ($possible_versions as $ver) |
2568 | 2667 | { |
2569 | 2668 | $ver = trim($ver); |
2570 | - if (strpos($ver, 'SMF') === 0) |
|
2571 | - $versions[] = $ver; |
|
2669 | + if (strpos($ver, 'SMF') === 0) { |
|
2670 | + $versions[] = $ver; |
|
2671 | + } |
|
2572 | 2672 | } |
2573 | 2673 | } |
2574 | 2674 | $smcFunc['db_free_result']($request); |
2575 | 2675 | |
2576 | 2676 | // Just in case we don't have ANYthing. |
2577 | - if (empty($versions)) |
|
2578 | - $versions = array('SMF 2.0'); |
|
2677 | + if (empty($versions)) { |
|
2678 | + $versions = array('SMF 2.0'); |
|
2679 | + } |
|
2579 | 2680 | |
2580 | - foreach ($versions as $id => $version) |
|
2581 | - if (strpos($version, strtoupper($_REQUEST['search'])) !== false) |
|
2681 | + foreach ($versions as $id => $version) { |
|
2682 | + if (strpos($version, strtoupper($_REQUEST['search'])) !== false) |
|
2582 | 2683 | $xml_data['items']['children'][] = array( |
2583 | 2684 | 'attributes' => array( |
2584 | 2685 | 'id' => $id, |
2585 | 2686 | ), |
2586 | 2687 | 'value' => $version, |
2587 | 2688 | ); |
2689 | + } |
|
2588 | 2690 | |
2589 | 2691 | return $xml_data; |
2590 | 2692 | } |
@@ -38,8 +38,8 @@ discard block |
||
38 | 38 | } |
39 | 39 | </script>'; |
40 | 40 | |
41 | - if (!empty($context['poll_error']['messages'])) |
|
42 | - echo ' |
|
41 | + if (!empty($context['poll_error']['messages'])) { |
|
42 | + echo ' |
|
43 | 43 | <div class="errorbox"> |
44 | 44 | <dl class="poll_error"> |
45 | 45 | <dt> |
@@ -50,6 +50,7 @@ discard block |
||
50 | 50 | </dt> |
51 | 51 | </dl> |
52 | 52 | </div>'; |
53 | + } |
|
53 | 54 | |
54 | 55 | // Start the main poll form. |
55 | 56 | echo ' |
@@ -79,8 +80,9 @@ discard block |
||
79 | 80 | <input type="text" name="options[', $choice['id'], ']" id="options-', $choice['id'], '" value="', $choice['label'], '" size="80" maxlength="255">'; |
80 | 81 | |
81 | 82 | // Does this option have a vote count yet, or is it new? |
82 | - if ($choice['votes'] != -1) |
|
83 | - echo ' (', $choice['votes'], ' ', $txt['votes'], ')'; |
|
83 | + if ($choice['votes'] != -1) { |
|
84 | + echo ' (', $choice['votes'], ' ', $txt['votes'], ')'; |
|
85 | + } |
|
84 | 86 | |
85 | 87 | echo ' |
86 | 88 | </dd>'; |
@@ -118,14 +120,15 @@ discard block |
||
118 | 120 | <input type="checkbox" id="poll_change_vote" name="poll_change_vote"', !empty($context['poll']['change_vote']) ? ' checked' : '', '> |
119 | 121 | </dd>'; |
120 | 122 | |
121 | - if ($context['poll']['guest_vote_allowed']) |
|
122 | - echo ' |
|
123 | + if ($context['poll']['guest_vote_allowed']) { |
|
124 | + echo ' |
|
123 | 125 | <dt> |
124 | 126 | <label for="poll_guest_vote">', $txt['poll_guest_vote'], ':</label> |
125 | 127 | </dt> |
126 | 128 | <dd> |
127 | 129 | <input type="checkbox" id="poll_guest_vote" name="poll_guest_vote"', !empty($context['poll']['guest_vote']) ? ' checked' : '', '> |
128 | 130 | </dd>'; |
131 | + } |
|
129 | 132 | } |
130 | 133 | |
131 | 134 | echo ' |
@@ -141,12 +144,13 @@ discard block |
||
141 | 144 | </fieldset>'; |
142 | 145 | |
143 | 146 | // If this is an edit, we can allow them to reset the vote counts. |
144 | - if ($context['is_edit']) |
|
145 | - echo ' |
|
147 | + if ($context['is_edit']) { |
|
148 | + echo ' |
|
146 | 149 | <fieldset id="poll_reset"> |
147 | 150 | <legend>', $txt['reset_votes'], '</legend> |
148 | 151 | <input type="checkbox" name="resetVoteCount" value="on"> ' . $txt['reset_votes_check'] . ' |
149 | 152 | </fieldset>'; |
153 | + } |
|
150 | 154 | echo ' |
151 | 155 | <input type="submit" name="post" value="', $txt['save'], '" onclick="return submitThisOnce(this);" accesskey="s" class="button"> |
152 | 156 | </div><!-- .roundframe --> |