@@ -38,12 +38,12 @@ discard block |
||
| 38 | 38 | $version = $smcFunc['db_get_version'](); |
| 39 | 39 | // if we got a Beta Version |
| 40 | 40 | if (stripos($version, 'beta') !== false) |
| 41 | - $version = substr($version, 0, stripos($version, 'beta')).'.0'; |
|
| 41 | + $version = substr($version, 0, stripos($version, 'beta')) . '.0'; |
|
| 42 | 42 | // or RC |
| 43 | 43 | if (stripos($version, 'rc') !== false) |
| 44 | - $version = substr($version, 0, stripos($version, 'rc')).'.0'; |
|
| 44 | + $version = substr($version, 0, stripos($version, 'rc')) . '.0'; |
|
| 45 | 45 | |
| 46 | - if (version_compare($version,'9.5.0','>=')) |
|
| 46 | + if (version_compare($version, '9.5.0', '>=')) |
|
| 47 | 47 | $smcFunc['db_support_ignore'] = true; |
| 48 | 48 | } |
| 49 | 49 | |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | */ |
| 56 | 56 | function smf_db_search_support($search_type) |
| 57 | 57 | { |
| 58 | - $supported_types = array('custom','fulltext'); |
|
| 58 | + $supported_types = array('custom', 'fulltext'); |
|
| 59 | 59 | |
| 60 | 60 | return in_array($search_type, $supported_types); |
| 61 | 61 | } |
@@ -109,9 +109,9 @@ discard block |
||
| 109 | 109 | if (preg_match('~^\s*INSERT\sIGNORE~i', $db_string) != 0) |
| 110 | 110 | { |
| 111 | 111 | $db_string = preg_replace('~^\s*INSERT\sIGNORE~i', 'INSERT', $db_string); |
| 112 | - if ($smcFunc['db_support_ignore']){ |
|
| 112 | + if ($smcFunc['db_support_ignore']) { |
|
| 113 | 113 | //pg style "INSERT INTO.... ON CONFLICT DO NOTHING" |
| 114 | - $db_string = $db_string.' ON CONFLICT DO NOTHING'; |
|
| 114 | + $db_string = $db_string . ' ON CONFLICT DO NOTHING'; |
|
| 115 | 115 | } |
| 116 | 116 | else |
| 117 | 117 | { |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | $language_ftx = $modSettings['search_language']; |
| 169 | 169 | else |
| 170 | 170 | { |
| 171 | - $request = $smcFunc['db_query']('',' |
|
| 171 | + $request = $smcFunc['db_query']('', ' |
|
| 172 | 172 | SELECT cfgname FROM pg_ts_config WHERE oid = current_setting({string:default_language})::regconfig', |
| 173 | 173 | array( |
| 174 | 174 | 'default_language' => 'default_text_search_config' |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 4 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * Add the file functions to the $smcFunc array. |
@@ -23,29 +24,33 @@ discard block |
||
| 23 | 24 | { |
| 24 | 25 | global $smcFunc; |
| 25 | 26 | |
| 26 | - if (!isset($smcFunc['db_search_query']) || $smcFunc['db_search_query'] != 'smf_db_search_query') |
|
| 27 | - $smcFunc += array( |
|
| 27 | + if (!isset($smcFunc['db_search_query']) || $smcFunc['db_search_query'] != 'smf_db_search_query') { |
|
| 28 | + $smcFunc += array( |
|
| 28 | 29 | 'db_search_query' => 'smf_db_search_query', |
| 29 | 30 | 'db_search_support' => 'smf_db_search_support', |
| 30 | 31 | 'db_create_word_search' => 'smf_db_create_word_search', |
| 31 | 32 | 'db_support_ignore' => false, |
| 32 | 33 | 'db_search_language' => 'smf_db_search_language', |
| 33 | 34 | ); |
| 35 | + } |
|
| 34 | 36 | |
| 35 | 37 | db_extend(); |
| 36 | 38 | |
| 37 | 39 | //pg 9.5 got ignore support |
| 38 | 40 | $version = $smcFunc['db_get_version'](); |
| 39 | 41 | // if we got a Beta Version |
| 40 | - if (stripos($version, 'beta') !== false) |
|
| 41 | - $version = substr($version, 0, stripos($version, 'beta')).'.0'; |
|
| 42 | + if (stripos($version, 'beta') !== false) { |
|
| 43 | + $version = substr($version, 0, stripos($version, 'beta')).'.0'; |
|
| 44 | + } |
|
| 42 | 45 | // or RC |
| 43 | - if (stripos($version, 'rc') !== false) |
|
| 44 | - $version = substr($version, 0, stripos($version, 'rc')).'.0'; |
|
| 46 | + if (stripos($version, 'rc') !== false) { |
|
| 47 | + $version = substr($version, 0, stripos($version, 'rc')).'.0'; |
|
| 48 | + } |
|
| 45 | 49 | |
| 46 | - if (version_compare($version,'9.5.0','>=')) |
|
| 47 | - $smcFunc['db_support_ignore'] = true; |
|
| 48 | -} |
|
| 50 | + if (version_compare($version,'9.5.0','>=')) { |
|
| 51 | + $smcFunc['db_support_ignore'] = true; |
|
| 52 | + } |
|
| 53 | + } |
|
| 49 | 54 | |
| 50 | 55 | /** |
| 51 | 56 | * This function will tell you whether this database type supports this search type. |
@@ -104,16 +109,16 @@ discard block |
||
| 104 | 109 | ), |
| 105 | 110 | ); |
| 106 | 111 | |
| 107 | - if (isset($replacements[$identifier])) |
|
| 108 | - $db_string = preg_replace(array_keys($replacements[$identifier]), array_values($replacements[$identifier]), $db_string); |
|
| 112 | + if (isset($replacements[$identifier])) { |
|
| 113 | + $db_string = preg_replace(array_keys($replacements[$identifier]), array_values($replacements[$identifier]), $db_string); |
|
| 114 | + } |
|
| 109 | 115 | if (preg_match('~^\s*INSERT\sIGNORE~i', $db_string) != 0) |
| 110 | 116 | { |
| 111 | 117 | $db_string = preg_replace('~^\s*INSERT\sIGNORE~i', 'INSERT', $db_string); |
| 112 | 118 | if ($smcFunc['db_support_ignore']){ |
| 113 | 119 | //pg style "INSERT INTO.... ON CONFLICT DO NOTHING" |
| 114 | 120 | $db_string = $db_string.' ON CONFLICT DO NOTHING'; |
| 115 | - } |
|
| 116 | - else |
|
| 121 | + } else |
|
| 117 | 122 | { |
| 118 | 123 | // Don't error on multi-insert. |
| 119 | 124 | $db_values['db_error_skip'] = true; |
@@ -121,8 +126,9 @@ discard block |
||
| 121 | 126 | } |
| 122 | 127 | |
| 123 | 128 | //fix double quotes |
| 124 | - if ($identifier == 'insert_into_log_messages_fulltext') |
|
| 125 | - $db_values = str_replace('"', "'", $db_values); |
|
| 129 | + if ($identifier == 'insert_into_log_messages_fulltext') { |
|
| 130 | + $db_values = str_replace('"', "'", $db_values); |
|
| 131 | + } |
|
| 126 | 132 | |
| 127 | 133 | $return = $smcFunc['db_query']('', $db_string, |
| 128 | 134 | $db_values, $connection |
@@ -164,9 +170,9 @@ discard block |
||
| 164 | 170 | |
| 165 | 171 | $language_ftx = 'english'; |
| 166 | 172 | |
| 167 | - if (!empty($modSettings['search_language'])) |
|
| 168 | - $language_ftx = $modSettings['search_language']; |
|
| 169 | - else |
|
| 173 | + if (!empty($modSettings['search_language'])) { |
|
| 174 | + $language_ftx = $modSettings['search_language']; |
|
| 175 | + } else |
|
| 170 | 176 | { |
| 171 | 177 | $request = $smcFunc['db_query']('',' |
| 172 | 178 | SELECT cfgname FROM pg_ts_config WHERE oid = current_setting({string:default_language})::regconfig', |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | /** |
| 82 | 82 | * Make files writable. First try to use regular chmod, but if that fails, try to use FTP. |
| 83 | 83 | * |
| 84 | - * @param $files |
|
| 84 | + * @param string[] $files |
|
| 85 | 85 | * @return bool |
| 86 | 86 | */ |
| 87 | 87 | function makeFilesWritable(&$files) |
@@ -322,7 +322,7 @@ discard block |
||
| 322 | 322 | /** |
| 323 | 323 | * Prints an error to stderr. |
| 324 | 324 | * |
| 325 | - * @param $message |
|
| 325 | + * @param string $message |
|
| 326 | 326 | * @param bool $fatal |
| 327 | 327 | */ |
| 328 | 328 | function print_error($message, $fatal = false) |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * This file contains helper functions for upgrade.php |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF_VERSION')) |
|
| 16 | +if (!defined('SMF_VERSION')) { |
|
| 17 | 17 | die('No direct access!'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * Clean the cache using the SMF 2.1 CacheAPI. |
@@ -45,8 +46,9 @@ discard block |
||
| 45 | 46 | global $smcFunc; |
| 46 | 47 | static $member_groups = array(); |
| 47 | 48 | |
| 48 | - if (!empty($member_groups)) |
|
| 49 | - return $member_groups; |
|
| 49 | + if (!empty($member_groups)) { |
|
| 50 | + return $member_groups; |
|
| 51 | + } |
|
| 50 | 52 | |
| 51 | 53 | $request = $smcFunc['db_query']('', ' |
| 52 | 54 | SELECT group_name, id_group |
@@ -71,8 +73,9 @@ discard block |
||
| 71 | 73 | ) |
| 72 | 74 | ); |
| 73 | 75 | } |
| 74 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
| 75 | - $member_groups[trim($row[0])] = $row[1]; |
|
| 76 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
| 77 | + $member_groups[trim($row[0])] = $row[1]; |
|
| 78 | + } |
|
| 76 | 79 | $smcFunc['db_free_result']($request); |
| 77 | 80 | |
| 78 | 81 | return $member_groups; |
@@ -88,8 +91,9 @@ discard block |
||
| 88 | 91 | { |
| 89 | 92 | global $upcontext, $boarddir, $sourcedir; |
| 90 | 93 | |
| 91 | - if (empty($files)) |
|
| 92 | - return true; |
|
| 94 | + if (empty($files)) { |
|
| 95 | + return true; |
|
| 96 | + } |
|
| 93 | 97 | |
| 94 | 98 | $failure = false; |
| 95 | 99 | // On linux, it's easy - just use is_writable! |
@@ -100,22 +104,25 @@ discard block |
||
| 100 | 104 | foreach ($files as $k => $file) |
| 101 | 105 | { |
| 102 | 106 | // Some files won't exist, try to address up front |
| 103 | - if (!file_exists($file)) |
|
| 104 | - @touch($file); |
|
| 107 | + if (!file_exists($file)) { |
|
| 108 | + @touch($file); |
|
| 109 | + } |
|
| 105 | 110 | // NOW do the writable check... |
| 106 | 111 | if (!is_writable($file)) |
| 107 | 112 | { |
| 108 | 113 | @chmod($file, 0755); |
| 109 | 114 | |
| 110 | 115 | // Well, 755 hopefully worked... if not, try 777. |
| 111 | - if (!is_writable($file) && !@chmod($file, 0777)) |
|
| 112 | - $failure = true; |
|
| 116 | + if (!is_writable($file) && !@chmod($file, 0777)) { |
|
| 117 | + $failure = true; |
|
| 118 | + } |
|
| 113 | 119 | // Otherwise remove it as it's good! |
| 114 | - else |
|
| 115 | - unset($files[$k]); |
|
| 120 | + else { |
|
| 121 | + unset($files[$k]); |
|
| 122 | + } |
|
| 123 | + } else { |
|
| 124 | + unset($files[$k]); |
|
| 116 | 125 | } |
| 117 | - else |
|
| 118 | - unset($files[$k]); |
|
| 119 | 126 | } |
| 120 | 127 | } |
| 121 | 128 | // Windows is trickier. Let's try opening for r+... |
@@ -126,30 +133,35 @@ discard block |
||
| 126 | 133 | foreach ($files as $k => $file) |
| 127 | 134 | { |
| 128 | 135 | // Folders can't be opened for write... but the index.php in them can ;). |
| 129 | - if (is_dir($file)) |
|
| 130 | - $file .= '/index.php'; |
|
| 136 | + if (is_dir($file)) { |
|
| 137 | + $file .= '/index.php'; |
|
| 138 | + } |
|
| 131 | 139 | |
| 132 | 140 | // Funny enough, chmod actually does do something on windows - it removes the read only attribute. |
| 133 | 141 | @chmod($file, 0777); |
| 134 | 142 | $fp = @fopen($file, 'r+'); |
| 135 | 143 | |
| 136 | 144 | // Hmm, okay, try just for write in that case... |
| 137 | - if (!$fp) |
|
| 138 | - $fp = @fopen($file, 'w'); |
|
| 145 | + if (!$fp) { |
|
| 146 | + $fp = @fopen($file, 'w'); |
|
| 147 | + } |
|
| 139 | 148 | |
| 140 | - if (!$fp) |
|
| 141 | - $failure = true; |
|
| 142 | - else |
|
| 143 | - unset($files[$k]); |
|
| 149 | + if (!$fp) { |
|
| 150 | + $failure = true; |
|
| 151 | + } else { |
|
| 152 | + unset($files[$k]); |
|
| 153 | + } |
|
| 144 | 154 | @fclose($fp); |
| 145 | 155 | } |
| 146 | 156 | } |
| 147 | 157 | |
| 148 | - if (empty($files)) |
|
| 149 | - return true; |
|
| 158 | + if (empty($files)) { |
|
| 159 | + return true; |
|
| 160 | + } |
|
| 150 | 161 | |
| 151 | - if (!isset($_SERVER)) |
|
| 152 | - return !$failure; |
|
| 162 | + if (!isset($_SERVER)) { |
|
| 163 | + return !$failure; |
|
| 164 | + } |
|
| 153 | 165 | |
| 154 | 166 | // What still needs to be done? |
| 155 | 167 | $upcontext['chmod']['files'] = $files; |
@@ -201,36 +213,40 @@ discard block |
||
| 201 | 213 | |
| 202 | 214 | if (!isset($ftp) || $ftp->error !== false) |
| 203 | 215 | { |
| 204 | - if (!isset($ftp)) |
|
| 205 | - $ftp = new ftp_connection(null); |
|
| 216 | + if (!isset($ftp)) { |
|
| 217 | + $ftp = new ftp_connection(null); |
|
| 218 | + } |
|
| 206 | 219 | // Save the error so we can mess with listing... |
| 207 | - elseif ($ftp->error !== false && !isset($upcontext['chmod']['ftp_error'])) |
|
| 208 | - $upcontext['chmod']['ftp_error'] = $ftp->last_message === null ? '' : $ftp->last_message; |
|
| 220 | + elseif ($ftp->error !== false && !isset($upcontext['chmod']['ftp_error'])) { |
|
| 221 | + $upcontext['chmod']['ftp_error'] = $ftp->last_message === null ? '' : $ftp->last_message; |
|
| 222 | + } |
|
| 209 | 223 | |
| 210 | 224 | list ($username, $detect_path, $found_path) = $ftp->detect_path(dirname(__FILE__)); |
| 211 | 225 | |
| 212 | - if ($found_path || !isset($upcontext['chmod']['path'])) |
|
| 213 | - $upcontext['chmod']['path'] = $detect_path; |
|
| 226 | + if ($found_path || !isset($upcontext['chmod']['path'])) { |
|
| 227 | + $upcontext['chmod']['path'] = $detect_path; |
|
| 228 | + } |
|
| 214 | 229 | |
| 215 | - if (!isset($upcontext['chmod']['username'])) |
|
| 216 | - $upcontext['chmod']['username'] = $username; |
|
| 230 | + if (!isset($upcontext['chmod']['username'])) { |
|
| 231 | + $upcontext['chmod']['username'] = $username; |
|
| 232 | + } |
|
| 217 | 233 | |
| 218 | 234 | // Don't forget the login token. |
| 219 | 235 | $upcontext += createToken('login'); |
| 220 | 236 | |
| 221 | 237 | return false; |
| 222 | - } |
|
| 223 | - else |
|
| 238 | + } else |
|
| 224 | 239 | { |
| 225 | 240 | // We want to do a relative path for FTP. |
| 226 | 241 | if (!in_array($upcontext['chmod']['path'], array('', '/'))) |
| 227 | 242 | { |
| 228 | 243 | $ftp_root = strtr($boarddir, array($upcontext['chmod']['path'] => '')); |
| 229 | - if (substr($ftp_root, -1) == '/' && ($upcontext['chmod']['path'] == '' || $upcontext['chmod']['path'][0] === '/')) |
|
| 230 | - $ftp_root = substr($ftp_root, 0, -1); |
|
| 244 | + if (substr($ftp_root, -1) == '/' && ($upcontext['chmod']['path'] == '' || $upcontext['chmod']['path'][0] === '/')) { |
|
| 245 | + $ftp_root = substr($ftp_root, 0, -1); |
|
| 246 | + } |
|
| 247 | + } else { |
|
| 248 | + $ftp_root = $boarddir; |
|
| 231 | 249 | } |
| 232 | - else |
|
| 233 | - $ftp_root = $boarddir; |
|
| 234 | 250 | |
| 235 | 251 | // Save the info for next time! |
| 236 | 252 | $_SESSION['installer_temp_ftp'] = array( |
@@ -244,10 +260,12 @@ discard block |
||
| 244 | 260 | |
| 245 | 261 | foreach ($files as $k => $file) |
| 246 | 262 | { |
| 247 | - if (!is_writable($file)) |
|
| 248 | - $ftp->chmod($file, 0755); |
|
| 249 | - if (!is_writable($file)) |
|
| 250 | - $ftp->chmod($file, 0777); |
|
| 263 | + if (!is_writable($file)) { |
|
| 264 | + $ftp->chmod($file, 0755); |
|
| 265 | + } |
|
| 266 | + if (!is_writable($file)) { |
|
| 267 | + $ftp->chmod($file, 0777); |
|
| 268 | + } |
|
| 251 | 269 | |
| 252 | 270 | // Assuming that didn't work calculate the path without the boarddir. |
| 253 | 271 | if (!is_writable($file)) |
@@ -256,19 +274,23 @@ discard block |
||
| 256 | 274 | { |
| 257 | 275 | $ftp_file = strtr($file, array($_SESSION['installer_temp_ftp']['root'] => '')); |
| 258 | 276 | $ftp->chmod($ftp_file, 0755); |
| 259 | - if (!is_writable($file)) |
|
| 260 | - $ftp->chmod($ftp_file, 0777); |
|
| 277 | + if (!is_writable($file)) { |
|
| 278 | + $ftp->chmod($ftp_file, 0777); |
|
| 279 | + } |
|
| 261 | 280 | // Sometimes an extra slash can help... |
| 262 | 281 | $ftp_file = '/' . $ftp_file; |
| 263 | - if (!is_writable($file)) |
|
| 264 | - $ftp->chmod($ftp_file, 0755); |
|
| 265 | - if (!is_writable($file)) |
|
| 266 | - $ftp->chmod($ftp_file, 0777); |
|
| 282 | + if (!is_writable($file)) { |
|
| 283 | + $ftp->chmod($ftp_file, 0755); |
|
| 284 | + } |
|
| 285 | + if (!is_writable($file)) { |
|
| 286 | + $ftp->chmod($ftp_file, 0777); |
|
| 287 | + } |
|
| 267 | 288 | } |
| 268 | 289 | } |
| 269 | 290 | |
| 270 | - if (is_writable($file)) |
|
| 271 | - unset($files[$k]); |
|
| 291 | + if (is_writable($file)) { |
|
| 292 | + unset($files[$k]); |
|
| 293 | + } |
|
| 272 | 294 | } |
| 273 | 295 | |
| 274 | 296 | $ftp->close(); |
@@ -278,8 +300,9 @@ discard block |
||
| 278 | 300 | // What remains? |
| 279 | 301 | $upcontext['chmod']['files'] = $files; |
| 280 | 302 | |
| 281 | - if (empty($files)) |
|
| 282 | - return true; |
|
| 303 | + if (empty($files)) { |
|
| 304 | + return true; |
|
| 305 | + } |
|
| 283 | 306 | |
| 284 | 307 | return false; |
| 285 | 308 | } |
@@ -294,12 +317,14 @@ discard block |
||
| 294 | 317 | { |
| 295 | 318 | |
| 296 | 319 | // Some files won't exist, try to address up front |
| 297 | - if (!file_exists($file)) |
|
| 298 | - @touch($file); |
|
| 320 | + if (!file_exists($file)) { |
|
| 321 | + @touch($file); |
|
| 322 | + } |
|
| 299 | 323 | |
| 300 | 324 | // NOW do the writable check... |
| 301 | - if (is_writable($file)) |
|
| 302 | - return true; |
|
| 325 | + if (is_writable($file)) { |
|
| 326 | + return true; |
|
| 327 | + } |
|
| 303 | 328 | |
| 304 | 329 | @chmod($file, 0755); |
| 305 | 330 | |
@@ -309,10 +334,11 @@ discard block |
||
| 309 | 334 | foreach ($chmod_values as $val) |
| 310 | 335 | { |
| 311 | 336 | // If it's writable, break out of the loop |
| 312 | - if (is_writable($file)) |
|
| 313 | - break; |
|
| 314 | - else |
|
| 315 | - @chmod($file, $val); |
|
| 337 | + if (is_writable($file)) { |
|
| 338 | + break; |
|
| 339 | + } else { |
|
| 340 | + @chmod($file, $val); |
|
| 341 | + } |
|
| 316 | 342 | } |
| 317 | 343 | |
| 318 | 344 | return is_writable($file); |
@@ -339,14 +365,16 @@ discard block |
||
| 339 | 365 | { |
| 340 | 366 | static $fp = null; |
| 341 | 367 | |
| 342 | - if ($fp === null) |
|
| 343 | - $fp = fopen('php://stderr', 'wb'); |
|
| 368 | + if ($fp === null) { |
|
| 369 | + $fp = fopen('php://stderr', 'wb'); |
|
| 370 | + } |
|
| 344 | 371 | |
| 345 | 372 | fwrite($fp, $message . "\n"); |
| 346 | 373 | |
| 347 | - if ($fatal) |
|
| 348 | - exit; |
|
| 349 | -} |
|
| 374 | + if ($fatal) { |
|
| 375 | + exit; |
|
| 376 | + } |
|
| 377 | + } |
|
| 350 | 378 | |
| 351 | 379 | /** |
| 352 | 380 | * Throws a graphical error message. |
@@ -16,8 +16,9 @@ discard block |
||
| 16 | 16 | * @version 2.1 Beta 4 |
| 17 | 17 | */ |
| 18 | 18 | |
| 19 | -if (!defined('SMF')) |
|
| 19 | +if (!defined('SMF')) { |
|
| 20 | 20 | die('No direct access...'); |
| 21 | +} |
|
| 21 | 22 | |
| 22 | 23 | |
| 23 | 24 | /** |
@@ -28,14 +29,16 @@ discard block |
||
| 28 | 29 | function sha1_smf($str) |
| 29 | 30 | { |
| 30 | 31 | // If we have mhash loaded in, use it instead! |
| 31 | - if (function_exists('mhash') && defined('MHASH_SHA1')) |
|
| 32 | - return bin2hex(mhash(MHASH_SHA1, $str)); |
|
| 32 | + if (function_exists('mhash') && defined('MHASH_SHA1')) { |
|
| 33 | + return bin2hex(mhash(MHASH_SHA1, $str)); |
|
| 34 | + } |
|
| 33 | 35 | |
| 34 | 36 | $nblk = (strlen($str) + 8 >> 6) + 1; |
| 35 | 37 | $blks = array_pad(array(), $nblk * 16, 0); |
| 36 | 38 | |
| 37 | - for ($i = 0; $i < strlen($str); $i++) |
|
| 38 | - $blks[$i >> 2] |= ord($str{$i}) << (24 - ($i % 4) * 8); |
|
| 39 | + for ($i = 0; $i < strlen($str); $i++) { |
|
| 40 | + $blks[$i >> 2] |= ord($str{$i}) << (24 - ($i % 4) * 8); |
|
| 41 | + } |
|
| 39 | 42 | |
| 40 | 43 | $blks[$i >> 2] |= 0x80 << (24 - ($i % 4) * 8); |
| 41 | 44 | |
@@ -70,10 +73,11 @@ discard block |
||
| 70 | 73 | |
| 71 | 74 | for ($j = 0; $j < 80; $j++) |
| 72 | 75 | { |
| 73 | - if ($j < 16) |
|
| 74 | - $w[$j] = isset($x[$i + $j]) ? $x[$i + $j] : 0; |
|
| 75 | - else |
|
| 76 | - $w[$j] = sha1_rol($w[$j - 3] ^ $w[$j - 8] ^ $w[$j - 14] ^ $w[$j - 16], 1); |
|
| 76 | + if ($j < 16) { |
|
| 77 | + $w[$j] = isset($x[$i + $j]) ? $x[$i + $j] : 0; |
|
| 78 | + } else { |
|
| 79 | + $w[$j] = sha1_rol($w[$j - 3] ^ $w[$j - 8] ^ $w[$j - 14] ^ $w[$j - 16], 1); |
|
| 80 | + } |
|
| 77 | 81 | |
| 78 | 82 | $t = sha1_rol($a, 5) + sha1_ft($j, $b, $c, $d) + $e + $w[$j] + sha1_kt($j); |
| 79 | 83 | $e = $d; |
@@ -103,12 +107,15 @@ discard block |
||
| 103 | 107 | */ |
| 104 | 108 | function sha1_ft($t, $b, $c, $d) |
| 105 | 109 | { |
| 106 | - if ($t < 20) |
|
| 107 | - return ($b & $c) | ((~$b) & $d); |
|
| 108 | - if ($t < 40) |
|
| 109 | - return $b ^ $c ^ $d; |
|
| 110 | - if ($t < 60) |
|
| 111 | - return ($b & $c) | ($b & $d) | ($c & $d); |
|
| 110 | + if ($t < 20) { |
|
| 111 | + return ($b & $c) | ((~$b) & $d); |
|
| 112 | + } |
|
| 113 | + if ($t < 40) { |
|
| 114 | + return $b ^ $c ^ $d; |
|
| 115 | + } |
|
| 116 | + if ($t < 60) { |
|
| 117 | + return ($b & $c) | ($b & $d) | ($c & $d); |
|
| 118 | + } |
|
| 112 | 119 | |
| 113 | 120 | return $b ^ $c ^ $d; |
| 114 | 121 | } |
@@ -132,10 +139,11 @@ discard block |
||
| 132 | 139 | function sha1_rol($num, $cnt) |
| 133 | 140 | { |
| 134 | 141 | // Unfortunately, PHP uses unsigned 32-bit longs only. So we have to kludge it a bit. |
| 135 | - if ($num & 0x80000000) |
|
| 136 | - $a = ($num >> 1 & 0x7fffffff) >> (31 - $cnt); |
|
| 137 | - else |
|
| 138 | - $a = $num >> (32 - $cnt); |
|
| 142 | + if ($num & 0x80000000) { |
|
| 143 | + $a = ($num >> 1 & 0x7fffffff) >> (31 - $cnt); |
|
| 144 | + } else { |
|
| 145 | + $a = $num >> (32 - $cnt); |
|
| 146 | + } |
|
| 139 | 147 | |
| 140 | 148 | return ($num << $cnt) | $a; |
| 141 | 149 | } |
@@ -14,8 +14,9 @@ discard block |
||
| 14 | 14 | * @version 2.1 Beta 4 |
| 15 | 15 | */ |
| 16 | 16 | |
| 17 | -if (!defined('SMF')) |
|
| 17 | +if (!defined('SMF')) { |
|
| 18 | 18 | die('No direct access...'); |
| 19 | +} |
|
| 19 | 20 | |
| 20 | 21 | /** |
| 21 | 22 | * This function allows to move a topic, making sure to ask the moderator |
@@ -32,8 +33,9 @@ discard block |
||
| 32 | 33 | { |
| 33 | 34 | global $txt, $board, $topic, $user_info, $context, $language, $scripturl, $smcFunc, $modSettings, $sourcedir; |
| 34 | 35 | |
| 35 | - if (empty($topic)) |
|
| 36 | - fatal_lang_error('no_access', false); |
|
| 36 | + if (empty($topic)) { |
|
| 37 | + fatal_lang_error('no_access', false); |
|
| 38 | + } |
|
| 37 | 39 | |
| 38 | 40 | $request = $smcFunc['db_query']('', ' |
| 39 | 41 | SELECT t.id_member_started, ms.subject, t.approved |
@@ -49,8 +51,9 @@ discard block |
||
| 49 | 51 | $smcFunc['db_free_result']($request); |
| 50 | 52 | |
| 51 | 53 | // Can they see it - if not approved? |
| 52 | - if ($modSettings['postmod_active'] && !$context['is_approved']) |
|
| 53 | - isAllowedTo('approve_posts'); |
|
| 54 | + if ($modSettings['postmod_active'] && !$context['is_approved']) { |
|
| 55 | + isAllowedTo('approve_posts'); |
|
| 56 | + } |
|
| 54 | 57 | |
| 55 | 58 | // Permission check! |
| 56 | 59 | // @todo |
@@ -59,9 +62,9 @@ discard block |
||
| 59 | 62 | if ($id_member_started == $user_info['id']) |
| 60 | 63 | { |
| 61 | 64 | isAllowedTo('move_own'); |
| 65 | + } else { |
|
| 66 | + isAllowedTo('move_any'); |
|
| 62 | 67 | } |
| 63 | - else |
|
| 64 | - isAllowedTo('move_any'); |
|
| 65 | 68 | } |
| 66 | 69 | |
| 67 | 70 | $context['move_any'] = $user_info['is_admin'] || $modSettings['topic_move_any']; |
@@ -83,11 +86,13 @@ discard block |
||
| 83 | 86 | 'not_redirection' => true, |
| 84 | 87 | ); |
| 85 | 88 | |
| 86 | - if (!empty($_SESSION['move_to_topic']) && $_SESSION['move_to_topic'] != $board) |
|
| 87 | - $options['selected_board'] = $_SESSION['move_to_topic']; |
|
| 89 | + if (!empty($_SESSION['move_to_topic']) && $_SESSION['move_to_topic'] != $board) { |
|
| 90 | + $options['selected_board'] = $_SESSION['move_to_topic']; |
|
| 91 | + } |
|
| 88 | 92 | |
| 89 | - if (!$context['move_any']) |
|
| 90 | - $options['included_boards'] = $boards; |
|
| 93 | + if (!$context['move_any']) { |
|
| 94 | + $options['included_boards'] = $boards; |
|
| 95 | + } |
|
| 91 | 96 | |
| 92 | 97 | require_once($sourcedir . '/Subs-MessageIndex.php'); |
| 93 | 98 | $context['categories'] = getBoardList($options); |
@@ -138,12 +143,14 @@ discard block |
||
| 138 | 143 | global $txt, $topic, $scripturl, $sourcedir, $context; |
| 139 | 144 | global $board, $language, $user_info, $smcFunc; |
| 140 | 145 | |
| 141 | - if (empty($topic)) |
|
| 142 | - fatal_lang_error('no_access', false); |
|
| 146 | + if (empty($topic)) { |
|
| 147 | + fatal_lang_error('no_access', false); |
|
| 148 | + } |
|
| 143 | 149 | |
| 144 | 150 | // You can't choose to have a redirection topic and use an empty reason. |
| 145 | - if (isset($_POST['postRedirect']) && (!isset($_POST['reason']) || trim($_POST['reason']) == '')) |
|
| 146 | - fatal_lang_error('movetopic_no_reason', false); |
|
| 151 | + if (isset($_POST['postRedirect']) && (!isset($_POST['reason']) || trim($_POST['reason']) == '')) { |
|
| 152 | + fatal_lang_error('movetopic_no_reason', false); |
|
| 153 | + } |
|
| 147 | 154 | |
| 148 | 155 | moveTopicConcurrence(); |
| 149 | 156 | |
@@ -163,16 +170,18 @@ discard block |
||
| 163 | 170 | $smcFunc['db_free_result']($request); |
| 164 | 171 | |
| 165 | 172 | // Can they see it? |
| 166 | - if (!$context['is_approved']) |
|
| 167 | - isAllowedTo('approve_posts'); |
|
| 173 | + if (!$context['is_approved']) { |
|
| 174 | + isAllowedTo('approve_posts'); |
|
| 175 | + } |
|
| 168 | 176 | |
| 169 | 177 | // Can they move topics on this board? |
| 170 | 178 | if (!allowedTo('move_any')) |
| 171 | 179 | { |
| 172 | - if ($id_member_started == $user_info['id']) |
|
| 173 | - isAllowedTo('move_own'); |
|
| 174 | - else |
|
| 175 | - isAllowedTo('move_any'); |
|
| 180 | + if ($id_member_started == $user_info['id']) { |
|
| 181 | + isAllowedTo('move_own'); |
|
| 182 | + } else { |
|
| 183 | + isAllowedTo('move_any'); |
|
| 184 | + } |
|
| 176 | 185 | } |
| 177 | 186 | |
| 178 | 187 | checkSession(); |
@@ -197,8 +206,9 @@ discard block |
||
| 197 | 206 | 'blank_redirect' => '', |
| 198 | 207 | ) |
| 199 | 208 | ); |
| 200 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 201 | - fatal_lang_error('no_board'); |
|
| 209 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 210 | + fatal_lang_error('no_board'); |
|
| 211 | + } |
|
| 202 | 212 | list ($pcounter, $board_name, $subject) = $smcFunc['db_fetch_row']($request); |
| 203 | 213 | $smcFunc['db_free_result']($request); |
| 204 | 214 | |
@@ -210,8 +220,9 @@ discard block |
||
| 210 | 220 | { |
| 211 | 221 | $_POST['custom_subject'] = strtr($smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['custom_subject'])), array("\r" => '', "\n" => '', "\t" => '')); |
| 212 | 222 | // Keep checking the length. |
| 213 | - if ($smcFunc['strlen']($_POST['custom_subject']) > 100) |
|
| 214 | - $_POST['custom_subject'] = $smcFunc['substr']($_POST['custom_subject'], 0, 100); |
|
| 223 | + if ($smcFunc['strlen']($_POST['custom_subject']) > 100) { |
|
| 224 | + $_POST['custom_subject'] = $smcFunc['substr']($_POST['custom_subject'], 0, 100); |
|
| 225 | + } |
|
| 215 | 226 | |
| 216 | 227 | // If it's still valid move onwards and upwards. |
| 217 | 228 | if ($_POST['custom_subject'] != '') |
@@ -221,9 +232,9 @@ discard block |
||
| 221 | 232 | // Get a response prefix, but in the forum's default language. |
| 222 | 233 | if (!isset($context['response_prefix']) && !($context['response_prefix'] = cache_get_data('response_prefix'))) |
| 223 | 234 | { |
| 224 | - if ($language === $user_info['language']) |
|
| 225 | - $context['response_prefix'] = $txt['response_prefix']; |
|
| 226 | - else |
|
| 235 | + if ($language === $user_info['language']) { |
|
| 236 | + $context['response_prefix'] = $txt['response_prefix']; |
|
| 237 | + } else |
|
| 227 | 238 | { |
| 228 | 239 | loadLanguage('index', $language, false); |
| 229 | 240 | $context['response_prefix'] = $txt['response_prefix']; |
@@ -263,8 +274,9 @@ discard block |
||
| 263 | 274 | if (isset($_POST['postRedirect'])) |
| 264 | 275 | { |
| 265 | 276 | // Should be in the boardwide language. |
| 266 | - if ($user_info['language'] != $language) |
|
| 267 | - loadLanguage('index', $language); |
|
| 277 | + if ($user_info['language'] != $language) { |
|
| 278 | + loadLanguage('index', $language); |
|
| 279 | + } |
|
| 268 | 280 | |
| 269 | 281 | $_POST['reason'] = $smcFunc['htmlspecialchars']($_POST['reason'], ENT_QUOTES); |
| 270 | 282 | preparsecode($_POST['reason']); |
@@ -328,8 +340,9 @@ discard block |
||
| 328 | 340 | $posters = array(); |
| 329 | 341 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 330 | 342 | { |
| 331 | - if (!isset($posters[$row['id_member']])) |
|
| 332 | - $posters[$row['id_member']] = 0; |
|
| 343 | + if (!isset($posters[$row['id_member']])) { |
|
| 344 | + $posters[$row['id_member']] = 0; |
|
| 345 | + } |
|
| 333 | 346 | |
| 334 | 347 | $posters[$row['id_member']]++; |
| 335 | 348 | } |
@@ -338,11 +351,13 @@ discard block |
||
| 338 | 351 | foreach ($posters as $id_member => $posts) |
| 339 | 352 | { |
| 340 | 353 | // The board we're moving from counted posts, but not to. |
| 341 | - if (empty($pcounter_from)) |
|
| 342 | - updateMemberData($id_member, array('posts' => 'posts - ' . $posts)); |
|
| 354 | + if (empty($pcounter_from)) { |
|
| 355 | + updateMemberData($id_member, array('posts' => 'posts - ' . $posts)); |
|
| 356 | + } |
|
| 343 | 357 | // The reverse: from didn't, to did. |
| 344 | - else |
|
| 345 | - updateMemberData($id_member, array('posts' => 'posts + ' . $posts)); |
|
| 358 | + else { |
|
| 359 | + updateMemberData($id_member, array('posts' => 'posts + ' . $posts)); |
|
| 360 | + } |
|
| 346 | 361 | } |
| 347 | 362 | } |
| 348 | 363 | |
@@ -350,17 +365,19 @@ discard block |
||
| 350 | 365 | moveTopics($topic, $_POST['toboard']); |
| 351 | 366 | |
| 352 | 367 | // Log that they moved this topic. |
| 353 | - if (!allowedTo('move_own') || $id_member_started != $user_info['id']) |
|
| 354 | - logAction('move', array('topic' => $topic, 'board_from' => $board, 'board_to' => $_POST['toboard'])); |
|
| 368 | + if (!allowedTo('move_own') || $id_member_started != $user_info['id']) { |
|
| 369 | + logAction('move', array('topic' => $topic, 'board_from' => $board, 'board_to' => $_POST['toboard'])); |
|
| 370 | + } |
|
| 355 | 371 | // Notify people that this topic has been moved? |
| 356 | 372 | sendNotifications($topic, 'move'); |
| 357 | 373 | |
| 358 | 374 | // Why not go back to the original board in case they want to keep moving? |
| 359 | - if (!isset($_REQUEST['goback'])) |
|
| 360 | - redirectexit('board=' . $board . '.0'); |
|
| 361 | - else |
|
| 362 | - redirectexit('topic=' . $topic . '.0'); |
|
| 363 | -} |
|
| 375 | + if (!isset($_REQUEST['goback'])) { |
|
| 376 | + redirectexit('board=' . $board . '.0'); |
|
| 377 | + } else { |
|
| 378 | + redirectexit('topic=' . $topic . '.0'); |
|
| 379 | + } |
|
| 380 | + } |
|
| 364 | 381 | |
| 365 | 382 | /** |
| 366 | 383 | * Moves one or more topics to a specific board. (doesn't check permissions.) |
@@ -376,18 +393,21 @@ discard block |
||
| 376 | 393 | global $sourcedir, $user_info, $modSettings, $smcFunc; |
| 377 | 394 | |
| 378 | 395 | // Empty array? |
| 379 | - if (empty($topics)) |
|
| 380 | - return; |
|
| 396 | + if (empty($topics)) { |
|
| 397 | + return; |
|
| 398 | + } |
|
| 381 | 399 | |
| 382 | 400 | // Only a single topic. |
| 383 | - if (is_numeric($topics)) |
|
| 384 | - $topics = array($topics); |
|
| 401 | + if (is_numeric($topics)) { |
|
| 402 | + $topics = array($topics); |
|
| 403 | + } |
|
| 385 | 404 | |
| 386 | 405 | $fromBoards = array(); |
| 387 | 406 | |
| 388 | 407 | // Destination board empty or equal to 0? |
| 389 | - if (empty($toBoard)) |
|
| 390 | - return; |
|
| 408 | + if (empty($toBoard)) { |
|
| 409 | + return; |
|
| 410 | + } |
|
| 391 | 411 | |
| 392 | 412 | // Are we moving to the recycle board? |
| 393 | 413 | $isRecycleDest = !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] == $toBoard; |
@@ -395,8 +415,9 @@ discard block |
||
| 395 | 415 | // Callback for search APIs to do their thing |
| 396 | 416 | require_once($sourcedir . '/Search.php'); |
| 397 | 417 | $searchAPI = findSearchAPI(); |
| 398 | - if ($searchAPI->supportsMethod('topicsMoved')) |
|
| 399 | - $searchAPI->topicsMoved($topics, $toBoard); |
|
| 418 | + if ($searchAPI->supportsMethod('topicsMoved')) { |
|
| 419 | + $searchAPI->topicsMoved($topics, $toBoard); |
|
| 420 | + } |
|
| 400 | 421 | |
| 401 | 422 | // Determine the source boards... |
| 402 | 423 | $request = $smcFunc['db_query']('', ' |
@@ -410,8 +431,9 @@ discard block |
||
| 410 | 431 | ) |
| 411 | 432 | ); |
| 412 | 433 | // Num of rows = 0 -> no topics found. Num of rows > 1 -> topics are on multiple boards. |
| 413 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 414 | - return; |
|
| 434 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 435 | + return; |
|
| 436 | + } |
|
| 415 | 437 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 416 | 438 | { |
| 417 | 439 | if (!isset($fromBoards[$row['id_board']]['num_posts'])) |
@@ -429,10 +451,11 @@ discard block |
||
| 429 | 451 | $fromBoards[$row['id_board']]['unapproved_posts'] += $row['unapproved_posts']; |
| 430 | 452 | |
| 431 | 453 | // Add the topics to the right type. |
| 432 | - if ($row['approved']) |
|
| 433 | - $fromBoards[$row['id_board']]['num_topics'] += $row['num_topics']; |
|
| 434 | - else |
|
| 435 | - $fromBoards[$row['id_board']]['unapproved_topics'] += $row['num_topics']; |
|
| 454 | + if ($row['approved']) { |
|
| 455 | + $fromBoards[$row['id_board']]['num_topics'] += $row['num_topics']; |
|
| 456 | + } else { |
|
| 457 | + $fromBoards[$row['id_board']]['unapproved_topics'] += $row['num_topics']; |
|
| 458 | + } |
|
| 436 | 459 | } |
| 437 | 460 | $smcFunc['db_free_result']($request); |
| 438 | 461 | |
@@ -558,13 +581,14 @@ discard block |
||
| 558 | 581 | ) |
| 559 | 582 | ); |
| 560 | 583 | $approval_msgs = array(); |
| 561 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 562 | - $approval_msgs[] = $row['id_msg']; |
|
| 584 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 585 | + $approval_msgs[] = $row['id_msg']; |
|
| 586 | + } |
|
| 563 | 587 | $smcFunc['db_free_result']($request); |
| 564 | 588 | |
| 565 | 589 | // Empty the approval queue for these, as we're going to approve them next. |
| 566 | - if (!empty($approval_msgs)) |
|
| 567 | - $smcFunc['db_query']('', ' |
|
| 590 | + if (!empty($approval_msgs)) { |
|
| 591 | + $smcFunc['db_query']('', ' |
|
| 568 | 592 | DELETE FROM {db_prefix}approval_queue |
| 569 | 593 | WHERE id_msg IN ({array_int:message_list}) |
| 570 | 594 | AND id_attach = {int:id_attach}', |
@@ -573,6 +597,7 @@ discard block |
||
| 573 | 597 | 'id_attach' => 0, |
| 574 | 598 | ) |
| 575 | 599 | ); |
| 600 | + } |
|
| 576 | 601 | |
| 577 | 602 | // Get all the current max and mins. |
| 578 | 603 | $request = $smcFunc['db_query']('', ' |
@@ -606,8 +631,8 @@ discard block |
||
| 606 | 631 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 607 | 632 | { |
| 608 | 633 | // If not, update. |
| 609 | - if ($row['first_msg'] != $topicMaxMin[$row['id_topic']]['min'] || $row['last_msg'] != $topicMaxMin[$row['id_topic']]['max']) |
|
| 610 | - $smcFunc['db_query']('', ' |
|
| 634 | + if ($row['first_msg'] != $topicMaxMin[$row['id_topic']]['min'] || $row['last_msg'] != $topicMaxMin[$row['id_topic']]['max']) { |
|
| 635 | + $smcFunc['db_query']('', ' |
|
| 611 | 636 | UPDATE {db_prefix}topics |
| 612 | 637 | SET id_first_msg = {int:first_msg}, id_last_msg = {int:last_msg} |
| 613 | 638 | WHERE id_topic = {int:selected_topic}', |
@@ -617,6 +642,7 @@ discard block |
||
| 617 | 642 | 'selected_topic' => $row['id_topic'], |
| 618 | 643 | ) |
| 619 | 644 | ); |
| 645 | + } |
|
| 620 | 646 | } |
| 621 | 647 | $smcFunc['db_free_result']($request); |
| 622 | 648 | } |
@@ -675,9 +701,10 @@ discard block |
||
| 675 | 701 | } |
| 676 | 702 | |
| 677 | 703 | // Update the cache? |
| 678 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 3) |
|
| 679 | - foreach ($topics as $topic_id) |
|
| 704 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 3) { |
|
| 705 | + foreach ($topics as $topic_id) |
|
| 680 | 706 | cache_put_data('topic_board-' . $topic_id, null, 120); |
| 707 | + } |
|
| 681 | 708 | |
| 682 | 709 | require_once($sourcedir . '/Subs-Post.php'); |
| 683 | 710 | |
@@ -701,15 +728,17 @@ discard block |
||
| 701 | 728 | { |
| 702 | 729 | global $board, $topic, $smcFunc, $scripturl; |
| 703 | 730 | |
| 704 | - if (isset($_GET['current_board'])) |
|
| 705 | - $move_from = (int) $_GET['current_board']; |
|
| 731 | + if (isset($_GET['current_board'])) { |
|
| 732 | + $move_from = (int) $_GET['current_board']; |
|
| 733 | + } |
|
| 706 | 734 | |
| 707 | - if (empty($move_from) || empty($board) || empty($topic)) |
|
| 708 | - return true; |
|
| 735 | + if (empty($move_from) || empty($board) || empty($topic)) { |
|
| 736 | + return true; |
|
| 737 | + } |
|
| 709 | 738 | |
| 710 | - if ($move_from == $board) |
|
| 711 | - return true; |
|
| 712 | - else |
|
| 739 | + if ($move_from == $board) { |
|
| 740 | + return true; |
|
| 741 | + } else |
|
| 713 | 742 | { |
| 714 | 743 | $request = $smcFunc['db_query']('', ' |
| 715 | 744 | SELECT m.subject, b.name |
@@ -14,8 +14,9 @@ discard block |
||
| 14 | 14 | * @version 2.1 Beta 4 |
| 15 | 15 | */ |
| 16 | 16 | |
| 17 | -if (!defined('SMF')) |
|
| 17 | +if (!defined('SMF')) { |
|
| 18 | 18 | die('No direct access...'); |
| 19 | +} |
|
| 19 | 20 | |
| 20 | 21 | /** |
| 21 | 22 | * View the forum's error log. |
@@ -30,8 +31,9 @@ discard block |
||
| 30 | 31 | global $scripturl, $txt, $context, $modSettings, $user_profile, $filter, $smcFunc; |
| 31 | 32 | |
| 32 | 33 | // Viewing contents of a file? |
| 33 | - if (isset($_GET['file'])) |
|
| 34 | - return ViewFile(); |
|
| 34 | + if (isset($_GET['file'])) { |
|
| 35 | + return ViewFile(); |
|
| 36 | + } |
|
| 35 | 37 | |
| 36 | 38 | // Check for the administrative permission to do this. |
| 37 | 39 | isAllowedTo('admin_forum'); |
@@ -85,8 +87,8 @@ discard block |
||
| 85 | 87 | ); |
| 86 | 88 | |
| 87 | 89 | // Set up the filtering... |
| 88 | - if (isset($_GET['value'], $_GET['filter']) && isset($filters[$_GET['filter']])) |
|
| 89 | - $filter = array( |
|
| 90 | + if (isset($_GET['value'], $_GET['filter']) && isset($filters[$_GET['filter']])) { |
|
| 91 | + $filter = array( |
|
| 90 | 92 | 'variable' => $_GET['filter'], |
| 91 | 93 | 'value' => array( |
| 92 | 94 | 'sql' => in_array($_GET['filter'], array('message', 'url', 'file')) ? base64_decode(strtr($_GET['value'], array(' ' => '+'))) : $smcFunc['db_escape_wildcard_string']($_GET['value']), |
@@ -94,10 +96,12 @@ discard block |
||
| 94 | 96 | 'href' => ';filter=' . $_GET['filter'] . ';value=' . $_GET['value'], |
| 95 | 97 | 'entity' => $filters[$_GET['filter']]['txt'] |
| 96 | 98 | ); |
| 99 | + } |
|
| 97 | 100 | |
| 98 | 101 | // Deleting, are we? |
| 99 | - if (isset($_POST['delall']) || isset($_POST['delete'])) |
|
| 100 | - deleteErrors(); |
|
| 102 | + if (isset($_POST['delall']) || isset($_POST['delete'])) { |
|
| 103 | + deleteErrors(); |
|
| 104 | + } |
|
| 101 | 105 | |
| 102 | 106 | // Just how many errors are there? |
| 103 | 107 | $result = $smcFunc['db_query']('', ' |
@@ -112,12 +116,14 @@ discard block |
||
| 112 | 116 | $smcFunc['db_free_result']($result); |
| 113 | 117 | |
| 114 | 118 | // If this filter is empty... |
| 115 | - if ($num_errors == 0 && isset($filter)) |
|
| 116 | - redirectexit('action=admin;area=logs;sa=errorlog' . (isset($_REQUEST['desc']) ? ';desc' : '')); |
|
| 119 | + if ($num_errors == 0 && isset($filter)) { |
|
| 120 | + redirectexit('action=admin;area=logs;sa=errorlog' . (isset($_REQUEST['desc']) ? ';desc' : '')); |
|
| 121 | + } |
|
| 117 | 122 | |
| 118 | 123 | // Clean up start. |
| 119 | - if (!isset($_GET['start']) || $_GET['start'] < 0) |
|
| 120 | - $_GET['start'] = 0; |
|
| 124 | + if (!isset($_GET['start']) || $_GET['start'] < 0) { |
|
| 125 | + $_GET['start'] = 0; |
|
| 126 | + } |
|
| 121 | 127 | |
| 122 | 128 | // Do we want to reverse error listing? |
| 123 | 129 | $context['sort_direction'] = isset($_REQUEST['desc']) ? 'down' : 'up'; |
@@ -127,9 +133,9 @@ discard block |
||
| 127 | 133 | $context['start'] = $_GET['start']; |
| 128 | 134 | |
| 129 | 135 | // Update the error count |
| 130 | - if (!isset($filter)) |
|
| 131 | - $context['num_errors'] = $num_errors; |
|
| 132 | - else |
|
| 136 | + if (!isset($filter)) { |
|
| 137 | + $context['num_errors'] = $num_errors; |
|
| 138 | + } else |
|
| 133 | 139 | { |
| 134 | 140 | // We want all errors, not just the number of filtered messages... |
| 135 | 141 | $query = $smcFunc['db_query']('', ' |
@@ -161,8 +167,9 @@ discard block |
||
| 161 | 167 | for ($i = 0; $row = $smcFunc['db_fetch_assoc']($request); $i++) |
| 162 | 168 | { |
| 163 | 169 | $search_message = preg_replace('~<span class="remove">(.+?)</span>~', '%', $smcFunc['db_escape_wildcard_string']($row['message'])); |
| 164 | - if ($search_message == $filter['value']['sql']) |
|
| 165 | - $search_message = $smcFunc['db_escape_wildcard_string']($row['message']); |
|
| 170 | + if ($search_message == $filter['value']['sql']) { |
|
| 171 | + $search_message = $smcFunc['db_escape_wildcard_string']($row['message']); |
|
| 172 | + } |
|
| 166 | 173 | $show_message = strtr(strtr(preg_replace('~<span class="remove">(.+?)</span>~', '$1', $row['message']), array("\r" => '', '<br>' => "\n", '<' => '<', '>' => '>', '"' => '"')), array("\n" => '<br>')); |
| 167 | 174 | |
| 168 | 175 | $context['errors'][$row['id_error']] = array( |
@@ -221,8 +228,9 @@ discard block |
||
| 221 | 228 | 'members' => count($members), |
| 222 | 229 | ) |
| 223 | 230 | ); |
| 224 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 225 | - $members[$row['id_member']] = $row; |
|
| 231 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 232 | + $members[$row['id_member']] = $row; |
|
| 233 | + } |
|
| 226 | 234 | $smcFunc['db_free_result']($request); |
| 227 | 235 | |
| 228 | 236 | // This is a guest... |
@@ -254,20 +262,18 @@ discard block |
||
| 254 | 262 | $id = $filter['value']['sql']; |
| 255 | 263 | loadMemberData($id, false, 'minimal'); |
| 256 | 264 | $context['filter']['value']['html'] = '<a href="' . $scripturl . '?action=profile;u=' . $id . '">' . $user_profile[$id]['real_name'] . '</a>'; |
| 257 | - } |
|
| 258 | - elseif ($filter['variable'] == 'url') |
|
| 259 | - $context['filter']['value']['html'] = '\'' . strtr($smcFunc['htmlspecialchars']((substr($filter['value']['sql'], 0, 1) == '?' ? $scripturl : '') . $filter['value']['sql']), array('\_' => '_')) . '\''; |
|
| 260 | - elseif ($filter['variable'] == 'message') |
|
| 265 | + } elseif ($filter['variable'] == 'url') { |
|
| 266 | + $context['filter']['value']['html'] = '\'' . strtr($smcFunc['htmlspecialchars']((substr($filter['value']['sql'], 0, 1) == '?' ? $scripturl : '') . $filter['value']['sql']), array('\_' => '_')) . '\''; |
|
| 267 | + } elseif ($filter['variable'] == 'message') |
|
| 261 | 268 | { |
| 262 | 269 | $context['filter']['value']['html'] = '\'' . strtr($smcFunc['htmlspecialchars']($filter['value']['sql']), array("\n" => '<br>', '<br />' => '<br>', "\t" => ' ', '\_' => '_', '\\%' => '%', '\\\\' => '\\')) . '\''; |
| 263 | 270 | $context['filter']['value']['html'] = preg_replace('~&lt;span class=&quot;remove&quot;&gt;(.+?)&lt;/span&gt;~', '$1', $context['filter']['value']['html']); |
| 264 | - } |
|
| 265 | - elseif ($filter['variable'] == 'error_type') |
|
| 271 | + } elseif ($filter['variable'] == 'error_type') |
|
| 266 | 272 | { |
| 267 | 273 | $context['filter']['value']['html'] = '\'' . strtr($smcFunc['htmlspecialchars']($filter['value']['sql']), array("\n" => '<br>', '<br />' => '<br>', "\t" => ' ', '\_' => '_', '\\%' => '%', '\\\\' => '\\')) . '\''; |
| 274 | + } else { |
|
| 275 | + $context['filter']['value']['html'] = &$filter['value']['sql']; |
|
| 268 | 276 | } |
| 269 | - else |
|
| 270 | - $context['filter']['value']['html'] = &$filter['value']['sql']; |
|
| 271 | 277 | } |
| 272 | 278 | |
| 273 | 279 | $context['error_types'] = array(); |
@@ -308,10 +314,11 @@ discard block |
||
| 308 | 314 | $context['error_types']['all']['label'] .= ' (' . $sum . ')'; |
| 309 | 315 | |
| 310 | 316 | // Finally, work out what is the last tab! |
| 311 | - if (isset($context['error_types'][$sum])) |
|
| 312 | - $context['error_types'][$sum]['is_last'] = true; |
|
| 313 | - else |
|
| 314 | - $context['error_types']['all']['is_last'] = true; |
|
| 317 | + if (isset($context['error_types'][$sum])) { |
|
| 318 | + $context['error_types'][$sum]['is_last'] = true; |
|
| 319 | + } else { |
|
| 320 | + $context['error_types']['all']['is_last'] = true; |
|
| 321 | + } |
|
| 315 | 322 | |
| 316 | 323 | // And this is pretty basic ;). |
| 317 | 324 | $context['page_title'] = $txt['errlog']; |
@@ -337,21 +344,23 @@ discard block |
||
| 337 | 344 | validateToken('admin-el'); |
| 338 | 345 | |
| 339 | 346 | // Delete all or just some? |
| 340 | - if (isset($_POST['delall']) && !isset($filter)) |
|
| 341 | - $smcFunc['db_query']('truncate_table', ' |
|
| 347 | + if (isset($_POST['delall']) && !isset($filter)) { |
|
| 348 | + $smcFunc['db_query']('truncate_table', ' |
|
| 342 | 349 | TRUNCATE {db_prefix}log_errors', |
| 343 | 350 | array( |
| 344 | 351 | ) |
| 345 | 352 | ); |
| 353 | + } |
|
| 346 | 354 | // Deleting all with a filter? |
| 347 | - elseif (isset($_POST['delall']) && isset($filter)) |
|
| 348 | - $smcFunc['db_query']('', ' |
|
| 355 | + elseif (isset($_POST['delall']) && isset($filter)) { |
|
| 356 | + $smcFunc['db_query']('', ' |
|
| 349 | 357 | DELETE FROM {db_prefix}log_errors |
| 350 | 358 | WHERE ' . $filter['variable'] . ' LIKE {string:filter}', |
| 351 | 359 | array( |
| 352 | 360 | 'filter' => $filter['value']['sql'], |
| 353 | 361 | ) |
| 354 | 362 | ); |
| 363 | + } |
|
| 355 | 364 | // Just specific errors? |
| 356 | 365 | elseif (!empty($_POST['delete'])) |
| 357 | 366 | { |
@@ -397,15 +406,17 @@ discard block |
||
| 397 | 406 | $line = isset($_REQUEST['line']) ? (int) $_REQUEST['line'] : 0; |
| 398 | 407 | |
| 399 | 408 | // Make sure the file we are looking for is one they are allowed to look at |
| 400 | - if ($ext != '.php' || (strpos($file, $real_board) === false && strpos($file, $real_source) === false) || ($basename == 'settings.php' || $basename == 'settings_bak.php') || strpos($file, $real_cache) !== false || !is_readable($file)) |
|
| 401 | - fatal_lang_error('error_bad_file', true, array($smcFunc['htmlspecialchars']($file))); |
|
| 409 | + if ($ext != '.php' || (strpos($file, $real_board) === false && strpos($file, $real_source) === false) || ($basename == 'settings.php' || $basename == 'settings_bak.php') || strpos($file, $real_cache) !== false || !is_readable($file)) { |
|
| 410 | + fatal_lang_error('error_bad_file', true, array($smcFunc['htmlspecialchars']($file))); |
|
| 411 | + } |
|
| 402 | 412 | |
| 403 | 413 | // get the min and max lines |
| 404 | 414 | $min = $line - 20 <= 0 ? 1 : $line - 20; |
| 405 | 415 | $max = $line + 21; // One additional line to make everything work out correctly |
| 406 | 416 | |
| 407 | - if ($max <= 0 || $min >= $max) |
|
| 408 | - fatal_lang_error('error_bad_line'); |
|
| 417 | + if ($max <= 0 || $min >= $max) { |
|
| 418 | + fatal_lang_error('error_bad_line'); |
|
| 419 | + } |
|
| 409 | 420 | |
| 410 | 421 | $file_data = explode('<br />', highlight_php_code($smcFunc['htmlspecialchars'](implode('', file($file))))); |
| 411 | 422 | |
@@ -11,8 +11,9 @@ |
||
| 11 | 11 | * @version 2.1 Beta 4 |
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | -if (!defined('SMF')) |
|
| 14 | +if (!defined('SMF')) { |
|
| 15 | 15 | die('No direct access...'); |
| 16 | +} |
|
| 16 | 17 | |
| 17 | 18 | /** |
| 18 | 19 | * Standard non full index, non custom index search |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 4 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * Get the latest posts of a forum. |
@@ -59,8 +60,9 @@ discard block |
||
| 59 | 60 | censorText($row['body']); |
| 60 | 61 | |
| 61 | 62 | $row['body'] = strip_tags(strtr(parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']), array('<br>' => ' '))); |
| 62 | - if ($smcFunc['strlen']($row['body']) > 128) |
|
| 63 | - $row['body'] = $smcFunc['substr']($row['body'], 0, 128) . '...'; |
|
| 63 | + if ($smcFunc['strlen']($row['body']) > 128) { |
|
| 64 | + $row['body'] = $smcFunc['substr']($row['body'], 0, 128) . '...'; |
|
| 65 | + } |
|
| 64 | 66 | |
| 65 | 67 | // Build the array. |
| 66 | 68 | $posts[] = array( |
@@ -11,8 +11,9 @@ discard block |
||
| 11 | 11 | * @version 2.1 Beta 4 |
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | -if (!defined('SMF')) |
|
| 14 | +if (!defined('SMF')) { |
|
| 15 | 15 | die('Hacking attempt...'); |
| 16 | +} |
|
| 16 | 17 | |
| 17 | 18 | /** |
| 18 | 19 | * Our Cache API class |
@@ -27,8 +28,9 @@ discard block |
||
| 27 | 28 | { |
| 28 | 29 | $supported = function_exists('apc_fetch') && function_exists('apc_store'); |
| 29 | 30 | |
| 30 | - if ($test) |
|
| 31 | - return $supported; |
|
| 31 | + if ($test) { |
|
| 32 | + return $supported; |
|
| 33 | + } |
|
| 32 | 34 | return parent::isSupported() && $supported; |
| 33 | 35 | } |
| 34 | 36 | |
@@ -50,10 +52,11 @@ discard block |
||
| 50 | 52 | $key = $this->prefix . strtr($key, ':/', '-_'); |
| 51 | 53 | |
| 52 | 54 | // An extended key is needed to counteract a bug in APC. |
| 53 | - if ($value === null) |
|
| 54 | - return apc_delete($key . 'smf'); |
|
| 55 | - else |
|
| 56 | - return apc_store($key . 'smf', $value, $ttl); |
|
| 55 | + if ($value === null) { |
|
| 56 | + return apc_delete($key . 'smf'); |
|
| 57 | + } else { |
|
| 58 | + return apc_store($key . 'smf', $value, $ttl); |
|
| 59 | + } |
|
| 57 | 60 | } |
| 58 | 61 | |
| 59 | 62 | /** |
@@ -67,9 +70,9 @@ discard block |
||
| 67 | 70 | // Always returns true. |
| 68 | 71 | apc_clear_cache('user'); |
| 69 | 72 | apc_clear_cache('system'); |
| 73 | + } elseif ($type === 'user') { |
|
| 74 | + apc_clear_cache('user'); |
|
| 70 | 75 | } |
| 71 | - elseif ($type === 'user') |
|
| 72 | - apc_clear_cache('user'); |
|
| 73 | 76 | |
| 74 | 77 | $this->invalidateCache(); |
| 75 | 78 | return true; |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 4 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * Sets and call a function based on the given subaction. Acts as a dispatcher function. |
@@ -54,8 +55,9 @@ discard block |
||
| 54 | 55 | ); |
| 55 | 56 | |
| 56 | 57 | // This comes under the umbrella of moderating posts. |
| 57 | - if ($context['report_type'] == 'members' || $user_info['mod_cache']['bq'] == '0=1') |
|
| 58 | - isAllowedTo('moderate_forum'); |
|
| 58 | + if ($context['report_type'] == 'members' || $user_info['mod_cache']['bq'] == '0=1') { |
|
| 59 | + isAllowedTo('moderate_forum'); |
|
| 60 | + } |
|
| 59 | 61 | |
| 60 | 62 | $subActions = array( |
| 61 | 63 | 'show' => 'ShowReports', |
@@ -70,11 +72,11 @@ discard block |
||
| 70 | 72 | call_integration_hook('integrate_reported_' . $context['report_type'], array(&$subActions)); |
| 71 | 73 | |
| 72 | 74 | // By default we call the open sub-action. |
| 73 | - if (isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']])) |
|
| 74 | - $context['sub_action'] = $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_REQUEST['sa']), ENT_QUOTES); |
|
| 75 | - |
|
| 76 | - else |
|
| 77 | - $context['sub_action'] = 'show'; |
|
| 75 | + if (isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']])) { |
|
| 76 | + $context['sub_action'] = $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_REQUEST['sa']), ENT_QUOTES); |
|
| 77 | + } else { |
|
| 78 | + $context['sub_action'] = 'show'; |
|
| 79 | + } |
|
| 78 | 80 | |
| 79 | 81 | // Hi Ho Silver Away! |
| 80 | 82 | call_helper($subActions[$context['sub_action']]); |
@@ -116,11 +118,13 @@ discard block |
||
| 116 | 118 | |
| 117 | 119 | // All the ones to update... |
| 118 | 120 | $toClose = array(); |
| 119 | - foreach ($_POST['close'] as $rid) |
|
| 120 | - $toClose[] = (int) $rid; |
|
| 121 | + foreach ($_POST['close'] as $rid) { |
|
| 122 | + $toClose[] = (int) $rid; |
|
| 123 | + } |
|
| 121 | 124 | |
| 122 | - if (!empty($toClose)) |
|
| 123 | - updateReport('closed', 1, $toClose); |
|
| 125 | + if (!empty($toClose)) { |
|
| 126 | + updateReport('closed', 1, $toClose); |
|
| 127 | + } |
|
| 124 | 128 | |
| 125 | 129 | // Set the confirmation message. |
| 126 | 130 | $_SESSION['rc_confirmation'] = 'close_all'; |
@@ -175,8 +179,9 @@ discard block |
||
| 175 | 179 | global $context, $sourcedir, $scripturl, $txt; |
| 176 | 180 | |
| 177 | 181 | // Have to at least give us something to work with. |
| 178 | - if (empty($_REQUEST['rid'])) |
|
| 179 | - fatal_lang_error('mc_reportedp_none_found'); |
|
| 182 | + if (empty($_REQUEST['rid'])) { |
|
| 183 | + fatal_lang_error('mc_reportedp_none_found'); |
|
| 184 | + } |
|
| 180 | 185 | |
| 181 | 186 | // Integers only please |
| 182 | 187 | $report_id = (int) $_REQUEST['rid']; |
@@ -184,8 +189,9 @@ discard block |
||
| 184 | 189 | // Get the report details. |
| 185 | 190 | $report = getReportDetails($report_id); |
| 186 | 191 | |
| 187 | - if (!$report) |
|
| 188 | - fatal_lang_error('mc_no_modreport_found'); |
|
| 192 | + if (!$report) { |
|
| 193 | + fatal_lang_error('mc_no_modreport_found'); |
|
| 194 | + } |
|
| 189 | 195 | |
| 190 | 196 | // Build the report data - basic details first, then extra stuff based on the type |
| 191 | 197 | $context['report'] = array( |
@@ -211,8 +217,7 @@ discard block |
||
| 211 | 217 | 'href' => $scripturl . '?action=profile;u=' . $report['id_user'], |
| 212 | 218 | ), |
| 213 | 219 | ); |
| 214 | - } |
|
| 215 | - else |
|
| 220 | + } else |
|
| 216 | 221 | { |
| 217 | 222 | $extraDetails = array( |
| 218 | 223 | 'topic_id' => $report['id_topic'], |
@@ -235,8 +240,9 @@ discard block |
||
| 235 | 240 | |
| 236 | 241 | $reportComments = getReportComments($report_id); |
| 237 | 242 | |
| 238 | - if (!empty($reportComments)) |
|
| 239 | - $context['report'] = array_merge($context['report'], $reportComments); |
|
| 243 | + if (!empty($reportComments)) { |
|
| 244 | + $context['report'] = array_merge($context['report'], $reportComments); |
|
| 245 | + } |
|
| 240 | 246 | |
| 241 | 247 | // What have the other moderators done to this message? |
| 242 | 248 | require_once($sourcedir . '/Modlog.php'); |
@@ -257,8 +263,7 @@ discard block |
||
| 257 | 263 | 1, |
| 258 | 264 | true, |
| 259 | 265 | ); |
| 260 | - } |
|
| 261 | - else |
|
| 266 | + } else |
|
| 262 | 267 | { |
| 263 | 268 | $params = array( |
| 264 | 269 | 'lm.id_topic = {int:id_topic} |
@@ -358,16 +363,16 @@ discard block |
||
| 358 | 363 | createList($listOptions); |
| 359 | 364 | |
| 360 | 365 | // Make sure to get the correct tab selected. |
| 361 | - if ($context['report']['closed']) |
|
| 362 | - $context[$context['moderation_menu_name']]['current_subsection'] = 'closed'; |
|
| 366 | + if ($context['report']['closed']) { |
|
| 367 | + $context[$context['moderation_menu_name']]['current_subsection'] = 'closed'; |
|
| 368 | + } |
|
| 363 | 369 | |
| 364 | 370 | // Finally we are done :P |
| 365 | 371 | if ($context['report_type'] == 'members') |
| 366 | 372 | { |
| 367 | 373 | $context['page_title'] = sprintf($txt['mc_viewmemberreport'], $context['report']['user']['name']); |
| 368 | 374 | $context['sub_template'] = 'viewmemberreport'; |
| 369 | - } |
|
| 370 | - else |
|
| 375 | + } else |
|
| 371 | 376 | { |
| 372 | 377 | $context['page_title'] = sprintf($txt['mc_viewmodreport'], $context['report']['subject'], $context['report']['author']['name']); |
| 373 | 378 | $context['sub_template'] = 'viewmodreport'; |
@@ -390,8 +395,9 @@ discard block |
||
| 390 | 395 | global $smcFunc, $scripturl, $user_info, $context; |
| 391 | 396 | |
| 392 | 397 | // The report ID is a must. |
| 393 | - if (empty($_REQUEST['rid'])) |
|
| 394 | - fatal_lang_error('mc_reportedp_none_found'); |
|
| 398 | + if (empty($_REQUEST['rid'])) { |
|
| 399 | + fatal_lang_error('mc_reportedp_none_found'); |
|
| 400 | + } |
|
| 395 | 401 | |
| 396 | 402 | // Integers only please. |
| 397 | 403 | $report_id = (int) $_REQUEST['rid']; |
@@ -416,8 +422,9 @@ discard block |
||
| 416 | 422 | checkSession('get'); |
| 417 | 423 | validateToken('mod-reportC-delete', 'get'); |
| 418 | 424 | |
| 419 | - if (empty($_REQUEST['mid'])) |
|
| 420 | - fatal_lang_error('mc_reportedp_comment_none_found'); |
|
| 425 | + if (empty($_REQUEST['mid'])) { |
|
| 426 | + fatal_lang_error('mc_reportedp_comment_none_found'); |
|
| 427 | + } |
|
| 421 | 428 | |
| 422 | 429 | $comment_id = (int) $_REQUEST['mid']; |
| 423 | 430 | |
@@ -425,15 +432,17 @@ discard block |
||
| 425 | 432 | $comment = getCommentModDetails($comment_id); |
| 426 | 433 | |
| 427 | 434 | // Perhaps somebody else already deleted this fine gem... |
| 428 | - if (empty($comment)) |
|
| 429 | - fatal_lang_error('report_action_message_delete_issue'); |
|
| 435 | + if (empty($comment)) { |
|
| 436 | + fatal_lang_error('report_action_message_delete_issue'); |
|
| 437 | + } |
|
| 430 | 438 | |
| 431 | 439 | // Can you actually do this? |
| 432 | 440 | $comment_owner = $user_info['id'] == $comment['id_member']; |
| 433 | 441 | |
| 434 | 442 | // Nope! sorry. |
| 435 | - if (!allowedTo('admin_forum') && !$comment_owner) |
|
| 436 | - fatal_lang_error('report_action_message_delete_cannot'); |
|
| 443 | + if (!allowedTo('admin_forum') && !$comment_owner) { |
|
| 444 | + fatal_lang_error('report_action_message_delete_cannot'); |
|
| 445 | + } |
|
| 437 | 446 | |
| 438 | 447 | // All good! |
| 439 | 448 | deleteModComment($comment_id); |
@@ -458,11 +467,13 @@ discard block |
||
| 458 | 467 | checkSession(isset($_REQUEST['save']) ? 'post' : 'get'); |
| 459 | 468 | |
| 460 | 469 | // The report ID is a must. |
| 461 | - if (empty($_REQUEST['rid'])) |
|
| 462 | - fatal_lang_error('mc_reportedp_none_found'); |
|
| 470 | + if (empty($_REQUEST['rid'])) { |
|
| 471 | + fatal_lang_error('mc_reportedp_none_found'); |
|
| 472 | + } |
|
| 463 | 473 | |
| 464 | - if (empty($_REQUEST['mid'])) |
|
| 465 | - fatal_lang_error('mc_reportedp_comment_none_found'); |
|
| 474 | + if (empty($_REQUEST['mid'])) { |
|
| 475 | + fatal_lang_error('mc_reportedp_comment_none_found'); |
|
| 476 | + } |
|
| 466 | 477 | |
| 467 | 478 | // Integers only please. |
| 468 | 479 | $context['report_id'] = (int) $_REQUEST['rid']; |
@@ -470,8 +481,9 @@ discard block |
||
| 470 | 481 | |
| 471 | 482 | $context['comment'] = getCommentModDetails($context['comment_id']); |
| 472 | 483 | |
| 473 | - if (empty($context['comment'])) |
|
| 474 | - fatal_lang_error('mc_reportedp_comment_none_found'); |
|
| 484 | + if (empty($context['comment'])) { |
|
| 485 | + fatal_lang_error('mc_reportedp_comment_none_found'); |
|
| 486 | + } |
|
| 475 | 487 | |
| 476 | 488 | // Set up the comforting bits... |
| 477 | 489 | $context['page_title'] = $txt['mc_reported_posts']; |
@@ -482,15 +494,17 @@ discard block |
||
| 482 | 494 | validateToken('mod-reportC-edit'); |
| 483 | 495 | |
| 484 | 496 | // Make sure there is some data to edit on the DB. |
| 485 | - if (empty($context['comment'])) |
|
| 486 | - fatal_lang_error('report_action_message_edit_issue'); |
|
| 497 | + if (empty($context['comment'])) { |
|
| 498 | + fatal_lang_error('report_action_message_edit_issue'); |
|
| 499 | + } |
|
| 487 | 500 | |
| 488 | 501 | // Still there, good, now lets see if you can actually edit it... |
| 489 | 502 | $comment_owner = $user_info['id'] == $context['comment']['id_member']; |
| 490 | 503 | |
| 491 | 504 | // So, you aren't neither an admin or the comment owner huh? that's too bad. |
| 492 | - if (!allowedTo('admin_forum') && !$comment_owner) |
|
| 493 | - fatal_lang_error('report_action_message_edit_cannot'); |
|
| 505 | + if (!allowedTo('admin_forum') && !$comment_owner) { |
|
| 506 | + fatal_lang_error('report_action_message_edit_cannot'); |
|
| 507 | + } |
|
| 494 | 508 | |
| 495 | 509 | // All good! |
| 496 | 510 | $edited_comment = trim($smcFunc['htmlspecialchars']($_POST['mod_comment'])); |
@@ -516,8 +530,9 @@ discard block |
||
| 516 | 530 | checkSession('get'); |
| 517 | 531 | |
| 518 | 532 | // We need to do something! |
| 519 | - if (empty($_GET['rid']) && (!isset($_GET['ignore']) || !isset($_GET['closed']))) |
|
| 520 | - fatal_lang_error('mc_reportedp_none_found'); |
|
| 533 | + if (empty($_GET['rid']) && (!isset($_GET['ignore']) || !isset($_GET['closed']))) { |
|
| 534 | + fatal_lang_error('mc_reportedp_none_found'); |
|
| 535 | + } |
|
| 521 | 536 | |
| 522 | 537 | // What are we gonna do? |
| 523 | 538 | $action = isset($_GET['ignore']) ? 'ignore' : 'closed'; |