@@ -12,8 +12,9 @@ discard block |
||
| 12 | 12 | * @version 2.1 Beta 4 |
| 13 | 13 | */ |
| 14 | 14 | |
| 15 | -if (!defined('SMF')) |
|
| 15 | +if (!defined('SMF')) { |
|
| 16 | 16 | die('No direct access...'); |
| 17 | +} |
|
| 17 | 18 | |
| 18 | 19 | /** |
| 19 | 20 | * Create a new list |
@@ -41,21 +42,21 @@ discard block |
||
| 41 | 42 | { |
| 42 | 43 | $list_context['sort'] = array(); |
| 43 | 44 | $sort = '1=1'; |
| 44 | - } |
|
| 45 | - else |
|
| 45 | + } else |
|
| 46 | 46 | { |
| 47 | 47 | $request_var_sort = isset($listOptions['request_vars']['sort']) ? $listOptions['request_vars']['sort'] : 'sort'; |
| 48 | 48 | $request_var_desc = isset($listOptions['request_vars']['desc']) ? $listOptions['request_vars']['desc'] : 'desc'; |
| 49 | - if (isset($_REQUEST[$request_var_sort], $listOptions['columns'][$_REQUEST[$request_var_sort]], $listOptions['columns'][$_REQUEST[$request_var_sort]]['sort'])) |
|
| 50 | - $list_context['sort'] = array( |
|
| 49 | + if (isset($_REQUEST[$request_var_sort], $listOptions['columns'][$_REQUEST[$request_var_sort]], $listOptions['columns'][$_REQUEST[$request_var_sort]]['sort'])) { |
|
| 50 | + $list_context['sort'] = array( |
|
| 51 | 51 | 'id' => $_REQUEST[$request_var_sort], |
| 52 | 52 | 'desc' => isset($_REQUEST[$request_var_desc]) && isset($listOptions['columns'][$_REQUEST[$request_var_sort]]['sort']['reverse']), |
| 53 | 53 | ); |
| 54 | - else |
|
| 55 | - $list_context['sort'] = array( |
|
| 54 | + } else { |
|
| 55 | + $list_context['sort'] = array( |
|
| 56 | 56 | 'id' => $listOptions['default_sort_col'], |
| 57 | 57 | 'desc' => (!empty($listOptions['default_sort_dir']) && $listOptions['default_sort_dir'] == 'desc') || (!empty($listOptions['columns'][$listOptions['default_sort_col']]['sort']['default']) && substr($listOptions['columns'][$listOptions['default_sort_col']]['sort']['default'], -4, 4) == 'desc') ? true : false, |
| 58 | 58 | ); |
| 59 | + } |
|
| 59 | 60 | |
| 60 | 61 | // Set the database column sort. |
| 61 | 62 | $sort = $listOptions['columns'][$list_context['sort']['id']]['sort'][$list_context['sort']['desc'] ? 'reverse' : 'default']; |
@@ -72,8 +73,9 @@ discard block |
||
| 72 | 73 | else |
| 73 | 74 | { |
| 74 | 75 | // First get an impression of how many items to expect. |
| 75 | - if (isset($listOptions['get_count']['file'])) |
|
| 76 | - require_once($listOptions['get_count']['file']); |
|
| 76 | + if (isset($listOptions['get_count']['file'])) { |
|
| 77 | + require_once($listOptions['get_count']['file']); |
|
| 78 | + } |
|
| 77 | 79 | |
| 78 | 80 | $call = call_helper($listOptions['get_count']['function'], true); |
| 79 | 81 | $list_context['total_num_items'] = call_user_func_array($call, empty($listOptions['get_count']['params']) ? array() : $listOptions['get_count']['params']); |
@@ -83,14 +85,15 @@ discard block |
||
| 83 | 85 | $list_context['items_per_page'] = $listOptions['items_per_page']; |
| 84 | 86 | |
| 85 | 87 | // Then create a page index. |
| 86 | - if ($list_context['total_num_items'] > $list_context['items_per_page']) |
|
| 87 | - $list_context['page_index'] = constructPageIndex($listOptions['base_href'] . (empty($list_context['sort']) ? '' : ';' . $request_var_sort . '=' . $list_context['sort']['id'] . ($list_context['sort']['desc'] ? ';' . $request_var_desc : '')) . ($list_context['start_var_name'] != 'start' ? ';' . $list_context['start_var_name'] . '=%1$d' : ''), $list_context['start'], $list_context['total_num_items'], $list_context['items_per_page'], $list_context['start_var_name'] != 'start'); |
|
| 88 | + if ($list_context['total_num_items'] > $list_context['items_per_page']) { |
|
| 89 | + $list_context['page_index'] = constructPageIndex($listOptions['base_href'] . (empty($list_context['sort']) ? '' : ';' . $request_var_sort . '=' . $list_context['sort']['id'] . ($list_context['sort']['desc'] ? ';' . $request_var_desc : '')) . ($list_context['start_var_name'] != 'start' ? ';' . $list_context['start_var_name'] . '=%1$d' : ''), $list_context['start'], $list_context['total_num_items'], $list_context['items_per_page'], $list_context['start_var_name'] != 'start'); |
|
| 90 | + } |
|
| 88 | 91 | } |
| 89 | 92 | |
| 90 | 93 | // Prepare the headers of the table. |
| 91 | 94 | $list_context['headers'] = array(); |
| 92 | - foreach ($listOptions['columns'] as $column_id => $column) |
|
| 93 | - $list_context['headers'][] = array( |
|
| 95 | + foreach ($listOptions['columns'] as $column_id => $column) { |
|
| 96 | + $list_context['headers'][] = array( |
|
| 94 | 97 | 'id' => $column_id, |
| 95 | 98 | 'label' => isset($column['header']['eval']) ? eval($column['header']['eval']) : (isset($column['header']['value']) ? $column['header']['value'] : ''), |
| 96 | 99 | 'href' => empty($listOptions['default_sort_col']) || empty($column['sort']) ? '' : $listOptions['base_href'] . ';' . $request_var_sort . '=' . $column_id . ($column_id === $list_context['sort']['id'] && !$list_context['sort']['desc'] && isset($column['sort']['reverse']) ? ';' . $request_var_desc : '') . (empty($list_context['start']) ? '' : ';' . $list_context['start_var_name'] . '=' . $list_context['start']), |
@@ -99,14 +102,16 @@ discard block |
||
| 99 | 102 | 'style' => isset($column['header']['style']) ? $column['header']['style'] : '', |
| 100 | 103 | 'colspan' => isset($column['header']['colspan']) ? $column['header']['colspan'] : '', |
| 101 | 104 | ); |
| 105 | + } |
|
| 102 | 106 | |
| 103 | 107 | // We know the amount of columns, might be useful for the template. |
| 104 | 108 | $list_context['num_columns'] = count($listOptions['columns']); |
| 105 | 109 | $list_context['width'] = isset($listOptions['width']) ? $listOptions['width'] : '0'; |
| 106 | 110 | |
| 107 | 111 | // Get the file with the function for the item list. |
| 108 | - if (isset($listOptions['get_items']['file'])) |
|
| 109 | - require_once($listOptions['get_items']['file']); |
|
| 112 | + if (isset($listOptions['get_items']['file'])) { |
|
| 113 | + require_once($listOptions['get_items']['file']); |
|
| 114 | + } |
|
| 110 | 115 | |
| 111 | 116 | // Call the function and include which items we want and in what order. |
| 112 | 117 | $call = call_helper($listOptions['get_items']['function'], true); |
@@ -123,51 +128,61 @@ discard block |
||
| 123 | 128 | $cur_data = array(); |
| 124 | 129 | |
| 125 | 130 | // A value straight from the database? |
| 126 | - if (isset($column['data']['db'])) |
|
| 127 | - $cur_data['value'] = $list_item[$column['data']['db']]; |
|
| 131 | + if (isset($column['data']['db'])) { |
|
| 132 | + $cur_data['value'] = $list_item[$column['data']['db']]; |
|
| 133 | + } |
|
| 128 | 134 | |
| 129 | 135 | // Take the value from the database and make it HTML safe. |
| 130 | - elseif (isset($column['data']['db_htmlsafe'])) |
|
| 131 | - $cur_data['value'] = $smcFunc['htmlspecialchars']($list_item[$column['data']['db_htmlsafe']]); |
|
| 136 | + elseif (isset($column['data']['db_htmlsafe'])) { |
|
| 137 | + $cur_data['value'] = $smcFunc['htmlspecialchars']($list_item[$column['data']['db_htmlsafe']]); |
|
| 138 | + } |
|
| 132 | 139 | |
| 133 | 140 | // Using sprintf is probably the most readable way of injecting data. |
| 134 | 141 | elseif (isset($column['data']['sprintf'])) |
| 135 | 142 | { |
| 136 | 143 | $params = array(); |
| 137 | - foreach ($column['data']['sprintf']['params'] as $sprintf_param => $htmlsafe) |
|
| 138 | - $params[] = $htmlsafe ? $smcFunc['htmlspecialchars']($list_item[$sprintf_param]) : $list_item[$sprintf_param]; |
|
| 144 | + foreach ($column['data']['sprintf']['params'] as $sprintf_param => $htmlsafe) { |
|
| 145 | + $params[] = $htmlsafe ? $smcFunc['htmlspecialchars']($list_item[$sprintf_param]) : $list_item[$sprintf_param]; |
|
| 146 | + } |
|
| 139 | 147 | $cur_data['value'] = vsprintf($column['data']['sprintf']['format'], $params); |
| 140 | 148 | } |
| 141 | 149 | |
| 142 | 150 | // The most flexible way probably is applying a custom function. |
| 143 | - elseif (isset($column['data']['function'])) |
|
| 144 | - $cur_data['value'] = call_user_func_array($column['data']['function'], array($list_item)); |
|
| 151 | + elseif (isset($column['data']['function'])) { |
|
| 152 | + $cur_data['value'] = call_user_func_array($column['data']['function'], array($list_item)); |
|
| 153 | + } |
|
| 145 | 154 | |
| 146 | 155 | // A modified value (inject the database values). |
| 147 | - elseif (isset($column['data']['eval'])) |
|
| 148 | - $cur_data['value'] = eval(preg_replace('~%([a-zA-Z0-9\-_]+)%~', '$list_item[\'$1\']', $column['data']['eval'])); |
|
| 156 | + elseif (isset($column['data']['eval'])) { |
|
| 157 | + $cur_data['value'] = eval(preg_replace('~%([a-zA-Z0-9\-_]+)%~', '$list_item[\'$1\']', $column['data']['eval'])); |
|
| 158 | + } |
|
| 149 | 159 | |
| 150 | 160 | // A literal value. |
| 151 | - elseif (isset($column['data']['value'])) |
|
| 152 | - $cur_data['value'] = $column['data']['value']; |
|
| 161 | + elseif (isset($column['data']['value'])) { |
|
| 162 | + $cur_data['value'] = $column['data']['value']; |
|
| 163 | + } |
|
| 153 | 164 | |
| 154 | 165 | // Empty value. |
| 155 | - else |
|
| 156 | - $cur_data['value'] = ''; |
|
| 166 | + else { |
|
| 167 | + $cur_data['value'] = ''; |
|
| 168 | + } |
|
| 157 | 169 | |
| 158 | 170 | // Allow for basic formatting. |
| 159 | - if (!empty($column['data']['comma_format'])) |
|
| 160 | - $cur_data['value'] = comma_format($cur_data['value']); |
|
| 161 | - elseif (!empty($column['data']['timeformat'])) |
|
| 162 | - $cur_data['value'] = timeformat($cur_data['value']); |
|
| 171 | + if (!empty($column['data']['comma_format'])) { |
|
| 172 | + $cur_data['value'] = comma_format($cur_data['value']); |
|
| 173 | + } elseif (!empty($column['data']['timeformat'])) { |
|
| 174 | + $cur_data['value'] = timeformat($cur_data['value']); |
|
| 175 | + } |
|
| 163 | 176 | |
| 164 | 177 | // Set a style class for this column? |
| 165 | - if (isset($column['data']['class'])) |
|
| 166 | - $cur_data['class'] = $column['data']['class']; |
|
| 178 | + if (isset($column['data']['class'])) { |
|
| 179 | + $cur_data['class'] = $column['data']['class']; |
|
| 180 | + } |
|
| 167 | 181 | |
| 168 | 182 | // Fully customized styling for the cells in this column only. |
| 169 | - if (isset($column['data']['style'])) |
|
| 170 | - $cur_data['style'] = $column['data']['style']; |
|
| 183 | + if (isset($column['data']['style'])) { |
|
| 184 | + $cur_data['style'] = $column['data']['style']; |
|
| 185 | + } |
|
| 171 | 186 | |
| 172 | 187 | // Add the data cell properties to the current row. |
| 173 | 188 | $cur_row[$column_id] = $cur_data; |
@@ -176,10 +191,12 @@ discard block |
||
| 176 | 191 | // Maybe we wat set a custom class for the row based on the data in the row itself |
| 177 | 192 | if (isset($listOptions['data_check'])) |
| 178 | 193 | { |
| 179 | - if (isset($listOptions['data_check']['class'])) |
|
| 180 | - $list_context['rows'][$item_id]['class'] = $listOptions['data_check']['class']($list_item); |
|
| 181 | - if (isset($listOptions['data_check']['style'])) |
|
| 182 | - $list_context['rows'][$item_id]['style'] = $listOptions['data_check']['style']($list_item); |
|
| 194 | + if (isset($listOptions['data_check']['class'])) { |
|
| 195 | + $list_context['rows'][$item_id]['class'] = $listOptions['data_check']['class']($list_item); |
|
| 196 | + } |
|
| 197 | + if (isset($listOptions['data_check']['style'])) { |
|
| 198 | + $list_context['rows'][$item_id]['style'] = $listOptions['data_check']['style']($list_item); |
|
| 199 | + } |
|
| 183 | 200 | } |
| 184 | 201 | |
| 185 | 202 | // Insert the row into the list. |
@@ -187,34 +204,39 @@ discard block |
||
| 187 | 204 | } |
| 188 | 205 | |
| 189 | 206 | // The title is currently optional. |
| 190 | - if (isset($listOptions['title'])) |
|
| 191 | - $list_context['title'] = $listOptions['title']; |
|
| 207 | + if (isset($listOptions['title'])) { |
|
| 208 | + $list_context['title'] = $listOptions['title']; |
|
| 209 | + } |
|
| 192 | 210 | |
| 193 | 211 | // In case there's a form, share it with the template context. |
| 194 | 212 | if (isset($listOptions['form'])) |
| 195 | 213 | { |
| 196 | 214 | $list_context['form'] = $listOptions['form']; |
| 197 | 215 | |
| 198 | - if (!isset($list_context['form']['hidden_fields'])) |
|
| 199 | - $list_context['form']['hidden_fields'] = array(); |
|
| 216 | + if (!isset($list_context['form']['hidden_fields'])) { |
|
| 217 | + $list_context['form']['hidden_fields'] = array(); |
|
| 218 | + } |
|
| 200 | 219 | |
| 201 | 220 | // Always add a session check field. |
| 202 | 221 | $list_context['form']['hidden_fields'][$context['session_var']] = $context['session_id']; |
| 203 | 222 | |
| 204 | 223 | // Will this do a token check? |
| 205 | - if (isset($listOptions['form']['token'])) |
|
| 206 | - $list_context['form']['hidden_fields'][$context[$listOptions['form']['token'] . '_token_var']] = $context[$listOptions['form']['token'] . '_token']; |
|
| 224 | + if (isset($listOptions['form']['token'])) { |
|
| 225 | + $list_context['form']['hidden_fields'][$context[$listOptions['form']['token'] . '_token_var']] = $context[$listOptions['form']['token'] . '_token']; |
|
| 226 | + } |
|
| 207 | 227 | |
| 208 | 228 | // Include the starting page as hidden field? |
| 209 | - if (!empty($list_context['form']['include_start']) && !empty($list_context['start'])) |
|
| 210 | - $list_context['form']['hidden_fields'][$list_context['start_var_name']] = $list_context['start']; |
|
| 229 | + if (!empty($list_context['form']['include_start']) && !empty($list_context['start'])) { |
|
| 230 | + $list_context['form']['hidden_fields'][$list_context['start_var_name']] = $list_context['start']; |
|
| 231 | + } |
|
| 211 | 232 | |
| 212 | 233 | // If sorting needs to be the same after submitting, add the parameter. |
| 213 | 234 | if (!empty($list_context['form']['include_sort']) && !empty($list_context['sort'])) |
| 214 | 235 | { |
| 215 | 236 | $list_context['form']['hidden_fields']['sort'] = $list_context['sort']['id']; |
| 216 | - if ($list_context['sort']['desc']) |
|
| 217 | - $list_context['form']['hidden_fields']['desc'] = 1; |
|
| 237 | + if ($list_context['sort']['desc']) { |
|
| 238 | + $list_context['form']['hidden_fields']['desc'] = 1; |
|
| 239 | + } |
|
| 218 | 240 | } |
| 219 | 241 | } |
| 220 | 242 | |
@@ -231,24 +253,28 @@ discard block |
||
| 231 | 253 | $list_context['additional_rows'] = array(); |
| 232 | 254 | foreach ($listOptions['additional_rows'] as $row) |
| 233 | 255 | { |
| 234 | - if (empty($row)) |
|
| 235 | - continue; |
|
| 256 | + if (empty($row)) { |
|
| 257 | + continue; |
|
| 258 | + } |
|
| 236 | 259 | |
| 237 | 260 | // Supported row positions: top_of_list, after_title, |
| 238 | 261 | // above_column_headers, below_table_data, bottom_of_list. |
| 239 | - if (!isset($list_context['additional_rows'][$row['position']])) |
|
| 240 | - $list_context['additional_rows'][$row['position']] = array(); |
|
| 262 | + if (!isset($list_context['additional_rows'][$row['position']])) { |
|
| 263 | + $list_context['additional_rows'][$row['position']] = array(); |
|
| 264 | + } |
|
| 241 | 265 | $list_context['additional_rows'][$row['position']][] = $row; |
| 242 | 266 | } |
| 243 | 267 | } |
| 244 | 268 | |
| 245 | 269 | // Add an option for inline JavaScript. |
| 246 | - if (isset($listOptions['javascript'])) |
|
| 247 | - $list_context['javascript'] = $listOptions['javascript']; |
|
| 270 | + if (isset($listOptions['javascript'])) { |
|
| 271 | + $list_context['javascript'] = $listOptions['javascript']; |
|
| 272 | + } |
|
| 248 | 273 | |
| 249 | 274 | // We want a menu. |
| 250 | - if (isset($listOptions['list_menu'])) |
|
| 251 | - $list_context['list_menu'] = $listOptions['list_menu']; |
|
| 275 | + if (isset($listOptions['list_menu'])) { |
|
| 276 | + $list_context['list_menu'] = $listOptions['list_menu']; |
|
| 277 | + } |
|
| 252 | 278 | |
| 253 | 279 | // Make sure the template is loaded. |
| 254 | 280 | loadTemplate('GenericList'); |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 4 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * This function works out what to do! |
@@ -24,9 +25,9 @@ discard block |
||
| 24 | 25 | global $time_start, $smcFunc; |
| 25 | 26 | |
| 26 | 27 | // Special case for doing the mail queue. |
| 27 | - if (isset($_GET['scheduled']) && $_GET['scheduled'] == 'mailq') |
|
| 28 | - ReduceMailQueue(); |
|
| 29 | - else |
|
| 28 | + if (isset($_GET['scheduled']) && $_GET['scheduled'] == 'mailq') { |
|
| 29 | + ReduceMailQueue(); |
|
| 30 | + } else |
|
| 30 | 31 | { |
| 31 | 32 | $task_string = ''; |
| 32 | 33 | |
@@ -53,18 +54,20 @@ discard block |
||
| 53 | 54 | |
| 54 | 55 | // How long in seconds it the gap? |
| 55 | 56 | $duration = $row['time_regularity']; |
| 56 | - if ($row['time_unit'] == 'm') |
|
| 57 | - $duration *= 60; |
|
| 58 | - elseif ($row['time_unit'] == 'h') |
|
| 59 | - $duration *= 3600; |
|
| 60 | - elseif ($row['time_unit'] == 'd') |
|
| 61 | - $duration *= 86400; |
|
| 62 | - elseif ($row['time_unit'] == 'w') |
|
| 63 | - $duration *= 604800; |
|
| 57 | + if ($row['time_unit'] == 'm') { |
|
| 58 | + $duration *= 60; |
|
| 59 | + } elseif ($row['time_unit'] == 'h') { |
|
| 60 | + $duration *= 3600; |
|
| 61 | + } elseif ($row['time_unit'] == 'd') { |
|
| 62 | + $duration *= 86400; |
|
| 63 | + } elseif ($row['time_unit'] == 'w') { |
|
| 64 | + $duration *= 604800; |
|
| 65 | + } |
|
| 64 | 66 | |
| 65 | 67 | // If we were really late running this task actually skip the next one. |
| 66 | - if (time() + ($duration / 2) > $next_time) |
|
| 67 | - $next_time += $duration; |
|
| 68 | + if (time() + ($duration / 2) > $next_time) { |
|
| 69 | + $next_time += $duration; |
|
| 70 | + } |
|
| 68 | 71 | |
| 69 | 72 | // Update it now, so no others run this! |
| 70 | 73 | $smcFunc['db_query']('', ' |
@@ -81,16 +84,19 @@ discard block |
||
| 81 | 84 | $affected_rows = $smcFunc['db_affected_rows'](); |
| 82 | 85 | |
| 83 | 86 | // What kind of task are we handling? |
| 84 | - if (!empty($row['callable'])) |
|
| 85 | - $task_string = $row['callable']; |
|
| 87 | + if (!empty($row['callable'])) { |
|
| 88 | + $task_string = $row['callable']; |
|
| 89 | + } |
|
| 86 | 90 | |
| 87 | 91 | // Default SMF task or old mods? |
| 88 | - elseif (function_exists('scheduled_' . $row['task'])) |
|
| 89 | - $task_string = 'scheduled_' . $row['task']; |
|
| 92 | + elseif (function_exists('scheduled_' . $row['task'])) { |
|
| 93 | + $task_string = 'scheduled_' . $row['task']; |
|
| 94 | + } |
|
| 90 | 95 | |
| 91 | 96 | // One last resource, the task name. |
| 92 | - elseif (!empty($row['task'])) |
|
| 93 | - $task_string = $row['task']; |
|
| 97 | + elseif (!empty($row['task'])) { |
|
| 98 | + $task_string = $row['task']; |
|
| 99 | + } |
|
| 94 | 100 | |
| 95 | 101 | // The function must exist or we are wasting our time, plus do some timestamp checking, and database check! |
| 96 | 102 | if (!empty($task_string) && (!isset($_GET['ts']) || $_GET['ts'] == $row['next_time']) && $affected_rows) |
@@ -101,11 +107,11 @@ discard block |
||
| 101 | 107 | $callable_task = call_helper($task_string, true); |
| 102 | 108 | |
| 103 | 109 | // Perform the task. |
| 104 | - if (!empty($callable_task)) |
|
| 105 | - $completed = call_user_func($callable_task); |
|
| 106 | - |
|
| 107 | - else |
|
| 108 | - $completed = false; |
|
| 110 | + if (!empty($callable_task)) { |
|
| 111 | + $completed = call_user_func($callable_task); |
|
| 112 | + } else { |
|
| 113 | + $completed = false; |
|
| 114 | + } |
|
| 109 | 115 | |
| 110 | 116 | // Log that we did it ;) |
| 111 | 117 | if ($completed) |
@@ -138,18 +144,20 @@ discard block |
||
| 138 | 144 | ) |
| 139 | 145 | ); |
| 140 | 146 | // No new task scheduled yet? |
| 141 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
| 142 | - $nextEvent = time() + 86400; |
|
| 143 | - else |
|
| 144 | - list ($nextEvent) = $smcFunc['db_fetch_row']($request); |
|
| 147 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
| 148 | + $nextEvent = time() + 86400; |
|
| 149 | + } else { |
|
| 150 | + list ($nextEvent) = $smcFunc['db_fetch_row']($request); |
|
| 151 | + } |
|
| 145 | 152 | $smcFunc['db_free_result']($request); |
| 146 | 153 | |
| 147 | 154 | updateSettings(array('next_task_time' => $nextEvent)); |
| 148 | 155 | } |
| 149 | 156 | |
| 150 | 157 | // Shall we return? |
| 151 | - if (!isset($_GET['scheduled'])) |
|
| 152 | - return true; |
|
| 158 | + if (!isset($_GET['scheduled'])) { |
|
| 159 | + return true; |
|
| 160 | + } |
|
| 153 | 161 | |
| 154 | 162 | // Finally, send some stuff... |
| 155 | 163 | header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); |
@@ -181,16 +189,18 @@ discard block |
||
| 181 | 189 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 182 | 190 | { |
| 183 | 191 | // If this is no longer around we'll ignore it. |
| 184 | - if (empty($row['id_topic'])) |
|
| 185 | - continue; |
|
| 192 | + if (empty($row['id_topic'])) { |
|
| 193 | + continue; |
|
| 194 | + } |
|
| 186 | 195 | |
| 187 | 196 | // What type is it? |
| 188 | - if ($row['id_first_msg'] && $row['id_first_msg'] == $row['id_msg']) |
|
| 189 | - $type = 'topic'; |
|
| 190 | - elseif ($row['id_attach']) |
|
| 191 | - $type = 'attach'; |
|
| 192 | - else |
|
| 193 | - $type = 'msg'; |
|
| 197 | + if ($row['id_first_msg'] && $row['id_first_msg'] == $row['id_msg']) { |
|
| 198 | + $type = 'topic'; |
|
| 199 | + } elseif ($row['id_attach']) { |
|
| 200 | + $type = 'attach'; |
|
| 201 | + } else { |
|
| 202 | + $type = 'msg'; |
|
| 203 | + } |
|
| 194 | 204 | |
| 195 | 205 | // Add it to the array otherwise. |
| 196 | 206 | $notices[$row['id_board']][$type][] = array( |
@@ -211,8 +221,9 @@ discard block |
||
| 211 | 221 | ); |
| 212 | 222 | |
| 213 | 223 | // If nothing quit now. |
| 214 | - if (empty($notices)) |
|
| 215 | - return true; |
|
| 224 | + if (empty($notices)) { |
|
| 225 | + return true; |
|
| 226 | + } |
|
| 216 | 227 | |
| 217 | 228 | // Now we need to think about finding out *who* can approve - this is hard! |
| 218 | 229 | |
@@ -231,14 +242,16 @@ discard block |
||
| 231 | 242 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 232 | 243 | { |
| 233 | 244 | // Sorry guys, but we have to ignore guests AND members - it would be too many otherwise. |
| 234 | - if ($row['id_group'] < 2) |
|
| 235 | - continue; |
|
| 245 | + if ($row['id_group'] < 2) { |
|
| 246 | + continue; |
|
| 247 | + } |
|
| 236 | 248 | |
| 237 | 249 | $perms[$row['id_profile']][$row['add_deny'] ? 'add' : 'deny'][] = $row['id_group']; |
| 238 | 250 | |
| 239 | 251 | // Anyone who can access has to be considered. |
| 240 | - if ($row['add_deny']) |
|
| 241 | - $addGroups[] = $row['id_group']; |
|
| 252 | + if ($row['add_deny']) { |
|
| 253 | + $addGroups[] = $row['id_group']; |
|
| 254 | + } |
|
| 242 | 255 | } |
| 243 | 256 | $smcFunc['db_free_result']($request); |
| 244 | 257 | |
@@ -283,8 +296,9 @@ discard block |
||
| 283 | 296 | if (!empty($row['mod_prefs'])) |
| 284 | 297 | { |
| 285 | 298 | list(,, $pref_binary) = explode('|', $row['mod_prefs']); |
| 286 | - if (!($pref_binary & 4)) |
|
| 287 | - continue; |
|
| 299 | + if (!($pref_binary & 4)) { |
|
| 300 | + continue; |
|
| 301 | + } |
|
| 288 | 302 | } |
| 289 | 303 | |
| 290 | 304 | $members[$row['id_member']] = array( |
@@ -309,8 +323,9 @@ discard block |
||
| 309 | 323 | $emailbody = ''; |
| 310 | 324 | |
| 311 | 325 | // Load the language file as required. |
| 312 | - if (empty($current_language) || $current_language != $member['language']) |
|
| 313 | - $current_language = loadLanguage('EmailTemplates', $member['language'], false); |
|
| 326 | + if (empty($current_language) || $current_language != $member['language']) { |
|
| 327 | + $current_language = loadLanguage('EmailTemplates', $member['language'], false); |
|
| 328 | + } |
|
| 314 | 329 | |
| 315 | 330 | // Loop through each notice... |
| 316 | 331 | foreach ($notices as $board => $notice) |
@@ -318,29 +333,34 @@ discard block |
||
| 318 | 333 | $access = false; |
| 319 | 334 | |
| 320 | 335 | // Can they mod in this board? |
| 321 | - if (isset($mods[$id][$board])) |
|
| 322 | - $access = true; |
|
| 336 | + if (isset($mods[$id][$board])) { |
|
| 337 | + $access = true; |
|
| 338 | + } |
|
| 323 | 339 | |
| 324 | 340 | // Do the group check... |
| 325 | 341 | if (!$access && isset($perms[$profiles[$board]]['add'])) |
| 326 | 342 | { |
| 327 | 343 | // They can access?! |
| 328 | - if (array_intersect($perms[$profiles[$board]]['add'], $member['groups'])) |
|
| 329 | - $access = true; |
|
| 344 | + if (array_intersect($perms[$profiles[$board]]['add'], $member['groups'])) { |
|
| 345 | + $access = true; |
|
| 346 | + } |
|
| 330 | 347 | |
| 331 | 348 | // If they have deny rights don't consider them! |
| 332 | - if (isset($perms[$profiles[$board]]['deny'])) |
|
| 333 | - if (array_intersect($perms[$profiles[$board]]['deny'], $member['groups'])) |
|
| 349 | + if (isset($perms[$profiles[$board]]['deny'])) { |
|
| 350 | + if (array_intersect($perms[$profiles[$board]]['deny'], $member['groups'])) |
|
| 334 | 351 | $access = false; |
| 352 | + } |
|
| 335 | 353 | } |
| 336 | 354 | |
| 337 | 355 | // Finally, fix it for admins! |
| 338 | - if (in_array(1, $member['groups'])) |
|
| 339 | - $access = true; |
|
| 356 | + if (in_array(1, $member['groups'])) { |
|
| 357 | + $access = true; |
|
| 358 | + } |
|
| 340 | 359 | |
| 341 | 360 | // If they can't access it then give it a break! |
| 342 | - if (!$access) |
|
| 343 | - continue; |
|
| 361 | + if (!$access) { |
|
| 362 | + continue; |
|
| 363 | + } |
|
| 344 | 364 | |
| 345 | 365 | foreach ($notice as $type => $items) |
| 346 | 366 | { |
@@ -348,15 +368,17 @@ discard block |
||
| 348 | 368 | $emailbody .= $txt['scheduled_approval_email_' . $type] . "\n" . |
| 349 | 369 | '------------------------------------------------------' . "\n"; |
| 350 | 370 | |
| 351 | - foreach ($items as $item) |
|
| 352 | - $emailbody .= $item['subject'] . ' - ' . $item['href'] . "\n"; |
|
| 371 | + foreach ($items as $item) { |
|
| 372 | + $emailbody .= $item['subject'] . ' - ' . $item['href'] . "\n"; |
|
| 373 | + } |
|
| 353 | 374 | |
| 354 | 375 | $emailbody .= "\n"; |
| 355 | 376 | } |
| 356 | 377 | } |
| 357 | 378 | |
| 358 | - if ($emailbody == '') |
|
| 359 | - continue; |
|
| 379 | + if ($emailbody == '') { |
|
| 380 | + continue; |
|
| 381 | + } |
|
| 360 | 382 | |
| 361 | 383 | $replacements = array( |
| 362 | 384 | 'REALNAME' => $member['name'], |
@@ -397,8 +419,9 @@ discard block |
||
| 397 | 419 | ) |
| 398 | 420 | ); |
| 399 | 421 | $members = array(); |
| 400 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 401 | - $members[$row['id_member']] = $row['warning']; |
|
| 422 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 423 | + $members[$row['id_member']] = $row['warning']; |
|
| 424 | + } |
|
| 402 | 425 | $smcFunc['db_free_result']($request); |
| 403 | 426 | |
| 404 | 427 | // Have some members to check? |
@@ -420,17 +443,18 @@ discard block |
||
| 420 | 443 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 421 | 444 | { |
| 422 | 445 | // More than 24 hours ago? |
| 423 | - if ($row['last_warning'] <= time() - 86400) |
|
| 424 | - $member_changes[] = array( |
|
| 446 | + if ($row['last_warning'] <= time() - 86400) { |
|
| 447 | + $member_changes[] = array( |
|
| 425 | 448 | 'id' => $row['id_recipient'], |
| 426 | 449 | 'warning' => $members[$row['id_recipient']] >= $modSettings['warning_decrement'] ? $members[$row['id_recipient']] - $modSettings['warning_decrement'] : 0, |
| 427 | 450 | ); |
| 451 | + } |
|
| 428 | 452 | } |
| 429 | 453 | $smcFunc['db_free_result']($request); |
| 430 | 454 | |
| 431 | 455 | // Have some members to change? |
| 432 | - if (!empty($member_changes)) |
|
| 433 | - foreach ($member_changes as $change) |
|
| 456 | + if (!empty($member_changes)) { |
|
| 457 | + foreach ($member_changes as $change) |
|
| 434 | 458 | $smcFunc['db_query']('', ' |
| 435 | 459 | UPDATE {db_prefix}members |
| 436 | 460 | SET warning = {int:warning} |
@@ -440,6 +464,7 @@ discard block |
||
| 440 | 464 | 'id_member' => $change['id'], |
| 441 | 465 | ) |
| 442 | 466 | ); |
| 467 | + } |
|
| 443 | 468 | } |
| 444 | 469 | } |
| 445 | 470 | |
@@ -452,16 +477,17 @@ discard block |
||
| 452 | 477 | |
| 453 | 478 | // Check the database version - for some buggy MySQL version. |
| 454 | 479 | $server_version = $smcFunc['db_server_info'](); |
| 455 | - if (($db_type == 'mysql') && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) |
|
| 456 | - updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
| 457 | - elseif (!empty($modSettings['db_mysql_group_by_fix'])) |
|
| 458 | - $smcFunc['db_query']('', ' |
|
| 480 | + if (($db_type == 'mysql') && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) { |
|
| 481 | + updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
| 482 | + } elseif (!empty($modSettings['db_mysql_group_by_fix'])) { |
|
| 483 | + $smcFunc['db_query']('', ' |
|
| 459 | 484 | DELETE FROM {db_prefix}settings |
| 460 | 485 | WHERE variable = {string:mysql_fix}', |
| 461 | 486 | array( |
| 462 | 487 | 'mysql_fix' => 'db_mysql_group_by_fix', |
| 463 | 488 | ) |
| 464 | 489 | ); |
| 490 | + } |
|
| 465 | 491 | |
| 466 | 492 | // Clean up some old login history information. |
| 467 | 493 | $smcFunc['db_query']('', ' |
@@ -519,15 +545,17 @@ discard block |
||
| 519 | 545 | |
| 520 | 546 | // Store this useful data! |
| 521 | 547 | $boards[$row['id_board']] = $row['id_board']; |
| 522 | - if ($row['id_topic']) |
|
| 523 | - $notify['topics'][$row['id_topic']][] = $row['id_member']; |
|
| 524 | - else |
|
| 525 | - $notify['boards'][$row['id_board']][] = $row['id_member']; |
|
| 548 | + if ($row['id_topic']) { |
|
| 549 | + $notify['topics'][$row['id_topic']][] = $row['id_member']; |
|
| 550 | + } else { |
|
| 551 | + $notify['boards'][$row['id_board']][] = $row['id_member']; |
|
| 552 | + } |
|
| 526 | 553 | } |
| 527 | 554 | $smcFunc['db_free_result']($request); |
| 528 | 555 | |
| 529 | - if (empty($boards)) |
|
| 530 | - return true; |
|
| 556 | + if (empty($boards)) { |
|
| 557 | + return true; |
|
| 558 | + } |
|
| 531 | 559 | |
| 532 | 560 | // Just get the board names. |
| 533 | 561 | $request = $smcFunc['db_query']('', ' |
@@ -539,12 +567,14 @@ discard block |
||
| 539 | 567 | ) |
| 540 | 568 | ); |
| 541 | 569 | $boards = array(); |
| 542 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 543 | - $boards[$row['id_board']] = $row['name']; |
|
| 570 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 571 | + $boards[$row['id_board']] = $row['name']; |
|
| 572 | + } |
|
| 544 | 573 | $smcFunc['db_free_result']($request); |
| 545 | 574 | |
| 546 | - if (empty($boards)) |
|
| 547 | - return true; |
|
| 575 | + if (empty($boards)) { |
|
| 576 | + return true; |
|
| 577 | + } |
|
| 548 | 578 | |
| 549 | 579 | // Get the actual topics... |
| 550 | 580 | $request = $smcFunc['db_query']('', ' |
@@ -564,52 +594,57 @@ discard block |
||
| 564 | 594 | $types = array(); |
| 565 | 595 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 566 | 596 | { |
| 567 | - if (!isset($types[$row['note_type']][$row['id_board']])) |
|
| 568 | - $types[$row['note_type']][$row['id_board']] = array( |
|
| 597 | + if (!isset($types[$row['note_type']][$row['id_board']])) { |
|
| 598 | + $types[$row['note_type']][$row['id_board']] = array( |
|
| 569 | 599 | 'lines' => array(), |
| 570 | 600 | 'name' => $row['board_name'], |
| 571 | 601 | 'id' => $row['id_board'], |
| 572 | 602 | ); |
| 603 | + } |
|
| 573 | 604 | |
| 574 | 605 | if ($row['note_type'] == 'reply') |
| 575 | 606 | { |
| 576 | - if (isset($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']])) |
|
| 577 | - $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['count']++; |
|
| 578 | - else |
|
| 579 | - $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']] = array( |
|
| 607 | + if (isset($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']])) { |
|
| 608 | + $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['count']++; |
|
| 609 | + } else { |
|
| 610 | + $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']] = array( |
|
| 580 | 611 | 'id' => $row['id_topic'], |
| 581 | 612 | 'subject' => un_htmlspecialchars($row['subject']), |
| 582 | 613 | 'count' => 1, |
| 583 | 614 | ); |
| 584 | - } |
|
| 585 | - elseif ($row['note_type'] == 'topic') |
|
| 615 | + } |
|
| 616 | + } elseif ($row['note_type'] == 'topic') |
|
| 586 | 617 | { |
| 587 | - if (!isset($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']])) |
|
| 588 | - $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']] = array( |
|
| 618 | + if (!isset($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']])) { |
|
| 619 | + $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']] = array( |
|
| 589 | 620 | 'id' => $row['id_topic'], |
| 590 | 621 | 'subject' => un_htmlspecialchars($row['subject']), |
| 591 | 622 | ); |
| 592 | - } |
|
| 593 | - else |
|
| 623 | + } |
|
| 624 | + } else |
|
| 594 | 625 | { |
| 595 | - if (!isset($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']])) |
|
| 596 | - $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']] = array( |
|
| 626 | + if (!isset($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']])) { |
|
| 627 | + $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']] = array( |
|
| 597 | 628 | 'id' => $row['id_topic'], |
| 598 | 629 | 'subject' => un_htmlspecialchars($row['subject']), |
| 599 | 630 | 'starter' => $row['id_member_started'], |
| 600 | 631 | ); |
| 632 | + } |
|
| 601 | 633 | } |
| 602 | 634 | |
| 603 | 635 | $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'] = array(); |
| 604 | - if (!empty($notify['topics'][$row['id_topic']])) |
|
| 605 | - $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'] = array_merge($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'], $notify['topics'][$row['id_topic']]); |
|
| 606 | - if (!empty($notify['boards'][$row['id_board']])) |
|
| 607 | - $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'] = array_merge($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'], $notify['boards'][$row['id_board']]); |
|
| 636 | + if (!empty($notify['topics'][$row['id_topic']])) { |
|
| 637 | + $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'] = array_merge($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'], $notify['topics'][$row['id_topic']]); |
|
| 638 | + } |
|
| 639 | + if (!empty($notify['boards'][$row['id_board']])) { |
|
| 640 | + $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'] = array_merge($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'], $notify['boards'][$row['id_board']]); |
|
| 641 | + } |
|
| 608 | 642 | } |
| 609 | 643 | $smcFunc['db_free_result']($request); |
| 610 | 644 | |
| 611 | - if (empty($types)) |
|
| 612 | - return true; |
|
| 645 | + if (empty($types)) { |
|
| 646 | + return true; |
|
| 647 | + } |
|
| 613 | 648 | |
| 614 | 649 | // Let's load all the languages into a cache thingy. |
| 615 | 650 | $langtxt = array(); |
@@ -650,8 +685,9 @@ discard block |
||
| 650 | 685 | $notify_types = !empty($prefs[$mid]['msg_notify_type']) ? $prefs[$mid]['msg_notify_type'] : 1; |
| 651 | 686 | |
| 652 | 687 | // Did they not elect to choose this? |
| 653 | - if ($frequency == 4 && !$is_weekly || $frequency == 3 && $is_weekly || $notify_types == 4) |
|
| 654 | - continue; |
|
| 688 | + if ($frequency == 4 && !$is_weekly || $frequency == 3 && $is_weekly || $notify_types == 4) { |
|
| 689 | + continue; |
|
| 690 | + } |
|
| 655 | 691 | |
| 656 | 692 | // Right character set! |
| 657 | 693 | $context['character_set'] = empty($modSettings['global_character_set']) ? $langtxt[$lang]['char_set'] : $modSettings['global_character_set']; |
@@ -667,39 +703,43 @@ discard block |
||
| 667 | 703 | if (isset($types['topic'])) |
| 668 | 704 | { |
| 669 | 705 | $titled = false; |
| 670 | - foreach ($types['topic'] as $id => $board) |
|
| 671 | - foreach ($board['lines'] as $topic) |
|
| 706 | + foreach ($types['topic'] as $id => $board) { |
|
| 707 | + foreach ($board['lines'] as $topic) |
|
| 672 | 708 | if (in_array($mid, $topic['members'])) |
| 673 | 709 | { |
| 674 | 710 | if (!$titled) |
| 675 | 711 | { |
| 676 | 712 | $email['body'] .= "\n" . $langtxt[$lang]['new_topics'] . ':' . "\n" . '-----------------------------------------------'; |
| 713 | + } |
|
| 677 | 714 | $titled = true; |
| 678 | 715 | } |
| 679 | 716 | $email['body'] .= "\n" . sprintf($langtxt[$lang]['topic_lines'], $topic['subject'], $board['name']); |
| 680 | 717 | } |
| 681 | - if ($titled) |
|
| 682 | - $email['body'] .= "\n"; |
|
| 718 | + if ($titled) { |
|
| 719 | + $email['body'] .= "\n"; |
|
| 720 | + } |
|
| 683 | 721 | } |
| 684 | 722 | |
| 685 | 723 | // What about replies? |
| 686 | 724 | if (isset($types['reply'])) |
| 687 | 725 | { |
| 688 | 726 | $titled = false; |
| 689 | - foreach ($types['reply'] as $id => $board) |
|
| 690 | - foreach ($board['lines'] as $topic) |
|
| 727 | + foreach ($types['reply'] as $id => $board) { |
|
| 728 | + foreach ($board['lines'] as $topic) |
|
| 691 | 729 | if (in_array($mid, $topic['members'])) |
| 692 | 730 | { |
| 693 | 731 | if (!$titled) |
| 694 | 732 | { |
| 695 | 733 | $email['body'] .= "\n" . $langtxt[$lang]['new_replies'] . ':' . "\n" . '-----------------------------------------------'; |
| 734 | + } |
|
| 696 | 735 | $titled = true; |
| 697 | 736 | } |
| 698 | 737 | $email['body'] .= "\n" . ($topic['count'] == 1 ? sprintf($langtxt[$lang]['replies_one'], $topic['subject']) : sprintf($langtxt[$lang]['replies_many'], $topic['count'], $topic['subject'])); |
| 699 | 738 | } |
| 700 | 739 | |
| 701 | - if ($titled) |
|
| 702 | - $email['body'] .= "\n"; |
|
| 740 | + if ($titled) { |
|
| 741 | + $email['body'] .= "\n"; |
|
| 742 | + } |
|
| 703 | 743 | } |
| 704 | 744 | |
| 705 | 745 | // Finally, moderation actions! |
@@ -708,24 +748,27 @@ discard block |
||
| 708 | 748 | $titled = false; |
| 709 | 749 | foreach ($types as $note_type => $type) |
| 710 | 750 | { |
| 711 | - if ($note_type == 'topic' || $note_type == 'reply') |
|
| 712 | - continue; |
|
| 751 | + if ($note_type == 'topic' || $note_type == 'reply') { |
|
| 752 | + continue; |
|
| 753 | + } |
|
| 713 | 754 | |
| 714 | - foreach ($type as $id => $board) |
|
| 715 | - foreach ($board['lines'] as $topic) |
|
| 755 | + foreach ($type as $id => $board) { |
|
| 756 | + foreach ($board['lines'] as $topic) |
|
| 716 | 757 | if (in_array($mid, $topic['members'])) |
| 717 | 758 | { |
| 718 | 759 | if (!$titled) |
| 719 | 760 | { |
| 720 | 761 | $email['body'] .= "\n" . $langtxt[$lang]['mod_actions'] . ':' . "\n" . '-----------------------------------------------'; |
| 762 | + } |
|
| 721 | 763 | $titled = true; |
| 722 | 764 | } |
| 723 | 765 | $email['body'] .= "\n" . sprintf($langtxt[$lang][$note_type], $topic['subject']); |
| 724 | 766 | } |
| 725 | 767 | } |
| 726 | 768 | } |
| 727 | - if ($titled) |
|
| 728 | - $email['body'] .= "\n"; |
|
| 769 | + if ($titled) { |
|
| 770 | + $email['body'] .= "\n"; |
|
| 771 | + } |
|
| 729 | 772 | |
| 730 | 773 | // Then just say our goodbyes! |
| 731 | 774 | $email['body'] .= "\n\n" . $txt['regards_team']; |
@@ -753,8 +796,7 @@ discard block |
||
| 753 | 796 | 'not_daily' => 0, |
| 754 | 797 | ) |
| 755 | 798 | ); |
| 756 | - } |
|
| 757 | - else |
|
| 799 | + } else |
|
| 758 | 800 | { |
| 759 | 801 | // Clear any only weekly ones, and stop us from sending daily again. |
| 760 | 802 | $smcFunc['db_query']('', ' |
@@ -816,16 +858,19 @@ discard block |
||
| 816 | 858 | global $modSettings, $smcFunc, $sourcedir; |
| 817 | 859 | |
| 818 | 860 | // Are we intending another script to be sending out the queue? |
| 819 | - if (!empty($modSettings['mail_queue_use_cron']) && empty($force_send)) |
|
| 820 | - return false; |
|
| 861 | + if (!empty($modSettings['mail_queue_use_cron']) && empty($force_send)) { |
|
| 862 | + return false; |
|
| 863 | + } |
|
| 821 | 864 | |
| 822 | 865 | // By default send 5 at once. |
| 823 | - if (!$number) |
|
| 824 | - $number = empty($modSettings['mail_quantity']) ? 5 : $modSettings['mail_quantity']; |
|
| 866 | + if (!$number) { |
|
| 867 | + $number = empty($modSettings['mail_quantity']) ? 5 : $modSettings['mail_quantity']; |
|
| 868 | + } |
|
| 825 | 869 | |
| 826 | 870 | // If we came with a timestamp, and that doesn't match the next event, then someone else has beaten us. |
| 827 | - if (isset($_GET['ts']) && $_GET['ts'] != $modSettings['mail_next_send'] && empty($force_send)) |
|
| 828 | - return false; |
|
| 871 | + if (isset($_GET['ts']) && $_GET['ts'] != $modSettings['mail_next_send'] && empty($force_send)) { |
|
| 872 | + return false; |
|
| 873 | + } |
|
| 829 | 874 | |
| 830 | 875 | // By default move the next sending on by 10 seconds, and require an affected row. |
| 831 | 876 | if (!$override_limit) |
@@ -842,8 +887,9 @@ discard block |
||
| 842 | 887 | 'last_send' => $modSettings['mail_next_send'], |
| 843 | 888 | ) |
| 844 | 889 | ); |
| 845 | - if ($smcFunc['db_affected_rows']() == 0) |
|
| 846 | - return false; |
|
| 890 | + if ($smcFunc['db_affected_rows']() == 0) { |
|
| 891 | + return false; |
|
| 892 | + } |
|
| 847 | 893 | $modSettings['mail_next_send'] = time() + $delay; |
| 848 | 894 | } |
| 849 | 895 | |
@@ -864,8 +910,9 @@ discard block |
||
| 864 | 910 | $mn += $number; |
| 865 | 911 | } |
| 866 | 912 | // No more I'm afraid, return! |
| 867 | - else |
|
| 868 | - return false; |
|
| 913 | + else { |
|
| 914 | + return false; |
|
| 915 | + } |
|
| 869 | 916 | |
| 870 | 917 | // Reflect that we're about to send some, do it now to be safe. |
| 871 | 918 | updateSettings(array('mail_recent' => $mt . '|' . $mn)); |
@@ -900,14 +947,15 @@ discard block |
||
| 900 | 947 | $smcFunc['db_free_result']($request); |
| 901 | 948 | |
| 902 | 949 | // Delete, delete, delete!!! |
| 903 | - if (!empty($ids)) |
|
| 904 | - $smcFunc['db_query']('', ' |
|
| 950 | + if (!empty($ids)) { |
|
| 951 | + $smcFunc['db_query']('', ' |
|
| 905 | 952 | DELETE FROM {db_prefix}mail_queue |
| 906 | 953 | WHERE id_mail IN ({array_int:mail_list})', |
| 907 | 954 | array( |
| 908 | 955 | 'mail_list' => $ids, |
| 909 | 956 | ) |
| 910 | 957 | ); |
| 958 | + } |
|
| 911 | 959 | |
| 912 | 960 | // Don't believe we have any left? |
| 913 | 961 | if (count($ids) < $number) |
@@ -925,11 +973,13 @@ discard block |
||
| 925 | 973 | ); |
| 926 | 974 | } |
| 927 | 975 | |
| 928 | - if (empty($ids)) |
|
| 929 | - return false; |
|
| 976 | + if (empty($ids)) { |
|
| 977 | + return false; |
|
| 978 | + } |
|
| 930 | 979 | |
| 931 | - if (!empty($modSettings['mail_type']) && $modSettings['smtp_host'] != '') |
|
| 932 | - require_once($sourcedir . '/Subs-Post.php'); |
|
| 980 | + if (!empty($modSettings['mail_type']) && $modSettings['smtp_host'] != '') { |
|
| 981 | + require_once($sourcedir . '/Subs-Post.php'); |
|
| 982 | + } |
|
| 933 | 983 | |
| 934 | 984 | // Send each email, yea! |
| 935 | 985 | $failed_emails = array(); |
@@ -949,15 +999,17 @@ discard block |
||
| 949 | 999 | |
| 950 | 1000 | // Try to stop a timeout, this would be bad... |
| 951 | 1001 | @set_time_limit(300); |
| 952 | - if (function_exists('apache_reset_timeout')) |
|
| 953 | - @apache_reset_timeout(); |
|
| 1002 | + if (function_exists('apache_reset_timeout')) { |
|
| 1003 | + @apache_reset_timeout(); |
|
| 1004 | + } |
|
| 1005 | + } else { |
|
| 1006 | + $result = smtp_mail(array($email['to']), $email['subject'], $email['body'], $email['headers']); |
|
| 954 | 1007 | } |
| 955 | - else |
|
| 956 | - $result = smtp_mail(array($email['to']), $email['subject'], $email['body'], $email['headers']); |
|
| 957 | 1008 | |
| 958 | 1009 | // Hopefully it sent? |
| 959 | - if (!$result) |
|
| 960 | - $failed_emails[] = array($email['to'], $email['body'], $email['subject'], $email['headers'], $email['send_html'], $email['time_sent'], $email['private']); |
|
| 1010 | + if (!$result) { |
|
| 1011 | + $failed_emails[] = array($email['to'], $email['body'], $email['subject'], $email['headers'], $email['send_html'], $email['time_sent'], $email['private']); |
|
| 1012 | + } |
|
| 961 | 1013 | } |
| 962 | 1014 | |
| 963 | 1015 | // Any emails that didn't send? |
@@ -972,8 +1024,8 @@ discard block |
||
| 972 | 1024 | ); |
| 973 | 1025 | |
| 974 | 1026 | // If we have failed to many times, tell mail to wait a bit and try again. |
| 975 | - if ($modSettings['mail_failed_attempts'] > 5) |
|
| 976 | - $smcFunc['db_query']('', ' |
|
| 1027 | + if ($modSettings['mail_failed_attempts'] > 5) { |
|
| 1028 | + $smcFunc['db_query']('', ' |
|
| 977 | 1029 | UPDATE {db_prefix}settings |
| 978 | 1030 | SET value = {string:next_mail_send} |
| 979 | 1031 | WHERE variable = {literal:mail_next_send} |
@@ -982,6 +1034,7 @@ discard block |
||
| 982 | 1034 | 'next_mail_send' => time() + 60, |
| 983 | 1035 | 'last_send' => $modSettings['mail_next_send'], |
| 984 | 1036 | )); |
| 1037 | + } |
|
| 985 | 1038 | |
| 986 | 1039 | // Add our email back to the queue, manually. |
| 987 | 1040 | $smcFunc['db_insert']('insert', |
@@ -994,8 +1047,8 @@ discard block |
||
| 994 | 1047 | return false; |
| 995 | 1048 | } |
| 996 | 1049 | // We where unable to send the email, clear our failed attempts. |
| 997 | - elseif (!empty($modSettings['mail_failed_attempts'])) |
|
| 998 | - $smcFunc['db_query']('', ' |
|
| 1050 | + elseif (!empty($modSettings['mail_failed_attempts'])) { |
|
| 1051 | + $smcFunc['db_query']('', ' |
|
| 999 | 1052 | UPDATE {db_prefix}settings |
| 1000 | 1053 | SET value = {string:zero} |
| 1001 | 1054 | WHERE variable = {string:mail_failed_attempts}', |
@@ -1003,6 +1056,7 @@ discard block |
||
| 1003 | 1056 | 'zero' => '0', |
| 1004 | 1057 | 'mail_failed_attempts' => 'mail_failed_attempts', |
| 1005 | 1058 | )); |
| 1059 | + } |
|
| 1006 | 1060 | |
| 1007 | 1061 | // Had something to send... |
| 1008 | 1062 | return true; |
@@ -1019,16 +1073,18 @@ discard block |
||
| 1019 | 1073 | global $modSettings, $smcFunc; |
| 1020 | 1074 | |
| 1021 | 1075 | $task_query = ''; |
| 1022 | - if (!is_array($tasks)) |
|
| 1023 | - $tasks = array($tasks); |
|
| 1076 | + if (!is_array($tasks)) { |
|
| 1077 | + $tasks = array($tasks); |
|
| 1078 | + } |
|
| 1024 | 1079 | |
| 1025 | 1080 | // Actually have something passed? |
| 1026 | 1081 | if (!empty($tasks)) |
| 1027 | 1082 | { |
| 1028 | - if (!isset($tasks[0]) || is_numeric($tasks[0])) |
|
| 1029 | - $task_query = ' AND id_task IN ({array_int:tasks})'; |
|
| 1030 | - else |
|
| 1031 | - $task_query = ' AND task IN ({array_string:tasks})'; |
|
| 1083 | + if (!isset($tasks[0]) || is_numeric($tasks[0])) { |
|
| 1084 | + $task_query = ' AND id_task IN ({array_int:tasks})'; |
|
| 1085 | + } else { |
|
| 1086 | + $task_query = ' AND task IN ({array_string:tasks})'; |
|
| 1087 | + } |
|
| 1032 | 1088 | } |
| 1033 | 1089 | $nextTaskTime = empty($tasks) ? time() + 86400 : $modSettings['next_task_time']; |
| 1034 | 1090 | |
@@ -1049,20 +1105,22 @@ discard block |
||
| 1049 | 1105 | $next_time = next_time($row['time_regularity'], $row['time_unit'], $row['time_offset']); |
| 1050 | 1106 | |
| 1051 | 1107 | // Only bother moving the task if it's out of place or we're forcing it! |
| 1052 | - if ($forceUpdate || $next_time < $row['next_time'] || $row['next_time'] < time()) |
|
| 1053 | - $tasks[$row['id_task']] = $next_time; |
|
| 1054 | - else |
|
| 1055 | - $next_time = $row['next_time']; |
|
| 1108 | + if ($forceUpdate || $next_time < $row['next_time'] || $row['next_time'] < time()) { |
|
| 1109 | + $tasks[$row['id_task']] = $next_time; |
|
| 1110 | + } else { |
|
| 1111 | + $next_time = $row['next_time']; |
|
| 1112 | + } |
|
| 1056 | 1113 | |
| 1057 | 1114 | // If this is sooner than the current next task, make this the next task. |
| 1058 | - if ($next_time < $nextTaskTime) |
|
| 1059 | - $nextTaskTime = $next_time; |
|
| 1115 | + if ($next_time < $nextTaskTime) { |
|
| 1116 | + $nextTaskTime = $next_time; |
|
| 1117 | + } |
|
| 1060 | 1118 | } |
| 1061 | 1119 | $smcFunc['db_free_result']($request); |
| 1062 | 1120 | |
| 1063 | 1121 | // Now make the changes! |
| 1064 | - foreach ($tasks as $id => $time) |
|
| 1065 | - $smcFunc['db_query']('', ' |
|
| 1122 | + foreach ($tasks as $id => $time) { |
|
| 1123 | + $smcFunc['db_query']('', ' |
|
| 1066 | 1124 | UPDATE {db_prefix}scheduled_tasks |
| 1067 | 1125 | SET next_time = {int:next_time} |
| 1068 | 1126 | WHERE id_task = {int:id_task}', |
@@ -1071,11 +1129,13 @@ discard block |
||
| 1071 | 1129 | 'id_task' => $id, |
| 1072 | 1130 | ) |
| 1073 | 1131 | ); |
| 1132 | + } |
|
| 1074 | 1133 | |
| 1075 | 1134 | // If the next task is now different update. |
| 1076 | - if ($modSettings['next_task_time'] != $nextTaskTime) |
|
| 1077 | - updateSettings(array('next_task_time' => $nextTaskTime)); |
|
| 1078 | -} |
|
| 1135 | + if ($modSettings['next_task_time'] != $nextTaskTime) { |
|
| 1136 | + updateSettings(array('next_task_time' => $nextTaskTime)); |
|
| 1137 | + } |
|
| 1138 | + } |
|
| 1079 | 1139 | |
| 1080 | 1140 | /** |
| 1081 | 1141 | * Simply returns a time stamp of the next instance of these time parameters. |
@@ -1088,8 +1148,9 @@ discard block |
||
| 1088 | 1148 | function next_time($regularity, $unit, $offset) |
| 1089 | 1149 | { |
| 1090 | 1150 | // Just in case! |
| 1091 | - if ($regularity == 0) |
|
| 1092 | - $regularity = 2; |
|
| 1151 | + if ($regularity == 0) { |
|
| 1152 | + $regularity = 2; |
|
| 1153 | + } |
|
| 1093 | 1154 | |
| 1094 | 1155 | $curMin = date('i', time()); |
| 1095 | 1156 | |
@@ -1099,15 +1160,16 @@ discard block |
||
| 1099 | 1160 | $off = date('i', $offset); |
| 1100 | 1161 | |
| 1101 | 1162 | // If it's now just pretend it ain't, |
| 1102 | - if ($off == $curMin) |
|
| 1103 | - $next_time = time() + $regularity; |
|
| 1104 | - else |
|
| 1163 | + if ($off == $curMin) { |
|
| 1164 | + $next_time = time() + $regularity; |
|
| 1165 | + } else |
|
| 1105 | 1166 | { |
| 1106 | 1167 | // Make sure that the offset is always in the past. |
| 1107 | 1168 | $off = $off > $curMin ? $off - 60 : $off; |
| 1108 | 1169 | |
| 1109 | - while ($off <= $curMin) |
|
| 1110 | - $off += $regularity; |
|
| 1170 | + while ($off <= $curMin) { |
|
| 1171 | + $off += $regularity; |
|
| 1172 | + } |
|
| 1111 | 1173 | |
| 1112 | 1174 | // Now we know when the time should be! |
| 1113 | 1175 | $next_time = time() + 60 * ($off - $curMin); |
@@ -1127,11 +1189,13 @@ discard block |
||
| 1127 | 1189 | // Default we'll jump in hours. |
| 1128 | 1190 | $applyOffset = 3600; |
| 1129 | 1191 | // 24 hours = 1 day. |
| 1130 | - if ($unit == 'd') |
|
| 1131 | - $applyOffset = 86400; |
|
| 1192 | + if ($unit == 'd') { |
|
| 1193 | + $applyOffset = 86400; |
|
| 1194 | + } |
|
| 1132 | 1195 | // Otherwise a week. |
| 1133 | - if ($unit == 'w') |
|
| 1134 | - $applyOffset = 604800; |
|
| 1196 | + if ($unit == 'w') { |
|
| 1197 | + $applyOffset = 604800; |
|
| 1198 | + } |
|
| 1135 | 1199 | |
| 1136 | 1200 | $applyOffset *= $regularity; |
| 1137 | 1201 | |
@@ -1168,8 +1232,9 @@ discard block |
||
| 1168 | 1232 | $settings[$row['variable']] = $row['value']; |
| 1169 | 1233 | |
| 1170 | 1234 | // Is this the default theme? |
| 1171 | - if (in_array($row['variable'], array('theme_dir', 'theme_url', 'images_url')) && $row['id_theme'] == '1') |
|
| 1172 | - $settings['default_' . $row['variable']] = $row['value']; |
|
| 1235 | + if (in_array($row['variable'], array('theme_dir', 'theme_url', 'images_url')) && $row['id_theme'] == '1') { |
|
| 1236 | + $settings['default_' . $row['variable']] = $row['value']; |
|
| 1237 | + } |
|
| 1173 | 1238 | } |
| 1174 | 1239 | $smcFunc['db_free_result']($result); |
| 1175 | 1240 | |
@@ -1179,12 +1244,14 @@ discard block |
||
| 1179 | 1244 | $settings['template_dirs'] = array($settings['theme_dir']); |
| 1180 | 1245 | |
| 1181 | 1246 | // Based on theme (if there is one). |
| 1182 | - if (!empty($settings['base_theme_dir'])) |
|
| 1183 | - $settings['template_dirs'][] = $settings['base_theme_dir']; |
|
| 1247 | + if (!empty($settings['base_theme_dir'])) { |
|
| 1248 | + $settings['template_dirs'][] = $settings['base_theme_dir']; |
|
| 1249 | + } |
|
| 1184 | 1250 | |
| 1185 | 1251 | // Lastly the default theme. |
| 1186 | - if ($settings['theme_dir'] != $settings['default_theme_dir']) |
|
| 1187 | - $settings['template_dirs'][] = $settings['default_theme_dir']; |
|
| 1252 | + if ($settings['theme_dir'] != $settings['default_theme_dir']) { |
|
| 1253 | + $settings['template_dirs'][] = $settings['default_theme_dir']; |
|
| 1254 | + } |
|
| 1188 | 1255 | } |
| 1189 | 1256 | |
| 1190 | 1257 | // Assume we want this. |
@@ -1330,8 +1397,9 @@ discard block |
||
| 1330 | 1397 | // Ok should we prune the logs? |
| 1331 | 1398 | if (!empty($modSettings['pruningOptions'])) |
| 1332 | 1399 | { |
| 1333 | - if (!empty($modSettings['pruningOptions']) && strpos($modSettings['pruningOptions'], ',') !== false) |
|
| 1334 | - list ($modSettings['pruneErrorLog'], $modSettings['pruneModLog'], $modSettings['pruneBanLog'], $modSettings['pruneReportLog'], $modSettings['pruneScheduledTaskLog'], $modSettings['pruneSpiderHitLog']) = explode(',', $modSettings['pruningOptions']); |
|
| 1400 | + if (!empty($modSettings['pruningOptions']) && strpos($modSettings['pruningOptions'], ',') !== false) { |
|
| 1401 | + list ($modSettings['pruneErrorLog'], $modSettings['pruneModLog'], $modSettings['pruneBanLog'], $modSettings['pruneReportLog'], $modSettings['pruneScheduledTaskLog'], $modSettings['pruneSpiderHitLog']) = explode(',', $modSettings['pruningOptions']); |
|
| 1402 | + } |
|
| 1335 | 1403 | |
| 1336 | 1404 | if (!empty($modSettings['pruneErrorLog'])) |
| 1337 | 1405 | { |
@@ -1397,8 +1465,9 @@ discard block |
||
| 1397 | 1465 | ) |
| 1398 | 1466 | ); |
| 1399 | 1467 | |
| 1400 | - while ($row = $smcFunc['db_fetch_row']($result)) |
|
| 1401 | - $reports[] = $row[0]; |
|
| 1468 | + while ($row = $smcFunc['db_fetch_row']($result)) { |
|
| 1469 | + $reports[] = $row[0]; |
|
| 1470 | + } |
|
| 1402 | 1471 | |
| 1403 | 1472 | $smcFunc['db_free_result']($result); |
| 1404 | 1473 | |
@@ -1560,8 +1629,9 @@ discard block |
||
| 1560 | 1629 | $emaildata = loadEmailTemplate('paid_subscription_reminder', $replacements, empty($row['lngfile']) || empty($modSettings['userLanguage']) ? $language : $row['lngfile']); |
| 1561 | 1630 | |
| 1562 | 1631 | // Send the actual email. |
| 1563 | - if ($notifyPrefs[$row['id_member']] & 0x02) |
|
| 1564 | - sendmail($row['email_address'], $emaildata['subject'], $emaildata['body'], null, 'paid_sub_remind', $emaildata['is_html'], 2); |
|
| 1632 | + if ($notifyPrefs[$row['id_member']] & 0x02) { |
|
| 1633 | + sendmail($row['email_address'], $emaildata['subject'], $emaildata['body'], null, 'paid_sub_remind', $emaildata['is_html'], 2); |
|
| 1634 | + } |
|
| 1565 | 1635 | |
| 1566 | 1636 | if ($notifyPrefs[$row['id_member']] & 0x01) |
| 1567 | 1637 | { |
@@ -1584,18 +1654,19 @@ discard block |
||
| 1584 | 1654 | } |
| 1585 | 1655 | |
| 1586 | 1656 | // Insert the alerts if any |
| 1587 | - if (!empty($alert_rows)) |
|
| 1588 | - $smcFunc['db_insert']('', |
|
| 1657 | + if (!empty($alert_rows)) { |
|
| 1658 | + $smcFunc['db_insert']('', |
|
| 1589 | 1659 | '{db_prefix}user_alerts', |
| 1590 | 1660 | array('alert_time' => 'int', 'id_member' => 'int', 'id_member_started' => 'int', 'member_name' => 'string', |
| 1591 | 1661 | 'content_type' => 'string', 'content_id' => 'int', 'content_action' => 'string', 'is_read' => 'int', 'extra' => 'string'), |
| 1592 | 1662 | $alert_rows, |
| 1593 | 1663 | array() |
| 1594 | 1664 | ); |
| 1665 | + } |
|
| 1595 | 1666 | |
| 1596 | 1667 | // Mark the reminder as sent. |
| 1597 | - if (!empty($subs_reminded)) |
|
| 1598 | - $smcFunc['db_query']('', ' |
|
| 1668 | + if (!empty($subs_reminded)) { |
|
| 1669 | + $smcFunc['db_query']('', ' |
|
| 1599 | 1670 | UPDATE {db_prefix}log_subscribed |
| 1600 | 1671 | SET reminder_sent = {int:reminder_sent} |
| 1601 | 1672 | WHERE id_sublog IN ({array_int:subscription_list})', |
@@ -1604,6 +1675,7 @@ discard block |
||
| 1604 | 1675 | 'reminder_sent' => 1, |
| 1605 | 1676 | ) |
| 1606 | 1677 | ); |
| 1678 | + } |
|
| 1607 | 1679 | |
| 1608 | 1680 | return true; |
| 1609 | 1681 | } |
@@ -1619,13 +1691,13 @@ discard block |
||
| 1619 | 1691 | // We need to know where this thing is going. |
| 1620 | 1692 | if (!empty($modSettings['currentAttachmentUploadDir'])) |
| 1621 | 1693 | { |
| 1622 | - if (!is_array($modSettings['attachmentUploadDir'])) |
|
| 1623 | - $modSettings['attachmentUploadDir'] = smf_json_decode($modSettings['attachmentUploadDir'], true); |
|
| 1694 | + if (!is_array($modSettings['attachmentUploadDir'])) { |
|
| 1695 | + $modSettings['attachmentUploadDir'] = smf_json_decode($modSettings['attachmentUploadDir'], true); |
|
| 1696 | + } |
|
| 1624 | 1697 | |
| 1625 | 1698 | // Just use the current path for temp files. |
| 1626 | 1699 | $attach_dirs = $modSettings['attachmentUploadDir']; |
| 1627 | - } |
|
| 1628 | - else |
|
| 1700 | + } else |
|
| 1629 | 1701 | { |
| 1630 | 1702 | $attach_dirs = array($modSettings['attachmentUploadDir']); |
| 1631 | 1703 | } |
@@ -1644,14 +1716,16 @@ discard block |
||
| 1644 | 1716 | |
| 1645 | 1717 | while ($file = readdir($dir)) |
| 1646 | 1718 | { |
| 1647 | - if ($file == '.' || $file == '..') |
|
| 1648 | - continue; |
|
| 1719 | + if ($file == '.' || $file == '..') { |
|
| 1720 | + continue; |
|
| 1721 | + } |
|
| 1649 | 1722 | |
| 1650 | 1723 | if (strpos($file, 'post_tmp_') !== false) |
| 1651 | 1724 | { |
| 1652 | 1725 | // Temp file is more than 5 hours old! |
| 1653 | - if (filemtime($attach_dir . '/' . $file) < time() - 18000) |
|
| 1654 | - @unlink($attach_dir . '/' . $file); |
|
| 1726 | + if (filemtime($attach_dir . '/' . $file) < time() - 18000) { |
|
| 1727 | + @unlink($attach_dir . '/' . $file); |
|
| 1728 | + } |
|
| 1655 | 1729 | } |
| 1656 | 1730 | } |
| 1657 | 1731 | closedir($dir); |
@@ -1684,8 +1758,9 @@ discard block |
||
| 1684 | 1758 | ) |
| 1685 | 1759 | ); |
| 1686 | 1760 | |
| 1687 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
| 1688 | - $topics[] = $row[0]; |
|
| 1761 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
| 1762 | + $topics[] = $row[0]; |
|
| 1763 | + } |
|
| 1689 | 1764 | $smcFunc['db_free_result']($request); |
| 1690 | 1765 | |
| 1691 | 1766 | // Zap, your gone |
@@ -1705,8 +1780,9 @@ discard block |
||
| 1705 | 1780 | { |
| 1706 | 1781 | global $smcFunc, $sourcedir, $modSettings; |
| 1707 | 1782 | |
| 1708 | - if (empty($modSettings['drafts_keep_days'])) |
|
| 1709 | - return true; |
|
| 1783 | + if (empty($modSettings['drafts_keep_days'])) { |
|
| 1784 | + return true; |
|
| 1785 | + } |
|
| 1710 | 1786 | |
| 1711 | 1787 | // init |
| 1712 | 1788 | $drafts = array(); |
@@ -1724,8 +1800,9 @@ discard block |
||
| 1724 | 1800 | ) |
| 1725 | 1801 | ); |
| 1726 | 1802 | |
| 1727 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
| 1728 | - $drafts[] = (int) $row[0]; |
|
| 1803 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
| 1804 | + $drafts[] = (int) $row[0]; |
|
| 1805 | + } |
|
| 1729 | 1806 | $smcFunc['db_free_result']($request); |
| 1730 | 1807 | |
| 1731 | 1808 | // If we have old one, remove them |
@@ -15,8 +15,9 @@ discard block |
||
| 15 | 15 | * @version 2.1 Beta 4 |
| 16 | 16 | */ |
| 17 | 17 | |
| 18 | -if (!defined('SMF')) |
|
| 18 | +if (!defined('SMF')) { |
|
| 19 | 19 | die('No direct access...'); |
| 20 | +} |
|
| 20 | 21 | |
| 21 | 22 | /** |
| 22 | 23 | * Begin the registration process. |
@@ -29,19 +30,23 @@ discard block |
||
| 29 | 30 | global $language, $scripturl, $smcFunc, $sourcedir, $cur_profile; |
| 30 | 31 | |
| 31 | 32 | // Is this an incoming AJAX check? |
| 32 | - if (isset($_GET['sa']) && $_GET['sa'] == 'usernamecheck') |
|
| 33 | - return RegisterCheckUsername(); |
|
| 33 | + if (isset($_GET['sa']) && $_GET['sa'] == 'usernamecheck') { |
|
| 34 | + return RegisterCheckUsername(); |
|
| 35 | + } |
|
| 34 | 36 | |
| 35 | 37 | // Check if the administrator has it disabled. |
| 36 | - if (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == '3') |
|
| 37 | - fatal_lang_error('registration_disabled', false); |
|
| 38 | + if (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == '3') { |
|
| 39 | + fatal_lang_error('registration_disabled', false); |
|
| 40 | + } |
|
| 38 | 41 | |
| 39 | 42 | // If this user is an admin - redirect them to the admin registration page. |
| 40 | - if (allowedTo('moderate_forum') && !$user_info['is_guest']) |
|
| 41 | - redirectexit('action=admin;area=regcenter;sa=register'); |
|
| 43 | + if (allowedTo('moderate_forum') && !$user_info['is_guest']) { |
|
| 44 | + redirectexit('action=admin;area=regcenter;sa=register'); |
|
| 45 | + } |
|
| 42 | 46 | // You are not a guest, so you are a member - and members don't get to register twice! |
| 43 | - elseif (empty($user_info['is_guest'])) |
|
| 44 | - redirectexit(); |
|
| 47 | + elseif (empty($user_info['is_guest'])) { |
|
| 48 | + redirectexit(); |
|
| 49 | + } |
|
| 45 | 50 | |
| 46 | 51 | loadLanguage('Login'); |
| 47 | 52 | loadTemplate('Register'); |
@@ -82,16 +87,18 @@ discard block |
||
| 82 | 87 | } |
| 83 | 88 | } |
| 84 | 89 | // Make sure they don't squeeze through without agreeing. |
| 85 | - elseif ($current_step > 1 && $context['require_agreement'] && !$context['registration_passed_agreement']) |
|
| 86 | - $current_step = 1; |
|
| 90 | + elseif ($current_step > 1 && $context['require_agreement'] && !$context['registration_passed_agreement']) { |
|
| 91 | + $current_step = 1; |
|
| 92 | + } |
|
| 87 | 93 | |
| 88 | 94 | // Show the user the right form. |
| 89 | 95 | $context['sub_template'] = $current_step == 1 ? 'registration_agreement' : 'registration_form'; |
| 90 | 96 | $context['page_title'] = $current_step == 1 ? $txt['registration_agreement'] : $txt['registration_form']; |
| 91 | 97 | |
| 92 | 98 | // Kinda need this. |
| 93 | - if ($context['sub_template'] == 'registration_form') |
|
| 94 | - loadJavaScriptFile('register.js', array('defer' => false), 'smf_register'); |
|
| 99 | + if ($context['sub_template'] == 'registration_form') { |
|
| 100 | + loadJavaScriptFile('register.js', array('defer' => false), 'smf_register'); |
|
| 101 | + } |
|
| 95 | 102 | |
| 96 | 103 | // Add the register chain to the link tree. |
| 97 | 104 | $context['linktree'][] = array( |
@@ -100,24 +107,26 @@ discard block |
||
| 100 | 107 | ); |
| 101 | 108 | |
| 102 | 109 | // Prepare the time gate! Do it like so, in case later steps want to reset the limit for any reason, but make sure the time is the current one. |
| 103 | - if (!isset($_SESSION['register'])) |
|
| 104 | - $_SESSION['register'] = array( |
|
| 110 | + if (!isset($_SESSION['register'])) { |
|
| 111 | + $_SESSION['register'] = array( |
|
| 105 | 112 | 'timenow' => time(), |
| 106 | 113 | 'limit' => 10, // minimum number of seconds required on this page for registration |
| 107 | 114 | ); |
| 108 | - else |
|
| 109 | - $_SESSION['register']['timenow'] = time(); |
|
| 115 | + } else { |
|
| 116 | + $_SESSION['register']['timenow'] = time(); |
|
| 117 | + } |
|
| 110 | 118 | |
| 111 | 119 | // If you have to agree to the agreement, it needs to be fetched from the file. |
| 112 | 120 | if ($context['require_agreement']) |
| 113 | 121 | { |
| 114 | 122 | // Have we got a localized one? |
| 115 | - if (file_exists($boarddir . '/agreement.' . $user_info['language'] . '.txt')) |
|
| 116 | - $context['agreement'] = parse_bbc(file_get_contents($boarddir . '/agreement.' . $user_info['language'] . '.txt'), true, 'agreement_' . $user_info['language']); |
|
| 117 | - elseif (file_exists($boarddir . '/agreement.txt')) |
|
| 118 | - $context['agreement'] = parse_bbc(file_get_contents($boarddir . '/agreement.txt'), true, 'agreement'); |
|
| 119 | - else |
|
| 120 | - $context['agreement'] = ''; |
|
| 123 | + if (file_exists($boarddir . '/agreement.' . $user_info['language'] . '.txt')) { |
|
| 124 | + $context['agreement'] = parse_bbc(file_get_contents($boarddir . '/agreement.' . $user_info['language'] . '.txt'), true, 'agreement_' . $user_info['language']); |
|
| 125 | + } elseif (file_exists($boarddir . '/agreement.txt')) { |
|
| 126 | + $context['agreement'] = parse_bbc(file_get_contents($boarddir . '/agreement.txt'), true, 'agreement'); |
|
| 127 | + } else { |
|
| 128 | + $context['agreement'] = ''; |
|
| 129 | + } |
|
| 121 | 130 | |
| 122 | 131 | // Nothing to show, lets disable registration and inform the admin of this error |
| 123 | 132 | if (empty($context['agreement'])) |
@@ -133,8 +142,9 @@ discard block |
||
| 133 | 142 | $selectedLanguage = empty($_SESSION['language']) ? $language : $_SESSION['language']; |
| 134 | 143 | |
| 135 | 144 | // Do we have any languages? |
| 136 | - if (empty($context['languages'])) |
|
| 137 | - getLanguages(); |
|
| 145 | + if (empty($context['languages'])) { |
|
| 146 | + getLanguages(); |
|
| 147 | + } |
|
| 138 | 148 | |
| 139 | 149 | // Try to find our selected language. |
| 140 | 150 | foreach ($context['languages'] as $key => $lang) |
@@ -142,8 +152,9 @@ discard block |
||
| 142 | 152 | $context['languages'][$key]['name'] = strtr($lang['name'], array('-utf8' => '')); |
| 143 | 153 | |
| 144 | 154 | // Found it! |
| 145 | - if ($selectedLanguage == $lang['filename']) |
|
| 146 | - $context['languages'][$key]['selected'] = true; |
|
| 155 | + if ($selectedLanguage == $lang['filename']) { |
|
| 156 | + $context['languages'][$key]['selected'] = true; |
|
| 157 | + } |
|
| 147 | 158 | } |
| 148 | 159 | } |
| 149 | 160 | |
@@ -167,9 +178,10 @@ discard block |
||
| 167 | 178 | $reg_fields = explode(',', $modSettings['registration_fields']); |
| 168 | 179 | |
| 169 | 180 | // We might have had some submissions on this front - go check. |
| 170 | - foreach ($reg_fields as $field) |
|
| 171 | - if (isset($_POST[$field])) |
|
| 181 | + foreach ($reg_fields as $field) { |
|
| 182 | + if (isset($_POST[$field])) |
|
| 172 | 183 | $cur_profile[$field] = $smcFunc['htmlspecialchars']($_POST[$field]); |
| 184 | + } |
|
| 173 | 185 | |
| 174 | 186 | // Load all the fields in question. |
| 175 | 187 | setupProfileContext($reg_fields); |
@@ -186,8 +198,9 @@ discard block |
||
| 186 | 198 | $context['visual_verification_id'] = $verificationOptions['id']; |
| 187 | 199 | } |
| 188 | 200 | // Otherwise we have nothing to show. |
| 189 | - else |
|
| 190 | - $context['visual_verification'] = false; |
|
| 201 | + else { |
|
| 202 | + $context['visual_verification'] = false; |
|
| 203 | + } |
|
| 191 | 204 | |
| 192 | 205 | |
| 193 | 206 | $context += array( |
@@ -198,8 +211,9 @@ discard block |
||
| 198 | 211 | |
| 199 | 212 | // Were there any errors? |
| 200 | 213 | $context['registration_errors'] = array(); |
| 201 | - if (!empty($reg_errors)) |
|
| 202 | - $context['registration_errors'] = $reg_errors; |
|
| 214 | + if (!empty($reg_errors)) { |
|
| 215 | + $context['registration_errors'] = $reg_errors; |
|
| 216 | + } |
|
| 203 | 217 | |
| 204 | 218 | createToken('register'); |
| 205 | 219 | } |
@@ -216,27 +230,32 @@ discard block |
||
| 216 | 230 | validateToken('register'); |
| 217 | 231 | |
| 218 | 232 | // Check to ensure we're forcing SSL for authentication |
| 219 | - if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) |
|
| 220 | - fatal_lang_error('register_ssl_required'); |
|
| 233 | + if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) { |
|
| 234 | + fatal_lang_error('register_ssl_required'); |
|
| 235 | + } |
|
| 221 | 236 | |
| 222 | 237 | // Start collecting together any errors. |
| 223 | 238 | $reg_errors = array(); |
| 224 | 239 | |
| 225 | 240 | // You can't register if it's disabled. |
| 226 | - if (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == 3) |
|
| 227 | - fatal_lang_error('registration_disabled', false); |
|
| 241 | + if (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == 3) { |
|
| 242 | + fatal_lang_error('registration_disabled', false); |
|
| 243 | + } |
|
| 228 | 244 | |
| 229 | 245 | // Well, if you don't agree, you can't register. |
| 230 | - if (!empty($modSettings['requireAgreement']) && empty($_SESSION['registration_agreed'])) |
|
| 231 | - redirectexit(); |
|
| 246 | + if (!empty($modSettings['requireAgreement']) && empty($_SESSION['registration_agreed'])) { |
|
| 247 | + redirectexit(); |
|
| 248 | + } |
|
| 232 | 249 | |
| 233 | 250 | // Make sure they came from *somewhere*, have a session. |
| 234 | - if (!isset($_SESSION['old_url'])) |
|
| 235 | - redirectexit('action=signup'); |
|
| 251 | + if (!isset($_SESSION['old_url'])) { |
|
| 252 | + redirectexit('action=signup'); |
|
| 253 | + } |
|
| 236 | 254 | |
| 237 | 255 | // If we don't require an agreement, we need a extra check for coppa. |
| 238 | - if (empty($modSettings['requireAgreement']) && !empty($modSettings['coppaAge'])) |
|
| 239 | - $_SESSION['skip_coppa'] = !empty($_POST['accept_agreement']); |
|
| 256 | + if (empty($modSettings['requireAgreement']) && !empty($modSettings['coppaAge'])) { |
|
| 257 | + $_SESSION['skip_coppa'] = !empty($_POST['accept_agreement']); |
|
| 258 | + } |
|
| 240 | 259 | // Are they under age, and under age users are banned? |
| 241 | 260 | if (!empty($modSettings['coppaAge']) && empty($modSettings['coppaType']) && empty($_SESSION['skip_coppa'])) |
| 242 | 261 | { |
@@ -245,8 +264,9 @@ discard block |
||
| 245 | 264 | } |
| 246 | 265 | |
| 247 | 266 | // Check the time gate for miscreants. First make sure they came from somewhere that actually set it up. |
| 248 | - if (empty($_SESSION['register']['timenow']) || empty($_SESSION['register']['limit'])) |
|
| 249 | - redirectexit('action=signup'); |
|
| 267 | + if (empty($_SESSION['register']['timenow']) || empty($_SESSION['register']['limit'])) { |
|
| 268 | + redirectexit('action=signup'); |
|
| 269 | + } |
|
| 250 | 270 | // Failing that, check the time on it. |
| 251 | 271 | if (time() - $_SESSION['register']['timenow'] < $_SESSION['register']['limit']) |
| 252 | 272 | { |
@@ -266,15 +286,17 @@ discard block |
||
| 266 | 286 | if (is_array($context['visual_verification'])) |
| 267 | 287 | { |
| 268 | 288 | loadLanguage('Errors'); |
| 269 | - foreach ($context['visual_verification'] as $error) |
|
| 270 | - $reg_errors[] = $txt['error_' . $error]; |
|
| 289 | + foreach ($context['visual_verification'] as $error) { |
|
| 290 | + $reg_errors[] = $txt['error_' . $error]; |
|
| 291 | + } |
|
| 271 | 292 | } |
| 272 | 293 | } |
| 273 | 294 | |
| 274 | 295 | foreach ($_POST as $key => $value) |
| 275 | 296 | { |
| 276 | - if (!is_array($_POST[$key])) |
|
| 277 | - $_POST[$key] = htmltrim__recursive(str_replace(array("\n", "\r"), '', $_POST[$key])); |
|
| 297 | + if (!is_array($_POST[$key])) { |
|
| 298 | + $_POST[$key] = htmltrim__recursive(str_replace(array("\n", "\r"), '', $_POST[$key])); |
|
| 299 | + } |
|
| 278 | 300 | } |
| 279 | 301 | |
| 280 | 302 | // Collect all extra registration fields someone might have filled in. |
@@ -304,12 +326,14 @@ discard block |
||
| 304 | 326 | $reg_fields = explode(',', $modSettings['registration_fields']); |
| 305 | 327 | |
| 306 | 328 | // Website is a little different |
| 307 | - if (in_array('website', $reg_fields)) |
|
| 308 | - $possible_strings += array('website_url', 'website_title'); |
|
| 329 | + if (in_array('website', $reg_fields)) { |
|
| 330 | + $possible_strings += array('website_url', 'website_title'); |
|
| 331 | + } |
|
| 309 | 332 | } |
| 310 | 333 | |
| 311 | - if (isset($_POST['secret_answer']) && $_POST['secret_answer'] != '') |
|
| 312 | - $_POST['secret_answer'] = md5($_POST['secret_answer']); |
|
| 334 | + if (isset($_POST['secret_answer']) && $_POST['secret_answer'] != '') { |
|
| 335 | + $_POST['secret_answer'] = md5($_POST['secret_answer']); |
|
| 336 | + } |
|
| 313 | 337 | |
| 314 | 338 | // Needed for isReservedName() and registerMember(). |
| 315 | 339 | require_once($sourcedir . '/Subs-Members.php'); |
@@ -318,32 +342,37 @@ discard block |
||
| 318 | 342 | if (isset($_POST['real_name']) && (allowedTo('profile_displayed_name') || allowedTo('moderate_forum'))) |
| 319 | 343 | { |
| 320 | 344 | $_POST['real_name'] = trim(preg_replace('~[\t\n\r \x0B\0' . ($context['utf8'] ? '\x{A0}\x{AD}\x{2000}-\x{200F}\x{201F}\x{202F}\x{3000}\x{FEFF}' : '\x00-\x08\x0B\x0C\x0E-\x19\xA0') . ']+~' . ($context['utf8'] ? 'u' : ''), ' ', $_POST['real_name'])); |
| 321 | - if (trim($_POST['real_name']) != '' && !isReservedName($_POST['real_name']) && $smcFunc['strlen']($_POST['real_name']) < 60) |
|
| 322 | - $possible_strings[] = 'real_name'; |
|
| 345 | + if (trim($_POST['real_name']) != '' && !isReservedName($_POST['real_name']) && $smcFunc['strlen']($_POST['real_name']) < 60) { |
|
| 346 | + $possible_strings[] = 'real_name'; |
|
| 347 | + } |
|
| 323 | 348 | } |
| 324 | 349 | |
| 325 | 350 | // Handle a string as a birthdate... |
| 326 | - if (isset($_POST['birthdate']) && $_POST['birthdate'] != '') |
|
| 327 | - $_POST['birthdate'] = strftime('%Y-%m-%d', strtotime($_POST['birthdate'])); |
|
| 351 | + if (isset($_POST['birthdate']) && $_POST['birthdate'] != '') { |
|
| 352 | + $_POST['birthdate'] = strftime('%Y-%m-%d', strtotime($_POST['birthdate'])); |
|
| 353 | + } |
|
| 328 | 354 | // Or birthdate parts... |
| 329 | - elseif (!empty($_POST['bday1']) && !empty($_POST['bday2'])) |
|
| 330 | - $_POST['birthdate'] = sprintf('%04d-%02d-%02d', empty($_POST['bday3']) ? 0 : (int) $_POST['bday3'], (int) $_POST['bday1'], (int) $_POST['bday2']); |
|
| 355 | + elseif (!empty($_POST['bday1']) && !empty($_POST['bday2'])) { |
|
| 356 | + $_POST['birthdate'] = sprintf('%04d-%02d-%02d', empty($_POST['bday3']) ? 0 : (int) $_POST['bday3'], (int) $_POST['bday1'], (int) $_POST['bday2']); |
|
| 357 | + } |
|
| 331 | 358 | |
| 332 | 359 | // Validate the passed language file. |
| 333 | 360 | if (isset($_POST['lngfile']) && !empty($modSettings['userLanguage'])) |
| 334 | 361 | { |
| 335 | 362 | // Do we have any languages? |
| 336 | - if (empty($context['languages'])) |
|
| 337 | - getLanguages(); |
|
| 363 | + if (empty($context['languages'])) { |
|
| 364 | + getLanguages(); |
|
| 365 | + } |
|
| 338 | 366 | |
| 339 | 367 | // Did we find it? |
| 340 | - if (isset($context['languages'][$_POST['lngfile']])) |
|
| 341 | - $_SESSION['language'] = $_POST['lngfile']; |
|
| 342 | - else |
|
| 368 | + if (isset($context['languages'][$_POST['lngfile']])) { |
|
| 369 | + $_SESSION['language'] = $_POST['lngfile']; |
|
| 370 | + } else { |
|
| 371 | + unset($_POST['lngfile']); |
|
| 372 | + } |
|
| 373 | + } else { |
|
| 343 | 374 | unset($_POST['lngfile']); |
| 344 | 375 | } |
| 345 | - else |
|
| 346 | - unset($_POST['lngfile']); |
|
| 347 | 376 | |
| 348 | 377 | // Set the options needed for registration. |
| 349 | 378 | $regOptions = array( |
@@ -363,22 +392,27 @@ discard block |
||
| 363 | 392 | ); |
| 364 | 393 | |
| 365 | 394 | // Include the additional options that might have been filled in. |
| 366 | - foreach ($possible_strings as $var) |
|
| 367 | - if (isset($_POST[$var])) |
|
| 395 | + foreach ($possible_strings as $var) { |
|
| 396 | + if (isset($_POST[$var])) |
|
| 368 | 397 | $regOptions['extra_register_vars'][$var] = $smcFunc['htmlspecialchars']($_POST[$var], ENT_QUOTES); |
| 369 | - foreach ($possible_ints as $var) |
|
| 370 | - if (isset($_POST[$var])) |
|
| 398 | + } |
|
| 399 | + foreach ($possible_ints as $var) { |
|
| 400 | + if (isset($_POST[$var])) |
|
| 371 | 401 | $regOptions['extra_register_vars'][$var] = (int) $_POST[$var]; |
| 372 | - foreach ($possible_floats as $var) |
|
| 373 | - if (isset($_POST[$var])) |
|
| 402 | + } |
|
| 403 | + foreach ($possible_floats as $var) { |
|
| 404 | + if (isset($_POST[$var])) |
|
| 374 | 405 | $regOptions['extra_register_vars'][$var] = (float) $_POST[$var]; |
| 375 | - foreach ($possible_bools as $var) |
|
| 376 | - if (isset($_POST[$var])) |
|
| 406 | + } |
|
| 407 | + foreach ($possible_bools as $var) { |
|
| 408 | + if (isset($_POST[$var])) |
|
| 377 | 409 | $regOptions['extra_register_vars'][$var] = empty($_POST[$var]) ? 0 : 1; |
| 410 | + } |
|
| 378 | 411 | |
| 379 | 412 | // Registration options are always default options... |
| 380 | - if (isset($_POST['default_options'])) |
|
| 381 | - $_POST['options'] = isset($_POST['options']) ? $_POST['options'] + $_POST['default_options'] : $_POST['default_options']; |
|
| 413 | + if (isset($_POST['default_options'])) { |
|
| 414 | + $_POST['options'] = isset($_POST['options']) ? $_POST['options'] + $_POST['default_options'] : $_POST['default_options']; |
|
| 415 | + } |
|
| 382 | 416 | $regOptions['theme_vars'] = isset($_POST['options']) && is_array($_POST['options']) ? $_POST['options'] : array(); |
| 383 | 417 | |
| 384 | 418 | // Make sure they are clean, dammit! |
@@ -398,12 +432,14 @@ discard block |
||
| 398 | 432 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 399 | 433 | { |
| 400 | 434 | // Don't allow overriding of the theme variables. |
| 401 | - if (isset($regOptions['theme_vars'][$row['col_name']])) |
|
| 402 | - unset($regOptions['theme_vars'][$row['col_name']]); |
|
| 435 | + if (isset($regOptions['theme_vars'][$row['col_name']])) { |
|
| 436 | + unset($regOptions['theme_vars'][$row['col_name']]); |
|
| 437 | + } |
|
| 403 | 438 | |
| 404 | 439 | // Not actually showing it then? |
| 405 | - if (!$row['show_reg']) |
|
| 406 | - continue; |
|
| 440 | + if (!$row['show_reg']) { |
|
| 441 | + continue; |
|
| 442 | + } |
|
| 407 | 443 | |
| 408 | 444 | // Prepare the value! |
| 409 | 445 | $value = isset($_POST['customfield'][$row['col_name']]) ? trim($_POST['customfield'][$row['col_name']]) : ''; |
@@ -412,24 +448,27 @@ discard block |
||
| 412 | 448 | if (!in_array($row['field_type'], array('check', 'select', 'radio'))) |
| 413 | 449 | { |
| 414 | 450 | // Is it too long? |
| 415 | - if ($row['field_length'] && $row['field_length'] < $smcFunc['strlen']($value)) |
|
| 416 | - $custom_field_errors[] = array('custom_field_too_long', array($row['field_name'], $row['field_length'])); |
|
| 451 | + if ($row['field_length'] && $row['field_length'] < $smcFunc['strlen']($value)) { |
|
| 452 | + $custom_field_errors[] = array('custom_field_too_long', array($row['field_name'], $row['field_length'])); |
|
| 453 | + } |
|
| 417 | 454 | |
| 418 | 455 | // Any masks to apply? |
| 419 | 456 | if ($row['field_type'] == 'text' && !empty($row['mask']) && $row['mask'] != 'none') |
| 420 | 457 | { |
| 421 | - if ($row['mask'] == 'email' && (!filter_var($value, FILTER_VALIDATE_EMAIL) || strlen($value) > 255)) |
|
| 422 | - $custom_field_errors[] = array('custom_field_invalid_email', array($row['field_name'])); |
|
| 423 | - elseif ($row['mask'] == 'number' && preg_match('~[^\d]~', $value)) |
|
| 424 | - $custom_field_errors[] = array('custom_field_not_number', array($row['field_name'])); |
|
| 425 | - elseif (substr($row['mask'], 0, 5) == 'regex' && trim($value) != '' && preg_match(substr($row['mask'], 5), $value) === 0) |
|
| 426 | - $custom_field_errors[] = array('custom_field_inproper_format', array($row['field_name'])); |
|
| 458 | + if ($row['mask'] == 'email' && (!filter_var($value, FILTER_VALIDATE_EMAIL) || strlen($value) > 255)) { |
|
| 459 | + $custom_field_errors[] = array('custom_field_invalid_email', array($row['field_name'])); |
|
| 460 | + } elseif ($row['mask'] == 'number' && preg_match('~[^\d]~', $value)) { |
|
| 461 | + $custom_field_errors[] = array('custom_field_not_number', array($row['field_name'])); |
|
| 462 | + } elseif (substr($row['mask'], 0, 5) == 'regex' && trim($value) != '' && preg_match(substr($row['mask'], 5), $value) === 0) { |
|
| 463 | + $custom_field_errors[] = array('custom_field_inproper_format', array($row['field_name'])); |
|
| 464 | + } |
|
| 427 | 465 | } |
| 428 | 466 | } |
| 429 | 467 | |
| 430 | 468 | // Is this required but not there? |
| 431 | - if (trim($value) == '' && $row['show_reg'] > 1) |
|
| 432 | - $custom_field_errors[] = array('custom_field_empty', array($row['field_name'])); |
|
| 469 | + if (trim($value) == '' && $row['show_reg'] > 1) { |
|
| 470 | + $custom_field_errors[] = array('custom_field_empty', array($row['field_name'])); |
|
| 471 | + } |
|
| 433 | 472 | } |
| 434 | 473 | $smcFunc['db_free_result']($request); |
| 435 | 474 | |
@@ -437,8 +476,9 @@ discard block |
||
| 437 | 476 | if (!empty($custom_field_errors)) |
| 438 | 477 | { |
| 439 | 478 | loadLanguage('Errors'); |
| 440 | - foreach ($custom_field_errors as $error) |
|
| 441 | - $reg_errors[] = vsprintf($txt['error_' . $error[0]], $error[1]); |
|
| 479 | + foreach ($custom_field_errors as $error) { |
|
| 480 | + $reg_errors[] = vsprintf($txt['error_' . $error[0]], $error[1]); |
|
| 481 | + } |
|
| 442 | 482 | } |
| 443 | 483 | |
| 444 | 484 | // Lets check for other errors before trying to register the member. |
@@ -483,8 +523,9 @@ discard block |
||
| 483 | 523 | } |
| 484 | 524 | |
| 485 | 525 | // If COPPA has been selected then things get complicated, setup the template. |
| 486 | - if (!empty($modSettings['coppaAge']) && empty($_SESSION['skip_coppa'])) |
|
| 487 | - redirectexit('action=coppa;member=' . $memberID); |
|
| 526 | + if (!empty($modSettings['coppaAge']) && empty($_SESSION['skip_coppa'])) { |
|
| 527 | + redirectexit('action=coppa;member=' . $memberID); |
|
| 528 | + } |
|
| 488 | 529 | // Basic template variable setup. |
| 489 | 530 | elseif (!empty($modSettings['registration_method'])) |
| 490 | 531 | { |
@@ -496,8 +537,7 @@ discard block |
||
| 496 | 537 | 'sub_template' => 'after', |
| 497 | 538 | 'description' => $modSettings['registration_method'] == 2 ? $txt['approval_after_registration'] : $txt['activate_after_registration'] |
| 498 | 539 | ); |
| 499 | - } |
|
| 500 | - else |
|
| 540 | + } else |
|
| 501 | 541 | { |
| 502 | 542 | call_integration_hook('integrate_activate', array($regOptions['username'])); |
| 503 | 543 | |
@@ -517,16 +557,18 @@ discard block |
||
| 517 | 557 | global $context, $txt, $modSettings, $scripturl, $sourcedir, $smcFunc, $language, $user_info; |
| 518 | 558 | |
| 519 | 559 | // Logged in users should not bother to activate their accounts |
| 520 | - if (!empty($user_info['id'])) |
|
| 521 | - redirectexit(); |
|
| 560 | + if (!empty($user_info['id'])) { |
|
| 561 | + redirectexit(); |
|
| 562 | + } |
|
| 522 | 563 | |
| 523 | 564 | loadLanguage('Login'); |
| 524 | 565 | loadTemplate('Login'); |
| 525 | 566 | |
| 526 | 567 | if (empty($_REQUEST['u']) && empty($_POST['user'])) |
| 527 | 568 | { |
| 528 | - if (empty($modSettings['registration_method']) || $modSettings['registration_method'] == '3') |
|
| 529 | - fatal_lang_error('no_access', false); |
|
| 569 | + if (empty($modSettings['registration_method']) || $modSettings['registration_method'] == '3') { |
|
| 570 | + fatal_lang_error('no_access', false); |
|
| 571 | + } |
|
| 530 | 572 | |
| 531 | 573 | $context['member_id'] = 0; |
| 532 | 574 | $context['sub_template'] = 'resend'; |
@@ -566,11 +608,13 @@ discard block |
||
| 566 | 608 | // Change their email address? (they probably tried a fake one first :P.) |
| 567 | 609 | if (isset($_POST['new_email'], $_REQUEST['passwd']) && hash_password($row['member_name'], $_REQUEST['passwd']) == $row['passwd'] && ($row['is_activated'] == 0 || $row['is_activated'] == 2)) |
| 568 | 610 | { |
| 569 | - if (empty($modSettings['registration_method']) || $modSettings['registration_method'] == 3) |
|
| 570 | - fatal_lang_error('no_access', false); |
|
| 611 | + if (empty($modSettings['registration_method']) || $modSettings['registration_method'] == 3) { |
|
| 612 | + fatal_lang_error('no_access', false); |
|
| 613 | + } |
|
| 571 | 614 | |
| 572 | - if (!filter_var($_POST['new_email'], FILTER_VALIDATE_EMAIL)) |
|
| 573 | - fatal_error(sprintf($txt['valid_email_needed'], $smcFunc['htmlspecialchars']($_POST['new_email'])), false); |
|
| 615 | + if (!filter_var($_POST['new_email'], FILTER_VALIDATE_EMAIL)) { |
|
| 616 | + fatal_error(sprintf($txt['valid_email_needed'], $smcFunc['htmlspecialchars']($_POST['new_email'])), false); |
|
| 617 | + } |
|
| 574 | 618 | |
| 575 | 619 | // Make sure their email isn't banned. |
| 576 | 620 | isBannedEmail($_POST['new_email'], 'cannot_register', $txt['ban_register_prohibited']); |
@@ -586,8 +630,9 @@ discard block |
||
| 586 | 630 | ) |
| 587 | 631 | ); |
| 588 | 632 | |
| 589 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
| 590 | - fatal_lang_error('email_in_use', false, array($smcFunc['htmlspecialchars']($_POST['new_email']))); |
|
| 633 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
| 634 | + fatal_lang_error('email_in_use', false, array($smcFunc['htmlspecialchars']($_POST['new_email']))); |
|
| 635 | + } |
|
| 591 | 636 | $smcFunc['db_free_result']($request); |
| 592 | 637 | |
| 593 | 638 | updateMemberData($row['id_member'], array('email_address' => $_POST['new_email'])); |
@@ -625,9 +670,9 @@ discard block |
||
| 625 | 670 | // Quit if this code is not right. |
| 626 | 671 | if (empty($_REQUEST['code']) || $row['validation_code'] != $_REQUEST['code']) |
| 627 | 672 | { |
| 628 | - if (!empty($row['is_activated'])) |
|
| 629 | - fatal_lang_error('already_activated', false); |
|
| 630 | - elseif ($row['validation_code'] == '') |
|
| 673 | + if (!empty($row['is_activated'])) { |
|
| 674 | + fatal_lang_error('already_activated', false); |
|
| 675 | + } elseif ($row['validation_code'] == '') |
|
| 631 | 676 | { |
| 632 | 677 | loadLanguage('Profile'); |
| 633 | 678 | fatal_error(sprintf($txt['registration_not_approved'], $scripturl . '?action=activate;user=' . $row['member_name']), false); |
@@ -677,8 +722,9 @@ discard block |
||
| 677 | 722 | loadTemplate('Register'); |
| 678 | 723 | |
| 679 | 724 | // No User ID?? |
| 680 | - if (!isset($_GET['member'])) |
|
| 681 | - fatal_lang_error('no_access', false); |
|
| 725 | + if (!isset($_GET['member'])) { |
|
| 726 | + fatal_lang_error('no_access', false); |
|
| 727 | + } |
|
| 682 | 728 | |
| 683 | 729 | // Get the user details... |
| 684 | 730 | $request = $smcFunc['db_query']('', ' |
@@ -691,8 +737,9 @@ discard block |
||
| 691 | 737 | 'is_coppa' => 5, |
| 692 | 738 | ) |
| 693 | 739 | ); |
| 694 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 695 | - fatal_lang_error('no_access', false); |
|
| 740 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 741 | + fatal_lang_error('no_access', false); |
|
| 742 | + } |
|
| 696 | 743 | list ($username) = $smcFunc['db_fetch_row']($request); |
| 697 | 744 | $smcFunc['db_free_result']($request); |
| 698 | 745 | |
@@ -730,8 +777,7 @@ discard block |
||
| 730 | 777 | echo $data; |
| 731 | 778 | obExit(false); |
| 732 | 779 | } |
| 733 | - } |
|
| 734 | - else |
|
| 780 | + } else |
|
| 735 | 781 | { |
| 736 | 782 | $context += array( |
| 737 | 783 | 'page_title' => $txt['coppa_title'], |
@@ -784,8 +830,9 @@ discard block |
||
| 784 | 830 | { |
| 785 | 831 | require_once($sourcedir . '/Subs-Graphics.php'); |
| 786 | 832 | |
| 787 | - if (in_array('gd', get_loaded_extensions()) && !showCodeImage($code)) |
|
| 788 | - header('HTTP/1.1 400 Bad Request'); |
|
| 833 | + if (in_array('gd', get_loaded_extensions()) && !showCodeImage($code)) { |
|
| 834 | + header('HTTP/1.1 400 Bad Request'); |
|
| 835 | + } |
|
| 789 | 836 | |
| 790 | 837 | // Otherwise just show a pre-defined letter. |
| 791 | 838 | elseif (isset($_REQUEST['letter'])) |
@@ -803,14 +850,13 @@ discard block |
||
| 803 | 850 | header('Content-Type: image/gif'); |
| 804 | 851 | die("\x47\x49\x46\x38\x39\x61\x01\x00\x01\x00\x80\x00\x00\x00\x00\x00\x00\x00\x00\x21\xF9\x04\x01\x00\x00\x00\x00\x2C\x00\x00\x00\x00\x01\x00\x01\x00\x00\x02\x02\x44\x01\x00\x3B"); |
| 805 | 852 | } |
| 806 | - } |
|
| 807 | - |
|
| 808 | - elseif ($_REQUEST['format'] === '.wav') |
|
| 853 | + } elseif ($_REQUEST['format'] === '.wav') |
|
| 809 | 854 | { |
| 810 | 855 | require_once($sourcedir . '/Subs-Sound.php'); |
| 811 | 856 | |
| 812 | - if (!createWaveFile($code)) |
|
| 813 | - header('HTTP/1.1 400 Bad Request'); |
|
| 857 | + if (!createWaveFile($code)) { |
|
| 858 | + header('HTTP/1.1 400 Bad Request'); |
|
| 859 | + } |
|
| 814 | 860 | } |
| 815 | 861 | |
| 816 | 862 | // We all die one day... |
@@ -19,8 +19,9 @@ discard block |
||
| 19 | 19 | * @version 2.1 Beta 4 |
| 20 | 20 | */ |
| 21 | 21 | |
| 22 | -if (!defined('SMF')) |
|
| 22 | +if (!defined('SMF')) { |
|
| 23 | 23 | die('No direct access...'); |
| 24 | +} |
|
| 24 | 25 | |
| 25 | 26 | /** |
| 26 | 27 | * Class gif_lzw_compression |
@@ -52,13 +53,15 @@ discard block |
||
| 52 | 53 | |
| 53 | 54 | $this->LZWCommand($data, true); |
| 54 | 55 | |
| 55 | - while (($iIndex = $this->LZWCommand($data, false)) >= 0) |
|
| 56 | - $ret .= chr($iIndex); |
|
| 56 | + while (($iIndex = $this->LZWCommand($data, false)) >= 0) { |
|
| 57 | + $ret .= chr($iIndex); |
|
| 58 | + } |
|
| 57 | 59 | |
| 58 | 60 | $datLen = $stLen - strlen($data); |
| 59 | 61 | |
| 60 | - if ($iIndex != -2) |
|
| 61 | - return false; |
|
| 62 | + if ($iIndex != -2) { |
|
| 63 | + return false; |
|
| 64 | + } |
|
| 62 | 65 | |
| 63 | 66 | return $ret; |
| 64 | 67 | } |
@@ -140,8 +143,9 @@ discard block |
||
| 140 | 143 | return $this->FirstCode; |
| 141 | 144 | } |
| 142 | 145 | |
| 143 | - if ($Code == $this->EndCode) |
|
| 144 | - return -2; |
|
| 146 | + if ($Code == $this->EndCode) { |
|
| 147 | + return -2; |
|
| 148 | + } |
|
| 145 | 149 | |
| 146 | 150 | $InCode = $Code; |
| 147 | 151 | if ($Code >= $this->MaxCode) |
@@ -156,8 +160,10 @@ discard block |
||
| 156 | 160 | $this->Stack[$this->sp] = $this->Vals[$Code]; |
| 157 | 161 | $this->sp++; |
| 158 | 162 | |
| 159 | - if ($Code == $this->Next[$Code]) // Circular table entry, big GIF Error! |
|
| 163 | + if ($Code == $this->Next[$Code]) { |
|
| 164 | + // Circular table entry, big GIF Error! |
|
| 160 | 165 | return -1; |
| 166 | + } |
|
| 161 | 167 | |
| 162 | 168 | $Code = $this->Next[$Code]; |
| 163 | 169 | } |
@@ -207,8 +213,9 @@ discard block |
||
| 207 | 213 | if ($this->Done) |
| 208 | 214 | { |
| 209 | 215 | // Ran off the end of my bits... |
| 210 | - if ($this->CurBit >= $this->LastBit) |
|
| 211 | - return 0; |
|
| 216 | + if ($this->CurBit >= $this->LastBit) { |
|
| 217 | + return 0; |
|
| 218 | + } |
|
| 212 | 219 | |
| 213 | 220 | return -1; |
| 214 | 221 | } |
@@ -221,13 +228,14 @@ discard block |
||
| 221 | 228 | |
| 222 | 229 | if ($count) |
| 223 | 230 | { |
| 224 | - for ($i = 0; $i < $count; $i++) |
|
| 225 | - $this->Buf[2 + $i] = ord($data{$i}); |
|
| 231 | + for ($i = 0; $i < $count; $i++) { |
|
| 232 | + $this->Buf[2 + $i] = ord($data{$i}); |
|
| 233 | + } |
|
| 226 | 234 | |
| 227 | 235 | $data = substr($data, $count); |
| 236 | + } else { |
|
| 237 | + $this->Done = 1; |
|
| 228 | 238 | } |
| 229 | - else |
|
| 230 | - $this->Done = 1; |
|
| 231 | 239 | |
| 232 | 240 | $this->LastByte = 2 + $count; |
| 233 | 241 | $this->CurBit = ($this->CurBit - $this->LastBit) + 16; |
@@ -235,8 +243,9 @@ discard block |
||
| 235 | 243 | } |
| 236 | 244 | |
| 237 | 245 | $iRet = 0; |
| 238 | - for ($i = $this->CurBit, $j = 0; $j < $this->CodeSize; $i++, $j++) |
|
| 239 | - $iRet |= (($this->Buf[intval($i / 8)] & (1 << ($i % 8))) != 0) << $j; |
|
| 246 | + for ($i = $this->CurBit, $j = 0; $j < $this->CodeSize; $i++, $j++) { |
|
| 247 | + $iRet |= (($this->Buf[intval($i / 8)] & (1 << ($i % 8))) != 0) << $j; |
|
| 248 | + } |
|
| 240 | 249 | |
| 241 | 250 | $this->CurBit += $this->CodeSize; |
| 242 | 251 | return $iRet; |
@@ -261,8 +270,9 @@ discard block |
||
| 261 | 270 | for ($i = 0; $i < $num; $i++) |
| 262 | 271 | { |
| 263 | 272 | $rgb = substr($lpData, $i * 3, 3); |
| 264 | - if (strlen($rgb) < 3) |
|
| 265 | - return false; |
|
| 273 | + if (strlen($rgb) < 3) { |
|
| 274 | + return false; |
|
| 275 | + } |
|
| 266 | 276 | |
| 267 | 277 | $this->m_arColors[] = (ord($rgb[2]) << 16) + (ord($rgb[1]) << 8) + ord($rgb[0]); |
| 268 | 278 | $this->m_nColors++; |
@@ -329,13 +339,15 @@ discard block |
||
| 329 | 339 | $hdrLen = 0; |
| 330 | 340 | |
| 331 | 341 | $this->m_lpVer = substr($lpData, 0, 6); |
| 332 | - if (($this->m_lpVer != 'GIF87a') && ($this->m_lpVer != 'GIF89a')) |
|
| 333 | - return false; |
|
| 342 | + if (($this->m_lpVer != 'GIF87a') && ($this->m_lpVer != 'GIF89a')) { |
|
| 343 | + return false; |
|
| 344 | + } |
|
| 334 | 345 | |
| 335 | 346 | list ($this->m_nWidth, $this->m_nHeight) = array_values(unpack('v2', substr($lpData, 6, 4))); |
| 336 | 347 | |
| 337 | - if (!$this->m_nWidth || !$this->m_nHeight) |
|
| 338 | - return false; |
|
| 348 | + if (!$this->m_nWidth || !$this->m_nHeight) { |
|
| 349 | + return false; |
|
| 350 | + } |
|
| 339 | 351 | |
| 340 | 352 | $b = ord(substr($lpData, 10, 1)); |
| 341 | 353 | $this->m_bGlobalClr = ($b & 0x80) ? true : false; |
@@ -349,8 +361,9 @@ discard block |
||
| 349 | 361 | if ($this->m_bGlobalClr) |
| 350 | 362 | { |
| 351 | 363 | $this->m_colorTable = new gif_color_table(); |
| 352 | - if (!$this->m_colorTable->load(substr($lpData, $hdrLen), $this->m_nTableSize)) |
|
| 353 | - return false; |
|
| 364 | + if (!$this->m_colorTable->load(substr($lpData, $hdrLen), $this->m_nTableSize)) { |
|
| 365 | + return false; |
|
| 366 | + } |
|
| 354 | 367 | |
| 355 | 368 | $hdrLen += 3 * $this->m_nTableSize; |
| 356 | 369 | } |
@@ -377,8 +390,9 @@ discard block |
||
| 377 | 390 | // Get the width/height/etc. from the header. |
| 378 | 391 | list ($this->m_nLeft, $this->m_nTop, $this->m_nWidth, $this->m_nHeight) = array_values(unpack('v4', substr($lpData, 0, 8))); |
| 379 | 392 | |
| 380 | - if (!$this->m_nWidth || !$this->m_nHeight) |
|
| 381 | - return false; |
|
| 393 | + if (!$this->m_nWidth || !$this->m_nHeight) { |
|
| 394 | + return false; |
|
| 395 | + } |
|
| 382 | 396 | |
| 383 | 397 | $b = ord($lpData[8]); |
| 384 | 398 | $this->m_bLocalClr = ($b & 0x80) ? true : false; |
@@ -390,8 +404,9 @@ discard block |
||
| 390 | 404 | if ($this->m_bLocalClr) |
| 391 | 405 | { |
| 392 | 406 | $this->m_colorTable = new gif_color_table(); |
| 393 | - if (!$this->m_colorTable->load(substr($lpData, $hdrLen), $this->m_nTableSize)) |
|
| 394 | - return false; |
|
| 407 | + if (!$this->m_colorTable->load(substr($lpData, $hdrLen), $this->m_nTableSize)) { |
|
| 408 | + return false; |
|
| 409 | + } |
|
| 395 | 410 | |
| 396 | 411 | $hdrLen += 3 * $this->m_nTableSize; |
| 397 | 412 | } |
@@ -427,8 +442,9 @@ discard block |
||
| 427 | 442 | // Extension... |
| 428 | 443 | case 0x21: |
| 429 | 444 | $len = 0; |
| 430 | - if (!$this->skipExt($data, $len)) |
|
| 431 | - return false; |
|
| 445 | + if (!$this->skipExt($data, $len)) { |
|
| 446 | + return false; |
|
| 447 | + } |
|
| 432 | 448 | |
| 433 | 449 | $datLen += $len; |
| 434 | 450 | break; |
@@ -437,21 +453,24 @@ discard block |
||
| 437 | 453 | case 0x2C: |
| 438 | 454 | // Load the header and color table. |
| 439 | 455 | $len = 0; |
| 440 | - if (!$this->m_gih->load($data, $len)) |
|
| 441 | - return false; |
|
| 456 | + if (!$this->m_gih->load($data, $len)) { |
|
| 457 | + return false; |
|
| 458 | + } |
|
| 442 | 459 | |
| 443 | 460 | $data = substr($data, $len); |
| 444 | 461 | $datLen += $len; |
| 445 | 462 | |
| 446 | 463 | // Decompress the data, and ride on home ;). |
| 447 | 464 | $len = 0; |
| 448 | - if (!($this->m_data = $this->m_lzw->decompress($data, $len))) |
|
| 449 | - return false; |
|
| 465 | + if (!($this->m_data = $this->m_lzw->decompress($data, $len))) { |
|
| 466 | + return false; |
|
| 467 | + } |
|
| 450 | 468 | |
| 451 | 469 | $datLen += $len; |
| 452 | 470 | |
| 453 | - if ($this->m_gih->m_bInterlace) |
|
| 454 | - $this->deInterlace(); |
|
| 471 | + if ($this->m_gih->m_bInterlace) { |
|
| 472 | + $this->deInterlace(); |
|
| 473 | + } |
|
| 455 | 474 | |
| 456 | 475 | return true; |
| 457 | 476 | |
@@ -571,17 +590,20 @@ discard block |
||
| 571 | 590 | |
| 572 | 591 | public function loadFile($filename, $iIndex) |
| 573 | 592 | { |
| 574 | - if ($iIndex < 0) |
|
| 575 | - return false; |
|
| 593 | + if ($iIndex < 0) { |
|
| 594 | + return false; |
|
| 595 | + } |
|
| 576 | 596 | |
| 577 | 597 | $this->data = @file_get_contents($filename); |
| 578 | - if ($this->data === false) |
|
| 579 | - return false; |
|
| 598 | + if ($this->data === false) { |
|
| 599 | + return false; |
|
| 600 | + } |
|
| 580 | 601 | |
| 581 | 602 | // Tell the header to load up.... |
| 582 | 603 | $len = 0; |
| 583 | - if (!$this->header->load($this->data, $len)) |
|
| 584 | - return false; |
|
| 604 | + if (!$this->header->load($this->data, $len)) { |
|
| 605 | + return false; |
|
| 606 | + } |
|
| 585 | 607 | |
| 586 | 608 | $this->data = substr($this->data, $len); |
| 587 | 609 | |
@@ -589,8 +611,9 @@ discard block |
||
| 589 | 611 | for ($j = 0; $j <= $iIndex; $j++) |
| 590 | 612 | { |
| 591 | 613 | $imgLen = 0; |
| 592 | - if (!$this->image->load($this->data, $imgLen)) |
|
| 593 | - return false; |
|
| 614 | + if (!$this->image->load($this->data, $imgLen)) { |
|
| 615 | + return false; |
|
| 616 | + } |
|
| 594 | 617 | |
| 595 | 618 | $this->data = substr($this->data, $imgLen); |
| 596 | 619 | } |
@@ -601,8 +624,9 @@ discard block |
||
| 601 | 624 | |
| 602 | 625 | public function get_png_data($background_color) |
| 603 | 626 | { |
| 604 | - if (!$this->loaded) |
|
| 605 | - return false; |
|
| 627 | + if (!$this->loaded) { |
|
| 628 | + return false; |
|
| 629 | + } |
|
| 606 | 630 | |
| 607 | 631 | // Prepare the color table. |
| 608 | 632 | if ($this->image->m_gih->m_bLocalClr) |
@@ -610,25 +634,26 @@ discard block |
||
| 610 | 634 | $colors = $this->image->m_gih->m_nTableSize; |
| 611 | 635 | $pal = $this->image->m_gih->m_colorTable->toString(); |
| 612 | 636 | |
| 613 | - if ($background_color != -1) |
|
| 614 | - $background_color = $this->image->m_gih->m_colorTable->colorIndex($background_color); |
|
| 615 | - } |
|
| 616 | - elseif ($this->header->m_bGlobalClr) |
|
| 637 | + if ($background_color != -1) { |
|
| 638 | + $background_color = $this->image->m_gih->m_colorTable->colorIndex($background_color); |
|
| 639 | + } |
|
| 640 | + } elseif ($this->header->m_bGlobalClr) |
|
| 617 | 641 | { |
| 618 | 642 | $colors = $this->header->m_nTableSize; |
| 619 | 643 | $pal = $this->header->m_colorTable->toString(); |
| 620 | 644 | |
| 621 | - if ($background_color != -1) |
|
| 622 | - $background_color = $this->header->m_colorTable->colorIndex($background_color); |
|
| 623 | - } |
|
| 624 | - else |
|
| 645 | + if ($background_color != -1) { |
|
| 646 | + $background_color = $this->header->m_colorTable->colorIndex($background_color); |
|
| 647 | + } |
|
| 648 | + } else |
|
| 625 | 649 | { |
| 626 | 650 | $colors = 0; |
| 627 | 651 | $background_color = -1; |
| 628 | 652 | } |
| 629 | 653 | |
| 630 | - if ($background_color == -1) |
|
| 631 | - $background_color = $this->header->m_nBgColor; |
|
| 654 | + if ($background_color == -1) { |
|
| 655 | + $background_color = $this->header->m_nBgColor; |
|
| 656 | + } |
|
| 632 | 657 | |
| 633 | 658 | $data = &$this->image->m_data; |
| 634 | 659 | $header = &$this->image->m_gih; |
@@ -644,11 +669,13 @@ discard block |
||
| 644 | 669 | for ($x = 0; $x < $this->header->m_nWidth; $x++, $i++) |
| 645 | 670 | { |
| 646 | 671 | // Is this in the proper range? If so, get the specific pixel data... |
| 647 | - if ($x >= $header->m_nLeft && $y >= $header->m_nTop && $x < ($header->m_nLeft + $header->m_nWidth) && $y < ($header->m_nTop + $header->m_nHeight)) |
|
| 648 | - $bmp .= $data{$i}; |
|
| 672 | + if ($x >= $header->m_nLeft && $y >= $header->m_nTop && $x < ($header->m_nLeft + $header->m_nWidth) && $y < ($header->m_nTop + $header->m_nHeight)) { |
|
| 673 | + $bmp .= $data{$i}; |
|
| 674 | + } |
|
| 649 | 675 | // Otherwise, this is background... |
| 650 | - else |
|
| 651 | - $bmp .= chr($background_color); |
|
| 676 | + else { |
|
| 677 | + $bmp .= chr($background_color); |
|
| 678 | + } |
|
| 652 | 679 | } |
| 653 | 680 | } |
| 654 | 681 | |
@@ -677,8 +704,9 @@ discard block |
||
| 677 | 704 | $tmp = 'tRNS'; |
| 678 | 705 | |
| 679 | 706 | // Stick each color on - full transparency or none. |
| 680 | - for ($i = 0; $i < $colors; $i++) |
|
| 681 | - $tmp .= $i == $this->image->m_nTrans ? "\x00" : "\xFF"; |
|
| 707 | + for ($i = 0; $i < $colors; $i++) { |
|
| 708 | + $tmp .= $i == $this->image->m_nTrans ? "\x00" : "\xFF"; |
|
| 709 | + } |
|
| 682 | 710 | |
| 683 | 711 | $out .= $tmp . pack('N', smf_crc32($tmp)); |
| 684 | 712 | } |
@@ -11,8 +11,9 @@ discard block |
||
| 11 | 11 | * @version 2.1 Beta 4 |
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | -if (!defined('SMF')) |
|
| 14 | +if (!defined('SMF')) { |
|
| 15 | 15 | die('Hacking attempt...'); |
| 16 | +} |
|
| 16 | 17 | |
| 17 | 18 | /** |
| 18 | 19 | * Our Cache API class |
@@ -34,8 +35,9 @@ discard block |
||
| 34 | 35 | |
| 35 | 36 | $supported = class_exists('memcache'); |
| 36 | 37 | |
| 37 | - if ($test) |
|
| 38 | - return $supported; |
|
| 38 | + if ($test) { |
|
| 39 | + return $supported; |
|
| 40 | + } |
|
| 39 | 41 | return parent::isSupported() && $supported && !empty($cache_memcached); |
| 40 | 42 | } |
| 41 | 43 | |
@@ -61,9 +63,9 @@ discard block |
||
| 61 | 63 | $server = trim($servers[array_rand($servers)]); |
| 62 | 64 | |
| 63 | 65 | // Normal host names do not contain slashes, while e.g. unix sockets do. Assume alternative transport pipe with port 0. |
| 64 | - if (strpos($server,'/') !== false) |
|
| 65 | - $host = $server; |
|
| 66 | - else |
|
| 66 | + if (strpos($server,'/') !== false) { |
|
| 67 | + $host = $server; |
|
| 68 | + } else |
|
| 67 | 69 | { |
| 68 | 70 | $server = explode(':', $server); |
| 69 | 71 | $host = $server[0]; |
@@ -71,10 +73,11 @@ discard block |
||
| 71 | 73 | } |
| 72 | 74 | |
| 73 | 75 | // Don't wait too long: yes, we want the server, but we might be able to run the query faster! |
| 74 | - if (empty($db_persist)) |
|
| 75 | - $connected = $this->memcache->connect($host, $port); |
|
| 76 | - else |
|
| 77 | - $connected = $this->memcache->pconnect($host, $port); |
|
| 76 | + if (empty($db_persist)) { |
|
| 77 | + $connected = $this->memcache->connect($host, $port); |
|
| 78 | + } else { |
|
| 79 | + $connected = $this->memcache->pconnect($host, $port); |
|
| 80 | + } |
|
| 78 | 81 | } |
| 79 | 82 | |
| 80 | 83 | return $connected; |
@@ -90,8 +93,9 @@ discard block |
||
| 90 | 93 | $value = $this->memcache->get($key); |
| 91 | 94 | |
| 92 | 95 | // $value should return either data or false (from failure, key not found or empty array). |
| 93 | - if ($value === false) |
|
| 94 | - return null; |
|
| 96 | + if ($value === false) { |
|
| 97 | + return null; |
|
| 98 | + } |
|
| 95 | 99 | return $value; |
| 96 | 100 | } |
| 97 | 101 | |
@@ -132,8 +136,9 @@ discard block |
||
| 132 | 136 | $config_vars[] = $txt['cache_memcache_settings']; |
| 133 | 137 | $config_vars[] = array('cache_memcached', $txt['cache_memcache_servers'], 'file', 'text', 0, 'cache_memcached', 'postinput' => '<br /><div class="smalltext"><em>' . $txt['cache_memcache_servers_subtext'] . '</em></div>'); |
| 134 | 138 | |
| 135 | - if (!isset($context['settings_post_javascript'])) |
|
| 136 | - $context['settings_post_javascript'] = ''; |
|
| 139 | + if (!isset($context['settings_post_javascript'])) { |
|
| 140 | + $context['settings_post_javascript'] = ''; |
|
| 141 | + } |
|
| 137 | 142 | |
| 138 | 143 | $context['settings_post_javascript'] .= ' |
| 139 | 144 | $("#cache_accelerator").change(function (e) { |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 4 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * The main handler and designator for AJAX stuff - jumpto, message icons and previews |
@@ -32,8 +33,9 @@ discard block |
||
| 32 | 33 | // Easy adding of sub actions. |
| 33 | 34 | call_integration_hook('integrate_XMLhttpMain_subActions', array(&$subActions)); |
| 34 | 35 | |
| 35 | - if (!isset($_REQUEST['sa'], $subActions[$_REQUEST['sa']])) |
|
| 36 | - fatal_lang_error('no_access', false); |
|
| 36 | + if (!isset($_REQUEST['sa'], $subActions[$_REQUEST['sa']])) { |
|
| 37 | + fatal_lang_error('no_access', false); |
|
| 38 | + } |
|
| 37 | 39 | |
| 38 | 40 | call_helper($subActions[$_REQUEST['sa']]); |
| 39 | 41 | } |
@@ -57,8 +59,9 @@ discard block |
||
| 57 | 59 | foreach ($context['jump_to'] as $id_cat => $cat) |
| 58 | 60 | { |
| 59 | 61 | $context['jump_to'][$id_cat]['name'] = un_htmlspecialchars(strip_tags($cat['name'])); |
| 60 | - foreach ($cat['boards'] as $id_board => $board) |
|
| 61 | - $context['jump_to'][$id_cat]['boards'][$id_board]['name'] = un_htmlspecialchars(strip_tags($board['name'])); |
|
| 62 | + foreach ($cat['boards'] as $id_board => $board) { |
|
| 63 | + $context['jump_to'][$id_cat]['boards'][$id_board]['name'] = un_htmlspecialchars(strip_tags($board['name'])); |
|
| 64 | + } |
|
| 62 | 65 | } |
| 63 | 66 | |
| 64 | 67 | $context['sub_template'] = 'jump_to'; |
@@ -95,8 +98,9 @@ discard block |
||
| 95 | 98 | |
| 96 | 99 | $context['sub_template'] = 'generic_xml'; |
| 97 | 100 | |
| 98 | - if (!isset($_POST['item']) || !in_array($_POST['item'], $items)) |
|
| 99 | - return false; |
|
| 101 | + if (!isset($_POST['item']) || !in_array($_POST['item'], $items)) { |
|
| 102 | + return false; |
|
| 103 | + } |
|
| 100 | 104 | |
| 101 | 105 | $_POST['item'](); |
| 102 | 106 | } |
@@ -112,10 +116,11 @@ discard block |
||
| 112 | 116 | |
| 113 | 117 | $errors = array(); |
| 114 | 118 | $news = !isset($_POST['news']) ? '' : $smcFunc['htmlspecialchars']($_POST['news'], ENT_QUOTES); |
| 115 | - if (empty($news)) |
|
| 116 | - $errors[] = array('value' => 'no_news'); |
|
| 117 | - else |
|
| 118 | - preparsecode($news); |
|
| 119 | + if (empty($news)) { |
|
| 120 | + $errors[] = array('value' => 'no_news'); |
|
| 121 | + } else { |
|
| 122 | + preparsecode($news); |
|
| 123 | + } |
|
| 119 | 124 | |
| 120 | 125 | $context['xml_data'] = array( |
| 121 | 126 | 'news' => array( |
@@ -148,10 +153,12 @@ discard block |
||
| 148 | 153 | $context['send_pm'] = !empty($_POST['send_pm']) ? 1 : 0; |
| 149 | 154 | $context['send_html'] = !empty($_POST['send_html']) ? 1 : 0; |
| 150 | 155 | |
| 151 | - if (empty($_POST['subject'])) |
|
| 152 | - $context['post_error']['messages'][] = $txt['error_no_subject']; |
|
| 153 | - if (empty($_POST['message'])) |
|
| 154 | - $context['post_error']['messages'][] = $txt['error_no_message']; |
|
| 156 | + if (empty($_POST['subject'])) { |
|
| 157 | + $context['post_error']['messages'][] = $txt['error_no_subject']; |
|
| 158 | + } |
|
| 159 | + if (empty($_POST['message'])) { |
|
| 160 | + $context['post_error']['messages'][] = $txt['error_no_message']; |
|
| 161 | + } |
|
| 155 | 162 | |
| 156 | 163 | prepareMailingForPreview(); |
| 157 | 164 | |
@@ -196,38 +203,41 @@ discard block |
||
| 196 | 203 | $preview_signature = !empty($_POST['signature']) ? $_POST['signature'] : $txt['no_signature_preview']; |
| 197 | 204 | $validation = profileValidateSignature($preview_signature); |
| 198 | 205 | |
| 199 | - if ($validation !== true && $validation !== false) |
|
| 200 | - $errors[] = array('value' => $txt['profile_error_' . $validation], 'attributes' => array('type' => 'error')); |
|
| 206 | + if ($validation !== true && $validation !== false) { |
|
| 207 | + $errors[] = array('value' => $txt['profile_error_' . $validation], 'attributes' => array('type' => 'error')); |
|
| 208 | + } |
|
| 201 | 209 | |
| 202 | 210 | censorText($preview_signature); |
| 203 | 211 | $preview_signature = parse_bbc($preview_signature, true, 'sig' . $user); |
| 204 | - } |
|
| 205 | - elseif (!$can_change) |
|
| 212 | + } elseif (!$can_change) |
|
| 206 | 213 | { |
| 207 | - if ($is_owner) |
|
| 208 | - $errors[] = array('value' => $txt['cannot_profile_extra_own'], 'attributes' => array('type' => 'error')); |
|
| 209 | - else |
|
| 210 | - $errors[] = array('value' => $txt['cannot_profile_extra_any'], 'attributes' => array('type' => 'error')); |
|
| 214 | + if ($is_owner) { |
|
| 215 | + $errors[] = array('value' => $txt['cannot_profile_extra_own'], 'attributes' => array('type' => 'error')); |
|
| 216 | + } else { |
|
| 217 | + $errors[] = array('value' => $txt['cannot_profile_extra_any'], 'attributes' => array('type' => 'error')); |
|
| 218 | + } |
|
| 219 | + } else { |
|
| 220 | + $errors[] = array('value' => $txt['no_user_selected'], 'attributes' => array('type' => 'error')); |
|
| 211 | 221 | } |
| 212 | - else |
|
| 213 | - $errors[] = array('value' => $txt['no_user_selected'], 'attributes' => array('type' => 'error')); |
|
| 214 | 222 | |
| 215 | 223 | $context['xml_data']['signatures'] = array( |
| 216 | 224 | 'identifier' => 'signature', |
| 217 | 225 | 'children' => array() |
| 218 | 226 | ); |
| 219 | - if (isset($current_signature)) |
|
| 220 | - $context['xml_data']['signatures']['children'][] = array( |
|
| 227 | + if (isset($current_signature)) { |
|
| 228 | + $context['xml_data']['signatures']['children'][] = array( |
|
| 221 | 229 | 'value' => $current_signature, |
| 222 | 230 | 'attributes' => array('type' => 'current'), |
| 223 | 231 | ); |
| 224 | - if (isset($preview_signature)) |
|
| 225 | - $context['xml_data']['signatures']['children'][] = array( |
|
| 232 | + } |
|
| 233 | + if (isset($preview_signature)) { |
|
| 234 | + $context['xml_data']['signatures']['children'][] = array( |
|
| 226 | 235 | 'value' => $preview_signature, |
| 227 | 236 | 'attributes' => array('type' => 'preview'), |
| 228 | 237 | ); |
| 229 | - if (!empty($errors)) |
|
| 230 | - $context['xml_data']['errors'] = array( |
|
| 238 | + } |
|
| 239 | + if (!empty($errors)) { |
|
| 240 | + $context['xml_data']['errors'] = array( |
|
| 231 | 241 | 'identifier' => 'error', |
| 232 | 242 | 'children' => array_merge( |
| 233 | 243 | array( |
@@ -239,7 +249,8 @@ discard block |
||
| 239 | 249 | $errors |
| 240 | 250 | ), |
| 241 | 251 | ); |
| 242 | -} |
|
| 252 | + } |
|
| 253 | + } |
|
| 243 | 254 | |
| 244 | 255 | /** |
| 245 | 256 | * Handles previewing user warnings |
@@ -259,15 +270,17 @@ discard block |
||
| 259 | 270 | $context['preview_subject'] = !empty($_POST['title']) ? trim($smcFunc['htmlspecialchars']($_POST['title'])) : ''; |
| 260 | 271 | if (isset($_POST['issuing'])) |
| 261 | 272 | { |
| 262 | - if (empty($_POST['title']) || empty($_POST['body'])) |
|
| 263 | - $context['post_error']['messages'][] = $txt['warning_notify_blank']; |
|
| 264 | - } |
|
| 265 | - else |
|
| 273 | + if (empty($_POST['title']) || empty($_POST['body'])) { |
|
| 274 | + $context['post_error']['messages'][] = $txt['warning_notify_blank']; |
|
| 275 | + } |
|
| 276 | + } else |
|
| 266 | 277 | { |
| 267 | - if (empty($_POST['title'])) |
|
| 268 | - $context['post_error']['messages'][] = $txt['mc_warning_template_error_no_title']; |
|
| 269 | - if (empty($_POST['body'])) |
|
| 270 | - $context['post_error']['messages'][] = $txt['mc_warning_template_error_no_body']; |
|
| 278 | + if (empty($_POST['title'])) { |
|
| 279 | + $context['post_error']['messages'][] = $txt['mc_warning_template_error_no_title']; |
|
| 280 | + } |
|
| 281 | + if (empty($_POST['body'])) { |
|
| 282 | + $context['post_error']['messages'][] = $txt['mc_warning_template_error_no_body']; |
|
| 283 | + } |
|
| 271 | 284 | // Add in few replacements. |
| 272 | 285 | /** |
| 273 | 286 | * These are the defaults: |
@@ -298,9 +311,9 @@ discard block |
||
| 298 | 311 | $warning_body = parse_bbc($warning_body, true); |
| 299 | 312 | } |
| 300 | 313 | $context['preview_message'] = $warning_body; |
| 314 | + } else { |
|
| 315 | + $context['post_error']['messages'][] = array('value' => $txt['cannot_issue_warning'], 'attributes' => array('type' => 'error')); |
|
| 301 | 316 | } |
| 302 | - else |
|
| 303 | - $context['post_error']['messages'][] = array('value' => $txt['cannot_issue_warning'], 'attributes' => array('type' => 'error')); |
|
| 304 | 317 | |
| 305 | 318 | $context['sub_template'] = 'warning'; |
| 306 | 319 | } |
@@ -14,8 +14,9 @@ discard block |
||
| 14 | 14 | * @version 2.1 Beta 4 |
| 15 | 15 | */ |
| 16 | 16 | |
| 17 | -if (!defined('SMF')) |
|
| 17 | +if (!defined('SMF')) { |
|
| 18 | 18 | die('No direct access...'); |
| 19 | +} |
|
| 19 | 20 | |
| 20 | 21 | /** |
| 21 | 22 | * 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); |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 4 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * Edit the position and properties of a category. |
@@ -42,8 +43,9 @@ discard block |
||
| 42 | 43 | $cat_order = array(); |
| 43 | 44 | |
| 44 | 45 | // Setting 'move_after' to '0' moves the category to the top. |
| 45 | - if ($catOptions['move_after'] == 0) |
|
| 46 | - $cats[] = $category_id; |
|
| 46 | + if ($catOptions['move_after'] == 0) { |
|
| 47 | + $cats[] = $category_id; |
|
| 48 | + } |
|
| 47 | 49 | |
| 48 | 50 | // Grab the categories sorted by cat_order. |
| 49 | 51 | $request = $smcFunc['db_query']('', ' |
@@ -55,17 +57,19 @@ discard block |
||
| 55 | 57 | ); |
| 56 | 58 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 57 | 59 | { |
| 58 | - if ($row['id_cat'] != $category_id) |
|
| 59 | - $cats[] = $row['id_cat']; |
|
| 60 | - if ($row['id_cat'] == $catOptions['move_after']) |
|
| 61 | - $cats[] = $category_id; |
|
| 60 | + if ($row['id_cat'] != $category_id) { |
|
| 61 | + $cats[] = $row['id_cat']; |
|
| 62 | + } |
|
| 63 | + if ($row['id_cat'] == $catOptions['move_after']) { |
|
| 64 | + $cats[] = $category_id; |
|
| 65 | + } |
|
| 62 | 66 | $cat_order[$row['id_cat']] = $row['cat_order']; |
| 63 | 67 | } |
| 64 | 68 | $smcFunc['db_free_result']($request); |
| 65 | 69 | |
| 66 | 70 | // Set the new order for the categories. |
| 67 | - foreach ($cats as $index => $cat) |
|
| 68 | - if ($index != $cat_order[$cat]) |
|
| 71 | + foreach ($cats as $index => $cat) { |
|
| 72 | + if ($index != $cat_order[$cat]) |
|
| 69 | 73 | $smcFunc['db_query']('', ' |
| 70 | 74 | UPDATE {db_prefix}categories |
| 71 | 75 | SET cat_order = {int:new_order} |
@@ -75,6 +79,7 @@ discard block |
||
| 75 | 79 | 'current_category' => $cat, |
| 76 | 80 | ) |
| 77 | 81 | ); |
| 82 | + } |
|
| 78 | 83 | |
| 79 | 84 | // If the category order changed, so did the board order. |
| 80 | 85 | require_once($sourcedir . '/Subs-Boards.php'); |
@@ -117,8 +122,9 @@ discard block |
||
| 117 | 122 | )) |
| 118 | 123 | ); |
| 119 | 124 | |
| 120 | - if (empty($catOptions['dont_log'])) |
|
| 121 | - logAction('edit_cat', array('catname' => isset($catOptions['cat_name']) ? $catOptions['cat_name'] : $category_id), 'admin'); |
|
| 125 | + if (empty($catOptions['dont_log'])) { |
|
| 126 | + logAction('edit_cat', array('catname' => isset($catOptions['cat_name']) ? $catOptions['cat_name'] : $category_id), 'admin'); |
|
| 127 | + } |
|
| 122 | 128 | } |
| 123 | 129 | } |
| 124 | 130 | |
@@ -135,16 +141,20 @@ discard block |
||
| 135 | 141 | global $smcFunc; |
| 136 | 142 | |
| 137 | 143 | // Check required values. |
| 138 | - if (!isset($catOptions['cat_name']) || trim($catOptions['cat_name']) == '') |
|
| 139 | - trigger_error('createCategory(): A category name is required', E_USER_ERROR); |
|
| 144 | + if (!isset($catOptions['cat_name']) || trim($catOptions['cat_name']) == '') { |
|
| 145 | + trigger_error('createCategory(): A category name is required', E_USER_ERROR); |
|
| 146 | + } |
|
| 140 | 147 | |
| 141 | 148 | // Set default values. |
| 142 | - if (!isset($catOptions['cat_desc'])) |
|
| 143 | - $catOptions['cat_desc'] = ''; |
|
| 144 | - if (!isset($catOptions['move_after'])) |
|
| 145 | - $catOptions['move_after'] = 0; |
|
| 146 | - if (!isset($catOptions['is_collapsible'])) |
|
| 147 | - $catOptions['is_collapsible'] = true; |
|
| 149 | + if (!isset($catOptions['cat_desc'])) { |
|
| 150 | + $catOptions['cat_desc'] = ''; |
|
| 151 | + } |
|
| 152 | + if (!isset($catOptions['move_after'])) { |
|
| 153 | + $catOptions['move_after'] = 0; |
|
| 154 | + } |
|
| 155 | + if (!isset($catOptions['is_collapsible'])) { |
|
| 156 | + $catOptions['is_collapsible'] = true; |
|
| 157 | + } |
|
| 148 | 158 | // Don't log an edit right after. |
| 149 | 159 | $catOptions['dont_log'] = true; |
| 150 | 160 | |
@@ -210,21 +220,24 @@ discard block |
||
| 210 | 220 | ) |
| 211 | 221 | ); |
| 212 | 222 | $boards_inside = array(); |
| 213 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 214 | - $boards_inside[] = $row['id_board']; |
|
| 223 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 224 | + $boards_inside[] = $row['id_board']; |
|
| 225 | + } |
|
| 215 | 226 | $smcFunc['db_free_result']($request); |
| 216 | 227 | |
| 217 | - if (!empty($boards_inside)) |
|
| 218 | - deleteBoards($boards_inside, null); |
|
| 228 | + if (!empty($boards_inside)) { |
|
| 229 | + deleteBoards($boards_inside, null); |
|
| 230 | + } |
|
| 219 | 231 | } |
| 220 | 232 | |
| 221 | 233 | // Make sure the safe category is really safe. |
| 222 | - elseif (in_array($moveBoardsTo, $categories)) |
|
| 223 | - trigger_error('deleteCategories(): You cannot move the boards to a category that\'s being deleted', E_USER_ERROR); |
|
| 234 | + elseif (in_array($moveBoardsTo, $categories)) { |
|
| 235 | + trigger_error('deleteCategories(): You cannot move the boards to a category that\'s being deleted', E_USER_ERROR); |
|
| 236 | + } |
|
| 224 | 237 | |
| 225 | 238 | // Move the boards inside the categories to a safe category. |
| 226 | - else |
|
| 227 | - $smcFunc['db_query']('', ' |
|
| 239 | + else { |
|
| 240 | + $smcFunc['db_query']('', ' |
|
| 228 | 241 | UPDATE {db_prefix}boards |
| 229 | 242 | SET id_cat = {int:new_parent_cat} |
| 230 | 243 | WHERE id_cat IN ({array_int:category_list})', |
@@ -233,6 +246,7 @@ discard block |
||
| 233 | 246 | 'new_parent_cat' => $moveBoardsTo, |
| 234 | 247 | ) |
| 235 | 248 | ); |
| 249 | + } |
|
| 236 | 250 | |
| 237 | 251 | // Do the deletion of the category itself |
| 238 | 252 | $smcFunc['db_query']('', ' |
@@ -244,8 +258,9 @@ discard block |
||
| 244 | 258 | ); |
| 245 | 259 | |
| 246 | 260 | // Log what we've done. |
| 247 | - foreach ($categories as $category) |
|
| 248 | - logAction('delete_cat', array('catname' => $cat_tree[$category]['node']['name']), 'admin'); |
|
| 261 | + foreach ($categories as $category) { |
|
| 262 | + logAction('delete_cat', array('catname' => $cat_tree[$category]['node']['name']), 'admin'); |
|
| 263 | + } |
|
| 249 | 264 | |
| 250 | 265 | // Get all boards back into the right order. |
| 251 | 266 | reorderBoards(); |
@@ -14,8 +14,9 @@ discard block |
||
| 14 | 14 | * @version 2.1 Beta 4 |
| 15 | 15 | */ |
| 16 | 16 | |
| 17 | -if (!defined('SMF')) |
|
| 17 | +if (!defined('SMF')) { |
|
| 18 | 18 | die('No direct access...'); |
| 19 | +} |
|
| 19 | 20 | |
| 20 | 21 | /** |
| 21 | 22 | * Show the list of topics in this board, along with any child boards. |
@@ -56,8 +57,9 @@ discard block |
||
| 56 | 57 | |
| 57 | 58 | $context['name'] = $board_info['name']; |
| 58 | 59 | $context['description'] = $board_info['description']; |
| 59 | - if (!empty($board_info['description'])) |
|
| 60 | - $context['meta_description'] = strip_tags($board_info['description']); |
|
| 60 | + if (!empty($board_info['description'])) { |
|
| 61 | + $context['meta_description'] = strip_tags($board_info['description']); |
|
| 62 | + } |
|
| 61 | 63 | |
| 62 | 64 | // How many topics do we have in total? |
| 63 | 65 | $board_info['total_topics'] = allowedTo('approve_posts') ? $board_info['num_topics'] + $board_info['unapproved_topics'] : $board_info['num_topics'] + $board_info['unapproved_user_topics']; |
@@ -73,12 +75,14 @@ discard block |
||
| 73 | 75 | $session_name = session_name(); |
| 74 | 76 | foreach ($_GET as $k => $v) |
| 75 | 77 | { |
| 76 | - if (!in_array($k, array('board', 'start', $session_name))) |
|
| 77 | - $context['robot_no_index'] = true; |
|
| 78 | + if (!in_array($k, array('board', 'start', $session_name))) { |
|
| 79 | + $context['robot_no_index'] = true; |
|
| 80 | + } |
|
| 78 | 81 | } |
| 79 | 82 | } |
| 80 | - if (!empty($_REQUEST['start']) && (!is_numeric($_REQUEST['start']) || $_REQUEST['start'] % $context['messages_per_page'] != 0)) |
|
| 81 | - $context['robot_no_index'] = true; |
|
| 83 | + if (!empty($_REQUEST['start']) && (!is_numeric($_REQUEST['start']) || $_REQUEST['start'] % $context['messages_per_page'] != 0)) { |
|
| 84 | + $context['robot_no_index'] = true; |
|
| 85 | + } |
|
| 82 | 86 | |
| 83 | 87 | // If we can view unapproved messages and there are some build up a list. |
| 84 | 88 | if (allowedTo('approve_posts') && ($board_info['unapproved_topics'] || $board_info['unapproved_posts'])) |
@@ -89,14 +93,16 @@ discard block |
||
| 89 | 93 | } |
| 90 | 94 | |
| 91 | 95 | // We only know these. |
| 92 | - if (isset($_REQUEST['sort']) && !in_array($_REQUEST['sort'], array('subject', 'starter', 'last_poster', 'replies', 'views', 'first_post', 'last_post'))) |
|
| 93 | - $_REQUEST['sort'] = 'last_post'; |
|
| 96 | + if (isset($_REQUEST['sort']) && !in_array($_REQUEST['sort'], array('subject', 'starter', 'last_poster', 'replies', 'views', 'first_post', 'last_post'))) { |
|
| 97 | + $_REQUEST['sort'] = 'last_post'; |
|
| 98 | + } |
|
| 94 | 99 | |
| 95 | 100 | // Make sure the starting place makes sense and construct the page index. |
| 96 | - if (isset($_REQUEST['sort'])) |
|
| 97 | - $context['page_index'] = constructPageIndex($scripturl . '?board=' . $board . '.%1$d;sort=' . $_REQUEST['sort'] . (isset($_REQUEST['desc']) ? ';desc' : ''), $_REQUEST['start'], $board_info['total_topics'], $maxindex, true); |
|
| 98 | - else |
|
| 99 | - $context['page_index'] = constructPageIndex($scripturl . '?board=' . $board . '.%1$d', $_REQUEST['start'], $board_info['total_topics'], $maxindex, true); |
|
| 101 | + if (isset($_REQUEST['sort'])) { |
|
| 102 | + $context['page_index'] = constructPageIndex($scripturl . '?board=' . $board . '.%1$d;sort=' . $_REQUEST['sort'] . (isset($_REQUEST['desc']) ? ';desc' : ''), $_REQUEST['start'], $board_info['total_topics'], $maxindex, true); |
|
| 103 | + } else { |
|
| 104 | + $context['page_index'] = constructPageIndex($scripturl . '?board=' . $board . '.%1$d', $_REQUEST['start'], $board_info['total_topics'], $maxindex, true); |
|
| 105 | + } |
|
| 100 | 106 | $context['start'] = &$_REQUEST['start']; |
| 101 | 107 | |
| 102 | 108 | // Set a canonical URL for this page. |
@@ -132,14 +138,16 @@ discard block |
||
| 132 | 138 | $context['link_moderators'] = array(); |
| 133 | 139 | if (!empty($board_info['moderators'])) |
| 134 | 140 | { |
| 135 | - foreach ($board_info['moderators'] as $mod) |
|
| 136 | - $context['link_moderators'][] = '<a href="' . $scripturl . '?action=profile;u=' . $mod['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod['name'] . '</a>'; |
|
| 141 | + foreach ($board_info['moderators'] as $mod) { |
|
| 142 | + $context['link_moderators'][] = '<a href="' . $scripturl . '?action=profile;u=' . $mod['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod['name'] . '</a>'; |
|
| 143 | + } |
|
| 137 | 144 | } |
| 138 | 145 | if (!empty($board_info['moderator_groups'])) |
| 139 | 146 | { |
| 140 | 147 | // By default just tack the moderator groups onto the end of the members |
| 141 | - foreach ($board_info['moderator_groups'] as $mod_group) |
|
| 142 | - $context['link_moderators'][] = '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $mod_group['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod_group['name'] . '</a>'; |
|
| 148 | + foreach ($board_info['moderator_groups'] as $mod_group) { |
|
| 149 | + $context['link_moderators'][] = '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $mod_group['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod_group['name'] . '</a>'; |
|
| 150 | + } |
|
| 143 | 151 | } |
| 144 | 152 | |
| 145 | 153 | // Now we tack the info onto the end of the linktree |
@@ -191,20 +199,24 @@ discard block |
||
| 191 | 199 | ); |
| 192 | 200 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 193 | 201 | { |
| 194 | - if (empty($row['id_member'])) |
|
| 195 | - continue; |
|
| 202 | + if (empty($row['id_member'])) { |
|
| 203 | + continue; |
|
| 204 | + } |
|
| 196 | 205 | |
| 197 | - if (!empty($row['online_color'])) |
|
| 198 | - $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>'; |
|
| 199 | - else |
|
| 200 | - $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
| 206 | + if (!empty($row['online_color'])) { |
|
| 207 | + $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>'; |
|
| 208 | + } else { |
|
| 209 | + $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
| 210 | + } |
|
| 201 | 211 | |
| 202 | 212 | $is_buddy = in_array($row['id_member'], $user_info['buddies']); |
| 203 | - if ($is_buddy) |
|
| 204 | - $link = '<strong>' . $link . '</strong>'; |
|
| 213 | + if ($is_buddy) { |
|
| 214 | + $link = '<strong>' . $link . '</strong>'; |
|
| 215 | + } |
|
| 205 | 216 | |
| 206 | - if (!empty($row['show_online']) || allowedTo('moderate_forum')) |
|
| 207 | - $context['view_members_list'][$row['log_time'] . $row['member_name']] = empty($row['show_online']) ? '<em>' . $link . '</em>' : $link; |
|
| 217 | + if (!empty($row['show_online']) || allowedTo('moderate_forum')) { |
|
| 218 | + $context['view_members_list'][$row['log_time'] . $row['member_name']] = empty($row['show_online']) ? '<em>' . $link . '</em>' : $link; |
|
| 219 | + } |
|
| 208 | 220 | // @todo why are we filling this array of data that are just counted (twice) and discarded? ??? |
| 209 | 221 | $context['view_members'][$row['log_time'] . $row['member_name']] = array( |
| 210 | 222 | 'id' => $row['id_member'], |
@@ -217,8 +229,9 @@ discard block |
||
| 217 | 229 | 'hidden' => empty($row['show_online']), |
| 218 | 230 | ); |
| 219 | 231 | |
| 220 | - if (empty($row['show_online'])) |
|
| 221 | - $context['view_num_hidden']++; |
|
| 232 | + if (empty($row['show_online'])) { |
|
| 233 | + $context['view_num_hidden']++; |
|
| 234 | + } |
|
| 222 | 235 | } |
| 223 | 236 | $context['view_num_guests'] = $smcFunc['db_num_rows']($request) - count($context['view_members']); |
| 224 | 237 | $smcFunc['db_free_result']($request); |
@@ -257,8 +270,9 @@ discard block |
||
| 257 | 270 | $context['sort_direction'] = $ascending ? 'up' : 'down'; |
| 258 | 271 | $txt['starter'] = $txt['started_by']; |
| 259 | 272 | |
| 260 | - foreach ($sort_methods as $key => $val) |
|
| 261 | - $context['topics_headers'][$key] = '<a href="' . $scripturl . '?board=' . $context['current_board'] . '.' . $context['start'] . ';sort=' . $key . ($context['sort_by'] == $key && $context['sort_direction'] == 'up' ? ';desc' : '') . '">' . $txt[$key] . ($context['sort_by'] == $key ? '<span class="sort sort_' . $context['sort_direction'] . '"></span>' : '') . '</a>'; |
|
| 273 | + foreach ($sort_methods as $key => $val) { |
|
| 274 | + $context['topics_headers'][$key] = '<a href="' . $scripturl . '?board=' . $context['current_board'] . '.' . $context['start'] . ';sort=' . $key . ($context['sort_by'] == $key && $context['sort_direction'] == 'up' ? ';desc' : '') . '">' . $txt[$key] . ($context['sort_by'] == $key ? '<span class="sort sort_' . $context['sort_direction'] . '"></span>' : '') . '</a>'; |
|
| 275 | + } |
|
| 262 | 276 | |
| 263 | 277 | // Calculate the fastest way to get the topics. |
| 264 | 278 | $start = (int) $_REQUEST['start']; |
@@ -268,14 +282,15 @@ discard block |
||
| 268 | 282 | $fake_ascending = true; |
| 269 | 283 | $maxindex = $board_info['total_topics'] < $start + $maxindex + 1 ? $board_info['total_topics'] - $start : $maxindex; |
| 270 | 284 | $start = $board_info['total_topics'] < $start + $maxindex + 1 ? 0 : $board_info['total_topics'] - $start - $maxindex; |
| 285 | + } else { |
|
| 286 | + $fake_ascending = false; |
|
| 271 | 287 | } |
| 272 | - else |
|
| 273 | - $fake_ascending = false; |
|
| 274 | 288 | |
| 275 | 289 | // Setup the default topic icons... |
| 276 | 290 | $context['icon_sources'] = array(); |
| 277 | - foreach ($context['stable_icons'] as $icon) |
|
| 278 | - $context['icon_sources'][$icon] = 'images_url'; |
|
| 291 | + foreach ($context['stable_icons'] as $icon) { |
|
| 292 | + $context['icon_sources'][$icon] = 'images_url'; |
|
| 293 | + } |
|
| 279 | 294 | |
| 280 | 295 | $topic_ids = array(); |
| 281 | 296 | $context['topics'] = array(); |
@@ -306,8 +321,9 @@ discard block |
||
| 306 | 321 | ) |
| 307 | 322 | ); |
| 308 | 323 | $topic_ids = array(); |
| 309 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 310 | - $topic_ids[] = $row['id_topic']; |
|
| 324 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 325 | + $topic_ids[] = $row['id_topic']; |
|
| 326 | + } |
|
| 311 | 327 | } |
| 312 | 328 | |
| 313 | 329 | // Grab the appropriate topic information... |
@@ -363,11 +379,13 @@ discard block |
||
| 363 | 379 | // Begin 'printing' the message index for current board. |
| 364 | 380 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 365 | 381 | { |
| 366 | - if ($row['id_poll'] > 0 && $modSettings['pollMode'] == '0') |
|
| 367 | - continue; |
|
| 382 | + if ($row['id_poll'] > 0 && $modSettings['pollMode'] == '0') { |
|
| 383 | + continue; |
|
| 384 | + } |
|
| 368 | 385 | |
| 369 | - if (!$pre_query) |
|
| 370 | - $topic_ids[] = $row['id_topic']; |
|
| 386 | + if (!$pre_query) { |
|
| 387 | + $topic_ids[] = $row['id_topic']; |
|
| 388 | + } |
|
| 371 | 389 | |
| 372 | 390 | // Reference the main color class. |
| 373 | 391 | $colorClass = 'windowbg'; |
@@ -377,8 +395,9 @@ discard block |
||
| 377 | 395 | { |
| 378 | 396 | // Limit them to $modSettings['preview_characters'] characters |
| 379 | 397 | $row['first_body'] = strip_tags(strtr(parse_bbc($row['first_body'], $row['first_smileys'], $row['id_first_msg']), array('<br>' => ' '))); |
| 380 | - if ($smcFunc['strlen']($row['first_body']) > $modSettings['preview_characters']) |
|
| 381 | - $row['first_body'] = $smcFunc['substr']($row['first_body'], 0, $modSettings['preview_characters']) . '...'; |
|
| 398 | + if ($smcFunc['strlen']($row['first_body']) > $modSettings['preview_characters']) { |
|
| 399 | + $row['first_body'] = $smcFunc['substr']($row['first_body'], 0, $modSettings['preview_characters']) . '...'; |
|
| 400 | + } |
|
| 382 | 401 | |
| 383 | 402 | // Censor the subject and message preview. |
| 384 | 403 | censorText($row['first_subject']); |
@@ -389,27 +408,27 @@ discard block |
||
| 389 | 408 | { |
| 390 | 409 | $row['last_subject'] = $row['first_subject']; |
| 391 | 410 | $row['last_body'] = $row['first_body']; |
| 392 | - } |
|
| 393 | - else |
|
| 411 | + } else |
|
| 394 | 412 | { |
| 395 | 413 | $row['last_body'] = strip_tags(strtr(parse_bbc($row['last_body'], $row['last_smileys'], $row['id_last_msg']), array('<br>' => ' '))); |
| 396 | - if ($smcFunc['strlen']($row['last_body']) > $modSettings['preview_characters']) |
|
| 397 | - $row['last_body'] = $smcFunc['substr']($row['last_body'], 0, $modSettings['preview_characters']) . '...'; |
|
| 414 | + if ($smcFunc['strlen']($row['last_body']) > $modSettings['preview_characters']) { |
|
| 415 | + $row['last_body'] = $smcFunc['substr']($row['last_body'], 0, $modSettings['preview_characters']) . '...'; |
|
| 416 | + } |
|
| 398 | 417 | |
| 399 | 418 | censorText($row['last_subject']); |
| 400 | 419 | censorText($row['last_body']); |
| 401 | 420 | } |
| 402 | - } |
|
| 403 | - else |
|
| 421 | + } else |
|
| 404 | 422 | { |
| 405 | 423 | $row['first_body'] = ''; |
| 406 | 424 | $row['last_body'] = ''; |
| 407 | 425 | censorText($row['first_subject']); |
| 408 | 426 | |
| 409 | - if ($row['id_first_msg'] == $row['id_last_msg']) |
|
| 410 | - $row['last_subject'] = $row['first_subject']; |
|
| 411 | - else |
|
| 412 | - censorText($row['last_subject']); |
|
| 427 | + if ($row['id_first_msg'] == $row['id_last_msg']) { |
|
| 428 | + $row['last_subject'] = $row['first_subject']; |
|
| 429 | + } else { |
|
| 430 | + censorText($row['last_subject']); |
|
| 431 | + } |
|
| 413 | 432 | } |
| 414 | 433 | |
| 415 | 434 | // Decide how many pages the topic should have. |
@@ -420,42 +439,50 @@ discard block |
||
| 420 | 439 | $pages = constructPageIndex($scripturl . '?topic=' . $row['id_topic'] . '.%1$d', $start, $row['num_replies'] + 1, $context['messages_per_page'], true, false); |
| 421 | 440 | |
| 422 | 441 | // If we can use all, show all. |
| 423 | - if (!empty($modSettings['enableAllMessages']) && $row['num_replies'] + 1 < $modSettings['enableAllMessages']) |
|
| 424 | - $pages .= ' <a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0;all">' . $txt['all'] . '</a>'; |
|
| 442 | + if (!empty($modSettings['enableAllMessages']) && $row['num_replies'] + 1 < $modSettings['enableAllMessages']) { |
|
| 443 | + $pages .= ' <a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0;all">' . $txt['all'] . '</a>'; |
|
| 444 | + } |
|
| 445 | + } else { |
|
| 446 | + $pages = ''; |
|
| 425 | 447 | } |
| 426 | - else |
|
| 427 | - $pages = ''; |
|
| 428 | 448 | |
| 429 | 449 | // We need to check the topic icons exist... |
| 430 | 450 | if (!empty($modSettings['messageIconChecks_enable'])) |
| 431 | 451 | { |
| 432 | - if (!isset($context['icon_sources'][$row['first_icon']])) |
|
| 433 | - $context['icon_sources'][$row['first_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['first_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
| 434 | - if (!isset($context['icon_sources'][$row['last_icon']])) |
|
| 435 | - $context['icon_sources'][$row['last_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['last_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
| 436 | - } |
|
| 437 | - else |
|
| 452 | + if (!isset($context['icon_sources'][$row['first_icon']])) { |
|
| 453 | + $context['icon_sources'][$row['first_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['first_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
| 454 | + } |
|
| 455 | + if (!isset($context['icon_sources'][$row['last_icon']])) { |
|
| 456 | + $context['icon_sources'][$row['last_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['last_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
| 457 | + } |
|
| 458 | + } else |
|
| 438 | 459 | { |
| 439 | - if (!isset($context['icon_sources'][$row['first_icon']])) |
|
| 440 | - $context['icon_sources'][$row['first_icon']] = 'images_url'; |
|
| 441 | - if (!isset($context['icon_sources'][$row['last_icon']])) |
|
| 442 | - $context['icon_sources'][$row['last_icon']] = 'images_url'; |
|
| 460 | + if (!isset($context['icon_sources'][$row['first_icon']])) { |
|
| 461 | + $context['icon_sources'][$row['first_icon']] = 'images_url'; |
|
| 462 | + } |
|
| 463 | + if (!isset($context['icon_sources'][$row['last_icon']])) { |
|
| 464 | + $context['icon_sources'][$row['last_icon']] = 'images_url'; |
|
| 465 | + } |
|
| 443 | 466 | } |
| 444 | 467 | |
| 445 | - if (!empty($board_info['recycle'])) |
|
| 446 | - $row['first_icon'] = 'recycled'; |
|
| 468 | + if (!empty($board_info['recycle'])) { |
|
| 469 | + $row['first_icon'] = 'recycled'; |
|
| 470 | + } |
|
| 447 | 471 | |
| 448 | 472 | // Is this topic pending approval, or does it have any posts pending approval? |
| 449 | - if ($context['can_approve_posts'] && $row['unapproved_posts']) |
|
| 450 | - $colorClass .= (!$row['approved'] ? ' approvetopic' : ' approvepost'); |
|
| 473 | + if ($context['can_approve_posts'] && $row['unapproved_posts']) { |
|
| 474 | + $colorClass .= (!$row['approved'] ? ' approvetopic' : ' approvepost'); |
|
| 475 | + } |
|
| 451 | 476 | |
| 452 | 477 | // Sticky topics should get a different color, too. |
| 453 | - if ($row['is_sticky']) |
|
| 454 | - $colorClass .= ' sticky'; |
|
| 478 | + if ($row['is_sticky']) { |
|
| 479 | + $colorClass .= ' sticky'; |
|
| 480 | + } |
|
| 455 | 481 | |
| 456 | 482 | // Locked topics get special treatment as well. |
| 457 | - if ($row['locked']) |
|
| 458 | - $colorClass .= ' locked'; |
|
| 483 | + if ($row['locked']) { |
|
| 484 | + $colorClass .= ' locked'; |
|
| 485 | + } |
|
| 459 | 486 | |
| 460 | 487 | // 'Print' the topic info. |
| 461 | 488 | $context['topics'][$row['id_topic']] = array_merge($row, array( |
@@ -536,8 +563,9 @@ discard block |
||
| 536 | 563 | $smcFunc['db_free_result']($result); |
| 537 | 564 | |
| 538 | 565 | // Fix the sequence of topics if they were retrieved in the wrong order. (for speed reasons...) |
| 539 | - if ($fake_ascending) |
|
| 540 | - $context['topics'] = array_reverse($context['topics'], true); |
|
| 566 | + if ($fake_ascending) { |
|
| 567 | + $context['topics'] = array_reverse($context['topics'], true); |
|
| 568 | + } |
|
| 541 | 569 | |
| 542 | 570 | if (!empty($modSettings['enableParticipation']) && !$user_info['is_guest'] && !empty($topic_ids)) |
| 543 | 571 | { |
@@ -554,8 +582,9 @@ discard block |
||
| 554 | 582 | 'limit' => count($topic_ids), |
| 555 | 583 | ) |
| 556 | 584 | ); |
| 557 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
| 558 | - $context['topics'][$row['id_topic']]['is_posted_in'] = true; |
|
| 585 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
| 586 | + $context['topics'][$row['id_topic']]['is_posted_in'] = true; |
|
| 587 | + } |
|
| 559 | 588 | $smcFunc['db_free_result']($result); |
| 560 | 589 | } |
| 561 | 590 | } |
@@ -580,9 +609,9 @@ discard block |
||
| 580 | 609 | // Can we restore topics? |
| 581 | 610 | $context['can_restore'] = allowedTo('move_any') && !empty($board_info['recycle']); |
| 582 | 611 | |
| 583 | - if ($user_info['is_admin'] || $modSettings['topic_move_any']) |
|
| 584 | - $context['can_move_any'] = true; |
|
| 585 | - else |
|
| 612 | + if ($user_info['is_admin'] || $modSettings['topic_move_any']) { |
|
| 613 | + $context['can_move_any'] = true; |
|
| 614 | + } else |
|
| 586 | 615 | { |
| 587 | 616 | // We'll use this in a minute |
| 588 | 617 | $boards_allowed = boardsAllowedTo('post_new'); |
@@ -609,11 +638,13 @@ discard block |
||
| 609 | 638 | } |
| 610 | 639 | |
| 611 | 640 | // Can we use quick moderation checkboxes? |
| 612 | - if ($options['display_quick_mod'] == 1) |
|
| 613 | - $context['can_quick_mod'] = $context['user']['is_logged'] || $context['can_approve'] || $context['can_remove'] || $context['can_lock'] || $context['can_sticky'] || $context['can_move'] || $context['can_merge'] || $context['can_restore']; |
|
| 641 | + if ($options['display_quick_mod'] == 1) { |
|
| 642 | + $context['can_quick_mod'] = $context['user']['is_logged'] || $context['can_approve'] || $context['can_remove'] || $context['can_lock'] || $context['can_sticky'] || $context['can_move'] || $context['can_merge'] || $context['can_restore']; |
|
| 643 | + } |
|
| 614 | 644 | // Or the icons? |
| 615 | - else |
|
| 616 | - $context['can_quick_mod'] = $context['can_remove'] || $context['can_lock'] || $context['can_sticky'] || $context['can_move']; |
|
| 645 | + else { |
|
| 646 | + $context['can_quick_mod'] = $context['can_remove'] || $context['can_lock'] || $context['can_sticky'] || $context['can_move']; |
|
| 647 | + } |
|
| 617 | 648 | } |
| 618 | 649 | |
| 619 | 650 | if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] == 1) |
@@ -647,13 +678,15 @@ discard block |
||
| 647 | 678 | ); |
| 648 | 679 | |
| 649 | 680 | // We've seen all these boards now! |
| 650 | - foreach ($board_info['parent_boards'] as $k => $dummy) |
|
| 651 | - if (isset($_SESSION['topicseen_cache'][$k])) |
|
| 681 | + foreach ($board_info['parent_boards'] as $k => $dummy) { |
|
| 682 | + if (isset($_SESSION['topicseen_cache'][$k])) |
|
| 652 | 683 | unset($_SESSION['topicseen_cache'][$k]); |
| 684 | + } |
|
| 653 | 685 | } |
| 654 | 686 | |
| 655 | - if (isset($_SESSION['topicseen_cache'][$board])) |
|
| 656 | - unset($_SESSION['topicseen_cache'][$board]); |
|
| 687 | + if (isset($_SESSION['topicseen_cache'][$board])) { |
|
| 688 | + unset($_SESSION['topicseen_cache'][$board]); |
|
| 689 | + } |
|
| 657 | 690 | |
| 658 | 691 | $request = $smcFunc['db_query']('', ' |
| 659 | 692 | SELECT id_topic, id_board, sent |
@@ -674,8 +707,9 @@ discard block |
||
| 674 | 707 | $context['is_marked_notify'] = true; |
| 675 | 708 | $board_sent = $row['sent']; |
| 676 | 709 | } |
| 677 | - if (!empty($row['id_topic'])) |
|
| 678 | - $context['topics'][$row['id_topic']]['is_watched'] = true; |
|
| 710 | + if (!empty($row['id_topic'])) { |
|
| 711 | + $context['topics'][$row['id_topic']]['is_watched'] = true; |
|
| 712 | + } |
|
| 679 | 713 | } |
| 680 | 714 | $smcFunc['db_free_result']($request); |
| 681 | 715 | |
@@ -699,8 +733,7 @@ discard block |
||
| 699 | 733 | $pref = !empty($pref[$user_info['id']]) ? $pref[$user_info['id']] : array(); |
| 700 | 734 | $pref = isset($pref['board_notify_' . $board]) ? $pref['board_notify_' . $board] : (!empty($pref['board_notify']) ? $pref['board_notify'] : 0); |
| 701 | 735 | $context['board_notification_mode'] = !$context['is_marked_notify'] ? 1 : ($pref & 0x02 ? 3 : ($pref & 0x01 ? 2 : 1)); |
| 702 | - } |
|
| 703 | - else |
|
| 736 | + } else |
|
| 704 | 737 | { |
| 705 | 738 | $context['is_marked_notify'] = false; |
| 706 | 739 | $context['board_notification_mode'] = 1; |
@@ -713,23 +746,27 @@ discard block |
||
| 713 | 746 | $context['becomesUnapproved'] = !empty($_SESSION['becomesUnapproved']) ? true : false; |
| 714 | 747 | |
| 715 | 748 | // Don't want to show this forever... |
| 716 | - if ($context['becomesUnapproved']) |
|
| 717 | - unset($_SESSION['becomesUnapproved']); |
|
| 749 | + if ($context['becomesUnapproved']) { |
|
| 750 | + unset($_SESSION['becomesUnapproved']); |
|
| 751 | + } |
|
| 718 | 752 | |
| 719 | 753 | // Build the message index button array. |
| 720 | 754 | $context['normal_buttons'] = array(); |
| 721 | 755 | |
| 722 | - if ($context['can_post_new']) |
|
| 723 | - $context['normal_buttons']['new_topic'] = array('text' => 'new_topic', 'image' => 'new_topic.png', 'lang' => true, 'url' => $scripturl . '?action=post;board=' . $context['current_board'] . '.0', 'active' => true); |
|
| 756 | + if ($context['can_post_new']) { |
|
| 757 | + $context['normal_buttons']['new_topic'] = array('text' => 'new_topic', 'image' => 'new_topic.png', 'lang' => true, 'url' => $scripturl . '?action=post;board=' . $context['current_board'] . '.0', 'active' => true); |
|
| 758 | + } |
|
| 724 | 759 | |
| 725 | - if ($context['can_post_poll']) |
|
| 726 | - $context['normal_buttons']['post_poll'] = array('text' => 'new_poll', 'image' => 'new_poll.png', 'lang' => true, 'url' => $scripturl . '?action=post;board=' . $context['current_board'] . '.0;poll'); |
|
| 760 | + if ($context['can_post_poll']) { |
|
| 761 | + $context['normal_buttons']['post_poll'] = array('text' => 'new_poll', 'image' => 'new_poll.png', 'lang' => true, 'url' => $scripturl . '?action=post;board=' . $context['current_board'] . '.0;poll'); |
|
| 762 | + } |
|
| 727 | 763 | |
| 728 | - if (!$context['user']['is_logged']) |
|
| 729 | - $context['normal_buttons']['markread'] = array('text' => 'mark_read_short', 'image' => 'markread.png', 'lang' => true, 'custom' => 'data-confirm="' . $txt['are_sure_mark_read'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=markasread;sa=board;board=' . $context['current_board'] . '.0;' . $context['session_var'] . '=' . $context['session_id']); |
|
| 764 | + if (!$context['user']['is_logged']) { |
|
| 765 | + $context['normal_buttons']['markread'] = array('text' => 'mark_read_short', 'image' => 'markread.png', 'lang' => true, 'custom' => 'data-confirm="' . $txt['are_sure_mark_read'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=markasread;sa=board;board=' . $context['current_board'] . '.0;' . $context['session_var'] . '=' . $context['session_id']); |
|
| 766 | + } |
|
| 730 | 767 | |
| 731 | - if ($context['can_mark_notify']) |
|
| 732 | - $context['normal_buttons']['notify'] = array( |
|
| 768 | + if ($context['can_mark_notify']) { |
|
| 769 | + $context['normal_buttons']['notify'] = array( |
|
| 733 | 770 | 'lang' => true, |
| 734 | 771 | 'text' => 'notify_board_' . $context['board_notification_mode'], |
| 735 | 772 | 'sub_buttons' => array( |
@@ -747,6 +784,7 @@ discard block |
||
| 747 | 784 | ), |
| 748 | 785 | ), |
| 749 | 786 | ); |
| 787 | + } |
|
| 750 | 788 | |
| 751 | 789 | // Javascript for inline editing. |
| 752 | 790 | loadJavaScriptFile('topic.js', array('defer' => false), 'smf_topic'); |
@@ -768,18 +806,21 @@ discard block |
||
| 768 | 806 | checkSession('request'); |
| 769 | 807 | |
| 770 | 808 | // Lets go straight to the restore area. |
| 771 | - if (isset($_REQUEST['qaction']) && $_REQUEST['qaction'] == 'restore' && !empty($_REQUEST['topics'])) |
|
| 772 | - redirectexit('action=restoretopic;topics=' . implode(',', $_REQUEST['topics']) . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 809 | + if (isset($_REQUEST['qaction']) && $_REQUEST['qaction'] == 'restore' && !empty($_REQUEST['topics'])) { |
|
| 810 | + redirectexit('action=restoretopic;topics=' . implode(',', $_REQUEST['topics']) . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 811 | + } |
|
| 773 | 812 | |
| 774 | - if (isset($_SESSION['topicseen_cache'])) |
|
| 775 | - $_SESSION['topicseen_cache'] = array(); |
|
| 813 | + if (isset($_SESSION['topicseen_cache'])) { |
|
| 814 | + $_SESSION['topicseen_cache'] = array(); |
|
| 815 | + } |
|
| 776 | 816 | |
| 777 | 817 | // This is going to be needed to send off the notifications and for updateLastMessages(). |
| 778 | 818 | require_once($sourcedir . '/Subs-Post.php'); |
| 779 | 819 | |
| 780 | 820 | // Remember the last board they moved things to. |
| 781 | - if (isset($_REQUEST['move_to'])) |
|
| 782 | - $_SESSION['move_to_topic'] = $_REQUEST['move_to']; |
|
| 821 | + if (isset($_REQUEST['move_to'])) { |
|
| 822 | + $_SESSION['move_to_topic'] = $_REQUEST['move_to']; |
|
| 823 | + } |
|
| 783 | 824 | |
| 784 | 825 | // Only a few possible actions. |
| 785 | 826 | $possibleActions = array(); |
@@ -799,8 +840,7 @@ discard block |
||
| 799 | 840 | ); |
| 800 | 841 | |
| 801 | 842 | $redirect_url = 'board=' . $board . '.' . $_REQUEST['start']; |
| 802 | - } |
|
| 803 | - else |
|
| 843 | + } else |
|
| 804 | 844 | { |
| 805 | 845 | /** |
| 806 | 846 | * @todo Ugly. There's no getting around this, is there? |
@@ -818,8 +858,7 @@ discard block |
||
| 818 | 858 | if (!empty($board)) |
| 819 | 859 | { |
| 820 | 860 | $boards_can['post_new'] = array_diff(boardsAllowedTo('post_new'), array($board)); |
| 821 | - } |
|
| 822 | - else |
|
| 861 | + } else |
|
| 823 | 862 | { |
| 824 | 863 | $boards_can['post_new'] = boardsAllowedTo('post_new'); |
| 825 | 864 | } |
@@ -830,55 +869,67 @@ discard block |
||
| 830 | 869 | } |
| 831 | 870 | } |
| 832 | 871 | |
| 833 | - if (!$user_info['is_guest']) |
|
| 834 | - $possibleActions[] = 'markread'; |
|
| 835 | - if (!empty($boards_can['make_sticky'])) |
|
| 836 | - $possibleActions[] = 'sticky'; |
|
| 837 | - if (!empty($boards_can['move_any']) || !empty($boards_can['move_own'])) |
|
| 838 | - $possibleActions[] = 'move'; |
|
| 839 | - if (!empty($boards_can['remove_any']) || !empty($boards_can['remove_own'])) |
|
| 840 | - $possibleActions[] = 'remove'; |
|
| 841 | - if (!empty($boards_can['lock_any']) || !empty($boards_can['lock_own'])) |
|
| 842 | - $possibleActions[] = 'lock'; |
|
| 843 | - if (!empty($boards_can['merge_any'])) |
|
| 844 | - $possibleActions[] = 'merge'; |
|
| 845 | - if (!empty($boards_can['approve_posts'])) |
|
| 846 | - $possibleActions[] = 'approve'; |
|
| 872 | + if (!$user_info['is_guest']) { |
|
| 873 | + $possibleActions[] = 'markread'; |
|
| 874 | + } |
|
| 875 | + if (!empty($boards_can['make_sticky'])) { |
|
| 876 | + $possibleActions[] = 'sticky'; |
|
| 877 | + } |
|
| 878 | + if (!empty($boards_can['move_any']) || !empty($boards_can['move_own'])) { |
|
| 879 | + $possibleActions[] = 'move'; |
|
| 880 | + } |
|
| 881 | + if (!empty($boards_can['remove_any']) || !empty($boards_can['remove_own'])) { |
|
| 882 | + $possibleActions[] = 'remove'; |
|
| 883 | + } |
|
| 884 | + if (!empty($boards_can['lock_any']) || !empty($boards_can['lock_own'])) { |
|
| 885 | + $possibleActions[] = 'lock'; |
|
| 886 | + } |
|
| 887 | + if (!empty($boards_can['merge_any'])) { |
|
| 888 | + $possibleActions[] = 'merge'; |
|
| 889 | + } |
|
| 890 | + if (!empty($boards_can['approve_posts'])) { |
|
| 891 | + $possibleActions[] = 'approve'; |
|
| 892 | + } |
|
| 847 | 893 | |
| 848 | 894 | // Two methods: $_REQUEST['actions'] (id_topic => action), and $_REQUEST['topics'] and $_REQUEST['qaction']. |
| 849 | 895 | // (if action is 'move', $_REQUEST['move_to'] or $_REQUEST['move_tos'][$topic] is used.) |
| 850 | 896 | if (!empty($_REQUEST['topics'])) |
| 851 | 897 | { |
| 852 | 898 | // If the action isn't valid, just quit now. |
| 853 | - if (empty($_REQUEST['qaction']) || !in_array($_REQUEST['qaction'], $possibleActions)) |
|
| 854 | - redirectexit($redirect_url); |
|
| 899 | + if (empty($_REQUEST['qaction']) || !in_array($_REQUEST['qaction'], $possibleActions)) { |
|
| 900 | + redirectexit($redirect_url); |
|
| 901 | + } |
|
| 855 | 902 | |
| 856 | 903 | // Merge requires all topics as one parameter and can be done at once. |
| 857 | 904 | if ($_REQUEST['qaction'] == 'merge') |
| 858 | 905 | { |
| 859 | 906 | // Merge requires at least two topics. |
| 860 | - if (empty($_REQUEST['topics']) || count($_REQUEST['topics']) < 2) |
|
| 861 | - redirectexit($redirect_url); |
|
| 907 | + if (empty($_REQUEST['topics']) || count($_REQUEST['topics']) < 2) { |
|
| 908 | + redirectexit($redirect_url); |
|
| 909 | + } |
|
| 862 | 910 | |
| 863 | 911 | require_once($sourcedir . '/SplitTopics.php'); |
| 864 | 912 | return MergeExecute($_REQUEST['topics']); |
| 865 | 913 | } |
| 866 | 914 | |
| 867 | 915 | // Just convert to the other method, to make it easier. |
| 868 | - foreach ($_REQUEST['topics'] as $topic) |
|
| 869 | - $_REQUEST['actions'][(int) $topic] = $_REQUEST['qaction']; |
|
| 916 | + foreach ($_REQUEST['topics'] as $topic) { |
|
| 917 | + $_REQUEST['actions'][(int) $topic] = $_REQUEST['qaction']; |
|
| 918 | + } |
|
| 870 | 919 | } |
| 871 | 920 | |
| 872 | 921 | // Weird... how'd you get here? |
| 873 | - if (empty($_REQUEST['actions'])) |
|
| 874 | - redirectexit($redirect_url); |
|
| 922 | + if (empty($_REQUEST['actions'])) { |
|
| 923 | + redirectexit($redirect_url); |
|
| 924 | + } |
|
| 875 | 925 | |
| 876 | 926 | // Validate each action. |
| 877 | 927 | $temp = array(); |
| 878 | 928 | foreach ($_REQUEST['actions'] as $topic => $action) |
| 879 | 929 | { |
| 880 | - if (in_array($action, $possibleActions)) |
|
| 881 | - $temp[(int) $topic] = $action; |
|
| 930 | + if (in_array($action, $possibleActions)) { |
|
| 931 | + $temp[(int) $topic] = $action; |
|
| 932 | + } |
|
| 882 | 933 | } |
| 883 | 934 | $_REQUEST['actions'] = $temp; |
| 884 | 935 | |
@@ -899,27 +950,31 @@ discard block |
||
| 899 | 950 | { |
| 900 | 951 | if (!empty($board)) |
| 901 | 952 | { |
| 902 | - if ($row['id_board'] != $board || ($modSettings['postmod_active'] && !$row['approved'] && !allowedTo('approve_posts'))) |
|
| 903 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 904 | - } |
|
| 905 | - else |
|
| 953 | + if ($row['id_board'] != $board || ($modSettings['postmod_active'] && !$row['approved'] && !allowedTo('approve_posts'))) { |
|
| 954 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 955 | + } |
|
| 956 | + } else |
|
| 906 | 957 | { |
| 907 | 958 | // Don't allow them to act on unapproved posts they can't see... |
| 908 | - if ($modSettings['postmod_active'] && !$row['approved'] && !in_array(0, $boards_can['approve_posts']) && !in_array($row['id_board'], $boards_can['approve_posts'])) |
|
| 909 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 959 | + if ($modSettings['postmod_active'] && !$row['approved'] && !in_array(0, $boards_can['approve_posts']) && !in_array($row['id_board'], $boards_can['approve_posts'])) { |
|
| 960 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 961 | + } |
|
| 910 | 962 | // Goodness, this is fun. We need to validate the action. |
| 911 | - elseif ($_REQUEST['actions'][$row['id_topic']] == 'sticky' && !in_array(0, $boards_can['make_sticky']) && !in_array($row['id_board'], $boards_can['make_sticky'])) |
|
| 912 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 913 | - elseif ($_REQUEST['actions'][$row['id_topic']] == 'move' && !in_array(0, $boards_can['move_any']) && !in_array($row['id_board'], $boards_can['move_any']) && ($row['id_member_started'] != $user_info['id'] || (!in_array(0, $boards_can['move_own']) && !in_array($row['id_board'], $boards_can['move_own'])))) |
|
| 914 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 915 | - elseif ($_REQUEST['actions'][$row['id_topic']] == 'remove' && !in_array(0, $boards_can['remove_any']) && !in_array($row['id_board'], $boards_can['remove_any']) && ($row['id_member_started'] != $user_info['id'] || (!in_array(0, $boards_can['remove_own']) && !in_array($row['id_board'], $boards_can['remove_own'])))) |
|
| 916 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 963 | + elseif ($_REQUEST['actions'][$row['id_topic']] == 'sticky' && !in_array(0, $boards_can['make_sticky']) && !in_array($row['id_board'], $boards_can['make_sticky'])) { |
|
| 964 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 965 | + } elseif ($_REQUEST['actions'][$row['id_topic']] == 'move' && !in_array(0, $boards_can['move_any']) && !in_array($row['id_board'], $boards_can['move_any']) && ($row['id_member_started'] != $user_info['id'] || (!in_array(0, $boards_can['move_own']) && !in_array($row['id_board'], $boards_can['move_own'])))) { |
|
| 966 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 967 | + } elseif ($_REQUEST['actions'][$row['id_topic']] == 'remove' && !in_array(0, $boards_can['remove_any']) && !in_array($row['id_board'], $boards_can['remove_any']) && ($row['id_member_started'] != $user_info['id'] || (!in_array(0, $boards_can['remove_own']) && !in_array($row['id_board'], $boards_can['remove_own'])))) { |
|
| 968 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 969 | + } |
|
| 917 | 970 | // @todo $locked is not set, what are you trying to do? (taking the change it is supposed to be $row['locked']) |
| 918 | - elseif ($_REQUEST['actions'][$row['id_topic']] == 'lock' && !in_array(0, $boards_can['lock_any']) && !in_array($row['id_board'], $boards_can['lock_any']) && ($row['id_member_started'] != $user_info['id'] || $row['locked'] == 1 || (!in_array(0, $boards_can['lock_own']) && !in_array($row['id_board'], $boards_can['lock_own'])))) |
|
| 919 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 971 | + elseif ($_REQUEST['actions'][$row['id_topic']] == 'lock' && !in_array(0, $boards_can['lock_any']) && !in_array($row['id_board'], $boards_can['lock_any']) && ($row['id_member_started'] != $user_info['id'] || $row['locked'] == 1 || (!in_array(0, $boards_can['lock_own']) && !in_array($row['id_board'], $boards_can['lock_own'])))) { |
|
| 972 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 973 | + } |
|
| 920 | 974 | // If the topic is approved then you need permission to approve the posts within. |
| 921 | - elseif ($_REQUEST['actions'][$row['id_topic']] == 'approve' && (!$row['unapproved_posts'] || (!in_array(0, $boards_can['approve_posts']) && !in_array($row['id_board'], $boards_can['approve_posts'])))) |
|
| 922 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 975 | + elseif ($_REQUEST['actions'][$row['id_topic']] == 'approve' && (!$row['unapproved_posts'] || (!in_array(0, $boards_can['approve_posts']) && !in_array($row['id_board'], $boards_can['approve_posts'])))) { |
|
| 976 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 977 | + } |
|
| 923 | 978 | } |
| 924 | 979 | } |
| 925 | 980 | $smcFunc['db_free_result']($request); |
@@ -937,11 +992,11 @@ discard block |
||
| 937 | 992 | { |
| 938 | 993 | $topic = (int) $topic; |
| 939 | 994 | |
| 940 | - if ($action == 'markread') |
|
| 941 | - $markCache[] = $topic; |
|
| 942 | - elseif ($action == 'sticky') |
|
| 943 | - $stickyCache[] = $topic; |
|
| 944 | - elseif ($action == 'move') |
|
| 995 | + if ($action == 'markread') { |
|
| 996 | + $markCache[] = $topic; |
|
| 997 | + } elseif ($action == 'sticky') { |
|
| 998 | + $stickyCache[] = $topic; |
|
| 999 | + } elseif ($action == 'move') |
|
| 945 | 1000 | { |
| 946 | 1001 | require_once($sourcedir . '/MoveTopic.php'); |
| 947 | 1002 | moveTopicConcurrence(); |
@@ -949,23 +1004,25 @@ discard block |
||
| 949 | 1004 | // $moveCache[0] is the topic, $moveCache[1] is the board to move to. |
| 950 | 1005 | $moveCache[1][$topic] = (int) (isset($_REQUEST['move_tos'][$topic]) ? $_REQUEST['move_tos'][$topic] : $_REQUEST['move_to']); |
| 951 | 1006 | |
| 952 | - if (empty($moveCache[1][$topic])) |
|
| 953 | - continue; |
|
| 1007 | + if (empty($moveCache[1][$topic])) { |
|
| 1008 | + continue; |
|
| 1009 | + } |
|
| 954 | 1010 | |
| 955 | 1011 | $moveCache[0][] = $topic; |
| 1012 | + } elseif ($action == 'remove') { |
|
| 1013 | + $removeCache[] = $topic; |
|
| 1014 | + } elseif ($action == 'lock') { |
|
| 1015 | + $lockCache[] = $topic; |
|
| 1016 | + } elseif ($action == 'approve') { |
|
| 1017 | + $approveCache[] = $topic; |
|
| 956 | 1018 | } |
| 957 | - elseif ($action == 'remove') |
|
| 958 | - $removeCache[] = $topic; |
|
| 959 | - elseif ($action == 'lock') |
|
| 960 | - $lockCache[] = $topic; |
|
| 961 | - elseif ($action == 'approve') |
|
| 962 | - $approveCache[] = $topic; |
|
| 963 | 1019 | } |
| 964 | 1020 | |
| 965 | - if (empty($board)) |
|
| 966 | - $affectedBoards = array(); |
|
| 967 | - else |
|
| 968 | - $affectedBoards = array($board => array(0, 0)); |
|
| 1021 | + if (empty($board)) { |
|
| 1022 | + $affectedBoards = array(); |
|
| 1023 | + } else { |
|
| 1024 | + $affectedBoards = array($board => array(0, 0)); |
|
| 1025 | + } |
|
| 969 | 1026 | |
| 970 | 1027 | // Do all the stickies... |
| 971 | 1028 | if (!empty($stickyCache)) |
@@ -1025,14 +1082,16 @@ discard block |
||
| 1025 | 1082 | { |
| 1026 | 1083 | $to = $moveCache[1][$row['id_topic']]; |
| 1027 | 1084 | |
| 1028 | - if (empty($to)) |
|
| 1029 | - continue; |
|
| 1085 | + if (empty($to)) { |
|
| 1086 | + continue; |
|
| 1087 | + } |
|
| 1030 | 1088 | |
| 1031 | 1089 | // Does this topic's board count the posts or not? |
| 1032 | 1090 | $countPosts[$row['id_topic']] = empty($row['count_posts']); |
| 1033 | 1091 | |
| 1034 | - if (!isset($moveTos[$to])) |
|
| 1035 | - $moveTos[$to] = array(); |
|
| 1092 | + if (!isset($moveTos[$to])) { |
|
| 1093 | + $moveTos[$to] = array(); |
|
| 1094 | + } |
|
| 1036 | 1095 | |
| 1037 | 1096 | $moveTos[$to][] = $row['id_topic']; |
| 1038 | 1097 | |
@@ -1046,8 +1105,9 @@ discard block |
||
| 1046 | 1105 | require_once($sourcedir . '/MoveTopic.php'); |
| 1047 | 1106 | |
| 1048 | 1107 | // Do the actual moves... |
| 1049 | - foreach ($moveTos as $to => $topics) |
|
| 1050 | - moveTopics($topics, $to); |
|
| 1108 | + foreach ($moveTos as $to => $topics) { |
|
| 1109 | + moveTopics($topics, $to); |
|
| 1110 | + } |
|
| 1051 | 1111 | |
| 1052 | 1112 | // Does the post counts need to be updated? |
| 1053 | 1113 | if (!empty($moveTos)) |
@@ -1096,20 +1156,23 @@ discard block |
||
| 1096 | 1156 | |
| 1097 | 1157 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1098 | 1158 | { |
| 1099 | - if (!isset($members[$row['id_member']])) |
|
| 1100 | - $members[$row['id_member']] = 0; |
|
| 1159 | + if (!isset($members[$row['id_member']])) { |
|
| 1160 | + $members[$row['id_member']] = 0; |
|
| 1161 | + } |
|
| 1101 | 1162 | |
| 1102 | - if ($topicRecounts[$row['id_topic']] === '+') |
|
| 1103 | - $members[$row['id_member']] += 1; |
|
| 1104 | - else |
|
| 1105 | - $members[$row['id_member']] -= 1; |
|
| 1163 | + if ($topicRecounts[$row['id_topic']] === '+') { |
|
| 1164 | + $members[$row['id_member']] += 1; |
|
| 1165 | + } else { |
|
| 1166 | + $members[$row['id_member']] -= 1; |
|
| 1167 | + } |
|
| 1106 | 1168 | } |
| 1107 | 1169 | |
| 1108 | 1170 | $smcFunc['db_free_result']($request); |
| 1109 | 1171 | |
| 1110 | 1172 | // And now update them member's post counts |
| 1111 | - foreach ($members as $id_member => $post_adj) |
|
| 1112 | - updateMemberData($id_member, array('posts' => 'posts + ' . $post_adj)); |
|
| 1173 | + foreach ($members as $id_member => $post_adj) { |
|
| 1174 | + updateMemberData($id_member, array('posts' => 'posts + ' . $post_adj)); |
|
| 1175 | + } |
|
| 1113 | 1176 | |
| 1114 | 1177 | } |
| 1115 | 1178 | } |
@@ -1189,8 +1252,9 @@ discard block |
||
| 1189 | 1252 | approveTopics($approveCache); |
| 1190 | 1253 | |
| 1191 | 1254 | // Time for some logging! |
| 1192 | - foreach ($approveCache as $topic) |
|
| 1193 | - logAction('approve_topic', array('topic' => $topic, 'member' => $approveCacheMembers[$topic])); |
|
| 1255 | + foreach ($approveCache as $topic) { |
|
| 1256 | + logAction('approve_topic', array('topic' => $topic, 'member' => $approveCacheMembers[$topic])); |
|
| 1257 | + } |
|
| 1194 | 1258 | } |
| 1195 | 1259 | } |
| 1196 | 1260 | |
@@ -1225,8 +1289,7 @@ discard block |
||
| 1225 | 1289 | $lockStatus[$row['id_topic']] = empty($row['locked']); |
| 1226 | 1290 | } |
| 1227 | 1291 | $smcFunc['db_free_result']($result); |
| 1228 | - } |
|
| 1229 | - else |
|
| 1292 | + } else |
|
| 1230 | 1293 | { |
| 1231 | 1294 | $result = $smcFunc['db_query']('', ' |
| 1232 | 1295 | SELECT id_topic, locked, id_board |
@@ -1276,13 +1339,15 @@ discard block |
||
| 1276 | 1339 | ) |
| 1277 | 1340 | ); |
| 1278 | 1341 | $logged_topics = array(); |
| 1279 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1280 | - $logged_topics[$row['id_topic']] = $row['unwatched']; |
|
| 1342 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1343 | + $logged_topics[$row['id_topic']] = $row['unwatched']; |
|
| 1344 | + } |
|
| 1281 | 1345 | $smcFunc['db_free_result']($request); |
| 1282 | 1346 | |
| 1283 | 1347 | $markArray = array(); |
| 1284 | - foreach ($markCache as $topic) |
|
| 1285 | - $markArray[] = array($modSettings['maxMsgID'], $user_info['id'], $topic, (isset($logged_topics[$topic]) ? $logged_topics[$topic] : 0)); |
|
| 1348 | + foreach ($markCache as $topic) { |
|
| 1349 | + $markArray[] = array($modSettings['maxMsgID'], $user_info['id'], $topic, (isset($logged_topics[$topic]) ? $logged_topics[$topic] : 0)); |
|
| 1350 | + } |
|
| 1286 | 1351 | |
| 1287 | 1352 | $smcFunc['db_insert']('replace', |
| 1288 | 1353 | '{db_prefix}log_topics', |
@@ -1295,8 +1360,9 @@ discard block |
||
| 1295 | 1360 | foreach ($moveCache as $topic) |
| 1296 | 1361 | { |
| 1297 | 1362 | // Didn't actually move anything! |
| 1298 | - if (!isset($topic[0])) |
|
| 1299 | - break; |
|
| 1363 | + if (!isset($topic[0])) { |
|
| 1364 | + break; |
|
| 1365 | + } |
|
| 1300 | 1366 | |
| 1301 | 1367 | logAction('move', array('topic' => $topic[0], 'board_from' => $topic[1], 'board_to' => $topic[2])); |
| 1302 | 1368 | sendNotifications($topic[0], 'move'); |
@@ -1318,8 +1384,9 @@ discard block |
||
| 1318 | 1384 | 'calendar_updated' => time(), |
| 1319 | 1385 | )); |
| 1320 | 1386 | |
| 1321 | - if (!empty($affectedBoards)) |
|
| 1322 | - updateLastMessages(array_keys($affectedBoards)); |
|
| 1387 | + if (!empty($affectedBoards)) { |
|
| 1388 | + updateLastMessages(array_keys($affectedBoards)); |
|
| 1389 | + } |
|
| 1323 | 1390 | |
| 1324 | 1391 | redirectexit($redirect_url); |
| 1325 | 1392 | } |