@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 3 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * Get the latest posts of a forum. |
@@ -59,8 +60,9 @@ discard block |
||
| 59 | 60 | censorText($row['body']); |
| 60 | 61 | |
| 61 | 62 | $row['body'] = strip_tags(strtr(parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']), array('<br>' => ' '))); |
| 62 | - if ($smcFunc['strlen']($row['body']) > 128) |
|
| 63 | - $row['body'] = $smcFunc['substr']($row['body'], 0, 128) . '...'; |
|
| 63 | + if ($smcFunc['strlen']($row['body']) > 128) { |
|
| 64 | + $row['body'] = $smcFunc['substr']($row['body'], 0, 128) . '...'; |
|
| 65 | + } |
|
| 64 | 66 | |
| 65 | 67 | // Build the array. |
| 66 | 68 | $posts[] = array( |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 3 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * Browse the list of package servers, add servers... |
@@ -43,13 +44,15 @@ discard block |
||
| 43 | 44 | ); |
| 44 | 45 | |
| 45 | 46 | // Now let's decide where we are taking this... |
| 46 | - if (isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']])) |
|
| 47 | - $context['sub_action'] = $_REQUEST['sa']; |
|
| 47 | + if (isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']])) { |
|
| 48 | + $context['sub_action'] = $_REQUEST['sa']; |
|
| 49 | + } |
|
| 48 | 50 | // We need to support possible old javascript links... |
| 49 | - elseif (isset($_GET['pgdownload'])) |
|
| 50 | - $context['sub_action'] = 'download'; |
|
| 51 | - else |
|
| 52 | - $context['sub_action'] = 'servers'; |
|
| 51 | + elseif (isset($_GET['pgdownload'])) { |
|
| 52 | + $context['sub_action'] = 'download'; |
|
| 53 | + } else { |
|
| 54 | + $context['sub_action'] = 'servers'; |
|
| 55 | + } |
|
| 53 | 56 | |
| 54 | 57 | // We need to force the "Download" tab as selected. |
| 55 | 58 | $context['menu_data_' . $context['admin_menu_id']]['current_subsection'] = 'packageget'; |
@@ -141,17 +144,19 @@ discard block |
||
| 141 | 144 | { |
| 142 | 145 | require_once($sourcedir . '/Class-Package.php'); |
| 143 | 146 | $ftp = new ftp_connection(null); |
| 147 | + } elseif ($ftp->error !== false && !isset($ftp_error)) { |
|
| 148 | + $ftp_error = $ftp->last_message === null ? '' : $ftp->last_message; |
|
| 144 | 149 | } |
| 145 | - elseif ($ftp->error !== false && !isset($ftp_error)) |
|
| 146 | - $ftp_error = $ftp->last_message === null ? '' : $ftp->last_message; |
|
| 147 | 150 | |
| 148 | 151 | list ($username, $detect_path, $found_path) = $ftp->detect_path($packagesdir); |
| 149 | 152 | |
| 150 | - if ($found_path || !isset($_POST['ftp_path'])) |
|
| 151 | - $_POST['ftp_path'] = $detect_path; |
|
| 153 | + if ($found_path || !isset($_POST['ftp_path'])) { |
|
| 154 | + $_POST['ftp_path'] = $detect_path; |
|
| 155 | + } |
|
| 152 | 156 | |
| 153 | - if (!isset($_POST['ftp_username'])) |
|
| 154 | - $_POST['ftp_username'] = $username; |
|
| 157 | + if (!isset($_POST['ftp_username'])) { |
|
| 158 | + $_POST['ftp_username'] = $username; |
|
| 159 | + } |
|
| 155 | 160 | |
| 156 | 161 | $context['package_ftp'] = array( |
| 157 | 162 | 'server' => isset($_POST['ftp_server']) ? $_POST['ftp_server'] : (isset($modSettings['package_server']) ? $modSettings['package_server'] : 'localhost'), |
@@ -160,8 +165,7 @@ discard block |
||
| 160 | 165 | 'path' => $_POST['ftp_path'], |
| 161 | 166 | 'error' => empty($ftp_error) ? null : $ftp_error, |
| 162 | 167 | ); |
| 163 | - } |
|
| 164 | - else |
|
| 168 | + } else |
|
| 165 | 169 | { |
| 166 | 170 | $context['package_download_broken'] = false; |
| 167 | 171 | |
@@ -203,8 +207,9 @@ discard block |
||
| 203 | 207 | |
| 204 | 208 | if (isset($_GET['server'])) |
| 205 | 209 | { |
| 206 | - if ($_GET['server'] == '') |
|
| 207 | - redirectexit('action=admin;area=packages;get'); |
|
| 210 | + if ($_GET['server'] == '') { |
|
| 211 | + redirectexit('action=admin;area=packages;get'); |
|
| 212 | + } |
|
| 208 | 213 | |
| 209 | 214 | $server = (int) $_GET['server']; |
| 210 | 215 | |
@@ -222,17 +227,18 @@ discard block |
||
| 222 | 227 | $smcFunc['db_free_result']($request); |
| 223 | 228 | |
| 224 | 229 | // If the server does not exist, dump out. |
| 225 | - if (empty($url)) |
|
| 226 | - fatal_lang_error('couldnt_connect', false); |
|
| 230 | + if (empty($url)) { |
|
| 231 | + fatal_lang_error('couldnt_connect', false); |
|
| 232 | + } |
|
| 227 | 233 | |
| 228 | 234 | // If there is a relative link, append to the stored server url. |
| 229 | - if (isset($_GET['relative'])) |
|
| 230 | - $url = $url . (substr($url, -1) == '/' ? '' : '/') . $_GET['relative']; |
|
| 235 | + if (isset($_GET['relative'])) { |
|
| 236 | + $url = $url . (substr($url, -1) == '/' ? '' : '/') . $_GET['relative']; |
|
| 237 | + } |
|
| 231 | 238 | |
| 232 | 239 | // Clear any "absolute" URL. Since "server" is present, "absolute" is garbage. |
| 233 | 240 | unset($_GET['absolute']); |
| 234 | - } |
|
| 235 | - elseif (isset($_GET['absolute']) && $_GET['absolute'] != '') |
|
| 241 | + } elseif (isset($_GET['absolute']) && $_GET['absolute'] != '') |
|
| 236 | 242 | { |
| 237 | 243 | // Initialize the requried variables. |
| 238 | 244 | $server = ''; |
@@ -256,16 +262,19 @@ discard block |
||
| 256 | 262 | } |
| 257 | 263 | } |
| 258 | 264 | // Minimum required parameter did not exist so dump out. |
| 259 | - else |
|
| 260 | - fatal_lang_error('couldnt_connect', false); |
|
| 265 | + else { |
|
| 266 | + fatal_lang_error('couldnt_connect', false); |
|
| 267 | + } |
|
| 261 | 268 | |
| 262 | 269 | // Attempt to connect. If unsuccessful... try the URL. |
| 263 | - if (!isset($_GET['package']) || file_exists($_GET['package'])) |
|
| 264 | - $_GET['package'] = $url . '/packages.xml?language=' . $context['user']['language']; |
|
| 270 | + if (!isset($_GET['package']) || file_exists($_GET['package'])) { |
|
| 271 | + $_GET['package'] = $url . '/packages.xml?language=' . $context['user']['language']; |
|
| 272 | + } |
|
| 265 | 273 | |
| 266 | 274 | // Check to be sure the packages.xml file actually exists where it is should be... or dump out. |
| 267 | - if ((isset($_GET['absolute']) || isset($_GET['relative'])) && !url_exists($_GET['package'])) |
|
| 268 | - fatal_lang_error('packageget_unable', false, array($url . '/index.php')); |
|
| 275 | + if ((isset($_GET['absolute']) || isset($_GET['relative'])) && !url_exists($_GET['package'])) { |
|
| 276 | + fatal_lang_error('packageget_unable', false, array($url . '/index.php')); |
|
| 277 | + } |
|
| 269 | 278 | |
| 270 | 279 | // Might take some time. |
| 271 | 280 | @set_time_limit(600); |
@@ -275,8 +284,9 @@ discard block |
||
| 275 | 284 | $listing = new xmlArray(fetch_web_data($_GET['package']), true); |
| 276 | 285 | |
| 277 | 286 | // Errm.... empty file? Try the URL.... |
| 278 | - if (!$listing->exists('package-list')) |
|
| 279 | - fatal_lang_error('packageget_unable', false, array($url . '/index.php')); |
|
| 287 | + if (!$listing->exists('package-list')) { |
|
| 288 | + fatal_lang_error('packageget_unable', false, array($url . '/index.php')); |
|
| 289 | + } |
|
| 280 | 290 | |
| 281 | 291 | // List out the packages... |
| 282 | 292 | $context['package_list'] = array(); |
@@ -284,8 +294,9 @@ discard block |
||
| 284 | 294 | $listing = $listing->path('package-list[0]'); |
| 285 | 295 | |
| 286 | 296 | // Use the package list's name if it exists. |
| 287 | - if ($listing->exists('list-title')) |
|
| 288 | - $name = $smcFunc['htmlspecialchars']($listing->fetch('list-title')); |
|
| 297 | + if ($listing->exists('list-title')) { |
|
| 298 | + $name = $smcFunc['htmlspecialchars']($listing->fetch('list-title')); |
|
| 299 | + } |
|
| 289 | 300 | |
| 290 | 301 | // Pick the correct template. |
| 291 | 302 | $context['sub_template'] = 'package_list'; |
@@ -300,28 +311,32 @@ discard block |
||
| 300 | 311 | |
| 301 | 312 | $installed_mods = array(); |
| 302 | 313 | // Look through the list of installed mods... |
| 303 | - foreach ($instmods as $installed_mod) |
|
| 304 | - $installed_mods[$installed_mod['package_id']] = $installed_mod['version']; |
|
| 314 | + foreach ($instmods as $installed_mod) { |
|
| 315 | + $installed_mods[$installed_mod['package_id']] = $installed_mod['version']; |
|
| 316 | + } |
|
| 305 | 317 | |
| 306 | 318 | // Get default author and email if they exist. |
| 307 | 319 | if ($listing->exists('default-author')) |
| 308 | 320 | { |
| 309 | 321 | $default_author = $smcFunc['htmlspecialchars']($listing->fetch('default-author')); |
| 310 | - if ($listing->exists('default-author/@email') && filter_var($listing->fetch('default-author/@email'), FILTER_VALIDATE_EMAIL)) |
|
| 311 | - $default_email = $smcFunc['htmlspecialchars']($listing->fetch('default-author/@email')); |
|
| 322 | + if ($listing->exists('default-author/@email') && filter_var($listing->fetch('default-author/@email'), FILTER_VALIDATE_EMAIL)) { |
|
| 323 | + $default_email = $smcFunc['htmlspecialchars']($listing->fetch('default-author/@email')); |
|
| 324 | + } |
|
| 312 | 325 | } |
| 313 | 326 | |
| 314 | 327 | // Get default web site if it exists. |
| 315 | 328 | if ($listing->exists('default-website')) |
| 316 | 329 | { |
| 317 | 330 | $default_website = $smcFunc['htmlspecialchars']($listing->fetch('default-website')); |
| 318 | - if ($listing->exists('default-website/@title')) |
|
| 319 | - $default_title = $smcFunc['htmlspecialchars']($listing->fetch('default-website/@title')); |
|
| 331 | + if ($listing->exists('default-website/@title')) { |
|
| 332 | + $default_title = $smcFunc['htmlspecialchars']($listing->fetch('default-website/@title')); |
|
| 333 | + } |
|
| 320 | 334 | } |
| 321 | 335 | |
| 322 | 336 | $the_version = strtr($forum_version, array('SMF ' => '')); |
| 323 | - if (!empty($_SESSION['version_emulate'])) |
|
| 324 | - $the_version = $_SESSION['version_emulate']; |
|
| 337 | + if (!empty($_SESSION['version_emulate'])) { |
|
| 338 | + $the_version = $_SESSION['version_emulate']; |
|
| 339 | + } |
|
| 325 | 340 | |
| 326 | 341 | $packageNum = 0; |
| 327 | 342 | $packageSection = 0; |
@@ -342,11 +357,13 @@ discard block |
||
| 342 | 357 | 'type' => $thisPackage->name(), |
| 343 | 358 | ); |
| 344 | 359 | |
| 345 | - if (in_array($package['type'], array('title', 'text'))) |
|
| 346 | - $context['package_list'][$packageSection][$package['type']] = $smcFunc['htmlspecialchars']($thisPackage->fetch('.')); |
|
| 360 | + if (in_array($package['type'], array('title', 'text'))) { |
|
| 361 | + $context['package_list'][$packageSection][$package['type']] = $smcFunc['htmlspecialchars']($thisPackage->fetch('.')); |
|
| 362 | + } |
|
| 347 | 363 | // It's a Title, Heading, Rule or Text. |
| 348 | - elseif (in_array($package['type'], array('heading', 'rule'))) |
|
| 349 | - $package['name'] = $smcFunc['htmlspecialchars']($thisPackage->fetch('.')); |
|
| 364 | + elseif (in_array($package['type'], array('heading', 'rule'))) { |
|
| 365 | + $package['name'] = $smcFunc['htmlspecialchars']($thisPackage->fetch('.')); |
|
| 366 | + } |
|
| 350 | 367 | // It's a Remote link. |
| 351 | 368 | elseif ($package['type'] == 'remote') |
| 352 | 369 | { |
@@ -354,20 +371,21 @@ discard block |
||
| 354 | 371 | |
| 355 | 372 | if ($remote_type == 'relative' && substr($thisPackage->fetch('@href'), 0, 7) != 'http://' && substr($thisPackage->fetch('@href'), 0, 8) != 'https://') |
| 356 | 373 | { |
| 357 | - if (isset($_GET['absolute'])) |
|
| 358 | - $current_url = $_GET['absolute'] . '/'; |
|
| 359 | - elseif (isset($_GET['relative'])) |
|
| 360 | - $current_url = $_GET['relative'] . '/'; |
|
| 361 | - else |
|
| 362 | - $current_url = ''; |
|
| 374 | + if (isset($_GET['absolute'])) { |
|
| 375 | + $current_url = $_GET['absolute'] . '/'; |
|
| 376 | + } elseif (isset($_GET['relative'])) { |
|
| 377 | + $current_url = $_GET['relative'] . '/'; |
|
| 378 | + } else { |
|
| 379 | + $current_url = ''; |
|
| 380 | + } |
|
| 363 | 381 | |
| 364 | 382 | $current_url .= $thisPackage->fetch('@href'); |
| 365 | - if (isset($_GET['absolute'])) |
|
| 366 | - $package['href'] = $scripturl . '?action=admin;area=packages;get;sa=browse;absolute=' . $current_url; |
|
| 367 | - else |
|
| 368 | - $package['href'] = $scripturl . '?action=admin;area=packages;get;sa=browse;server=' . $context['package_server'] . ';relative=' . $current_url; |
|
| 369 | - } |
|
| 370 | - else |
|
| 383 | + if (isset($_GET['absolute'])) { |
|
| 384 | + $package['href'] = $scripturl . '?action=admin;area=packages;get;sa=browse;absolute=' . $current_url; |
|
| 385 | + } else { |
|
| 386 | + $package['href'] = $scripturl . '?action=admin;area=packages;get;sa=browse;server=' . $context['package_server'] . ';relative=' . $current_url; |
|
| 387 | + } |
|
| 388 | + } else |
|
| 371 | 389 | { |
| 372 | 390 | $current_url = $thisPackage->fetch('@href'); |
| 373 | 391 | $package['href'] = $scripturl . '?action=admin;area=packages;get;sa=browse;absolute=' . $current_url; |
@@ -379,25 +397,28 @@ discard block |
||
| 379 | 397 | // It's a package... |
| 380 | 398 | else |
| 381 | 399 | { |
| 382 | - if (isset($_GET['absolute'])) |
|
| 383 | - $current_url = $_GET['absolute'] . '/'; |
|
| 384 | - elseif (isset($_GET['relative'])) |
|
| 385 | - $current_url = $_GET['relative'] . '/'; |
|
| 386 | - else |
|
| 387 | - $current_url = ''; |
|
| 400 | + if (isset($_GET['absolute'])) { |
|
| 401 | + $current_url = $_GET['absolute'] . '/'; |
|
| 402 | + } elseif (isset($_GET['relative'])) { |
|
| 403 | + $current_url = $_GET['relative'] . '/'; |
|
| 404 | + } else { |
|
| 405 | + $current_url = ''; |
|
| 406 | + } |
|
| 388 | 407 | |
| 389 | 408 | $server_att = $server != '' ? ';server=' . $server : ''; |
| 390 | 409 | |
| 391 | 410 | $package += $thisPackage->to_array(); |
| 392 | 411 | |
| 393 | - if (isset($package['website'])) |
|
| 394 | - unset($package['website']); |
|
| 412 | + if (isset($package['website'])) { |
|
| 413 | + unset($package['website']); |
|
| 414 | + } |
|
| 395 | 415 | $package['author'] = array(); |
| 396 | 416 | |
| 397 | - if ($package['description'] == '') |
|
| 398 | - $package['description'] = $txt['package_no_description']; |
|
| 399 | - else |
|
| 400 | - $package['description'] = parse_bbc(preg_replace('~\[[/]?html\]~i', '', $smcFunc['htmlspecialchars']($package['description']))); |
|
| 417 | + if ($package['description'] == '') { |
|
| 418 | + $package['description'] = $txt['package_no_description']; |
|
| 419 | + } else { |
|
| 420 | + $package['description'] = parse_bbc(preg_replace('~\[[/]?html\]~i', '', $smcFunc['htmlspecialchars']($package['description']))); |
|
| 421 | + } |
|
| 401 | 422 | |
| 402 | 423 | $package['is_installed'] = isset($installed_mods[$package['id']]); |
| 403 | 424 | $package['is_current'] = $package['is_installed'] && ($installed_mods[$package['id']] == $package['version']); |
@@ -406,12 +427,14 @@ discard block |
||
| 406 | 427 | // This package is either not installed, or installed but old. Is it supported on this version of SMF? |
| 407 | 428 | if (!$package['is_installed'] || (!$package['is_current'] && !$package['is_newer'])) |
| 408 | 429 | { |
| 409 | - if ($thisPackage->exists('version/@for')) |
|
| 410 | - $package['can_install'] = matchPackageVersion($the_version, $thisPackage->fetch('version/@for')); |
|
| 430 | + if ($thisPackage->exists('version/@for')) { |
|
| 431 | + $package['can_install'] = matchPackageVersion($the_version, $thisPackage->fetch('version/@for')); |
|
| 432 | + } |
|
| 411 | 433 | } |
| 412 | 434 | // Okay, it's already installed AND up to date. |
| 413 | - else |
|
| 414 | - $package['can_install'] = false; |
|
| 435 | + else { |
|
| 436 | + $package['can_install'] = false; |
|
| 437 | + } |
|
| 415 | 438 | |
| 416 | 439 | $already_exists = getPackageInfo(basename($package['filename'])); |
| 417 | 440 | $package['download_conflict'] = is_array($already_exists) && $already_exists['id'] == $package['id'] && $already_exists['version'] != $package['version']; |
@@ -423,40 +446,44 @@ discard block |
||
| 423 | 446 | |
| 424 | 447 | if ($thisPackage->exists('author') || isset($default_author)) |
| 425 | 448 | { |
| 426 | - if ($thisPackage->exists('author/@email') && filter_var($thisPackage->fetch('author/@email'), FILTER_VALIDATE_EMAIL)) |
|
| 427 | - $package['author']['email'] = $thisPackage->fetch('author/@email'); |
|
| 428 | - elseif (isset($default_email)) |
|
| 429 | - $package['author']['email'] = $default_email; |
|
| 430 | - |
|
| 431 | - if ($thisPackage->exists('author') && $thisPackage->fetch('author') != '') |
|
| 432 | - $package['author']['name'] = $smcFunc['htmlspecialchars']($thisPackage->fetch('author')); |
|
| 433 | - else |
|
| 434 | - $package['author']['name'] = $default_author; |
|
| 435 | - |
|
| 436 | - if (!empty($package['author']['email'])) |
|
| 437 | - $package['author']['link'] = '<a href="mailto:' . $package['author']['email'] . '">' . $package['author']['name'] . '</a>'; |
|
| 449 | + if ($thisPackage->exists('author/@email') && filter_var($thisPackage->fetch('author/@email'), FILTER_VALIDATE_EMAIL)) { |
|
| 450 | + $package['author']['email'] = $thisPackage->fetch('author/@email'); |
|
| 451 | + } elseif (isset($default_email)) { |
|
| 452 | + $package['author']['email'] = $default_email; |
|
| 453 | + } |
|
| 454 | + |
|
| 455 | + if ($thisPackage->exists('author') && $thisPackage->fetch('author') != '') { |
|
| 456 | + $package['author']['name'] = $smcFunc['htmlspecialchars']($thisPackage->fetch('author')); |
|
| 457 | + } else { |
|
| 458 | + $package['author']['name'] = $default_author; |
|
| 459 | + } |
|
| 460 | + |
|
| 461 | + if (!empty($package['author']['email'])) { |
|
| 462 | + $package['author']['link'] = '<a href="mailto:' . $package['author']['email'] . '">' . $package['author']['name'] . '</a>'; |
|
| 463 | + } |
|
| 438 | 464 | } |
| 439 | 465 | |
| 440 | 466 | if ($thisPackage->exists('website') || isset($default_website)) |
| 441 | 467 | { |
| 442 | - if ($thisPackage->exists('website') && $thisPackage->exists('website/@title')) |
|
| 443 | - $package['author']['website']['name'] = $smcFunc['htmlspecialchars']($thisPackage->fetch('website/@title')); |
|
| 444 | - elseif (isset($default_title)) |
|
| 445 | - $package['author']['website']['name'] = $default_title; |
|
| 446 | - elseif ($thisPackage->exists('website')) |
|
| 447 | - $package['author']['website']['name'] = $smcFunc['htmlspecialchars']($thisPackage->fetch('website')); |
|
| 448 | - else |
|
| 449 | - $package['author']['website']['name'] = $default_website; |
|
| 450 | - |
|
| 451 | - if ($thisPackage->exists('website') && $thisPackage->fetch('website') != '') |
|
| 452 | - $authorhompage = $smcFunc['htmlspecialchars']($thisPackage->fetch('website')); |
|
| 453 | - else |
|
| 454 | - $authorhompage = $default_website; |
|
| 468 | + if ($thisPackage->exists('website') && $thisPackage->exists('website/@title')) { |
|
| 469 | + $package['author']['website']['name'] = $smcFunc['htmlspecialchars']($thisPackage->fetch('website/@title')); |
|
| 470 | + } elseif (isset($default_title)) { |
|
| 471 | + $package['author']['website']['name'] = $default_title; |
|
| 472 | + } elseif ($thisPackage->exists('website')) { |
|
| 473 | + $package['author']['website']['name'] = $smcFunc['htmlspecialchars']($thisPackage->fetch('website')); |
|
| 474 | + } else { |
|
| 475 | + $package['author']['website']['name'] = $default_website; |
|
| 476 | + } |
|
| 477 | + |
|
| 478 | + if ($thisPackage->exists('website') && $thisPackage->fetch('website') != '') { |
|
| 479 | + $authorhompage = $smcFunc['htmlspecialchars']($thisPackage->fetch('website')); |
|
| 480 | + } else { |
|
| 481 | + $authorhompage = $default_website; |
|
| 482 | + } |
|
| 455 | 483 | |
| 456 | 484 | $package['author']['website']['href'] = $authorhompage; |
| 457 | 485 | $package['author']['website']['link'] = '<a href="' . $authorhompage . '">' . $package['author']['website']['name'] . '</a>'; |
| 458 | - } |
|
| 459 | - else |
|
| 486 | + } else |
|
| 460 | 487 | { |
| 461 | 488 | $package['author']['website']['href'] = ''; |
| 462 | 489 | $package['author']['website']['link'] = ''; |
@@ -472,11 +499,13 @@ discard block |
||
| 472 | 499 | $packageNum = in_array($package['type'], array('title', 'heading', 'text', 'remote', 'rule')) ? 0 : $packageNum + 1; |
| 473 | 500 | $package['count'] = $packageNum; |
| 474 | 501 | |
| 475 | - if (!in_array($package['type'], array('title', 'text'))) |
|
| 476 | - $context['package_list'][$packageSection]['items'][] = $package; |
|
| 502 | + if (!in_array($package['type'], array('title', 'text'))) { |
|
| 503 | + $context['package_list'][$packageSection]['items'][] = $package; |
|
| 504 | + } |
|
| 477 | 505 | |
| 478 | - if ($package['count'] > 1) |
|
| 479 | - $context['list_type'] = 'ol'; |
|
| 506 | + if ($package['count'] > 1) { |
|
| 507 | + $context['list_type'] = 'ol'; |
|
| 508 | + } |
|
| 480 | 509 | } |
| 481 | 510 | |
| 482 | 511 | $packageSection++; |
@@ -489,8 +518,9 @@ discard block |
||
| 489 | 518 | { |
| 490 | 519 | foreach ($packageSection['items'] as $i => $package) |
| 491 | 520 | { |
| 492 | - if ($package['count'] == 0 || isset($package['can_install'])) |
|
| 493 | - continue; |
|
| 521 | + if ($package['count'] == 0 || isset($package['can_install'])) { |
|
| 522 | + continue; |
|
| 523 | + } |
|
| 494 | 524 | |
| 495 | 525 | $context['package_list'][$ps_id]['items'][$i]['can_install'] = false; |
| 496 | 526 | |
@@ -539,8 +569,9 @@ discard block |
||
| 539 | 569 | checkSession('get'); |
| 540 | 570 | |
| 541 | 571 | // To download something, we need a valid server or url. |
| 542 | - if (empty($_GET['server']) && (!empty($_GET['get']) && !empty($_REQUEST['package']))) |
|
| 543 | - fatal_lang_error('package_get_error_is_zero', false); |
|
| 572 | + if (empty($_GET['server']) && (!empty($_GET['get']) && !empty($_REQUEST['package']))) { |
|
| 573 | + fatal_lang_error('package_get_error_is_zero', false); |
|
| 574 | + } |
|
| 544 | 575 | |
| 545 | 576 | if (isset($_GET['server'])) |
| 546 | 577 | { |
@@ -560,22 +591,23 @@ discard block |
||
| 560 | 591 | $smcFunc['db_free_result']($request); |
| 561 | 592 | |
| 562 | 593 | // If server does not exist then dump out. |
| 563 | - if (empty($url)) |
|
| 564 | - fatal_lang_error('couldnt_connect', false); |
|
| 594 | + if (empty($url)) { |
|
| 595 | + fatal_lang_error('couldnt_connect', false); |
|
| 596 | + } |
|
| 565 | 597 | |
| 566 | 598 | $url = $url . '/'; |
| 567 | - } |
|
| 568 | - else |
|
| 599 | + } else |
|
| 569 | 600 | { |
| 570 | 601 | // Initialize the requried variables. |
| 571 | 602 | $server = ''; |
| 572 | 603 | $url = ''; |
| 573 | 604 | } |
| 574 | 605 | |
| 575 | - if (isset($_REQUEST['byurl']) && !empty($_POST['filename'])) |
|
| 576 | - $package_name = basename($_REQUEST['filename']); |
|
| 577 | - else |
|
| 578 | - $package_name = basename($_REQUEST['package']); |
|
| 606 | + if (isset($_REQUEST['byurl']) && !empty($_POST['filename'])) { |
|
| 607 | + $package_name = basename($_REQUEST['filename']); |
|
| 608 | + } else { |
|
| 609 | + $package_name = basename($_REQUEST['package']); |
|
| 610 | + } |
|
| 579 | 611 | |
| 580 | 612 | if (isset($_REQUEST['conflict']) || (isset($_REQUEST['auto']) && file_exists($packagesdir . '/' . $package_name))) |
| 581 | 613 | { |
@@ -584,14 +616,15 @@ discard block |
||
| 584 | 616 | { |
| 585 | 617 | $ext = substr($package_name, strrpos(substr($package_name, 0, -3), '.')); |
| 586 | 618 | $package_name = substr($package_name, 0, strrpos(substr($package_name, 0, -3), '.')) . '_'; |
| 619 | + } else { |
|
| 620 | + $ext = ''; |
|
| 587 | 621 | } |
| 588 | - else |
|
| 589 | - $ext = ''; |
|
| 590 | 622 | |
| 591 | 623 | // Find the first available. |
| 592 | 624 | $i = 1; |
| 593 | - while (file_exists($packagesdir . '/' . $package_name . $i . $ext)) |
|
| 594 | - $i++; |
|
| 625 | + while (file_exists($packagesdir . '/' . $package_name . $i . $ext)) { |
|
| 626 | + $i++; |
|
| 627 | + } |
|
| 595 | 628 | |
| 596 | 629 | $package_name = $package_name . $i . $ext; |
| 597 | 630 | } |
@@ -601,25 +634,28 @@ discard block |
||
| 601 | 634 | package_put_contents($packagesdir . '/' . $package_name, fetch_web_data($url . $_REQUEST['package'])); |
| 602 | 635 | |
| 603 | 636 | // Done! Did we get this package automatically? |
| 604 | - if (preg_match('~^http://[\w_\-]+\.simplemachines\.org/~', $_REQUEST['package']) == 1 && strpos($_REQUEST['package'], 'dlattach') === false && isset($_REQUEST['auto'])) |
|
| 605 | - redirectexit('action=admin;area=packages;sa=install;package=' . $package_name); |
|
| 637 | + if (preg_match('~^http://[\w_\-]+\.simplemachines\.org/~', $_REQUEST['package']) == 1 && strpos($_REQUEST['package'], 'dlattach') === false && isset($_REQUEST['auto'])) { |
|
| 638 | + redirectexit('action=admin;area=packages;sa=install;package=' . $package_name); |
|
| 639 | + } |
|
| 606 | 640 | |
| 607 | 641 | // You just downloaded a mod from SERVER_NAME_GOES_HERE. |
| 608 | 642 | $context['package_server'] = $server; |
| 609 | 643 | |
| 610 | 644 | $context['package'] = getPackageInfo($package_name); |
| 611 | 645 | |
| 612 | - if (!is_array($context['package'])) |
|
| 613 | - fatal_lang_error('package_cant_download', false); |
|
| 646 | + if (!is_array($context['package'])) { |
|
| 647 | + fatal_lang_error('package_cant_download', false); |
|
| 648 | + } |
|
| 614 | 649 | |
| 615 | - if ($context['package']['type'] == 'modification') |
|
| 616 | - $context['package']['install']['link'] = '<a href="' . $scripturl . '?action=admin;area=packages;sa=install;package=' . $context['package']['filename'] . '">[ ' . $txt['install_mod'] . ' ]</a>'; |
|
| 617 | - elseif ($context['package']['type'] == 'avatar') |
|
| 618 | - $context['package']['install']['link'] = '<a href="' . $scripturl . '?action=admin;area=packages;sa=install;package=' . $context['package']['filename'] . '">[ ' . $txt['use_avatars'] . ' ]</a>'; |
|
| 619 | - elseif ($context['package']['type'] == 'language') |
|
| 620 | - $context['package']['install']['link'] = '<a href="' . $scripturl . '?action=admin;area=packages;sa=install;package=' . $context['package']['filename'] . '">[ ' . $txt['add_languages'] . ' ]</a>'; |
|
| 621 | - else |
|
| 622 | - $context['package']['install']['link'] = ''; |
|
| 650 | + if ($context['package']['type'] == 'modification') { |
|
| 651 | + $context['package']['install']['link'] = '<a href="' . $scripturl . '?action=admin;area=packages;sa=install;package=' . $context['package']['filename'] . '">[ ' . $txt['install_mod'] . ' ]</a>'; |
|
| 652 | + } elseif ($context['package']['type'] == 'avatar') { |
|
| 653 | + $context['package']['install']['link'] = '<a href="' . $scripturl . '?action=admin;area=packages;sa=install;package=' . $context['package']['filename'] . '">[ ' . $txt['use_avatars'] . ' ]</a>'; |
|
| 654 | + } elseif ($context['package']['type'] == 'language') { |
|
| 655 | + $context['package']['install']['link'] = '<a href="' . $scripturl . '?action=admin;area=packages;sa=install;package=' . $context['package']['filename'] . '">[ ' . $txt['add_languages'] . ' ]</a>'; |
|
| 656 | + } else { |
|
| 657 | + $context['package']['install']['link'] = ''; |
|
| 658 | + } |
|
| 623 | 659 | |
| 624 | 660 | // Does a 3rd party hook want to do some additional changes? |
| 625 | 661 | call_integration_hook('integrate_package_download'); |
@@ -645,10 +681,11 @@ discard block |
||
| 645 | 681 | // @todo Use FTP if the Packages directory is not writable. |
| 646 | 682 | |
| 647 | 683 | // Check the file was even sent! |
| 648 | - if (!isset($_FILES['package']['name']) || $_FILES['package']['name'] == '') |
|
| 649 | - fatal_lang_error('package_upload_error_nofile'); |
|
| 650 | - elseif (!is_uploaded_file($_FILES['package']['tmp_name']) || (ini_get('open_basedir') == '' && !file_exists($_FILES['package']['tmp_name']))) |
|
| 651 | - fatal_lang_error('package_upload_error_failed'); |
|
| 684 | + if (!isset($_FILES['package']['name']) || $_FILES['package']['name'] == '') { |
|
| 685 | + fatal_lang_error('package_upload_error_nofile'); |
|
| 686 | + } elseif (!is_uploaded_file($_FILES['package']['tmp_name']) || (ini_get('open_basedir') == '' && !file_exists($_FILES['package']['tmp_name']))) { |
|
| 687 | + fatal_lang_error('package_upload_error_failed'); |
|
| 688 | + } |
|
| 652 | 689 | |
| 653 | 690 | // Make sure it has a sane filename. |
| 654 | 691 | $_FILES['package']['name'] = preg_replace(array('/\s/', '/\.[\.]+/', '/[^\w_\.\-]/'), array('_', '.', ''), $_FILES['package']['name']); |
@@ -665,8 +702,9 @@ discard block |
||
| 665 | 702 | // Setup the destination and throw an error if the file is already there! |
| 666 | 703 | $destination = $packagesdir . '/' . $packageName; |
| 667 | 704 | // @todo Maybe just roll it like we do for downloads? |
| 668 | - if (file_exists($destination)) |
|
| 669 | - fatal_lang_error('package_upload_error_exists'); |
|
| 705 | + if (file_exists($destination)) { |
|
| 706 | + fatal_lang_error('package_upload_error_exists'); |
|
| 707 | + } |
|
| 670 | 708 | |
| 671 | 709 | // Now move the file. |
| 672 | 710 | move_uploaded_file($_FILES['package']['tmp_name'], $destination); |
@@ -689,12 +727,14 @@ discard block |
||
| 689 | 727 | { |
| 690 | 728 | while ($package = readdir($dir)) |
| 691 | 729 | { |
| 692 | - if ($package == '.' || $package == '..' || $package == 'temp' || $package == $packageName || (!(is_dir($packagesdir . '/' . $package) && file_exists($packagesdir . '/' . $package . '/package-info.xml')) && substr(strtolower($package), -7) != '.tar.gz' && substr(strtolower($package), -4) != '.tgz' && substr(strtolower($package), -4) != '.zip')) |
|
| 693 | - continue; |
|
| 730 | + if ($package == '.' || $package == '..' || $package == 'temp' || $package == $packageName || (!(is_dir($packagesdir . '/' . $package) && file_exists($packagesdir . '/' . $package . '/package-info.xml')) && substr(strtolower($package), -7) != '.tar.gz' && substr(strtolower($package), -4) != '.tgz' && substr(strtolower($package), -4) != '.zip')) { |
|
| 731 | + continue; |
|
| 732 | + } |
|
| 694 | 733 | |
| 695 | 734 | $packageInfo = getPackageInfo($package); |
| 696 | - if (!is_array($packageInfo)) |
|
| 697 | - continue; |
|
| 735 | + if (!is_array($packageInfo)) { |
|
| 736 | + continue; |
|
| 737 | + } |
|
| 698 | 738 | |
| 699 | 739 | if ($packageInfo['id'] == $context['package']['id'] && $packageInfo['version'] == $context['package']['version']) |
| 700 | 740 | { |
@@ -706,14 +746,15 @@ discard block |
||
| 706 | 746 | closedir($dir); |
| 707 | 747 | } |
| 708 | 748 | |
| 709 | - if ($context['package']['type'] == 'modification') |
|
| 710 | - $context['package']['install']['link'] = '<a href="' . $scripturl . '?action=admin;area=packages;sa=install;package=' . $context['package']['filename'] . '">[ ' . $txt['install_mod'] . ' ]</a>'; |
|
| 711 | - elseif ($context['package']['type'] == 'avatar') |
|
| 712 | - $context['package']['install']['link'] = '<a href="' . $scripturl . '?action=admin;area=packages;sa=install;package=' . $context['package']['filename'] . '">[ ' . $txt['use_avatars'] . ' ]</a>'; |
|
| 713 | - elseif ($context['package']['type'] == 'language') |
|
| 714 | - $context['package']['install']['link'] = '<a href="' . $scripturl . '?action=admin;area=packages;sa=install;package=' . $context['package']['filename'] . '">[ ' . $txt['add_languages'] . ' ]</a>'; |
|
| 715 | - else |
|
| 716 | - $context['package']['install']['link'] = ''; |
|
| 749 | + if ($context['package']['type'] == 'modification') { |
|
| 750 | + $context['package']['install']['link'] = '<a href="' . $scripturl . '?action=admin;area=packages;sa=install;package=' . $context['package']['filename'] . '">[ ' . $txt['install_mod'] . ' ]</a>'; |
|
| 751 | + } elseif ($context['package']['type'] == 'avatar') { |
|
| 752 | + $context['package']['install']['link'] = '<a href="' . $scripturl . '?action=admin;area=packages;sa=install;package=' . $context['package']['filename'] . '">[ ' . $txt['use_avatars'] . ' ]</a>'; |
|
| 753 | + } elseif ($context['package']['type'] == 'language') { |
|
| 754 | + $context['package']['install']['link'] = '<a href="' . $scripturl . '?action=admin;area=packages;sa=install;package=' . $context['package']['filename'] . '">[ ' . $txt['add_languages'] . ' ]</a>'; |
|
| 755 | + } else { |
|
| 756 | + $context['package']['install']['link'] = ''; |
|
| 757 | + } |
|
| 717 | 758 | |
| 718 | 759 | // Does a 3rd party hook want to do some additional changes? |
| 719 | 760 | call_integration_hook('integrate_package_upload'); |
@@ -736,16 +777,18 @@ discard block |
||
| 736 | 777 | checkSession(); |
| 737 | 778 | |
| 738 | 779 | // If they put a slash on the end, get rid of it. |
| 739 | - if (substr($_POST['serverurl'], -1) == '/') |
|
| 740 | - $_POST['serverurl'] = substr($_POST['serverurl'], 0, -1); |
|
| 780 | + if (substr($_POST['serverurl'], -1) == '/') { |
|
| 781 | + $_POST['serverurl'] = substr($_POST['serverurl'], 0, -1); |
|
| 782 | + } |
|
| 741 | 783 | |
| 742 | 784 | // Are they both nice and clean? |
| 743 | 785 | $servername = trim($smcFunc['htmlspecialchars']($_POST['servername'])); |
| 744 | 786 | $serverurl = trim($smcFunc['htmlspecialchars']($_POST['serverurl'])); |
| 745 | 787 | |
| 746 | 788 | // Make sure the URL has the correct prefix. |
| 747 | - if (strpos($serverurl, 'http://') !== 0 && strpos($serverurl, 'https://') !== 0) |
|
| 748 | - $serverurl = 'http://' . $serverurl; |
|
| 789 | + if (strpos($serverurl, 'http://') !== 0 && strpos($serverurl, 'https://') !== 0) { |
|
| 790 | + $serverurl = 'http://' . $serverurl; |
|
| 791 | + } |
|
| 749 | 792 | |
| 750 | 793 | $smcFunc['db_insert']('', |
| 751 | 794 | '{db_prefix}package_servers', |
@@ -15,8 +15,9 @@ discard block |
||
| 15 | 15 | * Original module by Mach8 - We'll never forget you. |
| 16 | 16 | */ |
| 17 | 17 | |
| 18 | -if (!defined('SMF')) |
|
| 18 | +if (!defined('SMF')) { |
|
| 19 | 19 | die('No direct access...'); |
| 20 | +} |
|
| 20 | 21 | |
| 21 | 22 | /** |
| 22 | 23 | * splits a topic into two topics. |
@@ -30,15 +31,17 @@ discard block |
||
| 30 | 31 | global $topic, $sourcedir; |
| 31 | 32 | |
| 32 | 33 | // And... which topic were you splitting, again? |
| 33 | - if (empty($topic)) |
|
| 34 | - fatal_lang_error('numbers_one_to_nine', false); |
|
| 34 | + if (empty($topic)) { |
|
| 35 | + fatal_lang_error('numbers_one_to_nine', false); |
|
| 36 | + } |
|
| 35 | 37 | |
| 36 | 38 | // Are you allowed to split topics? |
| 37 | 39 | isAllowedTo('split_any'); |
| 38 | 40 | |
| 39 | 41 | // Load up the "dependencies" - the template, getMsgMemberID(), and sendNotifications(). |
| 40 | - if (!isset($_REQUEST['xml'])) |
|
| 41 | - loadTemplate('SplitTopics'); |
|
| 42 | + if (!isset($_REQUEST['xml'])) { |
|
| 43 | + loadTemplate('SplitTopics'); |
|
| 44 | + } |
|
| 42 | 45 | require_once($sourcedir . '/Subs-Boards.php'); |
| 43 | 46 | require_once($sourcedir . '/Subs-Post.php'); |
| 44 | 47 | |
@@ -50,12 +53,12 @@ discard block |
||
| 50 | 53 | ); |
| 51 | 54 | |
| 52 | 55 | // ?action=splittopics;sa=LETSBREAKIT won't work, sorry. |
| 53 | - if (empty($_REQUEST['sa']) || !isset($subActions[$_REQUEST['sa']])) |
|
| 54 | - SplitIndex(); |
|
| 55 | - |
|
| 56 | - else |
|
| 57 | - call_helper($subActions[$_REQUEST['sa']]); |
|
| 58 | -} |
|
| 56 | + if (empty($_REQUEST['sa']) || !isset($subActions[$_REQUEST['sa']])) { |
|
| 57 | + SplitIndex(); |
|
| 58 | + } else { |
|
| 59 | + call_helper($subActions[$_REQUEST['sa']]); |
|
| 60 | + } |
|
| 61 | + } |
|
| 59 | 62 | |
| 60 | 63 | /** |
| 61 | 64 | * screen shown before the actual split. |
@@ -71,8 +74,9 @@ discard block |
||
| 71 | 74 | global $txt, $topic, $context, $smcFunc, $modSettings; |
| 72 | 75 | |
| 73 | 76 | // Validate "at". |
| 74 | - if (empty($_GET['at'])) |
|
| 75 | - fatal_lang_error('numbers_one_to_nine', false); |
|
| 77 | + if (empty($_GET['at'])) { |
|
| 78 | + fatal_lang_error('numbers_one_to_nine', false); |
|
| 79 | + } |
|
| 76 | 80 | $_GET['at'] = (int) $_GET['at']; |
| 77 | 81 | |
| 78 | 82 | // Retrieve the subject and stuff of the specific topic/message. |
@@ -89,26 +93,31 @@ discard block |
||
| 89 | 93 | 'split_at' => $_GET['at'], |
| 90 | 94 | ) |
| 91 | 95 | ); |
| 92 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 93 | - fatal_lang_error('cant_find_messages'); |
|
| 96 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 97 | + fatal_lang_error('cant_find_messages'); |
|
| 98 | + } |
|
| 94 | 99 | list ($_REQUEST['subname'], $num_replies, $unapproved_posts, $id_first_msg, $approved) = $smcFunc['db_fetch_row']($request); |
| 95 | 100 | $smcFunc['db_free_result']($request); |
| 96 | 101 | |
| 97 | 102 | // If not approved validate they can see it. |
| 98 | - if ($modSettings['postmod_active'] && !$approved) |
|
| 99 | - isAllowedTo('approve_posts'); |
|
| 103 | + if ($modSettings['postmod_active'] && !$approved) { |
|
| 104 | + isAllowedTo('approve_posts'); |
|
| 105 | + } |
|
| 100 | 106 | |
| 101 | 107 | // If this topic has unapproved posts, we need to count them too... |
| 102 | - if ($modSettings['postmod_active'] && allowedTo('approve_posts')) |
|
| 103 | - $num_replies += $unapproved_posts - ($approved ? 0 : 1); |
|
| 108 | + if ($modSettings['postmod_active'] && allowedTo('approve_posts')) { |
|
| 109 | + $num_replies += $unapproved_posts - ($approved ? 0 : 1); |
|
| 110 | + } |
|
| 104 | 111 | |
| 105 | 112 | // Check if there is more than one message in the topic. (there should be.) |
| 106 | - if ($num_replies < 1) |
|
| 107 | - fatal_lang_error('topic_one_post', false); |
|
| 113 | + if ($num_replies < 1) { |
|
| 114 | + fatal_lang_error('topic_one_post', false); |
|
| 115 | + } |
|
| 108 | 116 | |
| 109 | 117 | // Check if this is the first message in the topic (if so, the first and second option won't be available) |
| 110 | - if ($id_first_msg == $_GET['at']) |
|
| 111 | - return SplitSelectTopics(); |
|
| 118 | + if ($id_first_msg == $_GET['at']) { |
|
| 119 | + return SplitSelectTopics(); |
|
| 120 | + } |
|
| 112 | 121 | |
| 113 | 122 | // Basic template information.... |
| 114 | 123 | $context['message'] = array( |
@@ -137,8 +146,9 @@ discard block |
||
| 137 | 146 | checkSession(); |
| 138 | 147 | |
| 139 | 148 | // Clean up the subject. |
| 140 | - if (!isset($_POST['subname']) || $_POST['subname'] == '') |
|
| 141 | - $_POST['subname'] = $txt['new_topic']; |
|
| 149 | + if (!isset($_POST['subname']) || $_POST['subname'] == '') { |
|
| 150 | + $_POST['subname'] = $txt['new_topic']; |
|
| 151 | + } |
|
| 142 | 152 | |
| 143 | 153 | // Redirect to the selector if they chose selective. |
| 144 | 154 | if ($_POST['step2'] == 'selective') |
@@ -163,16 +173,19 @@ discard block |
||
| 163 | 173 | 'split_at' => $_POST['at'], |
| 164 | 174 | ) |
| 165 | 175 | ); |
| 166 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 167 | - $messagesToBeSplit[] = $row['id_msg']; |
|
| 176 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 177 | + $messagesToBeSplit[] = $row['id_msg']; |
|
| 178 | + } |
|
| 168 | 179 | $smcFunc['db_free_result']($request); |
| 169 | 180 | } |
| 170 | 181 | // Only the selected message has to be split. That should be easy. |
| 171 | - elseif ($_POST['step2'] == 'onlythis') |
|
| 172 | - $messagesToBeSplit[] = $_POST['at']; |
|
| 182 | + elseif ($_POST['step2'] == 'onlythis') { |
|
| 183 | + $messagesToBeSplit[] = $_POST['at']; |
|
| 184 | + } |
|
| 173 | 185 | // There's another action?! |
| 174 | - else |
|
| 175 | - fatal_lang_error('no_access', false); |
|
| 186 | + else { |
|
| 187 | + fatal_lang_error('no_access', false); |
|
| 188 | + } |
|
| 176 | 189 | |
| 177 | 190 | $context['old_topic'] = $topic; |
| 178 | 191 | $context['new_topic'] = splitTopic($topic, $messagesToBeSplit, $_POST['subname']); |
@@ -199,8 +212,9 @@ discard block |
||
| 199 | 212 | $_SESSION['split_selection'][$topic] = empty($_SESSION['split_selection'][$topic]) ? array() : $_SESSION['split_selection'][$topic]; |
| 200 | 213 | |
| 201 | 214 | // This is a special case for split topics from quick-moderation checkboxes |
| 202 | - if (isset($_REQUEST['subname_enc'])) |
|
| 203 | - $_REQUEST['subname'] = urldecode($_REQUEST['subname_enc']); |
|
| 215 | + if (isset($_REQUEST['subname_enc'])) { |
|
| 216 | + $_REQUEST['subname'] = urldecode($_REQUEST['subname_enc']); |
|
| 217 | + } |
|
| 204 | 218 | |
| 205 | 219 | $context['not_selected'] = array( |
| 206 | 220 | 'num_messages' => 0, |
@@ -252,10 +266,12 @@ discard block |
||
| 252 | 266 | ) |
| 253 | 267 | ); |
| 254 | 268 | // You can't split the last message off. |
| 255 | - if (empty($context['not_selected']['start']) && $smcFunc['db_num_rows']($request) <= 1 && $_REQUEST['move'] == 'down') |
|
| 256 | - $_REQUEST['move'] = ''; |
|
| 257 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 258 | - $original_msgs['not_selected'][] = $row['id_msg']; |
|
| 269 | + if (empty($context['not_selected']['start']) && $smcFunc['db_num_rows']($request) <= 1 && $_REQUEST['move'] == 'down') { |
|
| 270 | + $_REQUEST['move'] = ''; |
|
| 271 | + } |
|
| 272 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 273 | + $original_msgs['not_selected'][] = $row['id_msg']; |
|
| 274 | + } |
|
| 259 | 275 | $smcFunc['db_free_result']($request); |
| 260 | 276 | if (!empty($_SESSION['split_selection'][$topic])) |
| 261 | 277 | { |
@@ -275,8 +291,9 @@ discard block |
||
| 275 | 291 | 'messages_per_page' => $context['messages_per_page'], |
| 276 | 292 | ) |
| 277 | 293 | ); |
| 278 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 279 | - $original_msgs['selected'][] = $row['id_msg']; |
|
| 294 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 295 | + $original_msgs['selected'][] = $row['id_msg']; |
|
| 296 | + } |
|
| 280 | 297 | $smcFunc['db_free_result']($request); |
| 281 | 298 | } |
| 282 | 299 | } |
@@ -286,12 +303,13 @@ discard block |
||
| 286 | 303 | { |
| 287 | 304 | $_REQUEST['msg'] = (int) $_REQUEST['msg']; |
| 288 | 305 | |
| 289 | - if ($_REQUEST['move'] == 'reset') |
|
| 290 | - $_SESSION['split_selection'][$topic] = array(); |
|
| 291 | - elseif ($_REQUEST['move'] == 'up') |
|
| 292 | - $_SESSION['split_selection'][$topic] = array_diff($_SESSION['split_selection'][$topic], array($_REQUEST['msg'])); |
|
| 293 | - else |
|
| 294 | - $_SESSION['split_selection'][$topic][] = $_REQUEST['msg']; |
|
| 306 | + if ($_REQUEST['move'] == 'reset') { |
|
| 307 | + $_SESSION['split_selection'][$topic] = array(); |
|
| 308 | + } elseif ($_REQUEST['move'] == 'up') { |
|
| 309 | + $_SESSION['split_selection'][$topic] = array_diff($_SESSION['split_selection'][$topic], array($_REQUEST['msg'])); |
|
| 310 | + } else { |
|
| 311 | + $_SESSION['split_selection'][$topic][] = $_REQUEST['msg']; |
|
| 312 | + } |
|
| 295 | 313 | } |
| 296 | 314 | |
| 297 | 315 | // Make sure the selection is still accurate. |
@@ -310,8 +328,9 @@ discard block |
||
| 310 | 328 | ) |
| 311 | 329 | ); |
| 312 | 330 | $_SESSION['split_selection'][$topic] = array(); |
| 313 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 314 | - $_SESSION['split_selection'][$topic][] = $row['id_msg']; |
|
| 331 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 332 | + $_SESSION['split_selection'][$topic][] = $row['id_msg']; |
|
| 333 | + } |
|
| 315 | 334 | $smcFunc['db_free_result']($request); |
| 316 | 335 | } |
| 317 | 336 | |
@@ -328,13 +347,15 @@ discard block |
||
| 328 | 347 | 'is_approved' => 1, |
| 329 | 348 | ) |
| 330 | 349 | ); |
| 331 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 332 | - $context[empty($row['is_selected']) || $row['is_selected'] == 'f' ? 'not_selected' : 'selected']['num_messages'] = $row['num_messages']; |
|
| 350 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 351 | + $context[empty($row['is_selected']) || $row['is_selected'] == 'f' ? 'not_selected' : 'selected']['num_messages'] = $row['num_messages']; |
|
| 352 | + } |
|
| 333 | 353 | $smcFunc['db_free_result']($request); |
| 334 | 354 | |
| 335 | 355 | // Fix an oversized starting page (to make sure both pageindexes are properly set). |
| 336 | - if ($context['selected']['start'] >= $context['selected']['num_messages']) |
|
| 337 | - $context['selected']['start'] = $context['selected']['num_messages'] <= $context['messages_per_page'] ? 0 : ($context['selected']['num_messages'] - (($context['selected']['num_messages'] % $context['messages_per_page']) == 0 ? $context['messages_per_page'] : ($context['selected']['num_messages'] % $context['messages_per_page']))); |
|
| 356 | + if ($context['selected']['start'] >= $context['selected']['num_messages']) { |
|
| 357 | + $context['selected']['start'] = $context['selected']['num_messages'] <= $context['messages_per_page'] ? 0 : ($context['selected']['num_messages'] - (($context['selected']['num_messages'] % $context['messages_per_page']) == 0 ? $context['messages_per_page'] : ($context['selected']['num_messages'] % $context['messages_per_page']))); |
|
| 358 | + } |
|
| 338 | 359 | |
| 339 | 360 | // Build a page list of the not-selected topics... |
| 340 | 361 | $context['not_selected']['page_index'] = constructPageIndex($scripturl . '?action=splittopics;sa=selectTopics;subname=' . strtr(urlencode($_REQUEST['subname']), array('%' => '%%')) . ';topic=' . $topic . '.%1$d;start2=' . $context['selected']['start'], $context['not_selected']['start'], $context['not_selected']['num_messages'], $context['messages_per_page'], true); |
@@ -434,11 +455,12 @@ discard block |
||
| 434 | 455 | ); |
| 435 | 456 | |
| 436 | 457 | $context['changes'] = array(); |
| 437 | - foreach ($changes as $change_type => $change_array) |
|
| 438 | - foreach ($change_array as $section => $msg_array) |
|
| 458 | + foreach ($changes as $change_type => $change_array) { |
|
| 459 | + foreach ($change_array as $section => $msg_array) |
|
| 439 | 460 | { |
| 440 | 461 | if (empty($msg_array)) |
| 441 | 462 | continue; |
| 463 | + } |
|
| 442 | 464 | |
| 443 | 465 | foreach ($msg_array as $id_msg) |
| 444 | 466 | { |
@@ -447,8 +469,9 @@ discard block |
||
| 447 | 469 | 'type' => $change_type, |
| 448 | 470 | 'section' => $section, |
| 449 | 471 | ); |
| 450 | - if ($change_type == 'insert') |
|
| 451 | - $context['changes']['insert' . $id_msg]['insert_value'] = $context[$section]['messages'][$id_msg]; |
|
| 472 | + if ($change_type == 'insert') { |
|
| 473 | + $context['changes']['insert' . $id_msg]['insert_value'] = $context[$section]['messages'][$id_msg]; |
|
| 474 | + } |
|
| 452 | 475 | } |
| 453 | 476 | } |
| 454 | 477 | } |
@@ -468,12 +491,14 @@ discard block |
||
| 468 | 491 | checkSession(); |
| 469 | 492 | |
| 470 | 493 | // Default the subject in case it's blank. |
| 471 | - if (!isset($_POST['subname']) || $_POST['subname'] == '') |
|
| 472 | - $_POST['subname'] = $txt['new_topic']; |
|
| 494 | + if (!isset($_POST['subname']) || $_POST['subname'] == '') { |
|
| 495 | + $_POST['subname'] = $txt['new_topic']; |
|
| 496 | + } |
|
| 473 | 497 | |
| 474 | 498 | // You must've selected some messages! Can't split out none! |
| 475 | - if (empty($_SESSION['split_selection'][$topic])) |
|
| 476 | - fatal_lang_error('no_posts_selected', false); |
|
| 499 | + if (empty($_SESSION['split_selection'][$topic])) { |
|
| 500 | + fatal_lang_error('no_posts_selected', false); |
|
| 501 | + } |
|
| 477 | 502 | |
| 478 | 503 | $context['old_topic'] = $topic; |
| 479 | 504 | $context['new_topic'] = splitTopic($topic, $_SESSION['split_selection'][$topic], $_POST['subname']); |
@@ -499,8 +524,9 @@ discard block |
||
| 499 | 524 | global $smcFunc, $txt, $sourcedir; |
| 500 | 525 | |
| 501 | 526 | // Nothing to split? |
| 502 | - if (empty($splitMessages)) |
|
| 503 | - fatal_lang_error('no_posts_selected', false); |
|
| 527 | + if (empty($splitMessages)) { |
|
| 528 | + fatal_lang_error('no_posts_selected', false); |
|
| 529 | + } |
|
| 504 | 530 | |
| 505 | 531 | // Get some board info. |
| 506 | 532 | $request = $smcFunc['db_query']('', ' |
@@ -532,8 +558,9 @@ discard block |
||
| 532 | 558 | ) |
| 533 | 559 | ); |
| 534 | 560 | // You can't select ALL the messages! |
| 535 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 536 | - fatal_lang_error('selected_all_posts', false); |
|
| 561 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 562 | + fatal_lang_error('selected_all_posts', false); |
|
| 563 | + } |
|
| 537 | 564 | |
| 538 | 565 | $split1_first_msg = null; |
| 539 | 566 | $split1_last_msg = null; |
@@ -541,24 +568,27 @@ discard block |
||
| 541 | 568 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 542 | 569 | { |
| 543 | 570 | // Get the right first and last message dependant on approved state... |
| 544 | - if (empty($split1_first_msg) || $row['myid_first_msg'] < $split1_first_msg) |
|
| 545 | - $split1_first_msg = $row['myid_first_msg']; |
|
| 546 | - if (empty($split1_last_msg) || $row['approved']) |
|
| 547 | - $split1_last_msg = $row['myid_last_msg']; |
|
| 571 | + if (empty($split1_first_msg) || $row['myid_first_msg'] < $split1_first_msg) { |
|
| 572 | + $split1_first_msg = $row['myid_first_msg']; |
|
| 573 | + } |
|
| 574 | + if (empty($split1_last_msg) || $row['approved']) { |
|
| 575 | + $split1_last_msg = $row['myid_last_msg']; |
|
| 576 | + } |
|
| 548 | 577 | |
| 549 | 578 | // Get the counts correct... |
| 550 | 579 | if ($row['approved']) |
| 551 | 580 | { |
| 552 | 581 | $split1_replies = $row['message_count'] - 1; |
| 553 | 582 | $split1_unapprovedposts = 0; |
| 554 | - } |
|
| 555 | - else |
|
| 583 | + } else |
|
| 556 | 584 | { |
| 557 | - if (!isset($split1_replies)) |
|
| 558 | - $split1_replies = 0; |
|
| 585 | + if (!isset($split1_replies)) { |
|
| 586 | + $split1_replies = 0; |
|
| 587 | + } |
|
| 559 | 588 | // If the topic isn't approved then num replies must go up by one... as first post wouldn't be counted. |
| 560 | - elseif (!$split1_approved) |
|
| 561 | - $split1_replies++; |
|
| 589 | + elseif (!$split1_approved) { |
|
| 590 | + $split1_replies++; |
|
| 591 | + } |
|
| 562 | 592 | |
| 563 | 593 | $split1_unapprovedposts = $row['message_count']; |
| 564 | 594 | } |
@@ -584,10 +614,12 @@ discard block |
||
| 584 | 614 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 585 | 615 | { |
| 586 | 616 | // As before get the right first and last message dependant on approved state... |
| 587 | - if (empty($split2_first_msg) || $row['myid_first_msg'] < $split2_first_msg) |
|
| 588 | - $split2_first_msg = $row['myid_first_msg']; |
|
| 589 | - if (empty($split2_last_msg) || $row['approved']) |
|
| 590 | - $split2_last_msg = $row['myid_last_msg']; |
|
| 617 | + if (empty($split2_first_msg) || $row['myid_first_msg'] < $split2_first_msg) { |
|
| 618 | + $split2_first_msg = $row['myid_first_msg']; |
|
| 619 | + } |
|
| 620 | + if (empty($split2_last_msg) || $row['approved']) { |
|
| 621 | + $split2_last_msg = $row['myid_last_msg']; |
|
| 622 | + } |
|
| 591 | 623 | |
| 592 | 624 | // Then do the counts again... |
| 593 | 625 | if ($row['approved']) |
@@ -595,18 +627,20 @@ discard block |
||
| 595 | 627 | $split2_approved = true; |
| 596 | 628 | $split2_replies = $row['message_count'] - 1; |
| 597 | 629 | $split2_unapprovedposts = 0; |
| 598 | - } |
|
| 599 | - else |
|
| 630 | + } else |
|
| 600 | 631 | { |
| 601 | 632 | // Should this one be approved?? |
| 602 | - if ($split2_first_msg == $row['myid_first_msg']) |
|
| 603 | - $split2_approved = false; |
|
| 633 | + if ($split2_first_msg == $row['myid_first_msg']) { |
|
| 634 | + $split2_approved = false; |
|
| 635 | + } |
|
| 604 | 636 | |
| 605 | - if (!isset($split2_replies)) |
|
| 606 | - $split2_replies = 0; |
|
| 637 | + if (!isset($split2_replies)) { |
|
| 638 | + $split2_replies = 0; |
|
| 639 | + } |
|
| 607 | 640 | // As before, fix number of replies. |
| 608 | - elseif (!$split2_approved) |
|
| 609 | - $split2_replies++; |
|
| 641 | + elseif (!$split2_approved) { |
|
| 642 | + $split2_replies++; |
|
| 643 | + } |
|
| 610 | 644 | |
| 611 | 645 | $split2_unapprovedposts = $row['message_count']; |
| 612 | 646 | } |
@@ -616,12 +650,14 @@ discard block |
||
| 616 | 650 | $split2_lastMem = getMsgMemberID($split2_last_msg); |
| 617 | 651 | |
| 618 | 652 | // No database changes yet, so let's double check to see if everything makes at least a little sense. |
| 619 | - if ($split1_first_msg <= 0 || $split1_last_msg <= 0 || $split2_first_msg <= 0 || $split2_last_msg <= 0 || $split1_replies < 0 || $split2_replies < 0 || $split1_unapprovedposts < 0 || $split2_unapprovedposts < 0 || !isset($split1_approved) || !isset($split2_approved)) |
|
| 620 | - fatal_lang_error('cant_find_messages'); |
|
| 653 | + if ($split1_first_msg <= 0 || $split1_last_msg <= 0 || $split2_first_msg <= 0 || $split2_last_msg <= 0 || $split1_replies < 0 || $split2_replies < 0 || $split1_unapprovedposts < 0 || $split2_unapprovedposts < 0 || !isset($split1_approved) || !isset($split2_approved)) { |
|
| 654 | + fatal_lang_error('cant_find_messages'); |
|
| 655 | + } |
|
| 621 | 656 | |
| 622 | 657 | // You cannot split off the first message of a topic. |
| 623 | - if ($split1_first_msg > $split2_first_msg) |
|
| 624 | - fatal_lang_error('split_first_post', false); |
|
| 658 | + if ($split1_first_msg > $split2_first_msg) { |
|
| 659 | + fatal_lang_error('split_first_post', false); |
|
| 660 | + } |
|
| 625 | 661 | |
| 626 | 662 | // We're off to insert the new topic! Use 0 for now to avoid UNIQUE errors. |
| 627 | 663 | $smcFunc['db_insert']('', |
@@ -644,14 +680,16 @@ discard block |
||
| 644 | 680 | array('id_topic') |
| 645 | 681 | ); |
| 646 | 682 | $split2_ID_TOPIC = $smcFunc['db_insert_id']('{db_prefix}topics', 'id_topic'); |
| 647 | - if ($split2_ID_TOPIC <= 0) |
|
| 648 | - fatal_lang_error('cant_insert_topic'); |
|
| 683 | + if ($split2_ID_TOPIC <= 0) { |
|
| 684 | + fatal_lang_error('cant_insert_topic'); |
|
| 685 | + } |
|
| 649 | 686 | |
| 650 | 687 | // Move the messages over to the other topic. |
| 651 | 688 | $new_subject = strtr($smcFunc['htmltrim']($smcFunc['htmlspecialchars']($new_subject)), array("\r" => '', "\n" => '', "\t" => '')); |
| 652 | 689 | // Check the subject length. |
| 653 | - if ($smcFunc['strlen']($new_subject) > 100) |
|
| 654 | - $new_subject = $smcFunc['substr']($new_subject, 0, 100); |
|
| 690 | + if ($smcFunc['strlen']($new_subject) > 100) { |
|
| 691 | + $new_subject = $smcFunc['substr']($new_subject, 0, 100); |
|
| 692 | + } |
|
| 655 | 693 | // Valid subject? |
| 656 | 694 | if ($new_subject != '') |
| 657 | 695 | { |
@@ -722,8 +760,8 @@ discard block |
||
| 722 | 760 | ); |
| 723 | 761 | |
| 724 | 762 | // If the new topic isn't approved ensure the first message flags this just in case. |
| 725 | - if (!$split2_approved) |
|
| 726 | - $smcFunc['db_query']('', ' |
|
| 763 | + if (!$split2_approved) { |
|
| 764 | + $smcFunc['db_query']('', ' |
|
| 727 | 765 | UPDATE {db_prefix}messages |
| 728 | 766 | SET approved = {int:approved} |
| 729 | 767 | WHERE id_msg = {int:id_msg} |
@@ -734,6 +772,7 @@ discard block |
||
| 734 | 772 | 'id_topic' => $split2_ID_TOPIC, |
| 735 | 773 | ) |
| 736 | 774 | ); |
| 775 | + } |
|
| 737 | 776 | |
| 738 | 777 | // The board has more topics now (Or more unapproved ones!). |
| 739 | 778 | $smcFunc['db_query']('', ' |
@@ -760,8 +799,9 @@ discard block |
||
| 760 | 799 | if ($smcFunc['db_num_rows']($request) > 0) |
| 761 | 800 | { |
| 762 | 801 | $replaceEntries = array(); |
| 763 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 764 | - $replaceEntries[] = array($row['id_member'], $split2_ID_TOPIC, $row['id_msg'], $row['unwatched']); |
|
| 802 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 803 | + $replaceEntries[] = array($row['id_member'], $split2_ID_TOPIC, $row['id_msg'], $row['unwatched']); |
|
| 804 | + } |
|
| 765 | 805 | |
| 766 | 806 | $smcFunc['db_insert']('ignore', |
| 767 | 807 | '{db_prefix}log_topics', |
@@ -785,8 +825,9 @@ discard block |
||
| 785 | 825 | // If there's a search index that needs updating, update it... |
| 786 | 826 | require_once($sourcedir . '/Search.php'); |
| 787 | 827 | $searchAPI = findSearchAPI(); |
| 788 | - if (is_callable(array($searchAPI, 'topicSplit'))) |
|
| 789 | - $searchAPI->topicSplit($split2_ID_TOPIC, $splitMessages); |
|
| 828 | + if (is_callable(array($searchAPI, 'topicSplit'))) { |
|
| 829 | + $searchAPI->topicSplit($split2_ID_TOPIC, $splitMessages); |
|
| 830 | + } |
|
| 790 | 831 | |
| 791 | 832 | // Return the ID of the newly created topic. |
| 792 | 833 | return $split2_ID_TOPIC; |
@@ -812,12 +853,12 @@ discard block |
||
| 812 | 853 | ); |
| 813 | 854 | |
| 814 | 855 | // ?action=mergetopics;sa=LETSBREAKIT won't work, sorry. |
| 815 | - if (empty($_REQUEST['sa']) || !isset($subActions[$_REQUEST['sa']])) |
|
| 816 | - MergeIndex(); |
|
| 817 | - |
|
| 818 | - else |
|
| 819 | - call_helper($subActions[$_REQUEST['sa']]); |
|
| 820 | -} |
|
| 856 | + if (empty($_REQUEST['sa']) || !isset($subActions[$_REQUEST['sa']])) { |
|
| 857 | + MergeIndex(); |
|
| 858 | + } else { |
|
| 859 | + call_helper($subActions[$_REQUEST['sa']]); |
|
| 860 | + } |
|
| 861 | + } |
|
| 821 | 862 | |
| 822 | 863 | /** |
| 823 | 864 | * allows to pick a topic to merge the current topic with. |
@@ -831,8 +872,9 @@ discard block |
||
| 831 | 872 | global $txt, $board, $context, $smcFunc, $sourcedir; |
| 832 | 873 | global $scripturl, $modSettings; |
| 833 | 874 | |
| 834 | - if (!isset($_GET['from'])) |
|
| 835 | - fatal_lang_error('no_access', false); |
|
| 875 | + if (!isset($_GET['from'])) { |
|
| 876 | + fatal_lang_error('no_access', false); |
|
| 877 | + } |
|
| 836 | 878 | $_GET['from'] = (int) $_GET['from']; |
| 837 | 879 | |
| 838 | 880 | $_REQUEST['targetboard'] = isset($_REQUEST['targetboard']) ? (int) $_REQUEST['targetboard'] : $board; |
@@ -843,9 +885,9 @@ discard block |
||
| 843 | 885 | { |
| 844 | 886 | $can_approve_boards = boardsAllowedTo('approve_posts'); |
| 845 | 887 | $onlyApproved = $can_approve_boards !== array(0) && !in_array($_REQUEST['targetboard'], $can_approve_boards); |
| 888 | + } else { |
|
| 889 | + $onlyApproved = false; |
|
| 846 | 890 | } |
| 847 | - else |
|
| 848 | - $onlyApproved = false; |
|
| 849 | 891 | |
| 850 | 892 | // How many topics are on this board? (used for paging.) |
| 851 | 893 | $request = $smcFunc['db_query']('', ' |
@@ -879,8 +921,9 @@ discard block |
||
| 879 | 921 | 'is_approved' => 1, |
| 880 | 922 | ) |
| 881 | 923 | ); |
| 882 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 883 | - fatal_lang_error('no_board'); |
|
| 924 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 925 | + fatal_lang_error('no_board'); |
|
| 926 | + } |
|
| 884 | 927 | list ($subject) = $smcFunc['db_fetch_row']($request); |
| 885 | 928 | $smcFunc['db_free_result']($request); |
| 886 | 929 | |
@@ -893,8 +936,9 @@ discard block |
||
| 893 | 936 | // Check which boards you have merge permissions on. |
| 894 | 937 | $merge_boards = boardsAllowedTo('merge_any'); |
| 895 | 938 | |
| 896 | - if (empty($merge_boards)) |
|
| 897 | - fatal_lang_error('cannot_merge_any', 'user'); |
|
| 939 | + if (empty($merge_boards)) { |
|
| 940 | + fatal_lang_error('cannot_merge_any', 'user'); |
|
| 941 | + } |
|
| 898 | 942 | |
| 899 | 943 | // No sense in loading this if you can only merge on this board |
| 900 | 944 | if (count($merge_boards) > 1 || in_array(0, $merge_boards)) |
@@ -908,8 +952,9 @@ discard block |
||
| 908 | 952 | ); |
| 909 | 953 | |
| 910 | 954 | // Only include these boards in the list (0 means you're an admin') |
| 911 | - if (!in_array(0, $merge_boards)) |
|
| 912 | - $options['included_boards'] = $merge_boards; |
|
| 955 | + if (!in_array(0, $merge_boards)) { |
|
| 956 | + $options['included_boards'] = $merge_boards; |
|
| 957 | + } |
|
| 913 | 958 | |
| 914 | 959 | $context['merge_categories'] = getBoardList($options); |
| 915 | 960 | } |
@@ -955,8 +1000,9 @@ discard block |
||
| 955 | 1000 | } |
| 956 | 1001 | $smcFunc['db_free_result']($request); |
| 957 | 1002 | |
| 958 | - if (empty($context['topics']) && count($merge_boards) <= 1 && !in_array(0, $merge_boards)) |
|
| 959 | - fatal_lang_error('merge_need_more_topics'); |
|
| 1003 | + if (empty($context['topics']) && count($merge_boards) <= 1 && !in_array(0, $merge_boards)) { |
|
| 1004 | + fatal_lang_error('merge_need_more_topics'); |
|
| 1005 | + } |
|
| 960 | 1006 | |
| 961 | 1007 | $context['sub_template'] = 'merge'; |
| 962 | 1008 | } |
@@ -986,24 +1032,29 @@ discard block |
||
| 986 | 1032 | checkSession('request'); |
| 987 | 1033 | |
| 988 | 1034 | // Handle URLs from MergeIndex. |
| 989 | - if (!empty($_GET['from']) && !empty($_GET['to'])) |
|
| 990 | - $topics = array((int) $_GET['from'], (int) $_GET['to']); |
|
| 1035 | + if (!empty($_GET['from']) && !empty($_GET['to'])) { |
|
| 1036 | + $topics = array((int) $_GET['from'], (int) $_GET['to']); |
|
| 1037 | + } |
|
| 991 | 1038 | |
| 992 | 1039 | // If we came from a form, the topic IDs came by post. |
| 993 | - if (!empty($_POST['topics']) && is_array($_POST['topics'])) |
|
| 994 | - $topics = $_POST['topics']; |
|
| 1040 | + if (!empty($_POST['topics']) && is_array($_POST['topics'])) { |
|
| 1041 | + $topics = $_POST['topics']; |
|
| 1042 | + } |
|
| 995 | 1043 | |
| 996 | 1044 | // There's nothing to merge with just one topic... |
| 997 | - if (empty($topics) || !is_array($topics) || count($topics) == 1) |
|
| 998 | - fatal_lang_error('merge_need_more_topics'); |
|
| 1045 | + if (empty($topics) || !is_array($topics) || count($topics) == 1) { |
|
| 1046 | + fatal_lang_error('merge_need_more_topics'); |
|
| 1047 | + } |
|
| 999 | 1048 | |
| 1000 | 1049 | // Make sure every topic is numeric, or some nasty things could be done with the DB. |
| 1001 | - foreach ($topics as $id => $topic) |
|
| 1002 | - $topics[$id] = (int) $topic; |
|
| 1050 | + foreach ($topics as $id => $topic) { |
|
| 1051 | + $topics[$id] = (int) $topic; |
|
| 1052 | + } |
|
| 1003 | 1053 | |
| 1004 | 1054 | // Joy of all joys, make sure they're not messing about with unapproved topics they can't see :P |
| 1005 | - if ($modSettings['postmod_active']) |
|
| 1006 | - $can_approve_boards = boardsAllowedTo('approve_posts'); |
|
| 1055 | + if ($modSettings['postmod_active']) { |
|
| 1056 | + $can_approve_boards = boardsAllowedTo('approve_posts'); |
|
| 1057 | + } |
|
| 1007 | 1058 | |
| 1008 | 1059 | // Get info about the topics and polls that will be merged. |
| 1009 | 1060 | $request = $smcFunc['db_query']('', ' |
@@ -1024,8 +1075,9 @@ discard block |
||
| 1024 | 1075 | 'limit' => count($topics), |
| 1025 | 1076 | ) |
| 1026 | 1077 | ); |
| 1027 | - if ($smcFunc['db_num_rows']($request) < 2) |
|
| 1028 | - fatal_lang_error('no_topic_id'); |
|
| 1078 | + if ($smcFunc['db_num_rows']($request) < 2) { |
|
| 1079 | + fatal_lang_error('no_topic_id'); |
|
| 1080 | + } |
|
| 1029 | 1081 | $num_views = 0; |
| 1030 | 1082 | $is_sticky = 0; |
| 1031 | 1083 | $boardTotals = array(); |
@@ -1038,34 +1090,38 @@ discard block |
||
| 1038 | 1090 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1039 | 1091 | { |
| 1040 | 1092 | // Sorry, redirection topics can't be merged |
| 1041 | - if (!empty($row['id_redirect_topic'])) |
|
| 1042 | - fatal_lang_error('cannot_merge_redirect', false); |
|
| 1093 | + if (!empty($row['id_redirect_topic'])) { |
|
| 1094 | + fatal_lang_error('cannot_merge_redirect', false); |
|
| 1095 | + } |
|
| 1043 | 1096 | |
| 1044 | 1097 | // Make a note for the board counts... |
| 1045 | - if (!isset($boardTotals[$row['id_board']])) |
|
| 1046 | - $boardTotals[$row['id_board']] = array( |
|
| 1098 | + if (!isset($boardTotals[$row['id_board']])) { |
|
| 1099 | + $boardTotals[$row['id_board']] = array( |
|
| 1047 | 1100 | 'posts' => 0, |
| 1048 | 1101 | 'topics' => 0, |
| 1049 | 1102 | 'unapproved_posts' => 0, |
| 1050 | 1103 | 'unapproved_topics' => 0 |
| 1051 | 1104 | ); |
| 1105 | + } |
|
| 1052 | 1106 | |
| 1053 | 1107 | // We can't see unapproved topics here? |
| 1054 | 1108 | if ($modSettings['postmod_active'] && !$row['approved'] && $can_approve_boards != array(0) && in_array($row['id_board'], $can_approve_boards)) |
| 1055 | 1109 | { |
| 1056 | 1110 | unset($topics[$row['id_topic']]); // If we can't see it, we should not merge it and not adjust counts! Instead skip it. |
| 1057 | 1111 | continue; |
| 1058 | - }elseif (!$row['approved']) |
|
| 1059 | - $boardTotals[$row['id_board']]['unapproved_topics']++; |
|
| 1060 | - else |
|
| 1061 | - $boardTotals[$row['id_board']]['topics']++; |
|
| 1112 | + } elseif (!$row['approved']) { |
|
| 1113 | + $boardTotals[$row['id_board']]['unapproved_topics']++; |
|
| 1114 | + } else { |
|
| 1115 | + $boardTotals[$row['id_board']]['topics']++; |
|
| 1116 | + } |
|
| 1062 | 1117 | |
| 1063 | 1118 | $boardTotals[$row['id_board']]['unapproved_posts'] += $row['unapproved_posts']; |
| 1064 | 1119 | $boardTotals[$row['id_board']]['posts'] += $row['num_replies'] + ($row['approved'] ? 1 : 0); |
| 1065 | 1120 | |
| 1066 | 1121 | // In the case of making a redirect, the topic count goes up by one due to the redirect topic. |
| 1067 | - if (isset($_POST['postRedirect'])) |
|
| 1068 | - $boardTotals[$row['id_board']]['topics']--; |
|
| 1122 | + if (isset($_POST['postRedirect'])) { |
|
| 1123 | + $boardTotals[$row['id_board']]['topics']--; |
|
| 1124 | + } |
|
| 1069 | 1125 | |
| 1070 | 1126 | $topic_data[$row['id_topic']] = array( |
| 1071 | 1127 | 'id' => $row['id_topic'], |
@@ -1091,11 +1147,13 @@ discard block |
||
| 1091 | 1147 | $boards[] = $row['id_board']; |
| 1092 | 1148 | |
| 1093 | 1149 | // If there's no poll, id_poll == 0... |
| 1094 | - if ($row['id_poll'] > 0) |
|
| 1095 | - $polls[] = $row['id_poll']; |
|
| 1150 | + if ($row['id_poll'] > 0) { |
|
| 1151 | + $polls[] = $row['id_poll']; |
|
| 1152 | + } |
|
| 1096 | 1153 | // Store the id_topic with the lowest id_first_msg. |
| 1097 | - if (empty($firstTopic)) |
|
| 1098 | - $firstTopic = $row['id_topic']; |
|
| 1154 | + if (empty($firstTopic)) { |
|
| 1155 | + $firstTopic = $row['id_topic']; |
|
| 1156 | + } |
|
| 1099 | 1157 | |
| 1100 | 1158 | // Lowest topic id gets selected as surviving topic id. We need to store this board so we can adjust the topic count (This one will not have a redirect topic) |
| 1101 | 1159 | if($row['id_topic'] < $lowestTopicId || empty($lowestTopicId) ) |
@@ -1109,11 +1167,13 @@ discard block |
||
| 1109 | 1167 | $smcFunc['db_free_result']($request); |
| 1110 | 1168 | |
| 1111 | 1169 | // If we didn't get any topics then they've been messing with unapproved stuff. |
| 1112 | - if (empty($topic_data)) |
|
| 1113 | - fatal_lang_error('no_topic_id'); |
|
| 1170 | + if (empty($topic_data)) { |
|
| 1171 | + fatal_lang_error('no_topic_id'); |
|
| 1172 | + } |
|
| 1114 | 1173 | |
| 1115 | - if (isset($_POST['postRedirect']) && !empty($lowestTopicBoard)) |
|
| 1116 | - $boardTotals[$lowestTopicBoard]['topics']++; |
|
| 1174 | + if (isset($_POST['postRedirect']) && !empty($lowestTopicBoard)) { |
|
| 1175 | + $boardTotals[$lowestTopicBoard]['topics']++; |
|
| 1176 | + } |
|
| 1117 | 1177 | |
| 1118 | 1178 | // Will this be approved? |
| 1119 | 1179 | $context['is_approved'] = $topic_data[$firstTopic]['approved']; |
@@ -1129,8 +1189,9 @@ discard block |
||
| 1129 | 1189 | |
| 1130 | 1190 | // Get the boards a user is allowed to merge in. |
| 1131 | 1191 | $merge_boards = boardsAllowedTo('merge_any'); |
| 1132 | - if (empty($merge_boards)) |
|
| 1133 | - fatal_lang_error('cannot_merge_any', 'user'); |
|
| 1192 | + if (empty($merge_boards)) { |
|
| 1193 | + fatal_lang_error('cannot_merge_any', 'user'); |
|
| 1194 | + } |
|
| 1134 | 1195 | |
| 1135 | 1196 | // Make sure they can see all boards.... |
| 1136 | 1197 | $request = $smcFunc['db_query']('', ' |
@@ -1147,8 +1208,9 @@ discard block |
||
| 1147 | 1208 | ) |
| 1148 | 1209 | ); |
| 1149 | 1210 | // If the number of boards that's in the output isn't exactly the same as we've put in there, you're in trouble. |
| 1150 | - if ($smcFunc['db_num_rows']($request) != count($boards)) |
|
| 1151 | - fatal_lang_error('no_board'); |
|
| 1211 | + if ($smcFunc['db_num_rows']($request) != count($boards)) { |
|
| 1212 | + fatal_lang_error('no_board'); |
|
| 1213 | + } |
|
| 1152 | 1214 | $smcFunc['db_free_result']($request); |
| 1153 | 1215 | |
| 1154 | 1216 | if (empty($_REQUEST['sa']) || $_REQUEST['sa'] == 'options') |
@@ -1167,8 +1229,8 @@ discard block |
||
| 1167 | 1229 | 'limit' => count($polls), |
| 1168 | 1230 | ) |
| 1169 | 1231 | ); |
| 1170 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1171 | - $context['polls'][] = array( |
|
| 1232 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1233 | + $context['polls'][] = array( |
|
| 1172 | 1234 | 'id' => $row['id_poll'], |
| 1173 | 1235 | 'topic' => array( |
| 1174 | 1236 | 'id' => $row['id_topic'], |
@@ -1177,6 +1239,7 @@ discard block |
||
| 1177 | 1239 | 'question' => $row['question'], |
| 1178 | 1240 | 'selected' => $row['id_topic'] == $firstTopic |
| 1179 | 1241 | ); |
| 1242 | + } |
|
| 1180 | 1243 | $smcFunc['db_free_result']($request); |
| 1181 | 1244 | } |
| 1182 | 1245 | if (count($boards) > 1) |
@@ -1192,18 +1255,20 @@ discard block |
||
| 1192 | 1255 | 'limit' => count($boards), |
| 1193 | 1256 | ) |
| 1194 | 1257 | ); |
| 1195 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1196 | - $context['boards'][] = array( |
|
| 1258 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1259 | + $context['boards'][] = array( |
|
| 1197 | 1260 | 'id' => $row['id_board'], |
| 1198 | 1261 | 'name' => $row['name'], |
| 1199 | 1262 | 'selected' => $row['id_board'] == $topic_data[$firstTopic]['board'] |
| 1200 | 1263 | ); |
| 1264 | + } |
|
| 1201 | 1265 | $smcFunc['db_free_result']($request); |
| 1202 | 1266 | } |
| 1203 | 1267 | |
| 1204 | 1268 | $context['topics'] = $topic_data; |
| 1205 | - foreach ($topic_data as $id => $topic) |
|
| 1206 | - $context['topics'][$id]['selected'] = $topic['id'] == $firstTopic; |
|
| 1269 | + foreach ($topic_data as $id => $topic) { |
|
| 1270 | + $context['topics'][$id]['selected'] = $topic['id'] == $firstTopic; |
|
| 1271 | + } |
|
| 1207 | 1272 | |
| 1208 | 1273 | $context['page_title'] = $txt['merge']; |
| 1209 | 1274 | $context['sub_template'] = 'merge_extra_options'; |
@@ -1212,13 +1277,15 @@ discard block |
||
| 1212 | 1277 | |
| 1213 | 1278 | // Determine target board. |
| 1214 | 1279 | $target_board = count($boards) > 1 ? (int) $_REQUEST['board'] : $boards[0]; |
| 1215 | - if (!in_array($target_board, $boards)) |
|
| 1216 | - fatal_lang_error('no_board'); |
|
| 1280 | + if (!in_array($target_board, $boards)) { |
|
| 1281 | + fatal_lang_error('no_board'); |
|
| 1282 | + } |
|
| 1217 | 1283 | |
| 1218 | 1284 | // Determine which poll will survive and which polls won't. |
| 1219 | 1285 | $target_poll = count($polls) > 1 ? (int) $_POST['poll'] : (count($polls) == 1 ? $polls[0] : 0); |
| 1220 | - if ($target_poll > 0 && !in_array($target_poll, $polls)) |
|
| 1221 | - fatal_lang_error('no_access', false); |
|
| 1286 | + if ($target_poll > 0 && !in_array($target_poll, $polls)) { |
|
| 1287 | + fatal_lang_error('no_access', false); |
|
| 1288 | + } |
|
| 1222 | 1289 | $deleted_polls = empty($target_poll) ? $polls : array_diff($polls, array($target_poll)); |
| 1223 | 1290 | |
| 1224 | 1291 | // Determine the subject of the newly merged topic - was a custom subject specified? |
@@ -1226,19 +1293,23 @@ discard block |
||
| 1226 | 1293 | { |
| 1227 | 1294 | $target_subject = strtr($smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['custom_subject'])), array("\r" => '', "\n" => '', "\t" => '')); |
| 1228 | 1295 | // Keep checking the length. |
| 1229 | - if ($smcFunc['strlen']($target_subject) > 100) |
|
| 1230 | - $target_subject = $smcFunc['substr']($target_subject, 0, 100); |
|
| 1296 | + if ($smcFunc['strlen']($target_subject) > 100) { |
|
| 1297 | + $target_subject = $smcFunc['substr']($target_subject, 0, 100); |
|
| 1298 | + } |
|
| 1231 | 1299 | |
| 1232 | 1300 | // Nothing left - odd but pick the first topics subject. |
| 1233 | - if ($target_subject == '') |
|
| 1234 | - $target_subject = $topic_data[$firstTopic]['subject']; |
|
| 1301 | + if ($target_subject == '') { |
|
| 1302 | + $target_subject = $topic_data[$firstTopic]['subject']; |
|
| 1303 | + } |
|
| 1235 | 1304 | } |
| 1236 | 1305 | // A subject was selected from the list. |
| 1237 | - elseif (!empty($topic_data[(int) $_POST['subject']]['subject'])) |
|
| 1238 | - $target_subject = $topic_data[(int) $_POST['subject']]['subject']; |
|
| 1306 | + elseif (!empty($topic_data[(int) $_POST['subject']]['subject'])) { |
|
| 1307 | + $target_subject = $topic_data[(int) $_POST['subject']]['subject']; |
|
| 1308 | + } |
|
| 1239 | 1309 | // Nothing worked? Just take the subject of the first message. |
| 1240 | - else |
|
| 1241 | - $target_subject = $topic_data[$firstTopic]['subject']; |
|
| 1310 | + else { |
|
| 1311 | + $target_subject = $topic_data[$firstTopic]['subject']; |
|
| 1312 | + } |
|
| 1242 | 1313 | |
| 1243 | 1314 | // Get the first and last message and the number of messages.... |
| 1244 | 1315 | $request = $smcFunc['db_query']('', ' |
@@ -1264,15 +1335,13 @@ discard block |
||
| 1264 | 1335 | { |
| 1265 | 1336 | $num_replies = $row['message_count'] - 1; |
| 1266 | 1337 | $num_unapproved = 0; |
| 1267 | - } |
|
| 1268 | - else |
|
| 1338 | + } else |
|
| 1269 | 1339 | { |
| 1270 | 1340 | $topic_approved = 0; |
| 1271 | 1341 | $num_replies = 0; |
| 1272 | 1342 | $num_unapproved = $row['message_count']; |
| 1273 | 1343 | } |
| 1274 | - } |
|
| 1275 | - else |
|
| 1344 | + } else |
|
| 1276 | 1345 | { |
| 1277 | 1346 | // If this has a lower first_msg then the first post is not approved and hence the number of replies was wrong! |
| 1278 | 1347 | if ($first_msg > $row['first_msg']) |
@@ -1318,8 +1387,9 @@ discard block |
||
| 1318 | 1387 | list ($member_started) = $smcFunc['db_fetch_row']($request); |
| 1319 | 1388 | list ($member_updated) = $smcFunc['db_fetch_row']($request); |
| 1320 | 1389 | // First and last message are the same, so only row was returned. |
| 1321 | - if ($member_updated === NULL) |
|
| 1322 | - $member_updated = $member_started; |
|
| 1390 | + if ($member_updated === NULL) { |
|
| 1391 | + $member_updated = $member_started; |
|
| 1392 | + } |
|
| 1323 | 1393 | |
| 1324 | 1394 | $smcFunc['db_free_result']($request); |
| 1325 | 1395 | |
@@ -1332,8 +1402,9 @@ discard block |
||
| 1332 | 1402 | array( |
| 1333 | 1403 | 'topic_list' => $topics, |
| 1334 | 1404 | )); |
| 1335 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
| 1336 | - $affected_msgs[] = $row[0]; |
|
| 1405 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
| 1406 | + $affected_msgs[] = $row[0]; |
|
| 1407 | + } |
|
| 1337 | 1408 | $smcFunc['db_free_result']($request); |
| 1338 | 1409 | |
| 1339 | 1410 | // Assign the first topic ID to be the merged topic. |
@@ -1411,9 +1482,9 @@ discard block |
||
| 1411 | 1482 | // Grab the response prefix (like 'Re: ') in the default forum language. |
| 1412 | 1483 | if (!isset($context['response_prefix']) && !($context['response_prefix'] = cache_get_data('response_prefix'))) |
| 1413 | 1484 | { |
| 1414 | - if ($language === $user_info['language']) |
|
| 1415 | - $context['response_prefix'] = $txt['response_prefix']; |
|
| 1416 | - else |
|
| 1485 | + if ($language === $user_info['language']) { |
|
| 1486 | + $context['response_prefix'] = $txt['response_prefix']; |
|
| 1487 | + } else |
|
| 1417 | 1488 | { |
| 1418 | 1489 | loadLanguage('index', $language, false); |
| 1419 | 1490 | $context['response_prefix'] = $txt['response_prefix']; |
@@ -1493,8 +1564,9 @@ discard block |
||
| 1493 | 1564 | if ($smcFunc['db_num_rows']($request) > 0) |
| 1494 | 1565 | { |
| 1495 | 1566 | $replaceEntries = array(); |
| 1496 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1497 | - $replaceEntries[] = array($row['id_member'], $id_topic, $row['new_id_msg'], $row['unwatched']); |
|
| 1567 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1568 | + $replaceEntries[] = array($row['id_member'], $id_topic, $row['new_id_msg'], $row['unwatched']); |
|
| 1569 | + } |
|
| 1498 | 1570 | |
| 1499 | 1571 | $smcFunc['db_insert']('replace', |
| 1500 | 1572 | '{db_prefix}log_topics', |
@@ -1531,8 +1603,9 @@ discard block |
||
| 1531 | 1603 | if ($smcFunc['db_num_rows']($request) > 0) |
| 1532 | 1604 | { |
| 1533 | 1605 | $replaceEntries = array(); |
| 1534 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1535 | - $replaceEntries[] = array($row['id_member'], $id_topic, 0, $row['sent']); |
|
| 1606 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1607 | + $replaceEntries[] = array($row['id_member'], $id_topic, 0, $row['sent']); |
|
| 1608 | + } |
|
| 1536 | 1609 | |
| 1537 | 1610 | $smcFunc['db_insert']('replace', |
| 1538 | 1611 | '{db_prefix}log_notify', |
@@ -1707,8 +1780,9 @@ discard block |
||
| 1707 | 1780 | // If there's a search index that needs updating, update it... |
| 1708 | 1781 | require_once($sourcedir . '/Search.php'); |
| 1709 | 1782 | $searchAPI = findSearchAPI(); |
| 1710 | - if (is_callable(array($searchAPI, 'topicMerge'))) |
|
| 1711 | - $searchAPI->topicMerge($id_topic, $topics, $affected_msgs, empty($_POST['enforce_subject']) ? null : array($context['response_prefix'], $target_subject)); |
|
| 1783 | + if (is_callable(array($searchAPI, 'topicMerge'))) { |
|
| 1784 | + $searchAPI->topicMerge($id_topic, $topics, $affected_msgs, empty($_POST['enforce_subject']) ? null : array($context['response_prefix'], $target_subject)); |
|
| 1785 | + } |
|
| 1712 | 1786 | |
| 1713 | 1787 | // Send them to the all done page. |
| 1714 | 1788 | redirectexit('action=mergetopics;sa=done;to=' . $id_topic . ';targetboard=' . $target_board); |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 3 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * Retrieve a list and several other statistics of the users currently online. |
@@ -45,12 +46,14 @@ discard block |
||
| 45 | 46 | } |
| 46 | 47 | |
| 47 | 48 | // Not allowed sort method? Bang! Error! |
| 48 | - elseif (!in_array($membersOnlineOptions['sort'], $allowed_sort_options)) |
|
| 49 | - trigger_error('Sort method for getMembersOnlineStats() function is not allowed', E_USER_NOTICE); |
|
| 49 | + elseif (!in_array($membersOnlineOptions['sort'], $allowed_sort_options)) { |
|
| 50 | + trigger_error('Sort method for getMembersOnlineStats() function is not allowed', E_USER_NOTICE); |
|
| 51 | + } |
|
| 50 | 52 | |
| 51 | 53 | // Get it from the cache and send it back. |
| 52 | - if (($temp = cache_get_data('membersOnlineStats-' . $membersOnlineOptions['sort'], 240)) !== null) |
|
| 53 | - return $temp; |
|
| 54 | + if (($temp = cache_get_data('membersOnlineStats-' . $membersOnlineOptions['sort'], 240)) !== null) { |
|
| 55 | + return $temp; |
|
| 56 | + } |
|
| 54 | 57 | |
| 55 | 58 | // Initialize the array that'll be returned later on. |
| 56 | 59 | $membersOnlineStats = array( |
@@ -67,8 +70,9 @@ discard block |
||
| 67 | 70 | // Get any spiders if enabled. |
| 68 | 71 | $spiders = array(); |
| 69 | 72 | $spider_finds = array(); |
| 70 | - if (!empty($modSettings['show_spider_online']) && ($modSettings['show_spider_online'] < 3 || allowedTo('admin_forum')) && !empty($modSettings['spider_name_cache'])) |
|
| 71 | - $spiders = smf_json_decode($modSettings['spider_name_cache'], true); |
|
| 73 | + if (!empty($modSettings['show_spider_online']) && ($modSettings['show_spider_online'] < 3 || allowedTo('admin_forum')) && !empty($modSettings['spider_name_cache'])) { |
|
| 74 | + $spiders = smf_json_decode($modSettings['spider_name_cache'], true); |
|
| 75 | + } |
|
| 72 | 76 | |
| 73 | 77 | // Load the users online right now. |
| 74 | 78 | $request = $smcFunc['db_query']('', ' |
@@ -96,9 +100,7 @@ discard block |
||
| 96 | 100 | $membersOnlineStats['num_guests']++; |
| 97 | 101 | |
| 98 | 102 | continue; |
| 99 | - } |
|
| 100 | - |
|
| 101 | - elseif (empty($row['show_online']) && empty($membersOnlineOptions['show_hidden'])) |
|
| 103 | + } elseif (empty($row['show_online']) && empty($membersOnlineOptions['show_hidden'])) |
|
| 102 | 104 | { |
| 103 | 105 | // Just increase the stats and don't add this hidden user to any list. |
| 104 | 106 | $membersOnlineStats['num_users_hidden']++; |
@@ -106,10 +108,11 @@ discard block |
||
| 106 | 108 | } |
| 107 | 109 | |
| 108 | 110 | // Some basic color coding... |
| 109 | - if (!empty($row['online_color'])) |
|
| 110 | - $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>'; |
|
| 111 | - else |
|
| 112 | - $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
| 111 | + if (!empty($row['online_color'])) { |
|
| 112 | + $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>'; |
|
| 113 | + } else { |
|
| 114 | + $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
| 115 | + } |
|
| 113 | 116 | |
| 114 | 117 | // Buddies get counted and highlighted. |
| 115 | 118 | $is_buddy = in_array($row['id_member'], $user_info['buddies']); |
@@ -136,12 +139,13 @@ discard block |
||
| 136 | 139 | $membersOnlineStats['list_users_online'][$row[$membersOnlineOptions['sort']] . '_' . $row['member_name']] = empty($row['show_online']) ? '<em>' . $link . '</em>' : $link; |
| 137 | 140 | |
| 138 | 141 | // Store all distinct (primary) membergroups that are shown. |
| 139 | - if (!isset($membersOnlineStats['online_groups'][$row['id_group']])) |
|
| 140 | - $membersOnlineStats['online_groups'][$row['id_group']] = array( |
|
| 142 | + if (!isset($membersOnlineStats['online_groups'][$row['id_group']])) { |
|
| 143 | + $membersOnlineStats['online_groups'][$row['id_group']] = array( |
|
| 141 | 144 | 'id' => $row['id_group'], |
| 142 | 145 | 'name' => $row['group_name'], |
| 143 | 146 | 'color' => $row['online_color'] |
| 144 | 147 | ); |
| 148 | + } |
|
| 145 | 149 | } |
| 146 | 150 | $smcFunc['db_free_result']($request); |
| 147 | 151 | |
@@ -204,11 +208,12 @@ discard block |
||
| 204 | 208 | $settingsToUpdate = array(); |
| 205 | 209 | |
| 206 | 210 | // More members on now than ever were? Update it! |
| 207 | - if (!isset($modSettings['mostOnline']) || $total_users_online >= $modSettings['mostOnline']) |
|
| 208 | - $settingsToUpdate = array( |
|
| 211 | + if (!isset($modSettings['mostOnline']) || $total_users_online >= $modSettings['mostOnline']) { |
|
| 212 | + $settingsToUpdate = array( |
|
| 209 | 213 | 'mostOnline' => $total_users_online, |
| 210 | 214 | 'mostDate' => time() |
| 211 | 215 | ); |
| 216 | + } |
|
| 212 | 217 | |
| 213 | 218 | $date = strftime('%Y-%m-%d', forum_time(false)); |
| 214 | 219 | |
@@ -240,8 +245,9 @@ discard block |
||
| 240 | 245 | { |
| 241 | 246 | list ($modSettings['mostOnlineToday']) = $smcFunc['db_fetch_row']($request); |
| 242 | 247 | |
| 243 | - if ($total_users_online > $modSettings['mostOnlineToday']) |
|
| 244 | - trackStats(array('most_on' => $total_users_online)); |
|
| 248 | + if ($total_users_online > $modSettings['mostOnlineToday']) { |
|
| 249 | + trackStats(array('most_on' => $total_users_online)); |
|
| 250 | + } |
|
| 245 | 251 | |
| 246 | 252 | $total_users_online = max($total_users_online, $modSettings['mostOnlineToday']); |
| 247 | 253 | } |
@@ -258,8 +264,9 @@ discard block |
||
| 258 | 264 | $settingsToUpdate['mostOnlineToday'] = $total_users_online; |
| 259 | 265 | } |
| 260 | 266 | |
| 261 | - if (!empty($settingsToUpdate)) |
|
| 262 | - updateSettings($settingsToUpdate); |
|
| 263 | -} |
|
| 267 | + if (!empty($settingsToUpdate)) { |
|
| 268 | + updateSettings($settingsToUpdate); |
|
| 269 | + } |
|
| 270 | + } |
|
| 264 | 271 | |
| 265 | 272 | ?> |
| 266 | 273 | \ No newline at end of file |
@@ -11,8 +11,9 @@ discard block |
||
| 11 | 11 | * @version 2.1 Beta 3 |
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | -if (!defined('SMF')) |
|
| 14 | +if (!defined('SMF')) { |
|
| 15 | 15 | die('No direct access...'); |
| 16 | +} |
|
| 16 | 17 | |
| 17 | 18 | /** |
| 18 | 19 | * Fetches the list of preferences (or a single/subset of preferences) for |
@@ -30,8 +31,9 @@ discard block |
||
| 30 | 31 | // We want this as an array whether it is or not. |
| 31 | 32 | $members = is_array($members) ? $members : (array) $members; |
| 32 | 33 | |
| 33 | - if (!empty($prefs)) |
|
| 34 | - $prefs = is_array($prefs) ? $prefs : (array) $prefs; |
|
| 34 | + if (!empty($prefs)) { |
|
| 35 | + $prefs = is_array($prefs) ? $prefs : (array) $prefs; |
|
| 36 | + } |
|
| 35 | 37 | |
| 36 | 38 | $result = array(); |
| 37 | 39 | |
@@ -56,9 +58,10 @@ discard block |
||
| 56 | 58 | // We may want to keep the default values separate from a given user's. Or we might not. |
| 57 | 59 | if ($process_default && isset($result[0])) |
| 58 | 60 | { |
| 59 | - foreach ($members as $member) |
|
| 60 | - if (!isset($result[$member])) |
|
| 61 | + foreach ($members as $member) { |
|
| 62 | + if (!isset($result[$member])) |
|
| 61 | 63 | $result[$member] = $result[0]; |
| 64 | + } |
|
| 62 | 65 | |
| 63 | 66 | unset ($result[0]); |
| 64 | 67 | } |
@@ -76,12 +79,14 @@ discard block |
||
| 76 | 79 | { |
| 77 | 80 | global $smcFunc; |
| 78 | 81 | |
| 79 | - if (empty($prefs) || !is_int($memID)) |
|
| 80 | - return; |
|
| 82 | + if (empty($prefs) || !is_int($memID)) { |
|
| 83 | + return; |
|
| 84 | + } |
|
| 81 | 85 | |
| 82 | 86 | $update_rows = array(); |
| 83 | - foreach ($prefs as $k => $v) |
|
| 84 | - $update_rows[] = array($memID, $k, $v); |
|
| 87 | + foreach ($prefs as $k => $v) { |
|
| 88 | + $update_rows[] = array($memID, $k, $v); |
|
| 89 | + } |
|
| 85 | 90 | |
| 86 | 91 | $smcFunc['db_insert']('replace', |
| 87 | 92 | '{db_prefix}user_alerts_prefs', |
@@ -101,8 +106,9 @@ discard block |
||
| 101 | 106 | { |
| 102 | 107 | global $smcFunc; |
| 103 | 108 | |
| 104 | - if (empty($prefs) || empty($memID)) |
|
| 105 | - return; |
|
| 109 | + if (empty($prefs) || empty($memID)) { |
|
| 110 | + return; |
|
| 111 | + } |
|
| 106 | 112 | |
| 107 | 113 | $smcFunc['db_query']('', ' |
| 108 | 114 | DELETE FROM {db_prefix}user_alerts_prefs |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 3 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * Finds or repairs errors in the database to fix possible problems. |
@@ -50,8 +51,9 @@ discard block |
||
| 50 | 51 | ); |
| 51 | 52 | |
| 52 | 53 | // Start displaying errors without fixing them. |
| 53 | - if (isset($_GET['fixErrors'])) |
|
| 54 | - checkSession('get'); |
|
| 54 | + if (isset($_GET['fixErrors'])) { |
|
| 55 | + checkSession('get'); |
|
| 56 | + } |
|
| 55 | 57 | |
| 56 | 58 | // Will want this. |
| 57 | 59 | loadForumTests(); |
@@ -69,11 +71,11 @@ discard block |
||
| 69 | 71 | $_SESSION['repairboards_to_fix'] = $context['to_fix']; |
| 70 | 72 | $_SESSION['repairboards_to_fix2'] = null; |
| 71 | 73 | |
| 72 | - if (empty($context['repair_errors'])) |
|
| 73 | - $context['repair_errors'][] = '???'; |
|
| 74 | + if (empty($context['repair_errors'])) { |
|
| 75 | + $context['repair_errors'][] = '???'; |
|
| 76 | + } |
|
| 74 | 77 | } |
| 75 | - } |
|
| 76 | - else |
|
| 78 | + } else |
|
| 77 | 79 | { |
| 78 | 80 | $context['error_search'] = false; |
| 79 | 81 | $context['to_fix'] = isset($_SESSION['repairboards_to_fix']) ? $_SESSION['repairboards_to_fix'] : array(); |
@@ -120,16 +122,19 @@ discard block |
||
| 120 | 122 | |
| 121 | 123 | // More time, I need more time! |
| 122 | 124 | @set_time_limit(600); |
| 123 | - if (function_exists('apache_reset_timeout')) |
|
| 124 | - @apache_reset_timeout(); |
|
| 125 | + if (function_exists('apache_reset_timeout')) { |
|
| 126 | + @apache_reset_timeout(); |
|
| 127 | + } |
|
| 125 | 128 | |
| 126 | 129 | // Errr, wait. How much time has this taken already? |
| 127 | - if (!$force && time() - array_sum(explode(' ', $time_start)) < 3) |
|
| 128 | - return; |
|
| 130 | + if (!$force && time() - array_sum(explode(' ', $time_start)) < 3) { |
|
| 131 | + return; |
|
| 132 | + } |
|
| 129 | 133 | |
| 130 | 134 | // Restore the query cache if interested. |
| 131 | - if (!empty($db_temp_cache)) |
|
| 132 | - $db_cache = $db_temp_cache; |
|
| 135 | + if (!empty($db_temp_cache)) { |
|
| 136 | + $db_cache = $db_temp_cache; |
|
| 137 | + } |
|
| 133 | 138 | |
| 134 | 139 | $context['continue_get_data'] = '?action=admin;area=repairboards' . (isset($_GET['fixErrors']) ? ';fixErrors' : '') . ';step=' . $_GET['step'] . ';substep=' . $_GET['substep'] . ';' . $context['session_var'] . '=' . $context['session_id']; |
| 135 | 140 | $context['page_title'] = $txt['not_done_title']; |
@@ -138,10 +143,11 @@ discard block |
||
| 138 | 143 | $context['sub_template'] = 'not_done'; |
| 139 | 144 | |
| 140 | 145 | // Change these two if more steps are added! |
| 141 | - if (empty($max_substep)) |
|
| 142 | - $context['continue_percent'] = round(($_GET['step'] * 100) / $context['total_steps']); |
|
| 143 | - else |
|
| 144 | - $context['continue_percent'] = round((($_GET['step'] + ($_GET['substep'] / $max_substep)) * 100) / $context['total_steps']); |
|
| 146 | + if (empty($max_substep)) { |
|
| 147 | + $context['continue_percent'] = round(($_GET['step'] * 100) / $context['total_steps']); |
|
| 148 | + } else { |
|
| 149 | + $context['continue_percent'] = round((($_GET['step'] + ($_GET['substep'] / $max_substep)) * 100) / $context['total_steps']); |
|
| 150 | + } |
|
| 145 | 151 | |
| 146 | 152 | // Never more than 100%! |
| 147 | 153 | $context['continue_percent'] = min($context['continue_percent'], 100); |
@@ -617,8 +623,9 @@ discard block |
||
| 617 | 623 | $row['myid_last_msg'] = (int) $row['myid_last_msg']; |
| 618 | 624 | |
| 619 | 625 | // Not really a problem? |
| 620 | - if ($row['myid_first_msg'] == $row['myid_first_msg'] && $row['myid_first_msg'] == $row['myid_first_msg'] && $row['approved'] == $row['firstmsg_approved']) |
|
| 621 | - return false; |
|
| 626 | + if ($row['myid_first_msg'] == $row['myid_first_msg'] && $row['myid_first_msg'] == $row['myid_first_msg'] && $row['approved'] == $row['firstmsg_approved']) { |
|
| 627 | + return false; |
|
| 628 | + } |
|
| 622 | 629 | |
| 623 | 630 | $memberStartedID = (int) getMsgMemberID($row['myid_first_msg']); |
| 624 | 631 | $memberUpdatedID = (int) getMsgMemberID($row['myid_last_msg']); |
@@ -642,15 +649,19 @@ discard block |
||
| 642 | 649 | 'message_function' => function ($row) use ($txt, &$context) |
| 643 | 650 | { |
| 644 | 651 | // A pretend error? |
| 645 | - if ($row['myid_first_msg'] == $row['myid_first_msg'] && $row['myid_first_msg'] == $row['myid_first_msg'] && $row['approved'] == $row['firstmsg_approved']) |
|
| 646 | - return false; |
|
| 652 | + if ($row['myid_first_msg'] == $row['myid_first_msg'] && $row['myid_first_msg'] == $row['myid_first_msg'] && $row['approved'] == $row['firstmsg_approved']) { |
|
| 653 | + return false; |
|
| 654 | + } |
|
| 647 | 655 | |
| 648 | - if ($row['id_first_msg'] != $row['myid_first_msg']) |
|
| 649 | - $context['repair_errors'][] = sprintf($txt['repair_stats_topics_1'], $row['id_topic'], $row['id_first_msg']); |
|
| 650 | - if ($row['id_last_msg'] != $row['myid_last_msg']) |
|
| 651 | - $context['repair_errors'][] = sprintf($txt['repair_stats_topics_2'], $row['id_topic'], $row['id_last_msg']); |
|
| 652 | - if ($row['approved'] != $row['firstmsg_approved']) |
|
| 653 | - $context['repair_errors'][] = sprintf($txt['repair_stats_topics_5'], $row['id_topic']); |
|
| 656 | + if ($row['id_first_msg'] != $row['myid_first_msg']) { |
|
| 657 | + $context['repair_errors'][] = sprintf($txt['repair_stats_topics_1'], $row['id_topic'], $row['id_first_msg']); |
|
| 658 | + } |
|
| 659 | + if ($row['id_last_msg'] != $row['myid_last_msg']) { |
|
| 660 | + $context['repair_errors'][] = sprintf($txt['repair_stats_topics_2'], $row['id_topic'], $row['id_last_msg']); |
|
| 661 | + } |
|
| 662 | + if ($row['approved'] != $row['firstmsg_approved']) { |
|
| 663 | + $context['repair_errors'][] = sprintf($txt['repair_stats_topics_5'], $row['id_topic']); |
|
| 664 | + } |
|
| 654 | 665 | |
| 655 | 666 | return true; |
| 656 | 667 | }, |
@@ -680,8 +691,9 @@ discard block |
||
| 680 | 691 | $row['my_num_replies'] = (int) $row['my_num_replies']; |
| 681 | 692 | |
| 682 | 693 | // Not really a problem? |
| 683 | - if ($row['my_num_replies'] == $row['num_replies']) |
|
| 684 | - return false; |
|
| 694 | + if ($row['my_num_replies'] == $row['num_replies']) { |
|
| 695 | + return false; |
|
| 696 | + } |
|
| 685 | 697 | |
| 686 | 698 | $smcFunc['db_query']('', ' |
| 687 | 699 | UPDATE {db_prefix}topics |
@@ -700,11 +712,13 @@ discard block |
||
| 700 | 712 | global $txt, $context; |
| 701 | 713 | |
| 702 | 714 | // Just joking? |
| 703 | - if ($row['my_num_replies'] == $row['num_replies']) |
|
| 704 | - return false; |
|
| 715 | + if ($row['my_num_replies'] == $row['num_replies']) { |
|
| 716 | + return false; |
|
| 717 | + } |
|
| 705 | 718 | |
| 706 | - if ($row['num_replies'] != $row['my_num_replies']) |
|
| 707 | - $context['repair_errors'][] = sprintf($txt['repair_stats_topics_3'], $row['id_topic'], $row['num_replies']); |
|
| 719 | + if ($row['num_replies'] != $row['my_num_replies']) { |
|
| 720 | + $context['repair_errors'][] = sprintf($txt['repair_stats_topics_3'], $row['id_topic'], $row['num_replies']); |
|
| 721 | + } |
|
| 708 | 722 | |
| 709 | 723 | return true; |
| 710 | 724 | |
@@ -1295,8 +1309,9 @@ discard block |
||
| 1295 | 1309 | $inserts = array(); |
| 1296 | 1310 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 1297 | 1311 | { |
| 1298 | - foreach (text2words($row['subject']) as $word) |
|
| 1299 | - $inserts[] = array($word, $row['id_topic']); |
|
| 1312 | + foreach (text2words($row['subject']) as $word) { |
|
| 1313 | + $inserts[] = array($word, $row['id_topic']); |
|
| 1314 | + } |
|
| 1300 | 1315 | if (count($inserts) > 500) |
| 1301 | 1316 | { |
| 1302 | 1317 | $smcFunc['db_insert']('ignore', |
@@ -1310,13 +1325,14 @@ discard block |
||
| 1310 | 1325 | |
| 1311 | 1326 | } |
| 1312 | 1327 | |
| 1313 | - if (!empty($inserts)) |
|
| 1314 | - $smcFunc['db_insert']('ignore', |
|
| 1328 | + if (!empty($inserts)) { |
|
| 1329 | + $smcFunc['db_insert']('ignore', |
|
| 1315 | 1330 | '{db_prefix}log_search_subjects', |
| 1316 | 1331 | array('word' => 'string', 'id_topic' => 'int'), |
| 1317 | 1332 | $inserts, |
| 1318 | 1333 | array('word', 'id_topic') |
| 1319 | 1334 | ); |
| 1335 | + } |
|
| 1320 | 1336 | |
| 1321 | 1337 | }, |
| 1322 | 1338 | 'message_function' => function ($row) |
@@ -1586,8 +1602,9 @@ discard block |
||
| 1586 | 1602 | $current_step++; |
| 1587 | 1603 | |
| 1588 | 1604 | // Already done this? |
| 1589 | - if ($_GET['step'] > $current_step) |
|
| 1590 | - continue; |
|
| 1605 | + if ($_GET['step'] > $current_step) { |
|
| 1606 | + continue; |
|
| 1607 | + } |
|
| 1591 | 1608 | |
| 1592 | 1609 | // If we're fixing it but it ain't broke why try? |
| 1593 | 1610 | if ($do_fix && !in_array($error_type, $to_fix)) |
@@ -1616,14 +1633,16 @@ discard block |
||
| 1616 | 1633 | while (!$done) |
| 1617 | 1634 | { |
| 1618 | 1635 | // Make sure there's at least one ID to test. |
| 1619 | - if (isset($test['substeps']) && empty($step_max)) |
|
| 1620 | - break; |
|
| 1636 | + if (isset($test['substeps']) && empty($step_max)) { |
|
| 1637 | + break; |
|
| 1638 | + } |
|
| 1621 | 1639 | |
| 1622 | 1640 | // What is the testing query (Changes if we are testing or fixing) |
| 1623 | - if (!$do_fix) |
|
| 1624 | - $test_query = 'check_query'; |
|
| 1625 | - else |
|
| 1626 | - $test_query = isset($test['fix_query']) ? 'fix_query' : 'check_query'; |
|
| 1641 | + if (!$do_fix) { |
|
| 1642 | + $test_query = 'check_query'; |
|
| 1643 | + } else { |
|
| 1644 | + $test_query = isset($test['fix_query']) ? 'fix_query' : 'check_query'; |
|
| 1645 | + } |
|
| 1627 | 1646 | |
| 1628 | 1647 | // Do the test... |
| 1629 | 1648 | $request = $smcFunc['db_query']('', |
@@ -1634,10 +1653,11 @@ discard block |
||
| 1634 | 1653 | $needs_fix = false; |
| 1635 | 1654 | |
| 1636 | 1655 | // Does it need a fix? |
| 1637 | - if (!empty($test['check_type']) && $test['check_type'] == 'count') |
|
| 1638 | - list ($needs_fix) = $smcFunc['db_fetch_row']($request); |
|
| 1639 | - else |
|
| 1640 | - $needs_fix = $smcFunc['db_num_rows']($request); |
|
| 1656 | + if (!empty($test['check_type']) && $test['check_type'] == 'count') { |
|
| 1657 | + list ($needs_fix) = $smcFunc['db_fetch_row']($request); |
|
| 1658 | + } else { |
|
| 1659 | + $needs_fix = $smcFunc['db_num_rows']($request); |
|
| 1660 | + } |
|
| 1641 | 1661 | |
| 1642 | 1662 | $total_queries++; |
| 1643 | 1663 | |
@@ -1649,8 +1669,9 @@ discard block |
||
| 1649 | 1669 | // Assume need to fix. |
| 1650 | 1670 | $found_errors = true; |
| 1651 | 1671 | |
| 1652 | - if (isset($test['message'])) |
|
| 1653 | - $context['repair_errors'][] = $txt[$test['message']]; |
|
| 1672 | + if (isset($test['message'])) { |
|
| 1673 | + $context['repair_errors'][] = $txt[$test['message']]; |
|
| 1674 | + } |
|
| 1654 | 1675 | |
| 1655 | 1676 | // One per row! |
| 1656 | 1677 | elseif (isset($test['messages'])) |
@@ -1660,10 +1681,11 @@ discard block |
||
| 1660 | 1681 | $variables = $test['messages']; |
| 1661 | 1682 | foreach ($variables as $k => $v) |
| 1662 | 1683 | { |
| 1663 | - if ($k == 0 && isset($txt[$v])) |
|
| 1664 | - $variables[$k] = $txt[$v]; |
|
| 1665 | - elseif ($k > 0 && isset($row[$v])) |
|
| 1666 | - $variables[$k] = $row[$v]; |
|
| 1684 | + if ($k == 0 && isset($txt[$v])) { |
|
| 1685 | + $variables[$k] = $txt[$v]; |
|
| 1686 | + } elseif ($k > 0 && isset($row[$v])) { |
|
| 1687 | + $variables[$k] = $row[$v]; |
|
| 1688 | + } |
|
| 1667 | 1689 | } |
| 1668 | 1690 | $context['repair_errors'][] = call_user_func_array('sprintf', $variables); |
| 1669 | 1691 | } |
@@ -1674,13 +1696,15 @@ discard block |
||
| 1674 | 1696 | { |
| 1675 | 1697 | // Find out if there are actually errors. |
| 1676 | 1698 | $found_errors = false; |
| 1677 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1678 | - $found_errors |= $test['message_function']($row); |
|
| 1699 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1700 | + $found_errors |= $test['message_function']($row); |
|
| 1701 | + } |
|
| 1679 | 1702 | } |
| 1680 | 1703 | |
| 1681 | 1704 | // Actually have something to fix? |
| 1682 | - if ($found_errors) |
|
| 1683 | - $to_fix[] = $error_type; |
|
| 1705 | + if ($found_errors) { |
|
| 1706 | + $to_fix[] = $error_type; |
|
| 1707 | + } |
|
| 1684 | 1708 | } |
| 1685 | 1709 | |
| 1686 | 1710 | // We want to fix, we need to fix - so work out what exactly to do! |
@@ -1690,8 +1714,9 @@ discard block |
||
| 1690 | 1714 | if (isset($test['fix_collect'])) |
| 1691 | 1715 | { |
| 1692 | 1716 | $ids = array(); |
| 1693 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1694 | - $ids[] = $row[$test['fix_collect']['index']]; |
|
| 1717 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1718 | + $ids[] = $row[$test['fix_collect']['index']]; |
|
| 1719 | + } |
|
| 1695 | 1720 | if (!empty($ids)) |
| 1696 | 1721 | { |
| 1697 | 1722 | // Fix it! |
@@ -1700,30 +1725,34 @@ discard block |
||
| 1700 | 1725 | } |
| 1701 | 1726 | |
| 1702 | 1727 | // Simply executing a fix it query? |
| 1703 | - elseif (isset($test['fix_it_query'])) |
|
| 1704 | - $smcFunc['db_query']('', |
|
| 1728 | + elseif (isset($test['fix_it_query'])) { |
|
| 1729 | + $smcFunc['db_query']('', |
|
| 1705 | 1730 | $test['fix_it_query'], |
| 1706 | 1731 | array( |
| 1707 | 1732 | ) |
| 1708 | 1733 | ); |
| 1734 | + } |
|
| 1709 | 1735 | |
| 1710 | 1736 | // Do we have some processing to do? |
| 1711 | 1737 | elseif (isset($test['fix_processing'])) |
| 1712 | 1738 | { |
| 1713 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1714 | - $test['fix_processing']($row); |
|
| 1739 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1740 | + $test['fix_processing']($row); |
|
| 1741 | + } |
|
| 1715 | 1742 | } |
| 1716 | 1743 | |
| 1717 | 1744 | // What about the full set of processing? |
| 1718 | - elseif (isset($test['fix_full_processing'])) |
|
| 1719 | - $test['fix_full_processing']($request); |
|
| 1745 | + elseif (isset($test['fix_full_processing'])) { |
|
| 1746 | + $test['fix_full_processing']($request); |
|
| 1747 | + } |
|
| 1720 | 1748 | |
| 1721 | 1749 | // Do we have other things we need to fix as a result? |
| 1722 | 1750 | if (!empty($test['force_fix'])) |
| 1723 | 1751 | { |
| 1724 | - foreach ($test['force_fix'] as $item) |
|
| 1725 | - if (!in_array($item, $to_fix)) |
|
| 1752 | + foreach ($test['force_fix'] as $item) { |
|
| 1753 | + if (!in_array($item, $to_fix)) |
|
| 1726 | 1754 | $to_fix[] = $item; |
| 1755 | + } |
|
| 1727 | 1756 | } |
| 1728 | 1757 | } |
| 1729 | 1758 | } |
@@ -1741,16 +1770,17 @@ discard block |
||
| 1741 | 1770 | if ($_GET['substep'] <= $step_max) |
| 1742 | 1771 | { |
| 1743 | 1772 | pauseRepairProcess($to_fix, $error_type, $step_max); |
| 1773 | + } else { |
|
| 1774 | + $done = true; |
|
| 1744 | 1775 | } |
| 1745 | - else |
|
| 1746 | - $done = true; |
|
| 1776 | + } else { |
|
| 1777 | + $done = true; |
|
| 1747 | 1778 | } |
| 1748 | - else |
|
| 1749 | - $done = true; |
|
| 1750 | 1779 | |
| 1751 | 1780 | // Don't allow more than 1000 queries at a time. |
| 1752 | - if ($total_queries >= 1000) |
|
| 1753 | - pauseRepairProcess($to_fix, $error_type, $step_max, true); |
|
| 1781 | + if ($total_queries >= 1000) { |
|
| 1782 | + pauseRepairProcess($to_fix, $error_type, $step_max, true); |
|
| 1783 | + } |
|
| 1754 | 1784 | } |
| 1755 | 1785 | |
| 1756 | 1786 | // Keep going. |
@@ -1763,8 +1793,9 @@ discard block |
||
| 1763 | 1793 | if ($do_fix) |
| 1764 | 1794 | { |
| 1765 | 1795 | $key = array_search($error_type, $to_fix); |
| 1766 | - if ($key !== false && isset($to_fix[$key])) |
|
| 1767 | - unset($to_fix[$key]); |
|
| 1796 | + if ($key !== false && isset($to_fix[$key])) { |
|
| 1797 | + unset($to_fix[$key]); |
|
| 1798 | + } |
|
| 1768 | 1799 | } |
| 1769 | 1800 | |
| 1770 | 1801 | // Are we done? |
@@ -1787,10 +1818,11 @@ discard block |
||
| 1787 | 1818 | static $createOnce = false; |
| 1788 | 1819 | |
| 1789 | 1820 | // Have we already created it? |
| 1790 | - if ($createOnce) |
|
| 1791 | - return; |
|
| 1792 | - else |
|
| 1793 | - $createOnce = true; |
|
| 1821 | + if ($createOnce) { |
|
| 1822 | + return; |
|
| 1823 | + } else { |
|
| 1824 | + $createOnce = true; |
|
| 1825 | + } |
|
| 1794 | 1826 | |
| 1795 | 1827 | // Back to the forum's default language. |
| 1796 | 1828 | loadLanguage('Admin', $language); |
@@ -1805,8 +1837,9 @@ discard block |
||
| 1805 | 1837 | 'cat_name' => $txt['salvaged_category_name'], |
| 1806 | 1838 | ) |
| 1807 | 1839 | ); |
| 1808 | - if ($smcFunc['db_num_rows']($result) != 0) |
|
| 1809 | - list ($salvageCatID) = $smcFunc['db_fetch_row']($result); |
|
| 1840 | + if ($smcFunc['db_num_rows']($result) != 0) { |
|
| 1841 | + list ($salvageCatID) = $smcFunc['db_fetch_row']($result); |
|
| 1842 | + } |
|
| 1810 | 1843 | $smcFunc['db_free_result']($result); |
| 1811 | 1844 | |
| 1812 | 1845 | if (empty($salvageCatID)) |
@@ -1839,8 +1872,9 @@ discard block |
||
| 1839 | 1872 | 'board_name' => $txt['salvaged_board_name'], |
| 1840 | 1873 | ) |
| 1841 | 1874 | ); |
| 1842 | - if ($smcFunc['db_num_rows']($result) != 0) |
|
| 1843 | - list ($salvageBoardID) = $smcFunc['db_fetch_row']($result); |
|
| 1875 | + if ($smcFunc['db_num_rows']($result) != 0) { |
|
| 1876 | + list ($salvageBoardID) = $smcFunc['db_fetch_row']($result); |
|
| 1877 | + } |
|
| 1844 | 1878 | $smcFunc['db_free_result']($result); |
| 1845 | 1879 | |
| 1846 | 1880 | if (empty($salvageBoardID)) |
@@ -12,8 +12,9 @@ discard block |
||
| 12 | 12 | * @version 2.1 Beta 3 |
| 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 | * This is the controlling delegator |
@@ -38,13 +39,15 @@ discard block |
||
| 38 | 39 | ); |
| 39 | 40 | |
| 40 | 41 | // Any subaction? If none, fall through to the main template, which will ask for one. |
| 41 | - if (isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']])) |
|
| 42 | - call_helper($subActions[$_REQUEST['sa']]); |
|
| 42 | + if (isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']])) { |
|
| 43 | + call_helper($subActions[$_REQUEST['sa']]); |
|
| 44 | + } |
|
| 43 | 45 | |
| 44 | 46 | // Creating a one time token. |
| 45 | - else |
|
| 46 | - createToken('remind'); |
|
| 47 | -} |
|
| 47 | + else { |
|
| 48 | + createToken('remind'); |
|
| 49 | + } |
|
| 50 | + } |
|
| 48 | 51 | |
| 49 | 52 | /** |
| 50 | 53 | * Allows the user to pick how they wish to be reminded |
@@ -62,8 +65,7 @@ discard block |
||
| 62 | 65 | { |
| 63 | 66 | $where = 'id_member = {int:id_member}'; |
| 64 | 67 | $where_params['id_member'] = (int) $_REQUEST['uid']; |
| 65 | - } |
|
| 66 | - elseif (isset($_POST['user']) && $_POST['user'] != '') |
|
| 68 | + } elseif (isset($_POST['user']) && $_POST['user'] != '') |
|
| 67 | 69 | { |
| 68 | 70 | $where = 'member_name = {string:member_name}'; |
| 69 | 71 | $where_params['member_name'] = $_POST['user']; |
@@ -71,8 +73,9 @@ discard block |
||
| 71 | 73 | } |
| 72 | 74 | |
| 73 | 75 | // You must enter a username/email address. |
| 74 | - if (empty($where)) |
|
| 75 | - fatal_lang_error('username_no_exist', false); |
|
| 76 | + if (empty($where)) { |
|
| 77 | + fatal_lang_error('username_no_exist', false); |
|
| 78 | + } |
|
| 76 | 79 | |
| 77 | 80 | // Make sure we are not being slammed |
| 78 | 81 | // Don't call this if you're coming from the "Choose a reminder type" page - otherwise you'll likely get an error |
@@ -101,8 +104,9 @@ discard block |
||
| 101 | 104 | LIMIT 1', |
| 102 | 105 | $where_params |
| 103 | 106 | ); |
| 104 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 105 | - fatal_lang_error('no_user_with_email', false); |
|
| 107 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 108 | + fatal_lang_error('no_user_with_email', false); |
|
| 109 | + } |
|
| 106 | 110 | } |
| 107 | 111 | |
| 108 | 112 | $row = $smcFunc['db_fetch_assoc']($request); |
@@ -112,16 +116,18 @@ discard block |
||
| 112 | 116 | if ($row['is_activated'] != 1) |
| 113 | 117 | { |
| 114 | 118 | // Awaiting approval... |
| 115 | - if (trim($row['validation_code']) == '') |
|
| 116 | - fatal_error(sprintf($txt['registration_not_approved'], $scripturl . '?action=activate;user=' . $_POST['user']), false); |
|
| 117 | - else |
|
| 118 | - fatal_error(sprintf($txt['registration_not_activated'], $scripturl . '?action=activate;user=' . $_POST['user']), false); |
|
| 119 | + if (trim($row['validation_code']) == '') { |
|
| 120 | + fatal_error(sprintf($txt['registration_not_approved'], $scripturl . '?action=activate;user=' . $_POST['user']), false); |
|
| 121 | + } else { |
|
| 122 | + fatal_error(sprintf($txt['registration_not_activated'], $scripturl . '?action=activate;user=' . $_POST['user']), false); |
|
| 123 | + } |
|
| 119 | 124 | } |
| 120 | 125 | |
| 121 | 126 | // You can't get emailed if you have no email address. |
| 122 | 127 | $row['email_address'] = trim($row['email_address']); |
| 123 | - if ($row['email_address'] == '') |
|
| 124 | - fatal_error($txt['no_reminder_email'] . '<br>' . $txt['send_email'] . ' <a href="mailto:' . $webmaster_email . '">webmaster</a> ' . $txt['to_ask_password'] . '.'); |
|
| 128 | + if ($row['email_address'] == '') { |
|
| 129 | + fatal_error($txt['no_reminder_email'] . '<br>' . $txt['send_email'] . ' <a href="mailto:' . $webmaster_email . '">webmaster</a> ' . $txt['to_ask_password'] . '.'); |
|
| 130 | + } |
|
| 125 | 131 | |
| 126 | 132 | // If they have no secret question then they can only get emailed the item, or they are requesting the email, send them an email. |
| 127 | 133 | if (empty($row['secret_question']) || (isset($_POST['reminder_type']) && $_POST['reminder_type'] == 'email')) |
@@ -176,8 +182,9 @@ discard block |
||
| 176 | 182 | loadLanguage('Login'); |
| 177 | 183 | |
| 178 | 184 | // You need a code! |
| 179 | - if (!isset($_REQUEST['code'])) |
|
| 180 | - fatal_lang_error('no_access', false); |
|
| 185 | + if (!isset($_REQUEST['code'])) { |
|
| 186 | + fatal_lang_error('no_access', false); |
|
| 187 | + } |
|
| 181 | 188 | |
| 182 | 189 | // Fill the context array. |
| 183 | 190 | $context += array( |
@@ -203,16 +210,19 @@ discard block |
||
| 203 | 210 | checkSession(); |
| 204 | 211 | validateToken('remind-sp'); |
| 205 | 212 | |
| 206 | - if (empty($_POST['u']) || !isset($_POST['passwrd1']) || !isset($_POST['passwrd2'])) |
|
| 207 | - fatal_lang_error('no_access', false); |
|
| 213 | + if (empty($_POST['u']) || !isset($_POST['passwrd1']) || !isset($_POST['passwrd2'])) { |
|
| 214 | + fatal_lang_error('no_access', false); |
|
| 215 | + } |
|
| 208 | 216 | |
| 209 | 217 | $_POST['u'] = (int) $_POST['u']; |
| 210 | 218 | |
| 211 | - if ($_POST['passwrd1'] != $_POST['passwrd2']) |
|
| 212 | - fatal_lang_error('passwords_dont_match', false); |
|
| 219 | + if ($_POST['passwrd1'] != $_POST['passwrd2']) { |
|
| 220 | + fatal_lang_error('passwords_dont_match', false); |
|
| 221 | + } |
|
| 213 | 222 | |
| 214 | - if ($_POST['passwrd1'] == '') |
|
| 215 | - fatal_lang_error('no_password', false); |
|
| 223 | + if ($_POST['passwrd1'] == '') { |
|
| 224 | + fatal_lang_error('no_password', false); |
|
| 225 | + } |
|
| 216 | 226 | |
| 217 | 227 | loadLanguage('Login'); |
| 218 | 228 | |
@@ -232,8 +242,9 @@ discard block |
||
| 232 | 242 | ); |
| 233 | 243 | |
| 234 | 244 | // Does this user exist at all? |
| 235 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 236 | - fatal_lang_error('invalid_userid', false); |
|
| 245 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 246 | + fatal_lang_error('invalid_userid', false); |
|
| 247 | + } |
|
| 237 | 248 | |
| 238 | 249 | list ($realCode, $username, $email, $flood_value) = $smcFunc['db_fetch_row']($request); |
| 239 | 250 | $smcFunc['db_free_result']($request); |
@@ -243,8 +254,9 @@ discard block |
||
| 243 | 254 | $passwordError = validatePassword($_POST['passwrd1'], $username, array($email)); |
| 244 | 255 | |
| 245 | 256 | // What - it's not? |
| 246 | - if ($passwordError != null) |
|
| 247 | - fatal_lang_error('profile_error_password_' . $passwordError, false); |
|
| 257 | + if ($passwordError != null) { |
|
| 258 | + fatal_lang_error('profile_error_password_' . $passwordError, false); |
|
| 259 | + } |
|
| 248 | 260 | |
| 249 | 261 | require_once($sourcedir . '/LogInOut.php'); |
| 250 | 262 | |
@@ -291,8 +303,9 @@ discard block |
||
| 291 | 303 | loadLanguage('Login'); |
| 292 | 304 | |
| 293 | 305 | // Check they entered something... |
| 294 | - if (empty($_REQUEST['uid'])) |
|
| 295 | - fatal_lang_error('username_no_exist', false); |
|
| 306 | + if (empty($_REQUEST['uid'])) { |
|
| 307 | + fatal_lang_error('username_no_exist', false); |
|
| 308 | + } |
|
| 296 | 309 | |
| 297 | 310 | // Get the stuff.... |
| 298 | 311 | $request = $smcFunc['db_query']('', ' |
@@ -304,15 +317,17 @@ discard block |
||
| 304 | 317 | 'id_member' => (int) $_REQUEST['uid'], |
| 305 | 318 | ) |
| 306 | 319 | ); |
| 307 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 308 | - fatal_lang_error('username_no_exist', false); |
|
| 320 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 321 | + fatal_lang_error('username_no_exist', false); |
|
| 322 | + } |
|
| 309 | 323 | |
| 310 | 324 | $row = $smcFunc['db_fetch_assoc']($request); |
| 311 | 325 | $smcFunc['db_free_result']($request); |
| 312 | 326 | |
| 313 | 327 | // If there is NO secret question - then throw an error. |
| 314 | - if (trim($row['secret_question']) == '') |
|
| 315 | - fatal_lang_error('registration_no_secret_question', false); |
|
| 328 | + if (trim($row['secret_question']) == '') { |
|
| 329 | + fatal_lang_error('registration_no_secret_question', false); |
|
| 330 | + } |
|
| 316 | 331 | |
| 317 | 332 | // Ask for the answer... |
| 318 | 333 | $context['remind_user'] = $row['id_member']; |
@@ -335,8 +350,9 @@ discard block |
||
| 335 | 350 | validateToken('remind-sai'); |
| 336 | 351 | |
| 337 | 352 | // Hacker? How did you get this far without an email or username? |
| 338 | - if (empty($_REQUEST['uid'])) |
|
| 339 | - fatal_lang_error('username_no_exist', false); |
|
| 353 | + if (empty($_REQUEST['uid'])) { |
|
| 354 | + fatal_lang_error('username_no_exist', false); |
|
| 355 | + } |
|
| 340 | 356 | |
| 341 | 357 | loadLanguage('Login'); |
| 342 | 358 | |
@@ -350,8 +366,9 @@ discard block |
||
| 350 | 366 | 'id_member' => $_REQUEST['uid'], |
| 351 | 367 | ) |
| 352 | 368 | ); |
| 353 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 354 | - fatal_lang_error('username_no_exist', false); |
|
| 369 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 370 | + fatal_lang_error('username_no_exist', false); |
|
| 371 | + } |
|
| 355 | 372 | |
| 356 | 373 | $row = $smcFunc['db_fetch_assoc']($request); |
| 357 | 374 | $smcFunc['db_free_result']($request); |
@@ -364,20 +381,23 @@ discard block |
||
| 364 | 381 | } |
| 365 | 382 | |
| 366 | 383 | // You can't use a blank one! |
| 367 | - if (strlen(trim($_POST['passwrd1'])) === 0) |
|
| 368 | - fatal_lang_error('no_password', false); |
|
| 384 | + if (strlen(trim($_POST['passwrd1'])) === 0) { |
|
| 385 | + fatal_lang_error('no_password', false); |
|
| 386 | + } |
|
| 369 | 387 | |
| 370 | 388 | // They have to be the same too. |
| 371 | - if ($_POST['passwrd1'] != $_POST['passwrd2']) |
|
| 372 | - fatal_lang_error('passwords_dont_match', false); |
|
| 389 | + if ($_POST['passwrd1'] != $_POST['passwrd2']) { |
|
| 390 | + fatal_lang_error('passwords_dont_match', false); |
|
| 391 | + } |
|
| 373 | 392 | |
| 374 | 393 | // Make sure they have a strong enough password. |
| 375 | 394 | require_once($sourcedir . '/Subs-Auth.php'); |
| 376 | 395 | $passwordError = validatePassword($_POST['passwrd1'], $row['member_name'], array($row['email_address'])); |
| 377 | 396 | |
| 378 | 397 | // Invalid? |
| 379 | - if ($passwordError != null) |
|
| 380 | - fatal_lang_error('profile_error_password_' . $passwordError, false); |
|
| 398 | + if ($passwordError != null) { |
|
| 399 | + fatal_lang_error('profile_error_password_' . $passwordError, false); |
|
| 400 | + } |
|
| 381 | 401 | |
| 382 | 402 | // Alright, so long as 'yer sure. |
| 383 | 403 | updateMemberData($row['id_member'], array('passwd' => hash_password($row['member_name'], $_POST['passwrd1']))); |
@@ -14,8 +14,9 @@ discard block |
||
| 14 | 14 | * @version 2.1 Beta 3 |
| 15 | 15 | */ |
| 16 | 16 | |
| 17 | -if (!defined('SMF')) |
|
| 17 | +if (!defined('SMF')) { |
|
| 18 | 18 | die('No direct access...'); |
| 19 | +} |
|
| 19 | 20 | |
| 20 | 21 | /** |
| 21 | 22 | * Allow the user to vote. |
@@ -51,8 +52,9 @@ discard block |
||
| 51 | 52 | 'not_guest' => 0, |
| 52 | 53 | ) |
| 53 | 54 | ); |
| 54 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 55 | - fatal_lang_error('poll_error', false); |
|
| 55 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 56 | + fatal_lang_error('poll_error', false); |
|
| 57 | + } |
|
| 56 | 58 | $row = $smcFunc['db_fetch_assoc']($request); |
| 57 | 59 | $smcFunc['db_free_result']($request); |
| 58 | 60 | |
@@ -60,8 +62,9 @@ discard block |
||
| 60 | 62 | if ($user_info['is_guest']) |
| 61 | 63 | { |
| 62 | 64 | // Guest voting disabled? |
| 63 | - if (!$row['guest_vote']) |
|
| 64 | - fatal_lang_error('guest_vote_disabled'); |
|
| 65 | + if (!$row['guest_vote']) { |
|
| 66 | + fatal_lang_error('guest_vote_disabled'); |
|
| 67 | + } |
|
| 65 | 68 | // Guest already voted? |
| 66 | 69 | elseif (!empty($_COOKIE['guest_poll_vote']) && preg_match('~^[0-9,;]+$~', $_COOKIE['guest_poll_vote']) && strpos($_COOKIE['guest_poll_vote'], ';' . $row['id_poll'] . ',') !== false) |
| 67 | 70 | { |
@@ -71,32 +74,36 @@ discard block |
||
| 71 | 74 | foreach ($guestinfo as $i => $guestvoted) |
| 72 | 75 | { |
| 73 | 76 | $guestvoted = explode(',', $guestvoted); |
| 74 | - if ($guestvoted[0] == $row['id_poll']) |
|
| 75 | - break; |
|
| 77 | + if ($guestvoted[0] == $row['id_poll']) { |
|
| 78 | + break; |
|
| 79 | + } |
|
| 76 | 80 | } |
| 77 | 81 | // Has the poll been reset since guest voted? |
| 78 | 82 | if ($row['reset_poll'] > $guestvoted[1]) |
| 79 | 83 | { |
| 80 | 84 | // Remove the poll info from the cookie to allow guest to vote again |
| 81 | 85 | unset($guestinfo[$i]); |
| 82 | - if (!empty($guestinfo)) |
|
| 83 | - $_COOKIE['guest_poll_vote'] = ';' . implode(';', $guestinfo); |
|
| 84 | - else |
|
| 85 | - unset($_COOKIE['guest_poll_vote']); |
|
| 86 | + if (!empty($guestinfo)) { |
|
| 87 | + $_COOKIE['guest_poll_vote'] = ';' . implode(';', $guestinfo); |
|
| 88 | + } else { |
|
| 89 | + unset($_COOKIE['guest_poll_vote']); |
|
| 90 | + } |
|
| 91 | + } else { |
|
| 92 | + fatal_lang_error('poll_error', false); |
|
| 86 | 93 | } |
| 87 | - else |
|
| 88 | - fatal_lang_error('poll_error', false); |
|
| 89 | 94 | unset($guestinfo, $guestvoted, $i); |
| 90 | 95 | } |
| 91 | 96 | } |
| 92 | 97 | |
| 93 | 98 | // Is voting locked or has it expired? |
| 94 | - if (!empty($row['voting_locked']) || (!empty($row['expire_time']) && time() > $row['expire_time'])) |
|
| 95 | - fatal_lang_error('poll_error', false); |
|
| 99 | + if (!empty($row['voting_locked']) || (!empty($row['expire_time']) && time() > $row['expire_time'])) { |
|
| 100 | + fatal_lang_error('poll_error', false); |
|
| 101 | + } |
|
| 96 | 102 | |
| 97 | 103 | // If they have already voted and aren't allowed to change their vote - hence they are outta here! |
| 98 | - if (!$user_info['is_guest'] && $row['selected'] != -1 && empty($row['change_vote'])) |
|
| 99 | - fatal_lang_error('poll_error', false); |
|
| 104 | + if (!$user_info['is_guest'] && $row['selected'] != -1 && empty($row['change_vote'])) { |
|
| 105 | + fatal_lang_error('poll_error', false); |
|
| 106 | + } |
|
| 100 | 107 | // Otherwise if they can change their vote yet they haven't sent any options... remove their vote and redirect. |
| 101 | 108 | elseif (!empty($row['change_vote']) && !$user_info['is_guest'] && empty($_POST['options'])) |
| 102 | 109 | { |
@@ -114,8 +121,9 @@ discard block |
||
| 114 | 121 | 'id_poll' => $row['id_poll'], |
| 115 | 122 | ) |
| 116 | 123 | ); |
| 117 | - while ($choice = $smcFunc['db_fetch_row']($request)) |
|
| 118 | - $pollOptions[] = $choice[0]; |
|
| 124 | + while ($choice = $smcFunc['db_fetch_row']($request)) { |
|
| 125 | + $pollOptions[] = $choice[0]; |
|
| 126 | + } |
|
| 119 | 127 | $smcFunc['db_free_result']($request); |
| 120 | 128 | |
| 121 | 129 | // Just skip it if they had voted for nothing before. |
@@ -148,19 +156,22 @@ discard block |
||
| 148 | 156 | } |
| 149 | 157 | |
| 150 | 158 | // Redirect back to the topic so the user can vote again! |
| 151 | - if (empty($_POST['options'])) |
|
| 152 | - redirectexit('topic=' . $topic . '.' . $_REQUEST['start']); |
|
| 159 | + if (empty($_POST['options'])) { |
|
| 160 | + redirectexit('topic=' . $topic . '.' . $_REQUEST['start']); |
|
| 161 | + } |
|
| 153 | 162 | } |
| 154 | 163 | |
| 155 | 164 | checkSession('request'); |
| 156 | 165 | |
| 157 | 166 | // Make sure the option(s) are valid. |
| 158 | - if (empty($_POST['options'])) |
|
| 159 | - fatal_lang_error('didnt_select_vote', false); |
|
| 167 | + if (empty($_POST['options'])) { |
|
| 168 | + fatal_lang_error('didnt_select_vote', false); |
|
| 169 | + } |
|
| 160 | 170 | |
| 161 | 171 | // Too many options checked! |
| 162 | - if (count($_REQUEST['options']) > $row['max_votes']) |
|
| 163 | - fatal_lang_error('poll_too_many_votes', false, array($row['max_votes'])); |
|
| 172 | + if (count($_REQUEST['options']) > $row['max_votes']) { |
|
| 173 | + fatal_lang_error('poll_too_many_votes', false, array($row['max_votes'])); |
|
| 174 | + } |
|
| 164 | 175 | |
| 165 | 176 | $pollOptions = array(); |
| 166 | 177 | $inserts = array(); |
@@ -250,24 +261,30 @@ discard block |
||
| 250 | 261 | list ($memberID, $pollID, $voting_locked) = $smcFunc['db_fetch_row']($request); |
| 251 | 262 | |
| 252 | 263 | // If the user _can_ modify the poll.... |
| 253 | - if (!allowedTo('poll_lock_any')) |
|
| 254 | - isAllowedTo('poll_lock_' . ($user_info['id'] == $memberID ? 'own' : 'any')); |
|
| 264 | + if (!allowedTo('poll_lock_any')) { |
|
| 265 | + isAllowedTo('poll_lock_' . ($user_info['id'] == $memberID ? 'own' : 'any')); |
|
| 266 | + } |
|
| 255 | 267 | |
| 256 | 268 | // It's been locked by a non-moderator. |
| 257 | - if ($voting_locked == '1') |
|
| 258 | - $voting_locked = '0'; |
|
| 269 | + if ($voting_locked == '1') { |
|
| 270 | + $voting_locked = '0'; |
|
| 271 | + } |
|
| 259 | 272 | // Locked by a moderator, and this is a moderator. |
| 260 | - elseif ($voting_locked == '2' && allowedTo('moderate_board')) |
|
| 261 | - $voting_locked = '0'; |
|
| 273 | + elseif ($voting_locked == '2' && allowedTo('moderate_board')) { |
|
| 274 | + $voting_locked = '0'; |
|
| 275 | + } |
|
| 262 | 276 | // Sorry, a moderator locked it. |
| 263 | - elseif ($voting_locked == '2' && !allowedTo('moderate_board')) |
|
| 264 | - fatal_lang_error('locked_by_admin', 'user'); |
|
| 277 | + elseif ($voting_locked == '2' && !allowedTo('moderate_board')) { |
|
| 278 | + fatal_lang_error('locked_by_admin', 'user'); |
|
| 279 | + } |
|
| 265 | 280 | // A moderator *is* locking it. |
| 266 | - elseif ($voting_locked == '0' && allowedTo('moderate_board')) |
|
| 267 | - $voting_locked = '2'; |
|
| 281 | + elseif ($voting_locked == '0' && allowedTo('moderate_board')) { |
|
| 282 | + $voting_locked = '2'; |
|
| 283 | + } |
|
| 268 | 284 | // Well, it's gonna be locked one way or another otherwise... |
| 269 | - else |
|
| 270 | - $voting_locked = '1'; |
|
| 285 | + else { |
|
| 286 | + $voting_locked = '1'; |
|
| 287 | + } |
|
| 271 | 288 | |
| 272 | 289 | // Lock! *Poof* - no one can vote. |
| 273 | 290 | $smcFunc['db_query']('', ' |
@@ -302,8 +319,9 @@ discard block |
||
| 302 | 319 | { |
| 303 | 320 | global $txt, $user_info, $context, $topic, $board, $smcFunc, $sourcedir, $scripturl; |
| 304 | 321 | |
| 305 | - if (empty($topic)) |
|
| 306 | - fatal_lang_error('no_access', false); |
|
| 322 | + if (empty($topic)) { |
|
| 323 | + fatal_lang_error('no_access', false); |
|
| 324 | + } |
|
| 307 | 325 | |
| 308 | 326 | loadLanguage('Post'); |
| 309 | 327 | loadTemplate('Poll'); |
@@ -327,24 +345,28 @@ discard block |
||
| 327 | 345 | ); |
| 328 | 346 | |
| 329 | 347 | // Assume the the topic exists, right? |
| 330 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 331 | - fatal_lang_error('no_board'); |
|
| 348 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 349 | + fatal_lang_error('no_board'); |
|
| 350 | + } |
|
| 332 | 351 | // Get the poll information. |
| 333 | 352 | $pollinfo = $smcFunc['db_fetch_assoc']($request); |
| 334 | 353 | $smcFunc['db_free_result']($request); |
| 335 | 354 | |
| 336 | 355 | // If we are adding a new poll - make sure that there isn't already a poll there. |
| 337 | - if (!$context['is_edit'] && !empty($pollinfo['id_poll'])) |
|
| 338 | - fatal_lang_error('poll_already_exists'); |
|
| 356 | + if (!$context['is_edit'] && !empty($pollinfo['id_poll'])) { |
|
| 357 | + fatal_lang_error('poll_already_exists'); |
|
| 358 | + } |
|
| 339 | 359 | // Otherwise, if we're editing it, it does exist I assume? |
| 340 | - elseif ($context['is_edit'] && empty($pollinfo['id_poll'])) |
|
| 341 | - fatal_lang_error('poll_not_found'); |
|
| 360 | + elseif ($context['is_edit'] && empty($pollinfo['id_poll'])) { |
|
| 361 | + fatal_lang_error('poll_not_found'); |
|
| 362 | + } |
|
| 342 | 363 | |
| 343 | 364 | // Can you do this? |
| 344 | - if ($context['is_edit'] && !allowedTo('poll_edit_any')) |
|
| 345 | - isAllowedTo('poll_edit_' . ($user_info['id'] == $pollinfo['id_member_started'] || ($pollinfo['poll_starter'] != 0 && $user_info['id'] == $pollinfo['poll_starter']) ? 'own' : 'any')); |
|
| 346 | - elseif (!$context['is_edit'] && !allowedTo('poll_add_any')) |
|
| 347 | - isAllowedTo('poll_add_' . ($user_info['id'] == $pollinfo['id_member_started'] ? 'own' : 'any')); |
|
| 365 | + if ($context['is_edit'] && !allowedTo('poll_edit_any')) { |
|
| 366 | + isAllowedTo('poll_edit_' . ($user_info['id'] == $pollinfo['id_member_started'] || ($pollinfo['poll_starter'] != 0 && $user_info['id'] == $pollinfo['poll_starter']) ? 'own' : 'any')); |
|
| 367 | + } elseif (!$context['is_edit'] && !allowedTo('poll_add_any')) { |
|
| 368 | + isAllowedTo('poll_add_' . ($user_info['id'] == $pollinfo['id_member_started'] ? 'own' : 'any')); |
|
| 369 | + } |
|
| 348 | 370 | $context['can_moderate_poll'] = isset($_REQUEST['add']) ? true : allowedTo('poll_edit_' . ($user_info['id'] == $pollinfo['id_member_started'] || ($pollinfo['poll_starter'] != 0 && $user_info['id'] == $pollinfo['poll_starter']) ? 'own' : 'any')); |
| 349 | 371 | |
| 350 | 372 | // Do we enable guest voting? |
@@ -386,12 +408,14 @@ discard block |
||
| 386 | 408 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 387 | 409 | { |
| 388 | 410 | // Get the highest id so we can add more without reusing. |
| 389 | - if ($row['id_choice'] >= $last_id) |
|
| 390 | - $last_id = $row['id_choice'] + 1; |
|
| 411 | + if ($row['id_choice'] >= $last_id) { |
|
| 412 | + $last_id = $row['id_choice'] + 1; |
|
| 413 | + } |
|
| 391 | 414 | |
| 392 | 415 | // They cleared this by either omitting it or emptying it. |
| 393 | - if (!isset($_POST['options'][$row['id_choice']]) || $_POST['options'][$row['id_choice']] == '') |
|
| 394 | - continue; |
|
| 416 | + if (!isset($_POST['options'][$row['id_choice']]) || $_POST['options'][$row['id_choice']] == '') { |
|
| 417 | + continue; |
|
| 418 | + } |
|
| 395 | 419 | |
| 396 | 420 | censorText($row['label']); |
| 397 | 421 | |
@@ -409,9 +433,10 @@ discard block |
||
| 409 | 433 | |
| 410 | 434 | // Work out how many options we have, so we get the 'is_last' field right... |
| 411 | 435 | $totalPostOptions = 0; |
| 412 | - foreach ($_POST['options'] as $id => $label) |
|
| 413 | - if ($label != '') |
|
| 436 | + foreach ($_POST['options'] as $id => $label) { |
|
| 437 | + if ($label != '') |
|
| 414 | 438 | $totalPostOptions++; |
| 439 | + } |
|
| 415 | 440 | |
| 416 | 441 | $count = 1; |
| 417 | 442 | // If an option exists, update it. If it is new, add it - but don't reuse ids! |
@@ -420,30 +445,32 @@ discard block |
||
| 420 | 445 | $label = $smcFunc['htmlspecialchars']($label); |
| 421 | 446 | censorText($label); |
| 422 | 447 | |
| 423 | - if (isset($context['choices'][$id])) |
|
| 424 | - $context['choices'][$id]['label'] = $label; |
|
| 425 | - elseif ($label != '') |
|
| 426 | - $context['choices'][] = array( |
|
| 448 | + if (isset($context['choices'][$id])) { |
|
| 449 | + $context['choices'][$id]['label'] = $label; |
|
| 450 | + } elseif ($label != '') { |
|
| 451 | + $context['choices'][] = array( |
|
| 427 | 452 | 'id' => $last_id++, |
| 428 | 453 | 'number' => $number++, |
| 429 | 454 | 'label' => $label, |
| 430 | 455 | 'votes' => -1, |
| 431 | 456 | 'is_last' => $count++ == $totalPostOptions && $totalPostOptions > 1 ? true : false, |
| 432 | 457 | ); |
| 458 | + } |
|
| 433 | 459 | } |
| 434 | 460 | |
| 435 | 461 | // Make sure we have two choices for sure! |
| 436 | 462 | if ($totalPostOptions < 2) |
| 437 | 463 | { |
| 438 | 464 | // Need two? |
| 439 | - if ($totalPostOptions == 0) |
|
| 440 | - $context['choices'][] = array( |
|
| 465 | + if ($totalPostOptions == 0) { |
|
| 466 | + $context['choices'][] = array( |
|
| 441 | 467 | 'id' => $last_id++, |
| 442 | 468 | 'number' => $number++, |
| 443 | 469 | 'label' => '', |
| 444 | 470 | 'votes' => -1, |
| 445 | 471 | 'is_last' => false |
| 446 | 472 | ); |
| 473 | + } |
|
| 447 | 474 | $poll_errors[] = 'poll_few'; |
| 448 | 475 | } |
| 449 | 476 | |
@@ -458,12 +485,14 @@ discard block |
||
| 458 | 485 | |
| 459 | 486 | $context['last_choice_id'] = $last_id; |
| 460 | 487 | |
| 461 | - if ($context['can_moderate_poll']) |
|
| 462 | - $context['poll']['expiration'] = $_POST['poll_expire']; |
|
| 488 | + if ($context['can_moderate_poll']) { |
|
| 489 | + $context['poll']['expiration'] = $_POST['poll_expire']; |
|
| 490 | + } |
|
| 463 | 491 | |
| 464 | 492 | // Check the question/option count for errors. |
| 465 | - if (trim($_POST['question']) == '' && empty($context['poll_error'])) |
|
| 466 | - $poll_errors[] = 'no_question'; |
|
| 493 | + if (trim($_POST['question']) == '' && empty($context['poll_error'])) { |
|
| 494 | + $poll_errors[] = 'no_question'; |
|
| 495 | + } |
|
| 467 | 496 | |
| 468 | 497 | // No check is needed, since nothing is really posted. |
| 469 | 498 | checkSubmitOnce('free'); |
@@ -480,8 +509,7 @@ discard block |
||
| 480 | 509 | $context['poll_error']['messages'][] = $txt['error_' . $poll_error]; |
| 481 | 510 | } |
| 482 | 511 | } |
| 483 | - } |
|
| 484 | - else |
|
| 512 | + } else |
|
| 485 | 513 | { |
| 486 | 514 | // Basic theme info... |
| 487 | 515 | $context['poll'] = array( |
@@ -596,18 +624,22 @@ discard block |
||
| 596 | 624 | global $user_info, $smcFunc, $sourcedir; |
| 597 | 625 | |
| 598 | 626 | // Sneaking off, are we? |
| 599 | - if (empty($_POST)) |
|
| 600 | - redirectexit('action=editpoll;topic=' . $topic . '.0'); |
|
| 627 | + if (empty($_POST)) { |
|
| 628 | + redirectexit('action=editpoll;topic=' . $topic . '.0'); |
|
| 629 | + } |
|
| 601 | 630 | |
| 602 | - if (checkSession('post', '', false) != '') |
|
| 603 | - $poll_errors[] = 'session_timeout'; |
|
| 631 | + if (checkSession('post', '', false) != '') { |
|
| 632 | + $poll_errors[] = 'session_timeout'; |
|
| 633 | + } |
|
| 604 | 634 | |
| 605 | - if (isset($_POST['preview'])) |
|
| 606 | - return EditPoll(); |
|
| 635 | + if (isset($_POST['preview'])) { |
|
| 636 | + return EditPoll(); |
|
| 637 | + } |
|
| 607 | 638 | |
| 608 | 639 | // HACKERS (!!) can't edit :P. |
| 609 | - if (empty($topic)) |
|
| 610 | - fatal_lang_error('no_access', false); |
|
| 640 | + if (empty($topic)) { |
|
| 641 | + fatal_lang_error('no_access', false); |
|
| 642 | + } |
|
| 611 | 643 | |
| 612 | 644 | // Is this a new poll, or editing an existing? |
| 613 | 645 | $isEdit = isset($_REQUEST['add']) ? 0 : 1; |
@@ -623,23 +655,27 @@ discard block |
||
| 623 | 655 | 'current_topic' => $topic, |
| 624 | 656 | ) |
| 625 | 657 | ); |
| 626 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 627 | - fatal_lang_error('no_board'); |
|
| 658 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 659 | + fatal_lang_error('no_board'); |
|
| 660 | + } |
|
| 628 | 661 | $bcinfo = $smcFunc['db_fetch_assoc']($request); |
| 629 | 662 | $smcFunc['db_free_result']($request); |
| 630 | 663 | |
| 631 | 664 | // Check their adding/editing is valid. |
| 632 | - if (!$isEdit && !empty($bcinfo['id_poll'])) |
|
| 633 | - fatal_lang_error('poll_already_exists'); |
|
| 665 | + if (!$isEdit && !empty($bcinfo['id_poll'])) { |
|
| 666 | + fatal_lang_error('poll_already_exists'); |
|
| 667 | + } |
|
| 634 | 668 | // Are we editing a poll which doesn't exist? |
| 635 | - elseif ($isEdit && empty($bcinfo['id_poll'])) |
|
| 636 | - fatal_lang_error('poll_not_found'); |
|
| 669 | + elseif ($isEdit && empty($bcinfo['id_poll'])) { |
|
| 670 | + fatal_lang_error('poll_not_found'); |
|
| 671 | + } |
|
| 637 | 672 | |
| 638 | 673 | // Check if they have the power to add or edit the poll. |
| 639 | - if ($isEdit && !allowedTo('poll_edit_any')) |
|
| 640 | - isAllowedTo('poll_edit_' . ($user_info['id'] == $bcinfo['id_member_started'] || ($bcinfo['poll_starter'] != 0 && $user_info['id'] == $bcinfo['poll_starter']) ? 'own' : 'any')); |
|
| 641 | - elseif (!$isEdit && !allowedTo('poll_add_any')) |
|
| 642 | - isAllowedTo('poll_add_' . ($user_info['id'] == $bcinfo['id_member_started'] ? 'own' : 'any')); |
|
| 674 | + if ($isEdit && !allowedTo('poll_edit_any')) { |
|
| 675 | + isAllowedTo('poll_edit_' . ($user_info['id'] == $bcinfo['id_member_started'] || ($bcinfo['poll_starter'] != 0 && $user_info['id'] == $bcinfo['poll_starter']) ? 'own' : 'any')); |
|
| 676 | + } elseif (!$isEdit && !allowedTo('poll_add_any')) { |
|
| 677 | + isAllowedTo('poll_add_' . ($user_info['id'] == $bcinfo['id_member_started'] ? 'own' : 'any')); |
|
| 678 | + } |
|
| 643 | 679 | |
| 644 | 680 | $optionCount = 0; |
| 645 | 681 | $idCount = 0; |
@@ -652,14 +688,16 @@ discard block |
||
| 652 | 688 | $idCount = max($idCount, $k); |
| 653 | 689 | } |
| 654 | 690 | } |
| 655 | - if ($optionCount < 2) |
|
| 656 | - $poll_errors[] = 'poll_few'; |
|
| 657 | - elseif ($optionCount > 256 || $idCount > 255) |
|
| 658 | - $poll_errors[] = 'poll_many'; |
|
| 691 | + if ($optionCount < 2) { |
|
| 692 | + $poll_errors[] = 'poll_few'; |
|
| 693 | + } elseif ($optionCount > 256 || $idCount > 255) { |
|
| 694 | + $poll_errors[] = 'poll_many'; |
|
| 695 | + } |
|
| 659 | 696 | |
| 660 | 697 | // Also - ensure they are not removing the question. |
| 661 | - if (trim($_POST['question']) == '') |
|
| 662 | - $poll_errors[] = 'no_question'; |
|
| 698 | + if (trim($_POST['question']) == '') { |
|
| 699 | + $poll_errors[] = 'no_question'; |
|
| 700 | + } |
|
| 663 | 701 | |
| 664 | 702 | // Got any errors to report? |
| 665 | 703 | if (!empty($poll_errors)) |
@@ -695,8 +733,9 @@ discard block |
||
| 695 | 733 | { |
| 696 | 734 | require_once($sourcedir . '/Subs-Members.php'); |
| 697 | 735 | $allowedGroups = groupsAllowedTo('poll_vote', $board); |
| 698 | - if (!in_array(-1, $allowedGroups['allowed'])) |
|
| 699 | - $_POST['poll_guest_vote'] = 0; |
|
| 736 | + if (!in_array(-1, $allowedGroups['allowed'])) { |
|
| 737 | + $_POST['poll_guest_vote'] = 0; |
|
| 738 | + } |
|
| 700 | 739 | } |
| 701 | 740 | |
| 702 | 741 | // Ensure that the number options allowed makes sense, and the expiration date is valid. |
@@ -704,17 +743,19 @@ discard block |
||
| 704 | 743 | { |
| 705 | 744 | $_POST['poll_expire'] = $_POST['poll_expire'] > 9999 ? 9999 : ($_POST['poll_expire'] < 0 ? 0 : $_POST['poll_expire']); |
| 706 | 745 | |
| 707 | - if (empty($_POST['poll_expire']) && $_POST['poll_hide'] == 2) |
|
| 708 | - $_POST['poll_hide'] = 1; |
|
| 709 | - elseif (!$isEdit || $_POST['poll_expire'] != ceil($bcinfo['expire_time'] <= time() ? -1 : ($bcinfo['expire_time'] - time()) / (3600 * 24))) |
|
| 710 | - $_POST['poll_expire'] = empty($_POST['poll_expire']) ? '0' : time() + $_POST['poll_expire'] * 3600 * 24; |
|
| 711 | - else |
|
| 712 | - $_POST['poll_expire'] = $bcinfo['expire_time']; |
|
| 746 | + if (empty($_POST['poll_expire']) && $_POST['poll_hide'] == 2) { |
|
| 747 | + $_POST['poll_hide'] = 1; |
|
| 748 | + } elseif (!$isEdit || $_POST['poll_expire'] != ceil($bcinfo['expire_time'] <= time() ? -1 : ($bcinfo['expire_time'] - time()) / (3600 * 24))) { |
|
| 749 | + $_POST['poll_expire'] = empty($_POST['poll_expire']) ? '0' : time() + $_POST['poll_expire'] * 3600 * 24; |
|
| 750 | + } else { |
|
| 751 | + $_POST['poll_expire'] = $bcinfo['expire_time']; |
|
| 752 | + } |
|
| 713 | 753 | |
| 714 | - if (empty($_POST['poll_max_votes']) || $_POST['poll_max_votes'] <= 0) |
|
| 715 | - $_POST['poll_max_votes'] = 1; |
|
| 716 | - else |
|
| 717 | - $_POST['poll_max_votes'] = (int) $_POST['poll_max_votes']; |
|
| 754 | + if (empty($_POST['poll_max_votes']) || $_POST['poll_max_votes'] <= 0) { |
|
| 755 | + $_POST['poll_max_votes'] = 1; |
|
| 756 | + } else { |
|
| 757 | + $_POST['poll_max_votes'] = (int) $_POST['poll_max_votes']; |
|
| 758 | + } |
|
| 718 | 759 | } |
| 719 | 760 | |
| 720 | 761 | // If we're editing, let's commit the changes. |
@@ -781,8 +822,9 @@ discard block |
||
| 781 | 822 | ) |
| 782 | 823 | ); |
| 783 | 824 | $choices = array(); |
| 784 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 785 | - $choices[] = $row['id_choice']; |
|
| 825 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 826 | + $choices[] = $row['id_choice']; |
|
| 827 | + } |
|
| 786 | 828 | $smcFunc['db_free_result']($request); |
| 787 | 829 | |
| 788 | 830 | $delete_options = array(); |
@@ -795,8 +837,9 @@ discard block |
||
| 795 | 837 | if (trim($option) == '') |
| 796 | 838 | { |
| 797 | 839 | // They want it deleted. Bye. |
| 798 | - if (in_array($k, $choices)) |
|
| 799 | - $delete_options[] = $k; |
|
| 840 | + if (in_array($k, $choices)) { |
|
| 841 | + $delete_options[] = $k; |
|
| 842 | + } |
|
| 800 | 843 | |
| 801 | 844 | // Skip the rest... |
| 802 | 845 | continue; |
@@ -806,8 +849,8 @@ discard block |
||
| 806 | 849 | $option = $smcFunc['htmlspecialchars']($option); |
| 807 | 850 | |
| 808 | 851 | // If it's already there, update it. If it's not... add it. |
| 809 | - if (in_array($k, $choices)) |
|
| 810 | - $smcFunc['db_query']('', ' |
|
| 852 | + if (in_array($k, $choices)) { |
|
| 853 | + $smcFunc['db_query']('', ' |
|
| 811 | 854 | UPDATE {db_prefix}poll_choices |
| 812 | 855 | SET label = {string:option_name} |
| 813 | 856 | WHERE id_poll = {int:id_poll} |
@@ -818,8 +861,8 @@ discard block |
||
| 818 | 861 | 'option_name' => $option, |
| 819 | 862 | ) |
| 820 | 863 | ); |
| 821 | - else |
|
| 822 | - $smcFunc['db_insert']('', |
|
| 864 | + } else { |
|
| 865 | + $smcFunc['db_insert']('', |
|
| 823 | 866 | '{db_prefix}poll_choices', |
| 824 | 867 | array( |
| 825 | 868 | 'id_poll' => 'int', 'id_choice' => 'int', 'label' => 'string-255', 'votes' => 'int', |
@@ -829,6 +872,7 @@ discard block |
||
| 829 | 872 | ), |
| 830 | 873 | array() |
| 831 | 874 | ); |
| 875 | + } |
|
| 832 | 876 | } |
| 833 | 877 | |
| 834 | 878 | // I'm sorry, but... well, no one was choosing you. Poor options, I'll put you out of your misery. |
@@ -894,13 +938,11 @@ discard block |
||
| 894 | 938 | { |
| 895 | 939 | // Added a poll |
| 896 | 940 | logAction('add_poll', array('topic' => $topic)); |
| 897 | - } |
|
| 898 | - elseif (isset($_REQUEST['deletevotes'])) |
|
| 941 | + } elseif (isset($_REQUEST['deletevotes'])) |
|
| 899 | 942 | { |
| 900 | 943 | // Reset votes |
| 901 | 944 | logAction('reset_poll', array('topic' => $topic)); |
| 902 | - } |
|
| 903 | - else |
|
| 945 | + } else |
|
| 904 | 946 | { |
| 905 | 947 | // Something else |
| 906 | 948 | logAction('editpoll', array('topic' => $topic)); |
@@ -923,8 +965,9 @@ discard block |
||
| 923 | 965 | global $topic, $user_info, $smcFunc; |
| 924 | 966 | |
| 925 | 967 | // Make sure the topic is not empty. |
| 926 | - if (empty($topic)) |
|
| 927 | - fatal_lang_error('no_access', false); |
|
| 968 | + if (empty($topic)) { |
|
| 969 | + fatal_lang_error('no_access', false); |
|
| 970 | + } |
|
| 928 | 971 | |
| 929 | 972 | // Verify the session. |
| 930 | 973 | checkSession('get'); |
@@ -942,8 +985,9 @@ discard block |
||
| 942 | 985 | 'current_topic' => $topic, |
| 943 | 986 | ) |
| 944 | 987 | ); |
| 945 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 946 | - fatal_lang_error('no_access', false); |
|
| 988 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 989 | + fatal_lang_error('no_access', false); |
|
| 990 | + } |
|
| 947 | 991 | list ($topicStarter, $pollStarter) = $smcFunc['db_fetch_row']($request); |
| 948 | 992 | $smcFunc['db_free_result']($request); |
| 949 | 993 | |
@@ -12,8 +12,9 @@ discard block |
||
| 12 | 12 | * @version 2.1 Beta 3 |
| 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 | |
@@ -268,18 +280,20 @@ discard block |
||
| 268 | 280 | 'ignored' => 1, |
| 269 | 281 | ) |
| 270 | 282 | ); |
| 271 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
| 272 | - list ($id_report, $ignore) = $smcFunc['db_fetch_row']($request); |
|
| 283 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
| 284 | + list ($id_report, $ignore) = $smcFunc['db_fetch_row']($request); |
|
| 285 | + } |
|
| 273 | 286 | |
| 274 | 287 | $smcFunc['db_free_result']($request); |
| 275 | 288 | |
| 276 | 289 | // If we're just going to ignore these, then who gives a monkeys... |
| 277 | - if (!empty($ignore)) |
|
| 278 | - redirectexit('topic=' . $topic . '.msg' . $_POST['msg'] . '#msg' . $_POST['msg']); |
|
| 290 | + if (!empty($ignore)) { |
|
| 291 | + redirectexit('topic=' . $topic . '.msg' . $_POST['msg'] . '#msg' . $_POST['msg']); |
|
| 292 | + } |
|
| 279 | 293 | |
| 280 | 294 | // Already reported? My god, we could be dealing with a real rogue here... |
| 281 | - if (!empty($id_report)) |
|
| 282 | - $smcFunc['db_query']('', ' |
|
| 295 | + if (!empty($id_report)) { |
|
| 296 | + $smcFunc['db_query']('', ' |
|
| 283 | 297 | UPDATE {db_prefix}log_reported |
| 284 | 298 | SET num_reports = num_reports + 1, time_updated = {int:current_time} |
| 285 | 299 | WHERE id_report = {int:id_report}', |
@@ -288,11 +302,13 @@ discard block |
||
| 288 | 302 | 'id_report' => $id_report, |
| 289 | 303 | ) |
| 290 | 304 | ); |
| 305 | + } |
|
| 291 | 306 | // Otherwise, we shall make one! |
| 292 | 307 | else |
| 293 | 308 | { |
| 294 | - if (empty($message['real_name'])) |
|
| 295 | - $message['real_name'] = $message['poster_name']; |
|
| 309 | + if (empty($message['real_name'])) { |
|
| 310 | + $message['real_name'] = $message['poster_name']; |
|
| 311 | + } |
|
| 296 | 312 | |
| 297 | 313 | $smcFunc['db_insert']('', |
| 298 | 314 | '{db_prefix}log_reported', |
@@ -371,8 +387,9 @@ discard block |
||
| 371 | 387 | 'id_member' => $_POST['u'] |
| 372 | 388 | ) |
| 373 | 389 | ); |
| 374 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 375 | - fatal_lang_error('no_user', false); |
|
| 390 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 391 | + fatal_lang_error('no_user', false); |
|
| 392 | + } |
|
| 376 | 393 | $user = $smcFunc['db_fetch_assoc']($request); |
| 377 | 394 | $smcFunc['db_free_result']($request); |
| 378 | 395 | |
@@ -393,18 +410,20 @@ discard block |
||
| 393 | 410 | 'ignored' => 1, |
| 394 | 411 | ) |
| 395 | 412 | ); |
| 396 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
| 397 | - list ($id_report, $ignore) = $smcFunc['db_fetch_row']($request); |
|
| 413 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
| 414 | + list ($id_report, $ignore) = $smcFunc['db_fetch_row']($request); |
|
| 415 | + } |
|
| 398 | 416 | |
| 399 | 417 | $smcFunc['db_free_result']($request); |
| 400 | 418 | |
| 401 | 419 | // If we're just going to ignore these, then who gives a monkeys... |
| 402 | - if (!empty($ignore)) |
|
| 403 | - redirectexit('action=profile;u=' . $_POST['u']); |
|
| 420 | + if (!empty($ignore)) { |
|
| 421 | + redirectexit('action=profile;u=' . $_POST['u']); |
|
| 422 | + } |
|
| 404 | 423 | |
| 405 | 424 | // Already reported? My god, we could be dealing with a real rogue here... |
| 406 | - if (!empty($id_report)) |
|
| 407 | - $smcFunc['db_query']('', ' |
|
| 425 | + if (!empty($id_report)) { |
|
| 426 | + $smcFunc['db_query']('', ' |
|
| 408 | 427 | UPDATE {db_prefix}log_reported |
| 409 | 428 | SET num_reports = num_reports + 1, time_updated = {int:current_time} |
| 410 | 429 | WHERE id_report = {int:id_report}', |
@@ -413,6 +432,7 @@ discard block |
||
| 413 | 432 | 'id_report' => $id_report, |
| 414 | 433 | ) |
| 415 | 434 | ); |
| 435 | + } |
|
| 416 | 436 | // Otherwise, we shall make one! |
| 417 | 437 | else |
| 418 | 438 | { |