@@ -393,7 +393,7 @@ discard block |
||
| 393 | 393 | 'class' => 'centercol', |
| 394 | 394 | ), |
| 395 | 395 | 'data' => array( |
| 396 | - 'function' => function ($rowData) |
|
| 396 | + 'function' => function($rowData) |
|
| 397 | 397 | { |
| 398 | 398 | return $rowData['selected'] ? '<span class="generic_icons valid"></span>' : ''; |
| 399 | 399 | }, |
@@ -453,7 +453,7 @@ discard block |
||
| 453 | 453 | 'class' => 'centercol', |
| 454 | 454 | ), |
| 455 | 455 | 'data' => array( |
| 456 | - 'function' => function ($rowData) |
|
| 456 | + 'function' => function($rowData) |
|
| 457 | 457 | { |
| 458 | 458 | return $rowData['selected'] ? '' : sprintf('<input type="checkbox" name="smiley_set[%1$d]" class="input_check">', $rowData['id']); |
| 459 | 459 | }, |
@@ -997,7 +997,7 @@ discard block |
||
| 997 | 997 | 'value' => $txt['smileys_location'], |
| 998 | 998 | ), |
| 999 | 999 | 'data' => array( |
| 1000 | - 'function' => function ($rowData) use ($txt) |
|
| 1000 | + 'function' => function($rowData) use ($txt) |
|
| 1001 | 1001 | { |
| 1002 | 1002 | if (empty($rowData['hidden'])) |
| 1003 | 1003 | return $txt['smileys_location_form']; |
@@ -1017,7 +1017,7 @@ discard block |
||
| 1017 | 1017 | 'value' => $txt['smileys_description'], |
| 1018 | 1018 | ), |
| 1019 | 1019 | 'data' => array( |
| 1020 | - 'function' => function ($rowData) use ($context, $txt, $modSettings, $smcFunc) |
|
| 1020 | + 'function' => function($rowData) use ($context, $txt, $modSettings, $smcFunc) |
|
| 1021 | 1021 | { |
| 1022 | 1022 | if (empty($modSettings['smileys_dir']) || !is_dir($modSettings['smileys_dir'])) |
| 1023 | 1023 | return $smcFunc['htmlspecialchars']($rowData['description']); |
@@ -1557,7 +1557,7 @@ discard block |
||
| 1557 | 1557 | 'action' => $smcFunc['htmlspecialchars'](strtr($action['destination'], array($boarddir => '.'))) |
| 1558 | 1558 | ); |
| 1559 | 1559 | |
| 1560 | - $file = $packagesdir . '/temp/' . $base_path . $action['filename']; |
|
| 1560 | + $file = $packagesdir . '/temp/' . $base_path . $action['filename']; |
|
| 1561 | 1561 | if (isset($action['filename']) && (!file_exists($file) || !is_writable(dirname($action['destination'])))) |
| 1562 | 1562 | { |
| 1563 | 1563 | $context['has_failure'] = true; |
@@ -1601,7 +1601,7 @@ discard block |
||
| 1601 | 1601 | { |
| 1602 | 1602 | updateSettings(array( |
| 1603 | 1603 | 'smiley_sets_known' => $modSettings['smiley_sets_known'] . ',' . basename($action['action']), |
| 1604 | - 'smiley_sets_names' => $modSettings['smiley_sets_names'] . "\n" . $smileyInfo['name'] . (count($context['actions']) > 1 ? ' ' . (!empty($action['description']) ? $smcFunc['htmlspecialchars']($action['description']) : basename($action['action'])) : ''), |
|
| 1604 | + 'smiley_sets_names' => $modSettings['smiley_sets_names'] . "\n" . $smileyInfo['name'] . (count($context['actions']) > 1 ? ' ' . (!empty($action['description']) ? $smcFunc['htmlspecialchars']($action['description']) : basename($action['action'])) : ''), |
|
| 1605 | 1605 | )); |
| 1606 | 1606 | } |
| 1607 | 1607 | |
@@ -1613,7 +1613,7 @@ discard block |
||
| 1613 | 1613 | '{db_prefix}log_packages', |
| 1614 | 1614 | array( |
| 1615 | 1615 | 'filename' => 'string', 'name' => 'string', 'package_id' => 'string', 'version' => 'string', |
| 1616 | - 'id_member_installed' => 'int', 'member_installed' => 'string','time_installed' => 'int', |
|
| 1616 | + 'id_member_installed' => 'int', 'member_installed' => 'string', 'time_installed' => 'int', |
|
| 1617 | 1617 | 'install_state' => 'int', 'failed_steps' => 'string', 'themes_installed' => 'string', |
| 1618 | 1618 | 'member_removed' => 'int', 'db_changes' => 'string', 'credits' => 'string', |
| 1619 | 1619 | ), |
@@ -1862,7 +1862,7 @@ discard block |
||
| 1862 | 1862 | 'columns' => array( |
| 1863 | 1863 | 'icon' => array( |
| 1864 | 1864 | 'data' => array( |
| 1865 | - 'function' => function ($rowData) use ($settings, $smcFunc) |
|
| 1865 | + 'function' => function($rowData) use ($settings, $smcFunc) |
|
| 1866 | 1866 | { |
| 1867 | 1867 | $images_url = $settings[file_exists(sprintf('%1$s/images/post/%2$s.png', $settings['theme_dir'], $rowData['filename'])) ? 'actual_images_url' : 'default_images_url']; |
| 1868 | 1868 | return sprintf('<img src="%1$s/post/%2$s.png" alt="%3$s">', $images_url, $rowData['filename'], $smcFunc['htmlspecialchars']($rowData['title'])); |
@@ -1896,7 +1896,7 @@ discard block |
||
| 1896 | 1896 | 'value' => $txt['icons_board'], |
| 1897 | 1897 | ), |
| 1898 | 1898 | 'data' => array( |
| 1899 | - 'function' => function ($rowData) use ($txt) |
|
| 1899 | + 'function' => function($rowData) use ($txt) |
|
| 1900 | 1900 | { |
| 1901 | 1901 | return empty($rowData['board_name']) ? $txt['icons_edit_icons_all_boards'] : $rowData['board_name']; |
| 1902 | 1902 | }, |
@@ -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 | * This is the dispatcher of smileys administration. |
@@ -91,8 +92,9 @@ discard block |
||
| 91 | 92 | ); |
| 92 | 93 | |
| 93 | 94 | // Some settings may not be enabled, disallow these from the tabs as appropriate. |
| 94 | - if (empty($modSettings['messageIcons_enable'])) |
|
| 95 | - $context[$context['admin_menu_name']]['tab_data']['tabs']['editicons']['disabled'] = true; |
|
| 95 | + if (empty($modSettings['messageIcons_enable'])) { |
|
| 96 | + $context[$context['admin_menu_name']]['tab_data']['tabs']['editicons']['disabled'] = true; |
|
| 97 | + } |
|
| 96 | 98 | if (empty($modSettings['smiley_enable'])) |
| 97 | 99 | { |
| 98 | 100 | $context[$context['admin_menu_name']]['tab_data']['tabs']['addsmiley']['disabled'] = true; |
@@ -125,8 +127,9 @@ discard block |
||
| 125 | 127 | $set_names = explode("\n", $modSettings['smiley_sets_names']); |
| 126 | 128 | |
| 127 | 129 | $smiley_context = array(); |
| 128 | - foreach ($smiley_sets as $i => $set) |
|
| 129 | - $smiley_context[$set] = $set_names[$i]; |
|
| 130 | + foreach ($smiley_sets as $i => $set) { |
|
| 131 | + $smiley_context[$set] = $set_names[$i]; |
|
| 132 | + } |
|
| 130 | 133 | |
| 131 | 134 | // All the settings for the page... |
| 132 | 135 | $config_vars = array( |
@@ -147,8 +150,9 @@ discard block |
||
| 147 | 150 | |
| 148 | 151 | call_integration_hook('integrate_modify_smiley_settings', array(&$config_vars)); |
| 149 | 152 | |
| 150 | - if ($return_config) |
|
| 151 | - return $config_vars; |
|
| 153 | + if ($return_config) { |
|
| 154 | + return $config_vars; |
|
| 155 | + } |
|
| 152 | 156 | |
| 153 | 157 | // Setup the basics of the settings template. |
| 154 | 158 | require_once($sourcedir . '/ManageServer.php'); |
@@ -207,8 +211,9 @@ discard block |
||
| 207 | 211 | foreach ($_POST['smiley_set'] as $id => $val) |
| 208 | 212 | { |
| 209 | 213 | // If this is the set you've marked as default, or the only one remaining, you can't delete it |
| 210 | - if ($modSettings['smiley_sets_default'] != $set_paths[$id] && count($set_paths) != 1 && isset($set_paths[$id], $set_names[$id])) |
|
| 211 | - unset($set_paths[$id], $set_names[$id]); |
|
| 214 | + if ($modSettings['smiley_sets_default'] != $set_paths[$id] && count($set_paths) != 1 && isset($set_paths[$id], $set_names[$id])) { |
|
| 215 | + unset($set_paths[$id], $set_names[$id]); |
|
| 216 | + } |
|
| 212 | 217 | } |
| 213 | 218 | |
| 214 | 219 | // Shortcut... array_merge() on a single array resets the numeric keys |
@@ -222,8 +227,9 @@ discard block |
||
| 222 | 227 | )); |
| 223 | 228 | } |
| 224 | 229 | // Add a new smiley set. |
| 225 | - elseif (!empty($_POST['add'])) |
|
| 226 | - $context['sub_action'] = 'modifyset'; |
|
| 230 | + elseif (!empty($_POST['add'])) { |
|
| 231 | + $context['sub_action'] = 'modifyset'; |
|
| 232 | + } |
|
| 227 | 233 | // Create or modify a smiley set. |
| 228 | 234 | elseif (isset($_POST['set'])) |
| 229 | 235 | { |
@@ -233,8 +239,9 @@ discard block |
||
| 233 | 239 | // Create a new smiley set. |
| 234 | 240 | if ($_POST['set'] == -1 && isset($_POST['smiley_sets_path'])) |
| 235 | 241 | { |
| 236 | - if (in_array($_POST['smiley_sets_path'], $set_paths)) |
|
| 237 | - fatal_lang_error('smiley_set_already_exists'); |
|
| 242 | + if (in_array($_POST['smiley_sets_path'], $set_paths)) { |
|
| 243 | + fatal_lang_error('smiley_set_already_exists'); |
|
| 244 | + } |
|
| 238 | 245 | |
| 239 | 246 | updateSettings(array( |
| 240 | 247 | 'smiley_sets_known' => $modSettings['smiley_sets_known'] . ',' . $_POST['smiley_sets_path'], |
@@ -246,12 +253,14 @@ discard block |
||
| 246 | 253 | else |
| 247 | 254 | { |
| 248 | 255 | // Make sure the smiley set exists. |
| 249 | - if (!isset($set_paths[$_POST['set']]) || !isset($set_names[$_POST['set']])) |
|
| 250 | - fatal_lang_error('smiley_set_not_found'); |
|
| 256 | + if (!isset($set_paths[$_POST['set']]) || !isset($set_names[$_POST['set']])) { |
|
| 257 | + fatal_lang_error('smiley_set_not_found'); |
|
| 258 | + } |
|
| 251 | 259 | |
| 252 | 260 | // Make sure the path is not yet used by another smileyset. |
| 253 | - if (in_array($_POST['smiley_sets_path'], $set_paths) && $_POST['smiley_sets_path'] != $set_paths[$_POST['set']]) |
|
| 254 | - fatal_lang_error('smiley_set_path_already_used'); |
|
| 261 | + if (in_array($_POST['smiley_sets_path'], $set_paths) && $_POST['smiley_sets_path'] != $set_paths[$_POST['set']]) { |
|
| 262 | + fatal_lang_error('smiley_set_path_already_used'); |
|
| 263 | + } |
|
| 255 | 264 | |
| 256 | 265 | $set_paths[$_POST['set']] = $_POST['smiley_sets_path']; |
| 257 | 266 | $set_names[$_POST['set']] = $_POST['smiley_sets_name']; |
@@ -263,8 +272,9 @@ discard block |
||
| 263 | 272 | } |
| 264 | 273 | |
| 265 | 274 | // The user might have checked to also import smileys. |
| 266 | - if (!empty($_POST['smiley_sets_import'])) |
|
| 267 | - ImportSmileys($_POST['smiley_sets_path']); |
|
| 275 | + if (!empty($_POST['smiley_sets_import'])) { |
|
| 276 | + ImportSmileys($_POST['smiley_sets_path']); |
|
| 277 | + } |
|
| 268 | 278 | } |
| 269 | 279 | cache_put_data('parsing_smileys', null, 480); |
| 270 | 280 | cache_put_data('posting_smileys', null, 480); |
@@ -273,13 +283,14 @@ discard block |
||
| 273 | 283 | // Load all available smileysets... |
| 274 | 284 | $context['smiley_sets'] = explode(',', $modSettings['smiley_sets_known']); |
| 275 | 285 | $set_names = explode("\n", $modSettings['smiley_sets_names']); |
| 276 | - foreach ($context['smiley_sets'] as $i => $set) |
|
| 277 | - $context['smiley_sets'][$i] = array( |
|
| 286 | + foreach ($context['smiley_sets'] as $i => $set) { |
|
| 287 | + $context['smiley_sets'][$i] = array( |
|
| 278 | 288 | 'id' => $i, |
| 279 | 289 | 'path' => $smcFunc['htmlspecialchars']($set), |
| 280 | 290 | 'name' => $smcFunc['htmlspecialchars']($set_names[$i]), |
| 281 | 291 | 'selected' => $set == $modSettings['smiley_sets_default'] |
| 282 | 292 | ); |
| 293 | + } |
|
| 283 | 294 | |
| 284 | 295 | // Importing any smileys from an existing set? |
| 285 | 296 | if ($context['sub_action'] == 'import') |
@@ -290,8 +301,9 @@ discard block |
||
| 290 | 301 | $_GET['set'] = (int) $_GET['set']; |
| 291 | 302 | |
| 292 | 303 | // Sanity check - then import. |
| 293 | - if (isset($context['smiley_sets'][$_GET['set']])) |
|
| 294 | - ImportSmileys(un_htmlspecialchars($context['smiley_sets'][$_GET['set']]['path'])); |
|
| 304 | + if (isset($context['smiley_sets'][$_GET['set']])) { |
|
| 305 | + ImportSmileys(un_htmlspecialchars($context['smiley_sets'][$_GET['set']]['path'])); |
|
| 306 | + } |
|
| 295 | 307 | |
| 296 | 308 | // Force the process to continue. |
| 297 | 309 | $context['sub_action'] = 'modifyset'; |
@@ -301,15 +313,15 @@ discard block |
||
| 301 | 313 | if ($context['sub_action'] == 'modifyset') |
| 302 | 314 | { |
| 303 | 315 | $_GET['set'] = !isset($_GET['set']) ? -1 : (int) $_GET['set']; |
| 304 | - if ($_GET['set'] == -1 || !isset($context['smiley_sets'][$_GET['set']])) |
|
| 305 | - $context['current_set'] = array( |
|
| 316 | + if ($_GET['set'] == -1 || !isset($context['smiley_sets'][$_GET['set']])) { |
|
| 317 | + $context['current_set'] = array( |
|
| 306 | 318 | 'id' => '-1', |
| 307 | 319 | 'path' => '', |
| 308 | 320 | 'name' => '', |
| 309 | 321 | 'selected' => false, |
| 310 | 322 | 'is_new' => true, |
| 311 | 323 | ); |
| 312 | - else |
|
| 324 | + } else |
|
| 313 | 325 | { |
| 314 | 326 | $context['current_set'] = &$context['smiley_sets'][$_GET['set']]; |
| 315 | 327 | $context['current_set']['is_new'] = false; |
@@ -321,13 +333,15 @@ discard block |
||
| 321 | 333 | $dir = dir($modSettings['smileys_dir'] . '/' . $context['current_set']['path']); |
| 322 | 334 | while ($entry = $dir->read()) |
| 323 | 335 | { |
| 324 | - if (in_array(strrchr($entry, '.'), array('.jpg', '.gif', '.jpeg', '.png'))) |
|
| 325 | - $smileys[strtolower($entry)] = $entry; |
|
| 336 | + if (in_array(strrchr($entry, '.'), array('.jpg', '.gif', '.jpeg', '.png'))) { |
|
| 337 | + $smileys[strtolower($entry)] = $entry; |
|
| 338 | + } |
|
| 326 | 339 | } |
| 327 | 340 | $dir->close(); |
| 328 | 341 | |
| 329 | - if (empty($smileys)) |
|
| 330 | - fatal_lang_error('smiley_set_dir_not_found', false, array($context['current_set']['name'])); |
|
| 342 | + if (empty($smileys)) { |
|
| 343 | + fatal_lang_error('smiley_set_dir_not_found', false, array($context['current_set']['name'])); |
|
| 344 | + } |
|
| 331 | 345 | |
| 332 | 346 | // Exclude the smileys that are already in the database. |
| 333 | 347 | $request = $smcFunc['db_query']('', ' |
@@ -338,9 +352,10 @@ discard block |
||
| 338 | 352 | 'smiley_list' => $smileys, |
| 339 | 353 | ) |
| 340 | 354 | ); |
| 341 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 342 | - if (isset($smileys[strtolower($row['filename'])])) |
|
| 355 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 356 | + if (isset($smileys[strtolower($row['filename'])])) |
|
| 343 | 357 | unset($smileys[strtolower($row['filename'])]); |
| 358 | + } |
|
| 344 | 359 | $smcFunc['db_free_result']($request); |
| 345 | 360 | |
| 346 | 361 | $context['current_set']['can_import'] = count($smileys); |
@@ -355,13 +370,14 @@ discard block |
||
| 355 | 370 | $dir = dir($modSettings['smileys_dir']); |
| 356 | 371 | while ($entry = $dir->read()) |
| 357 | 372 | { |
| 358 | - if (!in_array($entry, array('.', '..')) && is_dir($modSettings['smileys_dir'] . '/' . $entry)) |
|
| 359 | - $context['smiley_set_dirs'][] = array( |
|
| 373 | + if (!in_array($entry, array('.', '..')) && is_dir($modSettings['smileys_dir'] . '/' . $entry)) { |
|
| 374 | + $context['smiley_set_dirs'][] = array( |
|
| 360 | 375 | 'id' => $entry, |
| 361 | 376 | 'path' => $modSettings['smileys_dir'] . '/' . $entry, |
| 362 | 377 | 'selectable' => $entry == $context['current_set']['path'] || !in_array($entry, explode(',', $modSettings['smiley_sets_known'])), |
| 363 | 378 | 'current' => $entry == $context['current_set']['path'], |
| 364 | 379 | ); |
| 380 | + } |
|
| 365 | 381 | } |
| 366 | 382 | $dir->close(); |
| 367 | 383 | } |
@@ -371,8 +387,9 @@ discard block |
||
| 371 | 387 | createToken('admin-mss', 'request'); |
| 372 | 388 | |
| 373 | 389 | // In case we need to import smileys, we need to add the token in now. |
| 374 | - if (isset($context['current_set']['import_url'])) |
|
| 375 | - $context['current_set']['import_url'] .= ';' . $context['admin-mss_token_var'] . '=' . $context['admin-mss_token']; |
|
| 390 | + if (isset($context['current_set']['import_url'])) { |
|
| 391 | + $context['current_set']['import_url'] .= ';' . $context['admin-mss_token_var'] . '=' . $context['admin-mss_token']; |
|
| 392 | + } |
|
| 376 | 393 | |
| 377 | 394 | $listOptions = array( |
| 378 | 395 | 'id' => 'smiley_set_list', |
@@ -510,21 +527,23 @@ discard block |
||
| 510 | 527 | $cols['name'][] = $set_names[$i]; |
| 511 | 528 | } |
| 512 | 529 | $sort_flag = strpos($sort, 'DESC') === false ? SORT_ASC : SORT_DESC; |
| 513 | - if (substr($sort, 0, 4) === 'name') |
|
| 514 | - array_multisort($cols['name'], $sort_flag, SORT_REGULAR, $cols['path'], $cols['selected'], $cols['id']); |
|
| 515 | - elseif (substr($sort, 0, 4) === 'path') |
|
| 516 | - array_multisort($cols['path'], $sort_flag, SORT_REGULAR, $cols['name'], $cols['selected'], $cols['id']); |
|
| 517 | - else |
|
| 518 | - array_multisort($cols['selected'], $sort_flag, SORT_REGULAR, $cols['path'], $cols['name'], $cols['id']); |
|
| 530 | + if (substr($sort, 0, 4) === 'name') { |
|
| 531 | + array_multisort($cols['name'], $sort_flag, SORT_REGULAR, $cols['path'], $cols['selected'], $cols['id']); |
|
| 532 | + } elseif (substr($sort, 0, 4) === 'path') { |
|
| 533 | + array_multisort($cols['path'], $sort_flag, SORT_REGULAR, $cols['name'], $cols['selected'], $cols['id']); |
|
| 534 | + } else { |
|
| 535 | + array_multisort($cols['selected'], $sort_flag, SORT_REGULAR, $cols['path'], $cols['name'], $cols['id']); |
|
| 536 | + } |
|
| 519 | 537 | |
| 520 | 538 | $smiley_sets = array(); |
| 521 | - foreach ($cols['id'] as $i => $id) |
|
| 522 | - $smiley_sets[] = array( |
|
| 539 | + foreach ($cols['id'] as $i => $id) { |
|
| 540 | + $smiley_sets[] = array( |
|
| 523 | 541 | 'id' => $id, |
| 524 | 542 | 'path' => $cols['path'][$i], |
| 525 | 543 | 'name' => $cols['name'][$i], |
| 526 | 544 | 'selected' => $cols['path'][$i] == $modSettings['smiley_sets_default'] |
| 527 | 545 | ); |
| 546 | + } |
|
| 528 | 547 | |
| 529 | 548 | return $smiley_sets; |
| 530 | 549 | } |
@@ -553,13 +572,14 @@ discard block |
||
| 553 | 572 | $context['smileys_dir_found'] = is_dir($context['smileys_dir']); |
| 554 | 573 | $context['smiley_sets'] = explode(',', $modSettings['smiley_sets_known']); |
| 555 | 574 | $set_names = explode("\n", $modSettings['smiley_sets_names']); |
| 556 | - foreach ($context['smiley_sets'] as $i => $set) |
|
| 557 | - $context['smiley_sets'][$i] = array( |
|
| 575 | + foreach ($context['smiley_sets'] as $i => $set) { |
|
| 576 | + $context['smiley_sets'][$i] = array( |
|
| 558 | 577 | 'id' => $i, |
| 559 | 578 | 'path' => $smcFunc['htmlspecialchars']($set), |
| 560 | 579 | 'name' => $smcFunc['htmlspecialchars']($set_names[$i]), |
| 561 | 580 | 'selected' => $set == $modSettings['smiley_sets_default'] |
| 562 | 581 | ); |
| 582 | + } |
|
| 563 | 583 | |
| 564 | 584 | // Submitting a form? |
| 565 | 585 | if (isset($_POST[$context['session_var']], $_POST['smiley_code'])) |
@@ -575,8 +595,9 @@ discard block |
||
| 575 | 595 | $_POST['smiley_filename'] = htmltrim__recursive($_POST['smiley_filename']); |
| 576 | 596 | |
| 577 | 597 | // Make sure some code was entered. |
| 578 | - if (empty($_POST['smiley_code'])) |
|
| 579 | - fatal_lang_error('smiley_has_no_code'); |
|
| 598 | + if (empty($_POST['smiley_code'])) { |
|
| 599 | + fatal_lang_error('smiley_has_no_code'); |
|
| 600 | + } |
|
| 580 | 601 | |
| 581 | 602 | // Check whether the new code has duplicates. It should be unique. |
| 582 | 603 | $request = $smcFunc['db_query']('', ' |
@@ -588,8 +609,9 @@ discard block |
||
| 588 | 609 | 'smiley_code' => $_POST['smiley_code'], |
| 589 | 610 | ) |
| 590 | 611 | ); |
| 591 | - if ($smcFunc['db_num_rows']($request) > 0) |
|
| 592 | - fatal_lang_error('smiley_not_unique'); |
|
| 612 | + if ($smcFunc['db_num_rows']($request) > 0) { |
|
| 613 | + fatal_lang_error('smiley_not_unique'); |
|
| 614 | + } |
|
| 593 | 615 | $smcFunc['db_free_result']($request); |
| 594 | 616 | |
| 595 | 617 | // If we are uploading - check all the smiley sets are writable! |
@@ -598,38 +620,44 @@ discard block |
||
| 598 | 620 | $writeErrors = array(); |
| 599 | 621 | foreach ($context['smiley_sets'] as $set) |
| 600 | 622 | { |
| 601 | - if (!is_writable($context['smileys_dir'] . '/' . un_htmlspecialchars($set['path']))) |
|
| 602 | - $writeErrors[] = $set['path']; |
|
| 623 | + if (!is_writable($context['smileys_dir'] . '/' . un_htmlspecialchars($set['path']))) { |
|
| 624 | + $writeErrors[] = $set['path']; |
|
| 625 | + } |
|
| 626 | + } |
|
| 627 | + if (!empty($writeErrors)) { |
|
| 628 | + fatal_lang_error('smileys_upload_error_notwritable', true, array(implode(', ', $writeErrors))); |
|
| 603 | 629 | } |
| 604 | - if (!empty($writeErrors)) |
|
| 605 | - fatal_lang_error('smileys_upload_error_notwritable', true, array(implode(', ', $writeErrors))); |
|
| 606 | 630 | } |
| 607 | 631 | |
| 608 | 632 | // Uploading just one smiley for all of them? |
| 609 | 633 | if (isset($_POST['sameall']) && isset($_FILES['uploadSmiley']['name']) && $_FILES['uploadSmiley']['name'] != '') |
| 610 | 634 | { |
| 611 | - if (!is_uploaded_file($_FILES['uploadSmiley']['tmp_name']) || (ini_get('open_basedir') == '' && !file_exists($_FILES['uploadSmiley']['tmp_name']))) |
|
| 612 | - fatal_lang_error('smileys_upload_error'); |
|
| 635 | + if (!is_uploaded_file($_FILES['uploadSmiley']['tmp_name']) || (ini_get('open_basedir') == '' && !file_exists($_FILES['uploadSmiley']['tmp_name']))) { |
|
| 636 | + fatal_lang_error('smileys_upload_error'); |
|
| 637 | + } |
|
| 613 | 638 | |
| 614 | 639 | // Sorry, no spaces, dots, or anything else but letters allowed. |
| 615 | 640 | $_FILES['uploadSmiley']['name'] = preg_replace(array('/\s/', '/\.[\.]+/', '/[^\w_\.\-]/'), array('_', '.', ''), $_FILES['uploadSmiley']['name']); |
| 616 | 641 | |
| 617 | 642 | // We only allow image files - it's THAT simple - no messing around here... |
| 618 | - if (!in_array(strtolower(substr(strrchr($_FILES['uploadSmiley']['name'], '.'), 1)), $allowedTypes)) |
|
| 619 | - fatal_lang_error('smileys_upload_error_types', false, array(implode(', ', $allowedTypes))); |
|
| 643 | + if (!in_array(strtolower(substr(strrchr($_FILES['uploadSmiley']['name'], '.'), 1)), $allowedTypes)) { |
|
| 644 | + fatal_lang_error('smileys_upload_error_types', false, array(implode(', ', $allowedTypes))); |
|
| 645 | + } |
|
| 620 | 646 | |
| 621 | 647 | // We only need the filename... |
| 622 | 648 | $destName = basename($_FILES['uploadSmiley']['name']); |
| 623 | 649 | |
| 624 | 650 | // Make sure they aren't trying to upload a nasty file - for their own good here! |
| 625 | - if (in_array(strtolower($destName), $disabledFiles)) |
|
| 626 | - fatal_lang_error('smileys_upload_error_illegal'); |
|
| 651 | + if (in_array(strtolower($destName), $disabledFiles)) { |
|
| 652 | + fatal_lang_error('smileys_upload_error_illegal'); |
|
| 653 | + } |
|
| 627 | 654 | |
| 628 | 655 | // Check if the file already exists... and if not move it to EVERY smiley set directory. |
| 629 | 656 | $i = 0; |
| 630 | 657 | // Keep going until we find a set the file doesn't exist in. (or maybe it exists in all of them?) |
| 631 | - while (isset($context['smiley_sets'][$i]) && file_exists($context['smileys_dir'] . '/' . un_htmlspecialchars($context['smiley_sets'][$i]['path']) . '/' . $destName)) |
|
| 632 | - $i++; |
|
| 658 | + while (isset($context['smiley_sets'][$i]) && file_exists($context['smileys_dir'] . '/' . un_htmlspecialchars($context['smiley_sets'][$i]['path']) . '/' . $destName)) { |
|
| 659 | + $i++; |
|
| 660 | + } |
|
| 633 | 661 | |
| 634 | 662 | // Okay, we're going to put the smiley right here, since it's not there yet! |
| 635 | 663 | if (isset($context['smiley_sets'][$i]['path'])) |
@@ -644,8 +672,9 @@ discard block |
||
| 644 | 672 | $currentPath = $context['smileys_dir'] . '/' . un_htmlspecialchars($context['smiley_sets'][$i]['path']) . '/' . $destName; |
| 645 | 673 | |
| 646 | 674 | // The file is already there! Don't overwrite it! |
| 647 | - if (file_exists($currentPath)) |
|
| 648 | - continue; |
|
| 675 | + if (file_exists($currentPath)) { |
|
| 676 | + continue; |
|
| 677 | + } |
|
| 649 | 678 | |
| 650 | 679 | // Okay, so copy the first one we made to here. |
| 651 | 680 | copy($smileyLocation, $currentPath); |
@@ -662,13 +691,15 @@ discard block |
||
| 662 | 691 | $newName = ''; |
| 663 | 692 | foreach ($_FILES as $name => $data) |
| 664 | 693 | { |
| 665 | - if ($_FILES[$name]['name'] == '') |
|
| 666 | - fatal_lang_error('smileys_upload_error_blank'); |
|
| 694 | + if ($_FILES[$name]['name'] == '') { |
|
| 695 | + fatal_lang_error('smileys_upload_error_blank'); |
|
| 696 | + } |
|
| 667 | 697 | |
| 668 | - if (empty($newName)) |
|
| 669 | - $newName = basename($_FILES[$name]['name']); |
|
| 670 | - elseif (basename($_FILES[$name]['name']) != $newName) |
|
| 671 | - fatal_lang_error('smileys_upload_error_name'); |
|
| 698 | + if (empty($newName)) { |
|
| 699 | + $newName = basename($_FILES[$name]['name']); |
|
| 700 | + } elseif (basename($_FILES[$name]['name']) != $newName) { |
|
| 701 | + fatal_lang_error('smileys_upload_error_name'); |
|
| 702 | + } |
|
| 672 | 703 | } |
| 673 | 704 | |
| 674 | 705 | foreach ($context['smiley_sets'] as $i => $set) |
@@ -676,31 +707,36 @@ discard block |
||
| 676 | 707 | $set['name'] = un_htmlspecialchars($set['name']); |
| 677 | 708 | $set['path'] = un_htmlspecialchars($set['path']); |
| 678 | 709 | |
| 679 | - if (!isset($_FILES['individual_' . $set['name']]['name']) || $_FILES['individual_' . $set['name']]['name'] == '') |
|
| 680 | - continue; |
|
| 710 | + if (!isset($_FILES['individual_' . $set['name']]['name']) || $_FILES['individual_' . $set['name']]['name'] == '') { |
|
| 711 | + continue; |
|
| 712 | + } |
|
| 681 | 713 | |
| 682 | 714 | // Got one... |
| 683 | - if (!is_uploaded_file($_FILES['individual_' . $set['name']]['tmp_name']) || (ini_get('open_basedir') == '' && !file_exists($_FILES['individual_' . $set['name']]['tmp_name']))) |
|
| 684 | - fatal_lang_error('smileys_upload_error'); |
|
| 715 | + if (!is_uploaded_file($_FILES['individual_' . $set['name']]['tmp_name']) || (ini_get('open_basedir') == '' && !file_exists($_FILES['individual_' . $set['name']]['tmp_name']))) { |
|
| 716 | + fatal_lang_error('smileys_upload_error'); |
|
| 717 | + } |
|
| 685 | 718 | |
| 686 | 719 | // Sorry, no spaces, dots, or anything else but letters allowed. |
| 687 | 720 | $_FILES['individual_' . $set['name']]['name'] = preg_replace(array('/\s/', '/\.[\.]+/', '/[^\w_\.\-]/'), array('_', '.', ''), $_FILES['individual_' . $set['name']]['name']); |
| 688 | 721 | |
| 689 | 722 | // We only allow image files - it's THAT simple - no messing around here... |
| 690 | - if (!in_array(strtolower(substr(strrchr($_FILES['individual_' . $set['name']]['name'], '.'), 1)), $allowedTypes)) |
|
| 691 | - fatal_lang_error('smileys_upload_error_types', false, array(implode(', ', $allowedTypes))); |
|
| 723 | + if (!in_array(strtolower(substr(strrchr($_FILES['individual_' . $set['name']]['name'], '.'), 1)), $allowedTypes)) { |
|
| 724 | + fatal_lang_error('smileys_upload_error_types', false, array(implode(', ', $allowedTypes))); |
|
| 725 | + } |
|
| 692 | 726 | |
| 693 | 727 | // We only need the filename... |
| 694 | 728 | $destName = basename($_FILES['individual_' . $set['name']]['name']); |
| 695 | 729 | |
| 696 | 730 | // Make sure they aren't trying to upload a nasty file - for their own good here! |
| 697 | - if (in_array(strtolower($destName), $disabledFiles)) |
|
| 698 | - fatal_lang_error('smileys_upload_error_illegal'); |
|
| 731 | + if (in_array(strtolower($destName), $disabledFiles)) { |
|
| 732 | + fatal_lang_error('smileys_upload_error_illegal'); |
|
| 733 | + } |
|
| 699 | 734 | |
| 700 | 735 | // If the file exists - ignore it. |
| 701 | 736 | $smileyLocation = $context['smileys_dir'] . '/' . $set['path'] . '/' . $destName; |
| 702 | - if (file_exists($smileyLocation)) |
|
| 703 | - continue; |
|
| 737 | + if (file_exists($smileyLocation)) { |
|
| 738 | + continue; |
|
| 739 | + } |
|
| 704 | 740 | |
| 705 | 741 | // Finally - move the image! |
| 706 | 742 | move_uploaded_file($_FILES['individual_' . $set['name']]['tmp_name'], $smileyLocation); |
@@ -712,8 +748,9 @@ discard block |
||
| 712 | 748 | } |
| 713 | 749 | |
| 714 | 750 | // Also make sure a filename was given. |
| 715 | - if (empty($_POST['smiley_filename'])) |
|
| 716 | - fatal_lang_error('smiley_has_no_filename'); |
|
| 751 | + if (empty($_POST['smiley_filename'])) { |
|
| 752 | + fatal_lang_error('smiley_has_no_filename'); |
|
| 753 | + } |
|
| 717 | 754 | |
| 718 | 755 | // Find the position on the right. |
| 719 | 756 | $smiley_order = '0'; |
@@ -732,8 +769,9 @@ discard block |
||
| 732 | 769 | list ($smiley_order) = $smcFunc['db_fetch_row']($request); |
| 733 | 770 | $smcFunc['db_free_result']($request); |
| 734 | 771 | |
| 735 | - if (empty($smiley_order)) |
|
| 736 | - $smiley_order = '0'; |
|
| 772 | + if (empty($smiley_order)) { |
|
| 773 | + $smiley_order = '0'; |
|
| 774 | + } |
|
| 737 | 775 | } |
| 738 | 776 | $smcFunc['db_insert']('', |
| 739 | 777 | '{db_prefix}smileys', |
@@ -761,17 +799,19 @@ discard block |
||
| 761 | 799 | { |
| 762 | 800 | foreach ($context['smiley_sets'] as $smiley_set) |
| 763 | 801 | { |
| 764 | - if (!file_exists($context['smileys_dir'] . '/' . un_htmlspecialchars($smiley_set['path']))) |
|
| 765 | - continue; |
|
| 802 | + if (!file_exists($context['smileys_dir'] . '/' . un_htmlspecialchars($smiley_set['path']))) { |
|
| 803 | + continue; |
|
| 804 | + } |
|
| 766 | 805 | |
| 767 | 806 | $dir = dir($context['smileys_dir'] . '/' . un_htmlspecialchars($smiley_set['path'])); |
| 768 | 807 | while ($entry = $dir->read()) |
| 769 | 808 | { |
| 770 | - if (!in_array($entry, $context['filenames']) && in_array(strrchr($entry, '.'), array('.jpg', '.gif', '.jpeg', '.png'))) |
|
| 771 | - $context['filenames'][strtolower($entry)] = array( |
|
| 809 | + if (!in_array($entry, $context['filenames']) && in_array(strrchr($entry, '.'), array('.jpg', '.gif', '.jpeg', '.png'))) { |
|
| 810 | + $context['filenames'][strtolower($entry)] = array( |
|
| 772 | 811 | 'id' => $smcFunc['htmlspecialchars']($entry), |
| 773 | 812 | 'selected' => false, |
| 774 | 813 | ); |
| 814 | + } |
|
| 775 | 815 | } |
| 776 | 816 | $dir->close(); |
| 777 | 817 | } |
@@ -809,17 +849,19 @@ discard block |
||
| 809 | 849 | // Changing the selected smileys? |
| 810 | 850 | if (isset($_POST['smiley_action']) && !empty($_POST['checked_smileys'])) |
| 811 | 851 | { |
| 812 | - foreach ($_POST['checked_smileys'] as $id => $smiley_id) |
|
| 813 | - $_POST['checked_smileys'][$id] = (int) $smiley_id; |
|
| 852 | + foreach ($_POST['checked_smileys'] as $id => $smiley_id) { |
|
| 853 | + $_POST['checked_smileys'][$id] = (int) $smiley_id; |
|
| 854 | + } |
|
| 814 | 855 | |
| 815 | - if ($_POST['smiley_action'] == 'delete') |
|
| 816 | - $smcFunc['db_query']('', ' |
|
| 856 | + if ($_POST['smiley_action'] == 'delete') { |
|
| 857 | + $smcFunc['db_query']('', ' |
|
| 817 | 858 | DELETE FROM {db_prefix}smileys |
| 818 | 859 | WHERE id_smiley IN ({array_int:checked_smileys})', |
| 819 | 860 | array( |
| 820 | 861 | 'checked_smileys' => $_POST['checked_smileys'], |
| 821 | 862 | ) |
| 822 | 863 | ); |
| 864 | + } |
|
| 823 | 865 | // Changing the status of the smiley? |
| 824 | 866 | else |
| 825 | 867 | { |
@@ -829,8 +871,8 @@ discard block |
||
| 829 | 871 | 'hidden' => 1, |
| 830 | 872 | 'popup' => 2 |
| 831 | 873 | ); |
| 832 | - if (isset($displayTypes[$_POST['smiley_action']])) |
|
| 833 | - $smcFunc['db_query']('', ' |
|
| 874 | + if (isset($displayTypes[$_POST['smiley_action']])) { |
|
| 875 | + $smcFunc['db_query']('', ' |
|
| 834 | 876 | UPDATE {db_prefix}smileys |
| 835 | 877 | SET hidden = {int:display_type} |
| 836 | 878 | WHERE id_smiley IN ({array_int:checked_smileys})', |
@@ -839,6 +881,7 @@ discard block |
||
| 839 | 881 | 'display_type' => $displayTypes[$_POST['smiley_action']], |
| 840 | 882 | ) |
| 841 | 883 | ); |
| 884 | + } |
|
| 842 | 885 | } |
| 843 | 886 | } |
| 844 | 887 | // Create/modify a smiley. |
@@ -864,12 +907,14 @@ discard block |
||
| 864 | 907 | $_POST['smiley_location'] = empty($_POST['smiley_location']) || $_POST['smiley_location'] > 2 || $_POST['smiley_location'] < 0 ? 0 : (int) $_POST['smiley_location']; |
| 865 | 908 | |
| 866 | 909 | // Make sure some code was entered. |
| 867 | - if (empty($_POST['smiley_code'])) |
|
| 868 | - fatal_lang_error('smiley_has_no_code'); |
|
| 910 | + if (empty($_POST['smiley_code'])) { |
|
| 911 | + fatal_lang_error('smiley_has_no_code'); |
|
| 912 | + } |
|
| 869 | 913 | |
| 870 | 914 | // Also make sure a filename was given. |
| 871 | - if (empty($_POST['smiley_filename'])) |
|
| 872 | - fatal_lang_error('smiley_has_no_filename'); |
|
| 915 | + if (empty($_POST['smiley_filename'])) { |
|
| 916 | + fatal_lang_error('smiley_has_no_filename'); |
|
| 917 | + } |
|
| 873 | 918 | |
| 874 | 919 | // Check whether the new code has duplicates. It should be unique. |
| 875 | 920 | $request = $smcFunc['db_query']('', ' |
@@ -883,8 +928,9 @@ discard block |
||
| 883 | 928 | 'smiley_code' => $_POST['smiley_code'], |
| 884 | 929 | ) |
| 885 | 930 | ); |
| 886 | - if ($smcFunc['db_num_rows']($request) > 0) |
|
| 887 | - fatal_lang_error('smiley_not_unique'); |
|
| 931 | + if ($smcFunc['db_num_rows']($request) > 0) { |
|
| 932 | + fatal_lang_error('smiley_not_unique'); |
|
| 933 | + } |
|
| 888 | 934 | $smcFunc['db_free_result']($request); |
| 889 | 935 | |
| 890 | 936 | $smcFunc['db_query']('', ' |
@@ -913,13 +959,14 @@ discard block |
||
| 913 | 959 | // Load all known smiley sets. |
| 914 | 960 | $context['smiley_sets'] = explode(',', $modSettings['smiley_sets_known']); |
| 915 | 961 | $set_names = explode("\n", $modSettings['smiley_sets_names']); |
| 916 | - foreach ($context['smiley_sets'] as $i => $set) |
|
| 917 | - $context['smiley_sets'][$i] = array( |
|
| 962 | + foreach ($context['smiley_sets'] as $i => $set) { |
|
| 963 | + $context['smiley_sets'][$i] = array( |
|
| 918 | 964 | 'id' => $i, |
| 919 | 965 | 'path' => $smcFunc['htmlspecialchars']($set), |
| 920 | 966 | 'name' => $smcFunc['htmlspecialchars']($set_names[$i]), |
| 921 | 967 | 'selected' => $set == $modSettings['smiley_sets_default'] |
| 922 | 968 | ); |
| 969 | + } |
|
| 923 | 970 | |
| 924 | 971 | // Prepare overview of all (custom) smileys. |
| 925 | 972 | if ($context['sub_action'] == 'editsmileys') |
@@ -935,9 +982,10 @@ discard block |
||
| 935 | 982 | // Create a list of options for selecting smiley sets. |
| 936 | 983 | $smileyset_option_list = ' |
| 937 | 984 | <select name="set" onchange="changeSet(this.options[this.selectedIndex].value);">'; |
| 938 | - foreach ($context['smiley_sets'] as $smiley_set) |
|
| 939 | - $smileyset_option_list .= ' |
|
| 985 | + foreach ($context['smiley_sets'] as $smiley_set) { |
|
| 986 | + $smileyset_option_list .= ' |
|
| 940 | 987 | <option value="' . $smiley_set['path'] . '"' . ($modSettings['smiley_sets_default'] == $smiley_set['path'] ? ' selected' : '') . '>' . $smiley_set['name'] . '</option>'; |
| 988 | + } |
|
| 941 | 989 | $smileyset_option_list .= ' |
| 942 | 990 | </select>'; |
| 943 | 991 | |
@@ -999,12 +1047,13 @@ discard block |
||
| 999 | 1047 | 'data' => array( |
| 1000 | 1048 | 'function' => function ($rowData) use ($txt) |
| 1001 | 1049 | { |
| 1002 | - if (empty($rowData['hidden'])) |
|
| 1003 | - return $txt['smileys_location_form']; |
|
| 1004 | - elseif ($rowData['hidden'] == 1) |
|
| 1005 | - return $txt['smileys_location_hidden']; |
|
| 1006 | - else |
|
| 1007 | - return $txt['smileys_location_popup']; |
|
| 1050 | + if (empty($rowData['hidden'])) { |
|
| 1051 | + return $txt['smileys_location_form']; |
|
| 1052 | + } elseif ($rowData['hidden'] == 1) { |
|
| 1053 | + return $txt['smileys_location_hidden']; |
|
| 1054 | + } else { |
|
| 1055 | + return $txt['smileys_location_popup']; |
|
| 1056 | + } |
|
| 1008 | 1057 | }, |
| 1009 | 1058 | ), |
| 1010 | 1059 | 'sort' => array( |
@@ -1019,19 +1068,22 @@ discard block |
||
| 1019 | 1068 | 'data' => array( |
| 1020 | 1069 | 'function' => function ($rowData) use ($context, $txt, $modSettings, $smcFunc) |
| 1021 | 1070 | { |
| 1022 | - if (empty($modSettings['smileys_dir']) || !is_dir($modSettings['smileys_dir'])) |
|
| 1023 | - return $smcFunc['htmlspecialchars']($rowData['description']); |
|
| 1071 | + if (empty($modSettings['smileys_dir']) || !is_dir($modSettings['smileys_dir'])) { |
|
| 1072 | + return $smcFunc['htmlspecialchars']($rowData['description']); |
|
| 1073 | + } |
|
| 1024 | 1074 | |
| 1025 | 1075 | // Check if there are smileys missing in some sets. |
| 1026 | 1076 | $missing_sets = array(); |
| 1027 | - foreach ($context['smiley_sets'] as $smiley_set) |
|
| 1028 | - if (!file_exists(sprintf('%1$s/%2$s/%3$s', $modSettings['smileys_dir'], $smiley_set['path'], $rowData['filename']))) |
|
| 1077 | + foreach ($context['smiley_sets'] as $smiley_set) { |
|
| 1078 | + if (!file_exists(sprintf('%1$s/%2$s/%3$s', $modSettings['smileys_dir'], $smiley_set['path'], $rowData['filename']))) |
|
| 1029 | 1079 | $missing_sets[] = $smiley_set['path']; |
| 1080 | + } |
|
| 1030 | 1081 | |
| 1031 | 1082 | $description = $smcFunc['htmlspecialchars']($rowData['description']); |
| 1032 | 1083 | |
| 1033 | - if (!empty($missing_sets)) |
|
| 1034 | - $description .= sprintf('<br><span class="smalltext"><strong>%1$s:</strong> %2$s</span>', $txt['smileys_not_found_in_set'], implode(', ', $missing_sets)); |
|
| 1084 | + if (!empty($missing_sets)) { |
|
| 1085 | + $description .= sprintf('<br><span class="smalltext"><strong>%1$s:</strong> %2$s</span>', $txt['smileys_not_found_in_set'], implode(', ', $missing_sets)); |
|
| 1086 | + } |
|
| 1035 | 1087 | |
| 1036 | 1088 | return $description; |
| 1037 | 1089 | }, |
@@ -1147,13 +1199,14 @@ discard block |
||
| 1147 | 1199 | $context['smileys_dir_found'] = is_dir($context['smileys_dir']); |
| 1148 | 1200 | $context['smiley_sets'] = explode(',', $modSettings['smiley_sets_known']); |
| 1149 | 1201 | $set_names = explode("\n", $modSettings['smiley_sets_names']); |
| 1150 | - foreach ($context['smiley_sets'] as $i => $set) |
|
| 1151 | - $context['smiley_sets'][$i] = array( |
|
| 1202 | + foreach ($context['smiley_sets'] as $i => $set) { |
|
| 1203 | + $context['smiley_sets'][$i] = array( |
|
| 1152 | 1204 | 'id' => $i, |
| 1153 | 1205 | 'path' => $smcFunc['htmlspecialchars']($set), |
| 1154 | 1206 | 'name' => $smcFunc['htmlspecialchars']($set_names[$i]), |
| 1155 | 1207 | 'selected' => $set == $modSettings['smiley_sets_default'] |
| 1156 | 1208 | ); |
| 1209 | + } |
|
| 1157 | 1210 | |
| 1158 | 1211 | $context['selected_set'] = $modSettings['smiley_sets_default']; |
| 1159 | 1212 | |
@@ -1163,17 +1216,19 @@ discard block |
||
| 1163 | 1216 | { |
| 1164 | 1217 | foreach ($context['smiley_sets'] as $smiley_set) |
| 1165 | 1218 | { |
| 1166 | - if (!file_exists($context['smileys_dir'] . '/' . un_htmlspecialchars($smiley_set['path']))) |
|
| 1167 | - continue; |
|
| 1219 | + if (!file_exists($context['smileys_dir'] . '/' . un_htmlspecialchars($smiley_set['path']))) { |
|
| 1220 | + continue; |
|
| 1221 | + } |
|
| 1168 | 1222 | |
| 1169 | 1223 | $dir = dir($context['smileys_dir'] . '/' . un_htmlspecialchars($smiley_set['path'])); |
| 1170 | 1224 | while ($entry = $dir->read()) |
| 1171 | 1225 | { |
| 1172 | - if (!in_array($entry, $context['filenames']) && in_array(strrchr($entry, '.'), array('.jpg', '.gif', '.jpeg', '.png'))) |
|
| 1173 | - $context['filenames'][strtolower($entry)] = array( |
|
| 1226 | + if (!in_array($entry, $context['filenames']) && in_array(strrchr($entry, '.'), array('.jpg', '.gif', '.jpeg', '.png'))) { |
|
| 1227 | + $context['filenames'][strtolower($entry)] = array( |
|
| 1174 | 1228 | 'id' => $smcFunc['htmlspecialchars']($entry), |
| 1175 | 1229 | 'selected' => false, |
| 1176 | 1230 | ); |
| 1231 | + } |
|
| 1177 | 1232 | } |
| 1178 | 1233 | $dir->close(); |
| 1179 | 1234 | } |
@@ -1188,8 +1243,9 @@ discard block |
||
| 1188 | 1243 | 'current_smiley' => (int) $_REQUEST['smiley'], |
| 1189 | 1244 | ) |
| 1190 | 1245 | ); |
| 1191 | - if ($smcFunc['db_num_rows']($request) != 1) |
|
| 1192 | - fatal_lang_error('smiley_not_found'); |
|
| 1246 | + if ($smcFunc['db_num_rows']($request) != 1) { |
|
| 1247 | + fatal_lang_error('smiley_not_found'); |
|
| 1248 | + } |
|
| 1193 | 1249 | $context['current_smiley'] = $smcFunc['db_fetch_assoc']($request); |
| 1194 | 1250 | $smcFunc['db_free_result']($request); |
| 1195 | 1251 | |
@@ -1197,8 +1253,9 @@ discard block |
||
| 1197 | 1253 | $context['current_smiley']['filename'] = $smcFunc['htmlspecialchars']($context['current_smiley']['filename']); |
| 1198 | 1254 | $context['current_smiley']['description'] = $smcFunc['htmlspecialchars']($context['current_smiley']['description']); |
| 1199 | 1255 | |
| 1200 | - if (isset($context['filenames'][strtolower($context['current_smiley']['filename'])])) |
|
| 1201 | - $context['filenames'][strtolower($context['current_smiley']['filename'])]['selected'] = true; |
|
| 1256 | + if (isset($context['filenames'][strtolower($context['current_smiley']['filename'])])) { |
|
| 1257 | + $context['filenames'][strtolower($context['current_smiley']['filename'])]['selected'] = true; |
|
| 1258 | + } |
|
| 1202 | 1259 | } |
| 1203 | 1260 | } |
| 1204 | 1261 | |
@@ -1223,8 +1280,9 @@ discard block |
||
| 1223 | 1280 | ) |
| 1224 | 1281 | ); |
| 1225 | 1282 | $smileys = array(); |
| 1226 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1227 | - $smileys[] = $row; |
|
| 1283 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1284 | + $smileys[] = $row; |
|
| 1285 | + } |
|
| 1228 | 1286 | $smcFunc['db_free_result']($request); |
| 1229 | 1287 | |
| 1230 | 1288 | return $smileys; |
@@ -1264,8 +1322,9 @@ discard block |
||
| 1264 | 1322 | $_GET['location'] = empty($_GET['location']) || $_GET['location'] != 'popup' ? 0 : 2; |
| 1265 | 1323 | $_GET['source'] = empty($_GET['source']) ? 0 : (int) $_GET['source']; |
| 1266 | 1324 | |
| 1267 | - if (empty($_GET['source'])) |
|
| 1268 | - fatal_lang_error('smiley_not_found'); |
|
| 1325 | + if (empty($_GET['source'])) { |
|
| 1326 | + fatal_lang_error('smiley_not_found'); |
|
| 1327 | + } |
|
| 1269 | 1328 | |
| 1270 | 1329 | if (!empty($_GET['after'])) |
| 1271 | 1330 | { |
@@ -1281,12 +1340,12 @@ discard block |
||
| 1281 | 1340 | 'after_smiley' => $_GET['after'], |
| 1282 | 1341 | ) |
| 1283 | 1342 | ); |
| 1284 | - if ($smcFunc['db_num_rows']($request) != 1) |
|
| 1285 | - fatal_lang_error('smiley_not_found'); |
|
| 1343 | + if ($smcFunc['db_num_rows']($request) != 1) { |
|
| 1344 | + fatal_lang_error('smiley_not_found'); |
|
| 1345 | + } |
|
| 1286 | 1346 | list ($smiley_row, $smiley_order, $smileyLocation) = $smcFunc['db_fetch_row']($request); |
| 1287 | 1347 | $smcFunc['db_free_result']($request); |
| 1288 | - } |
|
| 1289 | - else |
|
| 1348 | + } else |
|
| 1290 | 1349 | { |
| 1291 | 1350 | $smiley_row = (int) $_GET['row']; |
| 1292 | 1351 | $smiley_order = -1; |
@@ -1360,14 +1419,15 @@ discard block |
||
| 1360 | 1419 | $context['move_smiley'] = empty($_REQUEST['move']) ? 0 : (int) $_REQUEST['move']; |
| 1361 | 1420 | |
| 1362 | 1421 | // Make sure all rows are sequential. |
| 1363 | - foreach (array_keys($context['smileys']) as $location) |
|
| 1364 | - $context['smileys'][$location] = array( |
|
| 1422 | + foreach (array_keys($context['smileys']) as $location) { |
|
| 1423 | + $context['smileys'][$location] = array( |
|
| 1365 | 1424 | 'id' => $location, |
| 1366 | 1425 | 'title' => $location == 'postform' ? $txt['smileys_location_form'] : $txt['smileys_location_popup'], |
| 1367 | 1426 | 'description' => $location == 'postform' ? $txt['smileys_location_form_description'] : $txt['smileys_location_popup_description'], |
| 1368 | 1427 | 'last_row' => count($context['smileys'][$location]['rows']), |
| 1369 | 1428 | 'rows' => array_values($context['smileys'][$location]['rows']), |
| 1370 | 1429 | ); |
| 1430 | + } |
|
| 1371 | 1431 | |
| 1372 | 1432 | // Check & fix smileys that are not ordered properly in the database. |
| 1373 | 1433 | foreach (array_keys($context['smileys']) as $location) |
@@ -1392,8 +1452,8 @@ discard block |
||
| 1392 | 1452 | $context['smileys'][$location]['rows'][$id][0]['row'] = $id; |
| 1393 | 1453 | } |
| 1394 | 1454 | // Make sure the smiley order is always sequential. |
| 1395 | - foreach ($smiley_row as $order_id => $smiley) |
|
| 1396 | - if ($order_id != $smiley['order']) |
|
| 1455 | + foreach ($smiley_row as $order_id => $smiley) { |
|
| 1456 | + if ($order_id != $smiley['order']) |
|
| 1397 | 1457 | $smcFunc['db_query']('', ' |
| 1398 | 1458 | UPDATE {db_prefix}smileys |
| 1399 | 1459 | SET smiley_order = {int:new_order} |
@@ -1403,6 +1463,7 @@ discard block |
||
| 1403 | 1463 | 'current_smiley' => $smiley['id'], |
| 1404 | 1464 | ) |
| 1405 | 1465 | ); |
| 1466 | + } |
|
| 1406 | 1467 | } |
| 1407 | 1468 | } |
| 1408 | 1469 | |
@@ -1436,19 +1497,20 @@ discard block |
||
| 1436 | 1497 | |
| 1437 | 1498 | // Check that the smiley is from simplemachines.org, for now... maybe add mirroring later. |
| 1438 | 1499 | // @ TODO: Our current xml files serve http links. Allowing both for now until we serve https. |
| 1439 | - if (preg_match('~^https?://[\w_\-]+\.simplemachines\.org/~', $_REQUEST['set_gz']) == 0 || strpos($_REQUEST['set_gz'], 'dlattach') !== false) |
|
| 1440 | - fatal_lang_error('not_on_simplemachines'); |
|
| 1500 | + if (preg_match('~^https?://[\w_\-]+\.simplemachines\.org/~', $_REQUEST['set_gz']) == 0 || strpos($_REQUEST['set_gz'], 'dlattach') !== false) { |
|
| 1501 | + fatal_lang_error('not_on_simplemachines'); |
|
| 1502 | + } |
|
| 1441 | 1503 | |
| 1442 | 1504 | $destination = $packagesdir . '/' . $base_name; |
| 1443 | 1505 | |
| 1444 | - if (file_exists($destination)) |
|
| 1445 | - fatal_lang_error('package_upload_error_exists'); |
|
| 1506 | + if (file_exists($destination)) { |
|
| 1507 | + fatal_lang_error('package_upload_error_exists'); |
|
| 1508 | + } |
|
| 1446 | 1509 | |
| 1447 | 1510 | // Let's copy it to the Packages directory |
| 1448 | 1511 | file_put_contents($destination, fetch_web_data($_REQUEST['set_gz'])); |
| 1449 | 1512 | $testing = true; |
| 1450 | - } |
|
| 1451 | - elseif (isset($_REQUEST['package'])) |
|
| 1513 | + } elseif (isset($_REQUEST['package'])) |
|
| 1452 | 1514 | { |
| 1453 | 1515 | $base_name = basename($_REQUEST['package']); |
| 1454 | 1516 | $name = $smcFunc['htmlspecialchars'](strtok(basename($_REQUEST['package']), '.')); |
@@ -1457,12 +1519,14 @@ discard block |
||
| 1457 | 1519 | $destination = $packagesdir . '/' . basename($_REQUEST['package']); |
| 1458 | 1520 | } |
| 1459 | 1521 | |
| 1460 | - if (empty($destination) || !file_exists($destination)) |
|
| 1461 | - fatal_lang_error('package_no_file', false); |
|
| 1522 | + if (empty($destination) || !file_exists($destination)) { |
|
| 1523 | + fatal_lang_error('package_no_file', false); |
|
| 1524 | + } |
|
| 1462 | 1525 | |
| 1463 | 1526 | // Make sure temp directory exists and is empty. |
| 1464 | - if (file_exists($packagesdir . '/temp')) |
|
| 1465 | - deltree($packagesdir . '/temp', false); |
|
| 1527 | + if (file_exists($packagesdir . '/temp')) { |
|
| 1528 | + deltree($packagesdir . '/temp', false); |
|
| 1529 | + } |
|
| 1466 | 1530 | |
| 1467 | 1531 | if (!mktree($packagesdir . '/temp', 0755)) |
| 1468 | 1532 | { |
@@ -1474,31 +1538,37 @@ discard block |
||
| 1474 | 1538 | create_chmod_control(array($packagesdir . '/temp/delme.tmp'), array('destination_url' => $scripturl . '?action=admin;area=smileys;sa=install;set_gz=' . $_REQUEST['set_gz'], 'crash_on_error' => true)); |
| 1475 | 1539 | |
| 1476 | 1540 | deltree($packagesdir . '/temp', false); |
| 1477 | - if (!mktree($packagesdir . '/temp', 0777)) |
|
| 1478 | - fatal_lang_error('package_cant_download', false); |
|
| 1541 | + if (!mktree($packagesdir . '/temp', 0777)) { |
|
| 1542 | + fatal_lang_error('package_cant_download', false); |
|
| 1543 | + } |
|
| 1479 | 1544 | } |
| 1480 | 1545 | } |
| 1481 | 1546 | |
| 1482 | 1547 | $extracted = read_tgz_file($destination, $packagesdir . '/temp'); |
| 1483 | - if (!$extracted) |
|
| 1484 | - fatal_lang_error('packageget_unable', false, array('https://custom.simplemachines.org/mods/index.php?action=search;type=12;basic_search=' . $name)); |
|
| 1485 | - if ($extracted && !file_exists($packagesdir . '/temp/package-info.xml')) |
|
| 1486 | - foreach ($extracted as $file) |
|
| 1548 | + if (!$extracted) { |
|
| 1549 | + fatal_lang_error('packageget_unable', false, array('https://custom.simplemachines.org/mods/index.php?action=search;type=12;basic_search=' . $name)); |
|
| 1550 | + } |
|
| 1551 | + if ($extracted && !file_exists($packagesdir . '/temp/package-info.xml')) { |
|
| 1552 | + foreach ($extracted as $file) |
|
| 1487 | 1553 | if (basename($file['filename']) == 'package-info.xml') |
| 1488 | 1554 | { |
| 1489 | 1555 | $base_path = dirname($file['filename']) . '/'; |
| 1556 | + } |
|
| 1490 | 1557 | break; |
| 1491 | 1558 | } |
| 1492 | 1559 | |
| 1493 | - if (!isset($base_path)) |
|
| 1494 | - $base_path = ''; |
|
| 1560 | + if (!isset($base_path)) { |
|
| 1561 | + $base_path = ''; |
|
| 1562 | + } |
|
| 1495 | 1563 | |
| 1496 | - if (!file_exists($packagesdir . '/temp/' . $base_path . 'package-info.xml')) |
|
| 1497 | - fatal_lang_error('package_get_error_missing_xml', false); |
|
| 1564 | + if (!file_exists($packagesdir . '/temp/' . $base_path . 'package-info.xml')) { |
|
| 1565 | + fatal_lang_error('package_get_error_missing_xml', false); |
|
| 1566 | + } |
|
| 1498 | 1567 | |
| 1499 | 1568 | $smileyInfo = getPackageInfo($context['filename']); |
| 1500 | - if (!is_array($smileyInfo)) |
|
| 1501 | - fatal_lang_error($smileyInfo); |
|
| 1569 | + if (!is_array($smileyInfo)) { |
|
| 1570 | + fatal_lang_error($smileyInfo); |
|
| 1571 | + } |
|
| 1502 | 1572 | |
| 1503 | 1573 | // See if it is installed? |
| 1504 | 1574 | $request = $smcFunc['db_query']('', ' |
@@ -1514,8 +1584,9 @@ discard block |
||
| 1514 | 1584 | ) |
| 1515 | 1585 | ); |
| 1516 | 1586 | |
| 1517 | - if ($smcFunc['db_num_rows']($request) > 0) |
|
| 1518 | - fatal_lang_error('package_installed_warning1'); |
|
| 1587 | + if ($smcFunc['db_num_rows']($request) > 0) { |
|
| 1588 | + fatal_lang_error('package_installed_warning1'); |
|
| 1589 | + } |
|
| 1519 | 1590 | |
| 1520 | 1591 | // Everything is fine, now it's time to do something |
| 1521 | 1592 | $actions = parsePackageInfo($smileyInfo['xml'], true, 'install'); |
@@ -1532,23 +1603,23 @@ discard block |
||
| 1532 | 1603 | { |
| 1533 | 1604 | $has_readme = true; |
| 1534 | 1605 | $type = 'package_' . $action['type']; |
| 1535 | - if (file_exists($packagesdir . '/temp/' . $base_path . $action['filename'])) |
|
| 1536 | - $context[$type] = $smcFunc['htmlspecialchars'](trim(file_get_contents($packagesdir . '/temp/' . $base_path . $action['filename']), "\n\r")); |
|
| 1537 | - elseif (file_exists($action['filename'])) |
|
| 1538 | - $context[$type] = $smcFunc['htmlspecialchars'](trim(file_get_contents($action['filename']), "\n\r")); |
|
| 1606 | + if (file_exists($packagesdir . '/temp/' . $base_path . $action['filename'])) { |
|
| 1607 | + $context[$type] = $smcFunc['htmlspecialchars'](trim(file_get_contents($packagesdir . '/temp/' . $base_path . $action['filename']), "\n\r")); |
|
| 1608 | + } elseif (file_exists($action['filename'])) { |
|
| 1609 | + $context[$type] = $smcFunc['htmlspecialchars'](trim(file_get_contents($action['filename']), "\n\r")); |
|
| 1610 | + } |
|
| 1539 | 1611 | |
| 1540 | 1612 | if (!empty($action['parse_bbc'])) |
| 1541 | 1613 | { |
| 1542 | 1614 | require_once($sourcedir . '/Subs-Post.php'); |
| 1543 | 1615 | preparsecode($context[$type]); |
| 1544 | 1616 | $context[$type] = parse_bbc($context[$type]); |
| 1617 | + } else { |
|
| 1618 | + $context[$type] = nl2br($context[$type]); |
|
| 1545 | 1619 | } |
| 1546 | - else |
|
| 1547 | - $context[$type] = nl2br($context[$type]); |
|
| 1548 | 1620 | |
| 1549 | 1621 | continue; |
| 1550 | - } |
|
| 1551 | - elseif ($action['type'] == 'require-dir') |
|
| 1622 | + } elseif ($action['type'] == 'require-dir') |
|
| 1552 | 1623 | { |
| 1553 | 1624 | // Do this one... |
| 1554 | 1625 | $thisAction = array( |
@@ -1567,12 +1638,12 @@ discard block |
||
| 1567 | 1638 | ); |
| 1568 | 1639 | } |
| 1569 | 1640 | // @todo None given? |
| 1570 | - if (empty($thisAction['description'])) |
|
| 1571 | - $thisAction['description'] = isset($action['description']) ? $action['description'] : ''; |
|
| 1641 | + if (empty($thisAction['description'])) { |
|
| 1642 | + $thisAction['description'] = isset($action['description']) ? $action['description'] : ''; |
|
| 1643 | + } |
|
| 1572 | 1644 | |
| 1573 | 1645 | $context['actions'][] = $thisAction; |
| 1574 | - } |
|
| 1575 | - elseif ($action['type'] == 'credits') |
|
| 1646 | + } elseif ($action['type'] == 'credits') |
|
| 1576 | 1647 | { |
| 1577 | 1648 | // Time to build the billboard |
| 1578 | 1649 | $credits_tag = array( |
@@ -1631,12 +1702,14 @@ discard block |
||
| 1631 | 1702 | cache_put_data('posting_smileys', null, 480); |
| 1632 | 1703 | } |
| 1633 | 1704 | |
| 1634 | - if (file_exists($packagesdir . '/temp')) |
|
| 1635 | - deltree($packagesdir . '/temp'); |
|
| 1705 | + if (file_exists($packagesdir . '/temp')) { |
|
| 1706 | + deltree($packagesdir . '/temp'); |
|
| 1707 | + } |
|
| 1636 | 1708 | |
| 1637 | - if (!$testing) |
|
| 1638 | - redirectexit('action=admin;area=smileys'); |
|
| 1639 | -} |
|
| 1709 | + if (!$testing) { |
|
| 1710 | + redirectexit('action=admin;area=smileys'); |
|
| 1711 | + } |
|
| 1712 | + } |
|
| 1640 | 1713 | |
| 1641 | 1714 | /** |
| 1642 | 1715 | * A function to import new smileys from an existing directory into the database. |
@@ -1647,15 +1720,17 @@ discard block |
||
| 1647 | 1720 | { |
| 1648 | 1721 | global $modSettings, $smcFunc; |
| 1649 | 1722 | |
| 1650 | - if (empty($modSettings['smileys_dir']) || !is_dir($modSettings['smileys_dir'] . '/' . $smileyPath)) |
|
| 1651 | - fatal_lang_error('smiley_set_unable_to_import'); |
|
| 1723 | + if (empty($modSettings['smileys_dir']) || !is_dir($modSettings['smileys_dir'] . '/' . $smileyPath)) { |
|
| 1724 | + fatal_lang_error('smiley_set_unable_to_import'); |
|
| 1725 | + } |
|
| 1652 | 1726 | |
| 1653 | 1727 | $smileys = array(); |
| 1654 | 1728 | $dir = dir($modSettings['smileys_dir'] . '/' . $smileyPath); |
| 1655 | 1729 | while ($entry = $dir->read()) |
| 1656 | 1730 | { |
| 1657 | - if (in_array(strrchr($entry, '.'), array('.jpg', '.gif', '.jpeg', '.png'))) |
|
| 1658 | - $smileys[strtolower($entry)] = $entry; |
|
| 1731 | + if (in_array(strrchr($entry, '.'), array('.jpg', '.gif', '.jpeg', '.png'))) { |
|
| 1732 | + $smileys[strtolower($entry)] = $entry; |
|
| 1733 | + } |
|
| 1659 | 1734 | } |
| 1660 | 1735 | $dir->close(); |
| 1661 | 1736 | |
@@ -1668,9 +1743,10 @@ discard block |
||
| 1668 | 1743 | 'smiley_list' => $smileys, |
| 1669 | 1744 | ) |
| 1670 | 1745 | ); |
| 1671 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1672 | - if (isset($smileys[strtolower($row['filename'])])) |
|
| 1746 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1747 | + if (isset($smileys[strtolower($row['filename'])])) |
|
| 1673 | 1748 | unset($smileys[strtolower($row['filename'])]); |
| 1749 | + } |
|
| 1674 | 1750 | $smcFunc['db_free_result']($request); |
| 1675 | 1751 | |
| 1676 | 1752 | $request = $smcFunc['db_query']('', ' |
@@ -1687,9 +1763,10 @@ discard block |
||
| 1687 | 1763 | $smcFunc['db_free_result']($request); |
| 1688 | 1764 | |
| 1689 | 1765 | $new_smileys = array(); |
| 1690 | - foreach ($smileys as $smiley) |
|
| 1691 | - if (strlen($smiley) <= 48) |
|
| 1766 | + foreach ($smileys as $smiley) { |
|
| 1767 | + if (strlen($smiley) <= 48) |
|
| 1692 | 1768 | $new_smileys[] = array(':' . strtok($smiley, '.') . ':', $smiley, strtok($smiley, '.'), 0, ++$smiley_order); |
| 1769 | + } |
|
| 1693 | 1770 | |
| 1694 | 1771 | if (!empty($new_smileys)) |
| 1695 | 1772 | { |
@@ -1754,8 +1831,9 @@ discard block |
||
| 1754 | 1831 | if (isset($_POST['delete']) && !empty($_POST['checked_icons'])) |
| 1755 | 1832 | { |
| 1756 | 1833 | $deleteIcons = array(); |
| 1757 | - foreach ($_POST['checked_icons'] as $icon) |
|
| 1758 | - $deleteIcons[] = (int) $icon; |
|
| 1834 | + foreach ($_POST['checked_icons'] as $icon) { |
|
| 1835 | + $deleteIcons[] = (int) $icon; |
|
| 1836 | + } |
|
| 1759 | 1837 | |
| 1760 | 1838 | // Do the actual delete! |
| 1761 | 1839 | $smcFunc['db_query']('', ' |
@@ -1772,35 +1850,41 @@ discard block |
||
| 1772 | 1850 | $_GET['icon'] = (int) $_GET['icon']; |
| 1773 | 1851 | |
| 1774 | 1852 | // Do some preperation with the data... like check the icon exists *somewhere* |
| 1775 | - if (strpos($_POST['icon_filename'], '.png') !== false) |
|
| 1776 | - $_POST['icon_filename'] = substr($_POST['icon_filename'], 0, -4); |
|
| 1777 | - if (!file_exists($settings['default_theme_dir'] . '/images/post/' . $_POST['icon_filename'] . '.png')) |
|
| 1778 | - fatal_lang_error('icon_not_found'); |
|
| 1853 | + if (strpos($_POST['icon_filename'], '.png') !== false) { |
|
| 1854 | + $_POST['icon_filename'] = substr($_POST['icon_filename'], 0, -4); |
|
| 1855 | + } |
|
| 1856 | + if (!file_exists($settings['default_theme_dir'] . '/images/post/' . $_POST['icon_filename'] . '.png')) { |
|
| 1857 | + fatal_lang_error('icon_not_found'); |
|
| 1858 | + } |
|
| 1779 | 1859 | // There is a 16 character limit on message icons... |
| 1780 | - elseif (strlen($_POST['icon_filename']) > 16) |
|
| 1781 | - fatal_lang_error('icon_name_too_long'); |
|
| 1782 | - elseif ($_POST['icon_location'] == $_GET['icon'] && !empty($_GET['icon'])) |
|
| 1783 | - fatal_lang_error('icon_after_itself'); |
|
| 1860 | + elseif (strlen($_POST['icon_filename']) > 16) { |
|
| 1861 | + fatal_lang_error('icon_name_too_long'); |
|
| 1862 | + } elseif ($_POST['icon_location'] == $_GET['icon'] && !empty($_GET['icon'])) { |
|
| 1863 | + fatal_lang_error('icon_after_itself'); |
|
| 1864 | + } |
|
| 1784 | 1865 | |
| 1785 | 1866 | // First do the sorting... if this is an edit reduce the order of everything after it by one ;) |
| 1786 | 1867 | if ($_GET['icon'] != 0) |
| 1787 | 1868 | { |
| 1788 | 1869 | $oldOrder = $context['icons'][$_GET['icon']]['true_order']; |
| 1789 | - foreach ($context['icons'] as $id => $data) |
|
| 1790 | - if ($data['true_order'] > $oldOrder) |
|
| 1870 | + foreach ($context['icons'] as $id => $data) { |
|
| 1871 | + if ($data['true_order'] > $oldOrder) |
|
| 1791 | 1872 | $context['icons'][$id]['true_order']--; |
| 1873 | + } |
|
| 1792 | 1874 | } |
| 1793 | 1875 | |
| 1794 | 1876 | // If there are no existing icons and this is a new one, set the id to 1 (mainly for non-mysql) |
| 1795 | - if (empty($_GET['icon']) && empty($context['icons'])) |
|
| 1796 | - $_GET['icon'] = 1; |
|
| 1877 | + if (empty($_GET['icon']) && empty($context['icons'])) { |
|
| 1878 | + $_GET['icon'] = 1; |
|
| 1879 | + } |
|
| 1797 | 1880 | |
| 1798 | 1881 | // Get the new order. |
| 1799 | 1882 | $newOrder = $_POST['icon_location'] == 0 ? 0 : $context['icons'][$_POST['icon_location']]['true_order'] + 1; |
| 1800 | 1883 | // Do the same, but with the one that used to be after this icon, done to avoid conflict. |
| 1801 | - foreach ($context['icons'] as $id => $data) |
|
| 1802 | - if ($data['true_order'] >= $newOrder) |
|
| 1884 | + foreach ($context['icons'] as $id => $data) { |
|
| 1885 | + if ($data['true_order'] >= $newOrder) |
|
| 1803 | 1886 | $context['icons'][$id]['true_order']++; |
| 1887 | + } |
|
| 1804 | 1888 | |
| 1805 | 1889 | // Finally set the current icon's position! |
| 1806 | 1890 | $context['icons'][$_GET['icon']]['true_order'] = $newOrder; |
@@ -1818,8 +1902,7 @@ discard block |
||
| 1818 | 1902 | if ($id != 0) |
| 1819 | 1903 | { |
| 1820 | 1904 | $iconInsert[] = array($id, $icon['board_id'], $icon['title'], $icon['filename'], $icon['true_order']); |
| 1821 | - } |
|
| 1822 | - else |
|
| 1905 | + } else |
|
| 1823 | 1906 | { |
| 1824 | 1907 | $iconInsert_new[] = array($icon['board_id'], $icon['title'], $icon['filename'], $icon['true_order']); |
| 1825 | 1908 | } |
@@ -1844,8 +1927,9 @@ discard block |
||
| 1844 | 1927 | } |
| 1845 | 1928 | |
| 1846 | 1929 | // Unless we're adding a new thing, we'll escape |
| 1847 | - if (!isset($_POST['add'])) |
|
| 1848 | - redirectexit('action=admin;area=smileys;sa=editicons'); |
|
| 1930 | + if (!isset($_POST['add'])) { |
|
| 1931 | + redirectexit('action=admin;area=smileys;sa=editicons'); |
|
| 1932 | + } |
|
| 1849 | 1933 | } |
| 1850 | 1934 | |
| 1851 | 1935 | $context[$context['admin_menu_name']]['current_subsection'] = 'editicons'; |
@@ -1955,8 +2039,9 @@ discard block |
||
| 1955 | 2039 | $context['new_icon'] = !isset($_GET['icon']); |
| 1956 | 2040 | |
| 1957 | 2041 | // Get the properties of the current icon from the icon list. |
| 1958 | - if (!$context['new_icon']) |
|
| 1959 | - $context['icon'] = $context['icons'][$_GET['icon']]; |
|
| 2042 | + if (!$context['new_icon']) { |
|
| 2043 | + $context['icon'] = $context['icons'][$_GET['icon']]; |
|
| 2044 | + } |
|
| 1960 | 2045 | |
| 1961 | 2046 | // Get a list of boards needed for assigning this icon to a specific board. |
| 1962 | 2047 | $boardListOptions = array( |
@@ -1990,8 +2075,9 @@ discard block |
||
| 1990 | 2075 | ); |
| 1991 | 2076 | |
| 1992 | 2077 | $message_icons = array(); |
| 1993 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1994 | - $message_icons[] = $row; |
|
| 2078 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2079 | + $message_icons[] = $row; |
|
| 2080 | + } |
|
| 1995 | 2081 | $smcFunc['db_free_result']($request); |
| 1996 | 2082 | |
| 1997 | 2083 | return $message_icons; |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | 'value' => $txt['date'], |
| 137 | 137 | ), |
| 138 | 138 | 'data' => array( |
| 139 | - 'function' => function ($rowData) use ($txt) |
|
| 139 | + 'function' => function($rowData) use ($txt) |
|
| 140 | 140 | { |
| 141 | 141 | // Recurring every year or just a single year? |
| 142 | 142 | $year = $rowData['year'] == '0004' ? sprintf('(%1$s)', $txt['every_year']) : $rowData['year']; |
@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | checkSession(); |
| 219 | 219 | |
| 220 | 220 | // Not too long good sir? |
| 221 | - $_REQUEST['title'] = $smcFunc['substr']($_REQUEST['title'], 0, 60); |
|
| 221 | + $_REQUEST['title'] = $smcFunc['substr']($_REQUEST['title'], 0, 60); |
|
| 222 | 222 | $_REQUEST['holiday'] = isset($_REQUEST['holiday']) ? (int) $_REQUEST['holiday'] : 0; |
| 223 | 223 | |
| 224 | 224 | if (isset($_REQUEST['delete'])) |
@@ -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 | * The main controlling function doesn't have much to do... yet. |
@@ -43,8 +44,7 @@ discard block |
||
| 43 | 44 | 'settings' => 'ModifyCalendarSettings' |
| 44 | 45 | ); |
| 45 | 46 | $default = 'holidays'; |
| 46 | - } |
|
| 47 | - else |
|
| 47 | + } else |
|
| 48 | 48 | { |
| 49 | 49 | $subActions = array( |
| 50 | 50 | 'settings' => 'ModifyCalendarSettings' |
@@ -60,8 +60,8 @@ discard block |
||
| 60 | 60 | 'help' => 'calendar', |
| 61 | 61 | 'description' => $txt['calendar_settings_desc'], |
| 62 | 62 | ); |
| 63 | - if (!empty($modSettings['cal_enabled'])) |
|
| 64 | - $context[$context['admin_menu_name']]['tab_data']['tabs'] = array( |
|
| 63 | + if (!empty($modSettings['cal_enabled'])) { |
|
| 64 | + $context[$context['admin_menu_name']]['tab_data']['tabs'] = array( |
|
| 65 | 65 | 'holidays' => array( |
| 66 | 66 | 'description' => $txt['manage_holidays_desc'], |
| 67 | 67 | ), |
@@ -69,6 +69,7 @@ discard block |
||
| 69 | 69 | 'description' => $txt['calendar_settings_desc'], |
| 70 | 70 | ), |
| 71 | 71 | ); |
| 72 | + } |
|
| 72 | 73 | |
| 73 | 74 | call_integration_hook('integrate_manage_calendar', array(&$subActions)); |
| 74 | 75 | |
@@ -88,8 +89,9 @@ discard block |
||
| 88 | 89 | checkSession(); |
| 89 | 90 | validateToken('admin-mc'); |
| 90 | 91 | |
| 91 | - foreach ($_REQUEST['holiday'] as $id => $value) |
|
| 92 | - $_REQUEST['holiday'][$id] = (int) $id; |
|
| 92 | + foreach ($_REQUEST['holiday'] as $id => $value) { |
|
| 93 | + $_REQUEST['holiday'][$id] = (int) $id; |
|
| 94 | + } |
|
| 93 | 95 | |
| 94 | 96 | // Now the IDs are "safe" do the delete... |
| 95 | 97 | require_once($sourcedir . '/Subs-Calendar.php'); |
@@ -209,8 +211,9 @@ discard block |
||
| 209 | 211 | $context['sub_template'] = 'edit_holiday'; |
| 210 | 212 | |
| 211 | 213 | // Cast this for safety... |
| 212 | - if (isset($_REQUEST['holiday'])) |
|
| 213 | - $_REQUEST['holiday'] = (int) $_REQUEST['holiday']; |
|
| 214 | + if (isset($_REQUEST['holiday'])) { |
|
| 215 | + $_REQUEST['holiday'] = (int) $_REQUEST['holiday']; |
|
| 216 | + } |
|
| 214 | 217 | |
| 215 | 218 | // Submitting? |
| 216 | 219 | if (isset($_POST[$context['session_var']]) && (isset($_REQUEST['delete']) || $_REQUEST['title'] != '')) |
@@ -221,19 +224,19 @@ discard block |
||
| 221 | 224 | $_REQUEST['title'] = $smcFunc['substr']($_REQUEST['title'], 0, 60); |
| 222 | 225 | $_REQUEST['holiday'] = isset($_REQUEST['holiday']) ? (int) $_REQUEST['holiday'] : 0; |
| 223 | 226 | |
| 224 | - if (isset($_REQUEST['delete'])) |
|
| 225 | - $smcFunc['db_query']('', ' |
|
| 227 | + if (isset($_REQUEST['delete'])) { |
|
| 228 | + $smcFunc['db_query']('', ' |
|
| 226 | 229 | DELETE FROM {db_prefix}calendar_holidays |
| 227 | 230 | WHERE id_holiday = {int:selected_holiday}', |
| 228 | 231 | array( |
| 229 | 232 | 'selected_holiday' => $_REQUEST['holiday'], |
| 230 | 233 | ) |
| 231 | 234 | ); |
| 232 | - else |
|
| 235 | + } else |
|
| 233 | 236 | { |
| 234 | 237 | $date = strftime($_REQUEST['year'] <= 4 ? '0004-%m-%d' : '%Y-%m-%d', mktime(0, 0, 0, $_REQUEST['month'], $_REQUEST['day'], $_REQUEST['year'])); |
| 235 | - if (isset($_REQUEST['edit'])) |
|
| 236 | - $smcFunc['db_query']('', ' |
|
| 238 | + if (isset($_REQUEST['edit'])) { |
|
| 239 | + $smcFunc['db_query']('', ' |
|
| 237 | 240 | UPDATE {db_prefix}calendar_holidays |
| 238 | 241 | SET event_date = {date:holiday_date}, title = {string:holiday_title} |
| 239 | 242 | WHERE id_holiday = {int:selected_holiday}', |
@@ -243,8 +246,8 @@ discard block |
||
| 243 | 246 | 'holiday_title' => $_REQUEST['title'], |
| 244 | 247 | ) |
| 245 | 248 | ); |
| 246 | - else |
|
| 247 | - $smcFunc['db_insert']('', |
|
| 249 | + } else { |
|
| 250 | + $smcFunc['db_insert']('', |
|
| 248 | 251 | '{db_prefix}calendar_holidays', |
| 249 | 252 | array( |
| 250 | 253 | 'event_date' => 'date', 'title' => 'string-60', |
@@ -254,6 +257,7 @@ discard block |
||
| 254 | 257 | ), |
| 255 | 258 | array('id_holiday') |
| 256 | 259 | ); |
| 260 | + } |
|
| 257 | 261 | } |
| 258 | 262 | |
| 259 | 263 | updateSettings(array( |
@@ -265,14 +269,15 @@ discard block |
||
| 265 | 269 | } |
| 266 | 270 | |
| 267 | 271 | // Default states... |
| 268 | - if ($context['is_new']) |
|
| 269 | - $context['holiday'] = array( |
|
| 272 | + if ($context['is_new']) { |
|
| 273 | + $context['holiday'] = array( |
|
| 270 | 274 | 'id' => 0, |
| 271 | 275 | 'day' => date('d'), |
| 272 | 276 | 'month' => date('m'), |
| 273 | 277 | 'year' => '0000', |
| 274 | 278 | 'title' => '' |
| 275 | 279 | ); |
| 280 | + } |
|
| 276 | 281 | // If it's not new load the data. |
| 277 | 282 | else |
| 278 | 283 | { |
@@ -285,14 +290,15 @@ discard block |
||
| 285 | 290 | 'selected_holiday' => $_REQUEST['holiday'], |
| 286 | 291 | ) |
| 287 | 292 | ); |
| 288 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 289 | - $context['holiday'] = array( |
|
| 293 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 294 | + $context['holiday'] = array( |
|
| 290 | 295 | 'id' => $row['id_holiday'], |
| 291 | 296 | 'day' => $row['day'], |
| 292 | 297 | 'month' => $row['month'], |
| 293 | 298 | 'year' => $row['year'] <= 4 ? 0 : $row['year'], |
| 294 | 299 | 'title' => $row['title'] |
| 295 | 300 | ); |
| 301 | + } |
|
| 296 | 302 | $smcFunc['db_free_result']($request); |
| 297 | 303 | } |
| 298 | 304 | |
@@ -319,16 +325,17 @@ discard block |
||
| 319 | 325 | array( |
| 320 | 326 | ) |
| 321 | 327 | ); |
| 322 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 323 | - $boards[$row['id_board']] = $row['cat_name'] . ' - ' . $row['board_name']; |
|
| 328 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 329 | + $boards[$row['id_board']] = $row['cat_name'] . ' - ' . $row['board_name']; |
|
| 330 | + } |
|
| 324 | 331 | $smcFunc['db_free_result']($request); |
| 325 | 332 | |
| 326 | 333 | require_once($sourcedir . '/Subs-Boards.php'); |
| 327 | 334 | sortBoards($boards); |
| 328 | 335 | |
| 329 | 336 | // Look, all the calendar settings - of which there are many! |
| 330 | - if (!empty($modSettings['cal_enabled'])) |
|
| 331 | - $config_vars = array( |
|
| 337 | + if (!empty($modSettings['cal_enabled'])) { |
|
| 338 | + $config_vars = array( |
|
| 332 | 339 | array('check', 'cal_enabled'), |
| 333 | 340 | '', |
| 334 | 341 | // All the permissions: |
@@ -371,14 +378,16 @@ discard block |
||
| 371 | 378 | array('check', 'cal_short_days'), |
| 372 | 379 | array('check', 'cal_short_months'), |
| 373 | 380 | ); |
| 374 | - else |
|
| 375 | - $config_vars = array( |
|
| 381 | + } else { |
|
| 382 | + $config_vars = array( |
|
| 376 | 383 | array('check', 'cal_enabled'), |
| 377 | 384 | ); |
| 385 | + } |
|
| 378 | 386 | |
| 379 | 387 | call_integration_hook('integrate_modify_calendar_settings', array(&$config_vars)); |
| 380 | - if ($return_config) |
|
| 381 | - return $config_vars; |
|
| 388 | + if ($return_config) { |
|
| 389 | + return $config_vars; |
|
| 390 | + } |
|
| 382 | 391 | |
| 383 | 392 | // Get the settings template fired up. |
| 384 | 393 | require_once($sourcedir . '/ManageServer.php'); |
@@ -586,7 +586,7 @@ discard block |
||
| 586 | 586 | 'member_name' => $regOptions['username'], |
| 587 | 587 | 'email_address' => $regOptions['email'], |
| 588 | 588 | 'passwd' => hash_password($regOptions['username'], $regOptions['password']), |
| 589 | - 'password_salt' => substr(md5(mt_rand()), 0, 4) , |
|
| 589 | + 'password_salt' => substr(md5(mt_rand()), 0, 4), |
|
| 590 | 590 | 'posts' => 0, |
| 591 | 591 | 'date_registered' => time(), |
| 592 | 592 | 'member_ip' => $regOptions['interface'] == 'admin' ? '127.0.0.1' : $user_info['ip'], |
@@ -676,7 +676,7 @@ discard block |
||
| 676 | 676 | 'time_offset', |
| 677 | 677 | ); |
| 678 | 678 | $knownInets = array( |
| 679 | - 'member_ip','member_ip2', |
|
| 679 | + 'member_ip', 'member_ip2', |
|
| 680 | 680 | ); |
| 681 | 681 | |
| 682 | 682 | // Call an optional function to validate the users' input. |
@@ -904,7 +904,7 @@ discard block |
||
| 904 | 904 | $checkName = strtr($name, array('_' => '\\_', '%' => '\\%')); |
| 905 | 905 | |
| 906 | 906 | //when we got no wildcard we can use equal -> fast |
| 907 | - $operator = (strpos($checkName, '%') || strpos($checkName, '_') ? 'LIKE' : '=' ); |
|
| 907 | + $operator = (strpos($checkName, '%') || strpos($checkName, '_') ? 'LIKE' : '='); |
|
| 908 | 908 | |
| 909 | 909 | // Make sure they don't want someone else's name. |
| 910 | 910 | $request = $smcFunc['db_query']('', ' |
@@ -1273,7 +1273,7 @@ discard block |
||
| 1273 | 1273 | $user_info['buddies'][] = $userReceiver; |
| 1274 | 1274 | |
| 1275 | 1275 | // And add a nice alert. Don't abuse though! |
| 1276 | - if ((cache_get_data('Buddy-sent-'. $user_info['id'] .'-'. $userReceiver, 86400)) == null) |
|
| 1276 | + if ((cache_get_data('Buddy-sent-' . $user_info['id'] . '-' . $userReceiver, 86400)) == null) |
|
| 1277 | 1277 | { |
| 1278 | 1278 | $smcFunc['db_insert']('insert', |
| 1279 | 1279 | '{db_prefix}background_tasks', |
@@ -1288,7 +1288,7 @@ discard block |
||
| 1288 | 1288 | ); |
| 1289 | 1289 | |
| 1290 | 1290 | // Store this in a cache entry to avoid creating multiple alerts. Give it a long life cycle. |
| 1291 | - cache_put_data('Buddy-sent-'. $user_info['id'] .'-'. $userReceiver, '1', 86400); |
|
| 1291 | + cache_put_data('Buddy-sent-' . $user_info['id'] . '-' . $userReceiver, '1', 86400); |
|
| 1292 | 1292 | } |
| 1293 | 1293 | } |
| 1294 | 1294 | |
@@ -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 | * Delete one or more members. |
@@ -43,30 +44,32 @@ discard block |
||
| 43 | 44 | setMemoryLimit('128M'); |
| 44 | 45 | |
| 45 | 46 | // If it's not an array, make it so! |
| 46 | - if (!is_array($users)) |
|
| 47 | - $users = array($users); |
|
| 48 | - else |
|
| 49 | - $users = array_unique($users); |
|
| 47 | + if (!is_array($users)) { |
|
| 48 | + $users = array($users); |
|
| 49 | + } else { |
|
| 50 | + $users = array_unique($users); |
|
| 51 | + } |
|
| 50 | 52 | |
| 51 | 53 | // Make sure there's no void user in here. |
| 52 | 54 | $users = array_diff($users, array(0)); |
| 53 | 55 | |
| 54 | 56 | // How many are they deleting? |
| 55 | - if (empty($users)) |
|
| 56 | - return; |
|
| 57 | - elseif (count($users) == 1) |
|
| 57 | + if (empty($users)) { |
|
| 58 | + return; |
|
| 59 | + } elseif (count($users) == 1) |
|
| 58 | 60 | { |
| 59 | 61 | list ($user) = $users; |
| 60 | 62 | |
| 61 | - if ($user == $user_info['id']) |
|
| 62 | - isAllowedTo('profile_remove_own'); |
|
| 63 | - else |
|
| 64 | - isAllowedTo('profile_remove_any'); |
|
| 65 | - } |
|
| 66 | - else |
|
| 63 | + if ($user == $user_info['id']) { |
|
| 64 | + isAllowedTo('profile_remove_own'); |
|
| 65 | + } else { |
|
| 66 | + isAllowedTo('profile_remove_any'); |
|
| 67 | + } |
|
| 68 | + } else |
|
| 67 | 69 | { |
| 68 | - foreach ($users as $k => $v) |
|
| 69 | - $users[$k] = (int) $v; |
|
| 70 | + foreach ($users as $k => $v) { |
|
| 71 | + $users[$k] = (int) $v; |
|
| 72 | + } |
|
| 70 | 73 | |
| 71 | 74 | // Deleting more than one? You can't have more than one account... |
| 72 | 75 | isAllowedTo('profile_remove_any'); |
@@ -88,26 +91,30 @@ discard block |
||
| 88 | 91 | $user_log_details = array(); |
| 89 | 92 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 90 | 93 | { |
| 91 | - if ($row['is_admin']) |
|
| 92 | - $admins[] = $row['id_member']; |
|
| 94 | + if ($row['is_admin']) { |
|
| 95 | + $admins[] = $row['id_member']; |
|
| 96 | + } |
|
| 93 | 97 | $user_log_details[$row['id_member']] = array($row['id_member'], $row['member_name']); |
| 94 | 98 | } |
| 95 | 99 | $smcFunc['db_free_result']($request); |
| 96 | 100 | |
| 97 | - if (empty($user_log_details)) |
|
| 98 | - return; |
|
| 101 | + if (empty($user_log_details)) { |
|
| 102 | + return; |
|
| 103 | + } |
|
| 99 | 104 | |
| 100 | 105 | // Make sure they aren't trying to delete administrators if they aren't one. But don't bother checking if it's just themself. |
| 101 | 106 | if (!empty($admins) && ($check_not_admin || (!allowedTo('admin_forum') && (count($users) != 1 || $users[0] != $user_info['id'])))) |
| 102 | 107 | { |
| 103 | 108 | $users = array_diff($users, $admins); |
| 104 | - foreach ($admins as $id) |
|
| 105 | - unset($user_log_details[$id]); |
|
| 109 | + foreach ($admins as $id) { |
|
| 110 | + unset($user_log_details[$id]); |
|
| 111 | + } |
|
| 106 | 112 | } |
| 107 | 113 | |
| 108 | 114 | // No one left? |
| 109 | - if (empty($users)) |
|
| 110 | - return; |
|
| 115 | + if (empty($users)) { |
|
| 116 | + return; |
|
| 117 | + } |
|
| 111 | 118 | |
| 112 | 119 | // Log the action - regardless of who is deleting it. |
| 113 | 120 | $log_changes = array(); |
@@ -124,8 +131,9 @@ discard block |
||
| 124 | 131 | ); |
| 125 | 132 | |
| 126 | 133 | // Remove any cached data if enabled. |
| 127 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) |
|
| 128 | - cache_put_data('user_settings-' . $user[0], null, 60); |
|
| 134 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { |
|
| 135 | + cache_put_data('user_settings-' . $user[0], null, 60); |
|
| 136 | + } |
|
| 129 | 137 | } |
| 130 | 138 | |
| 131 | 139 | // Make these peoples' posts guest posts. |
@@ -388,8 +396,8 @@ discard block |
||
| 388 | 396 | 'buddy_list' => implode(', buddy_list) != 0 OR FIND_IN_SET(', $users), |
| 389 | 397 | ) |
| 390 | 398 | ); |
| 391 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 392 | - $smcFunc['db_query']('', ' |
|
| 399 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 400 | + $smcFunc['db_query']('', ' |
|
| 393 | 401 | UPDATE {db_prefix}members |
| 394 | 402 | SET |
| 395 | 403 | pm_ignore_list = {string:pm_ignore_list}, |
@@ -401,6 +409,7 @@ discard block |
||
| 401 | 409 | 'buddy_list' => implode(',', array_diff(explode(',', $row['buddy_list']), $users)), |
| 402 | 410 | ) |
| 403 | 411 | ); |
| 412 | + } |
|
| 404 | 413 | $smcFunc['db_free_result']($request); |
| 405 | 414 | |
| 406 | 415 | // Make sure no member's birthday is still sticking in the calendar... |
@@ -455,29 +464,34 @@ discard block |
||
| 455 | 464 | elseif ($regOptions['interface'] == 'guest') |
| 456 | 465 | { |
| 457 | 466 | // You cannot register twice... |
| 458 | - if (empty($user_info['is_guest'])) |
|
| 459 | - redirectexit(); |
|
| 467 | + if (empty($user_info['is_guest'])) { |
|
| 468 | + redirectexit(); |
|
| 469 | + } |
|
| 460 | 470 | |
| 461 | 471 | // Make sure they didn't just register with this session. |
| 462 | - if (!empty($_SESSION['just_registered']) && empty($modSettings['disableRegisterCheck'])) |
|
| 463 | - fatal_lang_error('register_only_once', false); |
|
| 472 | + if (!empty($_SESSION['just_registered']) && empty($modSettings['disableRegisterCheck'])) { |
|
| 473 | + fatal_lang_error('register_only_once', false); |
|
| 474 | + } |
|
| 464 | 475 | } |
| 465 | 476 | |
| 466 | 477 | // Spaces and other odd characters are evil... |
| 467 | 478 | $regOptions['username'] = trim(preg_replace('~[\t\n\r \x0B\0' . ($context['utf8'] ? '\x{A0}\x{AD}\x{2000}-\x{200F}\x{201F}\x{202F}\x{3000}\x{FEFF}' : '\x00-\x08\x0B\x0C\x0E-\x19\xA0') . ']+~' . ($context['utf8'] ? 'u' : ''), ' ', $regOptions['username'])); |
| 468 | 479 | |
| 469 | 480 | // @todo Separate the sprintf? |
| 470 | - if (empty($regOptions['email']) || !filter_var($regOptions['email'], FILTER_VALIDATE_EMAIL) || strlen($regOptions['email']) > 255) |
|
| 471 | - $reg_errors[] = array('lang', 'profile_error_bad_email'); |
|
| 481 | + if (empty($regOptions['email']) || !filter_var($regOptions['email'], FILTER_VALIDATE_EMAIL) || strlen($regOptions['email']) > 255) { |
|
| 482 | + $reg_errors[] = array('lang', 'profile_error_bad_email'); |
|
| 483 | + } |
|
| 472 | 484 | |
| 473 | 485 | $username_validation_errors = validateUsername(0, $regOptions['username'], true, !empty($regOptions['check_reserved_name'])); |
| 474 | - if (!empty($username_validation_errors)) |
|
| 475 | - $reg_errors = array_merge($reg_errors, $username_validation_errors); |
|
| 486 | + if (!empty($username_validation_errors)) { |
|
| 487 | + $reg_errors = array_merge($reg_errors, $username_validation_errors); |
|
| 488 | + } |
|
| 476 | 489 | |
| 477 | 490 | // Generate a validation code if it's supposed to be emailed. |
| 478 | 491 | $validation_code = ''; |
| 479 | - if ($regOptions['require'] == 'activation') |
|
| 480 | - $validation_code = generateValidationCode(); |
|
| 492 | + if ($regOptions['require'] == 'activation') { |
|
| 493 | + $validation_code = generateValidationCode(); |
|
| 494 | + } |
|
| 481 | 495 | |
| 482 | 496 | // If you haven't put in a password generate one. |
| 483 | 497 | if ($regOptions['interface'] == 'admin' && $regOptions['password'] == '') |
@@ -487,8 +501,9 @@ discard block |
||
| 487 | 501 | $regOptions['password_check'] = $regOptions['password']; |
| 488 | 502 | } |
| 489 | 503 | // Does the first password match the second? |
| 490 | - elseif ($regOptions['password'] != $regOptions['password_check']) |
|
| 491 | - $reg_errors[] = array('lang', 'passwords_dont_match'); |
|
| 504 | + elseif ($regOptions['password'] != $regOptions['password_check']) { |
|
| 505 | + $reg_errors[] = array('lang', 'passwords_dont_match'); |
|
| 506 | + } |
|
| 492 | 507 | |
| 493 | 508 | // That's kind of easy to guess... |
| 494 | 509 | if ($regOptions['password'] == '') |
@@ -502,13 +517,15 @@ discard block |
||
| 502 | 517 | $passwordError = validatePassword($regOptions['password'], $regOptions['username'], array($regOptions['email'])); |
| 503 | 518 | |
| 504 | 519 | // Password isn't legal? |
| 505 | - if ($passwordError != null) |
|
| 506 | - $reg_errors[] = array('lang', 'profile_error_password_' . $passwordError); |
|
| 520 | + if ($passwordError != null) { |
|
| 521 | + $reg_errors[] = array('lang', 'profile_error_password_' . $passwordError); |
|
| 522 | + } |
|
| 507 | 523 | } |
| 508 | 524 | |
| 509 | 525 | // You may not be allowed to register this email. |
| 510 | - if (!empty($regOptions['check_email_ban'])) |
|
| 511 | - isBannedEmail($regOptions['email'], 'cannot_register', $txt['ban_register_prohibited']); |
|
| 526 | + if (!empty($regOptions['check_email_ban'])) { |
|
| 527 | + isBannedEmail($regOptions['email'], 'cannot_register', $txt['ban_register_prohibited']); |
|
| 528 | + } |
|
| 512 | 529 | |
| 513 | 530 | // Check if the email address is in use. |
| 514 | 531 | $request = $smcFunc['db_query']('', ' |
@@ -523,8 +540,9 @@ discard block |
||
| 523 | 540 | ) |
| 524 | 541 | ); |
| 525 | 542 | // @todo Separate the sprintf? |
| 526 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
| 527 | - $reg_errors[] = array('lang', 'email_in_use', false, array($smcFunc['htmlspecialchars']($regOptions['email']))); |
|
| 543 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
| 544 | + $reg_errors[] = array('lang', 'email_in_use', false, array($smcFunc['htmlspecialchars']($regOptions['email']))); |
|
| 545 | + } |
|
| 528 | 546 | |
| 529 | 547 | $smcFunc['db_free_result']($request); |
| 530 | 548 | |
@@ -539,24 +557,27 @@ discard block |
||
| 539 | 557 | 1 = The text/index. |
| 540 | 558 | 2 = Whether to log. |
| 541 | 559 | 3 = sprintf data if necessary. */ |
| 542 | - if ($error[0] == 'lang') |
|
| 543 | - loadLanguage('Errors'); |
|
| 560 | + if ($error[0] == 'lang') { |
|
| 561 | + loadLanguage('Errors'); |
|
| 562 | + } |
|
| 544 | 563 | $message = $error[0] == 'lang' ? (empty($error[3]) ? $txt[$error[1]] : vsprintf($txt[$error[1]], $error[3])) : $error[1]; |
| 545 | 564 | |
| 546 | 565 | // What to do, what to do, what to do. |
| 547 | 566 | if ($return_errors) |
| 548 | 567 | { |
| 549 | - if (!empty($error[2])) |
|
| 550 | - log_error($message, $error[2]); |
|
| 568 | + if (!empty($error[2])) { |
|
| 569 | + log_error($message, $error[2]); |
|
| 570 | + } |
|
| 551 | 571 | $reg_errors[$key] = $message; |
| 572 | + } else { |
|
| 573 | + fatal_error($message, empty($error[2]) ? false : $error[2]); |
|
| 552 | 574 | } |
| 553 | - else |
|
| 554 | - fatal_error($message, empty($error[2]) ? false : $error[2]); |
|
| 555 | 575 | } |
| 556 | 576 | |
| 557 | 577 | // If there's any errors left return them at once! |
| 558 | - if (!empty($reg_errors)) |
|
| 559 | - return $reg_errors; |
|
| 578 | + if (!empty($reg_errors)) { |
|
| 579 | + return $reg_errors; |
|
| 580 | + } |
|
| 560 | 581 | |
| 561 | 582 | $reservedVars = array( |
| 562 | 583 | 'actual_theme_url', |
@@ -578,8 +599,9 @@ discard block |
||
| 578 | 599 | ); |
| 579 | 600 | |
| 580 | 601 | // Can't change reserved vars. |
| 581 | - if (isset($regOptions['theme_vars']) && count(array_intersect(array_keys($regOptions['theme_vars']), $reservedVars)) != 0) |
|
| 582 | - fatal_lang_error('no_theme'); |
|
| 602 | + if (isset($regOptions['theme_vars']) && count(array_intersect(array_keys($regOptions['theme_vars']), $reservedVars)) != 0) { |
|
| 603 | + fatal_lang_error('no_theme'); |
|
| 604 | + } |
|
| 583 | 605 | |
| 584 | 606 | // Some of these might be overwritten. (the lower ones that are in the arrays below.) |
| 585 | 607 | $regOptions['register_vars'] = array( |
@@ -621,14 +643,17 @@ discard block |
||
| 621 | 643 | $regOptions['register_vars']['validation_code'] = ''; |
| 622 | 644 | } |
| 623 | 645 | // Maybe it can be activated right away? |
| 624 | - elseif ($regOptions['require'] == 'nothing') |
|
| 625 | - $regOptions['register_vars']['is_activated'] = 1; |
|
| 646 | + elseif ($regOptions['require'] == 'nothing') { |
|
| 647 | + $regOptions['register_vars']['is_activated'] = 1; |
|
| 648 | + } |
|
| 626 | 649 | // Maybe it must be activated by email? |
| 627 | - elseif ($regOptions['require'] == 'activation') |
|
| 628 | - $regOptions['register_vars']['is_activated'] = 0; |
|
| 650 | + elseif ($regOptions['require'] == 'activation') { |
|
| 651 | + $regOptions['register_vars']['is_activated'] = 0; |
|
| 652 | + } |
|
| 629 | 653 | // Otherwise it must be awaiting approval! |
| 630 | - else |
|
| 631 | - $regOptions['register_vars']['is_activated'] = 3; |
|
| 654 | + else { |
|
| 655 | + $regOptions['register_vars']['is_activated'] = 3; |
|
| 656 | + } |
|
| 632 | 657 | |
| 633 | 658 | if (isset($regOptions['memberGroup'])) |
| 634 | 659 | { |
@@ -647,24 +672,28 @@ discard block |
||
| 647 | 672 | 'is_protected' => 1, |
| 648 | 673 | ) |
| 649 | 674 | ); |
| 650 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 651 | - $unassignableGroups[] = $row['id_group']; |
|
| 675 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 676 | + $unassignableGroups[] = $row['id_group']; |
|
| 677 | + } |
|
| 652 | 678 | $smcFunc['db_free_result']($request); |
| 653 | 679 | |
| 654 | - if (in_array($regOptions['register_vars']['id_group'], $unassignableGroups)) |
|
| 655 | - $regOptions['register_vars']['id_group'] = 0; |
|
| 680 | + if (in_array($regOptions['register_vars']['id_group'], $unassignableGroups)) { |
|
| 681 | + $regOptions['register_vars']['id_group'] = 0; |
|
| 682 | + } |
|
| 656 | 683 | } |
| 657 | 684 | |
| 658 | 685 | // Integrate optional member settings to be set. |
| 659 | - if (!empty($regOptions['extra_register_vars'])) |
|
| 660 | - foreach ($regOptions['extra_register_vars'] as $var => $value) |
|
| 686 | + if (!empty($regOptions['extra_register_vars'])) { |
|
| 687 | + foreach ($regOptions['extra_register_vars'] as $var => $value) |
|
| 661 | 688 | $regOptions['register_vars'][$var] = $value; |
| 689 | + } |
|
| 662 | 690 | |
| 663 | 691 | // Integrate optional user theme options to be set. |
| 664 | 692 | $theme_vars = array(); |
| 665 | - if (!empty($regOptions['theme_vars'])) |
|
| 666 | - foreach ($regOptions['theme_vars'] as $var => $value) |
|
| 693 | + if (!empty($regOptions['theme_vars'])) { |
|
| 694 | + foreach ($regOptions['theme_vars'] as $var => $value) |
|
| 667 | 695 | $theme_vars[$var] = $value; |
| 696 | + } |
|
| 668 | 697 | |
| 669 | 698 | // Right, now let's prepare for insertion. |
| 670 | 699 | $knownInts = array( |
@@ -687,14 +716,15 @@ discard block |
||
| 687 | 716 | foreach ($regOptions['register_vars'] as $var => $val) |
| 688 | 717 | { |
| 689 | 718 | $type = 'string'; |
| 690 | - if (in_array($var, $knownInts)) |
|
| 691 | - $type = 'int'; |
|
| 692 | - elseif (in_array($var, $knownFloats)) |
|
| 693 | - $type = 'float'; |
|
| 694 | - elseif (in_array($var, $knownInets)) |
|
| 695 | - $type = 'inet'; |
|
| 696 | - elseif ($var == 'birthdate') |
|
| 697 | - $type = 'date'; |
|
| 719 | + if (in_array($var, $knownInts)) { |
|
| 720 | + $type = 'int'; |
|
| 721 | + } elseif (in_array($var, $knownFloats)) { |
|
| 722 | + $type = 'float'; |
|
| 723 | + } elseif (in_array($var, $knownInets)) { |
|
| 724 | + $type = 'inet'; |
|
| 725 | + } elseif ($var == 'birthdate') { |
|
| 726 | + $type = 'date'; |
|
| 727 | + } |
|
| 698 | 728 | |
| 699 | 729 | $column_names[$var] = $type; |
| 700 | 730 | $values[$var] = $val; |
@@ -713,17 +743,19 @@ discard block |
||
| 713 | 743 | call_integration_hook('integrate_post_register', array(&$regOptions, &$theme_vars, &$memberID)); |
| 714 | 744 | |
| 715 | 745 | // Update the number of members and latest member's info - and pass the name, but remove the 's. |
| 716 | - if ($regOptions['register_vars']['is_activated'] == 1) |
|
| 717 | - updateStats('member', $memberID, $regOptions['register_vars']['real_name']); |
|
| 718 | - else |
|
| 719 | - updateStats('member'); |
|
| 746 | + if ($regOptions['register_vars']['is_activated'] == 1) { |
|
| 747 | + updateStats('member', $memberID, $regOptions['register_vars']['real_name']); |
|
| 748 | + } else { |
|
| 749 | + updateStats('member'); |
|
| 750 | + } |
|
| 720 | 751 | |
| 721 | 752 | // Theme variables too? |
| 722 | 753 | if (!empty($theme_vars)) |
| 723 | 754 | { |
| 724 | 755 | $inserts = array(); |
| 725 | - foreach ($theme_vars as $var => $val) |
|
| 726 | - $inserts[] = array($memberID, $var, $val); |
|
| 756 | + foreach ($theme_vars as $var => $val) { |
|
| 757 | + $inserts[] = array($memberID, $var, $val); |
|
| 758 | + } |
|
| 727 | 759 | $smcFunc['db_insert']('insert', |
| 728 | 760 | '{db_prefix}themes', |
| 729 | 761 | array('id_member' => 'int', 'variable' => 'string-255', 'value' => 'string-65534'), |
@@ -738,10 +770,11 @@ discard block |
||
| 738 | 770 | // Administrative registrations are a bit different... |
| 739 | 771 | if ($regOptions['interface'] == 'admin') |
| 740 | 772 | { |
| 741 | - if ($regOptions['require'] == 'activation') |
|
| 742 | - $email_message = 'admin_register_activate'; |
|
| 743 | - elseif (!empty($regOptions['send_welcome_email'])) |
|
| 744 | - $email_message = 'admin_register_immediate'; |
|
| 773 | + if ($regOptions['require'] == 'activation') { |
|
| 774 | + $email_message = 'admin_register_activate'; |
|
| 775 | + } elseif (!empty($regOptions['send_welcome_email'])) { |
|
| 776 | + $email_message = 'admin_register_immediate'; |
|
| 777 | + } |
|
| 745 | 778 | |
| 746 | 779 | if (isset($email_message)) |
| 747 | 780 | { |
@@ -792,16 +825,17 @@ discard block |
||
| 792 | 825 | 'FORGOTPASSWORDLINK' => $scripturl . '?action=reminder', |
| 793 | 826 | ); |
| 794 | 827 | |
| 795 | - if ($regOptions['require'] == 'activation') |
|
| 796 | - $replacements += array( |
|
| 828 | + if ($regOptions['require'] == 'activation') { |
|
| 829 | + $replacements += array( |
|
| 797 | 830 | 'ACTIVATIONLINK' => $scripturl . '?action=activate;u=' . $memberID . ';code=' . $validation_code, |
| 798 | 831 | 'ACTIVATIONLINKWITHOUTCODE' => $scripturl . '?action=activate;u=' . $memberID, |
| 799 | 832 | 'ACTIVATIONCODE' => $validation_code, |
| 800 | 833 | ); |
| 801 | - else |
|
| 802 | - $replacements += array( |
|
| 834 | + } else { |
|
| 835 | + $replacements += array( |
|
| 803 | 836 | 'COPPALINK' => $scripturl . '?action=coppa;u=' . $memberID, |
| 804 | 837 | ); |
| 838 | + } |
|
| 805 | 839 | |
| 806 | 840 | $emaildata = loadEmailTemplate('register_' . ($regOptions['require'] == 'activation' ? 'activate' : 'coppa'), $replacements); |
| 807 | 841 | |
@@ -866,39 +900,45 @@ discard block |
||
| 866 | 900 | // Check each name in the list... |
| 867 | 901 | foreach ($reservedNames as $reserved) |
| 868 | 902 | { |
| 869 | - if ($reserved == '') |
|
| 870 | - continue; |
|
| 903 | + if ($reserved == '') { |
|
| 904 | + continue; |
|
| 905 | + } |
|
| 871 | 906 | |
| 872 | 907 | // The admin might've used entities too, level the playing field. |
| 873 | 908 | $reservedCheck = preg_replace('~(&#(\d{1,7}|x[0-9a-fA-F]{1,6});)~', 'replaceEntities__callback', $reserved); |
| 874 | 909 | |
| 875 | 910 | // Case sensitive name? |
| 876 | - if (empty($modSettings['reserveCase'])) |
|
| 877 | - $reservedCheck = $smcFunc['strtolower']($reservedCheck); |
|
| 911 | + if (empty($modSettings['reserveCase'])) { |
|
| 912 | + $reservedCheck = $smcFunc['strtolower']($reservedCheck); |
|
| 913 | + } |
|
| 878 | 914 | |
| 879 | 915 | // If it's not just entire word, check for it in there somewhere... |
| 880 | - if ($checkMe == $reservedCheck || ($smcFunc['strpos']($checkMe, $reservedCheck) !== false && empty($modSettings['reserveWord']))) |
|
| 881 | - if ($fatal) |
|
| 916 | + if ($checkMe == $reservedCheck || ($smcFunc['strpos']($checkMe, $reservedCheck) !== false && empty($modSettings['reserveWord']))) { |
|
| 917 | + if ($fatal) |
|
| 882 | 918 | fatal_lang_error('username_reserved', 'password', array($reserved)); |
| 883 | - else |
|
| 884 | - return true; |
|
| 919 | + } else { |
|
| 920 | + return true; |
|
| 921 | + } |
|
| 885 | 922 | } |
| 886 | 923 | |
| 887 | 924 | $censor_name = $name; |
| 888 | - if (censorText($censor_name) != $name) |
|
| 889 | - if ($fatal) |
|
| 925 | + if (censorText($censor_name) != $name) { |
|
| 926 | + if ($fatal) |
|
| 890 | 927 | fatal_lang_error('name_censored', 'password', array($name)); |
| 891 | - else |
|
| 892 | - return true; |
|
| 928 | + } else { |
|
| 929 | + return true; |
|
| 930 | + } |
|
| 893 | 931 | } |
| 894 | 932 | |
| 895 | 933 | // Characters we just shouldn't allow, regardless. |
| 896 | - foreach (array('*') as $char) |
|
| 897 | - if (strpos($checkName, $char) !== false) |
|
| 934 | + foreach (array('*') as $char) { |
|
| 935 | + if (strpos($checkName, $char) !== false) |
|
| 898 | 936 | if ($fatal) |
| 899 | 937 | fatal_lang_error('username_reserved', 'password', array($char)); |
| 900 | - else |
|
| 901 | - return true; |
|
| 938 | + } |
|
| 939 | + else { |
|
| 940 | + return true; |
|
| 941 | + } |
|
| 902 | 942 | |
| 903 | 943 | // Get rid of any SQL parts of the reserved name... |
| 904 | 944 | $checkName = strtr($name, array('_' => '\\_', '%' => '\\%')); |
@@ -980,8 +1020,9 @@ discard block |
||
| 980 | 1020 | 'permission' => $permission, |
| 981 | 1021 | ) |
| 982 | 1022 | ); |
| 983 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 984 | - $member_groups[$row['add_deny'] === '1' ? 'allowed' : 'denied'][] = $row['id_group']; |
|
| 1023 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1024 | + $member_groups[$row['add_deny'] === '1' ? 'allowed' : 'denied'][] = $row['id_group']; |
|
| 1025 | + } |
|
| 985 | 1026 | $smcFunc['db_free_result']($request); |
| 986 | 1027 | } |
| 987 | 1028 | |
@@ -989,9 +1030,9 @@ discard block |
||
| 989 | 1030 | else |
| 990 | 1031 | { |
| 991 | 1032 | // First get the profile of the given board. |
| 992 | - if (isset($board_info['id']) && $board_info['id'] == $board_id) |
|
| 993 | - $profile_id = $board_info['profile']; |
|
| 994 | - elseif ($board_id !== 0) |
|
| 1033 | + if (isset($board_info['id']) && $board_info['id'] == $board_id) { |
|
| 1034 | + $profile_id = $board_info['profile']; |
|
| 1035 | + } elseif ($board_id !== 0) |
|
| 995 | 1036 | { |
| 996 | 1037 | $request = $smcFunc['db_query']('', ' |
| 997 | 1038 | SELECT id_profile |
@@ -1002,13 +1043,14 @@ discard block |
||
| 1002 | 1043 | 'id_board' => $board_id, |
| 1003 | 1044 | ) |
| 1004 | 1045 | ); |
| 1005 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 1006 | - fatal_lang_error('no_board'); |
|
| 1046 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 1047 | + fatal_lang_error('no_board'); |
|
| 1048 | + } |
|
| 1007 | 1049 | list ($profile_id) = $smcFunc['db_fetch_row']($request); |
| 1008 | 1050 | $smcFunc['db_free_result']($request); |
| 1051 | + } else { |
|
| 1052 | + $profile_id = 1; |
|
| 1009 | 1053 | } |
| 1010 | - else |
|
| 1011 | - $profile_id = 1; |
|
| 1012 | 1054 | |
| 1013 | 1055 | $request = $smcFunc['db_query']('', ' |
| 1014 | 1056 | SELECT bp.id_group, bp.add_deny |
@@ -1020,8 +1062,9 @@ discard block |
||
| 1020 | 1062 | 'permission' => $permission, |
| 1021 | 1063 | ) |
| 1022 | 1064 | ); |
| 1023 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1024 | - $member_groups[$row['add_deny'] === '1' ? 'allowed' : 'denied'][] = $row['id_group']; |
|
| 1065 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1066 | + $member_groups[$row['add_deny'] === '1' ? 'allowed' : 'denied'][] = $row['id_group']; |
|
| 1067 | + } |
|
| 1025 | 1068 | $smcFunc['db_free_result']($request); |
| 1026 | 1069 | |
| 1027 | 1070 | $moderator_groups = array(); |
@@ -1030,8 +1073,7 @@ discard block |
||
| 1030 | 1073 | if (isset($board_info['moderator_groups'])) |
| 1031 | 1074 | { |
| 1032 | 1075 | $moderator_groups = array_keys($board_info['moderator_groups']); |
| 1033 | - } |
|
| 1034 | - elseif ($board_id !== 0) |
|
| 1076 | + } elseif ($board_id !== 0) |
|
| 1035 | 1077 | { |
| 1036 | 1078 | // Get the groups that can moderate this board |
| 1037 | 1079 | $request = $smcFunc['db_query']('', ' |
@@ -1116,8 +1158,9 @@ discard block |
||
| 1116 | 1158 | ) |
| 1117 | 1159 | ); |
| 1118 | 1160 | $members = array(); |
| 1119 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1120 | - $members[] = $row['id_member']; |
|
| 1161 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1162 | + $members[] = $row['id_member']; |
|
| 1163 | + } |
|
| 1121 | 1164 | $smcFunc['db_free_result']($request); |
| 1122 | 1165 | |
| 1123 | 1166 | return $members; |
@@ -1190,10 +1233,12 @@ discard block |
||
| 1190 | 1233 | } |
| 1191 | 1234 | |
| 1192 | 1235 | $query_parts = array(); |
| 1193 | - if (!empty($email)) |
|
| 1194 | - $query_parts[] = 'poster_email = {string:email_address}'; |
|
| 1195 | - if (!empty($membername)) |
|
| 1196 | - $query_parts[] = 'poster_name = {string:member_name}'; |
|
| 1236 | + if (!empty($email)) { |
|
| 1237 | + $query_parts[] = 'poster_email = {string:email_address}'; |
|
| 1238 | + } |
|
| 1239 | + if (!empty($membername)) { |
|
| 1240 | + $query_parts[] = 'poster_name = {string:member_name}'; |
|
| 1241 | + } |
|
| 1197 | 1242 | $query = implode(' AND ', $query_parts); |
| 1198 | 1243 | |
| 1199 | 1244 | // Finally, update the posts themselves! |
@@ -1260,12 +1305,14 @@ discard block |
||
| 1260 | 1305 | |
| 1261 | 1306 | $userReceiver = (int) !empty($_REQUEST['u']) ? $_REQUEST['u'] : 0; |
| 1262 | 1307 | |
| 1263 | - if (empty($userReceiver)) |
|
| 1264 | - fatal_lang_error('no_access', false); |
|
| 1308 | + if (empty($userReceiver)) { |
|
| 1309 | + fatal_lang_error('no_access', false); |
|
| 1310 | + } |
|
| 1265 | 1311 | |
| 1266 | 1312 | // Remove if it's already there... |
| 1267 | - if (in_array($userReceiver, $user_info['buddies'])) |
|
| 1268 | - $user_info['buddies'] = array_diff($user_info['buddies'], array($userReceiver)); |
|
| 1313 | + if (in_array($userReceiver, $user_info['buddies'])) { |
|
| 1314 | + $user_info['buddies'] = array_diff($user_info['buddies'], array($userReceiver)); |
|
| 1315 | + } |
|
| 1269 | 1316 | |
| 1270 | 1317 | // ...or add if it's not and if it's not you. |
| 1271 | 1318 | elseif ($user_info['id'] != $userReceiver) |
@@ -1340,8 +1387,9 @@ discard block |
||
| 1340 | 1387 | $smcFunc['db_free_result']($request); |
| 1341 | 1388 | |
| 1342 | 1389 | // If we want duplicates pass the members array off. |
| 1343 | - if ($get_duplicates) |
|
| 1344 | - populateDuplicateMembers($members); |
|
| 1390 | + if ($get_duplicates) { |
|
| 1391 | + populateDuplicateMembers($members); |
|
| 1392 | + } |
|
| 1345 | 1393 | |
| 1346 | 1394 | return $members; |
| 1347 | 1395 | } |
@@ -1358,8 +1406,9 @@ discard block |
||
| 1358 | 1406 | global $smcFunc, $modSettings; |
| 1359 | 1407 | |
| 1360 | 1408 | // We know how many members there are in total. |
| 1361 | - if (empty($where) || $where == '1=1') |
|
| 1362 | - $num_members = $modSettings['totalMembers']; |
|
| 1409 | + if (empty($where) || $where == '1=1') { |
|
| 1410 | + $num_members = $modSettings['totalMembers']; |
|
| 1411 | + } |
|
| 1363 | 1412 | |
| 1364 | 1413 | // The database knows the amount when there are extra conditions. |
| 1365 | 1414 | else |
@@ -1395,16 +1444,19 @@ discard block |
||
| 1395 | 1444 | $members[$key]['duplicate_members'] = array(); |
| 1396 | 1445 | |
| 1397 | 1446 | // Store the IPs. |
| 1398 | - if (!empty($member['member_ip'])) |
|
| 1399 | - $ips[] = $member['member_ip']; |
|
| 1400 | - if (!empty($member['member_ip2'])) |
|
| 1401 | - $ips[] = $member['member_ip2']; |
|
| 1447 | + if (!empty($member['member_ip'])) { |
|
| 1448 | + $ips[] = $member['member_ip']; |
|
| 1449 | + } |
|
| 1450 | + if (!empty($member['member_ip2'])) { |
|
| 1451 | + $ips[] = $member['member_ip2']; |
|
| 1452 | + } |
|
| 1402 | 1453 | } |
| 1403 | 1454 | |
| 1404 | 1455 | $ips = array_unique($ips); |
| 1405 | 1456 | |
| 1406 | - if (empty($ips)) |
|
| 1407 | - return false; |
|
| 1457 | + if (empty($ips)) { |
|
| 1458 | + return false; |
|
| 1459 | + } |
|
| 1408 | 1460 | |
| 1409 | 1461 | // Fetch all members with this IP address, we'll filter out the current ones in a sec. |
| 1410 | 1462 | $request = $smcFunc['db_query']('', ' |
@@ -1434,10 +1486,12 @@ discard block |
||
| 1434 | 1486 | 'ip2' => $row['member_ip2'], |
| 1435 | 1487 | ); |
| 1436 | 1488 | |
| 1437 | - if (in_array($row['member_ip'], $ips)) |
|
| 1438 | - $duplicate_members[$row['member_ip']][] = $member_context; |
|
| 1439 | - if ($row['member_ip'] != $row['member_ip2'] && in_array($row['member_ip2'], $ips)) |
|
| 1440 | - $duplicate_members[$row['member_ip2']][] = $member_context; |
|
| 1489 | + if (in_array($row['member_ip'], $ips)) { |
|
| 1490 | + $duplicate_members[$row['member_ip']][] = $member_context; |
|
| 1491 | + } |
|
| 1492 | + if ($row['member_ip'] != $row['member_ip2'] && in_array($row['member_ip2'], $ips)) { |
|
| 1493 | + $duplicate_members[$row['member_ip2']][] = $member_context; |
|
| 1494 | + } |
|
| 1441 | 1495 | } |
| 1442 | 1496 | $smcFunc['db_free_result']($request); |
| 1443 | 1497 | |
@@ -1462,8 +1516,9 @@ discard block |
||
| 1462 | 1516 | $row['poster_ip'] = inet_dtop($row['poster_ip']); |
| 1463 | 1517 | |
| 1464 | 1518 | // Don't collect lots of the same. |
| 1465 | - if (isset($had_ips[$row['poster_ip']]) && in_array($row['id_member'], $had_ips[$row['poster_ip']])) |
|
| 1466 | - continue; |
|
| 1519 | + if (isset($had_ips[$row['poster_ip']]) && in_array($row['id_member'], $had_ips[$row['poster_ip']])) { |
|
| 1520 | + continue; |
|
| 1521 | + } |
|
| 1467 | 1522 | $had_ips[$row['poster_ip']][] = $row['id_member']; |
| 1468 | 1523 | |
| 1469 | 1524 | $duplicate_members[$row['poster_ip']][] = array( |
@@ -1478,13 +1533,15 @@ discard block |
||
| 1478 | 1533 | $smcFunc['db_free_result']($request); |
| 1479 | 1534 | |
| 1480 | 1535 | // Now we have all the duplicate members, stick them with their respective member in the list. |
| 1481 | - if (!empty($duplicate_members)) |
|
| 1482 | - foreach ($members as $key => $member) |
|
| 1536 | + if (!empty($duplicate_members)) { |
|
| 1537 | + foreach ($members as $key => $member) |
|
| 1483 | 1538 | { |
| 1484 | 1539 | if (isset($duplicate_members[$member['member_ip']])) |
| 1485 | 1540 | $members[$key]['duplicate_members'] = $duplicate_members[$member['member_ip']]; |
| 1486 | - if ($member['member_ip'] != $member['member_ip2'] && isset($duplicate_members[$member['member_ip2']])) |
|
| 1487 | - $members[$key]['duplicate_members'] = array_merge($member['duplicate_members'], $duplicate_members[$member['member_ip2']]); |
|
| 1541 | + } |
|
| 1542 | + if ($member['member_ip'] != $member['member_ip2'] && isset($duplicate_members[$member['member_ip2']])) { |
|
| 1543 | + $members[$key]['duplicate_members'] = array_merge($member['duplicate_members'], $duplicate_members[$member['member_ip2']]); |
|
| 1544 | + } |
|
| 1488 | 1545 | |
| 1489 | 1546 | // Check we don't have lots of the same member. |
| 1490 | 1547 | $member_track = array($member['id_member']); |
@@ -59,8 +59,9 @@ discard block |
||
| 59 | 59 | * @version 2.1 Beta 3 |
| 60 | 60 | */ |
| 61 | 61 | |
| 62 | -if (!defined('SMF')) |
|
| 62 | +if (!defined('SMF')) { |
|
| 63 | 63 | die('No direct access...'); |
| 64 | +} |
|
| 64 | 65 | |
| 65 | 66 | /** |
| 66 | 67 | * This is the main dispatcher. Sets up all the available sub-actions, all the tabs and selects |
@@ -111,10 +112,11 @@ discard block |
||
| 111 | 112 | $settings_not_writable = !is_writable($boarddir . '/Settings.php'); |
| 112 | 113 | $settings_backup_fail = !@is_writable($boarddir . '/Settings_bak.php') || !@copy($boarddir . '/Settings.php', $boarddir . '/Settings_bak.php'); |
| 113 | 114 | |
| 114 | - if ($settings_not_writable) |
|
| 115 | - $context['settings_message'] = '<div class="centertext"><strong>' . $txt['settings_not_writable'] . '</strong></div><br>'; |
|
| 116 | - elseif ($settings_backup_fail) |
|
| 117 | - $context['settings_message'] = '<div class="centertext"><strong>' . $txt['admin_backup_fail'] . '</strong></div><br>'; |
|
| 115 | + if ($settings_not_writable) { |
|
| 116 | + $context['settings_message'] = '<div class="centertext"><strong>' . $txt['settings_not_writable'] . '</strong></div><br>'; |
|
| 117 | + } elseif ($settings_backup_fail) { |
|
| 118 | + $context['settings_message'] = '<div class="centertext"><strong>' . $txt['admin_backup_fail'] . '</strong></div><br>'; |
|
| 119 | + } |
|
| 118 | 120 | |
| 119 | 121 | $context['settings_not_writable'] = $settings_not_writable; |
| 120 | 122 | |
@@ -166,8 +168,9 @@ discard block |
||
| 166 | 168 | |
| 167 | 169 | call_integration_hook('integrate_general_settings', array(&$config_vars)); |
| 168 | 170 | |
| 169 | - if ($return_config) |
|
| 170 | - return $config_vars; |
|
| 171 | + if ($return_config) { |
|
| 172 | + return $config_vars; |
|
| 173 | + } |
|
| 171 | 174 | |
| 172 | 175 | // Setup the template stuff. |
| 173 | 176 | $context['post_url'] = $scripturl . '?action=admin;area=serversettings;sa=general;save'; |
@@ -232,8 +235,9 @@ discard block |
||
| 232 | 235 | |
| 233 | 236 | call_integration_hook('integrate_database_settings', array(&$config_vars)); |
| 234 | 237 | |
| 235 | - if ($return_config) |
|
| 236 | - return $config_vars; |
|
| 238 | + if ($return_config) { |
|
| 239 | + return $config_vars; |
|
| 240 | + } |
|
| 237 | 241 | |
| 238 | 242 | // Setup the template stuff. |
| 239 | 243 | $context['post_url'] = $scripturl . '?action=admin;area=serversettings;sa=database;save'; |
@@ -308,13 +312,15 @@ discard block |
||
| 308 | 312 | hideGlobalCookies(); |
| 309 | 313 | });', true); |
| 310 | 314 | |
| 311 | - if (empty($user_settings['tfa_secret'])) |
|
| 312 | - addInlineJavaScript(''); |
|
| 315 | + if (empty($user_settings['tfa_secret'])) { |
|
| 316 | + addInlineJavaScript(''); |
|
| 317 | + } |
|
| 313 | 318 | |
| 314 | 319 | call_integration_hook('integrate_cookie_settings', array(&$config_vars)); |
| 315 | 320 | |
| 316 | - if ($return_config) |
|
| 317 | - return $config_vars; |
|
| 321 | + if ($return_config) { |
|
| 322 | + return $config_vars; |
|
| 323 | + } |
|
| 318 | 324 | |
| 319 | 325 | $context['post_url'] = $scripturl . '?action=admin;area=serversettings;sa=cookie;save'; |
| 320 | 326 | $context['settings_title'] = $txt['cookies_sessions_settings']; |
@@ -325,11 +331,13 @@ discard block |
||
| 325 | 331 | call_integration_hook('integrate_save_cookie_settings'); |
| 326 | 332 | |
| 327 | 333 | // Local and global do not play nicely together. |
| 328 | - if (!empty($_POST['localCookies']) && empty($_POST['globalCookies'])) |
|
| 329 | - unset ($_POST['globalCookies']); |
|
| 334 | + if (!empty($_POST['localCookies']) && empty($_POST['globalCookies'])) { |
|
| 335 | + unset ($_POST['globalCookies']); |
|
| 336 | + } |
|
| 330 | 337 | |
| 331 | - if (!empty($_POST['globalCookiesDomain']) && strpos($boardurl, $_POST['globalCookiesDomain']) === false) |
|
| 332 | - fatal_lang_error('invalid_cookie_domain', false); |
|
| 338 | + if (!empty($_POST['globalCookiesDomain']) && strpos($boardurl, $_POST['globalCookiesDomain']) === false) { |
|
| 339 | + fatal_lang_error('invalid_cookie_domain', false); |
|
| 340 | + } |
|
| 333 | 341 | |
| 334 | 342 | saveSettings($config_vars); |
| 335 | 343 | |
@@ -412,8 +420,9 @@ discard block |
||
| 412 | 420 | |
| 413 | 421 | call_integration_hook('integrate_general_security_settings', array(&$config_vars)); |
| 414 | 422 | |
| 415 | - if ($return_config) |
|
| 416 | - return $config_vars; |
|
| 423 | + if ($return_config) { |
|
| 424 | + return $config_vars; |
|
| 425 | + } |
|
| 417 | 426 | |
| 418 | 427 | // Saving? |
| 419 | 428 | if (isset($_GET['save'])) |
@@ -452,8 +461,7 @@ discard block |
||
| 452 | 461 | $txt['cache_settings_message'] = $txt['detected_no_caching']; |
| 453 | 462 | $cache_level = array($txt['cache_off']); |
| 454 | 463 | $detected['none'] = $txt['cache_off']; |
| 455 | - } |
|
| 456 | - else |
|
| 464 | + } else |
|
| 457 | 465 | { |
| 458 | 466 | $txt['cache_settings_message'] = sprintf($txt['detected_accelerators'], implode(', ', $detected)); |
| 459 | 467 | $cache_level = array($txt['cache_off'], $txt['cache_level1'], $txt['cache_level2'], $txt['cache_level3']); |
@@ -490,8 +498,9 @@ discard block |
||
| 490 | 498 | } |
| 491 | 499 | } |
| 492 | 500 | } |
| 493 | - if ($return_config) |
|
| 494 | - return $config_vars; |
|
| 501 | + if ($return_config) { |
|
| 502 | + return $config_vars; |
|
| 503 | + } |
|
| 495 | 504 | |
| 496 | 505 | // Saving again? |
| 497 | 506 | if (isset($_GET['save'])) |
@@ -519,8 +528,9 @@ discard block |
||
| 519 | 528 | $context['save_disabled'] = $context['settings_not_writable']; |
| 520 | 529 | |
| 521 | 530 | // Decide what message to show. |
| 522 | - if (!$context['save_disabled']) |
|
| 523 | - $context['settings_message'] = $txt['caching_information']; |
|
| 531 | + if (!$context['save_disabled']) { |
|
| 532 | + $context['settings_message'] = $txt['caching_information']; |
|
| 533 | + } |
|
| 524 | 534 | |
| 525 | 535 | // Prepare the template. |
| 526 | 536 | prepareServerSettingsContext($config_vars); |
@@ -543,24 +553,25 @@ discard block |
||
| 543 | 553 | if (stripos(PHP_OS, 'win') === 0) |
| 544 | 554 | { |
| 545 | 555 | $context['settings_message'] = $txt['loadavg_disabled_windows']; |
| 546 | - if (isset($_GET['save'])) |
|
| 547 | - $_SESSION['adm-save'] = $txt['loadavg_disabled_windows']; |
|
| 548 | - } |
|
| 549 | - elseif (stripos(PHP_OS, 'darwin') === 0) |
|
| 556 | + if (isset($_GET['save'])) { |
|
| 557 | + $_SESSION['adm-save'] = $txt['loadavg_disabled_windows']; |
|
| 558 | + } |
|
| 559 | + } elseif (stripos(PHP_OS, 'darwin') === 0) |
|
| 550 | 560 | { |
| 551 | 561 | $context['settings_message'] = $txt['loadavg_disabled_osx']; |
| 552 | - if (isset($_GET['save'])) |
|
| 553 | - $_SESSION['adm-save'] = $txt['loadavg_disabled_osx']; |
|
| 554 | - } |
|
| 555 | - else |
|
| 562 | + if (isset($_GET['save'])) { |
|
| 563 | + $_SESSION['adm-save'] = $txt['loadavg_disabled_osx']; |
|
| 564 | + } |
|
| 565 | + } else |
|
| 556 | 566 | { |
| 557 | 567 | $modSettings['load_average'] = @file_get_contents('/proc/loadavg'); |
| 558 | - if (!empty($modSettings['load_average']) && preg_match('~^([^ ]+?) ([^ ]+?) ([^ ]+)~', $modSettings['load_average'], $matches) !== 0) |
|
| 559 | - $modSettings['load_average'] = (float) $matches[1]; |
|
| 560 | - elseif (($modSettings['load_average'] = @`uptime`) !== null && preg_match('~load averages?: (\d+\.\d+), (\d+\.\d+), (\d+\.\d+)~i', $modSettings['load_average'], $matches) !== 0) |
|
| 561 | - $modSettings['load_average'] = (float) $matches[1]; |
|
| 562 | - else |
|
| 563 | - unset($modSettings['load_average']); |
|
| 568 | + if (!empty($modSettings['load_average']) && preg_match('~^([^ ]+?) ([^ ]+?) ([^ ]+)~', $modSettings['load_average'], $matches) !== 0) { |
|
| 569 | + $modSettings['load_average'] = (float) $matches[1]; |
|
| 570 | + } elseif (($modSettings['load_average'] = @`uptime`) !== null && preg_match('~load averages?: (\d+\.\d+), (\d+\.\d+), (\d+\.\d+)~i', $modSettings['load_average'], $matches) !== 0) { |
|
| 571 | + $modSettings['load_average'] = (float) $matches[1]; |
|
| 572 | + } else { |
|
| 573 | + unset($modSettings['load_average']); |
|
| 574 | + } |
|
| 564 | 575 | |
| 565 | 576 | if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0) |
| 566 | 577 | { |
@@ -596,8 +607,9 @@ discard block |
||
| 596 | 607 | |
| 597 | 608 | call_integration_hook('integrate_loadavg_settings', array(&$config_vars)); |
| 598 | 609 | |
| 599 | - if ($return_config) |
|
| 600 | - return $config_vars; |
|
| 610 | + if ($return_config) { |
|
| 611 | + return $config_vars; |
|
| 612 | + } |
|
| 601 | 613 | |
| 602 | 614 | $context['post_url'] = $scripturl . '?action=admin;area=serversettings;sa=loads;save'; |
| 603 | 615 | $context['settings_title'] = $txt['load_balancing_settings']; |
@@ -608,24 +620,27 @@ discard block |
||
| 608 | 620 | // Stupidity is not allowed. |
| 609 | 621 | foreach ($_POST as $key => $value) |
| 610 | 622 | { |
| 611 | - if (strpos($key, 'loadavg') === 0 || $key === 'loadavg_enable' || !in_array($key, array_keys($default_values))) |
|
| 612 | - continue; |
|
| 613 | - else |
|
| 614 | - $_POST[$key] = (float) $value; |
|
| 615 | - |
|
| 616 | - if ($key == 'loadavg_auto_opt' && $value <= 1) |
|
| 617 | - $_POST['loadavg_auto_opt'] = 1.0; |
|
| 618 | - elseif ($key == 'loadavg_forum' && $value < 10) |
|
| 619 | - $_POST['loadavg_forum'] = 10.0; |
|
| 620 | - elseif ($value < 2) |
|
| 621 | - $_POST[$key] = 2.0; |
|
| 623 | + if (strpos($key, 'loadavg') === 0 || $key === 'loadavg_enable' || !in_array($key, array_keys($default_values))) { |
|
| 624 | + continue; |
|
| 625 | + } else { |
|
| 626 | + $_POST[$key] = (float) $value; |
|
| 627 | + } |
|
| 628 | + |
|
| 629 | + if ($key == 'loadavg_auto_opt' && $value <= 1) { |
|
| 630 | + $_POST['loadavg_auto_opt'] = 1.0; |
|
| 631 | + } elseif ($key == 'loadavg_forum' && $value < 10) { |
|
| 632 | + $_POST['loadavg_forum'] = 10.0; |
|
| 633 | + } elseif ($value < 2) { |
|
| 634 | + $_POST[$key] = 2.0; |
|
| 635 | + } |
|
| 622 | 636 | } |
| 623 | 637 | |
| 624 | 638 | call_integration_hook('integrate_save_loadavg_settings'); |
| 625 | 639 | |
| 626 | 640 | saveDBSettings($config_vars); |
| 627 | - if (!isset($_SESSION['adm-save'])) |
|
| 628 | - $_SESSION['adm-save'] = true; |
|
| 641 | + if (!isset($_SESSION['adm-save'])) { |
|
| 642 | + $_SESSION['adm-save'] = true; |
|
| 643 | + } |
|
| 629 | 644 | redirectexit('action=admin;area=serversettings;sa=loads;' . $context['session_var'] . '=' . $context['session_id']); |
| 630 | 645 | } |
| 631 | 646 | |
@@ -661,10 +676,11 @@ discard block |
||
| 661 | 676 | |
| 662 | 677 | if (isset($_SESSION['adm-save'])) |
| 663 | 678 | { |
| 664 | - if ($_SESSION['adm-save'] === true) |
|
| 665 | - $context['saved_successful'] = true; |
|
| 666 | - else |
|
| 667 | - $context['saved_failed'] = $_SESSION['adm-save']; |
|
| 679 | + if ($_SESSION['adm-save'] === true) { |
|
| 680 | + $context['saved_successful'] = true; |
|
| 681 | + } else { |
|
| 682 | + $context['saved_failed'] = $_SESSION['adm-save']; |
|
| 683 | + } |
|
| 668 | 684 | |
| 669 | 685 | unset($_SESSION['adm-save']); |
| 670 | 686 | } |
@@ -672,9 +688,9 @@ discard block |
||
| 672 | 688 | $context['config_vars'] = array(); |
| 673 | 689 | foreach ($config_vars as $identifier => $config_var) |
| 674 | 690 | { |
| 675 | - if (!is_array($config_var) || !isset($config_var[1])) |
|
| 676 | - $context['config_vars'][] = $config_var; |
|
| 677 | - else |
|
| 691 | + if (!is_array($config_var) || !isset($config_var[1])) { |
|
| 692 | + $context['config_vars'][] = $config_var; |
|
| 693 | + } else |
|
| 678 | 694 | { |
| 679 | 695 | $varname = $config_var[0]; |
| 680 | 696 | global $$varname; |
@@ -709,16 +725,19 @@ discard block |
||
| 709 | 725 | if ($config_var[3] == 'int' || $config_var[3] == 'float') |
| 710 | 726 | { |
| 711 | 727 | // Default to a min of 0 if one isn't set |
| 712 | - if (isset($config_var['min'])) |
|
| 713 | - $context['config_vars'][$config_var[0]]['min'] = $config_var['min']; |
|
| 714 | - else |
|
| 715 | - $context['config_vars'][$config_var[0]]['min'] = 0; |
|
| 728 | + if (isset($config_var['min'])) { |
|
| 729 | + $context['config_vars'][$config_var[0]]['min'] = $config_var['min']; |
|
| 730 | + } else { |
|
| 731 | + $context['config_vars'][$config_var[0]]['min'] = 0; |
|
| 732 | + } |
|
| 716 | 733 | |
| 717 | - if (isset($config_var['max'])) |
|
| 718 | - $context['config_vars'][$config_var[0]]['max'] = $config_var['max']; |
|
| 734 | + if (isset($config_var['max'])) { |
|
| 735 | + $context['config_vars'][$config_var[0]]['max'] = $config_var['max']; |
|
| 736 | + } |
|
| 719 | 737 | |
| 720 | - if (isset($config_var['step'])) |
|
| 721 | - $context['config_vars'][$config_var[0]]['step'] = $config_var['step']; |
|
| 738 | + if (isset($config_var['step'])) { |
|
| 739 | + $context['config_vars'][$config_var[0]]['step'] = $config_var['step']; |
|
| 740 | + } |
|
| 722 | 741 | } |
| 723 | 742 | |
| 724 | 743 | // If this is a select box handle any data. |
@@ -726,12 +745,13 @@ discard block |
||
| 726 | 745 | { |
| 727 | 746 | // If it's associative |
| 728 | 747 | $config_values = array_values($config_var[4]); |
| 729 | - if (isset($config_values[0]) && is_array($config_values[0])) |
|
| 730 | - $context['config_vars'][$config_var[0]]['data'] = $config_var[4]; |
|
| 731 | - else |
|
| 748 | + if (isset($config_values[0]) && is_array($config_values[0])) { |
|
| 749 | + $context['config_vars'][$config_var[0]]['data'] = $config_var[4]; |
|
| 750 | + } else |
|
| 732 | 751 | { |
| 733 | - foreach ($config_var[4] as $key => $item) |
|
| 734 | - $context['config_vars'][$config_var[0]]['data'][] = array($key, $item); |
|
| 752 | + foreach ($config_var[4] as $key => $item) { |
|
| 753 | + $context['config_vars'][$config_var[0]]['data'][] = array($key, $item); |
|
| 754 | + } |
|
| 735 | 755 | } |
| 736 | 756 | } |
| 737 | 757 | } |
@@ -756,10 +776,11 @@ discard block |
||
| 756 | 776 | |
| 757 | 777 | if (isset($_SESSION['adm-save'])) |
| 758 | 778 | { |
| 759 | - if ($_SESSION['adm-save'] === true) |
|
| 760 | - $context['saved_successful'] = true; |
|
| 761 | - else |
|
| 762 | - $context['saved_failed'] = $_SESSION['adm-save']; |
|
| 779 | + if ($_SESSION['adm-save'] === true) { |
|
| 780 | + $context['saved_successful'] = true; |
|
| 781 | + } else { |
|
| 782 | + $context['saved_failed'] = $_SESSION['adm-save']; |
|
| 783 | + } |
|
| 763 | 784 | |
| 764 | 785 | unset($_SESSION['adm-save']); |
| 765 | 786 | } |
@@ -771,26 +792,30 @@ discard block |
||
| 771 | 792 | foreach ($config_vars as $config_var) |
| 772 | 793 | { |
| 773 | 794 | // HR? |
| 774 | - if (!is_array($config_var)) |
|
| 775 | - $context['config_vars'][] = $config_var; |
|
| 776 | - else |
|
| 795 | + if (!is_array($config_var)) { |
|
| 796 | + $context['config_vars'][] = $config_var; |
|
| 797 | + } else |
|
| 777 | 798 | { |
| 778 | 799 | // If it has no name it doesn't have any purpose! |
| 779 | - if (empty($config_var[1])) |
|
| 780 | - continue; |
|
| 800 | + if (empty($config_var[1])) { |
|
| 801 | + continue; |
|
| 802 | + } |
|
| 781 | 803 | |
| 782 | 804 | // Special case for inline permissions |
| 783 | - if ($config_var[0] == 'permissions' && allowedTo('manage_permissions')) |
|
| 784 | - $inlinePermissions[] = $config_var[1]; |
|
| 785 | - elseif ($config_var[0] == 'permissions') |
|
| 786 | - continue; |
|
| 805 | + if ($config_var[0] == 'permissions' && allowedTo('manage_permissions')) { |
|
| 806 | + $inlinePermissions[] = $config_var[1]; |
|
| 807 | + } elseif ($config_var[0] == 'permissions') { |
|
| 808 | + continue; |
|
| 809 | + } |
|
| 787 | 810 | |
| 788 | - if ($config_var[0] == 'boards') |
|
| 789 | - $board_list = true; |
|
| 811 | + if ($config_var[0] == 'boards') { |
|
| 812 | + $board_list = true; |
|
| 813 | + } |
|
| 790 | 814 | |
| 791 | 815 | // Are we showing the BBC selection box? |
| 792 | - if ($config_var[0] == 'bbc') |
|
| 793 | - $bbcChoice[] = $config_var[1]; |
|
| 816 | + if ($config_var[0] == 'bbc') { |
|
| 817 | + $bbcChoice[] = $config_var[1]; |
|
| 818 | + } |
|
| 794 | 819 | |
| 795 | 820 | // We need to do some parsing of the value before we pass it in. |
| 796 | 821 | if (isset($modSettings[$config_var[1]])) |
@@ -809,8 +834,7 @@ discard block |
||
| 809 | 834 | default: |
| 810 | 835 | $value = $smcFunc['htmlspecialchars']($modSettings[$config_var[1]]); |
| 811 | 836 | } |
| 812 | - } |
|
| 813 | - else |
|
| 837 | + } else |
|
| 814 | 838 | { |
| 815 | 839 | // Darn, it's empty. What type is expected? |
| 816 | 840 | switch ($config_var[0]) |
@@ -850,16 +874,19 @@ discard block |
||
| 850 | 874 | if ($config_var[0] == 'int' || $config_var[0] == 'float') |
| 851 | 875 | { |
| 852 | 876 | // Default to a min of 0 if one isn't set |
| 853 | - if (isset($config_var['min'])) |
|
| 854 | - $context['config_vars'][$config_var[1]]['min'] = $config_var['min']; |
|
| 855 | - else |
|
| 856 | - $context['config_vars'][$config_var[1]]['min'] = 0; |
|
| 877 | + if (isset($config_var['min'])) { |
|
| 878 | + $context['config_vars'][$config_var[1]]['min'] = $config_var['min']; |
|
| 879 | + } else { |
|
| 880 | + $context['config_vars'][$config_var[1]]['min'] = 0; |
|
| 881 | + } |
|
| 857 | 882 | |
| 858 | - if (isset($config_var['max'])) |
|
| 859 | - $context['config_vars'][$config_var[1]]['max'] = $config_var['max']; |
|
| 883 | + if (isset($config_var['max'])) { |
|
| 884 | + $context['config_vars'][$config_var[1]]['max'] = $config_var['max']; |
|
| 885 | + } |
|
| 860 | 886 | |
| 861 | - if (isset($config_var['step'])) |
|
| 862 | - $context['config_vars'][$config_var[1]]['step'] = $config_var['step']; |
|
| 887 | + if (isset($config_var['step'])) { |
|
| 888 | + $context['config_vars'][$config_var[1]]['step'] = $config_var['step']; |
|
| 889 | + } |
|
| 863 | 890 | } |
| 864 | 891 | |
| 865 | 892 | // If this is a select box handle any data. |
@@ -873,12 +900,13 @@ discard block |
||
| 873 | 900 | } |
| 874 | 901 | |
| 875 | 902 | // If it's associative |
| 876 | - if (isset($config_var[2][0]) && is_array($config_var[2][0])) |
|
| 877 | - $context['config_vars'][$config_var[1]]['data'] = $config_var[2]; |
|
| 878 | - else |
|
| 903 | + if (isset($config_var[2][0]) && is_array($config_var[2][0])) { |
|
| 904 | + $context['config_vars'][$config_var[1]]['data'] = $config_var[2]; |
|
| 905 | + } else |
|
| 879 | 906 | { |
| 880 | - foreach ($config_var[2] as $key => $item) |
|
| 881 | - $context['config_vars'][$config_var[1]]['data'][] = array($key, $item); |
|
| 907 | + foreach ($config_var[2] as $key => $item) { |
|
| 908 | + $context['config_vars'][$config_var[1]]['data'][] = array($key, $item); |
|
| 909 | + } |
|
| 882 | 910 | } |
| 883 | 911 | } |
| 884 | 912 | |
@@ -887,17 +915,19 @@ discard block |
||
| 887 | 915 | { |
| 888 | 916 | if (!is_numeric($k)) |
| 889 | 917 | { |
| 890 | - if (substr($k, 0, 2) == 'on') |
|
| 891 | - $context['config_vars'][$config_var[1]]['javascript'] .= ' ' . $k . '="' . $v . '"'; |
|
| 892 | - else |
|
| 893 | - $context['config_vars'][$config_var[1]][$k] = $v; |
|
| 918 | + if (substr($k, 0, 2) == 'on') { |
|
| 919 | + $context['config_vars'][$config_var[1]]['javascript'] .= ' ' . $k . '="' . $v . '"'; |
|
| 920 | + } else { |
|
| 921 | + $context['config_vars'][$config_var[1]][$k] = $v; |
|
| 922 | + } |
|
| 894 | 923 | } |
| 895 | 924 | |
| 896 | 925 | // See if there are any other labels that might fit? |
| 897 | - if (isset($txt['setting_' . $config_var[1]])) |
|
| 898 | - $context['config_vars'][$config_var[1]]['label'] = $txt['setting_' . $config_var[1]]; |
|
| 899 | - elseif (isset($txt['groups_' . $config_var[1]])) |
|
| 900 | - $context['config_vars'][$config_var[1]]['label'] = $txt['groups_' . $config_var[1]]; |
|
| 926 | + if (isset($txt['setting_' . $config_var[1]])) { |
|
| 927 | + $context['config_vars'][$config_var[1]]['label'] = $txt['setting_' . $config_var[1]]; |
|
| 928 | + } elseif (isset($txt['groups_' . $config_var[1]])) { |
|
| 929 | + $context['config_vars'][$config_var[1]]['label'] = $txt['groups_' . $config_var[1]]; |
|
| 930 | + } |
|
| 901 | 931 | } |
| 902 | 932 | |
| 903 | 933 | // Set the subtext in case it's part of the label. |
@@ -930,8 +960,9 @@ discard block |
||
| 930 | 960 | // What are the options, eh? |
| 931 | 961 | $temp = parse_bbc(false); |
| 932 | 962 | $bbcTags = array(); |
| 933 | - foreach ($temp as $tag) |
|
| 934 | - $bbcTags[] = $tag['tag']; |
|
| 963 | + foreach ($temp as $tag) { |
|
| 964 | + $bbcTags[] = $tag['tag']; |
|
| 965 | + } |
|
| 935 | 966 | |
| 936 | 967 | $bbcTags = array_unique($bbcTags); |
| 937 | 968 | $totalTags = count($bbcTags); |
@@ -946,8 +977,9 @@ discard block |
||
| 946 | 977 | $col = 0; $i = 0; |
| 947 | 978 | foreach ($bbcTags as $tag) |
| 948 | 979 | { |
| 949 | - if ($i % $tagsPerColumn == 0 && $i != 0) |
|
| 950 | - $col++; |
|
| 980 | + if ($i % $tagsPerColumn == 0 && $i != 0) { |
|
| 981 | + $col++; |
|
| 982 | + } |
|
| 951 | 983 | |
| 952 | 984 | $context['bbc_columns'][$col][] = array( |
| 953 | 985 | 'tag' => $tag, |
@@ -990,18 +1022,21 @@ discard block |
||
| 990 | 1022 | validateToken('admin-ssc'); |
| 991 | 1023 | |
| 992 | 1024 | // Fix the darn stupid cookiename! (more may not be allowed, but these for sure!) |
| 993 | - if (isset($_POST['cookiename'])) |
|
| 994 | - $_POST['cookiename'] = preg_replace('~[,;\s\.$]+~' . ($context['utf8'] ? 'u' : ''), '', $_POST['cookiename']); |
|
| 1025 | + if (isset($_POST['cookiename'])) { |
|
| 1026 | + $_POST['cookiename'] = preg_replace('~[,;\s\.$]+~' . ($context['utf8'] ? 'u' : ''), '', $_POST['cookiename']); |
|
| 1027 | + } |
|
| 995 | 1028 | |
| 996 | 1029 | // Fix the forum's URL if necessary. |
| 997 | 1030 | if (isset($_POST['boardurl'])) |
| 998 | 1031 | { |
| 999 | - if (substr($_POST['boardurl'], -10) == '/index.php') |
|
| 1000 | - $_POST['boardurl'] = substr($_POST['boardurl'], 0, -10); |
|
| 1001 | - elseif (substr($_POST['boardurl'], -1) == '/') |
|
| 1002 | - $_POST['boardurl'] = substr($_POST['boardurl'], 0, -1); |
|
| 1003 | - if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://') |
|
| 1004 | - $_POST['boardurl'] = 'http://' . $_POST['boardurl']; |
|
| 1032 | + if (substr($_POST['boardurl'], -10) == '/index.php') { |
|
| 1033 | + $_POST['boardurl'] = substr($_POST['boardurl'], 0, -10); |
|
| 1034 | + } elseif (substr($_POST['boardurl'], -1) == '/') { |
|
| 1035 | + $_POST['boardurl'] = substr($_POST['boardurl'], 0, -1); |
|
| 1036 | + } |
|
| 1037 | + if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://') { |
|
| 1038 | + $_POST['boardurl'] = 'http://' . $_POST['boardurl']; |
|
| 1039 | + } |
|
| 1005 | 1040 | } |
| 1006 | 1041 | |
| 1007 | 1042 | // Any passwords? |
@@ -1036,21 +1071,21 @@ discard block |
||
| 1036 | 1071 | // Figure out which config vars we're saving here... |
| 1037 | 1072 | foreach ($config_vars as $var) |
| 1038 | 1073 | { |
| 1039 | - if (!is_array($var) || $var[2] != 'file' || (!in_array($var[0], $config_bools) && !isset($_POST[$var[0]]))) |
|
| 1040 | - continue; |
|
| 1074 | + if (!is_array($var) || $var[2] != 'file' || (!in_array($var[0], $config_bools) && !isset($_POST[$var[0]]))) { |
|
| 1075 | + continue; |
|
| 1076 | + } |
|
| 1041 | 1077 | |
| 1042 | 1078 | $config_var = $var[0]; |
| 1043 | 1079 | |
| 1044 | 1080 | if (in_array($config_var, $config_passwords)) |
| 1045 | 1081 | { |
| 1046 | - if (isset($_POST[$config_var][1]) && $_POST[$config_var][0] == $_POST[$config_var][1]) |
|
| 1047 | - $new_settings[$config_var] = '\'' . addcslashes($_POST[$config_var][0], '\'\\') . '\''; |
|
| 1048 | - } |
|
| 1049 | - elseif (in_array($config_var, $config_strs)) |
|
| 1082 | + if (isset($_POST[$config_var][1]) && $_POST[$config_var][0] == $_POST[$config_var][1]) { |
|
| 1083 | + $new_settings[$config_var] = '\'' . addcslashes($_POST[$config_var][0], '\'\\') . '\''; |
|
| 1084 | + } |
|
| 1085 | + } elseif (in_array($config_var, $config_strs)) |
|
| 1050 | 1086 | { |
| 1051 | 1087 | $new_settings[$config_var] = '\'' . addcslashes($_POST[$config_var], '\'\\') . '\''; |
| 1052 | - } |
|
| 1053 | - elseif (in_array($config_var, $config_ints)) |
|
| 1088 | + } elseif (in_array($config_var, $config_ints)) |
|
| 1054 | 1089 | { |
| 1055 | 1090 | $new_settings[$config_var] = (int) $_POST[$config_var]; |
| 1056 | 1091 | |
@@ -1059,17 +1094,17 @@ discard block |
||
| 1059 | 1094 | $new_settings[$config_var] = max($min, $new_settings[$config_var]); |
| 1060 | 1095 | |
| 1061 | 1096 | // Is there a max value for this as well? |
| 1062 | - if (isset($var['max'])) |
|
| 1063 | - $new_settings[$config_var] = min($var['max'], $new_settings[$config_var]); |
|
| 1064 | - } |
|
| 1065 | - elseif (in_array($config_var, $config_bools)) |
|
| 1097 | + if (isset($var['max'])) { |
|
| 1098 | + $new_settings[$config_var] = min($var['max'], $new_settings[$config_var]); |
|
| 1099 | + } |
|
| 1100 | + } elseif (in_array($config_var, $config_bools)) |
|
| 1066 | 1101 | { |
| 1067 | - if (!empty($_POST[$config_var])) |
|
| 1068 | - $new_settings[$config_var] = '1'; |
|
| 1069 | - else |
|
| 1070 | - $new_settings[$config_var] = '0'; |
|
| 1071 | - } |
|
| 1072 | - else |
|
| 1102 | + if (!empty($_POST[$config_var])) { |
|
| 1103 | + $new_settings[$config_var] = '1'; |
|
| 1104 | + } else { |
|
| 1105 | + $new_settings[$config_var] = '0'; |
|
| 1106 | + } |
|
| 1107 | + } else |
|
| 1073 | 1108 | { |
| 1074 | 1109 | // This shouldn't happen, but it might... |
| 1075 | 1110 | fatal_error('Unknown config_var \'' . $config_var . '\''); |
@@ -1085,30 +1120,35 @@ discard block |
||
| 1085 | 1120 | foreach ($config_vars as $config_var) |
| 1086 | 1121 | { |
| 1087 | 1122 | // We just saved the file-based settings, so skip their definitions. |
| 1088 | - if (!is_array($config_var) || $config_var[2] == 'file') |
|
| 1089 | - continue; |
|
| 1123 | + if (!is_array($config_var) || $config_var[2] == 'file') { |
|
| 1124 | + continue; |
|
| 1125 | + } |
|
| 1090 | 1126 | |
| 1091 | 1127 | $new_setting = array($config_var[3], $config_var[0]); |
| 1092 | 1128 | |
| 1093 | 1129 | // Select options need carried over, too. |
| 1094 | - if (isset($config_var[4])) |
|
| 1095 | - $new_setting[] = $config_var[4]; |
|
| 1130 | + if (isset($config_var[4])) { |
|
| 1131 | + $new_setting[] = $config_var[4]; |
|
| 1132 | + } |
|
| 1096 | 1133 | |
| 1097 | 1134 | // Include min and max if necessary |
| 1098 | - if (isset($config_var['min'])) |
|
| 1099 | - $new_setting['min'] = $config_var['min']; |
|
| 1135 | + if (isset($config_var['min'])) { |
|
| 1136 | + $new_setting['min'] = $config_var['min']; |
|
| 1137 | + } |
|
| 1100 | 1138 | |
| 1101 | - if (isset($config_var['max'])) |
|
| 1102 | - $new_setting['max'] = $config_var['max']; |
|
| 1139 | + if (isset($config_var['max'])) { |
|
| 1140 | + $new_setting['max'] = $config_var['max']; |
|
| 1141 | + } |
|
| 1103 | 1142 | |
| 1104 | 1143 | // Rewrite the definition a bit. |
| 1105 | 1144 | $new_settings[] = $new_setting; |
| 1106 | 1145 | } |
| 1107 | 1146 | |
| 1108 | 1147 | // Save the new database-based settings, if any. |
| 1109 | - if (!empty($new_settings)) |
|
| 1110 | - saveDBSettings($new_settings); |
|
| 1111 | -} |
|
| 1148 | + if (!empty($new_settings)) { |
|
| 1149 | + saveDBSettings($new_settings); |
|
| 1150 | + } |
|
| 1151 | + } |
|
| 1112 | 1152 | |
| 1113 | 1153 | /** |
| 1114 | 1154 | * Helper function for saving database settings. |
@@ -1126,22 +1166,25 @@ discard block |
||
| 1126 | 1166 | $inlinePermissions = array(); |
| 1127 | 1167 | foreach ($config_vars as $var) |
| 1128 | 1168 | { |
| 1129 | - if (!isset($var[1]) || (!isset($_POST[$var[1]]) && $var[0] != 'check' && $var[0] != 'permissions' && $var[0] != 'boards' && ($var[0] != 'bbc' || !isset($_POST[$var[1] . '_enabledTags'])))) |
|
| 1130 | - continue; |
|
| 1169 | + if (!isset($var[1]) || (!isset($_POST[$var[1]]) && $var[0] != 'check' && $var[0] != 'permissions' && $var[0] != 'boards' && ($var[0] != 'bbc' || !isset($_POST[$var[1] . '_enabledTags'])))) { |
|
| 1170 | + continue; |
|
| 1171 | + } |
|
| 1131 | 1172 | |
| 1132 | 1173 | // Checkboxes! |
| 1133 | - elseif ($var[0] == 'check') |
|
| 1134 | - $setArray[$var[1]] = !empty($_POST[$var[1]]) ? '1' : '0'; |
|
| 1174 | + elseif ($var[0] == 'check') { |
|
| 1175 | + $setArray[$var[1]] = !empty($_POST[$var[1]]) ? '1' : '0'; |
|
| 1176 | + } |
|
| 1135 | 1177 | // Select boxes! |
| 1136 | - elseif ($var[0] == 'select' && in_array($_POST[$var[1]], array_keys($var[2]))) |
|
| 1137 | - $setArray[$var[1]] = $_POST[$var[1]]; |
|
| 1138 | - elseif ($var[0] == 'select' && !empty($var['multiple']) && array_intersect($_POST[$var[1]], array_keys($var[2])) != array()) |
|
| 1178 | + elseif ($var[0] == 'select' && in_array($_POST[$var[1]], array_keys($var[2]))) { |
|
| 1179 | + $setArray[$var[1]] = $_POST[$var[1]]; |
|
| 1180 | + } elseif ($var[0] == 'select' && !empty($var['multiple']) && array_intersect($_POST[$var[1]], array_keys($var[2])) != array()) |
|
| 1139 | 1181 | { |
| 1140 | 1182 | // For security purposes we validate this line by line. |
| 1141 | 1183 | $lOptions = array(); |
| 1142 | - foreach ($_POST[$var[1]] as $invar) |
|
| 1143 | - if (in_array($invar, array_keys($var[2]))) |
|
| 1184 | + foreach ($_POST[$var[1]] as $invar) { |
|
| 1185 | + if (in_array($invar, array_keys($var[2]))) |
|
| 1144 | 1186 | $lOptions[] = $invar; |
| 1187 | + } |
|
| 1145 | 1188 | |
| 1146 | 1189 | $setArray[$var[1]] = json_encode($lOptions); |
| 1147 | 1190 | } |
@@ -1155,18 +1198,20 @@ discard block |
||
| 1155 | 1198 | $request = $smcFunc['db_query']('', ' |
| 1156 | 1199 | SELECT id_board |
| 1157 | 1200 | FROM {db_prefix}boards'); |
| 1158 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
| 1159 | - $board_list[$row[0]] = true; |
|
| 1201 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
| 1202 | + $board_list[$row[0]] = true; |
|
| 1203 | + } |
|
| 1160 | 1204 | |
| 1161 | 1205 | $smcFunc['db_free_result']($request); |
| 1162 | 1206 | } |
| 1163 | 1207 | |
| 1164 | 1208 | $lOptions = array(); |
| 1165 | 1209 | |
| 1166 | - if (!empty($_POST[$var[1]])) |
|
| 1167 | - foreach ($_POST[$var[1]] as $invar => $dummy) |
|
| 1210 | + if (!empty($_POST[$var[1]])) { |
|
| 1211 | + foreach ($_POST[$var[1]] as $invar => $dummy) |
|
| 1168 | 1212 | if (isset($board_list[$invar])) |
| 1169 | 1213 | $lOptions[] = $invar; |
| 1214 | + } |
|
| 1170 | 1215 | |
| 1171 | 1216 | $setArray[$var[1]] = !empty($lOptions) ? implode(',', $lOptions) : ''; |
| 1172 | 1217 | } |
@@ -1180,8 +1225,9 @@ discard block |
||
| 1180 | 1225 | $setArray[$var[1]] = max($min, $setArray[$var[1]]); |
| 1181 | 1226 | |
| 1182 | 1227 | // Do we have a max value for this as well? |
| 1183 | - if (isset($var['max'])) |
|
| 1184 | - $setArray[$var[1]] = min($var['max'], $setArray[$var[1]]); |
|
| 1228 | + if (isset($var['max'])) { |
|
| 1229 | + $setArray[$var[1]] = min($var['max'], $setArray[$var[1]]); |
|
| 1230 | + } |
|
| 1185 | 1231 | } |
| 1186 | 1232 | // Floating point! |
| 1187 | 1233 | elseif ($var[0] == 'float') |
@@ -1193,40 +1239,47 @@ discard block |
||
| 1193 | 1239 | $setArray[$var[1]] = max($min, $setArray[$var[1]]); |
| 1194 | 1240 | |
| 1195 | 1241 | // Do we have a max value for this as well? |
| 1196 | - if (isset($var['max'])) |
|
| 1197 | - $setArray[$var[1]] = min($var['max'], $setArray[$var[1]]); |
|
| 1242 | + if (isset($var['max'])) { |
|
| 1243 | + $setArray[$var[1]] = min($var['max'], $setArray[$var[1]]); |
|
| 1244 | + } |
|
| 1198 | 1245 | } |
| 1199 | 1246 | // Text! |
| 1200 | - elseif (in_array($var[0], array('text', 'large_text', 'color', 'date', 'datetime', 'datetime-local', 'email', 'month', 'time'))) |
|
| 1201 | - $setArray[$var[1]] = $_POST[$var[1]]; |
|
| 1247 | + elseif (in_array($var[0], array('text', 'large_text', 'color', 'date', 'datetime', 'datetime-local', 'email', 'month', 'time'))) { |
|
| 1248 | + $setArray[$var[1]] = $_POST[$var[1]]; |
|
| 1249 | + } |
|
| 1202 | 1250 | // Passwords! |
| 1203 | 1251 | elseif ($var[0] == 'password') |
| 1204 | 1252 | { |
| 1205 | - if (isset($_POST[$var[1]][1]) && $_POST[$var[1]][0] == $_POST[$var[1]][1]) |
|
| 1206 | - $setArray[$var[1]] = $_POST[$var[1]][0]; |
|
| 1253 | + if (isset($_POST[$var[1]][1]) && $_POST[$var[1]][0] == $_POST[$var[1]][1]) { |
|
| 1254 | + $setArray[$var[1]] = $_POST[$var[1]][0]; |
|
| 1255 | + } |
|
| 1207 | 1256 | } |
| 1208 | 1257 | // BBC. |
| 1209 | 1258 | elseif ($var[0] == 'bbc') |
| 1210 | 1259 | { |
| 1211 | 1260 | |
| 1212 | 1261 | $bbcTags = array(); |
| 1213 | - foreach (parse_bbc(false) as $tag) |
|
| 1214 | - $bbcTags[] = $tag['tag']; |
|
| 1262 | + foreach (parse_bbc(false) as $tag) { |
|
| 1263 | + $bbcTags[] = $tag['tag']; |
|
| 1264 | + } |
|
| 1215 | 1265 | |
| 1216 | - if (!isset($_POST[$var[1] . '_enabledTags'])) |
|
| 1217 | - $_POST[$var[1] . '_enabledTags'] = array(); |
|
| 1218 | - elseif (!is_array($_POST[$var[1] . '_enabledTags'])) |
|
| 1219 | - $_POST[$var[1] . '_enabledTags'] = array($_POST[$var[1] . '_enabledTags']); |
|
| 1266 | + if (!isset($_POST[$var[1] . '_enabledTags'])) { |
|
| 1267 | + $_POST[$var[1] . '_enabledTags'] = array(); |
|
| 1268 | + } elseif (!is_array($_POST[$var[1] . '_enabledTags'])) { |
|
| 1269 | + $_POST[$var[1] . '_enabledTags'] = array($_POST[$var[1] . '_enabledTags']); |
|
| 1270 | + } |
|
| 1220 | 1271 | |
| 1221 | 1272 | $setArray[$var[1]] = implode(',', array_diff($bbcTags, $_POST[$var[1] . '_enabledTags'])); |
| 1222 | 1273 | } |
| 1223 | 1274 | // Permissions? |
| 1224 | - elseif ($var[0] == 'permissions') |
|
| 1225 | - $inlinePermissions[] = $var[1]; |
|
| 1275 | + elseif ($var[0] == 'permissions') { |
|
| 1276 | + $inlinePermissions[] = $var[1]; |
|
| 1277 | + } |
|
| 1226 | 1278 | } |
| 1227 | 1279 | |
| 1228 | - if (!empty($setArray)) |
|
| 1229 | - updateSettings($setArray); |
|
| 1280 | + if (!empty($setArray)) { |
|
| 1281 | + updateSettings($setArray); |
|
| 1282 | + } |
|
| 1230 | 1283 | |
| 1231 | 1284 | // If we have inline permissions we need to save them. |
| 1232 | 1285 | if (!empty($inlinePermissions) && allowedTo('manage_permissions')) |
@@ -1264,18 +1317,21 @@ discard block |
||
| 1264 | 1317 | // put all of it into an array |
| 1265 | 1318 | foreach ($info_lines as $line) |
| 1266 | 1319 | { |
| 1267 | - if (preg_match('~(' . $remove . ')~', $line)) |
|
| 1268 | - continue; |
|
| 1320 | + if (preg_match('~(' . $remove . ')~', $line)) { |
|
| 1321 | + continue; |
|
| 1322 | + } |
|
| 1269 | 1323 | |
| 1270 | 1324 | // new category? |
| 1271 | - if (strpos($line, '<h2>') !== false) |
|
| 1272 | - $category = preg_match('~<h2>(.*)</h2>~', $line, $title) ? $category = $title[1] : $category; |
|
| 1325 | + if (strpos($line, '<h2>') !== false) { |
|
| 1326 | + $category = preg_match('~<h2>(.*)</h2>~', $line, $title) ? $category = $title[1] : $category; |
|
| 1327 | + } |
|
| 1273 | 1328 | |
| 1274 | 1329 | // load it as setting => value or the old setting local master |
| 1275 | - if (preg_match('~<tr><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td></tr>~', $line, $val)) |
|
| 1276 | - $pinfo[$category][$val[1]] = $val[2]; |
|
| 1277 | - elseif (preg_match('~<tr><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td></tr>~', $line, $val)) |
|
| 1278 | - $pinfo[$category][$val[1]] = array($txt['phpinfo_localsettings'] => $val[2], $txt['phpinfo_defaultsettings'] => $val[3]); |
|
| 1330 | + if (preg_match('~<tr><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td></tr>~', $line, $val)) { |
|
| 1331 | + $pinfo[$category][$val[1]] = $val[2]; |
|
| 1332 | + } elseif (preg_match('~<tr><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td></tr>~', $line, $val)) { |
|
| 1333 | + $pinfo[$category][$val[1]] = array($txt['phpinfo_localsettings'] => $val[2], $txt['phpinfo_defaultsettings'] => $val[3]); |
|
| 1334 | + } |
|
| 1279 | 1335 | } |
| 1280 | 1336 | |
| 1281 | 1337 | // load it in to context and display it |
@@ -1310,8 +1366,9 @@ discard block |
||
| 1310 | 1366 | $testAPI = new $cache_class_name(); |
| 1311 | 1367 | |
| 1312 | 1368 | // No Support? NEXT! |
| 1313 | - if (!$testAPI->isSupported(true)) |
|
| 1314 | - continue; |
|
| 1369 | + if (!$testAPI->isSupported(true)) { |
|
| 1370 | + continue; |
|
| 1371 | + } |
|
| 1315 | 1372 | |
| 1316 | 1373 | $apis[$tryCache] = isset($txt[$tryCache . '_cache']) ? $txt[$tryCache . '_cache'] : $tryCache; |
| 1317 | 1374 | } |
@@ -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 | * Create a new list |
@@ -41,21 +42,21 @@ discard block |
||
| 41 | 42 | { |
| 42 | 43 | $list_context['sort'] = array(); |
| 43 | 44 | $sort = '1=1'; |
| 44 | - } |
|
| 45 | - else |
|
| 45 | + } else |
|
| 46 | 46 | { |
| 47 | 47 | $request_var_sort = isset($listOptions['request_vars']['sort']) ? $listOptions['request_vars']['sort'] : 'sort'; |
| 48 | 48 | $request_var_desc = isset($listOptions['request_vars']['desc']) ? $listOptions['request_vars']['desc'] : 'desc'; |
| 49 | - if (isset($_REQUEST[$request_var_sort], $listOptions['columns'][$_REQUEST[$request_var_sort]], $listOptions['columns'][$_REQUEST[$request_var_sort]]['sort'])) |
|
| 50 | - $list_context['sort'] = array( |
|
| 49 | + if (isset($_REQUEST[$request_var_sort], $listOptions['columns'][$_REQUEST[$request_var_sort]], $listOptions['columns'][$_REQUEST[$request_var_sort]]['sort'])) { |
|
| 50 | + $list_context['sort'] = array( |
|
| 51 | 51 | 'id' => $_REQUEST[$request_var_sort], |
| 52 | 52 | 'desc' => isset($_REQUEST[$request_var_desc]) && isset($listOptions['columns'][$_REQUEST[$request_var_sort]]['sort']['reverse']), |
| 53 | 53 | ); |
| 54 | - else |
|
| 55 | - $list_context['sort'] = array( |
|
| 54 | + } else { |
|
| 55 | + $list_context['sort'] = array( |
|
| 56 | 56 | 'id' => $listOptions['default_sort_col'], |
| 57 | 57 | 'desc' => (!empty($listOptions['default_sort_dir']) && $listOptions['default_sort_dir'] == 'desc') || (!empty($listOptions['columns'][$listOptions['default_sort_col']]['sort']['default']) && substr($listOptions['columns'][$listOptions['default_sort_col']]['sort']['default'], -4, 4) == 'desc') ? true : false, |
| 58 | 58 | ); |
| 59 | + } |
|
| 59 | 60 | |
| 60 | 61 | // Set the database column sort. |
| 61 | 62 | $sort = $listOptions['columns'][$list_context['sort']['id']]['sort'][$list_context['sort']['desc'] ? 'reverse' : 'default']; |
@@ -72,8 +73,9 @@ discard block |
||
| 72 | 73 | else |
| 73 | 74 | { |
| 74 | 75 | // First get an impression of how many items to expect. |
| 75 | - if (isset($listOptions['get_count']['file'])) |
|
| 76 | - require_once($listOptions['get_count']['file']); |
|
| 76 | + if (isset($listOptions['get_count']['file'])) { |
|
| 77 | + require_once($listOptions['get_count']['file']); |
|
| 78 | + } |
|
| 77 | 79 | |
| 78 | 80 | $call = call_helper($listOptions['get_count']['function'], true); |
| 79 | 81 | $list_context['total_num_items'] = call_user_func_array($call, empty($listOptions['get_count']['params']) ? array() : $listOptions['get_count']['params']); |
@@ -83,14 +85,15 @@ discard block |
||
| 83 | 85 | $list_context['items_per_page'] = $listOptions['items_per_page']; |
| 84 | 86 | |
| 85 | 87 | // Then create a page index. |
| 86 | - if ($list_context['total_num_items'] > $list_context['items_per_page']) |
|
| 87 | - $list_context['page_index'] = constructPageIndex($listOptions['base_href'] . (empty($list_context['sort']) ? '' : ';' . $request_var_sort . '=' . $list_context['sort']['id'] . ($list_context['sort']['desc'] ? ';' . $request_var_desc : '')) . ($list_context['start_var_name'] != 'start' ? ';' . $list_context['start_var_name'] . '=%1$d' : ''), $list_context['start'], $list_context['total_num_items'], $list_context['items_per_page'], $list_context['start_var_name'] != 'start'); |
|
| 88 | + if ($list_context['total_num_items'] > $list_context['items_per_page']) { |
|
| 89 | + $list_context['page_index'] = constructPageIndex($listOptions['base_href'] . (empty($list_context['sort']) ? '' : ';' . $request_var_sort . '=' . $list_context['sort']['id'] . ($list_context['sort']['desc'] ? ';' . $request_var_desc : '')) . ($list_context['start_var_name'] != 'start' ? ';' . $list_context['start_var_name'] . '=%1$d' : ''), $list_context['start'], $list_context['total_num_items'], $list_context['items_per_page'], $list_context['start_var_name'] != 'start'); |
|
| 90 | + } |
|
| 88 | 91 | } |
| 89 | 92 | |
| 90 | 93 | // Prepare the headers of the table. |
| 91 | 94 | $list_context['headers'] = array(); |
| 92 | - foreach ($listOptions['columns'] as $column_id => $column) |
|
| 93 | - $list_context['headers'][] = array( |
|
| 95 | + foreach ($listOptions['columns'] as $column_id => $column) { |
|
| 96 | + $list_context['headers'][] = array( |
|
| 94 | 97 | 'id' => $column_id, |
| 95 | 98 | 'label' => isset($column['header']['eval']) ? eval($column['header']['eval']) : (isset($column['header']['value']) ? $column['header']['value'] : ''), |
| 96 | 99 | 'href' => empty($listOptions['default_sort_col']) || empty($column['sort']) ? '' : $listOptions['base_href'] . ';' . $request_var_sort . '=' . $column_id . ($column_id === $list_context['sort']['id'] && !$list_context['sort']['desc'] && isset($column['sort']['reverse']) ? ';' . $request_var_desc : '') . (empty($list_context['start']) ? '' : ';' . $list_context['start_var_name'] . '=' . $list_context['start']), |
@@ -99,14 +102,16 @@ discard block |
||
| 99 | 102 | 'style' => isset($column['header']['style']) ? $column['header']['style'] : '', |
| 100 | 103 | 'colspan' => isset($column['header']['colspan']) ? $column['header']['colspan'] : '', |
| 101 | 104 | ); |
| 105 | + } |
|
| 102 | 106 | |
| 103 | 107 | // We know the amount of columns, might be useful for the template. |
| 104 | 108 | $list_context['num_columns'] = count($listOptions['columns']); |
| 105 | 109 | $list_context['width'] = isset($listOptions['width']) ? $listOptions['width'] : '0'; |
| 106 | 110 | |
| 107 | 111 | // Get the file with the function for the item list. |
| 108 | - if (isset($listOptions['get_items']['file'])) |
|
| 109 | - require_once($listOptions['get_items']['file']); |
|
| 112 | + if (isset($listOptions['get_items']['file'])) { |
|
| 113 | + require_once($listOptions['get_items']['file']); |
|
| 114 | + } |
|
| 110 | 115 | |
| 111 | 116 | // Call the function and include which items we want and in what order. |
| 112 | 117 | $call = call_helper($listOptions['get_items']['function'], true); |
@@ -123,51 +128,61 @@ discard block |
||
| 123 | 128 | $cur_data = array(); |
| 124 | 129 | |
| 125 | 130 | // A value straight from the database? |
| 126 | - if (isset($column['data']['db'])) |
|
| 127 | - $cur_data['value'] = $list_item[$column['data']['db']]; |
|
| 131 | + if (isset($column['data']['db'])) { |
|
| 132 | + $cur_data['value'] = $list_item[$column['data']['db']]; |
|
| 133 | + } |
|
| 128 | 134 | |
| 129 | 135 | // Take the value from the database and make it HTML safe. |
| 130 | - elseif (isset($column['data']['db_htmlsafe'])) |
|
| 131 | - $cur_data['value'] = $smcFunc['htmlspecialchars']($list_item[$column['data']['db_htmlsafe']]); |
|
| 136 | + elseif (isset($column['data']['db_htmlsafe'])) { |
|
| 137 | + $cur_data['value'] = $smcFunc['htmlspecialchars']($list_item[$column['data']['db_htmlsafe']]); |
|
| 138 | + } |
|
| 132 | 139 | |
| 133 | 140 | // Using sprintf is probably the most readable way of injecting data. |
| 134 | 141 | elseif (isset($column['data']['sprintf'])) |
| 135 | 142 | { |
| 136 | 143 | $params = array(); |
| 137 | - foreach ($column['data']['sprintf']['params'] as $sprintf_param => $htmlsafe) |
|
| 138 | - $params[] = $htmlsafe ? $smcFunc['htmlspecialchars']($list_item[$sprintf_param]) : $list_item[$sprintf_param]; |
|
| 144 | + foreach ($column['data']['sprintf']['params'] as $sprintf_param => $htmlsafe) { |
|
| 145 | + $params[] = $htmlsafe ? $smcFunc['htmlspecialchars']($list_item[$sprintf_param]) : $list_item[$sprintf_param]; |
|
| 146 | + } |
|
| 139 | 147 | $cur_data['value'] = vsprintf($column['data']['sprintf']['format'], $params); |
| 140 | 148 | } |
| 141 | 149 | |
| 142 | 150 | // The most flexible way probably is applying a custom function. |
| 143 | - elseif (isset($column['data']['function'])) |
|
| 144 | - $cur_data['value'] = call_user_func_array($column['data']['function'], array($list_item)); |
|
| 151 | + elseif (isset($column['data']['function'])) { |
|
| 152 | + $cur_data['value'] = call_user_func_array($column['data']['function'], array($list_item)); |
|
| 153 | + } |
|
| 145 | 154 | |
| 146 | 155 | // A modified value (inject the database values). |
| 147 | - elseif (isset($column['data']['eval'])) |
|
| 148 | - $cur_data['value'] = eval(preg_replace('~%([a-zA-Z0-9\-_]+)%~', '$list_item[\'$1\']', $column['data']['eval'])); |
|
| 156 | + elseif (isset($column['data']['eval'])) { |
|
| 157 | + $cur_data['value'] = eval(preg_replace('~%([a-zA-Z0-9\-_]+)%~', '$list_item[\'$1\']', $column['data']['eval'])); |
|
| 158 | + } |
|
| 149 | 159 | |
| 150 | 160 | // A literal value. |
| 151 | - elseif (isset($column['data']['value'])) |
|
| 152 | - $cur_data['value'] = $column['data']['value']; |
|
| 161 | + elseif (isset($column['data']['value'])) { |
|
| 162 | + $cur_data['value'] = $column['data']['value']; |
|
| 163 | + } |
|
| 153 | 164 | |
| 154 | 165 | // Empty value. |
| 155 | - else |
|
| 156 | - $cur_data['value'] = ''; |
|
| 166 | + else { |
|
| 167 | + $cur_data['value'] = ''; |
|
| 168 | + } |
|
| 157 | 169 | |
| 158 | 170 | // Allow for basic formatting. |
| 159 | - if (!empty($column['data']['comma_format'])) |
|
| 160 | - $cur_data['value'] = comma_format($cur_data['value']); |
|
| 161 | - elseif (!empty($column['data']['timeformat'])) |
|
| 162 | - $cur_data['value'] = timeformat($cur_data['value']); |
|
| 171 | + if (!empty($column['data']['comma_format'])) { |
|
| 172 | + $cur_data['value'] = comma_format($cur_data['value']); |
|
| 173 | + } elseif (!empty($column['data']['timeformat'])) { |
|
| 174 | + $cur_data['value'] = timeformat($cur_data['value']); |
|
| 175 | + } |
|
| 163 | 176 | |
| 164 | 177 | // Set a style class for this column? |
| 165 | - if (isset($column['data']['class'])) |
|
| 166 | - $cur_data['class'] = $column['data']['class']; |
|
| 178 | + if (isset($column['data']['class'])) { |
|
| 179 | + $cur_data['class'] = $column['data']['class']; |
|
| 180 | + } |
|
| 167 | 181 | |
| 168 | 182 | // Fully customized styling for the cells in this column only. |
| 169 | - if (isset($column['data']['style'])) |
|
| 170 | - $cur_data['style'] = $column['data']['style']; |
|
| 183 | + if (isset($column['data']['style'])) { |
|
| 184 | + $cur_data['style'] = $column['data']['style']; |
|
| 185 | + } |
|
| 171 | 186 | |
| 172 | 187 | // Add the data cell properties to the current row. |
| 173 | 188 | $cur_row[$column_id] = $cur_data; |
@@ -176,10 +191,12 @@ discard block |
||
| 176 | 191 | // Maybe we wat set a custom class for the row based on the data in the row itself |
| 177 | 192 | if (isset($listOptions['data_check'])) |
| 178 | 193 | { |
| 179 | - if (isset($listOptions['data_check']['class'])) |
|
| 180 | - $list_context['rows'][$item_id]['class'] = $listOptions['data_check']['class']($list_item); |
|
| 181 | - if (isset($listOptions['data_check']['style'])) |
|
| 182 | - $list_context['rows'][$item_id]['style'] = $listOptions['data_check']['style']($list_item); |
|
| 194 | + if (isset($listOptions['data_check']['class'])) { |
|
| 195 | + $list_context['rows'][$item_id]['class'] = $listOptions['data_check']['class']($list_item); |
|
| 196 | + } |
|
| 197 | + if (isset($listOptions['data_check']['style'])) { |
|
| 198 | + $list_context['rows'][$item_id]['style'] = $listOptions['data_check']['style']($list_item); |
|
| 199 | + } |
|
| 183 | 200 | } |
| 184 | 201 | |
| 185 | 202 | // Insert the row into the list. |
@@ -187,34 +204,39 @@ discard block |
||
| 187 | 204 | } |
| 188 | 205 | |
| 189 | 206 | // The title is currently optional. |
| 190 | - if (isset($listOptions['title'])) |
|
| 191 | - $list_context['title'] = $listOptions['title']; |
|
| 207 | + if (isset($listOptions['title'])) { |
|
| 208 | + $list_context['title'] = $listOptions['title']; |
|
| 209 | + } |
|
| 192 | 210 | |
| 193 | 211 | // In case there's a form, share it with the template context. |
| 194 | 212 | if (isset($listOptions['form'])) |
| 195 | 213 | { |
| 196 | 214 | $list_context['form'] = $listOptions['form']; |
| 197 | 215 | |
| 198 | - if (!isset($list_context['form']['hidden_fields'])) |
|
| 199 | - $list_context['form']['hidden_fields'] = array(); |
|
| 216 | + if (!isset($list_context['form']['hidden_fields'])) { |
|
| 217 | + $list_context['form']['hidden_fields'] = array(); |
|
| 218 | + } |
|
| 200 | 219 | |
| 201 | 220 | // Always add a session check field. |
| 202 | 221 | $list_context['form']['hidden_fields'][$context['session_var']] = $context['session_id']; |
| 203 | 222 | |
| 204 | 223 | // Will this do a token check? |
| 205 | - if (isset($listOptions['form']['token'])) |
|
| 206 | - $list_context['form']['hidden_fields'][$context[$listOptions['form']['token'] . '_token_var']] = $context[$listOptions['form']['token'] . '_token']; |
|
| 224 | + if (isset($listOptions['form']['token'])) { |
|
| 225 | + $list_context['form']['hidden_fields'][$context[$listOptions['form']['token'] . '_token_var']] = $context[$listOptions['form']['token'] . '_token']; |
|
| 226 | + } |
|
| 207 | 227 | |
| 208 | 228 | // Include the starting page as hidden field? |
| 209 | - if (!empty($list_context['form']['include_start']) && !empty($list_context['start'])) |
|
| 210 | - $list_context['form']['hidden_fields'][$list_context['start_var_name']] = $list_context['start']; |
|
| 229 | + if (!empty($list_context['form']['include_start']) && !empty($list_context['start'])) { |
|
| 230 | + $list_context['form']['hidden_fields'][$list_context['start_var_name']] = $list_context['start']; |
|
| 231 | + } |
|
| 211 | 232 | |
| 212 | 233 | // If sorting needs to be the same after submitting, add the parameter. |
| 213 | 234 | if (!empty($list_context['form']['include_sort']) && !empty($list_context['sort'])) |
| 214 | 235 | { |
| 215 | 236 | $list_context['form']['hidden_fields']['sort'] = $list_context['sort']['id']; |
| 216 | - if ($list_context['sort']['desc']) |
|
| 217 | - $list_context['form']['hidden_fields']['desc'] = 1; |
|
| 237 | + if ($list_context['sort']['desc']) { |
|
| 238 | + $list_context['form']['hidden_fields']['desc'] = 1; |
|
| 239 | + } |
|
| 218 | 240 | } |
| 219 | 241 | } |
| 220 | 242 | |
@@ -231,24 +253,28 @@ discard block |
||
| 231 | 253 | $list_context['additional_rows'] = array(); |
| 232 | 254 | foreach ($listOptions['additional_rows'] as $row) |
| 233 | 255 | { |
| 234 | - if (empty($row)) |
|
| 235 | - continue; |
|
| 256 | + if (empty($row)) { |
|
| 257 | + continue; |
|
| 258 | + } |
|
| 236 | 259 | |
| 237 | 260 | // Supported row positions: top_of_list, after_title, |
| 238 | 261 | // above_column_headers, below_table_data, bottom_of_list. |
| 239 | - if (!isset($list_context['additional_rows'][$row['position']])) |
|
| 240 | - $list_context['additional_rows'][$row['position']] = array(); |
|
| 262 | + if (!isset($list_context['additional_rows'][$row['position']])) { |
|
| 263 | + $list_context['additional_rows'][$row['position']] = array(); |
|
| 264 | + } |
|
| 241 | 265 | $list_context['additional_rows'][$row['position']][] = $row; |
| 242 | 266 | } |
| 243 | 267 | } |
| 244 | 268 | |
| 245 | 269 | // Add an option for inline JavaScript. |
| 246 | - if (isset($listOptions['javascript'])) |
|
| 247 | - $list_context['javascript'] = $listOptions['javascript']; |
|
| 270 | + if (isset($listOptions['javascript'])) { |
|
| 271 | + $list_context['javascript'] = $listOptions['javascript']; |
|
| 272 | + } |
|
| 248 | 273 | |
| 249 | 274 | // We want a menu. |
| 250 | - if (isset($listOptions['list_menu'])) |
|
| 251 | - $list_context['list_menu'] = $listOptions['list_menu']; |
|
| 275 | + if (isset($listOptions['list_menu'])) { |
|
| 276 | + $list_context['list_menu'] = $listOptions['list_menu']; |
|
| 277 | + } |
|
| 252 | 278 | |
| 253 | 279 | // Make sure the template is loaded. |
| 254 | 280 | loadTemplate('GenericList'); |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 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 | * Redirect to the user help ;). |
@@ -95,12 +96,13 @@ discard block |
||
| 95 | 96 | ); |
| 96 | 97 | |
| 97 | 98 | // Have we got a localized one? |
| 98 | - if (file_exists($boarddir . '/agreement.' . $user_info['language'] . '.txt')) |
|
| 99 | - $context['agreement'] = parse_bbc(file_get_contents($boarddir . '/agreement.' . $user_info['language'] . '.txt'), true, 'agreement_' . $user_info['language']); |
|
| 100 | - elseif (file_exists($boarddir . '/agreement.txt')) |
|
| 101 | - $context['agreement'] = parse_bbc(file_get_contents($boarddir . '/agreement.txt'), true, 'agreement'); |
|
| 102 | - else |
|
| 103 | - $context['agreement'] = ''; |
|
| 99 | + if (file_exists($boarddir . '/agreement.' . $user_info['language'] . '.txt')) { |
|
| 100 | + $context['agreement'] = parse_bbc(file_get_contents($boarddir . '/agreement.' . $user_info['language'] . '.txt'), true, 'agreement_' . $user_info['language']); |
|
| 101 | + } elseif (file_exists($boarddir . '/agreement.txt')) { |
|
| 102 | + $context['agreement'] = parse_bbc(file_get_contents($boarddir . '/agreement.txt'), true, 'agreement'); |
|
| 103 | + } else { |
|
| 104 | + $context['agreement'] = ''; |
|
| 105 | + } |
|
| 104 | 106 | |
| 105 | 107 | // Nothing to show, so let's get out of here |
| 106 | 108 | if (empty($context['agreement'])) |
@@ -128,18 +130,21 @@ discard block |
||
| 128 | 130 | { |
| 129 | 131 | global $txt, $helptxt, $context, $scripturl; |
| 130 | 132 | |
| 131 | - if (!isset($_GET['help']) || !is_string($_GET['help'])) |
|
| 132 | - fatal_lang_error('no_access', false); |
|
| 133 | + if (!isset($_GET['help']) || !is_string($_GET['help'])) { |
|
| 134 | + fatal_lang_error('no_access', false); |
|
| 135 | + } |
|
| 133 | 136 | |
| 134 | - if (!isset($helptxt)) |
|
| 135 | - $helptxt = array(); |
|
| 137 | + if (!isset($helptxt)) { |
|
| 138 | + $helptxt = array(); |
|
| 139 | + } |
|
| 136 | 140 | |
| 137 | 141 | // Load the admin help language file and template. |
| 138 | 142 | loadLanguage('Help'); |
| 139 | 143 | |
| 140 | 144 | // Permission specific help? |
| 141 | - if (isset($_GET['help']) && substr($_GET['help'], 0, 14) == 'permissionhelp') |
|
| 142 | - loadLanguage('ManagePermissions'); |
|
| 145 | + if (isset($_GET['help']) && substr($_GET['help'], 0, 14) == 'permissionhelp') { |
|
| 146 | + loadLanguage('ManagePermissions'); |
|
| 147 | + } |
|
| 143 | 148 | |
| 144 | 149 | loadTemplate('Help'); |
| 145 | 150 | |
@@ -154,16 +159,18 @@ discard block |
||
| 154 | 159 | $context['sub_template'] = 'popup'; |
| 155 | 160 | |
| 156 | 161 | // What help string should be used? |
| 157 | - if (isset($helptxt[$_GET['help']])) |
|
| 158 | - $context['help_text'] = $helptxt[$_GET['help']]; |
|
| 159 | - elseif (isset($txt[$_GET['help']])) |
|
| 160 | - $context['help_text'] = $txt[$_GET['help']]; |
|
| 161 | - else |
|
| 162 | - $context['help_text'] = $_GET['help']; |
|
| 162 | + if (isset($helptxt[$_GET['help']])) { |
|
| 163 | + $context['help_text'] = $helptxt[$_GET['help']]; |
|
| 164 | + } elseif (isset($txt[$_GET['help']])) { |
|
| 165 | + $context['help_text'] = $txt[$_GET['help']]; |
|
| 166 | + } else { |
|
| 167 | + $context['help_text'] = $_GET['help']; |
|
| 168 | + } |
|
| 163 | 169 | |
| 164 | 170 | // Does this text contain a link that we should fill in? |
| 165 | - if (preg_match('~%([0-9]+\$)?s\?~', $context['help_text'], $match)) |
|
| 166 | - $context['help_text'] = sprintf($context['help_text'], $scripturl, $context['session_id'], $context['session_var']); |
|
| 167 | -} |
|
| 171 | + if (preg_match('~%([0-9]+\$)?s\?~', $context['help_text'], $match)) { |
|
| 172 | + $context['help_text'] = sprintf($context['help_text'], $scripturl, $context['session_id'], $context['session_var']); |
|
| 173 | + } |
|
| 174 | + } |
|
| 168 | 175 | |
| 169 | 176 | ?> |
| 170 | 177 | \ No newline at end of file |
@@ -11,8 +11,9 @@ |
||
| 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 | * Standard non full index, non custom index search |
@@ -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 | * Add the file functions to the $smcFunc array. |
@@ -52,8 +53,9 @@ discard block |
||
| 52 | 53 | 'messages', 'moderators', 'package_servers', 'permission_profiles', 'permissions', 'personal_messages', |
| 53 | 54 | 'pm_recipients', 'poll_choices', 'polls', 'scheduled_tasks', 'sessions', 'settings', 'smileys', |
| 54 | 55 | 'themes', 'topics'); |
| 55 | - foreach ($reservedTables as $k => $table_name) |
|
| 56 | - $reservedTables[$k] = strtolower($db_prefix . $table_name); |
|
| 56 | + foreach ($reservedTables as $k => $table_name) { |
|
| 57 | + $reservedTables[$k] = strtolower($db_prefix . $table_name); |
|
| 58 | + } |
|
| 57 | 59 | |
| 58 | 60 | // We in turn may need the extra stuff. |
| 59 | 61 | db_extend('extra'); |
@@ -102,8 +104,9 @@ discard block |
||
| 102 | 104 | $table_name = str_replace('{db_prefix}', $db_prefix, $table_name); |
| 103 | 105 | |
| 104 | 106 | // First - no way do we touch SMF tables. |
| 105 | - if (in_array(strtolower($table_name), $reservedTables)) |
|
| 106 | - return false; |
|
| 107 | + if (in_array(strtolower($table_name), $reservedTables)) { |
|
| 108 | + return false; |
|
| 109 | + } |
|
| 107 | 110 | |
| 108 | 111 | // Log that we'll want to remove this on uninstall. |
| 109 | 112 | $db_package_log[] = array('remove_table', $table_name); |
@@ -113,10 +116,11 @@ discard block |
||
| 113 | 116 | if (in_array($full_table_name, $tables)) |
| 114 | 117 | { |
| 115 | 118 | // This is a sad day... drop the table? If not, return false (error) by default. |
| 116 | - if ($if_exists == 'overwrite') |
|
| 117 | - $smcFunc['db_drop_table']($table_name); |
|
| 118 | - else |
|
| 119 | - return $if_exists == 'ignore'; |
|
| 119 | + if ($if_exists == 'overwrite') { |
|
| 120 | + $smcFunc['db_drop_table']($table_name); |
|
| 121 | + } else { |
|
| 122 | + return $if_exists == 'ignore'; |
|
| 123 | + } |
|
| 120 | 124 | } |
| 121 | 125 | |
| 122 | 126 | // If we've got this far - good news - no table exists. We can build our own! |
@@ -134,17 +138,18 @@ discard block |
||
| 134 | 138 | ) |
| 135 | 139 | ); |
| 136 | 140 | $default = 'default nextval(\'' . $table_name . '_seq\')'; |
| 141 | + } elseif (isset($column['default']) && $column['default'] !== null) { |
|
| 142 | + $default = 'default \'' . $smcFunc['db_escape_string']($column['default']) . '\''; |
|
| 143 | + } else { |
|
| 144 | + $default = ''; |
|
| 137 | 145 | } |
| 138 | - elseif (isset($column['default']) && $column['default'] !== null) |
|
| 139 | - $default = 'default \'' . $smcFunc['db_escape_string']($column['default']) . '\''; |
|
| 140 | - else |
|
| 141 | - $default = ''; |
|
| 142 | 146 | |
| 143 | 147 | // Sort out the size... |
| 144 | 148 | $column['size'] = isset($column['size']) && is_numeric($column['size']) ? $column['size'] : null; |
| 145 | 149 | list ($type, $size) = $smcFunc['db_calculate_type']($column['type'], $column['size']); |
| 146 | - if ($size !== null) |
|
| 147 | - $type = $type . '(' . $size . ')'; |
|
| 150 | + if ($size !== null) { |
|
| 151 | + $type = $type . '(' . $size . ')'; |
|
| 152 | + } |
|
| 148 | 153 | |
| 149 | 154 | // Now just put it together! |
| 150 | 155 | $table_query .= "\n\t\"" . $column['name'] . '" ' . $type . ' ' . (!empty($column['null']) ? '' : 'NOT NULL') . ' ' . $default . ','; |
@@ -157,19 +162,21 @@ discard block |
||
| 157 | 162 | $columns = implode(',', $index['columns']); |
| 158 | 163 | |
| 159 | 164 | // Primary goes in the table... |
| 160 | - if (isset($index['type']) && $index['type'] == 'primary') |
|
| 161 | - $table_query .= "\n\t" . 'PRIMARY KEY (' . implode(',', $index['columns']) . '),'; |
|
| 162 | - else |
|
| 165 | + if (isset($index['type']) && $index['type'] == 'primary') { |
|
| 166 | + $table_query .= "\n\t" . 'PRIMARY KEY (' . implode(',', $index['columns']) . '),'; |
|
| 167 | + } else |
|
| 163 | 168 | { |
| 164 | - if (empty($index['name'])) |
|
| 165 | - $index['name'] = implode('_', $index['columns']); |
|
| 169 | + if (empty($index['name'])) { |
|
| 170 | + $index['name'] = implode('_', $index['columns']); |
|
| 171 | + } |
|
| 166 | 172 | $index_queries[] = 'CREATE ' . (isset($index['type']) && $index['type'] == 'unique' ? 'UNIQUE' : '') . ' INDEX ' . $table_name . '_' . $index['name'] . ' ON ' . $table_name . ' (' . $columns . ')'; |
| 167 | 173 | } |
| 168 | 174 | } |
| 169 | 175 | |
| 170 | 176 | // No trailing commas! |
| 171 | - if (substr($table_query, -1) == ',') |
|
| 172 | - $table_query = substr($table_query, 0, -1); |
|
| 177 | + if (substr($table_query, -1) == ',') { |
|
| 178 | + $table_query = substr($table_query, 0, -1); |
|
| 179 | + } |
|
| 173 | 180 | |
| 174 | 181 | $table_query .= ')'; |
| 175 | 182 | |
@@ -180,12 +187,13 @@ discard block |
||
| 180 | 187 | ) |
| 181 | 188 | ); |
| 182 | 189 | // And the indexes... |
| 183 | - foreach ($index_queries as $query) |
|
| 184 | - $smcFunc['db_query']('', $query, |
|
| 190 | + foreach ($index_queries as $query) { |
|
| 191 | + $smcFunc['db_query']('', $query, |
|
| 185 | 192 | array( |
| 186 | 193 | 'security_override' => true, |
| 187 | 194 | ) |
| 188 | 195 | ); |
| 196 | + } |
|
| 189 | 197 | |
| 190 | 198 | // Go, go power rangers! |
| 191 | 199 | $smcFunc['db_transaction']('commit'); |
@@ -213,8 +221,9 @@ discard block |
||
| 213 | 221 | $table_name = str_replace('{db_prefix}', $db_prefix, $table_name); |
| 214 | 222 | |
| 215 | 223 | // God no - dropping one of these = bad. |
| 216 | - if (in_array(strtolower($table_name), $reservedTables)) |
|
| 217 | - return false; |
|
| 224 | + if (in_array(strtolower($table_name), $reservedTables)) { |
|
| 225 | + return false; |
|
| 226 | + } |
|
| 218 | 227 | |
| 219 | 228 | // Does it exist? |
| 220 | 229 | if (in_array($full_table_name, $smcFunc['db_list_tables']())) |
@@ -272,21 +281,24 @@ discard block |
||
| 272 | 281 | |
| 273 | 282 | // Does it exist - if so don't add it again! |
| 274 | 283 | $columns = $smcFunc['db_list_columns']($table_name, false); |
| 275 | - foreach ($columns as $column) |
|
| 276 | - if ($column == $column_info['name']) |
|
| 284 | + foreach ($columns as $column) { |
|
| 285 | + if ($column == $column_info['name']) |
|
| 277 | 286 | { |
| 278 | 287 | // If we're going to overwrite then use change column. |
| 279 | 288 | if ($if_exists == 'update') |
| 280 | 289 | return $smcFunc['db_change_column']($table_name, $column_info['name'], $column_info); |
| 281 | - else |
|
| 282 | - return false; |
|
| 290 | + } |
|
| 291 | + else { |
|
| 292 | + return false; |
|
| 293 | + } |
|
| 283 | 294 | } |
| 284 | 295 | |
| 285 | 296 | // Get the specifics... |
| 286 | 297 | $column_info['size'] = isset($column_info['size']) && is_numeric($column_info['size']) ? $column_info['size'] : null; |
| 287 | 298 | list ($type, $size) = $smcFunc['db_calculate_type']($column_info['type'], $column_info['size']); |
| 288 | - if ($size !== null) |
|
| 289 | - $type = $type . '(' . $size . ')'; |
|
| 299 | + if ($size !== null) { |
|
| 300 | + $type = $type . '(' . $size . ')'; |
|
| 301 | + } |
|
| 290 | 302 | |
| 291 | 303 | // Now add the thing! |
| 292 | 304 | $query = ' |
@@ -301,11 +313,12 @@ discard block |
||
| 301 | 313 | // If there's more attributes they need to be done via a change on PostgreSQL. |
| 302 | 314 | unset($column_info['type'], $column_info['size']); |
| 303 | 315 | |
| 304 | - if (count($column_info) != 1) |
|
| 305 | - return $smcFunc['db_change_column']($table_name, $column_info['name'], $column_info); |
|
| 306 | - else |
|
| 307 | - return true; |
|
| 308 | -} |
|
| 316 | + if (count($column_info) != 1) { |
|
| 317 | + return $smcFunc['db_change_column']($table_name, $column_info['name'], $column_info); |
|
| 318 | + } else { |
|
| 319 | + return true; |
|
| 320 | + } |
|
| 321 | + } |
|
| 309 | 322 | |
| 310 | 323 | /** |
| 311 | 324 | * Removes a column. |
@@ -324,8 +337,8 @@ discard block |
||
| 324 | 337 | |
| 325 | 338 | // Does it exist? |
| 326 | 339 | $columns = $smcFunc['db_list_columns']($table_name, true); |
| 327 | - foreach ($columns as $column) |
|
| 328 | - if ($column['name'] == $column_name) |
|
| 340 | + foreach ($columns as $column) { |
|
| 341 | + if ($column['name'] == $column_name) |
|
| 329 | 342 | { |
| 330 | 343 | // If there is an auto we need remove it! |
| 331 | 344 | if ($column['auto']) |
@@ -335,6 +348,7 @@ discard block |
||
| 335 | 348 | 'security_override' => true, |
| 336 | 349 | ) |
| 337 | 350 | ); |
| 351 | + } |
|
| 338 | 352 | |
| 339 | 353 | $smcFunc['db_query']('', ' |
| 340 | 354 | ALTER TABLE ' . $table_name . ' |
@@ -369,13 +383,15 @@ discard block |
||
| 369 | 383 | // Check it does exist! |
| 370 | 384 | $columns = $smcFunc['db_list_columns']($table_name, true); |
| 371 | 385 | $old_info = null; |
| 372 | - foreach ($columns as $column) |
|
| 373 | - if ($column['name'] == $old_column) |
|
| 386 | + foreach ($columns as $column) { |
|
| 387 | + if ($column['name'] == $old_column) |
|
| 374 | 388 | $old_info = $column; |
| 389 | + } |
|
| 375 | 390 | |
| 376 | 391 | // Nothing? |
| 377 | - if ($old_info == null) |
|
| 378 | - return false; |
|
| 392 | + if ($old_info == null) { |
|
| 393 | + return false; |
|
| 394 | + } |
|
| 379 | 395 | |
| 380 | 396 | // Now we check each bit individually and ALTER as required. |
| 381 | 397 | if (isset($column_info['name']) && $column_info['name'] != $old_column) |
@@ -432,8 +448,9 @@ discard block |
||
| 432 | 448 | { |
| 433 | 449 | $column_info['size'] = isset($column_info['size']) && is_numeric($column_info['size']) ? $column_info['size'] : null; |
| 434 | 450 | list ($type, $size) = $smcFunc['db_calculate_type']($column_info['type'], $column_info['size']); |
| 435 | - if ($size !== null) |
|
| 436 | - $type = $type . '(' . $size . ')'; |
|
| 451 | + if ($size !== null) { |
|
| 452 | + $type = $type . '(' . $size . ')'; |
|
| 453 | + } |
|
| 437 | 454 | |
| 438 | 455 | // The alter is a pain. |
| 439 | 456 | $smcFunc['db_transaction']('begin'); |
@@ -527,21 +544,23 @@ discard block |
||
| 527 | 544 | $table_name = str_replace('{db_prefix}', $db_prefix, $table_name); |
| 528 | 545 | |
| 529 | 546 | // No columns = no index. |
| 530 | - if (empty($index_info['columns'])) |
|
| 531 | - return false; |
|
| 547 | + if (empty($index_info['columns'])) { |
|
| 548 | + return false; |
|
| 549 | + } |
|
| 532 | 550 | $columns = implode(',', $index_info['columns']); |
| 533 | 551 | |
| 534 | 552 | // No name - make it up! |
| 535 | 553 | if (empty($index_info['name'])) |
| 536 | 554 | { |
| 537 | 555 | // No need for primary. |
| 538 | - if (isset($index_info['type']) && $index_info['type'] == 'primary') |
|
| 539 | - $index_info['name'] = ''; |
|
| 540 | - else |
|
| 541 | - $index_info['name'] = $table_name . implode('_', $index_info['columns']); |
|
| 556 | + if (isset($index_info['type']) && $index_info['type'] == 'primary') { |
|
| 557 | + $index_info['name'] = ''; |
|
| 558 | + } else { |
|
| 559 | + $index_info['name'] = $table_name . implode('_', $index_info['columns']); |
|
| 560 | + } |
|
| 561 | + } else { |
|
| 562 | + $index_info['name'] = $table_name . $index_info['name']; |
|
| 542 | 563 | } |
| 543 | - else |
|
| 544 | - $index_info['name'] = $table_name . $index_info['name']; |
|
| 545 | 564 | |
| 546 | 565 | // Log that we are going to want to remove this! |
| 547 | 566 | $db_package_log[] = array('remove_index', $table_name, $index_info['name']); |
@@ -554,10 +573,11 @@ discard block |
||
| 554 | 573 | if ($index['name'] == $index_info['name'] || ($index['type'] == 'primary' && isset($index_info['type']) && $index_info['type'] == 'primary')) |
| 555 | 574 | { |
| 556 | 575 | // If we want to overwrite simply remove the current one then continue. |
| 557 | - if ($if_exists != 'update' || $index['type'] == 'primary') |
|
| 558 | - return false; |
|
| 559 | - else |
|
| 560 | - $smcFunc['db_remove_index']($table_name, $index_info['name']); |
|
| 576 | + if ($if_exists != 'update' || $index['type'] == 'primary') { |
|
| 577 | + return false; |
|
| 578 | + } else { |
|
| 579 | + $smcFunc['db_remove_index']($table_name, $index_info['name']); |
|
| 580 | + } |
|
| 561 | 581 | } |
| 562 | 582 | } |
| 563 | 583 | |
@@ -571,8 +591,7 @@ discard block |
||
| 571 | 591 | 'security_override' => true, |
| 572 | 592 | ) |
| 573 | 593 | ); |
| 574 | - } |
|
| 575 | - else |
|
| 594 | + } else |
|
| 576 | 595 | { |
| 577 | 596 | $smcFunc['db_query']('', ' |
| 578 | 597 | CREATE ' . (isset($index_info['type']) && $index_info['type'] == 'unique' ? 'UNIQUE' : '') . ' INDEX ' . $index_info['name'] . ' ON ' . $table_name . ' (' . $columns . ')', |
@@ -600,8 +619,9 @@ discard block |
||
| 600 | 619 | |
| 601 | 620 | // Better exist! |
| 602 | 621 | $indexes = $smcFunc['db_list_indexes']($table_name, true); |
| 603 | - if ($index_name != 'primary') |
|
| 604 | - $index_name = $table_name . '_' . $index_name; |
|
| 622 | + if ($index_name != 'primary') { |
|
| 623 | + $index_name = $table_name . '_' . $index_name; |
|
| 624 | + } |
|
| 605 | 625 | |
| 606 | 626 | foreach ($indexes as $index) |
| 607 | 627 | { |
@@ -665,8 +685,7 @@ discard block |
||
| 665 | 685 | 'datetime' => 'timestamp without time zone', |
| 666 | 686 | 'timestamp' => 'timestamp without time zone', |
| 667 | 687 | ); |
| 668 | - } |
|
| 669 | - else |
|
| 688 | + } else |
|
| 670 | 689 | { |
| 671 | 690 | $types = array( |
| 672 | 691 | 'character varying' => 'varchar', |
@@ -682,14 +701,16 @@ discard block |
||
| 682 | 701 | // Got it? Change it! |
| 683 | 702 | if (isset($types[$type_name])) |
| 684 | 703 | { |
| 685 | - if ($type_name == 'tinytext') |
|
| 686 | - $type_size = 255; |
|
| 704 | + if ($type_name == 'tinytext') { |
|
| 705 | + $type_size = 255; |
|
| 706 | + } |
|
| 687 | 707 | $type_name = $types[$type_name]; |
| 688 | 708 | } |
| 689 | 709 | |
| 690 | 710 | // Only char fields got size |
| 691 | - if (strpos($type_name, 'char') === false) |
|
| 692 | - $type_size = null; |
|
| 711 | + if (strpos($type_name, 'char') === false) { |
|
| 712 | + $type_size = null; |
|
| 713 | + } |
|
| 693 | 714 | |
| 694 | 715 | |
| 695 | 716 | return array($type_name, $type_size); |
@@ -744,8 +765,7 @@ discard block |
||
| 744 | 765 | if (!$detail) |
| 745 | 766 | { |
| 746 | 767 | $columns[] = $row['column_name']; |
| 747 | - } |
|
| 748 | - else |
|
| 768 | + } else |
|
| 749 | 769 | { |
| 750 | 770 | $auto = false; |
| 751 | 771 | // What is the default? |
@@ -753,11 +773,11 @@ discard block |
||
| 753 | 773 | { |
| 754 | 774 | $default = null; |
| 755 | 775 | $auto = true; |
| 776 | + } elseif (trim($row['column_default']) != '') { |
|
| 777 | + $default = strpos($row['column_default'], '::') === false ? $row['column_default'] : substr($row['column_default'], 0, strpos($row['column_default'], '::')); |
|
| 778 | + } else { |
|
| 779 | + $default = null; |
|
| 756 | 780 | } |
| 757 | - elseif (trim($row['column_default']) != '') |
|
| 758 | - $default = strpos($row['column_default'], '::') === false ? $row['column_default'] : substr($row['column_default'], 0, strpos($row['column_default'], '::')); |
|
| 759 | - else |
|
| 760 | - $default = null; |
|
| 761 | 781 | |
| 762 | 782 | // Make the type generic. |
| 763 | 783 | list ($type, $size) = $smcFunc['db_calculate_type']($row['data_type'], $row['character_maximum_length'], true); |
@@ -808,26 +828,30 @@ discard block |
||
| 808 | 828 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 809 | 829 | { |
| 810 | 830 | // Try get the columns that make it up. |
| 811 | - if (preg_match('~\(([^\)]+?)\)~i', $row['inddef'], $matches) == 0) |
|
| 812 | - continue; |
|
| 831 | + if (preg_match('~\(([^\)]+?)\)~i', $row['inddef'], $matches) == 0) { |
|
| 832 | + continue; |
|
| 833 | + } |
|
| 813 | 834 | |
| 814 | 835 | $columns = explode(',', $matches[1]); |
| 815 | 836 | |
| 816 | - if (empty($columns)) |
|
| 817 | - continue; |
|
| 837 | + if (empty($columns)) { |
|
| 838 | + continue; |
|
| 839 | + } |
|
| 818 | 840 | |
| 819 | - foreach ($columns as $k => $v) |
|
| 820 | - $columns[$k] = trim($v); |
|
| 841 | + foreach ($columns as $k => $v) { |
|
| 842 | + $columns[$k] = trim($v); |
|
| 843 | + } |
|
| 821 | 844 | |
| 822 | 845 | // Fix up the name to be consistent cross databases |
| 823 | - if (substr($row['name'], -5) == '_pkey' && $row['is_primary'] == 1) |
|
| 824 | - $row['name'] = 'PRIMARY'; |
|
| 825 | - else |
|
| 826 | - $row['name'] = str_replace($table_name . '_', '', $row['name']); |
|
| 846 | + if (substr($row['name'], -5) == '_pkey' && $row['is_primary'] == 1) { |
|
| 847 | + $row['name'] = 'PRIMARY'; |
|
| 848 | + } else { |
|
| 849 | + $row['name'] = str_replace($table_name . '_', '', $row['name']); |
|
| 850 | + } |
|
| 827 | 851 | |
| 828 | - if (!$detail) |
|
| 829 | - $indexes[] = $row['name']; |
|
| 830 | - else |
|
| 852 | + if (!$detail) { |
|
| 853 | + $indexes[] = $row['name']; |
|
| 854 | + } else |
|
| 831 | 855 | { |
| 832 | 856 | $indexes[$row['name']] = array( |
| 833 | 857 | 'name' => $row['name'], |
@@ -382,7 +382,7 @@ |
||
| 382 | 382 | * @param array $parameters Not used? |
| 383 | 383 | * @param string $if_exists What to do if the index exists. If 'update', the definition will be updated. |
| 384 | 384 | * @param string $error |
| 385 | - * @return boolean Whether or not the operation was successful |
|
| 385 | + * @return false|null Whether or not the operation was successful |
|
| 386 | 386 | */ |
| 387 | 387 | function smf_db_add_index($table_name, $index_info, $parameters = array(), $if_exists = 'update', $error = 'fatal') |
| 388 | 388 | { |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | if (filemtime($boarddir . '/db_last_error.php') === $last_db_error_change) |
| 176 | 176 | { |
| 177 | 177 | // Write the change |
| 178 | - $write_db_change = '<' . '?' . "php\n" . '$db_last_error = ' . time() . ';' . "\n" . '?' . '>'; |
|
| 178 | + $write_db_change = '<' . '?' . "php\n" . '$db_last_error = ' . time() . ';' . "\n" . '?' . '>'; |
|
| 179 | 179 | $written_bytes = file_put_contents($boarddir . '/db_last_error.php', $write_db_change, LOCK_EX); |
| 180 | 180 | |
| 181 | 181 | // survey says ... |
@@ -248,7 +248,7 @@ discard block |
||
| 248 | 248 | ', $txt['debug_language_files'], count($context['debug']['language_files']), ': <em>', implode('</em>, <em>', $context['debug']['language_files']), '</em>.<br> |
| 249 | 249 | ', $txt['debug_stylesheets'], count($context['debug']['sheets']), ': <em>', implode('</em>, <em>', $context['debug']['sheets']), '</em>.<br> |
| 250 | 250 | ', $txt['debug_hooks'], empty($context['debug']['hooks']) ? 0 : count($context['debug']['hooks']) . ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_hooks\').style.display = \'inline\'; this.style.display = \'none\'; return false;">', $txt['debug_show'], '</a><span id="debug_hooks" style="display: none;"><em>' . implode('</em>, <em>', $context['debug']['hooks']), '</em></span>)', '<br> |
| 251 | - ',(isset($context['debug']['instances']) ? ($txt['debug_instances'] . (empty($context['debug']['instances']) ? 0 : count($context['debug']['instances'])) . ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_instances\').style.display = \'inline\'; this.style.display = \'none\'; return false;">'. $txt['debug_show'] .'</a><span id="debug_instances" style="display: none;"><em>'. implode('</em>, <em>', array_keys($context['debug']['instances'])) .'</em></span>)'. '<br>') : ''),' |
|
| 251 | + ',(isset($context['debug']['instances']) ? ($txt['debug_instances'] . (empty($context['debug']['instances']) ? 0 : count($context['debug']['instances'])) . ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_instances\').style.display = \'inline\'; this.style.display = \'none\'; return false;">' . $txt['debug_show'] . '</a><span id="debug_instances" style="display: none;"><em>' . implode('</em>, <em>', array_keys($context['debug']['instances'])) . '</em></span>)' . '<br>') : ''), ' |
|
| 252 | 252 | ', $txt['debug_files_included'], count($files), ' - ', round($total_size / 1024), $txt['debug_kb'], ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_include_info\').style.display = \'inline\'; this.style.display = \'none\'; return false;">', $txt['debug_show'], '</a><span id="debug_include_info" style="display: none;"><em>', implode('</em>, <em>', $files), '</em></span>)<br>'; |
| 253 | 253 | |
| 254 | 254 | if (function_exists('memory_get_peak_usage')) |
@@ -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 | * Put this user in the online log. |
@@ -33,8 +34,9 @@ discard block |
||
| 33 | 34 | // Don't update for every page - this isn't wholly accurate but who cares. |
| 34 | 35 | if ($topic) |
| 35 | 36 | { |
| 36 | - if (isset($_SESSION['last_topic_id']) && $_SESSION['last_topic_id'] == $topic) |
|
| 37 | - $force = false; |
|
| 37 | + if (isset($_SESSION['last_topic_id']) && $_SESSION['last_topic_id'] == $topic) { |
|
| 38 | + $force = false; |
|
| 39 | + } |
|
| 38 | 40 | $_SESSION['last_topic_id'] = $topic; |
| 39 | 41 | } |
| 40 | 42 | } |
@@ -47,22 +49,24 @@ discard block |
||
| 47 | 49 | } |
| 48 | 50 | |
| 49 | 51 | // Don't mark them as online more than every so often. |
| 50 | - if (!empty($_SESSION['log_time']) && $_SESSION['log_time'] >= (time() - 8) && !$force) |
|
| 51 | - return; |
|
| 52 | + if (!empty($_SESSION['log_time']) && $_SESSION['log_time'] >= (time() - 8) && !$force) { |
|
| 53 | + return; |
|
| 54 | + } |
|
| 52 | 55 | |
| 53 | 56 | if (!empty($modSettings['who_enabled'])) |
| 54 | 57 | { |
| 55 | 58 | $serialized = $_GET + array('USER_AGENT' => $_SERVER['HTTP_USER_AGENT']); |
| 56 | 59 | |
| 57 | 60 | // In the case of a dlattach action, session_var may not be set. |
| 58 | - if (!isset($context['session_var'])) |
|
| 59 | - $context['session_var'] = $_SESSION['session_var']; |
|
| 61 | + if (!isset($context['session_var'])) { |
|
| 62 | + $context['session_var'] = $_SESSION['session_var']; |
|
| 63 | + } |
|
| 60 | 64 | |
| 61 | 65 | unset($serialized['sesc'], $serialized[$context['session_var']]); |
| 62 | 66 | $serialized = json_encode($serialized); |
| 67 | + } else { |
|
| 68 | + $serialized = ''; |
|
| 63 | 69 | } |
| 64 | - else |
|
| 65 | - $serialized = ''; |
|
| 66 | 70 | |
| 67 | 71 | // Guests use 0, members use their session ID. |
| 68 | 72 | $session_id = $user_info['is_guest'] ? 'ip' . $user_info['ip'] : session_id(); |
@@ -102,17 +106,18 @@ discard block |
||
| 102 | 106 | ); |
| 103 | 107 | |
| 104 | 108 | // Guess it got deleted. |
| 105 | - if ($smcFunc['db_affected_rows']() == 0) |
|
| 109 | + if ($smcFunc['db_affected_rows']() == 0) { |
|
| 110 | + $_SESSION['log_time'] = 0; |
|
| 111 | + } |
|
| 112 | + } else { |
|
| 106 | 113 | $_SESSION['log_time'] = 0; |
| 107 | 114 | } |
| 108 | - else |
|
| 109 | - $_SESSION['log_time'] = 0; |
|
| 110 | 115 | |
| 111 | 116 | // Otherwise, we have to delete and insert. |
| 112 | 117 | if (empty($_SESSION['log_time'])) |
| 113 | 118 | { |
| 114 | - if ($do_delete || !empty($user_info['id'])) |
|
| 115 | - $smcFunc['db_query']('', ' |
|
| 119 | + if ($do_delete || !empty($user_info['id'])) { |
|
| 120 | + $smcFunc['db_query']('', ' |
|
| 116 | 121 | DELETE FROM {db_prefix}log_online |
| 117 | 122 | WHERE ' . ($do_delete ? 'log_time < {int:log_time}' : '') . ($do_delete && !empty($user_info['id']) ? ' OR ' : '') . (empty($user_info['id']) ? '' : 'id_member = {int:current_member}'), |
| 118 | 123 | array( |
@@ -120,6 +125,7 @@ discard block |
||
| 120 | 125 | 'log_time' => time() - $modSettings['lastActive'] * 60, |
| 121 | 126 | ) |
| 122 | 127 | ); |
| 128 | + } |
|
| 123 | 129 | |
| 124 | 130 | $smcFunc['db_insert']($do_delete ? 'ignore' : 'replace', |
| 125 | 131 | '{db_prefix}log_online', |
@@ -133,21 +139,24 @@ discard block |
||
| 133 | 139 | $_SESSION['log_time'] = time(); |
| 134 | 140 | |
| 135 | 141 | // Well, they are online now. |
| 136 | - if (empty($_SESSION['timeOnlineUpdated'])) |
|
| 137 | - $_SESSION['timeOnlineUpdated'] = time(); |
|
| 142 | + if (empty($_SESSION['timeOnlineUpdated'])) { |
|
| 143 | + $_SESSION['timeOnlineUpdated'] = time(); |
|
| 144 | + } |
|
| 138 | 145 | |
| 139 | 146 | // Set their login time, if not already done within the last minute. |
| 140 | 147 | if (SMF != 'SSI' && !empty($user_info['last_login']) && $user_info['last_login'] < time() - 60 && (!isset($_REQUEST['action']) || !in_array($_REQUEST['action'], array('.xml', 'login2', 'logintfa')))) |
| 141 | 148 | { |
| 142 | 149 | // Don't count longer than 15 minutes. |
| 143 | - if (time() - $_SESSION['timeOnlineUpdated'] > 60 * 15) |
|
| 144 | - $_SESSION['timeOnlineUpdated'] = time(); |
|
| 150 | + if (time() - $_SESSION['timeOnlineUpdated'] > 60 * 15) { |
|
| 151 | + $_SESSION['timeOnlineUpdated'] = time(); |
|
| 152 | + } |
|
| 145 | 153 | |
| 146 | 154 | $user_settings['total_time_logged_in'] += time() - $_SESSION['timeOnlineUpdated']; |
| 147 | 155 | updateMemberData($user_info['id'], array('last_login' => time(), 'member_ip' => $user_info['ip'], 'member_ip2' => $_SERVER['BAN_CHECK_IP'], 'total_time_logged_in' => $user_settings['total_time_logged_in'])); |
| 148 | 156 | |
| 149 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) |
|
| 150 | - cache_put_data('user_settings-' . $user_info['id'], $user_settings, 60); |
|
| 157 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { |
|
| 158 | + cache_put_data('user_settings-' . $user_info['id'], $user_settings, 60); |
|
| 159 | + } |
|
| 151 | 160 | |
| 152 | 161 | $user_info['total_time_logged_in'] += time() - $_SESSION['timeOnlineUpdated']; |
| 153 | 162 | $_SESSION['timeOnlineUpdated'] = time(); |
@@ -184,8 +193,7 @@ discard block |
||
| 184 | 193 | // Oops. maybe we have no more disk space left, or some other troubles, troubles... |
| 185 | 194 | // Copy the file back and run for your life! |
| 186 | 195 | @copy($boarddir . '/db_last_error_bak.php', $boarddir . '/db_last_error.php'); |
| 187 | - } |
|
| 188 | - else |
|
| 196 | + } else |
|
| 189 | 197 | { |
| 190 | 198 | @touch($boarddir . '/' . 'Settings.php'); |
| 191 | 199 | return true; |
@@ -205,22 +213,27 @@ discard block |
||
| 205 | 213 | global $db_cache, $db_count, $cache_misses, $cache_count_misses, $db_show_debug, $cache_count, $cache_hits, $smcFunc, $txt; |
| 206 | 214 | |
| 207 | 215 | // Add to Settings.php if you want to show the debugging information. |
| 208 | - if (!isset($db_show_debug) || $db_show_debug !== true || (isset($_GET['action']) && $_GET['action'] == 'viewquery')) |
|
| 209 | - return; |
|
| 216 | + if (!isset($db_show_debug) || $db_show_debug !== true || (isset($_GET['action']) && $_GET['action'] == 'viewquery')) { |
|
| 217 | + return; |
|
| 218 | + } |
|
| 210 | 219 | |
| 211 | - if (empty($_SESSION['view_queries'])) |
|
| 212 | - $_SESSION['view_queries'] = 0; |
|
| 213 | - if (empty($context['debug']['language_files'])) |
|
| 214 | - $context['debug']['language_files'] = array(); |
|
| 215 | - if (empty($context['debug']['sheets'])) |
|
| 216 | - $context['debug']['sheets'] = array(); |
|
| 220 | + if (empty($_SESSION['view_queries'])) { |
|
| 221 | + $_SESSION['view_queries'] = 0; |
|
| 222 | + } |
|
| 223 | + if (empty($context['debug']['language_files'])) { |
|
| 224 | + $context['debug']['language_files'] = array(); |
|
| 225 | + } |
|
| 226 | + if (empty($context['debug']['sheets'])) { |
|
| 227 | + $context['debug']['sheets'] = array(); |
|
| 228 | + } |
|
| 217 | 229 | |
| 218 | 230 | $files = get_included_files(); |
| 219 | 231 | $total_size = 0; |
| 220 | 232 | for ($i = 0, $n = count($files); $i < $n; $i++) |
| 221 | 233 | { |
| 222 | - if (file_exists($files[$i])) |
|
| 223 | - $total_size += filesize($files[$i]); |
|
| 234 | + if (file_exists($files[$i])) { |
|
| 235 | + $total_size += filesize($files[$i]); |
|
| 236 | + } |
|
| 224 | 237 | $files[$i] = strtr($files[$i], array($boarddir => '.', $sourcedir => '(Sources)', $cachedir => '(Cache)', $settings['actual_theme_dir'] => '(Current Theme)')); |
| 225 | 238 | } |
| 226 | 239 | |
@@ -229,8 +242,9 @@ discard block |
||
| 229 | 242 | { |
| 230 | 243 | foreach ($db_cache as $q => $qq) |
| 231 | 244 | { |
| 232 | - if (!empty($qq['w'])) |
|
| 233 | - $warnings += count($qq['w']); |
|
| 245 | + if (!empty($qq['w'])) { |
|
| 246 | + $warnings += count($qq['w']); |
|
| 247 | + } |
|
| 234 | 248 | } |
| 235 | 249 | |
| 236 | 250 | $_SESSION['debug'] = &$db_cache; |
@@ -251,12 +265,14 @@ discard block |
||
| 251 | 265 | ',(isset($context['debug']['instances']) ? ($txt['debug_instances'] . (empty($context['debug']['instances']) ? 0 : count($context['debug']['instances'])) . ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_instances\').style.display = \'inline\'; this.style.display = \'none\'; return false;">'. $txt['debug_show'] .'</a><span id="debug_instances" style="display: none;"><em>'. implode('</em>, <em>', array_keys($context['debug']['instances'])) .'</em></span>)'. '<br>') : ''),' |
| 252 | 266 | ', $txt['debug_files_included'], count($files), ' - ', round($total_size / 1024), $txt['debug_kb'], ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_include_info\').style.display = \'inline\'; this.style.display = \'none\'; return false;">', $txt['debug_show'], '</a><span id="debug_include_info" style="display: none;"><em>', implode('</em>, <em>', $files), '</em></span>)<br>'; |
| 253 | 267 | |
| 254 | - if (function_exists('memory_get_peak_usage')) |
|
| 255 | - echo $txt['debug_memory_use'], ceil(memory_get_peak_usage() / 1024), $txt['debug_kb'], '<br>'; |
|
| 268 | + if (function_exists('memory_get_peak_usage')) { |
|
| 269 | + echo $txt['debug_memory_use'], ceil(memory_get_peak_usage() / 1024), $txt['debug_kb'], '<br>'; |
|
| 270 | + } |
|
| 256 | 271 | |
| 257 | 272 | // What tokens are active? |
| 258 | - if (isset($_SESSION['token'])) |
|
| 259 | - echo $txt['debug_tokens'] . '<em>' . implode(',</em> <em>', array_keys($_SESSION['token'])), '</em>.<br>'; |
|
| 273 | + if (isset($_SESSION['token'])) { |
|
| 274 | + echo $txt['debug_tokens'] . '<em>' . implode(',</em> <em>', array_keys($_SESSION['token'])), '</em>.<br>'; |
|
| 275 | + } |
|
| 260 | 276 | |
| 261 | 277 | if (!empty($modSettings['cache_enable']) && !empty($cache_hits)) |
| 262 | 278 | { |
@@ -269,10 +285,12 @@ discard block |
||
| 269 | 285 | $total_t += $cache_hit['t']; |
| 270 | 286 | $total_s += $cache_hit['s']; |
| 271 | 287 | } |
| 272 | - if (!isset($cache_misses)) |
|
| 273 | - $cache_misses = array(); |
|
| 274 | - foreach ($cache_misses as $missed) |
|
| 275 | - $missed_entires[] = $missed['d'] . ' ' . $missed['k']; |
|
| 288 | + if (!isset($cache_misses)) { |
|
| 289 | + $cache_misses = array(); |
|
| 290 | + } |
|
| 291 | + foreach ($cache_misses as $missed) { |
|
| 292 | + $missed_entires[] = $missed['d'] . ' ' . $missed['k']; |
|
| 293 | + } |
|
| 276 | 294 | |
| 277 | 295 | echo ' |
| 278 | 296 | ', $txt['debug_cache_hits'], $cache_count, ': ', sprintf($txt['debug_cache_seconds_bytes_total'], comma_format($total_t, 5), comma_format($total_s)), ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_cache_info\').style.display = \'inline\'; this.style.display = \'none\'; return false;">', $txt['debug_show'], '</a><span id="debug_cache_info" style="display: none;"><em>', implode('</em>, <em>', $entries), '</em></span>)<br> |
@@ -283,38 +301,44 @@ discard block |
||
| 283 | 301 | <a href="', $scripturl, '?action=viewquery" target="_blank" class="new_win">', $warnings == 0 ? sprintf($txt['debug_queries_used'], (int) $db_count) : sprintf($txt['debug_queries_used_and_warnings'], (int) $db_count, $warnings), '</a><br> |
| 284 | 302 | <br>'; |
| 285 | 303 | |
| 286 | - if ($_SESSION['view_queries'] == 1 && !empty($db_cache)) |
|
| 287 | - foreach ($db_cache as $q => $qq) |
|
| 304 | + if ($_SESSION['view_queries'] == 1 && !empty($db_cache)) { |
|
| 305 | + foreach ($db_cache as $q => $qq) |
|
| 288 | 306 | { |
| 289 | 307 | $is_select = strpos(trim($qq['q']), 'SELECT') === 0 || preg_match('~^INSERT(?: IGNORE)? INTO \w+(?:\s+\([^)]+\))?\s+SELECT .+$~s', trim($qq['q'])) != 0; |
| 308 | + } |
|
| 290 | 309 | // Temporary tables created in earlier queries are not explainable. |
| 291 | 310 | if ($is_select) |
| 292 | 311 | { |
| 293 | - foreach (array('log_topics_unread', 'topics_posted_in', 'tmp_log_search_topics', 'tmp_log_search_messages') as $tmp) |
|
| 294 | - if (strpos(trim($qq['q']), $tmp) !== false) |
|
| 312 | + foreach (array('log_topics_unread', 'topics_posted_in', 'tmp_log_search_topics', 'tmp_log_search_messages') as $tmp) { |
|
| 313 | + if (strpos(trim($qq['q']), $tmp) !== false) |
|
| 295 | 314 | { |
| 296 | 315 | $is_select = false; |
| 316 | + } |
|
| 297 | 317 | break; |
| 298 | 318 | } |
| 299 | 319 | } |
| 300 | 320 | // But actual creation of the temporary tables are. |
| 301 | - elseif (preg_match('~^CREATE TEMPORARY TABLE .+?SELECT .+$~s', trim($qq['q'])) != 0) |
|
| 302 | - $is_select = true; |
|
| 321 | + elseif (preg_match('~^CREATE TEMPORARY TABLE .+?SELECT .+$~s', trim($qq['q'])) != 0) { |
|
| 322 | + $is_select = true; |
|
| 323 | + } |
|
| 303 | 324 | |
| 304 | 325 | // Make the filenames look a bit better. |
| 305 | - if (isset($qq['f'])) |
|
| 306 | - $qq['f'] = preg_replace('~^' . preg_quote($boarddir, '~') . '~', '...', $qq['f']); |
|
| 326 | + if (isset($qq['f'])) { |
|
| 327 | + $qq['f'] = preg_replace('~^' . preg_quote($boarddir, '~') . '~', '...', $qq['f']); |
|
| 328 | + } |
|
| 307 | 329 | |
| 308 | 330 | echo ' |
| 309 | 331 | <strong>', $is_select ? '<a href="' . $scripturl . '?action=viewquery;qq=' . ($q + 1) . '#qq' . $q . '" target="_blank" class="new_win" style="text-decoration: none;">' : '', nl2br(str_replace("\t", ' ', $smcFunc['htmlspecialchars'](ltrim($qq['q'], "\n\r")))) . ($is_select ? '</a></strong>' : '</strong>') . '<br> |
| 310 | 332 | '; |
| 311 | - if (!empty($qq['f']) && !empty($qq['l'])) |
|
| 312 | - echo sprintf($txt['debug_query_in_line'], $qq['f'], $qq['l']); |
|
| 333 | + if (!empty($qq['f']) && !empty($qq['l'])) { |
|
| 334 | + echo sprintf($txt['debug_query_in_line'], $qq['f'], $qq['l']); |
|
| 335 | + } |
|
| 313 | 336 | |
| 314 | - if (isset($qq['s'], $qq['t']) && isset($txt['debug_query_which_took_at'])) |
|
| 315 | - echo sprintf($txt['debug_query_which_took_at'], round($qq['t'], 8), round($qq['s'], 8)) . '<br>'; |
|
| 316 | - elseif (isset($qq['t'])) |
|
| 317 | - echo sprintf($txt['debug_query_which_took'], round($qq['t'], 8)) . '<br>'; |
|
| 337 | + if (isset($qq['s'], $qq['t']) && isset($txt['debug_query_which_took_at'])) { |
|
| 338 | + echo sprintf($txt['debug_query_which_took_at'], round($qq['t'], 8), round($qq['s'], 8)) . '<br>'; |
|
| 339 | + } elseif (isset($qq['t'])) { |
|
| 340 | + echo sprintf($txt['debug_query_which_took'], round($qq['t'], 8)) . '<br>'; |
|
| 341 | + } |
|
| 318 | 342 | echo ' |
| 319 | 343 | <br>'; |
| 320 | 344 | } |
@@ -339,12 +363,14 @@ discard block |
||
| 339 | 363 | global $modSettings, $smcFunc; |
| 340 | 364 | static $cache_stats = array(); |
| 341 | 365 | |
| 342 | - if (empty($modSettings['trackStats'])) |
|
| 343 | - return false; |
|
| 344 | - if (!empty($stats)) |
|
| 345 | - return $cache_stats = array_merge($cache_stats, $stats); |
|
| 346 | - elseif (empty($cache_stats)) |
|
| 347 | - return false; |
|
| 366 | + if (empty($modSettings['trackStats'])) { |
|
| 367 | + return false; |
|
| 368 | + } |
|
| 369 | + if (!empty($stats)) { |
|
| 370 | + return $cache_stats = array_merge($cache_stats, $stats); |
|
| 371 | + } elseif (empty($cache_stats)) { |
|
| 372 | + return false; |
|
| 373 | + } |
|
| 348 | 374 | |
| 349 | 375 | $setStringUpdate = ''; |
| 350 | 376 | $insert_keys = array(); |
@@ -357,10 +383,11 @@ discard block |
||
| 357 | 383 | $setStringUpdate .= ' |
| 358 | 384 | ' . $field . ' = ' . ($change === '+' ? $field . ' + 1' : '{int:' . $field . '}') . ','; |
| 359 | 385 | |
| 360 | - if ($change === '+') |
|
| 361 | - $cache_stats[$field] = 1; |
|
| 362 | - else |
|
| 363 | - $update_parameters[$field] = $change; |
|
| 386 | + if ($change === '+') { |
|
| 387 | + $cache_stats[$field] = 1; |
|
| 388 | + } else { |
|
| 389 | + $update_parameters[$field] = $change; |
|
| 390 | + } |
|
| 364 | 391 | $insert_keys[$field] = 'int'; |
| 365 | 392 | } |
| 366 | 393 | |
@@ -424,43 +451,50 @@ discard block |
||
| 424 | 451 | ); |
| 425 | 452 | |
| 426 | 453 | // Make sure this particular log is enabled first... |
| 427 | - if (empty($modSettings['modlog_enabled'])) |
|
| 428 | - unset ($log_types['moderate']); |
|
| 429 | - if (empty($modSettings['userlog_enabled'])) |
|
| 430 | - unset ($log_types['user']); |
|
| 431 | - if (empty($modSettings['adminlog_enabled'])) |
|
| 432 | - unset ($log_types['admin']); |
|
| 454 | + if (empty($modSettings['modlog_enabled'])) { |
|
| 455 | + unset ($log_types['moderate']); |
|
| 456 | + } |
|
| 457 | + if (empty($modSettings['userlog_enabled'])) { |
|
| 458 | + unset ($log_types['user']); |
|
| 459 | + } |
|
| 460 | + if (empty($modSettings['adminlog_enabled'])) { |
|
| 461 | + unset ($log_types['admin']); |
|
| 462 | + } |
|
| 433 | 463 | |
| 434 | 464 | call_integration_hook('integrate_log_types', array(&$log_types)); |
| 435 | 465 | |
| 436 | 466 | foreach ($logs as $log) |
| 437 | 467 | { |
| 438 | - if (!isset($log_types[$log['log_type']])) |
|
| 439 | - return false; |
|
| 468 | + if (!isset($log_types[$log['log_type']])) { |
|
| 469 | + return false; |
|
| 470 | + } |
|
| 440 | 471 | |
| 441 | - if (!is_array($log['extra'])) |
|
| 442 | - trigger_error('logActions(): data is not an array with action \'' . $log['action'] . '\'', E_USER_NOTICE); |
|
| 472 | + if (!is_array($log['extra'])) { |
|
| 473 | + trigger_error('logActions(): data is not an array with action \'' . $log['action'] . '\'', E_USER_NOTICE); |
|
| 474 | + } |
|
| 443 | 475 | |
| 444 | 476 | // Pull out the parts we want to store separately, but also make sure that the data is proper |
| 445 | 477 | if (isset($log['extra']['topic'])) |
| 446 | 478 | { |
| 447 | - if (!is_numeric($log['extra']['topic'])) |
|
| 448 | - trigger_error('logActions(): data\'s topic is not a number', E_USER_NOTICE); |
|
| 479 | + if (!is_numeric($log['extra']['topic'])) { |
|
| 480 | + trigger_error('logActions(): data\'s topic is not a number', E_USER_NOTICE); |
|
| 481 | + } |
|
| 449 | 482 | $topic_id = empty($log['extra']['topic']) ? 0 : (int) $log['extra']['topic']; |
| 450 | 483 | unset($log['extra']['topic']); |
| 484 | + } else { |
|
| 485 | + $topic_id = 0; |
|
| 451 | 486 | } |
| 452 | - else |
|
| 453 | - $topic_id = 0; |
|
| 454 | 487 | |
| 455 | 488 | if (isset($log['extra']['message'])) |
| 456 | 489 | { |
| 457 | - if (!is_numeric($log['extra']['message'])) |
|
| 458 | - trigger_error('logActions(): data\'s message is not a number', E_USER_NOTICE); |
|
| 490 | + if (!is_numeric($log['extra']['message'])) { |
|
| 491 | + trigger_error('logActions(): data\'s message is not a number', E_USER_NOTICE); |
|
| 492 | + } |
|
| 459 | 493 | $msg_id = empty($log['extra']['message']) ? 0 : (int) $log['extra']['message']; |
| 460 | 494 | unset($log['extra']['message']); |
| 495 | + } else { |
|
| 496 | + $msg_id = 0; |
|
| 461 | 497 | } |
| 462 | - else |
|
| 463 | - $msg_id = 0; |
|
| 464 | 498 | |
| 465 | 499 | // @todo cache this? |
| 466 | 500 | // Is there an associated report on this? |
@@ -487,23 +521,26 @@ discard block |
||
| 487 | 521 | $smcFunc['db_free_result']($request); |
| 488 | 522 | } |
| 489 | 523 | |
| 490 | - if (isset($log['extra']['member']) && !is_numeric($log['extra']['member'])) |
|
| 491 | - trigger_error('logActions(): data\'s member is not a number', E_USER_NOTICE); |
|
| 524 | + if (isset($log['extra']['member']) && !is_numeric($log['extra']['member'])) { |
|
| 525 | + trigger_error('logActions(): data\'s member is not a number', E_USER_NOTICE); |
|
| 526 | + } |
|
| 492 | 527 | |
| 493 | 528 | if (isset($log['extra']['board'])) |
| 494 | 529 | { |
| 495 | - if (!is_numeric($log['extra']['board'])) |
|
| 496 | - trigger_error('logActions(): data\'s board is not a number', E_USER_NOTICE); |
|
| 530 | + if (!is_numeric($log['extra']['board'])) { |
|
| 531 | + trigger_error('logActions(): data\'s board is not a number', E_USER_NOTICE); |
|
| 532 | + } |
|
| 497 | 533 | $board_id = empty($log['extra']['board']) ? 0 : (int) $log['extra']['board']; |
| 498 | 534 | unset($log['extra']['board']); |
| 535 | + } else { |
|
| 536 | + $board_id = 0; |
|
| 499 | 537 | } |
| 500 | - else |
|
| 501 | - $board_id = 0; |
|
| 502 | 538 | |
| 503 | 539 | if (isset($log['extra']['board_to'])) |
| 504 | 540 | { |
| 505 | - if (!is_numeric($log['extra']['board_to'])) |
|
| 506 | - trigger_error('logActions(): data\'s board_to is not a number', E_USER_NOTICE); |
|
| 541 | + if (!is_numeric($log['extra']['board_to'])) { |
|
| 542 | + trigger_error('logActions(): data\'s board_to is not a number', E_USER_NOTICE); |
|
| 543 | + } |
|
| 507 | 544 | if (empty($board_id)) |
| 508 | 545 | { |
| 509 | 546 | $board_id = empty($log['extra']['board_to']) ? 0 : (int) $log['extra']['board_to']; |
@@ -511,10 +548,11 @@ discard block |
||
| 511 | 548 | } |
| 512 | 549 | } |
| 513 | 550 | |
| 514 | - if (isset($log['extra']['member_affected'])) |
|
| 515 | - $memID = $log['extra']['member_affected']; |
|
| 516 | - else |
|
| 517 | - $memID = $user_info['id']; |
|
| 551 | + if (isset($log['extra']['member_affected'])) { |
|
| 552 | + $memID = $log['extra']['member_affected']; |
|
| 553 | + } else { |
|
| 554 | + $memID = $user_info['id']; |
|
| 555 | + } |
|
| 518 | 556 | |
| 519 | 557 | $inserts[] = array( |
| 520 | 558 | time(), $log_types[$log['log_type']], $memID, $user_info['ip'], $log['action'], |