@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | |
92 | 92 | $table = str_replace('{db_prefix}', $db_prefix, $table); |
93 | 93 | |
94 | - $pg_tables = array('pg_catalog','information_schema'); |
|
94 | + $pg_tables = array('pg_catalog', 'information_schema'); |
|
95 | 95 | |
96 | 96 | $request = $smcFunc['db_query']('', ' |
97 | 97 | SELECT pg_relation_size(C.oid) AS "size" |
@@ -289,7 +289,7 @@ discard block |
||
289 | 289 | { |
290 | 290 | static $ver; |
291 | 291 | |
292 | - if(!empty($ver)) |
|
292 | + if (!empty($ver)) |
|
293 | 293 | return $ver; |
294 | 294 | |
295 | 295 | global $smcFunc; |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 3 |
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_engine' => 'smf_db_get_engine', |
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 | |
@@ -289,8 +298,9 @@ discard block |
||
289 | 298 | { |
290 | 299 | static $ver; |
291 | 300 | |
292 | - if(!empty($ver)) |
|
293 | - return $ver; |
|
301 | + if(!empty($ver)) { |
|
302 | + return $ver; |
|
303 | + } |
|
294 | 304 | |
295 | 305 | global $smcFunc; |
296 | 306 |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | // Righty - let's do the damn thing! |
126 | 126 | $table_query = 'CREATE TABLE ' . $table_name . "\n" . '('; |
127 | 127 | foreach ($columns as $column) |
128 | - $table_query .= "\n\t" . smf_db_create_query_column($column) . ','; |
|
128 | + $table_query .= "\n\t" . smf_db_create_query_column($column) . ','; |
|
129 | 129 | |
130 | 130 | // Loop through the indexes next... |
131 | 131 | foreach ($indexes as $index) |
@@ -744,7 +744,7 @@ discard block |
||
744 | 744 | $type = $type . '(' . $size . ')'; |
745 | 745 | |
746 | 746 | // Now just put it together! |
747 | - return '`' .$column['name'] . '` ' . $type . ' ' . (!empty($unsigned) ? $unsigned : '') . (!empty($column['null']) ? '' : 'NOT NULL') . ' ' . $default; |
|
747 | + return '`' . $column['name'] . '` ' . $type . ' ' . (!empty($unsigned) ? $unsigned : '') . (!empty($column['null']) ? '' : 'NOT NULL') . ' ' . $default; |
|
748 | 748 | } |
749 | 749 | |
750 | 750 | ?> |
751 | 751 | \ No newline at end of file |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 3 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * Add the file functions to the $smcFunc array. |
@@ -52,8 +53,9 @@ discard block |
||
52 | 53 | 'messages', 'moderators', 'package_servers', 'permission_profiles', 'permissions', 'personal_messages', |
53 | 54 | 'pm_recipients', 'poll_choices', 'polls', 'scheduled_tasks', 'sessions', 'settings', 'smileys', |
54 | 55 | 'themes', 'topics'); |
55 | - foreach ($reservedTables as $k => $table_name) |
|
56 | - $reservedTables[$k] = strtolower($db_prefix . $table_name); |
|
56 | + foreach ($reservedTables as $k => $table_name) { |
|
57 | + $reservedTables[$k] = strtolower($db_prefix . $table_name); |
|
58 | + } |
|
57 | 59 | |
58 | 60 | // We in turn may need the extra stuff. |
59 | 61 | db_extend('extra'); |
@@ -105,8 +107,9 @@ discard block |
||
105 | 107 | $table_name = str_replace('{db_prefix}', $db_prefix, $table_name); |
106 | 108 | |
107 | 109 | // First - no way do we touch SMF tables. |
108 | - if (in_array(strtolower($table_name), $reservedTables)) |
|
109 | - return false; |
|
110 | + if (in_array(strtolower($table_name), $reservedTables)) { |
|
111 | + return false; |
|
112 | + } |
|
110 | 113 | |
111 | 114 | // Log that we'll want to remove this on uninstall. |
112 | 115 | $db_package_log[] = array('remove_table', $table_name); |
@@ -116,16 +119,18 @@ discard block |
||
116 | 119 | if (in_array($full_table_name, $tables)) |
117 | 120 | { |
118 | 121 | // This is a sad day... drop the table? If not, return false (error) by default. |
119 | - if ($if_exists == 'overwrite') |
|
120 | - $smcFunc['db_drop_table']($table_name); |
|
121 | - else |
|
122 | - return $if_exists == 'ignore'; |
|
122 | + if ($if_exists == 'overwrite') { |
|
123 | + $smcFunc['db_drop_table']($table_name); |
|
124 | + } else { |
|
125 | + return $if_exists == 'ignore'; |
|
126 | + } |
|
123 | 127 | } |
124 | 128 | |
125 | 129 | // Righty - let's do the damn thing! |
126 | 130 | $table_query = 'CREATE TABLE ' . $table_name . "\n" . '('; |
127 | - foreach ($columns as $column) |
|
128 | - $table_query .= "\n\t" . smf_db_create_query_column($column) . ','; |
|
131 | + foreach ($columns as $column) { |
|
132 | + $table_query .= "\n\t" . smf_db_create_query_column($column) . ','; |
|
133 | + } |
|
129 | 134 | |
130 | 135 | // Loop through the indexes next... |
131 | 136 | foreach ($indexes as $index) |
@@ -133,19 +138,21 @@ discard block |
||
133 | 138 | $columns = implode(',', $index['columns']); |
134 | 139 | |
135 | 140 | // Is it the primary? |
136 | - if (isset($index['type']) && $index['type'] == 'primary') |
|
137 | - $table_query .= "\n\t" . 'PRIMARY KEY (' . implode(',', $index['columns']) . '),'; |
|
138 | - else |
|
141 | + if (isset($index['type']) && $index['type'] == 'primary') { |
|
142 | + $table_query .= "\n\t" . 'PRIMARY KEY (' . implode(',', $index['columns']) . '),'; |
|
143 | + } else |
|
139 | 144 | { |
140 | - if (empty($index['name'])) |
|
141 | - $index['name'] = implode('_', $index['columns']); |
|
145 | + if (empty($index['name'])) { |
|
146 | + $index['name'] = implode('_', $index['columns']); |
|
147 | + } |
|
142 | 148 | $table_query .= "\n\t" . (isset($index['type']) && $index['type'] == 'unique' ? 'UNIQUE' : 'KEY') . ' ' . $index['name'] . ' (' . $columns . '),'; |
143 | 149 | } |
144 | 150 | } |
145 | 151 | |
146 | 152 | // No trailing commas! |
147 | - if (substr($table_query, -1) == ',') |
|
148 | - $table_query = substr($table_query, 0, -1); |
|
153 | + if (substr($table_query, -1) == ',') { |
|
154 | + $table_query = substr($table_query, 0, -1); |
|
155 | + } |
|
149 | 156 | |
150 | 157 | // Which engine do we want here? |
151 | 158 | if (empty($engines)) |
@@ -155,8 +162,9 @@ discard block |
||
155 | 162 | |
156 | 163 | while ($row = $smcFunc['db_fetch_assoc']($get_engines)) |
157 | 164 | { |
158 | - if ($row['Support'] == 'YES' || $row['Support'] == 'DEFAULT') |
|
159 | - $engines[] = $row['Engine']; |
|
165 | + if ($row['Support'] == 'YES' || $row['Support'] == 'DEFAULT') { |
|
166 | + $engines[] = $row['Engine']; |
|
167 | + } |
|
160 | 168 | } |
161 | 169 | |
162 | 170 | $smcFunc['db_free_result']($get_engines); |
@@ -170,8 +178,9 @@ discard block |
||
170 | 178 | } |
171 | 179 | |
172 | 180 | $table_query .= ') ENGINE=' . $parameters['engine']; |
173 | - if (!empty($db_character_set) && $db_character_set == 'utf8') |
|
174 | - $table_query .= ' DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci'; |
|
181 | + if (!empty($db_character_set) && $db_character_set == 'utf8') { |
|
182 | + $table_query .= ' DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci'; |
|
183 | + } |
|
175 | 184 | |
176 | 185 | // Create the table! |
177 | 186 | $smcFunc['db_query']('', $table_query, |
@@ -203,8 +212,9 @@ discard block |
||
203 | 212 | $table_name = str_replace('{db_prefix}', $db_prefix, $table_name); |
204 | 213 | |
205 | 214 | // God no - dropping one of these = bad. |
206 | - if (in_array(strtolower($table_name), $reservedTables)) |
|
207 | - return false; |
|
215 | + if (in_array(strtolower($table_name), $reservedTables)) { |
|
216 | + return false; |
|
217 | + } |
|
208 | 218 | |
209 | 219 | // Does it exist? |
210 | 220 | if (in_array($full_table_name, $smcFunc['db_list_tables']())) |
@@ -245,14 +255,16 @@ discard block |
||
245 | 255 | |
246 | 256 | // Does it exist - if so don't add it again! |
247 | 257 | $columns = $smcFunc['db_list_columns']($table_name, false); |
248 | - foreach ($columns as $column) |
|
249 | - if ($column == $column_info['name']) |
|
258 | + foreach ($columns as $column) { |
|
259 | + if ($column == $column_info['name']) |
|
250 | 260 | { |
251 | 261 | // If we're going to overwrite then use change column. |
252 | 262 | if ($if_exists == 'update') |
253 | 263 | return $smcFunc['db_change_column']($table_name, $column_info['name'], $column_info); |
254 | - else |
|
255 | - return false; |
|
264 | + } |
|
265 | + else { |
|
266 | + return false; |
|
267 | + } |
|
256 | 268 | } |
257 | 269 | |
258 | 270 | // Get the specifics... |
@@ -262,8 +274,9 @@ discard block |
||
262 | 274 | // Allow unsigned integers (mysql only) |
263 | 275 | $unsigned = in_array($type, array('int', 'tinyint', 'smallint', 'mediumint', 'bigint')) && !empty($column_info['unsigned']) ? 'unsigned ' : ''; |
264 | 276 | |
265 | - if ($size !== null) |
|
266 | - $type = $type . '(' . $size . ')'; |
|
277 | + if ($size !== null) { |
|
278 | + $type = $type . '(' . $size . ')'; |
|
279 | + } |
|
267 | 280 | |
268 | 281 | // Now add the thing! |
269 | 282 | $query = ' |
@@ -295,8 +308,8 @@ discard block |
||
295 | 308 | |
296 | 309 | // Does it exist? |
297 | 310 | $columns = $smcFunc['db_list_columns']($table_name, true); |
298 | - foreach ($columns as $column) |
|
299 | - if ($column['name'] == $column_name) |
|
311 | + foreach ($columns as $column) { |
|
312 | + if ($column['name'] == $column_name) |
|
300 | 313 | { |
301 | 314 | $smcFunc['db_query']('', ' |
302 | 315 | ALTER TABLE ' . $table_name . ' |
@@ -305,6 +318,7 @@ discard block |
||
305 | 318 | 'security_override' => true, |
306 | 319 | ) |
307 | 320 | ); |
321 | + } |
|
308 | 322 | |
309 | 323 | return true; |
310 | 324 | } |
@@ -331,37 +345,47 @@ discard block |
||
331 | 345 | // Check it does exist! |
332 | 346 | $columns = $smcFunc['db_list_columns']($table_name, true); |
333 | 347 | $old_info = null; |
334 | - foreach ($columns as $column) |
|
335 | - if ($column['name'] == $old_column) |
|
348 | + foreach ($columns as $column) { |
|
349 | + if ($column['name'] == $old_column) |
|
336 | 350 | $old_info = $column; |
351 | + } |
|
337 | 352 | |
338 | 353 | // Nothing? |
339 | - if ($old_info == null) |
|
340 | - return false; |
|
354 | + if ($old_info == null) { |
|
355 | + return false; |
|
356 | + } |
|
341 | 357 | |
342 | 358 | // Get the right bits. |
343 | - if (!isset($column_info['name'])) |
|
344 | - $column_info['name'] = $old_column; |
|
345 | - if (!isset($column_info['default'])) |
|
346 | - $column_info['default'] = $old_info['default']; |
|
347 | - if (!isset($column_info['null'])) |
|
348 | - $column_info['null'] = $old_info['null']; |
|
349 | - if (!isset($column_info['auto'])) |
|
350 | - $column_info['auto'] = $old_info['auto']; |
|
351 | - if (!isset($column_info['type'])) |
|
352 | - $column_info['type'] = $old_info['type']; |
|
353 | - if (!isset($column_info['size']) || !is_numeric($column_info['size'])) |
|
354 | - $column_info['size'] = $old_info['size']; |
|
355 | - if (!isset($column_info['unsigned']) || !in_array($column_info['type'], array('int', 'tinyint', 'smallint', 'mediumint', 'bigint'))) |
|
356 | - $column_info['unsigned'] = ''; |
|
359 | + if (!isset($column_info['name'])) { |
|
360 | + $column_info['name'] = $old_column; |
|
361 | + } |
|
362 | + if (!isset($column_info['default'])) { |
|
363 | + $column_info['default'] = $old_info['default']; |
|
364 | + } |
|
365 | + if (!isset($column_info['null'])) { |
|
366 | + $column_info['null'] = $old_info['null']; |
|
367 | + } |
|
368 | + if (!isset($column_info['auto'])) { |
|
369 | + $column_info['auto'] = $old_info['auto']; |
|
370 | + } |
|
371 | + if (!isset($column_info['type'])) { |
|
372 | + $column_info['type'] = $old_info['type']; |
|
373 | + } |
|
374 | + if (!isset($column_info['size']) || !is_numeric($column_info['size'])) { |
|
375 | + $column_info['size'] = $old_info['size']; |
|
376 | + } |
|
377 | + if (!isset($column_info['unsigned']) || !in_array($column_info['type'], array('int', 'tinyint', 'smallint', 'mediumint', 'bigint'))) { |
|
378 | + $column_info['unsigned'] = ''; |
|
379 | + } |
|
357 | 380 | |
358 | 381 | list ($type, $size) = $smcFunc['db_calculate_type']($column_info['type'], $column_info['size']); |
359 | 382 | |
360 | 383 | // Allow for unsigned integers (mysql only) |
361 | 384 | $unsigned = in_array($type, array('int', 'tinyint', 'smallint', 'mediumint', 'bigint')) && !empty($column_info['unsigned']) ? 'unsigned ' : ''; |
362 | 385 | |
363 | - if ($size !== null) |
|
364 | - $type = $type . '(' . $size . ')'; |
|
386 | + if ($size !== null) { |
|
387 | + $type = $type . '(' . $size . ')'; |
|
388 | + } |
|
365 | 389 | |
366 | 390 | $smcFunc['db_query']('', ' |
367 | 391 | ALTER TABLE ' . $table_name . ' |
@@ -391,21 +415,23 @@ discard block |
||
391 | 415 | $table_name = str_replace('{db_prefix}', $db_prefix, $table_name); |
392 | 416 | |
393 | 417 | // No columns = no index. |
394 | - if (empty($index_info['columns'])) |
|
395 | - return false; |
|
418 | + if (empty($index_info['columns'])) { |
|
419 | + return false; |
|
420 | + } |
|
396 | 421 | $columns = implode(',', $index_info['columns']); |
397 | 422 | |
398 | 423 | // No name - make it up! |
399 | 424 | if (empty($index_info['name'])) |
400 | 425 | { |
401 | 426 | // No need for primary. |
402 | - if (isset($index_info['type']) && $index_info['type'] == 'primary') |
|
403 | - $index_info['name'] = ''; |
|
404 | - else |
|
405 | - $index_info['name'] = implode('_', $index_info['columns']); |
|
427 | + if (isset($index_info['type']) && $index_info['type'] == 'primary') { |
|
428 | + $index_info['name'] = ''; |
|
429 | + } else { |
|
430 | + $index_info['name'] = implode('_', $index_info['columns']); |
|
431 | + } |
|
432 | + } else { |
|
433 | + $index_info['name'] = $index_info['name']; |
|
406 | 434 | } |
407 | - else |
|
408 | - $index_info['name'] = $index_info['name']; |
|
409 | 435 | |
410 | 436 | // Log that we are going to want to remove this! |
411 | 437 | $db_package_log[] = array('remove_index', $table_name, $index_info['name']); |
@@ -418,10 +444,11 @@ discard block |
||
418 | 444 | if ($index['name'] == $index_info['name'] || ($index['type'] == 'primary' && isset($index_info['type']) && $index_info['type'] == 'primary')) |
419 | 445 | { |
420 | 446 | // If we want to overwrite simply remove the current one then continue. |
421 | - if ($if_exists != 'update' || $index['type'] == 'primary') |
|
422 | - return false; |
|
423 | - else |
|
424 | - $smcFunc['db_remove_index']($table_name, $index_info['name']); |
|
447 | + if ($if_exists != 'update' || $index['type'] == 'primary') { |
|
448 | + return false; |
|
449 | + } else { |
|
450 | + $smcFunc['db_remove_index']($table_name, $index_info['name']); |
|
451 | + } |
|
425 | 452 | } |
426 | 453 | } |
427 | 454 | |
@@ -435,8 +462,7 @@ discard block |
||
435 | 462 | 'security_override' => true, |
436 | 463 | ) |
437 | 464 | ); |
438 | - } |
|
439 | - else |
|
465 | + } else |
|
440 | 466 | { |
441 | 467 | $smcFunc['db_query']('', ' |
442 | 468 | ALTER TABLE ' . $table_name . ' |
@@ -520,8 +546,7 @@ discard block |
||
520 | 546 | $types = array( |
521 | 547 | 'inet' => 'varbinary', |
522 | 548 | ); |
523 | - } |
|
524 | - else |
|
549 | + } else |
|
525 | 550 | { |
526 | 551 | $types = array( |
527 | 552 | 'varbinary' => 'inet', |
@@ -535,16 +560,15 @@ discard block |
||
535 | 560 | { |
536 | 561 | $type_size = 16; |
537 | 562 | $type_name = 'varbinary'; |
538 | - } |
|
539 | - elseif ($type_name == 'varbinary' && $reverse && $type_size == 16) |
|
563 | + } elseif ($type_name == 'varbinary' && $reverse && $type_size == 16) |
|
540 | 564 | { |
541 | 565 | $type_name = 'inet'; |
542 | 566 | $type_size = null; |
567 | + } elseif ($type_name == 'varbinary') { |
|
568 | + $type_name = 'varbinary'; |
|
569 | + } else { |
|
570 | + $type_name = $types[$type_name]; |
|
543 | 571 | } |
544 | - elseif ($type_name == 'varbinary') |
|
545 | - $type_name = 'varbinary'; |
|
546 | - else |
|
547 | - $type_name = $types[$type_name]; |
|
548 | 572 | } |
549 | 573 | |
550 | 574 | return array($type_name, $type_size); |
@@ -612,8 +636,7 @@ discard block |
||
612 | 636 | if (!$detail) |
613 | 637 | { |
614 | 638 | $columns[] = $row['Field']; |
615 | - } |
|
616 | - else |
|
639 | + } else |
|
617 | 640 | { |
618 | 641 | // Is there an auto_increment? |
619 | 642 | $auto = strpos($row['Extra'], 'auto_increment') !== false ? true : false; |
@@ -623,10 +646,10 @@ discard block |
||
623 | 646 | { |
624 | 647 | $type = $matches[1]; |
625 | 648 | $size = $matches[2]; |
626 | - if (!empty($matches[3]) && $matches[3] == 'unsigned') |
|
627 | - $unsigned = true; |
|
628 | - } |
|
629 | - else |
|
649 | + if (!empty($matches[3]) && $matches[3] == 'unsigned') { |
|
650 | + $unsigned = true; |
|
651 | + } |
|
652 | + } else |
|
630 | 653 | { |
631 | 654 | $type = $row['Type']; |
632 | 655 | $size = null; |
@@ -677,19 +700,20 @@ discard block |
||
677 | 700 | $indexes = array(); |
678 | 701 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
679 | 702 | { |
680 | - if (!$detail) |
|
681 | - $indexes[] = $row['Key_name']; |
|
682 | - else |
|
703 | + if (!$detail) { |
|
704 | + $indexes[] = $row['Key_name']; |
|
705 | + } else |
|
683 | 706 | { |
684 | 707 | // What is the type? |
685 | - if ($row['Key_name'] == 'PRIMARY') |
|
686 | - $type = 'primary'; |
|
687 | - elseif (empty($row['Non_unique'])) |
|
688 | - $type = 'unique'; |
|
689 | - elseif (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT') |
|
690 | - $type = 'fulltext'; |
|
691 | - else |
|
692 | - $type = 'index'; |
|
708 | + if ($row['Key_name'] == 'PRIMARY') { |
|
709 | + $type = 'primary'; |
|
710 | + } elseif (empty($row['Non_unique'])) { |
|
711 | + $type = 'unique'; |
|
712 | + } elseif (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT') { |
|
713 | + $type = 'fulltext'; |
|
714 | + } else { |
|
715 | + $type = 'index'; |
|
716 | + } |
|
693 | 717 | |
694 | 718 | // This is the first column we've seen? |
695 | 719 | if (empty($indexes[$row['Key_name']])) |
@@ -702,10 +726,11 @@ discard block |
||
702 | 726 | } |
703 | 727 | |
704 | 728 | // Is it a partial index? |
705 | - if (!empty($row['Sub_part'])) |
|
706 | - $indexes[$row['Key_name']]['columns'][] = $row['Column_name'] . '(' . $row['Sub_part'] . ')'; |
|
707 | - else |
|
708 | - $indexes[$row['Key_name']]['columns'][] = $row['Column_name']; |
|
729 | + if (!empty($row['Sub_part'])) { |
|
730 | + $indexes[$row['Key_name']]['columns'][] = $row['Column_name'] . '(' . $row['Sub_part'] . ')'; |
|
731 | + } else { |
|
732 | + $indexes[$row['Key_name']]['columns'][] = $row['Column_name']; |
|
733 | + } |
|
709 | 734 | } |
710 | 735 | } |
711 | 736 | $smcFunc['db_free_result']($result); |
@@ -727,11 +752,11 @@ discard block |
||
727 | 752 | if (!empty($column['auto'])) |
728 | 753 | { |
729 | 754 | $default = 'auto_increment'; |
755 | + } elseif (isset($column['default']) && $column['default'] !== null) { |
|
756 | + $default = 'default \'' . $smcFunc['db_escape_string']($column['default']) . '\''; |
|
757 | + } else { |
|
758 | + $default = ''; |
|
730 | 759 | } |
731 | - elseif (isset($column['default']) && $column['default'] !== null) |
|
732 | - $default = 'default \'' . $smcFunc['db_escape_string']($column['default']) . '\''; |
|
733 | - else |
|
734 | - $default = ''; |
|
735 | 760 | |
736 | 761 | // Sort out the size... and stuff... |
737 | 762 | $column['size'] = isset($column['size']) && is_numeric($column['size']) ? $column['size'] : null; |
@@ -740,8 +765,9 @@ discard block |
||
740 | 765 | // Allow unsigned integers (mysql only) |
741 | 766 | $unsigned = in_array($type, array('int', 'tinyint', 'smallint', 'mediumint', 'bigint')) && !empty($column['unsigned']) ? 'unsigned ' : ''; |
742 | 767 | |
743 | - if ($size !== null) |
|
744 | - $type = $type . '(' . $size . ')'; |
|
768 | + if ($size !== null) { |
|
769 | + $type = $type . '(' . $size . ')'; |
|
770 | + } |
|
745 | 771 | |
746 | 772 | // Now just put it together! |
747 | 773 | return '`' .$column['name'] . '` ' . $type . ' ' . (!empty($unsigned) ? $unsigned : '') . (!empty($column['null']) ? '' : 'NOT NULL') . ' ' . $default; |
@@ -518,7 +518,7 @@ |
||
518 | 518 | * @param array $parameters Not used? |
519 | 519 | * @param string $if_exists What to do if the index exists. If 'update', the definition will be updated. |
520 | 520 | * @param string $error |
521 | - * @return boolean Whether or not the operation was successful |
|
521 | + * @return false|null Whether or not the operation was successful |
|
522 | 522 | */ |
523 | 523 | function smf_db_add_index($table_name, $index_info, $parameters = array(), $if_exists = 'update', $error = 'fatal') |
524 | 524 | { |
@@ -515,7 +515,7 @@ |
||
515 | 515 | 'value' => $txt['scheduled_log_time_run'], |
516 | 516 | ), |
517 | 517 | 'data' => array( |
518 | - 'function' => function ($rowData) |
|
518 | + 'function' => function($rowData) |
|
519 | 519 | { |
520 | 520 | return timeformat($rowData['time_run'], true); |
521 | 521 | }, |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 3 |
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 | * Scheduled tasks management dispatcher. This function checks permissions and delegates |
@@ -40,10 +41,11 @@ discard block |
||
40 | 41 | ); |
41 | 42 | |
42 | 43 | // We need to find what's the action. |
43 | - if (isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']])) |
|
44 | - $context['sub_action'] = $_REQUEST['sa']; |
|
45 | - else |
|
46 | - $context['sub_action'] = 'tasks'; |
|
44 | + if (isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']])) { |
|
45 | + $context['sub_action'] = $_REQUEST['sa']; |
|
46 | + } else { |
|
47 | + $context['sub_action'] = 'tasks'; |
|
48 | + } |
|
47 | 49 | |
48 | 50 | // Now for the lovely tabs. That we all love. |
49 | 51 | $context[$context['admin_menu_name']]['tab_data'] = array( |
@@ -90,9 +92,10 @@ discard block |
||
90 | 92 | |
91 | 93 | // Enable and disable as required. |
92 | 94 | $enablers = array(0); |
93 | - foreach ($_POST['enable_task'] as $id => $enabled) |
|
94 | - if ($enabled) |
|
95 | + foreach ($_POST['enable_task'] as $id => $enabled) { |
|
96 | + if ($enabled) |
|
95 | 97 | $enablers[] = (int) $id; |
98 | + } |
|
96 | 99 | |
97 | 100 | // Do the update! |
98 | 101 | $smcFunc['db_query']('', ' |
@@ -130,8 +133,9 @@ discard block |
||
130 | 133 | |
131 | 134 | // Lets figure out which ones they want to run. |
132 | 135 | $tasks = array(); |
133 | - foreach ($_POST['run_task'] as $task => $dummy) |
|
134 | - $tasks[] = (int) $task; |
|
136 | + foreach ($_POST['run_task'] as $task => $dummy) { |
|
137 | + $tasks[] = (int) $task; |
|
138 | + } |
|
135 | 139 | |
136 | 140 | // Load up the tasks. |
137 | 141 | $request = $smcFunc['db_query']('', ' |
@@ -151,36 +155,41 @@ discard block |
||
151 | 155 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
152 | 156 | { |
153 | 157 | // What kind of task are we handling? |
154 | - if (!empty($row['callable'])) |
|
155 | - $task_string = $row['callable']; |
|
158 | + if (!empty($row['callable'])) { |
|
159 | + $task_string = $row['callable']; |
|
160 | + } |
|
156 | 161 | |
157 | 162 | // Default SMF task or old mods? |
158 | - elseif (function_exists('scheduled_' . $row['task'])) |
|
159 | - $task_string = 'scheduled_' . $row['task']; |
|
163 | + elseif (function_exists('scheduled_' . $row['task'])) { |
|
164 | + $task_string = 'scheduled_' . $row['task']; |
|
165 | + } |
|
160 | 166 | |
161 | 167 | // One last resource, the task name. |
162 | - elseif (!empty($row['task'])) |
|
163 | - $task_string = $row['task']; |
|
168 | + elseif (!empty($row['task'])) { |
|
169 | + $task_string = $row['task']; |
|
170 | + } |
|
164 | 171 | |
165 | 172 | $start_time = microtime(); |
166 | 173 | // The functions got to exist for us to use it. |
167 | - if (empty($task_string)) |
|
168 | - continue; |
|
174 | + if (empty($task_string)) { |
|
175 | + continue; |
|
176 | + } |
|
169 | 177 | |
170 | 178 | // Try to stop a timeout, this would be bad... |
171 | 179 | @set_time_limit(300); |
172 | - if (function_exists('apache_reset_timeout')) |
|
173 | - @apache_reset_timeout(); |
|
180 | + if (function_exists('apache_reset_timeout')) { |
|
181 | + @apache_reset_timeout(); |
|
182 | + } |
|
174 | 183 | |
175 | 184 | // Get the callable. |
176 | 185 | $callable_task = call_helper($task_string, true); |
177 | 186 | |
178 | 187 | // Perform the task. |
179 | - if (!empty($callable_task)) |
|
180 | - $completed = call_user_func($callable_task); |
|
181 | - |
|
182 | - else |
|
183 | - $completed = false; |
|
188 | + if (!empty($callable_task)) { |
|
189 | + $completed = call_user_func($callable_task); |
|
190 | + } else { |
|
191 | + $completed = false; |
|
192 | + } |
|
184 | 193 | |
185 | 194 | // Log that we did it ;) |
186 | 195 | if ($completed) |
@@ -197,8 +206,9 @@ discard block |
||
197 | 206 | $smcFunc['db_free_result']($request); |
198 | 207 | |
199 | 208 | // If we had any errors, push them to session so we can pick them up next time to tell the user. |
200 | - if (!empty($context['scheduled_errors'])) |
|
201 | - $_SESSION['st_error'] = $context['scheduled_errors']; |
|
209 | + if (!empty($context['scheduled_errors'])) { |
|
210 | + $_SESSION['st_error'] = $context['scheduled_errors']; |
|
211 | + } |
|
202 | 212 | |
203 | 213 | redirectexit('action=admin;area=scheduledtasks;done'); |
204 | 214 | } |
@@ -370,8 +380,9 @@ discard block |
||
370 | 380 | $context['server_time'] = timeformat(time(), false, 'server'); |
371 | 381 | |
372 | 382 | // Cleaning... |
373 | - if (!isset($_GET['tid'])) |
|
374 | - fatal_lang_error('no_access', false); |
|
383 | + if (!isset($_GET['tid'])) { |
|
384 | + fatal_lang_error('no_access', false); |
|
385 | + } |
|
375 | 386 | $_GET['tid'] = (int) $_GET['tid']; |
376 | 387 | |
377 | 388 | // Saving? |
@@ -387,10 +398,12 @@ discard block |
||
387 | 398 | preg_match('~(\d{1,2}):(\d{1,2})~', $_POST['offset'], $matches); |
388 | 399 | |
389 | 400 | // If a half is empty then assume zero offset! |
390 | - if (!isset($matches[2]) || $matches[2] > 59) |
|
391 | - $matches[2] = 0; |
|
392 | - if (!isset($matches[1]) || $matches[1] > 23) |
|
393 | - $matches[1] = 0; |
|
401 | + if (!isset($matches[2]) || $matches[2] > 59) { |
|
402 | + $matches[2] = 0; |
|
403 | + } |
|
404 | + if (!isset($matches[1]) || $matches[1] > 23) { |
|
405 | + $matches[1] = 0; |
|
406 | + } |
|
394 | 407 | |
395 | 408 | // Now the offset is easy; easy peasy - except we need to offset by a few hours... |
396 | 409 | $offset = $matches[1] * 3600 + $matches[2] * 60 - date('Z'); |
@@ -400,8 +413,9 @@ discard block |
||
400 | 413 | $unit = in_array(substr($_POST['unit'], 0, 1), array('m', 'h', 'd', 'w')) ? substr($_POST['unit'], 0, 1) : 'd'; |
401 | 414 | |
402 | 415 | // Don't allow one minute intervals. |
403 | - if ($interval == 1 && $unit == 'm') |
|
404 | - $interval = 2; |
|
416 | + if ($interval == 1 && $unit == 'm') { |
|
417 | + $interval = 2; |
|
418 | + } |
|
405 | 419 | |
406 | 420 | // Is it disabled? |
407 | 421 | $disabled = !isset($_POST['enabled']) ? 1 : 0; |
@@ -439,8 +453,9 @@ discard block |
||
439 | 453 | ); |
440 | 454 | |
441 | 455 | // Should never, ever, happen! |
442 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
443 | - fatal_lang_error('no_access', false); |
|
456 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
457 | + fatal_lang_error('no_access', false); |
|
458 | + } |
|
444 | 459 | |
445 | 460 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
446 | 461 | { |
@@ -598,13 +613,14 @@ discard block |
||
598 | 613 | ) |
599 | 614 | ); |
600 | 615 | $log_entries = array(); |
601 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
602 | - $log_entries[] = array( |
|
616 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
617 | + $log_entries[] = array( |
|
603 | 618 | 'id' => $row['id_log'], |
604 | 619 | 'name' => isset($txt['scheduled_task_' . $row['task']]) ? $txt['scheduled_task_' . $row['task']] : $row['task'], |
605 | 620 | 'time_run' => $row['time_run'], |
606 | 621 | 'time_taken' => $row['time_taken'], |
607 | 622 | ); |
623 | + } |
|
608 | 624 | $smcFunc['db_free_result']($request); |
609 | 625 | |
610 | 626 | return $log_entries; |
@@ -14,8 +14,9 @@ discard block |
||
14 | 14 | * @version 2.1 Beta 3 |
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 | * Show the calendar. |
@@ -47,12 +48,14 @@ discard block |
||
47 | 48 | 'post' => 'CalendarPost', |
48 | 49 | ); |
49 | 50 | |
50 | - if (isset($_GET['sa']) && isset($subActions[$_GET['sa']])) |
|
51 | - return call_helper($subActions[$_GET['sa']]); |
|
51 | + if (isset($_GET['sa']) && isset($subActions[$_GET['sa']])) { |
|
52 | + return call_helper($subActions[$_GET['sa']]); |
|
53 | + } |
|
52 | 54 | |
53 | 55 | // You can't do anything if the calendar is off. |
54 | - if (empty($modSettings['cal_enabled'])) |
|
55 | - fatal_lang_error('calendar_off', false); |
|
56 | + if (empty($modSettings['cal_enabled'])) { |
|
57 | + fatal_lang_error('calendar_off', false); |
|
58 | + } |
|
56 | 59 | |
57 | 60 | // This is gonna be needed... |
58 | 61 | loadTemplate('Calendar'); |
@@ -97,8 +100,9 @@ discard block |
||
97 | 100 | $context['view_week'] = isset($_GET['viewweek']); |
98 | 101 | |
99 | 102 | // Don't let search engines index weekly calendar pages. |
100 | - if ($context['view_week']) |
|
101 | - $context['robot_no_index'] = true; |
|
103 | + if ($context['view_week']) { |
|
104 | + $context['robot_no_index'] = true; |
|
105 | + } |
|
102 | 106 | |
103 | 107 | // Get the current day of month... |
104 | 108 | require_once($sourcedir . '/Subs-Calendar.php'); |
@@ -112,17 +116,20 @@ discard block |
||
112 | 116 | ); |
113 | 117 | |
114 | 118 | // Make sure the year and month are in valid ranges. |
115 | - if ($curPage['month'] < 1 || $curPage['month'] > 12) |
|
116 | - fatal_lang_error('invalid_month', false); |
|
117 | - if ($curPage['year'] < $modSettings['cal_minyear'] || $curPage['year'] > $modSettings['cal_maxyear']) |
|
118 | - fatal_lang_error('invalid_year', false); |
|
119 | + if ($curPage['month'] < 1 || $curPage['month'] > 12) { |
|
120 | + fatal_lang_error('invalid_month', false); |
|
121 | + } |
|
122 | + if ($curPage['year'] < $modSettings['cal_minyear'] || $curPage['year'] > $modSettings['cal_maxyear']) { |
|
123 | + fatal_lang_error('invalid_year', false); |
|
124 | + } |
|
119 | 125 | // If we have a day clean that too. |
120 | 126 | if ($context['view_week']) |
121 | 127 | { |
122 | 128 | // Note $isValid is -1 < PHP 5.1 |
123 | 129 | $isValid = mktime(0, 0, 0, $curPage['month'], $curPage['day'], $curPage['year']); |
124 | - if ($curPage['day'] > 31 || !$isValid || $isValid == -1) |
|
125 | - fatal_lang_error('invalid_day', false); |
|
130 | + if ($curPage['day'] > 31 || !$isValid || $isValid == -1) { |
|
131 | + fatal_lang_error('invalid_day', false); |
|
132 | + } |
|
126 | 133 | } |
127 | 134 | |
128 | 135 | // Load all the context information needed to show the calendar grid. |
@@ -144,21 +151,24 @@ discard block |
||
144 | 151 | ); |
145 | 152 | |
146 | 153 | // Load up the main view. |
147 | - if ($context['view_week']) |
|
148 | - $context['calendar_grid_main'] = getCalendarWeek($curPage['month'], $curPage['year'], $curPage['day'], $calendarOptions); |
|
149 | - else |
|
150 | - $context['calendar_grid_main'] = getCalendarGrid($curPage['month'], $curPage['year'], $calendarOptions); |
|
154 | + if ($context['view_week']) { |
|
155 | + $context['calendar_grid_main'] = getCalendarWeek($curPage['month'], $curPage['year'], $curPage['day'], $calendarOptions); |
|
156 | + } else { |
|
157 | + $context['calendar_grid_main'] = getCalendarGrid($curPage['month'], $curPage['year'], $calendarOptions); |
|
158 | + } |
|
151 | 159 | |
152 | 160 | // Load up the previous and next months. |
153 | 161 | $context['calendar_grid_current'] = getCalendarGrid($curPage['month'], $curPage['year'], $calendarOptions); |
154 | 162 | |
155 | 163 | // Only show previous month if it isn't pre-January of the min-year |
156 | - if ($context['calendar_grid_current']['previous_calendar']['year'] > $modSettings['cal_minyear'] || $curPage['month'] != 1) |
|
157 | - $context['calendar_grid_prev'] = getCalendarGrid($context['calendar_grid_current']['previous_calendar']['month'], $context['calendar_grid_current']['previous_calendar']['year'], $calendarOptions, true); |
|
164 | + if ($context['calendar_grid_current']['previous_calendar']['year'] > $modSettings['cal_minyear'] || $curPage['month'] != 1) { |
|
165 | + $context['calendar_grid_prev'] = getCalendarGrid($context['calendar_grid_current']['previous_calendar']['month'], $context['calendar_grid_current']['previous_calendar']['year'], $calendarOptions, true); |
|
166 | + } |
|
158 | 167 | |
159 | 168 | // Only show next month if it isn't post-December of the max-year |
160 | - if ($context['calendar_grid_current']['next_calendar']['year'] < $modSettings['cal_maxyear'] || $curPage['month'] != 12) |
|
161 | - $context['calendar_grid_next'] = getCalendarGrid($context['calendar_grid_current']['next_calendar']['month'], $context['calendar_grid_current']['next_calendar']['year'], $calendarOptions); |
|
169 | + if ($context['calendar_grid_current']['next_calendar']['year'] < $modSettings['cal_maxyear'] || $curPage['month'] != 12) { |
|
170 | + $context['calendar_grid_next'] = getCalendarGrid($context['calendar_grid_current']['next_calendar']['month'], $context['calendar_grid_current']['next_calendar']['year'], $calendarOptions); |
|
171 | + } |
|
162 | 172 | |
163 | 173 | // Basic template stuff. |
164 | 174 | $context['allow_calendar_event'] = allowedTo('calendar_post'); |
@@ -191,17 +201,19 @@ discard block |
||
191 | 201 | 'name' => $txt['months'][$context['current_month']] . ' ' . $context['current_year'] |
192 | 202 | ); |
193 | 203 | // If applicable, add the current week to the linktree. |
194 | - if ($context['view_week']) |
|
195 | - $context['linktree'][] = array( |
|
204 | + if ($context['view_week']) { |
|
205 | + $context['linktree'][] = array( |
|
196 | 206 | 'url' => $scripturl . '?action=calendar;viewweek;year=' . $context['current_year'] . ';month=' . $context['current_month'] . ';day=' . $context['current_day'], |
197 | 207 | 'name' => $context['calendar_grid_main']['week_title'], |
198 | 208 | ); |
209 | + } |
|
199 | 210 | |
200 | 211 | // Build the calendar button array. |
201 | 212 | $context['calendar_buttons'] = array(); |
202 | 213 | |
203 | - if ($context['can_post']) |
|
204 | - $context['calendar_buttons']['post_event'] = array('text' => 'calendar_post_event', 'image' => 'calendarpe.png', 'url' => $scripturl . '?action=calendar;sa=post;month=' . $context['current_month'] . ';year=' . $context['current_year'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
214 | + if ($context['can_post']) { |
|
215 | + $context['calendar_buttons']['post_event'] = array('text' => 'calendar_post_event', 'image' => 'calendarpe.png', 'url' => $scripturl . '?action=calendar;sa=post;month=' . $context['current_month'] . ';year=' . $context['current_year'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
216 | + } |
|
205 | 217 | |
206 | 218 | // Allow mods to add additional buttons here |
207 | 219 | call_integration_hook('integrate_calendar_buttons'); |
@@ -229,8 +241,9 @@ discard block |
||
229 | 241 | require_once($sourcedir . '/Subs-Calendar.php'); |
230 | 242 | |
231 | 243 | // Cast this for safety... |
232 | - if (isset($_REQUEST['eventid'])) |
|
233 | - $_REQUEST['eventid'] = (int) $_REQUEST['eventid']; |
|
244 | + if (isset($_REQUEST['eventid'])) { |
|
245 | + $_REQUEST['eventid'] = (int) $_REQUEST['eventid']; |
|
246 | + } |
|
234 | 247 | |
235 | 248 | // Submitting? |
236 | 249 | if (isset($_POST[$context['session_var']], $_REQUEST['eventid'])) |
@@ -238,12 +251,14 @@ discard block |
||
238 | 251 | checkSession(); |
239 | 252 | |
240 | 253 | // Validate the post... |
241 | - if (!isset($_POST['link_to_board'])) |
|
242 | - validateEventPost(); |
|
254 | + if (!isset($_POST['link_to_board'])) { |
|
255 | + validateEventPost(); |
|
256 | + } |
|
243 | 257 | |
244 | 258 | // If you're not allowed to edit any events, you have to be the poster. |
245 | - if ($_REQUEST['eventid'] > 0 && !allowedTo('calendar_edit_any')) |
|
246 | - isAllowedTo('calendar_edit_' . (!empty($user_info['id']) && getEventPoster($_REQUEST['eventid']) == $user_info['id'] ? 'own' : 'any')); |
|
259 | + if ($_REQUEST['eventid'] > 0 && !allowedTo('calendar_edit_any')) { |
|
260 | + isAllowedTo('calendar_edit_' . (!empty($user_info['id']) && getEventPoster($_REQUEST['eventid']) == $user_info['id'] ? 'own' : 'any')); |
|
261 | + } |
|
247 | 262 | |
248 | 263 | // New - and directing? |
249 | 264 | if (isset($_POST['link_to_board']) || empty($modSettings['cal_allow_unlinked'])) |
@@ -267,8 +282,9 @@ discard block |
||
267 | 282 | } |
268 | 283 | |
269 | 284 | // Deleting... |
270 | - elseif (isset($_REQUEST['deleteevent'])) |
|
271 | - removeEvent($_REQUEST['eventid']); |
|
285 | + elseif (isset($_REQUEST['deleteevent'])) { |
|
286 | + removeEvent($_REQUEST['eventid']); |
|
287 | + } |
|
272 | 288 | |
273 | 289 | // ... or just update it? |
274 | 290 | else |
@@ -315,13 +331,13 @@ discard block |
||
315 | 331 | 'span' => 1, |
316 | 332 | ); |
317 | 333 | $context['event']['last_day'] = (int) strftime('%d', mktime(0, 0, 0, $context['event']['month'] == 12 ? 1 : $context['event']['month'] + 1, 0, $context['event']['month'] == 12 ? $context['event']['year'] + 1 : $context['event']['year'])); |
318 | - } |
|
319 | - else |
|
334 | + } else |
|
320 | 335 | { |
321 | 336 | $context['event'] = getEventProperties($_REQUEST['eventid']); |
322 | 337 | |
323 | - if ($context['event'] === false) |
|
324 | - fatal_lang_error('no_access', false); |
|
338 | + if ($context['event'] === false) { |
|
339 | + fatal_lang_error('no_access', false); |
|
340 | + } |
|
325 | 341 | |
326 | 342 | // If it has a board, then they should be editing it within the topic. |
327 | 343 | if (!empty($context['event']['topic']['id']) && !empty($context['event']['topic']['first_msg'])) |
@@ -332,10 +348,11 @@ discard block |
||
332 | 348 | } |
333 | 349 | |
334 | 350 | // Make sure the user is allowed to edit this event. |
335 | - if ($context['event']['member'] != $user_info['id']) |
|
336 | - isAllowedTo('calendar_edit_any'); |
|
337 | - elseif (!allowedTo('calendar_edit_any')) |
|
338 | - isAllowedTo('calendar_edit_own'); |
|
351 | + if ($context['event']['member'] != $user_info['id']) { |
|
352 | + isAllowedTo('calendar_edit_any'); |
|
353 | + } elseif (!allowedTo('calendar_edit_any')) { |
|
354 | + isAllowedTo('calendar_edit_own'); |
|
355 | + } |
|
339 | 356 | } |
340 | 357 | |
341 | 358 | // Get list of boards that can be posted in. |
@@ -344,8 +361,7 @@ discard block |
||
344 | 361 | { |
345 | 362 | // You can post new events but can't link them to anything... |
346 | 363 | $context['event']['categories'] = array(); |
347 | - } |
|
348 | - else |
|
364 | + } else |
|
349 | 365 | { |
350 | 366 | // Load the list of boards and categories in the context. |
351 | 367 | require_once($sourcedir . '/Subs-MessageIndex.php'); |
@@ -383,12 +399,14 @@ discard block |
||
383 | 399 | global $smcFunc, $sourcedir, $forum_version, $modSettings, $webmaster_email, $mbname; |
384 | 400 | |
385 | 401 | // You can't export if the calendar export feature is off. |
386 | - if (empty($modSettings['cal_export'])) |
|
387 | - fatal_lang_error('calendar_export_off', false); |
|
402 | + if (empty($modSettings['cal_export'])) { |
|
403 | + fatal_lang_error('calendar_export_off', false); |
|
404 | + } |
|
388 | 405 | |
389 | 406 | // Goes without saying that this is required. |
390 | - if (!isset($_REQUEST['eventid'])) |
|
391 | - fatal_lang_error('no_access', false); |
|
407 | + if (!isset($_REQUEST['eventid'])) { |
|
408 | + fatal_lang_error('no_access', false); |
|
409 | + } |
|
392 | 410 | |
393 | 411 | // This is kinda wanted. |
394 | 412 | require_once($sourcedir . '/Subs-Calendar.php'); |
@@ -396,15 +414,17 @@ discard block |
||
396 | 414 | // Load up the event in question and check it exists. |
397 | 415 | $event = getEventProperties($_REQUEST['eventid']); |
398 | 416 | |
399 | - if ($event === false) |
|
400 | - fatal_lang_error('no_access', false); |
|
417 | + if ($event === false) { |
|
418 | + fatal_lang_error('no_access', false); |
|
419 | + } |
|
401 | 420 | |
402 | 421 | // Check the title isn't too long - iCal requires some formatting if so. |
403 | 422 | $title = str_split($event['title'], 30); |
404 | 423 | foreach ($title as $id => $line) |
405 | 424 | { |
406 | - if ($id != 0) |
|
407 | - $title[$id] = ' ' . $title[$id]; |
|
425 | + if ($id != 0) { |
|
426 | + $title[$id] = ' ' . $title[$id]; |
|
427 | + } |
|
408 | 428 | $title[$id] .= "\n"; |
409 | 429 | } |
410 | 430 | |
@@ -433,12 +453,14 @@ discard block |
||
433 | 453 | $filecontents .= 'DTSTART;VALUE=DATE:' . $datestart . "\n"; |
434 | 454 | |
435 | 455 | // more than one day |
436 | - if ($event['span'] > 1) |
|
437 | - $filecontents .= 'DTEND;VALUE=DATE:' . $dateend . "\n"; |
|
456 | + if ($event['span'] > 1) { |
|
457 | + $filecontents .= 'DTEND;VALUE=DATE:' . $dateend . "\n"; |
|
458 | + } |
|
438 | 459 | |
439 | 460 | // event has changed? advance the sequence for this UID |
440 | - if ($event['sequence'] > 0) |
|
441 | - $filecontents .= 'SEQUENCE:' . $event['sequence'] . "\n"; |
|
461 | + if ($event['sequence'] > 0) { |
|
462 | + $filecontents .= 'SEQUENCE:' . $event['sequence'] . "\n"; |
|
463 | + } |
|
442 | 464 | |
443 | 465 | $filecontents .= 'SUMMARY:' . implode('', $title); |
444 | 466 | $filecontents .= 'UID:' . $event['eventid'] . '@' . str_replace(' ', '-', $mbname) . "\n"; |
@@ -447,23 +469,26 @@ discard block |
||
447 | 469 | |
448 | 470 | // Send some standard headers. |
449 | 471 | ob_end_clean(); |
450 | - if (!empty($modSettings['enableCompressedOutput'])) |
|
451 | - @ob_start('ob_gzhandler'); |
|
452 | - else |
|
453 | - ob_start(); |
|
472 | + if (!empty($modSettings['enableCompressedOutput'])) { |
|
473 | + @ob_start('ob_gzhandler'); |
|
474 | + } else { |
|
475 | + ob_start(); |
|
476 | + } |
|
454 | 477 | |
455 | 478 | // Send the file headers |
456 | 479 | header('Pragma: '); |
457 | 480 | header('Cache-Control: no-cache'); |
458 | - if (!isBrowser('gecko')) |
|
459 | - header('Content-Transfer-Encoding: binary'); |
|
481 | + if (!isBrowser('gecko')) { |
|
482 | + header('Content-Transfer-Encoding: binary'); |
|
483 | + } |
|
460 | 484 | header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 525600 * 60) . ' GMT'); |
461 | 485 | header('Last-Modified: ' . gmdate('D, d M Y H:i:s', time()) . 'GMT'); |
462 | 486 | header('Accept-Ranges: bytes'); |
463 | 487 | header('Connection: close'); |
464 | 488 | header('Content-Disposition: attachment; filename="' . $event['title'] . '.ics"'); |
465 | - if (empty($modSettings['enableCompressedOutput'])) |
|
466 | - header('Content-Length: ' . $smcFunc['strlen']($filecontents)); |
|
489 | + if (empty($modSettings['enableCompressedOutput'])) { |
|
490 | + header('Content-Length: ' . $smcFunc['strlen']($filecontents)); |
|
491 | + } |
|
467 | 492 | |
468 | 493 | // This is a calendar item! |
469 | 494 | header('Content-Type: text/calendar'); |
@@ -502,20 +527,17 @@ discard block |
||
502 | 527 | $context['sub_template'] = 'bcd'; |
503 | 528 | $context['linktree'][] = array('url' => $scripturl . '?action=clock;bcd', 'name' => 'BCD'); |
504 | 529 | $context['clockicons'] = safe_unserialize(base64_decode('YTo2OntzOjI6ImgxIjthOjI6e2k6MDtpOjI7aToxO2k6MTt9czoyOiJoMiI7YTo0OntpOjA7aTo4O2k6MTtpOjQ7aToyO2k6MjtpOjM7aToxO31zOjI6Im0xIjthOjM6e2k6MDtpOjQ7aToxO2k6MjtpOjI7aToxO31zOjI6Im0yIjthOjQ6e2k6MDtpOjg7aToxO2k6NDtpOjI7aToyO2k6MztpOjE7fXM6MjoiczEiO2E6Mzp7aTowO2k6NDtpOjE7aToyO2k6MjtpOjE7fXM6MjoiczIiO2E6NDp7aTowO2k6ODtpOjE7aTo0O2k6MjtpOjI7aTozO2k6MTt9fQ==')); |
505 | - } |
|
506 | - elseif (!$omfg && !isset($_REQUEST['time'])) |
|
530 | + } elseif (!$omfg && !isset($_REQUEST['time'])) |
|
507 | 531 | { |
508 | 532 | $context['sub_template'] = 'hms'; |
509 | 533 | $context['linktree'][] = array('url' => $scripturl . '?action=clock', 'name' => 'Binary'); |
510 | 534 | $context['clockicons'] = safe_unserialize(base64_decode('YTozOntzOjE6ImgiO2E6NTp7aTowO2k6MTY7aToxO2k6ODtpOjI7aTo0O2k6MztpOjI7aTo0O2k6MTt9czoxOiJtIjthOjY6e2k6MDtpOjMyO2k6MTtpOjE2O2k6MjtpOjg7aTozO2k6NDtpOjQ7aToyO2k6NTtpOjE7fXM6MToicyI7YTo2OntpOjA7aTozMjtpOjE7aToxNjtpOjI7aTo4O2k6MztpOjQ7aTo0O2k6MjtpOjU7aToxO319')); |
511 | - } |
|
512 | - elseif ($omfg) |
|
535 | + } elseif ($omfg) |
|
513 | 536 | { |
514 | 537 | $context['sub_template'] = 'omfg'; |
515 | 538 | $context['linktree'][] = array('url' => $scripturl . '?action=clock;omfg', 'name' => 'OMFG'); |
516 | 539 | $context['clockicons'] = safe_unserialize(base64_decode('YTo2OntzOjQ6InllYXIiO2E6Nzp7aTowO2k6NjQ7aToxO2k6MzI7aToyO2k6MTY7aTozO2k6ODtpOjQ7aTo0O2k6NTtpOjI7aTo2O2k6MTt9czo1OiJtb250aCI7YTo0OntpOjA7aTo4O2k6MTtpOjQ7aToyO2k6MjtpOjM7aToxO31zOjM6ImRheSI7YTo1OntpOjA7aToxNjtpOjE7aTo4O2k6MjtpOjQ7aTozO2k6MjtpOjQ7aToxO31zOjQ6ImhvdXIiO2E6NTp7aTowO2k6MTY7aToxO2k6ODtpOjI7aTo0O2k6MztpOjI7aTo0O2k6MTt9czozOiJtaW4iO2E6Njp7aTowO2k6MzI7aToxO2k6MTY7aToyO2k6ODtpOjM7aTo0O2k6NDtpOjI7aTo1O2k6MTt9czozOiJzZWMiO2E6Njp7aTowO2k6MzI7aToxO2k6MTY7aToyO2k6ODtpOjM7aTo0O2k6NDtpOjI7aTo1O2k6MTt9fQ==')); |
517 | - } |
|
518 | - elseif (isset($_REQUEST['time'])) |
|
540 | + } elseif (isset($_REQUEST['time'])) |
|
519 | 541 | { |
520 | 542 | $context['sub_template'] = 'thetime'; |
521 | 543 | $time = getdate($_REQUEST['time'] == 'now' ? time() : (int) $_REQUEST['time']); |
@@ -575,12 +597,13 @@ discard block |
||
575 | 597 | ), |
576 | 598 | ); |
577 | 599 | |
578 | - foreach ($context['clockicons'] as $t => $vs) |
|
579 | - foreach ($vs as $v => $dumb) |
|
600 | + foreach ($context['clockicons'] as $t => $vs) { |
|
601 | + foreach ($vs as $v => $dumb) |
|
580 | 602 | { |
581 | 603 | if ($$t >= $v) |
582 | 604 | { |
583 | 605 | $$t -= $v; |
606 | + } |
|
584 | 607 | $context['clockicons'][$t][$v] = true; |
585 | 608 | } |
586 | 609 | } |
@@ -50,8 +50,8 @@ discard block |
||
50 | 50 | ) |
51 | 51 | ); |
52 | 52 | $members = array(); |
53 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
54 | - $members[$row['id_member']] = array( |
|
53 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
54 | + $members[$row['id_member']] = array( |
|
55 | 55 | 'id' => $row['id_member'], |
56 | 56 | 'real_name' => $row['real_name'], |
57 | 57 | 'email_address' => $row['email_address'], |
@@ -62,6 +62,7 @@ discard block |
||
62 | 62 | ), |
63 | 63 | 'lngfile' => $row['lngfile'], |
64 | 64 | ); |
65 | + } |
|
65 | 66 | $smcFunc['db_free_result']($request); |
66 | 67 | |
67 | 68 | return $members; |
@@ -83,13 +84,14 @@ discard block |
||
83 | 84 | |
84 | 85 | call_integration_hook('mention_insert_' . $content_type, array($content_id, &$members)); |
85 | 86 | |
86 | - foreach ($members as $member) |
|
87 | - $smcFunc['db_insert']('ignore', |
|
87 | + foreach ($members as $member) { |
|
88 | + $smcFunc['db_insert']('ignore', |
|
88 | 89 | '{db_prefix}mentions', |
89 | 90 | array('content_id' => 'int', 'content_type' => 'string', 'id_member' => 'int', 'id_mentioned' => 'int', 'time' => 'int'), |
90 | 91 | array((int) $content_id, $content_type, $id_member, $member['id'], time()), |
91 | 92 | array('content_id', 'content_type', 'id_mentioned') |
92 | 93 | ); |
94 | + } |
|
93 | 95 | } |
94 | 96 | |
95 | 97 | /** |
@@ -103,8 +105,9 @@ discard block |
||
103 | 105 | */ |
104 | 106 | public static function getBody($body, array $members) |
105 | 107 | { |
106 | - foreach ($members as $member) |
|
107 | - $body = str_ireplace(static::$char . $member['real_name'], '[member=' . $member['id'] . ']' . $member['real_name'] . '[/member]', $body); |
|
108 | + foreach ($members as $member) { |
|
109 | + $body = str_ireplace(static::$char . $member['real_name'], '[member=' . $member['id'] . ']' . $member['real_name'] . '[/member]', $body); |
|
110 | + } |
|
108 | 111 | |
109 | 112 | return $body; |
110 | 113 | } |
@@ -123,8 +126,9 @@ discard block |
||
123 | 126 | |
124 | 127 | $possible_names = self::getPossibleMentions($body); |
125 | 128 | |
126 | - if (empty($possible_names) || !allowedTo('mention')) |
|
127 | - return array(); |
|
129 | + if (empty($possible_names) || !allowedTo('mention')) { |
|
130 | + return array(); |
|
131 | + } |
|
128 | 132 | |
129 | 133 | $request = $smcFunc['db_query']('', ' |
130 | 134 | SELECT id_member, real_name |
@@ -140,8 +144,9 @@ discard block |
||
140 | 144 | $members = array(); |
141 | 145 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
142 | 146 | { |
143 | - if (stripos($body, static::$char . $row['real_name']) === false) |
|
144 | - continue; |
|
147 | + if (stripos($body, static::$char . $row['real_name']) === false) { |
|
148 | + continue; |
|
149 | + } |
|
145 | 150 | |
146 | 151 | $members[$row['id_member']] = array( |
147 | 152 | 'id' => $row['id_member'], |
@@ -185,8 +190,9 @@ discard block |
||
185 | 190 | $body = htmlspecialchars_decode(preg_replace('~<br\s*/?\>~', "\n", str_replace(' ', ' ', $body)), ENT_QUOTES); |
186 | 191 | |
187 | 192 | // Remove quotes, we don't want to get double mentions. |
188 | - while (preg_match('~\[quote[^\]]*\](.+?)\[\/quote\]~s', $body)) |
|
189 | - $body = preg_replace('~\[quote[^\]]*\](.+?)\[\/quote\]~s', '', $body); |
|
193 | + while (preg_match('~\[quote[^\]]*\](.+?)\[\/quote\]~s', $body)) { |
|
194 | + $body = preg_replace('~\[quote[^\]]*\](.+?)\[\/quote\]~s', '', $body); |
|
195 | + } |
|
190 | 196 | |
191 | 197 | $matches = array(); |
192 | 198 | $string = str_split($body); |
@@ -197,9 +203,9 @@ discard block |
||
197 | 203 | { |
198 | 204 | $depth++; |
199 | 205 | $matches[] = array(); |
206 | + } elseif ($char == "\n") { |
|
207 | + $depth = 0; |
|
200 | 208 | } |
201 | - elseif ($char == "\n") |
|
202 | - $depth = 0; |
|
203 | 209 | |
204 | 210 | for ($i = $depth; $i > 0; $i--) |
205 | 211 | { |
@@ -212,8 +218,9 @@ discard block |
||
212 | 218 | } |
213 | 219 | } |
214 | 220 | |
215 | - foreach ($matches as $k => $match) |
|
216 | - $matches[$k] = substr(implode('', $match), 1); |
|
221 | + foreach ($matches as $k => $match) { |
|
222 | + $matches[$k] = substr(implode('', $match), 1); |
|
223 | + } |
|
217 | 224 | |
218 | 225 | // Names can have spaces, other breaks, or they can't...we try to match every possible |
219 | 226 | // combination. |
@@ -223,8 +230,9 @@ discard block |
||
223 | 230 | $match = preg_split('/([^\w])/', $match, -1, PREG_SPLIT_DELIM_CAPTURE); |
224 | 231 | $count = count($match); |
225 | 232 | |
226 | - for ($i = 1; $i <= $count; $i++) |
|
227 | - $names[] = $smcFunc['htmlspecialchars']($smcFunc['htmltrim'](implode('', array_slice($match, 0, $i)))); |
|
233 | + for ($i = 1; $i <= $count; $i++) { |
|
234 | + $names[] = $smcFunc['htmlspecialchars']($smcFunc['htmltrim'](implode('', array_slice($match, 0, $i)))); |
|
235 | + } |
|
228 | 236 | } |
229 | 237 | |
230 | 238 | $names = array_unique($names); |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | // Get the report details. |
188 | 188 | $report = getReportDetails($report_id); |
189 | 189 | |
190 | - if(!$report) |
|
190 | + if (!$report) |
|
191 | 191 | fatal_lang_error('mc_no_modreport_found'); |
192 | 192 | |
193 | 193 | // Build the report data - basic details first, then extra stuff based on the type |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | if ($context['report_type'] == 'members') |
251 | 251 | { |
252 | 252 | // Find their ID in the serialized action string... |
253 | - $user_id_length = strlen((string)$context['report']['user']['id']); |
|
253 | + $user_id_length = strlen((string) $context['report']['user']['id']); |
|
254 | 254 | $member = 's:6:"member";s:' . $user_id_length . ':"' . $context['report']['user']['id'] . '";}'; |
255 | 255 | |
256 | 256 | $params = array( |
@@ -529,7 +529,7 @@ discard block |
||
529 | 529 | // What are we gonna do? |
530 | 530 | $action = isset($_GET['ignore']) ? 'ignore' : 'closed'; |
531 | 531 | |
532 | - validateToken('mod-report-'. $action, 'get'); |
|
532 | + validateToken('mod-report-' . $action, 'get'); |
|
533 | 533 | |
534 | 534 | // Are we ignore or "un-ignore"? "un-ignore" that's a funny word! |
535 | 535 | $value = (int) $_GET[$action]; |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 3 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * Sets and call a function based on the given subaction. Acts as a dispatcher function. |
@@ -54,8 +55,9 @@ discard block |
||
54 | 55 | ); |
55 | 56 | |
56 | 57 | // This comes under the umbrella of moderating posts. |
57 | - if ($context['report_type'] == 'members' || $user_info['mod_cache']['bq'] == '0=1') |
|
58 | - isAllowedTo('moderate_forum'); |
|
58 | + if ($context['report_type'] == 'members' || $user_info['mod_cache']['bq'] == '0=1') { |
|
59 | + isAllowedTo('moderate_forum'); |
|
60 | + } |
|
59 | 61 | |
60 | 62 | $subActions = array( |
61 | 63 | 'show' => 'ShowReports', |
@@ -70,11 +72,11 @@ discard block |
||
70 | 72 | call_integration_hook('integrate_reported_' . $context['report_type'], array(&$subActions)); |
71 | 73 | |
72 | 74 | // By default we call the open sub-action. |
73 | - if (isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']])) |
|
74 | - $context['sub_action'] = $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_REQUEST['sa']), ENT_QUOTES); |
|
75 | - |
|
76 | - else |
|
77 | - $context['sub_action'] = 'show'; |
|
75 | + if (isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']])) { |
|
76 | + $context['sub_action'] = $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_REQUEST['sa']), ENT_QUOTES); |
|
77 | + } else { |
|
78 | + $context['sub_action'] = 'show'; |
|
79 | + } |
|
78 | 80 | |
79 | 81 | // Hi Ho Silver Away! |
80 | 82 | call_helper($subActions[$context['sub_action']]); |
@@ -116,11 +118,13 @@ discard block |
||
116 | 118 | |
117 | 119 | // All the ones to update... |
118 | 120 | $toClose = array(); |
119 | - foreach ($_POST['close'] as $rid) |
|
120 | - $toClose[] = (int) $rid; |
|
121 | + foreach ($_POST['close'] as $rid) { |
|
122 | + $toClose[] = (int) $rid; |
|
123 | + } |
|
121 | 124 | |
122 | - if (!empty($toClose)) |
|
123 | - updateReport('closed', 1, $toClose); |
|
125 | + if (!empty($toClose)) { |
|
126 | + updateReport('closed', 1, $toClose); |
|
127 | + } |
|
124 | 128 | |
125 | 129 | // Set the confirmation message. |
126 | 130 | $_SESSION['rc_confirmation'] = 'close_all'; |
@@ -178,8 +182,9 @@ discard block |
||
178 | 182 | $reportComments = array(); |
179 | 183 | |
180 | 184 | // Have to at least give us something to work with. |
181 | - if (empty($_REQUEST['rid'])) |
|
182 | - fatal_lang_error('mc_reportedp_none_found'); |
|
185 | + if (empty($_REQUEST['rid'])) { |
|
186 | + fatal_lang_error('mc_reportedp_none_found'); |
|
187 | + } |
|
183 | 188 | |
184 | 189 | // Integers only please |
185 | 190 | $report_id = (int) $_REQUEST['rid']; |
@@ -187,8 +192,9 @@ discard block |
||
187 | 192 | // Get the report details. |
188 | 193 | $report = getReportDetails($report_id); |
189 | 194 | |
190 | - if(!$report) |
|
191 | - fatal_lang_error('mc_no_modreport_found'); |
|
195 | + if(!$report) { |
|
196 | + fatal_lang_error('mc_no_modreport_found'); |
|
197 | + } |
|
192 | 198 | |
193 | 199 | // Build the report data - basic details first, then extra stuff based on the type |
194 | 200 | $context['report'] = array( |
@@ -214,8 +220,7 @@ discard block |
||
214 | 220 | 'href' => $scripturl . '?action=profile;u=' . $report['id_user'], |
215 | 221 | ), |
216 | 222 | ); |
217 | - } |
|
218 | - else |
|
223 | + } else |
|
219 | 224 | { |
220 | 225 | $extraDetails = array( |
221 | 226 | 'topic_id' => $report['id_topic'], |
@@ -238,8 +243,9 @@ discard block |
||
238 | 243 | |
239 | 244 | $reportComments = getReportComments($report_id); |
240 | 245 | |
241 | - if (!empty($reportComments)) |
|
242 | - $context['report'] = array_merge($context['report'], $reportComments); |
|
246 | + if (!empty($reportComments)) { |
|
247 | + $context['report'] = array_merge($context['report'], $reportComments); |
|
248 | + } |
|
243 | 249 | |
244 | 250 | // What have the other moderators done to this message? |
245 | 251 | require_once($sourcedir . '/Modlog.php'); |
@@ -260,8 +266,7 @@ discard block |
||
260 | 266 | 1, |
261 | 267 | true, |
262 | 268 | ); |
263 | - } |
|
264 | - else |
|
269 | + } else |
|
265 | 270 | { |
266 | 271 | $params = array( |
267 | 272 | 'lm.id_topic = {int:id_topic} |
@@ -361,16 +366,16 @@ discard block |
||
361 | 366 | createList($listOptions); |
362 | 367 | |
363 | 368 | // Make sure to get the correct tab selected. |
364 | - if ($context['report']['closed']) |
|
365 | - $context[$context['moderation_menu_name']]['current_subsection'] = 'closed'; |
|
369 | + if ($context['report']['closed']) { |
|
370 | + $context[$context['moderation_menu_name']]['current_subsection'] = 'closed'; |
|
371 | + } |
|
366 | 372 | |
367 | 373 | // Finally we are done :P |
368 | 374 | if ($context['report_type'] == 'members') |
369 | 375 | { |
370 | 376 | $context['page_title'] = sprintf($txt['mc_viewmemberreport'], $context['report']['user']['name']); |
371 | 377 | $context['sub_template'] = 'viewmemberreport'; |
372 | - } |
|
373 | - else |
|
378 | + } else |
|
374 | 379 | { |
375 | 380 | $context['page_title'] = sprintf($txt['mc_viewmodreport'], $context['report']['subject'], $context['report']['author']['name']); |
376 | 381 | $context['sub_template'] = 'viewmodreport'; |
@@ -395,8 +400,9 @@ discard block |
||
395 | 400 | $comment = array(); |
396 | 401 | |
397 | 402 | // The report ID is a must. |
398 | - if (empty($_REQUEST['rid'])) |
|
399 | - fatal_lang_error('mc_reportedp_none_found'); |
|
403 | + if (empty($_REQUEST['rid'])) { |
|
404 | + fatal_lang_error('mc_reportedp_none_found'); |
|
405 | + } |
|
400 | 406 | |
401 | 407 | // Integers only please. |
402 | 408 | $report_id = (int) $_REQUEST['rid']; |
@@ -421,8 +427,9 @@ discard block |
||
421 | 427 | checkSession('get'); |
422 | 428 | validateToken('mod-reportC-delete', 'get'); |
423 | 429 | |
424 | - if (empty($_REQUEST['mid'])) |
|
425 | - fatal_lang_error('mc_reportedp_comment_none_found'); |
|
430 | + if (empty($_REQUEST['mid'])) { |
|
431 | + fatal_lang_error('mc_reportedp_comment_none_found'); |
|
432 | + } |
|
426 | 433 | |
427 | 434 | $comment_id = (int) $_REQUEST['mid']; |
428 | 435 | |
@@ -430,15 +437,17 @@ discard block |
||
430 | 437 | $comment = getCommentModDetails($comment_id); |
431 | 438 | |
432 | 439 | // Perhaps somebody else already deleted this fine gem... |
433 | - if (empty($comment)) |
|
434 | - fatal_lang_error('report_action_message_delete_issue'); |
|
440 | + if (empty($comment)) { |
|
441 | + fatal_lang_error('report_action_message_delete_issue'); |
|
442 | + } |
|
435 | 443 | |
436 | 444 | // Can you actually do this? |
437 | 445 | $comment_owner = $user_info['id'] == $comment['id_member']; |
438 | 446 | |
439 | 447 | // Nope! sorry. |
440 | - if (!allowedTo('admin_forum') && !$comment_owner) |
|
441 | - fatal_lang_error('report_action_message_delete_cannot'); |
|
448 | + if (!allowedTo('admin_forum') && !$comment_owner) { |
|
449 | + fatal_lang_error('report_action_message_delete_cannot'); |
|
450 | + } |
|
442 | 451 | |
443 | 452 | // All good! |
444 | 453 | deleteModComment($comment_id); |
@@ -465,11 +474,13 @@ discard block |
||
465 | 474 | checkSession(isset($_REQUEST['save']) ? 'post' : 'get'); |
466 | 475 | |
467 | 476 | // The report ID is a must. |
468 | - if (empty($_REQUEST['rid'])) |
|
469 | - fatal_lang_error('mc_reportedp_none_found'); |
|
477 | + if (empty($_REQUEST['rid'])) { |
|
478 | + fatal_lang_error('mc_reportedp_none_found'); |
|
479 | + } |
|
470 | 480 | |
471 | - if (empty($_REQUEST['mid'])) |
|
472 | - fatal_lang_error('mc_reportedp_comment_none_found'); |
|
481 | + if (empty($_REQUEST['mid'])) { |
|
482 | + fatal_lang_error('mc_reportedp_comment_none_found'); |
|
483 | + } |
|
473 | 484 | |
474 | 485 | // Integers only please. |
475 | 486 | $context['report_id'] = (int) $_REQUEST['rid']; |
@@ -477,8 +488,9 @@ discard block |
||
477 | 488 | |
478 | 489 | $context['comment'] = getCommentModDetails($context['comment_id']); |
479 | 490 | |
480 | - if (empty($context['comment'])) |
|
481 | - fatal_lang_error('mc_reportedp_comment_none_found'); |
|
491 | + if (empty($context['comment'])) { |
|
492 | + fatal_lang_error('mc_reportedp_comment_none_found'); |
|
493 | + } |
|
482 | 494 | |
483 | 495 | // Set up the comforting bits... |
484 | 496 | $context['page_title'] = $txt['mc_reported_posts']; |
@@ -489,15 +501,17 @@ discard block |
||
489 | 501 | validateToken('mod-reportC-edit'); |
490 | 502 | |
491 | 503 | // Make sure there is some data to edit on the DB. |
492 | - if (empty($context['comment'])) |
|
493 | - fatal_lang_error('report_action_message_edit_issue'); |
|
504 | + if (empty($context['comment'])) { |
|
505 | + fatal_lang_error('report_action_message_edit_issue'); |
|
506 | + } |
|
494 | 507 | |
495 | 508 | // Still there, good, now lets see if you can actually edit it... |
496 | 509 | $comment_owner = $user_info['id'] == $context['comment']['id_member']; |
497 | 510 | |
498 | 511 | // So, you aren't neither an admin or the comment owner huh? that's too bad. |
499 | - if (!allowedTo('admin_forum') && !$comment_owner) |
|
500 | - fatal_lang_error('report_action_message_edit_cannot'); |
|
512 | + if (!allowedTo('admin_forum') && !$comment_owner) { |
|
513 | + fatal_lang_error('report_action_message_edit_cannot'); |
|
514 | + } |
|
501 | 515 | |
502 | 516 | // All good! |
503 | 517 | $edited_comment = trim($smcFunc['htmlspecialchars']($_POST['mod_comment'])); |
@@ -523,8 +537,9 @@ discard block |
||
523 | 537 | checkSession('get'); |
524 | 538 | |
525 | 539 | // We need to do something! |
526 | - if (empty($_GET['rid']) && (!isset($_GET['ignore']) || !isset($_GET['closed']))) |
|
527 | - fatal_lang_error('mc_reportedp_none_found'); |
|
540 | + if (empty($_GET['rid']) && (!isset($_GET['ignore']) || !isset($_GET['closed']))) { |
|
541 | + fatal_lang_error('mc_reportedp_none_found'); |
|
542 | + } |
|
528 | 543 | |
529 | 544 | // What are we gonna do? |
530 | 545 | $action = isset($_GET['ignore']) ? 'ignore' : 'closed'; |
@@ -1326,7 +1326,7 @@ discard block |
||
1326 | 1326 | 'class' => 'centercol', |
1327 | 1327 | ), |
1328 | 1328 | 'data' => array( |
1329 | - 'function' => function ($rowData) |
|
1329 | + 'function' => function($rowData) |
|
1330 | 1330 | { |
1331 | 1331 | $isChecked = $rowData['disabled'] ? '' : ' checked'; |
1332 | 1332 | $onClickHandler = $rowData['can_show_register'] ? sprintf(' onclick="document.getElementById(\'reg_%1$s\').disabled = !this.checked;"', $rowData['id']) : ''; |
@@ -1342,7 +1342,7 @@ discard block |
||
1342 | 1342 | 'class' => 'centercol', |
1343 | 1343 | ), |
1344 | 1344 | 'data' => array( |
1345 | - 'function' => function ($rowData) |
|
1345 | + 'function' => function($rowData) |
|
1346 | 1346 | { |
1347 | 1347 | $isChecked = $rowData['on_register'] && !$rowData['disabled'] ? ' checked' : ''; |
1348 | 1348 | $isDisabled = $rowData['can_show_register'] ? '' : ' disabled'; |
@@ -1389,15 +1389,15 @@ discard block |
||
1389 | 1389 | 'value' => $txt['custom_profile_fieldorder'], |
1390 | 1390 | ), |
1391 | 1391 | 'data' => array( |
1392 | - 'function' => function ($rowData) use ($context, $txt, $scripturl) |
|
1392 | + 'function' => function($rowData) use ($context, $txt, $scripturl) |
|
1393 | 1393 | { |
1394 | - $return = '<p class="centertext bold_text">'. $rowData['field_order'] .'<br />'; |
|
1394 | + $return = '<p class="centertext bold_text">' . $rowData['field_order'] . '<br />'; |
|
1395 | 1395 | |
1396 | 1396 | if ($rowData['field_order'] > 1) |
1397 | - $return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=up"><span class="toggle_up" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_up'] .'"></span></a>'; |
|
1397 | + $return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=up"><span class="toggle_up" title="' . $txt['custom_edit_order_move'] . ' ' . $txt['custom_edit_order_up'] . '"></span></a>'; |
|
1398 | 1398 | |
1399 | 1399 | if ($rowData['field_order'] < $context['custFieldsMaxOrder']) |
1400 | - $return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=down"><span class="toggle_down" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_down'] .'"></span></a>'; |
|
1400 | + $return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=down"><span class="toggle_down" title="' . $txt['custom_edit_order_move'] . ' ' . $txt['custom_edit_order_down'] . '"></span></a>'; |
|
1401 | 1401 | |
1402 | 1402 | $return .= '</p>'; |
1403 | 1403 | |
@@ -1415,7 +1415,7 @@ discard block |
||
1415 | 1415 | 'value' => $txt['custom_profile_fieldname'], |
1416 | 1416 | ), |
1417 | 1417 | 'data' => array( |
1418 | - 'function' => function ($rowData) use ($scripturl) |
|
1418 | + 'function' => function($rowData) use ($scripturl) |
|
1419 | 1419 | { |
1420 | 1420 | return sprintf('<a href="%1$s?action=admin;area=featuresettings;sa=profileedit;fid=%2$d">%3$s</a><div class="smalltext">%4$s</div>', $scripturl, $rowData['id_field'], $rowData['field_name'], $rowData['field_desc']); |
1421 | 1421 | }, |
@@ -1431,7 +1431,7 @@ discard block |
||
1431 | 1431 | 'value' => $txt['custom_profile_fieldtype'], |
1432 | 1432 | ), |
1433 | 1433 | 'data' => array( |
1434 | - 'function' => function ($rowData) use ($txt) |
|
1434 | + 'function' => function($rowData) use ($txt) |
|
1435 | 1435 | { |
1436 | 1436 | $textKey = sprintf('custom_profile_type_%1$s', $rowData['field_type']); |
1437 | 1437 | return isset($txt[$textKey]) ? $txt[$textKey] : $textKey; |
@@ -1449,7 +1449,7 @@ discard block |
||
1449 | 1449 | 'value' => $txt['custom_profile_active'], |
1450 | 1450 | ), |
1451 | 1451 | 'data' => array( |
1452 | - 'function' => function ($rowData) use ($txt) |
|
1452 | + 'function' => function($rowData) use ($txt) |
|
1453 | 1453 | { |
1454 | 1454 | return $rowData['active'] ? $txt['yes'] : $txt['no']; |
1455 | 1455 | }, |
@@ -1466,7 +1466,7 @@ discard block |
||
1466 | 1466 | 'value' => $txt['custom_profile_placement'], |
1467 | 1467 | ), |
1468 | 1468 | 'data' => array( |
1469 | - 'function' => function ($rowData) |
|
1469 | + 'function' => function($rowData) |
|
1470 | 1470 | { |
1471 | 1471 | global $txt, $context; |
1472 | 1472 | |
@@ -1701,7 +1701,7 @@ discard block |
||
1701 | 1701 | redirectexit('action=admin;area=featuresettings;sa=profile'); // @todo implement an error handler |
1702 | 1702 | |
1703 | 1703 | // All good, proceed. |
1704 | - $smcFunc['db_query']('',' |
|
1704 | + $smcFunc['db_query']('', ' |
|
1705 | 1705 | UPDATE {db_prefix}custom_fields |
1706 | 1706 | SET field_order = {int:old_order} |
1707 | 1707 | WHERE field_order = {int:new_order}', |
@@ -1710,7 +1710,7 @@ discard block |
||
1710 | 1710 | 'old_order' => $context['field']['order'], |
1711 | 1711 | ) |
1712 | 1712 | ); |
1713 | - $smcFunc['db_query']('',' |
|
1713 | + $smcFunc['db_query']('', ' |
|
1714 | 1714 | UPDATE {db_prefix}custom_fields |
1715 | 1715 | SET field_order = {int:new_order} |
1716 | 1716 | WHERE id_field = {int:id_field}', |
@@ -1812,7 +1812,7 @@ discard block |
||
1812 | 1812 | $smcFunc['db_free_result']($request); |
1813 | 1813 | |
1814 | 1814 | $unique = false; |
1815 | - for ($i = 0; !$unique && $i < 9; $i ++) |
|
1815 | + for ($i = 0; !$unique && $i < 9; $i++) |
|
1816 | 1816 | { |
1817 | 1817 | if (!in_array($col_name, $current_fields)) |
1818 | 1818 | $unique = true; |
@@ -1985,7 +1985,7 @@ discard block |
||
1985 | 1985 | ); |
1986 | 1986 | |
1987 | 1987 | // Re-arrange the order. |
1988 | - $smcFunc['db_query']('',' |
|
1988 | + $smcFunc['db_query']('', ' |
|
1989 | 1989 | UPDATE {db_prefix}custom_fields |
1990 | 1990 | SET field_order = field_order - 1 |
1991 | 1991 | WHERE field_order > {int:current_order}', |
@@ -2249,7 +2249,7 @@ discard block |
||
2249 | 2249 | $context['token_check'] = 'noti-admin'; |
2250 | 2250 | |
2251 | 2251 | // Specify our action since we'll want to post back here instead of the profile |
2252 | - $context['action'] = 'action=admin;area=featuresettings;sa=alerts;'. $context['session_var'] .'='. $context['session_id']; |
|
2252 | + $context['action'] = 'action=admin;area=featuresettings;sa=alerts;' . $context['session_var'] . '=' . $context['session_id']; |
|
2253 | 2253 | |
2254 | 2254 | loadTemplate('Profile'); |
2255 | 2255 | loadLanguage('Profile'); |
@@ -14,8 +14,9 @@ discard block |
||
14 | 14 | * @version 2.1 Beta 3 |
15 | 15 | */ |
16 | 16 | |
17 | -if (!defined('SMF')) |
|
17 | +if (!defined('SMF')) { |
|
18 | 18 | die('No direct access...'); |
19 | +} |
|
19 | 20 | |
20 | 21 | /** |
21 | 22 | * This function makes sure the requested subaction does exists, if it doesn't, it sets a default action or. |
@@ -205,16 +206,18 @@ discard block |
||
205 | 206 | { |
206 | 207 | $all_zones = timezone_identifiers_list(); |
207 | 208 | // Make sure we set the value to the same as the printed value. |
208 | - foreach ($all_zones as $zone) |
|
209 | - $config_vars['default_timezone'][2][$zone] = $zone; |
|
209 | + foreach ($all_zones as $zone) { |
|
210 | + $config_vars['default_timezone'][2][$zone] = $zone; |
|
211 | + } |
|
212 | + } else { |
|
213 | + unset($config_vars['default_timezone']); |
|
210 | 214 | } |
211 | - else |
|
212 | - unset($config_vars['default_timezone']); |
|
213 | 215 | |
214 | 216 | call_integration_hook('integrate_modify_basic_settings', array(&$config_vars)); |
215 | 217 | |
216 | - if ($return_config) |
|
217 | - return $config_vars; |
|
218 | + if ($return_config) { |
|
219 | + return $config_vars; |
|
220 | + } |
|
218 | 221 | |
219 | 222 | // Saving? |
220 | 223 | if (isset($_GET['save'])) |
@@ -222,8 +225,9 @@ discard block |
||
222 | 225 | checkSession(); |
223 | 226 | |
224 | 227 | // Prevent absurd boundaries here - make it a day tops. |
225 | - if (isset($_POST['lastActive'])) |
|
226 | - $_POST['lastActive'] = min((int) $_POST['lastActive'], 1440); |
|
228 | + if (isset($_POST['lastActive'])) { |
|
229 | + $_POST['lastActive'] = min((int) $_POST['lastActive'], 1440); |
|
230 | + } |
|
227 | 231 | |
228 | 232 | call_integration_hook('integrate_save_basic_settings'); |
229 | 233 | |
@@ -268,8 +272,9 @@ discard block |
||
268 | 272 | |
269 | 273 | call_integration_hook('integrate_modify_bbc_settings', array(&$config_vars)); |
270 | 274 | |
271 | - if ($return_config) |
|
272 | - return $config_vars; |
|
275 | + if ($return_config) { |
|
276 | + return $config_vars; |
|
277 | + } |
|
273 | 278 | |
274 | 279 | // Setup the template. |
275 | 280 | require_once($sourcedir . '/ManageServer.php'); |
@@ -286,13 +291,15 @@ discard block |
||
286 | 291 | |
287 | 292 | // Clean up the tags. |
288 | 293 | $bbcTags = array(); |
289 | - foreach (parse_bbc(false) as $tag) |
|
290 | - $bbcTags[] = $tag['tag']; |
|
294 | + foreach (parse_bbc(false) as $tag) { |
|
295 | + $bbcTags[] = $tag['tag']; |
|
296 | + } |
|
291 | 297 | |
292 | - if (!isset($_POST['disabledBBC_enabledTags'])) |
|
293 | - $_POST['disabledBBC_enabledTags'] = array(); |
|
294 | - elseif (!is_array($_POST['disabledBBC_enabledTags'])) |
|
295 | - $_POST['disabledBBC_enabledTags'] = array($_POST['disabledBBC_enabledTags']); |
|
298 | + if (!isset($_POST['disabledBBC_enabledTags'])) { |
|
299 | + $_POST['disabledBBC_enabledTags'] = array(); |
|
300 | + } elseif (!is_array($_POST['disabledBBC_enabledTags'])) { |
|
301 | + $_POST['disabledBBC_enabledTags'] = array($_POST['disabledBBC_enabledTags']); |
|
302 | + } |
|
296 | 303 | // Work out what is actually disabled! |
297 | 304 | $_POST['disabledBBC'] = implode(',', array_diff($bbcTags, $_POST['disabledBBC_enabledTags'])); |
298 | 305 | |
@@ -336,8 +343,9 @@ discard block |
||
336 | 343 | |
337 | 344 | call_integration_hook('integrate_layout_settings', array(&$config_vars)); |
338 | 345 | |
339 | - if ($return_config) |
|
340 | - return $config_vars; |
|
346 | + if ($return_config) { |
|
347 | + return $config_vars; |
|
348 | + } |
|
341 | 349 | |
342 | 350 | // Saving? |
343 | 351 | if (isset($_GET['save'])) |
@@ -378,8 +386,9 @@ discard block |
||
378 | 386 | |
379 | 387 | call_integration_hook('integrate_likes_settings', array(&$config_vars)); |
380 | 388 | |
381 | - if ($return_config) |
|
382 | - return $config_vars; |
|
389 | + if ($return_config) { |
|
390 | + return $config_vars; |
|
391 | + } |
|
383 | 392 | |
384 | 393 | // Saving? |
385 | 394 | if (isset($_GET['save'])) |
@@ -417,8 +426,9 @@ discard block |
||
417 | 426 | |
418 | 427 | call_integration_hook('integrate_mentions_settings', array(&$config_vars)); |
419 | 428 | |
420 | - if ($return_config) |
|
421 | - return $config_vars; |
|
429 | + if ($return_config) { |
|
430 | + return $config_vars; |
|
431 | + } |
|
422 | 432 | |
423 | 433 | // Saving? |
424 | 434 | if (isset($_GET['save'])) |
@@ -462,8 +472,8 @@ discard block |
||
462 | 472 | 'enable' => array('check', 'warning_enable'), |
463 | 473 | ); |
464 | 474 | |
465 | - if (!empty($modSettings['warning_settings']) && $currently_enabled) |
|
466 | - $config_vars += array( |
|
475 | + if (!empty($modSettings['warning_settings']) && $currently_enabled) { |
|
476 | + $config_vars += array( |
|
467 | 477 | '', |
468 | 478 | array('int', 'warning_watch', 'subtext' => $txt['setting_warning_watch_note'] . ' ' . $txt['zero_to_disable']), |
469 | 479 | 'moderate' => array('int', 'warning_moderate', 'subtext' => $txt['setting_warning_moderate_note'] . ' ' . $txt['zero_to_disable']), |
@@ -472,15 +482,18 @@ discard block |
||
472 | 482 | 'rem2' => array('int', 'warning_decrement', 'subtext' => $txt['setting_warning_decrement_note'] . ' ' . $txt['zero_to_disable']), |
473 | 483 | array('permissions', 'view_warning'), |
474 | 484 | ); |
485 | + } |
|
475 | 486 | |
476 | 487 | call_integration_hook('integrate_warning_settings', array(&$config_vars)); |
477 | 488 | |
478 | - if ($return_config) |
|
479 | - return $config_vars; |
|
489 | + if ($return_config) { |
|
490 | + return $config_vars; |
|
491 | + } |
|
480 | 492 | |
481 | 493 | // Cannot use moderation if post moderation is not enabled. |
482 | - if (!$modSettings['postmod_active']) |
|
483 | - unset($config_vars['moderate']); |
|
494 | + if (!$modSettings['postmod_active']) { |
|
495 | + unset($config_vars['moderate']); |
|
496 | + } |
|
484 | 497 | |
485 | 498 | // Will need the utility functions from here. |
486 | 499 | require_once($sourcedir . '/ManageServer.php'); |
@@ -505,16 +518,16 @@ discard block |
||
505 | 518 | 'warning_watch' => 10, |
506 | 519 | 'warning_mute' => 60, |
507 | 520 | ); |
508 | - if ($modSettings['postmod_active']) |
|
509 | - $vars['warning_moderate'] = 35; |
|
521 | + if ($modSettings['postmod_active']) { |
|
522 | + $vars['warning_moderate'] = 35; |
|
523 | + } |
|
510 | 524 | |
511 | 525 | foreach ($vars as $var => $value) |
512 | 526 | { |
513 | 527 | $config_vars[] = array('int', $var); |
514 | 528 | $_POST[$var] = $value; |
515 | 529 | } |
516 | - } |
|
517 | - else |
|
530 | + } else |
|
518 | 531 | { |
519 | 532 | $_POST['warning_watch'] = min($_POST['warning_watch'], 100); |
520 | 533 | $_POST['warning_moderate'] = $modSettings['postmod_active'] ? min($_POST['warning_moderate'], 100) : 0; |
@@ -595,8 +608,9 @@ discard block |
||
595 | 608 | |
596 | 609 | call_integration_hook('integrate_spam_settings', array(&$config_vars)); |
597 | 610 | |
598 | - if ($return_config) |
|
599 | - return $config_vars; |
|
611 | + if ($return_config) { |
|
612 | + return $config_vars; |
|
613 | + } |
|
600 | 614 | |
601 | 615 | // You need to be an admin to edit settings! |
602 | 616 | isAllowedTo('admin_forum'); |
@@ -630,8 +644,9 @@ discard block |
||
630 | 644 | |
631 | 645 | if (empty($context['qa_by_lang'][strtr($language, array('-utf8' => ''))]) && !empty($context['question_answers'])) |
632 | 646 | { |
633 | - if (empty($context['settings_insert_above'])) |
|
634 | - $context['settings_insert_above'] = ''; |
|
647 | + if (empty($context['settings_insert_above'])) { |
|
648 | + $context['settings_insert_above'] = ''; |
|
649 | + } |
|
635 | 650 | |
636 | 651 | $context['settings_insert_above'] .= '<div class="noticebox">' . sprintf($txt['question_not_defined'], $context['languages'][$language]['name']) . '</div>'; |
637 | 652 | } |
@@ -674,8 +689,9 @@ discard block |
||
674 | 689 | $_POST['pm_spam_settings'] = (int) $_POST['max_pm_recipients'] . ',' . (int) $_POST['pm_posts_verification'] . ',' . (int) $_POST['pm_posts_per_hour']; |
675 | 690 | |
676 | 691 | // Hack in guest requiring verification! |
677 | - if (empty($_POST['posts_require_captcha']) && !empty($_POST['guests_require_captcha'])) |
|
678 | - $_POST['posts_require_captcha'] = -1; |
|
692 | + if (empty($_POST['posts_require_captcha']) && !empty($_POST['guests_require_captcha'])) { |
|
693 | + $_POST['posts_require_captcha'] = -1; |
|
694 | + } |
|
679 | 695 | |
680 | 696 | $save_vars = $config_vars; |
681 | 697 | unset($save_vars['pm1'], $save_vars['pm2'], $save_vars['pm3'], $save_vars['guest_verify']); |
@@ -692,14 +708,16 @@ discard block |
||
692 | 708 | foreach ($context['qa_languages'] as $lang_id => $dummy) |
693 | 709 | { |
694 | 710 | // If we had some questions for this language before, but don't now, delete everything from that language. |
695 | - if ((!isset($_POST['question'][$lang_id]) || !is_array($_POST['question'][$lang_id])) && !empty($context['qa_by_lang'][$lang_id])) |
|
696 | - $changes['delete'] = array_merge($questions['delete'], $context['qa_by_lang'][$lang_id]); |
|
711 | + if ((!isset($_POST['question'][$lang_id]) || !is_array($_POST['question'][$lang_id])) && !empty($context['qa_by_lang'][$lang_id])) { |
|
712 | + $changes['delete'] = array_merge($questions['delete'], $context['qa_by_lang'][$lang_id]); |
|
713 | + } |
|
697 | 714 | |
698 | 715 | // Now step through and see if any existing questions no longer exist. |
699 | - if (!empty($context['qa_by_lang'][$lang_id])) |
|
700 | - foreach ($context['qa_by_lang'][$lang_id] as $q_id) |
|
716 | + if (!empty($context['qa_by_lang'][$lang_id])) { |
|
717 | + foreach ($context['qa_by_lang'][$lang_id] as $q_id) |
|
701 | 718 | if (empty($_POST['question'][$lang_id][$q_id])) |
702 | 719 | $changes['delete'][] = $q_id; |
720 | + } |
|
703 | 721 | |
704 | 722 | // Now let's see if there are new questions or ones that need updating. |
705 | 723 | if (isset($_POST['question'][$lang_id])) |
@@ -708,14 +726,16 @@ discard block |
||
708 | 726 | { |
709 | 727 | // Ignore junky ids. |
710 | 728 | $q_id = (int) $q_id; |
711 | - if ($q_id <= 0) |
|
712 | - continue; |
|
729 | + if ($q_id <= 0) { |
|
730 | + continue; |
|
731 | + } |
|
713 | 732 | |
714 | 733 | // Check the question isn't empty (because they want to delete it?) |
715 | 734 | if (empty($question) || trim($question) == '') |
716 | 735 | { |
717 | - if (isset($context['question_answers'][$q_id])) |
|
718 | - $changes['delete'][] = $q_id; |
|
736 | + if (isset($context['question_answers'][$q_id])) { |
|
737 | + $changes['delete'][] = $q_id; |
|
738 | + } |
|
719 | 739 | continue; |
720 | 740 | } |
721 | 741 | $question = $smcFunc['htmlspecialchars'](trim($question)); |
@@ -723,19 +743,22 @@ discard block |
||
723 | 743 | // Get the answers. Firstly check there actually might be some. |
724 | 744 | if (!isset($_POST['answer'][$lang_id][$q_id]) || !is_array($_POST['answer'][$lang_id][$q_id])) |
725 | 745 | { |
726 | - if (isset($context['question_answers'][$q_id])) |
|
727 | - $changes['delete'][] = $q_id; |
|
746 | + if (isset($context['question_answers'][$q_id])) { |
|
747 | + $changes['delete'][] = $q_id; |
|
748 | + } |
|
728 | 749 | continue; |
729 | 750 | } |
730 | 751 | // Now get them and check that they might be viable. |
731 | 752 | $answers = array(); |
732 | - foreach ($_POST['answer'][$lang_id][$q_id] as $answer) |
|
733 | - if (!empty($answer) && trim($answer) !== '') |
|
753 | + foreach ($_POST['answer'][$lang_id][$q_id] as $answer) { |
|
754 | + if (!empty($answer) && trim($answer) !== '') |
|
734 | 755 | $answers[] = $smcFunc['htmlspecialchars'](trim($answer)); |
756 | + } |
|
735 | 757 | if (empty($answers)) |
736 | 758 | { |
737 | - if (isset($context['question_answers'][$q_id])) |
|
738 | - $changes['delete'][] = $q_id; |
|
759 | + if (isset($context['question_answers'][$q_id])) { |
|
760 | + $changes['delete'][] = $q_id; |
|
761 | + } |
|
739 | 762 | continue; |
740 | 763 | } |
741 | 764 | $answers = json_encode($answers); |
@@ -745,16 +768,17 @@ discard block |
||
745 | 768 | { |
746 | 769 | // New question. Now, we don't want to randomly consume ids, so we'll set those, rather than trusting the browser's supplied ids. |
747 | 770 | $changes['insert'][] = array($lang_id, $question, $answers); |
748 | - } |
|
749 | - else |
|
771 | + } else |
|
750 | 772 | { |
751 | 773 | // It's an existing question. Let's see what's changed, if anything. |
752 | - if ($lang_id != $context['question_answers'][$q_id]['lngfile'] || $question != $context['question_answers'][$q_id]['question'] || $answers != $context['question_answers'][$q_id]['answers']) |
|
753 | - $changes['replace'][$q_id] = array('lngfile' => $lang_id, 'question' => $question, 'answers' => $answers); |
|
774 | + if ($lang_id != $context['question_answers'][$q_id]['lngfile'] || $question != $context['question_answers'][$q_id]['question'] || $answers != $context['question_answers'][$q_id]['answers']) { |
|
775 | + $changes['replace'][$q_id] = array('lngfile' => $lang_id, 'question' => $question, 'answers' => $answers); |
|
776 | + } |
|
754 | 777 | } |
755 | 778 | |
756 | - if (!isset($qs_per_lang[$lang_id])) |
|
757 | - $qs_per_lang[$lang_id] = 0; |
|
779 | + if (!isset($qs_per_lang[$lang_id])) { |
|
780 | + $qs_per_lang[$lang_id] = 0; |
|
781 | + } |
|
758 | 782 | $qs_per_lang[$lang_id]++; |
759 | 783 | } |
760 | 784 | } |
@@ -804,8 +828,9 @@ discard block |
||
804 | 828 | |
805 | 829 | // Lastly, the count of messages needs to be no more than the lowest number of questions for any one language. |
806 | 830 | $count_questions = empty($qs_per_lang) ? 0 : min($qs_per_lang); |
807 | - if (empty($count_questions) || $_POST['qa_verification_number'] > $count_questions) |
|
808 | - $_POST['qa_verification_number'] = $count_questions; |
|
831 | + if (empty($count_questions) || $_POST['qa_verification_number'] > $count_questions) { |
|
832 | + $_POST['qa_verification_number'] = $count_questions; |
|
833 | + } |
|
809 | 834 | |
810 | 835 | call_integration_hook('integrate_save_spam_settings', array(&$save_vars)); |
811 | 836 | |
@@ -820,24 +845,27 @@ discard block |
||
820 | 845 | |
821 | 846 | $character_range = array_merge(range('A', 'H'), array('K', 'M', 'N', 'P', 'R'), range('T', 'Y')); |
822 | 847 | $_SESSION['visual_verification_code'] = ''; |
823 | - for ($i = 0; $i < 6; $i++) |
|
824 | - $_SESSION['visual_verification_code'] .= $character_range[array_rand($character_range)]; |
|
848 | + for ($i = 0; $i < 6; $i++) { |
|
849 | + $_SESSION['visual_verification_code'] .= $character_range[array_rand($character_range)]; |
|
850 | + } |
|
825 | 851 | |
826 | 852 | // Some javascript for CAPTCHA. |
827 | 853 | $context['settings_post_javascript'] = ''; |
828 | - if ($context['use_graphic_library']) |
|
829 | - $context['settings_post_javascript'] .= ' |
|
854 | + if ($context['use_graphic_library']) { |
|
855 | + $context['settings_post_javascript'] .= ' |
|
830 | 856 | function refreshImages() |
831 | 857 | { |
832 | 858 | var imageType = document.getElementById(\'visual_verification_type\').value; |
833 | 859 | document.getElementById(\'verification_image\').src = \'' . $context['verification_image_href'] . ';type=\' + imageType; |
834 | 860 | }'; |
861 | + } |
|
835 | 862 | |
836 | 863 | // Show the image itself, or text saying we can't. |
837 | - if ($context['use_graphic_library']) |
|
838 | - $config_vars['vv']['postinput'] = '<br><img src="' . $context['verification_image_href'] . ';type=' . (empty($modSettings['visual_verification_type']) ? 0 : $modSettings['visual_verification_type']) . '" alt="' . $txt['setting_image_verification_sample'] . '" id="verification_image"><br>'; |
|
839 | - else |
|
840 | - $config_vars['vv']['postinput'] = '<br><span class="smalltext">' . $txt['setting_image_verification_nogd'] . '</span>'; |
|
864 | + if ($context['use_graphic_library']) { |
|
865 | + $config_vars['vv']['postinput'] = '<br><img src="' . $context['verification_image_href'] . ';type=' . (empty($modSettings['visual_verification_type']) ? 0 : $modSettings['visual_verification_type']) . '" alt="' . $txt['setting_image_verification_sample'] . '" id="verification_image"><br>'; |
|
866 | + } else { |
|
867 | + $config_vars['vv']['postinput'] = '<br><span class="smalltext">' . $txt['setting_image_verification_nogd'] . '</span>'; |
|
868 | + } |
|
841 | 869 | |
842 | 870 | // Hack for PM spam settings. |
843 | 871 | list ($modSettings['max_pm_recipients'], $modSettings['pm_posts_verification'], $modSettings['pm_posts_per_hour']) = explode(',', $modSettings['pm_spam_settings']); |
@@ -847,9 +875,10 @@ discard block |
||
847 | 875 | $modSettings['posts_require_captcha'] = !isset($modSettings['posts_require_captcha']) || $modSettings['posts_require_captcha'] == -1 ? 0 : $modSettings['posts_require_captcha']; |
848 | 876 | |
849 | 877 | // Some minor javascript for the guest post setting. |
850 | - if ($modSettings['posts_require_captcha']) |
|
851 | - $context['settings_post_javascript'] .= ' |
|
878 | + if ($modSettings['posts_require_captcha']) { |
|
879 | + $context['settings_post_javascript'] .= ' |
|
852 | 880 | document.getElementById(\'guests_require_captcha\').disabled = true;'; |
881 | + } |
|
853 | 882 | |
854 | 883 | // And everything else. |
855 | 884 | $context['post_url'] = $scripturl . '?action=admin;area=antispam;save'; |
@@ -896,8 +925,9 @@ discard block |
||
896 | 925 | |
897 | 926 | call_integration_hook('integrate_signature_settings', array(&$config_vars)); |
898 | 927 | |
899 | - if ($return_config) |
|
900 | - return $config_vars; |
|
928 | + if ($return_config) { |
|
929 | + return $config_vars; |
|
930 | + } |
|
901 | 931 | |
902 | 932 | // Setup the template. |
903 | 933 | $context['page_title'] = $txt['signature_settings']; |
@@ -952,8 +982,9 @@ discard block |
||
952 | 982 | $sig = strtr($row['signature'], array('<br>' => "\n")); |
953 | 983 | |
954 | 984 | // Max characters... |
955 | - if (!empty($sig_limits[1])) |
|
956 | - $sig = $smcFunc['substr']($sig, 0, $sig_limits[1]); |
|
985 | + if (!empty($sig_limits[1])) { |
|
986 | + $sig = $smcFunc['substr']($sig, 0, $sig_limits[1]); |
|
987 | + } |
|
957 | 988 | // Max lines... |
958 | 989 | if (!empty($sig_limits[2])) |
959 | 990 | { |
@@ -963,8 +994,9 @@ discard block |
||
963 | 994 | if ($sig[$i] == "\n") |
964 | 995 | { |
965 | 996 | $count++; |
966 | - if ($count >= $sig_limits[2]) |
|
967 | - $sig = substr($sig, 0, $i) . strtr(substr($sig, $i), array("\n" => ' ')); |
|
997 | + if ($count >= $sig_limits[2]) { |
|
998 | + $sig = substr($sig, 0, $i) . strtr(substr($sig, $i), array("\n" => ' ')); |
|
999 | + } |
|
968 | 1000 | } |
969 | 1001 | } |
970 | 1002 | } |
@@ -975,17 +1007,19 @@ discard block |
||
975 | 1007 | { |
976 | 1008 | $limit_broke = 0; |
977 | 1009 | // Attempt to allow all sizes of abuse, so to speak. |
978 | - if ($matches[2][$ind] == 'px' && $size > $sig_limits[7]) |
|
979 | - $limit_broke = $sig_limits[7] . 'px'; |
|
980 | - elseif ($matches[2][$ind] == 'pt' && $size > ($sig_limits[7] * 0.75)) |
|
981 | - $limit_broke = ((int) $sig_limits[7] * 0.75) . 'pt'; |
|
982 | - elseif ($matches[2][$ind] == 'em' && $size > ((float) $sig_limits[7] / 16)) |
|
983 | - $limit_broke = ((float) $sig_limits[7] / 16) . 'em'; |
|
984 | - elseif ($matches[2][$ind] != 'px' && $matches[2][$ind] != 'pt' && $matches[2][$ind] != 'em' && $sig_limits[7] < 18) |
|
985 | - $limit_broke = 'large'; |
|
986 | - |
|
987 | - if ($limit_broke) |
|
988 | - $sig = str_replace($matches[0][$ind], '[size=' . $sig_limits[7] . 'px', $sig); |
|
1010 | + if ($matches[2][$ind] == 'px' && $size > $sig_limits[7]) { |
|
1011 | + $limit_broke = $sig_limits[7] . 'px'; |
|
1012 | + } elseif ($matches[2][$ind] == 'pt' && $size > ($sig_limits[7] * 0.75)) { |
|
1013 | + $limit_broke = ((int) $sig_limits[7] * 0.75) . 'pt'; |
|
1014 | + } elseif ($matches[2][$ind] == 'em' && $size > ((float) $sig_limits[7] / 16)) { |
|
1015 | + $limit_broke = ((float) $sig_limits[7] / 16) . 'em'; |
|
1016 | + } elseif ($matches[2][$ind] != 'px' && $matches[2][$ind] != 'pt' && $matches[2][$ind] != 'em' && $sig_limits[7] < 18) { |
|
1017 | + $limit_broke = 'large'; |
|
1018 | + } |
|
1019 | + |
|
1020 | + if ($limit_broke) { |
|
1021 | + $sig = str_replace($matches[0][$ind], '[size=' . $sig_limits[7] . 'px', $sig); |
|
1022 | + } |
|
989 | 1023 | } |
990 | 1024 | } |
991 | 1025 | |
@@ -1041,32 +1075,34 @@ discard block |
||
1041 | 1075 | $img_offset = false; |
1042 | 1076 | } |
1043 | 1077 | } |
1078 | + } else { |
|
1079 | + $replaces[$image] = ''; |
|
1044 | 1080 | } |
1045 | - else |
|
1046 | - $replaces[$image] = ''; |
|
1047 | 1081 | |
1048 | 1082 | continue; |
1049 | 1083 | } |
1050 | 1084 | |
1051 | 1085 | // Does it have predefined restraints? Width first. |
1052 | - if ($matches[6][$key]) |
|
1053 | - $matches[2][$key] = $matches[6][$key]; |
|
1086 | + if ($matches[6][$key]) { |
|
1087 | + $matches[2][$key] = $matches[6][$key]; |
|
1088 | + } |
|
1054 | 1089 | if ($matches[2][$key] && $sig_limits[5] && $matches[2][$key] > $sig_limits[5]) |
1055 | 1090 | { |
1056 | 1091 | $width = $sig_limits[5]; |
1057 | 1092 | $matches[4][$key] = $matches[4][$key] * ($width / $matches[2][$key]); |
1093 | + } elseif ($matches[2][$key]) { |
|
1094 | + $width = $matches[2][$key]; |
|
1058 | 1095 | } |
1059 | - elseif ($matches[2][$key]) |
|
1060 | - $width = $matches[2][$key]; |
|
1061 | 1096 | // ... and height. |
1062 | 1097 | if ($matches[4][$key] && $sig_limits[6] && $matches[4][$key] > $sig_limits[6]) |
1063 | 1098 | { |
1064 | 1099 | $height = $sig_limits[6]; |
1065 | - if ($width != -1) |
|
1066 | - $width = $width * ($height / $matches[4][$key]); |
|
1100 | + if ($width != -1) { |
|
1101 | + $width = $width * ($height / $matches[4][$key]); |
|
1102 | + } |
|
1103 | + } elseif ($matches[4][$key]) { |
|
1104 | + $height = $matches[4][$key]; |
|
1067 | 1105 | } |
1068 | - elseif ($matches[4][$key]) |
|
1069 | - $height = $matches[4][$key]; |
|
1070 | 1106 | |
1071 | 1107 | // If the dimensions are still not fixed - we need to check the actual image. |
1072 | 1108 | if (($width == -1 && $sig_limits[5]) || ($height == -1 && $sig_limits[6])) |
@@ -1084,12 +1120,13 @@ discard block |
||
1084 | 1120 | if ($sizes[1] > $sig_limits[6] && $sig_limits[6]) |
1085 | 1121 | { |
1086 | 1122 | $height = $sig_limits[6]; |
1087 | - if ($width == -1) |
|
1088 | - $width = $sizes[0]; |
|
1123 | + if ($width == -1) { |
|
1124 | + $width = $sizes[0]; |
|
1125 | + } |
|
1089 | 1126 | $width = $width * ($height / $sizes[1]); |
1127 | + } elseif ($width != -1) { |
|
1128 | + $height = $sizes[1]; |
|
1090 | 1129 | } |
1091 | - elseif ($width != -1) |
|
1092 | - $height = $sizes[1]; |
|
1093 | 1130 | } |
1094 | 1131 | } |
1095 | 1132 | |
@@ -1102,8 +1139,9 @@ discard block |
||
1102 | 1139 | // Record that we got one. |
1103 | 1140 | $image_count_holder[$image] = isset($image_count_holder[$image]) ? $image_count_holder[$image] + 1 : 1; |
1104 | 1141 | } |
1105 | - if (!empty($replaces)) |
|
1106 | - $sig = str_replace(array_keys($replaces), array_values($replaces), $sig); |
|
1142 | + if (!empty($replaces)) { |
|
1143 | + $sig = str_replace(array_keys($replaces), array_values($replaces), $sig); |
|
1144 | + } |
|
1107 | 1145 | } |
1108 | 1146 | } |
1109 | 1147 | // Try to fix disabled tags. |
@@ -1115,18 +1153,20 @@ discard block |
||
1115 | 1153 | |
1116 | 1154 | $sig = strtr($sig, array("\n" => '<br>')); |
1117 | 1155 | call_integration_hook('integrate_apply_signature_settings', array(&$sig, $sig_limits, $disabledTags)); |
1118 | - if ($sig != $row['signature']) |
|
1119 | - $changes[$row['id_member']] = $sig; |
|
1156 | + if ($sig != $row['signature']) { |
|
1157 | + $changes[$row['id_member']] = $sig; |
|
1158 | + } |
|
1159 | + } |
|
1160 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
1161 | + $done = true; |
|
1120 | 1162 | } |
1121 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
1122 | - $done = true; |
|
1123 | 1163 | $smcFunc['db_free_result']($request); |
1124 | 1164 | |
1125 | 1165 | // Do we need to delete what we have? |
1126 | 1166 | if (!empty($changes)) |
1127 | 1167 | { |
1128 | - foreach ($changes as $id => $sig) |
|
1129 | - $smcFunc['db_query']('', ' |
|
1168 | + foreach ($changes as $id => $sig) { |
|
1169 | + $smcFunc['db_query']('', ' |
|
1130 | 1170 | UPDATE {db_prefix}members |
1131 | 1171 | SET signature = {string:signature} |
1132 | 1172 | WHERE id_member = {int:id_member}', |
@@ -1135,11 +1175,13 @@ discard block |
||
1135 | 1175 | 'signature' => $sig, |
1136 | 1176 | ) |
1137 | 1177 | ); |
1178 | + } |
|
1138 | 1179 | } |
1139 | 1180 | |
1140 | 1181 | $_GET['step'] += 50; |
1141 | - if (!$done) |
|
1142 | - pauseSignatureApplySettings(); |
|
1182 | + if (!$done) { |
|
1183 | + pauseSignatureApplySettings(); |
|
1184 | + } |
|
1143 | 1185 | } |
1144 | 1186 | $settings_applied = true; |
1145 | 1187 | } |
@@ -1157,8 +1199,9 @@ discard block |
||
1157 | 1199 | ); |
1158 | 1200 | |
1159 | 1201 | // Temporarily make each setting a modSetting! |
1160 | - foreach ($context['signature_settings'] as $key => $value) |
|
1161 | - $modSettings['signature_' . $key] = $value; |
|
1202 | + foreach ($context['signature_settings'] as $key => $value) { |
|
1203 | + $modSettings['signature_' . $key] = $value; |
|
1204 | + } |
|
1162 | 1205 | |
1163 | 1206 | // Make sure we check the right tags! |
1164 | 1207 | $modSettings['bbc_disabled_signature_bbc'] = $disabledTags; |
@@ -1170,23 +1213,26 @@ discard block |
||
1170 | 1213 | |
1171 | 1214 | // Clean up the tag stuff! |
1172 | 1215 | $bbcTags = array(); |
1173 | - foreach (parse_bbc(false) as $tag) |
|
1174 | - $bbcTags[] = $tag['tag']; |
|
1216 | + foreach (parse_bbc(false) as $tag) { |
|
1217 | + $bbcTags[] = $tag['tag']; |
|
1218 | + } |
|
1175 | 1219 | |
1176 | - if (!isset($_POST['signature_bbc_enabledTags'])) |
|
1177 | - $_POST['signature_bbc_enabledTags'] = array(); |
|
1178 | - elseif (!is_array($_POST['signature_bbc_enabledTags'])) |
|
1179 | - $_POST['signature_bbc_enabledTags'] = array($_POST['signature_bbc_enabledTags']); |
|
1220 | + if (!isset($_POST['signature_bbc_enabledTags'])) { |
|
1221 | + $_POST['signature_bbc_enabledTags'] = array(); |
|
1222 | + } elseif (!is_array($_POST['signature_bbc_enabledTags'])) { |
|
1223 | + $_POST['signature_bbc_enabledTags'] = array($_POST['signature_bbc_enabledTags']); |
|
1224 | + } |
|
1180 | 1225 | |
1181 | 1226 | $sig_limits = array(); |
1182 | 1227 | foreach ($context['signature_settings'] as $key => $value) |
1183 | 1228 | { |
1184 | - if ($key == 'allow_smileys') |
|
1185 | - continue; |
|
1186 | - elseif ($key == 'max_smileys' && empty($_POST['signature_allow_smileys'])) |
|
1187 | - $sig_limits[] = -1; |
|
1188 | - else |
|
1189 | - $sig_limits[] = !empty($_POST['signature_' . $key]) ? max(1, (int) $_POST['signature_' . $key]) : 0; |
|
1229 | + if ($key == 'allow_smileys') { |
|
1230 | + continue; |
|
1231 | + } elseif ($key == 'max_smileys' && empty($_POST['signature_allow_smileys'])) { |
|
1232 | + $sig_limits[] = -1; |
|
1233 | + } else { |
|
1234 | + $sig_limits[] = !empty($_POST['signature_' . $key]) ? max(1, (int) $_POST['signature_' . $key]) : 0; |
|
1235 | + } |
|
1190 | 1236 | } |
1191 | 1237 | |
1192 | 1238 | call_integration_hook('integrate_save_signature_settings', array(&$sig_limits, &$bbcTags)); |
@@ -1219,12 +1265,14 @@ discard block |
||
1219 | 1265 | |
1220 | 1266 | // Try get more time... |
1221 | 1267 | @set_time_limit(600); |
1222 | - if (function_exists('apache_reset_timeout')) |
|
1223 | - @apache_reset_timeout(); |
|
1268 | + if (function_exists('apache_reset_timeout')) { |
|
1269 | + @apache_reset_timeout(); |
|
1270 | + } |
|
1224 | 1271 | |
1225 | 1272 | // Have we exhausted all the time we allowed? |
1226 | - if (time() - array_sum(explode(' ', $sig_start)) < 3) |
|
1227 | - return; |
|
1273 | + if (time() - array_sum(explode(' ', $sig_start)) < 3) { |
|
1274 | + return; |
|
1275 | + } |
|
1228 | 1276 | |
1229 | 1277 | $context['continue_get_data'] = '?action=admin;area=featuresettings;sa=sig;apply;step=' . $_GET['step'] . ';' . $context['session_var'] . '=' . $context['session_id']; |
1230 | 1278 | $context['page_title'] = $txt['not_done_title']; |
@@ -1270,9 +1318,10 @@ discard block |
||
1270 | 1318 | $disable_fields = array_flip($standard_fields); |
1271 | 1319 | if (!empty($_POST['active'])) |
1272 | 1320 | { |
1273 | - foreach ($_POST['active'] as $value) |
|
1274 | - if (isset($disable_fields[$value])) |
|
1321 | + foreach ($_POST['active'] as $value) { |
|
1322 | + if (isset($disable_fields[$value])) |
|
1275 | 1323 | unset($disable_fields[$value]); |
1324 | + } |
|
1276 | 1325 | } |
1277 | 1326 | // What we have left! |
1278 | 1327 | $changes['disabled_profile_fields'] = empty($disable_fields) ? '' : implode(',', array_keys($disable_fields)); |
@@ -1281,16 +1330,18 @@ discard block |
||
1281 | 1330 | $reg_fields = array(); |
1282 | 1331 | if (!empty($_POST['reg'])) |
1283 | 1332 | { |
1284 | - foreach ($_POST['reg'] as $value) |
|
1285 | - if (in_array($value, $standard_fields) && !isset($disable_fields[$value])) |
|
1333 | + foreach ($_POST['reg'] as $value) { |
|
1334 | + if (in_array($value, $standard_fields) && !isset($disable_fields[$value])) |
|
1286 | 1335 | $reg_fields[] = $value; |
1336 | + } |
|
1287 | 1337 | } |
1288 | 1338 | // What we have left! |
1289 | 1339 | $changes['registration_fields'] = empty($reg_fields) ? '' : implode(',', $reg_fields); |
1290 | 1340 | |
1291 | 1341 | $_SESSION['adm-save'] = true; |
1292 | - if (!empty($changes)) |
|
1293 | - updateSettings($changes); |
|
1342 | + if (!empty($changes)) { |
|
1343 | + updateSettings($changes); |
|
1344 | + } |
|
1294 | 1345 | } |
1295 | 1346 | |
1296 | 1347 | createToken('admin-scp'); |
@@ -1393,11 +1444,13 @@ discard block |
||
1393 | 1444 | { |
1394 | 1445 | $return = '<p class="centertext bold_text">'. $rowData['field_order'] .'<br />'; |
1395 | 1446 | |
1396 | - if ($rowData['field_order'] > 1) |
|
1397 | - $return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=up"><span class="toggle_up" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_up'] .'"></span></a>'; |
|
1447 | + if ($rowData['field_order'] > 1) { |
|
1448 | + $return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=up"><span class="toggle_up" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_up'] .'"></span></a>'; |
|
1449 | + } |
|
1398 | 1450 | |
1399 | - if ($rowData['field_order'] < $context['custFieldsMaxOrder']) |
|
1400 | - $return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=down"><span class="toggle_down" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_down'] .'"></span></a>'; |
|
1451 | + if ($rowData['field_order'] < $context['custFieldsMaxOrder']) { |
|
1452 | + $return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=down"><span class="toggle_down" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_down'] .'"></span></a>'; |
|
1453 | + } |
|
1401 | 1454 | |
1402 | 1455 | $return .= '</p>'; |
1403 | 1456 | |
@@ -1535,16 +1588,16 @@ discard block |
||
1535 | 1588 | $disabled_fields = isset($modSettings['disabled_profile_fields']) ? explode(',', $modSettings['disabled_profile_fields']) : array(); |
1536 | 1589 | $registration_fields = isset($modSettings['registration_fields']) ? explode(',', $modSettings['registration_fields']) : array(); |
1537 | 1590 | |
1538 | - foreach ($standard_fields as $field) |
|
1539 | - $list[] = array( |
|
1591 | + foreach ($standard_fields as $field) { |
|
1592 | + $list[] = array( |
|
1540 | 1593 | 'id' => $field, |
1541 | 1594 | 'label' => isset($txt['standard_profile_field_' . $field]) ? $txt['standard_profile_field_' . $field] : (isset($txt[$field]) ? $txt[$field] : $field), |
1542 | 1595 | 'disabled' => in_array($field, $disabled_fields), |
1543 | 1596 | 'on_register' => in_array($field, $registration_fields) && !in_array($field, $fields_no_registration), |
1544 | 1597 | 'can_show_register' => !in_array($field, $fields_no_registration), |
1545 | 1598 | ); |
1546 | - } |
|
1547 | - else |
|
1599 | + } |
|
1600 | + } else |
|
1548 | 1601 | { |
1549 | 1602 | // Load all the fields. |
1550 | 1603 | $request = $smcFunc['db_query']('', ' |
@@ -1558,8 +1611,9 @@ discard block |
||
1558 | 1611 | 'items_per_page' => $items_per_page, |
1559 | 1612 | ) |
1560 | 1613 | ); |
1561 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1562 | - $list[] = $row; |
|
1614 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1615 | + $list[] = $row; |
|
1616 | + } |
|
1563 | 1617 | $smcFunc['db_free_result']($request); |
1564 | 1618 | } |
1565 | 1619 | |
@@ -1625,9 +1679,9 @@ discard block |
||
1625 | 1679 | $context['field'] = array(); |
1626 | 1680 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1627 | 1681 | { |
1628 | - if ($row['field_type'] == 'textarea') |
|
1629 | - @list ($rows, $cols) = @explode(',', $row['default_value']); |
|
1630 | - else |
|
1682 | + if ($row['field_type'] == 'textarea') { |
|
1683 | + @list ($rows, $cols) = @explode(',', $row['default_value']); |
|
1684 | + } else |
|
1631 | 1685 | { |
1632 | 1686 | $rows = 3; |
1633 | 1687 | $cols = 30; |
@@ -1663,8 +1717,8 @@ discard block |
||
1663 | 1717 | } |
1664 | 1718 | |
1665 | 1719 | // Setup the default values as needed. |
1666 | - if (empty($context['field'])) |
|
1667 | - $context['field'] = array( |
|
1720 | + if (empty($context['field'])) { |
|
1721 | + $context['field'] = array( |
|
1668 | 1722 | 'name' => '', |
1669 | 1723 | 'col_name' => '???', |
1670 | 1724 | 'desc' => '', |
@@ -1689,6 +1743,7 @@ discard block |
||
1689 | 1743 | 'enclose' => '', |
1690 | 1744 | 'placement' => 0, |
1691 | 1745 | ); |
1746 | + } |
|
1692 | 1747 | |
1693 | 1748 | // Are we moving it? |
1694 | 1749 | if (isset($_GET['move']) && in_array($smcFunc['htmlspecialchars']($_GET['move']), $move_to)) |
@@ -1697,8 +1752,10 @@ discard block |
||
1697 | 1752 | $new_order = ($_GET['move'] == 'up' ? ($context['field']['order'] - 1) : ($context['field']['order'] + 1)); |
1698 | 1753 | |
1699 | 1754 | // Is this a valid position? |
1700 | - if ($new_order <= 0 || $new_order > $order_count) |
|
1701 | - redirectexit('action=admin;area=featuresettings;sa=profile'); // @todo implement an error handler |
|
1755 | + if ($new_order <= 0 || $new_order > $order_count) { |
|
1756 | + redirectexit('action=admin;area=featuresettings;sa=profile'); |
|
1757 | + } |
|
1758 | + // @todo implement an error handler |
|
1702 | 1759 | |
1703 | 1760 | // All good, proceed. |
1704 | 1761 | $smcFunc['db_query']('',' |
@@ -1729,12 +1786,14 @@ discard block |
||
1729 | 1786 | validateToken('admin-ecp'); |
1730 | 1787 | |
1731 | 1788 | // Everyone needs a name - even the (bracket) unknown... |
1732 | - if (trim($_POST['field_name']) == '') |
|
1733 | - redirectexit($scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $_GET['fid'] . ';msg=need_name'); |
|
1789 | + if (trim($_POST['field_name']) == '') { |
|
1790 | + redirectexit($scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $_GET['fid'] . ';msg=need_name'); |
|
1791 | + } |
|
1734 | 1792 | |
1735 | 1793 | // Regex you say? Do a very basic test to see if the pattern is valid |
1736 | - if (!empty($_POST['regex']) && @preg_match($_POST['regex'], 'dummy') === false) |
|
1737 | - redirectexit($scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $_GET['fid'] . ';msg=regex_error'); |
|
1794 | + if (!empty($_POST['regex']) && @preg_match($_POST['regex'], 'dummy') === false) { |
|
1795 | + redirectexit($scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $_GET['fid'] . ';msg=regex_error'); |
|
1796 | + } |
|
1738 | 1797 | |
1739 | 1798 | $_POST['field_name'] = $smcFunc['htmlspecialchars']($_POST['field_name']); |
1740 | 1799 | $_POST['field_desc'] = $smcFunc['htmlspecialchars']($_POST['field_desc']); |
@@ -1751,8 +1810,9 @@ discard block |
||
1751 | 1810 | |
1752 | 1811 | // Some masking stuff... |
1753 | 1812 | $mask = isset($_POST['mask']) ? $_POST['mask'] : ''; |
1754 | - if ($mask == 'regex' && isset($_POST['regex'])) |
|
1755 | - $mask .= $_POST['regex']; |
|
1813 | + if ($mask == 'regex' && isset($_POST['regex'])) { |
|
1814 | + $mask .= $_POST['regex']; |
|
1815 | + } |
|
1756 | 1816 | |
1757 | 1817 | $field_length = isset($_POST['max_length']) ? (int) $_POST['max_length'] : 255; |
1758 | 1818 | $enclose = isset($_POST['enclose']) ? $_POST['enclose'] : ''; |
@@ -1771,8 +1831,9 @@ discard block |
||
1771 | 1831 | $v = strtr($v, array(',' => '')); |
1772 | 1832 | |
1773 | 1833 | // Nada, zip, etc... |
1774 | - if (trim($v) == '') |
|
1775 | - continue; |
|
1834 | + if (trim($v) == '') { |
|
1835 | + continue; |
|
1836 | + } |
|
1776 | 1837 | |
1777 | 1838 | // Otherwise, save it boy. |
1778 | 1839 | $field_options .= $v . ','; |
@@ -1780,15 +1841,17 @@ discard block |
||
1780 | 1841 | $newOptions[$k] = $v; |
1781 | 1842 | |
1782 | 1843 | // Is it default? |
1783 | - if (isset($_POST['default_select']) && $_POST['default_select'] == $k) |
|
1784 | - $default = $v; |
|
1844 | + if (isset($_POST['default_select']) && $_POST['default_select'] == $k) { |
|
1845 | + $default = $v; |
|
1846 | + } |
|
1785 | 1847 | } |
1786 | 1848 | $field_options = substr($field_options, 0, -1); |
1787 | 1849 | } |
1788 | 1850 | |
1789 | 1851 | // Text area has default has dimensions |
1790 | - if ($_POST['field_type'] == 'textarea') |
|
1791 | - $default = (int) $_POST['rows'] . ',' . (int) $_POST['cols']; |
|
1852 | + if ($_POST['field_type'] == 'textarea') { |
|
1853 | + $default = (int) $_POST['rows'] . ',' . (int) $_POST['cols']; |
|
1854 | + } |
|
1792 | 1855 | |
1793 | 1856 | // Come up with the unique name? |
1794 | 1857 | if (empty($context['fid'])) |
@@ -1797,32 +1860,36 @@ discard block |
||
1797 | 1860 | preg_match('~([\w\d_-]+)~', $col_name, $matches); |
1798 | 1861 | |
1799 | 1862 | // If there is nothing to the name, then let's start out own - for foreign languages etc. |
1800 | - if (isset($matches[1])) |
|
1801 | - $col_name = $initial_col_name = 'cust_' . strtolower($matches[1]); |
|
1802 | - else |
|
1803 | - $col_name = $initial_col_name = 'cust_' . mt_rand(1, 9999); |
|
1863 | + if (isset($matches[1])) { |
|
1864 | + $col_name = $initial_col_name = 'cust_' . strtolower($matches[1]); |
|
1865 | + } else { |
|
1866 | + $col_name = $initial_col_name = 'cust_' . mt_rand(1, 9999); |
|
1867 | + } |
|
1804 | 1868 | |
1805 | 1869 | // Make sure this is unique. |
1806 | 1870 | $current_fields = array(); |
1807 | 1871 | $request = $smcFunc['db_query']('', ' |
1808 | 1872 | SELECT id_field, col_name |
1809 | 1873 | FROM {db_prefix}custom_fields'); |
1810 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1811 | - $current_fields[$row['id_field']] = $row['col_name']; |
|
1874 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1875 | + $current_fields[$row['id_field']] = $row['col_name']; |
|
1876 | + } |
|
1812 | 1877 | $smcFunc['db_free_result']($request); |
1813 | 1878 | |
1814 | 1879 | $unique = false; |
1815 | 1880 | for ($i = 0; !$unique && $i < 9; $i ++) |
1816 | 1881 | { |
1817 | - if (!in_array($col_name, $current_fields)) |
|
1818 | - $unique = true; |
|
1819 | - else |
|
1820 | - $col_name = $initial_col_name . $i; |
|
1882 | + if (!in_array($col_name, $current_fields)) { |
|
1883 | + $unique = true; |
|
1884 | + } else { |
|
1885 | + $col_name = $initial_col_name . $i; |
|
1886 | + } |
|
1821 | 1887 | } |
1822 | 1888 | |
1823 | 1889 | // Still not a unique column name? Leave it up to the user, then. |
1824 | - if (!$unique) |
|
1825 | - fatal_lang_error('custom_option_not_unique'); |
|
1890 | + if (!$unique) { |
|
1891 | + fatal_lang_error('custom_option_not_unique'); |
|
1892 | + } |
|
1826 | 1893 | } |
1827 | 1894 | // Work out what to do with the user data otherwise... |
1828 | 1895 | else |
@@ -1850,8 +1917,9 @@ discard block |
||
1850 | 1917 | // Work out what's changed! |
1851 | 1918 | foreach ($context['field']['options'] as $k => $option) |
1852 | 1919 | { |
1853 | - if (trim($option) == '') |
|
1854 | - continue; |
|
1920 | + if (trim($option) == '') { |
|
1921 | + continue; |
|
1922 | + } |
|
1855 | 1923 | |
1856 | 1924 | // Still exists? |
1857 | 1925 | if (in_array($option, $newOptions)) |
@@ -1865,8 +1933,8 @@ discard block |
||
1865 | 1933 | foreach ($optionChanges as $k => $option) |
1866 | 1934 | { |
1867 | 1935 | // Just been renamed? |
1868 | - if (!in_array($k, $takenKeys) && !empty($newOptions[$k])) |
|
1869 | - $smcFunc['db_query']('', ' |
|
1936 | + if (!in_array($k, $takenKeys) && !empty($newOptions[$k])) { |
|
1937 | + $smcFunc['db_query']('', ' |
|
1870 | 1938 | UPDATE {db_prefix}themes |
1871 | 1939 | SET value = {string:new_value} |
1872 | 1940 | WHERE variable = {string:current_column} |
@@ -1879,6 +1947,7 @@ discard block |
||
1879 | 1947 | 'old_value' => $option, |
1880 | 1948 | ) |
1881 | 1949 | ); |
1950 | + } |
|
1882 | 1951 | } |
1883 | 1952 | } |
1884 | 1953 | // @todo Maybe we should adjust based on new text length limits? |
@@ -1921,8 +1990,8 @@ discard block |
||
1921 | 1990 | ); |
1922 | 1991 | |
1923 | 1992 | // Just clean up any old selects - these are a pain! |
1924 | - if (($_POST['field_type'] == 'select' || $_POST['field_type'] == 'radio') && !empty($newOptions)) |
|
1925 | - $smcFunc['db_query']('', ' |
|
1993 | + if (($_POST['field_type'] == 'select' || $_POST['field_type'] == 'radio') && !empty($newOptions)) { |
|
1994 | + $smcFunc['db_query']('', ' |
|
1926 | 1995 | DELETE FROM {db_prefix}themes |
1927 | 1996 | WHERE variable = {string:current_column} |
1928 | 1997 | AND value NOT IN ({array_string:new_option_values}) |
@@ -1933,8 +2002,8 @@ discard block |
||
1933 | 2002 | 'current_column' => $context['field']['col_name'], |
1934 | 2003 | ) |
1935 | 2004 | ); |
1936 | - } |
|
1937 | - else |
|
2005 | + } |
|
2006 | + } else |
|
1938 | 2007 | { |
1939 | 2008 | // Gotta figure it out the order. |
1940 | 2009 | $new_order = $order_count > 1 ? ($order_count + 1) : 1; |
@@ -2108,11 +2177,13 @@ discard block |
||
2108 | 2177 | call_integration_hook('integrate_prune_settings', array(&$config_vars, &$prune_toggle, false)); |
2109 | 2178 | |
2110 | 2179 | $prune_toggle_dt = array(); |
2111 | - foreach ($prune_toggle as $item) |
|
2112 | - $prune_toggle_dt[] = 'setting_' . $item; |
|
2180 | + foreach ($prune_toggle as $item) { |
|
2181 | + $prune_toggle_dt[] = 'setting_' . $item; |
|
2182 | + } |
|
2113 | 2183 | |
2114 | - if ($return_config) |
|
2115 | - return $config_vars; |
|
2184 | + if ($return_config) { |
|
2185 | + return $config_vars; |
|
2186 | + } |
|
2116 | 2187 | |
2117 | 2188 | addInlineJavaScript(' |
2118 | 2189 | function togglePruned() |
@@ -2150,15 +2221,16 @@ discard block |
||
2150 | 2221 | $vals = array(); |
2151 | 2222 | foreach ($config_vars as $index => $dummy) |
2152 | 2223 | { |
2153 | - if (!is_array($dummy) || $index == 'pruningOptions' || !in_array($dummy[1], $prune_toggle)) |
|
2154 | - continue; |
|
2224 | + if (!is_array($dummy) || $index == 'pruningOptions' || !in_array($dummy[1], $prune_toggle)) { |
|
2225 | + continue; |
|
2226 | + } |
|
2155 | 2227 | |
2156 | 2228 | $vals[] = empty($_POST[$dummy[1]]) || $_POST[$dummy[1]] < 0 ? 0 : (int) $_POST[$dummy[1]]; |
2157 | 2229 | } |
2158 | 2230 | $_POST['pruningOptions'] = implode(',', $vals); |
2231 | + } else { |
|
2232 | + $_POST['pruningOptions'] = ''; |
|
2159 | 2233 | } |
2160 | - else |
|
2161 | - $_POST['pruningOptions'] = ''; |
|
2162 | 2234 | |
2163 | 2235 | saveDBSettings($savevar); |
2164 | 2236 | $_SESSION['adm-save'] = true; |
@@ -2170,10 +2242,11 @@ discard block |
||
2170 | 2242 | $context['sub_template'] = 'show_settings'; |
2171 | 2243 | |
2172 | 2244 | // Get the actual values |
2173 | - if (!empty($modSettings['pruningOptions'])) |
|
2174 | - @list ($modSettings['pruneErrorLog'], $modSettings['pruneModLog'], $modSettings['pruneBanLog'], $modSettings['pruneReportLog'], $modSettings['pruneScheduledTaskLog'], $modSettings['pruneSpiderHitLog']) = explode(',', $modSettings['pruningOptions']); |
|
2175 | - else |
|
2176 | - $modSettings['pruneErrorLog'] = $modSettings['pruneModLog'] = $modSettings['pruneBanLog'] = $modSettings['pruneReportLog'] = $modSettings['pruneScheduledTaskLog'] = $modSettings['pruneSpiderHitLog'] = 0; |
|
2245 | + if (!empty($modSettings['pruningOptions'])) { |
|
2246 | + @list ($modSettings['pruneErrorLog'], $modSettings['pruneModLog'], $modSettings['pruneBanLog'], $modSettings['pruneReportLog'], $modSettings['pruneScheduledTaskLog'], $modSettings['pruneSpiderHitLog']) = explode(',', $modSettings['pruningOptions']); |
|
2247 | + } else { |
|
2248 | + $modSettings['pruneErrorLog'] = $modSettings['pruneModLog'] = $modSettings['pruneBanLog'] = $modSettings['pruneReportLog'] = $modSettings['pruneScheduledTaskLog'] = $modSettings['pruneSpiderHitLog'] = 0; |
|
2249 | + } |
|
2177 | 2250 | |
2178 | 2251 | prepareDBSettingContext($config_vars); |
2179 | 2252 | } |
@@ -2195,8 +2268,9 @@ discard block |
||
2195 | 2268 | // Make it even easier to add new settings. |
2196 | 2269 | call_integration_hook('integrate_general_mod_settings', array(&$config_vars)); |
2197 | 2270 | |
2198 | - if ($return_config) |
|
2199 | - return $config_vars; |
|
2271 | + if ($return_config) { |
|
2272 | + return $config_vars; |
|
2273 | + } |
|
2200 | 2274 | |
2201 | 2275 | $context['post_url'] = $scripturl . '?action=admin;area=modsettings;save;sa=general'; |
2202 | 2276 | $context['settings_title'] = $txt['mods_cat_modifications_misc']; |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | require_once($sourcedir . '/Subs-Auth.php'); |
53 | 53 | |
54 | 54 | // Posting the password... check it. |
55 | - if (isset($_POST[$type. '_pass'])) |
|
55 | + if (isset($_POST[$type . '_pass'])) |
|
56 | 56 | { |
57 | 57 | // Check to ensure we're forcing SSL for authentication |
58 | 58 | if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | { |
180 | 180 | if ($ip_number == 'ip2' && $user_info['ip2'] == $user_info['ip']) |
181 | 181 | continue; |
182 | - $ban_query[] = ' {inet:'.$ip_number.'} BETWEEN bi.ip_low and bi.ip_high'; |
|
182 | + $ban_query[] = ' {inet:' . $ip_number . '} BETWEEN bi.ip_low and bi.ip_high'; |
|
183 | 183 | $ban_query_vars[$ip_number] = $user_info[$ip_number]; |
184 | 184 | // IP was valid, maybe there's also a hostname... |
185 | 185 | if (empty($modSettings['disableHostnameLookup']) && $user_info[$ip_number] != 'unknown') |
@@ -187,8 +187,8 @@ discard block |
||
187 | 187 | $hostname = host_from_ip($user_info[$ip_number]); |
188 | 188 | if (strlen($hostname) > 0) |
189 | 189 | { |
190 | - $ban_query[] = '({string:hostname'.$ip_number.'} LIKE bi.hostname)'; |
|
191 | - $ban_query_vars['hostname'.$ip_number] = $hostname; |
|
190 | + $ban_query[] = '({string:hostname' . $ip_number . '} LIKE bi.hostname)'; |
|
191 | + $ban_query_vars['hostname' . $ip_number] = $hostname; |
|
192 | 192 | } |
193 | 193 | } |
194 | 194 | } |
@@ -912,7 +912,7 @@ discard block |
||
912 | 912 | return true; |
913 | 913 | |
914 | 914 | // Let's ensure this is an array. |
915 | - $permission = (array)$permission; |
|
915 | + $permission = (array) $permission; |
|
916 | 916 | |
917 | 917 | // Are we checking the _current_ board, or some other boards? |
918 | 918 | if ($boards === null) |
@@ -14,8 +14,9 @@ discard block |
||
14 | 14 | * @version 2.1 Beta 3 |
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 | * Check if the user is who he/she says he is |
@@ -42,12 +43,14 @@ discard block |
||
42 | 43 | $refreshTime = isset($_GET['xml']) ? 4200 : 3600; |
43 | 44 | |
44 | 45 | // Is the security option off? |
45 | - if (!empty($modSettings['securityDisable' . ($type != 'admin' ? '_' . $type : '')])) |
|
46 | - return; |
|
46 | + if (!empty($modSettings['securityDisable' . ($type != 'admin' ? '_' . $type : '')])) { |
|
47 | + return; |
|
48 | + } |
|
47 | 49 | |
48 | 50 | // Or are they already logged in?, Moderator or admin session is need for this area |
49 | - if ((!empty($_SESSION[$type . '_time']) && $_SESSION[$type . '_time'] + $refreshTime >= time()) || (!empty($_SESSION['admin_time']) && $_SESSION['admin_time'] + $refreshTime >= time())) |
|
50 | - return; |
|
51 | + if ((!empty($_SESSION[$type . '_time']) && $_SESSION[$type . '_time'] + $refreshTime >= time()) || (!empty($_SESSION['admin_time']) && $_SESSION['admin_time'] + $refreshTime >= time())) { |
|
52 | + return; |
|
53 | + } |
|
51 | 54 | |
52 | 55 | require_once($sourcedir . '/Subs-Auth.php'); |
53 | 56 | |
@@ -55,8 +58,9 @@ discard block |
||
55 | 58 | if (isset($_POST[$type. '_pass'])) |
56 | 59 | { |
57 | 60 | // Check to ensure we're forcing SSL for authentication |
58 | - if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) |
|
59 | - fatal_lang_error('login_ssl_required'); |
|
61 | + if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) { |
|
62 | + fatal_lang_error('login_ssl_required'); |
|
63 | + } |
|
60 | 64 | |
61 | 65 | checkSession(); |
62 | 66 | |
@@ -72,17 +76,19 @@ discard block |
||
72 | 76 | } |
73 | 77 | |
74 | 78 | // Better be sure to remember the real referer |
75 | - if (empty($_SESSION['request_referer'])) |
|
76 | - $_SESSION['request_referer'] = isset($_SERVER['HTTP_REFERER']) ? @parse_url($_SERVER['HTTP_REFERER']) : array(); |
|
77 | - elseif (empty($_POST)) |
|
78 | - unset($_SESSION['request_referer']); |
|
79 | + if (empty($_SESSION['request_referer'])) { |
|
80 | + $_SESSION['request_referer'] = isset($_SERVER['HTTP_REFERER']) ? @parse_url($_SERVER['HTTP_REFERER']) : array(); |
|
81 | + } elseif (empty($_POST)) { |
|
82 | + unset($_SESSION['request_referer']); |
|
83 | + } |
|
79 | 84 | |
80 | 85 | // Need to type in a password for that, man. |
81 | - if (!isset($_GET['xml'])) |
|
82 | - adminLogin($type); |
|
83 | - else |
|
84 | - return 'session_verify_fail'; |
|
85 | -} |
|
86 | + if (!isset($_GET['xml'])) { |
|
87 | + adminLogin($type); |
|
88 | + } else { |
|
89 | + return 'session_verify_fail'; |
|
90 | + } |
|
91 | + } |
|
86 | 92 | |
87 | 93 | /** |
88 | 94 | * Require a user who is logged in. (not a guest.) |
@@ -96,25 +102,30 @@ discard block |
||
96 | 102 | global $user_info, $txt, $context, $scripturl, $modSettings; |
97 | 103 | |
98 | 104 | // Luckily, this person isn't a guest. |
99 | - if (!$user_info['is_guest']) |
|
100 | - return; |
|
105 | + if (!$user_info['is_guest']) { |
|
106 | + return; |
|
107 | + } |
|
101 | 108 | |
102 | 109 | // Log what they were trying to do didn't work) |
103 | - if (!empty($modSettings['who_enabled'])) |
|
104 | - $_GET['error'] = 'guest_login'; |
|
110 | + if (!empty($modSettings['who_enabled'])) { |
|
111 | + $_GET['error'] = 'guest_login'; |
|
112 | + } |
|
105 | 113 | writeLog(true); |
106 | 114 | |
107 | 115 | // Just die. |
108 | - if (isset($_REQUEST['xml'])) |
|
109 | - obExit(false); |
|
116 | + if (isset($_REQUEST['xml'])) { |
|
117 | + obExit(false); |
|
118 | + } |
|
110 | 119 | |
111 | 120 | // Attempt to detect if they came from dlattach. |
112 | - if (SMF != 'SSI' && empty($context['theme_loaded'])) |
|
113 | - loadTheme(); |
|
121 | + if (SMF != 'SSI' && empty($context['theme_loaded'])) { |
|
122 | + loadTheme(); |
|
123 | + } |
|
114 | 124 | |
115 | 125 | // Never redirect to an attachment |
116 | - if (strpos($_SERVER['REQUEST_URL'], 'dlattach') === false) |
|
117 | - $_SESSION['login_url'] = $_SERVER['REQUEST_URL']; |
|
126 | + if (strpos($_SERVER['REQUEST_URL'], 'dlattach') === false) { |
|
127 | + $_SESSION['login_url'] = $_SERVER['REQUEST_URL']; |
|
128 | + } |
|
118 | 129 | |
119 | 130 | // Load the Login template and language file. |
120 | 131 | loadLanguage('Login'); |
@@ -124,8 +135,7 @@ discard block |
||
124 | 135 | { |
125 | 136 | $_SESSION['login_url'] = $scripturl . '?' . $_SERVER['QUERY_STRING']; |
126 | 137 | redirectexit('action=login'); |
127 | - } |
|
128 | - else |
|
138 | + } else |
|
129 | 139 | { |
130 | 140 | loadTemplate('Login'); |
131 | 141 | $context['sub_template'] = 'kick_guest'; |
@@ -155,8 +165,9 @@ discard block |
||
155 | 165 | global $sourcedir, $cookiename, $user_settings, $smcFunc; |
156 | 166 | |
157 | 167 | // You cannot be banned if you are an admin - doesn't help if you log out. |
158 | - if ($user_info['is_admin']) |
|
159 | - return; |
|
168 | + if ($user_info['is_admin']) { |
|
169 | + return; |
|
170 | + } |
|
160 | 171 | |
161 | 172 | // Only check the ban every so often. (to reduce load.) |
162 | 173 | if ($forceCheck || !isset($_SESSION['ban']) || empty($modSettings['banLastUpdated']) || ($_SESSION['ban']['last_checked'] < $modSettings['banLastUpdated']) || $_SESSION['ban']['id_member'] != $user_info['id'] || $_SESSION['ban']['ip'] != $user_info['ip'] || $_SESSION['ban']['ip2'] != $user_info['ip2'] || (isset($user_info['email'], $_SESSION['ban']['email']) && $_SESSION['ban']['email'] != $user_info['email'])) |
@@ -177,8 +188,9 @@ discard block |
||
177 | 188 | // Check both IP addresses. |
178 | 189 | foreach (array('ip', 'ip2') as $ip_number) |
179 | 190 | { |
180 | - if ($ip_number == 'ip2' && $user_info['ip2'] == $user_info['ip']) |
|
181 | - continue; |
|
191 | + if ($ip_number == 'ip2' && $user_info['ip2'] == $user_info['ip']) { |
|
192 | + continue; |
|
193 | + } |
|
182 | 194 | $ban_query[] = ' {inet:'.$ip_number.'} BETWEEN bi.ip_low and bi.ip_high'; |
183 | 195 | $ban_query_vars[$ip_number] = $user_info[$ip_number]; |
184 | 196 | // IP was valid, maybe there's also a hostname... |
@@ -228,24 +240,28 @@ discard block |
||
228 | 240 | // Store every type of ban that applies to you in your session. |
229 | 241 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
230 | 242 | { |
231 | - foreach ($restrictions as $restriction) |
|
232 | - if (!empty($row[$restriction])) |
|
243 | + foreach ($restrictions as $restriction) { |
|
244 | + if (!empty($row[$restriction])) |
|
233 | 245 | { |
234 | 246 | $_SESSION['ban'][$restriction]['reason'] = $row['reason']; |
247 | + } |
|
235 | 248 | $_SESSION['ban'][$restriction]['ids'][] = $row['id_ban']; |
236 | - if (!isset($_SESSION['ban']['expire_time']) || ($_SESSION['ban']['expire_time'] != 0 && ($row['expire_time'] == 0 || $row['expire_time'] > $_SESSION['ban']['expire_time']))) |
|
237 | - $_SESSION['ban']['expire_time'] = $row['expire_time']; |
|
249 | + if (!isset($_SESSION['ban']['expire_time']) || ($_SESSION['ban']['expire_time'] != 0 && ($row['expire_time'] == 0 || $row['expire_time'] > $_SESSION['ban']['expire_time']))) { |
|
250 | + $_SESSION['ban']['expire_time'] = $row['expire_time']; |
|
251 | + } |
|
238 | 252 | |
239 | - if (!$user_info['is_guest'] && $restriction == 'cannot_access' && ($row['id_member'] == $user_info['id'] || $row['email_address'] == $user_info['email'])) |
|
240 | - $flag_is_activated = true; |
|
253 | + if (!$user_info['is_guest'] && $restriction == 'cannot_access' && ($row['id_member'] == $user_info['id'] || $row['email_address'] == $user_info['email'])) { |
|
254 | + $flag_is_activated = true; |
|
255 | + } |
|
241 | 256 | } |
242 | 257 | } |
243 | 258 | $smcFunc['db_free_result']($request); |
244 | 259 | } |
245 | 260 | |
246 | 261 | // Mark the cannot_access and cannot_post bans as being 'hit'. |
247 | - if (isset($_SESSION['ban']['cannot_access']) || isset($_SESSION['ban']['cannot_post']) || isset($_SESSION['ban']['cannot_login'])) |
|
248 | - log_ban(array_merge(isset($_SESSION['ban']['cannot_access']) ? $_SESSION['ban']['cannot_access']['ids'] : array(), isset($_SESSION['ban']['cannot_post']) ? $_SESSION['ban']['cannot_post']['ids'] : array(), isset($_SESSION['ban']['cannot_login']) ? $_SESSION['ban']['cannot_login']['ids'] : array())); |
|
262 | + if (isset($_SESSION['ban']['cannot_access']) || isset($_SESSION['ban']['cannot_post']) || isset($_SESSION['ban']['cannot_login'])) { |
|
263 | + log_ban(array_merge(isset($_SESSION['ban']['cannot_access']) ? $_SESSION['ban']['cannot_access']['ids'] : array(), isset($_SESSION['ban']['cannot_post']) ? $_SESSION['ban']['cannot_post']['ids'] : array(), isset($_SESSION['ban']['cannot_login']) ? $_SESSION['ban']['cannot_login']['ids'] : array())); |
|
264 | + } |
|
249 | 265 | |
250 | 266 | // If for whatever reason the is_activated flag seems wrong, do a little work to clear it up. |
251 | 267 | if ($user_info['id'] && (($user_settings['is_activated'] >= 10 && !$flag_is_activated) |
@@ -260,8 +276,9 @@ discard block |
||
260 | 276 | if (!isset($_SESSION['ban']['cannot_access']) && !empty($_COOKIE[$cookiename . '_'])) |
261 | 277 | { |
262 | 278 | $bans = explode(',', $_COOKIE[$cookiename . '_']); |
263 | - foreach ($bans as $key => $value) |
|
264 | - $bans[$key] = (int) $value; |
|
279 | + foreach ($bans as $key => $value) { |
|
280 | + $bans[$key] = (int) $value; |
|
281 | + } |
|
265 | 282 | $request = $smcFunc['db_query']('', ' |
266 | 283 | SELECT bi.id_ban, bg.reason |
267 | 284 | FROM {db_prefix}ban_items AS bi |
@@ -297,14 +314,15 @@ discard block |
||
297 | 314 | if (isset($_SESSION['ban']['cannot_access'])) |
298 | 315 | { |
299 | 316 | // We don't wanna see you! |
300 | - if (!$user_info['is_guest']) |
|
301 | - $smcFunc['db_query']('', ' |
|
317 | + if (!$user_info['is_guest']) { |
|
318 | + $smcFunc['db_query']('', ' |
|
302 | 319 | DELETE FROM {db_prefix}log_online |
303 | 320 | WHERE id_member = {int:current_member}', |
304 | 321 | array( |
305 | 322 | 'current_member' => $user_info['id'], |
306 | 323 | ) |
307 | 324 | ); |
325 | + } |
|
308 | 326 | |
309 | 327 | // 'Log' the user out. Can't have any funny business... (save the name!) |
310 | 328 | $old_name = isset($user_info['name']) && $user_info['name'] != '' ? $user_info['name'] : $txt['guest_title']; |
@@ -390,9 +408,10 @@ discard block |
||
390 | 408 | } |
391 | 409 | |
392 | 410 | // Fix up the banning permissions. |
393 | - if (isset($user_info['permissions'])) |
|
394 | - banPermissions(); |
|
395 | -} |
|
411 | + if (isset($user_info['permissions'])) { |
|
412 | + banPermissions(); |
|
413 | + } |
|
414 | + } |
|
396 | 415 | |
397 | 416 | /** |
398 | 417 | * Fix permissions according to ban status. |
@@ -403,8 +422,9 @@ discard block |
||
403 | 422 | global $user_info, $sourcedir, $modSettings, $context; |
404 | 423 | |
405 | 424 | // Somehow they got here, at least take away all permissions... |
406 | - if (isset($_SESSION['ban']['cannot_access'])) |
|
407 | - $user_info['permissions'] = array(); |
|
425 | + if (isset($_SESSION['ban']['cannot_access'])) { |
|
426 | + $user_info['permissions'] = array(); |
|
427 | + } |
|
408 | 428 | // Okay, well, you can watch, but don't touch a thing. |
409 | 429 | elseif (isset($_SESSION['ban']['cannot_post']) || (!empty($modSettings['warning_mute']) && $modSettings['warning_mute'] <= $user_info['warning'])) |
410 | 430 | { |
@@ -446,44 +466,45 @@ discard block |
||
446 | 466 | call_integration_hook('integrate_warn_permissions', array(&$permission_change)); |
447 | 467 | foreach ($permission_change as $old => $new) |
448 | 468 | { |
449 | - if (!in_array($old, $user_info['permissions'])) |
|
450 | - unset($permission_change[$old]); |
|
451 | - else |
|
452 | - $user_info['permissions'][] = $new; |
|
469 | + if (!in_array($old, $user_info['permissions'])) { |
|
470 | + unset($permission_change[$old]); |
|
471 | + } else { |
|
472 | + $user_info['permissions'][] = $new; |
|
473 | + } |
|
453 | 474 | } |
454 | 475 | $user_info['permissions'] = array_diff($user_info['permissions'], array_keys($permission_change)); |
455 | 476 | } |
456 | 477 | |
457 | 478 | // @todo Find a better place to call this? Needs to be after permissions loaded! |
458 | 479 | // Finally, some bits we cache in the session because it saves queries. |
459 | - if (isset($_SESSION['mc']) && $_SESSION['mc']['time'] > $modSettings['settings_updated'] && $_SESSION['mc']['id'] == $user_info['id']) |
|
460 | - $user_info['mod_cache'] = $_SESSION['mc']; |
|
461 | - else |
|
480 | + if (isset($_SESSION['mc']) && $_SESSION['mc']['time'] > $modSettings['settings_updated'] && $_SESSION['mc']['id'] == $user_info['id']) { |
|
481 | + $user_info['mod_cache'] = $_SESSION['mc']; |
|
482 | + } else |
|
462 | 483 | { |
463 | 484 | require_once($sourcedir . '/Subs-Auth.php'); |
464 | 485 | rebuildModCache(); |
465 | 486 | } |
466 | 487 | |
467 | 488 | // Now that we have the mod cache taken care of lets setup a cache for the number of mod reports still open |
468 | - if (!empty($_SESSION['rc']) && $_SESSION['rc']['time'] > $modSettings['last_mod_report_action'] && $_SESSION['rc']['id'] == $user_info['id']) |
|
469 | - $context['open_mod_reports'] = $_SESSION['rc']['reports']; |
|
470 | - elseif ($_SESSION['mc']['bq'] != '0=1') |
|
489 | + if (!empty($_SESSION['rc']) && $_SESSION['rc']['time'] > $modSettings['last_mod_report_action'] && $_SESSION['rc']['id'] == $user_info['id']) { |
|
490 | + $context['open_mod_reports'] = $_SESSION['rc']['reports']; |
|
491 | + } elseif ($_SESSION['mc']['bq'] != '0=1') |
|
471 | 492 | { |
472 | 493 | require_once($sourcedir . '/Subs-ReportedContent.php'); |
473 | 494 | recountOpenReports('posts'); |
495 | + } else { |
|
496 | + $context['open_mod_reports'] = 0; |
|
474 | 497 | } |
475 | - else |
|
476 | - $context['open_mod_reports'] = 0; |
|
477 | 498 | |
478 | - if (!empty($_SESSION['rc']) && $_SESSION['rc']['time'] > $modSettings['last_mod_report_action'] && $_SESSION['rc']['id'] == $user_info['id']) |
|
479 | - $context['open_member_reports'] = !empty($_SESSION['rc']['member_reports']) ? $_SESSION['rc']['member_reports'] : 0; |
|
480 | - elseif (allowedTo('moderate_forum')) |
|
499 | + if (!empty($_SESSION['rc']) && $_SESSION['rc']['time'] > $modSettings['last_mod_report_action'] && $_SESSION['rc']['id'] == $user_info['id']) { |
|
500 | + $context['open_member_reports'] = !empty($_SESSION['rc']['member_reports']) ? $_SESSION['rc']['member_reports'] : 0; |
|
501 | + } elseif (allowedTo('moderate_forum')) |
|
481 | 502 | { |
482 | 503 | require_once($sourcedir . '/Subs-ReportedContent.php'); |
483 | 504 | recountOpenReports('members'); |
505 | + } else { |
|
506 | + $context['open_member_reports'] = 0; |
|
484 | 507 | } |
485 | - else |
|
486 | - $context['open_member_reports'] = 0; |
|
487 | 508 | |
488 | 509 | } |
489 | 510 | |
@@ -500,8 +521,9 @@ discard block |
||
500 | 521 | global $user_info, $smcFunc; |
501 | 522 | |
502 | 523 | // Don't log web accelerators, it's very confusing... |
503 | - if (isset($_SERVER['HTTP_X_MOZ']) && $_SERVER['HTTP_X_MOZ'] == 'prefetch') |
|
504 | - return; |
|
524 | + if (isset($_SERVER['HTTP_X_MOZ']) && $_SERVER['HTTP_X_MOZ'] == 'prefetch') { |
|
525 | + return; |
|
526 | + } |
|
505 | 527 | |
506 | 528 | $smcFunc['db_insert']('', |
507 | 529 | '{db_prefix}log_banned', |
@@ -511,8 +533,8 @@ discard block |
||
511 | 533 | ); |
512 | 534 | |
513 | 535 | // One extra point for these bans. |
514 | - if (!empty($ban_ids)) |
|
515 | - $smcFunc['db_query']('', ' |
|
536 | + if (!empty($ban_ids)) { |
|
537 | + $smcFunc['db_query']('', ' |
|
516 | 538 | UPDATE {db_prefix}ban_items |
517 | 539 | SET hits = hits + 1 |
518 | 540 | WHERE id_ban IN ({array_int:ban_ids})', |
@@ -520,7 +542,8 @@ discard block |
||
520 | 542 | 'ban_ids' => $ban_ids, |
521 | 543 | ) |
522 | 544 | ); |
523 | -} |
|
545 | + } |
|
546 | + } |
|
524 | 547 | |
525 | 548 | /** |
526 | 549 | * Checks if a given email address might be banned. |
@@ -536,8 +559,9 @@ discard block |
||
536 | 559 | global $txt, $smcFunc; |
537 | 560 | |
538 | 561 | // Can't ban an empty email |
539 | - if (empty($email) || trim($email) == '') |
|
540 | - return; |
|
562 | + if (empty($email) || trim($email) == '') { |
|
563 | + return; |
|
564 | + } |
|
541 | 565 | |
542 | 566 | // Let's start with the bans based on your IP/hostname/memberID... |
543 | 567 | $ban_ids = isset($_SESSION['ban'][$restriction]) ? $_SESSION['ban'][$restriction]['ids'] : array(); |
@@ -610,16 +634,18 @@ discard block |
||
610 | 634 | if ($type == 'post') |
611 | 635 | { |
612 | 636 | $check = isset($_POST[$_SESSION['session_var']]) ? $_POST[$_SESSION['session_var']] : (empty($modSettings['strictSessionCheck']) && isset($_POST['sc']) ? $_POST['sc'] : null); |
613 | - if ($check !== $sc) |
|
614 | - $error = 'session_timeout'; |
|
637 | + if ($check !== $sc) { |
|
638 | + $error = 'session_timeout'; |
|
639 | + } |
|
615 | 640 | } |
616 | 641 | |
617 | 642 | // How about $_GET['sesc']? |
618 | 643 | elseif ($type == 'get') |
619 | 644 | { |
620 | 645 | $check = isset($_GET[$_SESSION['session_var']]) ? $_GET[$_SESSION['session_var']] : (empty($modSettings['strictSessionCheck']) && isset($_GET['sesc']) ? $_GET['sesc'] : null); |
621 | - if ($check !== $sc) |
|
622 | - $error = 'session_verify_fail'; |
|
646 | + if ($check !== $sc) { |
|
647 | + $error = 'session_verify_fail'; |
|
648 | + } |
|
623 | 649 | } |
624 | 650 | |
625 | 651 | // Or can it be in either? |
@@ -627,13 +653,15 @@ discard block |
||
627 | 653 | { |
628 | 654 | $check = isset($_GET[$_SESSION['session_var']]) ? $_GET[$_SESSION['session_var']] : (empty($modSettings['strictSessionCheck']) && isset($_GET['sesc']) ? $_GET['sesc'] : (isset($_POST[$_SESSION['session_var']]) ? $_POST[$_SESSION['session_var']] : (empty($modSettings['strictSessionCheck']) && isset($_POST['sc']) ? $_POST['sc'] : null))); |
629 | 655 | |
630 | - if ($check !== $sc) |
|
631 | - $error = 'session_verify_fail'; |
|
656 | + if ($check !== $sc) { |
|
657 | + $error = 'session_verify_fail'; |
|
658 | + } |
|
632 | 659 | } |
633 | 660 | |
634 | 661 | // Verify that they aren't changing user agents on us - that could be bad. |
635 | - if ((!isset($_SESSION['USER_AGENT']) || $_SESSION['USER_AGENT'] != $_SERVER['HTTP_USER_AGENT']) && empty($modSettings['disableCheckUA'])) |
|
636 | - $error = 'session_verify_fail'; |
|
662 | + if ((!isset($_SESSION['USER_AGENT']) || $_SESSION['USER_AGENT'] != $_SERVER['HTTP_USER_AGENT']) && empty($modSettings['disableCheckUA'])) { |
|
663 | + $error = 'session_verify_fail'; |
|
664 | + } |
|
637 | 665 | |
638 | 666 | // Make sure a page with session check requirement is not being prefetched. |
639 | 667 | if (isset($_SERVER['HTTP_X_MOZ']) && $_SERVER['HTTP_X_MOZ'] == 'prefetch') |
@@ -644,30 +672,35 @@ discard block |
||
644 | 672 | } |
645 | 673 | |
646 | 674 | // Check the referring site - it should be the same server at least! |
647 | - if (isset($_SESSION['request_referer'])) |
|
648 | - $referrer = $_SESSION['request_referer']; |
|
649 | - else |
|
650 | - $referrer = isset($_SERVER['HTTP_REFERER']) ? @parse_url($_SERVER['HTTP_REFERER']) : array(); |
|
675 | + if (isset($_SESSION['request_referer'])) { |
|
676 | + $referrer = $_SESSION['request_referer']; |
|
677 | + } else { |
|
678 | + $referrer = isset($_SERVER['HTTP_REFERER']) ? @parse_url($_SERVER['HTTP_REFERER']) : array(); |
|
679 | + } |
|
651 | 680 | if (!empty($referrer['host'])) |
652 | 681 | { |
653 | - if (strpos($_SERVER['HTTP_HOST'], ':') !== false) |
|
654 | - $real_host = substr($_SERVER['HTTP_HOST'], 0, strpos($_SERVER['HTTP_HOST'], ':')); |
|
655 | - else |
|
656 | - $real_host = $_SERVER['HTTP_HOST']; |
|
682 | + if (strpos($_SERVER['HTTP_HOST'], ':') !== false) { |
|
683 | + $real_host = substr($_SERVER['HTTP_HOST'], 0, strpos($_SERVER['HTTP_HOST'], ':')); |
|
684 | + } else { |
|
685 | + $real_host = $_SERVER['HTTP_HOST']; |
|
686 | + } |
|
657 | 687 | |
658 | 688 | $parsed_url = parse_url($boardurl); |
659 | 689 | |
660 | 690 | // Are global cookies on? If so, let's check them ;). |
661 | 691 | if (!empty($modSettings['globalCookies'])) |
662 | 692 | { |
663 | - if (preg_match('~(?:[^\.]+\.)?([^\.]{3,}\..+)\z~i', $parsed_url['host'], $parts) == 1) |
|
664 | - $parsed_url['host'] = $parts[1]; |
|
693 | + if (preg_match('~(?:[^\.]+\.)?([^\.]{3,}\..+)\z~i', $parsed_url['host'], $parts) == 1) { |
|
694 | + $parsed_url['host'] = $parts[1]; |
|
695 | + } |
|
665 | 696 | |
666 | - if (preg_match('~(?:[^\.]+\.)?([^\.]{3,}\..+)\z~i', $referrer['host'], $parts) == 1) |
|
667 | - $referrer['host'] = $parts[1]; |
|
697 | + if (preg_match('~(?:[^\.]+\.)?([^\.]{3,}\..+)\z~i', $referrer['host'], $parts) == 1) { |
|
698 | + $referrer['host'] = $parts[1]; |
|
699 | + } |
|
668 | 700 | |
669 | - if (preg_match('~(?:[^\.]+\.)?([^\.]{3,}\..+)\z~i', $real_host, $parts) == 1) |
|
670 | - $real_host = $parts[1]; |
|
701 | + if (preg_match('~(?:[^\.]+\.)?([^\.]{3,}\..+)\z~i', $real_host, $parts) == 1) { |
|
702 | + $real_host = $parts[1]; |
|
703 | + } |
|
671 | 704 | } |
672 | 705 | |
673 | 706 | // Okay: referrer must either match parsed_url or real_host. |
@@ -685,12 +718,14 @@ discard block |
||
685 | 718 | $log_error = true; |
686 | 719 | } |
687 | 720 | |
688 | - if (strtolower($_SERVER['HTTP_USER_AGENT']) == 'hacker') |
|
689 | - fatal_error('Sound the alarm! It\'s a hacker! Close the castle gates!!', false); |
|
721 | + if (strtolower($_SERVER['HTTP_USER_AGENT']) == 'hacker') { |
|
722 | + fatal_error('Sound the alarm! It\'s a hacker! Close the castle gates!!', false); |
|
723 | + } |
|
690 | 724 | |
691 | 725 | // Everything is ok, return an empty string. |
692 | - if (!isset($error)) |
|
693 | - return ''; |
|
726 | + if (!isset($error)) { |
|
727 | + return ''; |
|
728 | + } |
|
694 | 729 | // A session error occurred, show the error. |
695 | 730 | elseif ($is_fatal) |
696 | 731 | { |
@@ -699,13 +734,14 @@ discard block |
||
699 | 734 | ob_end_clean(); |
700 | 735 | header('HTTP/1.1 403 Forbidden - Session timeout'); |
701 | 736 | die; |
737 | + } else { |
|
738 | + fatal_lang_error($error, isset($log_error) ? 'user' : false); |
|
702 | 739 | } |
703 | - else |
|
704 | - fatal_lang_error($error, isset($log_error) ? 'user' : false); |
|
705 | 740 | } |
706 | 741 | // A session error occurred, return the error to the calling function. |
707 | - else |
|
708 | - return $error; |
|
742 | + else { |
|
743 | + return $error; |
|
744 | + } |
|
709 | 745 | |
710 | 746 | // We really should never fall through here, for very important reasons. Let's make sure. |
711 | 747 | trigger_error('Hacking attempt...', E_USER_ERROR); |
@@ -721,10 +757,9 @@ discard block |
||
721 | 757 | { |
722 | 758 | global $modSettings; |
723 | 759 | |
724 | - if (isset($_GET['confirm']) && isset($_SESSION['confirm_' . $action]) && md5($_GET['confirm'] . $_SERVER['HTTP_USER_AGENT']) == $_SESSION['confirm_' . $action]) |
|
725 | - return true; |
|
726 | - |
|
727 | - else |
|
760 | + if (isset($_GET['confirm']) && isset($_SESSION['confirm_' . $action]) && md5($_GET['confirm'] . $_SERVER['HTTP_USER_AGENT']) == $_SESSION['confirm_' . $action]) { |
|
761 | + return true; |
|
762 | + } else |
|
728 | 763 | { |
729 | 764 | $token = md5(mt_rand() . session_id() . (string) microtime() . $modSettings['rand_seed']); |
730 | 765 | $_SESSION['confirm_' . $action] = md5($token . $_SERVER['HTTP_USER_AGENT']); |
@@ -775,9 +810,9 @@ discard block |
||
775 | 810 | $return = $_SESSION['token'][$type . '-' . $action][3]; |
776 | 811 | unset($_SESSION['token'][$type . '-' . $action]); |
777 | 812 | return $return; |
813 | + } else { |
|
814 | + return ''; |
|
778 | 815 | } |
779 | - else |
|
780 | - return ''; |
|
781 | 816 | } |
782 | 817 | |
783 | 818 | // This nasty piece of code validates a token. |
@@ -808,12 +843,14 @@ discard block |
||
808 | 843 | fatal_lang_error('token_verify_fail', false); |
809 | 844 | } |
810 | 845 | // Remove this token as its useless |
811 | - else |
|
812 | - unset($_SESSION['token'][$type . '-' . $action]); |
|
846 | + else { |
|
847 | + unset($_SESSION['token'][$type . '-' . $action]); |
|
848 | + } |
|
813 | 849 | |
814 | 850 | // Randomly check if we should remove some older tokens. |
815 | - if (mt_rand(0, 138) == 23) |
|
816 | - cleanTokens(); |
|
851 | + if (mt_rand(0, 138) == 23) { |
|
852 | + cleanTokens(); |
|
853 | + } |
|
817 | 854 | |
818 | 855 | return false; |
819 | 856 | } |
@@ -828,14 +865,16 @@ discard block |
||
828 | 865 | function cleanTokens($complete = false) |
829 | 866 | { |
830 | 867 | // We appreciate cleaning up after yourselves. |
831 | - if (!isset($_SESSION['token'])) |
|
832 | - return; |
|
868 | + if (!isset($_SESSION['token'])) { |
|
869 | + return; |
|
870 | + } |
|
833 | 871 | |
834 | 872 | // Clean up tokens, trying to give enough time still. |
835 | - foreach ($_SESSION['token'] as $key => $data) |
|
836 | - if ($data[2] + 10800 < time() || $complete) |
|
873 | + foreach ($_SESSION['token'] as $key => $data) { |
|
874 | + if ($data[2] + 10800 < time() || $complete) |
|
837 | 875 | unset($_SESSION['token'][$key]); |
838 | -} |
|
876 | + } |
|
877 | + } |
|
839 | 878 | |
840 | 879 | /** |
841 | 880 | * Check whether a form has been submitted twice. |
@@ -853,37 +892,40 @@ discard block |
||
853 | 892 | { |
854 | 893 | global $context; |
855 | 894 | |
856 | - if (!isset($_SESSION['forms'])) |
|
857 | - $_SESSION['forms'] = array(); |
|
895 | + if (!isset($_SESSION['forms'])) { |
|
896 | + $_SESSION['forms'] = array(); |
|
897 | + } |
|
858 | 898 | |
859 | 899 | // Register a form number and store it in the session stack. (use this on the page that has the form.) |
860 | 900 | if ($action == 'register') |
861 | 901 | { |
862 | 902 | $context['form_sequence_number'] = 0; |
863 | - while (empty($context['form_sequence_number']) || in_array($context['form_sequence_number'], $_SESSION['forms'])) |
|
864 | - $context['form_sequence_number'] = mt_rand(1, 16000000); |
|
903 | + while (empty($context['form_sequence_number']) || in_array($context['form_sequence_number'], $_SESSION['forms'])) { |
|
904 | + $context['form_sequence_number'] = mt_rand(1, 16000000); |
|
905 | + } |
|
865 | 906 | } |
866 | 907 | // Check whether the submitted number can be found in the session. |
867 | 908 | elseif ($action == 'check') |
868 | 909 | { |
869 | - if (!isset($_REQUEST['seqnum'])) |
|
870 | - return true; |
|
871 | - elseif (!in_array($_REQUEST['seqnum'], $_SESSION['forms'])) |
|
910 | + if (!isset($_REQUEST['seqnum'])) { |
|
911 | + return true; |
|
912 | + } elseif (!in_array($_REQUEST['seqnum'], $_SESSION['forms'])) |
|
872 | 913 | { |
873 | 914 | $_SESSION['forms'][] = (int) $_REQUEST['seqnum']; |
874 | 915 | return true; |
916 | + } elseif ($is_fatal) { |
|
917 | + fatal_lang_error('error_form_already_submitted', false); |
|
918 | + } else { |
|
919 | + return false; |
|
875 | 920 | } |
876 | - elseif ($is_fatal) |
|
877 | - fatal_lang_error('error_form_already_submitted', false); |
|
878 | - else |
|
879 | - return false; |
|
880 | 921 | } |
881 | 922 | // Don't check, just free the stack number. |
882 | - elseif ($action == 'free' && isset($_REQUEST['seqnum']) && in_array($_REQUEST['seqnum'], $_SESSION['forms'])) |
|
883 | - $_SESSION['forms'] = array_diff($_SESSION['forms'], array($_REQUEST['seqnum'])); |
|
884 | - elseif ($action != 'free') |
|
885 | - trigger_error('checkSubmitOnce(): Invalid action \'' . $action . '\'', E_USER_WARNING); |
|
886 | -} |
|
923 | + elseif ($action == 'free' && isset($_REQUEST['seqnum']) && in_array($_REQUEST['seqnum'], $_SESSION['forms'])) { |
|
924 | + $_SESSION['forms'] = array_diff($_SESSION['forms'], array($_REQUEST['seqnum'])); |
|
925 | + } elseif ($action != 'free') { |
|
926 | + trigger_error('checkSubmitOnce(): Invalid action \'' . $action . '\'', E_USER_WARNING); |
|
927 | + } |
|
928 | + } |
|
887 | 929 | |
888 | 930 | /** |
889 | 931 | * Check the user's permissions. |
@@ -900,16 +942,19 @@ discard block |
||
900 | 942 | global $user_info, $smcFunc; |
901 | 943 | |
902 | 944 | // You're always allowed to do nothing. (unless you're a working man, MR. LAZY :P!) |
903 | - if (empty($permission)) |
|
904 | - return true; |
|
945 | + if (empty($permission)) { |
|
946 | + return true; |
|
947 | + } |
|
905 | 948 | |
906 | 949 | // You're never allowed to do something if your data hasn't been loaded yet! |
907 | - if (empty($user_info)) |
|
908 | - return false; |
|
950 | + if (empty($user_info)) { |
|
951 | + return false; |
|
952 | + } |
|
909 | 953 | |
910 | 954 | // Administrators are supermen :P. |
911 | - if ($user_info['is_admin']) |
|
912 | - return true; |
|
955 | + if ($user_info['is_admin']) { |
|
956 | + return true; |
|
957 | + } |
|
913 | 958 | |
914 | 959 | // Let's ensure this is an array. |
915 | 960 | $permission = (array)$permission; |
@@ -917,14 +962,16 @@ discard block |
||
917 | 962 | // Are we checking the _current_ board, or some other boards? |
918 | 963 | if ($boards === null) |
919 | 964 | { |
920 | - if (count(array_intersect($permission, $user_info['permissions'])) != 0) |
|
921 | - return true; |
|
965 | + if (count(array_intersect($permission, $user_info['permissions'])) != 0) { |
|
966 | + return true; |
|
967 | + } |
|
922 | 968 | // You aren't allowed, by default. |
923 | - else |
|
924 | - return false; |
|
969 | + else { |
|
970 | + return false; |
|
971 | + } |
|
972 | + } elseif (!is_array($boards)) { |
|
973 | + $boards = array($boards); |
|
925 | 974 | } |
926 | - elseif (!is_array($boards)) |
|
927 | - $boards = array($boards); |
|
928 | 975 | |
929 | 976 | $request = $smcFunc['db_query']('', ' |
930 | 977 | SELECT MIN(bp.add_deny) AS add_deny |
@@ -947,12 +994,14 @@ discard block |
||
947 | 994 | ); |
948 | 995 | |
949 | 996 | // Make sure they can do it on all of the boards. |
950 | - if ($smcFunc['db_num_rows']($request) != count($boards)) |
|
951 | - return false; |
|
997 | + if ($smcFunc['db_num_rows']($request) != count($boards)) { |
|
998 | + return false; |
|
999 | + } |
|
952 | 1000 | |
953 | 1001 | $result = true; |
954 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
955 | - $result &= !empty($row['add_deny']); |
|
1002 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1003 | + $result &= !empty($row['add_deny']); |
|
1004 | + } |
|
956 | 1005 | $smcFunc['db_free_result']($request); |
957 | 1006 | |
958 | 1007 | // If the query returned 1, they can do it... otherwise, they can't. |
@@ -1017,9 +1066,10 @@ discard block |
||
1017 | 1066 | |
1018 | 1067 | // If you're doing something on behalf of some "heavy" permissions, validate your session. |
1019 | 1068 | // (take out the heavy permissions, and if you can't do anything but those, you need a validated session.) |
1020 | - if (!allowedTo(array_diff($permission, $heavy_permissions), $boards)) |
|
1021 | - validateSession(); |
|
1022 | -} |
|
1069 | + if (!allowedTo(array_diff($permission, $heavy_permissions), $boards)) { |
|
1070 | + validateSession(); |
|
1071 | + } |
|
1072 | + } |
|
1023 | 1073 | |
1024 | 1074 | /** |
1025 | 1075 | * Return the boards a user has a certain (board) permission on. (array(0) if all.) |
@@ -1038,8 +1088,9 @@ discard block |
||
1038 | 1088 | global $user_info, $smcFunc; |
1039 | 1089 | |
1040 | 1090 | // Arrays are nice, most of the time. |
1041 | - if (!is_array($permissions)) |
|
1042 | - $permissions = array($permissions); |
|
1091 | + if (!is_array($permissions)) { |
|
1092 | + $permissions = array($permissions); |
|
1093 | + } |
|
1043 | 1094 | |
1044 | 1095 | /* |
1045 | 1096 | * Set $simple to true to use this function as it were in SMF 2.0.x. |
@@ -1051,13 +1102,14 @@ discard block |
||
1051 | 1102 | // Administrators are all powerful, sorry. |
1052 | 1103 | if ($user_info['is_admin']) |
1053 | 1104 | { |
1054 | - if ($simple) |
|
1055 | - return array(0); |
|
1056 | - else |
|
1105 | + if ($simple) { |
|
1106 | + return array(0); |
|
1107 | + } else |
|
1057 | 1108 | { |
1058 | 1109 | $boards = array(); |
1059 | - foreach ($permissions as $permission) |
|
1060 | - $boards[$permission] = array(0); |
|
1110 | + foreach ($permissions as $permission) { |
|
1111 | + $boards[$permission] = array(0); |
|
1112 | + } |
|
1061 | 1113 | |
1062 | 1114 | return $boards; |
1063 | 1115 | } |
@@ -1089,31 +1141,32 @@ discard block |
||
1089 | 1141 | { |
1090 | 1142 | if ($simple) |
1091 | 1143 | { |
1092 | - if (empty($row['add_deny'])) |
|
1093 | - $deny_boards[] = $row['id_board']; |
|
1094 | - else |
|
1095 | - $boards[] = $row['id_board']; |
|
1096 | - } |
|
1097 | - else |
|
1144 | + if (empty($row['add_deny'])) { |
|
1145 | + $deny_boards[] = $row['id_board']; |
|
1146 | + } else { |
|
1147 | + $boards[] = $row['id_board']; |
|
1148 | + } |
|
1149 | + } else |
|
1098 | 1150 | { |
1099 | - if (empty($row['add_deny'])) |
|
1100 | - $deny_boards[$row['permission']][] = $row['id_board']; |
|
1101 | - else |
|
1102 | - $boards[$row['permission']][] = $row['id_board']; |
|
1151 | + if (empty($row['add_deny'])) { |
|
1152 | + $deny_boards[$row['permission']][] = $row['id_board']; |
|
1153 | + } else { |
|
1154 | + $boards[$row['permission']][] = $row['id_board']; |
|
1155 | + } |
|
1103 | 1156 | } |
1104 | 1157 | } |
1105 | 1158 | $smcFunc['db_free_result']($request); |
1106 | 1159 | |
1107 | - if ($simple) |
|
1108 | - $boards = array_unique(array_values(array_diff($boards, $deny_boards))); |
|
1109 | - else |
|
1160 | + if ($simple) { |
|
1161 | + $boards = array_unique(array_values(array_diff($boards, $deny_boards))); |
|
1162 | + } else |
|
1110 | 1163 | { |
1111 | 1164 | foreach ($permissions as $permission) |
1112 | 1165 | { |
1113 | 1166 | // never had it to start with |
1114 | - if (empty($boards[$permission])) |
|
1115 | - $boards[$permission] = array(); |
|
1116 | - else |
|
1167 | + if (empty($boards[$permission])) { |
|
1168 | + $boards[$permission] = array(); |
|
1169 | + } else |
|
1117 | 1170 | { |
1118 | 1171 | // Or it may have been removed |
1119 | 1172 | $deny_boards[$permission] = isset($deny_boards[$permission]) ? $deny_boards[$permission] : array(); |
@@ -1149,10 +1202,11 @@ discard block |
||
1149 | 1202 | |
1150 | 1203 | |
1151 | 1204 | // Moderators are free... |
1152 | - if (!allowedTo('moderate_board')) |
|
1153 | - $timeLimit = isset($timeOverrides[$error_type]) ? $timeOverrides[$error_type] : $modSettings['spamWaitTime']; |
|
1154 | - else |
|
1155 | - $timeLimit = 2; |
|
1205 | + if (!allowedTo('moderate_board')) { |
|
1206 | + $timeLimit = isset($timeOverrides[$error_type]) ? $timeOverrides[$error_type] : $modSettings['spamWaitTime']; |
|
1207 | + } else { |
|
1208 | + $timeLimit = 2; |
|
1209 | + } |
|
1156 | 1210 | |
1157 | 1211 | call_integration_hook('integrate_spam_protection', array(&$timeOverrides, &$timeLimit)); |
1158 | 1212 | |
@@ -1179,8 +1233,9 @@ discard block |
||
1179 | 1233 | if ($smcFunc['db_affected_rows']() != 1) |
1180 | 1234 | { |
1181 | 1235 | // Spammer! You only have to wait a *few* seconds! |
1182 | - if (!$only_return_result) |
|
1183 | - fatal_lang_error($error_type . '_WaitTime_broken', false, array($timeLimit)); |
|
1236 | + if (!$only_return_result) { |
|
1237 | + fatal_lang_error($error_type . '_WaitTime_broken', false, array($timeLimit)); |
|
1238 | + } |
|
1184 | 1239 | |
1185 | 1240 | return true; |
1186 | 1241 | } |
@@ -1198,11 +1253,13 @@ discard block |
||
1198 | 1253 | */ |
1199 | 1254 | function secureDirectory($path, $attachments = false) |
1200 | 1255 | { |
1201 | - if (empty($path)) |
|
1202 | - return 'empty_path'; |
|
1256 | + if (empty($path)) { |
|
1257 | + return 'empty_path'; |
|
1258 | + } |
|
1203 | 1259 | |
1204 | - if (!is_writable($path)) |
|
1205 | - return 'path_not_writable'; |
|
1260 | + if (!is_writable($path)) { |
|
1261 | + return 'path_not_writable'; |
|
1262 | + } |
|
1206 | 1263 | |
1207 | 1264 | $directoryname = basename($path); |
1208 | 1265 | |
@@ -1214,9 +1271,9 @@ discard block |
||
1214 | 1271 | |
1215 | 1272 | RemoveHandler .php .php3 .phtml .cgi .fcgi .pl .fpl .shtml'; |
1216 | 1273 | |
1217 | - if (file_exists($path . '/.htaccess')) |
|
1218 | - $errors[] = 'htaccess_exists'; |
|
1219 | - else |
|
1274 | + if (file_exists($path . '/.htaccess')) { |
|
1275 | + $errors[] = 'htaccess_exists'; |
|
1276 | + } else |
|
1220 | 1277 | { |
1221 | 1278 | $fh = @fopen($path . '/.htaccess', 'w'); |
1222 | 1279 | if ($fh) { |
@@ -1228,9 +1285,9 @@ discard block |
||
1228 | 1285 | $errors[] = 'htaccess_cannot_create_file'; |
1229 | 1286 | } |
1230 | 1287 | |
1231 | - if (file_exists($path . '/index.php')) |
|
1232 | - $errors[] = 'index-php_exists'; |
|
1233 | - else |
|
1288 | + if (file_exists($path . '/index.php')) { |
|
1289 | + $errors[] = 'index-php_exists'; |
|
1290 | + } else |
|
1234 | 1291 | { |
1235 | 1292 | $fh = @fopen($path . '/index.php', 'w'); |
1236 | 1293 | if ($fh) { |
@@ -1257,11 +1314,12 @@ discard block |
||
1257 | 1314 | $errors[] = 'index-php_cannot_create_file'; |
1258 | 1315 | } |
1259 | 1316 | |
1260 | - if (!empty($errors)) |
|
1261 | - return $errors; |
|
1262 | - else |
|
1263 | - return true; |
|
1264 | -} |
|
1317 | + if (!empty($errors)) { |
|
1318 | + return $errors; |
|
1319 | + } else { |
|
1320 | + return true; |
|
1321 | + } |
|
1322 | + } |
|
1265 | 1323 | |
1266 | 1324 | /** |
1267 | 1325 | * This sets the X-Frame-Options header. |
@@ -1274,14 +1332,16 @@ discard block |
||
1274 | 1332 | global $modSettings; |
1275 | 1333 | |
1276 | 1334 | $option = 'SAMEORIGIN'; |
1277 | - if (is_null($override) && !empty($modSettings['frame_security'])) |
|
1278 | - $option = $modSettings['frame_security']; |
|
1279 | - elseif (in_array($override, array('SAMEORIGIN', 'DENY'))) |
|
1280 | - $option = $override; |
|
1335 | + if (is_null($override) && !empty($modSettings['frame_security'])) { |
|
1336 | + $option = $modSettings['frame_security']; |
|
1337 | + } elseif (in_array($override, array('SAMEORIGIN', 'DENY'))) { |
|
1338 | + $option = $override; |
|
1339 | + } |
|
1281 | 1340 | |
1282 | 1341 | // Don't bother setting the header if we have disabled it. |
1283 | - if ($option == 'DISABLE') |
|
1284 | - return; |
|
1342 | + if ($option == 'DISABLE') { |
|
1343 | + return; |
|
1344 | + } |
|
1285 | 1345 | |
1286 | 1346 | // Finally set it. |
1287 | 1347 | header('X-Frame-Options: ' . $option); |
@@ -11,8 +11,9 @@ discard block |
||
11 | 11 | * @version 2.1 Beta 3 |
12 | 12 | */ |
13 | 13 | |
14 | -if (!defined('SMF')) |
|
14 | +if (!defined('SMF')) { |
|
15 | 15 | die('Hacking attempt...'); |
16 | +} |
|
16 | 17 | |
17 | 18 | /** |
18 | 19 | * Interface cache_api_interface |
@@ -186,8 +187,9 @@ discard block |
||
186 | 187 | { |
187 | 188 | global $cache_enable; |
188 | 189 | |
189 | - if ($test) |
|
190 | - return true; |
|
190 | + if ($test) { |
|
191 | + return true; |
|
192 | + } |
|
191 | 193 | return !empty($cache_enable); |
192 | 194 | } |
193 | 195 | |
@@ -206,10 +208,11 @@ discard block |
||
206 | 208 | global $boardurl, $cachedir; |
207 | 209 | |
208 | 210 | // Set the default if no prefix was specified. |
209 | - if (empty($prefix)) |
|
210 | - $this->prefix = md5($boardurl . filemtime($cachedir . '/' . 'index.php')) . '-SMF-'; |
|
211 | - else |
|
212 | - $this->prefix = $prefix; |
|
211 | + if (empty($prefix)) { |
|
212 | + $this->prefix = md5($boardurl . filemtime($cachedir . '/' . 'index.php')) . '-SMF-'; |
|
213 | + } else { |
|
214 | + $this->prefix = $prefix; |
|
215 | + } |
|
213 | 216 | |
214 | 217 | return true; |
215 | 218 | } |
@@ -272,8 +275,9 @@ discard block |
||
272 | 275 | |
273 | 276 | // Invalidate cache, to be sure! |
274 | 277 | // ... as long as index.php can be modified, anyway. |
275 | - if (is_writable($cachedir . '/' . 'index.php')) |
|
276 | - @touch($cachedir . '/' . 'index.php'); |
|
278 | + if (is_writable($cachedir . '/' . 'index.php')) { |
|
279 | + @touch($cachedir . '/' . 'index.php'); |
|
280 | + } |
|
277 | 281 | |
278 | 282 | return true; |
279 | 283 | } |