@@ -14,8 +14,9 @@ discard block |
||
| 14 | 14 | * @version 2.1 Beta 4 |
| 15 | 15 | */ |
| 16 | 16 | |
| 17 | -if (!defined('SMF')) |
|
| 17 | +if (!defined('SMF')) { |
|
| 18 | 18 | die('No direct access...'); |
| 19 | +} |
|
| 19 | 20 | |
| 20 | 21 | /** |
| 21 | 22 | * !!!Compatibility!!! |
@@ -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) |
@@ -381,8 +395,7 @@ discard block |
||
| 381 | 395 | |
| 382 | 396 | // Put the tags back into the body. |
| 383 | 397 | $text = substr($text, 0, $start_pos) . $tag . '[' . $matches[3] . ']' . $content . '[/' . $matches[3] . ']' . substr($text, $end_pos); |
| 384 | - } |
|
| 385 | - else |
|
| 398 | + } else |
|
| 386 | 399 | { |
| 387 | 400 | // Just get rid of this evil tag. |
| 388 | 401 | $text = substr($text, 0, $start_pos) . substr($text, $start_pos + strlen($matches[0])); |
@@ -395,8 +408,9 @@ discard block |
||
| 395 | 408 | // Find the position of this again. |
| 396 | 409 | $start_pos = strpos($text, $matches[0]); |
| 397 | 410 | $end_pos = false; |
| 398 | - if ($start_pos === false) |
|
| 399 | - break; |
|
| 411 | + if ($start_pos === false) { |
|
| 412 | + break; |
|
| 413 | + } |
|
| 400 | 414 | |
| 401 | 415 | // This must have an end tag - and we must find the right one. |
| 402 | 416 | $lower_text = strtolower($text); |
@@ -429,8 +443,9 @@ discard block |
||
| 429 | 443 | break; |
| 430 | 444 | } |
| 431 | 445 | } |
| 432 | - if ($end_pos === false) |
|
| 433 | - break; |
|
| 446 | + if ($end_pos === false) { |
|
| 447 | + break; |
|
| 448 | + } |
|
| 434 | 449 | |
| 435 | 450 | // Now work out what the attributes are. |
| 436 | 451 | $attribs = fetchTagAttributes($matches[1]); |
@@ -444,11 +459,11 @@ discard block |
||
| 444 | 459 | $v = (int) trim($v); |
| 445 | 460 | $v = empty($v) ? 1 : $v; |
| 446 | 461 | $tags[] = array('[size=' . $sizes_equivalence[$v] . ']', '[/size]'); |
| 462 | + } elseif ($s == 'face') { |
|
| 463 | + $tags[] = array('[font=' . trim(strtolower($v)) . ']', '[/font]'); |
|
| 464 | + } elseif ($s == 'color') { |
|
| 465 | + $tags[] = array('[color=' . trim(strtolower($v)) . ']', '[/color]'); |
|
| 447 | 466 | } |
| 448 | - elseif ($s == 'face') |
|
| 449 | - $tags[] = array('[font=' . trim(strtolower($v)) . ']', '[/font]'); |
|
| 450 | - elseif ($s == 'color') |
|
| 451 | - $tags[] = array('[color=' . trim(strtolower($v)) . ']', '[/color]'); |
|
| 452 | 467 | } |
| 453 | 468 | |
| 454 | 469 | // As before add in our tags. |
@@ -456,8 +471,9 @@ discard block |
||
| 456 | 471 | foreach ($tags as $tag) |
| 457 | 472 | { |
| 458 | 473 | $before .= $tag[0]; |
| 459 | - if (isset($tag[1])) |
|
| 460 | - $after = $tag[1] . $after; |
|
| 474 | + if (isset($tag[1])) { |
|
| 475 | + $after = $tag[1] . $after; |
|
| 476 | + } |
|
| 461 | 477 | } |
| 462 | 478 | |
| 463 | 479 | // Remove the tag so it's never checked again. |
@@ -468,8 +484,9 @@ discard block |
||
| 468 | 484 | } |
| 469 | 485 | |
| 470 | 486 | // Almost there, just a little more time. |
| 471 | - if (connection_aborted() && $context['server']['is_apache']) |
|
| 472 | - @apache_reset_timeout(); |
|
| 487 | + if (connection_aborted() && $context['server']['is_apache']) { |
|
| 488 | + @apache_reset_timeout(); |
|
| 489 | + } |
|
| 473 | 490 | |
| 474 | 491 | if (count($parts = preg_split('~<(/?)(li|ol|ul)([^>]*)>~i', $text, null, PREG_SPLIT_DELIM_CAPTURE)) > 1) |
| 475 | 492 | { |
@@ -525,12 +542,13 @@ discard block |
||
| 525 | 542 | { |
| 526 | 543 | $inList = true; |
| 527 | 544 | |
| 528 | - if ($tag === 'ol') |
|
| 529 | - $listType = 'decimal'; |
|
| 530 | - elseif (preg_match('~type="?(' . implode('|', array_keys($listTypeMapping)) . ')"?~', $parts[$i + 3], $match) === 1) |
|
| 531 | - $listType = $listTypeMapping[$match[1]]; |
|
| 532 | - else |
|
| 533 | - $listType = null; |
|
| 545 | + if ($tag === 'ol') { |
|
| 546 | + $listType = 'decimal'; |
|
| 547 | + } elseif (preg_match('~type="?(' . implode('|', array_keys($listTypeMapping)) . ')"?~', $parts[$i + 3], $match) === 1) { |
|
| 548 | + $listType = $listTypeMapping[$match[1]]; |
|
| 549 | + } else { |
|
| 550 | + $listType = null; |
|
| 551 | + } |
|
| 534 | 552 | |
| 535 | 553 | $listDepth++; |
| 536 | 554 | |
@@ -594,9 +612,7 @@ discard block |
||
| 594 | 612 | $parts[$i + 1] = ''; |
| 595 | 613 | $parts[$i + 2] = str_repeat("\t", $listDepth) . '[/list]'; |
| 596 | 614 | $parts[$i + 3] = ''; |
| 597 | - } |
|
| 598 | - |
|
| 599 | - else |
|
| 615 | + } else |
|
| 600 | 616 | { |
| 601 | 617 | // We're in a list item. |
| 602 | 618 | if ($listDepth > 0) |
@@ -633,9 +649,7 @@ discard block |
||
| 633 | 649 | $parts[$i + 1] = ''; |
| 634 | 650 | $parts[$i + 2] = ''; |
| 635 | 651 | $parts[$i + 3] = ''; |
| 636 | - } |
|
| 637 | - |
|
| 638 | - else |
|
| 652 | + } else |
|
| 639 | 653 | { |
| 640 | 654 | // Remove the trailing breaks from the list item. |
| 641 | 655 | $parts[$i] = preg_replace('~\s*<br\s*' . '/?' . '>\s*$~', '', $parts[$i]); |
@@ -673,8 +687,9 @@ discard block |
||
| 673 | 687 | $text .= str_repeat("\t", $listDepth) . '[/list]'; |
| 674 | 688 | } |
| 675 | 689 | |
| 676 | - for ($i = $listDepth; $i > 0; $i--) |
|
| 677 | - $text .= '[/li]' . "\n" . str_repeat("\t", $i - 1) . '[/list]'; |
|
| 690 | + for ($i = $listDepth; $i > 0; $i--) { |
|
| 691 | + $text .= '[/li]' . "\n" . str_repeat("\t", $i - 1) . '[/list]'; |
|
| 692 | + } |
|
| 678 | 693 | |
| 679 | 694 | } |
| 680 | 695 | |
@@ -683,8 +698,9 @@ discard block |
||
| 683 | 698 | { |
| 684 | 699 | // Find the position of the image. |
| 685 | 700 | $start_pos = strpos($text, $matches[0]); |
| 686 | - if ($start_pos === false) |
|
| 687 | - break; |
|
| 701 | + if ($start_pos === false) { |
|
| 702 | + break; |
|
| 703 | + } |
|
| 688 | 704 | $end_pos = $start_pos + strlen($matches[0]); |
| 689 | 705 | |
| 690 | 706 | $params = ''; |
@@ -693,12 +709,13 @@ discard block |
||
| 693 | 709 | $attrs = fetchTagAttributes($matches[1]); |
| 694 | 710 | foreach ($attrs as $attrib => $value) |
| 695 | 711 | { |
| 696 | - if (in_array($attrib, array('width', 'height'))) |
|
| 697 | - $params .= ' ' . $attrib . '=' . (int) $value; |
|
| 698 | - elseif ($attrib == 'alt' && trim($value) != '') |
|
| 699 | - $params .= ' alt=' . trim($value); |
|
| 700 | - elseif ($attrib == 'src') |
|
| 701 | - $src = trim($value); |
|
| 712 | + if (in_array($attrib, array('width', 'height'))) { |
|
| 713 | + $params .= ' ' . $attrib . '=' . (int) $value; |
|
| 714 | + } elseif ($attrib == 'alt' && trim($value) != '') { |
|
| 715 | + $params .= ' alt=' . trim($value); |
|
| 716 | + } elseif ($attrib == 'src') { |
|
| 717 | + $src = trim($value); |
|
| 718 | + } |
|
| 702 | 719 | } |
| 703 | 720 | |
| 704 | 721 | $tag = ''; |
@@ -709,10 +726,11 @@ discard block |
||
| 709 | 726 | { |
| 710 | 727 | $baseURL = (isset($parsedURL['scheme']) ? $parsedURL['scheme'] : 'http') . '://' . $parsedURL['host'] . (empty($parsedURL['port']) ? '' : ':' . $parsedURL['port']); |
| 711 | 728 | |
| 712 | - if (substr($src, 0, 1) === '/') |
|
| 713 | - $src = $baseURL . $src; |
|
| 714 | - else |
|
| 715 | - $src = $baseURL . (empty($parsedURL['path']) ? '/' : preg_replace('~/(?:index\\.php)?$~', '', $parsedURL['path'])) . '/' . $src; |
|
| 729 | + if (substr($src, 0, 1) === '/') { |
|
| 730 | + $src = $baseURL . $src; |
|
| 731 | + } else { |
|
| 732 | + $src = $baseURL . (empty($parsedURL['path']) ? '/' : preg_replace('~/(?:index\\.php)?$~', '', $parsedURL['path'])) . '/' . $src; |
|
| 733 | + } |
|
| 716 | 734 | } |
| 717 | 735 | |
| 718 | 736 | $tag = '[img' . $params . ']' . $src . '[/img]'; |
@@ -890,20 +908,23 @@ discard block |
||
| 890 | 908 | }, |
| 891 | 909 | ); |
| 892 | 910 | |
| 893 | - foreach ($tags as $tag => $replace) |
|
| 894 | - $text = preg_replace_callback($tag, $replace, $text); |
|
| 911 | + foreach ($tags as $tag => $replace) { |
|
| 912 | + $text = preg_replace_callback($tag, $replace, $text); |
|
| 913 | + } |
|
| 895 | 914 | |
| 896 | 915 | // Please give us just a little more time. |
| 897 | - if (connection_aborted() && $context['server']['is_apache']) |
|
| 898 | - @apache_reset_timeout(); |
|
| 916 | + if (connection_aborted() && $context['server']['is_apache']) { |
|
| 917 | + @apache_reset_timeout(); |
|
| 918 | + } |
|
| 899 | 919 | |
| 900 | 920 | // What about URL's - the pain in the ass of the tag world. |
| 901 | 921 | while (preg_match('~<a\s+([^<>]*)>([^<>]*)</a>~i', $text, $matches) === 1) |
| 902 | 922 | { |
| 903 | 923 | // Find the position of the URL. |
| 904 | 924 | $start_pos = strpos($text, $matches[0]); |
| 905 | - if ($start_pos === false) |
|
| 906 | - break; |
|
| 925 | + if ($start_pos === false) { |
|
| 926 | + break; |
|
| 927 | + } |
|
| 907 | 928 | $end_pos = $start_pos + strlen($matches[0]); |
| 908 | 929 | |
| 909 | 930 | $tag_type = 'url'; |
@@ -917,8 +938,9 @@ discard block |
||
| 917 | 938 | $href = trim($value); |
| 918 | 939 | |
| 919 | 940 | // Are we dealing with an FTP link? |
| 920 | - if (preg_match('~^ftps?://~', $href) === 1) |
|
| 921 | - $tag_type = 'ftp'; |
|
| 941 | + if (preg_match('~^ftps?://~', $href) === 1) { |
|
| 942 | + $tag_type = 'ftp'; |
|
| 943 | + } |
|
| 922 | 944 | |
| 923 | 945 | // Or is this a link to an email address? |
| 924 | 946 | elseif (substr($href, 0, 7) == 'mailto:') |
@@ -932,28 +954,31 @@ discard block |
||
| 932 | 954 | { |
| 933 | 955 | $baseURL = (isset($parsedURL['scheme']) ? $parsedURL['scheme'] : 'http') . '://' . $parsedURL['host'] . (empty($parsedURL['port']) ? '' : ':' . $parsedURL['port']); |
| 934 | 956 | |
| 935 | - if (substr($href, 0, 1) === '/') |
|
| 936 | - $href = $baseURL . $href; |
|
| 937 | - else |
|
| 938 | - $href = $baseURL . (empty($parsedURL['path']) ? '/' : preg_replace('~/(?:index\\.php)?$~', '', $parsedURL['path'])) . '/' . $href; |
|
| 957 | + if (substr($href, 0, 1) === '/') { |
|
| 958 | + $href = $baseURL . $href; |
|
| 959 | + } else { |
|
| 960 | + $href = $baseURL . (empty($parsedURL['path']) ? '/' : preg_replace('~/(?:index\\.php)?$~', '', $parsedURL['path'])) . '/' . $href; |
|
| 961 | + } |
|
| 939 | 962 | } |
| 940 | 963 | } |
| 941 | 964 | |
| 942 | 965 | // External URL? |
| 943 | 966 | if ($attrib == 'target' && $tag_type == 'url') |
| 944 | 967 | { |
| 945 | - if (trim($value) == '_blank') |
|
| 946 | - $tag_type == 'iurl'; |
|
| 968 | + if (trim($value) == '_blank') { |
|
| 969 | + $tag_type == 'iurl'; |
|
| 970 | + } |
|
| 947 | 971 | } |
| 948 | 972 | } |
| 949 | 973 | |
| 950 | 974 | $tag = ''; |
| 951 | 975 | if ($href != '') |
| 952 | 976 | { |
| 953 | - if ($matches[2] == $href) |
|
| 954 | - $tag = '[' . $tag_type . ']' . $href . '[/' . $tag_type . ']'; |
|
| 955 | - else |
|
| 956 | - $tag = '[' . $tag_type . '=' . $href . ']' . $matches[2] . '[/' . $tag_type . ']'; |
|
| 977 | + if ($matches[2] == $href) { |
|
| 978 | + $tag = '[' . $tag_type . ']' . $href . '[/' . $tag_type . ']'; |
|
| 979 | + } else { |
|
| 980 | + $tag = '[' . $tag_type . '=' . $href . ']' . $matches[2] . '[/' . $tag_type . ']'; |
|
| 981 | + } |
|
| 957 | 982 | } |
| 958 | 983 | |
| 959 | 984 | // Replace the tag |
@@ -992,17 +1017,18 @@ discard block |
||
| 992 | 1017 | // We're either moving from the key to the attribute or we're in a string and this is fine. |
| 993 | 1018 | if ($text[$i] == '=') |
| 994 | 1019 | { |
| 995 | - if ($tag_state == 0) |
|
| 996 | - $tag_state = 1; |
|
| 997 | - elseif ($tag_state == 2) |
|
| 998 | - $value .= '='; |
|
| 1020 | + if ($tag_state == 0) { |
|
| 1021 | + $tag_state = 1; |
|
| 1022 | + } elseif ($tag_state == 2) { |
|
| 1023 | + $value .= '='; |
|
| 1024 | + } |
|
| 999 | 1025 | } |
| 1000 | 1026 | // A space is either moving from an attribute back to a potential key or in a string is fine. |
| 1001 | 1027 | elseif ($text[$i] == ' ') |
| 1002 | 1028 | { |
| 1003 | - if ($tag_state == 2) |
|
| 1004 | - $value .= ' '; |
|
| 1005 | - elseif ($tag_state == 1) |
|
| 1029 | + if ($tag_state == 2) { |
|
| 1030 | + $value .= ' '; |
|
| 1031 | + } elseif ($tag_state == 1) |
|
| 1006 | 1032 | { |
| 1007 | 1033 | $attribs[$key] = $value; |
| 1008 | 1034 | $key = $value = ''; |
@@ -1013,24 +1039,27 @@ discard block |
||
| 1013 | 1039 | elseif ($text[$i] == '"') |
| 1014 | 1040 | { |
| 1015 | 1041 | // Must be either going into or out of a string. |
| 1016 | - if ($tag_state == 1) |
|
| 1017 | - $tag_state = 2; |
|
| 1018 | - else |
|
| 1019 | - $tag_state = 1; |
|
| 1042 | + if ($tag_state == 1) { |
|
| 1043 | + $tag_state = 2; |
|
| 1044 | + } else { |
|
| 1045 | + $tag_state = 1; |
|
| 1046 | + } |
|
| 1020 | 1047 | } |
| 1021 | 1048 | // Otherwise it's fine. |
| 1022 | 1049 | else |
| 1023 | 1050 | { |
| 1024 | - if ($tag_state == 0) |
|
| 1025 | - $key .= $text[$i]; |
|
| 1026 | - else |
|
| 1027 | - $value .= $text[$i]; |
|
| 1051 | + if ($tag_state == 0) { |
|
| 1052 | + $key .= $text[$i]; |
|
| 1053 | + } else { |
|
| 1054 | + $value .= $text[$i]; |
|
| 1055 | + } |
|
| 1028 | 1056 | } |
| 1029 | 1057 | } |
| 1030 | 1058 | |
| 1031 | 1059 | // Anything left? |
| 1032 | - if ($key != '' && $value != '') |
|
| 1033 | - $attribs[$key] = $value; |
|
| 1060 | + if ($key != '' && $value != '') { |
|
| 1061 | + $attribs[$key] = $value; |
|
| 1062 | + } |
|
| 1034 | 1063 | |
| 1035 | 1064 | return $attribs; |
| 1036 | 1065 | } |
@@ -1046,15 +1075,17 @@ discard block |
||
| 1046 | 1075 | global $modSettings; |
| 1047 | 1076 | |
| 1048 | 1077 | // Don't care about the texts that are too short. |
| 1049 | - if (strlen($text) < 3) |
|
| 1050 | - return $text; |
|
| 1078 | + if (strlen($text) < 3) { |
|
| 1079 | + return $text; |
|
| 1080 | + } |
|
| 1051 | 1081 | |
| 1052 | 1082 | // A list of tags that's disabled by the admin. |
| 1053 | 1083 | $disabled = empty($modSettings['disabledBBC']) ? array() : array_flip(explode(',', strtolower($modSettings['disabledBBC']))); |
| 1054 | 1084 | |
| 1055 | 1085 | // Add flash if it's disabled as embedded tag. |
| 1056 | - if (empty($modSettings['enableEmbeddedFlash'])) |
|
| 1057 | - $disabled['flash'] = true; |
|
| 1086 | + if (empty($modSettings['enableEmbeddedFlash'])) { |
|
| 1087 | + $disabled['flash'] = true; |
|
| 1088 | + } |
|
| 1058 | 1089 | |
| 1059 | 1090 | // Get a list of all the tags that are not disabled. |
| 1060 | 1091 | $all_tags = parse_bbc(false); |
@@ -1062,10 +1093,12 @@ discard block |
||
| 1062 | 1093 | $self_closing_tags = array(); |
| 1063 | 1094 | foreach ($all_tags as $tag) |
| 1064 | 1095 | { |
| 1065 | - if (!isset($disabled[$tag['tag']])) |
|
| 1066 | - $valid_tags[$tag['tag']] = !empty($tag['block_level']); |
|
| 1067 | - if (isset($tag['type']) && $tag['type'] == 'closed') |
|
| 1068 | - $self_closing_tags[] = $tag['tag']; |
|
| 1096 | + if (!isset($disabled[$tag['tag']])) { |
|
| 1097 | + $valid_tags[$tag['tag']] = !empty($tag['block_level']); |
|
| 1098 | + } |
|
| 1099 | + if (isset($tag['type']) && $tag['type'] == 'closed') { |
|
| 1100 | + $self_closing_tags[] = $tag['tag']; |
|
| 1101 | + } |
|
| 1069 | 1102 | } |
| 1070 | 1103 | |
| 1071 | 1104 | // Right - we're going to start by going through the whole lot to make sure we don't have align stuff crossed as this happens load and is stupid! |
@@ -1092,16 +1125,19 @@ discard block |
||
| 1092 | 1125 | $tagName = substr($match, $isClosingTag ? 2 : 1, -1); |
| 1093 | 1126 | |
| 1094 | 1127 | // We're closing the exact same tag that we opened. |
| 1095 | - if ($isClosingTag && $insideTag === $tagName) |
|
| 1096 | - $insideTag = null; |
|
| 1128 | + if ($isClosingTag && $insideTag === $tagName) { |
|
| 1129 | + $insideTag = null; |
|
| 1130 | + } |
|
| 1097 | 1131 | |
| 1098 | 1132 | // We're opening a tag and we're not yet inside one either |
| 1099 | - elseif (!$isClosingTag && $insideTag === null) |
|
| 1100 | - $insideTag = $tagName; |
|
| 1133 | + elseif (!$isClosingTag && $insideTag === null) { |
|
| 1134 | + $insideTag = $tagName; |
|
| 1135 | + } |
|
| 1101 | 1136 | |
| 1102 | 1137 | // In all other cases, this tag must be invalid |
| 1103 | - else |
|
| 1104 | - unset($matches[$i]); |
|
| 1138 | + else { |
|
| 1139 | + unset($matches[$i]); |
|
| 1140 | + } |
|
| 1105 | 1141 | } |
| 1106 | 1142 | |
| 1107 | 1143 | // The next one is gonna be the other one. |
@@ -1109,8 +1145,9 @@ discard block |
||
| 1109 | 1145 | } |
| 1110 | 1146 | |
| 1111 | 1147 | // We're still inside a tag and had no chance for closure? |
| 1112 | - if ($insideTag !== null) |
|
| 1113 | - $matches[] = '[/' . $insideTag . ']'; |
|
| 1148 | + if ($insideTag !== null) { |
|
| 1149 | + $matches[] = '[/' . $insideTag . ']'; |
|
| 1150 | + } |
|
| 1114 | 1151 | |
| 1115 | 1152 | // And a complete text string again. |
| 1116 | 1153 | $text = implode('', $matches); |
@@ -1119,8 +1156,9 @@ discard block |
||
| 1119 | 1156 | // Quickly remove any tags which are back to back. |
| 1120 | 1157 | $backToBackPattern = '~\\[(' . implode('|', array_diff(array_keys($valid_tags), array('td', 'anchor'))) . ')[^<>\\[\\]]*\\]\s*\\[/\\1\\]~'; |
| 1121 | 1158 | $lastlen = 0; |
| 1122 | - while (strlen($text) !== $lastlen) |
|
| 1123 | - $lastlen = strlen($text = preg_replace($backToBackPattern, '', $text)); |
|
| 1159 | + while (strlen($text) !== $lastlen) { |
|
| 1160 | + $lastlen = strlen($text = preg_replace($backToBackPattern, '', $text)); |
|
| 1161 | + } |
|
| 1124 | 1162 | |
| 1125 | 1163 | // Need to sort the tags my name length. |
| 1126 | 1164 | uksort($valid_tags, 'sort_array_length'); |
@@ -1157,8 +1195,9 @@ discard block |
||
| 1157 | 1195 | $isCompetingTag = in_array($tag, $competing_tags); |
| 1158 | 1196 | |
| 1159 | 1197 | // Check if this might be one of those cleaned out tags. |
| 1160 | - if ($tag === '') |
|
| 1161 | - continue; |
|
| 1198 | + if ($tag === '') { |
|
| 1199 | + continue; |
|
| 1200 | + } |
|
| 1162 | 1201 | |
| 1163 | 1202 | // Special case: inside [code] blocks any code is left untouched. |
| 1164 | 1203 | elseif ($tag === 'code') |
@@ -1169,8 +1208,9 @@ discard block |
||
| 1169 | 1208 | $inCode = false; |
| 1170 | 1209 | |
| 1171 | 1210 | // Reopen tags that were closed before the code block. |
| 1172 | - if (!empty($inlineElements)) |
|
| 1173 | - $parts[$i + 4] .= '[' . implode('][', array_keys($inlineElements)) . ']'; |
|
| 1211 | + if (!empty($inlineElements)) { |
|
| 1212 | + $parts[$i + 4] .= '[' . implode('][', array_keys($inlineElements)) . ']'; |
|
| 1213 | + } |
|
| 1174 | 1214 | } |
| 1175 | 1215 | |
| 1176 | 1216 | // We're outside a coding and nobbc block and opening it. |
@@ -1199,8 +1239,9 @@ discard block |
||
| 1199 | 1239 | $inNoBbc = false; |
| 1200 | 1240 | |
| 1201 | 1241 | // Some inline elements might've been closed that need reopening. |
| 1202 | - if (!empty($inlineElements)) |
|
| 1203 | - $parts[$i + 4] .= '[' . implode('][', array_keys($inlineElements)) . ']'; |
|
| 1242 | + if (!empty($inlineElements)) { |
|
| 1243 | + $parts[$i + 4] .= '[' . implode('][', array_keys($inlineElements)) . ']'; |
|
| 1244 | + } |
|
| 1204 | 1245 | } |
| 1205 | 1246 | |
| 1206 | 1247 | // We're outside a nobbc and coding block and opening it. |
@@ -1220,8 +1261,9 @@ discard block |
||
| 1220 | 1261 | } |
| 1221 | 1262 | |
| 1222 | 1263 | // So, we're inside one of the special blocks: ignore any tag. |
| 1223 | - elseif ($inCode || $inNoBbc) |
|
| 1224 | - continue; |
|
| 1264 | + elseif ($inCode || $inNoBbc) { |
|
| 1265 | + continue; |
|
| 1266 | + } |
|
| 1225 | 1267 | |
| 1226 | 1268 | // We're dealing with an opening tag. |
| 1227 | 1269 | if ($isOpeningTag) |
@@ -1262,8 +1304,9 @@ discard block |
||
| 1262 | 1304 | if ($parts[$j + 3] === $tag) |
| 1263 | 1305 | { |
| 1264 | 1306 | // If it's an opening tag, increase the level. |
| 1265 | - if ($parts[$j + 2] === '') |
|
| 1266 | - $curLevel++; |
|
| 1307 | + if ($parts[$j + 2] === '') { |
|
| 1308 | + $curLevel++; |
|
| 1309 | + } |
|
| 1267 | 1310 | |
| 1268 | 1311 | // A closing tag, decrease the level. |
| 1269 | 1312 | else |
@@ -1286,13 +1329,15 @@ discard block |
||
| 1286 | 1329 | { |
| 1287 | 1330 | if ($isCompetingTag) |
| 1288 | 1331 | { |
| 1289 | - if (!isset($competingElements[$tag])) |
|
| 1290 | - $competingElements[$tag] = array(); |
|
| 1332 | + if (!isset($competingElements[$tag])) { |
|
| 1333 | + $competingElements[$tag] = array(); |
|
| 1334 | + } |
|
| 1291 | 1335 | |
| 1292 | 1336 | $competingElements[$tag][] = $parts[$i + 4]; |
| 1293 | 1337 | |
| 1294 | - if (count($competingElements[$tag]) > 1) |
|
| 1295 | - $parts[$i] .= '[/' . $tag . ']'; |
|
| 1338 | + if (count($competingElements[$tag]) > 1) { |
|
| 1339 | + $parts[$i] .= '[/' . $tag . ']'; |
|
| 1340 | + } |
|
| 1296 | 1341 | } |
| 1297 | 1342 | |
| 1298 | 1343 | $inlineElements[$elementContent] = $tag; |
@@ -1313,15 +1358,17 @@ discard block |
||
| 1313 | 1358 | $addClosingTags = array(); |
| 1314 | 1359 | while ($element = array_pop($blockElements)) |
| 1315 | 1360 | { |
| 1316 | - if ($element === $tag) |
|
| 1317 | - break; |
|
| 1361 | + if ($element === $tag) { |
|
| 1362 | + break; |
|
| 1363 | + } |
|
| 1318 | 1364 | |
| 1319 | 1365 | // Still a block tag was open not equal to this tag. |
| 1320 | 1366 | $addClosingTags[] = $element['type']; |
| 1321 | 1367 | } |
| 1322 | 1368 | |
| 1323 | - if (!empty($addClosingTags)) |
|
| 1324 | - $parts[$i + 1] = '[/' . implode('][/', array_reverse($addClosingTags)) . ']' . $parts[$i + 1]; |
|
| 1369 | + if (!empty($addClosingTags)) { |
|
| 1370 | + $parts[$i + 1] = '[/' . implode('][/', array_reverse($addClosingTags)) . ']' . $parts[$i + 1]; |
|
| 1371 | + } |
|
| 1325 | 1372 | |
| 1326 | 1373 | // Apparently the closing tag was not found on the stack. |
| 1327 | 1374 | if (!is_string($element) || $element !== $tag) |
@@ -1331,8 +1378,7 @@ discard block |
||
| 1331 | 1378 | $parts[$i + 2] = $parts[$i + 3] = $parts[$i + 4] = ''; |
| 1332 | 1379 | continue; |
| 1333 | 1380 | } |
| 1334 | - } |
|
| 1335 | - else |
|
| 1381 | + } else |
|
| 1336 | 1382 | { |
| 1337 | 1383 | // Get rid of this closing tag! |
| 1338 | 1384 | $parts[$i + 1] = $parts[$i + 2] = $parts[$i + 3] = $parts[$i + 4] = ''; |
@@ -1361,53 +1407,62 @@ discard block |
||
| 1361 | 1407 | unset($inlineElements[$tagContentToBeClosed]); |
| 1362 | 1408 | |
| 1363 | 1409 | // Was this the tag we were looking for? |
| 1364 | - if ($tagToBeClosed === $tag) |
|
| 1365 | - break; |
|
| 1410 | + if ($tagToBeClosed === $tag) { |
|
| 1411 | + break; |
|
| 1412 | + } |
|
| 1366 | 1413 | |
| 1367 | 1414 | // Nope, close it and look further! |
| 1368 | - else |
|
| 1369 | - $parts[$i] .= '[/' . $tagToBeClosed . ']'; |
|
| 1415 | + else { |
|
| 1416 | + $parts[$i] .= '[/' . $tagToBeClosed . ']'; |
|
| 1417 | + } |
|
| 1370 | 1418 | } |
| 1371 | 1419 | |
| 1372 | 1420 | if ($isCompetingTag && !empty($competingElements[$tag])) |
| 1373 | 1421 | { |
| 1374 | 1422 | array_pop($competingElements[$tag]); |
| 1375 | 1423 | |
| 1376 | - if (count($competingElements[$tag]) > 0) |
|
| 1377 | - $parts[$i + 5] = '[' . $tag . $competingElements[$tag][count($competingElements[$tag]) - 1] . $parts[$i + 5]; |
|
| 1424 | + if (count($competingElements[$tag]) > 0) { |
|
| 1425 | + $parts[$i + 5] = '[' . $tag . $competingElements[$tag][count($competingElements[$tag]) - 1] . $parts[$i + 5]; |
|
| 1426 | + } |
|
| 1378 | 1427 | } |
| 1379 | 1428 | } |
| 1380 | 1429 | |
| 1381 | 1430 | // Unexpected closing tag, ex-ter-mi-nate. |
| 1382 | - else |
|
| 1383 | - $parts[$i + 1] = $parts[$i + 2] = $parts[$i + 3] = $parts[$i + 4] = ''; |
|
| 1431 | + else { |
|
| 1432 | + $parts[$i + 1] = $parts[$i + 2] = $parts[$i + 3] = $parts[$i + 4] = ''; |
|
| 1433 | + } |
|
| 1384 | 1434 | } |
| 1385 | 1435 | } |
| 1386 | 1436 | } |
| 1387 | 1437 | |
| 1388 | 1438 | // Close the code tags. |
| 1389 | - if ($inCode) |
|
| 1390 | - $parts[$i] .= '[/code]'; |
|
| 1439 | + if ($inCode) { |
|
| 1440 | + $parts[$i] .= '[/code]'; |
|
| 1441 | + } |
|
| 1391 | 1442 | |
| 1392 | 1443 | // The same for nobbc tags. |
| 1393 | - elseif ($inNoBbc) |
|
| 1394 | - $parts[$i] .= '[/nobbc]'; |
|
| 1444 | + elseif ($inNoBbc) { |
|
| 1445 | + $parts[$i] .= '[/nobbc]'; |
|
| 1446 | + } |
|
| 1395 | 1447 | |
| 1396 | 1448 | // Still inline tags left unclosed? Close them now, better late than never. |
| 1397 | - elseif (!empty($inlineElements)) |
|
| 1398 | - $parts[$i] .= '[/' . implode('][/', array_reverse($inlineElements)) . ']'; |
|
| 1449 | + elseif (!empty($inlineElements)) { |
|
| 1450 | + $parts[$i] .= '[/' . implode('][/', array_reverse($inlineElements)) . ']'; |
|
| 1451 | + } |
|
| 1399 | 1452 | |
| 1400 | 1453 | // Now close the block elements. |
| 1401 | - if (!empty($blockElements)) |
|
| 1402 | - $parts[$i] .= '[/' . implode('][/', array_reverse($blockElements)) . ']'; |
|
| 1454 | + if (!empty($blockElements)) { |
|
| 1455 | + $parts[$i] .= '[/' . implode('][/', array_reverse($blockElements)) . ']'; |
|
| 1456 | + } |
|
| 1403 | 1457 | |
| 1404 | 1458 | $text = implode('', $parts); |
| 1405 | 1459 | } |
| 1406 | 1460 | |
| 1407 | 1461 | // Final clean up of back to back tags. |
| 1408 | 1462 | $lastlen = 0; |
| 1409 | - while (strlen($text) !== $lastlen) |
|
| 1410 | - $lastlen = strlen($text = preg_replace($backToBackPattern, '', $text)); |
|
| 1463 | + while (strlen($text) !== $lastlen) { |
|
| 1464 | + $lastlen = strlen($text = preg_replace($backToBackPattern, '', $text)); |
|
| 1465 | + } |
|
| 1411 | 1466 | |
| 1412 | 1467 | return $text; |
| 1413 | 1468 | } |
@@ -1436,22 +1491,25 @@ discard block |
||
| 1436 | 1491 | $context['template_layers'] = array(); |
| 1437 | 1492 | // Lets make sure we aren't going to output anything nasty. |
| 1438 | 1493 | @ob_end_clean(); |
| 1439 | - if (!empty($modSettings['enableCompressedOutput'])) |
|
| 1440 | - @ob_start('ob_gzhandler'); |
|
| 1441 | - else |
|
| 1442 | - @ob_start(); |
|
| 1494 | + if (!empty($modSettings['enableCompressedOutput'])) { |
|
| 1495 | + @ob_start('ob_gzhandler'); |
|
| 1496 | + } else { |
|
| 1497 | + @ob_start(); |
|
| 1498 | + } |
|
| 1443 | 1499 | |
| 1444 | 1500 | // If we don't have any locale better avoid broken js |
| 1445 | - if (empty($txt['lang_locale'])) |
|
| 1446 | - die(); |
|
| 1501 | + if (empty($txt['lang_locale'])) { |
|
| 1502 | + die(); |
|
| 1503 | + } |
|
| 1447 | 1504 | |
| 1448 | 1505 | $file_data = '(function ($) { |
| 1449 | 1506 | \'use strict\'; |
| 1450 | 1507 | |
| 1451 | 1508 | $.sceditor.locale[' . javaScriptEscape($txt['lang_locale']) . '] = {'; |
| 1452 | - foreach ($editortxt as $key => $val) |
|
| 1453 | - $file_data .= ' |
|
| 1509 | + foreach ($editortxt as $key => $val) { |
|
| 1510 | + $file_data .= ' |
|
| 1454 | 1511 | ' . javaScriptEscape($key) . ': ' . javaScriptEscape($val) . ','; |
| 1512 | + } |
|
| 1455 | 1513 | |
| 1456 | 1514 | $file_data .= ' |
| 1457 | 1515 | dateFormat: "day.month.year" |
@@ -1519,8 +1577,9 @@ discard block |
||
| 1519 | 1577 | ) |
| 1520 | 1578 | ); |
| 1521 | 1579 | $icon_data = array(); |
| 1522 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1523 | - $icon_data[] = $row; |
|
| 1580 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1581 | + $icon_data[] = $row; |
|
| 1582 | + } |
|
| 1524 | 1583 | $smcFunc['db_free_result']($request); |
| 1525 | 1584 | |
| 1526 | 1585 | $icons = array(); |
@@ -1535,9 +1594,9 @@ discard block |
||
| 1535 | 1594 | } |
| 1536 | 1595 | |
| 1537 | 1596 | cache_put_data('posting_icons-' . $board_id, $icons, 480); |
| 1597 | + } else { |
|
| 1598 | + $icons = $temp; |
|
| 1538 | 1599 | } |
| 1539 | - else |
|
| 1540 | - $icons = $temp; |
|
| 1541 | 1600 | } |
| 1542 | 1601 | call_integration_hook('integrate_load_message_icons', array(&$icons)); |
| 1543 | 1602 | |
@@ -1578,8 +1637,9 @@ discard block |
||
| 1578 | 1637 | { |
| 1579 | 1638 | // Some general stuff. |
| 1580 | 1639 | $settings['smileys_url'] = $modSettings['smileys_url'] . '/' . $user_info['smiley_set']; |
| 1581 | - if (!empty($context['drafts_autosave'])) |
|
| 1582 | - $context['drafts_autosave_frequency'] = empty($modSettings['drafts_autosave_frequency']) ? 60000 : $modSettings['drafts_autosave_frequency'] * 1000; |
|
| 1640 | + if (!empty($context['drafts_autosave'])) { |
|
| 1641 | + $context['drafts_autosave_frequency'] = empty($modSettings['drafts_autosave_frequency']) ? 60000 : $modSettings['drafts_autosave_frequency'] * 1000; |
|
| 1642 | + } |
|
| 1583 | 1643 | |
| 1584 | 1644 | // This really has some WYSIWYG stuff. |
| 1585 | 1645 | loadCSSFile('jquery.sceditor.css', array('force_current' => false, 'validate' => true), 'smf_jquery_sceditor'); |
@@ -1595,8 +1655,9 @@ discard block |
||
| 1595 | 1655 | var bbc_quote = \'' . addcslashes($txt['quote'], "'") . '\'; |
| 1596 | 1656 | var bbc_search_on = \'' . addcslashes($txt['search_on'], "'") . '\';'); |
| 1597 | 1657 | // editor language file |
| 1598 | - if (!empty($txt['lang_locale']) && $txt['lang_locale'] != 'en_US') |
|
| 1599 | - loadJavaScriptFile($scripturl . '?action=loadeditorlocale', array('external' => true), 'sceditor_language'); |
|
| 1658 | + if (!empty($txt['lang_locale']) && $txt['lang_locale'] != 'en_US') { |
|
| 1659 | + loadJavaScriptFile($scripturl . '?action=loadeditorlocale', array('external' => true), 'sceditor_language'); |
|
| 1660 | + } |
|
| 1600 | 1661 | |
| 1601 | 1662 | $context['shortcuts_text'] = $txt['shortcuts' . (!empty($context['drafts_save']) ? '_drafts' : '') . (stripos($_SERVER['HTTP_USER_AGENT'], 'Macintosh') !== false ? '_mac' : (isBrowser('is_firefox') ? '_firefox' : ''))]; |
| 1602 | 1663 | $context['show_spellchecking'] = !empty($modSettings['enableSpellChecking']) && (function_exists('pspell_new') || (function_exists('enchant_broker_init') && ($txt['lang_charset'] == 'UTF-8' || function_exists('iconv')))); |
@@ -1605,11 +1666,12 @@ discard block |
||
| 1605 | 1666 | loadJavaScriptFile('spellcheck.js', array(), 'smf_spellcheck'); |
| 1606 | 1667 | |
| 1607 | 1668 | // Some hidden information is needed in order to make the spell checking work. |
| 1608 | - if (!isset($_REQUEST['xml'])) |
|
| 1609 | - $context['insert_after_template'] .= ' |
|
| 1669 | + if (!isset($_REQUEST['xml'])) { |
|
| 1670 | + $context['insert_after_template'] .= ' |
|
| 1610 | 1671 | <form name="spell_form" id="spell_form" method="post" accept-charset="' . $context['character_set'] . '" target="spellWindow" action="' . $scripturl . '?action=spellcheck"> |
| 1611 | 1672 | <input type="hidden" name="spellstring" value=""> |
| 1612 | 1673 | </form>'; |
| 1674 | + } |
|
| 1613 | 1675 | } |
| 1614 | 1676 | } |
| 1615 | 1677 | |
@@ -1775,10 +1837,12 @@ discard block |
||
| 1775 | 1837 | |
| 1776 | 1838 | // Generate a list of buttons that shouldn't be shown - this should be the fastest way to do this. |
| 1777 | 1839 | $disabled_tags = array(); |
| 1778 | - if (!empty($modSettings['disabledBBC'])) |
|
| 1779 | - $disabled_tags = explode(',', $modSettings['disabledBBC']); |
|
| 1780 | - if (empty($modSettings['enableEmbeddedFlash'])) |
|
| 1781 | - $disabled_tags[] = 'flash'; |
|
| 1840 | + if (!empty($modSettings['disabledBBC'])) { |
|
| 1841 | + $disabled_tags = explode(',', $modSettings['disabledBBC']); |
|
| 1842 | + } |
|
| 1843 | + if (empty($modSettings['enableEmbeddedFlash'])) { |
|
| 1844 | + $disabled_tags[] = 'flash'; |
|
| 1845 | + } |
|
| 1782 | 1846 | |
| 1783 | 1847 | foreach ($disabled_tags as $tag) |
| 1784 | 1848 | { |
@@ -1788,9 +1852,10 @@ discard block |
||
| 1788 | 1852 | $context['disabled_tags']['orderedlist'] = true; |
| 1789 | 1853 | } |
| 1790 | 1854 | |
| 1791 | - foreach ($editor_tag_map as $thisTag => $tagNameBBC) |
|
| 1792 | - if ($tag === $thisTag) |
|
| 1855 | + foreach ($editor_tag_map as $thisTag => $tagNameBBC) { |
|
| 1856 | + if ($tag === $thisTag) |
|
| 1793 | 1857 | $context['disabled_tags'][$tagNameBBC] = true; |
| 1858 | + } |
|
| 1794 | 1859 | |
| 1795 | 1860 | $context['disabled_tags'][trim($tag)] = true; |
| 1796 | 1861 | } |
@@ -1800,19 +1865,21 @@ discard block |
||
| 1800 | 1865 | $context['bbc_toolbar'] = array(); |
| 1801 | 1866 | foreach ($context['bbc_tags'] as $row => $tagRow) |
| 1802 | 1867 | { |
| 1803 | - if (!isset($context['bbc_toolbar'][$row])) |
|
| 1804 | - $context['bbc_toolbar'][$row] = array(); |
|
| 1868 | + if (!isset($context['bbc_toolbar'][$row])) { |
|
| 1869 | + $context['bbc_toolbar'][$row] = array(); |
|
| 1870 | + } |
|
| 1805 | 1871 | $tagsRow = array(); |
| 1806 | 1872 | foreach ($tagRow as $tag) |
| 1807 | 1873 | { |
| 1808 | 1874 | if ((!empty($tag['code'])) && empty($context['disabled_tags'][$tag['code']])) |
| 1809 | 1875 | { |
| 1810 | 1876 | $tagsRow[] = $tag['code']; |
| 1811 | - if (isset($tag['image'])) |
|
| 1812 | - $bbcodes_styles .= ' |
|
| 1877 | + if (isset($tag['image'])) { |
|
| 1878 | + $bbcodes_styles .= ' |
|
| 1813 | 1879 | .sceditor-button-' . $tag['code'] . ' div { |
| 1814 | 1880 | background: url(\'' . $settings['default_theme_url'] . '/images/bbc/' . $tag['image'] . '.png\'); |
| 1815 | 1881 | }'; |
| 1882 | + } |
|
| 1816 | 1883 | if (isset($tag['before'])) |
| 1817 | 1884 | { |
| 1818 | 1885 | $context['bbcodes_handlers'] .= ' |
@@ -1826,8 +1893,7 @@ discard block |
||
| 1826 | 1893 | });'; |
| 1827 | 1894 | } |
| 1828 | 1895 | |
| 1829 | - } |
|
| 1830 | - else |
|
| 1896 | + } else |
|
| 1831 | 1897 | { |
| 1832 | 1898 | $context['bbc_toolbar'][$row][] = implode(',', $tagsRow); |
| 1833 | 1899 | $tagsRow = array(); |
@@ -1838,14 +1904,16 @@ discard block |
||
| 1838 | 1904 | { |
| 1839 | 1905 | $context['bbc_toolbar'][$row][] = implode(',', $tagsRow); |
| 1840 | 1906 | $tagsRow = array(); |
| 1841 | - if (!isset($context['disabled_tags']['font'])) |
|
| 1842 | - $tagsRow[] = 'font'; |
|
| 1843 | - if (!isset($context['disabled_tags']['size'])) |
|
| 1844 | - $tagsRow[] = 'size'; |
|
| 1845 | - if (!isset($context['disabled_tags']['color'])) |
|
| 1846 | - $tagsRow[] = 'color'; |
|
| 1847 | - } |
|
| 1848 | - elseif ($row == 1 && empty($modSettings['disable_wysiwyg'])) |
|
| 1907 | + if (!isset($context['disabled_tags']['font'])) { |
|
| 1908 | + $tagsRow[] = 'font'; |
|
| 1909 | + } |
|
| 1910 | + if (!isset($context['disabled_tags']['size'])) { |
|
| 1911 | + $tagsRow[] = 'size'; |
|
| 1912 | + } |
|
| 1913 | + if (!isset($context['disabled_tags']['color'])) { |
|
| 1914 | + $tagsRow[] = 'color'; |
|
| 1915 | + } |
|
| 1916 | + } elseif ($row == 1 && empty($modSettings['disable_wysiwyg'])) |
|
| 1849 | 1917 | { |
| 1850 | 1918 | $tmp = array(); |
| 1851 | 1919 | $tagsRow[] = 'removeformat'; |
@@ -1856,13 +1924,15 @@ discard block |
||
| 1856 | 1924 | } |
| 1857 | 1925 | } |
| 1858 | 1926 | |
| 1859 | - if (!empty($tagsRow)) |
|
| 1860 | - $context['bbc_toolbar'][$row][] = implode(',', $tagsRow); |
|
| 1927 | + if (!empty($tagsRow)) { |
|
| 1928 | + $context['bbc_toolbar'][$row][] = implode(',', $tagsRow); |
|
| 1929 | + } |
|
| 1861 | 1930 | } |
| 1862 | - if (!empty($bbcodes_styles)) |
|
| 1863 | - $context['html_headers'] .= ' |
|
| 1931 | + if (!empty($bbcodes_styles)) { |
|
| 1932 | + $context['html_headers'] .= ' |
|
| 1864 | 1933 | <style>' . $bbcodes_styles . ' |
| 1865 | 1934 | </style>'; |
| 1935 | + } |
|
| 1866 | 1936 | } |
| 1867 | 1937 | |
| 1868 | 1938 | // Initialize smiley array... if not loaded before. |
@@ -1874,8 +1944,8 @@ discard block |
||
| 1874 | 1944 | ); |
| 1875 | 1945 | |
| 1876 | 1946 | // Load smileys - don't bother to run a query if we're not using the database's ones anyhow. |
| 1877 | - if (empty($modSettings['smiley_enable']) && $user_info['smiley_set'] != 'none') |
|
| 1878 | - $context['smileys']['postform'][] = array( |
|
| 1947 | + if (empty($modSettings['smiley_enable']) && $user_info['smiley_set'] != 'none') { |
|
| 1948 | + $context['smileys']['postform'][] = array( |
|
| 1879 | 1949 | 'smileys' => array( |
| 1880 | 1950 | array( |
| 1881 | 1951 | 'code' => ':)', |
@@ -1961,7 +2031,7 @@ discard block |
||
| 1961 | 2031 | ), |
| 1962 | 2032 | 'isLast' => true, |
| 1963 | 2033 | ); |
| 1964 | - elseif ($user_info['smiley_set'] != 'none') |
|
| 2034 | + } elseif ($user_info['smiley_set'] != 'none') |
|
| 1965 | 2035 | { |
| 1966 | 2036 | if (($temp = cache_get_data('posting_smileys', 480)) == null) |
| 1967 | 2037 | { |
@@ -1984,17 +2054,19 @@ discard block |
||
| 1984 | 2054 | |
| 1985 | 2055 | foreach ($context['smileys'] as $section => $smileyRows) |
| 1986 | 2056 | { |
| 1987 | - foreach ($smileyRows as $rowIndex => $smileys) |
|
| 1988 | - $context['smileys'][$section][$rowIndex]['smileys'][count($smileys['smileys']) - 1]['isLast'] = true; |
|
| 2057 | + foreach ($smileyRows as $rowIndex => $smileys) { |
|
| 2058 | + $context['smileys'][$section][$rowIndex]['smileys'][count($smileys['smileys']) - 1]['isLast'] = true; |
|
| 2059 | + } |
|
| 1989 | 2060 | |
| 1990 | - if (!empty($smileyRows)) |
|
| 1991 | - $context['smileys'][$section][count($smileyRows) - 1]['isLast'] = true; |
|
| 2061 | + if (!empty($smileyRows)) { |
|
| 2062 | + $context['smileys'][$section][count($smileyRows) - 1]['isLast'] = true; |
|
| 2063 | + } |
|
| 1992 | 2064 | } |
| 1993 | 2065 | |
| 1994 | 2066 | cache_put_data('posting_smileys', $context['smileys'], 480); |
| 2067 | + } else { |
|
| 2068 | + $context['smileys'] = $temp; |
|
| 1995 | 2069 | } |
| 1996 | - else |
|
| 1997 | - $context['smileys'] = $temp; |
|
| 1998 | 2070 | } |
| 1999 | 2071 | } |
| 2000 | 2072 | |
@@ -2020,8 +2092,9 @@ discard block |
||
| 2020 | 2092 | loadTemplate('GenericControls'); |
| 2021 | 2093 | |
| 2022 | 2094 | // Some javascript ma'am? |
| 2023 | - if (!empty($verificationOptions['override_visual']) || (!empty($modSettings['visual_verification_type']) && !isset($verificationOptions['override_visual']))) |
|
| 2024 | - loadJavaScriptFile('captcha.js', array(), 'smf_captcha'); |
|
| 2095 | + if (!empty($verificationOptions['override_visual']) || (!empty($modSettings['visual_verification_type']) && !isset($verificationOptions['override_visual']))) { |
|
| 2096 | + loadJavaScriptFile('captcha.js', array(), 'smf_captcha'); |
|
| 2097 | + } |
|
| 2025 | 2098 | |
| 2026 | 2099 | $context['use_graphic_library'] = in_array('gd', get_loaded_extensions()); |
| 2027 | 2100 | |
@@ -2034,8 +2107,8 @@ discard block |
||
| 2034 | 2107 | $isNew = !isset($context['controls']['verification'][$verificationOptions['id']]); |
| 2035 | 2108 | |
| 2036 | 2109 | // Log this into our collection. |
| 2037 | - if ($isNew) |
|
| 2038 | - $context['controls']['verification'][$verificationOptions['id']] = array( |
|
| 2110 | + if ($isNew) { |
|
| 2111 | + $context['controls']['verification'][$verificationOptions['id']] = array( |
|
| 2039 | 2112 | 'id' => $verificationOptions['id'], |
| 2040 | 2113 | 'empty_field' => empty($verificationOptions['no_empty_field']), |
| 2041 | 2114 | 'show_visual' => !empty($verificationOptions['override_visual']) || (!empty($modSettings['visual_verification_type']) && !isset($verificationOptions['override_visual'])), |
@@ -2046,13 +2119,15 @@ discard block |
||
| 2046 | 2119 | 'questions' => array(), |
| 2047 | 2120 | 'can_recaptcha' => !empty($modSettings['recaptcha_enabled']) && !empty($modSettings['recaptcha_site_key']) && !empty($modSettings['recaptcha_secret_key']), |
| 2048 | 2121 | ); |
| 2122 | + } |
|
| 2049 | 2123 | $thisVerification = &$context['controls']['verification'][$verificationOptions['id']]; |
| 2050 | 2124 | |
| 2051 | 2125 | // Is there actually going to be anything? |
| 2052 | - if (empty($thisVerification['show_visual']) && empty($thisVerification['number_questions']) && empty($thisVerification['can_recaptcha'])) |
|
| 2053 | - return false; |
|
| 2054 | - elseif (!$isNew && !$do_test) |
|
| 2055 | - return true; |
|
| 2126 | + if (empty($thisVerification['show_visual']) && empty($thisVerification['number_questions']) && empty($thisVerification['can_recaptcha'])) { |
|
| 2127 | + return false; |
|
| 2128 | + } elseif (!$isNew && !$do_test) { |
|
| 2129 | + return true; |
|
| 2130 | + } |
|
| 2056 | 2131 | |
| 2057 | 2132 | // Sanitize reCAPTCHA fields? |
| 2058 | 2133 | if ($thisVerification['can_recaptcha']) |
@@ -2065,11 +2140,12 @@ discard block |
||
| 2065 | 2140 | } |
| 2066 | 2141 | |
| 2067 | 2142 | // Add javascript for the object. |
| 2068 | - if ($context['controls']['verification'][$verificationOptions['id']]['show_visual']) |
|
| 2069 | - $context['insert_after_template'] .= ' |
|
| 2143 | + if ($context['controls']['verification'][$verificationOptions['id']]['show_visual']) { |
|
| 2144 | + $context['insert_after_template'] .= ' |
|
| 2070 | 2145 | <script> |
| 2071 | 2146 | var verification' . $verificationOptions['id'] . 'Handle = new smfCaptcha("' . $thisVerification['image_href'] . '", "' . $verificationOptions['id'] . '", ' . ($context['use_graphic_library'] ? 1 : 0) . '); |
| 2072 | 2147 | </script>'; |
| 2148 | + } |
|
| 2073 | 2149 | |
| 2074 | 2150 | // If we want questions do we have a cache of all the IDs? |
| 2075 | 2151 | if (!empty($thisVerification['number_questions']) && empty($modSettings['question_id_cache'])) |
@@ -2092,8 +2168,9 @@ discard block |
||
| 2092 | 2168 | unset ($row['id_question']); |
| 2093 | 2169 | // Make them all lowercase. We can't directly use $smcFunc['strtolower'] with array_walk, so do it manually, eh? |
| 2094 | 2170 | $row['answers'] = smf_json_decode($row['answers'], true); |
| 2095 | - foreach ($row['answers'] as $k => $v) |
|
| 2096 | - $row['answers'][$k] = $smcFunc['strtolower']($v); |
|
| 2171 | + foreach ($row['answers'] as $k => $v) { |
|
| 2172 | + $row['answers'][$k] = $smcFunc['strtolower']($v); |
|
| 2173 | + } |
|
| 2097 | 2174 | |
| 2098 | 2175 | $modSettings['question_id_cache']['questions'][$id_question] = $row; |
| 2099 | 2176 | $modSettings['question_id_cache']['langs'][$row['lngfile']][] = $id_question; |
@@ -2104,35 +2181,42 @@ discard block |
||
| 2104 | 2181 | } |
| 2105 | 2182 | } |
| 2106 | 2183 | |
| 2107 | - if (!isset($_SESSION[$verificationOptions['id'] . '_vv'])) |
|
| 2108 | - $_SESSION[$verificationOptions['id'] . '_vv'] = array(); |
|
| 2184 | + if (!isset($_SESSION[$verificationOptions['id'] . '_vv'])) { |
|
| 2185 | + $_SESSION[$verificationOptions['id'] . '_vv'] = array(); |
|
| 2186 | + } |
|
| 2109 | 2187 | |
| 2110 | 2188 | // Do we need to refresh the verification? |
| 2111 | - 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'])) |
|
| 2112 | - $force_refresh = true; |
|
| 2113 | - else |
|
| 2114 | - $force_refresh = false; |
|
| 2189 | + 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'])) { |
|
| 2190 | + $force_refresh = true; |
|
| 2191 | + } else { |
|
| 2192 | + $force_refresh = false; |
|
| 2193 | + } |
|
| 2115 | 2194 | |
| 2116 | 2195 | // This can also force a fresh, although unlikely. |
| 2117 | - if (($thisVerification['show_visual'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['code'])) || ($thisVerification['number_questions'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['q']))) |
|
| 2118 | - $force_refresh = true; |
|
| 2196 | + if (($thisVerification['show_visual'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['code'])) || ($thisVerification['number_questions'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['q']))) { |
|
| 2197 | + $force_refresh = true; |
|
| 2198 | + } |
|
| 2119 | 2199 | |
| 2120 | 2200 | $verification_errors = array(); |
| 2121 | 2201 | // Start with any testing. |
| 2122 | 2202 | if ($do_test) |
| 2123 | 2203 | { |
| 2124 | 2204 | // This cannot happen! |
| 2125 | - if (!isset($_SESSION[$verificationOptions['id'] . '_vv']['count'])) |
|
| 2126 | - fatal_lang_error('no_access', false); |
|
| 2205 | + if (!isset($_SESSION[$verificationOptions['id'] . '_vv']['count'])) { |
|
| 2206 | + fatal_lang_error('no_access', false); |
|
| 2207 | + } |
|
| 2127 | 2208 | // ... nor this! |
| 2128 | - if ($thisVerification['number_questions'] && (!isset($_SESSION[$verificationOptions['id'] . '_vv']['q']) || !isset($_REQUEST[$verificationOptions['id'] . '_vv']['q']))) |
|
| 2129 | - fatal_lang_error('no_access', false); |
|
| 2209 | + if ($thisVerification['number_questions'] && (!isset($_SESSION[$verificationOptions['id'] . '_vv']['q']) || !isset($_REQUEST[$verificationOptions['id'] . '_vv']['q']))) { |
|
| 2210 | + fatal_lang_error('no_access', false); |
|
| 2211 | + } |
|
| 2130 | 2212 | // Hmm, it's requested but not actually declared. This shouldn't happen. |
| 2131 | - if ($thisVerification['empty_field'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field'])) |
|
| 2132 | - fatal_lang_error('no_access', false); |
|
| 2213 | + if ($thisVerification['empty_field'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field'])) { |
|
| 2214 | + fatal_lang_error('no_access', false); |
|
| 2215 | + } |
|
| 2133 | 2216 | // While we're here, did the user do something bad? |
| 2134 | - if ($thisVerification['empty_field'] && !empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field']) && !empty($_REQUEST[$_SESSION[$verificationOptions['id'] . '_vv']['empty_field']])) |
|
| 2135 | - $verification_errors[] = 'wrong_verification_answer'; |
|
| 2217 | + if ($thisVerification['empty_field'] && !empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field']) && !empty($_REQUEST[$_SESSION[$verificationOptions['id'] . '_vv']['empty_field']])) { |
|
| 2218 | + $verification_errors[] = 'wrong_verification_answer'; |
|
| 2219 | + } |
|
| 2136 | 2220 | |
| 2137 | 2221 | if ($thisVerification['can_recaptcha']) |
| 2138 | 2222 | { |
@@ -2143,22 +2227,25 @@ discard block |
||
| 2143 | 2227 | { |
| 2144 | 2228 | $resp = $reCaptcha->verify($_POST['g-recaptcha-response'], $user_info['ip']); |
| 2145 | 2229 | |
| 2146 | - if (!$resp->isSuccess()) |
|
| 2147 | - $verification_errors[] = 'wrong_verification_code'; |
|
| 2230 | + if (!$resp->isSuccess()) { |
|
| 2231 | + $verification_errors[] = 'wrong_verification_code'; |
|
| 2232 | + } |
|
| 2233 | + } else { |
|
| 2234 | + $verification_errors[] = 'wrong_verification_code'; |
|
| 2148 | 2235 | } |
| 2149 | - else |
|
| 2150 | - $verification_errors[] = 'wrong_verification_code'; |
|
| 2151 | 2236 | } |
| 2152 | - 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'])) |
|
| 2153 | - $verification_errors[] = 'wrong_verification_code'; |
|
| 2237 | + 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'])) { |
|
| 2238 | + $verification_errors[] = 'wrong_verification_code'; |
|
| 2239 | + } |
|
| 2154 | 2240 | if ($thisVerification['number_questions']) |
| 2155 | 2241 | { |
| 2156 | 2242 | $incorrectQuestions = array(); |
| 2157 | 2243 | foreach ($_SESSION[$verificationOptions['id'] . '_vv']['q'] as $q) |
| 2158 | 2244 | { |
| 2159 | 2245 | // We don't have this question any more, thus no answers. |
| 2160 | - if (!isset($modSettings['question_id_cache']['questions'][$q])) |
|
| 2161 | - continue; |
|
| 2246 | + if (!isset($modSettings['question_id_cache']['questions'][$q])) { |
|
| 2247 | + continue; |
|
| 2248 | + } |
|
| 2162 | 2249 | // This is quite complex. We have our question but it might have multiple answers. |
| 2163 | 2250 | // First, did they actually answer this question? |
| 2164 | 2251 | if (!isset($_REQUEST[$verificationOptions['id'] . '_vv']['q'][$q]) || trim($_REQUEST[$verificationOptions['id'] . '_vv']['q'][$q]) == '') |
@@ -2170,24 +2257,28 @@ discard block |
||
| 2170 | 2257 | else |
| 2171 | 2258 | { |
| 2172 | 2259 | $given_answer = trim($smcFunc['htmlspecialchars'](strtolower($_REQUEST[$verificationOptions['id'] . '_vv']['q'][$q]))); |
| 2173 | - if (!in_array($given_answer, $modSettings['question_id_cache']['questions'][$q]['answers'])) |
|
| 2174 | - $incorrectQuestions[] = $q; |
|
| 2260 | + if (!in_array($given_answer, $modSettings['question_id_cache']['questions'][$q]['answers'])) { |
|
| 2261 | + $incorrectQuestions[] = $q; |
|
| 2262 | + } |
|
| 2175 | 2263 | } |
| 2176 | 2264 | } |
| 2177 | 2265 | |
| 2178 | - if (!empty($incorrectQuestions)) |
|
| 2179 | - $verification_errors[] = 'wrong_verification_answer'; |
|
| 2266 | + if (!empty($incorrectQuestions)) { |
|
| 2267 | + $verification_errors[] = 'wrong_verification_answer'; |
|
| 2268 | + } |
|
| 2180 | 2269 | } |
| 2181 | 2270 | } |
| 2182 | 2271 | |
| 2183 | 2272 | // Any errors means we refresh potentially. |
| 2184 | 2273 | if (!empty($verification_errors)) |
| 2185 | 2274 | { |
| 2186 | - if (empty($_SESSION[$verificationOptions['id'] . '_vv']['errors'])) |
|
| 2187 | - $_SESSION[$verificationOptions['id'] . '_vv']['errors'] = 0; |
|
| 2275 | + if (empty($_SESSION[$verificationOptions['id'] . '_vv']['errors'])) { |
|
| 2276 | + $_SESSION[$verificationOptions['id'] . '_vv']['errors'] = 0; |
|
| 2277 | + } |
|
| 2188 | 2278 | // Too many errors? |
| 2189 | - elseif ($_SESSION[$verificationOptions['id'] . '_vv']['errors'] > $thisVerification['max_errors']) |
|
| 2190 | - $force_refresh = true; |
|
| 2279 | + elseif ($_SESSION[$verificationOptions['id'] . '_vv']['errors'] > $thisVerification['max_errors']) { |
|
| 2280 | + $force_refresh = true; |
|
| 2281 | + } |
|
| 2191 | 2282 | |
| 2192 | 2283 | // Keep a track of these. |
| 2193 | 2284 | $_SESSION[$verificationOptions['id'] . '_vv']['errors']++; |
@@ -2220,8 +2311,9 @@ discard block |
||
| 2220 | 2311 | // Are we overriding the range? |
| 2221 | 2312 | $character_range = !empty($verificationOptions['override_range']) ? $verificationOptions['override_range'] : $context['standard_captcha_range']; |
| 2222 | 2313 | |
| 2223 | - for ($i = 0; $i < 6; $i++) |
|
| 2224 | - $_SESSION[$verificationOptions['id'] . '_vv']['code'] .= $character_range[array_rand($character_range)]; |
|
| 2314 | + for ($i = 0; $i < 6; $i++) { |
|
| 2315 | + $_SESSION[$verificationOptions['id'] . '_vv']['code'] .= $character_range[array_rand($character_range)]; |
|
| 2316 | + } |
|
| 2225 | 2317 | } |
| 2226 | 2318 | |
| 2227 | 2319 | // Getting some new questions? |
@@ -2229,8 +2321,9 @@ discard block |
||
| 2229 | 2321 | { |
| 2230 | 2322 | // Attempt to try the current page's language, followed by the user's preference, followed by the site default. |
| 2231 | 2323 | $possible_langs = array(); |
| 2232 | - if (isset($_SESSION['language'])) |
|
| 2233 | - $possible_langs[] = strtr($_SESSION['language'], array('-utf8' => '')); |
|
| 2324 | + if (isset($_SESSION['language'])) { |
|
| 2325 | + $possible_langs[] = strtr($_SESSION['language'], array('-utf8' => '')); |
|
| 2326 | + } |
|
| 2234 | 2327 | if (!empty($user_info['language'])); |
| 2235 | 2328 | $possible_langs[] = $user_info['language']; |
| 2236 | 2329 | $possible_langs[] = $language; |
@@ -2249,8 +2342,7 @@ discard block |
||
| 2249 | 2342 | } |
| 2250 | 2343 | } |
| 2251 | 2344 | } |
| 2252 | - } |
|
| 2253 | - else |
|
| 2345 | + } else |
|
| 2254 | 2346 | { |
| 2255 | 2347 | // Same questions as before. |
| 2256 | 2348 | $questionIDs = !empty($_SESSION[$verificationOptions['id'] . '_vv']['q']) ? $_SESSION[$verificationOptions['id'] . '_vv']['q'] : array(); |
@@ -2260,8 +2352,9 @@ discard block |
||
| 2260 | 2352 | // If we do have an empty field, it would be nice to hide it from legitimate users who shouldn't be populating it anyway. |
| 2261 | 2353 | if (!empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field'])) |
| 2262 | 2354 | { |
| 2263 | - if (!isset($context['html_headers'])) |
|
| 2264 | - $context['html_headers'] = ''; |
|
| 2355 | + if (!isset($context['html_headers'])) { |
|
| 2356 | + $context['html_headers'] = ''; |
|
| 2357 | + } |
|
| 2265 | 2358 | $context['html_headers'] .= '<style>.vv_special { display:none; }</style>'; |
| 2266 | 2359 | } |
| 2267 | 2360 | |
@@ -2287,11 +2380,13 @@ discard block |
||
| 2287 | 2380 | $_SESSION[$verificationOptions['id'] . '_vv']['count'] = empty($_SESSION[$verificationOptions['id'] . '_vv']['count']) ? 1 : $_SESSION[$verificationOptions['id'] . '_vv']['count'] + 1; |
| 2288 | 2381 | |
| 2289 | 2382 | // Return errors if we have them. |
| 2290 | - if (!empty($verification_errors)) |
|
| 2291 | - return $verification_errors; |
|
| 2383 | + if (!empty($verification_errors)) { |
|
| 2384 | + return $verification_errors; |
|
| 2385 | + } |
|
| 2292 | 2386 | // If we had a test that one, make a note. |
| 2293 | - elseif ($do_test) |
|
| 2294 | - $_SESSION[$verificationOptions['id'] . '_vv']['did_pass'] = true; |
|
| 2387 | + elseif ($do_test) { |
|
| 2388 | + $_SESSION[$verificationOptions['id'] . '_vv']['did_pass'] = true; |
|
| 2389 | + } |
|
| 2295 | 2390 | |
| 2296 | 2391 | // Say that everything went well chaps. |
| 2297 | 2392 | return true; |
@@ -2316,8 +2411,9 @@ discard block |
||
| 2316 | 2411 | call_integration_hook('integrate_autosuggest', array(&$searchTypes)); |
| 2317 | 2412 | |
| 2318 | 2413 | // If we're just checking the callback function is registered return true or false. |
| 2319 | - if ($checkRegistered != null) |
|
| 2320 | - return isset($searchTypes[$checkRegistered]) && function_exists('AutoSuggest_Search_' . $checkRegistered); |
|
| 2414 | + if ($checkRegistered != null) { |
|
| 2415 | + return isset($searchTypes[$checkRegistered]) && function_exists('AutoSuggest_Search_' . $checkRegistered); |
|
| 2416 | + } |
|
| 2321 | 2417 | |
| 2322 | 2418 | checkSession('get'); |
| 2323 | 2419 | loadTemplate('Xml'); |
@@ -2468,24 +2564,27 @@ discard block |
||
| 2468 | 2564 | foreach ($possible_versions as $ver) |
| 2469 | 2565 | { |
| 2470 | 2566 | $ver = trim($ver); |
| 2471 | - if (strpos($ver, 'SMF') === 0) |
|
| 2472 | - $versions[] = $ver; |
|
| 2567 | + if (strpos($ver, 'SMF') === 0) { |
|
| 2568 | + $versions[] = $ver; |
|
| 2569 | + } |
|
| 2473 | 2570 | } |
| 2474 | 2571 | } |
| 2475 | 2572 | $smcFunc['db_free_result']($request); |
| 2476 | 2573 | |
| 2477 | 2574 | // Just in case we don't have ANYthing. |
| 2478 | - if (empty($versions)) |
|
| 2479 | - $versions = array('SMF 2.0'); |
|
| 2575 | + if (empty($versions)) { |
|
| 2576 | + $versions = array('SMF 2.0'); |
|
| 2577 | + } |
|
| 2480 | 2578 | |
| 2481 | - foreach ($versions as $id => $version) |
|
| 2482 | - if (strpos($version, strtoupper($_REQUEST['search'])) !== false) |
|
| 2579 | + foreach ($versions as $id => $version) { |
|
| 2580 | + if (strpos($version, strtoupper($_REQUEST['search'])) !== false) |
|
| 2483 | 2581 | $xml_data['items']['children'][] = array( |
| 2484 | 2582 | 'attributes' => array( |
| 2485 | 2583 | 'id' => $id, |
| 2486 | 2584 | ), |
| 2487 | 2585 | 'value' => $version, |
| 2488 | 2586 | ); |
| 2587 | + } |
|
| 2489 | 2588 | |
| 2490 | 2589 | return $xml_data; |
| 2491 | 2590 | } |
@@ -14,8 +14,9 @@ discard block |
||
| 14 | 14 | * @version 2.1 Beta 4 |
| 15 | 15 | */ |
| 16 | 16 | |
| 17 | -if (!defined('SMF')) |
|
| 17 | +if (!defined('SMF')) { |
|
| 18 | 18 | die('No direct access...'); |
| 19 | +} |
|
| 19 | 20 | |
| 20 | 21 | /** |
| 21 | 22 | * Fetches a list of boards and (optional) categories including |
@@ -37,11 +38,12 @@ discard block |
||
| 37 | 38 | require_once($sourcedir . '/Subs-Boards.php'); |
| 38 | 39 | |
| 39 | 40 | // For performance, track the latest post while going through the boards. |
| 40 | - if (!empty($boardIndexOptions['set_latest_post'])) |
|
| 41 | - $latest_post = array( |
|
| 41 | + if (!empty($boardIndexOptions['set_latest_post'])) { |
|
| 42 | + $latest_post = array( |
|
| 42 | 43 | 'timestamp' => 0, |
| 43 | 44 | 'ref' => 0, |
| 44 | 45 | ); |
| 46 | + } |
|
| 45 | 47 | |
| 46 | 48 | // Find all boards and categories, as well as related information. This will be sorted by the natural order of boards and categories, which we control. |
| 47 | 49 | $result_boards = $smcFunc['db_query']('', ' |
@@ -74,10 +76,11 @@ discard block |
||
| 74 | 76 | ); |
| 75 | 77 | |
| 76 | 78 | // Start with an empty array. |
| 77 | - if ($boardIndexOptions['include_categories']) |
|
| 78 | - $categories = array(); |
|
| 79 | - else |
|
| 80 | - $this_category = array(); |
|
| 79 | + if ($boardIndexOptions['include_categories']) { |
|
| 80 | + $categories = array(); |
|
| 81 | + } else { |
|
| 82 | + $this_category = array(); |
|
| 83 | + } |
|
| 81 | 84 | $boards = array(); |
| 82 | 85 | |
| 83 | 86 | // Run through the categories and boards (or only boards).... |
@@ -88,8 +91,9 @@ discard block |
||
| 88 | 91 | $row_board['is_read'] = !empty($row_board['is_read']) || $ignoreThisBoard ? '1' : '0'; |
| 89 | 92 | |
| 90 | 93 | // Add parent boards to the $boards list later used to fetch moderators |
| 91 | - if ($row_board['id_parent'] == $boardIndexOptions['parent_id']) |
|
| 92 | - $boards[] = $row_board['id_board']; |
|
| 94 | + if ($row_board['id_parent'] == $boardIndexOptions['parent_id']) { |
|
| 95 | + $boards[] = $row_board['id_board']; |
|
| 96 | + } |
|
| 93 | 97 | |
| 94 | 98 | if ($boardIndexOptions['include_categories']) |
| 95 | 99 | { |
@@ -111,8 +115,9 @@ discard block |
||
| 111 | 115 | } |
| 112 | 116 | |
| 113 | 117 | // If this board has new posts in it (and isn't the recycle bin!) then the category is new. |
| 114 | - if (empty($modSettings['recycle_enable']) || $modSettings['recycle_board'] != $row_board['id_board']) |
|
| 115 | - $categories[$row_board['id_cat']]['new'] |= empty($row_board['is_read']) && $row_board['poster_name'] != ''; |
|
| 118 | + if (empty($modSettings['recycle_enable']) || $modSettings['recycle_board'] != $row_board['id_board']) { |
|
| 119 | + $categories[$row_board['id_cat']]['new'] |= empty($row_board['is_read']) && $row_board['poster_name'] != ''; |
|
| 120 | + } |
|
| 116 | 121 | |
| 117 | 122 | // Avoid showing category unread link where it only has redirection boards. |
| 118 | 123 | $categories[$row_board['id_cat']]['show_unread'] = !empty($categories[$row_board['id_cat']]['show_unread']) ? 1 : !$row_board['is_redirect']; |
@@ -160,14 +165,12 @@ discard block |
||
| 160 | 165 | { |
| 161 | 166 | $this_category[$row_board['id_board']]['board_class'] = 'redirect'; |
| 162 | 167 | $this_category[$row_board['id_board']]['board_tooltip'] = $txt['redirect_board']; |
| 163 | - } |
|
| 164 | - elseif ($this_category[$row_board['id_board']]['new'] || $context['user']['is_guest']) |
|
| 168 | + } elseif ($this_category[$row_board['id_board']]['new'] || $context['user']['is_guest']) |
|
| 165 | 169 | { |
| 166 | 170 | // If we're showing to guests, we want to give them the idea that something interesting is going on! |
| 167 | 171 | $this_category[$row_board['id_board']]['board_class'] = 'on'; |
| 168 | 172 | $this_category[$row_board['id_board']]['board_tooltip'] = $txt['new_posts']; |
| 169 | - } |
|
| 170 | - else |
|
| 173 | + } else |
|
| 171 | 174 | { |
| 172 | 175 | $this_category[$row_board['id_board']]['board_tooltip'] = $txt['old_posts']; |
| 173 | 176 | } |
@@ -218,14 +221,16 @@ discard block |
||
| 218 | 221 | // Child of a child... just add it on... |
| 219 | 222 | elseif (!empty($boardIndexOptions['countChildPosts'])) |
| 220 | 223 | { |
| 221 | - if (!isset($parent_map)) |
|
| 222 | - $parent_map = array(); |
|
| 224 | + if (!isset($parent_map)) { |
|
| 225 | + $parent_map = array(); |
|
| 226 | + } |
|
| 223 | 227 | |
| 224 | - if (!isset($parent_map[$row_board['id_parent']])) |
|
| 225 | - foreach ($this_category as $id => $board) |
|
| 228 | + if (!isset($parent_map[$row_board['id_parent']])) { |
|
| 229 | + foreach ($this_category as $id => $board) |
|
| 226 | 230 | { |
| 227 | 231 | if (!isset($board['children'][$row_board['id_parent']])) |
| 228 | 232 | continue; |
| 233 | + } |
|
| 229 | 234 | |
| 230 | 235 | $parent_map[$row_board['id_parent']] = array(&$this_category[$id], &$this_category[$id]['children'][$row_board['id_parent']]); |
| 231 | 236 | $parent_map[$row_board['id_board']] = array(&$this_category[$id], &$this_category[$id]['children'][$row_board['id_parent']]); |
@@ -246,8 +251,9 @@ discard block |
||
| 246 | 251 | continue; |
| 247 | 252 | } |
| 248 | 253 | // Found a child of a child - skip. |
| 249 | - else |
|
| 250 | - continue; |
|
| 254 | + else { |
|
| 255 | + continue; |
|
| 256 | + } |
|
| 251 | 257 | |
| 252 | 258 | // Prepare the subject, and make sure it's not too long. |
| 253 | 259 | censorText($row_board['subject']); |
@@ -268,12 +274,13 @@ discard block |
||
| 268 | 274 | 'topic' => $row_board['id_topic'] |
| 269 | 275 | ); |
| 270 | 276 | |
| 271 | - if (!empty($settings['avatars_on_boardIndex'])) |
|
| 272 | - $this_last_post['member']['avatar'] = set_avatar_data(array( |
|
| 277 | + if (!empty($settings['avatars_on_boardIndex'])) { |
|
| 278 | + $this_last_post['member']['avatar'] = set_avatar_data(array( |
|
| 273 | 279 | 'avatar' => $row_board['avatar'], |
| 274 | 280 | 'email' => $row_board['email_address'], |
| 275 | 281 | 'filename' => !empty($row['member_filename']) ? $row_board['member_filename'] : '', |
| 276 | 282 | )); |
| 283 | + } |
|
| 277 | 284 | |
| 278 | 285 | // Provide the href and link. |
| 279 | 286 | if ($row_board['subject'] != '') |
@@ -285,8 +292,7 @@ discard block |
||
| 285 | 292 | link, href, subject, start (where they should go for the first unread post.), |
| 286 | 293 | and member. (which has id, name, link, href, username in it.) */ |
| 287 | 294 | $this_last_post['last_post_message'] = sprintf($txt['last_post_message'], $this_last_post['member']['link'], $this_last_post['link'], $this_last_post['time']); |
| 288 | - } |
|
| 289 | - else |
|
| 295 | + } else |
|
| 290 | 296 | { |
| 291 | 297 | $this_last_post['href'] = ''; |
| 292 | 298 | $this_last_post['link'] = $txt['not_applicable']; |
@@ -294,8 +300,9 @@ discard block |
||
| 294 | 300 | } |
| 295 | 301 | |
| 296 | 302 | // Set the last post in the parent board. |
| 297 | - if ($row_board['id_parent'] == $boardIndexOptions['parent_id'] || ($isChild && !empty($row_board['poster_time']) && $this_category[$row_board['id_parent']]['last_post']['timestamp'] < forum_time(true, $row_board['poster_time']))) |
|
| 298 | - $this_category[$isChild ? $row_board['id_parent'] : $row_board['id_board']]['last_post'] = $this_last_post; |
|
| 303 | + if ($row_board['id_parent'] == $boardIndexOptions['parent_id'] || ($isChild && !empty($row_board['poster_time']) && $this_category[$row_board['id_parent']]['last_post']['timestamp'] < forum_time(true, $row_board['poster_time']))) { |
|
| 304 | + $this_category[$isChild ? $row_board['id_parent'] : $row_board['id_board']]['last_post'] = $this_last_post; |
|
| 305 | + } |
|
| 299 | 306 | // Just in the child...? |
| 300 | 307 | if ($isChild) |
| 301 | 308 | { |
@@ -305,15 +312,17 @@ discard block |
||
| 305 | 312 | $this_category[$row_board['id_parent']]['children'][$row_board['id_board']]['new'] &= $row_board['poster_name'] != ''; |
| 306 | 313 | } |
| 307 | 314 | // No last post for this board? It's not new then, is it..? |
| 308 | - elseif ($row_board['poster_name'] == '') |
|
| 309 | - $this_category[$row_board['id_board']]['new'] = false; |
|
| 315 | + elseif ($row_board['poster_name'] == '') { |
|
| 316 | + $this_category[$row_board['id_board']]['new'] = false; |
|
| 317 | + } |
|
| 310 | 318 | |
| 311 | 319 | // Determine a global most recent topic. |
| 312 | - if (!empty($boardIndexOptions['set_latest_post']) && !empty($row_board['poster_time']) && $row_board['poster_time'] > $latest_post['timestamp'] && !$ignoreThisBoard) |
|
| 313 | - $latest_post = array( |
|
| 320 | + if (!empty($boardIndexOptions['set_latest_post']) && !empty($row_board['poster_time']) && $row_board['poster_time'] > $latest_post['timestamp'] && !$ignoreThisBoard) { |
|
| 321 | + $latest_post = array( |
|
| 314 | 322 | 'timestamp' => $row_board['poster_time'], |
| 315 | 323 | 'ref' => &$this_category[$isChild ? $row_board['id_parent'] : $row_board['id_board']]['last_post'], |
| 316 | 324 | ); |
| 325 | + } |
|
| 317 | 326 | } |
| 318 | 327 | $smcFunc['db_free_result']($result_boards); |
| 319 | 328 | |
@@ -330,8 +339,9 @@ discard block |
||
| 330 | 339 | if (!empty($moderators[$board['id']])) |
| 331 | 340 | { |
| 332 | 341 | $categories[$k]['boards'][$j]['moderators'] = $moderators[$board['id']]; |
| 333 | - foreach ($moderators[$board['id']] as $moderator) |
|
| 334 | - $categories[$k]['boards'][$j]['link_moderators'][] = $moderator['link']; |
|
| 342 | + foreach ($moderators[$board['id']] as $moderator) { |
|
| 343 | + $categories[$k]['boards'][$j]['link_moderators'][] = $moderator['link']; |
|
| 344 | + } |
|
| 335 | 345 | } |
| 336 | 346 | if (!empty($groups[$board['id']])) |
| 337 | 347 | { |
@@ -344,16 +354,16 @@ discard block |
||
| 344 | 354 | } |
| 345 | 355 | } |
| 346 | 356 | } |
| 347 | - } |
|
| 348 | - else |
|
| 357 | + } else |
|
| 349 | 358 | { |
| 350 | 359 | foreach ($this_category as $k => $board) |
| 351 | 360 | { |
| 352 | 361 | if (!empty($moderators[$board['id']])) |
| 353 | 362 | { |
| 354 | 363 | $this_category[$k]['moderators'] = $moderators[$board['id']]; |
| 355 | - foreach ($moderators[$board['id']] as $moderator) |
|
| 356 | - $this_category[$k]['link_moderators'][] = $moderator['link']; |
|
| 364 | + foreach ($moderators[$board['id']] as $moderator) { |
|
| 365 | + $this_category[$k]['link_moderators'][] = $moderator['link']; |
|
| 366 | + } |
|
| 357 | 367 | } |
| 358 | 368 | if (!empty($groups[$board['id']])) |
| 359 | 369 | { |
@@ -367,20 +377,23 @@ discard block |
||
| 367 | 377 | } |
| 368 | 378 | } |
| 369 | 379 | |
| 370 | - if ($boardIndexOptions['include_categories']) |
|
| 371 | - sortCategories($categories); |
|
| 372 | - else |
|
| 373 | - sortBoards($this_category); |
|
| 380 | + if ($boardIndexOptions['include_categories']) { |
|
| 381 | + sortCategories($categories); |
|
| 382 | + } else { |
|
| 383 | + sortBoards($this_category); |
|
| 384 | + } |
|
| 374 | 385 | |
| 375 | 386 | // By now we should know the most recent post...if we wanna know it that is. |
| 376 | - if (!empty($boardIndexOptions['set_latest_post']) && !empty($latest_post['ref'])) |
|
| 377 | - $context['latest_post'] = $latest_post['ref']; |
|
| 387 | + if (!empty($boardIndexOptions['set_latest_post']) && !empty($latest_post['ref'])) { |
|
| 388 | + $context['latest_post'] = $latest_post['ref']; |
|
| 389 | + } |
|
| 378 | 390 | |
| 379 | 391 | // I can't remember why but trying to make a ternary to get this all in one line is actually a Very Bad Idea. |
| 380 | - if ($boardIndexOptions['include_categories']) |
|
| 381 | - call_integration_hook('integrate_getboardtree', array($boardIndexOptions, &$categories)); |
|
| 382 | - else |
|
| 383 | - call_integration_hook('integrate_getboardtree', array($boardIndexOptions, &$this_category)); |
|
| 392 | + if ($boardIndexOptions['include_categories']) { |
|
| 393 | + call_integration_hook('integrate_getboardtree', array($boardIndexOptions, &$categories)); |
|
| 394 | + } else { |
|
| 395 | + call_integration_hook('integrate_getboardtree', array($boardIndexOptions, &$this_category)); |
|
| 396 | + } |
|
| 384 | 397 | |
| 385 | 398 | return $boardIndexOptions['include_categories'] ? $categories : $this_category; |
| 386 | 399 | } |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 4 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * Class Likes |
@@ -108,8 +109,9 @@ discard block |
||
| 108 | 109 | $this->_extra = isset($_GET['extra']) ? $_GET['extra'] : false; |
| 109 | 110 | |
| 110 | 111 | // We do not want to output debug information here. |
| 111 | - if ($this->_js) |
|
| 112 | - $db_show_debug = false; |
|
| 112 | + if ($this->_js) { |
|
| 113 | + $db_show_debug = false; |
|
| 114 | + } |
|
| 113 | 115 | } |
| 114 | 116 | |
| 115 | 117 | /** |
@@ -143,8 +145,9 @@ discard block |
||
| 143 | 145 | $call = $this->_sa; |
| 144 | 146 | |
| 145 | 147 | // Guest can only view likes. |
| 146 | - if ($call != 'view') |
|
| 147 | - is_not_guest(); |
|
| 148 | + if ($call != 'view') { |
|
| 149 | + is_not_guest(); |
|
| 150 | + } |
|
| 148 | 151 | |
| 149 | 152 | checkSession('get'); |
| 150 | 153 | |
@@ -182,15 +185,17 @@ discard block |
||
| 182 | 185 | global $smcFunc, $modSettings; |
| 183 | 186 | |
| 184 | 187 | // This feature is currently disable. |
| 185 | - if (empty($modSettings['enable_likes'])) |
|
| 186 | - return $this->_error = 'like_disable'; |
|
| 188 | + if (empty($modSettings['enable_likes'])) { |
|
| 189 | + return $this->_error = 'like_disable'; |
|
| 190 | + } |
|
| 187 | 191 | |
| 188 | 192 | // Zerothly, they did indicate some kind of content to like, right? |
| 189 | 193 | preg_match('~^([a-z0-9\-\_]{1,6})~i', $this->_type, $matches); |
| 190 | 194 | $this->_type = isset($matches[1]) ? $matches[1] : ''; |
| 191 | 195 | |
| 192 | - if ($this->_type == '' || $this->_content <= 0) |
|
| 193 | - return $this->_error = 'cannot_'; |
|
| 196 | + if ($this->_type == '' || $this->_content <= 0) { |
|
| 197 | + return $this->_error = 'cannot_'; |
|
| 198 | + } |
|
| 194 | 199 | |
| 195 | 200 | // First we need to verify if the user can see the type of content or not. This is set up to be extensible, |
| 196 | 201 | // so we'll check for the one type we do know about, and if it's not that, we'll defer to any hooks. |
@@ -209,12 +214,14 @@ discard block |
||
| 209 | 214 | 'msg' => $this->_content, |
| 210 | 215 | ) |
| 211 | 216 | ); |
| 212 | - if ($smcFunc['db_num_rows']($request) == 1) |
|
| 213 | - list ($this->_idTopic, $topicOwner) = $smcFunc['db_fetch_row']($request); |
|
| 217 | + if ($smcFunc['db_num_rows']($request) == 1) { |
|
| 218 | + list ($this->_idTopic, $topicOwner) = $smcFunc['db_fetch_row']($request); |
|
| 219 | + } |
|
| 214 | 220 | |
| 215 | 221 | $smcFunc['db_free_result']($request); |
| 216 | - if (empty($this->_idTopic)) |
|
| 217 | - return $this->_error = 'cannot_'; |
|
| 222 | + if (empty($this->_idTopic)) { |
|
| 223 | + return $this->_error = 'cannot_'; |
|
| 224 | + } |
|
| 218 | 225 | |
| 219 | 226 | // So we know what topic it's in and more importantly we know the user can see it. |
| 220 | 227 | // If we're not viewing, we need some info set up. |
@@ -224,9 +231,7 @@ discard block |
||
| 224 | 231 | $this->_validLikes['can_see'] = allowedTo('likes_view') ? true : 'cannot_view_likes'; |
| 225 | 232 | |
| 226 | 233 | $this->_validLikes['can_like'] = ($this->_user['id'] == $topicOwner ? 'cannot_like_content' : (allowedTo('likes_like') ? true : 'cannot_like_content')); |
| 227 | - } |
|
| 228 | - |
|
| 229 | - else |
|
| 234 | + } else |
|
| 230 | 235 | { |
| 231 | 236 | // Modders: This will give you whatever the user offers up in terms of liking, e.g. $this->_type=msg, $this->_content=1 |
| 232 | 237 | // When you hook this, check $this->_type first. If it is not something your mod worries about, return false. |
@@ -244,8 +249,9 @@ discard block |
||
| 244 | 249 | if ($result !== false) |
| 245 | 250 | { |
| 246 | 251 | // Match the type with what we already have. |
| 247 | - if (!isset($result['type']) || $result['type'] != $this->_type) |
|
| 248 | - return $this->_error = 'not_valid_like_type'; |
|
| 252 | + if (!isset($result['type']) || $result['type'] != $this->_type) { |
|
| 253 | + return $this->_error = 'not_valid_like_type'; |
|
| 254 | + } |
|
| 249 | 255 | |
| 250 | 256 | // Fill out the rest. |
| 251 | 257 | $this->_type = $result['type']; |
@@ -256,17 +262,20 @@ discard block |
||
| 256 | 262 | } |
| 257 | 263 | } |
| 258 | 264 | |
| 259 | - if (!$found) |
|
| 260 | - return $this->_error = 'cannot_'; |
|
| 265 | + if (!$found) { |
|
| 266 | + return $this->_error = 'cannot_'; |
|
| 267 | + } |
|
| 261 | 268 | } |
| 262 | 269 | |
| 263 | 270 | // Does the user can see this? |
| 264 | - if (isset($this->_validLikes['can_see']) && is_string($this->_validLikes['can_see'])) |
|
| 265 | - return $this->_error = $this->_validLikes['can_see']; |
|
| 271 | + if (isset($this->_validLikes['can_see']) && is_string($this->_validLikes['can_see'])) { |
|
| 272 | + return $this->_error = $this->_validLikes['can_see']; |
|
| 273 | + } |
|
| 266 | 274 | |
| 267 | 275 | // Does the user can like this? Viewing a list of likes doesn't require this permission. |
| 268 | - if ($this->_sa != 'view' && isset($this->_validLikes['can_like']) && is_string($this->_validLikes['can_like'])) |
|
| 269 | - return $this->_error = $this->_validLikes['can_like']; |
|
| 276 | + if ($this->_sa != 'view' && isset($this->_validLikes['can_like']) && is_string($this->_validLikes['can_like'])) { |
|
| 277 | + return $this->_error = $this->_validLikes['can_like']; |
|
| 278 | + } |
|
| 270 | 279 | } |
| 271 | 280 | |
| 272 | 281 | /** |
@@ -291,8 +300,9 @@ discard block |
||
| 291 | 300 | ); |
| 292 | 301 | |
| 293 | 302 | // Are we calling this directly? if so, set a proper data for the response. Do note that __METHOD__ returns both the class name and the function name. |
| 294 | - if ($this->_sa == __FUNCTION__) |
|
| 295 | - $this->_data = __FUNCTION__; |
|
| 303 | + if ($this->_sa == __FUNCTION__) { |
|
| 304 | + $this->_data = __FUNCTION__; |
|
| 305 | + } |
|
| 296 | 306 | } |
| 297 | 307 | |
| 298 | 308 | /** |
@@ -322,8 +332,8 @@ discard block |
||
| 322 | 332 | |
| 323 | 333 | // Add a background task to process sending alerts. |
| 324 | 334 | // Mod author, you can add your own background task for your own custom like event using the "integrate_issue_like" hook or your callback, both are immediately called after this. |
| 325 | - if ($this->_type == 'msg') |
|
| 326 | - $smcFunc['db_insert']('insert', |
|
| 335 | + if ($this->_type == 'msg') { |
|
| 336 | + $smcFunc['db_insert']('insert', |
|
| 327 | 337 | '{db_prefix}background_tasks', |
| 328 | 338 | array('task_file' => 'string', 'task_class' => 'string', 'task_data' => 'string', 'claimed_time' => 'int'), |
| 329 | 339 | array('$sourcedir/tasks/Likes-Notify.php', 'Likes_Notify_Background', json_encode(array( |
@@ -335,10 +345,12 @@ discard block |
||
| 335 | 345 | )), 0), |
| 336 | 346 | array('id_task') |
| 337 | 347 | ); |
| 348 | + } |
|
| 338 | 349 | |
| 339 | 350 | // Are we calling this directly? if so, set a proper data for the response. Do note that __METHOD__ returns both the class name and the function name. |
| 340 | - if ($this->_sa == __FUNCTION__) |
|
| 341 | - $this->_data = __FUNCTION__; |
|
| 351 | + if ($this->_sa == __FUNCTION__) { |
|
| 352 | + $this->_data = __FUNCTION__; |
|
| 353 | + } |
|
| 342 | 354 | } |
| 343 | 355 | |
| 344 | 356 | /** |
@@ -364,8 +376,9 @@ discard block |
||
| 364 | 376 | $smcFunc['db_free_result']($request); |
| 365 | 377 | |
| 366 | 378 | // If you want to call this directly, fill out _data property too. |
| 367 | - if ($this->_sa == __FUNCTION__) |
|
| 368 | - $this->_data = $this->_numLikes; |
|
| 379 | + if ($this->_sa == __FUNCTION__) { |
|
| 380 | + $this->_data = $this->_numLikes; |
|
| 381 | + } |
|
| 369 | 382 | } |
| 370 | 383 | |
| 371 | 384 | /** |
@@ -378,8 +391,9 @@ discard block |
||
| 378 | 391 | global $smcFunc; |
| 379 | 392 | |
| 380 | 393 | // Safety first! |
| 381 | - if (empty($this->_type) || empty($this->_content)) |
|
| 382 | - return $this->_error = 'cannot_'; |
|
| 394 | + if (empty($this->_type) || empty($this->_content)) { |
|
| 395 | + return $this->_error = 'cannot_'; |
|
| 396 | + } |
|
| 383 | 397 | |
| 384 | 398 | // Do we already like this? |
| 385 | 399 | $request = $smcFunc['db_query']('', ' |
@@ -397,26 +411,28 @@ discard block |
||
| 397 | 411 | $this->_alreadyLiked = (bool) $smcFunc['db_num_rows']($request) != 0; |
| 398 | 412 | $smcFunc['db_free_result']($request); |
| 399 | 413 | |
| 400 | - if ($this->_alreadyLiked) |
|
| 401 | - $this->delete(); |
|
| 402 | - |
|
| 403 | - else |
|
| 404 | - $this->insert(); |
|
| 414 | + if ($this->_alreadyLiked) { |
|
| 415 | + $this->delete(); |
|
| 416 | + } else { |
|
| 417 | + $this->insert(); |
|
| 418 | + } |
|
| 405 | 419 | |
| 406 | 420 | // Now, how many people like this content now? We *could* just +1 / -1 the relevant container but that has proven to become unstable. |
| 407 | 421 | $this->_count(); |
| 408 | 422 | |
| 409 | 423 | // Update the likes count for messages. |
| 410 | - if ($this->_type == 'msg') |
|
| 411 | - $this->msgIssueLike(); |
|
| 424 | + if ($this->_type == 'msg') { |
|
| 425 | + $this->msgIssueLike(); |
|
| 426 | + } |
|
| 412 | 427 | |
| 413 | 428 | // Any callbacks? |
| 414 | 429 | elseif (!empty($this->_validLikes['callback'])) |
| 415 | 430 | { |
| 416 | 431 | $call = call_helper($this->_validLikes['callback'], true); |
| 417 | 432 | |
| 418 | - if (!empty($call)) |
|
| 419 | - call_user_func_array($call, array($this)); |
|
| 433 | + if (!empty($call)) { |
|
| 434 | + call_user_func_array($call, array($this)); |
|
| 435 | + } |
|
| 420 | 436 | } |
| 421 | 437 | |
| 422 | 438 | // Sometimes there might be other things that need updating after we do this like. |
@@ -425,8 +441,9 @@ discard block |
||
| 425 | 441 | // Now some clean up. This is provided here for any like handlers that want to do any cache flushing. |
| 426 | 442 | // This way a like handler doesn't need to explicitly declare anything in integrate_issue_like, but do so |
| 427 | 443 | // in integrate_valid_likes where it absolutely has to exist. |
| 428 | - if (!empty($this->_validLikes['flush_cache'])) |
|
| 429 | - cache_put_data($this->_validLikes['flush_cache'], null); |
|
| 444 | + if (!empty($this->_validLikes['flush_cache'])) { |
|
| 445 | + cache_put_data($this->_validLikes['flush_cache'], null); |
|
| 446 | + } |
|
| 430 | 447 | |
| 431 | 448 | // All done, start building the data to pass as response. |
| 432 | 449 | $this->_data = array( |
@@ -450,8 +467,9 @@ discard block |
||
| 450 | 467 | { |
| 451 | 468 | global $smcFunc; |
| 452 | 469 | |
| 453 | - if ($this->_type !== 'msg') |
|
| 454 | - return; |
|
| 470 | + if ($this->_type !== 'msg') { |
|
| 471 | + return; |
|
| 472 | + } |
|
| 455 | 473 | |
| 456 | 474 | $smcFunc['db_query']('', ' |
| 457 | 475 | UPDATE {db_prefix}messages |
@@ -492,8 +510,9 @@ discard block |
||
| 492 | 510 | 'like_type' => $this->_type, |
| 493 | 511 | ) |
| 494 | 512 | ); |
| 495 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 496 | - $context['likers'][$row['id_member']] = array('timestamp' => $row['like_time']); |
|
| 513 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 514 | + $context['likers'][$row['id_member']] = array('timestamp' => $row['like_time']); |
|
| 515 | + } |
|
| 497 | 516 | |
| 498 | 517 | // Now to get member data, including avatars and so on. |
| 499 | 518 | $members = array_keys($context['likers']); |
@@ -501,8 +520,9 @@ discard block |
||
| 501 | 520 | if (count($loaded) != count($members)) |
| 502 | 521 | { |
| 503 | 522 | $members = array_diff($members, $loaded); |
| 504 | - foreach ($members as $not_loaded) |
|
| 505 | - unset ($context['likers'][$not_loaded]); |
|
| 523 | + foreach ($members as $not_loaded) { |
|
| 524 | + unset ($context['likers'][$not_loaded]); |
|
| 525 | + } |
|
| 506 | 526 | } |
| 507 | 527 | |
| 508 | 528 | foreach ($context['likers'] as $liker => $dummy) |
@@ -544,12 +564,14 @@ discard block |
||
| 544 | 564 | global $context, $txt; |
| 545 | 565 | |
| 546 | 566 | // Don't do anything if someone else has already take care of the response. |
| 547 | - if (!$this->_setResponse) |
|
| 548 | - return; |
|
| 567 | + if (!$this->_setResponse) { |
|
| 568 | + return; |
|
| 569 | + } |
|
| 549 | 570 | |
| 550 | 571 | // Want a json response huh? |
| 551 | - if ($this->_validLikes['json']) |
|
| 552 | - return $this->jsonResponse(); |
|
| 572 | + if ($this->_validLikes['json']) { |
|
| 573 | + return $this->jsonResponse(); |
|
| 574 | + } |
|
| 553 | 575 | |
| 554 | 576 | // Set everything up for display. |
| 555 | 577 | loadTemplate('Likes'); |
@@ -559,8 +581,9 @@ discard block |
||
| 559 | 581 | if ($this->_error) |
| 560 | 582 | { |
| 561 | 583 | // If this is a generic error, set it up good. |
| 562 | - if ($this->_error == 'cannot_') |
|
| 563 | - $this->_error = $this->_sa == 'view' ? 'cannot_view_likes' : 'cannot_like_content'; |
|
| 584 | + if ($this->_error == 'cannot_') { |
|
| 585 | + $this->_error = $this->_sa == 'view' ? 'cannot_view_likes' : 'cannot_like_content'; |
|
| 586 | + } |
|
| 564 | 587 | |
| 565 | 588 | // Is this request coming from an ajax call? |
| 566 | 589 | if ($this->_js) |
@@ -570,8 +593,9 @@ discard block |
||
| 570 | 593 | } |
| 571 | 594 | |
| 572 | 595 | // Nope? then just do a redirect to whatever URL was provided. |
| 573 | - else |
|
| 574 | - redirectexit(!empty($this->_validLikes['redirect']) ? $this->_validLikes['redirect'] . ';error=' . $this->_error : ''); |
|
| 596 | + else { |
|
| 597 | + redirectexit(!empty($this->_validLikes['redirect']) ? $this->_validLikes['redirect'] . ';error=' . $this->_error : ''); |
|
| 598 | + } |
|
| 575 | 599 | |
| 576 | 600 | return; |
| 577 | 601 | } |
@@ -580,8 +604,9 @@ discard block |
||
| 580 | 604 | else |
| 581 | 605 | { |
| 582 | 606 | // Not an ajax request so send the user back to the previous location or the main page. |
| 583 | - if (!$this->_js) |
|
| 584 | - redirectexit(!empty($this->_validLikes['redirect']) ? $this->_validLikes['redirect'] : ''); |
|
| 607 | + if (!$this->_js) { |
|
| 608 | + redirectexit(!empty($this->_validLikes['redirect']) ? $this->_validLikes['redirect'] : ''); |
|
| 609 | + } |
|
| 585 | 610 | |
| 586 | 611 | // These fine gentlemen all share the same template. |
| 587 | 612 | $generic = array('delete', 'insert', '_count'); |
@@ -612,8 +637,9 @@ discard block |
||
| 612 | 637 | // If there is an error, send it. |
| 613 | 638 | if ($this->_error) |
| 614 | 639 | { |
| 615 | - if ($this->_error == 'cannot_') |
|
| 616 | - $this->_error = $this->_sa == 'view' ? 'cannot_view_likes' : 'cannot_like_content'; |
|
| 640 | + if ($this->_error == 'cannot_') { |
|
| 641 | + $this->_error = $this->_sa == 'view' ? 'cannot_view_likes' : 'cannot_like_content'; |
|
| 642 | + } |
|
| 617 | 643 | |
| 618 | 644 | $print['error'] = $this->_error; |
| 619 | 645 | } |
@@ -649,33 +675,36 @@ discard block |
||
| 649 | 675 | <body style="background-color: #444455; color: white; font-style: italic; font-family: serif;"> |
| 650 | 676 | <div style="margin-top: 12%; font-size: 1.1em; line-height: 1.4; text-align: center;">'; |
| 651 | 677 | |
| 652 | - if (!isset($_GET['verse']) || ($_GET['verse'] != '2:18' && $_GET['verse'] != '22:1-2')) |
|
| 653 | - $_GET['verse'] = '4:16'; |
|
| 678 | + if (!isset($_GET['verse']) || ($_GET['verse'] != '2:18' && $_GET['verse'] != '22:1-2')) { |
|
| 679 | + $_GET['verse'] = '4:16'; |
|
| 680 | + } |
|
| 654 | 681 | |
| 655 | - if ($_GET['verse'] == '2:18') |
|
| 656 | - echo ' |
|
| 682 | + if ($_GET['verse'] == '2:18') { |
|
| 683 | + echo ' |
|
| 657 | 684 | Woe, it was that his name wasn\'t <em>known</em>, that he came in mystery, and was recognized by none. And it became to be in those days <em>something</em>. Something not yet <em id="unknown" name="[Unknown]">unknown</em> to mankind. And thus what was to be known the <em>secret project</em> began into its existence. Henceforth the opposition was only <em>weary</em> and <em>fearful</em>, for now their match was at arms against them.'; |
| 658 | - elseif ($_GET['verse'] == '4:16') |
|
| 659 | - echo ' |
|
| 685 | + } elseif ($_GET['verse'] == '4:16') { |
|
| 686 | + echo ' |
|
| 660 | 687 | And it came to pass that the <em>unbelievers</em> dwindled in number and saw rise of many <em>proselytizers</em>, and the opposition found fear in the face of the <em>x</em> and the <em>j</em> while those who stood with the <em>something</em> grew stronger and came together. Still, this was only the <em>beginning</em>, and what lay in the future was <em id="unknown" name="[Unknown]">unknown</em> to all, even those on the right side.'; |
| 661 | - elseif ($_GET['verse'] == '22:1-2') |
|
| 662 | - echo ' |
|
| 688 | + } elseif ($_GET['verse'] == '22:1-2') { |
|
| 689 | + echo ' |
|
| 663 | 690 | <p>Now <em>behold</em>, that which was once the secret project was <em id="unknown" name="[Unknown]">unknown</em> no longer. Alas, it needed more than <em>only one</em>, but yet even thought otherwise. It became that the opposition <em>rumored</em> and lied, but still to no avail. Their match, though not <em>perfect</em>, had them outdone.</p> |
| 664 | 691 | <p style="margin: 2ex 1ex 0 1ex; font-size: 1.05em; line-height: 1.5; text-align: center;">Let it continue. <em>The end</em>.</p>'; |
| 692 | + } |
|
| 665 | 693 | |
| 666 | 694 | echo ' |
| 667 | 695 | </div> |
| 668 | 696 | <div style="margin-top: 2ex; font-size: 2em; text-align: right;">'; |
| 669 | 697 | |
| 670 | - if ($_GET['verse'] == '2:18') |
|
| 671 | - echo ' |
|
| 698 | + if ($_GET['verse'] == '2:18') { |
|
| 699 | + echo ' |
|
| 672 | 700 | from <span style="font-family: Georgia, serif;"><strong><a href="', $scripturl, '?action=about:unknown;verse=4:16" style="color: white; text-decoration: none; cursor: text;">The Book of Unknown</a></strong>, 2:18</span>'; |
| 673 | - elseif ($_GET['verse'] == '4:16') |
|
| 674 | - echo ' |
|
| 701 | + } elseif ($_GET['verse'] == '4:16') { |
|
| 702 | + echo ' |
|
| 675 | 703 | from <span style="font-family: Georgia, serif;"><strong><a href="', $scripturl, '?action=about:unknown;verse=22:1-2" style="color: white; text-decoration: none; cursor: text;">The Book of Unknown</a></strong>, 4:16</span>'; |
| 676 | - elseif ($_GET['verse'] == '22:1-2') |
|
| 677 | - echo ' |
|
| 704 | + } elseif ($_GET['verse'] == '22:1-2') { |
|
| 705 | + echo ' |
|
| 678 | 706 | from <span style="font-family: Georgia, serif;"><strong>The Book of Unknown</strong>, 22:1-2</span>'; |
| 707 | + } |
|
| 679 | 708 | |
| 680 | 709 | echo ' |
| 681 | 710 | </div> |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 4 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * Scheduled tasks management dispatcher. This function checks permissions and delegates |
@@ -40,10 +41,11 @@ discard block |
||
| 40 | 41 | ); |
| 41 | 42 | |
| 42 | 43 | // We need to find what's the action. |
| 43 | - if (isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']])) |
|
| 44 | - $context['sub_action'] = $_REQUEST['sa']; |
|
| 45 | - else |
|
| 46 | - $context['sub_action'] = 'tasks'; |
|
| 44 | + if (isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']])) { |
|
| 45 | + $context['sub_action'] = $_REQUEST['sa']; |
|
| 46 | + } else { |
|
| 47 | + $context['sub_action'] = 'tasks'; |
|
| 48 | + } |
|
| 47 | 49 | |
| 48 | 50 | // Now for the lovely tabs. That we all love. |
| 49 | 51 | $context[$context['admin_menu_name']]['tab_data'] = array( |
@@ -90,9 +92,10 @@ discard block |
||
| 90 | 92 | |
| 91 | 93 | // Enable and disable as required. |
| 92 | 94 | $enablers = array(0); |
| 93 | - foreach ($_POST['enable_task'] as $id => $enabled) |
|
| 94 | - if ($enabled) |
|
| 95 | + foreach ($_POST['enable_task'] as $id => $enabled) { |
|
| 96 | + if ($enabled) |
|
| 95 | 97 | $enablers[] = (int) $id; |
| 98 | + } |
|
| 96 | 99 | |
| 97 | 100 | // Do the update! |
| 98 | 101 | $smcFunc['db_query']('', ' |
@@ -130,8 +133,9 @@ discard block |
||
| 130 | 133 | |
| 131 | 134 | // Lets figure out which ones they want to run. |
| 132 | 135 | $tasks = array(); |
| 133 | - foreach ($_POST['run_task'] as $task => $dummy) |
|
| 134 | - $tasks[] = (int) $task; |
|
| 136 | + foreach ($_POST['run_task'] as $task => $dummy) { |
|
| 137 | + $tasks[] = (int) $task; |
|
| 138 | + } |
|
| 135 | 139 | |
| 136 | 140 | // Load up the tasks. |
| 137 | 141 | $request = $smcFunc['db_query']('', ' |
@@ -151,36 +155,41 @@ discard block |
||
| 151 | 155 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 152 | 156 | { |
| 153 | 157 | // What kind of task are we handling? |
| 154 | - if (!empty($row['callable'])) |
|
| 155 | - $task_string = $row['callable']; |
|
| 158 | + if (!empty($row['callable'])) { |
|
| 159 | + $task_string = $row['callable']; |
|
| 160 | + } |
|
| 156 | 161 | |
| 157 | 162 | // Default SMF task or old mods? |
| 158 | - elseif (function_exists('scheduled_' . $row['task'])) |
|
| 159 | - $task_string = 'scheduled_' . $row['task']; |
|
| 163 | + elseif (function_exists('scheduled_' . $row['task'])) { |
|
| 164 | + $task_string = 'scheduled_' . $row['task']; |
|
| 165 | + } |
|
| 160 | 166 | |
| 161 | 167 | // One last resource, the task name. |
| 162 | - elseif (!empty($row['task'])) |
|
| 163 | - $task_string = $row['task']; |
|
| 168 | + elseif (!empty($row['task'])) { |
|
| 169 | + $task_string = $row['task']; |
|
| 170 | + } |
|
| 164 | 171 | |
| 165 | 172 | $start_time = microtime(); |
| 166 | 173 | // The functions got to exist for us to use it. |
| 167 | - if (empty($task_string)) |
|
| 168 | - continue; |
|
| 174 | + if (empty($task_string)) { |
|
| 175 | + continue; |
|
| 176 | + } |
|
| 169 | 177 | |
| 170 | 178 | // Try to stop a timeout, this would be bad... |
| 171 | 179 | @set_time_limit(300); |
| 172 | - if (function_exists('apache_reset_timeout')) |
|
| 173 | - @apache_reset_timeout(); |
|
| 180 | + if (function_exists('apache_reset_timeout')) { |
|
| 181 | + @apache_reset_timeout(); |
|
| 182 | + } |
|
| 174 | 183 | |
| 175 | 184 | // Get the callable. |
| 176 | 185 | $callable_task = call_helper($task_string, true); |
| 177 | 186 | |
| 178 | 187 | // Perform the task. |
| 179 | - if (!empty($callable_task)) |
|
| 180 | - $completed = call_user_func($callable_task); |
|
| 181 | - |
|
| 182 | - else |
|
| 183 | - $completed = false; |
|
| 188 | + if (!empty($callable_task)) { |
|
| 189 | + $completed = call_user_func($callable_task); |
|
| 190 | + } else { |
|
| 191 | + $completed = false; |
|
| 192 | + } |
|
| 184 | 193 | |
| 185 | 194 | // Log that we did it ;) |
| 186 | 195 | if ($completed) |
@@ -197,8 +206,9 @@ discard block |
||
| 197 | 206 | $smcFunc['db_free_result']($request); |
| 198 | 207 | |
| 199 | 208 | // If we had any errors, push them to session so we can pick them up next time to tell the user. |
| 200 | - if (!empty($context['scheduled_errors'])) |
|
| 201 | - $_SESSION['st_error'] = $context['scheduled_errors']; |
|
| 209 | + if (!empty($context['scheduled_errors'])) { |
|
| 210 | + $_SESSION['st_error'] = $context['scheduled_errors']; |
|
| 211 | + } |
|
| 202 | 212 | |
| 203 | 213 | redirectexit('action=admin;area=scheduledtasks;done'); |
| 204 | 214 | } |
@@ -370,8 +380,9 @@ discard block |
||
| 370 | 380 | $context['server_time'] = timeformat(time(), false, 'server'); |
| 371 | 381 | |
| 372 | 382 | // Cleaning... |
| 373 | - if (!isset($_GET['tid'])) |
|
| 374 | - fatal_lang_error('no_access', false); |
|
| 383 | + if (!isset($_GET['tid'])) { |
|
| 384 | + fatal_lang_error('no_access', false); |
|
| 385 | + } |
|
| 375 | 386 | $_GET['tid'] = (int) $_GET['tid']; |
| 376 | 387 | |
| 377 | 388 | // Saving? |
@@ -387,10 +398,12 @@ discard block |
||
| 387 | 398 | preg_match('~(\d{1,2}):(\d{1,2})~', $_POST['offset'], $matches); |
| 388 | 399 | |
| 389 | 400 | // If a half is empty then assume zero offset! |
| 390 | - if (!isset($matches[2]) || $matches[2] > 59) |
|
| 391 | - $matches[2] = 0; |
|
| 392 | - if (!isset($matches[1]) || $matches[1] > 23) |
|
| 393 | - $matches[1] = 0; |
|
| 401 | + if (!isset($matches[2]) || $matches[2] > 59) { |
|
| 402 | + $matches[2] = 0; |
|
| 403 | + } |
|
| 404 | + if (!isset($matches[1]) || $matches[1] > 23) { |
|
| 405 | + $matches[1] = 0; |
|
| 406 | + } |
|
| 394 | 407 | |
| 395 | 408 | // Now the offset is easy; easy peasy - except we need to offset by a few hours... |
| 396 | 409 | $offset = $matches[1] * 3600 + $matches[2] * 60 - date('Z'); |
@@ -400,8 +413,9 @@ discard block |
||
| 400 | 413 | $unit = in_array(substr($_POST['unit'], 0, 1), array('m', 'h', 'd', 'w')) ? substr($_POST['unit'], 0, 1) : 'd'; |
| 401 | 414 | |
| 402 | 415 | // Don't allow one minute intervals. |
| 403 | - if ($interval == 1 && $unit == 'm') |
|
| 404 | - $interval = 2; |
|
| 416 | + if ($interval == 1 && $unit == 'm') { |
|
| 417 | + $interval = 2; |
|
| 418 | + } |
|
| 405 | 419 | |
| 406 | 420 | // Is it disabled? |
| 407 | 421 | $disabled = !isset($_POST['enabled']) ? 1 : 0; |
@@ -439,8 +453,9 @@ discard block |
||
| 439 | 453 | ); |
| 440 | 454 | |
| 441 | 455 | // Should never, ever, happen! |
| 442 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 443 | - fatal_lang_error('no_access', false); |
|
| 456 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 457 | + fatal_lang_error('no_access', false); |
|
| 458 | + } |
|
| 444 | 459 | |
| 445 | 460 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 446 | 461 | { |
@@ -598,13 +613,14 @@ discard block |
||
| 598 | 613 | ) |
| 599 | 614 | ); |
| 600 | 615 | $log_entries = array(); |
| 601 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 602 | - $log_entries[] = array( |
|
| 616 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 617 | + $log_entries[] = array( |
|
| 603 | 618 | 'id' => $row['id_log'], |
| 604 | 619 | 'name' => isset($txt['scheduled_task_' . $row['task']]) ? $txt['scheduled_task_' . $row['task']] : $row['task'], |
| 605 | 620 | 'time_run' => $row['time_run'], |
| 606 | 621 | 'time_taken' => $row['time_taken'], |
| 607 | 622 | ); |
| 623 | + } |
|
| 608 | 624 | $smcFunc['db_free_result']($request); |
| 609 | 625 | |
| 610 | 626 | return $log_entries; |
@@ -12,8 +12,9 @@ discard block |
||
| 12 | 12 | * @version 2.1 Beta 4 |
| 13 | 13 | */ |
| 14 | 14 | |
| 15 | -if (!defined('SMF')) |
|
| 15 | +if (!defined('SMF')) { |
|
| 16 | 16 | die('No direct access...'); |
| 17 | +} |
|
| 17 | 18 | |
| 18 | 19 | /** |
| 19 | 20 | * Report a post or profile to the moderator... ask for a comment. |
@@ -35,10 +36,11 @@ discard block |
||
| 35 | 36 | |
| 36 | 37 | // You can't use this if it's off or you are not allowed to do it. |
| 37 | 38 | // If we don't have the ID of something to report, we'll die with a no_access error below |
| 38 | - if (isset($_REQUEST['msg'])) |
|
| 39 | - isAllowedTo('report_any'); |
|
| 40 | - elseif (isset($_REQUEST['u'])) |
|
| 41 | - isAllowedTo('report_user'); |
|
| 39 | + if (isset($_REQUEST['msg'])) { |
|
| 40 | + isAllowedTo('report_any'); |
|
| 41 | + } elseif (isset($_REQUEST['u'])) { |
|
| 42 | + isAllowedTo('report_user'); |
|
| 43 | + } |
|
| 42 | 44 | |
| 43 | 45 | // Previewing or modifying? |
| 44 | 46 | if (isset($_POST['preview']) && !isset($_POST['save'])) |
@@ -56,19 +58,23 @@ discard block |
||
| 56 | 58 | } |
| 57 | 59 | |
| 58 | 60 | // If they're posting, it should be processed by ReportToModerator2. |
| 59 | - if ((isset($_POST[$context['session_var']]) || isset($_POST['save'])) && empty($context['post_errors']) && !isset($_POST['preview'])) |
|
| 60 | - ReportToModerator2(); |
|
| 61 | + if ((isset($_POST[$context['session_var']]) || isset($_POST['save'])) && empty($context['post_errors']) && !isset($_POST['preview'])) { |
|
| 62 | + ReportToModerator2(); |
|
| 63 | + } |
|
| 61 | 64 | |
| 62 | 65 | // We need a message ID or user ID to check! |
| 63 | - if (empty($_REQUEST['msg']) && empty($_REQUEST['mid']) && empty($_REQUEST['u'])) |
|
| 64 | - fatal_lang_error('no_access', false); |
|
| 66 | + if (empty($_REQUEST['msg']) && empty($_REQUEST['mid']) && empty($_REQUEST['u'])) { |
|
| 67 | + fatal_lang_error('no_access', false); |
|
| 68 | + } |
|
| 65 | 69 | |
| 66 | 70 | // For compatibility, accept mid, but we should be using msg. (not the flavor kind!) |
| 67 | - if (!empty($_REQUEST['msg']) || !empty($_REQUEST['mid'])) |
|
| 68 | - $_REQUEST['msg'] = empty($_REQUEST['msg']) ? (int) $_REQUEST['mid'] : (int) $_REQUEST['msg']; |
|
| 71 | + if (!empty($_REQUEST['msg']) || !empty($_REQUEST['mid'])) { |
|
| 72 | + $_REQUEST['msg'] = empty($_REQUEST['msg']) ? (int) $_REQUEST['mid'] : (int) $_REQUEST['msg']; |
|
| 73 | + } |
|
| 69 | 74 | // msg and mid empty - assume we're reporting a user |
| 70 | - elseif (!empty($_REQUEST['u'])) |
|
| 71 | - $_REQUEST['u'] = (int) $_REQUEST['u']; |
|
| 75 | + elseif (!empty($_REQUEST['u'])) { |
|
| 76 | + $_REQUEST['u'] = (int) $_REQUEST['u']; |
|
| 77 | + } |
|
| 72 | 78 | |
| 73 | 79 | // Set up some form values |
| 74 | 80 | $context['report_type'] = isset($_REQUEST['msg']) ? 'msg' : 'u'; |
@@ -89,8 +95,9 @@ discard block |
||
| 89 | 95 | 'id_msg' => $_REQUEST['msg'], |
| 90 | 96 | ) |
| 91 | 97 | ); |
| 92 | - if ($smcFunc['db_num_rows']($result) == 0) |
|
| 93 | - fatal_lang_error('no_board', false); |
|
| 98 | + if ($smcFunc['db_num_rows']($result) == 0) { |
|
| 99 | + fatal_lang_error('no_board', false); |
|
| 100 | + } |
|
| 94 | 101 | list ($_REQUEST['msg'], $member, $starter) = $smcFunc['db_fetch_row']($result); |
| 95 | 102 | $smcFunc['db_free_result']($result); |
| 96 | 103 | |
@@ -101,8 +108,7 @@ discard block |
||
| 101 | 108 | |
| 102 | 109 | // The submit URL is different for users than it is for posts |
| 103 | 110 | $context['submit_url'] = $scripturl . '?action=reporttm;msg=' . $_REQUEST['msg'] . ';topic=' . $topic; |
| 104 | - } |
|
| 105 | - else |
|
| 111 | + } else |
|
| 106 | 112 | { |
| 107 | 113 | // Check the user's ID |
| 108 | 114 | $result = $smcFunc['db_query']('', ' |
@@ -114,8 +120,9 @@ discard block |
||
| 114 | 120 | ) |
| 115 | 121 | ); |
| 116 | 122 | |
| 117 | - if ($smcFunc['db_num_rows']($result) == 0) |
|
| 118 | - fatal_lang_error('no_user', false); |
|
| 123 | + if ($smcFunc['db_num_rows']($result) == 0) { |
|
| 124 | + fatal_lang_error('no_user', false); |
|
| 125 | + } |
|
| 119 | 126 | list($_REQUEST['u'], $display_name, $username) = $smcFunc['db_fetch_row']($result); |
| 120 | 127 | |
| 121 | 128 | $context['current_user'] = $_REQUEST['u']; |
@@ -170,10 +177,11 @@ discard block |
||
| 170 | 177 | is_not_guest(); |
| 171 | 178 | |
| 172 | 179 | // You must have the proper permissions! |
| 173 | - if (isset($_REQUEST['msg'])) |
|
| 174 | - isAllowedTo('report_any'); |
|
| 175 | - else |
|
| 176 | - isAllowedTo('report_user'); |
|
| 180 | + if (isset($_REQUEST['msg'])) { |
|
| 181 | + isAllowedTo('report_any'); |
|
| 182 | + } else { |
|
| 183 | + isAllowedTo('report_user'); |
|
| 184 | + } |
|
| 177 | 185 | |
| 178 | 186 | // Make sure they aren't spamming. |
| 179 | 187 | spamProtection('reporttm'); |
@@ -187,17 +195,20 @@ discard block |
||
| 187 | 195 | $post_errors = array(); |
| 188 | 196 | |
| 189 | 197 | // Check their session. |
| 190 | - if (checkSession('post', '', false) != '') |
|
| 191 | - $post_errors[] = 'session_timeout'; |
|
| 198 | + if (checkSession('post', '', false) != '') { |
|
| 199 | + $post_errors[] = 'session_timeout'; |
|
| 200 | + } |
|
| 192 | 201 | |
| 193 | 202 | // Make sure we have a comment and it's clean. |
| 194 | - if (!isset($_POST['comment']) || $smcFunc['htmltrim']($_POST['comment']) === '') |
|
| 195 | - $post_errors[] = 'no_comment'; |
|
| 203 | + if (!isset($_POST['comment']) || $smcFunc['htmltrim']($_POST['comment']) === '') { |
|
| 204 | + $post_errors[] = 'no_comment'; |
|
| 205 | + } |
|
| 196 | 206 | |
| 197 | 207 | $poster_comment = strtr($smcFunc['htmlspecialchars']($_POST['comment']), array("\r" => '', "\t" => '')); |
| 198 | 208 | |
| 199 | - if ($smcFunc['strlen']($poster_comment) > 254) |
|
| 200 | - $post_errors[] = 'post_too_long'; |
|
| 209 | + if ($smcFunc['strlen']($poster_comment) > 254) { |
|
| 210 | + $post_errors[] = 'post_too_long'; |
|
| 211 | + } |
|
| 201 | 212 | |
| 202 | 213 | // Any errors? |
| 203 | 214 | if (!empty($post_errors)) |
@@ -205,8 +216,9 @@ discard block |
||
| 205 | 216 | loadLanguage('Errors'); |
| 206 | 217 | |
| 207 | 218 | $context['post_errors'] = array(); |
| 208 | - foreach ($post_errors as $post_error) |
|
| 209 | - $context['post_errors'][$post_error] = $txt['error_' . $post_error]; |
|
| 219 | + foreach ($post_errors as $post_error) { |
|
| 220 | + $context['post_errors'][$post_error] = $txt['error_' . $post_error]; |
|
| 221 | + } |
|
| 210 | 222 | |
| 211 | 223 | return ReportToModerator(); |
| 212 | 224 | } |
@@ -215,8 +227,7 @@ discard block |
||
| 215 | 227 | { |
| 216 | 228 | // Handle this elsewhere to keep things from getting too long |
| 217 | 229 | reportPost($_POST['msg'], $poster_comment); |
| 218 | - } |
|
| 219 | - else |
|
| 230 | + } else |
|
| 220 | 231 | { |
| 221 | 232 | reportUser($_POST['u'], $poster_comment); |
| 222 | 233 | } |
@@ -247,8 +258,9 @@ discard block |
||
| 247 | 258 | 'id_msg' => $_POST['msg'], |
| 248 | 259 | ) |
| 249 | 260 | ); |
| 250 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 251 | - fatal_lang_error('no_board', false); |
|
| 261 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 262 | + fatal_lang_error('no_board', false); |
|
| 263 | + } |
|
| 252 | 264 | $message = $smcFunc['db_fetch_assoc']($request); |
| 253 | 265 | $smcFunc['db_free_result']($request); |
| 254 | 266 | |
@@ -264,18 +276,20 @@ discard block |
||
| 264 | 276 | 'ignored' => 1, |
| 265 | 277 | ) |
| 266 | 278 | ); |
| 267 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
| 268 | - list ($id_report, $ignore) = $smcFunc['db_fetch_row']($request); |
|
| 279 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
| 280 | + list ($id_report, $ignore) = $smcFunc['db_fetch_row']($request); |
|
| 281 | + } |
|
| 269 | 282 | |
| 270 | 283 | $smcFunc['db_free_result']($request); |
| 271 | 284 | |
| 272 | 285 | // If we're just going to ignore these, then who gives a monkeys... |
| 273 | - if (!empty($ignore)) |
|
| 274 | - redirectexit('topic=' . $topic . '.msg' . $_POST['msg'] . '#msg' . $_POST['msg']); |
|
| 286 | + if (!empty($ignore)) { |
|
| 287 | + redirectexit('topic=' . $topic . '.msg' . $_POST['msg'] . '#msg' . $_POST['msg']); |
|
| 288 | + } |
|
| 275 | 289 | |
| 276 | 290 | // Already reported? My god, we could be dealing with a real rogue here... |
| 277 | - if (!empty($id_report)) |
|
| 278 | - $smcFunc['db_query']('', ' |
|
| 291 | + if (!empty($id_report)) { |
|
| 292 | + $smcFunc['db_query']('', ' |
|
| 279 | 293 | UPDATE {db_prefix}log_reported |
| 280 | 294 | SET num_reports = num_reports + 1, time_updated = {int:current_time} |
| 281 | 295 | WHERE id_report = {int:id_report}', |
@@ -284,11 +298,13 @@ discard block |
||
| 284 | 298 | 'id_report' => $id_report, |
| 285 | 299 | ) |
| 286 | 300 | ); |
| 301 | + } |
|
| 287 | 302 | // Otherwise, we shall make one! |
| 288 | 303 | else |
| 289 | 304 | { |
| 290 | - if (empty($message['real_name'])) |
|
| 291 | - $message['real_name'] = $message['poster_name']; |
|
| 305 | + if (empty($message['real_name'])) { |
|
| 306 | + $message['real_name'] = $message['poster_name']; |
|
| 307 | + } |
|
| 292 | 308 | |
| 293 | 309 | $id_report = $smcFunc['db_insert']('', |
| 294 | 310 | '{db_prefix}log_reported', |
@@ -367,8 +383,9 @@ discard block |
||
| 367 | 383 | 'id_member' => $_POST['u'] |
| 368 | 384 | ) |
| 369 | 385 | ); |
| 370 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 371 | - fatal_lang_error('no_user', false); |
|
| 386 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 387 | + fatal_lang_error('no_user', false); |
|
| 388 | + } |
|
| 372 | 389 | $user = $smcFunc['db_fetch_assoc']($request); |
| 373 | 390 | $smcFunc['db_free_result']($request); |
| 374 | 391 | |
@@ -388,18 +405,20 @@ discard block |
||
| 388 | 405 | 'ignored' => 1, |
| 389 | 406 | ) |
| 390 | 407 | ); |
| 391 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
| 392 | - list ($id_report, $ignore) = $smcFunc['db_fetch_row']($request); |
|
| 408 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
| 409 | + list ($id_report, $ignore) = $smcFunc['db_fetch_row']($request); |
|
| 410 | + } |
|
| 393 | 411 | |
| 394 | 412 | $smcFunc['db_free_result']($request); |
| 395 | 413 | |
| 396 | 414 | // If we're just going to ignore these, then who gives a monkeys... |
| 397 | - if (!empty($ignore)) |
|
| 398 | - redirectexit('action=profile;u=' . $_POST['u']); |
|
| 415 | + if (!empty($ignore)) { |
|
| 416 | + redirectexit('action=profile;u=' . $_POST['u']); |
|
| 417 | + } |
|
| 399 | 418 | |
| 400 | 419 | // Already reported? My god, we could be dealing with a real rogue here... |
| 401 | - if (!empty($id_report)) |
|
| 402 | - $smcFunc['db_query']('', ' |
|
| 420 | + if (!empty($id_report)) { |
|
| 421 | + $smcFunc['db_query']('', ' |
|
| 403 | 422 | UPDATE {db_prefix}log_reported |
| 404 | 423 | SET num_reports = num_reports + 1, time_updated = {int:current_time} |
| 405 | 424 | WHERE id_report = {int:id_report}', |
@@ -408,6 +427,7 @@ discard block |
||
| 408 | 427 | 'id_report' => $id_report, |
| 409 | 428 | ) |
| 410 | 429 | ); |
| 430 | + } |
|
| 411 | 431 | // Otherwise, we shall make one! |
| 412 | 432 | else |
| 413 | 433 | { |
@@ -14,8 +14,9 @@ discard block |
||
| 14 | 14 | * @version 2.1 Beta 4 |
| 15 | 15 | */ |
| 16 | 16 | |
| 17 | -if (!defined('SMF')) |
|
| 17 | +if (!defined('SMF')) { |
|
| 18 | 18 | die('No direct access...'); |
| 19 | +} |
|
| 19 | 20 | |
| 20 | 21 | /** |
| 21 | 22 | * Shows a listing of registered members. |
@@ -110,8 +111,9 @@ discard block |
||
| 110 | 111 | |
| 111 | 112 | $context['custom_profile_fields'] = getCustFieldsMList(); |
| 112 | 113 | |
| 113 | - if (!empty($context['custom_profile_fields']['columns'])) |
|
| 114 | - $context['columns'] += $context['custom_profile_fields']['columns']; |
|
| 114 | + if (!empty($context['custom_profile_fields']['columns'])) { |
|
| 115 | + $context['columns'] += $context['custom_profile_fields']['columns']; |
|
| 116 | + } |
|
| 115 | 117 | |
| 116 | 118 | $context['colspan'] = 0; |
| 117 | 119 | $context['disabled_fields'] = isset($modSettings['disabled_profile_fields']) ? array_flip(explode(',', $modSettings['disabled_profile_fields'])) : array(); |
@@ -147,12 +149,12 @@ discard block |
||
| 147 | 149 | call_integration_hook('integrate_memberlist_buttons'); |
| 148 | 150 | |
| 149 | 151 | // Jump to the sub action. |
| 150 | - if (isset($subActions[$context['listing_by']])) |
|
| 151 | - call_helper($subActions[$context['listing_by']][1]); |
|
| 152 | - |
|
| 153 | - else |
|
| 154 | - call_helper($subActions['all'][1]); |
|
| 155 | -} |
|
| 152 | + if (isset($subActions[$context['listing_by']])) { |
|
| 153 | + call_helper($subActions[$context['listing_by']][1]); |
|
| 154 | + } else { |
|
| 155 | + call_helper($subActions['all'][1]); |
|
| 156 | + } |
|
| 157 | + } |
|
| 156 | 158 | |
| 157 | 159 | /** |
| 158 | 160 | * List all members, page by page, with sorting. |
@@ -177,8 +179,9 @@ discard block |
||
| 177 | 179 | if ($use_cache) |
| 178 | 180 | { |
| 179 | 181 | // Maybe there's something cached already. |
| 180 | - if (!empty($modSettings['memberlist_cache'])) |
|
| 181 | - $memberlist_cache = smf_json_decode($modSettings['memberlist_cache'], true); |
|
| 182 | + if (!empty($modSettings['memberlist_cache'])) { |
|
| 183 | + $memberlist_cache = smf_json_decode($modSettings['memberlist_cache'], true); |
|
| 184 | + } |
|
| 182 | 185 | |
| 183 | 186 | // The chunk size for the cached index. |
| 184 | 187 | $cache_step_size = 500; |
@@ -234,13 +237,15 @@ discard block |
||
| 234 | 237 | } |
| 235 | 238 | |
| 236 | 239 | // Set defaults for sort (real_name) and start. (0) |
| 237 | - if (!isset($_REQUEST['sort']) || !isset($context['columns'][$_REQUEST['sort']])) |
|
| 238 | - $_REQUEST['sort'] = 'real_name'; |
|
| 240 | + if (!isset($_REQUEST['sort']) || !isset($context['columns'][$_REQUEST['sort']])) { |
|
| 241 | + $_REQUEST['sort'] = 'real_name'; |
|
| 242 | + } |
|
| 239 | 243 | |
| 240 | 244 | if (!is_numeric($_REQUEST['start'])) |
| 241 | 245 | { |
| 242 | - if (preg_match('~^[^\'\\\\/]~' . ($context['utf8'] ? 'u' : ''), $smcFunc['strtolower']($_REQUEST['start']), $match) === 0) |
|
| 243 | - fatal_error('Hacker?', false); |
|
| 246 | + if (preg_match('~^[^\'\\\\/]~' . ($context['utf8'] ? 'u' : ''), $smcFunc['strtolower']($_REQUEST['start']), $match) === 0) { |
|
| 247 | + fatal_error('Hacker?', false); |
|
| 248 | + } |
|
| 244 | 249 | |
| 245 | 250 | $_REQUEST['start'] = $match[0]; |
| 246 | 251 | |
@@ -259,16 +264,18 @@ discard block |
||
| 259 | 264 | } |
| 260 | 265 | |
| 261 | 266 | $context['letter_links'] = ''; |
| 262 | - for ($i = 97; $i < 123; $i++) |
|
| 263 | - $context['letter_links'] .= '<a href="' . $scripturl . '?action=mlist;sa=all;start=' . chr($i) . '#letter' . chr($i) . '">' . strtoupper(chr($i)) . '</a> '; |
|
| 267 | + for ($i = 97; $i < 123; $i++) { |
|
| 268 | + $context['letter_links'] .= '<a href="' . $scripturl . '?action=mlist;sa=all;start=' . chr($i) . '#letter' . chr($i) . '">' . strtoupper(chr($i)) . '</a> '; |
|
| 269 | + } |
|
| 264 | 270 | |
| 265 | 271 | // Sort out the column information. |
| 266 | 272 | foreach ($context['columns'] as $col => $column_details) |
| 267 | 273 | { |
| 268 | 274 | $context['columns'][$col]['href'] = $scripturl . '?action=mlist;sort=' . $col . ';start=0'; |
| 269 | 275 | |
| 270 | - if ((!isset($_REQUEST['desc']) && $col == $_REQUEST['sort']) || ($col != $_REQUEST['sort'] && !empty($column_details['default_sort_rev']))) |
|
| 271 | - $context['columns'][$col]['href'] .= ';desc'; |
|
| 276 | + if ((!isset($_REQUEST['desc']) && $col == $_REQUEST['sort']) || ($col != $_REQUEST['sort'] && !empty($column_details['default_sort_rev']))) { |
|
| 277 | + $context['columns'][$col]['href'] .= ';desc'; |
|
| 278 | + } |
|
| 272 | 279 | |
| 273 | 280 | $context['columns'][$col]['link'] = '<a href="' . $context['columns'][$col]['href'] . '" rel="nofollow">' . $context['columns'][$col]['label'] . '</a>'; |
| 274 | 281 | $context['columns'][$col]['selected'] = $_REQUEST['sort'] == $col; |
@@ -317,8 +324,9 @@ discard block |
||
| 317 | 324 | elseif ($use_cache && $_REQUEST['sort'] === 'real_name') |
| 318 | 325 | { |
| 319 | 326 | $first_offset = floor(($memberlist_cache['num_members'] - $modSettings['defaultMaxMembers'] - $_REQUEST['start']) / $cache_step_size) * $cache_step_size; |
| 320 | - if ($first_offset < 0) |
|
| 321 | - $first_offset = 0; |
|
| 327 | + if ($first_offset < 0) { |
|
| 328 | + $first_offset = 0; |
|
| 329 | + } |
|
| 322 | 330 | $second_offset = ceil(($memberlist_cache['num_members'] - $_REQUEST['start']) / $cache_step_size) * $cache_step_size; |
| 323 | 331 | |
| 324 | 332 | $where = 'mem.real_name BETWEEN {string:real_name_low} AND {string:real_name_high}'; |
@@ -328,8 +336,9 @@ discard block |
||
| 328 | 336 | } |
| 329 | 337 | |
| 330 | 338 | $custom_fields_qry = ''; |
| 331 | - if (!empty($context['custom_profile_fields']['join'][$_REQUEST['sort']])) |
|
| 332 | - $custom_fields_qry = $context['custom_profile_fields']['join'][$_REQUEST['sort']]; |
|
| 339 | + if (!empty($context['custom_profile_fields']['join'][$_REQUEST['sort']])) { |
|
| 340 | + $custom_fields_qry = $context['custom_profile_fields']['join'][$_REQUEST['sort']]; |
|
| 341 | + } |
|
| 333 | 342 | |
| 334 | 343 | // Select the members from the database. |
| 335 | 344 | $request = $smcFunc['db_query']('', ' |
@@ -399,12 +408,13 @@ discard block |
||
| 399 | 408 | ) |
| 400 | 409 | ); |
| 401 | 410 | $context['custom_search_fields'] = array(); |
| 402 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 403 | - $context['custom_search_fields'][$row['col_name']] = array( |
|
| 411 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 412 | + $context['custom_search_fields'][$row['col_name']] = array( |
|
| 404 | 413 | 'colname' => $row['col_name'], |
| 405 | 414 | 'name' => $row['field_name'], |
| 406 | 415 | 'desc' => $row['field_desc'], |
| 407 | 416 | ); |
| 417 | + } |
|
| 408 | 418 | $smcFunc['db_free_result']($request); |
| 409 | 419 | |
| 410 | 420 | // They're searching.. |
@@ -417,23 +427,27 @@ discard block |
||
| 417 | 427 | $context['old_search_value'] = urlencode($_REQUEST['search']); |
| 418 | 428 | |
| 419 | 429 | // No fields? Use default... |
| 420 | - if (empty($_POST['fields'])) |
|
| 421 | - $_POST['fields'] = array('name'); |
|
| 430 | + if (empty($_POST['fields'])) { |
|
| 431 | + $_POST['fields'] = array('name'); |
|
| 432 | + } |
|
| 422 | 433 | |
| 423 | 434 | // Set defaults for how the results are sorted |
| 424 | - if (!isset($_REQUEST['sort']) || !isset($context['columns'][$_REQUEST['sort']])) |
|
| 425 | - $_REQUEST['sort'] = 'real_name'; |
|
| 435 | + if (!isset($_REQUEST['sort']) || !isset($context['columns'][$_REQUEST['sort']])) { |
|
| 436 | + $_REQUEST['sort'] = 'real_name'; |
|
| 437 | + } |
|
| 426 | 438 | |
| 427 | 439 | // Build the column link / sort information. |
| 428 | 440 | foreach ($context['columns'] as $col => $column_details) |
| 429 | 441 | { |
| 430 | 442 | $context['columns'][$col]['href'] = $scripturl . '?action=mlist;sa=search;start=0;sort=' . $col; |
| 431 | 443 | |
| 432 | - if ((!isset($_REQUEST['desc']) && $col == $_REQUEST['sort']) || ($col != $_REQUEST['sort'] && !empty($column_details['default_sort_rev']))) |
|
| 433 | - $context['columns'][$col]['href'] .= ';desc'; |
|
| 444 | + if ((!isset($_REQUEST['desc']) && $col == $_REQUEST['sort']) || ($col != $_REQUEST['sort'] && !empty($column_details['default_sort_rev']))) { |
|
| 445 | + $context['columns'][$col]['href'] .= ';desc'; |
|
| 446 | + } |
|
| 434 | 447 | |
| 435 | - if (isset($_POST['search']) && isset($_POST['fields'])) |
|
| 436 | - $context['columns'][$col]['href'] .= ';search=' . $_POST['search'] . ';fields=' . implode(',', $_POST['fields']); |
|
| 448 | + if (isset($_POST['search']) && isset($_POST['fields'])) { |
|
| 449 | + $context['columns'][$col]['href'] .= ';search=' . $_POST['search'] . ';fields=' . implode(',', $_POST['fields']); |
|
| 450 | + } |
|
| 437 | 451 | |
| 438 | 452 | $context['columns'][$col]['link'] = '<a href="' . $context['columns'][$col]['href'] . '" rel="nofollow">' . $context['columns'][$col]['label'] . '</a>'; |
| 439 | 453 | $context['columns'][$col]['selected'] = $_REQUEST['sort'] == $col; |
@@ -456,8 +470,7 @@ discard block |
||
| 456 | 470 | { |
| 457 | 471 | $fields = allowedTo('moderate_forum') ? array('member_name', 'real_name') : array('real_name'); |
| 458 | 472 | $search_fields[] = 'name'; |
| 459 | - } |
|
| 460 | - else |
|
| 473 | + } else |
|
| 461 | 474 | { |
| 462 | 475 | $fields = array(); |
| 463 | 476 | $search_fields = array(); |
@@ -482,9 +495,10 @@ discard block |
||
| 482 | 495 | $search_fields[] = 'email'; |
| 483 | 496 | } |
| 484 | 497 | |
| 485 | - if ($smcFunc['db_case_sensitive']) |
|
| 486 | - foreach ($fields as $key => $field) |
|
| 498 | + if ($smcFunc['db_case_sensitive']) { |
|
| 499 | + foreach ($fields as $key => $field) |
|
| 487 | 500 | $fields[$key] = 'LOWER(' . $field . ')'; |
| 501 | + } |
|
| 488 | 502 | |
| 489 | 503 | $customJoin = array(); |
| 490 | 504 | $customCount = 10; |
@@ -503,8 +517,9 @@ discard block |
||
| 503 | 517 | } |
| 504 | 518 | |
| 505 | 519 | // No search fields? That means you're trying to hack things |
| 506 | - if (empty($search_fields)) |
|
| 507 | - fatal_lang_error('invalid_search_string', false); |
|
| 520 | + if (empty($search_fields)) { |
|
| 521 | + fatal_lang_error('invalid_search_string', false); |
|
| 522 | + } |
|
| 508 | 523 | |
| 509 | 524 | $query = $_POST['search'] == '' ? '= {string:blank_string}' : ($smcFunc['db_case_sensitive'] ? 'LIKE LOWER({string:search})' : 'LIKE {string:search}'); |
| 510 | 525 | |
@@ -542,8 +557,7 @@ discard block |
||
| 542 | 557 | ); |
| 543 | 558 | printMemberListRows($request); |
| 544 | 559 | $smcFunc['db_free_result']($request); |
| 545 | - } |
|
| 546 | - else |
|
| 560 | + } else |
|
| 547 | 561 | { |
| 548 | 562 | // These are all the possible fields. |
| 549 | 563 | $context['search_fields'] = array( |
@@ -558,14 +572,14 @@ discard block |
||
| 558 | 572 | { |
| 559 | 573 | unset($context['search_fields']['email']); |
| 560 | 574 | $context['search_defaults'] = array('name'); |
| 561 | - } |
|
| 562 | - else |
|
| 575 | + } else |
|
| 563 | 576 | { |
| 564 | 577 | $context['search_defaults'] = array('name', 'email'); |
| 565 | 578 | } |
| 566 | 579 | |
| 567 | - foreach ($context['custom_search_fields'] as $field) |
|
| 568 | - $context['search_fields']['cust_' . $field['colname']] = sprintf($txt['mlist_search_by'], $field['name']); |
|
| 580 | + foreach ($context['custom_search_fields'] as $field) { |
|
| 581 | + $context['search_fields']['cust_' . $field['colname']] = sprintf($txt['mlist_search_by'], $field['name']); |
|
| 582 | + } |
|
| 569 | 583 | |
| 570 | 584 | $context['sub_template'] = 'search'; |
| 571 | 585 | $context['old_search'] = isset($_GET['search']) ? $_GET['search'] : (isset($_POST['search']) ? $smcFunc['htmlspecialchars']($_POST['search']) : ''); |
@@ -607,12 +621,14 @@ discard block |
||
| 607 | 621 | $smcFunc['db_free_result']($result); |
| 608 | 622 | |
| 609 | 623 | // Avoid division by zero... |
| 610 | - if ($most_posts == 0) |
|
| 611 | - $most_posts = 1; |
|
| 624 | + if ($most_posts == 0) { |
|
| 625 | + $most_posts = 1; |
|
| 626 | + } |
|
| 612 | 627 | |
| 613 | 628 | $members = array(); |
| 614 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 615 | - $members[] = $row['id_member']; |
|
| 629 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 630 | + $members[] = $row['id_member']; |
|
| 631 | + } |
|
| 616 | 632 | |
| 617 | 633 | // Load all the members for display. |
| 618 | 634 | loadMemberData($members); |
@@ -620,8 +636,9 @@ discard block |
||
| 620 | 636 | $context['members'] = array(); |
| 621 | 637 | foreach ($members as $member) |
| 622 | 638 | { |
| 623 | - if (!loadMemberContext($member)) |
|
| 624 | - continue; |
|
| 639 | + if (!loadMemberContext($member)) { |
|
| 640 | + continue; |
|
| 641 | + } |
|
| 625 | 642 | |
| 626 | 643 | $context['members'][$member] = $memberContext[$member]; |
| 627 | 644 | $context['members'][$member]['post_percent'] = round(($context['members'][$member]['real_posts'] * 100) / $most_posts); |
@@ -638,20 +655,21 @@ discard block |
||
| 638 | 655 | continue; |
| 639 | 656 | } |
| 640 | 657 | |
| 641 | - if ($column['bbc'] && !empty($context['members'][$member]['options'][$key])) |
|
| 642 | - $context['members'][$member]['options'][$key] = strip_tags(parse_bbc($context['members'][$member]['options'][$key])); |
|
| 643 | - |
|
| 644 | - elseif ($column['type'] == 'check') |
|
| 645 | - $context['members'][$member]['options'][$key] = $context['members'][$member]['options'][$key] == 0 ? $txt['no'] : $txt['yes']; |
|
| 658 | + if ($column['bbc'] && !empty($context['members'][$member]['options'][$key])) { |
|
| 659 | + $context['members'][$member]['options'][$key] = strip_tags(parse_bbc($context['members'][$member]['options'][$key])); |
|
| 660 | + } elseif ($column['type'] == 'check') { |
|
| 661 | + $context['members'][$member]['options'][$key] = $context['members'][$member]['options'][$key] == 0 ? $txt['no'] : $txt['yes']; |
|
| 662 | + } |
|
| 646 | 663 | |
| 647 | 664 | // Enclosing the user input within some other text? |
| 648 | - if (!empty($column['enclose'])) |
|
| 649 | - $context['members'][$member]['options'][$key] = strtr($column['enclose'], array( |
|
| 665 | + if (!empty($column['enclose'])) { |
|
| 666 | + $context['members'][$member]['options'][$key] = strtr($column['enclose'], array( |
|
| 650 | 667 | '{SCRIPTURL}' => $scripturl, |
| 651 | 668 | '{IMAGES_URL}' => $settings['images_url'], |
| 652 | 669 | '{DEFAULT_IMAGES_URL}' => $settings['default_images_url'], |
| 653 | 670 | '{INPUT}' => $context['members'][$member]['options'][$key], |
| 654 | 671 | )); |
| 672 | + } |
|
| 655 | 673 | } |
| 656 | 674 | } |
| 657 | 675 | } |
@@ -692,17 +710,17 @@ discard block |
||
| 692 | 710 | ); |
| 693 | 711 | |
| 694 | 712 | // Get the right sort method depending on the cust field type. |
| 695 | - if ($row['field_type'] != 'check') |
|
| 696 | - $cpf['columns'][$row['col_name']]['sort'] = array( |
|
| 713 | + if ($row['field_type'] != 'check') { |
|
| 714 | + $cpf['columns'][$row['col_name']]['sort'] = array( |
|
| 697 | 715 | 'down' => 'LENGTH(t' . $row['col_name'] . '.value) > 0 ASC, COALESCE(t' . $row['col_name'] . '.value, \'\') DESC', |
| 698 | 716 | 'up' => 'LENGTH(t' . $row['col_name'] . '.value) > 0 DESC, COALESCE(t' . $row['col_name'] . '.value, \'\') ASC' |
| 699 | 717 | ); |
| 700 | - |
|
| 701 | - else |
|
| 702 | - $cpf['columns'][$row['col_name']]['sort'] = array( |
|
| 718 | + } else { |
|
| 719 | + $cpf['columns'][$row['col_name']]['sort'] = array( |
|
| 703 | 720 | 'down' => 't' . $row['col_name'] . '.value DESC', |
| 704 | 721 | 'up' => 't' . $row['col_name'] . '.value ASC' |
| 705 | 722 | ); |
| 723 | + } |
|
| 706 | 724 | |
| 707 | 725 | $cpf['join'][$row['col_name']] = 'LEFT JOIN {db_prefix}themes AS t' . $row['col_name'] . ' ON (t' . $row['col_name'] . '.variable = {literal:' . $row['col_name'] . '} AND t' . $row['col_name'] . '.id_theme = 1 AND t' . $row['col_name'] . '.id_member = mem.id_member)'; |
| 708 | 726 | } |
@@ -12,8 +12,9 @@ discard block |
||
| 12 | 12 | * @version 2.1 Beta 4 |
| 13 | 13 | */ |
| 14 | 14 | |
| 15 | -if (!defined('SMF')) |
|
| 15 | +if (!defined('SMF')) { |
|
| 16 | 16 | die('No direct access...'); |
| 17 | +} |
|
| 17 | 18 | |
| 18 | 19 | /** |
| 19 | 20 | * Create a new list |
@@ -41,21 +42,21 @@ discard block |
||
| 41 | 42 | { |
| 42 | 43 | $list_context['sort'] = array(); |
| 43 | 44 | $sort = '1=1'; |
| 44 | - } |
|
| 45 | - else |
|
| 45 | + } else |
|
| 46 | 46 | { |
| 47 | 47 | $request_var_sort = isset($listOptions['request_vars']['sort']) ? $listOptions['request_vars']['sort'] : 'sort'; |
| 48 | 48 | $request_var_desc = isset($listOptions['request_vars']['desc']) ? $listOptions['request_vars']['desc'] : 'desc'; |
| 49 | - if (isset($_REQUEST[$request_var_sort], $listOptions['columns'][$_REQUEST[$request_var_sort]], $listOptions['columns'][$_REQUEST[$request_var_sort]]['sort'])) |
|
| 50 | - $list_context['sort'] = array( |
|
| 49 | + if (isset($_REQUEST[$request_var_sort], $listOptions['columns'][$_REQUEST[$request_var_sort]], $listOptions['columns'][$_REQUEST[$request_var_sort]]['sort'])) { |
|
| 50 | + $list_context['sort'] = array( |
|
| 51 | 51 | 'id' => $_REQUEST[$request_var_sort], |
| 52 | 52 | 'desc' => isset($_REQUEST[$request_var_desc]) && isset($listOptions['columns'][$_REQUEST[$request_var_sort]]['sort']['reverse']), |
| 53 | 53 | ); |
| 54 | - else |
|
| 55 | - $list_context['sort'] = array( |
|
| 54 | + } else { |
|
| 55 | + $list_context['sort'] = array( |
|
| 56 | 56 | 'id' => $listOptions['default_sort_col'], |
| 57 | 57 | 'desc' => (!empty($listOptions['default_sort_dir']) && $listOptions['default_sort_dir'] == 'desc') || (!empty($listOptions['columns'][$listOptions['default_sort_col']]['sort']['default']) && substr($listOptions['columns'][$listOptions['default_sort_col']]['sort']['default'], -4, 4) == 'desc') ? true : false, |
| 58 | 58 | ); |
| 59 | + } |
|
| 59 | 60 | |
| 60 | 61 | // Set the database column sort. |
| 61 | 62 | $sort = $listOptions['columns'][$list_context['sort']['id']]['sort'][$list_context['sort']['desc'] ? 'reverse' : 'default']; |
@@ -72,8 +73,9 @@ discard block |
||
| 72 | 73 | else |
| 73 | 74 | { |
| 74 | 75 | // First get an impression of how many items to expect. |
| 75 | - if (isset($listOptions['get_count']['file'])) |
|
| 76 | - require_once($listOptions['get_count']['file']); |
|
| 76 | + if (isset($listOptions['get_count']['file'])) { |
|
| 77 | + require_once($listOptions['get_count']['file']); |
|
| 78 | + } |
|
| 77 | 79 | |
| 78 | 80 | $call = call_helper($listOptions['get_count']['function'], true); |
| 79 | 81 | $list_context['total_num_items'] = call_user_func_array($call, empty($listOptions['get_count']['params']) ? array() : $listOptions['get_count']['params']); |
@@ -83,14 +85,15 @@ discard block |
||
| 83 | 85 | $list_context['items_per_page'] = $listOptions['items_per_page']; |
| 84 | 86 | |
| 85 | 87 | // Then create a page index. |
| 86 | - if ($list_context['total_num_items'] > $list_context['items_per_page']) |
|
| 87 | - $list_context['page_index'] = constructPageIndex($listOptions['base_href'] . (empty($list_context['sort']) ? '' : ';' . $request_var_sort . '=' . $list_context['sort']['id'] . ($list_context['sort']['desc'] ? ';' . $request_var_desc : '')) . ($list_context['start_var_name'] != 'start' ? ';' . $list_context['start_var_name'] . '=%1$d' : ''), $list_context['start'], $list_context['total_num_items'], $list_context['items_per_page'], $list_context['start_var_name'] != 'start'); |
|
| 88 | + if ($list_context['total_num_items'] > $list_context['items_per_page']) { |
|
| 89 | + $list_context['page_index'] = constructPageIndex($listOptions['base_href'] . (empty($list_context['sort']) ? '' : ';' . $request_var_sort . '=' . $list_context['sort']['id'] . ($list_context['sort']['desc'] ? ';' . $request_var_desc : '')) . ($list_context['start_var_name'] != 'start' ? ';' . $list_context['start_var_name'] . '=%1$d' : ''), $list_context['start'], $list_context['total_num_items'], $list_context['items_per_page'], $list_context['start_var_name'] != 'start'); |
|
| 90 | + } |
|
| 88 | 91 | } |
| 89 | 92 | |
| 90 | 93 | // Prepare the headers of the table. |
| 91 | 94 | $list_context['headers'] = array(); |
| 92 | - foreach ($listOptions['columns'] as $column_id => $column) |
|
| 93 | - $list_context['headers'][] = array( |
|
| 95 | + foreach ($listOptions['columns'] as $column_id => $column) { |
|
| 96 | + $list_context['headers'][] = array( |
|
| 94 | 97 | 'id' => $column_id, |
| 95 | 98 | 'label' => isset($column['header']['eval']) ? eval($column['header']['eval']) : (isset($column['header']['value']) ? $column['header']['value'] : ''), |
| 96 | 99 | 'href' => empty($listOptions['default_sort_col']) || empty($column['sort']) ? '' : $listOptions['base_href'] . ';' . $request_var_sort . '=' . $column_id . ($column_id === $list_context['sort']['id'] && !$list_context['sort']['desc'] && isset($column['sort']['reverse']) ? ';' . $request_var_desc : '') . (empty($list_context['start']) ? '' : ';' . $list_context['start_var_name'] . '=' . $list_context['start']), |
@@ -99,14 +102,16 @@ discard block |
||
| 99 | 102 | 'style' => isset($column['header']['style']) ? $column['header']['style'] : '', |
| 100 | 103 | 'colspan' => isset($column['header']['colspan']) ? $column['header']['colspan'] : '', |
| 101 | 104 | ); |
| 105 | + } |
|
| 102 | 106 | |
| 103 | 107 | // We know the amount of columns, might be useful for the template. |
| 104 | 108 | $list_context['num_columns'] = count($listOptions['columns']); |
| 105 | 109 | $list_context['width'] = isset($listOptions['width']) ? $listOptions['width'] : '0'; |
| 106 | 110 | |
| 107 | 111 | // Get the file with the function for the item list. |
| 108 | - if (isset($listOptions['get_items']['file'])) |
|
| 109 | - require_once($listOptions['get_items']['file']); |
|
| 112 | + if (isset($listOptions['get_items']['file'])) { |
|
| 113 | + require_once($listOptions['get_items']['file']); |
|
| 114 | + } |
|
| 110 | 115 | |
| 111 | 116 | // Call the function and include which items we want and in what order. |
| 112 | 117 | $call = call_helper($listOptions['get_items']['function'], true); |
@@ -123,51 +128,61 @@ discard block |
||
| 123 | 128 | $cur_data = array(); |
| 124 | 129 | |
| 125 | 130 | // A value straight from the database? |
| 126 | - if (isset($column['data']['db'])) |
|
| 127 | - $cur_data['value'] = $list_item[$column['data']['db']]; |
|
| 131 | + if (isset($column['data']['db'])) { |
|
| 132 | + $cur_data['value'] = $list_item[$column['data']['db']]; |
|
| 133 | + } |
|
| 128 | 134 | |
| 129 | 135 | // Take the value from the database and make it HTML safe. |
| 130 | - elseif (isset($column['data']['db_htmlsafe'])) |
|
| 131 | - $cur_data['value'] = $smcFunc['htmlspecialchars']($list_item[$column['data']['db_htmlsafe']]); |
|
| 136 | + elseif (isset($column['data']['db_htmlsafe'])) { |
|
| 137 | + $cur_data['value'] = $smcFunc['htmlspecialchars']($list_item[$column['data']['db_htmlsafe']]); |
|
| 138 | + } |
|
| 132 | 139 | |
| 133 | 140 | // Using sprintf is probably the most readable way of injecting data. |
| 134 | 141 | elseif (isset($column['data']['sprintf'])) |
| 135 | 142 | { |
| 136 | 143 | $params = array(); |
| 137 | - foreach ($column['data']['sprintf']['params'] as $sprintf_param => $htmlsafe) |
|
| 138 | - $params[] = $htmlsafe ? $smcFunc['htmlspecialchars']($list_item[$sprintf_param]) : $list_item[$sprintf_param]; |
|
| 144 | + foreach ($column['data']['sprintf']['params'] as $sprintf_param => $htmlsafe) { |
|
| 145 | + $params[] = $htmlsafe ? $smcFunc['htmlspecialchars']($list_item[$sprintf_param]) : $list_item[$sprintf_param]; |
|
| 146 | + } |
|
| 139 | 147 | $cur_data['value'] = vsprintf($column['data']['sprintf']['format'], $params); |
| 140 | 148 | } |
| 141 | 149 | |
| 142 | 150 | // The most flexible way probably is applying a custom function. |
| 143 | - elseif (isset($column['data']['function'])) |
|
| 144 | - $cur_data['value'] = call_user_func_array($column['data']['function'], array($list_item)); |
|
| 151 | + elseif (isset($column['data']['function'])) { |
|
| 152 | + $cur_data['value'] = call_user_func_array($column['data']['function'], array($list_item)); |
|
| 153 | + } |
|
| 145 | 154 | |
| 146 | 155 | // A modified value (inject the database values). |
| 147 | - elseif (isset($column['data']['eval'])) |
|
| 148 | - $cur_data['value'] = eval(preg_replace('~%([a-zA-Z0-9\-_]+)%~', '$list_item[\'$1\']', $column['data']['eval'])); |
|
| 156 | + elseif (isset($column['data']['eval'])) { |
|
| 157 | + $cur_data['value'] = eval(preg_replace('~%([a-zA-Z0-9\-_]+)%~', '$list_item[\'$1\']', $column['data']['eval'])); |
|
| 158 | + } |
|
| 149 | 159 | |
| 150 | 160 | // A literal value. |
| 151 | - elseif (isset($column['data']['value'])) |
|
| 152 | - $cur_data['value'] = $column['data']['value']; |
|
| 161 | + elseif (isset($column['data']['value'])) { |
|
| 162 | + $cur_data['value'] = $column['data']['value']; |
|
| 163 | + } |
|
| 153 | 164 | |
| 154 | 165 | // Empty value. |
| 155 | - else |
|
| 156 | - $cur_data['value'] = ''; |
|
| 166 | + else { |
|
| 167 | + $cur_data['value'] = ''; |
|
| 168 | + } |
|
| 157 | 169 | |
| 158 | 170 | // Allow for basic formatting. |
| 159 | - if (!empty($column['data']['comma_format'])) |
|
| 160 | - $cur_data['value'] = comma_format($cur_data['value']); |
|
| 161 | - elseif (!empty($column['data']['timeformat'])) |
|
| 162 | - $cur_data['value'] = timeformat($cur_data['value']); |
|
| 171 | + if (!empty($column['data']['comma_format'])) { |
|
| 172 | + $cur_data['value'] = comma_format($cur_data['value']); |
|
| 173 | + } elseif (!empty($column['data']['timeformat'])) { |
|
| 174 | + $cur_data['value'] = timeformat($cur_data['value']); |
|
| 175 | + } |
|
| 163 | 176 | |
| 164 | 177 | // Set a style class for this column? |
| 165 | - if (isset($column['data']['class'])) |
|
| 166 | - $cur_data['class'] = $column['data']['class']; |
|
| 178 | + if (isset($column['data']['class'])) { |
|
| 179 | + $cur_data['class'] = $column['data']['class']; |
|
| 180 | + } |
|
| 167 | 181 | |
| 168 | 182 | // Fully customized styling for the cells in this column only. |
| 169 | - if (isset($column['data']['style'])) |
|
| 170 | - $cur_data['style'] = $column['data']['style']; |
|
| 183 | + if (isset($column['data']['style'])) { |
|
| 184 | + $cur_data['style'] = $column['data']['style']; |
|
| 185 | + } |
|
| 171 | 186 | |
| 172 | 187 | // Add the data cell properties to the current row. |
| 173 | 188 | $cur_row[$column_id] = $cur_data; |
@@ -176,10 +191,12 @@ discard block |
||
| 176 | 191 | // Maybe we wat set a custom class for the row based on the data in the row itself |
| 177 | 192 | if (isset($listOptions['data_check'])) |
| 178 | 193 | { |
| 179 | - if (isset($listOptions['data_check']['class'])) |
|
| 180 | - $list_context['rows'][$item_id]['class'] = $listOptions['data_check']['class']($list_item); |
|
| 181 | - if (isset($listOptions['data_check']['style'])) |
|
| 182 | - $list_context['rows'][$item_id]['style'] = $listOptions['data_check']['style']($list_item); |
|
| 194 | + if (isset($listOptions['data_check']['class'])) { |
|
| 195 | + $list_context['rows'][$item_id]['class'] = $listOptions['data_check']['class']($list_item); |
|
| 196 | + } |
|
| 197 | + if (isset($listOptions['data_check']['style'])) { |
|
| 198 | + $list_context['rows'][$item_id]['style'] = $listOptions['data_check']['style']($list_item); |
|
| 199 | + } |
|
| 183 | 200 | } |
| 184 | 201 | |
| 185 | 202 | // Insert the row into the list. |
@@ -187,34 +204,39 @@ discard block |
||
| 187 | 204 | } |
| 188 | 205 | |
| 189 | 206 | // The title is currently optional. |
| 190 | - if (isset($listOptions['title'])) |
|
| 191 | - $list_context['title'] = $listOptions['title']; |
|
| 207 | + if (isset($listOptions['title'])) { |
|
| 208 | + $list_context['title'] = $listOptions['title']; |
|
| 209 | + } |
|
| 192 | 210 | |
| 193 | 211 | // In case there's a form, share it with the template context. |
| 194 | 212 | if (isset($listOptions['form'])) |
| 195 | 213 | { |
| 196 | 214 | $list_context['form'] = $listOptions['form']; |
| 197 | 215 | |
| 198 | - if (!isset($list_context['form']['hidden_fields'])) |
|
| 199 | - $list_context['form']['hidden_fields'] = array(); |
|
| 216 | + if (!isset($list_context['form']['hidden_fields'])) { |
|
| 217 | + $list_context['form']['hidden_fields'] = array(); |
|
| 218 | + } |
|
| 200 | 219 | |
| 201 | 220 | // Always add a session check field. |
| 202 | 221 | $list_context['form']['hidden_fields'][$context['session_var']] = $context['session_id']; |
| 203 | 222 | |
| 204 | 223 | // Will this do a token check? |
| 205 | - if (isset($listOptions['form']['token'])) |
|
| 206 | - $list_context['form']['hidden_fields'][$context[$listOptions['form']['token'] . '_token_var']] = $context[$listOptions['form']['token'] . '_token']; |
|
| 224 | + if (isset($listOptions['form']['token'])) { |
|
| 225 | + $list_context['form']['hidden_fields'][$context[$listOptions['form']['token'] . '_token_var']] = $context[$listOptions['form']['token'] . '_token']; |
|
| 226 | + } |
|
| 207 | 227 | |
| 208 | 228 | // Include the starting page as hidden field? |
| 209 | - if (!empty($list_context['form']['include_start']) && !empty($list_context['start'])) |
|
| 210 | - $list_context['form']['hidden_fields'][$list_context['start_var_name']] = $list_context['start']; |
|
| 229 | + if (!empty($list_context['form']['include_start']) && !empty($list_context['start'])) { |
|
| 230 | + $list_context['form']['hidden_fields'][$list_context['start_var_name']] = $list_context['start']; |
|
| 231 | + } |
|
| 211 | 232 | |
| 212 | 233 | // If sorting needs to be the same after submitting, add the parameter. |
| 213 | 234 | if (!empty($list_context['form']['include_sort']) && !empty($list_context['sort'])) |
| 214 | 235 | { |
| 215 | 236 | $list_context['form']['hidden_fields']['sort'] = $list_context['sort']['id']; |
| 216 | - if ($list_context['sort']['desc']) |
|
| 217 | - $list_context['form']['hidden_fields']['desc'] = 1; |
|
| 237 | + if ($list_context['sort']['desc']) { |
|
| 238 | + $list_context['form']['hidden_fields']['desc'] = 1; |
|
| 239 | + } |
|
| 218 | 240 | } |
| 219 | 241 | } |
| 220 | 242 | |
@@ -231,24 +253,28 @@ discard block |
||
| 231 | 253 | $list_context['additional_rows'] = array(); |
| 232 | 254 | foreach ($listOptions['additional_rows'] as $row) |
| 233 | 255 | { |
| 234 | - if (empty($row)) |
|
| 235 | - continue; |
|
| 256 | + if (empty($row)) { |
|
| 257 | + continue; |
|
| 258 | + } |
|
| 236 | 259 | |
| 237 | 260 | // Supported row positions: top_of_list, after_title, |
| 238 | 261 | // above_column_headers, below_table_data, bottom_of_list. |
| 239 | - if (!isset($list_context['additional_rows'][$row['position']])) |
|
| 240 | - $list_context['additional_rows'][$row['position']] = array(); |
|
| 262 | + if (!isset($list_context['additional_rows'][$row['position']])) { |
|
| 263 | + $list_context['additional_rows'][$row['position']] = array(); |
|
| 264 | + } |
|
| 241 | 265 | $list_context['additional_rows'][$row['position']][] = $row; |
| 242 | 266 | } |
| 243 | 267 | } |
| 244 | 268 | |
| 245 | 269 | // Add an option for inline JavaScript. |
| 246 | - if (isset($listOptions['javascript'])) |
|
| 247 | - $list_context['javascript'] = $listOptions['javascript']; |
|
| 270 | + if (isset($listOptions['javascript'])) { |
|
| 271 | + $list_context['javascript'] = $listOptions['javascript']; |
|
| 272 | + } |
|
| 248 | 273 | |
| 249 | 274 | // We want a menu. |
| 250 | - if (isset($listOptions['list_menu'])) |
|
| 251 | - $list_context['list_menu'] = $listOptions['list_menu']; |
|
| 275 | + if (isset($listOptions['list_menu'])) { |
|
| 276 | + $list_context['list_menu'] = $listOptions['list_menu']; |
|
| 277 | + } |
|
| 252 | 278 | |
| 253 | 279 | // Make sure the template is loaded. |
| 254 | 280 | loadTemplate('GenericList'); |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 4 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * Edit the position and properties of a category. |
@@ -42,8 +43,9 @@ discard block |
||
| 42 | 43 | $cat_order = array(); |
| 43 | 44 | |
| 44 | 45 | // Setting 'move_after' to '0' moves the category to the top. |
| 45 | - if ($catOptions['move_after'] == 0) |
|
| 46 | - $cats[] = $category_id; |
|
| 46 | + if ($catOptions['move_after'] == 0) { |
|
| 47 | + $cats[] = $category_id; |
|
| 48 | + } |
|
| 47 | 49 | |
| 48 | 50 | // Grab the categories sorted by cat_order. |
| 49 | 51 | $request = $smcFunc['db_query']('', ' |
@@ -55,17 +57,19 @@ discard block |
||
| 55 | 57 | ); |
| 56 | 58 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 57 | 59 | { |
| 58 | - if ($row['id_cat'] != $category_id) |
|
| 59 | - $cats[] = $row['id_cat']; |
|
| 60 | - if ($row['id_cat'] == $catOptions['move_after']) |
|
| 61 | - $cats[] = $category_id; |
|
| 60 | + if ($row['id_cat'] != $category_id) { |
|
| 61 | + $cats[] = $row['id_cat']; |
|
| 62 | + } |
|
| 63 | + if ($row['id_cat'] == $catOptions['move_after']) { |
|
| 64 | + $cats[] = $category_id; |
|
| 65 | + } |
|
| 62 | 66 | $cat_order[$row['id_cat']] = $row['cat_order']; |
| 63 | 67 | } |
| 64 | 68 | $smcFunc['db_free_result']($request); |
| 65 | 69 | |
| 66 | 70 | // Set the new order for the categories. |
| 67 | - foreach ($cats as $index => $cat) |
|
| 68 | - if ($index != $cat_order[$cat]) |
|
| 71 | + foreach ($cats as $index => $cat) { |
|
| 72 | + if ($index != $cat_order[$cat]) |
|
| 69 | 73 | $smcFunc['db_query']('', ' |
| 70 | 74 | UPDATE {db_prefix}categories |
| 71 | 75 | SET cat_order = {int:new_order} |
@@ -75,6 +79,7 @@ discard block |
||
| 75 | 79 | 'current_category' => $cat, |
| 76 | 80 | ) |
| 77 | 81 | ); |
| 82 | + } |
|
| 78 | 83 | |
| 79 | 84 | // If the category order changed, so did the board order. |
| 80 | 85 | require_once($sourcedir . '/Subs-Boards.php'); |
@@ -117,8 +122,9 @@ discard block |
||
| 117 | 122 | )) |
| 118 | 123 | ); |
| 119 | 124 | |
| 120 | - if (empty($catOptions['dont_log'])) |
|
| 121 | - logAction('edit_cat', array('catname' => isset($catOptions['cat_name']) ? $catOptions['cat_name'] : $category_id), 'admin'); |
|
| 125 | + if (empty($catOptions['dont_log'])) { |
|
| 126 | + logAction('edit_cat', array('catname' => isset($catOptions['cat_name']) ? $catOptions['cat_name'] : $category_id), 'admin'); |
|
| 127 | + } |
|
| 122 | 128 | } |
| 123 | 129 | } |
| 124 | 130 | |
@@ -135,16 +141,20 @@ discard block |
||
| 135 | 141 | global $smcFunc; |
| 136 | 142 | |
| 137 | 143 | // Check required values. |
| 138 | - if (!isset($catOptions['cat_name']) || trim($catOptions['cat_name']) == '') |
|
| 139 | - trigger_error('createCategory(): A category name is required', E_USER_ERROR); |
|
| 144 | + if (!isset($catOptions['cat_name']) || trim($catOptions['cat_name']) == '') { |
|
| 145 | + trigger_error('createCategory(): A category name is required', E_USER_ERROR); |
|
| 146 | + } |
|
| 140 | 147 | |
| 141 | 148 | // Set default values. |
| 142 | - if (!isset($catOptions['cat_desc'])) |
|
| 143 | - $catOptions['cat_desc'] = ''; |
|
| 144 | - if (!isset($catOptions['move_after'])) |
|
| 145 | - $catOptions['move_after'] = 0; |
|
| 146 | - if (!isset($catOptions['is_collapsible'])) |
|
| 147 | - $catOptions['is_collapsible'] = true; |
|
| 149 | + if (!isset($catOptions['cat_desc'])) { |
|
| 150 | + $catOptions['cat_desc'] = ''; |
|
| 151 | + } |
|
| 152 | + if (!isset($catOptions['move_after'])) { |
|
| 153 | + $catOptions['move_after'] = 0; |
|
| 154 | + } |
|
| 155 | + if (!isset($catOptions['is_collapsible'])) { |
|
| 156 | + $catOptions['is_collapsible'] = true; |
|
| 157 | + } |
|
| 148 | 158 | // Don't log an edit right after. |
| 149 | 159 | $catOptions['dont_log'] = true; |
| 150 | 160 | |
@@ -210,21 +220,24 @@ discard block |
||
| 210 | 220 | ) |
| 211 | 221 | ); |
| 212 | 222 | $boards_inside = array(); |
| 213 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 214 | - $boards_inside[] = $row['id_board']; |
|
| 223 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 224 | + $boards_inside[] = $row['id_board']; |
|
| 225 | + } |
|
| 215 | 226 | $smcFunc['db_free_result']($request); |
| 216 | 227 | |
| 217 | - if (!empty($boards_inside)) |
|
| 218 | - deleteBoards($boards_inside, null); |
|
| 228 | + if (!empty($boards_inside)) { |
|
| 229 | + deleteBoards($boards_inside, null); |
|
| 230 | + } |
|
| 219 | 231 | } |
| 220 | 232 | |
| 221 | 233 | // Make sure the safe category is really safe. |
| 222 | - elseif (in_array($moveBoardsTo, $categories)) |
|
| 223 | - trigger_error('deleteCategories(): You cannot move the boards to a category that\'s being deleted', E_USER_ERROR); |
|
| 234 | + elseif (in_array($moveBoardsTo, $categories)) { |
|
| 235 | + trigger_error('deleteCategories(): You cannot move the boards to a category that\'s being deleted', E_USER_ERROR); |
|
| 236 | + } |
|
| 224 | 237 | |
| 225 | 238 | // Move the boards inside the categories to a safe category. |
| 226 | - else |
|
| 227 | - $smcFunc['db_query']('', ' |
|
| 239 | + else { |
|
| 240 | + $smcFunc['db_query']('', ' |
|
| 228 | 241 | UPDATE {db_prefix}boards |
| 229 | 242 | SET id_cat = {int:new_parent_cat} |
| 230 | 243 | WHERE id_cat IN ({array_int:category_list})', |
@@ -233,6 +246,7 @@ discard block |
||
| 233 | 246 | 'new_parent_cat' => $moveBoardsTo, |
| 234 | 247 | ) |
| 235 | 248 | ); |
| 249 | + } |
|
| 236 | 250 | |
| 237 | 251 | // Do the deletion of the category itself |
| 238 | 252 | $smcFunc['db_query']('', ' |
@@ -244,8 +258,9 @@ discard block |
||
| 244 | 258 | ); |
| 245 | 259 | |
| 246 | 260 | // Log what we've done. |
| 247 | - foreach ($categories as $category) |
|
| 248 | - logAction('delete_cat', array('catname' => $cat_tree[$category]['node']['name']), 'admin'); |
|
| 261 | + foreach ($categories as $category) { |
|
| 262 | + logAction('delete_cat', array('catname' => $cat_tree[$category]['node']['name']), 'admin'); |
|
| 263 | + } |
|
| 249 | 264 | |
| 250 | 265 | // Get all boards back into the right order. |
| 251 | 266 | reorderBoards(); |
@@ -14,8 +14,9 @@ discard block |
||
| 14 | 14 | * @version 2.1 Beta 4 |
| 15 | 15 | */ |
| 16 | 16 | |
| 17 | -if (!defined('SMF')) |
|
| 17 | +if (!defined('SMF')) { |
|
| 18 | 18 | die('No direct access...'); |
| 19 | +} |
|
| 19 | 20 | |
| 20 | 21 | /** |
| 21 | 22 | * Show the list of topics in this board, along with any child boards. |
@@ -56,8 +57,9 @@ discard block |
||
| 56 | 57 | |
| 57 | 58 | $context['name'] = $board_info['name']; |
| 58 | 59 | $context['description'] = $board_info['description']; |
| 59 | - if (!empty($board_info['description'])) |
|
| 60 | - $context['meta_description'] = strip_tags($board_info['description']); |
|
| 60 | + if (!empty($board_info['description'])) { |
|
| 61 | + $context['meta_description'] = strip_tags($board_info['description']); |
|
| 62 | + } |
|
| 61 | 63 | |
| 62 | 64 | // How many topics do we have in total? |
| 63 | 65 | $board_info['total_topics'] = allowedTo('approve_posts') ? $board_info['num_topics'] + $board_info['unapproved_topics'] : $board_info['num_topics'] + $board_info['unapproved_user_topics']; |
@@ -73,12 +75,14 @@ discard block |
||
| 73 | 75 | $session_name = session_name(); |
| 74 | 76 | foreach ($_GET as $k => $v) |
| 75 | 77 | { |
| 76 | - if (!in_array($k, array('board', 'start', $session_name))) |
|
| 77 | - $context['robot_no_index'] = true; |
|
| 78 | + if (!in_array($k, array('board', 'start', $session_name))) { |
|
| 79 | + $context['robot_no_index'] = true; |
|
| 80 | + } |
|
| 78 | 81 | } |
| 79 | 82 | } |
| 80 | - if (!empty($_REQUEST['start']) && (!is_numeric($_REQUEST['start']) || $_REQUEST['start'] % $context['messages_per_page'] != 0)) |
|
| 81 | - $context['robot_no_index'] = true; |
|
| 83 | + if (!empty($_REQUEST['start']) && (!is_numeric($_REQUEST['start']) || $_REQUEST['start'] % $context['messages_per_page'] != 0)) { |
|
| 84 | + $context['robot_no_index'] = true; |
|
| 85 | + } |
|
| 82 | 86 | |
| 83 | 87 | // If we can view unapproved messages and there are some build up a list. |
| 84 | 88 | if (allowedTo('approve_posts') && ($board_info['unapproved_topics'] || $board_info['unapproved_posts'])) |
@@ -89,14 +93,16 @@ discard block |
||
| 89 | 93 | } |
| 90 | 94 | |
| 91 | 95 | // We only know these. |
| 92 | - if (isset($_REQUEST['sort']) && !in_array($_REQUEST['sort'], array('subject', 'starter', 'last_poster', 'replies', 'views', 'first_post', 'last_post'))) |
|
| 93 | - $_REQUEST['sort'] = 'last_post'; |
|
| 96 | + if (isset($_REQUEST['sort']) && !in_array($_REQUEST['sort'], array('subject', 'starter', 'last_poster', 'replies', 'views', 'first_post', 'last_post'))) { |
|
| 97 | + $_REQUEST['sort'] = 'last_post'; |
|
| 98 | + } |
|
| 94 | 99 | |
| 95 | 100 | // Make sure the starting place makes sense and construct the page index. |
| 96 | - if (isset($_REQUEST['sort'])) |
|
| 97 | - $context['page_index'] = constructPageIndex($scripturl . '?board=' . $board . '.%1$d;sort=' . $_REQUEST['sort'] . (isset($_REQUEST['desc']) ? ';desc' : ''), $_REQUEST['start'], $board_info['total_topics'], $maxindex, true); |
|
| 98 | - else |
|
| 99 | - $context['page_index'] = constructPageIndex($scripturl . '?board=' . $board . '.%1$d', $_REQUEST['start'], $board_info['total_topics'], $maxindex, true); |
|
| 101 | + if (isset($_REQUEST['sort'])) { |
|
| 102 | + $context['page_index'] = constructPageIndex($scripturl . '?board=' . $board . '.%1$d;sort=' . $_REQUEST['sort'] . (isset($_REQUEST['desc']) ? ';desc' : ''), $_REQUEST['start'], $board_info['total_topics'], $maxindex, true); |
|
| 103 | + } else { |
|
| 104 | + $context['page_index'] = constructPageIndex($scripturl . '?board=' . $board . '.%1$d', $_REQUEST['start'], $board_info['total_topics'], $maxindex, true); |
|
| 105 | + } |
|
| 100 | 106 | $context['start'] = &$_REQUEST['start']; |
| 101 | 107 | |
| 102 | 108 | // Set a canonical URL for this page. |
@@ -132,14 +138,16 @@ discard block |
||
| 132 | 138 | $context['link_moderators'] = array(); |
| 133 | 139 | if (!empty($board_info['moderators'])) |
| 134 | 140 | { |
| 135 | - foreach ($board_info['moderators'] as $mod) |
|
| 136 | - $context['link_moderators'][] = '<a href="' . $scripturl . '?action=profile;u=' . $mod['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod['name'] . '</a>'; |
|
| 141 | + foreach ($board_info['moderators'] as $mod) { |
|
| 142 | + $context['link_moderators'][] = '<a href="' . $scripturl . '?action=profile;u=' . $mod['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod['name'] . '</a>'; |
|
| 143 | + } |
|
| 137 | 144 | } |
| 138 | 145 | if (!empty($board_info['moderator_groups'])) |
| 139 | 146 | { |
| 140 | 147 | // By default just tack the moderator groups onto the end of the members |
| 141 | - foreach ($board_info['moderator_groups'] as $mod_group) |
|
| 142 | - $context['link_moderators'][] = '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $mod_group['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod_group['name'] . '</a>'; |
|
| 148 | + foreach ($board_info['moderator_groups'] as $mod_group) { |
|
| 149 | + $context['link_moderators'][] = '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $mod_group['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod_group['name'] . '</a>'; |
|
| 150 | + } |
|
| 143 | 151 | } |
| 144 | 152 | |
| 145 | 153 | // Now we tack the info onto the end of the linktree |
@@ -191,20 +199,24 @@ discard block |
||
| 191 | 199 | ); |
| 192 | 200 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 193 | 201 | { |
| 194 | - if (empty($row['id_member'])) |
|
| 195 | - continue; |
|
| 202 | + if (empty($row['id_member'])) { |
|
| 203 | + continue; |
|
| 204 | + } |
|
| 196 | 205 | |
| 197 | - if (!empty($row['online_color'])) |
|
| 198 | - $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>'; |
|
| 199 | - else |
|
| 200 | - $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
| 206 | + if (!empty($row['online_color'])) { |
|
| 207 | + $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>'; |
|
| 208 | + } else { |
|
| 209 | + $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
| 210 | + } |
|
| 201 | 211 | |
| 202 | 212 | $is_buddy = in_array($row['id_member'], $user_info['buddies']); |
| 203 | - if ($is_buddy) |
|
| 204 | - $link = '<strong>' . $link . '</strong>'; |
|
| 213 | + if ($is_buddy) { |
|
| 214 | + $link = '<strong>' . $link . '</strong>'; |
|
| 215 | + } |
|
| 205 | 216 | |
| 206 | - if (!empty($row['show_online']) || allowedTo('moderate_forum')) |
|
| 207 | - $context['view_members_list'][$row['log_time'] . $row['member_name']] = empty($row['show_online']) ? '<em>' . $link . '</em>' : $link; |
|
| 217 | + if (!empty($row['show_online']) || allowedTo('moderate_forum')) { |
|
| 218 | + $context['view_members_list'][$row['log_time'] . $row['member_name']] = empty($row['show_online']) ? '<em>' . $link . '</em>' : $link; |
|
| 219 | + } |
|
| 208 | 220 | // @todo why are we filling this array of data that are just counted (twice) and discarded? ??? |
| 209 | 221 | $context['view_members'][$row['log_time'] . $row['member_name']] = array( |
| 210 | 222 | 'id' => $row['id_member'], |
@@ -217,8 +229,9 @@ discard block |
||
| 217 | 229 | 'hidden' => empty($row['show_online']), |
| 218 | 230 | ); |
| 219 | 231 | |
| 220 | - if (empty($row['show_online'])) |
|
| 221 | - $context['view_num_hidden']++; |
|
| 232 | + if (empty($row['show_online'])) { |
|
| 233 | + $context['view_num_hidden']++; |
|
| 234 | + } |
|
| 222 | 235 | } |
| 223 | 236 | $context['view_num_guests'] = $smcFunc['db_num_rows']($request) - count($context['view_members']); |
| 224 | 237 | $smcFunc['db_free_result']($request); |
@@ -257,8 +270,9 @@ discard block |
||
| 257 | 270 | $context['sort_direction'] = $ascending ? 'up' : 'down'; |
| 258 | 271 | $txt['starter'] = $txt['started_by']; |
| 259 | 272 | |
| 260 | - foreach ($sort_methods as $key => $val) |
|
| 261 | - $context['topics_headers'][$key] = '<a href="' . $scripturl . '?board=' . $context['current_board'] . '.' . $context['start'] . ';sort=' . $key . ($context['sort_by'] == $key && $context['sort_direction'] == 'up' ? ';desc' : '') . '">' . $txt[$key] . ($context['sort_by'] == $key ? '<span class="sort sort_' . $context['sort_direction'] . '"></span>' : '') . '</a>'; |
|
| 273 | + foreach ($sort_methods as $key => $val) { |
|
| 274 | + $context['topics_headers'][$key] = '<a href="' . $scripturl . '?board=' . $context['current_board'] . '.' . $context['start'] . ';sort=' . $key . ($context['sort_by'] == $key && $context['sort_direction'] == 'up' ? ';desc' : '') . '">' . $txt[$key] . ($context['sort_by'] == $key ? '<span class="sort sort_' . $context['sort_direction'] . '"></span>' : '') . '</a>'; |
|
| 275 | + } |
|
| 262 | 276 | |
| 263 | 277 | // Calculate the fastest way to get the topics. |
| 264 | 278 | $start = (int) $_REQUEST['start']; |
@@ -268,14 +282,15 @@ discard block |
||
| 268 | 282 | $fake_ascending = true; |
| 269 | 283 | $maxindex = $board_info['total_topics'] < $start + $maxindex + 1 ? $board_info['total_topics'] - $start : $maxindex; |
| 270 | 284 | $start = $board_info['total_topics'] < $start + $maxindex + 1 ? 0 : $board_info['total_topics'] - $start - $maxindex; |
| 285 | + } else { |
|
| 286 | + $fake_ascending = false; |
|
| 271 | 287 | } |
| 272 | - else |
|
| 273 | - $fake_ascending = false; |
|
| 274 | 288 | |
| 275 | 289 | // Setup the default topic icons... |
| 276 | 290 | $context['icon_sources'] = array(); |
| 277 | - foreach ($context['stable_icons'] as $icon) |
|
| 278 | - $context['icon_sources'][$icon] = 'images_url'; |
|
| 291 | + foreach ($context['stable_icons'] as $icon) { |
|
| 292 | + $context['icon_sources'][$icon] = 'images_url'; |
|
| 293 | + } |
|
| 279 | 294 | |
| 280 | 295 | $topic_ids = array(); |
| 281 | 296 | $context['topics'] = array(); |
@@ -306,8 +321,9 @@ discard block |
||
| 306 | 321 | ) |
| 307 | 322 | ); |
| 308 | 323 | $topic_ids = array(); |
| 309 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 310 | - $topic_ids[] = $row['id_topic']; |
|
| 324 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 325 | + $topic_ids[] = $row['id_topic']; |
|
| 326 | + } |
|
| 311 | 327 | } |
| 312 | 328 | |
| 313 | 329 | // Grab the appropriate topic information... |
@@ -363,11 +379,13 @@ discard block |
||
| 363 | 379 | // Begin 'printing' the message index for current board. |
| 364 | 380 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 365 | 381 | { |
| 366 | - if ($row['id_poll'] > 0 && $modSettings['pollMode'] == '0') |
|
| 367 | - continue; |
|
| 382 | + if ($row['id_poll'] > 0 && $modSettings['pollMode'] == '0') { |
|
| 383 | + continue; |
|
| 384 | + } |
|
| 368 | 385 | |
| 369 | - if (!$pre_query) |
|
| 370 | - $topic_ids[] = $row['id_topic']; |
|
| 386 | + if (!$pre_query) { |
|
| 387 | + $topic_ids[] = $row['id_topic']; |
|
| 388 | + } |
|
| 371 | 389 | |
| 372 | 390 | // Reference the main color class. |
| 373 | 391 | $colorClass = 'windowbg'; |
@@ -377,8 +395,9 @@ discard block |
||
| 377 | 395 | { |
| 378 | 396 | // Limit them to $modSettings['preview_characters'] characters |
| 379 | 397 | $row['first_body'] = strip_tags(strtr(parse_bbc($row['first_body'], $row['first_smileys'], $row['id_first_msg']), array('<br>' => ' '))); |
| 380 | - if ($smcFunc['strlen']($row['first_body']) > $modSettings['preview_characters']) |
|
| 381 | - $row['first_body'] = $smcFunc['substr']($row['first_body'], 0, $modSettings['preview_characters']) . '...'; |
|
| 398 | + if ($smcFunc['strlen']($row['first_body']) > $modSettings['preview_characters']) { |
|
| 399 | + $row['first_body'] = $smcFunc['substr']($row['first_body'], 0, $modSettings['preview_characters']) . '...'; |
|
| 400 | + } |
|
| 382 | 401 | |
| 383 | 402 | // Censor the subject and message preview. |
| 384 | 403 | censorText($row['first_subject']); |
@@ -389,27 +408,27 @@ discard block |
||
| 389 | 408 | { |
| 390 | 409 | $row['last_subject'] = $row['first_subject']; |
| 391 | 410 | $row['last_body'] = $row['first_body']; |
| 392 | - } |
|
| 393 | - else |
|
| 411 | + } else |
|
| 394 | 412 | { |
| 395 | 413 | $row['last_body'] = strip_tags(strtr(parse_bbc($row['last_body'], $row['last_smileys'], $row['id_last_msg']), array('<br>' => ' '))); |
| 396 | - if ($smcFunc['strlen']($row['last_body']) > $modSettings['preview_characters']) |
|
| 397 | - $row['last_body'] = $smcFunc['substr']($row['last_body'], 0, $modSettings['preview_characters']) . '...'; |
|
| 414 | + if ($smcFunc['strlen']($row['last_body']) > $modSettings['preview_characters']) { |
|
| 415 | + $row['last_body'] = $smcFunc['substr']($row['last_body'], 0, $modSettings['preview_characters']) . '...'; |
|
| 416 | + } |
|
| 398 | 417 | |
| 399 | 418 | censorText($row['last_subject']); |
| 400 | 419 | censorText($row['last_body']); |
| 401 | 420 | } |
| 402 | - } |
|
| 403 | - else |
|
| 421 | + } else |
|
| 404 | 422 | { |
| 405 | 423 | $row['first_body'] = ''; |
| 406 | 424 | $row['last_body'] = ''; |
| 407 | 425 | censorText($row['first_subject']); |
| 408 | 426 | |
| 409 | - if ($row['id_first_msg'] == $row['id_last_msg']) |
|
| 410 | - $row['last_subject'] = $row['first_subject']; |
|
| 411 | - else |
|
| 412 | - censorText($row['last_subject']); |
|
| 427 | + if ($row['id_first_msg'] == $row['id_last_msg']) { |
|
| 428 | + $row['last_subject'] = $row['first_subject']; |
|
| 429 | + } else { |
|
| 430 | + censorText($row['last_subject']); |
|
| 431 | + } |
|
| 413 | 432 | } |
| 414 | 433 | |
| 415 | 434 | // Decide how many pages the topic should have. |
@@ -420,42 +439,50 @@ discard block |
||
| 420 | 439 | $pages = constructPageIndex($scripturl . '?topic=' . $row['id_topic'] . '.%1$d', $start, $row['num_replies'] + 1, $context['messages_per_page'], true, false); |
| 421 | 440 | |
| 422 | 441 | // If we can use all, show all. |
| 423 | - if (!empty($modSettings['enableAllMessages']) && $row['num_replies'] + 1 < $modSettings['enableAllMessages']) |
|
| 424 | - $pages .= ' <a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0;all">' . $txt['all'] . '</a>'; |
|
| 442 | + if (!empty($modSettings['enableAllMessages']) && $row['num_replies'] + 1 < $modSettings['enableAllMessages']) { |
|
| 443 | + $pages .= ' <a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0;all">' . $txt['all'] . '</a>'; |
|
| 444 | + } |
|
| 445 | + } else { |
|
| 446 | + $pages = ''; |
|
| 425 | 447 | } |
| 426 | - else |
|
| 427 | - $pages = ''; |
|
| 428 | 448 | |
| 429 | 449 | // We need to check the topic icons exist... |
| 430 | 450 | if (!empty($modSettings['messageIconChecks_enable'])) |
| 431 | 451 | { |
| 432 | - if (!isset($context['icon_sources'][$row['first_icon']])) |
|
| 433 | - $context['icon_sources'][$row['first_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['first_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
| 434 | - if (!isset($context['icon_sources'][$row['last_icon']])) |
|
| 435 | - $context['icon_sources'][$row['last_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['last_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
| 436 | - } |
|
| 437 | - else |
|
| 452 | + if (!isset($context['icon_sources'][$row['first_icon']])) { |
|
| 453 | + $context['icon_sources'][$row['first_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['first_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
| 454 | + } |
|
| 455 | + if (!isset($context['icon_sources'][$row['last_icon']])) { |
|
| 456 | + $context['icon_sources'][$row['last_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['last_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
| 457 | + } |
|
| 458 | + } else |
|
| 438 | 459 | { |
| 439 | - if (!isset($context['icon_sources'][$row['first_icon']])) |
|
| 440 | - $context['icon_sources'][$row['first_icon']] = 'images_url'; |
|
| 441 | - if (!isset($context['icon_sources'][$row['last_icon']])) |
|
| 442 | - $context['icon_sources'][$row['last_icon']] = 'images_url'; |
|
| 460 | + if (!isset($context['icon_sources'][$row['first_icon']])) { |
|
| 461 | + $context['icon_sources'][$row['first_icon']] = 'images_url'; |
|
| 462 | + } |
|
| 463 | + if (!isset($context['icon_sources'][$row['last_icon']])) { |
|
| 464 | + $context['icon_sources'][$row['last_icon']] = 'images_url'; |
|
| 465 | + } |
|
| 443 | 466 | } |
| 444 | 467 | |
| 445 | - if (!empty($board_info['recycle'])) |
|
| 446 | - $row['first_icon'] = 'recycled'; |
|
| 468 | + if (!empty($board_info['recycle'])) { |
|
| 469 | + $row['first_icon'] = 'recycled'; |
|
| 470 | + } |
|
| 447 | 471 | |
| 448 | 472 | // Is this topic pending approval, or does it have any posts pending approval? |
| 449 | - if ($context['can_approve_posts'] && $row['unapproved_posts']) |
|
| 450 | - $colorClass .= (!$row['approved'] ? ' approvetopic' : ' approvepost'); |
|
| 473 | + if ($context['can_approve_posts'] && $row['unapproved_posts']) { |
|
| 474 | + $colorClass .= (!$row['approved'] ? ' approvetopic' : ' approvepost'); |
|
| 475 | + } |
|
| 451 | 476 | |
| 452 | 477 | // Sticky topics should get a different color, too. |
| 453 | - if ($row['is_sticky']) |
|
| 454 | - $colorClass .= ' sticky'; |
|
| 478 | + if ($row['is_sticky']) { |
|
| 479 | + $colorClass .= ' sticky'; |
|
| 480 | + } |
|
| 455 | 481 | |
| 456 | 482 | // Locked topics get special treatment as well. |
| 457 | - if ($row['locked']) |
|
| 458 | - $colorClass .= ' locked'; |
|
| 483 | + if ($row['locked']) { |
|
| 484 | + $colorClass .= ' locked'; |
|
| 485 | + } |
|
| 459 | 486 | |
| 460 | 487 | // 'Print' the topic info. |
| 461 | 488 | $context['topics'][$row['id_topic']] = array_merge($row, array( |
@@ -536,8 +563,9 @@ discard block |
||
| 536 | 563 | $smcFunc['db_free_result']($result); |
| 537 | 564 | |
| 538 | 565 | // Fix the sequence of topics if they were retrieved in the wrong order. (for speed reasons...) |
| 539 | - if ($fake_ascending) |
|
| 540 | - $context['topics'] = array_reverse($context['topics'], true); |
|
| 566 | + if ($fake_ascending) { |
|
| 567 | + $context['topics'] = array_reverse($context['topics'], true); |
|
| 568 | + } |
|
| 541 | 569 | |
| 542 | 570 | if (!empty($modSettings['enableParticipation']) && !$user_info['is_guest'] && !empty($topic_ids)) |
| 543 | 571 | { |
@@ -554,8 +582,9 @@ discard block |
||
| 554 | 582 | 'limit' => count($topic_ids), |
| 555 | 583 | ) |
| 556 | 584 | ); |
| 557 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
| 558 | - $context['topics'][$row['id_topic']]['is_posted_in'] = true; |
|
| 585 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
| 586 | + $context['topics'][$row['id_topic']]['is_posted_in'] = true; |
|
| 587 | + } |
|
| 559 | 588 | $smcFunc['db_free_result']($result); |
| 560 | 589 | } |
| 561 | 590 | } |
@@ -580,9 +609,9 @@ discard block |
||
| 580 | 609 | // Can we restore topics? |
| 581 | 610 | $context['can_restore'] = allowedTo('move_any') && !empty($board_info['recycle']); |
| 582 | 611 | |
| 583 | - if ($user_info['is_admin'] || $modSettings['topic_move_any']) |
|
| 584 | - $context['can_move_any'] = true; |
|
| 585 | - else |
|
| 612 | + if ($user_info['is_admin'] || $modSettings['topic_move_any']) { |
|
| 613 | + $context['can_move_any'] = true; |
|
| 614 | + } else |
|
| 586 | 615 | { |
| 587 | 616 | // We'll use this in a minute |
| 588 | 617 | $boards_allowed = boardsAllowedTo('post_new'); |
@@ -609,11 +638,13 @@ discard block |
||
| 609 | 638 | } |
| 610 | 639 | |
| 611 | 640 | // Can we use quick moderation checkboxes? |
| 612 | - if ($options['display_quick_mod'] == 1) |
|
| 613 | - $context['can_quick_mod'] = $context['user']['is_logged'] || $context['can_approve'] || $context['can_remove'] || $context['can_lock'] || $context['can_sticky'] || $context['can_move'] || $context['can_merge'] || $context['can_restore']; |
|
| 641 | + if ($options['display_quick_mod'] == 1) { |
|
| 642 | + $context['can_quick_mod'] = $context['user']['is_logged'] || $context['can_approve'] || $context['can_remove'] || $context['can_lock'] || $context['can_sticky'] || $context['can_move'] || $context['can_merge'] || $context['can_restore']; |
|
| 643 | + } |
|
| 614 | 644 | // Or the icons? |
| 615 | - else |
|
| 616 | - $context['can_quick_mod'] = $context['can_remove'] || $context['can_lock'] || $context['can_sticky'] || $context['can_move']; |
|
| 645 | + else { |
|
| 646 | + $context['can_quick_mod'] = $context['can_remove'] || $context['can_lock'] || $context['can_sticky'] || $context['can_move']; |
|
| 647 | + } |
|
| 617 | 648 | } |
| 618 | 649 | |
| 619 | 650 | if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] == 1) |
@@ -647,13 +678,15 @@ discard block |
||
| 647 | 678 | ); |
| 648 | 679 | |
| 649 | 680 | // We've seen all these boards now! |
| 650 | - foreach ($board_info['parent_boards'] as $k => $dummy) |
|
| 651 | - if (isset($_SESSION['topicseen_cache'][$k])) |
|
| 681 | + foreach ($board_info['parent_boards'] as $k => $dummy) { |
|
| 682 | + if (isset($_SESSION['topicseen_cache'][$k])) |
|
| 652 | 683 | unset($_SESSION['topicseen_cache'][$k]); |
| 684 | + } |
|
| 653 | 685 | } |
| 654 | 686 | |
| 655 | - if (isset($_SESSION['topicseen_cache'][$board])) |
|
| 656 | - unset($_SESSION['topicseen_cache'][$board]); |
|
| 687 | + if (isset($_SESSION['topicseen_cache'][$board])) { |
|
| 688 | + unset($_SESSION['topicseen_cache'][$board]); |
|
| 689 | + } |
|
| 657 | 690 | |
| 658 | 691 | $request = $smcFunc['db_query']('', ' |
| 659 | 692 | SELECT id_topic, id_board, sent |
@@ -674,8 +707,9 @@ discard block |
||
| 674 | 707 | $context['is_marked_notify'] = true; |
| 675 | 708 | $board_sent = $row['sent']; |
| 676 | 709 | } |
| 677 | - if (!empty($row['id_topic'])) |
|
| 678 | - $context['topics'][$row['id_topic']]['is_watched'] = true; |
|
| 710 | + if (!empty($row['id_topic'])) { |
|
| 711 | + $context['topics'][$row['id_topic']]['is_watched'] = true; |
|
| 712 | + } |
|
| 679 | 713 | } |
| 680 | 714 | $smcFunc['db_free_result']($request); |
| 681 | 715 | |
@@ -699,8 +733,7 @@ discard block |
||
| 699 | 733 | $pref = !empty($pref[$user_info['id']]) ? $pref[$user_info['id']] : array(); |
| 700 | 734 | $pref = isset($pref['board_notify_' . $board]) ? $pref['board_notify_' . $board] : (!empty($pref['board_notify']) ? $pref['board_notify'] : 0); |
| 701 | 735 | $context['board_notification_mode'] = !$context['is_marked_notify'] ? 1 : ($pref & 0x02 ? 3 : ($pref & 0x01 ? 2 : 1)); |
| 702 | - } |
|
| 703 | - else |
|
| 736 | + } else |
|
| 704 | 737 | { |
| 705 | 738 | $context['is_marked_notify'] = false; |
| 706 | 739 | $context['board_notification_mode'] = 1; |
@@ -713,23 +746,27 @@ discard block |
||
| 713 | 746 | $context['becomesUnapproved'] = !empty($_SESSION['becomesUnapproved']) ? true : false; |
| 714 | 747 | |
| 715 | 748 | // Don't want to show this forever... |
| 716 | - if ($context['becomesUnapproved']) |
|
| 717 | - unset($_SESSION['becomesUnapproved']); |
|
| 749 | + if ($context['becomesUnapproved']) { |
|
| 750 | + unset($_SESSION['becomesUnapproved']); |
|
| 751 | + } |
|
| 718 | 752 | |
| 719 | 753 | // Build the message index button array. |
| 720 | 754 | $context['normal_buttons'] = array(); |
| 721 | 755 | |
| 722 | - if ($context['can_post_new']) |
|
| 723 | - $context['normal_buttons']['new_topic'] = array('text' => 'new_topic', 'image' => 'new_topic.png', 'lang' => true, 'url' => $scripturl . '?action=post;board=' . $context['current_board'] . '.0', 'active' => true); |
|
| 756 | + if ($context['can_post_new']) { |
|
| 757 | + $context['normal_buttons']['new_topic'] = array('text' => 'new_topic', 'image' => 'new_topic.png', 'lang' => true, 'url' => $scripturl . '?action=post;board=' . $context['current_board'] . '.0', 'active' => true); |
|
| 758 | + } |
|
| 724 | 759 | |
| 725 | - if ($context['can_post_poll']) |
|
| 726 | - $context['normal_buttons']['post_poll'] = array('text' => 'new_poll', 'image' => 'new_poll.png', 'lang' => true, 'url' => $scripturl . '?action=post;board=' . $context['current_board'] . '.0;poll'); |
|
| 760 | + if ($context['can_post_poll']) { |
|
| 761 | + $context['normal_buttons']['post_poll'] = array('text' => 'new_poll', 'image' => 'new_poll.png', 'lang' => true, 'url' => $scripturl . '?action=post;board=' . $context['current_board'] . '.0;poll'); |
|
| 762 | + } |
|
| 727 | 763 | |
| 728 | - if (!$context['user']['is_logged']) |
|
| 729 | - $context['normal_buttons']['markread'] = array('text' => 'mark_read_short', 'image' => 'markread.png', 'lang' => true, 'custom' => 'data-confirm="' . $txt['are_sure_mark_read'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=markasread;sa=board;board=' . $context['current_board'] . '.0;' . $context['session_var'] . '=' . $context['session_id']); |
|
| 764 | + if (!$context['user']['is_logged']) { |
|
| 765 | + $context['normal_buttons']['markread'] = array('text' => 'mark_read_short', 'image' => 'markread.png', 'lang' => true, 'custom' => 'data-confirm="' . $txt['are_sure_mark_read'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=markasread;sa=board;board=' . $context['current_board'] . '.0;' . $context['session_var'] . '=' . $context['session_id']); |
|
| 766 | + } |
|
| 730 | 767 | |
| 731 | - if ($context['can_mark_notify']) |
|
| 732 | - $context['normal_buttons']['notify'] = array( |
|
| 768 | + if ($context['can_mark_notify']) { |
|
| 769 | + $context['normal_buttons']['notify'] = array( |
|
| 733 | 770 | 'lang' => true, |
| 734 | 771 | 'text' => 'notify_board_' . $context['board_notification_mode'], |
| 735 | 772 | 'sub_buttons' => array( |
@@ -747,6 +784,7 @@ discard block |
||
| 747 | 784 | ), |
| 748 | 785 | ), |
| 749 | 786 | ); |
| 787 | + } |
|
| 750 | 788 | |
| 751 | 789 | // Javascript for inline editing. |
| 752 | 790 | loadJavaScriptFile('topic.js', array('defer' => false), 'smf_topic'); |
@@ -768,18 +806,21 @@ discard block |
||
| 768 | 806 | checkSession('request'); |
| 769 | 807 | |
| 770 | 808 | // Lets go straight to the restore area. |
| 771 | - if (isset($_REQUEST['qaction']) && $_REQUEST['qaction'] == 'restore' && !empty($_REQUEST['topics'])) |
|
| 772 | - redirectexit('action=restoretopic;topics=' . implode(',', $_REQUEST['topics']) . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 809 | + if (isset($_REQUEST['qaction']) && $_REQUEST['qaction'] == 'restore' && !empty($_REQUEST['topics'])) { |
|
| 810 | + redirectexit('action=restoretopic;topics=' . implode(',', $_REQUEST['topics']) . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 811 | + } |
|
| 773 | 812 | |
| 774 | - if (isset($_SESSION['topicseen_cache'])) |
|
| 775 | - $_SESSION['topicseen_cache'] = array(); |
|
| 813 | + if (isset($_SESSION['topicseen_cache'])) { |
|
| 814 | + $_SESSION['topicseen_cache'] = array(); |
|
| 815 | + } |
|
| 776 | 816 | |
| 777 | 817 | // This is going to be needed to send off the notifications and for updateLastMessages(). |
| 778 | 818 | require_once($sourcedir . '/Subs-Post.php'); |
| 779 | 819 | |
| 780 | 820 | // Remember the last board they moved things to. |
| 781 | - if (isset($_REQUEST['move_to'])) |
|
| 782 | - $_SESSION['move_to_topic'] = $_REQUEST['move_to']; |
|
| 821 | + if (isset($_REQUEST['move_to'])) { |
|
| 822 | + $_SESSION['move_to_topic'] = $_REQUEST['move_to']; |
|
| 823 | + } |
|
| 783 | 824 | |
| 784 | 825 | // Only a few possible actions. |
| 785 | 826 | $possibleActions = array(); |
@@ -799,8 +840,7 @@ discard block |
||
| 799 | 840 | ); |
| 800 | 841 | |
| 801 | 842 | $redirect_url = 'board=' . $board . '.' . $_REQUEST['start']; |
| 802 | - } |
|
| 803 | - else |
|
| 843 | + } else |
|
| 804 | 844 | { |
| 805 | 845 | /** |
| 806 | 846 | * @todo Ugly. There's no getting around this, is there? |
@@ -818,8 +858,7 @@ discard block |
||
| 818 | 858 | if (!empty($board)) |
| 819 | 859 | { |
| 820 | 860 | $boards_can['post_new'] = array_diff(boardsAllowedTo('post_new'), array($board)); |
| 821 | - } |
|
| 822 | - else |
|
| 861 | + } else |
|
| 823 | 862 | { |
| 824 | 863 | $boards_can['post_new'] = boardsAllowedTo('post_new'); |
| 825 | 864 | } |
@@ -830,55 +869,67 @@ discard block |
||
| 830 | 869 | } |
| 831 | 870 | } |
| 832 | 871 | |
| 833 | - if (!$user_info['is_guest']) |
|
| 834 | - $possibleActions[] = 'markread'; |
|
| 835 | - if (!empty($boards_can['make_sticky'])) |
|
| 836 | - $possibleActions[] = 'sticky'; |
|
| 837 | - if (!empty($boards_can['move_any']) || !empty($boards_can['move_own'])) |
|
| 838 | - $possibleActions[] = 'move'; |
|
| 839 | - if (!empty($boards_can['remove_any']) || !empty($boards_can['remove_own'])) |
|
| 840 | - $possibleActions[] = 'remove'; |
|
| 841 | - if (!empty($boards_can['lock_any']) || !empty($boards_can['lock_own'])) |
|
| 842 | - $possibleActions[] = 'lock'; |
|
| 843 | - if (!empty($boards_can['merge_any'])) |
|
| 844 | - $possibleActions[] = 'merge'; |
|
| 845 | - if (!empty($boards_can['approve_posts'])) |
|
| 846 | - $possibleActions[] = 'approve'; |
|
| 872 | + if (!$user_info['is_guest']) { |
|
| 873 | + $possibleActions[] = 'markread'; |
|
| 874 | + } |
|
| 875 | + if (!empty($boards_can['make_sticky'])) { |
|
| 876 | + $possibleActions[] = 'sticky'; |
|
| 877 | + } |
|
| 878 | + if (!empty($boards_can['move_any']) || !empty($boards_can['move_own'])) { |
|
| 879 | + $possibleActions[] = 'move'; |
|
| 880 | + } |
|
| 881 | + if (!empty($boards_can['remove_any']) || !empty($boards_can['remove_own'])) { |
|
| 882 | + $possibleActions[] = 'remove'; |
|
| 883 | + } |
|
| 884 | + if (!empty($boards_can['lock_any']) || !empty($boards_can['lock_own'])) { |
|
| 885 | + $possibleActions[] = 'lock'; |
|
| 886 | + } |
|
| 887 | + if (!empty($boards_can['merge_any'])) { |
|
| 888 | + $possibleActions[] = 'merge'; |
|
| 889 | + } |
|
| 890 | + if (!empty($boards_can['approve_posts'])) { |
|
| 891 | + $possibleActions[] = 'approve'; |
|
| 892 | + } |
|
| 847 | 893 | |
| 848 | 894 | // Two methods: $_REQUEST['actions'] (id_topic => action), and $_REQUEST['topics'] and $_REQUEST['qaction']. |
| 849 | 895 | // (if action is 'move', $_REQUEST['move_to'] or $_REQUEST['move_tos'][$topic] is used.) |
| 850 | 896 | if (!empty($_REQUEST['topics'])) |
| 851 | 897 | { |
| 852 | 898 | // If the action isn't valid, just quit now. |
| 853 | - if (empty($_REQUEST['qaction']) || !in_array($_REQUEST['qaction'], $possibleActions)) |
|
| 854 | - redirectexit($redirect_url); |
|
| 899 | + if (empty($_REQUEST['qaction']) || !in_array($_REQUEST['qaction'], $possibleActions)) { |
|
| 900 | + redirectexit($redirect_url); |
|
| 901 | + } |
|
| 855 | 902 | |
| 856 | 903 | // Merge requires all topics as one parameter and can be done at once. |
| 857 | 904 | if ($_REQUEST['qaction'] == 'merge') |
| 858 | 905 | { |
| 859 | 906 | // Merge requires at least two topics. |
| 860 | - if (empty($_REQUEST['topics']) || count($_REQUEST['topics']) < 2) |
|
| 861 | - redirectexit($redirect_url); |
|
| 907 | + if (empty($_REQUEST['topics']) || count($_REQUEST['topics']) < 2) { |
|
| 908 | + redirectexit($redirect_url); |
|
| 909 | + } |
|
| 862 | 910 | |
| 863 | 911 | require_once($sourcedir . '/SplitTopics.php'); |
| 864 | 912 | return MergeExecute($_REQUEST['topics']); |
| 865 | 913 | } |
| 866 | 914 | |
| 867 | 915 | // Just convert to the other method, to make it easier. |
| 868 | - foreach ($_REQUEST['topics'] as $topic) |
|
| 869 | - $_REQUEST['actions'][(int) $topic] = $_REQUEST['qaction']; |
|
| 916 | + foreach ($_REQUEST['topics'] as $topic) { |
|
| 917 | + $_REQUEST['actions'][(int) $topic] = $_REQUEST['qaction']; |
|
| 918 | + } |
|
| 870 | 919 | } |
| 871 | 920 | |
| 872 | 921 | // Weird... how'd you get here? |
| 873 | - if (empty($_REQUEST['actions'])) |
|
| 874 | - redirectexit($redirect_url); |
|
| 922 | + if (empty($_REQUEST['actions'])) { |
|
| 923 | + redirectexit($redirect_url); |
|
| 924 | + } |
|
| 875 | 925 | |
| 876 | 926 | // Validate each action. |
| 877 | 927 | $temp = array(); |
| 878 | 928 | foreach ($_REQUEST['actions'] as $topic => $action) |
| 879 | 929 | { |
| 880 | - if (in_array($action, $possibleActions)) |
|
| 881 | - $temp[(int) $topic] = $action; |
|
| 930 | + if (in_array($action, $possibleActions)) { |
|
| 931 | + $temp[(int) $topic] = $action; |
|
| 932 | + } |
|
| 882 | 933 | } |
| 883 | 934 | $_REQUEST['actions'] = $temp; |
| 884 | 935 | |
@@ -899,27 +950,31 @@ discard block |
||
| 899 | 950 | { |
| 900 | 951 | if (!empty($board)) |
| 901 | 952 | { |
| 902 | - if ($row['id_board'] != $board || ($modSettings['postmod_active'] && !$row['approved'] && !allowedTo('approve_posts'))) |
|
| 903 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 904 | - } |
|
| 905 | - else |
|
| 953 | + if ($row['id_board'] != $board || ($modSettings['postmod_active'] && !$row['approved'] && !allowedTo('approve_posts'))) { |
|
| 954 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 955 | + } |
|
| 956 | + } else |
|
| 906 | 957 | { |
| 907 | 958 | // Don't allow them to act on unapproved posts they can't see... |
| 908 | - if ($modSettings['postmod_active'] && !$row['approved'] && !in_array(0, $boards_can['approve_posts']) && !in_array($row['id_board'], $boards_can['approve_posts'])) |
|
| 909 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 959 | + if ($modSettings['postmod_active'] && !$row['approved'] && !in_array(0, $boards_can['approve_posts']) && !in_array($row['id_board'], $boards_can['approve_posts'])) { |
|
| 960 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 961 | + } |
|
| 910 | 962 | // Goodness, this is fun. We need to validate the action. |
| 911 | - elseif ($_REQUEST['actions'][$row['id_topic']] == 'sticky' && !in_array(0, $boards_can['make_sticky']) && !in_array($row['id_board'], $boards_can['make_sticky'])) |
|
| 912 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 913 | - elseif ($_REQUEST['actions'][$row['id_topic']] == 'move' && !in_array(0, $boards_can['move_any']) && !in_array($row['id_board'], $boards_can['move_any']) && ($row['id_member_started'] != $user_info['id'] || (!in_array(0, $boards_can['move_own']) && !in_array($row['id_board'], $boards_can['move_own'])))) |
|
| 914 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 915 | - elseif ($_REQUEST['actions'][$row['id_topic']] == 'remove' && !in_array(0, $boards_can['remove_any']) && !in_array($row['id_board'], $boards_can['remove_any']) && ($row['id_member_started'] != $user_info['id'] || (!in_array(0, $boards_can['remove_own']) && !in_array($row['id_board'], $boards_can['remove_own'])))) |
|
| 916 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 963 | + elseif ($_REQUEST['actions'][$row['id_topic']] == 'sticky' && !in_array(0, $boards_can['make_sticky']) && !in_array($row['id_board'], $boards_can['make_sticky'])) { |
|
| 964 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 965 | + } elseif ($_REQUEST['actions'][$row['id_topic']] == 'move' && !in_array(0, $boards_can['move_any']) && !in_array($row['id_board'], $boards_can['move_any']) && ($row['id_member_started'] != $user_info['id'] || (!in_array(0, $boards_can['move_own']) && !in_array($row['id_board'], $boards_can['move_own'])))) { |
|
| 966 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 967 | + } elseif ($_REQUEST['actions'][$row['id_topic']] == 'remove' && !in_array(0, $boards_can['remove_any']) && !in_array($row['id_board'], $boards_can['remove_any']) && ($row['id_member_started'] != $user_info['id'] || (!in_array(0, $boards_can['remove_own']) && !in_array($row['id_board'], $boards_can['remove_own'])))) { |
|
| 968 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 969 | + } |
|
| 917 | 970 | // @todo $locked is not set, what are you trying to do? (taking the change it is supposed to be $row['locked']) |
| 918 | - elseif ($_REQUEST['actions'][$row['id_topic']] == 'lock' && !in_array(0, $boards_can['lock_any']) && !in_array($row['id_board'], $boards_can['lock_any']) && ($row['id_member_started'] != $user_info['id'] || $row['locked'] == 1 || (!in_array(0, $boards_can['lock_own']) && !in_array($row['id_board'], $boards_can['lock_own'])))) |
|
| 919 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 971 | + elseif ($_REQUEST['actions'][$row['id_topic']] == 'lock' && !in_array(0, $boards_can['lock_any']) && !in_array($row['id_board'], $boards_can['lock_any']) && ($row['id_member_started'] != $user_info['id'] || $row['locked'] == 1 || (!in_array(0, $boards_can['lock_own']) && !in_array($row['id_board'], $boards_can['lock_own'])))) { |
|
| 972 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 973 | + } |
|
| 920 | 974 | // If the topic is approved then you need permission to approve the posts within. |
| 921 | - elseif ($_REQUEST['actions'][$row['id_topic']] == 'approve' && (!$row['unapproved_posts'] || (!in_array(0, $boards_can['approve_posts']) && !in_array($row['id_board'], $boards_can['approve_posts'])))) |
|
| 922 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 975 | + elseif ($_REQUEST['actions'][$row['id_topic']] == 'approve' && (!$row['unapproved_posts'] || (!in_array(0, $boards_can['approve_posts']) && !in_array($row['id_board'], $boards_can['approve_posts'])))) { |
|
| 976 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 977 | + } |
|
| 923 | 978 | } |
| 924 | 979 | } |
| 925 | 980 | $smcFunc['db_free_result']($request); |
@@ -937,11 +992,11 @@ discard block |
||
| 937 | 992 | { |
| 938 | 993 | $topic = (int) $topic; |
| 939 | 994 | |
| 940 | - if ($action == 'markread') |
|
| 941 | - $markCache[] = $topic; |
|
| 942 | - elseif ($action == 'sticky') |
|
| 943 | - $stickyCache[] = $topic; |
|
| 944 | - elseif ($action == 'move') |
|
| 995 | + if ($action == 'markread') { |
|
| 996 | + $markCache[] = $topic; |
|
| 997 | + } elseif ($action == 'sticky') { |
|
| 998 | + $stickyCache[] = $topic; |
|
| 999 | + } elseif ($action == 'move') |
|
| 945 | 1000 | { |
| 946 | 1001 | require_once($sourcedir . '/MoveTopic.php'); |
| 947 | 1002 | moveTopicConcurrence(); |
@@ -949,23 +1004,25 @@ discard block |
||
| 949 | 1004 | // $moveCache[0] is the topic, $moveCache[1] is the board to move to. |
| 950 | 1005 | $moveCache[1][$topic] = (int) (isset($_REQUEST['move_tos'][$topic]) ? $_REQUEST['move_tos'][$topic] : $_REQUEST['move_to']); |
| 951 | 1006 | |
| 952 | - if (empty($moveCache[1][$topic])) |
|
| 953 | - continue; |
|
| 1007 | + if (empty($moveCache[1][$topic])) { |
|
| 1008 | + continue; |
|
| 1009 | + } |
|
| 954 | 1010 | |
| 955 | 1011 | $moveCache[0][] = $topic; |
| 1012 | + } elseif ($action == 'remove') { |
|
| 1013 | + $removeCache[] = $topic; |
|
| 1014 | + } elseif ($action == 'lock') { |
|
| 1015 | + $lockCache[] = $topic; |
|
| 1016 | + } elseif ($action == 'approve') { |
|
| 1017 | + $approveCache[] = $topic; |
|
| 956 | 1018 | } |
| 957 | - elseif ($action == 'remove') |
|
| 958 | - $removeCache[] = $topic; |
|
| 959 | - elseif ($action == 'lock') |
|
| 960 | - $lockCache[] = $topic; |
|
| 961 | - elseif ($action == 'approve') |
|
| 962 | - $approveCache[] = $topic; |
|
| 963 | 1019 | } |
| 964 | 1020 | |
| 965 | - if (empty($board)) |
|
| 966 | - $affectedBoards = array(); |
|
| 967 | - else |
|
| 968 | - $affectedBoards = array($board => array(0, 0)); |
|
| 1021 | + if (empty($board)) { |
|
| 1022 | + $affectedBoards = array(); |
|
| 1023 | + } else { |
|
| 1024 | + $affectedBoards = array($board => array(0, 0)); |
|
| 1025 | + } |
|
| 969 | 1026 | |
| 970 | 1027 | // Do all the stickies... |
| 971 | 1028 | if (!empty($stickyCache)) |
@@ -1025,14 +1082,16 @@ discard block |
||
| 1025 | 1082 | { |
| 1026 | 1083 | $to = $moveCache[1][$row['id_topic']]; |
| 1027 | 1084 | |
| 1028 | - if (empty($to)) |
|
| 1029 | - continue; |
|
| 1085 | + if (empty($to)) { |
|
| 1086 | + continue; |
|
| 1087 | + } |
|
| 1030 | 1088 | |
| 1031 | 1089 | // Does this topic's board count the posts or not? |
| 1032 | 1090 | $countPosts[$row['id_topic']] = empty($row['count_posts']); |
| 1033 | 1091 | |
| 1034 | - if (!isset($moveTos[$to])) |
|
| 1035 | - $moveTos[$to] = array(); |
|
| 1092 | + if (!isset($moveTos[$to])) { |
|
| 1093 | + $moveTos[$to] = array(); |
|
| 1094 | + } |
|
| 1036 | 1095 | |
| 1037 | 1096 | $moveTos[$to][] = $row['id_topic']; |
| 1038 | 1097 | |
@@ -1046,8 +1105,9 @@ discard block |
||
| 1046 | 1105 | require_once($sourcedir . '/MoveTopic.php'); |
| 1047 | 1106 | |
| 1048 | 1107 | // Do the actual moves... |
| 1049 | - foreach ($moveTos as $to => $topics) |
|
| 1050 | - moveTopics($topics, $to); |
|
| 1108 | + foreach ($moveTos as $to => $topics) { |
|
| 1109 | + moveTopics($topics, $to); |
|
| 1110 | + } |
|
| 1051 | 1111 | |
| 1052 | 1112 | // Does the post counts need to be updated? |
| 1053 | 1113 | if (!empty($moveTos)) |
@@ -1096,20 +1156,23 @@ discard block |
||
| 1096 | 1156 | |
| 1097 | 1157 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1098 | 1158 | { |
| 1099 | - if (!isset($members[$row['id_member']])) |
|
| 1100 | - $members[$row['id_member']] = 0; |
|
| 1159 | + if (!isset($members[$row['id_member']])) { |
|
| 1160 | + $members[$row['id_member']] = 0; |
|
| 1161 | + } |
|
| 1101 | 1162 | |
| 1102 | - if ($topicRecounts[$row['id_topic']] === '+') |
|
| 1103 | - $members[$row['id_member']] += 1; |
|
| 1104 | - else |
|
| 1105 | - $members[$row['id_member']] -= 1; |
|
| 1163 | + if ($topicRecounts[$row['id_topic']] === '+') { |
|
| 1164 | + $members[$row['id_member']] += 1; |
|
| 1165 | + } else { |
|
| 1166 | + $members[$row['id_member']] -= 1; |
|
| 1167 | + } |
|
| 1106 | 1168 | } |
| 1107 | 1169 | |
| 1108 | 1170 | $smcFunc['db_free_result']($request); |
| 1109 | 1171 | |
| 1110 | 1172 | // And now update them member's post counts |
| 1111 | - foreach ($members as $id_member => $post_adj) |
|
| 1112 | - updateMemberData($id_member, array('posts' => 'posts + ' . $post_adj)); |
|
| 1173 | + foreach ($members as $id_member => $post_adj) { |
|
| 1174 | + updateMemberData($id_member, array('posts' => 'posts + ' . $post_adj)); |
|
| 1175 | + } |
|
| 1113 | 1176 | |
| 1114 | 1177 | } |
| 1115 | 1178 | } |
@@ -1189,8 +1252,9 @@ discard block |
||
| 1189 | 1252 | approveTopics($approveCache); |
| 1190 | 1253 | |
| 1191 | 1254 | // Time for some logging! |
| 1192 | - foreach ($approveCache as $topic) |
|
| 1193 | - logAction('approve_topic', array('topic' => $topic, 'member' => $approveCacheMembers[$topic])); |
|
| 1255 | + foreach ($approveCache as $topic) { |
|
| 1256 | + logAction('approve_topic', array('topic' => $topic, 'member' => $approveCacheMembers[$topic])); |
|
| 1257 | + } |
|
| 1194 | 1258 | } |
| 1195 | 1259 | } |
| 1196 | 1260 | |
@@ -1225,8 +1289,7 @@ discard block |
||
| 1225 | 1289 | $lockStatus[$row['id_topic']] = empty($row['locked']); |
| 1226 | 1290 | } |
| 1227 | 1291 | $smcFunc['db_free_result']($result); |
| 1228 | - } |
|
| 1229 | - else |
|
| 1292 | + } else |
|
| 1230 | 1293 | { |
| 1231 | 1294 | $result = $smcFunc['db_query']('', ' |
| 1232 | 1295 | SELECT id_topic, locked, id_board |
@@ -1276,13 +1339,15 @@ discard block |
||
| 1276 | 1339 | ) |
| 1277 | 1340 | ); |
| 1278 | 1341 | $logged_topics = array(); |
| 1279 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1280 | - $logged_topics[$row['id_topic']] = $row['unwatched']; |
|
| 1342 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1343 | + $logged_topics[$row['id_topic']] = $row['unwatched']; |
|
| 1344 | + } |
|
| 1281 | 1345 | $smcFunc['db_free_result']($request); |
| 1282 | 1346 | |
| 1283 | 1347 | $markArray = array(); |
| 1284 | - foreach ($markCache as $topic) |
|
| 1285 | - $markArray[] = array($modSettings['maxMsgID'], $user_info['id'], $topic, (isset($logged_topics[$topic]) ? $logged_topics[$topic] : 0)); |
|
| 1348 | + foreach ($markCache as $topic) { |
|
| 1349 | + $markArray[] = array($modSettings['maxMsgID'], $user_info['id'], $topic, (isset($logged_topics[$topic]) ? $logged_topics[$topic] : 0)); |
|
| 1350 | + } |
|
| 1286 | 1351 | |
| 1287 | 1352 | $smcFunc['db_insert']('replace', |
| 1288 | 1353 | '{db_prefix}log_topics', |
@@ -1295,8 +1360,9 @@ discard block |
||
| 1295 | 1360 | foreach ($moveCache as $topic) |
| 1296 | 1361 | { |
| 1297 | 1362 | // Didn't actually move anything! |
| 1298 | - if (!isset($topic[0])) |
|
| 1299 | - break; |
|
| 1363 | + if (!isset($topic[0])) { |
|
| 1364 | + break; |
|
| 1365 | + } |
|
| 1300 | 1366 | |
| 1301 | 1367 | logAction('move', array('topic' => $topic[0], 'board_from' => $topic[1], 'board_to' => $topic[2])); |
| 1302 | 1368 | sendNotifications($topic[0], 'move'); |
@@ -1318,8 +1384,9 @@ discard block |
||
| 1318 | 1384 | 'calendar_updated' => time(), |
| 1319 | 1385 | )); |
| 1320 | 1386 | |
| 1321 | - if (!empty($affectedBoards)) |
|
| 1322 | - updateLastMessages(array_keys($affectedBoards)); |
|
| 1387 | + if (!empty($affectedBoards)) { |
|
| 1388 | + updateLastMessages(array_keys($affectedBoards)); |
|
| 1389 | + } |
|
| 1323 | 1390 | |
| 1324 | 1391 | redirectexit($redirect_url); |
| 1325 | 1392 | } |