@@ -41,37 +41,43 @@ discard block |
||
| 41 | 41 | define('TIME_START', microtime(true)); |
| 42 | 42 | |
| 43 | 43 | // Just being safe... |
| 44 | -foreach (array('db_character_set', 'cachedir') as $variable) |
|
| 44 | +foreach (array('db_character_set', 'cachedir') as $variable) { |
|
| 45 | 45 | if (isset($GLOBALS[$variable])) |
| 46 | 46 | unset($GLOBALS[$variable]); |
| 47 | +} |
|
| 47 | 48 | |
| 48 | 49 | // Get the forum's settings for database and file paths. |
| 49 | 50 | require_once(dirname(__FILE__) . '/Settings.php'); |
| 50 | 51 | |
| 51 | 52 | // Make absolutely sure the cache directory is defined. |
| 52 | -if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache')) |
|
| 53 | +if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache')) { |
|
| 53 | 54 | $cachedir = $boarddir . '/cache'; |
| 55 | +} |
|
| 54 | 56 | |
| 55 | 57 | // Don't do john didley if the forum's been shut down competely. |
| 56 | -if ($maintenance == 2) |
|
| 58 | +if ($maintenance == 2) { |
|
| 57 | 59 | die($mmessage); |
| 60 | +} |
|
| 58 | 61 | |
| 59 | 62 | // Fix for using the current directory as a path. |
| 60 | -if (substr($sourcedir, 0, 1) == '.' && substr($sourcedir, 1, 1) != '.') |
|
| 63 | +if (substr($sourcedir, 0, 1) == '.' && substr($sourcedir, 1, 1) != '.') { |
|
| 61 | 64 | $sourcedir = dirname(__FILE__) . substr($sourcedir, 1); |
| 65 | +} |
|
| 62 | 66 | |
| 63 | 67 | // Have we already turned this off? If so, exist gracefully. |
| 64 | -if (file_exists($cachedir . '/cron.lock')) |
|
| 68 | +if (file_exists($cachedir . '/cron.lock')) { |
|
| 65 | 69 | obExit_cron(); |
| 70 | +} |
|
| 66 | 71 | |
| 67 | 72 | // Before we go any further, if this is not a CLI request, we need to do some checking. |
| 68 | 73 | if (!FROM_CLI) |
| 69 | 74 | { |
| 70 | 75 | // We will clean up $_GET shortly. But we want to this ASAP. |
| 71 | 76 | $ts = isset($_GET['ts']) ? (int) $_GET['ts'] : 0; |
| 72 | - if ($ts <= 0 || $ts % 15 != 0 || time() - $ts < 0 || time() - $ts > 20) |
|
| 73 | - obExit_cron(); |
|
| 74 | -} |
|
| 77 | + if ($ts <= 0 || $ts % 15 != 0 || time() - $ts < 0 || time() - $ts > 20) { |
|
| 78 | + obExit_cron(); |
|
| 79 | + } |
|
| 80 | + } |
|
| 75 | 81 | |
| 76 | 82 | // Load the most important includes. In general, a background should be loading its own dependencies. |
| 77 | 83 | require_once($sourcedir . '/Errors.php'); |
@@ -123,8 +129,9 @@ discard block |
||
| 123 | 129 | global $smcFunc; |
| 124 | 130 | |
| 125 | 131 | // Check we haven't run over our time limit. |
| 126 | - if (microtime(true) - TIME_START > MAX_CRON_TIME) |
|
| 127 | - return false; |
|
| 132 | + if (microtime(true) - TIME_START > MAX_CRON_TIME) { |
|
| 133 | + return false; |
|
| 134 | + } |
|
| 128 | 135 | |
| 129 | 136 | // Try to find a task. Specifically, try to find one that hasn't been claimed previously, or failing that, |
| 130 | 137 | // a task that was claimed but failed for whatever reason and failed long enough ago. We should not care |
@@ -159,14 +166,12 @@ discard block |
||
| 159 | 166 | // Update the time and go back. |
| 160 | 167 | $row['claimed_time'] = time(); |
| 161 | 168 | return $row; |
| 162 | - } |
|
| 163 | - else |
|
| 169 | + } else |
|
| 164 | 170 | { |
| 165 | 171 | // Uh oh, we just missed it. Try to claim another one, and let it fall through if there aren't any. |
| 166 | 172 | return fetch_task(); |
| 167 | 173 | } |
| 168 | - } |
|
| 169 | - else |
|
| 174 | + } else |
|
| 170 | 175 | { |
| 171 | 176 | // No dice. Clean up and go home. |
| 172 | 177 | $smcFunc['db_free_result']($request); |
@@ -187,8 +192,9 @@ discard block |
||
| 187 | 192 | if (!empty($task_details['task_file'])) |
| 188 | 193 | { |
| 189 | 194 | $include = strtr(trim($task_details['task_file']), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir)); |
| 190 | - if (file_exists($include)) |
|
| 191 | - require_once($include); |
|
| 195 | + if (file_exists($include)) { |
|
| 196 | + require_once($include); |
|
| 197 | + } |
|
| 192 | 198 | } |
| 193 | 199 | |
| 194 | 200 | if (empty($task_details['task_class'])) |
@@ -204,8 +210,7 @@ discard block |
||
| 204 | 210 | $details = empty($task_details['task_data']) ? array() : json_decode($task_details['task_data'], true); |
| 205 | 211 | $bgtask = new $task_details['task_class']($details); |
| 206 | 212 | return $bgtask->execute(); |
| 207 | - } |
|
| 208 | - else |
|
| 213 | + } else |
|
| 209 | 214 | { |
| 210 | 215 | log_error('Invalid background task specified: (class: ' . $task_details['task_class'] . ', ' . (empty($task_details['task_file']) ? ' no file' : ' to load ' . $task_details['task_file']) . ')'); |
| 211 | 216 | return true; // So we clear it from the queue. |
@@ -224,8 +229,9 @@ discard block |
||
| 224 | 229 | $scripturl = $boardurl . '/index.php'; |
| 225 | 230 | |
| 226 | 231 | // These keys shouldn't be set...ever. |
| 227 | - if (isset($_REQUEST['GLOBALS']) || isset($_COOKIE['GLOBALS'])) |
|
| 228 | - die('Invalid request variable.'); |
|
| 232 | + if (isset($_REQUEST['GLOBALS']) || isset($_COOKIE['GLOBALS'])) { |
|
| 233 | + die('Invalid request variable.'); |
|
| 234 | + } |
|
| 229 | 235 | |
| 230 | 236 | // Save some memory.. (since we don't use these anyway.) |
| 231 | 237 | unset($GLOBALS['HTTP_POST_VARS'], $GLOBALS['HTTP_POST_VARS']); |
@@ -246,26 +252,28 @@ discard block |
||
| 246 | 252 | global $modSettings; |
| 247 | 253 | |
| 248 | 254 | // Ignore errors if we're ignoring them or they are strict notices from PHP 5 (which cannot be solved without breaking PHP 4.) |
| 249 | - if (error_reporting() == 0 || (defined('E_STRICT') && $error_level == E_STRICT && !empty($modSettings['enableErrorLogging']))) |
|
| 250 | - return; |
|
| 255 | + if (error_reporting() == 0 || (defined('E_STRICT') && $error_level == E_STRICT && !empty($modSettings['enableErrorLogging']))) { |
|
| 256 | + return; |
|
| 257 | + } |
|
| 251 | 258 | |
| 252 | 259 | $error_type = 'cron'; |
| 253 | 260 | |
| 254 | 261 | log_error($error_level . ': ' . $error_string, $error_type, $file, $line); |
| 255 | 262 | |
| 256 | 263 | // If this is an E_ERROR or E_USER_ERROR.... die. Violently so. |
| 257 | - if ($error_level % 255 == E_ERROR) |
|
| 258 | - die('No direct access...'); |
|
| 259 | -} |
|
| 264 | + if ($error_level % 255 == E_ERROR) { |
|
| 265 | + die('No direct access...'); |
|
| 266 | + } |
|
| 267 | + } |
|
| 260 | 268 | |
| 261 | 269 | /** |
| 262 | 270 | * The exit function |
| 263 | 271 | */ |
| 264 | 272 | function obExit_cron() |
| 265 | 273 | { |
| 266 | - if (FROM_CLI) |
|
| 267 | - die(0); |
|
| 268 | - else |
|
| 274 | + if (FROM_CLI) { |
|
| 275 | + die(0); |
|
| 276 | + } else |
|
| 269 | 277 | { |
| 270 | 278 | header('Content-Type: image/gif'); |
| 271 | 279 | die("\x47\x49\x46\x38\x39\x61\x01\x00\x01\x00\x80\x00\x00\x00\x00\x00\x00\x00\x00\x21\xF9\x04\x01\x00\x00\x00\x00\x2C\x00\x00\x00\x00\x01\x00\x01\x00\x00\x02\x02\x44\x01\x00\x3B"); |
@@ -16,8 +16,9 @@ discard block |
||
| 16 | 16 | |
| 17 | 17 | // Start things rolling by getting SMF alive... |
| 18 | 18 | $ssi_guest_access = true; |
| 19 | -if (!file_exists(dirname(__FILE__) . '/SSI.php')) |
|
| 19 | +if (!file_exists(dirname(__FILE__) . '/SSI.php')) { |
|
| 20 | 20 | die('Cannot find SSI.php'); |
| 21 | +} |
|
| 21 | 22 | |
| 22 | 23 | require_once(dirname(__FILE__) . '/SSI.php'); |
| 23 | 24 | require_once($sourcedir . '/ManagePaid.php'); |
@@ -35,20 +36,22 @@ discard block |
||
| 35 | 36 | } |
| 36 | 37 | |
| 37 | 38 | // I assume we're even active? |
| 38 | -if (empty($modSettings['paid_enabled'])) |
|
| 39 | +if (empty($modSettings['paid_enabled'])) { |
|
| 39 | 40 | exit; |
| 41 | +} |
|
| 40 | 42 | |
| 41 | 43 | // If we have some custom people who find out about problems load them here. |
| 42 | 44 | $notify_users = array(); |
| 43 | 45 | if (!empty($modSettings['paid_email_to'])) |
| 44 | 46 | { |
| 45 | - foreach (explode(',', $modSettings['paid_email_to']) as $email) |
|
| 46 | - $notify_users[] = array( |
|
| 47 | + foreach (explode(',', $modSettings['paid_email_to']) as $email) { |
|
| 48 | + $notify_users[] = array( |
|
| 47 | 49 | 'email' => $email, |
| 48 | 50 | 'name' => $txt['who_member'], |
| 49 | 51 | 'id' => 0, |
| 50 | 52 | ); |
| 51 | -} |
|
| 53 | + } |
|
| 54 | + } |
|
| 52 | 55 | |
| 53 | 56 | // We need to see whether we can find the correct payment gateway, |
| 54 | 57 | // we'll going to go through all our gateway scripts and find out |
@@ -65,8 +68,9 @@ discard block |
||
| 65 | 68 | } |
| 66 | 69 | } |
| 67 | 70 | |
| 68 | -if (empty($txnType)) |
|
| 71 | +if (empty($txnType)) { |
|
| 69 | 72 | generateSubscriptionError($txt['paid_unknown_transaction_type']); |
| 73 | +} |
|
| 70 | 74 | |
| 71 | 75 | // Get the subscription and member ID amoungst others... |
| 72 | 76 | @list($subscription_id, $member_id) = $gatewayClass->precheck(); |
@@ -76,8 +80,9 @@ discard block |
||
| 76 | 80 | $member_id = (int) $member_id; |
| 77 | 81 | |
| 78 | 82 | // This would be bad... |
| 79 | -if (empty($member_id)) |
|
| 83 | +if (empty($member_id)) { |
|
| 80 | 84 | generateSubscriptionError($txt['paid_empty_member']); |
| 85 | +} |
|
| 81 | 86 | |
| 82 | 87 | // Verify the member. |
| 83 | 88 | $request = $smcFunc['db_query']('', ' |
@@ -89,8 +94,9 @@ discard block |
||
| 89 | 94 | ) |
| 90 | 95 | ); |
| 91 | 96 | // Didn't find them? |
| 92 | -if ($smcFunc['db_num_rows']($request) === 0) |
|
| 97 | +if ($smcFunc['db_num_rows']($request) === 0) { |
|
| 93 | 98 | generateSubscriptionError(sprintf($txt['paid_could_not_find_member'], $member_id)); |
| 99 | +} |
|
| 94 | 100 | $member_info = $smcFunc['db_fetch_assoc']($request); |
| 95 | 101 | $smcFunc['db_free_result']($request); |
| 96 | 102 | |
@@ -105,8 +111,9 @@ discard block |
||
| 105 | 111 | ); |
| 106 | 112 | |
| 107 | 113 | // Didn't find it? |
| 108 | -if ($smcFunc['db_num_rows']($request) === 0) |
|
| 114 | +if ($smcFunc['db_num_rows']($request) === 0) { |
|
| 109 | 115 | generateSubscriptionError(sprintf($txt['paid_count_not_find_subscription'], $member_id, $subscription_id)); |
| 116 | +} |
|
| 110 | 117 | |
| 111 | 118 | $subscription_info = $smcFunc['db_fetch_assoc']($request); |
| 112 | 119 | $smcFunc['db_free_result']($request); |
@@ -123,8 +130,9 @@ discard block |
||
| 123 | 130 | 'current_member' => $member_id, |
| 124 | 131 | ) |
| 125 | 132 | ); |
| 126 | -if ($smcFunc['db_num_rows']($request) === 0) |
|
| 133 | +if ($smcFunc['db_num_rows']($request) === 0) { |
|
| 127 | 134 | generateSubscriptionError(sprintf($txt['paid_count_not_find_subscription_log'], $member_id, $subscription_id)); |
| 135 | +} |
|
| 128 | 136 | $subscription_info += $smcFunc['db_fetch_assoc']($request); |
| 129 | 137 | $smcFunc['db_free_result']($request); |
| 130 | 138 | |
@@ -139,8 +147,7 @@ discard block |
||
| 139 | 147 | removeSubscription($subscription_id, $member_id); |
| 140 | 148 | $subscription_act = time(); |
| 141 | 149 | $status = 0; |
| 142 | - } |
|
| 143 | - else |
|
| 150 | + } else |
|
| 144 | 151 | { |
| 145 | 152 | loadSubscriptions(); |
| 146 | 153 | $subscription_act = $subscription_info['end_time'] - $context['subscriptions'][$subscription_id]['num_length']; |
@@ -188,16 +195,18 @@ discard block |
||
| 188 | 195 | if (!$gatewayClass->isSubscription()) |
| 189 | 196 | { |
| 190 | 197 | $real_details = json_decode($subscription_info['pending_details'], true); |
| 191 | - if (empty($real_details)) |
|
| 192 | - generateSubscriptionError(sprintf($txt['paid_count_not_find_outstanding_payment'], $member_id, $subscription_id)); |
|
| 198 | + if (empty($real_details)) { |
|
| 199 | + generateSubscriptionError(sprintf($txt['paid_count_not_find_outstanding_payment'], $member_id, $subscription_id)); |
|
| 200 | + } |
|
| 193 | 201 | |
| 194 | 202 | // Now we just try to find anything pending. |
| 195 | 203 | // We don't really care which it is as security happens later. |
| 196 | 204 | foreach ($real_details as $id => $detail) |
| 197 | 205 | { |
| 198 | 206 | unset($real_details[$id]); |
| 199 | - if ($detail[3] == 'payback' && $subscription_info['payments_pending']) |
|
| 200 | - $subscription_info['payments_pending']--; |
|
| 207 | + if ($detail[3] == 'payback' && $subscription_info['payments_pending']) { |
|
| 208 | + $subscription_info['payments_pending']--; |
|
| 209 | + } |
|
| 201 | 210 | break; |
| 202 | 211 | } |
| 203 | 212 | |
@@ -223,10 +232,11 @@ discard block |
||
| 223 | 232 | // This is a little harder, can we find the right duration? |
| 224 | 233 | foreach ($cost as $duration => $value) |
| 225 | 234 | { |
| 226 | - if ($duration == 'fixed') |
|
| 227 | - continue; |
|
| 228 | - elseif ((float) $value == (float) $total_cost) |
|
| 229 | - $found_duration = strtoupper(substr($duration, 0, 1)); |
|
| 235 | + if ($duration == 'fixed') { |
|
| 236 | + continue; |
|
| 237 | + } elseif ((float) $value == (float) $total_cost) { |
|
| 238 | + $found_duration = strtoupper(substr($duration, 0, 1)); |
|
| 239 | + } |
|
| 230 | 240 | } |
| 231 | 241 | |
| 232 | 242 | // If we have the duration then we're done. |
@@ -235,8 +245,7 @@ discard block |
||
| 235 | 245 | $notify = true; |
| 236 | 246 | addSubscription($subscription_id, $member_id, $found_duration); |
| 237 | 247 | } |
| 238 | - } |
|
| 239 | - else |
|
| 248 | + } else |
|
| 240 | 249 | { |
| 241 | 250 | $actual_cost = $cost['fixed']; |
| 242 | 251 | |
@@ -268,10 +277,10 @@ discard block |
||
| 268 | 277 | // Maybe they're cancelling. Some subscriptions may require actively doing something, but PayPal doesn't, for example. |
| 269 | 278 | elseif ($gatewayClass->isCancellation()) |
| 270 | 279 | { |
| 271 | - if (method_exists($gatewayClass, 'performCancel')) |
|
| 272 | - $gatewayClass->performCancel($subscription_id, $member_id, $subscription_info); |
|
| 273 | -} |
|
| 274 | -else |
|
| 280 | + if (method_exists($gatewayClass, 'performCancel')) { |
|
| 281 | + $gatewayClass->performCancel($subscription_id, $member_id, $subscription_info); |
|
| 282 | + } |
|
| 283 | + } else |
|
| 275 | 284 | { |
| 276 | 285 | // Some other "valid" transaction such as: |
| 277 | 286 | // |
@@ -308,8 +317,9 @@ discard block |
||
| 308 | 317 | // Maybe we can try to give them the post data? |
| 309 | 318 | if (!empty($_POST)) |
| 310 | 319 | { |
| 311 | - foreach ($_POST as $key => $val) |
|
| 312 | - $text .= '<br>' . $smcFunc['htmlspecialchars']($key) . ': ' . $smcFunc['htmlspecialchars']($val); |
|
| 320 | + foreach ($_POST as $key => $val) { |
|
| 321 | + $text .= '<br>' . $smcFunc['htmlspecialchars']($key) . ': ' . $smcFunc['htmlspecialchars']($val); |
|
| 322 | + } |
|
| 313 | 323 | } |
| 314 | 324 | |
| 315 | 325 | // Then just log and die. |
@@ -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 | * Edit the position and properties of a category. |
@@ -42,8 +43,9 @@ discard block |
||
| 42 | 43 | $cat_order = array(); |
| 43 | 44 | |
| 44 | 45 | // Setting 'move_after' to '0' moves the category to the top. |
| 45 | - if ($catOptions['move_after'] == 0) |
|
| 46 | - $cats[] = $category_id; |
|
| 46 | + if ($catOptions['move_after'] == 0) { |
|
| 47 | + $cats[] = $category_id; |
|
| 48 | + } |
|
| 47 | 49 | |
| 48 | 50 | // Grab the categories sorted by cat_order. |
| 49 | 51 | $request = $smcFunc['db_query']('', ' |
@@ -55,17 +57,19 @@ discard block |
||
| 55 | 57 | ); |
| 56 | 58 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 57 | 59 | { |
| 58 | - if ($row['id_cat'] != $category_id) |
|
| 59 | - $cats[] = $row['id_cat']; |
|
| 60 | - if ($row['id_cat'] == $catOptions['move_after']) |
|
| 61 | - $cats[] = $category_id; |
|
| 60 | + if ($row['id_cat'] != $category_id) { |
|
| 61 | + $cats[] = $row['id_cat']; |
|
| 62 | + } |
|
| 63 | + if ($row['id_cat'] == $catOptions['move_after']) { |
|
| 64 | + $cats[] = $category_id; |
|
| 65 | + } |
|
| 62 | 66 | $cat_order[$row['id_cat']] = $row['cat_order']; |
| 63 | 67 | } |
| 64 | 68 | $smcFunc['db_free_result']($request); |
| 65 | 69 | |
| 66 | 70 | // Set the new order for the categories. |
| 67 | - foreach ($cats as $index => $cat) |
|
| 68 | - if ($index != $cat_order[$cat]) |
|
| 71 | + foreach ($cats as $index => $cat) { |
|
| 72 | + if ($index != $cat_order[$cat]) |
|
| 69 | 73 | $smcFunc['db_query']('', ' |
| 70 | 74 | UPDATE {db_prefix}categories |
| 71 | 75 | SET cat_order = {int:new_order} |
@@ -75,6 +79,7 @@ discard block |
||
| 75 | 79 | 'current_category' => $cat, |
| 76 | 80 | ) |
| 77 | 81 | ); |
| 82 | + } |
|
| 78 | 83 | |
| 79 | 84 | // If the category order changed, so did the board order. |
| 80 | 85 | require_once($sourcedir . '/Subs-Boards.php'); |
@@ -117,8 +122,9 @@ discard block |
||
| 117 | 122 | )) |
| 118 | 123 | ); |
| 119 | 124 | |
| 120 | - if (empty($catOptions['dont_log'])) |
|
| 121 | - logAction('edit_cat', array('catname' => isset($catOptions['cat_name']) ? $catOptions['cat_name'] : $category_id), 'admin'); |
|
| 125 | + if (empty($catOptions['dont_log'])) { |
|
| 126 | + logAction('edit_cat', array('catname' => isset($catOptions['cat_name']) ? $catOptions['cat_name'] : $category_id), 'admin'); |
|
| 127 | + } |
|
| 122 | 128 | } |
| 123 | 129 | } |
| 124 | 130 | |
@@ -135,16 +141,20 @@ discard block |
||
| 135 | 141 | global $smcFunc; |
| 136 | 142 | |
| 137 | 143 | // Check required values. |
| 138 | - if (!isset($catOptions['cat_name']) || trim($catOptions['cat_name']) == '') |
|
| 139 | - trigger_error('createCategory(): A category name is required', E_USER_ERROR); |
|
| 144 | + if (!isset($catOptions['cat_name']) || trim($catOptions['cat_name']) == '') { |
|
| 145 | + trigger_error('createCategory(): A category name is required', E_USER_ERROR); |
|
| 146 | + } |
|
| 140 | 147 | |
| 141 | 148 | // Set default values. |
| 142 | - if (!isset($catOptions['cat_desc'])) |
|
| 143 | - $catOptions['cat_desc'] = ''; |
|
| 144 | - if (!isset($catOptions['move_after'])) |
|
| 145 | - $catOptions['move_after'] = 0; |
|
| 146 | - if (!isset($catOptions['is_collapsible'])) |
|
| 147 | - $catOptions['is_collapsible'] = true; |
|
| 149 | + if (!isset($catOptions['cat_desc'])) { |
|
| 150 | + $catOptions['cat_desc'] = ''; |
|
| 151 | + } |
|
| 152 | + if (!isset($catOptions['move_after'])) { |
|
| 153 | + $catOptions['move_after'] = 0; |
|
| 154 | + } |
|
| 155 | + if (!isset($catOptions['is_collapsible'])) { |
|
| 156 | + $catOptions['is_collapsible'] = true; |
|
| 157 | + } |
|
| 148 | 158 | // Don't log an edit right after. |
| 149 | 159 | $catOptions['dont_log'] = true; |
| 150 | 160 | |
@@ -212,21 +222,24 @@ discard block |
||
| 212 | 222 | ) |
| 213 | 223 | ); |
| 214 | 224 | $boards_inside = array(); |
| 215 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 216 | - $boards_inside[] = $row['id_board']; |
|
| 225 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 226 | + $boards_inside[] = $row['id_board']; |
|
| 227 | + } |
|
| 217 | 228 | $smcFunc['db_free_result']($request); |
| 218 | 229 | |
| 219 | - if (!empty($boards_inside)) |
|
| 220 | - deleteBoards($boards_inside, null); |
|
| 230 | + if (!empty($boards_inside)) { |
|
| 231 | + deleteBoards($boards_inside, null); |
|
| 232 | + } |
|
| 221 | 233 | } |
| 222 | 234 | |
| 223 | 235 | // Make sure the safe category is really safe. |
| 224 | - elseif (in_array($moveBoardsTo, $categories)) |
|
| 225 | - trigger_error('deleteCategories(): You cannot move the boards to a category that\'s being deleted', E_USER_ERROR); |
|
| 236 | + elseif (in_array($moveBoardsTo, $categories)) { |
|
| 237 | + trigger_error('deleteCategories(): You cannot move the boards to a category that\'s being deleted', E_USER_ERROR); |
|
| 238 | + } |
|
| 226 | 239 | |
| 227 | 240 | // Move the boards inside the categories to a safe category. |
| 228 | - else |
|
| 229 | - $smcFunc['db_query']('', ' |
|
| 241 | + else { |
|
| 242 | + $smcFunc['db_query']('', ' |
|
| 230 | 243 | UPDATE {db_prefix}boards |
| 231 | 244 | SET id_cat = {int:new_parent_cat} |
| 232 | 245 | WHERE id_cat IN ({array_int:category_list})', |
@@ -235,6 +248,7 @@ discard block |
||
| 235 | 248 | 'new_parent_cat' => $moveBoardsTo, |
| 236 | 249 | ) |
| 237 | 250 | ); |
| 251 | + } |
|
| 238 | 252 | |
| 239 | 253 | // Do the deletion of the category itself |
| 240 | 254 | $smcFunc['db_query']('', ' |
@@ -246,8 +260,9 @@ discard block |
||
| 246 | 260 | ); |
| 247 | 261 | |
| 248 | 262 | // Log what we've done. |
| 249 | - foreach ($categories as $category) |
|
| 250 | - logAction('delete_cat', array('catname' => $cat_tree[$category]['node']['name']), 'admin'); |
|
| 263 | + foreach ($categories as $category) { |
|
| 264 | + logAction('delete_cat', array('catname' => $cat_tree[$category]['node']['name']), 'admin'); |
|
| 265 | + } |
|
| 251 | 266 | |
| 252 | 267 | // Get all boards back into the right order. |
| 253 | 268 | reorderBoards(); |
@@ -590,7 +590,7 @@ discard block |
||
| 590 | 590 | 'Shitiz "Dragooon" Garg', |
| 591 | 591 | 'Karl "RegularExpression" Benson', |
| 592 | 592 | 'Matthew "Labradoodle-360" Kerle', |
| 593 | - $user_info['is_admin'] ? 'Matt "Grudge" Wolf': 'Grudge', |
|
| 593 | + $user_info['is_admin'] ? 'Matt "Grudge" Wolf' : 'Grudge', |
|
| 594 | 594 | 'Michael "Thantos" Miller', |
| 595 | 595 | 'Norv', |
| 596 | 596 | 'Peter "Arantor" Spicer', |
@@ -813,13 +813,13 @@ discard block |
||
| 813 | 813 | $credit_info = smf_json_decode($row['credits'], true); |
| 814 | 814 | |
| 815 | 815 | $copyright = empty($credit_info['copyright']) ? '' : $txt['credits_copyright'] . ' © ' . $smcFunc['htmlspecialchars']($credit_info['copyright']); |
| 816 | - $license = empty($credit_info['license']) ? '' : $txt['credits_license'] . ': ' . (!empty($credit_info['licenseurl']) ? '<a href="'. $smcFunc['htmlspecialchars']($credit_info['licenseurl']) .'">'. $smcFunc['htmlspecialchars']($credit_info['license']) .'</a>' : $smcFunc['htmlspecialchars']($credit_info['license'])); |
|
| 816 | + $license = empty($credit_info['license']) ? '' : $txt['credits_license'] . ': ' . (!empty($credit_info['licenseurl']) ? '<a href="' . $smcFunc['htmlspecialchars']($credit_info['licenseurl']) . '">' . $smcFunc['htmlspecialchars']($credit_info['license']) . '</a>' : $smcFunc['htmlspecialchars']($credit_info['license'])); |
|
| 817 | 817 | $version = $txt['credits_version'] . ' ' . $row['version']; |
| 818 | 818 | $title = (empty($credit_info['title']) ? $row['name'] : $smcFunc['htmlspecialchars']($credit_info['title'])) . ': ' . $version; |
| 819 | 819 | |
| 820 | 820 | // build this one out and stash it away |
| 821 | 821 | $mod_name = empty($credit_info['url']) ? $title : '<a href="' . $credit_info['url'] . '">' . $title . '</a>'; |
| 822 | - $mods[] = $mod_name . (!empty($license) ? ' | ' . $license : '') . (!empty($copyright) ? ' | ' . $copyright : ''); |
|
| 822 | + $mods[] = $mod_name . (!empty($license) ? ' | ' . $license : '') . (!empty($copyright) ? ' | ' . $copyright : ''); |
|
| 823 | 823 | } |
| 824 | 824 | cache_put_data('mods_credits', $mods, 86400); |
| 825 | 825 | } |
@@ -14,8 +14,9 @@ discard block |
||
| 14 | 14 | * @version 2.1 Beta 3 |
| 15 | 15 | */ |
| 16 | 16 | |
| 17 | -if (!defined('SMF')) |
|
| 17 | +if (!defined('SMF')) { |
|
| 18 | 18 | die('No direct access...'); |
| 19 | +} |
|
| 19 | 20 | |
| 20 | 21 | /** |
| 21 | 22 | * Who's online, and what are they doing? |
@@ -35,8 +36,9 @@ discard block |
||
| 35 | 36 | isAllowedTo('who_view'); |
| 36 | 37 | |
| 37 | 38 | // You can't do anything if this is off. |
| 38 | - if (empty($modSettings['who_enabled'])) |
|
| 39 | - fatal_lang_error('who_off', false); |
|
| 39 | + if (empty($modSettings['who_enabled'])) { |
|
| 40 | + fatal_lang_error('who_off', false); |
|
| 41 | + } |
|
| 40 | 42 | |
| 41 | 43 | // Load the 'Who' template. |
| 42 | 44 | loadTemplate('Who'); |
@@ -71,9 +73,9 @@ discard block |
||
| 71 | 73 | $show_methods['spiders'] = '(lo.id_member = 0 AND lo.id_spider > 0)'; |
| 72 | 74 | $show_methods['guests'] = '(lo.id_member = 0 AND lo.id_spider = 0)'; |
| 73 | 75 | $context['show_methods']['spiders'] = $txt['who_show_spiders_only']; |
| 76 | + } elseif (empty($modSettings['show_spider_online']) && isset($_SESSION['who_online_filter']) && $_SESSION['who_online_filter'] == 'spiders') { |
|
| 77 | + unset($_SESSION['who_online_filter']); |
|
| 74 | 78 | } |
| 75 | - elseif (empty($modSettings['show_spider_online']) && isset($_SESSION['who_online_filter']) && $_SESSION['who_online_filter'] == 'spiders') |
|
| 76 | - unset($_SESSION['who_online_filter']); |
|
| 77 | 79 | |
| 78 | 80 | // Does the user prefer a different sort direction? |
| 79 | 81 | if (isset($_REQUEST['sort']) && isset($sort_methods[$_REQUEST['sort']])) |
@@ -97,20 +99,24 @@ discard block |
||
| 97 | 99 | $context['sort_direction'] = isset($_REQUEST['asc']) || (isset($_REQUEST['sort_dir']) && $_REQUEST['sort_dir'] == 'asc') ? 'up' : 'down'; |
| 98 | 100 | |
| 99 | 101 | $conditions = array(); |
| 100 | - if (!allowedTo('moderate_forum')) |
|
| 101 | - $conditions[] = '(COALESCE(mem.show_online, 1) = 1)'; |
|
| 102 | + if (!allowedTo('moderate_forum')) { |
|
| 103 | + $conditions[] = '(COALESCE(mem.show_online, 1) = 1)'; |
|
| 104 | + } |
|
| 102 | 105 | |
| 103 | 106 | // Fallback to top filter? |
| 104 | - if (isset($_REQUEST['submit_top']) && isset($_REQUEST['show_top'])) |
|
| 105 | - $_REQUEST['show'] = $_REQUEST['show_top']; |
|
| 107 | + if (isset($_REQUEST['submit_top']) && isset($_REQUEST['show_top'])) { |
|
| 108 | + $_REQUEST['show'] = $_REQUEST['show_top']; |
|
| 109 | + } |
|
| 106 | 110 | // Does the user wish to apply a filter? |
| 107 | - if (isset($_REQUEST['show']) && isset($show_methods[$_REQUEST['show']])) |
|
| 108 | - $context['show_by'] = $_SESSION['who_online_filter'] = $_REQUEST['show']; |
|
| 111 | + if (isset($_REQUEST['show']) && isset($show_methods[$_REQUEST['show']])) { |
|
| 112 | + $context['show_by'] = $_SESSION['who_online_filter'] = $_REQUEST['show']; |
|
| 113 | + } |
|
| 109 | 114 | // Perhaps we saved a filter earlier in the session? |
| 110 | - elseif (isset($_SESSION['who_online_filter'])) |
|
| 111 | - $context['show_by'] = $_SESSION['who_online_filter']; |
|
| 112 | - else |
|
| 113 | - $context['show_by'] = 'members'; |
|
| 115 | + elseif (isset($_SESSION['who_online_filter'])) { |
|
| 116 | + $context['show_by'] = $_SESSION['who_online_filter']; |
|
| 117 | + } else { |
|
| 118 | + $context['show_by'] = 'members'; |
|
| 119 | + } |
|
| 114 | 120 | |
| 115 | 121 | $conditions[] = $show_methods[$context['show_by']]; |
| 116 | 122 | |
@@ -156,8 +162,9 @@ discard block |
||
| 156 | 162 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 157 | 163 | { |
| 158 | 164 | $actions = smf_json_decode($row['url'], true); |
| 159 | - if ($actions === false) |
|
| 160 | - continue; |
|
| 165 | + if ($actions === false) { |
|
| 166 | + continue; |
|
| 167 | + } |
|
| 161 | 168 | |
| 162 | 169 | // Send the information to the template. |
| 163 | 170 | $context['members'][$row['session']] = array( |
@@ -195,8 +202,8 @@ discard block |
||
| 195 | 202 | $spiderContext = array(); |
| 196 | 203 | if (!empty($modSettings['show_spider_online']) && ($modSettings['show_spider_online'] == 2 || allowedTo('admin_forum')) && !empty($modSettings['spider_name_cache'])) |
| 197 | 204 | { |
| 198 | - foreach (smf_json_decode($modSettings['spider_name_cache'], true) as $id => $name) |
|
| 199 | - $spiderContext[$id] = array( |
|
| 205 | + foreach (smf_json_decode($modSettings['spider_name_cache'], true) as $id => $name) { |
|
| 206 | + $spiderContext[$id] = array( |
|
| 200 | 207 | 'id' => 0, |
| 201 | 208 | 'name' => $name, |
| 202 | 209 | 'group' => $txt['spiders'], |
@@ -205,6 +212,7 @@ discard block |
||
| 205 | 212 | 'email' => $name, |
| 206 | 213 | 'is_guest' => true |
| 207 | 214 | ); |
| 215 | + } |
|
| 208 | 216 | } |
| 209 | 217 | |
| 210 | 218 | $url_data = determineActions($url_data); |
@@ -219,16 +227,18 @@ discard block |
||
| 219 | 227 | // Put it in the context variables. |
| 220 | 228 | foreach ($context['members'] as $i => $member) |
| 221 | 229 | { |
| 222 | - if ($member['id'] != 0) |
|
| 223 | - $member['id'] = loadMemberContext($member['id']) ? $member['id'] : 0; |
|
| 230 | + if ($member['id'] != 0) { |
|
| 231 | + $member['id'] = loadMemberContext($member['id']) ? $member['id'] : 0; |
|
| 232 | + } |
|
| 224 | 233 | |
| 225 | 234 | // Keep the IP that came from the database. |
| 226 | 235 | $memberContext[$member['id']]['ip'] = $member['ip']; |
| 227 | 236 | $context['members'][$i]['action'] = isset($url_data[$i]) ? $url_data[$i] : $txt['who_hidden']; |
| 228 | - if ($member['id'] == 0 && isset($spiderContext[$member['id_spider']])) |
|
| 229 | - $context['members'][$i] += $spiderContext[$member['id_spider']]; |
|
| 230 | - else |
|
| 231 | - $context['members'][$i] += $memberContext[$member['id']]; |
|
| 237 | + if ($member['id'] == 0 && isset($spiderContext[$member['id_spider']])) { |
|
| 238 | + $context['members'][$i] += $spiderContext[$member['id_spider']]; |
|
| 239 | + } else { |
|
| 240 | + $context['members'][$i] += $memberContext[$member['id']]; |
|
| 241 | + } |
|
| 232 | 242 | } |
| 233 | 243 | |
| 234 | 244 | // Some people can't send personal messages... |
@@ -263,8 +273,9 @@ discard block |
||
| 263 | 273 | { |
| 264 | 274 | global $txt, $user_info, $modSettings, $smcFunc; |
| 265 | 275 | |
| 266 | - if (!allowedTo('who_view')) |
|
| 267 | - return array(); |
|
| 276 | + if (!allowedTo('who_view')) { |
|
| 277 | + return array(); |
|
| 278 | + } |
|
| 268 | 279 | loadLanguage('Who'); |
| 269 | 280 | |
| 270 | 281 | // Actions that require a specific permission level. |
@@ -292,10 +303,11 @@ discard block |
||
| 292 | 303 | ); |
| 293 | 304 | call_integration_hook('who_allowed', array(&$allowedActions)); |
| 294 | 305 | |
| 295 | - if (!is_array($urls)) |
|
| 296 | - $url_list = array(array($urls, $user_info['id'])); |
|
| 297 | - else |
|
| 298 | - $url_list = $urls; |
|
| 306 | + if (!is_array($urls)) { |
|
| 307 | + $url_list = array(array($urls, $user_info['id'])); |
|
| 308 | + } else { |
|
| 309 | + $url_list = $urls; |
|
| 310 | + } |
|
| 299 | 311 | |
| 300 | 312 | // These are done to later query these in large chunks. (instead of one by one.) |
| 301 | 313 | $topic_ids = array(); |
@@ -307,12 +319,14 @@ discard block |
||
| 307 | 319 | { |
| 308 | 320 | // Get the request parameters.. |
| 309 | 321 | $actions = smf_json_decode($url[0], true); |
| 310 | - if ($actions === false) |
|
| 311 | - continue; |
|
| 322 | + if ($actions === false) { |
|
| 323 | + continue; |
|
| 324 | + } |
|
| 312 | 325 | |
| 313 | 326 | // If it's the admin or moderation center, and there is an area set, use that instead. |
| 314 | - if (isset($actions['action']) && ($actions['action'] == 'admin' || $actions['action'] == 'moderate') && isset($actions['area'])) |
|
| 315 | - $actions['action'] = $actions['area']; |
|
| 327 | + if (isset($actions['action']) && ($actions['action'] == 'admin' || $actions['action'] == 'moderate') && isset($actions['area'])) { |
|
| 328 | + $actions['action'] = $actions['area']; |
|
| 329 | + } |
|
| 316 | 330 | |
| 317 | 331 | // Check if there was no action or the action is display. |
| 318 | 332 | if (!isset($actions['action']) || $actions['action'] == 'display') |
@@ -332,12 +346,14 @@ discard block |
||
| 332 | 346 | $board_ids[$actions['board']][$k] = $txt['who_board']; |
| 333 | 347 | } |
| 334 | 348 | // It's the board index!! It must be! |
| 335 | - else |
|
| 336 | - $data[$k] = $txt['who_index']; |
|
| 349 | + else { |
|
| 350 | + $data[$k] = $txt['who_index']; |
|
| 351 | + } |
|
| 337 | 352 | } |
| 338 | 353 | // Probably an error or some goon? |
| 339 | - elseif ($actions['action'] == '') |
|
| 340 | - $data[$k] = $txt['who_index']; |
|
| 354 | + elseif ($actions['action'] == '') { |
|
| 355 | + $data[$k] = $txt['who_index']; |
|
| 356 | + } |
|
| 341 | 357 | // Some other normal action...? |
| 342 | 358 | else |
| 343 | 359 | { |
@@ -345,23 +361,25 @@ discard block |
||
| 345 | 361 | if ($actions['action'] == 'profile') |
| 346 | 362 | { |
| 347 | 363 | // Whose? Their own? |
| 348 | - if (empty($actions['u'])) |
|
| 349 | - $actions['u'] = $url[1]; |
|
| 364 | + if (empty($actions['u'])) { |
|
| 365 | + $actions['u'] = $url[1]; |
|
| 366 | + } |
|
| 350 | 367 | |
| 351 | 368 | $data[$k] = $txt['who_hidden']; |
| 352 | 369 | $profile_ids[(int) $actions['u']][$k] = $actions['u'] == $url[1] ? $txt['who_viewownprofile'] : $txt['who_viewprofile']; |
| 353 | - } |
|
| 354 | - elseif (($actions['action'] == 'post' || $actions['action'] == 'post2') && empty($actions['topic']) && isset($actions['board'])) |
|
| 370 | + } elseif (($actions['action'] == 'post' || $actions['action'] == 'post2') && empty($actions['topic']) && isset($actions['board'])) |
|
| 355 | 371 | { |
| 356 | 372 | $data[$k] = $txt['who_hidden']; |
| 357 | 373 | $board_ids[(int) $actions['board']][$k] = isset($actions['poll']) ? $txt['who_poll'] : $txt['who_post']; |
| 358 | 374 | } |
| 359 | 375 | // A subaction anyone can view... if the language string is there, show it. |
| 360 | - elseif (isset($actions['sa']) && isset($txt['whoall_' . $actions['action'] . '_' . $actions['sa']])) |
|
| 361 | - $data[$k] = $preferred_prefix && isset($txt[$preferred_prefix . $actions['action'] . '_' . $actions['sa']]) ? $txt[$preferred_prefix . $actions['action'] . '_' . $actions['sa']] : $txt['whoall_' . $actions['action'] . '_' . $actions['sa']]; |
|
| 376 | + elseif (isset($actions['sa']) && isset($txt['whoall_' . $actions['action'] . '_' . $actions['sa']])) { |
|
| 377 | + $data[$k] = $preferred_prefix && isset($txt[$preferred_prefix . $actions['action'] . '_' . $actions['sa']]) ? $txt[$preferred_prefix . $actions['action'] . '_' . $actions['sa']] : $txt['whoall_' . $actions['action'] . '_' . $actions['sa']]; |
|
| 378 | + } |
|
| 362 | 379 | // An action any old fellow can look at. (if ['whoall_' . $action] exists, we know everyone can see it.) |
| 363 | - elseif (isset($txt['whoall_' . $actions['action']])) |
|
| 364 | - $data[$k] = $preferred_prefix && isset($txt[$preferred_prefix . $actions['action']]) ? $txt[$preferred_prefix . $actions['action']] : $txt['whoall_' . $actions['action']]; |
|
| 380 | + elseif (isset($txt['whoall_' . $actions['action']])) { |
|
| 381 | + $data[$k] = $preferred_prefix && isset($txt[$preferred_prefix . $actions['action']]) ? $txt[$preferred_prefix . $actions['action']] : $txt['whoall_' . $actions['action']]; |
|
| 382 | + } |
|
| 365 | 383 | // Viewable if and only if they can see the board... |
| 366 | 384 | elseif (isset($txt['whotopic_' . $actions['action']])) |
| 367 | 385 | { |
@@ -370,8 +388,7 @@ discard block |
||
| 370 | 388 | |
| 371 | 389 | $data[$k] = $txt['who_hidden']; |
| 372 | 390 | $topic_ids[$topic][$k] = $txt['whotopic_' . $actions['action']]; |
| 373 | - } |
|
| 374 | - elseif (isset($txt['whopost_' . $actions['action']])) |
|
| 391 | + } elseif (isset($txt['whopost_' . $actions['action']])) |
|
| 375 | 392 | { |
| 376 | 393 | // Find out what message they are accessing. |
| 377 | 394 | $msgid = (int) (isset($actions['msg']) ? $actions['msg'] : (isset($actions['quote']) ? $actions['quote'] : 0)); |
@@ -394,41 +411,46 @@ discard block |
||
| 394 | 411 | $data[$k] = sprintf($txt['whopost_' . $actions['action']], $id_topic, $subject); |
| 395 | 412 | $smcFunc['db_free_result']($result); |
| 396 | 413 | |
| 397 | - if (empty($id_topic)) |
|
| 398 | - $data[$k] = $txt['who_hidden']; |
|
| 414 | + if (empty($id_topic)) { |
|
| 415 | + $data[$k] = $txt['who_hidden']; |
|
| 416 | + } |
|
| 399 | 417 | } |
| 400 | 418 | // Viewable only by administrators.. (if it starts with whoadmin, it's admin only!) |
| 401 | - elseif (allowedTo('moderate_forum') && isset($txt['whoadmin_' . $actions['action']])) |
|
| 402 | - $data[$k] = $txt['whoadmin_' . $actions['action']]; |
|
| 419 | + elseif (allowedTo('moderate_forum') && isset($txt['whoadmin_' . $actions['action']])) { |
|
| 420 | + $data[$k] = $txt['whoadmin_' . $actions['action']]; |
|
| 421 | + } |
|
| 403 | 422 | // Viewable by permission level. |
| 404 | 423 | elseif (isset($allowedActions[$actions['action']])) |
| 405 | 424 | { |
| 406 | - if (allowedTo($allowedActions[$actions['action']])) |
|
| 407 | - $data[$k] = $txt['whoallow_' . $actions['action']]; |
|
| 408 | - elseif (in_array('moderate_forum', $allowedActions[$actions['action']])) |
|
| 409 | - $data[$k] = $txt['who_moderate']; |
|
| 410 | - elseif (in_array('admin_forum', $allowedActions[$actions['action']])) |
|
| 411 | - $data[$k] = $txt['who_admin']; |
|
| 412 | - else |
|
| 413 | - $data[$k] = $txt['who_hidden']; |
|
| 425 | + if (allowedTo($allowedActions[$actions['action']])) { |
|
| 426 | + $data[$k] = $txt['whoallow_' . $actions['action']]; |
|
| 427 | + } elseif (in_array('moderate_forum', $allowedActions[$actions['action']])) { |
|
| 428 | + $data[$k] = $txt['who_moderate']; |
|
| 429 | + } elseif (in_array('admin_forum', $allowedActions[$actions['action']])) { |
|
| 430 | + $data[$k] = $txt['who_admin']; |
|
| 431 | + } else { |
|
| 432 | + $data[$k] = $txt['who_hidden']; |
|
| 433 | + } |
|
| 434 | + } elseif (!empty($actions['action'])) { |
|
| 435 | + $data[$k] = $txt['who_generic'] . ' ' . $actions['action']; |
|
| 436 | + } else { |
|
| 437 | + $data[$k] = $txt['who_unknown']; |
|
| 414 | 438 | } |
| 415 | - elseif (!empty($actions['action'])) |
|
| 416 | - $data[$k] = $txt['who_generic'] . ' ' . $actions['action']; |
|
| 417 | - else |
|
| 418 | - $data[$k] = $txt['who_unknown']; |
|
| 419 | 439 | } |
| 420 | 440 | |
| 421 | 441 | if (isset($actions['error'])) |
| 422 | 442 | { |
| 423 | - if (isset($txt[$actions['error']])) |
|
| 424 | - $error_message = str_replace('"', '"', empty($actions['who_error_params']) ? $txt[$actions['error']] : vsprintf($txt[$actions['error']], $actions['who_error_params'])); |
|
| 425 | - elseif ($actions['error'] == 'guest_login') |
|
| 426 | - $error_message = str_replace('"', '"', $txt['who_guest_login']); |
|
| 427 | - else |
|
| 428 | - $error_message = str_replace('"', '"', $actions['error']); |
|
| 429 | - |
|
| 430 | - if (!empty($error_message)) |
|
| 431 | - $data[$k] .= ' <span class="generic_icons error" title="' . $error_message . '"></span>'; |
|
| 443 | + if (isset($txt[$actions['error']])) { |
|
| 444 | + $error_message = str_replace('"', '"', empty($actions['who_error_params']) ? $txt[$actions['error']] : vsprintf($txt[$actions['error']], $actions['who_error_params'])); |
|
| 445 | + } elseif ($actions['error'] == 'guest_login') { |
|
| 446 | + $error_message = str_replace('"', '"', $txt['who_guest_login']); |
|
| 447 | + } else { |
|
| 448 | + $error_message = str_replace('"', '"', $actions['error']); |
|
| 449 | + } |
|
| 450 | + |
|
| 451 | + if (!empty($error_message)) { |
|
| 452 | + $data[$k] .= ' <span class="generic_icons error" title="' . $error_message . '"></span>'; |
|
| 453 | + } |
|
| 432 | 454 | } |
| 433 | 455 | |
| 434 | 456 | // Maybe the action is integrated into another system? |
@@ -439,12 +461,15 @@ discard block |
||
| 439 | 461 | if (!empty($integrate_action)) |
| 440 | 462 | { |
| 441 | 463 | $data[$k] = $integrate_action; |
| 442 | - if (isset($actions['topic']) && isset($topic_ids[(int) $actions['topic']][$k])) |
|
| 443 | - $topic_ids[(int) $actions['topic']][$k] = $integrate_action; |
|
| 444 | - if (isset($actions['board']) && isset($board_ids[(int) $actions['board']][$k])) |
|
| 445 | - $board_ids[(int) $actions['board']][$k] = $integrate_action; |
|
| 446 | - if (isset($actions['u']) && isset($profile_ids[(int) $actions['u']][$k])) |
|
| 447 | - $profile_ids[(int) $actions['u']][$k] = $integrate_action; |
|
| 464 | + if (isset($actions['topic']) && isset($topic_ids[(int) $actions['topic']][$k])) { |
|
| 465 | + $topic_ids[(int) $actions['topic']][$k] = $integrate_action; |
|
| 466 | + } |
|
| 467 | + if (isset($actions['board']) && isset($board_ids[(int) $actions['board']][$k])) { |
|
| 468 | + $board_ids[(int) $actions['board']][$k] = $integrate_action; |
|
| 469 | + } |
|
| 470 | + if (isset($actions['u']) && isset($profile_ids[(int) $actions['u']][$k])) { |
|
| 471 | + $profile_ids[(int) $actions['u']][$k] = $integrate_action; |
|
| 472 | + } |
|
| 448 | 473 | break; |
| 449 | 474 | } |
| 450 | 475 | } |
@@ -472,8 +497,9 @@ discard block |
||
| 472 | 497 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 473 | 498 | { |
| 474 | 499 | // Show the topic's subject for each of the actions. |
| 475 | - foreach ($topic_ids[$row['id_topic']] as $k => $session_text) |
|
| 476 | - $data[$k] = sprintf($session_text, $row['id_topic'], censorText($row['subject'])); |
|
| 500 | + foreach ($topic_ids[$row['id_topic']] as $k => $session_text) { |
|
| 501 | + $data[$k] = sprintf($session_text, $row['id_topic'], censorText($row['subject'])); |
|
| 502 | + } |
|
| 477 | 503 | } |
| 478 | 504 | $smcFunc['db_free_result']($result); |
| 479 | 505 | } |
@@ -495,8 +521,9 @@ discard block |
||
| 495 | 521 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 496 | 522 | { |
| 497 | 523 | // Put the board name into the string for each member... |
| 498 | - foreach ($board_ids[$row['id_board']] as $k => $session_text) |
|
| 499 | - $data[$k] = sprintf($session_text, $row['id_board'], $row['name']); |
|
| 524 | + foreach ($board_ids[$row['id_board']] as $k => $session_text) { |
|
| 525 | + $data[$k] = sprintf($session_text, $row['id_board'], $row['name']); |
|
| 526 | + } |
|
| 500 | 527 | } |
| 501 | 528 | $smcFunc['db_free_result']($result); |
| 502 | 529 | } |
@@ -518,23 +545,26 @@ discard block |
||
| 518 | 545 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 519 | 546 | { |
| 520 | 547 | // If they aren't allowed to view this person's profile, skip it. |
| 521 | - if (!$allow_view_any && ($user_info['id'] != $row['id_member'])) |
|
| 522 | - continue; |
|
| 548 | + if (!$allow_view_any && ($user_info['id'] != $row['id_member'])) { |
|
| 549 | + continue; |
|
| 550 | + } |
|
| 523 | 551 | |
| 524 | 552 | // Set their action on each - session/text to sprintf. |
| 525 | - foreach ($profile_ids[$row['id_member']] as $k => $session_text) |
|
| 526 | - $data[$k] = sprintf($session_text, $row['id_member'], $row['real_name']); |
|
| 553 | + foreach ($profile_ids[$row['id_member']] as $k => $session_text) { |
|
| 554 | + $data[$k] = sprintf($session_text, $row['id_member'], $row['real_name']); |
|
| 555 | + } |
|
| 527 | 556 | } |
| 528 | 557 | $smcFunc['db_free_result']($result); |
| 529 | 558 | } |
| 530 | 559 | |
| 531 | 560 | call_integration_hook('whos_online_after', array(&$urls, &$data)); |
| 532 | 561 | |
| 533 | - if (!is_array($urls)) |
|
| 534 | - return isset($data[0]) ? $data[0] : false; |
|
| 535 | - else |
|
| 536 | - return $data; |
|
| 537 | -} |
|
| 562 | + if (!is_array($urls)) { |
|
| 563 | + return isset($data[0]) ? $data[0] : false; |
|
| 564 | + } else { |
|
| 565 | + return $data; |
|
| 566 | + } |
|
| 567 | + } |
|
| 538 | 568 | |
| 539 | 569 | /** |
| 540 | 570 | * It prepares credit and copyright information for the credits page or the admin page |
@@ -709,8 +739,8 @@ discard block |
||
| 709 | 739 | ); |
| 710 | 740 | |
| 711 | 741 | // Give the translators some credit for their hard work. |
| 712 | - if (!empty($txt['translation_credits'])) |
|
| 713 | - $context['credits'][] = array( |
|
| 742 | + if (!empty($txt['translation_credits'])) { |
|
| 743 | + $context['credits'][] = array( |
|
| 714 | 744 | 'title' => $txt['credits_groups_translation'], |
| 715 | 745 | 'groups' => array( |
| 716 | 746 | array( |
@@ -719,6 +749,7 @@ discard block |
||
| 719 | 749 | ), |
| 720 | 750 | ), |
| 721 | 751 | ); |
| 752 | + } |
|
| 722 | 753 | |
| 723 | 754 | $context['credits'][] = array( |
| 724 | 755 | 'title' => $txt['credits_special'], |
@@ -673,7 +673,7 @@ |
||
| 673 | 673 | 'Nikola "Dzonny" Novaković', |
| 674 | 674 | // Localizers |
| 675 | 675 | 'Dr. Deejay', |
| 676 | - 'd3vcho', |
|
| 676 | + 'd3vcho', |
|
| 677 | 677 | // Former Localizers |
| 678 | 678 | 'Relyana', |
| 679 | 679 | ), |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 3 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * Get the latest posts of a forum. |
@@ -59,8 +60,9 @@ discard block |
||
| 59 | 60 | censorText($row['body']); |
| 60 | 61 | |
| 61 | 62 | $row['body'] = strip_tags(strtr(parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']), array('<br>' => ' '))); |
| 62 | - if ($smcFunc['strlen']($row['body']) > 128) |
|
| 63 | - $row['body'] = $smcFunc['substr']($row['body'], 0, 128) . '...'; |
|
| 63 | + if ($smcFunc['strlen']($row['body']) > 128) { |
|
| 64 | + $row['body'] = $smcFunc['substr']($row['body'], 0, 128) . '...'; |
|
| 65 | + } |
|
| 64 | 66 | |
| 65 | 67 | // Build the array. |
| 66 | 68 | $posts[] = array( |
@@ -181,14 +181,14 @@ discard block |
||
| 181 | 181 | { |
| 182 | 182 | collapsedDiv.show(\'slow\'); |
| 183 | 183 | icon.removeClass(\'toggle_down\').addClass(\'toggle_up\'); |
| 184 | - icon.prop(\'title\', '. JavaScriptEscape($txt['hide']) .'); |
|
| 184 | + icon.prop(\'title\', '. JavaScriptEscape($txt['hide']) . '); |
|
| 185 | 185 | } |
| 186 | 186 | |
| 187 | 187 | else |
| 188 | 188 | { |
| 189 | 189 | collapsedDiv.hide(\'slow\'); |
| 190 | 190 | icon.removeClass(\'toggle_up\').addClass(\'toggle_down\'); |
| 191 | - icon.prop(\'title\', '. JavaScriptEscape($txt['show']) .'); |
|
| 191 | + icon.prop(\'title\', '. JavaScriptEscape($txt['show']) . '); |
|
| 192 | 192 | } |
| 193 | 193 | |
| 194 | 194 | });', true); |
@@ -641,7 +641,7 @@ discard block |
||
| 641 | 641 | |
| 642 | 642 | // Setup the correct template, even though I'll admit we ain't downloading ;) |
| 643 | 643 | $context['sub_template'] = 'downloaded'; |
| 644 | - $allowext = array('.zip','.tgz','.gz'); |
|
| 644 | + $allowext = array('.zip', '.tgz', '.gz'); |
|
| 645 | 645 | // @todo Use FTP if the Packages directory is not writable. |
| 646 | 646 | |
| 647 | 647 | // Check the file was even sent! |
@@ -653,13 +653,13 @@ discard block |
||
| 653 | 653 | // Make sure it has a sane filename. |
| 654 | 654 | $_FILES['package']['name'] = preg_replace(array('/\s/', '/\.[\.]+/', '/[^\w_\.\-]/'), array('_', '.', ''), $_FILES['package']['name']); |
| 655 | 655 | $extension = substr(strrchr(strtolower($_FILES['package']['name']), '.'), 0); |
| 656 | - if(!in_array($extension, $allowext)) |
|
| 656 | + if (!in_array($extension, $allowext)) |
|
| 657 | 657 | { |
| 658 | 658 | fatal_lang_error('package_upload_error_supports', false, array('zip, tgz, tar.gz')); |
| 659 | 659 | } |
| 660 | 660 | |
| 661 | 661 | // We only need the filename... |
| 662 | - $extension = ($extension == '.gz') ? '.tar.gz' : $extension ; |
|
| 662 | + $extension = ($extension == '.gz') ? '.tar.gz' : $extension; |
|
| 663 | 663 | $packageName = time() . $extension; |
| 664 | 664 | |
| 665 | 665 | // Setup the destination and throw an error if the file is already there! |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 3 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * Browse the list of package servers, add servers... |
@@ -43,13 +44,15 @@ discard block |
||
| 43 | 44 | ); |
| 44 | 45 | |
| 45 | 46 | // Now let's decide where we are taking this... |
| 46 | - if (isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']])) |
|
| 47 | - $context['sub_action'] = $_REQUEST['sa']; |
|
| 47 | + if (isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']])) { |
|
| 48 | + $context['sub_action'] = $_REQUEST['sa']; |
|
| 49 | + } |
|
| 48 | 50 | // We need to support possible old javascript links... |
| 49 | - elseif (isset($_GET['pgdownload'])) |
|
| 50 | - $context['sub_action'] = 'download'; |
|
| 51 | - else |
|
| 52 | - $context['sub_action'] = 'servers'; |
|
| 51 | + elseif (isset($_GET['pgdownload'])) { |
|
| 52 | + $context['sub_action'] = 'download'; |
|
| 53 | + } else { |
|
| 54 | + $context['sub_action'] = 'servers'; |
|
| 55 | + } |
|
| 53 | 56 | |
| 54 | 57 | // We need to force the "Download" tab as selected. |
| 55 | 58 | $context['menu_data_' . $context['admin_menu_id']]['current_subsection'] = 'packageget'; |
@@ -141,17 +144,19 @@ discard block |
||
| 141 | 144 | { |
| 142 | 145 | require_once($sourcedir . '/Class-Package.php'); |
| 143 | 146 | $ftp = new ftp_connection(null); |
| 147 | + } elseif ($ftp->error !== false && !isset($ftp_error)) { |
|
| 148 | + $ftp_error = $ftp->last_message === null ? '' : $ftp->last_message; |
|
| 144 | 149 | } |
| 145 | - elseif ($ftp->error !== false && !isset($ftp_error)) |
|
| 146 | - $ftp_error = $ftp->last_message === null ? '' : $ftp->last_message; |
|
| 147 | 150 | |
| 148 | 151 | list ($username, $detect_path, $found_path) = $ftp->detect_path($packagesdir); |
| 149 | 152 | |
| 150 | - if ($found_path || !isset($_POST['ftp_path'])) |
|
| 151 | - $_POST['ftp_path'] = $detect_path; |
|
| 153 | + if ($found_path || !isset($_POST['ftp_path'])) { |
|
| 154 | + $_POST['ftp_path'] = $detect_path; |
|
| 155 | + } |
|
| 152 | 156 | |
| 153 | - if (!isset($_POST['ftp_username'])) |
|
| 154 | - $_POST['ftp_username'] = $username; |
|
| 157 | + if (!isset($_POST['ftp_username'])) { |
|
| 158 | + $_POST['ftp_username'] = $username; |
|
| 159 | + } |
|
| 155 | 160 | |
| 156 | 161 | $context['package_ftp'] = array( |
| 157 | 162 | 'server' => isset($_POST['ftp_server']) ? $_POST['ftp_server'] : (isset($modSettings['package_server']) ? $modSettings['package_server'] : 'localhost'), |
@@ -160,8 +165,7 @@ discard block |
||
| 160 | 165 | 'path' => $_POST['ftp_path'], |
| 161 | 166 | 'error' => empty($ftp_error) ? null : $ftp_error, |
| 162 | 167 | ); |
| 163 | - } |
|
| 164 | - else |
|
| 168 | + } else |
|
| 165 | 169 | { |
| 166 | 170 | $context['package_download_broken'] = false; |
| 167 | 171 | |
@@ -203,8 +207,9 @@ discard block |
||
| 203 | 207 | |
| 204 | 208 | if (isset($_GET['server'])) |
| 205 | 209 | { |
| 206 | - if ($_GET['server'] == '') |
|
| 207 | - redirectexit('action=admin;area=packages;get'); |
|
| 210 | + if ($_GET['server'] == '') { |
|
| 211 | + redirectexit('action=admin;area=packages;get'); |
|
| 212 | + } |
|
| 208 | 213 | |
| 209 | 214 | $server = (int) $_GET['server']; |
| 210 | 215 | |
@@ -222,17 +227,18 @@ discard block |
||
| 222 | 227 | $smcFunc['db_free_result']($request); |
| 223 | 228 | |
| 224 | 229 | // If the server does not exist, dump out. |
| 225 | - if (empty($url)) |
|
| 226 | - fatal_lang_error('couldnt_connect', false); |
|
| 230 | + if (empty($url)) { |
|
| 231 | + fatal_lang_error('couldnt_connect', false); |
|
| 232 | + } |
|
| 227 | 233 | |
| 228 | 234 | // If there is a relative link, append to the stored server url. |
| 229 | - if (isset($_GET['relative'])) |
|
| 230 | - $url = $url . (substr($url, -1) == '/' ? '' : '/') . $_GET['relative']; |
|
| 235 | + if (isset($_GET['relative'])) { |
|
| 236 | + $url = $url . (substr($url, -1) == '/' ? '' : '/') . $_GET['relative']; |
|
| 237 | + } |
|
| 231 | 238 | |
| 232 | 239 | // Clear any "absolute" URL. Since "server" is present, "absolute" is garbage. |
| 233 | 240 | unset($_GET['absolute']); |
| 234 | - } |
|
| 235 | - elseif (isset($_GET['absolute']) && $_GET['absolute'] != '') |
|
| 241 | + } elseif (isset($_GET['absolute']) && $_GET['absolute'] != '') |
|
| 236 | 242 | { |
| 237 | 243 | // Initialize the requried variables. |
| 238 | 244 | $server = ''; |
@@ -256,16 +262,19 @@ discard block |
||
| 256 | 262 | } |
| 257 | 263 | } |
| 258 | 264 | // Minimum required parameter did not exist so dump out. |
| 259 | - else |
|
| 260 | - fatal_lang_error('couldnt_connect', false); |
|
| 265 | + else { |
|
| 266 | + fatal_lang_error('couldnt_connect', false); |
|
| 267 | + } |
|
| 261 | 268 | |
| 262 | 269 | // Attempt to connect. If unsuccessful... try the URL. |
| 263 | - if (!isset($_GET['package']) || file_exists($_GET['package'])) |
|
| 264 | - $_GET['package'] = $url . '/packages.xml?language=' . $context['user']['language']; |
|
| 270 | + if (!isset($_GET['package']) || file_exists($_GET['package'])) { |
|
| 271 | + $_GET['package'] = $url . '/packages.xml?language=' . $context['user']['language']; |
|
| 272 | + } |
|
| 265 | 273 | |
| 266 | 274 | // Check to be sure the packages.xml file actually exists where it is should be... or dump out. |
| 267 | - if ((isset($_GET['absolute']) || isset($_GET['relative'])) && !url_exists($_GET['package'])) |
|
| 268 | - fatal_lang_error('packageget_unable', false, array($url . '/index.php')); |
|
| 275 | + if ((isset($_GET['absolute']) || isset($_GET['relative'])) && !url_exists($_GET['package'])) { |
|
| 276 | + fatal_lang_error('packageget_unable', false, array($url . '/index.php')); |
|
| 277 | + } |
|
| 269 | 278 | |
| 270 | 279 | // Might take some time. |
| 271 | 280 | @set_time_limit(600); |
@@ -275,8 +284,9 @@ discard block |
||
| 275 | 284 | $listing = new xmlArray(fetch_web_data($_GET['package']), true); |
| 276 | 285 | |
| 277 | 286 | // Errm.... empty file? Try the URL.... |
| 278 | - if (!$listing->exists('package-list')) |
|
| 279 | - fatal_lang_error('packageget_unable', false, array($url . '/index.php')); |
|
| 287 | + if (!$listing->exists('package-list')) { |
|
| 288 | + fatal_lang_error('packageget_unable', false, array($url . '/index.php')); |
|
| 289 | + } |
|
| 280 | 290 | |
| 281 | 291 | // List out the packages... |
| 282 | 292 | $context['package_list'] = array(); |
@@ -284,8 +294,9 @@ discard block |
||
| 284 | 294 | $listing = $listing->path('package-list[0]'); |
| 285 | 295 | |
| 286 | 296 | // Use the package list's name if it exists. |
| 287 | - if ($listing->exists('list-title')) |
|
| 288 | - $name = $smcFunc['htmlspecialchars']($listing->fetch('list-title')); |
|
| 297 | + if ($listing->exists('list-title')) { |
|
| 298 | + $name = $smcFunc['htmlspecialchars']($listing->fetch('list-title')); |
|
| 299 | + } |
|
| 289 | 300 | |
| 290 | 301 | // Pick the correct template. |
| 291 | 302 | $context['sub_template'] = 'package_list'; |
@@ -300,28 +311,32 @@ discard block |
||
| 300 | 311 | |
| 301 | 312 | $installed_mods = array(); |
| 302 | 313 | // Look through the list of installed mods... |
| 303 | - foreach ($instmods as $installed_mod) |
|
| 304 | - $installed_mods[$installed_mod['package_id']] = $installed_mod['version']; |
|
| 314 | + foreach ($instmods as $installed_mod) { |
|
| 315 | + $installed_mods[$installed_mod['package_id']] = $installed_mod['version']; |
|
| 316 | + } |
|
| 305 | 317 | |
| 306 | 318 | // Get default author and email if they exist. |
| 307 | 319 | if ($listing->exists('default-author')) |
| 308 | 320 | { |
| 309 | 321 | $default_author = $smcFunc['htmlspecialchars']($listing->fetch('default-author')); |
| 310 | - if ($listing->exists('default-author/@email') && filter_var($listing->fetch('default-author/@email'), FILTER_VALIDATE_EMAIL)) |
|
| 311 | - $default_email = $smcFunc['htmlspecialchars']($listing->fetch('default-author/@email')); |
|
| 322 | + if ($listing->exists('default-author/@email') && filter_var($listing->fetch('default-author/@email'), FILTER_VALIDATE_EMAIL)) { |
|
| 323 | + $default_email = $smcFunc['htmlspecialchars']($listing->fetch('default-author/@email')); |
|
| 324 | + } |
|
| 312 | 325 | } |
| 313 | 326 | |
| 314 | 327 | // Get default web site if it exists. |
| 315 | 328 | if ($listing->exists('default-website')) |
| 316 | 329 | { |
| 317 | 330 | $default_website = $smcFunc['htmlspecialchars']($listing->fetch('default-website')); |
| 318 | - if ($listing->exists('default-website/@title')) |
|
| 319 | - $default_title = $smcFunc['htmlspecialchars']($listing->fetch('default-website/@title')); |
|
| 331 | + if ($listing->exists('default-website/@title')) { |
|
| 332 | + $default_title = $smcFunc['htmlspecialchars']($listing->fetch('default-website/@title')); |
|
| 333 | + } |
|
| 320 | 334 | } |
| 321 | 335 | |
| 322 | 336 | $the_version = strtr($forum_version, array('SMF ' => '')); |
| 323 | - if (!empty($_SESSION['version_emulate'])) |
|
| 324 | - $the_version = $_SESSION['version_emulate']; |
|
| 337 | + if (!empty($_SESSION['version_emulate'])) { |
|
| 338 | + $the_version = $_SESSION['version_emulate']; |
|
| 339 | + } |
|
| 325 | 340 | |
| 326 | 341 | $packageNum = 0; |
| 327 | 342 | $packageSection = 0; |
@@ -342,11 +357,13 @@ discard block |
||
| 342 | 357 | 'type' => $thisPackage->name(), |
| 343 | 358 | ); |
| 344 | 359 | |
| 345 | - if (in_array($package['type'], array('title', 'text'))) |
|
| 346 | - $context['package_list'][$packageSection][$package['type']] = $smcFunc['htmlspecialchars']($thisPackage->fetch('.')); |
|
| 360 | + if (in_array($package['type'], array('title', 'text'))) { |
|
| 361 | + $context['package_list'][$packageSection][$package['type']] = $smcFunc['htmlspecialchars']($thisPackage->fetch('.')); |
|
| 362 | + } |
|
| 347 | 363 | // It's a Title, Heading, Rule or Text. |
| 348 | - elseif (in_array($package['type'], array('heading', 'rule'))) |
|
| 349 | - $package['name'] = $smcFunc['htmlspecialchars']($thisPackage->fetch('.')); |
|
| 364 | + elseif (in_array($package['type'], array('heading', 'rule'))) { |
|
| 365 | + $package['name'] = $smcFunc['htmlspecialchars']($thisPackage->fetch('.')); |
|
| 366 | + } |
|
| 350 | 367 | // It's a Remote link. |
| 351 | 368 | elseif ($package['type'] == 'remote') |
| 352 | 369 | { |
@@ -354,20 +371,21 @@ discard block |
||
| 354 | 371 | |
| 355 | 372 | if ($remote_type == 'relative' && substr($thisPackage->fetch('@href'), 0, 7) != 'http://' && substr($thisPackage->fetch('@href'), 0, 8) != 'https://') |
| 356 | 373 | { |
| 357 | - if (isset($_GET['absolute'])) |
|
| 358 | - $current_url = $_GET['absolute'] . '/'; |
|
| 359 | - elseif (isset($_GET['relative'])) |
|
| 360 | - $current_url = $_GET['relative'] . '/'; |
|
| 361 | - else |
|
| 362 | - $current_url = ''; |
|
| 374 | + if (isset($_GET['absolute'])) { |
|
| 375 | + $current_url = $_GET['absolute'] . '/'; |
|
| 376 | + } elseif (isset($_GET['relative'])) { |
|
| 377 | + $current_url = $_GET['relative'] . '/'; |
|
| 378 | + } else { |
|
| 379 | + $current_url = ''; |
|
| 380 | + } |
|
| 363 | 381 | |
| 364 | 382 | $current_url .= $thisPackage->fetch('@href'); |
| 365 | - if (isset($_GET['absolute'])) |
|
| 366 | - $package['href'] = $scripturl . '?action=admin;area=packages;get;sa=browse;absolute=' . $current_url; |
|
| 367 | - else |
|
| 368 | - $package['href'] = $scripturl . '?action=admin;area=packages;get;sa=browse;server=' . $context['package_server'] . ';relative=' . $current_url; |
|
| 369 | - } |
|
| 370 | - else |
|
| 383 | + if (isset($_GET['absolute'])) { |
|
| 384 | + $package['href'] = $scripturl . '?action=admin;area=packages;get;sa=browse;absolute=' . $current_url; |
|
| 385 | + } else { |
|
| 386 | + $package['href'] = $scripturl . '?action=admin;area=packages;get;sa=browse;server=' . $context['package_server'] . ';relative=' . $current_url; |
|
| 387 | + } |
|
| 388 | + } else |
|
| 371 | 389 | { |
| 372 | 390 | $current_url = $thisPackage->fetch('@href'); |
| 373 | 391 | $package['href'] = $scripturl . '?action=admin;area=packages;get;sa=browse;absolute=' . $current_url; |
@@ -379,25 +397,28 @@ discard block |
||
| 379 | 397 | // It's a package... |
| 380 | 398 | else |
| 381 | 399 | { |
| 382 | - if (isset($_GET['absolute'])) |
|
| 383 | - $current_url = $_GET['absolute'] . '/'; |
|
| 384 | - elseif (isset($_GET['relative'])) |
|
| 385 | - $current_url = $_GET['relative'] . '/'; |
|
| 386 | - else |
|
| 387 | - $current_url = ''; |
|
| 400 | + if (isset($_GET['absolute'])) { |
|
| 401 | + $current_url = $_GET['absolute'] . '/'; |
|
| 402 | + } elseif (isset($_GET['relative'])) { |
|
| 403 | + $current_url = $_GET['relative'] . '/'; |
|
| 404 | + } else { |
|
| 405 | + $current_url = ''; |
|
| 406 | + } |
|
| 388 | 407 | |
| 389 | 408 | $server_att = $server != '' ? ';server=' . $server : ''; |
| 390 | 409 | |
| 391 | 410 | $package += $thisPackage->to_array(); |
| 392 | 411 | |
| 393 | - if (isset($package['website'])) |
|
| 394 | - unset($package['website']); |
|
| 412 | + if (isset($package['website'])) { |
|
| 413 | + unset($package['website']); |
|
| 414 | + } |
|
| 395 | 415 | $package['author'] = array(); |
| 396 | 416 | |
| 397 | - if ($package['description'] == '') |
|
| 398 | - $package['description'] = $txt['package_no_description']; |
|
| 399 | - else |
|
| 400 | - $package['description'] = parse_bbc(preg_replace('~\[[/]?html\]~i', '', $smcFunc['htmlspecialchars']($package['description']))); |
|
| 417 | + if ($package['description'] == '') { |
|
| 418 | + $package['description'] = $txt['package_no_description']; |
|
| 419 | + } else { |
|
| 420 | + $package['description'] = parse_bbc(preg_replace('~\[[/]?html\]~i', '', $smcFunc['htmlspecialchars']($package['description']))); |
|
| 421 | + } |
|
| 401 | 422 | |
| 402 | 423 | $package['is_installed'] = isset($installed_mods[$package['id']]); |
| 403 | 424 | $package['is_current'] = $package['is_installed'] && ($installed_mods[$package['id']] == $package['version']); |
@@ -406,12 +427,14 @@ discard block |
||
| 406 | 427 | // This package is either not installed, or installed but old. Is it supported on this version of SMF? |
| 407 | 428 | if (!$package['is_installed'] || (!$package['is_current'] && !$package['is_newer'])) |
| 408 | 429 | { |
| 409 | - if ($thisPackage->exists('version/@for')) |
|
| 410 | - $package['can_install'] = matchPackageVersion($the_version, $thisPackage->fetch('version/@for')); |
|
| 430 | + if ($thisPackage->exists('version/@for')) { |
|
| 431 | + $package['can_install'] = matchPackageVersion($the_version, $thisPackage->fetch('version/@for')); |
|
| 432 | + } |
|
| 411 | 433 | } |
| 412 | 434 | // Okay, it's already installed AND up to date. |
| 413 | - else |
|
| 414 | - $package['can_install'] = false; |
|
| 435 | + else { |
|
| 436 | + $package['can_install'] = false; |
|
| 437 | + } |
|
| 415 | 438 | |
| 416 | 439 | $already_exists = getPackageInfo(basename($package['filename'])); |
| 417 | 440 | $package['download_conflict'] = is_array($already_exists) && $already_exists['id'] == $package['id'] && $already_exists['version'] != $package['version']; |
@@ -423,40 +446,44 @@ discard block |
||
| 423 | 446 | |
| 424 | 447 | if ($thisPackage->exists('author') || isset($default_author)) |
| 425 | 448 | { |
| 426 | - if ($thisPackage->exists('author/@email') && filter_var($thisPackage->fetch('author/@email'), FILTER_VALIDATE_EMAIL)) |
|
| 427 | - $package['author']['email'] = $thisPackage->fetch('author/@email'); |
|
| 428 | - elseif (isset($default_email)) |
|
| 429 | - $package['author']['email'] = $default_email; |
|
| 430 | - |
|
| 431 | - if ($thisPackage->exists('author') && $thisPackage->fetch('author') != '') |
|
| 432 | - $package['author']['name'] = $smcFunc['htmlspecialchars']($thisPackage->fetch('author')); |
|
| 433 | - else |
|
| 434 | - $package['author']['name'] = $default_author; |
|
| 435 | - |
|
| 436 | - if (!empty($package['author']['email'])) |
|
| 437 | - $package['author']['link'] = '<a href="mailto:' . $package['author']['email'] . '">' . $package['author']['name'] . '</a>'; |
|
| 449 | + if ($thisPackage->exists('author/@email') && filter_var($thisPackage->fetch('author/@email'), FILTER_VALIDATE_EMAIL)) { |
|
| 450 | + $package['author']['email'] = $thisPackage->fetch('author/@email'); |
|
| 451 | + } elseif (isset($default_email)) { |
|
| 452 | + $package['author']['email'] = $default_email; |
|
| 453 | + } |
|
| 454 | + |
|
| 455 | + if ($thisPackage->exists('author') && $thisPackage->fetch('author') != '') { |
|
| 456 | + $package['author']['name'] = $smcFunc['htmlspecialchars']($thisPackage->fetch('author')); |
|
| 457 | + } else { |
|
| 458 | + $package['author']['name'] = $default_author; |
|
| 459 | + } |
|
| 460 | + |
|
| 461 | + if (!empty($package['author']['email'])) { |
|
| 462 | + $package['author']['link'] = '<a href="mailto:' . $package['author']['email'] . '">' . $package['author']['name'] . '</a>'; |
|
| 463 | + } |
|
| 438 | 464 | } |
| 439 | 465 | |
| 440 | 466 | if ($thisPackage->exists('website') || isset($default_website)) |
| 441 | 467 | { |
| 442 | - if ($thisPackage->exists('website') && $thisPackage->exists('website/@title')) |
|
| 443 | - $package['author']['website']['name'] = $smcFunc['htmlspecialchars']($thisPackage->fetch('website/@title')); |
|
| 444 | - elseif (isset($default_title)) |
|
| 445 | - $package['author']['website']['name'] = $default_title; |
|
| 446 | - elseif ($thisPackage->exists('website')) |
|
| 447 | - $package['author']['website']['name'] = $smcFunc['htmlspecialchars']($thisPackage->fetch('website')); |
|
| 448 | - else |
|
| 449 | - $package['author']['website']['name'] = $default_website; |
|
| 450 | - |
|
| 451 | - if ($thisPackage->exists('website') && $thisPackage->fetch('website') != '') |
|
| 452 | - $authorhompage = $smcFunc['htmlspecialchars']($thisPackage->fetch('website')); |
|
| 453 | - else |
|
| 454 | - $authorhompage = $default_website; |
|
| 468 | + if ($thisPackage->exists('website') && $thisPackage->exists('website/@title')) { |
|
| 469 | + $package['author']['website']['name'] = $smcFunc['htmlspecialchars']($thisPackage->fetch('website/@title')); |
|
| 470 | + } elseif (isset($default_title)) { |
|
| 471 | + $package['author']['website']['name'] = $default_title; |
|
| 472 | + } elseif ($thisPackage->exists('website')) { |
|
| 473 | + $package['author']['website']['name'] = $smcFunc['htmlspecialchars']($thisPackage->fetch('website')); |
|
| 474 | + } else { |
|
| 475 | + $package['author']['website']['name'] = $default_website; |
|
| 476 | + } |
|
| 477 | + |
|
| 478 | + if ($thisPackage->exists('website') && $thisPackage->fetch('website') != '') { |
|
| 479 | + $authorhompage = $smcFunc['htmlspecialchars']($thisPackage->fetch('website')); |
|
| 480 | + } else { |
|
| 481 | + $authorhompage = $default_website; |
|
| 482 | + } |
|
| 455 | 483 | |
| 456 | 484 | $package['author']['website']['href'] = $authorhompage; |
| 457 | 485 | $package['author']['website']['link'] = '<a href="' . $authorhompage . '">' . $package['author']['website']['name'] . '</a>'; |
| 458 | - } |
|
| 459 | - else |
|
| 486 | + } else |
|
| 460 | 487 | { |
| 461 | 488 | $package['author']['website']['href'] = ''; |
| 462 | 489 | $package['author']['website']['link'] = ''; |
@@ -472,11 +499,13 @@ discard block |
||
| 472 | 499 | $packageNum = in_array($package['type'], array('title', 'heading', 'text', 'remote', 'rule')) ? 0 : $packageNum + 1; |
| 473 | 500 | $package['count'] = $packageNum; |
| 474 | 501 | |
| 475 | - if (!in_array($package['type'], array('title', 'text'))) |
|
| 476 | - $context['package_list'][$packageSection]['items'][] = $package; |
|
| 502 | + if (!in_array($package['type'], array('title', 'text'))) { |
|
| 503 | + $context['package_list'][$packageSection]['items'][] = $package; |
|
| 504 | + } |
|
| 477 | 505 | |
| 478 | - if ($package['count'] > 1) |
|
| 479 | - $context['list_type'] = 'ol'; |
|
| 506 | + if ($package['count'] > 1) { |
|
| 507 | + $context['list_type'] = 'ol'; |
|
| 508 | + } |
|
| 480 | 509 | } |
| 481 | 510 | |
| 482 | 511 | $packageSection++; |
@@ -489,8 +518,9 @@ discard block |
||
| 489 | 518 | { |
| 490 | 519 | foreach ($packageSection['items'] as $i => $package) |
| 491 | 520 | { |
| 492 | - if ($package['count'] == 0 || isset($package['can_install'])) |
|
| 493 | - continue; |
|
| 521 | + if ($package['count'] == 0 || isset($package['can_install'])) { |
|
| 522 | + continue; |
|
| 523 | + } |
|
| 494 | 524 | |
| 495 | 525 | $context['package_list'][$ps_id]['items'][$i]['can_install'] = false; |
| 496 | 526 | |
@@ -539,8 +569,9 @@ discard block |
||
| 539 | 569 | checkSession('get'); |
| 540 | 570 | |
| 541 | 571 | // To download something, we need a valid server or url. |
| 542 | - if (empty($_GET['server']) && (!empty($_GET['get']) && !empty($_REQUEST['package']))) |
|
| 543 | - fatal_lang_error('package_get_error_is_zero', false); |
|
| 572 | + if (empty($_GET['server']) && (!empty($_GET['get']) && !empty($_REQUEST['package']))) { |
|
| 573 | + fatal_lang_error('package_get_error_is_zero', false); |
|
| 574 | + } |
|
| 544 | 575 | |
| 545 | 576 | if (isset($_GET['server'])) |
| 546 | 577 | { |
@@ -560,22 +591,23 @@ discard block |
||
| 560 | 591 | $smcFunc['db_free_result']($request); |
| 561 | 592 | |
| 562 | 593 | // If server does not exist then dump out. |
| 563 | - if (empty($url)) |
|
| 564 | - fatal_lang_error('couldnt_connect', false); |
|
| 594 | + if (empty($url)) { |
|
| 595 | + fatal_lang_error('couldnt_connect', false); |
|
| 596 | + } |
|
| 565 | 597 | |
| 566 | 598 | $url = $url . '/'; |
| 567 | - } |
|
| 568 | - else |
|
| 599 | + } else |
|
| 569 | 600 | { |
| 570 | 601 | // Initialize the requried variables. |
| 571 | 602 | $server = ''; |
| 572 | 603 | $url = ''; |
| 573 | 604 | } |
| 574 | 605 | |
| 575 | - if (isset($_REQUEST['byurl']) && !empty($_POST['filename'])) |
|
| 576 | - $package_name = basename($_REQUEST['filename']); |
|
| 577 | - else |
|
| 578 | - $package_name = basename($_REQUEST['package']); |
|
| 606 | + if (isset($_REQUEST['byurl']) && !empty($_POST['filename'])) { |
|
| 607 | + $package_name = basename($_REQUEST['filename']); |
|
| 608 | + } else { |
|
| 609 | + $package_name = basename($_REQUEST['package']); |
|
| 610 | + } |
|
| 579 | 611 | |
| 580 | 612 | if (isset($_REQUEST['conflict']) || (isset($_REQUEST['auto']) && file_exists($packagesdir . '/' . $package_name))) |
| 581 | 613 | { |
@@ -584,14 +616,15 @@ discard block |
||
| 584 | 616 | { |
| 585 | 617 | $ext = substr($package_name, strrpos(substr($package_name, 0, -3), '.')); |
| 586 | 618 | $package_name = substr($package_name, 0, strrpos(substr($package_name, 0, -3), '.')) . '_'; |
| 619 | + } else { |
|
| 620 | + $ext = ''; |
|
| 587 | 621 | } |
| 588 | - else |
|
| 589 | - $ext = ''; |
|
| 590 | 622 | |
| 591 | 623 | // Find the first available. |
| 592 | 624 | $i = 1; |
| 593 | - while (file_exists($packagesdir . '/' . $package_name . $i . $ext)) |
|
| 594 | - $i++; |
|
| 625 | + while (file_exists($packagesdir . '/' . $package_name . $i . $ext)) { |
|
| 626 | + $i++; |
|
| 627 | + } |
|
| 595 | 628 | |
| 596 | 629 | $package_name = $package_name . $i . $ext; |
| 597 | 630 | } |
@@ -601,25 +634,28 @@ discard block |
||
| 601 | 634 | package_put_contents($packagesdir . '/' . $package_name, fetch_web_data($url . $_REQUEST['package'])); |
| 602 | 635 | |
| 603 | 636 | // Done! Did we get this package automatically? |
| 604 | - if (preg_match('~^http://[\w_\-]+\.simplemachines\.org/~', $_REQUEST['package']) == 1 && strpos($_REQUEST['package'], 'dlattach') === false && isset($_REQUEST['auto'])) |
|
| 605 | - redirectexit('action=admin;area=packages;sa=install;package=' . $package_name); |
|
| 637 | + if (preg_match('~^http://[\w_\-]+\.simplemachines\.org/~', $_REQUEST['package']) == 1 && strpos($_REQUEST['package'], 'dlattach') === false && isset($_REQUEST['auto'])) { |
|
| 638 | + redirectexit('action=admin;area=packages;sa=install;package=' . $package_name); |
|
| 639 | + } |
|
| 606 | 640 | |
| 607 | 641 | // You just downloaded a mod from SERVER_NAME_GOES_HERE. |
| 608 | 642 | $context['package_server'] = $server; |
| 609 | 643 | |
| 610 | 644 | $context['package'] = getPackageInfo($package_name); |
| 611 | 645 | |
| 612 | - if (!is_array($context['package'])) |
|
| 613 | - fatal_lang_error('package_cant_download', false); |
|
| 646 | + if (!is_array($context['package'])) { |
|
| 647 | + fatal_lang_error('package_cant_download', false); |
|
| 648 | + } |
|
| 614 | 649 | |
| 615 | - if ($context['package']['type'] == 'modification') |
|
| 616 | - $context['package']['install']['link'] = '<a href="' . $scripturl . '?action=admin;area=packages;sa=install;package=' . $context['package']['filename'] . '">[ ' . $txt['install_mod'] . ' ]</a>'; |
|
| 617 | - elseif ($context['package']['type'] == 'avatar') |
|
| 618 | - $context['package']['install']['link'] = '<a href="' . $scripturl . '?action=admin;area=packages;sa=install;package=' . $context['package']['filename'] . '">[ ' . $txt['use_avatars'] . ' ]</a>'; |
|
| 619 | - elseif ($context['package']['type'] == 'language') |
|
| 620 | - $context['package']['install']['link'] = '<a href="' . $scripturl . '?action=admin;area=packages;sa=install;package=' . $context['package']['filename'] . '">[ ' . $txt['add_languages'] . ' ]</a>'; |
|
| 621 | - else |
|
| 622 | - $context['package']['install']['link'] = ''; |
|
| 650 | + if ($context['package']['type'] == 'modification') { |
|
| 651 | + $context['package']['install']['link'] = '<a href="' . $scripturl . '?action=admin;area=packages;sa=install;package=' . $context['package']['filename'] . '">[ ' . $txt['install_mod'] . ' ]</a>'; |
|
| 652 | + } elseif ($context['package']['type'] == 'avatar') { |
|
| 653 | + $context['package']['install']['link'] = '<a href="' . $scripturl . '?action=admin;area=packages;sa=install;package=' . $context['package']['filename'] . '">[ ' . $txt['use_avatars'] . ' ]</a>'; |
|
| 654 | + } elseif ($context['package']['type'] == 'language') { |
|
| 655 | + $context['package']['install']['link'] = '<a href="' . $scripturl . '?action=admin;area=packages;sa=install;package=' . $context['package']['filename'] . '">[ ' . $txt['add_languages'] . ' ]</a>'; |
|
| 656 | + } else { |
|
| 657 | + $context['package']['install']['link'] = ''; |
|
| 658 | + } |
|
| 623 | 659 | |
| 624 | 660 | // Does a 3rd party hook want to do some additional changes? |
| 625 | 661 | call_integration_hook('integrate_package_download'); |
@@ -645,10 +681,11 @@ discard block |
||
| 645 | 681 | // @todo Use FTP if the Packages directory is not writable. |
| 646 | 682 | |
| 647 | 683 | // Check the file was even sent! |
| 648 | - if (!isset($_FILES['package']['name']) || $_FILES['package']['name'] == '') |
|
| 649 | - fatal_lang_error('package_upload_error_nofile'); |
|
| 650 | - elseif (!is_uploaded_file($_FILES['package']['tmp_name']) || (ini_get('open_basedir') == '' && !file_exists($_FILES['package']['tmp_name']))) |
|
| 651 | - fatal_lang_error('package_upload_error_failed'); |
|
| 684 | + if (!isset($_FILES['package']['name']) || $_FILES['package']['name'] == '') { |
|
| 685 | + fatal_lang_error('package_upload_error_nofile'); |
|
| 686 | + } elseif (!is_uploaded_file($_FILES['package']['tmp_name']) || (ini_get('open_basedir') == '' && !file_exists($_FILES['package']['tmp_name']))) { |
|
| 687 | + fatal_lang_error('package_upload_error_failed'); |
|
| 688 | + } |
|
| 652 | 689 | |
| 653 | 690 | // Make sure it has a sane filename. |
| 654 | 691 | $_FILES['package']['name'] = preg_replace(array('/\s/', '/\.[\.]+/', '/[^\w_\.\-]/'), array('_', '.', ''), $_FILES['package']['name']); |
@@ -665,8 +702,9 @@ discard block |
||
| 665 | 702 | // Setup the destination and throw an error if the file is already there! |
| 666 | 703 | $destination = $packagesdir . '/' . $packageName; |
| 667 | 704 | // @todo Maybe just roll it like we do for downloads? |
| 668 | - if (file_exists($destination)) |
|
| 669 | - fatal_lang_error('package_upload_error_exists'); |
|
| 705 | + if (file_exists($destination)) { |
|
| 706 | + fatal_lang_error('package_upload_error_exists'); |
|
| 707 | + } |
|
| 670 | 708 | |
| 671 | 709 | // Now move the file. |
| 672 | 710 | move_uploaded_file($_FILES['package']['tmp_name'], $destination); |
@@ -689,12 +727,14 @@ discard block |
||
| 689 | 727 | { |
| 690 | 728 | while ($package = readdir($dir)) |
| 691 | 729 | { |
| 692 | - if ($package == '.' || $package == '..' || $package == 'temp' || $package == $packageName || (!(is_dir($packagesdir . '/' . $package) && file_exists($packagesdir . '/' . $package . '/package-info.xml')) && substr(strtolower($package), -7) != '.tar.gz' && substr(strtolower($package), -4) != '.tgz' && substr(strtolower($package), -4) != '.zip')) |
|
| 693 | - continue; |
|
| 730 | + if ($package == '.' || $package == '..' || $package == 'temp' || $package == $packageName || (!(is_dir($packagesdir . '/' . $package) && file_exists($packagesdir . '/' . $package . '/package-info.xml')) && substr(strtolower($package), -7) != '.tar.gz' && substr(strtolower($package), -4) != '.tgz' && substr(strtolower($package), -4) != '.zip')) { |
|
| 731 | + continue; |
|
| 732 | + } |
|
| 694 | 733 | |
| 695 | 734 | $packageInfo = getPackageInfo($package); |
| 696 | - if (!is_array($packageInfo)) |
|
| 697 | - continue; |
|
| 735 | + if (!is_array($packageInfo)) { |
|
| 736 | + continue; |
|
| 737 | + } |
|
| 698 | 738 | |
| 699 | 739 | if ($packageInfo['id'] == $context['package']['id'] && $packageInfo['version'] == $context['package']['version']) |
| 700 | 740 | { |
@@ -706,14 +746,15 @@ discard block |
||
| 706 | 746 | closedir($dir); |
| 707 | 747 | } |
| 708 | 748 | |
| 709 | - if ($context['package']['type'] == 'modification') |
|
| 710 | - $context['package']['install']['link'] = '<a href="' . $scripturl . '?action=admin;area=packages;sa=install;package=' . $context['package']['filename'] . '">[ ' . $txt['install_mod'] . ' ]</a>'; |
|
| 711 | - elseif ($context['package']['type'] == 'avatar') |
|
| 712 | - $context['package']['install']['link'] = '<a href="' . $scripturl . '?action=admin;area=packages;sa=install;package=' . $context['package']['filename'] . '">[ ' . $txt['use_avatars'] . ' ]</a>'; |
|
| 713 | - elseif ($context['package']['type'] == 'language') |
|
| 714 | - $context['package']['install']['link'] = '<a href="' . $scripturl . '?action=admin;area=packages;sa=install;package=' . $context['package']['filename'] . '">[ ' . $txt['add_languages'] . ' ]</a>'; |
|
| 715 | - else |
|
| 716 | - $context['package']['install']['link'] = ''; |
|
| 749 | + if ($context['package']['type'] == 'modification') { |
|
| 750 | + $context['package']['install']['link'] = '<a href="' . $scripturl . '?action=admin;area=packages;sa=install;package=' . $context['package']['filename'] . '">[ ' . $txt['install_mod'] . ' ]</a>'; |
|
| 751 | + } elseif ($context['package']['type'] == 'avatar') { |
|
| 752 | + $context['package']['install']['link'] = '<a href="' . $scripturl . '?action=admin;area=packages;sa=install;package=' . $context['package']['filename'] . '">[ ' . $txt['use_avatars'] . ' ]</a>'; |
|
| 753 | + } elseif ($context['package']['type'] == 'language') { |
|
| 754 | + $context['package']['install']['link'] = '<a href="' . $scripturl . '?action=admin;area=packages;sa=install;package=' . $context['package']['filename'] . '">[ ' . $txt['add_languages'] . ' ]</a>'; |
|
| 755 | + } else { |
|
| 756 | + $context['package']['install']['link'] = ''; |
|
| 757 | + } |
|
| 717 | 758 | |
| 718 | 759 | // Does a 3rd party hook want to do some additional changes? |
| 719 | 760 | call_integration_hook('integrate_package_upload'); |
@@ -736,16 +777,18 @@ discard block |
||
| 736 | 777 | checkSession(); |
| 737 | 778 | |
| 738 | 779 | // If they put a slash on the end, get rid of it. |
| 739 | - if (substr($_POST['serverurl'], -1) == '/') |
|
| 740 | - $_POST['serverurl'] = substr($_POST['serverurl'], 0, -1); |
|
| 780 | + if (substr($_POST['serverurl'], -1) == '/') { |
|
| 781 | + $_POST['serverurl'] = substr($_POST['serverurl'], 0, -1); |
|
| 782 | + } |
|
| 741 | 783 | |
| 742 | 784 | // Are they both nice and clean? |
| 743 | 785 | $servername = trim($smcFunc['htmlspecialchars']($_POST['servername'])); |
| 744 | 786 | $serverurl = trim($smcFunc['htmlspecialchars']($_POST['serverurl'])); |
| 745 | 787 | |
| 746 | 788 | // Make sure the URL has the correct prefix. |
| 747 | - if (strpos($serverurl, 'http://') !== 0 && strpos($serverurl, 'https://') !== 0) |
|
| 748 | - $serverurl = 'http://' . $serverurl; |
|
| 789 | + if (strpos($serverurl, 'http://') !== 0 && strpos($serverurl, 'https://') !== 0) { |
|
| 790 | + $serverurl = 'http://' . $serverurl; |
|
| 791 | + } |
|
| 749 | 792 | |
| 750 | 793 | $smcFunc['db_insert']('', |
| 751 | 794 | '{db_prefix}package_servers', |
@@ -15,8 +15,9 @@ discard block |
||
| 15 | 15 | * Original module by Mach8 - We'll never forget you. |
| 16 | 16 | */ |
| 17 | 17 | |
| 18 | -if (!defined('SMF')) |
|
| 18 | +if (!defined('SMF')) { |
|
| 19 | 19 | die('No direct access...'); |
| 20 | +} |
|
| 20 | 21 | |
| 21 | 22 | /** |
| 22 | 23 | * splits a topic into two topics. |
@@ -30,15 +31,17 @@ discard block |
||
| 30 | 31 | global $topic, $sourcedir; |
| 31 | 32 | |
| 32 | 33 | // And... which topic were you splitting, again? |
| 33 | - if (empty($topic)) |
|
| 34 | - fatal_lang_error('numbers_one_to_nine', false); |
|
| 34 | + if (empty($topic)) { |
|
| 35 | + fatal_lang_error('numbers_one_to_nine', false); |
|
| 36 | + } |
|
| 35 | 37 | |
| 36 | 38 | // Are you allowed to split topics? |
| 37 | 39 | isAllowedTo('split_any'); |
| 38 | 40 | |
| 39 | 41 | // Load up the "dependencies" - the template, getMsgMemberID(), and sendNotifications(). |
| 40 | - if (!isset($_REQUEST['xml'])) |
|
| 41 | - loadTemplate('SplitTopics'); |
|
| 42 | + if (!isset($_REQUEST['xml'])) { |
|
| 43 | + loadTemplate('SplitTopics'); |
|
| 44 | + } |
|
| 42 | 45 | require_once($sourcedir . '/Subs-Boards.php'); |
| 43 | 46 | require_once($sourcedir . '/Subs-Post.php'); |
| 44 | 47 | |
@@ -50,12 +53,12 @@ discard block |
||
| 50 | 53 | ); |
| 51 | 54 | |
| 52 | 55 | // ?action=splittopics;sa=LETSBREAKIT won't work, sorry. |
| 53 | - if (empty($_REQUEST['sa']) || !isset($subActions[$_REQUEST['sa']])) |
|
| 54 | - SplitIndex(); |
|
| 55 | - |
|
| 56 | - else |
|
| 57 | - call_helper($subActions[$_REQUEST['sa']]); |
|
| 58 | -} |
|
| 56 | + if (empty($_REQUEST['sa']) || !isset($subActions[$_REQUEST['sa']])) { |
|
| 57 | + SplitIndex(); |
|
| 58 | + } else { |
|
| 59 | + call_helper($subActions[$_REQUEST['sa']]); |
|
| 60 | + } |
|
| 61 | + } |
|
| 59 | 62 | |
| 60 | 63 | /** |
| 61 | 64 | * screen shown before the actual split. |
@@ -71,8 +74,9 @@ discard block |
||
| 71 | 74 | global $txt, $topic, $context, $smcFunc, $modSettings; |
| 72 | 75 | |
| 73 | 76 | // Validate "at". |
| 74 | - if (empty($_GET['at'])) |
|
| 75 | - fatal_lang_error('numbers_one_to_nine', false); |
|
| 77 | + if (empty($_GET['at'])) { |
|
| 78 | + fatal_lang_error('numbers_one_to_nine', false); |
|
| 79 | + } |
|
| 76 | 80 | $_GET['at'] = (int) $_GET['at']; |
| 77 | 81 | |
| 78 | 82 | // Retrieve the subject and stuff of the specific topic/message. |
@@ -89,26 +93,31 @@ discard block |
||
| 89 | 93 | 'split_at' => $_GET['at'], |
| 90 | 94 | ) |
| 91 | 95 | ); |
| 92 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 93 | - fatal_lang_error('cant_find_messages'); |
|
| 96 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 97 | + fatal_lang_error('cant_find_messages'); |
|
| 98 | + } |
|
| 94 | 99 | list ($_REQUEST['subname'], $num_replies, $unapproved_posts, $id_first_msg, $approved) = $smcFunc['db_fetch_row']($request); |
| 95 | 100 | $smcFunc['db_free_result']($request); |
| 96 | 101 | |
| 97 | 102 | // If not approved validate they can see it. |
| 98 | - if ($modSettings['postmod_active'] && !$approved) |
|
| 99 | - isAllowedTo('approve_posts'); |
|
| 103 | + if ($modSettings['postmod_active'] && !$approved) { |
|
| 104 | + isAllowedTo('approve_posts'); |
|
| 105 | + } |
|
| 100 | 106 | |
| 101 | 107 | // If this topic has unapproved posts, we need to count them too... |
| 102 | - if ($modSettings['postmod_active'] && allowedTo('approve_posts')) |
|
| 103 | - $num_replies += $unapproved_posts - ($approved ? 0 : 1); |
|
| 108 | + if ($modSettings['postmod_active'] && allowedTo('approve_posts')) { |
|
| 109 | + $num_replies += $unapproved_posts - ($approved ? 0 : 1); |
|
| 110 | + } |
|
| 104 | 111 | |
| 105 | 112 | // Check if there is more than one message in the topic. (there should be.) |
| 106 | - if ($num_replies < 1) |
|
| 107 | - fatal_lang_error('topic_one_post', false); |
|
| 113 | + if ($num_replies < 1) { |
|
| 114 | + fatal_lang_error('topic_one_post', false); |
|
| 115 | + } |
|
| 108 | 116 | |
| 109 | 117 | // Check if this is the first message in the topic (if so, the first and second option won't be available) |
| 110 | - if ($id_first_msg == $_GET['at']) |
|
| 111 | - return SplitSelectTopics(); |
|
| 118 | + if ($id_first_msg == $_GET['at']) { |
|
| 119 | + return SplitSelectTopics(); |
|
| 120 | + } |
|
| 112 | 121 | |
| 113 | 122 | // Basic template information.... |
| 114 | 123 | $context['message'] = array( |
@@ -137,8 +146,9 @@ discard block |
||
| 137 | 146 | checkSession(); |
| 138 | 147 | |
| 139 | 148 | // Clean up the subject. |
| 140 | - if (!isset($_POST['subname']) || $_POST['subname'] == '') |
|
| 141 | - $_POST['subname'] = $txt['new_topic']; |
|
| 149 | + if (!isset($_POST['subname']) || $_POST['subname'] == '') { |
|
| 150 | + $_POST['subname'] = $txt['new_topic']; |
|
| 151 | + } |
|
| 142 | 152 | |
| 143 | 153 | // Redirect to the selector if they chose selective. |
| 144 | 154 | if ($_POST['step2'] == 'selective') |
@@ -163,16 +173,19 @@ discard block |
||
| 163 | 173 | 'split_at' => $_POST['at'], |
| 164 | 174 | ) |
| 165 | 175 | ); |
| 166 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 167 | - $messagesToBeSplit[] = $row['id_msg']; |
|
| 176 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 177 | + $messagesToBeSplit[] = $row['id_msg']; |
|
| 178 | + } |
|
| 168 | 179 | $smcFunc['db_free_result']($request); |
| 169 | 180 | } |
| 170 | 181 | // Only the selected message has to be split. That should be easy. |
| 171 | - elseif ($_POST['step2'] == 'onlythis') |
|
| 172 | - $messagesToBeSplit[] = $_POST['at']; |
|
| 182 | + elseif ($_POST['step2'] == 'onlythis') { |
|
| 183 | + $messagesToBeSplit[] = $_POST['at']; |
|
| 184 | + } |
|
| 173 | 185 | // There's another action?! |
| 174 | - else |
|
| 175 | - fatal_lang_error('no_access', false); |
|
| 186 | + else { |
|
| 187 | + fatal_lang_error('no_access', false); |
|
| 188 | + } |
|
| 176 | 189 | |
| 177 | 190 | $context['old_topic'] = $topic; |
| 178 | 191 | $context['new_topic'] = splitTopic($topic, $messagesToBeSplit, $_POST['subname']); |
@@ -199,8 +212,9 @@ discard block |
||
| 199 | 212 | $_SESSION['split_selection'][$topic] = empty($_SESSION['split_selection'][$topic]) ? array() : $_SESSION['split_selection'][$topic]; |
| 200 | 213 | |
| 201 | 214 | // This is a special case for split topics from quick-moderation checkboxes |
| 202 | - if (isset($_REQUEST['subname_enc'])) |
|
| 203 | - $_REQUEST['subname'] = urldecode($_REQUEST['subname_enc']); |
|
| 215 | + if (isset($_REQUEST['subname_enc'])) { |
|
| 216 | + $_REQUEST['subname'] = urldecode($_REQUEST['subname_enc']); |
|
| 217 | + } |
|
| 204 | 218 | |
| 205 | 219 | $context['not_selected'] = array( |
| 206 | 220 | 'num_messages' => 0, |
@@ -252,10 +266,12 @@ discard block |
||
| 252 | 266 | ) |
| 253 | 267 | ); |
| 254 | 268 | // You can't split the last message off. |
| 255 | - if (empty($context['not_selected']['start']) && $smcFunc['db_num_rows']($request) <= 1 && $_REQUEST['move'] == 'down') |
|
| 256 | - $_REQUEST['move'] = ''; |
|
| 257 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 258 | - $original_msgs['not_selected'][] = $row['id_msg']; |
|
| 269 | + if (empty($context['not_selected']['start']) && $smcFunc['db_num_rows']($request) <= 1 && $_REQUEST['move'] == 'down') { |
|
| 270 | + $_REQUEST['move'] = ''; |
|
| 271 | + } |
|
| 272 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 273 | + $original_msgs['not_selected'][] = $row['id_msg']; |
|
| 274 | + } |
|
| 259 | 275 | $smcFunc['db_free_result']($request); |
| 260 | 276 | if (!empty($_SESSION['split_selection'][$topic])) |
| 261 | 277 | { |
@@ -275,8 +291,9 @@ discard block |
||
| 275 | 291 | 'messages_per_page' => $context['messages_per_page'], |
| 276 | 292 | ) |
| 277 | 293 | ); |
| 278 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 279 | - $original_msgs['selected'][] = $row['id_msg']; |
|
| 294 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 295 | + $original_msgs['selected'][] = $row['id_msg']; |
|
| 296 | + } |
|
| 280 | 297 | $smcFunc['db_free_result']($request); |
| 281 | 298 | } |
| 282 | 299 | } |
@@ -286,12 +303,13 @@ discard block |
||
| 286 | 303 | { |
| 287 | 304 | $_REQUEST['msg'] = (int) $_REQUEST['msg']; |
| 288 | 305 | |
| 289 | - if ($_REQUEST['move'] == 'reset') |
|
| 290 | - $_SESSION['split_selection'][$topic] = array(); |
|
| 291 | - elseif ($_REQUEST['move'] == 'up') |
|
| 292 | - $_SESSION['split_selection'][$topic] = array_diff($_SESSION['split_selection'][$topic], array($_REQUEST['msg'])); |
|
| 293 | - else |
|
| 294 | - $_SESSION['split_selection'][$topic][] = $_REQUEST['msg']; |
|
| 306 | + if ($_REQUEST['move'] == 'reset') { |
|
| 307 | + $_SESSION['split_selection'][$topic] = array(); |
|
| 308 | + } elseif ($_REQUEST['move'] == 'up') { |
|
| 309 | + $_SESSION['split_selection'][$topic] = array_diff($_SESSION['split_selection'][$topic], array($_REQUEST['msg'])); |
|
| 310 | + } else { |
|
| 311 | + $_SESSION['split_selection'][$topic][] = $_REQUEST['msg']; |
|
| 312 | + } |
|
| 295 | 313 | } |
| 296 | 314 | |
| 297 | 315 | // Make sure the selection is still accurate. |
@@ -310,8 +328,9 @@ discard block |
||
| 310 | 328 | ) |
| 311 | 329 | ); |
| 312 | 330 | $_SESSION['split_selection'][$topic] = array(); |
| 313 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 314 | - $_SESSION['split_selection'][$topic][] = $row['id_msg']; |
|
| 331 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 332 | + $_SESSION['split_selection'][$topic][] = $row['id_msg']; |
|
| 333 | + } |
|
| 315 | 334 | $smcFunc['db_free_result']($request); |
| 316 | 335 | } |
| 317 | 336 | |
@@ -328,13 +347,15 @@ discard block |
||
| 328 | 347 | 'is_approved' => 1, |
| 329 | 348 | ) |
| 330 | 349 | ); |
| 331 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 332 | - $context[empty($row['is_selected']) || $row['is_selected'] == 'f' ? 'not_selected' : 'selected']['num_messages'] = $row['num_messages']; |
|
| 350 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 351 | + $context[empty($row['is_selected']) || $row['is_selected'] == 'f' ? 'not_selected' : 'selected']['num_messages'] = $row['num_messages']; |
|
| 352 | + } |
|
| 333 | 353 | $smcFunc['db_free_result']($request); |
| 334 | 354 | |
| 335 | 355 | // Fix an oversized starting page (to make sure both pageindexes are properly set). |
| 336 | - if ($context['selected']['start'] >= $context['selected']['num_messages']) |
|
| 337 | - $context['selected']['start'] = $context['selected']['num_messages'] <= $context['messages_per_page'] ? 0 : ($context['selected']['num_messages'] - (($context['selected']['num_messages'] % $context['messages_per_page']) == 0 ? $context['messages_per_page'] : ($context['selected']['num_messages'] % $context['messages_per_page']))); |
|
| 356 | + if ($context['selected']['start'] >= $context['selected']['num_messages']) { |
|
| 357 | + $context['selected']['start'] = $context['selected']['num_messages'] <= $context['messages_per_page'] ? 0 : ($context['selected']['num_messages'] - (($context['selected']['num_messages'] % $context['messages_per_page']) == 0 ? $context['messages_per_page'] : ($context['selected']['num_messages'] % $context['messages_per_page']))); |
|
| 358 | + } |
|
| 338 | 359 | |
| 339 | 360 | // Build a page list of the not-selected topics... |
| 340 | 361 | $context['not_selected']['page_index'] = constructPageIndex($scripturl . '?action=splittopics;sa=selectTopics;subname=' . strtr(urlencode($_REQUEST['subname']), array('%' => '%%')) . ';topic=' . $topic . '.%1$d;start2=' . $context['selected']['start'], $context['not_selected']['start'], $context['not_selected']['num_messages'], $context['messages_per_page'], true); |
@@ -434,11 +455,12 @@ discard block |
||
| 434 | 455 | ); |
| 435 | 456 | |
| 436 | 457 | $context['changes'] = array(); |
| 437 | - foreach ($changes as $change_type => $change_array) |
|
| 438 | - foreach ($change_array as $section => $msg_array) |
|
| 458 | + foreach ($changes as $change_type => $change_array) { |
|
| 459 | + foreach ($change_array as $section => $msg_array) |
|
| 439 | 460 | { |
| 440 | 461 | if (empty($msg_array)) |
| 441 | 462 | continue; |
| 463 | + } |
|
| 442 | 464 | |
| 443 | 465 | foreach ($msg_array as $id_msg) |
| 444 | 466 | { |
@@ -447,8 +469,9 @@ discard block |
||
| 447 | 469 | 'type' => $change_type, |
| 448 | 470 | 'section' => $section, |
| 449 | 471 | ); |
| 450 | - if ($change_type == 'insert') |
|
| 451 | - $context['changes']['insert' . $id_msg]['insert_value'] = $context[$section]['messages'][$id_msg]; |
|
| 472 | + if ($change_type == 'insert') { |
|
| 473 | + $context['changes']['insert' . $id_msg]['insert_value'] = $context[$section]['messages'][$id_msg]; |
|
| 474 | + } |
|
| 452 | 475 | } |
| 453 | 476 | } |
| 454 | 477 | } |
@@ -468,12 +491,14 @@ discard block |
||
| 468 | 491 | checkSession(); |
| 469 | 492 | |
| 470 | 493 | // Default the subject in case it's blank. |
| 471 | - if (!isset($_POST['subname']) || $_POST['subname'] == '') |
|
| 472 | - $_POST['subname'] = $txt['new_topic']; |
|
| 494 | + if (!isset($_POST['subname']) || $_POST['subname'] == '') { |
|
| 495 | + $_POST['subname'] = $txt['new_topic']; |
|
| 496 | + } |
|
| 473 | 497 | |
| 474 | 498 | // You must've selected some messages! Can't split out none! |
| 475 | - if (empty($_SESSION['split_selection'][$topic])) |
|
| 476 | - fatal_lang_error('no_posts_selected', false); |
|
| 499 | + if (empty($_SESSION['split_selection'][$topic])) { |
|
| 500 | + fatal_lang_error('no_posts_selected', false); |
|
| 501 | + } |
|
| 477 | 502 | |
| 478 | 503 | $context['old_topic'] = $topic; |
| 479 | 504 | $context['new_topic'] = splitTopic($topic, $_SESSION['split_selection'][$topic], $_POST['subname']); |
@@ -499,8 +524,9 @@ discard block |
||
| 499 | 524 | global $smcFunc, $txt, $sourcedir; |
| 500 | 525 | |
| 501 | 526 | // Nothing to split? |
| 502 | - if (empty($splitMessages)) |
|
| 503 | - fatal_lang_error('no_posts_selected', false); |
|
| 527 | + if (empty($splitMessages)) { |
|
| 528 | + fatal_lang_error('no_posts_selected', false); |
|
| 529 | + } |
|
| 504 | 530 | |
| 505 | 531 | // Get some board info. |
| 506 | 532 | $request = $smcFunc['db_query']('', ' |
@@ -532,8 +558,9 @@ discard block |
||
| 532 | 558 | ) |
| 533 | 559 | ); |
| 534 | 560 | // You can't select ALL the messages! |
| 535 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 536 | - fatal_lang_error('selected_all_posts', false); |
|
| 561 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 562 | + fatal_lang_error('selected_all_posts', false); |
|
| 563 | + } |
|
| 537 | 564 | |
| 538 | 565 | $split1_first_msg = null; |
| 539 | 566 | $split1_last_msg = null; |
@@ -541,24 +568,27 @@ discard block |
||
| 541 | 568 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 542 | 569 | { |
| 543 | 570 | // Get the right first and last message dependant on approved state... |
| 544 | - if (empty($split1_first_msg) || $row['myid_first_msg'] < $split1_first_msg) |
|
| 545 | - $split1_first_msg = $row['myid_first_msg']; |
|
| 546 | - if (empty($split1_last_msg) || $row['approved']) |
|
| 547 | - $split1_last_msg = $row['myid_last_msg']; |
|
| 571 | + if (empty($split1_first_msg) || $row['myid_first_msg'] < $split1_first_msg) { |
|
| 572 | + $split1_first_msg = $row['myid_first_msg']; |
|
| 573 | + } |
|
| 574 | + if (empty($split1_last_msg) || $row['approved']) { |
|
| 575 | + $split1_last_msg = $row['myid_last_msg']; |
|
| 576 | + } |
|
| 548 | 577 | |
| 549 | 578 | // Get the counts correct... |
| 550 | 579 | if ($row['approved']) |
| 551 | 580 | { |
| 552 | 581 | $split1_replies = $row['message_count'] - 1; |
| 553 | 582 | $split1_unapprovedposts = 0; |
| 554 | - } |
|
| 555 | - else |
|
| 583 | + } else |
|
| 556 | 584 | { |
| 557 | - if (!isset($split1_replies)) |
|
| 558 | - $split1_replies = 0; |
|
| 585 | + if (!isset($split1_replies)) { |
|
| 586 | + $split1_replies = 0; |
|
| 587 | + } |
|
| 559 | 588 | // If the topic isn't approved then num replies must go up by one... as first post wouldn't be counted. |
| 560 | - elseif (!$split1_approved) |
|
| 561 | - $split1_replies++; |
|
| 589 | + elseif (!$split1_approved) { |
|
| 590 | + $split1_replies++; |
|
| 591 | + } |
|
| 562 | 592 | |
| 563 | 593 | $split1_unapprovedposts = $row['message_count']; |
| 564 | 594 | } |
@@ -584,10 +614,12 @@ discard block |
||
| 584 | 614 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 585 | 615 | { |
| 586 | 616 | // As before get the right first and last message dependant on approved state... |
| 587 | - if (empty($split2_first_msg) || $row['myid_first_msg'] < $split2_first_msg) |
|
| 588 | - $split2_first_msg = $row['myid_first_msg']; |
|
| 589 | - if (empty($split2_last_msg) || $row['approved']) |
|
| 590 | - $split2_last_msg = $row['myid_last_msg']; |
|
| 617 | + if (empty($split2_first_msg) || $row['myid_first_msg'] < $split2_first_msg) { |
|
| 618 | + $split2_first_msg = $row['myid_first_msg']; |
|
| 619 | + } |
|
| 620 | + if (empty($split2_last_msg) || $row['approved']) { |
|
| 621 | + $split2_last_msg = $row['myid_last_msg']; |
|
| 622 | + } |
|
| 591 | 623 | |
| 592 | 624 | // Then do the counts again... |
| 593 | 625 | if ($row['approved']) |
@@ -595,18 +627,20 @@ discard block |
||
| 595 | 627 | $split2_approved = true; |
| 596 | 628 | $split2_replies = $row['message_count'] - 1; |
| 597 | 629 | $split2_unapprovedposts = 0; |
| 598 | - } |
|
| 599 | - else |
|
| 630 | + } else |
|
| 600 | 631 | { |
| 601 | 632 | // Should this one be approved?? |
| 602 | - if ($split2_first_msg == $row['myid_first_msg']) |
|
| 603 | - $split2_approved = false; |
|
| 633 | + if ($split2_first_msg == $row['myid_first_msg']) { |
|
| 634 | + $split2_approved = false; |
|
| 635 | + } |
|
| 604 | 636 | |
| 605 | - if (!isset($split2_replies)) |
|
| 606 | - $split2_replies = 0; |
|
| 637 | + if (!isset($split2_replies)) { |
|
| 638 | + $split2_replies = 0; |
|
| 639 | + } |
|
| 607 | 640 | // As before, fix number of replies. |
| 608 | - elseif (!$split2_approved) |
|
| 609 | - $split2_replies++; |
|
| 641 | + elseif (!$split2_approved) { |
|
| 642 | + $split2_replies++; |
|
| 643 | + } |
|
| 610 | 644 | |
| 611 | 645 | $split2_unapprovedposts = $row['message_count']; |
| 612 | 646 | } |
@@ -616,12 +650,14 @@ discard block |
||
| 616 | 650 | $split2_lastMem = getMsgMemberID($split2_last_msg); |
| 617 | 651 | |
| 618 | 652 | // No database changes yet, so let's double check to see if everything makes at least a little sense. |
| 619 | - if ($split1_first_msg <= 0 || $split1_last_msg <= 0 || $split2_first_msg <= 0 || $split2_last_msg <= 0 || $split1_replies < 0 || $split2_replies < 0 || $split1_unapprovedposts < 0 || $split2_unapprovedposts < 0 || !isset($split1_approved) || !isset($split2_approved)) |
|
| 620 | - fatal_lang_error('cant_find_messages'); |
|
| 653 | + if ($split1_first_msg <= 0 || $split1_last_msg <= 0 || $split2_first_msg <= 0 || $split2_last_msg <= 0 || $split1_replies < 0 || $split2_replies < 0 || $split1_unapprovedposts < 0 || $split2_unapprovedposts < 0 || !isset($split1_approved) || !isset($split2_approved)) { |
|
| 654 | + fatal_lang_error('cant_find_messages'); |
|
| 655 | + } |
|
| 621 | 656 | |
| 622 | 657 | // You cannot split off the first message of a topic. |
| 623 | - if ($split1_first_msg > $split2_first_msg) |
|
| 624 | - fatal_lang_error('split_first_post', false); |
|
| 658 | + if ($split1_first_msg > $split2_first_msg) { |
|
| 659 | + fatal_lang_error('split_first_post', false); |
|
| 660 | + } |
|
| 625 | 661 | |
| 626 | 662 | // We're off to insert the new topic! Use 0 for now to avoid UNIQUE errors. |
| 627 | 663 | $smcFunc['db_insert']('', |
@@ -644,14 +680,16 @@ discard block |
||
| 644 | 680 | array('id_topic') |
| 645 | 681 | ); |
| 646 | 682 | $split2_ID_TOPIC = $smcFunc['db_insert_id']('{db_prefix}topics', 'id_topic'); |
| 647 | - if ($split2_ID_TOPIC <= 0) |
|
| 648 | - fatal_lang_error('cant_insert_topic'); |
|
| 683 | + if ($split2_ID_TOPIC <= 0) { |
|
| 684 | + fatal_lang_error('cant_insert_topic'); |
|
| 685 | + } |
|
| 649 | 686 | |
| 650 | 687 | // Move the messages over to the other topic. |
| 651 | 688 | $new_subject = strtr($smcFunc['htmltrim']($smcFunc['htmlspecialchars']($new_subject)), array("\r" => '', "\n" => '', "\t" => '')); |
| 652 | 689 | // Check the subject length. |
| 653 | - if ($smcFunc['strlen']($new_subject) > 100) |
|
| 654 | - $new_subject = $smcFunc['substr']($new_subject, 0, 100); |
|
| 690 | + if ($smcFunc['strlen']($new_subject) > 100) { |
|
| 691 | + $new_subject = $smcFunc['substr']($new_subject, 0, 100); |
|
| 692 | + } |
|
| 655 | 693 | // Valid subject? |
| 656 | 694 | if ($new_subject != '') |
| 657 | 695 | { |
@@ -722,8 +760,8 @@ discard block |
||
| 722 | 760 | ); |
| 723 | 761 | |
| 724 | 762 | // If the new topic isn't approved ensure the first message flags this just in case. |
| 725 | - if (!$split2_approved) |
|
| 726 | - $smcFunc['db_query']('', ' |
|
| 763 | + if (!$split2_approved) { |
|
| 764 | + $smcFunc['db_query']('', ' |
|
| 727 | 765 | UPDATE {db_prefix}messages |
| 728 | 766 | SET approved = {int:approved} |
| 729 | 767 | WHERE id_msg = {int:id_msg} |
@@ -734,6 +772,7 @@ discard block |
||
| 734 | 772 | 'id_topic' => $split2_ID_TOPIC, |
| 735 | 773 | ) |
| 736 | 774 | ); |
| 775 | + } |
|
| 737 | 776 | |
| 738 | 777 | // The board has more topics now (Or more unapproved ones!). |
| 739 | 778 | $smcFunc['db_query']('', ' |
@@ -760,8 +799,9 @@ discard block |
||
| 760 | 799 | if ($smcFunc['db_num_rows']($request) > 0) |
| 761 | 800 | { |
| 762 | 801 | $replaceEntries = array(); |
| 763 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 764 | - $replaceEntries[] = array($row['id_member'], $split2_ID_TOPIC, $row['id_msg'], $row['unwatched']); |
|
| 802 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 803 | + $replaceEntries[] = array($row['id_member'], $split2_ID_TOPIC, $row['id_msg'], $row['unwatched']); |
|
| 804 | + } |
|
| 765 | 805 | |
| 766 | 806 | $smcFunc['db_insert']('ignore', |
| 767 | 807 | '{db_prefix}log_topics', |
@@ -785,8 +825,9 @@ discard block |
||
| 785 | 825 | // If there's a search index that needs updating, update it... |
| 786 | 826 | require_once($sourcedir . '/Search.php'); |
| 787 | 827 | $searchAPI = findSearchAPI(); |
| 788 | - if (is_callable(array($searchAPI, 'topicSplit'))) |
|
| 789 | - $searchAPI->topicSplit($split2_ID_TOPIC, $splitMessages); |
|
| 828 | + if (is_callable(array($searchAPI, 'topicSplit'))) { |
|
| 829 | + $searchAPI->topicSplit($split2_ID_TOPIC, $splitMessages); |
|
| 830 | + } |
|
| 790 | 831 | |
| 791 | 832 | // Return the ID of the newly created topic. |
| 792 | 833 | return $split2_ID_TOPIC; |
@@ -812,12 +853,12 @@ discard block |
||
| 812 | 853 | ); |
| 813 | 854 | |
| 814 | 855 | // ?action=mergetopics;sa=LETSBREAKIT won't work, sorry. |
| 815 | - if (empty($_REQUEST['sa']) || !isset($subActions[$_REQUEST['sa']])) |
|
| 816 | - MergeIndex(); |
|
| 817 | - |
|
| 818 | - else |
|
| 819 | - call_helper($subActions[$_REQUEST['sa']]); |
|
| 820 | -} |
|
| 856 | + if (empty($_REQUEST['sa']) || !isset($subActions[$_REQUEST['sa']])) { |
|
| 857 | + MergeIndex(); |
|
| 858 | + } else { |
|
| 859 | + call_helper($subActions[$_REQUEST['sa']]); |
|
| 860 | + } |
|
| 861 | + } |
|
| 821 | 862 | |
| 822 | 863 | /** |
| 823 | 864 | * allows to pick a topic to merge the current topic with. |
@@ -831,8 +872,9 @@ discard block |
||
| 831 | 872 | global $txt, $board, $context, $smcFunc, $sourcedir; |
| 832 | 873 | global $scripturl, $modSettings; |
| 833 | 874 | |
| 834 | - if (!isset($_GET['from'])) |
|
| 835 | - fatal_lang_error('no_access', false); |
|
| 875 | + if (!isset($_GET['from'])) { |
|
| 876 | + fatal_lang_error('no_access', false); |
|
| 877 | + } |
|
| 836 | 878 | $_GET['from'] = (int) $_GET['from']; |
| 837 | 879 | |
| 838 | 880 | $_REQUEST['targetboard'] = isset($_REQUEST['targetboard']) ? (int) $_REQUEST['targetboard'] : $board; |
@@ -843,9 +885,9 @@ discard block |
||
| 843 | 885 | { |
| 844 | 886 | $can_approve_boards = boardsAllowedTo('approve_posts'); |
| 845 | 887 | $onlyApproved = $can_approve_boards !== array(0) && !in_array($_REQUEST['targetboard'], $can_approve_boards); |
| 888 | + } else { |
|
| 889 | + $onlyApproved = false; |
|
| 846 | 890 | } |
| 847 | - else |
|
| 848 | - $onlyApproved = false; |
|
| 849 | 891 | |
| 850 | 892 | // How many topics are on this board? (used for paging.) |
| 851 | 893 | $request = $smcFunc['db_query']('', ' |
@@ -879,8 +921,9 @@ discard block |
||
| 879 | 921 | 'is_approved' => 1, |
| 880 | 922 | ) |
| 881 | 923 | ); |
| 882 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 883 | - fatal_lang_error('no_board'); |
|
| 924 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 925 | + fatal_lang_error('no_board'); |
|
| 926 | + } |
|
| 884 | 927 | list ($subject) = $smcFunc['db_fetch_row']($request); |
| 885 | 928 | $smcFunc['db_free_result']($request); |
| 886 | 929 | |
@@ -893,8 +936,9 @@ discard block |
||
| 893 | 936 | // Check which boards you have merge permissions on. |
| 894 | 937 | $merge_boards = boardsAllowedTo('merge_any'); |
| 895 | 938 | |
| 896 | - if (empty($merge_boards)) |
|
| 897 | - fatal_lang_error('cannot_merge_any', 'user'); |
|
| 939 | + if (empty($merge_boards)) { |
|
| 940 | + fatal_lang_error('cannot_merge_any', 'user'); |
|
| 941 | + } |
|
| 898 | 942 | |
| 899 | 943 | // No sense in loading this if you can only merge on this board |
| 900 | 944 | if (count($merge_boards) > 1 || in_array(0, $merge_boards)) |
@@ -908,8 +952,9 @@ discard block |
||
| 908 | 952 | ); |
| 909 | 953 | |
| 910 | 954 | // Only include these boards in the list (0 means you're an admin') |
| 911 | - if (!in_array(0, $merge_boards)) |
|
| 912 | - $options['included_boards'] = $merge_boards; |
|
| 955 | + if (!in_array(0, $merge_boards)) { |
|
| 956 | + $options['included_boards'] = $merge_boards; |
|
| 957 | + } |
|
| 913 | 958 | |
| 914 | 959 | $context['merge_categories'] = getBoardList($options); |
| 915 | 960 | } |
@@ -955,8 +1000,9 @@ discard block |
||
| 955 | 1000 | } |
| 956 | 1001 | $smcFunc['db_free_result']($request); |
| 957 | 1002 | |
| 958 | - if (empty($context['topics']) && count($merge_boards) <= 1 && !in_array(0, $merge_boards)) |
|
| 959 | - fatal_lang_error('merge_need_more_topics'); |
|
| 1003 | + if (empty($context['topics']) && count($merge_boards) <= 1 && !in_array(0, $merge_boards)) { |
|
| 1004 | + fatal_lang_error('merge_need_more_topics'); |
|
| 1005 | + } |
|
| 960 | 1006 | |
| 961 | 1007 | $context['sub_template'] = 'merge'; |
| 962 | 1008 | } |
@@ -986,24 +1032,29 @@ discard block |
||
| 986 | 1032 | checkSession('request'); |
| 987 | 1033 | |
| 988 | 1034 | // Handle URLs from MergeIndex. |
| 989 | - if (!empty($_GET['from']) && !empty($_GET['to'])) |
|
| 990 | - $topics = array((int) $_GET['from'], (int) $_GET['to']); |
|
| 1035 | + if (!empty($_GET['from']) && !empty($_GET['to'])) { |
|
| 1036 | + $topics = array((int) $_GET['from'], (int) $_GET['to']); |
|
| 1037 | + } |
|
| 991 | 1038 | |
| 992 | 1039 | // If we came from a form, the topic IDs came by post. |
| 993 | - if (!empty($_POST['topics']) && is_array($_POST['topics'])) |
|
| 994 | - $topics = $_POST['topics']; |
|
| 1040 | + if (!empty($_POST['topics']) && is_array($_POST['topics'])) { |
|
| 1041 | + $topics = $_POST['topics']; |
|
| 1042 | + } |
|
| 995 | 1043 | |
| 996 | 1044 | // There's nothing to merge with just one topic... |
| 997 | - if (empty($topics) || !is_array($topics) || count($topics) == 1) |
|
| 998 | - fatal_lang_error('merge_need_more_topics'); |
|
| 1045 | + if (empty($topics) || !is_array($topics) || count($topics) == 1) { |
|
| 1046 | + fatal_lang_error('merge_need_more_topics'); |
|
| 1047 | + } |
|
| 999 | 1048 | |
| 1000 | 1049 | // Make sure every topic is numeric, or some nasty things could be done with the DB. |
| 1001 | - foreach ($topics as $id => $topic) |
|
| 1002 | - $topics[$id] = (int) $topic; |
|
| 1050 | + foreach ($topics as $id => $topic) { |
|
| 1051 | + $topics[$id] = (int) $topic; |
|
| 1052 | + } |
|
| 1003 | 1053 | |
| 1004 | 1054 | // Joy of all joys, make sure they're not messing about with unapproved topics they can't see :P |
| 1005 | - if ($modSettings['postmod_active']) |
|
| 1006 | - $can_approve_boards = boardsAllowedTo('approve_posts'); |
|
| 1055 | + if ($modSettings['postmod_active']) { |
|
| 1056 | + $can_approve_boards = boardsAllowedTo('approve_posts'); |
|
| 1057 | + } |
|
| 1007 | 1058 | |
| 1008 | 1059 | // Get info about the topics and polls that will be merged. |
| 1009 | 1060 | $request = $smcFunc['db_query']('', ' |
@@ -1024,8 +1075,9 @@ discard block |
||
| 1024 | 1075 | 'limit' => count($topics), |
| 1025 | 1076 | ) |
| 1026 | 1077 | ); |
| 1027 | - if ($smcFunc['db_num_rows']($request) < 2) |
|
| 1028 | - fatal_lang_error('no_topic_id'); |
|
| 1078 | + if ($smcFunc['db_num_rows']($request) < 2) { |
|
| 1079 | + fatal_lang_error('no_topic_id'); |
|
| 1080 | + } |
|
| 1029 | 1081 | $num_views = 0; |
| 1030 | 1082 | $is_sticky = 0; |
| 1031 | 1083 | $boardTotals = array(); |
@@ -1038,34 +1090,38 @@ discard block |
||
| 1038 | 1090 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1039 | 1091 | { |
| 1040 | 1092 | // Sorry, redirection topics can't be merged |
| 1041 | - if (!empty($row['id_redirect_topic'])) |
|
| 1042 | - fatal_lang_error('cannot_merge_redirect', false); |
|
| 1093 | + if (!empty($row['id_redirect_topic'])) { |
|
| 1094 | + fatal_lang_error('cannot_merge_redirect', false); |
|
| 1095 | + } |
|
| 1043 | 1096 | |
| 1044 | 1097 | // Make a note for the board counts... |
| 1045 | - if (!isset($boardTotals[$row['id_board']])) |
|
| 1046 | - $boardTotals[$row['id_board']] = array( |
|
| 1098 | + if (!isset($boardTotals[$row['id_board']])) { |
|
| 1099 | + $boardTotals[$row['id_board']] = array( |
|
| 1047 | 1100 | 'posts' => 0, |
| 1048 | 1101 | 'topics' => 0, |
| 1049 | 1102 | 'unapproved_posts' => 0, |
| 1050 | 1103 | 'unapproved_topics' => 0 |
| 1051 | 1104 | ); |
| 1105 | + } |
|
| 1052 | 1106 | |
| 1053 | 1107 | // We can't see unapproved topics here? |
| 1054 | 1108 | if ($modSettings['postmod_active'] && !$row['approved'] && $can_approve_boards != array(0) && in_array($row['id_board'], $can_approve_boards)) |
| 1055 | 1109 | { |
| 1056 | 1110 | unset($topics[$row['id_topic']]); // If we can't see it, we should not merge it and not adjust counts! Instead skip it. |
| 1057 | 1111 | continue; |
| 1058 | - }elseif (!$row['approved']) |
|
| 1059 | - $boardTotals[$row['id_board']]['unapproved_topics']++; |
|
| 1060 | - else |
|
| 1061 | - $boardTotals[$row['id_board']]['topics']++; |
|
| 1112 | + } elseif (!$row['approved']) { |
|
| 1113 | + $boardTotals[$row['id_board']]['unapproved_topics']++; |
|
| 1114 | + } else { |
|
| 1115 | + $boardTotals[$row['id_board']]['topics']++; |
|
| 1116 | + } |
|
| 1062 | 1117 | |
| 1063 | 1118 | $boardTotals[$row['id_board']]['unapproved_posts'] += $row['unapproved_posts']; |
| 1064 | 1119 | $boardTotals[$row['id_board']]['posts'] += $row['num_replies'] + ($row['approved'] ? 1 : 0); |
| 1065 | 1120 | |
| 1066 | 1121 | // In the case of making a redirect, the topic count goes up by one due to the redirect topic. |
| 1067 | - if (isset($_POST['postRedirect'])) |
|
| 1068 | - $boardTotals[$row['id_board']]['topics']--; |
|
| 1122 | + if (isset($_POST['postRedirect'])) { |
|
| 1123 | + $boardTotals[$row['id_board']]['topics']--; |
|
| 1124 | + } |
|
| 1069 | 1125 | |
| 1070 | 1126 | $topic_data[$row['id_topic']] = array( |
| 1071 | 1127 | 'id' => $row['id_topic'], |
@@ -1091,11 +1147,13 @@ discard block |
||
| 1091 | 1147 | $boards[] = $row['id_board']; |
| 1092 | 1148 | |
| 1093 | 1149 | // If there's no poll, id_poll == 0... |
| 1094 | - if ($row['id_poll'] > 0) |
|
| 1095 | - $polls[] = $row['id_poll']; |
|
| 1150 | + if ($row['id_poll'] > 0) { |
|
| 1151 | + $polls[] = $row['id_poll']; |
|
| 1152 | + } |
|
| 1096 | 1153 | // Store the id_topic with the lowest id_first_msg. |
| 1097 | - if (empty($firstTopic)) |
|
| 1098 | - $firstTopic = $row['id_topic']; |
|
| 1154 | + if (empty($firstTopic)) { |
|
| 1155 | + $firstTopic = $row['id_topic']; |
|
| 1156 | + } |
|
| 1099 | 1157 | |
| 1100 | 1158 | // Lowest topic id gets selected as surviving topic id. We need to store this board so we can adjust the topic count (This one will not have a redirect topic) |
| 1101 | 1159 | if($row['id_topic'] < $lowestTopicId || empty($lowestTopicId) ) |
@@ -1109,11 +1167,13 @@ discard block |
||
| 1109 | 1167 | $smcFunc['db_free_result']($request); |
| 1110 | 1168 | |
| 1111 | 1169 | // If we didn't get any topics then they've been messing with unapproved stuff. |
| 1112 | - if (empty($topic_data)) |
|
| 1113 | - fatal_lang_error('no_topic_id'); |
|
| 1170 | + if (empty($topic_data)) { |
|
| 1171 | + fatal_lang_error('no_topic_id'); |
|
| 1172 | + } |
|
| 1114 | 1173 | |
| 1115 | - if (isset($_POST['postRedirect']) && !empty($lowestTopicBoard)) |
|
| 1116 | - $boardTotals[$lowestTopicBoard]['topics']++; |
|
| 1174 | + if (isset($_POST['postRedirect']) && !empty($lowestTopicBoard)) { |
|
| 1175 | + $boardTotals[$lowestTopicBoard]['topics']++; |
|
| 1176 | + } |
|
| 1117 | 1177 | |
| 1118 | 1178 | // Will this be approved? |
| 1119 | 1179 | $context['is_approved'] = $topic_data[$firstTopic]['approved']; |
@@ -1129,8 +1189,9 @@ discard block |
||
| 1129 | 1189 | |
| 1130 | 1190 | // Get the boards a user is allowed to merge in. |
| 1131 | 1191 | $merge_boards = boardsAllowedTo('merge_any'); |
| 1132 | - if (empty($merge_boards)) |
|
| 1133 | - fatal_lang_error('cannot_merge_any', 'user'); |
|
| 1192 | + if (empty($merge_boards)) { |
|
| 1193 | + fatal_lang_error('cannot_merge_any', 'user'); |
|
| 1194 | + } |
|
| 1134 | 1195 | |
| 1135 | 1196 | // Make sure they can see all boards.... |
| 1136 | 1197 | $request = $smcFunc['db_query']('', ' |
@@ -1147,8 +1208,9 @@ discard block |
||
| 1147 | 1208 | ) |
| 1148 | 1209 | ); |
| 1149 | 1210 | // If the number of boards that's in the output isn't exactly the same as we've put in there, you're in trouble. |
| 1150 | - if ($smcFunc['db_num_rows']($request) != count($boards)) |
|
| 1151 | - fatal_lang_error('no_board'); |
|
| 1211 | + if ($smcFunc['db_num_rows']($request) != count($boards)) { |
|
| 1212 | + fatal_lang_error('no_board'); |
|
| 1213 | + } |
|
| 1152 | 1214 | $smcFunc['db_free_result']($request); |
| 1153 | 1215 | |
| 1154 | 1216 | if (empty($_REQUEST['sa']) || $_REQUEST['sa'] == 'options') |
@@ -1167,8 +1229,8 @@ discard block |
||
| 1167 | 1229 | 'limit' => count($polls), |
| 1168 | 1230 | ) |
| 1169 | 1231 | ); |
| 1170 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1171 | - $context['polls'][] = array( |
|
| 1232 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1233 | + $context['polls'][] = array( |
|
| 1172 | 1234 | 'id' => $row['id_poll'], |
| 1173 | 1235 | 'topic' => array( |
| 1174 | 1236 | 'id' => $row['id_topic'], |
@@ -1177,6 +1239,7 @@ discard block |
||
| 1177 | 1239 | 'question' => $row['question'], |
| 1178 | 1240 | 'selected' => $row['id_topic'] == $firstTopic |
| 1179 | 1241 | ); |
| 1242 | + } |
|
| 1180 | 1243 | $smcFunc['db_free_result']($request); |
| 1181 | 1244 | } |
| 1182 | 1245 | if (count($boards) > 1) |
@@ -1192,18 +1255,20 @@ discard block |
||
| 1192 | 1255 | 'limit' => count($boards), |
| 1193 | 1256 | ) |
| 1194 | 1257 | ); |
| 1195 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1196 | - $context['boards'][] = array( |
|
| 1258 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1259 | + $context['boards'][] = array( |
|
| 1197 | 1260 | 'id' => $row['id_board'], |
| 1198 | 1261 | 'name' => $row['name'], |
| 1199 | 1262 | 'selected' => $row['id_board'] == $topic_data[$firstTopic]['board'] |
| 1200 | 1263 | ); |
| 1264 | + } |
|
| 1201 | 1265 | $smcFunc['db_free_result']($request); |
| 1202 | 1266 | } |
| 1203 | 1267 | |
| 1204 | 1268 | $context['topics'] = $topic_data; |
| 1205 | - foreach ($topic_data as $id => $topic) |
|
| 1206 | - $context['topics'][$id]['selected'] = $topic['id'] == $firstTopic; |
|
| 1269 | + foreach ($topic_data as $id => $topic) { |
|
| 1270 | + $context['topics'][$id]['selected'] = $topic['id'] == $firstTopic; |
|
| 1271 | + } |
|
| 1207 | 1272 | |
| 1208 | 1273 | $context['page_title'] = $txt['merge']; |
| 1209 | 1274 | $context['sub_template'] = 'merge_extra_options'; |
@@ -1212,13 +1277,15 @@ discard block |
||
| 1212 | 1277 | |
| 1213 | 1278 | // Determine target board. |
| 1214 | 1279 | $target_board = count($boards) > 1 ? (int) $_REQUEST['board'] : $boards[0]; |
| 1215 | - if (!in_array($target_board, $boards)) |
|
| 1216 | - fatal_lang_error('no_board'); |
|
| 1280 | + if (!in_array($target_board, $boards)) { |
|
| 1281 | + fatal_lang_error('no_board'); |
|
| 1282 | + } |
|
| 1217 | 1283 | |
| 1218 | 1284 | // Determine which poll will survive and which polls won't. |
| 1219 | 1285 | $target_poll = count($polls) > 1 ? (int) $_POST['poll'] : (count($polls) == 1 ? $polls[0] : 0); |
| 1220 | - if ($target_poll > 0 && !in_array($target_poll, $polls)) |
|
| 1221 | - fatal_lang_error('no_access', false); |
|
| 1286 | + if ($target_poll > 0 && !in_array($target_poll, $polls)) { |
|
| 1287 | + fatal_lang_error('no_access', false); |
|
| 1288 | + } |
|
| 1222 | 1289 | $deleted_polls = empty($target_poll) ? $polls : array_diff($polls, array($target_poll)); |
| 1223 | 1290 | |
| 1224 | 1291 | // Determine the subject of the newly merged topic - was a custom subject specified? |
@@ -1226,19 +1293,23 @@ discard block |
||
| 1226 | 1293 | { |
| 1227 | 1294 | $target_subject = strtr($smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['custom_subject'])), array("\r" => '', "\n" => '', "\t" => '')); |
| 1228 | 1295 | // Keep checking the length. |
| 1229 | - if ($smcFunc['strlen']($target_subject) > 100) |
|
| 1230 | - $target_subject = $smcFunc['substr']($target_subject, 0, 100); |
|
| 1296 | + if ($smcFunc['strlen']($target_subject) > 100) { |
|
| 1297 | + $target_subject = $smcFunc['substr']($target_subject, 0, 100); |
|
| 1298 | + } |
|
| 1231 | 1299 | |
| 1232 | 1300 | // Nothing left - odd but pick the first topics subject. |
| 1233 | - if ($target_subject == '') |
|
| 1234 | - $target_subject = $topic_data[$firstTopic]['subject']; |
|
| 1301 | + if ($target_subject == '') { |
|
| 1302 | + $target_subject = $topic_data[$firstTopic]['subject']; |
|
| 1303 | + } |
|
| 1235 | 1304 | } |
| 1236 | 1305 | // A subject was selected from the list. |
| 1237 | - elseif (!empty($topic_data[(int) $_POST['subject']]['subject'])) |
|
| 1238 | - $target_subject = $topic_data[(int) $_POST['subject']]['subject']; |
|
| 1306 | + elseif (!empty($topic_data[(int) $_POST['subject']]['subject'])) { |
|
| 1307 | + $target_subject = $topic_data[(int) $_POST['subject']]['subject']; |
|
| 1308 | + } |
|
| 1239 | 1309 | // Nothing worked? Just take the subject of the first message. |
| 1240 | - else |
|
| 1241 | - $target_subject = $topic_data[$firstTopic]['subject']; |
|
| 1310 | + else { |
|
| 1311 | + $target_subject = $topic_data[$firstTopic]['subject']; |
|
| 1312 | + } |
|
| 1242 | 1313 | |
| 1243 | 1314 | // Get the first and last message and the number of messages.... |
| 1244 | 1315 | $request = $smcFunc['db_query']('', ' |
@@ -1264,15 +1335,13 @@ discard block |
||
| 1264 | 1335 | { |
| 1265 | 1336 | $num_replies = $row['message_count'] - 1; |
| 1266 | 1337 | $num_unapproved = 0; |
| 1267 | - } |
|
| 1268 | - else |
|
| 1338 | + } else |
|
| 1269 | 1339 | { |
| 1270 | 1340 | $topic_approved = 0; |
| 1271 | 1341 | $num_replies = 0; |
| 1272 | 1342 | $num_unapproved = $row['message_count']; |
| 1273 | 1343 | } |
| 1274 | - } |
|
| 1275 | - else |
|
| 1344 | + } else |
|
| 1276 | 1345 | { |
| 1277 | 1346 | // If this has a lower first_msg then the first post is not approved and hence the number of replies was wrong! |
| 1278 | 1347 | if ($first_msg > $row['first_msg']) |
@@ -1318,8 +1387,9 @@ discard block |
||
| 1318 | 1387 | list ($member_started) = $smcFunc['db_fetch_row']($request); |
| 1319 | 1388 | list ($member_updated) = $smcFunc['db_fetch_row']($request); |
| 1320 | 1389 | // First and last message are the same, so only row was returned. |
| 1321 | - if ($member_updated === NULL) |
|
| 1322 | - $member_updated = $member_started; |
|
| 1390 | + if ($member_updated === NULL) { |
|
| 1391 | + $member_updated = $member_started; |
|
| 1392 | + } |
|
| 1323 | 1393 | |
| 1324 | 1394 | $smcFunc['db_free_result']($request); |
| 1325 | 1395 | |
@@ -1332,8 +1402,9 @@ discard block |
||
| 1332 | 1402 | array( |
| 1333 | 1403 | 'topic_list' => $topics, |
| 1334 | 1404 | )); |
| 1335 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
| 1336 | - $affected_msgs[] = $row[0]; |
|
| 1405 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
| 1406 | + $affected_msgs[] = $row[0]; |
|
| 1407 | + } |
|
| 1337 | 1408 | $smcFunc['db_free_result']($request); |
| 1338 | 1409 | |
| 1339 | 1410 | // Assign the first topic ID to be the merged topic. |
@@ -1411,9 +1482,9 @@ discard block |
||
| 1411 | 1482 | // Grab the response prefix (like 'Re: ') in the default forum language. |
| 1412 | 1483 | if (!isset($context['response_prefix']) && !($context['response_prefix'] = cache_get_data('response_prefix'))) |
| 1413 | 1484 | { |
| 1414 | - if ($language === $user_info['language']) |
|
| 1415 | - $context['response_prefix'] = $txt['response_prefix']; |
|
| 1416 | - else |
|
| 1485 | + if ($language === $user_info['language']) { |
|
| 1486 | + $context['response_prefix'] = $txt['response_prefix']; |
|
| 1487 | + } else |
|
| 1417 | 1488 | { |
| 1418 | 1489 | loadLanguage('index', $language, false); |
| 1419 | 1490 | $context['response_prefix'] = $txt['response_prefix']; |
@@ -1493,8 +1564,9 @@ discard block |
||
| 1493 | 1564 | if ($smcFunc['db_num_rows']($request) > 0) |
| 1494 | 1565 | { |
| 1495 | 1566 | $replaceEntries = array(); |
| 1496 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1497 | - $replaceEntries[] = array($row['id_member'], $id_topic, $row['new_id_msg'], $row['unwatched']); |
|
| 1567 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1568 | + $replaceEntries[] = array($row['id_member'], $id_topic, $row['new_id_msg'], $row['unwatched']); |
|
| 1569 | + } |
|
| 1498 | 1570 | |
| 1499 | 1571 | $smcFunc['db_insert']('replace', |
| 1500 | 1572 | '{db_prefix}log_topics', |
@@ -1531,8 +1603,9 @@ discard block |
||
| 1531 | 1603 | if ($smcFunc['db_num_rows']($request) > 0) |
| 1532 | 1604 | { |
| 1533 | 1605 | $replaceEntries = array(); |
| 1534 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1535 | - $replaceEntries[] = array($row['id_member'], $id_topic, 0, $row['sent']); |
|
| 1606 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1607 | + $replaceEntries[] = array($row['id_member'], $id_topic, 0, $row['sent']); |
|
| 1608 | + } |
|
| 1536 | 1609 | |
| 1537 | 1610 | $smcFunc['db_insert']('replace', |
| 1538 | 1611 | '{db_prefix}log_notify', |
@@ -1707,8 +1780,9 @@ discard block |
||
| 1707 | 1780 | // If there's a search index that needs updating, update it... |
| 1708 | 1781 | require_once($sourcedir . '/Search.php'); |
| 1709 | 1782 | $searchAPI = findSearchAPI(); |
| 1710 | - if (is_callable(array($searchAPI, 'topicMerge'))) |
|
| 1711 | - $searchAPI->topicMerge($id_topic, $topics, $affected_msgs, empty($_POST['enforce_subject']) ? null : array($context['response_prefix'], $target_subject)); |
|
| 1783 | + if (is_callable(array($searchAPI, 'topicMerge'))) { |
|
| 1784 | + $searchAPI->topicMerge($id_topic, $topics, $affected_msgs, empty($_POST['enforce_subject']) ? null : array($context['response_prefix'], $target_subject)); |
|
| 1785 | + } |
|
| 1712 | 1786 | |
| 1713 | 1787 | // Send them to the all done page. |
| 1714 | 1788 | redirectexit('action=mergetopics;sa=done;to=' . $id_topic . ';targetboard=' . $target_board); |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 3 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * Retrieve a list and several other statistics of the users currently online. |
@@ -45,12 +46,14 @@ discard block |
||
| 45 | 46 | } |
| 46 | 47 | |
| 47 | 48 | // Not allowed sort method? Bang! Error! |
| 48 | - elseif (!in_array($membersOnlineOptions['sort'], $allowed_sort_options)) |
|
| 49 | - trigger_error('Sort method for getMembersOnlineStats() function is not allowed', E_USER_NOTICE); |
|
| 49 | + elseif (!in_array($membersOnlineOptions['sort'], $allowed_sort_options)) { |
|
| 50 | + trigger_error('Sort method for getMembersOnlineStats() function is not allowed', E_USER_NOTICE); |
|
| 51 | + } |
|
| 50 | 52 | |
| 51 | 53 | // Get it from the cache and send it back. |
| 52 | - if (($temp = cache_get_data('membersOnlineStats-' . $membersOnlineOptions['sort'], 240)) !== null) |
|
| 53 | - return $temp; |
|
| 54 | + if (($temp = cache_get_data('membersOnlineStats-' . $membersOnlineOptions['sort'], 240)) !== null) { |
|
| 55 | + return $temp; |
|
| 56 | + } |
|
| 54 | 57 | |
| 55 | 58 | // Initialize the array that'll be returned later on. |
| 56 | 59 | $membersOnlineStats = array( |
@@ -67,8 +70,9 @@ discard block |
||
| 67 | 70 | // Get any spiders if enabled. |
| 68 | 71 | $spiders = array(); |
| 69 | 72 | $spider_finds = array(); |
| 70 | - if (!empty($modSettings['show_spider_online']) && ($modSettings['show_spider_online'] < 3 || allowedTo('admin_forum')) && !empty($modSettings['spider_name_cache'])) |
|
| 71 | - $spiders = smf_json_decode($modSettings['spider_name_cache'], true); |
|
| 73 | + if (!empty($modSettings['show_spider_online']) && ($modSettings['show_spider_online'] < 3 || allowedTo('admin_forum')) && !empty($modSettings['spider_name_cache'])) { |
|
| 74 | + $spiders = smf_json_decode($modSettings['spider_name_cache'], true); |
|
| 75 | + } |
|
| 72 | 76 | |
| 73 | 77 | // Load the users online right now. |
| 74 | 78 | $request = $smcFunc['db_query']('', ' |
@@ -96,9 +100,7 @@ discard block |
||
| 96 | 100 | $membersOnlineStats['num_guests']++; |
| 97 | 101 | |
| 98 | 102 | continue; |
| 99 | - } |
|
| 100 | - |
|
| 101 | - elseif (empty($row['show_online']) && empty($membersOnlineOptions['show_hidden'])) |
|
| 103 | + } elseif (empty($row['show_online']) && empty($membersOnlineOptions['show_hidden'])) |
|
| 102 | 104 | { |
| 103 | 105 | // Just increase the stats and don't add this hidden user to any list. |
| 104 | 106 | $membersOnlineStats['num_users_hidden']++; |
@@ -106,10 +108,11 @@ discard block |
||
| 106 | 108 | } |
| 107 | 109 | |
| 108 | 110 | // Some basic color coding... |
| 109 | - if (!empty($row['online_color'])) |
|
| 110 | - $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>'; |
|
| 111 | - else |
|
| 112 | - $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
| 111 | + if (!empty($row['online_color'])) { |
|
| 112 | + $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>'; |
|
| 113 | + } else { |
|
| 114 | + $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
| 115 | + } |
|
| 113 | 116 | |
| 114 | 117 | // Buddies get counted and highlighted. |
| 115 | 118 | $is_buddy = in_array($row['id_member'], $user_info['buddies']); |
@@ -136,12 +139,13 @@ discard block |
||
| 136 | 139 | $membersOnlineStats['list_users_online'][$row[$membersOnlineOptions['sort']] . '_' . $row['member_name']] = empty($row['show_online']) ? '<em>' . $link . '</em>' : $link; |
| 137 | 140 | |
| 138 | 141 | // Store all distinct (primary) membergroups that are shown. |
| 139 | - if (!isset($membersOnlineStats['online_groups'][$row['id_group']])) |
|
| 140 | - $membersOnlineStats['online_groups'][$row['id_group']] = array( |
|
| 142 | + if (!isset($membersOnlineStats['online_groups'][$row['id_group']])) { |
|
| 143 | + $membersOnlineStats['online_groups'][$row['id_group']] = array( |
|
| 141 | 144 | 'id' => $row['id_group'], |
| 142 | 145 | 'name' => $row['group_name'], |
| 143 | 146 | 'color' => $row['online_color'] |
| 144 | 147 | ); |
| 148 | + } |
|
| 145 | 149 | } |
| 146 | 150 | $smcFunc['db_free_result']($request); |
| 147 | 151 | |
@@ -204,11 +208,12 @@ discard block |
||
| 204 | 208 | $settingsToUpdate = array(); |
| 205 | 209 | |
| 206 | 210 | // More members on now than ever were? Update it! |
| 207 | - if (!isset($modSettings['mostOnline']) || $total_users_online >= $modSettings['mostOnline']) |
|
| 208 | - $settingsToUpdate = array( |
|
| 211 | + if (!isset($modSettings['mostOnline']) || $total_users_online >= $modSettings['mostOnline']) { |
|
| 212 | + $settingsToUpdate = array( |
|
| 209 | 213 | 'mostOnline' => $total_users_online, |
| 210 | 214 | 'mostDate' => time() |
| 211 | 215 | ); |
| 216 | + } |
|
| 212 | 217 | |
| 213 | 218 | $date = strftime('%Y-%m-%d', forum_time(false)); |
| 214 | 219 | |
@@ -240,8 +245,9 @@ discard block |
||
| 240 | 245 | { |
| 241 | 246 | list ($modSettings['mostOnlineToday']) = $smcFunc['db_fetch_row']($request); |
| 242 | 247 | |
| 243 | - if ($total_users_online > $modSettings['mostOnlineToday']) |
|
| 244 | - trackStats(array('most_on' => $total_users_online)); |
|
| 248 | + if ($total_users_online > $modSettings['mostOnlineToday']) { |
|
| 249 | + trackStats(array('most_on' => $total_users_online)); |
|
| 250 | + } |
|
| 245 | 251 | |
| 246 | 252 | $total_users_online = max($total_users_online, $modSettings['mostOnlineToday']); |
| 247 | 253 | } |
@@ -258,8 +264,9 @@ discard block |
||
| 258 | 264 | $settingsToUpdate['mostOnlineToday'] = $total_users_online; |
| 259 | 265 | } |
| 260 | 266 | |
| 261 | - if (!empty($settingsToUpdate)) |
|
| 262 | - updateSettings($settingsToUpdate); |
|
| 263 | -} |
|
| 267 | + if (!empty($settingsToUpdate)) { |
|
| 268 | + updateSettings($settingsToUpdate); |
|
| 269 | + } |
|
| 270 | + } |
|
| 264 | 271 | |
| 265 | 272 | ?> |
| 266 | 273 | \ No newline at end of file |
@@ -11,8 +11,9 @@ discard block |
||
| 11 | 11 | * @version 2.1 Beta 3 |
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | -if (!defined('SMF')) |
|
| 14 | +if (!defined('SMF')) { |
|
| 15 | 15 | die('No direct access...'); |
| 16 | +} |
|
| 16 | 17 | |
| 17 | 18 | /** |
| 18 | 19 | * Fetches the list of preferences (or a single/subset of preferences) for |
@@ -30,8 +31,9 @@ discard block |
||
| 30 | 31 | // We want this as an array whether it is or not. |
| 31 | 32 | $members = is_array($members) ? $members : (array) $members; |
| 32 | 33 | |
| 33 | - if (!empty($prefs)) |
|
| 34 | - $prefs = is_array($prefs) ? $prefs : (array) $prefs; |
|
| 34 | + if (!empty($prefs)) { |
|
| 35 | + $prefs = is_array($prefs) ? $prefs : (array) $prefs; |
|
| 36 | + } |
|
| 35 | 37 | |
| 36 | 38 | $result = array(); |
| 37 | 39 | |
@@ -56,9 +58,10 @@ discard block |
||
| 56 | 58 | // We may want to keep the default values separate from a given user's. Or we might not. |
| 57 | 59 | if ($process_default && isset($result[0])) |
| 58 | 60 | { |
| 59 | - foreach ($members as $member) |
|
| 60 | - if (!isset($result[$member])) |
|
| 61 | + foreach ($members as $member) { |
|
| 62 | + if (!isset($result[$member])) |
|
| 61 | 63 | $result[$member] = $result[0]; |
| 64 | + } |
|
| 62 | 65 | |
| 63 | 66 | unset ($result[0]); |
| 64 | 67 | } |
@@ -76,12 +79,14 @@ discard block |
||
| 76 | 79 | { |
| 77 | 80 | global $smcFunc; |
| 78 | 81 | |
| 79 | - if (empty($prefs) || !is_int($memID)) |
|
| 80 | - return; |
|
| 82 | + if (empty($prefs) || !is_int($memID)) { |
|
| 83 | + return; |
|
| 84 | + } |
|
| 81 | 85 | |
| 82 | 86 | $update_rows = array(); |
| 83 | - foreach ($prefs as $k => $v) |
|
| 84 | - $update_rows[] = array($memID, $k, $v); |
|
| 87 | + foreach ($prefs as $k => $v) { |
|
| 88 | + $update_rows[] = array($memID, $k, $v); |
|
| 89 | + } |
|
| 85 | 90 | |
| 86 | 91 | $smcFunc['db_insert']('replace', |
| 87 | 92 | '{db_prefix}user_alerts_prefs', |
@@ -101,8 +106,9 @@ discard block |
||
| 101 | 106 | { |
| 102 | 107 | global $smcFunc; |
| 103 | 108 | |
| 104 | - if (empty($prefs) || empty($memID)) |
|
| 105 | - return; |
|
| 109 | + if (empty($prefs) || empty($memID)) { |
|
| 110 | + return; |
|
| 111 | + } |
|
| 106 | 112 | |
| 107 | 113 | $smcFunc['db_query']('', ' |
| 108 | 114 | DELETE FROM {db_prefix}user_alerts_prefs |