@@ -12,8 +12,9 @@ discard block |
||
12 | 12 | * @version 2.1 Beta 3 |
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'); |
@@ -16,8 +16,9 @@ discard block |
||
16 | 16 | * @version 2.1 Beta 3 |
17 | 17 | */ |
18 | 18 | |
19 | -if (!defined('SMF')) |
|
19 | +if (!defined('SMF')) { |
|
20 | 20 | die('No direct access...'); |
21 | +} |
|
21 | 22 | |
22 | 23 | /** |
23 | 24 | * Reads a .tar.gz file, filename, in and extracts file(s) from it. |
@@ -67,47 +68,53 @@ discard block |
||
67 | 68 | loadLanguage('Packages'); |
68 | 69 | |
69 | 70 | // This function sorta needs gzinflate! |
70 | - if (!function_exists('gzinflate')) |
|
71 | - fatal_lang_error('package_no_zlib', 'critical'); |
|
71 | + if (!function_exists('gzinflate')) { |
|
72 | + fatal_lang_error('package_no_zlib', 'critical'); |
|
73 | + } |
|
72 | 74 | |
73 | 75 | if (substr($gzfilename, 0, 7) == 'http://' || substr($gzfilename, 0, 8) == 'https://') |
74 | 76 | { |
75 | 77 | $data = fetch_web_data($gzfilename); |
76 | 78 | |
77 | - if ($data === false) |
|
78 | - return false; |
|
79 | - } |
|
80 | - else |
|
79 | + if ($data === false) { |
|
80 | + return false; |
|
81 | + } |
|
82 | + } else |
|
81 | 83 | { |
82 | 84 | $data = @file_get_contents($gzfilename); |
83 | 85 | |
84 | - if ($data === false) |
|
85 | - return false; |
|
86 | + if ($data === false) { |
|
87 | + return false; |
|
88 | + } |
|
86 | 89 | } |
87 | 90 | |
88 | 91 | umask(0); |
89 | - if (!$single_file && $destination !== null && !file_exists($destination)) |
|
90 | - mktree($destination, 0777); |
|
92 | + if (!$single_file && $destination !== null && !file_exists($destination)) { |
|
93 | + mktree($destination, 0777); |
|
94 | + } |
|
91 | 95 | |
92 | 96 | // No signature? |
93 | - if (strlen($data) < 2) |
|
94 | - return false; |
|
97 | + if (strlen($data) < 2) { |
|
98 | + return false; |
|
99 | + } |
|
95 | 100 | |
96 | 101 | $id = unpack('H2a/H2b', substr($data, 0, 2)); |
97 | 102 | if (strtolower($id['a'] . $id['b']) != '1f8b') |
98 | 103 | { |
99 | 104 | // Okay, this ain't no tar.gz, but maybe it's a zip file. |
100 | - if (substr($data, 0, 2) == 'PK') |
|
101 | - return read_zip_file($gzfilename, $destination, $single_file, $overwrite, $files_to_extract); |
|
102 | - else |
|
103 | - return false; |
|
105 | + if (substr($data, 0, 2) == 'PK') { |
|
106 | + return read_zip_file($gzfilename, $destination, $single_file, $overwrite, $files_to_extract); |
|
107 | + } else { |
|
108 | + return false; |
|
109 | + } |
|
104 | 110 | } |
105 | 111 | |
106 | 112 | $flags = unpack('Ct/Cf', substr($data, 2, 2)); |
107 | 113 | |
108 | 114 | // Not deflate! |
109 | - if ($flags['t'] != 8) |
|
110 | - return false; |
|
115 | + if ($flags['t'] != 8) { |
|
116 | + return false; |
|
117 | + } |
|
111 | 118 | $flags = $flags['f']; |
112 | 119 | |
113 | 120 | $offset = 10; |
@@ -117,18 +124,21 @@ discard block |
||
117 | 124 | // @todo Might be mussed. |
118 | 125 | if ($flags & 12) |
119 | 126 | { |
120 | - while ($flags & 8 && $data{$offset++} != "\0") |
|
121 | - continue; |
|
122 | - while ($flags & 4 && $data{$offset++} != "\0") |
|
123 | - continue; |
|
127 | + while ($flags & 8 && $data{$offset++} != "\0") { |
|
128 | + continue; |
|
129 | + } |
|
130 | + while ($flags & 4 && $data{$offset++} != "\0") { |
|
131 | + continue; |
|
132 | + } |
|
124 | 133 | } |
125 | 134 | |
126 | 135 | $crc = unpack('Vcrc32/Visize', substr($data, strlen($data) - 8, 8)); |
127 | 136 | $data = @gzinflate(substr($data, $offset, strlen($data) - 8 - $offset)); |
128 | 137 | |
129 | 138 | // smf_crc32 and crc32 may not return the same results, so we accept either. |
130 | - if ($crc['crc32'] != smf_crc32($data) && $crc['crc32'] != crc32($data)) |
|
131 | - return false; |
|
139 | + if ($crc['crc32'] != smf_crc32($data) && $crc['crc32'] != crc32($data)) { |
|
140 | + return false; |
|
141 | + } |
|
132 | 142 | |
133 | 143 | $blocks = strlen($data) / 512 - 1; |
134 | 144 | $offset = 0; |
@@ -149,83 +159,98 @@ discard block |
||
149 | 159 | |
150 | 160 | foreach ($current as $k => $v) |
151 | 161 | { |
152 | - if (in_array($k, $octdec)) |
|
153 | - $current[$k] = octdec(trim($v)); |
|
154 | - else |
|
155 | - $current[$k] = trim($v); |
|
162 | + if (in_array($k, $octdec)) { |
|
163 | + $current[$k] = octdec(trim($v)); |
|
164 | + } else { |
|
165 | + $current[$k] = trim($v); |
|
166 | + } |
|
156 | 167 | } |
157 | 168 | |
158 | - if ($current['type'] == 5 && substr($current['filename'], -1) != '/') |
|
159 | - $current['filename'] .= '/'; |
|
169 | + if ($current['type'] == 5 && substr($current['filename'], -1) != '/') { |
|
170 | + $current['filename'] .= '/'; |
|
171 | + } |
|
160 | 172 | |
161 | 173 | $checksum = 256; |
162 | - for ($i = 0; $i < 148; $i++) |
|
163 | - $checksum += ord($header{$i}); |
|
164 | - for ($i = 156; $i < 512; $i++) |
|
165 | - $checksum += ord($header{$i}); |
|
174 | + for ($i = 0; $i < 148; $i++) { |
|
175 | + $checksum += ord($header{$i}); |
|
176 | + } |
|
177 | + for ($i = 156; $i < 512; $i++) { |
|
178 | + $checksum += ord($header{$i}); |
|
179 | + } |
|
166 | 180 | |
167 | - if ($current['checksum'] != $checksum) |
|
168 | - break; |
|
181 | + if ($current['checksum'] != $checksum) { |
|
182 | + break; |
|
183 | + } |
|
169 | 184 | |
170 | 185 | $size = ceil($current['size'] / 512); |
171 | 186 | $current['data'] = substr($data, ++$offset << 9, $current['size']); |
172 | 187 | $offset += $size; |
173 | 188 | |
174 | 189 | // Not a directory and doesn't exist already... |
175 | - if (substr($current['filename'], -1, 1) != '/' && !file_exists($destination . '/' . $current['filename'])) |
|
176 | - $write_this = true; |
|
190 | + if (substr($current['filename'], -1, 1) != '/' && !file_exists($destination . '/' . $current['filename'])) { |
|
191 | + $write_this = true; |
|
192 | + } |
|
177 | 193 | // File exists... check if it is newer. |
178 | - elseif (substr($current['filename'], -1, 1) != '/') |
|
179 | - $write_this = $overwrite || filemtime($destination . '/' . $current['filename']) < $current['mtime']; |
|
194 | + elseif (substr($current['filename'], -1, 1) != '/') { |
|
195 | + $write_this = $overwrite || filemtime($destination . '/' . $current['filename']) < $current['mtime']; |
|
196 | + } |
|
180 | 197 | // Folder... create. |
181 | 198 | elseif ($destination !== null && !$single_file) |
182 | 199 | { |
183 | 200 | // Protect from accidental parent directory writing... |
184 | 201 | $current['filename'] = strtr($current['filename'], array('../' => '', '/..' => '')); |
185 | 202 | |
186 | - if (!file_exists($destination . '/' . $current['filename'])) |
|
187 | - mktree($destination . '/' . $current['filename'], 0777); |
|
203 | + if (!file_exists($destination . '/' . $current['filename'])) { |
|
204 | + mktree($destination . '/' . $current['filename'], 0777); |
|
205 | + } |
|
188 | 206 | $write_this = false; |
207 | + } else { |
|
208 | + $write_this = false; |
|
189 | 209 | } |
190 | - else |
|
191 | - $write_this = false; |
|
192 | 210 | |
193 | 211 | if ($write_this && $destination !== null) |
194 | 212 | { |
195 | - if (strpos($current['filename'], '/') !== false && !$single_file) |
|
196 | - mktree($destination . '/' . dirname($current['filename']), 0777); |
|
213 | + if (strpos($current['filename'], '/') !== false && !$single_file) { |
|
214 | + mktree($destination . '/' . dirname($current['filename']), 0777); |
|
215 | + } |
|
197 | 216 | |
198 | 217 | // Is this the file we're looking for? |
199 | - if ($single_file && ($destination == $current['filename'] || $destination == '*/' . basename($current['filename']))) |
|
200 | - return $current['data']; |
|
218 | + if ($single_file && ($destination == $current['filename'] || $destination == '*/' . basename($current['filename']))) { |
|
219 | + return $current['data']; |
|
220 | + } |
|
201 | 221 | // If we're looking for another file, keep going. |
202 | - elseif ($single_file) |
|
203 | - continue; |
|
222 | + elseif ($single_file) { |
|
223 | + continue; |
|
224 | + } |
|
204 | 225 | // Looking for restricted files? |
205 | - elseif ($files_to_extract !== null && !in_array($current['filename'], $files_to_extract)) |
|
206 | - continue; |
|
226 | + elseif ($files_to_extract !== null && !in_array($current['filename'], $files_to_extract)) { |
|
227 | + continue; |
|
228 | + } |
|
207 | 229 | |
208 | 230 | package_put_contents($destination . '/' . $current['filename'], $current['data']); |
209 | 231 | } |
210 | 232 | |
211 | - if (substr($current['filename'], -1, 1) != '/') |
|
212 | - $return[] = array( |
|
233 | + if (substr($current['filename'], -1, 1) != '/') { |
|
234 | + $return[] = array( |
|
213 | 235 | 'filename' => $current['filename'], |
214 | 236 | 'md5' => md5($current['data']), |
215 | 237 | 'preview' => substr($current['data'], 0, 100), |
216 | 238 | 'size' => $current['size'], |
217 | 239 | 'skipped' => false |
218 | 240 | ); |
241 | + } |
|
219 | 242 | } |
220 | 243 | |
221 | - if ($destination !== null && !$single_file) |
|
222 | - package_flush_cache(); |
|
244 | + if ($destination !== null && !$single_file) { |
|
245 | + package_flush_cache(); |
|
246 | + } |
|
223 | 247 | |
224 | - if ($single_file) |
|
225 | - return false; |
|
226 | - else |
|
227 | - return $return; |
|
228 | -} |
|
248 | + if ($single_file) { |
|
249 | + return false; |
|
250 | + } else { |
|
251 | + return $return; |
|
252 | + } |
|
253 | + } |
|
229 | 254 | |
230 | 255 | /** |
231 | 256 | * Extract zip data. A functional copy of {@list read_zip_data()}. |
@@ -254,65 +279,74 @@ discard block |
||
254 | 279 | { |
255 | 280 | $i = $iterator->getSubPathname(); |
256 | 281 | // If this is a file, and it doesn't exist.... happy days! |
257 | - if (substr($i, -1) != '/' && !file_exists($destination . '/' . $i)) |
|
258 | - $write_this = true; |
|
282 | + if (substr($i, -1) != '/' && !file_exists($destination . '/' . $i)) { |
|
283 | + $write_this = true; |
|
284 | + } |
|
259 | 285 | // If the file exists, we may not want to overwrite it. |
260 | - elseif (substr($i, -1) != '/') |
|
261 | - $write_this = $overwrite; |
|
262 | - else |
|
263 | - $write_this = false; |
|
286 | + elseif (substr($i, -1) != '/') { |
|
287 | + $write_this = $overwrite; |
|
288 | + } else { |
|
289 | + $write_this = false; |
|
290 | + } |
|
264 | 291 | |
265 | 292 | // Get the actual compressed data. |
266 | - if (!$file_info->isDir()) |
|
267 | - $file_data = file_get_contents($file_info); |
|
268 | - elseif ($destination !== null && !$single_file) |
|
293 | + if (!$file_info->isDir()) { |
|
294 | + $file_data = file_get_contents($file_info); |
|
295 | + } elseif ($destination !== null && !$single_file) |
|
269 | 296 | { |
270 | 297 | // Folder... create. |
271 | - if (!file_exists($destination . '/' . $i)) |
|
272 | - mktree($destination . '/' . $i, 0777); |
|
298 | + if (!file_exists($destination . '/' . $i)) { |
|
299 | + mktree($destination . '/' . $i, 0777); |
|
300 | + } |
|
273 | 301 | $file_data = null; |
302 | + } else { |
|
303 | + $file_data = null; |
|
274 | 304 | } |
275 | - else |
|
276 | - $file_data = null; |
|
277 | 305 | |
278 | 306 | // Okay! We can write this file, looks good from here... |
279 | 307 | if ($write_this && $destination !== null) |
280 | 308 | { |
281 | - if (!$single_file && !is_dir($destination . '/' . dirname($i))) |
|
282 | - mktree($destination . '/' . dirname($i), 0777); |
|
309 | + if (!$single_file && !is_dir($destination . '/' . dirname($i))) { |
|
310 | + mktree($destination . '/' . dirname($i), 0777); |
|
311 | + } |
|
283 | 312 | |
284 | 313 | // If we're looking for a specific file, and this is it... ka-bam, baby. |
285 | - if ($single_file && ($destination == $i || $destination == '*/' . basename($i))) |
|
286 | - return $file_data; |
|
314 | + if ($single_file && ($destination == $i || $destination == '*/' . basename($i))) { |
|
315 | + return $file_data; |
|
316 | + } |
|
287 | 317 | // Oh? Another file. Fine. You don't like this file, do you? I know how it is. Yeah... just go away. No, don't apologize. I know this file's just not *good enough* for you. |
288 | - elseif ($single_file) |
|
289 | - continue; |
|
318 | + elseif ($single_file) { |
|
319 | + continue; |
|
320 | + } |
|
290 | 321 | // Don't really want this? |
291 | - elseif ($files_to_extract !== null && !in_array($i, $files_to_extract)) |
|
292 | - continue; |
|
322 | + elseif ($files_to_extract !== null && !in_array($i, $files_to_extract)) { |
|
323 | + continue; |
|
324 | + } |
|
293 | 325 | |
294 | 326 | package_put_contents($destination . '/' . $i, $file_data); |
295 | 327 | } |
296 | 328 | |
297 | - if (substr($i, -1, 1) != '/') |
|
298 | - $return[] = array( |
|
329 | + if (substr($i, -1, 1) != '/') { |
|
330 | + $return[] = array( |
|
299 | 331 | 'filename' => $i, |
300 | 332 | 'md5' => md5($file_data), |
301 | 333 | 'preview' => substr($file_data, 0, 100), |
302 | 334 | 'size' => strlen($file_data), |
303 | 335 | 'skipped' => false |
304 | 336 | ); |
337 | + } |
|
305 | 338 | } |
306 | 339 | |
307 | - if ($destination !== null && !$single_file) |
|
308 | - package_flush_cache(); |
|
340 | + if ($destination !== null && !$single_file) { |
|
341 | + package_flush_cache(); |
|
342 | + } |
|
309 | 343 | |
310 | - if ($single_file) |
|
311 | - return false; |
|
312 | - else |
|
313 | - return $return; |
|
314 | - } |
|
315 | - catch (Exception $e) |
|
344 | + if ($single_file) { |
|
345 | + return false; |
|
346 | + } else { |
|
347 | + return $return; |
|
348 | + } |
|
349 | + } catch (Exception $e) |
|
316 | 350 | { |
317 | 351 | return false; |
318 | 352 | } |
@@ -334,13 +368,15 @@ discard block |
||
334 | 368 | function read_zip_data($data, $destination, $single_file = false, $overwrite = false, $files_to_extract = null) |
335 | 369 | { |
336 | 370 | umask(0); |
337 | - if ($destination !== null && !file_exists($destination) && !$single_file) |
|
338 | - mktree($destination, 0777); |
|
371 | + if ($destination !== null && !file_exists($destination) && !$single_file) { |
|
372 | + mktree($destination, 0777); |
|
373 | + } |
|
339 | 374 | |
340 | 375 | // Look for the end of directory signature 0x06054b50 |
341 | 376 | $data_ecr = explode("\x50\x4b\x05\x06", $data); |
342 | - if (!isset($data_ecr[1])) |
|
343 | - return false; |
|
377 | + if (!isset($data_ecr[1])) { |
|
378 | + return false; |
|
379 | + } |
|
344 | 380 | |
345 | 381 | $return = array(); |
346 | 382 | |
@@ -355,8 +391,9 @@ discard block |
||
355 | 391 | array_shift($file_sections); |
356 | 392 | |
357 | 393 | // sections and count from the signature must match or the zip file is bad |
358 | - if (count($file_sections) != $zip_info['files']) |
|
359 | - return false; |
|
394 | + if (count($file_sections) != $zip_info['files']) { |
|
395 | + return false; |
|
396 | + } |
|
360 | 397 | |
361 | 398 | // go though each file in the archive |
362 | 399 | foreach ($file_sections as $data) |
@@ -378,68 +415,79 @@ discard block |
||
378 | 415 | } |
379 | 416 | |
380 | 417 | // If this is a file, and it doesn't exist.... happy days! |
381 | - if (substr($file_info['filename'], -1) != '/' && !file_exists($destination . '/' . $file_info['filename'])) |
|
382 | - $write_this = true; |
|
418 | + if (substr($file_info['filename'], -1) != '/' && !file_exists($destination . '/' . $file_info['filename'])) { |
|
419 | + $write_this = true; |
|
420 | + } |
|
383 | 421 | // If the file exists, we may not want to overwrite it. |
384 | - elseif (substr($file_info['filename'], -1) != '/') |
|
385 | - $write_this = $overwrite; |
|
422 | + elseif (substr($file_info['filename'], -1) != '/') { |
|
423 | + $write_this = $overwrite; |
|
424 | + } |
|
386 | 425 | // This is a directory, so we're gonna want to create it. (probably...) |
387 | 426 | elseif ($destination !== null && !$single_file) |
388 | 427 | { |
389 | 428 | // Just a little accident prevention, don't mind me. |
390 | 429 | $file_info['filename'] = strtr($file_info['filename'], array('../' => '', '/..' => '')); |
391 | 430 | |
392 | - if (!file_exists($destination . '/' . $file_info['filename'])) |
|
393 | - mktree($destination . '/' . $file_info['filename'], 0777); |
|
431 | + if (!file_exists($destination . '/' . $file_info['filename'])) { |
|
432 | + mktree($destination . '/' . $file_info['filename'], 0777); |
|
433 | + } |
|
394 | 434 | $write_this = false; |
435 | + } else { |
|
436 | + $write_this = false; |
|
395 | 437 | } |
396 | - else |
|
397 | - $write_this = false; |
|
398 | 438 | |
399 | 439 | // Get the actual compressed data. |
400 | 440 | $file_info['data'] = substr($data, 26 + $file_info['filename_length'] + $file_info['extrafield_length']); |
401 | 441 | |
402 | 442 | // Only inflate it if we need to ;) |
403 | - if (!empty($file_info['compress_method']) || ($file_info['compressed_size'] != $file_info['size'])) |
|
404 | - $file_info['data'] = gzinflate($file_info['data']); |
|
443 | + if (!empty($file_info['compress_method']) || ($file_info['compressed_size'] != $file_info['size'])) { |
|
444 | + $file_info['data'] = gzinflate($file_info['data']); |
|
445 | + } |
|
405 | 446 | |
406 | 447 | // Okay! We can write this file, looks good from here... |
407 | 448 | if ($write_this && $destination !== null) |
408 | 449 | { |
409 | - if ((strpos($file_info['filename'], '/') !== false && !$single_file) || (!$single_file && !is_dir($file_info['dir']))) |
|
410 | - mktree($file_info['dir'], 0777); |
|
450 | + if ((strpos($file_info['filename'], '/') !== false && !$single_file) || (!$single_file && !is_dir($file_info['dir']))) { |
|
451 | + mktree($file_info['dir'], 0777); |
|
452 | + } |
|
411 | 453 | |
412 | 454 | // If we're looking for a specific file, and this is it... ka-bam, baby. |
413 | - if ($single_file && ($destination == $file_info['filename'] || $destination == '*/' . basename($file_info['filename']))) |
|
414 | - return $file_info['data']; |
|
455 | + if ($single_file && ($destination == $file_info['filename'] || $destination == '*/' . basename($file_info['filename']))) { |
|
456 | + return $file_info['data']; |
|
457 | + } |
|
415 | 458 | // Oh? Another file. Fine. You don't like this file, do you? I know how it is. Yeah... just go away. No, don't apologize. I know this file's just not *good enough* for you. |
416 | - elseif ($single_file) |
|
417 | - continue; |
|
459 | + elseif ($single_file) { |
|
460 | + continue; |
|
461 | + } |
|
418 | 462 | // Don't really want this? |
419 | - elseif ($files_to_extract !== null && !in_array($file_info['filename'], $files_to_extract)) |
|
420 | - continue; |
|
463 | + elseif ($files_to_extract !== null && !in_array($file_info['filename'], $files_to_extract)) { |
|
464 | + continue; |
|
465 | + } |
|
421 | 466 | |
422 | 467 | package_put_contents($destination . '/' . $file_info['filename'], $file_info['data']); |
423 | 468 | } |
424 | 469 | |
425 | - if (substr($file_info['filename'], -1, 1) != '/') |
|
426 | - $return[] = array( |
|
470 | + if (substr($file_info['filename'], -1, 1) != '/') { |
|
471 | + $return[] = array( |
|
427 | 472 | 'filename' => $file_info['filename'], |
428 | 473 | 'md5' => md5($file_info['data']), |
429 | 474 | 'preview' => substr($file_info['data'], 0, 100), |
430 | 475 | 'size' => $file_info['size'], |
431 | 476 | 'skipped' => false |
432 | 477 | ); |
478 | + } |
|
433 | 479 | } |
434 | 480 | |
435 | - if ($destination !== null && !$single_file) |
|
436 | - package_flush_cache(); |
|
481 | + if ($destination !== null && !$single_file) { |
|
482 | + package_flush_cache(); |
|
483 | + } |
|
437 | 484 | |
438 | - if ($single_file) |
|
439 | - return false; |
|
440 | - else |
|
441 | - return $return; |
|
442 | -} |
|
485 | + if ($single_file) { |
|
486 | + return false; |
|
487 | + } else { |
|
488 | + return $return; |
|
489 | + } |
|
490 | + } |
|
443 | 491 | |
444 | 492 | /** |
445 | 493 | * Checks the existence of a remote file since file_exists() does not do remote. |
@@ -451,14 +499,16 @@ discard block |
||
451 | 499 | { |
452 | 500 | $a_url = parse_url($url); |
453 | 501 | |
454 | - if (!isset($a_url['scheme'])) |
|
455 | - return false; |
|
502 | + if (!isset($a_url['scheme'])) { |
|
503 | + return false; |
|
504 | + } |
|
456 | 505 | |
457 | 506 | // Attempt to connect... |
458 | 507 | $temp = ''; |
459 | 508 | $fid = fsockopen($a_url['host'], !isset($a_url['port']) ? 80 : $a_url['port'], $temp, $temp, 8); |
460 | - if (!$fid) |
|
461 | - return false; |
|
509 | + if (!$fid) { |
|
510 | + return false; |
|
511 | + } |
|
462 | 512 | |
463 | 513 | fputs($fid, 'HEAD ' . $a_url['path'] . ' HTTP/1.0' . "\r\n" . 'Host: ' . $a_url['host'] . "\r\n\r\n"); |
464 | 514 | $head = fread($fid, 1024); |
@@ -493,8 +543,9 @@ discard block |
||
493 | 543 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
494 | 544 | { |
495 | 545 | // Already found this? If so don't add it twice! |
496 | - if (in_array($row['package_id'], $found)) |
|
497 | - continue; |
|
546 | + if (in_array($row['package_id'], $found)) { |
|
547 | + continue; |
|
548 | + } |
|
498 | 549 | |
499 | 550 | $found[] = $row['package_id']; |
500 | 551 | |
@@ -529,19 +580,21 @@ discard block |
||
529 | 580 | global $sourcedir, $packagesdir, $smcFunc; |
530 | 581 | |
531 | 582 | // Extract package-info.xml from downloaded file. (*/ is used because it could be in any directory.) |
532 | - if (strpos($gzfilename, 'http://') !== false || strpos($gzfilename, 'https://') !== false) |
|
533 | - $packageInfo = read_tgz_data($gzfilename, 'package-info.xml', true); |
|
534 | - else |
|
583 | + if (strpos($gzfilename, 'http://') !== false || strpos($gzfilename, 'https://') !== false) { |
|
584 | + $packageInfo = read_tgz_data($gzfilename, 'package-info.xml', true); |
|
585 | + } else |
|
535 | 586 | { |
536 | - if (!file_exists($packagesdir . '/' . $gzfilename)) |
|
537 | - return 'package_get_error_not_found'; |
|
587 | + if (!file_exists($packagesdir . '/' . $gzfilename)) { |
|
588 | + return 'package_get_error_not_found'; |
|
589 | + } |
|
538 | 590 | |
539 | - if (is_file($packagesdir . '/' . $gzfilename)) |
|
540 | - $packageInfo = read_tgz_file($packagesdir . '/' . $gzfilename, '*/package-info.xml', true); |
|
541 | - elseif (file_exists($packagesdir . '/' . $gzfilename . '/package-info.xml')) |
|
542 | - $packageInfo = file_get_contents($packagesdir . '/' . $gzfilename . '/package-info.xml'); |
|
543 | - else |
|
544 | - return 'package_get_error_missing_xml'; |
|
591 | + if (is_file($packagesdir . '/' . $gzfilename)) { |
|
592 | + $packageInfo = read_tgz_file($packagesdir . '/' . $gzfilename, '*/package-info.xml', true); |
|
593 | + } elseif (file_exists($packagesdir . '/' . $gzfilename . '/package-info.xml')) { |
|
594 | + $packageInfo = file_get_contents($packagesdir . '/' . $gzfilename . '/package-info.xml'); |
|
595 | + } else { |
|
596 | + return 'package_get_error_missing_xml'; |
|
597 | + } |
|
545 | 598 | } |
546 | 599 | |
547 | 600 | // Nothing? |
@@ -549,10 +602,11 @@ discard block |
||
549 | 602 | { |
550 | 603 | // Perhaps they are trying to install a theme, lets tell them nicely this is the wrong function |
551 | 604 | $packageInfo = read_tgz_file($packagesdir . '/' . $gzfilename, '*/theme_info.xml', true); |
552 | - if (!empty($packageInfo)) |
|
553 | - return 'package_get_error_is_theme'; |
|
554 | - else |
|
555 | - return 'package_get_error_is_zero'; |
|
605 | + if (!empty($packageInfo)) { |
|
606 | + return 'package_get_error_is_theme'; |
|
607 | + } else { |
|
608 | + return 'package_get_error_is_zero'; |
|
609 | + } |
|
556 | 610 | } |
557 | 611 | |
558 | 612 | // Parse package-info.xml into an xmlArray. |
@@ -560,8 +614,9 @@ discard block |
||
560 | 614 | $packageInfo = new xmlArray($packageInfo); |
561 | 615 | |
562 | 616 | // @todo Error message of some sort? |
563 | - if (!$packageInfo->exists('package-info[0]')) |
|
564 | - return 'package_get_error_packageinfo_corrupt'; |
|
617 | + if (!$packageInfo->exists('package-info[0]')) { |
|
618 | + return 'package_get_error_packageinfo_corrupt'; |
|
619 | + } |
|
565 | 620 | |
566 | 621 | $packageInfo = $packageInfo->path('package-info[0]'); |
567 | 622 | |
@@ -580,8 +635,9 @@ discard block |
||
580 | 635 | } |
581 | 636 | } |
582 | 637 | |
583 | - if (!isset($package['type'])) |
|
584 | - $package['type'] = 'modification'; |
|
638 | + if (!isset($package['type'])) { |
|
639 | + $package['type'] = 'modification'; |
|
640 | + } |
|
585 | 641 | |
586 | 642 | return $package; |
587 | 643 | } |
@@ -634,15 +690,14 @@ discard block |
||
634 | 690 | { |
635 | 691 | $ftp_file = strtr($file, array($_SESSION['pack_ftp']['root'] => '')); |
636 | 692 | $package_ftp->chmod($ftp_file, $perms); |
693 | + } else { |
|
694 | + smf_chmod($file, $perms); |
|
637 | 695 | } |
638 | - else |
|
639 | - smf_chmod($file, $perms); |
|
640 | 696 | |
641 | 697 | $new_permissions = @fileperms($file); |
642 | 698 | $result = $new_permissions == $perms ? 'success' : 'failure'; |
643 | 699 | unset($_SESSION['pack_ftp']['original_perms'][$file]); |
644 | - } |
|
645 | - elseif ($do_change) |
|
700 | + } elseif ($do_change) |
|
646 | 701 | { |
647 | 702 | $new_permissions = ''; |
648 | 703 | $result = 'skipped'; |
@@ -758,8 +813,7 @@ discard block |
||
758 | 813 | |
759 | 814 | $context['sub_template'] = 'show_list'; |
760 | 815 | $context['default_list'] = 'restore_file_permissions'; |
761 | - } |
|
762 | - else |
|
816 | + } else |
|
763 | 817 | { |
764 | 818 | unset($listOptions['columns']['result']); |
765 | 819 | } |
@@ -769,12 +823,14 @@ discard block |
||
769 | 823 | createList($listOptions); |
770 | 824 | |
771 | 825 | // If we just restored permissions then whereever we are, we are now done and dusted. |
772 | - if (!empty($_POST['restore_perms'])) |
|
773 | - obExit(); |
|
826 | + if (!empty($_POST['restore_perms'])) { |
|
827 | + obExit(); |
|
828 | + } |
|
774 | 829 | } |
775 | 830 | // Otherwise, it's entirely irrelevant? |
776 | - elseif ($restore_write_status) |
|
777 | - return true; |
|
831 | + elseif ($restore_write_status) { |
|
832 | + return true; |
|
833 | + } |
|
778 | 834 | |
779 | 835 | // This is where we report what we got up to. |
780 | 836 | $return_data = array( |
@@ -812,11 +868,12 @@ discard block |
||
812 | 868 | if (!in_array($_POST['ftp_path'], array('', '/'))) |
813 | 869 | { |
814 | 870 | $ftp_root = strtr($boarddir, array($_POST['ftp_path'] => '')); |
815 | - if (substr($ftp_root, -1) == '/' && ($_POST['ftp_path'] == '' || substr($_POST['ftp_path'], 0, 1) == '/')) |
|
816 | - $ftp_root = substr($ftp_root, 0, -1); |
|
871 | + if (substr($ftp_root, -1) == '/' && ($_POST['ftp_path'] == '' || substr($_POST['ftp_path'], 0, 1) == '/')) { |
|
872 | + $ftp_root = substr($ftp_root, 0, -1); |
|
873 | + } |
|
874 | + } else { |
|
875 | + $ftp_root = $boarddir; |
|
817 | 876 | } |
818 | - else |
|
819 | - $ftp_root = $boarddir; |
|
820 | 877 | |
821 | 878 | $_SESSION['pack_ftp'] = array( |
822 | 879 | 'server' => $_POST['ftp_server'], |
@@ -828,8 +885,9 @@ discard block |
||
828 | 885 | 'connected' => true, |
829 | 886 | ); |
830 | 887 | |
831 | - if (!isset($modSettings['package_path']) || $modSettings['package_path'] != $_POST['ftp_path']) |
|
832 | - updateSettings(array('package_path' => $_POST['ftp_path'])); |
|
888 | + if (!isset($modSettings['package_path']) || $modSettings['package_path'] != $_POST['ftp_path']) { |
|
889 | + updateSettings(array('package_path' => $_POST['ftp_path'])); |
|
890 | + } |
|
833 | 891 | |
834 | 892 | // This is now the primary connection. |
835 | 893 | $package_ftp = $ftp; |
@@ -842,12 +900,13 @@ discard block |
||
842 | 900 | foreach ($chmodFiles as $k => $file) |
843 | 901 | { |
844 | 902 | // Sometimes this can somehow happen maybe? |
845 | - if (empty($file)) |
|
846 | - unset($chmodFiles[$k]); |
|
903 | + if (empty($file)) { |
|
904 | + unset($chmodFiles[$k]); |
|
905 | + } |
|
847 | 906 | // Already writable? |
848 | - elseif (@is_writable($file)) |
|
849 | - $return_data['files']['writable'][] = $file; |
|
850 | - else |
|
907 | + elseif (@is_writable($file)) { |
|
908 | + $return_data['files']['writable'][] = $file; |
|
909 | + } else |
|
851 | 910 | { |
852 | 911 | // Now try to change that. |
853 | 912 | $return_data['files'][package_chmod($file, 'writable', true) ? 'writable' : 'notwritable'][] = $file; |
@@ -864,19 +923,21 @@ discard block |
||
864 | 923 | { |
865 | 924 | require_once($sourcedir . '/Class-Package.php'); |
866 | 925 | $ftp = new ftp_connection(null); |
926 | + } elseif ($ftp->error !== false && !isset($ftp_error)) { |
|
927 | + $ftp_error = $ftp->last_message === null ? '' : $ftp->last_message; |
|
867 | 928 | } |
868 | - elseif ($ftp->error !== false && !isset($ftp_error)) |
|
869 | - $ftp_error = $ftp->last_message === null ? '' : $ftp->last_message; |
|
870 | 929 | |
871 | 930 | list ($username, $detect_path, $found_path) = $ftp->detect_path($boarddir); |
872 | 931 | |
873 | - if ($found_path) |
|
874 | - $_POST['ftp_path'] = $detect_path; |
|
875 | - elseif (!isset($_POST['ftp_path'])) |
|
876 | - $_POST['ftp_path'] = isset($modSettings['package_path']) ? $modSettings['package_path'] : $detect_path; |
|
932 | + if ($found_path) { |
|
933 | + $_POST['ftp_path'] = $detect_path; |
|
934 | + } elseif (!isset($_POST['ftp_path'])) { |
|
935 | + $_POST['ftp_path'] = isset($modSettings['package_path']) ? $modSettings['package_path'] : $detect_path; |
|
936 | + } |
|
877 | 937 | |
878 | - if (!isset($_POST['ftp_username'])) |
|
879 | - $_POST['ftp_username'] = $username; |
|
938 | + if (!isset($_POST['ftp_username'])) { |
|
939 | + $_POST['ftp_username'] = $username; |
|
940 | + } |
|
880 | 941 | } |
881 | 942 | |
882 | 943 | $context['package_ftp'] = array( |
@@ -889,8 +950,9 @@ discard block |
||
889 | 950 | ); |
890 | 951 | |
891 | 952 | // Which files failed? |
892 | - if (!isset($context['notwritable_files'])) |
|
893 | - $context['notwritable_files'] = array(); |
|
953 | + if (!isset($context['notwritable_files'])) { |
|
954 | + $context['notwritable_files'] = array(); |
|
955 | + } |
|
894 | 956 | $context['notwritable_files'] = array_merge($context['notwritable_files'], $return_data['files']['notwritable']); |
895 | 957 | |
896 | 958 | // Sent here to die? |
@@ -923,40 +985,48 @@ discard block |
||
923 | 985 | foreach ($files as $k => $file) |
924 | 986 | { |
925 | 987 | // If this file doesn't exist, then we actually want to look at the directory, no? |
926 | - if (!file_exists($file)) |
|
927 | - $file = dirname($file); |
|
988 | + if (!file_exists($file)) { |
|
989 | + $file = dirname($file); |
|
990 | + } |
|
928 | 991 | |
929 | 992 | // This looks odd, but it's an attempt to work around PHP suExec. |
930 | - if (!@is_writable($file)) |
|
931 | - smf_chmod($file, 0755); |
|
932 | - if (!@is_writable($file)) |
|
933 | - smf_chmod($file, 0777); |
|
934 | - if (!@is_writable(dirname($file))) |
|
935 | - smf_chmod($file, 0755); |
|
936 | - if (!@is_writable(dirname($file))) |
|
937 | - smf_chmod($file, 0777); |
|
993 | + if (!@is_writable($file)) { |
|
994 | + smf_chmod($file, 0755); |
|
995 | + } |
|
996 | + if (!@is_writable($file)) { |
|
997 | + smf_chmod($file, 0777); |
|
998 | + } |
|
999 | + if (!@is_writable(dirname($file))) { |
|
1000 | + smf_chmod($file, 0755); |
|
1001 | + } |
|
1002 | + if (!@is_writable(dirname($file))) { |
|
1003 | + smf_chmod($file, 0777); |
|
1004 | + } |
|
938 | 1005 | |
939 | 1006 | $fp = is_dir($file) ? @opendir($file) : @fopen($file, 'rb'); |
940 | 1007 | if (@is_writable($file) && $fp) |
941 | 1008 | { |
942 | 1009 | unset($files[$k]); |
943 | - if (!is_dir($file)) |
|
944 | - fclose($fp); |
|
945 | - else |
|
946 | - closedir($fp); |
|
1010 | + if (!is_dir($file)) { |
|
1011 | + fclose($fp); |
|
1012 | + } else { |
|
1013 | + closedir($fp); |
|
1014 | + } |
|
947 | 1015 | } |
948 | 1016 | } |
949 | 1017 | |
950 | 1018 | // No FTP required! |
951 | - if (empty($files)) |
|
952 | - return array(); |
|
1019 | + if (empty($files)) { |
|
1020 | + return array(); |
|
1021 | + } |
|
953 | 1022 | } |
954 | 1023 | |
955 | 1024 | // They've opted to not use FTP, and try anyway. |
956 | 1025 | if (isset($_SESSION['pack_ftp']) && $_SESSION['pack_ftp'] == false) |
957 | 1026 | { |
958 | - if ($files === null) |
|
959 | - return array(); |
|
1027 | + if ($files === null) { |
|
1028 | + return array(); |
|
1029 | + } |
|
960 | 1030 | |
961 | 1031 | foreach ($files as $k => $file) |
962 | 1032 | { |
@@ -968,26 +1038,29 @@ discard block |
||
968 | 1038 | smf_chmod($file, 0755); |
969 | 1039 | } |
970 | 1040 | |
971 | - if (!@is_writable($file)) |
|
972 | - smf_chmod($file, 0777); |
|
973 | - if (!@is_writable(dirname($file))) |
|
974 | - smf_chmod(dirname($file), 0777); |
|
1041 | + if (!@is_writable($file)) { |
|
1042 | + smf_chmod($file, 0777); |
|
1043 | + } |
|
1044 | + if (!@is_writable(dirname($file))) { |
|
1045 | + smf_chmod(dirname($file), 0777); |
|
1046 | + } |
|
975 | 1047 | |
976 | - if (@is_writable($file)) |
|
977 | - unset($files[$k]); |
|
1048 | + if (@is_writable($file)) { |
|
1049 | + unset($files[$k]); |
|
1050 | + } |
|
978 | 1051 | } |
979 | 1052 | |
980 | 1053 | return $files; |
981 | - } |
|
982 | - elseif (isset($_SESSION['pack_ftp'])) |
|
1054 | + } elseif (isset($_SESSION['pack_ftp'])) |
|
983 | 1055 | { |
984 | 1056 | // Load the file containing the ftp_connection class. |
985 | 1057 | require_once($sourcedir . '/Class-Package.php'); |
986 | 1058 | |
987 | 1059 | $package_ftp = new ftp_connection($_SESSION['pack_ftp']['server'], $_SESSION['pack_ftp']['port'], $_SESSION['pack_ftp']['username'], package_crypt($_SESSION['pack_ftp']['password'])); |
988 | 1060 | |
989 | - if ($files === null) |
|
990 | - return array(); |
|
1061 | + if ($files === null) { |
|
1062 | + return array(); |
|
1063 | + } |
|
991 | 1064 | |
992 | 1065 | foreach ($files as $k => $file) |
993 | 1066 | { |
@@ -1001,13 +1074,16 @@ discard block |
||
1001 | 1074 | $package_ftp->chmod($ftp_file, 0755); |
1002 | 1075 | } |
1003 | 1076 | |
1004 | - if (!@is_writable($file)) |
|
1005 | - $package_ftp->chmod($ftp_file, 0777); |
|
1006 | - if (!@is_writable(dirname($file))) |
|
1007 | - $package_ftp->chmod(dirname($ftp_file), 0777); |
|
1077 | + if (!@is_writable($file)) { |
|
1078 | + $package_ftp->chmod($ftp_file, 0777); |
|
1079 | + } |
|
1080 | + if (!@is_writable(dirname($file))) { |
|
1081 | + $package_ftp->chmod(dirname($ftp_file), 0777); |
|
1082 | + } |
|
1008 | 1083 | |
1009 | - if (@is_writable($file)) |
|
1010 | - unset($files[$k]); |
|
1084 | + if (@is_writable($file)) { |
|
1085 | + unset($files[$k]); |
|
1086 | + } |
|
1011 | 1087 | } |
1012 | 1088 | |
1013 | 1089 | return $files; |
@@ -1019,8 +1095,7 @@ discard block |
||
1019 | 1095 | |
1020 | 1096 | $files = packageRequireFTP($destination_url, $files, $return); |
1021 | 1097 | return $files; |
1022 | - } |
|
1023 | - elseif (isset($_POST['ftp_username'])) |
|
1098 | + } elseif (isset($_POST['ftp_username'])) |
|
1024 | 1099 | { |
1025 | 1100 | require_once($sourcedir . '/Class-Package.php'); |
1026 | 1101 | $ftp = new ftp_connection($_POST['ftp_server'], $_POST['ftp_port'], $_POST['ftp_username'], $_POST['ftp_password']); |
@@ -1042,19 +1117,21 @@ discard block |
||
1042 | 1117 | { |
1043 | 1118 | require_once($sourcedir . '/Class-Package.php'); |
1044 | 1119 | $ftp = new ftp_connection(null); |
1120 | + } elseif ($ftp->error !== false && !isset($ftp_error)) { |
|
1121 | + $ftp_error = $ftp->last_message === null ? '' : $ftp->last_message; |
|
1045 | 1122 | } |
1046 | - elseif ($ftp->error !== false && !isset($ftp_error)) |
|
1047 | - $ftp_error = $ftp->last_message === null ? '' : $ftp->last_message; |
|
1048 | 1123 | |
1049 | 1124 | list ($username, $detect_path, $found_path) = $ftp->detect_path($boarddir); |
1050 | 1125 | |
1051 | - if ($found_path) |
|
1052 | - $_POST['ftp_path'] = $detect_path; |
|
1053 | - elseif (!isset($_POST['ftp_path'])) |
|
1054 | - $_POST['ftp_path'] = isset($modSettings['package_path']) ? $modSettings['package_path'] : $detect_path; |
|
1126 | + if ($found_path) { |
|
1127 | + $_POST['ftp_path'] = $detect_path; |
|
1128 | + } elseif (!isset($_POST['ftp_path'])) { |
|
1129 | + $_POST['ftp_path'] = isset($modSettings['package_path']) ? $modSettings['package_path'] : $detect_path; |
|
1130 | + } |
|
1055 | 1131 | |
1056 | - if (!isset($_POST['ftp_username'])) |
|
1057 | - $_POST['ftp_username'] = $username; |
|
1132 | + if (!isset($_POST['ftp_username'])) { |
|
1133 | + $_POST['ftp_username'] = $username; |
|
1134 | + } |
|
1058 | 1135 | |
1059 | 1136 | $context['package_ftp'] = array( |
1060 | 1137 | 'server' => isset($_POST['ftp_server']) ? $_POST['ftp_server'] : (isset($modSettings['package_server']) ? $modSettings['package_server'] : 'localhost'), |
@@ -1066,23 +1143,24 @@ discard block |
||
1066 | 1143 | ); |
1067 | 1144 | |
1068 | 1145 | // If we're returning dump out here. |
1069 | - if ($return) |
|
1070 | - return $files; |
|
1146 | + if ($return) { |
|
1147 | + return $files; |
|
1148 | + } |
|
1071 | 1149 | |
1072 | 1150 | $context['page_title'] = $txt['package_ftp_necessary']; |
1073 | 1151 | $context['sub_template'] = 'ftp_required'; |
1074 | 1152 | obExit(); |
1075 | - } |
|
1076 | - else |
|
1153 | + } else |
|
1077 | 1154 | { |
1078 | 1155 | if (!in_array($_POST['ftp_path'], array('', '/'))) |
1079 | 1156 | { |
1080 | 1157 | $ftp_root = strtr($boarddir, array($_POST['ftp_path'] => '')); |
1081 | - if (substr($ftp_root, -1) == '/' && ($_POST['ftp_path'] == '' || $_POST['ftp_path'][0] == '/')) |
|
1082 | - $ftp_root = substr($ftp_root, 0, -1); |
|
1158 | + if (substr($ftp_root, -1) == '/' && ($_POST['ftp_path'] == '' || $_POST['ftp_path'][0] == '/')) { |
|
1159 | + $ftp_root = substr($ftp_root, 0, -1); |
|
1160 | + } |
|
1161 | + } else { |
|
1162 | + $ftp_root = $boarddir; |
|
1083 | 1163 | } |
1084 | - else |
|
1085 | - $ftp_root = $boarddir; |
|
1086 | 1164 | |
1087 | 1165 | $_SESSION['pack_ftp'] = array( |
1088 | 1166 | 'server' => $_POST['ftp_server'], |
@@ -1093,8 +1171,9 @@ discard block |
||
1093 | 1171 | 'root' => $ftp_root, |
1094 | 1172 | ); |
1095 | 1173 | |
1096 | - if (!isset($modSettings['package_path']) || $modSettings['package_path'] != $_POST['ftp_path']) |
|
1097 | - updateSettings(array('package_path' => $_POST['ftp_path'])); |
|
1174 | + if (!isset($modSettings['package_path']) || $modSettings['package_path'] != $_POST['ftp_path']) { |
|
1175 | + updateSettings(array('package_path' => $_POST['ftp_path'])); |
|
1176 | + } |
|
1098 | 1177 | |
1099 | 1178 | $files = packageRequireFTP($destination_url, $files, $return); |
1100 | 1179 | } |
@@ -1122,16 +1201,18 @@ discard block |
||
1122 | 1201 | global $packagesdir, $forum_version, $context, $temp_path, $language, $smcFunc; |
1123 | 1202 | |
1124 | 1203 | // Mayday! That action doesn't exist!! |
1125 | - if (empty($packageXML) || !$packageXML->exists($method)) |
|
1126 | - return array(); |
|
1204 | + if (empty($packageXML) || !$packageXML->exists($method)) { |
|
1205 | + return array(); |
|
1206 | + } |
|
1127 | 1207 | |
1128 | 1208 | // We haven't found the package script yet... |
1129 | 1209 | $script = false; |
1130 | 1210 | $the_version = strtr($forum_version, array('SMF ' => '')); |
1131 | 1211 | |
1132 | 1212 | // Emulation support... |
1133 | - if (!empty($_SESSION['version_emulate'])) |
|
1134 | - $the_version = $_SESSION['version_emulate']; |
|
1213 | + if (!empty($_SESSION['version_emulate'])) { |
|
1214 | + $the_version = $_SESSION['version_emulate']; |
|
1215 | + } |
|
1135 | 1216 | |
1136 | 1217 | // Single package emulation |
1137 | 1218 | if (!empty($_REQUEST['ve']) && !empty($_REQUEST['package'])) |
@@ -1139,8 +1220,9 @@ discard block |
||
1139 | 1220 | $the_version = $_REQUEST['ve']; |
1140 | 1221 | $_SESSION['single_version_emulate'][$_REQUEST['package']] = $the_version; |
1141 | 1222 | } |
1142 | - if (!empty($_REQUEST['package']) && (!empty($_SESSION['single_version_emulate'][$_REQUEST['package']]))) |
|
1143 | - $the_version = $_SESSION['single_version_emulate'][$_REQUEST['package']]; |
|
1223 | + if (!empty($_REQUEST['package']) && (!empty($_SESSION['single_version_emulate'][$_REQUEST['package']]))) { |
|
1224 | + $the_version = $_SESSION['single_version_emulate'][$_REQUEST['package']]; |
|
1225 | + } |
|
1144 | 1226 | |
1145 | 1227 | // Get all the versions of this method and find the right one. |
1146 | 1228 | $these_methods = $packageXML->set($method); |
@@ -1150,16 +1232,18 @@ discard block |
||
1150 | 1232 | if ($this_method->exists('@for')) |
1151 | 1233 | { |
1152 | 1234 | // Don't keep going if this won't work for this version of SMF. |
1153 | - if (!matchPackageVersion($the_version, $this_method->fetch('@for'))) |
|
1154 | - continue; |
|
1235 | + if (!matchPackageVersion($the_version, $this_method->fetch('@for'))) { |
|
1236 | + continue; |
|
1237 | + } |
|
1155 | 1238 | } |
1156 | 1239 | |
1157 | 1240 | // Upgrades may go from a certain old version of the mod. |
1158 | 1241 | if ($method == 'upgrade' && $this_method->exists('@from')) |
1159 | 1242 | { |
1160 | 1243 | // Well, this is for the wrong old version... |
1161 | - if (!matchPackageVersion($previous_version, $this_method->fetch('@from'))) |
|
1162 | - continue; |
|
1244 | + if (!matchPackageVersion($previous_version, $this_method->fetch('@from'))) { |
|
1245 | + continue; |
|
1246 | + } |
|
1163 | 1247 | } |
1164 | 1248 | |
1165 | 1249 | // We've found it! |
@@ -1168,8 +1252,9 @@ discard block |
||
1168 | 1252 | } |
1169 | 1253 | |
1170 | 1254 | // Bad news, a matching script wasn't found! |
1171 | - if ($script === false) |
|
1172 | - return array(); |
|
1255 | + if ($script === false) { |
|
1256 | + return array(); |
|
1257 | + } |
|
1173 | 1258 | |
1174 | 1259 | // Find all the actions in this method - in theory, these should only be allowed actions. (* means all.) |
1175 | 1260 | $actions = $script->set('*'); |
@@ -1198,12 +1283,12 @@ discard block |
||
1198 | 1283 | if ((isset($_REQUEST['readme']) && $action->fetch('@lang') == $_REQUEST['readme']) || (isset($_REQUEST['license']) && $action->fetch('@lang') == $_REQUEST['license']) || (!isset($_REQUEST['readme']) && $action->fetch('@lang') == $language) || (!isset($_REQUEST['license']) && $action->fetch('@lang') == $language)) |
1199 | 1284 | { |
1200 | 1285 | // In case the user put the blocks in the wrong order. |
1201 | - if (isset($context[$type]['selected']) && $context[$type]['selected'] == 'default') |
|
1202 | - $context[$type][] = 'default'; |
|
1286 | + if (isset($context[$type]['selected']) && $context[$type]['selected'] == 'default') { |
|
1287 | + $context[$type][] = 'default'; |
|
1288 | + } |
|
1203 | 1289 | |
1204 | 1290 | $context[$type]['selected'] = $smcFunc['htmlspecialchars']($action->fetch('@lang')); |
1205 | - } |
|
1206 | - else |
|
1291 | + } else |
|
1207 | 1292 | { |
1208 | 1293 | // We don't want this now, but we'll allow the user to select to read it. |
1209 | 1294 | $context[$type][] = $smcFunc['htmlspecialchars']($action->fetch('@lang')); |
@@ -1218,9 +1303,9 @@ discard block |
||
1218 | 1303 | { |
1219 | 1304 | $context[$type][] = 'default'; |
1220 | 1305 | continue; |
1306 | + } else { |
|
1307 | + $context[$type]['selected'] = 'default'; |
|
1221 | 1308 | } |
1222 | - else |
|
1223 | - $context[$type]['selected'] = 'default'; |
|
1224 | 1309 | } |
1225 | 1310 | } |
1226 | 1311 | |
@@ -1230,9 +1315,9 @@ discard block |
||
1230 | 1315 | $filename = $temp_path . '$auto_' . $temp_auto++ . (in_array($actionType, array('readme', 'redirect', 'license')) ? '.txt' : ($actionType == 'code' || $actionType == 'database' ? '.php' : '.mod')); |
1231 | 1316 | package_put_contents($filename, $action->fetch('.')); |
1232 | 1317 | $filename = strtr($filename, array($temp_path => '')); |
1318 | + } else { |
|
1319 | + $filename = $action->fetch('.'); |
|
1233 | 1320 | } |
1234 | - else |
|
1235 | - $filename = $action->fetch('.'); |
|
1236 | 1321 | |
1237 | 1322 | $return[] = array( |
1238 | 1323 | 'type' => $actionType, |
@@ -1247,8 +1332,7 @@ discard block |
||
1247 | 1332 | ); |
1248 | 1333 | |
1249 | 1334 | continue; |
1250 | - } |
|
1251 | - elseif ($actionType == 'hook') |
|
1335 | + } elseif ($actionType == 'hook') |
|
1252 | 1336 | { |
1253 | 1337 | $return[] = array( |
1254 | 1338 | 'type' => $actionType, |
@@ -1260,16 +1344,16 @@ discard block |
||
1260 | 1344 | 'description' => '', |
1261 | 1345 | ); |
1262 | 1346 | continue; |
1263 | - } |
|
1264 | - elseif ($actionType == 'credits') |
|
1347 | + } elseif ($actionType == 'credits') |
|
1265 | 1348 | { |
1266 | 1349 | // quick check of any supplied url |
1267 | 1350 | $url = $action->exists('@url') ? $action->fetch('@url') : ''; |
1268 | 1351 | if (strlen(trim($url)) > 0 && substr($url, 0, 7) !== 'http://' && substr($url, 0, 8) !== 'https://') |
1269 | 1352 | { |
1270 | 1353 | $url = 'http://' . $url; |
1271 | - if (strlen($url) < 8 || (substr($url, 0, 7) !== 'http://' && substr($url, 0, 8) !== 'https://')) |
|
1272 | - $url = ''; |
|
1354 | + if (strlen($url) < 8 || (substr($url, 0, 7) !== 'http://' && substr($url, 0, 8) !== 'https://')) { |
|
1355 | + $url = ''; |
|
1356 | + } |
|
1273 | 1357 | } |
1274 | 1358 | |
1275 | 1359 | $return[] = array( |
@@ -1281,8 +1365,7 @@ discard block |
||
1281 | 1365 | 'title' => $action->fetch('.'), |
1282 | 1366 | ); |
1283 | 1367 | continue; |
1284 | - } |
|
1285 | - elseif ($actionType == 'requires') |
|
1368 | + } elseif ($actionType == 'requires') |
|
1286 | 1369 | { |
1287 | 1370 | $return[] = array( |
1288 | 1371 | 'type' => $actionType, |
@@ -1291,14 +1374,12 @@ discard block |
||
1291 | 1374 | 'description' => '', |
1292 | 1375 | ); |
1293 | 1376 | continue; |
1294 | - } |
|
1295 | - elseif ($actionType == 'error') |
|
1377 | + } elseif ($actionType == 'error') |
|
1296 | 1378 | { |
1297 | 1379 | $return[] = array( |
1298 | 1380 | 'type' => 'error', |
1299 | 1381 | ); |
1300 | - } |
|
1301 | - elseif (in_array($actionType, array('require-file', 'remove-file', 'require-dir', 'remove-dir', 'move-file', 'move-dir', 'create-file', 'create-dir'))) |
|
1382 | + } elseif (in_array($actionType, array('require-file', 'remove-file', 'require-dir', 'remove-dir', 'move-file', 'move-dir', 'create-file', 'create-dir'))) |
|
1302 | 1383 | { |
1303 | 1384 | $this_action = &$return[]; |
1304 | 1385 | $this_action = array( |
@@ -1312,8 +1393,7 @@ discard block |
||
1312 | 1393 | { |
1313 | 1394 | $this_action['unparsed_destination'] = $action->fetch('@destination'); |
1314 | 1395 | $this_action['destination'] = parse_path($action->fetch('@destination')) . '/' . basename($this_action['filename']); |
1315 | - } |
|
1316 | - else |
|
1396 | + } else |
|
1317 | 1397 | { |
1318 | 1398 | $this_action['unparsed_filename'] = $this_action['filename']; |
1319 | 1399 | $this_action['filename'] = parse_path($this_action['filename']); |
@@ -1322,10 +1402,11 @@ discard block |
||
1322 | 1402 | // If we're moving or requiring (copying) a file. |
1323 | 1403 | if (substr($actionType, 0, 4) == 'move' || substr($actionType, 0, 7) == 'require') |
1324 | 1404 | { |
1325 | - if ($action->exists('@from')) |
|
1326 | - $this_action['source'] = parse_path($action->fetch('@from')); |
|
1327 | - else |
|
1328 | - $this_action['source'] = $temp_path . $this_action['filename']; |
|
1405 | + if ($action->exists('@from')) { |
|
1406 | + $this_action['source'] = parse_path($action->fetch('@from')); |
|
1407 | + } else { |
|
1408 | + $this_action['source'] = $temp_path . $this_action['filename']; |
|
1409 | + } |
|
1329 | 1410 | } |
1330 | 1411 | |
1331 | 1412 | // Check if these things can be done. (chmod's etc.) |
@@ -1334,22 +1415,23 @@ discard block |
||
1334 | 1415 | if (!mktree($this_action['destination'], false)) |
1335 | 1416 | { |
1336 | 1417 | $temp = $this_action['destination']; |
1337 | - while (!file_exists($temp) && strlen($temp) > 1) |
|
1338 | - $temp = dirname($temp); |
|
1418 | + while (!file_exists($temp) && strlen($temp) > 1) { |
|
1419 | + $temp = dirname($temp); |
|
1420 | + } |
|
1339 | 1421 | |
1340 | 1422 | $return[] = array( |
1341 | 1423 | 'type' => 'chmod', |
1342 | 1424 | 'filename' => $temp |
1343 | 1425 | ); |
1344 | 1426 | } |
1345 | - } |
|
1346 | - elseif ($actionType == 'create-file') |
|
1427 | + } elseif ($actionType == 'create-file') |
|
1347 | 1428 | { |
1348 | 1429 | if (!mktree(dirname($this_action['destination']), false)) |
1349 | 1430 | { |
1350 | 1431 | $temp = dirname($this_action['destination']); |
1351 | - while (!file_exists($temp) && strlen($temp) > 1) |
|
1352 | - $temp = dirname($temp); |
|
1432 | + while (!file_exists($temp) && strlen($temp) > 1) { |
|
1433 | + $temp = dirname($temp); |
|
1434 | + } |
|
1353 | 1435 | |
1354 | 1436 | $return[] = array( |
1355 | 1437 | 'type' => 'chmod', |
@@ -1357,36 +1439,38 @@ discard block |
||
1357 | 1439 | ); |
1358 | 1440 | } |
1359 | 1441 | |
1360 | - if (!is_writable($this_action['destination']) && (file_exists($this_action['destination']) || !is_writable(dirname($this_action['destination'])))) |
|
1361 | - $return[] = array( |
|
1442 | + if (!is_writable($this_action['destination']) && (file_exists($this_action['destination']) || !is_writable(dirname($this_action['destination'])))) { |
|
1443 | + $return[] = array( |
|
1362 | 1444 | 'type' => 'chmod', |
1363 | 1445 | 'filename' => $this_action['destination'] |
1364 | 1446 | ); |
1365 | - } |
|
1366 | - elseif ($actionType == 'require-dir') |
|
1447 | + } |
|
1448 | + } elseif ($actionType == 'require-dir') |
|
1367 | 1449 | { |
1368 | 1450 | if (!mktree($this_action['destination'], false)) |
1369 | 1451 | { |
1370 | 1452 | $temp = $this_action['destination']; |
1371 | - while (!file_exists($temp) && strlen($temp) > 1) |
|
1372 | - $temp = dirname($temp); |
|
1453 | + while (!file_exists($temp) && strlen($temp) > 1) { |
|
1454 | + $temp = dirname($temp); |
|
1455 | + } |
|
1373 | 1456 | |
1374 | 1457 | $return[] = array( |
1375 | 1458 | 'type' => 'chmod', |
1376 | 1459 | 'filename' => $temp |
1377 | 1460 | ); |
1378 | 1461 | } |
1379 | - } |
|
1380 | - elseif ($actionType == 'require-file') |
|
1462 | + } elseif ($actionType == 'require-file') |
|
1381 | 1463 | { |
1382 | - if ($action->exists('@theme')) |
|
1383 | - $this_action['theme_action'] = $action->fetch('@theme'); |
|
1464 | + if ($action->exists('@theme')) { |
|
1465 | + $this_action['theme_action'] = $action->fetch('@theme'); |
|
1466 | + } |
|
1384 | 1467 | |
1385 | 1468 | if (!mktree(dirname($this_action['destination']), false)) |
1386 | 1469 | { |
1387 | 1470 | $temp = dirname($this_action['destination']); |
1388 | - while (!file_exists($temp) && strlen($temp) > 1) |
|
1389 | - $temp = dirname($temp); |
|
1471 | + while (!file_exists($temp) && strlen($temp) > 1) { |
|
1472 | + $temp = dirname($temp); |
|
1473 | + } |
|
1390 | 1474 | |
1391 | 1475 | $return[] = array( |
1392 | 1476 | 'type' => 'chmod', |
@@ -1394,19 +1478,20 @@ discard block |
||
1394 | 1478 | ); |
1395 | 1479 | } |
1396 | 1480 | |
1397 | - if (!is_writable($this_action['destination']) && (file_exists($this_action['destination']) || !is_writable(dirname($this_action['destination'])))) |
|
1398 | - $return[] = array( |
|
1481 | + if (!is_writable($this_action['destination']) && (file_exists($this_action['destination']) || !is_writable(dirname($this_action['destination'])))) { |
|
1482 | + $return[] = array( |
|
1399 | 1483 | 'type' => 'chmod', |
1400 | 1484 | 'filename' => $this_action['destination'] |
1401 | 1485 | ); |
1402 | - } |
|
1403 | - elseif ($actionType == 'move-dir' || $actionType == 'move-file') |
|
1486 | + } |
|
1487 | + } elseif ($actionType == 'move-dir' || $actionType == 'move-file') |
|
1404 | 1488 | { |
1405 | 1489 | if (!mktree(dirname($this_action['destination']), false)) |
1406 | 1490 | { |
1407 | 1491 | $temp = dirname($this_action['destination']); |
1408 | - while (!file_exists($temp) && strlen($temp) > 1) |
|
1409 | - $temp = dirname($temp); |
|
1492 | + while (!file_exists($temp) && strlen($temp) > 1) { |
|
1493 | + $temp = dirname($temp); |
|
1494 | + } |
|
1410 | 1495 | |
1411 | 1496 | $return[] = array( |
1412 | 1497 | 'type' => 'chmod', |
@@ -1414,30 +1499,30 @@ discard block |
||
1414 | 1499 | ); |
1415 | 1500 | } |
1416 | 1501 | |
1417 | - if (!is_writable($this_action['destination']) && (file_exists($this_action['destination']) || !is_writable(dirname($this_action['destination'])))) |
|
1418 | - $return[] = array( |
|
1502 | + if (!is_writable($this_action['destination']) && (file_exists($this_action['destination']) || !is_writable(dirname($this_action['destination'])))) { |
|
1503 | + $return[] = array( |
|
1419 | 1504 | 'type' => 'chmod', |
1420 | 1505 | 'filename' => $this_action['destination'] |
1421 | 1506 | ); |
1422 | - } |
|
1423 | - elseif ($actionType == 'remove-dir') |
|
1507 | + } |
|
1508 | + } elseif ($actionType == 'remove-dir') |
|
1424 | 1509 | { |
1425 | - if (!is_writable($this_action['filename']) && file_exists($this_action['filename'])) |
|
1426 | - $return[] = array( |
|
1510 | + if (!is_writable($this_action['filename']) && file_exists($this_action['filename'])) { |
|
1511 | + $return[] = array( |
|
1427 | 1512 | 'type' => 'chmod', |
1428 | 1513 | 'filename' => $this_action['filename'] |
1429 | 1514 | ); |
1430 | - } |
|
1431 | - elseif ($actionType == 'remove-file') |
|
1515 | + } |
|
1516 | + } elseif ($actionType == 'remove-file') |
|
1432 | 1517 | { |
1433 | - if (!is_writable($this_action['filename']) && file_exists($this_action['filename'])) |
|
1434 | - $return[] = array( |
|
1518 | + if (!is_writable($this_action['filename']) && file_exists($this_action['filename'])) { |
|
1519 | + $return[] = array( |
|
1435 | 1520 | 'type' => 'chmod', |
1436 | 1521 | 'filename' => $this_action['filename'] |
1437 | 1522 | ); |
1523 | + } |
|
1438 | 1524 | } |
1439 | - } |
|
1440 | - else |
|
1525 | + } else |
|
1441 | 1526 | { |
1442 | 1527 | $return[] = array( |
1443 | 1528 | 'type' => 'error', |
@@ -1448,8 +1533,9 @@ discard block |
||
1448 | 1533 | } |
1449 | 1534 | |
1450 | 1535 | // Only testing - just return a list of things to be done. |
1451 | - if ($testing_only) |
|
1452 | - return $return; |
|
1536 | + if ($testing_only) { |
|
1537 | + return $return; |
|
1538 | + } |
|
1453 | 1539 | |
1454 | 1540 | umask(0); |
1455 | 1541 | |
@@ -1457,78 +1543,81 @@ discard block |
||
1457 | 1543 | $not_done = array(array('type' => '!')); |
1458 | 1544 | foreach ($return as $action) |
1459 | 1545 | { |
1460 | - if (in_array($action['type'], array('modification', 'code', 'database', 'redirect', 'hook', 'credits'))) |
|
1461 | - $not_done[] = $action; |
|
1546 | + if (in_array($action['type'], array('modification', 'code', 'database', 'redirect', 'hook', 'credits'))) { |
|
1547 | + $not_done[] = $action; |
|
1548 | + } |
|
1462 | 1549 | |
1463 | 1550 | if ($action['type'] == 'create-dir') |
1464 | 1551 | { |
1465 | - if (!mktree($action['destination'], 0755) || !is_writable($action['destination'])) |
|
1466 | - $failure |= !mktree($action['destination'], 0777); |
|
1467 | - } |
|
1468 | - elseif ($action['type'] == 'create-file') |
|
1552 | + if (!mktree($action['destination'], 0755) || !is_writable($action['destination'])) { |
|
1553 | + $failure |= !mktree($action['destination'], 0777); |
|
1554 | + } |
|
1555 | + } elseif ($action['type'] == 'create-file') |
|
1469 | 1556 | { |
1470 | - if (!mktree(dirname($action['destination']), 0755) || !is_writable(dirname($action['destination']))) |
|
1471 | - $failure |= !mktree(dirname($action['destination']), 0777); |
|
1557 | + if (!mktree(dirname($action['destination']), 0755) || !is_writable(dirname($action['destination']))) { |
|
1558 | + $failure |= !mktree(dirname($action['destination']), 0777); |
|
1559 | + } |
|
1472 | 1560 | |
1473 | 1561 | // Create an empty file. |
1474 | 1562 | package_put_contents($action['destination'], package_get_contents($action['source']), $testing_only); |
1475 | 1563 | |
1476 | - if (!file_exists($action['destination'])) |
|
1477 | - $failure = true; |
|
1478 | - } |
|
1479 | - elseif ($action['type'] == 'require-dir') |
|
1564 | + if (!file_exists($action['destination'])) { |
|
1565 | + $failure = true; |
|
1566 | + } |
|
1567 | + } elseif ($action['type'] == 'require-dir') |
|
1480 | 1568 | { |
1481 | 1569 | copytree($action['source'], $action['destination']); |
1482 | 1570 | // Any other theme folders? |
1483 | - if (!empty($context['theme_copies']) && !empty($context['theme_copies'][$action['type']][$action['destination']])) |
|
1484 | - foreach ($context['theme_copies'][$action['type']][$action['destination']] as $theme_destination) |
|
1571 | + if (!empty($context['theme_copies']) && !empty($context['theme_copies'][$action['type']][$action['destination']])) { |
|
1572 | + foreach ($context['theme_copies'][$action['type']][$action['destination']] as $theme_destination) |
|
1485 | 1573 | copytree($action['source'], $theme_destination); |
1486 | - } |
|
1487 | - elseif ($action['type'] == 'require-file') |
|
1574 | + } |
|
1575 | + } elseif ($action['type'] == 'require-file') |
|
1488 | 1576 | { |
1489 | - if (!mktree(dirname($action['destination']), 0755) || !is_writable(dirname($action['destination']))) |
|
1490 | - $failure |= !mktree(dirname($action['destination']), 0777); |
|
1577 | + if (!mktree(dirname($action['destination']), 0755) || !is_writable(dirname($action['destination']))) { |
|
1578 | + $failure |= !mktree(dirname($action['destination']), 0777); |
|
1579 | + } |
|
1491 | 1580 | |
1492 | 1581 | package_put_contents($action['destination'], package_get_contents($action['source']), $testing_only); |
1493 | 1582 | |
1494 | 1583 | $failure |= !copy($action['source'], $action['destination']); |
1495 | 1584 | |
1496 | 1585 | // Any other theme files? |
1497 | - if (!empty($context['theme_copies']) && !empty($context['theme_copies'][$action['type']][$action['destination']])) |
|
1498 | - foreach ($context['theme_copies'][$action['type']][$action['destination']] as $theme_destination) |
|
1586 | + if (!empty($context['theme_copies']) && !empty($context['theme_copies'][$action['type']][$action['destination']])) { |
|
1587 | + foreach ($context['theme_copies'][$action['type']][$action['destination']] as $theme_destination) |
|
1499 | 1588 | { |
1500 | 1589 | if (!mktree(dirname($theme_destination), 0755) || !is_writable(dirname($theme_destination))) |
1501 | 1590 | $failure |= !mktree(dirname($theme_destination), 0777); |
1591 | + } |
|
1502 | 1592 | |
1503 | 1593 | package_put_contents($theme_destination, package_get_contents($action['source']), $testing_only); |
1504 | 1594 | |
1505 | 1595 | $failure |= !copy($action['source'], $theme_destination); |
1506 | 1596 | } |
1507 | - } |
|
1508 | - elseif ($action['type'] == 'move-file') |
|
1597 | + } elseif ($action['type'] == 'move-file') |
|
1509 | 1598 | { |
1510 | - if (!mktree(dirname($action['destination']), 0755) || !is_writable(dirname($action['destination']))) |
|
1511 | - $failure |= !mktree(dirname($action['destination']), 0777); |
|
1599 | + if (!mktree(dirname($action['destination']), 0755) || !is_writable(dirname($action['destination']))) { |
|
1600 | + $failure |= !mktree(dirname($action['destination']), 0777); |
|
1601 | + } |
|
1512 | 1602 | |
1513 | 1603 | $failure |= !rename($action['source'], $action['destination']); |
1514 | - } |
|
1515 | - elseif ($action['type'] == 'move-dir') |
|
1604 | + } elseif ($action['type'] == 'move-dir') |
|
1516 | 1605 | { |
1517 | - if (!mktree($action['destination'], 0755) || !is_writable($action['destination'])) |
|
1518 | - $failure |= !mktree($action['destination'], 0777); |
|
1606 | + if (!mktree($action['destination'], 0755) || !is_writable($action['destination'])) { |
|
1607 | + $failure |= !mktree($action['destination'], 0777); |
|
1608 | + } |
|
1519 | 1609 | |
1520 | 1610 | $failure |= !rename($action['source'], $action['destination']); |
1521 | - } |
|
1522 | - elseif ($action['type'] == 'remove-dir') |
|
1611 | + } elseif ($action['type'] == 'remove-dir') |
|
1523 | 1612 | { |
1524 | 1613 | deltree($action['filename']); |
1525 | 1614 | |
1526 | 1615 | // Any other theme folders? |
1527 | - if (!empty($context['theme_copies']) && !empty($context['theme_copies'][$action['type']][$action['filename']])) |
|
1528 | - foreach ($context['theme_copies'][$action['type']][$action['filename']] as $theme_destination) |
|
1616 | + if (!empty($context['theme_copies']) && !empty($context['theme_copies'][$action['type']][$action['filename']])) { |
|
1617 | + foreach ($context['theme_copies'][$action['type']][$action['filename']] as $theme_destination) |
|
1529 | 1618 | deltree($theme_destination); |
1530 | - } |
|
1531 | - elseif ($action['type'] == 'remove-file') |
|
1619 | + } |
|
1620 | + } elseif ($action['type'] == 'remove-file') |
|
1532 | 1621 | { |
1533 | 1622 | // Make sure the file exists before deleting it. |
1534 | 1623 | if (file_exists($action['filename'])) |
@@ -1537,16 +1626,18 @@ discard block |
||
1537 | 1626 | $failure |= !unlink($action['filename']); |
1538 | 1627 | } |
1539 | 1628 | // The file that was supposed to be deleted couldn't be found. |
1540 | - else |
|
1541 | - $failure = true; |
|
1629 | + else { |
|
1630 | + $failure = true; |
|
1631 | + } |
|
1542 | 1632 | |
1543 | 1633 | // Any other theme folders? |
1544 | - if (!empty($context['theme_copies']) && !empty($context['theme_copies'][$action['type']][$action['filename']])) |
|
1545 | - foreach ($context['theme_copies'][$action['type']][$action['filename']] as $theme_destination) |
|
1634 | + if (!empty($context['theme_copies']) && !empty($context['theme_copies'][$action['type']][$action['filename']])) { |
|
1635 | + foreach ($context['theme_copies'][$action['type']][$action['filename']] as $theme_destination) |
|
1546 | 1636 | if (file_exists($theme_destination)) |
1547 | 1637 | $failure |= !unlink($theme_destination); |
1548 | - else |
|
1549 | - $failure = true; |
|
1638 | + } else { |
|
1639 | + $failure = true; |
|
1640 | + } |
|
1550 | 1641 | } |
1551 | 1642 | } |
1552 | 1643 | |
@@ -1568,8 +1659,9 @@ discard block |
||
1568 | 1659 | { |
1569 | 1660 | static $near_version = 0; |
1570 | 1661 | |
1571 | - if ($reset) |
|
1572 | - $near_version = 0; |
|
1662 | + if ($reset) { |
|
1663 | + $near_version = 0; |
|
1664 | + } |
|
1573 | 1665 | |
1574 | 1666 | // Normalize the $versions while we remove our previous Doh! |
1575 | 1667 | $versions = explode(',', str_replace(array(' ', '2.0rc1-1'), array('', '2.0rc1.1'), strtolower($versions))); |
@@ -1578,16 +1670,19 @@ discard block |
||
1578 | 1670 | foreach ($versions as $for) |
1579 | 1671 | { |
1580 | 1672 | // Adjust for those wild cards |
1581 | - if (strpos($for, '*') !== false) |
|
1582 | - $for = str_replace('*', '0dev0', $for) . '-' . str_replace('*', '999', $for); |
|
1673 | + if (strpos($for, '*') !== false) { |
|
1674 | + $for = str_replace('*', '0dev0', $for) . '-' . str_replace('*', '999', $for); |
|
1675 | + } |
|
1583 | 1676 | |
1584 | 1677 | // If we have a range, grab the lower value, done this way so it looks normal-er to the user e.g. 2.0 vs 2.0.99 |
1585 | - if (strpos($for, '-') !== false) |
|
1586 | - list ($for, $higher) = explode('-', $for); |
|
1678 | + if (strpos($for, '-') !== false) { |
|
1679 | + list ($for, $higher) = explode('-', $for); |
|
1680 | + } |
|
1587 | 1681 | |
1588 | 1682 | // Do the compare, if the for is greater, than what we have but not greater than what we are running ..... |
1589 | - if (compareVersions($near_version, $for) === -1 && compareVersions($for, $the_version) !== 1) |
|
1590 | - $near_version = $for; |
|
1683 | + if (compareVersions($near_version, $for) === -1 && compareVersions($for, $the_version) !== 1) { |
|
1684 | + $near_version = $for; |
|
1685 | + } |
|
1591 | 1686 | } |
1592 | 1687 | |
1593 | 1688 | return !empty($near_version) ? $near_version : false; |
@@ -1610,15 +1705,17 @@ discard block |
||
1610 | 1705 | $versions = explode(',', str_replace(array(' ', '2.0rc1-1'), array('', '2.0rc1.1'), strtolower($versions))); |
1611 | 1706 | |
1612 | 1707 | // Perhaps we do accept anything? |
1613 | - if (in_array('all', $versions)) |
|
1614 | - return true; |
|
1708 | + if (in_array('all', $versions)) { |
|
1709 | + return true; |
|
1710 | + } |
|
1615 | 1711 | |
1616 | 1712 | // Loop through each version. |
1617 | 1713 | foreach ($versions as $for) |
1618 | 1714 | { |
1619 | 1715 | // Wild card spotted? |
1620 | - if (strpos($for, '*') !== false) |
|
1621 | - $for = str_replace('*', '0dev0', $for) . '-' . str_replace('*', '999', $for); |
|
1716 | + if (strpos($for, '*') !== false) { |
|
1717 | + $for = str_replace('*', '0dev0', $for) . '-' . str_replace('*', '999', $for); |
|
1718 | + } |
|
1622 | 1719 | |
1623 | 1720 | // Do we have a range? |
1624 | 1721 | if (strpos($for, '-') !== false) |
@@ -1626,12 +1723,14 @@ discard block |
||
1626 | 1723 | list ($lower, $upper) = explode('-', $for); |
1627 | 1724 | |
1628 | 1725 | // Compare the version against lower and upper bounds. |
1629 | - if (compareVersions($version, $lower) > -1 && compareVersions($version, $upper) < 1) |
|
1630 | - return true; |
|
1726 | + if (compareVersions($version, $lower) > -1 && compareVersions($version, $upper) < 1) { |
|
1727 | + return true; |
|
1728 | + } |
|
1631 | 1729 | } |
1632 | 1730 | // Otherwise check if they are equal... |
1633 | - elseif (compareVersions($version, $for) === 0) |
|
1634 | - return true; |
|
1731 | + elseif (compareVersions($version, $for) === 0) { |
|
1732 | + return true; |
|
1733 | + } |
|
1635 | 1734 | } |
1636 | 1735 | |
1637 | 1736 | return false; |
@@ -1671,12 +1770,14 @@ discard block |
||
1671 | 1770 | } |
1672 | 1771 | |
1673 | 1772 | // Are they the same, perhaps? |
1674 | - if ($versions[1] === $versions[2]) |
|
1675 | - return 0; |
|
1773 | + if ($versions[1] === $versions[2]) { |
|
1774 | + return 0; |
|
1775 | + } |
|
1676 | 1776 | |
1677 | 1777 | // Get version numbering categories... |
1678 | - if (!isset($categories)) |
|
1679 | - $categories = array_keys($versions[1]); |
|
1778 | + if (!isset($categories)) { |
|
1779 | + $categories = array_keys($versions[1]); |
|
1780 | + } |
|
1680 | 1781 | |
1681 | 1782 | // Loop through each category. |
1682 | 1783 | foreach ($categories as $category) |
@@ -1686,13 +1787,15 @@ discard block |
||
1686 | 1787 | { |
1687 | 1788 | // Dev builds are a problematic exception. |
1688 | 1789 | // (stable) dev < (stable) but (unstable) dev = (unstable) |
1689 | - if ($category == 'type') |
|
1690 | - return $versions[1][$category] > $versions[2][$category] ? ($versions[1]['dev'] ? -1 : 1) : ($versions[2]['dev'] ? 1 : -1); |
|
1691 | - elseif ($category == 'dev') |
|
1692 | - return $versions[1]['dev'] ? ($versions[2]['type'] == 'stable' ? -1 : 0) : ($versions[1]['type'] == 'stable' ? 1 : 0); |
|
1790 | + if ($category == 'type') { |
|
1791 | + return $versions[1][$category] > $versions[2][$category] ? ($versions[1]['dev'] ? -1 : 1) : ($versions[2]['dev'] ? 1 : -1); |
|
1792 | + } elseif ($category == 'dev') { |
|
1793 | + return $versions[1]['dev'] ? ($versions[2]['type'] == 'stable' ? -1 : 0) : ($versions[1]['type'] == 'stable' ? 1 : 0); |
|
1794 | + } |
|
1693 | 1795 | // Otherwise a simple comparison. |
1694 | - else |
|
1695 | - return $versions[1][$category] > $versions[2][$category] ? 1 : -1; |
|
1796 | + else { |
|
1797 | + return $versions[1][$category] > $versions[2][$category] ? 1 : -1; |
|
1798 | + } |
|
1696 | 1799 | } |
1697 | 1800 | } |
1698 | 1801 | |
@@ -1726,11 +1829,13 @@ discard block |
||
1726 | 1829 | ); |
1727 | 1830 | |
1728 | 1831 | // do we parse in a package directory? |
1729 | - if (!empty($temp_path)) |
|
1730 | - $dirs['$package'] = $temp_path; |
|
1832 | + if (!empty($temp_path)) { |
|
1833 | + $dirs['$package'] = $temp_path; |
|
1834 | + } |
|
1731 | 1835 | |
1732 | - if (strlen($path) == 0) |
|
1733 | - trigger_error('parse_path(): There should never be an empty filename', E_USER_ERROR); |
|
1836 | + if (strlen($path) == 0) { |
|
1837 | + trigger_error('parse_path(): There should never be an empty filename', E_USER_ERROR); |
|
1838 | + } |
|
1734 | 1839 | |
1735 | 1840 | return strtr($path, $dirs); |
1736 | 1841 | } |
@@ -1746,8 +1851,9 @@ discard block |
||
1746 | 1851 | { |
1747 | 1852 | global $package_ftp; |
1748 | 1853 | |
1749 | - if (!file_exists($dir)) |
|
1750 | - return; |
|
1854 | + if (!file_exists($dir)) { |
|
1855 | + return; |
|
1856 | + } |
|
1751 | 1857 | |
1752 | 1858 | $current_dir = @opendir($dir); |
1753 | 1859 | if ($current_dir == false) |
@@ -1755,8 +1861,9 @@ discard block |
||
1755 | 1861 | if ($delete_dir && isset($package_ftp)) |
1756 | 1862 | { |
1757 | 1863 | $ftp_file = strtr($dir, array($_SESSION['pack_ftp']['root'] => '')); |
1758 | - if (!is_dir($dir)) |
|
1759 | - $package_ftp->chmod($ftp_file, 0777); |
|
1864 | + if (!is_dir($dir)) { |
|
1865 | + $package_ftp->chmod($ftp_file, 0777); |
|
1866 | + } |
|
1760 | 1867 | $package_ftp->unlink($ftp_file); |
1761 | 1868 | } |
1762 | 1869 | |
@@ -1765,26 +1872,28 @@ discard block |
||
1765 | 1872 | |
1766 | 1873 | while ($entryname = readdir($current_dir)) |
1767 | 1874 | { |
1768 | - if (in_array($entryname, array('.', '..'))) |
|
1769 | - continue; |
|
1875 | + if (in_array($entryname, array('.', '..'))) { |
|
1876 | + continue; |
|
1877 | + } |
|
1770 | 1878 | |
1771 | - if (is_dir($dir . '/' . $entryname)) |
|
1772 | - deltree($dir . '/' . $entryname); |
|
1773 | - else |
|
1879 | + if (is_dir($dir . '/' . $entryname)) { |
|
1880 | + deltree($dir . '/' . $entryname); |
|
1881 | + } else |
|
1774 | 1882 | { |
1775 | 1883 | // Here, 755 doesn't really matter since we're deleting it anyway. |
1776 | 1884 | if (isset($package_ftp)) |
1777 | 1885 | { |
1778 | 1886 | $ftp_file = strtr($dir . '/' . $entryname, array($_SESSION['pack_ftp']['root'] => '')); |
1779 | 1887 | |
1780 | - if (!is_writable($dir . '/' . $entryname)) |
|
1781 | - $package_ftp->chmod($ftp_file, 0777); |
|
1888 | + if (!is_writable($dir . '/' . $entryname)) { |
|
1889 | + $package_ftp->chmod($ftp_file, 0777); |
|
1890 | + } |
|
1782 | 1891 | $package_ftp->unlink($ftp_file); |
1783 | - } |
|
1784 | - else |
|
1892 | + } else |
|
1785 | 1893 | { |
1786 | - if (!is_writable($dir . '/' . $entryname)) |
|
1787 | - smf_chmod($dir . '/' . $entryname, 0777); |
|
1894 | + if (!is_writable($dir . '/' . $entryname)) { |
|
1895 | + smf_chmod($dir . '/' . $entryname, 0777); |
|
1896 | + } |
|
1788 | 1897 | unlink($dir . '/' . $entryname); |
1789 | 1898 | } |
1790 | 1899 | } |
@@ -1797,14 +1906,15 @@ discard block |
||
1797 | 1906 | if (isset($package_ftp)) |
1798 | 1907 | { |
1799 | 1908 | $ftp_file = strtr($dir, array($_SESSION['pack_ftp']['root'] => '')); |
1800 | - if (!is_writable($dir . '/' . $entryname)) |
|
1801 | - $package_ftp->chmod($ftp_file, 0777); |
|
1909 | + if (!is_writable($dir . '/' . $entryname)) { |
|
1910 | + $package_ftp->chmod($ftp_file, 0777); |
|
1911 | + } |
|
1802 | 1912 | $package_ftp->unlink($ftp_file); |
1803 | - } |
|
1804 | - else |
|
1913 | + } else |
|
1805 | 1914 | { |
1806 | - if (!is_writable($dir)) |
|
1807 | - smf_chmod($dir, 0777); |
|
1915 | + if (!is_writable($dir)) { |
|
1916 | + smf_chmod($dir, 0777); |
|
1917 | + } |
|
1808 | 1918 | @rmdir($dir); |
1809 | 1919 | } |
1810 | 1920 | } |
@@ -1826,10 +1936,11 @@ discard block |
||
1826 | 1936 | { |
1827 | 1937 | if (!is_writable($strPath) && $mode !== false) |
1828 | 1938 | { |
1829 | - if (isset($package_ftp)) |
|
1830 | - $package_ftp->chmod(strtr($strPath, array($_SESSION['pack_ftp']['root'] => '')), $mode); |
|
1831 | - else |
|
1832 | - smf_chmod($strPath, $mode); |
|
1939 | + if (isset($package_ftp)) { |
|
1940 | + $package_ftp->chmod(strtr($strPath, array($_SESSION['pack_ftp']['root'] => '')), $mode); |
|
1941 | + } else { |
|
1942 | + smf_chmod($strPath, $mode); |
|
1943 | + } |
|
1833 | 1944 | } |
1834 | 1945 | |
1835 | 1946 | $test = @opendir($strPath); |
@@ -1837,36 +1948,37 @@ discard block |
||
1837 | 1948 | { |
1838 | 1949 | closedir($test); |
1839 | 1950 | return is_writable($strPath); |
1951 | + } else { |
|
1952 | + return false; |
|
1840 | 1953 | } |
1841 | - else |
|
1842 | - return false; |
|
1843 | 1954 | } |
1844 | 1955 | // Is this an invalid path and/or we can't make the directory? |
1845 | - if ($strPath == dirname($strPath) || !mktree(dirname($strPath), $mode)) |
|
1846 | - return false; |
|
1956 | + if ($strPath == dirname($strPath) || !mktree(dirname($strPath), $mode)) { |
|
1957 | + return false; |
|
1958 | + } |
|
1847 | 1959 | |
1848 | 1960 | if (!is_writable(dirname($strPath)) && $mode !== false) |
1849 | 1961 | { |
1850 | - if (isset($package_ftp)) |
|
1851 | - $package_ftp->chmod(dirname(strtr($strPath, array($_SESSION['pack_ftp']['root'] => ''))), $mode); |
|
1852 | - else |
|
1853 | - smf_chmod(dirname($strPath), $mode); |
|
1962 | + if (isset($package_ftp)) { |
|
1963 | + $package_ftp->chmod(dirname(strtr($strPath, array($_SESSION['pack_ftp']['root'] => ''))), $mode); |
|
1964 | + } else { |
|
1965 | + smf_chmod(dirname($strPath), $mode); |
|
1966 | + } |
|
1854 | 1967 | } |
1855 | 1968 | |
1856 | - if ($mode !== false && isset($package_ftp)) |
|
1857 | - return $package_ftp->create_dir(strtr($strPath, array($_SESSION['pack_ftp']['root'] => ''))); |
|
1858 | - elseif ($mode === false) |
|
1969 | + if ($mode !== false && isset($package_ftp)) { |
|
1970 | + return $package_ftp->create_dir(strtr($strPath, array($_SESSION['pack_ftp']['root'] => ''))); |
|
1971 | + } elseif ($mode === false) |
|
1859 | 1972 | { |
1860 | 1973 | $test = @opendir(dirname($strPath)); |
1861 | 1974 | if ($test) |
1862 | 1975 | { |
1863 | 1976 | closedir($test); |
1864 | 1977 | return true; |
1978 | + } else { |
|
1979 | + return false; |
|
1865 | 1980 | } |
1866 | - else |
|
1867 | - return false; |
|
1868 | - } |
|
1869 | - else |
|
1981 | + } else |
|
1870 | 1982 | { |
1871 | 1983 | @mkdir($strPath, $mode); |
1872 | 1984 | $test = @opendir($strPath); |
@@ -1874,9 +1986,9 @@ discard block |
||
1874 | 1986 | { |
1875 | 1987 | closedir($test); |
1876 | 1988 | return true; |
1989 | + } else { |
|
1990 | + return false; |
|
1877 | 1991 | } |
1878 | - else |
|
1879 | - return false; |
|
1880 | 1992 | } |
1881 | 1993 | } |
1882 | 1994 | |
@@ -1891,39 +2003,46 @@ discard block |
||
1891 | 2003 | { |
1892 | 2004 | global $package_ftp; |
1893 | 2005 | |
1894 | - if (!file_exists($destination) || !is_writable($destination)) |
|
1895 | - mktree($destination, 0755); |
|
1896 | - if (!is_writable($destination)) |
|
1897 | - mktree($destination, 0777); |
|
2006 | + if (!file_exists($destination) || !is_writable($destination)) { |
|
2007 | + mktree($destination, 0755); |
|
2008 | + } |
|
2009 | + if (!is_writable($destination)) { |
|
2010 | + mktree($destination, 0777); |
|
2011 | + } |
|
1898 | 2012 | |
1899 | 2013 | $current_dir = opendir($source); |
1900 | - if ($current_dir == false) |
|
1901 | - return; |
|
2014 | + if ($current_dir == false) { |
|
2015 | + return; |
|
2016 | + } |
|
1902 | 2017 | |
1903 | 2018 | while ($entryname = readdir($current_dir)) |
1904 | 2019 | { |
1905 | - if (in_array($entryname, array('.', '..'))) |
|
1906 | - continue; |
|
2020 | + if (in_array($entryname, array('.', '..'))) { |
|
2021 | + continue; |
|
2022 | + } |
|
1907 | 2023 | |
1908 | - if (isset($package_ftp)) |
|
1909 | - $ftp_file = strtr($destination . '/' . $entryname, array($_SESSION['pack_ftp']['root'] => '')); |
|
2024 | + if (isset($package_ftp)) { |
|
2025 | + $ftp_file = strtr($destination . '/' . $entryname, array($_SESSION['pack_ftp']['root'] => '')); |
|
2026 | + } |
|
1910 | 2027 | |
1911 | 2028 | if (is_file($source . '/' . $entryname)) |
1912 | 2029 | { |
1913 | - if (isset($package_ftp) && !file_exists($destination . '/' . $entryname)) |
|
1914 | - $package_ftp->create_file($ftp_file); |
|
1915 | - elseif (!file_exists($destination . '/' . $entryname)) |
|
1916 | - @touch($destination . '/' . $entryname); |
|
2030 | + if (isset($package_ftp) && !file_exists($destination . '/' . $entryname)) { |
|
2031 | + $package_ftp->create_file($ftp_file); |
|
2032 | + } elseif (!file_exists($destination . '/' . $entryname)) { |
|
2033 | + @touch($destination . '/' . $entryname); |
|
2034 | + } |
|
1917 | 2035 | } |
1918 | 2036 | |
1919 | 2037 | package_chmod($destination . '/' . $entryname); |
1920 | 2038 | |
1921 | - if (is_dir($source . '/' . $entryname)) |
|
1922 | - copytree($source . '/' . $entryname, $destination . '/' . $entryname); |
|
1923 | - elseif (file_exists($destination . '/' . $entryname)) |
|
1924 | - package_put_contents($destination . '/' . $entryname, package_get_contents($source . '/' . $entryname)); |
|
1925 | - else |
|
1926 | - copy($source . '/' . $entryname, $destination . '/' . $entryname); |
|
2039 | + if (is_dir($source . '/' . $entryname)) { |
|
2040 | + copytree($source . '/' . $entryname, $destination . '/' . $entryname); |
|
2041 | + } elseif (file_exists($destination . '/' . $entryname)) { |
|
2042 | + package_put_contents($destination . '/' . $entryname, package_get_contents($source . '/' . $entryname)); |
|
2043 | + } else { |
|
2044 | + copy($source . '/' . $entryname, $destination . '/' . $entryname); |
|
2045 | + } |
|
1927 | 2046 | } |
1928 | 2047 | |
1929 | 2048 | closedir($current_dir); |
@@ -1941,21 +2060,24 @@ discard block |
||
1941 | 2060 | $data = array(); |
1942 | 2061 | |
1943 | 2062 | $dir = @dir($path . $sub_path); |
1944 | - if (!$dir) |
|
1945 | - return array(); |
|
2063 | + if (!$dir) { |
|
2064 | + return array(); |
|
2065 | + } |
|
1946 | 2066 | while ($entry = $dir->read()) |
1947 | 2067 | { |
1948 | - if ($entry == '.' || $entry == '..') |
|
1949 | - continue; |
|
2068 | + if ($entry == '.' || $entry == '..') { |
|
2069 | + continue; |
|
2070 | + } |
|
1950 | 2071 | |
1951 | - if (is_dir($path . $sub_path . '/' . $entry)) |
|
1952 | - $data = array_merge($data, listtree($path, $sub_path . '/' . $entry)); |
|
1953 | - else |
|
1954 | - $data[] = array( |
|
2072 | + if (is_dir($path . $sub_path . '/' . $entry)) { |
|
2073 | + $data = array_merge($data, listtree($path, $sub_path . '/' . $entry)); |
|
2074 | + } else { |
|
2075 | + $data[] = array( |
|
1955 | 2076 | 'filename' => $sub_path == '' ? $entry : $sub_path . '/' . $entry, |
1956 | 2077 | 'size' => filesize($path . $sub_path . '/' . $entry), |
1957 | 2078 | 'skipped' => false, |
1958 | 2079 | ); |
2080 | + } |
|
1959 | 2081 | } |
1960 | 2082 | $dir->close(); |
1961 | 2083 | |
@@ -2010,8 +2132,9 @@ discard block |
||
2010 | 2132 | { |
2011 | 2133 | // If this filename is relative, if so take a guess at what it should be. |
2012 | 2134 | $real_filename = $filename; |
2013 | - if (strpos($filename, 'Themes') === 0) |
|
2014 | - $real_filename = $boarddir . '/' . $filename; |
|
2135 | + if (strpos($filename, 'Themes') === 0) { |
|
2136 | + $real_filename = $boarddir . '/' . $filename; |
|
2137 | + } |
|
2015 | 2138 | |
2016 | 2139 | if (strpos($real_filename, $theme['theme_dir']) === 0) |
2017 | 2140 | { |
@@ -2030,8 +2153,9 @@ discard block |
||
2030 | 2153 | foreach ($theme_paths as $id => $theme) |
2031 | 2154 | { |
2032 | 2155 | // Default is getting done anyway, so no need for involvement here. |
2033 | - if ($id == 1) |
|
2034 | - continue; |
|
2156 | + if ($id == 1) { |
|
2157 | + continue; |
|
2158 | + } |
|
2035 | 2159 | |
2036 | 2160 | // For every template, do we want it? Yea, no, maybe? |
2037 | 2161 | foreach ($template_changes[1] as $index => $template_file) |
@@ -2054,8 +2178,9 @@ discard block |
||
2054 | 2178 | ); |
2055 | 2179 | |
2056 | 2180 | // Sometimes though, we have some additional files for other themes, if we have add them to the mix. |
2057 | - if (isset($custom_themes_add[$files_to_change[1]])) |
|
2058 | - $files_to_change += $custom_themes_add[$files_to_change[1]]; |
|
2181 | + if (isset($custom_themes_add[$files_to_change[1]])) { |
|
2182 | + $files_to_change += $custom_themes_add[$files_to_change[1]]; |
|
2183 | + } |
|
2059 | 2184 | |
2060 | 2185 | // Now, loop through all the files we're changing, and, well, change them ;) |
2061 | 2186 | foreach ($files_to_change as $theme => $working_file) |
@@ -2089,11 +2214,13 @@ discard block |
||
2089 | 2214 | continue; |
2090 | 2215 | } |
2091 | 2216 | // Okay, we're creating this file then...? |
2092 | - elseif (!file_exists($working_file)) |
|
2093 | - $working_data = ''; |
|
2217 | + elseif (!file_exists($working_file)) { |
|
2218 | + $working_data = ''; |
|
2219 | + } |
|
2094 | 2220 | // Phew, it exists! Load 'er up! |
2095 | - else |
|
2096 | - $working_data = str_replace("\r", '', package_get_contents($working_file)); |
|
2221 | + else { |
|
2222 | + $working_data = str_replace("\r", '', package_get_contents($working_file)); |
|
2223 | + } |
|
2097 | 2224 | |
2098 | 2225 | $actions[] = array( |
2099 | 2226 | 'type' => 'opened', |
@@ -2114,8 +2241,8 @@ discard block |
||
2114 | 2241 | |
2115 | 2242 | // Grab all search items of this operation (in most cases just 1). |
2116 | 2243 | $searches = $operation->set('search'); |
2117 | - foreach ($searches as $i => $search) |
|
2118 | - $actual_operation['searches'][] = array( |
|
2244 | + foreach ($searches as $i => $search) { |
|
2245 | + $actual_operation['searches'][] = array( |
|
2119 | 2246 | 'position' => $search->exists('@position') && in_array(trim($search->fetch('@position')), array('before', 'after', 'replace', 'end')) ? trim($search->fetch('@position')) : 'replace', |
2120 | 2247 | 'is_reg_exp' => $search->exists('@regexp') && trim($search->fetch('@regexp')) === 'true', |
2121 | 2248 | 'loose_whitespace' => $search->exists('@whitespace') && trim($search->fetch('@whitespace')) === 'loose', |
@@ -2124,6 +2251,7 @@ discard block |
||
2124 | 2251 | 'preg_search' => '', |
2125 | 2252 | 'preg_replace' => '', |
2126 | 2253 | ); |
2254 | + } |
|
2127 | 2255 | |
2128 | 2256 | // At least one search should be defined. |
2129 | 2257 | if (empty($actual_operation['searches'])) |
@@ -2148,30 +2276,32 @@ discard block |
||
2148 | 2276 | // Reverse modification of regular expressions are not allowed. |
2149 | 2277 | if ($search['is_reg_exp']) |
2150 | 2278 | { |
2151 | - if ($actual_operation['error'] === 'fatal') |
|
2152 | - $actions[] = array( |
|
2279 | + if ($actual_operation['error'] === 'fatal') { |
|
2280 | + $actions[] = array( |
|
2153 | 2281 | 'type' => 'failure', |
2154 | 2282 | 'filename' => $working_file, |
2155 | 2283 | 'search' => $search['search'], |
2156 | 2284 | 'is_custom' => $theme > 1 ? $theme : 0, |
2157 | 2285 | ); |
2286 | + } |
|
2158 | 2287 | |
2159 | 2288 | // Continue to the next operation. |
2160 | 2289 | continue 2; |
2161 | 2290 | } |
2162 | 2291 | |
2163 | 2292 | // The replacement is now the search subject... |
2164 | - if ($search['position'] === 'replace' || $search['position'] === 'end') |
|
2165 | - $actual_operation['searches'][$i]['search'] = $search['add']; |
|
2166 | - else |
|
2293 | + if ($search['position'] === 'replace' || $search['position'] === 'end') { |
|
2294 | + $actual_operation['searches'][$i]['search'] = $search['add']; |
|
2295 | + } else |
|
2167 | 2296 | { |
2168 | 2297 | // Reversing a before/after modification becomes a replacement. |
2169 | 2298 | $actual_operation['searches'][$i]['position'] = 'replace'; |
2170 | 2299 | |
2171 | - if ($search['position'] === 'before') |
|
2172 | - $actual_operation['searches'][$i]['search'] .= $search['add']; |
|
2173 | - elseif ($search['position'] === 'after') |
|
2174 | - $actual_operation['searches'][$i]['search'] = $search['add'] . $search['search']; |
|
2300 | + if ($search['position'] === 'before') { |
|
2301 | + $actual_operation['searches'][$i]['search'] .= $search['add']; |
|
2302 | + } elseif ($search['position'] === 'after') { |
|
2303 | + $actual_operation['searches'][$i]['search'] = $search['add'] . $search['search']; |
|
2304 | + } |
|
2175 | 2305 | } |
2176 | 2306 | |
2177 | 2307 | // ...and the search subject is now the replacement. |
@@ -2199,16 +2329,17 @@ discard block |
||
2199 | 2329 | foreach ($actual_operation['searches'] as $i => $search) |
2200 | 2330 | { |
2201 | 2331 | // Not much needed if the search subject is already a regexp. |
2202 | - if ($search['is_reg_exp']) |
|
2203 | - $actual_operation['searches'][$i]['preg_search'] = $search['search']; |
|
2204 | - else |
|
2332 | + if ($search['is_reg_exp']) { |
|
2333 | + $actual_operation['searches'][$i]['preg_search'] = $search['search']; |
|
2334 | + } else |
|
2205 | 2335 | { |
2206 | 2336 | // Make the search subject fit into a regular expression. |
2207 | 2337 | $actual_operation['searches'][$i]['preg_search'] = preg_quote($search['search'], '~'); |
2208 | 2338 | |
2209 | 2339 | // Using 'loose', a random amount of tabs and spaces may be used. |
2210 | - if ($search['loose_whitespace']) |
|
2211 | - $actual_operation['searches'][$i]['preg_search'] = preg_replace('~[ \t]+~', '[ \t]+', $actual_operation['searches'][$i]['preg_search']); |
|
2340 | + if ($search['loose_whitespace']) { |
|
2341 | + $actual_operation['searches'][$i]['preg_search'] = preg_replace('~[ \t]+~', '[ \t]+', $actual_operation['searches'][$i]['preg_search']); |
|
2342 | + } |
|
2212 | 2343 | } |
2213 | 2344 | |
2214 | 2345 | // Shuzzup. This is done so we can safely use a regular expression. ($0 is bad!!) |
@@ -2234,8 +2365,7 @@ discard block |
||
2234 | 2365 | if ($undo) |
2235 | 2366 | { |
2236 | 2367 | $actual_operation['searches'][$i]['preg_replace'] = ''; |
2237 | - } |
|
2238 | - else |
|
2368 | + } else |
|
2239 | 2369 | { |
2240 | 2370 | $actual_operation['searches'][$i]['preg_search'] = '(\\n\\?\\>)?$'; |
2241 | 2371 | $actual_operation['searches'][$i]['preg_replace'] .= '$1'; |
@@ -2282,8 +2412,9 @@ discard block |
||
2282 | 2412 | } |
2283 | 2413 | |
2284 | 2414 | // Replace it into nothing? That's not an option...unless it's an undoing end. |
2285 | - if ($search['add'] === '' && ($search['position'] !== 'end' || !$undo)) |
|
2286 | - continue; |
|
2415 | + if ($search['add'] === '' && ($search['position'] !== 'end' || !$undo)) { |
|
2416 | + continue; |
|
2417 | + } |
|
2287 | 2418 | |
2288 | 2419 | // Finally, we're doing some replacements. |
2289 | 2420 | $working_data = preg_replace('~' . $actual_operation['searches'][$i]['preg_search'] . '~s', $actual_operation['searches'][$i]['preg_replace'], $working_data, 1); |
@@ -2308,22 +2439,25 @@ discard block |
||
2308 | 2439 | |
2309 | 2440 | package_chmod($working_file); |
2310 | 2441 | |
2311 | - if ((file_exists($working_file) && !is_writable($working_file)) || (!file_exists($working_file) && !is_writable(dirname($working_file)))) |
|
2312 | - $actions[] = array( |
|
2442 | + if ((file_exists($working_file) && !is_writable($working_file)) || (!file_exists($working_file) && !is_writable(dirname($working_file)))) { |
|
2443 | + $actions[] = array( |
|
2313 | 2444 | 'type' => 'chmod', |
2314 | 2445 | 'filename' => $working_file |
2315 | 2446 | ); |
2447 | + } |
|
2316 | 2448 | |
2317 | - if (basename($working_file) == 'Settings_bak.php') |
|
2318 | - continue; |
|
2449 | + if (basename($working_file) == 'Settings_bak.php') { |
|
2450 | + continue; |
|
2451 | + } |
|
2319 | 2452 | |
2320 | 2453 | if (!$testing && !empty($modSettings['package_make_backups']) && file_exists($working_file)) |
2321 | 2454 | { |
2322 | 2455 | // No, no, not Settings.php! |
2323 | - if (basename($working_file) == 'Settings.php') |
|
2324 | - @copy($working_file, dirname($working_file) . '/Settings_bak.php'); |
|
2325 | - else |
|
2326 | - @copy($working_file, $working_file . '~'); |
|
2456 | + if (basename($working_file) == 'Settings.php') { |
|
2457 | + @copy($working_file, dirname($working_file) . '/Settings_bak.php'); |
|
2458 | + } else { |
|
2459 | + @copy($working_file, $working_file . '~'); |
|
2460 | + } |
|
2327 | 2461 | } |
2328 | 2462 | |
2329 | 2463 | // Always call this, even if in testing, because it won't really be written in testing mode. |
@@ -2390,8 +2524,9 @@ discard block |
||
2390 | 2524 | if ($code_match[1] != 'edit file' && $code_match[1] != 'file') |
2391 | 2525 | { |
2392 | 2526 | // It's a step, let's add that to the current steps. |
2393 | - if (isset($temp_changes[$step_counter])) |
|
2394 | - $temp_changes[$step_counter]['changes'][] = $code_match[0]; |
|
2527 | + if (isset($temp_changes[$step_counter])) { |
|
2528 | + $temp_changes[$step_counter]['changes'][] = $code_match[0]; |
|
2529 | + } |
|
2395 | 2530 | continue; |
2396 | 2531 | } |
2397 | 2532 | |
@@ -2408,11 +2543,13 @@ discard block |
||
2408 | 2543 | foreach ($theme_paths as $id => $theme) |
2409 | 2544 | { |
2410 | 2545 | // If this filename is relative, if so take a guess at what it should be. |
2411 | - if (strpos($filename, 'Themes') === 0) |
|
2412 | - $filename = $boarddir . '/' . $filename; |
|
2546 | + if (strpos($filename, 'Themes') === 0) { |
|
2547 | + $filename = $boarddir . '/' . $filename; |
|
2548 | + } |
|
2413 | 2549 | |
2414 | - if (strpos($filename, $theme['theme_dir']) === 0) |
|
2415 | - $template_changes[$id][$counter] = substr($filename, strlen($theme['theme_dir']) + 1); |
|
2550 | + if (strpos($filename, $theme['theme_dir']) === 0) { |
|
2551 | + $template_changes[$id][$counter] = substr($filename, strlen($theme['theme_dir']) + 1); |
|
2552 | + } |
|
2416 | 2553 | } |
2417 | 2554 | } |
2418 | 2555 | |
@@ -2427,8 +2564,9 @@ discard block |
||
2427 | 2564 | foreach ($theme_paths as $id => $theme) |
2428 | 2565 | { |
2429 | 2566 | // Don't do default, it means nothing to me. |
2430 | - if ($id == 1) |
|
2431 | - continue; |
|
2567 | + if ($id == 1) { |
|
2568 | + continue; |
|
2569 | + } |
|
2432 | 2570 | |
2433 | 2571 | // Now, for each file do we need to edit it? |
2434 | 2572 | foreach ($template_changes[1] as $pos => $template_file) |
@@ -2464,32 +2602,36 @@ discard block |
||
2464 | 2602 | package_chmod($working_file); |
2465 | 2603 | |
2466 | 2604 | // Don't even dare. |
2467 | - if (basename($working_file) == 'Settings_bak.php') |
|
2468 | - continue; |
|
2605 | + if (basename($working_file) == 'Settings_bak.php') { |
|
2606 | + continue; |
|
2607 | + } |
|
2469 | 2608 | |
2470 | - if (!is_writable($working_file)) |
|
2471 | - $actions[] = array( |
|
2609 | + if (!is_writable($working_file)) { |
|
2610 | + $actions[] = array( |
|
2472 | 2611 | 'type' => 'chmod', |
2473 | 2612 | 'filename' => $working_file |
2474 | 2613 | ); |
2614 | + } |
|
2475 | 2615 | |
2476 | 2616 | if (!$testing && !empty($modSettings['package_make_backups']) && file_exists($working_file)) |
2477 | 2617 | { |
2478 | - if (basename($working_file) == 'Settings.php') |
|
2479 | - @copy($working_file, dirname($working_file) . '/Settings_bak.php'); |
|
2480 | - else |
|
2481 | - @copy($working_file, $working_file . '~'); |
|
2618 | + if (basename($working_file) == 'Settings.php') { |
|
2619 | + @copy($working_file, dirname($working_file) . '/Settings_bak.php'); |
|
2620 | + } else { |
|
2621 | + @copy($working_file, $working_file . '~'); |
|
2622 | + } |
|
2482 | 2623 | } |
2483 | 2624 | |
2484 | 2625 | package_put_contents($working_file, $working_data, $testing); |
2485 | 2626 | } |
2486 | 2627 | |
2487 | - if ($working_file !== null) |
|
2488 | - $actions[] = array( |
|
2628 | + if ($working_file !== null) { |
|
2629 | + $actions[] = array( |
|
2489 | 2630 | 'type' => 'saved', |
2490 | 2631 | 'filename' => $working_file, |
2491 | 2632 | 'is_custom' => $is_custom, |
2492 | 2633 | ); |
2634 | + } |
|
2493 | 2635 | |
2494 | 2636 | // Is this "now working on" file a theme specific one? |
2495 | 2637 | $is_custom = isset($theme_id_ref[$counter - 1]) ? $theme_id_ref[$counter - 1] : 0; |
@@ -2508,10 +2650,11 @@ discard block |
||
2508 | 2650 | { |
2509 | 2651 | $places_to_check = array($boarddir, $sourcedir, $settings['default_theme_dir'], $settings['default_theme_dir'] . '/languages'); |
2510 | 2652 | |
2511 | - foreach ($places_to_check as $place) |
|
2512 | - if (file_exists($place . '/' . $working_file)) |
|
2653 | + foreach ($places_to_check as $place) { |
|
2654 | + if (file_exists($place . '/' . $working_file)) |
|
2513 | 2655 | { |
2514 | 2656 | $working_file = $place . '/' . $working_file; |
2657 | + } |
|
2515 | 2658 | break; |
2516 | 2659 | } |
2517 | 2660 | } |
@@ -2525,8 +2668,7 @@ discard block |
||
2525 | 2668 | 'type' => 'opened', |
2526 | 2669 | 'filename' => $working_file |
2527 | 2670 | ); |
2528 | - } |
|
2529 | - else |
|
2671 | + } else |
|
2530 | 2672 | { |
2531 | 2673 | $actions[] = array( |
2532 | 2674 | 'type' => 'missing', |
@@ -2562,11 +2704,13 @@ discard block |
||
2562 | 2704 | $replace_with = $code_match[2]; |
2563 | 2705 | |
2564 | 2706 | // Add this afterward... |
2565 | - if ($code_match[1] == 'add' || $code_match[1] == 'add after') |
|
2566 | - $replace_with = $working_search . "\n" . $replace_with; |
|
2707 | + if ($code_match[1] == 'add' || $code_match[1] == 'add after') { |
|
2708 | + $replace_with = $working_search . "\n" . $replace_with; |
|
2709 | + } |
|
2567 | 2710 | // Add this beforehand. |
2568 | - elseif ($code_match[1] == 'before' || $code_match[1] == 'add before' || $code_match[1] == 'above' || $code_match[1] == 'add above') |
|
2569 | - $replace_with .= "\n" . $working_search; |
|
2711 | + elseif ($code_match[1] == 'before' || $code_match[1] == 'add before' || $code_match[1] == 'above' || $code_match[1] == 'add above') { |
|
2712 | + $replace_with .= "\n" . $working_search; |
|
2713 | + } |
|
2570 | 2714 | // Otherwise.. replace with $replace_with ;). |
2571 | 2715 | } |
2572 | 2716 | |
@@ -2629,29 +2773,32 @@ discard block |
||
2629 | 2773 | { |
2630 | 2774 | package_chmod($working_file); |
2631 | 2775 | |
2632 | - if (!is_writable($working_file)) |
|
2633 | - $actions[] = array( |
|
2776 | + if (!is_writable($working_file)) { |
|
2777 | + $actions[] = array( |
|
2634 | 2778 | 'type' => 'chmod', |
2635 | 2779 | 'filename' => $working_file |
2636 | 2780 | ); |
2781 | + } |
|
2637 | 2782 | |
2638 | 2783 | if (!$testing && !empty($modSettings['package_make_backups']) && file_exists($working_file)) |
2639 | 2784 | { |
2640 | - if (basename($working_file) == 'Settings.php') |
|
2641 | - @copy($working_file, dirname($working_file) . '/Settings_bak.php'); |
|
2642 | - else |
|
2643 | - @copy($working_file, $working_file . '~'); |
|
2785 | + if (basename($working_file) == 'Settings.php') { |
|
2786 | + @copy($working_file, dirname($working_file) . '/Settings_bak.php'); |
|
2787 | + } else { |
|
2788 | + @copy($working_file, $working_file . '~'); |
|
2789 | + } |
|
2644 | 2790 | } |
2645 | 2791 | |
2646 | 2792 | package_put_contents($working_file, $working_data, $testing); |
2647 | 2793 | } |
2648 | 2794 | |
2649 | - if ($working_file !== null) |
|
2650 | - $actions[] = array( |
|
2795 | + if ($working_file !== null) { |
|
2796 | + $actions[] = array( |
|
2651 | 2797 | 'type' => 'saved', |
2652 | 2798 | 'filename' => $working_file, |
2653 | 2799 | 'is_custom' => $is_custom, |
2654 | 2800 | ); |
2801 | + } |
|
2655 | 2802 | |
2656 | 2803 | $actions[] = array( |
2657 | 2804 | 'type' => 'result', |
@@ -2677,17 +2824,19 @@ discard block |
||
2677 | 2824 | $mem_check = setMemoryLimit('128M'); |
2678 | 2825 | |
2679 | 2826 | // Windows doesn't seem to care about the memory_limit. |
2680 | - if (!empty($modSettings['package_disable_cache']) || $mem_check || stripos(PHP_OS, 'win') !== false) |
|
2681 | - $package_cache = array(); |
|
2682 | - else |
|
2683 | - $package_cache = false; |
|
2827 | + if (!empty($modSettings['package_disable_cache']) || $mem_check || stripos(PHP_OS, 'win') !== false) { |
|
2828 | + $package_cache = array(); |
|
2829 | + } else { |
|
2830 | + $package_cache = false; |
|
2831 | + } |
|
2684 | 2832 | } |
2685 | 2833 | |
2686 | - if (strpos($filename, 'Packages/') !== false || $package_cache === false || !isset($package_cache[$filename])) |
|
2687 | - return file_get_contents($filename); |
|
2688 | - else |
|
2689 | - return $package_cache[$filename]; |
|
2690 | -} |
|
2834 | + if (strpos($filename, 'Packages/') !== false || $package_cache === false || !isset($package_cache[$filename])) { |
|
2835 | + return file_get_contents($filename); |
|
2836 | + } else { |
|
2837 | + return $package_cache[$filename]; |
|
2838 | + } |
|
2839 | + } |
|
2691 | 2840 | |
2692 | 2841 | /** |
2693 | 2842 | * Writes data to a file, almost exactly like the file_put_contents() function. |
@@ -2710,19 +2859,22 @@ discard block |
||
2710 | 2859 | // Try to increase the memory limit - we don't want to run out of ram! |
2711 | 2860 | $mem_check = setMemoryLimit('128M'); |
2712 | 2861 | |
2713 | - if (!empty($modSettings['package_disable_cache']) || $mem_check || stripos(PHP_OS, 'win') !== false) |
|
2714 | - $package_cache = array(); |
|
2715 | - else |
|
2716 | - $package_cache = false; |
|
2862 | + if (!empty($modSettings['package_disable_cache']) || $mem_check || stripos(PHP_OS, 'win') !== false) { |
|
2863 | + $package_cache = array(); |
|
2864 | + } else { |
|
2865 | + $package_cache = false; |
|
2866 | + } |
|
2717 | 2867 | } |
2718 | 2868 | |
2719 | - if (isset($package_ftp)) |
|
2720 | - $ftp_file = strtr($filename, array($_SESSION['pack_ftp']['root'] => '')); |
|
2869 | + if (isset($package_ftp)) { |
|
2870 | + $ftp_file = strtr($filename, array($_SESSION['pack_ftp']['root'] => '')); |
|
2871 | + } |
|
2721 | 2872 | |
2722 | - if (!file_exists($filename) && isset($package_ftp)) |
|
2723 | - $package_ftp->create_file($ftp_file); |
|
2724 | - elseif (!file_exists($filename)) |
|
2725 | - @touch($filename); |
|
2873 | + if (!file_exists($filename) && isset($package_ftp)) { |
|
2874 | + $package_ftp->create_file($ftp_file); |
|
2875 | + } elseif (!file_exists($filename)) { |
|
2876 | + @touch($filename); |
|
2877 | + } |
|
2726 | 2878 | |
2727 | 2879 | package_chmod($filename); |
2728 | 2880 | |
@@ -2731,22 +2883,23 @@ discard block |
||
2731 | 2883 | $fp = @fopen($filename, in_array(substr($filename, -3), $text_filetypes) ? 'w' : 'wb'); |
2732 | 2884 | |
2733 | 2885 | // We should show an error message or attempt a rollback, no? |
2734 | - if (!$fp) |
|
2735 | - return false; |
|
2886 | + if (!$fp) { |
|
2887 | + return false; |
|
2888 | + } |
|
2736 | 2889 | |
2737 | 2890 | fwrite($fp, $data); |
2738 | 2891 | fclose($fp); |
2739 | - } |
|
2740 | - elseif (strpos($filename, 'Packages/') !== false || $package_cache === false) |
|
2741 | - return strlen($data); |
|
2742 | - else |
|
2892 | + } elseif (strpos($filename, 'Packages/') !== false || $package_cache === false) { |
|
2893 | + return strlen($data); |
|
2894 | + } else |
|
2743 | 2895 | { |
2744 | 2896 | $package_cache[$filename] = $data; |
2745 | 2897 | |
2746 | 2898 | // Permission denied, eh? |
2747 | 2899 | $fp = @fopen($filename, 'r+'); |
2748 | - if (!$fp) |
|
2749 | - return false; |
|
2900 | + if (!$fp) { |
|
2901 | + return false; |
|
2902 | + } |
|
2750 | 2903 | fclose($fp); |
2751 | 2904 | } |
2752 | 2905 | |
@@ -2763,19 +2916,22 @@ discard block |
||
2763 | 2916 | global $package_ftp, $package_cache; |
2764 | 2917 | static $text_filetypes = array('php', 'txt', '.js', 'css', 'vbs', 'tml', 'htm'); |
2765 | 2918 | |
2766 | - if (empty($package_cache)) |
|
2767 | - return; |
|
2919 | + if (empty($package_cache)) { |
|
2920 | + return; |
|
2921 | + } |
|
2768 | 2922 | |
2769 | 2923 | // First, let's check permissions! |
2770 | 2924 | foreach ($package_cache as $filename => $data) |
2771 | 2925 | { |
2772 | - if (isset($package_ftp)) |
|
2773 | - $ftp_file = strtr($filename, array($_SESSION['pack_ftp']['root'] => '')); |
|
2926 | + if (isset($package_ftp)) { |
|
2927 | + $ftp_file = strtr($filename, array($_SESSION['pack_ftp']['root'] => '')); |
|
2928 | + } |
|
2774 | 2929 | |
2775 | - if (!file_exists($filename) && isset($package_ftp)) |
|
2776 | - $package_ftp->create_file($ftp_file); |
|
2777 | - elseif (!file_exists($filename)) |
|
2778 | - @touch($filename); |
|
2930 | + if (!file_exists($filename) && isset($package_ftp)) { |
|
2931 | + $package_ftp->create_file($ftp_file); |
|
2932 | + } elseif (!file_exists($filename)) { |
|
2933 | + @touch($filename); |
|
2934 | + } |
|
2779 | 2935 | |
2780 | 2936 | $result = package_chmod($filename); |
2781 | 2937 | |
@@ -2822,8 +2978,9 @@ discard block |
||
2822 | 2978 | { |
2823 | 2979 | global $package_ftp; |
2824 | 2980 | |
2825 | - if (file_exists($filename) && is_writable($filename) && $perm_state == 'writable') |
|
2826 | - return true; |
|
2981 | + if (file_exists($filename) && is_writable($filename) && $perm_state == 'writable') { |
|
2982 | + return true; |
|
2983 | + } |
|
2827 | 2984 | |
2828 | 2985 | // Start off checking without FTP. |
2829 | 2986 | if (!isset($package_ftp) || $package_ftp === false) |
@@ -2845,8 +3002,7 @@ discard block |
||
2845 | 3002 | |
2846 | 3003 | // Keep track of the writable status here. |
2847 | 3004 | $file_permissions = @fileperms($chmod_file); |
2848 | - } |
|
2849 | - else |
|
3005 | + } else |
|
2850 | 3006 | { |
2851 | 3007 | // This looks odd, but it's an attempt to work around PHP suExec. |
2852 | 3008 | if (!file_exists($chmod_file) && $perm_state == 'writable') |
@@ -2856,24 +3012,28 @@ discard block |
||
2856 | 3012 | mktree(dirname($chmod_file), 0755); |
2857 | 3013 | @touch($chmod_file); |
2858 | 3014 | smf_chmod($chmod_file, 0755); |
3015 | + } else { |
|
3016 | + $file_permissions = @fileperms($chmod_file); |
|
2859 | 3017 | } |
2860 | - else |
|
2861 | - $file_permissions = @fileperms($chmod_file); |
|
2862 | 3018 | } |
2863 | 3019 | |
2864 | 3020 | // This looks odd, but it's another attempt to work around PHP suExec. |
2865 | - if ($perm_state != 'writable') |
|
2866 | - smf_chmod($chmod_file, $perm_state == 'execute' ? 0755 : 0644); |
|
2867 | - else |
|
3021 | + if ($perm_state != 'writable') { |
|
3022 | + smf_chmod($chmod_file, $perm_state == 'execute' ? 0755 : 0644); |
|
3023 | + } else |
|
2868 | 3024 | { |
2869 | - if (!@is_writable($chmod_file)) |
|
2870 | - smf_chmod($chmod_file, 0755); |
|
2871 | - if (!@is_writable($chmod_file)) |
|
2872 | - smf_chmod($chmod_file, 0777); |
|
2873 | - if (!@is_writable(dirname($chmod_file))) |
|
2874 | - smf_chmod($chmod_file, 0755); |
|
2875 | - if (!@is_writable(dirname($chmod_file))) |
|
2876 | - smf_chmod($chmod_file, 0777); |
|
3025 | + if (!@is_writable($chmod_file)) { |
|
3026 | + smf_chmod($chmod_file, 0755); |
|
3027 | + } |
|
3028 | + if (!@is_writable($chmod_file)) { |
|
3029 | + smf_chmod($chmod_file, 0777); |
|
3030 | + } |
|
3031 | + if (!@is_writable(dirname($chmod_file))) { |
|
3032 | + smf_chmod($chmod_file, 0755); |
|
3033 | + } |
|
3034 | + if (!@is_writable(dirname($chmod_file))) { |
|
3035 | + smf_chmod($chmod_file, 0777); |
|
3036 | + } |
|
2877 | 3037 | } |
2878 | 3038 | |
2879 | 3039 | // The ultimate writable test. |
@@ -2882,20 +3042,22 @@ discard block |
||
2882 | 3042 | $fp = is_dir($chmod_file) ? @opendir($chmod_file) : @fopen($chmod_file, 'rb'); |
2883 | 3043 | if (@is_writable($chmod_file) && $fp) |
2884 | 3044 | { |
2885 | - if (!is_dir($chmod_file)) |
|
2886 | - fclose($fp); |
|
2887 | - else |
|
2888 | - closedir($fp); |
|
3045 | + if (!is_dir($chmod_file)) { |
|
3046 | + fclose($fp); |
|
3047 | + } else { |
|
3048 | + closedir($fp); |
|
3049 | + } |
|
2889 | 3050 | |
2890 | 3051 | // It worked! |
2891 | - if ($track_change) |
|
2892 | - $_SESSION['pack_ftp']['original_perms'][$chmod_file] = $file_permissions; |
|
3052 | + if ($track_change) { |
|
3053 | + $_SESSION['pack_ftp']['original_perms'][$chmod_file] = $file_permissions; |
|
3054 | + } |
|
2893 | 3055 | |
2894 | 3056 | return true; |
2895 | 3057 | } |
3058 | + } elseif ($perm_state != 'writable' && isset($_SESSION['pack_ftp']['original_perms'][$chmod_file])) { |
|
3059 | + unset($_SESSION['pack_ftp']['original_perms'][$chmod_file]); |
|
2896 | 3060 | } |
2897 | - elseif ($perm_state != 'writable' && isset($_SESSION['pack_ftp']['original_perms'][$chmod_file])) |
|
2898 | - unset($_SESSION['pack_ftp']['original_perms'][$chmod_file]); |
|
2899 | 3061 | } |
2900 | 3062 | |
2901 | 3063 | // If we're here we're a failure. |
@@ -2914,31 +3076,33 @@ discard block |
||
2914 | 3076 | mktree(dirname($filename), 0755); |
2915 | 3077 | $package_ftp->create_file($ftp_file); |
2916 | 3078 | $package_ftp->chmod($ftp_file, 0755); |
3079 | + } else { |
|
3080 | + $file_permissions = @fileperms($filename); |
|
2917 | 3081 | } |
2918 | - else |
|
2919 | - $file_permissions = @fileperms($filename); |
|
2920 | 3082 | |
2921 | 3083 | if ($perm_state != 'writable') |
2922 | 3084 | { |
2923 | 3085 | $package_ftp->chmod($ftp_file, $perm_state == 'execute' ? 0755 : 0644); |
2924 | - } |
|
2925 | - else |
|
3086 | + } else |
|
2926 | 3087 | { |
2927 | - if (!@is_writable($filename)) |
|
2928 | - $package_ftp->chmod($ftp_file, 0777); |
|
2929 | - if (!@is_writable(dirname($filename))) |
|
2930 | - $package_ftp->chmod(dirname($ftp_file), 0777); |
|
3088 | + if (!@is_writable($filename)) { |
|
3089 | + $package_ftp->chmod($ftp_file, 0777); |
|
3090 | + } |
|
3091 | + if (!@is_writable(dirname($filename))) { |
|
3092 | + $package_ftp->chmod(dirname($ftp_file), 0777); |
|
3093 | + } |
|
2931 | 3094 | } |
2932 | 3095 | |
2933 | 3096 | if (@is_writable($filename)) |
2934 | 3097 | { |
2935 | - if ($track_change) |
|
2936 | - $_SESSION['pack_ftp']['original_perms'][$filename] = $file_permissions; |
|
3098 | + if ($track_change) { |
|
3099 | + $_SESSION['pack_ftp']['original_perms'][$filename] = $file_permissions; |
|
3100 | + } |
|
2937 | 3101 | |
2938 | 3102 | return true; |
3103 | + } elseif ($perm_state != 'writable' && isset($_SESSION['pack_ftp']['original_perms'][$filename])) { |
|
3104 | + unset($_SESSION['pack_ftp']['original_perms'][$filename]); |
|
2939 | 3105 | } |
2940 | - elseif ($perm_state != 'writable' && isset($_SESSION['pack_ftp']['original_perms'][$filename])) |
|
2941 | - unset($_SESSION['pack_ftp']['original_perms'][$filename]); |
|
2942 | 3106 | } |
2943 | 3107 | |
2944 | 3108 | // Oh dear, we failed if we get here. |
@@ -2956,11 +3120,13 @@ discard block |
||
2956 | 3120 | $n = strlen($pass); |
2957 | 3121 | |
2958 | 3122 | $salt = session_id(); |
2959 | - while (strlen($salt) < $n) |
|
2960 | - $salt .= session_id(); |
|
3123 | + while (strlen($salt) < $n) { |
|
3124 | + $salt .= session_id(); |
|
3125 | + } |
|
2961 | 3126 | |
2962 | - for ($i = 0; $i < $n; $i++) |
|
2963 | - $pass{$i} = chr(ord($pass{$i}) ^ (ord($salt{$i}) - 32)); |
|
3127 | + for ($i = 0; $i < $n; $i++) { |
|
3128 | + $pass{$i} = chr(ord($pass{$i}) ^ (ord($salt{$i}) - 32)); |
|
3129 | + } |
|
2964 | 3130 | |
2965 | 3131 | return $pass; |
2966 | 3132 | } |
@@ -2979,8 +3145,9 @@ discard block |
||
2979 | 3145 | $base_files = array('index.php', 'SSI.php', 'agreement.txt', 'cron.php', 'ssi_examples.php', 'ssi_examples.shtml', 'subscriptions.php'); |
2980 | 3146 | foreach ($base_files as $file) |
2981 | 3147 | { |
2982 | - if (file_exists($boarddir . '/' . $file)) |
|
2983 | - $files[empty($_REQUEST['use_full_paths']) ? $file : $boarddir . '/' . $file] = $boarddir . '/' . $file; |
|
3148 | + if (file_exists($boarddir . '/' . $file)) { |
|
3149 | + $files[empty($_REQUEST['use_full_paths']) ? $file : $boarddir . '/' . $file] = $boarddir . '/' . $file; |
|
3150 | + } |
|
2984 | 3151 | } |
2985 | 3152 | |
2986 | 3153 | $dirs = array( |
@@ -2997,8 +3164,9 @@ discard block |
||
2997 | 3164 | 'theme_dir' => 'theme_dir', |
2998 | 3165 | ) |
2999 | 3166 | ); |
3000 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
3001 | - $dirs[$row['value']] = empty($_REQUEST['use_full_paths']) ? 'Themes/' . basename($row['value']) . '/' : strtr($row['value'] . '/', '\\', '/'); |
|
3167 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
3168 | + $dirs[$row['value']] = empty($_REQUEST['use_full_paths']) ? 'Themes/' . basename($row['value']) . '/' : strtr($row['value'] . '/', '\\', '/'); |
|
3169 | + } |
|
3002 | 3170 | $smcFunc['db_free_result']($request); |
3003 | 3171 | |
3004 | 3172 | try |
@@ -3013,11 +3181,13 @@ discard block |
||
3013 | 3181 | |
3014 | 3182 | foreach ($iter as $entry => $dir) |
3015 | 3183 | { |
3016 | - if ($dir->isDir()) |
|
3017 | - continue; |
|
3184 | + if ($dir->isDir()) { |
|
3185 | + continue; |
|
3186 | + } |
|
3018 | 3187 | |
3019 | - if (preg_match('~^(\.{1,2}|CVS|backup.*|help|images|.*\~)$~', $entry) != 0) |
|
3020 | - continue; |
|
3188 | + if (preg_match('~^(\.{1,2}|CVS|backup.*|help|images|.*\~)$~', $entry) != 0) { |
|
3189 | + continue; |
|
3190 | + } |
|
3021 | 3191 | |
3022 | 3192 | $files[empty($_REQUEST['use_full_paths']) ? str_replace(realpath($boarddir), '', $entry) : $entry] = $entry; |
3023 | 3193 | } |
@@ -3025,26 +3195,30 @@ discard block |
||
3025 | 3195 | $obj = new ArrayObject($files); |
3026 | 3196 | $iterator = $obj->getIterator(); |
3027 | 3197 | |
3028 | - if (!file_exists($packagesdir . '/backups')) |
|
3029 | - mktree($packagesdir . '/backups', 0777); |
|
3030 | - if (!is_writable($packagesdir . '/backups')) |
|
3031 | - package_chmod($packagesdir . '/backups'); |
|
3198 | + if (!file_exists($packagesdir . '/backups')) { |
|
3199 | + mktree($packagesdir . '/backups', 0777); |
|
3200 | + } |
|
3201 | + if (!is_writable($packagesdir . '/backups')) { |
|
3202 | + package_chmod($packagesdir . '/backups'); |
|
3203 | + } |
|
3032 | 3204 | $output_file = $packagesdir . '/backups/' . strftime('%Y-%m-%d_') . preg_replace('~[$\\\\/:<>|?*"\']~', '', $id); |
3033 | 3205 | $output_ext = '.tar'; |
3034 | 3206 | |
3035 | 3207 | if (file_exists($output_file . $output_ext)) |
3036 | 3208 | { |
3037 | 3209 | $i = 2; |
3038 | - while (file_exists($output_file . '_' . $i . $output_ext)) |
|
3039 | - $i++; |
|
3210 | + while (file_exists($output_file . '_' . $i . $output_ext)) { |
|
3211 | + $i++; |
|
3212 | + } |
|
3040 | 3213 | $output_file = $output_file . '_' . $i . $output_ext; |
3214 | + } else { |
|
3215 | + $output_file .= $output_ext; |
|
3041 | 3216 | } |
3042 | - else |
|
3043 | - $output_file .= $output_ext; |
|
3044 | 3217 | |
3045 | 3218 | @set_time_limit(300); |
3046 | - if (function_exists('apache_reset_timeout')) |
|
3047 | - @apache_reset_timeout(); |
|
3219 | + if (function_exists('apache_reset_timeout')) { |
|
3220 | + @apache_reset_timeout(); |
|
3221 | + } |
|
3048 | 3222 | |
3049 | 3223 | $a = new PharData($output_file); |
3050 | 3224 | $a->buildFromIterator($iterator); |
@@ -3056,8 +3230,7 @@ discard block |
||
3056 | 3230 | */ |
3057 | 3231 | unset($a); |
3058 | 3232 | unlink($output_file); |
3059 | - } |
|
3060 | - catch (Exception $e) |
|
3233 | + } catch (Exception $e) |
|
3061 | 3234 | { |
3062 | 3235 | log_error($e->getMessage(), 'backup'); |
3063 | 3236 | |
@@ -3089,32 +3262,35 @@ discard block |
||
3089 | 3262 | preg_match('~^(http|ftp)(s)?://([^/:]+)(:(\d+))?(.+)$~', $url, $match); |
3090 | 3263 | |
3091 | 3264 | // An FTP url. We should try connecting and RETRieving it... |
3092 | - if (empty($match[1])) |
|
3093 | - return false; |
|
3094 | - elseif ($match[1] == 'ftp') |
|
3265 | + if (empty($match[1])) { |
|
3266 | + return false; |
|
3267 | + } elseif ($match[1] == 'ftp') |
|
3095 | 3268 | { |
3096 | 3269 | // Include the file containing the ftp_connection class. |
3097 | 3270 | require_once($sourcedir . '/Class-Package.php'); |
3098 | 3271 | |
3099 | 3272 | // Establish a connection and attempt to enable passive mode. |
3100 | 3273 | $ftp = new ftp_connection(($match[2] ? 'ssl://' : '') . $match[3], empty($match[5]) ? 21 : $match[5], 'anonymous', $webmaster_email); |
3101 | - if ($ftp->error !== false || !$ftp->passive()) |
|
3102 | - return false; |
|
3274 | + if ($ftp->error !== false || !$ftp->passive()) { |
|
3275 | + return false; |
|
3276 | + } |
|
3103 | 3277 | |
3104 | 3278 | // I want that one *points*! |
3105 | 3279 | fwrite($ftp->connection, 'RETR ' . $match[6] . "\r\n"); |
3106 | 3280 | |
3107 | 3281 | // Since passive mode worked (or we would have returned already!) open the connection. |
3108 | 3282 | $fp = @fsockopen($ftp->pasv['ip'], $ftp->pasv['port'], $err, $err, 5); |
3109 | - if (!$fp) |
|
3110 | - return false; |
|
3283 | + if (!$fp) { |
|
3284 | + return false; |
|
3285 | + } |
|
3111 | 3286 | |
3112 | 3287 | // The server should now say something in acknowledgement. |
3113 | 3288 | $ftp->check_response(150); |
3114 | 3289 | |
3115 | 3290 | $data = ''; |
3116 | - while (!feof($fp)) |
|
3117 | - $data .= fread($fp, 4096); |
|
3291 | + while (!feof($fp)) { |
|
3292 | + $data .= fread($fp, 4096); |
|
3293 | + } |
|
3118 | 3294 | fclose($fp); |
3119 | 3295 | |
3120 | 3296 | // All done, right? Good. |
@@ -3131,22 +3307,25 @@ discard block |
||
3131 | 3307 | $fetch_data->get_url_data($url, $post_data); |
3132 | 3308 | |
3133 | 3309 | // no errors and a 200 result, then we have a good dataset, well we at least have data ;) |
3134 | - if ($fetch_data->result('code') == 200 && !$fetch_data->result('error')) |
|
3135 | - $data = $fetch_data->result('body'); |
|
3136 | - else |
|
3137 | - return false; |
|
3310 | + if ($fetch_data->result('code') == 200 && !$fetch_data->result('error')) { |
|
3311 | + $data = $fetch_data->result('body'); |
|
3312 | + } else { |
|
3313 | + return false; |
|
3314 | + } |
|
3138 | 3315 | } |
3139 | 3316 | // This is more likely; a standard HTTP URL. |
3140 | 3317 | elseif (isset($match[1]) && $match[1] == 'http') |
3141 | 3318 | { |
3142 | - if ($keep_alive && $match[3] == $keep_alive_dom) |
|
3143 | - $fp = $keep_alive_fp; |
|
3319 | + if ($keep_alive && $match[3] == $keep_alive_dom) { |
|
3320 | + $fp = $keep_alive_fp; |
|
3321 | + } |
|
3144 | 3322 | if (empty($fp)) |
3145 | 3323 | { |
3146 | 3324 | // Open the socket on the port we want... |
3147 | 3325 | $fp = @fsockopen(($match[2] ? 'ssl://' : '') . $match[3], empty($match[5]) ? ($match[2] ? 443 : 80) : $match[5], $err, $err, 5); |
3148 | - if (!$fp) |
|
3149 | - return false; |
|
3326 | + if (!$fp) { |
|
3327 | + return false; |
|
3328 | + } |
|
3150 | 3329 | } |
3151 | 3330 | |
3152 | 3331 | if ($keep_alive) |
@@ -3161,20 +3340,21 @@ discard block |
||
3161 | 3340 | fwrite($fp, 'GET ' . ($match[6] !== '/' ? str_replace(' ', '%20', $match[6]) : '') . ' HTTP/1.0' . "\r\n"); |
3162 | 3341 | fwrite($fp, 'Host: ' . $match[3] . (empty($match[5]) ? ($match[2] ? ':443' : '') : ':' . $match[5]) . "\r\n"); |
3163 | 3342 | fwrite($fp, 'User-Agent: PHP/SMF' . "\r\n"); |
3164 | - if ($keep_alive) |
|
3165 | - fwrite($fp, 'Connection: Keep-Alive' . "\r\n\r\n"); |
|
3166 | - else |
|
3167 | - fwrite($fp, 'Connection: close' . "\r\n\r\n"); |
|
3168 | - } |
|
3169 | - else |
|
3343 | + if ($keep_alive) { |
|
3344 | + fwrite($fp, 'Connection: Keep-Alive' . "\r\n\r\n"); |
|
3345 | + } else { |
|
3346 | + fwrite($fp, 'Connection: close' . "\r\n\r\n"); |
|
3347 | + } |
|
3348 | + } else |
|
3170 | 3349 | { |
3171 | 3350 | fwrite($fp, 'POST ' . ($match[6] !== '/' ? $match[6] : '') . ' HTTP/1.0' . "\r\n"); |
3172 | 3351 | fwrite($fp, 'Host: ' . $match[3] . (empty($match[5]) ? ($match[2] ? ':443' : '') : ':' . $match[5]) . "\r\n"); |
3173 | 3352 | fwrite($fp, 'User-Agent: PHP/SMF' . "\r\n"); |
3174 | - if ($keep_alive) |
|
3175 | - fwrite($fp, 'Connection: Keep-Alive' . "\r\n"); |
|
3176 | - else |
|
3177 | - fwrite($fp, 'Connection: close' . "\r\n"); |
|
3353 | + if ($keep_alive) { |
|
3354 | + fwrite($fp, 'Connection: Keep-Alive' . "\r\n"); |
|
3355 | + } else { |
|
3356 | + fwrite($fp, 'Connection: close' . "\r\n"); |
|
3357 | + } |
|
3178 | 3358 | fwrite($fp, 'Content-Type: application/x-www-form-urlencoded' . "\r\n"); |
3179 | 3359 | fwrite($fp, 'Content-Length: ' . strlen($post_data) . "\r\n\r\n"); |
3180 | 3360 | fwrite($fp, $post_data); |
@@ -3187,30 +3367,33 @@ discard block |
||
3187 | 3367 | { |
3188 | 3368 | $header = ''; |
3189 | 3369 | $location = ''; |
3190 | - while (!feof($fp) && trim($header = fgets($fp, 4096)) != '') |
|
3191 | - if (strpos($header, 'Location:') !== false) |
|
3370 | + while (!feof($fp) && trim($header = fgets($fp, 4096)) != '') { |
|
3371 | + if (strpos($header, 'Location:') !== false) |
|
3192 | 3372 | $location = trim(substr($header, strpos($header, ':') + 1)); |
3373 | + } |
|
3193 | 3374 | |
3194 | - if (empty($location)) |
|
3195 | - return false; |
|
3196 | - else |
|
3375 | + if (empty($location)) { |
|
3376 | + return false; |
|
3377 | + } else |
|
3197 | 3378 | { |
3198 | - if (!$keep_alive) |
|
3199 | - fclose($fp); |
|
3379 | + if (!$keep_alive) { |
|
3380 | + fclose($fp); |
|
3381 | + } |
|
3200 | 3382 | return fetch_web_data($location, $post_data, $keep_alive, $redirection_level + 1); |
3201 | 3383 | } |
3202 | 3384 | } |
3203 | 3385 | |
3204 | 3386 | // Make sure we get a 200 OK. |
3205 | - elseif (preg_match('~^HTTP/\S+\s+20[01]~i', $response) === 0) |
|
3206 | - return false; |
|
3387 | + elseif (preg_match('~^HTTP/\S+\s+20[01]~i', $response) === 0) { |
|
3388 | + return false; |
|
3389 | + } |
|
3207 | 3390 | |
3208 | 3391 | // Skip the headers... |
3209 | 3392 | while (!feof($fp) && trim($header = fgets($fp, 4096)) != '') |
3210 | 3393 | { |
3211 | - if (preg_match('~content-length:\s*(\d+)~i', $header, $match) != 0) |
|
3212 | - $content_length = $match[1]; |
|
3213 | - elseif (preg_match('~connection:\s*close~i', $header) != 0) |
|
3394 | + if (preg_match('~content-length:\s*(\d+)~i', $header, $match) != 0) { |
|
3395 | + $content_length = $match[1]; |
|
3396 | + } elseif (preg_match('~connection:\s*close~i', $header) != 0) |
|
3214 | 3397 | { |
3215 | 3398 | $keep_alive_dom = null; |
3216 | 3399 | $keep_alive = false; |
@@ -3222,19 +3405,20 @@ discard block |
||
3222 | 3405 | $data = ''; |
3223 | 3406 | if (isset($content_length)) |
3224 | 3407 | { |
3225 | - while (!feof($fp) && strlen($data) < $content_length) |
|
3226 | - $data .= fread($fp, $content_length - strlen($data)); |
|
3227 | - } |
|
3228 | - else |
|
3408 | + while (!feof($fp) && strlen($data) < $content_length) { |
|
3409 | + $data .= fread($fp, $content_length - strlen($data)); |
|
3410 | + } |
|
3411 | + } else |
|
3229 | 3412 | { |
3230 | - while (!feof($fp)) |
|
3231 | - $data .= fread($fp, 4096); |
|
3413 | + while (!feof($fp)) { |
|
3414 | + $data .= fread($fp, 4096); |
|
3415 | + } |
|
3232 | 3416 | } |
3233 | 3417 | |
3234 | - if (!$keep_alive) |
|
3235 | - fclose($fp); |
|
3236 | - } |
|
3237 | - else |
|
3418 | + if (!$keep_alive) { |
|
3419 | + fclose($fp); |
|
3420 | + } |
|
3421 | + } else |
|
3238 | 3422 | { |
3239 | 3423 | // Umm, this shouldn't happen? |
3240 | 3424 | trigger_error('fetch_web_data(): Bad URL', E_USER_NOTICE); |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 3 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * Redirect to the user help ;). |
@@ -95,12 +96,13 @@ discard block |
||
95 | 96 | ); |
96 | 97 | |
97 | 98 | // Have we got a localized one? |
98 | - if (file_exists($boarddir . '/agreement.' . $user_info['language'] . '.txt')) |
|
99 | - $context['agreement'] = parse_bbc(file_get_contents($boarddir . '/agreement.' . $user_info['language'] . '.txt'), true, 'agreement_' . $user_info['language']); |
|
100 | - elseif (file_exists($boarddir . '/agreement.txt')) |
|
101 | - $context['agreement'] = parse_bbc(file_get_contents($boarddir . '/agreement.txt'), true, 'agreement'); |
|
102 | - else |
|
103 | - $context['agreement'] = ''; |
|
99 | + if (file_exists($boarddir . '/agreement.' . $user_info['language'] . '.txt')) { |
|
100 | + $context['agreement'] = parse_bbc(file_get_contents($boarddir . '/agreement.' . $user_info['language'] . '.txt'), true, 'agreement_' . $user_info['language']); |
|
101 | + } elseif (file_exists($boarddir . '/agreement.txt')) { |
|
102 | + $context['agreement'] = parse_bbc(file_get_contents($boarddir . '/agreement.txt'), true, 'agreement'); |
|
103 | + } else { |
|
104 | + $context['agreement'] = ''; |
|
105 | + } |
|
104 | 106 | |
105 | 107 | // Nothing to show, so let's get out of here |
106 | 108 | if (empty($context['agreement'])) |
@@ -128,18 +130,21 @@ discard block |
||
128 | 130 | { |
129 | 131 | global $txt, $helptxt, $context, $scripturl; |
130 | 132 | |
131 | - if (!isset($_GET['help']) || !is_string($_GET['help'])) |
|
132 | - fatal_lang_error('no_access', false); |
|
133 | + if (!isset($_GET['help']) || !is_string($_GET['help'])) { |
|
134 | + fatal_lang_error('no_access', false); |
|
135 | + } |
|
133 | 136 | |
134 | - if (!isset($helptxt)) |
|
135 | - $helptxt = array(); |
|
137 | + if (!isset($helptxt)) { |
|
138 | + $helptxt = array(); |
|
139 | + } |
|
136 | 140 | |
137 | 141 | // Load the admin help language file and template. |
138 | 142 | loadLanguage('Help'); |
139 | 143 | |
140 | 144 | // Permission specific help? |
141 | - if (isset($_GET['help']) && substr($_GET['help'], 0, 14) == 'permissionhelp') |
|
142 | - loadLanguage('ManagePermissions'); |
|
145 | + if (isset($_GET['help']) && substr($_GET['help'], 0, 14) == 'permissionhelp') { |
|
146 | + loadLanguage('ManagePermissions'); |
|
147 | + } |
|
143 | 148 | |
144 | 149 | loadTemplate('Help'); |
145 | 150 | |
@@ -154,16 +159,18 @@ discard block |
||
154 | 159 | $context['sub_template'] = 'popup'; |
155 | 160 | |
156 | 161 | // What help string should be used? |
157 | - if (isset($helptxt[$_GET['help']])) |
|
158 | - $context['help_text'] = $helptxt[$_GET['help']]; |
|
159 | - elseif (isset($txt[$_GET['help']])) |
|
160 | - $context['help_text'] = $txt[$_GET['help']]; |
|
161 | - else |
|
162 | - $context['help_text'] = $_GET['help']; |
|
162 | + if (isset($helptxt[$_GET['help']])) { |
|
163 | + $context['help_text'] = $helptxt[$_GET['help']]; |
|
164 | + } elseif (isset($txt[$_GET['help']])) { |
|
165 | + $context['help_text'] = $txt[$_GET['help']]; |
|
166 | + } else { |
|
167 | + $context['help_text'] = $_GET['help']; |
|
168 | + } |
|
163 | 169 | |
164 | 170 | // Does this text contain a link that we should fill in? |
165 | - if (preg_match('~%([0-9]+\$)?s\?~', $context['help_text'], $match)) |
|
166 | - $context['help_text'] = sprintf($context['help_text'], $scripturl, $context['session_id'], $context['session_var']); |
|
167 | -} |
|
171 | + if (preg_match('~%([0-9]+\$)?s\?~', $context['help_text'], $match)) { |
|
172 | + $context['help_text'] = sprintf($context['help_text'], $scripturl, $context['session_id'], $context['session_var']); |
|
173 | + } |
|
174 | + } |
|
168 | 175 | |
169 | 176 | ?> |
170 | 177 | \ No newline at end of file |
@@ -11,8 +11,9 @@ discard block |
||
11 | 11 | * @version 2.1 Beta 3 |
12 | 12 | */ |
13 | 13 | |
14 | -if (!defined('SMF')) |
|
14 | +if (!defined('SMF')) { |
|
15 | 15 | die('Hacking attempt...'); |
16 | +} |
|
16 | 17 | |
17 | 18 | /** |
18 | 19 | * Our Cache API class |
@@ -43,8 +44,9 @@ discard block |
||
43 | 44 | { |
44 | 45 | $supported = is_writable($this->cachedir); |
45 | 46 | |
46 | - if ($test) |
|
47 | - return $supported; |
|
47 | + if ($test) { |
|
48 | + return $supported; |
|
49 | + } |
|
48 | 50 | return parent::isSupported() && $supported; |
49 | 51 | } |
50 | 52 | |
@@ -61,11 +63,13 @@ discard block |
||
61 | 63 | { |
62 | 64 | // Work around Zend's opcode caching (PHP 5.5+), they would cache older files for a couple of seconds |
63 | 65 | // causing newer files to take effect a while later. |
64 | - if (function_exists('opcache_invalidate')) |
|
65 | - opcache_invalidate($cachedir . '/data_' . $key . '.php', true); |
|
66 | + if (function_exists('opcache_invalidate')) { |
|
67 | + opcache_invalidate($cachedir . '/data_' . $key . '.php', true); |
|
68 | + } |
|
66 | 69 | |
67 | - if (function_exists('apc_delete_file')) |
|
68 | - @apc_delete_file($cachedir . '/data_' . $key . '.php'); |
|
70 | + if (function_exists('apc_delete_file')) { |
|
71 | + @apc_delete_file($cachedir . '/data_' . $key . '.php'); |
|
72 | + } |
|
69 | 73 | |
70 | 74 | // php will cache file_exists et all, we can't 100% depend on its results so proceed with caution |
71 | 75 | @include($cachedir . '/data_' . $key . '.php'); |
@@ -89,16 +93,18 @@ discard block |
||
89 | 93 | |
90 | 94 | // Work around Zend's opcode caching (PHP 5.5+), they would cache older files for a couple of seconds |
91 | 95 | // causing newer files to take effect a while later. |
92 | - if (function_exists('opcache_invalidate')) |
|
93 | - opcache_invalidate($cachedir . '/data_' . $key . '.php', true); |
|
96 | + if (function_exists('opcache_invalidate')) { |
|
97 | + opcache_invalidate($cachedir . '/data_' . $key . '.php', true); |
|
98 | + } |
|
94 | 99 | |
95 | - if (function_exists('apc_delete_file')) |
|
96 | - @apc_delete_file($cachedir . '/data_' . $key . '.php'); |
|
100 | + if (function_exists('apc_delete_file')) { |
|
101 | + @apc_delete_file($cachedir . '/data_' . $key . '.php'); |
|
102 | + } |
|
97 | 103 | |
98 | 104 | // Otherwise custom cache? |
99 | - if ($value === null) |
|
100 | - @unlink($cachedir . '/data_' . $key . '.php'); |
|
101 | - else |
|
105 | + if ($value === null) { |
|
106 | + @unlink($cachedir . '/data_' . $key . '.php'); |
|
107 | + } else |
|
102 | 108 | { |
103 | 109 | $cache_data = '<' . '?' . 'php if (!defined(\'SMF\')) die; if (' . (time() + $ttl) . ' < time()) $expired = true; else{$expired = false; $value = \'' . addcslashes($value, '\\\'') . '\';}' . '?' . '>'; |
104 | 110 | |
@@ -109,9 +115,9 @@ discard block |
||
109 | 115 | { |
110 | 116 | @unlink($cachedir . '/data_' . $key . '.php'); |
111 | 117 | return false; |
118 | + } else { |
|
119 | + return true; |
|
112 | 120 | } |
113 | - else |
|
114 | - return true; |
|
115 | 121 | } |
116 | 122 | } |
117 | 123 | |
@@ -123,15 +129,17 @@ discard block |
||
123 | 129 | $cachedir = $this->cachedir; |
124 | 130 | |
125 | 131 | // No directory = no game. |
126 | - if (!is_dir($cachedir)) |
|
127 | - return; |
|
132 | + if (!is_dir($cachedir)) { |
|
133 | + return; |
|
134 | + } |
|
128 | 135 | |
129 | 136 | // Remove the files in SMF's own disk cache, if any |
130 | 137 | $dh = opendir($cachedir); |
131 | 138 | while ($file = readdir($dh)) |
132 | 139 | { |
133 | - if ($file != '.' && $file != '..' && $file != 'index.php' && $file != '.htaccess' && (!$type || substr($file, 0, strlen($type)) == $type)) |
|
134 | - @unlink($cachedir . '/' . $file); |
|
140 | + if ($file != '.' && $file != '..' && $file != 'index.php' && $file != '.htaccess' && (!$type || substr($file, 0, strlen($type)) == $type)) { |
|
141 | + @unlink($cachedir . '/' . $file); |
|
142 | + } |
|
135 | 143 | } |
136 | 144 | closedir($dh); |
137 | 145 | |
@@ -165,8 +173,9 @@ discard block |
||
165 | 173 | $config_vars[] = $txt['cache_smf_settings']; |
166 | 174 | $config_vars[] = array('cachedir', $txt['cachedir'], 'file', 'text', 36, 'cache_cachedir'); |
167 | 175 | |
168 | - if (!isset($context['settings_post_javascript'])) |
|
169 | - $context['settings_post_javascript'] = ''; |
|
176 | + if (!isset($context['settings_post_javascript'])) { |
|
177 | + $context['settings_post_javascript'] = ''; |
|
178 | + } |
|
170 | 179 | |
171 | 180 | $context['settings_post_javascript'] .= ' |
172 | 181 | $("#cache_accelerator").change(function (e) { |
@@ -187,10 +196,11 @@ discard block |
||
187 | 196 | global $cachedir; |
188 | 197 | |
189 | 198 | // If its invalid, use SMF's. |
190 | - if (is_null($dir) || !is_writable($dir)) |
|
191 | - $this->cachedir = $cachedir; |
|
192 | - else |
|
193 | - $this->cachedir = $dir; |
|
199 | + if (is_null($dir) || !is_writable($dir)) { |
|
200 | + $this->cachedir = $cachedir; |
|
201 | + } else { |
|
202 | + $this->cachedir = $dir; |
|
203 | + } |
|
194 | 204 | } |
195 | 205 | |
196 | 206 | /** |
@@ -21,8 +21,9 @@ discard block |
||
21 | 21 | * @version 2.1 Beta 3 |
22 | 22 | */ |
23 | 23 | |
24 | -if (!defined('SMF')) |
|
24 | +if (!defined('SMF')) { |
|
25 | 25 | die('No direct access...'); |
26 | +} |
|
26 | 27 | |
27 | 28 | /** |
28 | 29 | * Handling function for generating reports. |
@@ -69,14 +70,15 @@ discard block |
||
69 | 70 | ); |
70 | 71 | |
71 | 72 | $is_first = 0; |
72 | - foreach ($context['report_types'] as $k => $temp) |
|
73 | - $context['report_types'][$k] = array( |
|
73 | + foreach ($context['report_types'] as $k => $temp) { |
|
74 | + $context['report_types'][$k] = array( |
|
74 | 75 | 'id' => $k, |
75 | 76 | 'title' => isset($txt['gr_type_' . $k]) ? $txt['gr_type_' . $k] : $k, |
76 | 77 | 'description' => isset($txt['gr_type_desc_' . $k]) ? $txt['gr_type_desc_' . $k] : null, |
77 | 78 | 'function' => $temp, |
78 | 79 | 'is_first' => $is_first++ == 0, |
79 | 80 | ); |
81 | + } |
|
80 | 82 | |
81 | 83 | // If they haven't chosen a report type which is valid, send them off to the report type chooser! |
82 | 84 | if (empty($_REQUEST['rt']) || !isset($context['report_types'][$_REQUEST['rt']])) |
@@ -102,8 +104,9 @@ discard block |
||
102 | 104 | $context['sub_template'] = $_REQUEST['st']; |
103 | 105 | |
104 | 106 | // Are we disabling the other layers - print friendly for example? |
105 | - if ($reportTemplates[$_REQUEST['st']]['layers'] !== null) |
|
106 | - $context['template_layers'] = $reportTemplates[$_REQUEST['st']]['layers']; |
|
107 | + if ($reportTemplates[$_REQUEST['st']]['layers'] !== null) { |
|
108 | + $context['template_layers'] = $reportTemplates[$_REQUEST['st']]['layers']; |
|
109 | + } |
|
107 | 110 | } |
108 | 111 | |
109 | 112 | // Make the page title more descriptive. |
@@ -151,8 +154,9 @@ discard block |
||
151 | 154 | ) |
152 | 155 | ); |
153 | 156 | $moderators = array(); |
154 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
155 | - $moderators[$row['id_board']][] = $row['real_name']; |
|
157 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
158 | + $moderators[$row['id_board']][] = $row['real_name']; |
|
159 | + } |
|
156 | 160 | $smcFunc['db_free_result']($request); |
157 | 161 | |
158 | 162 | // Get every moderator gruop. |
@@ -164,8 +168,9 @@ discard block |
||
164 | 168 | ) |
165 | 169 | ); |
166 | 170 | $moderator_groups = array(); |
167 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
168 | - $moderator_groups[$row['id_board']][] = $row['group_name']; |
|
171 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
172 | + $moderator_groups[$row['id_board']][] = $row['group_name']; |
|
173 | + } |
|
169 | 174 | $smcFunc['db_free_result']($request); |
170 | 175 | |
171 | 176 | // Get all the possible membergroups! |
@@ -176,8 +181,9 @@ discard block |
||
176 | 181 | ) |
177 | 182 | ); |
178 | 183 | $groups = array(-1 => $txt['guest_title'], 0 => $txt['full_member']); |
179 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
180 | - $groups[$row['id_group']] = empty($row['online_color']) ? $row['group_name'] : '<span style="color: ' . $row['online_color'] . '">' . $row['group_name'] . '</span>'; |
|
184 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
185 | + $groups[$row['id_group']] = empty($row['online_color']) ? $row['group_name'] : '<span style="color: ' . $row['online_color'] . '">' . $row['group_name'] . '</span>'; |
|
186 | + } |
|
181 | 187 | $smcFunc['db_free_result']($request); |
182 | 188 | |
183 | 189 | // All the fields we'll show. |
@@ -195,8 +201,9 @@ discard block |
||
195 | 201 | 'moderator_groups' => $txt['board_moderator_groups'], |
196 | 202 | 'groups' => $txt['board_groups'], |
197 | 203 | ); |
198 | - if (!empty($modSettings['deny_boards_access'])) |
|
199 | - $boardSettings['disallowed_groups'] = $txt['board_disallowed_groups']; |
|
204 | + if (!empty($modSettings['deny_boards_access'])) { |
|
205 | + $boardSettings['disallowed_groups'] = $txt['board_disallowed_groups']; |
|
206 | + } |
|
200 | 207 | |
201 | 208 | // Do it in columns, it's just easier. |
202 | 209 | setKeys('cols'); |
@@ -222,8 +229,9 @@ discard block |
||
222 | 229 | newTable($row['name'], '', 'left', 'auto', 'left', 200, 'left'); |
223 | 230 | |
224 | 231 | $this_boardSettings = $boardSettings; |
225 | - if (empty($row['redirect'])) |
|
226 | - unset($this_boardSettings['redirect']); |
|
232 | + if (empty($row['redirect'])) { |
|
233 | + unset($this_boardSettings['redirect']); |
|
234 | + } |
|
227 | 235 | |
228 | 236 | // First off, add in the side key. |
229 | 237 | addData($this_boardSettings); |
@@ -250,10 +258,11 @@ discard block |
||
250 | 258 | $allowedGroups = explode(',', $row['member_groups']); |
251 | 259 | foreach ($allowedGroups as $key => $group) |
252 | 260 | { |
253 | - if (isset($groups[$group])) |
|
254 | - $allowedGroups[$key] = $groups[$group]; |
|
255 | - else |
|
256 | - unset($allowedGroups[$key]); |
|
261 | + if (isset($groups[$group])) { |
|
262 | + $allowedGroups[$key] = $groups[$group]; |
|
263 | + } else { |
|
264 | + unset($allowedGroups[$key]); |
|
265 | + } |
|
257 | 266 | } |
258 | 267 | $boardData['groups'] = implode(', ', $allowedGroups); |
259 | 268 | if (!empty($modSettings['deny_boards_access'])) |
@@ -261,16 +270,18 @@ discard block |
||
261 | 270 | $disallowedGroups = explode(',', $row['deny_member_groups']); |
262 | 271 | foreach ($disallowedGroups as $key => $group) |
263 | 272 | { |
264 | - if (isset($groups[$group])) |
|
265 | - $disallowedGroups[$key] = $groups[$group]; |
|
266 | - else |
|
267 | - unset($disallowedGroups[$key]); |
|
273 | + if (isset($groups[$group])) { |
|
274 | + $disallowedGroups[$key] = $groups[$group]; |
|
275 | + } else { |
|
276 | + unset($disallowedGroups[$key]); |
|
277 | + } |
|
268 | 278 | } |
269 | 279 | $boardData['disallowed_groups'] = implode(', ', $disallowedGroups); |
270 | 280 | } |
271 | 281 | |
272 | - if (empty($row['redirect'])) |
|
273 | - unset ($boardData['redirect']); |
|
282 | + if (empty($row['redirect'])) { |
|
283 | + unset ($boardData['redirect']); |
|
284 | + } |
|
274 | 285 | |
275 | 286 | // Next add the main data. |
276 | 287 | addData($boardData); |
@@ -295,27 +306,31 @@ discard block |
||
295 | 306 | |
296 | 307 | if (isset($_REQUEST['boards'])) |
297 | 308 | { |
298 | - if (!is_array($_REQUEST['boards'])) |
|
299 | - $_REQUEST['boards'] = explode(',', $_REQUEST['boards']); |
|
300 | - foreach ($_REQUEST['boards'] as $k => $dummy) |
|
301 | - $_REQUEST['boards'][$k] = (int) $dummy; |
|
309 | + if (!is_array($_REQUEST['boards'])) { |
|
310 | + $_REQUEST['boards'] = explode(',', $_REQUEST['boards']); |
|
311 | + } |
|
312 | + foreach ($_REQUEST['boards'] as $k => $dummy) { |
|
313 | + $_REQUEST['boards'][$k] = (int) $dummy; |
|
314 | + } |
|
302 | 315 | |
303 | 316 | $board_clause = 'id_board IN ({array_int:boards})'; |
317 | + } else { |
|
318 | + $board_clause = '1=1'; |
|
304 | 319 | } |
305 | - else |
|
306 | - $board_clause = '1=1'; |
|
307 | 320 | |
308 | 321 | if (isset($_REQUEST['groups'])) |
309 | 322 | { |
310 | - if (!is_array($_REQUEST['groups'])) |
|
311 | - $_REQUEST['groups'] = explode(',', $_REQUEST['groups']); |
|
312 | - foreach ($_REQUEST['groups'] as $k => $dummy) |
|
313 | - $_REQUEST['groups'][$k] = (int) $dummy; |
|
323 | + if (!is_array($_REQUEST['groups'])) { |
|
324 | + $_REQUEST['groups'] = explode(',', $_REQUEST['groups']); |
|
325 | + } |
|
326 | + foreach ($_REQUEST['groups'] as $k => $dummy) { |
|
327 | + $_REQUEST['groups'][$k] = (int) $dummy; |
|
328 | + } |
|
314 | 329 | |
315 | 330 | $group_clause = 'id_group IN ({array_int:groups})'; |
331 | + } else { |
|
332 | + $group_clause = '1=1'; |
|
316 | 333 | } |
317 | - else |
|
318 | - $group_clause = '1=1'; |
|
319 | 334 | |
320 | 335 | // Fetch all the board names. |
321 | 336 | $request = $smcFunc['db_query']('', ' |
@@ -369,12 +384,14 @@ discard block |
||
369 | 384 | 'groups' => isset($_REQUEST['groups']) ? $_REQUEST['groups'] : array(), |
370 | 385 | ) |
371 | 386 | ); |
372 | - if (!isset($_REQUEST['groups']) || in_array(-1, $_REQUEST['groups']) || in_array(0, $_REQUEST['groups'])) |
|
373 | - $member_groups = array('col' => '', -1 => $txt['membergroups_guests'], 0 => $txt['membergroups_members']); |
|
374 | - else |
|
375 | - $member_groups = array('col' => ''); |
|
376 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
377 | - $member_groups[$row['id_group']] = $row['group_name']; |
|
387 | + if (!isset($_REQUEST['groups']) || in_array(-1, $_REQUEST['groups']) || in_array(0, $_REQUEST['groups'])) { |
|
388 | + $member_groups = array('col' => '', -1 => $txt['membergroups_guests'], 0 => $txt['membergroups_members']); |
|
389 | + } else { |
|
390 | + $member_groups = array('col' => ''); |
|
391 | + } |
|
392 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
393 | + $member_groups[$row['id_group']] = $row['group_name']; |
|
394 | + } |
|
378 | 395 | $smcFunc['db_free_result']($request); |
379 | 396 | |
380 | 397 | // Make sure that every group is represented - plus in rows! |
@@ -411,12 +428,14 @@ discard block |
||
411 | 428 | ); |
412 | 429 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
413 | 430 | { |
414 | - if (in_array($row['permission'], $disabled_permissions)) |
|
415 | - continue; |
|
431 | + if (in_array($row['permission'], $disabled_permissions)) { |
|
432 | + continue; |
|
433 | + } |
|
416 | 434 | |
417 | - foreach ($boards as $id => $board) |
|
418 | - if ($board['profile'] == $row['id_profile']) |
|
435 | + foreach ($boards as $id => $board) { |
|
436 | + if ($board['profile'] == $row['id_profile']) |
|
419 | 437 | $board_permissions[$id][$row['id_group']][$row['permission']] = $row['add_deny']; |
438 | + } |
|
420 | 439 | |
421 | 440 | // Make sure we get every permission. |
422 | 441 | if (!isset($permissions[$row['permission']])) |
@@ -454,8 +473,9 @@ discard block |
||
454 | 473 | foreach ($member_groups as $id_group => $name) |
455 | 474 | { |
456 | 475 | // Don't overwrite the key column! |
457 | - if ($id_group === 'col') |
|
458 | - continue; |
|
476 | + if ($id_group === 'col') { |
|
477 | + continue; |
|
478 | + } |
|
459 | 479 | |
460 | 480 | $group_permissions = isset($groups[$id_group]) ? $groups[$id_group] : array(); |
461 | 481 | |
@@ -477,16 +497,18 @@ discard block |
||
477 | 497 | } |
478 | 498 | |
479 | 499 | // Now actually make the data for the group look right. |
480 | - if (empty($curData[$id_group])) |
|
481 | - $curData[$id_group] = '<span class="red">' . $txt['board_perms_deny'] . '</span>'; |
|
482 | - elseif ($curData[$id_group] == 1) |
|
483 | - $curData[$id_group] = '<span style="color: darkgreen;">' . $txt['board_perms_allow'] . '</span>'; |
|
484 | - else |
|
485 | - $curData[$id_group] = 'x'; |
|
500 | + if (empty($curData[$id_group])) { |
|
501 | + $curData[$id_group] = '<span class="red">' . $txt['board_perms_deny'] . '</span>'; |
|
502 | + } elseif ($curData[$id_group] == 1) { |
|
503 | + $curData[$id_group] = '<span style="color: darkgreen;">' . $txt['board_perms_allow'] . '</span>'; |
|
504 | + } else { |
|
505 | + $curData[$id_group] = 'x'; |
|
506 | + } |
|
486 | 507 | |
487 | 508 | // Embolden those permissions different from global (makes it a lot easier!) |
488 | - if (@$board_permissions[0][$id_group][$ID_PERM] != @$group_permissions[$ID_PERM]) |
|
489 | - $curData[$id_group] = '<strong>' . $curData[$id_group] . '</strong>'; |
|
509 | + if (@$board_permissions[0][$id_group][$ID_PERM] != @$group_permissions[$ID_PERM]) { |
|
510 | + $curData[$id_group] = '<strong>' . $curData[$id_group] . '</strong>'; |
|
511 | + } |
|
490 | 512 | } |
491 | 513 | |
492 | 514 | // Now add the data for this permission. |
@@ -516,15 +538,17 @@ discard block |
||
516 | 538 | ); |
517 | 539 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
518 | 540 | { |
519 | - if (trim($row['member_groups']) == '') |
|
520 | - $groups = array(1); |
|
521 | - else |
|
522 | - $groups = array_merge(array(1), explode(',', $row['member_groups'])); |
|
541 | + if (trim($row['member_groups']) == '') { |
|
542 | + $groups = array(1); |
|
543 | + } else { |
|
544 | + $groups = array_merge(array(1), explode(',', $row['member_groups'])); |
|
545 | + } |
|
523 | 546 | |
524 | - if (trim($row['deny_member_groups']) == '') |
|
525 | - $denyGroups = array(); |
|
526 | - else |
|
527 | - $denyGroups = explode(',', $row['deny_member_groups']); |
|
547 | + if (trim($row['deny_member_groups']) == '') { |
|
548 | + $denyGroups = array(); |
|
549 | + } else { |
|
550 | + $denyGroups = explode(',', $row['deny_member_groups']); |
|
551 | + } |
|
528 | 552 | |
529 | 553 | $boards[$row['id_board']] = array( |
530 | 554 | 'id' => $row['id_board'], |
@@ -548,8 +572,9 @@ discard block |
||
548 | 572 | ); |
549 | 573 | |
550 | 574 | // Add on the boards! |
551 | - foreach ($boards as $board) |
|
552 | - $mgSettings['board_' . $board['id']] = $board['name']; |
|
575 | + foreach ($boards as $board) { |
|
576 | + $mgSettings['board_' . $board['id']] = $board['name']; |
|
577 | + } |
|
553 | 578 | |
554 | 579 | // Add all the membergroup settings, plus we'll be adding in columns! |
555 | 580 | setKeys('cols', $mgSettings); |
@@ -594,8 +619,9 @@ discard block |
||
594 | 619 | 'icons' => '' |
595 | 620 | ), |
596 | 621 | ); |
597 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
598 | - $rows[] = $row; |
|
622 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
623 | + $rows[] = $row; |
|
624 | + } |
|
599 | 625 | $smcFunc['db_free_result']($request); |
600 | 626 | |
601 | 627 | foreach ($rows as $row) |
@@ -611,8 +637,9 @@ discard block |
||
611 | 637 | ); |
612 | 638 | |
613 | 639 | // Board permissions. |
614 | - foreach ($boards as $board) |
|
615 | - $group['board_' . $board['id']] = in_array($row['id_group'], $board['groups']) ? '<span class="success">' . $txt['board_perms_allow'] . '</span>' : (!empty($modSettings['deny_boards_access']) && in_array($row['id_group'], $board['deny_groups']) ? '<span class="alert">' . $txt['board_perms_deny'] . '</span>' : 'x'); |
|
640 | + foreach ($boards as $board) { |
|
641 | + $group['board_' . $board['id']] = in_array($row['id_group'], $board['groups']) ? '<span class="success">' . $txt['board_perms_allow'] . '</span>' : (!empty($modSettings['deny_boards_access']) && in_array($row['id_group'], $board['deny_groups']) ? '<span class="alert">' . $txt['board_perms_deny'] . '</span>' : 'x'); |
|
642 | + } |
|
616 | 643 | |
617 | 644 | addData($group); |
618 | 645 | } |
@@ -632,16 +659,18 @@ discard block |
||
632 | 659 | |
633 | 660 | if (isset($_REQUEST['groups'])) |
634 | 661 | { |
635 | - if (!is_array($_REQUEST['groups'])) |
|
636 | - $_REQUEST['groups'] = explode(',', $_REQUEST['groups']); |
|
637 | - foreach ($_REQUEST['groups'] as $k => $dummy) |
|
638 | - $_REQUEST['groups'][$k] = (int) $dummy; |
|
662 | + if (!is_array($_REQUEST['groups'])) { |
|
663 | + $_REQUEST['groups'] = explode(',', $_REQUEST['groups']); |
|
664 | + } |
|
665 | + foreach ($_REQUEST['groups'] as $k => $dummy) { |
|
666 | + $_REQUEST['groups'][$k] = (int) $dummy; |
|
667 | + } |
|
639 | 668 | $_REQUEST['groups'] = array_diff($_REQUEST['groups'], array(3)); |
640 | 669 | |
641 | 670 | $clause = 'id_group IN ({array_int:groups})'; |
671 | + } else { |
|
672 | + $clause = 'id_group != {int:moderator_group}'; |
|
642 | 673 | } |
643 | - else |
|
644 | - $clause = 'id_group != {int:moderator_group}'; |
|
645 | 674 | |
646 | 675 | // Get all the possible membergroups, except admin! |
647 | 676 | $request = $smcFunc['db_query']('', ' |
@@ -659,12 +688,14 @@ discard block |
||
659 | 688 | 'groups' => isset($_REQUEST['groups']) ? $_REQUEST['groups'] : array(), |
660 | 689 | ) |
661 | 690 | ); |
662 | - if (!isset($_REQUEST['groups']) || in_array(-1, $_REQUEST['groups']) || in_array(0, $_REQUEST['groups'])) |
|
663 | - $groups = array('col' => '', -1 => $txt['membergroups_guests'], 0 => $txt['membergroups_members']); |
|
664 | - else |
|
665 | - $groups = array('col' => ''); |
|
666 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
667 | - $groups[$row['id_group']] = $row['group_name']; |
|
691 | + if (!isset($_REQUEST['groups']) || in_array(-1, $_REQUEST['groups']) || in_array(0, $_REQUEST['groups'])) { |
|
692 | + $groups = array('col' => '', -1 => $txt['membergroups_guests'], 0 => $txt['membergroups_members']); |
|
693 | + } else { |
|
694 | + $groups = array('col' => ''); |
|
695 | + } |
|
696 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
697 | + $groups[$row['id_group']] = $row['group_name']; |
|
698 | + } |
|
668 | 699 | $smcFunc['db_free_result']($request); |
669 | 700 | |
670 | 701 | // Make sure that every group is represented! |
@@ -688,8 +719,9 @@ discard block |
||
688 | 719 | $disabled_permissions[] = 'calendar_edit_own'; |
689 | 720 | $disabled_permissions[] = 'calendar_edit_any'; |
690 | 721 | } |
691 | - if (empty($modSettings['warning_settings']) || $modSettings['warning_settings'][0] == 0) |
|
692 | - $disabled_permissions[] = 'issue_warning'; |
|
722 | + if (empty($modSettings['warning_settings']) || $modSettings['warning_settings'][0] == 0) { |
|
723 | + $disabled_permissions[] = 'issue_warning'; |
|
724 | + } |
|
693 | 725 | |
694 | 726 | call_integration_hook('integrate_reports_groupperm', array(&$disabled_permissions)); |
695 | 727 | |
@@ -710,15 +742,17 @@ discard block |
||
710 | 742 | $curData = array(); |
711 | 743 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
712 | 744 | { |
713 | - if (in_array($row['permission'], $disabled_permissions)) |
|
714 | - continue; |
|
745 | + if (in_array($row['permission'], $disabled_permissions)) { |
|
746 | + continue; |
|
747 | + } |
|
715 | 748 | |
716 | 749 | // If this is a new permission flush the last row. |
717 | 750 | if ($row['permission'] != $lastPermission) |
718 | 751 | { |
719 | 752 | // Send the data! |
720 | - if ($lastPermission !== null) |
|
721 | - addData($curData); |
|
753 | + if ($lastPermission !== null) { |
|
754 | + addData($curData); |
|
755 | + } |
|
722 | 756 | |
723 | 757 | // Add the permission name in the left column. |
724 | 758 | $curData = array('col' => isset($txt['group_perms_name_' . $row['permission']]) ? $txt['group_perms_name_' . $row['permission']] : $row['permission']); |
@@ -727,10 +761,11 @@ discard block |
||
727 | 761 | } |
728 | 762 | |
729 | 763 | // Good stuff - add the permission to the list! |
730 | - if ($row['add_deny']) |
|
731 | - $curData[$row['id_group']] = '<span style="color: darkgreen;">' . $txt['board_perms_allow'] . '</span>'; |
|
732 | - else |
|
733 | - $curData[$row['id_group']] = '<span class="red">' . $txt['board_perms_deny'] . '</span>'; |
|
764 | + if ($row['add_deny']) { |
|
765 | + $curData[$row['id_group']] = '<span style="color: darkgreen;">' . $txt['board_perms_allow'] . '</span>'; |
|
766 | + } else { |
|
767 | + $curData[$row['id_group']] = '<span class="red">' . $txt['board_perms_deny'] . '</span>'; |
|
768 | + } |
|
734 | 769 | } |
735 | 770 | $smcFunc['db_free_result']($request); |
736 | 771 | |
@@ -760,8 +795,9 @@ discard block |
||
760 | 795 | ) |
761 | 796 | ); |
762 | 797 | $boards = array(); |
763 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
764 | - $boards[$row['id_board']] = $row['name']; |
|
798 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
799 | + $boards[$row['id_board']] = $row['name']; |
|
800 | + } |
|
765 | 801 | $smcFunc['db_free_result']($request); |
766 | 802 | |
767 | 803 | // Get every moderator. |
@@ -793,12 +829,14 @@ discard block |
||
793 | 829 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
794 | 830 | { |
795 | 831 | // Either we don't have them as a moderator at all or at least not as a moderator of this board |
796 | - if (!array_key_exists($row['id_member'], $moderators) || !in_array($row['id_board'], $moderators[$row['id_member']])) |
|
797 | - $moderators[$row['id_member']][] = $row['id_board']; |
|
832 | + if (!array_key_exists($row['id_member'], $moderators) || !in_array($row['id_board'], $moderators[$row['id_member']])) { |
|
833 | + $moderators[$row['id_member']][] = $row['id_board']; |
|
834 | + } |
|
798 | 835 | |
799 | 836 | // We don't have them listed as a moderator yet |
800 | - if (!array_key_exists($row['id_member'], $local_mods)) |
|
801 | - $local_mods[$row['id_member']] = $row['id_member']; |
|
837 | + if (!array_key_exists($row['id_member'], $local_mods)) { |
|
838 | + $local_mods[$row['id_member']] = $row['id_member']; |
|
839 | + } |
|
802 | 840 | } |
803 | 841 | |
804 | 842 | // Get a list of global moderators (i.e. members with moderation powers). |
@@ -811,8 +849,9 @@ discard block |
||
811 | 849 | $allStaff = array_unique($allStaff); |
812 | 850 | |
813 | 851 | // This is a bit of a cop out - but we're protecting their forum, really! |
814 | - if (count($allStaff) > 300) |
|
815 | - fatal_lang_error('report_error_too_many_staff'); |
|
852 | + if (count($allStaff) > 300) { |
|
853 | + fatal_lang_error('report_error_too_many_staff'); |
|
854 | + } |
|
816 | 855 | |
817 | 856 | // Get all the possible membergroups! |
818 | 857 | $request = $smcFunc['db_query']('', ' |
@@ -822,8 +861,9 @@ discard block |
||
822 | 861 | ) |
823 | 862 | ); |
824 | 863 | $groups = array(0 => $txt['full_member']); |
825 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
826 | - $groups[$row['id_group']] = empty($row['online_color']) ? $row['group_name'] : '<span style="color: ' . $row['online_color'] . '">' . $row['group_name'] . '</span>'; |
|
864 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
865 | + $groups[$row['id_group']] = empty($row['online_color']) ? $row['group_name'] : '<span style="color: ' . $row['online_color'] . '">' . $row['group_name'] . '</span>'; |
|
866 | + } |
|
827 | 867 | $smcFunc['db_free_result']($request); |
828 | 868 | |
829 | 869 | // All the fields we'll show. |
@@ -864,19 +904,20 @@ discard block |
||
864 | 904 | ); |
865 | 905 | |
866 | 906 | // What do they moderate? |
867 | - if (in_array($row['id_member'], $global_mods)) |
|
868 | - $staffData['moderates'] = '<em>' . $txt['report_staff_all_boards'] . '</em>'; |
|
869 | - elseif (isset($moderators[$row['id_member']])) |
|
907 | + if (in_array($row['id_member'], $global_mods)) { |
|
908 | + $staffData['moderates'] = '<em>' . $txt['report_staff_all_boards'] . '</em>'; |
|
909 | + } elseif (isset($moderators[$row['id_member']])) |
|
870 | 910 | { |
871 | 911 | // Get the names |
872 | - foreach ($moderators[$row['id_member']] as $board) |
|
873 | - if (isset($boards[$board])) |
|
912 | + foreach ($moderators[$row['id_member']] as $board) { |
|
913 | + if (isset($boards[$board])) |
|
874 | 914 | $staffData['moderates'][] = $boards[$board]; |
915 | + } |
|
875 | 916 | |
876 | 917 | $staffData['moderates'] = implode(', ', $staffData['moderates']); |
918 | + } else { |
|
919 | + $staffData['moderates'] = '<em>' . $txt['report_staff_no_boards'] . '</em>'; |
|
877 | 920 | } |
878 | - else |
|
879 | - $staffData['moderates'] = '<em>' . $txt['report_staff_no_boards'] . '</em>'; |
|
880 | 921 | |
881 | 922 | // Next add the main data. |
882 | 923 | addData($staffData); |
@@ -904,8 +945,9 @@ discard block |
||
904 | 945 | global $context; |
905 | 946 | |
906 | 947 | // Set the table count if needed. |
907 | - if (empty($context['table_count'])) |
|
908 | - $context['table_count'] = 0; |
|
948 | + if (empty($context['table_count'])) { |
|
949 | + $context['table_count'] = 0; |
|
950 | + } |
|
909 | 951 | |
910 | 952 | // Create the table! |
911 | 953 | $context['tables'][$context['table_count']] = array( |
@@ -955,16 +997,18 @@ discard block |
||
955 | 997 | global $context; |
956 | 998 | |
957 | 999 | // No tables? Create one even though we are probably already in a bad state! |
958 | - if (empty($context['table_count'])) |
|
959 | - newTable(); |
|
1000 | + if (empty($context['table_count'])) { |
|
1001 | + newTable(); |
|
1002 | + } |
|
960 | 1003 | |
961 | 1004 | // Specific table? |
962 | - if ($custom_table !== null && !isset($context['tables'][$custom_table])) |
|
963 | - return false; |
|
964 | - elseif ($custom_table !== null) |
|
965 | - $table = $custom_table; |
|
966 | - else |
|
967 | - $table = $context['current_table']; |
|
1005 | + if ($custom_table !== null && !isset($context['tables'][$custom_table])) { |
|
1006 | + return false; |
|
1007 | + } elseif ($custom_table !== null) { |
|
1008 | + $table = $custom_table; |
|
1009 | + } else { |
|
1010 | + $table = $context['current_table']; |
|
1011 | + } |
|
968 | 1012 | |
969 | 1013 | // If we have keys, sanitise the data... |
970 | 1014 | if (!empty($context['keys'])) |
@@ -976,11 +1020,11 @@ discard block |
||
976 | 1020 | 'v' => empty($inc_data[$key]) ? $context['tables'][$table]['default_value'] : $inc_data[$key], |
977 | 1021 | ); |
978 | 1022 | // Special "hack" the adding separators when doing data by column. |
979 | - if (substr($key, 0, 5) == '#sep#') |
|
980 | - $data[$key]['separator'] = true; |
|
1023 | + if (substr($key, 0, 5) == '#sep#') { |
|
1024 | + $data[$key]['separator'] = true; |
|
1025 | + } |
|
981 | 1026 | } |
982 | - } |
|
983 | - else |
|
1027 | + } else |
|
984 | 1028 | { |
985 | 1029 | $data = $inc_data; |
986 | 1030 | foreach ($data as $key => $value) |
@@ -988,8 +1032,9 @@ discard block |
||
988 | 1032 | $data[$key] = array( |
989 | 1033 | 'v' => $value, |
990 | 1034 | ); |
991 | - if (substr($key, 0, 5) == '#sep#') |
|
992 | - $data[$key]['separator'] = true; |
|
1035 | + if (substr($key, 0, 5) == '#sep#') { |
|
1036 | + $data[$key]['separator'] = true; |
|
1037 | + } |
|
993 | 1038 | } |
994 | 1039 | } |
995 | 1040 | |
@@ -1002,8 +1047,9 @@ discard block |
||
1002 | 1047 | // Otherwise, tricky! |
1003 | 1048 | else |
1004 | 1049 | { |
1005 | - foreach ($data as $key => $item) |
|
1006 | - $context['tables'][$table]['data'][$key][] = $item; |
|
1050 | + foreach ($data as $key => $item) { |
|
1051 | + $context['tables'][$table]['data'][$key][] = $item; |
|
1052 | + } |
|
1007 | 1053 | } |
1008 | 1054 | } |
1009 | 1055 | |
@@ -1020,16 +1066,18 @@ discard block |
||
1020 | 1066 | global $context; |
1021 | 1067 | |
1022 | 1068 | // No tables - return? |
1023 | - if (empty($context['table_count'])) |
|
1024 | - return; |
|
1069 | + if (empty($context['table_count'])) { |
|
1070 | + return; |
|
1071 | + } |
|
1025 | 1072 | |
1026 | 1073 | // Specific table? |
1027 | - if ($custom_table !== null && !isset($context['tables'][$table])) |
|
1028 | - return false; |
|
1029 | - elseif ($custom_table !== null) |
|
1030 | - $table = $custom_table; |
|
1031 | - else |
|
1032 | - $table = $context['current_table']; |
|
1074 | + if ($custom_table !== null && !isset($context['tables'][$table])) { |
|
1075 | + return false; |
|
1076 | + } elseif ($custom_table !== null) { |
|
1077 | + $table = $custom_table; |
|
1078 | + } else { |
|
1079 | + $table = $context['current_table']; |
|
1080 | + } |
|
1033 | 1081 | |
1034 | 1082 | // Plumb in the separator |
1035 | 1083 | $context['tables'][$table]['data'][] = array(0 => array( |
@@ -1050,8 +1098,9 @@ discard block |
||
1050 | 1098 | { |
1051 | 1099 | global $context; |
1052 | 1100 | |
1053 | - if (empty($context['tables'])) |
|
1054 | - return; |
|
1101 | + if (empty($context['tables'])) { |
|
1102 | + return; |
|
1103 | + } |
|
1055 | 1104 | |
1056 | 1105 | // Loop through each table counting up some basic values, to help with the templating. |
1057 | 1106 | foreach ($context['tables'] as $id => $table) |
@@ -1062,12 +1111,13 @@ discard block |
||
1062 | 1111 | $context['tables'][$id]['column_count'] = count($curElement); |
1063 | 1112 | |
1064 | 1113 | // Work out the rough width - for templates like the print template. Without this we might get funny tables. |
1065 | - if ($table['shading']['left'] && $table['width']['shaded'] != 'auto' && $table['width']['normal'] != 'auto') |
|
1066 | - $context['tables'][$id]['max_width'] = $table['width']['shaded'] + ($context['tables'][$id]['column_count'] - 1) * $table['width']['normal']; |
|
1067 | - elseif ($table['width']['normal'] != 'auto') |
|
1068 | - $context['tables'][$id]['max_width'] = $context['tables'][$id]['column_count'] * $table['width']['normal']; |
|
1069 | - else |
|
1070 | - $context['tables'][$id]['max_width'] = 'auto'; |
|
1114 | + if ($table['shading']['left'] && $table['width']['shaded'] != 'auto' && $table['width']['normal'] != 'auto') { |
|
1115 | + $context['tables'][$id]['max_width'] = $table['width']['shaded'] + ($context['tables'][$id]['column_count'] - 1) * $table['width']['normal']; |
|
1116 | + } elseif ($table['width']['normal'] != 'auto') { |
|
1117 | + $context['tables'][$id]['max_width'] = $context['tables'][$id]['column_count'] * $table['width']['normal']; |
|
1118 | + } else { |
|
1119 | + $context['tables'][$id]['max_width'] = 'auto'; |
|
1120 | + } |
|
1071 | 1121 | } |
1072 | 1122 | } |
1073 | 1123 | |
@@ -1092,10 +1142,11 @@ discard block |
||
1092 | 1142 | global $context; |
1093 | 1143 | |
1094 | 1144 | // Do we want to use the keys of the keys as the keys? :P |
1095 | - if ($reverse) |
|
1096 | - $context['keys'] = array_flip($keys); |
|
1097 | - else |
|
1098 | - $context['keys'] = $keys; |
|
1145 | + if ($reverse) { |
|
1146 | + $context['keys'] = array_flip($keys); |
|
1147 | + } else { |
|
1148 | + $context['keys'] = $keys; |
|
1149 | + } |
|
1099 | 1150 | |
1100 | 1151 | // Rows or columns? |
1101 | 1152 | $context['key_method'] = $method == 'rows' ? 'rows' : 'cols'; |
@@ -11,8 +11,9 @@ |
||
11 | 11 | * @version 2.1 Beta 3 |
12 | 12 | */ |
13 | 13 | |
14 | -if (!defined('SMF')) |
|
14 | +if (!defined('SMF')) { |
|
15 | 15 | die('No direct access...'); |
16 | +} |
|
16 | 17 | |
17 | 18 | /** |
18 | 19 | * Standard non full index, non custom index search |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 3 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * Add the file functions to the $smcFunc array. |
@@ -52,8 +53,9 @@ discard block |
||
52 | 53 | 'messages', 'moderators', 'package_servers', 'permission_profiles', 'permissions', 'personal_messages', |
53 | 54 | 'pm_recipients', 'poll_choices', 'polls', 'scheduled_tasks', 'sessions', 'settings', 'smileys', |
54 | 55 | 'themes', 'topics'); |
55 | - foreach ($reservedTables as $k => $table_name) |
|
56 | - $reservedTables[$k] = strtolower($db_prefix . $table_name); |
|
56 | + foreach ($reservedTables as $k => $table_name) { |
|
57 | + $reservedTables[$k] = strtolower($db_prefix . $table_name); |
|
58 | + } |
|
57 | 59 | |
58 | 60 | // We in turn may need the extra stuff. |
59 | 61 | db_extend('extra'); |
@@ -102,8 +104,9 @@ discard block |
||
102 | 104 | $table_name = str_replace('{db_prefix}', $db_prefix, $table_name); |
103 | 105 | |
104 | 106 | // First - no way do we touch SMF tables. |
105 | - if (in_array(strtolower($table_name), $reservedTables)) |
|
106 | - return false; |
|
107 | + if (in_array(strtolower($table_name), $reservedTables)) { |
|
108 | + return false; |
|
109 | + } |
|
107 | 110 | |
108 | 111 | // Log that we'll want to remove this on uninstall. |
109 | 112 | $db_package_log[] = array('remove_table', $table_name); |
@@ -113,10 +116,11 @@ discard block |
||
113 | 116 | if (in_array($full_table_name, $tables)) |
114 | 117 | { |
115 | 118 | // This is a sad day... drop the table? If not, return false (error) by default. |
116 | - if ($if_exists == 'overwrite') |
|
117 | - $smcFunc['db_drop_table']($table_name); |
|
118 | - else |
|
119 | - return $if_exists == 'ignore'; |
|
119 | + if ($if_exists == 'overwrite') { |
|
120 | + $smcFunc['db_drop_table']($table_name); |
|
121 | + } else { |
|
122 | + return $if_exists == 'ignore'; |
|
123 | + } |
|
120 | 124 | } |
121 | 125 | |
122 | 126 | // If we've got this far - good news - no table exists. We can build our own! |
@@ -134,17 +138,18 @@ discard block |
||
134 | 138 | ) |
135 | 139 | ); |
136 | 140 | $default = 'default nextval(\'' . $table_name . '_seq\')'; |
141 | + } elseif (isset($column['default']) && $column['default'] !== null) { |
|
142 | + $default = 'default \'' . $smcFunc['db_escape_string']($column['default']) . '\''; |
|
143 | + } else { |
|
144 | + $default = ''; |
|
137 | 145 | } |
138 | - elseif (isset($column['default']) && $column['default'] !== null) |
|
139 | - $default = 'default \'' . $smcFunc['db_escape_string']($column['default']) . '\''; |
|
140 | - else |
|
141 | - $default = ''; |
|
142 | 146 | |
143 | 147 | // Sort out the size... |
144 | 148 | $column['size'] = isset($column['size']) && is_numeric($column['size']) ? $column['size'] : null; |
145 | 149 | list ($type, $size) = $smcFunc['db_calculate_type']($column['type'], $column['size']); |
146 | - if ($size !== null) |
|
147 | - $type = $type . '(' . $size . ')'; |
|
150 | + if ($size !== null) { |
|
151 | + $type = $type . '(' . $size . ')'; |
|
152 | + } |
|
148 | 153 | |
149 | 154 | // Now just put it together! |
150 | 155 | $table_query .= "\n\t\"" . $column['name'] . '" ' . $type . ' ' . (!empty($column['null']) ? '' : 'NOT NULL') . ' ' . $default . ','; |
@@ -157,19 +162,21 @@ discard block |
||
157 | 162 | $columns = implode(',', $index['columns']); |
158 | 163 | |
159 | 164 | // Primary goes in the table... |
160 | - if (isset($index['type']) && $index['type'] == 'primary') |
|
161 | - $table_query .= "\n\t" . 'PRIMARY KEY (' . implode(',', $index['columns']) . '),'; |
|
162 | - else |
|
165 | + if (isset($index['type']) && $index['type'] == 'primary') { |
|
166 | + $table_query .= "\n\t" . 'PRIMARY KEY (' . implode(',', $index['columns']) . '),'; |
|
167 | + } else |
|
163 | 168 | { |
164 | - if (empty($index['name'])) |
|
165 | - $index['name'] = implode('_', $index['columns']); |
|
169 | + if (empty($index['name'])) { |
|
170 | + $index['name'] = implode('_', $index['columns']); |
|
171 | + } |
|
166 | 172 | $index_queries[] = 'CREATE ' . (isset($index['type']) && $index['type'] == 'unique' ? 'UNIQUE' : '') . ' INDEX ' . $table_name . '_' . $index['name'] . ' ON ' . $table_name . ' (' . $columns . ')'; |
167 | 173 | } |
168 | 174 | } |
169 | 175 | |
170 | 176 | // No trailing commas! |
171 | - if (substr($table_query, -1) == ',') |
|
172 | - $table_query = substr($table_query, 0, -1); |
|
177 | + if (substr($table_query, -1) == ',') { |
|
178 | + $table_query = substr($table_query, 0, -1); |
|
179 | + } |
|
173 | 180 | |
174 | 181 | $table_query .= ')'; |
175 | 182 | |
@@ -180,12 +187,13 @@ discard block |
||
180 | 187 | ) |
181 | 188 | ); |
182 | 189 | // And the indexes... |
183 | - foreach ($index_queries as $query) |
|
184 | - $smcFunc['db_query']('', $query, |
|
190 | + foreach ($index_queries as $query) { |
|
191 | + $smcFunc['db_query']('', $query, |
|
185 | 192 | array( |
186 | 193 | 'security_override' => true, |
187 | 194 | ) |
188 | 195 | ); |
196 | + } |
|
189 | 197 | |
190 | 198 | // Go, go power rangers! |
191 | 199 | $smcFunc['db_transaction']('commit'); |
@@ -213,8 +221,9 @@ discard block |
||
213 | 221 | $table_name = str_replace('{db_prefix}', $db_prefix, $table_name); |
214 | 222 | |
215 | 223 | // God no - dropping one of these = bad. |
216 | - if (in_array(strtolower($table_name), $reservedTables)) |
|
217 | - return false; |
|
224 | + if (in_array(strtolower($table_name), $reservedTables)) { |
|
225 | + return false; |
|
226 | + } |
|
218 | 227 | |
219 | 228 | // Does it exist? |
220 | 229 | if (in_array($full_table_name, $smcFunc['db_list_tables']())) |
@@ -272,21 +281,24 @@ discard block |
||
272 | 281 | |
273 | 282 | // Does it exist - if so don't add it again! |
274 | 283 | $columns = $smcFunc['db_list_columns']($table_name, false); |
275 | - foreach ($columns as $column) |
|
276 | - if ($column == $column_info['name']) |
|
284 | + foreach ($columns as $column) { |
|
285 | + if ($column == $column_info['name']) |
|
277 | 286 | { |
278 | 287 | // If we're going to overwrite then use change column. |
279 | 288 | if ($if_exists == 'update') |
280 | 289 | return $smcFunc['db_change_column']($table_name, $column_info['name'], $column_info); |
281 | - else |
|
282 | - return false; |
|
290 | + } |
|
291 | + else { |
|
292 | + return false; |
|
293 | + } |
|
283 | 294 | } |
284 | 295 | |
285 | 296 | // Get the specifics... |
286 | 297 | $column_info['size'] = isset($column_info['size']) && is_numeric($column_info['size']) ? $column_info['size'] : null; |
287 | 298 | list ($type, $size) = $smcFunc['db_calculate_type']($column_info['type'], $column_info['size']); |
288 | - if ($size !== null) |
|
289 | - $type = $type . '(' . $size . ')'; |
|
299 | + if ($size !== null) { |
|
300 | + $type = $type . '(' . $size . ')'; |
|
301 | + } |
|
290 | 302 | |
291 | 303 | // Now add the thing! |
292 | 304 | $query = ' |
@@ -301,11 +313,12 @@ discard block |
||
301 | 313 | // If there's more attributes they need to be done via a change on PostgreSQL. |
302 | 314 | unset($column_info['type'], $column_info['size']); |
303 | 315 | |
304 | - if (count($column_info) != 1) |
|
305 | - return $smcFunc['db_change_column']($table_name, $column_info['name'], $column_info); |
|
306 | - else |
|
307 | - return true; |
|
308 | -} |
|
316 | + if (count($column_info) != 1) { |
|
317 | + return $smcFunc['db_change_column']($table_name, $column_info['name'], $column_info); |
|
318 | + } else { |
|
319 | + return true; |
|
320 | + } |
|
321 | + } |
|
309 | 322 | |
310 | 323 | /** |
311 | 324 | * Removes a column. |
@@ -324,8 +337,8 @@ discard block |
||
324 | 337 | |
325 | 338 | // Does it exist? |
326 | 339 | $columns = $smcFunc['db_list_columns']($table_name, true); |
327 | - foreach ($columns as $column) |
|
328 | - if ($column['name'] == $column_name) |
|
340 | + foreach ($columns as $column) { |
|
341 | + if ($column['name'] == $column_name) |
|
329 | 342 | { |
330 | 343 | // If there is an auto we need remove it! |
331 | 344 | if ($column['auto']) |
@@ -335,6 +348,7 @@ discard block |
||
335 | 348 | 'security_override' => true, |
336 | 349 | ) |
337 | 350 | ); |
351 | + } |
|
338 | 352 | |
339 | 353 | $smcFunc['db_query']('', ' |
340 | 354 | ALTER TABLE ' . $table_name . ' |
@@ -369,13 +383,15 @@ discard block |
||
369 | 383 | // Check it does exist! |
370 | 384 | $columns = $smcFunc['db_list_columns']($table_name, true); |
371 | 385 | $old_info = null; |
372 | - foreach ($columns as $column) |
|
373 | - if ($column['name'] == $old_column) |
|
386 | + foreach ($columns as $column) { |
|
387 | + if ($column['name'] == $old_column) |
|
374 | 388 | $old_info = $column; |
389 | + } |
|
375 | 390 | |
376 | 391 | // Nothing? |
377 | - if ($old_info == null) |
|
378 | - return false; |
|
392 | + if ($old_info == null) { |
|
393 | + return false; |
|
394 | + } |
|
379 | 395 | |
380 | 396 | // Now we check each bit individually and ALTER as required. |
381 | 397 | if (isset($column_info['name']) && $column_info['name'] != $old_column) |
@@ -432,8 +448,9 @@ discard block |
||
432 | 448 | { |
433 | 449 | $column_info['size'] = isset($column_info['size']) && is_numeric($column_info['size']) ? $column_info['size'] : null; |
434 | 450 | list ($type, $size) = $smcFunc['db_calculate_type']($column_info['type'], $column_info['size']); |
435 | - if ($size !== null) |
|
436 | - $type = $type . '(' . $size . ')'; |
|
451 | + if ($size !== null) { |
|
452 | + $type = $type . '(' . $size . ')'; |
|
453 | + } |
|
437 | 454 | |
438 | 455 | // The alter is a pain. |
439 | 456 | $smcFunc['db_transaction']('begin'); |
@@ -527,21 +544,23 @@ discard block |
||
527 | 544 | $table_name = str_replace('{db_prefix}', $db_prefix, $table_name); |
528 | 545 | |
529 | 546 | // No columns = no index. |
530 | - if (empty($index_info['columns'])) |
|
531 | - return false; |
|
547 | + if (empty($index_info['columns'])) { |
|
548 | + return false; |
|
549 | + } |
|
532 | 550 | $columns = implode(',', $index_info['columns']); |
533 | 551 | |
534 | 552 | // No name - make it up! |
535 | 553 | if (empty($index_info['name'])) |
536 | 554 | { |
537 | 555 | // No need for primary. |
538 | - if (isset($index_info['type']) && $index_info['type'] == 'primary') |
|
539 | - $index_info['name'] = ''; |
|
540 | - else |
|
541 | - $index_info['name'] = $table_name . implode('_', $index_info['columns']); |
|
556 | + if (isset($index_info['type']) && $index_info['type'] == 'primary') { |
|
557 | + $index_info['name'] = ''; |
|
558 | + } else { |
|
559 | + $index_info['name'] = $table_name . implode('_', $index_info['columns']); |
|
560 | + } |
|
561 | + } else { |
|
562 | + $index_info['name'] = $table_name . $index_info['name']; |
|
542 | 563 | } |
543 | - else |
|
544 | - $index_info['name'] = $table_name . $index_info['name']; |
|
545 | 564 | |
546 | 565 | // Log that we are going to want to remove this! |
547 | 566 | $db_package_log[] = array('remove_index', $table_name, $index_info['name']); |
@@ -554,10 +573,11 @@ discard block |
||
554 | 573 | if ($index['name'] == $index_info['name'] || ($index['type'] == 'primary' && isset($index_info['type']) && $index_info['type'] == 'primary')) |
555 | 574 | { |
556 | 575 | // If we want to overwrite simply remove the current one then continue. |
557 | - if ($if_exists != 'update' || $index['type'] == 'primary') |
|
558 | - return false; |
|
559 | - else |
|
560 | - $smcFunc['db_remove_index']($table_name, $index_info['name']); |
|
576 | + if ($if_exists != 'update' || $index['type'] == 'primary') { |
|
577 | + return false; |
|
578 | + } else { |
|
579 | + $smcFunc['db_remove_index']($table_name, $index_info['name']); |
|
580 | + } |
|
561 | 581 | } |
562 | 582 | } |
563 | 583 | |
@@ -571,8 +591,7 @@ discard block |
||
571 | 591 | 'security_override' => true, |
572 | 592 | ) |
573 | 593 | ); |
574 | - } |
|
575 | - else |
|
594 | + } else |
|
576 | 595 | { |
577 | 596 | $smcFunc['db_query']('', ' |
578 | 597 | CREATE ' . (isset($index_info['type']) && $index_info['type'] == 'unique' ? 'UNIQUE' : '') . ' INDEX ' . $index_info['name'] . ' ON ' . $table_name . ' (' . $columns . ')', |
@@ -600,8 +619,9 @@ discard block |
||
600 | 619 | |
601 | 620 | // Better exist! |
602 | 621 | $indexes = $smcFunc['db_list_indexes']($table_name, true); |
603 | - if ($index_name != 'primary') |
|
604 | - $index_name = $table_name . '_' . $index_name; |
|
622 | + if ($index_name != 'primary') { |
|
623 | + $index_name = $table_name . '_' . $index_name; |
|
624 | + } |
|
605 | 625 | |
606 | 626 | foreach ($indexes as $index) |
607 | 627 | { |
@@ -665,8 +685,7 @@ discard block |
||
665 | 685 | 'datetime' => 'timestamp without time zone', |
666 | 686 | 'timestamp' => 'timestamp without time zone', |
667 | 687 | ); |
668 | - } |
|
669 | - else |
|
688 | + } else |
|
670 | 689 | { |
671 | 690 | $types = array( |
672 | 691 | 'character varying' => 'varchar', |
@@ -682,14 +701,16 @@ discard block |
||
682 | 701 | // Got it? Change it! |
683 | 702 | if (isset($types[$type_name])) |
684 | 703 | { |
685 | - if ($type_name == 'tinytext') |
|
686 | - $type_size = 255; |
|
704 | + if ($type_name == 'tinytext') { |
|
705 | + $type_size = 255; |
|
706 | + } |
|
687 | 707 | $type_name = $types[$type_name]; |
688 | 708 | } |
689 | 709 | |
690 | 710 | // Only char fields got size |
691 | - if (strpos($type_name, 'char') === false) |
|
692 | - $type_size = null; |
|
711 | + if (strpos($type_name, 'char') === false) { |
|
712 | + $type_size = null; |
|
713 | + } |
|
693 | 714 | |
694 | 715 | |
695 | 716 | return array($type_name, $type_size); |
@@ -744,8 +765,7 @@ discard block |
||
744 | 765 | if (!$detail) |
745 | 766 | { |
746 | 767 | $columns[] = $row['column_name']; |
747 | - } |
|
748 | - else |
|
768 | + } else |
|
749 | 769 | { |
750 | 770 | $auto = false; |
751 | 771 | // What is the default? |
@@ -753,11 +773,11 @@ discard block |
||
753 | 773 | { |
754 | 774 | $default = null; |
755 | 775 | $auto = true; |
776 | + } elseif (trim($row['column_default']) != '') { |
|
777 | + $default = strpos($row['column_default'], '::') === false ? $row['column_default'] : substr($row['column_default'], 0, strpos($row['column_default'], '::')); |
|
778 | + } else { |
|
779 | + $default = null; |
|
756 | 780 | } |
757 | - elseif (trim($row['column_default']) != '') |
|
758 | - $default = strpos($row['column_default'], '::') === false ? $row['column_default'] : substr($row['column_default'], 0, strpos($row['column_default'], '::')); |
|
759 | - else |
|
760 | - $default = null; |
|
761 | 781 | |
762 | 782 | // Make the type generic. |
763 | 783 | list ($type, $size) = $smcFunc['db_calculate_type']($row['data_type'], $row['character_maximum_length'], true); |
@@ -808,26 +828,30 @@ discard block |
||
808 | 828 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
809 | 829 | { |
810 | 830 | // Try get the columns that make it up. |
811 | - if (preg_match('~\(([^\)]+?)\)~i', $row['inddef'], $matches) == 0) |
|
812 | - continue; |
|
831 | + if (preg_match('~\(([^\)]+?)\)~i', $row['inddef'], $matches) == 0) { |
|
832 | + continue; |
|
833 | + } |
|
813 | 834 | |
814 | 835 | $columns = explode(',', $matches[1]); |
815 | 836 | |
816 | - if (empty($columns)) |
|
817 | - continue; |
|
837 | + if (empty($columns)) { |
|
838 | + continue; |
|
839 | + } |
|
818 | 840 | |
819 | - foreach ($columns as $k => $v) |
|
820 | - $columns[$k] = trim($v); |
|
841 | + foreach ($columns as $k => $v) { |
|
842 | + $columns[$k] = trim($v); |
|
843 | + } |
|
821 | 844 | |
822 | 845 | // Fix up the name to be consistent cross databases |
823 | - if (substr($row['name'], -5) == '_pkey' && $row['is_primary'] == 1) |
|
824 | - $row['name'] = 'PRIMARY'; |
|
825 | - else |
|
826 | - $row['name'] = str_replace($table_name . '_', '', $row['name']); |
|
846 | + if (substr($row['name'], -5) == '_pkey' && $row['is_primary'] == 1) { |
|
847 | + $row['name'] = 'PRIMARY'; |
|
848 | + } else { |
|
849 | + $row['name'] = str_replace($table_name . '_', '', $row['name']); |
|
850 | + } |
|
827 | 851 | |
828 | - if (!$detail) |
|
829 | - $indexes[] = $row['name']; |
|
830 | - else |
|
852 | + if (!$detail) { |
|
853 | + $indexes[] = $row['name']; |
|
854 | + } else |
|
831 | 855 | { |
832 | 856 | $indexes[$row['name']] = array( |
833 | 857 | 'name' => $row['name'], |
@@ -11,8 +11,9 @@ discard block |
||
11 | 11 | * @version 2.1 Beta 3 |
12 | 12 | */ |
13 | 13 | |
14 | -if (!defined('SMF')) |
|
14 | +if (!defined('SMF')) { |
|
15 | 15 | die('No direct access...'); |
16 | +} |
|
16 | 17 | |
17 | 18 | /** |
18 | 19 | * View a summary. |
@@ -23,8 +24,9 @@ discard block |
||
23 | 24 | global $context, $memberContext, $txt, $modSettings, $user_profile, $sourcedir, $scripturl, $smcFunc; |
24 | 25 | |
25 | 26 | // Attempt to load the member's profile data. |
26 | - if (!loadMemberContext($memID) || !isset($memberContext[$memID])) |
|
27 | - fatal_lang_error('not_a_user', false, 404); |
|
27 | + if (!loadMemberContext($memID) || !isset($memberContext[$memID])) { |
|
28 | + fatal_lang_error('not_a_user', false, 404); |
|
29 | + } |
|
28 | 30 | |
29 | 31 | // Set up the stuff and load the user. |
30 | 32 | $context += array( |
@@ -49,19 +51,21 @@ discard block |
||
49 | 51 | |
50 | 52 | // See if they have broken any warning levels... |
51 | 53 | list ($modSettings['warning_enable'], $modSettings['user_limit']) = explode(',', $modSettings['warning_settings']); |
52 | - if (!empty($modSettings['warning_mute']) && $modSettings['warning_mute'] <= $context['member']['warning']) |
|
53 | - $context['warning_status'] = $txt['profile_warning_is_muted']; |
|
54 | - elseif (!empty($modSettings['warning_moderate']) && $modSettings['warning_moderate'] <= $context['member']['warning']) |
|
55 | - $context['warning_status'] = $txt['profile_warning_is_moderation']; |
|
56 | - elseif (!empty($modSettings['warning_watch']) && $modSettings['warning_watch'] <= $context['member']['warning']) |
|
57 | - $context['warning_status'] = $txt['profile_warning_is_watch']; |
|
54 | + if (!empty($modSettings['warning_mute']) && $modSettings['warning_mute'] <= $context['member']['warning']) { |
|
55 | + $context['warning_status'] = $txt['profile_warning_is_muted']; |
|
56 | + } elseif (!empty($modSettings['warning_moderate']) && $modSettings['warning_moderate'] <= $context['member']['warning']) { |
|
57 | + $context['warning_status'] = $txt['profile_warning_is_moderation']; |
|
58 | + } elseif (!empty($modSettings['warning_watch']) && $modSettings['warning_watch'] <= $context['member']['warning']) { |
|
59 | + $context['warning_status'] = $txt['profile_warning_is_watch']; |
|
60 | + } |
|
58 | 61 | |
59 | 62 | // They haven't even been registered for a full day!? |
60 | 63 | $days_registered = (int) ((time() - $user_profile[$memID]['date_registered']) / (3600 * 24)); |
61 | - if (empty($user_profile[$memID]['date_registered']) || $days_registered < 1) |
|
62 | - $context['member']['posts_per_day'] = $txt['not_applicable']; |
|
63 | - else |
|
64 | - $context['member']['posts_per_day'] = comma_format($context['member']['real_posts'] / $days_registered, 3); |
|
64 | + if (empty($user_profile[$memID]['date_registered']) || $days_registered < 1) { |
|
65 | + $context['member']['posts_per_day'] = $txt['not_applicable']; |
|
66 | + } else { |
|
67 | + $context['member']['posts_per_day'] = comma_format($context['member']['real_posts'] / $days_registered, 3); |
|
68 | + } |
|
65 | 69 | |
66 | 70 | // Set the age... |
67 | 71 | if (empty($context['member']['birth_date'])) |
@@ -70,8 +74,7 @@ discard block |
||
70 | 74 | 'age' => $txt['not_applicable'], |
71 | 75 | 'today_is_birthday' => false |
72 | 76 | ); |
73 | - } |
|
74 | - else |
|
77 | + } else |
|
75 | 78 | { |
76 | 79 | list ($birth_year, $birth_month, $birth_day) = sscanf($context['member']['birth_date'], '%d-%d-%d'); |
77 | 80 | $datearray = getdate(forum_time()); |
@@ -84,15 +87,16 @@ discard block |
||
84 | 87 | if (allowedTo('moderate_forum')) |
85 | 88 | { |
86 | 89 | // Make sure it's a valid ip address; otherwise, don't bother... |
87 | - if (preg_match('/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/', $memberContext[$memID]['ip']) == 1 && empty($modSettings['disableHostnameLookup'])) |
|
88 | - $context['member']['hostname'] = host_from_ip($memberContext[$memID]['ip']); |
|
89 | - else |
|
90 | - $context['member']['hostname'] = ''; |
|
90 | + if (preg_match('/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/', $memberContext[$memID]['ip']) == 1 && empty($modSettings['disableHostnameLookup'])) { |
|
91 | + $context['member']['hostname'] = host_from_ip($memberContext[$memID]['ip']); |
|
92 | + } else { |
|
93 | + $context['member']['hostname'] = ''; |
|
94 | + } |
|
91 | 95 | |
92 | 96 | $context['can_see_ip'] = true; |
97 | + } else { |
|
98 | + $context['can_see_ip'] = false; |
|
93 | 99 | } |
94 | - else |
|
95 | - $context['can_see_ip'] = false; |
|
96 | 100 | |
97 | 101 | // Are they hidden? |
98 | 102 | $context['member']['is_hidden'] = empty($user_profile[$memID]['show_online']); |
@@ -103,8 +107,9 @@ discard block |
||
103 | 107 | include_once($sourcedir . '/Who.php'); |
104 | 108 | $action = determineActions($user_profile[$memID]['url']); |
105 | 109 | |
106 | - if ($action !== false) |
|
107 | - $context['member']['action'] = $action; |
|
110 | + if ($action !== false) { |
|
111 | + $context['member']['action'] = $action; |
|
112 | + } |
|
108 | 113 | } |
109 | 114 | |
110 | 115 | // If the user is awaiting activation, and the viewer has permission - setup some activation context messages. |
@@ -167,13 +172,15 @@ discard block |
||
167 | 172 | { |
168 | 173 | // Work out what restrictions we actually have. |
169 | 174 | $ban_restrictions = array(); |
170 | - foreach (array('access', 'register', 'login', 'post') as $type) |
|
171 | - if ($row['cannot_' . $type]) |
|
175 | + foreach (array('access', 'register', 'login', 'post') as $type) { |
|
176 | + if ($row['cannot_' . $type]) |
|
172 | 177 | $ban_restrictions[] = $txt['ban_type_' . $type]; |
178 | + } |
|
173 | 179 | |
174 | 180 | // No actual ban in place? |
175 | - if (empty($ban_restrictions)) |
|
176 | - continue; |
|
181 | + if (empty($ban_restrictions)) { |
|
182 | + continue; |
|
183 | + } |
|
177 | 184 | |
178 | 185 | // Prepare the link for context. |
179 | 186 | $ban_explanation = sprintf($txt['user_cannot_due_to'], implode(', ', $ban_restrictions), '<a href="' . $scripturl . '?action=admin;area=ban;sa=edit;bg=' . $row['id_ban_group'] . '">' . $row['name'] . '</a>'); |
@@ -196,9 +203,10 @@ discard block |
||
196 | 203 | $context['print_custom_fields'] = array(); |
197 | 204 | |
198 | 205 | // Any custom profile fields? |
199 | - if (!empty($context['custom_fields'])) |
|
200 | - foreach ($context['custom_fields'] as $custom) |
|
206 | + if (!empty($context['custom_fields'])) { |
|
207 | + foreach ($context['custom_fields'] as $custom) |
|
201 | 208 | $context['print_custom_fields'][$context['cust_profile_fields_placement'][$custom['placement']]][] = $custom; |
209 | + } |
|
202 | 210 | |
203 | 211 | } |
204 | 212 | |
@@ -242,14 +250,16 @@ discard block |
||
242 | 250 | $row['extra'] = !empty($row['extra']) ? smf_json_decode($row['extra'], true) : array(); |
243 | 251 | $alerts[$id_alert] = $row; |
244 | 252 | |
245 | - if (!empty($row['sender_id'])) |
|
246 | - $senders[] = $row['sender_id']; |
|
253 | + if (!empty($row['sender_id'])) { |
|
254 | + $senders[] = $row['sender_id']; |
|
255 | + } |
|
247 | 256 | } |
248 | 257 | $smcFunc['db_free_result']($request); |
249 | 258 | |
250 | 259 | $senders = loadMemberData($senders); |
251 | - foreach ($senders as $member) |
|
252 | - loadMemberContext($member); |
|
260 | + foreach ($senders as $member) { |
|
261 | + loadMemberContext($member); |
|
262 | + } |
|
253 | 263 | |
254 | 264 | // Now go through and actually make with the text. |
255 | 265 | loadLanguage('Alerts'); |
@@ -263,12 +273,15 @@ discard block |
||
263 | 273 | $msgs = array(); |
264 | 274 | foreach ($alerts as $id_alert => $alert) |
265 | 275 | { |
266 | - if (isset($alert['extra']['board'])) |
|
267 | - $boards[$alert['extra']['board']] = $txt['board_na']; |
|
268 | - if (isset($alert['extra']['topic'])) |
|
269 | - $topics[$alert['extra']['topic']] = $txt['topic_na']; |
|
270 | - if ($alert['content_type'] == 'msg') |
|
271 | - $msgs[$alert['content_id']] = $txt['topic_na']; |
|
276 | + if (isset($alert['extra']['board'])) { |
|
277 | + $boards[$alert['extra']['board']] = $txt['board_na']; |
|
278 | + } |
|
279 | + if (isset($alert['extra']['topic'])) { |
|
280 | + $topics[$alert['extra']['topic']] = $txt['topic_na']; |
|
281 | + } |
|
282 | + if ($alert['content_type'] == 'msg') { |
|
283 | + $msgs[$alert['content_id']] = $txt['topic_na']; |
|
284 | + } |
|
272 | 285 | } |
273 | 286 | |
274 | 287 | // Having figured out what boards etc. there are, let's now get the names of them if we can see them. If not, there's already a fallback set up. |
@@ -283,8 +296,9 @@ discard block |
||
283 | 296 | 'boards' => array_keys($boards), |
284 | 297 | ) |
285 | 298 | ); |
286 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
287 | - $boards[$row['id_board']] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
299 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
300 | + $boards[$row['id_board']] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
301 | + } |
|
288 | 302 | } |
289 | 303 | if (!empty($topics)) |
290 | 304 | { |
@@ -299,8 +313,9 @@ discard block |
||
299 | 313 | 'topics' => array_keys($topics), |
300 | 314 | ) |
301 | 315 | ); |
302 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
303 | - $topics[$row['id_topic']] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">' . $row['subject'] . '</a>'; |
|
316 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
317 | + $topics[$row['id_topic']] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">' . $row['subject'] . '</a>'; |
|
318 | + } |
|
304 | 319 | } |
305 | 320 | if (!empty($msgs)) |
306 | 321 | { |
@@ -315,26 +330,33 @@ discard block |
||
315 | 330 | 'msgs' => array_keys($msgs), |
316 | 331 | ) |
317 | 332 | ); |
318 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
319 | - $msgs[$row['id_msg']] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'] . '">' . $row['subject'] . '</a>'; |
|
333 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
334 | + $msgs[$row['id_msg']] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'] . '">' . $row['subject'] . '</a>'; |
|
335 | + } |
|
320 | 336 | } |
321 | 337 | |
322 | 338 | // Now to go back through the alerts, reattach this extra information and then try to build the string out of it (if a hook didn't already) |
323 | 339 | foreach ($alerts as $id_alert => $alert) |
324 | 340 | { |
325 | - if (!empty($alert['text'])) |
|
326 | - continue; |
|
327 | - if (isset($alert['extra']['board'])) |
|
328 | - $alerts[$id_alert]['extra']['board_msg'] = $boards[$alert['extra']['board']]; |
|
329 | - if (isset($alert['extra']['topic'])) |
|
330 | - $alerts[$id_alert]['extra']['topic_msg'] = $topics[$alert['extra']['topic']]; |
|
331 | - if ($alert['content_type'] == 'msg') |
|
332 | - $alerts[$id_alert]['extra']['msg_msg'] = $msgs[$alert['content_id']]; |
|
333 | - if ($alert['content_type'] == 'profile') |
|
334 | - $alerts[$id_alert]['extra']['profile_msg'] = '<a href="' . $scripturl . '?action=profile;u=' . $alerts[$id_alert]['content_id'] . '">' . $alerts[$id_alert]['extra']['user_name'] . '</a>'; |
|
335 | - |
|
336 | - if (!empty($memberContext[$alert['sender_id']])) |
|
337 | - $alerts[$id_alert]['sender'] = &$memberContext[$alert['sender_id']]; |
|
341 | + if (!empty($alert['text'])) { |
|
342 | + continue; |
|
343 | + } |
|
344 | + if (isset($alert['extra']['board'])) { |
|
345 | + $alerts[$id_alert]['extra']['board_msg'] = $boards[$alert['extra']['board']]; |
|
346 | + } |
|
347 | + if (isset($alert['extra']['topic'])) { |
|
348 | + $alerts[$id_alert]['extra']['topic_msg'] = $topics[$alert['extra']['topic']]; |
|
349 | + } |
|
350 | + if ($alert['content_type'] == 'msg') { |
|
351 | + $alerts[$id_alert]['extra']['msg_msg'] = $msgs[$alert['content_id']]; |
|
352 | + } |
|
353 | + if ($alert['content_type'] == 'profile') { |
|
354 | + $alerts[$id_alert]['extra']['profile_msg'] = '<a href="' . $scripturl . '?action=profile;u=' . $alerts[$id_alert]['content_id'] . '">' . $alerts[$id_alert]['extra']['user_name'] . '</a>'; |
|
355 | + } |
|
356 | + |
|
357 | + if (!empty($memberContext[$alert['sender_id']])) { |
|
358 | + $alerts[$id_alert]['sender'] = &$memberContext[$alert['sender_id']]; |
|
359 | + } |
|
338 | 360 | |
339 | 361 | $string = 'alert_' . $alert['content_type'] . '_' . $alert['content_action']; |
340 | 362 | if (isset($txt[$string])) |
@@ -422,11 +444,11 @@ discard block |
||
422 | 444 | checkSession('request'); |
423 | 445 | |
424 | 446 | // Call it! |
425 | - if ($action == 'remove') |
|
426 | - alert_delete($toMark, $memID); |
|
427 | - |
|
428 | - else |
|
429 | - alert_mark($memID, $toMark, $action == 'read' ? 1 : 0); |
|
447 | + if ($action == 'remove') { |
|
448 | + alert_delete($toMark, $memID); |
|
449 | + } else { |
|
450 | + alert_mark($memID, $toMark, $action == 'read' ? 1 : 0); |
|
451 | + } |
|
430 | 452 | |
431 | 453 | // Set a nice update message. |
432 | 454 | $_SESSION['update_message'] = true; |
@@ -476,23 +498,27 @@ discard block |
||
476 | 498 | ); |
477 | 499 | |
478 | 500 | // Set the page title |
479 | - if (isset($_GET['sa']) && array_key_exists($_GET['sa'], $title)) |
|
480 | - $context['page_title'] = $txt['show' . $title[$_GET['sa']]]; |
|
481 | - else |
|
482 | - $context['page_title'] = $txt['showPosts']; |
|
501 | + if (isset($_GET['sa']) && array_key_exists($_GET['sa'], $title)) { |
|
502 | + $context['page_title'] = $txt['show' . $title[$_GET['sa']]]; |
|
503 | + } else { |
|
504 | + $context['page_title'] = $txt['showPosts']; |
|
505 | + } |
|
483 | 506 | |
484 | 507 | $context['page_title'] .= ' - ' . $user_profile[$memID]['real_name']; |
485 | 508 | |
486 | 509 | // Is the load average too high to allow searching just now? |
487 | - if (!empty($context['load_average']) && !empty($modSettings['loadavg_show_posts']) && $context['load_average'] >= $modSettings['loadavg_show_posts']) |
|
488 | - fatal_lang_error('loadavg_show_posts_disabled', false); |
|
510 | + if (!empty($context['load_average']) && !empty($modSettings['loadavg_show_posts']) && $context['load_average'] >= $modSettings['loadavg_show_posts']) { |
|
511 | + fatal_lang_error('loadavg_show_posts_disabled', false); |
|
512 | + } |
|
489 | 513 | |
490 | 514 | // If we're specifically dealing with attachments use that function! |
491 | - if (isset($_GET['sa']) && $_GET['sa'] == 'attach') |
|
492 | - return showAttachments($memID); |
|
515 | + if (isset($_GET['sa']) && $_GET['sa'] == 'attach') { |
|
516 | + return showAttachments($memID); |
|
517 | + } |
|
493 | 518 | // Instead, if we're dealing with unwatched topics (and the feature is enabled) use that other function. |
494 | - elseif (isset($_GET['sa']) && $_GET['sa'] == 'unwatchedtopics') |
|
495 | - return showUnwatched($memID); |
|
519 | + elseif (isset($_GET['sa']) && $_GET['sa'] == 'unwatchedtopics') { |
|
520 | + return showUnwatched($memID); |
|
521 | + } |
|
496 | 522 | |
497 | 523 | // Are we just viewing topics? |
498 | 524 | $context['is_topics'] = isset($_GET['sa']) && $_GET['sa'] == 'topics' ? true : false; |
@@ -515,27 +541,30 @@ discard block |
||
515 | 541 | $smcFunc['db_free_result']($request); |
516 | 542 | |
517 | 543 | // Trying to remove a message that doesn't exist. |
518 | - if (empty($info)) |
|
519 | - redirectexit('action=profile;u=' . $memID . ';area=showposts;start=' . $_GET['start']); |
|
544 | + if (empty($info)) { |
|
545 | + redirectexit('action=profile;u=' . $memID . ';area=showposts;start=' . $_GET['start']); |
|
546 | + } |
|
520 | 547 | |
521 | 548 | // We can be lazy, since removeMessage() will check the permissions for us. |
522 | 549 | require_once($sourcedir . '/RemoveTopic.php'); |
523 | 550 | removeMessage((int) $_GET['delete']); |
524 | 551 | |
525 | 552 | // Add it to the mod log. |
526 | - if (allowedTo('delete_any') && (!allowedTo('delete_own') || $info[1] != $user_info['id'])) |
|
527 | - logAction('delete', array('topic' => $info[2], 'subject' => $info[0], 'member' => $info[1], 'board' => $info[3])); |
|
553 | + if (allowedTo('delete_any') && (!allowedTo('delete_own') || $info[1] != $user_info['id'])) { |
|
554 | + logAction('delete', array('topic' => $info[2], 'subject' => $info[0], 'member' => $info[1], 'board' => $info[3])); |
|
555 | + } |
|
528 | 556 | |
529 | 557 | // Back to... where we are now ;). |
530 | 558 | redirectexit('action=profile;u=' . $memID . ';area=showposts;start=' . $_GET['start']); |
531 | 559 | } |
532 | 560 | |
533 | 561 | // Default to 10. |
534 | - if (empty($_REQUEST['viewscount']) || !is_numeric($_REQUEST['viewscount'])) |
|
535 | - $_REQUEST['viewscount'] = '10'; |
|
562 | + if (empty($_REQUEST['viewscount']) || !is_numeric($_REQUEST['viewscount'])) { |
|
563 | + $_REQUEST['viewscount'] = '10'; |
|
564 | + } |
|
536 | 565 | |
537 | - if ($context['is_topics']) |
|
538 | - $request = $smcFunc['db_query']('', ' |
|
566 | + if ($context['is_topics']) { |
|
567 | + $request = $smcFunc['db_query']('', ' |
|
539 | 568 | SELECT COUNT(*) |
540 | 569 | FROM {db_prefix}topics AS t' . ($user_info['query_see_board'] == '1=1' ? '' : ' |
541 | 570 | INNER JOIN {db_prefix}boards AS b ON (b.id_board = t.id_board AND {query_see_board})') . ' |
@@ -548,8 +577,8 @@ discard block |
||
548 | 577 | 'board' => $board, |
549 | 578 | ) |
550 | 579 | ); |
551 | - else |
|
552 | - $request = $smcFunc['db_query']('', ' |
|
580 | + } else { |
|
581 | + $request = $smcFunc['db_query']('', ' |
|
553 | 582 | SELECT COUNT(*) |
554 | 583 | FROM {db_prefix}messages AS m' . ($user_info['query_see_board'] == '1=1' ? '' : ' |
555 | 584 | INNER JOIN {db_prefix}boards AS b ON (b.id_board = m.id_board AND {query_see_board})') . ' |
@@ -562,6 +591,7 @@ discard block |
||
562 | 591 | 'board' => $board, |
563 | 592 | ) |
564 | 593 | ); |
594 | + } |
|
565 | 595 | list ($msgCount) = $smcFunc['db_fetch_row']($request); |
566 | 596 | $smcFunc['db_free_result']($request); |
567 | 597 | |
@@ -583,10 +613,11 @@ discard block |
||
583 | 613 | $reverse = false; |
584 | 614 | $range_limit = ''; |
585 | 615 | |
586 | - if ($context['is_topics']) |
|
587 | - $maxPerPage = empty($modSettings['disableCustomPerPage']) && !empty($options['topics_per_page']) ? $options['topics_per_page'] : $modSettings['defaultMaxTopics']; |
|
588 | - else |
|
589 | - $maxPerPage = empty($modSettings['disableCustomPerPage']) && !empty($options['messages_per_page']) ? $options['messages_per_page'] : $modSettings['defaultMaxMessages']; |
|
616 | + if ($context['is_topics']) { |
|
617 | + $maxPerPage = empty($modSettings['disableCustomPerPage']) && !empty($options['topics_per_page']) ? $options['topics_per_page'] : $modSettings['defaultMaxTopics']; |
|
618 | + } else { |
|
619 | + $maxPerPage = empty($modSettings['disableCustomPerPage']) && !empty($options['messages_per_page']) ? $options['messages_per_page'] : $modSettings['defaultMaxMessages']; |
|
620 | + } |
|
590 | 621 | |
591 | 622 | $maxIndex = $maxPerPage; |
592 | 623 | |
@@ -612,9 +643,9 @@ discard block |
||
612 | 643 | { |
613 | 644 | $margin *= 5; |
614 | 645 | $range_limit = $reverse ? 't.id_first_msg < ' . ($min_msg_member + $margin) : 't.id_first_msg > ' . ($max_msg_member - $margin); |
646 | + } else { |
|
647 | + $range_limit = $reverse ? 'm.id_msg < ' . ($min_msg_member + $margin) : 'm.id_msg > ' . ($max_msg_member - $margin); |
|
615 | 648 | } |
616 | - else |
|
617 | - $range_limit = $reverse ? 'm.id_msg < ' . ($min_msg_member + $margin) : 'm.id_msg > ' . ($max_msg_member - $margin); |
|
618 | 649 | } |
619 | 650 | |
620 | 651 | // Find this user's posts. The left join on categories somehow makes this faster, weird as it looks. |
@@ -646,8 +677,7 @@ discard block |
||
646 | 677 | 'max' => $maxIndex, |
647 | 678 | ) |
648 | 679 | ); |
649 | - } |
|
650 | - else |
|
680 | + } else |
|
651 | 681 | { |
652 | 682 | $request = $smcFunc['db_query']('', ' |
653 | 683 | SELECT |
@@ -676,8 +706,9 @@ discard block |
||
676 | 706 | } |
677 | 707 | |
678 | 708 | // Make sure we quit this loop. |
679 | - if ($smcFunc['db_num_rows']($request) === $maxIndex || $looped) |
|
680 | - break; |
|
709 | + if ($smcFunc['db_num_rows']($request) === $maxIndex || $looped) { |
|
710 | + break; |
|
711 | + } |
|
681 | 712 | $looped = true; |
682 | 713 | $range_limit = ''; |
683 | 714 | } |
@@ -721,19 +752,21 @@ discard block |
||
721 | 752 | 'css_class' => $row['approved'] ? 'windowbg' : 'approvebg', |
722 | 753 | ); |
723 | 754 | |
724 | - if ($user_info['id'] == $row['id_member_started']) |
|
725 | - $board_ids['own'][$row['id_board']][] = $counter; |
|
755 | + if ($user_info['id'] == $row['id_member_started']) { |
|
756 | + $board_ids['own'][$row['id_board']][] = $counter; |
|
757 | + } |
|
726 | 758 | $board_ids['any'][$row['id_board']][] = $counter; |
727 | 759 | } |
728 | 760 | $smcFunc['db_free_result']($request); |
729 | 761 | |
730 | 762 | // All posts were retrieved in reverse order, get them right again. |
731 | - if ($reverse) |
|
732 | - $context['posts'] = array_reverse($context['posts'], true); |
|
763 | + if ($reverse) { |
|
764 | + $context['posts'] = array_reverse($context['posts'], true); |
|
765 | + } |
|
733 | 766 | |
734 | 767 | // These are all the permissions that are different from board to board.. |
735 | - if ($context['is_topics']) |
|
736 | - $permissions = array( |
|
768 | + if ($context['is_topics']) { |
|
769 | + $permissions = array( |
|
737 | 770 | 'own' => array( |
738 | 771 | 'post_reply_own' => 'can_reply', |
739 | 772 | ), |
@@ -741,8 +774,8 @@ discard block |
||
741 | 774 | 'post_reply_any' => 'can_reply', |
742 | 775 | ) |
743 | 776 | ); |
744 | - else |
|
745 | - $permissions = array( |
|
777 | + } else { |
|
778 | + $permissions = array( |
|
746 | 779 | 'own' => array( |
747 | 780 | 'post_reply_own' => 'can_reply', |
748 | 781 | 'delete_own' => 'can_delete', |
@@ -752,6 +785,7 @@ discard block |
||
752 | 785 | 'delete_any' => 'can_delete', |
753 | 786 | ) |
754 | 787 | ); |
788 | + } |
|
755 | 789 | |
756 | 790 | // For every permission in the own/any lists... |
757 | 791 | foreach ($permissions as $type => $list) |
@@ -762,19 +796,22 @@ discard block |
||
762 | 796 | $boards = boardsAllowedTo($permission); |
763 | 797 | |
764 | 798 | // Hmm, they can do it on all boards, can they? |
765 | - if (!empty($boards) && $boards[0] == 0) |
|
766 | - $boards = array_keys($board_ids[$type]); |
|
799 | + if (!empty($boards) && $boards[0] == 0) { |
|
800 | + $boards = array_keys($board_ids[$type]); |
|
801 | + } |
|
767 | 802 | |
768 | 803 | // Now go through each board they can do the permission on. |
769 | 804 | foreach ($boards as $board_id) |
770 | 805 | { |
771 | 806 | // There aren't any posts displayed from this board. |
772 | - if (!isset($board_ids[$type][$board_id])) |
|
773 | - continue; |
|
807 | + if (!isset($board_ids[$type][$board_id])) { |
|
808 | + continue; |
|
809 | + } |
|
774 | 810 | |
775 | 811 | // Set the permission to true ;). |
776 | - foreach ($board_ids[$type][$board_id] as $counter) |
|
777 | - $context['posts'][$counter][$allowed] = true; |
|
812 | + foreach ($board_ids[$type][$board_id] as $counter) { |
|
813 | + $context['posts'][$counter][$allowed] = true; |
|
814 | + } |
|
778 | 815 | } |
779 | 816 | } |
780 | 817 | } |
@@ -805,8 +842,9 @@ discard block |
||
805 | 842 | $boardsAllowed = boardsAllowedTo('view_attachments'); |
806 | 843 | |
807 | 844 | // Make sure we can't actually see anything... |
808 | - if (empty($boardsAllowed)) |
|
809 | - $boardsAllowed = array(-1); |
|
845 | + if (empty($boardsAllowed)) { |
|
846 | + $boardsAllowed = array(-1); |
|
847 | + } |
|
810 | 848 | |
811 | 849 | require_once($sourcedir . '/Subs-List.php'); |
812 | 850 | |
@@ -957,8 +995,8 @@ discard block |
||
957 | 995 | ) |
958 | 996 | ); |
959 | 997 | $attachments = array(); |
960 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
961 | - $attachments[] = array( |
|
998 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
999 | + $attachments[] = array( |
|
962 | 1000 | 'id' => $row['id_attach'], |
963 | 1001 | 'filename' => $row['filename'], |
964 | 1002 | 'downloads' => $row['downloads'], |
@@ -970,6 +1008,7 @@ discard block |
||
970 | 1008 | 'board_name' => $row['name'], |
971 | 1009 | 'approved' => $row['approved'], |
972 | 1010 | ); |
1011 | + } |
|
973 | 1012 | |
974 | 1013 | $smcFunc['db_free_result']($request); |
975 | 1014 | |
@@ -1024,8 +1063,9 @@ discard block |
||
1024 | 1063 | global $txt, $user_info, $scripturl, $modSettings, $context, $sourcedir; |
1025 | 1064 | |
1026 | 1065 | // Only the owner can see the list (if the function is enabled of course) |
1027 | - if ($user_info['id'] != $memID) |
|
1028 | - return; |
|
1066 | + if ($user_info['id'] != $memID) { |
|
1067 | + return; |
|
1068 | + } |
|
1029 | 1069 | |
1030 | 1070 | require_once($sourcedir . '/Subs-List.php'); |
1031 | 1071 | |
@@ -1171,8 +1211,9 @@ discard block |
||
1171 | 1211 | ); |
1172 | 1212 | |
1173 | 1213 | $topics = array(); |
1174 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1175 | - $topics[] = $row['id_topic']; |
|
1214 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1215 | + $topics[] = $row['id_topic']; |
|
1216 | + } |
|
1176 | 1217 | |
1177 | 1218 | $smcFunc['db_free_result']($request); |
1178 | 1219 | |
@@ -1192,8 +1233,9 @@ discard block |
||
1192 | 1233 | 'topics' => $topics, |
1193 | 1234 | ) |
1194 | 1235 | ); |
1195 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1196 | - $topicsInfo[] = $row; |
|
1236 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1237 | + $topicsInfo[] = $row; |
|
1238 | + } |
|
1197 | 1239 | $smcFunc['db_free_result']($request); |
1198 | 1240 | } |
1199 | 1241 | |
@@ -1241,8 +1283,9 @@ discard block |
||
1241 | 1283 | $context['page_title'] = $txt['statPanel_showStats'] . ' ' . $user_profile[$memID]['real_name']; |
1242 | 1284 | |
1243 | 1285 | // Is the load average too high to allow searching just now? |
1244 | - if (!empty($context['load_average']) && !empty($modSettings['loadavg_userstats']) && $context['load_average'] >= $modSettings['loadavg_userstats']) |
|
1245 | - fatal_lang_error('loadavg_userstats_disabled', false); |
|
1286 | + if (!empty($context['load_average']) && !empty($modSettings['loadavg_userstats']) && $context['load_average'] >= $modSettings['loadavg_userstats']) { |
|
1287 | + fatal_lang_error('loadavg_userstats_disabled', false); |
|
1288 | + } |
|
1246 | 1289 | |
1247 | 1290 | // General user statistics. |
1248 | 1291 | $timeDays = floor($user_profile[$memID]['total_time_logged_in'] / 86400); |
@@ -1400,11 +1443,13 @@ discard block |
||
1400 | 1443 | } |
1401 | 1444 | $smcFunc['db_free_result']($result); |
1402 | 1445 | |
1403 | - if ($maxPosts > 0) |
|
1404 | - for ($hour = 0; $hour < 24; $hour++) |
|
1446 | + if ($maxPosts > 0) { |
|
1447 | + for ($hour = 0; |
|
1448 | + } |
|
1449 | + $hour < 24; $hour++) |
|
1405 | 1450 | { |
1406 | - if (!isset($context['posts_by_time'][$hour])) |
|
1407 | - $context['posts_by_time'][$hour] = array( |
|
1451 | + if (!isset($context['posts_by_time'][$hour])) { |
|
1452 | + $context['posts_by_time'][$hour] = array( |
|
1408 | 1453 | 'hour' => $hour, |
1409 | 1454 | 'hour_format' => stripos($user_info['time_format'], '%p') === false ? $hour : date('g a', mktime($hour)), |
1410 | 1455 | 'posts' => 0, |
@@ -1412,7 +1457,7 @@ discard block |
||
1412 | 1457 | 'relative_percent' => 0, |
1413 | 1458 | 'is_last' => $hour == 23, |
1414 | 1459 | ); |
1415 | - else |
|
1460 | + } else |
|
1416 | 1461 | { |
1417 | 1462 | $context['posts_by_time'][$hour]['posts_percent'] = round(($context['posts_by_time'][$hour]['posts'] * 100) / $realPosts); |
1418 | 1463 | $context['posts_by_time'][$hour]['relative_percent'] = round(($context['posts_by_time'][$hour]['posts'] * 100) / $maxPosts); |
@@ -1445,8 +1490,9 @@ discard block |
||
1445 | 1490 | |
1446 | 1491 | foreach ($subActions as $sa => $action) |
1447 | 1492 | { |
1448 | - if (!allowedTo($action[2])) |
|
1449 | - unset($subActions[$sa]); |
|
1493 | + if (!allowedTo($action[2])) { |
|
1494 | + unset($subActions[$sa]); |
|
1495 | + } |
|
1450 | 1496 | } |
1451 | 1497 | |
1452 | 1498 | // Create the tabs for the template. |
@@ -1464,15 +1510,18 @@ discard block |
||
1464 | 1510 | ); |
1465 | 1511 | |
1466 | 1512 | // Moderation must be on to track edits. |
1467 | - if (empty($modSettings['userlog_enabled'])) |
|
1468 | - unset($context[$context['profile_menu_name']]['tab_data']['edits'], $subActions['edits']); |
|
1513 | + if (empty($modSettings['userlog_enabled'])) { |
|
1514 | + unset($context[$context['profile_menu_name']]['tab_data']['edits'], $subActions['edits']); |
|
1515 | + } |
|
1469 | 1516 | |
1470 | 1517 | // Group requests must be active to show it... |
1471 | - if (empty($modSettings['show_group_membership'])) |
|
1472 | - unset($context[$context['profile_menu_name']]['tab_data']['groupreq'], $subActions['groupreq']); |
|
1518 | + if (empty($modSettings['show_group_membership'])) { |
|
1519 | + unset($context[$context['profile_menu_name']]['tab_data']['groupreq'], $subActions['groupreq']); |
|
1520 | + } |
|
1473 | 1521 | |
1474 | - if (empty($subActions)) |
|
1475 | - fatal_lang_error('no_access', false); |
|
1522 | + if (empty($subActions)) { |
|
1523 | + fatal_lang_error('no_access', false); |
|
1524 | + } |
|
1476 | 1525 | |
1477 | 1526 | $keys = array_keys($subActions); |
1478 | 1527 | $default = array_shift($keys); |
@@ -1485,9 +1534,10 @@ discard block |
||
1485 | 1534 | $context['sub_template'] = $subActions[$context['tracking_area']][0]; |
1486 | 1535 | $call = call_helper($subActions[$context['tracking_area']][0], true); |
1487 | 1536 | |
1488 | - if (!empty($call)) |
|
1489 | - call_user_func($call, $memID); |
|
1490 | -} |
|
1537 | + if (!empty($call)) { |
|
1538 | + call_user_func($call, $memID); |
|
1539 | + } |
|
1540 | + } |
|
1491 | 1541 | |
1492 | 1542 | /** |
1493 | 1543 | * Handles tracking a user's activity |
@@ -1503,8 +1553,9 @@ discard block |
||
1503 | 1553 | isAllowedTo('moderate_forum'); |
1504 | 1554 | |
1505 | 1555 | $context['last_ip'] = $user_profile[$memID]['member_ip']; |
1506 | - if ($context['last_ip'] != $user_profile[$memID]['member_ip2']) |
|
1507 | - $context['last_ip2'] = $user_profile[$memID]['member_ip2']; |
|
1556 | + if ($context['last_ip'] != $user_profile[$memID]['member_ip2']) { |
|
1557 | + $context['last_ip2'] = $user_profile[$memID]['member_ip2']; |
|
1558 | + } |
|
1508 | 1559 | $context['member']['name'] = $user_profile[$memID]['real_name']; |
1509 | 1560 | |
1510 | 1561 | // Set the options for the list component. |
@@ -1670,8 +1721,9 @@ discard block |
||
1670 | 1721 | ) |
1671 | 1722 | ); |
1672 | 1723 | $message_members = array(); |
1673 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1674 | - $message_members[] = $row['id_member']; |
|
1724 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1725 | + $message_members[] = $row['id_member']; |
|
1726 | + } |
|
1675 | 1727 | $smcFunc['db_free_result']($request); |
1676 | 1728 | |
1677 | 1729 | // Fetch their names, cause of the GROUP BY doesn't like giving us that normally. |
@@ -1686,8 +1738,9 @@ discard block |
||
1686 | 1738 | 'ip_list' => $ips, |
1687 | 1739 | ) |
1688 | 1740 | ); |
1689 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1690 | - $context['members_in_range'][$row['id_member']] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
1741 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1742 | + $context['members_in_range'][$row['id_member']] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
1743 | + } |
|
1691 | 1744 | $smcFunc['db_free_result']($request); |
1692 | 1745 | } |
1693 | 1746 | |
@@ -1701,8 +1754,9 @@ discard block |
||
1701 | 1754 | 'ip_list' => $ips, |
1702 | 1755 | ) |
1703 | 1756 | ); |
1704 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1705 | - $context['members_in_range'][$row['id_member']] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
1757 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1758 | + $context['members_in_range'][$row['id_member']] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
1759 | + } |
|
1706 | 1760 | $smcFunc['db_free_result']($request); |
1707 | 1761 | } |
1708 | 1762 | } |
@@ -1762,8 +1816,8 @@ discard block |
||
1762 | 1816 | )) |
1763 | 1817 | ); |
1764 | 1818 | $error_messages = array(); |
1765 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1766 | - $error_messages[] = array( |
|
1819 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1820 | + $error_messages[] = array( |
|
1767 | 1821 | 'ip' => inet_dtop($row['ip']), |
1768 | 1822 | 'member_link' => $row['id_member'] > 0 ? '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['display_name'] . '</a>' : $row['display_name'], |
1769 | 1823 | 'message' => strtr($row['message'], array('<span class="remove">' => '', '</span>' => '')), |
@@ -1771,6 +1825,7 @@ discard block |
||
1771 | 1825 | 'time' => timeformat($row['log_time']), |
1772 | 1826 | 'timestamp' => forum_time(true, $row['log_time']), |
1773 | 1827 | ); |
1828 | + } |
|
1774 | 1829 | $smcFunc['db_free_result']($request); |
1775 | 1830 | |
1776 | 1831 | return $error_messages; |
@@ -1833,8 +1888,8 @@ discard block |
||
1833 | 1888 | )) |
1834 | 1889 | ); |
1835 | 1890 | $messages = array(); |
1836 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1837 | - $messages[] = array( |
|
1891 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1892 | + $messages[] = array( |
|
1838 | 1893 | 'ip' => inet_dtop($row['poster_ip']), |
1839 | 1894 | 'member_link' => empty($row['id_member']) ? $row['display_name'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['display_name'] . '</a>', |
1840 | 1895 | 'board' => array( |
@@ -1847,6 +1902,7 @@ discard block |
||
1847 | 1902 | 'time' => timeformat($row['poster_time']), |
1848 | 1903 | 'timestamp' => forum_time(true, $row['poster_time']) |
1849 | 1904 | ); |
1905 | + } |
|
1850 | 1906 | $smcFunc['db_free_result']($request); |
1851 | 1907 | |
1852 | 1908 | return $messages; |
@@ -1873,19 +1929,20 @@ discard block |
||
1873 | 1929 | $context['sub_template'] = 'trackIP'; |
1874 | 1930 | $context['page_title'] = $txt['profile']; |
1875 | 1931 | $context['base_url'] = $scripturl . '?action=trackip'; |
1876 | - } |
|
1877 | - else |
|
1932 | + } else |
|
1878 | 1933 | { |
1879 | 1934 | $context['ip'] = $user_profile[$memID]['member_ip']; |
1880 | 1935 | $context['base_url'] = $scripturl . '?action=profile;area=tracking;sa=ip;u=' . $memID; |
1881 | 1936 | } |
1882 | 1937 | |
1883 | 1938 | // Searching? |
1884 | - if (isset($_REQUEST['searchip'])) |
|
1885 | - $context['ip'] = trim($_REQUEST['searchip']); |
|
1939 | + if (isset($_REQUEST['searchip'])) { |
|
1940 | + $context['ip'] = trim($_REQUEST['searchip']); |
|
1941 | + } |
|
1886 | 1942 | |
1887 | - if (isValidIP($context['ip']) === false) |
|
1888 | - fatal_lang_error('invalid_tracking_ip', false); |
|
1943 | + if (isValidIP($context['ip']) === false) { |
|
1944 | + fatal_lang_error('invalid_tracking_ip', false); |
|
1945 | + } |
|
1889 | 1946 | |
1890 | 1947 | //mysql didn't support like search with varbinary |
1891 | 1948 | //$ip_var = str_replace('*', '%', $context['ip']); |
@@ -1893,8 +1950,9 @@ discard block |
||
1893 | 1950 | $ip_var = $context['ip']; |
1894 | 1951 | $ip_string = '= {inet:ip_address}'; |
1895 | 1952 | |
1896 | - if (empty($context['tracking_area'])) |
|
1897 | - $context['page_title'] = $txt['trackIP'] . ' - ' . $context['ip']; |
|
1953 | + if (empty($context['tracking_area'])) { |
|
1954 | + $context['page_title'] = $txt['trackIP'] . ' - ' . $context['ip']; |
|
1955 | + } |
|
1898 | 1956 | |
1899 | 1957 | $request = $smcFunc['db_query']('', ' |
1900 | 1958 | SELECT id_member, real_name AS display_name, member_ip |
@@ -1905,8 +1963,9 @@ discard block |
||
1905 | 1963 | ) |
1906 | 1964 | ); |
1907 | 1965 | $context['ips'] = array(); |
1908 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1909 | - $context['ips'][inet_dtop($row['member_ip'])][] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['display_name'] . '</a>'; |
|
1966 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1967 | + $context['ips'][inet_dtop($row['member_ip'])][] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['display_name'] . '</a>'; |
|
1968 | + } |
|
1910 | 1969 | $smcFunc['db_free_result']($request); |
1911 | 1970 | |
1912 | 1971 | ksort($context['ips']); |
@@ -2135,8 +2194,9 @@ discard block |
||
2135 | 2194 | foreach ($context['whois_servers'] as $whois) |
2136 | 2195 | { |
2137 | 2196 | // Strip off the "decimal point" and anything following... |
2138 | - if (in_array((int) $context['ip'], $whois['range'])) |
|
2139 | - $context['auto_whois_server'] = $whois; |
|
2197 | + if (in_array((int) $context['ip'], $whois['range'])) { |
|
2198 | + $context['auto_whois_server'] = $whois; |
|
2199 | + } |
|
2140 | 2200 | } |
2141 | 2201 | } |
2142 | 2202 | } |
@@ -2153,10 +2213,11 @@ discard block |
||
2153 | 2213 | // Gonna want this for the list. |
2154 | 2214 | require_once($sourcedir . '/Subs-List.php'); |
2155 | 2215 | |
2156 | - if ($memID == 0) |
|
2157 | - $context['base_url'] = $scripturl . '?action=trackip'; |
|
2158 | - else |
|
2159 | - $context['base_url'] = $scripturl . '?action=profile;area=tracking;sa=ip;u=' . $memID; |
|
2216 | + if ($memID == 0) { |
|
2217 | + $context['base_url'] = $scripturl . '?action=trackip'; |
|
2218 | + } else { |
|
2219 | + $context['base_url'] = $scripturl . '?action=profile;area=tracking;sa=ip;u=' . $memID; |
|
2220 | + } |
|
2160 | 2221 | |
2161 | 2222 | // Start with the user messages. |
2162 | 2223 | $listOptions = array( |
@@ -2266,12 +2327,13 @@ discard block |
||
2266 | 2327 | ) |
2267 | 2328 | ); |
2268 | 2329 | $logins = array(); |
2269 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
2270 | - $logins[] = array( |
|
2330 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2331 | + $logins[] = array( |
|
2271 | 2332 | 'time' => timeformat($row['time']), |
2272 | 2333 | 'ip' => inet_dtop($row['ip']), |
2273 | 2334 | 'ip2' => inet_dtop($row['ip2']), |
2274 | 2335 | ); |
2336 | + } |
|
2275 | 2337 | $smcFunc['db_free_result']($request); |
2276 | 2338 | |
2277 | 2339 | return $logins; |
@@ -2296,11 +2358,12 @@ discard block |
||
2296 | 2358 | ) |
2297 | 2359 | ); |
2298 | 2360 | $context['custom_field_titles'] = array(); |
2299 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
2300 | - $context['custom_field_titles']['customfield_' . $row['col_name']] = array( |
|
2361 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2362 | + $context['custom_field_titles']['customfield_' . $row['col_name']] = array( |
|
2301 | 2363 | 'title' => $row['field_name'], |
2302 | 2364 | 'parse_bbc' => $row['bbc'], |
2303 | 2365 | ); |
2366 | + } |
|
2304 | 2367 | $smcFunc['db_free_result']($request); |
2305 | 2368 | |
2306 | 2369 | // Set the options for the error lists. |
@@ -2439,19 +2502,22 @@ discard block |
||
2439 | 2502 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
2440 | 2503 | { |
2441 | 2504 | $extra = smf_json_decode($row['extra'], true); |
2442 | - if (!empty($extra['applicator'])) |
|
2443 | - $members[] = $extra['applicator']; |
|
2505 | + if (!empty($extra['applicator'])) { |
|
2506 | + $members[] = $extra['applicator']; |
|
2507 | + } |
|
2444 | 2508 | |
2445 | 2509 | // Work out what the name of the action is. |
2446 | - if (isset($txt['trackEdit_action_' . $row['action']])) |
|
2447 | - $action_text = $txt['trackEdit_action_' . $row['action']]; |
|
2448 | - elseif (isset($txt[$row['action']])) |
|
2449 | - $action_text = $txt[$row['action']]; |
|
2510 | + if (isset($txt['trackEdit_action_' . $row['action']])) { |
|
2511 | + $action_text = $txt['trackEdit_action_' . $row['action']]; |
|
2512 | + } elseif (isset($txt[$row['action']])) { |
|
2513 | + $action_text = $txt[$row['action']]; |
|
2514 | + } |
|
2450 | 2515 | // Custom field? |
2451 | - elseif (isset($context['custom_field_titles'][$row['action']])) |
|
2452 | - $action_text = $context['custom_field_titles'][$row['action']]['title']; |
|
2453 | - else |
|
2454 | - $action_text = $row['action']; |
|
2516 | + elseif (isset($context['custom_field_titles'][$row['action']])) { |
|
2517 | + $action_text = $context['custom_field_titles'][$row['action']]['title']; |
|
2518 | + } else { |
|
2519 | + $action_text = $row['action']; |
|
2520 | + } |
|
2455 | 2521 | |
2456 | 2522 | // Parse BBC? |
2457 | 2523 | $parse_bbc = isset($context['custom_field_titles'][$row['action']]) && $context['custom_field_titles'][$row['action']]['parse_bbc'] ? true : false; |
@@ -2483,13 +2549,15 @@ discard block |
||
2483 | 2549 | ) |
2484 | 2550 | ); |
2485 | 2551 | $members = array(); |
2486 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
2487 | - $members[$row['id_member']] = $row['real_name']; |
|
2552 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2553 | + $members[$row['id_member']] = $row['real_name']; |
|
2554 | + } |
|
2488 | 2555 | $smcFunc['db_free_result']($request); |
2489 | 2556 | |
2490 | - foreach ($edits as $key => $value) |
|
2491 | - if (isset($members[$value['id_member']])) |
|
2557 | + foreach ($edits as $key => $value) { |
|
2558 | + if (isset($members[$value['id_member']])) |
|
2492 | 2559 | $edits[$key]['member_link'] = '<a href="' . $scripturl . '?action=profile;u=' . $value['id_member'] . '">' . $members[$value['id_member']] . '</a>'; |
2560 | + } |
|
2493 | 2561 | } |
2494 | 2562 | |
2495 | 2563 | return $edits; |
@@ -2690,10 +2758,11 @@ discard block |
||
2690 | 2758 | $context['board'] = $board; |
2691 | 2759 | |
2692 | 2760 | // Determine which groups this user is in. |
2693 | - if (empty($user_profile[$memID]['additional_groups'])) |
|
2694 | - $curGroups = array(); |
|
2695 | - else |
|
2696 | - $curGroups = explode(',', $user_profile[$memID]['additional_groups']); |
|
2761 | + if (empty($user_profile[$memID]['additional_groups'])) { |
|
2762 | + $curGroups = array(); |
|
2763 | + } else { |
|
2764 | + $curGroups = explode(',', $user_profile[$memID]['additional_groups']); |
|
2765 | + } |
|
2697 | 2766 | $curGroups[] = $user_profile[$memID]['id_group']; |
2698 | 2767 | $curGroups[] = $user_profile[$memID]['id_post_group']; |
2699 | 2768 | |
@@ -2713,28 +2782,30 @@ discard block |
||
2713 | 2782 | $context['no_access_boards'] = array(); |
2714 | 2783 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
2715 | 2784 | { |
2716 | - if (count(array_intersect($curGroups, explode(',', $row['member_groups']))) === 0 && !$row['is_mod']) |
|
2717 | - $context['no_access_boards'][] = array( |
|
2785 | + if (count(array_intersect($curGroups, explode(',', $row['member_groups']))) === 0 && !$row['is_mod']) { |
|
2786 | + $context['no_access_boards'][] = array( |
|
2718 | 2787 | 'id' => $row['id_board'], |
2719 | 2788 | 'name' => $row['name'], |
2720 | 2789 | 'is_last' => false, |
2721 | 2790 | ); |
2722 | - elseif ($row['id_profile'] != 1 || $row['is_mod']) |
|
2723 | - $context['boards'][$row['id_board']] = array( |
|
2791 | + } elseif ($row['id_profile'] != 1 || $row['is_mod']) { |
|
2792 | + $context['boards'][$row['id_board']] = array( |
|
2724 | 2793 | 'id' => $row['id_board'], |
2725 | 2794 | 'name' => $row['name'], |
2726 | 2795 | 'selected' => $board == $row['id_board'], |
2727 | 2796 | 'profile' => $row['id_profile'], |
2728 | 2797 | 'profile_name' => $context['profiles'][$row['id_profile']]['name'], |
2729 | 2798 | ); |
2799 | + } |
|
2730 | 2800 | } |
2731 | 2801 | $smcFunc['db_free_result']($request); |
2732 | 2802 | |
2733 | 2803 | require_once($sourcedir . '/Subs-Boards.php'); |
2734 | 2804 | sortBoards($context['boards']); |
2735 | 2805 | |
2736 | - if (!empty($context['no_access_boards'])) |
|
2737 | - $context['no_access_boards'][count($context['no_access_boards']) - 1]['is_last'] = true; |
|
2806 | + if (!empty($context['no_access_boards'])) { |
|
2807 | + $context['no_access_boards'][count($context['no_access_boards']) - 1]['is_last'] = true; |
|
2808 | + } |
|
2738 | 2809 | |
2739 | 2810 | $context['member']['permissions'] = array( |
2740 | 2811 | 'general' => array(), |
@@ -2743,8 +2814,9 @@ discard block |
||
2743 | 2814 | |
2744 | 2815 | // If you're an admin we know you can do everything, we might as well leave. |
2745 | 2816 | $context['member']['has_all_permissions'] = in_array(1, $curGroups); |
2746 | - if ($context['member']['has_all_permissions']) |
|
2747 | - return; |
|
2817 | + if ($context['member']['has_all_permissions']) { |
|
2818 | + return; |
|
2819 | + } |
|
2748 | 2820 | |
2749 | 2821 | $denied = array(); |
2750 | 2822 | |
@@ -2763,21 +2835,24 @@ discard block |
||
2763 | 2835 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
2764 | 2836 | { |
2765 | 2837 | // We don't know about this permission, it doesn't exist :P. |
2766 | - if (!isset($txt['permissionname_' . $row['permission']])) |
|
2767 | - continue; |
|
2838 | + if (!isset($txt['permissionname_' . $row['permission']])) { |
|
2839 | + continue; |
|
2840 | + } |
|
2768 | 2841 | |
2769 | - if (empty($row['add_deny'])) |
|
2770 | - $denied[] = $row['permission']; |
|
2842 | + if (empty($row['add_deny'])) { |
|
2843 | + $denied[] = $row['permission']; |
|
2844 | + } |
|
2771 | 2845 | |
2772 | 2846 | // Permissions that end with _own or _any consist of two parts. |
2773 | - if (in_array(substr($row['permission'], -4), array('_own', '_any')) && isset($txt['permissionname_' . substr($row['permission'], 0, -4)])) |
|
2774 | - $name = $txt['permissionname_' . substr($row['permission'], 0, -4)] . ' - ' . $txt['permissionname_' . $row['permission']]; |
|
2775 | - else |
|
2776 | - $name = $txt['permissionname_' . $row['permission']]; |
|
2847 | + if (in_array(substr($row['permission'], -4), array('_own', '_any')) && isset($txt['permissionname_' . substr($row['permission'], 0, -4)])) { |
|
2848 | + $name = $txt['permissionname_' . substr($row['permission'], 0, -4)] . ' - ' . $txt['permissionname_' . $row['permission']]; |
|
2849 | + } else { |
|
2850 | + $name = $txt['permissionname_' . $row['permission']]; |
|
2851 | + } |
|
2777 | 2852 | |
2778 | 2853 | // Add this permission if it doesn't exist yet. |
2779 | - if (!isset($context['member']['permissions']['general'][$row['permission']])) |
|
2780 | - $context['member']['permissions']['general'][$row['permission']] = array( |
|
2854 | + if (!isset($context['member']['permissions']['general'][$row['permission']])) { |
|
2855 | + $context['member']['permissions']['general'][$row['permission']] = array( |
|
2781 | 2856 | 'id' => $row['permission'], |
2782 | 2857 | 'groups' => array( |
2783 | 2858 | 'allowed' => array(), |
@@ -2787,6 +2862,7 @@ discard block |
||
2787 | 2862 | 'is_denied' => false, |
2788 | 2863 | 'is_global' => true, |
2789 | 2864 | ); |
2865 | + } |
|
2790 | 2866 | |
2791 | 2867 | // Add the membergroup to either the denied or the allowed groups. |
2792 | 2868 | $context['member']['permissions']['general'][$row['permission']]['groups'][empty($row['add_deny']) ? 'denied' : 'allowed'][] = $row['id_group'] == 0 ? $txt['membergroups_members'] : $row['group_name']; |
@@ -2820,18 +2896,20 @@ discard block |
||
2820 | 2896 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
2821 | 2897 | { |
2822 | 2898 | // We don't know about this permission, it doesn't exist :P. |
2823 | - if (!isset($txt['permissionname_' . $row['permission']])) |
|
2824 | - continue; |
|
2899 | + if (!isset($txt['permissionname_' . $row['permission']])) { |
|
2900 | + continue; |
|
2901 | + } |
|
2825 | 2902 | |
2826 | 2903 | // The name of the permission using the format 'permission name' - 'own/any topic/event/etc.'. |
2827 | - if (in_array(substr($row['permission'], -4), array('_own', '_any')) && isset($txt['permissionname_' . substr($row['permission'], 0, -4)])) |
|
2828 | - $name = $txt['permissionname_' . substr($row['permission'], 0, -4)] . ' - ' . $txt['permissionname_' . $row['permission']]; |
|
2829 | - else |
|
2830 | - $name = $txt['permissionname_' . $row['permission']]; |
|
2904 | + if (in_array(substr($row['permission'], -4), array('_own', '_any')) && isset($txt['permissionname_' . substr($row['permission'], 0, -4)])) { |
|
2905 | + $name = $txt['permissionname_' . substr($row['permission'], 0, -4)] . ' - ' . $txt['permissionname_' . $row['permission']]; |
|
2906 | + } else { |
|
2907 | + $name = $txt['permissionname_' . $row['permission']]; |
|
2908 | + } |
|
2831 | 2909 | |
2832 | 2910 | // Create the structure for this permission. |
2833 | - if (!isset($context['member']['permissions']['board'][$row['permission']])) |
|
2834 | - $context['member']['permissions']['board'][$row['permission']] = array( |
|
2911 | + if (!isset($context['member']['permissions']['board'][$row['permission']])) { |
|
2912 | + $context['member']['permissions']['board'][$row['permission']] = array( |
|
2835 | 2913 | 'id' => $row['permission'], |
2836 | 2914 | 'groups' => array( |
2837 | 2915 | 'allowed' => array(), |
@@ -2841,6 +2919,7 @@ discard block |
||
2841 | 2919 | 'is_denied' => false, |
2842 | 2920 | 'is_global' => empty($board), |
2843 | 2921 | ); |
2922 | + } |
|
2844 | 2923 | |
2845 | 2924 | $context['member']['permissions']['board'][$row['permission']]['groups'][empty($row['add_deny']) ? 'denied' : 'allowed'][$row['id_group']] = $row['id_group'] == 0 ? $txt['membergroups_members'] : $row['group_name']; |
2846 | 2925 | |
@@ -2859,8 +2938,9 @@ discard block |
||
2859 | 2938 | global $modSettings, $context, $sourcedir, $txt, $scripturl; |
2860 | 2939 | |
2861 | 2940 | // Firstly, can we actually even be here? |
2862 | - if (!($context['user']['is_owner'] && allowedTo('view_warning_own')) && !allowedTo('view_warning_any') && !allowedTo('issue_warning') && !allowedTo('moderate_forum')) |
|
2863 | - fatal_lang_error('no_access', false); |
|
2941 | + if (!($context['user']['is_owner'] && allowedTo('view_warning_own')) && !allowedTo('view_warning_any') && !allowedTo('issue_warning') && !allowedTo('moderate_forum')) { |
|
2942 | + fatal_lang_error('no_access', false); |
|
2943 | + } |
|
2864 | 2944 | |
2865 | 2945 | // Make sure things which are disabled stay disabled. |
2866 | 2946 | $modSettings['warning_watch'] = !empty($modSettings['warning_watch']) ? $modSettings['warning_watch'] : 110; |
@@ -2947,9 +3027,10 @@ discard block |
||
2947 | 3027 | $modSettings['warning_mute'] => $txt['profile_warning_effect_own_muted'], |
2948 | 3028 | ); |
2949 | 3029 | $context['current_level'] = 0; |
2950 | - foreach ($context['level_effects'] as $limit => $dummy) |
|
2951 | - if ($context['member']['warning'] >= $limit) |
|
3030 | + foreach ($context['level_effects'] as $limit => $dummy) { |
|
3031 | + if ($context['member']['warning'] >= $limit) |
|
2952 | 3032 | $context['current_level'] = $limit; |
2953 | -} |
|
3033 | + } |
|
3034 | + } |
|
2954 | 3035 | |
2955 | 3036 | ?> |
2956 | 3037 | \ No newline at end of file |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 3 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * 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 |
@@ -261,15 +272,17 @@ discard block |
||
261 | 272 | $context['preview_subject'] = !empty($_POST['title']) ? trim($smcFunc['htmlspecialchars']($_POST['title'])) : ''; |
262 | 273 | if (isset($_POST['issuing'])) |
263 | 274 | { |
264 | - if (empty($_POST['title']) || empty($_POST['body'])) |
|
265 | - $context['post_error']['messages'][] = $txt['warning_notify_blank']; |
|
266 | - } |
|
267 | - else |
|
275 | + if (empty($_POST['title']) || empty($_POST['body'])) { |
|
276 | + $context['post_error']['messages'][] = $txt['warning_notify_blank']; |
|
277 | + } |
|
278 | + } else |
|
268 | 279 | { |
269 | - if (empty($_POST['title'])) |
|
270 | - $context['post_error']['messages'][] = $txt['mc_warning_template_error_no_title']; |
|
271 | - if (empty($_POST['body'])) |
|
272 | - $context['post_error']['messages'][] = $txt['mc_warning_template_error_no_body']; |
|
280 | + if (empty($_POST['title'])) { |
|
281 | + $context['post_error']['messages'][] = $txt['mc_warning_template_error_no_title']; |
|
282 | + } |
|
283 | + if (empty($_POST['body'])) { |
|
284 | + $context['post_error']['messages'][] = $txt['mc_warning_template_error_no_body']; |
|
285 | + } |
|
273 | 286 | // Add in few replacements. |
274 | 287 | /** |
275 | 288 | * These are the defaults: |
@@ -300,9 +313,9 @@ discard block |
||
300 | 313 | $warning_body = parse_bbc($warning_body, true); |
301 | 314 | } |
302 | 315 | $context['preview_message'] = $warning_body; |
316 | + } else { |
|
317 | + $context['post_error']['messages'][] = array('value' => $txt['cannot_issue_warning'], 'attributes' => array('type' => 'error')); |
|
303 | 318 | } |
304 | - else |
|
305 | - $context['post_error']['messages'][] = array('value' => $txt['cannot_issue_warning'], 'attributes' => array('type' => 'error')); |
|
306 | 319 | |
307 | 320 | $context['sub_template'] = 'warning'; |
308 | 321 | } |