@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 4 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * Add the functions implemented in this file to the $smcFunc array. |
@@ -23,8 +24,8 @@ discard block |
||
| 23 | 24 | { |
| 24 | 25 | global $smcFunc; |
| 25 | 26 | |
| 26 | - if (!isset($smcFunc['db_backup_table']) || $smcFunc['db_backup_table'] != 'smf_db_backup_table') |
|
| 27 | - $smcFunc += array( |
|
| 27 | + if (!isset($smcFunc['db_backup_table']) || $smcFunc['db_backup_table'] != 'smf_db_backup_table') { |
|
| 28 | + $smcFunc += array( |
|
| 28 | 29 | 'db_backup_table' => 'smf_db_backup_table', |
| 29 | 30 | 'db_optimize_table' => 'smf_db_optimize_table', |
| 30 | 31 | 'db_table_sql' => 'smf_db_table_sql', |
@@ -32,7 +33,8 @@ discard block |
||
| 32 | 33 | 'db_get_version' => 'smf_db_get_version', |
| 33 | 34 | 'db_get_vendor' => 'smf_db_get_vendor', |
| 34 | 35 | ); |
| 35 | -} |
|
| 36 | + } |
|
| 37 | + } |
|
| 36 | 38 | |
| 37 | 39 | /** |
| 38 | 40 | * Backup $table to $backup_table. |
@@ -74,8 +76,9 @@ discard block |
||
| 74 | 76 | )); |
| 75 | 77 | |
| 76 | 78 | // Old school or no school? |
| 77 | - if ($request) |
|
| 78 | - return $request; |
|
| 79 | + if ($request) { |
|
| 80 | + return $request; |
|
| 81 | + } |
|
| 79 | 82 | } |
| 80 | 83 | |
| 81 | 84 | // At this point, the quick method failed. |
@@ -99,8 +102,9 @@ discard block |
||
| 99 | 102 | foreach ($create as $k => $l) |
| 100 | 103 | { |
| 101 | 104 | // Get the name of the auto_increment column. |
| 102 | - if (strpos($l, 'auto_increment')) |
|
| 103 | - $auto_inc = trim($l); |
|
| 105 | + if (strpos($l, 'auto_increment')) { |
|
| 106 | + $auto_inc = trim($l); |
|
| 107 | + } |
|
| 104 | 108 | |
| 105 | 109 | // For the engine type, see if we can work out what it is. |
| 106 | 110 | if (strpos($l, 'ENGINE') !== false || strpos($l, 'TYPE') !== false) |
@@ -108,30 +112,36 @@ discard block |
||
| 108 | 112 | // Extract the engine type. |
| 109 | 113 | preg_match('~(ENGINE|TYPE)=(\w+)(\sDEFAULT)?(\sCHARSET=(\w+))?(\sCOLLATE=(\w+))?~', $l, $match); |
| 110 | 114 | |
| 111 | - if (!empty($match[1])) |
|
| 112 | - $engine = $match[1]; |
|
| 115 | + if (!empty($match[1])) { |
|
| 116 | + $engine = $match[1]; |
|
| 117 | + } |
|
| 113 | 118 | |
| 114 | - if (!empty($match[2])) |
|
| 115 | - $engine = $match[2]; |
|
| 119 | + if (!empty($match[2])) { |
|
| 120 | + $engine = $match[2]; |
|
| 121 | + } |
|
| 116 | 122 | |
| 117 | - if (!empty($match[5])) |
|
| 118 | - $charset = $match[5]; |
|
| 123 | + if (!empty($match[5])) { |
|
| 124 | + $charset = $match[5]; |
|
| 125 | + } |
|
| 119 | 126 | |
| 120 | - if (!empty($match[7])) |
|
| 121 | - $collate = $match[7]; |
|
| 127 | + if (!empty($match[7])) { |
|
| 128 | + $collate = $match[7]; |
|
| 129 | + } |
|
| 122 | 130 | } |
| 123 | 131 | |
| 124 | 132 | // Skip everything but keys... |
| 125 | - if (strpos($l, 'KEY') === false) |
|
| 126 | - unset($create[$k]); |
|
| 133 | + if (strpos($l, 'KEY') === false) { |
|
| 134 | + unset($create[$k]); |
|
| 135 | + } |
|
| 127 | 136 | } |
| 128 | 137 | |
| 129 | - if (!empty($create)) |
|
| 130 | - $create = '( |
|
| 138 | + if (!empty($create)) { |
|
| 139 | + $create = '( |
|
| 131 | 140 | ' . implode(' |
| 132 | 141 | ', $create) . ')'; |
| 133 | - else |
|
| 134 | - $create = ''; |
|
| 142 | + } else { |
|
| 143 | + $create = ''; |
|
| 144 | + } |
|
| 135 | 145 | |
| 136 | 146 | $request = $smcFunc['db_query']('', ' |
| 137 | 147 | CREATE TABLE {raw:backup_table} {raw:create} |
@@ -150,8 +160,9 @@ discard block |
||
| 150 | 160 | |
| 151 | 161 | if ($auto_inc != '') |
| 152 | 162 | { |
| 153 | - if (preg_match('~\`(.+?)\`\s~', $auto_inc, $match) != 0 && substr($auto_inc, -1, 1) == ',') |
|
| 154 | - $auto_inc = substr($auto_inc, 0, -1); |
|
| 163 | + if (preg_match('~\`(.+?)\`\s~', $auto_inc, $match) != 0 && substr($auto_inc, -1, 1) == ',') { |
|
| 164 | + $auto_inc = substr($auto_inc, 0, -1); |
|
| 165 | + } |
|
| 155 | 166 | |
| 156 | 167 | $smcFunc['db_query']('', ' |
| 157 | 168 | ALTER TABLE {raw:backup_table} |
@@ -195,8 +206,9 @@ discard block |
||
| 195 | 206 | 'table' => $table, |
| 196 | 207 | ) |
| 197 | 208 | ); |
| 198 | - if (!$request) |
|
| 199 | - return -1; |
|
| 209 | + if (!$request) { |
|
| 210 | + return -1; |
|
| 211 | + } |
|
| 200 | 212 | |
| 201 | 213 | // How much left? |
| 202 | 214 | $request = $smcFunc['db_query']('', ' |
@@ -239,8 +251,9 @@ discard block |
||
| 239 | 251 | ) |
| 240 | 252 | ); |
| 241 | 253 | $tables = array(); |
| 242 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
| 243 | - $tables[] = $row[0]; |
|
| 254 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
| 255 | + $tables[] = $row[0]; |
|
| 256 | + } |
|
| 244 | 257 | $smcFunc['db_free_result']($request); |
| 245 | 258 | |
| 246 | 259 | return $tables; |
@@ -284,8 +297,9 @@ discard block |
||
| 284 | 297 | if (!empty($row['Default']) || $row['Null'] !== 'YES') |
| 285 | 298 | { |
| 286 | 299 | // Make a special case of auto-timestamp. |
| 287 | - if ($row['Default'] == 'CURRENT_TIMESTAMP') |
|
| 288 | - $schema_create .= ' /*!40102 NOT NULL default CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP */'; |
|
| 300 | + if ($row['Default'] == 'CURRENT_TIMESTAMP') { |
|
| 301 | + $schema_create .= ' /*!40102 NOT NULL default CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP */'; |
|
| 302 | + } |
|
| 289 | 303 | // Text shouldn't have a default. |
| 290 | 304 | elseif ($row['Default'] !== null) |
| 291 | 305 | { |
@@ -320,14 +334,16 @@ discard block |
||
| 320 | 334 | $row['Key_name'] = $row['Key_name'] == 'PRIMARY' ? 'PRIMARY KEY' : (empty($row['Non_unique']) ? 'UNIQUE ' : ($row['Comment'] == 'FULLTEXT' || (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT') ? 'FULLTEXT ' : 'KEY ')) . '`' . $row['Key_name'] . '`'; |
| 321 | 335 | |
| 322 | 336 | // Is this the first column in the index? |
| 323 | - if (empty($indexes[$row['Key_name']])) |
|
| 324 | - $indexes[$row['Key_name']] = array(); |
|
| 337 | + if (empty($indexes[$row['Key_name']])) { |
|
| 338 | + $indexes[$row['Key_name']] = array(); |
|
| 339 | + } |
|
| 325 | 340 | |
| 326 | 341 | // A sub part, like only indexing 15 characters of a varchar. |
| 327 | - if (!empty($row['Sub_part'])) |
|
| 328 | - $indexes[$row['Key_name']][$row['Seq_in_index']] = '`' . $row['Column_name'] . '`(' . $row['Sub_part'] . ')'; |
|
| 329 | - else |
|
| 330 | - $indexes[$row['Key_name']][$row['Seq_in_index']] = '`' . $row['Column_name'] . '`'; |
|
| 342 | + if (!empty($row['Sub_part'])) { |
|
| 343 | + $indexes[$row['Key_name']][$row['Seq_in_index']] = '`' . $row['Column_name'] . '`(' . $row['Sub_part'] . ')'; |
|
| 344 | + } else { |
|
| 345 | + $indexes[$row['Key_name']][$row['Seq_in_index']] = '`' . $row['Column_name'] . '`'; |
|
| 346 | + } |
|
| 331 | 347 | } |
| 332 | 348 | $smcFunc['db_free_result']($result); |
| 333 | 349 | |
@@ -365,8 +381,9 @@ discard block |
||
| 365 | 381 | { |
| 366 | 382 | static $ver; |
| 367 | 383 | |
| 368 | - if (!empty($ver)) |
|
| 369 | - return $ver; |
|
| 384 | + if (!empty($ver)) { |
|
| 385 | + return $ver; |
|
| 386 | + } |
|
| 370 | 387 | |
| 371 | 388 | global $smcFunc; |
| 372 | 389 | |
@@ -391,8 +408,9 @@ discard block |
||
| 391 | 408 | global $smcFunc; |
| 392 | 409 | static $db_type; |
| 393 | 410 | |
| 394 | - if (!empty($db_type)) |
|
| 395 | - return $db_type; |
|
| 411 | + if (!empty($db_type)) { |
|
| 412 | + return $db_type; |
|
| 413 | + } |
|
| 396 | 414 | |
| 397 | 415 | $request = $smcFunc['db_query']('', |
| 398 | 416 | 'SELECT VARIABLE_VALUE |
@@ -408,13 +426,15 @@ discard block |
||
| 408 | 426 | // Skip these if we don't have a comment. |
| 409 | 427 | if (!empty($comment)) |
| 410 | 428 | { |
| 411 | - if (stripos($comment, 'percona') !== false) |
|
| 412 | - return 'Percona'; |
|
| 413 | - if (stripos($comment, 'mariadb') !== false) |
|
| 414 | - return 'MariaDB'; |
|
| 429 | + if (stripos($comment, 'percona') !== false) { |
|
| 430 | + return 'Percona'; |
|
| 431 | + } |
|
| 432 | + if (stripos($comment, 'mariadb') !== false) { |
|
| 433 | + return 'MariaDB'; |
|
| 434 | + } |
|
| 435 | + } else { |
|
| 436 | + return 'fail'; |
|
| 415 | 437 | } |
| 416 | - else |
|
| 417 | - return 'fail'; |
|
| 418 | 438 | |
| 419 | 439 | return 'MySQL'; |
| 420 | 440 | } |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 4 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * Add the functions implemented in this file to the $smcFunc array. |
@@ -23,8 +24,8 @@ discard block |
||
| 23 | 24 | { |
| 24 | 25 | global $smcFunc; |
| 25 | 26 | |
| 26 | - if (!isset($smcFunc['db_backup_table']) || $smcFunc['db_backup_table'] != 'smf_db_backup_table') |
|
| 27 | - $smcFunc += array( |
|
| 27 | + if (!isset($smcFunc['db_backup_table']) || $smcFunc['db_backup_table'] != 'smf_db_backup_table') { |
|
| 28 | + $smcFunc += array( |
|
| 28 | 29 | 'db_backup_table' => 'smf_db_backup_table', |
| 29 | 30 | 'db_optimize_table' => 'smf_db_optimize_table', |
| 30 | 31 | 'db_table_sql' => 'smf_db_table_sql', |
@@ -32,7 +33,8 @@ discard block |
||
| 32 | 33 | 'db_get_version' => 'smf_db_get_version', |
| 33 | 34 | 'db_get_vendor' => 'smf_db_get_vendor', |
| 34 | 35 | ); |
| 35 | -} |
|
| 36 | + } |
|
| 37 | + } |
|
| 36 | 38 | |
| 37 | 39 | /** |
| 38 | 40 | * Backup $table to $backup_table. |
@@ -48,13 +50,14 @@ discard block |
||
| 48 | 50 | |
| 49 | 51 | // Do we need to drop it first? |
| 50 | 52 | $tables = smf_db_list_tables(false, $backup_table); |
| 51 | - if (!empty($tables)) |
|
| 52 | - $smcFunc['db_query']('', ' |
|
| 53 | + if (!empty($tables)) { |
|
| 54 | + $smcFunc['db_query']('', ' |
|
| 53 | 55 | DROP TABLE {raw:backup_table}', |
| 54 | 56 | array( |
| 55 | 57 | 'backup_table' => $backup_table, |
| 56 | 58 | ) |
| 57 | 59 | ); |
| 60 | + } |
|
| 58 | 61 | |
| 59 | 62 | /** |
| 60 | 63 | * @todo Should we create backups of sequences as well? |
@@ -117,8 +120,9 @@ discard block |
||
| 117 | 120 | ) |
| 118 | 121 | ); |
| 119 | 122 | |
| 120 | - if (!$request) |
|
| 121 | - return -1; |
|
| 123 | + if (!$request) { |
|
| 124 | + return -1; |
|
| 125 | + } |
|
| 122 | 126 | |
| 123 | 127 | $request = $smcFunc['db_query']('', ' |
| 124 | 128 | SELECT pg_relation_size(C.oid) AS "size" |
@@ -136,11 +140,12 @@ discard block |
||
| 136 | 140 | $row = $smcFunc['db_fetch_assoc']($request); |
| 137 | 141 | $smcFunc['db_free_result']($request); |
| 138 | 142 | |
| 139 | - if (isset($row['size'])) |
|
| 140 | - return ($old_size - $row['size']) / 1024; |
|
| 141 | - else |
|
| 142 | - return 0; |
|
| 143 | -} |
|
| 143 | + if (isset($row['size'])) { |
|
| 144 | + return ($old_size - $row['size']) / 1024; |
|
| 145 | + } else { |
|
| 146 | + return 0; |
|
| 147 | + } |
|
| 148 | + } |
|
| 144 | 149 | |
| 145 | 150 | /** |
| 146 | 151 | * This function lists all tables in the database. |
@@ -167,8 +172,9 @@ discard block |
||
| 167 | 172 | ); |
| 168 | 173 | |
| 169 | 174 | $tables = array(); |
| 170 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
| 171 | - $tables[] = $row[0]; |
|
| 175 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
| 176 | + $tables[] = $row[0]; |
|
| 177 | + } |
|
| 172 | 178 | $smcFunc['db_free_result']($request); |
| 173 | 179 | |
| 174 | 180 | return $tables; |
@@ -209,12 +215,14 @@ discard block |
||
| 209 | 215 | ); |
| 210 | 216 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 211 | 217 | { |
| 212 | - if ($row['data_type'] == 'character varying') |
|
| 213 | - $row['data_type'] = 'varchar'; |
|
| 214 | - elseif ($row['data_type'] == 'character') |
|
| 215 | - $row['data_type'] = 'char'; |
|
| 216 | - if ($row['character_maximum_length']) |
|
| 217 | - $row['data_type'] .= '(' . $row['character_maximum_length'] . ')'; |
|
| 218 | + if ($row['data_type'] == 'character varying') { |
|
| 219 | + $row['data_type'] = 'varchar'; |
|
| 220 | + } elseif ($row['data_type'] == 'character') { |
|
| 221 | + $row['data_type'] = 'char'; |
|
| 222 | + } |
|
| 223 | + if ($row['character_maximum_length']) { |
|
| 224 | + $row['data_type'] .= '(' . $row['character_maximum_length'] . ')'; |
|
| 225 | + } |
|
| 218 | 226 | |
| 219 | 227 | // Make the CREATE for this column. |
| 220 | 228 | $schema_create .= ' "' . $row['column_name'] . '" ' . $row['data_type'] . ($row['is_nullable'] != 'YES' ? ' NOT NULL' : ''); |
@@ -265,13 +273,14 @@ discard block |
||
| 265 | 273 | { |
| 266 | 274 | if ($row['is_primary']) |
| 267 | 275 | { |
| 268 | - if (preg_match('~\(([^\)]+?)\)~i', $row['inddef'], $matches) == 0) |
|
| 269 | - continue; |
|
| 276 | + if (preg_match('~\(([^\)]+?)\)~i', $row['inddef'], $matches) == 0) { |
|
| 277 | + continue; |
|
| 278 | + } |
|
| 270 | 279 | |
| 271 | 280 | $index_create .= $crlf . 'ALTER TABLE ' . $tableName . ' ADD PRIMARY KEY ("' . $matches[1] . '");'; |
| 281 | + } else { |
|
| 282 | + $index_create .= $crlf . $row['inddef'] . ';'; |
|
| 272 | 283 | } |
| 273 | - else |
|
| 274 | - $index_create .= $crlf . $row['inddef'] . ';'; |
|
| 275 | 284 | } |
| 276 | 285 | $smcFunc['db_free_result']($result); |
| 277 | 286 | |
@@ -290,8 +299,9 @@ discard block |
||
| 290 | 299 | global $db_connection; |
| 291 | 300 | static $ver; |
| 292 | 301 | |
| 293 | - if(!empty($ver)) |
|
| 294 | - return $ver; |
|
| 302 | + if(!empty($ver)) { |
|
| 303 | + return $ver; |
|
| 304 | + } |
|
| 295 | 305 | |
| 296 | 306 | $ver = pg_version($db_connection)['server']; |
| 297 | 307 | |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 4 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * Get a list of versions that are currently installed on the server. |
@@ -45,8 +46,7 @@ discard block |
||
| 45 | 46 | $temp2 = $temp->getVersion(); |
| 46 | 47 | $im_version = $temp2['versionString']; |
| 47 | 48 | $extension_version = 'Imagick ' . phpversion('Imagick'); |
| 48 | - } |
|
| 49 | - else |
|
| 49 | + } else |
|
| 50 | 50 | { |
| 51 | 51 | $im_version = MagickGetVersionString(); |
| 52 | 52 | $extension_version = 'MagickWand ' . phpversion('MagickWand'); |
@@ -61,9 +61,9 @@ discard block |
||
| 61 | 61 | if (in_array('db_server', $checkFor)) |
| 62 | 62 | { |
| 63 | 63 | db_extend(); |
| 64 | - if (!isset($db_connection) || $db_connection === false) |
|
| 65 | - trigger_error('getServerVersions(): you need to be connected to the database in order to get its server version', E_USER_NOTICE); |
|
| 66 | - else |
|
| 64 | + if (!isset($db_connection) || $db_connection === false) { |
|
| 65 | + trigger_error('getServerVersions(): you need to be connected to the database in order to get its server version', E_USER_NOTICE); |
|
| 66 | + } else |
|
| 67 | 67 | { |
| 68 | 68 | $versions['db_engine'] = array('title' => sprintf($txt['support_versions_db_engine'], $smcFunc['db_title']), 'version' => ''); |
| 69 | 69 | $versions['db_engine']['version'] = $smcFunc['db_get_vendor'](); |
@@ -75,24 +75,31 @@ discard block |
||
| 75 | 75 | |
| 76 | 76 | // If we're using memcache we need the server info. |
| 77 | 77 | $memcache_version = '???'; |
| 78 | - if (!empty($cache_accelerator) && ($cache_accelerator == 'memcached' || $cache_accelerator == 'memcache') && !empty($cache_memcached) && !empty($cacheAPI)) |
|
| 79 | - $memcache_version = $cacheAPI->getVersion(); |
|
| 78 | + if (!empty($cache_accelerator) && ($cache_accelerator == 'memcached' || $cache_accelerator == 'memcache') && !empty($cache_memcached) && !empty($cacheAPI)) { |
|
| 79 | + $memcache_version = $cacheAPI->getVersion(); |
|
| 80 | + } |
|
| 80 | 81 | |
| 81 | 82 | // Check to see if we have any accelerators installed... |
| 82 | - if (in_array('phpa', $checkFor) && isset($_PHPA)) |
|
| 83 | - $versions['phpa'] = array('title' => 'ionCube PHP-Accelerator', 'version' => $_PHPA['VERSION']); |
|
| 84 | - if (in_array('apc', $checkFor) && extension_loaded('apc')) |
|
| 85 | - $versions['apc'] = array('title' => 'Alternative PHP Cache', 'version' => phpversion('apc')); |
|
| 86 | - if (in_array('memcache', $checkFor) && function_exists('memcache_set')) |
|
| 87 | - $versions['memcache'] = array('title' => 'Memcached', 'version' => $memcache_version); |
|
| 88 | - if (in_array('xcache', $checkFor) && function_exists('xcache_set')) |
|
| 89 | - $versions['xcache'] = array('title' => 'XCache', 'version' => XCACHE_VERSION); |
|
| 83 | + if (in_array('phpa', $checkFor) && isset($_PHPA)) { |
|
| 84 | + $versions['phpa'] = array('title' => 'ionCube PHP-Accelerator', 'version' => $_PHPA['VERSION']); |
|
| 85 | + } |
|
| 86 | + if (in_array('apc', $checkFor) && extension_loaded('apc')) { |
|
| 87 | + $versions['apc'] = array('title' => 'Alternative PHP Cache', 'version' => phpversion('apc')); |
|
| 88 | + } |
|
| 89 | + if (in_array('memcache', $checkFor) && function_exists('memcache_set')) { |
|
| 90 | + $versions['memcache'] = array('title' => 'Memcached', 'version' => $memcache_version); |
|
| 91 | + } |
|
| 92 | + if (in_array('xcache', $checkFor) && function_exists('xcache_set')) { |
|
| 93 | + $versions['xcache'] = array('title' => 'XCache', 'version' => XCACHE_VERSION); |
|
| 94 | + } |
|
| 90 | 95 | |
| 91 | - if (in_array('php', $checkFor)) |
|
| 92 | - $versions['php'] = array('title' => 'PHP', 'version' => PHP_VERSION, 'more' => '?action=admin;area=serversettings;sa=phpinfo'); |
|
| 96 | + if (in_array('php', $checkFor)) { |
|
| 97 | + $versions['php'] = array('title' => 'PHP', 'version' => PHP_VERSION, 'more' => '?action=admin;area=serversettings;sa=phpinfo'); |
|
| 98 | + } |
|
| 93 | 99 | |
| 94 | - if (in_array('server', $checkFor)) |
|
| 95 | - $versions['server'] = array('title' => $txt['support_versions_server'], 'version' => $_SERVER['SERVER_SOFTWARE']); |
|
| 100 | + if (in_array('server', $checkFor)) { |
|
| 101 | + $versions['server'] = array('title' => $txt['support_versions_server'], 'version' => $_SERVER['SERVER_SOFTWARE']); |
|
| 102 | + } |
|
| 96 | 103 | |
| 97 | 104 | return $versions; |
| 98 | 105 | } |
@@ -132,11 +139,13 @@ discard block |
||
| 132 | 139 | fclose($fp); |
| 133 | 140 | |
| 134 | 141 | // The comment looks rougly like... that. |
| 135 | - if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) |
|
| 136 | - $version_info['file_versions']['SSI.php'] = $match[1]; |
|
| 142 | + if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) { |
|
| 143 | + $version_info['file_versions']['SSI.php'] = $match[1]; |
|
| 144 | + } |
|
| 137 | 145 | // Not found! This is bad. |
| 138 | - else |
|
| 139 | - $version_info['file_versions']['SSI.php'] = '??'; |
|
| 146 | + else { |
|
| 147 | + $version_info['file_versions']['SSI.php'] = '??'; |
|
| 148 | + } |
|
| 140 | 149 | } |
| 141 | 150 | |
| 142 | 151 | // Do the paid subscriptions handler? |
@@ -147,11 +156,13 @@ discard block |
||
| 147 | 156 | fclose($fp); |
| 148 | 157 | |
| 149 | 158 | // Found it? |
| 150 | - if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) |
|
| 151 | - $version_info['file_versions']['subscriptions.php'] = $match[1]; |
|
| 159 | + if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) { |
|
| 160 | + $version_info['file_versions']['subscriptions.php'] = $match[1]; |
|
| 161 | + } |
|
| 152 | 162 | // If we haven't how do we all get paid? |
| 153 | - else |
|
| 154 | - $version_info['file_versions']['subscriptions.php'] = '??'; |
|
| 163 | + else { |
|
| 164 | + $version_info['file_versions']['subscriptions.php'] = '??'; |
|
| 165 | + } |
|
| 155 | 166 | } |
| 156 | 167 | |
| 157 | 168 | // Load all the files in the Sources directory, except this file and the redirect. |
@@ -166,11 +177,13 @@ discard block |
||
| 166 | 177 | fclose($fp); |
| 167 | 178 | |
| 168 | 179 | // Look for the version comment in the file header. |
| 169 | - if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) |
|
| 170 | - $version_info['file_versions'][$entry] = $match[1]; |
|
| 180 | + if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) { |
|
| 181 | + $version_info['file_versions'][$entry] = $match[1]; |
|
| 182 | + } |
|
| 171 | 183 | // It wasn't found, but the file was... show a '??'. |
| 172 | - else |
|
| 173 | - $version_info['file_versions'][$entry] = '??'; |
|
| 184 | + else { |
|
| 185 | + $version_info['file_versions'][$entry] = '??'; |
|
| 186 | + } |
|
| 174 | 187 | } |
| 175 | 188 | } |
| 176 | 189 | $sources_dir->close(); |
@@ -189,11 +202,13 @@ discard block |
||
| 189 | 202 | fclose($fp); |
| 190 | 203 | |
| 191 | 204 | // Look for the version comment in the file header. |
| 192 | - if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) |
|
| 193 | - $version_info['tasks_versions'][$entry] = $match[1]; |
|
| 205 | + if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) { |
|
| 206 | + $version_info['tasks_versions'][$entry] = $match[1]; |
|
| 207 | + } |
|
| 194 | 208 | // It wasn't found, but the file was... show a '??'. |
| 195 | - else |
|
| 196 | - $version_info['tasks_versions'][$entry] = '??'; |
|
| 209 | + else { |
|
| 210 | + $version_info['tasks_versions'][$entry] = '??'; |
|
| 211 | + } |
|
| 197 | 212 | } |
| 198 | 213 | } |
| 199 | 214 | $tasks_dir->close(); |
@@ -201,8 +216,9 @@ discard block |
||
| 201 | 216 | |
| 202 | 217 | // Load all the files in the default template directory - and the current theme if applicable. |
| 203 | 218 | $directories = array('default_template_versions' => $settings['default_theme_dir']); |
| 204 | - if ($settings['theme_id'] != 1) |
|
| 205 | - $directories += array('template_versions' => $settings['theme_dir']); |
|
| 219 | + if ($settings['theme_id'] != 1) { |
|
| 220 | + $directories += array('template_versions' => $settings['theme_dir']); |
|
| 221 | + } |
|
| 206 | 222 | |
| 207 | 223 | foreach ($directories as $type => $dirname) |
| 208 | 224 | { |
@@ -217,11 +233,13 @@ discard block |
||
| 217 | 233 | fclose($fp); |
| 218 | 234 | |
| 219 | 235 | // Look for the version comment in the file header. |
| 220 | - if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) |
|
| 221 | - $version_info[$type][$entry] = $match[1]; |
|
| 236 | + if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) { |
|
| 237 | + $version_info[$type][$entry] = $match[1]; |
|
| 238 | + } |
|
| 222 | 239 | // It wasn't found, but the file was... show a '??'. |
| 223 | - else |
|
| 224 | - $version_info[$type][$entry] = '??'; |
|
| 240 | + else { |
|
| 241 | + $version_info[$type][$entry] = '??'; |
|
| 242 | + } |
|
| 225 | 243 | } |
| 226 | 244 | } |
| 227 | 245 | $this_dir->close(); |
@@ -242,11 +260,13 @@ discard block |
||
| 242 | 260 | list ($name, $language) = explode('.', $entry); |
| 243 | 261 | |
| 244 | 262 | // Look for the version comment in the file header. |
| 245 | - if (preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*' . preg_quote($name, '~') . '(?:[\s]{2}|\*/)~i', $header, $match) == 1) |
|
| 246 | - $version_info['default_language_versions'][$language][$name] = $match[1]; |
|
| 263 | + if (preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*' . preg_quote($name, '~') . '(?:[\s]{2}|\*/)~i', $header, $match) == 1) { |
|
| 264 | + $version_info['default_language_versions'][$language][$name] = $match[1]; |
|
| 265 | + } |
|
| 247 | 266 | // It wasn't found, but the file was... show a '??'. |
| 248 | - else |
|
| 249 | - $version_info['default_language_versions'][$language][$name] = '??'; |
|
| 267 | + else { |
|
| 268 | + $version_info['default_language_versions'][$language][$name] = '??'; |
|
| 269 | + } |
|
| 250 | 270 | } |
| 251 | 271 | } |
| 252 | 272 | $this_dir->close(); |
@@ -261,8 +281,9 @@ discard block |
||
| 261 | 281 | ksort($version_info['tasks_versions']); |
| 262 | 282 | |
| 263 | 283 | // For languages sort each language too. |
| 264 | - foreach ($version_info['default_language_versions'] as $language => $dummy) |
|
| 265 | - ksort($version_info['default_language_versions'][$language]); |
|
| 284 | + foreach ($version_info['default_language_versions'] as $language => $dummy) { |
|
| 285 | + ksort($version_info['default_language_versions'][$language]); |
|
| 286 | + } |
|
| 266 | 287 | } |
| 267 | 288 | return $version_info; |
| 268 | 289 | } |
@@ -304,27 +325,31 @@ discard block |
||
| 304 | 325 | $settingsArray = trim(file_get_contents($boarddir . '/Settings.php')); |
| 305 | 326 | |
| 306 | 327 | // Break it up based on \r or \n, and then clean out extra characters. |
| 307 | - if (strpos($settingsArray, "\n") !== false) |
|
| 308 | - $settingsArray = explode("\n", $settingsArray); |
|
| 309 | - elseif (strpos($settingsArray, "\r") !== false) |
|
| 310 | - $settingsArray = explode("\r", $settingsArray); |
|
| 311 | - else |
|
| 312 | - return; |
|
| 328 | + if (strpos($settingsArray, "\n") !== false) { |
|
| 329 | + $settingsArray = explode("\n", $settingsArray); |
|
| 330 | + } elseif (strpos($settingsArray, "\r") !== false) { |
|
| 331 | + $settingsArray = explode("\r", $settingsArray); |
|
| 332 | + } else { |
|
| 333 | + return; |
|
| 334 | + } |
|
| 313 | 335 | |
| 314 | 336 | // Presumably, the file has to have stuff in it for this function to be called :P. |
| 315 | - if (count($settingsArray) < 10) |
|
| 316 | - return; |
|
| 337 | + if (count($settingsArray) < 10) { |
|
| 338 | + return; |
|
| 339 | + } |
|
| 317 | 340 | |
| 318 | 341 | // remove any /r's that made there way in here |
| 319 | - foreach ($settingsArray as $k => $dummy) |
|
| 320 | - $settingsArray[$k] = strtr($dummy, array("\r" => '')) . "\n"; |
|
| 342 | + foreach ($settingsArray as $k => $dummy) { |
|
| 343 | + $settingsArray[$k] = strtr($dummy, array("\r" => '')) . "\n"; |
|
| 344 | + } |
|
| 321 | 345 | |
| 322 | 346 | // go line by line and see whats changing |
| 323 | 347 | for ($i = 0, $n = count($settingsArray); $i < $n; $i++) |
| 324 | 348 | { |
| 325 | 349 | // Don't trim or bother with it if it's not a variable. |
| 326 | - if (substr($settingsArray[$i], 0, 1) != '$') |
|
| 327 | - continue; |
|
| 350 | + if (substr($settingsArray[$i], 0, 1) != '$') { |
|
| 351 | + continue; |
|
| 352 | + } |
|
| 328 | 353 | |
| 329 | 354 | $settingsArray[$i] = trim($settingsArray[$i]) . "\n"; |
| 330 | 355 | |
@@ -336,8 +361,7 @@ discard block |
||
| 336 | 361 | { |
| 337 | 362 | updateDbLastError($val); |
| 338 | 363 | unset($config_vars[$var]); |
| 339 | - } |
|
| 340 | - elseif (strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0) |
|
| 364 | + } elseif (strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0) |
|
| 341 | 365 | { |
| 342 | 366 | $comment = strstr(substr($settingsArray[$i], strpos($settingsArray[$i], ';')), '#'); |
| 343 | 367 | $settingsArray[$i] = '$' . $var . ' = ' . $val . ';' . ($comment == '' ? '' : "\t\t" . rtrim($comment)) . "\n"; |
@@ -348,34 +372,39 @@ discard block |
||
| 348 | 372 | } |
| 349 | 373 | |
| 350 | 374 | // End of the file ... maybe |
| 351 | - if (substr(trim($settingsArray[$i]), 0, 2) == '?' . '>') |
|
| 352 | - $end = $i; |
|
| 375 | + if (substr(trim($settingsArray[$i]), 0, 2) == '?' . '>') { |
|
| 376 | + $end = $i; |
|
| 377 | + } |
|
| 353 | 378 | } |
| 354 | 379 | |
| 355 | 380 | // This should never happen, but apparently it is happening. |
| 356 | - if (empty($end) || $end < 10) |
|
| 357 | - $end = count($settingsArray) - 1; |
|
| 381 | + if (empty($end) || $end < 10) { |
|
| 382 | + $end = count($settingsArray) - 1; |
|
| 383 | + } |
|
| 358 | 384 | |
| 359 | 385 | // Still more variables to go? Then lets add them at the end. |
| 360 | 386 | if (!empty($config_vars)) |
| 361 | 387 | { |
| 362 | - if (trim($settingsArray[$end]) == '?' . '>') |
|
| 363 | - $settingsArray[$end++] = ''; |
|
| 364 | - else |
|
| 365 | - $end++; |
|
| 388 | + if (trim($settingsArray[$end]) == '?' . '>') { |
|
| 389 | + $settingsArray[$end++] = ''; |
|
| 390 | + } else { |
|
| 391 | + $end++; |
|
| 392 | + } |
|
| 366 | 393 | |
| 367 | 394 | // Add in any newly defined vars that were passed |
| 368 | - foreach ($config_vars as $var => $val) |
|
| 369 | - $settingsArray[$end++] = '$' . $var . ' = ' . $val . ';' . "\n"; |
|
| 395 | + foreach ($config_vars as $var => $val) { |
|
| 396 | + $settingsArray[$end++] = '$' . $var . ' = ' . $val . ';' . "\n"; |
|
| 397 | + } |
|
| 370 | 398 | |
| 371 | 399 | $settingsArray[$end] = '?' . '>'; |
| 400 | + } else { |
|
| 401 | + $settingsArray[$end] = trim($settingsArray[$end]); |
|
| 372 | 402 | } |
| 373 | - else |
|
| 374 | - $settingsArray[$end] = trim($settingsArray[$end]); |
|
| 375 | 403 | |
| 376 | 404 | // Sanity error checking: the file needs to be at least 12 lines. |
| 377 | - if (count($settingsArray) < 12) |
|
| 378 | - return; |
|
| 405 | + if (count($settingsArray) < 12) { |
|
| 406 | + return; |
|
| 407 | + } |
|
| 379 | 408 | |
| 380 | 409 | // Try to avoid a few pitfalls: |
| 381 | 410 | // - like a possible race condition, |
@@ -383,8 +412,9 @@ discard block |
||
| 383 | 412 | // |
| 384 | 413 | // Check before you act: if cache is enabled, we can do a simple write test |
| 385 | 414 | // to validate that we even write things on this filesystem. |
| 386 | - if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache')) |
|
| 387 | - $cachedir = $boarddir . '/cache'; |
|
| 415 | + if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache')) { |
|
| 416 | + $cachedir = $boarddir . '/cache'; |
|
| 417 | + } |
|
| 388 | 418 | |
| 389 | 419 | $test_fp = @fopen($cachedir . '/settings_update.tmp', "w+"); |
| 390 | 420 | if ($test_fp) |
@@ -419,16 +449,18 @@ discard block |
||
| 419 | 449 | // Well this is not good at all, lets see if we can save this |
| 420 | 450 | $context['settings_message'] = 'settings_error'; |
| 421 | 451 | |
| 422 | - if (file_exists($boarddir . '/Settings_bak.php')) |
|
| 423 | - @copy($boarddir . '/Settings_bak.php', $boarddir . '/Settings.php'); |
|
| 452 | + if (file_exists($boarddir . '/Settings_bak.php')) { |
|
| 453 | + @copy($boarddir . '/Settings_bak.php', $boarddir . '/Settings.php'); |
|
| 454 | + } |
|
| 424 | 455 | } |
| 425 | 456 | } |
| 426 | 457 | |
| 427 | 458 | // Even though on normal installations the filemtime should prevent this being used by the installer incorrectly |
| 428 | 459 | // it seems that there are times it might not. So let's MAKE it dump the cache. |
| 429 | - if (function_exists('opcache_invalidate')) |
|
| 430 | - opcache_invalidate($boarddir . '/Settings.php', true); |
|
| 431 | -} |
|
| 460 | + if (function_exists('opcache_invalidate')) { |
|
| 461 | + opcache_invalidate($boarddir . '/Settings.php', true); |
|
| 462 | + } |
|
| 463 | + } |
|
| 432 | 464 | |
| 433 | 465 | /** |
| 434 | 466 | * Saves the time of the last db error for the error log |
@@ -454,8 +486,9 @@ discard block |
||
| 454 | 486 | global $options, $context, $smcFunc, $settings, $user_info; |
| 455 | 487 | |
| 456 | 488 | // This must exist! |
| 457 | - if (!isset($context['admin_preferences'])) |
|
| 458 | - return false; |
|
| 489 | + if (!isset($context['admin_preferences'])) { |
|
| 490 | + return false; |
|
| 491 | + } |
|
| 459 | 492 | |
| 460 | 493 | // This is what we'll be saving. |
| 461 | 494 | $options['admin_preferences'] = $smcFunc['json_encode']($context['admin_preferences']); |
@@ -519,8 +552,9 @@ discard block |
||
| 519 | 552 | $emails_sent = array(); |
| 520 | 553 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 521 | 554 | { |
| 522 | - if (empty($prefs[$row['id_member']]['announcements'])) |
|
| 523 | - continue; |
|
| 555 | + if (empty($prefs[$row['id_member']]['announcements'])) { |
|
| 556 | + continue; |
|
| 557 | + } |
|
| 524 | 558 | |
| 525 | 559 | // Stick their particulars in the replacement data. |
| 526 | 560 | $replacements['IDMEMBER'] = $row['id_member']; |
@@ -539,11 +573,12 @@ discard block |
||
| 539 | 573 | $smcFunc['db_free_result']($request); |
| 540 | 574 | |
| 541 | 575 | // Any additional users we must email this to? |
| 542 | - if (!empty($additional_recipients)) |
|
| 543 | - foreach ($additional_recipients as $recipient) |
|
| 576 | + if (!empty($additional_recipients)) { |
|
| 577 | + foreach ($additional_recipients as $recipient) |
|
| 544 | 578 | { |
| 545 | 579 | if (in_array($recipient['email'], $emails_sent)) |
| 546 | 580 | continue; |
| 581 | + } |
|
| 547 | 582 | |
| 548 | 583 | $replacements['IDMEMBER'] = $recipient['id']; |
| 549 | 584 | $replacements['REALNAME'] = $recipient['name']; |
@@ -14,8 +14,9 @@ discard block |
||
| 14 | 14 | * @version 2.1 Beta 4 |
| 15 | 15 | */ |
| 16 | 16 | |
| 17 | -if (!defined('SMF')) |
|
| 17 | +if (!defined('SMF')) { |
|
| 18 | 18 | die('No direct access...'); |
| 19 | +} |
|
| 19 | 20 | |
| 20 | 21 | /** |
| 21 | 22 | * Handles showing the post screen, loading the post to be modified, and loading any post quoted. |
@@ -35,12 +36,14 @@ discard block |
||
| 35 | 36 | global $sourcedir, $smcFunc, $language; |
| 36 | 37 | |
| 37 | 38 | loadLanguage('Post'); |
| 38 | - if (!empty($modSettings['drafts_post_enabled'])) |
|
| 39 | - loadLanguage('Drafts'); |
|
| 39 | + if (!empty($modSettings['drafts_post_enabled'])) { |
|
| 40 | + loadLanguage('Drafts'); |
|
| 41 | + } |
|
| 40 | 42 | |
| 41 | 43 | // You can't reply with a poll... hacker. |
| 42 | - if (isset($_REQUEST['poll']) && !empty($topic) && !isset($_REQUEST['msg'])) |
|
| 43 | - unset($_REQUEST['poll']); |
|
| 44 | + if (isset($_REQUEST['poll']) && !empty($topic) && !isset($_REQUEST['msg'])) { |
|
| 45 | + unset($_REQUEST['poll']); |
|
| 46 | + } |
|
| 44 | 47 | |
| 45 | 48 | // Posting an event? |
| 46 | 49 | $context['make_event'] = isset($_REQUEST['calendar']); |
@@ -54,8 +57,9 @@ discard block |
||
| 54 | 57 | $context['auto_notify'] = !empty($context['notify_prefs']['msg_auto_notify']); |
| 55 | 58 | |
| 56 | 59 | // You must be posting to *some* board. |
| 57 | - if (empty($board) && !$context['make_event']) |
|
| 58 | - fatal_lang_error('no_board', false); |
|
| 60 | + if (empty($board) && !$context['make_event']) { |
|
| 61 | + fatal_lang_error('no_board', false); |
|
| 62 | + } |
|
| 59 | 63 | |
| 60 | 64 | require_once($sourcedir . '/Subs-Post.php'); |
| 61 | 65 | |
@@ -78,10 +82,11 @@ discard block |
||
| 78 | 82 | array( |
| 79 | 83 | 'msg' => (int) $_REQUEST['msg'], |
| 80 | 84 | )); |
| 81 | - if ($smcFunc['db_num_rows']($request) != 1) |
|
| 82 | - unset($_REQUEST['msg'], $_POST['msg'], $_GET['msg']); |
|
| 83 | - else |
|
| 84 | - list ($topic) = $smcFunc['db_fetch_row']($request); |
|
| 85 | + if ($smcFunc['db_num_rows']($request) != 1) { |
|
| 86 | + unset($_REQUEST['msg'], $_POST['msg'], $_GET['msg']); |
|
| 87 | + } else { |
|
| 88 | + list ($topic) = $smcFunc['db_fetch_row']($request); |
|
| 89 | + } |
|
| 85 | 90 | $smcFunc['db_free_result']($request); |
| 86 | 91 | } |
| 87 | 92 | |
@@ -108,33 +113,36 @@ discard block |
||
| 108 | 113 | $smcFunc['db_free_result']($request); |
| 109 | 114 | |
| 110 | 115 | // If this topic already has a poll, they sure can't add another. |
| 111 | - if (isset($_REQUEST['poll']) && $pollID > 0) |
|
| 112 | - unset($_REQUEST['poll']); |
|
| 116 | + if (isset($_REQUEST['poll']) && $pollID > 0) { |
|
| 117 | + unset($_REQUEST['poll']); |
|
| 118 | + } |
|
| 113 | 119 | |
| 114 | 120 | if (empty($_REQUEST['msg'])) |
| 115 | 121 | { |
| 116 | - if ($user_info['is_guest'] && !allowedTo('post_reply_any') && (!$modSettings['postmod_active'] || !allowedTo('post_unapproved_replies_any'))) |
|
| 117 | - is_not_guest(); |
|
| 122 | + if ($user_info['is_guest'] && !allowedTo('post_reply_any') && (!$modSettings['postmod_active'] || !allowedTo('post_unapproved_replies_any'))) { |
|
| 123 | + is_not_guest(); |
|
| 124 | + } |
|
| 118 | 125 | |
| 119 | 126 | // By default the reply will be approved... |
| 120 | 127 | $context['becomes_approved'] = true; |
| 121 | 128 | if ($id_member_poster != $user_info['id'] || $user_info['is_guest']) |
| 122 | 129 | { |
| 123 | - if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_any') && !allowedTo('post_reply_any')) |
|
| 124 | - $context['becomes_approved'] = false; |
|
| 125 | - else |
|
| 126 | - isAllowedTo('post_reply_any'); |
|
| 127 | - } |
|
| 128 | - elseif (!allowedTo('post_reply_any')) |
|
| 130 | + if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_any') && !allowedTo('post_reply_any')) { |
|
| 131 | + $context['becomes_approved'] = false; |
|
| 132 | + } else { |
|
| 133 | + isAllowedTo('post_reply_any'); |
|
| 134 | + } |
|
| 135 | + } elseif (!allowedTo('post_reply_any')) |
|
| 129 | 136 | { |
| 130 | - if ($modSettings['postmod_active'] && ((allowedTo('post_unapproved_replies_own') && !allowedTo('post_reply_own')) || allowedTo('post_unapproved_replies_any'))) |
|
| 131 | - $context['becomes_approved'] = false; |
|
| 132 | - else |
|
| 133 | - isAllowedTo('post_reply_own'); |
|
| 137 | + if ($modSettings['postmod_active'] && ((allowedTo('post_unapproved_replies_own') && !allowedTo('post_reply_own')) || allowedTo('post_unapproved_replies_any'))) { |
|
| 138 | + $context['becomes_approved'] = false; |
|
| 139 | + } else { |
|
| 140 | + isAllowedTo('post_reply_own'); |
|
| 141 | + } |
|
| 134 | 142 | } |
| 143 | + } else { |
|
| 144 | + $context['becomes_approved'] = true; |
|
| 135 | 145 | } |
| 136 | - else |
|
| 137 | - $context['becomes_approved'] = true; |
|
| 138 | 146 | |
| 139 | 147 | $context['can_lock'] = allowedTo('lock_any') || ($user_info['id'] == $id_member_poster && allowedTo('lock_own')); |
| 140 | 148 | $context['can_sticky'] = allowedTo('make_sticky'); |
@@ -146,18 +154,19 @@ discard block |
||
| 146 | 154 | $context['sticky'] = isset($_REQUEST['sticky']) ? !empty($_REQUEST['sticky']) : $sticky; |
| 147 | 155 | |
| 148 | 156 | // Check whether this is a really old post being bumped... |
| 149 | - if (!empty($modSettings['oldTopicDays']) && $lastPostTime + $modSettings['oldTopicDays'] * 86400 < time() && empty($sticky) && !isset($_REQUEST['subject'])) |
|
| 150 | - $post_errors[] = array('old_topic', array($modSettings['oldTopicDays'])); |
|
| 151 | - } |
|
| 152 | - else |
|
| 157 | + if (!empty($modSettings['oldTopicDays']) && $lastPostTime + $modSettings['oldTopicDays'] * 86400 < time() && empty($sticky) && !isset($_REQUEST['subject'])) { |
|
| 158 | + $post_errors[] = array('old_topic', array($modSettings['oldTopicDays'])); |
|
| 159 | + } |
|
| 160 | + } else |
|
| 153 | 161 | { |
| 154 | 162 | $context['becomes_approved'] = true; |
| 155 | 163 | if ((!$context['make_event'] || !empty($board))) |
| 156 | 164 | { |
| 157 | - if ($modSettings['postmod_active'] && !allowedTo('post_new') && allowedTo('post_unapproved_topics')) |
|
| 158 | - $context['becomes_approved'] = false; |
|
| 159 | - else |
|
| 160 | - isAllowedTo('post_new'); |
|
| 165 | + if ($modSettings['postmod_active'] && !allowedTo('post_new') && allowedTo('post_unapproved_topics')) { |
|
| 166 | + $context['becomes_approved'] = false; |
|
| 167 | + } else { |
|
| 168 | + isAllowedTo('post_new'); |
|
| 169 | + } |
|
| 161 | 170 | } |
| 162 | 171 | |
| 163 | 172 | $locked = 0; |
@@ -193,20 +202,24 @@ discard block |
||
| 193 | 202 | } |
| 194 | 203 | |
| 195 | 204 | // Don't allow a post if it's locked and you aren't all powerful. |
| 196 | - if ($locked && !allowedTo('moderate_board')) |
|
| 197 | - fatal_lang_error('topic_locked', false); |
|
| 205 | + if ($locked && !allowedTo('moderate_board')) { |
|
| 206 | + fatal_lang_error('topic_locked', false); |
|
| 207 | + } |
|
| 198 | 208 | // Check the users permissions - is the user allowed to add or post a poll? |
| 199 | 209 | if (isset($_REQUEST['poll']) && $modSettings['pollMode'] == '1') |
| 200 | 210 | { |
| 201 | 211 | // New topic, new poll. |
| 202 | - if (empty($topic)) |
|
| 203 | - isAllowedTo('poll_post'); |
|
| 212 | + if (empty($topic)) { |
|
| 213 | + isAllowedTo('poll_post'); |
|
| 214 | + } |
|
| 204 | 215 | // This is an old topic - but it is yours! Can you add to it? |
| 205 | - elseif ($user_info['id'] == $id_member_poster && !allowedTo('poll_add_any')) |
|
| 206 | - isAllowedTo('poll_add_own'); |
|
| 216 | + elseif ($user_info['id'] == $id_member_poster && !allowedTo('poll_add_any')) { |
|
| 217 | + isAllowedTo('poll_add_own'); |
|
| 218 | + } |
|
| 207 | 219 | // If you're not the owner, can you add to any poll? |
| 208 | - else |
|
| 209 | - isAllowedTo('poll_add_any'); |
|
| 220 | + else { |
|
| 221 | + isAllowedTo('poll_add_any'); |
|
| 222 | + } |
|
| 210 | 223 | |
| 211 | 224 | require_once($sourcedir . '/Subs-Members.php'); |
| 212 | 225 | $allowedVoteGroups = groupsAllowedTo('poll_vote', $board); |
@@ -235,8 +248,9 @@ discard block |
||
| 235 | 248 | if ($context['make_event']) |
| 236 | 249 | { |
| 237 | 250 | // They might want to pick a board. |
| 238 | - if (!isset($context['current_board'])) |
|
| 239 | - $context['current_board'] = 0; |
|
| 251 | + if (!isset($context['current_board'])) { |
|
| 252 | + $context['current_board'] = 0; |
|
| 253 | + } |
|
| 240 | 254 | |
| 241 | 255 | // Start loading up the event info. |
| 242 | 256 | $context['event'] = array(); |
@@ -250,10 +264,11 @@ discard block |
||
| 250 | 264 | isAllowedTo('calendar_post'); |
| 251 | 265 | |
| 252 | 266 | // We want a fairly compact version of the time, but as close as possible to the user's settings. |
| 253 | - if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) |
|
| 254 | - $time_string = '%k:%M'; |
|
| 255 | - else |
|
| 256 | - $time_string = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]); |
|
| 267 | + if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) { |
|
| 268 | + $time_string = '%k:%M'; |
|
| 269 | + } else { |
|
| 270 | + $time_string = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]); |
|
| 271 | + } |
|
| 257 | 272 | |
| 258 | 273 | $js_time_string = str_replace( |
| 259 | 274 | array('%H', '%k', '%I', '%l', '%M', '%p', '%P', '%r', '%R', '%S', '%T', '%X'), |
@@ -275,8 +290,7 @@ discard block |
||
| 275 | 290 | require_once($sourcedir . '/Subs-Calendar.php'); |
| 276 | 291 | $eventProperties = getEventProperties($context['event']['id']); |
| 277 | 292 | $context['event'] = array_merge($context['event'], $eventProperties); |
| 278 | - } |
|
| 279 | - else |
|
| 293 | + } else |
|
| 280 | 294 | { |
| 281 | 295 | // Get the current event information. |
| 282 | 296 | require_once($sourcedir . '/Subs-Calendar.php'); |
@@ -284,15 +298,18 @@ discard block |
||
| 284 | 298 | $context['event'] = array_merge($context['event'], $eventProperties); |
| 285 | 299 | |
| 286 | 300 | // Make sure the year and month are in the valid range. |
| 287 | - if ($context['event']['month'] < 1 || $context['event']['month'] > 12) |
|
| 288 | - fatal_lang_error('invalid_month', false); |
|
| 289 | - if ($context['event']['year'] < $modSettings['cal_minyear'] || $context['event']['year'] > $modSettings['cal_maxyear']) |
|
| 290 | - fatal_lang_error('invalid_year', false); |
|
| 301 | + if ($context['event']['month'] < 1 || $context['event']['month'] > 12) { |
|
| 302 | + fatal_lang_error('invalid_month', false); |
|
| 303 | + } |
|
| 304 | + if ($context['event']['year'] < $modSettings['cal_minyear'] || $context['event']['year'] > $modSettings['cal_maxyear']) { |
|
| 305 | + fatal_lang_error('invalid_year', false); |
|
| 306 | + } |
|
| 291 | 307 | |
| 292 | 308 | // Get a list of boards they can post in. |
| 293 | 309 | $boards = boardsAllowedTo('post_new'); |
| 294 | - if (empty($boards)) |
|
| 295 | - fatal_lang_error('cannot_post_new', 'user'); |
|
| 310 | + if (empty($boards)) { |
|
| 311 | + fatal_lang_error('cannot_post_new', 'user'); |
|
| 312 | + } |
|
| 296 | 313 | |
| 297 | 314 | // Load a list of boards for this event in the context. |
| 298 | 315 | require_once($sourcedir . '/Subs-MessageIndex.php'); |
@@ -411,10 +428,11 @@ discard block |
||
| 411 | 428 | |
| 412 | 429 | if (!empty($context['new_replies'])) |
| 413 | 430 | { |
| 414 | - if ($context['new_replies'] == 1) |
|
| 415 | - $txt['error_new_replies'] = isset($_GET['last_msg']) ? $txt['error_new_reply_reading'] : $txt['error_new_reply']; |
|
| 416 | - else |
|
| 417 | - $txt['error_new_replies'] = sprintf(isset($_GET['last_msg']) ? $txt['error_new_replies_reading'] : $txt['error_new_replies'], $context['new_replies']); |
|
| 431 | + if ($context['new_replies'] == 1) { |
|
| 432 | + $txt['error_new_replies'] = isset($_GET['last_msg']) ? $txt['error_new_reply_reading'] : $txt['error_new_reply']; |
|
| 433 | + } else { |
|
| 434 | + $txt['error_new_replies'] = sprintf(isset($_GET['last_msg']) ? $txt['error_new_replies_reading'] : $txt['error_new_replies'], $context['new_replies']); |
|
| 435 | + } |
|
| 418 | 436 | |
| 419 | 437 | $post_errors[] = 'new_replies'; |
| 420 | 438 | |
@@ -426,9 +444,9 @@ discard block |
||
| 426 | 444 | // Get a response prefix (like 'Re:') in the default forum language. |
| 427 | 445 | if (!isset($context['response_prefix']) && !($context['response_prefix'] = cache_get_data('response_prefix'))) |
| 428 | 446 | { |
| 429 | - if ($language === $user_info['language']) |
|
| 430 | - $context['response_prefix'] = $txt['response_prefix']; |
|
| 431 | - else |
|
| 447 | + if ($language === $user_info['language']) { |
|
| 448 | + $context['response_prefix'] = $txt['response_prefix']; |
|
| 449 | + } else |
|
| 432 | 450 | { |
| 433 | 451 | loadLanguage('index', $language, false); |
| 434 | 452 | $context['response_prefix'] = $txt['response_prefix']; |
@@ -441,8 +459,9 @@ discard block |
||
| 441 | 459 | // Do we have a body, but an error happened. |
| 442 | 460 | if (isset($_REQUEST['message']) || isset($_REQUEST['quickReply']) || !empty($context['post_error'])) |
| 443 | 461 | { |
| 444 | - if (isset($_REQUEST['quickReply'])) |
|
| 445 | - $_REQUEST['message'] = $_REQUEST['quickReply']; |
|
| 462 | + if (isset($_REQUEST['quickReply'])) { |
|
| 463 | + $_REQUEST['message'] = $_REQUEST['quickReply']; |
|
| 464 | + } |
|
| 446 | 465 | |
| 447 | 466 | // Validate inputs. |
| 448 | 467 | if (empty($context['post_error'])) |
@@ -450,15 +469,17 @@ discard block |
||
| 450 | 469 | // This means they didn't click Post and get an error. |
| 451 | 470 | $really_previewing = true; |
| 452 | 471 | |
| 453 | - } |
|
| 454 | - else |
|
| 472 | + } else |
|
| 455 | 473 | { |
| 456 | - if (!isset($_REQUEST['subject'])) |
|
| 457 | - $_REQUEST['subject'] = ''; |
|
| 458 | - if (!isset($_REQUEST['message'])) |
|
| 459 | - $_REQUEST['message'] = ''; |
|
| 460 | - if (!isset($_REQUEST['icon'])) |
|
| 461 | - $_REQUEST['icon'] = 'xx'; |
|
| 474 | + if (!isset($_REQUEST['subject'])) { |
|
| 475 | + $_REQUEST['subject'] = ''; |
|
| 476 | + } |
|
| 477 | + if (!isset($_REQUEST['message'])) { |
|
| 478 | + $_REQUEST['message'] = ''; |
|
| 479 | + } |
|
| 480 | + if (!isset($_REQUEST['icon'])) { |
|
| 481 | + $_REQUEST['icon'] = 'xx'; |
|
| 482 | + } |
|
| 462 | 483 | |
| 463 | 484 | // They are previewing if they asked to preview (i.e. came from quick reply). |
| 464 | 485 | $really_previewing = !empty($_POST['preview']); |
@@ -474,8 +495,9 @@ discard block |
||
| 474 | 495 | $form_message = $smcFunc['htmlspecialchars']($_REQUEST['message'], ENT_QUOTES); |
| 475 | 496 | |
| 476 | 497 | // Make sure the subject isn't too long - taking into account special characters. |
| 477 | - if ($smcFunc['strlen']($form_subject) > 100) |
|
| 478 | - $form_subject = $smcFunc['substr']($form_subject, 0, 100); |
|
| 498 | + if ($smcFunc['strlen']($form_subject) > 100) { |
|
| 499 | + $form_subject = $smcFunc['substr']($form_subject, 0, 100); |
|
| 500 | + } |
|
| 479 | 501 | |
| 480 | 502 | if (isset($_REQUEST['poll'])) |
| 481 | 503 | { |
@@ -487,8 +509,9 @@ discard block |
||
| 487 | 509 | $_POST['options'] = empty($_POST['options']) ? array() : htmlspecialchars__recursive($_POST['options']); |
| 488 | 510 | foreach ($_POST['options'] as $option) |
| 489 | 511 | { |
| 490 | - if (trim($option) == '') |
|
| 491 | - continue; |
|
| 512 | + if (trim($option) == '') { |
|
| 513 | + continue; |
|
| 514 | + } |
|
| 492 | 515 | |
| 493 | 516 | $context['choices'][] = array( |
| 494 | 517 | 'id' => $choice_id++, |
@@ -550,13 +573,14 @@ discard block |
||
| 550 | 573 | $context['preview_subject'] = $form_subject; |
| 551 | 574 | |
| 552 | 575 | censorText($context['preview_subject']); |
| 576 | + } else { |
|
| 577 | + $context['preview_subject'] = '<em>' . $txt['no_subject'] . '</em>'; |
|
| 553 | 578 | } |
| 554 | - else |
|
| 555 | - $context['preview_subject'] = '<em>' . $txt['no_subject'] . '</em>'; |
|
| 556 | 579 | |
| 557 | 580 | // Protect any CDATA blocks. |
| 558 | - if (isset($_REQUEST['xml'])) |
|
| 559 | - $context['preview_message'] = strtr($context['preview_message'], array(']]>' => ']]]]><![CDATA[>')); |
|
| 581 | + if (isset($_REQUEST['xml'])) { |
|
| 582 | + $context['preview_message'] = strtr($context['preview_message'], array(']]>' => ']]]]>< == 0) |
|
| 599 | - fatal_lang_error('no_board', false); |
|
| 622 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 623 | + fatal_lang_error('no_board', false); |
|
| 624 | + } |
|
| 600 | 625 | $row = $smcFunc['db_fetch_assoc']($request); |
| 601 | 626 | |
| 602 | 627 | $attachment_stuff = array($row); |
| 603 | - while ($row2 = $smcFunc['db_fetch_assoc']($request)) |
|
| 604 | - $attachment_stuff[] = $row2; |
|
| 628 | + while ($row2 = $smcFunc['db_fetch_assoc']($request)) { |
|
| 629 | + $attachment_stuff[] = $row2; |
|
| 630 | + } |
|
| 605 | 631 | $smcFunc['db_free_result']($request); |
| 606 | 632 | |
| 607 | 633 | if ($row['id_member'] == $user_info['id'] && !allowedTo('modify_any')) |
| 608 | 634 | { |
| 609 | 635 | // Give an extra five minutes over the disable time threshold, so they can type - assuming the post is public. |
| 610 | - if ($row['approved'] && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) |
|
| 611 | - fatal_lang_error('modify_post_time_passed', false); |
|
| 612 | - elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_own')) |
|
| 613 | - isAllowedTo('modify_replies'); |
|
| 614 | - else |
|
| 615 | - isAllowedTo('modify_own'); |
|
| 636 | + if ($row['approved'] && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) { |
|
| 637 | + fatal_lang_error('modify_post_time_passed', false); |
|
| 638 | + } elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_own')) { |
|
| 639 | + isAllowedTo('modify_replies'); |
|
| 640 | + } else { |
|
| 641 | + isAllowedTo('modify_own'); |
|
| 642 | + } |
|
| 643 | + } elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_any')) { |
|
| 644 | + isAllowedTo('modify_replies'); |
|
| 645 | + } else { |
|
| 646 | + isAllowedTo('modify_any'); |
|
| 616 | 647 | } |
| 617 | - elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_any')) |
|
| 618 | - isAllowedTo('modify_replies'); |
|
| 619 | - else |
|
| 620 | - isAllowedTo('modify_any'); |
|
| 621 | 648 | |
| 622 | 649 | if ($context['can_announce'] && !empty($row['id_action'])) |
| 623 | 650 | { |
@@ -641,8 +668,9 @@ discard block |
||
| 641 | 668 | |
| 642 | 669 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 643 | 670 | { |
| 644 | - if ($row['filesize'] <= 0) |
|
| 645 | - continue; |
|
| 671 | + if ($row['filesize'] <= 0) { |
|
| 672 | + continue; |
|
| 673 | + } |
|
| 646 | 674 | $context['current_attachments'][$row['id_attach']] = array( |
| 647 | 675 | 'name' => $smcFunc['htmlspecialchars']($row['filename']), |
| 648 | 676 | 'size' => $row['filesize'], |
@@ -712,29 +740,32 @@ discard block |
||
| 712 | 740 | ) |
| 713 | 741 | ); |
| 714 | 742 | // The message they were trying to edit was most likely deleted. |
| 715 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 716 | - fatal_lang_error('no_message', false); |
|
| 743 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 744 | + fatal_lang_error('no_message', false); |
|
| 745 | + } |
|
| 717 | 746 | $row = $smcFunc['db_fetch_assoc']($request); |
| 718 | 747 | |
| 719 | 748 | $attachment_stuff = array($row); |
| 720 | - while ($row2 = $smcFunc['db_fetch_assoc']($request)) |
|
| 721 | - $attachment_stuff[] = $row2; |
|
| 749 | + while ($row2 = $smcFunc['db_fetch_assoc']($request)) { |
|
| 750 | + $attachment_stuff[] = $row2; |
|
| 751 | + } |
|
| 722 | 752 | $smcFunc['db_free_result']($request); |
| 723 | 753 | |
| 724 | 754 | if ($row['id_member'] == $user_info['id'] && !allowedTo('modify_any')) |
| 725 | 755 | { |
| 726 | 756 | // Give an extra five minutes over the disable time threshold, so they can type - assuming the post is public. |
| 727 | - if ($row['approved'] && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) |
|
| 728 | - fatal_lang_error('modify_post_time_passed', false); |
|
| 729 | - elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_own')) |
|
| 730 | - isAllowedTo('modify_replies'); |
|
| 731 | - else |
|
| 732 | - isAllowedTo('modify_own'); |
|
| 757 | + if ($row['approved'] && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) { |
|
| 758 | + fatal_lang_error('modify_post_time_passed', false); |
|
| 759 | + } elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_own')) { |
|
| 760 | + isAllowedTo('modify_replies'); |
|
| 761 | + } else { |
|
| 762 | + isAllowedTo('modify_own'); |
|
| 763 | + } |
|
| 764 | + } elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_any')) { |
|
| 765 | + isAllowedTo('modify_replies'); |
|
| 766 | + } else { |
|
| 767 | + isAllowedTo('modify_any'); |
|
| 733 | 768 | } |
| 734 | - elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_any')) |
|
| 735 | - isAllowedTo('modify_replies'); |
|
| 736 | - else |
|
| 737 | - isAllowedTo('modify_any'); |
|
| 738 | 769 | |
| 739 | 770 | if ($context['can_announce'] && !empty($row['id_action'])) |
| 740 | 771 | { |
@@ -761,15 +792,17 @@ discard block |
||
| 761 | 792 | $context['icon'] = $row['icon']; |
| 762 | 793 | |
| 763 | 794 | // Show an "approve" box if the user can approve it, and the message isn't approved. |
| 764 | - if (!$row['approved'] && !$context['show_approval']) |
|
| 765 | - $context['show_approval'] = allowedTo('approve_posts'); |
|
| 795 | + if (!$row['approved'] && !$context['show_approval']) { |
|
| 796 | + $context['show_approval'] = allowedTo('approve_posts'); |
|
| 797 | + } |
|
| 766 | 798 | |
| 767 | 799 | // Sort the attachments so they are in the order saved |
| 768 | 800 | $temp = array(); |
| 769 | 801 | foreach ($attachment_stuff as $attachment) |
| 770 | 802 | { |
| 771 | - if ($attachment['filesize'] >= 0 && !empty($modSettings['attachmentEnable'])) |
|
| 772 | - $temp[$attachment['id_attach']] = $attachment; |
|
| 803 | + if ($attachment['filesize'] >= 0 && !empty($modSettings['attachmentEnable'])) { |
|
| 804 | + $temp[$attachment['id_attach']] = $attachment; |
|
| 805 | + } |
|
| 773 | 806 | |
| 774 | 807 | } |
| 775 | 808 | ksort($temp); |
@@ -831,14 +864,16 @@ discard block |
||
| 831 | 864 | 'is_approved' => 1, |
| 832 | 865 | ) |
| 833 | 866 | ); |
| 834 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 835 | - fatal_lang_error('quoted_post_deleted', false); |
|
| 867 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 868 | + fatal_lang_error('quoted_post_deleted', false); |
|
| 869 | + } |
|
| 836 | 870 | list ($form_subject, $mname, $mdate, $form_message) = $smcFunc['db_fetch_row']($request); |
| 837 | 871 | $smcFunc['db_free_result']($request); |
| 838 | 872 | |
| 839 | 873 | // Add 'Re: ' to the front of the quoted subject. |
| 840 | - if (trim($context['response_prefix']) != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0) |
|
| 841 | - $form_subject = $context['response_prefix'] . $form_subject; |
|
| 874 | + if (trim($context['response_prefix']) != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0) { |
|
| 875 | + $form_subject = $context['response_prefix'] . $form_subject; |
|
| 876 | + } |
|
| 842 | 877 | |
| 843 | 878 | // Censor the message and subject. |
| 844 | 879 | censorText($form_message); |
@@ -851,10 +886,11 @@ discard block |
||
| 851 | 886 | for ($i = 0, $n = count($parts); $i < $n; $i++) |
| 852 | 887 | { |
| 853 | 888 | // It goes 0 = outside, 1 = begin tag, 2 = inside, 3 = close tag, repeat. |
| 854 | - if ($i % 4 == 0) |
|
| 855 | - $parts[$i] = preg_replace_callback('~\[html\](.+?)\[/html\]~is', function($m) |
|
| 889 | + if ($i % 4 == 0) { |
|
| 890 | + $parts[$i] = preg_replace_callback('~\[html\](.+?)\[/html\]~is', function($m) |
|
| 856 | 891 | { |
| 857 | 892 | return '[html]' . preg_replace('~<br\s?/?' . '>~i', '<br /><br>', "$m[1]") . '[/html]'; |
| 893 | + } |
|
| 858 | 894 | }, $parts[$i]); |
| 859 | 895 | } |
| 860 | 896 | $form_message = implode('', $parts); |
@@ -863,8 +899,9 @@ discard block |
||
| 863 | 899 | $form_message = preg_replace('~<br ?/?' . '>~i', "\n", $form_message); |
| 864 | 900 | |
| 865 | 901 | // Remove any nested quotes, if necessary. |
| 866 | - if (!empty($modSettings['removeNestedQuotes'])) |
|
| 867 | - $form_message = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $form_message); |
|
| 902 | + if (!empty($modSettings['removeNestedQuotes'])) { |
|
| 903 | + $form_message = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $form_message); |
|
| 904 | + } |
|
| 868 | 905 | |
| 869 | 906 | // Add a quote string on the front and end. |
| 870 | 907 | $form_message = '[quote author=' . $mname . ' link=msg=' . (int) $_REQUEST['quote'] . ' date=' . $mdate . ']' . "\n" . rtrim($form_message) . "\n" . '[/quote]'; |
@@ -876,15 +913,15 @@ discard block |
||
| 876 | 913 | $form_subject = $first_subject; |
| 877 | 914 | |
| 878 | 915 | // Add 'Re: ' to the front of the subject. |
| 879 | - if (trim($context['response_prefix']) != '' && $form_subject != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0) |
|
| 880 | - $form_subject = $context['response_prefix'] . $form_subject; |
|
| 916 | + if (trim($context['response_prefix']) != '' && $form_subject != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0) { |
|
| 917 | + $form_subject = $context['response_prefix'] . $form_subject; |
|
| 918 | + } |
|
| 881 | 919 | |
| 882 | 920 | // Censor the subject. |
| 883 | 921 | censorText($form_subject); |
| 884 | 922 | |
| 885 | 923 | $form_message = ''; |
| 886 | - } |
|
| 887 | - else |
|
| 924 | + } else |
|
| 888 | 925 | { |
| 889 | 926 | $form_subject = isset($_GET['subject']) ? $_GET['subject'] : ''; |
| 890 | 927 | $form_message = ''; |
@@ -902,13 +939,15 @@ discard block |
||
| 902 | 939 | if (isset($_REQUEST['msg'])) |
| 903 | 940 | { |
| 904 | 941 | $context['attachments']['quantity'] = count($context['current_attachments']); |
| 905 | - foreach ($context['current_attachments'] as $attachment) |
|
| 906 | - $context['attachments']['total_size'] += $attachment['size']; |
|
| 942 | + foreach ($context['current_attachments'] as $attachment) { |
|
| 943 | + $context['attachments']['total_size'] += $attachment['size']; |
|
| 944 | + } |
|
| 907 | 945 | } |
| 908 | 946 | |
| 909 | 947 | // A bit of house keeping first. |
| 910 | - if (!empty($_SESSION['temp_attachments']) && count($_SESSION['temp_attachments']) == 1) |
|
| 911 | - unset($_SESSION['temp_attachments']); |
|
| 948 | + if (!empty($_SESSION['temp_attachments']) && count($_SESSION['temp_attachments']) == 1) { |
|
| 949 | + unset($_SESSION['temp_attachments']); |
|
| 950 | + } |
|
| 912 | 951 | |
| 913 | 952 | if (!empty($_SESSION['temp_attachments'])) |
| 914 | 953 | { |
@@ -917,9 +956,10 @@ discard block |
||
| 917 | 956 | { |
| 918 | 957 | foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
| 919 | 958 | { |
| 920 | - if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false) |
|
| 921 | - if (file_exists($attachment['tmp_name'])) |
|
| 959 | + if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false) { |
|
| 960 | + if (file_exists($attachment['tmp_name'])) |
|
| 922 | 961 | unlink($attachment['tmp_name']); |
| 962 | + } |
|
| 923 | 963 | } |
| 924 | 964 | $post_errors[] = 'temp_attachments_gone'; |
| 925 | 965 | $_SESSION['temp_attachments'] = array(); |
@@ -933,8 +973,9 @@ discard block |
||
| 933 | 973 | // See if any files still exist before showing the warning message and the files attached. |
| 934 | 974 | foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
| 935 | 975 | { |
| 936 | - if (strpos($attachID, 'post_tmp_' . $user_info['id']) === false) |
|
| 937 | - continue; |
|
| 976 | + if (strpos($attachID, 'post_tmp_' . $user_info['id']) === false) { |
|
| 977 | + continue; |
|
| 978 | + } |
|
| 938 | 979 | |
| 939 | 980 | if (file_exists($attachment['tmp_name'])) |
| 940 | 981 | { |
@@ -944,20 +985,21 @@ discard block |
||
| 944 | 985 | break; |
| 945 | 986 | } |
| 946 | 987 | } |
| 947 | - } |
|
| 948 | - else |
|
| 988 | + } else |
|
| 949 | 989 | { |
| 950 | 990 | // Since, they don't belong here. Let's inform the user that they exist.. |
| 951 | - if (!empty($topic)) |
|
| 952 | - $delete_url = $scripturl . '?action=post' . (!empty($_REQUEST['msg']) ? (';msg=' . $_REQUEST['msg']) : '') . (!empty($_REQUEST['last_msg']) ? (';last_msg=' . $_REQUEST['last_msg']) : '') . ';topic=' . $topic . ';delete_temp'; |
|
| 953 | - else |
|
| 954 | - $delete_url = $scripturl . '?action=post;board=' . $board . ';delete_temp'; |
|
| 991 | + if (!empty($topic)) { |
|
| 992 | + $delete_url = $scripturl . '?action=post' . (!empty($_REQUEST['msg']) ? (';msg=' . $_REQUEST['msg']) : '') . (!empty($_REQUEST['last_msg']) ? (';last_msg=' . $_REQUEST['last_msg']) : '') . ';topic=' . $topic . ';delete_temp'; |
|
| 993 | + } else { |
|
| 994 | + $delete_url = $scripturl . '?action=post;board=' . $board . ';delete_temp'; |
|
| 995 | + } |
|
| 955 | 996 | |
| 956 | 997 | // Compile a list of the files to show the user. |
| 957 | 998 | $file_list = array(); |
| 958 | - foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
|
| 959 | - if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false) |
|
| 999 | + foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) { |
|
| 1000 | + if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false) |
|
| 960 | 1001 | $file_list[] = $attachment['name']; |
| 1002 | + } |
|
| 961 | 1003 | |
| 962 | 1004 | $_SESSION['temp_attachments']['post']['files'] = $file_list; |
| 963 | 1005 | $file_list = '<div class="attachments">' . implode('<br>', $file_list) . '</div>'; |
@@ -969,8 +1011,7 @@ discard block |
||
| 969 | 1011 | |
| 970 | 1012 | $post_errors[] = array('temp_attachments_found', array($delete_url, $goback_url, $file_list)); |
| 971 | 1013 | $context['ignore_temp_attachments'] = true; |
| 972 | - } |
|
| 973 | - else |
|
| 1014 | + } else |
|
| 974 | 1015 | { |
| 975 | 1016 | $post_errors[] = array('temp_attachments_lost', array($delete_url, $file_list)); |
| 976 | 1017 | $context['ignore_temp_attachments'] = true; |
@@ -978,16 +1019,19 @@ discard block |
||
| 978 | 1019 | } |
| 979 | 1020 | } |
| 980 | 1021 | |
| 981 | - if (!empty($context['we_are_history'])) |
|
| 982 | - $post_errors[] = $context['we_are_history']; |
|
| 1022 | + if (!empty($context['we_are_history'])) { |
|
| 1023 | + $post_errors[] = $context['we_are_history']; |
|
| 1024 | + } |
|
| 983 | 1025 | |
| 984 | 1026 | foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
| 985 | 1027 | { |
| 986 | - if (isset($context['ignore_temp_attachments']) || isset($_SESSION['temp_attachments']['post']['files'])) |
|
| 987 | - break; |
|
| 1028 | + if (isset($context['ignore_temp_attachments']) || isset($_SESSION['temp_attachments']['post']['files'])) { |
|
| 1029 | + break; |
|
| 1030 | + } |
|
| 988 | 1031 | |
| 989 | - if ($attachID != 'initial_error' && strpos($attachID, 'post_tmp_' . $user_info['id']) === false) |
|
| 990 | - continue; |
|
| 1032 | + if ($attachID != 'initial_error' && strpos($attachID, 'post_tmp_' . $user_info['id']) === false) { |
|
| 1033 | + continue; |
|
| 1034 | + } |
|
| 991 | 1035 | |
| 992 | 1036 | if ($attachID == 'initial_error') |
| 993 | 1037 | { |
@@ -1002,15 +1046,17 @@ discard block |
||
| 1002 | 1046 | { |
| 1003 | 1047 | $txt['error_attach_errors'] = empty($txt['error_attach_errors']) ? '<br>' : ''; |
| 1004 | 1048 | $txt['error_attach_errors'] .= vsprintf($txt['attach_warning'], $attachment['name']) . '<div style="padding: 0 1em;">'; |
| 1005 | - foreach ($attachment['errors'] as $error) |
|
| 1006 | - $txt['error_attach_errors'] .= (is_array($error) ? vsprintf($txt[$error[0]], $error[1]) : $txt[$error]) . '<br >'; |
|
| 1049 | + foreach ($attachment['errors'] as $error) { |
|
| 1050 | + $txt['error_attach_errors'] .= (is_array($error) ? vsprintf($txt[$error[0]], $error[1]) : $txt[$error]) . '<br >'; |
|
| 1051 | + } |
|
| 1007 | 1052 | $txt['error_attach_errors'] .= '</div>'; |
| 1008 | 1053 | $post_errors[] = 'attach_errors'; |
| 1009 | 1054 | |
| 1010 | 1055 | // Take out the trash. |
| 1011 | 1056 | unset($_SESSION['temp_attachments'][$attachID]); |
| 1012 | - if (file_exists($attachment['tmp_name'])) |
|
| 1013 | - unlink($attachment['tmp_name']); |
|
| 1057 | + if (file_exists($attachment['tmp_name'])) { |
|
| 1058 | + unlink($attachment['tmp_name']); |
|
| 1059 | + } |
|
| 1014 | 1060 | continue; |
| 1015 | 1061 | } |
| 1016 | 1062 | |
@@ -1023,8 +1069,9 @@ discard block |
||
| 1023 | 1069 | |
| 1024 | 1070 | $context['attachments']['quantity']++; |
| 1025 | 1071 | $context['attachments']['total_size'] += $attachment['size']; |
| 1026 | - if (!isset($context['files_in_session_warning'])) |
|
| 1027 | - $context['files_in_session_warning'] = $txt['attached_files_in_session']; |
|
| 1072 | + if (!isset($context['files_in_session_warning'])) { |
|
| 1073 | + $context['files_in_session_warning'] = $txt['attached_files_in_session']; |
|
| 1074 | + } |
|
| 1028 | 1075 | |
| 1029 | 1076 | $context['current_attachments'][$attachID] = array( |
| 1030 | 1077 | 'name' => '<u>' . $smcFunc['htmlspecialchars']($attachment['name']) . '</u>', |
@@ -1052,8 +1099,9 @@ discard block |
||
| 1052 | 1099 | } |
| 1053 | 1100 | |
| 1054 | 1101 | // If they came from quick reply, and have to enter verification details, give them some notice. |
| 1055 | - if (!empty($_REQUEST['from_qr']) && !empty($context['require_verification'])) |
|
| 1056 | - $post_errors[] = 'need_qr_verification'; |
|
| 1102 | + if (!empty($_REQUEST['from_qr']) && !empty($context['require_verification'])) { |
|
| 1103 | + $post_errors[] = 'need_qr_verification'; |
|
| 1104 | + } |
|
| 1057 | 1105 | |
| 1058 | 1106 | /* |
| 1059 | 1107 | * There are two error types: serious and minor. Serious errors |
@@ -1070,52 +1118,56 @@ discard block |
||
| 1070 | 1118 | { |
| 1071 | 1119 | loadLanguage('Errors'); |
| 1072 | 1120 | $context['error_type'] = 'minor'; |
| 1073 | - foreach ($post_errors as $post_error) |
|
| 1074 | - if (is_array($post_error)) |
|
| 1121 | + foreach ($post_errors as $post_error) { |
|
| 1122 | + if (is_array($post_error)) |
|
| 1075 | 1123 | { |
| 1076 | 1124 | $post_error_id = $post_error[0]; |
| 1125 | + } |
|
| 1077 | 1126 | $context['post_error'][$post_error_id] = vsprintf($txt['error_' . $post_error_id], $post_error[1]); |
| 1078 | 1127 | |
| 1079 | 1128 | // If it's not a minor error flag it as such. |
| 1080 | - if (!in_array($post_error_id, $minor_errors)) |
|
| 1081 | - $context['error_type'] = 'serious'; |
|
| 1082 | - } |
|
| 1083 | - else |
|
| 1129 | + if (!in_array($post_error_id, $minor_errors)) { |
|
| 1130 | + $context['error_type'] = 'serious'; |
|
| 1131 | + } |
|
| 1132 | + } else |
|
| 1084 | 1133 | { |
| 1085 | 1134 | $context['post_error'][$post_error] = $txt['error_' . $post_error]; |
| 1086 | 1135 | |
| 1087 | 1136 | // If it's not a minor error flag it as such. |
| 1088 | - if (!in_array($post_error, $minor_errors)) |
|
| 1089 | - $context['error_type'] = 'serious'; |
|
| 1137 | + if (!in_array($post_error, $minor_errors)) { |
|
| 1138 | + $context['error_type'] = 'serious'; |
|
| 1139 | + } |
|
| 1090 | 1140 | } |
| 1091 | 1141 | } |
| 1092 | 1142 | |
| 1093 | 1143 | // What are you doing? Posting a poll, modifying, previewing, new post, or reply... |
| 1094 | - if (isset($_REQUEST['poll'])) |
|
| 1095 | - $context['page_title'] = $txt['new_poll']; |
|
| 1096 | - elseif ($context['make_event']) |
|
| 1097 | - $context['page_title'] = $context['event']['id'] == -1 ? $txt['calendar_post_event'] : $txt['calendar_edit']; |
|
| 1098 | - elseif (isset($_REQUEST['msg'])) |
|
| 1099 | - $context['page_title'] = $txt['modify_msg']; |
|
| 1100 | - elseif (isset($_REQUEST['subject'], $context['preview_subject'])) |
|
| 1101 | - $context['page_title'] = $txt['preview'] . ' - ' . strip_tags($context['preview_subject']); |
|
| 1102 | - elseif (empty($topic)) |
|
| 1103 | - $context['page_title'] = $txt['start_new_topic']; |
|
| 1104 | - else |
|
| 1105 | - $context['page_title'] = $txt['post_reply']; |
|
| 1144 | + if (isset($_REQUEST['poll'])) { |
|
| 1145 | + $context['page_title'] = $txt['new_poll']; |
|
| 1146 | + } elseif ($context['make_event']) { |
|
| 1147 | + $context['page_title'] = $context['event']['id'] == -1 ? $txt['calendar_post_event'] : $txt['calendar_edit']; |
|
| 1148 | + } elseif (isset($_REQUEST['msg'])) { |
|
| 1149 | + $context['page_title'] = $txt['modify_msg']; |
|
| 1150 | + } elseif (isset($_REQUEST['subject'], $context['preview_subject'])) { |
|
| 1151 | + $context['page_title'] = $txt['preview'] . ' - ' . strip_tags($context['preview_subject']); |
|
| 1152 | + } elseif (empty($topic)) { |
|
| 1153 | + $context['page_title'] = $txt['start_new_topic']; |
|
| 1154 | + } else { |
|
| 1155 | + $context['page_title'] = $txt['post_reply']; |
|
| 1156 | + } |
|
| 1106 | 1157 | |
| 1107 | 1158 | // Build the link tree. |
| 1108 | - if (empty($topic)) |
|
| 1109 | - $context['linktree'][] = array( |
|
| 1159 | + if (empty($topic)) { |
|
| 1160 | + $context['linktree'][] = array( |
|
| 1110 | 1161 | 'name' => '<em>' . $txt['start_new_topic'] . '</em>' |
| 1111 | 1162 | ); |
| 1112 | - else |
|
| 1113 | - $context['linktree'][] = array( |
|
| 1163 | + } else { |
|
| 1164 | + $context['linktree'][] = array( |
|
| 1114 | 1165 | 'url' => $scripturl . '?topic=' . $topic . '.' . $_REQUEST['start'], |
| 1115 | 1166 | 'name' => $form_subject, |
| 1116 | 1167 | 'extra_before' => '<span><strong class="nav">' . $context['page_title'] . ' (</strong></span>', |
| 1117 | 1168 | 'extra_after' => '<span><strong class="nav">)</strong></span>' |
| 1118 | 1169 | ); |
| 1170 | + } |
|
| 1119 | 1171 | |
| 1120 | 1172 | $context['subject'] = addcslashes($form_subject, '"'); |
| 1121 | 1173 | $context['message'] = str_replace(array('"', '<', '>', ' '), array('"', '<', '>', ' '), $form_message); |
@@ -1159,8 +1211,9 @@ discard block |
||
| 1159 | 1211 | // Message icons - customized icons are off? |
| 1160 | 1212 | $context['icons'] = getMessageIcons($board); |
| 1161 | 1213 | |
| 1162 | - if (!empty($context['icons'])) |
|
| 1163 | - $context['icons'][count($context['icons']) - 1]['is_last'] = true; |
|
| 1214 | + if (!empty($context['icons'])) { |
|
| 1215 | + $context['icons'][count($context['icons']) - 1]['is_last'] = true; |
|
| 1216 | + } |
|
| 1164 | 1217 | |
| 1165 | 1218 | // Are we starting a poll? if set the poll icon as selected if its available |
| 1166 | 1219 | if (isset($_REQUEST['poll'])) |
@@ -1180,8 +1233,9 @@ discard block |
||
| 1180 | 1233 | for ($i = 0, $n = count($context['icons']); $i < $n; $i++) |
| 1181 | 1234 | { |
| 1182 | 1235 | $context['icons'][$i]['selected'] = $context['icon'] == $context['icons'][$i]['value']; |
| 1183 | - if ($context['icons'][$i]['selected']) |
|
| 1184 | - $context['icon_url'] = $context['icons'][$i]['url']; |
|
| 1236 | + if ($context['icons'][$i]['selected']) { |
|
| 1237 | + $context['icon_url'] = $context['icons'][$i]['url']; |
|
| 1238 | + } |
|
| 1185 | 1239 | } |
| 1186 | 1240 | if (empty($context['icon_url'])) |
| 1187 | 1241 | { |
@@ -1195,8 +1249,9 @@ discard block |
||
| 1195 | 1249 | )); |
| 1196 | 1250 | } |
| 1197 | 1251 | |
| 1198 | - if (!empty($topic) && !empty($modSettings['topicSummaryPosts'])) |
|
| 1199 | - getTopic(); |
|
| 1252 | + if (!empty($topic) && !empty($modSettings['topicSummaryPosts'])) { |
|
| 1253 | + getTopic(); |
|
| 1254 | + } |
|
| 1200 | 1255 | |
| 1201 | 1256 | // If the user can post attachments prepare the warning labels. |
| 1202 | 1257 | if ($context['can_post_attachment']) |
@@ -1207,12 +1262,13 @@ discard block |
||
| 1207 | 1262 | $context['attachment_restrictions'] = array(); |
| 1208 | 1263 | $context['allowed_extensions'] = strtr(strtolower($modSettings['attachmentExtensions']), array(',' => ', ')); |
| 1209 | 1264 | $attachmentRestrictionTypes = array('attachmentNumPerPostLimit', 'attachmentPostLimit', 'attachmentSizeLimit'); |
| 1210 | - foreach ($attachmentRestrictionTypes as $type) |
|
| 1211 | - if (!empty($modSettings[$type])) |
|
| 1265 | + foreach ($attachmentRestrictionTypes as $type) { |
|
| 1266 | + if (!empty($modSettings[$type])) |
|
| 1212 | 1267 | { |
| 1213 | 1268 | // Show the max number of attachments if not 0. |
| 1214 | 1269 | if ($type == 'attachmentNumPerPostLimit') |
| 1215 | 1270 | $context['attachment_restrictions'][] = sprintf($txt['attach_remaining'], $modSettings['attachmentNumPerPostLimit'] - $context['attachments']['quantity']); |
| 1271 | + } |
|
| 1216 | 1272 | } |
| 1217 | 1273 | } |
| 1218 | 1274 | |
@@ -1246,8 +1302,8 @@ discard block |
||
| 1246 | 1302 | |
| 1247 | 1303 | if (!empty($context['current_attachments'])) |
| 1248 | 1304 | { |
| 1249 | - foreach ($context['current_attachments'] as $key => $mock) |
|
| 1250 | - addInlineJavaScript(' |
|
| 1305 | + foreach ($context['current_attachments'] as $key => $mock) { |
|
| 1306 | + addInlineJavaScript(' |
|
| 1251 | 1307 | current_attachments.push({ |
| 1252 | 1308 | name: '. JavaScriptEscape($mock['name']) . ', |
| 1253 | 1309 | size: '. $mock['size'] . ', |
@@ -1256,6 +1312,7 @@ discard block |
||
| 1256 | 1312 | type: '. JavaScriptEscape(!empty($mock['mime_type']) ? $mock['mime_type'] : '') . ', |
| 1257 | 1313 | thumbID: '. (!empty($mock['thumb']) ? $mock['thumb'] : 0) . ' |
| 1258 | 1314 | });', true); |
| 1315 | + } |
|
| 1259 | 1316 | } |
| 1260 | 1317 | |
| 1261 | 1318 | // File Upload. |
@@ -1340,8 +1397,9 @@ discard block |
||
| 1340 | 1397 | |
| 1341 | 1398 | |
| 1342 | 1399 | // Finally, load the template. |
| 1343 | - if (!isset($_REQUEST['xml'])) |
|
| 1344 | - loadTemplate('Post'); |
|
| 1400 | + if (!isset($_REQUEST['xml'])) { |
|
| 1401 | + loadTemplate('Post'); |
|
| 1402 | + } |
|
| 1345 | 1403 | |
| 1346 | 1404 | call_integration_hook('integrate_post_end'); |
| 1347 | 1405 | } |
@@ -1362,13 +1420,14 @@ discard block |
||
| 1362 | 1420 | // Sneaking off, are we? |
| 1363 | 1421 | if (empty($_POST) && empty($topic)) |
| 1364 | 1422 | { |
| 1365 | - if (empty($_SERVER['CONTENT_LENGTH'])) |
|
| 1366 | - redirectexit('action=post;board=' . $board . '.0'); |
|
| 1367 | - else |
|
| 1368 | - fatal_lang_error('post_upload_error', false); |
|
| 1423 | + if (empty($_SERVER['CONTENT_LENGTH'])) { |
|
| 1424 | + redirectexit('action=post;board=' . $board . '.0'); |
|
| 1425 | + } else { |
|
| 1426 | + fatal_lang_error('post_upload_error', false); |
|
| 1427 | + } |
|
| 1428 | + } elseif (empty($_POST) && !empty($topic)) { |
|
| 1429 | + redirectexit('action=post;topic=' . $topic . '.0'); |
|
| 1369 | 1430 | } |
| 1370 | - elseif (empty($_POST) && !empty($topic)) |
|
| 1371 | - redirectexit('action=post;topic=' . $topic . '.0'); |
|
| 1372 | 1431 | |
| 1373 | 1432 | // No need! |
| 1374 | 1433 | $context['robot_no_index'] = true; |
@@ -1380,8 +1439,9 @@ discard block |
||
| 1380 | 1439 | $post_errors = array(); |
| 1381 | 1440 | |
| 1382 | 1441 | // If the session has timed out, let the user re-submit their form. |
| 1383 | - if (checkSession('post', '', false) != '') |
|
| 1384 | - $post_errors[] = 'session_timeout'; |
|
| 1442 | + if (checkSession('post', '', false) != '') { |
|
| 1443 | + $post_errors[] = 'session_timeout'; |
|
| 1444 | + } |
|
| 1385 | 1445 | |
| 1386 | 1446 | // Wrong verification code? |
| 1387 | 1447 | if (!$user_info['is_admin'] && !$user_info['is_mod'] && !empty($modSettings['posts_require_captcha']) && ($user_info['posts'] < $modSettings['posts_require_captcha'] || ($user_info['is_guest'] && $modSettings['posts_require_captcha'] == -1))) |
@@ -1391,33 +1451,38 @@ discard block |
||
| 1391 | 1451 | 'id' => 'post', |
| 1392 | 1452 | ); |
| 1393 | 1453 | $context['require_verification'] = create_control_verification($verificationOptions, true); |
| 1394 | - if (is_array($context['require_verification'])) |
|
| 1395 | - $post_errors = array_merge($post_errors, $context['require_verification']); |
|
| 1454 | + if (is_array($context['require_verification'])) { |
|
| 1455 | + $post_errors = array_merge($post_errors, $context['require_verification']); |
|
| 1456 | + } |
|
| 1396 | 1457 | } |
| 1397 | 1458 | |
| 1398 | 1459 | require_once($sourcedir . '/Subs-Post.php'); |
| 1399 | 1460 | loadLanguage('Post'); |
| 1400 | 1461 | |
| 1401 | 1462 | // Drafts enabled and needed? |
| 1402 | - if (!empty($modSettings['drafts_post_enabled']) && (isset($_POST['save_draft']) || isset($_POST['id_draft']))) |
|
| 1403 | - require_once($sourcedir . '/Drafts.php'); |
|
| 1463 | + if (!empty($modSettings['drafts_post_enabled']) && (isset($_POST['save_draft']) || isset($_POST['id_draft']))) { |
|
| 1464 | + require_once($sourcedir . '/Drafts.php'); |
|
| 1465 | + } |
|
| 1404 | 1466 | |
| 1405 | 1467 | // First check to see if they are trying to delete any current attachments. |
| 1406 | 1468 | if (isset($_POST['attach_del'])) |
| 1407 | 1469 | { |
| 1408 | 1470 | $keep_temp = array(); |
| 1409 | 1471 | $keep_ids = array(); |
| 1410 | - foreach ($_POST['attach_del'] as $dummy) |
|
| 1411 | - if (strpos($dummy, 'post_tmp_' . $user_info['id']) !== false) |
|
| 1472 | + foreach ($_POST['attach_del'] as $dummy) { |
|
| 1473 | + if (strpos($dummy, 'post_tmp_' . $user_info['id']) !== false) |
|
| 1412 | 1474 | $keep_temp[] = $dummy; |
| 1413 | - else |
|
| 1414 | - $keep_ids[] = (int) $dummy; |
|
| 1475 | + } |
|
| 1476 | + else { |
|
| 1477 | + $keep_ids[] = (int) $dummy; |
|
| 1478 | + } |
|
| 1415 | 1479 | |
| 1416 | - if (isset($_SESSION['temp_attachments'])) |
|
| 1417 | - foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
|
| 1480 | + if (isset($_SESSION['temp_attachments'])) { |
|
| 1481 | + foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
|
| 1418 | 1482 | { |
| 1419 | 1483 | if ((isset($_SESSION['temp_attachments']['post']['files'], $attachment['name']) && in_array($attachment['name'], $_SESSION['temp_attachments']['post']['files'])) || in_array($attachID, $keep_temp) || strpos($attachID, 'post_tmp_' . $user_info['id']) === false) |
| 1420 | 1484 | continue; |
| 1485 | + } |
|
| 1421 | 1486 | |
| 1422 | 1487 | unset($_SESSION['temp_attachments'][$attachID]); |
| 1423 | 1488 | unlink($attachment['tmp_name']); |
@@ -1459,12 +1524,14 @@ discard block |
||
| 1459 | 1524 | $smcFunc['db_free_result']($request); |
| 1460 | 1525 | |
| 1461 | 1526 | // Though the topic should be there, it might have vanished. |
| 1462 | - if (!is_array($topic_info)) |
|
| 1463 | - fatal_lang_error('topic_doesnt_exist', 404); |
|
| 1527 | + if (!is_array($topic_info)) { |
|
| 1528 | + fatal_lang_error('topic_doesnt_exist', 404); |
|
| 1529 | + } |
|
| 1464 | 1530 | |
| 1465 | 1531 | // Did this topic suddenly move? Just checking... |
| 1466 | - if ($topic_info['id_board'] != $board) |
|
| 1467 | - fatal_lang_error('not_a_topic'); |
|
| 1532 | + if ($topic_info['id_board'] != $board) { |
|
| 1533 | + fatal_lang_error('not_a_topic'); |
|
| 1534 | + } |
|
| 1468 | 1535 | |
| 1469 | 1536 | // Do the permissions and approval stuff... |
| 1470 | 1537 | $becomesApproved = true; |
@@ -1487,49 +1554,50 @@ discard block |
||
| 1487 | 1554 | if (!empty($topic) && !isset($_REQUEST['msg'])) |
| 1488 | 1555 | { |
| 1489 | 1556 | // Don't allow a post if it's locked. |
| 1490 | - if ($topic_info['locked'] != 0 && !allowedTo('moderate_board')) |
|
| 1491 | - fatal_lang_error('topic_locked', false); |
|
| 1557 | + if ($topic_info['locked'] != 0 && !allowedTo('moderate_board')) { |
|
| 1558 | + fatal_lang_error('topic_locked', false); |
|
| 1559 | + } |
|
| 1492 | 1560 | |
| 1493 | 1561 | // Sorry, multiple polls aren't allowed... yet. You should stop giving me ideas :P. |
| 1494 | - if (isset($_REQUEST['poll']) && $topic_info['id_poll'] > 0) |
|
| 1495 | - unset($_REQUEST['poll']); |
|
| 1496 | - |
|
| 1497 | - elseif ($topic_info['id_member_started'] != $user_info['id']) |
|
| 1498 | - { |
|
| 1499 | - if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_any') && !allowedTo('post_reply_any')) |
|
| 1500 | - $becomesApproved = false; |
|
| 1501 | - |
|
| 1502 | - else |
|
| 1503 | - isAllowedTo('post_reply_any'); |
|
| 1504 | - } |
|
| 1505 | - elseif (!allowedTo('post_reply_any')) |
|
| 1562 | + if (isset($_REQUEST['poll']) && $topic_info['id_poll'] > 0) { |
|
| 1563 | + unset($_REQUEST['poll']); |
|
| 1564 | + } elseif ($topic_info['id_member_started'] != $user_info['id']) |
|
| 1565 | + { |
|
| 1566 | + if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_any') && !allowedTo('post_reply_any')) { |
|
| 1567 | + $becomesApproved = false; |
|
| 1568 | + } else { |
|
| 1569 | + isAllowedTo('post_reply_any'); |
|
| 1570 | + } |
|
| 1571 | + } elseif (!allowedTo('post_reply_any')) |
|
| 1506 | 1572 | { |
| 1507 | - if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_own') && !allowedTo('post_reply_own')) |
|
| 1508 | - $becomesApproved = false; |
|
| 1509 | - |
|
| 1510 | - else |
|
| 1511 | - isAllowedTo('post_reply_own'); |
|
| 1573 | + if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_own') && !allowedTo('post_reply_own')) { |
|
| 1574 | + $becomesApproved = false; |
|
| 1575 | + } else { |
|
| 1576 | + isAllowedTo('post_reply_own'); |
|
| 1577 | + } |
|
| 1512 | 1578 | } |
| 1513 | 1579 | |
| 1514 | 1580 | if (isset($_POST['lock'])) |
| 1515 | 1581 | { |
| 1516 | 1582 | // Nothing is changed to the lock. |
| 1517 | - if ((empty($topic_info['locked']) && empty($_POST['lock'])) || (!empty($_POST['lock']) && !empty($topic_info['locked']))) |
|
| 1518 | - unset($_POST['lock']); |
|
| 1583 | + if ((empty($topic_info['locked']) && empty($_POST['lock'])) || (!empty($_POST['lock']) && !empty($topic_info['locked']))) { |
|
| 1584 | + unset($_POST['lock']); |
|
| 1585 | + } |
|
| 1519 | 1586 | |
| 1520 | 1587 | // You're have no permission to lock this topic. |
| 1521 | - elseif (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $topic_info['id_member_started'])) |
|
| 1522 | - unset($_POST['lock']); |
|
| 1588 | + elseif (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $topic_info['id_member_started'])) { |
|
| 1589 | + unset($_POST['lock']); |
|
| 1590 | + } |
|
| 1523 | 1591 | |
| 1524 | 1592 | // You are allowed to (un)lock your own topic only. |
| 1525 | 1593 | elseif (!allowedTo('lock_any')) |
| 1526 | 1594 | { |
| 1527 | 1595 | // You cannot override a moderator lock. |
| 1528 | - if ($topic_info['locked'] == 1) |
|
| 1529 | - unset($_POST['lock']); |
|
| 1530 | - |
|
| 1531 | - else |
|
| 1532 | - $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
| 1596 | + if ($topic_info['locked'] == 1) { |
|
| 1597 | + unset($_POST['lock']); |
|
| 1598 | + } else { |
|
| 1599 | + $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
| 1600 | + } |
|
| 1533 | 1601 | } |
| 1534 | 1602 | // Hail mighty moderator, (un)lock this topic immediately. |
| 1535 | 1603 | else |
@@ -1537,19 +1605,21 @@ discard block |
||
| 1537 | 1605 | $_POST['lock'] = empty($_POST['lock']) ? 0 : 1; |
| 1538 | 1606 | |
| 1539 | 1607 | // Did someone (un)lock this while you were posting? |
| 1540 | - if (isset($_POST['already_locked']) && $_POST['already_locked'] != $topic_info['locked']) |
|
| 1541 | - $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'locked'; |
|
| 1608 | + if (isset($_POST['already_locked']) && $_POST['already_locked'] != $topic_info['locked']) { |
|
| 1609 | + $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'locked'; |
|
| 1610 | + } |
|
| 1542 | 1611 | } |
| 1543 | 1612 | } |
| 1544 | 1613 | |
| 1545 | 1614 | // So you wanna (un)sticky this...let's see. |
| 1546 | - if (isset($_POST['sticky']) && ($_POST['sticky'] == $topic_info['is_sticky'] || !allowedTo('make_sticky'))) |
|
| 1547 | - unset($_POST['sticky']); |
|
| 1548 | - elseif (isset($_POST['sticky'])) |
|
| 1615 | + if (isset($_POST['sticky']) && ($_POST['sticky'] == $topic_info['is_sticky'] || !allowedTo('make_sticky'))) { |
|
| 1616 | + unset($_POST['sticky']); |
|
| 1617 | + } elseif (isset($_POST['sticky'])) |
|
| 1549 | 1618 | { |
| 1550 | 1619 | // Did someone (un)sticky this while you were posting? |
| 1551 | - if (isset($_POST['already_sticky']) && $_POST['already_sticky'] != $topic_info['is_sticky']) |
|
| 1552 | - $post_errors[] = 'topic_' . (empty($topic_info['is_sticky']) ? 'un' : '') . 'sticky'; |
|
| 1620 | + if (isset($_POST['already_sticky']) && $_POST['already_sticky'] != $topic_info['is_sticky']) { |
|
| 1621 | + $post_errors[] = 'topic_' . (empty($topic_info['is_sticky']) ? 'un' : '') . 'sticky'; |
|
| 1622 | + } |
|
| 1553 | 1623 | } |
| 1554 | 1624 | |
| 1555 | 1625 | // If drafts are enabled, then pass this off |
@@ -1576,26 +1646,31 @@ discard block |
||
| 1576 | 1646 | |
| 1577 | 1647 | // Do like, the permissions, for safety and stuff... |
| 1578 | 1648 | $becomesApproved = true; |
| 1579 | - if ($modSettings['postmod_active'] && !allowedTo('post_new') && allowedTo('post_unapproved_topics')) |
|
| 1580 | - $becomesApproved = false; |
|
| 1581 | - else |
|
| 1582 | - isAllowedTo('post_new'); |
|
| 1649 | + if ($modSettings['postmod_active'] && !allowedTo('post_new') && allowedTo('post_unapproved_topics')) { |
|
| 1650 | + $becomesApproved = false; |
|
| 1651 | + } else { |
|
| 1652 | + isAllowedTo('post_new'); |
|
| 1653 | + } |
|
| 1583 | 1654 | |
| 1584 | 1655 | if (isset($_POST['lock'])) |
| 1585 | 1656 | { |
| 1586 | 1657 | // New topics are by default not locked. |
| 1587 | - if (empty($_POST['lock'])) |
|
| 1588 | - unset($_POST['lock']); |
|
| 1658 | + if (empty($_POST['lock'])) { |
|
| 1659 | + unset($_POST['lock']); |
|
| 1660 | + } |
|
| 1589 | 1661 | // Besides, you need permission. |
| 1590 | - elseif (!allowedTo(array('lock_any', 'lock_own'))) |
|
| 1591 | - unset($_POST['lock']); |
|
| 1662 | + elseif (!allowedTo(array('lock_any', 'lock_own'))) { |
|
| 1663 | + unset($_POST['lock']); |
|
| 1664 | + } |
|
| 1592 | 1665 | // A moderator-lock (1) can override a user-lock (2). |
| 1593 | - else |
|
| 1594 | - $_POST['lock'] = allowedTo('lock_any') ? 1 : 2; |
|
| 1666 | + else { |
|
| 1667 | + $_POST['lock'] = allowedTo('lock_any') ? 1 : 2; |
|
| 1668 | + } |
|
| 1595 | 1669 | } |
| 1596 | 1670 | |
| 1597 | - if (isset($_POST['sticky']) && (empty($_POST['sticky']) || !allowedTo('make_sticky'))) |
|
| 1598 | - unset($_POST['sticky']); |
|
| 1671 | + if (isset($_POST['sticky']) && (empty($_POST['sticky']) || !allowedTo('make_sticky'))) { |
|
| 1672 | + unset($_POST['sticky']); |
|
| 1673 | + } |
|
| 1599 | 1674 | |
| 1600 | 1675 | // Saving your new topic as a draft first? |
| 1601 | 1676 | if (!empty($modSettings['drafts_post_enabled']) && isset($_POST['save_draft'])) |
@@ -1620,31 +1695,37 @@ discard block |
||
| 1620 | 1695 | 'id_msg' => $_REQUEST['msg'], |
| 1621 | 1696 | ) |
| 1622 | 1697 | ); |
| 1623 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 1624 | - fatal_lang_error('cant_find_messages', false); |
|
| 1698 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 1699 | + fatal_lang_error('cant_find_messages', false); |
|
| 1700 | + } |
|
| 1625 | 1701 | $row = $smcFunc['db_fetch_assoc']($request); |
| 1626 | 1702 | $smcFunc['db_free_result']($request); |
| 1627 | 1703 | |
| 1628 | - if (!empty($topic_info['locked']) && !allowedTo('moderate_board')) |
|
| 1629 | - fatal_lang_error('topic_locked', false); |
|
| 1704 | + if (!empty($topic_info['locked']) && !allowedTo('moderate_board')) { |
|
| 1705 | + fatal_lang_error('topic_locked', false); |
|
| 1706 | + } |
|
| 1630 | 1707 | |
| 1631 | 1708 | if (isset($_POST['lock'])) |
| 1632 | 1709 | { |
| 1633 | 1710 | // Nothing changes to the lock status. |
| 1634 | - if ((empty($_POST['lock']) && empty($topic_info['locked'])) || (!empty($_POST['lock']) && !empty($topic_info['locked']))) |
|
| 1635 | - unset($_POST['lock']); |
|
| 1711 | + if ((empty($_POST['lock']) && empty($topic_info['locked'])) || (!empty($_POST['lock']) && !empty($topic_info['locked']))) { |
|
| 1712 | + unset($_POST['lock']); |
|
| 1713 | + } |
|
| 1636 | 1714 | // You're simply not allowed to (un)lock this. |
| 1637 | - elseif (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $topic_info['id_member_started'])) |
|
| 1638 | - unset($_POST['lock']); |
|
| 1715 | + elseif (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $topic_info['id_member_started'])) { |
|
| 1716 | + unset($_POST['lock']); |
|
| 1717 | + } |
|
| 1639 | 1718 | // You're only allowed to lock your own topics. |
| 1640 | 1719 | elseif (!allowedTo('lock_any')) |
| 1641 | 1720 | { |
| 1642 | 1721 | // You're not allowed to break a moderator's lock. |
| 1643 | - if ($topic_info['locked'] == 1) |
|
| 1644 | - unset($_POST['lock']); |
|
| 1722 | + if ($topic_info['locked'] == 1) { |
|
| 1723 | + unset($_POST['lock']); |
|
| 1724 | + } |
|
| 1645 | 1725 | // Lock it with a soft lock or unlock it. |
| 1646 | - else |
|
| 1647 | - $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
| 1726 | + else { |
|
| 1727 | + $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
| 1728 | + } |
|
| 1648 | 1729 | } |
| 1649 | 1730 | // You must be the moderator. |
| 1650 | 1731 | else |
@@ -1652,44 +1733,46 @@ discard block |
||
| 1652 | 1733 | $_POST['lock'] = empty($_POST['lock']) ? 0 : 1; |
| 1653 | 1734 | |
| 1654 | 1735 | // Did someone (un)lock this while you were posting? |
| 1655 | - if (isset($_POST['already_locked']) && $_POST['already_locked'] != $topic_info['locked']) |
|
| 1656 | - $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'locked'; |
|
| 1736 | + if (isset($_POST['already_locked']) && $_POST['already_locked'] != $topic_info['locked']) { |
|
| 1737 | + $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'locked'; |
|
| 1738 | + } |
|
| 1657 | 1739 | } |
| 1658 | 1740 | } |
| 1659 | 1741 | |
| 1660 | 1742 | // Change the sticky status of this topic? |
| 1661 | - if (isset($_POST['sticky']) && (!allowedTo('make_sticky') || $_POST['sticky'] == $topic_info['is_sticky'])) |
|
| 1662 | - unset($_POST['sticky']); |
|
| 1663 | - elseif (isset($_POST['sticky'])) |
|
| 1743 | + if (isset($_POST['sticky']) && (!allowedTo('make_sticky') || $_POST['sticky'] == $topic_info['is_sticky'])) { |
|
| 1744 | + unset($_POST['sticky']); |
|
| 1745 | + } elseif (isset($_POST['sticky'])) |
|
| 1664 | 1746 | { |
| 1665 | 1747 | // Did someone (un)sticky this while you were posting? |
| 1666 | - if (isset($_POST['already_sticky']) && $_POST['already_sticky'] != $topic_info['is_sticky']) |
|
| 1667 | - $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'stickied'; |
|
| 1748 | + if (isset($_POST['already_sticky']) && $_POST['already_sticky'] != $topic_info['is_sticky']) { |
|
| 1749 | + $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'stickied'; |
|
| 1750 | + } |
|
| 1668 | 1751 | } |
| 1669 | 1752 | |
| 1670 | 1753 | if ($row['id_member'] == $user_info['id'] && !allowedTo('modify_any')) |
| 1671 | 1754 | { |
| 1672 | - if ((!$modSettings['postmod_active'] || $row['approved']) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) |
|
| 1673 | - fatal_lang_error('modify_post_time_passed', false); |
|
| 1674 | - elseif ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('modify_own')) |
|
| 1675 | - isAllowedTo('modify_replies'); |
|
| 1676 | - else |
|
| 1677 | - isAllowedTo('modify_own'); |
|
| 1678 | - } |
|
| 1679 | - elseif ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('modify_any')) |
|
| 1755 | + if ((!$modSettings['postmod_active'] || $row['approved']) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) { |
|
| 1756 | + fatal_lang_error('modify_post_time_passed', false); |
|
| 1757 | + } elseif ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('modify_own')) { |
|
| 1758 | + isAllowedTo('modify_replies'); |
|
| 1759 | + } else { |
|
| 1760 | + isAllowedTo('modify_own'); |
|
| 1761 | + } |
|
| 1762 | + } elseif ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('modify_any')) |
|
| 1680 | 1763 | { |
| 1681 | 1764 | isAllowedTo('modify_replies'); |
| 1682 | 1765 | |
| 1683 | 1766 | // If you're modifying a reply, I say it better be logged... |
| 1684 | 1767 | $moderationAction = true; |
| 1685 | - } |
|
| 1686 | - else |
|
| 1768 | + } else |
|
| 1687 | 1769 | { |
| 1688 | 1770 | isAllowedTo('modify_any'); |
| 1689 | 1771 | |
| 1690 | 1772 | // Log it, assuming you're not modifying your own post. |
| 1691 | - if ($row['id_member'] != $user_info['id']) |
|
| 1692 | - $moderationAction = true; |
|
| 1773 | + if ($row['id_member'] != $user_info['id']) { |
|
| 1774 | + $moderationAction = true; |
|
| 1775 | + } |
|
| 1693 | 1776 | } |
| 1694 | 1777 | |
| 1695 | 1778 | // If drafts are enabled, then lets send this off to save |
@@ -1727,20 +1810,24 @@ discard block |
||
| 1727 | 1810 | $_POST['guestname'] = !isset($_POST['guestname']) ? '' : trim($_POST['guestname']); |
| 1728 | 1811 | $_POST['email'] = !isset($_POST['email']) ? '' : trim($_POST['email']); |
| 1729 | 1812 | |
| 1730 | - if ($_POST['guestname'] == '' || $_POST['guestname'] == '_') |
|
| 1731 | - $post_errors[] = 'no_name'; |
|
| 1732 | - if ($smcFunc['strlen']($_POST['guestname']) > 25) |
|
| 1733 | - $post_errors[] = 'long_name'; |
|
| 1813 | + if ($_POST['guestname'] == '' || $_POST['guestname'] == '_') { |
|
| 1814 | + $post_errors[] = 'no_name'; |
|
| 1815 | + } |
|
| 1816 | + if ($smcFunc['strlen']($_POST['guestname']) > 25) { |
|
| 1817 | + $post_errors[] = 'long_name'; |
|
| 1818 | + } |
|
| 1734 | 1819 | |
| 1735 | 1820 | if (empty($modSettings['guest_post_no_email'])) |
| 1736 | 1821 | { |
| 1737 | 1822 | // Only check if they changed it! |
| 1738 | 1823 | if (!isset($row) || $row['poster_email'] != $_POST['email']) |
| 1739 | 1824 | { |
| 1740 | - if (!allowedTo('moderate_forum') && (!isset($_POST['email']) || $_POST['email'] == '')) |
|
| 1741 | - $post_errors[] = 'no_email'; |
|
| 1742 | - if (!allowedTo('moderate_forum') && !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) |
|
| 1743 | - $post_errors[] = 'bad_email'; |
|
| 1825 | + if (!allowedTo('moderate_forum') && (!isset($_POST['email']) || $_POST['email'] == '')) { |
|
| 1826 | + $post_errors[] = 'no_email'; |
|
| 1827 | + } |
|
| 1828 | + if (!allowedTo('moderate_forum') && !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) { |
|
| 1829 | + $post_errors[] = 'bad_email'; |
|
| 1830 | + } |
|
| 1744 | 1831 | } |
| 1745 | 1832 | |
| 1746 | 1833 | // Now make sure this email address is not banned from posting. |
@@ -1756,75 +1843,89 @@ discard block |
||
| 1756 | 1843 | } |
| 1757 | 1844 | |
| 1758 | 1845 | // Coming from the quickReply? |
| 1759 | - if (isset($_POST['quickReply'])) |
|
| 1760 | - $_POST['message'] = $_POST['quickReply']; |
|
| 1846 | + if (isset($_POST['quickReply'])) { |
|
| 1847 | + $_POST['message'] = $_POST['quickReply']; |
|
| 1848 | + } |
|
| 1761 | 1849 | |
| 1762 | 1850 | // Check the subject and message. |
| 1763 | - if (!isset($_POST['subject']) || $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['subject'])) === '') |
|
| 1764 | - $post_errors[] = 'no_subject'; |
|
| 1765 | - if (!isset($_POST['message']) || $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['message']), ENT_QUOTES) === '') |
|
| 1766 | - $post_errors[] = 'no_message'; |
|
| 1767 | - elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_POST['message']) > $modSettings['max_messageLength']) |
|
| 1768 | - $post_errors[] = array('long_message', array($modSettings['max_messageLength'])); |
|
| 1769 | - else |
|
| 1851 | + if (!isset($_POST['subject']) || $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['subject'])) === '') { |
|
| 1852 | + $post_errors[] = 'no_subject'; |
|
| 1853 | + } |
|
| 1854 | + if (!isset($_POST['message']) || $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['message']), ENT_QUOTES) === '') { |
|
| 1855 | + $post_errors[] = 'no_message'; |
|
| 1856 | + } elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_POST['message']) > $modSettings['max_messageLength']) { |
|
| 1857 | + $post_errors[] = array('long_message', array($modSettings['max_messageLength'])); |
|
| 1858 | + } else |
|
| 1770 | 1859 | { |
| 1771 | 1860 | // Prepare the message a bit for some additional testing. |
| 1772 | 1861 | $_POST['message'] = $smcFunc['htmlspecialchars']($_POST['message'], ENT_QUOTES); |
| 1773 | 1862 | |
| 1774 | 1863 | // Preparse code. (Zef) |
| 1775 | - if ($user_info['is_guest']) |
|
| 1776 | - $user_info['name'] = $_POST['guestname']; |
|
| 1864 | + if ($user_info['is_guest']) { |
|
| 1865 | + $user_info['name'] = $_POST['guestname']; |
|
| 1866 | + } |
|
| 1777 | 1867 | preparsecode($_POST['message']); |
| 1778 | 1868 | |
| 1779 | 1869 | // Let's see if there's still some content left without the tags. |
| 1780 | - if ($smcFunc['htmltrim'](strip_tags(parse_bbc($_POST['message'], false), implode('', $context['allowed_html_tags']))) === '' && (!allowedTo('admin_forum') || strpos($_POST['message'], '[html]') === false)) |
|
| 1781 | - $post_errors[] = 'no_message'; |
|
| 1870 | + if ($smcFunc['htmltrim'](strip_tags(parse_bbc($_POST['message'], false), implode('', $context['allowed_html_tags']))) === '' && (!allowedTo('admin_forum') || strpos($_POST['message'], '[html]') === false)) { |
|
| 1871 | + $post_errors[] = 'no_message'; |
|
| 1872 | + } |
|
| 1873 | + } |
|
| 1874 | + if (isset($_POST['calendar']) && !isset($_REQUEST['deleteevent']) && $smcFunc['htmltrim']($_POST['evtitle']) === '') { |
|
| 1875 | + $post_errors[] = 'no_event'; |
|
| 1782 | 1876 | } |
| 1783 | - if (isset($_POST['calendar']) && !isset($_REQUEST['deleteevent']) && $smcFunc['htmltrim']($_POST['evtitle']) === '') |
|
| 1784 | - $post_errors[] = 'no_event'; |
|
| 1785 | 1877 | // You are not! |
| 1786 | - if (isset($_POST['message']) && strtolower($_POST['message']) == 'i am the administrator.' && !$user_info['is_admin']) |
|
| 1787 | - fatal_error('Knave! Masquerader! Charlatan!', false); |
|
| 1878 | + if (isset($_POST['message']) && strtolower($_POST['message']) == 'i am the administrator.' && !$user_info['is_admin']) { |
|
| 1879 | + fatal_error('Knave! Masquerader! Charlatan!', false); |
|
| 1880 | + } |
|
| 1788 | 1881 | |
| 1789 | 1882 | // Validate the poll... |
| 1790 | 1883 | if (isset($_REQUEST['poll']) && $modSettings['pollMode'] == '1') |
| 1791 | 1884 | { |
| 1792 | - if (!empty($topic) && !isset($_REQUEST['msg'])) |
|
| 1793 | - fatal_lang_error('no_access', false); |
|
| 1885 | + if (!empty($topic) && !isset($_REQUEST['msg'])) { |
|
| 1886 | + fatal_lang_error('no_access', false); |
|
| 1887 | + } |
|
| 1794 | 1888 | |
| 1795 | 1889 | // This is a new topic... so it's a new poll. |
| 1796 | - if (empty($topic)) |
|
| 1797 | - isAllowedTo('poll_post'); |
|
| 1890 | + if (empty($topic)) { |
|
| 1891 | + isAllowedTo('poll_post'); |
|
| 1892 | + } |
|
| 1798 | 1893 | // Can you add to your own topics? |
| 1799 | - elseif ($user_info['id'] == $topic_info['id_member_started'] && !allowedTo('poll_add_any')) |
|
| 1800 | - isAllowedTo('poll_add_own'); |
|
| 1894 | + elseif ($user_info['id'] == $topic_info['id_member_started'] && !allowedTo('poll_add_any')) { |
|
| 1895 | + isAllowedTo('poll_add_own'); |
|
| 1896 | + } |
|
| 1801 | 1897 | // Can you add polls to any topic, then? |
| 1802 | - else |
|
| 1803 | - isAllowedTo('poll_add_any'); |
|
| 1898 | + else { |
|
| 1899 | + isAllowedTo('poll_add_any'); |
|
| 1900 | + } |
|
| 1804 | 1901 | |
| 1805 | - if (!isset($_POST['question']) || trim($_POST['question']) == '') |
|
| 1806 | - $post_errors[] = 'no_question'; |
|
| 1902 | + if (!isset($_POST['question']) || trim($_POST['question']) == '') { |
|
| 1903 | + $post_errors[] = 'no_question'; |
|
| 1904 | + } |
|
| 1807 | 1905 | |
| 1808 | 1906 | $_POST['options'] = empty($_POST['options']) ? array() : htmltrim__recursive($_POST['options']); |
| 1809 | 1907 | |
| 1810 | 1908 | // Get rid of empty ones. |
| 1811 | - foreach ($_POST['options'] as $k => $option) |
|
| 1812 | - if ($option == '') |
|
| 1909 | + foreach ($_POST['options'] as $k => $option) { |
|
| 1910 | + if ($option == '') |
|
| 1813 | 1911 | unset($_POST['options'][$k], $_POST['options'][$k]); |
| 1912 | + } |
|
| 1814 | 1913 | |
| 1815 | 1914 | // What are you going to vote between with one choice?!? |
| 1816 | - if (count($_POST['options']) < 2) |
|
| 1817 | - $post_errors[] = 'poll_few'; |
|
| 1818 | - elseif (count($_POST['options']) > 256) |
|
| 1819 | - $post_errors[] = 'poll_many'; |
|
| 1915 | + if (count($_POST['options']) < 2) { |
|
| 1916 | + $post_errors[] = 'poll_few'; |
|
| 1917 | + } elseif (count($_POST['options']) > 256) { |
|
| 1918 | + $post_errors[] = 'poll_many'; |
|
| 1919 | + } |
|
| 1820 | 1920 | } |
| 1821 | 1921 | |
| 1822 | 1922 | if ($posterIsGuest) |
| 1823 | 1923 | { |
| 1824 | 1924 | // If user is a guest, make sure the chosen name isn't taken. |
| 1825 | 1925 | require_once($sourcedir . '/Subs-Members.php'); |
| 1826 | - if (isReservedName($_POST['guestname'], 0, true, false) && (!isset($row['poster_name']) || $_POST['guestname'] != $row['poster_name'])) |
|
| 1827 | - $post_errors[] = 'bad_name'; |
|
| 1926 | + if (isReservedName($_POST['guestname'], 0, true, false) && (!isset($row['poster_name']) || $_POST['guestname'] != $row['poster_name'])) { |
|
| 1927 | + $post_errors[] = 'bad_name'; |
|
| 1928 | + } |
|
| 1828 | 1929 | } |
| 1829 | 1930 | // If the user isn't a guest, get his or her name and email. |
| 1830 | 1931 | elseif (!isset($_REQUEST['msg'])) |
@@ -1855,8 +1956,9 @@ discard block |
||
| 1855 | 1956 | } |
| 1856 | 1957 | |
| 1857 | 1958 | // Make sure the user isn't spamming the board. |
| 1858 | - if (!isset($_REQUEST['msg'])) |
|
| 1859 | - spamProtection('post'); |
|
| 1959 | + if (!isset($_REQUEST['msg'])) { |
|
| 1960 | + spamProtection('post'); |
|
| 1961 | + } |
|
| 1860 | 1962 | |
| 1861 | 1963 | // At about this point, we're posting and that's that. |
| 1862 | 1964 | ignore_user_abort(true); |
@@ -1869,32 +1971,36 @@ discard block |
||
| 1869 | 1971 | $_POST['modify_reason'] = empty($_POST['modify_reason']) ? '' : strtr($smcFunc['htmlspecialchars']($_POST['modify_reason']), array("\r" => '', "\n" => '', "\t" => '')); |
| 1870 | 1972 | |
| 1871 | 1973 | // At this point, we want to make sure the subject isn't too long. |
| 1872 | - if ($smcFunc['strlen']($_POST['subject']) > 100) |
|
| 1873 | - $_POST['subject'] = $smcFunc['substr']($_POST['subject'], 0, 100); |
|
| 1974 | + if ($smcFunc['strlen']($_POST['subject']) > 100) { |
|
| 1975 | + $_POST['subject'] = $smcFunc['substr']($_POST['subject'], 0, 100); |
|
| 1976 | + } |
|
| 1874 | 1977 | |
| 1875 | 1978 | // Same with the "why did you edit this" text. |
| 1876 | - if ($smcFunc['strlen']($_POST['modify_reason']) > 100) |
|
| 1877 | - $_POST['modify_reason'] = $smcFunc['substr']($_POST['modify_reason'], 0, 100); |
|
| 1979 | + if ($smcFunc['strlen']($_POST['modify_reason']) > 100) { |
|
| 1980 | + $_POST['modify_reason'] = $smcFunc['substr']($_POST['modify_reason'], 0, 100); |
|
| 1981 | + } |
|
| 1878 | 1982 | |
| 1879 | 1983 | // Make the poll... |
| 1880 | 1984 | if (isset($_REQUEST['poll'])) |
| 1881 | 1985 | { |
| 1882 | 1986 | // Make sure that the user has not entered a ridiculous number of options.. |
| 1883 | - if (empty($_POST['poll_max_votes']) || $_POST['poll_max_votes'] <= 0) |
|
| 1884 | - $_POST['poll_max_votes'] = 1; |
|
| 1885 | - elseif ($_POST['poll_max_votes'] > count($_POST['options'])) |
|
| 1886 | - $_POST['poll_max_votes'] = count($_POST['options']); |
|
| 1887 | - else |
|
| 1888 | - $_POST['poll_max_votes'] = (int) $_POST['poll_max_votes']; |
|
| 1987 | + if (empty($_POST['poll_max_votes']) || $_POST['poll_max_votes'] <= 0) { |
|
| 1988 | + $_POST['poll_max_votes'] = 1; |
|
| 1989 | + } elseif ($_POST['poll_max_votes'] > count($_POST['options'])) { |
|
| 1990 | + $_POST['poll_max_votes'] = count($_POST['options']); |
|
| 1991 | + } else { |
|
| 1992 | + $_POST['poll_max_votes'] = (int) $_POST['poll_max_votes']; |
|
| 1993 | + } |
|
| 1889 | 1994 | |
| 1890 | 1995 | $_POST['poll_expire'] = (int) $_POST['poll_expire']; |
| 1891 | 1996 | $_POST['poll_expire'] = $_POST['poll_expire'] > 9999 ? 9999 : ($_POST['poll_expire'] < 0 ? 0 : $_POST['poll_expire']); |
| 1892 | 1997 | |
| 1893 | 1998 | // Just set it to zero if it's not there.. |
| 1894 | - if (!isset($_POST['poll_hide'])) |
|
| 1895 | - $_POST['poll_hide'] = 0; |
|
| 1896 | - else |
|
| 1897 | - $_POST['poll_hide'] = (int) $_POST['poll_hide']; |
|
| 1999 | + if (!isset($_POST['poll_hide'])) { |
|
| 2000 | + $_POST['poll_hide'] = 0; |
|
| 2001 | + } else { |
|
| 2002 | + $_POST['poll_hide'] = (int) $_POST['poll_hide']; |
|
| 2003 | + } |
|
| 1898 | 2004 | $_POST['poll_change_vote'] = isset($_POST['poll_change_vote']) ? 1 : 0; |
| 1899 | 2005 | |
| 1900 | 2006 | $_POST['poll_guest_vote'] = isset($_POST['poll_guest_vote']) ? 1 : 0; |
@@ -1903,16 +2009,19 @@ discard block |
||
| 1903 | 2009 | { |
| 1904 | 2010 | require_once($sourcedir . '/Subs-Members.php'); |
| 1905 | 2011 | $allowedVoteGroups = groupsAllowedTo('poll_vote', $board); |
| 1906 | - if (!in_array(-1, $allowedVoteGroups['allowed'])) |
|
| 1907 | - $_POST['poll_guest_vote'] = 0; |
|
| 2012 | + if (!in_array(-1, $allowedVoteGroups['allowed'])) { |
|
| 2013 | + $_POST['poll_guest_vote'] = 0; |
|
| 2014 | + } |
|
| 1908 | 2015 | } |
| 1909 | 2016 | |
| 1910 | 2017 | // If the user tries to set the poll too far in advance, don't let them. |
| 1911 | - if (!empty($_POST['poll_expire']) && $_POST['poll_expire'] < 1) |
|
| 1912 | - fatal_lang_error('poll_range_error', false); |
|
| 2018 | + if (!empty($_POST['poll_expire']) && $_POST['poll_expire'] < 1) { |
|
| 2019 | + fatal_lang_error('poll_range_error', false); |
|
| 2020 | + } |
|
| 1913 | 2021 | // Don't allow them to select option 2 for hidden results if it's not time limited. |
| 1914 | - elseif (empty($_POST['poll_expire']) && $_POST['poll_hide'] == 2) |
|
| 1915 | - $_POST['poll_hide'] = 1; |
|
| 2022 | + elseif (empty($_POST['poll_expire']) && $_POST['poll_hide'] == 2) { |
|
| 2023 | + $_POST['poll_hide'] = 1; |
|
| 2024 | + } |
|
| 1916 | 2025 | |
| 1917 | 2026 | // Clean up the question and answers. |
| 1918 | 2027 | $_POST['question'] = $smcFunc['htmlspecialchars']($_POST['question']); |
@@ -1926,13 +2035,15 @@ discard block |
||
| 1926 | 2035 | { |
| 1927 | 2036 | $attachIDs = array(); |
| 1928 | 2037 | $attach_errors = array(); |
| 1929 | - if (!empty($context['we_are_history'])) |
|
| 1930 | - $attach_errors[] = '<dd>' . $txt['error_temp_attachments_flushed'] . '<br><br></dd>'; |
|
| 2038 | + if (!empty($context['we_are_history'])) { |
|
| 2039 | + $attach_errors[] = '<dd>' . $txt['error_temp_attachments_flushed'] . '<br><br></dd>'; |
|
| 2040 | + } |
|
| 1931 | 2041 | |
| 1932 | 2042 | foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
| 1933 | 2043 | { |
| 1934 | - if ($attachID != 'initial_error' && strpos($attachID, 'post_tmp_' . $user_info['id']) === false) |
|
| 1935 | - continue; |
|
| 2044 | + if ($attachID != 'initial_error' && strpos($attachID, 'post_tmp_' . $user_info['id']) === false) { |
|
| 2045 | + continue; |
|
| 2046 | + } |
|
| 1936 | 2047 | |
| 1937 | 2048 | // If there was an initial error just show that message. |
| 1938 | 2049 | if ($attachID == 'initial_error') |
@@ -1961,12 +2072,13 @@ discard block |
||
| 1961 | 2072 | if (createAttachment($attachmentOptions)) |
| 1962 | 2073 | { |
| 1963 | 2074 | $attachIDs[] = $attachmentOptions['id']; |
| 1964 | - if (!empty($attachmentOptions['thumb'])) |
|
| 1965 | - $attachIDs[] = $attachmentOptions['thumb']; |
|
| 2075 | + if (!empty($attachmentOptions['thumb'])) { |
|
| 2076 | + $attachIDs[] = $attachmentOptions['thumb']; |
|
| 2077 | + } |
|
| 1966 | 2078 | } |
| 2079 | + } else { |
|
| 2080 | + $attach_errors[] = '<dt> </dt>'; |
|
| 1967 | 2081 | } |
| 1968 | - else |
|
| 1969 | - $attach_errors[] = '<dt> </dt>'; |
|
| 1970 | 2082 | |
| 1971 | 2083 | if (!empty($attachmentOptions['errors'])) |
| 1972 | 2084 | { |
@@ -1978,14 +2090,16 @@ discard block |
||
| 1978 | 2090 | if (!is_array($error)) |
| 1979 | 2091 | { |
| 1980 | 2092 | $attach_errors[] = '<dd>' . $txt[$error] . '</dd>'; |
| 1981 | - if (in_array($error, $log_these)) |
|
| 1982 | - log_error($attachment['name'] . ': ' . $txt[$error], 'critical'); |
|
| 2093 | + if (in_array($error, $log_these)) { |
|
| 2094 | + log_error($attachment['name'] . ': ' . $txt[$error], 'critical'); |
|
| 2095 | + } |
|
| 2096 | + } else { |
|
| 2097 | + $attach_errors[] = '<dd>' . vsprintf($txt[$error[0]], $error[1]) . '</dd>'; |
|
| 1983 | 2098 | } |
| 1984 | - else |
|
| 1985 | - $attach_errors[] = '<dd>' . vsprintf($txt[$error[0]], $error[1]) . '</dd>'; |
|
| 1986 | 2099 | } |
| 1987 | - if (file_exists($attachment['tmp_name'])) |
|
| 1988 | - unlink($attachment['tmp_name']); |
|
| 2100 | + if (file_exists($attachment['tmp_name'])) { |
|
| 2101 | + unlink($attachment['tmp_name']); |
|
| 2102 | + } |
|
| 1989 | 2103 | } |
| 1990 | 2104 | } |
| 1991 | 2105 | unset($_SESSION['temp_attachments']); |
@@ -2026,24 +2140,24 @@ discard block |
||
| 2026 | 2140 | ); |
| 2027 | 2141 | |
| 2028 | 2142 | call_integration_hook('integrate_poll_add_edit', array($id_poll, false)); |
| 2143 | + } else { |
|
| 2144 | + $id_poll = 0; |
|
| 2029 | 2145 | } |
| 2030 | - else |
|
| 2031 | - $id_poll = 0; |
|
| 2032 | 2146 | |
| 2033 | 2147 | // Creating a new topic? |
| 2034 | 2148 | $newTopic = empty($_REQUEST['msg']) && empty($topic); |
| 2035 | 2149 | |
| 2036 | 2150 | // Check the icon. |
| 2037 | - if (!isset($_POST['icon'])) |
|
| 2038 | - $_POST['icon'] = 'xx'; |
|
| 2039 | - |
|
| 2040 | - else |
|
| 2151 | + if (!isset($_POST['icon'])) { |
|
| 2152 | + $_POST['icon'] = 'xx'; |
|
| 2153 | + } else |
|
| 2041 | 2154 | { |
| 2042 | 2155 | $_POST['icon'] = $smcFunc['htmlspecialchars']($_POST['icon']); |
| 2043 | 2156 | |
| 2044 | 2157 | // Need to figure it out if this is a valid icon name. |
| 2045 | - if ((!file_exists($settings['theme_dir'] . '/images/post/' . $_POST['icon'] . '.png')) && (!file_exists($settings['default_theme_dir'] . '/images/post/' . $_POST['icon'] . '.png'))) |
|
| 2046 | - $_POST['icon'] = 'xx'; |
|
| 2158 | + if ((!file_exists($settings['theme_dir'] . '/images/post/' . $_POST['icon'] . '.png')) && (!file_exists($settings['default_theme_dir'] . '/images/post/' . $_POST['icon'] . '.png'))) { |
|
| 2159 | + $_POST['icon'] = 'xx'; |
|
| 2160 | + } |
|
| 2047 | 2161 | } |
| 2048 | 2162 | |
| 2049 | 2163 | // Collect all parameters for the creation or modification of a post. |
@@ -2084,8 +2198,9 @@ discard block |
||
| 2084 | 2198 | } |
| 2085 | 2199 | |
| 2086 | 2200 | // This will save some time... |
| 2087 | - if (empty($approve_has_changed)) |
|
| 2088 | - unset($msgOptions['approved']); |
|
| 2201 | + if (empty($approve_has_changed)) { |
|
| 2202 | + unset($msgOptions['approved']); |
|
| 2203 | + } |
|
| 2089 | 2204 | |
| 2090 | 2205 | modifyPost($msgOptions, $topicOptions, $posterOptions); |
| 2091 | 2206 | } |
@@ -2094,8 +2209,9 @@ discard block |
||
| 2094 | 2209 | { |
| 2095 | 2210 | createPost($msgOptions, $topicOptions, $posterOptions); |
| 2096 | 2211 | |
| 2097 | - if (isset($topicOptions['id'])) |
|
| 2098 | - $topic = $topicOptions['id']; |
|
| 2212 | + if (isset($topicOptions['id'])) { |
|
| 2213 | + $topic = $topicOptions['id']; |
|
| 2214 | + } |
|
| 2099 | 2215 | } |
| 2100 | 2216 | |
| 2101 | 2217 | // Assign the previously uploaded attachments to the brand new message. |
@@ -2107,8 +2223,9 @@ discard block |
||
| 2107 | 2223 | } |
| 2108 | 2224 | |
| 2109 | 2225 | // If we had a draft for this, its time to remove it since it was just posted |
| 2110 | - if (!empty($modSettings['drafts_post_enabled']) && !empty($_POST['id_draft'])) |
|
| 2111 | - DeleteDraft($_POST['id_draft']); |
|
| 2226 | + if (!empty($modSettings['drafts_post_enabled']) && !empty($_POST['id_draft'])) { |
|
| 2227 | + DeleteDraft($_POST['id_draft']); |
|
| 2228 | + } |
|
| 2112 | 2229 | |
| 2113 | 2230 | // Editing or posting an event? |
| 2114 | 2231 | if (isset($_POST['calendar']) && (!isset($_REQUEST['eventid']) || $_REQUEST['eventid'] == -1)) |
@@ -2127,8 +2244,7 @@ discard block |
||
| 2127 | 2244 | 'member' => $user_info['id'], |
| 2128 | 2245 | ); |
| 2129 | 2246 | insertEvent($eventOptions); |
| 2130 | - } |
|
| 2131 | - elseif (isset($_POST['calendar'])) |
|
| 2247 | + } elseif (isset($_POST['calendar'])) |
|
| 2132 | 2248 | { |
| 2133 | 2249 | $_REQUEST['eventid'] = (int) $_REQUEST['eventid']; |
| 2134 | 2250 | |
@@ -2156,14 +2272,15 @@ discard block |
||
| 2156 | 2272 | } |
| 2157 | 2273 | |
| 2158 | 2274 | // Delete it? |
| 2159 | - if (isset($_REQUEST['deleteevent'])) |
|
| 2160 | - $smcFunc['db_query']('', ' |
|
| 2275 | + if (isset($_REQUEST['deleteevent'])) { |
|
| 2276 | + $smcFunc['db_query']('', ' |
|
| 2161 | 2277 | DELETE FROM {db_prefix}calendar |
| 2162 | 2278 | WHERE id_event = {int:id_event}', |
| 2163 | 2279 | array( |
| 2164 | 2280 | 'id_event' => $_REQUEST['eventid'], |
| 2165 | 2281 | ) |
| 2166 | 2282 | ); |
| 2283 | + } |
|
| 2167 | 2284 | // ... or just update it? |
| 2168 | 2285 | else |
| 2169 | 2286 | { |
@@ -2205,9 +2322,8 @@ discard block |
||
| 2205 | 2322 | array($user_info['id'], $topic, 0), |
| 2206 | 2323 | array('id_member', 'id_topic', 'id_board') |
| 2207 | 2324 | ); |
| 2208 | - } |
|
| 2209 | - elseif (!$newTopic) |
|
| 2210 | - $smcFunc['db_query']('', ' |
|
| 2325 | + } elseif (!$newTopic) { |
|
| 2326 | + $smcFunc['db_query']('', ' |
|
| 2211 | 2327 | DELETE FROM {db_prefix}log_notify |
| 2212 | 2328 | WHERE id_member = {int:current_member} |
| 2213 | 2329 | AND id_topic = {int:current_topic}', |
@@ -2216,16 +2332,20 @@ discard block |
||
| 2216 | 2332 | 'current_topic' => $topic, |
| 2217 | 2333 | ) |
| 2218 | 2334 | ); |
| 2335 | + } |
|
| 2219 | 2336 | |
| 2220 | 2337 | // Log an act of moderation - modifying. |
| 2221 | - if (!empty($moderationAction)) |
|
| 2222 | - logAction('modify', array('topic' => $topic, 'message' => (int) $_REQUEST['msg'], 'member' => $row['id_member'], 'board' => $board)); |
|
| 2338 | + if (!empty($moderationAction)) { |
|
| 2339 | + logAction('modify', array('topic' => $topic, 'message' => (int) $_REQUEST['msg'], 'member' => $row['id_member'], 'board' => $board)); |
|
| 2340 | + } |
|
| 2223 | 2341 | |
| 2224 | - if (isset($_POST['lock']) && $_POST['lock'] != 2) |
|
| 2225 | - logAction(empty($_POST['lock']) ? 'unlock' : 'lock', array('topic' => $topicOptions['id'], 'board' => $topicOptions['board'])); |
|
| 2342 | + if (isset($_POST['lock']) && $_POST['lock'] != 2) { |
|
| 2343 | + logAction(empty($_POST['lock']) ? 'unlock' : 'lock', array('topic' => $topicOptions['id'], 'board' => $topicOptions['board'])); |
|
| 2344 | + } |
|
| 2226 | 2345 | |
| 2227 | - if (isset($_POST['sticky'])) |
|
| 2228 | - logAction(empty($_POST['sticky']) ? 'unsticky' : 'sticky', array('topic' => $topicOptions['id'], 'board' => $topicOptions['board'])); |
|
| 2346 | + if (isset($_POST['sticky'])) { |
|
| 2347 | + logAction(empty($_POST['sticky']) ? 'unsticky' : 'sticky', array('topic' => $topicOptions['id'], 'board' => $topicOptions['board'])); |
|
| 2348 | + } |
|
| 2229 | 2349 | |
| 2230 | 2350 | // Returning to the topic? |
| 2231 | 2351 | if (!empty($_REQUEST['goback'])) |
@@ -2244,26 +2364,31 @@ discard block |
||
| 2244 | 2364 | ); |
| 2245 | 2365 | } |
| 2246 | 2366 | |
| 2247 | - if ($board_info['num_topics'] == 0) |
|
| 2248 | - cache_put_data('board-' . $board, null, 120); |
|
| 2367 | + if ($board_info['num_topics'] == 0) { |
|
| 2368 | + cache_put_data('board-' . $board, null, 120); |
|
| 2369 | + } |
|
| 2249 | 2370 | |
| 2250 | 2371 | call_integration_hook('integrate_post2_end'); |
| 2251 | 2372 | |
| 2252 | - if (!empty($_POST['announce_topic'])) |
|
| 2253 | - redirectexit('action=announce;sa=selectgroup;topic=' . $topic . (!empty($_POST['move']) && allowedTo('move_any') ? ';move' : '') . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
| 2373 | + if (!empty($_POST['announce_topic'])) { |
|
| 2374 | + redirectexit('action=announce;sa=selectgroup;topic=' . $topic . (!empty($_POST['move']) && allowedTo('move_any') ? ';move' : '') . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
| 2375 | + } |
|
| 2254 | 2376 | |
| 2255 | - if (!empty($_POST['move']) && allowedTo('move_any')) |
|
| 2256 | - redirectexit('action=movetopic;topic=' . $topic . '.0' . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
| 2377 | + if (!empty($_POST['move']) && allowedTo('move_any')) { |
|
| 2378 | + redirectexit('action=movetopic;topic=' . $topic . '.0' . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
| 2379 | + } |
|
| 2257 | 2380 | |
| 2258 | 2381 | // Return to post if the mod is on. |
| 2259 | - if (isset($_REQUEST['msg']) && !empty($_REQUEST['goback'])) |
|
| 2260 | - redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg'], isBrowser('ie')); |
|
| 2261 | - elseif (!empty($_REQUEST['goback'])) |
|
| 2262 | - redirectexit('topic=' . $topic . '.new#new', isBrowser('ie')); |
|
| 2382 | + if (isset($_REQUEST['msg']) && !empty($_REQUEST['goback'])) { |
|
| 2383 | + redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg'], isBrowser('ie')); |
|
| 2384 | + } elseif (!empty($_REQUEST['goback'])) { |
|
| 2385 | + redirectexit('topic=' . $topic . '.new#new', isBrowser('ie')); |
|
| 2386 | + } |
|
| 2263 | 2387 | // Dut-dut-duh-duh-DUH-duh-dut-duh-duh! *dances to the Final Fantasy Fanfare...* |
| 2264 | - else |
|
| 2265 | - redirectexit('board=' . $board . '.0'); |
|
| 2266 | -} |
|
| 2388 | + else { |
|
| 2389 | + redirectexit('board=' . $board . '.0'); |
|
| 2390 | + } |
|
| 2391 | + } |
|
| 2267 | 2392 | |
| 2268 | 2393 | /** |
| 2269 | 2394 | * Handle the announce topic function (action=announce). |
@@ -2281,8 +2406,9 @@ discard block |
||
| 2281 | 2406 | |
| 2282 | 2407 | validateSession(); |
| 2283 | 2408 | |
| 2284 | - if (empty($topic)) |
|
| 2285 | - fatal_lang_error('topic_gone', false); |
|
| 2409 | + if (empty($topic)) { |
|
| 2410 | + fatal_lang_error('topic_gone', false); |
|
| 2411 | + } |
|
| 2286 | 2412 | |
| 2287 | 2413 | loadLanguage('Post'); |
| 2288 | 2414 | loadTemplate('Post'); |
@@ -2309,8 +2435,9 @@ discard block |
||
| 2309 | 2435 | global $txt, $context, $topic, $board_info, $smcFunc; |
| 2310 | 2436 | |
| 2311 | 2437 | $groups = array_merge($board_info['groups'], array(1)); |
| 2312 | - foreach ($groups as $id => $group) |
|
| 2313 | - $groups[$id] = (int) $group; |
|
| 2438 | + foreach ($groups as $id => $group) { |
|
| 2439 | + $groups[$id] = (int) $group; |
|
| 2440 | + } |
|
| 2314 | 2441 | |
| 2315 | 2442 | $context['groups'] = array(); |
| 2316 | 2443 | if (in_array(0, $groups)) |
@@ -2353,8 +2480,9 @@ discard block |
||
| 2353 | 2480 | 'group_list' => $groups, |
| 2354 | 2481 | ) |
| 2355 | 2482 | ); |
| 2356 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2357 | - $context['groups'][$row['id_group']]['name'] = $row['group_name']; |
|
| 2483 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2484 | + $context['groups'][$row['id_group']]['name'] = $row['group_name']; |
|
| 2485 | + } |
|
| 2358 | 2486 | $smcFunc['db_free_result']($request); |
| 2359 | 2487 | |
| 2360 | 2488 | // Get the subject of the topic we're about to announce. |
@@ -2396,16 +2524,19 @@ discard block |
||
| 2396 | 2524 | $context['start'] = empty($_REQUEST['start']) ? 0 : (int) $_REQUEST['start']; |
| 2397 | 2525 | $groups = array_merge($board_info['groups'], array(1)); |
| 2398 | 2526 | |
| 2399 | - if (isset($_POST['membergroups'])) |
|
| 2400 | - $_POST['who'] = explode(',', $_POST['membergroups']); |
|
| 2527 | + if (isset($_POST['membergroups'])) { |
|
| 2528 | + $_POST['who'] = explode(',', $_POST['membergroups']); |
|
| 2529 | + } |
|
| 2401 | 2530 | |
| 2402 | 2531 | // Check whether at least one membergroup was selected. |
| 2403 | - if (empty($_POST['who'])) |
|
| 2404 | - fatal_lang_error('no_membergroup_selected'); |
|
| 2532 | + if (empty($_POST['who'])) { |
|
| 2533 | + fatal_lang_error('no_membergroup_selected'); |
|
| 2534 | + } |
|
| 2405 | 2535 | |
| 2406 | 2536 | // Make sure all membergroups are integers and can access the board of the announcement. |
| 2407 | - foreach ($_POST['who'] as $id => $mg) |
|
| 2408 | - $_POST['who'][$id] = in_array((int) $mg, $groups) ? (int) $mg : 0; |
|
| 2537 | + foreach ($_POST['who'] as $id => $mg) { |
|
| 2538 | + $_POST['who'][$id] = in_array((int) $mg, $groups) ? (int) $mg : 0; |
|
| 2539 | + } |
|
| 2409 | 2540 | |
| 2410 | 2541 | // Get the topic subject and censor it. |
| 2411 | 2542 | $request = $smcFunc['db_query']('', ' |
@@ -2451,12 +2582,13 @@ discard block |
||
| 2451 | 2582 | if ($smcFunc['db_num_rows']($request) == 0) |
| 2452 | 2583 | { |
| 2453 | 2584 | logAction('announce_topic', array('topic' => $topic), 'user'); |
| 2454 | - if (!empty($_REQUEST['move']) && allowedTo('move_any')) |
|
| 2455 | - redirectexit('action=movetopic;topic=' . $topic . '.0' . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
| 2456 | - elseif (!empty($_REQUEST['goback'])) |
|
| 2457 | - redirectexit('topic=' . $topic . '.new;boardseen#new', isBrowser('ie')); |
|
| 2458 | - else |
|
| 2459 | - redirectexit('board=' . $board . '.0'); |
|
| 2585 | + if (!empty($_REQUEST['move']) && allowedTo('move_any')) { |
|
| 2586 | + redirectexit('action=movetopic;topic=' . $topic . '.0' . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
| 2587 | + } elseif (!empty($_REQUEST['goback'])) { |
|
| 2588 | + redirectexit('topic=' . $topic . '.new;boardseen#new', isBrowser('ie')); |
|
| 2589 | + } else { |
|
| 2590 | + redirectexit('board=' . $board . '.0'); |
|
| 2591 | + } |
|
| 2460 | 2592 | } |
| 2461 | 2593 | |
| 2462 | 2594 | $announcements = array(); |
@@ -2475,8 +2607,9 @@ discard block |
||
| 2475 | 2607 | foreach ($rows as $row) |
| 2476 | 2608 | { |
| 2477 | 2609 | // Force them to have it? |
| 2478 | - if (empty($prefs[$row['id_member']]['announcements'])) |
|
| 2479 | - continue; |
|
| 2610 | + if (empty($prefs[$row['id_member']]['announcements'])) { |
|
| 2611 | + continue; |
|
| 2612 | + } |
|
| 2480 | 2613 | |
| 2481 | 2614 | $cur_language = empty($row['lngfile']) || empty($modSettings['userLanguage']) ? $language : $row['lngfile']; |
| 2482 | 2615 | |
@@ -2504,8 +2637,9 @@ discard block |
||
| 2504 | 2637 | } |
| 2505 | 2638 | |
| 2506 | 2639 | // For each language send a different mail - low priority... |
| 2507 | - foreach ($announcements as $lang => $mail) |
|
| 2508 | - sendmail($mail['recipients'], $mail['subject'], $mail['body'], null, 'ann-' . $lang, $mail['is_html'], 5); |
|
| 2640 | + foreach ($announcements as $lang => $mail) { |
|
| 2641 | + sendmail($mail['recipients'], $mail['subject'], $mail['body'], null, 'ann-' . $lang, $mail['is_html'], 5); |
|
| 2642 | + } |
|
| 2509 | 2643 | |
| 2510 | 2644 | $context['percentage_done'] = round(100 * $context['start'] / $modSettings['latestMember'], 1); |
| 2511 | 2645 | |
@@ -2515,9 +2649,10 @@ discard block |
||
| 2515 | 2649 | $context['sub_template'] = 'announcement_send'; |
| 2516 | 2650 | |
| 2517 | 2651 | // Go back to the correct language for the user ;). |
| 2518 | - if (!empty($modSettings['userLanguage'])) |
|
| 2519 | - loadLanguage('Post'); |
|
| 2520 | -} |
|
| 2652 | + if (!empty($modSettings['userLanguage'])) { |
|
| 2653 | + loadLanguage('Post'); |
|
| 2654 | + } |
|
| 2655 | + } |
|
| 2521 | 2656 | |
| 2522 | 2657 | /** |
| 2523 | 2658 | * Get the topic for display purposes. |
@@ -2530,12 +2665,13 @@ discard block |
||
| 2530 | 2665 | { |
| 2531 | 2666 | global $topic, $modSettings, $context, $smcFunc, $counter, $options; |
| 2532 | 2667 | |
| 2533 | - if (isset($_REQUEST['xml'])) |
|
| 2534 | - $limit = ' |
|
| 2668 | + if (isset($_REQUEST['xml'])) { |
|
| 2669 | + $limit = ' |
|
| 2535 | 2670 | LIMIT ' . (empty($context['new_replies']) ? '0' : $context['new_replies']); |
| 2536 | - else |
|
| 2537 | - $limit = empty($modSettings['topicSummaryPosts']) ? '' : ' |
|
| 2671 | + } else { |
|
| 2672 | + $limit = empty($modSettings['topicSummaryPosts']) ? '' : ' |
|
| 2538 | 2673 | LIMIT ' . (int) $modSettings['topicSummaryPosts']; |
| 2674 | + } |
|
| 2539 | 2675 | |
| 2540 | 2676 | // If you're modifying, get only those posts before the current one. (otherwise get all.) |
| 2541 | 2677 | $request = $smcFunc['db_query']('', ' |
@@ -2573,8 +2709,9 @@ discard block |
||
| 2573 | 2709 | 'is_ignored' => !empty($modSettings['enable_buddylist']) && !empty($options['posts_apply_ignore_list']) && in_array($row['id_member'], $context['user']['ignoreusers']), |
| 2574 | 2710 | ); |
| 2575 | 2711 | |
| 2576 | - if (!empty($context['new_replies'])) |
|
| 2577 | - $context['new_replies']--; |
|
| 2712 | + if (!empty($context['new_replies'])) { |
|
| 2713 | + $context['new_replies']--; |
|
| 2714 | + } |
|
| 2578 | 2715 | } |
| 2579 | 2716 | $smcFunc['db_free_result']($request); |
| 2580 | 2717 | } |
@@ -2591,8 +2728,9 @@ discard block |
||
| 2591 | 2728 | global $sourcedir, $smcFunc; |
| 2592 | 2729 | |
| 2593 | 2730 | loadLanguage('Post'); |
| 2594 | - if (!isset($_REQUEST['xml'])) |
|
| 2595 | - loadTemplate('Post'); |
|
| 2731 | + if (!isset($_REQUEST['xml'])) { |
|
| 2732 | + loadTemplate('Post'); |
|
| 2733 | + } |
|
| 2596 | 2734 | |
| 2597 | 2735 | include_once($sourcedir . '/Subs-Post.php'); |
| 2598 | 2736 | |
@@ -2623,8 +2761,9 @@ discard block |
||
| 2623 | 2761 | $smcFunc['db_free_result']($request); |
| 2624 | 2762 | |
| 2625 | 2763 | $context['sub_template'] = 'quotefast'; |
| 2626 | - if (!empty($row)) |
|
| 2627 | - $can_view_post = $row['approved'] || ($row['id_member'] != 0 && $row['id_member'] == $user_info['id']) || allowedTo('approve_posts', $row['id_board']); |
|
| 2764 | + if (!empty($row)) { |
|
| 2765 | + $can_view_post = $row['approved'] || ($row['id_member'] != 0 && $row['id_member'] == $user_info['id']) || allowedTo('approve_posts', $row['id_board']); |
|
| 2766 | + } |
|
| 2628 | 2767 | |
| 2629 | 2768 | if (!empty($can_view_post)) |
| 2630 | 2769 | { |
@@ -2657,8 +2796,9 @@ discard block |
||
| 2657 | 2796 | } |
| 2658 | 2797 | |
| 2659 | 2798 | // Remove any nested quotes. |
| 2660 | - if (!empty($modSettings['removeNestedQuotes'])) |
|
| 2661 | - $row['body'] = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $row['body']); |
|
| 2799 | + if (!empty($modSettings['removeNestedQuotes'])) { |
|
| 2800 | + $row['body'] = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $row['body']); |
|
| 2801 | + } |
|
| 2662 | 2802 | |
| 2663 | 2803 | $lb = "\n"; |
| 2664 | 2804 | |
@@ -2684,14 +2824,14 @@ discard block |
||
| 2684 | 2824 | 'time' => '', |
| 2685 | 2825 | ), |
| 2686 | 2826 | ); |
| 2687 | - } |
|
| 2688 | - else |
|
| 2689 | - $context['quote'] = array( |
|
| 2827 | + } else { |
|
| 2828 | + $context['quote'] = array( |
|
| 2690 | 2829 | 'xml' => '', |
| 2691 | 2830 | 'mozilla' => '', |
| 2692 | 2831 | 'text' => '', |
| 2693 | 2832 | ); |
| 2694 | -} |
|
| 2833 | + } |
|
| 2834 | + } |
|
| 2695 | 2835 | |
| 2696 | 2836 | /** |
| 2697 | 2837 | * Used to edit the body or subject of a message inline |
@@ -2703,8 +2843,9 @@ discard block |
||
| 2703 | 2843 | global $user_info, $context, $smcFunc, $language, $board_info; |
| 2704 | 2844 | |
| 2705 | 2845 | // We have to have a topic! |
| 2706 | - if (empty($topic)) |
|
| 2707 | - obExit(false); |
|
| 2846 | + if (empty($topic)) { |
|
| 2847 | + obExit(false); |
|
| 2848 | + } |
|
| 2708 | 2849 | |
| 2709 | 2850 | checkSession('get'); |
| 2710 | 2851 | require_once($sourcedir . '/Subs-Post.php'); |
@@ -2730,31 +2871,35 @@ discard block |
||
| 2730 | 2871 | 'guest_id' => 0, |
| 2731 | 2872 | ) |
| 2732 | 2873 | ); |
| 2733 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 2734 | - fatal_lang_error('no_board', false); |
|
| 2874 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 2875 | + fatal_lang_error('no_board', false); |
|
| 2876 | + } |
|
| 2735 | 2877 | $row = $smcFunc['db_fetch_assoc']($request); |
| 2736 | 2878 | $smcFunc['db_free_result']($request); |
| 2737 | 2879 | |
| 2738 | 2880 | // Change either body or subject requires permissions to modify messages. |
| 2739 | 2881 | if (isset($_POST['message']) || isset($_POST['subject']) || isset($_REQUEST['icon'])) |
| 2740 | 2882 | { |
| 2741 | - if (!empty($row['locked'])) |
|
| 2742 | - isAllowedTo('moderate_board'); |
|
| 2883 | + if (!empty($row['locked'])) { |
|
| 2884 | + isAllowedTo('moderate_board'); |
|
| 2885 | + } |
|
| 2743 | 2886 | |
| 2744 | 2887 | if ($row['id_member'] == $user_info['id'] && !allowedTo('modify_any')) |
| 2745 | 2888 | { |
| 2746 | - if ((!$modSettings['postmod_active'] || $row['approved']) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) |
|
| 2747 | - fatal_lang_error('modify_post_time_passed', false); |
|
| 2748 | - elseif ($row['id_member_started'] == $user_info['id'] && !allowedTo('modify_own')) |
|
| 2749 | - isAllowedTo('modify_replies'); |
|
| 2750 | - else |
|
| 2751 | - isAllowedTo('modify_own'); |
|
| 2889 | + if ((!$modSettings['postmod_active'] || $row['approved']) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) { |
|
| 2890 | + fatal_lang_error('modify_post_time_passed', false); |
|
| 2891 | + } elseif ($row['id_member_started'] == $user_info['id'] && !allowedTo('modify_own')) { |
|
| 2892 | + isAllowedTo('modify_replies'); |
|
| 2893 | + } else { |
|
| 2894 | + isAllowedTo('modify_own'); |
|
| 2895 | + } |
|
| 2752 | 2896 | } |
| 2753 | 2897 | // Otherwise, they're locked out; someone who can modify the replies is needed. |
| 2754 | - elseif ($row['id_member_started'] == $user_info['id'] && !allowedTo('modify_any')) |
|
| 2755 | - isAllowedTo('modify_replies'); |
|
| 2756 | - else |
|
| 2757 | - isAllowedTo('modify_any'); |
|
| 2898 | + elseif ($row['id_member_started'] == $user_info['id'] && !allowedTo('modify_any')) { |
|
| 2899 | + isAllowedTo('modify_replies'); |
|
| 2900 | + } else { |
|
| 2901 | + isAllowedTo('modify_any'); |
|
| 2902 | + } |
|
| 2758 | 2903 | |
| 2759 | 2904 | // Only log this action if it wasn't your message. |
| 2760 | 2905 | $moderationAction = $row['id_member'] != $user_info['id']; |
@@ -2766,10 +2911,10 @@ discard block |
||
| 2766 | 2911 | $_POST['subject'] = strtr($smcFunc['htmlspecialchars']($_POST['subject']), array("\r" => '', "\n" => '', "\t" => '')); |
| 2767 | 2912 | |
| 2768 | 2913 | // Maximum number of characters. |
| 2769 | - if ($smcFunc['strlen']($_POST['subject']) > 100) |
|
| 2770 | - $_POST['subject'] = $smcFunc['substr']($_POST['subject'], 0, 100); |
|
| 2771 | - } |
|
| 2772 | - elseif (isset($_POST['subject'])) |
|
| 2914 | + if ($smcFunc['strlen']($_POST['subject']) > 100) { |
|
| 2915 | + $_POST['subject'] = $smcFunc['substr']($_POST['subject'], 0, 100); |
|
| 2916 | + } |
|
| 2917 | + } elseif (isset($_POST['subject'])) |
|
| 2773 | 2918 | { |
| 2774 | 2919 | $post_errors[] = 'no_subject'; |
| 2775 | 2920 | unset($_POST['subject']); |
@@ -2781,13 +2926,11 @@ discard block |
||
| 2781 | 2926 | { |
| 2782 | 2927 | $post_errors[] = 'no_message'; |
| 2783 | 2928 | unset($_POST['message']); |
| 2784 | - } |
|
| 2785 | - elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_POST['message']) > $modSettings['max_messageLength']) |
|
| 2929 | + } elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_POST['message']) > $modSettings['max_messageLength']) |
|
| 2786 | 2930 | { |
| 2787 | 2931 | $post_errors[] = 'long_message'; |
| 2788 | 2932 | unset($_POST['message']); |
| 2789 | - } |
|
| 2790 | - else |
|
| 2933 | + } else |
|
| 2791 | 2934 | { |
| 2792 | 2935 | $_POST['message'] = $smcFunc['htmlspecialchars']($_POST['message'], ENT_QUOTES); |
| 2793 | 2936 | |
@@ -2803,31 +2946,34 @@ discard block |
||
| 2803 | 2946 | |
| 2804 | 2947 | if (isset($_POST['lock'])) |
| 2805 | 2948 | { |
| 2806 | - if (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $row['id_member'])) |
|
| 2807 | - unset($_POST['lock']); |
|
| 2808 | - elseif (!allowedTo('lock_any')) |
|
| 2949 | + if (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $row['id_member'])) { |
|
| 2950 | + unset($_POST['lock']); |
|
| 2951 | + } elseif (!allowedTo('lock_any')) |
|
| 2809 | 2952 | { |
| 2810 | - if ($row['locked'] == 1) |
|
| 2811 | - unset($_POST['lock']); |
|
| 2812 | - else |
|
| 2813 | - $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
| 2953 | + if ($row['locked'] == 1) { |
|
| 2954 | + unset($_POST['lock']); |
|
| 2955 | + } else { |
|
| 2956 | + $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
| 2957 | + } |
|
| 2958 | + } elseif (!empty($row['locked']) && !empty($_POST['lock']) || $_POST['lock'] == $row['locked']) { |
|
| 2959 | + unset($_POST['lock']); |
|
| 2960 | + } else { |
|
| 2961 | + $_POST['lock'] = empty($_POST['lock']) ? 0 : 1; |
|
| 2814 | 2962 | } |
| 2815 | - elseif (!empty($row['locked']) && !empty($_POST['lock']) || $_POST['lock'] == $row['locked']) |
|
| 2816 | - unset($_POST['lock']); |
|
| 2817 | - else |
|
| 2818 | - $_POST['lock'] = empty($_POST['lock']) ? 0 : 1; |
|
| 2819 | 2963 | } |
| 2820 | 2964 | |
| 2821 | - if (isset($_POST['sticky']) && !allowedTo('make_sticky')) |
|
| 2822 | - unset($_POST['sticky']); |
|
| 2965 | + if (isset($_POST['sticky']) && !allowedTo('make_sticky')) { |
|
| 2966 | + unset($_POST['sticky']); |
|
| 2967 | + } |
|
| 2823 | 2968 | |
| 2824 | 2969 | if (isset($_POST['modify_reason'])) |
| 2825 | 2970 | { |
| 2826 | 2971 | $_POST['modify_reason'] = strtr($smcFunc['htmlspecialchars']($_POST['modify_reason']), array("\r" => '', "\n" => '', "\t" => '')); |
| 2827 | 2972 | |
| 2828 | 2973 | // Maximum number of characters. |
| 2829 | - if ($smcFunc['strlen']($_POST['modify_reason']) > 100) |
|
| 2830 | - $_POST['modify_reason'] = $smcFunc['substr']($_POST['modify_reason'], 0, 100); |
|
| 2974 | + if ($smcFunc['strlen']($_POST['modify_reason']) > 100) { |
|
| 2975 | + $_POST['modify_reason'] = $smcFunc['substr']($_POST['modify_reason'], 0, 100); |
|
| 2976 | + } |
|
| 2831 | 2977 | } |
| 2832 | 2978 | |
| 2833 | 2979 | if (empty($post_errors)) |
@@ -2864,8 +3010,9 @@ discard block |
||
| 2864 | 3010 | } |
| 2865 | 3011 | } |
| 2866 | 3012 | // If nothing was changed there's no need to add an entry to the moderation log. |
| 2867 | - else |
|
| 2868 | - $moderationAction = false; |
|
| 3013 | + else { |
|
| 3014 | + $moderationAction = false; |
|
| 3015 | + } |
|
| 2869 | 3016 | |
| 2870 | 3017 | modifyPost($msgOptions, $topicOptions, $posterOptions); |
| 2871 | 3018 | |
@@ -2883,9 +3030,9 @@ discard block |
||
| 2883 | 3030 | // Get the proper (default language) response prefix first. |
| 2884 | 3031 | if (!isset($context['response_prefix']) && !($context['response_prefix'] = cache_get_data('response_prefix'))) |
| 2885 | 3032 | { |
| 2886 | - if ($language === $user_info['language']) |
|
| 2887 | - $context['response_prefix'] = $txt['response_prefix']; |
|
| 2888 | - else |
|
| 3033 | + if ($language === $user_info['language']) { |
|
| 3034 | + $context['response_prefix'] = $txt['response_prefix']; |
|
| 3035 | + } else |
|
| 2889 | 3036 | { |
| 2890 | 3037 | loadLanguage('index', $language, false); |
| 2891 | 3038 | $context['response_prefix'] = $txt['response_prefix']; |
@@ -2907,8 +3054,9 @@ discard block |
||
| 2907 | 3054 | ); |
| 2908 | 3055 | } |
| 2909 | 3056 | |
| 2910 | - if (!empty($moderationAction)) |
|
| 2911 | - logAction('modify', array('topic' => $topic, 'message' => $row['id_msg'], 'member' => $row['id_member'], 'board' => $board)); |
|
| 3057 | + if (!empty($moderationAction)) { |
|
| 3058 | + logAction('modify', array('topic' => $topic, 'message' => $row['id_msg'], 'member' => $row['id_member'], 'board' => $board)); |
|
| 3059 | + } |
|
| 2912 | 3060 | } |
| 2913 | 3061 | |
| 2914 | 3062 | if (isset($_REQUEST['xml'])) |
@@ -2949,8 +3097,7 @@ discard block |
||
| 2949 | 3097 | ); |
| 2950 | 3098 | |
| 2951 | 3099 | censorText($context['message']['subject']); |
| 2952 | - } |
|
| 2953 | - else |
|
| 3100 | + } else |
|
| 2954 | 3101 | { |
| 2955 | 3102 | $context['message'] = array( |
| 2956 | 3103 | 'id' => $row['id_msg'], |
@@ -2962,15 +3109,16 @@ discard block |
||
| 2962 | 3109 | loadLanguage('Errors'); |
| 2963 | 3110 | foreach ($post_errors as $post_error) |
| 2964 | 3111 | { |
| 2965 | - if ($post_error == 'long_message') |
|
| 2966 | - $context['message']['errors'][] = sprintf($txt['error_' . $post_error], $modSettings['max_messageLength']); |
|
| 2967 | - else |
|
| 2968 | - $context['message']['errors'][] = $txt['error_' . $post_error]; |
|
| 3112 | + if ($post_error == 'long_message') { |
|
| 3113 | + $context['message']['errors'][] = sprintf($txt['error_' . $post_error], $modSettings['max_messageLength']); |
|
| 3114 | + } else { |
|
| 3115 | + $context['message']['errors'][] = $txt['error_' . $post_error]; |
|
| 3116 | + } |
|
| 2969 | 3117 | } |
| 2970 | 3118 | } |
| 3119 | + } else { |
|
| 3120 | + obExit(false); |
|
| 3121 | + } |
|
| 2971 | 3122 | } |
| 2972 | - else |
|
| 2973 | - obExit(false); |
|
| 2974 | -} |
|
| 2975 | 3123 | |
| 2976 | 3124 | ?> |
| 2977 | 3125 | \ No newline at end of file |
@@ -41,37 +41,43 @@ discard block |
||
| 41 | 41 | define('TIME_START', microtime(true)); |
| 42 | 42 | |
| 43 | 43 | // Just being safe... |
| 44 | -foreach (array('db_character_set', 'cachedir') as $variable) |
|
| 44 | +foreach (array('db_character_set', 'cachedir') as $variable) { |
|
| 45 | 45 | if (isset($GLOBALS[$variable])) |
| 46 | 46 | unset($GLOBALS[$variable]); |
| 47 | +} |
|
| 47 | 48 | |
| 48 | 49 | // Get the forum's settings for database and file paths. |
| 49 | 50 | require_once(dirname(__FILE__) . '/Settings.php'); |
| 50 | 51 | |
| 51 | 52 | // Make absolutely sure the cache directory is defined. |
| 52 | -if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache')) |
|
| 53 | +if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache')) { |
|
| 53 | 54 | $cachedir = $boarddir . '/cache'; |
| 55 | +} |
|
| 54 | 56 | |
| 55 | 57 | // Don't do john didley if the forum's been shut down competely. |
| 56 | -if ($maintenance == 2) |
|
| 58 | +if ($maintenance == 2) { |
|
| 57 | 59 | die($mmessage); |
| 60 | +} |
|
| 58 | 61 | |
| 59 | 62 | // Fix for using the current directory as a path. |
| 60 | -if (substr($sourcedir, 0, 1) == '.' && substr($sourcedir, 1, 1) != '.') |
|
| 63 | +if (substr($sourcedir, 0, 1) == '.' && substr($sourcedir, 1, 1) != '.') { |
|
| 61 | 64 | $sourcedir = dirname(__FILE__) . substr($sourcedir, 1); |
| 65 | +} |
|
| 62 | 66 | |
| 63 | 67 | // Have we already turned this off? If so, exist gracefully. |
| 64 | -if (file_exists($cachedir . '/cron.lock')) |
|
| 68 | +if (file_exists($cachedir . '/cron.lock')) { |
|
| 65 | 69 | obExit_cron(); |
| 70 | +} |
|
| 66 | 71 | |
| 67 | 72 | // Before we go any further, if this is not a CLI request, we need to do some checking. |
| 68 | 73 | if (!FROM_CLI) |
| 69 | 74 | { |
| 70 | 75 | // We will clean up $_GET shortly. But we want to this ASAP. |
| 71 | 76 | $ts = isset($_GET['ts']) ? (int) $_GET['ts'] : 0; |
| 72 | - if ($ts <= 0 || $ts % 15 != 0 || time() - $ts < 0 || time() - $ts > 20) |
|
| 73 | - obExit_cron(); |
|
| 74 | -} |
|
| 77 | + if ($ts <= 0 || $ts % 15 != 0 || time() - $ts < 0 || time() - $ts > 20) { |
|
| 78 | + obExit_cron(); |
|
| 79 | + } |
|
| 80 | + } |
|
| 75 | 81 | |
| 76 | 82 | // Load the most important includes. In general, a background should be loading its own dependencies. |
| 77 | 83 | require_once($sourcedir . '/Errors.php'); |
@@ -123,8 +129,9 @@ discard block |
||
| 123 | 129 | global $smcFunc; |
| 124 | 130 | |
| 125 | 131 | // Check we haven't run over our time limit. |
| 126 | - if (microtime(true) - TIME_START > MAX_CRON_TIME) |
|
| 127 | - return false; |
|
| 132 | + if (microtime(true) - TIME_START > MAX_CRON_TIME) { |
|
| 133 | + return false; |
|
| 134 | + } |
|
| 128 | 135 | |
| 129 | 136 | // Try to find a task. Specifically, try to find one that hasn't been claimed previously, or failing that, |
| 130 | 137 | // a task that was claimed but failed for whatever reason and failed long enough ago. We should not care |
@@ -159,14 +166,12 @@ discard block |
||
| 159 | 166 | // Update the time and go back. |
| 160 | 167 | $row['claimed_time'] = time(); |
| 161 | 168 | return $row; |
| 162 | - } |
|
| 163 | - else |
|
| 169 | + } else |
|
| 164 | 170 | { |
| 165 | 171 | // Uh oh, we just missed it. Try to claim another one, and let it fall through if there aren't any. |
| 166 | 172 | return fetch_task(); |
| 167 | 173 | } |
| 168 | - } |
|
| 169 | - else |
|
| 174 | + } else |
|
| 170 | 175 | { |
| 171 | 176 | // No dice. Clean up and go home. |
| 172 | 177 | $smcFunc['db_free_result']($request); |
@@ -187,8 +192,9 @@ discard block |
||
| 187 | 192 | if (!empty($task_details['task_file'])) |
| 188 | 193 | { |
| 189 | 194 | $include = strtr(trim($task_details['task_file']), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir)); |
| 190 | - if (file_exists($include)) |
|
| 191 | - require_once($include); |
|
| 195 | + if (file_exists($include)) { |
|
| 196 | + require_once($include); |
|
| 197 | + } |
|
| 192 | 198 | } |
| 193 | 199 | |
| 194 | 200 | if (empty($task_details['task_class'])) |
@@ -204,8 +210,7 @@ discard block |
||
| 204 | 210 | $details = empty($task_details['task_data']) ? array() : $smcFunc['json_decode']($task_details['task_data'], true); |
| 205 | 211 | $bgtask = new $task_details['task_class']($details); |
| 206 | 212 | return $bgtask->execute(); |
| 207 | - } |
|
| 208 | - else |
|
| 213 | + } else |
|
| 209 | 214 | { |
| 210 | 215 | log_error('Invalid background task specified: (class: ' . $task_details['task_class'] . ', ' . (empty($task_details['task_file']) ? ' no file' : ' to load ' . $task_details['task_file']) . ')'); |
| 211 | 216 | return true; // So we clear it from the queue. |
@@ -224,8 +229,9 @@ discard block |
||
| 224 | 229 | $scripturl = $boardurl . '/index.php'; |
| 225 | 230 | |
| 226 | 231 | // These keys shouldn't be set...ever. |
| 227 | - if (isset($_REQUEST['GLOBALS']) || isset($_COOKIE['GLOBALS'])) |
|
| 228 | - die('Invalid request variable.'); |
|
| 232 | + if (isset($_REQUEST['GLOBALS']) || isset($_COOKIE['GLOBALS'])) { |
|
| 233 | + die('Invalid request variable.'); |
|
| 234 | + } |
|
| 229 | 235 | |
| 230 | 236 | // Save some memory.. (since we don't use these anyway.) |
| 231 | 237 | unset($GLOBALS['HTTP_POST_VARS'], $GLOBALS['HTTP_POST_VARS']); |
@@ -246,26 +252,28 @@ discard block |
||
| 246 | 252 | global $modSettings; |
| 247 | 253 | |
| 248 | 254 | // Ignore errors if we're ignoring them or they are strict notices from PHP 5 |
| 249 | - if (error_reporting() == 0) |
|
| 250 | - return; |
|
| 255 | + if (error_reporting() == 0) { |
|
| 256 | + return; |
|
| 257 | + } |
|
| 251 | 258 | |
| 252 | 259 | $error_type = 'cron'; |
| 253 | 260 | |
| 254 | 261 | log_error($error_level . ': ' . $error_string, $error_type, $file, $line); |
| 255 | 262 | |
| 256 | 263 | // If this is an E_ERROR or E_USER_ERROR.... die. Violently so. |
| 257 | - if ($error_level % 255 == E_ERROR) |
|
| 258 | - die('No direct access...'); |
|
| 259 | -} |
|
| 264 | + if ($error_level % 255 == E_ERROR) { |
|
| 265 | + die('No direct access...'); |
|
| 266 | + } |
|
| 267 | + } |
|
| 260 | 268 | |
| 261 | 269 | /** |
| 262 | 270 | * The exit function |
| 263 | 271 | */ |
| 264 | 272 | function obExit_cron() |
| 265 | 273 | { |
| 266 | - if (FROM_CLI) |
|
| 267 | - die(0); |
|
| 268 | - else |
|
| 274 | + if (FROM_CLI) { |
|
| 275 | + die(0); |
|
| 276 | + } else |
|
| 269 | 277 | { |
| 270 | 278 | header('Content-Type: image/gif'); |
| 271 | 279 | die("\x47\x49\x46\x38\x39\x61\x01\x00\x01\x00\x80\x00\x00\x00\x00\x00\x00\x00\x00\x21\xF9\x04\x01\x00\x00\x00\x00\x2C\x00\x00\x00\x00\x01\x00\x01\x00\x00\x02\x02\x44\x01\x00\x3B"); |
@@ -12,8 +12,9 @@ discard block |
||
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | 14 | // Don't do anything if SMF is already loaded. |
| 15 | -if (defined('SMF')) |
|
| 15 | +if (defined('SMF')) { |
|
| 16 | 16 | return true; |
| 17 | +} |
|
| 17 | 18 | |
| 18 | 19 | define('SMF', 'SSI'); |
| 19 | 20 | |
@@ -28,16 +29,18 @@ discard block |
||
| 28 | 29 | $time_start = microtime(true); |
| 29 | 30 | |
| 30 | 31 | // Just being safe... |
| 31 | -foreach (array('db_character_set', 'cachedir') as $variable) |
|
| 32 | +foreach (array('db_character_set', 'cachedir') as $variable) { |
|
| 32 | 33 | if (isset($GLOBALS[$variable])) |
| 33 | 34 | unset($GLOBALS[$variable]); |
| 35 | +} |
|
| 34 | 36 | |
| 35 | 37 | // Get the forum's settings for database and file paths. |
| 36 | 38 | require_once(dirname(__FILE__) . '/Settings.php'); |
| 37 | 39 | |
| 38 | 40 | // Make absolutely sure the cache directory is defined. |
| 39 | -if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache')) |
|
| 41 | +if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache')) { |
|
| 40 | 42 | $cachedir = $boarddir . '/cache'; |
| 43 | +} |
|
| 41 | 44 | |
| 42 | 45 | $ssi_error_reporting = error_reporting(E_ALL); |
| 43 | 46 | /* Set this to one of three values depending on what you want to happen in the case of a fatal error. |
@@ -48,12 +51,14 @@ discard block |
||
| 48 | 51 | $ssi_on_error_method = false; |
| 49 | 52 | |
| 50 | 53 | // Don't do john didley if the forum's been shut down completely. |
| 51 | -if ($maintenance == 2 && (!isset($ssi_maintenance_off) || $ssi_maintenance_off !== true)) |
|
| 54 | +if ($maintenance == 2 && (!isset($ssi_maintenance_off) || $ssi_maintenance_off !== true)) { |
|
| 52 | 55 | die($mmessage); |
| 56 | +} |
|
| 53 | 57 | |
| 54 | 58 | // Fix for using the current directory as a path. |
| 55 | -if (substr($sourcedir, 0, 1) == '.' && substr($sourcedir, 1, 1) != '.') |
|
| 59 | +if (substr($sourcedir, 0, 1) == '.' && substr($sourcedir, 1, 1) != '.') { |
|
| 56 | 60 | $sourcedir = dirname(__FILE__) . substr($sourcedir, 1); |
| 61 | +} |
|
| 57 | 62 | |
| 58 | 63 | // Load the important includes. |
| 59 | 64 | require_once($sourcedir . '/QueryString.php'); |
@@ -78,34 +83,38 @@ discard block |
||
| 78 | 83 | cleanRequest(); |
| 79 | 84 | |
| 80 | 85 | // Seed the random generator? |
| 81 | -if (empty($modSettings['rand_seed']) || mt_rand(1, 250) == 69) |
|
| 86 | +if (empty($modSettings['rand_seed']) || mt_rand(1, 250) == 69) { |
|
| 82 | 87 | smf_seed_generator(); |
| 88 | +} |
|
| 83 | 89 | |
| 84 | 90 | // Check on any hacking attempts. |
| 85 | -if (isset($_REQUEST['GLOBALS']) || isset($_COOKIE['GLOBALS'])) |
|
| 91 | +if (isset($_REQUEST['GLOBALS']) || isset($_COOKIE['GLOBALS'])) { |
|
| 86 | 92 | die('No direct access...'); |
| 87 | -elseif (isset($_REQUEST['ssi_theme']) && (int) $_REQUEST['ssi_theme'] == (int) $ssi_theme) |
|
| 93 | +} elseif (isset($_REQUEST['ssi_theme']) && (int) $_REQUEST['ssi_theme'] == (int) $ssi_theme) { |
|
| 88 | 94 | die('No direct access...'); |
| 89 | -elseif (isset($_COOKIE['ssi_theme']) && (int) $_COOKIE['ssi_theme'] == (int) $ssi_theme) |
|
| 95 | +} elseif (isset($_COOKIE['ssi_theme']) && (int) $_COOKIE['ssi_theme'] == (int) $ssi_theme) { |
|
| 90 | 96 | die('No direct access...'); |
| 91 | -elseif (isset($_REQUEST['ssi_layers'], $ssi_layers) && (@get_magic_quotes_gpc() ? stripslashes($_REQUEST['ssi_layers']) : $_REQUEST['ssi_layers']) == $ssi_layers) |
|
| 97 | +} elseif (isset($_REQUEST['ssi_layers'], $ssi_layers) && (@get_magic_quotes_gpc() ? stripslashes($_REQUEST['ssi_layers']) : $_REQUEST['ssi_layers']) == $ssi_layers) { |
|
| 92 | 98 | die('No direct access...'); |
| 93 | -if (isset($_REQUEST['context'])) |
|
| 99 | +} |
|
| 100 | +if (isset($_REQUEST['context'])) { |
|
| 94 | 101 | die('No direct access...'); |
| 102 | +} |
|
| 95 | 103 | |
| 96 | 104 | // Gzip output? (because it must be boolean and true, this can't be hacked.) |
| 97 | -if (isset($ssi_gzip) && $ssi_gzip === true && ini_get('zlib.output_compression') != '1' && ini_get('output_handler') != 'ob_gzhandler' && version_compare(PHP_VERSION, '4.2.0', '>=')) |
|
| 105 | +if (isset($ssi_gzip) && $ssi_gzip === true && ini_get('zlib.output_compression') != '1' && ini_get('output_handler') != 'ob_gzhandler' && version_compare(PHP_VERSION, '4.2.0', '>=')) { |
|
| 98 | 106 | ob_start('ob_gzhandler'); |
| 99 | -else |
|
| 107 | +} else { |
|
| 100 | 108 | $modSettings['enableCompressedOutput'] = '0'; |
| 109 | +} |
|
| 101 | 110 | |
| 102 | 111 | // Primarily, this is to fix the URLs... |
| 103 | 112 | ob_start('ob_sessrewrite'); |
| 104 | 113 | |
| 105 | 114 | // Start the session... known to scramble SSI includes in cases... |
| 106 | -if (!headers_sent()) |
|
| 115 | +if (!headers_sent()) { |
|
| 107 | 116 | loadSession(); |
| 108 | -else |
|
| 117 | +} else |
|
| 109 | 118 | { |
| 110 | 119 | if (isset($_COOKIE[session_name()]) || isset($_REQUEST[session_name()])) |
| 111 | 120 | { |
@@ -139,12 +148,14 @@ discard block |
||
| 139 | 148 | loadTheme(isset($ssi_theme) ? (int) $ssi_theme : 0); |
| 140 | 149 | |
| 141 | 150 | // @todo: probably not the best place, but somewhere it should be set... |
| 142 | -if (!headers_sent()) |
|
| 151 | +if (!headers_sent()) { |
|
| 143 | 152 | header('Content-Type: text/html; charset=' . (empty($modSettings['global_character_set']) ? (empty($txt['lang_character_set']) ? 'ISO-8859-1' : $txt['lang_character_set']) : $modSettings['global_character_set'])); |
| 153 | +} |
|
| 144 | 154 | |
| 145 | 155 | // Take care of any banning that needs to be done. |
| 146 | -if (isset($_REQUEST['ssi_ban']) || (isset($ssi_ban) && $ssi_ban === true)) |
|
| 156 | +if (isset($_REQUEST['ssi_ban']) || (isset($ssi_ban) && $ssi_ban === true)) { |
|
| 147 | 157 | is_not_banned(); |
| 158 | +} |
|
| 148 | 159 | |
| 149 | 160 | // Do we allow guests in here? |
| 150 | 161 | if (empty($ssi_guest_access) && empty($modSettings['allow_guestAccess']) && $user_info['is_guest'] && basename($_SERVER['PHP_SELF']) != 'SSI.php') |
@@ -159,17 +170,19 @@ discard block |
||
| 159 | 170 | { |
| 160 | 171 | $context['template_layers'] = $ssi_layers; |
| 161 | 172 | template_header(); |
| 162 | -} |
|
| 163 | -else |
|
| 173 | +} else { |
|
| 164 | 174 | setupThemeContext(); |
| 175 | +} |
|
| 165 | 176 | |
| 166 | 177 | // Make sure they didn't muss around with the settings... but only if it's not cli. |
| 167 | -if (isset($_SERVER['REMOTE_ADDR']) && !isset($_SERVER['is_cli']) && session_id() == '') |
|
| 178 | +if (isset($_SERVER['REMOTE_ADDR']) && !isset($_SERVER['is_cli']) && session_id() == '') { |
|
| 168 | 179 | trigger_error($txt['ssi_session_broken'], E_USER_NOTICE); |
| 180 | +} |
|
| 169 | 181 | |
| 170 | 182 | // Without visiting the forum this session variable might not be set on submit. |
| 171 | -if (!isset($_SESSION['USER_AGENT']) && (!isset($_GET['ssi_function']) || $_GET['ssi_function'] !== 'pollVote')) |
|
| 183 | +if (!isset($_SESSION['USER_AGENT']) && (!isset($_GET['ssi_function']) || $_GET['ssi_function'] !== 'pollVote')) { |
|
| 172 | 184 | $_SESSION['USER_AGENT'] = $_SERVER['HTTP_USER_AGENT']; |
| 185 | +} |
|
| 173 | 186 | |
| 174 | 187 | // Have the ability to easily add functions to SSI. |
| 175 | 188 | call_integration_hook('integrate_SSI'); |
@@ -178,11 +191,13 @@ discard block |
||
| 178 | 191 | if (basename($_SERVER['PHP_SELF']) == 'SSI.php') |
| 179 | 192 | { |
| 180 | 193 | // You shouldn't just access SSI.php directly by URL!! |
| 181 | - if (!isset($_GET['ssi_function'])) |
|
| 182 | - die(sprintf($txt['ssi_not_direct'], $user_info['is_admin'] ? '\'' . addslashes(__FILE__) . '\'' : '\'SSI.php\'')); |
|
| 194 | + if (!isset($_GET['ssi_function'])) { |
|
| 195 | + die(sprintf($txt['ssi_not_direct'], $user_info['is_admin'] ? '\'' . addslashes(__FILE__) . '\'' : '\'SSI.php\'')); |
|
| 196 | + } |
|
| 183 | 197 | // Call a function passed by GET. |
| 184 | - if (function_exists('ssi_' . $_GET['ssi_function']) && (!empty($modSettings['allow_guestAccess']) || !$user_info['is_guest'])) |
|
| 185 | - call_user_func('ssi_' . $_GET['ssi_function']); |
|
| 198 | + if (function_exists('ssi_' . $_GET['ssi_function']) && (!empty($modSettings['allow_guestAccess']) || !$user_info['is_guest'])) { |
|
| 199 | + call_user_func('ssi_' . $_GET['ssi_function']); |
|
| 200 | + } |
|
| 186 | 201 | exit; |
| 187 | 202 | } |
| 188 | 203 | |
@@ -199,9 +214,10 @@ discard block |
||
| 199 | 214 | */ |
| 200 | 215 | function ssi_shutdown() |
| 201 | 216 | { |
| 202 | - if (!isset($_GET['ssi_function']) || $_GET['ssi_function'] != 'shutdown') |
|
| 203 | - template_footer(); |
|
| 204 | -} |
|
| 217 | + if (!isset($_GET['ssi_function']) || $_GET['ssi_function'] != 'shutdown') { |
|
| 218 | + template_footer(); |
|
| 219 | + } |
|
| 220 | + } |
|
| 205 | 221 | |
| 206 | 222 | /** |
| 207 | 223 | * Display a welcome message, like: Hey, User, you have 0 messages, 0 are new. |
@@ -214,15 +230,17 @@ discard block |
||
| 214 | 230 | |
| 215 | 231 | if ($output_method == 'echo') |
| 216 | 232 | { |
| 217 | - if ($context['user']['is_guest']) |
|
| 218 | - echo sprintf($txt[$context['can_register'] ? 'welcome_guest_register' : 'welcome_guest'], $txt['guest_title'], $context['forum_name_html_safe'], $scripturl . '?action=login', 'return reqOverlayDiv(this.href, ' . JavaScriptEscape($txt['login']) . ');', $scripturl . '?action=signup'); |
|
| 219 | - else |
|
| 220 | - echo $txt['hello_member'], ' <strong>', $context['user']['name'], '</strong>', allowedTo('pm_read') ? ', ' . (empty($context['user']['messages']) ? $txt['msg_alert_no_messages'] : (($context['user']['messages'] == 1 ? sprintf($txt['msg_alert_one_message'], $scripturl . '?action=pm') : sprintf($txt['msg_alert_many_message'], $scripturl . '?action=pm', $context['user']['messages'])) . ', ' . ($context['user']['unread_messages'] == 1 ? $txt['msg_alert_one_new'] : sprintf($txt['msg_alert_many_new'], $context['user']['unread_messages'])))) : ''; |
|
| 233 | + if ($context['user']['is_guest']) { |
|
| 234 | + echo sprintf($txt[$context['can_register'] ? 'welcome_guest_register' : 'welcome_guest'], $txt['guest_title'], $context['forum_name_html_safe'], $scripturl . '?action=login', 'return reqOverlayDiv(this.href, ' . JavaScriptEscape($txt['login']) . ');', $scripturl . '?action=signup'); |
|
| 235 | + } else { |
|
| 236 | + echo $txt['hello_member'], ' <strong>', $context['user']['name'], '</strong>', allowedTo('pm_read') ? ', ' . (empty($context['user']['messages']) ? $txt['msg_alert_no_messages'] : (($context['user']['messages'] == 1 ? sprintf($txt['msg_alert_one_message'], $scripturl . '?action=pm') : sprintf($txt['msg_alert_many_message'], $scripturl . '?action=pm', $context['user']['messages'])) . ', ' . ($context['user']['unread_messages'] == 1 ? $txt['msg_alert_one_new'] : sprintf($txt['msg_alert_many_new'], $context['user']['unread_messages'])))) : ''; |
|
| 237 | + } |
|
| 221 | 238 | } |
| 222 | 239 | // Don't echo... then do what?! |
| 223 | - else |
|
| 224 | - return $context['user']; |
|
| 225 | -} |
|
| 240 | + else { |
|
| 241 | + return $context['user']; |
|
| 242 | + } |
|
| 243 | + } |
|
| 226 | 244 | |
| 227 | 245 | /** |
| 228 | 246 | * Display a menu bar, like is displayed at the top of the forum. |
@@ -233,12 +251,14 @@ discard block |
||
| 233 | 251 | { |
| 234 | 252 | global $context; |
| 235 | 253 | |
| 236 | - if ($output_method == 'echo') |
|
| 237 | - template_menu(); |
|
| 254 | + if ($output_method == 'echo') { |
|
| 255 | + template_menu(); |
|
| 256 | + } |
|
| 238 | 257 | // What else could this do? |
| 239 | - else |
|
| 240 | - return $context['menu_buttons']; |
|
| 241 | -} |
|
| 258 | + else { |
|
| 259 | + return $context['menu_buttons']; |
|
| 260 | + } |
|
| 261 | + } |
|
| 242 | 262 | |
| 243 | 263 | /** |
| 244 | 264 | * Show a logout link. |
@@ -250,20 +270,23 @@ discard block |
||
| 250 | 270 | { |
| 251 | 271 | global $context, $txt, $scripturl; |
| 252 | 272 | |
| 253 | - if ($redirect_to != '') |
|
| 254 | - $_SESSION['logout_url'] = $redirect_to; |
|
| 273 | + if ($redirect_to != '') { |
|
| 274 | + $_SESSION['logout_url'] = $redirect_to; |
|
| 275 | + } |
|
| 255 | 276 | |
| 256 | 277 | // Guests can't log out. |
| 257 | - if ($context['user']['is_guest']) |
|
| 258 | - return false; |
|
| 278 | + if ($context['user']['is_guest']) { |
|
| 279 | + return false; |
|
| 280 | + } |
|
| 259 | 281 | |
| 260 | 282 | $link = '<a href="' . $scripturl . '?action=logout;' . $context['session_var'] . '=' . $context['session_id'] . '">' . $txt['logout'] . '</a>'; |
| 261 | 283 | |
| 262 | - if ($output_method == 'echo') |
|
| 263 | - echo $link; |
|
| 264 | - else |
|
| 265 | - return $link; |
|
| 266 | -} |
|
| 284 | + if ($output_method == 'echo') { |
|
| 285 | + echo $link; |
|
| 286 | + } else { |
|
| 287 | + return $link; |
|
| 288 | + } |
|
| 289 | + } |
|
| 267 | 290 | |
| 268 | 291 | /** |
| 269 | 292 | * Recent post list: [board] Subject by Poster Date |
@@ -279,17 +302,17 @@ discard block |
||
| 279 | 302 | global $modSettings, $context; |
| 280 | 303 | |
| 281 | 304 | // Excluding certain boards... |
| 282 | - if ($exclude_boards === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0) |
|
| 283 | - $exclude_boards = array($modSettings['recycle_board']); |
|
| 284 | - else |
|
| 285 | - $exclude_boards = empty($exclude_boards) ? array() : (is_array($exclude_boards) ? $exclude_boards : array($exclude_boards)); |
|
| 305 | + if ($exclude_boards === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0) { |
|
| 306 | + $exclude_boards = array($modSettings['recycle_board']); |
|
| 307 | + } else { |
|
| 308 | + $exclude_boards = empty($exclude_boards) ? array() : (is_array($exclude_boards) ? $exclude_boards : array($exclude_boards)); |
|
| 309 | + } |
|
| 286 | 310 | |
| 287 | 311 | // What about including certain boards - note we do some protection here as pre-2.0 didn't have this parameter. |
| 288 | 312 | if (is_array($include_boards) || (int) $include_boards === $include_boards) |
| 289 | 313 | { |
| 290 | 314 | $include_boards = is_array($include_boards) ? $include_boards : array($include_boards); |
| 291 | - } |
|
| 292 | - elseif ($include_boards != null) |
|
| 315 | + } elseif ($include_boards != null) |
|
| 293 | 316 | { |
| 294 | 317 | $include_boards = array(); |
| 295 | 318 | } |
@@ -326,8 +349,9 @@ discard block |
||
| 326 | 349 | { |
| 327 | 350 | global $modSettings; |
| 328 | 351 | |
| 329 | - if (empty($post_ids)) |
|
| 330 | - return; |
|
| 352 | + if (empty($post_ids)) { |
|
| 353 | + return; |
|
| 354 | + } |
|
| 331 | 355 | |
| 332 | 356 | // Allow the user to request more than one - why not? |
| 333 | 357 | $post_ids = is_array($post_ids) ? $post_ids : array($post_ids); |
@@ -362,8 +386,9 @@ discard block |
||
| 362 | 386 | global $scripturl, $txt, $user_info; |
| 363 | 387 | global $modSettings, $smcFunc, $context; |
| 364 | 388 | |
| 365 | - if (!empty($modSettings['enable_likes'])) |
|
| 366 | - $context['can_like'] = allowedTo('likes_like'); |
|
| 389 | + if (!empty($modSettings['enable_likes'])) { |
|
| 390 | + $context['can_like'] = allowedTo('likes_like'); |
|
| 391 | + } |
|
| 367 | 392 | |
| 368 | 393 | // Find all the posts. Newer ones will have higher IDs. |
| 369 | 394 | $request = $smcFunc['db_query']('substring', ' |
@@ -429,12 +454,13 @@ discard block |
||
| 429 | 454 | ); |
| 430 | 455 | |
| 431 | 456 | // Get the likes for each message. |
| 432 | - if (!empty($modSettings['enable_likes'])) |
|
| 433 | - $posts[$row['id_msg']]['likes'] = array( |
|
| 457 | + if (!empty($modSettings['enable_likes'])) { |
|
| 458 | + $posts[$row['id_msg']]['likes'] = array( |
|
| 434 | 459 | 'count' => $row['likes'], |
| 435 | 460 | 'you' => in_array($row['id_msg'], prepareLikesContext($row['id_topic'])), |
| 436 | 461 | 'can_like' => !$context['user']['is_guest'] && $row['id_member'] != $context['user']['id'] && !empty($context['can_like']), |
| 437 | 462 | ); |
| 463 | + } |
|
| 438 | 464 | } |
| 439 | 465 | $smcFunc['db_free_result']($request); |
| 440 | 466 | |
@@ -442,13 +468,14 @@ discard block |
||
| 442 | 468 | call_integration_hook('integrate_ssi_queryPosts', array(&$posts)); |
| 443 | 469 | |
| 444 | 470 | // Just return it. |
| 445 | - if ($output_method != 'echo' || empty($posts)) |
|
| 446 | - return $posts; |
|
| 471 | + if ($output_method != 'echo' || empty($posts)) { |
|
| 472 | + return $posts; |
|
| 473 | + } |
|
| 447 | 474 | |
| 448 | 475 | echo ' |
| 449 | 476 | <table style="border: none" class="ssi_table">'; |
| 450 | - foreach ($posts as $post) |
|
| 451 | - echo ' |
|
| 477 | + foreach ($posts as $post) { |
|
| 478 | + echo ' |
|
| 452 | 479 | <tr> |
| 453 | 480 | <td style="text-align: right; vertical-align: top; white-space: nowrap"> |
| 454 | 481 | [', $post['board']['link'], '] |
@@ -462,6 +489,7 @@ discard block |
||
| 462 | 489 | ', $post['time'], ' |
| 463 | 490 | </td> |
| 464 | 491 | </tr>'; |
| 492 | + } |
|
| 465 | 493 | echo ' |
| 466 | 494 | </table>'; |
| 467 | 495 | } |
@@ -479,25 +507,26 @@ discard block |
||
| 479 | 507 | global $settings, $scripturl, $txt, $user_info; |
| 480 | 508 | global $modSettings, $smcFunc, $context; |
| 481 | 509 | |
| 482 | - if ($exclude_boards === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0) |
|
| 483 | - $exclude_boards = array($modSettings['recycle_board']); |
|
| 484 | - else |
|
| 485 | - $exclude_boards = empty($exclude_boards) ? array() : (is_array($exclude_boards) ? $exclude_boards : array($exclude_boards)); |
|
| 510 | + if ($exclude_boards === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0) { |
|
| 511 | + $exclude_boards = array($modSettings['recycle_board']); |
|
| 512 | + } else { |
|
| 513 | + $exclude_boards = empty($exclude_boards) ? array() : (is_array($exclude_boards) ? $exclude_boards : array($exclude_boards)); |
|
| 514 | + } |
|
| 486 | 515 | |
| 487 | 516 | // Only some boards?. |
| 488 | 517 | if (is_array($include_boards) || (int) $include_boards === $include_boards) |
| 489 | 518 | { |
| 490 | 519 | $include_boards = is_array($include_boards) ? $include_boards : array($include_boards); |
| 491 | - } |
|
| 492 | - elseif ($include_boards != null) |
|
| 520 | + } elseif ($include_boards != null) |
|
| 493 | 521 | { |
| 494 | 522 | $output_method = $include_boards; |
| 495 | 523 | $include_boards = array(); |
| 496 | 524 | } |
| 497 | 525 | |
| 498 | 526 | $icon_sources = array(); |
| 499 | - foreach ($context['stable_icons'] as $icon) |
|
| 500 | - $icon_sources[$icon] = 'images_url'; |
|
| 527 | + foreach ($context['stable_icons'] as $icon) { |
|
| 528 | + $icon_sources[$icon] = 'images_url'; |
|
| 529 | + } |
|
| 501 | 530 | |
| 502 | 531 | // Find all the posts in distinct topics. Newer ones will have higher IDs. |
| 503 | 532 | $request = $smcFunc['db_query']('substring', ' |
@@ -522,13 +551,15 @@ discard block |
||
| 522 | 551 | ) |
| 523 | 552 | ); |
| 524 | 553 | $topics = array(); |
| 525 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 526 | - $topics[$row['id_topic']] = $row; |
|
| 554 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 555 | + $topics[$row['id_topic']] = $row; |
|
| 556 | + } |
|
| 527 | 557 | $smcFunc['db_free_result']($request); |
| 528 | 558 | |
| 529 | 559 | // Did we find anything? If not, bail. |
| 530 | - if (empty($topics)) |
|
| 531 | - return array(); |
|
| 560 | + if (empty($topics)) { |
|
| 561 | + return array(); |
|
| 562 | + } |
|
| 532 | 563 | |
| 533 | 564 | $recycle_board = !empty($modSettings['recycle_enable']) && !empty($modSettings['recycle_board']) ? (int) $modSettings['recycle_board'] : 0; |
| 534 | 565 | |
@@ -556,19 +587,22 @@ discard block |
||
| 556 | 587 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 557 | 588 | { |
| 558 | 589 | $row['body'] = strip_tags(strtr(parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']), array('<br>' => ' '))); |
| 559 | - if ($smcFunc['strlen']($row['body']) > 128) |
|
| 560 | - $row['body'] = $smcFunc['substr']($row['body'], 0, 128) . '...'; |
|
| 590 | + if ($smcFunc['strlen']($row['body']) > 128) { |
|
| 591 | + $row['body'] = $smcFunc['substr']($row['body'], 0, 128) . '...'; |
|
| 592 | + } |
|
| 561 | 593 | |
| 562 | 594 | // Censor the subject. |
| 563 | 595 | censorText($row['subject']); |
| 564 | 596 | censorText($row['body']); |
| 565 | 597 | |
| 566 | 598 | // Recycled icon |
| 567 | - if (!empty($recycle_board) && $topics[$row['id_topic']]['id_board']) |
|
| 568 | - $row['icon'] = 'recycled'; |
|
| 599 | + if (!empty($recycle_board) && $topics[$row['id_topic']]['id_board']) { |
|
| 600 | + $row['icon'] = 'recycled'; |
|
| 601 | + } |
|
| 569 | 602 | |
| 570 | - if (!empty($modSettings['messageIconChecks_enable']) && !isset($icon_sources[$row['icon']])) |
|
| 571 | - $icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
| 603 | + if (!empty($modSettings['messageIconChecks_enable']) && !isset($icon_sources[$row['icon']])) { |
|
| 604 | + $icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
| 605 | + } |
|
| 572 | 606 | |
| 573 | 607 | // Build the array. |
| 574 | 608 | $posts[] = array( |
@@ -607,13 +641,14 @@ discard block |
||
| 607 | 641 | call_integration_hook('integrate_ssi_recentTopics', array(&$posts)); |
| 608 | 642 | |
| 609 | 643 | // Just return it. |
| 610 | - if ($output_method != 'echo' || empty($posts)) |
|
| 611 | - return $posts; |
|
| 644 | + if ($output_method != 'echo' || empty($posts)) { |
|
| 645 | + return $posts; |
|
| 646 | + } |
|
| 612 | 647 | |
| 613 | 648 | echo ' |
| 614 | 649 | <table style="border: none" class="ssi_table">'; |
| 615 | - foreach ($posts as $post) |
|
| 616 | - echo ' |
|
| 650 | + foreach ($posts as $post) { |
|
| 651 | + echo ' |
|
| 617 | 652 | <tr> |
| 618 | 653 | <td style="text-align: right; vertical-align: top; white-space: nowrap"> |
| 619 | 654 | [', $post['board']['link'], '] |
@@ -627,6 +662,7 @@ discard block |
||
| 627 | 662 | ', $post['time'], ' |
| 628 | 663 | </td> |
| 629 | 664 | </tr>'; |
| 665 | + } |
|
| 630 | 666 | echo ' |
| 631 | 667 | </table>'; |
| 632 | 668 | } |
@@ -651,27 +687,30 @@ discard block |
||
| 651 | 687 | ) |
| 652 | 688 | ); |
| 653 | 689 | $return = array(); |
| 654 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 655 | - $return[] = array( |
|
| 690 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 691 | + $return[] = array( |
|
| 656 | 692 | 'id' => $row['id_member'], |
| 657 | 693 | 'name' => $row['real_name'], |
| 658 | 694 | 'href' => $scripturl . '?action=profile;u=' . $row['id_member'], |
| 659 | 695 | 'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>', |
| 660 | 696 | 'posts' => $row['posts'] |
| 661 | 697 | ); |
| 698 | + } |
|
| 662 | 699 | $smcFunc['db_free_result']($request); |
| 663 | 700 | |
| 664 | 701 | // If mods want to do somthing with this list of members, let them do that now. |
| 665 | 702 | call_integration_hook('integrate_ssi_topPoster', array(&$return)); |
| 666 | 703 | |
| 667 | 704 | // Just return all the top posters. |
| 668 | - if ($output_method != 'echo') |
|
| 669 | - return $return; |
|
| 705 | + if ($output_method != 'echo') { |
|
| 706 | + return $return; |
|
| 707 | + } |
|
| 670 | 708 | |
| 671 | 709 | // Make a quick array to list the links in. |
| 672 | 710 | $temp_array = array(); |
| 673 | - foreach ($return as $member) |
|
| 674 | - $temp_array[] = $member['link']; |
|
| 711 | + foreach ($return as $member) { |
|
| 712 | + $temp_array[] = $member['link']; |
|
| 713 | + } |
|
| 675 | 714 | |
| 676 | 715 | echo implode(', ', $temp_array); |
| 677 | 716 | } |
@@ -703,8 +742,8 @@ discard block |
||
| 703 | 742 | ) |
| 704 | 743 | ); |
| 705 | 744 | $boards = array(); |
| 706 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 707 | - $boards[] = array( |
|
| 745 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 746 | + $boards[] = array( |
|
| 708 | 747 | 'id' => $row['id_board'], |
| 709 | 748 | 'num_posts' => $row['num_posts'], |
| 710 | 749 | 'num_topics' => $row['num_topics'], |
@@ -713,14 +752,16 @@ discard block |
||
| 713 | 752 | 'href' => $scripturl . '?board=' . $row['id_board'] . '.0', |
| 714 | 753 | 'link' => '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>' |
| 715 | 754 | ); |
| 755 | + } |
|
| 716 | 756 | $smcFunc['db_free_result']($request); |
| 717 | 757 | |
| 718 | 758 | // If mods want to do somthing with this list of boards, let them do that now. |
| 719 | 759 | call_integration_hook('integrate_ssi_topBoards', array(&$boards)); |
| 720 | 760 | |
| 721 | 761 | // If we shouldn't output or have nothing to output, just jump out. |
| 722 | - if ($output_method != 'echo' || empty($boards)) |
|
| 723 | - return $boards; |
|
| 762 | + if ($output_method != 'echo' || empty($boards)) { |
|
| 763 | + return $boards; |
|
| 764 | + } |
|
| 724 | 765 | |
| 725 | 766 | echo ' |
| 726 | 767 | <table class="ssi_table"> |
@@ -729,13 +770,14 @@ discard block |
||
| 729 | 770 | <th style="text-align: left">', $txt['board_topics'], '</th> |
| 730 | 771 | <th style="text-align: left">', $txt['posts'], '</th> |
| 731 | 772 | </tr>'; |
| 732 | - foreach ($boards as $sBoard) |
|
| 733 | - echo ' |
|
| 773 | + foreach ($boards as $sBoard) { |
|
| 774 | + echo ' |
|
| 734 | 775 | <tr> |
| 735 | 776 | <td>', $sBoard['link'], $sBoard['new'] ? ' <a href="' . $sBoard['href'] . '"><span class="new_posts">' . $txt['new'] . '</span></a>' : '', '</td> |
| 736 | 777 | <td style="text-align: right">', comma_format($sBoard['num_topics']), '</td> |
| 737 | 778 | <td style="text-align: right">', comma_format($sBoard['num_posts']), '</td> |
| 738 | 779 | </tr>'; |
| 780 | + } |
|
| 739 | 781 | echo ' |
| 740 | 782 | </table>'; |
| 741 | 783 | } |
@@ -768,12 +810,13 @@ discard block |
||
| 768 | 810 | ) |
| 769 | 811 | ); |
| 770 | 812 | $topic_ids = array(); |
| 771 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 772 | - $topic_ids[] = $row['id_topic']; |
|
| 813 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 814 | + $topic_ids[] = $row['id_topic']; |
|
| 815 | + } |
|
| 773 | 816 | $smcFunc['db_free_result']($request); |
| 817 | + } else { |
|
| 818 | + $topic_ids = array(); |
|
| 774 | 819 | } |
| 775 | - else |
|
| 776 | - $topic_ids = array(); |
|
| 777 | 820 | |
| 778 | 821 | $request = $smcFunc['db_query']('', ' |
| 779 | 822 | SELECT m.subject, m.id_topic, t.num_views, t.num_replies |
@@ -812,8 +855,9 @@ discard block |
||
| 812 | 855 | // If mods want to do somthing with this list of topics, let them do that now. |
| 813 | 856 | call_integration_hook('integrate_ssi_topTopics', array(&$topics, $type)); |
| 814 | 857 | |
| 815 | - if ($output_method != 'echo' || empty($topics)) |
|
| 816 | - return $topics; |
|
| 858 | + if ($output_method != 'echo' || empty($topics)) { |
|
| 859 | + return $topics; |
|
| 860 | + } |
|
| 817 | 861 | |
| 818 | 862 | echo ' |
| 819 | 863 | <table class="ssi_table"> |
@@ -822,8 +866,8 @@ discard block |
||
| 822 | 866 | <th style="text-align: left">', $txt['views'], '</th> |
| 823 | 867 | <th style="text-align: left">', $txt['replies'], '</th> |
| 824 | 868 | </tr>'; |
| 825 | - foreach ($topics as $sTopic) |
|
| 826 | - echo ' |
|
| 869 | + foreach ($topics as $sTopic) { |
|
| 870 | + echo ' |
|
| 827 | 871 | <tr> |
| 828 | 872 | <td style="text-align: left"> |
| 829 | 873 | ', $sTopic['link'], ' |
@@ -831,6 +875,7 @@ discard block |
||
| 831 | 875 | <td style="text-align: right">', comma_format($sTopic['num_views']), '</td> |
| 832 | 876 | <td style="text-align: right">', comma_format($sTopic['num_replies']), '</td> |
| 833 | 877 | </tr>'; |
| 878 | + } |
|
| 834 | 879 | echo ' |
| 835 | 880 | </table>'; |
| 836 | 881 | } |
@@ -866,12 +911,13 @@ discard block |
||
| 866 | 911 | { |
| 867 | 912 | global $txt, $context; |
| 868 | 913 | |
| 869 | - if ($output_method == 'echo') |
|
| 870 | - echo ' |
|
| 914 | + if ($output_method == 'echo') { |
|
| 915 | + echo ' |
|
| 871 | 916 | ', sprintf($txt['welcome_newest_member'], $context['common_stats']['latest_member']['link']), '<br>'; |
| 872 | - else |
|
| 873 | - return $context['common_stats']['latest_member']; |
|
| 874 | -} |
|
| 917 | + } else { |
|
| 918 | + return $context['common_stats']['latest_member']; |
|
| 919 | + } |
|
| 920 | + } |
|
| 875 | 921 | |
| 876 | 922 | /** |
| 877 | 923 | * Fetches a random member. |
@@ -920,8 +966,9 @@ discard block |
||
| 920 | 966 | } |
| 921 | 967 | |
| 922 | 968 | // Just to be sure put the random generator back to something... random. |
| 923 | - if ($random_type != '') |
|
| 924 | - mt_srand(time()); |
|
| 969 | + if ($random_type != '') { |
|
| 970 | + mt_srand(time()); |
|
| 971 | + } |
|
| 925 | 972 | |
| 926 | 973 | return $result; |
| 927 | 974 | } |
@@ -934,8 +981,9 @@ discard block |
||
| 934 | 981 | */ |
| 935 | 982 | function ssi_fetchMember($member_ids = array(), $output_method = 'echo') |
| 936 | 983 | { |
| 937 | - if (empty($member_ids)) |
|
| 938 | - return; |
|
| 984 | + if (empty($member_ids)) { |
|
| 985 | + return; |
|
| 986 | + } |
|
| 939 | 987 | |
| 940 | 988 | // Can have more than one member if you really want... |
| 941 | 989 | $member_ids = is_array($member_ids) ? $member_ids : array($member_ids); |
@@ -960,8 +1008,9 @@ discard block |
||
| 960 | 1008 | */ |
| 961 | 1009 | function ssi_fetchGroupMembers($group_id = null, $output_method = 'echo') |
| 962 | 1010 | { |
| 963 | - if ($group_id === null) |
|
| 964 | - return; |
|
| 1011 | + if ($group_id === null) { |
|
| 1012 | + return; |
|
| 1013 | + } |
|
| 965 | 1014 | |
| 966 | 1015 | $query_where = ' |
| 967 | 1016 | id_group = {int:id_group} |
@@ -988,8 +1037,9 @@ discard block |
||
| 988 | 1037 | { |
| 989 | 1038 | global $smcFunc, $memberContext; |
| 990 | 1039 | |
| 991 | - if ($query_where === null) |
|
| 992 | - return; |
|
| 1040 | + if ($query_where === null) { |
|
| 1041 | + return; |
|
| 1042 | + } |
|
| 993 | 1043 | |
| 994 | 1044 | // Fetch the members in question. |
| 995 | 1045 | $request = $smcFunc['db_query']('', ' |
@@ -1002,12 +1052,14 @@ discard block |
||
| 1002 | 1052 | )) |
| 1003 | 1053 | ); |
| 1004 | 1054 | $members = array(); |
| 1005 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1006 | - $members[] = $row['id_member']; |
|
| 1055 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1056 | + $members[] = $row['id_member']; |
|
| 1057 | + } |
|
| 1007 | 1058 | $smcFunc['db_free_result']($request); |
| 1008 | 1059 | |
| 1009 | - if (empty($members)) |
|
| 1010 | - return array(); |
|
| 1060 | + if (empty($members)) { |
|
| 1061 | + return array(); |
|
| 1062 | + } |
|
| 1011 | 1063 | |
| 1012 | 1064 | // If mods want to do somthing with this list of members, let them do that now. |
| 1013 | 1065 | call_integration_hook('integrate_ssi_queryMembers', array(&$members)); |
@@ -1016,23 +1068,25 @@ discard block |
||
| 1016 | 1068 | loadMemberData($members); |
| 1017 | 1069 | |
| 1018 | 1070 | // Draw the table! |
| 1019 | - if ($output_method == 'echo') |
|
| 1020 | - echo ' |
|
| 1071 | + if ($output_method == 'echo') { |
|
| 1072 | + echo ' |
|
| 1021 | 1073 | <table style="border: none" class="ssi_table">'; |
| 1074 | + } |
|
| 1022 | 1075 | |
| 1023 | 1076 | $query_members = array(); |
| 1024 | 1077 | foreach ($members as $member) |
| 1025 | 1078 | { |
| 1026 | 1079 | // Load their context data. |
| 1027 | - if (!loadMemberContext($member)) |
|
| 1028 | - continue; |
|
| 1080 | + if (!loadMemberContext($member)) { |
|
| 1081 | + continue; |
|
| 1082 | + } |
|
| 1029 | 1083 | |
| 1030 | 1084 | // Store this member's information. |
| 1031 | 1085 | $query_members[$member] = $memberContext[$member]; |
| 1032 | 1086 | |
| 1033 | 1087 | // Only do something if we're echo'ing. |
| 1034 | - if ($output_method == 'echo') |
|
| 1035 | - echo ' |
|
| 1088 | + if ($output_method == 'echo') { |
|
| 1089 | + echo ' |
|
| 1036 | 1090 | <tr> |
| 1037 | 1091 | <td style="text-align: right; vertical-align: top; white-space: nowrap"> |
| 1038 | 1092 | ', $query_members[$member]['link'], ' |
@@ -1040,12 +1094,14 @@ discard block |
||
| 1040 | 1094 | <br>', $query_members[$member]['avatar']['image'], ' |
| 1041 | 1095 | </td> |
| 1042 | 1096 | </tr>'; |
| 1097 | + } |
|
| 1043 | 1098 | } |
| 1044 | 1099 | |
| 1045 | 1100 | // End the table if appropriate. |
| 1046 | - if ($output_method == 'echo') |
|
| 1047 | - echo ' |
|
| 1101 | + if ($output_method == 'echo') { |
|
| 1102 | + echo ' |
|
| 1048 | 1103 | </table>'; |
| 1104 | + } |
|
| 1049 | 1105 | |
| 1050 | 1106 | // Send back the data. |
| 1051 | 1107 | return $query_members; |
@@ -1060,8 +1116,9 @@ discard block |
||
| 1060 | 1116 | { |
| 1061 | 1117 | global $txt, $scripturl, $modSettings, $smcFunc; |
| 1062 | 1118 | |
| 1063 | - if (!allowedTo('view_stats')) |
|
| 1064 | - return; |
|
| 1119 | + if (!allowedTo('view_stats')) { |
|
| 1120 | + return; |
|
| 1121 | + } |
|
| 1065 | 1122 | |
| 1066 | 1123 | $totals = array( |
| 1067 | 1124 | 'members' => $modSettings['totalMembers'], |
@@ -1090,8 +1147,9 @@ discard block |
||
| 1090 | 1147 | // If mods want to do somthing with the board stats, let them do that now. |
| 1091 | 1148 | call_integration_hook('integrate_ssi_boardStats', array(&$totals)); |
| 1092 | 1149 | |
| 1093 | - if ($output_method != 'echo') |
|
| 1094 | - return $totals; |
|
| 1150 | + if ($output_method != 'echo') { |
|
| 1151 | + return $totals; |
|
| 1152 | + } |
|
| 1095 | 1153 | |
| 1096 | 1154 | echo ' |
| 1097 | 1155 | ', $txt['total_members'], ': <a href="', $scripturl . '?action=mlist">', comma_format($totals['members']), '</a><br> |
@@ -1120,8 +1178,8 @@ discard block |
||
| 1120 | 1178 | call_integration_hook('integrate_ssi_whosOnline', array(&$return)); |
| 1121 | 1179 | |
| 1122 | 1180 | // Add some redundancy for backwards compatibility reasons. |
| 1123 | - if ($output_method != 'echo') |
|
| 1124 | - return $return + array( |
|
| 1181 | + if ($output_method != 'echo') { |
|
| 1182 | + return $return + array( |
|
| 1125 | 1183 | 'users' => $return['users_online'], |
| 1126 | 1184 | 'guests' => $return['num_guests'], |
| 1127 | 1185 | 'hidden' => $return['num_users_hidden'], |
@@ -1129,29 +1187,35 @@ discard block |
||
| 1129 | 1187 | 'num_users' => $return['num_users_online'], |
| 1130 | 1188 | 'total_users' => $return['num_users_online'] + $return['num_guests'], |
| 1131 | 1189 | ); |
| 1190 | + } |
|
| 1132 | 1191 | |
| 1133 | 1192 | echo ' |
| 1134 | 1193 | ', comma_format($return['num_guests']), ' ', $return['num_guests'] == 1 ? $txt['guest'] : $txt['guests'], ', ', comma_format($return['num_users_online']), ' ', $return['num_users_online'] == 1 ? $txt['user'] : $txt['users']; |
| 1135 | 1194 | |
| 1136 | 1195 | $bracketList = array(); |
| 1137 | - if (!empty($user_info['buddies'])) |
|
| 1138 | - $bracketList[] = comma_format($return['num_buddies']) . ' ' . ($return['num_buddies'] == 1 ? $txt['buddy'] : $txt['buddies']); |
|
| 1139 | - if (!empty($return['num_spiders'])) |
|
| 1140 | - $bracketList[] = comma_format($return['num_spiders']) . ' ' . ($return['num_spiders'] == 1 ? $txt['spider'] : $txt['spiders']); |
|
| 1141 | - if (!empty($return['num_users_hidden'])) |
|
| 1142 | - $bracketList[] = comma_format($return['num_users_hidden']) . ' ' . $txt['hidden']; |
|
| 1196 | + if (!empty($user_info['buddies'])) { |
|
| 1197 | + $bracketList[] = comma_format($return['num_buddies']) . ' ' . ($return['num_buddies'] == 1 ? $txt['buddy'] : $txt['buddies']); |
|
| 1198 | + } |
|
| 1199 | + if (!empty($return['num_spiders'])) { |
|
| 1200 | + $bracketList[] = comma_format($return['num_spiders']) . ' ' . ($return['num_spiders'] == 1 ? $txt['spider'] : $txt['spiders']); |
|
| 1201 | + } |
|
| 1202 | + if (!empty($return['num_users_hidden'])) { |
|
| 1203 | + $bracketList[] = comma_format($return['num_users_hidden']) . ' ' . $txt['hidden']; |
|
| 1204 | + } |
|
| 1143 | 1205 | |
| 1144 | - if (!empty($bracketList)) |
|
| 1145 | - echo ' (' . implode(', ', $bracketList) . ')'; |
|
| 1206 | + if (!empty($bracketList)) { |
|
| 1207 | + echo ' (' . implode(', ', $bracketList) . ')'; |
|
| 1208 | + } |
|
| 1146 | 1209 | |
| 1147 | 1210 | echo '<br> |
| 1148 | 1211 | ', implode(', ', $return['list_users_online']); |
| 1149 | 1212 | |
| 1150 | 1213 | // Showing membergroups? |
| 1151 | - if (!empty($settings['show_group_key']) && !empty($return['membergroups'])) |
|
| 1152 | - echo '<br> |
|
| 1214 | + if (!empty($settings['show_group_key']) && !empty($return['membergroups'])) { |
|
| 1215 | + echo '<br> |
|
| 1153 | 1216 | [' . implode('] [', $return['membergroups']) . ']'; |
| 1154 | -} |
|
| 1217 | + } |
|
| 1218 | + } |
|
| 1155 | 1219 | |
| 1156 | 1220 | /** |
| 1157 | 1221 | * Just like whosOnline except it also logs the online presence. |
@@ -1162,11 +1226,12 @@ discard block |
||
| 1162 | 1226 | { |
| 1163 | 1227 | writeLog(); |
| 1164 | 1228 | |
| 1165 | - if ($output_method != 'echo') |
|
| 1166 | - return ssi_whosOnline($output_method); |
|
| 1167 | - else |
|
| 1168 | - ssi_whosOnline($output_method); |
|
| 1169 | -} |
|
| 1229 | + if ($output_method != 'echo') { |
|
| 1230 | + return ssi_whosOnline($output_method); |
|
| 1231 | + } else { |
|
| 1232 | + ssi_whosOnline($output_method); |
|
| 1233 | + } |
|
| 1234 | + } |
|
| 1170 | 1235 | |
| 1171 | 1236 | // Shows a login box. |
| 1172 | 1237 | /** |
@@ -1179,11 +1244,13 @@ discard block |
||
| 1179 | 1244 | { |
| 1180 | 1245 | global $scripturl, $txt, $user_info, $context; |
| 1181 | 1246 | |
| 1182 | - if ($redirect_to != '') |
|
| 1183 | - $_SESSION['login_url'] = $redirect_to; |
|
| 1247 | + if ($redirect_to != '') { |
|
| 1248 | + $_SESSION['login_url'] = $redirect_to; |
|
| 1249 | + } |
|
| 1184 | 1250 | |
| 1185 | - if ($output_method != 'echo' || !$user_info['is_guest']) |
|
| 1186 | - return $user_info['is_guest']; |
|
| 1251 | + if ($output_method != 'echo' || !$user_info['is_guest']) { |
|
| 1252 | + return $user_info['is_guest']; |
|
| 1253 | + } |
|
| 1187 | 1254 | |
| 1188 | 1255 | // Create a login token |
| 1189 | 1256 | createToken('login'); |
@@ -1235,8 +1302,9 @@ discard block |
||
| 1235 | 1302 | |
| 1236 | 1303 | $boardsAllowed = array_intersect(boardsAllowedTo('poll_view'), boardsAllowedTo('poll_vote')); |
| 1237 | 1304 | |
| 1238 | - if (empty($boardsAllowed)) |
|
| 1239 | - return array(); |
|
| 1305 | + if (empty($boardsAllowed)) { |
|
| 1306 | + return array(); |
|
| 1307 | + } |
|
| 1240 | 1308 | |
| 1241 | 1309 | $request = $smcFunc['db_query']('', ' |
| 1242 | 1310 | SELECT p.id_poll, p.question, t.id_topic, p.max_votes, p.guest_vote, p.hide_results, p.expire_time |
@@ -1269,12 +1337,14 @@ discard block |
||
| 1269 | 1337 | $smcFunc['db_free_result']($request); |
| 1270 | 1338 | |
| 1271 | 1339 | // This user has voted on all the polls. |
| 1272 | - if (empty($row) || !is_array($row)) |
|
| 1273 | - return array(); |
|
| 1340 | + if (empty($row) || !is_array($row)) { |
|
| 1341 | + return array(); |
|
| 1342 | + } |
|
| 1274 | 1343 | |
| 1275 | 1344 | // If this is a guest who's voted we'll through ourselves to show poll to show the results. |
| 1276 | - if ($user_info['is_guest'] && (!$row['guest_vote'] || (isset($_COOKIE['guest_poll_vote']) && in_array($row['id_poll'], explode(',', $_COOKIE['guest_poll_vote']))))) |
|
| 1277 | - return ssi_showPoll($row['id_topic'], $output_method); |
|
| 1345 | + if ($user_info['is_guest'] && (!$row['guest_vote'] || (isset($_COOKIE['guest_poll_vote']) && in_array($row['id_poll'], explode(',', $_COOKIE['guest_poll_vote']))))) { |
|
| 1346 | + return ssi_showPoll($row['id_topic'], $output_method); |
|
| 1347 | + } |
|
| 1278 | 1348 | |
| 1279 | 1349 | $request = $smcFunc['db_query']('', ' |
| 1280 | 1350 | SELECT COUNT(DISTINCT id_member) |
@@ -1338,8 +1408,9 @@ discard block |
||
| 1338 | 1408 | // If mods want to do somthing with this list of polls, let them do that now. |
| 1339 | 1409 | call_integration_hook('integrate_ssi_recentPoll', array(&$return, $topPollInstead)); |
| 1340 | 1410 | |
| 1341 | - if ($output_method != 'echo') |
|
| 1342 | - return $return; |
|
| 1411 | + if ($output_method != 'echo') { |
|
| 1412 | + return $return; |
|
| 1413 | + } |
|
| 1343 | 1414 | |
| 1344 | 1415 | if ($allow_view_results) |
| 1345 | 1416 | { |
@@ -1348,19 +1419,20 @@ discard block |
||
| 1348 | 1419 | <strong>', $return['question'], '</strong><br> |
| 1349 | 1420 | ', !empty($return['allowed_warning']) ? $return['allowed_warning'] . '<br>' : ''; |
| 1350 | 1421 | |
| 1351 | - foreach ($return['options'] as $option) |
|
| 1352 | - echo ' |
|
| 1422 | + foreach ($return['options'] as $option) { |
|
| 1423 | + echo ' |
|
| 1353 | 1424 | <label for="', $option['id'], '">', $option['vote_button'], ' ', $option['option'], '</label><br>'; |
| 1425 | + } |
|
| 1354 | 1426 | |
| 1355 | 1427 | echo ' |
| 1356 | 1428 | <input type="submit" value="', $txt['poll_vote'], '" class="button"> |
| 1357 | 1429 | <input type="hidden" name="poll" value="', $return['id'], '"> |
| 1358 | 1430 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
| 1359 | 1431 | </form>'; |
| 1432 | + } else { |
|
| 1433 | + echo $txt['poll_cannot_see']; |
|
| 1434 | + } |
|
| 1360 | 1435 | } |
| 1361 | - else |
|
| 1362 | - echo $txt['poll_cannot_see']; |
|
| 1363 | -} |
|
| 1364 | 1436 | |
| 1365 | 1437 | /** |
| 1366 | 1438 | * Shows the poll from the specified topic |
@@ -1374,13 +1446,15 @@ discard block |
||
| 1374 | 1446 | |
| 1375 | 1447 | $boardsAllowed = boardsAllowedTo('poll_view'); |
| 1376 | 1448 | |
| 1377 | - if (empty($boardsAllowed)) |
|
| 1378 | - return array(); |
|
| 1449 | + if (empty($boardsAllowed)) { |
|
| 1450 | + return array(); |
|
| 1451 | + } |
|
| 1379 | 1452 | |
| 1380 | - if ($topic === null && isset($_REQUEST['ssi_topic'])) |
|
| 1381 | - $topic = (int) $_REQUEST['ssi_topic']; |
|
| 1382 | - else |
|
| 1383 | - $topic = (int) $topic; |
|
| 1453 | + if ($topic === null && isset($_REQUEST['ssi_topic'])) { |
|
| 1454 | + $topic = (int) $_REQUEST['ssi_topic']; |
|
| 1455 | + } else { |
|
| 1456 | + $topic = (int) $topic; |
|
| 1457 | + } |
|
| 1384 | 1458 | |
| 1385 | 1459 | $request = $smcFunc['db_query']('', ' |
| 1386 | 1460 | SELECT |
@@ -1401,17 +1475,18 @@ discard block |
||
| 1401 | 1475 | ); |
| 1402 | 1476 | |
| 1403 | 1477 | // Either this topic has no poll, or the user cannot view it. |
| 1404 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 1405 | - return array(); |
|
| 1478 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 1479 | + return array(); |
|
| 1480 | + } |
|
| 1406 | 1481 | |
| 1407 | 1482 | $row = $smcFunc['db_fetch_assoc']($request); |
| 1408 | 1483 | $smcFunc['db_free_result']($request); |
| 1409 | 1484 | |
| 1410 | 1485 | // Check if they can vote. |
| 1411 | 1486 | $already_voted = false; |
| 1412 | - if (!empty($row['expire_time']) && $row['expire_time'] < time()) |
|
| 1413 | - $allow_vote = false; |
|
| 1414 | - elseif ($user_info['is_guest']) |
|
| 1487 | + if (!empty($row['expire_time']) && $row['expire_time'] < time()) { |
|
| 1488 | + $allow_vote = false; |
|
| 1489 | + } elseif ($user_info['is_guest']) |
|
| 1415 | 1490 | { |
| 1416 | 1491 | // There's a difference between "allowed to vote" and "already voted"... |
| 1417 | 1492 | $allow_vote = $row['guest_vote']; |
@@ -1421,10 +1496,9 @@ discard block |
||
| 1421 | 1496 | { |
| 1422 | 1497 | $already_voted = true; |
| 1423 | 1498 | } |
| 1424 | - } |
|
| 1425 | - elseif (!empty($row['voting_locked']) || !allowedTo('poll_vote', $row['id_board'])) |
|
| 1426 | - $allow_vote = false; |
|
| 1427 | - else |
|
| 1499 | + } elseif (!empty($row['voting_locked']) || !allowedTo('poll_vote', $row['id_board'])) { |
|
| 1500 | + $allow_vote = false; |
|
| 1501 | + } else |
|
| 1428 | 1502 | { |
| 1429 | 1503 | $request = $smcFunc['db_query']('', ' |
| 1430 | 1504 | SELECT id_member |
@@ -1506,8 +1580,9 @@ discard block |
||
| 1506 | 1580 | // If mods want to do somthing with this poll, let them do that now. |
| 1507 | 1581 | call_integration_hook('integrate_ssi_showPoll', array(&$return)); |
| 1508 | 1582 | |
| 1509 | - if ($output_method != 'echo') |
|
| 1510 | - return $return; |
|
| 1583 | + if ($output_method != 'echo') { |
|
| 1584 | + return $return; |
|
| 1585 | + } |
|
| 1511 | 1586 | |
| 1512 | 1587 | if ($return['allow_vote']) |
| 1513 | 1588 | { |
@@ -1516,17 +1591,17 @@ discard block |
||
| 1516 | 1591 | <strong>', $return['question'], '</strong><br> |
| 1517 | 1592 | ', !empty($return['allowed_warning']) ? $return['allowed_warning'] . '<br>' : ''; |
| 1518 | 1593 | |
| 1519 | - foreach ($return['options'] as $option) |
|
| 1520 | - echo ' |
|
| 1594 | + foreach ($return['options'] as $option) { |
|
| 1595 | + echo ' |
|
| 1521 | 1596 | <label for="', $option['id'], '">', $option['vote_button'], ' ', $option['option'], '</label><br>'; |
| 1597 | + } |
|
| 1522 | 1598 | |
| 1523 | 1599 | echo ' |
| 1524 | 1600 | <input type="submit" value="', $txt['poll_vote'], '" class="button"> |
| 1525 | 1601 | <input type="hidden" name="poll" value="', $return['id'], '"> |
| 1526 | 1602 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
| 1527 | 1603 | </form>'; |
| 1528 | - } |
|
| 1529 | - else |
|
| 1604 | + } else |
|
| 1530 | 1605 | { |
| 1531 | 1606 | echo ' |
| 1532 | 1607 | <div class="ssi_poll"> |
@@ -1606,27 +1681,32 @@ discard block |
||
| 1606 | 1681 | 'is_approved' => 1, |
| 1607 | 1682 | ) |
| 1608 | 1683 | ); |
| 1609 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 1610 | - die; |
|
| 1684 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 1685 | + die; |
|
| 1686 | + } |
|
| 1611 | 1687 | $row = $smcFunc['db_fetch_assoc']($request); |
| 1612 | 1688 | $smcFunc['db_free_result']($request); |
| 1613 | 1689 | |
| 1614 | - if (!empty($row['voting_locked']) || ($row['selected'] != -1 && !$user_info['is_guest']) || (!empty($row['expire_time']) && time() > $row['expire_time'])) |
|
| 1615 | - redirectexit('topic=' . $row['id_topic'] . '.0'); |
|
| 1690 | + if (!empty($row['voting_locked']) || ($row['selected'] != -1 && !$user_info['is_guest']) || (!empty($row['expire_time']) && time() > $row['expire_time'])) { |
|
| 1691 | + redirectexit('topic=' . $row['id_topic'] . '.0'); |
|
| 1692 | + } |
|
| 1616 | 1693 | |
| 1617 | 1694 | // Too many options checked? |
| 1618 | - if (count($_REQUEST['options']) > $row['max_votes']) |
|
| 1619 | - redirectexit('topic=' . $row['id_topic'] . '.0'); |
|
| 1695 | + if (count($_REQUEST['options']) > $row['max_votes']) { |
|
| 1696 | + redirectexit('topic=' . $row['id_topic'] . '.0'); |
|
| 1697 | + } |
|
| 1620 | 1698 | |
| 1621 | 1699 | // It's a guest who has already voted? |
| 1622 | 1700 | if ($user_info['is_guest']) |
| 1623 | 1701 | { |
| 1624 | 1702 | // Guest voting disabled? |
| 1625 | - if (!$row['guest_vote']) |
|
| 1626 | - redirectexit('topic=' . $row['id_topic'] . '.0'); |
|
| 1703 | + if (!$row['guest_vote']) { |
|
| 1704 | + redirectexit('topic=' . $row['id_topic'] . '.0'); |
|
| 1705 | + } |
|
| 1627 | 1706 | // Already voted? |
| 1628 | - elseif (isset($_COOKIE['guest_poll_vote']) && in_array($row['id_poll'], explode(',', $_COOKIE['guest_poll_vote']))) |
|
| 1629 | - redirectexit('topic=' . $row['id_topic'] . '.0'); |
|
| 1707 | + elseif (isset($_COOKIE['guest_poll_vote']) && in_array($row['id_poll'], explode(',', $_COOKIE['guest_poll_vote']))) { |
|
| 1708 | + redirectexit('topic=' . $row['id_topic'] . '.0'); |
|
| 1709 | + } |
|
| 1630 | 1710 | } |
| 1631 | 1711 | |
| 1632 | 1712 | $sOptions = array(); |
@@ -1680,11 +1760,13 @@ discard block |
||
| 1680 | 1760 | { |
| 1681 | 1761 | global $scripturl, $txt, $context; |
| 1682 | 1762 | |
| 1683 | - if (!allowedTo('search_posts')) |
|
| 1684 | - return; |
|
| 1763 | + if (!allowedTo('search_posts')) { |
|
| 1764 | + return; |
|
| 1765 | + } |
|
| 1685 | 1766 | |
| 1686 | - if ($output_method != 'echo') |
|
| 1687 | - return $scripturl . '?action=search'; |
|
| 1767 | + if ($output_method != 'echo') { |
|
| 1768 | + return $scripturl . '?action=search'; |
|
| 1769 | + } |
|
| 1688 | 1770 | |
| 1689 | 1771 | echo ' |
| 1690 | 1772 | <form action="', $scripturl, '?action=search2" method="post" accept-charset="', $context['character_set'], '"> |
@@ -1706,8 +1788,9 @@ discard block |
||
| 1706 | 1788 | // If mods want to do somthing with the news, let them do that now. Don't need to pass the news line itself, since it is already in $context. |
| 1707 | 1789 | call_integration_hook('integrate_ssi_news'); |
| 1708 | 1790 | |
| 1709 | - if ($output_method != 'echo') |
|
| 1710 | - return $context['random_news_line']; |
|
| 1791 | + if ($output_method != 'echo') { |
|
| 1792 | + return $context['random_news_line']; |
|
| 1793 | + } |
|
| 1711 | 1794 | |
| 1712 | 1795 | echo $context['random_news_line']; |
| 1713 | 1796 | } |
@@ -1721,8 +1804,9 @@ discard block |
||
| 1721 | 1804 | { |
| 1722 | 1805 | global $scripturl, $modSettings, $user_info; |
| 1723 | 1806 | |
| 1724 | - if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view') || !allowedTo('profile_view')) |
|
| 1725 | - return; |
|
| 1807 | + if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view') || !allowedTo('profile_view')) { |
|
| 1808 | + return; |
|
| 1809 | + } |
|
| 1726 | 1810 | |
| 1727 | 1811 | $eventOptions = array( |
| 1728 | 1812 | 'include_birthdays' => true, |
@@ -1733,13 +1817,15 @@ discard block |
||
| 1733 | 1817 | // The ssi_todaysCalendar variants all use the same hook and just pass on $eventOptions so the hooked code can distinguish different cases if necessary |
| 1734 | 1818 | call_integration_hook('integrate_ssi_calendar', array(&$return, $eventOptions)); |
| 1735 | 1819 | |
| 1736 | - if ($output_method != 'echo') |
|
| 1737 | - return $return['calendar_birthdays']; |
|
| 1820 | + if ($output_method != 'echo') { |
|
| 1821 | + return $return['calendar_birthdays']; |
|
| 1822 | + } |
|
| 1738 | 1823 | |
| 1739 | - foreach ($return['calendar_birthdays'] as $member) |
|
| 1740 | - echo ' |
|
| 1824 | + foreach ($return['calendar_birthdays'] as $member) { |
|
| 1825 | + echo ' |
|
| 1741 | 1826 | <a href="', $scripturl, '?action=profile;u=', $member['id'], '"><span class="fix_rtl_names">' . $member['name'] . '</span>' . (isset($member['age']) ? ' (' . $member['age'] . ')' : '') . '</a>' . (!$member['is_last'] ? ', ' : ''); |
| 1742 | -} |
|
| 1827 | + } |
|
| 1828 | + } |
|
| 1743 | 1829 | |
| 1744 | 1830 | /** |
| 1745 | 1831 | * Shows today's holidays. |
@@ -1750,8 +1836,9 @@ discard block |
||
| 1750 | 1836 | { |
| 1751 | 1837 | global $modSettings, $user_info; |
| 1752 | 1838 | |
| 1753 | - if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) |
|
| 1754 | - return; |
|
| 1839 | + if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) { |
|
| 1840 | + return; |
|
| 1841 | + } |
|
| 1755 | 1842 | |
| 1756 | 1843 | $eventOptions = array( |
| 1757 | 1844 | 'include_holidays' => true, |
@@ -1762,8 +1849,9 @@ discard block |
||
| 1762 | 1849 | // The ssi_todaysCalendar variants all use the same hook and just pass on $eventOptions so the hooked code can distinguish different cases if necessary |
| 1763 | 1850 | call_integration_hook('integrate_ssi_calendar', array(&$return, $eventOptions)); |
| 1764 | 1851 | |
| 1765 | - if ($output_method != 'echo') |
|
| 1766 | - return $return['calendar_holidays']; |
|
| 1852 | + if ($output_method != 'echo') { |
|
| 1853 | + return $return['calendar_holidays']; |
|
| 1854 | + } |
|
| 1767 | 1855 | |
| 1768 | 1856 | echo ' |
| 1769 | 1857 | ', implode(', ', $return['calendar_holidays']); |
@@ -1777,8 +1865,9 @@ discard block |
||
| 1777 | 1865 | { |
| 1778 | 1866 | global $modSettings, $user_info; |
| 1779 | 1867 | |
| 1780 | - if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) |
|
| 1781 | - return; |
|
| 1868 | + if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) { |
|
| 1869 | + return; |
|
| 1870 | + } |
|
| 1782 | 1871 | |
| 1783 | 1872 | $eventOptions = array( |
| 1784 | 1873 | 'include_events' => true, |
@@ -1789,14 +1878,16 @@ discard block |
||
| 1789 | 1878 | // The ssi_todaysCalendar variants all use the same hook and just pass on $eventOptions so the hooked code can distinguish different cases if necessary |
| 1790 | 1879 | call_integration_hook('integrate_ssi_calendar', array(&$return, $eventOptions)); |
| 1791 | 1880 | |
| 1792 | - if ($output_method != 'echo') |
|
| 1793 | - return $return['calendar_events']; |
|
| 1881 | + if ($output_method != 'echo') { |
|
| 1882 | + return $return['calendar_events']; |
|
| 1883 | + } |
|
| 1794 | 1884 | |
| 1795 | 1885 | foreach ($return['calendar_events'] as $event) |
| 1796 | 1886 | { |
| 1797 | - if ($event['can_edit']) |
|
| 1798 | - echo ' |
|
| 1887 | + if ($event['can_edit']) { |
|
| 1888 | + echo ' |
|
| 1799 | 1889 | <a href="' . $event['modify_href'] . '" style="color: #ff0000;">*</a> '; |
| 1890 | + } |
|
| 1800 | 1891 | echo ' |
| 1801 | 1892 | ' . $event['link'] . (!$event['is_last'] ? ', ' : ''); |
| 1802 | 1893 | } |
@@ -1811,8 +1902,9 @@ discard block |
||
| 1811 | 1902 | { |
| 1812 | 1903 | global $modSettings, $txt, $scripturl, $user_info; |
| 1813 | 1904 | |
| 1814 | - if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) |
|
| 1815 | - return; |
|
| 1905 | + if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) { |
|
| 1906 | + return; |
|
| 1907 | + } |
|
| 1816 | 1908 | |
| 1817 | 1909 | $eventOptions = array( |
| 1818 | 1910 | 'include_birthdays' => allowedTo('profile_view'), |
@@ -1825,19 +1917,22 @@ discard block |
||
| 1825 | 1917 | // The ssi_todaysCalendar variants all use the same hook and just pass on $eventOptions so the hooked code can distinguish different cases if necessary |
| 1826 | 1918 | call_integration_hook('integrate_ssi_calendar', array(&$return, $eventOptions)); |
| 1827 | 1919 | |
| 1828 | - if ($output_method != 'echo') |
|
| 1829 | - return $return; |
|
| 1920 | + if ($output_method != 'echo') { |
|
| 1921 | + return $return; |
|
| 1922 | + } |
|
| 1830 | 1923 | |
| 1831 | - if (!empty($return['calendar_holidays'])) |
|
| 1832 | - echo ' |
|
| 1924 | + if (!empty($return['calendar_holidays'])) { |
|
| 1925 | + echo ' |
|
| 1833 | 1926 | <span class="holiday">' . $txt['calendar_prompt'] . ' ' . implode(', ', $return['calendar_holidays']) . '<br></span>'; |
| 1927 | + } |
|
| 1834 | 1928 | if (!empty($return['calendar_birthdays'])) |
| 1835 | 1929 | { |
| 1836 | 1930 | echo ' |
| 1837 | 1931 | <span class="birthday">' . $txt['birthdays_upcoming'] . '</span> '; |
| 1838 | - foreach ($return['calendar_birthdays'] as $member) |
|
| 1839 | - echo ' |
|
| 1932 | + foreach ($return['calendar_birthdays'] as $member) { |
|
| 1933 | + echo ' |
|
| 1840 | 1934 | <a href="', $scripturl, '?action=profile;u=', $member['id'], '"><span class="fix_rtl_names">', $member['name'], '</span>', isset($member['age']) ? ' (' . $member['age'] . ')' : '', '</a>', !$member['is_last'] ? ', ' : ''; |
| 1935 | + } |
|
| 1841 | 1936 | echo ' |
| 1842 | 1937 | <br>'; |
| 1843 | 1938 | } |
@@ -1847,9 +1942,10 @@ discard block |
||
| 1847 | 1942 | <span class="event">' . $txt['events_upcoming'] . '</span> '; |
| 1848 | 1943 | foreach ($return['calendar_events'] as $event) |
| 1849 | 1944 | { |
| 1850 | - if ($event['can_edit']) |
|
| 1851 | - echo ' |
|
| 1945 | + if ($event['can_edit']) { |
|
| 1946 | + echo ' |
|
| 1852 | 1947 | <a href="' . $event['modify_href'] . '" style="color: #ff0000;">*</a> '; |
| 1948 | + } |
|
| 1853 | 1949 | echo ' |
| 1854 | 1950 | ' . $event['link'] . (!$event['is_last'] ? ', ' : ''); |
| 1855 | 1951 | } |
@@ -1873,25 +1969,29 @@ discard block |
||
| 1873 | 1969 | loadLanguage('Stats'); |
| 1874 | 1970 | |
| 1875 | 1971 | // Must be integers.... |
| 1876 | - if ($limit === null) |
|
| 1877 | - $limit = isset($_GET['limit']) ? (int) $_GET['limit'] : 5; |
|
| 1878 | - else |
|
| 1879 | - $limit = (int) $limit; |
|
| 1880 | - |
|
| 1881 | - if ($start === null) |
|
| 1882 | - $start = isset($_GET['start']) ? (int) $_GET['start'] : 0; |
|
| 1883 | - else |
|
| 1884 | - $start = (int) $start; |
|
| 1885 | - |
|
| 1886 | - if ($board !== null) |
|
| 1887 | - $board = (int) $board; |
|
| 1888 | - elseif (isset($_GET['board'])) |
|
| 1889 | - $board = (int) $_GET['board']; |
|
| 1890 | - |
|
| 1891 | - if ($length === null) |
|
| 1892 | - $length = isset($_GET['length']) ? (int) $_GET['length'] : 0; |
|
| 1893 | - else |
|
| 1894 | - $length = (int) $length; |
|
| 1972 | + if ($limit === null) { |
|
| 1973 | + $limit = isset($_GET['limit']) ? (int) $_GET['limit'] : 5; |
|
| 1974 | + } else { |
|
| 1975 | + $limit = (int) $limit; |
|
| 1976 | + } |
|
| 1977 | + |
|
| 1978 | + if ($start === null) { |
|
| 1979 | + $start = isset($_GET['start']) ? (int) $_GET['start'] : 0; |
|
| 1980 | + } else { |
|
| 1981 | + $start = (int) $start; |
|
| 1982 | + } |
|
| 1983 | + |
|
| 1984 | + if ($board !== null) { |
|
| 1985 | + $board = (int) $board; |
|
| 1986 | + } elseif (isset($_GET['board'])) { |
|
| 1987 | + $board = (int) $_GET['board']; |
|
| 1988 | + } |
|
| 1989 | + |
|
| 1990 | + if ($length === null) { |
|
| 1991 | + $length = isset($_GET['length']) ? (int) $_GET['length'] : 0; |
|
| 1992 | + } else { |
|
| 1993 | + $length = (int) $length; |
|
| 1994 | + } |
|
| 1895 | 1995 | |
| 1896 | 1996 | $limit = max(0, $limit); |
| 1897 | 1997 | $start = max(0, $start); |
@@ -1909,17 +2009,19 @@ discard block |
||
| 1909 | 2009 | ); |
| 1910 | 2010 | if ($smcFunc['db_num_rows']($request) == 0) |
| 1911 | 2011 | { |
| 1912 | - if ($output_method == 'echo') |
|
| 1913 | - die($txt['ssi_no_guests']); |
|
| 1914 | - else |
|
| 1915 | - return array(); |
|
| 2012 | + if ($output_method == 'echo') { |
|
| 2013 | + die($txt['ssi_no_guests']); |
|
| 2014 | + } else { |
|
| 2015 | + return array(); |
|
| 2016 | + } |
|
| 1916 | 2017 | } |
| 1917 | 2018 | list ($board) = $smcFunc['db_fetch_row']($request); |
| 1918 | 2019 | $smcFunc['db_free_result']($request); |
| 1919 | 2020 | |
| 1920 | 2021 | $icon_sources = array(); |
| 1921 | - foreach ($context['stable_icons'] as $icon) |
|
| 1922 | - $icon_sources[$icon] = 'images_url'; |
|
| 2022 | + foreach ($context['stable_icons'] as $icon) { |
|
| 2023 | + $icon_sources[$icon] = 'images_url'; |
|
| 2024 | + } |
|
| 1923 | 2025 | |
| 1924 | 2026 | if (!empty($modSettings['enable_likes'])) |
| 1925 | 2027 | { |
@@ -1942,12 +2044,14 @@ discard block |
||
| 1942 | 2044 | ) |
| 1943 | 2045 | ); |
| 1944 | 2046 | $posts = array(); |
| 1945 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1946 | - $posts[] = $row['id_first_msg']; |
|
| 2047 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2048 | + $posts[] = $row['id_first_msg']; |
|
| 2049 | + } |
|
| 1947 | 2050 | $smcFunc['db_free_result']($request); |
| 1948 | 2051 | |
| 1949 | - if (empty($posts)) |
|
| 1950 | - return array(); |
|
| 2052 | + if (empty($posts)) { |
|
| 2053 | + return array(); |
|
| 2054 | + } |
|
| 1951 | 2055 | |
| 1952 | 2056 | // Find the posts. |
| 1953 | 2057 | $request = $smcFunc['db_query']('', ' |
@@ -1977,24 +2081,28 @@ discard block |
||
| 1977 | 2081 | $last_space = strrpos($row['body'], ' '); |
| 1978 | 2082 | $last_open = strrpos($row['body'], '<'); |
| 1979 | 2083 | $last_close = strrpos($row['body'], '>'); |
| 1980 | - if (empty($last_space) || ($last_space == $last_open + 3 && (empty($last_close) || (!empty($last_close) && $last_close < $last_open))) || $last_space < $last_open || $last_open == $length - 6) |
|
| 1981 | - $cutoff = $last_open; |
|
| 1982 | - elseif (empty($last_close) || $last_close < $last_open) |
|
| 1983 | - $cutoff = $last_space; |
|
| 2084 | + if (empty($last_space) || ($last_space == $last_open + 3 && (empty($last_close) || (!empty($last_close) && $last_close < $last_open))) || $last_space < $last_open || $last_open == $length - 6) { |
|
| 2085 | + $cutoff = $last_open; |
|
| 2086 | + } elseif (empty($last_close) || $last_close < $last_open) { |
|
| 2087 | + $cutoff = $last_space; |
|
| 2088 | + } |
|
| 1984 | 2089 | |
| 1985 | - if ($cutoff !== false) |
|
| 1986 | - $row['body'] = $smcFunc['substr']($row['body'], 0, $cutoff); |
|
| 2090 | + if ($cutoff !== false) { |
|
| 2091 | + $row['body'] = $smcFunc['substr']($row['body'], 0, $cutoff); |
|
| 2092 | + } |
|
| 1987 | 2093 | $row['body'] .= '...'; |
| 1988 | 2094 | } |
| 1989 | 2095 | |
| 1990 | 2096 | $row['body'] = parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']); |
| 1991 | 2097 | |
| 1992 | - if (!empty($recycle_board) && $row['id_board'] == $recycle_board) |
|
| 1993 | - $row['icon'] = 'recycled'; |
|
| 2098 | + if (!empty($recycle_board) && $row['id_board'] == $recycle_board) { |
|
| 2099 | + $row['icon'] = 'recycled'; |
|
| 2100 | + } |
|
| 1994 | 2101 | |
| 1995 | 2102 | // Check that this message icon is there... |
| 1996 | - if (!empty($modSettings['messageIconChecks_enable']) && !isset($icon_sources[$row['icon']])) |
|
| 1997 | - $icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
| 2103 | + if (!empty($modSettings['messageIconChecks_enable']) && !isset($icon_sources[$row['icon']])) { |
|
| 2104 | + $icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
| 2105 | + } |
|
| 1998 | 2106 | |
| 1999 | 2107 | censorText($row['subject']); |
| 2000 | 2108 | censorText($row['body']); |
@@ -2031,16 +2139,18 @@ discard block |
||
| 2031 | 2139 | } |
| 2032 | 2140 | $smcFunc['db_free_result']($request); |
| 2033 | 2141 | |
| 2034 | - if (empty($return)) |
|
| 2035 | - return $return; |
|
| 2142 | + if (empty($return)) { |
|
| 2143 | + return $return; |
|
| 2144 | + } |
|
| 2036 | 2145 | |
| 2037 | 2146 | $return[count($return) - 1]['is_last'] = true; |
| 2038 | 2147 | |
| 2039 | 2148 | // If mods want to do somthing with this list of posts, let them do that now. |
| 2040 | 2149 | call_integration_hook('integrate_ssi_boardNews', array(&$return)); |
| 2041 | 2150 | |
| 2042 | - if ($output_method != 'echo') |
|
| 2043 | - return $return; |
|
| 2151 | + if ($output_method != 'echo') { |
|
| 2152 | + return $return; |
|
| 2153 | + } |
|
| 2044 | 2154 | |
| 2045 | 2155 | foreach ($return as $news) |
| 2046 | 2156 | { |
@@ -2092,9 +2202,10 @@ discard block |
||
| 2092 | 2202 | echo ' |
| 2093 | 2203 | </div>'; |
| 2094 | 2204 | |
| 2095 | - if (!$news['is_last']) |
|
| 2096 | - echo ' |
|
| 2205 | + if (!$news['is_last']) { |
|
| 2206 | + echo ' |
|
| 2097 | 2207 | <hr>'; |
| 2208 | + } |
|
| 2098 | 2209 | } |
| 2099 | 2210 | } |
| 2100 | 2211 | |
@@ -2108,8 +2219,9 @@ discard block |
||
| 2108 | 2219 | { |
| 2109 | 2220 | global $user_info, $scripturl, $modSettings, $txt, $context, $smcFunc; |
| 2110 | 2221 | |
| 2111 | - if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) |
|
| 2112 | - return; |
|
| 2222 | + if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) { |
|
| 2223 | + return; |
|
| 2224 | + } |
|
| 2113 | 2225 | |
| 2114 | 2226 | // Find all events which are happening in the near future that the member can see. |
| 2115 | 2227 | $request = $smcFunc['db_query']('', ' |
@@ -2135,20 +2247,23 @@ discard block |
||
| 2135 | 2247 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 2136 | 2248 | { |
| 2137 | 2249 | // Check if we've already come by an event linked to this same topic with the same title... and don't display it if we have. |
| 2138 | - if (!empty($duplicates[$row['title'] . $row['id_topic']])) |
|
| 2139 | - continue; |
|
| 2250 | + if (!empty($duplicates[$row['title'] . $row['id_topic']])) { |
|
| 2251 | + continue; |
|
| 2252 | + } |
|
| 2140 | 2253 | |
| 2141 | 2254 | // Censor the title. |
| 2142 | 2255 | censorText($row['title']); |
| 2143 | 2256 | |
| 2144 | - if ($row['start_date'] < strftime('%Y-%m-%d', forum_time(false))) |
|
| 2145 | - $date = strftime('%Y-%m-%d', forum_time(false)); |
|
| 2146 | - else |
|
| 2147 | - $date = $row['start_date']; |
|
| 2257 | + if ($row['start_date'] < strftime('%Y-%m-%d', forum_time(false))) { |
|
| 2258 | + $date = strftime('%Y-%m-%d', forum_time(false)); |
|
| 2259 | + } else { |
|
| 2260 | + $date = $row['start_date']; |
|
| 2261 | + } |
|
| 2148 | 2262 | |
| 2149 | 2263 | // If the topic it is attached to is not approved then don't link it. |
| 2150 | - if (!empty($row['id_first_msg']) && !$row['approved']) |
|
| 2151 | - $row['id_board'] = $row['id_topic'] = $row['id_first_msg'] = 0; |
|
| 2264 | + if (!empty($row['id_first_msg']) && !$row['approved']) { |
|
| 2265 | + $row['id_board'] = $row['id_topic'] = $row['id_first_msg'] = 0; |
|
| 2266 | + } |
|
| 2152 | 2267 | |
| 2153 | 2268 | $allday = (empty($row['start_time']) || empty($row['end_time']) || empty($row['timezone']) || !in_array($row['timezone'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) ? true : false; |
| 2154 | 2269 | |
@@ -2174,24 +2289,27 @@ discard block |
||
| 2174 | 2289 | } |
| 2175 | 2290 | $smcFunc['db_free_result']($request); |
| 2176 | 2291 | |
| 2177 | - foreach ($return as $mday => $array) |
|
| 2178 | - $return[$mday][count($array) - 1]['is_last'] = true; |
|
| 2292 | + foreach ($return as $mday => $array) { |
|
| 2293 | + $return[$mday][count($array) - 1]['is_last'] = true; |
|
| 2294 | + } |
|
| 2179 | 2295 | |
| 2180 | 2296 | // If mods want to do somthing with this list of events, let them do that now. |
| 2181 | 2297 | call_integration_hook('integrate_ssi_recentEvents', array(&$return)); |
| 2182 | 2298 | |
| 2183 | - if ($output_method != 'echo' || empty($return)) |
|
| 2184 | - return $return; |
|
| 2299 | + if ($output_method != 'echo' || empty($return)) { |
|
| 2300 | + return $return; |
|
| 2301 | + } |
|
| 2185 | 2302 | |
| 2186 | 2303 | // Well the output method is echo. |
| 2187 | 2304 | echo ' |
| 2188 | 2305 | <span class="event">' . $txt['events'] . '</span> '; |
| 2189 | - foreach ($return as $mday => $array) |
|
| 2190 | - foreach ($array as $event) |
|
| 2306 | + foreach ($return as $mday => $array) { |
|
| 2307 | + foreach ($array as $event) |
|
| 2191 | 2308 | { |
| 2192 | 2309 | if ($event['can_edit']) |
| 2193 | 2310 | echo ' |
| 2194 | 2311 | <a href="' . $event['modify_href'] . '" style="color: #ff0000;">*</a> '; |
| 2312 | + } |
|
| 2195 | 2313 | |
| 2196 | 2314 | echo ' |
| 2197 | 2315 | ' . $event['link'] . (!$event['is_last'] ? ', ' : ''); |
@@ -2210,8 +2328,9 @@ discard block |
||
| 2210 | 2328 | global $smcFunc; |
| 2211 | 2329 | |
| 2212 | 2330 | // If $id is null, this was most likely called from a query string and should do nothing. |
| 2213 | - if ($id === null) |
|
| 2214 | - return; |
|
| 2331 | + if ($id === null) { |
|
| 2332 | + return; |
|
| 2333 | + } |
|
| 2215 | 2334 | |
| 2216 | 2335 | $request = $smcFunc['db_query']('', ' |
| 2217 | 2336 | SELECT passwd, member_name, is_activated |
@@ -2243,8 +2362,9 @@ discard block |
||
| 2243 | 2362 | $attachments_boards = boardsAllowedTo('view_attachments'); |
| 2244 | 2363 | |
| 2245 | 2364 | // No boards? Adios amigo. |
| 2246 | - if (empty($attachments_boards)) |
|
| 2247 | - return array(); |
|
| 2365 | + if (empty($attachments_boards)) { |
|
| 2366 | + return array(); |
|
| 2367 | + } |
|
| 2248 | 2368 | |
| 2249 | 2369 | // Is it an array? |
| 2250 | 2370 | $attachment_ext = (array) $attachment_ext; |
@@ -2328,8 +2448,9 @@ discard block |
||
| 2328 | 2448 | call_integration_hook('integrate_ssi_recentAttachments', array(&$attachments)); |
| 2329 | 2449 | |
| 2330 | 2450 | // So you just want an array? Here you can have it. |
| 2331 | - if ($output_method == 'array' || empty($attachments)) |
|
| 2332 | - return $attachments; |
|
| 2451 | + if ($output_method == 'array' || empty($attachments)) { |
|
| 2452 | + return $attachments; |
|
| 2453 | + } |
|
| 2333 | 2454 | |
| 2334 | 2455 | // Give them the default. |
| 2335 | 2456 | echo ' |
@@ -2340,14 +2461,15 @@ discard block |
||
| 2340 | 2461 | <th style="text-align: left; padding: 2">', $txt['downloads'], '</th> |
| 2341 | 2462 | <th style="text-align: left; padding: 2">', $txt['filesize'], '</th> |
| 2342 | 2463 | </tr>'; |
| 2343 | - foreach ($attachments as $attach) |
|
| 2344 | - echo ' |
|
| 2464 | + foreach ($attachments as $attach) { |
|
| 2465 | + echo ' |
|
| 2345 | 2466 | <tr> |
| 2346 | 2467 | <td>', $attach['file']['link'], '</td> |
| 2347 | 2468 | <td>', $attach['member']['link'], '</td> |
| 2348 | 2469 | <td style="text-align: center">', $attach['file']['downloads'], '</td> |
| 2349 | 2470 | <td>', $attach['file']['filesize'], '</td> |
| 2350 | 2471 | </tr>'; |
| 2472 | + } |
|
| 2351 | 2473 | echo ' |
| 2352 | 2474 | </table>'; |
| 2353 | 2475 | } |
@@ -15,8 +15,9 @@ discard block |
||
| 15 | 15 | * @version 2.1 Beta 4 |
| 16 | 16 | */ |
| 17 | 17 | |
| 18 | -if (!defined('SMF')) |
|
| 18 | +if (!defined('SMF')) { |
|
| 19 | 19 | die('No direct access...'); |
| 20 | +} |
|
| 20 | 21 | |
| 21 | 22 | /** |
| 22 | 23 | * Log an error, if the error logging is enabled. |
@@ -41,17 +42,19 @@ discard block |
||
| 41 | 42 | // are we in a loop? |
| 42 | 43 | if($error_call > 2) |
| 43 | 44 | { |
| 44 | - if (!isset($db_show_debug) || $db_show_debug === false) |
|
| 45 | - $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); |
|
| 46 | - else |
|
| 47 | - $backtrace = debug_backtrace(); |
|
| 45 | + if (!isset($db_show_debug) || $db_show_debug === false) { |
|
| 46 | + $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); |
|
| 47 | + } else { |
|
| 48 | + $backtrace = debug_backtrace(); |
|
| 49 | + } |
|
| 48 | 50 | var_dump($backtrace); |
| 49 | 51 | die('Error loop.'); |
| 50 | 52 | } |
| 51 | 53 | |
| 52 | 54 | // Check if error logging is actually on. |
| 53 | - if (empty($modSettings['enableErrorLogging'])) |
|
| 54 | - return $error_message; |
|
| 55 | + if (empty($modSettings['enableErrorLogging'])) { |
|
| 56 | + return $error_message; |
|
| 57 | + } |
|
| 55 | 58 | |
| 56 | 59 | // Basically, htmlspecialchars it minus &. (for entities!) |
| 57 | 60 | $error_message = strtr($error_message, array('<' => '<', '>' => '>', '"' => '"')); |
@@ -59,33 +62,39 @@ discard block |
||
| 59 | 62 | |
| 60 | 63 | // Add a file and line to the error message? |
| 61 | 64 | // Don't use the actual txt entries for file and line but instead use %1$s for file and %2$s for line |
| 62 | - if ($file == null) |
|
| 63 | - $file = ''; |
|
| 64 | - else |
|
| 65 | - // Window style slashes don't play well, lets convert them to the unix style. |
|
| 65 | + if ($file == null) { |
|
| 66 | + $file = ''; |
|
| 67 | + } else { |
|
| 68 | + // Window style slashes don't play well, lets convert them to the unix style. |
|
| 66 | 69 | $file = str_replace('\\', '/', $file); |
| 70 | + } |
|
| 67 | 71 | |
| 68 | - if ($line == null) |
|
| 69 | - $line = 0; |
|
| 70 | - else |
|
| 71 | - $line = (int) $line; |
|
| 72 | + if ($line == null) { |
|
| 73 | + $line = 0; |
|
| 74 | + } else { |
|
| 75 | + $line = (int) $line; |
|
| 76 | + } |
|
| 72 | 77 | |
| 73 | 78 | // Just in case there's no id_member or IP set yet. |
| 74 | - if (empty($user_info['id'])) |
|
| 75 | - $user_info['id'] = 0; |
|
| 76 | - if (empty($user_info['ip'])) |
|
| 77 | - $user_info['ip'] = ''; |
|
| 79 | + if (empty($user_info['id'])) { |
|
| 80 | + $user_info['id'] = 0; |
|
| 81 | + } |
|
| 82 | + if (empty($user_info['ip'])) { |
|
| 83 | + $user_info['ip'] = ''; |
|
| 84 | + } |
|
| 78 | 85 | |
| 79 | 86 | // Find the best query string we can... |
| 80 | 87 | $query_string = empty($_SERVER['QUERY_STRING']) ? (empty($_SERVER['REQUEST_URL']) ? '' : str_replace($scripturl, '', $_SERVER['REQUEST_URL'])) : $_SERVER['QUERY_STRING']; |
| 81 | 88 | |
| 82 | 89 | // Don't log the session hash in the url twice, it's a waste. |
| 83 | - if (!empty($smcFunc['htmlspecialchars'])) |
|
| 84 | - $query_string = $smcFunc['htmlspecialchars']((SMF == 'SSI' || SMF == 'BACKGROUND' ? '' : '?') . preg_replace(array('~;sesc=[^&;]+~', '~' . session_name() . '=' . session_id() . '[&;]~'), array(';sesc', ''), $query_string)); |
|
| 90 | + if (!empty($smcFunc['htmlspecialchars'])) { |
|
| 91 | + $query_string = $smcFunc['htmlspecialchars']((SMF == 'SSI' || SMF == 'BACKGROUND' ? '' : '?') . preg_replace(array('~;sesc=[^&;]+~', '~' . session_name() . '=' . session_id() . '[&;]~'), array(';sesc', ''), $query_string)); |
|
| 92 | + } |
|
| 85 | 93 | |
| 86 | 94 | // Just so we know what board error messages are from. |
| 87 | - if (isset($_POST['board']) && !isset($_GET['board'])) |
|
| 88 | - $query_string .= ($query_string == '' ? 'board=' : ';board=') . $_POST['board']; |
|
| 95 | + if (isset($_POST['board']) && !isset($_GET['board'])) { |
|
| 96 | + $query_string .= ($query_string == '' ? 'board=' : ';board=') . $_POST['board']; |
|
| 97 | + } |
|
| 89 | 98 | |
| 90 | 99 | // What types of categories do we have? |
| 91 | 100 | $known_error_types = array( |
@@ -146,12 +155,14 @@ discard block |
||
| 146 | 155 | global $txt; |
| 147 | 156 | |
| 148 | 157 | // Send the appropriate HTTP status header - set this to 0 or false if you don't want to send one at all |
| 149 | - if (!empty($status)) |
|
| 150 | - send_http_status($status); |
|
| 158 | + if (!empty($status)) { |
|
| 159 | + send_http_status($status); |
|
| 160 | + } |
|
| 151 | 161 | |
| 152 | 162 | // We don't have $txt yet, but that's okay... |
| 153 | - if (empty($txt)) |
|
| 154 | - die($error); |
|
| 163 | + if (empty($txt)) { |
|
| 164 | + die($error); |
|
| 165 | + } |
|
| 155 | 166 | |
| 156 | 167 | log_error_online($error, false); |
| 157 | 168 | setup_fatal_error_context($log ? log_error($error, $log) : $error); |
@@ -178,8 +189,9 @@ discard block |
||
| 178 | 189 | static $fatal_error_called = false; |
| 179 | 190 | |
| 180 | 191 | // Send the status header - set this to 0 or false if you don't want to send one at all |
| 181 | - if (!empty($status)) |
|
| 182 | - send_http_status($status); |
|
| 192 | + if (!empty($status)) { |
|
| 193 | + send_http_status($status); |
|
| 194 | + } |
|
| 183 | 195 | |
| 184 | 196 | // Try to load a theme if we don't have one. |
| 185 | 197 | if (empty($context['theme_loaded']) && empty($fatal_error_called)) |
@@ -189,8 +201,9 @@ discard block |
||
| 189 | 201 | } |
| 190 | 202 | |
| 191 | 203 | // If we have no theme stuff we can't have the language file... |
| 192 | - if (empty($context['theme_loaded'])) |
|
| 193 | - die($error); |
|
| 204 | + if (empty($context['theme_loaded'])) { |
|
| 205 | + die($error); |
|
| 206 | + } |
|
| 194 | 207 | |
| 195 | 208 | $reload_lang_file = true; |
| 196 | 209 | // Log the error in the forum's language, but don't waste the time if we aren't logging |
@@ -226,8 +239,9 @@ discard block |
||
| 226 | 239 | global $settings, $modSettings, $db_show_debug; |
| 227 | 240 | |
| 228 | 241 | // Ignore errors if we're ignoring them or they are strict notices from PHP 5 |
| 229 | - if (error_reporting() == 0) |
|
| 230 | - return; |
|
| 242 | + if (error_reporting() == 0) { |
|
| 243 | + return; |
|
| 244 | + } |
|
| 231 | 245 | |
| 232 | 246 | if (strpos($file, 'eval()') !== false && !empty($settings['current_include_filename'])) |
| 233 | 247 | { |
@@ -235,19 +249,22 @@ discard block |
||
| 235 | 249 | $count = count($array); |
| 236 | 250 | for ($i = 0; $i < $count; $i++) |
| 237 | 251 | { |
| 238 | - if ($array[$i]['function'] != 'loadSubTemplate') |
|
| 239 | - continue; |
|
| 252 | + if ($array[$i]['function'] != 'loadSubTemplate') { |
|
| 253 | + continue; |
|
| 254 | + } |
|
| 240 | 255 | |
| 241 | 256 | // This is a bug in PHP, with eval, it seems! |
| 242 | - if (empty($array[$i]['args'])) |
|
| 243 | - $i++; |
|
| 257 | + if (empty($array[$i]['args'])) { |
|
| 258 | + $i++; |
|
| 259 | + } |
|
| 244 | 260 | break; |
| 245 | 261 | } |
| 246 | 262 | |
| 247 | - if (isset($array[$i]) && !empty($array[$i]['args'])) |
|
| 248 | - $file = realpath($settings['current_include_filename']) . ' (' . $array[$i]['args'][0] . ' sub template - eval?)'; |
|
| 249 | - else |
|
| 250 | - $file = realpath($settings['current_include_filename']) . ' (eval?)'; |
|
| 263 | + if (isset($array[$i]) && !empty($array[$i]['args'])) { |
|
| 264 | + $file = realpath($settings['current_include_filename']) . ' (' . $array[$i]['args'][0] . ' sub template - eval?)'; |
|
| 265 | + } else { |
|
| 266 | + $file = realpath($settings['current_include_filename']) . ' (eval?)'; |
|
| 267 | + } |
|
| 251 | 268 | } |
| 252 | 269 | |
| 253 | 270 | if (isset($db_show_debug) && $db_show_debug === true) |
@@ -256,8 +273,9 @@ discard block |
||
| 256 | 273 | if ($error_level % 255 != E_ERROR) |
| 257 | 274 | { |
| 258 | 275 | $temporary = ob_get_contents(); |
| 259 | - if (substr($temporary, -2) == '="') |
|
| 260 | - echo '"'; |
|
| 276 | + if (substr($temporary, -2) == '="') { |
|
| 277 | + echo '"'; |
|
| 278 | + } |
|
| 261 | 279 | } |
| 262 | 280 | |
| 263 | 281 | // Debugging! This should look like a PHP error message. |
@@ -273,23 +291,27 @@ discard block |
||
| 273 | 291 | call_integration_hook('integrate_output_error', array($message, $error_type, $error_level, $file, $line)); |
| 274 | 292 | |
| 275 | 293 | // Dying on these errors only causes MORE problems (blank pages!) |
| 276 | - if ($file == 'Unknown') |
|
| 277 | - return; |
|
| 294 | + if ($file == 'Unknown') { |
|
| 295 | + return; |
|
| 296 | + } |
|
| 278 | 297 | |
| 279 | 298 | // If this is an E_ERROR or E_USER_ERROR.... die. Violently so. |
| 280 | - if ($error_level % 255 == E_ERROR) |
|
| 281 | - obExit(false); |
|
| 282 | - else |
|
| 283 | - return; |
|
| 299 | + if ($error_level % 255 == E_ERROR) { |
|
| 300 | + obExit(false); |
|
| 301 | + } else { |
|
| 302 | + return; |
|
| 303 | + } |
|
| 284 | 304 | |
| 285 | 305 | // If this is an E_ERROR, E_USER_ERROR, E_WARNING, or E_USER_WARNING.... die. Violently so. |
| 286 | - if ($error_level % 255 == E_ERROR || $error_level % 255 == E_WARNING) |
|
| 287 | - fatal_error(allowedTo('admin_forum') ? $message : $error_string, false); |
|
| 306 | + if ($error_level % 255 == E_ERROR || $error_level % 255 == E_WARNING) { |
|
| 307 | + fatal_error(allowedTo('admin_forum') ? $message : $error_string, false); |
|
| 308 | + } |
|
| 288 | 309 | |
| 289 | 310 | // We should NEVER get to this point. Any fatal error MUST quit, or very bad things can happen. |
| 290 | - if ($error_level % 255 == E_ERROR) |
|
| 291 | - die('No direct access...'); |
|
| 292 | -} |
|
| 311 | + if ($error_level % 255 == E_ERROR) { |
|
| 312 | + die('No direct access...'); |
|
| 313 | + } |
|
| 314 | + } |
|
| 293 | 315 | |
| 294 | 316 | /** |
| 295 | 317 | * It is called by {@link fatal_error()} and {@link fatal_lang_error()}. |
@@ -305,24 +327,28 @@ discard block |
||
| 305 | 327 | |
| 306 | 328 | // Attempt to prevent a recursive loop. |
| 307 | 329 | ++$level; |
| 308 | - if ($level > 1) |
|
| 309 | - return false; |
|
| 330 | + if ($level > 1) { |
|
| 331 | + return false; |
|
| 332 | + } |
|
| 310 | 333 | |
| 311 | 334 | // Maybe they came from dlattach or similar? |
| 312 | - if (SMF != 'SSI' && SMF != 'BACKGROUND' && empty($context['theme_loaded'])) |
|
| 313 | - loadTheme(); |
|
| 335 | + if (SMF != 'SSI' && SMF != 'BACKGROUND' && empty($context['theme_loaded'])) { |
|
| 336 | + loadTheme(); |
|
| 337 | + } |
|
| 314 | 338 | |
| 315 | 339 | // Don't bother indexing errors mate... |
| 316 | 340 | $context['robot_no_index'] = true; |
| 317 | 341 | |
| 318 | - if (!isset($context['error_title'])) |
|
| 319 | - $context['error_title'] = $txt['error_occured']; |
|
| 342 | + if (!isset($context['error_title'])) { |
|
| 343 | + $context['error_title'] = $txt['error_occured']; |
|
| 344 | + } |
|
| 320 | 345 | $context['error_message'] = isset($context['error_message']) ? $context['error_message'] : $error_message; |
| 321 | 346 | |
| 322 | 347 | $context['error_code'] = isset($error_code) ? 'id="' . $error_code . '" ' : ''; |
| 323 | 348 | |
| 324 | - if (empty($context['page_title'])) |
|
| 325 | - $context['page_title'] = $context['error_title']; |
|
| 349 | + if (empty($context['page_title'])) { |
|
| 350 | + $context['page_title'] = $context['error_title']; |
|
| 351 | + } |
|
| 326 | 352 | |
| 327 | 353 | loadTemplate('Errors'); |
| 328 | 354 | $context['sub_template'] = 'fatal_error'; |
@@ -330,23 +356,26 @@ discard block |
||
| 330 | 356 | // If this is SSI, what do they want us to do? |
| 331 | 357 | if (SMF == 'SSI') |
| 332 | 358 | { |
| 333 | - if (!empty($ssi_on_error_method) && $ssi_on_error_method !== true && is_callable($ssi_on_error_method)) |
|
| 334 | - $ssi_on_error_method(); |
|
| 335 | - elseif (empty($ssi_on_error_method) || $ssi_on_error_method !== true) |
|
| 336 | - loadSubTemplate('fatal_error'); |
|
| 359 | + if (!empty($ssi_on_error_method) && $ssi_on_error_method !== true && is_callable($ssi_on_error_method)) { |
|
| 360 | + $ssi_on_error_method(); |
|
| 361 | + } elseif (empty($ssi_on_error_method) || $ssi_on_error_method !== true) { |
|
| 362 | + loadSubTemplate('fatal_error'); |
|
| 363 | + } |
|
| 337 | 364 | |
| 338 | 365 | // No layers? |
| 339 | - if (empty($ssi_on_error_method) || $ssi_on_error_method !== true) |
|
| 340 | - exit; |
|
| 366 | + if (empty($ssi_on_error_method) || $ssi_on_error_method !== true) { |
|
| 367 | + exit; |
|
| 368 | + } |
|
| 341 | 369 | } |
| 342 | 370 | // Alternatively from the cron call? |
| 343 | 371 | elseif (SMF == 'BACKGROUND') |
| 344 | 372 | { |
| 345 | 373 | // We can't rely on even having language files available. |
| 346 | - if (defined('FROM_CLI') && FROM_CLI) |
|
| 347 | - echo 'cron error: ', $context['error_message']; |
|
| 348 | - else |
|
| 349 | - echo 'An error occurred. More information may be available in your logs.'; |
|
| 374 | + if (defined('FROM_CLI') && FROM_CLI) { |
|
| 375 | + echo 'cron error: ', $context['error_message']; |
|
| 376 | + } else { |
|
| 377 | + echo 'An error occurred. More information may be available in your logs.'; |
|
| 378 | + } |
|
| 350 | 379 | exit; |
| 351 | 380 | } |
| 352 | 381 | |
@@ -374,8 +403,8 @@ discard block |
||
| 374 | 403 | |
| 375 | 404 | set_fatal_error_headers(); |
| 376 | 405 | |
| 377 | - if (!empty($maintenance)) |
|
| 378 | - echo '<!DOCTYPE html> |
|
| 406 | + if (!empty($maintenance)) { |
|
| 407 | + echo '<!DOCTYPE html> |
|
| 379 | 408 | <html> |
| 380 | 409 | <head> |
| 381 | 410 | <meta name="robots" content="noindex"> |
@@ -386,6 +415,7 @@ discard block |
||
| 386 | 415 | ', $mmessage, ' |
| 387 | 416 | </body> |
| 388 | 417 | </html>'; |
| 418 | + } |
|
| 389 | 419 | |
| 390 | 420 | die(); |
| 391 | 421 | } |
@@ -407,15 +437,17 @@ discard block |
||
| 407 | 437 | // For our purposes, we're gonna want this on if at all possible. |
| 408 | 438 | $modSettings['cache_enable'] = '1'; |
| 409 | 439 | |
| 410 | - if (($temp = cache_get_data('db_last_error', 600)) !== null) |
|
| 411 | - $db_last_error = max($db_last_error, $temp); |
|
| 440 | + if (($temp = cache_get_data('db_last_error', 600)) !== null) { |
|
| 441 | + $db_last_error = max($db_last_error, $temp); |
|
| 442 | + } |
|
| 412 | 443 | |
| 413 | 444 | if ($db_last_error < time() - 3600 * 24 * 3 && empty($maintenance) && !empty($db_error_send)) |
| 414 | 445 | { |
| 415 | 446 | // Avoid writing to the Settings.php file if at all possible; use shared memory instead. |
| 416 | 447 | cache_put_data('db_last_error', time(), 600); |
| 417 | - if (($temp = cache_get_data('db_last_error', 600)) === null) |
|
| 418 | - logLastDatabaseError(); |
|
| 448 | + if (($temp = cache_get_data('db_last_error', 600)) === null) { |
|
| 449 | + logLastDatabaseError(); |
|
| 450 | + } |
|
| 419 | 451 | |
| 420 | 452 | // Language files aren't loaded yet :(. |
| 421 | 453 | $db_error = @$smcFunc['db_error']($db_connection); |
@@ -496,12 +528,14 @@ discard block |
||
| 496 | 528 | global $smcFunc, $user_info, $modSettings; |
| 497 | 529 | |
| 498 | 530 | // Don't bother if Who's Online is disabled. |
| 499 | - if (empty($modSettings['who_enabled'])) |
|
| 500 | - return; |
|
| 531 | + if (empty($modSettings['who_enabled'])) { |
|
| 532 | + return; |
|
| 533 | + } |
|
| 501 | 534 | |
| 502 | 535 | // Maybe they came from SSI or similar where sessions are not recorded? |
| 503 | - if (SMF == 'SSI' || SMF == 'BACKGROUND') |
|
| 504 | - return; |
|
| 536 | + if (SMF == 'SSI' || SMF == 'BACKGROUND') { |
|
| 537 | + return; |
|
| 538 | + } |
|
| 505 | 539 | |
| 506 | 540 | $session_id = !empty($user_info['is_guest']) ? 'ip' . $user_info['ip'] : session_id(); |
| 507 | 541 | |
@@ -527,8 +561,9 @@ discard block |
||
| 527 | 561 | $url = $smcFunc['json_decode']($url, true); |
| 528 | 562 | $url['error'] = $error; |
| 529 | 563 | |
| 530 | - if (!empty($sprintf)) |
|
| 531 | - $url['error_params'] = $sprintf; |
|
| 564 | + if (!empty($sprintf)) { |
|
| 565 | + $url['error_params'] = $sprintf; |
|
| 566 | + } |
|
| 532 | 567 | |
| 533 | 568 | $smcFunc['db_query']('', ' |
| 534 | 569 | UPDATE {db_prefix}log_online |
@@ -559,10 +594,11 @@ discard block |
||
| 559 | 594 | |
| 560 | 595 | $protocol = preg_match('~HTTP/1\.[01]~i', $_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0'; |
| 561 | 596 | |
| 562 | - if (!isset($statuses[$code])) |
|
| 563 | - header($protocol . ' 500 Internal Server Error'); |
|
| 564 | - else |
|
| 565 | - header($protocol . ' ' . $code . ' ' . $statuses[$code]); |
|
| 566 | -} |
|
| 597 | + if (!isset($statuses[$code])) { |
|
| 598 | + header($protocol . ' 500 Internal Server Error'); |
|
| 599 | + } else { |
|
| 600 | + header($protocol . ' ' . $code . ' ' . $statuses[$code]); |
|
| 601 | + } |
|
| 602 | + } |
|
| 567 | 603 | |
| 568 | 604 | ?> |
| 569 | 605 | \ No newline at end of file |
@@ -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 | class Attachments |
| 20 | 21 | { |
@@ -70,16 +71,18 @@ discard block |
||
| 70 | 71 | |
| 71 | 72 | $this->_sa = !empty($_REQUEST['sa']) ? $smcFunc['htmlspecialchars']($smcFunc['htmltrim']($_REQUEST['sa'])) : false; |
| 72 | 73 | |
| 73 | - if ($this->_canPostAttachment && $this->_sa && in_array($this->_sa, $this->_subActions)) |
|
| 74 | - $this->{$this->_sa}(); |
|
| 74 | + if ($this->_canPostAttachment && $this->_sa && in_array($this->_sa, $this->_subActions)) { |
|
| 75 | + $this->{$this->_sa}(); |
|
| 76 | + } |
|
| 75 | 77 | |
| 76 | 78 | // Just send a generic message. |
| 77 | - else |
|
| 78 | - $this->setResponse(array( |
|
| 79 | + else { |
|
| 80 | + $this->setResponse(array( |
|
| 79 | 81 | 'text' => $this->_sa == 'add' ? 'attach_error_title' : 'attached_file_deleted_error', |
| 80 | 82 | 'type' => 'error', |
| 81 | 83 | 'data' => false, |
| 82 | 84 | )); |
| 85 | + } |
|
| 83 | 86 | |
| 84 | 87 | // Back to the future, oh, to the browser! |
| 85 | 88 | $this->sendResponse(); |
@@ -95,12 +98,13 @@ discard block |
||
| 95 | 98 | $attachID = !empty($_REQUEST['attach']) && is_numeric($_REQUEST['attach']) ? (int) $_REQUEST['attach'] : 0; |
| 96 | 99 | |
| 97 | 100 | // Need something to work with. |
| 98 | - if (!$attachID || (!empty($_SESSION['already_attached']) && !isset($_SESSION['already_attached'][$attachID]))) |
|
| 99 | - return $this->setResponse(array( |
|
| 101 | + if (!$attachID || (!empty($_SESSION['already_attached']) && !isset($_SESSION['already_attached'][$attachID]))) { |
|
| 102 | + return $this->setResponse(array( |
|
| 100 | 103 | 'text' => 'attached_file_deleted_error', |
| 101 | 104 | 'type' => 'error', |
| 102 | 105 | 'data' => false, |
| 103 | 106 | )); |
| 107 | + } |
|
| 104 | 108 | |
| 105 | 109 | // Lets pass some params and see what happens :P |
| 106 | 110 | $affectedMessage = removeAttachments(array('id_attach' => $attachID), '', true, true); |
@@ -119,19 +123,21 @@ discard block |
||
| 119 | 123 | public function add() |
| 120 | 124 | { |
| 121 | 125 | // You gotta be able to post attachments. |
| 122 | - if (!$this->_canPostAttachment) |
|
| 123 | - return $this->setResponse(array( |
|
| 126 | + if (!$this->_canPostAttachment) { |
|
| 127 | + return $this->setResponse(array( |
|
| 124 | 128 | 'text' => 'attached_file_cannot', |
| 125 | 129 | 'type' => 'error', |
| 126 | 130 | 'data' => false, |
| 127 | 131 | )); |
| 132 | + } |
|
| 128 | 133 | |
| 129 | 134 | // Process them at once! |
| 130 | 135 | $this->processAttachments(); |
| 131 | 136 | |
| 132 | 137 | // The attachments was created and moved the the right folder, time to update the DB. |
| 133 | - if (!empty($_SESSION['temp_attachments'])) |
|
| 134 | - $this->createAtttach(); |
|
| 138 | + if (!empty($_SESSION['temp_attachments'])) { |
|
| 139 | + $this->createAtttach(); |
|
| 140 | + } |
|
| 135 | 141 | |
| 136 | 142 | // Set the response. |
| 137 | 143 | $this->setResponse(); |
@@ -144,8 +150,9 @@ discard block |
||
| 144 | 150 | { |
| 145 | 151 | global $context, $modSettings, $smcFunc, $user_info, $txt; |
| 146 | 152 | |
| 147 | - if (!isset($_FILES['attachment']['name'])) |
|
| 148 | - $_FILES['attachment']['tmp_name'] = array(); |
|
| 153 | + if (!isset($_FILES['attachment']['name'])) { |
|
| 154 | + $_FILES['attachment']['tmp_name'] = array(); |
|
| 155 | + } |
|
| 149 | 156 | |
| 150 | 157 | // If there are attachments, calculate the total size and how many. |
| 151 | 158 | $context['attachments']['total_size'] = 0; |
@@ -155,25 +162,30 @@ discard block |
||
| 155 | 162 | if (isset($_REQUEST['msg'])) |
| 156 | 163 | { |
| 157 | 164 | $context['attachments']['quantity'] = count($context['current_attachments']); |
| 158 | - foreach ($context['current_attachments'] as $attachment) |
|
| 159 | - $context['attachments']['total_size'] += $attachment['size']; |
|
| 165 | + foreach ($context['current_attachments'] as $attachment) { |
|
| 166 | + $context['attachments']['total_size'] += $attachment['size']; |
|
| 167 | + } |
|
| 160 | 168 | } |
| 161 | 169 | |
| 162 | 170 | // A bit of house keeping first. |
| 163 | - if (!empty($_SESSION['temp_attachments']) && count($_SESSION['temp_attachments']) == 1) |
|
| 164 | - unset($_SESSION['temp_attachments']); |
|
| 171 | + if (!empty($_SESSION['temp_attachments']) && count($_SESSION['temp_attachments']) == 1) { |
|
| 172 | + unset($_SESSION['temp_attachments']); |
|
| 173 | + } |
|
| 165 | 174 | |
| 166 | 175 | // Our infamous SESSION var, we are gonna have soo much fun with it! |
| 167 | - if (!isset($_SESSION['temp_attachments'])) |
|
| 168 | - $_SESSION['temp_attachments'] = array(); |
|
| 176 | + if (!isset($_SESSION['temp_attachments'])) { |
|
| 177 | + $_SESSION['temp_attachments'] = array(); |
|
| 178 | + } |
|
| 169 | 179 | |
| 170 | 180 | // Make sure we're uploading to the right place. |
| 171 | - if (!empty($modSettings['automanage_attachments'])) |
|
| 172 | - automanage_attachments_check_directory(); |
|
| 181 | + if (!empty($modSettings['automanage_attachments'])) { |
|
| 182 | + automanage_attachments_check_directory(); |
|
| 183 | + } |
|
| 173 | 184 | |
| 174 | 185 | // Is the attachments folder actually there? |
| 175 | - if (!empty($context['dir_creation_error'])) |
|
| 176 | - $this->_generalErrors[] = $context['dir_creation_error']; |
|
| 186 | + if (!empty($context['dir_creation_error'])) { |
|
| 187 | + $this->_generalErrors[] = $context['dir_creation_error']; |
|
| 188 | + } |
|
| 177 | 189 | |
| 178 | 190 | // The current attach folder ha some issues... |
| 179 | 191 | elseif (!is_dir($this->_attchDir)) |
@@ -198,13 +210,12 @@ discard block |
||
| 198 | 210 | ); |
| 199 | 211 | list ($context['attachments']['quantity'], $context['attachments']['total_size']) = $smcFunc['db_fetch_row']($request); |
| 200 | 212 | $smcFunc['db_free_result']($request); |
| 201 | - } |
|
| 202 | - |
|
| 203 | - else |
|
| 204 | - $context['attachments'] = array( |
|
| 213 | + } else { |
|
| 214 | + $context['attachments'] = array( |
|
| 205 | 215 | 'quantity' => 0, |
| 206 | 216 | 'total_size' => 0, |
| 207 | 217 | ); |
| 218 | + } |
|
| 208 | 219 | |
| 209 | 220 | // Check for other general errors here. |
| 210 | 221 | |
@@ -212,9 +223,10 @@ discard block |
||
| 212 | 223 | if (!empty($this->_generalErrors)) |
| 213 | 224 | { |
| 214 | 225 | // And delete the files 'cos they ain't going nowhere. |
| 215 | - foreach ($_FILES['attachment']['tmp_name'] as $n => $dummy) |
|
| 216 | - if (file_exists($_FILES['attachment']['tmp_name'][$n])) |
|
| 226 | + foreach ($_FILES['attachment']['tmp_name'] as $n => $dummy) { |
|
| 227 | + if (file_exists($_FILES['attachment']['tmp_name'][$n])) |
|
| 217 | 228 | unlink($_FILES['attachment']['tmp_name'][$n]); |
| 229 | + } |
|
| 218 | 230 | |
| 219 | 231 | $_FILES['attachment']['tmp_name'] = array(); |
| 220 | 232 | |
@@ -225,26 +237,29 @@ discard block |
||
| 225 | 237 | // Loop through $_FILES['attachment'] array and move each file to the current attachments folder. |
| 226 | 238 | foreach ($_FILES['attachment']['tmp_name'] as $n => $dummy) |
| 227 | 239 | { |
| 228 | - if ($_FILES['attachment']['name'][$n] == '') |
|
| 229 | - continue; |
|
| 240 | + if ($_FILES['attachment']['name'][$n] == '') { |
|
| 241 | + continue; |
|
| 242 | + } |
|
| 230 | 243 | |
| 231 | 244 | // First, let's first check for PHP upload errors. |
| 232 | 245 | $errors = array(); |
| 233 | 246 | if (!empty($_FILES['attachment']['error'][$n])) |
| 234 | 247 | { |
| 235 | - if ($_FILES['attachment']['error'][$n] == 2) |
|
| 236 | - $errors[] = array('file_too_big', array($modSettings['attachmentSizeLimit'])); |
|
| 237 | - |
|
| 238 | - else |
|
| 239 | - log_error($_FILES['attachment']['name'][$n] . ': ' . $txt['php_upload_error_' . $_FILES['attachment']['error'][$n]]); |
|
| 248 | + if ($_FILES['attachment']['error'][$n] == 2) { |
|
| 249 | + $errors[] = array('file_too_big', array($modSettings['attachmentSizeLimit'])); |
|
| 250 | + } else { |
|
| 251 | + log_error($_FILES['attachment']['name'][$n] . ': ' . $txt['php_upload_error_' . $_FILES['attachment']['error'][$n]]); |
|
| 252 | + } |
|
| 240 | 253 | |
| 241 | 254 | // Log this one, because... |
| 242 | - if ($_FILES['attachment']['error'][$n] == 6) |
|
| 243 | - log_error($_FILES['attachment']['name'][$n] . ': ' . $txt['php_upload_error_6'], 'critical'); |
|
| 255 | + if ($_FILES['attachment']['error'][$n] == 6) { |
|
| 256 | + log_error($_FILES['attachment']['name'][$n] . ': ' . $txt['php_upload_error_6'], 'critical'); |
|
| 257 | + } |
|
| 244 | 258 | |
| 245 | 259 | // Weird, no errors were cached, still fill out a generic one. |
| 246 | - if (empty($errors)) |
|
| 247 | - $errors[] = 'attach_php_error'; |
|
| 260 | + if (empty($errors)) { |
|
| 261 | + $errors[] = 'attach_php_error'; |
|
| 262 | + } |
|
| 248 | 263 | } |
| 249 | 264 | |
| 250 | 265 | // Try to move and rename the file before doing any more checks on it. |
@@ -256,8 +271,9 @@ discard block |
||
| 256 | 271 | { |
| 257 | 272 | // The reported MIME type of the attachment might not be reliable. |
| 258 | 273 | // Fortunately, PHP 5.3+ lets us easily verify the real MIME type. |
| 259 | - if (function_exists('mime_content_type')) |
|
| 260 | - $_FILES['attachment']['type'][$n] = mime_content_type($_FILES['attachment']['tmp_name'][$n]); |
|
| 274 | + if (function_exists('mime_content_type')) { |
|
| 275 | + $_FILES['attachment']['type'][$n] = mime_content_type($_FILES['attachment']['tmp_name'][$n]); |
|
| 276 | + } |
|
| 261 | 277 | |
| 262 | 278 | $_SESSION['temp_attachments'][$attachID] = array( |
| 263 | 279 | 'name' => $smcFunc['htmlspecialchars'](basename($_FILES['attachment']['name'][$n])), |
@@ -269,16 +285,18 @@ discard block |
||
| 269 | 285 | ); |
| 270 | 286 | |
| 271 | 287 | // Move the file to the attachments folder with a temp name for now. |
| 272 | - if (@move_uploaded_file($_FILES['attachment']['tmp_name'][$n], $destName)) |
|
| 273 | - smf_chmod($destName, 0644); |
|
| 288 | + if (@move_uploaded_file($_FILES['attachment']['tmp_name'][$n], $destName)) { |
|
| 289 | + smf_chmod($destName, 0644); |
|
| 290 | + } |
|
| 274 | 291 | |
| 275 | 292 | // This is madness!! |
| 276 | 293 | else |
| 277 | 294 | { |
| 278 | 295 | // File couldn't be moved. |
| 279 | 296 | $_SESSION['temp_attachments'][$attachID]['errors'][] = 'attach_timeout'; |
| 280 | - if (file_exists($_FILES['attachment']['tmp_name'][$n])) |
|
| 281 | - unlink($_FILES['attachment']['tmp_name'][$n]); |
|
| 297 | + if (file_exists($_FILES['attachment']['tmp_name'][$n])) { |
|
| 298 | + unlink($_FILES['attachment']['tmp_name'][$n]); |
|
| 299 | + } |
|
| 282 | 300 | } |
| 283 | 301 | } |
| 284 | 302 | |
@@ -291,13 +309,15 @@ discard block |
||
| 291 | 309 | 'errors' => $errors, |
| 292 | 310 | ); |
| 293 | 311 | |
| 294 | - if (file_exists($_FILES['attachment']['tmp_name'][$n])) |
|
| 295 | - unlink($_FILES['attachment']['tmp_name'][$n]); |
|
| 312 | + if (file_exists($_FILES['attachment']['tmp_name'][$n])) { |
|
| 313 | + unlink($_FILES['attachment']['tmp_name'][$n]); |
|
| 314 | + } |
|
| 296 | 315 | } |
| 297 | 316 | |
| 298 | 317 | // If there's no errors to this point. We still do need to apply some additional checks before we are finished. |
| 299 | - if (empty($_SESSION['temp_attachments'][$attachID]['errors'])) |
|
| 300 | - attachmentChecks($attachID); |
|
| 318 | + if (empty($_SESSION['temp_attachments'][$attachID]['errors'])) { |
|
| 319 | + attachmentChecks($attachID); |
|
| 320 | + } |
|
| 301 | 321 | } |
| 302 | 322 | |
| 303 | 323 | // Mod authors, finally a hook to hang an alternate attachment upload system upon |
@@ -344,14 +364,15 @@ discard block |
||
| 344 | 364 | |
| 345 | 365 | $_SESSION['already_attached'][$attachmentOptions['attachID']] = $attachmentOptions['attachID']; |
| 346 | 366 | |
| 347 | - if (!empty($attachmentOptions['thumb'])) |
|
| 348 | - $_SESSION['already_attached'][$attachmentOptions['thumb']] = $attachmentOptions['thumb']; |
|
| 367 | + if (!empty($attachmentOptions['thumb'])) { |
|
| 368 | + $_SESSION['already_attached'][$attachmentOptions['thumb']] = $attachmentOptions['thumb']; |
|
| 369 | + } |
|
| 349 | 370 | |
| 350 | - if ($this->_msg) |
|
| 351 | - assignAttachments($_SESSION['already_attached'], $this->_msg); |
|
| 371 | + if ($this->_msg) { |
|
| 372 | + assignAttachments($_SESSION['already_attached'], $this->_msg); |
|
| 373 | + } |
|
| 352 | 374 | } |
| 353 | - } |
|
| 354 | - else |
|
| 375 | + } else |
|
| 355 | 376 | { |
| 356 | 377 | // Sort out the errors for display and delete any associated files. |
| 357 | 378 | $log_these = array('attachments_no_create', 'attachments_no_write', 'attach_timeout', 'ran_out_of_space', 'cant_access_upload_path', 'attach_0_byte_file'); |
@@ -363,14 +384,16 @@ discard block |
||
| 363 | 384 | if (!is_array($error)) |
| 364 | 385 | { |
| 365 | 386 | $attachmentOptions['errors'][] = $txt[$error]; |
| 366 | - if (in_array($error, $log_these)) |
|
| 367 | - log_error($attachment['name'] . ': ' . $txt[$error], 'critical'); |
|
| 387 | + if (in_array($error, $log_these)) { |
|
| 388 | + log_error($attachment['name'] . ': ' . $txt[$error], 'critical'); |
|
| 389 | + } |
|
| 390 | + } else { |
|
| 391 | + $attachmentOptions['errors'][] = vsprintf($txt[$error[0]], $error[1]); |
|
| 368 | 392 | } |
| 369 | - else |
|
| 370 | - $attachmentOptions['errors'][] = vsprintf($txt[$error[0]], $error[1]); |
|
| 371 | 393 | } |
| 372 | - if (file_exists($attachment['tmp_name'])) |
|
| 373 | - unlink($attachment['tmp_name']); |
|
| 394 | + if (file_exists($attachment['tmp_name'])) { |
|
| 395 | + unlink($attachment['tmp_name']); |
|
| 396 | + } |
|
| 374 | 397 | } |
| 375 | 398 | |
| 376 | 399 | // You don't need to know. |
@@ -382,8 +405,9 @@ discard block |
||
| 382 | 405 | } |
| 383 | 406 | |
| 384 | 407 | // Temp save this on the db. |
| 385 | - if (!empty($_SESSION['already_attached'])) |
|
| 386 | - $this->_attachSuccess = $_SESSION['already_attached']; |
|
| 408 | + if (!empty($_SESSION['already_attached'])) { |
|
| 409 | + $this->_attachSuccess = $_SESSION['already_attached']; |
|
| 410 | + } |
|
| 387 | 411 | |
| 388 | 412 | unset($_SESSION['temp_attachments']); |
| 389 | 413 | } |
@@ -403,14 +427,16 @@ discard block |
||
| 403 | 427 | if ($this->_sa == 'add') |
| 404 | 428 | { |
| 405 | 429 | // Is there any generic errors? made some sense out of them! |
| 406 | - if ($this->_generalErrors) |
|
| 407 | - foreach ($this->_generalErrors as $k => $v) |
|
| 430 | + if ($this->_generalErrors) { |
|
| 431 | + foreach ($this->_generalErrors as $k => $v) |
|
| 408 | 432 | $this->_generalErrors[$k] = (is_array($v) ? vsprintf($txt[$v[0]], $v[1]) : $txt[$v]); |
| 433 | + } |
|
| 409 | 434 | |
| 410 | 435 | // Gotta urlencode the filename. |
| 411 | - if ($this->_attachResults) |
|
| 412 | - foreach ($this->_attachResults as $k => $v) |
|
| 436 | + if ($this->_attachResults) { |
|
| 437 | + foreach ($this->_attachResults as $k => $v) |
|
| 413 | 438 | $this->_attachResults[$k]['name'] = urlencode($this->_attachResults[$k]['name']); |
| 439 | + } |
|
| 414 | 440 | |
| 415 | 441 | $this->_response = array( |
| 416 | 442 | 'files' => $this->_attachResults ? $this->_attachResults : false, |
@@ -419,9 +445,10 @@ discard block |
||
| 419 | 445 | } |
| 420 | 446 | |
| 421 | 447 | // Rest of us mere mortals gets no special treatment... |
| 422 | - elseif (!empty($data)) |
|
| 423 | - if (!empty($data['text']) && !empty($txt[$data['text']])) |
|
| 448 | + elseif (!empty($data)) { |
|
| 449 | + if (!empty($data['text']) && !empty($txt[$data['text']])) |
|
| 424 | 450 | $this->_response['text'] = $txt[$data['text']]; |
| 451 | + } |
|
| 425 | 452 | } |
| 426 | 453 | |
| 427 | 454 | protected function sendResponse() |
@@ -430,11 +457,11 @@ discard block |
||
| 430 | 457 | |
| 431 | 458 | ob_end_clean(); |
| 432 | 459 | |
| 433 | - if (!empty($modSettings['CompressedOutput'])) |
|
| 434 | - @ob_start('ob_gzhandler'); |
|
| 435 | - |
|
| 436 | - else |
|
| 437 | - ob_start(); |
|
| 460 | + if (!empty($modSettings['CompressedOutput'])) { |
|
| 461 | + @ob_start('ob_gzhandler'); |
|
| 462 | + } else { |
|
| 463 | + ob_start(); |
|
| 464 | + } |
|
| 438 | 465 | |
| 439 | 466 | // Set the header. |
| 440 | 467 | header('Content-Type: application/json; charset='. $context['character_set'] .''); |
@@ -18,18 +18,20 @@ discard block |
||
| 18 | 18 | global $context, $settings, $options, $txt, $scripturl, $modSettings; |
| 19 | 19 | |
| 20 | 20 | // Let them know, if their report was a success! |
| 21 | - if ($context['report_sent']) |
|
| 22 | - echo ' |
|
| 21 | + if ($context['report_sent']) { |
|
| 22 | + echo ' |
|
| 23 | 23 | <div class="infobox"> |
| 24 | 24 | ', $txt['report_sent'], ' |
| 25 | 25 | </div>'; |
| 26 | + } |
|
| 26 | 27 | |
| 27 | 28 | // Let them know why their message became unapproved. |
| 28 | - if ($context['becomesUnapproved']) |
|
| 29 | - echo ' |
|
| 29 | + if ($context['becomesUnapproved']) { |
|
| 30 | + echo ' |
|
| 30 | 31 | <div class="noticebox"> |
| 31 | 32 | ', $txt['post_becomesUnapproved'], ' |
| 32 | 33 | </div>'; |
| 34 | + } |
|
| 33 | 35 | |
| 34 | 36 | // Show new topic info here? |
| 35 | 37 | echo ' |
@@ -49,11 +51,13 @@ discard block |
||
| 49 | 51 | <p>'; |
| 50 | 52 | |
| 51 | 53 | // Show just numbers...? |
| 52 | - if ($settings['display_who_viewing'] == 1) |
|
| 53 | - echo count($context['view_members']), ' ', count($context['view_members']) == 1 ? $txt['who_member'] : $txt['members']; |
|
| 54 | + if ($settings['display_who_viewing'] == 1) { |
|
| 55 | + echo count($context['view_members']), ' ', count($context['view_members']) == 1 ? $txt['who_member'] : $txt['members']; |
|
| 56 | + } |
|
| 54 | 57 | // Or show the actual people viewing the topic? |
| 55 | - else |
|
| 56 | - 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'] . ')'); |
|
| 58 | + else { |
|
| 59 | + 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'] . ')'); |
|
| 60 | + } |
|
| 57 | 61 | |
| 58 | 62 | // Now show how many guests are here too. |
| 59 | 63 | echo $txt['who_and'], $context['view_num_guests'], ' ', $context['view_num_guests'] == 1 ? $txt['guest'] : $txt['guests'], $txt['who_viewing_topic'], ' |
@@ -91,10 +95,11 @@ discard block |
||
| 91 | 95 | <dt class="', $option['voted_this'] ? ' voted' : '', '">', $option['option'], '</dt> |
| 92 | 96 | <dd class="statsbar', $option['voted_this'] ? ' voted' : '', '">'; |
| 93 | 97 | |
| 94 | - if ($context['allow_results_view']) |
|
| 95 | - echo ' |
|
| 98 | + if ($context['allow_results_view']) { |
|
| 99 | + echo ' |
|
| 96 | 100 | ', $option['bar_ndt'], ' |
| 97 | 101 | <span class="percentage">', $option['votes'], ' (', $option['percent'], '%)</span>'; |
| 102 | + } |
|
| 98 | 103 | |
| 99 | 104 | echo ' |
| 100 | 105 | </dd>'; |
@@ -103,9 +108,10 @@ discard block |
||
| 103 | 108 | echo ' |
| 104 | 109 | </dl>'; |
| 105 | 110 | |
| 106 | - if ($context['allow_results_view']) |
|
| 107 | - echo ' |
|
| 111 | + if ($context['allow_results_view']) { |
|
| 112 | + echo ' |
|
| 108 | 113 | <p><strong>', $txt['poll_total_voters'], ':</strong> ', $context['poll']['total_votes'], '</p>'; |
| 114 | + } |
|
| 109 | 115 | } |
| 110 | 116 | // They are allowed to vote! Go to it! |
| 111 | 117 | else |
@@ -114,17 +120,19 @@ discard block |
||
| 114 | 120 | <form action="', $scripturl, '?action=vote;topic=', $context['current_topic'], '.', $context['start'], ';poll=', $context['poll']['id'], '" method="post" accept-charset="', $context['character_set'], '">'; |
| 115 | 121 | |
| 116 | 122 | // Show a warning if they are allowed more than one option. |
| 117 | - if ($context['poll']['allowed_warning']) |
|
| 118 | - echo ' |
|
| 123 | + if ($context['poll']['allowed_warning']) { |
|
| 124 | + echo ' |
|
| 119 | 125 | <p class="smallpadding">', $context['poll']['allowed_warning'], '</p>'; |
| 126 | + } |
|
| 120 | 127 | |
| 121 | 128 | echo ' |
| 122 | 129 | <ul class="options">'; |
| 123 | 130 | |
| 124 | 131 | // Show each option with its button - a radio likely. |
| 125 | - foreach ($context['poll']['options'] as $option) |
|
| 126 | - echo ' |
|
| 132 | + foreach ($context['poll']['options'] as $option) { |
|
| 133 | + echo ' |
|
| 127 | 134 | <li>', $option['vote_button'], ' <label for="', $option['id'], '">', $option['option'], '</label></li>'; |
| 135 | + } |
|
| 128 | 136 | |
| 129 | 137 | echo ' |
| 130 | 138 | </ul> |
@@ -136,9 +144,10 @@ discard block |
||
| 136 | 144 | } |
| 137 | 145 | |
| 138 | 146 | // Is the clock ticking? |
| 139 | - if (!empty($context['poll']['expire_time'])) |
|
| 140 | - echo ' |
|
| 147 | + if (!empty($context['poll']['expire_time'])) { |
|
| 148 | + echo ' |
|
| 141 | 149 | <p><strong>', ($context['poll']['is_expired'] ? $txt['poll_expired_on'] : $txt['poll_expires_on']), ':</strong> ', $context['poll']['expire_time'], '</p>'; |
| 150 | + } |
|
| 142 | 151 | |
| 143 | 152 | echo ' |
| 144 | 153 | </div><!-- #poll_options --> |
@@ -168,11 +177,13 @@ discard block |
||
| 168 | 177 | <li> |
| 169 | 178 | <strong class="event_title"><a href="', $scripturl, '?action=calendar;event=', $event['id'], '">', $event['title'], '</a></strong>'; |
| 170 | 179 | |
| 171 | - if ($event['can_edit']) |
|
| 172 | - echo ' <a href="' . $event['modify_href'] . '"><span class="generic_icons calendar_modify" title="', $txt['calendar_edit'], '"></span></a>'; |
|
| 180 | + if ($event['can_edit']) { |
|
| 181 | + echo ' <a href="' . $event['modify_href'] . '"><span class="generic_icons calendar_modify" title="', $txt['calendar_edit'], '"></span></a>'; |
|
| 182 | + } |
|
| 173 | 183 | |
| 174 | - if ($event['can_export']) |
|
| 175 | - echo ' <a href="' . $event['export_href'] . '"><span class="generic_icons calendar_export" title="', $txt['calendar_export'], '"></span></a>'; |
|
| 184 | + if ($event['can_export']) { |
|
| 185 | + echo ' <a href="' . $event['export_href'] . '"><span class="generic_icons calendar_export" title="', $txt['calendar_export'], '"></span></a>'; |
|
| 186 | + } |
|
| 176 | 187 | |
| 177 | 188 | echo ' |
| 178 | 189 | <br>'; |
@@ -180,14 +191,14 @@ discard block |
||
| 180 | 191 | if (!empty($event['allday'])) |
| 181 | 192 | { |
| 182 | 193 | echo '<time datetime="' . $event['start_iso_gmdate'] . '">', trim($event['start_date_local']), '</time>', ($event['start_date'] != $event['end_date']) ? ' – <time datetime="' . $event['end_iso_gmdate'] . '">' . trim($event['end_date_local']) . '</time>' : ''; |
| 183 | - } |
|
| 184 | - else |
|
| 194 | + } else |
|
| 185 | 195 | { |
| 186 | 196 | // Display event info relative to user's local timezone |
| 187 | 197 | echo '<time datetime="' . $event['start_iso_gmdate'] . '">', trim($event['start_date_local']), ', ', trim($event['start_time_local']), '</time> – <time datetime="' . $event['end_iso_gmdate'] . '">'; |
| 188 | 198 | |
| 189 | - if ($event['start_date_local'] != $event['end_date_local']) |
|
| 190 | - echo trim($event['end_date_local']) . ', '; |
|
| 199 | + if ($event['start_date_local'] != $event['end_date_local']) { |
|
| 200 | + echo trim($event['end_date_local']) . ', '; |
|
| 201 | + } |
|
| 191 | 202 | |
| 192 | 203 | echo trim($event['end_time_local']); |
| 193 | 204 | |
@@ -196,24 +207,28 @@ discard block |
||
| 196 | 207 | { |
| 197 | 208 | echo '</time> (<time datetime="' . $event['start_iso_gmdate'] . '">'; |
| 198 | 209 | |
| 199 | - if ($event['start_date_orig'] != $event['start_date_local'] || $event['end_date_orig'] != $event['end_date_local'] || $event['start_date_orig'] != $event['end_date_orig']) |
|
| 200 | - echo trim($event['start_date_orig']), ', '; |
|
| 210 | + if ($event['start_date_orig'] != $event['start_date_local'] || $event['end_date_orig'] != $event['end_date_local'] || $event['start_date_orig'] != $event['end_date_orig']) { |
|
| 211 | + echo trim($event['start_date_orig']), ', '; |
|
| 212 | + } |
|
| 201 | 213 | |
| 202 | 214 | echo trim($event['start_time_orig']), '</time> – <time datetime="' . $event['end_iso_gmdate'] . '">'; |
| 203 | 215 | |
| 204 | - if ($event['start_date_orig'] != $event['end_date_orig']) |
|
| 205 | - echo trim($event['end_date_orig']) . ', '; |
|
| 216 | + if ($event['start_date_orig'] != $event['end_date_orig']) { |
|
| 217 | + echo trim($event['end_date_orig']) . ', '; |
|
| 218 | + } |
|
| 206 | 219 | |
| 207 | 220 | echo trim($event['end_time_orig']), ' ', $event['tz_abbrev'], '</time>)'; |
| 208 | 221 | } |
| 209 | 222 | // Event is scheduled in the user's own timezone? Let 'em know, just to avoid confusion |
| 210 | - else |
|
| 211 | - echo ' ', $event['tz_abbrev'], '</time>'; |
|
| 223 | + else { |
|
| 224 | + echo ' ', $event['tz_abbrev'], '</time>'; |
|
| 225 | + } |
|
| 212 | 226 | } |
| 213 | 227 | |
| 214 | - if (!empty($event['location'])) |
|
| 215 | - echo ' |
|
| 228 | + if (!empty($event['location'])) { |
|
| 229 | + echo ' |
|
| 216 | 230 | <br>', $event['location']; |
| 231 | + } |
|
| 217 | 232 | |
| 218 | 233 | echo ' |
| 219 | 234 | </li>'; |
@@ -250,8 +265,9 @@ discard block |
||
| 250 | 265 | $context['removableMessageIDs'] = array(); |
| 251 | 266 | |
| 252 | 267 | // Get all the messages... |
| 253 | - while ($message = $context['get_message']()) |
|
| 254 | - template_single_post($message); |
|
| 268 | + while ($message = $context['get_message']()) { |
|
| 269 | + template_single_post($message); |
|
| 270 | + } |
|
| 255 | 271 | |
| 256 | 272 | echo ' |
| 257 | 273 | </form> |
@@ -289,8 +305,9 @@ discard block |
||
| 289 | 305 | <div id="display_jump_to"></div>'; |
| 290 | 306 | |
| 291 | 307 | // Show quickreply |
| 292 | - if ($context['can_reply']) |
|
| 293 | - template_quickreply(); |
|
| 308 | + if ($context['can_reply']) { |
|
| 309 | + template_quickreply(); |
|
| 310 | + } |
|
| 294 | 311 | |
| 295 | 312 | // User action pop on mobile screen (or actually small screen), this uses responsive css does not check mobile device. |
| 296 | 313 | echo ' |
@@ -305,8 +322,8 @@ discard block |
||
| 305 | 322 | </div>'; |
| 306 | 323 | |
| 307 | 324 | // Show the moderation button & pop only if user can moderate |
| 308 | - if ($context['can_moderate_forum'] || $context['user']['is_mod']) |
|
| 309 | - echo ' |
|
| 325 | + if ($context['can_moderate_forum'] || $context['user']['is_mod']) { |
|
| 326 | + echo ' |
|
| 310 | 327 | <div id="mobile_moderation" class="popup_container"> |
| 311 | 328 | <div class="popup_window description"> |
| 312 | 329 | <div class="popup_heading"> |
@@ -318,6 +335,7 @@ discard block |
||
| 318 | 335 | </div> |
| 319 | 336 | </div> |
| 320 | 337 | </div>'; |
| 338 | + } |
|
| 321 | 339 | |
| 322 | 340 | echo ' |
| 323 | 341 | <script>'; |
@@ -441,9 +459,10 @@ discard block |
||
| 441 | 459 | }); |
| 442 | 460 | }'; |
| 443 | 461 | |
| 444 | - if (!empty($context['ignoredMsgs'])) |
|
| 445 | - echo ' |
|
| 462 | + if (!empty($context['ignoredMsgs'])) { |
|
| 463 | + echo ' |
|
| 446 | 464 | ignore_toggles([', implode(', ', $context['ignoredMsgs']), '], ', JavaScriptEscape($txt['show_ignore_user_post']), ');'; |
| 465 | + } |
|
| 447 | 466 | |
| 448 | 467 | echo ' |
| 449 | 468 | </script>'; |
@@ -460,8 +479,9 @@ discard block |
||
| 460 | 479 | |
| 461 | 480 | $ignoring = false; |
| 462 | 481 | |
| 463 | - if ($message['can_remove']) |
|
| 464 | - $context['removableMessageIDs'][] = $message['id']; |
|
| 482 | + if ($message['can_remove']) { |
|
| 483 | + $context['removableMessageIDs'][] = $message['id']; |
|
| 484 | + } |
|
| 465 | 485 | |
| 466 | 486 | // Are we ignoring this message? |
| 467 | 487 | if (!empty($message['is_ignored'])) |
@@ -488,9 +508,10 @@ discard block |
||
| 488 | 508 | <div class="custom_fields_above_member"> |
| 489 | 509 | <ul class="nolist">'; |
| 490 | 510 | |
| 491 | - foreach ($message['custom_fields']['above_member'] as $custom) |
|
| 492 | - echo ' |
|
| 511 | + foreach ($message['custom_fields']['above_member'] as $custom) { |
|
| 512 | + echo ' |
|
| 493 | 513 | <li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>'; |
| 514 | + } |
|
| 494 | 515 | |
| 495 | 516 | echo ' |
| 496 | 517 | </ul> |
@@ -501,25 +522,28 @@ discard block |
||
| 501 | 522 | <h4>'; |
| 502 | 523 | |
| 503 | 524 | // Show online and offline buttons? |
| 504 | - if (!empty($modSettings['onlineEnable']) && !$message['member']['is_guest']) |
|
| 505 | - echo ' |
|
| 525 | + if (!empty($modSettings['onlineEnable']) && !$message['member']['is_guest']) { |
|
| 526 | + echo ' |
|
| 506 | 527 | ', $context['can_send_pm'] ? '<a href="' . $message['member']['online']['href'] . '" title="' . $message['member']['online']['label'] . '">' : '', '<span class="' . ($message['member']['online']['is_online'] == 1 ? 'on' : 'off') . '" title="' . $message['member']['online']['text'] . '"></span>', $context['can_send_pm'] ? '</a>' : ''; |
| 528 | + } |
|
| 507 | 529 | |
| 508 | 530 | // Custom fields BEFORE the username? |
| 509 | - if (!empty($message['custom_fields']['before_member'])) |
|
| 510 | - foreach ($message['custom_fields']['before_member'] as $custom) |
|
| 531 | + if (!empty($message['custom_fields']['before_member'])) { |
|
| 532 | + foreach ($message['custom_fields']['before_member'] as $custom) |
|
| 511 | 533 | echo ' |
| 512 | 534 | <span class="custom ', $custom['col_name'], '">', $custom['value'], '</span>'; |
| 535 | + } |
|
| 513 | 536 | |
| 514 | 537 | // Show a link to the member's profile. |
| 515 | 538 | echo ' |
| 516 | 539 | ', $message['member']['link']; |
| 517 | 540 | |
| 518 | 541 | // Custom fields AFTER the username? |
| 519 | - if (!empty($message['custom_fields']['after_member'])) |
|
| 520 | - foreach ($message['custom_fields']['after_member'] as $custom) |
|
| 542 | + if (!empty($message['custom_fields']['after_member'])) { |
|
| 543 | + foreach ($message['custom_fields']['after_member'] as $custom) |
|
| 521 | 544 | echo ' |
| 522 | 545 | <span class="custom ', $custom['col_name'], '">', $custom['value'], '</span>'; |
| 546 | + } |
|
| 523 | 547 | |
| 524 | 548 | // Begin display of user info |
| 525 | 549 | echo ' |
@@ -527,51 +551,59 @@ discard block |
||
| 527 | 551 | <ul class="user_info">'; |
| 528 | 552 | |
| 529 | 553 | // Show the user's avatar. |
| 530 | - if (!empty($modSettings['show_user_images']) && empty($options['show_no_avatars']) && !empty($message['member']['avatar']['image'])) |
|
| 531 | - echo ' |
|
| 554 | + if (!empty($modSettings['show_user_images']) && empty($options['show_no_avatars']) && !empty($message['member']['avatar']['image'])) { |
|
| 555 | + echo ' |
|
| 532 | 556 | <li class="avatar"> |
| 533 | 557 | <a href="', $message['member']['href'], '">', $message['member']['avatar']['image'], '</a> |
| 534 | 558 | </li>'; |
| 559 | + } |
|
| 535 | 560 | |
| 536 | 561 | // Are there any custom fields below the avatar? |
| 537 | - if (!empty($message['custom_fields']['below_avatar'])) |
|
| 538 | - foreach ($message['custom_fields']['below_avatar'] as $custom) |
|
| 562 | + if (!empty($message['custom_fields']['below_avatar'])) { |
|
| 563 | + foreach ($message['custom_fields']['below_avatar'] as $custom) |
|
| 539 | 564 | echo ' |
| 540 | 565 | <li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>'; |
| 566 | + } |
|
| 541 | 567 | |
| 542 | 568 | // Show the post group icons, but not for guests. |
| 543 | - if (!$message['member']['is_guest']) |
|
| 544 | - echo ' |
|
| 569 | + if (!$message['member']['is_guest']) { |
|
| 570 | + echo ' |
|
| 545 | 571 | <li class="icons">', $message['member']['group_icons'], '</li>'; |
| 572 | + } |
|
| 546 | 573 | |
| 547 | 574 | // Show the member's primary group (like 'Administrator') if they have one. |
| 548 | - if (!empty($message['member']['group'])) |
|
| 549 | - echo ' |
|
| 575 | + if (!empty($message['member']['group'])) { |
|
| 576 | + echo ' |
|
| 550 | 577 | <li class="membergroup">', $message['member']['group'], '</li>'; |
| 578 | + } |
|
| 551 | 579 | |
| 552 | 580 | // Show the member's custom title, if they have one. |
| 553 | - if (!empty($message['member']['title'])) |
|
| 554 | - echo ' |
|
| 581 | + if (!empty($message['member']['title'])) { |
|
| 582 | + echo ' |
|
| 555 | 583 | <li class="title">', $message['member']['title'], '</li>'; |
| 584 | + } |
|
| 556 | 585 | |
| 557 | 586 | // Don't show these things for guests. |
| 558 | 587 | if (!$message['member']['is_guest']) |
| 559 | 588 | { |
| 560 | 589 | |
| 561 | 590 | // Show the post group if and only if they have no other group or the option is on, and they are in a post group. |
| 562 | - if ((empty($modSettings['hide_post_group']) || empty($message['member']['group'])) && !empty($message['member']['post_group'])) |
|
| 563 | - echo ' |
|
| 591 | + if ((empty($modSettings['hide_post_group']) || empty($message['member']['group'])) && !empty($message['member']['post_group'])) { |
|
| 592 | + echo ' |
|
| 564 | 593 | <li class="postgroup">', $message['member']['post_group'], '</li>'; |
| 594 | + } |
|
| 565 | 595 | |
| 566 | 596 | // Show how many posts they have made. |
| 567 | - if (!isset($context['disabled_fields']['posts'])) |
|
| 568 | - echo ' |
|
| 597 | + if (!isset($context['disabled_fields']['posts'])) { |
|
| 598 | + echo ' |
|
| 569 | 599 | <li class="postcount">', $txt['member_postcount'], ': ', $message['member']['posts'], '</li>'; |
| 600 | + } |
|
| 570 | 601 | |
| 571 | 602 | // Show their personal text? |
| 572 | - if (!empty($modSettings['show_blurb']) && !empty($message['member']['blurb'])) |
|
| 573 | - echo ' |
|
| 603 | + if (!empty($modSettings['show_blurb']) && !empty($message['member']['blurb'])) { |
|
| 604 | + echo ' |
|
| 574 | 605 | <li class="blurb">', $message['member']['blurb'], '</li>'; |
| 606 | + } |
|
| 575 | 607 | |
| 576 | 608 | // Any custom fields to show as icons? |
| 577 | 609 | if (!empty($message['custom_fields']['icons'])) |
@@ -580,9 +612,10 @@ discard block |
||
| 580 | 612 | <li class="im_icons"> |
| 581 | 613 | <ol>'; |
| 582 | 614 | |
| 583 | - foreach ($message['custom_fields']['icons'] as $custom) |
|
| 584 | - echo ' |
|
| 615 | + foreach ($message['custom_fields']['icons'] as $custom) { |
|
| 616 | + echo ' |
|
| 585 | 617 | <li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>'; |
| 618 | + } |
|
| 586 | 619 | |
| 587 | 620 | echo ' |
| 588 | 621 | </ol> |
@@ -597,19 +630,22 @@ discard block |
||
| 597 | 630 | <ol class="profile_icons">'; |
| 598 | 631 | |
| 599 | 632 | // Don't show an icon if they haven't specified a website. |
| 600 | - if (!empty($message['member']['website']['url']) && !isset($context['disabled_fields']['website'])) |
|
| 601 | - echo ' |
|
| 633 | + if (!empty($message['member']['website']['url']) && !isset($context['disabled_fields']['website'])) { |
|
| 634 | + echo ' |
|
| 602 | 635 | <li><a href="', $message['member']['website']['url'], '" title="' . $message['member']['website']['title'] . '" target="_blank">', ($settings['use_image_buttons'] ? '<span class="generic_icons www centericon" title="' . $message['member']['website']['title'] . '"></span>' : $txt['www']), '</a></li>'; |
| 636 | + } |
|
| 603 | 637 | |
| 604 | 638 | // Since we know this person isn't a guest, you *can* message them. |
| 605 | - if ($context['can_send_pm']) |
|
| 606 | - echo ' |
|
| 639 | + if ($context['can_send_pm']) { |
|
| 640 | + echo ' |
|
| 607 | 641 | <li><a href="', $scripturl, '?action=pm;sa=send;u=', $message['member']['id'], '" title="', $message['member']['online']['is_online'] ? $txt['pm_online'] : $txt['pm_offline'], '">', $settings['use_image_buttons'] ? '<span class="generic_icons im_' . ($message['member']['online']['is_online'] ? 'on' : 'off') . ' centericon" title="' . ($message['member']['online']['is_online'] ? $txt['pm_online'] : $txt['pm_offline']) . '"></span> ' : ($message['member']['online']['is_online'] ? $txt['pm_online'] : $txt['pm_offline']), '</a></li>'; |
| 642 | + } |
|
| 608 | 643 | |
| 609 | 644 | // Show the email if necessary |
| 610 | - if (!empty($message['member']['email']) && $message['member']['show_email']) |
|
| 611 | - echo ' |
|
| 645 | + if (!empty($message['member']['email']) && $message['member']['show_email']) { |
|
| 646 | + echo ' |
|
| 612 | 647 | <li class="email"><a href="mailto:' . $message['member']['email'] . '" rel="nofollow">', ($settings['use_image_buttons'] ? '<span class="generic_icons mail centericon" title="' . $txt['email'] . '"></span>' : $txt['email']), '</a></li>'; |
| 648 | + } |
|
| 613 | 649 | |
| 614 | 650 | echo ' |
| 615 | 651 | </ol> |
@@ -617,58 +653,66 @@ discard block |
||
| 617 | 653 | } |
| 618 | 654 | |
| 619 | 655 | // Any custom fields for standard placement? |
| 620 | - if (!empty($message['custom_fields']['standard'])) |
|
| 621 | - foreach ($message['custom_fields']['standard'] as $custom) |
|
| 656 | + if (!empty($message['custom_fields']['standard'])) { |
|
| 657 | + foreach ($message['custom_fields']['standard'] as $custom) |
|
| 622 | 658 | echo ' |
| 623 | 659 | <li class="custom ', $custom['col_name'], '">', $custom['title'], ': ', $custom['value'], '</li>'; |
| 660 | + } |
|
| 624 | 661 | |
| 625 | 662 | } |
| 626 | 663 | // Otherwise, show the guest's email. |
| 627 | - elseif (!empty($message['member']['email']) && $message['member']['show_email']) |
|
| 628 | - echo ' |
|
| 664 | + elseif (!empty($message['member']['email']) && $message['member']['show_email']) { |
|
| 665 | + echo ' |
|
| 629 | 666 | <li class="email"> |
| 630 | 667 | <a href="mailto:' . $message['member']['email'] . '" rel="nofollow">', ($settings['use_image_buttons'] ? '<span class="generic_icons mail centericon" title="' . $txt['email'] . '"></span>' : $txt['email']), '</a> |
| 631 | 668 | </li>'; |
| 669 | + } |
|
| 632 | 670 | |
| 633 | 671 | // Show the IP to this user for this post - because you can moderate? |
| 634 | - if (!empty($context['can_moderate_forum']) && !empty($message['member']['ip'])) |
|
| 635 | - echo ' |
|
| 672 | + if (!empty($context['can_moderate_forum']) && !empty($message['member']['ip'])) { |
|
| 673 | + echo ' |
|
| 636 | 674 | <li class="poster_ip"> |
| 637 | 675 | <a href="', $scripturl, '?action=', !empty($message['member']['is_guest']) ? 'trackip' : 'profile;area=tracking;sa=ip;u=' . $message['member']['id'], ';searchip=', $message['member']['ip'], '">', $message['member']['ip'], '</a> <a href="', $scripturl, '?action=helpadmin;help=see_admin_ip" onclick="return reqOverlayDiv(this.href);" class="help">(?)</a> |
| 638 | 676 | </li>'; |
| 677 | + } |
|
| 639 | 678 | |
| 640 | 679 | // Or, should we show it because this is you? |
| 641 | - elseif ($message['can_see_ip']) |
|
| 642 | - echo ' |
|
| 680 | + elseif ($message['can_see_ip']) { |
|
| 681 | + echo ' |
|
| 643 | 682 | <li class="poster_ip"> |
| 644 | 683 | <a href="', $scripturl, '?action=helpadmin;help=see_member_ip" onclick="return reqOverlayDiv(this.href);" class="help">', $message['member']['ip'], '</a> |
| 645 | 684 | </li>'; |
| 685 | + } |
|
| 646 | 686 | |
| 647 | 687 | // Okay, are you at least logged in? Then we can show something about why IPs are logged... |
| 648 | - elseif (!$context['user']['is_guest']) |
|
| 649 | - echo ' |
|
| 688 | + elseif (!$context['user']['is_guest']) { |
|
| 689 | + echo ' |
|
| 650 | 690 | <li class="poster_ip"> |
| 651 | 691 | <a href="', $scripturl, '?action=helpadmin;help=see_member_ip" onclick="return reqOverlayDiv(this.href);" class="help">', $txt['logged'], '</a> |
| 652 | 692 | </li>'; |
| 693 | + } |
|
| 653 | 694 | |
| 654 | 695 | // Otherwise, you see NOTHING! |
| 655 | - else |
|
| 656 | - echo ' |
|
| 696 | + else { |
|
| 697 | + echo ' |
|
| 657 | 698 | <li class="poster_ip">', $txt['logged'], '</li>'; |
| 699 | + } |
|
| 658 | 700 | |
| 659 | 701 | // Are we showing the warning status? |
| 660 | 702 | // Don't show these things for guests. |
| 661 | - if (!$message['member']['is_guest'] && $message['member']['can_see_warning']) |
|
| 662 | - echo ' |
|
| 703 | + if (!$message['member']['is_guest'] && $message['member']['can_see_warning']) { |
|
| 704 | + echo ' |
|
| 663 | 705 | <li class="warning"> |
| 664 | 706 | ', $context['can_issue_warning'] ? '<a href="' . $scripturl . '?action=profile;area=issuewarning;u=' . $message['member']['id'] . '">' : '', '<span class="generic_icons warning_', $message['member']['warning_status'], '"></span> ', $context['can_issue_warning'] ? '</a>' : '', '<span class="warn_', $message['member']['warning_status'], '">', $txt['warn_' . $message['member']['warning_status']], '</span> |
| 665 | 707 | </li>'; |
| 708 | + } |
|
| 666 | 709 | |
| 667 | 710 | // Are there any custom fields to show at the bottom of the poster info? |
| 668 | - if (!empty($message['custom_fields']['bottom_poster'])) |
|
| 669 | - foreach ($message['custom_fields']['bottom_poster'] as $custom) |
|
| 711 | + if (!empty($message['custom_fields']['bottom_poster'])) { |
|
| 712 | + foreach ($message['custom_fields']['bottom_poster'] as $custom) |
|
| 670 | 713 | echo ' |
| 671 | 714 | <li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>'; |
| 715 | + } |
|
| 672 | 716 | |
| 673 | 717 | // Poster info ends. |
| 674 | 718 | echo ' |
@@ -698,9 +742,10 @@ discard block |
||
| 698 | 742 | echo ' |
| 699 | 743 | <span class="smalltext modified floatright', !empty($modSettings['show_modify']) && !empty($message['modified']['name']) ? ' mvisible' : '','" id="modified_', $message['id'], '">'; |
| 700 | 744 | |
| 701 | - if (!empty($modSettings['show_modify']) && !empty($message['modified']['name'])) |
|
| 702 | - echo |
|
| 745 | + if (!empty($modSettings['show_modify']) && !empty($message['modified']['name'])) { |
|
| 746 | + echo |
|
| 703 | 747 | $message['modified']['last_edit_text']; |
| 748 | + } |
|
| 704 | 749 | |
| 705 | 750 | echo ' |
| 706 | 751 | </span> |
@@ -709,22 +754,24 @@ discard block |
||
| 709 | 754 | </div><!-- .keyinfo -->'; |
| 710 | 755 | |
| 711 | 756 | // Ignoring this user? Hide the post. |
| 712 | - if ($ignoring) |
|
| 713 | - echo ' |
|
| 757 | + if ($ignoring) { |
|
| 758 | + echo ' |
|
| 714 | 759 | <div id="msg_', $message['id'], '_ignored_prompt"> |
| 715 | 760 | ', $txt['ignoring_user'], ' |
| 716 | 761 | <a href="#" id="msg_', $message['id'], '_ignored_link" style="display: none;">', $txt['show_ignore_user_post'], '</a> |
| 717 | 762 | </div>'; |
| 763 | + } |
|
| 718 | 764 | |
| 719 | 765 | // Show the post itself, finally! |
| 720 | 766 | echo ' |
| 721 | 767 | <div class="post">'; |
| 722 | 768 | |
| 723 | - if (!$message['approved'] && $message['member']['id'] != 0 && $message['member']['id'] == $context['user']['id']) |
|
| 724 | - echo ' |
|
| 769 | + if (!$message['approved'] && $message['member']['id'] != 0 && $message['member']['id'] == $context['user']['id']) { |
|
| 770 | + echo ' |
|
| 725 | 771 | <div class="approve_post"> |
| 726 | 772 | ', $txt['post_awaiting_approval'], ' |
| 727 | 773 | </div>'; |
| 774 | + } |
|
| 728 | 775 | echo ' |
| 729 | 776 | <div class="inner" data-msgid="', $message['id'], '" id="msg_', $message['id'], '"', $ignoring ? ' style="display:none;"' : '', '> |
| 730 | 777 | ', $message['body'], ' |
@@ -743,9 +790,9 @@ discard block |
||
| 743 | 790 | foreach ($message['attachment'] as $attachment) |
| 744 | 791 | { |
| 745 | 792 | // Do we want this attachment to not be showed here? |
| 746 | - if (!empty($modSettings['dont_show_attach_under_post']) && !empty($context['show_attach_under_post'][$attachment['id']])) |
|
| 747 | - continue; |
|
| 748 | - elseif (!$div_output) |
|
| 793 | + if (!empty($modSettings['dont_show_attach_under_post']) && !empty($context['show_attach_under_post'][$attachment['id']])) { |
|
| 794 | + continue; |
|
| 795 | + } elseif (!$div_output) |
|
| 749 | 796 | { |
| 750 | 797 | $div_output = true; |
| 751 | 798 | |
@@ -762,9 +809,10 @@ discard block |
||
| 762 | 809 | <legend> |
| 763 | 810 | ', $txt['attach_awaiting_approve']; |
| 764 | 811 | |
| 765 | - if ($context['can_approve']) |
|
| 766 | - echo ' |
|
| 812 | + if ($context['can_approve']) { |
|
| 813 | + echo ' |
|
| 767 | 814 | [<a href="', $scripturl, '?action=attachapprove;sa=all;mid=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['approve_all'], '</a>]'; |
| 815 | + } |
|
| 768 | 816 | |
| 769 | 817 | echo ' |
| 770 | 818 | </legend>'; |
@@ -778,12 +826,13 @@ discard block |
||
| 778 | 826 | echo ' |
| 779 | 827 | <div class="attachments_top">'; |
| 780 | 828 | |
| 781 | - if ($attachment['thumbnail']['has_thumb']) |
|
| 782 | - echo ' |
|
| 829 | + if ($attachment['thumbnail']['has_thumb']) { |
|
| 830 | + echo ' |
|
| 783 | 831 | <a href="', $attachment['href'], ';image" id="link_', $attachment['id'], '" onclick="', $attachment['thumbnail']['javascript'], '"><img src="', $attachment['thumbnail']['href'], '" alt="" id="thumb_', $attachment['id'], '" class="atc_img"></a>'; |
| 784 | - else |
|
| 785 | - echo ' |
|
| 832 | + } else { |
|
| 833 | + echo ' |
|
| 786 | 834 | <img src="' . $attachment['href'] . ';image" alt="" width="' . $attachment['width'] . '" height="' . $attachment['height'] . '" class="atc_img">'; |
| 835 | + } |
|
| 787 | 836 | |
| 788 | 837 | echo ' |
| 789 | 838 | </div><!-- .attachments_top -->'; |
@@ -793,9 +842,10 @@ discard block |
||
| 793 | 842 | <div class="attachments_bot"> |
| 794 | 843 | <a href="' . $attachment['href'] . '"><img src="' . $settings['images_url'] . '/icons/clip.png" class="centericon" alt="*"> ' . $attachment['name'] . '</a> '; |
| 795 | 844 | |
| 796 | - if (!$attachment['is_approved'] && $context['can_approve']) |
|
| 797 | - echo ' |
|
| 845 | + if (!$attachment['is_approved'] && $context['can_approve']) { |
|
| 846 | + echo ' |
|
| 798 | 847 | [<a href="', $scripturl, '?action=attachapprove;sa=approve;aid=', $attachment['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['approve'], '</a>] [<a href="', $scripturl, '?action=attachapprove;sa=reject;aid=', $attachment['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['delete'], '</a>] '; |
| 848 | + } |
|
| 799 | 849 | echo ' |
| 800 | 850 | <br>', $attachment['size'], ($attachment['is_image'] ? ', ' . $attachment['real_width'] . 'x' . $attachment['real_height'] . '<br>' . sprintf($txt['attach_viewed'], $attachment['downloads']) : '<br>' . sprintf($txt['attach_downloaded'], $attachment['downloads'])), ' |
| 801 | 851 | </div><!-- .attachments_bot -->'; |
@@ -804,35 +854,40 @@ discard block |
||
| 804 | 854 | </div><!-- .attached -->'; |
| 805 | 855 | |
| 806 | 856 | // Next attachment line ? |
| 807 | - if (++$i % $attachments_per_line === 0) |
|
| 808 | - echo ' |
|
| 857 | + if (++$i % $attachments_per_line === 0) { |
|
| 858 | + echo ' |
|
| 809 | 859 | <br>'; |
| 860 | + } |
|
| 810 | 861 | } |
| 811 | 862 | |
| 812 | 863 | // If we had unapproved attachments clean up. |
| 813 | - if ($last_approved_state == 0) |
|
| 814 | - echo ' |
|
| 864 | + if ($last_approved_state == 0) { |
|
| 865 | + echo ' |
|
| 815 | 866 | </fieldset>'; |
| 867 | + } |
|
| 816 | 868 | |
| 817 | 869 | // Only do this if we output a div above - otherwise it'll break things |
| 818 | - if ($div_output) |
|
| 819 | - echo ' |
|
| 870 | + if ($div_output) { |
|
| 871 | + echo ' |
|
| 820 | 872 | </div><!-- #msg_[id]_footer -->'; |
| 873 | + } |
|
| 821 | 874 | } |
| 822 | 875 | |
| 823 | 876 | // And stuff below the attachments. |
| 824 | - if ($context['can_report_moderator'] || !empty($modSettings['enable_likes']) || $message['can_approve'] || $message['can_unapprove'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg'] || $context['can_quote']) |
|
| 825 | - echo ' |
|
| 877 | + if ($context['can_report_moderator'] || !empty($modSettings['enable_likes']) || $message['can_approve'] || $message['can_unapprove'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg'] || $context['can_quote']) { |
|
| 878 | + echo ' |
|
| 826 | 879 | <div class="under_message">'; |
| 880 | + } |
|
| 827 | 881 | |
| 828 | 882 | // Maybe they want to report this post to the moderator(s)? |
| 829 | - if ($context['can_report_moderator']) |
|
| 830 | - echo ' |
|
| 883 | + if ($context['can_report_moderator']) { |
|
| 884 | + echo ' |
|
| 831 | 885 | <ul class="floatright smalltext"> |
| 832 | 886 | <li class="report_link"> |
| 833 | 887 | <a href="', $scripturl, '?action=reporttm;topic=', $context['current_topic'], '.', $message['counter'], ';msg=', $message['id'], '">', $txt['report_to_mod'], '</a> |
| 834 | 888 | </li> |
| 835 | 889 | </ul>'; |
| 890 | + } |
|
| 836 | 891 | |
| 837 | 892 | // What about likes? |
| 838 | 893 | if (!empty($modSettings['enable_likes'])) |
@@ -879,83 +934,95 @@ discard block |
||
| 879 | 934 | <ul class="quickbuttons">'; |
| 880 | 935 | |
| 881 | 936 | // Can they quote? if so they can select and quote as well! |
| 882 | - if ($context['can_quote']) |
|
| 883 | - echo ' |
|
| 937 | + if ($context['can_quote']) { |
|
| 938 | + echo ' |
|
| 884 | 939 | <li><a href="', $scripturl, '?action=post;quote=', $message['id'], ';topic=', $context['current_topic'], '.', $context['start'], ';last_msg=', $context['topic_last_message'], '" onclick="return oQuickReply.quote(', $message['id'], ');"><span class="generic_icons quote"></span>', $txt['quote_action'], '</a></li> |
| 885 | 940 | <li style="display:none;" id="quoteSelected_', $message['id'], '"> |
| 886 | 941 | <a href="javascript:void(0)"><span class="generic_icons quote_selected"></span>', $txt['quote_selected_action'], '</a> |
| 887 | 942 | </li>'; |
| 943 | + } |
|
| 888 | 944 | |
| 889 | 945 | // Can the user modify the contents of this post? Show the modify inline image. |
| 890 | - if ($message['can_modify']) |
|
| 891 | - echo ' |
|
| 946 | + if ($message['can_modify']) { |
|
| 947 | + echo ' |
|
| 892 | 948 | <li class="quick_edit"> |
| 893 | 949 | <a title="', $txt['modify_msg'], '" class="modifybutton" id="modify_button_', $message['id'], '" onclick="oQuickModify.modifyMsg(\'', $message['id'], '\', \'', !empty($modSettings['toggle_subject']), '\')"><span class="generic_icons quick_edit_button"></span>', $txt['quick_edit'], '</a> |
| 894 | 950 | </li>'; |
| 951 | + } |
|
| 895 | 952 | |
| 896 | - if ($message['can_approve'] || $message['can_unapprove'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg']) |
|
| 897 | - echo ' |
|
| 953 | + if ($message['can_approve'] || $message['can_unapprove'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg']) { |
|
| 954 | + echo ' |
|
| 898 | 955 | <li class="post_options">', $txt['post_options']; |
| 956 | + } |
|
| 899 | 957 | |
| 900 | 958 | echo ' |
| 901 | 959 | <ul>'; |
| 902 | 960 | |
| 903 | 961 | // Can the user modify the contents of this post? |
| 904 | - if ($message['can_modify']) |
|
| 905 | - echo ' |
|
| 962 | + if ($message['can_modify']) { |
|
| 963 | + echo ' |
|
| 906 | 964 | <li><a href="', $scripturl, '?action=post;msg=', $message['id'], ';topic=', $context['current_topic'], '.', $context['start'], '"><span class="generic_icons modify_button"></span>', $txt['modify'], '</a></li>'; |
| 965 | + } |
|
| 907 | 966 | |
| 908 | 967 | // How about... even... remove it entirely?! |
| 909 | - if ($context['can_delete'] && ($context['topic_first_message'] == $message['id'])) |
|
| 910 | - echo ' |
|
| 968 | + if ($context['can_delete'] && ($context['topic_first_message'] == $message['id'])) { |
|
| 969 | + echo ' |
|
| 911 | 970 | <li><a href="', $scripturl, '?action=removetopic2;topic=', $context['current_topic'], '.', $context['start'], ';', $context['session_var'], '=', $context['session_id'], '" data-confirm="', $txt['are_sure_remove_topic'], '" class="you_sure"><span class="generic_icons remove_button"></span>', $txt['remove_topic'], '</a></li>'; |
| 912 | - |
|
| 913 | - elseif ($message['can_remove'] && ($context['topic_first_message'] != $message['id'])) |
|
| 914 | - echo ' |
|
| 971 | + } elseif ($message['can_remove'] && ($context['topic_first_message'] != $message['id'])) { |
|
| 972 | + echo ' |
|
| 915 | 973 | <li><a href="', $scripturl, '?action=deletemsg;topic=', $context['current_topic'], '.', $context['start'], ';msg=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '" data-confirm="', $txt['remove_message_question'], '" class="you_sure"><span class="generic_icons remove_button"></span>', $txt['remove'], '</a></li>'; |
| 974 | + } |
|
| 916 | 975 | |
| 917 | 976 | // What about splitting it off the rest of the topic? |
| 918 | - if ($context['can_split'] && !empty($context['real_num_replies'])) |
|
| 919 | - echo ' |
|
| 977 | + if ($context['can_split'] && !empty($context['real_num_replies'])) { |
|
| 978 | + echo ' |
|
| 920 | 979 | <li><a href="', $scripturl, '?action=splittopics;topic=', $context['current_topic'], '.0;at=', $message['id'], '"><span class="generic_icons split_button"></span>', $txt['split'], '</a></li>'; |
| 980 | + } |
|
| 921 | 981 | |
| 922 | 982 | // Can we issue a warning because of this post? Remember, we can't give guests warnings. |
| 923 | - if ($context['can_issue_warning'] && !$message['is_message_author'] && !$message['member']['is_guest']) |
|
| 924 | - echo ' |
|
| 983 | + if ($context['can_issue_warning'] && !$message['is_message_author'] && !$message['member']['is_guest']) { |
|
| 984 | + echo ' |
|
| 925 | 985 | <li><a href="', $scripturl, '?action=profile;area=issuewarning;u=', $message['member']['id'], ';msg=', $message['id'], '"><span class="generic_icons warn_button"></span>', $txt['issue_warning'], '</a></li>'; |
| 986 | + } |
|
| 926 | 987 | |
| 927 | 988 | // Can we restore topics? |
| 928 | - if ($context['can_restore_msg']) |
|
| 929 | - echo ' |
|
| 989 | + if ($context['can_restore_msg']) { |
|
| 990 | + echo ' |
|
| 930 | 991 | <li><a href="', $scripturl, '?action=restoretopic;msgs=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="generic_icons restore_button"></span>', $txt['restore_message'], '</a></li>'; |
| 992 | + } |
|
| 931 | 993 | |
| 932 | 994 | // Maybe we can approve it, maybe we should? |
| 933 | - if ($message['can_approve']) |
|
| 934 | - echo ' |
|
| 995 | + if ($message['can_approve']) { |
|
| 996 | + echo ' |
|
| 935 | 997 | <li><a href="', $scripturl, '?action=moderate;area=postmod;sa=approve;topic=', $context['current_topic'], '.', $context['start'], ';msg=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="generic_icons approve_button"></span>', $txt['approve'], '</a></li>'; |
| 998 | + } |
|
| 936 | 999 | |
| 937 | 1000 | // Maybe we can unapprove it? |
| 938 | - if ($message['can_unapprove']) |
|
| 939 | - echo ' |
|
| 1001 | + if ($message['can_unapprove']) { |
|
| 1002 | + echo ' |
|
| 940 | 1003 | <li><a href="', $scripturl, '?action=moderate;area=postmod;sa=approve;topic=', $context['current_topic'], '.', $context['start'], ';msg=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="generic_icons unapprove_button"></span>', $txt['unapprove'], '</a></li>'; |
| 1004 | + } |
|
| 941 | 1005 | |
| 942 | 1006 | echo ' |
| 943 | 1007 | </ul> |
| 944 | 1008 | </li>'; |
| 945 | 1009 | |
| 946 | 1010 | // Show a checkbox for quick moderation? |
| 947 | - if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && $message['can_remove']) |
|
| 948 | - echo ' |
|
| 1011 | + if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && $message['can_remove']) { |
|
| 1012 | + echo ' |
|
| 949 | 1013 | <li style="display: none;" id="in_topic_mod_check_', $message['id'], '"></li>'; |
| 1014 | + } |
|
| 950 | 1015 | |
| 951 | - if ($message['can_approve'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg']) |
|
| 952 | - echo ' |
|
| 1016 | + if ($message['can_approve'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg']) { |
|
| 1017 | + echo ' |
|
| 953 | 1018 | </ul><!-- .quickbuttons -->'; |
| 1019 | + } |
|
| 954 | 1020 | } |
| 955 | 1021 | |
| 956 | - if ($context['can_report_moderator'] || !empty($modSettings['enable_likes']) || $message['can_approve'] || $message['can_unapprove'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg'] || $context['can_quote']) |
|
| 957 | - echo ' |
|
| 1022 | + if ($context['can_report_moderator'] || !empty($modSettings['enable_likes']) || $message['can_approve'] || $message['can_unapprove'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg'] || $context['can_quote']) { |
|
| 1023 | + echo ' |
|
| 958 | 1024 | </div><!-- .under_message -->'; |
| 1025 | + } |
|
| 959 | 1026 | |
| 960 | 1027 | echo ' |
| 961 | 1028 | </div><!-- .postarea --> |
@@ -968,9 +1035,10 @@ discard block |
||
| 968 | 1035 | <div class="custom_fields_above_signature"> |
| 969 | 1036 | <ul class="nolist">'; |
| 970 | 1037 | |
| 971 | - foreach ($message['custom_fields']['above_signature'] as $custom) |
|
| 972 | - echo ' |
|
| 1038 | + foreach ($message['custom_fields']['above_signature'] as $custom) { |
|
| 1039 | + echo ' |
|
| 973 | 1040 | <li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>'; |
| 1041 | + } |
|
| 974 | 1042 | |
| 975 | 1043 | echo ' |
| 976 | 1044 | </ul> |
@@ -978,11 +1046,12 @@ discard block |
||
| 978 | 1046 | } |
| 979 | 1047 | |
| 980 | 1048 | // Show the member's signature? |
| 981 | - if (!empty($message['member']['signature']) && empty($options['show_no_signatures']) && $context['signature_enabled']) |
|
| 982 | - echo ' |
|
| 1049 | + if (!empty($message['member']['signature']) && empty($options['show_no_signatures']) && $context['signature_enabled']) { |
|
| 1050 | + echo ' |
|
| 983 | 1051 | <div class="signature" id="msg_', $message['id'], '_signature"', $ignoring ? ' style="display:none;"' : '', '> |
| 984 | 1052 | ', $message['member']['signature'], ' |
| 985 | 1053 | </div>'; |
| 1054 | + } |
|
| 986 | 1055 | |
| 987 | 1056 | |
| 988 | 1057 | // Are there any custom profile fields for below the signature? |
@@ -992,9 +1061,10 @@ discard block |
||
| 992 | 1061 | <div class="custom_fields_below_signature"> |
| 993 | 1062 | <ul class="nolist">'; |
| 994 | 1063 | |
| 995 | - foreach ($message['custom_fields']['below_signature'] as $custom) |
|
| 996 | - echo ' |
|
| 1064 | + foreach ($message['custom_fields']['below_signature'] as $custom) { |
|
| 1065 | + echo ' |
|
| 997 | 1066 | <li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>'; |
| 1067 | + } |
|
| 998 | 1068 | |
| 999 | 1069 | echo ' |
| 1000 | 1070 | </ul> |
@@ -1044,8 +1114,8 @@ discard block |
||
| 1044 | 1114 | <input type="hidden" name="seqnum" value="', $context['form_sequence_number'], '">'; |
| 1045 | 1115 | |
| 1046 | 1116 | // Guests just need more. |
| 1047 | - if ($context['user']['is_guest']) |
|
| 1048 | - echo ' |
|
| 1117 | + if ($context['user']['is_guest']) { |
|
| 1118 | + echo ' |
|
| 1049 | 1119 | <dl id="post_header"> |
| 1050 | 1120 | <dt> |
| 1051 | 1121 | ', $txt['name'], ': |
@@ -1060,6 +1130,7 @@ discard block |
||
| 1060 | 1130 | <input type="email" name="email" size="25" value="', $context['email'], '" tabindex="', $context['tabindex']++, '" required> |
| 1061 | 1131 | </dd> |
| 1062 | 1132 | </dl>'; |
| 1133 | + } |
|
| 1063 | 1134 | |
| 1064 | 1135 | echo ' |
| 1065 | 1136 | ', template_control_richedit($context['post_box_name'], 'smileyBox_message', 'bbcBox_message'), ' |
@@ -1084,12 +1155,13 @@ discard block |
||
| 1084 | 1155 | </script>'; |
| 1085 | 1156 | |
| 1086 | 1157 | // Is visual verification enabled? |
| 1087 | - if ($context['require_verification']) |
|
| 1088 | - echo ' |
|
| 1158 | + if ($context['require_verification']) { |
|
| 1159 | + echo ' |
|
| 1089 | 1160 | <div class="post_verification"> |
| 1090 | 1161 | <strong>', $txt['verification'], ':</strong> |
| 1091 | 1162 | ', template_control_verification($context['visual_verification_id'], 'all'), ' |
| 1092 | 1163 | </div>'; |
| 1164 | + } |
|
| 1093 | 1165 | |
| 1094 | 1166 | // Finally, the submit buttons. |
| 1095 | 1167 | echo ' |
@@ -1105,8 +1177,8 @@ discard block |
||
| 1105 | 1177 | <br class="clear">'; |
| 1106 | 1178 | |
| 1107 | 1179 | // Draft autosave available and the user has it enabled? |
| 1108 | - if (!empty($context['drafts_autosave'])) |
|
| 1109 | - echo ' |
|
| 1180 | + if (!empty($context['drafts_autosave'])) { |
|
| 1181 | + echo ' |
|
| 1110 | 1182 | <script> |
| 1111 | 1183 | var oDraftAutoSave = new smf_DraftAutoSave({ |
| 1112 | 1184 | sSelf: \'oDraftAutoSave\', |
@@ -1118,12 +1190,14 @@ discard block |
||
| 1118 | 1190 | iFreq: ', (empty($modSettings['masterAutoSaveDraftsDelay']) ? 60000 : $modSettings['masterAutoSaveDraftsDelay'] * 1000), ' |
| 1119 | 1191 | }); |
| 1120 | 1192 | </script>'; |
| 1193 | + } |
|
| 1121 | 1194 | |
| 1122 | - if ($context['show_spellchecking']) |
|
| 1123 | - echo ' |
|
| 1195 | + if ($context['show_spellchecking']) { |
|
| 1196 | + echo ' |
|
| 1124 | 1197 | <form action="', $scripturl, '?action=spellcheck" method="post" accept-charset="', $context['character_set'], '" name="spell_form" id="spell_form" target="spellWindow"> |
| 1125 | 1198 | <input type="hidden" name="spellstring" value=""> |
| 1126 | 1199 | </form>'; |
| 1200 | + } |
|
| 1127 | 1201 | |
| 1128 | 1202 | echo ' |
| 1129 | 1203 | <script> |