@@ -25,7 +25,8 @@ discard block |
||
| 25 | 25 | # requirements (there can be none), but merely suggestions. |
| 26 | 26 | # |
| 27 | 27 | |
| 28 | -class PasswordHash { |
|
| 28 | +class PasswordHash |
|
| 29 | +{ |
|
| 29 | 30 | var $itoa64; |
| 30 | 31 | var $iteration_count_log2; |
| 31 | 32 | var $portable_hashes; |
@@ -36,7 +37,9 @@ discard block |
||
| 36 | 37 | $this->itoa64 = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'; |
| 37 | 38 | |
| 38 | 39 | if ($iteration_count_log2 < 4 || $iteration_count_log2 > 31) |
| 39 | - $iteration_count_log2 = 8; |
|
| 40 | + { |
|
| 41 | + $iteration_count_log2 = 8; |
|
| 42 | + } |
|
| 40 | 43 | $this->iteration_count_log2 = $iteration_count_log2; |
| 41 | 44 | |
| 42 | 45 | $this->portable_hashes = $portable_hashes; |
@@ -49,25 +52,30 @@ discard block |
||
| 49 | 52 | $output = ''; |
| 50 | 53 | |
| 51 | 54 | // PHP >= 7 |
| 52 | - if (is_callable('random_bytes')) { |
|
| 55 | + if (is_callable('random_bytes')) |
|
| 56 | + { |
|
| 53 | 57 | $output = random_bytes($count); |
| 54 | 58 | } |
| 55 | 59 | // *nix |
| 56 | 60 | elseif (@is_readable('/dev/urandom') && |
| 57 | - ($fh = @fopen('/dev/urandom', 'rb'))) { |
|
| 61 | + ($fh = @fopen('/dev/urandom', 'rb'))) |
|
| 62 | + { |
|
| 58 | 63 | $output = fread($fh, $count); |
| 59 | 64 | fclose($fh); |
| 60 | 65 | } |
| 61 | 66 | // This is much to slow on windows php < 5.3.4 |
| 62 | 67 | elseif (function_exists('openssl_random_pseudo_bytes') && |
| 63 | - (substr(PHP_OS, 0, 3) !== 'WIN' || version_compare(PHP_VERSION, '5.3.4', '>='))) { |
|
| 68 | + (substr(PHP_OS, 0, 3) !== 'WIN' || version_compare(PHP_VERSION, '5.3.4', '>='))) |
|
| 69 | + { |
|
| 64 | 70 | $output = openssl_random_pseudo_bytes($count); |
| 65 | 71 | } |
| 66 | 72 | |
| 67 | 73 | // Do it ourselves then |
| 68 | - if (strlen($output) < $count) { |
|
| 74 | + if (strlen($output) < $count) |
|
| 75 | + { |
|
| 69 | 76 | $output = ''; |
| 70 | - for ($i = 0; $i < $count; $i += 16) { |
|
| 77 | + for ($i = 0; $i < $count; $i += 16) |
|
| 78 | + { |
|
| 71 | 79 | $this->random_state = |
| 72 | 80 | md5(microtime() . $this->random_state); |
| 73 | 81 | $output .= |
@@ -83,19 +91,28 @@ discard block |
||
| 83 | 91 | { |
| 84 | 92 | $output = ''; |
| 85 | 93 | $i = 0; |
| 86 | - do { |
|
| 94 | + do |
|
| 95 | + { |
|
| 87 | 96 | $value = ord($input[$i++]); |
| 88 | 97 | $output .= $this->itoa64[$value & 0x3f]; |
| 89 | 98 | if ($i < $count) |
| 90 | - $value |= ord($input[$i]) << 8; |
|
| 99 | + { |
|
| 100 | + $value |= ord($input[$i]) << 8; |
|
| 101 | + } |
|
| 91 | 102 | $output .= $this->itoa64[($value >> 6) & 0x3f]; |
| 92 | 103 | if ($i++ >= $count) |
| 93 | - break; |
|
| 104 | + { |
|
| 105 | + break; |
|
| 106 | + } |
|
| 94 | 107 | if ($i < $count) |
| 95 | - $value |= ord($input[$i]) << 16; |
|
| 108 | + { |
|
| 109 | + $value |= ord($input[$i]) << 16; |
|
| 110 | + } |
|
| 96 | 111 | $output .= $this->itoa64[($value >> 12) & 0x3f]; |
| 97 | 112 | if ($i++ >= $count) |
| 98 | - break; |
|
| 113 | + { |
|
| 114 | + break; |
|
| 115 | + } |
|
| 99 | 116 | $output .= $this->itoa64[($value >> 18) & 0x3f]; |
| 100 | 117 | } while ($i < $count); |
| 101 | 118 | |
@@ -116,22 +133,30 @@ discard block |
||
| 116 | 133 | { |
| 117 | 134 | $output = '*0'; |
| 118 | 135 | if (substr($setting, 0, 2) == $output) |
| 119 | - $output = '*1'; |
|
| 136 | + { |
|
| 137 | + $output = '*1'; |
|
| 138 | + } |
|
| 120 | 139 | |
| 121 | 140 | $id = substr($setting, 0, 3); |
| 122 | 141 | # We use "$P$", phpBB3 uses "$H$" for the same thing |
| 123 | 142 | if ($id != '$P$' && $id != '$H$') |
| 124 | - return $output; |
|
| 143 | + { |
|
| 144 | + return $output; |
|
| 145 | + } |
|
| 125 | 146 | |
| 126 | 147 | $count_log2 = strpos($this->itoa64, $setting[3]); |
| 127 | 148 | if ($count_log2 < 7 || $count_log2 > 30) |
| 128 | - return $output; |
|
| 149 | + { |
|
| 150 | + return $output; |
|
| 151 | + } |
|
| 129 | 152 | |
| 130 | 153 | $count = 1 << $count_log2; |
| 131 | 154 | |
| 132 | 155 | $salt = substr($setting, 4, 8); |
| 133 | 156 | if (strlen($salt) != 8) |
| 134 | - return $output; |
|
| 157 | + { |
|
| 158 | + return $output; |
|
| 159 | + } |
|
| 135 | 160 | |
| 136 | 161 | # We're kind of forced to use MD5 here since it's the only |
| 137 | 162 | # cryptographic primitive available in all versions of PHP |
@@ -139,14 +164,19 @@ discard block |
||
| 139 | 164 | # in PHP would result in much worse performance and |
| 140 | 165 | # consequently in lower iteration counts and hashes that are |
| 141 | 166 | # quicker to crack (by non-PHP code). |
| 142 | - if (PHP_VERSION >= '5') { |
|
| 167 | + if (PHP_VERSION >= '5') |
|
| 168 | + { |
|
| 143 | 169 | $hash = md5($salt . $password, TRUE); |
| 144 | - do { |
|
| 170 | + do |
|
| 171 | + { |
|
| 145 | 172 | $hash = md5($hash . $password, TRUE); |
| 146 | 173 | } while (--$count); |
| 147 | - } else { |
|
| 174 | + } |
|
| 175 | + else |
|
| 176 | + { |
|
| 148 | 177 | $hash = pack('H*', md5($salt . $password)); |
| 149 | - do { |
|
| 178 | + do |
|
| 179 | + { |
|
| 150 | 180 | $hash = pack('H*', md5($hash . $password)); |
| 151 | 181 | } while (--$count); |
| 152 | 182 | } |
@@ -193,11 +223,13 @@ discard block |
||
| 193 | 223 | $output .= '$'; |
| 194 | 224 | |
| 195 | 225 | $i = 0; |
| 196 | - do { |
|
| 226 | + do |
|
| 227 | + { |
|
| 197 | 228 | $c1 = ord($input[$i++]); |
| 198 | 229 | $output .= $itoa64[$c1 >> 2]; |
| 199 | 230 | $c1 = ($c1 & 0x03) << 4; |
| 200 | - if ($i >= 16) { |
|
| 231 | + if ($i >= 16) |
|
| 232 | + { |
|
| 201 | 233 | $output .= $itoa64[$c1]; |
| 202 | 234 | break; |
| 203 | 235 | } |
@@ -219,34 +251,48 @@ discard block |
||
| 219 | 251 | public function HashPassword($password) |
| 220 | 252 | { |
| 221 | 253 | if ( strlen( $password ) > 4096 ) |
| 222 | - return '*'; |
|
| 254 | + { |
|
| 255 | + return '*'; |
|
| 256 | + } |
|
| 223 | 257 | |
| 224 | 258 | $random = ''; |
| 225 | 259 | |
| 226 | - if (CRYPT_BLOWFISH == 1 && !$this->portable_hashes) { |
|
| 260 | + if (CRYPT_BLOWFISH == 1 && !$this->portable_hashes) |
|
| 261 | + { |
|
| 227 | 262 | $random = $this->get_random_bytes(16); |
| 228 | 263 | $hash = |
| 229 | 264 | crypt($password, $this->gensalt_blowfish($random)); |
| 230 | 265 | if (strlen($hash) == 60) |
| 231 | - return $hash; |
|
| 266 | + { |
|
| 267 | + return $hash; |
|
| 268 | + } |
|
| 232 | 269 | } |
| 233 | 270 | |
| 234 | - if (CRYPT_EXT_DES == 1 && !$this->portable_hashes) { |
|
| 271 | + if (CRYPT_EXT_DES == 1 && !$this->portable_hashes) |
|
| 272 | + { |
|
| 235 | 273 | if (strlen($random) < 3) |
| 236 | - $random = $this->get_random_bytes(3); |
|
| 274 | + { |
|
| 275 | + $random = $this->get_random_bytes(3); |
|
| 276 | + } |
|
| 237 | 277 | $hash = |
| 238 | 278 | crypt($password, $this->gensalt_extended($random)); |
| 239 | 279 | if (strlen($hash) == 20) |
| 240 | - return $hash; |
|
| 280 | + { |
|
| 281 | + return $hash; |
|
| 282 | + } |
|
| 241 | 283 | } |
| 242 | 284 | |
| 243 | 285 | if (strlen($random) < 6) |
| 244 | - $random = $this->get_random_bytes(6); |
|
| 286 | + { |
|
| 287 | + $random = $this->get_random_bytes(6); |
|
| 288 | + } |
|
| 245 | 289 | $hash = |
| 246 | 290 | $this->crypt_private($password, |
| 247 | 291 | $this->gensalt_private($random)); |
| 248 | 292 | if (strlen($hash) == 34) |
| 249 | - return $hash; |
|
| 293 | + { |
|
| 294 | + return $hash; |
|
| 295 | + } |
|
| 250 | 296 | |
| 251 | 297 | # Returning '*' on error is safe here, but would _not_ be safe |
| 252 | 298 | # in a crypt(3)-like function used _both_ for generating new |
@@ -257,11 +303,15 @@ discard block |
||
| 257 | 303 | public function CheckPassword($password, $stored_hash) |
| 258 | 304 | { |
| 259 | 305 | if ( strlen( $password ) > 4096 ) |
| 260 | - return false; |
|
| 306 | + { |
|
| 307 | + return false; |
|
| 308 | + } |
|
| 261 | 309 | |
| 262 | 310 | $hash = $this->crypt_private($password, $stored_hash); |
| 263 | 311 | if ($hash[0] == '*') |
| 264 | - $hash = crypt($password, $stored_hash); |
|
| 312 | + { |
|
| 313 | + $hash = crypt($password, $stored_hash); |
|
| 314 | + } |
|
| 265 | 315 | |
| 266 | 316 | return $this->_hash_equals($hash, $stored_hash); |
| 267 | 317 | } |
@@ -154,7 +154,9 @@ discard block |
||
| 154 | 154 | $validator->text_replacements(array('paid_email_to' => $txt['paid_email_to'])); |
| 155 | 155 | |
| 156 | 156 | if ($validator->validate($this->_req->post)) |
| 157 | - $this->_req->post->paid_email_to = $validator->validation_data('paid_email_to'); |
|
| 157 | + { |
|
| 158 | + $this->_req->post->paid_email_to = $validator->validation_data('paid_email_to'); |
|
| 159 | + } |
|
| 158 | 160 | else |
| 159 | 161 | { |
| 160 | 162 | // That's not an email, lets set it back in the form to be fixed and let them know its wrong |
@@ -162,7 +164,9 @@ discard block |
||
| 162 | 164 | $context['error_type'] = 'minor'; |
| 163 | 165 | $context['settings_message'] = array(); |
| 164 | 166 | foreach ($validator->validation_errors() as $id => $error) |
| 165 | - $context['settings_message'][] = $error; |
|
| 167 | + { |
|
| 168 | + $context['settings_message'][] = $error; |
|
| 169 | + } |
|
| 166 | 170 | } |
| 167 | 171 | } |
| 168 | 172 | |
@@ -201,7 +205,9 @@ discard block |
||
| 201 | 205 | // If the currency is set to something different then we need to set it to other for this to work and set it back shortly. |
| 202 | 206 | $modSettings['paid_currency'] = !empty($modSettings['paid_currency_code']) ? $modSettings['paid_currency_code'] : ''; |
| 203 | 207 | if (!empty($modSettings['paid_currency_code']) && !in_array($modSettings['paid_currency_code'], array('usd', 'eur', 'gbp'))) |
| 204 | - $modSettings['paid_currency'] = 'other'; |
|
| 208 | + { |
|
| 209 | + $modSettings['paid_currency'] = 'other'; |
|
| 210 | + } |
|
| 205 | 211 | |
| 206 | 212 | // These are all the default settings. |
| 207 | 213 | $config_vars = array( |
@@ -257,7 +263,9 @@ discard block |
||
| 257 | 263 | |
| 258 | 264 | // Not made the settings yet? |
| 259 | 265 | if (empty($modSettings['paid_currency_symbol'])) |
| 260 | - throw new Elk_Exception('paid_not_set_currency', false, array($scripturl . '?action=admin;area=paidsubscribe;sa=settings')); |
|
| 266 | + { |
|
| 267 | + throw new Elk_Exception('paid_not_set_currency', false, array($scripturl . '?action=admin;area=paidsubscribe;sa=settings')); |
|
| 268 | + } |
|
| 261 | 269 | |
| 262 | 270 | // Some basic stuff. |
| 263 | 271 | $context['page_title'] = $txt['paid_subs_view']; |
@@ -460,7 +468,9 @@ discard block |
||
| 460 | 468 | |
| 461 | 469 | // There needs to be something. |
| 462 | 470 | if (empty($this->_req->post->span_value) || empty($this->_req->post->cost)) |
| 463 | - throw new Elk_Exception('paid_no_cost_value'); |
|
| 471 | + { |
|
| 472 | + throw new Elk_Exception('paid_no_cost_value'); |
|
| 473 | + } |
|
| 464 | 474 | } |
| 465 | 475 | // Flexible is harder but more fun ;) |
| 466 | 476 | else |
@@ -475,7 +485,9 @@ discard block |
||
| 475 | 485 | ); |
| 476 | 486 | |
| 477 | 487 | if (empty($this->_req->post->cost_day) && empty($this->_req->post->cost_week) && empty($this->_req->post->cost_month) && empty($this->_req->post->cost_year)) |
| 478 | - throw new Elk_Exception('paid_all_freq_blank'); |
|
| 488 | + { |
|
| 489 | + throw new Elk_Exception('paid_all_freq_blank'); |
|
| 490 | + } |
|
| 479 | 491 | } |
| 480 | 492 | |
| 481 | 493 | $cost = serialize($cost); |
@@ -485,7 +497,9 @@ discard block |
||
| 485 | 497 | if (!empty($this->_req->post->addgroup)) |
| 486 | 498 | { |
| 487 | 499 | foreach ($this->_req->post->addgroup as $id => $dummy) |
| 488 | - $addGroups[] = (int) $id; |
|
| 500 | + { |
|
| 501 | + $addGroups[] = (int) $id; |
|
| 502 | + } |
|
| 489 | 503 | } |
| 490 | 504 | $addGroups = implode(',', $addGroups); |
| 491 | 505 | |
@@ -813,16 +827,22 @@ discard block |
||
| 813 | 827 | |
| 814 | 828 | // If we haven't been passed the subscription ID get it. |
| 815 | 829 | if ($context['log_id'] && !$context['sub_id']) |
| 816 | - $context['sub_id'] = validateSubscriptionID($context['log_id']); |
|
| 830 | + { |
|
| 831 | + $context['sub_id'] = validateSubscriptionID($context['log_id']); |
|
| 832 | + } |
|
| 817 | 833 | |
| 818 | 834 | if (!isset($context['subscriptions'][$context['sub_id']])) |
| 819 | - throw new Elk_Exception('no_access', false); |
|
| 835 | + { |
|
| 836 | + throw new Elk_Exception('no_access', false); |
|
| 837 | + } |
|
| 820 | 838 | |
| 821 | 839 | $context['current_subscription'] = $context['subscriptions'][$context['sub_id']]; |
| 822 | 840 | |
| 823 | 841 | // Searching? |
| 824 | 842 | if (isset($this->_req->post->ssearch)) |
| 825 | - return $this->action_viewsub(); |
|
| 843 | + { |
|
| 844 | + return $this->action_viewsub(); |
|
| 845 | + } |
|
| 826 | 846 | // Saving? |
| 827 | 847 | elseif (isset($this->_req->post->save_sub)) |
| 828 | 848 | { |
@@ -843,14 +863,20 @@ discard block |
||
| 843 | 863 | $member = getMemberByName($this->_req->post->name); |
| 844 | 864 | |
| 845 | 865 | if (empty($member)) |
| 846 | - throw new Elk_Exception('error_member_not_found'); |
|
| 866 | + { |
|
| 867 | + throw new Elk_Exception('error_member_not_found'); |
|
| 868 | + } |
|
| 847 | 869 | |
| 848 | 870 | if (alreadySubscribed($context['sub_id'], $member['id_member'])) |
| 849 | - throw new Elk_Exception('member_already_subscribed'); |
|
| 871 | + { |
|
| 872 | + throw new Elk_Exception('member_already_subscribed'); |
|
| 873 | + } |
|
| 850 | 874 | |
| 851 | 875 | // Actually put the subscription in place. |
| 852 | 876 | if ($status == 1) |
| 853 | - addSubscription($context['sub_id'], $member['id_member'], 0, $starttime, $endtime); |
|
| 877 | + { |
|
| 878 | + addSubscription($context['sub_id'], $member['id_member'], 0, $starttime, $endtime); |
|
| 879 | + } |
|
| 854 | 880 | else |
| 855 | 881 | { |
| 856 | 882 | $details = array( |
@@ -872,10 +898,14 @@ discard block |
||
| 872 | 898 | |
| 873 | 899 | // Pick the right permission stuff depending on what the status is changing from/to. |
| 874 | 900 | if ($subscription_status['old_status'] == 1 && $status != 1) |
| 875 | - removeSubscription($context['sub_id'], $subscription_status['id_member']); |
|
| 901 | + { |
|
| 902 | + removeSubscription($context['sub_id'], $subscription_status['id_member']); |
|
| 903 | + } |
|
| 876 | 904 | |
| 877 | 905 | elseif ($status == 1 && $subscription_status['old_status'] != 1) |
| 878 | - addSubscription($context['sub_id'], $subscription_status['id_member'], 0, $starttime, $endtime); |
|
| 906 | + { |
|
| 907 | + addSubscription($context['sub_id'], $subscription_status['id_member'], 0, $starttime, $endtime); |
|
| 908 | + } |
|
| 879 | 909 | |
| 880 | 910 | else |
| 881 | 911 | { |
@@ -902,12 +932,16 @@ discard block |
||
| 902 | 932 | { |
| 903 | 933 | $toDelete = array(); |
| 904 | 934 | foreach ($this->_req->post->delsub as $id => $dummy) |
| 905 | - $toDelete[] = (int) $id; |
|
| 935 | + { |
|
| 936 | + $toDelete[] = (int) $id; |
|
| 937 | + } |
|
| 906 | 938 | |
| 907 | 939 | $deletes = prepareDeleteSubscriptions($toDelete); |
| 908 | 940 | |
| 909 | 941 | foreach ($deletes as $id_subscribe => $id_member) |
| 910 | - removeSubscription($id_subscribe, $id_member, isset($this->_req->post->delete)); |
|
| 942 | + { |
|
| 943 | + removeSubscription($id_subscribe, $id_member, isset($this->_req->post->delete)); |
|
| 944 | + } |
|
| 911 | 945 | } |
| 912 | 946 | redirectexit('action=admin;area=paidsubscribe;sa=viewsub;sid=' . $context['sub_id']); |
| 913 | 947 | } |
@@ -946,15 +980,18 @@ discard block |
||
| 946 | 980 | $result = getBasicMemberData((int) $this->_req->query->uid); |
| 947 | 981 | $context['sub']['username'] = $result['real_name']; |
| 948 | 982 | } |
| 949 | - else |
|
| 950 | - $context['sub']['username'] = ''; |
|
| 983 | + else { |
|
| 984 | + $context['sub']['username'] = ''; |
|
| 985 | + } |
|
| 951 | 986 | } |
| 952 | 987 | // Otherwise load the existing info. |
| 953 | 988 | else |
| 954 | 989 | { |
| 955 | 990 | $row = getPendingSubscriptions($context['log_id']); |
| 956 | 991 | if (empty($row)) |
| 957 | - throw new Elk_Exception('no_access', false); |
|
| 992 | + { |
|
| 993 | + throw new Elk_Exception('no_access', false); |
|
| 994 | + } |
|
| 958 | 995 | |
| 959 | 996 | // Any pending payments? |
| 960 | 997 | $context['pending_payments'] = array(); |
@@ -974,9 +1011,11 @@ discard block |
||
| 974 | 1011 | foreach ($costs as $duration => $cost) |
| 975 | 1012 | { |
| 976 | 1013 | if ($cost != 0 && $cost == $pending[1] && $duration == $pending[2]) |
| 977 | - $context['pending_payments'][$id] = array( |
|
| 1014 | + { |
|
| 1015 | + $context['pending_payments'][$id] = array( |
|
| 978 | 1016 | 'desc' => sprintf($modSettings['paid_currency_symbol'], $cost . '/' . $txt[$duration]), |
| 979 | 1017 | ); |
| 1018 | + } |
|
| 980 | 1019 | } |
| 981 | 1020 | } |
| 982 | 1021 | elseif ($costs['fixed'] == $pending[1]) |
@@ -998,7 +1037,9 @@ discard block |
||
| 998 | 1037 | { |
| 999 | 1038 | // Flexible? |
| 1000 | 1039 | if (isset($this->_req->query->accept)) |
| 1001 | - addSubscription($context['current_subscription']['id'], $row['id_member'], $context['current_subscription']['real_length'] === 'F' ? strtoupper(substr($pending[2], 0, 1)) : 0); |
|
| 1040 | + { |
|
| 1041 | + addSubscription($context['current_subscription']['id'], $row['id_member'], $context['current_subscription']['real_length'] === 'F' ? strtoupper(substr($pending[2], 0, 1)) : 0); |
|
| 1042 | + } |
|
| 1002 | 1043 | unset($pending_details[$id]); |
| 1003 | 1044 | |
| 1004 | 1045 | $new_details = serialize($pending_details); |
@@ -168,7 +168,9 @@ discard block |
||
| 168 | 168 | |
| 169 | 169 | // Prevent absurd boundaries here - make it a day tops. |
| 170 | 170 | if (isset($this->_req->post->lastActive)) |
| 171 | - $this->_req->post->lastActive = min((int) $this->_req->post->lastActive, 1440); |
|
| 171 | + { |
|
| 172 | + $this->_req->post->lastActive = min((int) $this->_req->post->lastActive, 1440); |
|
| 173 | + } |
|
| 172 | 174 | |
| 173 | 175 | call_integration_hook('integrate_save_basic_settings'); |
| 174 | 176 | |
@@ -420,7 +422,9 @@ discard block |
||
| 420 | 422 | |
| 421 | 423 | // Something like enableModule('mentions', array('post', 'display'); |
| 422 | 424 | foreach ($modules as $key => $val) |
| 423 | - $function($key, $val); |
|
| 425 | + { |
|
| 426 | + $function($key, $val); |
|
| 427 | + } |
|
| 424 | 428 | } |
| 425 | 429 | } |
| 426 | 430 | |
@@ -499,7 +503,9 @@ discard block |
||
| 499 | 503 | |
| 500 | 504 | // Temporarily make each setting a modSetting! |
| 501 | 505 | foreach ($context['signature_settings'] as $key => $value) |
| 502 | - $modSettings['signature_' . $key] = $value; |
|
| 506 | + { |
|
| 507 | + $modSettings['signature_' . $key] = $value; |
|
| 508 | + } |
|
| 503 | 509 | |
| 504 | 510 | // Make sure we check the right tags! |
| 505 | 511 | $modSettings['bbc_disabled_signature_bbc'] = $disabledTags; |
@@ -514,17 +520,25 @@ discard block |
||
| 514 | 520 | $bbcTags = $codes->getTags(); |
| 515 | 521 | |
| 516 | 522 | if (!isset($this->_req->post->signature_bbc_enabledTags)) |
| 517 | - $this->_req->post->signature_bbc_enabledTags = array(); |
|
| 523 | + { |
|
| 524 | + $this->_req->post->signature_bbc_enabledTags = array(); |
|
| 525 | + } |
|
| 518 | 526 | elseif (!is_array($this->_req->post->signature_bbc_enabledTags)) |
| 519 | - $this->_req->post->signature_bbc_enabledTags = array($this->_req->post->signature_bbc_enabledTags); |
|
| 527 | + { |
|
| 528 | + $this->_req->post->signature_bbc_enabledTags = array($this->_req->post->signature_bbc_enabledTags); |
|
| 529 | + } |
|
| 520 | 530 | |
| 521 | 531 | $sig_limits = array(); |
| 522 | 532 | foreach ($context['signature_settings'] as $key => $value) |
| 523 | 533 | { |
| 524 | 534 | if ($key == 'allow_smileys') |
| 525 | - continue; |
|
| 535 | + { |
|
| 536 | + continue; |
|
| 537 | + } |
|
| 526 | 538 | elseif ($key == 'max_smileys' && empty($this->_req->post->signature_allow_smileys)) |
| 527 | - $sig_limits[] = -1; |
|
| 539 | + { |
|
| 540 | + $sig_limits[] = -1; |
|
| 541 | + } |
|
| 528 | 542 | else |
| 529 | 543 | { |
| 530 | 544 | $current_key = $this->_req->getPost('signature_' . $key, 'intval'); |
@@ -606,7 +620,9 @@ discard block |
||
| 606 | 620 | foreach ($this->_req->post->reg as $value) |
| 607 | 621 | { |
| 608 | 622 | if (in_array($value, $standard_fields) && !isset($disable_fields[$value])) |
| 609 | - $reg_fields[] = $value; |
|
| 623 | + { |
|
| 624 | + $reg_fields[] = $value; |
|
| 625 | + } |
|
| 610 | 626 | } |
| 611 | 627 | } |
| 612 | 628 | |
@@ -614,7 +630,9 @@ discard block |
||
| 614 | 630 | $changes['registration_fields'] = empty($reg_fields) ? '' : implode(',', $reg_fields); |
| 615 | 631 | |
| 616 | 632 | if (!empty($changes)) |
| 617 | - updateSettings($changes); |
|
| 633 | + { |
|
| 634 | + updateSettings($changes); |
|
| 635 | + } |
|
| 618 | 636 | } |
| 619 | 637 | |
| 620 | 638 | createToken('admin-scp'); |
@@ -874,7 +892,9 @@ discard block |
||
| 874 | 892 | loadLanguage('Errors'); |
| 875 | 893 | |
| 876 | 894 | if (isset($txt['custom_option_' . $this->_req->query->msg])) |
| 877 | - $context['custom_option__error'] = $txt['custom_option_' . $this->_req->query->msg]; |
|
| 895 | + { |
|
| 896 | + $context['custom_option__error'] = $txt['custom_option_' . $this->_req->query->msg]; |
|
| 897 | + } |
|
| 878 | 898 | } |
| 879 | 899 | |
| 880 | 900 | // Load the profile language for section names. |
@@ -928,9 +948,12 @@ discard block |
||
| 928 | 948 | |
| 929 | 949 | // Enable and disable custom fields as required. |
| 930 | 950 | $enabled = array(0); |
| 931 | - if(isset($this->_req->post->cust) && is_array($this->_req->post->cust)) { |
|
| 951 | + if(isset($this->_req->post->cust) && is_array($this->_req->post->cust)) |
|
| 952 | + { |
|
| 932 | 953 | foreach ($this->_req->post->cust as $id) |
| 933 | - $enabled[] = (int) $id; |
|
| 954 | + { |
|
| 955 | + $enabled[] = (int) $id; |
|
| 956 | + } |
|
| 934 | 957 | } |
| 935 | 958 | |
| 936 | 959 | updateRenamedProfileStatus($enabled); |
@@ -943,11 +966,15 @@ discard block |
||
| 943 | 966 | |
| 944 | 967 | // Everyone needs a name - even the (bracket) unknown... |
| 945 | 968 | if (trim($this->_req->post->field_name) == '') |
| 946 | - redirectexit($scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $this->_req->query->fid . ';msg=need_name'); |
|
| 969 | + { |
|
| 970 | + redirectexit($scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $this->_req->query->fid . ';msg=need_name'); |
|
| 971 | + } |
|
| 947 | 972 | |
| 948 | 973 | // Regex you say? Do a very basic test to see if the pattern is valid |
| 949 | 974 | if (!empty($this->_req->post->regex) && @preg_match($this->_req->post->regex, 'dummy') === false) |
| 950 | - redirectexit($scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $this->_req->query->fid . ';msg=regex_error'); |
|
| 975 | + { |
|
| 976 | + redirectexit($scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $this->_req->query->fid . ';msg=regex_error'); |
|
| 977 | + } |
|
| 951 | 978 | |
| 952 | 979 | $this->_req->post->field_name = $this->_req->getPost('field_name', 'Util::htmlspecialchars'); |
| 953 | 980 | $this->_req->post->field_desc = $this->_req->getPost('field_desc', 'Util::htmlspecialchars'); |
@@ -968,7 +995,9 @@ discard block |
||
| 968 | 995 | // Some masking stuff... |
| 969 | 996 | $mask = $this->_req->getPost('mask', 'strval', ''); |
| 970 | 997 | if ($mask == 'regex' && isset($this->_req->post->regex)) |
| 971 | - $mask .= $this->_req->post->regex; |
|
| 998 | + { |
|
| 999 | + $mask .= $this->_req->post->regex; |
|
| 1000 | + } |
|
| 972 | 1001 | |
| 973 | 1002 | $field_length = $this->_req->getPost('max_length', 'intval', 255); |
| 974 | 1003 | $enclose = $this->_req->getPost('enclose', 'strval', ''); |
@@ -998,7 +1027,9 @@ discard block |
||
| 998 | 1027 | |
| 999 | 1028 | // Nada, zip, etc... |
| 1000 | 1029 | if (trim($v) == '') |
| 1001 | - continue; |
|
| 1030 | + { |
|
| 1031 | + continue; |
|
| 1032 | + } |
|
| 1002 | 1033 | |
| 1003 | 1034 | // Otherwise, save it boy. |
| 1004 | 1035 | $field_options .= $v . ','; |
@@ -1014,7 +1045,9 @@ discard block |
||
| 1014 | 1045 | } |
| 1015 | 1046 | |
| 1016 | 1047 | if (isset($_POST['default_select']) && $_POST['default_select'] == 'no_default') |
| 1017 | - $default = 'no_default'; |
|
| 1048 | + { |
|
| 1049 | + $default = 'no_default'; |
|
| 1050 | + } |
|
| 1018 | 1051 | |
| 1019 | 1052 | $field_options = substr($field_options, 0, -1); |
| 1020 | 1053 | } |
@@ -1035,15 +1068,20 @@ discard block |
||
| 1035 | 1068 | |
| 1036 | 1069 | // If there is nothing to the name, then let's start our own - for foreign languages etc. |
| 1037 | 1070 | if (isset($matches[1])) |
| 1038 | - $colname = $initial_colname = 'cust_' . strtolower($matches[1]); |
|
| 1039 | - else |
|
| 1040 | - $colname = $initial_colname = 'cust_' . mt_rand(1, 999999); |
|
| 1071 | + { |
|
| 1072 | + $colname = $initial_colname = 'cust_' . strtolower($matches[1]); |
|
| 1073 | + } |
|
| 1074 | + else { |
|
| 1075 | + $colname = $initial_colname = 'cust_' . mt_rand(1, 999999); |
|
| 1076 | + } |
|
| 1041 | 1077 | |
| 1042 | 1078 | $unique = ensureUniqueProfileField($colname, $initial_colname); |
| 1043 | 1079 | |
| 1044 | 1080 | // Still not a unique column name? Leave it up to the user, then. |
| 1045 | 1081 | if (!$unique) |
| 1046 | - throw new Elk_Exception('custom_option_not_unique'); |
|
| 1082 | + { |
|
| 1083 | + throw new Elk_Exception('custom_option_not_unique'); |
|
| 1084 | + } |
|
| 1047 | 1085 | |
| 1048 | 1086 | // And create a new field |
| 1049 | 1087 | $new_field = array( |
@@ -1091,7 +1129,9 @@ discard block |
||
| 1091 | 1129 | foreach ($context['field']['options'] as $k => $option) |
| 1092 | 1130 | { |
| 1093 | 1131 | if (trim($option) == '') |
| 1094 | - continue; |
|
| 1132 | + { |
|
| 1133 | + continue; |
|
| 1134 | + } |
|
| 1095 | 1135 | |
| 1096 | 1136 | // Still exists? |
| 1097 | 1137 | if (in_array($option, $newOptions)) |
@@ -1106,7 +1146,9 @@ discard block |
||
| 1106 | 1146 | { |
| 1107 | 1147 | // Just been renamed? |
| 1108 | 1148 | if (!in_array($k, $takenKeys) && !empty($newOptions[$k])) |
| 1109 | - updateRenamedProfileField($k, $newOptions, $context['field']['colname'], $option); |
|
| 1149 | + { |
|
| 1150 | + updateRenamedProfileField($k, $newOptions, $context['field']['colname'], $option); |
|
| 1151 | + } |
|
| 1110 | 1152 | } |
| 1111 | 1153 | } |
| 1112 | 1154 | // @todo Maybe we should adjust based on new text length limits? |
@@ -1139,7 +1181,9 @@ discard block |
||
| 1139 | 1181 | |
| 1140 | 1182 | // Just clean up any old selects - these are a pain! |
| 1141 | 1183 | if (($this->_req->post->field_type == 'select' || $this->_req->post->field_type == 'radio') && !empty($newOptions)) |
| 1142 | - deleteOldProfileFieldSelects($newOptions, $context['field']['colname']); |
|
| 1184 | + { |
|
| 1185 | + deleteOldProfileFieldSelects($newOptions, $context['field']['colname']); |
|
| 1186 | + } |
|
| 1143 | 1187 | } |
| 1144 | 1188 | } |
| 1145 | 1189 | // Deleting? |
@@ -1197,7 +1241,9 @@ discard block |
||
| 1197 | 1241 | foreach ($context['pm_limits'] as $group_id => $group) |
| 1198 | 1242 | { |
| 1199 | 1243 | if (isset($this->_req->post->group[$group_id]) && $this->_req->post->group[$group_id] != $group['max_messages']) |
| 1200 | - updateMembergroupProperties(array('current_group' => $group_id, 'max_messages' => $this->_req->post->group[$group_id])); |
|
| 1244 | + { |
|
| 1245 | + updateMembergroupProperties(array('current_group' => $group_id, 'max_messages' => $this->_req->post->group[$group_id])); |
|
| 1246 | + } |
|
| 1201 | 1247 | } |
| 1202 | 1248 | |
| 1203 | 1249 | call_integration_hook('integrate_save_pmsettings_settings'); |
@@ -1260,12 +1306,16 @@ discard block |
||
| 1260 | 1306 | // Get all the time zones. |
| 1261 | 1307 | $all_zones = timezone_identifiers_list(); |
| 1262 | 1308 | if ($all_zones === false) |
| 1263 | - unset($config_vars['default_timezone']); |
|
| 1309 | + { |
|
| 1310 | + unset($config_vars['default_timezone']); |
|
| 1311 | + } |
|
| 1264 | 1312 | else |
| 1265 | 1313 | { |
| 1266 | 1314 | // Make sure we set the value to the same as the printed value. |
| 1267 | 1315 | foreach ($all_zones as $zone) |
| 1268 | - $config_vars['default_timezone'][2][$zone] = $zone; |
|
| 1316 | + { |
|
| 1317 | + $config_vars['default_timezone'][2][$zone] = $zone; |
|
| 1318 | + } |
|
| 1269 | 1319 | } |
| 1270 | 1320 | |
| 1271 | 1321 | call_integration_hook('integrate_modify_basic_settings', array(&$config_vars)); |
@@ -1565,7 +1615,9 @@ discard block |
||
| 1565 | 1615 | |
| 1566 | 1616 | // Have we exhausted all the time we allowed? |
| 1567 | 1617 | if (time() - array_sum(explode(' ', $sig_start)) < 3) |
| 1568 | - return; |
|
| 1618 | + { |
|
| 1619 | + return; |
|
| 1620 | + } |
|
| 1569 | 1621 | |
| 1570 | 1622 | $context['continue_get_data'] = '?action=admin;area=featuresettings;sa=sig;apply;step=' . $applied_sigs . ';' . $context['session_var'] . '=' . $context['session_id']; |
| 1571 | 1623 | $context['page_title'] = $txt['not_done_title']; |
@@ -147,18 +147,21 @@ discard block |
||
| 147 | 147 | |
| 148 | 148 | // Top is special, its the top! |
| 149 | 149 | if ($this->_req->query->move_to === 'top') |
| 150 | - $boardOptions = array( |
|
| 150 | + { |
|
| 151 | + $boardOptions = array( |
|
| 151 | 152 | 'move_to' => $this->_req->query->move_to, |
| 152 | 153 | 'target_category' => (int) $this->_req->query->target_cat, |
| 153 | 154 | 'move_first_child' => true, |
| 154 | 155 | ); |
| 156 | + } |
|
| 155 | 157 | // Moving it after another board |
| 156 | - else |
|
| 157 | - $boardOptions = array( |
|
| 158 | + else { |
|
| 159 | + $boardOptions = array( |
|
| 158 | 160 | 'move_to' => $this->_req->query->move_to, |
| 159 | 161 | 'target_board' => (int) $this->_req->query->target_board, |
| 160 | 162 | 'move_first_child' => true, |
| 161 | 163 | ); |
| 164 | + } |
|
| 162 | 165 | |
| 163 | 166 | // Use modifyBoard to perform the action |
| 164 | 167 | modifyBoard((int) $this->_req->query->src_board, $boardOptions); |
@@ -210,14 +213,17 @@ discard block |
||
| 210 | 213 | foreach ($boardList[$catid] as $boardid) |
| 211 | 214 | { |
| 212 | 215 | if (!isset($context['categories'][$catid]['move_link'])) |
| 213 | - $context['categories'][$catid]['move_link'] = array( |
|
| 216 | + { |
|
| 217 | + $context['categories'][$catid]['move_link'] = array( |
|
| 214 | 218 | 'child_level' => 0, |
| 215 | 219 | 'label' => $txt['mboards_order_before'] . ' \'' . htmlspecialchars($boards[$boardid]['name'], ENT_COMPAT, 'UTF-8') . '\'', |
| 216 | 220 | 'href' => $scripturl . '?action=admin;area=manageboards;sa=move;src_board=' . $context['move_board'] . ';target_board=' . $boardid . ';move_to=before;' . $security, |
| 217 | 221 | ); |
| 222 | + } |
|
| 218 | 223 | |
| 219 | 224 | if (!$context['categories'][$catid]['boards'][$boardid]['move']) |
| 220 | - $context['categories'][$catid]['boards'][$boardid]['move_links'] = array( |
|
| 225 | + { |
|
| 226 | + $context['categories'][$catid]['boards'][$boardid]['move_links'] = array( |
|
| 221 | 227 | array( |
| 222 | 228 | 'child_level' => $boards[$boardid]['level'], |
| 223 | 229 | 'label' => $txt['mboards_order_after'] . '\'' . htmlspecialchars($boards[$boardid]['name'], ENT_COMPAT, 'UTF-8') . '\'', |
@@ -229,18 +235,25 @@ discard block |
||
| 229 | 235 | 'href' => $scripturl . '?action=admin;area=manageboards;sa=move;src_board=' . $context['move_board'] . ';target_board=' . $boardid . ';move_to=child;' . $security, |
| 230 | 236 | ), |
| 231 | 237 | ); |
| 238 | + } |
|
| 232 | 239 | |
| 233 | 240 | $difference = $boards[$boardid]['level'] - $prev_child_level; |
| 234 | 241 | if ($difference == 1) |
| 235 | - array_push($stack, !empty($context['categories'][$catid]['boards'][$prev_board]['move_links']) ? array_shift($context['categories'][$catid]['boards'][$prev_board]['move_links']) : null); |
|
| 242 | + { |
|
| 243 | + array_push($stack, !empty($context['categories'][$catid]['boards'][$prev_board]['move_links']) ? array_shift($context['categories'][$catid]['boards'][$prev_board]['move_links']) : null); |
|
| 244 | + } |
|
| 236 | 245 | elseif ($difference < 0) |
| 237 | 246 | { |
| 238 | 247 | if (empty($context['categories'][$catid]['boards'][$prev_board]['move_links'])) |
| 239 | - $context['categories'][$catid]['boards'][$prev_board]['move_links'] = array(); |
|
| 248 | + { |
|
| 249 | + $context['categories'][$catid]['boards'][$prev_board]['move_links'] = array(); |
|
| 250 | + } |
|
| 240 | 251 | |
| 241 | 252 | for ($i = 0; $i < -$difference; $i++) |
| 242 | - if (($temp = array_pop($stack)) !== null) |
|
| 253 | + { |
|
| 254 | + if (($temp = array_pop($stack)) !== null) |
|
| 243 | 255 | array_unshift($context['categories'][$catid]['boards'][$prev_board]['move_links'], $temp); |
| 256 | + } |
|
| 244 | 257 | } |
| 245 | 258 | |
| 246 | 259 | $prev_board = $boardid; |
@@ -249,16 +262,22 @@ discard block |
||
| 249 | 262 | } |
| 250 | 263 | |
| 251 | 264 | if (!empty($stack) && !empty($context['categories'][$catid]['boards'][$prev_board]['move_links'])) |
| 252 | - $context['categories'][$catid]['boards'][$prev_board]['move_links'] = array_merge($stack, $context['categories'][$catid]['boards'][$prev_board]['move_links']); |
|
| 265 | + { |
|
| 266 | + $context['categories'][$catid]['boards'][$prev_board]['move_links'] = array_merge($stack, $context['categories'][$catid]['boards'][$prev_board]['move_links']); |
|
| 267 | + } |
|
| 253 | 268 | elseif (!empty($stack)) |
| 254 | - $context['categories'][$catid]['boards'][$prev_board]['move_links'] = $stack; |
|
| 269 | + { |
|
| 270 | + $context['categories'][$catid]['boards'][$prev_board]['move_links'] = $stack; |
|
| 271 | + } |
|
| 255 | 272 | |
| 256 | 273 | if (empty($boardList[$catid])) |
| 257 | - $context['categories'][$catid]['move_link'] = array( |
|
| 274 | + { |
|
| 275 | + $context['categories'][$catid]['move_link'] = array( |
|
| 258 | 276 | 'child_level' => 0, |
| 259 | 277 | 'label' => $txt['mboards_order_before'] . ' \'' . htmlspecialchars($tree['node']['name'], ENT_COMPAT, 'UTF-8') . '\'', |
| 260 | 278 | 'href' => $scripturl . '?action=admin;area=manageboards;sa=move;src_board=' . $context['move_board'] . ';target_cat=' . $catid . ';move_to=top;' . $security, |
| 261 | 279 | ); |
| 280 | + } |
|
| 262 | 281 | } |
| 263 | 282 | } |
| 264 | 283 | |
@@ -317,7 +336,9 @@ discard block |
||
| 317 | 336 | } |
| 318 | 337 | // Category doesn't exist, man... sorry. |
| 319 | 338 | elseif (!isset($cat_tree[$this->cat])) |
| 320 | - redirectexit('action=admin;area=manageboards'); |
|
| 339 | + { |
|
| 340 | + redirectexit('action=admin;area=manageboards'); |
|
| 341 | + } |
|
| 321 | 342 | else |
| 322 | 343 | { |
| 323 | 344 | $context['category'] = array( |
@@ -330,21 +351,27 @@ discard block |
||
| 330 | 351 | ); |
| 331 | 352 | |
| 332 | 353 | foreach ($boardList[$this->cat] as $child_board) |
| 333 | - $context['category']['children'][] = str_repeat('-', $boards[$child_board]['level']) . ' ' . $boards[$child_board]['name']; |
|
| 354 | + { |
|
| 355 | + $context['category']['children'][] = str_repeat('-', $boards[$child_board]['level']) . ' ' . $boards[$child_board]['name']; |
|
| 356 | + } |
|
| 334 | 357 | } |
| 335 | 358 | |
| 336 | 359 | $prevCat = 0; |
| 337 | 360 | foreach ($cat_tree as $catid => $tree) |
| 338 | 361 | { |
| 339 | 362 | if ($catid == $this->cat && $prevCat > 0) |
| 340 | - $context['category_order'][$prevCat]['selected'] = true; |
|
| 363 | + { |
|
| 364 | + $context['category_order'][$prevCat]['selected'] = true; |
|
| 365 | + } |
|
| 341 | 366 | elseif ($catid != $this->cat) |
| 342 | - $context['category_order'][$catid] = array( |
|
| 367 | + { |
|
| 368 | + $context['category_order'][$catid] = array( |
|
| 343 | 369 | 'id' => $catid, |
| 344 | 370 | 'name' => $txt['mboards_order_after'] . $tree['node']['name'], |
| 345 | 371 | 'selected' => false, |
| 346 | 372 | 'true_name' => $tree['node']['name'] |
| 347 | 373 | ); |
| 374 | + } |
|
| 348 | 375 | |
| 349 | 376 | $prevCat = $catid; |
| 350 | 377 | } |
@@ -393,7 +420,9 @@ discard block |
||
| 393 | 420 | $catOptions = array(); |
| 394 | 421 | |
| 395 | 422 | if (isset($this->_req->post->cat_order)) |
| 396 | - $catOptions['move_after'] = (int) $this->_req->post->cat_order; |
|
| 423 | + { |
|
| 424 | + $catOptions['move_after'] = (int) $this->_req->post->cat_order; |
|
| 425 | + } |
|
| 397 | 426 | |
| 398 | 427 | // Change "This & That" to "This & That" but don't change "¢" to "&cent;"... |
| 399 | 428 | $catOptions['cat_name'] = preg_replace('~[&]([^;]{8}|[^;]{0,8}$)~', '&$1', $this->_req->post->cat_name); |
@@ -401,9 +430,12 @@ discard block |
||
| 401 | 430 | $catOptions['is_collapsible'] = isset($this->_req->post->collapse); |
| 402 | 431 | |
| 403 | 432 | if (isset($this->_req->post->add)) |
| 404 | - createCategory($catOptions); |
|
| 405 | - else |
|
| 406 | - modifyCategory($this->cat, $catOptions); |
|
| 433 | + { |
|
| 434 | + createCategory($catOptions); |
|
| 435 | + } |
|
| 436 | + else { |
|
| 437 | + modifyCategory($this->cat, $catOptions); |
|
| 438 | + } |
|
| 407 | 439 | } |
| 408 | 440 | // If they want to delete - first give them confirmation. |
| 409 | 441 | elseif (isset($this->_req->post->delete) && !isset($this->_req->post->confirmation) && !isset($this->_req->post->empty)) |
@@ -418,12 +450,15 @@ discard block |
||
| 418 | 450 | if (isset($this->_req->post->delete_action) && $this->_req->post->delete_action == 1) |
| 419 | 451 | { |
| 420 | 452 | if (empty($this->_req->post->cat_to)) |
| 421 | - throw new Elk_Exception('mboards_delete_error'); |
|
| 453 | + { |
|
| 454 | + throw new Elk_Exception('mboards_delete_error'); |
|
| 455 | + } |
|
| 422 | 456 | |
| 423 | 457 | deleteCategories(array($this->cat), (int) $this->_req->post->cat_to); |
| 424 | 458 | } |
| 425 | - else |
|
| 426 | - deleteCategories(array($this->cat)); |
|
| 459 | + else { |
|
| 460 | + deleteCategories(array($this->cat)); |
|
| 461 | + } |
|
| 427 | 462 | } |
| 428 | 463 | |
| 429 | 464 | redirectexit('action=admin;area=manageboards'); |
@@ -470,7 +505,9 @@ discard block |
||
| 470 | 505 | |
| 471 | 506 | // Category doesn't exist, man... sorry. |
| 472 | 507 | if (empty($this->cat)) |
| 473 | - redirectexit('action=admin;area=manageboards'); |
|
| 508 | + { |
|
| 509 | + redirectexit('action=admin;area=manageboards'); |
|
| 510 | + } |
|
| 474 | 511 | |
| 475 | 512 | // Some things that need to be setup for a new board. |
| 476 | 513 | $curBoard = array( |
@@ -534,7 +571,9 @@ discard block |
||
| 534 | 571 | |
| 535 | 572 | // Category doesn't exist, man... sorry. |
| 536 | 573 | if (!isset($boardList[$curBoard['category']])) |
| 537 | - redirectexit('action=admin;area=manageboards'); |
|
| 574 | + { |
|
| 575 | + redirectexit('action=admin;area=manageboards'); |
|
| 576 | + } |
|
| 538 | 577 | |
| 539 | 578 | foreach ($boardList[$curBoard['category']] as $boardid) |
| 540 | 579 | { |
@@ -566,24 +605,30 @@ discard block |
||
| 566 | 605 | $context['can_move_children'] = false; |
| 567 | 606 | $context['children'] = $boards[$this->boardid]['tree']['children']; |
| 568 | 607 | foreach ($context['board_order'] as $board) |
| 569 | - if ($board['is_child'] === false && $board['selected'] === false) |
|
| 608 | + { |
|
| 609 | + if ($board['is_child'] === false && $board['selected'] === false) |
|
| 570 | 610 | $context['can_move_children'] = true; |
| 611 | + } |
|
| 571 | 612 | } |
| 572 | 613 | |
| 573 | 614 | // Get other available categories. |
| 574 | 615 | $context['categories'] = array(); |
| 575 | 616 | foreach ($cat_tree as $catID => $tree) |
| 576 | - $context['categories'][] = array( |
|
| 617 | + { |
|
| 618 | + $context['categories'][] = array( |
|
| 577 | 619 | 'id' => $catID == $curBoard['category'] ? 0 : $catID, |
| 578 | 620 | 'name' => $tree['node']['name'], |
| 579 | 621 | 'selected' => $catID == $curBoard['category'] |
| 580 | 622 | ); |
| 623 | + } |
|
| 581 | 624 | |
| 582 | 625 | $context['board']['moderators'] = getBoardModerators($this->boardid); |
| 583 | 626 | $context['board']['moderator_list'] = empty($context['board']['moderators']) ? '' : '"' . implode('", "', $context['board']['moderators']) . '"'; |
| 584 | 627 | |
| 585 | 628 | if (!empty($context['board']['moderators'])) |
| 586 | - list ($context['board']['last_moderator_id']) = array_slice(array_keys($context['board']['moderators']), -1); |
|
| 629 | + { |
|
| 630 | + list ($context['board']['last_moderator_id']) = array_slice(array_keys($context['board']['moderators']), -1); |
|
| 631 | + } |
|
| 587 | 632 | |
| 588 | 633 | $context['themes'] = getAllThemes(); |
| 589 | 634 | |
@@ -646,7 +691,9 @@ discard block |
||
| 646 | 691 | elseif (!empty($this->_req->post->placement) && !empty($this->_req->post->board_order)) |
| 647 | 692 | { |
| 648 | 693 | if (!in_array($this->_req->post->placement, array('before', 'after', 'child'))) |
| 649 | - throw new Elk_Exception('mangled_post', false); |
|
| 694 | + { |
|
| 695 | + throw new Elk_Exception('mangled_post', false); |
|
| 696 | + } |
|
| 650 | 697 | |
| 651 | 698 | $boardOptions['move_to'] = $this->_req->post->placement; |
| 652 | 699 | $boardOptions['target_board'] = (int) $this->_req->post->board_order; |
@@ -664,14 +711,20 @@ discard block |
||
| 664 | 711 | foreach ($this->_req->post->groups as $group => $action) |
| 665 | 712 | { |
| 666 | 713 | if ($action == 'allow') |
| 667 | - $boardOptions['access_groups'][] = (int) $group; |
|
| 714 | + { |
|
| 715 | + $boardOptions['access_groups'][] = (int) $group; |
|
| 716 | + } |
|
| 668 | 717 | elseif ($action == 'deny') |
| 669 | - $boardOptions['deny_groups'][] = (int) $group; |
|
| 718 | + { |
|
| 719 | + $boardOptions['deny_groups'][] = (int) $group; |
|
| 720 | + } |
|
| 670 | 721 | } |
| 671 | 722 | } |
| 672 | 723 | |
| 673 | 724 | if (strlen(implode(',', $boardOptions['access_groups'])) > 255 || strlen(implode(',', $boardOptions['deny_groups'])) > 255) |
| 674 | - throw new Elk_Exception('too_many_groups', false); |
|
| 725 | + { |
|
| 726 | + throw new Elk_Exception('too_many_groups', false); |
|
| 727 | + } |
|
| 675 | 728 | |
| 676 | 729 | // Change '1 & 2' to '1 & 2', but not '&' to '&amp;'... |
| 677 | 730 | $boardOptions['board_name'] = preg_replace('~[&]([^;]{8}|[^;]{0,8}$)~', '&$1', $this->_req->post->board_name); |
@@ -685,7 +738,9 @@ discard block |
||
| 685 | 738 | { |
| 686 | 739 | $moderators = array(); |
| 687 | 740 | foreach ($this->_req->post->moderator_list as $moderator) |
| 688 | - $moderators[(int) $moderator] = (int) $moderator; |
|
| 741 | + { |
|
| 742 | + $moderators[(int) $moderator] = (int) $moderator; |
|
| 743 | + } |
|
| 689 | 744 | |
| 690 | 745 | $boardOptions['moderators'] = $moderators; |
| 691 | 746 | } |
@@ -704,13 +759,19 @@ discard block |
||
| 704 | 759 | |
| 705 | 760 | // If we're turning redirection on check the board doesn't have posts in it - if it does don't make it a redirection board. |
| 706 | 761 | if ($boardOptions['redirect'] && empty($properties['oldRedirect']) && $properties['numPosts']) |
| 707 | - unset($boardOptions['redirect']); |
|
| 762 | + { |
|
| 763 | + unset($boardOptions['redirect']); |
|
| 764 | + } |
|
| 708 | 765 | // Reset the redirection count when switching on/off. |
| 709 | 766 | elseif (empty($boardOptions['redirect']) != empty($properties['oldRedirect'])) |
| 710 | - $boardOptions['num_posts'] = 0; |
|
| 767 | + { |
|
| 768 | + $boardOptions['num_posts'] = 0; |
|
| 769 | + } |
|
| 711 | 770 | // Resetting the count? |
| 712 | 771 | elseif ($boardOptions['redirect'] && !empty($this->_req->post->reset_redirect)) |
| 713 | - $boardOptions['num_posts'] = 0; |
|
| 772 | + { |
|
| 773 | + $boardOptions['num_posts'] = 0; |
|
| 774 | + } |
|
| 714 | 775 | } |
| 715 | 776 | |
| 716 | 777 | call_integration_hook('integrate_save_board', array($board_id, &$boardOptions)); |
@@ -720,22 +781,29 @@ discard block |
||
| 720 | 781 | { |
| 721 | 782 | // New boards by default go to the bottom of the category. |
| 722 | 783 | if (empty($this->_req->post->new_cat)) |
| 723 | - $boardOptions['target_category'] = (int) $this->_req->post->cur_cat; |
|
| 784 | + { |
|
| 785 | + $boardOptions['target_category'] = (int) $this->_req->post->cur_cat; |
|
| 786 | + } |
|
| 724 | 787 | if (!isset($boardOptions['move_to'])) |
| 725 | - $boardOptions['move_to'] = 'bottom'; |
|
| 788 | + { |
|
| 789 | + $boardOptions['move_to'] = 'bottom'; |
|
| 790 | + } |
|
| 726 | 791 | |
| 727 | 792 | createBoard($boardOptions); |
| 728 | 793 | } |
| 729 | 794 | // ...or update an existing board. |
| 730 | - else |
|
| 731 | - modifyBoard($board_id, $boardOptions); |
|
| 795 | + else { |
|
| 796 | + modifyBoard($board_id, $boardOptions); |
|
| 797 | + } |
|
| 732 | 798 | } |
| 733 | 799 | elseif (isset($this->_req->post->delete) && !isset($this->_req->post->confirmation) && !isset($this->_req->post->no_children)) |
| 734 | 800 | { |
| 735 | - if ($posts) { |
|
| 801 | + if ($posts) |
|
| 802 | + { |
|
| 736 | 803 | throw new Elk_Exception('mboards_delete_board_has_posts'); |
| 737 | 804 | } |
| 738 | - else { |
|
| 805 | + else |
|
| 806 | + { |
|
| 739 | 807 | $this->action_board(); |
| 740 | 808 | } |
| 741 | 809 | return; |
@@ -743,25 +811,32 @@ discard block |
||
| 743 | 811 | elseif (isset($this->_req->post->delete)) |
| 744 | 812 | { |
| 745 | 813 | // First, check if our board still has posts or topics. |
| 746 | - if ($posts) { |
|
| 814 | + if ($posts) |
|
| 815 | + { |
|
| 747 | 816 | throw new Elk_Exception('mboards_delete_board_has_posts'); |
| 748 | 817 | } |
| 749 | 818 | else if (isset($this->_req->post->delete_action) && $this->_req->post->delete_action == 1) |
| 750 | 819 | { |
| 751 | 820 | // Check if we are moving all the current sub-boards first - before we start deleting! |
| 752 | 821 | if (empty($this->_req->post->board_to)) |
| 753 | - throw new Elk_Exception('mboards_delete_board_error'); |
|
| 822 | + { |
|
| 823 | + throw new Elk_Exception('mboards_delete_board_error'); |
|
| 824 | + } |
|
| 754 | 825 | |
| 755 | 826 | deleteBoards(array($board_id), (int) $this->_req->post->board_to); |
| 756 | 827 | } |
| 757 | - else |
|
| 758 | - deleteBoards(array($board_id), 0); |
|
| 828 | + else { |
|
| 829 | + deleteBoards(array($board_id), 0); |
|
| 830 | + } |
|
| 759 | 831 | } |
| 760 | 832 | |
| 761 | 833 | if (isset($this->_req->query->rid) && $this->_req->query->rid == 'permissions') |
| 762 | - redirectexit('action=admin;area=permissions;sa=board;' . $context['session_var'] . '=' . $context['session_id']); |
|
| 763 | - else |
|
| 764 | - redirectexit('action=admin;area=manageboards'); |
|
| 834 | + { |
|
| 835 | + redirectexit('action=admin;area=permissions;sa=board;' . $context['session_var'] . '=' . $context['session_id']); |
|
| 836 | + } |
|
| 837 | + else { |
|
| 838 | + redirectexit('action=admin;area=manageboards'); |
|
| 839 | + } |
|
| 765 | 840 | } |
| 766 | 841 | |
| 767 | 842 | /** |
@@ -826,7 +901,9 @@ discard block |
||
| 826 | 901 | $boards = getBoardList(array('override_permissions' => true, 'not_redirection' => true), true); |
| 827 | 902 | $recycle_boards = array(''); |
| 828 | 903 | foreach ($boards as $board) |
| 829 | - $recycle_boards[$board['id_board']] = $board['cat_name'] . ' - ' . $board['board_name']; |
|
| 904 | + { |
|
| 905 | + $recycle_boards[$board['id_board']] = $board['cat_name'] . ' - ' . $board['board_name']; |
|
| 906 | + } |
|
| 830 | 907 | |
| 831 | 908 | // Here and the board settings... |
| 832 | 909 | $config_vars = array( |
@@ -242,14 +242,19 @@ discard block |
||
| 242 | 242 | $this->_req->post->holiday = $this->_req->getPost('holiday', 'intval', 0); |
| 243 | 243 | |
| 244 | 244 | if (isset($this->_req->post->delete)) |
| 245 | - removeHolidays($this->_req->post->holiday); |
|
| 245 | + { |
|
| 246 | + removeHolidays($this->_req->post->holiday); |
|
| 247 | + } |
|
| 246 | 248 | else |
| 247 | 249 | { |
| 248 | 250 | $date = Util::strftime($this->_req->post->year <= 4 ? '0004-%m-%d' : '%Y-%m-%d', mktime(0, 0, 0, $this->_req->post->month, $this->_req->post->day, $this->_req->post->year)); |
| 249 | 251 | if (isset($this->_req->post->edit)) |
| 250 | - editHoliday($this->_req->post->holiday, $date, $this->_req->post->title); |
|
| 251 | - else |
|
| 252 | - insertHoliday($date, $this->_req->post->title); |
|
| 252 | + { |
|
| 253 | + editHoliday($this->_req->post->holiday, $date, $this->_req->post->title); |
|
| 254 | + } |
|
| 255 | + else { |
|
| 256 | + insertHoliday($date, $this->_req->post->title); |
|
| 257 | + } |
|
| 253 | 258 | } |
| 254 | 259 | |
| 255 | 260 | redirectexit('action=admin;area=managecalendar;sa=holidays'); |
@@ -267,8 +272,9 @@ discard block |
||
| 267 | 272 | ); |
| 268 | 273 | } |
| 269 | 274 | // If it's not new load the data. |
| 270 | - else |
|
| 271 | - $context['holiday'] = getHoliday($this->_req->query->holiday); |
|
| 275 | + else { |
|
| 276 | + $context['holiday'] = getHoliday($this->_req->query->holiday); |
|
| 277 | + } |
|
| 272 | 278 | |
| 273 | 279 | // Last day for the drop down? |
| 274 | 280 | $context['holiday']['last_day'] = (int) Util::strftime('%d', mktime(0, 0, 0, $context['holiday']['month'] == 12 ? 1 : $context['holiday']['month'] + 1, 0, $context['holiday']['month'] == 12 ? $context['holiday']['year'] + 1 : $context['holiday']['year'])); |
@@ -337,7 +343,9 @@ discard block |
||
| 337 | 343 | $boards_list = getBoardList(array('override_permissions' => true, 'not_redirection' => true), true); |
| 338 | 344 | $boards = array(''); |
| 339 | 345 | foreach ($boards_list as $board) |
| 340 | - $boards[$board['id_board']] = $board['cat_name'] . ' - ' . $board['board_name']; |
|
| 346 | + { |
|
| 347 | + $boards[$board['id_board']] = $board['cat_name'] . ' - ' . $board['board_name']; |
|
| 348 | + } |
|
| 341 | 349 | |
| 342 | 350 | // Look, all the calendar settings - of which there are many! |
| 343 | 351 | $config_vars = array( |
@@ -113,7 +113,9 @@ discard block |
||
| 113 | 113 | $context['package_download_broken'] = !is_writable(BOARDDIR . '/packages') || !is_writable(BOARDDIR . '/packages/installed.list'); |
| 114 | 114 | |
| 115 | 115 | if ($context['package_download_broken']) |
| 116 | - $this->ftp_connect(); |
|
| 116 | + { |
|
| 117 | + $this->ftp_connect(); |
|
| 118 | + } |
|
| 117 | 119 | } |
| 118 | 120 | |
| 119 | 121 | /** |
@@ -130,11 +132,14 @@ discard block |
||
| 130 | 132 | |
| 131 | 133 | // Browsing the packages from a server |
| 132 | 134 | if (isset($this->_req->query->server)) |
| 133 | - list($name, $url, $server) = $this->_package_server(); |
|
| 135 | + { |
|
| 136 | + list($name, $url, $server) = $this->_package_server(); |
|
| 137 | + } |
|
| 134 | 138 | |
| 135 | 139 | // Minimum required parameter did not exist so dump out. |
| 136 | - else |
|
| 137 | - throw new Elk_Exception('couldnt_connect', false); |
|
| 140 | + else { |
|
| 141 | + throw new Elk_Exception('couldnt_connect', false); |
|
| 142 | + } |
|
| 138 | 143 | |
| 139 | 144 | // Might take some time. |
| 140 | 145 | detectServer()->setTimeLimit(60); |
@@ -159,11 +164,15 @@ discard block |
||
| 159 | 164 | // Look through the list of installed mods and get version information for the compare |
| 160 | 165 | $installed_adds = array(); |
| 161 | 166 | foreach ($instadds as $installed_add) |
| 162 | - $installed_adds[$installed_add['package_id']] = $installed_add['version']; |
|
| 167 | + { |
|
| 168 | + $installed_adds[$installed_add['package_id']] = $installed_add['version']; |
|
| 169 | + } |
|
| 163 | 170 | |
| 164 | 171 | $the_version = strtr(FORUM_VERSION, array('ElkArte ' => '')); |
| 165 | 172 | if (!empty($_SESSION['version_emulate'])) |
| 166 | - $the_version = $_SESSION['version_emulate']; |
|
| 173 | + { |
|
| 174 | + $the_version = $_SESSION['version_emulate']; |
|
| 175 | + } |
|
| 167 | 176 | |
| 168 | 177 | // Parse the json file, each section contains a category of addons |
| 169 | 178 | $packageNum = 0; |
@@ -352,12 +361,15 @@ discard block |
||
| 352 | 361 | // not always accurate, especially when dealing with repos. So for now just put in in no conflict mode |
| 353 | 362 | // and do the save. |
| 354 | 363 | if ($this->_req->getQuery('area') === 'packageservers' && $this->_req->getQuery('sa') === 'download') |
| 355 | - $this->_req->query->auto = true; |
|
| 364 | + { |
|
| 365 | + $this->_req->query->auto = true; |
|
| 366 | + } |
|
| 356 | 367 | |
| 357 | 368 | return str_replace($invalid, '_', $newname) . $matches[6]; |
| 358 | 369 | } |
| 359 | - else |
|
| 360 | - return basename($name); |
|
| 370 | + else { |
|
| 371 | + return basename($name); |
|
| 372 | + } |
|
| 361 | 373 | } |
| 362 | 374 | |
| 363 | 375 | /** |
@@ -384,13 +396,18 @@ discard block |
||
| 384 | 396 | |
| 385 | 397 | // Security is good... |
| 386 | 398 | if (isset($this->_req->query->server)) |
| 387 | - checkSession('get'); |
|
| 388 | - else |
|
| 389 | - checkSession(); |
|
| 399 | + { |
|
| 400 | + checkSession('get'); |
|
| 401 | + } |
|
| 402 | + else { |
|
| 403 | + checkSession(); |
|
| 404 | + } |
|
| 390 | 405 | |
| 391 | 406 | // To download something, we need either a valid server or url. |
| 392 | 407 | if (empty($this->_req->query->server) && (!empty($this->_req->query->get) && !empty($this->_req->post->package))) |
| 393 | - throw new Elk_Exception('package_get_error_is_zero', false); |
|
| 408 | + { |
|
| 409 | + throw new Elk_Exception('package_get_error_is_zero', false); |
|
| 410 | + } |
|
| 394 | 411 | |
| 395 | 412 | // Start off with nothing |
| 396 | 413 | $server = ''; |
@@ -418,8 +435,9 @@ discard block |
||
| 418 | 435 | $url = isset($path_url['dirname']) ? $path_url['dirname'] . '/' : ''; |
| 419 | 436 | } |
| 420 | 437 | // Not found or some monkey business |
| 421 | - else |
|
| 422 | - throw new Elk_Exception('package_cant_download', false); |
|
| 438 | + else { |
|
| 439 | + throw new Elk_Exception('package_cant_download', false); |
|
| 440 | + } |
|
| 423 | 441 | } |
| 424 | 442 | // Entered a url and optional filename |
| 425 | 443 | elseif (isset($this->_req->post->byurl) && !empty($this->_req->post->filename)) |
@@ -443,13 +461,16 @@ discard block |
||
| 443 | 461 | $ext = substr($package_name, strrpos(substr($package_name, 0, -3), '.')); |
| 444 | 462 | $package_name = substr($package_name, 0, strrpos(substr($package_name, 0, -3), '.')) . '_'; |
| 445 | 463 | } |
| 446 | - else |
|
| 447 | - $ext = ''; |
|
| 464 | + else { |
|
| 465 | + $ext = ''; |
|
| 466 | + } |
|
| 448 | 467 | |
| 449 | 468 | // Find the first available free name |
| 450 | 469 | $i = 1; |
| 451 | 470 | while (file_exists(BOARDDIR . '/packages/' . $package_name . $i . $ext)) |
| 452 | - $i++; |
|
| 471 | + { |
|
| 472 | + $i++; |
|
| 473 | + } |
|
| 453 | 474 | |
| 454 | 475 | $package_name = $package_name . $i . $ext; |
| 455 | 476 | } |
@@ -458,7 +479,9 @@ discard block |
||
| 458 | 479 | $packageInfo = getPackageInfo($url . $package_id); |
| 459 | 480 | |
| 460 | 481 | if (!is_array($packageInfo)) |
| 461 | - throw new Elk_Exception($packageInfo); |
|
| 482 | + { |
|
| 483 | + throw new Elk_Exception($packageInfo); |
|
| 484 | + } |
|
| 462 | 485 | |
| 463 | 486 | // Save the package to disk, use FTP if necessary |
| 464 | 487 | create_chmod_control( |
@@ -473,7 +496,9 @@ discard block |
||
| 473 | 496 | |
| 474 | 497 | // Done! Did we get this package automatically? |
| 475 | 498 | if (preg_match('~^http://[\w_\-]+\.elkarte\.net/~', $package_id) == 1 && strpos($package_id, 'dlattach') === false && isset($this->_req->query->auto)) |
| 476 | - redirectexit('action=admin;area=packages;sa=install;package=' . $package_name); |
|
| 499 | + { |
|
| 500 | + redirectexit('action=admin;area=packages;sa=install;package=' . $package_name); |
|
| 501 | + } |
|
| 477 | 502 | |
| 478 | 503 | // You just downloaded a addon from SERVER_NAME_GOES_HERE. |
| 479 | 504 | $context['package_server'] = $server; |
@@ -482,16 +507,25 @@ discard block |
||
| 482 | 507 | $context['package'] = getPackageInfo($package_name); |
| 483 | 508 | |
| 484 | 509 | if (!is_array($context['package'])) |
| 485 | - throw new Elk_Exception('package_cant_download', false); |
|
| 510 | + { |
|
| 511 | + throw new Elk_Exception('package_cant_download', false); |
|
| 512 | + } |
|
| 486 | 513 | |
| 487 | 514 | if ($context['package']['type'] === 'modification' || $context['package']['type'] === 'addon') |
| 488 | - $context['package']['install']['link'] = '<a class="linkbutton" href="' . $scripturl . '?action=admin;area=packages;sa=install;package=' . $context['package']['filename'] . '">' . $txt['install_mod'] . '</a>'; |
|
| 515 | + { |
|
| 516 | + $context['package']['install']['link'] = '<a class="linkbutton" href="' . $scripturl . '?action=admin;area=packages;sa=install;package=' . $context['package']['filename'] . '">' . $txt['install_mod'] . '</a>'; |
|
| 517 | + } |
|
| 489 | 518 | elseif ($context['package']['type'] === 'avatar') |
| 490 | - $context['package']['install']['link'] = '<a class="linkbutton" href="' . $scripturl . '?action=admin;area=packages;sa=install;package=' . $context['package']['filename'] . '">' . $txt['use_avatars'] . '</a>'; |
|
| 519 | + { |
|
| 520 | + $context['package']['install']['link'] = '<a class="linkbutton" href="' . $scripturl . '?action=admin;area=packages;sa=install;package=' . $context['package']['filename'] . '">' . $txt['use_avatars'] . '</a>'; |
|
| 521 | + } |
|
| 491 | 522 | elseif ($context['package']['type'] === 'language') |
| 492 | - $context['package']['install']['link'] = '<a class="linkbutton" href="' . $scripturl . '?action=admin;area=packages;sa=install;package=' . $context['package']['filename'] . '">' . $txt['add_languages'] . '</a>'; |
|
| 493 | - else |
|
| 494 | - $context['package']['install']['link'] = ''; |
|
| 523 | + { |
|
| 524 | + $context['package']['install']['link'] = '<a class="linkbutton" href="' . $scripturl . '?action=admin;area=packages;sa=install;package=' . $context['package']['filename'] . '">' . $txt['add_languages'] . '</a>'; |
|
| 525 | + } |
|
| 526 | + else { |
|
| 527 | + $context['package']['install']['link'] = ''; |
|
| 528 | + } |
|
| 495 | 529 | |
| 496 | 530 | $context['package']['list_files']['link'] = '<a class="linkbutton" href="' . $scripturl . '?action=admin;area=packages;sa=list;package=' . $context['package']['filename'] . '">' . $txt['list_files'] . '</a>'; |
| 497 | 531 | |
@@ -519,7 +553,9 @@ discard block |
||
| 519 | 553 | if (isset($this->_req->query->server)) |
| 520 | 554 | { |
| 521 | 555 | if ($this->_req->query->server == '') |
| 522 | - redirectexit('action=admin;area=packageservers'); |
|
| 556 | + { |
|
| 557 | + redirectexit('action=admin;area=packageservers'); |
|
| 558 | + } |
|
| 523 | 559 | |
| 524 | 560 | $server = $this->_req->getQuery('server', 'intval'); |
| 525 | 561 | |
@@ -530,7 +566,9 @@ discard block |
||
| 530 | 566 | |
| 531 | 567 | // If server does not exist then dump out. |
| 532 | 568 | if (empty($url)) |
| 533 | - throw new Elk_Exception('couldnt_connect', false); |
|
| 569 | + { |
|
| 570 | + throw new Elk_Exception('couldnt_connect', false); |
|
| 571 | + } |
|
| 534 | 572 | } |
| 535 | 573 | |
| 536 | 574 | return array($name, $url, $server); |
@@ -551,15 +589,21 @@ discard block |
||
| 551 | 589 | // @todo Use FTP if the packages directory is not writable. |
| 552 | 590 | // Check the file was even sent! |
| 553 | 591 | if (!isset($_FILES['package']['name']) || $_FILES['package']['name'] == '') |
| 554 | - throw new Elk_Exception('package_upload_error_nofile'); |
|
| 592 | + { |
|
| 593 | + throw new Elk_Exception('package_upload_error_nofile'); |
|
| 594 | + } |
|
| 555 | 595 | elseif (!is_uploaded_file($_FILES['package']['tmp_name']) || (ini_get('open_basedir') == '' && !file_exists($_FILES['package']['tmp_name']))) |
| 556 | - throw new Elk_Exception('package_upload_error_failed'); |
|
| 596 | + { |
|
| 597 | + throw new Elk_Exception('package_upload_error_failed'); |
|
| 598 | + } |
|
| 557 | 599 | |
| 558 | 600 | // Make sure it has a sane filename. |
| 559 | 601 | $_FILES['package']['name'] = preg_replace(array('/\s/', '/\.[\.]+/', '/[^\w_\.\-]/'), array('_', '.', ''), $_FILES['package']['name']); |
| 560 | 602 | |
| 561 | 603 | if (strtolower(substr($_FILES['package']['name'], -4)) !== '.zip' && strtolower(substr($_FILES['package']['name'], -4)) !== '.tgz' && strtolower(substr($_FILES['package']['name'], -7)) !== '.tar.gz') |
| 562 | - throw new Elk_Exception('package_upload_error_supports', false, array('zip, tgz, tar.gz')); |
|
| 604 | + { |
|
| 605 | + throw new Elk_Exception('package_upload_error_supports', false, array('zip, tgz, tar.gz')); |
|
| 606 | + } |
|
| 563 | 607 | |
| 564 | 608 | // We only need the filename... |
| 565 | 609 | $packageName = basename($_FILES['package']['name']); |
@@ -569,7 +613,9 @@ discard block |
||
| 569 | 613 | |
| 570 | 614 | // @todo Maybe just roll it like we do for downloads? |
| 571 | 615 | if (file_exists($destination)) |
| 572 | - throw new Elk_Exception('package_upload_error_exists'); |
|
| 616 | + { |
|
| 617 | + throw new Elk_Exception('package_upload_error_exists'); |
|
| 618 | + } |
|
| 573 | 619 | |
| 574 | 620 | // Now move the file. |
| 575 | 621 | move_uploaded_file($_FILES['package']['tmp_name'], $destination); |
@@ -601,12 +647,16 @@ discard block |
||
| 601 | 647 | { |
| 602 | 648 | // No need to check these |
| 603 | 649 | if ($package->getFilename() == $packageName) |
| 604 | - continue; |
|
| 650 | + { |
|
| 651 | + continue; |
|
| 652 | + } |
|
| 605 | 653 | |
| 606 | 654 | // Read package info for the archive we found |
| 607 | 655 | $packageInfo = getPackageInfo($package->getFilename()); |
| 608 | 656 | if (!is_array($packageInfo)) |
| 609 | - continue; |
|
| 657 | + { |
|
| 658 | + continue; |
|
| 659 | + } |
|
| 610 | 660 | |
| 611 | 661 | // If it was already uploaded under another name don't upload it again. |
| 612 | 662 | if ($packageInfo['id'] == $context['package']['id'] && compareVersions($packageInfo['version'], $context['package']['version']) == 0) |
@@ -624,13 +674,20 @@ discard block |
||
| 624 | 674 | } |
| 625 | 675 | |
| 626 | 676 | if ($context['package']['type'] === 'modification' || $context['package']['type'] === 'addon') |
| 627 | - $context['package']['install']['link'] = '<a class="linkbutton" href="' . $scripturl . '?action=admin;area=packages;sa=install;package=' . $context['package']['filename'] . '">' . $txt['install_mod'] . '</a>'; |
|
| 677 | + { |
|
| 678 | + $context['package']['install']['link'] = '<a class="linkbutton" href="' . $scripturl . '?action=admin;area=packages;sa=install;package=' . $context['package']['filename'] . '">' . $txt['install_mod'] . '</a>'; |
|
| 679 | + } |
|
| 628 | 680 | elseif ($context['package']['type'] === 'avatar') |
| 629 | - $context['package']['install']['link'] = '<a class="linkbutton" href="' . $scripturl . '?action=admin;area=packages;sa=install;package=' . $context['package']['filename'] . '">' . $txt['use_avatars'] . '</a>'; |
|
| 681 | + { |
|
| 682 | + $context['package']['install']['link'] = '<a class="linkbutton" href="' . $scripturl . '?action=admin;area=packages;sa=install;package=' . $context['package']['filename'] . '">' . $txt['use_avatars'] . '</a>'; |
|
| 683 | + } |
|
| 630 | 684 | elseif ($context['package']['type'] === 'language') |
| 631 | - $context['package']['install']['link'] = '<a class="linkbutton" href="' . $scripturl . '?action=admin;area=packages;sa=install;package=' . $context['package']['filename'] . '">' . $txt['add_languages'] . '</a>'; |
|
| 632 | - else |
|
| 633 | - $context['package']['install']['link'] = ''; |
|
| 685 | + { |
|
| 686 | + $context['package']['install']['link'] = '<a class="linkbutton" href="' . $scripturl . '?action=admin;area=packages;sa=install;package=' . $context['package']['filename'] . '">' . $txt['add_languages'] . '</a>'; |
|
| 687 | + } |
|
| 688 | + else { |
|
| 689 | + $context['package']['install']['link'] = ''; |
|
| 690 | + } |
|
| 634 | 691 | |
| 635 | 692 | $context['package']['list_files']['link'] = '<a class="linkbutton" href="' . $scripturl . '?action=admin;area=packages;sa=list;package=' . $context['package']['filename'] . '">' . $txt['list_files'] . '</a>'; |
| 636 | 693 | |
@@ -654,7 +711,9 @@ discard block |
||
| 654 | 711 | |
| 655 | 712 | // If they put a slash on the end, get rid of it. |
| 656 | 713 | if (substr($this->_req->post->serverurl, -1) === '/') |
| 657 | - $this->_req->post->serverurl = substr($this->_req->post->serverurl, 0, -1); |
|
| 714 | + { |
|
| 715 | + $this->_req->post->serverurl = substr($this->_req->post->serverurl, 0, -1); |
|
| 716 | + } |
|
| 658 | 717 | |
| 659 | 718 | // Are they both nice and clean? |
| 660 | 719 | $servername = trim(Util::htmlspecialchars($this->_req->post->servername)); |
@@ -712,7 +771,9 @@ discard block |
||
| 712 | 771 | |
| 713 | 772 | // Give FTP a chance... |
| 714 | 773 | if ($context['package_download_broken']) |
| 715 | - $this->ftp_connect(); |
|
| 774 | + { |
|
| 775 | + $this->ftp_connect(); |
|
| 776 | + } |
|
| 716 | 777 | } |
| 717 | 778 | |
| 718 | 779 | /** |
@@ -769,15 +830,21 @@ discard block |
||
| 769 | 830 | } |
| 770 | 831 | // ...or we failed |
| 771 | 832 | elseif ($ftp->error !== false && !isset($ftp_error)) |
| 772 | - $ftp_error = $ftp->last_message === null ? '' : $ftp->last_message; |
|
| 833 | + { |
|
| 834 | + $ftp_error = $ftp->last_message === null ? '' : $ftp->last_message; |
|
| 835 | + } |
|
| 773 | 836 | |
| 774 | 837 | list ($username, $detect_path, $found_path) = $ftp->detect_path(BOARDDIR); |
| 775 | 838 | |
| 776 | 839 | if ($found_path || !isset($this->_req->post->ftp_path)) |
| 777 | - $this->_req->post->ftp_path = $detect_path; |
|
| 840 | + { |
|
| 841 | + $this->_req->post->ftp_path = $detect_path; |
|
| 842 | + } |
|
| 778 | 843 | |
| 779 | 844 | if (!isset($this->_req->post->ftp_username)) |
| 780 | - $this->_req->post->ftp_username = $username; |
|
| 845 | + { |
|
| 846 | + $this->_req->post->ftp_username = $username; |
|
| 847 | + } |
|
| 781 | 848 | |
| 782 | 849 | // Fill the boxes for a FTP connection with data from the previous attempt too, if any |
| 783 | 850 | $context['package_ftp'] = array( |
@@ -82,7 +82,9 @@ discard block |
||
| 82 | 82 | |
| 83 | 83 | // Now - finally - call the right place! |
| 84 | 84 | if (isset($admin_include_data['file'])) |
| 85 | - require_once($admin_include_data['file']); |
|
| 85 | + { |
|
| 86 | + require_once($admin_include_data['file']); |
|
| 87 | + } |
|
| 86 | 88 | |
| 87 | 89 | callMenu($admin_include_data); |
| 88 | 90 | } |
@@ -612,16 +614,20 @@ discard block |
||
| 612 | 614 | ); |
| 613 | 615 | |
| 614 | 616 | if (isset($admin_include_data['current_area']) && $admin_include_data['current_area'] != 'index') |
| 615 | - $context['linktree'][] = array( |
|
| 617 | + { |
|
| 618 | + $context['linktree'][] = array( |
|
| 616 | 619 | 'url' => $scripturl . '?action=admin;area=' . $admin_include_data['current_area'] . ';' . $context['session_var'] . '=' . $context['session_id'], |
| 617 | 620 | 'name' => $admin_include_data['label'], |
| 618 | 621 | ); |
| 622 | + } |
|
| 619 | 623 | |
| 620 | 624 | if (!empty($admin_include_data['current_subsection']) && $admin_include_data['subsections'][$admin_include_data['current_subsection']][0] != $admin_include_data['label']) |
| 621 | - $context['linktree'][] = array( |
|
| 625 | + { |
|
| 626 | + $context['linktree'][] = array( |
|
| 622 | 627 | 'url' => $scripturl . '?action=admin;area=' . $admin_include_data['current_area'] . ';sa=' . $admin_include_data['current_subsection'] . ';' . $context['session_var'] . '=' . $context['session_id'], |
| 623 | 628 | 'name' => $admin_include_data['subsections'][$admin_include_data['current_subsection']][0], |
| 624 | 629 | ); |
| 630 | + } |
|
| 625 | 631 | } |
| 626 | 632 | |
| 627 | 633 | /** |
@@ -779,9 +785,12 @@ discard block |
||
| 779 | 785 | |
| 780 | 786 | // You did remember to enter something to search for, otherwise its easy |
| 781 | 787 | if ($context['search_term'] === '') |
| 782 | - $context['search_results'] = array(); |
|
| 783 | - else |
|
| 784 | - $action->dispatch($subAction); |
|
| 788 | + { |
|
| 789 | + $context['search_results'] = array(); |
|
| 790 | + } |
|
| 791 | + else { |
|
| 792 | + $action->dispatch($subAction); |
|
| 793 | + } |
|
| 785 | 794 | } |
| 786 | 795 | |
| 787 | 796 | /** |
@@ -925,7 +934,9 @@ discard block |
||
| 925 | 934 | |
| 926 | 935 | // Encode the search data. |
| 927 | 936 | foreach ($postVars as $k => $v) |
| 928 | - $postVars[$k] = urlencode($v); |
|
| 937 | + { |
|
| 938 | + $postVars[$k] = urlencode($v); |
|
| 939 | + } |
|
| 929 | 940 | |
| 930 | 941 | // This is what we will send. |
| 931 | 942 | $postVars = implode('+', $postVars); |
@@ -938,7 +949,9 @@ discard block |
||
| 938 | 949 | |
| 939 | 950 | // If we didn't get any xml back we are in trouble - perhaps the doc site is overloaded? |
| 940 | 951 | if (!$search_results || preg_match('~<' . '\?xml\sversion="\d+\.\d+"\?' . '>\s*(<api>.+?</api>)~is', $search_results, $matches) !== 1) |
| 941 | - throw new Elk_Exception('cannot_connect_doc_site'); |
|
| 952 | + { |
|
| 953 | + throw new Elk_Exception('cannot_connect_doc_site'); |
|
| 954 | + } |
|
| 942 | 955 | |
| 943 | 956 | $search_results = !empty($matches[1]) ? $matches[1] : ''; |
| 944 | 957 | |
@@ -85,7 +85,9 @@ |
||
| 85 | 85 | |
| 86 | 86 | // Disable if invalid values would result |
| 87 | 87 | if (isset($this->_req->post->custom_avatar_enabled) && $this->_req->post->custom_avatar_enabled == 1 && (empty($this->_req->post->custom_avatar_dir) || empty($this->_req->post->custom_avatar_url))) |
| 88 | - $this->_req->post->custom_avatar_enabled = 0; |
|
| 88 | + { |
|
| 89 | + $this->_req->post->custom_avatar_enabled = 0; |
|
| 90 | + } |
|
| 89 | 91 | |
| 90 | 92 | $settingsForm->setConfigValues((array) $this->_req->post); |
| 91 | 93 | $settingsForm->save(); |
@@ -97,7 +97,9 @@ discard block |
||
| 97 | 97 | |
| 98 | 98 | // Some settings may not be enabled, disallow these from the tabs as appropriate. |
| 99 | 99 | if (empty($modSettings['messageIcons_enable'])) |
| 100 | - $context[$context['admin_menu_name']]['tab_data']['tabs']['editicons']['disabled'] = true; |
|
| 100 | + { |
|
| 101 | + $context[$context['admin_menu_name']]['tab_data']['tabs']['editicons']['disabled'] = true; |
|
| 102 | + } |
|
| 101 | 103 | |
| 102 | 104 | if (empty($modSettings['smiley_enable'])) |
| 103 | 105 | { |
@@ -141,7 +143,9 @@ discard block |
||
| 141 | 143 | |
| 142 | 144 | // Make sure that the smileys are in the right order after enabling them. |
| 143 | 145 | if (isset($this->_req->post->smiley_enable)) |
| 144 | - sortSmileyTable(); |
|
| 146 | + { |
|
| 147 | + sortSmileyTable(); |
|
| 148 | + } |
|
| 145 | 149 | |
| 146 | 150 | call_integration_hook('integrate_save_smiley_settings'); |
| 147 | 151 | |
@@ -220,12 +224,14 @@ discard block |
||
| 220 | 224 | $context['smiley_sets'] = explode(',', $modSettings['smiley_sets_known']); |
| 221 | 225 | $set_names = explode("\n", $modSettings['smiley_sets_names']); |
| 222 | 226 | foreach ($context['smiley_sets'] as $i => $set) |
| 223 | - $context['smiley_sets'][$i] = array( |
|
| 227 | + { |
|
| 228 | + $context['smiley_sets'][$i] = array( |
|
| 224 | 229 | 'id' => $i, |
| 225 | 230 | 'path' => htmlspecialchars($set, ENT_COMPAT, 'UTF-8'), |
| 226 | 231 | 'name' => htmlspecialchars(stripslashes($set_names[$i]), ENT_COMPAT, 'UTF-8'), |
| 227 | 232 | 'selected' => $set == $modSettings['smiley_sets_default'] |
| 228 | 233 | ); |
| 234 | + } |
|
| 229 | 235 | |
| 230 | 236 | // Importing any smileys from an existing set? |
| 231 | 237 | $this->_subActionImport(); |
@@ -362,7 +368,9 @@ discard block |
||
| 362 | 368 | foreach ($this->_req->post->smiley_set as $id => $val) |
| 363 | 369 | { |
| 364 | 370 | if (isset($set_paths[$id], $set_names[$id]) && !empty($id)) |
| 365 | - unset($set_paths[$id], $set_names[$id]); |
|
| 371 | + { |
|
| 372 | + unset($set_paths[$id], $set_names[$id]); |
|
| 373 | + } |
|
| 366 | 374 | } |
| 367 | 375 | |
| 368 | 376 | // Update the modsettings with the new values |
@@ -374,7 +382,9 @@ discard block |
||
| 374 | 382 | } |
| 375 | 383 | // Add a new smiley set. |
| 376 | 384 | elseif (!empty($this->_req->post->add)) |
| 377 | - $context['sub_action'] = 'modifyset'; |
|
| 385 | + { |
|
| 386 | + $context['sub_action'] = 'modifyset'; |
|
| 387 | + } |
|
| 378 | 388 | // Create or modify a smiley set. |
| 379 | 389 | elseif (isset($this->_req->post->set)) |
| 380 | 390 | { |
@@ -387,7 +397,9 @@ discard block |
||
| 387 | 397 | if ($set == -1 && isset($this->_req->post->smiley_sets_path)) |
| 388 | 398 | { |
| 389 | 399 | if (in_array($this->_req->post->smiley_sets_path, $set_paths)) |
| 390 | - throw new Elk_Exception('smiley_set_already_exists'); |
|
| 400 | + { |
|
| 401 | + throw new Elk_Exception('smiley_set_already_exists'); |
|
| 402 | + } |
|
| 391 | 403 | |
| 392 | 404 | updateSettings(array( |
| 393 | 405 | 'smiley_sets_known' => $modSettings['smiley_sets_known'] . ',' . $this->_req->post->smiley_sets_path, |
@@ -400,11 +412,15 @@ discard block |
||
| 400 | 412 | { |
| 401 | 413 | // Make sure the smiley set exists. |
| 402 | 414 | if (!isset($set_paths[$set]) || !isset($set_names[$set])) |
| 403 | - throw new Elk_Exception('smiley_set_not_found'); |
|
| 415 | + { |
|
| 416 | + throw new Elk_Exception('smiley_set_not_found'); |
|
| 417 | + } |
|
| 404 | 418 | |
| 405 | 419 | // Make sure the path is not yet used by another smileyset. |
| 406 | 420 | if (in_array($this->_req->post->smiley_sets_path, $set_paths) && $this->_req->post->smiley_sets_path != $set_paths[$set]) |
| 407 | - throw new Elk_Exception('smiley_set_path_already_used'); |
|
| 421 | + { |
|
| 422 | + throw new Elk_Exception('smiley_set_path_already_used'); |
|
| 423 | + } |
|
| 408 | 424 | |
| 409 | 425 | $set_paths[$set] = $this->_req->post->smiley_sets_path; |
| 410 | 426 | $set_names[$set] = $this->_req->post->smiley_sets_name; |
@@ -417,7 +433,9 @@ discard block |
||
| 417 | 433 | |
| 418 | 434 | // The user might have checked to also import smileys. |
| 419 | 435 | if (!empty($this->_req->post->smiley_sets_import)) |
| 420 | - $this->importSmileys($this->_req->post->smiley_sets_path); |
|
| 436 | + { |
|
| 437 | + $this->importSmileys($this->_req->post->smiley_sets_path); |
|
| 438 | + } |
|
| 421 | 439 | } |
| 422 | 440 | |
| 423 | 441 | // No matter what, reset the cache |
@@ -437,13 +455,15 @@ discard block |
||
| 437 | 455 | { |
| 438 | 456 | $set = $this->_req->getQuery('set', 'intval', -1); |
| 439 | 457 | if ($set == -1 || !isset($context['smiley_sets'][$set])) |
| 440 | - $context['current_set'] = array( |
|
| 458 | + { |
|
| 459 | + $context['current_set'] = array( |
|
| 441 | 460 | 'id' => '-1', |
| 442 | 461 | 'path' => '', |
| 443 | 462 | 'name' => '', |
| 444 | 463 | 'selected' => false, |
| 445 | 464 | 'is_new' => true, |
| 446 | 465 | ); |
| 466 | + } |
|
| 447 | 467 | else |
| 448 | 468 | { |
| 449 | 469 | $context['current_set'] = &$context['smiley_sets'][$set]; |
@@ -457,19 +477,25 @@ discard block |
||
| 457 | 477 | while ($entry = $dir->read()) |
| 458 | 478 | { |
| 459 | 479 | if (in_array(strrchr($entry, '.'), array('.jpg', '.gif', '.jpeg', '.png', '.webp'))) |
| 460 | - $smileys[strtolower($entry)] = $entry; |
|
| 480 | + { |
|
| 481 | + $smileys[strtolower($entry)] = $entry; |
|
| 482 | + } |
|
| 461 | 483 | } |
| 462 | 484 | $dir->close(); |
| 463 | 485 | |
| 464 | 486 | if (empty($smileys)) |
| 465 | - throw new Elk_Exception('smiley_set_dir_not_found', false, array($context['current_set']['name'])); |
|
| 487 | + { |
|
| 488 | + throw new Elk_Exception('smiley_set_dir_not_found', false, array($context['current_set']['name'])); |
|
| 489 | + } |
|
| 466 | 490 | |
| 467 | 491 | // Exclude the smileys that are already in the database. |
| 468 | 492 | $found = smileyExists($smileys); |
| 469 | 493 | foreach ($found as $smiley) |
| 470 | 494 | { |
| 471 | 495 | if (isset($smileys[$smiley])) |
| 472 | - unset($smileys[$smiley]); |
|
| 496 | + { |
|
| 497 | + unset($smileys[$smiley]); |
|
| 498 | + } |
|
| 473 | 499 | } |
| 474 | 500 | |
| 475 | 501 | $context['current_set']['can_import'] = count($smileys); |
@@ -487,12 +513,14 @@ discard block |
||
| 487 | 513 | while ($entry = $dir->read()) |
| 488 | 514 | { |
| 489 | 515 | if (!in_array($entry, array('.', '..')) && is_dir($modSettings['smileys_dir'] . '/' . $entry)) |
| 490 | - $context['smiley_set_dirs'][] = array( |
|
| 516 | + { |
|
| 517 | + $context['smiley_set_dirs'][] = array( |
|
| 491 | 518 | 'id' => $entry, |
| 492 | 519 | 'path' => $modSettings['smileys_dir'] . '/' . $entry, |
| 493 | 520 | 'selectable' => $entry == $context['current_set']['path'] || !in_array($entry, explode(',', $modSettings['smiley_sets_known'])), |
| 494 | 521 | 'current' => $entry == $context['current_set']['path'], |
| 495 | 522 | ); |
| 523 | + } |
|
| 496 | 524 | } |
| 497 | 525 | $dir->close(); |
| 498 | 526 | } |
@@ -516,7 +544,9 @@ discard block |
||
| 516 | 544 | |
| 517 | 545 | // Sanity check - then import. |
| 518 | 546 | if (isset($context['smiley_sets'][$set])) |
| 519 | - $this->importSmileys(un_htmlspecialchars($context['smiley_sets'][$set]['path'])); |
|
| 547 | + { |
|
| 548 | + $this->importSmileys(un_htmlspecialchars($context['smiley_sets'][$set]['path'])); |
|
| 549 | + } |
|
| 520 | 550 | |
| 521 | 551 | // Force the process to continue. |
| 522 | 552 | $context['sub_action'] = 'modifyset'; |
@@ -541,12 +571,14 @@ discard block |
||
| 541 | 571 | |
| 542 | 572 | $set_names = explode("\n", $modSettings['smiley_sets_names']); |
| 543 | 573 | foreach ($context['smiley_sets'] as $i => $set) |
| 544 | - $context['smiley_sets'][$i] = array( |
|
| 574 | + { |
|
| 575 | + $context['smiley_sets'][$i] = array( |
|
| 545 | 576 | 'id' => $i, |
| 546 | 577 | 'path' => htmlspecialchars($set, ENT_COMPAT, 'UTF-8'), |
| 547 | 578 | 'name' => htmlspecialchars(stripslashes($set_names[$i]), ENT_COMPAT, 'UTF-8'), |
| 548 | 579 | 'selected' => $set == $modSettings['smiley_sets_default'] |
| 549 | 580 | ); |
| 581 | + } |
|
| 550 | 582 | |
| 551 | 583 | // Submitting a form? |
| 552 | 584 | if (isset($this->_req->post->{$context['session_var']}, $this->_req->post->smiley_code)) |
@@ -563,11 +595,15 @@ discard block |
||
| 563 | 595 | |
| 564 | 596 | // Make sure some code was entered. |
| 565 | 597 | if (empty($this->_req->post->smiley_code)) |
| 566 | - throw new Elk_Exception('smiley_has_no_code'); |
|
| 598 | + { |
|
| 599 | + throw new Elk_Exception('smiley_has_no_code'); |
|
| 600 | + } |
|
| 567 | 601 | |
| 568 | 602 | // Check whether the new code has duplicates. It should be unique. |
| 569 | 603 | if (validateDuplicateSmiley($this->_req->post->smiley_code)) |
| 570 | - throw new Elk_Exception('smiley_not_unique'); |
|
| 604 | + { |
|
| 605 | + throw new Elk_Exception('smiley_not_unique'); |
|
| 606 | + } |
|
| 571 | 607 | |
| 572 | 608 | // If we are uploading - check all the smiley sets are writable! |
| 573 | 609 | if ($this->_req->post->method !== 'existing') |
@@ -576,39 +612,51 @@ discard block |
||
| 576 | 612 | foreach ($context['smiley_sets'] as $set) |
| 577 | 613 | { |
| 578 | 614 | if (!is_writable($context['smileys_dir'] . '/' . un_htmlspecialchars($set['path']))) |
| 579 | - $writeErrors[] = $set['path']; |
|
| 615 | + { |
|
| 616 | + $writeErrors[] = $set['path']; |
|
| 617 | + } |
|
| 580 | 618 | } |
| 581 | 619 | |
| 582 | 620 | if (!empty($writeErrors)) |
| 583 | - throw new Elk_Exception('smileys_upload_error_notwritable', true, array(implode(', ', $writeErrors))); |
|
| 621 | + { |
|
| 622 | + throw new Elk_Exception('smileys_upload_error_notwritable', true, array(implode(', ', $writeErrors))); |
|
| 623 | + } |
|
| 584 | 624 | } |
| 585 | 625 | |
| 586 | 626 | // Uploading just one smiley for all of them? |
| 587 | 627 | if (isset($this->_req->post->sameall) && isset($_FILES['uploadSmiley']['name']) && $_FILES['uploadSmiley']['name'] != '') |
| 588 | 628 | { |
| 589 | 629 | if (!is_uploaded_file($_FILES['uploadSmiley']['tmp_name']) || (ini_get('open_basedir') == '' && !file_exists($_FILES['uploadSmiley']['tmp_name']))) |
| 590 | - throw new Elk_Exception('smileys_upload_error'); |
|
| 630 | + { |
|
| 631 | + throw new Elk_Exception('smileys_upload_error'); |
|
| 632 | + } |
|
| 591 | 633 | |
| 592 | 634 | // Sorry, no spaces, dots, or anything else but letters allowed. |
| 593 | 635 | $_FILES['uploadSmiley']['name'] = preg_replace(array('/\s/', '/\.[\.]+/', '/[^\w_\.\-]/'), array('_', '.', ''), $_FILES['uploadSmiley']['name']); |
| 594 | 636 | |
| 595 | 637 | // We only allow image files - it's THAT simple - no messing around here... |
| 596 | 638 | if (!in_array(strtolower(substr(strrchr($_FILES['uploadSmiley']['name'], '.'), 1)), $allowedTypes)) |
| 597 | - throw new Elk_Exception('smileys_upload_error_types', false, array(implode(', ', $allowedTypes))); |
|
| 639 | + { |
|
| 640 | + throw new Elk_Exception('smileys_upload_error_types', false, array(implode(', ', $allowedTypes))); |
|
| 641 | + } |
|
| 598 | 642 | |
| 599 | 643 | // We only need the filename... |
| 600 | 644 | $destName = basename($_FILES['uploadSmiley']['name']); |
| 601 | 645 | |
| 602 | 646 | // Make sure they aren't trying to upload a nasty file - for their own good here! |
| 603 | 647 | if (in_array(strtolower($destName), $disabledFiles)) |
| 604 | - throw new Elk_Exception('smileys_upload_error_illegal'); |
|
| 648 | + { |
|
| 649 | + throw new Elk_Exception('smileys_upload_error_illegal'); |
|
| 650 | + } |
|
| 605 | 651 | |
| 606 | 652 | // Check if the file already exists... and if not move it to EVERY smiley set directory. |
| 607 | 653 | $i = 0; |
| 608 | 654 | |
| 609 | 655 | // Keep going until we find a set the file doesn't exist in. (or maybe it exists in all of them?) |
| 610 | 656 | while (isset($context['smiley_sets'][$i]) && file_exists($context['smileys_dir'] . '/' . un_htmlspecialchars($context['smiley_sets'][$i]['path']) . '/' . $destName)) |
| 611 | - $i++; |
|
| 657 | + { |
|
| 658 | + $i++; |
|
| 659 | + } |
|
| 612 | 660 | |
| 613 | 661 | // Okay, we're going to put the smiley right here, since it's not there yet! |
| 614 | 662 | if (isset($context['smiley_sets'][$i]['path'])) |
@@ -624,7 +672,9 @@ discard block |
||
| 624 | 672 | |
| 625 | 673 | // The file is already there! Don't overwrite it! |
| 626 | 674 | if (file_exists($currentPath)) |
| 627 | - continue; |
|
| 675 | + { |
|
| 676 | + continue; |
|
| 677 | + } |
|
| 628 | 678 | |
| 629 | 679 | // Okay, so copy the first one we made to here. |
| 630 | 680 | copy($smileyLocation, $currentPath); |
@@ -642,12 +692,18 @@ discard block |
||
| 642 | 692 | foreach ($_FILES as $name => $dummy) |
| 643 | 693 | { |
| 644 | 694 | if ($_FILES[$name]['name'] == '') |
| 645 | - throw new Elk_Exception('smileys_upload_error_blank'); |
|
| 695 | + { |
|
| 696 | + throw new Elk_Exception('smileys_upload_error_blank'); |
|
| 697 | + } |
|
| 646 | 698 | |
| 647 | 699 | if (empty($newName)) |
| 648 | - $newName = basename($_FILES[$name]['name']); |
|
| 700 | + { |
|
| 701 | + $newName = basename($_FILES[$name]['name']); |
|
| 702 | + } |
|
| 649 | 703 | elseif (basename($_FILES[$name]['name']) != $newName) |
| 650 | - throw new Elk_Exception('smileys_upload_error_name'); |
|
| 704 | + { |
|
| 705 | + throw new Elk_Exception('smileys_upload_error_name'); |
|
| 706 | + } |
|
| 651 | 707 | } |
| 652 | 708 | |
| 653 | 709 | foreach ($context['smiley_sets'] as $i => $set) |
@@ -656,30 +712,40 @@ discard block |
||
| 656 | 712 | $set['path'] = un_htmlspecialchars($set['path']); |
| 657 | 713 | |
| 658 | 714 | if (!isset($_FILES['individual_' . $set['name']]['name']) || $_FILES['individual_' . $set['name']]['name'] == '') |
| 659 | - continue; |
|
| 715 | + { |
|
| 716 | + continue; |
|
| 717 | + } |
|
| 660 | 718 | |
| 661 | 719 | // Got one... |
| 662 | 720 | if (!is_uploaded_file($_FILES['individual_' . $set['name']]['tmp_name']) || (ini_get('open_basedir') == '' && !file_exists($_FILES['individual_' . $set['name']]['tmp_name']))) |
| 663 | - throw new Elk_Exception('smileys_upload_error'); |
|
| 721 | + { |
|
| 722 | + throw new Elk_Exception('smileys_upload_error'); |
|
| 723 | + } |
|
| 664 | 724 | |
| 665 | 725 | // Sorry, no spaces, dots, or anything else but letters allowed. |
| 666 | 726 | $_FILES['individual_' . $set['name']]['name'] = preg_replace(array('/\s/', '/\.[\.]+/', '/[^\w_\.\-]/'), array('_', '.', ''), $_FILES['individual_' . $set['name']]['name']); |
| 667 | 727 | |
| 668 | 728 | // We only allow image files - it's THAT simple - no messing around here... |
| 669 | 729 | if (!in_array(strtolower(substr(strrchr($_FILES['individual_' . $set['name']]['name'], '.'), 1)), $allowedTypes)) |
| 670 | - throw new Elk_Exception('smileys_upload_error_types', false, array(implode(', ', $allowedTypes))); |
|
| 730 | + { |
|
| 731 | + throw new Elk_Exception('smileys_upload_error_types', false, array(implode(', ', $allowedTypes))); |
|
| 732 | + } |
|
| 671 | 733 | |
| 672 | 734 | // We only need the filename... |
| 673 | 735 | $destName = basename($_FILES['individual_' . $set['name']]['name']); |
| 674 | 736 | |
| 675 | 737 | // Make sure they aren't trying to upload a nasty file - for their own good here! |
| 676 | 738 | if (in_array(strtolower($destName), $disabledFiles)) |
| 677 | - throw new Elk_Exception('smileys_upload_error_illegal'); |
|
| 739 | + { |
|
| 740 | + throw new Elk_Exception('smileys_upload_error_illegal'); |
|
| 741 | + } |
|
| 678 | 742 | |
| 679 | 743 | // If the file exists - ignore it. |
| 680 | 744 | $smileyLocation = $context['smileys_dir'] . '/' . $set['path'] . '/' . $destName; |
| 681 | 745 | if (file_exists($smileyLocation)) |
| 682 | - continue; |
|
| 746 | + { |
|
| 747 | + continue; |
|
| 748 | + } |
|
| 683 | 749 | |
| 684 | 750 | // Finally - move the image! |
| 685 | 751 | move_uploaded_file($_FILES['individual_' . $set['name']]['tmp_name'], $smileyLocation); |
@@ -692,7 +758,9 @@ discard block |
||
| 692 | 758 | |
| 693 | 759 | // Also make sure a filename was given. |
| 694 | 760 | if (empty($this->_req->post->smiley_filename)) |
| 695 | - throw new Elk_Exception('smiley_has_no_filename'); |
|
| 761 | + { |
|
| 762 | + throw new Elk_Exception('smiley_has_no_filename'); |
|
| 763 | + } |
|
| 696 | 764 | |
| 697 | 765 | // Find the position on the right. |
| 698 | 766 | $smiley_order = '0'; |
@@ -702,7 +770,9 @@ discard block |
||
| 702 | 770 | $smiley_order = nextSmileyLocation($this->_req->post->smiley_location); |
| 703 | 771 | |
| 704 | 772 | if (empty($smiley_order)) |
| 705 | - $smiley_order = '0'; |
|
| 773 | + { |
|
| 774 | + $smiley_order = '0'; |
|
| 775 | + } |
|
| 706 | 776 | } |
| 707 | 777 | $param = array( |
| 708 | 778 | $this->_req->post->smiley_code, |
@@ -728,16 +798,20 @@ discard block |
||
| 728 | 798 | foreach ($context['smiley_sets'] as $smiley_set) |
| 729 | 799 | { |
| 730 | 800 | if (!file_exists($context['smileys_dir'] . '/' . un_htmlspecialchars($smiley_set['path']))) |
| 731 | - continue; |
|
| 801 | + { |
|
| 802 | + continue; |
|
| 803 | + } |
|
| 732 | 804 | |
| 733 | 805 | $dir = dir($context['smileys_dir'] . '/' . un_htmlspecialchars($smiley_set['path'])); |
| 734 | 806 | while ($entry = $dir->read()) |
| 735 | 807 | { |
| 736 | 808 | if (!in_array($entry, $context['filenames']) && in_array(strrchr($entry, '.'), array('.jpg', '.gif', '.jpeg', '.png', '.webp'))) |
| 737 | - $context['filenames'][strtolower($entry)] = array( |
|
| 809 | + { |
|
| 810 | + $context['filenames'][strtolower($entry)] = array( |
|
| 738 | 811 | 'id' => htmlspecialchars($entry, ENT_COMPAT, 'UTF-8'), |
| 739 | 812 | 'selected' => false, |
| 740 | 813 | ); |
| 814 | + } |
|
| 741 | 815 | } |
| 742 | 816 | $dir->close(); |
| 743 | 817 | } |
@@ -780,10 +854,14 @@ discard block |
||
| 780 | 854 | if (isset($this->_req->post->smiley_action) && !empty($this->_req->post->checked_smileys)) |
| 781 | 855 | { |
| 782 | 856 | foreach ($this->_req->post->checked_smileys as $id => $smiley_id) |
| 783 | - $this->_req->post->checked_smileys[$id] = (int) $smiley_id; |
|
| 857 | + { |
|
| 858 | + $this->_req->post->checked_smileys[$id] = (int) $smiley_id; |
|
| 859 | + } |
|
| 784 | 860 | |
| 785 | 861 | if ($this->_req->post->smiley_action == 'delete') |
| 786 | - deleteSmileys($this->_req->post->checked_smileys); |
|
| 862 | + { |
|
| 863 | + deleteSmileys($this->_req->post->checked_smileys); |
|
| 864 | + } |
|
| 787 | 865 | // Changing the status of the smiley? |
| 788 | 866 | else |
| 789 | 867 | { |
@@ -794,7 +872,9 @@ discard block |
||
| 794 | 872 | 'popup' => 2 |
| 795 | 873 | ); |
| 796 | 874 | if (isset($displayTypes[$this->_req->post->smiley_action])) |
| 797 | - updateSmileyDisplayType($this->_req->post->checked_smileys, $displayTypes[$this->_req->post->smiley_action]); |
|
| 875 | + { |
|
| 876 | + updateSmileyDisplayType($this->_req->post->checked_smileys, $displayTypes[$this->_req->post->smiley_action]); |
|
| 877 | + } |
|
| 798 | 878 | } |
| 799 | 879 | } |
| 800 | 880 | // Create/modify a smiley. |
@@ -804,7 +884,9 @@ discard block |
||
| 804 | 884 | |
| 805 | 885 | // Is it a delete? |
| 806 | 886 | if (!empty($this->_req->post->deletesmiley)) |
| 807 | - deleteSmileys(array($this->_req->post->smiley)); |
|
| 887 | + { |
|
| 888 | + deleteSmileys(array($this->_req->post->smiley)); |
|
| 889 | + } |
|
| 808 | 890 | // Otherwise an edit. |
| 809 | 891 | else |
| 810 | 892 | { |
@@ -814,15 +896,21 @@ discard block |
||
| 814 | 896 | |
| 815 | 897 | // Make sure some code was entered. |
| 816 | 898 | if (empty($this->_req->post->smiley_code)) |
| 817 | - throw new Elk_Exception('smiley_has_no_code'); |
|
| 899 | + { |
|
| 900 | + throw new Elk_Exception('smiley_has_no_code'); |
|
| 901 | + } |
|
| 818 | 902 | |
| 819 | 903 | // Also make sure a filename was given. |
| 820 | 904 | if (empty($this->_req->post->smiley_filename)) |
| 821 | - throw new Elk_Exception('smiley_has_no_filename'); |
|
| 905 | + { |
|
| 906 | + throw new Elk_Exception('smiley_has_no_filename'); |
|
| 907 | + } |
|
| 822 | 908 | |
| 823 | 909 | // Check whether the new code has duplicates. It should be unique. |
| 824 | 910 | if (validateDuplicateSmiley($this->_req->post->smiley_code, $this->_req->post->smiley)) |
| 825 | - throw new Elk_Exception('smiley_not_unique'); |
|
| 911 | + { |
|
| 912 | + throw new Elk_Exception('smiley_not_unique'); |
|
| 913 | + } |
|
| 826 | 914 | |
| 827 | 915 | $param = array( |
| 828 | 916 | 'smiley_location' => $this->_req->post->smiley_location, |
@@ -845,12 +933,14 @@ discard block |
||
| 845 | 933 | $context['smiley_sets'] = explode(',', $modSettings['smiley_sets_known']); |
| 846 | 934 | $set_names = explode("\n", $modSettings['smiley_sets_names']); |
| 847 | 935 | foreach ($context['smiley_sets'] as $i => $set) |
| 848 | - $context['smiley_sets'][$i] = array( |
|
| 936 | + { |
|
| 937 | + $context['smiley_sets'][$i] = array( |
|
| 849 | 938 | 'id' => $i, |
| 850 | 939 | 'path' => htmlspecialchars($set, ENT_COMPAT, 'UTF-8'), |
| 851 | 940 | 'name' => htmlspecialchars(stripslashes($set_names[$i]), ENT_COMPAT, 'UTF-8'), |
| 852 | 941 | 'selected' => $set == $modSettings['smiley_sets_default'] |
| 853 | 942 | ); |
| 943 | + } |
|
| 854 | 944 | |
| 855 | 945 | // Prepare overview of all (custom) smileys. |
| 856 | 946 | if ($context['sub_action'] == 'editsmileys') |
@@ -867,8 +957,10 @@ discard block |
||
| 867 | 957 | $smileyset_option_list = ' |
| 868 | 958 | <select name="set" onchange="changeSet(this.options[this.selectedIndex].value);">'; |
| 869 | 959 | foreach ($context['smiley_sets'] as $smiley_set) |
| 870 | - $smileyset_option_list .= ' |
|
| 960 | + { |
|
| 961 | + $smileyset_option_list .= ' |
|
| 871 | 962 | <option value="' . $smiley_set['path'] . '"' . ($modSettings['smiley_sets_default'] == $smiley_set['path'] ? ' selected="selected"' : '') . '>' . $smiley_set['name'] . '</option>'; |
| 963 | + } |
|
| 872 | 964 | $smileyset_option_list .= ' |
| 873 | 965 | </select>'; |
| 874 | 966 | |
@@ -932,11 +1024,16 @@ discard block |
||
| 932 | 1024 | global $txt; |
| 933 | 1025 | |
| 934 | 1026 | if (empty($rowData['hidden'])) |
| 935 | - return $txt['smileys_location_form']; |
|
| 1027 | + { |
|
| 1028 | + return $txt['smileys_location_form']; |
|
| 1029 | + } |
|
| 936 | 1030 | elseif ($rowData['hidden'] == 1) |
| 937 | - return $txt['smileys_location_hidden']; |
|
| 938 | - else |
|
| 939 | - return $txt['smileys_location_popup']; |
|
| 1031 | + { |
|
| 1032 | + return $txt['smileys_location_hidden']; |
|
| 1033 | + } |
|
| 1034 | + else { |
|
| 1035 | + return $txt['smileys_location_popup']; |
|
| 1036 | + } |
|
| 940 | 1037 | }, |
| 941 | 1038 | ), |
| 942 | 1039 | 'sort' => array( |
@@ -953,18 +1050,24 @@ discard block |
||
| 953 | 1050 | global $context, $txt, $modSettings; |
| 954 | 1051 | |
| 955 | 1052 | if (empty($modSettings['smileys_dir']) || !is_dir($modSettings['smileys_dir'])) |
| 956 | - return htmlspecialchars($rowData['description'], ENT_COMPAT, 'UTF-8'); |
|
| 1053 | + { |
|
| 1054 | + return htmlspecialchars($rowData['description'], ENT_COMPAT, 'UTF-8'); |
|
| 1055 | + } |
|
| 957 | 1056 | |
| 958 | 1057 | // Check if there are smileys missing in some sets. |
| 959 | 1058 | $missing_sets = array(); |
| 960 | 1059 | foreach ($context['smiley_sets'] as $smiley_set) |
| 961 | - if (!file_exists(sprintf('%1$s/%2$s/%3$s', $modSettings['smileys_dir'], $smiley_set['path'], $rowData['filename']))) |
|
| 1060 | + { |
|
| 1061 | + if (!file_exists(sprintf('%1$s/%2$s/%3$s', $modSettings['smileys_dir'], $smiley_set['path'], $rowData['filename']))) |
|
| 962 | 1062 | $missing_sets[] = $smiley_set['path']; |
| 1063 | + } |
|
| 963 | 1064 | |
| 964 | 1065 | $description = htmlspecialchars($rowData['description'], ENT_COMPAT, 'UTF-8'); |
| 965 | 1066 | |
| 966 | 1067 | if (!empty($missing_sets)) |
| 967 | - $description .= sprintf('<br /><span class="smalltext"><strong>%1$s:</strong> %2$s</span>', $txt['smileys_not_found_in_set'], implode(', ', $missing_sets)); |
|
| 1068 | + { |
|
| 1069 | + $description .= sprintf('<br /><span class="smalltext"><strong>%1$s:</strong> %2$s</span>', $txt['smileys_not_found_in_set'], implode(', ', $missing_sets)); |
|
| 1070 | + } |
|
| 968 | 1071 | |
| 969 | 1072 | return $description; |
| 970 | 1073 | }, |
@@ -1080,12 +1183,14 @@ discard block |
||
| 1080 | 1183 | $context['smiley_sets'] = explode(',', $modSettings['smiley_sets_known']); |
| 1081 | 1184 | $set_names = explode("\n", $modSettings['smiley_sets_names']); |
| 1082 | 1185 | foreach ($context['smiley_sets'] as $i => $set) |
| 1083 | - $context['smiley_sets'][$i] = array( |
|
| 1186 | + { |
|
| 1187 | + $context['smiley_sets'][$i] = array( |
|
| 1084 | 1188 | 'id' => $i, |
| 1085 | 1189 | 'path' => htmlspecialchars($set, ENT_COMPAT, 'UTF-8'), |
| 1086 | 1190 | 'name' => htmlspecialchars(stripslashes($set_names[$i]), ENT_COMPAT, 'UTF-8'), |
| 1087 | 1191 | 'selected' => $set == $modSettings['smiley_sets_default'] |
| 1088 | 1192 | ); |
| 1193 | + } |
|
| 1089 | 1194 | |
| 1090 | 1195 | $context['selected_set'] = $modSettings['smiley_sets_default']; |
| 1091 | 1196 | |
@@ -1096,16 +1201,20 @@ discard block |
||
| 1096 | 1201 | foreach ($context['smiley_sets'] as $smiley_set) |
| 1097 | 1202 | { |
| 1098 | 1203 | if (!file_exists($context['smileys_dir'] . '/' . un_htmlspecialchars($smiley_set['path']))) |
| 1099 | - continue; |
|
| 1204 | + { |
|
| 1205 | + continue; |
|
| 1206 | + } |
|
| 1100 | 1207 | |
| 1101 | 1208 | $dir = dir($context['smileys_dir'] . '/' . un_htmlspecialchars($smiley_set['path'])); |
| 1102 | 1209 | while ($entry = $dir->read()) |
| 1103 | 1210 | { |
| 1104 | 1211 | if (!in_array($entry, $context['filenames']) && in_array(strrchr($entry, '.'), array('.jpg', '.gif', '.jpeg', '.png', '.webp'))) |
| 1105 | - $context['filenames'][strtolower($entry)] = array( |
|
| 1212 | + { |
|
| 1213 | + $context['filenames'][strtolower($entry)] = array( |
|
| 1106 | 1214 | 'id' => htmlspecialchars($entry, ENT_COMPAT, 'UTF-8'), |
| 1107 | 1215 | 'selected' => false, |
| 1108 | 1216 | ); |
| 1217 | + } |
|
| 1109 | 1218 | } |
| 1110 | 1219 | $dir->close(); |
| 1111 | 1220 | } |
@@ -1119,7 +1228,9 @@ discard block |
||
| 1119 | 1228 | $context['current_smiley']['description'] = htmlspecialchars($context['current_smiley']['description'], ENT_COMPAT, 'UTF-8'); |
| 1120 | 1229 | |
| 1121 | 1230 | if (isset($context['filenames'][strtolower($context['current_smiley']['filename'])])) |
| 1122 | - $context['filenames'][strtolower($context['current_smiley']['filename'])]['selected'] = true; |
|
| 1231 | + { |
|
| 1232 | + $context['filenames'][strtolower($context['current_smiley']['filename'])]['selected'] = true; |
|
| 1233 | + } |
|
| 1123 | 1234 | } |
| 1124 | 1235 | } |
| 1125 | 1236 | |
@@ -1147,7 +1258,9 @@ discard block |
||
| 1147 | 1258 | { |
| 1148 | 1259 | $deleteIcons = array(); |
| 1149 | 1260 | foreach ($this->_req->post->checked_icons as $icon) |
| 1150 | - $deleteIcons[] = (int) $icon; |
|
| 1261 | + { |
|
| 1262 | + $deleteIcons[] = (int) $icon; |
|
| 1263 | + } |
|
| 1151 | 1264 | |
| 1152 | 1265 | // Do the actual delete! |
| 1153 | 1266 | deleteMessageIcons($deleteIcons); |
@@ -1159,36 +1272,50 @@ discard block |
||
| 1159 | 1272 | |
| 1160 | 1273 | // Do some preparation with the data... like check the icon exists *somewhere* |
| 1161 | 1274 | if (strpos($this->_req->post->icon_filename, '.png') !== false) |
| 1162 | - $this->_req->post->icon_filename = substr($this->_req->post->icon_filename, 0, -4); |
|
| 1275 | + { |
|
| 1276 | + $this->_req->post->icon_filename = substr($this->_req->post->icon_filename, 0, -4); |
|
| 1277 | + } |
|
| 1163 | 1278 | |
| 1164 | 1279 | if (!file_exists($settings['default_theme_dir'] . '/images/post/' . $this->_req->post->icon_filename . '.png')) |
| 1165 | - throw new Elk_Exception('icon_not_found'); |
|
| 1280 | + { |
|
| 1281 | + throw new Elk_Exception('icon_not_found'); |
|
| 1282 | + } |
|
| 1166 | 1283 | // There is a 16 character limit on message icons... |
| 1167 | 1284 | elseif (strlen($this->_req->post->icon_filename) > 16) |
| 1168 | - throw new Elk_Exception('icon_name_too_long'); |
|
| 1285 | + { |
|
| 1286 | + throw new Elk_Exception('icon_name_too_long'); |
|
| 1287 | + } |
|
| 1169 | 1288 | elseif ($this->_req->post->icon_location == $this->_req->query->icon && !empty($this->_req->query->icon)) |
| 1170 | - throw new Elk_Exception('icon_after_itself'); |
|
| 1289 | + { |
|
| 1290 | + throw new Elk_Exception('icon_after_itself'); |
|
| 1291 | + } |
|
| 1171 | 1292 | |
| 1172 | 1293 | // First do the sorting... if this is an edit reduce the order of everything after it by one ;) |
| 1173 | 1294 | if ($this->_req->query->icon != 0) |
| 1174 | 1295 | { |
| 1175 | 1296 | $oldOrder = $context['icons'][$this->_req->query->icon]['true_order']; |
| 1176 | 1297 | foreach ($context['icons'] as $id => $data) |
| 1177 | - if ($data['true_order'] > $oldOrder) |
|
| 1298 | + { |
|
| 1299 | + if ($data['true_order'] > $oldOrder) |
|
| 1178 | 1300 | $context['icons'][$id]['true_order']--; |
| 1301 | + } |
|
| 1179 | 1302 | } |
| 1180 | 1303 | |
| 1181 | 1304 | // If there are no existing icons and this is a new one, set the id to 1 (mainly for non-mysql) |
| 1182 | 1305 | if (empty($this->_req->query->icon) && empty($context['icons'])) |
| 1183 | - $this->_req->query->icon = 1; |
|
| 1306 | + { |
|
| 1307 | + $this->_req->query->icon = 1; |
|
| 1308 | + } |
|
| 1184 | 1309 | |
| 1185 | 1310 | // Get the new order. |
| 1186 | 1311 | $newOrder = $this->_req->post->icon_location == 0 ? 0 : $context['icons'][$this->_req->post->icon_location]['true_order'] + 1; |
| 1187 | 1312 | |
| 1188 | 1313 | // Do the same, but with the one that used to be after this icon, done to avoid conflict. |
| 1189 | 1314 | foreach ($context['icons'] as $id => $data) |
| 1190 | - if ($data['true_order'] >= $newOrder) |
|
| 1315 | + { |
|
| 1316 | + if ($data['true_order'] >= $newOrder) |
|
| 1191 | 1317 | $context['icons'][$id]['true_order']++; |
| 1318 | + } |
|
| 1192 | 1319 | |
| 1193 | 1320 | // Finally set the current icon's position! |
| 1194 | 1321 | $context['icons'][$this->_req->query->icon]['true_order'] = $newOrder; |
@@ -1204,15 +1331,20 @@ discard block |
||
| 1204 | 1331 | foreach ($context['icons'] as $id => $icon) |
| 1205 | 1332 | { |
| 1206 | 1333 | if ($id != 0) |
| 1207 | - $iconInsert[] = array($id, $icon['board_id'], $icon['title'], $icon['filename'], $icon['true_order']); |
|
| 1208 | - else |
|
| 1209 | - $iconInsert_new[] = array($icon['board_id'], $icon['title'], $icon['filename'], $icon['true_order']); |
|
| 1334 | + { |
|
| 1335 | + $iconInsert[] = array($id, $icon['board_id'], $icon['title'], $icon['filename'], $icon['true_order']); |
|
| 1336 | + } |
|
| 1337 | + else { |
|
| 1338 | + $iconInsert_new[] = array($icon['board_id'], $icon['title'], $icon['filename'], $icon['true_order']); |
|
| 1339 | + } |
|
| 1210 | 1340 | } |
| 1211 | 1341 | |
| 1212 | 1342 | updateMessageIcon($iconInsert); |
| 1213 | 1343 | |
| 1214 | 1344 | if (!empty($iconInsert_new)) |
| 1215 | - addMessageIcon($iconInsert_new); |
|
| 1345 | + { |
|
| 1346 | + addMessageIcon($iconInsert_new); |
|
| 1347 | + } |
|
| 1216 | 1348 | |
| 1217 | 1349 | // Flush the cache so the changes are reflected |
| 1218 | 1350 | Cache::instance()->remove('posting_icons-' . (int) $this->_req->post->icon_board); |
@@ -1223,7 +1355,9 @@ discard block |
||
| 1223 | 1355 | |
| 1224 | 1356 | // Unless we're adding a new thing, we'll escape |
| 1225 | 1357 | if (!isset($this->_req->post->add)) |
| 1226 | - redirectexit('action=admin;area=smileys;sa=editicons'); |
|
| 1358 | + { |
|
| 1359 | + redirectexit('action=admin;area=smileys;sa=editicons'); |
|
| 1360 | + } |
|
| 1227 | 1361 | } |
| 1228 | 1362 | |
| 1229 | 1363 | $context[$context['admin_menu_name']]['current_subsection'] = 'editicons'; |
@@ -1350,7 +1484,9 @@ discard block |
||
| 1350 | 1484 | |
| 1351 | 1485 | // Get the properties of the current icon from the icon list. |
| 1352 | 1486 | if (!$context['new_icon']) |
| 1353 | - $context['icon'] = $context['icons'][$this->_req->query->icon]; |
|
| 1487 | + { |
|
| 1488 | + $context['icon'] = $context['icons'][$this->_req->query->icon]; |
|
| 1489 | + } |
|
| 1354 | 1490 | |
| 1355 | 1491 | // Get a list of boards needed for assigning this icon to a specific board. |
| 1356 | 1492 | $boardListOptions = array( |
@@ -1380,7 +1516,9 @@ discard block |
||
| 1380 | 1516 | $this->_req->query->source = empty($this->_req->query->source) ? 0 : (int) $this->_req->query->source; |
| 1381 | 1517 | |
| 1382 | 1518 | if (empty($this->_req->query->source)) |
| 1383 | - throw new Elk_Exception('smiley_not_found'); |
|
| 1519 | + { |
|
| 1520 | + throw new Elk_Exception('smiley_not_found'); |
|
| 1521 | + } |
|
| 1384 | 1522 | |
| 1385 | 1523 | $smiley = array(); |
| 1386 | 1524 | |
@@ -1390,7 +1528,9 @@ discard block |
||
| 1390 | 1528 | |
| 1391 | 1529 | $smiley = getSmileyPosition($this->_req->query->location, $this->_req->query->after); |
| 1392 | 1530 | if (empty($smiley)) |
| 1393 | - throw new Elk_Exception('smiley_not_found'); |
|
| 1531 | + { |
|
| 1532 | + throw new Elk_Exception('smiley_not_found'); |
|
| 1533 | + } |
|
| 1394 | 1534 | } |
| 1395 | 1535 | else |
| 1396 | 1536 | { |
@@ -1407,13 +1547,15 @@ discard block |
||
| 1407 | 1547 | |
| 1408 | 1548 | // Make sure all rows are sequential. |
| 1409 | 1549 | foreach (array_keys($context['smileys']) as $location) |
| 1410 | - $context['smileys'][$location] = array( |
|
| 1550 | + { |
|
| 1551 | + $context['smileys'][$location] = array( |
|
| 1411 | 1552 | 'id' => $location, |
| 1412 | 1553 | 'title' => $location === 'postform' ? $txt['smileys_location_form'] : $txt['smileys_location_popup'], |
| 1413 | 1554 | 'description' => $location === 'postform' ? $txt['smileys_location_form_description'] : $txt['smileys_location_popup_description'], |
| 1414 | 1555 | 'last_row' => count($context['smileys'][$location]['rows']), |
| 1415 | 1556 | 'rows' => array_values($context['smileys'][$location]['rows']), |
| 1416 | 1557 | ); |
| 1558 | + } |
|
| 1417 | 1559 | |
| 1418 | 1560 | // Check & fix smileys that are not ordered properly in the database. |
| 1419 | 1561 | foreach (array_keys($context['smileys']) as $location) |
@@ -1430,8 +1572,10 @@ discard block |
||
| 1430 | 1572 | |
| 1431 | 1573 | // Make sure the smiley order is always sequential. |
| 1432 | 1574 | foreach ($smiley_row as $order_id => $smiley) |
| 1433 | - if ($order_id != $smiley['order']) |
|
| 1575 | + { |
|
| 1576 | + if ($order_id != $smiley['order']) |
|
| 1434 | 1577 | updateSmileyOrder($smiley['id'], $order_id); |
| 1578 | + } |
|
| 1435 | 1579 | } |
| 1436 | 1580 | } |
| 1437 | 1581 | |
@@ -1471,12 +1615,16 @@ discard block |
||
| 1471 | 1615 | |
| 1472 | 1616 | // Check that the smiley is from simplemachines.org, for now... maybe add mirroring later. |
| 1473 | 1617 | if (!isAuthorizedServer($this->_req->query->set_gz) == 0) |
| 1474 | - throw new Elk_Exception('not_valid_server'); |
|
| 1618 | + { |
|
| 1619 | + throw new Elk_Exception('not_valid_server'); |
|
| 1620 | + } |
|
| 1475 | 1621 | |
| 1476 | 1622 | $destination = BOARDDIR . '/packages/' . $base_name; |
| 1477 | 1623 | |
| 1478 | 1624 | if (file_exists($destination)) |
| 1479 | - throw new Elk_Exception('package_upload_error_exists'); |
|
| 1625 | + { |
|
| 1626 | + throw new Elk_Exception('package_upload_error_exists'); |
|
| 1627 | + } |
|
| 1480 | 1628 | |
| 1481 | 1629 | // Let's copy it to the packages directory |
| 1482 | 1630 | file_put_contents($destination, fetch_web_data($this->_req->query->set_gz)); |
@@ -1492,11 +1640,15 @@ discard block |
||
| 1492 | 1640 | } |
| 1493 | 1641 | |
| 1494 | 1642 | if (!file_exists($destination)) |
| 1495 | - throw new Elk_Exception('package_no_file', false); |
|
| 1643 | + { |
|
| 1644 | + throw new Elk_Exception('package_no_file', false); |
|
| 1645 | + } |
|
| 1496 | 1646 | |
| 1497 | 1647 | // Make sure temp directory exists and is empty. |
| 1498 | 1648 | if (file_exists(BOARDDIR . '/packages/temp')) |
| 1499 | - deltree(BOARDDIR . '/packages/temp', false); |
|
| 1649 | + { |
|
| 1650 | + deltree(BOARDDIR . '/packages/temp', false); |
|
| 1651 | + } |
|
| 1500 | 1652 | |
| 1501 | 1653 | if (!mktree(BOARDDIR . '/packages/temp', 0755)) |
| 1502 | 1654 | { |
@@ -1509,7 +1661,9 @@ discard block |
||
| 1509 | 1661 | |
| 1510 | 1662 | deltree(BOARDDIR . '/packages/temp', false); |
| 1511 | 1663 | if (!mktree(BOARDDIR . '/packages/temp', 0777)) |
| 1512 | - throw new Elk_Exception('package_cant_download', false); |
|
| 1664 | + { |
|
| 1665 | + throw new Elk_Exception('package_cant_download', false); |
|
| 1666 | + } |
|
| 1513 | 1667 | } |
| 1514 | 1668 | } |
| 1515 | 1669 | |
@@ -1517,7 +1671,9 @@ discard block |
||
| 1517 | 1671 | |
| 1518 | 1672 | // @todo needs to change the URL in the next line ;) |
| 1519 | 1673 | if (!$extracted) |
| 1520 | - throw new Elk_Exception('packageget_unable', false, array('http://custom.elkarte.net/index.php?action=search;type=12;basic_search=' . $name)); |
|
| 1674 | + { |
|
| 1675 | + throw new Elk_Exception('packageget_unable', false, array('http://custom.elkarte.net/index.php?action=search;type=12;basic_search=' . $name)); |
|
| 1676 | + } |
|
| 1521 | 1677 | |
| 1522 | 1678 | if ($extracted && !file_exists(BOARDDIR . '/packages/temp/package-info.xml')) |
| 1523 | 1679 | { |
@@ -1532,18 +1688,26 @@ discard block |
||
| 1532 | 1688 | } |
| 1533 | 1689 | |
| 1534 | 1690 | if (!isset($base_path)) |
| 1535 | - $base_path = ''; |
|
| 1691 | + { |
|
| 1692 | + $base_path = ''; |
|
| 1693 | + } |
|
| 1536 | 1694 | |
| 1537 | 1695 | if (!file_exists(BOARDDIR . '/packages/temp/' . $base_path . 'package-info.xml')) |
| 1538 | - throw new Elk_Exception('package_get_error_missing_xml', false); |
|
| 1696 | + { |
|
| 1697 | + throw new Elk_Exception('package_get_error_missing_xml', false); |
|
| 1698 | + } |
|
| 1539 | 1699 | |
| 1540 | 1700 | $smileyInfo = getPackageInfo($context['filename']); |
| 1541 | 1701 | if (!is_array($smileyInfo)) |
| 1542 | - throw new Elk_Exception($smileyInfo); |
|
| 1702 | + { |
|
| 1703 | + throw new Elk_Exception($smileyInfo); |
|
| 1704 | + } |
|
| 1543 | 1705 | |
| 1544 | 1706 | // See if it is installed? |
| 1545 | 1707 | if (isSmileySetInstalled($smileyInfo['id'])) |
| 1546 | - \Errors::instance()->fatal_lang_error('package_installed_warning1'); |
|
| 1708 | + { |
|
| 1709 | + \Errors::instance()->fatal_lang_error('package_installed_warning1'); |
|
| 1710 | + } |
|
| 1547 | 1711 | |
| 1548 | 1712 | // Everything is fine, now it's time to do something, first we test |
| 1549 | 1713 | $actions = parsePackageInfo($smileyInfo['xml'], true, 'install'); |
@@ -1561,9 +1725,13 @@ discard block |
||
| 1561 | 1725 | { |
| 1562 | 1726 | $type = 'package_' . $action['type']; |
| 1563 | 1727 | if (file_exists(BOARDDIR . '/packages/temp/' . $base_path . $action['filename'])) |
| 1564 | - $context[$type] = htmlspecialchars(trim(file_get_contents(BOARDDIR . '/packages/temp/' . $base_path . $action['filename']), "\n\r"), ENT_COMPAT, 'UTF-8'); |
|
| 1728 | + { |
|
| 1729 | + $context[$type] = htmlspecialchars(trim(file_get_contents(BOARDDIR . '/packages/temp/' . $base_path . $action['filename']), "\n\r"), ENT_COMPAT, 'UTF-8'); |
|
| 1730 | + } |
|
| 1565 | 1731 | elseif (file_exists($action['filename'])) |
| 1566 | - $context[$type] = htmlspecialchars(trim(file_get_contents($action['filename']), "\n\r"), ENT_COMPAT, 'UTF-8'); |
|
| 1732 | + { |
|
| 1733 | + $context[$type] = htmlspecialchars(trim(file_get_contents($action['filename']), "\n\r"), ENT_COMPAT, 'UTF-8'); |
|
| 1734 | + } |
|
| 1567 | 1735 | |
| 1568 | 1736 | if (!empty($action['parse_bbc'])) |
| 1569 | 1737 | { |
@@ -1571,8 +1739,9 @@ discard block |
||
| 1571 | 1739 | preparsecode($context[$type]); |
| 1572 | 1740 | $context[$type] = $bbc_parser->parsePackage($context[$type]); |
| 1573 | 1741 | } |
| 1574 | - else |
|
| 1575 | - $context[$type] = nl2br($context[$type]); |
|
| 1742 | + else { |
|
| 1743 | + $context[$type] = nl2br($context[$type]); |
|
| 1744 | + } |
|
| 1576 | 1745 | |
| 1577 | 1746 | continue; |
| 1578 | 1747 | } |
@@ -1597,7 +1766,9 @@ discard block |
||
| 1597 | 1766 | |
| 1598 | 1767 | // Show a description for the action if one is provided |
| 1599 | 1768 | if (empty($thisAction['description'])) |
| 1600 | - $thisAction['description'] = isset($action['description']) ? $action['description'] : ''; |
|
| 1769 | + { |
|
| 1770 | + $thisAction['description'] = isset($action['description']) ? $action['description'] : ''; |
|
| 1771 | + } |
|
| 1601 | 1772 | |
| 1602 | 1773 | $context['actions'][] = $thisAction; |
| 1603 | 1774 | } |
@@ -1656,10 +1827,14 @@ discard block |
||
| 1656 | 1827 | } |
| 1657 | 1828 | |
| 1658 | 1829 | if (file_exists(BOARDDIR . '/packages/temp')) |
| 1659 | - deltree(BOARDDIR . '/packages/temp'); |
|
| 1830 | + { |
|
| 1831 | + deltree(BOARDDIR . '/packages/temp'); |
|
| 1832 | + } |
|
| 1660 | 1833 | |
| 1661 | 1834 | if (!$testing) |
| 1662 | - redirectexit('action=admin;area=smileys'); |
|
| 1835 | + { |
|
| 1836 | + redirectexit('action=admin;area=smileys'); |
|
| 1837 | + } |
|
| 1663 | 1838 | } |
| 1664 | 1839 | |
| 1665 | 1840 | /** |
@@ -1675,7 +1850,9 @@ discard block |
||
| 1675 | 1850 | $smiley_context = array(); |
| 1676 | 1851 | |
| 1677 | 1852 | foreach ($smiley_sets as $i => $set) |
| 1678 | - $smiley_context[$set] = stripslashes($set_names[$i]); |
|
| 1853 | + { |
|
| 1854 | + $smiley_context[$set] = stripslashes($set_names[$i]); |
|
| 1855 | + } |
|
| 1679 | 1856 | |
| 1680 | 1857 | $this->_smiley_context = $smiley_context; |
| 1681 | 1858 | } |
@@ -1694,14 +1871,18 @@ discard block |
||
| 1694 | 1871 | require_once(SUBSDIR . '/Smileys.subs.php'); |
| 1695 | 1872 | |
| 1696 | 1873 | if (empty($modSettings['smileys_dir']) || !is_dir($modSettings['smileys_dir'] . '/' . $smileyPath)) |
| 1697 | - throw new Elk_Exception('smiley_set_unable_to_import'); |
|
| 1874 | + { |
|
| 1875 | + throw new Elk_Exception('smiley_set_unable_to_import'); |
|
| 1876 | + } |
|
| 1698 | 1877 | |
| 1699 | 1878 | $smileys = array(); |
| 1700 | 1879 | $dir = dir($modSettings['smileys_dir'] . '/' . $smileyPath); |
| 1701 | 1880 | while ($entry = $dir->read()) |
| 1702 | 1881 | { |
| 1703 | 1882 | if (in_array(strrchr($entry, '.'), array('.jpg', '.gif', '.jpeg', '.png', '.webp'))) |
| 1704 | - $smileys[strtolower($entry)] = $entry; |
|
| 1883 | + { |
|
| 1884 | + $smileys[strtolower($entry)] = $entry; |
|
| 1885 | + } |
|
| 1705 | 1886 | } |
| 1706 | 1887 | $dir->close(); |
| 1707 | 1888 | |
@@ -1711,15 +1892,19 @@ discard block |
||
| 1711 | 1892 | foreach ($duplicates as $duplicate) |
| 1712 | 1893 | { |
| 1713 | 1894 | if (isset($smileys[strtolower($duplicate)])) |
| 1714 | - unset($smileys[strtolower($duplicate)]); |
|
| 1895 | + { |
|
| 1896 | + unset($smileys[strtolower($duplicate)]); |
|
| 1897 | + } |
|
| 1715 | 1898 | } |
| 1716 | 1899 | |
| 1717 | 1900 | $smiley_order = getMaxSmileyOrder(); |
| 1718 | 1901 | |
| 1719 | 1902 | $new_smileys = array(); |
| 1720 | 1903 | foreach ($smileys as $smiley) |
| 1721 | - if (strlen($smiley) <= 48) |
|
| 1904 | + { |
|
| 1905 | + if (strlen($smiley) <= 48) |
|
| 1722 | 1906 | $new_smileys[] = array(':' . strtok($smiley, '.') . ':', $smiley, strtok($smiley, '.'), 0, ++$smiley_order); |
| 1907 | + } |
|
| 1723 | 1908 | |
| 1724 | 1909 | if (!empty($new_smileys)) |
| 1725 | 1910 | { |