@@ -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) |
@@ -33,8 +34,8 @@ discard block |
||
| 33 | 34 | global $smcFunc; |
| 34 | 35 | |
| 35 | 36 | // Map some database specific functions, only do this once. |
| 36 | - if (!isset($smcFunc['db_fetch_assoc'])) |
|
| 37 | - $smcFunc += array( |
|
| 37 | + if (!isset($smcFunc['db_fetch_assoc'])) { |
|
| 38 | + $smcFunc += array( |
|
| 38 | 39 | 'db_query' => 'smf_db_query', |
| 39 | 40 | 'db_quote' => 'smf_db_quote', |
| 40 | 41 | 'db_fetch_assoc' => 'mysqli_fetch_assoc', |
@@ -62,9 +63,11 @@ discard block |
||
| 62 | 63 | 'db_fetch_all' => 'smf_db_fetch_all', |
| 63 | 64 | 'db_error_insert' => 'smf_db_error_insert', |
| 64 | 65 | ); |
| 66 | + } |
|
| 65 | 67 | |
| 66 | - if (!empty($db_options['persist'])) |
|
| 67 | - $db_server = 'p:' . $db_server; |
|
| 68 | + if (!empty($db_options['persist'])) { |
|
| 69 | + $db_server = 'p:' . $db_server; |
|
| 70 | + } |
|
| 68 | 71 | |
| 69 | 72 | $connection = mysqli_init(); |
| 70 | 73 | |
@@ -73,24 +76,27 @@ discard block |
||
| 73 | 76 | $success = false; |
| 74 | 77 | |
| 75 | 78 | if ($connection) { |
| 76 | - if (!empty($db_options['port'])) |
|
| 77 | - $success = mysqli_real_connect($connection, $db_server, $db_user, $db_passwd, '', $db_options['port'], null, $flags); |
|
| 78 | - else |
|
| 79 | - $success = mysqli_real_connect($connection, $db_server, $db_user, $db_passwd, '', 0, null, $flags); |
|
| 79 | + if (!empty($db_options['port'])) { |
|
| 80 | + $success = mysqli_real_connect($connection, $db_server, $db_user, $db_passwd, '', $db_options['port'], null, $flags); |
|
| 81 | + } else { |
|
| 82 | + $success = mysqli_real_connect($connection, $db_server, $db_user, $db_passwd, '', 0, null, $flags); |
|
| 83 | + } |
|
| 80 | 84 | } |
| 81 | 85 | |
| 82 | 86 | // Something's wrong, show an error if its fatal (which we assume it is) |
| 83 | 87 | if ($success === false) |
| 84 | 88 | { |
| 85 | - if (!empty($db_options['non_fatal'])) |
|
| 86 | - return null; |
|
| 87 | - else |
|
| 88 | - display_db_error(); |
|
| 89 | + if (!empty($db_options['non_fatal'])) { |
|
| 90 | + return null; |
|
| 91 | + } else { |
|
| 92 | + display_db_error(); |
|
| 93 | + } |
|
| 89 | 94 | } |
| 90 | 95 | |
| 91 | 96 | // Select the database, unless told not to |
| 92 | - if (empty($db_options['dont_select_db']) && !@mysqli_select_db($connection, $db_name) && empty($db_options['non_fatal'])) |
|
| 93 | - display_db_error(); |
|
| 97 | + if (empty($db_options['dont_select_db']) && !@mysqli_select_db($connection, $db_name) && empty($db_options['non_fatal'])) { |
|
| 98 | + display_db_error(); |
|
| 99 | + } |
|
| 94 | 100 | |
| 95 | 101 | $smcFunc['db_query']('', 'SET SESSION sql_mode = \'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION\'', |
| 96 | 102 | array(), |
@@ -166,34 +172,42 @@ discard block |
||
| 166 | 172 | global $db_callback, $user_info, $db_prefix, $smcFunc; |
| 167 | 173 | |
| 168 | 174 | list ($values, $connection) = $db_callback; |
| 169 | - if (!is_object($connection)) |
|
| 170 | - display_db_error(); |
|
| 175 | + if (!is_object($connection)) { |
|
| 176 | + display_db_error(); |
|
| 177 | + } |
|
| 171 | 178 | |
| 172 | - if ($matches[1] === 'db_prefix') |
|
| 173 | - return $db_prefix; |
|
| 179 | + if ($matches[1] === 'db_prefix') { |
|
| 180 | + return $db_prefix; |
|
| 181 | + } |
|
| 174 | 182 | |
| 175 | - if (isset($user_info[$matches[1]]) && strpos($matches[1], 'query_') !== false) |
|
| 176 | - return $user_info[$matches[1]]; |
|
| 183 | + if (isset($user_info[$matches[1]]) && strpos($matches[1], 'query_') !== false) { |
|
| 184 | + return $user_info[$matches[1]]; |
|
| 185 | + } |
|
| 177 | 186 | |
| 178 | - if ($matches[1] === 'empty') |
|
| 179 | - return '\'\''; |
|
| 187 | + if ($matches[1] === 'empty') { |
|
| 188 | + return '\'\''; |
|
| 189 | + } |
|
| 180 | 190 | |
| 181 | - if (!isset($matches[2])) |
|
| 182 | - smf_db_error_backtrace('Invalid value inserted or no type specified.', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 191 | + if (!isset($matches[2])) { |
|
| 192 | + smf_db_error_backtrace('Invalid value inserted or no type specified.', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 193 | + } |
|
| 183 | 194 | |
| 184 | - if ($matches[1] === 'literal') |
|
| 185 | - return '\'' . mysqli_real_escape_string($connection, $matches[2]) . '\''; |
|
| 195 | + if ($matches[1] === 'literal') { |
|
| 196 | + return '\'' . mysqli_real_escape_string($connection, $matches[2]) . '\''; |
|
| 197 | + } |
|
| 186 | 198 | |
| 187 | - if (!isset($values[$matches[2]])) |
|
| 188 | - 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__); |
|
| 199 | + if (!isset($values[$matches[2]])) { |
|
| 200 | + 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__); |
|
| 201 | + } |
|
| 189 | 202 | |
| 190 | 203 | $replacement = $values[$matches[2]]; |
| 191 | 204 | |
| 192 | 205 | switch ($matches[1]) |
| 193 | 206 | { |
| 194 | 207 | case 'int': |
| 195 | - if (!is_numeric($replacement) || (string) $replacement !== (string) (int) $replacement) |
|
| 196 | - smf_db_error_backtrace('Wrong value type sent to the database. Integer expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 208 | + if (!is_numeric($replacement) || (string) $replacement !== (string) (int) $replacement) { |
|
| 209 | + smf_db_error_backtrace('Wrong value type sent to the database. Integer expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 210 | + } |
|
| 197 | 211 | return (string) (int) $replacement; |
| 198 | 212 | break; |
| 199 | 213 | |
@@ -205,65 +219,73 @@ discard block |
||
| 205 | 219 | case 'array_int': |
| 206 | 220 | if (is_array($replacement)) |
| 207 | 221 | { |
| 208 | - if (empty($replacement)) |
|
| 209 | - smf_db_error_backtrace('Database error, given array of integer values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 222 | + if (empty($replacement)) { |
|
| 223 | + smf_db_error_backtrace('Database error, given array of integer values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 224 | + } |
|
| 210 | 225 | |
| 211 | 226 | foreach ($replacement as $key => $value) |
| 212 | 227 | { |
| 213 | - if (!is_numeric($value) || (string) $value !== (string) (int) $value) |
|
| 214 | - smf_db_error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 228 | + if (!is_numeric($value) || (string) $value !== (string) (int) $value) { |
|
| 229 | + smf_db_error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 230 | + } |
|
| 215 | 231 | |
| 216 | 232 | $replacement[$key] = (string) (int) $value; |
| 217 | 233 | } |
| 218 | 234 | |
| 219 | 235 | return implode(', ', $replacement); |
| 236 | + } else { |
|
| 237 | + smf_db_error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 220 | 238 | } |
| 221 | - else |
|
| 222 | - smf_db_error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 223 | 239 | |
| 224 | 240 | break; |
| 225 | 241 | |
| 226 | 242 | case 'array_string': |
| 227 | 243 | if (is_array($replacement)) |
| 228 | 244 | { |
| 229 | - if (empty($replacement)) |
|
| 230 | - smf_db_error_backtrace('Database error, given array of string values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 245 | + if (empty($replacement)) { |
|
| 246 | + smf_db_error_backtrace('Database error, given array of string values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 247 | + } |
|
| 231 | 248 | |
| 232 | - foreach ($replacement as $key => $value) |
|
| 233 | - $replacement[$key] = sprintf('\'%1$s\'', mysqli_real_escape_string($connection, $value)); |
|
| 249 | + foreach ($replacement as $key => $value) { |
|
| 250 | + $replacement[$key] = sprintf('\'%1$s\'', mysqli_real_escape_string($connection, $value)); |
|
| 251 | + } |
|
| 234 | 252 | |
| 235 | 253 | return implode(', ', $replacement); |
| 254 | + } else { |
|
| 255 | + smf_db_error_backtrace('Wrong value type sent to the database. Array of strings expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 236 | 256 | } |
| 237 | - else |
|
| 238 | - smf_db_error_backtrace('Wrong value type sent to the database. Array of strings expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 239 | 257 | break; |
| 240 | 258 | |
| 241 | 259 | case 'date': |
| 242 | - if (preg_match('~^(\d{4})-([0-1]?\d)-([0-3]?\d)$~', $replacement, $date_matches) === 1) |
|
| 243 | - return sprintf('\'%04d-%02d-%02d\'', $date_matches[1], $date_matches[2], $date_matches[3]); |
|
| 244 | - else |
|
| 245 | - smf_db_error_backtrace('Wrong value type sent to the database. Date expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 260 | + if (preg_match('~^(\d{4})-([0-1]?\d)-([0-3]?\d)$~', $replacement, $date_matches) === 1) { |
|
| 261 | + return sprintf('\'%04d-%02d-%02d\'', $date_matches[1], $date_matches[2], $date_matches[3]); |
|
| 262 | + } else { |
|
| 263 | + smf_db_error_backtrace('Wrong value type sent to the database. Date expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 264 | + } |
|
| 246 | 265 | break; |
| 247 | 266 | |
| 248 | 267 | case 'time': |
| 249 | - if (preg_match('~^([0-1]?\d|2[0-3]):([0-5]\d):([0-5]\d)$~', $replacement, $time_matches) === 1) |
|
| 250 | - return sprintf('\'%02d:%02d:%02d\'', $time_matches[1], $time_matches[2], $time_matches[3]); |
|
| 251 | - else |
|
| 252 | - smf_db_error_backtrace('Wrong value type sent to the database. Time expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 268 | + if (preg_match('~^([0-1]?\d|2[0-3]):([0-5]\d):([0-5]\d)$~', $replacement, $time_matches) === 1) { |
|
| 269 | + return sprintf('\'%02d:%02d:%02d\'', $time_matches[1], $time_matches[2], $time_matches[3]); |
|
| 270 | + } else { |
|
| 271 | + smf_db_error_backtrace('Wrong value type sent to the database. Time expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 272 | + } |
|
| 253 | 273 | break; |
| 254 | 274 | |
| 255 | 275 | case 'datetime': |
| 256 | - 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) |
|
| 257 | - return 'str_to_date('. |
|
| 276 | + 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) { |
|
| 277 | + return 'str_to_date('. |
|
| 258 | 278 | 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]). |
| 259 | 279 | ',\'%Y-%m-%d %h:%i:%s\')'; |
| 260 | - else |
|
| 261 | - smf_db_error_backtrace('Wrong value type sent to the database. Datetime expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 280 | + } else { |
|
| 281 | + smf_db_error_backtrace('Wrong value type sent to the database. Datetime expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 282 | + } |
|
| 262 | 283 | break; |
| 263 | 284 | |
| 264 | 285 | case 'float': |
| 265 | - if (!is_numeric($replacement)) |
|
| 266 | - smf_db_error_backtrace('Wrong value type sent to the database. Floating point number expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 286 | + if (!is_numeric($replacement)) { |
|
| 287 | + smf_db_error_backtrace('Wrong value type sent to the database. Floating point number expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 288 | + } |
|
| 267 | 289 | return (string) (float) $replacement; |
| 268 | 290 | break; |
| 269 | 291 | |
@@ -277,32 +299,37 @@ discard block |
||
| 277 | 299 | break; |
| 278 | 300 | |
| 279 | 301 | case 'inet': |
| 280 | - if ($replacement == 'null' || $replacement == '') |
|
| 281 | - return 'null'; |
|
| 282 | - if (!isValidIP($replacement)) |
|
| 283 | - smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 302 | + if ($replacement == 'null' || $replacement == '') { |
|
| 303 | + return 'null'; |
|
| 304 | + } |
|
| 305 | + if (!isValidIP($replacement)) { |
|
| 306 | + smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 307 | + } |
|
| 284 | 308 | //we don't use the native support of mysql > 5.6.2 |
| 285 | 309 | return sprintf('unhex(\'%1$s\')', bin2hex(inet_pton($replacement))); |
| 286 | 310 | |
| 287 | 311 | case 'array_inet': |
| 288 | 312 | if (is_array($replacement)) |
| 289 | 313 | { |
| 290 | - if (empty($replacement)) |
|
| 291 | - smf_db_error_backtrace('Database error, given array of IPv4 or IPv6 values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 314 | + if (empty($replacement)) { |
|
| 315 | + smf_db_error_backtrace('Database error, given array of IPv4 or IPv6 values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 316 | + } |
|
| 292 | 317 | |
| 293 | 318 | foreach ($replacement as $key => $value) |
| 294 | 319 | { |
| 295 | - if ($replacement == 'null' || $replacement == '') |
|
| 296 | - $replacement[$key] = 'null'; |
|
| 297 | - if (!isValidIP($value)) |
|
| 298 | - smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 320 | + if ($replacement == 'null' || $replacement == '') { |
|
| 321 | + $replacement[$key] = 'null'; |
|
| 322 | + } |
|
| 323 | + if (!isValidIP($value)) { |
|
| 324 | + smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 325 | + } |
|
| 299 | 326 | $replacement[$key] = sprintf('unhex(\'%1$s\')', bin2hex(inet_pton($value))); |
| 300 | 327 | } |
| 301 | 328 | |
| 302 | 329 | return implode(', ', $replacement); |
| 330 | + } else { |
|
| 331 | + smf_db_error_backtrace('Wrong value type sent to the database. Array of IPv4 or IPv6 expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 303 | 332 | } |
| 304 | - else |
|
| 305 | - smf_db_error_backtrace('Wrong value type sent to the database. Array of IPv4 or IPv6 expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 306 | 333 | break; |
| 307 | 334 | |
| 308 | 335 | default: |
@@ -378,22 +405,25 @@ discard block |
||
| 378 | 405 | // Are we in SSI mode? If so try that username and password first |
| 379 | 406 | if (SMF == 'SSI' && !empty($ssi_db_user) && !empty($ssi_db_passwd)) |
| 380 | 407 | { |
| 381 | - if (empty($db_persist)) |
|
| 382 | - $db_connection = @mysqli_connect($db_server, $ssi_db_user, $ssi_db_passwd); |
|
| 383 | - else |
|
| 384 | - $db_connection = @mysqli_connect('p:' . $db_server, $ssi_db_user, $ssi_db_passwd); |
|
| 408 | + if (empty($db_persist)) { |
|
| 409 | + $db_connection = @mysqli_connect($db_server, $ssi_db_user, $ssi_db_passwd); |
|
| 410 | + } else { |
|
| 411 | + $db_connection = @mysqli_connect('p:' . $db_server, $ssi_db_user, $ssi_db_passwd); |
|
| 412 | + } |
|
| 385 | 413 | } |
| 386 | 414 | // Fall back to the regular username and password if need be |
| 387 | 415 | if (!$db_connection) |
| 388 | 416 | { |
| 389 | - if (empty($db_persist)) |
|
| 390 | - $db_connection = @mysqli_connect($db_server, $db_user, $db_passwd); |
|
| 391 | - else |
|
| 392 | - $db_connection = @mysqli_connect('p:' . $db_server, $db_user, $db_passwd); |
|
| 417 | + if (empty($db_persist)) { |
|
| 418 | + $db_connection = @mysqli_connect($db_server, $db_user, $db_passwd); |
|
| 419 | + } else { |
|
| 420 | + $db_connection = @mysqli_connect('p:' . $db_server, $db_user, $db_passwd); |
|
| 421 | + } |
|
| 393 | 422 | } |
| 394 | 423 | |
| 395 | - if (!$db_connection || !@mysqli_select_db($db_connection, $db_name)) |
|
| 396 | - $db_connection = false; |
|
| 424 | + if (!$db_connection || !@mysqli_select_db($db_connection, $db_name)) { |
|
| 425 | + $db_connection = false; |
|
| 426 | + } |
|
| 397 | 427 | |
| 398 | 428 | $connection = $db_connection; |
| 399 | 429 | } |
@@ -401,18 +431,20 @@ discard block |
||
| 401 | 431 | // One more query.... |
| 402 | 432 | $db_count = !isset($db_count) ? 1 : $db_count + 1; |
| 403 | 433 | |
| 404 | - if (empty($modSettings['disableQueryCheck']) && strpos($db_string, '\'') !== false && empty($db_values['security_override'])) |
|
| 405 | - smf_db_error_backtrace('Hacking attempt...', 'Illegal character (\') used in query...', true, __FILE__, __LINE__); |
|
| 434 | + if (empty($modSettings['disableQueryCheck']) && strpos($db_string, '\'') !== false && empty($db_values['security_override'])) { |
|
| 435 | + smf_db_error_backtrace('Hacking attempt...', 'Illegal character (\') used in query...', true, __FILE__, __LINE__); |
|
| 436 | + } |
|
| 406 | 437 | |
| 407 | 438 | // Use "ORDER BY null" to prevent Mysql doing filesorts for Group By clauses without an Order By |
| 408 | 439 | if (strpos($db_string, 'GROUP BY') !== false && strpos($db_string, 'ORDER BY') === false && preg_match('~^\s+SELECT~i', $db_string)) |
| 409 | 440 | { |
| 410 | 441 | // Add before LIMIT |
| 411 | - if ($pos = strpos($db_string, 'LIMIT ')) |
|
| 412 | - $db_string = substr($db_string, 0, $pos) . "\t\t\tORDER BY null\n" . substr($db_string, $pos, strlen($db_string)); |
|
| 413 | - else |
|
| 414 | - // Append it. |
|
| 442 | + if ($pos = strpos($db_string, 'LIMIT ')) { |
|
| 443 | + $db_string = substr($db_string, 0, $pos) . "\t\t\tORDER BY null\n" . substr($db_string, $pos, strlen($db_string)); |
|
| 444 | + } else { |
|
| 445 | + // Append it. |
|
| 415 | 446 | $db_string .= "\n\t\t\tORDER BY null"; |
| 447 | + } |
|
| 416 | 448 | } |
| 417 | 449 | |
| 418 | 450 | if (empty($db_values['security_override']) && (!empty($db_values) || strpos($db_string, '{db_prefix}') !== false)) |
@@ -434,8 +466,9 @@ discard block |
||
| 434 | 466 | list ($file, $line) = smf_db_error_backtrace('', '', 'return', __FILE__, __LINE__); |
| 435 | 467 | |
| 436 | 468 | // Initialize $db_cache if not already initialized. |
| 437 | - if (!isset($db_cache)) |
|
| 438 | - $db_cache = array(); |
|
| 469 | + if (!isset($db_cache)) { |
|
| 470 | + $db_cache = array(); |
|
| 471 | + } |
|
| 439 | 472 | |
| 440 | 473 | if (!empty($_SESSION['debug_redirect'])) |
| 441 | 474 | { |
@@ -461,17 +494,18 @@ discard block |
||
| 461 | 494 | while (true) |
| 462 | 495 | { |
| 463 | 496 | $pos = strpos($db_string, '\'', $pos + 1); |
| 464 | - if ($pos === false) |
|
| 465 | - break; |
|
| 497 | + if ($pos === false) { |
|
| 498 | + break; |
|
| 499 | + } |
|
| 466 | 500 | $clean .= substr($db_string, $old_pos, $pos - $old_pos); |
| 467 | 501 | |
| 468 | 502 | while (true) |
| 469 | 503 | { |
| 470 | 504 | $pos1 = strpos($db_string, '\'', $pos + 1); |
| 471 | 505 | $pos2 = strpos($db_string, '\\', $pos + 1); |
| 472 | - if ($pos1 === false) |
|
| 473 | - break; |
|
| 474 | - elseif ($pos2 === false || $pos2 > $pos1) |
|
| 506 | + if ($pos1 === false) { |
|
| 507 | + break; |
|
| 508 | + } elseif ($pos2 === false || $pos2 > $pos1) |
|
| 475 | 509 | { |
| 476 | 510 | $pos = $pos1; |
| 477 | 511 | break; |
@@ -487,29 +521,35 @@ discard block |
||
| 487 | 521 | $clean = trim(strtolower(preg_replace($allowed_comments_from, $allowed_comments_to, $clean))); |
| 488 | 522 | |
| 489 | 523 | // Comments? We don't use comments in our queries, we leave 'em outside! |
| 490 | - if (strpos($clean, '/*') > 2 || strpos($clean, '--') !== false || strpos($clean, ';') !== false) |
|
| 491 | - $fail = true; |
|
| 524 | + if (strpos($clean, '/*') > 2 || strpos($clean, '--') !== false || strpos($clean, ';') !== false) { |
|
| 525 | + $fail = true; |
|
| 526 | + } |
|
| 492 | 527 | // Trying to change passwords, slow us down, or something? |
| 493 | - elseif (strpos($clean, 'sleep') !== false && preg_match('~(^|[^a-z])sleep($|[^[_a-z])~s', $clean) != 0) |
|
| 494 | - $fail = true; |
|
| 495 | - elseif (strpos($clean, 'benchmark') !== false && preg_match('~(^|[^a-z])benchmark($|[^[a-z])~s', $clean) != 0) |
|
| 496 | - $fail = true; |
|
| 528 | + elseif (strpos($clean, 'sleep') !== false && preg_match('~(^|[^a-z])sleep($|[^[_a-z])~s', $clean) != 0) { |
|
| 529 | + $fail = true; |
|
| 530 | + } elseif (strpos($clean, 'benchmark') !== false && preg_match('~(^|[^a-z])benchmark($|[^[a-z])~s', $clean) != 0) { |
|
| 531 | + $fail = true; |
|
| 532 | + } |
|
| 497 | 533 | |
| 498 | - if (!empty($fail) && function_exists('log_error')) |
|
| 499 | - smf_db_error_backtrace('Hacking attempt...', 'Hacking attempt...' . "\n" . $db_string, E_USER_ERROR, __FILE__, __LINE__); |
|
| 534 | + if (!empty($fail) && function_exists('log_error')) { |
|
| 535 | + smf_db_error_backtrace('Hacking attempt...', 'Hacking attempt...' . "\n" . $db_string, E_USER_ERROR, __FILE__, __LINE__); |
|
| 536 | + } |
|
| 500 | 537 | } |
| 501 | 538 | |
| 502 | - if (empty($db_unbuffered)) |
|
| 503 | - $ret = @mysqli_query($connection, $db_string); |
|
| 504 | - else |
|
| 505 | - $ret = @mysqli_query($connection, $db_string, MYSQLI_USE_RESULT); |
|
| 539 | + if (empty($db_unbuffered)) { |
|
| 540 | + $ret = @mysqli_query($connection, $db_string); |
|
| 541 | + } else { |
|
| 542 | + $ret = @mysqli_query($connection, $db_string, MYSQLI_USE_RESULT); |
|
| 543 | + } |
|
| 506 | 544 | |
| 507 | - if ($ret === false && empty($db_values['db_error_skip'])) |
|
| 508 | - $ret = smf_db_error($db_string, $connection); |
|
| 545 | + if ($ret === false && empty($db_values['db_error_skip'])) { |
|
| 546 | + $ret = smf_db_error($db_string, $connection); |
|
| 547 | + } |
|
| 509 | 548 | |
| 510 | 549 | // Debugging. |
| 511 | - if (isset($db_show_debug) && $db_show_debug === true) |
|
| 512 | - $db_cache[$db_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st)); |
|
| 550 | + if (isset($db_show_debug) && $db_show_debug === true) { |
|
| 551 | + $db_cache[$db_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st)); |
|
| 552 | + } |
|
| 513 | 553 | |
| 514 | 554 | return $ret; |
| 515 | 555 | } |
@@ -556,12 +596,13 @@ discard block |
||
| 556 | 596 | // Decide which connection to use |
| 557 | 597 | $connection = $connection === null ? $db_connection : $connection; |
| 558 | 598 | |
| 559 | - if ($type == 'begin') |
|
| 560 | - return @mysqli_query($connection, 'BEGIN'); |
|
| 561 | - elseif ($type == 'rollback') |
|
| 562 | - return @mysqli_query($connection, 'ROLLBACK'); |
|
| 563 | - elseif ($type == 'commit') |
|
| 564 | - return @mysqli_query($connection, 'COMMIT'); |
|
| 599 | + if ($type == 'begin') { |
|
| 600 | + return @mysqli_query($connection, 'BEGIN'); |
|
| 601 | + } elseif ($type == 'rollback') { |
|
| 602 | + return @mysqli_query($connection, 'ROLLBACK'); |
|
| 603 | + } elseif ($type == 'commit') { |
|
| 604 | + return @mysqli_query($connection, 'COMMIT'); |
|
| 605 | + } |
|
| 565 | 606 | |
| 566 | 607 | return false; |
| 567 | 608 | } |
@@ -601,8 +642,9 @@ discard block |
||
| 601 | 642 | // 2013: Lost connection to server during query. |
| 602 | 643 | |
| 603 | 644 | // Log the error. |
| 604 | - if ($query_errno != 1213 && $query_errno != 1205 && function_exists('log_error')) |
|
| 605 | - log_error($txt['database_error'] . ': ' . $query_error . (!empty($modSettings['enableErrorQueryLogging']) ? "\n\n$db_string" : ''), 'database', $file, $line); |
|
| 645 | + if ($query_errno != 1213 && $query_errno != 1205 && function_exists('log_error')) { |
|
| 646 | + log_error($txt['database_error'] . ': ' . $query_error . (!empty($modSettings['enableErrorQueryLogging']) ? "\n\n$db_string" : ''), 'database', $file, $line); |
|
| 647 | + } |
|
| 606 | 648 | |
| 607 | 649 | // Database error auto fixing ;). |
| 608 | 650 | if (function_exists('cache_get_data') && (!isset($modSettings['autoFixDatabase']) || $modSettings['autoFixDatabase'] == '1')) |
@@ -611,8 +653,9 @@ discard block |
||
| 611 | 653 | $old_cache = @$modSettings['cache_enable']; |
| 612 | 654 | $modSettings['cache_enable'] = '1'; |
| 613 | 655 | |
| 614 | - if (($temp = cache_get_data('db_last_error', 600)) !== null) |
|
| 615 | - $db_last_error = max(@$db_last_error, $temp); |
|
| 656 | + if (($temp = cache_get_data('db_last_error', 600)) !== null) { |
|
| 657 | + $db_last_error = max(@$db_last_error, $temp); |
|
| 658 | + } |
|
| 616 | 659 | |
| 617 | 660 | if (@$db_last_error < time() - 3600 * 24 * 3) |
| 618 | 661 | { |
@@ -628,8 +671,9 @@ discard block |
||
| 628 | 671 | foreach ($tables as $table) |
| 629 | 672 | { |
| 630 | 673 | // Now, it's still theoretically possible this could be an injection. So backtick it! |
| 631 | - if (trim($table) != '') |
|
| 632 | - $fix_tables[] = '`' . strtr(trim($table), array('`' => '')) . '`'; |
|
| 674 | + if (trim($table) != '') { |
|
| 675 | + $fix_tables[] = '`' . strtr(trim($table), array('`' => '')) . '`'; |
|
| 676 | + } |
|
| 633 | 677 | } |
| 634 | 678 | } |
| 635 | 679 | |
@@ -638,8 +682,9 @@ discard block |
||
| 638 | 682 | // Table crashed. Let's try to fix it. |
| 639 | 683 | elseif ($query_errno == 1016) |
| 640 | 684 | { |
| 641 | - if (preg_match('~\'([^\.\']+)~', $query_error, $match) != 0) |
|
| 642 | - $fix_tables = array('`' . $match[1] . '`'); |
|
| 685 | + if (preg_match('~\'([^\.\']+)~', $query_error, $match) != 0) { |
|
| 686 | + $fix_tables = array('`' . $match[1] . '`'); |
|
| 687 | + } |
|
| 643 | 688 | } |
| 644 | 689 | // Indexes crashed. Should be easy to fix! |
| 645 | 690 | elseif ($query_errno == 1034 || $query_errno == 1035) |
@@ -658,13 +703,15 @@ discard block |
||
| 658 | 703 | |
| 659 | 704 | // Make a note of the REPAIR... |
| 660 | 705 | cache_put_data('db_last_error', time(), 600); |
| 661 | - if (($temp = cache_get_data('db_last_error', 600)) === null) |
|
| 662 | - updateSettingsFile(array('db_last_error' => time())); |
|
| 706 | + if (($temp = cache_get_data('db_last_error', 600)) === null) { |
|
| 707 | + updateSettingsFile(array('db_last_error' => time())); |
|
| 708 | + } |
|
| 663 | 709 | |
| 664 | 710 | // Attempt to find and repair the broken table. |
| 665 | - foreach ($fix_tables as $table) |
|
| 666 | - $smcFunc['db_query']('', " |
|
| 711 | + foreach ($fix_tables as $table) { |
|
| 712 | + $smcFunc['db_query']('', " |
|
| 667 | 713 | REPAIR TABLE $table", false, false); |
| 714 | + } |
|
| 668 | 715 | |
| 669 | 716 | // And send off an email! |
| 670 | 717 | sendmail($webmaster_email, $txt['database_error'], $txt['tried_to_repair'], null, 'dberror'); |
@@ -673,11 +720,12 @@ discard block |
||
| 673 | 720 | |
| 674 | 721 | // Try the query again...? |
| 675 | 722 | $ret = $smcFunc['db_query']('', $db_string, false, false); |
| 676 | - if ($ret !== false) |
|
| 677 | - return $ret; |
|
| 723 | + if ($ret !== false) { |
|
| 724 | + return $ret; |
|
| 725 | + } |
|
| 726 | + } else { |
|
| 727 | + $modSettings['cache_enable'] = $old_cache; |
|
| 678 | 728 | } |
| 679 | - else |
|
| 680 | - $modSettings['cache_enable'] = $old_cache; |
|
| 681 | 729 | |
| 682 | 730 | // Check for the "lost connection" or "deadlock found" errors - and try it just one more time. |
| 683 | 731 | if (in_array($query_errno, array(1205, 1213, 2006, 2013))) |
@@ -687,22 +735,25 @@ discard block |
||
| 687 | 735 | // Are we in SSI mode? If so try that username and password first |
| 688 | 736 | if (SMF == 'SSI' && !empty($ssi_db_user) && !empty($ssi_db_passwd)) |
| 689 | 737 | { |
| 690 | - if (empty($db_persist)) |
|
| 691 | - $db_connection = @mysqli_connect($db_server, $ssi_db_user, $ssi_db_passwd); |
|
| 692 | - else |
|
| 693 | - $db_connection = @mysqli_connect('p:' . $db_server, $ssi_db_user, $ssi_db_passwd); |
|
| 738 | + if (empty($db_persist)) { |
|
| 739 | + $db_connection = @mysqli_connect($db_server, $ssi_db_user, $ssi_db_passwd); |
|
| 740 | + } else { |
|
| 741 | + $db_connection = @mysqli_connect('p:' . $db_server, $ssi_db_user, $ssi_db_passwd); |
|
| 742 | + } |
|
| 694 | 743 | } |
| 695 | 744 | // Fall back to the regular username and password if need be |
| 696 | 745 | if (!$db_connection) |
| 697 | 746 | { |
| 698 | - if (empty($db_persist)) |
|
| 699 | - $db_connection = @mysqli_connect($db_server, $db_user, $db_passwd); |
|
| 700 | - else |
|
| 701 | - $db_connection = @mysqli_connect('p:' . $db_server, $db_user, $db_passwd); |
|
| 747 | + if (empty($db_persist)) { |
|
| 748 | + $db_connection = @mysqli_connect($db_server, $db_user, $db_passwd); |
|
| 749 | + } else { |
|
| 750 | + $db_connection = @mysqli_connect('p:' . $db_server, $db_user, $db_passwd); |
|
| 751 | + } |
|
| 702 | 752 | } |
| 703 | 753 | |
| 704 | - if (!$db_connection || !@mysqli_select_db($db_connection, $db_name)) |
|
| 705 | - $db_connection = false; |
|
| 754 | + if (!$db_connection || !@mysqli_select_db($db_connection, $db_name)) { |
|
| 755 | + $db_connection = false; |
|
| 756 | + } |
|
| 706 | 757 | } |
| 707 | 758 | |
| 708 | 759 | if ($db_connection) |
@@ -713,24 +764,27 @@ discard block |
||
| 713 | 764 | $ret = $smcFunc['db_query']('', $db_string, false, false); |
| 714 | 765 | |
| 715 | 766 | $new_errno = mysqli_errno($db_connection); |
| 716 | - if ($ret !== false || in_array($new_errno, array(1205, 1213))) |
|
| 717 | - break; |
|
| 767 | + if ($ret !== false || in_array($new_errno, array(1205, 1213))) { |
|
| 768 | + break; |
|
| 769 | + } |
|
| 718 | 770 | } |
| 719 | 771 | |
| 720 | 772 | // If it failed again, shucks to be you... we're not trying it over and over. |
| 721 | - if ($ret !== false) |
|
| 722 | - return $ret; |
|
| 773 | + if ($ret !== false) { |
|
| 774 | + return $ret; |
|
| 775 | + } |
|
| 723 | 776 | } |
| 724 | 777 | } |
| 725 | 778 | // Are they out of space, perhaps? |
| 726 | 779 | elseif ($query_errno == 1030 && (strpos($query_error, ' -1 ') !== false || strpos($query_error, ' 28 ') !== false || strpos($query_error, ' 12 ') !== false)) |
| 727 | 780 | { |
| 728 | - if (!isset($txt)) |
|
| 729 | - $query_error .= ' - check database storage space.'; |
|
| 730 | - else |
|
| 781 | + if (!isset($txt)) { |
|
| 782 | + $query_error .= ' - check database storage space.'; |
|
| 783 | + } else |
|
| 731 | 784 | { |
| 732 | - if (!isset($txt['mysql_error_space'])) |
|
| 733 | - loadLanguage('Errors'); |
|
| 785 | + if (!isset($txt['mysql_error_space'])) { |
|
| 786 | + loadLanguage('Errors'); |
|
| 787 | + } |
|
| 734 | 788 | |
| 735 | 789 | $query_error .= !isset($txt['mysql_error_space']) ? ' - check database storage space.' : $txt['mysql_error_space']; |
| 736 | 790 | } |
@@ -738,15 +792,17 @@ discard block |
||
| 738 | 792 | } |
| 739 | 793 | |
| 740 | 794 | // Nothing's defined yet... just die with it. |
| 741 | - if (empty($context) || empty($txt)) |
|
| 742 | - die($query_error); |
|
| 795 | + if (empty($context) || empty($txt)) { |
|
| 796 | + die($query_error); |
|
| 797 | + } |
|
| 743 | 798 | |
| 744 | 799 | // Show an error message, if possible. |
| 745 | 800 | $context['error_title'] = $txt['database_error']; |
| 746 | - if (allowedTo('admin_forum')) |
|
| 747 | - $context['error_message'] = nl2br($query_error) . '<br>' . $txt['file'] . ': ' . $file . '<br>' . $txt['line'] . ': ' . $line; |
|
| 748 | - else |
|
| 749 | - $context['error_message'] = $txt['try_again']; |
|
| 801 | + if (allowedTo('admin_forum')) { |
|
| 802 | + $context['error_message'] = nl2br($query_error) . '<br>' . $txt['file'] . ': ' . $file . '<br>' . $txt['line'] . ': ' . $line; |
|
| 803 | + } else { |
|
| 804 | + $context['error_message'] = $txt['try_again']; |
|
| 805 | + } |
|
| 750 | 806 | |
| 751 | 807 | if (allowedTo('admin_forum') && isset($db_show_debug) && $db_show_debug === true) |
| 752 | 808 | { |
@@ -778,8 +834,9 @@ discard block |
||
| 778 | 834 | $return_var = null; |
| 779 | 835 | |
| 780 | 836 | // With nothing to insert, simply return. |
| 781 | - if (empty($data)) |
|
| 782 | - return; |
|
| 837 | + if (empty($data)) { |
|
| 838 | + return; |
|
| 839 | + } |
|
| 783 | 840 | |
| 784 | 841 | // Replace the prefix holder with the actual prefix. |
| 785 | 842 | $table = str_replace('{db_prefix}', $db_prefix, $table); |
@@ -789,23 +846,26 @@ discard block |
||
| 789 | 846 | if (!empty($keys) && (count($keys) > 0) && $returnmode > 0) |
| 790 | 847 | { |
| 791 | 848 | $with_returning = true; |
| 792 | - if ($returnmode == 2) |
|
| 793 | - $return_var = array(); |
|
| 849 | + if ($returnmode == 2) { |
|
| 850 | + $return_var = array(); |
|
| 851 | + } |
|
| 794 | 852 | } |
| 795 | 853 | |
| 796 | 854 | // Inserting data as a single row can be done as a single array. |
| 797 | - if (!is_array($data[array_rand($data)])) |
|
| 798 | - $data = array($data); |
|
| 855 | + if (!is_array($data[array_rand($data)])) { |
|
| 856 | + $data = array($data); |
|
| 857 | + } |
|
| 799 | 858 | |
| 800 | 859 | // Create the mold for a single row insert. |
| 801 | 860 | $insertData = '('; |
| 802 | 861 | foreach ($columns as $columnName => $type) |
| 803 | 862 | { |
| 804 | 863 | // Are we restricting the length? |
| 805 | - if (strpos($type, 'string-') !== false) |
|
| 806 | - $insertData .= sprintf('SUBSTRING({string:%1$s}, 1, ' . substr($type, 7) . '), ', $columnName); |
|
| 807 | - else |
|
| 808 | - $insertData .= sprintf('{%1$s:%2$s}, ', $type, $columnName); |
|
| 864 | + if (strpos($type, 'string-') !== false) { |
|
| 865 | + $insertData .= sprintf('SUBSTRING({string:%1$s}, 1, ' . substr($type, 7) . '), ', $columnName); |
|
| 866 | + } else { |
|
| 867 | + $insertData .= sprintf('{%1$s:%2$s}, ', $type, $columnName); |
|
| 868 | + } |
|
| 809 | 869 | } |
| 810 | 870 | $insertData = substr($insertData, 0, -2) . ')'; |
| 811 | 871 | |
@@ -814,8 +874,9 @@ discard block |
||
| 814 | 874 | |
| 815 | 875 | // Here's where the variables are injected to the query. |
| 816 | 876 | $insertRows = array(); |
| 817 | - foreach ($data as $dataRow) |
|
| 818 | - $insertRows[] = smf_db_quote($insertData, array_combine($indexed_columns, $dataRow), $connection); |
|
| 877 | + foreach ($data as $dataRow) { |
|
| 878 | + $insertRows[] = smf_db_quote($insertData, array_combine($indexed_columns, $dataRow), $connection); |
|
| 879 | + } |
|
| 819 | 880 | |
| 820 | 881 | // Determine the method of insertion. |
| 821 | 882 | $queryTitle = $method == 'replace' ? 'REPLACE' : ($method == 'ignore' ? 'INSERT IGNORE' : 'INSERT'); |
@@ -834,8 +895,7 @@ discard block |
||
| 834 | 895 | ), |
| 835 | 896 | $connection |
| 836 | 897 | ); |
| 837 | - } |
|
| 838 | - else //special way for ignore method with returning |
|
| 898 | + } else //special way for ignore method with returning |
|
| 839 | 899 | { |
| 840 | 900 | $count = count($insertRows); |
| 841 | 901 | $ai = 0; |
@@ -855,19 +915,21 @@ discard block |
||
| 855 | 915 | ); |
| 856 | 916 | $new_id = $smcFunc['db_insert_id'](); |
| 857 | 917 | |
| 858 | - if ($last_id != $new_id) //the inserted value was new |
|
| 918 | + if ($last_id != $new_id) { |
|
| 919 | + //the inserted value was new |
|
| 859 | 920 | { |
| 860 | 921 | $ai = $new_id; |
| 861 | 922 | } |
| 862 | - else // the inserted value already exists we need to find the pk |
|
| 923 | + } else // the inserted value already exists we need to find the pk |
|
| 863 | 924 | { |
| 864 | 925 | $where_string = ''; |
| 865 | 926 | $count2 = count($indexed_columns); |
| 866 | 927 | for ($x = 0; $x < $count2; $x++) |
| 867 | 928 | { |
| 868 | 929 | $where_string += key($indexed_columns[$x]) . ' = '. $insertRows[$i][$x]; |
| 869 | - if (($x + 1) < $count2) |
|
| 870 | - $where_string += ' AND '; |
|
| 930 | + if (($x + 1) < $count2) { |
|
| 931 | + $where_string += ' AND '; |
|
| 932 | + } |
|
| 871 | 933 | } |
| 872 | 934 | |
| 873 | 935 | $request = $smcFunc['db_query']('',' |
@@ -883,25 +945,27 @@ discard block |
||
| 883 | 945 | } |
| 884 | 946 | } |
| 885 | 947 | |
| 886 | - if ($returnmode == 1) |
|
| 887 | - $return_var = $ai; |
|
| 888 | - else if ($returnmode == 2) |
|
| 889 | - $return_var[] = $ai; |
|
| 948 | + if ($returnmode == 1) { |
|
| 949 | + $return_var = $ai; |
|
| 950 | + } else if ($returnmode == 2) { |
|
| 951 | + $return_var[] = $ai; |
|
| 952 | + } |
|
| 890 | 953 | } |
| 891 | 954 | } |
| 892 | 955 | |
| 893 | 956 | |
| 894 | 957 | if ($with_returning) |
| 895 | 958 | { |
| 896 | - if ($returnmode == 1 && empty($return_var)) |
|
| 897 | - $return_var = smf_db_insert_id($table, $keys[0]) + count($insertRows) - 1; |
|
| 898 | - else if ($returnmode == 2 && empty($return_var)) |
|
| 959 | + if ($returnmode == 1 && empty($return_var)) { |
|
| 960 | + $return_var = smf_db_insert_id($table, $keys[0]) + count($insertRows) - 1; |
|
| 961 | + } else if ($returnmode == 2 && empty($return_var)) |
|
| 899 | 962 | { |
| 900 | 963 | $return_var = array(); |
| 901 | 964 | $count = count($insertRows); |
| 902 | 965 | $start = smf_db_insert_id($table, $keys[0]); |
| 903 | - for ($i = 0; $i < $count; $i++ ) |
|
| 904 | - $return_var[] = $start + $i; |
|
| 966 | + for ($i = 0; $i < $count; $i++ ) { |
|
| 967 | + $return_var[] = $start + $i; |
|
| 968 | + } |
|
| 905 | 969 | } |
| 906 | 970 | return $return_var; |
| 907 | 971 | } |
@@ -919,8 +983,9 @@ discard block |
||
| 919 | 983 | */ |
| 920 | 984 | function smf_db_error_backtrace($error_message, $log_message = '', $error_type = false, $file = null, $line = null) |
| 921 | 985 | { |
| 922 | - if (empty($log_message)) |
|
| 923 | - $log_message = $error_message; |
|
| 986 | + if (empty($log_message)) { |
|
| 987 | + $log_message = $error_message; |
|
| 988 | + } |
|
| 924 | 989 | |
| 925 | 990 | foreach (debug_backtrace() as $step) |
| 926 | 991 | { |
@@ -939,12 +1004,14 @@ discard block |
||
| 939 | 1004 | } |
| 940 | 1005 | |
| 941 | 1006 | // A special case - we want the file and line numbers for debugging. |
| 942 | - if ($error_type == 'return') |
|
| 943 | - return array($file, $line); |
|
| 1007 | + if ($error_type == 'return') { |
|
| 1008 | + return array($file, $line); |
|
| 1009 | + } |
|
| 944 | 1010 | |
| 945 | 1011 | // Is always a critical error. |
| 946 | - if (function_exists('log_error')) |
|
| 947 | - log_error($log_message, 'critical', $file, $line); |
|
| 1012 | + if (function_exists('log_error')) { |
|
| 1013 | + log_error($log_message, 'critical', $file, $line); |
|
| 1014 | + } |
|
| 948 | 1015 | |
| 949 | 1016 | if (function_exists('fatal_error')) |
| 950 | 1017 | { |
@@ -952,12 +1019,12 @@ discard block |
||
| 952 | 1019 | |
| 953 | 1020 | // Cannot continue... |
| 954 | 1021 | exit; |
| 1022 | + } elseif ($error_type) { |
|
| 1023 | + trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : ''), $error_type); |
|
| 1024 | + } else { |
|
| 1025 | + trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : '')); |
|
| 1026 | + } |
|
| 955 | 1027 | } |
| 956 | - elseif ($error_type) |
|
| 957 | - trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : ''), $error_type); |
|
| 958 | - else |
|
| 959 | - trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : '')); |
|
| 960 | -} |
|
| 961 | 1028 | |
| 962 | 1029 | /** |
| 963 | 1030 | * Escape the LIKE wildcards so that they match the character and not the wildcard. |
@@ -974,10 +1041,11 @@ discard block |
||
| 974 | 1041 | '\\' => '\\\\', |
| 975 | 1042 | ); |
| 976 | 1043 | |
| 977 | - if ($translate_human_wildcards) |
|
| 978 | - $replacements += array( |
|
| 1044 | + if ($translate_human_wildcards) { |
|
| 1045 | + $replacements += array( |
|
| 979 | 1046 | '*' => '%', |
| 980 | 1047 | ); |
| 1048 | + } |
|
| 981 | 1049 | |
| 982 | 1050 | return strtr($string, $replacements); |
| 983 | 1051 | } |
@@ -991,8 +1059,9 @@ discard block |
||
| 991 | 1059 | */ |
| 992 | 1060 | function smf_is_resource($result) |
| 993 | 1061 | { |
| 994 | - if ($result instanceof mysqli_result) |
|
| 995 | - return true; |
|
| 1062 | + if ($result instanceof mysqli_result) { |
|
| 1063 | + return true; |
|
| 1064 | + } |
|
| 996 | 1065 | |
| 997 | 1066 | return false; |
| 998 | 1067 | } |
@@ -1020,16 +1089,18 @@ discard block |
||
| 1020 | 1089 | global $db_prefix, $db_connection; |
| 1021 | 1090 | static $mysql_error_data_prep; |
| 1022 | 1091 | |
| 1023 | - if (empty($mysql_error_data_prep)) |
|
| 1024 | - $mysql_error_data_prep = mysqli_prepare($db_connection, |
|
| 1092 | + if (empty($mysql_error_data_prep)) { |
|
| 1093 | + $mysql_error_data_prep = mysqli_prepare($db_connection, |
|
| 1025 | 1094 | 'INSERT INTO ' . $db_prefix . 'log_errors(id_member, log_time, ip, url, message, session, error_type, file, line) |
| 1026 | 1095 | VALUES( ?, ?, unhex(?), ?, ?, ?, ?, ?, ?)' |
| 1027 | 1096 | ); |
| 1097 | + } |
|
| 1028 | 1098 | |
| 1029 | - if (filter_var($error_array[2], FILTER_VALIDATE_IP) !== false) |
|
| 1030 | - $error_array[2] = bin2hex(inet_pton($error_array[2])); |
|
| 1031 | - else |
|
| 1032 | - $error_array[2] = null; |
|
| 1099 | + if (filter_var($error_array[2], FILTER_VALIDATE_IP) !== false) { |
|
| 1100 | + $error_array[2] = bin2hex(inet_pton($error_array[2])); |
|
| 1101 | + } else { |
|
| 1102 | + $error_array[2] = null; |
|
| 1103 | + } |
|
| 1033 | 1104 | mysqli_stmt_bind_param($mysql_error_data_prep, 'iissssssi', |
| 1034 | 1105 | $error_array[0], $error_array[1], $error_array[2], $error_array[3], $error_array[4], $error_array[5], $error_array[6], |
| 1035 | 1106 | $error_array[7], $error_array[8]); |
@@ -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 | } |
@@ -28,14 +28,15 @@ discard block |
||
| 28 | 28 | <div id="confirm_buttons">'; |
| 29 | 29 | |
| 30 | 30 | // Age restriction in effect? |
| 31 | - if ($context['show_coppa']) |
|
| 32 | - echo ' |
|
| 31 | + if ($context['show_coppa']) { |
|
| 32 | + echo ' |
|
| 33 | 33 | <input type="submit" name="accept_agreement" value="', $context['coppa_agree_above'], '" class="button"><br> |
| 34 | 34 | <br> |
| 35 | 35 | <input type="submit" name="accept_agreement_coppa" value="', $context['coppa_agree_below'], '" class="button">'; |
| 36 | - else |
|
| 37 | - echo ' |
|
| 36 | + } else { |
|
| 37 | + echo ' |
|
| 38 | 38 | <input type="submit" name="accept_agreement" value="', $txt['agreement_agree'], '" class="button">'; |
| 39 | + } |
|
| 39 | 40 | |
| 40 | 41 | echo ' |
| 41 | 42 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -78,9 +79,10 @@ discard block |
||
| 78 | 79 | <ul>'; |
| 79 | 80 | |
| 80 | 81 | // Cycle through each error and display an error message. |
| 81 | - foreach ($context['registration_errors'] as $error) |
|
| 82 | - echo ' |
|
| 82 | + foreach ($context['registration_errors'] as $error) { |
|
| 83 | + echo ' |
|
| 83 | 84 | <li>', $error, '</li>'; |
| 85 | + } |
|
| 84 | 86 | |
| 85 | 87 | echo ' |
| 86 | 88 | </ul> |
@@ -150,14 +152,15 @@ discard block |
||
| 150 | 152 | |
| 151 | 153 | <dl class="register_form">'; |
| 152 | 154 | |
| 153 | - foreach ($context['custom_fields'] as $field) |
|
| 154 | - if ($field['show_reg'] > 1) |
|
| 155 | + foreach ($context['custom_fields'] as $field) { |
|
| 156 | + if ($field['show_reg'] > 1) |
|
| 155 | 157 | echo ' |
| 156 | 158 | <dt> |
| 157 | 159 | <strong', !empty($field['is_error']) ? ' class="red"' : '', '>', $field['name'], ':</strong> |
| 158 | 160 | <span class="smalltext">', $field['desc'], '</span> |
| 159 | 161 | </dt> |
| 160 | 162 | <dd>', str_replace('name="', 'tabindex="' . $context['tabindex']++ . '" name="', $field['input_html']), '</dd>'; |
| 163 | + } |
|
| 161 | 164 | |
| 162 | 165 | echo ' |
| 163 | 166 | </dl>'; |
@@ -191,41 +194,45 @@ discard block |
||
| 191 | 194 | $callback_func = 'template_profile_' . $field['callback_func']; |
| 192 | 195 | $callback_func(); |
| 193 | 196 | } |
| 194 | - } |
|
| 195 | - else |
|
| 197 | + } else |
|
| 196 | 198 | { |
| 197 | 199 | echo ' |
| 198 | 200 | <dt> |
| 199 | 201 | <strong', !empty($field['is_error']) ? ' class="red"' : '', '>', $field['label'], ':</strong>'; |
| 200 | 202 | |
| 201 | 203 | // Does it have any subtext to show? |
| 202 | - if (!empty($field['subtext'])) |
|
| 203 | - echo ' |
|
| 204 | + if (!empty($field['subtext'])) { |
|
| 205 | + echo ' |
|
| 204 | 206 | <span class="smalltext">', $field['subtext'], '</span>'; |
| 207 | + } |
|
| 205 | 208 | |
| 206 | 209 | echo ' |
| 207 | 210 | </dt> |
| 208 | 211 | <dd>'; |
| 209 | 212 | |
| 210 | 213 | // Want to put something infront of the box? |
| 211 | - if (!empty($field['preinput'])) |
|
| 212 | - echo ' |
|
| 214 | + if (!empty($field['preinput'])) { |
|
| 215 | + echo ' |
|
| 213 | 216 | ', $field['preinput']; |
| 217 | + } |
|
| 214 | 218 | |
| 215 | 219 | // What type of data are we showing? |
| 216 | - if ($field['type'] == 'label') |
|
| 217 | - echo ' |
|
| 220 | + if ($field['type'] == 'label') { |
|
| 221 | + echo ' |
|
| 218 | 222 | ', $field['value']; |
| 223 | + } |
|
| 219 | 224 | |
| 220 | 225 | // Maybe it's a text box - very likely! |
| 221 | - elseif (in_array($field['type'], array('int', 'float', 'text', 'password'))) |
|
| 222 | - echo ' |
|
| 226 | + elseif (in_array($field['type'], array('int', 'float', 'text', 'password'))) { |
|
| 227 | + echo ' |
|
| 223 | 228 | <input type="', $field['type'] == 'password' ? 'password' : 'text', '" name="', $key, '" id="', $key, '" size="', empty($field['size']) ? 30 : $field['size'], '" value="', $field['value'], '" tabindex="', $context['tabindex']++, '" ', $field['input_attr'], '>'; |
| 229 | + } |
|
| 224 | 230 | |
| 225 | 231 | // You "checking" me out? ;) |
| 226 | - elseif ($field['type'] == 'check') |
|
| 227 | - echo ' |
|
| 232 | + elseif ($field['type'] == 'check') { |
|
| 233 | + echo ' |
|
| 228 | 234 | <input type="hidden" name="', $key, '" value="0"><input type="checkbox" name="', $key, '" id="', $key, '"', !empty($field['value']) ? ' checked' : '', ' value="1" tabindex="', $context['tabindex']++, '" ', $field['input_attr'], '>'; |
| 235 | + } |
|
| 229 | 236 | |
| 230 | 237 | // Always fun - select boxes! |
| 231 | 238 | elseif ($field['type'] == 'select') |
@@ -236,14 +243,16 @@ discard block |
||
| 236 | 243 | if (isset($field['options'])) |
| 237 | 244 | { |
| 238 | 245 | // Is this some code to generate the options? |
| 239 | - if (!is_array($field['options'])) |
|
| 240 | - $field['options'] = eval($field['options']); |
|
| 246 | + if (!is_array($field['options'])) { |
|
| 247 | + $field['options'] = eval($field['options']); |
|
| 248 | + } |
|
| 241 | 249 | |
| 242 | 250 | // Assuming we now have some! |
| 243 | - if (is_array($field['options'])) |
|
| 244 | - foreach ($field['options'] as $value => $name) |
|
| 251 | + if (is_array($field['options'])) { |
|
| 252 | + foreach ($field['options'] as $value => $name) |
|
| 245 | 253 | echo ' |
| 246 | 254 | <option value="', $value, '"', $value == $field['value'] ? ' selected' : '', '>', $name, '</option>'; |
| 255 | + } |
|
| 247 | 256 | } |
| 248 | 257 | |
| 249 | 258 | echo ' |
@@ -251,9 +260,10 @@ discard block |
||
| 251 | 260 | } |
| 252 | 261 | |
| 253 | 262 | // Something to end with? |
| 254 | - if (!empty($field['postinput'])) |
|
| 255 | - echo ' |
|
| 263 | + if (!empty($field['postinput'])) { |
|
| 264 | + echo ' |
|
| 256 | 265 | ', $field['postinput']; |
| 266 | + } |
|
| 257 | 267 | |
| 258 | 268 | echo ' |
| 259 | 269 | </dd>'; |
@@ -266,13 +276,14 @@ discard block |
||
| 266 | 276 | { |
| 267 | 277 | foreach ($context['custom_fields'] as $field) |
| 268 | 278 | { |
| 269 | - if ($field['show_reg'] < 2) |
|
| 270 | - echo ' |
|
| 279 | + if ($field['show_reg'] < 2) { |
|
| 280 | + echo ' |
|
| 271 | 281 | <dt> |
| 272 | 282 | <strong', !empty($field['is_error']) ? ' class="red"' : '', '>', $field['name'], ':</strong> |
| 273 | 283 | <span class="smalltext">', $field['desc'], '</span> |
| 274 | 284 | </dt> |
| 275 | 285 | <dd>', $field['input_html'], '</dd>'; |
| 286 | + } |
|
| 276 | 287 | } |
| 277 | 288 | } |
| 278 | 289 | |
@@ -302,14 +313,15 @@ discard block |
||
| 302 | 313 | <div id="confirm_buttons" class="flow_auto">'; |
| 303 | 314 | |
| 304 | 315 | // Age restriction in effect? |
| 305 | - if (!$context['require_agreement'] && $context['show_coppa']) |
|
| 306 | - echo ' |
|
| 316 | + if (!$context['require_agreement'] && $context['show_coppa']) { |
|
| 317 | + echo ' |
|
| 307 | 318 | <input type="submit" name="accept_agreement" value="', $context['coppa_agree_above'], '" class="button"><br> |
| 308 | 319 | <br> |
| 309 | 320 | <input type="submit" name="accept_agreement_coppa" value="', $context['coppa_agree_below'], '" class="button">'; |
| 310 | - else |
|
| 311 | - echo ' |
|
| 321 | + } else { |
|
| 322 | + echo ' |
|
| 312 | 323 | <input type="submit" name="regSubmit" value="', $txt['register'], '" tabindex="', $context['tabindex']++, '" class="button">'; |
| 324 | + } |
|
| 313 | 325 | echo ' |
| 314 | 326 | </div> |
| 315 | 327 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -457,19 +469,20 @@ discard block |
||
| 457 | 469 | </head> |
| 458 | 470 | <body style="margin: 1ex;"> |
| 459 | 471 | <div class="windowbg description" style="text-align: center;">'; |
| 460 | - if (isBrowser('is_ie') || isBrowser('is_ie11')) |
|
| 461 | - echo ' |
|
| 472 | + if (isBrowser('is_ie') || isBrowser('is_ie11')) { |
|
| 473 | + echo ' |
|
| 462 | 474 | <object classid="clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95" type="audio/x-wav"> |
| 463 | 475 | <param name="AutoStart" value="1"> |
| 464 | 476 | <param name="FileName" value="', $context['verification_sound_href'], '"> |
| 465 | 477 | </object>'; |
| 466 | - else |
|
| 467 | - echo ' |
|
| 478 | + } else { |
|
| 479 | + echo ' |
|
| 468 | 480 | <audio src="', $context['verification_sound_href'], '" controls> |
| 469 | 481 | <object type="audio/x-wav" data="', $context['verification_sound_href'], '"> |
| 470 | 482 | <a href="', $context['verification_sound_href'], '" rel="nofollow">', $context['verification_sound_href'], '</a> |
| 471 | 483 | </object> |
| 472 | 484 | </audio>'; |
| 485 | + } |
|
| 473 | 486 | echo ' |
| 474 | 487 | <br> |
| 475 | 488 | <a href="', $context['verification_sound_href'], ';sound" rel="nofollow">', $txt['visual_verification_sound_again'], '</a><br> |
@@ -496,11 +509,12 @@ discard block |
||
| 496 | 509 | </div> |
| 497 | 510 | <div id="register_screen" class="windowbg2 noup">'; |
| 498 | 511 | |
| 499 | - if (!empty($context['registration_done'])) |
|
| 500 | - echo ' |
|
| 512 | + if (!empty($context['registration_done'])) { |
|
| 513 | + echo ' |
|
| 501 | 514 | <div class="infobox"> |
| 502 | 515 | ', $context['registration_done'], ' |
| 503 | 516 | </div>'; |
| 517 | + } |
|
| 504 | 518 | |
| 505 | 519 | echo ' |
| 506 | 520 | <dl class="register_form" id="admin_register_form"> |
@@ -536,9 +550,10 @@ discard block |
||
| 536 | 550 | <dd> |
| 537 | 551 | <select name="group" id="group_select" tabindex="', $context['tabindex']++, '">'; |
| 538 | 552 | |
| 539 | - foreach ($context['member_groups'] as $id => $name) |
|
| 540 | - echo ' |
|
| 553 | + foreach ($context['member_groups'] as $id => $name) { |
|
| 554 | + echo ' |
|
| 541 | 555 | <option value="', $id, '">', $name, '</option>'; |
| 556 | + } |
|
| 542 | 557 | |
| 543 | 558 | echo ' |
| 544 | 559 | </select> |
@@ -546,8 +561,8 @@ discard block |
||
| 546 | 561 | } |
| 547 | 562 | |
| 548 | 563 | // If there is any field marked as required, show it here! |
| 549 | - if (!empty($context['custom_fields_required']) && !empty($context['custom_fields'])) |
|
| 550 | - foreach ($context['custom_fields'] as $field) |
|
| 564 | + if (!empty($context['custom_fields_required']) && !empty($context['custom_fields'])) { |
|
| 565 | + foreach ($context['custom_fields'] as $field) |
|
| 551 | 566 | if ($field['show_reg'] > 1) |
| 552 | 567 | echo ' |
| 553 | 568 | <dt> |
@@ -557,6 +572,7 @@ discard block |
||
| 557 | 572 | <dd> |
| 558 | 573 | ', str_replace('name="', 'tabindex="' . $context['tabindex']++ . '" name="', $field['input_html']), ' |
| 559 | 574 | </dd>'; |
| 575 | + } |
|
| 560 | 576 | |
| 561 | 577 | echo ' |
| 562 | 578 | <dt> |
@@ -593,12 +609,13 @@ discard block |
||
| 593 | 609 | { |
| 594 | 610 | global $context, $scripturl, $txt; |
| 595 | 611 | |
| 596 | - if (!empty($context['saved_successful'])) |
|
| 597 | - echo ' |
|
| 612 | + if (!empty($context['saved_successful'])) { |
|
| 613 | + echo ' |
|
| 598 | 614 | <div class="infobox">', $txt['settings_saved'], '</div>'; |
| 599 | - elseif (!empty($context['could_not_save'])) |
|
| 600 | - echo ' |
|
| 615 | + } elseif (!empty($context['could_not_save'])) { |
|
| 616 | + echo ' |
|
| 601 | 617 | <div class="errorbox">', $txt['admin_agreement_not_saved'], '</div>'; |
| 618 | + } |
|
| 602 | 619 | |
| 603 | 620 | // Just a big box to edit the text file ;) |
| 604 | 621 | echo ' |
@@ -608,9 +625,10 @@ discard block |
||
| 608 | 625 | </div>'; |
| 609 | 626 | |
| 610 | 627 | // Warning for if the file isn't writable. |
| 611 | - if (!empty($context['warning'])) |
|
| 612 | - echo ' |
|
| 628 | + if (!empty($context['warning'])) { |
|
| 629 | + echo ' |
|
| 613 | 630 | <p class="error">', $context['warning'], '</p>'; |
| 631 | + } |
|
| 614 | 632 | |
| 615 | 633 | echo ' |
| 616 | 634 | <div class="windowbg2 noup" id="registration_agreement">'; |
@@ -627,9 +645,10 @@ discard block |
||
| 627 | 645 | <strong>', $txt['admin_agreement_select_language'], ':</strong> |
| 628 | 646 | <select name="agree_lang" onchange="document.getElementById(\'change_reg\').submit();" tabindex="', $context['tabindex']++, '">'; |
| 629 | 647 | |
| 630 | - foreach ($context['editable_agreements'] as $file => $name) |
|
| 631 | - echo ' |
|
| 648 | + foreach ($context['editable_agreements'] as $file => $name) { |
|
| 649 | + echo ' |
|
| 632 | 650 | <option value="', $file, '"', $context['current_agreement'] == $file ? ' selected' : '', '>', $name, '</option>'; |
| 651 | + } |
|
| 633 | 652 | |
| 634 | 653 | echo ' |
| 635 | 654 | </select> |
@@ -669,9 +688,10 @@ discard block |
||
| 669 | 688 | { |
| 670 | 689 | global $context, $scripturl, $txt; |
| 671 | 690 | |
| 672 | - if (!empty($context['saved_successful'])) |
|
| 673 | - echo ' |
|
| 691 | + if (!empty($context['saved_successful'])) { |
|
| 692 | + echo ' |
|
| 674 | 693 | <div class="infobox">', $txt['settings_saved'], '</div>'; |
| 694 | + } |
|
| 675 | 695 | |
| 676 | 696 | echo ' |
| 677 | 697 | <form id="admin_form_wrapper" action="', $scripturl, '?action=admin;area=regcenter" method="post" accept-charset="', $context['character_set'], '"> |
@@ -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 -->'; |
@@ -25,15 +25,17 @@ discard block |
||
| 25 | 25 | </h3> |
| 26 | 26 | </div>'; |
| 27 | 27 | |
| 28 | - if (!empty($context['search_errors'])) |
|
| 29 | - echo ' |
|
| 28 | + if (!empty($context['search_errors'])) { |
|
| 29 | + echo ' |
|
| 30 | 30 | <div class="errorbox">', implode('<br>', $context['search_errors']['messages']), '</div>'; |
| 31 | + } |
|
| 31 | 32 | |
| 32 | - if (!empty($context['search_ignored'])) |
|
| 33 | - echo ' |
|
| 33 | + if (!empty($context['search_ignored'])) { |
|
| 34 | + echo ' |
|
| 34 | 35 | <p class="noticebox"> |
| 35 | 36 | ', $txt['search_warning_ignored_word' . (count($context['search_ignored']) == 1 ? '' : 's')], ': ', implode(', ', $context['search_ignored']), ' |
| 36 | 37 | </p>'; |
| 38 | + } |
|
| 37 | 39 | |
| 38 | 40 | echo ' |
| 39 | 41 | <div id="advanced_search" class="roundframe"> |
@@ -44,9 +46,10 @@ discard block |
||
| 44 | 46 | <dd> |
| 45 | 47 | <input type="search" name="search" id="searchfor" ', !empty($context['search_params']['search']) ? ' value="' . $context['search_params']['search'] . '"' : '', ' maxlength="', $context['search_string_limit'], '" size="40">'; |
| 46 | 48 | |
| 47 | - if (empty($modSettings['search_simple_fulltext'])) |
|
| 48 | - echo ' |
|
| 49 | + if (empty($modSettings['search_simple_fulltext'])) { |
|
| 50 | + echo ' |
|
| 49 | 51 | <br><em class="smalltext">', $txt['search_example'], '</em>'; |
| 52 | + } |
|
| 50 | 53 | |
| 51 | 54 | echo ' |
| 52 | 55 | </dd> |
@@ -120,13 +123,14 @@ discard block |
||
| 120 | 123 | } |
| 121 | 124 | |
| 122 | 125 | // If $context['search_params']['topic'] is set, that means we're searching just one topic. |
| 123 | - if (!empty($context['search_params']['topic'])) |
|
| 124 | - echo ' |
|
| 126 | + if (!empty($context['search_params']['topic'])) { |
|
| 127 | + echo ' |
|
| 125 | 128 | <p> |
| 126 | 129 | ', $txt['search_specific_topic'], ' "', $context['search_topic']['link'], '". |
| 127 | 130 | </p> |
| 128 | 131 | <input type="hidden" name="topic" value="', $context['search_topic']['id'], '"> |
| 129 | 132 | <input type="submit" name="b_search" value="', $txt['search'], '" class="button">'; |
| 133 | + } |
|
| 130 | 134 | |
| 131 | 135 | echo ' |
| 132 | 136 | </div>'; |
@@ -156,14 +160,15 @@ discard block |
||
| 156 | 160 | |
| 157 | 161 | foreach ($category['boards'] as $board) |
| 158 | 162 | { |
| 159 | - if ($i == $limit) |
|
| 160 | - echo ' |
|
| 163 | + if ($i == $limit) { |
|
| 164 | + echo ' |
|
| 161 | 165 | </ul> |
| 162 | 166 | </li> |
| 163 | 167 | </ul> |
| 164 | 168 | <ul class="ignoreboards floatright"> |
| 165 | 169 | <li class="category"> |
| 166 | 170 | <ul>'; |
| 171 | + } |
|
| 167 | 172 | |
| 168 | 173 | echo ' |
| 169 | 174 | <li class="board"> |
@@ -251,17 +256,19 @@ discard block |
||
| 251 | 256 | <div class="roundframe">'; |
| 252 | 257 | |
| 253 | 258 | // Did they make any typos or mistakes, perhaps? |
| 254 | - if (isset($context['did_you_mean'])) |
|
| 255 | - echo ' |
|
| 259 | + if (isset($context['did_you_mean'])) { |
|
| 260 | + echo ' |
|
| 256 | 261 | <p> |
| 257 | 262 | ', $txt['search_did_you_mean'], ' <a href="', $scripturl, '?action=search2;params=', $context['did_you_mean_params'], '">', $context['did_you_mean'], '</a>. |
| 258 | 263 | </p>'; |
| 264 | + } |
|
| 259 | 265 | |
| 260 | - if (!empty($context['search_ignored'])) |
|
| 261 | - echo ' |
|
| 266 | + if (!empty($context['search_ignored'])) { |
|
| 267 | + echo ' |
|
| 262 | 268 | <p> |
| 263 | 269 | ', $txt['search_warning_ignored_word' . (count($context['search_ignored']) == 1 ? '' : 's')], ': ', implode(', ', $context['search_ignored']), ' |
| 264 | 270 | </p>'; |
| 271 | + } |
|
| 265 | 272 | |
| 266 | 273 | echo ' |
| 267 | 274 | <form action="', $scripturl, '?action=search2" method="post" accept-charset="', $context['character_set'], '"> |
@@ -284,10 +291,11 @@ discard block |
||
| 284 | 291 | <input type="hidden" name="sort" value="', !empty($context['search_params']['sort']) ? $context['search_params']['sort'] : 'relevance', '"> |
| 285 | 292 | </div>'; |
| 286 | 293 | |
| 287 | - if (!empty($context['search_params']['brd'])) |
|
| 288 | - foreach ($context['search_params']['brd'] as $board_id) |
|
| 294 | + if (!empty($context['search_params']['brd'])) { |
|
| 295 | + foreach ($context['search_params']['brd'] as $board_id) |
|
| 289 | 296 | echo ' |
| 290 | 297 | <input type="hidden" name="brd[', $board_id, ']" value="', $board_id, '">'; |
| 298 | + } |
|
| 291 | 299 | |
| 292 | 300 | echo ' |
| 293 | 301 | </form> |
@@ -299,18 +307,20 @@ discard block |
||
| 299 | 307 | if ($context['compact']) |
| 300 | 308 | { |
| 301 | 309 | // Quick moderation set to checkboxes? Oh, how fun :/ |
| 302 | - if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1) |
|
| 303 | - echo ' |
|
| 310 | + if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1) { |
|
| 311 | + echo ' |
|
| 304 | 312 | <form action="', $scripturl, '?action=quickmod" method="post" accept-charset="', $context['character_set'], '" name="topicForm">'; |
| 313 | + } |
|
| 305 | 314 | |
| 306 | 315 | echo ' |
| 307 | 316 | <div class="cat_bar"> |
| 308 | 317 | <h3 class="catbg"> |
| 309 | 318 | <span class="floatright">'; |
| 310 | 319 | |
| 311 | - if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1) |
|
| 312 | - echo ' |
|
| 320 | + if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1) { |
|
| 321 | + echo ' |
|
| 313 | 322 | <input type="checkbox" onclick="invertAll(this, this.form, \'topics[]\');">'; |
| 323 | + } |
|
| 314 | 324 | echo ' |
| 315 | 325 | </span> |
| 316 | 326 | <span class="generic_icons filter"></span> ', $txt['mlist_search_results'], ': ', $context['search_params']['search'], ' |
@@ -318,15 +328,15 @@ discard block |
||
| 318 | 328 | </div>'; |
| 319 | 329 | |
| 320 | 330 | // Was anything even found? |
| 321 | - if (!empty($context['topics'])) |
|
| 322 | - echo ' |
|
| 331 | + if (!empty($context['topics'])) { |
|
| 332 | + echo ' |
|
| 323 | 333 | <div class="pagesection"> |
| 324 | 334 | <span>', $context['page_index'], '</span> |
| 325 | 335 | </div>'; |
| 326 | - |
|
| 327 | - else |
|
| 328 | - echo ' |
|
| 336 | + } else { |
|
| 337 | + echo ' |
|
| 329 | 338 | <div class="roundframe">', $txt['find_no_results'], '</div>'; |
| 339 | + } |
|
| 330 | 340 | |
| 331 | 341 | // While we have results to show ... |
| 332 | 342 | while ($topic = $context['get_topics']()) |
@@ -354,38 +364,43 @@ discard block |
||
| 354 | 364 | { |
| 355 | 365 | echo ' |
| 356 | 366 | <input type="checkbox" name="topics[]" value="', $topic['id'], '">'; |
| 357 | - } |
|
| 358 | - else |
|
| 367 | + } else |
|
| 359 | 368 | { |
| 360 | - if ($topic['quick_mod']['remove']) |
|
| 361 | - echo ' |
|
| 369 | + if ($topic['quick_mod']['remove']) { |
|
| 370 | + echo ' |
|
| 362 | 371 | <a href="', $scripturl, '?action=quickmod;board=' . $topic['board']['id'] . '.0;actions%5B', $topic['id'], '%5D=remove;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons delete" title="', $txt['remove_topic'], '"></span></a>'; |
| 372 | + } |
|
| 363 | 373 | |
| 364 | - if ($topic['quick_mod']['lock']) |
|
| 365 | - echo ' |
|
| 374 | + if ($topic['quick_mod']['lock']) { |
|
| 375 | + echo ' |
|
| 366 | 376 | <a href="', $scripturl, '?action=quickmod;board=' . $topic['board']['id'] . '.0;actions%5B', $topic['id'], '%5D=lock;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons lock" title="', $topic['is_locked'] ? $txt['set_unlock'] : $txt['set_lock'], '"></span></a>'; |
| 377 | + } |
|
| 367 | 378 | |
| 368 | - if ($topic['quick_mod']['lock'] || $topic['quick_mod']['remove']) |
|
| 369 | - echo ' |
|
| 379 | + if ($topic['quick_mod']['lock'] || $topic['quick_mod']['remove']) { |
|
| 380 | + echo ' |
|
| 370 | 381 | <br>'; |
| 382 | + } |
|
| 371 | 383 | |
| 372 | - if ($topic['quick_mod']['sticky']) |
|
| 373 | - echo ' |
|
| 384 | + if ($topic['quick_mod']['sticky']) { |
|
| 385 | + echo ' |
|
| 374 | 386 | <a href="', $scripturl, '?action=quickmod;board=' . $topic['board']['id'] . '.0;actions%5B', $topic['id'], '%5D=sticky;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons sticky" title="', $topic['is_sticky'] ? $txt['set_nonsticky'] : $txt['set_sticky'], '"></span></a>'; |
| 387 | + } |
|
| 375 | 388 | |
| 376 | - if ($topic['quick_mod']['move']) |
|
| 377 | - echo ' |
|
| 389 | + if ($topic['quick_mod']['move']) { |
|
| 390 | + echo ' |
|
| 378 | 391 | <a href="', $scripturl, '?action=movetopic;topic=', $topic['id'], '.0"><span class="generic_icons move" title="', $txt['move_topic'], '"></span></a>'; |
| 392 | + } |
|
| 379 | 393 | } |
| 380 | 394 | |
| 381 | 395 | echo ' |
| 382 | 396 | </div><!-- .floatright -->'; |
| 383 | 397 | } |
| 384 | 398 | |
| 385 | - if ($message['body_highlighted'] != '') |
|
| 386 | - echo ' |
|
| 399 | + if ($message['body_highlighted'] != '') { |
|
| 400 | + echo ' |
|
| 387 | 401 | <br class="clear"> |
| 388 | 402 | <div class="list_posts double_height">', $message['body_highlighted'], '</div>'; |
| 403 | + } |
|
| 389 | 404 | } |
| 390 | 405 | |
| 391 | 406 | echo ' |
@@ -393,11 +408,12 @@ discard block |
||
| 393 | 408 | </div><!-- $topic[css_class] -->'; |
| 394 | 409 | |
| 395 | 410 | } |
| 396 | - if (!empty($context['topics'])) |
|
| 397 | - echo ' |
|
| 411 | + if (!empty($context['topics'])) { |
|
| 412 | + echo ' |
|
| 398 | 413 | <div class="pagesection"> |
| 399 | 414 | <span>', $context['page_index'], '</span> |
| 400 | 415 | </div>'; |
| 416 | + } |
|
| 401 | 417 | |
| 402 | 418 | if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics'])) |
| 403 | 419 | { |
@@ -407,17 +423,19 @@ discard block |
||
| 407 | 423 | <select class="qaction" name="qaction"', $context['can_move'] ? ' onchange="this.form.move_to.disabled = (this.options[this.selectedIndex].value != \'move\');"' : '', '> |
| 408 | 424 | <option value="">--------</option>'; |
| 409 | 425 | |
| 410 | - foreach ($context['qmod_actions'] as $qmod_action) |
|
| 411 | - if ($context['can_' . $qmod_action]) |
|
| 426 | + foreach ($context['qmod_actions'] as $qmod_action) { |
|
| 427 | + if ($context['can_' . $qmod_action]) |
|
| 412 | 428 | echo ' |
| 413 | 429 | <option value="' . $qmod_action . '">' . $txt['quick_mod_' . $qmod_action] . '</option>'; |
| 430 | + } |
|
| 414 | 431 | |
| 415 | 432 | echo ' |
| 416 | 433 | </select>'; |
| 417 | 434 | |
| 418 | - if ($context['can_move']) |
|
| 419 | - echo ' |
|
| 435 | + if ($context['can_move']) { |
|
| 436 | + echo ' |
|
| 420 | 437 | <span id="quick_mod_jump_to"> </span>'; |
| 438 | + } |
|
| 421 | 439 | |
| 422 | 440 | echo ' |
| 423 | 441 | <input type="hidden" name="redirect_url" value="', $scripturl . '?action=search2;params=' . $context['params'], '"> |
@@ -427,13 +445,13 @@ discard block |
||
| 427 | 445 | } |
| 428 | 446 | |
| 429 | 447 | |
| 430 | - if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics'])) |
|
| 431 | - echo ' |
|
| 448 | + if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics'])) { |
|
| 449 | + echo ' |
|
| 432 | 450 | <input type="hidden" name="' . $context['session_var'] . '" value="' . $context['session_id'] . '"> |
| 433 | 451 | </form>'; |
| 452 | + } |
|
| 434 | 453 | |
| 435 | - } |
|
| 436 | - else |
|
| 454 | + } else |
|
| 437 | 455 | { |
| 438 | 456 | echo ' |
| 439 | 457 | <div class="cat_bar"> |
@@ -445,9 +463,10 @@ discard block |
||
| 445 | 463 | <span>', $context['page_index'], '</span> |
| 446 | 464 | </div>'; |
| 447 | 465 | |
| 448 | - if (empty($context['topics'])) |
|
| 449 | - echo ' |
|
| 466 | + if (empty($context['topics'])) { |
|
| 467 | + echo ' |
|
| 450 | 468 | <div class="information">(', $txt['search_no_results'], ')</div>'; |
| 469 | + } |
|
| 451 | 470 | |
| 452 | 471 | while ($topic = $context['get_topics']()) |
| 453 | 472 | { |
@@ -464,23 +483,27 @@ discard block |
||
| 464 | 483 | </div> |
| 465 | 484 | <div class="list_posts">', $message['body_highlighted'], '</div>'; |
| 466 | 485 | |
| 467 | - if ($topic['can_reply']) |
|
| 468 | - echo ' |
|
| 486 | + if ($topic['can_reply']) { |
|
| 487 | + echo ' |
|
| 469 | 488 | <ul class="quickbuttons">'; |
| 489 | + } |
|
| 470 | 490 | |
| 471 | 491 | // If they *can* reply? |
| 472 | - if ($topic['can_reply']) |
|
| 473 | - echo ' |
|
| 492 | + if ($topic['can_reply']) { |
|
| 493 | + echo ' |
|
| 474 | 494 | <li><a href="', $scripturl . '?action=post;topic=' . $topic['id'] . '.' . $message['start'], '"><span class="generic_icons reply_button"></span>', $txt['reply'], '</a></li>'; |
| 495 | + } |
|
| 475 | 496 | |
| 476 | 497 | // If they *can* quote? |
| 477 | - if ($topic['can_quote']) |
|
| 478 | - echo ' |
|
| 498 | + if ($topic['can_quote']) { |
|
| 499 | + echo ' |
|
| 479 | 500 | <li><a href="', $scripturl . '?action=post;topic=' . $topic['id'] . '.' . $message['start'] . ';quote=' . $message['id'] . '"><span class="generic_icons quote"></span>', $txt['quote_action'], '</a></li>'; |
| 501 | + } |
|
| 480 | 502 | |
| 481 | - if ($topic['can_reply']) |
|
| 482 | - echo ' |
|
| 503 | + if ($topic['can_reply']) { |
|
| 504 | + echo ' |
|
| 483 | 505 | </ul>'; |
| 506 | + } |
|
| 484 | 507 | echo ' |
| 485 | 508 | <br class="clear"> |
| 486 | 509 | </div><!-- $topic[css_class] -->'; |
@@ -499,8 +522,8 @@ discard block |
||
| 499 | 522 | <div class="smalltext righttext" id="search_jump_to"> </div> |
| 500 | 523 | <script>'; |
| 501 | 524 | |
| 502 | - if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics']) && $context['can_move']) |
|
| 503 | - echo ' |
|
| 525 | + if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics']) && $context['can_move']) { |
|
| 526 | + echo ' |
|
| 504 | 527 | if (typeof(window.XMLHttpRequest) != "undefined") |
| 505 | 528 | aJumpTo[aJumpTo.length] = new JumpTo({ |
| 506 | 529 | sContainerId: "quick_mod_jump_to", |
@@ -515,6 +538,7 @@ discard block |
||
| 515 | 538 | bDisabled: true, |
| 516 | 539 | sCustomName: "move_to" |
| 517 | 540 | });'; |
| 541 | + } |
|
| 518 | 542 | |
| 519 | 543 | echo ' |
| 520 | 544 | if (typeof(window.XMLHttpRequest) != "undefined") |
@@ -54,9 +54,10 @@ discard block |
||
| 54 | 54 | <dd> |
| 55 | 55 | <div id="known_themes_list">'; |
| 56 | 56 | |
| 57 | - foreach ($context['themes'] as $theme) |
|
| 58 | - echo ' |
|
| 57 | + foreach ($context['themes'] as $theme) { |
|
| 58 | + echo ' |
|
| 59 | 59 | <label for="options-known_themes_', $theme['id'], '"><input type="checkbox" name="options[known_themes][]" id="options-known_themes_', $theme['id'], '" value="', $theme['id'], '"', $theme['known'] ? ' checked' : '', '> ', $theme['name'], '</label><br>'; |
| 60 | + } |
|
| 60 | 61 | |
| 61 | 62 | echo ' |
| 62 | 63 | </div> |
@@ -73,9 +74,10 @@ discard block |
||
| 73 | 74 | <select name="options[theme_guests]" id="theme_guests">'; |
| 74 | 75 | |
| 75 | 76 | // Put an option for each theme in the select box. |
| 76 | - foreach ($context['themes'] as $theme) |
|
| 77 | - echo ' |
|
| 77 | + foreach ($context['themes'] as $theme) { |
|
| 78 | + echo ' |
|
| 78 | 79 | <option value="', $theme['id'], '"', $modSettings['theme_guests'] == $theme['id'] ? ' selected' : '', '>', $theme['name'], '</option>'; |
| 80 | + } |
|
| 79 | 81 | |
| 80 | 82 | echo ' |
| 81 | 83 | </select> |
@@ -90,9 +92,10 @@ discard block |
||
| 90 | 92 | <option value="0">', $txt['theme_forum_default'], '</option>'; |
| 91 | 93 | |
| 92 | 94 | // Same thing, this time for changing the theme of everyone. |
| 93 | - foreach ($context['themes'] as $theme) |
|
| 94 | - echo ' |
|
| 95 | + foreach ($context['themes'] as $theme) { |
|
| 96 | + echo ' |
|
| 95 | 97 | <option value="', $theme['id'], '">', $theme['name'], '</option>'; |
| 98 | + } |
|
| 96 | 99 | |
| 97 | 100 | echo ' |
| 98 | 101 | </select> |
@@ -189,11 +192,12 @@ discard block |
||
| 189 | 192 | global $context, $scripturl, $txt; |
| 190 | 193 | |
| 191 | 194 | // Show a nice confirmation message. |
| 192 | - if (isset($_GET['done'])) |
|
| 193 | - echo ' |
|
| 195 | + if (isset($_GET['done'])) { |
|
| 196 | + echo ' |
|
| 194 | 197 | <div class="infobox"> |
| 195 | 198 | ', $txt['theme_confirmed_' . $_GET['done']], ' |
| 196 | 199 | </div>'; |
| 200 | + } |
|
| 197 | 201 | |
| 198 | 202 | echo ' |
| 199 | 203 | <div id="admincenter">'; |
@@ -358,11 +362,12 @@ discard block |
||
| 358 | 362 | if (empty($setting) || !is_array($setting)) |
| 359 | 363 | { |
| 360 | 364 | // Insert a separator (unless this is the first item in the list) |
| 361 | - if ($i !== $first_option_key) |
|
| 362 | - echo ' |
|
| 365 | + if ($i !== $first_option_key) { |
|
| 366 | + echo ' |
|
| 363 | 367 | </dl> |
| 364 | 368 | <hr> |
| 365 | 369 | <dl class="settings">'; |
| 370 | + } |
|
| 366 | 371 | |
| 367 | 372 | // Should we give a name to this section? |
| 368 | 373 | if (is_string($setting) && !empty($setting)) |
@@ -371,9 +376,9 @@ discard block |
||
| 371 | 376 | echo ' |
| 372 | 377 | <dt><strong>' . $setting . '</strong></dt> |
| 373 | 378 | <dd></dd>'; |
| 379 | + } else { |
|
| 380 | + $titled_section = false; |
|
| 374 | 381 | } |
| 375 | - else |
|
| 376 | - $titled_section = false; |
|
| 377 | 382 | |
| 378 | 383 | continue; |
| 379 | 384 | } |
@@ -382,8 +387,8 @@ discard block |
||
| 382 | 387 | <dt>'; |
| 383 | 388 | |
| 384 | 389 | // Show the change option box? |
| 385 | - if ($context['theme_options_reset']) |
|
| 386 | - echo ' |
|
| 390 | + if ($context['theme_options_reset']) { |
|
| 391 | + echo ' |
|
| 387 | 392 | <span class="floatleft"> |
| 388 | 393 | <select name="', !empty($setting['default']) ? 'default_' : '', 'options_master[', $setting['id'], ']" onchange="this.form.options_', $setting['id'], '.disabled = this.selectedIndex != 1;"> |
| 389 | 394 | <option value="0" selected>', $txt['themeadmin_reset_options_none'], '</option> |
@@ -391,14 +396,16 @@ discard block |
||
| 391 | 396 | <option value="2">', $txt['themeadmin_reset_options_default'], '</option> |
| 392 | 397 | </select> |
| 393 | 398 | </span>'; |
| 399 | + } |
|
| 394 | 400 | |
| 395 | 401 | echo ' |
| 396 | 402 | <label for="options_', $setting['id'], '">', !$titled_section ? '<strong>' : '', $setting['label'], !$titled_section ? '</strong>' : '', '</label>'; |
| 397 | 403 | |
| 398 | - if (isset($setting['description'])) |
|
| 399 | - echo ' |
|
| 404 | + if (isset($setting['description'])) { |
|
| 405 | + echo ' |
|
| 400 | 406 | <br> |
| 401 | 407 | <span class="smalltext">', $setting['description'], '</span>'; |
| 408 | + } |
|
| 402 | 409 | echo ' |
| 403 | 410 | </dt>'; |
| 404 | 411 | |
@@ -440,13 +447,11 @@ discard block |
||
| 440 | 447 | |
| 441 | 448 | echo ' |
| 442 | 449 | <input type="number"', $min . $max . $step; |
| 443 | - } |
|
| 444 | - else if (isset($setting['type']) && $setting['type'] == 'url') |
|
| 450 | + } else if (isset($setting['type']) && $setting['type'] == 'url') |
|
| 445 | 451 | { |
| 446 | 452 | echo' |
| 447 | 453 | <input type="url"'; |
| 448 | - } |
|
| 449 | - else |
|
| 454 | + } else |
|
| 450 | 455 | { |
| 451 | 456 | echo ' |
| 452 | 457 | <input type="text"'; |
@@ -490,8 +495,8 @@ discard block |
||
| 490 | 495 | <br>'; |
| 491 | 496 | |
| 492 | 497 | // @todo Why can't I edit the default theme popup. |
| 493 | - if ($context['theme_settings']['theme_id'] != 1) |
|
| 494 | - echo ' |
|
| 498 | + if ($context['theme_settings']['theme_id'] != 1) { |
|
| 499 | + echo ' |
|
| 495 | 500 | <div class="cat_bar"> |
| 496 | 501 | <h3 class="catbg config_hd"> |
| 497 | 502 | ', $txt['theme_edit'], ' |
@@ -507,6 +512,7 @@ discard block |
||
| 507 | 512 | </li> |
| 508 | 513 | </ul> |
| 509 | 514 | </div>'; |
| 515 | + } |
|
| 510 | 516 | |
| 511 | 517 | echo ' |
| 512 | 518 | <div class="cat_bar"> |
@@ -560,9 +566,10 @@ discard block |
||
| 560 | 566 | <dd> |
| 561 | 567 | <select id="variant" name="options[default_variant]" onchange="changeVariant(this.value)">'; |
| 562 | 568 | |
| 563 | - foreach ($context['theme_variants'] as $key => $variant) |
|
| 564 | - echo ' |
|
| 569 | + foreach ($context['theme_variants'] as $key => $variant) { |
|
| 570 | + echo ' |
|
| 565 | 571 | <option value="', $key, '"', $context['default_variant'] == $key ? ' selected' : '', '>', $variant['label'], '</option>'; |
| 572 | + } |
|
| 566 | 573 | |
| 567 | 574 | echo ' |
| 568 | 575 | </select> |
@@ -598,11 +605,12 @@ discard block |
||
| 598 | 605 | if (empty($setting) || !is_array($setting)) |
| 599 | 606 | { |
| 600 | 607 | // We don't need a separator before the first list element |
| 601 | - if ($i !== $first_setting_key) |
|
| 602 | - echo ' |
|
| 608 | + if ($i !== $first_setting_key) { |
|
| 609 | + echo ' |
|
| 603 | 610 | </dl> |
| 604 | 611 | <hr> |
| 605 | 612 | <dl class="settings">'; |
| 613 | + } |
|
| 606 | 614 | |
| 607 | 615 | // Add a fake heading? |
| 608 | 616 | if (is_string($setting) && !empty($setting)) |
@@ -611,9 +619,9 @@ discard block |
||
| 611 | 619 | echo ' |
| 612 | 620 | <dt><strong>' . $setting . '</strong></dt> |
| 613 | 621 | <dd></dd>'; |
| 622 | + } else { |
|
| 623 | + $titled_section = false; |
|
| 614 | 624 | } |
| 615 | - else |
|
| 616 | - $titled_section = false; |
|
| 617 | 625 | |
| 618 | 626 | continue; |
| 619 | 627 | } |
@@ -622,9 +630,10 @@ discard block |
||
| 622 | 630 | <dt> |
| 623 | 631 | <label for="', $setting['id'], '">', !$titled_section ? '<strong>' : '', $setting['label'], !$titled_section ? '</strong>' : '', '</label>:'; |
| 624 | 632 | |
| 625 | - if (isset($setting['description'])) |
|
| 626 | - echo '<br> |
|
| 633 | + if (isset($setting['description'])) { |
|
| 634 | + echo '<br> |
|
| 627 | 635 | <span class="smalltext">', $setting['description'], '</span>'; |
| 636 | + } |
|
| 628 | 637 | |
| 629 | 638 | echo ' |
| 630 | 639 | </dt>'; |
@@ -645,9 +654,10 @@ discard block |
||
| 645 | 654 | <dd> |
| 646 | 655 | <select name="', !empty($setting['default']) ? 'default_' : '', 'options[', $setting['id'], ']" id="', $setting['id'], '">'; |
| 647 | 656 | |
| 648 | - foreach ($setting['options'] as $value => $label) |
|
| 649 | - echo ' |
|
| 657 | + foreach ($setting['options'] as $value => $label) { |
|
| 658 | + echo ' |
|
| 650 | 659 | <option value="', $value, '"', $value == $setting['value'] ? ' selected' : '', '>', $label, '</option>'; |
| 660 | + } |
|
| 651 | 661 | |
| 652 | 662 | echo ' |
| 653 | 663 | </select> |
@@ -676,13 +686,11 @@ discard block |
||
| 676 | 686 | |
| 677 | 687 | echo ' |
| 678 | 688 | <input type="number"', $min . $max . $step; |
| 679 | - } |
|
| 680 | - else if (isset($setting['type']) && $setting['type'] == 'url') |
|
| 689 | + } else if (isset($setting['type']) && $setting['type'] == 'url') |
|
| 681 | 690 | { |
| 682 | 691 | echo' |
| 683 | 692 | <input type="url"'; |
| 684 | - } |
|
| 685 | - else |
|
| 693 | + } else |
|
| 686 | 694 | { |
| 687 | 695 | echo ' |
| 688 | 696 | <input type="text"'; |
@@ -839,21 +847,23 @@ discard block |
||
| 839 | 847 | <div class="windowbg">'; |
| 840 | 848 | |
| 841 | 849 | // Oops! there was an error :( |
| 842 | - if (!empty($context['error_message'])) |
|
| 843 | - echo ' |
|
| 850 | + if (!empty($context['error_message'])) { |
|
| 851 | + echo ' |
|
| 844 | 852 | <p> |
| 845 | 853 | ', $context['error_message'], ' |
| 846 | 854 | </p>'; |
| 855 | + } |
|
| 847 | 856 | |
| 848 | 857 | // Not much to show except a link back... |
| 849 | - else |
|
| 850 | - echo ' |
|
| 858 | + else { |
|
| 859 | + echo ' |
|
| 851 | 860 | <p> |
| 852 | 861 | <a href="', $scripturl, '?action=admin;area=theme;sa=list;th=', $context['installed_theme']['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $context['installed_theme']['name'], '</a> ', $txt['theme_' . (isset($context['installed_theme']['updated']) ? 'updated' : 'installed') . '_message'], ' |
| 853 | 862 | </p> |
| 854 | 863 | <p> |
| 855 | 864 | <a href="', $scripturl, '?action=admin;area=theme;sa=admin;', $context['session_var'], '=', $context['session_id'], '">', $txt['back'], '</a> |
| 856 | 865 | </p>'; |
| 866 | + } |
|
| 857 | 867 | |
| 858 | 868 | echo ' |
| 859 | 869 | </div><!-- .windowbg --> |
@@ -920,11 +930,12 @@ discard block |
||
| 920 | 930 | <span class="floatleft">', $template['filename'], $template['already_exists'] ? ' <span class="error">(' . $txt['themeadmin_edit_exists'] . ')</span>' : '', '</span> |
| 921 | 931 | <span class="floatright">'; |
| 922 | 932 | |
| 923 | - if ($template['can_copy']) |
|
| 924 | - echo ' |
|
| 933 | + if ($template['can_copy']) { |
|
| 934 | + echo ' |
|
| 925 | 935 | <a href="', $scripturl, '?action=admin;area=theme;th=', $context['theme_id'], ';', $context['session_var'], '=', $context['session_id'], ';sa=copy;template=', $template['value'], '" data-confirm="', $template['already_exists'] ? $txt['themeadmin_edit_overwrite_confirm'] : $txt['themeadmin_edit_copy_confirm'], '" class="you_sure">', $txt['themeadmin_edit_do_copy'], '</a>'; |
| 926 | - else |
|
| 927 | - echo $txt['themeadmin_edit_no_copy']; |
|
| 936 | + } else { |
|
| 937 | + echo $txt['themeadmin_edit_no_copy']; |
|
| 938 | + } |
|
| 928 | 939 | |
| 929 | 940 | echo ' |
| 930 | 941 | </span> |
@@ -947,11 +958,12 @@ discard block |
||
| 947 | 958 | echo ' |
| 948 | 959 | <div id="admincenter">'; |
| 949 | 960 | |
| 950 | - if (!empty($context['browse_title'])) |
|
| 951 | - echo ' |
|
| 961 | + if (!empty($context['browse_title'])) { |
|
| 962 | + echo ' |
|
| 952 | 963 | <div class="cat_bar"> |
| 953 | 964 | <h3 class="catbg">', $context['browse_title'], '</h3> |
| 954 | 965 | </div>'; |
| 966 | + } |
|
| 955 | 967 | |
| 956 | 968 | echo ' |
| 957 | 969 | <table class="table_grid tborder"> |
@@ -971,16 +983,15 @@ discard block |
||
| 971 | 983 | <tr class="windowbg"> |
| 972 | 984 | <td>'; |
| 973 | 985 | |
| 974 | - if ($file['is_editable']) |
|
| 975 | - echo ' |
|
| 986 | + if ($file['is_editable']) { |
|
| 987 | + echo ' |
|
| 976 | 988 | <a href="', $file['href'], '"', $file['is_template'] ? ' style="font-weight: bold;"' : '', '>', $file['filename'], '</a>'; |
| 977 | - |
|
| 978 | - elseif ($file['is_directory']) |
|
| 979 | - echo ' |
|
| 989 | + } elseif ($file['is_directory']) { |
|
| 990 | + echo ' |
|
| 980 | 991 | <a href="', $file['href'], '" class="is_directory"><span class="generic_icons folder"></span>', $file['filename'], '</a>'; |
| 981 | - |
|
| 982 | - else |
|
| 983 | - echo $file['filename']; |
|
| 992 | + } else { |
|
| 993 | + echo $file['filename']; |
|
| 994 | + } |
|
| 984 | 995 | |
| 985 | 996 | echo ' |
| 986 | 997 | </td> |
@@ -1002,11 +1013,12 @@ discard block |
||
| 1002 | 1013 | { |
| 1003 | 1014 | global $context, $settings, $scripturl, $txt; |
| 1004 | 1015 | |
| 1005 | - if ($context['session_error']) |
|
| 1006 | - echo ' |
|
| 1016 | + if ($context['session_error']) { |
|
| 1017 | + echo ' |
|
| 1007 | 1018 | <div class="errorbox"> |
| 1008 | 1019 | ', $txt['error_session_timeout'], ' |
| 1009 | 1020 | </div>'; |
| 1021 | + } |
|
| 1010 | 1022 | |
| 1011 | 1023 | // From now on no one can complain that editing css is difficult. If you disagree, go to www.w3schools.com. |
| 1012 | 1024 | echo ' |
@@ -1069,17 +1081,18 @@ discard block |
||
| 1069 | 1081 | try |
| 1070 | 1082 | { |
| 1071 | 1083 | '; |
| 1072 | - if (isBrowser('is_ie')) |
|
| 1073 | - echo ' |
|
| 1084 | + if (isBrowser('is_ie')) { |
|
| 1085 | + echo ' |
|
| 1074 | 1086 | var sheets = frames["css_preview_box"].document.styleSheets; |
| 1075 | 1087 | for (var j = 0; j < sheets.length; j++) |
| 1076 | 1088 | { |
| 1077 | 1089 | if (sheets[j].id == "css_preview_box") |
| 1078 | 1090 | sheets[j].cssText = document.forms.stylesheetForm.entire_file.value; |
| 1079 | 1091 | }'; |
| 1080 | - else |
|
| 1081 | - echo ' |
|
| 1092 | + } else { |
|
| 1093 | + echo ' |
|
| 1082 | 1094 | setInnerHTML(frames["css_preview_box"].document.getElementById("css_preview_sheet"), document.forms.stylesheetForm.entire_file.value);'; |
| 1095 | + } |
|
| 1083 | 1096 | echo ' |
| 1084 | 1097 | } |
| 1085 | 1098 | catch (e) |
@@ -1131,9 +1144,10 @@ discard block |
||
| 1131 | 1144 | </div> |
| 1132 | 1145 | <div class="windowbg">'; |
| 1133 | 1146 | |
| 1134 | - if (!$context['allow_save']) |
|
| 1135 | - echo ' |
|
| 1147 | + if (!$context['allow_save']) { |
|
| 1148 | + echo ' |
|
| 1136 | 1149 | ', $txt['theme_edit_no_save'], ': ', $context['allow_save_filename'], '<br>'; |
| 1150 | + } |
|
| 1137 | 1151 | |
| 1138 | 1152 | echo ' |
| 1139 | 1153 | <textarea class="edit_file" name="entire_file" cols="80" rows="20" onkeyup="setPreviewTimeout();" onchange="refreshPreview(true);">', $context['entire_file'], '</textarea> |
@@ -1147,9 +1161,10 @@ discard block |
||
| 1147 | 1161 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">'; |
| 1148 | 1162 | |
| 1149 | 1163 | // Hopefully it exists. |
| 1150 | - if (isset($context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token'])) |
|
| 1151 | - echo ' |
|
| 1164 | + if (isset($context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token'])) { |
|
| 1165 | + echo ' |
|
| 1152 | 1166 | <input type="hidden" name="', $context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token_var'], '" value="', $context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token'], '">'; |
| 1167 | + } |
|
| 1153 | 1168 | |
| 1154 | 1169 | echo ' |
| 1155 | 1170 | </form> |
@@ -1163,18 +1178,20 @@ discard block |
||
| 1163 | 1178 | { |
| 1164 | 1179 | global $context, $scripturl, $txt; |
| 1165 | 1180 | |
| 1166 | - if ($context['session_error']) |
|
| 1167 | - echo ' |
|
| 1181 | + if ($context['session_error']) { |
|
| 1182 | + echo ' |
|
| 1168 | 1183 | <div class="errorbox"> |
| 1169 | 1184 | ', $txt['error_session_timeout'], ' |
| 1170 | 1185 | </div>'; |
| 1186 | + } |
|
| 1171 | 1187 | |
| 1172 | - if (isset($context['parse_error'])) |
|
| 1173 | - echo ' |
|
| 1188 | + if (isset($context['parse_error'])) { |
|
| 1189 | + echo ' |
|
| 1174 | 1190 | <div class="errorbox"> |
| 1175 | 1191 | ', $txt['themeadmin_edit_error'], ' |
| 1176 | 1192 | <div><pre>', $context['parse_error'], '</pre></div> |
| 1177 | 1193 | </div>'; |
| 1194 | + } |
|
| 1178 | 1195 | |
| 1179 | 1196 | // Just show a big box.... gray out the Save button if it's not saveable... (ie. not 777.) |
| 1180 | 1197 | echo ' |
@@ -1185,16 +1202,18 @@ discard block |
||
| 1185 | 1202 | </div> |
| 1186 | 1203 | <div class="windowbg">'; |
| 1187 | 1204 | |
| 1188 | - if (!$context['allow_save']) |
|
| 1189 | - echo ' |
|
| 1205 | + if (!$context['allow_save']) { |
|
| 1206 | + echo ' |
|
| 1190 | 1207 | ', $txt['theme_edit_no_save'], ': ', $context['allow_save_filename'], '<br>'; |
| 1208 | + } |
|
| 1191 | 1209 | |
| 1192 | - foreach ($context['file_parts'] as $part) |
|
| 1193 | - echo ' |
|
| 1210 | + foreach ($context['file_parts'] as $part) { |
|
| 1211 | + echo ' |
|
| 1194 | 1212 | <label for="on_line', $part['line'], '">', $txt['themeadmin_edit_on_line'], ' ', $part['line'], '</label>:<br> |
| 1195 | 1213 | <div class="centertext"> |
| 1196 | 1214 | <textarea id="on_line', $part['line'], '" name="entire_file[]" cols="80" rows="', $part['lines'] > 14 ? '14' : $part['lines'], '" class="edit_file">', $part['data'], '</textarea> |
| 1197 | 1215 | </div>'; |
| 1216 | + } |
|
| 1198 | 1217 | |
| 1199 | 1218 | echo ' |
| 1200 | 1219 | <div class="padding righttext"> |
@@ -1203,9 +1222,10 @@ discard block |
||
| 1203 | 1222 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">'; |
| 1204 | 1223 | |
| 1205 | 1224 | // Hopefully it exists. |
| 1206 | - if (isset($context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token'])) |
|
| 1207 | - echo ' |
|
| 1225 | + if (isset($context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token'])) { |
|
| 1226 | + echo ' |
|
| 1208 | 1227 | <input type="hidden" name="', $context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token_var'], '" value="', $context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token'], '">'; |
| 1228 | + } |
|
| 1209 | 1229 | |
| 1210 | 1230 | echo ' |
| 1211 | 1231 | </div><!-- .righttext --> |
@@ -1221,18 +1241,20 @@ discard block |
||
| 1221 | 1241 | { |
| 1222 | 1242 | global $context, $scripturl, $txt; |
| 1223 | 1243 | |
| 1224 | - if ($context['session_error']) |
|
| 1225 | - echo ' |
|
| 1244 | + if ($context['session_error']) { |
|
| 1245 | + echo ' |
|
| 1226 | 1246 | <div class="errorbox"> |
| 1227 | 1247 | ', $txt['error_session_timeout'], ' |
| 1228 | 1248 | </div>'; |
| 1249 | + } |
|
| 1229 | 1250 | |
| 1230 | 1251 | // Is this file writeable? |
| 1231 | - if (!$context['allow_save']) |
|
| 1232 | - echo ' |
|
| 1252 | + if (!$context['allow_save']) { |
|
| 1253 | + echo ' |
|
| 1233 | 1254 | <div class="errorbox"> |
| 1234 | 1255 | ', $txt['theme_edit_no_save'], ': ', $context['allow_save_filename'], ' |
| 1235 | 1256 | </div>'; |
| 1257 | + } |
|
| 1236 | 1258 | |
| 1237 | 1259 | // Just show a big box.... gray out the Save button if it's not saveable... (ie. not 777.) |
| 1238 | 1260 | echo ' |
@@ -1248,9 +1270,10 @@ discard block |
||
| 1248 | 1270 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">'; |
| 1249 | 1271 | |
| 1250 | 1272 | // Hopefully it exists. |
| 1251 | - if (isset($context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token'])) |
|
| 1252 | - echo ' |
|
| 1273 | + if (isset($context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token'])) { |
|
| 1274 | + echo ' |
|
| 1253 | 1275 | <input type="hidden" name="', $context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token_var'], '" value="', $context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token'], '">'; |
| 1276 | + } |
|
| 1254 | 1277 | |
| 1255 | 1278 | echo ' |
| 1256 | 1279 | </div><!-- .windowbg --> |
@@ -48,17 +48,19 @@ discard block |
||
| 48 | 48 | </a>'; |
| 49 | 49 | |
| 50 | 50 | // Has it outstanding posts for approval? |
| 51 | - if ($board['can_approve_posts'] && ($board['unapproved_posts'] || $board['unapproved_topics'])) |
|
| 52 | - echo ' |
|
| 51 | + if ($board['can_approve_posts'] && ($board['unapproved_posts'] || $board['unapproved_topics'])) { |
|
| 52 | + echo ' |
|
| 53 | 53 | <a href="', $scripturl, '?action=moderate;area=postmod;sa=', ($board['unapproved_topics'] > 0 ? 'topics' : 'posts'), ';brd=', $board['id'], ';', $context['session_var'], '=', $context['session_id'], '" title="', sprintf($txt['unapproved_posts'], $board['unapproved_topics'], $board['unapproved_posts']), '" class="moderation_link">(!)</a>'; |
| 54 | + } |
|
| 54 | 55 | |
| 55 | 56 | echo ' |
| 56 | 57 | <p class="board_description">', $board['description'], '</p>'; |
| 57 | 58 | |
| 58 | 59 | // Show the "Moderators: ". Each has name, href, link, and id. (but we're gonna use link_moderators.) |
| 59 | - if (!empty($board['moderators']) || !empty($board['moderator_groups'])) |
|
| 60 | - echo ' |
|
| 60 | + if (!empty($board['moderators']) || !empty($board['moderator_groups'])) { |
|
| 61 | + echo ' |
|
| 61 | 62 | <p class="moderators">', count($board['link_moderators']) === 1 ? $txt['moderator'] : $txt['moderators'], ': ', implode(', ', $board['link_moderators']), '</p>'; |
| 63 | + } |
|
| 62 | 64 | |
| 63 | 65 | // Show some basic information about the number of posts, etc. |
| 64 | 66 | echo ' |
@@ -70,9 +72,10 @@ discard block |
||
| 70 | 72 | </div> |
| 71 | 73 | <div class="lastpost lpr_border">'; |
| 72 | 74 | |
| 73 | - if (!empty($board['last_post']['id'])) |
|
| 74 | - echo ' |
|
| 75 | + if (!empty($board['last_post']['id'])) { |
|
| 76 | + echo ' |
|
| 75 | 77 | <p>', $board['last_post']['last_post_message'], '</p>'; |
| 78 | + } |
|
| 76 | 79 | |
| 77 | 80 | echo ' |
| 78 | 81 | </div>'; |
@@ -87,14 +90,16 @@ discard block |
||
| 87 | 90 | |
| 88 | 91 | foreach ($board['children'] as $child) |
| 89 | 92 | { |
| 90 | - if (!$child['is_redirect']) |
|
| 91 | - $child['link'] = ''. ($child['new'] ? '<a href="' . $scripturl . '?action=unread;board=' . $child['id'] . '" title="' . $txt['new_posts'] . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')"><span class="new_posts">' . $txt['new'] . '</span></a>' : '') . '<a href="' . $child['href'] . '" ' . ($child['new'] ? 'class="board_new_posts" ' : '') . 'title="' . ($child['new'] ? $txt['new_posts'] : $txt['old_posts']) . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')">' . $child['name'] . '</a>'; |
|
| 92 | - else |
|
| 93 | - $child['link'] = '<a href="' . $child['href'] . '" title="' . comma_format($child['posts']) . ' ' . $txt['redirects'] . '">' . $child['name'] . '</a>'; |
|
| 93 | + if (!$child['is_redirect']) { |
|
| 94 | + $child['link'] = ''. ($child['new'] ? '<a href="' . $scripturl . '?action=unread;board=' . $child['id'] . '" title="' . $txt['new_posts'] . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')"><span class="new_posts">' . $txt['new'] . '</span></a>' : '') . '<a href="' . $child['href'] . '" ' . ($child['new'] ? 'class="board_new_posts" ' : '') . 'title="' . ($child['new'] ? $txt['new_posts'] : $txt['old_posts']) . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')">' . $child['name'] . '</a>'; |
|
| 95 | + } else { |
|
| 96 | + $child['link'] = '<a href="' . $child['href'] . '" title="' . comma_format($child['posts']) . ' ' . $txt['redirects'] . '">' . $child['name'] . '</a>'; |
|
| 97 | + } |
|
| 94 | 98 | |
| 95 | 99 | // Has it posts awaiting approval? |
| 96 | - if ($child['can_approve_posts'] && ($child['unapproved_posts'] | $child['unapproved_topics'])) |
|
| 97 | - $child['link'] .= ' <a href="' . $scripturl . '?action=moderate;area=postmod;sa=' . ($child['unapproved_topics'] > 0 ? 'topics' : 'posts') . ';brd=' . $child['id'] . ';' . $context['session_var'] . '=' . $context['session_id'] . '" title="' . sprintf($txt['unapproved_posts'], $child['unapproved_topics'], $child['unapproved_posts']) . '" class="moderation_link">(!)</a>'; |
|
| 100 | + if ($child['can_approve_posts'] && ($child['unapproved_posts'] | $child['unapproved_topics'])) { |
|
| 101 | + $child['link'] .= ' <a href="' . $scripturl . '?action=moderate;area=postmod;sa=' . ($child['unapproved_topics'] > 0 ? 'topics' : 'posts') . ';brd=' . $child['id'] . ';' . $context['session_var'] . '=' . $context['session_id'] . '" title="' . sprintf($txt['unapproved_posts'], $child['unapproved_topics'], $child['unapproved_posts']) . '" class="moderation_link">(!)</a>'; |
|
| 102 | + } |
|
| 98 | 103 | |
| 99 | 104 | $children[] = $child['new'] ? '<span class="strong">' . $child['link'] . '</span>' : '<span>' . $child['link'] . '</span>'; |
| 100 | 105 | } |
@@ -114,8 +119,9 @@ discard block |
||
| 114 | 119 | } |
| 115 | 120 | |
| 116 | 121 | // They can only mark read if they are logged in and it's enabled! |
| 117 | - if (!$context['user']['is_logged']) |
|
| 118 | - unset($context['normal_buttons']['markread']); |
|
| 122 | + if (!$context['user']['is_logged']) { |
|
| 123 | + unset($context['normal_buttons']['markread']); |
|
| 124 | + } |
|
| 119 | 125 | |
| 120 | 126 | if (!$context['no_topic_listing']) |
| 121 | 127 | { |
@@ -142,13 +148,15 @@ discard block |
||
| 142 | 148 | <h3>', $context['name'], '</h3> |
| 143 | 149 | <p>'; |
| 144 | 150 | |
| 145 | - if ($context['description'] != '') |
|
| 146 | - echo ' |
|
| 151 | + if ($context['description'] != '') { |
|
| 152 | + echo ' |
|
| 147 | 153 | ', $context['description'], ' '; |
| 154 | + } |
|
| 148 | 155 | |
| 149 | - if (!empty($context['moderators'])) |
|
| 150 | - echo ' |
|
| 156 | + if (!empty($context['moderators'])) { |
|
| 157 | + echo ' |
|
| 151 | 158 | ', count($context['moderators']) === 1 ? $txt['moderator'] : $txt['moderators'], ': ', implode(', ', $context['link_moderators']), '.'; |
| 159 | + } |
|
| 152 | 160 | |
| 153 | 161 | echo ' |
| 154 | 162 | </p> |
@@ -156,9 +164,10 @@ discard block |
||
| 156 | 164 | } |
| 157 | 165 | |
| 158 | 166 | // If Quick Moderation is enabled start the form. |
| 159 | - if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] > 0 && !empty($context['topics'])) |
|
| 160 | - echo ' |
|
| 167 | + if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] > 0 && !empty($context['topics'])) { |
|
| 168 | + echo ' |
|
| 161 | 169 | <form action="', $scripturl, '?action=quickmod;board=', $context['current_board'], '.', $context['start'], '" method="post" accept-charset="', $context['character_set'], '" class="clear" name="quickModForm" id="quickModForm">'; |
| 170 | + } |
|
| 162 | 171 | |
| 163 | 172 | echo ' |
| 164 | 173 | <div id="messageindex">'; |
@@ -168,11 +177,11 @@ discard block |
||
| 168 | 177 | echo ' |
| 169 | 178 | <div class="information">'; |
| 170 | 179 | |
| 171 | - if ($settings['display_who_viewing'] == 1) |
|
| 172 | - echo count($context['view_members']), ' ', count($context['view_members']) === 1 ? $txt['who_member'] : $txt['members']; |
|
| 173 | - |
|
| 174 | - else |
|
| 175 | - echo empty($context['view_members_list']) ? '0 ' . $txt['members'] : implode(', ', $context['view_members_list']) . (empty($context['view_num_hidden']) || $context['can_moderate_forum'] ? '' : ' (+ ' . $context['view_num_hidden'] . ' ' . $txt['hidden'] . ')'); |
|
| 180 | + if ($settings['display_who_viewing'] == 1) { |
|
| 181 | + echo count($context['view_members']), ' ', count($context['view_members']) === 1 ? $txt['who_member'] : $txt['members']; |
|
| 182 | + } else { |
|
| 183 | + echo empty($context['view_members_list']) ? '0 ' . $txt['members'] : implode(', ', $context['view_members_list']) . (empty($context['view_num_hidden']) || $context['can_moderate_forum'] ? '' : ' (+ ' . $context['view_num_hidden'] . ' ' . $txt['hidden'] . ')'); |
|
| 184 | + } |
|
| 176 | 185 | echo $txt['who_and'], $context['view_num_guests'], ' ', $context['view_num_guests'] == 1 ? $txt['guest'] : $txt['guests'], $txt['who_viewing_board']; |
| 177 | 186 | |
| 178 | 187 | echo ' |
@@ -192,22 +201,25 @@ discard block |
||
| 192 | 201 | <div class="lastpost">', $context['topics_headers']['last_post'], '</div>'; |
| 193 | 202 | |
| 194 | 203 | // Show a "select all" box for quick moderation? |
| 195 | - if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] == 1) |
|
| 196 | - echo ' |
|
| 204 | + if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] == 1) { |
|
| 205 | + echo ' |
|
| 197 | 206 | <div class="moderation"> |
| 198 | 207 | <input type="checkbox" onclick="invertAll(this, this.form, \'topics[]\');"> |
| 199 | 208 | </div>'; |
| 209 | + } |
|
| 200 | 210 | |
| 201 | 211 | // If it's on in "image" mode, don't show anything but the column. |
| 202 | - elseif (!empty($context['can_quick_mod'])) |
|
| 203 | - echo ' |
|
| 212 | + elseif (!empty($context['can_quick_mod'])) { |
|
| 213 | + echo ' |
|
| 204 | 214 | <div class="moderation"> </div>'; |
| 215 | + } |
|
| 205 | 216 | } |
| 206 | 217 | |
| 207 | 218 | // No topics.... just say, "sorry bub". |
| 208 | - else |
|
| 209 | - echo ' |
|
| 219 | + else { |
|
| 220 | + echo ' |
|
| 210 | 221 | <h3 class="titlebg">', $txt['topic_alert_none'], '</h3>'; |
| 222 | + } |
|
| 211 | 223 | |
| 212 | 224 | echo ' |
| 213 | 225 | </div><!-- #topic_header -->'; |
@@ -240,21 +252,26 @@ discard block |
||
| 240 | 252 | echo ' |
| 241 | 253 | <div class="icons floatright">'; |
| 242 | 254 | |
| 243 | - if ($topic['is_watched']) |
|
| 244 | - echo ' |
|
| 255 | + if ($topic['is_watched']) { |
|
| 256 | + echo ' |
|
| 245 | 257 | <span class="generic_icons watch" title="', $txt['watching_this_topic'], '"></span>'; |
| 246 | - if ($topic['is_locked']) |
|
| 247 | - echo ' |
|
| 258 | + } |
|
| 259 | + if ($topic['is_locked']) { |
|
| 260 | + echo ' |
|
| 248 | 261 | <span class="generic_icons lock"></span>'; |
| 249 | - if ($topic['is_sticky']) |
|
| 250 | - echo ' |
|
| 262 | + } |
|
| 263 | + if ($topic['is_sticky']) { |
|
| 264 | + echo ' |
|
| 251 | 265 | <span class="generic_icons sticky"></span>'; |
| 252 | - if ($topic['is_redirect']) |
|
| 253 | - echo ' |
|
| 266 | + } |
|
| 267 | + if ($topic['is_redirect']) { |
|
| 268 | + echo ' |
|
| 254 | 269 | <span class="generic_icons move"></span>'; |
| 255 | - if ($topic['is_poll']) |
|
| 256 | - echo ' |
|
| 270 | + } |
|
| 271 | + if ($topic['is_poll']) { |
|
| 272 | + echo ' |
|
| 257 | 273 | <span class="generic_icons poll"></span>'; |
| 274 | + } |
|
| 258 | 275 | |
| 259 | 276 | echo ' |
| 260 | 277 | </div>'; |
@@ -284,26 +301,31 @@ discard block |
||
| 284 | 301 | echo ' |
| 285 | 302 | <div class="moderation">'; |
| 286 | 303 | |
| 287 | - if ($options['display_quick_mod'] == 1) |
|
| 288 | - echo ' |
|
| 304 | + if ($options['display_quick_mod'] == 1) { |
|
| 305 | + echo ' |
|
| 289 | 306 | <input type="checkbox" name="topics[]" value="', $topic['id'], '">'; |
| 290 | - else |
|
| 307 | + } else |
|
| 291 | 308 | { |
| 292 | 309 | // Check permissions on each and show only the ones they are allowed to use. |
| 293 | - if ($topic['quick_mod']['remove']) |
|
| 294 | - echo '<a href="', $scripturl, '?action=quickmod;board=', $context['current_board'], '.', $context['start'], ';actions%5B', $topic['id'], '%5D=remove;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons delete" title="', $txt['remove_topic'], '"></span></a>'; |
|
| 310 | + if ($topic['quick_mod']['remove']) { |
|
| 311 | + echo '<a href="', $scripturl, '?action=quickmod;board=', $context['current_board'], '.', $context['start'], ';actions%5B', $topic['id'], '%5D=remove;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons delete" title="', $txt['remove_topic'], '"></span></a>'; |
|
| 312 | + } |
|
| 295 | 313 | |
| 296 | - if ($topic['quick_mod']['lock']) |
|
| 297 | - echo '<a href="', $scripturl, '?action=quickmod;board=', $context['current_board'], '.', $context['start'], ';actions%5B', $topic['id'], '%5D=lock;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons lock" title="', $topic['is_locked'] ? $txt['set_unlock'] : $txt['set_lock'], '"></span></a>'; |
|
| 314 | + if ($topic['quick_mod']['lock']) { |
|
| 315 | + echo '<a href="', $scripturl, '?action=quickmod;board=', $context['current_board'], '.', $context['start'], ';actions%5B', $topic['id'], '%5D=lock;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons lock" title="', $topic['is_locked'] ? $txt['set_unlock'] : $txt['set_lock'], '"></span></a>'; |
|
| 316 | + } |
|
| 298 | 317 | |
| 299 | - if ($topic['quick_mod']['lock'] || $topic['quick_mod']['remove']) |
|
| 300 | - echo '<br>'; |
|
| 318 | + if ($topic['quick_mod']['lock'] || $topic['quick_mod']['remove']) { |
|
| 319 | + echo '<br>'; |
|
| 320 | + } |
|
| 301 | 321 | |
| 302 | - if ($topic['quick_mod']['sticky']) |
|
| 303 | - echo '<a href="', $scripturl, '?action=quickmod;board=', $context['current_board'], '.', $context['start'], ';actions%5B', $topic['id'], '%5D=sticky;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons sticky" title="', $topic['is_sticky'] ? $txt['set_nonsticky'] : $txt['set_sticky'], '"></span></a>'; |
|
| 322 | + if ($topic['quick_mod']['sticky']) { |
|
| 323 | + echo '<a href="', $scripturl, '?action=quickmod;board=', $context['current_board'], '.', $context['start'], ';actions%5B', $topic['id'], '%5D=sticky;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons sticky" title="', $topic['is_sticky'] ? $txt['set_nonsticky'] : $txt['set_sticky'], '"></span></a>'; |
|
| 324 | + } |
|
| 304 | 325 | |
| 305 | - if ($topic['quick_mod']['move']) |
|
| 306 | - echo '<a href="', $scripturl, '?action=movetopic;current_board=', $context['current_board'], ';board=', $context['current_board'], '.', $context['start'], ';topic=', $topic['id'], '.0"><span class="generic_icons move" title="', $txt['move_topic'], '"></span></a>'; |
|
| 326 | + if ($topic['quick_mod']['move']) { |
|
| 327 | + echo '<a href="', $scripturl, '?action=movetopic;current_board=', $context['current_board'], ';board=', $context['current_board'], '.', $context['start'], ';topic=', $topic['id'], '.0"><span class="generic_icons move" title="', $txt['move_topic'], '"></span></a>'; |
|
| 328 | + } |
|
| 307 | 329 | } |
| 308 | 330 | echo ' |
| 309 | 331 | </div><!-- .moderation -->'; |
@@ -321,18 +343,20 @@ discard block |
||
| 321 | 343 | <select class="qaction" name="qaction"', $context['can_move'] ? ' onchange="this.form.move_to.disabled = (this.options[this.selectedIndex].value != \'move\');"' : '', '> |
| 322 | 344 | <option value="">--------</option>'; |
| 323 | 345 | |
| 324 | - foreach ($context['qmod_actions'] as $qmod_action) |
|
| 325 | - if ($context['can_' . $qmod_action]) |
|
| 346 | + foreach ($context['qmod_actions'] as $qmod_action) { |
|
| 347 | + if ($context['can_' . $qmod_action]) |
|
| 326 | 348 | echo ' |
| 327 | 349 | <option value="' . $qmod_action . '">' . $txt['quick_mod_' . $qmod_action] . '</option>'; |
| 350 | + } |
|
| 328 | 351 | |
| 329 | 352 | echo ' |
| 330 | 353 | </select>'; |
| 331 | 354 | |
| 332 | 355 | // Show a list of boards they can move the topic to. |
| 333 | - if ($context['can_move']) |
|
| 334 | - echo ' |
|
| 356 | + if ($context['can_move']) { |
|
| 357 | + echo ' |
|
| 335 | 358 | <span id="quick_mod_jump_to"> </span>'; |
| 359 | + } |
|
| 336 | 360 | |
| 337 | 361 | echo ' |
| 338 | 362 | <input type="submit" value="', $txt['quick_mod_go'], '" onclick="return document.forms.quickModForm.qaction.value != \'\' && confirm(\'', $txt['quickmod_confirm'], '\');" class="button qaction"> |
@@ -343,10 +367,11 @@ discard block |
||
| 343 | 367 | </div><!-- #messageindex -->'; |
| 344 | 368 | |
| 345 | 369 | // Finish off the form - again. |
| 346 | - if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] > 0 && !empty($context['topics'])) |
|
| 347 | - echo ' |
|
| 370 | + if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] > 0 && !empty($context['topics'])) { |
|
| 371 | + echo ' |
|
| 348 | 372 | <input type="hidden" name="' . $context['session_var'] . '" value="' . $context['session_id'] . '"> |
| 349 | 373 | </form>'; |
| 374 | + } |
|
| 350 | 375 | |
| 351 | 376 | // Mobile action buttons (bottom) |
| 352 | 377 | echo ' |
@@ -368,8 +393,8 @@ discard block |
||
| 368 | 393 | // Show breadcrumbs at the bottom too. |
| 369 | 394 | theme_linktree(); |
| 370 | 395 | |
| 371 | - if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics']) && $context['can_move']) |
|
| 372 | - echo ' |
|
| 396 | + if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics']) && $context['can_move']) { |
|
| 397 | + echo ' |
|
| 373 | 398 | <script> |
| 374 | 399 | if (typeof(window.XMLHttpRequest) != "undefined") |
| 375 | 400 | aJumpTo[aJumpTo.length] = new JumpTo({ |
@@ -388,6 +413,7 @@ discard block |
||
| 388 | 413 | sCustomName: "move_to" |
| 389 | 414 | }); |
| 390 | 415 | </script>'; |
| 416 | + } |
|
| 391 | 417 | |
| 392 | 418 | // Javascript for inline editing. |
| 393 | 419 | echo ' |
@@ -424,8 +450,8 @@ discard block |
||
| 424 | 450 | <div class="information"> |
| 425 | 451 | <p class="floatright" id="message_index_jump_to"> </p>'; |
| 426 | 452 | |
| 427 | - if (empty($context['no_topic_listing'])) |
|
| 428 | - echo ' |
|
| 453 | + if (empty($context['no_topic_listing'])) { |
|
| 454 | + echo ' |
|
| 429 | 455 | <p class="floatleft">', !empty($modSettings['enableParticipation']) && $context['user']['is_logged'] ? ' |
| 430 | 456 | <img src="' . $settings['images_url'] . '/icons/profile_sm.png" alt="" class="centericon"> ' . $txt['participation_caption'] . '<br>' : '', ' |
| 431 | 457 | '. ($modSettings['pollMode'] == '1' ? '<span class="generic_icons poll centericon"></span> ' . $txt['poll'] : '') . '<br> |
@@ -435,9 +461,10 @@ discard block |
||
| 435 | 461 | <span class="generic_icons lock centericon"></span> ' . $txt['locked_topic'] . '<br> |
| 436 | 462 | <span class="generic_icons sticky centericon"></span> ' . $txt['sticky_topic'] . '<br> |
| 437 | 463 | </p>'; |
| 464 | + } |
|
| 438 | 465 | |
| 439 | - if (!empty($context['jump_to'])) |
|
| 440 | - echo ' |
|
| 466 | + if (!empty($context['jump_to'])) { |
|
| 467 | + echo ' |
|
| 441 | 468 | <script> |
| 442 | 469 | if (typeof(window.XMLHttpRequest) != "undefined") |
| 443 | 470 | aJumpTo[aJumpTo.length] = new JumpTo({ |
@@ -453,6 +480,7 @@ discard block |
||
| 453 | 480 | sGoButtonLabel: "', $txt['quick_mod_go'], '" |
| 454 | 481 | }); |
| 455 | 482 | </script>'; |
| 483 | + } |
|
| 456 | 484 | |
| 457 | 485 | echo ' |
| 458 | 486 | <br class="clear"> |
@@ -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" style="min-height: 64px; max-height: 64px; min-width: 50%; max-width: 99%;">', $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" style="min-height: 64px; max-height: 64px; min-width: 50%; max-width: 99%;">', $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> |
@@ -55,9 +55,10 @@ discard block |
||
| 55 | 55 | <legend>', $txt['membergroups_edit_select_group_type'], '</legend> |
| 56 | 56 | <label for="group_type_private"><input type="radio" name="group_type" id="group_type_private" value="0" checked onclick="swapPostGroup(0);">', $txt['membergroups_group_type_private'], '</label><br>'; |
| 57 | 57 | |
| 58 | - if ($context['allow_protected']) |
|
| 59 | - echo ' |
|
| 58 | + if ($context['allow_protected']) { |
|
| 59 | + echo ' |
|
| 60 | 60 | <label for="group_type_protected"><input type="radio" name="group_type" id="group_type_protected" value="1" onclick="swapPostGroup(0);">', $txt['membergroups_group_type_protected'], '</label><br>'; |
| 61 | + } |
|
| 61 | 62 | |
| 62 | 63 | echo ' |
| 63 | 64 | <label for="group_type_request"><input type="radio" name="group_type" id="group_type_request" value="2" onclick="swapPostGroup(0);">', $txt['membergroups_group_type_request'], '</label><br> |
@@ -67,14 +68,15 @@ discard block |
||
| 67 | 68 | </dd>'; |
| 68 | 69 | } |
| 69 | 70 | |
| 70 | - if ($context['post_group'] || $context['undefined_group']) |
|
| 71 | - echo ' |
|
| 71 | + if ($context['post_group'] || $context['undefined_group']) { |
|
| 72 | + echo ' |
|
| 72 | 73 | <dt id="min_posts_text"> |
| 73 | 74 | <strong>', $txt['membergroups_min_posts'], ':</strong> |
| 74 | 75 | </dt> |
| 75 | 76 | <dd> |
| 76 | 77 | <input type="number" name="min_posts" id="min_posts_input" size="5"> |
| 77 | 78 | </dd>'; |
| 79 | + } |
|
| 78 | 80 | |
| 79 | 81 | if (!$context['post_group'] || !empty($modSettings['permission_enable_postgroups'])) |
| 80 | 82 | { |
@@ -92,9 +94,10 @@ discard block |
||
| 92 | 94 | <option value="-1">', $txt['membergroups_guests'], '</option> |
| 93 | 95 | <option value="0" selected>', $txt['membergroups_members'], '</option>'; |
| 94 | 96 | |
| 95 | - foreach ($context['groups'] as $group) |
|
| 96 | - echo ' |
|
| 97 | + foreach ($context['groups'] as $group) { |
|
| 98 | + echo ' |
|
| 97 | 99 | <option value="', $group['id'], '">', $group['name'], '</option>'; |
| 100 | + } |
|
| 98 | 101 | |
| 99 | 102 | echo ' |
| 100 | 103 | </select> |
@@ -105,9 +108,10 @@ discard block |
||
| 105 | 108 | <option value="-1">', $txt['membergroups_guests'], '</option> |
| 106 | 109 | <option value="0" selected>', $txt['membergroups_members'], '</option>'; |
| 107 | 110 | |
| 108 | - foreach ($context['groups'] as $group) |
|
| 109 | - echo ' |
|
| 111 | + foreach ($context['groups'] as $group) { |
|
| 112 | + echo ' |
|
| 110 | 113 | <option value="', $group['id'], '">', $group['name'], '</option>'; |
| 114 | + } |
|
| 111 | 115 | |
| 112 | 116 | echo ' |
| 113 | 117 | </select> |
@@ -183,8 +187,8 @@ discard block |
||
| 183 | 187 | <input type="text" name="group_name" id="group_name_input" value="', $context['group']['editable_name'], '" size="30"> |
| 184 | 188 | </dd>'; |
| 185 | 189 | |
| 186 | - if ($context['group']['id'] != 3 && $context['group']['id'] != 4) |
|
| 187 | - echo ' |
|
| 190 | + if ($context['group']['id'] != 3 && $context['group']['id'] != 4) { |
|
| 191 | + echo ' |
|
| 188 | 192 | |
| 189 | 193 | <dt id="group_desc_text"> |
| 190 | 194 | <label for="group_desc_input"><strong>', $txt['membergroups_edit_desc'], ':</strong></label> |
@@ -192,6 +196,7 @@ discard block |
||
| 192 | 196 | <dd> |
| 193 | 197 | <textarea name="group_desc" id="group_desc_input" rows="4" cols="40">', $context['group']['description'], '</textarea> |
| 194 | 198 | </dd>'; |
| 199 | + } |
|
| 195 | 200 | |
| 196 | 201 | // Group type... |
| 197 | 202 | if ($context['group']['allow_post_group']) |
@@ -205,9 +210,10 @@ discard block |
||
| 205 | 210 | <legend>', $txt['membergroups_edit_select_group_type'], '</legend> |
| 206 | 211 | <label for="group_type_private"><input type="radio" name="group_type" id="group_type_private" value="0"', !$context['group']['is_post_group'] && $context['group']['type'] == 0 ? ' checked' : '', ' onclick="swapPostGroup(0);">', $txt['membergroups_group_type_private'], '</label><br>'; |
| 207 | 212 | |
| 208 | - if ($context['group']['allow_protected']) |
|
| 209 | - echo ' |
|
| 213 | + if ($context['group']['allow_protected']) { |
|
| 214 | + echo ' |
|
| 210 | 215 | <label for="group_type_protected"><input type="radio" name="group_type" id="group_type_protected" value="1"', $context['group']['type'] == 1 ? ' checked' : '', ' onclick="swapPostGroup(0);">', $txt['membergroups_group_type_protected'], '</label><br>'; |
| 216 | + } |
|
| 211 | 217 | |
| 212 | 218 | echo ' |
| 213 | 219 | <label for="group_type_request"><input type="radio" name="group_type" id="group_type_request" value="2"', $context['group']['type'] == 2 ? ' checked' : '', ' onclick="swapPostGroup(0);">', $txt['membergroups_group_type_request'], '</label><br> |
@@ -217,8 +223,8 @@ discard block |
||
| 217 | 223 | </dd>'; |
| 218 | 224 | } |
| 219 | 225 | |
| 220 | - if ($context['group']['id'] != 3 && $context['group']['id'] != 4) |
|
| 221 | - echo ' |
|
| 226 | + if ($context['group']['id'] != 3 && $context['group']['id'] != 4) { |
|
| 227 | + echo ' |
|
| 222 | 228 | <dt id="group_moderators_text"> |
| 223 | 229 | <label for="group_moderators"><strong>', $txt['moderators'], ':</strong></label> |
| 224 | 230 | </dt> |
@@ -236,6 +242,7 @@ discard block |
||
| 236 | 242 | <option value="2"', $context['group']['hidden'] == 2 ? ' selected' : '', '>', $txt['membergroups_edit_hidden_all'], '</option> |
| 237 | 243 | </select> |
| 238 | 244 | </dd>'; |
| 245 | + } |
|
| 239 | 246 | |
| 240 | 247 | // Can they inherit permissions? |
| 241 | 248 | if ($context['group']['id'] > 1 && $context['group']['id'] != 3) |
@@ -252,9 +259,10 @@ discard block |
||
| 252 | 259 | <option value="0"', $context['group']['inherited_from'] == 0 ? ' selected' : '', '>', $txt['membergroups_edit_inherit_permissions_from'], ': ', $txt['membergroups_members'], '</option>'; |
| 253 | 260 | |
| 254 | 261 | // For all the inheritable groups show an option. |
| 255 | - foreach ($context['inheritable_groups'] as $id => $group) |
|
| 256 | - echo ' |
|
| 262 | + foreach ($context['inheritable_groups'] as $id => $group) { |
|
| 263 | + echo ' |
|
| 257 | 264 | <option value="', $id, '"', $context['group']['inherited_from'] == $id ? ' selected' : '', '>', $txt['membergroups_edit_inherit_permissions_from'], ': ', $group, '</option>'; |
| 265 | + } |
|
| 258 | 266 | |
| 259 | 267 | echo ' |
| 260 | 268 | </select> |
@@ -262,8 +270,8 @@ discard block |
||
| 262 | 270 | </dd>'; |
| 263 | 271 | } |
| 264 | 272 | |
| 265 | - if ($context['group']['allow_post_group']) |
|
| 266 | - echo ' |
|
| 273 | + if ($context['group']['allow_post_group']) { |
|
| 274 | + echo ' |
|
| 267 | 275 | |
| 268 | 276 | <dt id="min_posts_text"> |
| 269 | 277 | <label for="min_posts_input"><strong>', $txt['membergroups_min_posts'], ':</strong></label> |
@@ -271,6 +279,7 @@ discard block |
||
| 271 | 279 | <dd> |
| 272 | 280 | <input type="number" name="min_posts" id="min_posts_input"', $context['group']['is_post_group'] ? ' value="' . $context['group']['min_posts'] . '"' : '', ' size="6"> |
| 273 | 281 | </dd>'; |
| 282 | + } |
|
| 274 | 283 | |
| 275 | 284 | echo ' |
| 276 | 285 | <dt> |
@@ -313,9 +322,10 @@ discard block |
||
| 313 | 322 | } |
| 314 | 323 | |
| 315 | 324 | // No? Hide the entire control. |
| 316 | - else |
|
| 317 | - echo ' |
|
| 325 | + else { |
|
| 326 | + echo ' |
|
| 318 | 327 | <input type="hidden" name="icon_image" value="">'; |
| 328 | + } |
|
| 319 | 329 | |
| 320 | 330 | echo ' |
| 321 | 331 | <dt> |
@@ -327,8 +337,8 @@ discard block |
||
| 327 | 337 | </dd>'; |
| 328 | 338 | |
| 329 | 339 | // Force 2FA for this membergroup? |
| 330 | - if (!empty($modSettings['tfa_mode']) && $modSettings['tfa_mode'] == 2) |
|
| 331 | - echo ' |
|
| 340 | + if (!empty($modSettings['tfa_mode']) && $modSettings['tfa_mode'] == 2) { |
|
| 341 | + echo ' |
|
| 332 | 342 | <dt> |
| 333 | 343 | <label for="group_tfa_force_input"><strong>', $txt['membergroups_tfa_force'], ':</strong></label><br> |
| 334 | 344 | <span class="smalltext">', $txt['membergroups_tfa_force_note'], '</span> |
@@ -336,6 +346,7 @@ discard block |
||
| 336 | 346 | <dd> |
| 337 | 347 | <input type="checkbox" name="group_tfa_force"', $context['group']['tfa_required'] ? ' checked' : '', '> |
| 338 | 348 | </dd>'; |
| 349 | + } |
|
| 339 | 350 | |
| 340 | 351 | if (!empty($context['categories'])) |
| 341 | 352 | { |
@@ -346,11 +357,11 @@ discard block |
||
| 346 | 357 | </dt> |
| 347 | 358 | <dd>'; |
| 348 | 359 | |
| 349 | - if (!empty($context['can_manage_boards'])) |
|
| 350 | - echo $txt['membergroups_can_manage_access']; |
|
| 351 | - |
|
| 352 | - else |
|
| 353 | - template_add_edit_group_boards_list(); |
|
| 360 | + if (!empty($context['can_manage_boards'])) { |
|
| 361 | + echo $txt['membergroups_can_manage_access']; |
|
| 362 | + } else { |
|
| 363 | + template_add_edit_group_boards_list(); |
|
| 364 | + } |
|
| 354 | 365 | |
| 355 | 366 | echo ' |
| 356 | 367 | </dd>'; |
@@ -379,20 +390,21 @@ discard block |
||
| 379 | 390 | sItemListContainerId: \'moderator_container\', |
| 380 | 391 | aListItems: ['; |
| 381 | 392 | |
| 382 | - foreach ($context['group']['moderators'] as $id_member => $member_name) |
|
| 383 | - echo ' |
|
| 393 | + foreach ($context['group']['moderators'] as $id_member => $member_name) { |
|
| 394 | + echo ' |
|
| 384 | 395 | { |
| 385 | 396 | sItemId: ', JavaScriptEscape($id_member), ', |
| 386 | 397 | sItemName: ', JavaScriptEscape($member_name), ' |
| 387 | 398 | }', $id_member == $context['group']['last_moderator_id'] ? '' : ','; |
| 399 | + } |
|
| 388 | 400 | |
| 389 | 401 | echo ' |
| 390 | 402 | ] |
| 391 | 403 | }); |
| 392 | 404 | </script>'; |
| 393 | 405 | |
| 394 | - if ($context['group']['allow_post_group']) |
|
| 395 | - echo ' |
|
| 406 | + if ($context['group']['allow_post_group']) { |
|
| 407 | + echo ' |
|
| 396 | 408 | <script> |
| 397 | 409 | function swapPostGroup(isChecked) |
| 398 | 410 | { |
@@ -440,7 +452,8 @@ discard block |
||
| 440 | 452 | |
| 441 | 453 | swapPostGroup(', $context['group']['is_post_group'] ? 'true' : 'false', '); |
| 442 | 454 | </script>'; |
| 443 | -} |
|
| 455 | + } |
|
| 456 | + } |
|
| 444 | 457 | |
| 445 | 458 | /** |
| 446 | 459 | * The template for determining which boards a group has access to. |
@@ -458,13 +471,13 @@ discard block |
||
| 458 | 471 | |
| 459 | 472 | foreach ($context['categories'] as $category) |
| 460 | 473 | { |
| 461 | - if (empty($modSettings['deny_boards_access'])) |
|
| 462 | - echo ' |
|
| 474 | + if (empty($modSettings['deny_boards_access'])) { |
|
| 475 | + echo ' |
|
| 463 | 476 | <li class="category"> |
| 464 | 477 | <a href="javascript:void(0);" onclick="selectBoards([', implode(', ', $category['child_ids']), '], \'new_group\'); return false;"><strong>', $category['name'], '</strong></a> |
| 465 | 478 | <ul style="width:100%">'; |
| 466 | - else |
|
| 467 | - echo ' |
|
| 479 | + } else { |
|
| 480 | + echo ' |
|
| 468 | 481 | <li class="category"> |
| 469 | 482 | <strong>', $category['name'], '</strong> |
| 470 | 483 | <span class="select_all_box"> |
@@ -477,16 +490,17 @@ discard block |
||
| 477 | 490 | </select> |
| 478 | 491 | </span> |
| 479 | 492 | <ul style="width:100%" id="boards_list_', $category['id'], '">'; |
| 493 | + } |
|
| 480 | 494 | |
| 481 | 495 | foreach ($category['boards'] as $board) |
| 482 | 496 | { |
| 483 | - if (empty($modSettings['deny_boards_access'])) |
|
| 484 | - echo ' |
|
| 497 | + if (empty($modSettings['deny_boards_access'])) { |
|
| 498 | + echo ' |
|
| 485 | 499 | <li class="board" style="margin-', $context['right_to_left'] ? 'right' : 'left', ': ', $board['child_level'], 'em;"> |
| 486 | 500 | <input type="checkbox" name="boardaccess[', $board['id'], ']" id="brd', $board['id'], '" value="allow"', $board['allow'] ? ' checked' : '', '> <label for="brd', $board['id'], '">', $board['name'], '</label> |
| 487 | 501 | </li>'; |
| 488 | - else |
|
| 489 | - echo ' |
|
| 502 | + } else { |
|
| 503 | + echo ' |
|
| 490 | 504 | <li class="board" style="width:100%"> |
| 491 | 505 | <span style="margin-', $context['right_to_left'] ? 'right' : 'left', ': ', $board['child_level'], 'em;">', $board['name'], ': </span> |
| 492 | 506 | <span style="width:50%;float:right"> |
@@ -495,6 +509,7 @@ discard block |
||
| 495 | 509 | <input type="radio" name="boardaccess[', $board['id'], ']" id="deny_brd', $board['id'], '" value="deny"', $board['deny'] ? ' checked' : '', '> <label for="deny_brd', $board['id'], '">', $txt['permissions_option_deny'], '</label> |
| 496 | 510 | </span> |
| 497 | 511 | </li>'; |
| 512 | + } |
|
| 498 | 513 | } |
| 499 | 514 | |
| 500 | 515 | echo ' |
@@ -505,14 +520,14 @@ discard block |
||
| 505 | 520 | echo ' |
| 506 | 521 | </ul>'; |
| 507 | 522 | |
| 508 | - if (empty($modSettings['deny_boards_access'])) |
|
| 509 | - echo ' |
|
| 523 | + if (empty($modSettings['deny_boards_access'])) { |
|
| 524 | + echo ' |
|
| 510 | 525 | <br class="clear"><br> |
| 511 | 526 | <input type="checkbox" id="checkall_check" onclick="invertAll(this, this.form, \'boardaccess\');"> |
| 512 | 527 | <label for="checkall_check"><em>', $txt['check_all'], '</em></label> |
| 513 | 528 | </fieldset>'; |
| 514 | - else |
|
| 515 | - echo ' |
|
| 529 | + } else { |
|
| 530 | + echo ' |
|
| 516 | 531 | <br class="clear"> |
| 517 | 532 | <span class="select_all_box"> |
| 518 | 533 | <em>', $txt['all'], ': </em> |
@@ -528,15 +543,17 @@ discard block |
||
| 528 | 543 | }); |
| 529 | 544 | }); |
| 530 | 545 | </script>'; |
| 546 | + } |
|
| 531 | 547 | |
| 532 | - if ($collapse) |
|
| 533 | - echo ' |
|
| 548 | + if ($collapse) { |
|
| 549 | + echo ' |
|
| 534 | 550 | <a href="javascript:void(0);" onclick="document.getElementById(\'visible_boards\').style.display = \'block\'; document.getElementById(\'visible_boards_link\').style.display = \'none\'; return false;" id="visible_boards_link" style="display: none;">[ ', $txt['membergroups_select_visible_boards'], ' ]</a> |
| 535 | 551 | <script> |
| 536 | 552 | document.getElementById("visible_boards_link").style.display = ""; |
| 537 | 553 | document.getElementById("visible_boards").style.display = "none"; |
| 538 | 554 | </script>'; |
| 539 | -} |
|
| 555 | + } |
|
| 556 | + } |
|
| 540 | 557 | |
| 541 | 558 | /** |
| 542 | 559 | * Templatine for viewing the members of a group. |
@@ -561,14 +578,15 @@ discard block |
||
| 561 | 578 | </dd>'; |
| 562 | 579 | |
| 563 | 580 | // Any description to show? |
| 564 | - if (!empty($context['group']['description'])) |
|
| 565 | - echo ' |
|
| 581 | + if (!empty($context['group']['description'])) { |
|
| 582 | + echo ' |
|
| 566 | 583 | <dt> |
| 567 | 584 | <strong>' . $txt['membergroups_members_description'] . ':</strong> |
| 568 | 585 | </dt> |
| 569 | 586 | <dd> |
| 570 | 587 | ', $context['group']['description'], ' |
| 571 | 588 | </dd>'; |
| 589 | + } |
|
| 572 | 590 | |
| 573 | 591 | echo ' |
| 574 | 592 | <dt> |
@@ -582,8 +600,9 @@ discard block |
||
| 582 | 600 | if (!empty($context['group']['moderators'])) |
| 583 | 601 | { |
| 584 | 602 | $moderators = array(); |
| 585 | - foreach ($context['group']['moderators'] as $moderator) |
|
| 586 | - $moderators[] = '<a href="' . $scripturl . '?action=profile;u=' . $moderator['id'] . '">' . $moderator['name'] . '</a>'; |
|
| 603 | + foreach ($context['group']['moderators'] as $moderator) { |
|
| 604 | + $moderators[] = '<a href="' . $scripturl . '?action=profile;u=' . $moderator['id'] . '">' . $moderator['name'] . '</a>'; |
|
| 605 | + } |
|
| 587 | 606 | |
| 588 | 607 | echo ' |
| 589 | 608 | <dt> |
@@ -608,9 +627,10 @@ discard block |
||
| 608 | 627 | <tr class="title_bar"> |
| 609 | 628 | <th><a href="', $scripturl, '?action=', $context['current_action'], (isset($context['admin_area']) ? ';area=' . $context['admin_area'] : ''), ';sa=members;start=', $context['start'], ';sort=name', $context['sort_by'] == 'name' && $context['sort_direction'] == 'up' ? ';desc' : '', ';group=', $context['group']['id'], '">', $txt['name'], $context['sort_by'] == 'name' ? ' <span class="generic_icons sort_' . $context['sort_direction'] . '"></span>' : '', '</a></th>'; |
| 610 | 629 | |
| 611 | - if ($context['can_send_email']) |
|
| 612 | - echo ' |
|
| 630 | + if ($context['can_send_email']) { |
|
| 631 | + echo ' |
|
| 613 | 632 | <th><a href="', $scripturl, '?action=', $context['current_action'], (isset($context['admin_area']) ? ';area=' . $context['admin_area'] : ''), ';sa=members;start=', $context['start'], ';sort=email', $context['sort_by'] == 'email' && $context['sort_direction'] == 'up' ? ';desc' : '', ';group=', $context['group']['id'], '">', $txt['email'], $context['sort_by'] == 'email' ? ' <span class="generic_icons sort_' . $context['sort_direction'] . '"></span>' : '', '</a></th>'; |
| 633 | + } |
|
| 614 | 634 | |
| 615 | 635 | echo ' |
| 616 | 636 | <th><a href="', $scripturl, '?action=', $context['current_action'], (isset($context['admin_area']) ? ';area=' . $context['admin_area'] : ''), ';sa=members;start=', $context['start'], ';sort=active', $context['sort_by'] == 'active' && $context['sort_direction'] == 'up' ? ';desc' : '', ';group=', $context['group']['id'], '">', $txt['membergroups_members_last_active'], $context['sort_by'] == 'active' ? '<span class="generic_icons sort_' . $context['sort_direction'] . '"></span>' : '', '</a></th> |
@@ -619,19 +639,21 @@ discard block |
||
| 619 | 639 | <a href="', $scripturl, '?action=', $context['current_action'], (isset($context['admin_area']) ? ';area=' . $context['admin_area'] : ''), ';sa=members;start=', $context['start'], ';sort=posts', $context['sort_by'] == 'posts' && $context['sort_direction'] == 'up' ? ';desc' : '', ';group=', $context['group']['id'], '">', $txt['posts'], $context['sort_by'] == 'posts' ? ' <span class="generic_icons sort_' . $context['sort_direction'] . '"></span>' : '', '</a> |
| 620 | 640 | </th>'; |
| 621 | 641 | |
| 622 | - if (!empty($context['group']['assignable'])) |
|
| 623 | - echo ' |
|
| 642 | + if (!empty($context['group']['assignable'])) { |
|
| 643 | + echo ' |
|
| 624 | 644 | <th style="width: 4%"><input type="checkbox" onclick="invertAll(this, this.form);"></th>'; |
| 645 | + } |
|
| 625 | 646 | echo ' |
| 626 | 647 | </tr> |
| 627 | 648 | </thead> |
| 628 | 649 | <tbody>'; |
| 629 | 650 | |
| 630 | - if (empty($context['members'])) |
|
| 631 | - echo ' |
|
| 651 | + if (empty($context['members'])) { |
|
| 652 | + echo ' |
|
| 632 | 653 | <tr class="windowbg"> |
| 633 | 654 | <td colspan="6">', $txt['membergroups_members_no_members'], '</td> |
| 634 | 655 | </tr>'; |
| 656 | + } |
|
| 635 | 657 | |
| 636 | 658 | foreach ($context['members'] as $member) |
| 637 | 659 | { |
@@ -652,9 +674,10 @@ discard block |
||
| 652 | 674 | <td>', $member['registered'], '</td> |
| 653 | 675 | <td', empty($context['group']['assignable']) ? ' colspan="2"' : '', '>', $member['posts'], '</td>'; |
| 654 | 676 | |
| 655 | - if (!empty($context['group']['assignable'])) |
|
| 656 | - echo ' |
|
| 677 | + if (!empty($context['group']['assignable'])) { |
|
| 678 | + echo ' |
|
| 657 | 679 | <td style="width: 4%"><input type="checkbox" name="rem[]" value="', $member['id'], '" ', ($context['user']['id'] == $member['id'] && $context['group']['id'] == 1 ? 'onclick="if (this.checked) return confirm(\'' . $txt['membergroups_members_deadmin_confirm'] . '\')" ' : ''), '/></td>'; |
| 680 | + } |
|
| 658 | 681 | echo ' |
| 659 | 682 | </tr>'; |
| 660 | 683 | } |
@@ -663,11 +686,12 @@ discard block |
||
| 663 | 686 | </tbody> |
| 664 | 687 | </table>'; |
| 665 | 688 | |
| 666 | - if (!empty($context['group']['assignable'])) |
|
| 667 | - echo ' |
|
| 689 | + if (!empty($context['group']['assignable'])) { |
|
| 690 | + echo ' |
|
| 668 | 691 | <div class="floatright"> |
| 669 | 692 | <input type="submit" name="remove" value="', $txt['membergroups_members_remove'], '" class="button "> |
| 670 | 693 | </div>'; |
| 694 | + } |
|
| 671 | 695 | |
| 672 | 696 | echo ' |
| 673 | 697 | <div class="pagesection flow_hidden"> |
@@ -701,8 +725,8 @@ discard block |
||
| 701 | 725 | </form> |
| 702 | 726 | </div><!-- #admincenter -->'; |
| 703 | 727 | |
| 704 | - if (!empty($context['group']['assignable'])) |
|
| 705 | - echo ' |
|
| 728 | + if (!empty($context['group']['assignable'])) { |
|
| 729 | + echo ' |
|
| 706 | 730 | <script> |
| 707 | 731 | var oAddMemberSuggest = new smc_AutoSuggest({ |
| 708 | 732 | sSelf: \'oAddMemberSuggest\', |
@@ -718,7 +742,8 @@ discard block |
||
| 718 | 742 | sItemListContainerId: \'toAddItemContainer\' |
| 719 | 743 | }); |
| 720 | 744 | </script>'; |
| 721 | -} |
|
| 745 | + } |
|
| 746 | + } |
|
| 722 | 747 | |
| 723 | 748 | /** |
| 724 | 749 | * Allow the moderator to enter a reason to each user being rejected. |
@@ -738,8 +763,8 @@ discard block |
||
| 738 | 763 | <dl class="settings">'; |
| 739 | 764 | |
| 740 | 765 | // Loop through and print out a reason box for each... |
| 741 | - foreach ($context['group_requests'] as $request) |
|
| 742 | - echo ' |
|
| 766 | + foreach ($context['group_requests'] as $request) { |
|
| 767 | + echo ' |
|
| 743 | 768 | <dt> |
| 744 | 769 | <strong>', sprintf($txt['mc_groupr_reason_desc'], $request['member_link'], $request['group_link']), ':</strong> |
| 745 | 770 | </dt> |
@@ -747,6 +772,7 @@ discard block |
||
| 747 | 772 | <input type="hidden" name="groupr[]" value="', $request['id'], '"> |
| 748 | 773 | <textarea name="groupreason[', $request['id'], ']" rows="3" cols="40" style="min-width: 80%; max-width: 99%;"></textarea> |
| 749 | 774 | </dd>'; |
| 775 | + } |
|
| 750 | 776 | |
| 751 | 777 | echo ' |
| 752 | 778 | </dl> |