@@ -14,8 +14,9 @@ discard block |
||
| 14 | 14 | * @version 2.1 Beta 3 |
| 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!!! |
@@ -30,8 +31,9 @@ discard block |
||
| 30 | 31 | { |
| 31 | 32 | global $modSettings; |
| 32 | 33 | |
| 33 | - if (!$compat_mode) |
|
| 34 | - return $text; |
|
| 34 | + if (!$compat_mode) { |
|
| 35 | + return $text; |
|
| 36 | + } |
|
| 35 | 37 | |
| 36 | 38 | // Turn line breaks back into br's. |
| 37 | 39 | $text = strtr($text, array("\r" => '', "\n" => '<br>')); |
@@ -48,8 +50,9 @@ discard block |
||
| 48 | 50 | for ($i = 0, $n = count($parts); $i < $n; $i++) |
| 49 | 51 | { |
| 50 | 52 | // Value of 2 means we're inside the tag. |
| 51 | - if ($i % 4 == 2) |
|
| 52 | - $parts[$i] = strtr($parts[$i], array('[' => '[', ']' => ']', "'" => "'")); |
|
| 53 | + if ($i % 4 == 2) { |
|
| 54 | + $parts[$i] = strtr($parts[$i], array('[' => '[', ']' => ']', "'" => "'")); |
|
| 55 | + } |
|
| 53 | 56 | } |
| 54 | 57 | // Put our humpty dumpty message back together again. |
| 55 | 58 | $text = implode('', $parts); |
@@ -107,8 +110,9 @@ discard block |
||
| 107 | 110 | $text = preg_replace('~</p>\s*(?!<)~i', '</p><br>', $text); |
| 108 | 111 | |
| 109 | 112 | // Safari/webkit wraps lines in Wysiwyg in <div>'s. |
| 110 | - if (isBrowser('webkit')) |
|
| 111 | - $text = preg_replace(array('~<div(?:\s(?:[^<>]*?))?' . '>~i', '</div>'), array('<br>', ''), $text); |
|
| 113 | + if (isBrowser('webkit')) { |
|
| 114 | + $text = preg_replace(array('~<div(?:\s(?:[^<>]*?))?' . '>~i', '</div>'), array('<br>', ''), $text); |
|
| 115 | + } |
|
| 112 | 116 | |
| 113 | 117 | // If there's a trailing break get rid of it - Firefox tends to add one. |
| 114 | 118 | $text = preg_replace('~<br\s?/?' . '>$~i', '', $text); |
@@ -123,8 +127,9 @@ discard block |
||
| 123 | 127 | for ($i = 0, $n = count($parts); $i < $n; $i++) |
| 124 | 128 | { |
| 125 | 129 | // Value of 2 means we're inside the tag. |
| 126 | - if ($i % 4 == 2) |
|
| 127 | - $parts[$i] = strip_tags($parts[$i]); |
|
| 130 | + if ($i % 4 == 2) { |
|
| 131 | + $parts[$i] = strip_tags($parts[$i]); |
|
| 132 | + } |
|
| 128 | 133 | } |
| 129 | 134 | |
| 130 | 135 | $text = strtr(implode('', $parts), array('#smf_br_spec_grudge_cool!#' => '<br>')); |
@@ -150,18 +155,19 @@ discard block |
||
| 150 | 155 | { |
| 151 | 156 | $found = array_search($file, $smileysto); |
| 152 | 157 | // Note the weirdness here is to stop double spaces between smileys. |
| 153 | - if ($found) |
|
| 154 | - $matches[1][$k] = '-[]-smf_smily_start#|#' . $smcFunc['htmlspecialchars']($smileysfrom[$found]) . '-[]-smf_smily_end#|#'; |
|
| 155 | - else |
|
| 156 | - $matches[1][$k] = ''; |
|
| 158 | + if ($found) { |
|
| 159 | + $matches[1][$k] = '-[]-smf_smily_start#|#' . $smcFunc['htmlspecialchars']($smileysfrom[$found]) . '-[]-smf_smily_end#|#'; |
|
| 160 | + } else { |
|
| 161 | + $matches[1][$k] = ''; |
|
| 162 | + } |
|
| 157 | 163 | } |
| 158 | - } |
|
| 159 | - else |
|
| 164 | + } else |
|
| 160 | 165 | { |
| 161 | 166 | // Load all the smileys. |
| 162 | 167 | $names = array(); |
| 163 | - foreach ($matches[1] as $file) |
|
| 164 | - $names[] = $file; |
|
| 168 | + foreach ($matches[1] as $file) { |
|
| 169 | + $names[] = $file; |
|
| 170 | + } |
|
| 165 | 171 | $names = array_unique($names); |
| 166 | 172 | |
| 167 | 173 | if (!empty($names)) |
@@ -175,13 +181,15 @@ discard block |
||
| 175 | 181 | ) |
| 176 | 182 | ); |
| 177 | 183 | $mappings = array(); |
| 178 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 179 | - $mappings[$row['filename']] = $smcFunc['htmlspecialchars']($row['code']); |
|
| 184 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 185 | + $mappings[$row['filename']] = $smcFunc['htmlspecialchars']($row['code']); |
|
| 186 | + } |
|
| 180 | 187 | $smcFunc['db_free_result']($request); |
| 181 | 188 | |
| 182 | - foreach ($matches[1] as $k => $file) |
|
| 183 | - if (isset($mappings[$file])) |
|
| 189 | + foreach ($matches[1] as $k => $file) { |
|
| 190 | + if (isset($mappings[$file])) |
|
| 184 | 191 | $matches[1][$k] = '-[]-smf_smily_start#|#' . $mappings[$file] . '-[]-smf_smily_end#|#'; |
| 192 | + } |
|
| 185 | 193 | } |
| 186 | 194 | } |
| 187 | 195 | |
@@ -193,8 +201,9 @@ discard block |
||
| 193 | 201 | } |
| 194 | 202 | |
| 195 | 203 | // Only try to buy more time if the client didn't quit. |
| 196 | - if (connection_aborted() && $context['server']['is_apache']) |
|
| 197 | - @apache_reset_timeout(); |
|
| 204 | + if (connection_aborted() && $context['server']['is_apache']) { |
|
| 205 | + @apache_reset_timeout(); |
|
| 206 | + } |
|
| 198 | 207 | |
| 199 | 208 | $parts = preg_split('~(<[A-Za-z]+\s*[^<>]*?style="?[^<>"]+"?[^<>]*?(?:/?)>|</[A-Za-z]+>)~', $text, -1, PREG_SPLIT_DELIM_CAPTURE); |
| 200 | 209 | $replacement = ''; |
@@ -205,9 +214,9 @@ discard block |
||
| 205 | 214 | if (preg_match('~(<([A-Za-z]+)\s*[^<>]*?)style="?([^<>"]+)"?([^<>]*?(/?)>)~', $part, $matches) === 1) |
| 206 | 215 | { |
| 207 | 216 | // If it's being closed instantly, we can't deal with it...yet. |
| 208 | - if ($matches[5] === '/') |
|
| 209 | - continue; |
|
| 210 | - else |
|
| 217 | + if ($matches[5] === '/') { |
|
| 218 | + continue; |
|
| 219 | + } else |
|
| 211 | 220 | { |
| 212 | 221 | // Get an array of styles that apply to this element. (The strtr is there to combat HTML generated by Word.) |
| 213 | 222 | $styles = explode(';', strtr($matches[3], array('"' => ''))); |
@@ -223,8 +232,9 @@ discard block |
||
| 223 | 232 | $clean_type_value_pair = strtolower(strtr(trim($type_value_pair), '=', ':')); |
| 224 | 233 | |
| 225 | 234 | // Something like 'font-weight: bold' is expected here. |
| 226 | - if (strpos($clean_type_value_pair, ':') === false) |
|
| 227 | - continue; |
|
| 235 | + if (strpos($clean_type_value_pair, ':') === false) { |
|
| 236 | + continue; |
|
| 237 | + } |
|
| 228 | 238 | |
| 229 | 239 | // Capture the elements of a single style item (e.g. 'font-weight' and 'bold'). |
| 230 | 240 | list ($style_type, $style_value) = explode(':', $type_value_pair); |
@@ -246,8 +256,7 @@ discard block |
||
| 246 | 256 | { |
| 247 | 257 | $curCloseTags .= '[/u]'; |
| 248 | 258 | $replacement .= '[u]'; |
| 249 | - } |
|
| 250 | - elseif ($style_value == 'line-through') |
|
| 259 | + } elseif ($style_value == 'line-through') |
|
| 251 | 260 | { |
| 252 | 261 | $curCloseTags .= '[/s]'; |
| 253 | 262 | $replacement .= '[s]'; |
@@ -259,13 +268,11 @@ discard block |
||
| 259 | 268 | { |
| 260 | 269 | $curCloseTags .= '[/left]'; |
| 261 | 270 | $replacement .= '[left]'; |
| 262 | - } |
|
| 263 | - elseif ($style_value == 'center') |
|
| 271 | + } elseif ($style_value == 'center') |
|
| 264 | 272 | { |
| 265 | 273 | $curCloseTags .= '[/center]'; |
| 266 | 274 | $replacement .= '[center]'; |
| 267 | - } |
|
| 268 | - elseif ($style_value == 'right') |
|
| 275 | + } elseif ($style_value == 'right') |
|
| 269 | 276 | { |
| 270 | 277 | $curCloseTags .= '[/right]'; |
| 271 | 278 | $replacement .= '[right]'; |
@@ -287,8 +294,9 @@ discard block |
||
| 287 | 294 | |
| 288 | 295 | case 'font-size': |
| 289 | 296 | // Sometimes people put decimals where decimals should not be. |
| 290 | - if (preg_match('~(\d)+\.\d+(p[xt])~i', $style_value, $dec_matches) === 1) |
|
| 291 | - $style_value = $dec_matches[1] . $dec_matches[2]; |
|
| 297 | + if (preg_match('~(\d)+\.\d+(p[xt])~i', $style_value, $dec_matches) === 1) { |
|
| 298 | + $style_value = $dec_matches[1] . $dec_matches[2]; |
|
| 299 | + } |
|
| 292 | 300 | |
| 293 | 301 | $curCloseTags .= '[/size]'; |
| 294 | 302 | $replacement .= '[size=' . $style_value . ']'; |
@@ -296,8 +304,9 @@ discard block |
||
| 296 | 304 | |
| 297 | 305 | case 'font-family': |
| 298 | 306 | // Only get the first freaking font if there's a list! |
| 299 | - if (strpos($style_value, ',') !== false) |
|
| 300 | - $style_value = substr($style_value, 0, strpos($style_value, ',')); |
|
| 307 | + if (strpos($style_value, ',') !== false) { |
|
| 308 | + $style_value = substr($style_value, 0, strpos($style_value, ',')); |
|
| 309 | + } |
|
| 301 | 310 | |
| 302 | 311 | $curCloseTags .= '[/font]'; |
| 303 | 312 | $replacement .= '[font=' . strtr($style_value, array("'" => '')) . ']'; |
@@ -306,13 +315,15 @@ discard block |
||
| 306 | 315 | // This is a hack for images with dimensions embedded. |
| 307 | 316 | case 'width': |
| 308 | 317 | case 'height': |
| 309 | - if (preg_match('~[1-9]\d*~i', $style_value, $dimension) === 1) |
|
| 310 | - $extra_attr .= ' ' . $style_type . '="' . $dimension[0] . '"'; |
|
| 318 | + if (preg_match('~[1-9]\d*~i', $style_value, $dimension) === 1) { |
|
| 319 | + $extra_attr .= ' ' . $style_type . '="' . $dimension[0] . '"'; |
|
| 320 | + } |
|
| 311 | 321 | break; |
| 312 | 322 | |
| 313 | 323 | case 'list-style-type': |
| 314 | - 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) |
|
| 315 | - $extra_attr .= ' listtype="' . $listType[0] . '"'; |
|
| 324 | + 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) { |
|
| 325 | + $extra_attr .= ' listtype="' . $listType[0] . '"'; |
|
| 326 | + } |
|
| 316 | 327 | break; |
| 317 | 328 | } |
| 318 | 329 | } |
@@ -325,18 +336,17 @@ discard block |
||
| 325 | 336 | } |
| 326 | 337 | |
| 327 | 338 | // If there's something that still needs closing, push it to the stack. |
| 328 | - if (!empty($curCloseTags)) |
|
| 329 | - array_push($stack, array( |
|
| 339 | + if (!empty($curCloseTags)) { |
|
| 340 | + array_push($stack, array( |
|
| 330 | 341 | 'element' => strtolower($curElement), |
| 331 | 342 | 'closeTags' => $curCloseTags |
| 332 | 343 | ) |
| 333 | 344 | ); |
| 334 | - elseif (!empty($extra_attr)) |
|
| 335 | - $replacement .= $precedingStyle . $extra_attr . $afterStyle; |
|
| 345 | + } elseif (!empty($extra_attr)) { |
|
| 346 | + $replacement .= $precedingStyle . $extra_attr . $afterStyle; |
|
| 347 | + } |
|
| 336 | 348 | } |
| 337 | - } |
|
| 338 | - |
|
| 339 | - elseif (preg_match('~</([A-Za-z]+)>~', $part, $matches) === 1) |
|
| 349 | + } elseif (preg_match('~</([A-Za-z]+)>~', $part, $matches) === 1) |
|
| 340 | 350 | { |
| 341 | 351 | // Is this the element that we've been waiting for to be closed? |
| 342 | 352 | if (!empty($stack) && strtolower($matches[1]) === $stack[count($stack) - 1]['element']) |
@@ -346,28 +356,32 @@ discard block |
||
| 346 | 356 | } |
| 347 | 357 | |
| 348 | 358 | // Must've been something else. |
| 349 | - else |
|
| 350 | - $replacement .= $part; |
|
| 359 | + else { |
|
| 360 | + $replacement .= $part; |
|
| 361 | + } |
|
| 351 | 362 | } |
| 352 | 363 | // In all other cases, just add the part to the replacement. |
| 353 | - else |
|
| 354 | - $replacement .= $part; |
|
| 364 | + else { |
|
| 365 | + $replacement .= $part; |
|
| 366 | + } |
|
| 355 | 367 | } |
| 356 | 368 | |
| 357 | 369 | // Now put back the replacement in the text. |
| 358 | 370 | $text = $replacement; |
| 359 | 371 | |
| 360 | 372 | // We are not finished yet, request more time. |
| 361 | - if (connection_aborted() && $context['server']['is_apache']) |
|
| 362 | - @apache_reset_timeout(); |
|
| 373 | + if (connection_aborted() && $context['server']['is_apache']) { |
|
| 374 | + @apache_reset_timeout(); |
|
| 375 | + } |
|
| 363 | 376 | |
| 364 | 377 | // Let's pull out any legacy alignments. |
| 365 | 378 | while (preg_match('~<([A-Za-z]+)\s+[^<>]*?(align="*(left|center|right)"*)[^<>]*?(/?)>~i', $text, $matches) === 1) |
| 366 | 379 | { |
| 367 | 380 | // Find the position in the text of this tag over again. |
| 368 | 381 | $start_pos = strpos($text, $matches[0]); |
| 369 | - if ($start_pos === false) |
|
| 370 | - break; |
|
| 382 | + if ($start_pos === false) { |
|
| 383 | + break; |
|
| 384 | + } |
|
| 371 | 385 | |
| 372 | 386 | // End tag? |
| 373 | 387 | if ($matches[4] != '/' && strpos($text, '</' . $matches[1] . '>', $start_pos) !== false) |
@@ -382,8 +396,7 @@ discard block |
||
| 382 | 396 | |
| 383 | 397 | // Put the tags back into the body. |
| 384 | 398 | $text = substr($text, 0, $start_pos) . $tag . '[' . $matches[3] . ']' . $content . '[/' . $matches[3] . ']' . substr($text, $end_pos); |
| 385 | - } |
|
| 386 | - else |
|
| 399 | + } else |
|
| 387 | 400 | { |
| 388 | 401 | // Just get rid of this evil tag. |
| 389 | 402 | $text = substr($text, 0, $start_pos) . substr($text, $start_pos + strlen($matches[0])); |
@@ -396,8 +409,9 @@ discard block |
||
| 396 | 409 | // Find the position of this again. |
| 397 | 410 | $start_pos = strpos($text, $matches[0]); |
| 398 | 411 | $end_pos = false; |
| 399 | - if ($start_pos === false) |
|
| 400 | - break; |
|
| 412 | + if ($start_pos === false) { |
|
| 413 | + break; |
|
| 414 | + } |
|
| 401 | 415 | |
| 402 | 416 | // This must have an end tag - and we must find the right one. |
| 403 | 417 | $lower_text = strtolower($text); |
@@ -430,8 +444,9 @@ discard block |
||
| 430 | 444 | break; |
| 431 | 445 | } |
| 432 | 446 | } |
| 433 | - if ($end_pos === false) |
|
| 434 | - break; |
|
| 447 | + if ($end_pos === false) { |
|
| 448 | + break; |
|
| 449 | + } |
|
| 435 | 450 | |
| 436 | 451 | // Now work out what the attributes are. |
| 437 | 452 | $attribs = fetchTagAttributes($matches[1]); |
@@ -445,11 +460,11 @@ discard block |
||
| 445 | 460 | $v = (int) trim($v); |
| 446 | 461 | $v = empty($v) ? 1 : $v; |
| 447 | 462 | $tags[] = array('[size=' . $sizes_equivalence[$v] . ']', '[/size]'); |
| 463 | + } elseif ($s == 'face') { |
|
| 464 | + $tags[] = array('[font=' . trim(strtolower($v)) . ']', '[/font]'); |
|
| 465 | + } elseif ($s == 'color') { |
|
| 466 | + $tags[] = array('[color=' . trim(strtolower($v)) . ']', '[/color]'); |
|
| 448 | 467 | } |
| 449 | - elseif ($s == 'face') |
|
| 450 | - $tags[] = array('[font=' . trim(strtolower($v)) . ']', '[/font]'); |
|
| 451 | - elseif ($s == 'color') |
|
| 452 | - $tags[] = array('[color=' . trim(strtolower($v)) . ']', '[/color]'); |
|
| 453 | 468 | } |
| 454 | 469 | |
| 455 | 470 | // As before add in our tags. |
@@ -457,8 +472,9 @@ discard block |
||
| 457 | 472 | foreach ($tags as $tag) |
| 458 | 473 | { |
| 459 | 474 | $before .= $tag[0]; |
| 460 | - if (isset($tag[1])) |
|
| 461 | - $after = $tag[1] . $after; |
|
| 475 | + if (isset($tag[1])) { |
|
| 476 | + $after = $tag[1] . $after; |
|
| 477 | + } |
|
| 462 | 478 | } |
| 463 | 479 | |
| 464 | 480 | // Remove the tag so it's never checked again. |
@@ -469,8 +485,9 @@ discard block |
||
| 469 | 485 | } |
| 470 | 486 | |
| 471 | 487 | // Almost there, just a little more time. |
| 472 | - if (connection_aborted() && $context['server']['is_apache']) |
|
| 473 | - @apache_reset_timeout(); |
|
| 488 | + if (connection_aborted() && $context['server']['is_apache']) { |
|
| 489 | + @apache_reset_timeout(); |
|
| 490 | + } |
|
| 474 | 491 | |
| 475 | 492 | if (count($parts = preg_split('~<(/?)(li|ol|ul)([^>]*)>~i', $text, null, PREG_SPLIT_DELIM_CAPTURE)) > 1) |
| 476 | 493 | { |
@@ -526,12 +543,13 @@ discard block |
||
| 526 | 543 | { |
| 527 | 544 | $inList = true; |
| 528 | 545 | |
| 529 | - if ($tag === 'ol') |
|
| 530 | - $listType = 'decimal'; |
|
| 531 | - elseif (preg_match('~type="?(' . implode('|', array_keys($listTypeMapping)) . ')"?~', $parts[$i + 3], $match) === 1) |
|
| 532 | - $listType = $listTypeMapping[$match[1]]; |
|
| 533 | - else |
|
| 534 | - $listType = null; |
|
| 546 | + if ($tag === 'ol') { |
|
| 547 | + $listType = 'decimal'; |
|
| 548 | + } elseif (preg_match('~type="?(' . implode('|', array_keys($listTypeMapping)) . ')"?~', $parts[$i + 3], $match) === 1) { |
|
| 549 | + $listType = $listTypeMapping[$match[1]]; |
|
| 550 | + } else { |
|
| 551 | + $listType = null; |
|
| 552 | + } |
|
| 535 | 553 | |
| 536 | 554 | $listDepth++; |
| 537 | 555 | |
@@ -595,9 +613,7 @@ discard block |
||
| 595 | 613 | $parts[$i + 1] = ''; |
| 596 | 614 | $parts[$i + 2] = str_repeat("\t", $listDepth) . '[/list]'; |
| 597 | 615 | $parts[$i + 3] = ''; |
| 598 | - } |
|
| 599 | - |
|
| 600 | - else |
|
| 616 | + } else |
|
| 601 | 617 | { |
| 602 | 618 | // We're in a list item. |
| 603 | 619 | if ($listDepth > 0) |
@@ -634,9 +650,7 @@ discard block |
||
| 634 | 650 | $parts[$i + 1] = ''; |
| 635 | 651 | $parts[$i + 2] = ''; |
| 636 | 652 | $parts[$i + 3] = ''; |
| 637 | - } |
|
| 638 | - |
|
| 639 | - else |
|
| 653 | + } else |
|
| 640 | 654 | { |
| 641 | 655 | // Remove the trailing breaks from the list item. |
| 642 | 656 | $parts[$i] = preg_replace('~\s*<br\s*' . '/?' . '>\s*$~', '', $parts[$i]); |
@@ -674,8 +688,9 @@ discard block |
||
| 674 | 688 | $text .= str_repeat("\t", $listDepth) . '[/list]'; |
| 675 | 689 | } |
| 676 | 690 | |
| 677 | - for ($i = $listDepth; $i > 0; $i--) |
|
| 678 | - $text .= '[/li]' . "\n" . str_repeat("\t", $i - 1) . '[/list]'; |
|
| 691 | + for ($i = $listDepth; $i > 0; $i--) { |
|
| 692 | + $text .= '[/li]' . "\n" . str_repeat("\t", $i - 1) . '[/list]'; |
|
| 693 | + } |
|
| 679 | 694 | |
| 680 | 695 | } |
| 681 | 696 | |
@@ -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 = ''; |
@@ -695,12 +711,13 @@ discard block |
||
| 695 | 711 | $attrs = fetchTagAttributes($matches[1]); |
| 696 | 712 | foreach ($attrs as $attrib => $value) |
| 697 | 713 | { |
| 698 | - if (in_array($attrib, array('width', 'height'))) |
|
| 699 | - $params .= ' ' . $attrib . '=' . (int) $value; |
|
| 700 | - elseif ($attrib == 'alt' && trim($value) != '') |
|
| 701 | - $params .= ' alt=' . trim($value); |
|
| 702 | - elseif ($attrib == 'src') |
|
| 703 | - $src = trim($value); |
|
| 714 | + if (in_array($attrib, array('width', 'height'))) { |
|
| 715 | + $params .= ' ' . $attrib . '=' . (int) $value; |
|
| 716 | + } elseif ($attrib == 'alt' && trim($value) != '') { |
|
| 717 | + $params .= ' alt=' . trim($value); |
|
| 718 | + } elseif ($attrib == 'src') { |
|
| 719 | + $src = trim($value); |
|
| 720 | + } |
|
| 704 | 721 | } |
| 705 | 722 | |
| 706 | 723 | $tag = ''; |
@@ -711,10 +728,11 @@ discard block |
||
| 711 | 728 | { |
| 712 | 729 | $baseURL = (isset($parsedURL['scheme']) ? $parsedURL['scheme'] : 'http') . '://' . $parsedURL['host'] . (empty($parsedURL['port']) ? '' : ':' . $parsedURL['port']); |
| 713 | 730 | |
| 714 | - if (substr($src, 0, 1) === '/') |
|
| 715 | - $src = $baseURL . $src; |
|
| 716 | - else |
|
| 717 | - $src = $baseURL . (empty($parsedURL['path']) ? '/' : preg_replace('~/(?:index\\.php)?$~', '', $parsedURL['path'])) . '/' . $src; |
|
| 731 | + if (substr($src, 0, 1) === '/') { |
|
| 732 | + $src = $baseURL . $src; |
|
| 733 | + } else { |
|
| 734 | + $src = $baseURL . (empty($parsedURL['path']) ? '/' : preg_replace('~/(?:index\\.php)?$~', '', $parsedURL['path'])) . '/' . $src; |
|
| 735 | + } |
|
| 718 | 736 | } |
| 719 | 737 | |
| 720 | 738 | $tag = '[img' . $params . ']' . $src . '[/img]'; |
@@ -892,20 +910,23 @@ discard block |
||
| 892 | 910 | }, |
| 893 | 911 | ); |
| 894 | 912 | |
| 895 | - foreach ($tags as $tag => $replace) |
|
| 896 | - $text = preg_replace_callback($tag, $replace, $text); |
|
| 913 | + foreach ($tags as $tag => $replace) { |
|
| 914 | + $text = preg_replace_callback($tag, $replace, $text); |
|
| 915 | + } |
|
| 897 | 916 | |
| 898 | 917 | // Please give us just a little more time. |
| 899 | - if (connection_aborted() && $context['server']['is_apache']) |
|
| 900 | - @apache_reset_timeout(); |
|
| 918 | + if (connection_aborted() && $context['server']['is_apache']) { |
|
| 919 | + @apache_reset_timeout(); |
|
| 920 | + } |
|
| 901 | 921 | |
| 902 | 922 | // What about URL's - the pain in the ass of the tag world. |
| 903 | 923 | while (preg_match('~<a\s+([^<>]*)>([^<>]*)</a>~i', $text, $matches) === 1) |
| 904 | 924 | { |
| 905 | 925 | // Find the position of the URL. |
| 906 | 926 | $start_pos = strpos($text, $matches[0]); |
| 907 | - if ($start_pos === false) |
|
| 908 | - break; |
|
| 927 | + if ($start_pos === false) { |
|
| 928 | + break; |
|
| 929 | + } |
|
| 909 | 930 | $end_pos = $start_pos + strlen($matches[0]); |
| 910 | 931 | |
| 911 | 932 | $tag_type = 'url'; |
@@ -919,8 +940,9 @@ discard block |
||
| 919 | 940 | $href = trim($value); |
| 920 | 941 | |
| 921 | 942 | // Are we dealing with an FTP link? |
| 922 | - if (preg_match('~^ftps?://~', $href) === 1) |
|
| 923 | - $tag_type = 'ftp'; |
|
| 943 | + if (preg_match('~^ftps?://~', $href) === 1) { |
|
| 944 | + $tag_type = 'ftp'; |
|
| 945 | + } |
|
| 924 | 946 | |
| 925 | 947 | // Or is this a link to an email address? |
| 926 | 948 | elseif (substr($href, 0, 7) == 'mailto:') |
@@ -934,28 +956,31 @@ discard block |
||
| 934 | 956 | { |
| 935 | 957 | $baseURL = (isset($parsedURL['scheme']) ? $parsedURL['scheme'] : 'http') . '://' . $parsedURL['host'] . (empty($parsedURL['port']) ? '' : ':' . $parsedURL['port']); |
| 936 | 958 | |
| 937 | - if (substr($href, 0, 1) === '/') |
|
| 938 | - $href = $baseURL . $href; |
|
| 939 | - else |
|
| 940 | - $href = $baseURL . (empty($parsedURL['path']) ? '/' : preg_replace('~/(?:index\\.php)?$~', '', $parsedURL['path'])) . '/' . $href; |
|
| 959 | + if (substr($href, 0, 1) === '/') { |
|
| 960 | + $href = $baseURL . $href; |
|
| 961 | + } else { |
|
| 962 | + $href = $baseURL . (empty($parsedURL['path']) ? '/' : preg_replace('~/(?:index\\.php)?$~', '', $parsedURL['path'])) . '/' . $href; |
|
| 963 | + } |
|
| 941 | 964 | } |
| 942 | 965 | } |
| 943 | 966 | |
| 944 | 967 | // External URL? |
| 945 | 968 | if ($attrib == 'target' && $tag_type == 'url') |
| 946 | 969 | { |
| 947 | - if (trim($value) == '_blank') |
|
| 948 | - $tag_type == 'iurl'; |
|
| 970 | + if (trim($value) == '_blank') { |
|
| 971 | + $tag_type == 'iurl'; |
|
| 972 | + } |
|
| 949 | 973 | } |
| 950 | 974 | } |
| 951 | 975 | |
| 952 | 976 | $tag = ''; |
| 953 | 977 | if ($href != '') |
| 954 | 978 | { |
| 955 | - if ($matches[2] == $href) |
|
| 956 | - $tag = '[' . $tag_type . ']' . $href . '[/' . $tag_type . ']'; |
|
| 957 | - else |
|
| 958 | - $tag = '[' . $tag_type . '=' . $href . ']' . $matches[2] . '[/' . $tag_type . ']'; |
|
| 979 | + if ($matches[2] == $href) { |
|
| 980 | + $tag = '[' . $tag_type . ']' . $href . '[/' . $tag_type . ']'; |
|
| 981 | + } else { |
|
| 982 | + $tag = '[' . $tag_type . '=' . $href . ']' . $matches[2] . '[/' . $tag_type . ']'; |
|
| 983 | + } |
|
| 959 | 984 | } |
| 960 | 985 | |
| 961 | 986 | // Replace the tag |
@@ -995,17 +1020,18 @@ discard block |
||
| 995 | 1020 | // We're either moving from the key to the attribute or we're in a string and this is fine. |
| 996 | 1021 | if ($text[$i] == '=') |
| 997 | 1022 | { |
| 998 | - if ($tag_state == 0) |
|
| 999 | - $tag_state = 1; |
|
| 1000 | - elseif ($tag_state == 2) |
|
| 1001 | - $value .= '='; |
|
| 1023 | + if ($tag_state == 0) { |
|
| 1024 | + $tag_state = 1; |
|
| 1025 | + } elseif ($tag_state == 2) { |
|
| 1026 | + $value .= '='; |
|
| 1027 | + } |
|
| 1002 | 1028 | } |
| 1003 | 1029 | // A space is either moving from an attribute back to a potential key or in a string is fine. |
| 1004 | 1030 | elseif ($text[$i] == ' ') |
| 1005 | 1031 | { |
| 1006 | - if ($tag_state == 2) |
|
| 1007 | - $value .= ' '; |
|
| 1008 | - elseif ($tag_state == 1) |
|
| 1032 | + if ($tag_state == 2) { |
|
| 1033 | + $value .= ' '; |
|
| 1034 | + } elseif ($tag_state == 1) |
|
| 1009 | 1035 | { |
| 1010 | 1036 | $attribs[$key] = $value; |
| 1011 | 1037 | $key = $value = ''; |
@@ -1016,24 +1042,27 @@ discard block |
||
| 1016 | 1042 | elseif ($text[$i] == '"') |
| 1017 | 1043 | { |
| 1018 | 1044 | // Must be either going into or out of a string. |
| 1019 | - if ($tag_state == 1) |
|
| 1020 | - $tag_state = 2; |
|
| 1021 | - else |
|
| 1022 | - $tag_state = 1; |
|
| 1045 | + if ($tag_state == 1) { |
|
| 1046 | + $tag_state = 2; |
|
| 1047 | + } else { |
|
| 1048 | + $tag_state = 1; |
|
| 1049 | + } |
|
| 1023 | 1050 | } |
| 1024 | 1051 | // Otherwise it's fine. |
| 1025 | 1052 | else |
| 1026 | 1053 | { |
| 1027 | - if ($tag_state == 0) |
|
| 1028 | - $key .= $text[$i]; |
|
| 1029 | - else |
|
| 1030 | - $value .= $text[$i]; |
|
| 1054 | + if ($tag_state == 0) { |
|
| 1055 | + $key .= $text[$i]; |
|
| 1056 | + } else { |
|
| 1057 | + $value .= $text[$i]; |
|
| 1058 | + } |
|
| 1031 | 1059 | } |
| 1032 | 1060 | } |
| 1033 | 1061 | |
| 1034 | 1062 | // Anything left? |
| 1035 | - if ($key != '' && $value != '') |
|
| 1036 | - $attribs[$key] = $value; |
|
| 1063 | + if ($key != '' && $value != '') { |
|
| 1064 | + $attribs[$key] = $value; |
|
| 1065 | + } |
|
| 1037 | 1066 | |
| 1038 | 1067 | return $attribs; |
| 1039 | 1068 | } |
@@ -1049,8 +1078,9 @@ discard block |
||
| 1049 | 1078 | global $modSettings; |
| 1050 | 1079 | |
| 1051 | 1080 | // Don't care about the texts that are too short. |
| 1052 | - if (strlen($text) < 3) |
|
| 1053 | - return $text; |
|
| 1081 | + if (strlen($text) < 3) { |
|
| 1082 | + return $text; |
|
| 1083 | + } |
|
| 1054 | 1084 | |
| 1055 | 1085 | // We are going to cycle through the BBC and keep track of tags as they arise - in order. If get to a block level tag we're going to make sure it's not in a non-block level tag! |
| 1056 | 1086 | // This will keep the order of tags that are open. |
@@ -1063,8 +1093,9 @@ discard block |
||
| 1063 | 1093 | $disabled = empty($modSettings['disabledBBC']) ? array() : array_flip(explode(',', strtolower($modSettings['disabledBBC']))); |
| 1064 | 1094 | |
| 1065 | 1095 | // Add flash if it's disabled as embedded tag. |
| 1066 | - if (empty($modSettings['enableEmbeddedFlash'])) |
|
| 1067 | - $disabled['flash'] = true; |
|
| 1096 | + if (empty($modSettings['enableEmbeddedFlash'])) { |
|
| 1097 | + $disabled['flash'] = true; |
|
| 1098 | + } |
|
| 1068 | 1099 | |
| 1069 | 1100 | // Get a list of all the tags that are not disabled. |
| 1070 | 1101 | $all_tags = parse_bbc(false); |
@@ -1072,10 +1103,12 @@ discard block |
||
| 1072 | 1103 | $self_closing_tags = array(); |
| 1073 | 1104 | foreach ($all_tags as $tag) |
| 1074 | 1105 | { |
| 1075 | - if (!isset($disabled[$tag['tag']])) |
|
| 1076 | - $valid_tags[$tag['tag']] = !empty($tag['block_level']); |
|
| 1077 | - if (isset($tag['type']) && $tag['type'] == 'closed') |
|
| 1078 | - $self_closing_tags[] = $tag['tag']; |
|
| 1106 | + if (!isset($disabled[$tag['tag']])) { |
|
| 1107 | + $valid_tags[$tag['tag']] = !empty($tag['block_level']); |
|
| 1108 | + } |
|
| 1109 | + if (isset($tag['type']) && $tag['type'] == 'closed') { |
|
| 1110 | + $self_closing_tags[] = $tag['tag']; |
|
| 1111 | + } |
|
| 1079 | 1112 | } |
| 1080 | 1113 | |
| 1081 | 1114 | // Don't worry if we're in a code/nobbc. |
@@ -1105,16 +1138,19 @@ discard block |
||
| 1105 | 1138 | $tagName = substr($match, $isClosingTag ? 2 : 1, -1); |
| 1106 | 1139 | |
| 1107 | 1140 | // We're closing the exact same tag that we opened. |
| 1108 | - if ($isClosingTag && $insideTag === $tagName) |
|
| 1109 | - $insideTag = null; |
|
| 1141 | + if ($isClosingTag && $insideTag === $tagName) { |
|
| 1142 | + $insideTag = null; |
|
| 1143 | + } |
|
| 1110 | 1144 | |
| 1111 | 1145 | // We're opening a tag and we're not yet inside one either |
| 1112 | - elseif (!$isClosingTag && $insideTag === null) |
|
| 1113 | - $insideTag = $tagName; |
|
| 1146 | + elseif (!$isClosingTag && $insideTag === null) { |
|
| 1147 | + $insideTag = $tagName; |
|
| 1148 | + } |
|
| 1114 | 1149 | |
| 1115 | 1150 | // In all other cases, this tag must be invalid |
| 1116 | - else |
|
| 1117 | - unset($matches[$i]); |
|
| 1151 | + else { |
|
| 1152 | + unset($matches[$i]); |
|
| 1153 | + } |
|
| 1118 | 1154 | } |
| 1119 | 1155 | |
| 1120 | 1156 | // The next one is gonna be the other one. |
@@ -1122,8 +1158,9 @@ discard block |
||
| 1122 | 1158 | } |
| 1123 | 1159 | |
| 1124 | 1160 | // We're still inside a tag and had no chance for closure? |
| 1125 | - if ($insideTag !== null) |
|
| 1126 | - $matches[] = '[/' . $insideTag . ']'; |
|
| 1161 | + if ($insideTag !== null) { |
|
| 1162 | + $matches[] = '[/' . $insideTag . ']'; |
|
| 1163 | + } |
|
| 1127 | 1164 | |
| 1128 | 1165 | // And a complete text string again. |
| 1129 | 1166 | $text = implode('', $matches); |
@@ -1132,8 +1169,9 @@ discard block |
||
| 1132 | 1169 | // Quickly remove any tags which are back to back. |
| 1133 | 1170 | $backToBackPattern = '~\\[(' . implode('|', array_diff(array_keys($valid_tags), array('td', 'anchor'))) . ')[^<>\\[\\]]*\\]\s*\\[/\\1\\]~'; |
| 1134 | 1171 | $lastlen = 0; |
| 1135 | - while (strlen($text) !== $lastlen) |
|
| 1136 | - $lastlen = strlen($text = preg_replace($backToBackPattern, '', $text)); |
|
| 1172 | + while (strlen($text) !== $lastlen) { |
|
| 1173 | + $lastlen = strlen($text = preg_replace($backToBackPattern, '', $text)); |
|
| 1174 | + } |
|
| 1137 | 1175 | |
| 1138 | 1176 | // Need to sort the tags my name length. |
| 1139 | 1177 | uksort($valid_tags, 'sort_array_length'); |
@@ -1177,8 +1215,9 @@ discard block |
||
| 1177 | 1215 | $isCompetingTag = in_array($tag, $competing_tags); |
| 1178 | 1216 | |
| 1179 | 1217 | // Check if this might be one of those cleaned out tags. |
| 1180 | - if ($tag === '') |
|
| 1181 | - continue; |
|
| 1218 | + if ($tag === '') { |
|
| 1219 | + continue; |
|
| 1220 | + } |
|
| 1182 | 1221 | |
| 1183 | 1222 | // Special case: inside [code] blocks any code is left untouched. |
| 1184 | 1223 | elseif ($tag === 'code') |
@@ -1189,8 +1228,9 @@ discard block |
||
| 1189 | 1228 | $inCode = false; |
| 1190 | 1229 | |
| 1191 | 1230 | // Reopen tags that were closed before the code block. |
| 1192 | - if (!empty($inlineElements)) |
|
| 1193 | - $parts[$i + 4] .= '[' . implode('][', array_keys($inlineElements)) . ']'; |
|
| 1231 | + if (!empty($inlineElements)) { |
|
| 1232 | + $parts[$i + 4] .= '[' . implode('][', array_keys($inlineElements)) . ']'; |
|
| 1233 | + } |
|
| 1194 | 1234 | } |
| 1195 | 1235 | |
| 1196 | 1236 | // We're outside a coding and nobbc block and opening it. |
@@ -1219,8 +1259,9 @@ discard block |
||
| 1219 | 1259 | $inNoBbc = false; |
| 1220 | 1260 | |
| 1221 | 1261 | // Some inline elements might've been closed that need reopening. |
| 1222 | - if (!empty($inlineElements)) |
|
| 1223 | - $parts[$i + 4] .= '[' . implode('][', array_keys($inlineElements)) . ']'; |
|
| 1262 | + if (!empty($inlineElements)) { |
|
| 1263 | + $parts[$i + 4] .= '[' . implode('][', array_keys($inlineElements)) . ']'; |
|
| 1264 | + } |
|
| 1224 | 1265 | } |
| 1225 | 1266 | |
| 1226 | 1267 | // We're outside a nobbc and coding block and opening it. |
@@ -1240,8 +1281,9 @@ discard block |
||
| 1240 | 1281 | } |
| 1241 | 1282 | |
| 1242 | 1283 | // So, we're inside one of the special blocks: ignore any tag. |
| 1243 | - elseif ($inCode || $inNoBbc) |
|
| 1244 | - continue; |
|
| 1284 | + elseif ($inCode || $inNoBbc) { |
|
| 1285 | + continue; |
|
| 1286 | + } |
|
| 1245 | 1287 | |
| 1246 | 1288 | // We're dealing with an opening tag. |
| 1247 | 1289 | if ($isOpeningTag) |
@@ -1282,8 +1324,9 @@ discard block |
||
| 1282 | 1324 | if ($parts[$j + 3] === $tag) |
| 1283 | 1325 | { |
| 1284 | 1326 | // If it's an opening tag, increase the level. |
| 1285 | - if ($parts[$j + 2] === '') |
|
| 1286 | - $curLevel++; |
|
| 1327 | + if ($parts[$j + 2] === '') { |
|
| 1328 | + $curLevel++; |
|
| 1329 | + } |
|
| 1287 | 1330 | |
| 1288 | 1331 | // A closing tag, decrease the level. |
| 1289 | 1332 | else |
@@ -1306,13 +1349,15 @@ discard block |
||
| 1306 | 1349 | { |
| 1307 | 1350 | if ($isCompetingTag) |
| 1308 | 1351 | { |
| 1309 | - if (!isset($competingElements[$tag])) |
|
| 1310 | - $competingElements[$tag] = array(); |
|
| 1352 | + if (!isset($competingElements[$tag])) { |
|
| 1353 | + $competingElements[$tag] = array(); |
|
| 1354 | + } |
|
| 1311 | 1355 | |
| 1312 | 1356 | $competingElements[$tag][] = $parts[$i + 4]; |
| 1313 | 1357 | |
| 1314 | - if (count($competingElements[$tag]) > 1) |
|
| 1315 | - $parts[$i] .= '[/' . $tag . ']'; |
|
| 1358 | + if (count($competingElements[$tag]) > 1) { |
|
| 1359 | + $parts[$i] .= '[/' . $tag . ']'; |
|
| 1360 | + } |
|
| 1316 | 1361 | } |
| 1317 | 1362 | |
| 1318 | 1363 | $inlineElements[$elementContent] = $tag; |
@@ -1333,15 +1378,17 @@ discard block |
||
| 1333 | 1378 | $addClosingTags = array(); |
| 1334 | 1379 | while ($element = array_pop($blockElements)) |
| 1335 | 1380 | { |
| 1336 | - if ($element === $tag) |
|
| 1337 | - break; |
|
| 1381 | + if ($element === $tag) { |
|
| 1382 | + break; |
|
| 1383 | + } |
|
| 1338 | 1384 | |
| 1339 | 1385 | // Still a block tag was open not equal to this tag. |
| 1340 | 1386 | $addClosingTags[] = $element['type']; |
| 1341 | 1387 | } |
| 1342 | 1388 | |
| 1343 | - if (!empty($addClosingTags)) |
|
| 1344 | - $parts[$i + 1] = '[/' . implode('][/', array_reverse($addClosingTags)) . ']' . $parts[$i + 1]; |
|
| 1389 | + if (!empty($addClosingTags)) { |
|
| 1390 | + $parts[$i + 1] = '[/' . implode('][/', array_reverse($addClosingTags)) . ']' . $parts[$i + 1]; |
|
| 1391 | + } |
|
| 1345 | 1392 | |
| 1346 | 1393 | // Apparently the closing tag was not found on the stack. |
| 1347 | 1394 | if (!is_string($element) || $element !== $tag) |
@@ -1351,8 +1398,7 @@ discard block |
||
| 1351 | 1398 | $parts[$i + 2] = $parts[$i + 3] = $parts[$i + 4] = ''; |
| 1352 | 1399 | continue; |
| 1353 | 1400 | } |
| 1354 | - } |
|
| 1355 | - else |
|
| 1401 | + } else |
|
| 1356 | 1402 | { |
| 1357 | 1403 | // Get rid of this closing tag! |
| 1358 | 1404 | $parts[$i + 1] = $parts[$i + 2] = $parts[$i + 3] = $parts[$i + 4] = ''; |
@@ -1381,53 +1427,62 @@ discard block |
||
| 1381 | 1427 | unset($inlineElements[$tagContentToBeClosed]); |
| 1382 | 1428 | |
| 1383 | 1429 | // Was this the tag we were looking for? |
| 1384 | - if ($tagToBeClosed === $tag) |
|
| 1385 | - break; |
|
| 1430 | + if ($tagToBeClosed === $tag) { |
|
| 1431 | + break; |
|
| 1432 | + } |
|
| 1386 | 1433 | |
| 1387 | 1434 | // Nope, close it and look further! |
| 1388 | - else |
|
| 1389 | - $parts[$i] .= '[/' . $tagToBeClosed . ']'; |
|
| 1435 | + else { |
|
| 1436 | + $parts[$i] .= '[/' . $tagToBeClosed . ']'; |
|
| 1437 | + } |
|
| 1390 | 1438 | } |
| 1391 | 1439 | |
| 1392 | 1440 | if ($isCompetingTag && !empty($competingElements[$tag])) |
| 1393 | 1441 | { |
| 1394 | 1442 | array_pop($competingElements[$tag]); |
| 1395 | 1443 | |
| 1396 | - if (count($competingElements[$tag]) > 0) |
|
| 1397 | - $parts[$i + 5] = '[' . $tag . $competingElements[$tag][count($competingElements[$tag]) - 1] . $parts[$i + 5]; |
|
| 1444 | + if (count($competingElements[$tag]) > 0) { |
|
| 1445 | + $parts[$i + 5] = '[' . $tag . $competingElements[$tag][count($competingElements[$tag]) - 1] . $parts[$i + 5]; |
|
| 1446 | + } |
|
| 1398 | 1447 | } |
| 1399 | 1448 | } |
| 1400 | 1449 | |
| 1401 | 1450 | // Unexpected closing tag, ex-ter-mi-nate. |
| 1402 | - else |
|
| 1403 | - $parts[$i + 1] = $parts[$i + 2] = $parts[$i + 3] = $parts[$i + 4] = ''; |
|
| 1451 | + else { |
|
| 1452 | + $parts[$i + 1] = $parts[$i + 2] = $parts[$i + 3] = $parts[$i + 4] = ''; |
|
| 1453 | + } |
|
| 1404 | 1454 | } |
| 1405 | 1455 | } |
| 1406 | 1456 | } |
| 1407 | 1457 | |
| 1408 | 1458 | // Close the code tags. |
| 1409 | - if ($inCode) |
|
| 1410 | - $parts[$i] .= '[/code]'; |
|
| 1459 | + if ($inCode) { |
|
| 1460 | + $parts[$i] .= '[/code]'; |
|
| 1461 | + } |
|
| 1411 | 1462 | |
| 1412 | 1463 | // The same for nobbc tags. |
| 1413 | - elseif ($inNoBbc) |
|
| 1414 | - $parts[$i] .= '[/nobbc]'; |
|
| 1464 | + elseif ($inNoBbc) { |
|
| 1465 | + $parts[$i] .= '[/nobbc]'; |
|
| 1466 | + } |
|
| 1415 | 1467 | |
| 1416 | 1468 | // Still inline tags left unclosed? Close them now, better late than never. |
| 1417 | - elseif (!empty($inlineElements)) |
|
| 1418 | - $parts[$i] .= '[/' . implode('][/', array_reverse($inlineElements)) . ']'; |
|
| 1469 | + elseif (!empty($inlineElements)) { |
|
| 1470 | + $parts[$i] .= '[/' . implode('][/', array_reverse($inlineElements)) . ']'; |
|
| 1471 | + } |
|
| 1419 | 1472 | |
| 1420 | 1473 | // Now close the block elements. |
| 1421 | - if (!empty($blockElements)) |
|
| 1422 | - $parts[$i] .= '[/' . implode('][/', array_reverse($blockElements)) . ']'; |
|
| 1474 | + if (!empty($blockElements)) { |
|
| 1475 | + $parts[$i] .= '[/' . implode('][/', array_reverse($blockElements)) . ']'; |
|
| 1476 | + } |
|
| 1423 | 1477 | |
| 1424 | 1478 | $text = implode('', $parts); |
| 1425 | 1479 | } |
| 1426 | 1480 | |
| 1427 | 1481 | // Final clean up of back to back tags. |
| 1428 | 1482 | $lastlen = 0; |
| 1429 | - while (strlen($text) !== $lastlen) |
|
| 1430 | - $lastlen = strlen($text = preg_replace($backToBackPattern, '', $text)); |
|
| 1483 | + while (strlen($text) !== $lastlen) { |
|
| 1484 | + $lastlen = strlen($text = preg_replace($backToBackPattern, '', $text)); |
|
| 1485 | + } |
|
| 1431 | 1486 | |
| 1432 | 1487 | return $text; |
| 1433 | 1488 | } |
@@ -1456,22 +1511,25 @@ discard block |
||
| 1456 | 1511 | $context['template_layers'] = array(); |
| 1457 | 1512 | // Lets make sure we aren't going to output anything nasty. |
| 1458 | 1513 | @ob_end_clean(); |
| 1459 | - if (!empty($modSettings['enableCompressedOutput'])) |
|
| 1460 | - @ob_start('ob_gzhandler'); |
|
| 1461 | - else |
|
| 1462 | - @ob_start(); |
|
| 1514 | + if (!empty($modSettings['enableCompressedOutput'])) { |
|
| 1515 | + @ob_start('ob_gzhandler'); |
|
| 1516 | + } else { |
|
| 1517 | + @ob_start(); |
|
| 1518 | + } |
|
| 1463 | 1519 | |
| 1464 | 1520 | // If we don't have any locale better avoid broken js |
| 1465 | - if (empty($txt['lang_locale'])) |
|
| 1466 | - die(); |
|
| 1521 | + if (empty($txt['lang_locale'])) { |
|
| 1522 | + die(); |
|
| 1523 | + } |
|
| 1467 | 1524 | |
| 1468 | 1525 | $file_data = '(function ($) { |
| 1469 | 1526 | \'use strict\'; |
| 1470 | 1527 | |
| 1471 | 1528 | $.sceditor.locale[' . javaScriptEscape($txt['lang_locale']) . '] = {'; |
| 1472 | - foreach ($editortxt as $key => $val) |
|
| 1473 | - $file_data .= ' |
|
| 1529 | + foreach ($editortxt as $key => $val) { |
|
| 1530 | + $file_data .= ' |
|
| 1474 | 1531 | ' . javaScriptEscape($key) . ': ' . javaScriptEscape($val) . ','; |
| 1532 | + } |
|
| 1475 | 1533 | |
| 1476 | 1534 | $file_data .= ' |
| 1477 | 1535 | dateFormat: "day.month.year" |
@@ -1539,8 +1597,9 @@ discard block |
||
| 1539 | 1597 | ) |
| 1540 | 1598 | ); |
| 1541 | 1599 | $icon_data = array(); |
| 1542 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1543 | - $icon_data[] = $row; |
|
| 1600 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1601 | + $icon_data[] = $row; |
|
| 1602 | + } |
|
| 1544 | 1603 | $smcFunc['db_free_result']($request); |
| 1545 | 1604 | |
| 1546 | 1605 | $icons = array(); |
@@ -1555,9 +1614,9 @@ discard block |
||
| 1555 | 1614 | } |
| 1556 | 1615 | |
| 1557 | 1616 | cache_put_data('posting_icons-' . $board_id, $icons, 480); |
| 1617 | + } else { |
|
| 1618 | + $icons = $temp; |
|
| 1558 | 1619 | } |
| 1559 | - else |
|
| 1560 | - $icons = $temp; |
|
| 1561 | 1620 | } |
| 1562 | 1621 | call_integration_hook('integrate_load_message_icons', array(&$icons)); |
| 1563 | 1622 | |
@@ -1598,8 +1657,9 @@ discard block |
||
| 1598 | 1657 | { |
| 1599 | 1658 | // Some general stuff. |
| 1600 | 1659 | $settings['smileys_url'] = $modSettings['smileys_url'] . '/' . $user_info['smiley_set']; |
| 1601 | - if (!empty($context['drafts_autosave'])) |
|
| 1602 | - $context['drafts_autosave_frequency'] = empty($modSettings['drafts_autosave_frequency']) ? 60000 : $modSettings['drafts_autosave_frequency'] * 1000; |
|
| 1660 | + if (!empty($context['drafts_autosave'])) { |
|
| 1661 | + $context['drafts_autosave_frequency'] = empty($modSettings['drafts_autosave_frequency']) ? 60000 : $modSettings['drafts_autosave_frequency'] * 1000; |
|
| 1662 | + } |
|
| 1603 | 1663 | |
| 1604 | 1664 | // This really has some WYSIWYG stuff. |
| 1605 | 1665 | loadCSSFile('jquery.sceditor.css', array('force_current' => false, 'validate' => true), 'smf_jquery_sceditor'); |
@@ -1615,8 +1675,9 @@ discard block |
||
| 1615 | 1675 | var bbc_quote = \'' . addcslashes($txt['quote'], "'") . '\'; |
| 1616 | 1676 | var bbc_search_on = \'' . addcslashes($txt['search_on'], "'") . '\';'); |
| 1617 | 1677 | // editor language file |
| 1618 | - if (!empty($txt['lang_locale']) && $txt['lang_locale'] != 'en_US') |
|
| 1619 | - loadJavaScriptFile($scripturl . '?action=loadeditorlocale', array('external' => true), 'sceditor_language'); |
|
| 1678 | + if (!empty($txt['lang_locale']) && $txt['lang_locale'] != 'en_US') { |
|
| 1679 | + loadJavaScriptFile($scripturl . '?action=loadeditorlocale', array('external' => true), 'sceditor_language'); |
|
| 1680 | + } |
|
| 1620 | 1681 | |
| 1621 | 1682 | $context['shortcuts_text'] = $txt['shortcuts' . (!empty($context['drafts_save']) ? '_drafts' : '') . (isBrowser('is_firefox') ? '_firefox' : '')]; |
| 1622 | 1683 | $context['show_spellchecking'] = !empty($modSettings['enableSpellChecking']) && (function_exists('pspell_new') || (function_exists('enchant_broker_init') && ($txt['lang_charset'] == 'UTF-8' || function_exists('iconv')))); |
@@ -1625,11 +1686,12 @@ discard block |
||
| 1625 | 1686 | loadJavaScriptFile('spellcheck.js', array(), 'smf_spellcheck'); |
| 1626 | 1687 | |
| 1627 | 1688 | // Some hidden information is needed in order to make the spell checking work. |
| 1628 | - if (!isset($_REQUEST['xml'])) |
|
| 1629 | - $context['insert_after_template'] .= ' |
|
| 1689 | + if (!isset($_REQUEST['xml'])) { |
|
| 1690 | + $context['insert_after_template'] .= ' |
|
| 1630 | 1691 | <form name="spell_form" id="spell_form" method="post" accept-charset="' . $context['character_set'] . '" target="spellWindow" action="' . $scripturl . '?action=spellcheck"> |
| 1631 | 1692 | <input type="hidden" name="spellstring" value=""> |
| 1632 | 1693 | </form>'; |
| 1694 | + } |
|
| 1633 | 1695 | } |
| 1634 | 1696 | } |
| 1635 | 1697 | |
@@ -1786,10 +1848,12 @@ discard block |
||
| 1786 | 1848 | |
| 1787 | 1849 | // Generate a list of buttons that shouldn't be shown - this should be the fastest way to do this. |
| 1788 | 1850 | $disabled_tags = array(); |
| 1789 | - if (!empty($modSettings['disabledBBC'])) |
|
| 1790 | - $disabled_tags = explode(',', $modSettings['disabledBBC']); |
|
| 1791 | - if (empty($modSettings['enableEmbeddedFlash'])) |
|
| 1792 | - $disabled_tags[] = 'flash'; |
|
| 1851 | + if (!empty($modSettings['disabledBBC'])) { |
|
| 1852 | + $disabled_tags = explode(',', $modSettings['disabledBBC']); |
|
| 1853 | + } |
|
| 1854 | + if (empty($modSettings['enableEmbeddedFlash'])) { |
|
| 1855 | + $disabled_tags[] = 'flash'; |
|
| 1856 | + } |
|
| 1793 | 1857 | |
| 1794 | 1858 | foreach ($disabled_tags as $tag) |
| 1795 | 1859 | { |
@@ -1799,9 +1863,10 @@ discard block |
||
| 1799 | 1863 | $context['disabled_tags']['orderedlist'] = true; |
| 1800 | 1864 | } |
| 1801 | 1865 | |
| 1802 | - foreach ($editor_tag_map as $thisTag => $tagNameBBC) |
|
| 1803 | - if ($tag === $thisTag) |
|
| 1866 | + foreach ($editor_tag_map as $thisTag => $tagNameBBC) { |
|
| 1867 | + if ($tag === $thisTag) |
|
| 1804 | 1868 | $context['disabled_tags'][$tagNameBBC] = true; |
| 1869 | + } |
|
| 1805 | 1870 | |
| 1806 | 1871 | $context['disabled_tags'][trim($tag)] = true; |
| 1807 | 1872 | } |
@@ -1811,19 +1876,21 @@ discard block |
||
| 1811 | 1876 | $context['bbc_toolbar'] = array(); |
| 1812 | 1877 | foreach ($context['bbc_tags'] as $row => $tagRow) |
| 1813 | 1878 | { |
| 1814 | - if (!isset($context['bbc_toolbar'][$row])) |
|
| 1815 | - $context['bbc_toolbar'][$row] = array(); |
|
| 1879 | + if (!isset($context['bbc_toolbar'][$row])) { |
|
| 1880 | + $context['bbc_toolbar'][$row] = array(); |
|
| 1881 | + } |
|
| 1816 | 1882 | $tagsRow = array(); |
| 1817 | 1883 | foreach ($tagRow as $tag) |
| 1818 | 1884 | { |
| 1819 | 1885 | if ((!empty($tag['code'])) && empty($context['disabled_tags'][$tag['code']])) |
| 1820 | 1886 | { |
| 1821 | 1887 | $tagsRow[] = $tag['code']; |
| 1822 | - if (isset($tag['image'])) |
|
| 1823 | - $bbcodes_styles .= ' |
|
| 1888 | + if (isset($tag['image'])) { |
|
| 1889 | + $bbcodes_styles .= ' |
|
| 1824 | 1890 | .sceditor-button-' . $tag['code'] . ' div { |
| 1825 | 1891 | background: url(\'' . $settings['default_theme_url'] . '/images/bbc/' . $tag['image'] . '.png\'); |
| 1826 | 1892 | }'; |
| 1893 | + } |
|
| 1827 | 1894 | if (isset($tag['before'])) |
| 1828 | 1895 | { |
| 1829 | 1896 | $context['bbcodes_handlers'] .= ' |
@@ -1837,8 +1904,7 @@ discard block |
||
| 1837 | 1904 | });'; |
| 1838 | 1905 | } |
| 1839 | 1906 | |
| 1840 | - } |
|
| 1841 | - else |
|
| 1907 | + } else |
|
| 1842 | 1908 | { |
| 1843 | 1909 | $context['bbc_toolbar'][$row][] = implode(',', $tagsRow); |
| 1844 | 1910 | $tagsRow = array(); |
@@ -1849,14 +1915,16 @@ discard block |
||
| 1849 | 1915 | { |
| 1850 | 1916 | $context['bbc_toolbar'][$row][] = implode(',', $tagsRow); |
| 1851 | 1917 | $tagsRow = array(); |
| 1852 | - if (!isset($context['disabled_tags']['font'])) |
|
| 1853 | - $tagsRow[] = 'font'; |
|
| 1854 | - if (!isset($context['disabled_tags']['size'])) |
|
| 1855 | - $tagsRow[] = 'size'; |
|
| 1856 | - if (!isset($context['disabled_tags']['color'])) |
|
| 1857 | - $tagsRow[] = 'color'; |
|
| 1858 | - } |
|
| 1859 | - elseif ($row == 1 && empty($modSettings['disable_wysiwyg'])) |
|
| 1918 | + if (!isset($context['disabled_tags']['font'])) { |
|
| 1919 | + $tagsRow[] = 'font'; |
|
| 1920 | + } |
|
| 1921 | + if (!isset($context['disabled_tags']['size'])) { |
|
| 1922 | + $tagsRow[] = 'size'; |
|
| 1923 | + } |
|
| 1924 | + if (!isset($context['disabled_tags']['color'])) { |
|
| 1925 | + $tagsRow[] = 'color'; |
|
| 1926 | + } |
|
| 1927 | + } elseif ($row == 1 && empty($modSettings['disable_wysiwyg'])) |
|
| 1860 | 1928 | { |
| 1861 | 1929 | $tmp = array(); |
| 1862 | 1930 | $tagsRow[] = 'removeformat'; |
@@ -1867,13 +1935,15 @@ discard block |
||
| 1867 | 1935 | } |
| 1868 | 1936 | } |
| 1869 | 1937 | |
| 1870 | - if (!empty($tagsRow)) |
|
| 1871 | - $context['bbc_toolbar'][$row][] = implode(',', $tagsRow); |
|
| 1938 | + if (!empty($tagsRow)) { |
|
| 1939 | + $context['bbc_toolbar'][$row][] = implode(',', $tagsRow); |
|
| 1940 | + } |
|
| 1872 | 1941 | } |
| 1873 | - if (!empty($bbcodes_styles)) |
|
| 1874 | - $context['html_headers'] .= ' |
|
| 1942 | + if (!empty($bbcodes_styles)) { |
|
| 1943 | + $context['html_headers'] .= ' |
|
| 1875 | 1944 | <style>' . $bbcodes_styles . ' |
| 1876 | 1945 | </style>'; |
| 1946 | + } |
|
| 1877 | 1947 | } |
| 1878 | 1948 | |
| 1879 | 1949 | // Initialize smiley array... if not loaded before. |
@@ -1885,8 +1955,8 @@ discard block |
||
| 1885 | 1955 | ); |
| 1886 | 1956 | |
| 1887 | 1957 | // Load smileys - don't bother to run a query if we're not using the database's ones anyhow. |
| 1888 | - if (empty($modSettings['smiley_enable']) && $user_info['smiley_set'] != 'none') |
|
| 1889 | - $context['smileys']['postform'][] = array( |
|
| 1958 | + if (empty($modSettings['smiley_enable']) && $user_info['smiley_set'] != 'none') { |
|
| 1959 | + $context['smileys']['postform'][] = array( |
|
| 1890 | 1960 | 'smileys' => array( |
| 1891 | 1961 | array( |
| 1892 | 1962 | 'code' => ':)', |
@@ -1972,7 +2042,7 @@ discard block |
||
| 1972 | 2042 | ), |
| 1973 | 2043 | 'isLast' => true, |
| 1974 | 2044 | ); |
| 1975 | - elseif ($user_info['smiley_set'] != 'none') |
|
| 2045 | + } elseif ($user_info['smiley_set'] != 'none') |
|
| 1976 | 2046 | { |
| 1977 | 2047 | if (($temp = cache_get_data('posting_smileys', 480)) == null) |
| 1978 | 2048 | { |
@@ -1995,17 +2065,19 @@ discard block |
||
| 1995 | 2065 | |
| 1996 | 2066 | foreach ($context['smileys'] as $section => $smileyRows) |
| 1997 | 2067 | { |
| 1998 | - foreach ($smileyRows as $rowIndex => $smileys) |
|
| 1999 | - $context['smileys'][$section][$rowIndex]['smileys'][count($smileys['smileys']) - 1]['isLast'] = true; |
|
| 2068 | + foreach ($smileyRows as $rowIndex => $smileys) { |
|
| 2069 | + $context['smileys'][$section][$rowIndex]['smileys'][count($smileys['smileys']) - 1]['isLast'] = true; |
|
| 2070 | + } |
|
| 2000 | 2071 | |
| 2001 | - if (!empty($smileyRows)) |
|
| 2002 | - $context['smileys'][$section][count($smileyRows) - 1]['isLast'] = true; |
|
| 2072 | + if (!empty($smileyRows)) { |
|
| 2073 | + $context['smileys'][$section][count($smileyRows) - 1]['isLast'] = true; |
|
| 2074 | + } |
|
| 2003 | 2075 | } |
| 2004 | 2076 | |
| 2005 | 2077 | cache_put_data('posting_smileys', $context['smileys'], 480); |
| 2078 | + } else { |
|
| 2079 | + $context['smileys'] = $temp; |
|
| 2006 | 2080 | } |
| 2007 | - else |
|
| 2008 | - $context['smileys'] = $temp; |
|
| 2009 | 2081 | } |
| 2010 | 2082 | } |
| 2011 | 2083 | |
@@ -2031,8 +2103,9 @@ discard block |
||
| 2031 | 2103 | loadTemplate('GenericControls'); |
| 2032 | 2104 | |
| 2033 | 2105 | // Some javascript ma'am? |
| 2034 | - if (!empty($verificationOptions['override_visual']) || (!empty($modSettings['visual_verification_type']) && !isset($verificationOptions['override_visual']))) |
|
| 2035 | - loadJavaScriptFile('captcha.js', array(), 'smf_captcha'); |
|
| 2106 | + if (!empty($verificationOptions['override_visual']) || (!empty($modSettings['visual_verification_type']) && !isset($verificationOptions['override_visual']))) { |
|
| 2107 | + loadJavaScriptFile('captcha.js', array(), 'smf_captcha'); |
|
| 2108 | + } |
|
| 2036 | 2109 | |
| 2037 | 2110 | $context['use_graphic_library'] = in_array('gd', get_loaded_extensions()); |
| 2038 | 2111 | |
@@ -2045,8 +2118,8 @@ discard block |
||
| 2045 | 2118 | $isNew = !isset($context['controls']['verification'][$verificationOptions['id']]); |
| 2046 | 2119 | |
| 2047 | 2120 | // Log this into our collection. |
| 2048 | - if ($isNew) |
|
| 2049 | - $context['controls']['verification'][$verificationOptions['id']] = array( |
|
| 2121 | + if ($isNew) { |
|
| 2122 | + $context['controls']['verification'][$verificationOptions['id']] = array( |
|
| 2050 | 2123 | 'id' => $verificationOptions['id'], |
| 2051 | 2124 | 'empty_field' => empty($verificationOptions['no_empty_field']), |
| 2052 | 2125 | 'show_visual' => !empty($verificationOptions['override_visual']) || (!empty($modSettings['visual_verification_type']) && !isset($verificationOptions['override_visual'])), |
@@ -2057,13 +2130,15 @@ discard block |
||
| 2057 | 2130 | 'questions' => array(), |
| 2058 | 2131 | 'can_recaptcha' => !empty($modSettings['recaptcha_enabled']) && $modSettings['recaptcha_enabled'] == 1 && !empty($modSettings['recaptcha_site_key']) && !empty($modSettings['recaptcha_secret_key']), |
| 2059 | 2132 | ); |
| 2133 | + } |
|
| 2060 | 2134 | $thisVerification = &$context['controls']['verification'][$verificationOptions['id']]; |
| 2061 | 2135 | |
| 2062 | 2136 | // Is there actually going to be anything? |
| 2063 | - if (empty($thisVerification['show_visual']) && empty($thisVerification['number_questions']) && empty($thisVerification['can_recaptcha'])) |
|
| 2064 | - return false; |
|
| 2065 | - elseif (!$isNew && !$do_test) |
|
| 2066 | - return true; |
|
| 2137 | + if (empty($thisVerification['show_visual']) && empty($thisVerification['number_questions']) && empty($thisVerification['can_recaptcha'])) { |
|
| 2138 | + return false; |
|
| 2139 | + } elseif (!$isNew && !$do_test) { |
|
| 2140 | + return true; |
|
| 2141 | + } |
|
| 2067 | 2142 | |
| 2068 | 2143 | // Sanitize reCAPTCHA fields? |
| 2069 | 2144 | if ($thisVerification['can_recaptcha']) |
@@ -2076,11 +2151,12 @@ discard block |
||
| 2076 | 2151 | } |
| 2077 | 2152 | |
| 2078 | 2153 | // Add javascript for the object. |
| 2079 | - if ($context['controls']['verification'][$verificationOptions['id']]['show_visual']) |
|
| 2080 | - $context['insert_after_template'] .= ' |
|
| 2154 | + if ($context['controls']['verification'][$verificationOptions['id']]['show_visual']) { |
|
| 2155 | + $context['insert_after_template'] .= ' |
|
| 2081 | 2156 | <script> |
| 2082 | 2157 | var verification' . $verificationOptions['id'] . 'Handle = new smfCaptcha("' . $thisVerification['image_href'] . '", "' . $verificationOptions['id'] . '", ' . ($context['use_graphic_library'] ? 1 : 0) . '); |
| 2083 | 2158 | </script>'; |
| 2159 | + } |
|
| 2084 | 2160 | |
| 2085 | 2161 | // If we want questions do we have a cache of all the IDs? |
| 2086 | 2162 | if (!empty($thisVerification['number_questions']) && empty($modSettings['question_id_cache'])) |
@@ -2103,8 +2179,9 @@ discard block |
||
| 2103 | 2179 | unset ($row['id_question']); |
| 2104 | 2180 | // Make them all lowercase. We can't directly use $smcFunc['strtolower'] with array_walk, so do it manually, eh? |
| 2105 | 2181 | $row['answers'] = smf_json_decode($row['answers'], true); |
| 2106 | - foreach ($row['answers'] as $k => $v) |
|
| 2107 | - $row['answers'][$k] = $smcFunc['strtolower']($v); |
|
| 2182 | + foreach ($row['answers'] as $k => $v) { |
|
| 2183 | + $row['answers'][$k] = $smcFunc['strtolower']($v); |
|
| 2184 | + } |
|
| 2108 | 2185 | |
| 2109 | 2186 | $modSettings['question_id_cache']['questions'][$id_question] = $row; |
| 2110 | 2187 | $modSettings['question_id_cache']['langs'][$row['lngfile']][] = $id_question; |
@@ -2115,35 +2192,42 @@ discard block |
||
| 2115 | 2192 | } |
| 2116 | 2193 | } |
| 2117 | 2194 | |
| 2118 | - if (!isset($_SESSION[$verificationOptions['id'] . '_vv'])) |
|
| 2119 | - $_SESSION[$verificationOptions['id'] . '_vv'] = array(); |
|
| 2195 | + if (!isset($_SESSION[$verificationOptions['id'] . '_vv'])) { |
|
| 2196 | + $_SESSION[$verificationOptions['id'] . '_vv'] = array(); |
|
| 2197 | + } |
|
| 2120 | 2198 | |
| 2121 | 2199 | // Do we need to refresh the verification? |
| 2122 | - 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'])) |
|
| 2123 | - $force_refresh = true; |
|
| 2124 | - else |
|
| 2125 | - $force_refresh = false; |
|
| 2200 | + 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'])) { |
|
| 2201 | + $force_refresh = true; |
|
| 2202 | + } else { |
|
| 2203 | + $force_refresh = false; |
|
| 2204 | + } |
|
| 2126 | 2205 | |
| 2127 | 2206 | // This can also force a fresh, although unlikely. |
| 2128 | - if (($thisVerification['show_visual'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['code'])) || ($thisVerification['number_questions'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['q']))) |
|
| 2129 | - $force_refresh = true; |
|
| 2207 | + if (($thisVerification['show_visual'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['code'])) || ($thisVerification['number_questions'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['q']))) { |
|
| 2208 | + $force_refresh = true; |
|
| 2209 | + } |
|
| 2130 | 2210 | |
| 2131 | 2211 | $verification_errors = array(); |
| 2132 | 2212 | // Start with any testing. |
| 2133 | 2213 | if ($do_test) |
| 2134 | 2214 | { |
| 2135 | 2215 | // This cannot happen! |
| 2136 | - if (!isset($_SESSION[$verificationOptions['id'] . '_vv']['count'])) |
|
| 2137 | - fatal_lang_error('no_access', false); |
|
| 2216 | + if (!isset($_SESSION[$verificationOptions['id'] . '_vv']['count'])) { |
|
| 2217 | + fatal_lang_error('no_access', false); |
|
| 2218 | + } |
|
| 2138 | 2219 | // ... nor this! |
| 2139 | - if ($thisVerification['number_questions'] && (!isset($_SESSION[$verificationOptions['id'] . '_vv']['q']) || !isset($_REQUEST[$verificationOptions['id'] . '_vv']['q']))) |
|
| 2140 | - fatal_lang_error('no_access', false); |
|
| 2220 | + if ($thisVerification['number_questions'] && (!isset($_SESSION[$verificationOptions['id'] . '_vv']['q']) || !isset($_REQUEST[$verificationOptions['id'] . '_vv']['q']))) { |
|
| 2221 | + fatal_lang_error('no_access', false); |
|
| 2222 | + } |
|
| 2141 | 2223 | // Hmm, it's requested but not actually declared. This shouldn't happen. |
| 2142 | - if ($thisVerification['empty_field'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field'])) |
|
| 2143 | - fatal_lang_error('no_access', false); |
|
| 2224 | + if ($thisVerification['empty_field'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field'])) { |
|
| 2225 | + fatal_lang_error('no_access', false); |
|
| 2226 | + } |
|
| 2144 | 2227 | // While we're here, did the user do something bad? |
| 2145 | - if ($thisVerification['empty_field'] && !empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field']) && !empty($_REQUEST[$_SESSION[$verificationOptions['id'] . '_vv']['empty_field']])) |
|
| 2146 | - $verification_errors[] = 'wrong_verification_answer'; |
|
| 2228 | + if ($thisVerification['empty_field'] && !empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field']) && !empty($_REQUEST[$_SESSION[$verificationOptions['id'] . '_vv']['empty_field']])) { |
|
| 2229 | + $verification_errors[] = 'wrong_verification_answer'; |
|
| 2230 | + } |
|
| 2147 | 2231 | |
| 2148 | 2232 | if ($thisVerification['can_recaptcha']) |
| 2149 | 2233 | { |
@@ -2156,22 +2240,25 @@ discard block |
||
| 2156 | 2240 | { |
| 2157 | 2241 | $resp = $reCaptcha->verify($_POST['g-recaptcha-response'], $_SERVER['REMOTE_ADDR']); |
| 2158 | 2242 | |
| 2159 | - if (!$resp->isSuccess()) |
|
| 2160 | - $verification_errors[] = 'wrong_verification_code'; |
|
| 2243 | + if (!$resp->isSuccess()) { |
|
| 2244 | + $verification_errors[] = 'wrong_verification_code'; |
|
| 2245 | + } |
|
| 2246 | + } else { |
|
| 2247 | + $verification_errors[] = 'wrong_verification_code'; |
|
| 2161 | 2248 | } |
| 2162 | - else |
|
| 2163 | - $verification_errors[] = 'wrong_verification_code'; |
|
| 2164 | 2249 | } |
| 2165 | - 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'])) |
|
| 2166 | - $verification_errors[] = 'wrong_verification_code'; |
|
| 2250 | + 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'])) { |
|
| 2251 | + $verification_errors[] = 'wrong_verification_code'; |
|
| 2252 | + } |
|
| 2167 | 2253 | if ($thisVerification['number_questions']) |
| 2168 | 2254 | { |
| 2169 | 2255 | $incorrectQuestions = array(); |
| 2170 | 2256 | foreach ($_SESSION[$verificationOptions['id'] . '_vv']['q'] as $q) |
| 2171 | 2257 | { |
| 2172 | 2258 | // We don't have this question any more, thus no answers. |
| 2173 | - if (!isset($modSettings['question_id_cache']['questions'][$q])) |
|
| 2174 | - continue; |
|
| 2259 | + if (!isset($modSettings['question_id_cache']['questions'][$q])) { |
|
| 2260 | + continue; |
|
| 2261 | + } |
|
| 2175 | 2262 | // This is quite complex. We have our question but it might have multiple answers. |
| 2176 | 2263 | // First, did they actually answer this question? |
| 2177 | 2264 | if (!isset($_REQUEST[$verificationOptions['id'] . '_vv']['q'][$q]) || trim($_REQUEST[$verificationOptions['id'] . '_vv']['q'][$q]) == '') |
@@ -2183,24 +2270,28 @@ discard block |
||
| 2183 | 2270 | else |
| 2184 | 2271 | { |
| 2185 | 2272 | $given_answer = trim($smcFunc['htmlspecialchars'](strtolower($_REQUEST[$verificationOptions['id'] . '_vv']['q'][$q]))); |
| 2186 | - if (!in_array($given_answer, $modSettings['question_id_cache']['questions'][$q]['answers'])) |
|
| 2187 | - $incorrectQuestions[] = $q; |
|
| 2273 | + if (!in_array($given_answer, $modSettings['question_id_cache']['questions'][$q]['answers'])) { |
|
| 2274 | + $incorrectQuestions[] = $q; |
|
| 2275 | + } |
|
| 2188 | 2276 | } |
| 2189 | 2277 | } |
| 2190 | 2278 | |
| 2191 | - if (!empty($incorrectQuestions)) |
|
| 2192 | - $verification_errors[] = 'wrong_verification_answer'; |
|
| 2279 | + if (!empty($incorrectQuestions)) { |
|
| 2280 | + $verification_errors[] = 'wrong_verification_answer'; |
|
| 2281 | + } |
|
| 2193 | 2282 | } |
| 2194 | 2283 | } |
| 2195 | 2284 | |
| 2196 | 2285 | // Any errors means we refresh potentially. |
| 2197 | 2286 | if (!empty($verification_errors)) |
| 2198 | 2287 | { |
| 2199 | - if (empty($_SESSION[$verificationOptions['id'] . '_vv']['errors'])) |
|
| 2200 | - $_SESSION[$verificationOptions['id'] . '_vv']['errors'] = 0; |
|
| 2288 | + if (empty($_SESSION[$verificationOptions['id'] . '_vv']['errors'])) { |
|
| 2289 | + $_SESSION[$verificationOptions['id'] . '_vv']['errors'] = 0; |
|
| 2290 | + } |
|
| 2201 | 2291 | // Too many errors? |
| 2202 | - elseif ($_SESSION[$verificationOptions['id'] . '_vv']['errors'] > $thisVerification['max_errors']) |
|
| 2203 | - $force_refresh = true; |
|
| 2292 | + elseif ($_SESSION[$verificationOptions['id'] . '_vv']['errors'] > $thisVerification['max_errors']) { |
|
| 2293 | + $force_refresh = true; |
|
| 2294 | + } |
|
| 2204 | 2295 | |
| 2205 | 2296 | // Keep a track of these. |
| 2206 | 2297 | $_SESSION[$verificationOptions['id'] . '_vv']['errors']++; |
@@ -2233,8 +2324,9 @@ discard block |
||
| 2233 | 2324 | // Are we overriding the range? |
| 2234 | 2325 | $character_range = !empty($verificationOptions['override_range']) ? $verificationOptions['override_range'] : $context['standard_captcha_range']; |
| 2235 | 2326 | |
| 2236 | - for ($i = 0; $i < 6; $i++) |
|
| 2237 | - $_SESSION[$verificationOptions['id'] . '_vv']['code'] .= $character_range[array_rand($character_range)]; |
|
| 2327 | + for ($i = 0; $i < 6; $i++) { |
|
| 2328 | + $_SESSION[$verificationOptions['id'] . '_vv']['code'] .= $character_range[array_rand($character_range)]; |
|
| 2329 | + } |
|
| 2238 | 2330 | } |
| 2239 | 2331 | |
| 2240 | 2332 | // Getting some new questions? |
@@ -2242,8 +2334,9 @@ discard block |
||
| 2242 | 2334 | { |
| 2243 | 2335 | // Attempt to try the current page's language, followed by the user's preference, followed by the site default. |
| 2244 | 2336 | $possible_langs = array(); |
| 2245 | - if (isset($_SESSION['language'])) |
|
| 2246 | - $possible_langs[] = strtr($_SESSION['language'], array('-utf8' => '')); |
|
| 2337 | + if (isset($_SESSION['language'])) { |
|
| 2338 | + $possible_langs[] = strtr($_SESSION['language'], array('-utf8' => '')); |
|
| 2339 | + } |
|
| 2247 | 2340 | if (!empty($user_info['language'])); |
| 2248 | 2341 | $possible_langs[] = $user_info['language']; |
| 2249 | 2342 | $possible_langs[] = $language; |
@@ -2262,8 +2355,7 @@ discard block |
||
| 2262 | 2355 | } |
| 2263 | 2356 | } |
| 2264 | 2357 | } |
| 2265 | - } |
|
| 2266 | - else |
|
| 2358 | + } else |
|
| 2267 | 2359 | { |
| 2268 | 2360 | // Same questions as before. |
| 2269 | 2361 | $questionIDs = !empty($_SESSION[$verificationOptions['id'] . '_vv']['q']) ? $_SESSION[$verificationOptions['id'] . '_vv']['q'] : array(); |
@@ -2273,8 +2365,9 @@ discard block |
||
| 2273 | 2365 | // If we do have an empty field, it would be nice to hide it from legitimate users who shouldn't be populating it anyway. |
| 2274 | 2366 | if (!empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field'])) |
| 2275 | 2367 | { |
| 2276 | - if (!isset($context['html_headers'])) |
|
| 2277 | - $context['html_headers'] = ''; |
|
| 2368 | + if (!isset($context['html_headers'])) { |
|
| 2369 | + $context['html_headers'] = ''; |
|
| 2370 | + } |
|
| 2278 | 2371 | $context['html_headers'] .= '<style>.vv_special { display:none; }</style>'; |
| 2279 | 2372 | } |
| 2280 | 2373 | |
@@ -2300,11 +2393,13 @@ discard block |
||
| 2300 | 2393 | $_SESSION[$verificationOptions['id'] . '_vv']['count'] = empty($_SESSION[$verificationOptions['id'] . '_vv']['count']) ? 1 : $_SESSION[$verificationOptions['id'] . '_vv']['count'] + 1; |
| 2301 | 2394 | |
| 2302 | 2395 | // Return errors if we have them. |
| 2303 | - if (!empty($verification_errors)) |
|
| 2304 | - return $verification_errors; |
|
| 2396 | + if (!empty($verification_errors)) { |
|
| 2397 | + return $verification_errors; |
|
| 2398 | + } |
|
| 2305 | 2399 | // If we had a test that one, make a note. |
| 2306 | - elseif ($do_test) |
|
| 2307 | - $_SESSION[$verificationOptions['id'] . '_vv']['did_pass'] = true; |
|
| 2400 | + elseif ($do_test) { |
|
| 2401 | + $_SESSION[$verificationOptions['id'] . '_vv']['did_pass'] = true; |
|
| 2402 | + } |
|
| 2308 | 2403 | |
| 2309 | 2404 | // Say that everything went well chaps. |
| 2310 | 2405 | return true; |
@@ -2329,8 +2424,9 @@ discard block |
||
| 2329 | 2424 | call_integration_hook('integrate_autosuggest', array(&$searchTypes)); |
| 2330 | 2425 | |
| 2331 | 2426 | // If we're just checking the callback function is registered return true or false. |
| 2332 | - if ($checkRegistered != null) |
|
| 2333 | - return isset($searchTypes[$checkRegistered]) && function_exists('AutoSuggest_Search_' . $checkRegistered); |
|
| 2427 | + if ($checkRegistered != null) { |
|
| 2428 | + return isset($searchTypes[$checkRegistered]) && function_exists('AutoSuggest_Search_' . $checkRegistered); |
|
| 2429 | + } |
|
| 2334 | 2430 | |
| 2335 | 2431 | checkSession('get'); |
| 2336 | 2432 | loadTemplate('Xml'); |
@@ -2481,24 +2577,27 @@ discard block |
||
| 2481 | 2577 | foreach ($possible_versions as $ver) |
| 2482 | 2578 | { |
| 2483 | 2579 | $ver = trim($ver); |
| 2484 | - if (strpos($ver, 'SMF') === 0) |
|
| 2485 | - $versions[] = $ver; |
|
| 2580 | + if (strpos($ver, 'SMF') === 0) { |
|
| 2581 | + $versions[] = $ver; |
|
| 2582 | + } |
|
| 2486 | 2583 | } |
| 2487 | 2584 | } |
| 2488 | 2585 | $smcFunc['db_free_result']($request); |
| 2489 | 2586 | |
| 2490 | 2587 | // Just in case we don't have ANYthing. |
| 2491 | - if (empty($versions)) |
|
| 2492 | - $versions = array('SMF 2.0'); |
|
| 2588 | + if (empty($versions)) { |
|
| 2589 | + $versions = array('SMF 2.0'); |
|
| 2590 | + } |
|
| 2493 | 2591 | |
| 2494 | - foreach ($versions as $id => $version) |
|
| 2495 | - if (strpos($version, strtoupper($_REQUEST['search'])) !== false) |
|
| 2592 | + foreach ($versions as $id => $version) { |
|
| 2593 | + if (strpos($version, strtoupper($_REQUEST['search'])) !== false) |
|
| 2496 | 2594 | $xml_data['items']['children'][] = array( |
| 2497 | 2595 | 'attributes' => array( |
| 2498 | 2596 | 'id' => $id, |
| 2499 | 2597 | ), |
| 2500 | 2598 | 'value' => $version, |
| 2501 | 2599 | ); |
| 2600 | + } |
|
| 2502 | 2601 | |
| 2503 | 2602 | return $xml_data; |
| 2504 | 2603 | } |
@@ -51,11 +51,13 @@ discard block |
||
| 51 | 51 | <p>'; |
| 52 | 52 | |
| 53 | 53 | // Show just numbers...? |
| 54 | - if ($settings['display_who_viewing'] == 1) |
|
| 55 | - echo count($context['view_members']), ' ', count($context['view_members']) == 1 ? $txt['who_member'] : $txt['members']; |
|
| 54 | + if ($settings['display_who_viewing'] == 1) { |
|
| 55 | + echo count($context['view_members']), ' ', count($context['view_members']) == 1 ? $txt['who_member'] : $txt['members']; |
|
| 56 | + } |
|
| 56 | 57 | // Or show the actual people viewing the topic? |
| 57 | - else |
|
| 58 | - echo empty($context['view_members_list']) ? '0 ' . $txt['members'] : implode(', ', $context['view_members_list']) . ((empty($context['view_num_hidden']) || $context['can_moderate_forum']) ? '' : ' (+ ' . $context['view_num_hidden'] . ' ' . $txt['hidden'] . ')'); |
|
| 58 | + else { |
|
| 59 | + echo empty($context['view_members_list']) ? '0 ' . $txt['members'] : implode(', ', $context['view_members_list']) . ((empty($context['view_num_hidden']) || $context['can_moderate_forum']) ? '' : ' (+ ' . $context['view_num_hidden'] . ' ' . $txt['hidden'] . ')'); |
|
| 60 | + } |
|
| 59 | 61 | |
| 60 | 62 | // Now show how many guests are here too. |
| 61 | 63 | echo $txt['who_and'], $context['view_num_guests'], ' ', $context['view_num_guests'] == 1 ? $txt['guest'] : $txt['guests'], $txt['who_viewing_topic'], ' |
@@ -93,10 +95,11 @@ discard block |
||
| 93 | 95 | <dt class="', $option['voted_this'] ? ' voted' : '', '">', $option['option'], '</dt> |
| 94 | 96 | <dd class="statsbar', $option['voted_this'] ? ' voted' : '', '">'; |
| 95 | 97 | |
| 96 | - if ($context['allow_results_view']) |
|
| 97 | - echo ' |
|
| 98 | + if ($context['allow_results_view']) { |
|
| 99 | + echo ' |
|
| 98 | 100 | ', $option['bar_ndt'], ' |
| 99 | 101 | <span class="percentage">', $option['votes'], ' (', $option['percent'], '%)</span>'; |
| 102 | + } |
|
| 100 | 103 | |
| 101 | 104 | echo ' |
| 102 | 105 | </dd>'; |
@@ -105,9 +108,10 @@ discard block |
||
| 105 | 108 | echo ' |
| 106 | 109 | </dl>'; |
| 107 | 110 | |
| 108 | - if ($context['allow_results_view']) |
|
| 109 | - echo ' |
|
| 111 | + if ($context['allow_results_view']) { |
|
| 112 | + echo ' |
|
| 110 | 113 | <p><strong>', $txt['poll_total_voters'], ':</strong> ', $context['poll']['total_votes'], '</p>'; |
| 114 | + } |
|
| 111 | 115 | } |
| 112 | 116 | // They are allowed to vote! Go to it! |
| 113 | 117 | else |
@@ -116,17 +120,19 @@ discard block |
||
| 116 | 120 | <form action="', $scripturl, '?action=vote;topic=', $context['current_topic'], '.', $context['start'], ';poll=', $context['poll']['id'], '" method="post" accept-charset="', $context['character_set'], '">'; |
| 117 | 121 | |
| 118 | 122 | // Show a warning if they are allowed more than one option. |
| 119 | - if ($context['poll']['allowed_warning']) |
|
| 120 | - echo ' |
|
| 123 | + if ($context['poll']['allowed_warning']) { |
|
| 124 | + echo ' |
|
| 121 | 125 | <p class="smallpadding">', $context['poll']['allowed_warning'], '</p>'; |
| 126 | + } |
|
| 122 | 127 | |
| 123 | 128 | echo ' |
| 124 | 129 | <ul class="options">'; |
| 125 | 130 | |
| 126 | 131 | // Show each option with its button - a radio likely. |
| 127 | - foreach ($context['poll']['options'] as $option) |
|
| 128 | - echo ' |
|
| 132 | + foreach ($context['poll']['options'] as $option) { |
|
| 133 | + echo ' |
|
| 129 | 134 | <li>', $option['vote_button'], ' <label for="', $option['id'], '">', $option['option'], '</label></li>'; |
| 135 | + } |
|
| 130 | 136 | |
| 131 | 137 | echo ' |
| 132 | 138 | </ul> |
@@ -138,9 +144,10 @@ discard block |
||
| 138 | 144 | } |
| 139 | 145 | |
| 140 | 146 | // Is the clock ticking? |
| 141 | - if (!empty($context['poll']['expire_time'])) |
|
| 142 | - echo ' |
|
| 147 | + if (!empty($context['poll']['expire_time'])) { |
|
| 148 | + echo ' |
|
| 143 | 149 | <p><strong>', ($context['poll']['is_expired'] ? $txt['poll_expired_on'] : $txt['poll_expires_on']), ':</strong> ', $context['poll']['expire_time'], '</p>'; |
| 150 | + } |
|
| 144 | 151 | |
| 145 | 152 | echo ' |
| 146 | 153 | </div> |
@@ -170,11 +177,13 @@ discard block |
||
| 170 | 177 | <li> |
| 171 | 178 | <b class="event_title"><a href="', $scripturl, '?action=calendar;event=', $event['id'], '">', $event['title'], '</a></b>'; |
| 172 | 179 | |
| 173 | - if ($event['can_edit']) |
|
| 174 | - echo ' <a href="' . $event['modify_href'] . '"><span class="generic_icons calendar_modify" title="', $txt['calendar_edit'], '"></span></a>'; |
|
| 180 | + if ($event['can_edit']) { |
|
| 181 | + echo ' <a href="' . $event['modify_href'] . '"><span class="generic_icons calendar_modify" title="', $txt['calendar_edit'], '"></span></a>'; |
|
| 182 | + } |
|
| 175 | 183 | |
| 176 | - if ($event['can_export']) |
|
| 177 | - echo ' <a href="' . $event['export_href'] . '"><span class="generic_icons calendar_export" title="', $txt['calendar_export'], '"></span></a>'; |
|
| 184 | + if ($event['can_export']) { |
|
| 185 | + echo ' <a href="' . $event['export_href'] . '"><span class="generic_icons calendar_export" title="', $txt['calendar_export'], '"></span></a>'; |
|
| 186 | + } |
|
| 178 | 187 | |
| 179 | 188 | echo ' |
| 180 | 189 | <br>'; |
@@ -182,14 +191,14 @@ discard block |
||
| 182 | 191 | if (!empty($event['allday'])) |
| 183 | 192 | { |
| 184 | 193 | echo '<time datetime="' . $event['start_iso_gmdate'] . '">', trim($event['start_date_local']), '</time>', ($event['start_date'] != $event['end_date']) ? ' – <time datetime="' . $event['end_iso_gmdate'] . '">' . trim($event['end_date_local']) . '</time>' : ''; |
| 185 | - } |
|
| 186 | - else |
|
| 194 | + } else |
|
| 187 | 195 | { |
| 188 | 196 | // Display event info relative to user's local timezone |
| 189 | 197 | echo '<time datetime="' . $event['start_iso_gmdate'] . '">', trim($event['start_date_local']), ', ', trim($event['start_time_local']), '</time> – <time datetime="' . $event['end_iso_gmdate'] . '">'; |
| 190 | 198 | |
| 191 | - if ($event['start_date_local'] != $event['end_date_local']) |
|
| 192 | - echo trim($event['end_date_local']) . ', '; |
|
| 199 | + if ($event['start_date_local'] != $event['end_date_local']) { |
|
| 200 | + echo trim($event['end_date_local']) . ', '; |
|
| 201 | + } |
|
| 193 | 202 | |
| 194 | 203 | echo trim($event['end_time_local']); |
| 195 | 204 | |
@@ -198,23 +207,27 @@ discard block |
||
| 198 | 207 | { |
| 199 | 208 | echo '</time> (<time datetime="' . $event['start_iso_gmdate'] . '">'; |
| 200 | 209 | |
| 201 | - if ($event['start_date_orig'] != $event['start_date_local'] || $event['end_date_orig'] != $event['end_date_local'] || $event['start_date_orig'] != $event['end_date_orig']) |
|
| 202 | - echo trim($event['start_date_orig']), ', '; |
|
| 210 | + if ($event['start_date_orig'] != $event['start_date_local'] || $event['end_date_orig'] != $event['end_date_local'] || $event['start_date_orig'] != $event['end_date_orig']) { |
|
| 211 | + echo trim($event['start_date_orig']), ', '; |
|
| 212 | + } |
|
| 203 | 213 | |
| 204 | 214 | echo trim($event['start_time_orig']), '</time> – <time datetime="' . $event['end_iso_gmdate'] . '">'; |
| 205 | 215 | |
| 206 | - if ($event['start_date_orig'] != $event['end_date_orig']) |
|
| 207 | - echo trim($event['end_date_orig']) . ', '; |
|
| 216 | + if ($event['start_date_orig'] != $event['end_date_orig']) { |
|
| 217 | + echo trim($event['end_date_orig']) . ', '; |
|
| 218 | + } |
|
| 208 | 219 | |
| 209 | 220 | echo trim($event['end_time_orig']), ' ', $event['tz_abbrev'], '</time>)'; |
| 210 | 221 | } |
| 211 | 222 | // Event is scheduled in the user's own timezone? Let 'em know, just to avoid confusion |
| 212 | - else |
|
| 213 | - echo ' ', $event['tz_abbrev'], '</time>'; |
|
| 223 | + else { |
|
| 224 | + echo ' ', $event['tz_abbrev'], '</time>'; |
|
| 225 | + } |
|
| 214 | 226 | } |
| 215 | 227 | |
| 216 | - if (!empty($event['location'])) |
|
| 217 | - echo '<br>', $event['location']; |
|
| 228 | + if (!empty($event['location'])) { |
|
| 229 | + echo '<br>', $event['location']; |
|
| 230 | + } |
|
| 218 | 231 | |
| 219 | 232 | echo ' |
| 220 | 233 | </li>'; |
@@ -252,8 +265,9 @@ discard block |
||
| 252 | 265 | $context['removableMessageIDs'] = array(); |
| 253 | 266 | |
| 254 | 267 | // Get all the messages... |
| 255 | - while ($message = $context['get_message']()) |
|
| 256 | - template_single_post($message); |
|
| 268 | + while ($message = $context['get_message']()) { |
|
| 269 | + template_single_post($message); |
|
| 270 | + } |
|
| 257 | 271 | |
| 258 | 272 | echo ' |
| 259 | 273 | </form> |
@@ -290,8 +304,9 @@ discard block |
||
| 290 | 304 | <div id="display_jump_to"> </div>'; |
| 291 | 305 | |
| 292 | 306 | // Show quickreply |
| 293 | - if ($context['can_reply']) |
|
| 294 | - template_quickreply(); |
|
| 307 | + if ($context['can_reply']) { |
|
| 308 | + template_quickreply(); |
|
| 309 | + } |
|
| 295 | 310 | |
| 296 | 311 | // User action pop on mobile screen (or actually small screen), this uses responsive css does not check mobile device. |
| 297 | 312 | echo ' |
@@ -304,8 +319,8 @@ discard block |
||
| 304 | 319 | </div>'; |
| 305 | 320 | |
| 306 | 321 | // Show the moderation button & pop only if user can moderate |
| 307 | - if ($context['can_moderate_forum'] || $context['user']['is_mod']) |
|
| 308 | - echo ' |
|
| 322 | + if ($context['can_moderate_forum'] || $context['user']['is_mod']) { |
|
| 323 | + echo ' |
|
| 309 | 324 | <div id="mobile_moderation" class="popup_container"> |
| 310 | 325 | <div class="popup_window description"> |
| 311 | 326 | <div class="popup_heading">', $txt['mobile_moderation'],' |
@@ -315,6 +330,7 @@ discard block |
||
| 315 | 330 | </div> |
| 316 | 331 | </div> |
| 317 | 332 | </div>'; |
| 333 | + } |
|
| 318 | 334 | |
| 319 | 335 | echo ' |
| 320 | 336 | <script>'; |
@@ -438,9 +454,10 @@ discard block |
||
| 438 | 454 | }); |
| 439 | 455 | }'; |
| 440 | 456 | |
| 441 | - if (!empty($context['ignoredMsgs'])) |
|
| 442 | - echo ' |
|
| 457 | + if (!empty($context['ignoredMsgs'])) { |
|
| 458 | + echo ' |
|
| 443 | 459 | ignore_toggles([', implode(', ', $context['ignoredMsgs']), '], ', JavaScriptEscape($txt['show_ignore_user_post']), ');'; |
| 460 | + } |
|
| 444 | 461 | |
| 445 | 462 | echo ' |
| 446 | 463 | </script>'; |
@@ -457,8 +474,9 @@ discard block |
||
| 457 | 474 | |
| 458 | 475 | $ignoring = false; |
| 459 | 476 | |
| 460 | - if ($message['can_remove']) |
|
| 461 | - $context['removableMessageIDs'][] = $message['id']; |
|
| 477 | + if ($message['can_remove']) { |
|
| 478 | + $context['removableMessageIDs'][] = $message['id']; |
|
| 479 | + } |
|
| 462 | 480 | |
| 463 | 481 | // Are we ignoring this message? |
| 464 | 482 | if (!empty($message['is_ignored'])) |
@@ -484,9 +502,10 @@ discard block |
||
| 484 | 502 | <div class="custom_fields_above_member"> |
| 485 | 503 | <ul class="nolist">'; |
| 486 | 504 | |
| 487 | - foreach ($message['custom_fields']['above_member'] as $custom) |
|
| 488 | - echo ' |
|
| 505 | + foreach ($message['custom_fields']['above_member'] as $custom) { |
|
| 506 | + echo ' |
|
| 489 | 507 | <li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>'; |
| 508 | + } |
|
| 490 | 509 | |
| 491 | 510 | echo ' |
| 492 | 511 | </ul> |
@@ -497,9 +516,10 @@ discard block |
||
| 497 | 516 | <h4>'; |
| 498 | 517 | |
| 499 | 518 | // Show online and offline buttons? |
| 500 | - if (!empty($modSettings['onlineEnable']) && !$message['member']['is_guest']) |
|
| 501 | - echo ' |
|
| 519 | + if (!empty($modSettings['onlineEnable']) && !$message['member']['is_guest']) { |
|
| 520 | + echo ' |
|
| 502 | 521 | ', $context['can_send_pm'] ? '<a href="' . $message['member']['online']['href'] . '" title="' . $message['member']['online']['label'] . '">' : '', '<span class="' . ($message['member']['online']['is_online'] == 1 ? 'on' : 'off') . '" title="' . $message['member']['online']['text'] . '"></span>', $context['can_send_pm'] ? '</a>' : ''; |
| 522 | + } |
|
| 503 | 523 | |
| 504 | 524 | |
| 505 | 525 | // Show a link to the member's profile. |
@@ -512,51 +532,59 @@ discard block |
||
| 512 | 532 | |
| 513 | 533 | |
| 514 | 534 | // Show the user's avatar. |
| 515 | - if (!empty($modSettings['show_user_images']) && empty($options['show_no_avatars']) && !empty($message['member']['avatar']['image'])) |
|
| 516 | - echo ' |
|
| 535 | + if (!empty($modSettings['show_user_images']) && empty($options['show_no_avatars']) && !empty($message['member']['avatar']['image'])) { |
|
| 536 | + echo ' |
|
| 517 | 537 | <li class="avatar"> |
| 518 | 538 | <a href="', $message['member']['href'], '">', $message['member']['avatar']['image'], '</a> |
| 519 | 539 | </li>'; |
| 540 | + } |
|
| 520 | 541 | |
| 521 | 542 | // Are there any custom fields below the avatar? |
| 522 | - if (!empty($message['custom_fields']['below_avatar'])) |
|
| 523 | - foreach ($message['custom_fields']['below_avatar'] as $custom) |
|
| 543 | + if (!empty($message['custom_fields']['below_avatar'])) { |
|
| 544 | + foreach ($message['custom_fields']['below_avatar'] as $custom) |
|
| 524 | 545 | echo ' |
| 525 | 546 | <li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>'; |
| 547 | + } |
|
| 526 | 548 | |
| 527 | 549 | // Show the post group icons, but not for guests. |
| 528 | - if (!$message['member']['is_guest']) |
|
| 529 | - echo ' |
|
| 550 | + if (!$message['member']['is_guest']) { |
|
| 551 | + echo ' |
|
| 530 | 552 | <li class="icons">', $message['member']['group_icons'], '</li>'; |
| 553 | + } |
|
| 531 | 554 | |
| 532 | 555 | // Show the member's primary group (like 'Administrator') if they have one. |
| 533 | - if (!empty($message['member']['group'])) |
|
| 534 | - echo ' |
|
| 556 | + if (!empty($message['member']['group'])) { |
|
| 557 | + echo ' |
|
| 535 | 558 | <li class="membergroup">', $message['member']['group'], '</li>'; |
| 559 | + } |
|
| 536 | 560 | |
| 537 | 561 | // Show the member's custom title, if they have one. |
| 538 | - if (!empty($message['member']['title'])) |
|
| 539 | - echo ' |
|
| 562 | + if (!empty($message['member']['title'])) { |
|
| 563 | + echo ' |
|
| 540 | 564 | <li class="title">', $message['member']['title'], '</li>'; |
| 565 | + } |
|
| 541 | 566 | |
| 542 | 567 | // Don't show these things for guests. |
| 543 | 568 | if (!$message['member']['is_guest']) |
| 544 | 569 | { |
| 545 | 570 | |
| 546 | 571 | // Show the post group if and only if they have no other group or the option is on, and they are in a post group. |
| 547 | - if ((empty($modSettings['hide_post_group']) || empty($message['member']['group'])) && !empty($message['member']['post_group'])) |
|
| 548 | - echo ' |
|
| 572 | + if ((empty($modSettings['hide_post_group']) || empty($message['member']['group'])) && !empty($message['member']['post_group'])) { |
|
| 573 | + echo ' |
|
| 549 | 574 | <li class="postgroup">', $message['member']['post_group'], '</li>'; |
| 575 | + } |
|
| 550 | 576 | |
| 551 | 577 | // Show how many posts they have made. |
| 552 | - if (!isset($context['disabled_fields']['posts'])) |
|
| 553 | - echo ' |
|
| 578 | + if (!isset($context['disabled_fields']['posts'])) { |
|
| 579 | + echo ' |
|
| 554 | 580 | <li class="postcount">', $txt['member_postcount'], ': ', $message['member']['posts'], '</li>'; |
| 581 | + } |
|
| 555 | 582 | |
| 556 | 583 | // Show their personal text? |
| 557 | - if (!empty($modSettings['show_blurb']) && !empty($message['member']['blurb'])) |
|
| 558 | - echo ' |
|
| 584 | + if (!empty($modSettings['show_blurb']) && !empty($message['member']['blurb'])) { |
|
| 585 | + echo ' |
|
| 559 | 586 | <li class="blurb">', $message['member']['blurb'], '</li>'; |
| 587 | + } |
|
| 560 | 588 | |
| 561 | 589 | // Any custom fields to show as icons? |
| 562 | 590 | if (!empty($message['custom_fields']['icons'])) |
@@ -565,9 +593,10 @@ discard block |
||
| 565 | 593 | <li class="im_icons"> |
| 566 | 594 | <ol>'; |
| 567 | 595 | |
| 568 | - foreach ($message['custom_fields']['icons'] as $custom) |
|
| 569 | - echo ' |
|
| 596 | + foreach ($message['custom_fields']['icons'] as $custom) { |
|
| 597 | + echo ' |
|
| 570 | 598 | <li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>'; |
| 599 | + } |
|
| 571 | 600 | |
| 572 | 601 | echo ' |
| 573 | 602 | </ol> |
@@ -582,19 +611,22 @@ discard block |
||
| 582 | 611 | <ol class="profile_icons">'; |
| 583 | 612 | |
| 584 | 613 | // Don't show an icon if they haven't specified a website. |
| 585 | - if (!empty($message['member']['website']['url']) && !isset($context['disabled_fields']['website'])) |
|
| 586 | - echo ' |
|
| 614 | + if (!empty($message['member']['website']['url']) && !isset($context['disabled_fields']['website'])) { |
|
| 615 | + echo ' |
|
| 587 | 616 | <li><a href="', $message['member']['website']['url'], '" title="' . $message['member']['website']['title'] . '" target="_blank" class="new_win">', ($settings['use_image_buttons'] ? '<span class="generic_icons www centericon" title="' . $message['member']['website']['title'] . '"></span>' : $txt['www']), '</a></li>'; |
| 617 | + } |
|
| 588 | 618 | |
| 589 | 619 | // Since we know this person isn't a guest, you *can* message them. |
| 590 | - if ($context['can_send_pm']) |
|
| 591 | - echo ' |
|
| 620 | + if ($context['can_send_pm']) { |
|
| 621 | + echo ' |
|
| 592 | 622 | <li><a href="', $scripturl, '?action=pm;sa=send;u=', $message['member']['id'], '" title="', $message['member']['online']['is_online'] ? $txt['pm_online'] : $txt['pm_offline'], '">', $settings['use_image_buttons'] ? '<span class="generic_icons im_' . ($message['member']['online']['is_online'] ? 'on' : 'off') . ' centericon" title="' . ($message['member']['online']['is_online'] ? $txt['pm_online'] : $txt['pm_offline']) . '"></span> ' : ($message['member']['online']['is_online'] ? $txt['pm_online'] : $txt['pm_offline']), '</a></li>'; |
| 623 | + } |
|
| 593 | 624 | |
| 594 | 625 | // Show the email if necessary |
| 595 | - if (!empty($message['member']['email']) && $message['member']['show_email']) |
|
| 596 | - echo ' |
|
| 626 | + if (!empty($message['member']['email']) && $message['member']['show_email']) { |
|
| 627 | + echo ' |
|
| 597 | 628 | <li class="email"><a href="mailto:' . $message['member']['email'] . '" rel="nofollow">', ($settings['use_image_buttons'] ? '<span class="generic_icons mail centericon" title="' . $txt['email'] . '"></span>' : $txt['email']), '</a></li>'; |
| 629 | + } |
|
| 598 | 630 | |
| 599 | 631 | echo ' |
| 600 | 632 | </ol> |
@@ -602,48 +634,56 @@ discard block |
||
| 602 | 634 | } |
| 603 | 635 | |
| 604 | 636 | // Any custom fields for standard placement? |
| 605 | - if (!empty($message['custom_fields']['standard'])) |
|
| 606 | - foreach ($message['custom_fields']['standard'] as $custom) |
|
| 637 | + if (!empty($message['custom_fields']['standard'])) { |
|
| 638 | + foreach ($message['custom_fields']['standard'] as $custom) |
|
| 607 | 639 | echo ' |
| 608 | 640 | <li class="custom ', $custom['col_name'] ,'">', $custom['title'], ': ', $custom['value'], '</li>'; |
| 641 | + } |
|
| 609 | 642 | |
| 610 | 643 | } |
| 611 | 644 | // Otherwise, show the guest's email. |
| 612 | - elseif (!empty($message['member']['email']) && $message['member']['show_email']) |
|
| 613 | - echo ' |
|
| 645 | + elseif (!empty($message['member']['email']) && $message['member']['show_email']) { |
|
| 646 | + echo ' |
|
| 614 | 647 | <li class="email"><a href="mailto:' . $message['member']['email'] . '" rel="nofollow">', ($settings['use_image_buttons'] ? '<span class="generic_icons mail centericon" title="' . $txt['email'] . '"></span>' : $txt['email']), '</a></li>'; |
| 648 | + } |
|
| 615 | 649 | |
| 616 | 650 | // Show the IP to this user for this post - because you can moderate? |
| 617 | - if (!empty($context['can_moderate_forum']) && !empty($message['member']['ip'])) |
|
| 618 | - echo ' |
|
| 651 | + if (!empty($context['can_moderate_forum']) && !empty($message['member']['ip'])) { |
|
| 652 | + echo ' |
|
| 619 | 653 | <li class="poster_ip"><a href="', $scripturl, '?action=', !empty($message['member']['is_guest']) ? 'trackip' : 'profile;area=tracking;sa=ip;u=' . $message['member']['id'], ';searchip=', $message['member']['ip'], '">', $message['member']['ip'], '</a> <a href="', $scripturl, '?action=helpadmin;help=see_admin_ip" onclick="return reqOverlayDiv(this.href);" class="help">(?)</a></li>'; |
| 654 | + } |
|
| 620 | 655 | |
| 621 | 656 | // Or, should we show it because this is you? |
| 622 | - elseif ($message['can_see_ip']) |
|
| 623 | - echo ' |
|
| 657 | + elseif ($message['can_see_ip']) { |
|
| 658 | + echo ' |
|
| 624 | 659 | <li class="poster_ip"><a href="', $scripturl, '?action=helpadmin;help=see_member_ip" onclick="return reqOverlayDiv(this.href);" class="help">', $message['member']['ip'], '</a></li>'; |
| 660 | + } |
|
| 625 | 661 | |
| 626 | 662 | // Okay, are you at least logged in? Then we can show something about why IPs are logged... |
| 627 | - elseif (!$context['user']['is_guest']) |
|
| 628 | - echo ' |
|
| 663 | + elseif (!$context['user']['is_guest']) { |
|
| 664 | + echo ' |
|
| 629 | 665 | <li class="poster_ip"><a href="', $scripturl, '?action=helpadmin;help=see_member_ip" onclick="return reqOverlayDiv(this.href);" class="help">', $txt['logged'], '</a></li>'; |
| 666 | + } |
|
| 630 | 667 | |
| 631 | 668 | // Otherwise, you see NOTHING! |
| 632 | - else |
|
| 633 | - echo ' |
|
| 669 | + else { |
|
| 670 | + echo ' |
|
| 634 | 671 | <li class="poster_ip">', $txt['logged'], '</li>'; |
| 672 | + } |
|
| 635 | 673 | |
| 636 | 674 | // Are we showing the warning status? |
| 637 | 675 | // Don't show these things for guests. |
| 638 | - if (!$message['member']['is_guest'] && $message['member']['can_see_warning']) |
|
| 639 | - echo ' |
|
| 676 | + if (!$message['member']['is_guest'] && $message['member']['can_see_warning']) { |
|
| 677 | + echo ' |
|
| 640 | 678 | <li class="warning">', $context['can_issue_warning'] ? '<a href="' . $scripturl . '?action=profile;area=issuewarning;u=' . $message['member']['id'] . '">' : '', '<span class="generic_icons warning_', $message['member']['warning_status'], '"></span> ', $context['can_issue_warning'] ? '</a>' : '', '<span class="warn_', $message['member']['warning_status'], '">', $txt['warn_' . $message['member']['warning_status']], '</span></li>'; |
| 679 | + } |
|
| 641 | 680 | |
| 642 | 681 | // Are there any custom fields to show at the bottom of the poster info? |
| 643 | - if (!empty($message['custom_fields']['bottom_poster'])) |
|
| 644 | - foreach ($message['custom_fields']['bottom_poster'] as $custom) |
|
| 682 | + if (!empty($message['custom_fields']['bottom_poster'])) { |
|
| 683 | + foreach ($message['custom_fields']['bottom_poster'] as $custom) |
|
| 645 | 684 | echo ' |
| 646 | 685 | <li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>'; |
| 686 | + } |
|
| 647 | 687 | |
| 648 | 688 | // Poster info ends. |
| 649 | 689 | echo ' |
@@ -672,9 +712,10 @@ discard block |
||
| 672 | 712 | echo ' |
| 673 | 713 | <span class="smalltext modified" id="modified_', $message['id'], '">'; |
| 674 | 714 | |
| 675 | - if (!empty($modSettings['show_modify']) && !empty($message['modified']['name'])) |
|
| 676 | - echo |
|
| 715 | + if (!empty($modSettings['show_modify']) && !empty($message['modified']['name'])) { |
|
| 716 | + echo |
|
| 677 | 717 | $message['modified']['last_edit_text']; |
| 718 | + } |
|
| 678 | 719 | |
| 679 | 720 | echo ' |
| 680 | 721 | </span>'; |
@@ -685,22 +726,24 @@ discard block |
||
| 685 | 726 | </div>'; |
| 686 | 727 | |
| 687 | 728 | // Ignoring this user? Hide the post. |
| 688 | - if ($ignoring) |
|
| 689 | - echo ' |
|
| 729 | + if ($ignoring) { |
|
| 730 | + echo ' |
|
| 690 | 731 | <div id="msg_', $message['id'], '_ignored_prompt"> |
| 691 | 732 | ', $txt['ignoring_user'], ' |
| 692 | 733 | <a href="#" id="msg_', $message['id'], '_ignored_link" style="display: none;">', $txt['show_ignore_user_post'], '</a> |
| 693 | 734 | </div>'; |
| 735 | + } |
|
| 694 | 736 | |
| 695 | 737 | // Show the post itself, finally! |
| 696 | 738 | echo ' |
| 697 | 739 | <div class="post">'; |
| 698 | 740 | |
| 699 | - if (!$message['approved'] && $message['member']['id'] != 0 && $message['member']['id'] == $context['user']['id']) |
|
| 700 | - echo ' |
|
| 741 | + if (!$message['approved'] && $message['member']['id'] != 0 && $message['member']['id'] == $context['user']['id']) { |
|
| 742 | + echo ' |
|
| 701 | 743 | <div class="approve_post"> |
| 702 | 744 | ', $txt['post_awaiting_approval'], ' |
| 703 | 745 | </div>'; |
| 746 | + } |
|
| 704 | 747 | echo ' |
| 705 | 748 | <div class="inner" data-msgid="', $message['id'], '" id="msg_', $message['id'], '"', $ignoring ? ' style="display:none;"' : '', '>', $message['body'], '</div> |
| 706 | 749 | </div>'; |
@@ -717,9 +760,9 @@ discard block |
||
| 717 | 760 | foreach ($message['attachment'] as $attachment) |
| 718 | 761 | { |
| 719 | 762 | // Do we want this attachment to not be showed here? |
| 720 | - if (!empty($modSettings['dont_show_attach_under_post']) && !empty($context['show_attach_under_post'][$attachment['id']])) |
|
| 721 | - continue; |
|
| 722 | - elseif (!$div_output) |
|
| 763 | + if (!empty($modSettings['dont_show_attach_under_post']) && !empty($context['show_attach_under_post'][$attachment['id']])) { |
|
| 764 | + continue; |
|
| 765 | + } elseif (!$div_output) |
|
| 723 | 766 | { |
| 724 | 767 | $div_output = true; |
| 725 | 768 | |
@@ -735,9 +778,10 @@ discard block |
||
| 735 | 778 | <fieldset> |
| 736 | 779 | <legend>', $txt['attach_awaiting_approve']; |
| 737 | 780 | |
| 738 | - if ($context['can_approve']) |
|
| 739 | - echo ' |
|
| 781 | + if ($context['can_approve']) { |
|
| 782 | + echo ' |
|
| 740 | 783 | [<a href="', $scripturl, '?action=attachapprove;sa=all;mid=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['approve_all'], '</a>]'; |
| 784 | + } |
|
| 741 | 785 | |
| 742 | 786 | echo ' |
| 743 | 787 | </legend>'; |
@@ -751,12 +795,13 @@ discard block |
||
| 751 | 795 | echo ' |
| 752 | 796 | <div class="attachments_top">'; |
| 753 | 797 | |
| 754 | - if ($attachment['thumbnail']['has_thumb']) |
|
| 755 | - echo ' |
|
| 798 | + if ($attachment['thumbnail']['has_thumb']) { |
|
| 799 | + echo ' |
|
| 756 | 800 | <a href="', $attachment['href'], ';image" id="link_', $attachment['id'], '" onclick="', $attachment['thumbnail']['javascript'], '"><img src="', $attachment['thumbnail']['href'], '" alt="" id="thumb_', $attachment['id'], '" class="atc_img"></a>'; |
| 757 | - else |
|
| 758 | - echo ' |
|
| 801 | + } else { |
|
| 802 | + echo ' |
|
| 759 | 803 | <img src="' . $attachment['href'] . ';image" alt="" width="' . $attachment['width'] . '" height="' . $attachment['height'] . '" class="atc_img">'; |
| 804 | + } |
|
| 760 | 805 | |
| 761 | 806 | echo ' |
| 762 | 807 | </div>'; |
@@ -766,9 +811,10 @@ discard block |
||
| 766 | 811 | <div class="attachments_bot"> |
| 767 | 812 | <a href="' . $attachment['href'] . '"><img src="' . $settings['images_url'] . '/icons/clip.png" class="centericon" alt="*"> ' . $attachment['name'] . '</a> '; |
| 768 | 813 | |
| 769 | - if (!$attachment['is_approved'] && $context['can_approve']) |
|
| 770 | - echo ' |
|
| 814 | + if (!$attachment['is_approved'] && $context['can_approve']) { |
|
| 815 | + echo ' |
|
| 771 | 816 | [<a href="', $scripturl, '?action=attachapprove;sa=approve;aid=', $attachment['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['approve'], '</a>] | [<a href="', $scripturl, '?action=attachapprove;sa=reject;aid=', $attachment['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['delete'], '</a>] '; |
| 817 | + } |
|
| 772 | 818 | echo ' |
| 773 | 819 | <br>', $attachment['size'], ($attachment['is_image'] ? ', ' . $attachment['real_width'] . 'x' . $attachment['real_height'] . '<br>' . sprintf($txt['attach_viewed'], $attachment['downloads']) : '<br>' . sprintf($txt['attach_downloaded'], $attachment['downloads'])), ' |
| 774 | 820 | </div>'; |
@@ -777,33 +823,38 @@ discard block |
||
| 777 | 823 | </div>'; |
| 778 | 824 | |
| 779 | 825 | // Next attachment line ? |
| 780 | - if (++$i % $attachments_per_line === 0) |
|
| 781 | - echo ' |
|
| 826 | + if (++$i % $attachments_per_line === 0) { |
|
| 827 | + echo ' |
|
| 782 | 828 | <br>'; |
| 829 | + } |
|
| 783 | 830 | } |
| 784 | 831 | |
| 785 | 832 | // If we had unapproved attachments clean up. |
| 786 | - if ($last_approved_state == 0) |
|
| 787 | - echo ' |
|
| 833 | + if ($last_approved_state == 0) { |
|
| 834 | + echo ' |
|
| 788 | 835 | </fieldset>'; |
| 836 | + } |
|
| 789 | 837 | |
| 790 | 838 | // Only do this if we output a div above - otherwise it'll break things |
| 791 | - if ($div_output) |
|
| 792 | - echo ' |
|
| 839 | + if ($div_output) { |
|
| 840 | + echo ' |
|
| 793 | 841 | </div>'; |
| 842 | + } |
|
| 794 | 843 | } |
| 795 | 844 | |
| 796 | 845 | // And stuff below the attachments. |
| 797 | - if ($context['can_report_moderator'] || !empty($context['can_see_likes']) || !empty($context['can_like']) || $message['can_approve'] || $message['can_unapprove'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg'] || $context['can_quote']) |
|
| 798 | - echo ' |
|
| 846 | + if ($context['can_report_moderator'] || !empty($context['can_see_likes']) || !empty($context['can_like']) || $message['can_approve'] || $message['can_unapprove'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg'] || $context['can_quote']) { |
|
| 847 | + echo ' |
|
| 799 | 848 | <div class="under_message">'; |
| 849 | + } |
|
| 800 | 850 | |
| 801 | 851 | // Maybe they want to report this post to the moderator(s)? |
| 802 | - if ($context['can_report_moderator']) |
|
| 803 | - echo ' |
|
| 852 | + if ($context['can_report_moderator']) { |
|
| 853 | + echo ' |
|
| 804 | 854 | <ul class="floatright smalltext"> |
| 805 | 855 | <li class="report_link"><a href="', $scripturl, '?action=reporttm;topic=', $context['current_topic'], '.', $message['counter'], ';msg=', $message['id'], '">', $txt['report_to_mod'], '</a></li> |
| 806 | 856 | </ul>'; |
| 857 | + } |
|
| 807 | 858 | |
| 808 | 859 | // What about likes? |
| 809 | 860 | if (!empty($modSettings['enable_likes'])) |
@@ -844,78 +895,91 @@ discard block |
||
| 844 | 895 | <ul class="quickbuttons">'; |
| 845 | 896 | |
| 846 | 897 | // Can they quote? if so they can select and quote as well! |
| 847 | - if ($context['can_quote']) |
|
| 848 | - echo ' |
|
| 898 | + if ($context['can_quote']) { |
|
| 899 | + echo ' |
|
| 849 | 900 | <li><a href="', $scripturl, '?action=post;quote=', $message['id'], ';topic=', $context['current_topic'], '.', $context['start'], ';last_msg=', $context['topic_last_message'], '" onclick="return oQuickReply.quote(', $message['id'], ');"><span class="generic_icons quote"></span>', $txt['quote_action'], '</a></li> |
| 850 | 901 | <li style="display:none;" id="quoteSelected_', $message['id'], '"><a href="javascript:void(0)"><span class="generic_icons quote_selected"></span>', $txt['quote_selected_action'] ,'</a></li>'; |
| 902 | + } |
|
| 851 | 903 | |
| 852 | 904 | // Can the user modify the contents of this post? Show the modify inline image. |
| 853 | - if ($message['can_modify']) |
|
| 854 | - echo ' |
|
| 905 | + if ($message['can_modify']) { |
|
| 906 | + echo ' |
|
| 855 | 907 | <li class="quick_edit"><a title="', $txt['modify_msg'], '" class="modifybutton" id="modify_button_', $message['id'], '" onclick="oQuickModify.modifyMsg(\'', $message['id'], '\', \'', !empty($modSettings['toggle_subject']), '\')"><span class="generic_icons quick_edit_button"></span>', $txt['quick_edit'], '</a></li>'; |
| 908 | + } |
|
| 856 | 909 | |
| 857 | - if ($message['can_approve'] || $message['can_unapprove'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg']) |
|
| 858 | - echo ' |
|
| 910 | + if ($message['can_approve'] || $message['can_unapprove'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg']) { |
|
| 911 | + echo ' |
|
| 859 | 912 | <li class="post_options">', $txt['post_options']; |
| 913 | + } |
|
| 860 | 914 | |
| 861 | 915 | echo ' |
| 862 | 916 | <ul>'; |
| 863 | 917 | |
| 864 | 918 | // Can the user modify the contents of this post? |
| 865 | - if ($message['can_modify']) |
|
| 866 | - echo ' |
|
| 919 | + if ($message['can_modify']) { |
|
| 920 | + echo ' |
|
| 867 | 921 | <li><a href="', $scripturl, '?action=post;msg=', $message['id'], ';topic=', $context['current_topic'], '.', $context['start'], '"><span class="generic_icons modify_button"></span>', $txt['modify'], '</a></li>'; |
| 922 | + } |
|
| 868 | 923 | |
| 869 | 924 | // How about... even... remove it entirely?! |
| 870 | - if ($context['can_delete'] && ($context['topic_first_message'] == $message['id'])) |
|
| 871 | - echo ' |
|
| 925 | + if ($context['can_delete'] && ($context['topic_first_message'] == $message['id'])) { |
|
| 926 | + echo ' |
|
| 872 | 927 | <li><a href="', $scripturl, '?action=removetopic2;topic=', $context['current_topic'], '.', $context['start'], ';', $context['session_var'], '=', $context['session_id'], '" data-confirm="', $txt['are_sure_remove_topic'], '" class="you_sure"><span class="generic_icons remove_button"></span>', $txt['remove_topic'],'</a></li>'; |
| 873 | - elseif ($message['can_remove'] && ($context['topic_first_message'] != $message['id'])) |
|
| 874 | - echo ' |
|
| 928 | + } elseif ($message['can_remove'] && ($context['topic_first_message'] != $message['id'])) { |
|
| 929 | + echo ' |
|
| 875 | 930 | <li><a href="', $scripturl, '?action=deletemsg;topic=', $context['current_topic'], '.', $context['start'], ';msg=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '" data-confirm="', $txt['remove_message_question'] ,'" class="you_sure"><span class="generic_icons remove_button"></span>', $txt['remove'], '</a></li>'; |
| 931 | + } |
|
| 876 | 932 | |
| 877 | 933 | // What about splitting it off the rest of the topic? |
| 878 | - if ($context['can_split'] && !empty($context['real_num_replies'])) |
|
| 879 | - echo ' |
|
| 934 | + if ($context['can_split'] && !empty($context['real_num_replies'])) { |
|
| 935 | + echo ' |
|
| 880 | 936 | <li><a href="', $scripturl, '?action=splittopics;topic=', $context['current_topic'], '.0;at=', $message['id'], '"><span class="generic_icons split_button"></span>', $txt['split'], '</a></li>'; |
| 937 | + } |
|
| 881 | 938 | |
| 882 | 939 | // Can we issue a warning because of this post? Remember, we can't give guests warnings. |
| 883 | - if ($context['can_issue_warning'] && !$message['is_message_author'] && !$message['member']['is_guest']) |
|
| 884 | - echo ' |
|
| 940 | + if ($context['can_issue_warning'] && !$message['is_message_author'] && !$message['member']['is_guest']) { |
|
| 941 | + echo ' |
|
| 885 | 942 | <li><a href="', $scripturl, '?action=profile;area=issuewarning;u=', $message['member']['id'], ';msg=', $message['id'], '"><span class="generic_icons warn_button"></span>', $txt['issue_warning'], '</a></li>'; |
| 943 | + } |
|
| 886 | 944 | |
| 887 | 945 | // Can we restore topics? |
| 888 | - if ($context['can_restore_msg']) |
|
| 889 | - echo ' |
|
| 946 | + if ($context['can_restore_msg']) { |
|
| 947 | + echo ' |
|
| 890 | 948 | <li><a href="', $scripturl, '?action=restoretopic;msgs=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="generic_icons restore_button"></span>', $txt['restore_message'], '</a></li>'; |
| 949 | + } |
|
| 891 | 950 | |
| 892 | 951 | // Maybe we can approve it, maybe we should? |
| 893 | - if ($message['can_approve']) |
|
| 894 | - echo ' |
|
| 952 | + if ($message['can_approve']) { |
|
| 953 | + echo ' |
|
| 895 | 954 | <li><a href="', $scripturl, '?action=moderate;area=postmod;sa=approve;topic=', $context['current_topic'], '.', $context['start'], ';msg=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="generic_icons approve_button"></span>', $txt['approve'], '</a></li>'; |
| 955 | + } |
|
| 896 | 956 | |
| 897 | 957 | // Maybe we can unapprove it? |
| 898 | - if ($message['can_unapprove']) |
|
| 899 | - echo ' |
|
| 958 | + if ($message['can_unapprove']) { |
|
| 959 | + echo ' |
|
| 900 | 960 | <li><a href="', $scripturl, '?action=moderate;area=postmod;sa=approve;topic=', $context['current_topic'], '.', $context['start'], ';msg=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="generic_icons unapprove_button"></span>', $txt['unapprove'], '</a></li>'; |
| 961 | + } |
|
| 901 | 962 | |
| 902 | 963 | echo ' |
| 903 | 964 | </ul> |
| 904 | 965 | </li>'; |
| 905 | 966 | |
| 906 | 967 | // Show a checkbox for quick moderation? |
| 907 | - if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && $message['can_remove']) |
|
| 908 | - echo ' |
|
| 968 | + if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && $message['can_remove']) { |
|
| 969 | + echo ' |
|
| 909 | 970 | <li style="display: none;" id="in_topic_mod_check_', $message['id'], '"></li>'; |
| 971 | + } |
|
| 910 | 972 | |
| 911 | - if ($message['can_approve'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg']) |
|
| 912 | - echo ' |
|
| 973 | + if ($message['can_approve'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg']) { |
|
| 974 | + echo ' |
|
| 913 | 975 | </ul>'; |
| 976 | + } |
|
| 914 | 977 | } |
| 915 | 978 | |
| 916 | - if ($context['can_report_moderator'] || !empty($context['can_see_likes']) || !empty($context['can_like']) || $message['can_approve'] || $message['can_unapprove'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg'] || $context['can_quote']) |
|
| 917 | - echo ' |
|
| 979 | + if ($context['can_report_moderator'] || !empty($context['can_see_likes']) || !empty($context['can_like']) || $message['can_approve'] || $message['can_unapprove'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg'] || $context['can_quote']) { |
|
| 980 | + echo ' |
|
| 918 | 981 | </div>'; |
| 982 | + } |
|
| 919 | 983 | |
| 920 | 984 | echo ' |
| 921 | 985 | </div> |
@@ -928,9 +992,10 @@ discard block |
||
| 928 | 992 | <div class="custom_fields_above_signature"> |
| 929 | 993 | <ul class="nolist">'; |
| 930 | 994 | |
| 931 | - foreach ($message['custom_fields']['above_signature'] as $custom) |
|
| 932 | - echo ' |
|
| 995 | + foreach ($message['custom_fields']['above_signature'] as $custom) { |
|
| 996 | + echo ' |
|
| 933 | 997 | <li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>'; |
| 998 | + } |
|
| 934 | 999 | |
| 935 | 1000 | echo ' |
| 936 | 1001 | </ul> |
@@ -938,9 +1003,10 @@ discard block |
||
| 938 | 1003 | } |
| 939 | 1004 | |
| 940 | 1005 | // Show the member's signature? |
| 941 | - if (!empty($message['member']['signature']) && empty($options['show_no_signatures']) && $context['signature_enabled']) |
|
| 942 | - echo ' |
|
| 1006 | + if (!empty($message['member']['signature']) && empty($options['show_no_signatures']) && $context['signature_enabled']) { |
|
| 1007 | + echo ' |
|
| 943 | 1008 | <div class="signature" id="msg_', $message['id'], '_signature"', $ignoring ? ' style="display:none;"' : '', '>', $message['member']['signature'], '</div>'; |
| 1009 | + } |
|
| 944 | 1010 | |
| 945 | 1011 | |
| 946 | 1012 | // Are there any custom profile fields for below the signature? |
@@ -950,9 +1016,10 @@ discard block |
||
| 950 | 1016 | <div class="custom_fields_below_signature"> |
| 951 | 1017 | <ul class="nolist">'; |
| 952 | 1018 | |
| 953 | - foreach ($message['custom_fields']['below_signature'] as $custom) |
|
| 954 | - echo ' |
|
| 1019 | + foreach ($message['custom_fields']['below_signature'] as $custom) { |
|
| 1020 | + echo ' |
|
| 955 | 1021 | <li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>'; |
| 1022 | + } |
|
| 956 | 1023 | |
| 957 | 1024 | echo ' |
| 958 | 1025 | </ul> |
@@ -1000,8 +1067,8 @@ discard block |
||
| 1000 | 1067 | <input type="hidden" name="seqnum" value="', $context['form_sequence_number'], '">'; |
| 1001 | 1068 | |
| 1002 | 1069 | // Guests just need more. |
| 1003 | - if ($context['user']['is_guest']) |
|
| 1004 | - echo ' |
|
| 1070 | + if ($context['user']['is_guest']) { |
|
| 1071 | + echo ' |
|
| 1005 | 1072 | <dl id="post_header"> |
| 1006 | 1073 | <dt> |
| 1007 | 1074 | ', $txt['name'], ': |
@@ -1016,6 +1083,7 @@ discard block |
||
| 1016 | 1083 | <input type="email" name="email" size="25" value="', $context['email'], '" tabindex="', $context['tabindex']++, '" class="input_text" required> |
| 1017 | 1084 | </dd> |
| 1018 | 1085 | </dl>'; |
| 1086 | + } |
|
| 1019 | 1087 | |
| 1020 | 1088 | echo ' |
| 1021 | 1089 | ', template_control_richedit($context['post_box_name'], 'smileyBox_message', 'bbcBox_message'), ' |
@@ -1063,8 +1131,8 @@ discard block |
||
| 1063 | 1131 | <br class="clear">'; |
| 1064 | 1132 | |
| 1065 | 1133 | // draft autosave available and the user has it enabled? |
| 1066 | - if (!empty($context['drafts_autosave'])) |
|
| 1067 | - echo ' |
|
| 1134 | + if (!empty($context['drafts_autosave'])) { |
|
| 1135 | + echo ' |
|
| 1068 | 1136 | <script> |
| 1069 | 1137 | var oDraftAutoSave = new smf_DraftAutoSave({ |
| 1070 | 1138 | sSelf: \'oDraftAutoSave\', |
@@ -1076,10 +1144,12 @@ discard block |
||
| 1076 | 1144 | iFreq: ', (empty($modSettings['masterAutoSaveDraftsDelay']) ? 60000 : $modSettings['masterAutoSaveDraftsDelay'] * 1000), ' |
| 1077 | 1145 | }); |
| 1078 | 1146 | </script>'; |
| 1147 | + } |
|
| 1079 | 1148 | |
| 1080 | - if ($context['show_spellchecking']) |
|
| 1081 | - echo ' |
|
| 1149 | + if ($context['show_spellchecking']) { |
|
| 1150 | + echo ' |
|
| 1082 | 1151 | <form action="', $scripturl, '?action=spellcheck" method="post" accept-charset="', $context['character_set'], '" name="spell_form" id="spell_form" target="spellWindow"><input type="hidden" name="spellstring" value=""></form>'; |
| 1152 | + } |
|
| 1083 | 1153 | |
| 1084 | 1154 | echo ' |
| 1085 | 1155 | <script> |
@@ -253,9 +253,9 @@ discard block |
||
| 253 | 253 | { |
| 254 | 254 | // Sort events by start time (all day events will be listed first) |
| 255 | 255 | uasort($day['events'], function ($a, $b) { |
| 256 | - if ($a['start_timestamp'] == $b['start_timestamp']) |
|
| 257 | - return 0; |
|
| 258 | - return ($a['start_timestamp'] < $b['start_timestamp']) ? -1 : 1; |
|
| 256 | + if ($a['start_timestamp'] == $b['start_timestamp']) |
|
| 257 | + return 0; |
|
| 258 | + return ($a['start_timestamp'] < $b['start_timestamp']) ? -1 : 1; |
|
| 259 | 259 | }); |
| 260 | 260 | |
| 261 | 261 | echo ' |
@@ -436,9 +436,9 @@ discard block |
||
| 436 | 436 | { |
| 437 | 437 | // Sort events by start time (all day events will be listed first) |
| 438 | 438 | uasort($day['events'], function ($a, $b) { |
| 439 | - if ($a['start_timestamp'] == $b['start_timestamp']) |
|
| 440 | - return 0; |
|
| 441 | - return ($a['start_timestamp'] < $b['start_timestamp']) ? -1 : 1; |
|
| 439 | + if ($a['start_timestamp'] == $b['start_timestamp']) |
|
| 440 | + return 0; |
|
| 441 | + return ($a['start_timestamp'] < $b['start_timestamp']) ? -1 : 1; |
|
| 442 | 442 | }); |
| 443 | 443 | |
| 444 | 444 | foreach ($day['events'] as $event) |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | * Display a list of upcoming events, birthdays, and holidays. |
| 69 | 69 | * |
| 70 | 70 | * @param string $grid_name The grid name |
| 71 | - * @return void|bool Returns false if the grid doesn't exist. |
|
| 71 | + * @return false|null Returns false if the grid doesn't exist. |
|
| 72 | 72 | */ |
| 73 | 73 | function template_show_upcoming_list($grid_name) |
| 74 | 74 | { |
@@ -238,7 +238,7 @@ discard block |
||
| 238 | 238 | * |
| 239 | 239 | * @param string $grid_name The grid name |
| 240 | 240 | * @param bool $is_mini Is this a mini grid? |
| 241 | - * @return void|bool Returns false if the grid doesn't exist. |
|
| 241 | + * @return false|null Returns false if the grid doesn't exist. |
|
| 242 | 242 | */ |
| 243 | 243 | function template_show_month_grid($grid_name, $is_mini = false) |
| 244 | 244 | { |
@@ -523,7 +523,7 @@ discard block |
||
| 523 | 523 | * Shows a weekly grid |
| 524 | 524 | * |
| 525 | 525 | * @param string $grid_name The name of the grid |
| 526 | - * @return void|bool Returns false if the grid doesn't exist |
|
| 526 | + * @return false|null Returns false if the grid doesn't exist |
|
| 527 | 527 | */ |
| 528 | 528 | function template_show_week_grid($grid_name) |
| 529 | 529 | { |
@@ -40,16 +40,14 @@ discard block |
||
| 40 | 40 | ', template_show_upcoming_list('main'), ' |
| 41 | 41 | </div> |
| 42 | 42 | '; |
| 43 | - } |
|
| 44 | - elseif ($context['calendar_view'] == 'view_week') |
|
| 43 | + } elseif ($context['calendar_view'] == 'view_week') |
|
| 45 | 44 | { |
| 46 | 45 | echo ' |
| 47 | 46 | <div id="main_grid"> |
| 48 | 47 | ', template_show_week_grid('main'), ' |
| 49 | 48 | </div> |
| 50 | 49 | '; |
| 51 | - } |
|
| 52 | - else |
|
| 50 | + } else |
|
| 53 | 51 | { |
| 54 | 52 | echo ' |
| 55 | 53 | <div id="main_grid"> |
@@ -75,8 +73,9 @@ discard block |
||
| 75 | 73 | global $context, $scripturl, $txt, $modSettings; |
| 76 | 74 | |
| 77 | 75 | // Bail out if we have nothing to work with |
| 78 | - if (!isset($context['calendar_grid_' . $grid_name])) |
|
| 79 | - return false; |
|
| 76 | + if (!isset($context['calendar_grid_' . $grid_name])) { |
|
| 77 | + return false; |
|
| 78 | + } |
|
| 80 | 79 | |
| 81 | 80 | // Protect programmer sanity |
| 82 | 81 | $calendar_data = &$context['calendar_grid_' . $grid_name]; |
@@ -113,11 +112,13 @@ discard block |
||
| 113 | 112 | <li class="windowbg"> |
| 114 | 113 | <b class="event_title">', $event['link'], '</b>'; |
| 115 | 114 | |
| 116 | - if ($event['can_edit']) |
|
| 117 | - echo ' <a href="' . $event['modify_href'] . '"><span class="generic_icons calendar_modify" title="', $txt['calendar_edit'], '"></span></a>'; |
|
| 115 | + if ($event['can_edit']) { |
|
| 116 | + echo ' <a href="' . $event['modify_href'] . '"><span class="generic_icons calendar_modify" title="', $txt['calendar_edit'], '"></span></a>'; |
|
| 117 | + } |
|
| 118 | 118 | |
| 119 | - if ($event['can_export']) |
|
| 120 | - echo ' <a href="' . $event['export_href'] . '"><span class="generic_icons calendar_export" title="', $txt['calendar_export'], '"></span></a>'; |
|
| 119 | + if ($event['can_export']) { |
|
| 120 | + echo ' <a href="' . $event['export_href'] . '"><span class="generic_icons calendar_export" title="', $txt['calendar_export'], '"></span></a>'; |
|
| 121 | + } |
|
| 121 | 122 | |
| 122 | 123 | echo ' |
| 123 | 124 | <br>'; |
@@ -125,14 +126,14 @@ discard block |
||
| 125 | 126 | if (!empty($event['allday'])) |
| 126 | 127 | { |
| 127 | 128 | echo '<time datetime="' . $event['start_iso_gmdate'] . '">', trim($event['start_date_local']), '</time>', ($event['start_date'] != $event['end_date']) ? ' – <time datetime="' . $event['end_iso_gmdate'] . '">' . trim($event['end_date_local']) . '</time>' : ''; |
| 128 | - } |
|
| 129 | - else |
|
| 129 | + } else |
|
| 130 | 130 | { |
| 131 | 131 | // Display event info relative to user's local timezone |
| 132 | 132 | echo '<time datetime="' . $event['start_iso_gmdate'] . '">', trim($event['start_date_local']), ', ', trim($event['start_time_local']), '</time> – <time datetime="' . $event['end_iso_gmdate'] . '">'; |
| 133 | 133 | |
| 134 | - if ($event['start_date_local'] != $event['end_date_local']) |
|
| 135 | - echo trim($event['end_date_local']) . ', '; |
|
| 134 | + if ($event['start_date_local'] != $event['end_date_local']) { |
|
| 135 | + echo trim($event['end_date_local']) . ', '; |
|
| 136 | + } |
|
| 136 | 137 | |
| 137 | 138 | echo trim($event['end_time_local']); |
| 138 | 139 | |
@@ -141,23 +142,27 @@ discard block |
||
| 141 | 142 | { |
| 142 | 143 | echo '</time> (<time datetime="' . $event['start_iso_gmdate'] . '">'; |
| 143 | 144 | |
| 144 | - if ($event['start_date_orig'] != $event['start_date_local'] || $event['end_date_orig'] != $event['end_date_local'] || $event['start_date_orig'] != $event['end_date_orig']) |
|
| 145 | - echo trim($event['start_date_orig']), ', '; |
|
| 145 | + if ($event['start_date_orig'] != $event['start_date_local'] || $event['end_date_orig'] != $event['end_date_local'] || $event['start_date_orig'] != $event['end_date_orig']) { |
|
| 146 | + echo trim($event['start_date_orig']), ', '; |
|
| 147 | + } |
|
| 146 | 148 | |
| 147 | 149 | echo trim($event['start_time_orig']), '</time> – <time datetime="' . $event['end_iso_gmdate'] . '">'; |
| 148 | 150 | |
| 149 | - if ($event['start_date_orig'] != $event['end_date_orig']) |
|
| 150 | - echo trim($event['end_date_orig']) . ', '; |
|
| 151 | + if ($event['start_date_orig'] != $event['end_date_orig']) { |
|
| 152 | + echo trim($event['end_date_orig']) . ', '; |
|
| 153 | + } |
|
| 151 | 154 | |
| 152 | 155 | echo trim($event['end_time_orig']), ' ', $event['tz_abbrev'], '</time>)'; |
| 153 | 156 | } |
| 154 | 157 | // Event is scheduled in the user's own timezone? Let 'em know, just to avoid confusion |
| 155 | - else |
|
| 156 | - echo ' ', $event['tz_abbrev'], '</time>'; |
|
| 158 | + else { |
|
| 159 | + echo ' ', $event['tz_abbrev'], '</time>'; |
|
| 160 | + } |
|
| 157 | 161 | } |
| 158 | 162 | |
| 159 | - if (!empty($event['location'])) |
|
| 160 | - echo '<br>', $event['location']; |
|
| 163 | + if (!empty($event['location'])) { |
|
| 164 | + echo '<br>', $event['location']; |
|
| 165 | + } |
|
| 161 | 166 | |
| 162 | 167 | echo ' |
| 163 | 168 | </li>'; |
@@ -189,8 +194,9 @@ discard block |
||
| 189 | 194 | |
| 190 | 195 | $birthdays = array(); |
| 191 | 196 | |
| 192 | - foreach ($date as $member) |
|
| 193 | - $birthdays[] = '<a href="' . $scripturl . '?action=profile;u=' . $member['id'] . '">' . $member['name'] . (isset($member['age']) ? ' (' . $member['age'] . ')' : '') . '</a>'; |
|
| 197 | + foreach ($date as $member) { |
|
| 198 | + $birthdays[] = '<a href="' . $scripturl . '?action=profile;u=' . $member['id'] . '">' . $member['name'] . (isset($member['age']) ? ' (' . $member['age'] . ')' : '') . '</a>'; |
|
| 199 | + } |
|
| 194 | 200 | |
| 195 | 201 | echo implode(', ', $birthdays); |
| 196 | 202 | |
@@ -221,8 +227,9 @@ discard block |
||
| 221 | 227 | $date_local = $date['date_local']; |
| 222 | 228 | unset($date['date_local']); |
| 223 | 229 | |
| 224 | - foreach ($date as $holiday) |
|
| 225 | - $holidays[] = $holiday . ' (' . $date_local . ')'; |
|
| 230 | + foreach ($date as $holiday) { |
|
| 231 | + $holidays[] = $holiday . ' (' . $date_local . ')'; |
|
| 232 | + } |
|
| 226 | 233 | } |
| 227 | 234 | |
| 228 | 235 | echo implode(', ', $holidays); |
@@ -245,17 +252,19 @@ discard block |
||
| 245 | 252 | global $context, $settings, $txt, $scripturl, $modSettings; |
| 246 | 253 | |
| 247 | 254 | // If the grid doesn't exist, no point in proceeding. |
| 248 | - if (!isset($context['calendar_grid_' . $grid_name])) |
|
| 249 | - return false; |
|
| 255 | + if (!isset($context['calendar_grid_' . $grid_name])) { |
|
| 256 | + return false; |
|
| 257 | + } |
|
| 250 | 258 | |
| 251 | 259 | // A handy little pointer variable. |
| 252 | 260 | $calendar_data = &$context['calendar_grid_' . $grid_name]; |
| 253 | 261 | |
| 254 | 262 | // Some conditions for whether or not we should show the week links *here*. |
| 255 | - if (isset($calendar_data['show_week_links']) && ($calendar_data['show_week_links'] == 3 || (($calendar_data['show_week_links'] == 1 && $is_mini === true) || $calendar_data['show_week_links'] == 2 && $is_mini === false))) |
|
| 256 | - $show_week_links = true; |
|
| 257 | - else |
|
| 258 | - $show_week_links = false; |
|
| 263 | + if (isset($calendar_data['show_week_links']) && ($calendar_data['show_week_links'] == 3 || (($calendar_data['show_week_links'] == 1 && $is_mini === true) || $calendar_data['show_week_links'] == 2 && $is_mini === false))) { |
|
| 264 | + $show_week_links = true; |
|
| 265 | + } else { |
|
| 266 | + $show_week_links = false; |
|
| 267 | + } |
|
| 259 | 268 | |
| 260 | 269 | // Assuming that we've not disabled it, show the title block! |
| 261 | 270 | if (empty($calendar_data['disable_title'])) |
@@ -294,8 +303,9 @@ discard block |
||
| 294 | 303 | } |
| 295 | 304 | |
| 296 | 305 | // Show the controls on main grids |
| 297 | - if ($is_mini === false) |
|
| 298 | - template_calendar_top($calendar_data); |
|
| 306 | + if ($is_mini === false) { |
|
| 307 | + template_calendar_top($calendar_data); |
|
| 308 | + } |
|
| 299 | 309 | |
| 300 | 310 | // Finally, the main calendar table. |
| 301 | 311 | echo '<table class="calendar_table">'; |
@@ -306,8 +316,9 @@ discard block |
||
| 306 | 316 | echo '<tr>'; |
| 307 | 317 | |
| 308 | 318 | // If we're showing week links, there's an extra column ahead of the week links, so let's think ahead and be prepared! |
| 309 | - if ($show_week_links === true) |
|
| 310 | - echo '<th> </th>'; |
|
| 319 | + if ($show_week_links === true) { |
|
| 320 | + echo '<th> </th>'; |
|
| 321 | + } |
|
| 311 | 322 | |
| 312 | 323 | // Now, loop through each actual day of the week. |
| 313 | 324 | foreach ($calendar_data['week_days'] as $day) |
@@ -354,27 +365,29 @@ discard block |
||
| 354 | 365 | // Additional classes are given for events, holidays, and birthdays. |
| 355 | 366 | if (!empty($day['events']) && !empty($calendar_data['highlight']['events'])) |
| 356 | 367 | { |
| 357 | - if ($is_mini === true && in_array($calendar_data['highlight']['events'], array(1, 3))) |
|
| 358 | - $classes[] = 'events'; |
|
| 359 | - elseif ($is_mini === false && in_array($calendar_data['highlight']['events'], array(2, 3))) |
|
| 360 | - $classes[] = 'events'; |
|
| 368 | + if ($is_mini === true && in_array($calendar_data['highlight']['events'], array(1, 3))) { |
|
| 369 | + $classes[] = 'events'; |
|
| 370 | + } elseif ($is_mini === false && in_array($calendar_data['highlight']['events'], array(2, 3))) { |
|
| 371 | + $classes[] = 'events'; |
|
| 372 | + } |
|
| 361 | 373 | } |
| 362 | 374 | if (!empty($day['holidays']) && !empty($calendar_data['highlight']['holidays'])) |
| 363 | 375 | { |
| 364 | - if ($is_mini === true && in_array($calendar_data['highlight']['holidays'], array(1, 3))) |
|
| 365 | - $classes[] = 'holidays'; |
|
| 366 | - elseif ($is_mini === false && in_array($calendar_data['highlight']['holidays'], array(2, 3))) |
|
| 367 | - $classes[] = 'holidays'; |
|
| 376 | + if ($is_mini === true && in_array($calendar_data['highlight']['holidays'], array(1, 3))) { |
|
| 377 | + $classes[] = 'holidays'; |
|
| 378 | + } elseif ($is_mini === false && in_array($calendar_data['highlight']['holidays'], array(2, 3))) { |
|
| 379 | + $classes[] = 'holidays'; |
|
| 380 | + } |
|
| 368 | 381 | } |
| 369 | 382 | if (!empty($day['birthdays']) && !empty($calendar_data['highlight']['birthdays'])) |
| 370 | 383 | { |
| 371 | - if ($is_mini === true && in_array($calendar_data['highlight']['birthdays'], array(1, 3))) |
|
| 372 | - $classes[] = 'birthdays'; |
|
| 373 | - elseif ($is_mini === false && in_array($calendar_data['highlight']['birthdays'], array(2, 3))) |
|
| 374 | - $classes[] = 'birthdays'; |
|
| 384 | + if ($is_mini === true && in_array($calendar_data['highlight']['birthdays'], array(1, 3))) { |
|
| 385 | + $classes[] = 'birthdays'; |
|
| 386 | + } elseif ($is_mini === false && in_array($calendar_data['highlight']['birthdays'], array(2, 3))) { |
|
| 387 | + $classes[] = 'birthdays'; |
|
| 388 | + } |
|
| 375 | 389 | } |
| 376 | - } |
|
| 377 | - else |
|
| 390 | + } else |
|
| 378 | 391 | { |
| 379 | 392 | // Default Classes (either compact or comfortable and disabled). |
| 380 | 393 | $classes[] = !empty($calendar_data['size']) && $calendar_data['size'] == 'small' ? 'compact' : 'comfortable'; |
@@ -392,17 +405,19 @@ discard block |
||
| 392 | 405 | $title_prefix = !empty($day['is_first_of_month']) && $context['current_month'] == $calendar_data['current_month'] && $is_mini === false ? (!empty($calendar_data['short_month_titles']) ? $txt['months_short'][$calendar_data['current_month']] . ' ' : $txt['months_titles'][$calendar_data['current_month']] . ' ') : ''; |
| 393 | 406 | |
| 394 | 407 | // The actual day number - be it a link, or just plain old text! |
| 395 | - if (!empty($modSettings['cal_daysaslink']) && $context['can_post']) |
|
| 396 | - echo '<a href="', $scripturl, '?action=calendar;sa=post;year=', $calendar_data['current_year'], ';month=', $calendar_data['current_month'], ';day=', $day['day'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="day_text">', $title_prefix, $day['day'], '</span></a>'; |
|
| 397 | - else |
|
| 398 | - echo '<span class="day_text">', $title_prefix, $day['day'], '</span>'; |
|
| 408 | + if (!empty($modSettings['cal_daysaslink']) && $context['can_post']) { |
|
| 409 | + echo '<a href="', $scripturl, '?action=calendar;sa=post;year=', $calendar_data['current_year'], ';month=', $calendar_data['current_month'], ';day=', $day['day'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="day_text">', $title_prefix, $day['day'], '</span></a>'; |
|
| 410 | + } else { |
|
| 411 | + echo '<span class="day_text">', $title_prefix, $day['day'], '</span>'; |
|
| 412 | + } |
|
| 399 | 413 | |
| 400 | 414 | // A lot of stuff, we're not showing on mini-calendars to conserve space. |
| 401 | 415 | if ($is_mini === false) |
| 402 | 416 | { |
| 403 | 417 | // Holidays are always fun, let's show them! |
| 404 | - if (!empty($day['holidays'])) |
|
| 405 | - echo '<div class="smalltext holiday"><span>', $txt['calendar_prompt'], '</span> ', implode(', ', $day['holidays']), '</div>'; |
|
| 418 | + if (!empty($day['holidays'])) { |
|
| 419 | + echo '<div class="smalltext holiday"><span>', $txt['calendar_prompt'], '</span> ', implode(', ', $day['holidays']), '</div>'; |
|
| 420 | + } |
|
| 406 | 421 | |
| 407 | 422 | // Happy Birthday Dear, Member! |
| 408 | 423 | if (!empty($day['birthdays'])) |
@@ -420,14 +435,16 @@ discard block |
||
| 420 | 435 | echo '<a href="', $scripturl, '?action=profile;u=', $member['id'], '"><span class="fix_rtl_names">', $member['name'], '</span>', isset($member['age']) ? ' (' . $member['age'] . ')' : '', '</a>', $member['is_last'] || ($count == 10 && $use_js_hide) ? '' : ', '; |
| 421 | 436 | |
| 422 | 437 | // 9...10! Let's stop there. |
| 423 | - if ($birthday_count == 10 && $use_js_hide) |
|
| 424 | - // !!TODO - Inline CSS and JavaScript should be moved. |
|
| 438 | + if ($birthday_count == 10 && $use_js_hide) { |
|
| 439 | + // !!TODO - Inline CSS and JavaScript should be moved. |
|
| 425 | 440 | echo '<span class="hidelink" id="bdhidelink_', $day['day'], '">...<br><a href="', $scripturl, '?action=calendar;month=', $calendar_data['current_month'], ';year=', $calendar_data['current_year'], ';showbd" onclick="document.getElementById(\'bdhide_', $day['day'], '\').style.display = \'\'; document.getElementById(\'bdhidelink_', $day['day'], '\').style.display = \'none\'; return false;">(', sprintf($txt['calendar_click_all'], count($day['birthdays'])), ')</a></span><span id="bdhide_', $day['day'], '" style="display: none;">, '; |
| 441 | + } |
|
| 426 | 442 | |
| 427 | 443 | ++$birthday_count; |
| 428 | 444 | } |
| 429 | - if ($use_js_hide) |
|
| 430 | - echo '</span>'; |
|
| 445 | + if ($use_js_hide) { |
|
| 446 | + echo '</span>'; |
|
| 447 | + } |
|
| 431 | 448 | |
| 432 | 449 | echo '</div>'; |
| 433 | 450 | } |
@@ -437,8 +454,9 @@ discard block |
||
| 437 | 454 | { |
| 438 | 455 | // Sort events by start time (all day events will be listed first) |
| 439 | 456 | uasort($day['events'], function($a, $b) { |
| 440 | - if ($a['start_timestamp'] == $b['start_timestamp']) |
|
| 441 | - return 0; |
|
| 457 | + if ($a['start_timestamp'] == $b['start_timestamp']) { |
|
| 458 | + return 0; |
|
| 459 | + } |
|
| 442 | 460 | return ($a['start_timestamp'] < $b['start_timestamp']) ? -1 : 1; |
| 443 | 461 | }); |
| 444 | 462 | |
@@ -454,17 +472,19 @@ discard block |
||
| 454 | 472 | |
| 455 | 473 | echo '<div class="event_wrapper', $event['starts_today'] == true ? ' event_starts_today' : '', $event['ends_today'] == true ? ' event_ends_today' : '', $event['allday'] == true ? ' allday' : '', $event['is_selected'] ? ' sel_event' : '', '">', $event['link'], '<br><span class="event_time', empty($event_icons_needed) ? ' floatright' : '', '">'; |
| 456 | 474 | |
| 457 | - if (!empty($event['start_time_local']) && $event['starts_today'] == true) |
|
| 458 | - echo trim(str_replace(':00 ', ' ', $event['start_time_local'])); |
|
| 459 | - elseif (!empty($event['end_time_local']) && $event['ends_today'] == true) |
|
| 460 | - echo strtolower($txt['ends']), ' ', trim(str_replace(':00 ', ' ', $event['end_time_local'])); |
|
| 461 | - elseif (!empty($event['allday'])) |
|
| 462 | - echo $txt['calendar_allday']; |
|
| 475 | + if (!empty($event['start_time_local']) && $event['starts_today'] == true) { |
|
| 476 | + echo trim(str_replace(':00 ', ' ', $event['start_time_local'])); |
|
| 477 | + } elseif (!empty($event['end_time_local']) && $event['ends_today'] == true) { |
|
| 478 | + echo strtolower($txt['ends']), ' ', trim(str_replace(':00 ', ' ', $event['end_time_local'])); |
|
| 479 | + } elseif (!empty($event['allday'])) { |
|
| 480 | + echo $txt['calendar_allday']; |
|
| 481 | + } |
|
| 463 | 482 | |
| 464 | 483 | echo '</span>'; |
| 465 | 484 | |
| 466 | - if (!empty($event['location'])) |
|
| 467 | - echo '<br><span class="event_location', empty($event_icons_needed) ? ' floatright' : '', '">' . $event['location'] . '</span>'; |
|
| 485 | + if (!empty($event['location'])) { |
|
| 486 | + echo '<br><span class="event_location', empty($event_icons_needed) ? ' floatright' : '', '">' . $event['location'] . '</span>'; |
|
| 487 | + } |
|
| 468 | 488 | |
| 469 | 489 | if ($event['can_edit'] || $event['can_export']) |
| 470 | 490 | { |
@@ -501,10 +521,11 @@ discard block |
||
| 501 | 521 | // Otherwise, assuming it's not a mini-calendar, we can show previous / next month days! |
| 502 | 522 | elseif ($is_mini === false) |
| 503 | 523 | { |
| 504 | - if (empty($current_month_started) && !empty($context['calendar_grid_prev'])) |
|
| 505 | - echo '<a href="', $scripturl, '?action=calendar;year=', $context['calendar_grid_prev']['current_year'], ';month=', $context['calendar_grid_prev']['current_month'], '">', $context['calendar_grid_prev']['last_of_month'] - $calendar_data['shift']-- +1, '</a>'; |
|
| 506 | - elseif (!empty($current_month_started) && !empty($context['calendar_grid_next'])) |
|
| 507 | - echo '<a href="', $scripturl, '?action=calendar;year=', $context['calendar_grid_next']['current_year'], ';month=', $context['calendar_grid_next']['current_month'], '">', $current_month_started + 1 == $count ? (!empty($calendar_data['short_month_titles']) ? $txt['months_short'][$context['calendar_grid_next']['current_month']] . ' ' : $txt['months_titles'][$context['calendar_grid_next']['current_month']] . ' ') : '', $final_count++, '</a>'; |
|
| 524 | + if (empty($current_month_started) && !empty($context['calendar_grid_prev'])) { |
|
| 525 | + echo '<a href="', $scripturl, '?action=calendar;year=', $context['calendar_grid_prev']['current_year'], ';month=', $context['calendar_grid_prev']['current_month'], '">', $context['calendar_grid_prev']['last_of_month'] - $calendar_data['shift']-- +1, '</a>'; |
|
| 526 | + } elseif (!empty($current_month_started) && !empty($context['calendar_grid_next'])) { |
|
| 527 | + echo '<a href="', $scripturl, '?action=calendar;year=', $context['calendar_grid_next']['current_year'], ';month=', $context['calendar_grid_next']['current_month'], '">', $current_month_started + 1 == $count ? (!empty($calendar_data['short_month_titles']) ? $txt['months_short'][$context['calendar_grid_next']['current_month']] . ' ' : $txt['months_titles'][$context['calendar_grid_next']['current_month']] . ' ') : '', $final_count++, '</a>'; |
|
| 528 | + } |
|
| 508 | 529 | } |
| 509 | 530 | |
| 510 | 531 | // Close this day and increase var count. |
@@ -530,8 +551,9 @@ discard block |
||
| 530 | 551 | global $context, $settings, $txt, $scripturl, $modSettings; |
| 531 | 552 | |
| 532 | 553 | // We might have no reason to proceed, if the variable isn't there. |
| 533 | - if (!isset($context['calendar_grid_' . $grid_name])) |
|
| 534 | - return false; |
|
| 554 | + if (!isset($context['calendar_grid_' . $grid_name])) { |
|
| 555 | + return false; |
|
| 556 | + } |
|
| 535 | 557 | |
| 536 | 558 | // Handy pointer. |
| 537 | 559 | $calendar_data = &$context['calendar_grid_' . $grid_name]; |
@@ -567,8 +589,9 @@ discard block |
||
| 567 | 589 | } |
| 568 | 590 | |
| 569 | 591 | // The Month Title + Week Number... |
| 570 | - if (!empty($calendar_data['week_title'])) |
|
| 571 | - echo $calendar_data['week_title']; |
|
| 592 | + if (!empty($calendar_data['week_title'])) { |
|
| 593 | + echo $calendar_data['week_title']; |
|
| 594 | + } |
|
| 572 | 595 | |
| 573 | 596 | echo ' |
| 574 | 597 | </h3> |
@@ -607,10 +630,11 @@ discard block |
||
| 607 | 630 | <tr class="days_wrapper"> |
| 608 | 631 | <td class="', implode(' ', $classes), ' act_day">'; |
| 609 | 632 | // Should the day number be a link? |
| 610 | - if (!empty($modSettings['cal_daysaslink']) && $context['can_post']) |
|
| 611 | - echo '<a href="', $scripturl, '?action=calendar;sa=post;month=', $month_data['current_month'], ';year=', $month_data['current_year'], ';day=', $day['day'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['days'][$day['day_of_week']], ' - ', $day['day'], '</a>'; |
|
| 612 | - else |
|
| 613 | - echo $txt['days'][$day['day_of_week']], ' - ', $day['day']; |
|
| 633 | + if (!empty($modSettings['cal_daysaslink']) && $context['can_post']) { |
|
| 634 | + echo '<a href="', $scripturl, '?action=calendar;sa=post;month=', $month_data['current_month'], ';year=', $month_data['current_year'], ';day=', $day['day'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['days'][$day['day_of_week']], ' - ', $day['day'], '</a>'; |
|
| 635 | + } else { |
|
| 636 | + echo $txt['days'][$day['day_of_week']], ' - ', $day['day']; |
|
| 637 | + } |
|
| 614 | 638 | |
| 615 | 639 | echo '</td> |
| 616 | 640 | <td class="', implode(' ', $classes), '', empty($day['events']) ? (' disabled' . ($context['can_post'] ? ' week_post' : '')) : ' events', ' event_col" data-css-prefix="' . $txt['events'] . ' ', (empty($day['events']) && empty($context['can_post'])) ? $txt['none'] : '', '">'; |
@@ -619,8 +643,9 @@ discard block |
||
| 619 | 643 | { |
| 620 | 644 | // Sort events by start time (all day events will be listed first) |
| 621 | 645 | uasort($day['events'], function($a, $b) { |
| 622 | - if ($a['start_timestamp'] == $b['start_timestamp']) |
|
| 623 | - return 0; |
|
| 646 | + if ($a['start_timestamp'] == $b['start_timestamp']) { |
|
| 647 | + return 0; |
|
| 648 | + } |
|
| 624 | 649 | return ($a['start_timestamp'] < $b['start_timestamp']) ? -1 : 1; |
| 625 | 650 | }); |
| 626 | 651 | |
@@ -632,15 +657,17 @@ discard block |
||
| 632 | 657 | |
| 633 | 658 | echo $event['link'], '<br><span class="event_time', empty($event_icons_needed) ? ' floatright' : '', '">'; |
| 634 | 659 | |
| 635 | - if (!empty($event['start_time_local'])) |
|
| 636 | - echo trim($event['start_time_local']), !empty($event['end_time_local']) ? ' – ' . trim($event['end_time_local']) : ''; |
|
| 637 | - else |
|
| 638 | - echo $txt['calendar_allday']; |
|
| 660 | + if (!empty($event['start_time_local'])) { |
|
| 661 | + echo trim($event['start_time_local']), !empty($event['end_time_local']) ? ' – ' . trim($event['end_time_local']) : ''; |
|
| 662 | + } else { |
|
| 663 | + echo $txt['calendar_allday']; |
|
| 664 | + } |
|
| 639 | 665 | |
| 640 | 666 | echo '</span>'; |
| 641 | 667 | |
| 642 | - if (!empty($event['location'])) |
|
| 643 | - echo '<br><span class="event_location', empty($event_icons_needed) ? ' floatright' : '', '">' . $event['location'] . '</span>'; |
|
| 668 | + if (!empty($event['location'])) { |
|
| 669 | + echo '<br><span class="event_location', empty($event_icons_needed) ? ' floatright' : '', '">' . $event['location'] . '</span>'; |
|
| 670 | + } |
|
| 644 | 671 | |
| 645 | 672 | if (!empty($event_icons_needed)) |
| 646 | 673 | { |
@@ -677,8 +704,7 @@ discard block |
||
| 677 | 704 | </div> |
| 678 | 705 | <br class="clear">'; |
| 679 | 706 | } |
| 680 | - } |
|
| 681 | - else |
|
| 707 | + } else |
|
| 682 | 708 | { |
| 683 | 709 | if (!empty($context['can_post'])) |
| 684 | 710 | { |
@@ -691,8 +717,9 @@ discard block |
||
| 691 | 717 | echo '</td> |
| 692 | 718 | <td class="', implode(' ', $classes), !empty($day['holidays']) ? ' holidays' : ' disabled', ' holiday_col" data-css-prefix="' . $txt['calendar_prompt'] . ' ">'; |
| 693 | 719 | // Show any holidays! |
| 694 | - if (!empty($day['holidays'])) |
|
| 695 | - echo implode('<br>', $day['holidays']); |
|
| 720 | + if (!empty($day['holidays'])) { |
|
| 721 | + echo implode('<br>', $day['holidays']); |
|
| 722 | + } |
|
| 696 | 723 | |
| 697 | 724 | echo '</td> |
| 698 | 725 | <td class="', implode(' ', $classes), '', !empty($day['birthdays']) ? ' birthdays' : ' disabled', ' birthday_col" data-css-prefix="' . $txt['birthdays'] . ' ">'; |
@@ -750,8 +777,7 @@ discard block |
||
| 750 | 777 | <input type="text" name="end_date" id="end_date" maxlength="10" value="', $calendar_data['end_date'], '" tabindex="', $context['tabindex']++, '" class="input_text date_input end" data-type="date"> |
| 751 | 778 | <input type="submit" class="button_submit" style="float:none" id="view_button" value="', $txt['view'], '"> |
| 752 | 779 | </form>'; |
| 753 | - } |
|
| 754 | - else |
|
| 780 | + } else |
|
| 755 | 781 | { |
| 756 | 782 | echo' |
| 757 | 783 | <form action="', $scripturl, '?action=calendar" id="calendar_navigation" method="post" accept-charset="', $context['character_set'], '"> |
@@ -793,8 +819,9 @@ discard block |
||
| 793 | 819 | echo ' |
| 794 | 820 | <form action="', $scripturl, '?action=calendar;sa=post" method="post" name="postevent" accept-charset="', $context['character_set'], '" onsubmit="submitonce(this);smc_saveEntities(\'postevent\', [\'evtitle\']);" style="margin: 0;">'; |
| 795 | 821 | |
| 796 | - if (!empty($context['event']['new'])) |
|
| 797 | - echo '<input type="hidden" name="eventid" value="', $context['event']['eventid'], '">'; |
|
| 822 | + if (!empty($context['event']['new'])) { |
|
| 823 | + echo '<input type="hidden" name="eventid" value="', $context['event']['eventid'], '">'; |
|
| 824 | + } |
|
| 798 | 825 | |
| 799 | 826 | // Start the main table. |
| 800 | 827 | echo ' |
@@ -844,9 +871,10 @@ discard block |
||
| 844 | 871 | { |
| 845 | 872 | echo ' |
| 846 | 873 | <optgroup label="', $category['name'], '">'; |
| 847 | - foreach ($category['boards'] as $board) |
|
| 848 | - echo ' |
|
| 874 | + foreach ($category['boards'] as $board) { |
|
| 875 | + echo ' |
|
| 849 | 876 | <option value="', $board['id'], '"', $board['selected'] ? ' selected' : '', '>', $board['child_level'] > 0 ? str_repeat('==', $board['child_level'] - 1) . '=>' : '', ' ', $board['name'], ' </option>'; |
| 877 | + } |
|
| 850 | 878 | echo ' |
| 851 | 879 | </optgroup>'; |
| 852 | 880 | } |
@@ -882,9 +910,10 @@ discard block |
||
| 882 | 910 | <span class="label">', $txt['calendar_timezone'], '</span> |
| 883 | 911 | <select name="tz" id="tz"', !empty($context['event']['allday']) ? ' disabled' : '', '>'; |
| 884 | 912 | |
| 885 | - foreach ($context['all_timezones'] as $tz => $tzname) |
|
| 886 | - echo ' |
|
| 913 | + foreach ($context['all_timezones'] as $tz => $tzname) { |
|
| 914 | + echo ' |
|
| 887 | 915 | <option value="', $tz, '"', $tz == $context['event']['tz'] ? ' selected' : '', '>', $tzname, '</option>'; |
| 916 | + } |
|
| 888 | 917 | |
| 889 | 918 | echo ' |
| 890 | 919 | </select> |
@@ -899,9 +928,10 @@ discard block |
||
| 899 | 928 | echo ' |
| 900 | 929 | <input type="submit" value="', empty($context['event']['new']) ? $txt['save'] : $txt['post'], '" class="button_submit">'; |
| 901 | 930 | // Delete button? |
| 902 | - if (empty($context['event']['new'])) |
|
| 903 | - echo ' |
|
| 931 | + if (empty($context['event']['new'])) { |
|
| 932 | + echo ' |
|
| 904 | 933 | <input type="submit" name="deleteevent" value="', $txt['event_delete'], '" data-confirm="', $txt['calendar_confirm_delete'], '" class="button_submit you_sure">'; |
| 934 | + } |
|
| 905 | 935 | |
| 906 | 936 | echo ' |
| 907 | 937 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -945,9 +975,10 @@ discard block |
||
| 945 | 975 | |
| 946 | 976 | foreach ($context['clockicons'] as $t => $v) |
| 947 | 977 | { |
| 948 | - foreach ($v as $i) |
|
| 949 | - echo ' |
|
| 978 | + foreach ($v as $i) { |
|
| 979 | + echo ' |
|
| 950 | 980 | icons[\'', $t, '_', $i, '\'] = document.getElementById(\'', $t, '_', $i, '\');'; |
| 981 | + } |
|
| 951 | 982 | } |
| 952 | 983 | |
| 953 | 984 | echo ' |
@@ -972,13 +1003,14 @@ discard block |
||
| 972 | 1003 | |
| 973 | 1004 | foreach ($context['clockicons'] as $t => $v) |
| 974 | 1005 | { |
| 975 | - foreach ($v as $i) |
|
| 976 | - echo ' |
|
| 1006 | + foreach ($v as $i) { |
|
| 1007 | + echo ' |
|
| 977 | 1008 | if (', $t, ' >= ', $i, ') |
| 978 | 1009 | { |
| 979 | 1010 | turnon.push("', $t, '_', $i, '"); |
| 980 | 1011 | ', $t, ' -= ', $i, '; |
| 981 | 1012 | }'; |
| 1013 | + } |
|
| 982 | 1014 | } |
| 983 | 1015 | |
| 984 | 1016 | echo ' |
@@ -1042,9 +1074,10 @@ discard block |
||
| 1042 | 1074 | |
| 1043 | 1075 | foreach ($context['clockicons'] as $t => $v) |
| 1044 | 1076 | { |
| 1045 | - foreach ($v as $i) |
|
| 1046 | - echo ' |
|
| 1077 | + foreach ($v as $i) { |
|
| 1078 | + echo ' |
|
| 1047 | 1079 | icons[\'', $t, '_', $i, '\'] = document.getElementById(\'', $t, '_', $i, '\');'; |
| 1080 | + } |
|
| 1048 | 1081 | } |
| 1049 | 1082 | |
| 1050 | 1083 | echo ' |
@@ -1061,13 +1094,14 @@ discard block |
||
| 1061 | 1094 | |
| 1062 | 1095 | foreach ($context['clockicons'] as $t => $v) |
| 1063 | 1096 | { |
| 1064 | - foreach ($v as $i) |
|
| 1065 | - echo ' |
|
| 1097 | + foreach ($v as $i) { |
|
| 1098 | + echo ' |
|
| 1066 | 1099 | if (', $t, ' >= ', $i, ') |
| 1067 | 1100 | { |
| 1068 | 1101 | turnon.push("', $t, '_', $i, '"); |
| 1069 | 1102 | ', $t, ' -= ', $i, '; |
| 1070 | 1103 | }'; |
| 1104 | + } |
|
| 1071 | 1105 | } |
| 1072 | 1106 | |
| 1073 | 1107 | echo ' |
@@ -1126,9 +1160,10 @@ discard block |
||
| 1126 | 1160 | |
| 1127 | 1161 | foreach ($context['clockicons'] as $t => $v) |
| 1128 | 1162 | { |
| 1129 | - foreach ($v as $i) |
|
| 1130 | - echo ' |
|
| 1163 | + foreach ($v as $i) { |
|
| 1164 | + echo ' |
|
| 1131 | 1165 | icons[\'', $t, '_', $i, '\'] = document.getElementById(\'', $t, '_', $i, '\');'; |
| 1166 | + } |
|
| 1132 | 1167 | } |
| 1133 | 1168 | |
| 1134 | 1169 | echo ' |
@@ -1149,13 +1184,14 @@ discard block |
||
| 1149 | 1184 | |
| 1150 | 1185 | foreach ($context['clockicons'] as $t => $v) |
| 1151 | 1186 | { |
| 1152 | - foreach ($v as $i) |
|
| 1153 | - echo ' |
|
| 1187 | + foreach ($v as $i) { |
|
| 1188 | + echo ' |
|
| 1154 | 1189 | if (', $t, ' >= ', $i, ') |
| 1155 | 1190 | { |
| 1156 | 1191 | turnon.push("', $t, '_', $i, '"); |
| 1157 | 1192 | ', $t, ' -= ', $i, '; |
| 1158 | 1193 | }'; |
| 1194 | + } |
|
| 1159 | 1195 | } |
| 1160 | 1196 | |
| 1161 | 1197 | echo ' |
@@ -240,8 +240,8 @@ |
||
| 240 | 240 | $time_string = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]); |
| 241 | 241 | |
| 242 | 242 | $js_time_string = str_replace( |
| 243 | - array('%H', '%k', '%I', '%l', '%M', '%p', '%P', '%r', '%R', '%S', '%T', '%X'), |
|
| 244 | - array('H', 'G', 'h', 'g', 'i', 'A', 'a', 'h:i:s A', 'H:i', 's', 'H:i:s', 'H:i:s'), |
|
| 243 | + array('%H', '%k', '%I', '%l', '%M', '%p', '%P', '%r', '%R', '%S', '%T', '%X'), |
|
| 244 | + array('H', 'G', 'h', 'g', 'i', 'A', 'a', 'h:i:s A', 'H:i', 's', 'H:i:s', 'H:i:s'), |
|
| 245 | 245 | $time_string |
| 246 | 246 | ); |
| 247 | 247 | |
@@ -14,8 +14,9 @@ discard block |
||
| 14 | 14 | * @version 2.1 Beta 3 |
| 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 | * Show the calendar. |
@@ -47,12 +48,14 @@ discard block |
||
| 47 | 48 | 'post' => 'CalendarPost', |
| 48 | 49 | ); |
| 49 | 50 | |
| 50 | - if (isset($_GET['sa']) && isset($subActions[$_GET['sa']])) |
|
| 51 | - return call_helper($subActions[$_GET['sa']]); |
|
| 51 | + if (isset($_GET['sa']) && isset($subActions[$_GET['sa']])) { |
|
| 52 | + return call_helper($subActions[$_GET['sa']]); |
|
| 53 | + } |
|
| 52 | 54 | |
| 53 | 55 | // You can't do anything if the calendar is off. |
| 54 | - if (empty($modSettings['cal_enabled'])) |
|
| 55 | - fatal_lang_error('calendar_off', false); |
|
| 56 | + if (empty($modSettings['cal_enabled'])) { |
|
| 57 | + fatal_lang_error('calendar_off', false); |
|
| 58 | + } |
|
| 56 | 59 | |
| 57 | 60 | // This is gonna be needed... |
| 58 | 61 | loadTemplate('Calendar'); |
@@ -80,8 +83,9 @@ discard block |
||
| 80 | 83 | $_REQUEST['month'] = (int) $_REQUEST['month']; |
| 81 | 84 | |
| 82 | 85 | // We want month view. |
| 83 | - if (empty($_GET['viewmonth'])) |
|
| 84 | - $_GET['viewmonth'] = true; |
|
| 86 | + if (empty($_GET['viewmonth'])) { |
|
| 87 | + $_GET['viewmonth'] = true; |
|
| 88 | + } |
|
| 85 | 89 | |
| 86 | 90 | // And we definitely don't want weekly view. |
| 87 | 91 | unset ($_GET['viewweek']); |
@@ -98,22 +102,25 @@ discard block |
||
| 98 | 102 | $context['page_title'] = $txt['calendar']; |
| 99 | 103 | |
| 100 | 104 | // Ensure a default view is defined |
| 101 | - if (empty($modSettings['calendar_default_view'])) |
|
| 102 | - $modSettings['calendar_default_view'] = 'view_list'; |
|
| 105 | + if (empty($modSettings['calendar_default_view'])) { |
|
| 106 | + $modSettings['calendar_default_view'] = 'view_list'; |
|
| 107 | + } |
|
| 103 | 108 | |
| 104 | 109 | // What view do we want? |
| 105 | - if (isset($_GET['viewweek'])) |
|
| 106 | - $context['calendar_view'] = 'view_week'; |
|
| 107 | - elseif (isset($_GET['viewmonth'])) |
|
| 108 | - $context['calendar_view'] = 'view_month'; |
|
| 109 | - elseif (isset($_GET['viewlist'])) |
|
| 110 | - $context['calendar_view'] = 'view_list'; |
|
| 111 | - else |
|
| 112 | - $context['calendar_view'] = $modSettings['calendar_default_view']; |
|
| 110 | + if (isset($_GET['viewweek'])) { |
|
| 111 | + $context['calendar_view'] = 'view_week'; |
|
| 112 | + } elseif (isset($_GET['viewmonth'])) { |
|
| 113 | + $context['calendar_view'] = 'view_month'; |
|
| 114 | + } elseif (isset($_GET['viewlist'])) { |
|
| 115 | + $context['calendar_view'] = 'view_list'; |
|
| 116 | + } else { |
|
| 117 | + $context['calendar_view'] = $modSettings['calendar_default_view']; |
|
| 118 | + } |
|
| 113 | 119 | |
| 114 | 120 | // Don't let search engines index the non-default calendar pages |
| 115 | - if ($context['calendar_view'] !== $modSettings['calendar_default_view']) |
|
| 116 | - $context['robot_no_index'] = true; |
|
| 121 | + if ($context['calendar_view'] !== $modSettings['calendar_default_view']) { |
|
| 122 | + $context['robot_no_index'] = true; |
|
| 123 | + } |
|
| 117 | 124 | |
| 118 | 125 | // Get the current day of month... |
| 119 | 126 | require_once($sourcedir . '/Subs-Calendar.php'); |
@@ -174,16 +181,19 @@ discard block |
||
| 174 | 181 | ); |
| 175 | 182 | |
| 176 | 183 | // Make sure the year and month are in valid ranges. |
| 177 | - if ($curPage['month'] < 1 || $curPage['month'] > 12) |
|
| 178 | - fatal_lang_error('invalid_month', false); |
|
| 179 | - if ($curPage['year'] < $modSettings['cal_minyear'] || $curPage['year'] > $modSettings['cal_maxyear']) |
|
| 180 | - fatal_lang_error('invalid_year', false); |
|
| 184 | + if ($curPage['month'] < 1 || $curPage['month'] > 12) { |
|
| 185 | + fatal_lang_error('invalid_month', false); |
|
| 186 | + } |
|
| 187 | + if ($curPage['year'] < $modSettings['cal_minyear'] || $curPage['year'] > $modSettings['cal_maxyear']) { |
|
| 188 | + fatal_lang_error('invalid_year', false); |
|
| 189 | + } |
|
| 181 | 190 | // If we have a day clean that too. |
| 182 | 191 | if ($context['calendar_view'] != 'view_month') |
| 183 | 192 | { |
| 184 | 193 | $isValid = checkdate($curPage['month'], $curPage['day'], $curPage['year']); |
| 185 | - if (!$isValid) |
|
| 186 | - fatal_lang_error('invalid_day', false); |
|
| 194 | + if (!$isValid) { |
|
| 195 | + fatal_lang_error('invalid_day', false); |
|
| 196 | + } |
|
| 187 | 197 | } |
| 188 | 198 | |
| 189 | 199 | // Load all the context information needed to show the calendar grid. |
@@ -205,23 +215,26 @@ discard block |
||
| 205 | 215 | ); |
| 206 | 216 | |
| 207 | 217 | // Load up the main view. |
| 208 | - if ($context['calendar_view'] == 'view_list') |
|
| 209 | - $context['calendar_grid_main'] = getCalendarList($curPage['start_date'], $curPage['end_date'], $calendarOptions); |
|
| 210 | - elseif ($context['calendar_view'] == 'view_week') |
|
| 211 | - $context['calendar_grid_main'] = getCalendarWeek($curPage['month'], $curPage['year'], $curPage['day'], $calendarOptions); |
|
| 212 | - else |
|
| 213 | - $context['calendar_grid_main'] = getCalendarGrid($curPage['month'], $curPage['year'], $calendarOptions); |
|
| 218 | + if ($context['calendar_view'] == 'view_list') { |
|
| 219 | + $context['calendar_grid_main'] = getCalendarList($curPage['start_date'], $curPage['end_date'], $calendarOptions); |
|
| 220 | + } elseif ($context['calendar_view'] == 'view_week') { |
|
| 221 | + $context['calendar_grid_main'] = getCalendarWeek($curPage['month'], $curPage['year'], $curPage['day'], $calendarOptions); |
|
| 222 | + } else { |
|
| 223 | + $context['calendar_grid_main'] = getCalendarGrid($curPage['month'], $curPage['year'], $calendarOptions); |
|
| 224 | + } |
|
| 214 | 225 | |
| 215 | 226 | // Load up the previous and next months. |
| 216 | 227 | $context['calendar_grid_current'] = getCalendarGrid($curPage['month'], $curPage['year'], $calendarOptions); |
| 217 | 228 | |
| 218 | 229 | // Only show previous month if it isn't pre-January of the min-year |
| 219 | - if ($context['calendar_grid_current']['previous_calendar']['year'] > $modSettings['cal_minyear'] || $curPage['month'] != 1) |
|
| 220 | - $context['calendar_grid_prev'] = getCalendarGrid($context['calendar_grid_current']['previous_calendar']['month'], $context['calendar_grid_current']['previous_calendar']['year'], $calendarOptions, true); |
|
| 230 | + if ($context['calendar_grid_current']['previous_calendar']['year'] > $modSettings['cal_minyear'] || $curPage['month'] != 1) { |
|
| 231 | + $context['calendar_grid_prev'] = getCalendarGrid($context['calendar_grid_current']['previous_calendar']['month'], $context['calendar_grid_current']['previous_calendar']['year'], $calendarOptions, true); |
|
| 232 | + } |
|
| 221 | 233 | |
| 222 | 234 | // Only show next month if it isn't post-December of the max-year |
| 223 | - if ($context['calendar_grid_current']['next_calendar']['year'] < $modSettings['cal_maxyear'] || $curPage['month'] != 12) |
|
| 224 | - $context['calendar_grid_next'] = getCalendarGrid($context['calendar_grid_current']['next_calendar']['month'], $context['calendar_grid_current']['next_calendar']['year'], $calendarOptions); |
|
| 235 | + if ($context['calendar_grid_current']['next_calendar']['year'] < $modSettings['cal_maxyear'] || $curPage['month'] != 12) { |
|
| 236 | + $context['calendar_grid_next'] = getCalendarGrid($context['calendar_grid_current']['next_calendar']['month'], $context['calendar_grid_current']['next_calendar']['year'], $calendarOptions); |
|
| 237 | + } |
|
| 225 | 238 | |
| 226 | 239 | // Basic template stuff. |
| 227 | 240 | $context['allow_calendar_event'] = allowedTo('calendar_post'); |
@@ -241,8 +254,9 @@ discard block |
||
| 241 | 254 | $context['blocks_disabled'] = !empty($modSettings['cal_disable_prev_next']) ? 1 : 0; |
| 242 | 255 | |
| 243 | 256 | // Set the page title to mention the month or week, too |
| 244 | - if ($context['calendar_view'] != 'view_list') |
|
| 245 | - $context['page_title'] .= ' - ' . ($context['calendar_view'] == 'view_week' ? $context['calendar_grid_main']['week_title'] : $txt['months'][$context['current_month']] . ' ' . $context['current_year']); |
|
| 257 | + if ($context['calendar_view'] != 'view_list') { |
|
| 258 | + $context['page_title'] .= ' - ' . ($context['calendar_view'] == 'view_week' ? $context['calendar_grid_main']['week_title'] : $txt['months'][$context['current_month']] . ' ' . $context['current_year']); |
|
| 259 | + } |
|
| 246 | 260 | |
| 247 | 261 | // Load up the linktree! |
| 248 | 262 | $context['linktree'][] = array( |
@@ -255,17 +269,19 @@ discard block |
||
| 255 | 269 | 'name' => $txt['months'][$context['current_month']] . ' ' . $context['current_year'] |
| 256 | 270 | ); |
| 257 | 271 | // If applicable, add the current week to the linktree. |
| 258 | - if ($context['calendar_view'] == 'view_week') |
|
| 259 | - $context['linktree'][] = array( |
|
| 272 | + if ($context['calendar_view'] == 'view_week') { |
|
| 273 | + $context['linktree'][] = array( |
|
| 260 | 274 | 'url' => $scripturl . '?action=calendar;viewweek;year=' . $context['current_year'] . ';month=' . $context['current_month'] . ';day=' . $context['current_day'], |
| 261 | 275 | 'name' => $context['calendar_grid_main']['week_title'], |
| 262 | 276 | ); |
| 277 | + } |
|
| 263 | 278 | |
| 264 | 279 | // Build the calendar button array. |
| 265 | 280 | $context['calendar_buttons'] = array(); |
| 266 | 281 | |
| 267 | - if ($context['can_post']) |
|
| 268 | - $context['calendar_buttons']['post_event'] = array('text' => 'calendar_post_event', 'image' => 'calendarpe.png', 'url' => $scripturl . '?action=calendar;sa=post;month=' . $context['current_month'] . ';year=' . $context['current_year'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 282 | + if ($context['can_post']) { |
|
| 283 | + $context['calendar_buttons']['post_event'] = array('text' => 'calendar_post_event', 'image' => 'calendarpe.png', 'url' => $scripturl . '?action=calendar;sa=post;month=' . $context['current_month'] . ';year=' . $context['current_year'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 284 | + } |
|
| 269 | 285 | |
| 270 | 286 | // Allow mods to add additional buttons here |
| 271 | 287 | call_integration_hook('integrate_calendar_buttons'); |
@@ -294,14 +310,16 @@ discard block |
||
| 294 | 310 | require_once($sourcedir . '/Subs.php'); |
| 295 | 311 | |
| 296 | 312 | // Cast this for safety... |
| 297 | - if (isset($_REQUEST['eventid'])) |
|
| 298 | - $_REQUEST['eventid'] = (int) $_REQUEST['eventid']; |
|
| 313 | + if (isset($_REQUEST['eventid'])) { |
|
| 314 | + $_REQUEST['eventid'] = (int) $_REQUEST['eventid']; |
|
| 315 | + } |
|
| 299 | 316 | |
| 300 | 317 | // We want a fairly compact version of the time, but as close as possible to the user's settings. |
| 301 | - if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) |
|
| 302 | - $time_string = '%k:%M'; |
|
| 303 | - else |
|
| 304 | - $time_string = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]); |
|
| 318 | + if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) { |
|
| 319 | + $time_string = '%k:%M'; |
|
| 320 | + } else { |
|
| 321 | + $time_string = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]); |
|
| 322 | + } |
|
| 305 | 323 | |
| 306 | 324 | $js_time_string = str_replace( |
| 307 | 325 | array('%H', '%k', '%I', '%l', '%M', '%p', '%P', '%r', '%R', '%S', '%T', '%X'), |
@@ -315,12 +333,14 @@ discard block |
||
| 315 | 333 | checkSession(); |
| 316 | 334 | |
| 317 | 335 | // Validate the post... |
| 318 | - if (!isset($_POST['link_to_board'])) |
|
| 319 | - validateEventPost(); |
|
| 336 | + if (!isset($_POST['link_to_board'])) { |
|
| 337 | + validateEventPost(); |
|
| 338 | + } |
|
| 320 | 339 | |
| 321 | 340 | // If you're not allowed to edit any events, you have to be the poster. |
| 322 | - if ($_REQUEST['eventid'] > 0 && !allowedTo('calendar_edit_any')) |
|
| 323 | - isAllowedTo('calendar_edit_' . (!empty($user_info['id']) && getEventPoster($_REQUEST['eventid']) == $user_info['id'] ? 'own' : 'any')); |
|
| 341 | + if ($_REQUEST['eventid'] > 0 && !allowedTo('calendar_edit_any')) { |
|
| 342 | + isAllowedTo('calendar_edit_' . (!empty($user_info['id']) && getEventPoster($_REQUEST['eventid']) == $user_info['id'] ? 'own' : 'any')); |
|
| 343 | + } |
|
| 324 | 344 | |
| 325 | 345 | // New - and directing? |
| 326 | 346 | if (isset($_POST['link_to_board']) || empty($modSettings['cal_allow_unlinked'])) |
@@ -343,8 +363,9 @@ discard block |
||
| 343 | 363 | } |
| 344 | 364 | |
| 345 | 365 | // Deleting... |
| 346 | - elseif (isset($_REQUEST['deleteevent'])) |
|
| 347 | - removeEvent($_REQUEST['eventid']); |
|
| 366 | + elseif (isset($_REQUEST['deleteevent'])) { |
|
| 367 | + removeEvent($_REQUEST['eventid']); |
|
| 368 | + } |
|
| 348 | 369 | |
| 349 | 370 | // ... or just update it? |
| 350 | 371 | else |
@@ -366,14 +387,12 @@ discard block |
||
| 366 | 387 | $d = date_parse($_POST['start_date']); |
| 367 | 388 | $year = $d['year']; |
| 368 | 389 | $month = $d['month']; |
| 369 | - } |
|
| 370 | - elseif (isset($_POST['start_datetime'])) |
|
| 390 | + } elseif (isset($_POST['start_datetime'])) |
|
| 371 | 391 | { |
| 372 | 392 | $d = date_parse($_POST['start_datetime']); |
| 373 | 393 | $year = $d['year']; |
| 374 | 394 | $month = $d['month']; |
| 375 | - } |
|
| 376 | - else |
|
| 395 | + } else |
|
| 377 | 396 | { |
| 378 | 397 | $today = getdate(); |
| 379 | 398 | $year = isset($_POST['year']) ? $_POST['year'] : $today['year']; |
@@ -406,13 +425,13 @@ discard block |
||
| 406 | 425 | $context['event'] = array_merge($context['event'], $eventDatetimes); |
| 407 | 426 | |
| 408 | 427 | $context['event']['last_day'] = (int) strftime('%d', mktime(0, 0, 0, $context['event']['month'] == 12 ? 1 : $context['event']['month'] + 1, 0, $context['event']['month'] == 12 ? $context['event']['year'] + 1 : $context['event']['year'])); |
| 409 | - } |
|
| 410 | - else |
|
| 428 | + } else |
|
| 411 | 429 | { |
| 412 | 430 | $context['event'] = getEventProperties($_REQUEST['eventid']); |
| 413 | 431 | |
| 414 | - if ($context['event'] === false) |
|
| 415 | - fatal_lang_error('no_access', false); |
|
| 432 | + if ($context['event'] === false) { |
|
| 433 | + fatal_lang_error('no_access', false); |
|
| 434 | + } |
|
| 416 | 435 | |
| 417 | 436 | // If it has a board, then they should be editing it within the topic. |
| 418 | 437 | if (!empty($context['event']['topic']['id']) && !empty($context['event']['topic']['first_msg'])) |
@@ -423,10 +442,11 @@ discard block |
||
| 423 | 442 | } |
| 424 | 443 | |
| 425 | 444 | // Make sure the user is allowed to edit this event. |
| 426 | - if ($context['event']['member'] != $user_info['id']) |
|
| 427 | - isAllowedTo('calendar_edit_any'); |
|
| 428 | - elseif (!allowedTo('calendar_edit_any')) |
|
| 429 | - isAllowedTo('calendar_edit_own'); |
|
| 445 | + if ($context['event']['member'] != $user_info['id']) { |
|
| 446 | + isAllowedTo('calendar_edit_any'); |
|
| 447 | + } elseif (!allowedTo('calendar_edit_any')) { |
|
| 448 | + isAllowedTo('calendar_edit_own'); |
|
| 449 | + } |
|
| 430 | 450 | } |
| 431 | 451 | |
| 432 | 452 | // An all day event? Set up some nice defaults in case the user wants to change that |
@@ -460,8 +480,7 @@ discard block |
||
| 460 | 480 | { |
| 461 | 481 | // You can post new events but can't link them to anything... |
| 462 | 482 | $context['event']['categories'] = array(); |
| 463 | - } |
|
| 464 | - else |
|
| 483 | + } else |
|
| 465 | 484 | { |
| 466 | 485 | // Load the list of boards and categories in the context. |
| 467 | 486 | require_once($sourcedir . '/Subs-MessageIndex.php'); |
@@ -548,12 +567,14 @@ discard block |
||
| 548 | 567 | global $smcFunc, $sourcedir, $forum_version, $modSettings, $webmaster_email, $mbname; |
| 549 | 568 | |
| 550 | 569 | // You can't export if the calendar export feature is off. |
| 551 | - if (empty($modSettings['cal_export'])) |
|
| 552 | - fatal_lang_error('calendar_export_off', false); |
|
| 570 | + if (empty($modSettings['cal_export'])) { |
|
| 571 | + fatal_lang_error('calendar_export_off', false); |
|
| 572 | + } |
|
| 553 | 573 | |
| 554 | 574 | // Goes without saying that this is required. |
| 555 | - if (!isset($_REQUEST['eventid'])) |
|
| 556 | - fatal_lang_error('no_access', false); |
|
| 575 | + if (!isset($_REQUEST['eventid'])) { |
|
| 576 | + fatal_lang_error('no_access', false); |
|
| 577 | + } |
|
| 557 | 578 | |
| 558 | 579 | // This is kinda wanted. |
| 559 | 580 | require_once($sourcedir . '/Subs-Calendar.php'); |
@@ -561,15 +582,17 @@ discard block |
||
| 561 | 582 | // Load up the event in question and check it exists. |
| 562 | 583 | $event = getEventProperties($_REQUEST['eventid']); |
| 563 | 584 | |
| 564 | - if ($event === false) |
|
| 565 | - fatal_lang_error('no_access', false); |
|
| 585 | + if ($event === false) { |
|
| 586 | + fatal_lang_error('no_access', false); |
|
| 587 | + } |
|
| 566 | 588 | |
| 567 | 589 | // Check the title isn't too long - iCal requires some formatting if so. |
| 568 | 590 | $title = str_split($event['title'], 30); |
| 569 | 591 | foreach ($title as $id => $line) |
| 570 | 592 | { |
| 571 | - if ($id != 0) |
|
| 572 | - $title[$id] = ' ' . $title[$id]; |
|
| 593 | + if ($id != 0) { |
|
| 594 | + $title[$id] = ' ' . $title[$id]; |
|
| 595 | + } |
|
| 573 | 596 | $title[$id] .= "\n"; |
| 574 | 597 | } |
| 575 | 598 | |
@@ -582,8 +605,7 @@ discard block |
||
| 582 | 605 | { |
| 583 | 606 | $datestart = date_format($start_date, 'Ymd\THis'); |
| 584 | 607 | $dateend = date_format($end_date, 'Ymd\THis'); |
| 585 | - } |
|
| 586 | - else |
|
| 608 | + } else |
|
| 587 | 609 | { |
| 588 | 610 | $datestart = date_format($start_date, 'Ymd'); |
| 589 | 611 | |
@@ -604,15 +626,18 @@ discard block |
||
| 604 | 626 | $filecontents .= 'DTSTART' . (!empty($event['start_time']) ? ';TZID=' . $event['tz'] : ';VALUE=DATE') . ':' . $datestart . "\n"; |
| 605 | 627 | |
| 606 | 628 | // event has a duration |
| 607 | - if ($event['start_iso_gmdate'] != $event['end_iso_gmdate']) |
|
| 608 | - $filecontents .= 'DTEND' . (!empty($event['end_time']) ? ';TZID=' . $event['tz'] : ';VALUE=DATE') . ':' . $dateend . "\n"; |
|
| 629 | + if ($event['start_iso_gmdate'] != $event['end_iso_gmdate']) { |
|
| 630 | + $filecontents .= 'DTEND' . (!empty($event['end_time']) ? ';TZID=' . $event['tz'] : ';VALUE=DATE') . ':' . $dateend . "\n"; |
|
| 631 | + } |
|
| 609 | 632 | |
| 610 | 633 | // event has changed? advance the sequence for this UID |
| 611 | - if ($event['sequence'] > 0) |
|
| 612 | - $filecontents .= 'SEQUENCE:' . $event['sequence'] . "\n"; |
|
| 634 | + if ($event['sequence'] > 0) { |
|
| 635 | + $filecontents .= 'SEQUENCE:' . $event['sequence'] . "\n"; |
|
| 636 | + } |
|
| 613 | 637 | |
| 614 | - if (!empty($event['location'])) |
|
| 615 | - $filecontents .= 'LOCATION:' . str_replace(',', '\,', $event['location']) . "\n"; |
|
| 638 | + if (!empty($event['location'])) { |
|
| 639 | + $filecontents .= 'LOCATION:' . str_replace(',', '\,', $event['location']) . "\n"; |
|
| 640 | + } |
|
| 616 | 641 | |
| 617 | 642 | $filecontents .= 'SUMMARY:' . implode('', $title); |
| 618 | 643 | $filecontents .= 'UID:' . $event['eventid'] . '@' . str_replace(' ', '-', $mbname) . "\n"; |
@@ -621,23 +646,26 @@ discard block |
||
| 621 | 646 | |
| 622 | 647 | // Send some standard headers. |
| 623 | 648 | ob_end_clean(); |
| 624 | - if (!empty($modSettings['enableCompressedOutput'])) |
|
| 625 | - @ob_start('ob_gzhandler'); |
|
| 626 | - else |
|
| 627 | - ob_start(); |
|
| 649 | + if (!empty($modSettings['enableCompressedOutput'])) { |
|
| 650 | + @ob_start('ob_gzhandler'); |
|
| 651 | + } else { |
|
| 652 | + ob_start(); |
|
| 653 | + } |
|
| 628 | 654 | |
| 629 | 655 | // Send the file headers |
| 630 | 656 | header('Pragma: '); |
| 631 | 657 | header('Cache-Control: no-cache'); |
| 632 | - if (!isBrowser('gecko')) |
|
| 633 | - header('Content-Transfer-Encoding: binary'); |
|
| 658 | + if (!isBrowser('gecko')) { |
|
| 659 | + header('Content-Transfer-Encoding: binary'); |
|
| 660 | + } |
|
| 634 | 661 | header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 525600 * 60) . ' GMT'); |
| 635 | 662 | header('Last-Modified: ' . gmdate('D, d M Y H:i:s', time()) . 'GMT'); |
| 636 | 663 | header('Accept-Ranges: bytes'); |
| 637 | 664 | header('Connection: close'); |
| 638 | 665 | header('Content-Disposition: attachment; filename="' . $event['title'] . '.ics"'); |
| 639 | - if (empty($modSettings['enableCompressedOutput'])) |
|
| 640 | - header('Content-Length: ' . $smcFunc['strlen']($filecontents)); |
|
| 666 | + if (empty($modSettings['enableCompressedOutput'])) { |
|
| 667 | + header('Content-Length: ' . $smcFunc['strlen']($filecontents)); |
|
| 668 | + } |
|
| 641 | 669 | |
| 642 | 670 | // This is a calendar item! |
| 643 | 671 | header('Content-Type: text/calendar'); |
@@ -676,20 +704,17 @@ discard block |
||
| 676 | 704 | $context['sub_template'] = 'bcd'; |
| 677 | 705 | $context['linktree'][] = array('url' => $scripturl . '?action=clock;bcd', 'name' => 'BCD'); |
| 678 | 706 | $context['clockicons'] = safe_unserialize(base64_decode('YTo2OntzOjI6ImgxIjthOjI6e2k6MDtpOjI7aToxO2k6MTt9czoyOiJoMiI7YTo0OntpOjA7aTo4O2k6MTtpOjQ7aToyO2k6MjtpOjM7aToxO31zOjI6Im0xIjthOjM6e2k6MDtpOjQ7aToxO2k6MjtpOjI7aToxO31zOjI6Im0yIjthOjQ6e2k6MDtpOjg7aToxO2k6NDtpOjI7aToyO2k6MztpOjE7fXM6MjoiczEiO2E6Mzp7aTowO2k6NDtpOjE7aToyO2k6MjtpOjE7fXM6MjoiczIiO2E6NDp7aTowO2k6ODtpOjE7aTo0O2k6MjtpOjI7aTozO2k6MTt9fQ==')); |
| 679 | - } |
|
| 680 | - elseif (!$omfg && !isset($_REQUEST['time'])) |
|
| 707 | + } elseif (!$omfg && !isset($_REQUEST['time'])) |
|
| 681 | 708 | { |
| 682 | 709 | $context['sub_template'] = 'hms'; |
| 683 | 710 | $context['linktree'][] = array('url' => $scripturl . '?action=clock', 'name' => 'Binary'); |
| 684 | 711 | $context['clockicons'] = safe_unserialize(base64_decode('YTozOntzOjE6ImgiO2E6NTp7aTowO2k6MTY7aToxO2k6ODtpOjI7aTo0O2k6MztpOjI7aTo0O2k6MTt9czoxOiJtIjthOjY6e2k6MDtpOjMyO2k6MTtpOjE2O2k6MjtpOjg7aTozO2k6NDtpOjQ7aToyO2k6NTtpOjE7fXM6MToicyI7YTo2OntpOjA7aTozMjtpOjE7aToxNjtpOjI7aTo4O2k6MztpOjQ7aTo0O2k6MjtpOjU7aToxO319')); |
| 685 | - } |
|
| 686 | - elseif ($omfg) |
|
| 712 | + } elseif ($omfg) |
|
| 687 | 713 | { |
| 688 | 714 | $context['sub_template'] = 'omfg'; |
| 689 | 715 | $context['linktree'][] = array('url' => $scripturl . '?action=clock;omfg', 'name' => 'OMFG'); |
| 690 | 716 | $context['clockicons'] = safe_unserialize(base64_decode('YTo2OntzOjQ6InllYXIiO2E6Nzp7aTowO2k6NjQ7aToxO2k6MzI7aToyO2k6MTY7aTozO2k6ODtpOjQ7aTo0O2k6NTtpOjI7aTo2O2k6MTt9czo1OiJtb250aCI7YTo0OntpOjA7aTo4O2k6MTtpOjQ7aToyO2k6MjtpOjM7aToxO31zOjM6ImRheSI7YTo1OntpOjA7aToxNjtpOjE7aTo4O2k6MjtpOjQ7aTozO2k6MjtpOjQ7aToxO31zOjQ6ImhvdXIiO2E6NTp7aTowO2k6MTY7aToxO2k6ODtpOjI7aTo0O2k6MztpOjI7aTo0O2k6MTt9czozOiJtaW4iO2E6Njp7aTowO2k6MzI7aToxO2k6MTY7aToyO2k6ODtpOjM7aTo0O2k6NDtpOjI7aTo1O2k6MTt9czozOiJzZWMiO2E6Njp7aTowO2k6MzI7aToxO2k6MTY7aToyO2k6ODtpOjM7aTo0O2k6NDtpOjI7aTo1O2k6MTt9fQ==')); |
| 691 | - } |
|
| 692 | - elseif (isset($_REQUEST['time'])) |
|
| 717 | + } elseif (isset($_REQUEST['time'])) |
|
| 693 | 718 | { |
| 694 | 719 | $context['sub_template'] = 'thetime'; |
| 695 | 720 | $time = getdate($_REQUEST['time'] == 'now' ? time() : (int) $_REQUEST['time']); |
@@ -749,12 +774,13 @@ discard block |
||
| 749 | 774 | ), |
| 750 | 775 | ); |
| 751 | 776 | |
| 752 | - foreach ($context['clockicons'] as $t => $vs) |
|
| 753 | - foreach ($vs as $v => $dumb) |
|
| 777 | + foreach ($context['clockicons'] as $t => $vs) { |
|
| 778 | + foreach ($vs as $v => $dumb) |
|
| 754 | 779 | { |
| 755 | 780 | if ($$t >= $v) |
| 756 | 781 | { |
| 757 | 782 | $$t -= $v; |
| 783 | + } |
|
| 758 | 784 | $context['clockicons'][$t][$v] = true; |
| 759 | 785 | } |
| 760 | 786 | } |
@@ -1622,8 +1622,7 @@ |
||
| 1622 | 1622 | updateStats('topic'); |
| 1623 | 1623 | |
| 1624 | 1624 | // This function is needed to do the updateStats('subject') call. |
| 1625 | - $smcFunc['strtolower'] = $db_character_set != 'utf8' && $txt['lang_character_set'] != 'UTF-8' ? 'strtolower' : |
|
| 1626 | - function($string){ |
|
| 1625 | + $smcFunc['strtolower'] = $db_character_set != 'utf8' && $txt['lang_character_set'] != 'UTF-8' ? 'strtolower' : function($string) { |
|
| 1627 | 1626 | global $sourcedir; |
| 1628 | 1627 | if (function_exists('mb_strtolower')) |
| 1629 | 1628 | return mb_strtolower($string, 'UTF-8'); |
@@ -20,8 +20,9 @@ discard block |
||
| 20 | 20 | // ><html dir="ltr"><head><title>Error!</title></head><body>Sorry, this installer requires PHP!<div style="display: none;"> |
| 21 | 21 | |
| 22 | 22 | // Let's pull in useful classes |
| 23 | -if (!defined('SMF')) |
|
| 23 | +if (!defined('SMF')) { |
|
| 24 | 24 | define('SMF', 1); |
| 25 | +} |
|
| 25 | 26 | |
| 26 | 27 | require_once('Sources/Class-Package.php'); |
| 27 | 28 | |
@@ -63,12 +64,14 @@ discard block |
||
| 63 | 64 | $value = preg_replace('~[^A-Za-z0-9_\$]~', '', $value); |
| 64 | 65 | |
| 65 | 66 | // Is it reserved? |
| 66 | - if ($value == 'pg_') |
|
| 67 | - return $txt['error_db_prefix_reserved']; |
|
| 67 | + if ($value == 'pg_') { |
|
| 68 | + return $txt['error_db_prefix_reserved']; |
|
| 69 | + } |
|
| 68 | 70 | |
| 69 | 71 | // Is the prefix numeric? |
| 70 | - if (preg_match('~^\d~', $value)) |
|
| 71 | - return $txt['error_db_prefix_numeric']; |
|
| 72 | + if (preg_match('~^\d~', $value)) { |
|
| 73 | + return $txt['error_db_prefix_numeric']; |
|
| 74 | + } |
|
| 72 | 75 | |
| 73 | 76 | return true; |
| 74 | 77 | }, |
@@ -115,10 +118,11 @@ discard block |
||
| 115 | 118 | $incontext['skip'] = false; |
| 116 | 119 | |
| 117 | 120 | // Call the step and if it returns false that means pause! |
| 118 | - if (function_exists($step[2]) && $step[2]() === false) |
|
| 119 | - break; |
|
| 120 | - elseif (function_exists($step[2])) |
|
| 121 | - $incontext['current_step']++; |
|
| 121 | + if (function_exists($step[2]) && $step[2]() === false) { |
|
| 122 | + break; |
|
| 123 | + } elseif (function_exists($step[2])) { |
|
| 124 | + $incontext['current_step']++; |
|
| 125 | + } |
|
| 122 | 126 | |
| 123 | 127 | // No warnings pass on. |
| 124 | 128 | $incontext['warning'] = ''; |
@@ -134,12 +138,14 @@ discard block |
||
| 134 | 138 | global $databases, $incontext; |
| 135 | 139 | |
| 136 | 140 | // Just so people using older versions of PHP aren't left in the cold. |
| 137 | - if (!isset($_SERVER['PHP_SELF'])) |
|
| 138 | - $_SERVER['PHP_SELF'] = isset($GLOBALS['HTTP_SERVER_VARS']['PHP_SELF']) ? $GLOBALS['HTTP_SERVER_VARS']['PHP_SELF'] : 'install.php'; |
|
| 141 | + if (!isset($_SERVER['PHP_SELF'])) { |
|
| 142 | + $_SERVER['PHP_SELF'] = isset($GLOBALS['HTTP_SERVER_VARS']['PHP_SELF']) ? $GLOBALS['HTTP_SERVER_VARS']['PHP_SELF'] : 'install.php'; |
|
| 143 | + } |
|
| 139 | 144 | |
| 140 | 145 | // Turn off magic quotes runtime and enable error reporting. |
| 141 | - if (function_exists('set_magic_quotes_runtime')) |
|
| 142 | - @set_magic_quotes_runtime(0); |
|
| 146 | + if (function_exists('set_magic_quotes_runtime')) { |
|
| 147 | + @set_magic_quotes_runtime(0); |
|
| 148 | + } |
|
| 143 | 149 | error_reporting(E_ALL); |
| 144 | 150 | |
| 145 | 151 | // Fun. Low PHP version... |
@@ -153,21 +159,23 @@ discard block |
||
| 153 | 159 | { |
| 154 | 160 | ob_start(); |
| 155 | 161 | |
| 156 | - if (ini_get('session.save_handler') == 'user') |
|
| 157 | - @ini_set('session.save_handler', 'files'); |
|
| 158 | - if (function_exists('session_start')) |
|
| 159 | - @session_start(); |
|
| 160 | - } |
|
| 161 | - else |
|
| 162 | + if (ini_get('session.save_handler') == 'user') { |
|
| 163 | + @ini_set('session.save_handler', 'files'); |
|
| 164 | + } |
|
| 165 | + if (function_exists('session_start')) { |
|
| 166 | + @session_start(); |
|
| 167 | + } |
|
| 168 | + } else |
|
| 162 | 169 | { |
| 163 | 170 | ob_start('ob_gzhandler'); |
| 164 | 171 | |
| 165 | - if (ini_get('session.save_handler') == 'user') |
|
| 166 | - @ini_set('session.save_handler', 'files'); |
|
| 172 | + if (ini_get('session.save_handler') == 'user') { |
|
| 173 | + @ini_set('session.save_handler', 'files'); |
|
| 174 | + } |
|
| 167 | 175 | session_start(); |
| 168 | 176 | |
| 169 | - if (!headers_sent()) |
|
| 170 | - echo '<!DOCTYPE html> |
|
| 177 | + if (!headers_sent()) { |
|
| 178 | + echo '<!DOCTYPE html> |
|
| 171 | 179 | <html> |
| 172 | 180 | <head> |
| 173 | 181 | <title>', htmlspecialchars($_GET['pass_string']), '</title> |
@@ -176,6 +184,7 @@ discard block |
||
| 176 | 184 | <strong>', htmlspecialchars($_GET['pass_string']), '</strong> |
| 177 | 185 | </body> |
| 178 | 186 | </html>'; |
| 187 | + } |
|
| 179 | 188 | exit; |
| 180 | 189 | } |
| 181 | 190 | |
@@ -184,16 +193,18 @@ discard block |
||
| 184 | 193 | { |
| 185 | 194 | $incontext['remote_files_available'] = false; |
| 186 | 195 | $test = @fsockopen('www.simplemachines.org', 80, $errno, $errstr, 1); |
| 187 | - if ($test) |
|
| 188 | - $incontext['remote_files_available'] = true; |
|
| 196 | + if ($test) { |
|
| 197 | + $incontext['remote_files_available'] = true; |
|
| 198 | + } |
|
| 189 | 199 | @fclose($test); |
| 190 | 200 | } |
| 191 | 201 | |
| 192 | 202 | // Add slashes, as long as they aren't already being added. |
| 193 | - if (!function_exists('get_magic_quotes_gpc') || @get_magic_quotes_gpc() == 0) |
|
| 194 | - foreach ($_POST as $k => $v) |
|
| 203 | + if (!function_exists('get_magic_quotes_gpc') || @get_magic_quotes_gpc() == 0) { |
|
| 204 | + foreach ($_POST as $k => $v) |
|
| 195 | 205 | if (strpos($k, 'password') === false && strpos($k, 'db_passwd') === false) |
| 196 | 206 | $_POST[$k] = addslashes($v); |
| 207 | + } |
|
| 197 | 208 | |
| 198 | 209 | // This is really quite simple; if ?delete is on the URL, delete the installer... |
| 199 | 210 | if (isset($_GET['delete'])) |
@@ -214,8 +225,7 @@ discard block |
||
| 214 | 225 | $ftp->close(); |
| 215 | 226 | |
| 216 | 227 | unset($_SESSION['installer_temp_ftp']); |
| 217 | - } |
|
| 218 | - else |
|
| 228 | + } else |
|
| 219 | 229 | { |
| 220 | 230 | @unlink(__FILE__); |
| 221 | 231 | |
@@ -236,10 +246,11 @@ discard block |
||
| 236 | 246 | { |
| 237 | 247 | // Get PHP's default timezone, if set |
| 238 | 248 | $ini_tz = ini_get('date.timezone'); |
| 239 | - if (!empty($ini_tz)) |
|
| 240 | - $timezone_id = $ini_tz; |
|
| 241 | - else |
|
| 242 | - $timezone_id = ''; |
|
| 249 | + if (!empty($ini_tz)) { |
|
| 250 | + $timezone_id = $ini_tz; |
|
| 251 | + } else { |
|
| 252 | + $timezone_id = ''; |
|
| 253 | + } |
|
| 243 | 254 | |
| 244 | 255 | // If date.timezone is unset, invalid, or just plain weird, make a best guess |
| 245 | 256 | if (!in_array($timezone_id, timezone_identifiers_list())) |
@@ -269,8 +280,9 @@ discard block |
||
| 269 | 280 | $dir = dir(dirname(__FILE__) . '/Themes/default/languages'); |
| 270 | 281 | while ($entry = $dir->read()) |
| 271 | 282 | { |
| 272 | - if (substr($entry, 0, 8) == 'Install.' && substr($entry, -4) == '.php') |
|
| 273 | - $incontext['detected_languages'][$entry] = ucfirst(substr($entry, 8, strlen($entry) - 12)); |
|
| 283 | + if (substr($entry, 0, 8) == 'Install.' && substr($entry, -4) == '.php') { |
|
| 284 | + $incontext['detected_languages'][$entry] = ucfirst(substr($entry, 8, strlen($entry) - 12)); |
|
| 285 | + } |
|
| 274 | 286 | } |
| 275 | 287 | $dir->close(); |
| 276 | 288 | } |
@@ -305,10 +317,11 @@ discard block |
||
| 305 | 317 | } |
| 306 | 318 | |
| 307 | 319 | // Override the language file? |
| 308 | - if (isset($_GET['lang_file'])) |
|
| 309 | - $_SESSION['installer_temp_lang'] = $_GET['lang_file']; |
|
| 310 | - elseif (isset($GLOBALS['HTTP_GET_VARS']['lang_file'])) |
|
| 311 | - $_SESSION['installer_temp_lang'] = $GLOBALS['HTTP_GET_VARS']['lang_file']; |
|
| 320 | + if (isset($_GET['lang_file'])) { |
|
| 321 | + $_SESSION['installer_temp_lang'] = $_GET['lang_file']; |
|
| 322 | + } elseif (isset($GLOBALS['HTTP_GET_VARS']['lang_file'])) { |
|
| 323 | + $_SESSION['installer_temp_lang'] = $GLOBALS['HTTP_GET_VARS']['lang_file']; |
|
| 324 | + } |
|
| 312 | 325 | |
| 313 | 326 | // Make sure it exists, if it doesn't reset it. |
| 314 | 327 | if (!isset($_SESSION['installer_temp_lang']) || preg_match('~[^\\w_\\-.]~', $_SESSION['installer_temp_lang']) === 1 || !file_exists(dirname(__FILE__) . '/Themes/default/languages/' . $_SESSION['installer_temp_lang'])) |
@@ -317,8 +330,9 @@ discard block |
||
| 317 | 330 | list ($_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']); |
| 318 | 331 | |
| 319 | 332 | // If we have english and some other language, use the other language. We Americans hate english :P. |
| 320 | - if ($_SESSION['installer_temp_lang'] == 'Install.english.php' && count($incontext['detected_languages']) > 1) |
|
| 321 | - list (, $_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']); |
|
| 333 | + if ($_SESSION['installer_temp_lang'] == 'Install.english.php' && count($incontext['detected_languages']) > 1) { |
|
| 334 | + list (, $_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']); |
|
| 335 | + } |
|
| 322 | 336 | } |
| 323 | 337 | |
| 324 | 338 | // And now include the actual language file itself. |
@@ -331,15 +345,18 @@ discard block |
||
| 331 | 345 | global $db_prefix, $db_connection, $sourcedir; |
| 332 | 346 | global $smcFunc, $modSettings, $db_type, $db_name, $db_user, $db_persist; |
| 333 | 347 | |
| 334 | - if (empty($sourcedir)) |
|
| 335 | - $sourcedir = dirname(__FILE__) . '/Sources'; |
|
| 348 | + if (empty($sourcedir)) { |
|
| 349 | + $sourcedir = dirname(__FILE__) . '/Sources'; |
|
| 350 | + } |
|
| 336 | 351 | |
| 337 | 352 | // Need this to check whether we need the database password. |
| 338 | 353 | require(dirname(__FILE__) . '/Settings.php'); |
| 339 | - if (!defined('SMF')) |
|
| 340 | - define('SMF', 1); |
|
| 341 | - if (empty($smcFunc)) |
|
| 342 | - $smcFunc = array(); |
|
| 354 | + if (!defined('SMF')) { |
|
| 355 | + define('SMF', 1); |
|
| 356 | + } |
|
| 357 | + if (empty($smcFunc)) { |
|
| 358 | + $smcFunc = array(); |
|
| 359 | + } |
|
| 343 | 360 | |
| 344 | 361 | $modSettings['disableQueryCheck'] = true; |
| 345 | 362 | |
@@ -347,8 +364,9 @@ discard block |
||
| 347 | 364 | if (!$db_connection) |
| 348 | 365 | { |
| 349 | 366 | require_once($sourcedir . '/Subs-Db-' . $db_type . '.php'); |
| 350 | - if (version_compare(PHP_VERSION, '5', '<')) |
|
| 351 | - require_once($sourcedir . '/Subs-Compat.php'); |
|
| 367 | + if (version_compare(PHP_VERSION, '5', '<')) { |
|
| 368 | + require_once($sourcedir . '/Subs-Compat.php'); |
|
| 369 | + } |
|
| 352 | 370 | |
| 353 | 371 | $db_options = array('persist' => $db_persist); |
| 354 | 372 | $port = ''; |
@@ -359,19 +377,20 @@ discard block |
||
| 359 | 377 | if ($db_type == 'mysql') |
| 360 | 378 | { |
| 361 | 379 | $port = ((int) $_POST['db_port'] == ini_get($db_type . 'default_port')) ? '' : (int) $_POST['db_port']; |
| 362 | - } |
|
| 363 | - elseif ($db_type == 'postgresql') |
|
| 380 | + } elseif ($db_type == 'postgresql') |
|
| 364 | 381 | { |
| 365 | 382 | // PostgreSQL doesn't have a default port setting in php.ini, so just check against the default |
| 366 | 383 | $port = ((int) $_POST['db_port'] == 5432) ? '' : (int) $_POST['db_port']; |
| 367 | 384 | } |
| 368 | 385 | } |
| 369 | 386 | |
| 370 | - if (!empty($port)) |
|
| 371 | - $db_options['port'] = $port; |
|
| 387 | + if (!empty($port)) { |
|
| 388 | + $db_options['port'] = $port; |
|
| 389 | + } |
|
| 372 | 390 | |
| 373 | - if (!$db_connection) |
|
| 374 | - $db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, $db_options); |
|
| 391 | + if (!$db_connection) { |
|
| 392 | + $db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, $db_options); |
|
| 393 | + } |
|
| 375 | 394 | } |
| 376 | 395 | } |
| 377 | 396 | |
@@ -399,8 +418,9 @@ discard block |
||
| 399 | 418 | // @todo REMOVE THIS!! |
| 400 | 419 | else |
| 401 | 420 | { |
| 402 | - if (function_exists('doStep' . $_GET['step'])) |
|
| 403 | - call_user_func('doStep' . $_GET['step']); |
|
| 421 | + if (function_exists('doStep' . $_GET['step'])) { |
|
| 422 | + call_user_func('doStep' . $_GET['step']); |
|
| 423 | + } |
|
| 404 | 424 | } |
| 405 | 425 | // Show the footer. |
| 406 | 426 | template_install_below(); |
@@ -418,8 +438,9 @@ discard block |
||
| 418 | 438 | $incontext['sub_template'] = 'welcome_message'; |
| 419 | 439 | |
| 420 | 440 | // Done the submission? |
| 421 | - if (isset($_POST['contbutt'])) |
|
| 422 | - return true; |
|
| 441 | + if (isset($_POST['contbutt'])) { |
|
| 442 | + return true; |
|
| 443 | + } |
|
| 423 | 444 | |
| 424 | 445 | // See if we think they have already installed it? |
| 425 | 446 | if (is_readable(dirname(__FILE__) . '/Settings.php')) |
@@ -427,14 +448,17 @@ discard block |
||
| 427 | 448 | $probably_installed = 0; |
| 428 | 449 | foreach (file(dirname(__FILE__) . '/Settings.php') as $line) |
| 429 | 450 | { |
| 430 | - if (preg_match('~^\$db_passwd\s=\s\'([^\']+)\';$~', $line)) |
|
| 431 | - $probably_installed++; |
|
| 432 | - if (preg_match('~^\$boardurl\s=\s\'([^\']+)\';~', $line) && !preg_match('~^\$boardurl\s=\s\'http://127\.0\.0\.1/smf\';~', $line)) |
|
| 433 | - $probably_installed++; |
|
| 451 | + if (preg_match('~^\$db_passwd\s=\s\'([^\']+)\';$~', $line)) { |
|
| 452 | + $probably_installed++; |
|
| 453 | + } |
|
| 454 | + if (preg_match('~^\$boardurl\s=\s\'([^\']+)\';~', $line) && !preg_match('~^\$boardurl\s=\s\'http://127\.0\.0\.1/smf\';~', $line)) { |
|
| 455 | + $probably_installed++; |
|
| 456 | + } |
|
| 434 | 457 | } |
| 435 | 458 | |
| 436 | - if ($probably_installed == 2) |
|
| 437 | - $incontext['warning'] = $txt['error_already_installed']; |
|
| 459 | + if ($probably_installed == 2) { |
|
| 460 | + $incontext['warning'] = $txt['error_already_installed']; |
|
| 461 | + } |
|
| 438 | 462 | } |
| 439 | 463 | |
| 440 | 464 | // Is some database support even compiled in? |
@@ -449,36 +473,43 @@ discard block |
||
| 449 | 473 | $databases[$key]['supported'] = false; |
| 450 | 474 | $notFoundSQLFile = true; |
| 451 | 475 | $txt['error_db_script_missing'] = sprintf($txt['error_db_script_missing'], 'install_' . $GLOBALS['db_script_version'] . '_' . $type . '.sql'); |
| 476 | + } else { |
|
| 477 | + $incontext['supported_databases'][] = $db; |
|
| 452 | 478 | } |
| 453 | - else |
|
| 454 | - $incontext['supported_databases'][] = $db; |
|
| 455 | 479 | } |
| 456 | 480 | } |
| 457 | 481 | |
| 458 | 482 | // Check the PHP version. |
| 459 | - if ((!function_exists('version_compare') || version_compare($GLOBALS['required_php_version'], PHP_VERSION, '>'))) |
|
| 460 | - $error = 'error_php_too_low'; |
|
| 483 | + if ((!function_exists('version_compare') || version_compare($GLOBALS['required_php_version'], PHP_VERSION, '>'))) { |
|
| 484 | + $error = 'error_php_too_low'; |
|
| 485 | + } |
|
| 461 | 486 | // Make sure we have a supported database |
| 462 | - elseif (empty($incontext['supported_databases'])) |
|
| 463 | - $error = empty($notFoundSQLFile) ? 'error_db_missing' : 'error_db_script_missing'; |
|
| 487 | + elseif (empty($incontext['supported_databases'])) { |
|
| 488 | + $error = empty($notFoundSQLFile) ? 'error_db_missing' : 'error_db_script_missing'; |
|
| 489 | + } |
|
| 464 | 490 | // How about session support? Some crazy sysadmin remove it? |
| 465 | - elseif (!function_exists('session_start')) |
|
| 466 | - $error = 'error_session_missing'; |
|
| 491 | + elseif (!function_exists('session_start')) { |
|
| 492 | + $error = 'error_session_missing'; |
|
| 493 | + } |
|
| 467 | 494 | // Make sure they uploaded all the files. |
| 468 | - elseif (!file_exists(dirname(__FILE__) . '/index.php')) |
|
| 469 | - $error = 'error_missing_files'; |
|
| 495 | + elseif (!file_exists(dirname(__FILE__) . '/index.php')) { |
|
| 496 | + $error = 'error_missing_files'; |
|
| 497 | + } |
|
| 470 | 498 | // Very simple check on the session.save_path for Windows. |
| 471 | 499 | // @todo Move this down later if they don't use database-driven sessions? |
| 472 | - elseif (@ini_get('session.save_path') == '/tmp' && substr(__FILE__, 1, 2) == ':\\') |
|
| 473 | - $error = 'error_session_save_path'; |
|
| 500 | + elseif (@ini_get('session.save_path') == '/tmp' && substr(__FILE__, 1, 2) == ':\\') { |
|
| 501 | + $error = 'error_session_save_path'; |
|
| 502 | + } |
|
| 474 | 503 | |
| 475 | 504 | // Since each of the three messages would look the same, anyway... |
| 476 | - if (isset($error)) |
|
| 477 | - $incontext['error'] = $txt[$error]; |
|
| 505 | + if (isset($error)) { |
|
| 506 | + $incontext['error'] = $txt[$error]; |
|
| 507 | + } |
|
| 478 | 508 | |
| 479 | 509 | // Mod_security blocks everything that smells funny. Let SMF handle security. |
| 480 | - if (!fixModSecurity() && !isset($_GET['overmodsecurity'])) |
|
| 481 | - $incontext['error'] = $txt['error_mod_security'] . '<br><br><a href="' . $installurl . '?overmodsecurity=true">' . $txt['error_message_click'] . '</a> ' . $txt['error_message_bad_try_again']; |
|
| 510 | + if (!fixModSecurity() && !isset($_GET['overmodsecurity'])) { |
|
| 511 | + $incontext['error'] = $txt['error_mod_security'] . '<br><br><a href="' . $installurl . '?overmodsecurity=true">' . $txt['error_message_click'] . '</a> ' . $txt['error_message_bad_try_again']; |
|
| 512 | + } |
|
| 482 | 513 | |
| 483 | 514 | return false; |
| 484 | 515 | } |
@@ -503,12 +534,14 @@ discard block |
||
| 503 | 534 | 'Settings_bak.php', |
| 504 | 535 | ); |
| 505 | 536 | |
| 506 | - foreach ($incontext['detected_languages'] as $lang => $temp) |
|
| 507 | - $extra_files[] = 'Themes/default/languages/' . $lang; |
|
| 537 | + foreach ($incontext['detected_languages'] as $lang => $temp) { |
|
| 538 | + $extra_files[] = 'Themes/default/languages/' . $lang; |
|
| 539 | + } |
|
| 508 | 540 | |
| 509 | 541 | // With mod_security installed, we could attempt to fix it with .htaccess. |
| 510 | - if (function_exists('apache_get_modules') && in_array('mod_security', apache_get_modules())) |
|
| 511 | - $writable_files[] = file_exists(dirname(__FILE__) . '/.htaccess') ? '.htaccess' : '.'; |
|
| 542 | + if (function_exists('apache_get_modules') && in_array('mod_security', apache_get_modules())) { |
|
| 543 | + $writable_files[] = file_exists(dirname(__FILE__) . '/.htaccess') ? '.htaccess' : '.'; |
|
| 544 | + } |
|
| 512 | 545 | |
| 513 | 546 | $failed_files = array(); |
| 514 | 547 | |
@@ -524,12 +557,14 @@ discard block |
||
| 524 | 557 | @chmod(dirname(__FILE__) . '/' . $file, 0755); |
| 525 | 558 | |
| 526 | 559 | // Well, 755 hopefully worked... if not, try 777. |
| 527 | - if (!is_writable(dirname(__FILE__) . '/' . $file) && !@chmod(dirname(__FILE__) . '/' . $file, 0777)) |
|
| 528 | - $failed_files[] = $file; |
|
| 560 | + if (!is_writable(dirname(__FILE__) . '/' . $file) && !@chmod(dirname(__FILE__) . '/' . $file, 0777)) { |
|
| 561 | + $failed_files[] = $file; |
|
| 562 | + } |
|
| 529 | 563 | } |
| 530 | 564 | } |
| 531 | - foreach ($extra_files as $file) |
|
| 532 | - @chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777); |
|
| 565 | + foreach ($extra_files as $file) { |
|
| 566 | + @chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777); |
|
| 567 | + } |
|
| 533 | 568 | } |
| 534 | 569 | // Windows is trickier. Let's try opening for r+... |
| 535 | 570 | else |
@@ -539,30 +574,35 @@ discard block |
||
| 539 | 574 | foreach ($writable_files as $file) |
| 540 | 575 | { |
| 541 | 576 | // Folders can't be opened for write... but the index.php in them can ;) |
| 542 | - if (is_dir(dirname(__FILE__) . '/' . $file)) |
|
| 543 | - $file .= '/index.php'; |
|
| 577 | + if (is_dir(dirname(__FILE__) . '/' . $file)) { |
|
| 578 | + $file .= '/index.php'; |
|
| 579 | + } |
|
| 544 | 580 | |
| 545 | 581 | // Funny enough, chmod actually does do something on windows - it removes the read only attribute. |
| 546 | 582 | @chmod(dirname(__FILE__) . '/' . $file, 0777); |
| 547 | 583 | $fp = @fopen(dirname(__FILE__) . '/' . $file, 'r+'); |
| 548 | 584 | |
| 549 | 585 | // Hmm, okay, try just for write in that case... |
| 550 | - if (!is_resource($fp)) |
|
| 551 | - $fp = @fopen(dirname(__FILE__) . '/' . $file, 'w'); |
|
| 586 | + if (!is_resource($fp)) { |
|
| 587 | + $fp = @fopen(dirname(__FILE__) . '/' . $file, 'w'); |
|
| 588 | + } |
|
| 552 | 589 | |
| 553 | - if (!is_resource($fp)) |
|
| 554 | - $failed_files[] = $file; |
|
| 590 | + if (!is_resource($fp)) { |
|
| 591 | + $failed_files[] = $file; |
|
| 592 | + } |
|
| 555 | 593 | |
| 556 | 594 | @fclose($fp); |
| 557 | 595 | } |
| 558 | - foreach ($extra_files as $file) |
|
| 559 | - @chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777); |
|
| 596 | + foreach ($extra_files as $file) { |
|
| 597 | + @chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777); |
|
| 598 | + } |
|
| 560 | 599 | } |
| 561 | 600 | |
| 562 | 601 | $failure = count($failed_files) >= 1; |
| 563 | 602 | |
| 564 | - if (!isset($_SERVER)) |
|
| 565 | - return !$failure; |
|
| 603 | + if (!isset($_SERVER)) { |
|
| 604 | + return !$failure; |
|
| 605 | + } |
|
| 566 | 606 | |
| 567 | 607 | // Put the list into context. |
| 568 | 608 | $incontext['failed_files'] = $failed_files; |
@@ -610,19 +650,23 @@ discard block |
||
| 610 | 650 | |
| 611 | 651 | if (!isset($ftp) || $ftp->error !== false) |
| 612 | 652 | { |
| 613 | - if (!isset($ftp)) |
|
| 614 | - $ftp = new ftp_connection(null); |
|
| 653 | + if (!isset($ftp)) { |
|
| 654 | + $ftp = new ftp_connection(null); |
|
| 655 | + } |
|
| 615 | 656 | // Save the error so we can mess with listing... |
| 616 | - elseif ($ftp->error !== false && empty($incontext['ftp_errors']) && !empty($ftp->last_message)) |
|
| 617 | - $incontext['ftp_errors'][] = $ftp->last_message; |
|
| 657 | + elseif ($ftp->error !== false && empty($incontext['ftp_errors']) && !empty($ftp->last_message)) { |
|
| 658 | + $incontext['ftp_errors'][] = $ftp->last_message; |
|
| 659 | + } |
|
| 618 | 660 | |
| 619 | 661 | list ($username, $detect_path, $found_path) = $ftp->detect_path(dirname(__FILE__)); |
| 620 | 662 | |
| 621 | - if (empty($_POST['ftp_path']) && $found_path) |
|
| 622 | - $_POST['ftp_path'] = $detect_path; |
|
| 663 | + if (empty($_POST['ftp_path']) && $found_path) { |
|
| 664 | + $_POST['ftp_path'] = $detect_path; |
|
| 665 | + } |
|
| 623 | 666 | |
| 624 | - if (!isset($_POST['ftp_username'])) |
|
| 625 | - $_POST['ftp_username'] = $username; |
|
| 667 | + if (!isset($_POST['ftp_username'])) { |
|
| 668 | + $_POST['ftp_username'] = $username; |
|
| 669 | + } |
|
| 626 | 670 | |
| 627 | 671 | // Set the username etc, into context. |
| 628 | 672 | $incontext['ftp'] = array( |
@@ -634,8 +678,7 @@ discard block |
||
| 634 | 678 | ); |
| 635 | 679 | |
| 636 | 680 | return false; |
| 637 | - } |
|
| 638 | - else |
|
| 681 | + } else |
|
| 639 | 682 | { |
| 640 | 683 | $_SESSION['installer_temp_ftp'] = array( |
| 641 | 684 | 'server' => $_POST['ftp_server'], |
@@ -649,10 +692,12 @@ discard block |
||
| 649 | 692 | |
| 650 | 693 | foreach ($failed_files as $file) |
| 651 | 694 | { |
| 652 | - if (!is_writable(dirname(__FILE__) . '/' . $file)) |
|
| 653 | - $ftp->chmod($file, 0755); |
|
| 654 | - if (!is_writable(dirname(__FILE__) . '/' . $file)) |
|
| 655 | - $ftp->chmod($file, 0777); |
|
| 695 | + if (!is_writable(dirname(__FILE__) . '/' . $file)) { |
|
| 696 | + $ftp->chmod($file, 0755); |
|
| 697 | + } |
|
| 698 | + if (!is_writable(dirname(__FILE__) . '/' . $file)) { |
|
| 699 | + $ftp->chmod($file, 0777); |
|
| 700 | + } |
|
| 656 | 701 | if (!is_writable(dirname(__FILE__) . '/' . $file)) |
| 657 | 702 | { |
| 658 | 703 | $failed_files_updated[] = $file; |
@@ -707,15 +752,17 @@ discard block |
||
| 707 | 752 | |
| 708 | 753 | if (!$foundOne) |
| 709 | 754 | { |
| 710 | - if (isset($db['default_host'])) |
|
| 711 | - $incontext['db']['server'] = ini_get($db['default_host']) or $incontext['db']['server'] = 'localhost'; |
|
| 755 | + if (isset($db['default_host'])) { |
|
| 756 | + $incontext['db']['server'] = ini_get($db['default_host']) or $incontext['db']['server'] = 'localhost'; |
|
| 757 | + } |
|
| 712 | 758 | if (isset($db['default_user'])) |
| 713 | 759 | { |
| 714 | 760 | $incontext['db']['user'] = ini_get($db['default_user']); |
| 715 | 761 | $incontext['db']['name'] = ini_get($db['default_user']); |
| 716 | 762 | } |
| 717 | - if (isset($db['default_password'])) |
|
| 718 | - $incontext['db']['pass'] = ini_get($db['default_password']); |
|
| 763 | + if (isset($db['default_password'])) { |
|
| 764 | + $incontext['db']['pass'] = ini_get($db['default_password']); |
|
| 765 | + } |
|
| 719 | 766 | |
| 720 | 767 | // For simplicity and less confusion, leave the port blank by default |
| 721 | 768 | $incontext['db']['port'] = ''; |
@@ -734,10 +781,10 @@ discard block |
||
| 734 | 781 | $incontext['db']['server'] = $_POST['db_server']; |
| 735 | 782 | $incontext['db']['prefix'] = $_POST['db_prefix']; |
| 736 | 783 | |
| 737 | - if (!empty($_POST['db_port'])) |
|
| 738 | - $incontext['db']['port'] = $_POST['db_port']; |
|
| 739 | - } |
|
| 740 | - else |
|
| 784 | + if (!empty($_POST['db_port'])) { |
|
| 785 | + $incontext['db']['port'] = $_POST['db_port']; |
|
| 786 | + } |
|
| 787 | + } else |
|
| 741 | 788 | { |
| 742 | 789 | $incontext['db']['prefix'] = 'smf_'; |
| 743 | 790 | } |
@@ -773,10 +820,11 @@ discard block |
||
| 773 | 820 | if (!empty($_POST['db_port'])) |
| 774 | 821 | { |
| 775 | 822 | // For MySQL, we can get the "default port" from PHP. PostgreSQL has no such option though. |
| 776 | - if (($db_type == 'mysql' || $db_type == 'mysqli') && $_POST['db_port'] != ini_get($db_type . '.default_port')) |
|
| 777 | - $vars['db_port'] = (int) $_POST['db_port']; |
|
| 778 | - elseif ($db_type == 'postgresql' && $_POST['db_port'] != 5432) |
|
| 779 | - $vars['db_port'] = (int) $_POST['db_port']; |
|
| 823 | + if (($db_type == 'mysql' || $db_type == 'mysqli') && $_POST['db_port'] != ini_get($db_type . '.default_port')) { |
|
| 824 | + $vars['db_port'] = (int) $_POST['db_port']; |
|
| 825 | + } elseif ($db_type == 'postgresql' && $_POST['db_port'] != 5432) { |
|
| 826 | + $vars['db_port'] = (int) $_POST['db_port']; |
|
| 827 | + } |
|
| 780 | 828 | } |
| 781 | 829 | |
| 782 | 830 | // God I hope it saved! |
@@ -789,8 +837,9 @@ discard block |
||
| 789 | 837 | // Make sure it works. |
| 790 | 838 | require(dirname(__FILE__) . '/Settings.php'); |
| 791 | 839 | |
| 792 | - if (empty($sourcedir)) |
|
| 793 | - $sourcedir = dirname(__FILE__) . '/Sources'; |
|
| 840 | + if (empty($sourcedir)) { |
|
| 841 | + $sourcedir = dirname(__FILE__) . '/Sources'; |
|
| 842 | + } |
|
| 794 | 843 | |
| 795 | 844 | // Better find the database file! |
| 796 | 845 | if (!file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php')) |
@@ -800,18 +849,21 @@ discard block |
||
| 800 | 849 | } |
| 801 | 850 | |
| 802 | 851 | // Now include it for database functions! |
| 803 | - if (!defined('SMF')) |
|
| 804 | - define('SMF', 1); |
|
| 852 | + if (!defined('SMF')) { |
|
| 853 | + define('SMF', 1); |
|
| 854 | + } |
|
| 805 | 855 | |
| 806 | 856 | $modSettings['disableQueryCheck'] = true; |
| 807 | - if (empty($smcFunc)) |
|
| 808 | - $smcFunc = array(); |
|
| 857 | + if (empty($smcFunc)) { |
|
| 858 | + $smcFunc = array(); |
|
| 859 | + } |
|
| 809 | 860 | |
| 810 | 861 | require_once($sourcedir . '/Subs-Db-' . $db_type . '.php'); |
| 811 | 862 | |
| 812 | 863 | // What - running PHP4? The shame! |
| 813 | - if (version_compare(PHP_VERSION, '5', '<')) |
|
| 814 | - require_once($sourcedir . '/Subs-Compat.php'); |
|
| 864 | + if (version_compare(PHP_VERSION, '5', '<')) { |
|
| 865 | + require_once($sourcedir . '/Subs-Compat.php'); |
|
| 866 | + } |
|
| 815 | 867 | |
| 816 | 868 | // Attempt a connection. |
| 817 | 869 | $needsDB = !empty($databases[$db_type]['always_has_db']); |
@@ -899,12 +951,14 @@ discard block |
||
| 899 | 951 | $incontext['page_title'] = $txt['install_settings']; |
| 900 | 952 | |
| 901 | 953 | // Let's see if we got the database type correct. |
| 902 | - if (isset($_POST['db_type'], $databases[$_POST['db_type']])) |
|
| 903 | - $db_type = $_POST['db_type']; |
|
| 954 | + if (isset($_POST['db_type'], $databases[$_POST['db_type']])) { |
|
| 955 | + $db_type = $_POST['db_type']; |
|
| 956 | + } |
|
| 904 | 957 | |
| 905 | 958 | // Else we'd better be able to get the connection. |
| 906 | - else |
|
| 907 | - load_database(); |
|
| 959 | + else { |
|
| 960 | + load_database(); |
|
| 961 | + } |
|
| 908 | 962 | |
| 909 | 963 | $db_type = isset($_POST['db_type']) ? $_POST['db_type'] : $db_type; |
| 910 | 964 | |
@@ -924,12 +978,14 @@ discard block |
||
| 924 | 978 | // Submitting? |
| 925 | 979 | if (isset($_POST['boardurl'])) |
| 926 | 980 | { |
| 927 | - if (substr($_POST['boardurl'], -10) == '/index.php') |
|
| 928 | - $_POST['boardurl'] = substr($_POST['boardurl'], 0, -10); |
|
| 929 | - elseif (substr($_POST['boardurl'], -1) == '/') |
|
| 930 | - $_POST['boardurl'] = substr($_POST['boardurl'], 0, -1); |
|
| 931 | - if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://') |
|
| 932 | - $_POST['boardurl'] = 'http://' . $_POST['boardurl']; |
|
| 981 | + if (substr($_POST['boardurl'], -10) == '/index.php') { |
|
| 982 | + $_POST['boardurl'] = substr($_POST['boardurl'], 0, -10); |
|
| 983 | + } elseif (substr($_POST['boardurl'], -1) == '/') { |
|
| 984 | + $_POST['boardurl'] = substr($_POST['boardurl'], 0, -1); |
|
| 985 | + } |
|
| 986 | + if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://') { |
|
| 987 | + $_POST['boardurl'] = 'http://' . $_POST['boardurl']; |
|
| 988 | + } |
|
| 933 | 989 | |
| 934 | 990 | // Save these variables. |
| 935 | 991 | $vars = array( |
@@ -960,10 +1016,10 @@ discard block |
||
| 960 | 1016 | { |
| 961 | 1017 | $incontext['error'] = sprintf($txt['error_utf8_version'], $databases[$db_type]['utf8_version']); |
| 962 | 1018 | return false; |
| 963 | - } |
|
| 964 | - else |
|
| 965 | - // Set the character set here. |
|
| 1019 | + } else { |
|
| 1020 | + // Set the character set here. |
|
| 966 | 1021 | updateSettingsFile(array('db_character_set' => 'utf8')); |
| 1022 | + } |
|
| 967 | 1023 | } |
| 968 | 1024 | |
| 969 | 1025 | // Good, skip on. |
@@ -983,8 +1039,9 @@ discard block |
||
| 983 | 1039 | $incontext['continue'] = 1; |
| 984 | 1040 | |
| 985 | 1041 | // Already done? |
| 986 | - if (isset($_POST['pop_done'])) |
|
| 987 | - return true; |
|
| 1042 | + if (isset($_POST['pop_done'])) { |
|
| 1043 | + return true; |
|
| 1044 | + } |
|
| 988 | 1045 | |
| 989 | 1046 | // Reload settings. |
| 990 | 1047 | require(dirname(__FILE__) . '/Settings.php'); |
@@ -1002,8 +1059,9 @@ discard block |
||
| 1002 | 1059 | $modSettings = array(); |
| 1003 | 1060 | if ($result !== false) |
| 1004 | 1061 | { |
| 1005 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
| 1006 | - $modSettings[$row['variable']] = $row['value']; |
|
| 1062 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
| 1063 | + $modSettings[$row['variable']] = $row['value']; |
|
| 1064 | + } |
|
| 1007 | 1065 | $smcFunc['db_free_result']($result); |
| 1008 | 1066 | |
| 1009 | 1067 | // Do they match? If so, this is just a refresh so charge on! |
@@ -1016,20 +1074,22 @@ discard block |
||
| 1016 | 1074 | $modSettings['disableQueryCheck'] = true; |
| 1017 | 1075 | |
| 1018 | 1076 | // If doing UTF8, select it. PostgreSQL requires passing it as a string... |
| 1019 | - if (!empty($db_character_set) && $db_character_set == 'utf8' && !empty($databases[$db_type]['utf8_support'])) |
|
| 1020 | - $smcFunc['db_query']('', ' |
|
| 1077 | + if (!empty($db_character_set) && $db_character_set == 'utf8' && !empty($databases[$db_type]['utf8_support'])) { |
|
| 1078 | + $smcFunc['db_query']('', ' |
|
| 1021 | 1079 | SET NAMES {string:utf8}', |
| 1022 | 1080 | array( |
| 1023 | 1081 | 'db_error_skip' => true, |
| 1024 | 1082 | 'utf8' => 'utf8', |
| 1025 | 1083 | ) |
| 1026 | 1084 | ); |
| 1085 | + } |
|
| 1027 | 1086 | |
| 1028 | 1087 | // Windows likes to leave the trailing slash, which yields to C:\path\to\SMF\/attachments... |
| 1029 | - if (substr(__DIR__, -1) == '\\') |
|
| 1030 | - $attachdir = __DIR__ . 'attachments'; |
|
| 1031 | - else |
|
| 1032 | - $attachdir = __DIR__ . '/attachments'; |
|
| 1088 | + if (substr(__DIR__, -1) == '\\') { |
|
| 1089 | + $attachdir = __DIR__ . 'attachments'; |
|
| 1090 | + } else { |
|
| 1091 | + $attachdir = __DIR__ . '/attachments'; |
|
| 1092 | + } |
|
| 1033 | 1093 | |
| 1034 | 1094 | $replaces = array( |
| 1035 | 1095 | '{$db_prefix}' => $db_prefix, |
@@ -1046,8 +1106,9 @@ discard block |
||
| 1046 | 1106 | |
| 1047 | 1107 | foreach ($txt as $key => $value) |
| 1048 | 1108 | { |
| 1049 | - if (substr($key, 0, 8) == 'default_') |
|
| 1050 | - $replaces['{$' . $key . '}'] = $smcFunc['db_escape_string']($value); |
|
| 1109 | + if (substr($key, 0, 8) == 'default_') { |
|
| 1110 | + $replaces['{$' . $key . '}'] = $smcFunc['db_escape_string']($value); |
|
| 1111 | + } |
|
| 1051 | 1112 | } |
| 1052 | 1113 | $replaces['{$default_reserved_names}'] = strtr($replaces['{$default_reserved_names}'], array('\\\\n' => '\\n')); |
| 1053 | 1114 | |
@@ -1062,8 +1123,9 @@ discard block |
||
| 1062 | 1123 | |
| 1063 | 1124 | while ($row = $smcFunc['db_fetch_assoc']($get_engines)) |
| 1064 | 1125 | { |
| 1065 | - if ($row['Support'] == 'YES' || $row['Support'] == 'DEFAULT') |
|
| 1066 | - $engines[] = $row['Engine']; |
|
| 1126 | + if ($row['Support'] == 'YES' || $row['Support'] == 'DEFAULT') { |
|
| 1127 | + $engines[] = $row['Engine']; |
|
| 1128 | + } |
|
| 1067 | 1129 | } |
| 1068 | 1130 | |
| 1069 | 1131 | // Done with this now |
@@ -1087,8 +1149,7 @@ discard block |
||
| 1087 | 1149 | $replaces['START TRANSACTION;'] = ''; |
| 1088 | 1150 | $replaces['COMMIT;'] = ''; |
| 1089 | 1151 | } |
| 1090 | - } |
|
| 1091 | - else |
|
| 1152 | + } else |
|
| 1092 | 1153 | { |
| 1093 | 1154 | $has_innodb = false; |
| 1094 | 1155 | } |
@@ -1110,21 +1171,24 @@ discard block |
||
| 1110 | 1171 | foreach ($sql_lines as $count => $line) |
| 1111 | 1172 | { |
| 1112 | 1173 | // No comments allowed! |
| 1113 | - if (substr(trim($line), 0, 1) != '#') |
|
| 1114 | - $current_statement .= "\n" . rtrim($line); |
|
| 1174 | + if (substr(trim($line), 0, 1) != '#') { |
|
| 1175 | + $current_statement .= "\n" . rtrim($line); |
|
| 1176 | + } |
|
| 1115 | 1177 | |
| 1116 | 1178 | // Is this the end of the query string? |
| 1117 | - if (empty($current_statement) || (preg_match('~;[\s]*$~s', $line) == 0 && $count != count($sql_lines))) |
|
| 1118 | - continue; |
|
| 1179 | + if (empty($current_statement) || (preg_match('~;[\s]*$~s', $line) == 0 && $count != count($sql_lines))) { |
|
| 1180 | + continue; |
|
| 1181 | + } |
|
| 1119 | 1182 | |
| 1120 | 1183 | // Does this table already exist? If so, don't insert more data into it! |
| 1121 | 1184 | if (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) != 0 && in_array($match[1], $exists)) |
| 1122 | 1185 | { |
| 1123 | 1186 | preg_match_all('~\)[,;]~', $current_statement, $matches); |
| 1124 | - if (!empty($matches[0])) |
|
| 1125 | - $incontext['sql_results']['insert_dups'] += count($matches[0]); |
|
| 1126 | - else |
|
| 1127 | - $incontext['sql_results']['insert_dups']++; |
|
| 1187 | + if (!empty($matches[0])) { |
|
| 1188 | + $incontext['sql_results']['insert_dups'] += count($matches[0]); |
|
| 1189 | + } else { |
|
| 1190 | + $incontext['sql_results']['insert_dups']++; |
|
| 1191 | + } |
|
| 1128 | 1192 | |
| 1129 | 1193 | $current_statement = ''; |
| 1130 | 1194 | continue; |
@@ -1133,8 +1197,9 @@ discard block |
||
| 1133 | 1197 | if ($smcFunc['db_query']('', $current_statement, array('security_override' => true, 'db_error_skip' => true), $db_connection) === false) |
| 1134 | 1198 | { |
| 1135 | 1199 | // Use the appropriate function based on the DB type |
| 1136 | - if ($db_type == 'mysql' || $db_type == 'mysqli') |
|
| 1137 | - $db_errorno = $db_type . '_errno'; |
|
| 1200 | + if ($db_type == 'mysql' || $db_type == 'mysqli') { |
|
| 1201 | + $db_errorno = $db_type . '_errno'; |
|
| 1202 | + } |
|
| 1138 | 1203 | |
| 1139 | 1204 | // Error 1050: Table already exists! |
| 1140 | 1205 | // @todo Needs to be made better! |
@@ -1149,18 +1214,18 @@ discard block |
||
| 1149 | 1214 | // MySQLi requires a connection object. It's optional with MySQL and Postgres |
| 1150 | 1215 | $incontext['failures'][$count] = $smcFunc['db_error']($db_connection); |
| 1151 | 1216 | } |
| 1152 | - } |
|
| 1153 | - else |
|
| 1217 | + } else |
|
| 1154 | 1218 | { |
| 1155 | - if (preg_match('~^\s*CREATE TABLE ([^\s\n\r]+?)~', $current_statement, $match) == 1) |
|
| 1156 | - $incontext['sql_results']['tables']++; |
|
| 1157 | - elseif (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) == 1) |
|
| 1219 | + if (preg_match('~^\s*CREATE TABLE ([^\s\n\r]+?)~', $current_statement, $match) == 1) { |
|
| 1220 | + $incontext['sql_results']['tables']++; |
|
| 1221 | + } elseif (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) == 1) |
|
| 1158 | 1222 | { |
| 1159 | 1223 | preg_match_all('~\)[,;]~', $current_statement, $matches); |
| 1160 | - if (!empty($matches[0])) |
|
| 1161 | - $incontext['sql_results']['inserts'] += count($matches[0]); |
|
| 1162 | - else |
|
| 1163 | - $incontext['sql_results']['inserts']++; |
|
| 1224 | + if (!empty($matches[0])) { |
|
| 1225 | + $incontext['sql_results']['inserts'] += count($matches[0]); |
|
| 1226 | + } else { |
|
| 1227 | + $incontext['sql_results']['inserts']++; |
|
| 1228 | + } |
|
| 1164 | 1229 | } |
| 1165 | 1230 | } |
| 1166 | 1231 | |
@@ -1173,15 +1238,17 @@ discard block |
||
| 1173 | 1238 | // Sort out the context for the SQL. |
| 1174 | 1239 | foreach ($incontext['sql_results'] as $key => $number) |
| 1175 | 1240 | { |
| 1176 | - if ($number == 0) |
|
| 1177 | - unset($incontext['sql_results'][$key]); |
|
| 1178 | - else |
|
| 1179 | - $incontext['sql_results'][$key] = sprintf($txt['db_populate_' . $key], $number); |
|
| 1241 | + if ($number == 0) { |
|
| 1242 | + unset($incontext['sql_results'][$key]); |
|
| 1243 | + } else { |
|
| 1244 | + $incontext['sql_results'][$key] = sprintf($txt['db_populate_' . $key], $number); |
|
| 1245 | + } |
|
| 1180 | 1246 | } |
| 1181 | 1247 | |
| 1182 | 1248 | // Make sure UTF will be used globally. |
| 1183 | - if ((!empty($databases[$db_type]['utf8_support']) && !empty($databases[$db_type]['utf8_required'])) || (empty($databases[$db_type]['utf8_required']) && !empty($databases[$db_type]['utf8_support']) && isset($_POST['utf8']))) |
|
| 1184 | - $newSettings[] = array('global_character_set', 'UTF-8'); |
|
| 1249 | + if ((!empty($databases[$db_type]['utf8_support']) && !empty($databases[$db_type]['utf8_required'])) || (empty($databases[$db_type]['utf8_required']) && !empty($databases[$db_type]['utf8_support']) && isset($_POST['utf8']))) { |
|
| 1250 | + $newSettings[] = array('global_character_set', 'UTF-8'); |
|
| 1251 | + } |
|
| 1185 | 1252 | |
| 1186 | 1253 | // Maybe we can auto-detect better cookie settings? |
| 1187 | 1254 | preg_match('~^http[s]?://([^\.]+?)([^/]*?)(/.*)?$~', $boardurl, $matches); |
@@ -1192,16 +1259,20 @@ discard block |
||
| 1192 | 1259 | $globalCookies = false; |
| 1193 | 1260 | |
| 1194 | 1261 | // Okay... let's see. Using a subdomain other than www.? (not a perfect check.) |
| 1195 | - if ($matches[2] != '' && (strpos(substr($matches[2], 1), '.') === false || in_array($matches[1], array('forum', 'board', 'community', 'forums', 'support', 'chat', 'help', 'talk', 'boards', 'www')))) |
|
| 1196 | - $globalCookies = true; |
|
| 1262 | + if ($matches[2] != '' && (strpos(substr($matches[2], 1), '.') === false || in_array($matches[1], array('forum', 'board', 'community', 'forums', 'support', 'chat', 'help', 'talk', 'boards', 'www')))) { |
|
| 1263 | + $globalCookies = true; |
|
| 1264 | + } |
|
| 1197 | 1265 | // If there's a / in the middle of the path, or it starts with ~... we want local. |
| 1198 | - if (isset($matches[3]) && strlen($matches[3]) > 3 && (substr($matches[3], 0, 2) == '/~' || strpos(substr($matches[3], 1), '/') !== false)) |
|
| 1199 | - $localCookies = true; |
|
| 1266 | + if (isset($matches[3]) && strlen($matches[3]) > 3 && (substr($matches[3], 0, 2) == '/~' || strpos(substr($matches[3], 1), '/') !== false)) { |
|
| 1267 | + $localCookies = true; |
|
| 1268 | + } |
|
| 1200 | 1269 | |
| 1201 | - if ($globalCookies) |
|
| 1202 | - $newSettings[] = array('globalCookies', '1'); |
|
| 1203 | - if ($localCookies) |
|
| 1204 | - $newSettings[] = array('localCookies', '1'); |
|
| 1270 | + if ($globalCookies) { |
|
| 1271 | + $newSettings[] = array('globalCookies', '1'); |
|
| 1272 | + } |
|
| 1273 | + if ($localCookies) { |
|
| 1274 | + $newSettings[] = array('localCookies', '1'); |
|
| 1275 | + } |
|
| 1205 | 1276 | } |
| 1206 | 1277 | |
| 1207 | 1278 | // Are we allowing stat collection? |
@@ -1217,32 +1288,36 @@ discard block |
||
| 1217 | 1288 | fwrite($fp, $out); |
| 1218 | 1289 | |
| 1219 | 1290 | $return_data = ''; |
| 1220 | - while (!feof($fp)) |
|
| 1221 | - $return_data .= fgets($fp, 128); |
|
| 1291 | + while (!feof($fp)) { |
|
| 1292 | + $return_data .= fgets($fp, 128); |
|
| 1293 | + } |
|
| 1222 | 1294 | |
| 1223 | 1295 | fclose($fp); |
| 1224 | 1296 | |
| 1225 | 1297 | // Get the unique site ID. |
| 1226 | 1298 | preg_match('~SITE-ID:\s(\w{10})~', $return_data, $ID); |
| 1227 | 1299 | |
| 1228 | - if (!empty($ID[1])) |
|
| 1229 | - $newSettings[] = array('allow_sm_stats', $ID[1]); |
|
| 1300 | + if (!empty($ID[1])) { |
|
| 1301 | + $newSettings[] = array('allow_sm_stats', $ID[1]); |
|
| 1302 | + } |
|
| 1230 | 1303 | } |
| 1231 | 1304 | } |
| 1232 | 1305 | |
| 1233 | 1306 | // Are we enabling SSL? |
| 1234 | - if (!empty($_POST['force_ssl'])) |
|
| 1235 | - $newSettings[] = array('force_ssl', 2); |
|
| 1307 | + if (!empty($_POST['force_ssl'])) { |
|
| 1308 | + $newSettings[] = array('force_ssl', 2); |
|
| 1309 | + } |
|
| 1236 | 1310 | |
| 1237 | 1311 | // Setting a timezone is required. |
| 1238 | 1312 | if (!isset($modSettings['default_timezone']) && function_exists('date_default_timezone_set')) |
| 1239 | 1313 | { |
| 1240 | 1314 | // Get PHP's default timezone, if set |
| 1241 | 1315 | $ini_tz = ini_get('date.timezone'); |
| 1242 | - if (!empty($ini_tz)) |
|
| 1243 | - $timezone_id = $ini_tz; |
|
| 1244 | - else |
|
| 1245 | - $timezone_id = ''; |
|
| 1316 | + if (!empty($ini_tz)) { |
|
| 1317 | + $timezone_id = $ini_tz; |
|
| 1318 | + } else { |
|
| 1319 | + $timezone_id = ''; |
|
| 1320 | + } |
|
| 1246 | 1321 | |
| 1247 | 1322 | // If date.timezone is unset, invalid, or just plain weird, make a best guess |
| 1248 | 1323 | if (!in_array($timezone_id, timezone_identifiers_list())) |
@@ -1251,8 +1326,9 @@ discard block |
||
| 1251 | 1326 | $timezone_id = timezone_name_from_abbr('', $server_offset, 0); |
| 1252 | 1327 | } |
| 1253 | 1328 | |
| 1254 | - if (date_default_timezone_set($timezone_id)) |
|
| 1255 | - $newSettings[] = array('default_timezone', $timezone_id); |
|
| 1329 | + if (date_default_timezone_set($timezone_id)) { |
|
| 1330 | + $newSettings[] = array('default_timezone', $timezone_id); |
|
| 1331 | + } |
|
| 1256 | 1332 | } |
| 1257 | 1333 | |
| 1258 | 1334 | if (!empty($newSettings)) |
@@ -1283,16 +1359,18 @@ discard block |
||
| 1283 | 1359 | } |
| 1284 | 1360 | |
| 1285 | 1361 | // MySQL specific stuff |
| 1286 | - if (substr($db_type, 0, 5) != 'mysql') |
|
| 1287 | - return false; |
|
| 1362 | + if (substr($db_type, 0, 5) != 'mysql') { |
|
| 1363 | + return false; |
|
| 1364 | + } |
|
| 1288 | 1365 | |
| 1289 | 1366 | // Find database user privileges. |
| 1290 | 1367 | $privs = array(); |
| 1291 | 1368 | $get_privs = $smcFunc['db_query']('', 'SHOW PRIVILEGES', array()); |
| 1292 | 1369 | while ($row = $smcFunc['db_fetch_assoc']($get_privs)) |
| 1293 | 1370 | { |
| 1294 | - if ($row['Privilege'] == 'Alter') |
|
| 1295 | - $privs[] = $row['Privilege']; |
|
| 1371 | + if ($row['Privilege'] == 'Alter') { |
|
| 1372 | + $privs[] = $row['Privilege']; |
|
| 1373 | + } |
|
| 1296 | 1374 | } |
| 1297 | 1375 | $smcFunc['db_free_result']($get_privs); |
| 1298 | 1376 | |
@@ -1322,8 +1400,9 @@ discard block |
||
| 1322 | 1400 | $incontext['continue'] = 1; |
| 1323 | 1401 | |
| 1324 | 1402 | // Skipping? |
| 1325 | - if (!empty($_POST['skip'])) |
|
| 1326 | - return true; |
|
| 1403 | + if (!empty($_POST['skip'])) { |
|
| 1404 | + return true; |
|
| 1405 | + } |
|
| 1327 | 1406 | |
| 1328 | 1407 | // Need this to check whether we need the database password. |
| 1329 | 1408 | require(dirname(__FILE__) . '/Settings.php'); |
@@ -1336,18 +1415,22 @@ discard block |
||
| 1336 | 1415 | // We need this to properly hash the password for Admin |
| 1337 | 1416 | $smcFunc['strtolower'] = $db_character_set != 'utf8' && $txt['lang_character_set'] != 'UTF-8' ? 'strtolower' : function($string) { |
| 1338 | 1417 | global $sourcedir; |
| 1339 | - if (function_exists('mb_strtolower')) |
|
| 1340 | - return mb_strtolower($string, 'UTF-8'); |
|
| 1418 | + if (function_exists('mb_strtolower')) { |
|
| 1419 | + return mb_strtolower($string, 'UTF-8'); |
|
| 1420 | + } |
|
| 1341 | 1421 | require_once($sourcedir . '/Subs-Charset.php'); |
| 1342 | 1422 | return utf8_strtolower($string); |
| 1343 | 1423 | }; |
| 1344 | 1424 | |
| 1345 | - if (!isset($_POST['username'])) |
|
| 1346 | - $_POST['username'] = ''; |
|
| 1347 | - if (!isset($_POST['email'])) |
|
| 1348 | - $_POST['email'] = ''; |
|
| 1349 | - if (!isset($_POST['server_email'])) |
|
| 1350 | - $_POST['server_email'] = ''; |
|
| 1425 | + if (!isset($_POST['username'])) { |
|
| 1426 | + $_POST['username'] = ''; |
|
| 1427 | + } |
|
| 1428 | + if (!isset($_POST['email'])) { |
|
| 1429 | + $_POST['email'] = ''; |
|
| 1430 | + } |
|
| 1431 | + if (!isset($_POST['server_email'])) { |
|
| 1432 | + $_POST['server_email'] = ''; |
|
| 1433 | + } |
|
| 1351 | 1434 | |
| 1352 | 1435 | $incontext['username'] = htmlspecialchars(stripslashes($_POST['username'])); |
| 1353 | 1436 | $incontext['email'] = htmlspecialchars(stripslashes($_POST['email'])); |
@@ -1366,8 +1449,9 @@ discard block |
||
| 1366 | 1449 | 'admin_group' => 1, |
| 1367 | 1450 | ) |
| 1368 | 1451 | ); |
| 1369 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
| 1370 | - $incontext['skip'] = 1; |
|
| 1452 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
| 1453 | + $incontext['skip'] = 1; |
|
| 1454 | + } |
|
| 1371 | 1455 | $smcFunc['db_free_result']($request); |
| 1372 | 1456 | |
| 1373 | 1457 | // Trying to create an account? |
@@ -1398,8 +1482,9 @@ discard block |
||
| 1398 | 1482 | } |
| 1399 | 1483 | |
| 1400 | 1484 | // Update the webmaster's email? |
| 1401 | - if (!empty($_POST['server_email']) && (empty($webmaster_email) || $webmaster_email == '[email protected]')) |
|
| 1402 | - updateSettingsFile(array('webmaster_email' => $_POST['server_email'])); |
|
| 1485 | + if (!empty($_POST['server_email']) && (empty($webmaster_email) || $webmaster_email == '[email protected]')) { |
|
| 1486 | + updateSettingsFile(array('webmaster_email' => $_POST['server_email'])); |
|
| 1487 | + } |
|
| 1403 | 1488 | |
| 1404 | 1489 | // Work out whether we're going to have dodgy characters and remove them. |
| 1405 | 1490 | $invalid_characters = preg_match('~[<>&"\'=\\\]~', $_POST['username']) != 0; |
@@ -1422,32 +1507,27 @@ discard block |
||
| 1422 | 1507 | $smcFunc['db_free_result']($result); |
| 1423 | 1508 | |
| 1424 | 1509 | $incontext['account_existed'] = $txt['error_user_settings_taken']; |
| 1425 | - } |
|
| 1426 | - elseif ($_POST['username'] == '' || strlen($_POST['username']) > 25) |
|
| 1510 | + } elseif ($_POST['username'] == '' || strlen($_POST['username']) > 25) |
|
| 1427 | 1511 | { |
| 1428 | 1512 | // Try the previous step again. |
| 1429 | 1513 | $incontext['error'] = $_POST['username'] == '' ? $txt['error_username_left_empty'] : $txt['error_username_too_long']; |
| 1430 | 1514 | return false; |
| 1431 | - } |
|
| 1432 | - elseif ($invalid_characters || $_POST['username'] == '_' || $_POST['username'] == '|' || strpos($_POST['username'], '[code') !== false || strpos($_POST['username'], '[/code') !== false) |
|
| 1515 | + } elseif ($invalid_characters || $_POST['username'] == '_' || $_POST['username'] == '|' || strpos($_POST['username'], '[code') !== false || strpos($_POST['username'], '[/code') !== false) |
|
| 1433 | 1516 | { |
| 1434 | 1517 | // Try the previous step again. |
| 1435 | 1518 | $incontext['error'] = $txt['error_invalid_characters_username']; |
| 1436 | 1519 | return false; |
| 1437 | - } |
|
| 1438 | - elseif (empty($_POST['email']) || !filter_var(stripslashes($_POST['email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['email'])) > 255) |
|
| 1520 | + } elseif (empty($_POST['email']) || !filter_var(stripslashes($_POST['email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['email'])) > 255) |
|
| 1439 | 1521 | { |
| 1440 | 1522 | // One step back, this time fill out a proper admin email address. |
| 1441 | 1523 | $incontext['error'] = sprintf($txt['error_valid_admin_email_needed'], $_POST['username']); |
| 1442 | 1524 | return false; |
| 1443 | - } |
|
| 1444 | - elseif (empty($_POST['server_email']) || !filter_var(stripslashes($_POST['server_email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['server_email'])) > 255) |
|
| 1525 | + } elseif (empty($_POST['server_email']) || !filter_var(stripslashes($_POST['server_email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['server_email'])) > 255) |
|
| 1445 | 1526 | { |
| 1446 | 1527 | // One step back, this time fill out a proper admin email address. |
| 1447 | 1528 | $incontext['error'] = $txt['error_valid_server_email_needed']; |
| 1448 | 1529 | return false; |
| 1449 | - } |
|
| 1450 | - elseif ($_POST['username'] != '') |
|
| 1530 | + } elseif ($_POST['username'] != '') |
|
| 1451 | 1531 | { |
| 1452 | 1532 | $incontext['member_salt'] = substr(md5(mt_rand()), 0, 4); |
| 1453 | 1533 | |
@@ -1513,17 +1593,19 @@ discard block |
||
| 1513 | 1593 | require_once($sourcedir . '/Subs-Auth.php'); |
| 1514 | 1594 | |
| 1515 | 1595 | // Bring a warning over. |
| 1516 | - if (!empty($incontext['account_existed'])) |
|
| 1517 | - $incontext['warning'] = $incontext['account_existed']; |
|
| 1596 | + if (!empty($incontext['account_existed'])) { |
|
| 1597 | + $incontext['warning'] = $incontext['account_existed']; |
|
| 1598 | + } |
|
| 1518 | 1599 | |
| 1519 | - if (!empty($db_character_set) && !empty($databases[$db_type]['utf8_support'])) |
|
| 1520 | - $smcFunc['db_query']('', ' |
|
| 1600 | + if (!empty($db_character_set) && !empty($databases[$db_type]['utf8_support'])) { |
|
| 1601 | + $smcFunc['db_query']('', ' |
|
| 1521 | 1602 | SET NAMES {string:db_character_set}', |
| 1522 | 1603 | array( |
| 1523 | 1604 | 'db_character_set' => $db_character_set, |
| 1524 | 1605 | 'db_error_skip' => true, |
| 1525 | 1606 | ) |
| 1526 | 1607 | ); |
| 1608 | + } |
|
| 1527 | 1609 | |
| 1528 | 1610 | // As track stats is by default enabled let's add some activity. |
| 1529 | 1611 | $smcFunc['db_insert']('ignore', |
@@ -1544,14 +1626,16 @@ discard block |
||
| 1544 | 1626 | // Only proceed if we can load the data. |
| 1545 | 1627 | if ($request) |
| 1546 | 1628 | { |
| 1547 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
| 1548 | - $modSettings[$row[0]] = $row[1]; |
|
| 1629 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
| 1630 | + $modSettings[$row[0]] = $row[1]; |
|
| 1631 | + } |
|
| 1549 | 1632 | $smcFunc['db_free_result']($request); |
| 1550 | 1633 | } |
| 1551 | 1634 | |
| 1552 | 1635 | // Automatically log them in ;) |
| 1553 | - if (isset($incontext['member_id']) && isset($incontext['member_salt'])) |
|
| 1554 | - setLoginCookie(3153600 * 60, $incontext['member_id'], hash_salt($_POST['password1'], $incontext['member_salt'])); |
|
| 1636 | + if (isset($incontext['member_id']) && isset($incontext['member_salt'])) { |
|
| 1637 | + setLoginCookie(3153600 * 60, $incontext['member_id'], hash_salt($_POST['password1'], $incontext['member_salt'])); |
|
| 1638 | + } |
|
| 1555 | 1639 | |
| 1556 | 1640 | $result = $smcFunc['db_query']('', ' |
| 1557 | 1641 | SELECT value |
@@ -1562,13 +1646,14 @@ discard block |
||
| 1562 | 1646 | 'db_error_skip' => true, |
| 1563 | 1647 | ) |
| 1564 | 1648 | ); |
| 1565 | - if ($smcFunc['db_num_rows']($result) != 0) |
|
| 1566 | - list ($db_sessions) = $smcFunc['db_fetch_row']($result); |
|
| 1649 | + if ($smcFunc['db_num_rows']($result) != 0) { |
|
| 1650 | + list ($db_sessions) = $smcFunc['db_fetch_row']($result); |
|
| 1651 | + } |
|
| 1567 | 1652 | $smcFunc['db_free_result']($result); |
| 1568 | 1653 | |
| 1569 | - if (empty($db_sessions)) |
|
| 1570 | - $_SESSION['admin_time'] = time(); |
|
| 1571 | - else |
|
| 1654 | + if (empty($db_sessions)) { |
|
| 1655 | + $_SESSION['admin_time'] = time(); |
|
| 1656 | + } else |
|
| 1572 | 1657 | { |
| 1573 | 1658 | $_SERVER['HTTP_USER_AGENT'] = substr($_SERVER['HTTP_USER_AGENT'], 0, 211); |
| 1574 | 1659 | |
@@ -1592,8 +1677,9 @@ discard block |
||
| 1592 | 1677 | $smcFunc['strtolower'] = $db_character_set != 'utf8' && $txt['lang_character_set'] != 'UTF-8' ? 'strtolower' : |
| 1593 | 1678 | function($string){ |
| 1594 | 1679 | global $sourcedir; |
| 1595 | - if (function_exists('mb_strtolower')) |
|
| 1596 | - return mb_strtolower($string, 'UTF-8'); |
|
| 1680 | + if (function_exists('mb_strtolower')) { |
|
| 1681 | + return mb_strtolower($string, 'UTF-8'); |
|
| 1682 | + } |
|
| 1597 | 1683 | require_once($sourcedir . '/Subs-Charset.php'); |
| 1598 | 1684 | return utf8_strtolower($string); |
| 1599 | 1685 | }; |
@@ -1609,8 +1695,9 @@ discard block |
||
| 1609 | 1695 | ) |
| 1610 | 1696 | ); |
| 1611 | 1697 | $context['utf8'] = $db_character_set === 'utf8' || $txt['lang_character_set'] === 'UTF-8'; |
| 1612 | - if ($smcFunc['db_num_rows']($request) > 0) |
|
| 1613 | - updateStats('subject', 1, htmlspecialchars($txt['default_topic_subject'])); |
|
| 1698 | + if ($smcFunc['db_num_rows']($request) > 0) { |
|
| 1699 | + updateStats('subject', 1, htmlspecialchars($txt['default_topic_subject'])); |
|
| 1700 | + } |
|
| 1614 | 1701 | $smcFunc['db_free_result']($request); |
| 1615 | 1702 | |
| 1616 | 1703 | // Now is the perfect time to fetch the SM files. |
@@ -1629,8 +1716,9 @@ discard block |
||
| 1629 | 1716 | |
| 1630 | 1717 | // Check if we need some stupid MySQL fix. |
| 1631 | 1718 | $server_version = $smcFunc['db_server_info'](); |
| 1632 | - if (($db_type == 'mysql' || $db_type == 'mysqli') && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) |
|
| 1633 | - updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
| 1719 | + if (($db_type == 'mysql' || $db_type == 'mysqli') && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) { |
|
| 1720 | + updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
| 1721 | + } |
|
| 1634 | 1722 | |
| 1635 | 1723 | // Some final context for the template. |
| 1636 | 1724 | $incontext['dir_still_writable'] = is_writable(dirname(__FILE__)) && substr(__FILE__, 1, 2) != ':\\'; |
@@ -1650,8 +1738,9 @@ discard block |
||
| 1650 | 1738 | $settingsArray = file(dirname(__FILE__) . '/Settings.php'); |
| 1651 | 1739 | |
| 1652 | 1740 | // @todo Do we just want to read the file in clean, and split it this way always? |
| 1653 | - if (count($settingsArray) == 1) |
|
| 1654 | - $settingsArray = preg_split('~[\r\n]~', $settingsArray[0]); |
|
| 1741 | + if (count($settingsArray) == 1) { |
|
| 1742 | + $settingsArray = preg_split('~[\r\n]~', $settingsArray[0]); |
|
| 1743 | + } |
|
| 1655 | 1744 | |
| 1656 | 1745 | for ($i = 0, $n = count($settingsArray); $i < $n; $i++) |
| 1657 | 1746 | { |
@@ -1666,19 +1755,22 @@ discard block |
||
| 1666 | 1755 | continue; |
| 1667 | 1756 | } |
| 1668 | 1757 | |
| 1669 | - if (trim($settingsArray[$i]) == '?' . '>') |
|
| 1670 | - $settingsArray[$i] = ''; |
|
| 1758 | + if (trim($settingsArray[$i]) == '?' . '>') { |
|
| 1759 | + $settingsArray[$i] = ''; |
|
| 1760 | + } |
|
| 1671 | 1761 | |
| 1672 | 1762 | // Don't trim or bother with it if it's not a variable. |
| 1673 | - if (substr($settingsArray[$i], 0, 1) != '$') |
|
| 1674 | - continue; |
|
| 1763 | + if (substr($settingsArray[$i], 0, 1) != '$') { |
|
| 1764 | + continue; |
|
| 1765 | + } |
|
| 1675 | 1766 | |
| 1676 | 1767 | $settingsArray[$i] = rtrim($settingsArray[$i]) . "\n"; |
| 1677 | 1768 | |
| 1678 | - foreach ($vars as $var => $val) |
|
| 1679 | - if (strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0) |
|
| 1769 | + foreach ($vars as $var => $val) { |
|
| 1770 | + if (strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0) |
|
| 1680 | 1771 | { |
| 1681 | 1772 | $comment = strstr($settingsArray[$i], '#'); |
| 1773 | + } |
|
| 1682 | 1774 | $settingsArray[$i] = '$' . $var . ' = \'' . $val . '\';' . ($comment != '' ? "\t\t" . $comment : "\n"); |
| 1683 | 1775 | unset($vars[$var]); |
| 1684 | 1776 | } |
@@ -1688,36 +1780,41 @@ discard block |
||
| 1688 | 1780 | if (!empty($vars)) |
| 1689 | 1781 | { |
| 1690 | 1782 | $settingsArray[$i++] = ''; |
| 1691 | - foreach ($vars as $var => $val) |
|
| 1692 | - $settingsArray[$i++] = '$' . $var . ' = \'' . $val . '\';' . "\n"; |
|
| 1783 | + foreach ($vars as $var => $val) { |
|
| 1784 | + $settingsArray[$i++] = '$' . $var . ' = \'' . $val . '\';' . "\n"; |
|
| 1785 | + } |
|
| 1693 | 1786 | } |
| 1694 | 1787 | |
| 1695 | 1788 | // Blank out the file - done to fix a oddity with some servers. |
| 1696 | 1789 | $fp = @fopen(dirname(__FILE__) . '/Settings.php', 'w'); |
| 1697 | - if (!$fp) |
|
| 1698 | - return false; |
|
| 1790 | + if (!$fp) { |
|
| 1791 | + return false; |
|
| 1792 | + } |
|
| 1699 | 1793 | fclose($fp); |
| 1700 | 1794 | |
| 1701 | 1795 | $fp = fopen(dirname(__FILE__) . '/Settings.php', 'r+'); |
| 1702 | 1796 | |
| 1703 | 1797 | // Gotta have one of these ;) |
| 1704 | - if (trim($settingsArray[0]) != '<?php') |
|
| 1705 | - fwrite($fp, "<?php\n"); |
|
| 1798 | + if (trim($settingsArray[0]) != '<?php') { |
|
| 1799 | + fwrite($fp, "<?php\n"); |
|
| 1800 | + } |
|
| 1706 | 1801 | |
| 1707 | 1802 | $lines = count($settingsArray); |
| 1708 | 1803 | for ($i = 0; $i < $lines - 1; $i++) |
| 1709 | 1804 | { |
| 1710 | 1805 | // Don't just write a bunch of blank lines. |
| 1711 | - if ($settingsArray[$i] != '' || @$settingsArray[$i - 1] != '') |
|
| 1712 | - fwrite($fp, strtr($settingsArray[$i], "\r", '')); |
|
| 1806 | + if ($settingsArray[$i] != '' || @$settingsArray[$i - 1] != '') { |
|
| 1807 | + fwrite($fp, strtr($settingsArray[$i], "\r", '')); |
|
| 1808 | + } |
|
| 1713 | 1809 | } |
| 1714 | 1810 | fwrite($fp, $settingsArray[$i] . '?' . '>'); |
| 1715 | 1811 | fclose($fp); |
| 1716 | 1812 | |
| 1717 | 1813 | // Even though on normal installations the filemtime should prevent this being used by the installer incorrectly |
| 1718 | 1814 | // it seems that there are times it might not. So let's MAKE it dump the cache. |
| 1719 | - if (function_exists('opcache_invalidate')) |
|
| 1720 | - opcache_invalidate(dirname(__FILE__) . '/Settings.php', true); |
|
| 1815 | + if (function_exists('opcache_invalidate')) { |
|
| 1816 | + opcache_invalidate(dirname(__FILE__) . '/Settings.php', true); |
|
| 1817 | + } |
|
| 1721 | 1818 | |
| 1722 | 1819 | return true; |
| 1723 | 1820 | } |
@@ -1742,9 +1839,9 @@ discard block |
||
| 1742 | 1839 | SecFilterScanPOST Off |
| 1743 | 1840 | </IfModule>'; |
| 1744 | 1841 | |
| 1745 | - if (!function_exists('apache_get_modules') || !in_array('mod_security', apache_get_modules())) |
|
| 1746 | - return true; |
|
| 1747 | - elseif (file_exists(dirname(__FILE__) . '/.htaccess') && is_writable(dirname(__FILE__) . '/.htaccess')) |
|
| 1842 | + if (!function_exists('apache_get_modules') || !in_array('mod_security', apache_get_modules())) { |
|
| 1843 | + return true; |
|
| 1844 | + } elseif (file_exists(dirname(__FILE__) . '/.htaccess') && is_writable(dirname(__FILE__) . '/.htaccess')) |
|
| 1748 | 1845 | { |
| 1749 | 1846 | $current_htaccess = implode('', file(dirname(__FILE__) . '/.htaccess')); |
| 1750 | 1847 | |
@@ -1756,29 +1853,28 @@ discard block |
||
| 1756 | 1853 | fwrite($ht_handle, $htaccess_addition); |
| 1757 | 1854 | fclose($ht_handle); |
| 1758 | 1855 | return true; |
| 1856 | + } else { |
|
| 1857 | + return false; |
|
| 1759 | 1858 | } |
| 1760 | - else |
|
| 1761 | - return false; |
|
| 1859 | + } else { |
|
| 1860 | + return true; |
|
| 1762 | 1861 | } |
| 1763 | - else |
|
| 1764 | - return true; |
|
| 1765 | - } |
|
| 1766 | - elseif (file_exists(dirname(__FILE__) . '/.htaccess')) |
|
| 1767 | - return strpos(implode('', file(dirname(__FILE__) . '/.htaccess')), '<IfModule mod_security.c>') !== false; |
|
| 1768 | - elseif (is_writable(dirname(__FILE__))) |
|
| 1862 | + } elseif (file_exists(dirname(__FILE__) . '/.htaccess')) { |
|
| 1863 | + return strpos(implode('', file(dirname(__FILE__) . '/.htaccess')), '<IfModule mod_security.c>') !== false; |
|
| 1864 | + } elseif (is_writable(dirname(__FILE__))) |
|
| 1769 | 1865 | { |
| 1770 | 1866 | if ($ht_handle = fopen(dirname(__FILE__) . '/.htaccess', 'w')) |
| 1771 | 1867 | { |
| 1772 | 1868 | fwrite($ht_handle, $htaccess_addition); |
| 1773 | 1869 | fclose($ht_handle); |
| 1774 | 1870 | return true; |
| 1871 | + } else { |
|
| 1872 | + return false; |
|
| 1775 | 1873 | } |
| 1776 | - else |
|
| 1874 | + } else { |
|
| 1777 | 1875 | return false; |
| 1778 | 1876 | } |
| 1779 | - else |
|
| 1780 | - return false; |
|
| 1781 | -} |
|
| 1877 | + } |
|
| 1782 | 1878 | |
| 1783 | 1879 | function template_install_above() |
| 1784 | 1880 | { |
@@ -1816,9 +1912,10 @@ discard block |
||
| 1816 | 1912 | <label for="installer_language">', $txt['installer_language'], ':</label> |
| 1817 | 1913 | <select id="installer_language" name="lang_file" onchange="location.href = \'', $installurl, '?lang_file=\' + this.options[this.selectedIndex].value;">'; |
| 1818 | 1914 | |
| 1819 | - foreach ($incontext['detected_languages'] as $lang => $name) |
|
| 1820 | - echo ' |
|
| 1915 | + foreach ($incontext['detected_languages'] as $lang => $name) { |
|
| 1916 | + echo ' |
|
| 1821 | 1917 | <option', isset($_SESSION['installer_temp_lang']) && $_SESSION['installer_temp_lang'] == $lang ? ' selected' : '', ' value="', $lang, '">', $name, '</option>'; |
| 1918 | + } |
|
| 1822 | 1919 | |
| 1823 | 1920 | echo ' |
| 1824 | 1921 | </select> |
@@ -1838,9 +1935,10 @@ discard block |
||
| 1838 | 1935 | <h2>', $txt['upgrade_progress'], '</h2> |
| 1839 | 1936 | <ul>'; |
| 1840 | 1937 | |
| 1841 | - foreach ($incontext['steps'] as $num => $step) |
|
| 1842 | - echo ' |
|
| 1938 | + foreach ($incontext['steps'] as $num => $step) { |
|
| 1939 | + echo ' |
|
| 1843 | 1940 | <li class="', $num < $incontext['current_step'] ? 'stepdone' : ($num == $incontext['current_step'] ? 'stepcurrent' : 'stepwaiting'), '">', $txt['upgrade_step'], ' ', $step[0], ': ', $step[1], '</li>'; |
| 1941 | + } |
|
| 1844 | 1942 | |
| 1845 | 1943 | echo ' |
| 1846 | 1944 | </ul> |
@@ -1865,20 +1963,23 @@ discard block |
||
| 1865 | 1963 | echo ' |
| 1866 | 1964 | <div>'; |
| 1867 | 1965 | |
| 1868 | - if (!empty($incontext['continue'])) |
|
| 1869 | - echo ' |
|
| 1966 | + if (!empty($incontext['continue'])) { |
|
| 1967 | + echo ' |
|
| 1870 | 1968 | <input type="submit" id="contbutt" name="contbutt" value="', $txt['upgrade_continue'], '" onclick="return submitThisOnce(this);" class="button_submit" />'; |
| 1871 | - if (!empty($incontext['skip'])) |
|
| 1872 | - echo ' |
|
| 1969 | + } |
|
| 1970 | + if (!empty($incontext['skip'])) { |
|
| 1971 | + echo ' |
|
| 1873 | 1972 | <input type="submit" id="skip" name="skip" value="', $txt['upgrade_skip'], '" onclick="return submitThisOnce(this);" class="button_submit" />'; |
| 1973 | + } |
|
| 1874 | 1974 | echo ' |
| 1875 | 1975 | </div>'; |
| 1876 | 1976 | } |
| 1877 | 1977 | |
| 1878 | 1978 | // Show the closing form tag and other data only if not in the last step |
| 1879 | - if (count($incontext['steps']) - 1 !== (int) $incontext['current_step']) |
|
| 1880 | - echo ' |
|
| 1979 | + if (count($incontext['steps']) - 1 !== (int) $incontext['current_step']) { |
|
| 1980 | + echo ' |
|
| 1881 | 1981 | </form>'; |
| 1982 | + } |
|
| 1882 | 1983 | |
| 1883 | 1984 | echo ' |
| 1884 | 1985 | </div> |
@@ -1913,13 +2014,15 @@ discard block |
||
| 1913 | 2014 | </div>'; |
| 1914 | 2015 | |
| 1915 | 2016 | // Show the warnings, or not. |
| 1916 | - if (template_warning_divs()) |
|
| 1917 | - echo ' |
|
| 2017 | + if (template_warning_divs()) { |
|
| 2018 | + echo ' |
|
| 1918 | 2019 | <h3>', $txt['install_all_lovely'], '</h3>'; |
| 2020 | + } |
|
| 1919 | 2021 | |
| 1920 | 2022 | // Say we want the continue button! |
| 1921 | - if (empty($incontext['error'])) |
|
| 1922 | - $incontext['continue'] = 1; |
|
| 2023 | + if (empty($incontext['error'])) { |
|
| 2024 | + $incontext['continue'] = 1; |
|
| 2025 | + } |
|
| 1923 | 2026 | |
| 1924 | 2027 | // For the latest version stuff. |
| 1925 | 2028 | echo ' |
@@ -1953,8 +2056,8 @@ discard block |
||
| 1953 | 2056 | global $txt, $incontext; |
| 1954 | 2057 | |
| 1955 | 2058 | // Errors are very serious.. |
| 1956 | - if (!empty($incontext['error'])) |
|
| 1957 | - echo ' |
|
| 2059 | + if (!empty($incontext['error'])) { |
|
| 2060 | + echo ' |
|
| 1958 | 2061 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
| 1959 | 2062 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
| 1960 | 2063 | <strong style="text-decoration: underline;">', $txt['upgrade_critical_error'], '</strong><br> |
@@ -1962,9 +2065,10 @@ discard block |
||
| 1962 | 2065 | ', $incontext['error'], ' |
| 1963 | 2066 | </div> |
| 1964 | 2067 | </div>'; |
| 2068 | + } |
|
| 1965 | 2069 | // A warning message? |
| 1966 | - elseif (!empty($incontext['warning'])) |
|
| 1967 | - echo ' |
|
| 2070 | + elseif (!empty($incontext['warning'])) { |
|
| 2071 | + echo ' |
|
| 1968 | 2072 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
| 1969 | 2073 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
| 1970 | 2074 | <strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br> |
@@ -1972,6 +2076,7 @@ discard block |
||
| 1972 | 2076 | ', $incontext['warning'], ' |
| 1973 | 2077 | </div> |
| 1974 | 2078 | </div>'; |
| 2079 | + } |
|
| 1975 | 2080 | |
| 1976 | 2081 | return empty($incontext['error']) && empty($incontext['warning']); |
| 1977 | 2082 | } |
@@ -1987,27 +2092,30 @@ discard block |
||
| 1987 | 2092 | <li>', $incontext['failed_files']), '</li> |
| 1988 | 2093 | </ul>'; |
| 1989 | 2094 | |
| 1990 | - if (isset($incontext['systemos'], $incontext['detected_path']) && $incontext['systemos'] == 'linux') |
|
| 1991 | - echo ' |
|
| 2095 | + if (isset($incontext['systemos'], $incontext['detected_path']) && $incontext['systemos'] == 'linux') { |
|
| 2096 | + echo ' |
|
| 1992 | 2097 | <hr> |
| 1993 | 2098 | <p>', $txt['chmod_linux_info'], '</p> |
| 1994 | 2099 | <tt># chmod a+w ', implode(' ' . $incontext['detected_path'] . '/', $incontext['failed_files']), '</tt>'; |
| 2100 | + } |
|
| 1995 | 2101 | |
| 1996 | 2102 | // This is serious! |
| 1997 | - if (!template_warning_divs()) |
|
| 1998 | - return; |
|
| 2103 | + if (!template_warning_divs()) { |
|
| 2104 | + return; |
|
| 2105 | + } |
|
| 1999 | 2106 | |
| 2000 | 2107 | echo ' |
| 2001 | 2108 | <hr> |
| 2002 | 2109 | <p>', $txt['ftp_setup_info'], '</p>'; |
| 2003 | 2110 | |
| 2004 | - if (!empty($incontext['ftp_errors'])) |
|
| 2005 | - echo ' |
|
| 2111 | + if (!empty($incontext['ftp_errors'])) { |
|
| 2112 | + echo ' |
|
| 2006 | 2113 | <div class="error_message"> |
| 2007 | 2114 | ', $txt['error_ftp_no_connect'], '<br><br> |
| 2008 | 2115 | <code>', implode('<br>', $incontext['ftp_errors']), '</code> |
| 2009 | 2116 | </div> |
| 2010 | 2117 | <br>'; |
| 2118 | + } |
|
| 2011 | 2119 | |
| 2012 | 2120 | echo ' |
| 2013 | 2121 | <form action="', $incontext['form_url'], '" method="post"> |
@@ -2067,17 +2175,17 @@ discard block |
||
| 2067 | 2175 | <td> |
| 2068 | 2176 | <select name="db_type" id="db_type_input" onchange="toggleDBInput();">'; |
| 2069 | 2177 | |
| 2070 | - foreach ($incontext['supported_databases'] as $key => $db) |
|
| 2071 | - echo ' |
|
| 2178 | + foreach ($incontext['supported_databases'] as $key => $db) { |
|
| 2179 | + echo ' |
|
| 2072 | 2180 | <option value="', $key, '"', isset($_POST['db_type']) && $_POST['db_type'] == $key ? ' selected' : '', '>', $db['name'], '</option>'; |
| 2181 | + } |
|
| 2073 | 2182 | |
| 2074 | 2183 | echo ' |
| 2075 | 2184 | </select> |
| 2076 | 2185 | <div class="smalltext block">', $txt['db_settings_type_info'], '</div> |
| 2077 | 2186 | </td> |
| 2078 | 2187 | </tr>'; |
| 2079 | - } |
|
| 2080 | - else |
|
| 2188 | + } else |
|
| 2081 | 2189 | { |
| 2082 | 2190 | echo ' |
| 2083 | 2191 | <tr style="display: none;"> |
@@ -2269,9 +2377,10 @@ discard block |
||
| 2269 | 2377 | <div style="color: red;">', $txt['error_db_queries'], '</div> |
| 2270 | 2378 | <ul>'; |
| 2271 | 2379 | |
| 2272 | - foreach ($incontext['failures'] as $line => $fail) |
|
| 2273 | - echo ' |
|
| 2380 | + foreach ($incontext['failures'] as $line => $fail) { |
|
| 2381 | + echo ' |
|
| 2274 | 2382 | <li><strong>', $txt['error_db_queries_line'], $line + 1, ':</strong> ', nl2br(htmlspecialchars($fail)), '</li>'; |
| 2383 | + } |
|
| 2275 | 2384 | |
| 2276 | 2385 | echo ' |
| 2277 | 2386 | </ul>'; |
@@ -2332,15 +2441,16 @@ discard block |
||
| 2332 | 2441 | </tr> |
| 2333 | 2442 | </table>'; |
| 2334 | 2443 | |
| 2335 | - if ($incontext['require_db_confirm']) |
|
| 2336 | - echo ' |
|
| 2444 | + if ($incontext['require_db_confirm']) { |
|
| 2445 | + echo ' |
|
| 2337 | 2446 | <h2>', $txt['user_settings_database'], '</h2> |
| 2338 | 2447 | <p>', $txt['user_settings_database_info'], '</p> |
| 2339 | 2448 | |
| 2340 | 2449 | <div style="margin-bottom: 2ex; padding-', $txt['lang_rtl'] == false ? 'left' : 'right', ': 50px;"> |
| 2341 | 2450 | <input type="password" name="password3" size="30" class="input_password" /> |
| 2342 | 2451 | </div>'; |
| 2343 | -} |
|
| 2452 | + } |
|
| 2453 | + } |
|
| 2344 | 2454 | |
| 2345 | 2455 | // Tell them it's done, and to delete. |
| 2346 | 2456 | function template_delete_install() |
@@ -2353,14 +2463,15 @@ discard block |
||
| 2353 | 2463 | template_warning_divs(); |
| 2354 | 2464 | |
| 2355 | 2465 | // Install directory still writable? |
| 2356 | - if ($incontext['dir_still_writable']) |
|
| 2357 | - echo ' |
|
| 2466 | + if ($incontext['dir_still_writable']) { |
|
| 2467 | + echo ' |
|
| 2358 | 2468 | <em>', $txt['still_writable'], '</em><br> |
| 2359 | 2469 | <br>'; |
| 2470 | + } |
|
| 2360 | 2471 | |
| 2361 | 2472 | // Don't show the box if it's like 99% sure it won't work :P. |
| 2362 | - if ($incontext['probably_delete_install']) |
|
| 2363 | - echo ' |
|
| 2473 | + if ($incontext['probably_delete_install']) { |
|
| 2474 | + echo ' |
|
| 2364 | 2475 | <div style="margin: 1ex; font-weight: bold;"> |
| 2365 | 2476 | <label for="delete_self"><input type="checkbox" id="delete_self" onclick="doTheDelete();" class="input_check" /> ', $txt['delete_installer'], !isset($_SESSION['installer_temp_ftp']) ? ' ' . $txt['delete_installer_maybe'] : '', '</label> |
| 2366 | 2477 | </div> |
@@ -2376,6 +2487,7 @@ discard block |
||
| 2376 | 2487 | } |
| 2377 | 2488 | </script> |
| 2378 | 2489 | <br>'; |
| 2490 | + } |
|
| 2379 | 2491 | |
| 2380 | 2492 | echo ' |
| 2381 | 2493 | ', sprintf($txt['go_to_your_forum'], $boardurl . '/index.php'), '<br> |
@@ -25,8 +25,9 @@ discard block |
||
| 25 | 25 | |
| 26 | 26 | // Get everything started up... |
| 27 | 27 | define('SMF', 1); |
| 28 | -if (function_exists('set_magic_quotes_runtime') && strnatcmp(phpversion(), '5.3.0') < 0) |
|
| 28 | +if (function_exists('set_magic_quotes_runtime') && strnatcmp(phpversion(), '5.3.0') < 0) { |
|
| 29 | 29 | @set_magic_quotes_runtime(0); |
| 30 | +} |
|
| 30 | 31 | error_reporting(defined('E_STRICT') ? E_ALL | E_STRICT : E_ALL); |
| 31 | 32 | $time_start = microtime(); |
| 32 | 33 | |
@@ -34,16 +35,18 @@ discard block |
||
| 34 | 35 | ob_start(); |
| 35 | 36 | |
| 36 | 37 | // Do some cleaning, just in case. |
| 37 | -foreach (array('db_character_set', 'cachedir') as $variable) |
|
| 38 | +foreach (array('db_character_set', 'cachedir') as $variable) { |
|
| 38 | 39 | if (isset($GLOBALS[$variable])) |
| 39 | 40 | unset($GLOBALS[$variable], $GLOBALS[$variable]); |
| 41 | +} |
|
| 40 | 42 | |
| 41 | 43 | // Load the settings... |
| 42 | 44 | require_once(dirname(__FILE__) . '/Settings.php'); |
| 43 | 45 | |
| 44 | 46 | // Make absolutely sure the cache directory is defined. |
| 45 | -if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache')) |
|
| 47 | +if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache')) { |
|
| 46 | 48 | $cachedir = $boarddir . '/cache'; |
| 49 | +} |
|
| 47 | 50 | |
| 48 | 51 | // Without those we can't go anywhere |
| 49 | 52 | require_once($sourcedir . '/QueryString.php'); |
@@ -53,8 +56,9 @@ discard block |
||
| 53 | 56 | require_once($sourcedir . '/Load.php'); |
| 54 | 57 | |
| 55 | 58 | // If $maintenance is set specifically to 2, then we're upgrading or something. |
| 56 | -if (!empty($maintenance) && $maintenance == 2) |
|
| 59 | +if (!empty($maintenance) && $maintenance == 2) { |
|
| 57 | 60 | display_maintenance_message(); |
| 61 | +} |
|
| 58 | 62 | |
| 59 | 63 | // Create a variable to store some SMF specific functions in. |
| 60 | 64 | $smcFunc = array(); |
@@ -69,8 +73,9 @@ discard block |
||
| 69 | 73 | cleanRequest(); |
| 70 | 74 | |
| 71 | 75 | // Seed the random generator. |
| 72 | -if (empty($modSettings['rand_seed']) || mt_rand(1, 250) == 69) |
|
| 76 | +if (empty($modSettings['rand_seed']) || mt_rand(1, 250) == 69) { |
|
| 73 | 77 | smf_seed_generator(); |
| 78 | +} |
|
| 74 | 79 | |
| 75 | 80 | // Before we get carried away, are we doing a scheduled task? If so save CPU cycles by jumping out! |
| 76 | 81 | if (isset($_GET['scheduled'])) |
@@ -90,9 +95,9 @@ discard block |
||
| 90 | 95 | if (!empty($modSettings['enableCompressedOutput']) && !headers_sent()) |
| 91 | 96 | { |
| 92 | 97 | // If zlib is being used, turn off output compression. |
| 93 | - if (ini_get('zlib.output_compression') >= 1 || ini_get('output_handler') == 'ob_gzhandler') |
|
| 94 | - $modSettings['enableCompressedOutput'] = '0'; |
|
| 95 | - else |
|
| 98 | + if (ini_get('zlib.output_compression') >= 1 || ini_get('output_handler') == 'ob_gzhandler') { |
|
| 99 | + $modSettings['enableCompressedOutput'] = '0'; |
|
| 100 | + } else |
|
| 96 | 101 | { |
| 97 | 102 | ob_end_clean(); |
| 98 | 103 | ob_start('ob_gzhandler'); |
@@ -141,18 +146,21 @@ discard block |
||
| 141 | 146 | loadPermissions(); |
| 142 | 147 | |
| 143 | 148 | // Attachments don't require the entire theme to be loaded. |
| 144 | - if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'dlattach') |
|
| 145 | - detectBrowser(); |
|
| 149 | + if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'dlattach') { |
|
| 150 | + detectBrowser(); |
|
| 151 | + } |
|
| 146 | 152 | // Load the current theme. (note that ?theme=1 will also work, may be used for guest theming.) |
| 147 | - else |
|
| 148 | - loadTheme(); |
|
| 153 | + else { |
|
| 154 | + loadTheme(); |
|
| 155 | + } |
|
| 149 | 156 | |
| 150 | 157 | // Check if the user should be disallowed access. |
| 151 | 158 | is_not_banned(); |
| 152 | 159 | |
| 153 | 160 | // If we are in a topic and don't have permission to approve it then duck out now. |
| 154 | - if (!empty($topic) && empty($board_info['cur_topic_approved']) && !allowedTo('approve_posts') && ($user_info['id'] != $board_info['cur_topic_starter'] || $user_info['is_guest'])) |
|
| 155 | - fatal_lang_error('not_a_topic', false); |
|
| 161 | + if (!empty($topic) && empty($board_info['cur_topic_approved']) && !allowedTo('approve_posts') && ($user_info['id'] != $board_info['cur_topic_starter'] || $user_info['is_guest'])) { |
|
| 162 | + fatal_lang_error('not_a_topic', false); |
|
| 163 | + } |
|
| 156 | 164 | |
| 157 | 165 | $no_stat_actions = array('clock', 'dlattach', 'findmember', 'jsoption', 'likes', 'loadeditorlocale', 'modifycat', 'requestmembers', 'smstats', 'suggest', 'about:unknown', '.xml', 'xmlhttp', 'verificationcode', 'viewquery', 'viewsmfile'); |
| 158 | 166 | call_integration_hook('integrate_pre_log_stats', array(&$no_stat_actions)); |
@@ -163,8 +171,9 @@ discard block |
||
| 163 | 171 | writeLog(); |
| 164 | 172 | |
| 165 | 173 | // Track forum statistics and hits...? |
| 166 | - if (!empty($modSettings['hitStats'])) |
|
| 167 | - trackStats(array('hits' => '+')); |
|
| 174 | + if (!empty($modSettings['hitStats'])) { |
|
| 175 | + trackStats(array('hits' => '+')); |
|
| 176 | + } |
|
| 168 | 177 | } |
| 169 | 178 | unset($no_stat_actions); |
| 170 | 179 | |
@@ -178,13 +187,14 @@ discard block |
||
| 178 | 187 | return ($_REQUEST['action'] == 'login2' ? 'Login2' : ($_REQUEST['action'] == 'logintfa' ? 'LoginTFA' : 'Logout')); |
| 179 | 188 | } |
| 180 | 189 | // Don't even try it, sonny. |
| 181 | - else |
|
| 182 | - return 'InMaintenance'; |
|
| 190 | + else { |
|
| 191 | + return 'InMaintenance'; |
|
| 192 | + } |
|
| 183 | 193 | } |
| 184 | 194 | // If guest access is off, a guest can only do one of the very few following actions. |
| 185 | - elseif (empty($modSettings['allow_guestAccess']) && $user_info['is_guest'] && (!isset($_REQUEST['action']) || !in_array($_REQUEST['action'], array('coppa', 'login', 'login2', 'logintfa', 'reminder', 'activate', 'help', 'helpadmin', 'smstats', 'verificationcode', 'signup', 'signup2')))) |
|
| 186 | - return 'KickGuest'; |
|
| 187 | - elseif (empty($_REQUEST['action'])) |
|
| 195 | + elseif (empty($modSettings['allow_guestAccess']) && $user_info['is_guest'] && (!isset($_REQUEST['action']) || !in_array($_REQUEST['action'], array('coppa', 'login', 'login2', 'logintfa', 'reminder', 'activate', 'help', 'helpadmin', 'smstats', 'verificationcode', 'signup', 'signup2')))) { |
|
| 196 | + return 'KickGuest'; |
|
| 197 | + } elseif (empty($_REQUEST['action'])) |
|
| 188 | 198 | { |
| 189 | 199 | // Action and board are both empty... BoardIndex! Unless someone else wants to do something different. |
| 190 | 200 | if (empty($board) && empty($topic)) |
@@ -200,8 +210,9 @@ discard block |
||
| 200 | 210 | |
| 201 | 211 | $call = call_helper($defaultAction, true); |
| 202 | 212 | |
| 203 | - if (!empty($call)) |
|
| 204 | - return $call; |
|
| 213 | + if (!empty($call)) { |
|
| 214 | + return $call; |
|
| 215 | + } |
|
| 205 | 216 | } |
| 206 | 217 | |
| 207 | 218 | // No default action huh? then go to our good old BoardIndex. |
@@ -331,8 +342,9 @@ discard block |
||
| 331 | 342 | |
| 332 | 343 | $call = call_helper($fallbackAction, true); |
| 333 | 344 | |
| 334 | - if (!empty($call)) |
|
| 335 | - return $call; |
|
| 345 | + if (!empty($call)) { |
|
| 346 | + return $call; |
|
| 347 | + } |
|
| 336 | 348 | } |
| 337 | 349 | |
| 338 | 350 | // No fallback action, huh? |
@@ -104,7 +104,7 @@ |
||
| 104 | 104 | * |
| 105 | 105 | * @param string $class The fully-qualified class name. |
| 106 | 106 | */ |
| 107 | -spl_autoload_register(function ($class) use ($sourcedir) |
|
| 107 | +spl_autoload_register(function($class) use ($sourcedir) |
|
| 108 | 108 | { |
| 109 | 109 | $classMap = array( |
| 110 | 110 | 'ReCaptcha\\' => 'ReCaptcha/', |
@@ -89,8 +89,9 @@ discard block |
||
| 89 | 89 | foreach ($section['areas'] as $i => $area) |
| 90 | 90 | { |
| 91 | 91 | // Not supposed to be printed? |
| 92 | - if (empty($area['label'])) |
|
| 93 | - continue; |
|
| 92 | + if (empty($area['label'])) { |
|
| 93 | + continue; |
|
| 94 | + } |
|
| 94 | 95 | |
| 95 | 96 | echo ' |
| 96 | 97 | <li', !empty($area['subsections']) ? ' class="subsections"' : '', '>'; |
@@ -99,8 +100,9 @@ discard block |
||
| 99 | 100 | <a class="', $area['icon_class'], !empty($area['selected']) ? ' chosen ' : '', '" href="', (isset($area['url']) ? $area['url'] : $menu_context['base_url'] . ';area=' . $i), $menu_context['extra_parameters'], '">', $area['icon'], $area['label'], '</a>'; |
| 100 | 101 | |
| 101 | 102 | // Is this the current area, or just some area? |
| 102 | - if (!empty($area['selected']) && empty($context['tabs'])) |
|
| 103 | - $context['tabs'] = isset($area['subsections']) ? $area['subsections'] : array(); |
|
| 103 | + if (!empty($area['selected']) && empty($context['tabs'])) { |
|
| 104 | + $context['tabs'] = isset($area['subsections']) ? $area['subsections'] : array(); |
|
| 105 | + } |
|
| 104 | 106 | |
| 105 | 107 | // Are there any subsections? |
| 106 | 108 | if (!empty($area['subsections'])) |
@@ -110,8 +112,9 @@ discard block |
||
| 110 | 112 | |
| 111 | 113 | foreach ($area['subsections'] as $sa => $sub) |
| 112 | 114 | { |
| 113 | - if (!empty($sub['disabled'])) |
|
| 114 | - continue; |
|
| 115 | + if (!empty($sub['disabled'])) { |
|
| 116 | + continue; |
|
| 117 | + } |
|
| 115 | 118 | |
| 116 | 119 | $url = isset($sub['url']) ? $sub['url'] : (isset($area['url']) ? $area['url'] : $menu_context['base_url'] . ';area=' . $i) . ';sa=' . $sa; |
| 117 | 120 | |
@@ -158,8 +161,9 @@ discard block |
||
| 158 | 161 | <h3 class="catbg">'; |
| 159 | 162 | |
| 160 | 163 | // The function is in Admin.template.php, but since this template is used elsewhere too better check if the function is available |
| 161 | - if (function_exists('template_admin_quick_search')) |
|
| 162 | - template_admin_quick_search(); |
|
| 164 | + if (function_exists('template_admin_quick_search')) { |
|
| 165 | + template_admin_quick_search(); |
|
| 166 | + } |
|
| 163 | 167 | |
| 164 | 168 | // Exactly how many tabs do we have? |
| 165 | 169 | if (!empty($context['tabs'])) |
@@ -174,30 +178,36 @@ discard block |
||
| 174 | 178 | } |
| 175 | 179 | |
| 176 | 180 | // Did this not even exist - or do we not have a label? |
| 177 | - if (!isset($tab_context['tabs'][$id])) |
|
| 178 | - $tab_context['tabs'][$id] = array('label' => $tab['label']); |
|
| 179 | - elseif (!isset($tab_context['tabs'][$id]['label'])) |
|
| 180 | - $tab_context['tabs'][$id]['label'] = $tab['label']; |
|
| 181 | + if (!isset($tab_context['tabs'][$id])) { |
|
| 182 | + $tab_context['tabs'][$id] = array('label' => $tab['label']); |
|
| 183 | + } elseif (!isset($tab_context['tabs'][$id]['label'])) { |
|
| 184 | + $tab_context['tabs'][$id]['label'] = $tab['label']; |
|
| 185 | + } |
|
| 181 | 186 | |
| 182 | 187 | // Has a custom URL defined in the main admin structure? |
| 183 | - if (isset($tab['url']) && !isset($tab_context['tabs'][$id]['url'])) |
|
| 184 | - $tab_context['tabs'][$id]['url'] = $tab['url']; |
|
| 188 | + if (isset($tab['url']) && !isset($tab_context['tabs'][$id]['url'])) { |
|
| 189 | + $tab_context['tabs'][$id]['url'] = $tab['url']; |
|
| 190 | + } |
|
| 185 | 191 | |
| 186 | 192 | // Any additional paramaters for the url? |
| 187 | - if (isset($tab['add_params']) && !isset($tab_context['tabs'][$id]['add_params'])) |
|
| 188 | - $tab_context['tabs'][$id]['add_params'] = $tab['add_params']; |
|
| 193 | + if (isset($tab['add_params']) && !isset($tab_context['tabs'][$id]['add_params'])) { |
|
| 194 | + $tab_context['tabs'][$id]['add_params'] = $tab['add_params']; |
|
| 195 | + } |
|
| 189 | 196 | |
| 190 | 197 | // Has it been deemed selected? |
| 191 | - if (!empty($tab['is_selected'])) |
|
| 192 | - $tab_context['tabs'][$id]['is_selected'] = true; |
|
| 198 | + if (!empty($tab['is_selected'])) { |
|
| 199 | + $tab_context['tabs'][$id]['is_selected'] = true; |
|
| 200 | + } |
|
| 193 | 201 | |
| 194 | 202 | // Does it have its own help? |
| 195 | - if (!empty($tab['help'])) |
|
| 196 | - $tab_context['tabs'][$id]['help'] = $tab['help']; |
|
| 203 | + if (!empty($tab['help'])) { |
|
| 204 | + $tab_context['tabs'][$id]['help'] = $tab['help']; |
|
| 205 | + } |
|
| 197 | 206 | |
| 198 | 207 | // Is this the last one? |
| 199 | - if (!empty($tab['is_last']) && !isset($tab_context['override_last'])) |
|
| 200 | - $tab_context['tabs'][$id]['is_last'] = true; |
|
| 208 | + if (!empty($tab['is_last']) && !isset($tab_context['override_last'])) { |
|
| 209 | + $tab_context['tabs'][$id]['is_last'] = true; |
|
| 210 | + } |
|
| 201 | 211 | } |
| 202 | 212 | |
| 203 | 213 | // Find the selected tab |
@@ -214,17 +224,18 @@ discard block |
||
| 214 | 224 | // Show an icon and/or a help item? |
| 215 | 225 | if (!empty($selected_tab['icon_class']) || !empty($tab_context['icon_class']) || !empty($selected_tab['icon']) || !empty($tab_context['icon']) || !empty($selected_tab['help']) || !empty($tab_context['help'])) |
| 216 | 226 | { |
| 217 | - if (!empty($selected_tab['icon_class']) || !empty($tab_context['icon_class'])) |
|
| 218 | - echo '<span class="', !empty($selected_tab['icon_class']) ? $selected_tab['icon_class'] : $tab_context['icon_class'], ' icon"></span>'; |
|
| 219 | - elseif (!empty($selected_tab['icon']) || !empty($tab_context['icon'])) |
|
| 220 | - echo '<img src="', $settings['images_url'], '/icons/', !empty($selected_tab['icon']) ? $selected_tab['icon'] : $tab_context['icon'], '" alt="" class="icon">'; |
|
| 227 | + if (!empty($selected_tab['icon_class']) || !empty($tab_context['icon_class'])) { |
|
| 228 | + echo '<span class="', !empty($selected_tab['icon_class']) ? $selected_tab['icon_class'] : $tab_context['icon_class'], ' icon"></span>'; |
|
| 229 | + } elseif (!empty($selected_tab['icon']) || !empty($tab_context['icon'])) { |
|
| 230 | + echo '<img src="', $settings['images_url'], '/icons/', !empty($selected_tab['icon']) ? $selected_tab['icon'] : $tab_context['icon'], '" alt="" class="icon">'; |
|
| 231 | + } |
|
| 221 | 232 | |
| 222 | - if (!empty($selected_tab['help']) || !empty($tab_context['help'])) |
|
| 223 | - echo '<a href="', $scripturl, '?action=helpadmin;help=', !empty($selected_tab['help']) ? $selected_tab['help'] : $tab_context['help'], '" onclick="return reqOverlayDiv(this.href);" class="help"><span class="generic_icons help" title="', $txt['help'], '"></span></a>'; |
|
| 233 | + if (!empty($selected_tab['help']) || !empty($tab_context['help'])) { |
|
| 234 | + echo '<a href="', $scripturl, '?action=helpadmin;help=', !empty($selected_tab['help']) ? $selected_tab['help'] : $tab_context['help'], '" onclick="return reqOverlayDiv(this.href);" class="help"><span class="generic_icons help" title="', $txt['help'], '"></span></a>'; |
|
| 235 | + } |
|
| 224 | 236 | |
| 225 | 237 | echo $tab_context['title']; |
| 226 | - } |
|
| 227 | - else |
|
| 238 | + } else |
|
| 228 | 239 | { |
| 229 | 240 | echo ' |
| 230 | 241 | ', $tab_context['title']; |
@@ -237,11 +248,12 @@ discard block |
||
| 237 | 248 | } |
| 238 | 249 | |
| 239 | 250 | // Shall we use the tabs? Yes, it's the only known way! |
| 240 | - if (!empty($selected_tab['description']) || !empty($tab_context['description'])) |
|
| 241 | - echo ' |
|
| 251 | + if (!empty($selected_tab['description']) || !empty($tab_context['description'])) { |
|
| 252 | + echo ' |
|
| 242 | 253 | <p class="information"> |
| 243 | 254 | ', !empty($selected_tab['description']) ? $selected_tab['description'] : $tab_context['description'], ' |
| 244 | 255 | </p>'; |
| 256 | + } |
|
| 245 | 257 | |
| 246 | 258 | // Print out all the items in this tab (if any). |
| 247 | 259 | if (!empty($context['tabs'])) |
@@ -253,8 +265,9 @@ discard block |
||
| 253 | 265 | |
| 254 | 266 | foreach ($tab_context['tabs'] as $sa => $tab) |
| 255 | 267 | { |
| 256 | - if (!empty($tab['disabled'])) |
|
| 257 | - continue; |
|
| 268 | + if (!empty($tab['disabled'])) { |
|
| 269 | + continue; |
|
| 270 | + } |
|
| 258 | 271 | |
| 259 | 272 | if (!empty($tab['is_selected'])) |
| 260 | 273 | { |
@@ -262,12 +275,12 @@ discard block |
||
| 262 | 275 | <li> |
| 263 | 276 | <a class="active" href="', isset($tab['url']) ? $tab['url'] : $menu_context['base_url'] . ';area=' . $menu_context['current_area'] . ';sa=' . $sa, $menu_context['extra_parameters'], isset($tab['add_params']) ? $tab['add_params'] : '', '">', $tab['label'], '</a> |
| 264 | 277 | </li>'; |
| 265 | - } |
|
| 266 | - else |
|
| 267 | - echo ' |
|
| 278 | + } else { |
|
| 279 | + echo ' |
|
| 268 | 280 | <li> |
| 269 | 281 | <a href="', isset($tab['url']) ? $tab['url'] : $menu_context['base_url'] . ';area=' . $menu_context['current_area'] . ';sa=' . $sa, $menu_context['extra_parameters'], isset($tab['add_params']) ? $tab['add_params'] : '', '">', $tab['label'], '</a> |
| 270 | 282 | </li>'; |
| 283 | + } |
|
| 271 | 284 | } |
| 272 | 285 | |
| 273 | 286 | // the end of tabs |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 3 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * Entry point function, permission checks, admin bars, etc. |
@@ -99,27 +100,27 @@ discard block |
||
| 99 | 100 | 'function' => function($rowData) use ($scripturl) |
| 100 | 101 | { |
| 101 | 102 | // Since the moderator group has no explicit members, no link is needed. |
| 102 | - if ($rowData['id_group'] == 3) |
|
| 103 | - $group_name = $rowData['group_name']; |
|
| 104 | - else |
|
| 103 | + if ($rowData['id_group'] == 3) { |
|
| 104 | + $group_name = $rowData['group_name']; |
|
| 105 | + } else |
|
| 105 | 106 | { |
| 106 | 107 | $color_style = empty($rowData['online_color']) ? '' : sprintf(' style="color: %1$s;"', $rowData['online_color']); |
| 107 | 108 | |
| 108 | 109 | if (allowedTo('manage_membergroups')) |
| 109 | 110 | { |
| 110 | 111 | $group_name = sprintf('<a href="%1$s?action=admin;area=membergroups;sa=members;group=%2$d"%3$s>%4$s</a>', $scripturl, $rowData['id_group'], $color_style, $rowData['group_name']); |
| 111 | - } |
|
| 112 | - else |
|
| 112 | + } else |
|
| 113 | 113 | { |
| 114 | 114 | $group_name = sprintf('<a href="%1$s?action=groups;sa=members;group=%2$d"%3$s>%4$s</a>', $scripturl, $rowData['id_group'], $color_style, $rowData['group_name']); |
| 115 | 115 | } |
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | // Add a help option for moderator and administrator. |
| 119 | - if ($rowData['id_group'] == 1) |
|
| 120 | - $group_name .= sprintf(' (<a href="%1$s?action=helpadmin;help=membergroup_administrator" onclick="return reqOverlayDiv(this.href);">?</a>)', $scripturl); |
|
| 121 | - elseif ($rowData['id_group'] == 3) |
|
| 122 | - $group_name .= sprintf(' (<a href="%1$s?action=helpadmin;help=membergroup_moderator" onclick="return reqOverlayDiv(this.href);">?</a>)', $scripturl); |
|
| 119 | + if ($rowData['id_group'] == 1) { |
|
| 120 | + $group_name .= sprintf(' (<a href="%1$s?action=helpadmin;help=membergroup_administrator" onclick="return reqOverlayDiv(this.href);">?</a>)', $scripturl); |
|
| 121 | + } elseif ($rowData['id_group'] == 3) { |
|
| 122 | + $group_name .= sprintf(' (<a href="%1$s?action=helpadmin;help=membergroup_moderator" onclick="return reqOverlayDiv(this.href);">?</a>)', $scripturl); |
|
| 123 | + } |
|
| 123 | 124 | |
| 124 | 125 | return $group_name; |
| 125 | 126 | }, |
@@ -198,8 +199,9 @@ discard block |
||
| 198 | 199 | $_REQUEST['group'] = isset($_REQUEST['group']) ? (int) $_REQUEST['group'] : 0; |
| 199 | 200 | |
| 200 | 201 | // No browsing of guests, membergroup 0 or moderators. |
| 201 | - if (in_array($_REQUEST['group'], array(-1, 0, 3))) |
|
| 202 | - fatal_lang_error('membergroup_does_not_exist', false); |
|
| 202 | + if (in_array($_REQUEST['group'], array(-1, 0, 3))) { |
|
| 203 | + fatal_lang_error('membergroup_does_not_exist', false); |
|
| 204 | + } |
|
| 203 | 205 | |
| 204 | 206 | // Load up the group details. |
| 205 | 207 | $request = $smcFunc['db_query']('', ' |
@@ -214,8 +216,9 @@ discard block |
||
| 214 | 216 | ) |
| 215 | 217 | ); |
| 216 | 218 | // Doesn't exist? |
| 217 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 218 | - fatal_lang_error('membergroup_does_not_exist', false); |
|
| 219 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 220 | + fatal_lang_error('membergroup_does_not_exist', false); |
|
| 221 | + } |
|
| 219 | 222 | $context['group'] = $smcFunc['db_fetch_assoc']($request); |
| 220 | 223 | $smcFunc['db_free_result']($request); |
| 221 | 224 | |
@@ -248,21 +251,25 @@ discard block |
||
| 248 | 251 | 'name' => $row['real_name'] |
| 249 | 252 | ); |
| 250 | 253 | |
| 251 | - if ($user_info['id'] == $row['id_member'] && $context['group']['group_type'] != 1) |
|
| 252 | - $context['group']['can_moderate'] = true; |
|
| 254 | + if ($user_info['id'] == $row['id_member'] && $context['group']['group_type'] != 1) { |
|
| 255 | + $context['group']['can_moderate'] = true; |
|
| 256 | + } |
|
| 253 | 257 | } |
| 254 | 258 | $smcFunc['db_free_result']($request); |
| 255 | 259 | |
| 256 | 260 | // If this group is hidden then it can only "exists" if the user can moderate it! |
| 257 | - if ($context['group']['hidden'] && !$context['group']['can_moderate']) |
|
| 258 | - fatal_lang_error('membergroup_does_not_exist', false); |
|
| 261 | + if ($context['group']['hidden'] && !$context['group']['can_moderate']) { |
|
| 262 | + fatal_lang_error('membergroup_does_not_exist', false); |
|
| 263 | + } |
|
| 259 | 264 | |
| 260 | 265 | // You can only assign membership if you are the moderator and/or can manage groups! |
| 261 | - if (!$context['group']['can_moderate']) |
|
| 262 | - $context['group']['assignable'] = 0; |
|
| 266 | + if (!$context['group']['can_moderate']) { |
|
| 267 | + $context['group']['assignable'] = 0; |
|
| 268 | + } |
|
| 263 | 269 | // Non-admins cannot assign admins. |
| 264 | - elseif ($context['group']['id'] == 1 && !allowedTo('admin_forum')) |
|
| 265 | - $context['group']['assignable'] = 0; |
|
| 270 | + elseif ($context['group']['id'] == 1 && !allowedTo('admin_forum')) { |
|
| 271 | + $context['group']['assignable'] = 0; |
|
| 272 | + } |
|
| 266 | 273 | |
| 267 | 274 | // Removing member from group? |
| 268 | 275 | if (isset($_POST['remove']) && !empty($_REQUEST['rem']) && is_array($_REQUEST['rem']) && $context['group']['assignable']) |
@@ -271,8 +278,9 @@ discard block |
||
| 271 | 278 | validateToken('mod-mgm'); |
| 272 | 279 | |
| 273 | 280 | // Make sure we're dealing with integers only. |
| 274 | - foreach ($_REQUEST['rem'] as $key => $group) |
|
| 275 | - $_REQUEST['rem'][$key] = (int) $group; |
|
| 281 | + foreach ($_REQUEST['rem'] as $key => $group) { |
|
| 282 | + $_REQUEST['rem'][$key] = (int) $group; |
|
| 283 | + } |
|
| 276 | 284 | |
| 277 | 285 | require_once($sourcedir . '/Subs-Membergroups.php'); |
| 278 | 286 | removeMembersFromGroups($_REQUEST['rem'], $_REQUEST['group'], true); |
@@ -295,16 +303,18 @@ discard block |
||
| 295 | 303 | { |
| 296 | 304 | $member_names[$index] = trim($smcFunc['strtolower']($member_names[$index])); |
| 297 | 305 | |
| 298 | - if (strlen($member_names[$index]) == 0) |
|
| 299 | - unset($member_names[$index]); |
|
| 306 | + if (strlen($member_names[$index]) == 0) { |
|
| 307 | + unset($member_names[$index]); |
|
| 308 | + } |
|
| 300 | 309 | } |
| 301 | 310 | |
| 302 | 311 | // Any passed by ID? |
| 303 | 312 | $member_ids = array(); |
| 304 | - if (!empty($_REQUEST['member_add'])) |
|
| 305 | - foreach ($_REQUEST['member_add'] as $id) |
|
| 313 | + if (!empty($_REQUEST['member_add'])) { |
|
| 314 | + foreach ($_REQUEST['member_add'] as $id) |
|
| 306 | 315 | if ($id > 0) |
| 307 | 316 | $member_ids[] = (int) $id; |
| 317 | + } |
|
| 308 | 318 | |
| 309 | 319 | // Construct the query pelements. |
| 310 | 320 | if (!empty($member_ids)) |
@@ -332,8 +342,9 @@ discard block |
||
| 332 | 342 | 'id_group' => $_REQUEST['group'], |
| 333 | 343 | )) |
| 334 | 344 | ); |
| 335 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 336 | - $members[] = $row['id_member']; |
|
| 345 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 346 | + $members[] = $row['id_member']; |
|
| 347 | + } |
|
| 337 | 348 | $smcFunc['db_free_result']($request); |
| 338 | 349 | } |
| 339 | 350 | |
@@ -372,10 +383,11 @@ discard block |
||
| 372 | 383 | $context['sort_direction'] = isset($_REQUEST['desc']) ? 'down' : 'up'; |
| 373 | 384 | |
| 374 | 385 | // The where on the query is interesting. Non-moderators should only see people who are in this group as primary. |
| 375 | - if ($context['group']['can_moderate']) |
|
| 376 | - $where = $context['group']['is_post_group'] ? 'id_post_group = {int:group}' : 'id_group = {int:group} OR FIND_IN_SET({int:group}, additional_groups) != 0'; |
|
| 377 | - else |
|
| 378 | - $where = $context['group']['is_post_group'] ? 'id_post_group = {int:group}' : 'id_group = {int:group}'; |
|
| 386 | + if ($context['group']['can_moderate']) { |
|
| 387 | + $where = $context['group']['is_post_group'] ? 'id_post_group = {int:group}' : 'id_group = {int:group} OR FIND_IN_SET({int:group}, additional_groups) != 0'; |
|
| 388 | + } else { |
|
| 389 | + $where = $context['group']['is_post_group'] ? 'id_post_group = {int:group}' : 'id_group = {int:group}'; |
|
| 390 | + } |
|
| 379 | 391 | |
| 380 | 392 | // Count members of the group. |
| 381 | 393 | $request = $smcFunc['db_query']('', ' |
@@ -416,8 +428,9 @@ discard block |
||
| 416 | 428 | $last_online = empty($row['last_login']) ? $txt['never'] : timeformat($row['last_login']); |
| 417 | 429 | |
| 418 | 430 | // Italicize the online note if they aren't activated. |
| 419 | - if ($row['is_activated'] % 10 != 1) |
|
| 420 | - $last_online = '<em title="' . $txt['not_activated'] . '">' . $last_online . '</em>'; |
|
| 431 | + if ($row['is_activated'] % 10 != 1) { |
|
| 432 | + $last_online = '<em title="' . $txt['not_activated'] . '">' . $last_online . '</em>'; |
|
| 433 | + } |
|
| 421 | 434 | |
| 422 | 435 | $context['members'][] = array( |
| 423 | 436 | 'id' => $row['id_member'], |
@@ -437,9 +450,10 @@ discard block |
||
| 437 | 450 | $context['page_title'] = $txt['membergroups_members_title'] . ': ' . $context['group']['name']; |
| 438 | 451 | createToken('mod-mgm'); |
| 439 | 452 | |
| 440 | - if ($context['group']['assignable']) |
|
| 441 | - loadJavaScriptFile('suggest.js', array('defer' => false), 'smf_suggest'); |
|
| 442 | -} |
|
| 453 | + if ($context['group']['assignable']) { |
|
| 454 | + loadJavaScriptFile('suggest.js', array('defer' => false), 'smf_suggest'); |
|
| 455 | + } |
|
| 456 | + } |
|
| 443 | 457 | |
| 444 | 458 | /** |
| 445 | 459 | * Show and manage all group requests. |
@@ -453,16 +467,18 @@ discard block |
||
| 453 | 467 | $context['sub_template'] = 'show_list'; |
| 454 | 468 | |
| 455 | 469 | // Verify we can be here. |
| 456 | - if ($user_info['mod_cache']['gq'] == '0=1') |
|
| 457 | - isAllowedTo('manage_membergroups'); |
|
| 470 | + if ($user_info['mod_cache']['gq'] == '0=1') { |
|
| 471 | + isAllowedTo('manage_membergroups'); |
|
| 472 | + } |
|
| 458 | 473 | |
| 459 | 474 | // Normally, we act normally... |
| 460 | 475 | $where = ($user_info['mod_cache']['gq'] == '1=1' || $user_info['mod_cache']['gq'] == '0=1' ? $user_info['mod_cache']['gq'] : 'lgr.' . $user_info['mod_cache']['gq']); |
| 461 | 476 | |
| 462 | - if (isset($_GET['closed'])) |
|
| 463 | - $where .= ' AND lgr.status != {int:status_open}'; |
|
| 464 | - else |
|
| 465 | - $where .= ' AND lgr.status = {int:status_open}'; |
|
| 477 | + if (isset($_GET['closed'])) { |
|
| 478 | + $where .= ' AND lgr.status != {int:status_open}'; |
|
| 479 | + } else { |
|
| 480 | + $where .= ' AND lgr.status = {int:status_open}'; |
|
| 481 | + } |
|
| 466 | 482 | |
| 467 | 483 | $where_parameters = array( |
| 468 | 484 | 'status_open' => 0, |
@@ -475,8 +491,9 @@ discard block |
||
| 475 | 491 | validateToken('mod-gr'); |
| 476 | 492 | |
| 477 | 493 | // Clean the values. |
| 478 | - foreach ($_POST['groupr'] as $k => $request) |
|
| 479 | - $_POST['groupr'][$k] = (int) $request; |
|
| 494 | + foreach ($_POST['groupr'] as $k => $request) { |
|
| 495 | + $_POST['groupr'][$k] = (int) $request; |
|
| 496 | + } |
|
| 480 | 497 | |
| 481 | 498 | $log_changes = array(); |
| 482 | 499 | |
@@ -513,8 +530,8 @@ discard block |
||
| 513 | 530 | $request_list = array(); |
| 514 | 531 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 515 | 532 | { |
| 516 | - if (!isset($log_changes[$row['id_request']])) |
|
| 517 | - $log_changes[$row['id_request']] = array( |
|
| 533 | + if (!isset($log_changes[$row['id_request']])) { |
|
| 534 | + $log_changes[$row['id_request']] = array( |
|
| 518 | 535 | 'id_request' => $row['id_request'], |
| 519 | 536 | 'status' => $_POST['req_action'] == 'approve' ? 1 : 2, // 1 = approved, 2 = rejected |
| 520 | 537 | 'id_member_acted' => $user_info['id'], |
@@ -522,6 +539,7 @@ discard block |
||
| 522 | 539 | 'time_acted' => time(), |
| 523 | 540 | 'act_reason' => $_POST['req_action'] != 'approve' && !empty($_POST['groupreason']) && !empty($_POST['groupreason'][$row['id_request']]) ? $smcFunc['htmlspecialchars']($_POST['groupreason'][$row['id_request']], ENT_QUOTES) : '', |
| 524 | 541 | ); |
| 542 | + } |
|
| 525 | 543 | $request_list[] = $row['id_request']; |
| 526 | 544 | } |
| 527 | 545 | $smcFunc['db_free_result']($request); |
@@ -744,21 +762,24 @@ discard block |
||
| 744 | 762 | $group_requests = array(); |
| 745 | 763 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 746 | 764 | { |
| 747 | - if (empty($row['reason'])) |
|
| 748 | - $reason = '<em>(' . $txt['mc_groupr_no_reason'] . ')</em>'; |
|
| 749 | - else |
|
| 750 | - $reason = censorText($row['reason']); |
|
| 765 | + if (empty($row['reason'])) { |
|
| 766 | + $reason = '<em>(' . $txt['mc_groupr_no_reason'] . ')</em>'; |
|
| 767 | + } else { |
|
| 768 | + $reason = censorText($row['reason']); |
|
| 769 | + } |
|
| 751 | 770 | |
| 752 | 771 | if (isset($_GET['closed'])) |
| 753 | 772 | { |
| 754 | - if ($row['status'] == 1) |
|
| 755 | - $reason .= '<br><br><strong>' . $txt['mc_groupr_approved'] . '</strong>'; |
|
| 756 | - elseif ($row['status'] == 2) |
|
| 757 | - $reason .= '<br><br><strong>' . $txt['mc_groupr_rejected'] . '</strong>'; |
|
| 773 | + if ($row['status'] == 1) { |
|
| 774 | + $reason .= '<br><br><strong>' . $txt['mc_groupr_approved'] . '</strong>'; |
|
| 775 | + } elseif ($row['status'] == 2) { |
|
| 776 | + $reason .= '<br><br><strong>' . $txt['mc_groupr_rejected'] . '</strong>'; |
|
| 777 | + } |
|
| 758 | 778 | |
| 759 | 779 | $reason .= ' (' . timeformat($row['time_acted']) . ')'; |
| 760 | - if (!empty($row['act_reason'])) |
|
| 761 | - $reason .= '<br><br>' . censorText($row['act_reason']); |
|
| 780 | + if (!empty($row['act_reason'])) { |
|
| 781 | + $reason .= '<br><br>' . censorText($row['act_reason']); |
|
| 782 | + } |
|
| 762 | 783 | } |
| 763 | 784 | |
| 764 | 785 | $group_requests[] = array( |
@@ -259,8 +259,8 @@ |
||
| 259 | 259 | $time_string = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]); |
| 260 | 260 | |
| 261 | 261 | $js_time_string = str_replace( |
| 262 | - array('%H', '%k', '%I', '%l', '%M', '%p', '%P', '%r', '%R', '%S', '%T', '%X'), |
|
| 263 | - array('H', 'G', 'h', 'g', 'i', 'A', 'a', 'h:i:s A', 'H:i', 's', 'H:i:s', 'H:i:s'), |
|
| 262 | + array('%H', '%k', '%I', '%l', '%M', '%p', '%P', '%r', '%R', '%S', '%T', '%X'), |
|
| 263 | + array('H', 'G', 'h', 'g', 'i', 'A', 'a', 'h:i:s A', 'H:i', 's', 'H:i:s', 'H:i:s'), |
|
| 264 | 264 | $time_string |
| 265 | 265 | ); |
| 266 | 266 | |
@@ -14,8 +14,9 @@ discard block |
||
| 14 | 14 | * @version 2.1 Beta 3 |
| 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 | * Handles showing the post screen, loading the post to be modified, and loading any post quoted. |
@@ -35,12 +36,14 @@ discard block |
||
| 35 | 36 | global $sourcedir, $smcFunc, $language; |
| 36 | 37 | |
| 37 | 38 | loadLanguage('Post'); |
| 38 | - if (!empty($modSettings['drafts_post_enabled'])) |
|
| 39 | - loadLanguage('Drafts'); |
|
| 39 | + if (!empty($modSettings['drafts_post_enabled'])) { |
|
| 40 | + loadLanguage('Drafts'); |
|
| 41 | + } |
|
| 40 | 42 | |
| 41 | 43 | // You can't reply with a poll... hacker. |
| 42 | - if (isset($_REQUEST['poll']) && !empty($topic) && !isset($_REQUEST['msg'])) |
|
| 43 | - unset($_REQUEST['poll']); |
|
| 44 | + if (isset($_REQUEST['poll']) && !empty($topic) && !isset($_REQUEST['msg'])) { |
|
| 45 | + unset($_REQUEST['poll']); |
|
| 46 | + } |
|
| 44 | 47 | |
| 45 | 48 | // Posting an event? |
| 46 | 49 | $context['make_event'] = isset($_REQUEST['calendar']); |
@@ -55,8 +58,9 @@ discard block |
||
| 55 | 58 | $context['auto_notify'] = !empty($context['notify_prefs']['msg_auto_notify']); |
| 56 | 59 | |
| 57 | 60 | // You must be posting to *some* board. |
| 58 | - if (empty($board) && !$context['make_event']) |
|
| 59 | - fatal_lang_error('no_board', false); |
|
| 61 | + if (empty($board) && !$context['make_event']) { |
|
| 62 | + fatal_lang_error('no_board', false); |
|
| 63 | + } |
|
| 60 | 64 | |
| 61 | 65 | require_once($sourcedir . '/Subs-Post.php'); |
| 62 | 66 | |
@@ -79,10 +83,11 @@ discard block |
||
| 79 | 83 | array( |
| 80 | 84 | 'msg' => (int) $_REQUEST['msg'], |
| 81 | 85 | )); |
| 82 | - if ($smcFunc['db_num_rows']($request) != 1) |
|
| 83 | - unset($_REQUEST['msg'], $_POST['msg'], $_GET['msg']); |
|
| 84 | - else |
|
| 85 | - list ($topic) = $smcFunc['db_fetch_row']($request); |
|
| 86 | + if ($smcFunc['db_num_rows']($request) != 1) { |
|
| 87 | + unset($_REQUEST['msg'], $_POST['msg'], $_GET['msg']); |
|
| 88 | + } else { |
|
| 89 | + list ($topic) = $smcFunc['db_fetch_row']($request); |
|
| 90 | + } |
|
| 86 | 91 | $smcFunc['db_free_result']($request); |
| 87 | 92 | } |
| 88 | 93 | |
@@ -109,33 +114,36 @@ discard block |
||
| 109 | 114 | $smcFunc['db_free_result']($request); |
| 110 | 115 | |
| 111 | 116 | // If this topic already has a poll, they sure can't add another. |
| 112 | - if (isset($_REQUEST['poll']) && $pollID > 0) |
|
| 113 | - unset($_REQUEST['poll']); |
|
| 117 | + if (isset($_REQUEST['poll']) && $pollID > 0) { |
|
| 118 | + unset($_REQUEST['poll']); |
|
| 119 | + } |
|
| 114 | 120 | |
| 115 | 121 | if (empty($_REQUEST['msg'])) |
| 116 | 122 | { |
| 117 | - if ($user_info['is_guest'] && !allowedTo('post_reply_any') && (!$modSettings['postmod_active'] || !allowedTo('post_unapproved_replies_any'))) |
|
| 118 | - is_not_guest(); |
|
| 123 | + if ($user_info['is_guest'] && !allowedTo('post_reply_any') && (!$modSettings['postmod_active'] || !allowedTo('post_unapproved_replies_any'))) { |
|
| 124 | + is_not_guest(); |
|
| 125 | + } |
|
| 119 | 126 | |
| 120 | 127 | // By default the reply will be approved... |
| 121 | 128 | $context['becomes_approved'] = true; |
| 122 | 129 | if ($id_member_poster != $user_info['id'] || $user_info['is_guest']) |
| 123 | 130 | { |
| 124 | - if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_any') && !allowedTo('post_reply_any')) |
|
| 125 | - $context['becomes_approved'] = false; |
|
| 126 | - else |
|
| 127 | - isAllowedTo('post_reply_any'); |
|
| 128 | - } |
|
| 129 | - elseif (!allowedTo('post_reply_any')) |
|
| 131 | + if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_any') && !allowedTo('post_reply_any')) { |
|
| 132 | + $context['becomes_approved'] = false; |
|
| 133 | + } else { |
|
| 134 | + isAllowedTo('post_reply_any'); |
|
| 135 | + } |
|
| 136 | + } elseif (!allowedTo('post_reply_any')) |
|
| 130 | 137 | { |
| 131 | - if ($modSettings['postmod_active'] && ((allowedTo('post_unapproved_replies_own') && !allowedTo('post_reply_own')) || allowedTo('post_unapproved_replies_any'))) |
|
| 132 | - $context['becomes_approved'] = false; |
|
| 133 | - else |
|
| 134 | - isAllowedTo('post_reply_own'); |
|
| 138 | + if ($modSettings['postmod_active'] && ((allowedTo('post_unapproved_replies_own') && !allowedTo('post_reply_own')) || allowedTo('post_unapproved_replies_any'))) { |
|
| 139 | + $context['becomes_approved'] = false; |
|
| 140 | + } else { |
|
| 141 | + isAllowedTo('post_reply_own'); |
|
| 142 | + } |
|
| 135 | 143 | } |
| 144 | + } else { |
|
| 145 | + $context['becomes_approved'] = true; |
|
| 136 | 146 | } |
| 137 | - else |
|
| 138 | - $context['becomes_approved'] = true; |
|
| 139 | 147 | |
| 140 | 148 | $context['can_lock'] = allowedTo('lock_any') || ($user_info['id'] == $id_member_poster && allowedTo('lock_own')); |
| 141 | 149 | $context['can_sticky'] = allowedTo('make_sticky'); |
@@ -147,18 +155,19 @@ discard block |
||
| 147 | 155 | $context['sticky'] = isset($_REQUEST['sticky']) ? !empty($_REQUEST['sticky']) : $sticky; |
| 148 | 156 | |
| 149 | 157 | // Check whether this is a really old post being bumped... |
| 150 | - if (!empty($modSettings['oldTopicDays']) && $lastPostTime + $modSettings['oldTopicDays'] * 86400 < time() && empty($sticky) && !isset($_REQUEST['subject'])) |
|
| 151 | - $post_errors[] = array('old_topic', array($modSettings['oldTopicDays'])); |
|
| 152 | - } |
|
| 153 | - else |
|
| 158 | + if (!empty($modSettings['oldTopicDays']) && $lastPostTime + $modSettings['oldTopicDays'] * 86400 < time() && empty($sticky) && !isset($_REQUEST['subject'])) { |
|
| 159 | + $post_errors[] = array('old_topic', array($modSettings['oldTopicDays'])); |
|
| 160 | + } |
|
| 161 | + } else |
|
| 154 | 162 | { |
| 155 | 163 | $context['becomes_approved'] = true; |
| 156 | 164 | if ((!$context['make_event'] || !empty($board))) |
| 157 | 165 | { |
| 158 | - if ($modSettings['postmod_active'] && !allowedTo('post_new') && allowedTo('post_unapproved_topics')) |
|
| 159 | - $context['becomes_approved'] = false; |
|
| 160 | - else |
|
| 161 | - isAllowedTo('post_new'); |
|
| 166 | + if ($modSettings['postmod_active'] && !allowedTo('post_new') && allowedTo('post_unapproved_topics')) { |
|
| 167 | + $context['becomes_approved'] = false; |
|
| 168 | + } else { |
|
| 169 | + isAllowedTo('post_new'); |
|
| 170 | + } |
|
| 162 | 171 | } |
| 163 | 172 | |
| 164 | 173 | $locked = 0; |
@@ -196,20 +205,24 @@ discard block |
||
| 196 | 205 | } |
| 197 | 206 | |
| 198 | 207 | // Don't allow a post if it's locked and you aren't all powerful. |
| 199 | - if ($locked && !allowedTo('moderate_board')) |
|
| 200 | - fatal_lang_error('topic_locked', false); |
|
| 208 | + if ($locked && !allowedTo('moderate_board')) { |
|
| 209 | + fatal_lang_error('topic_locked', false); |
|
| 210 | + } |
|
| 201 | 211 | // Check the users permissions - is the user allowed to add or post a poll? |
| 202 | 212 | if (isset($_REQUEST['poll']) && $modSettings['pollMode'] == '1') |
| 203 | 213 | { |
| 204 | 214 | // New topic, new poll. |
| 205 | - if (empty($topic)) |
|
| 206 | - isAllowedTo('poll_post'); |
|
| 215 | + if (empty($topic)) { |
|
| 216 | + isAllowedTo('poll_post'); |
|
| 217 | + } |
|
| 207 | 218 | // This is an old topic - but it is yours! Can you add to it? |
| 208 | - elseif ($user_info['id'] == $id_member_poster && !allowedTo('poll_add_any')) |
|
| 209 | - isAllowedTo('poll_add_own'); |
|
| 219 | + elseif ($user_info['id'] == $id_member_poster && !allowedTo('poll_add_any')) { |
|
| 220 | + isAllowedTo('poll_add_own'); |
|
| 221 | + } |
|
| 210 | 222 | // If you're not the owner, can you add to any poll? |
| 211 | - else |
|
| 212 | - isAllowedTo('poll_add_any'); |
|
| 223 | + else { |
|
| 224 | + isAllowedTo('poll_add_any'); |
|
| 225 | + } |
|
| 213 | 226 | |
| 214 | 227 | require_once($sourcedir . '/Subs-Members.php'); |
| 215 | 228 | $allowedVoteGroups = groupsAllowedTo('poll_vote', $board); |
@@ -238,8 +251,9 @@ discard block |
||
| 238 | 251 | if ($context['make_event']) |
| 239 | 252 | { |
| 240 | 253 | // They might want to pick a board. |
| 241 | - if (!isset($context['current_board'])) |
|
| 242 | - $context['current_board'] = 0; |
|
| 254 | + if (!isset($context['current_board'])) { |
|
| 255 | + $context['current_board'] = 0; |
|
| 256 | + } |
|
| 243 | 257 | |
| 244 | 258 | // Start loading up the event info. |
| 245 | 259 | $context['event'] = array(); |
@@ -253,10 +267,11 @@ discard block |
||
| 253 | 267 | isAllowedTo('calendar_post'); |
| 254 | 268 | |
| 255 | 269 | // We want a fairly compact version of the time, but as close as possible to the user's settings. |
| 256 | - if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) |
|
| 257 | - $time_string = '%k:%M'; |
|
| 258 | - else |
|
| 259 | - $time_string = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]); |
|
| 270 | + if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) { |
|
| 271 | + $time_string = '%k:%M'; |
|
| 272 | + } else { |
|
| 273 | + $time_string = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]); |
|
| 274 | + } |
|
| 260 | 275 | |
| 261 | 276 | $js_time_string = str_replace( |
| 262 | 277 | array('%H', '%k', '%I', '%l', '%M', '%p', '%P', '%r', '%R', '%S', '%T', '%X'), |
@@ -278,8 +293,7 @@ discard block |
||
| 278 | 293 | require_once($sourcedir . '/Subs-Calendar.php'); |
| 279 | 294 | $eventProperties = getEventProperties($context['event']['id']); |
| 280 | 295 | $context['event'] = array_merge($context['event'], $eventProperties); |
| 281 | - } |
|
| 282 | - else |
|
| 296 | + } else |
|
| 283 | 297 | { |
| 284 | 298 | // Get the current event information. |
| 285 | 299 | require_once($sourcedir . '/Subs-Calendar.php'); |
@@ -287,15 +301,18 @@ discard block |
||
| 287 | 301 | $context['event'] = array_merge($context['event'], $eventProperties); |
| 288 | 302 | |
| 289 | 303 | // Make sure the year and month are in the valid range. |
| 290 | - if ($context['event']['month'] < 1 || $context['event']['month'] > 12) |
|
| 291 | - fatal_lang_error('invalid_month', false); |
|
| 292 | - if ($context['event']['year'] < $modSettings['cal_minyear'] || $context['event']['year'] > $modSettings['cal_maxyear']) |
|
| 293 | - fatal_lang_error('invalid_year', false); |
|
| 304 | + if ($context['event']['month'] < 1 || $context['event']['month'] > 12) { |
|
| 305 | + fatal_lang_error('invalid_month', false); |
|
| 306 | + } |
|
| 307 | + if ($context['event']['year'] < $modSettings['cal_minyear'] || $context['event']['year'] > $modSettings['cal_maxyear']) { |
|
| 308 | + fatal_lang_error('invalid_year', false); |
|
| 309 | + } |
|
| 294 | 310 | |
| 295 | 311 | // Get a list of boards they can post in. |
| 296 | 312 | $boards = boardsAllowedTo('post_new'); |
| 297 | - if (empty($boards)) |
|
| 298 | - fatal_lang_error('cannot_post_new', 'user'); |
|
| 313 | + if (empty($boards)) { |
|
| 314 | + fatal_lang_error('cannot_post_new', 'user'); |
|
| 315 | + } |
|
| 299 | 316 | |
| 300 | 317 | // Load a list of boards for this event in the context. |
| 301 | 318 | require_once($sourcedir . '/Subs-MessageIndex.php'); |
@@ -414,10 +431,11 @@ discard block |
||
| 414 | 431 | |
| 415 | 432 | if (!empty($context['new_replies'])) |
| 416 | 433 | { |
| 417 | - if ($context['new_replies'] == 1) |
|
| 418 | - $txt['error_new_replies'] = isset($_GET['last_msg']) ? $txt['error_new_reply_reading'] : $txt['error_new_reply']; |
|
| 419 | - else |
|
| 420 | - $txt['error_new_replies'] = sprintf(isset($_GET['last_msg']) ? $txt['error_new_replies_reading'] : $txt['error_new_replies'], $context['new_replies']); |
|
| 434 | + if ($context['new_replies'] == 1) { |
|
| 435 | + $txt['error_new_replies'] = isset($_GET['last_msg']) ? $txt['error_new_reply_reading'] : $txt['error_new_reply']; |
|
| 436 | + } else { |
|
| 437 | + $txt['error_new_replies'] = sprintf(isset($_GET['last_msg']) ? $txt['error_new_replies_reading'] : $txt['error_new_replies'], $context['new_replies']); |
|
| 438 | + } |
|
| 421 | 439 | |
| 422 | 440 | $post_errors[] = 'new_replies'; |
| 423 | 441 | |
@@ -429,9 +447,9 @@ discard block |
||
| 429 | 447 | // Get a response prefix (like 'Re:') in the default forum language. |
| 430 | 448 | if (!isset($context['response_prefix']) && !($context['response_prefix'] = cache_get_data('response_prefix'))) |
| 431 | 449 | { |
| 432 | - if ($language === $user_info['language']) |
|
| 433 | - $context['response_prefix'] = $txt['response_prefix']; |
|
| 434 | - else |
|
| 450 | + if ($language === $user_info['language']) { |
|
| 451 | + $context['response_prefix'] = $txt['response_prefix']; |
|
| 452 | + } else |
|
| 435 | 453 | { |
| 436 | 454 | loadLanguage('index', $language, false); |
| 437 | 455 | $context['response_prefix'] = $txt['response_prefix']; |
@@ -444,8 +462,9 @@ discard block |
||
| 444 | 462 | // Do we have a body, but an error happened. |
| 445 | 463 | if (isset($_REQUEST['message']) || isset($_REQUEST['quickReply']) || !empty($context['post_error'])) |
| 446 | 464 | { |
| 447 | - if (isset($_REQUEST['quickReply'])) |
|
| 448 | - $_REQUEST['message'] = $_REQUEST['quickReply']; |
|
| 465 | + if (isset($_REQUEST['quickReply'])) { |
|
| 466 | + $_REQUEST['message'] = $_REQUEST['quickReply']; |
|
| 467 | + } |
|
| 449 | 468 | |
| 450 | 469 | // Validate inputs. |
| 451 | 470 | if (empty($context['post_error'])) |
@@ -453,15 +472,17 @@ discard block |
||
| 453 | 472 | // This means they didn't click Post and get an error. |
| 454 | 473 | $really_previewing = true; |
| 455 | 474 | |
| 456 | - } |
|
| 457 | - else |
|
| 475 | + } else |
|
| 458 | 476 | { |
| 459 | - if (!isset($_REQUEST['subject'])) |
|
| 460 | - $_REQUEST['subject'] = ''; |
|
| 461 | - if (!isset($_REQUEST['message'])) |
|
| 462 | - $_REQUEST['message'] = ''; |
|
| 463 | - if (!isset($_REQUEST['icon'])) |
|
| 464 | - $_REQUEST['icon'] = 'xx'; |
|
| 477 | + if (!isset($_REQUEST['subject'])) { |
|
| 478 | + $_REQUEST['subject'] = ''; |
|
| 479 | + } |
|
| 480 | + if (!isset($_REQUEST['message'])) { |
|
| 481 | + $_REQUEST['message'] = ''; |
|
| 482 | + } |
|
| 483 | + if (!isset($_REQUEST['icon'])) { |
|
| 484 | + $_REQUEST['icon'] = 'xx'; |
|
| 485 | + } |
|
| 465 | 486 | |
| 466 | 487 | // They are previewing if they asked to preview (i.e. came from quick reply). |
| 467 | 488 | $really_previewing = !empty($_POST['preview']); |
@@ -477,8 +498,9 @@ discard block |
||
| 477 | 498 | $form_message = $smcFunc['htmlspecialchars']($_REQUEST['message'], ENT_QUOTES); |
| 478 | 499 | |
| 479 | 500 | // Make sure the subject isn't too long - taking into account special characters. |
| 480 | - if ($smcFunc['strlen']($form_subject) > 100) |
|
| 481 | - $form_subject = $smcFunc['substr']($form_subject, 0, 100); |
|
| 501 | + if ($smcFunc['strlen']($form_subject) > 100) { |
|
| 502 | + $form_subject = $smcFunc['substr']($form_subject, 0, 100); |
|
| 503 | + } |
|
| 482 | 504 | |
| 483 | 505 | if (isset($_REQUEST['poll'])) |
| 484 | 506 | { |
@@ -490,8 +512,9 @@ discard block |
||
| 490 | 512 | $_POST['options'] = empty($_POST['options']) ? array() : htmlspecialchars__recursive($_POST['options']); |
| 491 | 513 | foreach ($_POST['options'] as $option) |
| 492 | 514 | { |
| 493 | - if (trim($option) == '') |
|
| 494 | - continue; |
|
| 515 | + if (trim($option) == '') { |
|
| 516 | + continue; |
|
| 517 | + } |
|
| 495 | 518 | |
| 496 | 519 | $context['choices'][] = array( |
| 497 | 520 | 'id' => $choice_id++, |
@@ -553,13 +576,14 @@ discard block |
||
| 553 | 576 | $context['preview_subject'] = $form_subject; |
| 554 | 577 | |
| 555 | 578 | censorText($context['preview_subject']); |
| 579 | + } else { |
|
| 580 | + $context['preview_subject'] = '<em>' . $txt['no_subject'] . '</em>'; |
|
| 556 | 581 | } |
| 557 | - else |
|
| 558 | - $context['preview_subject'] = '<em>' . $txt['no_subject'] . '</em>'; |
|
| 559 | 582 | |
| 560 | 583 | // Protect any CDATA blocks. |
| 561 | - if (isset($_REQUEST['xml'])) |
|
| 562 | - $context['preview_message'] = strtr($context['preview_message'], array(']]>' => ']]]]><![CDATA[>')); |
|
| 584 | + if (isset($_REQUEST['xml'])) { |
|
| 585 | + $context['preview_message'] = strtr($context['preview_message'], array(']]>' => ']]]]>< == 0) |
|
| 602 | - fatal_lang_error('no_board', false); |
|
| 625 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 626 | + fatal_lang_error('no_board', false); |
|
| 627 | + } |
|
| 603 | 628 | $row = $smcFunc['db_fetch_assoc']($request); |
| 604 | 629 | |
| 605 | 630 | $attachment_stuff = array($row); |
| 606 | - while ($row2 = $smcFunc['db_fetch_assoc']($request)) |
|
| 607 | - $attachment_stuff[] = $row2; |
|
| 631 | + while ($row2 = $smcFunc['db_fetch_assoc']($request)) { |
|
| 632 | + $attachment_stuff[] = $row2; |
|
| 633 | + } |
|
| 608 | 634 | $smcFunc['db_free_result']($request); |
| 609 | 635 | |
| 610 | 636 | if ($row['id_member'] == $user_info['id'] && !allowedTo('modify_any')) |
| 611 | 637 | { |
| 612 | 638 | // Give an extra five minutes over the disable time threshold, so they can type - assuming the post is public. |
| 613 | - if ($row['approved'] && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) |
|
| 614 | - fatal_lang_error('modify_post_time_passed', false); |
|
| 615 | - elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_own')) |
|
| 616 | - isAllowedTo('modify_replies'); |
|
| 617 | - else |
|
| 618 | - isAllowedTo('modify_own'); |
|
| 639 | + if ($row['approved'] && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) { |
|
| 640 | + fatal_lang_error('modify_post_time_passed', false); |
|
| 641 | + } elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_own')) { |
|
| 642 | + isAllowedTo('modify_replies'); |
|
| 643 | + } else { |
|
| 644 | + isAllowedTo('modify_own'); |
|
| 645 | + } |
|
| 646 | + } elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_any')) { |
|
| 647 | + isAllowedTo('modify_replies'); |
|
| 648 | + } else { |
|
| 649 | + isAllowedTo('modify_any'); |
|
| 619 | 650 | } |
| 620 | - elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_any')) |
|
| 621 | - isAllowedTo('modify_replies'); |
|
| 622 | - else |
|
| 623 | - isAllowedTo('modify_any'); |
|
| 624 | 651 | |
| 625 | 652 | if ($context['can_announce'] && !empty($row['id_action'])) |
| 626 | 653 | { |
@@ -644,8 +671,9 @@ discard block |
||
| 644 | 671 | |
| 645 | 672 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 646 | 673 | { |
| 647 | - if ($row['filesize'] <= 0) |
|
| 648 | - continue; |
|
| 674 | + if ($row['filesize'] <= 0) { |
|
| 675 | + continue; |
|
| 676 | + } |
|
| 649 | 677 | $context['current_attachments'][$row['id_attach']] = array( |
| 650 | 678 | 'name' => $smcFunc['htmlspecialchars']($row['filename']), |
| 651 | 679 | 'size' => $row['filesize'], |
@@ -715,29 +743,32 @@ discard block |
||
| 715 | 743 | ) |
| 716 | 744 | ); |
| 717 | 745 | // The message they were trying to edit was most likely deleted. |
| 718 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 719 | - fatal_lang_error('no_message', false); |
|
| 746 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 747 | + fatal_lang_error('no_message', false); |
|
| 748 | + } |
|
| 720 | 749 | $row = $smcFunc['db_fetch_assoc']($request); |
| 721 | 750 | |
| 722 | 751 | $attachment_stuff = array($row); |
| 723 | - while ($row2 = $smcFunc['db_fetch_assoc']($request)) |
|
| 724 | - $attachment_stuff[] = $row2; |
|
| 752 | + while ($row2 = $smcFunc['db_fetch_assoc']($request)) { |
|
| 753 | + $attachment_stuff[] = $row2; |
|
| 754 | + } |
|
| 725 | 755 | $smcFunc['db_free_result']($request); |
| 726 | 756 | |
| 727 | 757 | if ($row['id_member'] == $user_info['id'] && !allowedTo('modify_any')) |
| 728 | 758 | { |
| 729 | 759 | // Give an extra five minutes over the disable time threshold, so they can type - assuming the post is public. |
| 730 | - if ($row['approved'] && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) |
|
| 731 | - fatal_lang_error('modify_post_time_passed', false); |
|
| 732 | - elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_own')) |
|
| 733 | - isAllowedTo('modify_replies'); |
|
| 734 | - else |
|
| 735 | - isAllowedTo('modify_own'); |
|
| 760 | + if ($row['approved'] && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) { |
|
| 761 | + fatal_lang_error('modify_post_time_passed', false); |
|
| 762 | + } elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_own')) { |
|
| 763 | + isAllowedTo('modify_replies'); |
|
| 764 | + } else { |
|
| 765 | + isAllowedTo('modify_own'); |
|
| 766 | + } |
|
| 767 | + } elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_any')) { |
|
| 768 | + isAllowedTo('modify_replies'); |
|
| 769 | + } else { |
|
| 770 | + isAllowedTo('modify_any'); |
|
| 736 | 771 | } |
| 737 | - elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_any')) |
|
| 738 | - isAllowedTo('modify_replies'); |
|
| 739 | - else |
|
| 740 | - isAllowedTo('modify_any'); |
|
| 741 | 772 | |
| 742 | 773 | if ($context['can_announce'] && !empty($row['id_action'])) |
| 743 | 774 | { |
@@ -764,15 +795,17 @@ discard block |
||
| 764 | 795 | $context['icon'] = $row['icon']; |
| 765 | 796 | |
| 766 | 797 | // Show an "approve" box if the user can approve it, and the message isn't approved. |
| 767 | - if (!$row['approved'] && !$context['show_approval']) |
|
| 768 | - $context['show_approval'] = allowedTo('approve_posts'); |
|
| 798 | + if (!$row['approved'] && !$context['show_approval']) { |
|
| 799 | + $context['show_approval'] = allowedTo('approve_posts'); |
|
| 800 | + } |
|
| 769 | 801 | |
| 770 | 802 | // Sort the attachments so they are in the order saved |
| 771 | 803 | $temp = array(); |
| 772 | 804 | foreach ($attachment_stuff as $attachment) |
| 773 | 805 | { |
| 774 | - if ($attachment['filesize'] >= 0 && !empty($modSettings['attachmentEnable'])) |
|
| 775 | - $temp[$attachment['id_attach']] = $attachment; |
|
| 806 | + if ($attachment['filesize'] >= 0 && !empty($modSettings['attachmentEnable'])) { |
|
| 807 | + $temp[$attachment['id_attach']] = $attachment; |
|
| 808 | + } |
|
| 776 | 809 | |
| 777 | 810 | } |
| 778 | 811 | ksort($temp); |
@@ -834,14 +867,16 @@ discard block |
||
| 834 | 867 | 'is_approved' => 1, |
| 835 | 868 | ) |
| 836 | 869 | ); |
| 837 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 838 | - fatal_lang_error('quoted_post_deleted', false); |
|
| 870 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 871 | + fatal_lang_error('quoted_post_deleted', false); |
|
| 872 | + } |
|
| 839 | 873 | list ($form_subject, $mname, $mdate, $form_message) = $smcFunc['db_fetch_row']($request); |
| 840 | 874 | $smcFunc['db_free_result']($request); |
| 841 | 875 | |
| 842 | 876 | // Add 'Re: ' to the front of the quoted subject. |
| 843 | - if (trim($context['response_prefix']) != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0) |
|
| 844 | - $form_subject = $context['response_prefix'] . $form_subject; |
|
| 877 | + if (trim($context['response_prefix']) != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0) { |
|
| 878 | + $form_subject = $context['response_prefix'] . $form_subject; |
|
| 879 | + } |
|
| 845 | 880 | |
| 846 | 881 | // Censor the message and subject. |
| 847 | 882 | censorText($form_message); |
@@ -854,10 +889,11 @@ discard block |
||
| 854 | 889 | for ($i = 0, $n = count($parts); $i < $n; $i++) |
| 855 | 890 | { |
| 856 | 891 | // It goes 0 = outside, 1 = begin tag, 2 = inside, 3 = close tag, repeat. |
| 857 | - if ($i % 4 == 0) |
|
| 858 | - $parts[$i] = preg_replace_callback('~\[html\](.+?)\[/html\]~is', function($m) |
|
| 892 | + if ($i % 4 == 0) { |
|
| 893 | + $parts[$i] = preg_replace_callback('~\[html\](.+?)\[/html\]~is', function($m) |
|
| 859 | 894 | { |
| 860 | 895 | return '[html]' . preg_replace('~<br\s?/?' . '>~i', '<br /><br>', "$m[1]") . '[/html]'; |
| 896 | + } |
|
| 861 | 897 | }, $parts[$i]); |
| 862 | 898 | } |
| 863 | 899 | $form_message = implode('', $parts); |
@@ -866,8 +902,9 @@ discard block |
||
| 866 | 902 | $form_message = preg_replace('~<br ?/?' . '>~i', "\n", $form_message); |
| 867 | 903 | |
| 868 | 904 | // Remove any nested quotes, if necessary. |
| 869 | - if (!empty($modSettings['removeNestedQuotes'])) |
|
| 870 | - $form_message = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $form_message); |
|
| 905 | + if (!empty($modSettings['removeNestedQuotes'])) { |
|
| 906 | + $form_message = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $form_message); |
|
| 907 | + } |
|
| 871 | 908 | |
| 872 | 909 | // Add a quote string on the front and end. |
| 873 | 910 | $form_message = '[quote author=' . $mname . ' link=msg=' . (int) $_REQUEST['quote'] . ' date=' . $mdate . ']' . "\n" . rtrim($form_message) . "\n" . '[/quote]'; |
@@ -879,15 +916,15 @@ discard block |
||
| 879 | 916 | $form_subject = $first_subject; |
| 880 | 917 | |
| 881 | 918 | // Add 'Re: ' to the front of the subject. |
| 882 | - if (trim($context['response_prefix']) != '' && $form_subject != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0) |
|
| 883 | - $form_subject = $context['response_prefix'] . $form_subject; |
|
| 919 | + if (trim($context['response_prefix']) != '' && $form_subject != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0) { |
|
| 920 | + $form_subject = $context['response_prefix'] . $form_subject; |
|
| 921 | + } |
|
| 884 | 922 | |
| 885 | 923 | // Censor the subject. |
| 886 | 924 | censorText($form_subject); |
| 887 | 925 | |
| 888 | 926 | $form_message = ''; |
| 889 | - } |
|
| 890 | - else |
|
| 927 | + } else |
|
| 891 | 928 | { |
| 892 | 929 | $form_subject = isset($_GET['subject']) ? $_GET['subject'] : ''; |
| 893 | 930 | $form_message = ''; |
@@ -905,13 +942,15 @@ discard block |
||
| 905 | 942 | if (isset($_REQUEST['msg'])) |
| 906 | 943 | { |
| 907 | 944 | $context['attachments']['quantity'] = count($context['current_attachments']); |
| 908 | - foreach ($context['current_attachments'] as $attachment) |
|
| 909 | - $context['attachments']['total_size'] += $attachment['size']; |
|
| 945 | + foreach ($context['current_attachments'] as $attachment) { |
|
| 946 | + $context['attachments']['total_size'] += $attachment['size']; |
|
| 947 | + } |
|
| 910 | 948 | } |
| 911 | 949 | |
| 912 | 950 | // A bit of house keeping first. |
| 913 | - if (!empty($_SESSION['temp_attachments']) && count($_SESSION['temp_attachments']) == 1) |
|
| 914 | - unset($_SESSION['temp_attachments']); |
|
| 951 | + if (!empty($_SESSION['temp_attachments']) && count($_SESSION['temp_attachments']) == 1) { |
|
| 952 | + unset($_SESSION['temp_attachments']); |
|
| 953 | + } |
|
| 915 | 954 | |
| 916 | 955 | if (!empty($_SESSION['temp_attachments'])) |
| 917 | 956 | { |
@@ -920,9 +959,10 @@ discard block |
||
| 920 | 959 | { |
| 921 | 960 | foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
| 922 | 961 | { |
| 923 | - if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false) |
|
| 924 | - if (file_exists($attachment['tmp_name'])) |
|
| 962 | + if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false) { |
|
| 963 | + if (file_exists($attachment['tmp_name'])) |
|
| 925 | 964 | unlink($attachment['tmp_name']); |
| 965 | + } |
|
| 926 | 966 | } |
| 927 | 967 | $post_errors[] = 'temp_attachments_gone'; |
| 928 | 968 | $_SESSION['temp_attachments'] = array(); |
@@ -936,8 +976,9 @@ discard block |
||
| 936 | 976 | // See if any files still exist before showing the warning message and the files attached. |
| 937 | 977 | foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
| 938 | 978 | { |
| 939 | - if (strpos($attachID, 'post_tmp_' . $user_info['id']) === false) |
|
| 940 | - continue; |
|
| 979 | + if (strpos($attachID, 'post_tmp_' . $user_info['id']) === false) { |
|
| 980 | + continue; |
|
| 981 | + } |
|
| 941 | 982 | |
| 942 | 983 | if (file_exists($attachment['tmp_name'])) |
| 943 | 984 | { |
@@ -947,20 +988,21 @@ discard block |
||
| 947 | 988 | break; |
| 948 | 989 | } |
| 949 | 990 | } |
| 950 | - } |
|
| 951 | - else |
|
| 991 | + } else |
|
| 952 | 992 | { |
| 953 | 993 | // Since, they don't belong here. Let's inform the user that they exist.. |
| 954 | - if (!empty($topic)) |
|
| 955 | - $delete_url = $scripturl . '?action=post' . (!empty($_REQUEST['msg']) ? (';msg=' . $_REQUEST['msg']) : '') . (!empty($_REQUEST['last_msg']) ? (';last_msg=' . $_REQUEST['last_msg']) : '') . ';topic=' . $topic . ';delete_temp'; |
|
| 956 | - else |
|
| 957 | - $delete_url = $scripturl . '?action=post;board=' . $board . ';delete_temp'; |
|
| 994 | + if (!empty($topic)) { |
|
| 995 | + $delete_url = $scripturl . '?action=post' . (!empty($_REQUEST['msg']) ? (';msg=' . $_REQUEST['msg']) : '') . (!empty($_REQUEST['last_msg']) ? (';last_msg=' . $_REQUEST['last_msg']) : '') . ';topic=' . $topic . ';delete_temp'; |
|
| 996 | + } else { |
|
| 997 | + $delete_url = $scripturl . '?action=post;board=' . $board . ';delete_temp'; |
|
| 998 | + } |
|
| 958 | 999 | |
| 959 | 1000 | // Compile a list of the files to show the user. |
| 960 | 1001 | $file_list = array(); |
| 961 | - foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
|
| 962 | - if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false) |
|
| 1002 | + foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) { |
|
| 1003 | + if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false) |
|
| 963 | 1004 | $file_list[] = $attachment['name']; |
| 1005 | + } |
|
| 964 | 1006 | |
| 965 | 1007 | $_SESSION['temp_attachments']['post']['files'] = $file_list; |
| 966 | 1008 | $file_list = '<div class="attachments">' . implode('<br>', $file_list) . '</div>'; |
@@ -972,8 +1014,7 @@ discard block |
||
| 972 | 1014 | |
| 973 | 1015 | $post_errors[] = array('temp_attachments_found', array($delete_url, $goback_url, $file_list)); |
| 974 | 1016 | $context['ignore_temp_attachments'] = true; |
| 975 | - } |
|
| 976 | - else |
|
| 1017 | + } else |
|
| 977 | 1018 | { |
| 978 | 1019 | $post_errors[] = array('temp_attachments_lost', array($delete_url, $file_list)); |
| 979 | 1020 | $context['ignore_temp_attachments'] = true; |
@@ -981,16 +1022,19 @@ discard block |
||
| 981 | 1022 | } |
| 982 | 1023 | } |
| 983 | 1024 | |
| 984 | - if (!empty($context['we_are_history'])) |
|
| 985 | - $post_errors[] = $context['we_are_history']; |
|
| 1025 | + if (!empty($context['we_are_history'])) { |
|
| 1026 | + $post_errors[] = $context['we_are_history']; |
|
| 1027 | + } |
|
| 986 | 1028 | |
| 987 | 1029 | foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
| 988 | 1030 | { |
| 989 | - if (isset($context['ignore_temp_attachments']) || isset($_SESSION['temp_attachments']['post']['files'])) |
|
| 990 | - break; |
|
| 1031 | + if (isset($context['ignore_temp_attachments']) || isset($_SESSION['temp_attachments']['post']['files'])) { |
|
| 1032 | + break; |
|
| 1033 | + } |
|
| 991 | 1034 | |
| 992 | - if ($attachID != 'initial_error' && strpos($attachID, 'post_tmp_' . $user_info['id']) === false) |
|
| 993 | - continue; |
|
| 1035 | + if ($attachID != 'initial_error' && strpos($attachID, 'post_tmp_' . $user_info['id']) === false) { |
|
| 1036 | + continue; |
|
| 1037 | + } |
|
| 994 | 1038 | |
| 995 | 1039 | if ($attachID == 'initial_error') |
| 996 | 1040 | { |
@@ -1005,15 +1049,17 @@ discard block |
||
| 1005 | 1049 | { |
| 1006 | 1050 | $txt['error_attach_errors'] = empty($txt['error_attach_errors']) ? '<br>' : ''; |
| 1007 | 1051 | $txt['error_attach_errors'] .= vsprintf($txt['attach_warning'], $attachment['name']) . '<div style="padding: 0 1em;">'; |
| 1008 | - foreach ($attachment['errors'] as $error) |
|
| 1009 | - $txt['error_attach_errors'] .= (is_array($error) ? vsprintf($txt[$error[0]], $error[1]) : $txt[$error]) . '<br >'; |
|
| 1052 | + foreach ($attachment['errors'] as $error) { |
|
| 1053 | + $txt['error_attach_errors'] .= (is_array($error) ? vsprintf($txt[$error[0]], $error[1]) : $txt[$error]) . '<br >'; |
|
| 1054 | + } |
|
| 1010 | 1055 | $txt['error_attach_errors'] .= '</div>'; |
| 1011 | 1056 | $post_errors[] = 'attach_errors'; |
| 1012 | 1057 | |
| 1013 | 1058 | // Take out the trash. |
| 1014 | 1059 | unset($_SESSION['temp_attachments'][$attachID]); |
| 1015 | - if (file_exists($attachment['tmp_name'])) |
|
| 1016 | - unlink($attachment['tmp_name']); |
|
| 1060 | + if (file_exists($attachment['tmp_name'])) { |
|
| 1061 | + unlink($attachment['tmp_name']); |
|
| 1062 | + } |
|
| 1017 | 1063 | continue; |
| 1018 | 1064 | } |
| 1019 | 1065 | |
@@ -1026,8 +1072,9 @@ discard block |
||
| 1026 | 1072 | |
| 1027 | 1073 | $context['attachments']['quantity']++; |
| 1028 | 1074 | $context['attachments']['total_size'] += $attachment['size']; |
| 1029 | - if (!isset($context['files_in_session_warning'])) |
|
| 1030 | - $context['files_in_session_warning'] = $txt['attached_files_in_session']; |
|
| 1075 | + if (!isset($context['files_in_session_warning'])) { |
|
| 1076 | + $context['files_in_session_warning'] = $txt['attached_files_in_session']; |
|
| 1077 | + } |
|
| 1031 | 1078 | |
| 1032 | 1079 | $context['current_attachments'][$attachID] = array( |
| 1033 | 1080 | 'name' => '<u>' . $smcFunc['htmlspecialchars']($attachment['name']) . '</u>', |
@@ -1055,8 +1102,9 @@ discard block |
||
| 1055 | 1102 | } |
| 1056 | 1103 | |
| 1057 | 1104 | // If they came from quick reply, and have to enter verification details, give them some notice. |
| 1058 | - if (!empty($_REQUEST['from_qr']) && !empty($context['require_verification'])) |
|
| 1059 | - $post_errors[] = 'need_qr_verification'; |
|
| 1105 | + if (!empty($_REQUEST['from_qr']) && !empty($context['require_verification'])) { |
|
| 1106 | + $post_errors[] = 'need_qr_verification'; |
|
| 1107 | + } |
|
| 1060 | 1108 | |
| 1061 | 1109 | /* |
| 1062 | 1110 | * There are two error types: serious and minor. Serious errors |
@@ -1073,52 +1121,56 @@ discard block |
||
| 1073 | 1121 | { |
| 1074 | 1122 | loadLanguage('Errors'); |
| 1075 | 1123 | $context['error_type'] = 'minor'; |
| 1076 | - foreach ($post_errors as $post_error) |
|
| 1077 | - if (is_array($post_error)) |
|
| 1124 | + foreach ($post_errors as $post_error) { |
|
| 1125 | + if (is_array($post_error)) |
|
| 1078 | 1126 | { |
| 1079 | 1127 | $post_error_id = $post_error[0]; |
| 1128 | + } |
|
| 1080 | 1129 | $context['post_error'][$post_error_id] = vsprintf($txt['error_' . $post_error_id], $post_error[1]); |
| 1081 | 1130 | |
| 1082 | 1131 | // If it's not a minor error flag it as such. |
| 1083 | - if (!in_array($post_error_id, $minor_errors)) |
|
| 1084 | - $context['error_type'] = 'serious'; |
|
| 1085 | - } |
|
| 1086 | - else |
|
| 1132 | + if (!in_array($post_error_id, $minor_errors)) { |
|
| 1133 | + $context['error_type'] = 'serious'; |
|
| 1134 | + } |
|
| 1135 | + } else |
|
| 1087 | 1136 | { |
| 1088 | 1137 | $context['post_error'][$post_error] = $txt['error_' . $post_error]; |
| 1089 | 1138 | |
| 1090 | 1139 | // If it's not a minor error flag it as such. |
| 1091 | - if (!in_array($post_error, $minor_errors)) |
|
| 1092 | - $context['error_type'] = 'serious'; |
|
| 1140 | + if (!in_array($post_error, $minor_errors)) { |
|
| 1141 | + $context['error_type'] = 'serious'; |
|
| 1142 | + } |
|
| 1093 | 1143 | } |
| 1094 | 1144 | } |
| 1095 | 1145 | |
| 1096 | 1146 | // What are you doing? Posting a poll, modifying, previewing, new post, or reply... |
| 1097 | - if (isset($_REQUEST['poll'])) |
|
| 1098 | - $context['page_title'] = $txt['new_poll']; |
|
| 1099 | - elseif ($context['make_event']) |
|
| 1100 | - $context['page_title'] = $context['event']['id'] == -1 ? $txt['calendar_post_event'] : $txt['calendar_edit']; |
|
| 1101 | - elseif (isset($_REQUEST['msg'])) |
|
| 1102 | - $context['page_title'] = $txt['modify_msg']; |
|
| 1103 | - elseif (isset($_REQUEST['subject'], $context['preview_subject'])) |
|
| 1104 | - $context['page_title'] = $txt['preview'] . ' - ' . strip_tags($context['preview_subject']); |
|
| 1105 | - elseif (empty($topic)) |
|
| 1106 | - $context['page_title'] = $txt['start_new_topic']; |
|
| 1107 | - else |
|
| 1108 | - $context['page_title'] = $txt['post_reply']; |
|
| 1147 | + if (isset($_REQUEST['poll'])) { |
|
| 1148 | + $context['page_title'] = $txt['new_poll']; |
|
| 1149 | + } elseif ($context['make_event']) { |
|
| 1150 | + $context['page_title'] = $context['event']['id'] == -1 ? $txt['calendar_post_event'] : $txt['calendar_edit']; |
|
| 1151 | + } elseif (isset($_REQUEST['msg'])) { |
|
| 1152 | + $context['page_title'] = $txt['modify_msg']; |
|
| 1153 | + } elseif (isset($_REQUEST['subject'], $context['preview_subject'])) { |
|
| 1154 | + $context['page_title'] = $txt['preview'] . ' - ' . strip_tags($context['preview_subject']); |
|
| 1155 | + } elseif (empty($topic)) { |
|
| 1156 | + $context['page_title'] = $txt['start_new_topic']; |
|
| 1157 | + } else { |
|
| 1158 | + $context['page_title'] = $txt['post_reply']; |
|
| 1159 | + } |
|
| 1109 | 1160 | |
| 1110 | 1161 | // Build the link tree. |
| 1111 | - if (empty($topic)) |
|
| 1112 | - $context['linktree'][] = array( |
|
| 1162 | + if (empty($topic)) { |
|
| 1163 | + $context['linktree'][] = array( |
|
| 1113 | 1164 | 'name' => '<em>' . $txt['start_new_topic'] . '</em>' |
| 1114 | 1165 | ); |
| 1115 | - else |
|
| 1116 | - $context['linktree'][] = array( |
|
| 1166 | + } else { |
|
| 1167 | + $context['linktree'][] = array( |
|
| 1117 | 1168 | 'url' => $scripturl . '?topic=' . $topic . '.' . $_REQUEST['start'], |
| 1118 | 1169 | 'name' => $form_subject, |
| 1119 | 1170 | 'extra_before' => '<span><strong class="nav">' . $context['page_title'] . ' (</strong></span>', |
| 1120 | 1171 | 'extra_after' => '<span><strong class="nav">)</strong></span>' |
| 1121 | 1172 | ); |
| 1173 | + } |
|
| 1122 | 1174 | |
| 1123 | 1175 | $context['subject'] = addcslashes($form_subject, '"'); |
| 1124 | 1176 | $context['message'] = str_replace(array('"', '<', '>', ' '), array('"', '<', '>', ' '), $form_message); |
@@ -1162,8 +1214,9 @@ discard block |
||
| 1162 | 1214 | // Message icons - customized icons are off? |
| 1163 | 1215 | $context['icons'] = getMessageIcons($board); |
| 1164 | 1216 | |
| 1165 | - if (!empty($context['icons'])) |
|
| 1166 | - $context['icons'][count($context['icons']) - 1]['is_last'] = true; |
|
| 1217 | + if (!empty($context['icons'])) { |
|
| 1218 | + $context['icons'][count($context['icons']) - 1]['is_last'] = true; |
|
| 1219 | + } |
|
| 1167 | 1220 | |
| 1168 | 1221 | // Are we starting a poll? if set the poll icon as selected if its available |
| 1169 | 1222 | if (isset($_REQUEST['poll'])) |
@@ -1183,8 +1236,9 @@ discard block |
||
| 1183 | 1236 | for ($i = 0, $n = count($context['icons']); $i < $n; $i++) |
| 1184 | 1237 | { |
| 1185 | 1238 | $context['icons'][$i]['selected'] = $context['icon'] == $context['icons'][$i]['value']; |
| 1186 | - if ($context['icons'][$i]['selected']) |
|
| 1187 | - $context['icon_url'] = $context['icons'][$i]['url']; |
|
| 1239 | + if ($context['icons'][$i]['selected']) { |
|
| 1240 | + $context['icon_url'] = $context['icons'][$i]['url']; |
|
| 1241 | + } |
|
| 1188 | 1242 | } |
| 1189 | 1243 | if (empty($context['icon_url'])) |
| 1190 | 1244 | { |
@@ -1198,8 +1252,9 @@ discard block |
||
| 1198 | 1252 | )); |
| 1199 | 1253 | } |
| 1200 | 1254 | |
| 1201 | - if (!empty($topic) && !empty($modSettings['topicSummaryPosts'])) |
|
| 1202 | - getTopic(); |
|
| 1255 | + if (!empty($topic) && !empty($modSettings['topicSummaryPosts'])) { |
|
| 1256 | + getTopic(); |
|
| 1257 | + } |
|
| 1203 | 1258 | |
| 1204 | 1259 | // If the user can post attachments prepare the warning labels. |
| 1205 | 1260 | if ($context['can_post_attachment']) |
@@ -1210,15 +1265,17 @@ discard block |
||
| 1210 | 1265 | $context['attachment_restrictions'] = array(); |
| 1211 | 1266 | $context['allowed_extensions'] = strtr(strtolower($modSettings['attachmentExtensions']), array(',' => ', ')); |
| 1212 | 1267 | $attachmentRestrictionTypes = array('attachmentNumPerPostLimit', 'attachmentPostLimit', 'attachmentSizeLimit'); |
| 1213 | - foreach ($attachmentRestrictionTypes as $type) |
|
| 1214 | - if (!empty($modSettings[$type])) |
|
| 1268 | + foreach ($attachmentRestrictionTypes as $type) { |
|
| 1269 | + if (!empty($modSettings[$type])) |
|
| 1215 | 1270 | { |
| 1216 | 1271 | $context['attachment_restrictions'][] = sprintf($txt['attach_restrict_' . $type . ($modSettings[$type] >= 1024 ? '_MB' : '')], comma_format($modSettings[$type], 0)); |
| 1272 | + } |
|
| 1217 | 1273 | // Show some numbers. If they exist. |
| 1218 | - if ($type == 'attachmentNumPerPostLimit' && $context['attachments']['quantity'] > 0) |
|
| 1219 | - $context['attachment_restrictions'][] = sprintf($txt['attach_remaining'], $modSettings['attachmentNumPerPostLimit'] - $context['attachments']['quantity']); |
|
| 1220 | - elseif ($type == 'attachmentPostLimit' && $context['attachments']['total_size'] > 0) |
|
| 1221 | - $context['attachment_restrictions'][] = sprintf($txt['attach_available'], comma_format(round(max($modSettings['attachmentPostLimit'] - ($context['attachments']['total_size'] / 1024), 0)), 0)); |
|
| 1274 | + if ($type == 'attachmentNumPerPostLimit' && $context['attachments']['quantity'] > 0) { |
|
| 1275 | + $context['attachment_restrictions'][] = sprintf($txt['attach_remaining'], $modSettings['attachmentNumPerPostLimit'] - $context['attachments']['quantity']); |
|
| 1276 | + } elseif ($type == 'attachmentPostLimit' && $context['attachments']['total_size'] > 0) { |
|
| 1277 | + $context['attachment_restrictions'][] = sprintf($txt['attach_available'], comma_format(round(max($modSettings['attachmentPostLimit'] - ($context['attachments']['total_size'] / 1024), 0)), 0)); |
|
| 1278 | + } |
|
| 1222 | 1279 | } |
| 1223 | 1280 | } |
| 1224 | 1281 | |
@@ -1252,8 +1309,8 @@ discard block |
||
| 1252 | 1309 | |
| 1253 | 1310 | if (!empty($context['current_attachments'])) |
| 1254 | 1311 | { |
| 1255 | - foreach ($context['current_attachments'] as $key => $mock) |
|
| 1256 | - addInlineJavaScript(' |
|
| 1312 | + foreach ($context['current_attachments'] as $key => $mock) { |
|
| 1313 | + addInlineJavaScript(' |
|
| 1257 | 1314 | current_attachments.push({ |
| 1258 | 1315 | name: '. JavaScriptEscape($mock['name']) . ', |
| 1259 | 1316 | size: '. $mock['size'] . ', |
@@ -1262,6 +1319,7 @@ discard block |
||
| 1262 | 1319 | type: '. JavaScriptEscape(!empty($mock['mime_type']) ? $mock['mime_type'] : '') . ', |
| 1263 | 1320 | thumbID: '. (!empty($mock['thumb']) ? $mock['thumb'] : 0) . ' |
| 1264 | 1321 | });', true); |
| 1322 | + } |
|
| 1265 | 1323 | } |
| 1266 | 1324 | |
| 1267 | 1325 | // File Upload. |
@@ -1306,8 +1364,9 @@ discard block |
||
| 1306 | 1364 | var current_board = '. (empty($context['current_board']) ? 'null' : $context['current_board']) . ';', false); |
| 1307 | 1365 | |
| 1308 | 1366 | // Finally, load the template. |
| 1309 | - if (!isset($_REQUEST['xml'])) |
|
| 1310 | - loadTemplate('Post'); |
|
| 1367 | + if (!isset($_REQUEST['xml'])) { |
|
| 1368 | + loadTemplate('Post'); |
|
| 1369 | + } |
|
| 1311 | 1370 | |
| 1312 | 1371 | call_integration_hook('integrate_post_end'); |
| 1313 | 1372 | } |
@@ -1328,13 +1387,14 @@ discard block |
||
| 1328 | 1387 | // Sneaking off, are we? |
| 1329 | 1388 | if (empty($_POST) && empty($topic)) |
| 1330 | 1389 | { |
| 1331 | - if (empty($_SERVER['CONTENT_LENGTH'])) |
|
| 1332 | - redirectexit('action=post;board=' . $board . '.0'); |
|
| 1333 | - else |
|
| 1334 | - fatal_lang_error('post_upload_error', false); |
|
| 1390 | + if (empty($_SERVER['CONTENT_LENGTH'])) { |
|
| 1391 | + redirectexit('action=post;board=' . $board . '.0'); |
|
| 1392 | + } else { |
|
| 1393 | + fatal_lang_error('post_upload_error', false); |
|
| 1394 | + } |
|
| 1395 | + } elseif (empty($_POST) && !empty($topic)) { |
|
| 1396 | + redirectexit('action=post;topic=' . $topic . '.0'); |
|
| 1335 | 1397 | } |
| 1336 | - elseif (empty($_POST) && !empty($topic)) |
|
| 1337 | - redirectexit('action=post;topic=' . $topic . '.0'); |
|
| 1338 | 1398 | |
| 1339 | 1399 | // No need! |
| 1340 | 1400 | $context['robot_no_index'] = true; |
@@ -1346,8 +1406,9 @@ discard block |
||
| 1346 | 1406 | $post_errors = array(); |
| 1347 | 1407 | |
| 1348 | 1408 | // If the session has timed out, let the user re-submit their form. |
| 1349 | - if (checkSession('post', '', false) != '') |
|
| 1350 | - $post_errors[] = 'session_timeout'; |
|
| 1409 | + if (checkSession('post', '', false) != '') { |
|
| 1410 | + $post_errors[] = 'session_timeout'; |
|
| 1411 | + } |
|
| 1351 | 1412 | |
| 1352 | 1413 | // Wrong verification code? |
| 1353 | 1414 | if (!$user_info['is_admin'] && !$user_info['is_mod'] && !empty($modSettings['posts_require_captcha']) && ($user_info['posts'] < $modSettings['posts_require_captcha'] || ($user_info['is_guest'] && $modSettings['posts_require_captcha'] == -1))) |
@@ -1357,33 +1418,38 @@ discard block |
||
| 1357 | 1418 | 'id' => 'post', |
| 1358 | 1419 | ); |
| 1359 | 1420 | $context['require_verification'] = create_control_verification($verificationOptions, true); |
| 1360 | - if (is_array($context['require_verification'])) |
|
| 1361 | - $post_errors = array_merge($post_errors, $context['require_verification']); |
|
| 1421 | + if (is_array($context['require_verification'])) { |
|
| 1422 | + $post_errors = array_merge($post_errors, $context['require_verification']); |
|
| 1423 | + } |
|
| 1362 | 1424 | } |
| 1363 | 1425 | |
| 1364 | 1426 | require_once($sourcedir . '/Subs-Post.php'); |
| 1365 | 1427 | loadLanguage('Post'); |
| 1366 | 1428 | |
| 1367 | 1429 | // Drafts enabled and needed? |
| 1368 | - if (!empty($modSettings['drafts_post_enabled']) && (isset($_POST['save_draft']) || isset($_POST['id_draft']))) |
|
| 1369 | - require_once($sourcedir . '/Drafts.php'); |
|
| 1430 | + if (!empty($modSettings['drafts_post_enabled']) && (isset($_POST['save_draft']) || isset($_POST['id_draft']))) { |
|
| 1431 | + require_once($sourcedir . '/Drafts.php'); |
|
| 1432 | + } |
|
| 1370 | 1433 | |
| 1371 | 1434 | // First check to see if they are trying to delete any current attachments. |
| 1372 | 1435 | if (isset($_POST['attach_del'])) |
| 1373 | 1436 | { |
| 1374 | 1437 | $keep_temp = array(); |
| 1375 | 1438 | $keep_ids = array(); |
| 1376 | - foreach ($_POST['attach_del'] as $dummy) |
|
| 1377 | - if (strpos($dummy, 'post_tmp_' . $user_info['id']) !== false) |
|
| 1439 | + foreach ($_POST['attach_del'] as $dummy) { |
|
| 1440 | + if (strpos($dummy, 'post_tmp_' . $user_info['id']) !== false) |
|
| 1378 | 1441 | $keep_temp[] = $dummy; |
| 1379 | - else |
|
| 1380 | - $keep_ids[] = (int) $dummy; |
|
| 1442 | + } |
|
| 1443 | + else { |
|
| 1444 | + $keep_ids[] = (int) $dummy; |
|
| 1445 | + } |
|
| 1381 | 1446 | |
| 1382 | - if (isset($_SESSION['temp_attachments'])) |
|
| 1383 | - foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
|
| 1447 | + if (isset($_SESSION['temp_attachments'])) { |
|
| 1448 | + foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
|
| 1384 | 1449 | { |
| 1385 | 1450 | if ((isset($_SESSION['temp_attachments']['post']['files'], $attachment['name']) && in_array($attachment['name'], $_SESSION['temp_attachments']['post']['files'])) || in_array($attachID, $keep_temp) || strpos($attachID, 'post_tmp_' . $user_info['id']) === false) |
| 1386 | 1451 | continue; |
| 1452 | + } |
|
| 1387 | 1453 | |
| 1388 | 1454 | unset($_SESSION['temp_attachments'][$attachID]); |
| 1389 | 1455 | unlink($attachment['tmp_name']); |
@@ -1425,24 +1491,28 @@ discard block |
||
| 1425 | 1491 | $smcFunc['db_free_result']($request); |
| 1426 | 1492 | |
| 1427 | 1493 | // Though the topic should be there, it might have vanished. |
| 1428 | - if (!is_array($topic_info)) |
|
| 1429 | - fatal_lang_error('topic_doesnt_exist', 404); |
|
| 1494 | + if (!is_array($topic_info)) { |
|
| 1495 | + fatal_lang_error('topic_doesnt_exist', 404); |
|
| 1496 | + } |
|
| 1430 | 1497 | |
| 1431 | 1498 | // Did this topic suddenly move? Just checking... |
| 1432 | - if ($topic_info['id_board'] != $board) |
|
| 1433 | - fatal_lang_error('not_a_topic'); |
|
| 1499 | + if ($topic_info['id_board'] != $board) { |
|
| 1500 | + fatal_lang_error('not_a_topic'); |
|
| 1501 | + } |
|
| 1434 | 1502 | } |
| 1435 | 1503 | |
| 1436 | 1504 | // Replying to a topic? |
| 1437 | 1505 | if (!empty($topic) && !isset($_REQUEST['msg'])) |
| 1438 | 1506 | { |
| 1439 | 1507 | // Don't allow a post if it's locked. |
| 1440 | - if ($topic_info['locked'] != 0 && !allowedTo('moderate_board')) |
|
| 1441 | - fatal_lang_error('topic_locked', false); |
|
| 1508 | + if ($topic_info['locked'] != 0 && !allowedTo('moderate_board')) { |
|
| 1509 | + fatal_lang_error('topic_locked', false); |
|
| 1510 | + } |
|
| 1442 | 1511 | |
| 1443 | 1512 | // Sorry, multiple polls aren't allowed... yet. You should stop giving me ideas :P. |
| 1444 | - if (isset($_REQUEST['poll']) && $topic_info['id_poll'] > 0) |
|
| 1445 | - unset($_REQUEST['poll']); |
|
| 1513 | + if (isset($_REQUEST['poll']) && $topic_info['id_poll'] > 0) { |
|
| 1514 | + unset($_REQUEST['poll']); |
|
| 1515 | + } |
|
| 1446 | 1516 | |
| 1447 | 1517 | // Do the permissions and approval stuff... |
| 1448 | 1518 | $becomesApproved = true; |
@@ -1458,44 +1528,43 @@ discard block |
||
| 1458 | 1528 | |
| 1459 | 1529 | // Set a nice session var... |
| 1460 | 1530 | $_SESSION['becomesUnapproved'] = true; |
| 1461 | - } |
|
| 1462 | - |
|
| 1463 | - elseif ($topic_info['id_member_started'] != $user_info['id']) |
|
| 1531 | + } elseif ($topic_info['id_member_started'] != $user_info['id']) |
|
| 1464 | 1532 | { |
| 1465 | - if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_any') && !allowedTo('post_reply_any')) |
|
| 1466 | - $becomesApproved = false; |
|
| 1467 | - |
|
| 1468 | - else |
|
| 1469 | - isAllowedTo('post_reply_any'); |
|
| 1470 | - } |
|
| 1471 | - elseif (!allowedTo('post_reply_any')) |
|
| 1533 | + if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_any') && !allowedTo('post_reply_any')) { |
|
| 1534 | + $becomesApproved = false; |
|
| 1535 | + } else { |
|
| 1536 | + isAllowedTo('post_reply_any'); |
|
| 1537 | + } |
|
| 1538 | + } elseif (!allowedTo('post_reply_any')) |
|
| 1472 | 1539 | { |
| 1473 | - if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_own') && !allowedTo('post_reply_own')) |
|
| 1474 | - $becomesApproved = false; |
|
| 1475 | - |
|
| 1476 | - else |
|
| 1477 | - isAllowedTo('post_reply_own'); |
|
| 1540 | + if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_own') && !allowedTo('post_reply_own')) { |
|
| 1541 | + $becomesApproved = false; |
|
| 1542 | + } else { |
|
| 1543 | + isAllowedTo('post_reply_own'); |
|
| 1544 | + } |
|
| 1478 | 1545 | } |
| 1479 | 1546 | |
| 1480 | 1547 | if (isset($_POST['lock'])) |
| 1481 | 1548 | { |
| 1482 | 1549 | // Nothing is changed to the lock. |
| 1483 | - if ((empty($topic_info['locked']) && empty($_POST['lock'])) || (!empty($_POST['lock']) && !empty($topic_info['locked']))) |
|
| 1484 | - unset($_POST['lock']); |
|
| 1550 | + if ((empty($topic_info['locked']) && empty($_POST['lock'])) || (!empty($_POST['lock']) && !empty($topic_info['locked']))) { |
|
| 1551 | + unset($_POST['lock']); |
|
| 1552 | + } |
|
| 1485 | 1553 | |
| 1486 | 1554 | // You're have no permission to lock this topic. |
| 1487 | - elseif (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $topic_info['id_member_started'])) |
|
| 1488 | - unset($_POST['lock']); |
|
| 1555 | + elseif (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $topic_info['id_member_started'])) { |
|
| 1556 | + unset($_POST['lock']); |
|
| 1557 | + } |
|
| 1489 | 1558 | |
| 1490 | 1559 | // You are allowed to (un)lock your own topic only. |
| 1491 | 1560 | elseif (!allowedTo('lock_any')) |
| 1492 | 1561 | { |
| 1493 | 1562 | // You cannot override a moderator lock. |
| 1494 | - if ($topic_info['locked'] == 1) |
|
| 1495 | - unset($_POST['lock']); |
|
| 1496 | - |
|
| 1497 | - else |
|
| 1498 | - $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
| 1563 | + if ($topic_info['locked'] == 1) { |
|
| 1564 | + unset($_POST['lock']); |
|
| 1565 | + } else { |
|
| 1566 | + $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
| 1567 | + } |
|
| 1499 | 1568 | } |
| 1500 | 1569 | // Hail mighty moderator, (un)lock this topic immediately. |
| 1501 | 1570 | else |
@@ -1503,19 +1572,21 @@ discard block |
||
| 1503 | 1572 | $_POST['lock'] = empty($_POST['lock']) ? 0 : 1; |
| 1504 | 1573 | |
| 1505 | 1574 | // Did someone (un)lock this while you were posting? |
| 1506 | - if (isset($_POST['already_locked']) && $_POST['already_locked'] != $topic_info['locked']) |
|
| 1507 | - $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'locked'; |
|
| 1575 | + if (isset($_POST['already_locked']) && $_POST['already_locked'] != $topic_info['locked']) { |
|
| 1576 | + $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'locked'; |
|
| 1577 | + } |
|
| 1508 | 1578 | } |
| 1509 | 1579 | } |
| 1510 | 1580 | |
| 1511 | 1581 | // So you wanna (un)sticky this...let's see. |
| 1512 | - if (isset($_POST['sticky']) && ($_POST['sticky'] == $topic_info['is_sticky'] || !allowedTo('make_sticky'))) |
|
| 1513 | - unset($_POST['sticky']); |
|
| 1514 | - elseif (isset($_POST['sticky'])) |
|
| 1582 | + if (isset($_POST['sticky']) && ($_POST['sticky'] == $topic_info['is_sticky'] || !allowedTo('make_sticky'))) { |
|
| 1583 | + unset($_POST['sticky']); |
|
| 1584 | + } elseif (isset($_POST['sticky'])) |
|
| 1515 | 1585 | { |
| 1516 | 1586 | // Did someone (un)sticky this while you were posting? |
| 1517 | - if (isset($_POST['already_sticky']) && $_POST['already_sticky'] != $topic_info['is_sticky']) |
|
| 1518 | - $post_errors[] = 'topic_' . (empty($topic_info['is_sticky']) ? 'un' : '') . 'sticky'; |
|
| 1587 | + if (isset($_POST['already_sticky']) && $_POST['already_sticky'] != $topic_info['is_sticky']) { |
|
| 1588 | + $post_errors[] = 'topic_' . (empty($topic_info['is_sticky']) ? 'un' : '') . 'sticky'; |
|
| 1589 | + } |
|
| 1519 | 1590 | } |
| 1520 | 1591 | |
| 1521 | 1592 | // If drafts are enabled, then pass this off |
@@ -1542,26 +1613,31 @@ discard block |
||
| 1542 | 1613 | |
| 1543 | 1614 | // Do like, the permissions, for safety and stuff... |
| 1544 | 1615 | $becomesApproved = true; |
| 1545 | - if ($modSettings['postmod_active'] && !allowedTo('post_new') && allowedTo('post_unapproved_topics')) |
|
| 1546 | - $becomesApproved = false; |
|
| 1547 | - else |
|
| 1548 | - isAllowedTo('post_new'); |
|
| 1616 | + if ($modSettings['postmod_active'] && !allowedTo('post_new') && allowedTo('post_unapproved_topics')) { |
|
| 1617 | + $becomesApproved = false; |
|
| 1618 | + } else { |
|
| 1619 | + isAllowedTo('post_new'); |
|
| 1620 | + } |
|
| 1549 | 1621 | |
| 1550 | 1622 | if (isset($_POST['lock'])) |
| 1551 | 1623 | { |
| 1552 | 1624 | // New topics are by default not locked. |
| 1553 | - if (empty($_POST['lock'])) |
|
| 1554 | - unset($_POST['lock']); |
|
| 1625 | + if (empty($_POST['lock'])) { |
|
| 1626 | + unset($_POST['lock']); |
|
| 1627 | + } |
|
| 1555 | 1628 | // Besides, you need permission. |
| 1556 | - elseif (!allowedTo(array('lock_any', 'lock_own'))) |
|
| 1557 | - unset($_POST['lock']); |
|
| 1629 | + elseif (!allowedTo(array('lock_any', 'lock_own'))) { |
|
| 1630 | + unset($_POST['lock']); |
|
| 1631 | + } |
|
| 1558 | 1632 | // A moderator-lock (1) can override a user-lock (2). |
| 1559 | - else |
|
| 1560 | - $_POST['lock'] = allowedTo('lock_any') ? 1 : 2; |
|
| 1633 | + else { |
|
| 1634 | + $_POST['lock'] = allowedTo('lock_any') ? 1 : 2; |
|
| 1635 | + } |
|
| 1561 | 1636 | } |
| 1562 | 1637 | |
| 1563 | - if (isset($_POST['sticky']) && (empty($_POST['sticky']) || !allowedTo('make_sticky'))) |
|
| 1564 | - unset($_POST['sticky']); |
|
| 1638 | + if (isset($_POST['sticky']) && (empty($_POST['sticky']) || !allowedTo('make_sticky'))) { |
|
| 1639 | + unset($_POST['sticky']); |
|
| 1640 | + } |
|
| 1565 | 1641 | |
| 1566 | 1642 | // Saving your new topic as a draft first? |
| 1567 | 1643 | if (!empty($modSettings['drafts_post_enabled']) && isset($_POST['save_draft'])) |
@@ -1586,31 +1662,37 @@ discard block |
||
| 1586 | 1662 | 'id_msg' => $_REQUEST['msg'], |
| 1587 | 1663 | ) |
| 1588 | 1664 | ); |
| 1589 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 1590 | - fatal_lang_error('cant_find_messages', false); |
|
| 1665 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 1666 | + fatal_lang_error('cant_find_messages', false); |
|
| 1667 | + } |
|
| 1591 | 1668 | $row = $smcFunc['db_fetch_assoc']($request); |
| 1592 | 1669 | $smcFunc['db_free_result']($request); |
| 1593 | 1670 | |
| 1594 | - if (!empty($topic_info['locked']) && !allowedTo('moderate_board')) |
|
| 1595 | - fatal_lang_error('topic_locked', false); |
|
| 1671 | + if (!empty($topic_info['locked']) && !allowedTo('moderate_board')) { |
|
| 1672 | + fatal_lang_error('topic_locked', false); |
|
| 1673 | + } |
|
| 1596 | 1674 | |
| 1597 | 1675 | if (isset($_POST['lock'])) |
| 1598 | 1676 | { |
| 1599 | 1677 | // Nothing changes to the lock status. |
| 1600 | - if ((empty($_POST['lock']) && empty($topic_info['locked'])) || (!empty($_POST['lock']) && !empty($topic_info['locked']))) |
|
| 1601 | - unset($_POST['lock']); |
|
| 1678 | + if ((empty($_POST['lock']) && empty($topic_info['locked'])) || (!empty($_POST['lock']) && !empty($topic_info['locked']))) { |
|
| 1679 | + unset($_POST['lock']); |
|
| 1680 | + } |
|
| 1602 | 1681 | // You're simply not allowed to (un)lock this. |
| 1603 | - elseif (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $topic_info['id_member_started'])) |
|
| 1604 | - unset($_POST['lock']); |
|
| 1682 | + elseif (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $topic_info['id_member_started'])) { |
|
| 1683 | + unset($_POST['lock']); |
|
| 1684 | + } |
|
| 1605 | 1685 | // You're only allowed to lock your own topics. |
| 1606 | 1686 | elseif (!allowedTo('lock_any')) |
| 1607 | 1687 | { |
| 1608 | 1688 | // You're not allowed to break a moderator's lock. |
| 1609 | - if ($topic_info['locked'] == 1) |
|
| 1610 | - unset($_POST['lock']); |
|
| 1689 | + if ($topic_info['locked'] == 1) { |
|
| 1690 | + unset($_POST['lock']); |
|
| 1691 | + } |
|
| 1611 | 1692 | // Lock it with a soft lock or unlock it. |
| 1612 | - else |
|
| 1613 | - $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
| 1693 | + else { |
|
| 1694 | + $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
| 1695 | + } |
|
| 1614 | 1696 | } |
| 1615 | 1697 | // You must be the moderator. |
| 1616 | 1698 | else |
@@ -1618,44 +1700,46 @@ discard block |
||
| 1618 | 1700 | $_POST['lock'] = empty($_POST['lock']) ? 0 : 1; |
| 1619 | 1701 | |
| 1620 | 1702 | // Did someone (un)lock this while you were posting? |
| 1621 | - if (isset($_POST['already_locked']) && $_POST['already_locked'] != $topic_info['locked']) |
|
| 1622 | - $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'locked'; |
|
| 1703 | + if (isset($_POST['already_locked']) && $_POST['already_locked'] != $topic_info['locked']) { |
|
| 1704 | + $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'locked'; |
|
| 1705 | + } |
|
| 1623 | 1706 | } |
| 1624 | 1707 | } |
| 1625 | 1708 | |
| 1626 | 1709 | // Change the sticky status of this topic? |
| 1627 | - if (isset($_POST['sticky']) && (!allowedTo('make_sticky') || $_POST['sticky'] == $topic_info['is_sticky'])) |
|
| 1628 | - unset($_POST['sticky']); |
|
| 1629 | - elseif (isset($_POST['sticky'])) |
|
| 1710 | + if (isset($_POST['sticky']) && (!allowedTo('make_sticky') || $_POST['sticky'] == $topic_info['is_sticky'])) { |
|
| 1711 | + unset($_POST['sticky']); |
|
| 1712 | + } elseif (isset($_POST['sticky'])) |
|
| 1630 | 1713 | { |
| 1631 | 1714 | // Did someone (un)sticky this while you were posting? |
| 1632 | - if (isset($_POST['already_sticky']) && $_POST['already_sticky'] != $topic_info['is_sticky']) |
|
| 1633 | - $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'stickied'; |
|
| 1715 | + if (isset($_POST['already_sticky']) && $_POST['already_sticky'] != $topic_info['is_sticky']) { |
|
| 1716 | + $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'stickied'; |
|
| 1717 | + } |
|
| 1634 | 1718 | } |
| 1635 | 1719 | |
| 1636 | 1720 | if ($row['id_member'] == $user_info['id'] && !allowedTo('modify_any')) |
| 1637 | 1721 | { |
| 1638 | - if ((!$modSettings['postmod_active'] || $row['approved']) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) |
|
| 1639 | - fatal_lang_error('modify_post_time_passed', false); |
|
| 1640 | - elseif ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('modify_own')) |
|
| 1641 | - isAllowedTo('modify_replies'); |
|
| 1642 | - else |
|
| 1643 | - isAllowedTo('modify_own'); |
|
| 1644 | - } |
|
| 1645 | - elseif ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('modify_any')) |
|
| 1722 | + if ((!$modSettings['postmod_active'] || $row['approved']) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) { |
|
| 1723 | + fatal_lang_error('modify_post_time_passed', false); |
|
| 1724 | + } elseif ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('modify_own')) { |
|
| 1725 | + isAllowedTo('modify_replies'); |
|
| 1726 | + } else { |
|
| 1727 | + isAllowedTo('modify_own'); |
|
| 1728 | + } |
|
| 1729 | + } elseif ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('modify_any')) |
|
| 1646 | 1730 | { |
| 1647 | 1731 | isAllowedTo('modify_replies'); |
| 1648 | 1732 | |
| 1649 | 1733 | // If you're modifying a reply, I say it better be logged... |
| 1650 | 1734 | $moderationAction = true; |
| 1651 | - } |
|
| 1652 | - else |
|
| 1735 | + } else |
|
| 1653 | 1736 | { |
| 1654 | 1737 | isAllowedTo('modify_any'); |
| 1655 | 1738 | |
| 1656 | 1739 | // Log it, assuming you're not modifying your own post. |
| 1657 | - if ($row['id_member'] != $user_info['id']) |
|
| 1658 | - $moderationAction = true; |
|
| 1740 | + if ($row['id_member'] != $user_info['id']) { |
|
| 1741 | + $moderationAction = true; |
|
| 1742 | + } |
|
| 1659 | 1743 | } |
| 1660 | 1744 | |
| 1661 | 1745 | // If drafts are enabled, then lets send this off to save |
@@ -1692,20 +1776,24 @@ discard block |
||
| 1692 | 1776 | $_POST['guestname'] = !isset($_POST['guestname']) ? '' : trim($_POST['guestname']); |
| 1693 | 1777 | $_POST['email'] = !isset($_POST['email']) ? '' : trim($_POST['email']); |
| 1694 | 1778 | |
| 1695 | - if ($_POST['guestname'] == '' || $_POST['guestname'] == '_') |
|
| 1696 | - $post_errors[] = 'no_name'; |
|
| 1697 | - if ($smcFunc['strlen']($_POST['guestname']) > 25) |
|
| 1698 | - $post_errors[] = 'long_name'; |
|
| 1779 | + if ($_POST['guestname'] == '' || $_POST['guestname'] == '_') { |
|
| 1780 | + $post_errors[] = 'no_name'; |
|
| 1781 | + } |
|
| 1782 | + if ($smcFunc['strlen']($_POST['guestname']) > 25) { |
|
| 1783 | + $post_errors[] = 'long_name'; |
|
| 1784 | + } |
|
| 1699 | 1785 | |
| 1700 | 1786 | if (empty($modSettings['guest_post_no_email'])) |
| 1701 | 1787 | { |
| 1702 | 1788 | // Only check if they changed it! |
| 1703 | 1789 | if (!isset($row) || $row['poster_email'] != $_POST['email']) |
| 1704 | 1790 | { |
| 1705 | - if (!allowedTo('moderate_forum') && (!isset($_POST['email']) || $_POST['email'] == '')) |
|
| 1706 | - $post_errors[] = 'no_email'; |
|
| 1707 | - if (!allowedTo('moderate_forum') && !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) |
|
| 1708 | - $post_errors[] = 'bad_email'; |
|
| 1791 | + if (!allowedTo('moderate_forum') && (!isset($_POST['email']) || $_POST['email'] == '')) { |
|
| 1792 | + $post_errors[] = 'no_email'; |
|
| 1793 | + } |
|
| 1794 | + if (!allowedTo('moderate_forum') && !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) { |
|
| 1795 | + $post_errors[] = 'bad_email'; |
|
| 1796 | + } |
|
| 1709 | 1797 | } |
| 1710 | 1798 | |
| 1711 | 1799 | // Now make sure this email address is not banned from posting. |
@@ -1721,75 +1809,89 @@ discard block |
||
| 1721 | 1809 | } |
| 1722 | 1810 | |
| 1723 | 1811 | // Coming from the quickReply? |
| 1724 | - if (isset($_POST['quickReply'])) |
|
| 1725 | - $_POST['message'] = $_POST['quickReply']; |
|
| 1812 | + if (isset($_POST['quickReply'])) { |
|
| 1813 | + $_POST['message'] = $_POST['quickReply']; |
|
| 1814 | + } |
|
| 1726 | 1815 | |
| 1727 | 1816 | // Check the subject and message. |
| 1728 | - if (!isset($_POST['subject']) || $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['subject'])) === '') |
|
| 1729 | - $post_errors[] = 'no_subject'; |
|
| 1730 | - if (!isset($_POST['message']) || $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['message']), ENT_QUOTES) === '') |
|
| 1731 | - $post_errors[] = 'no_message'; |
|
| 1732 | - elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_POST['message']) > $modSettings['max_messageLength']) |
|
| 1733 | - $post_errors[] = array('long_message', array($modSettings['max_messageLength'])); |
|
| 1734 | - else |
|
| 1817 | + if (!isset($_POST['subject']) || $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['subject'])) === '') { |
|
| 1818 | + $post_errors[] = 'no_subject'; |
|
| 1819 | + } |
|
| 1820 | + if (!isset($_POST['message']) || $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['message']), ENT_QUOTES) === '') { |
|
| 1821 | + $post_errors[] = 'no_message'; |
|
| 1822 | + } elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_POST['message']) > $modSettings['max_messageLength']) { |
|
| 1823 | + $post_errors[] = array('long_message', array($modSettings['max_messageLength'])); |
|
| 1824 | + } else |
|
| 1735 | 1825 | { |
| 1736 | 1826 | // Prepare the message a bit for some additional testing. |
| 1737 | 1827 | $_POST['message'] = $smcFunc['htmlspecialchars']($_POST['message'], ENT_QUOTES); |
| 1738 | 1828 | |
| 1739 | 1829 | // Preparse code. (Zef) |
| 1740 | - if ($user_info['is_guest']) |
|
| 1741 | - $user_info['name'] = $_POST['guestname']; |
|
| 1830 | + if ($user_info['is_guest']) { |
|
| 1831 | + $user_info['name'] = $_POST['guestname']; |
|
| 1832 | + } |
|
| 1742 | 1833 | preparsecode($_POST['message']); |
| 1743 | 1834 | |
| 1744 | 1835 | // Let's see if there's still some content left without the tags. |
| 1745 | - if ($smcFunc['htmltrim'](strip_tags(parse_bbc($_POST['message'], false), implode('', $context['allowed_html_tags']))) === '' && (!allowedTo('admin_forum') || strpos($_POST['message'], '[html]') === false)) |
|
| 1746 | - $post_errors[] = 'no_message'; |
|
| 1836 | + if ($smcFunc['htmltrim'](strip_tags(parse_bbc($_POST['message'], false), implode('', $context['allowed_html_tags']))) === '' && (!allowedTo('admin_forum') || strpos($_POST['message'], '[html]') === false)) { |
|
| 1837 | + $post_errors[] = 'no_message'; |
|
| 1838 | + } |
|
| 1839 | + } |
|
| 1840 | + if (isset($_POST['calendar']) && !isset($_REQUEST['deleteevent']) && $smcFunc['htmltrim']($_POST['evtitle']) === '') { |
|
| 1841 | + $post_errors[] = 'no_event'; |
|
| 1747 | 1842 | } |
| 1748 | - if (isset($_POST['calendar']) && !isset($_REQUEST['deleteevent']) && $smcFunc['htmltrim']($_POST['evtitle']) === '') |
|
| 1749 | - $post_errors[] = 'no_event'; |
|
| 1750 | 1843 | // You are not! |
| 1751 | - if (isset($_POST['message']) && strtolower($_POST['message']) == 'i am the administrator.' && !$user_info['is_admin']) |
|
| 1752 | - fatal_error('Knave! Masquerader! Charlatan!', false); |
|
| 1844 | + if (isset($_POST['message']) && strtolower($_POST['message']) == 'i am the administrator.' && !$user_info['is_admin']) { |
|
| 1845 | + fatal_error('Knave! Masquerader! Charlatan!', false); |
|
| 1846 | + } |
|
| 1753 | 1847 | |
| 1754 | 1848 | // Validate the poll... |
| 1755 | 1849 | if (isset($_REQUEST['poll']) && $modSettings['pollMode'] == '1') |
| 1756 | 1850 | { |
| 1757 | - if (!empty($topic) && !isset($_REQUEST['msg'])) |
|
| 1758 | - fatal_lang_error('no_access', false); |
|
| 1851 | + if (!empty($topic) && !isset($_REQUEST['msg'])) { |
|
| 1852 | + fatal_lang_error('no_access', false); |
|
| 1853 | + } |
|
| 1759 | 1854 | |
| 1760 | 1855 | // This is a new topic... so it's a new poll. |
| 1761 | - if (empty($topic)) |
|
| 1762 | - isAllowedTo('poll_post'); |
|
| 1856 | + if (empty($topic)) { |
|
| 1857 | + isAllowedTo('poll_post'); |
|
| 1858 | + } |
|
| 1763 | 1859 | // Can you add to your own topics? |
| 1764 | - elseif ($user_info['id'] == $topic_info['id_member_started'] && !allowedTo('poll_add_any')) |
|
| 1765 | - isAllowedTo('poll_add_own'); |
|
| 1860 | + elseif ($user_info['id'] == $topic_info['id_member_started'] && !allowedTo('poll_add_any')) { |
|
| 1861 | + isAllowedTo('poll_add_own'); |
|
| 1862 | + } |
|
| 1766 | 1863 | // Can you add polls to any topic, then? |
| 1767 | - else |
|
| 1768 | - isAllowedTo('poll_add_any'); |
|
| 1864 | + else { |
|
| 1865 | + isAllowedTo('poll_add_any'); |
|
| 1866 | + } |
|
| 1769 | 1867 | |
| 1770 | - if (!isset($_POST['question']) || trim($_POST['question']) == '') |
|
| 1771 | - $post_errors[] = 'no_question'; |
|
| 1868 | + if (!isset($_POST['question']) || trim($_POST['question']) == '') { |
|
| 1869 | + $post_errors[] = 'no_question'; |
|
| 1870 | + } |
|
| 1772 | 1871 | |
| 1773 | 1872 | $_POST['options'] = empty($_POST['options']) ? array() : htmltrim__recursive($_POST['options']); |
| 1774 | 1873 | |
| 1775 | 1874 | // Get rid of empty ones. |
| 1776 | - foreach ($_POST['options'] as $k => $option) |
|
| 1777 | - if ($option == '') |
|
| 1875 | + foreach ($_POST['options'] as $k => $option) { |
|
| 1876 | + if ($option == '') |
|
| 1778 | 1877 | unset($_POST['options'][$k], $_POST['options'][$k]); |
| 1878 | + } |
|
| 1779 | 1879 | |
| 1780 | 1880 | // What are you going to vote between with one choice?!? |
| 1781 | - if (count($_POST['options']) < 2) |
|
| 1782 | - $post_errors[] = 'poll_few'; |
|
| 1783 | - elseif (count($_POST['options']) > 256) |
|
| 1784 | - $post_errors[] = 'poll_many'; |
|
| 1881 | + if (count($_POST['options']) < 2) { |
|
| 1882 | + $post_errors[] = 'poll_few'; |
|
| 1883 | + } elseif (count($_POST['options']) > 256) { |
|
| 1884 | + $post_errors[] = 'poll_many'; |
|
| 1885 | + } |
|
| 1785 | 1886 | } |
| 1786 | 1887 | |
| 1787 | 1888 | if ($posterIsGuest) |
| 1788 | 1889 | { |
| 1789 | 1890 | // If user is a guest, make sure the chosen name isn't taken. |
| 1790 | 1891 | require_once($sourcedir . '/Subs-Members.php'); |
| 1791 | - if (isReservedName($_POST['guestname'], 0, true, false) && (!isset($row['poster_name']) || $_POST['guestname'] != $row['poster_name'])) |
|
| 1792 | - $post_errors[] = 'bad_name'; |
|
| 1892 | + if (isReservedName($_POST['guestname'], 0, true, false) && (!isset($row['poster_name']) || $_POST['guestname'] != $row['poster_name'])) { |
|
| 1893 | + $post_errors[] = 'bad_name'; |
|
| 1894 | + } |
|
| 1793 | 1895 | } |
| 1794 | 1896 | // If the user isn't a guest, get his or her name and email. |
| 1795 | 1897 | elseif (!isset($_REQUEST['msg'])) |
@@ -1820,8 +1922,9 @@ discard block |
||
| 1820 | 1922 | } |
| 1821 | 1923 | |
| 1822 | 1924 | // Make sure the user isn't spamming the board. |
| 1823 | - if (!isset($_REQUEST['msg'])) |
|
| 1824 | - spamProtection('post'); |
|
| 1925 | + if (!isset($_REQUEST['msg'])) { |
|
| 1926 | + spamProtection('post'); |
|
| 1927 | + } |
|
| 1825 | 1928 | |
| 1826 | 1929 | // At about this point, we're posting and that's that. |
| 1827 | 1930 | ignore_user_abort(true); |
@@ -1834,32 +1937,36 @@ discard block |
||
| 1834 | 1937 | $_POST['modify_reason'] = empty($_POST['modify_reason']) ? '' : strtr($smcFunc['htmlspecialchars']($_POST['modify_reason']), array("\r" => '', "\n" => '', "\t" => '')); |
| 1835 | 1938 | |
| 1836 | 1939 | // At this point, we want to make sure the subject isn't too long. |
| 1837 | - if ($smcFunc['strlen']($_POST['subject']) > 100) |
|
| 1838 | - $_POST['subject'] = $smcFunc['substr']($_POST['subject'], 0, 100); |
|
| 1940 | + if ($smcFunc['strlen']($_POST['subject']) > 100) { |
|
| 1941 | + $_POST['subject'] = $smcFunc['substr']($_POST['subject'], 0, 100); |
|
| 1942 | + } |
|
| 1839 | 1943 | |
| 1840 | 1944 | // Same with the "why did you edit this" text. |
| 1841 | - if ($smcFunc['strlen']($_POST['modify_reason']) > 100) |
|
| 1842 | - $_POST['modify_reason'] = $smcFunc['substr']($_POST['modify_reason'], 0, 100); |
|
| 1945 | + if ($smcFunc['strlen']($_POST['modify_reason']) > 100) { |
|
| 1946 | + $_POST['modify_reason'] = $smcFunc['substr']($_POST['modify_reason'], 0, 100); |
|
| 1947 | + } |
|
| 1843 | 1948 | |
| 1844 | 1949 | // Make the poll... |
| 1845 | 1950 | if (isset($_REQUEST['poll'])) |
| 1846 | 1951 | { |
| 1847 | 1952 | // Make sure that the user has not entered a ridiculous number of options.. |
| 1848 | - if (empty($_POST['poll_max_votes']) || $_POST['poll_max_votes'] <= 0) |
|
| 1849 | - $_POST['poll_max_votes'] = 1; |
|
| 1850 | - elseif ($_POST['poll_max_votes'] > count($_POST['options'])) |
|
| 1851 | - $_POST['poll_max_votes'] = count($_POST['options']); |
|
| 1852 | - else |
|
| 1853 | - $_POST['poll_max_votes'] = (int) $_POST['poll_max_votes']; |
|
| 1953 | + if (empty($_POST['poll_max_votes']) || $_POST['poll_max_votes'] <= 0) { |
|
| 1954 | + $_POST['poll_max_votes'] = 1; |
|
| 1955 | + } elseif ($_POST['poll_max_votes'] > count($_POST['options'])) { |
|
| 1956 | + $_POST['poll_max_votes'] = count($_POST['options']); |
|
| 1957 | + } else { |
|
| 1958 | + $_POST['poll_max_votes'] = (int) $_POST['poll_max_votes']; |
|
| 1959 | + } |
|
| 1854 | 1960 | |
| 1855 | 1961 | $_POST['poll_expire'] = (int) $_POST['poll_expire']; |
| 1856 | 1962 | $_POST['poll_expire'] = $_POST['poll_expire'] > 9999 ? 9999 : ($_POST['poll_expire'] < 0 ? 0 : $_POST['poll_expire']); |
| 1857 | 1963 | |
| 1858 | 1964 | // Just set it to zero if it's not there.. |
| 1859 | - if (!isset($_POST['poll_hide'])) |
|
| 1860 | - $_POST['poll_hide'] = 0; |
|
| 1861 | - else |
|
| 1862 | - $_POST['poll_hide'] = (int) $_POST['poll_hide']; |
|
| 1965 | + if (!isset($_POST['poll_hide'])) { |
|
| 1966 | + $_POST['poll_hide'] = 0; |
|
| 1967 | + } else { |
|
| 1968 | + $_POST['poll_hide'] = (int) $_POST['poll_hide']; |
|
| 1969 | + } |
|
| 1863 | 1970 | $_POST['poll_change_vote'] = isset($_POST['poll_change_vote']) ? 1 : 0; |
| 1864 | 1971 | |
| 1865 | 1972 | $_POST['poll_guest_vote'] = isset($_POST['poll_guest_vote']) ? 1 : 0; |
@@ -1868,16 +1975,19 @@ discard block |
||
| 1868 | 1975 | { |
| 1869 | 1976 | require_once($sourcedir . '/Subs-Members.php'); |
| 1870 | 1977 | $allowedVoteGroups = groupsAllowedTo('poll_vote', $board); |
| 1871 | - if (!in_array(-1, $allowedVoteGroups['allowed'])) |
|
| 1872 | - $_POST['poll_guest_vote'] = 0; |
|
| 1978 | + if (!in_array(-1, $allowedVoteGroups['allowed'])) { |
|
| 1979 | + $_POST['poll_guest_vote'] = 0; |
|
| 1980 | + } |
|
| 1873 | 1981 | } |
| 1874 | 1982 | |
| 1875 | 1983 | // If the user tries to set the poll too far in advance, don't let them. |
| 1876 | - if (!empty($_POST['poll_expire']) && $_POST['poll_expire'] < 1) |
|
| 1877 | - fatal_lang_error('poll_range_error', false); |
|
| 1984 | + if (!empty($_POST['poll_expire']) && $_POST['poll_expire'] < 1) { |
|
| 1985 | + fatal_lang_error('poll_range_error', false); |
|
| 1986 | + } |
|
| 1878 | 1987 | // Don't allow them to select option 2 for hidden results if it's not time limited. |
| 1879 | - elseif (empty($_POST['poll_expire']) && $_POST['poll_hide'] == 2) |
|
| 1880 | - $_POST['poll_hide'] = 1; |
|
| 1988 | + elseif (empty($_POST['poll_expire']) && $_POST['poll_hide'] == 2) { |
|
| 1989 | + $_POST['poll_hide'] = 1; |
|
| 1990 | + } |
|
| 1881 | 1991 | |
| 1882 | 1992 | // Clean up the question and answers. |
| 1883 | 1993 | $_POST['question'] = $smcFunc['htmlspecialchars']($_POST['question']); |
@@ -1891,13 +2001,15 @@ discard block |
||
| 1891 | 2001 | { |
| 1892 | 2002 | $attachIDs = array(); |
| 1893 | 2003 | $attach_errors = array(); |
| 1894 | - if (!empty($context['we_are_history'])) |
|
| 1895 | - $attach_errors[] = '<dd>' . $txt['error_temp_attachments_flushed'] . '<br><br></dd>'; |
|
| 2004 | + if (!empty($context['we_are_history'])) { |
|
| 2005 | + $attach_errors[] = '<dd>' . $txt['error_temp_attachments_flushed'] . '<br><br></dd>'; |
|
| 2006 | + } |
|
| 1896 | 2007 | |
| 1897 | 2008 | foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
| 1898 | 2009 | { |
| 1899 | - if ($attachID != 'initial_error' && strpos($attachID, 'post_tmp_' . $user_info['id']) === false) |
|
| 1900 | - continue; |
|
| 2010 | + if ($attachID != 'initial_error' && strpos($attachID, 'post_tmp_' . $user_info['id']) === false) { |
|
| 2011 | + continue; |
|
| 2012 | + } |
|
| 1901 | 2013 | |
| 1902 | 2014 | // If there was an initial error just show that message. |
| 1903 | 2015 | if ($attachID == 'initial_error') |
@@ -1926,12 +2038,13 @@ discard block |
||
| 1926 | 2038 | if (createAttachment($attachmentOptions)) |
| 1927 | 2039 | { |
| 1928 | 2040 | $attachIDs[] = $attachmentOptions['id']; |
| 1929 | - if (!empty($attachmentOptions['thumb'])) |
|
| 1930 | - $attachIDs[] = $attachmentOptions['thumb']; |
|
| 2041 | + if (!empty($attachmentOptions['thumb'])) { |
|
| 2042 | + $attachIDs[] = $attachmentOptions['thumb']; |
|
| 2043 | + } |
|
| 1931 | 2044 | } |
| 2045 | + } else { |
|
| 2046 | + $attach_errors[] = '<dt> </dt>'; |
|
| 1932 | 2047 | } |
| 1933 | - else |
|
| 1934 | - $attach_errors[] = '<dt> </dt>'; |
|
| 1935 | 2048 | |
| 1936 | 2049 | if (!empty($attachmentOptions['errors'])) |
| 1937 | 2050 | { |
@@ -1943,14 +2056,16 @@ discard block |
||
| 1943 | 2056 | if (!is_array($error)) |
| 1944 | 2057 | { |
| 1945 | 2058 | $attach_errors[] = '<dd>' . $txt[$error] . '</dd>'; |
| 1946 | - if (in_array($error, $log_these)) |
|
| 1947 | - log_error($attachment['name'] . ': ' . $txt[$error], 'critical'); |
|
| 2059 | + if (in_array($error, $log_these)) { |
|
| 2060 | + log_error($attachment['name'] . ': ' . $txt[$error], 'critical'); |
|
| 2061 | + } |
|
| 2062 | + } else { |
|
| 2063 | + $attach_errors[] = '<dd>' . vsprintf($txt[$error[0]], $error[1]) . '</dd>'; |
|
| 1948 | 2064 | } |
| 1949 | - else |
|
| 1950 | - $attach_errors[] = '<dd>' . vsprintf($txt[$error[0]], $error[1]) . '</dd>'; |
|
| 1951 | 2065 | } |
| 1952 | - if (file_exists($attachment['tmp_name'])) |
|
| 1953 | - unlink($attachment['tmp_name']); |
|
| 2066 | + if (file_exists($attachment['tmp_name'])) { |
|
| 2067 | + unlink($attachment['tmp_name']); |
|
| 2068 | + } |
|
| 1954 | 2069 | } |
| 1955 | 2070 | } |
| 1956 | 2071 | unset($_SESSION['temp_attachments']); |
@@ -1991,24 +2106,24 @@ discard block |
||
| 1991 | 2106 | ); |
| 1992 | 2107 | |
| 1993 | 2108 | call_integration_hook('integrate_poll_add_edit', array($id_poll, false)); |
| 2109 | + } else { |
|
| 2110 | + $id_poll = 0; |
|
| 1994 | 2111 | } |
| 1995 | - else |
|
| 1996 | - $id_poll = 0; |
|
| 1997 | 2112 | |
| 1998 | 2113 | // Creating a new topic? |
| 1999 | 2114 | $newTopic = empty($_REQUEST['msg']) && empty($topic); |
| 2000 | 2115 | |
| 2001 | 2116 | // Check the icon. |
| 2002 | - if (!isset($_POST['icon'])) |
|
| 2003 | - $_POST['icon'] = 'xx'; |
|
| 2004 | - |
|
| 2005 | - else |
|
| 2117 | + if (!isset($_POST['icon'])) { |
|
| 2118 | + $_POST['icon'] = 'xx'; |
|
| 2119 | + } else |
|
| 2006 | 2120 | { |
| 2007 | 2121 | $_POST['icon'] = $smcFunc['htmlspecialchars']($_POST['icon']); |
| 2008 | 2122 | |
| 2009 | 2123 | // Need to figure it out if this is a valid icon name. |
| 2010 | - if ((!file_exists($settings['theme_dir'] . '/images/post/' . $_POST['icon'] . '.png')) && (!file_exists($settings['default_theme_dir'] . '/images/post/' . $_POST['icon'] . '.png'))) |
|
| 2011 | - $_POST['icon'] = 'xx'; |
|
| 2124 | + if ((!file_exists($settings['theme_dir'] . '/images/post/' . $_POST['icon'] . '.png')) && (!file_exists($settings['default_theme_dir'] . '/images/post/' . $_POST['icon'] . '.png'))) { |
|
| 2125 | + $_POST['icon'] = 'xx'; |
|
| 2126 | + } |
|
| 2012 | 2127 | } |
| 2013 | 2128 | |
| 2014 | 2129 | // Collect all parameters for the creation or modification of a post. |
@@ -2049,8 +2164,9 @@ discard block |
||
| 2049 | 2164 | } |
| 2050 | 2165 | |
| 2051 | 2166 | // This will save some time... |
| 2052 | - if (empty($approve_has_changed)) |
|
| 2053 | - unset($msgOptions['approved']); |
|
| 2167 | + if (empty($approve_has_changed)) { |
|
| 2168 | + unset($msgOptions['approved']); |
|
| 2169 | + } |
|
| 2054 | 2170 | |
| 2055 | 2171 | modifyPost($msgOptions, $topicOptions, $posterOptions); |
| 2056 | 2172 | } |
@@ -2059,8 +2175,9 @@ discard block |
||
| 2059 | 2175 | { |
| 2060 | 2176 | createPost($msgOptions, $topicOptions, $posterOptions); |
| 2061 | 2177 | |
| 2062 | - if (isset($topicOptions['id'])) |
|
| 2063 | - $topic = $topicOptions['id']; |
|
| 2178 | + if (isset($topicOptions['id'])) { |
|
| 2179 | + $topic = $topicOptions['id']; |
|
| 2180 | + } |
|
| 2064 | 2181 | } |
| 2065 | 2182 | |
| 2066 | 2183 | // Assign the previously uploaded attachments to the brand new message. |
@@ -2072,8 +2189,9 @@ discard block |
||
| 2072 | 2189 | } |
| 2073 | 2190 | |
| 2074 | 2191 | // If we had a draft for this, its time to remove it since it was just posted |
| 2075 | - if (!empty($modSettings['drafts_post_enabled']) && !empty($_POST['id_draft'])) |
|
| 2076 | - DeleteDraft($_POST['id_draft']); |
|
| 2192 | + if (!empty($modSettings['drafts_post_enabled']) && !empty($_POST['id_draft'])) { |
|
| 2193 | + DeleteDraft($_POST['id_draft']); |
|
| 2194 | + } |
|
| 2077 | 2195 | |
| 2078 | 2196 | // Editing or posting an event? |
| 2079 | 2197 | if (isset($_POST['calendar']) && (!isset($_REQUEST['eventid']) || $_REQUEST['eventid'] == -1)) |
@@ -2092,8 +2210,7 @@ discard block |
||
| 2092 | 2210 | 'member' => $user_info['id'], |
| 2093 | 2211 | ); |
| 2094 | 2212 | insertEvent($eventOptions); |
| 2095 | - } |
|
| 2096 | - elseif (isset($_POST['calendar'])) |
|
| 2213 | + } elseif (isset($_POST['calendar'])) |
|
| 2097 | 2214 | { |
| 2098 | 2215 | $_REQUEST['eventid'] = (int) $_REQUEST['eventid']; |
| 2099 | 2216 | |
@@ -2121,14 +2238,15 @@ discard block |
||
| 2121 | 2238 | } |
| 2122 | 2239 | |
| 2123 | 2240 | // Delete it? |
| 2124 | - if (isset($_REQUEST['deleteevent'])) |
|
| 2125 | - $smcFunc['db_query']('', ' |
|
| 2241 | + if (isset($_REQUEST['deleteevent'])) { |
|
| 2242 | + $smcFunc['db_query']('', ' |
|
| 2126 | 2243 | DELETE FROM {db_prefix}calendar |
| 2127 | 2244 | WHERE id_event = {int:id_event}', |
| 2128 | 2245 | array( |
| 2129 | 2246 | 'id_event' => $_REQUEST['eventid'], |
| 2130 | 2247 | ) |
| 2131 | 2248 | ); |
| 2249 | + } |
|
| 2132 | 2250 | // ... or just update it? |
| 2133 | 2251 | else |
| 2134 | 2252 | { |
@@ -2170,9 +2288,8 @@ discard block |
||
| 2170 | 2288 | array($user_info['id'], $topic, 0), |
| 2171 | 2289 | array('id_member', 'id_topic', 'id_board') |
| 2172 | 2290 | ); |
| 2173 | - } |
|
| 2174 | - elseif (!$newTopic) |
|
| 2175 | - $smcFunc['db_query']('', ' |
|
| 2291 | + } elseif (!$newTopic) { |
|
| 2292 | + $smcFunc['db_query']('', ' |
|
| 2176 | 2293 | DELETE FROM {db_prefix}log_notify |
| 2177 | 2294 | WHERE id_member = {int:current_member} |
| 2178 | 2295 | AND id_topic = {int:current_topic}', |
@@ -2181,16 +2298,20 @@ discard block |
||
| 2181 | 2298 | 'current_topic' => $topic, |
| 2182 | 2299 | ) |
| 2183 | 2300 | ); |
| 2301 | + } |
|
| 2184 | 2302 | |
| 2185 | 2303 | // Log an act of moderation - modifying. |
| 2186 | - if (!empty($moderationAction)) |
|
| 2187 | - logAction('modify', array('topic' => $topic, 'message' => (int) $_REQUEST['msg'], 'member' => $row['id_member'], 'board' => $board)); |
|
| 2304 | + if (!empty($moderationAction)) { |
|
| 2305 | + logAction('modify', array('topic' => $topic, 'message' => (int) $_REQUEST['msg'], 'member' => $row['id_member'], 'board' => $board)); |
|
| 2306 | + } |
|
| 2188 | 2307 | |
| 2189 | - if (isset($_POST['lock']) && $_POST['lock'] != 2) |
|
| 2190 | - logAction(empty($_POST['lock']) ? 'unlock' : 'lock', array('topic' => $topicOptions['id'], 'board' => $topicOptions['board'])); |
|
| 2308 | + if (isset($_POST['lock']) && $_POST['lock'] != 2) { |
|
| 2309 | + logAction(empty($_POST['lock']) ? 'unlock' : 'lock', array('topic' => $topicOptions['id'], 'board' => $topicOptions['board'])); |
|
| 2310 | + } |
|
| 2191 | 2311 | |
| 2192 | - if (isset($_POST['sticky'])) |
|
| 2193 | - logAction(empty($_POST['sticky']) ? 'unsticky' : 'sticky', array('topic' => $topicOptions['id'], 'board' => $topicOptions['board'])); |
|
| 2312 | + if (isset($_POST['sticky'])) { |
|
| 2313 | + logAction(empty($_POST['sticky']) ? 'unsticky' : 'sticky', array('topic' => $topicOptions['id'], 'board' => $topicOptions['board'])); |
|
| 2314 | + } |
|
| 2194 | 2315 | |
| 2195 | 2316 | // Returning to the topic? |
| 2196 | 2317 | if (!empty($_REQUEST['goback'])) |
@@ -2209,26 +2330,31 @@ discard block |
||
| 2209 | 2330 | ); |
| 2210 | 2331 | } |
| 2211 | 2332 | |
| 2212 | - if ($board_info['num_topics'] == 0) |
|
| 2213 | - cache_put_data('board-' . $board, null, 120); |
|
| 2333 | + if ($board_info['num_topics'] == 0) { |
|
| 2334 | + cache_put_data('board-' . $board, null, 120); |
|
| 2335 | + } |
|
| 2214 | 2336 | |
| 2215 | 2337 | call_integration_hook('integrate_post2_end'); |
| 2216 | 2338 | |
| 2217 | - if (!empty($_POST['announce_topic'])) |
|
| 2218 | - redirectexit('action=announce;sa=selectgroup;topic=' . $topic . (!empty($_POST['move']) && allowedTo('move_any') ? ';move' : '') . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
| 2339 | + if (!empty($_POST['announce_topic'])) { |
|
| 2340 | + redirectexit('action=announce;sa=selectgroup;topic=' . $topic . (!empty($_POST['move']) && allowedTo('move_any') ? ';move' : '') . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
| 2341 | + } |
|
| 2219 | 2342 | |
| 2220 | - if (!empty($_POST['move']) && allowedTo('move_any')) |
|
| 2221 | - redirectexit('action=movetopic;topic=' . $topic . '.0' . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
| 2343 | + if (!empty($_POST['move']) && allowedTo('move_any')) { |
|
| 2344 | + redirectexit('action=movetopic;topic=' . $topic . '.0' . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
| 2345 | + } |
|
| 2222 | 2346 | |
| 2223 | 2347 | // Return to post if the mod is on. |
| 2224 | - if (isset($_REQUEST['msg']) && !empty($_REQUEST['goback'])) |
|
| 2225 | - redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg'], isBrowser('ie')); |
|
| 2226 | - elseif (!empty($_REQUEST['goback'])) |
|
| 2227 | - redirectexit('topic=' . $topic . '.new#new', isBrowser('ie')); |
|
| 2348 | + if (isset($_REQUEST['msg']) && !empty($_REQUEST['goback'])) { |
|
| 2349 | + redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg'], isBrowser('ie')); |
|
| 2350 | + } elseif (!empty($_REQUEST['goback'])) { |
|
| 2351 | + redirectexit('topic=' . $topic . '.new#new', isBrowser('ie')); |
|
| 2352 | + } |
|
| 2228 | 2353 | // Dut-dut-duh-duh-DUH-duh-dut-duh-duh! *dances to the Final Fantasy Fanfare...* |
| 2229 | - else |
|
| 2230 | - redirectexit('board=' . $board . '.0'); |
|
| 2231 | -} |
|
| 2354 | + else { |
|
| 2355 | + redirectexit('board=' . $board . '.0'); |
|
| 2356 | + } |
|
| 2357 | + } |
|
| 2232 | 2358 | |
| 2233 | 2359 | /** |
| 2234 | 2360 | * Handle the announce topic function (action=announce). |
@@ -2246,8 +2372,9 @@ discard block |
||
| 2246 | 2372 | |
| 2247 | 2373 | validateSession(); |
| 2248 | 2374 | |
| 2249 | - if (empty($topic)) |
|
| 2250 | - fatal_lang_error('topic_gone', false); |
|
| 2375 | + if (empty($topic)) { |
|
| 2376 | + fatal_lang_error('topic_gone', false); |
|
| 2377 | + } |
|
| 2251 | 2378 | |
| 2252 | 2379 | loadLanguage('Post'); |
| 2253 | 2380 | loadTemplate('Post'); |
@@ -2274,8 +2401,9 @@ discard block |
||
| 2274 | 2401 | global $txt, $context, $topic, $board, $board_info, $smcFunc; |
| 2275 | 2402 | |
| 2276 | 2403 | $groups = array_merge($board_info['groups'], array(1)); |
| 2277 | - foreach ($groups as $id => $group) |
|
| 2278 | - $groups[$id] = (int) $group; |
|
| 2404 | + foreach ($groups as $id => $group) { |
|
| 2405 | + $groups[$id] = (int) $group; |
|
| 2406 | + } |
|
| 2279 | 2407 | |
| 2280 | 2408 | $context['groups'] = array(); |
| 2281 | 2409 | if (in_array(0, $groups)) |
@@ -2318,8 +2446,9 @@ discard block |
||
| 2318 | 2446 | 'group_list' => $groups, |
| 2319 | 2447 | ) |
| 2320 | 2448 | ); |
| 2321 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2322 | - $context['groups'][$row['id_group']]['name'] = $row['group_name']; |
|
| 2449 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2450 | + $context['groups'][$row['id_group']]['name'] = $row['group_name']; |
|
| 2451 | + } |
|
| 2323 | 2452 | $smcFunc['db_free_result']($request); |
| 2324 | 2453 | |
| 2325 | 2454 | // Get the subject of the topic we're about to announce. |
@@ -2361,16 +2490,19 @@ discard block |
||
| 2361 | 2490 | $context['start'] = empty($_REQUEST['start']) ? 0 : (int) $_REQUEST['start']; |
| 2362 | 2491 | $groups = array_merge($board_info['groups'], array(1)); |
| 2363 | 2492 | |
| 2364 | - if (isset($_POST['membergroups'])) |
|
| 2365 | - $_POST['who'] = explode(',', $_POST['membergroups']); |
|
| 2493 | + if (isset($_POST['membergroups'])) { |
|
| 2494 | + $_POST['who'] = explode(',', $_POST['membergroups']); |
|
| 2495 | + } |
|
| 2366 | 2496 | |
| 2367 | 2497 | // Check whether at least one membergroup was selected. |
| 2368 | - if (empty($_POST['who'])) |
|
| 2369 | - fatal_lang_error('no_membergroup_selected'); |
|
| 2498 | + if (empty($_POST['who'])) { |
|
| 2499 | + fatal_lang_error('no_membergroup_selected'); |
|
| 2500 | + } |
|
| 2370 | 2501 | |
| 2371 | 2502 | // Make sure all membergroups are integers and can access the board of the announcement. |
| 2372 | - foreach ($_POST['who'] as $id => $mg) |
|
| 2373 | - $_POST['who'][$id] = in_array((int) $mg, $groups) ? (int) $mg : 0; |
|
| 2503 | + foreach ($_POST['who'] as $id => $mg) { |
|
| 2504 | + $_POST['who'][$id] = in_array((int) $mg, $groups) ? (int) $mg : 0; |
|
| 2505 | + } |
|
| 2374 | 2506 | |
| 2375 | 2507 | // Get the topic subject and censor it. |
| 2376 | 2508 | $request = $smcFunc['db_query']('', ' |
@@ -2416,12 +2548,13 @@ discard block |
||
| 2416 | 2548 | if ($smcFunc['db_num_rows']($request) == 0) |
| 2417 | 2549 | { |
| 2418 | 2550 | logAction('announce_topic', array('topic' => $topic), 'user'); |
| 2419 | - if (!empty($_REQUEST['move']) && allowedTo('move_any')) |
|
| 2420 | - redirectexit('action=movetopic;topic=' . $topic . '.0' . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
| 2421 | - elseif (!empty($_REQUEST['goback'])) |
|
| 2422 | - redirectexit('topic=' . $topic . '.new;boardseen#new', isBrowser('ie')); |
|
| 2423 | - else |
|
| 2424 | - redirectexit('board=' . $board . '.0'); |
|
| 2551 | + if (!empty($_REQUEST['move']) && allowedTo('move_any')) { |
|
| 2552 | + redirectexit('action=movetopic;topic=' . $topic . '.0' . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
| 2553 | + } elseif (!empty($_REQUEST['goback'])) { |
|
| 2554 | + redirectexit('topic=' . $topic . '.new;boardseen#new', isBrowser('ie')); |
|
| 2555 | + } else { |
|
| 2556 | + redirectexit('board=' . $board . '.0'); |
|
| 2557 | + } |
|
| 2425 | 2558 | } |
| 2426 | 2559 | |
| 2427 | 2560 | $announcements = array(); |
@@ -2440,8 +2573,9 @@ discard block |
||
| 2440 | 2573 | foreach ($rows as $row) |
| 2441 | 2574 | { |
| 2442 | 2575 | // Force them to have it? |
| 2443 | - if (empty($prefs[$row['id_member']]['announcements'])) |
|
| 2444 | - continue; |
|
| 2576 | + if (empty($prefs[$row['id_member']]['announcements'])) { |
|
| 2577 | + continue; |
|
| 2578 | + } |
|
| 2445 | 2579 | |
| 2446 | 2580 | $cur_language = empty($row['lngfile']) || empty($modSettings['userLanguage']) ? $language : $row['lngfile']; |
| 2447 | 2581 | |
@@ -2469,8 +2603,9 @@ discard block |
||
| 2469 | 2603 | } |
| 2470 | 2604 | |
| 2471 | 2605 | // For each language send a different mail - low priority... |
| 2472 | - foreach ($announcements as $lang => $mail) |
|
| 2473 | - sendmail($mail['recipients'], $mail['subject'], $mail['body'], null, 'ann-' . $lang, $mail['is_html'], 5); |
|
| 2606 | + foreach ($announcements as $lang => $mail) { |
|
| 2607 | + sendmail($mail['recipients'], $mail['subject'], $mail['body'], null, 'ann-' . $lang, $mail['is_html'], 5); |
|
| 2608 | + } |
|
| 2474 | 2609 | |
| 2475 | 2610 | $context['percentage_done'] = round(100 * $context['start'] / $modSettings['latestMember'], 1); |
| 2476 | 2611 | |
@@ -2480,9 +2615,10 @@ discard block |
||
| 2480 | 2615 | $context['sub_template'] = 'announcement_send'; |
| 2481 | 2616 | |
| 2482 | 2617 | // Go back to the correct language for the user ;). |
| 2483 | - if (!empty($modSettings['userLanguage'])) |
|
| 2484 | - loadLanguage('Post'); |
|
| 2485 | -} |
|
| 2618 | + if (!empty($modSettings['userLanguage'])) { |
|
| 2619 | + loadLanguage('Post'); |
|
| 2620 | + } |
|
| 2621 | + } |
|
| 2486 | 2622 | |
| 2487 | 2623 | /** |
| 2488 | 2624 | * Get the topic for display purposes. |
@@ -2495,12 +2631,13 @@ discard block |
||
| 2495 | 2631 | { |
| 2496 | 2632 | global $topic, $modSettings, $context, $smcFunc, $counter, $options; |
| 2497 | 2633 | |
| 2498 | - if (isset($_REQUEST['xml'])) |
|
| 2499 | - $limit = ' |
|
| 2634 | + if (isset($_REQUEST['xml'])) { |
|
| 2635 | + $limit = ' |
|
| 2500 | 2636 | LIMIT ' . (empty($context['new_replies']) ? '0' : $context['new_replies']); |
| 2501 | - else |
|
| 2502 | - $limit = empty($modSettings['topicSummaryPosts']) ? '' : ' |
|
| 2637 | + } else { |
|
| 2638 | + $limit = empty($modSettings['topicSummaryPosts']) ? '' : ' |
|
| 2503 | 2639 | LIMIT ' . (int) $modSettings['topicSummaryPosts']; |
| 2640 | + } |
|
| 2504 | 2641 | |
| 2505 | 2642 | // If you're modifying, get only those posts before the current one. (otherwise get all.) |
| 2506 | 2643 | $request = $smcFunc['db_query']('', ' |
@@ -2538,8 +2675,9 @@ discard block |
||
| 2538 | 2675 | 'is_ignored' => !empty($modSettings['enable_buddylist']) && !empty($options['posts_apply_ignore_list']) && in_array($row['id_member'], $context['user']['ignoreusers']), |
| 2539 | 2676 | ); |
| 2540 | 2677 | |
| 2541 | - if (!empty($context['new_replies'])) |
|
| 2542 | - $context['new_replies']--; |
|
| 2678 | + if (!empty($context['new_replies'])) { |
|
| 2679 | + $context['new_replies']--; |
|
| 2680 | + } |
|
| 2543 | 2681 | } |
| 2544 | 2682 | $smcFunc['db_free_result']($request); |
| 2545 | 2683 | } |
@@ -2556,8 +2694,9 @@ discard block |
||
| 2556 | 2694 | global $sourcedir, $smcFunc; |
| 2557 | 2695 | |
| 2558 | 2696 | loadLanguage('Post'); |
| 2559 | - if (!isset($_REQUEST['xml'])) |
|
| 2560 | - loadTemplate('Post'); |
|
| 2697 | + if (!isset($_REQUEST['xml'])) { |
|
| 2698 | + loadTemplate('Post'); |
|
| 2699 | + } |
|
| 2561 | 2700 | |
| 2562 | 2701 | include_once($sourcedir . '/Subs-Post.php'); |
| 2563 | 2702 | |
@@ -2588,8 +2727,9 @@ discard block |
||
| 2588 | 2727 | $smcFunc['db_free_result']($request); |
| 2589 | 2728 | |
| 2590 | 2729 | $context['sub_template'] = 'quotefast'; |
| 2591 | - if (!empty($row)) |
|
| 2592 | - $can_view_post = $row['approved'] || ($row['id_member'] != 0 && $row['id_member'] == $user_info['id']) || allowedTo('approve_posts', $row['id_board']); |
|
| 2730 | + if (!empty($row)) { |
|
| 2731 | + $can_view_post = $row['approved'] || ($row['id_member'] != 0 && $row['id_member'] == $user_info['id']) || allowedTo('approve_posts', $row['id_board']); |
|
| 2732 | + } |
|
| 2593 | 2733 | |
| 2594 | 2734 | if (!empty($can_view_post)) |
| 2595 | 2735 | { |
@@ -2622,8 +2762,9 @@ discard block |
||
| 2622 | 2762 | } |
| 2623 | 2763 | |
| 2624 | 2764 | // Remove any nested quotes. |
| 2625 | - if (!empty($modSettings['removeNestedQuotes'])) |
|
| 2626 | - $row['body'] = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $row['body']); |
|
| 2765 | + if (!empty($modSettings['removeNestedQuotes'])) { |
|
| 2766 | + $row['body'] = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $row['body']); |
|
| 2767 | + } |
|
| 2627 | 2768 | |
| 2628 | 2769 | $lb = "\n"; |
| 2629 | 2770 | |
@@ -2649,14 +2790,14 @@ discard block |
||
| 2649 | 2790 | 'time' => '', |
| 2650 | 2791 | ), |
| 2651 | 2792 | ); |
| 2652 | - } |
|
| 2653 | - else |
|
| 2654 | - $context['quote'] = array( |
|
| 2793 | + } else { |
|
| 2794 | + $context['quote'] = array( |
|
| 2655 | 2795 | 'xml' => '', |
| 2656 | 2796 | 'mozilla' => '', |
| 2657 | 2797 | 'text' => '', |
| 2658 | 2798 | ); |
| 2659 | -} |
|
| 2799 | + } |
|
| 2800 | + } |
|
| 2660 | 2801 | |
| 2661 | 2802 | /** |
| 2662 | 2803 | * Used to edit the body or subject of a message inline |
@@ -2668,8 +2809,9 @@ discard block |
||
| 2668 | 2809 | global $user_info, $context, $smcFunc, $language, $board_info; |
| 2669 | 2810 | |
| 2670 | 2811 | // We have to have a topic! |
| 2671 | - if (empty($topic)) |
|
| 2672 | - obExit(false); |
|
| 2812 | + if (empty($topic)) { |
|
| 2813 | + obExit(false); |
|
| 2814 | + } |
|
| 2673 | 2815 | |
| 2674 | 2816 | checkSession('get'); |
| 2675 | 2817 | require_once($sourcedir . '/Subs-Post.php'); |
@@ -2695,31 +2837,35 @@ discard block |
||
| 2695 | 2837 | 'guest_id' => 0, |
| 2696 | 2838 | ) |
| 2697 | 2839 | ); |
| 2698 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 2699 | - fatal_lang_error('no_board', false); |
|
| 2840 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 2841 | + fatal_lang_error('no_board', false); |
|
| 2842 | + } |
|
| 2700 | 2843 | $row = $smcFunc['db_fetch_assoc']($request); |
| 2701 | 2844 | $smcFunc['db_free_result']($request); |
| 2702 | 2845 | |
| 2703 | 2846 | // Change either body or subject requires permissions to modify messages. |
| 2704 | 2847 | if (isset($_POST['message']) || isset($_POST['subject']) || isset($_REQUEST['icon'])) |
| 2705 | 2848 | { |
| 2706 | - if (!empty($row['locked'])) |
|
| 2707 | - isAllowedTo('moderate_board'); |
|
| 2849 | + if (!empty($row['locked'])) { |
|
| 2850 | + isAllowedTo('moderate_board'); |
|
| 2851 | + } |
|
| 2708 | 2852 | |
| 2709 | 2853 | if ($row['id_member'] == $user_info['id'] && !allowedTo('modify_any')) |
| 2710 | 2854 | { |
| 2711 | - if ((!$modSettings['postmod_active'] || $row['approved']) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) |
|
| 2712 | - fatal_lang_error('modify_post_time_passed', false); |
|
| 2713 | - elseif ($row['id_member_started'] == $user_info['id'] && !allowedTo('modify_own')) |
|
| 2714 | - isAllowedTo('modify_replies'); |
|
| 2715 | - else |
|
| 2716 | - isAllowedTo('modify_own'); |
|
| 2855 | + if ((!$modSettings['postmod_active'] || $row['approved']) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) { |
|
| 2856 | + fatal_lang_error('modify_post_time_passed', false); |
|
| 2857 | + } elseif ($row['id_member_started'] == $user_info['id'] && !allowedTo('modify_own')) { |
|
| 2858 | + isAllowedTo('modify_replies'); |
|
| 2859 | + } else { |
|
| 2860 | + isAllowedTo('modify_own'); |
|
| 2861 | + } |
|
| 2717 | 2862 | } |
| 2718 | 2863 | // Otherwise, they're locked out; someone who can modify the replies is needed. |
| 2719 | - elseif ($row['id_member_started'] == $user_info['id'] && !allowedTo('modify_any')) |
|
| 2720 | - isAllowedTo('modify_replies'); |
|
| 2721 | - else |
|
| 2722 | - isAllowedTo('modify_any'); |
|
| 2864 | + elseif ($row['id_member_started'] == $user_info['id'] && !allowedTo('modify_any')) { |
|
| 2865 | + isAllowedTo('modify_replies'); |
|
| 2866 | + } else { |
|
| 2867 | + isAllowedTo('modify_any'); |
|
| 2868 | + } |
|
| 2723 | 2869 | |
| 2724 | 2870 | // Only log this action if it wasn't your message. |
| 2725 | 2871 | $moderationAction = $row['id_member'] != $user_info['id']; |
@@ -2731,10 +2877,10 @@ discard block |
||
| 2731 | 2877 | $_POST['subject'] = strtr($smcFunc['htmlspecialchars']($_POST['subject']), array("\r" => '', "\n" => '', "\t" => '')); |
| 2732 | 2878 | |
| 2733 | 2879 | // Maximum number of characters. |
| 2734 | - if ($smcFunc['strlen']($_POST['subject']) > 100) |
|
| 2735 | - $_POST['subject'] = $smcFunc['substr']($_POST['subject'], 0, 100); |
|
| 2736 | - } |
|
| 2737 | - elseif (isset($_POST['subject'])) |
|
| 2880 | + if ($smcFunc['strlen']($_POST['subject']) > 100) { |
|
| 2881 | + $_POST['subject'] = $smcFunc['substr']($_POST['subject'], 0, 100); |
|
| 2882 | + } |
|
| 2883 | + } elseif (isset($_POST['subject'])) |
|
| 2738 | 2884 | { |
| 2739 | 2885 | $post_errors[] = 'no_subject'; |
| 2740 | 2886 | unset($_POST['subject']); |
@@ -2746,13 +2892,11 @@ discard block |
||
| 2746 | 2892 | { |
| 2747 | 2893 | $post_errors[] = 'no_message'; |
| 2748 | 2894 | unset($_POST['message']); |
| 2749 | - } |
|
| 2750 | - elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_POST['message']) > $modSettings['max_messageLength']) |
|
| 2895 | + } elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_POST['message']) > $modSettings['max_messageLength']) |
|
| 2751 | 2896 | { |
| 2752 | 2897 | $post_errors[] = 'long_message'; |
| 2753 | 2898 | unset($_POST['message']); |
| 2754 | - } |
|
| 2755 | - else |
|
| 2899 | + } else |
|
| 2756 | 2900 | { |
| 2757 | 2901 | $_POST['message'] = $smcFunc['htmlspecialchars']($_POST['message'], ENT_QUOTES); |
| 2758 | 2902 | |
@@ -2768,31 +2912,34 @@ discard block |
||
| 2768 | 2912 | |
| 2769 | 2913 | if (isset($_POST['lock'])) |
| 2770 | 2914 | { |
| 2771 | - if (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $row['id_member'])) |
|
| 2772 | - unset($_POST['lock']); |
|
| 2773 | - elseif (!allowedTo('lock_any')) |
|
| 2915 | + if (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $row['id_member'])) { |
|
| 2916 | + unset($_POST['lock']); |
|
| 2917 | + } elseif (!allowedTo('lock_any')) |
|
| 2774 | 2918 | { |
| 2775 | - if ($row['locked'] == 1) |
|
| 2776 | - unset($_POST['lock']); |
|
| 2777 | - else |
|
| 2778 | - $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
| 2919 | + if ($row['locked'] == 1) { |
|
| 2920 | + unset($_POST['lock']); |
|
| 2921 | + } else { |
|
| 2922 | + $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
| 2923 | + } |
|
| 2924 | + } elseif (!empty($row['locked']) && !empty($_POST['lock']) || $_POST['lock'] == $row['locked']) { |
|
| 2925 | + unset($_POST['lock']); |
|
| 2926 | + } else { |
|
| 2927 | + $_POST['lock'] = empty($_POST['lock']) ? 0 : 1; |
|
| 2779 | 2928 | } |
| 2780 | - elseif (!empty($row['locked']) && !empty($_POST['lock']) || $_POST['lock'] == $row['locked']) |
|
| 2781 | - unset($_POST['lock']); |
|
| 2782 | - else |
|
| 2783 | - $_POST['lock'] = empty($_POST['lock']) ? 0 : 1; |
|
| 2784 | 2929 | } |
| 2785 | 2930 | |
| 2786 | - if (isset($_POST['sticky']) && !allowedTo('make_sticky')) |
|
| 2787 | - unset($_POST['sticky']); |
|
| 2931 | + if (isset($_POST['sticky']) && !allowedTo('make_sticky')) { |
|
| 2932 | + unset($_POST['sticky']); |
|
| 2933 | + } |
|
| 2788 | 2934 | |
| 2789 | 2935 | if (isset($_POST['modify_reason'])) |
| 2790 | 2936 | { |
| 2791 | 2937 | $_POST['modify_reason'] = strtr($smcFunc['htmlspecialchars']($_POST['modify_reason']), array("\r" => '', "\n" => '', "\t" => '')); |
| 2792 | 2938 | |
| 2793 | 2939 | // Maximum number of characters. |
| 2794 | - if ($smcFunc['strlen']($_POST['modify_reason']) > 100) |
|
| 2795 | - $_POST['modify_reason'] = $smcFunc['substr']($_POST['modify_reason'], 0, 100); |
|
| 2940 | + if ($smcFunc['strlen']($_POST['modify_reason']) > 100) { |
|
| 2941 | + $_POST['modify_reason'] = $smcFunc['substr']($_POST['modify_reason'], 0, 100); |
|
| 2942 | + } |
|
| 2796 | 2943 | } |
| 2797 | 2944 | |
| 2798 | 2945 | if (empty($post_errors)) |
@@ -2829,8 +2976,9 @@ discard block |
||
| 2829 | 2976 | } |
| 2830 | 2977 | } |
| 2831 | 2978 | // If nothing was changed there's no need to add an entry to the moderation log. |
| 2832 | - else |
|
| 2833 | - $moderationAction = false; |
|
| 2979 | + else { |
|
| 2980 | + $moderationAction = false; |
|
| 2981 | + } |
|
| 2834 | 2982 | |
| 2835 | 2983 | modifyPost($msgOptions, $topicOptions, $posterOptions); |
| 2836 | 2984 | |
@@ -2848,9 +2996,9 @@ discard block |
||
| 2848 | 2996 | // Get the proper (default language) response prefix first. |
| 2849 | 2997 | if (!isset($context['response_prefix']) && !($context['response_prefix'] = cache_get_data('response_prefix'))) |
| 2850 | 2998 | { |
| 2851 | - if ($language === $user_info['language']) |
|
| 2852 | - $context['response_prefix'] = $txt['response_prefix']; |
|
| 2853 | - else |
|
| 2999 | + if ($language === $user_info['language']) { |
|
| 3000 | + $context['response_prefix'] = $txt['response_prefix']; |
|
| 3001 | + } else |
|
| 2854 | 3002 | { |
| 2855 | 3003 | loadLanguage('index', $language, false); |
| 2856 | 3004 | $context['response_prefix'] = $txt['response_prefix']; |
@@ -2872,8 +3020,9 @@ discard block |
||
| 2872 | 3020 | ); |
| 2873 | 3021 | } |
| 2874 | 3022 | |
| 2875 | - if (!empty($moderationAction)) |
|
| 2876 | - logAction('modify', array('topic' => $topic, 'message' => $row['id_msg'], 'member' => $row['id_member'], 'board' => $board)); |
|
| 3023 | + if (!empty($moderationAction)) { |
|
| 3024 | + logAction('modify', array('topic' => $topic, 'message' => $row['id_msg'], 'member' => $row['id_member'], 'board' => $board)); |
|
| 3025 | + } |
|
| 2877 | 3026 | } |
| 2878 | 3027 | |
| 2879 | 3028 | if (isset($_REQUEST['xml'])) |
@@ -2914,8 +3063,7 @@ discard block |
||
| 2914 | 3063 | ); |
| 2915 | 3064 | |
| 2916 | 3065 | censorText($context['message']['subject']); |
| 2917 | - } |
|
| 2918 | - else |
|
| 3066 | + } else |
|
| 2919 | 3067 | { |
| 2920 | 3068 | $context['message'] = array( |
| 2921 | 3069 | 'id' => $row['id_msg'], |
@@ -2927,15 +3075,16 @@ discard block |
||
| 2927 | 3075 | loadLanguage('Errors'); |
| 2928 | 3076 | foreach ($post_errors as $post_error) |
| 2929 | 3077 | { |
| 2930 | - if ($post_error == 'long_message') |
|
| 2931 | - $context['message']['errors'][] = sprintf($txt['error_' . $post_error], $modSettings['max_messageLength']); |
|
| 2932 | - else |
|
| 2933 | - $context['message']['errors'][] = $txt['error_' . $post_error]; |
|
| 3078 | + if ($post_error == 'long_message') { |
|
| 3079 | + $context['message']['errors'][] = sprintf($txt['error_' . $post_error], $modSettings['max_messageLength']); |
|
| 3080 | + } else { |
|
| 3081 | + $context['message']['errors'][] = $txt['error_' . $post_error]; |
|
| 3082 | + } |
|
| 2934 | 3083 | } |
| 2935 | 3084 | } |
| 3085 | + } else { |
|
| 3086 | + obExit(false); |
|
| 3087 | + } |
|
| 2936 | 3088 | } |
| 2937 | - else |
|
| 2938 | - obExit(false); |
|
| 2939 | -} |
|
| 2940 | 3089 | |
| 2941 | 3090 | ?> |
| 2942 | 3091 | \ No newline at end of file |