@@ -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 | * Maps the implementations in this file (smf_db_function_name) |
@@ -34,8 +35,8 @@ discard block |
||
| 34 | 35 | global $smcFunc; |
| 35 | 36 | |
| 36 | 37 | // Map some database specific functions, only do this once. |
| 37 | - if (!isset($smcFunc['db_fetch_assoc'])) |
|
| 38 | - $smcFunc += array( |
|
| 38 | + if (!isset($smcFunc['db_fetch_assoc'])) { |
|
| 39 | + $smcFunc += array( |
|
| 39 | 40 | 'db_query' => 'smf_db_query', |
| 40 | 41 | 'db_quote' => 'smf_db_quote', |
| 41 | 42 | 'db_insert' => 'smf_db_insert', |
@@ -63,11 +64,13 @@ discard block |
||
| 63 | 64 | 'db_fetch_all' => 'smf_db_fetch_all', |
| 64 | 65 | 'db_error_insert' => 'smf_db_error_insert', |
| 65 | 66 | ); |
| 67 | + } |
|
| 66 | 68 | |
| 67 | - if (!empty($db_options['persist'])) |
|
| 68 | - $connection = @pg_pconnect('host=' . $db_server . ' dbname=' . $db_name . ' user=\'' . $db_user . '\' password=\'' . $db_passwd . '\'' . (empty($db_options['port']) ? '' : ' port=\'' . $db_options['port'] . '\'')); |
|
| 69 | - else |
|
| 70 | - $connection = @pg_connect('host=' . $db_server . ' dbname=' . $db_name . ' user=\'' . $db_user . '\' password=\'' . $db_passwd . '\'' . (empty($db_options['port']) ? '' : ' port=\'' . $db_options['port'] . '\'')); |
|
| 69 | + if (!empty($db_options['persist'])) { |
|
| 70 | + $connection = @pg_pconnect('host=' . $db_server . ' dbname=' . $db_name . ' user=\'' . $db_user . '\' password=\'' . $db_passwd . '\'' . (empty($db_options['port']) ? '' : ' port=\'' . $db_options['port'] . '\'')); |
|
| 71 | + } else { |
|
| 72 | + $connection = @pg_connect('host=' . $db_server . ' dbname=' . $db_name . ' user=\'' . $db_user . '\' password=\'' . $db_passwd . '\'' . (empty($db_options['port']) ? '' : ' port=\'' . $db_options['port'] . '\'')); |
|
| 73 | + } |
|
| 71 | 74 | |
| 72 | 75 | // Something's wrong, show an error if its fatal (which we assume it is) |
| 73 | 76 | if (!$connection) |
@@ -75,8 +78,7 @@ discard block |
||
| 75 | 78 | if (!empty($db_options['non_fatal'])) |
| 76 | 79 | { |
| 77 | 80 | return null; |
| 78 | - } |
|
| 79 | - else |
|
| 81 | + } else |
|
| 80 | 82 | { |
| 81 | 83 | display_db_error(); |
| 82 | 84 | } |
@@ -127,31 +129,38 @@ discard block |
||
| 127 | 129 | |
| 128 | 130 | list ($values, $connection) = $db_callback; |
| 129 | 131 | |
| 130 | - if ($matches[1] === 'db_prefix') |
|
| 131 | - return $db_prefix; |
|
| 132 | + if ($matches[1] === 'db_prefix') { |
|
| 133 | + return $db_prefix; |
|
| 134 | + } |
|
| 132 | 135 | |
| 133 | - if (isset($user_info[$matches[1]]) && strpos($matches[1], 'query_') !== false) |
|
| 134 | - return $user_info[$matches[1]]; |
|
| 136 | + if (isset($user_info[$matches[1]]) && strpos($matches[1], 'query_') !== false) { |
|
| 137 | + return $user_info[$matches[1]]; |
|
| 138 | + } |
|
| 135 | 139 | |
| 136 | - if ($matches[1] === 'empty') |
|
| 137 | - return '\'\''; |
|
| 140 | + if ($matches[1] === 'empty') { |
|
| 141 | + return '\'\''; |
|
| 142 | + } |
|
| 138 | 143 | |
| 139 | - if (!isset($matches[2])) |
|
| 140 | - smf_db_error_backtrace('Invalid value inserted or no type specified.', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 144 | + if (!isset($matches[2])) { |
|
| 145 | + smf_db_error_backtrace('Invalid value inserted or no type specified.', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 146 | + } |
|
| 141 | 147 | |
| 142 | - if ($matches[1] === 'literal') |
|
| 143 | - return '\'' . pg_escape_string($matches[2]) . '\''; |
|
| 148 | + if ($matches[1] === 'literal') { |
|
| 149 | + return '\'' . pg_escape_string($matches[2]) . '\''; |
|
| 150 | + } |
|
| 144 | 151 | |
| 145 | - if (!isset($values[$matches[2]])) |
|
| 146 | - smf_db_error_backtrace('The database value you\'re trying to insert does not exist: ' . (isset($smcFunc['htmlspecialchars']) ? $smcFunc['htmlspecialchars']($matches[2]) : htmlspecialchars($matches[2])), '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 152 | + if (!isset($values[$matches[2]])) { |
|
| 153 | + smf_db_error_backtrace('The database value you\'re trying to insert does not exist: ' . (isset($smcFunc['htmlspecialchars']) ? $smcFunc['htmlspecialchars']($matches[2]) : htmlspecialchars($matches[2])), '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 154 | + } |
|
| 147 | 155 | |
| 148 | 156 | $replacement = $values[$matches[2]]; |
| 149 | 157 | |
| 150 | 158 | switch ($matches[1]) |
| 151 | 159 | { |
| 152 | 160 | case 'int': |
| 153 | - if (!is_numeric($replacement) || (string) $replacement !== (string) (int) $replacement) |
|
| 154 | - smf_db_error_backtrace('Wrong value type sent to the database. Integer expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 161 | + if (!is_numeric($replacement) || (string) $replacement !== (string) (int) $replacement) { |
|
| 162 | + smf_db_error_backtrace('Wrong value type sent to the database. Integer expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 163 | + } |
|
| 155 | 164 | return (string) (int) $replacement; |
| 156 | 165 | break; |
| 157 | 166 | |
@@ -163,65 +172,73 @@ discard block |
||
| 163 | 172 | case 'array_int': |
| 164 | 173 | if (is_array($replacement)) |
| 165 | 174 | { |
| 166 | - if (empty($replacement)) |
|
| 167 | - smf_db_error_backtrace('Database error, given array of integer values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 175 | + if (empty($replacement)) { |
|
| 176 | + smf_db_error_backtrace('Database error, given array of integer values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 177 | + } |
|
| 168 | 178 | |
| 169 | 179 | foreach ($replacement as $key => $value) |
| 170 | 180 | { |
| 171 | - if (!is_numeric($value) || (string) $value !== (string) (int) $value) |
|
| 172 | - smf_db_error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 181 | + if (!is_numeric($value) || (string) $value !== (string) (int) $value) { |
|
| 182 | + smf_db_error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 183 | + } |
|
| 173 | 184 | |
| 174 | 185 | $replacement[$key] = (string) (int) $value; |
| 175 | 186 | } |
| 176 | 187 | |
| 177 | 188 | return implode(', ', $replacement); |
| 189 | + } else { |
|
| 190 | + smf_db_error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 178 | 191 | } |
| 179 | - else |
|
| 180 | - smf_db_error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 181 | 192 | |
| 182 | 193 | break; |
| 183 | 194 | |
| 184 | 195 | case 'array_string': |
| 185 | 196 | if (is_array($replacement)) |
| 186 | 197 | { |
| 187 | - if (empty($replacement)) |
|
| 188 | - smf_db_error_backtrace('Database error, given array of string values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 198 | + if (empty($replacement)) { |
|
| 199 | + smf_db_error_backtrace('Database error, given array of string values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 200 | + } |
|
| 189 | 201 | |
| 190 | - foreach ($replacement as $key => $value) |
|
| 191 | - $replacement[$key] = sprintf('\'%1$s\'', pg_escape_string($value)); |
|
| 202 | + foreach ($replacement as $key => $value) { |
|
| 203 | + $replacement[$key] = sprintf('\'%1$s\'', pg_escape_string($value)); |
|
| 204 | + } |
|
| 192 | 205 | |
| 193 | 206 | return implode(', ', $replacement); |
| 207 | + } else { |
|
| 208 | + smf_db_error_backtrace('Wrong value type sent to the database. Array of strings expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 194 | 209 | } |
| 195 | - else |
|
| 196 | - smf_db_error_backtrace('Wrong value type sent to the database. Array of strings expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 197 | 210 | break; |
| 198 | 211 | |
| 199 | 212 | case 'date': |
| 200 | - if (preg_match('~^(\d{4})-([0-1]?\d)-([0-3]?\d)$~', $replacement, $date_matches) === 1) |
|
| 201 | - return sprintf('\'%04d-%02d-%02d\'', $date_matches[1], $date_matches[2], $date_matches[3]).'::date'; |
|
| 202 | - else |
|
| 203 | - smf_db_error_backtrace('Wrong value type sent to the database. Date expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 213 | + if (preg_match('~^(\d{4})-([0-1]?\d)-([0-3]?\d)$~', $replacement, $date_matches) === 1) { |
|
| 214 | + return sprintf('\'%04d-%02d-%02d\'', $date_matches[1], $date_matches[2], $date_matches[3]).'::date'; |
|
| 215 | + } else { |
|
| 216 | + smf_db_error_backtrace('Wrong value type sent to the database. Date expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 217 | + } |
|
| 204 | 218 | break; |
| 205 | 219 | |
| 206 | 220 | case 'time': |
| 207 | - if (preg_match('~^([0-1]?\d|2[0-3]):([0-5]\d):([0-5]\d)$~', $replacement, $time_matches) === 1) |
|
| 208 | - return sprintf('\'%02d:%02d:%02d\'', $time_matches[1], $time_matches[2], $time_matches[3]).'::time'; |
|
| 209 | - else |
|
| 210 | - smf_db_error_backtrace('Wrong value type sent to the database. Time expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 221 | + if (preg_match('~^([0-1]?\d|2[0-3]):([0-5]\d):([0-5]\d)$~', $replacement, $time_matches) === 1) { |
|
| 222 | + return sprintf('\'%02d:%02d:%02d\'', $time_matches[1], $time_matches[2], $time_matches[3]).'::time'; |
|
| 223 | + } else { |
|
| 224 | + smf_db_error_backtrace('Wrong value type sent to the database. Time expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 225 | + } |
|
| 211 | 226 | break; |
| 212 | 227 | |
| 213 | 228 | case 'datetime': |
| 214 | - if (preg_match('~^(\d{4})-([0-1]?\d)-([0-3]?\d) ([0-1]?\d|2[0-3]):([0-5]\d):([0-5]\d)$~', $replacement, $datetime_matches) === 1) |
|
| 215 | - return 'to_timestamp('. |
|
| 229 | + if (preg_match('~^(\d{4})-([0-1]?\d)-([0-3]?\d) ([0-1]?\d|2[0-3]):([0-5]\d):([0-5]\d)$~', $replacement, $datetime_matches) === 1) { |
|
| 230 | + return 'to_timestamp('. |
|
| 216 | 231 | sprintf('\'%04d-%02d-%02d %02d:%02d:%02d\'', $datetime_matches[1], $datetime_matches[2], $datetime_matches[3], $datetime_matches[4], $datetime_matches[5] ,$datetime_matches[6]). |
| 217 | 232 | ',\'YYYY-MM-DD HH24:MI:SS\')'; |
| 218 | - else |
|
| 219 | - smf_db_error_backtrace('Wrong value type sent to the database. Datetime expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 233 | + } else { |
|
| 234 | + smf_db_error_backtrace('Wrong value type sent to the database. Datetime expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 235 | + } |
|
| 220 | 236 | break; |
| 221 | 237 | |
| 222 | 238 | case 'float': |
| 223 | - if (!is_numeric($replacement)) |
|
| 224 | - smf_db_error_backtrace('Wrong value type sent to the database. Floating point number expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 239 | + if (!is_numeric($replacement)) { |
|
| 240 | + smf_db_error_backtrace('Wrong value type sent to the database. Floating point number expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 241 | + } |
|
| 225 | 242 | return (string) (float) $replacement; |
| 226 | 243 | break; |
| 227 | 244 | |
@@ -234,31 +251,36 @@ discard block |
||
| 234 | 251 | break; |
| 235 | 252 | |
| 236 | 253 | case 'inet': |
| 237 | - if ($replacement == 'null' || $replacement == '') |
|
| 238 | - return 'null'; |
|
| 239 | - if (inet_pton($replacement) === false) |
|
| 240 | - smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 254 | + if ($replacement == 'null' || $replacement == '') { |
|
| 255 | + return 'null'; |
|
| 256 | + } |
|
| 257 | + if (inet_pton($replacement) === false) { |
|
| 258 | + smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 259 | + } |
|
| 241 | 260 | return sprintf('\'%1$s\'::inet', pg_escape_string($replacement)); |
| 242 | 261 | |
| 243 | 262 | case 'array_inet': |
| 244 | 263 | if (is_array($replacement)) |
| 245 | 264 | { |
| 246 | - if (empty($replacement)) |
|
| 247 | - smf_db_error_backtrace('Database error, given array of IPv4 or IPv6 values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 265 | + if (empty($replacement)) { |
|
| 266 | + smf_db_error_backtrace('Database error, given array of IPv4 or IPv6 values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 267 | + } |
|
| 248 | 268 | |
| 249 | 269 | foreach ($replacement as $key => $value) |
| 250 | 270 | { |
| 251 | - if ($replacement == 'null' || $replacement == '') |
|
| 252 | - $replacement[$key] = 'null'; |
|
| 253 | - if (!isValidIP($value)) |
|
| 254 | - smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 271 | + if ($replacement == 'null' || $replacement == '') { |
|
| 272 | + $replacement[$key] = 'null'; |
|
| 273 | + } |
|
| 274 | + if (!isValidIP($value)) { |
|
| 275 | + smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 276 | + } |
|
| 255 | 277 | $replacement[$key] = sprintf('\'%1$s\'::inet', pg_escape_string($value)); |
| 256 | 278 | } |
| 257 | 279 | |
| 258 | 280 | return implode(', ', $replacement); |
| 281 | + } else { |
|
| 282 | + smf_db_error_backtrace('Wrong value type sent to the database. Array of IPv4 or IPv6 expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 259 | 283 | } |
| 260 | - else |
|
| 261 | - smf_db_error_backtrace('Wrong value type sent to the database. Array of IPv4 or IPv6 expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 262 | 284 | break; |
| 263 | 285 | |
| 264 | 286 | default: |
@@ -349,14 +371,16 @@ discard block |
||
| 349 | 371 | ), |
| 350 | 372 | ); |
| 351 | 373 | |
| 352 | - if (isset($replacements[$identifier])) |
|
| 353 | - $db_string = preg_replace(array_keys($replacements[$identifier]), array_values($replacements[$identifier]), $db_string); |
|
| 374 | + if (isset($replacements[$identifier])) { |
|
| 375 | + $db_string = preg_replace(array_keys($replacements[$identifier]), array_values($replacements[$identifier]), $db_string); |
|
| 376 | + } |
|
| 354 | 377 | |
| 355 | 378 | // Limits need to be a little different. |
| 356 | 379 | $db_string = preg_replace('~\sLIMIT\s(\d+|{int:.+}),\s*(\d+|{int:.+})\s*$~i', 'LIMIT $2 OFFSET $1', $db_string); |
| 357 | 380 | |
| 358 | - if (trim($db_string) == '') |
|
| 359 | - return false; |
|
| 381 | + if (trim($db_string) == '') { |
|
| 382 | + return false; |
|
| 383 | + } |
|
| 360 | 384 | |
| 361 | 385 | // Comments that are allowed in a query are preg_removed. |
| 362 | 386 | static $allowed_comments_from = array( |
@@ -376,8 +400,9 @@ discard block |
||
| 376 | 400 | $db_count = !isset($db_count) ? 1 : $db_count + 1; |
| 377 | 401 | $db_replace_result = 0; |
| 378 | 402 | |
| 379 | - if (empty($modSettings['disableQueryCheck']) && strpos($db_string, '\'') !== false && empty($db_values['security_override'])) |
|
| 380 | - smf_db_error_backtrace('Hacking attempt...', 'Illegal character (\') used in query...', true, __FILE__, __LINE__); |
|
| 403 | + if (empty($modSettings['disableQueryCheck']) && strpos($db_string, '\'') !== false && empty($db_values['security_override'])) { |
|
| 404 | + smf_db_error_backtrace('Hacking attempt...', 'Illegal character (\') used in query...', true, __FILE__, __LINE__); |
|
| 405 | + } |
|
| 381 | 406 | |
| 382 | 407 | if (empty($db_values['security_override']) && (!empty($db_values) || strpos($db_string, '{db_prefix}') !== false)) |
| 383 | 408 | { |
@@ -398,8 +423,9 @@ discard block |
||
| 398 | 423 | list ($file, $line) = smf_db_error_backtrace('', '', 'return', __FILE__, __LINE__); |
| 399 | 424 | |
| 400 | 425 | // Initialize $db_cache if not already initialized. |
| 401 | - if (!isset($db_cache)) |
|
| 402 | - $db_cache = array(); |
|
| 426 | + if (!isset($db_cache)) { |
|
| 427 | + $db_cache = array(); |
|
| 428 | + } |
|
| 403 | 429 | |
| 404 | 430 | if (!empty($_SESSION['debug_redirect'])) |
| 405 | 431 | { |
@@ -425,17 +451,18 @@ discard block |
||
| 425 | 451 | while (true) |
| 426 | 452 | { |
| 427 | 453 | $pos = strpos($db_string, '\'', $pos + 1); |
| 428 | - if ($pos === false) |
|
| 429 | - break; |
|
| 454 | + if ($pos === false) { |
|
| 455 | + break; |
|
| 456 | + } |
|
| 430 | 457 | $clean .= substr($db_string, $old_pos, $pos - $old_pos); |
| 431 | 458 | |
| 432 | 459 | while (true) |
| 433 | 460 | { |
| 434 | 461 | $pos1 = strpos($db_string, '\'', $pos + 1); |
| 435 | 462 | $pos2 = strpos($db_string, '\\', $pos + 1); |
| 436 | - if ($pos1 === false) |
|
| 437 | - break; |
|
| 438 | - elseif ($pos2 === false || $pos2 > $pos1) |
|
| 463 | + if ($pos1 === false) { |
|
| 464 | + break; |
|
| 465 | + } elseif ($pos2 === false || $pos2 > $pos1) |
|
| 439 | 466 | { |
| 440 | 467 | $pos = $pos1; |
| 441 | 468 | break; |
@@ -451,16 +478,19 @@ discard block |
||
| 451 | 478 | $clean = trim(strtolower(preg_replace($allowed_comments_from, $allowed_comments_to, $clean))); |
| 452 | 479 | |
| 453 | 480 | // Comments? We don't use comments in our queries, we leave 'em outside! |
| 454 | - if (strpos($clean, '/*') > 2 || strpos($clean, '--') !== false || strpos($clean, ';') !== false) |
|
| 455 | - $fail = true; |
|
| 481 | + if (strpos($clean, '/*') > 2 || strpos($clean, '--') !== false || strpos($clean, ';') !== false) { |
|
| 482 | + $fail = true; |
|
| 483 | + } |
|
| 456 | 484 | // Trying to change passwords, slow us down, or something? |
| 457 | - elseif (strpos($clean, 'sleep') !== false && preg_match('~(^|[^a-z])sleep($|[^[_a-z])~s', $clean) != 0) |
|
| 458 | - $fail = true; |
|
| 459 | - elseif (strpos($clean, 'benchmark') !== false && preg_match('~(^|[^a-z])benchmark($|[^[a-z])~s', $clean) != 0) |
|
| 460 | - $fail = true; |
|
| 485 | + elseif (strpos($clean, 'sleep') !== false && preg_match('~(^|[^a-z])sleep($|[^[_a-z])~s', $clean) != 0) { |
|
| 486 | + $fail = true; |
|
| 487 | + } elseif (strpos($clean, 'benchmark') !== false && preg_match('~(^|[^a-z])benchmark($|[^[a-z])~s', $clean) != 0) { |
|
| 488 | + $fail = true; |
|
| 489 | + } |
|
| 461 | 490 | |
| 462 | - if (!empty($fail) && function_exists('log_error')) |
|
| 463 | - smf_db_error_backtrace('Hacking attempt...', 'Hacking attempt...' . "\n" . $db_string, E_USER_ERROR, __FILE__, __LINE__); |
|
| 491 | + if (!empty($fail) && function_exists('log_error')) { |
|
| 492 | + smf_db_error_backtrace('Hacking attempt...', 'Hacking attempt...' . "\n" . $db_string, E_USER_ERROR, __FILE__, __LINE__); |
|
| 493 | + } |
|
| 464 | 494 | } |
| 465 | 495 | |
| 466 | 496 | // Set optimize stuff |
@@ -479,18 +509,21 @@ discard block |
||
| 479 | 509 | |
| 480 | 510 | $db_string = $query_hints_set . $db_string; |
| 481 | 511 | |
| 482 | - if (isset($db_show_debug) && $db_show_debug === true && $db_cache[$db_count]['q'] != '...') |
|
| 483 | - $db_cache[$db_count]['q'] = "\t\t" . $db_string; |
|
| 512 | + if (isset($db_show_debug) && $db_show_debug === true && $db_cache[$db_count]['q'] != '...') { |
|
| 513 | + $db_cache[$db_count]['q'] = "\t\t" . $db_string; |
|
| 514 | + } |
|
| 484 | 515 | } |
| 485 | 516 | |
| 486 | 517 | $db_last_result = @pg_query($connection, $db_string); |
| 487 | 518 | |
| 488 | - if ($db_last_result === false && empty($db_values['db_error_skip'])) |
|
| 489 | - $db_last_result = smf_db_error($db_string, $connection); |
|
| 519 | + if ($db_last_result === false && empty($db_values['db_error_skip'])) { |
|
| 520 | + $db_last_result = smf_db_error($db_string, $connection); |
|
| 521 | + } |
|
| 490 | 522 | |
| 491 | 523 | // Debugging. |
| 492 | - if (isset($db_show_debug) && $db_show_debug === true) |
|
| 493 | - $db_cache[$db_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st)); |
|
| 524 | + if (isset($db_show_debug) && $db_show_debug === true) { |
|
| 525 | + $db_cache[$db_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st)); |
|
| 526 | + } |
|
| 494 | 527 | |
| 495 | 528 | return $db_last_result; |
| 496 | 529 | } |
@@ -507,10 +540,11 @@ discard block |
||
| 507 | 540 | { |
| 508 | 541 | global $db_last_result, $db_replace_result; |
| 509 | 542 | |
| 510 | - if ($db_replace_result) |
|
| 511 | - return $db_replace_result; |
|
| 512 | - elseif ($result === null && !$db_last_result) |
|
| 513 | - return 0; |
|
| 543 | + if ($db_replace_result) { |
|
| 544 | + return $db_replace_result; |
|
| 545 | + } elseif ($result === null && !$db_last_result) { |
|
| 546 | + return 0; |
|
| 547 | + } |
|
| 514 | 548 | |
| 515 | 549 | return pg_affected_rows($result === null ? $db_last_result : $result); |
| 516 | 550 | } |
@@ -534,8 +568,9 @@ discard block |
||
| 534 | 568 | array( |
| 535 | 569 | ) |
| 536 | 570 | ); |
| 537 | - if (!$request) |
|
| 538 | - return false; |
|
| 571 | + if (!$request) { |
|
| 572 | + return false; |
|
| 573 | + } |
|
| 539 | 574 | list ($lastID) = $smcFunc['db_fetch_row']($request); |
| 540 | 575 | $smcFunc['db_free_result']($request); |
| 541 | 576 | |
@@ -556,12 +591,13 @@ discard block |
||
| 556 | 591 | // Decide which connection to use |
| 557 | 592 | $connection = $connection === null ? $db_connection : $connection; |
| 558 | 593 | |
| 559 | - if ($type == 'begin') |
|
| 560 | - return @pg_query($connection, 'BEGIN'); |
|
| 561 | - elseif ($type == 'rollback') |
|
| 562 | - return @pg_query($connection, 'ROLLBACK'); |
|
| 563 | - elseif ($type == 'commit') |
|
| 564 | - return @pg_query($connection, 'COMMIT'); |
|
| 594 | + if ($type == 'begin') { |
|
| 595 | + return @pg_query($connection, 'BEGIN'); |
|
| 596 | + } elseif ($type == 'rollback') { |
|
| 597 | + return @pg_query($connection, 'ROLLBACK'); |
|
| 598 | + } elseif ($type == 'commit') { |
|
| 599 | + return @pg_query($connection, 'COMMIT'); |
|
| 600 | + } |
|
| 565 | 601 | |
| 566 | 602 | return false; |
| 567 | 603 | } |
@@ -589,19 +625,22 @@ discard block |
||
| 589 | 625 | $query_error = @pg_last_error($connection); |
| 590 | 626 | |
| 591 | 627 | // Log the error. |
| 592 | - if (function_exists('log_error')) |
|
| 593 | - log_error($txt['database_error'] . ': ' . $query_error . (!empty($modSettings['enableErrorQueryLogging']) ? "\n\n" . $db_string : ''), 'database', $file, $line); |
|
| 628 | + if (function_exists('log_error')) { |
|
| 629 | + log_error($txt['database_error'] . ': ' . $query_error . (!empty($modSettings['enableErrorQueryLogging']) ? "\n\n" . $db_string : ''), 'database', $file, $line); |
|
| 630 | + } |
|
| 594 | 631 | |
| 595 | 632 | // Nothing's defined yet... just die with it. |
| 596 | - if (empty($context) || empty($txt)) |
|
| 597 | - die($query_error); |
|
| 633 | + if (empty($context) || empty($txt)) { |
|
| 634 | + die($query_error); |
|
| 635 | + } |
|
| 598 | 636 | |
| 599 | 637 | // Show an error message, if possible. |
| 600 | 638 | $context['error_title'] = $txt['database_error']; |
| 601 | - if (allowedTo('admin_forum')) |
|
| 602 | - $context['error_message'] = nl2br($query_error) . '<br>' . $txt['file'] . ': ' . $file . '<br>' . $txt['line'] . ': ' . $line; |
|
| 603 | - else |
|
| 604 | - $context['error_message'] = $txt['try_again']; |
|
| 639 | + if (allowedTo('admin_forum')) { |
|
| 640 | + $context['error_message'] = nl2br($query_error) . '<br>' . $txt['file'] . ': ' . $file . '<br>' . $txt['line'] . ': ' . $line; |
|
| 641 | + } else { |
|
| 642 | + $context['error_message'] = $txt['try_again']; |
|
| 643 | + } |
|
| 605 | 644 | |
| 606 | 645 | if (allowedTo('admin_forum') && isset($db_show_debug) && $db_show_debug === true) |
| 607 | 646 | { |
@@ -623,12 +662,14 @@ discard block |
||
| 623 | 662 | { |
| 624 | 663 | global $db_row_count; |
| 625 | 664 | |
| 626 | - if ($counter !== false) |
|
| 627 | - return pg_fetch_row($request, $counter); |
|
| 665 | + if ($counter !== false) { |
|
| 666 | + return pg_fetch_row($request, $counter); |
|
| 667 | + } |
|
| 628 | 668 | |
| 629 | 669 | // Reset the row counter... |
| 630 | - if (!isset($db_row_count[(int) $request])) |
|
| 631 | - $db_row_count[(int) $request] = 0; |
|
| 670 | + if (!isset($db_row_count[(int) $request])) { |
|
| 671 | + $db_row_count[(int) $request] = 0; |
|
| 672 | + } |
|
| 632 | 673 | |
| 633 | 674 | // Return the right row. |
| 634 | 675 | return @pg_fetch_row($request, $db_row_count[(int) $request]++); |
@@ -645,12 +686,14 @@ discard block |
||
| 645 | 686 | { |
| 646 | 687 | global $db_row_count; |
| 647 | 688 | |
| 648 | - if ($counter !== false) |
|
| 649 | - return pg_fetch_assoc($request, $counter); |
|
| 689 | + if ($counter !== false) { |
|
| 690 | + return pg_fetch_assoc($request, $counter); |
|
| 691 | + } |
|
| 650 | 692 | |
| 651 | 693 | // Reset the row counter... |
| 652 | - if (!isset($db_row_count[(int) $request])) |
|
| 653 | - $db_row_count[(int) $request] = 0; |
|
| 694 | + if (!isset($db_row_count[(int) $request])) { |
|
| 695 | + $db_row_count[(int) $request] = 0; |
|
| 696 | + } |
|
| 654 | 697 | |
| 655 | 698 | // Return the right row. |
| 656 | 699 | return @pg_fetch_assoc($request, $db_row_count[(int) $request]++); |
@@ -703,11 +746,13 @@ discard block |
||
| 703 | 746 | |
| 704 | 747 | $replace = ''; |
| 705 | 748 | |
| 706 | - if (empty($data)) |
|
| 707 | - return; |
|
| 749 | + if (empty($data)) { |
|
| 750 | + return; |
|
| 751 | + } |
|
| 708 | 752 | |
| 709 | - if (!is_array($data[array_rand($data)])) |
|
| 710 | - $data = array($data); |
|
| 753 | + if (!is_array($data[array_rand($data)])) { |
|
| 754 | + $data = array($data); |
|
| 755 | + } |
|
| 711 | 756 | |
| 712 | 757 | // Replace the prefix holder with the actual prefix. |
| 713 | 758 | $table = str_replace('{db_prefix}', $db_prefix, $table); |
@@ -726,11 +771,13 @@ discard block |
||
| 726 | 771 | //pg 9.5 got replace support |
| 727 | 772 | $pg_version = $smcFunc['db_get_version'](); |
| 728 | 773 | // if we got a Beta Version |
| 729 | - if (stripos($pg_version, 'beta') !== false) |
|
| 730 | - $pg_version = substr($pg_version, 0, stripos($pg_version, 'beta')) . '.0'; |
|
| 774 | + if (stripos($pg_version, 'beta') !== false) { |
|
| 775 | + $pg_version = substr($pg_version, 0, stripos($pg_version, 'beta')) . '.0'; |
|
| 776 | + } |
|
| 731 | 777 | // or RC |
| 732 | - if (stripos($pg_version, 'rc') !== false) |
|
| 733 | - $pg_version = substr($pg_version, 0, stripos($pg_version, 'rc')) . '.0'; |
|
| 778 | + if (stripos($pg_version, 'rc') !== false) { |
|
| 779 | + $pg_version = substr($pg_version, 0, stripos($pg_version, 'rc')) . '.0'; |
|
| 780 | + } |
|
| 734 | 781 | |
| 735 | 782 | $replace_support = (version_compare($pg_version, '9.5.0', '>=') ? true : false); |
| 736 | 783 | } |
@@ -749,32 +796,35 @@ discard block |
||
| 749 | 796 | $key_str .= ($count_pk > 0 ? ',' : ''); |
| 750 | 797 | $key_str .= $columnName; |
| 751 | 798 | $count_pk++; |
| 752 | - } |
|
| 753 | - else if ($method == 'replace') //normal field |
|
| 799 | + } else if ($method == 'replace') { |
|
| 800 | + //normal field |
|
| 754 | 801 | { |
| 755 | 802 | $col_str .= ($count > 0 ? ',' : ''); |
| 803 | + } |
|
| 756 | 804 | $col_str .= $columnName . ' = EXCLUDED.' . $columnName; |
| 757 | 805 | $count++; |
| 758 | 806 | } |
| 759 | 807 | } |
| 760 | - if ($method == 'replace') |
|
| 761 | - $replace = ' ON CONFLICT (' . $key_str . ') DO UPDATE SET ' . $col_str; |
|
| 762 | - else |
|
| 763 | - $replace = ' ON CONFLICT (' . $key_str . ') DO NOTHING'; |
|
| 764 | - } |
|
| 765 | - else if ($method == 'replace') |
|
| 808 | + if ($method == 'replace') { |
|
| 809 | + $replace = ' ON CONFLICT (' . $key_str . ') DO UPDATE SET ' . $col_str; |
|
| 810 | + } else { |
|
| 811 | + $replace = ' ON CONFLICT (' . $key_str . ') DO NOTHING'; |
|
| 812 | + } |
|
| 813 | + } else if ($method == 'replace') |
|
| 766 | 814 | { |
| 767 | 815 | foreach ($columns as $columnName => $type) |
| 768 | 816 | { |
| 769 | 817 | // Are we restricting the length? |
| 770 | - if (strpos($type, 'string-') !== false) |
|
| 771 | - $actualType = sprintf($columnName . ' = SUBSTRING({string:%1$s}, 1, ' . substr($type, 7) . '), ', $count); |
|
| 772 | - else |
|
| 773 | - $actualType = sprintf($columnName . ' = {%1$s:%2$s}, ', $type, $count); |
|
| 818 | + if (strpos($type, 'string-') !== false) { |
|
| 819 | + $actualType = sprintf($columnName . ' = SUBSTRING({string:%1$s}, 1, ' . substr($type, 7) . '), ', $count); |
|
| 820 | + } else { |
|
| 821 | + $actualType = sprintf($columnName . ' = {%1$s:%2$s}, ', $type, $count); |
|
| 822 | + } |
|
| 774 | 823 | |
| 775 | 824 | // A key? That's what we were looking for. |
| 776 | - if (in_array($columnName, $keys)) |
|
| 777 | - $where .= (empty($where) ? '' : ' AND ') . substr($actualType, 0, -2); |
|
| 825 | + if (in_array($columnName, $keys)) { |
|
| 826 | + $where .= (empty($where) ? '' : ' AND ') . substr($actualType, 0, -2); |
|
| 827 | + } |
|
| 778 | 828 | $count++; |
| 779 | 829 | } |
| 780 | 830 | |
@@ -810,10 +860,11 @@ discard block |
||
| 810 | 860 | foreach ($columns as $columnName => $type) |
| 811 | 861 | { |
| 812 | 862 | // Are we restricting the length? |
| 813 | - if (strpos($type, 'string-') !== false) |
|
| 814 | - $insertData .= sprintf('SUBSTRING({string:%1$s}, 1, ' . substr($type, 7) . '), ', $columnName); |
|
| 815 | - else |
|
| 816 | - $insertData .= sprintf('{%1$s:%2$s}, ', $type, $columnName); |
|
| 863 | + if (strpos($type, 'string-') !== false) { |
|
| 864 | + $insertData .= sprintf('SUBSTRING({string:%1$s}, 1, ' . substr($type, 7) . '), ', $columnName); |
|
| 865 | + } else { |
|
| 866 | + $insertData .= sprintf('{%1$s:%2$s}, ', $type, $columnName); |
|
| 867 | + } |
|
| 817 | 868 | } |
| 818 | 869 | $insertData = substr($insertData, 0, -2) . ')'; |
| 819 | 870 | |
@@ -822,8 +873,9 @@ discard block |
||
| 822 | 873 | |
| 823 | 874 | // Here's where the variables are injected to the query. |
| 824 | 875 | $insertRows = array(); |
| 825 | - foreach ($data as $dataRow) |
|
| 826 | - $insertRows[] = smf_db_quote($insertData, array_combine($indexed_columns, $dataRow), $connection); |
|
| 876 | + foreach ($data as $dataRow) { |
|
| 877 | + $insertRows[] = smf_db_quote($insertData, array_combine($indexed_columns, $dataRow), $connection); |
|
| 878 | + } |
|
| 827 | 879 | |
| 828 | 880 | // Do the insert. |
| 829 | 881 | $request = $smcFunc['db_query']('', ' |
@@ -840,19 +892,21 @@ discard block |
||
| 840 | 892 | |
| 841 | 893 | if ($with_returning && $request !== false) |
| 842 | 894 | { |
| 843 | - if ($returnmode === 2) |
|
| 844 | - $return_var = array(); |
|
| 895 | + if ($returnmode === 2) { |
|
| 896 | + $return_var = array(); |
|
| 897 | + } |
|
| 845 | 898 | |
| 846 | 899 | while(($row = $smcFunc['db_fetch_row']($request)) && $with_returning) |
| 847 | 900 | { |
| 848 | - if (is_numeric($row[0])) // try to emulate mysql limitation |
|
| 901 | + if (is_numeric($row[0])) { |
|
| 902 | + // try to emulate mysql limitation |
|
| 849 | 903 | { |
| 850 | 904 | if ($returnmode === 1) |
| 851 | 905 | $return_var = $row[0]; |
| 852 | - elseif ($returnmode === 2) |
|
| 853 | - $return_var[] = $row[0]; |
|
| 854 | - } |
|
| 855 | - else |
|
| 906 | + } elseif ($returnmode === 2) { |
|
| 907 | + $return_var[] = $row[0]; |
|
| 908 | + } |
|
| 909 | + } else |
|
| 856 | 910 | { |
| 857 | 911 | $with_returning = false; |
| 858 | 912 | trigger_error('trying to returning ID Field which is not a Int field', E_USER_ERROR); |
@@ -861,9 +915,10 @@ discard block |
||
| 861 | 915 | } |
| 862 | 916 | } |
| 863 | 917 | |
| 864 | - if ($with_returning && !empty($return_var)) |
|
| 865 | - return $return_var; |
|
| 866 | -} |
|
| 918 | + if ($with_returning && !empty($return_var)) { |
|
| 919 | + return $return_var; |
|
| 920 | + } |
|
| 921 | + } |
|
| 867 | 922 | |
| 868 | 923 | /** |
| 869 | 924 | * Dummy function really. Doesn't do anything on PostgreSQL. |
@@ -900,8 +955,9 @@ discard block |
||
| 900 | 955 | */ |
| 901 | 956 | function smf_db_error_backtrace($error_message, $log_message = '', $error_type = false, $file = null, $line = null) |
| 902 | 957 | { |
| 903 | - if (empty($log_message)) |
|
| 904 | - $log_message = $error_message; |
|
| 958 | + if (empty($log_message)) { |
|
| 959 | + $log_message = $error_message; |
|
| 960 | + } |
|
| 905 | 961 | |
| 906 | 962 | foreach (debug_backtrace() as $step) |
| 907 | 963 | { |
@@ -920,12 +976,14 @@ discard block |
||
| 920 | 976 | } |
| 921 | 977 | |
| 922 | 978 | // A special case - we want the file and line numbers for debugging. |
| 923 | - if ($error_type == 'return') |
|
| 924 | - return array($file, $line); |
|
| 979 | + if ($error_type == 'return') { |
|
| 980 | + return array($file, $line); |
|
| 981 | + } |
|
| 925 | 982 | |
| 926 | 983 | // Is always a critical error. |
| 927 | - if (function_exists('log_error')) |
|
| 928 | - log_error($log_message, 'critical', $file, $line); |
|
| 984 | + if (function_exists('log_error')) { |
|
| 985 | + log_error($log_message, 'critical', $file, $line); |
|
| 986 | + } |
|
| 929 | 987 | |
| 930 | 988 | if (function_exists('fatal_error')) |
| 931 | 989 | { |
@@ -933,12 +991,12 @@ discard block |
||
| 933 | 991 | |
| 934 | 992 | // Cannot continue... |
| 935 | 993 | exit; |
| 994 | + } elseif ($error_type) { |
|
| 995 | + trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : ''), $error_type); |
|
| 996 | + } else { |
|
| 997 | + trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : '')); |
|
| 998 | + } |
|
| 936 | 999 | } |
| 937 | - elseif ($error_type) |
|
| 938 | - trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : ''), $error_type); |
|
| 939 | - else |
|
| 940 | - trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : '')); |
|
| 941 | -} |
|
| 942 | 1000 | |
| 943 | 1001 | /** |
| 944 | 1002 | * Escape the LIKE wildcards so that they match the character and not the wildcard. |
@@ -955,10 +1013,11 @@ discard block |
||
| 955 | 1013 | '\\' => '\\\\', |
| 956 | 1014 | ); |
| 957 | 1015 | |
| 958 | - if ($translate_human_wildcards) |
|
| 959 | - $replacements += array( |
|
| 1016 | + if ($translate_human_wildcards) { |
|
| 1017 | + $replacements += array( |
|
| 960 | 1018 | '*' => '%', |
| 961 | 1019 | ); |
| 1020 | + } |
|
| 962 | 1021 | |
| 963 | 1022 | return strtr($string, $replacements); |
| 964 | 1023 | } |
@@ -986,11 +1045,12 @@ discard block |
||
| 986 | 1045 | global $db_prefix, $db_connection; |
| 987 | 1046 | static $pg_error_data_prep; |
| 988 | 1047 | |
| 989 | - if (empty($pg_error_data_prep)) |
|
| 990 | - $pg_error_data_prep = pg_prepare($db_connection, 'smf_log_errors', |
|
| 1048 | + if (empty($pg_error_data_prep)) { |
|
| 1049 | + $pg_error_data_prep = pg_prepare($db_connection, 'smf_log_errors', |
|
| 991 | 1050 | 'INSERT INTO ' . $db_prefix . 'log_errors(id_member, log_time, ip, url, message, session, error_type, file, line) |
| 992 | 1051 | VALUES( $1, $2, $3, $4, $5, $6, $7, $8, $9)' |
| 993 | 1052 | ); |
| 1053 | + } |
|
| 994 | 1054 | |
| 995 | 1055 | pg_execute($db_connection, 'smf_log_errors', $error_array); |
| 996 | 1056 | } |
@@ -144,11 +144,12 @@ discard block |
||
| 144 | 144 | <div class="question">', $txt['poll_question'], ': <strong>', $context['poll']['question'], '</strong>'; |
| 145 | 145 | |
| 146 | 146 | $options = 1; |
| 147 | - foreach ($context['poll']['options'] as $option) |
|
| 148 | - echo ' |
|
| 147 | + foreach ($context['poll']['options'] as $option) { |
|
| 148 | + echo ' |
|
| 149 | 149 | <div class="', $option['voted_this'] ? 'voted' : '', '">', $txt['option'], ' ', $options++, ': <strong>', $option['option'], '</strong> |
| 150 | 150 | ', $context['allow_poll_view'] ? $txt['votes'] . ': ' . $option['votes'] . '' : '', ' |
| 151 | 151 | </div>'; |
| 152 | + } |
|
| 152 | 153 | |
| 153 | 154 | echo ' |
| 154 | 155 | </div>'; |
@@ -170,9 +171,10 @@ discard block |
||
| 170 | 171 | echo ' |
| 171 | 172 | <hr>'; |
| 172 | 173 | |
| 173 | - foreach ($context['printattach'][$post['id_msg']] as $attach) |
|
| 174 | - echo ' |
|
| 174 | + foreach ($context['printattach'][$post['id_msg']] as $attach) { |
|
| 175 | + echo ' |
|
| 175 | 176 | <img width="' . $attach['width'] . '" height="' . $attach['height'] . '" src="', $scripturl . '?action=dlattach;topic=' . $topic . '.0;attach=' . $attach['id_attach'] . '" alt="">'; |
| 177 | + } |
|
| 176 | 178 | } |
| 177 | 179 | |
| 178 | 180 | echo ' |
@@ -207,12 +209,13 @@ discard block |
||
| 207 | 209 | <div class="print_options">'; |
| 208 | 210 | |
| 209 | 211 | // Which option is set, text or text&images |
| 210 | - if (isset($_REQUEST['images'])) |
|
| 211 | - echo ' |
|
| 212 | + if (isset($_REQUEST['images'])) { |
|
| 213 | + echo ' |
|
| 212 | 214 | <a href="', $url_text, '">', $txt['print_page_text'], '</a> | <strong><a href="', $url_images, '">', $txt['print_page_images'], '</a></strong>'; |
| 213 | - else |
|
| 214 | - echo ' |
|
| 215 | + } else { |
|
| 216 | + echo ' |
|
| 215 | 217 | <strong><a href="', $url_text, '">', $txt['print_page_text'], '</a></strong> | <a href="', $url_images, '">', $txt['print_page_images'], '</a>'; |
| 218 | + } |
|
| 216 | 219 | |
| 217 | 220 | echo ' |
| 218 | 221 | </div><!-- .print_options -->'; |
@@ -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 | * Downloads an avatar or attachment based on $_GET['attach'], and increments the download count. |
@@ -40,11 +41,11 @@ discard block |
||
| 40 | 41 | |
| 41 | 42 | if (!empty($modSettings['enableCompressedOutput']) && !headers_sent() && ob_get_length() == 0) |
| 42 | 43 | { |
| 43 | - if (@ini_get('zlib.output_compression') == '1' || @ini_get('output_handler') == 'ob_gzhandler') |
|
| 44 | - $modSettings['enableCompressedOutput'] = 0; |
|
| 45 | - |
|
| 46 | - else |
|
| 47 | - ob_start('ob_gzhandler'); |
|
| 44 | + if (@ini_get('zlib.output_compression') == '1' || @ini_get('output_handler') == 'ob_gzhandler') { |
|
| 45 | + $modSettings['enableCompressedOutput'] = 0; |
|
| 46 | + } else { |
|
| 47 | + ob_start('ob_gzhandler'); |
|
| 48 | + } |
|
| 48 | 49 | } |
| 49 | 50 | |
| 50 | 51 | if (empty($modSettings['enableCompressedOutput'])) |
@@ -76,8 +77,9 @@ discard block |
||
| 76 | 77 | } |
| 77 | 78 | |
| 78 | 79 | // Use cache when possible. |
| 79 | - if (($cache = cache_get_data('attachment_lookup_id-' . $attachId)) != null) |
|
| 80 | - list($file, $thumbFile) = $cache; |
|
| 80 | + if (($cache = cache_get_data('attachment_lookup_id-' . $attachId)) != null) { |
|
| 81 | + list($file, $thumbFile) = $cache; |
|
| 82 | + } |
|
| 81 | 83 | |
| 82 | 84 | // Get the info from the DB. |
| 83 | 85 | if (empty($file) || empty($thumbFile) && !empty($file['id_thumb'])) |
@@ -85,10 +87,9 @@ discard block |
||
| 85 | 87 | // Do we have a hook wanting to use our attachment system? We use $attachRequest to prevent accidental usage of $request. |
| 86 | 88 | $attachRequest = null; |
| 87 | 89 | call_integration_hook('integrate_download_request', array(&$attachRequest)); |
| 88 | - if (!is_null($attachRequest) && $smcFunc['db_is_resource']($attachRequest)) |
|
| 89 | - $request = $attachRequest; |
|
| 90 | - |
|
| 91 | - else |
|
| 90 | + if (!is_null($attachRequest) && $smcFunc['db_is_resource']($attachRequest)) { |
|
| 91 | + $request = $attachRequest; |
|
| 92 | + } else |
|
| 92 | 93 | { |
| 93 | 94 | // Make sure this attachment is on this board and load its info while we are at it. |
| 94 | 95 | $request = $smcFunc['db_query']('', ' |
@@ -181,13 +182,15 @@ discard block |
||
| 181 | 182 | } |
| 182 | 183 | |
| 183 | 184 | // Cache it. |
| 184 | - if (!empty($file) || !empty($thumbFile)) |
|
| 185 | - cache_put_data('attachment_lookup_id-' . $file['id_attach'], array($file, $thumbFile), mt_rand(850, 900)); |
|
| 185 | + if (!empty($file) || !empty($thumbFile)) { |
|
| 186 | + cache_put_data('attachment_lookup_id-' . $file['id_attach'], array($file, $thumbFile), mt_rand(850, 900)); |
|
| 187 | + } |
|
| 186 | 188 | } |
| 187 | 189 | |
| 188 | 190 | // Replace the normal file with its thumbnail if it has one! |
| 189 | - if (!empty($showThumb) && !empty($thumbFile)) |
|
| 190 | - $file = $thumbFile; |
|
| 191 | + if (!empty($showThumb) && !empty($thumbFile)) { |
|
| 192 | + $file = $thumbFile; |
|
| 193 | + } |
|
| 191 | 194 | |
| 192 | 195 | // No point in a nicer message, because this is supposed to be an attachment anyway... |
| 193 | 196 | if (!file_exists($file['filePath'])) |
@@ -237,8 +240,8 @@ discard block |
||
| 237 | 240 | } |
| 238 | 241 | |
| 239 | 242 | // Update the download counter (unless it's a thumbnail or resuming an incomplete download). |
| 240 | - if ($file['attachment_type'] != 3 && empty($showThumb) && $range === 0) |
|
| 241 | - $smcFunc['db_query']('', ' |
|
| 243 | + if ($file['attachment_type'] != 3 && empty($showThumb) && $range === 0) { |
|
| 244 | + $smcFunc['db_query']('', ' |
|
| 242 | 245 | UPDATE {db_prefix}attachments |
| 243 | 246 | SET downloads = downloads + 1 |
| 244 | 247 | WHERE id_attach = {int:id_attach}', |
@@ -246,12 +249,14 @@ discard block |
||
| 246 | 249 | 'id_attach' => $attachId, |
| 247 | 250 | ) |
| 248 | 251 | ); |
| 252 | + } |
|
| 249 | 253 | |
| 250 | 254 | // Send the attachment headers. |
| 251 | 255 | header('Pragma: '); |
| 252 | 256 | |
| 253 | - if (!isBrowser('gecko')) |
|
| 254 | - header('Content-Transfer-Encoding: binary'); |
|
| 257 | + if (!isBrowser('gecko')) { |
|
| 258 | + header('Content-Transfer-Encoding: binary'); |
|
| 259 | + } |
|
| 255 | 260 | |
| 256 | 261 | header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 525600 * 60) . ' GMT'); |
| 257 | 262 | header('Last-Modified: ' . gmdate('D, d M Y H:i:s', filemtime($file['filePath'])) . ' GMT'); |
@@ -260,18 +265,19 @@ discard block |
||
| 260 | 265 | header('ETag: ' . $eTag); |
| 261 | 266 | |
| 262 | 267 | // Make sure the mime type warrants an inline display. |
| 263 | - if (isset($_REQUEST['image']) && !empty($file['mime_type']) && strpos($file['mime_type'], 'image/') !== 0) |
|
| 264 | - unset($_REQUEST['image']); |
|
| 268 | + if (isset($_REQUEST['image']) && !empty($file['mime_type']) && strpos($file['mime_type'], 'image/') !== 0) { |
|
| 269 | + unset($_REQUEST['image']); |
|
| 270 | + } |
|
| 265 | 271 | |
| 266 | 272 | // Does this have a mime type? |
| 267 | - elseif (!empty($file['mime_type']) && (isset($_REQUEST['image']) || !in_array($file['fileext'], array('jpg', 'gif', 'jpeg', 'x-ms-bmp', 'png', 'psd', 'tiff', 'iff')))) |
|
| 268 | - header('Content-Type: ' . strtr($file['mime_type'], array('image/bmp' => 'image/x-ms-bmp'))); |
|
| 269 | - |
|
| 270 | - else |
|
| 273 | + elseif (!empty($file['mime_type']) && (isset($_REQUEST['image']) || !in_array($file['fileext'], array('jpg', 'gif', 'jpeg', 'x-ms-bmp', 'png', 'psd', 'tiff', 'iff')))) { |
|
| 274 | + header('Content-Type: ' . strtr($file['mime_type'], array('image/bmp' => 'image/x-ms-bmp'))); |
|
| 275 | + } else |
|
| 271 | 276 | { |
| 272 | 277 | header('Content-Type: ' . (isBrowser('ie') || isBrowser('opera') ? 'application/octetstream' : 'application/octet-stream')); |
| 273 | - if (isset($_REQUEST['image'])) |
|
| 274 | - unset($_REQUEST['image']); |
|
| 278 | + if (isset($_REQUEST['image'])) { |
|
| 279 | + unset($_REQUEST['image']); |
|
| 280 | + } |
|
| 275 | 281 | } |
| 276 | 282 | |
| 277 | 283 | // Convert the file to UTF-8, cuz most browsers dig that. |
@@ -279,24 +285,22 @@ discard block |
||
| 279 | 285 | $disposition = !isset($_REQUEST['image']) ? 'attachment' : 'inline'; |
| 280 | 286 | |
| 281 | 287 | // Different browsers like different standards... |
| 282 | - if (isBrowser('firefox')) |
|
| 283 | - header('Content-Disposition: ' . $disposition . '; filename*=UTF-8\'\'' . rawurlencode(preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name))); |
|
| 284 | - |
|
| 285 | - elseif (isBrowser('opera')) |
|
| 286 | - header('Content-Disposition: ' . $disposition . '; filename="' . preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name) . '"'); |
|
| 287 | - |
|
| 288 | - elseif (isBrowser('ie')) |
|
| 289 | - header('Content-Disposition: ' . $disposition . '; filename="' . urlencode(preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name)) . '"'); |
|
| 290 | - |
|
| 291 | - else |
|
| 292 | - header('Content-Disposition: ' . $disposition . '; filename="' . $utf8name . '"'); |
|
| 288 | + if (isBrowser('firefox')) { |
|
| 289 | + header('Content-Disposition: ' . $disposition . '; filename*=UTF-8\'\'' . rawurlencode(preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name))); |
|
| 290 | + } elseif (isBrowser('opera')) { |
|
| 291 | + header('Content-Disposition: ' . $disposition . '; filename="' . preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name) . '"'); |
|
| 292 | + } elseif (isBrowser('ie')) { |
|
| 293 | + header('Content-Disposition: ' . $disposition . '; filename="' . urlencode(preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name)) . '"'); |
|
| 294 | + } else { |
|
| 295 | + header('Content-Disposition: ' . $disposition . '; filename="' . $utf8name . '"'); |
|
| 296 | + } |
|
| 293 | 297 | |
| 294 | 298 | // If this has an "image extension" - but isn't actually an image - then ensure it isn't cached cause of silly IE. |
| 295 | - if (!isset($_REQUEST['image']) && in_array($file['fileext'], array('gif', 'jpg', 'bmp', 'png', 'jpeg', 'tiff'))) |
|
| 296 | - header('Cache-Control: no-cache'); |
|
| 297 | - |
|
| 298 | - else |
|
| 299 | - header('Cache-Control: max-age=' . (525600 * 60) . ', private'); |
|
| 299 | + if (!isset($_REQUEST['image']) && in_array($file['fileext'], array('gif', 'jpg', 'bmp', 'png', 'jpeg', 'tiff'))) { |
|
| 300 | + header('Cache-Control: no-cache'); |
|
| 301 | + } else { |
|
| 302 | + header('Cache-Control: max-age=' . (525600 * 60) . ', private'); |
|
| 303 | + } |
|
| 300 | 304 | |
| 301 | 305 | // Multipart and resuming support |
| 302 | 306 | if (isset($_SERVER['HTTP_RANGE'])) |
@@ -304,9 +308,9 @@ discard block |
||
| 304 | 308 | header("HTTP/1.1 206 Partial Content"); |
| 305 | 309 | header("Content-Length: $new_length"); |
| 306 | 310 | header("Content-Range: bytes $range-$range_end/$size"); |
| 311 | + } else { |
|
| 312 | + header("Content-Length: " . $size); |
|
| 307 | 313 | } |
| 308 | - else |
|
| 309 | - header("Content-Length: " . $size); |
|
| 310 | 314 | |
| 311 | 315 | |
| 312 | 316 | // Try to buy some time... |
@@ -315,8 +319,9 @@ discard block |
||
| 315 | 319 | // For multipart/resumable downloads, send the requested chunk(s) of the file |
| 316 | 320 | if (isset($_SERVER['HTTP_RANGE'])) |
| 317 | 321 | { |
| 318 | - while (@ob_get_level() > 0) |
|
| 319 | - @ob_end_clean(); |
|
| 322 | + while (@ob_get_level() > 0) { |
|
| 323 | + @ob_end_clean(); |
|
| 324 | + } |
|
| 320 | 325 | |
| 321 | 326 | // 40 kilobytes is a good-ish amount |
| 322 | 327 | $chunksize = 40 * 1024; |
@@ -340,8 +345,9 @@ discard block |
||
| 340 | 345 | elseif ($size > 4194304) |
| 341 | 346 | { |
| 342 | 347 | // Forcibly end any output buffering going on. |
| 343 | - while (@ob_get_level() > 0) |
|
| 344 | - @ob_end_clean(); |
|
| 348 | + while (@ob_get_level() > 0) { |
|
| 349 | + @ob_end_clean(); |
|
| 350 | + } |
|
| 345 | 351 | |
| 346 | 352 | $fp = fopen($file['filePath'], 'rb'); |
| 347 | 353 | while (!feof($fp)) |
@@ -353,8 +359,9 @@ discard block |
||
| 353 | 359 | } |
| 354 | 360 | |
| 355 | 361 | // On some of the less-bright hosts, readfile() is disabled. It's just a faster, more byte safe, version of what's in the if. |
| 356 | - elseif (@readfile($file['filePath']) === null) |
|
| 357 | - echo file_get_contents($file['filePath']); |
|
| 362 | + elseif (@readfile($file['filePath']) === null) { |
|
| 363 | + echo file_get_contents($file['filePath']); |
|
| 364 | + } |
|
| 358 | 365 | |
| 359 | 366 | die(); |
| 360 | 367 | } |
@@ -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 | * The central part of the board - topic display. |
@@ -34,8 +35,9 @@ discard block |
||
| 34 | 35 | global $messages_request, $language, $smcFunc; |
| 35 | 36 | |
| 36 | 37 | // What are you gonna display if these are empty?! |
| 37 | - if (empty($topic)) |
|
| 38 | - fatal_lang_error('no_board', false); |
|
| 38 | + if (empty($topic)) { |
|
| 39 | + fatal_lang_error('no_board', false); |
|
| 40 | + } |
|
| 39 | 41 | |
| 40 | 42 | // Load the proper template. |
| 41 | 43 | loadTemplate('Display'); |
@@ -52,15 +54,17 @@ discard block |
||
| 52 | 54 | $context['messages_per_page'] = empty($modSettings['disableCustomPerPage']) && !empty($options['messages_per_page']) ? $options['messages_per_page'] : $modSettings['defaultMaxMessages']; |
| 53 | 55 | |
| 54 | 56 | // Let's do some work on what to search index. |
| 55 | - if (count($_GET) > 2) |
|
| 56 | - foreach ($_GET as $k => $v) |
|
| 57 | + if (count($_GET) > 2) { |
|
| 58 | + foreach ($_GET as $k => $v) |
|
| 57 | 59 | { |
| 58 | 60 | if (!in_array($k, array('topic', 'board', 'start', session_name()))) |
| 59 | 61 | $context['robot_no_index'] = true; |
| 62 | + } |
|
| 60 | 63 | } |
| 61 | 64 | |
| 62 | - if (!empty($_REQUEST['start']) && (!is_numeric($_REQUEST['start']) || $_REQUEST['start'] % $context['messages_per_page'] != 0)) |
|
| 63 | - $context['robot_no_index'] = true; |
|
| 65 | + if (!empty($_REQUEST['start']) && (!is_numeric($_REQUEST['start']) || $_REQUEST['start'] % $context['messages_per_page'] != 0)) { |
|
| 66 | + $context['robot_no_index'] = true; |
|
| 67 | + } |
|
| 64 | 68 | |
| 65 | 69 | // Find the previous or next topic. Make a fuss if there are no more. |
| 66 | 70 | if (isset($_REQUEST['prev_next']) && ($_REQUEST['prev_next'] == 'prev' || $_REQUEST['prev_next'] == 'next')) |
@@ -172,8 +176,9 @@ discard block |
||
| 172 | 176 | $topic_parameters |
| 173 | 177 | ); |
| 174 | 178 | |
| 175 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 176 | - fatal_lang_error('not_a_topic', false, 404); |
|
| 179 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 180 | + fatal_lang_error('not_a_topic', false, 404); |
|
| 181 | + } |
|
| 177 | 182 | $context['topicinfo'] = $smcFunc['db_fetch_assoc']($request); |
| 178 | 183 | $smcFunc['db_free_result']($request); |
| 179 | 184 | |
@@ -210,8 +215,9 @@ discard block |
||
| 210 | 215 | $context['topic_unwatched'] = isset($context['topicinfo']['unwatched']) ? $context['topicinfo']['unwatched'] : 0; |
| 211 | 216 | |
| 212 | 217 | // Add up unapproved replies to get real number of replies... |
| 213 | - if ($modSettings['postmod_active'] && $approve_posts) |
|
| 214 | - $context['real_num_replies'] += $context['topicinfo']['unapproved_posts'] - ($context['topicinfo']['approved'] ? 0 : 1); |
|
| 218 | + if ($modSettings['postmod_active'] && $approve_posts) { |
|
| 219 | + $context['real_num_replies'] += $context['topicinfo']['unapproved_posts'] - ($context['topicinfo']['approved'] ? 0 : 1); |
|
| 220 | + } |
|
| 215 | 221 | |
| 216 | 222 | // If this topic has unapproved posts, we need to work out how many posts the user can see, for page indexing. |
| 217 | 223 | if ($modSettings['postmod_active'] && $context['topicinfo']['unapproved_posts'] && !$user_info['is_guest'] && !$approve_posts) |
@@ -231,11 +237,11 @@ discard block |
||
| 231 | 237 | $smcFunc['db_free_result']($request); |
| 232 | 238 | |
| 233 | 239 | $context['total_visible_posts'] = $context['num_replies'] + $myUnapprovedPosts + ($context['topicinfo']['approved'] ? 1 : 0); |
| 240 | + } elseif ($user_info['is_guest']) { |
|
| 241 | + $context['total_visible_posts'] = $context['num_replies'] + ($context['topicinfo']['approved'] ? 1 : 0); |
|
| 242 | + } else { |
|
| 243 | + $context['total_visible_posts'] = $context['num_replies'] + $context['topicinfo']['unapproved_posts'] + ($context['topicinfo']['approved'] ? 1 : 0); |
|
| 234 | 244 | } |
| 235 | - elseif ($user_info['is_guest']) |
|
| 236 | - $context['total_visible_posts'] = $context['num_replies'] + ($context['topicinfo']['approved'] ? 1 : 0); |
|
| 237 | - else |
|
| 238 | - $context['total_visible_posts'] = $context['num_replies'] + $context['topicinfo']['unapproved_posts'] + ($context['topicinfo']['approved'] ? 1 : 0); |
|
| 239 | 245 | |
| 240 | 246 | // The start isn't a number; it's information about what to do, where to go. |
| 241 | 247 | if (!is_numeric($_REQUEST['start'])) |
@@ -248,8 +254,7 @@ discard block |
||
| 248 | 254 | { |
| 249 | 255 | $context['start_from'] = $context['total_visible_posts'] - 1; |
| 250 | 256 | $_REQUEST['start'] = empty($options['view_newest_first']) ? $context['start_from'] : 0; |
| 251 | - } |
|
| 252 | - else |
|
| 257 | + } else |
|
| 253 | 258 | { |
| 254 | 259 | // Find the earliest unread message in the topic. (the use of topics here is just for both tables.) |
| 255 | 260 | $request = $smcFunc['db_query']('', ' |
@@ -277,9 +282,9 @@ discard block |
||
| 277 | 282 | if (substr($_REQUEST['start'], 0, 4) == 'from') |
| 278 | 283 | { |
| 279 | 284 | $timestamp = (int) substr($_REQUEST['start'], 4); |
| 280 | - if ($timestamp === 0) |
|
| 281 | - $_REQUEST['start'] = 0; |
|
| 282 | - else |
|
| 285 | + if ($timestamp === 0) { |
|
| 286 | + $_REQUEST['start'] = 0; |
|
| 287 | + } else |
|
| 283 | 288 | { |
| 284 | 289 | // Find the number of messages posted before said time... |
| 285 | 290 | $request = $smcFunc['db_query']('', ' |
@@ -307,11 +312,11 @@ discard block |
||
| 307 | 312 | elseif (substr($_REQUEST['start'], 0, 3) == 'msg') |
| 308 | 313 | { |
| 309 | 314 | $virtual_msg = (int) substr($_REQUEST['start'], 3); |
| 310 | - if (!$context['topicinfo']['unapproved_posts'] && $virtual_msg >= $context['topicinfo']['id_last_msg']) |
|
| 311 | - $context['start_from'] = $context['total_visible_posts'] - 1; |
|
| 312 | - elseif (!$context['topicinfo']['unapproved_posts'] && $virtual_msg <= $context['topicinfo']['id_first_msg']) |
|
| 313 | - $context['start_from'] = 0; |
|
| 314 | - else |
|
| 315 | + if (!$context['topicinfo']['unapproved_posts'] && $virtual_msg >= $context['topicinfo']['id_last_msg']) { |
|
| 316 | + $context['start_from'] = $context['total_visible_posts'] - 1; |
|
| 317 | + } elseif (!$context['topicinfo']['unapproved_posts'] && $virtual_msg <= $context['topicinfo']['id_first_msg']) { |
|
| 318 | + $context['start_from'] = 0; |
|
| 319 | + } else |
|
| 315 | 320 | { |
| 316 | 321 | // Find the start value for that message...... |
| 317 | 322 | $request = $smcFunc['db_query']('', ' |
@@ -394,21 +399,25 @@ discard block |
||
| 394 | 399 | ); |
| 395 | 400 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 396 | 401 | { |
| 397 | - if (empty($row['id_member'])) |
|
| 398 | - continue; |
|
| 402 | + if (empty($row['id_member'])) { |
|
| 403 | + continue; |
|
| 404 | + } |
|
| 399 | 405 | |
| 400 | - if (!empty($row['online_color'])) |
|
| 401 | - $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>'; |
|
| 402 | - else |
|
| 403 | - $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
| 406 | + if (!empty($row['online_color'])) { |
|
| 407 | + $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>'; |
|
| 408 | + } else { |
|
| 409 | + $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
| 410 | + } |
|
| 404 | 411 | |
| 405 | 412 | $is_buddy = in_array($row['id_member'], $user_info['buddies']); |
| 406 | - if ($is_buddy) |
|
| 407 | - $link = '<strong>' . $link . '</strong>'; |
|
| 413 | + if ($is_buddy) { |
|
| 414 | + $link = '<strong>' . $link . '</strong>'; |
|
| 415 | + } |
|
| 408 | 416 | |
| 409 | 417 | // Add them both to the list and to the more detailed list. |
| 410 | - if (!empty($row['show_online']) || allowedTo('moderate_forum')) |
|
| 411 | - $context['view_members_list'][$row['log_time'] . $row['member_name']] = empty($row['show_online']) ? '<em>' . $link . '</em>' : $link; |
|
| 418 | + if (!empty($row['show_online']) || allowedTo('moderate_forum')) { |
|
| 419 | + $context['view_members_list'][$row['log_time'] . $row['member_name']] = empty($row['show_online']) ? '<em>' . $link . '</em>' : $link; |
|
| 420 | + } |
|
| 412 | 421 | $context['view_members'][$row['log_time'] . $row['member_name']] = array( |
| 413 | 422 | 'id' => $row['id_member'], |
| 414 | 423 | 'username' => $row['member_name'], |
@@ -420,8 +429,9 @@ discard block |
||
| 420 | 429 | 'hidden' => empty($row['show_online']), |
| 421 | 430 | ); |
| 422 | 431 | |
| 423 | - if (empty($row['show_online'])) |
|
| 424 | - $context['view_num_hidden']++; |
|
| 432 | + if (empty($row['show_online'])) { |
|
| 433 | + $context['view_num_hidden']++; |
|
| 434 | + } |
|
| 425 | 435 | } |
| 426 | 436 | |
| 427 | 437 | // The number of guests is equal to the rows minus the ones we actually used ;). |
@@ -435,11 +445,13 @@ discard block |
||
| 435 | 445 | |
| 436 | 446 | // If all is set, but not allowed... just unset it. |
| 437 | 447 | $can_show_all = !empty($modSettings['enableAllMessages']) && $context['total_visible_posts'] > $context['messages_per_page'] && $context['total_visible_posts'] < $modSettings['enableAllMessages']; |
| 438 | - if (isset($_REQUEST['all']) && !$can_show_all) |
|
| 439 | - unset($_REQUEST['all']); |
|
| 448 | + if (isset($_REQUEST['all']) && !$can_show_all) { |
|
| 449 | + unset($_REQUEST['all']); |
|
| 450 | + } |
|
| 440 | 451 | // Otherwise, it must be allowed... so pretend start was -1. |
| 441 | - elseif (isset($_REQUEST['all'])) |
|
| 442 | - $_REQUEST['start'] = -1; |
|
| 452 | + elseif (isset($_REQUEST['all'])) { |
|
| 453 | + $_REQUEST['start'] = -1; |
|
| 454 | + } |
|
| 443 | 455 | |
| 444 | 456 | // Construct the page index, allowing for the .START method... |
| 445 | 457 | $context['page_index'] = constructPageIndex($scripturl . '?topic=' . $topic . '.%1$d', $_REQUEST['start'], $context['total_visible_posts'], $context['messages_per_page'], true); |
@@ -476,8 +488,9 @@ discard block |
||
| 476 | 488 | $_REQUEST['start'] = 0; |
| 477 | 489 | } |
| 478 | 490 | // They aren't using it, but the *option* is there, at least. |
| 479 | - else |
|
| 480 | - $context['page_index'] .= ' <a href="' . $scripturl . '?topic=' . $topic . '.0;all">' . $txt['all'] . '</a> '; |
|
| 491 | + else { |
|
| 492 | + $context['page_index'] .= ' <a href="' . $scripturl . '?topic=' . $topic . '.0;all">' . $txt['all'] . '</a> '; |
|
| 493 | + } |
|
| 481 | 494 | } |
| 482 | 495 | |
| 483 | 496 | // Build the link tree. |
@@ -493,14 +506,16 @@ discard block |
||
| 493 | 506 | if (!empty($board_info['moderators'])) |
| 494 | 507 | { |
| 495 | 508 | // Add a link for each moderator... |
| 496 | - foreach ($board_info['moderators'] as $mod) |
|
| 497 | - $context['link_moderators'][] = '<a href="' . $scripturl . '?action=profile;u=' . $mod['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod['name'] . '</a>'; |
|
| 509 | + foreach ($board_info['moderators'] as $mod) { |
|
| 510 | + $context['link_moderators'][] = '<a href="' . $scripturl . '?action=profile;u=' . $mod['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod['name'] . '</a>'; |
|
| 511 | + } |
|
| 498 | 512 | } |
| 499 | 513 | if (!empty($board_info['moderator_groups'])) |
| 500 | 514 | { |
| 501 | 515 | // Add a link for each moderator group as well... |
| 502 | - foreach ($board_info['moderator_groups'] as $mod_group) |
|
| 503 | - $context['link_moderators'][] = '<a href="' . $scripturl . '?action=groups;sa=viewmemberes;group=' . $mod_group['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod_group['name'] . '</a>'; |
|
| 516 | + foreach ($board_info['moderator_groups'] as $mod_group) { |
|
| 517 | + $context['link_moderators'][] = '<a href="' . $scripturl . '?action=groups;sa=viewmemberes;group=' . $mod_group['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod_group['name'] . '</a>'; |
|
| 518 | + } |
|
| 504 | 519 | } |
| 505 | 520 | |
| 506 | 521 | if (!empty($context['link_moderators'])) |
@@ -531,9 +546,9 @@ discard block |
||
| 531 | 546 | // For quick reply we need a response prefix in the default forum language. |
| 532 | 547 | if (!isset($context['response_prefix']) && !($context['response_prefix'] = cache_get_data('response_prefix', 600))) |
| 533 | 548 | { |
| 534 | - if ($language === $user_info['language']) |
|
| 535 | - $context['response_prefix'] = $txt['response_prefix']; |
|
| 536 | - else |
|
| 549 | + if ($language === $user_info['language']) { |
|
| 550 | + $context['response_prefix'] = $txt['response_prefix']; |
|
| 551 | + } else |
|
| 537 | 552 | { |
| 538 | 553 | loadLanguage('index', $language, false); |
| 539 | 554 | $context['response_prefix'] = $txt['response_prefix']; |
@@ -565,8 +580,9 @@ discard block |
||
| 565 | 580 | list($start, $end, $allday, $span, $tz, $tz_abbrev) = buildEventDatetimes($row); |
| 566 | 581 | |
| 567 | 582 | // Sanity check |
| 568 | - if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count'])) |
|
| 569 | - continue; |
|
| 583 | + if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count'])) { |
|
| 584 | + continue; |
|
| 585 | + } |
|
| 570 | 586 | |
| 571 | 587 | $linked_calendar_event = array( |
| 572 | 588 | 'id' => $row['id_event'], |
@@ -615,8 +631,9 @@ discard block |
||
| 615 | 631 | } |
| 616 | 632 | $smcFunc['db_free_result']($request); |
| 617 | 633 | |
| 618 | - if (!empty($context['linked_calendar_events'])) |
|
| 619 | - $context['linked_calendar_events'][count($context['linked_calendar_events']) - 1]['is_last'] = true; |
|
| 634 | + if (!empty($context['linked_calendar_events'])) { |
|
| 635 | + $context['linked_calendar_events'][count($context['linked_calendar_events']) - 1]['is_last'] = true; |
|
| 636 | + } |
|
| 620 | 637 | } |
| 621 | 638 | |
| 622 | 639 | // Create the poll info if it exists. |
@@ -679,8 +696,9 @@ discard block |
||
| 679 | 696 | $smcFunc['db_free_result']($request); |
| 680 | 697 | |
| 681 | 698 | // Got we multi choice? |
| 682 | - if ($pollinfo['max_votes'] > 1) |
|
| 683 | - $realtotal = $pollinfo['total']; |
|
| 699 | + if ($pollinfo['max_votes'] > 1) { |
|
| 700 | + $realtotal = $pollinfo['total']; |
|
| 701 | + } |
|
| 684 | 702 | |
| 685 | 703 | // If this is a guest we need to do our best to work out if they have voted, and what they voted for. |
| 686 | 704 | if ($user_info['is_guest'] && $pollinfo['guest_vote'] && allowedTo('poll_vote')) |
@@ -693,20 +711,21 @@ discard block |
||
| 693 | 711 | foreach ($guestinfo as $i => $guestvoted) |
| 694 | 712 | { |
| 695 | 713 | $guestvoted = explode(',', $guestvoted); |
| 696 | - if ($guestvoted[0] == $context['topicinfo']['id_poll']) |
|
| 697 | - break; |
|
| 714 | + if ($guestvoted[0] == $context['topicinfo']['id_poll']) { |
|
| 715 | + break; |
|
| 716 | + } |
|
| 698 | 717 | } |
| 699 | 718 | // Has the poll been reset since guest voted? |
| 700 | 719 | if ($pollinfo['reset_poll'] > $guestvoted[1]) |
| 701 | 720 | { |
| 702 | 721 | // Remove the poll info from the cookie to allow guest to vote again |
| 703 | 722 | unset($guestinfo[$i]); |
| 704 | - if (!empty($guestinfo)) |
|
| 705 | - $_COOKIE['guest_poll_vote'] = ';' . implode(';', $guestinfo); |
|
| 706 | - else |
|
| 707 | - unset($_COOKIE['guest_poll_vote']); |
|
| 708 | - } |
|
| 709 | - else |
|
| 723 | + if (!empty($guestinfo)) { |
|
| 724 | + $_COOKIE['guest_poll_vote'] = ';' . implode(';', $guestinfo); |
|
| 725 | + } else { |
|
| 726 | + unset($_COOKIE['guest_poll_vote']); |
|
| 727 | + } |
|
| 728 | + } else |
|
| 710 | 729 | { |
| 711 | 730 | // What did they vote for? |
| 712 | 731 | unset($guestvoted[0], $guestvoted[1]); |
@@ -820,23 +839,29 @@ discard block |
||
| 820 | 839 | // Build the poll moderation button array. |
| 821 | 840 | $context['poll_buttons'] = array(); |
| 822 | 841 | |
| 823 | - if ($context['allow_return_vote']) |
|
| 824 | - $context['poll_buttons']['vote'] = array('text' => 'poll_return_vote', 'image' => 'poll_options.png', 'url' => $scripturl . '?topic=' . $context['current_topic'] . '.' . $context['start']); |
|
| 842 | + if ($context['allow_return_vote']) { |
|
| 843 | + $context['poll_buttons']['vote'] = array('text' => 'poll_return_vote', 'image' => 'poll_options.png', 'url' => $scripturl . '?topic=' . $context['current_topic'] . '.' . $context['start']); |
|
| 844 | + } |
|
| 825 | 845 | |
| 826 | - if ($context['show_view_results_button']) |
|
| 827 | - $context['poll_buttons']['results'] = array('text' => 'poll_results', 'image' => 'poll_results.png', 'url' => $scripturl . '?topic=' . $context['current_topic'] . '.' . $context['start'] . ';viewresults'); |
|
| 846 | + if ($context['show_view_results_button']) { |
|
| 847 | + $context['poll_buttons']['results'] = array('text' => 'poll_results', 'image' => 'poll_results.png', 'url' => $scripturl . '?topic=' . $context['current_topic'] . '.' . $context['start'] . ';viewresults'); |
|
| 848 | + } |
|
| 828 | 849 | |
| 829 | - if ($context['allow_change_vote']) |
|
| 830 | - $context['poll_buttons']['change_vote'] = array('text' => 'poll_change_vote', 'image' => 'poll_change_vote.png', 'url' => $scripturl . '?action=vote;topic=' . $context['current_topic'] . '.' . $context['start'] . ';poll=' . $context['poll']['id'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 850 | + if ($context['allow_change_vote']) { |
|
| 851 | + $context['poll_buttons']['change_vote'] = array('text' => 'poll_change_vote', 'image' => 'poll_change_vote.png', 'url' => $scripturl . '?action=vote;topic=' . $context['current_topic'] . '.' . $context['start'] . ';poll=' . $context['poll']['id'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 852 | + } |
|
| 831 | 853 | |
| 832 | - if ($context['allow_lock_poll']) |
|
| 833 | - $context['poll_buttons']['lock'] = array('text' => (!$context['poll']['is_locked'] ? 'poll_lock' : 'poll_unlock'), 'image' => 'poll_lock.png', 'url' => $scripturl . '?action=lockvoting;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 854 | + if ($context['allow_lock_poll']) { |
|
| 855 | + $context['poll_buttons']['lock'] = array('text' => (!$context['poll']['is_locked'] ? 'poll_lock' : 'poll_unlock'), 'image' => 'poll_lock.png', 'url' => $scripturl . '?action=lockvoting;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 856 | + } |
|
| 834 | 857 | |
| 835 | - if ($context['allow_edit_poll']) |
|
| 836 | - $context['poll_buttons']['edit'] = array('text' => 'poll_edit', 'image' => 'poll_edit.png', 'url' => $scripturl . '?action=editpoll;topic=' . $context['current_topic'] . '.' . $context['start']); |
|
| 858 | + if ($context['allow_edit_poll']) { |
|
| 859 | + $context['poll_buttons']['edit'] = array('text' => 'poll_edit', 'image' => 'poll_edit.png', 'url' => $scripturl . '?action=editpoll;topic=' . $context['current_topic'] . '.' . $context['start']); |
|
| 860 | + } |
|
| 837 | 861 | |
| 838 | - if ($context['can_remove_poll']) |
|
| 839 | - $context['poll_buttons']['remove_poll'] = array('text' => 'poll_remove', 'image' => 'admin_remove_poll.png', 'custom' => 'data-confirm="' . $txt['poll_remove_warn'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=removepoll;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 862 | + if ($context['can_remove_poll']) { |
|
| 863 | + $context['poll_buttons']['remove_poll'] = array('text' => 'poll_remove', 'image' => 'admin_remove_poll.png', 'custom' => 'data-confirm="' . $txt['poll_remove_warn'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=removepoll;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 864 | + } |
|
| 840 | 865 | |
| 841 | 866 | // Allow mods to add additional buttons here |
| 842 | 867 | call_integration_hook('integrate_poll_buttons'); |
@@ -871,9 +896,9 @@ discard block |
||
| 871 | 896 | { |
| 872 | 897 | $start_char = 'C'; |
| 873 | 898 | $page_id = $context['topicinfo']['id_first_msg']; |
| 899 | + } else { |
|
| 900 | + $start_char = null; |
|
| 874 | 901 | } |
| 875 | - else |
|
| 876 | - $start_char = null; |
|
| 877 | 902 | |
| 878 | 903 | $limit = $context['messages_per_page']; |
| 879 | 904 | |
@@ -888,17 +913,17 @@ discard block |
||
| 888 | 913 | { |
| 889 | 914 | $ascending = true; |
| 890 | 915 | $page_operator = '>='; |
| 891 | - } |
|
| 892 | - else |
|
| 916 | + } else |
|
| 893 | 917 | { |
| 894 | 918 | $ascending = false; |
| 895 | 919 | $page_operator = '<='; |
| 896 | 920 | } |
| 897 | 921 | |
| 898 | - if ($start_char === 'C') |
|
| 899 | - $limit_seek = $limit; |
|
| 900 | - else |
|
| 901 | - $limit_seek = $limit + 1; |
|
| 922 | + if ($start_char === 'C') { |
|
| 923 | + $limit_seek = $limit; |
|
| 924 | + } else { |
|
| 925 | + $limit_seek = $limit + 1; |
|
| 926 | + } |
|
| 902 | 927 | |
| 903 | 928 | $request = $smcFunc['db_query']('', ' |
| 904 | 929 | SELECT id_msg, id_member, approved |
@@ -921,21 +946,23 @@ discard block |
||
| 921 | 946 | $found_msg = false; |
| 922 | 947 | |
| 923 | 948 | // Fallback |
| 924 | - if ($smcFunc['db_num_rows']($request) < 1) |
|
| 925 | - unset($start_char); |
|
| 926 | - else |
|
| 949 | + if ($smcFunc['db_num_rows']($request) < 1) { |
|
| 950 | + unset($start_char); |
|
| 951 | + } else |
|
| 927 | 952 | { |
| 928 | 953 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 929 | 954 | { |
| 930 | 955 | // Check if the start msg is in our result |
| 931 | - if ($row['id_msg'] == $page_id) |
|
| 932 | - $found_msg = true; |
|
| 956 | + if ($row['id_msg'] == $page_id) { |
|
| 957 | + $found_msg = true; |
|
| 958 | + } |
|
| 933 | 959 | |
| 934 | 960 | // Skip the the start msg if we not in mode C |
| 935 | 961 | if ($start_char === 'C' || $row['id_msg'] != $page_id) |
| 936 | 962 | { |
| 937 | - if (!empty($row['id_member'])) |
|
| 938 | - $all_posters[$row['id_msg']] = $row['id_member']; |
|
| 963 | + if (!empty($row['id_member'])) { |
|
| 964 | + $all_posters[$row['id_msg']] = $row['id_member']; |
|
| 965 | + } |
|
| 939 | 966 | |
| 940 | 967 | $messages[] = $row['id_msg']; |
| 941 | 968 | } |
@@ -951,8 +978,9 @@ discard block |
||
| 951 | 978 | } |
| 952 | 979 | |
| 953 | 980 | // Before Page bring in the right order |
| 954 | - if (!empty($start_char) && $start_char === 'L') |
|
| 955 | - krsort($messages); |
|
| 981 | + if (!empty($start_char) && $start_char === 'L') { |
|
| 982 | + krsort($messages); |
|
| 983 | + } |
|
| 956 | 984 | } |
| 957 | 985 | |
| 958 | 986 | // Jump to page |
@@ -989,14 +1017,16 @@ discard block |
||
| 989 | 1017 | |
| 990 | 1018 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 991 | 1019 | { |
| 992 | - if (!empty($row['id_member'])) |
|
| 993 | - $all_posters[$row['id_msg']] = $row['id_member']; |
|
| 1020 | + if (!empty($row['id_member'])) { |
|
| 1021 | + $all_posters[$row['id_msg']] = $row['id_member']; |
|
| 1022 | + } |
|
| 994 | 1023 | $messages[] = $row['id_msg']; |
| 995 | 1024 | } |
| 996 | 1025 | |
| 997 | 1026 | // Sort the messages into the correct display order |
| 998 | - if (!$ascending) |
|
| 999 | - sort($messages); |
|
| 1027 | + if (!$ascending) { |
|
| 1028 | + sort($messages); |
|
| 1029 | + } |
|
| 1000 | 1030 | } |
| 1001 | 1031 | |
| 1002 | 1032 | // Remember the paging data for next time |
@@ -1016,8 +1046,9 @@ discard block |
||
| 1016 | 1046 | if (!$user_info['is_guest'] && !empty($messages)) |
| 1017 | 1047 | { |
| 1018 | 1048 | $mark_at_msg = max($messages); |
| 1019 | - if ($mark_at_msg >= $context['topicinfo']['id_last_msg']) |
|
| 1020 | - $mark_at_msg = $modSettings['maxMsgID']; |
|
| 1049 | + if ($mark_at_msg >= $context['topicinfo']['id_last_msg']) { |
|
| 1050 | + $mark_at_msg = $modSettings['maxMsgID']; |
|
| 1051 | + } |
|
| 1021 | 1052 | if ($mark_at_msg >= $context['topicinfo']['new_from']) |
| 1022 | 1053 | { |
| 1023 | 1054 | $smcFunc['db_insert']($context['topicinfo']['new_from'] == 0 ? 'ignore' : 'replace', |
@@ -1049,8 +1080,9 @@ discard block |
||
| 1049 | 1080 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1050 | 1081 | { |
| 1051 | 1082 | // Find if this topic is marked for notification... |
| 1052 | - if (!empty($row['id_topic'])) |
|
| 1053 | - $context['is_marked_notify'] = true; |
|
| 1083 | + if (!empty($row['id_topic'])) { |
|
| 1084 | + $context['is_marked_notify'] = true; |
|
| 1085 | + } |
|
| 1054 | 1086 | |
| 1055 | 1087 | // Only do this once, but mark the notifications as "not sent yet" for next time. |
| 1056 | 1088 | if (!empty($row['sent']) && $do_once) |
@@ -1072,8 +1104,9 @@ discard block |
||
| 1072 | 1104 | } |
| 1073 | 1105 | |
| 1074 | 1106 | // Have we recently cached the number of new topics in this board, and it's still a lot? |
| 1075 | - if (isset($_REQUEST['topicseen']) && isset($_SESSION['topicseen_cache'][$board]) && $_SESSION['topicseen_cache'][$board] > 5) |
|
| 1076 | - $_SESSION['topicseen_cache'][$board]--; |
|
| 1107 | + if (isset($_REQUEST['topicseen']) && isset($_SESSION['topicseen_cache'][$board]) && $_SESSION['topicseen_cache'][$board] > 5) { |
|
| 1108 | + $_SESSION['topicseen_cache'][$board]--; |
|
| 1109 | + } |
|
| 1077 | 1110 | // Mark board as seen if this is the only new topic. |
| 1078 | 1111 | elseif (isset($_REQUEST['topicseen'])) |
| 1079 | 1112 | { |
@@ -1097,14 +1130,16 @@ discard block |
||
| 1097 | 1130 | $smcFunc['db_free_result']($request); |
| 1098 | 1131 | |
| 1099 | 1132 | // If there're no real new topics in this board, mark the board as seen. |
| 1100 | - if (empty($numNewTopics)) |
|
| 1101 | - $_REQUEST['boardseen'] = true; |
|
| 1102 | - else |
|
| 1103 | - $_SESSION['topicseen_cache'][$board] = $numNewTopics; |
|
| 1133 | + if (empty($numNewTopics)) { |
|
| 1134 | + $_REQUEST['boardseen'] = true; |
|
| 1135 | + } else { |
|
| 1136 | + $_SESSION['topicseen_cache'][$board] = $numNewTopics; |
|
| 1137 | + } |
|
| 1104 | 1138 | } |
| 1105 | 1139 | // Probably one less topic - maybe not, but even if we decrease this too fast it will only make us look more often. |
| 1106 | - elseif (isset($_SESSION['topicseen_cache'][$board])) |
|
| 1107 | - $_SESSION['topicseen_cache'][$board]--; |
|
| 1140 | + elseif (isset($_SESSION['topicseen_cache'][$board])) { |
|
| 1141 | + $_SESSION['topicseen_cache'][$board]--; |
|
| 1142 | + } |
|
| 1108 | 1143 | |
| 1109 | 1144 | // Mark board as seen if we came using last post link from BoardIndex. (or other places...) |
| 1110 | 1145 | if (isset($_REQUEST['boardseen'])) |
@@ -1161,23 +1196,26 @@ discard block |
||
| 1161 | 1196 | $temp = array(); |
| 1162 | 1197 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1163 | 1198 | { |
| 1164 | - if (!$row['approved'] && $modSettings['postmod_active'] && !allowedTo('approve_posts') && (!isset($all_posters[$row['id_msg']]) || $all_posters[$row['id_msg']] != $user_info['id'])) |
|
| 1165 | - continue; |
|
| 1199 | + if (!$row['approved'] && $modSettings['postmod_active'] && !allowedTo('approve_posts') && (!isset($all_posters[$row['id_msg']]) || $all_posters[$row['id_msg']] != $user_info['id'])) { |
|
| 1200 | + continue; |
|
| 1201 | + } |
|
| 1166 | 1202 | |
| 1167 | 1203 | $temp[$row['id_attach']] = $row; |
| 1168 | 1204 | $temp[$row['id_attach']]['topic'] = $topic; |
| 1169 | 1205 | $temp[$row['id_attach']]['board'] = $board; |
| 1170 | 1206 | |
| 1171 | - if (!isset($context['loaded_attachments'][$row['id_msg']])) |
|
| 1172 | - $context['loaded_attachments'][$row['id_msg']] = array(); |
|
| 1207 | + if (!isset($context['loaded_attachments'][$row['id_msg']])) { |
|
| 1208 | + $context['loaded_attachments'][$row['id_msg']] = array(); |
|
| 1209 | + } |
|
| 1173 | 1210 | } |
| 1174 | 1211 | $smcFunc['db_free_result']($request); |
| 1175 | 1212 | |
| 1176 | 1213 | // This is better than sorting it with the query... |
| 1177 | 1214 | ksort($temp); |
| 1178 | 1215 | |
| 1179 | - foreach ($temp as $row) |
|
| 1180 | - $context['loaded_attachments'][$row['id_msg']][] = $row; |
|
| 1216 | + foreach ($temp as $row) { |
|
| 1217 | + $context['loaded_attachments'][$row['id_msg']][] = $row; |
|
| 1218 | + } |
|
| 1181 | 1219 | } |
| 1182 | 1220 | |
| 1183 | 1221 | $msg_parameters = array( |
@@ -1204,21 +1242,23 @@ discard block |
||
| 1204 | 1242 | ); |
| 1205 | 1243 | |
| 1206 | 1244 | // And the likes |
| 1207 | - if (!empty($modSettings['enable_likes'])) |
|
| 1208 | - $context['my_likes'] = $context['user']['is_guest'] ? array() : prepareLikesContext($topic); |
|
| 1245 | + if (!empty($modSettings['enable_likes'])) { |
|
| 1246 | + $context['my_likes'] = $context['user']['is_guest'] ? array() : prepareLikesContext($topic); |
|
| 1247 | + } |
|
| 1209 | 1248 | |
| 1210 | 1249 | // Go to the last message if the given time is beyond the time of the last message. |
| 1211 | - if (isset($context['start_from']) && $context['start_from'] >= $context['topicinfo']['num_replies']) |
|
| 1212 | - $context['start_from'] = $context['topicinfo']['num_replies']; |
|
| 1250 | + if (isset($context['start_from']) && $context['start_from'] >= $context['topicinfo']['num_replies']) { |
|
| 1251 | + $context['start_from'] = $context['topicinfo']['num_replies']; |
|
| 1252 | + } |
|
| 1213 | 1253 | |
| 1214 | 1254 | // Since the anchor information is needed on the top of the page we load these variables beforehand. |
| 1215 | 1255 | $context['first_message'] = isset($messages[$firstIndex]) ? $messages[$firstIndex] : $messages[0]; |
| 1216 | - if (empty($options['view_newest_first'])) |
|
| 1217 | - $context['first_new_message'] = isset($context['start_from']) && $_REQUEST['start'] == $context['start_from']; |
|
| 1218 | - else |
|
| 1219 | - $context['first_new_message'] = isset($context['start_from']) && $_REQUEST['start'] == $context['topicinfo']['num_replies'] - $context['start_from']; |
|
| 1220 | - } |
|
| 1221 | - else |
|
| 1256 | + if (empty($options['view_newest_first'])) { |
|
| 1257 | + $context['first_new_message'] = isset($context['start_from']) && $_REQUEST['start'] == $context['start_from']; |
|
| 1258 | + } else { |
|
| 1259 | + $context['first_new_message'] = isset($context['start_from']) && $_REQUEST['start'] == $context['topicinfo']['num_replies'] - $context['start_from']; |
|
| 1260 | + } |
|
| 1261 | + } else |
|
| 1222 | 1262 | { |
| 1223 | 1263 | $messages_request = false; |
| 1224 | 1264 | $context['first_message'] = 0; |
@@ -1253,8 +1293,9 @@ discard block |
||
| 1253 | 1293 | 'can_restore_msg' => 'move_any', |
| 1254 | 1294 | 'can_like' => 'likes_like', |
| 1255 | 1295 | ); |
| 1256 | - foreach ($common_permissions as $contextual => $perm) |
|
| 1257 | - $context[$contextual] = allowedTo($perm); |
|
| 1296 | + foreach ($common_permissions as $contextual => $perm) { |
|
| 1297 | + $context[$contextual] = allowedTo($perm); |
|
| 1298 | + } |
|
| 1258 | 1299 | |
| 1259 | 1300 | // Permissions with _any/_own versions. $context[YYY] => ZZZ_any/_own. |
| 1260 | 1301 | $anyown_permissions = array( |
@@ -1267,8 +1308,9 @@ discard block |
||
| 1267 | 1308 | 'can_reply_unapproved' => 'post_unapproved_replies', |
| 1268 | 1309 | 'can_view_warning' => 'profile_warning', |
| 1269 | 1310 | ); |
| 1270 | - foreach ($anyown_permissions as $contextual => $perm) |
|
| 1271 | - $context[$contextual] = allowedTo($perm . '_any') || ($context['user']['started'] && allowedTo($perm . '_own')); |
|
| 1311 | + foreach ($anyown_permissions as $contextual => $perm) { |
|
| 1312 | + $context[$contextual] = allowedTo($perm . '_any') || ($context['user']['started'] && allowedTo($perm . '_own')); |
|
| 1313 | + } |
|
| 1272 | 1314 | |
| 1273 | 1315 | if (!$user_info['is_admin'] && !$modSettings['topic_move_any']) |
| 1274 | 1316 | { |
@@ -1314,8 +1356,9 @@ discard block |
||
| 1314 | 1356 | // Check if the draft functions are enabled and that they have permission to use them (for quick reply.) |
| 1315 | 1357 | $context['drafts_save'] = !empty($modSettings['drafts_post_enabled']) && allowedTo('post_draft') && $context['can_reply']; |
| 1316 | 1358 | $context['drafts_autosave'] = !empty($context['drafts_save']) && !empty($modSettings['drafts_autosave_enabled']); |
| 1317 | - if (!empty($context['drafts_save'])) |
|
| 1318 | - loadLanguage('Drafts'); |
|
| 1359 | + if (!empty($context['drafts_save'])) { |
|
| 1360 | + loadLanguage('Drafts'); |
|
| 1361 | + } |
|
| 1319 | 1362 | |
| 1320 | 1363 | // When was the last time this topic was replied to? Should we warn them about it? |
| 1321 | 1364 | if (!empty($modSettings['oldTopicDays']) && ($context['can_reply'] || $context['can_reply_unapproved']) && empty($context['topicinfo']['is_sticky'])) |
@@ -1376,26 +1419,31 @@ discard block |
||
| 1376 | 1419 | // Message icons - customized icons are off? |
| 1377 | 1420 | $context['icons'] = getMessageIcons($board); |
| 1378 | 1421 | |
| 1379 | - if (!empty($context['icons'])) |
|
| 1380 | - $context['icons'][count($context['icons']) - 1]['is_last'] = true; |
|
| 1422 | + if (!empty($context['icons'])) { |
|
| 1423 | + $context['icons'][count($context['icons']) - 1]['is_last'] = true; |
|
| 1424 | + } |
|
| 1381 | 1425 | |
| 1382 | 1426 | // Build the normal button array. |
| 1383 | 1427 | $context['normal_buttons'] = array(); |
| 1384 | 1428 | |
| 1385 | - if ($context['can_reply']) |
|
| 1386 | - $context['normal_buttons']['reply'] = array('text' => 'reply', 'image' => 'reply.png', 'url' => $scripturl . '?action=post;topic=' . $context['current_topic'] . '.' . $context['start'] . ';last_msg=' . $context['topic_last_message'], 'active' => true); |
|
| 1429 | + if ($context['can_reply']) { |
|
| 1430 | + $context['normal_buttons']['reply'] = array('text' => 'reply', 'image' => 'reply.png', 'url' => $scripturl . '?action=post;topic=' . $context['current_topic'] . '.' . $context['start'] . ';last_msg=' . $context['topic_last_message'], 'active' => true); |
|
| 1431 | + } |
|
| 1387 | 1432 | |
| 1388 | - if ($context['can_add_poll']) |
|
| 1389 | - $context['normal_buttons']['add_poll'] = array('text' => 'add_poll', 'image' => 'add_poll.png', 'url' => $scripturl . '?action=editpoll;add;topic=' . $context['current_topic'] . '.' . $context['start']); |
|
| 1433 | + if ($context['can_add_poll']) { |
|
| 1434 | + $context['normal_buttons']['add_poll'] = array('text' => 'add_poll', 'image' => 'add_poll.png', 'url' => $scripturl . '?action=editpoll;add;topic=' . $context['current_topic'] . '.' . $context['start']); |
|
| 1435 | + } |
|
| 1390 | 1436 | |
| 1391 | - if ($context['can_mark_unread']) |
|
| 1392 | - $context['normal_buttons']['mark_unread'] = array('text' => 'mark_unread', 'image' => 'markunread.png', 'url' => $scripturl . '?action=markasread;sa=topic;t=' . $context['mark_unread_time'] . ';topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 1437 | + if ($context['can_mark_unread']) { |
|
| 1438 | + $context['normal_buttons']['mark_unread'] = array('text' => 'mark_unread', 'image' => 'markunread.png', 'url' => $scripturl . '?action=markasread;sa=topic;t=' . $context['mark_unread_time'] . ';topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 1439 | + } |
|
| 1393 | 1440 | |
| 1394 | - if ($context['can_print']) |
|
| 1395 | - $context['normal_buttons']['print'] = array('text' => 'print', 'image' => 'print.png', 'custom' => 'rel="nofollow"', 'url' => $scripturl . '?action=printpage;topic=' . $context['current_topic'] . '.0'); |
|
| 1441 | + if ($context['can_print']) { |
|
| 1442 | + $context['normal_buttons']['print'] = array('text' => 'print', 'image' => 'print.png', 'custom' => 'rel="nofollow"', 'url' => $scripturl . '?action=printpage;topic=' . $context['current_topic'] . '.0'); |
|
| 1443 | + } |
|
| 1396 | 1444 | |
| 1397 | - if ($context['can_set_notify']) |
|
| 1398 | - $context['normal_buttons']['notify'] = array( |
|
| 1445 | + if ($context['can_set_notify']) { |
|
| 1446 | + $context['normal_buttons']['notify'] = array( |
|
| 1399 | 1447 | 'text' => 'notify_topic_' . $context['topic_notification_mode'], |
| 1400 | 1448 | 'sub_buttons' => array( |
| 1401 | 1449 | array( |
@@ -1417,38 +1465,47 @@ discard block |
||
| 1417 | 1465 | ), |
| 1418 | 1466 | ), |
| 1419 | 1467 | ); |
| 1468 | + } |
|
| 1420 | 1469 | |
| 1421 | 1470 | // Build the mod button array |
| 1422 | 1471 | $context['mod_buttons'] = array(); |
| 1423 | 1472 | |
| 1424 | - if ($context['can_move']) |
|
| 1425 | - $context['mod_buttons']['move'] = array('text' => 'move_topic', 'image' => 'admin_move.png', 'url' => $scripturl . '?action=movetopic;current_board=' . $context['current_board'] . ';topic=' . $context['current_topic'] . '.0'); |
|
| 1473 | + if ($context['can_move']) { |
|
| 1474 | + $context['mod_buttons']['move'] = array('text' => 'move_topic', 'image' => 'admin_move.png', 'url' => $scripturl . '?action=movetopic;current_board=' . $context['current_board'] . ';topic=' . $context['current_topic'] . '.0'); |
|
| 1475 | + } |
|
| 1426 | 1476 | |
| 1427 | - if ($context['can_delete']) |
|
| 1428 | - $context['mod_buttons']['delete'] = array('text' => 'remove_topic', 'image' => 'admin_rem.png', 'custom' => 'data-confirm="' . $txt['are_sure_remove_topic'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=removetopic2;topic=' . $context['current_topic'] . '.0;' . $context['session_var'] . '=' . $context['session_id']); |
|
| 1477 | + if ($context['can_delete']) { |
|
| 1478 | + $context['mod_buttons']['delete'] = array('text' => 'remove_topic', 'image' => 'admin_rem.png', 'custom' => 'data-confirm="' . $txt['are_sure_remove_topic'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=removetopic2;topic=' . $context['current_topic'] . '.0;' . $context['session_var'] . '=' . $context['session_id']); |
|
| 1479 | + } |
|
| 1429 | 1480 | |
| 1430 | - if ($context['can_lock']) |
|
| 1431 | - $context['mod_buttons']['lock'] = array('text' => empty($context['is_locked']) ? 'set_lock' : 'set_unlock', 'image' => 'admin_lock.png', 'url' => $scripturl . '?action=lock;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 1481 | + if ($context['can_lock']) { |
|
| 1482 | + $context['mod_buttons']['lock'] = array('text' => empty($context['is_locked']) ? 'set_lock' : 'set_unlock', 'image' => 'admin_lock.png', 'url' => $scripturl . '?action=lock;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 1483 | + } |
|
| 1432 | 1484 | |
| 1433 | - if ($context['can_sticky']) |
|
| 1434 | - $context['mod_buttons']['sticky'] = array('text' => empty($context['is_sticky']) ? 'set_sticky' : 'set_nonsticky', 'image' => 'admin_sticky.png', 'url' => $scripturl . '?action=sticky;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 1485 | + if ($context['can_sticky']) { |
|
| 1486 | + $context['mod_buttons']['sticky'] = array('text' => empty($context['is_sticky']) ? 'set_sticky' : 'set_nonsticky', 'image' => 'admin_sticky.png', 'url' => $scripturl . '?action=sticky;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 1487 | + } |
|
| 1435 | 1488 | |
| 1436 | - if ($context['can_merge']) |
|
| 1437 | - $context['mod_buttons']['merge'] = array('text' => 'merge', 'image' => 'merge.png', 'url' => $scripturl . '?action=mergetopics;board=' . $context['current_board'] . '.0;from=' . $context['current_topic']); |
|
| 1489 | + if ($context['can_merge']) { |
|
| 1490 | + $context['mod_buttons']['merge'] = array('text' => 'merge', 'image' => 'merge.png', 'url' => $scripturl . '?action=mergetopics;board=' . $context['current_board'] . '.0;from=' . $context['current_topic']); |
|
| 1491 | + } |
|
| 1438 | 1492 | |
| 1439 | - if ($context['calendar_post']) |
|
| 1440 | - $context['mod_buttons']['calendar'] = array('text' => 'calendar_link', 'image' => 'linktocal.png', 'url' => $scripturl . '?action=post;calendar;msg=' . $context['topic_first_message'] . ';topic=' . $context['current_topic'] . '.0'); |
|
| 1493 | + if ($context['calendar_post']) { |
|
| 1494 | + $context['mod_buttons']['calendar'] = array('text' => 'calendar_link', 'image' => 'linktocal.png', 'url' => $scripturl . '?action=post;calendar;msg=' . $context['topic_first_message'] . ';topic=' . $context['current_topic'] . '.0'); |
|
| 1495 | + } |
|
| 1441 | 1496 | |
| 1442 | 1497 | // Restore topic. eh? No monkey business. |
| 1443 | - if ($context['can_restore_topic']) |
|
| 1444 | - $context['mod_buttons']['restore_topic'] = array('text' => 'restore_topic', 'image' => '', 'url' => $scripturl . '?action=restoretopic;topics=' . $context['current_topic'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 1498 | + if ($context['can_restore_topic']) { |
|
| 1499 | + $context['mod_buttons']['restore_topic'] = array('text' => 'restore_topic', 'image' => '', 'url' => $scripturl . '?action=restoretopic;topics=' . $context['current_topic'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 1500 | + } |
|
| 1445 | 1501 | |
| 1446 | 1502 | // Show a message in case a recently posted message became unapproved. |
| 1447 | 1503 | $context['becomesUnapproved'] = !empty($_SESSION['becomesUnapproved']) ? true : false; |
| 1448 | 1504 | |
| 1449 | 1505 | // Don't want to show this forever... |
| 1450 | - if ($context['becomesUnapproved']) |
|
| 1451 | - unset($_SESSION['becomesUnapproved']); |
|
| 1506 | + if ($context['becomesUnapproved']) { |
|
| 1507 | + unset($_SESSION['becomesUnapproved']); |
|
| 1508 | + } |
|
| 1452 | 1509 | |
| 1453 | 1510 | // Allow adding new mod buttons easily. |
| 1454 | 1511 | // Note: $context['normal_buttons'] and $context['mod_buttons'] are added for backward compatibility with 2.0, but are deprecated and should not be used |
@@ -1457,12 +1514,14 @@ discard block |
||
| 1457 | 1514 | call_integration_hook('integrate_mod_buttons', array(&$context['mod_buttons'])); |
| 1458 | 1515 | |
| 1459 | 1516 | // Load the drafts js file |
| 1460 | - if ($context['drafts_autosave']) |
|
| 1461 | - loadJavaScriptFile('drafts.js', array('defer' => false), 'smf_drafts'); |
|
| 1517 | + if ($context['drafts_autosave']) { |
|
| 1518 | + loadJavaScriptFile('drafts.js', array('defer' => false), 'smf_drafts'); |
|
| 1519 | + } |
|
| 1462 | 1520 | |
| 1463 | 1521 | // Spellcheck |
| 1464 | - if ($context['show_spellchecking']) |
|
| 1465 | - loadJavaScriptFile('spellcheck.js', array('defer' => false), 'smf_spellcheck'); |
|
| 1522 | + if ($context['show_spellchecking']) { |
|
| 1523 | + loadJavaScriptFile('spellcheck.js', array('defer' => false), 'smf_spellcheck'); |
|
| 1524 | + } |
|
| 1466 | 1525 | |
| 1467 | 1526 | // topic.js |
| 1468 | 1527 | loadJavaScriptFile('topic.js', array('defer' => false), 'smf_topic'); |
@@ -1496,16 +1555,19 @@ discard block |
||
| 1496 | 1555 | static $counter = null; |
| 1497 | 1556 | |
| 1498 | 1557 | // If the query returned false, bail. |
| 1499 | - if ($messages_request == false) |
|
| 1500 | - return false; |
|
| 1558 | + if ($messages_request == false) { |
|
| 1559 | + return false; |
|
| 1560 | + } |
|
| 1501 | 1561 | |
| 1502 | 1562 | // Remember which message this is. (ie. reply #83) |
| 1503 | - if ($counter === null || $reset) |
|
| 1504 | - $counter = empty($options['view_newest_first']) ? $context['start'] : $context['total_visible_posts'] - $context['start']; |
|
| 1563 | + if ($counter === null || $reset) { |
|
| 1564 | + $counter = empty($options['view_newest_first']) ? $context['start'] : $context['total_visible_posts'] - $context['start']; |
|
| 1565 | + } |
|
| 1505 | 1566 | |
| 1506 | 1567 | // Start from the beginning... |
| 1507 | - if ($reset) |
|
| 1508 | - return @$smcFunc['db_data_seek']($messages_request, 0); |
|
| 1568 | + if ($reset) { |
|
| 1569 | + return @$smcFunc['db_data_seek']($messages_request, 0); |
|
| 1570 | + } |
|
| 1509 | 1571 | |
| 1510 | 1572 | // Attempt to get the next message. |
| 1511 | 1573 | $message = $smcFunc['db_fetch_assoc']($messages_request); |
@@ -1519,19 +1581,21 @@ discard block |
||
| 1519 | 1581 | if (empty($context['icon_sources'])) |
| 1520 | 1582 | { |
| 1521 | 1583 | $context['icon_sources'] = array(); |
| 1522 | - foreach ($context['stable_icons'] as $icon) |
|
| 1523 | - $context['icon_sources'][$icon] = 'images_url'; |
|
| 1584 | + foreach ($context['stable_icons'] as $icon) { |
|
| 1585 | + $context['icon_sources'][$icon] = 'images_url'; |
|
| 1586 | + } |
|
| 1524 | 1587 | } |
| 1525 | 1588 | |
| 1526 | 1589 | // Message Icon Management... check the images exist. |
| 1527 | 1590 | if (empty($modSettings['messageIconChecks_disable'])) |
| 1528 | 1591 | { |
| 1529 | 1592 | // If the current icon isn't known, then we need to do something... |
| 1530 | - if (!isset($context['icon_sources'][$message['icon']])) |
|
| 1531 | - $context['icon_sources'][$message['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
| 1593 | + if (!isset($context['icon_sources'][$message['icon']])) { |
|
| 1594 | + $context['icon_sources'][$message['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
| 1595 | + } |
|
| 1596 | + } elseif (!isset($context['icon_sources'][$message['icon']])) { |
|
| 1597 | + $context['icon_sources'][$message['icon']] = 'images_url'; |
|
| 1532 | 1598 | } |
| 1533 | - elseif (!isset($context['icon_sources'][$message['icon']])) |
|
| 1534 | - $context['icon_sources'][$message['icon']] = 'images_url'; |
|
| 1535 | 1599 | |
| 1536 | 1600 | // If you're a lazy bum, you probably didn't give a subject... |
| 1537 | 1601 | $message['subject'] = $message['subject'] != '' ? $message['subject'] : $txt['no_subject']; |
@@ -1556,8 +1620,7 @@ discard block |
||
| 1556 | 1620 | $memberContext[$message['id_member']]['email'] = $message['poster_email']; |
| 1557 | 1621 | $memberContext[$message['id_member']]['show_email'] = allowedTo('moderate_forum'); |
| 1558 | 1622 | $memberContext[$message['id_member']]['is_guest'] = true; |
| 1559 | - } |
|
| 1560 | - else |
|
| 1623 | + } else |
|
| 1561 | 1624 | { |
| 1562 | 1625 | // Define this here to make things a bit more readable |
| 1563 | 1626 | $can_view_warning = $context['user']['can_mod'] || allowedTo('view_warning_any') || ($message['id_member'] == $user_info['id'] && allowedTo('view_warning_own')); |
@@ -1580,8 +1643,9 @@ discard block |
||
| 1580 | 1643 | $message['body'] = parse_bbc($message['body'], $message['smileys_enabled'], $message['id_msg']); |
| 1581 | 1644 | |
| 1582 | 1645 | // If it's in the recycle bin we need to override whatever icon we did have. |
| 1583 | - if (!empty($board_info['recycle'])) |
|
| 1584 | - $message['icon'] = 'recycled'; |
|
| 1646 | + if (!empty($board_info['recycle'])) { |
|
| 1647 | + $message['icon'] = 'recycled'; |
|
| 1648 | + } |
|
| 1585 | 1649 | |
| 1586 | 1650 | require_once($sourcedir . '/Subs-Attachments.php'); |
| 1587 | 1651 | |
@@ -1625,32 +1689,36 @@ discard block |
||
| 1625 | 1689 | } |
| 1626 | 1690 | |
| 1627 | 1691 | // Are likes enable? |
| 1628 | - if (!empty($modSettings['enable_likes'])) |
|
| 1629 | - $output['likes'] = array( |
|
| 1692 | + if (!empty($modSettings['enable_likes'])) { |
|
| 1693 | + $output['likes'] = array( |
|
| 1630 | 1694 | 'count' => $message['likes'], |
| 1631 | 1695 | 'you' => in_array($message['id_msg'], $context['my_likes']), |
| 1632 | 1696 | 'can_like' => !$context['user']['is_guest'] && $message['id_member'] != $context['user']['id'] && !empty($context['can_like']), |
| 1633 | 1697 | ); |
| 1698 | + } |
|
| 1634 | 1699 | |
| 1635 | 1700 | // Is this user the message author? |
| 1636 | 1701 | $output['is_message_author'] = $message['id_member'] == $user_info['id']; |
| 1637 | - if (!empty($output['modified']['name'])) |
|
| 1638 | - $output['modified']['last_edit_text'] = sprintf($txt['last_edit_by'], $output['modified']['time'], $output['modified']['name']); |
|
| 1702 | + if (!empty($output['modified']['name'])) { |
|
| 1703 | + $output['modified']['last_edit_text'] = sprintf($txt['last_edit_by'], $output['modified']['time'], $output['modified']['name']); |
|
| 1704 | + } |
|
| 1639 | 1705 | |
| 1640 | 1706 | // Did they give a reason for editing? |
| 1641 | - if (!empty($output['modified']['name']) && !empty($output['modified']['reason'])) |
|
| 1642 | - $output['modified']['last_edit_text'] .= ' ' . sprintf($txt['last_edit_reason'], $output['modified']['reason']); |
|
| 1707 | + if (!empty($output['modified']['name']) && !empty($output['modified']['reason'])) { |
|
| 1708 | + $output['modified']['last_edit_text'] .= ' ' . sprintf($txt['last_edit_reason'], $output['modified']['reason']); |
|
| 1709 | + } |
|
| 1643 | 1710 | |
| 1644 | 1711 | // Any custom profile fields? |
| 1645 | - if (!empty($memberContext[$message['id_member']]['custom_fields'])) |
|
| 1646 | - foreach ($memberContext[$message['id_member']]['custom_fields'] as $custom) |
|
| 1712 | + if (!empty($memberContext[$message['id_member']]['custom_fields'])) { |
|
| 1713 | + foreach ($memberContext[$message['id_member']]['custom_fields'] as $custom) |
|
| 1647 | 1714 | $output['custom_fields'][$context['cust_profile_fields_placement'][$custom['placement']]][] = $custom; |
| 1715 | + } |
|
| 1648 | 1716 | |
| 1649 | - if (empty($options['view_newest_first'])) |
|
| 1650 | - $counter++; |
|
| 1651 | - |
|
| 1652 | - else |
|
| 1653 | - $counter--; |
|
| 1717 | + if (empty($options['view_newest_first'])) { |
|
| 1718 | + $counter++; |
|
| 1719 | + } else { |
|
| 1720 | + $counter--; |
|
| 1721 | + } |
|
| 1654 | 1722 | |
| 1655 | 1723 | call_integration_hook('integrate_prepare_display_context', array(&$output, &$message, $counter)); |
| 1656 | 1724 | |
@@ -1676,8 +1744,9 @@ discard block |
||
| 1676 | 1744 | */ |
| 1677 | 1745 | function approved_attach_sort($a, $b) |
| 1678 | 1746 | { |
| 1679 | - if ($a['is_approved'] == $b['is_approved']) |
|
| 1680 | - return 0; |
|
| 1747 | + if ($a['is_approved'] == $b['is_approved']) { |
|
| 1748 | + return 0; |
|
| 1749 | + } |
|
| 1681 | 1750 | |
| 1682 | 1751 | return $a['is_approved'] > $b['is_approved'] ? -1 : 1; |
| 1683 | 1752 | } |
@@ -1694,16 +1763,19 @@ discard block |
||
| 1694 | 1763 | |
| 1695 | 1764 | require_once($sourcedir . '/RemoveTopic.php'); |
| 1696 | 1765 | |
| 1697 | - if (empty($_REQUEST['msgs'])) |
|
| 1698 | - redirectexit('topic=' . $topic . '.' . $_REQUEST['start']); |
|
| 1766 | + if (empty($_REQUEST['msgs'])) { |
|
| 1767 | + redirectexit('topic=' . $topic . '.' . $_REQUEST['start']); |
|
| 1768 | + } |
|
| 1699 | 1769 | |
| 1700 | 1770 | $messages = array(); |
| 1701 | - foreach ($_REQUEST['msgs'] as $dummy) |
|
| 1702 | - $messages[] = (int) $dummy; |
|
| 1771 | + foreach ($_REQUEST['msgs'] as $dummy) { |
|
| 1772 | + $messages[] = (int) $dummy; |
|
| 1773 | + } |
|
| 1703 | 1774 | |
| 1704 | 1775 | // We are restoring messages. We handle this in another place. |
| 1705 | - if (isset($_REQUEST['restore_selected'])) |
|
| 1706 | - redirectexit('action=restoretopic;msgs=' . implode(',', $messages) . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 1776 | + if (isset($_REQUEST['restore_selected'])) { |
|
| 1777 | + redirectexit('action=restoretopic;msgs=' . implode(',', $messages) . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 1778 | + } |
|
| 1707 | 1779 | if (isset($_REQUEST['split_selection'])) |
| 1708 | 1780 | { |
| 1709 | 1781 | $request = $smcFunc['db_query']('', ' |
@@ -1722,8 +1794,9 @@ discard block |
||
| 1722 | 1794 | } |
| 1723 | 1795 | |
| 1724 | 1796 | // Allowed to delete any message? |
| 1725 | - if (allowedTo('delete_any')) |
|
| 1726 | - $allowed_all = true; |
|
| 1797 | + if (allowedTo('delete_any')) { |
|
| 1798 | + $allowed_all = true; |
|
| 1799 | + } |
|
| 1727 | 1800 | // Allowed to delete replies to their messages? |
| 1728 | 1801 | elseif (allowedTo('delete_replies')) |
| 1729 | 1802 | { |
@@ -1740,13 +1813,14 @@ discard block |
||
| 1740 | 1813 | $smcFunc['db_free_result']($request); |
| 1741 | 1814 | |
| 1742 | 1815 | $allowed_all = $starter == $user_info['id']; |
| 1816 | + } else { |
|
| 1817 | + $allowed_all = false; |
|
| 1743 | 1818 | } |
| 1744 | - else |
|
| 1745 | - $allowed_all = false; |
|
| 1746 | 1819 | |
| 1747 | 1820 | // Make sure they're allowed to delete their own messages, if not any. |
| 1748 | - if (!$allowed_all) |
|
| 1749 | - isAllowedTo('delete_own'); |
|
| 1821 | + if (!$allowed_all) { |
|
| 1822 | + isAllowedTo('delete_own'); |
|
| 1823 | + } |
|
| 1750 | 1824 | |
| 1751 | 1825 | // Allowed to remove which messages? |
| 1752 | 1826 | $request = $smcFunc['db_query']('', ' |
@@ -1766,8 +1840,9 @@ discard block |
||
| 1766 | 1840 | $messages = array(); |
| 1767 | 1841 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1768 | 1842 | { |
| 1769 | - if (!$allowed_all && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + $modSettings['edit_disable_time'] * 60 < time()) |
|
| 1770 | - continue; |
|
| 1843 | + if (!$allowed_all && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + $modSettings['edit_disable_time'] * 60 < time()) { |
|
| 1844 | + continue; |
|
| 1845 | + } |
|
| 1771 | 1846 | |
| 1772 | 1847 | $messages[$row['id_msg']] = array($row['subject'], $row['id_member']); |
| 1773 | 1848 | } |
@@ -1790,17 +1865,20 @@ discard block |
||
| 1790 | 1865 | foreach ($messages as $message => $info) |
| 1791 | 1866 | { |
| 1792 | 1867 | // Just skip the first message - if it's not the last. |
| 1793 | - if ($message == $first_message && $message != $last_message) |
|
| 1794 | - continue; |
|
| 1868 | + if ($message == $first_message && $message != $last_message) { |
|
| 1869 | + continue; |
|
| 1870 | + } |
|
| 1795 | 1871 | // If the first message is going then don't bother going back to the topic as we're effectively deleting it. |
| 1796 | - elseif ($message == $first_message) |
|
| 1797 | - $topicGone = true; |
|
| 1872 | + elseif ($message == $first_message) { |
|
| 1873 | + $topicGone = true; |
|
| 1874 | + } |
|
| 1798 | 1875 | |
| 1799 | 1876 | removeMessage($message); |
| 1800 | 1877 | |
| 1801 | 1878 | // Log this moderation action ;). |
| 1802 | - if (allowedTo('delete_any') && (!allowedTo('delete_own') || $info[1] != $user_info['id'])) |
|
| 1803 | - logAction('delete', array('topic' => $topic, 'subject' => $info[0], 'member' => $info[1], 'board' => $board)); |
|
| 1879 | + if (allowedTo('delete_any') && (!allowedTo('delete_own') || $info[1] != $user_info['id'])) { |
|
| 1880 | + logAction('delete', array('topic' => $topic, 'subject' => $info[0], 'member' => $info[1], 'board' => $board)); |
|
| 1881 | + } |
|
| 1804 | 1882 | } |
| 1805 | 1883 | |
| 1806 | 1884 | redirectexit(!empty($topicGone) ? 'board=' . $board : 'topic=' . $topic . '.' . $_REQUEST['start']); |
@@ -73,10 +73,10 @@ discard block |
||
| 73 | 73 | <subject is_first="', $context['message']['first_in_topic'] ? '1' : '0', '"><![CDATA[', cleanXml($context['message']['subject']), ']]></subject> |
| 74 | 74 | <body><![CDATA[', $context['message']['body'], ']]></body> |
| 75 | 75 | <success><![CDATA[', $txt['quick_modify_message'], ']]></success>'; |
| 76 | - } |
|
| 77 | - else |
|
| 78 | - echo ' |
|
| 76 | + } else { |
|
| 77 | + echo ' |
|
| 79 | 78 | <error in_subject="', $context['message']['error_in_subject'] ? '1' : '0', '" in_body="', cleanXml($context['message']['error_in_body']) ? '1' : '0', '"><![CDATA[', implode('<br />', $context['message']['errors']), ']]></error>'; |
| 79 | + } |
|
| 80 | 80 | echo ' |
| 81 | 81 | </message> |
| 82 | 82 | </smf>'; |
@@ -101,13 +101,14 @@ discard block |
||
| 101 | 101 | echo ' |
| 102 | 102 | <modified><![CDATA[', empty($modified) ? '' : cleanXml('« <em>' . $modified . '</em>»'), ']]></modified>'; |
| 103 | 103 | |
| 104 | - if (!empty($context['message']['subject'])) |
|
| 105 | - echo ' |
|
| 104 | + if (!empty($context['message']['subject'])) { |
|
| 105 | + echo ' |
|
| 106 | 106 | <subject><![CDATA[', cleanXml($context['message']['subject']), ']]></subject>'; |
| 107 | - } |
|
| 108 | - else |
|
| 109 | - echo ' |
|
| 107 | + } |
|
| 108 | + } else { |
|
| 109 | + echo ' |
|
| 110 | 110 | <error in_subject="', $context['message']['error_in_subject'] ? '1' : '0', '"><![CDATA[', cleanXml(implode('<br />', $context['message']['errors'])), ']]></error>'; |
| 111 | + } |
|
| 111 | 112 | echo ' |
| 112 | 113 | </message> |
| 113 | 114 | </smf>'; |
@@ -128,10 +129,11 @@ discard block |
||
| 128 | 129 | </preview> |
| 129 | 130 | <errors serious="', empty($context['error_type']) || $context['error_type'] != 'serious' ? '0' : '1', '" topic_locked="', $context['locked'] ? '1' : '0', '">'; |
| 130 | 131 | |
| 131 | - if (!empty($context['post_error'])) |
|
| 132 | - foreach ($context['post_error'] as $message) |
|
| 132 | + if (!empty($context['post_error'])) { |
|
| 133 | + foreach ($context['post_error'] as $message) |
|
| 133 | 134 | echo ' |
| 134 | 135 | <error><![CDATA[', cleanXml($message), ']]></error>'; |
| 136 | + } |
|
| 135 | 137 | |
| 136 | 138 | echo ' |
| 137 | 139 | <caption name="guestname" class="', isset($context['post_error']['long_name']) || isset($context['post_error']['no_name']) || isset($context['post_error']['bad_name']) ? 'error' : '', '" /> |
@@ -148,14 +150,15 @@ discard block |
||
| 148 | 150 | echo ' |
| 149 | 151 | <new_posts>'; |
| 150 | 152 | |
| 151 | - foreach ($context['previous_posts'] as $post) |
|
| 152 | - echo ' |
|
| 153 | + foreach ($context['previous_posts'] as $post) { |
|
| 154 | + echo ' |
|
| 153 | 155 | <post id="', $post['id'], '"> |
| 154 | 156 | <time><![CDATA[', $post['time'], ']]></time> |
| 155 | 157 | <poster><![CDATA[', cleanXml($post['poster']), ']]></poster> |
| 156 | 158 | <message><![CDATA[', cleanXml($post['message']), ']]></message> |
| 157 | 159 | <is_ignored>', $post['is_ignored'] ? '1' : '0', '</is_ignored> |
| 158 | 160 | </post>'; |
| 161 | + } |
|
| 159 | 162 | |
| 160 | 163 | echo ' |
| 161 | 164 | </new_posts>'; |
@@ -181,10 +184,11 @@ discard block |
||
| 181 | 184 | </preview> |
| 182 | 185 | <errors serious="', empty($context['error_type']) || $context['error_type'] != 'serious' ? '0' : '1', '">'; |
| 183 | 186 | |
| 184 | - if (!empty($context['post_error']['messages'])) |
|
| 185 | - foreach ($context['post_error']['messages'] as $message) |
|
| 187 | + if (!empty($context['post_error']['messages'])) { |
|
| 188 | + foreach ($context['post_error']['messages'] as $message) |
|
| 186 | 189 | echo ' |
| 187 | 190 | <error><![CDATA[', cleanXml($message), ']]></error>'; |
| 191 | + } |
|
| 188 | 192 | |
| 189 | 193 | echo ' |
| 190 | 194 | <caption name="to" class="', isset($context['post_error']['no_to']) ? 'error' : '', '" /> |
@@ -214,10 +218,11 @@ discard block |
||
| 214 | 218 | </preview> |
| 215 | 219 | <errors serious="', empty($context['error_type']) || $context['error_type'] != 'serious' ? '0' : '1', '">'; |
| 216 | 220 | |
| 217 | - if (!empty($context['post_error']['messages'])) |
|
| 218 | - foreach ($context['post_error']['messages'] as $message) |
|
| 221 | + if (!empty($context['post_error']['messages'])) { |
|
| 222 | + foreach ($context['post_error']['messages'] as $message) |
|
| 219 | 223 | echo ' |
| 220 | 224 | <error><![CDATA[', cleanXml($message), ']]></error>'; |
| 225 | + } |
|
| 221 | 226 | |
| 222 | 227 | echo ' |
| 223 | 228 | </errors>'; |
@@ -233,20 +238,23 @@ discard block |
||
| 233 | 238 | { |
| 234 | 239 | global $context, $modSettings; |
| 235 | 240 | |
| 236 | - if (empty($context['yearly'])) |
|
| 237 | - return; |
|
| 241 | + if (empty($context['yearly'])) { |
|
| 242 | + return; |
|
| 243 | + } |
|
| 238 | 244 | |
| 239 | 245 | echo '<', '?xml version="1.0" encoding="', $context['character_set'], '"?', '> |
| 240 | 246 | <smf>'; |
| 241 | - foreach ($context['yearly'] as $year) |
|
| 242 | - foreach ($year['months'] as $month) |
|
| 247 | + foreach ($context['yearly'] as $year) { |
|
| 248 | + foreach ($year['months'] as $month) |
|
| 243 | 249 | { |
| 244 | 250 | echo ' |
| 245 | 251 | <month id="', $month['date']['year'], $month['date']['month'], '">'; |
| 252 | + } |
|
| 246 | 253 | |
| 247 | - foreach ($month['days'] as $day) |
|
| 248 | - echo ' |
|
| 254 | + foreach ($month['days'] as $day) { |
|
| 255 | + echo ' |
|
| 249 | 256 | <day date="', $day['year'], '-', $day['month'], '-', $day['day'], '" new_topics="', $day['new_topics'], '" new_posts="', $day['new_posts'], '" new_members="', $day['new_members'], '" most_members_online="', $day['most_members_online'], '"', empty($modSettings['hitStats']) ? '' : ' hits="' . $day['hits'] . '"', ' />'; |
| 257 | + } |
|
| 250 | 258 | |
| 251 | 259 | echo ' |
| 252 | 260 | </month>'; |
@@ -269,17 +277,18 @@ discard block |
||
| 269 | 277 | <pageIndex section="selected" startFrom="', $context['selected']['start'], '"><![CDATA[', $context['selected']['page_index'], ']]></pageIndex>'; |
| 270 | 278 | foreach ($context['changes'] as $change) |
| 271 | 279 | { |
| 272 | - if ($change['type'] == 'remove') |
|
| 273 | - echo ' |
|
| 280 | + if ($change['type'] == 'remove') { |
|
| 281 | + echo ' |
|
| 274 | 282 | <change id="', $change['id'], '" curAction="remove" section="', $change['section'], '" />'; |
| 275 | - else |
|
| 276 | - echo ' |
|
| 283 | + } else { |
|
| 284 | + echo ' |
|
| 277 | 285 | <change id="', $change['id'], '" curAction="insert" section="', $change['section'], '"> |
| 278 | 286 | <subject><![CDATA[', cleanXml($change['insert_value']['subject']), ']]></subject> |
| 279 | 287 | <time><![CDATA[', cleanXml($change['insert_value']['time']), ']]></time> |
| 280 | 288 | <body><![CDATA[', cleanXml($change['insert_value']['body']), ']]></body> |
| 281 | 289 | <poster><![CDATA[', cleanXml($change['insert_value']['poster']), ']]></poster> |
| 282 | 290 | </change>'; |
| 291 | + } |
|
| 283 | 292 | } |
| 284 | 293 | echo ' |
| 285 | 294 | </smf>'; |
@@ -310,10 +319,10 @@ discard block |
||
| 310 | 319 | echo '<', '?xml version="1.0" encoding="', $context['character_set'], '"?', '> |
| 311 | 320 | <smf>'; |
| 312 | 321 | |
| 313 | - if (empty($context['topics'])) |
|
| 314 | - echo ' |
|
| 322 | + if (empty($context['topics'])) { |
|
| 323 | + echo ' |
|
| 315 | 324 | <noresults>', $txt['search_no_results'], '</noresults>'; |
| 316 | - else |
|
| 325 | + } else |
|
| 317 | 326 | { |
| 318 | 327 | echo ' |
| 319 | 328 | <results>'; |
@@ -382,9 +391,10 @@ discard block |
||
| 382 | 391 | echo ' |
| 383 | 392 | <item type="category" id="', $category['id'], '"><![CDATA[', cleanXml($category['name']), ']]></item>'; |
| 384 | 393 | |
| 385 | - foreach ($category['boards'] as $board) |
|
| 386 | - echo ' |
|
| 394 | + foreach ($category['boards'] as $board) { |
|
| 395 | + echo ' |
|
| 387 | 396 | <item type="board" id="', $board['id'], '" childlevel="', $board['child_level'], '"><![CDATA[', cleanXml($board['name']), ']]></item>'; |
| 397 | + } |
|
| 388 | 398 | } |
| 389 | 399 | echo ' |
| 390 | 400 | </smf>'; |
@@ -400,9 +410,10 @@ discard block |
||
| 400 | 410 | echo '<', '?xml version="1.0" encoding="', $context['character_set'], '"?', '> |
| 401 | 411 | <smf>'; |
| 402 | 412 | |
| 403 | - foreach ($context['icons'] as $icon) |
|
| 404 | - echo ' |
|
| 413 | + foreach ($context['icons'] as $icon) { |
|
| 414 | + echo ' |
|
| 405 | 415 | <icon value="', $icon['value'], '" url="', $icon['url'], '"><![CDATA[', cleanXml($icon['name']), ']]></icon>'; |
| 416 | + } |
|
| 406 | 417 | |
| 407 | 418 | echo ' |
| 408 | 419 | </smf>'; |
@@ -452,16 +463,18 @@ discard block |
||
| 452 | 463 | foreach ($xml_data as $key => $data) |
| 453 | 464 | { |
| 454 | 465 | // A group? |
| 455 | - if (is_array($data) && isset($data['identifier'])) |
|
| 456 | - template_generic_xml_recursive($data['children'], $key, $data['identifier'], $level); |
|
| 466 | + if (is_array($data) && isset($data['identifier'])) { |
|
| 467 | + template_generic_xml_recursive($data['children'], $key, $data['identifier'], $level); |
|
| 468 | + } |
|
| 457 | 469 | // An item... |
| 458 | 470 | elseif (is_array($data) && isset($data['value'])) |
| 459 | 471 | { |
| 460 | 472 | echo "\n", str_repeat("\t", $level), '<', $child_ident; |
| 461 | 473 | |
| 462 | - if (!empty($data['attributes'])) |
|
| 463 | - foreach ($data['attributes'] as $k => $v) |
|
| 474 | + if (!empty($data['attributes'])) { |
|
| 475 | + foreach ($data['attributes'] as $k => $v) |
|
| 464 | 476 | echo ' ' . $k . '="' . $v . '"'; |
| 477 | + } |
|
| 465 | 478 | echo '><![CDATA[', cleanXml($data['value']), ']]></', $child_ident, '>'; |
| 466 | 479 | } |
| 467 | 480 | |
@@ -26,9 +26,10 @@ discard block |
||
| 26 | 26 | </div> |
| 27 | 27 | <div class="pagesection">', $context['page_index'], '</div>'; |
| 28 | 28 | |
| 29 | - if (empty($context['posts'])) |
|
| 30 | - echo ' |
|
| 29 | + if (empty($context['posts'])) { |
|
| 30 | + echo ' |
|
| 31 | 31 | <div class="windowbg">', $txt['no_messages'], '</div>'; |
| 32 | + } |
|
| 32 | 33 | |
| 33 | 34 | foreach ($context['posts'] as $post) |
| 34 | 35 | { |
@@ -41,28 +42,33 @@ discard block |
||
| 41 | 42 | </div> |
| 42 | 43 | <div class="list_posts">', $post['message'], '</div>'; |
| 43 | 44 | |
| 44 | - if ($post['can_reply'] || $post['can_quote'] || $post['can_delete']) |
|
| 45 | - echo ' |
|
| 45 | + if ($post['can_reply'] || $post['can_quote'] || $post['can_delete']) { |
|
| 46 | + echo ' |
|
| 46 | 47 | <ul class="quickbuttons">'; |
| 48 | + } |
|
| 47 | 49 | |
| 48 | 50 | // If they *can* reply? |
| 49 | - if ($post['can_reply']) |
|
| 50 | - echo ' |
|
| 51 | + if ($post['can_reply']) { |
|
| 52 | + echo ' |
|
| 51 | 53 | <li><a href="', $scripturl, '?action=post;topic=', $post['topic'], '.', $post['start'], '"><span class="generic_icons reply_button"></span>', $txt['reply'], '</a></li>'; |
| 54 | + } |
|
| 52 | 55 | |
| 53 | 56 | // If they *can* quote? |
| 54 | - if ($post['can_quote']) |
|
| 55 | - echo ' |
|
| 57 | + if ($post['can_quote']) { |
|
| 58 | + echo ' |
|
| 56 | 59 | <li><a href="', $scripturl, '?action=post;topic=', $post['topic'], '.', $post['start'], ';quote=', $post['id'], '"><span class="generic_icons quote"></span>', $txt['quote_action'], '</a></li>'; |
| 60 | + } |
|
| 57 | 61 | |
| 58 | 62 | // How about... even... remove it entirely?! |
| 59 | - if ($post['can_delete']) |
|
| 60 | - echo ' |
|
| 63 | + if ($post['can_delete']) { |
|
| 64 | + echo ' |
|
| 61 | 65 | <li><a href="', $scripturl, '?action=deletemsg;msg=', $post['id'], ';topic=', $post['topic'], ';recent;', $context['session_var'], '=', $context['session_id'], '" data-confirm="', $txt['remove_message'], '" class="you_sure"><span class="generic_icons remove_button"></span>', $txt['remove'], '</a></li>'; |
| 66 | + } |
|
| 62 | 67 | |
| 63 | - if ($post['can_reply'] || $post['can_quote'] || $post['can_delete']) |
|
| 64 | - echo ' |
|
| 68 | + if ($post['can_reply'] || $post['can_quote'] || $post['can_delete']) { |
|
| 69 | + echo ' |
|
| 65 | 70 | </ul>'; |
| 71 | + } |
|
| 66 | 72 | |
| 67 | 73 | echo ' |
| 68 | 74 | </div><!-- $post[css_class] -->'; |
@@ -84,12 +90,13 @@ discard block |
||
| 84 | 90 | echo ' |
| 85 | 91 | <div id="recent" class="main_content">'; |
| 86 | 92 | |
| 87 | - if ($context['showCheckboxes']) |
|
| 88 | - echo ' |
|
| 93 | + if ($context['showCheckboxes']) { |
|
| 94 | + echo ' |
|
| 89 | 95 | <form action="', $scripturl, '?action=quickmod" method="post" accept-charset="', $context['character_set'], '" name="quickModForm" id="quickModForm"> |
| 90 | 96 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
| 91 | 97 | <input type="hidden" name="qaction" value="markread"> |
| 92 | 98 | <input type="hidden" name="redirect_url" value="action=unread', (!empty($context['showing_all_topics']) ? ';all' : ''), $context['querystring_board_limits'], '">'; |
| 99 | + } |
|
| 93 | 100 | |
| 94 | 101 | if (!empty($context['topics'])) |
| 95 | 102 | { |
@@ -118,11 +125,12 @@ discard block |
||
| 118 | 125 | </div>'; |
| 119 | 126 | |
| 120 | 127 | // Show a "select all" box for quick moderation? |
| 121 | - if ($context['showCheckboxes']) |
|
| 122 | - echo ' |
|
| 128 | + if ($context['showCheckboxes']) { |
|
| 129 | + echo ' |
|
| 123 | 130 | <div class="moderation"> |
| 124 | 131 | <input type="checkbox" onclick="invertAll(this, this.form, \'topics[]\');"> |
| 125 | 132 | </div>'; |
| 133 | + } |
|
| 126 | 134 | |
| 127 | 135 | echo ' |
| 128 | 136 | </div><!-- #topic_header --> |
@@ -142,17 +150,20 @@ discard block |
||
| 142 | 150 | echo ' |
| 143 | 151 | <div class="icons floatright">'; |
| 144 | 152 | |
| 145 | - if ($topic['is_locked']) |
|
| 146 | - echo ' |
|
| 153 | + if ($topic['is_locked']) { |
|
| 154 | + echo ' |
|
| 147 | 155 | <span class="generic_icons lock"></span>'; |
| 156 | + } |
|
| 148 | 157 | |
| 149 | - if ($topic['is_sticky']) |
|
| 150 | - echo ' |
|
| 158 | + if ($topic['is_sticky']) { |
|
| 159 | + echo ' |
|
| 151 | 160 | <span class="generic_icons sticky"></span>'; |
| 161 | + } |
|
| 152 | 162 | |
| 153 | - if ($topic['is_poll']) |
|
| 154 | - echo ' |
|
| 163 | + if ($topic['is_poll']) { |
|
| 164 | + echo ' |
|
| 155 | 165 | <span class="generic_icons poll"></span>'; |
| 166 | + } |
|
| 156 | 167 | |
| 157 | 168 | echo ' |
| 158 | 169 | </div>'; |
@@ -178,19 +189,21 @@ discard block |
||
| 178 | 189 | ', sprintf($txt['last_post_topic'], '<a href="' . $topic['last_post']['href'] . '">' . $topic['last_post']['time'] . '</a>', $topic['last_post']['member']['link']), ' |
| 179 | 190 | </div>'; |
| 180 | 191 | |
| 181 | - if ($context['showCheckboxes']) |
|
| 182 | - echo ' |
|
| 192 | + if ($context['showCheckboxes']) { |
|
| 193 | + echo ' |
|
| 183 | 194 | <div class="moderation"> |
| 184 | 195 | <input type="checkbox" name="topics[]" value="', $topic['id'], '"> |
| 185 | 196 | </div>'; |
| 197 | + } |
|
| 186 | 198 | |
| 187 | 199 | echo ' |
| 188 | 200 | </div><!-- $topic[css_class] -->'; |
| 189 | 201 | } |
| 190 | 202 | |
| 191 | - if (empty($context['topics'])) |
|
| 192 | - echo ' |
|
| 203 | + if (empty($context['topics'])) { |
|
| 204 | + echo ' |
|
| 193 | 205 | <div style="display: none;"></div>'; |
| 206 | + } |
|
| 194 | 207 | |
| 195 | 208 | echo ' |
| 196 | 209 | </div><!-- #topic_container --> |
@@ -205,25 +218,27 @@ discard block |
||
| 205 | 218 | ', $context['page_index'], ' |
| 206 | 219 | </div> |
| 207 | 220 | </div>'; |
| 208 | - } |
|
| 209 | - else |
|
| 210 | - echo ' |
|
| 221 | + } else { |
|
| 222 | + echo ' |
|
| 211 | 223 | <div class="cat_bar"> |
| 212 | 224 | <h3 class="catbg centertext"> |
| 213 | 225 | ', $context['showing_all_topics'] ? $txt['topic_alert_none'] : $txt['unread_topics_visit_none'], ' |
| 214 | 226 | </h3> |
| 215 | 227 | </div>'; |
| 228 | + } |
|
| 216 | 229 | |
| 217 | - if ($context['showCheckboxes']) |
|
| 218 | - echo ' |
|
| 230 | + if ($context['showCheckboxes']) { |
|
| 231 | + echo ' |
|
| 219 | 232 | </form>'; |
| 233 | + } |
|
| 220 | 234 | |
| 221 | 235 | echo ' |
| 222 | 236 | </div><!-- #recent -->'; |
| 223 | 237 | |
| 224 | - if (empty($context['no_topic_listing'])) |
|
| 225 | - template_topic_legend(); |
|
| 226 | -} |
|
| 238 | + if (empty($context['no_topic_listing'])) { |
|
| 239 | + template_topic_legend(); |
|
| 240 | + } |
|
| 241 | + } |
|
| 227 | 242 | |
| 228 | 243 | /** |
| 229 | 244 | * Template for showing unread replies (eg new replies to topics you've posted in) |
@@ -235,12 +250,13 @@ discard block |
||
| 235 | 250 | echo ' |
| 236 | 251 | <div id="recent">'; |
| 237 | 252 | |
| 238 | - if ($context['showCheckboxes']) |
|
| 239 | - echo ' |
|
| 253 | + if ($context['showCheckboxes']) { |
|
| 254 | + echo ' |
|
| 240 | 255 | <form action="', $scripturl, '?action=quickmod" method="post" accept-charset="', $context['character_set'], '" name="quickModForm" id="quickModForm"> |
| 241 | 256 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
| 242 | 257 | <input type="hidden" name="qaction" value="markread"> |
| 243 | 258 | <input type="hidden" name="redirect_url" value="action=unreadreplies', (!empty($context['showing_all_topics']) ? ';all' : ''), $context['querystring_board_limits'], '">'; |
| 259 | + } |
|
| 244 | 260 | |
| 245 | 261 | if (!empty($context['topics'])) |
| 246 | 262 | { |
@@ -269,11 +285,12 @@ discard block |
||
| 269 | 285 | </div>'; |
| 270 | 286 | |
| 271 | 287 | // Show a "select all" box for quick moderation? |
| 272 | - if ($context['showCheckboxes']) |
|
| 273 | - echo ' |
|
| 288 | + if ($context['showCheckboxes']) { |
|
| 289 | + echo ' |
|
| 274 | 290 | <div class="moderation"> |
| 275 | 291 | <input type="checkbox" onclick="invertAll(this, this.form, \'topics[]\');"> |
| 276 | 292 | </div>'; |
| 293 | + } |
|
| 277 | 294 | |
| 278 | 295 | echo ' |
| 279 | 296 | </div><!-- #topic_header --> |
@@ -293,17 +310,20 @@ discard block |
||
| 293 | 310 | echo ' |
| 294 | 311 | <div class="icons floatright">'; |
| 295 | 312 | |
| 296 | - if ($topic['is_locked']) |
|
| 297 | - echo ' |
|
| 313 | + if ($topic['is_locked']) { |
|
| 314 | + echo ' |
|
| 298 | 315 | <span class="generic_icons lock"></span>'; |
| 316 | + } |
|
| 299 | 317 | |
| 300 | - if ($topic['is_sticky']) |
|
| 301 | - echo ' |
|
| 318 | + if ($topic['is_sticky']) { |
|
| 319 | + echo ' |
|
| 302 | 320 | <span class="generic_icons sticky"></span>'; |
| 321 | + } |
|
| 303 | 322 | |
| 304 | - if ($topic['is_poll']) |
|
| 305 | - echo ' |
|
| 323 | + if ($topic['is_poll']) { |
|
| 324 | + echo ' |
|
| 306 | 325 | <span class="generic_icons poll"></span>'; |
| 326 | + } |
|
| 307 | 327 | |
| 308 | 328 | echo ' |
| 309 | 329 | </div>'; |
@@ -329,11 +349,12 @@ discard block |
||
| 329 | 349 | ', sprintf($txt['last_post_topic'], '<a href="' . $topic['last_post']['href'] . '">' . $topic['last_post']['time'] . '</a>', $topic['last_post']['member']['link']), ' |
| 330 | 350 | </div>'; |
| 331 | 351 | |
| 332 | - if ($context['showCheckboxes']) |
|
| 333 | - echo ' |
|
| 352 | + if ($context['showCheckboxes']) { |
|
| 353 | + echo ' |
|
| 334 | 354 | <div class="moderation"> |
| 335 | 355 | <input type="checkbox" name="topics[]" value="', $topic['id'], '"> |
| 336 | 356 | </div>'; |
| 357 | + } |
|
| 337 | 358 | |
| 338 | 359 | echo ' |
| 339 | 360 | </div><!-- $topic[css_class] -->'; |
@@ -350,24 +371,26 @@ discard block |
||
| 350 | 371 | ', $context['page_index'], ' |
| 351 | 372 | </div> |
| 352 | 373 | </div>'; |
| 353 | - } |
|
| 354 | - else |
|
| 355 | - echo ' |
|
| 374 | + } else { |
|
| 375 | + echo ' |
|
| 356 | 376 | <div class="cat_bar"> |
| 357 | 377 | <h3 class="catbg centertext"> |
| 358 | 378 | ', $context['showing_all_topics'] ? $txt['topic_alert_none'] : $txt['unread_topics_visit_none'], ' |
| 359 | 379 | </h3> |
| 360 | 380 | </div>'; |
| 381 | + } |
|
| 361 | 382 | |
| 362 | - if ($context['showCheckboxes']) |
|
| 363 | - echo ' |
|
| 383 | + if ($context['showCheckboxes']) { |
|
| 384 | + echo ' |
|
| 364 | 385 | </form>'; |
| 386 | + } |
|
| 365 | 387 | |
| 366 | 388 | echo ' |
| 367 | 389 | </div><!-- #recent -->'; |
| 368 | 390 | |
| 369 | - if (empty($context['no_topic_listing'])) |
|
| 370 | - template_topic_legend(); |
|
| 371 | -} |
|
| 391 | + if (empty($context['no_topic_listing'])) { |
|
| 392 | + template_topic_legend(); |
|
| 393 | + } |
|
| 394 | + } |
|
| 372 | 395 | |
| 373 | 396 | ?> |
| 374 | 397 | \ No newline at end of file |
@@ -31,8 +31,8 @@ discard block |
||
| 31 | 31 | <div class="windowbg"> |
| 32 | 32 | <ul id="likes">'; |
| 33 | 33 | |
| 34 | - foreach ($context['likers'] as $liker => $like_details) |
|
| 35 | - echo ' |
|
| 34 | + foreach ($context['likers'] as $liker => $like_details) { |
|
| 35 | + echo ' |
|
| 36 | 36 | <li> |
| 37 | 37 | ', $like_details['profile']['avatar']['image'], ' |
| 38 | 38 | <span> |
@@ -41,6 +41,7 @@ discard block |
||
| 41 | 41 | </span> |
| 42 | 42 | <span class="floatright">', $like_details['time'], '</span> |
| 43 | 43 | </li>'; |
| 44 | + } |
|
| 44 | 45 | |
| 45 | 46 | echo ' |
| 46 | 47 | </ul> |
@@ -61,11 +62,12 @@ discard block |
||
| 61 | 62 | echo ' |
| 62 | 63 | <ul class="floatleft">'; |
| 63 | 64 | |
| 64 | - if (!empty($context['data']['can_like'])) |
|
| 65 | - echo ' |
|
| 65 | + if (!empty($context['data']['can_like'])) { |
|
| 66 | + echo ' |
|
| 66 | 67 | <li class="like_button" id="', $context['data']['type'], '_', $context['data']['id_content'], '_likes"', '> |
| 67 | 68 | <a href="', $scripturl, '?action=likes;ltype=', $context['data']['type'], ';sa=like;like=', $context['data']['id_content'], ';', $context['session_var'], '=', $context['session_id'], '" class="', $context['data']['type'], '_like"><span class="generic_icons ', $context['data']['already_liked'] ? 'unlike' : 'like', '"></span> ', $context['data']['already_liked'] ? $txt['unlike'] : $txt['like'], '</a> |
| 68 | 69 | </li>'; |
| 70 | + } |
|
| 69 | 71 | |
| 70 | 72 | if (!empty($context['data']['count'])) |
| 71 | 73 | { |
@@ -55,18 +55,20 @@ discard block |
||
| 55 | 55 | <div class="modbox"> |
| 56 | 56 | <ul>'; |
| 57 | 57 | |
| 58 | - foreach ($context['group_requests'] as $request) |
|
| 59 | - echo ' |
|
| 58 | + foreach ($context['group_requests'] as $request) { |
|
| 59 | + echo ' |
|
| 60 | 60 | <li class="smalltext"> |
| 61 | 61 | <a href="', $request['request_href'], '">', $request['group']['name'], '</a> ', $txt['mc_groupr_by'], ' ', $request['member']['link'], ' |
| 62 | 62 | </li>'; |
| 63 | + } |
|
| 63 | 64 | |
| 64 | 65 | // Don't have any watched users right now? |
| 65 | - if (empty($context['group_requests'])) |
|
| 66 | - echo ' |
|
| 66 | + if (empty($context['group_requests'])) { |
|
| 67 | + echo ' |
|
| 67 | 68 | <li> |
| 68 | 69 | <strong class="smalltext">', $txt['mc_group_requests_none'], '</strong> |
| 69 | 70 | </li>'; |
| 71 | + } |
|
| 70 | 72 | |
| 71 | 73 | echo ' |
| 72 | 74 | </ul> |
@@ -124,18 +126,20 @@ discard block |
||
| 124 | 126 | <div class="modbox"> |
| 125 | 127 | <ul>'; |
| 126 | 128 | |
| 127 | - foreach ($context['watched_users'] as $user) |
|
| 128 | - echo ' |
|
| 129 | + foreach ($context['watched_users'] as $user) { |
|
| 130 | + echo ' |
|
| 129 | 131 | <li> |
| 130 | 132 | <span class="smalltext">', sprintf(!empty($user['last_login']) ? $txt['mc_seen'] : $txt['mc_seen_never'], $user['link'], $user['last_login']), '</span> |
| 131 | 133 | </li>'; |
| 134 | + } |
|
| 132 | 135 | |
| 133 | 136 | // Don't have any watched users right now? |
| 134 | - if (empty($context['watched_users'])) |
|
| 135 | - echo ' |
|
| 137 | + if (empty($context['watched_users'])) { |
|
| 138 | + echo ' |
|
| 136 | 139 | <li> |
| 137 | 140 | <strong class="smalltext">', $txt['mc_watched_users_none'], '</strong> |
| 138 | 141 | </li>'; |
| 142 | + } |
|
| 139 | 143 | |
| 140 | 144 | echo ' |
| 141 | 145 | </ul> |
@@ -193,18 +197,20 @@ discard block |
||
| 193 | 197 | <div class="modbox"> |
| 194 | 198 | <ul>'; |
| 195 | 199 | |
| 196 | - foreach ($context['reported_posts'] as $post) |
|
| 197 | - echo ' |
|
| 200 | + foreach ($context['reported_posts'] as $post) { |
|
| 201 | + echo ' |
|
| 198 | 202 | <li> |
| 199 | 203 | <span class="smalltext">', sprintf($txt['mc_post_report'], $post['report_link'], $post['author']['link']), '</span> |
| 200 | 204 | </li>'; |
| 205 | + } |
|
| 201 | 206 | |
| 202 | 207 | // Don't have any watched users right now? |
| 203 | - if (empty($context['reported_posts'])) |
|
| 204 | - echo ' |
|
| 208 | + if (empty($context['reported_posts'])) { |
|
| 209 | + echo ' |
|
| 205 | 210 | <li> |
| 206 | 211 | <strong class="smalltext">', $txt['mc_recent_reports_none'], '</strong> |
| 207 | 212 | </li>'; |
| 213 | + } |
|
| 208 | 214 | |
| 209 | 215 | echo ' |
| 210 | 216 | </ul> |
@@ -262,18 +268,20 @@ discard block |
||
| 262 | 268 | <div class="modbox"> |
| 263 | 269 | <ul>'; |
| 264 | 270 | |
| 265 | - foreach ($context['reported_users'] as $user) |
|
| 266 | - echo ' |
|
| 271 | + foreach ($context['reported_users'] as $user) { |
|
| 272 | + echo ' |
|
| 267 | 273 | <li> |
| 268 | 274 | <span class="smalltext">', $user['user']['link'], '</span> |
| 269 | 275 | </li>'; |
| 276 | + } |
|
| 270 | 277 | |
| 271 | 278 | // Don't have any watched users right now? |
| 272 | - if (empty($context['reported_users'])) |
|
| 273 | - echo ' |
|
| 279 | + if (empty($context['reported_users'])) { |
|
| 280 | + echo ' |
|
| 274 | 281 | <li> |
| 275 | 282 | <strong class="smalltext">', $txt['mc_reported_users_none'], '</strong> |
| 276 | 283 | </li>'; |
| 284 | + } |
|
| 277 | 285 | |
| 278 | 286 | echo ' |
| 279 | 287 | </ul> |
@@ -321,11 +329,12 @@ discard block |
||
| 321 | 329 | global $context, $txt, $scripturl; |
| 322 | 330 | |
| 323 | 331 | // Let them know the action was a success. |
| 324 | - if (!empty($context['report_post_action'])) |
|
| 325 | - echo ' |
|
| 332 | + if (!empty($context['report_post_action'])) { |
|
| 333 | + echo ' |
|
| 326 | 334 | <div class="infobox"> |
| 327 | 335 | ', $txt['report_action_' . $context['report_post_action']], ' |
| 328 | 336 | </div>'; |
| 337 | + } |
|
| 329 | 338 | |
| 330 | 339 | echo ' |
| 331 | 340 | <div class="modnotes"> |
@@ -342,11 +351,12 @@ discard block |
||
| 342 | 351 | <ul class="moderation_notes">'; |
| 343 | 352 | |
| 344 | 353 | // Cycle through the notes. |
| 345 | - foreach ($context['notes'] as $note) |
|
| 346 | - echo ' |
|
| 354 | + foreach ($context['notes'] as $note) { |
|
| 355 | + echo ' |
|
| 347 | 356 | <li class="smalltext"> |
| 348 | 357 | ', ($note['can_delete'] ? '<a href="' . $note['delete_href'] . ';' . $context['mod-modnote-del_token_var'] . '=' . $context['mod-modnote-del_token'] . '" data-confirm="' . $txt['mc_reportedp_delete_confirm'] . '" class="you_sure"><span class="generic_icons delete"></span></a>' : ''), $note['time'], ' <strong>', $note['author']['link'], ':</strong> ', $note['text'], ' |
| 349 | 358 | </li>'; |
| 359 | + } |
|
| 350 | 360 | |
| 351 | 361 | echo ' |
| 352 | 362 | </ul> |
@@ -388,18 +398,19 @@ discard block |
||
| 388 | 398 | $remove_button = create_button('delete', 'remove_message', 'remove'); |
| 389 | 399 | |
| 390 | 400 | // No posts? |
| 391 | - if (empty($context['unapproved_items'])) |
|
| 392 | - echo ' |
|
| 401 | + if (empty($context['unapproved_items'])) { |
|
| 402 | + echo ' |
|
| 393 | 403 | <div class="windowbg2"> |
| 394 | 404 | <p class="centertext"> |
| 395 | 405 | ', $txt['mc_unapproved_' . $context['current_view'] . '_none_found'], ' |
| 396 | 406 | </p> |
| 397 | 407 | </div>'; |
| 398 | - else |
|
| 399 | - echo ' |
|
| 408 | + } else { |
|
| 409 | + echo ' |
|
| 400 | 410 | <div class="pagesection floatleft"> |
| 401 | 411 | ', $context['page_index'], ' |
| 402 | 412 | </div>'; |
| 413 | + } |
|
| 403 | 414 | |
| 404 | 415 | foreach ($context['unapproved_items'] as $item) |
| 405 | 416 | { |
@@ -418,14 +429,16 @@ discard block |
||
| 418 | 429 | <span class="floatright"> |
| 419 | 430 | <a href="', $scripturl, '?action=moderate;area=postmod;sa=', $context['current_view'], ';start=', $context['start'], ';', $context['session_var'], '=', $context['session_id'], ';approve=', $item['id'], '">', $approve_button, '</a>'; |
| 420 | 431 | |
| 421 | - if ($item['can_delete']) |
|
| 422 | - echo ' |
|
| 432 | + if ($item['can_delete']) { |
|
| 433 | + echo ' |
|
| 423 | 434 | ', $context['menu_separator'], ' |
| 424 | 435 | <a href="', $scripturl, '?action=moderate;area=postmod;sa=', $context['current_view'], ';start=', $context['start'], ';', $context['session_var'], '=', $context['session_id'], ';delete=', $item['id'], '">', $remove_button, '</a>'; |
| 436 | + } |
|
| 425 | 437 | |
| 426 | - if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1) |
|
| 427 | - echo ' |
|
| 438 | + if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1) { |
|
| 439 | + echo ' |
|
| 428 | 440 | <input type="checkbox" name="item[]" value="', $item['id'], '" checked> '; |
| 441 | + } |
|
| 429 | 442 | |
| 430 | 443 | echo ' |
| 431 | 444 | </span> |
@@ -435,8 +448,8 @@ discard block |
||
| 435 | 448 | echo ' |
| 436 | 449 | <div class="pagesection">'; |
| 437 | 450 | |
| 438 | - if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1) |
|
| 439 | - echo ' |
|
| 451 | + if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1) { |
|
| 452 | + echo ' |
|
| 440 | 453 | <div class="floatright"> |
| 441 | 454 | <select name="do" onchange="if (this.value != 0 && confirm(\'', $txt['mc_unapproved_sure'], '\')) submit();"> |
| 442 | 455 | <option value="0">', $txt['with_selected'], ':</option> |
@@ -448,12 +461,14 @@ discard block |
||
| 448 | 461 | <input type="submit" name="mc_go" value="', $txt['go'], '" class="button"> |
| 449 | 462 | </noscript> |
| 450 | 463 | </div>'; |
| 464 | + } |
|
| 451 | 465 | |
| 452 | - if (!empty($context['unapproved_items'])) |
|
| 453 | - echo ' |
|
| 466 | + if (!empty($context['unapproved_items'])) { |
|
| 467 | + echo ' |
|
| 454 | 468 | <div class="floatleft"> |
| 455 | 469 | <div class="pagelinks">', $context['page_index'], '</div> |
| 456 | 470 | </div>'; |
| 471 | + } |
|
| 457 | 472 | |
| 458 | 473 | echo ' |
| 459 | 474 | </div><!-- .pagesection --> |
@@ -473,8 +488,9 @@ discard block |
||
| 473 | 488 | global $scripturl, $context, $txt, $delete_button; |
| 474 | 489 | |
| 475 | 490 | // We'll have a delete please bob. |
| 476 | - if (empty($delete_button)) |
|
| 477 | - $delete_button = create_button('delete', 'remove_message', 'remove', 'class="centericon"'); |
|
| 491 | + if (empty($delete_button)) { |
|
| 492 | + $delete_button = create_button('delete', 'remove_message', 'remove', 'class="centericon"'); |
|
| 493 | + } |
|
| 478 | 494 | |
| 479 | 495 | $output_html = ' |
| 480 | 496 | <div> |
@@ -483,10 +499,11 @@ discard block |
||
| 483 | 499 | </div> |
| 484 | 500 | <div class="floatright">'; |
| 485 | 501 | |
| 486 | - if ($post['can_delete']) |
|
| 487 | - $output_html .= ' |
|
| 502 | + if ($post['can_delete']) { |
|
| 503 | + $output_html .= ' |
|
| 488 | 504 | <a href="' . $scripturl . '?action=moderate;area=userwatch;sa=post;delete=' . $post['id'] . ';start=' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id'] . '" data-confirm="' . $txt['mc_watched_users_delete_post'] . '" class="you_sure">' . $delete_button . '</a> |
| 489 | 505 | <input type="checkbox" name="delete[]" value="' . $post['id'] . '">'; |
| 506 | + } |
|
| 490 | 507 | |
| 491 | 508 | $output_html .= ' |
| 492 | 509 | </div> |
@@ -529,12 +546,12 @@ discard block |
||
| 529 | 546 | <input type="submit" name="save" value="', $txt['save'], '" class="button"> |
| 530 | 547 | </div> |
| 531 | 548 | </form>'; |
| 532 | - } |
|
| 533 | - else |
|
| 534 | - echo ' |
|
| 549 | + } else { |
|
| 550 | + echo ' |
|
| 535 | 551 | <div class="windowbg"> |
| 536 | 552 | <div class="centertext">', $txt['mc_no_settings'], '</div> |
| 537 | 553 | </div>'; |
| 554 | + } |
|
| 538 | 555 | |
| 539 | 556 | echo ' |
| 540 | 557 | </div><!-- #modcenter -->'; |
@@ -630,13 +647,14 @@ discard block |
||
| 630 | 647 | </dd> |
| 631 | 648 | </dl>'; |
| 632 | 649 | |
| 633 | - if ($context['template_data']['can_edit_personal']) |
|
| 634 | - echo ' |
|
| 650 | + if ($context['template_data']['can_edit_personal']) { |
|
| 651 | + echo ' |
|
| 635 | 652 | <input type="checkbox" name="make_personal" id="make_personal"', $context['template_data']['personal'] ? ' checked' : '', '> |
| 636 | 653 | <label for="make_personal"> |
| 637 | 654 | <strong>', $txt['mc_warning_template_personal'], '</strong> |
| 638 | 655 | </label><br> |
| 639 | 656 | <span class="smalltext">', $txt['mc_warning_template_personal_desc'], '</span><br>'; |
| 657 | + } |
|
| 640 | 658 | |
| 641 | 659 | echo ' |
| 642 | 660 | <hr> |
@@ -26,9 +26,10 @@ discard block |
||
| 26 | 26 | </h3> |
| 27 | 27 | </div>'; |
| 28 | 28 | |
| 29 | - if ($context['ban']['is_new']) |
|
| 30 | - echo ' |
|
| 29 | + if ($context['ban']['is_new']) { |
|
| 30 | + echo ' |
|
| 31 | 31 | <div class="information noup">', $txt['ban_add_notes'], '</div>'; |
| 32 | + } |
|
| 32 | 33 | |
| 33 | 34 | // If there were errors creating the ban, show them. |
| 34 | 35 | if (!empty($context['error_messages'])) |
@@ -38,9 +39,10 @@ discard block |
||
| 38 | 39 | <strong>', $txt['ban_errors_detected'], '</strong> |
| 39 | 40 | <ul>'; |
| 40 | 41 | |
| 41 | - foreach ($context['error_messages'] as $error) |
|
| 42 | - echo ' |
|
| 42 | + foreach ($context['error_messages'] as $error) { |
|
| 43 | + echo ' |
|
| 43 | 44 | <li class="error">', $error, '</li>'; |
| 45 | + } |
|
| 44 | 46 | |
| 45 | 47 | echo ' |
| 46 | 48 | </ul> |
@@ -57,8 +59,8 @@ discard block |
||
| 57 | 59 | <input type="text" id="ban_name" name="ban_name" value="', $context['ban']['name'], '" size="45" maxlength="60"> |
| 58 | 60 | </dd>'; |
| 59 | 61 | |
| 60 | - if (isset($context['ban']['reason'])) |
|
| 61 | - echo ' |
|
| 62 | + if (isset($context['ban']['reason'])) { |
|
| 63 | + echo ' |
|
| 62 | 64 | <dt> |
| 63 | 65 | <strong><label for="reason">', $txt['ban_reason'], ':</label></strong><br> |
| 64 | 66 | <span class="smalltext">', $txt['ban_reason_desc'], '</span> |
@@ -66,9 +68,10 @@ discard block |
||
| 66 | 68 | <dd> |
| 67 | 69 | <textarea name="reason" id="reason" cols="40" rows="3">', $context['ban']['reason'], '</textarea> |
| 68 | 70 | </dd>'; |
| 71 | + } |
|
| 69 | 72 | |
| 70 | - if (isset($context['ban']['notes'])) |
|
| 71 | - echo ' |
|
| 73 | + if (isset($context['ban']['notes'])) { |
|
| 74 | + echo ' |
|
| 72 | 75 | <dt> |
| 73 | 76 | <strong><label for="ban_notes">', $txt['ban_notes'], ':</label></strong><br> |
| 74 | 77 | <span class="smalltext">', $txt['ban_notes_desc'], '</span> |
@@ -76,6 +79,7 @@ discard block |
||
| 76 | 79 | <dd> |
| 77 | 80 | <textarea name="notes" id="ban_notes" cols="40" rows="3">', $context['ban']['notes'], '</textarea> |
| 78 | 81 | </dd>'; |
| 82 | + } |
|
| 79 | 83 | |
| 80 | 84 | echo ' |
| 81 | 85 | </dl> |
@@ -115,8 +119,8 @@ discard block |
||
| 115 | 119 | <input type="text" name="main_ip" value="', $context['ban_suggestions']['main_ip'], '" size="44" onfocus="document.getElementById(\'main_ip_check\').checked = true;"> |
| 116 | 120 | </dd>'; |
| 117 | 121 | |
| 118 | - if (empty($modSettings['disableHostnameLookup'])) |
|
| 119 | - echo ' |
|
| 122 | + if (empty($modSettings['disableHostnameLookup'])) { |
|
| 123 | + echo ' |
|
| 120 | 124 | <dt> |
| 121 | 125 | <input type="checkbox" name="ban_suggestions[]" id="hostname_check" value="hostname"', !empty($context['ban_suggestions']['hostname']) ? ' checked' : '', '> |
| 122 | 126 | <label for="hostname_check">', $txt['ban_on_hostname'], '</label> |
@@ -124,6 +128,7 @@ discard block |
||
| 124 | 128 | <dd> |
| 125 | 129 | <input type="text" name="hostname" value="', $context['ban_suggestions']['hostname'], '" size="44" onfocus="document.getElementById(\'hostname_check\').checked = true;"> |
| 126 | 130 | </dd>'; |
| 131 | + } |
|
| 127 | 132 | |
| 128 | 133 | echo ' |
| 129 | 134 | <dt> |
@@ -153,14 +158,15 @@ discard block |
||
| 153 | 158 | <dl class="settings">'; |
| 154 | 159 | |
| 155 | 160 | $count = 0; |
| 156 | - foreach ($ban_ips as $ip) |
|
| 157 | - echo ' |
|
| 161 | + foreach ($ban_ips as $ip) { |
|
| 162 | + echo ' |
|
| 158 | 163 | <dt> |
| 159 | 164 | <input type="checkbox" id="suggestions_', $key, '_', $count, '" name="ban_suggestions[', $key, '][]"', !empty($context['ban_suggestions']['saved_triggers'][$key]) && in_array($ip, $context['ban_suggestions']['saved_triggers'][$key]) ? ' checked' : '', ' value="', $ip, '"> |
| 160 | 165 | </dt> |
| 161 | 166 | <dd> |
| 162 | 167 | <label for="suggestions_', $key, '_', $count++, '">', $ip, '</label> |
| 163 | 168 | </dd>'; |
| 169 | + } |
|
| 164 | 170 | |
| 165 | 171 | echo ' |
| 166 | 172 | </dl>'; |
@@ -202,8 +208,8 @@ discard block |
||
| 202 | 208 | addLoadEvent(fUpdateStatus);'; |
| 203 | 209 | |
| 204 | 210 | // Auto suggest only needed for adding new bans, not editing |
| 205 | - if ($context['ban']['is_new'] && empty($_REQUEST['u'])) |
|
| 206 | - echo ' |
|
| 211 | + if ($context['ban']['is_new'] && empty($_REQUEST['u'])) { |
|
| 212 | + echo ' |
|
| 207 | 213 | var oAddMemberSuggest = new smc_AutoSuggest({ |
| 208 | 214 | sSelf: \'oAddMemberSuggest\', |
| 209 | 215 | sSessionId: smf_session_id, |
@@ -221,6 +227,7 @@ discard block |
||
| 221 | 227 | return true; |
| 222 | 228 | } |
| 223 | 229 | oAddMemberSuggest.registerCallback(\'onBeforeUpdate\', \'onUpdateName\');'; |
| 230 | + } |
|
| 224 | 231 | |
| 225 | 232 | echo ' |
| 226 | 233 | function confirmBan(aForm) |
@@ -269,8 +276,8 @@ discard block |
||
| 269 | 276 | <input type="text" name="main_ip" value="', $context['ban_trigger']['ip']['value'], '" size="44" onfocus="document.getElementById(\'main_ip_check\').checked = true;"> |
| 270 | 277 | </dd>'; |
| 271 | 278 | |
| 272 | - if (empty($modSettings['disableHostnameLookup'])) |
|
| 273 | - echo ' |
|
| 279 | + if (empty($modSettings['disableHostnameLookup'])) { |
|
| 280 | + echo ' |
|
| 274 | 281 | <dt> |
| 275 | 282 | <input type="checkbox" name="ban_suggestions[]" id="hostname_check" value="hostname"', $context['ban_trigger']['hostname']['selected'] ? ' checked' : '', '> |
| 276 | 283 | <label for="hostname_check">', $txt['ban_on_hostname'], '</label> |
@@ -278,6 +285,7 @@ discard block |
||
| 278 | 285 | <dd> |
| 279 | 286 | <input type="text" name="hostname" value="', $context['ban_trigger']['hostname']['value'], '" size="44" onfocus="document.getElementById(\'hostname_check\').checked = true;"> |
| 280 | 287 | </dd>'; |
| 288 | + } |
|
| 281 | 289 | |
| 282 | 290 | echo ' |
| 283 | 291 | <dt> |