@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 4 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * Scheduled tasks management dispatcher. This function checks permissions and delegates |
@@ -41,10 +42,11 @@ discard block |
||
41 | 42 | ); |
42 | 43 | |
43 | 44 | // We need to find what's the action. |
44 | - if (isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']])) |
|
45 | - $context['sub_action'] = $_REQUEST['sa']; |
|
46 | - else |
|
47 | - $context['sub_action'] = 'tasks'; |
|
45 | + if (isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']])) { |
|
46 | + $context['sub_action'] = $_REQUEST['sa']; |
|
47 | + } else { |
|
48 | + $context['sub_action'] = 'tasks'; |
|
49 | + } |
|
48 | 50 | |
49 | 51 | // Now for the lovely tabs. That we all love. |
50 | 52 | $context[$context['admin_menu_name']]['tab_data'] = array( |
@@ -94,9 +96,10 @@ discard block |
||
94 | 96 | |
95 | 97 | // Enable and disable as required. |
96 | 98 | $enablers = array(0); |
97 | - foreach ($_POST['enable_task'] as $id => $enabled) |
|
98 | - if ($enabled) |
|
99 | + foreach ($_POST['enable_task'] as $id => $enabled) { |
|
100 | + if ($enabled) |
|
99 | 101 | $enablers[] = (int) $id; |
102 | + } |
|
100 | 103 | |
101 | 104 | // Do the update! |
102 | 105 | $smcFunc['db_query']('', ' |
@@ -134,8 +137,9 @@ discard block |
||
134 | 137 | |
135 | 138 | // Lets figure out which ones they want to run. |
136 | 139 | $tasks = array(); |
137 | - foreach ($_POST['run_task'] as $task => $dummy) |
|
138 | - $tasks[] = (int) $task; |
|
140 | + foreach ($_POST['run_task'] as $task => $dummy) { |
|
141 | + $tasks[] = (int) $task; |
|
142 | + } |
|
139 | 143 | |
140 | 144 | // Load up the tasks. |
141 | 145 | $request = $smcFunc['db_query']('', ' |
@@ -155,36 +159,41 @@ discard block |
||
155 | 159 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
156 | 160 | { |
157 | 161 | // What kind of task are we handling? |
158 | - if (!empty($row['callable'])) |
|
159 | - $task_string = $row['callable']; |
|
162 | + if (!empty($row['callable'])) { |
|
163 | + $task_string = $row['callable']; |
|
164 | + } |
|
160 | 165 | |
161 | 166 | // Default SMF task or old mods? |
162 | - elseif (function_exists('scheduled_' . $row['task'])) |
|
163 | - $task_string = 'scheduled_' . $row['task']; |
|
167 | + elseif (function_exists('scheduled_' . $row['task'])) { |
|
168 | + $task_string = 'scheduled_' . $row['task']; |
|
169 | + } |
|
164 | 170 | |
165 | 171 | // One last resource, the task name. |
166 | - elseif (!empty($row['task'])) |
|
167 | - $task_string = $row['task']; |
|
172 | + elseif (!empty($row['task'])) { |
|
173 | + $task_string = $row['task']; |
|
174 | + } |
|
168 | 175 | |
169 | 176 | $start_time = microtime(); |
170 | 177 | // The functions got to exist for us to use it. |
171 | - if (empty($task_string)) |
|
172 | - continue; |
|
178 | + if (empty($task_string)) { |
|
179 | + continue; |
|
180 | + } |
|
173 | 181 | |
174 | 182 | // Try to stop a timeout, this would be bad... |
175 | 183 | @set_time_limit(300); |
176 | - if (function_exists('apache_reset_timeout')) |
|
177 | - @apache_reset_timeout(); |
|
184 | + if (function_exists('apache_reset_timeout')) { |
|
185 | + @apache_reset_timeout(); |
|
186 | + } |
|
178 | 187 | |
179 | 188 | // Get the callable. |
180 | 189 | $callable_task = call_helper($task_string, true); |
181 | 190 | |
182 | 191 | // Perform the task. |
183 | - if (!empty($callable_task)) |
|
184 | - $completed = call_user_func($callable_task); |
|
185 | - |
|
186 | - else |
|
187 | - $completed = false; |
|
192 | + if (!empty($callable_task)) { |
|
193 | + $completed = call_user_func($callable_task); |
|
194 | + } else { |
|
195 | + $completed = false; |
|
196 | + } |
|
188 | 197 | |
189 | 198 | // Log that we did it ;) |
190 | 199 | if ($completed) |
@@ -201,8 +210,9 @@ discard block |
||
201 | 210 | $smcFunc['db_free_result']($request); |
202 | 211 | |
203 | 212 | // If we had any errors, push them to session so we can pick them up next time to tell the user. |
204 | - if (!empty($context['scheduled_errors'])) |
|
205 | - $_SESSION['st_error'] = $context['scheduled_errors']; |
|
213 | + if (!empty($context['scheduled_errors'])) { |
|
214 | + $_SESSION['st_error'] = $context['scheduled_errors']; |
|
215 | + } |
|
206 | 216 | |
207 | 217 | redirectexit('action=admin;area=scheduledtasks;done'); |
208 | 218 | } |
@@ -374,8 +384,9 @@ discard block |
||
374 | 384 | $context['server_time'] = timeformat(time(), false, 'server'); |
375 | 385 | |
376 | 386 | // Cleaning... |
377 | - if (!isset($_GET['tid'])) |
|
378 | - fatal_lang_error('no_access', false); |
|
387 | + if (!isset($_GET['tid'])) { |
|
388 | + fatal_lang_error('no_access', false); |
|
389 | + } |
|
379 | 390 | $_GET['tid'] = (int) $_GET['tid']; |
380 | 391 | |
381 | 392 | // Saving? |
@@ -391,10 +402,12 @@ discard block |
||
391 | 402 | preg_match('~(\d{1,2}):(\d{1,2})~', $_POST['offset'], $matches); |
392 | 403 | |
393 | 404 | // If a half is empty then assume zero offset! |
394 | - if (!isset($matches[2]) || $matches[2] > 59) |
|
395 | - $matches[2] = 0; |
|
396 | - if (!isset($matches[1]) || $matches[1] > 23) |
|
397 | - $matches[1] = 0; |
|
405 | + if (!isset($matches[2]) || $matches[2] > 59) { |
|
406 | + $matches[2] = 0; |
|
407 | + } |
|
408 | + if (!isset($matches[1]) || $matches[1] > 23) { |
|
409 | + $matches[1] = 0; |
|
410 | + } |
|
398 | 411 | |
399 | 412 | // Now the offset is easy; easy peasy - except we need to offset by a few hours... |
400 | 413 | $offset = $matches[1] * 3600 + $matches[2] * 60 - date('Z'); |
@@ -404,8 +417,9 @@ discard block |
||
404 | 417 | $unit = in_array(substr($_POST['unit'], 0, 1), array('m', 'h', 'd', 'w')) ? substr($_POST['unit'], 0, 1) : 'd'; |
405 | 418 | |
406 | 419 | // Don't allow one minute intervals. |
407 | - if ($interval == 1 && $unit == 'm') |
|
408 | - $interval = 2; |
|
420 | + if ($interval == 1 && $unit == 'm') { |
|
421 | + $interval = 2; |
|
422 | + } |
|
409 | 423 | |
410 | 424 | // Is it disabled? |
411 | 425 | $disabled = !isset($_POST['enabled']) ? 1 : 0; |
@@ -443,8 +457,9 @@ discard block |
||
443 | 457 | ); |
444 | 458 | |
445 | 459 | // Should never, ever, happen! |
446 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
447 | - fatal_lang_error('no_access', false); |
|
460 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
461 | + fatal_lang_error('no_access', false); |
|
462 | + } |
|
448 | 463 | |
449 | 464 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
450 | 465 | { |
@@ -602,13 +617,14 @@ discard block |
||
602 | 617 | ) |
603 | 618 | ); |
604 | 619 | $log_entries = array(); |
605 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
606 | - $log_entries[] = array( |
|
620 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
621 | + $log_entries[] = array( |
|
607 | 622 | 'id' => $row['id_log'], |
608 | 623 | 'name' => isset($txt['scheduled_task_' . $row['task']]) ? $txt['scheduled_task_' . $row['task']] : $row['task'], |
609 | 624 | 'time_run' => $row['time_run'], |
610 | 625 | 'time_taken' => $row['time_taken'], |
611 | 626 | ); |
627 | + } |
|
612 | 628 | $smcFunc['db_free_result']($request); |
613 | 629 | |
614 | 630 | return $log_entries; |
@@ -649,8 +665,9 @@ discard block |
||
649 | 665 | |
650 | 666 | call_integration_hook('integrate_scheduled_tasks_settings', array(&$config_vars)); |
651 | 667 | |
652 | - if ($return_config) |
|
653 | - return $config_vars; |
|
668 | + if ($return_config) { |
|
669 | + return $config_vars; |
|
670 | + } |
|
654 | 671 | |
655 | 672 | // Set up the template. |
656 | 673 | $context['page_title'] = $txt['scheduled_tasks_settings']; |
@@ -15,8 +15,9 @@ discard block |
||
15 | 15 | * @version 2.1 Beta 4 |
16 | 16 | */ |
17 | 17 | |
18 | -if (!defined('SMF')) |
|
18 | +if (!defined('SMF')) { |
|
19 | 19 | die('No direct access...'); |
20 | +} |
|
20 | 21 | |
21 | 22 | /** |
22 | 23 | * Begin the registration process. |
@@ -29,19 +30,23 @@ discard block |
||
29 | 30 | global $language, $scripturl, $smcFunc, $sourcedir, $cur_profile; |
30 | 31 | |
31 | 32 | // Is this an incoming AJAX check? |
32 | - if (isset($_GET['sa']) && $_GET['sa'] == 'usernamecheck') |
|
33 | - return RegisterCheckUsername(); |
|
33 | + if (isset($_GET['sa']) && $_GET['sa'] == 'usernamecheck') { |
|
34 | + return RegisterCheckUsername(); |
|
35 | + } |
|
34 | 36 | |
35 | 37 | // Check if the administrator has it disabled. |
36 | - if (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == '3') |
|
37 | - fatal_lang_error('registration_disabled', false); |
|
38 | + if (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == '3') { |
|
39 | + fatal_lang_error('registration_disabled', false); |
|
40 | + } |
|
38 | 41 | |
39 | 42 | // If this user is an admin - redirect them to the admin registration page. |
40 | - if (allowedTo('moderate_forum') && !$user_info['is_guest']) |
|
41 | - redirectexit('action=admin;area=regcenter;sa=register'); |
|
43 | + if (allowedTo('moderate_forum') && !$user_info['is_guest']) { |
|
44 | + redirectexit('action=admin;area=regcenter;sa=register'); |
|
45 | + } |
|
42 | 46 | // You are not a guest, so you are a member - and members don't get to register twice! |
43 | - elseif (empty($user_info['is_guest'])) |
|
44 | - redirectexit(); |
|
47 | + elseif (empty($user_info['is_guest'])) { |
|
48 | + redirectexit(); |
|
49 | + } |
|
45 | 50 | |
46 | 51 | loadLanguage('Login'); |
47 | 52 | loadTemplate('Register'); |
@@ -82,16 +87,18 @@ discard block |
||
82 | 87 | } |
83 | 88 | } |
84 | 89 | // Make sure they don't squeeze through without agreeing. |
85 | - elseif ($current_step > 1 && $context['require_agreement'] && !$context['registration_passed_agreement']) |
|
86 | - $current_step = 1; |
|
90 | + elseif ($current_step > 1 && $context['require_agreement'] && !$context['registration_passed_agreement']) { |
|
91 | + $current_step = 1; |
|
92 | + } |
|
87 | 93 | |
88 | 94 | // Show the user the right form. |
89 | 95 | $context['sub_template'] = $current_step == 1 ? 'registration_agreement' : 'registration_form'; |
90 | 96 | $context['page_title'] = $current_step == 1 ? $txt['registration_agreement'] : $txt['registration_form']; |
91 | 97 | |
92 | 98 | // Kinda need this. |
93 | - if ($context['sub_template'] == 'registration_form') |
|
94 | - loadJavaScriptFile('register.js', array('defer' => false, 'minimize' => true), 'smf_register'); |
|
99 | + if ($context['sub_template'] == 'registration_form') { |
|
100 | + loadJavaScriptFile('register.js', array('defer' => false, 'minimize' => true), 'smf_register'); |
|
101 | + } |
|
95 | 102 | |
96 | 103 | // Add the register chain to the link tree. |
97 | 104 | $context['linktree'][] = array( |
@@ -100,24 +107,26 @@ discard block |
||
100 | 107 | ); |
101 | 108 | |
102 | 109 | // Prepare the time gate! Do it like so, in case later steps want to reset the limit for any reason, but make sure the time is the current one. |
103 | - if (!isset($_SESSION['register'])) |
|
104 | - $_SESSION['register'] = array( |
|
110 | + if (!isset($_SESSION['register'])) { |
|
111 | + $_SESSION['register'] = array( |
|
105 | 112 | 'timenow' => time(), |
106 | 113 | 'limit' => 10, // minimum number of seconds required on this page for registration |
107 | 114 | ); |
108 | - else |
|
109 | - $_SESSION['register']['timenow'] = time(); |
|
115 | + } else { |
|
116 | + $_SESSION['register']['timenow'] = time(); |
|
117 | + } |
|
110 | 118 | |
111 | 119 | // If you have to agree to the agreement, it needs to be fetched from the file. |
112 | 120 | if ($context['require_agreement']) |
113 | 121 | { |
114 | 122 | // Have we got a localized one? |
115 | - if (file_exists($boarddir . '/agreement.' . $user_info['language'] . '.txt')) |
|
116 | - $context['agreement'] = parse_bbc(file_get_contents($boarddir . '/agreement.' . $user_info['language'] . '.txt'), true, 'agreement_' . $user_info['language']); |
|
117 | - elseif (file_exists($boarddir . '/agreement.txt')) |
|
118 | - $context['agreement'] = parse_bbc(file_get_contents($boarddir . '/agreement.txt'), true, 'agreement'); |
|
119 | - else |
|
120 | - $context['agreement'] = ''; |
|
123 | + if (file_exists($boarddir . '/agreement.' . $user_info['language'] . '.txt')) { |
|
124 | + $context['agreement'] = parse_bbc(file_get_contents($boarddir . '/agreement.' . $user_info['language'] . '.txt'), true, 'agreement_' . $user_info['language']); |
|
125 | + } elseif (file_exists($boarddir . '/agreement.txt')) { |
|
126 | + $context['agreement'] = parse_bbc(file_get_contents($boarddir . '/agreement.txt'), true, 'agreement'); |
|
127 | + } else { |
|
128 | + $context['agreement'] = ''; |
|
129 | + } |
|
121 | 130 | |
122 | 131 | // Nothing to show, lets disable registration and inform the admin of this error |
123 | 132 | if (empty($context['agreement'])) |
@@ -133,8 +142,9 @@ discard block |
||
133 | 142 | $selectedLanguage = empty($_SESSION['language']) ? $language : $_SESSION['language']; |
134 | 143 | |
135 | 144 | // Do we have any languages? |
136 | - if (empty($context['languages'])) |
|
137 | - getLanguages(); |
|
145 | + if (empty($context['languages'])) { |
|
146 | + getLanguages(); |
|
147 | + } |
|
138 | 148 | |
139 | 149 | // Try to find our selected language. |
140 | 150 | foreach ($context['languages'] as $key => $lang) |
@@ -142,8 +152,9 @@ discard block |
||
142 | 152 | $context['languages'][$key]['name'] = strtr($lang['name'], array('-utf8' => '')); |
143 | 153 | |
144 | 154 | // Found it! |
145 | - if ($selectedLanguage == $lang['filename']) |
|
146 | - $context['languages'][$key]['selected'] = true; |
|
155 | + if ($selectedLanguage == $lang['filename']) { |
|
156 | + $context['languages'][$key]['selected'] = true; |
|
157 | + } |
|
147 | 158 | } |
148 | 159 | } |
149 | 160 | |
@@ -170,16 +181,19 @@ discard block |
||
170 | 181 | if (in_array('website', $reg_fields)) |
171 | 182 | { |
172 | 183 | unset($reg_fields['website']); |
173 | - if (isset($_POST['website_title'])) |
|
174 | - $cur_profile['website_title'] = $smcFunc['htmlspecialchars']($_POST['website_title']); |
|
175 | - if (isset($_POST['website_url'])) |
|
176 | - $cur_profile['website_url'] = $smcFunc['htmlspecialchars']($_POST['website_url']); |
|
184 | + if (isset($_POST['website_title'])) { |
|
185 | + $cur_profile['website_title'] = $smcFunc['htmlspecialchars']($_POST['website_title']); |
|
186 | + } |
|
187 | + if (isset($_POST['website_url'])) { |
|
188 | + $cur_profile['website_url'] = $smcFunc['htmlspecialchars']($_POST['website_url']); |
|
189 | + } |
|
177 | 190 | } |
178 | 191 | |
179 | 192 | // We might have had some submissions on this front - go check. |
180 | - foreach ($reg_fields as $field) |
|
181 | - if (isset($_POST[$field])) |
|
193 | + foreach ($reg_fields as $field) { |
|
194 | + if (isset($_POST[$field])) |
|
182 | 195 | $cur_profile[$field] = $smcFunc['htmlspecialchars']($_POST[$field]); |
196 | + } |
|
183 | 197 | |
184 | 198 | // Load all the fields in question. |
185 | 199 | setupProfileContext($reg_fields); |
@@ -196,8 +210,9 @@ discard block |
||
196 | 210 | $context['visual_verification_id'] = $verificationOptions['id']; |
197 | 211 | } |
198 | 212 | // Otherwise we have nothing to show. |
199 | - else |
|
200 | - $context['visual_verification'] = false; |
|
213 | + else { |
|
214 | + $context['visual_verification'] = false; |
|
215 | + } |
|
201 | 216 | |
202 | 217 | |
203 | 218 | $context += array( |
@@ -208,8 +223,9 @@ discard block |
||
208 | 223 | |
209 | 224 | // Were there any errors? |
210 | 225 | $context['registration_errors'] = array(); |
211 | - if (!empty($reg_errors)) |
|
212 | - $context['registration_errors'] = $reg_errors; |
|
226 | + if (!empty($reg_errors)) { |
|
227 | + $context['registration_errors'] = $reg_errors; |
|
228 | + } |
|
213 | 229 | |
214 | 230 | createToken('register'); |
215 | 231 | } |
@@ -226,27 +242,32 @@ discard block |
||
226 | 242 | validateToken('register'); |
227 | 243 | |
228 | 244 | // Check to ensure we're forcing SSL for authentication |
229 | - if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn()) |
|
230 | - fatal_lang_error('register_ssl_required'); |
|
245 | + if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn()) { |
|
246 | + fatal_lang_error('register_ssl_required'); |
|
247 | + } |
|
231 | 248 | |
232 | 249 | // Start collecting together any errors. |
233 | 250 | $reg_errors = array(); |
234 | 251 | |
235 | 252 | // You can't register if it's disabled. |
236 | - if (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == 3) |
|
237 | - fatal_lang_error('registration_disabled', false); |
|
253 | + if (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == 3) { |
|
254 | + fatal_lang_error('registration_disabled', false); |
|
255 | + } |
|
238 | 256 | |
239 | 257 | // Well, if you don't agree, you can't register. |
240 | - if (!empty($modSettings['requireAgreement']) && empty($_SESSION['registration_agreed'])) |
|
241 | - redirectexit(); |
|
258 | + if (!empty($modSettings['requireAgreement']) && empty($_SESSION['registration_agreed'])) { |
|
259 | + redirectexit(); |
|
260 | + } |
|
242 | 261 | |
243 | 262 | // Make sure they came from *somewhere*, have a session. |
244 | - if (!isset($_SESSION['old_url'])) |
|
245 | - redirectexit('action=signup'); |
|
263 | + if (!isset($_SESSION['old_url'])) { |
|
264 | + redirectexit('action=signup'); |
|
265 | + } |
|
246 | 266 | |
247 | 267 | // If we don't require an agreement, we need a extra check for coppa. |
248 | - if (empty($modSettings['requireAgreement']) && !empty($modSettings['coppaAge'])) |
|
249 | - $_SESSION['skip_coppa'] = !empty($_POST['accept_agreement']); |
|
268 | + if (empty($modSettings['requireAgreement']) && !empty($modSettings['coppaAge'])) { |
|
269 | + $_SESSION['skip_coppa'] = !empty($_POST['accept_agreement']); |
|
270 | + } |
|
250 | 271 | // Are they under age, and under age users are banned? |
251 | 272 | if (!empty($modSettings['coppaAge']) && empty($modSettings['coppaType']) && empty($_SESSION['skip_coppa'])) |
252 | 273 | { |
@@ -255,8 +276,9 @@ discard block |
||
255 | 276 | } |
256 | 277 | |
257 | 278 | // Check the time gate for miscreants. First make sure they came from somewhere that actually set it up. |
258 | - if (empty($_SESSION['register']['timenow']) || empty($_SESSION['register']['limit'])) |
|
259 | - redirectexit('action=signup'); |
|
279 | + if (empty($_SESSION['register']['timenow']) || empty($_SESSION['register']['limit'])) { |
|
280 | + redirectexit('action=signup'); |
|
281 | + } |
|
260 | 282 | // Failing that, check the time on it. |
261 | 283 | if (time() - $_SESSION['register']['timenow'] < $_SESSION['register']['limit']) |
262 | 284 | { |
@@ -276,8 +298,9 @@ discard block |
||
276 | 298 | if (is_array($context['visual_verification'])) |
277 | 299 | { |
278 | 300 | loadLanguage('Errors'); |
279 | - foreach ($context['visual_verification'] as $error) |
|
280 | - $reg_errors[] = $txt['error_' . $error]; |
|
301 | + foreach ($context['visual_verification'] as $error) { |
|
302 | + $reg_errors[] = $txt['error_' . $error]; |
|
303 | + } |
|
281 | 304 | } |
282 | 305 | } |
283 | 306 | |
@@ -286,14 +309,16 @@ discard block |
||
286 | 309 | if (!is_array($_POST[$key])) |
287 | 310 | { |
288 | 311 | // For UTF-8, replace any kind of space with a normal space, and remove any kind of control character (incl. "\n" and "\r"), then trim. |
289 | - if ($context['utf8']) |
|
290 | - $_POST[$key] = $smcFunc['htmltrim'](preg_replace(array('~\p{Z}+~u', '~\p{C}+~u'), array(' ', ''), $_POST[$key])); |
|
312 | + if ($context['utf8']) { |
|
313 | + $_POST[$key] = $smcFunc['htmltrim'](preg_replace(array('~\p{Z}+~u', '~\p{C}+~u'), array(' ', ''), $_POST[$key])); |
|
314 | + } |
|
291 | 315 | // Otherwise, just remove "\n" and "\r", then trim. |
292 | - else |
|
293 | - $_POST[$key] = $smcFunc['htmltrim'](str_replace(array("\n", "\r"), '', $_POST[$key])); |
|
316 | + else { |
|
317 | + $_POST[$key] = $smcFunc['htmltrim'](str_replace(array("\n", "\r"), '', $_POST[$key])); |
|
318 | + } |
|
319 | + } else { |
|
320 | + $_POST[$key] = htmltrim__recursive($_POST[$key]); |
|
294 | 321 | } |
295 | - else |
|
296 | - $_POST[$key] = htmltrim__recursive($_POST[$key]); |
|
297 | 322 | } |
298 | 323 | |
299 | 324 | // Collect all extra registration fields someone might have filled in. |
@@ -328,13 +353,15 @@ discard block |
||
328 | 353 | $possible_strings = array_merge(array('website_url', 'website_title'), $possible_strings); |
329 | 354 | |
330 | 355 | // Make sure their website URL is squeaky clean |
331 | - if (isset($_POST['website_url'])) |
|
332 | - $_POST['website_url'] = (string) validate_iri(sanitize_iri($_POST['website_url'])); |
|
356 | + if (isset($_POST['website_url'])) { |
|
357 | + $_POST['website_url'] = (string) validate_iri(sanitize_iri($_POST['website_url'])); |
|
358 | + } |
|
333 | 359 | } |
334 | 360 | } |
335 | 361 | |
336 | - if (isset($_POST['secret_answer']) && $_POST['secret_answer'] != '') |
|
337 | - $_POST['secret_answer'] = md5($_POST['secret_answer']); |
|
362 | + if (isset($_POST['secret_answer']) && $_POST['secret_answer'] != '') { |
|
363 | + $_POST['secret_answer'] = md5($_POST['secret_answer']); |
|
364 | + } |
|
338 | 365 | |
339 | 366 | // Needed for isReservedName() and registerMember(). |
340 | 367 | require_once($sourcedir . '/Subs-Members.php'); |
@@ -343,8 +370,9 @@ discard block |
||
343 | 370 | if (isset($_POST['real_name'])) |
344 | 371 | { |
345 | 372 | // Are you already allowed to edit the displayed name? |
346 | - if (allowedTo('profile_displayed_name') || allowedTo('moderate_forum')) |
|
347 | - $canEditDisplayName = true; |
|
373 | + if (allowedTo('profile_displayed_name') || allowedTo('moderate_forum')) { |
|
374 | + $canEditDisplayName = true; |
|
375 | + } |
|
348 | 376 | |
349 | 377 | // If you are a guest, will you be allowed to once you register? |
350 | 378 | else |
@@ -363,32 +391,37 @@ discard block |
||
363 | 391 | } |
364 | 392 | |
365 | 393 | // Only set it if you can and if we are sure it is good |
366 | - if ($canEditDisplayName && $smcFunc['htmltrim']($_POST['real_name']) != '' && !isReservedName($_POST['real_name']) && $smcFunc['strlen']($_POST['real_name']) < 60) |
|
367 | - $possible_strings[] = 'real_name'; |
|
394 | + if ($canEditDisplayName && $smcFunc['htmltrim']($_POST['real_name']) != '' && !isReservedName($_POST['real_name']) && $smcFunc['strlen']($_POST['real_name']) < 60) { |
|
395 | + $possible_strings[] = 'real_name'; |
|
396 | + } |
|
368 | 397 | } |
369 | 398 | |
370 | 399 | // Handle a string as a birthdate... |
371 | - if (isset($_POST['birthdate']) && $_POST['birthdate'] != '') |
|
372 | - $_POST['birthdate'] = strftime('%Y-%m-%d', strtotime($_POST['birthdate'])); |
|
400 | + if (isset($_POST['birthdate']) && $_POST['birthdate'] != '') { |
|
401 | + $_POST['birthdate'] = strftime('%Y-%m-%d', strtotime($_POST['birthdate'])); |
|
402 | + } |
|
373 | 403 | // Or birthdate parts... |
374 | - elseif (!empty($_POST['bday1']) && !empty($_POST['bday2'])) |
|
375 | - $_POST['birthdate'] = sprintf('%04d-%02d-%02d', empty($_POST['bday3']) ? 0 : (int) $_POST['bday3'], (int) $_POST['bday1'], (int) $_POST['bday2']); |
|
404 | + elseif (!empty($_POST['bday1']) && !empty($_POST['bday2'])) { |
|
405 | + $_POST['birthdate'] = sprintf('%04d-%02d-%02d', empty($_POST['bday3']) ? 0 : (int) $_POST['bday3'], (int) $_POST['bday1'], (int) $_POST['bday2']); |
|
406 | + } |
|
376 | 407 | |
377 | 408 | // Validate the passed language file. |
378 | 409 | if (isset($_POST['lngfile']) && !empty($modSettings['userLanguage'])) |
379 | 410 | { |
380 | 411 | // Do we have any languages? |
381 | - if (empty($context['languages'])) |
|
382 | - getLanguages(); |
|
412 | + if (empty($context['languages'])) { |
|
413 | + getLanguages(); |
|
414 | + } |
|
383 | 415 | |
384 | 416 | // Did we find it? |
385 | - if (isset($context['languages'][$_POST['lngfile']])) |
|
386 | - $_SESSION['language'] = $_POST['lngfile']; |
|
387 | - else |
|
417 | + if (isset($context['languages'][$_POST['lngfile']])) { |
|
418 | + $_SESSION['language'] = $_POST['lngfile']; |
|
419 | + } else { |
|
420 | + unset($_POST['lngfile']); |
|
421 | + } |
|
422 | + } else { |
|
388 | 423 | unset($_POST['lngfile']); |
389 | 424 | } |
390 | - else |
|
391 | - unset($_POST['lngfile']); |
|
392 | 425 | |
393 | 426 | // Set the options needed for registration. |
394 | 427 | $regOptions = array( |
@@ -408,22 +441,27 @@ discard block |
||
408 | 441 | ); |
409 | 442 | |
410 | 443 | // Include the additional options that might have been filled in. |
411 | - foreach ($possible_strings as $var) |
|
412 | - if (isset($_POST[$var])) |
|
444 | + foreach ($possible_strings as $var) { |
|
445 | + if (isset($_POST[$var])) |
|
413 | 446 | $regOptions['extra_register_vars'][$var] = $smcFunc['htmlspecialchars']($_POST[$var], ENT_QUOTES); |
414 | - foreach ($possible_ints as $var) |
|
415 | - if (isset($_POST[$var])) |
|
447 | + } |
|
448 | + foreach ($possible_ints as $var) { |
|
449 | + if (isset($_POST[$var])) |
|
416 | 450 | $regOptions['extra_register_vars'][$var] = (int) $_POST[$var]; |
417 | - foreach ($possible_floats as $var) |
|
418 | - if (isset($_POST[$var])) |
|
451 | + } |
|
452 | + foreach ($possible_floats as $var) { |
|
453 | + if (isset($_POST[$var])) |
|
419 | 454 | $regOptions['extra_register_vars'][$var] = (float) $_POST[$var]; |
420 | - foreach ($possible_bools as $var) |
|
421 | - if (isset($_POST[$var])) |
|
455 | + } |
|
456 | + foreach ($possible_bools as $var) { |
|
457 | + if (isset($_POST[$var])) |
|
422 | 458 | $regOptions['extra_register_vars'][$var] = empty($_POST[$var]) ? 0 : 1; |
459 | + } |
|
423 | 460 | |
424 | 461 | // Registration options are always default options... |
425 | - if (isset($_POST['default_options'])) |
|
426 | - $_POST['options'] = isset($_POST['options']) ? $_POST['options'] + $_POST['default_options'] : $_POST['default_options']; |
|
462 | + if (isset($_POST['default_options'])) { |
|
463 | + $_POST['options'] = isset($_POST['options']) ? $_POST['options'] + $_POST['default_options'] : $_POST['default_options']; |
|
464 | + } |
|
427 | 465 | $regOptions['theme_vars'] = isset($_POST['options']) && is_array($_POST['options']) ? $_POST['options'] : array(); |
428 | 466 | |
429 | 467 | // Make sure they are clean, dammit! |
@@ -443,12 +481,14 @@ discard block |
||
443 | 481 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
444 | 482 | { |
445 | 483 | // Don't allow overriding of the theme variables. |
446 | - if (isset($regOptions['theme_vars'][$row['col_name']])) |
|
447 | - unset($regOptions['theme_vars'][$row['col_name']]); |
|
484 | + if (isset($regOptions['theme_vars'][$row['col_name']])) { |
|
485 | + unset($regOptions['theme_vars'][$row['col_name']]); |
|
486 | + } |
|
448 | 487 | |
449 | 488 | // Not actually showing it then? |
450 | - if (!$row['show_reg']) |
|
451 | - continue; |
|
489 | + if (!$row['show_reg']) { |
|
490 | + continue; |
|
491 | + } |
|
452 | 492 | |
453 | 493 | // Prepare the value! |
454 | 494 | $value = isset($_POST['customfield'][$row['col_name']]) ? trim($_POST['customfield'][$row['col_name']]) : ''; |
@@ -457,24 +497,27 @@ discard block |
||
457 | 497 | if (!in_array($row['field_type'], array('check', 'select', 'radio'))) |
458 | 498 | { |
459 | 499 | // Is it too long? |
460 | - if ($row['field_length'] && $row['field_length'] < $smcFunc['strlen']($value)) |
|
461 | - $custom_field_errors[] = array('custom_field_too_long', array($row['field_name'], $row['field_length'])); |
|
500 | + if ($row['field_length'] && $row['field_length'] < $smcFunc['strlen']($value)) { |
|
501 | + $custom_field_errors[] = array('custom_field_too_long', array($row['field_name'], $row['field_length'])); |
|
502 | + } |
|
462 | 503 | |
463 | 504 | // Any masks to apply? |
464 | 505 | if ($row['field_type'] == 'text' && !empty($row['mask']) && $row['mask'] != 'none') |
465 | 506 | { |
466 | - if ($row['mask'] == 'email' && (!filter_var($value, FILTER_VALIDATE_EMAIL) || strlen($value) > 255)) |
|
467 | - $custom_field_errors[] = array('custom_field_invalid_email', array($row['field_name'])); |
|
468 | - elseif ($row['mask'] == 'number' && preg_match('~[^\d]~', $value)) |
|
469 | - $custom_field_errors[] = array('custom_field_not_number', array($row['field_name'])); |
|
470 | - elseif (substr($row['mask'], 0, 5) == 'regex' && trim($value) != '' && preg_match(substr($row['mask'], 5), $value) === 0) |
|
471 | - $custom_field_errors[] = array('custom_field_inproper_format', array($row['field_name'])); |
|
507 | + if ($row['mask'] == 'email' && (!filter_var($value, FILTER_VALIDATE_EMAIL) || strlen($value) > 255)) { |
|
508 | + $custom_field_errors[] = array('custom_field_invalid_email', array($row['field_name'])); |
|
509 | + } elseif ($row['mask'] == 'number' && preg_match('~[^\d]~', $value)) { |
|
510 | + $custom_field_errors[] = array('custom_field_not_number', array($row['field_name'])); |
|
511 | + } elseif (substr($row['mask'], 0, 5) == 'regex' && trim($value) != '' && preg_match(substr($row['mask'], 5), $value) === 0) { |
|
512 | + $custom_field_errors[] = array('custom_field_inproper_format', array($row['field_name'])); |
|
513 | + } |
|
472 | 514 | } |
473 | 515 | } |
474 | 516 | |
475 | 517 | // Is this required but not there? |
476 | - if (trim($value) == '' && $row['show_reg'] > 1) |
|
477 | - $custom_field_errors[] = array('custom_field_empty', array($row['field_name'])); |
|
518 | + if (trim($value) == '' && $row['show_reg'] > 1) { |
|
519 | + $custom_field_errors[] = array('custom_field_empty', array($row['field_name'])); |
|
520 | + } |
|
478 | 521 | } |
479 | 522 | $smcFunc['db_free_result']($request); |
480 | 523 | |
@@ -482,8 +525,9 @@ discard block |
||
482 | 525 | if (!empty($custom_field_errors)) |
483 | 526 | { |
484 | 527 | loadLanguage('Errors'); |
485 | - foreach ($custom_field_errors as $error) |
|
486 | - $reg_errors[] = vsprintf($txt['error_' . $error[0]], $error[1]); |
|
528 | + foreach ($custom_field_errors as $error) { |
|
529 | + $reg_errors[] = vsprintf($txt['error_' . $error[0]], $error[1]); |
|
530 | + } |
|
487 | 531 | } |
488 | 532 | |
489 | 533 | // Lets check for other errors before trying to register the member. |
@@ -528,8 +572,9 @@ discard block |
||
528 | 572 | } |
529 | 573 | |
530 | 574 | // If COPPA has been selected then things get complicated, setup the template. |
531 | - if (!empty($modSettings['coppaAge']) && empty($_SESSION['skip_coppa'])) |
|
532 | - redirectexit('action=coppa;member=' . $memberID); |
|
575 | + if (!empty($modSettings['coppaAge']) && empty($_SESSION['skip_coppa'])) { |
|
576 | + redirectexit('action=coppa;member=' . $memberID); |
|
577 | + } |
|
533 | 578 | // Basic template variable setup. |
534 | 579 | elseif (!empty($modSettings['registration_method'])) |
535 | 580 | { |
@@ -541,8 +586,7 @@ discard block |
||
541 | 586 | 'sub_template' => 'after', |
542 | 587 | 'description' => $modSettings['registration_method'] == 2 ? $txt['approval_after_registration'] : $txt['activate_after_registration'] |
543 | 588 | ); |
544 | - } |
|
545 | - else |
|
589 | + } else |
|
546 | 590 | { |
547 | 591 | call_integration_hook('integrate_activate', array($regOptions['username'])); |
548 | 592 | |
@@ -562,16 +606,18 @@ discard block |
||
562 | 606 | global $context, $txt, $modSettings, $scripturl, $sourcedir, $smcFunc, $language, $user_info; |
563 | 607 | |
564 | 608 | // Logged in users should not bother to activate their accounts |
565 | - if (!empty($user_info['id'])) |
|
566 | - redirectexit(); |
|
609 | + if (!empty($user_info['id'])) { |
|
610 | + redirectexit(); |
|
611 | + } |
|
567 | 612 | |
568 | 613 | loadLanguage('Login'); |
569 | 614 | loadTemplate('Login'); |
570 | 615 | |
571 | 616 | if (empty($_REQUEST['u']) && empty($_POST['user'])) |
572 | 617 | { |
573 | - if (empty($modSettings['registration_method']) || $modSettings['registration_method'] == '3') |
|
574 | - fatal_lang_error('no_access', false); |
|
618 | + if (empty($modSettings['registration_method']) || $modSettings['registration_method'] == '3') { |
|
619 | + fatal_lang_error('no_access', false); |
|
620 | + } |
|
575 | 621 | |
576 | 622 | $context['member_id'] = 0; |
577 | 623 | $context['sub_template'] = 'resend'; |
@@ -611,11 +657,13 @@ discard block |
||
611 | 657 | // Change their email address? (they probably tried a fake one first :P.) |
612 | 658 | if (isset($_POST['new_email'], $_REQUEST['passwd']) && hash_password($row['member_name'], $_REQUEST['passwd']) == $row['passwd'] && ($row['is_activated'] == 0 || $row['is_activated'] == 2)) |
613 | 659 | { |
614 | - if (empty($modSettings['registration_method']) || $modSettings['registration_method'] == 3) |
|
615 | - fatal_lang_error('no_access', false); |
|
660 | + if (empty($modSettings['registration_method']) || $modSettings['registration_method'] == 3) { |
|
661 | + fatal_lang_error('no_access', false); |
|
662 | + } |
|
616 | 663 | |
617 | - if (!filter_var($_POST['new_email'], FILTER_VALIDATE_EMAIL)) |
|
618 | - fatal_error(sprintf($txt['valid_email_needed'], $smcFunc['htmlspecialchars']($_POST['new_email'])), false); |
|
664 | + if (!filter_var($_POST['new_email'], FILTER_VALIDATE_EMAIL)) { |
|
665 | + fatal_error(sprintf($txt['valid_email_needed'], $smcFunc['htmlspecialchars']($_POST['new_email'])), false); |
|
666 | + } |
|
619 | 667 | |
620 | 668 | // Make sure their email isn't banned. |
621 | 669 | isBannedEmail($_POST['new_email'], 'cannot_register', $txt['ban_register_prohibited']); |
@@ -631,8 +679,9 @@ discard block |
||
631 | 679 | ) |
632 | 680 | ); |
633 | 681 | |
634 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
635 | - fatal_lang_error('email_in_use', false, array($smcFunc['htmlspecialchars']($_POST['new_email']))); |
|
682 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
683 | + fatal_lang_error('email_in_use', false, array($smcFunc['htmlspecialchars']($_POST['new_email']))); |
|
684 | + } |
|
636 | 685 | $smcFunc['db_free_result']($request); |
637 | 686 | |
638 | 687 | updateMemberData($row['id_member'], array('email_address' => $_POST['new_email'])); |
@@ -670,9 +719,9 @@ discard block |
||
670 | 719 | // Quit if this code is not right. |
671 | 720 | if (empty($_REQUEST['code']) || $row['validation_code'] != $_REQUEST['code']) |
672 | 721 | { |
673 | - if (!empty($row['is_activated'])) |
|
674 | - fatal_lang_error('already_activated', false); |
|
675 | - elseif ($row['validation_code'] == '') |
|
722 | + if (!empty($row['is_activated'])) { |
|
723 | + fatal_lang_error('already_activated', false); |
|
724 | + } elseif ($row['validation_code'] == '') |
|
676 | 725 | { |
677 | 726 | loadLanguage('Profile'); |
678 | 727 | fatal_error(sprintf($txt['registration_not_approved'], $scripturl . '?action=activate;user=' . $row['member_name']), false); |
@@ -722,8 +771,9 @@ discard block |
||
722 | 771 | loadTemplate('Register'); |
723 | 772 | |
724 | 773 | // No User ID?? |
725 | - if (!isset($_GET['member'])) |
|
726 | - fatal_lang_error('no_access', false); |
|
774 | + if (!isset($_GET['member'])) { |
|
775 | + fatal_lang_error('no_access', false); |
|
776 | + } |
|
727 | 777 | |
728 | 778 | // Get the user details... |
729 | 779 | $request = $smcFunc['db_query']('', ' |
@@ -736,8 +786,9 @@ discard block |
||
736 | 786 | 'is_coppa' => 5, |
737 | 787 | ) |
738 | 788 | ); |
739 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
740 | - fatal_lang_error('no_access', false); |
|
789 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
790 | + fatal_lang_error('no_access', false); |
|
791 | + } |
|
741 | 792 | list ($username) = $smcFunc['db_fetch_row']($request); |
742 | 793 | $smcFunc['db_free_result']($request); |
743 | 794 | |
@@ -775,8 +826,7 @@ discard block |
||
775 | 826 | echo $data; |
776 | 827 | obExit(false); |
777 | 828 | } |
778 | - } |
|
779 | - else |
|
829 | + } else |
|
780 | 830 | { |
781 | 831 | $context += array( |
782 | 832 | 'page_title' => $txt['coppa_title'], |
@@ -829,8 +879,9 @@ discard block |
||
829 | 879 | { |
830 | 880 | require_once($sourcedir . '/Subs-Graphics.php'); |
831 | 881 | |
832 | - if (in_array('gd', get_loaded_extensions()) && !showCodeImage($code)) |
|
833 | - header('HTTP/1.1 400 Bad Request'); |
|
882 | + if (in_array('gd', get_loaded_extensions()) && !showCodeImage($code)) { |
|
883 | + header('HTTP/1.1 400 Bad Request'); |
|
884 | + } |
|
834 | 885 | |
835 | 886 | // Otherwise just show a pre-defined letter. |
836 | 887 | elseif (isset($_REQUEST['letter'])) |
@@ -848,14 +899,13 @@ discard block |
||
848 | 899 | header('content-type: image/gif'); |
849 | 900 | die("\x47\x49\x46\x38\x39\x61\x01\x00\x01\x00\x80\x00\x00\x00\x00\x00\x00\x00\x00\x21\xF9\x04\x01\x00\x00\x00\x00\x2C\x00\x00\x00\x00\x01\x00\x01\x00\x00\x02\x02\x44\x01\x00\x3B"); |
850 | 901 | } |
851 | - } |
|
852 | - |
|
853 | - elseif ($_REQUEST['format'] === '.wav') |
|
902 | + } elseif ($_REQUEST['format'] === '.wav') |
|
854 | 903 | { |
855 | 904 | require_once($sourcedir . '/Subs-Sound.php'); |
856 | 905 | |
857 | - if (!createWaveFile($code)) |
|
858 | - header('HTTP/1.1 400 Bad Request'); |
|
906 | + if (!createWaveFile($code)) { |
|
907 | + header('HTTP/1.1 400 Bad Request'); |
|
908 | + } |
|
859 | 909 | } |
860 | 910 | |
861 | 911 | // We all die one day... |
@@ -28,14 +28,15 @@ discard block |
||
28 | 28 | <div id="confirm_buttons">'; |
29 | 29 | |
30 | 30 | // Age restriction in effect? |
31 | - if ($context['show_coppa']) |
|
32 | - echo ' |
|
31 | + if ($context['show_coppa']) { |
|
32 | + echo ' |
|
33 | 33 | <input type="submit" name="accept_agreement" value="', $context['coppa_agree_above'], '" class="button"><br> |
34 | 34 | <br> |
35 | 35 | <input type="submit" name="accept_agreement_coppa" value="', $context['coppa_agree_below'], '" class="button">'; |
36 | - else |
|
37 | - echo ' |
|
36 | + } else { |
|
37 | + echo ' |
|
38 | 38 | <input type="submit" name="accept_agreement" value="', $txt['agreement_agree'], '" class="button">'; |
39 | + } |
|
39 | 40 | |
40 | 41 | echo ' |
41 | 42 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -78,9 +79,10 @@ discard block |
||
78 | 79 | <ul>'; |
79 | 80 | |
80 | 81 | // Cycle through each error and display an error message. |
81 | - foreach ($context['registration_errors'] as $error) |
|
82 | - echo ' |
|
82 | + foreach ($context['registration_errors'] as $error) { |
|
83 | + echo ' |
|
83 | 84 | <li>', $error, '</li>'; |
85 | + } |
|
84 | 86 | |
85 | 87 | echo ' |
86 | 88 | </ul> |
@@ -149,14 +151,15 @@ discard block |
||
149 | 151 | echo ' |
150 | 152 | <dl class="register_form">'; |
151 | 153 | |
152 | - foreach ($context['custom_fields'] as $field) |
|
153 | - if ($field['show_reg'] > 1) |
|
154 | + foreach ($context['custom_fields'] as $field) { |
|
155 | + if ($field['show_reg'] > 1) |
|
154 | 156 | echo ' |
155 | 157 | <dt> |
156 | 158 | <strong', !empty($field['is_error']) ? ' class="red"' : '', '>', $field['name'], ':</strong> |
157 | 159 | <span class="smalltext">', $field['desc'], '</span> |
158 | 160 | </dt> |
159 | 161 | <dd>', str_replace('name="', 'tabindex="' . $context['tabindex']++ . '" name="', $field['input_html']), '</dd>'; |
162 | + } |
|
160 | 163 | |
161 | 164 | echo ' |
162 | 165 | </dl>'; |
@@ -167,14 +170,15 @@ discard block |
||
167 | 170 | </div><!-- .roundframe -->'; |
168 | 171 | |
169 | 172 | // If we have either of these, show the extra group. |
170 | - if (!empty($context['profile_fields']) || !empty($context['custom_fields'])) |
|
171 | - echo ' |
|
173 | + if (!empty($context['profile_fields']) || !empty($context['custom_fields'])) { |
|
174 | + echo ' |
|
172 | 175 | <div class="title_bar title_top"> |
173 | 176 | <h3 class="titlebg">', $txt['additional_information'], '</h3> |
174 | 177 | </div> |
175 | 178 | <div class="roundframe noup"> |
176 | 179 | <fieldset> |
177 | 180 | <dl class="register_form" id="custom_group">'; |
181 | + } |
|
178 | 182 | |
179 | 183 | if (!empty($context['profile_fields'])) |
180 | 184 | { |
@@ -188,41 +192,45 @@ discard block |
||
188 | 192 | $callback_func = 'template_profile_' . $field['callback_func']; |
189 | 193 | $callback_func(); |
190 | 194 | } |
191 | - } |
|
192 | - else |
|
195 | + } else |
|
193 | 196 | { |
194 | 197 | echo ' |
195 | 198 | <dt> |
196 | 199 | <strong', !empty($field['is_error']) ? ' class="red"' : '', '>', $field['label'], ':</strong>'; |
197 | 200 | |
198 | 201 | // Does it have any subtext to show? |
199 | - if (!empty($field['subtext'])) |
|
200 | - echo ' |
|
202 | + if (!empty($field['subtext'])) { |
|
203 | + echo ' |
|
201 | 204 | <span class="smalltext">', $field['subtext'], '</span>'; |
205 | + } |
|
202 | 206 | |
203 | 207 | echo ' |
204 | 208 | </dt> |
205 | 209 | <dd>'; |
206 | 210 | |
207 | 211 | // Want to put something infront of the box? |
208 | - if (!empty($field['preinput'])) |
|
209 | - echo ' |
|
212 | + if (!empty($field['preinput'])) { |
|
213 | + echo ' |
|
210 | 214 | ', $field['preinput']; |
215 | + } |
|
211 | 216 | |
212 | 217 | // What type of data are we showing? |
213 | - if ($field['type'] == 'label') |
|
214 | - echo ' |
|
218 | + if ($field['type'] == 'label') { |
|
219 | + echo ' |
|
215 | 220 | ', $field['value']; |
221 | + } |
|
216 | 222 | |
217 | 223 | // Maybe it's a text box - very likely! |
218 | - elseif (in_array($field['type'], array('int', 'float', 'text', 'password', 'url'))) |
|
219 | - echo ' |
|
224 | + elseif (in_array($field['type'], array('int', 'float', 'text', 'password', 'url'))) { |
|
225 | + echo ' |
|
220 | 226 | <input type="', $field['type'] == 'password' ? 'password' : 'text', '" name="', $key, '" id="', $key, '" size="', empty($field['size']) ? 30 : $field['size'], '" value="', $field['value'], '" tabindex="', $context['tabindex']++, '" ', $field['input_attr'], '>'; |
227 | + } |
|
221 | 228 | |
222 | 229 | // You "checking" me out? ;) |
223 | - elseif ($field['type'] == 'check') |
|
224 | - echo ' |
|
230 | + elseif ($field['type'] == 'check') { |
|
231 | + echo ' |
|
225 | 232 | <input type="hidden" name="', $key, '" value="0"><input type="checkbox" name="', $key, '" id="', $key, '"', !empty($field['value']) ? ' checked' : '', ' value="1" tabindex="', $context['tabindex']++, '" ', $field['input_attr'], '>'; |
233 | + } |
|
226 | 234 | |
227 | 235 | // Always fun - select boxes! |
228 | 236 | elseif ($field['type'] == 'select') |
@@ -233,14 +241,16 @@ discard block |
||
233 | 241 | if (isset($field['options'])) |
234 | 242 | { |
235 | 243 | // Is this some code to generate the options? |
236 | - if (!is_array($field['options'])) |
|
237 | - $field['options'] = eval($field['options']); |
|
244 | + if (!is_array($field['options'])) { |
|
245 | + $field['options'] = eval($field['options']); |
|
246 | + } |
|
238 | 247 | |
239 | 248 | // Assuming we now have some! |
240 | - if (is_array($field['options'])) |
|
241 | - foreach ($field['options'] as $value => $name) |
|
249 | + if (is_array($field['options'])) { |
|
250 | + foreach ($field['options'] as $value => $name) |
|
242 | 251 | echo ' |
243 | 252 | <option', is_numeric($value) ? ' value="" disabled' : ' value="' . $value . '"', $value === $field['value'] ? ' selected' : '', '>', $name, '</option>'; |
253 | + } |
|
244 | 254 | } |
245 | 255 | |
246 | 256 | echo ' |
@@ -248,9 +258,10 @@ discard block |
||
248 | 258 | } |
249 | 259 | |
250 | 260 | // Something to end with? |
251 | - if (!empty($field['postinput'])) |
|
252 | - echo ' |
|
261 | + if (!empty($field['postinput'])) { |
|
262 | + echo ' |
|
253 | 263 | ', $field['postinput']; |
264 | + } |
|
254 | 265 | |
255 | 266 | echo ' |
256 | 267 | </dd>'; |
@@ -261,25 +272,27 @@ discard block |
||
261 | 272 | // Are there any custom fields? |
262 | 273 | if (!empty($context['custom_fields'])) |
263 | 274 | { |
264 | - foreach ($context['custom_fields'] as $field) |
|
265 | - if ($field['show_reg'] < 2) |
|
275 | + foreach ($context['custom_fields'] as $field) { |
|
276 | + if ($field['show_reg'] < 2) |
|
266 | 277 | echo ' |
267 | 278 | <dt> |
268 | 279 | <strong', !empty($field['is_error']) ? ' class="red"' : '', '>', $field['name'], ':</strong> |
269 | 280 | <span class="smalltext">', $field['desc'], '</span> |
270 | 281 | </dt> |
271 | 282 | <dd>', $field['input_html'], '</dd>'; |
283 | + } |
|
272 | 284 | } |
273 | 285 | |
274 | 286 | // If we have either of these, close the list like a proper gent. |
275 | - if (!empty($context['profile_fields']) || !empty($context['custom_fields'])) |
|
276 | - echo ' |
|
287 | + if (!empty($context['profile_fields']) || !empty($context['custom_fields'])) { |
|
288 | + echo ' |
|
277 | 289 | </dl> |
278 | 290 | </fieldset> |
279 | 291 | </div><!-- .roundframe -->'; |
292 | + } |
|
280 | 293 | |
281 | - if ($context['visual_verification']) |
|
282 | - echo ' |
|
294 | + if ($context['visual_verification']) { |
|
295 | + echo ' |
|
283 | 296 | <div class="title_bar title_top"> |
284 | 297 | <h3 class="titlebg">', $txt['verification'], '</h3> |
285 | 298 | </div> |
@@ -288,19 +301,21 @@ discard block |
||
288 | 301 | ', template_control_verification($context['visual_verification_id'], 'all'), ' |
289 | 302 | </fieldset> |
290 | 303 | </div>'; |
304 | + } |
|
291 | 305 | |
292 | 306 | echo ' |
293 | 307 | <div id="confirm_buttons" class="flow_auto">'; |
294 | 308 | |
295 | 309 | // Age restriction in effect? |
296 | - if (!$context['require_agreement'] && $context['show_coppa']) |
|
297 | - echo ' |
|
310 | + if (!$context['require_agreement'] && $context['show_coppa']) { |
|
311 | + echo ' |
|
298 | 312 | <input type="submit" name="accept_agreement" value="', $context['coppa_agree_above'], '" class="button"><br> |
299 | 313 | <br> |
300 | 314 | <input type="submit" name="accept_agreement_coppa" value="', $context['coppa_agree_below'], '" class="button">'; |
301 | - else |
|
302 | - echo ' |
|
315 | + } else { |
|
316 | + echo ' |
|
303 | 317 | <input type="submit" name="regSubmit" value="', $txt['register'], '" tabindex="', $context['tabindex']++, '" class="button">'; |
318 | + } |
|
304 | 319 | |
305 | 320 | echo ' |
306 | 321 | </div> |
@@ -362,25 +377,28 @@ discard block |
||
362 | 377 | <p>', $context['coppa']['many_options'] ? $txt['coppa_send_to_two_options'] : $txt['coppa_send_to_one_option'], '</p>'; |
363 | 378 | |
364 | 379 | // Can they send by post? |
365 | - if (!empty($context['coppa']['post'])) |
|
366 | - echo ' |
|
380 | + if (!empty($context['coppa']['post'])) { |
|
381 | + echo ' |
|
367 | 382 | <h4>1) ', $txt['coppa_send_by_post'], '</h4> |
368 | 383 | <div class="coppa_contact"> |
369 | 384 | ', $context['coppa']['post'], ' |
370 | 385 | </div>'; |
386 | + } |
|
371 | 387 | |
372 | 388 | // Can they send by fax?? |
373 | - if (!empty($context['coppa']['fax'])) |
|
374 | - echo ' |
|
389 | + if (!empty($context['coppa']['fax'])) { |
|
390 | + echo ' |
|
375 | 391 | <h4>', !empty($context['coppa']['post']) ? '2' : '1', ') ', $txt['coppa_send_by_fax'], '</h4> |
376 | 392 | <div class="coppa_contact"> |
377 | 393 | ', $context['coppa']['fax'], ' |
378 | 394 | </div>'; |
395 | + } |
|
379 | 396 | |
380 | 397 | // Offer an alternative Phone Number? |
381 | - if ($context['coppa']['phone']) |
|
382 | - echo ' |
|
398 | + if ($context['coppa']['phone']) { |
|
399 | + echo ' |
|
383 | 400 | <p>', $context['coppa']['phone'], '</p>'; |
401 | + } |
|
384 | 402 | |
385 | 403 | echo ' |
386 | 404 | </div><!-- #coppa -->'; |
@@ -445,19 +463,20 @@ discard block |
||
445 | 463 | <body style="margin: 1ex;"> |
446 | 464 | <div class="windowbg description" style="text-align: center;">'; |
447 | 465 | |
448 | - if (isBrowser('is_ie') || isBrowser('is_ie11')) |
|
449 | - echo ' |
|
466 | + if (isBrowser('is_ie') || isBrowser('is_ie11')) { |
|
467 | + echo ' |
|
450 | 468 | <object classid="clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95" type="audio/x-wav"> |
451 | 469 | <param name="AutoStart" value="1"> |
452 | 470 | <param name="FileName" value="', $context['verification_sound_href'], '"> |
453 | 471 | </object>'; |
454 | - else |
|
455 | - echo ' |
|
472 | + } else { |
|
473 | + echo ' |
|
456 | 474 | <audio src="', $context['verification_sound_href'], '" controls> |
457 | 475 | <object type="audio/x-wav" data="', $context['verification_sound_href'], '"> |
458 | 476 | <a href="', $context['verification_sound_href'], '" rel="nofollow">', $context['verification_sound_href'], '</a> |
459 | 477 | </object> |
460 | 478 | </audio>'; |
479 | + } |
|
461 | 480 | |
462 | 481 | echo ' |
463 | 482 | <br> |
@@ -485,11 +504,12 @@ discard block |
||
485 | 504 | </div> |
486 | 505 | <div id="register_screen" class="windowbg2 noup">'; |
487 | 506 | |
488 | - if (!empty($context['registration_done'])) |
|
489 | - echo ' |
|
507 | + if (!empty($context['registration_done'])) { |
|
508 | + echo ' |
|
490 | 509 | <div class="infobox"> |
491 | 510 | ', $context['registration_done'], ' |
492 | 511 | </div>'; |
512 | + } |
|
493 | 513 | |
494 | 514 | echo ' |
495 | 515 | <dl class="register_form" id="admin_register_form"> |
@@ -525,9 +545,10 @@ discard block |
||
525 | 545 | <dd> |
526 | 546 | <select name="group" id="group_select" tabindex="', $context['tabindex']++, '">'; |
527 | 547 | |
528 | - foreach ($context['member_groups'] as $id => $name) |
|
529 | - echo ' |
|
548 | + foreach ($context['member_groups'] as $id => $name) { |
|
549 | + echo ' |
|
530 | 550 | <option value="', $id, '">', $name, '</option>'; |
551 | + } |
|
531 | 552 | |
532 | 553 | echo ' |
533 | 554 | </select> |
@@ -535,8 +556,8 @@ discard block |
||
535 | 556 | } |
536 | 557 | |
537 | 558 | // If there is any field marked as required, show it here! |
538 | - if (!empty($context['custom_fields_required']) && !empty($context['custom_fields'])) |
|
539 | - foreach ($context['custom_fields'] as $field) |
|
559 | + if (!empty($context['custom_fields_required']) && !empty($context['custom_fields'])) { |
|
560 | + foreach ($context['custom_fields'] as $field) |
|
540 | 561 | if ($field['show_reg'] > 1) |
541 | 562 | echo ' |
542 | 563 | <dt> |
@@ -546,6 +567,7 @@ discard block |
||
546 | 567 | <dd> |
547 | 568 | ', str_replace('name="', 'tabindex="' . $context['tabindex']++ . '" name="', $field['input_html']), ' |
548 | 569 | </dd>'; |
570 | + } |
|
549 | 571 | |
550 | 572 | echo ' |
551 | 573 | <dt> |
@@ -582,13 +604,13 @@ discard block |
||
582 | 604 | { |
583 | 605 | global $context, $scripturl, $txt; |
584 | 606 | |
585 | - if (!empty($context['saved_successful'])) |
|
586 | - echo ' |
|
607 | + if (!empty($context['saved_successful'])) { |
|
608 | + echo ' |
|
587 | 609 | <div class="infobox">', $txt['settings_saved'], '</div>'; |
588 | - |
|
589 | - elseif (!empty($context['could_not_save'])) |
|
590 | - echo ' |
|
610 | + } elseif (!empty($context['could_not_save'])) { |
|
611 | + echo ' |
|
591 | 612 | <div class="errorbox">', $txt['admin_agreement_not_saved'], '</div>'; |
613 | + } |
|
592 | 614 | |
593 | 615 | // Just a big box to edit the text file ;) |
594 | 616 | echo ' |
@@ -598,9 +620,10 @@ discard block |
||
598 | 620 | </div>'; |
599 | 621 | |
600 | 622 | // Warning for if the file isn't writable. |
601 | - if (!empty($context['warning'])) |
|
602 | - echo ' |
|
623 | + if (!empty($context['warning'])) { |
|
624 | + echo ' |
|
603 | 625 | <p class="error">', $context['warning'], '</p>'; |
626 | + } |
|
604 | 627 | |
605 | 628 | echo ' |
606 | 629 | <div class="windowbg2 noup" id="registration_agreement">'; |
@@ -617,9 +640,10 @@ discard block |
||
617 | 640 | <strong>', $txt['admin_agreement_select_language'], ':</strong> |
618 | 641 | <select name="agree_lang" onchange="document.getElementById(\'change_reg\').submit();" tabindex="', $context['tabindex']++, '">'; |
619 | 642 | |
620 | - foreach ($context['editable_agreements'] as $file => $name) |
|
621 | - echo ' |
|
643 | + foreach ($context['editable_agreements'] as $file => $name) { |
|
644 | + echo ' |
|
622 | 645 | <option value="', $file, '"', $context['current_agreement'] == $file ? ' selected' : '', '>', $name, '</option>'; |
646 | + } |
|
623 | 647 | |
624 | 648 | echo ' |
625 | 649 | </select> |
@@ -659,9 +683,10 @@ discard block |
||
659 | 683 | { |
660 | 684 | global $context, $scripturl, $txt; |
661 | 685 | |
662 | - if (!empty($context['saved_successful'])) |
|
663 | - echo ' |
|
686 | + if (!empty($context['saved_successful'])) { |
|
687 | + echo ' |
|
664 | 688 | <div class="infobox">', $txt['settings_saved'], '</div>'; |
689 | + } |
|
665 | 690 | |
666 | 691 | echo ' |
667 | 692 | <form id="admin_form_wrapper" action="', $scripturl, '?action=admin;area=regcenter" method="post" accept-charset="', $context['character_set'], '"> |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 4 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * Get all birthdays within the given time range. |
@@ -60,8 +61,7 @@ discard block |
||
60 | 61 | 'max_year' => $year_high, |
61 | 62 | ) |
62 | 63 | ); |
63 | - } |
|
64 | - else |
|
64 | + } else |
|
65 | 65 | { |
66 | 66 | $result = $smcFunc['db_query']('birthday_array', ' |
67 | 67 | SELECT id_member, real_name, YEAR(birthdate) AS birth_year, birthdate |
@@ -91,10 +91,11 @@ discard block |
||
91 | 91 | $bday = array(); |
92 | 92 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
93 | 93 | { |
94 | - if ($year_low != $year_high) |
|
95 | - $age_year = substr($row['birthdate'], 5) < substr($high_date, 5) ? $year_high : $year_low; |
|
96 | - else |
|
97 | - $age_year = $year_low; |
|
94 | + if ($year_low != $year_high) { |
|
95 | + $age_year = substr($row['birthdate'], 5) < substr($high_date, 5) ? $year_high : $year_low; |
|
96 | + } else { |
|
97 | + $age_year = $year_low; |
|
98 | + } |
|
98 | 99 | |
99 | 100 | $bday[$age_year . substr($row['birthdate'], 4)][] = array( |
100 | 101 | 'id' => $row['id_member'], |
@@ -108,8 +109,9 @@ discard block |
||
108 | 109 | ksort($bday); |
109 | 110 | |
110 | 111 | // Set is_last, so the themes know when to stop placing separators. |
111 | - foreach ($bday as $mday => $array) |
|
112 | - $bday[$mday][count($array) - 1]['is_last'] = true; |
|
112 | + foreach ($bday as $mday => $array) { |
|
113 | + $bday[$mday][count($array) - 1]['is_last'] = true; |
|
114 | + } |
|
113 | 115 | |
114 | 116 | return $bday; |
115 | 117 | } |
@@ -133,8 +135,9 @@ discard block |
||
133 | 135 | static $timezone_array = array(); |
134 | 136 | require_once($sourcedir . '/Subs.php'); |
135 | 137 | |
136 | - if (empty($timezone_array['default'])) |
|
137 | - $timezone_array['default'] = timezone_open(date_default_timezone_get()); |
|
138 | + if (empty($timezone_array['default'])) { |
|
139 | + $timezone_array['default'] = timezone_open(date_default_timezone_get()); |
|
140 | + } |
|
138 | 141 | |
139 | 142 | $low_object = date_create($low_date); |
140 | 143 | $high_object = date_create($high_date); |
@@ -161,8 +164,9 @@ discard block |
||
161 | 164 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
162 | 165 | { |
163 | 166 | // If the attached topic is not approved then for the moment pretend it doesn't exist |
164 | - if (!empty($row['id_first_msg']) && $modSettings['postmod_active'] && !$row['approved']) |
|
165 | - continue; |
|
167 | + if (!empty($row['id_first_msg']) && $modSettings['postmod_active'] && !$row['approved']) { |
|
168 | + continue; |
|
169 | + } |
|
166 | 170 | |
167 | 171 | // Force a censor of the title - as often these are used by others. |
168 | 172 | censorText($row['title'], $use_permissions ? false : true); |
@@ -170,12 +174,14 @@ discard block |
||
170 | 174 | // Get the various time and date properties for this event |
171 | 175 | list($start, $end, $allday, $span, $tz, $tz_abbrev) = buildEventDatetimes($row); |
172 | 176 | |
173 | - if (empty($timezone_array[$tz])) |
|
174 | - $timezone_array[$tz] = timezone_open($tz); |
|
177 | + if (empty($timezone_array[$tz])) { |
|
178 | + $timezone_array[$tz] = timezone_open($tz); |
|
179 | + } |
|
175 | 180 | |
176 | 181 | // Sanity check |
177 | - if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count'])) |
|
178 | - continue; |
|
182 | + if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count'])) { |
|
183 | + continue; |
|
184 | + } |
|
179 | 185 | |
180 | 186 | // Get set up for the loop |
181 | 187 | $start_object = date_create($row['start_date'] . (!$allday ? ' ' . $row['start_time'] : ''), $timezone_array[$tz]); |
@@ -239,8 +245,8 @@ discard block |
||
239 | 245 | ); |
240 | 246 | |
241 | 247 | // If we're using permissions (calendar pages?) then just ouput normal contextual style information. |
242 | - if ($use_permissions) |
|
243 | - $events[date_format($cal_date, 'Y-m-d')][] = array_merge($eventProperties, array( |
|
248 | + if ($use_permissions) { |
|
249 | + $events[date_format($cal_date, 'Y-m-d')][] = array_merge($eventProperties, array( |
|
244 | 250 | 'href' => $row['id_board'] == 0 ? '' : $scripturl . '?topic=' . $row['id_topic'] . '.0', |
245 | 251 | 'link' => $row['id_board'] == 0 ? $row['title'] : '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">' . $row['title'] . '</a>', |
246 | 252 | 'can_edit' => allowedTo('calendar_edit_any') || ($row['id_member'] == $user_info['id'] && allowedTo('calendar_edit_own')), |
@@ -248,9 +254,10 @@ discard block |
||
248 | 254 | 'can_export' => !empty($modSettings['cal_export']) ? true : false, |
249 | 255 | 'export_href' => $scripturl . '?action=calendar;sa=ical;eventid=' . $row['id_event'] . ';' . $context['session_var'] . '=' . $context['session_id'], |
250 | 256 | )); |
257 | + } |
|
251 | 258 | // Otherwise, this is going to be cached and the VIEWER'S permissions should apply... just put together some info. |
252 | - else |
|
253 | - $events[date_format($cal_date, 'Y-m-d')][] = array_merge($eventProperties, array( |
|
259 | + else { |
|
260 | + $events[date_format($cal_date, 'Y-m-d')][] = array_merge($eventProperties, array( |
|
254 | 261 | 'href' => $row['id_topic'] == 0 ? '' : $scripturl . '?topic=' . $row['id_topic'] . '.0', |
255 | 262 | 'link' => $row['id_topic'] == 0 ? $row['title'] : '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">' . $row['title'] . '</a>', |
256 | 263 | 'can_edit' => false, |
@@ -260,6 +267,7 @@ discard block |
||
260 | 267 | 'poster' => $row['id_member'], |
261 | 268 | 'allowed_groups' => explode(',', $row['member_groups']), |
262 | 269 | )); |
270 | + } |
|
263 | 271 | |
264 | 272 | date_add($cal_date, date_interval_create_from_date_string('1 day')); |
265 | 273 | } |
@@ -269,8 +277,9 @@ discard block |
||
269 | 277 | // If we're doing normal contextual data, go through and make things clear to the templates ;). |
270 | 278 | if ($use_permissions) |
271 | 279 | { |
272 | - foreach ($events as $mday => $array) |
|
273 | - $events[$mday][count($array) - 1]['is_last'] = true; |
|
280 | + foreach ($events as $mday => $array) { |
|
281 | + $events[$mday][count($array) - 1]['is_last'] = true; |
|
282 | + } |
|
274 | 283 | } |
275 | 284 | |
276 | 285 | ksort($events); |
@@ -290,11 +299,12 @@ discard block |
||
290 | 299 | global $smcFunc; |
291 | 300 | |
292 | 301 | // Get the lowest and highest dates for "all years". |
293 | - if (substr($low_date, 0, 4) != substr($high_date, 0, 4)) |
|
294 | - $allyear_part = 'event_date BETWEEN {date:all_year_low} AND {date:all_year_dec} |
|
302 | + if (substr($low_date, 0, 4) != substr($high_date, 0, 4)) { |
|
303 | + $allyear_part = 'event_date BETWEEN {date:all_year_low} AND {date:all_year_dec} |
|
295 | 304 | OR event_date BETWEEN {date:all_year_jan} AND {date:all_year_high}'; |
296 | - else |
|
297 | - $allyear_part = 'event_date BETWEEN {date:all_year_low} AND {date:all_year_high}'; |
|
305 | + } else { |
|
306 | + $allyear_part = 'event_date BETWEEN {date:all_year_low} AND {date:all_year_high}'; |
|
307 | + } |
|
298 | 308 | |
299 | 309 | // Find some holidays... ;). |
300 | 310 | $result = $smcFunc['db_query']('', ' |
@@ -314,10 +324,11 @@ discard block |
||
314 | 324 | $holidays = array(); |
315 | 325 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
316 | 326 | { |
317 | - if (substr($low_date, 0, 4) != substr($high_date, 0, 4)) |
|
318 | - $event_year = substr($row['event_date'], 5) < substr($high_date, 5) ? substr($high_date, 0, 4) : substr($low_date, 0, 4); |
|
319 | - else |
|
320 | - $event_year = substr($low_date, 0, 4); |
|
327 | + if (substr($low_date, 0, 4) != substr($high_date, 0, 4)) { |
|
328 | + $event_year = substr($row['event_date'], 5) < substr($high_date, 5) ? substr($high_date, 0, 4) : substr($low_date, 0, 4); |
|
329 | + } else { |
|
330 | + $event_year = substr($low_date, 0, 4); |
|
331 | + } |
|
321 | 332 | |
322 | 333 | $holidays[$event_year . substr($row['event_date'], 4)][] = $row['title']; |
323 | 334 | } |
@@ -343,10 +354,12 @@ discard block |
||
343 | 354 | isAllowedTo('calendar_post'); |
344 | 355 | |
345 | 356 | // No board? No topic?!? |
346 | - if (empty($board)) |
|
347 | - fatal_lang_error('missing_board_id', false); |
|
348 | - if (empty($topic)) |
|
349 | - fatal_lang_error('missing_topic_id', false); |
|
357 | + if (empty($board)) { |
|
358 | + fatal_lang_error('missing_board_id', false); |
|
359 | + } |
|
360 | + if (empty($topic)) { |
|
361 | + fatal_lang_error('missing_topic_id', false); |
|
362 | + } |
|
350 | 363 | |
351 | 364 | // Administrator, Moderator, or owner. Period. |
352 | 365 | if (!allowedTo('admin_forum') && !allowedTo('moderate_board')) |
@@ -364,12 +377,14 @@ discard block |
||
364 | 377 | if ($row = $smcFunc['db_fetch_assoc']($result)) |
365 | 378 | { |
366 | 379 | // Not the owner of the topic. |
367 | - if ($row['id_member_started'] != $user_info['id']) |
|
368 | - fatal_lang_error('not_your_topic', 'user'); |
|
380 | + if ($row['id_member_started'] != $user_info['id']) { |
|
381 | + fatal_lang_error('not_your_topic', 'user'); |
|
382 | + } |
|
369 | 383 | } |
370 | 384 | // Topic/Board doesn't exist..... |
371 | - else |
|
372 | - fatal_lang_error('calendar_no_topic', 'general'); |
|
385 | + else { |
|
386 | + fatal_lang_error('calendar_no_topic', 'general'); |
|
387 | + } |
|
373 | 388 | $smcFunc['db_free_result']($result); |
374 | 389 | } |
375 | 390 | } |
@@ -457,14 +472,16 @@ discard block |
||
457 | 472 | if (!empty($calendarOptions['start_day'])) |
458 | 473 | { |
459 | 474 | $nShift -= $calendarOptions['start_day']; |
460 | - if ($nShift < 0) |
|
461 | - $nShift = 7 + $nShift; |
|
475 | + if ($nShift < 0) { |
|
476 | + $nShift = 7 + $nShift; |
|
477 | + } |
|
462 | 478 | } |
463 | 479 | |
464 | 480 | // Number of rows required to fit the month. |
465 | 481 | $nRows = floor(($month_info['last_day']['day_of_month'] + $nShift) / 7); |
466 | - if (($month_info['last_day']['day_of_month'] + $nShift) % 7) |
|
467 | - $nRows++; |
|
482 | + if (($month_info['last_day']['day_of_month'] + $nShift) % 7) { |
|
483 | + $nRows++; |
|
484 | + } |
|
468 | 485 | |
469 | 486 | // Fetch the arrays for birthdays, posted events, and holidays. |
470 | 487 | $bday = $calendarOptions['show_birthdays'] ? getBirthdayRange($month_info['first_day']['date'], $month_info['last_day']['date']) : array(); |
@@ -477,8 +494,9 @@ discard block |
||
477 | 494 | { |
478 | 495 | $calendarGrid['week_days'][] = $count; |
479 | 496 | $count++; |
480 | - if ($count == 7) |
|
481 | - $count = 0; |
|
497 | + if ($count == 7) { |
|
498 | + $count = 0; |
|
499 | + } |
|
482 | 500 | } |
483 | 501 | |
484 | 502 | // Iterate through each week. |
@@ -495,8 +513,9 @@ discard block |
||
495 | 513 | { |
496 | 514 | $nDay = ($nRow * 7) + $nCol - $nShift + 1; |
497 | 515 | |
498 | - if ($nDay < 1 || $nDay > $month_info['last_day']['day_of_month']) |
|
499 | - $nDay = 0; |
|
516 | + if ($nDay < 1 || $nDay > $month_info['last_day']['day_of_month']) { |
|
517 | + $nDay = 0; |
|
518 | + } |
|
500 | 519 | |
501 | 520 | $date = sprintf('%04d-%02d-%02d', $year, $month, $nDay); |
502 | 521 | |
@@ -514,8 +533,9 @@ discard block |
||
514 | 533 | } |
515 | 534 | |
516 | 535 | // What is the last day of the month? |
517 | - if ($is_previous === true) |
|
518 | - $calendarGrid['last_of_month'] = $month_info['last_day']['day_of_month']; |
|
536 | + if ($is_previous === true) { |
|
537 | + $calendarGrid['last_of_month'] = $month_info['last_day']['day_of_month']; |
|
538 | + } |
|
519 | 539 | |
520 | 540 | // We'll use the shift in the template. |
521 | 541 | $calendarGrid['shift'] = $nShift; |
@@ -549,8 +569,9 @@ discard block |
||
549 | 569 | { |
550 | 570 | // Here we offset accordingly to get things to the real start of a week. |
551 | 571 | $date_diff = $day_of_week - $calendarOptions['start_day']; |
552 | - if ($date_diff < 0) |
|
553 | - $date_diff += 7; |
|
572 | + if ($date_diff < 0) { |
|
573 | + $date_diff += 7; |
|
574 | + } |
|
554 | 575 | $new_timestamp = mktime(0, 0, 0, $month, $day, $year) - $date_diff * 86400; |
555 | 576 | $day = (int) strftime('%d', $new_timestamp); |
556 | 577 | $month = (int) strftime('%m', $new_timestamp); |
@@ -680,18 +701,20 @@ discard block |
||
680 | 701 | { |
681 | 702 | foreach ($date_events as $event_key => $event_val) |
682 | 703 | { |
683 | - if (in_array($event_val['id'], $temp)) |
|
684 | - unset($calendarGrid['events'][$date][$event_key]); |
|
685 | - else |
|
686 | - $temp[] = $event_val['id']; |
|
704 | + if (in_array($event_val['id'], $temp)) { |
|
705 | + unset($calendarGrid['events'][$date][$event_key]); |
|
706 | + } else { |
|
707 | + $temp[] = $event_val['id']; |
|
708 | + } |
|
687 | 709 | } |
688 | 710 | } |
689 | 711 | |
690 | 712 | // Give birthdays and holidays a friendly format, without the year |
691 | - if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) |
|
692 | - $date_format = '%b %d'; |
|
693 | - else |
|
694 | - $date_format = str_replace(array('%Y', '%y', '%G', '%g', '%C', '%c', '%D'), array('', '', '', '', '', '%b %d', '%m/%d'), $matches[0]); |
|
713 | + if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) { |
|
714 | + $date_format = '%b %d'; |
|
715 | + } else { |
|
716 | + $date_format = str_replace(array('%Y', '%y', '%G', '%g', '%C', '%c', '%D'), array('', '', '', '', '', '%b %d', '%m/%d'), $matches[0]); |
|
717 | + } |
|
695 | 718 | |
696 | 719 | foreach (array('birthdays', 'holidays') as $type) |
697 | 720 | { |
@@ -790,8 +813,9 @@ discard block |
||
790 | 813 | // Holidays between now and now + days. |
791 | 814 | for ($i = $now; $i < $now + $days_for_index; $i += 86400) |
792 | 815 | { |
793 | - if (isset($cached_data['holidays'][strftime('%Y-%m-%d', $i)])) |
|
794 | - $return_data['calendar_holidays'] = array_merge($return_data['calendar_holidays'], $cached_data['holidays'][strftime('%Y-%m-%d', $i)]); |
|
816 | + if (isset($cached_data['holidays'][strftime('%Y-%m-%d', $i)])) { |
|
817 | + $return_data['calendar_holidays'] = array_merge($return_data['calendar_holidays'], $cached_data['holidays'][strftime('%Y-%m-%d', $i)]); |
|
818 | + } |
|
795 | 819 | } |
796 | 820 | } |
797 | 821 | |
@@ -803,8 +827,9 @@ discard block |
||
803 | 827 | $loop_date = strftime('%Y-%m-%d', $i); |
804 | 828 | if (isset($cached_data['birthdays'][$loop_date])) |
805 | 829 | { |
806 | - foreach ($cached_data['birthdays'][$loop_date] as $index => $dummy) |
|
807 | - $cached_data['birthdays'][strftime('%Y-%m-%d', $i)][$index]['is_today'] = $loop_date === $today['date']; |
|
830 | + foreach ($cached_data['birthdays'][$loop_date] as $index => $dummy) { |
|
831 | + $cached_data['birthdays'][strftime('%Y-%m-%d', $i)][$index]['is_today'] = $loop_date === $today['date']; |
|
832 | + } |
|
808 | 833 | $return_data['calendar_birthdays'] = array_merge($return_data['calendar_birthdays'], $cached_data['birthdays'][$loop_date]); |
809 | 834 | } |
810 | 835 | } |
@@ -819,8 +844,9 @@ discard block |
||
819 | 844 | $loop_date = strftime('%Y-%m-%d', $i); |
820 | 845 | |
821 | 846 | // No events today? Check the next day. |
822 | - if (empty($cached_data['events'][$loop_date])) |
|
823 | - continue; |
|
847 | + if (empty($cached_data['events'][$loop_date])) { |
|
848 | + continue; |
|
849 | + } |
|
824 | 850 | |
825 | 851 | // Loop through all events to add a few last-minute values. |
826 | 852 | foreach ($cached_data['events'][$loop_date] as $ev => $event) |
@@ -833,9 +859,9 @@ discard block |
||
833 | 859 | { |
834 | 860 | unset($cached_data['events'][$loop_date][$ev]); |
835 | 861 | continue; |
862 | + } else { |
|
863 | + $duplicates[$this_event['topic'] . $this_event['title']] = true; |
|
836 | 864 | } |
837 | - else |
|
838 | - $duplicates[$this_event['topic'] . $this_event['title']] = true; |
|
839 | 865 | |
840 | 866 | // Might be set to true afterwards, depending on the permissions. |
841 | 867 | $this_event['can_edit'] = false; |
@@ -843,16 +869,19 @@ discard block |
||
843 | 869 | $this_event['date'] = $loop_date; |
844 | 870 | } |
845 | 871 | |
846 | - if (!empty($cached_data['events'][$loop_date])) |
|
847 | - $return_data['calendar_events'] = array_merge($return_data['calendar_events'], $cached_data['events'][$loop_date]); |
|
872 | + if (!empty($cached_data['events'][$loop_date])) { |
|
873 | + $return_data['calendar_events'] = array_merge($return_data['calendar_events'], $cached_data['events'][$loop_date]); |
|
874 | + } |
|
848 | 875 | } |
849 | 876 | } |
850 | 877 | |
851 | 878 | // Mark the last item so that a list separator can be used in the template. |
852 | - for ($i = 0, $n = count($return_data['calendar_birthdays']); $i < $n; $i++) |
|
853 | - $return_data['calendar_birthdays'][$i]['is_last'] = !isset($return_data['calendar_birthdays'][$i + 1]); |
|
854 | - for ($i = 0, $n = count($return_data['calendar_events']); $i < $n; $i++) |
|
855 | - $return_data['calendar_events'][$i]['is_last'] = !isset($return_data['calendar_events'][$i + 1]); |
|
879 | + for ($i = 0, $n = count($return_data['calendar_birthdays']); $i < $n; $i++) { |
|
880 | + $return_data['calendar_birthdays'][$i]['is_last'] = !isset($return_data['calendar_birthdays'][$i + 1]); |
|
881 | + } |
|
882 | + for ($i = 0, $n = count($return_data['calendar_events']); $i < $n; $i++) { |
|
883 | + $return_data['calendar_events'][$i]['is_last'] = !isset($return_data['calendar_events'][$i + 1]); |
|
884 | + } |
|
856 | 885 | |
857 | 886 | return array( |
858 | 887 | 'data' => $return_data, |
@@ -900,37 +929,46 @@ discard block |
||
900 | 929 | if (isset($_POST['start_date'])) |
901 | 930 | { |
902 | 931 | $d = date_parse($_POST['start_date']); |
903 | - if (!empty($d['error_count']) || !empty($d['warning_count'])) |
|
904 | - fatal_lang_error('invalid_date', false); |
|
905 | - if (empty($d['year'])) |
|
906 | - fatal_lang_error('event_year_missing', false); |
|
907 | - if (empty($d['month'])) |
|
908 | - fatal_lang_error('event_month_missing', false); |
|
909 | - } |
|
910 | - elseif (isset($_POST['start_datetime'])) |
|
932 | + if (!empty($d['error_count']) || !empty($d['warning_count'])) { |
|
933 | + fatal_lang_error('invalid_date', false); |
|
934 | + } |
|
935 | + if (empty($d['year'])) { |
|
936 | + fatal_lang_error('event_year_missing', false); |
|
937 | + } |
|
938 | + if (empty($d['month'])) { |
|
939 | + fatal_lang_error('event_month_missing', false); |
|
940 | + } |
|
941 | + } elseif (isset($_POST['start_datetime'])) |
|
911 | 942 | { |
912 | 943 | $d = date_parse($_POST['start_datetime']); |
913 | - if (!empty($d['error_count']) || !empty($d['warning_count'])) |
|
914 | - fatal_lang_error('invalid_date', false); |
|
915 | - if (empty($d['year'])) |
|
916 | - fatal_lang_error('event_year_missing', false); |
|
917 | - if (empty($d['month'])) |
|
918 | - fatal_lang_error('event_month_missing', false); |
|
944 | + if (!empty($d['error_count']) || !empty($d['warning_count'])) { |
|
945 | + fatal_lang_error('invalid_date', false); |
|
946 | + } |
|
947 | + if (empty($d['year'])) { |
|
948 | + fatal_lang_error('event_year_missing', false); |
|
949 | + } |
|
950 | + if (empty($d['month'])) { |
|
951 | + fatal_lang_error('event_month_missing', false); |
|
952 | + } |
|
919 | 953 | } |
920 | 954 | // The 2.0 way |
921 | 955 | else |
922 | 956 | { |
923 | 957 | // No month? No year? |
924 | - if (!isset($_POST['month'])) |
|
925 | - fatal_lang_error('event_month_missing', false); |
|
926 | - if (!isset($_POST['year'])) |
|
927 | - fatal_lang_error('event_year_missing', false); |
|
958 | + if (!isset($_POST['month'])) { |
|
959 | + fatal_lang_error('event_month_missing', false); |
|
960 | + } |
|
961 | + if (!isset($_POST['year'])) { |
|
962 | + fatal_lang_error('event_year_missing', false); |
|
963 | + } |
|
928 | 964 | |
929 | 965 | // Check the month and year... |
930 | - if ($_POST['month'] < 1 || $_POST['month'] > 12) |
|
931 | - fatal_lang_error('invalid_month', false); |
|
932 | - if ($_POST['year'] < $modSettings['cal_minyear'] || $_POST['year'] > $modSettings['cal_maxyear']) |
|
933 | - fatal_lang_error('invalid_year', false); |
|
966 | + if ($_POST['month'] < 1 || $_POST['month'] > 12) { |
|
967 | + fatal_lang_error('invalid_month', false); |
|
968 | + } |
|
969 | + if ($_POST['year'] < $modSettings['cal_minyear'] || $_POST['year'] > $modSettings['cal_maxyear']) { |
|
970 | + fatal_lang_error('invalid_year', false); |
|
971 | + } |
|
934 | 972 | } |
935 | 973 | } |
936 | 974 | |
@@ -940,8 +978,9 @@ discard block |
||
940 | 978 | // If they want to us to calculate an end date, make sure it will fit in an acceptable range. |
941 | 979 | if (isset($_POST['span'])) |
942 | 980 | { |
943 | - if (($_POST['span'] < 1) || (!empty($modSettings['cal_maxspan']) && $_POST['span'] > $modSettings['cal_maxspan'])) |
|
944 | - fatal_lang_error('invalid_days_numb', false); |
|
981 | + if (($_POST['span'] < 1) || (!empty($modSettings['cal_maxspan']) && $_POST['span'] > $modSettings['cal_maxspan'])) { |
|
982 | + fatal_lang_error('invalid_days_numb', false); |
|
983 | + } |
|
945 | 984 | } |
946 | 985 | |
947 | 986 | // There is no need to validate the following values if we are just deleting the event. |
@@ -951,24 +990,29 @@ discard block |
||
951 | 990 | if (empty($_POST['start_date']) && empty($_POST['start_datetime'])) |
952 | 991 | { |
953 | 992 | // No day? |
954 | - if (!isset($_POST['day'])) |
|
955 | - fatal_lang_error('event_day_missing', false); |
|
993 | + if (!isset($_POST['day'])) { |
|
994 | + fatal_lang_error('event_day_missing', false); |
|
995 | + } |
|
956 | 996 | |
957 | 997 | // Bad day? |
958 | - if (!checkdate($_POST['month'], $_POST['day'], $_POST['year'])) |
|
959 | - fatal_lang_error('invalid_date', false); |
|
998 | + if (!checkdate($_POST['month'], $_POST['day'], $_POST['year'])) { |
|
999 | + fatal_lang_error('invalid_date', false); |
|
1000 | + } |
|
960 | 1001 | } |
961 | 1002 | |
962 | - if (!isset($_POST['evtitle']) && !isset($_POST['subject'])) |
|
963 | - fatal_lang_error('event_title_missing', false); |
|
964 | - elseif (!isset($_POST['evtitle'])) |
|
965 | - $_POST['evtitle'] = $_POST['subject']; |
|
1003 | + if (!isset($_POST['evtitle']) && !isset($_POST['subject'])) { |
|
1004 | + fatal_lang_error('event_title_missing', false); |
|
1005 | + } elseif (!isset($_POST['evtitle'])) { |
|
1006 | + $_POST['evtitle'] = $_POST['subject']; |
|
1007 | + } |
|
966 | 1008 | |
967 | 1009 | // No title? |
968 | - if ($smcFunc['htmltrim']($_POST['evtitle']) === '') |
|
969 | - fatal_lang_error('no_event_title', false); |
|
970 | - if ($smcFunc['strlen']($_POST['evtitle']) > 100) |
|
971 | - $_POST['evtitle'] = $smcFunc['substr']($_POST['evtitle'], 0, 100); |
|
1010 | + if ($smcFunc['htmltrim']($_POST['evtitle']) === '') { |
|
1011 | + fatal_lang_error('no_event_title', false); |
|
1012 | + } |
|
1013 | + if ($smcFunc['strlen']($_POST['evtitle']) > 100) { |
|
1014 | + $_POST['evtitle'] = $smcFunc['substr']($_POST['evtitle'], 0, 100); |
|
1015 | + } |
|
972 | 1016 | $_POST['evtitle'] = str_replace(';', '', $_POST['evtitle']); |
973 | 1017 | } |
974 | 1018 | } |
@@ -995,8 +1039,9 @@ discard block |
||
995 | 1039 | ); |
996 | 1040 | |
997 | 1041 | // No results, return false. |
998 | - if ($smcFunc['db_num_rows'] === 0) |
|
999 | - return false; |
|
1042 | + if ($smcFunc['db_num_rows'] === 0) { |
|
1043 | + return false; |
|
1044 | + } |
|
1000 | 1045 | |
1001 | 1046 | // Grab the results and return. |
1002 | 1047 | list ($poster) = $smcFunc['db_fetch_row']($request); |
@@ -1130,8 +1175,9 @@ discard block |
||
1130 | 1175 | call_integration_hook('integrate_modify_event', array($event_id, &$eventOptions, &$event_columns, &$event_parameters)); |
1131 | 1176 | |
1132 | 1177 | $column_clauses = array(); |
1133 | - foreach ($event_columns as $col => $crit) |
|
1134 | - $column_clauses[] = $col . ' = ' . $crit; |
|
1178 | + foreach ($event_columns as $col => $crit) { |
|
1179 | + $column_clauses[] = $col . ' = ' . $crit; |
|
1180 | + } |
|
1135 | 1181 | |
1136 | 1182 | $smcFunc['db_query']('', ' |
1137 | 1183 | UPDATE {db_prefix}calendar |
@@ -1216,8 +1262,9 @@ discard block |
||
1216 | 1262 | ); |
1217 | 1263 | |
1218 | 1264 | // If nothing returned, we are in poo, poo. |
1219 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
1220 | - return false; |
|
1265 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
1266 | + return false; |
|
1267 | + } |
|
1221 | 1268 | |
1222 | 1269 | $row = $smcFunc['db_fetch_assoc']($request); |
1223 | 1270 | $smcFunc['db_free_result']($request); |
@@ -1225,8 +1272,9 @@ discard block |
||
1225 | 1272 | list($start, $end, $allday, $span, $tz, $tz_abbrev) = buildEventDatetimes($row); |
1226 | 1273 | |
1227 | 1274 | // Sanity check |
1228 | - if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count'])) |
|
1229 | - return false; |
|
1275 | + if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count'])) { |
|
1276 | + return false; |
|
1277 | + } |
|
1230 | 1278 | |
1231 | 1279 | $return_value = array( |
1232 | 1280 | 'boards' => array(), |
@@ -1363,24 +1411,27 @@ discard block |
||
1363 | 1411 | |
1364 | 1412 | // Set $span, in case we need it |
1365 | 1413 | $span = isset($eventOptions['span']) ? $eventOptions['span'] : (isset($_POST['span']) ? $_POST['span'] : 0); |
1366 | - if ($span > 0) |
|
1367 | - $span = !empty($modSettings['cal_maxspan']) ? min($modSettings['cal_maxspan'], $span - 1) : $span - 1; |
|
1414 | + if ($span > 0) { |
|
1415 | + $span = !empty($modSettings['cal_maxspan']) ? min($modSettings['cal_maxspan'], $span - 1) : $span - 1; |
|
1416 | + } |
|
1368 | 1417 | |
1369 | 1418 | // Define the timezone for this event, falling back to the default if not provided |
1370 | - if (!empty($eventOptions['tz']) && in_array($eventOptions['tz'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) |
|
1371 | - $tz = $eventOptions['tz']; |
|
1372 | - elseif (!empty($_POST['tz']) && in_array($_POST['tz'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) |
|
1373 | - $tz = $_POST['tz']; |
|
1374 | - else |
|
1375 | - $tz = getUserTimezone(); |
|
1419 | + if (!empty($eventOptions['tz']) && in_array($eventOptions['tz'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) { |
|
1420 | + $tz = $eventOptions['tz']; |
|
1421 | + } elseif (!empty($_POST['tz']) && in_array($_POST['tz'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) { |
|
1422 | + $tz = $_POST['tz']; |
|
1423 | + } else { |
|
1424 | + $tz = getUserTimezone(); |
|
1425 | + } |
|
1376 | 1426 | |
1377 | 1427 | // Is this supposed to be an all day event, or should it have specific start and end times? |
1378 | - if (isset($eventOptions['allday'])) |
|
1379 | - $allday = $eventOptions['allday']; |
|
1380 | - elseif (empty($_POST['allday'])) |
|
1381 | - $allday = false; |
|
1382 | - else |
|
1383 | - $allday = true; |
|
1428 | + if (isset($eventOptions['allday'])) { |
|
1429 | + $allday = $eventOptions['allday']; |
|
1430 | + } elseif (empty($_POST['allday'])) { |
|
1431 | + $allday = false; |
|
1432 | + } else { |
|
1433 | + $allday = true; |
|
1434 | + } |
|
1384 | 1435 | |
1385 | 1436 | // Input might come as individual parameters... |
1386 | 1437 | $start_year = isset($eventOptions['year']) ? $eventOptions['year'] : (isset($_POST['year']) ? $_POST['year'] : null); |
@@ -1407,10 +1458,12 @@ discard block |
||
1407 | 1458 | $end_time_string = isset($eventOptions['end_time']) ? $eventOptions['end_time'] : (isset($_POST['end_time']) ? $_POST['end_time'] : null); |
1408 | 1459 | |
1409 | 1460 | // If the date and time were given in separate strings, combine them |
1410 | - if (empty($start_string) && isset($start_date_string)) |
|
1411 | - $start_string = $start_date_string . (isset($start_time_string) ? ' ' . $start_time_string : ''); |
|
1412 | - if (empty($end_string) && isset($end_date_string)) |
|
1413 | - $end_string = $end_date_string . (isset($end_time_string) ? ' ' . $end_time_string : ''); |
|
1461 | + if (empty($start_string) && isset($start_date_string)) { |
|
1462 | + $start_string = $start_date_string . (isset($start_time_string) ? ' ' . $start_time_string : ''); |
|
1463 | + } |
|
1464 | + if (empty($end_string) && isset($end_date_string)) { |
|
1465 | + $end_string = $end_date_string . (isset($end_time_string) ? ' ' . $end_time_string : ''); |
|
1466 | + } |
|
1414 | 1467 | |
1415 | 1468 | // If some form of string input was given, override individually defined options with it |
1416 | 1469 | if (isset($start_string)) |
@@ -1501,10 +1554,11 @@ discard block |
||
1501 | 1554 | if ($start_object >= $end_object) |
1502 | 1555 | { |
1503 | 1556 | $end_object = date_create(sprintf('%04d-%02d-%02d %02d:%02d:%02d', $start_year, $start_month, $start_day, $start_hour, $start_minute, $start_second) . ' ' . $tz); |
1504 | - if ($span > 0) |
|
1505 | - date_add($end_object, date_interval_create_from_date_string($span . ' days')); |
|
1506 | - else |
|
1507 | - date_add($end_object, date_interval_create_from_date_string('1 hour')); |
|
1557 | + if ($span > 0) { |
|
1558 | + date_add($end_object, date_interval_create_from_date_string($span . ' days')); |
|
1559 | + } else { |
|
1560 | + date_add($end_object, date_interval_create_from_date_string('1 hour')); |
|
1561 | + } |
|
1508 | 1562 | } |
1509 | 1563 | |
1510 | 1564 | // Is $end_object too late? |
@@ -1517,9 +1571,9 @@ discard block |
||
1517 | 1571 | { |
1518 | 1572 | $end_object = date_create(sprintf('%04d-%02d-%02d %02d:%02d:%02d', $start_year, $start_month, $start_day, $start_hour, $start_minute, $start_second) . ' ' . $tz); |
1519 | 1573 | date_add($end_object, date_interval_create_from_date_string($modSettings['cal_maxspan'] . ' days')); |
1574 | + } else { |
|
1575 | + $end_object = date_create(sprintf('%04d-%02d-%02d %02d:%02d:%02d', $start_year, $start_month, $start_day, '11', '59', '59') . ' ' . $tz); |
|
1520 | 1576 | } |
1521 | - else |
|
1522 | - $end_object = date_create(sprintf('%04d-%02d-%02d %02d:%02d:%02d', $start_year, $start_month, $start_day, '11', '59', '59') . ' ' . $tz); |
|
1523 | 1577 | } |
1524 | 1578 | } |
1525 | 1579 | |
@@ -1532,8 +1586,7 @@ discard block |
||
1532 | 1586 | $start_time = null; |
1533 | 1587 | $end_time = null; |
1534 | 1588 | $tz = null; |
1535 | - } |
|
1536 | - else |
|
1589 | + } else |
|
1537 | 1590 | { |
1538 | 1591 | $start_time = date_format($start_object, 'H:i:s'); |
1539 | 1592 | $end_time = date_format($end_object, 'H:i:s'); |
@@ -1561,19 +1614,21 @@ discard block |
||
1561 | 1614 | // First, try to create a better date format, ignoring the "time" elements. |
1562 | 1615 | if (empty($date_format)) |
1563 | 1616 | { |
1564 | - if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) |
|
1565 | - $date_format = '%F'; |
|
1566 | - else |
|
1567 | - $date_format = $matches[0]; |
|
1617 | + if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) { |
|
1618 | + $date_format = '%F'; |
|
1619 | + } else { |
|
1620 | + $date_format = $matches[0]; |
|
1621 | + } |
|
1568 | 1622 | } |
1569 | 1623 | |
1570 | 1624 | // We want a fairly compact version of the time, but as close as possible to the user's settings. |
1571 | 1625 | if (empty($time_format)) |
1572 | 1626 | { |
1573 | - if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) |
|
1574 | - $time_format = '%k:%M'; |
|
1575 | - else |
|
1576 | - $time_format = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]); |
|
1627 | + if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) { |
|
1628 | + $time_format = '%k:%M'; |
|
1629 | + } else { |
|
1630 | + $time_format = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]); |
|
1631 | + } |
|
1577 | 1632 | } |
1578 | 1633 | |
1579 | 1634 | // Should this be an all day event? |
@@ -1583,11 +1638,13 @@ discard block |
||
1583 | 1638 | $span = 1 + date_interval_format(date_diff(date_create($row['start_date']), date_create($row['end_date'])), '%d'); |
1584 | 1639 | |
1585 | 1640 | // We need to have a defined timezone in the steps below |
1586 | - if (empty($row['timezone'])) |
|
1587 | - $row['timezone'] = getUserTimezone(); |
|
1641 | + if (empty($row['timezone'])) { |
|
1642 | + $row['timezone'] = getUserTimezone(); |
|
1643 | + } |
|
1588 | 1644 | |
1589 | - if (empty($timezone_array[$row['timezone']])) |
|
1590 | - $timezone_array[$row['timezone']] = timezone_open($row['timezone']); |
|
1645 | + if (empty($timezone_array[$row['timezone']])) { |
|
1646 | + $timezone_array[$row['timezone']] = timezone_open($row['timezone']); |
|
1647 | + } |
|
1591 | 1648 | |
1592 | 1649 | // Get most of the standard date information for the start and end datetimes |
1593 | 1650 | $start = date_parse($row['start_date'] . (!$allday ? ' ' . $row['start_time'] : '')); |
@@ -1622,8 +1679,9 @@ discard block |
||
1622 | 1679 | $tz_abbrev = date_format($start_object, 'T'); |
1623 | 1680 | |
1624 | 1681 | // If the abbreviation is just a numerical offset from UTC, make that clear. |
1625 | - if (strspn($tz_abbrev, '+-') > 0) |
|
1626 | - $tz_abbrev = 'UTC' . $tz_abbrev; |
|
1682 | + if (strspn($tz_abbrev, '+-') > 0) { |
|
1683 | + $tz_abbrev = 'UTC' . $tz_abbrev; |
|
1684 | + } |
|
1627 | 1685 | |
1628 | 1686 | return array($start, $end, $allday, $span, $tz, $tz_abbrev); |
1629 | 1687 | } |
@@ -1639,8 +1697,9 @@ discard block |
||
1639 | 1697 | global $smcFunc, $context, $user_info, $modSettings, $user_settings; |
1640 | 1698 | static $member_cache = array(); |
1641 | 1699 | |
1642 | - if (is_null($id_member) && $user_info['is_guest'] == false) |
|
1643 | - $id_member = $context['user']['id']; |
|
1700 | + if (is_null($id_member) && $user_info['is_guest'] == false) { |
|
1701 | + $id_member = $context['user']['id']; |
|
1702 | + } |
|
1644 | 1703 | |
1645 | 1704 | //check if the cache got the data |
1646 | 1705 | if (isset($id_member) && isset($member_cache[$id_member])) |
@@ -1669,11 +1728,13 @@ discard block |
||
1669 | 1728 | $smcFunc['db_free_result']($request); |
1670 | 1729 | } |
1671 | 1730 | |
1672 | - if (empty($timezone) || !in_array($timezone, timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) |
|
1673 | - $timezone = isset($modSettings['default_timezone']) ? $modSettings['default_timezone'] : date_default_timezone_get(); |
|
1731 | + if (empty($timezone) || !in_array($timezone, timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) { |
|
1732 | + $timezone = isset($modSettings['default_timezone']) ? $modSettings['default_timezone'] : date_default_timezone_get(); |
|
1733 | + } |
|
1674 | 1734 | |
1675 | - if (isset($id_member)) |
|
1676 | - $member_cache[$id_member] = $timezone; |
|
1735 | + if (isset($id_member)) { |
|
1736 | + $member_cache[$id_member] = $timezone; |
|
1737 | + } |
|
1677 | 1738 | |
1678 | 1739 | return $timezone; |
1679 | 1740 | } |
@@ -1702,8 +1763,9 @@ discard block |
||
1702 | 1763 | ) |
1703 | 1764 | ); |
1704 | 1765 | $holidays = array(); |
1705 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1706 | - $holidays[] = $row; |
|
1766 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1767 | + $holidays[] = $row; |
|
1768 | + } |
|
1707 | 1769 | $smcFunc['db_free_result']($request); |
1708 | 1770 | |
1709 | 1771 | return $holidays; |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | /** |
34 | 34 | * @var array Which databases support this method? |
35 | 35 | */ |
36 | - protected $supported_databases = array('mysql','postgresql'); |
|
36 | + protected $supported_databases = array('mysql', 'postgresql'); |
|
37 | 37 | |
38 | 38 | /** |
39 | 39 | * The constructor function |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | $query_where = array(); |
177 | 177 | $query_params = $search_data['params']; |
178 | 178 | |
179 | - if( $smcFunc['db_title'] == "PostgreSQL") |
|
179 | + if ($smcFunc['db_title'] == "PostgreSQL") |
|
180 | 180 | $modSettings['search_simple_fulltext'] = true; |
181 | 181 | |
182 | 182 | if ($query_params['id_search']) |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | // if we have bool terms to search, add them in |
257 | 257 | if ($query_params['boolean_match']) |
258 | 258 | { |
259 | - if($smcFunc['db_title'] == "PostgreSQL") |
|
259 | + if ($smcFunc['db_title'] == "PostgreSQL") |
|
260 | 260 | { |
261 | 261 | $language_ftx = $smcFunc['db_search_language'](); |
262 | 262 | |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | } |
269 | 269 | } |
270 | 270 | |
271 | - $ignoreRequest = $smcFunc['db_search_query']('insert_into_log_messages_fulltext', ($smcFunc['db_support_ignore'] ? ( ' |
|
271 | + $ignoreRequest = $smcFunc['db_search_query']('insert_into_log_messages_fulltext', ($smcFunc['db_support_ignore'] ? (' |
|
272 | 272 | INSERT IGNORE INTO {db_prefix}' . $search_data['insert_into'] . ' |
273 | 273 | (' . implode(', ', array_keys($query_select)) . ')') : '') . ' |
274 | 274 | SELECT ' . implode(', ', $query_select) . ' |
@@ -11,8 +11,9 @@ discard block |
||
11 | 11 | * @version 2.1 Beta 4 |
12 | 12 | */ |
13 | 13 | |
14 | -if (!defined('SMF')) |
|
14 | +if (!defined('SMF')) { |
|
15 | 15 | die('No direct access...'); |
16 | +} |
|
16 | 17 | |
17 | 18 | /** |
18 | 19 | * Class fulltext_search |
@@ -75,8 +76,9 @@ discard block |
||
75 | 76 | } |
76 | 77 | |
77 | 78 | // Maybe parent got support |
78 | - if (!$return) |
|
79 | - $return = parent::supportsMethod($methodName, $query_params); |
|
79 | + if (!$return) { |
|
80 | + $return = parent::supportsMethod($methodName, $query_params); |
|
81 | + } |
|
80 | 82 | |
81 | 83 | return $return; |
82 | 84 | } |
@@ -92,8 +94,9 @@ discard block |
||
92 | 94 | { |
93 | 95 | global $smcFunc, $db_type; |
94 | 96 | |
95 | - if ($db_type == 'postgresql') |
|
96 | - return 0; |
|
97 | + if ($db_type == 'postgresql') { |
|
98 | + return 0; |
|
99 | + } |
|
97 | 100 | // Try to determine the minimum number of letters for a fulltext search. |
98 | 101 | $request = $smcFunc['db_search_query']('max_fulltext_length', ' |
99 | 102 | SHOW VARIABLES |
@@ -108,8 +111,9 @@ discard block |
||
108 | 111 | $smcFunc['db_free_result']($request); |
109 | 112 | } |
110 | 113 | // 4 is the MySQL default... |
111 | - else |
|
112 | - $min_word_length = 4; |
|
114 | + else { |
|
115 | + $min_word_length = 4; |
|
116 | + } |
|
113 | 117 | |
114 | 118 | return $min_word_length; |
115 | 119 | } |
@@ -148,8 +152,7 @@ discard block |
||
148 | 152 | $wordsSearch['words'][] = trim($word, "/*- "); |
149 | 153 | $wordsSearch['complex_words'][] = count($subwords) === 1 ? $word : '"' . $word . '"'; |
150 | 154 | } |
151 | - } |
|
152 | - elseif ($smcFunc['strlen'](trim($word, "/*- ")) < $this->min_word_length) |
|
155 | + } elseif ($smcFunc['strlen'](trim($word, "/*- ")) < $this->min_word_length) |
|
153 | 156 | { |
154 | 157 | // short words have feelings too |
155 | 158 | $wordsSearch['words'][] = trim($word, "/*- "); |
@@ -159,8 +162,9 @@ discard block |
||
159 | 162 | |
160 | 163 | $fulltextWord = count($subwords) === 1 ? $word : '"' . $word . '"'; |
161 | 164 | $wordsSearch['indexed_words'][] = $fulltextWord; |
162 | - if ($isExcluded) |
|
163 | - $wordsExclude[] = $fulltextWord; |
|
165 | + if ($isExcluded) { |
|
166 | + $wordsExclude[] = $fulltextWord; |
|
167 | + } |
|
164 | 168 | } |
165 | 169 | |
166 | 170 | /** |
@@ -176,44 +180,54 @@ discard block |
||
176 | 180 | $query_where = array(); |
177 | 181 | $query_params = $search_data['params']; |
178 | 182 | |
179 | - if( $smcFunc['db_title'] == "PostgreSQL") |
|
180 | - $modSettings['search_simple_fulltext'] = true; |
|
183 | + if( $smcFunc['db_title'] == "PostgreSQL") { |
|
184 | + $modSettings['search_simple_fulltext'] = true; |
|
185 | + } |
|
181 | 186 | |
182 | - if ($query_params['id_search']) |
|
183 | - $query_select['id_search'] = '{int:id_search}'; |
|
187 | + if ($query_params['id_search']) { |
|
188 | + $query_select['id_search'] = '{int:id_search}'; |
|
189 | + } |
|
184 | 190 | |
185 | 191 | $count = 0; |
186 | - if (empty($modSettings['search_simple_fulltext'])) |
|
187 | - foreach ($words['words'] as $regularWord) |
|
192 | + if (empty($modSettings['search_simple_fulltext'])) { |
|
193 | + foreach ($words['words'] as $regularWord) |
|
188 | 194 | { |
189 | 195 | $query_where[] = 'm.body' . (in_array($regularWord, $query_params['excluded_words']) ? ' NOT' : '') . (empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? ' LIKE ' : 'RLIKE') . '{string:complex_body_' . $count . '}'; |
196 | + } |
|
190 | 197 | $query_params['complex_body_' . $count++] = empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? '%' . strtr($regularWord, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $regularWord), '\\\'') . '[[:>:]]'; |
191 | 198 | } |
192 | 199 | |
193 | - if ($query_params['user_query']) |
|
194 | - $query_where[] = '{raw:user_query}'; |
|
195 | - if ($query_params['board_query']) |
|
196 | - $query_where[] = 'm.id_board {raw:board_query}'; |
|
200 | + if ($query_params['user_query']) { |
|
201 | + $query_where[] = '{raw:user_query}'; |
|
202 | + } |
|
203 | + if ($query_params['board_query']) { |
|
204 | + $query_where[] = 'm.id_board {raw:board_query}'; |
|
205 | + } |
|
197 | 206 | |
198 | - if ($query_params['topic']) |
|
199 | - $query_where[] = 'm.id_topic = {int:topic}'; |
|
200 | - if ($query_params['min_msg_id']) |
|
201 | - $query_where[] = 'm.id_msg >= {int:min_msg_id}'; |
|
202 | - if ($query_params['max_msg_id']) |
|
203 | - $query_where[] = 'm.id_msg <= {int:max_msg_id}'; |
|
207 | + if ($query_params['topic']) { |
|
208 | + $query_where[] = 'm.id_topic = {int:topic}'; |
|
209 | + } |
|
210 | + if ($query_params['min_msg_id']) { |
|
211 | + $query_where[] = 'm.id_msg >= {int:min_msg_id}'; |
|
212 | + } |
|
213 | + if ($query_params['max_msg_id']) { |
|
214 | + $query_where[] = 'm.id_msg <= {int:max_msg_id}'; |
|
215 | + } |
|
204 | 216 | |
205 | 217 | $count = 0; |
206 | - if (!empty($query_params['excluded_phrases']) && empty($modSettings['search_force_index'])) |
|
207 | - foreach ($query_params['excluded_phrases'] as $phrase) |
|
218 | + if (!empty($query_params['excluded_phrases']) && empty($modSettings['search_force_index'])) { |
|
219 | + foreach ($query_params['excluded_phrases'] as $phrase) |
|
208 | 220 | { |
209 | 221 | $query_where[] = 'subject NOT ' . (empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? ' LIKE ' : 'RLIKE') . '{string:exclude_subject_phrase_' . $count . '}'; |
222 | + } |
|
210 | 223 | $query_params['exclude_subject_phrase_' . $count++] = empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? '%' . strtr($phrase, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $phrase), '\\\'') . '[[:>:]]'; |
211 | 224 | } |
212 | 225 | $count = 0; |
213 | - if (!empty($query_params['excluded_subject_words']) && empty($modSettings['search_force_index'])) |
|
214 | - foreach ($query_params['excluded_subject_words'] as $excludedWord) |
|
226 | + if (!empty($query_params['excluded_subject_words']) && empty($modSettings['search_force_index'])) { |
|
227 | + foreach ($query_params['excluded_subject_words'] as $excludedWord) |
|
215 | 228 | { |
216 | 229 | $query_where[] = 'subject NOT ' . (empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? ' LIKE ' : 'RLIKE') . '{string:exclude_subject_words_' . $count . '}'; |
230 | + } |
|
217 | 231 | $query_params['exclude_subject_words_' . $count++] = empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? '%' . strtr($excludedWord, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $excludedWord), '\\\'') . '[[:>:]]'; |
218 | 232 | } |
219 | 233 | |
@@ -225,12 +239,11 @@ discard block |
||
225 | 239 | |
226 | 240 | $query_where[] = 'to_tsvector({string:language_ftx},body) @@ plainto_tsquery({string:language_ftx},{string:body_match})'; |
227 | 241 | $query_params['language_ftx'] = $language_ftx; |
242 | + } else { |
|
243 | + $query_where[] = 'MATCH (body) AGAINST ({string:body_match})'; |
|
228 | 244 | } |
229 | - else |
|
230 | - $query_where[] = 'MATCH (body) AGAINST ({string:body_match})'; |
|
231 | 245 | $query_params['body_match'] = implode(' ', array_diff($words['indexed_words'], $query_params['excluded_index_words'])); |
232 | - } |
|
233 | - else |
|
246 | + } else |
|
234 | 247 | { |
235 | 248 | $query_params['boolean_match'] = ''; |
236 | 249 | |
@@ -246,10 +259,10 @@ discard block |
||
246 | 259 | $query_params['boolean_match'] .= (in_array($fulltextWord, $query_params['excluded_index_words']) ? '!' : '') . $fulltextWord . ' '; |
247 | 260 | $row++; |
248 | 261 | } |
249 | - } |
|
250 | - else |
|
251 | - foreach ($words['indexed_words'] as $fulltextWord) |
|
262 | + } else { |
|
263 | + foreach ($words['indexed_words'] as $fulltextWord) |
|
252 | 264 | $query_params['boolean_match'] .= (in_array($fulltextWord, $query_params['excluded_index_words']) ? '-' : '+') . $fulltextWord . ' '; |
265 | + } |
|
253 | 266 | |
254 | 267 | $query_params['boolean_match'] = substr($query_params['boolean_match'], 0, -1); |
255 | 268 | |
@@ -262,9 +275,9 @@ discard block |
||
262 | 275 | |
263 | 276 | $query_where[] = 'to_tsvector({string:language_ftx},body) @@ plainto_tsquery({string:language_ftx},{string:boolean_match})'; |
264 | 277 | $query_params['language_ftx'] = $language_ftx; |
278 | + } else { |
|
279 | + $query_where[] = 'MATCH (body) AGAINST ({string:boolean_match} IN BOOLEAN MODE)'; |
|
265 | 280 | } |
266 | - else |
|
267 | - $query_where[] = 'MATCH (body) AGAINST ({string:boolean_match} IN BOOLEAN MODE)'; |
|
268 | 281 | } |
269 | 282 | } |
270 | 283 |
@@ -11,8 +11,9 @@ discard block |
||
11 | 11 | * @version 2.1 Beta 4 |
12 | 12 | */ |
13 | 13 | |
14 | -if (!defined('SMF')) |
|
14 | +if (!defined('SMF')) { |
|
15 | 15 | die('No direct access...'); |
16 | +} |
|
16 | 17 | |
17 | 18 | /** |
18 | 19 | * Standard non full index, non custom index search |
@@ -27,8 +28,9 @@ discard block |
||
27 | 28 | $return = false; |
28 | 29 | |
29 | 30 | // Maybe parent got support |
30 | - if (!$return) |
|
31 | - $return = parent::supportsMethod($methodName, $query_params); |
|
31 | + if (!$return) { |
|
32 | + $return = parent::supportsMethod($methodName, $query_params); |
|
33 | + } |
|
32 | 34 | |
33 | 35 | return $return; |
34 | 36 | } |
@@ -11,8 +11,9 @@ discard block |
||
11 | 11 | * @version 2.1 Beta 4 |
12 | 12 | */ |
13 | 13 | |
14 | -if (!defined('SMF')) |
|
14 | +if (!defined('SMF')) { |
|
15 | 15 | die('No direct access...'); |
16 | +} |
|
16 | 17 | |
17 | 18 | /** |
18 | 19 | * Used for the "custom search index" option |
@@ -54,8 +55,9 @@ discard block |
||
54 | 55 | return; |
55 | 56 | } |
56 | 57 | |
57 | - if (empty($modSettings['search_custom_index_config'])) |
|
58 | - return; |
|
58 | + if (empty($modSettings['search_custom_index_config'])) { |
|
59 | + return; |
|
60 | + } |
|
59 | 61 | |
60 | 62 | $this->indexSettings = $smcFunc['json_decode']($modSettings['search_custom_index_config'], true); |
61 | 63 | |
@@ -86,8 +88,9 @@ discard block |
||
86 | 88 | } |
87 | 89 | |
88 | 90 | // Maybe parent got support |
89 | - if (!$return) |
|
90 | - $return = parent::supportsMethod($methodName, $query_params); |
|
91 | + if (!$return) { |
|
92 | + $return = parent::supportsMethod($methodName, $query_params); |
|
93 | + } |
|
91 | 94 | |
92 | 95 | return $return; |
93 | 96 | } |
@@ -124,21 +127,23 @@ discard block |
||
124 | 127 | |
125 | 128 | $subwords = text2words($word, $this->min_word_length, true); |
126 | 129 | |
127 | - if (empty($modSettings['search_force_index'])) |
|
128 | - $wordsSearch['words'][] = $word; |
|
130 | + if (empty($modSettings['search_force_index'])) { |
|
131 | + $wordsSearch['words'][] = $word; |
|
132 | + } |
|
129 | 133 | |
130 | 134 | // Excluded phrases don't benefit from being split into subwords. |
131 | - if (count($subwords) > 1 && $isExcluded) |
|
132 | - return; |
|
133 | - else |
|
135 | + if (count($subwords) > 1 && $isExcluded) { |
|
136 | + return; |
|
137 | + } else |
|
134 | 138 | { |
135 | 139 | foreach ($subwords as $subword) |
136 | 140 | { |
137 | 141 | if ($smcFunc['strlen']($subword) >= $this->min_word_length && !in_array($subword, $this->bannedWords)) |
138 | 142 | { |
139 | 143 | $wordsSearch['indexed_words'][] = $subword; |
140 | - if ($isExcluded) |
|
141 | - $wordsExclude[] = $subword; |
|
144 | + if ($isExcluded) { |
|
145 | + $wordsExclude[] = $subword; |
|
146 | + } |
|
142 | 147 | } |
143 | 148 | } |
144 | 149 | } |
@@ -159,8 +164,9 @@ discard block |
||
159 | 164 | $query_where = array(); |
160 | 165 | $query_params = $search_data['params']; |
161 | 166 | |
162 | - if ($query_params['id_search']) |
|
163 | - $query_select['id_search'] = '{int:id_search}'; |
|
167 | + if ($query_params['id_search']) { |
|
168 | + $query_select['id_search'] = '{int:id_search}'; |
|
169 | + } |
|
164 | 170 | |
165 | 171 | $count = 0; |
166 | 172 | foreach ($words['words'] as $regularWord) |
@@ -169,30 +175,37 @@ discard block |
||
169 | 175 | $query_params['complex_body_' . $count++] = empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? '%' . strtr($regularWord, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $regularWord), '\\\'') . '[[:>:]]'; |
170 | 176 | } |
171 | 177 | |
172 | - if ($query_params['user_query']) |
|
173 | - $query_where[] = '{raw:user_query}'; |
|
174 | - if ($query_params['board_query']) |
|
175 | - $query_where[] = 'm.id_board {raw:board_query}'; |
|
178 | + if ($query_params['user_query']) { |
|
179 | + $query_where[] = '{raw:user_query}'; |
|
180 | + } |
|
181 | + if ($query_params['board_query']) { |
|
182 | + $query_where[] = 'm.id_board {raw:board_query}'; |
|
183 | + } |
|
176 | 184 | |
177 | - if ($query_params['topic']) |
|
178 | - $query_where[] = 'm.id_topic = {int:topic}'; |
|
179 | - if ($query_params['min_msg_id']) |
|
180 | - $query_where[] = 'm.id_msg >= {int:min_msg_id}'; |
|
181 | - if ($query_params['max_msg_id']) |
|
182 | - $query_where[] = 'm.id_msg <= {int:max_msg_id}'; |
|
185 | + if ($query_params['topic']) { |
|
186 | + $query_where[] = 'm.id_topic = {int:topic}'; |
|
187 | + } |
|
188 | + if ($query_params['min_msg_id']) { |
|
189 | + $query_where[] = 'm.id_msg >= {int:min_msg_id}'; |
|
190 | + } |
|
191 | + if ($query_params['max_msg_id']) { |
|
192 | + $query_where[] = 'm.id_msg <= {int:max_msg_id}'; |
|
193 | + } |
|
183 | 194 | |
184 | 195 | $count = 0; |
185 | - if (!empty($query_params['excluded_phrases']) && empty($modSettings['search_force_index'])) |
|
186 | - foreach ($query_params['excluded_phrases'] as $phrase) |
|
196 | + if (!empty($query_params['excluded_phrases']) && empty($modSettings['search_force_index'])) { |
|
197 | + foreach ($query_params['excluded_phrases'] as $phrase) |
|
187 | 198 | { |
188 | 199 | $query_where[] = 'subject NOT ' . (empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? ' LIKE ' : ' RLIKE ') . '{string:exclude_subject_phrase_' . $count . '}'; |
200 | + } |
|
189 | 201 | $query_params['exclude_subject_phrase_' . $count++] = empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? '%' . strtr($phrase, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $phrase), '\\\'') . '[[:>:]]'; |
190 | 202 | } |
191 | 203 | $count = 0; |
192 | - if (!empty($query_params['excluded_subject_words']) && empty($modSettings['search_force_index'])) |
|
193 | - foreach ($query_params['excluded_subject_words'] as $excludedWord) |
|
204 | + if (!empty($query_params['excluded_subject_words']) && empty($modSettings['search_force_index'])) { |
|
205 | + foreach ($query_params['excluded_subject_words'] as $excludedWord) |
|
194 | 206 | { |
195 | 207 | $query_where[] = 'subject NOT ' . (empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? ' LIKE ' : ' RLIKE ') . '{string:exclude_subject_words_' . $count . '}'; |
208 | + } |
|
196 | 209 | $query_params['exclude_subject_words_' . $count++] = empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? '%' . strtr($excludedWord, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $excludedWord), '\\\'') . '[[:>:]]'; |
197 | 210 | } |
198 | 211 | |
@@ -205,8 +218,7 @@ discard block |
||
205 | 218 | { |
206 | 219 | $query_left_join[] = '{db_prefix}log_search_words AS lsw' . $numTables . ' ON (lsw' . $numTables . '.id_word = ' . $indexedWord . ' AND lsw' . $numTables . '.id_msg = m.id_msg)'; |
207 | 220 | $query_where[] = '(lsw' . $numTables . '.id_word IS NULL)'; |
208 | - } |
|
209 | - else |
|
221 | + } else |
|
210 | 222 | { |
211 | 223 | $query_inner_join[] = '{db_prefix}log_search_words AS lsw' . $numTables . ' ON (lsw' . $numTables . '.id_msg = ' . ($prev_join === 0 ? 'm' : 'lsw' . $prev_join) . '.id_msg)'; |
212 | 224 | $query_where[] = 'lsw' . $numTables . '.id_word = ' . $indexedWord; |
@@ -242,16 +254,18 @@ discard block |
||
242 | 254 | $customIndexSettings = $smcFunc['json_decode']($modSettings['search_custom_index_config'], true); |
243 | 255 | |
244 | 256 | $inserts = array(); |
245 | - foreach (text2words($msgOptions['body'], $customIndexSettings['bytes_per_word'], true) as $word) |
|
246 | - $inserts[] = array($word, $msgOptions['id']); |
|
257 | + foreach (text2words($msgOptions['body'], $customIndexSettings['bytes_per_word'], true) as $word) { |
|
258 | + $inserts[] = array($word, $msgOptions['id']); |
|
259 | + } |
|
247 | 260 | |
248 | - if (!empty($inserts)) |
|
249 | - $smcFunc['db_insert']('ignore', |
|
261 | + if (!empty($inserts)) { |
|
262 | + $smcFunc['db_insert']('ignore', |
|
250 | 263 | '{db_prefix}log_search_words', |
251 | 264 | array('id_word' => 'int', 'id_msg' => 'int'), |
252 | 265 | $inserts, |
253 | 266 | array('id_word', 'id_msg') |
254 | 267 | ); |
268 | + } |
|
255 | 269 | } |
256 | 270 | |
257 | 271 | /** |
@@ -294,8 +308,9 @@ discard block |
||
294 | 308 | if (!empty($inserted_words)) |
295 | 309 | { |
296 | 310 | $inserts = array(); |
297 | - foreach ($inserted_words as $word) |
|
298 | - $inserts[] = array($word, $msgOptions['id']); |
|
311 | + foreach ($inserted_words as $word) { |
|
312 | + $inserts[] = array($word, $msgOptions['id']); |
|
313 | + } |
|
299 | 314 | $smcFunc['db_insert']('insert', |
300 | 315 | '{db_prefix}log_search_words', |
301 | 316 | array('id_word' => 'string', 'id_msg' => 'int'), |
@@ -1229,8 +1229,8 @@ |
||
1229 | 1229 | continue; |
1230 | 1230 | |
1231 | 1231 | $final_saves[$string_key] = array( |
1232 | - 'find' => "\n\n?".'>', |
|
1233 | - 'replace' => "\n$" . $type . '[\'' . $string_key . '\'] = ' . $string_val['string'] . ';' . "\n\n?".'>', |
|
1232 | + 'find' => "\n\n?" . '>', |
|
1233 | + 'replace' => "\n$" . $type . '[\'' . $string_key . '\'] = ' . $string_val['string'] . ';' . "\n\n?" . '>', |
|
1234 | 1234 | ); |
1235 | 1235 | } |
1236 | 1236 | } |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 4 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * This is the main function for the languages area. |
@@ -150,11 +151,11 @@ discard block |
||
150 | 151 | $language_list = new xmlArray(fetch_web_data($url), true); |
151 | 152 | |
152 | 153 | // Check that the site responded and that the language exists. |
153 | - if (!$language_list->exists('languages')) |
|
154 | - $context['smf_error'] = 'no_response'; |
|
155 | - elseif (!$language_list->exists('languages/language')) |
|
156 | - $context['smf_error'] = 'no_files'; |
|
157 | - else |
|
154 | + if (!$language_list->exists('languages')) { |
|
155 | + $context['smf_error'] = 'no_response'; |
|
156 | + } elseif (!$language_list->exists('languages/language')) { |
|
157 | + $context['smf_error'] = 'no_files'; |
|
158 | + } else |
|
158 | 159 | { |
159 | 160 | $language_list = $language_list->path('languages[0]'); |
160 | 161 | $lang_files = $language_list->set('language'); |
@@ -162,8 +163,9 @@ discard block |
||
162 | 163 | foreach ($lang_files as $file) |
163 | 164 | { |
164 | 165 | // Were we searching? |
165 | - if (!empty($context['smf_search_term']) && strpos($file->fetch('name'), $smcFunc['strtolower']($context['smf_search_term'])) === false) |
|
166 | - continue; |
|
166 | + if (!empty($context['smf_search_term']) && strpos($file->fetch('name'), $smcFunc['strtolower']($context['smf_search_term'])) === false) { |
|
167 | + continue; |
|
168 | + } |
|
167 | 169 | |
168 | 170 | $smf_languages[] = array( |
169 | 171 | 'id' => $file->fetch('id'), |
@@ -174,10 +176,11 @@ discard block |
||
174 | 176 | 'install_link' => '<a href="' . $scripturl . '?action=admin;area=languages;sa=downloadlang;did=' . $file->fetch('id') . ';' . $context['session_var'] . '=' . $context['session_id'] . '">' . $txt['add_language_smf_install'] . '</a>', |
175 | 177 | ); |
176 | 178 | } |
177 | - if (empty($smf_languages)) |
|
178 | - $context['smf_error'] = 'no_files'; |
|
179 | - else |
|
180 | - return $smf_languages; |
|
179 | + if (empty($smf_languages)) { |
|
180 | + $context['smf_error'] = 'no_files'; |
|
181 | + } else { |
|
182 | + return $smf_languages; |
|
183 | + } |
|
181 | 184 | } |
182 | 185 | } |
183 | 186 | |
@@ -199,8 +202,9 @@ discard block |
||
199 | 202 | require_once($sourcedir . '/Subs-Package.php'); |
200 | 203 | |
201 | 204 | // Clearly we need to know what to request. |
202 | - if (!isset($_GET['did'])) |
|
203 | - fatal_lang_error('no_access', false); |
|
205 | + if (!isset($_GET['did'])) { |
|
206 | + fatal_lang_error('no_access', false); |
|
207 | + } |
|
204 | 208 | |
205 | 209 | // Some lovely context. |
206 | 210 | $context['download_id'] = $_GET['did']; |
@@ -220,8 +224,9 @@ discard block |
||
220 | 224 | foreach ($_POST['copy_file'] as $file) |
221 | 225 | { |
222 | 226 | // Check it's not very bad. |
223 | - if (strpos($file, '..') !== false || (strpos($file, 'Themes') !== 0 && !preg_match('~agreement\.[A-Za-z-_0-9]+\.txt$~', $file))) |
|
224 | - fatal_error($txt['languages_download_illegal_paths']); |
|
227 | + if (strpos($file, '..') !== false || (strpos($file, 'Themes') !== 0 && !preg_match('~agreement\.[A-Za-z-_0-9]+\.txt$~', $file))) { |
|
228 | + fatal_error($txt['languages_download_illegal_paths']); |
|
229 | + } |
|
225 | 230 | |
226 | 231 | $chmod_files[] = $boarddir . '/' . $file; |
227 | 232 | $install_files[] = $file; |
@@ -232,8 +237,9 @@ discard block |
||
232 | 237 | $files_left = $file_status['files']['notwritable']; |
233 | 238 | |
234 | 239 | // Something not writable? |
235 | - if (!empty($files_left)) |
|
236 | - $context['error_message'] = $txt['languages_download_not_chmod']; |
|
240 | + if (!empty($files_left)) { |
|
241 | + $context['error_message'] = $txt['languages_download_not_chmod']; |
|
242 | + } |
|
237 | 243 | // Otherwise, go go go! |
238 | 244 | elseif (!empty($install_files)) |
239 | 245 | { |
@@ -248,11 +254,13 @@ discard block |
||
248 | 254 | } |
249 | 255 | |
250 | 256 | // Open up the old china. |
251 | - if (!isset($archive_content)) |
|
252 | - $archive_content = read_tgz_file('https://download.simplemachines.org/fetch_language.php?version=' . urlencode(strtr($forum_version, array('SMF ' => ''))) . ';fetch=' . urlencode($_GET['did']), null); |
|
257 | + if (!isset($archive_content)) { |
|
258 | + $archive_content = read_tgz_file('https://download.simplemachines.org/fetch_language.php?version=' . urlencode(strtr($forum_version, array('SMF ' => ''))) . ';fetch=' . urlencode($_GET['did']), null); |
|
259 | + } |
|
253 | 260 | |
254 | - if (empty($archive_content)) |
|
255 | - fatal_error($txt['add_language_error_no_response']); |
|
261 | + if (empty($archive_content)) { |
|
262 | + fatal_error($txt['add_language_error_no_response']); |
|
263 | + } |
|
256 | 264 | |
257 | 265 | // Now for each of the files, let's do some *stuff* |
258 | 266 | $context['files'] = array( |
@@ -267,8 +275,9 @@ discard block |
||
267 | 275 | $extension = substr($filename, strrpos($filename, '.') + 1); |
268 | 276 | |
269 | 277 | // Don't do anything with files we don't understand. |
270 | - if (!in_array($extension, array('php', 'jpg', 'gif', 'jpeg', 'png', 'txt'))) |
|
271 | - continue; |
|
278 | + if (!in_array($extension, array('php', 'jpg', 'gif', 'jpeg', 'png', 'txt'))) { |
|
279 | + continue; |
|
280 | + } |
|
272 | 281 | |
273 | 282 | // Basic data. |
274 | 283 | $context_data = array( |
@@ -287,8 +296,9 @@ discard block |
||
287 | 296 | // Does the file exist, is it different and can we overwrite? |
288 | 297 | if (file_exists($boarddir . '/' . $file['filename'])) |
289 | 298 | { |
290 | - if (is_writable($boarddir . '/' . $file['filename'])) |
|
291 | - $context_data['writable'] = true; |
|
299 | + if (is_writable($boarddir . '/' . $file['filename'])) { |
|
300 | + $context_data['writable'] = true; |
|
301 | + } |
|
292 | 302 | |
293 | 303 | // Finally, do we actually think the content has changed? |
294 | 304 | if ($file['size'] == filesize($boarddir . '/' . $file['filename']) && $file['md5'] == md5_file($boarddir . '/' . $file['filename'])) |
@@ -301,16 +311,17 @@ discard block |
||
301 | 311 | { |
302 | 312 | $context_data['exists'] = 'same'; |
303 | 313 | $context_data['default_copy'] = false; |
314 | + } else { |
|
315 | + $context_data['exists'] = 'different'; |
|
304 | 316 | } |
305 | - else |
|
306 | - $context_data['exists'] = 'different'; |
|
307 | 317 | } |
308 | 318 | // No overwrite? |
309 | 319 | else |
310 | 320 | { |
311 | 321 | // Can we at least stick it in the directory... |
312 | - if (is_writable($boarddir . '/' . $dirname)) |
|
313 | - $context_data['writable'] = true; |
|
322 | + if (is_writable($boarddir . '/' . $dirname)) { |
|
323 | + $context_data['writable'] = true; |
|
324 | + } |
|
314 | 325 | } |
315 | 326 | |
316 | 327 | // I love PHP files, that's why I'm a developer and not an artistic type spending my time drinking absinth and living a life of sin... |
@@ -325,8 +336,9 @@ discard block |
||
325 | 336 | list ($name, $language) = explode('.', $filename); |
326 | 337 | |
327 | 338 | // Let's get the new version, I like versions, they tell me that I'm up to date. |
328 | - if (preg_match('~\s*Version:\s+(.+?);\s*' . preg_quote($name, '~') . '~i', $file['preview'], $match) == 1) |
|
329 | - $context_data['version'] = $match[1]; |
|
339 | + if (preg_match('~\s*Version:\s+(.+?);\s*' . preg_quote($name, '~') . '~i', $file['preview'], $match) == 1) { |
|
340 | + $context_data['version'] = $match[1]; |
|
341 | + } |
|
330 | 342 | |
331 | 343 | // Now does the old file exist - if so what is it's version? |
332 | 344 | if (file_exists($boarddir . '/' . $file['filename'])) |
@@ -342,34 +354,35 @@ discard block |
||
342 | 354 | $context_data['cur_version'] = $match[1]; |
343 | 355 | |
344 | 356 | // How does this compare? |
345 | - if ($context_data['cur_version'] == $context_data['version']) |
|
346 | - $context_data['version_compare'] = 'same'; |
|
347 | - elseif ($context_data['cur_version'] > $context_data['version']) |
|
348 | - $context_data['version_compare'] = 'older'; |
|
357 | + if ($context_data['cur_version'] == $context_data['version']) { |
|
358 | + $context_data['version_compare'] = 'same'; |
|
359 | + } elseif ($context_data['cur_version'] > $context_data['version']) { |
|
360 | + $context_data['version_compare'] = 'older'; |
|
361 | + } |
|
349 | 362 | |
350 | 363 | // Don't recommend copying if the version is the same. |
351 | - if ($context_data['version_compare'] != 'newer') |
|
352 | - $context_data['default_copy'] = false; |
|
364 | + if ($context_data['version_compare'] != 'newer') { |
|
365 | + $context_data['default_copy'] = false; |
|
366 | + } |
|
353 | 367 | } |
354 | 368 | } |
355 | 369 | |
356 | 370 | // Add the context data to the main set. |
357 | 371 | $context['files']['lang'][] = $context_data; |
358 | - } |
|
359 | - elseif ($extension == '.txt' && stripos($filename, 'agreement') !== false) |
|
372 | + } elseif ($extension == '.txt' && stripos($filename, 'agreement') !== false) |
|
360 | 373 | { |
361 | 374 | // Registration agreement is a primary file |
362 | 375 | $context['files']['lang'][] = $context_data; |
363 | - } |
|
364 | - else |
|
376 | + } else |
|
365 | 377 | { |
366 | 378 | // There shouldn't be anything else, but load this into "other" in case we decide to handle it in the future |
367 | 379 | $context['files']['other'][] = $context_data; |
368 | 380 | } |
369 | 381 | |
370 | 382 | // Collect together all non-writable areas. |
371 | - if (!$context_data['writable']) |
|
372 | - $context['make_writable'][] = $context_data['destination']; |
|
383 | + if (!$context_data['writable']) { |
|
384 | + $context['make_writable'][] = $context_data['destination']; |
|
385 | + } |
|
373 | 386 | } |
374 | 387 | |
375 | 388 | // Before we go to far can we make anything writable, eh, eh? |
@@ -384,22 +397,24 @@ discard block |
||
384 | 397 | { |
385 | 398 | if ($type == 'lang') |
386 | 399 | { |
387 | - foreach ($data as $k => $file) |
|
388 | - if (!$file['writable'] && !in_array($file['destination'], $context['still_not_writable'])) |
|
400 | + foreach ($data as $k => $file) { |
|
401 | + if (!$file['writable'] && !in_array($file['destination'], $context['still_not_writable'])) |
|
389 | 402 | $context['files'][$type][$k]['writable'] = true; |
390 | - } |
|
391 | - else |
|
403 | + } |
|
404 | + } else |
|
392 | 405 | { |
393 | - foreach ($data as $theme => $files) |
|
394 | - foreach ($files as $k => $file) |
|
406 | + foreach ($data as $theme => $files) { |
|
407 | + foreach ($files as $k => $file) |
|
395 | 408 | if (!$file['writable'] && !in_array($file['destination'], $context['still_not_writable'])) |
396 | 409 | $context['files'][$type][$theme][$k]['writable'] = true; |
410 | + } |
|
397 | 411 | } |
398 | 412 | } |
399 | 413 | |
400 | 414 | // Are we going to need more language stuff? |
401 | - if (!empty($context['still_not_writable'])) |
|
402 | - loadLanguage('Packages'); |
|
415 | + if (!empty($context['still_not_writable'])) { |
|
416 | + loadLanguage('Packages'); |
|
417 | + } |
|
403 | 418 | } |
404 | 419 | |
405 | 420 | // This is the list for the main files. |
@@ -612,12 +627,13 @@ discard block |
||
612 | 627 | highlightSelected("list_language_list_' . ($language == '' ? 'english' : $language) . '");', true); |
613 | 628 | |
614 | 629 | // Display a warning if we cannot edit the default setting. |
615 | - if (!is_writable($boarddir . '/Settings.php')) |
|
616 | - $listOptions['additional_rows'][] = array( |
|
630 | + if (!is_writable($boarddir . '/Settings.php')) { |
|
631 | + $listOptions['additional_rows'][] = array( |
|
617 | 632 | 'position' => 'after_title', |
618 | 633 | 'value' => $txt['language_settings_writable'], |
619 | 634 | 'class' => 'smalltext alert', |
620 | 635 | ); |
636 | + } |
|
621 | 637 | |
622 | 638 | require_once($sourcedir . '/Subs-List.php'); |
623 | 639 | createList($listOptions); |
@@ -659,10 +675,11 @@ discard block |
||
659 | 675 | |
660 | 676 | // Put them back. |
661 | 677 | $settings['actual_theme_dir'] = $backup_actual_theme_dir; |
662 | - if (!empty($backup_base_theme_dir)) |
|
663 | - $settings['base_theme_dir'] = $backup_base_theme_dir; |
|
664 | - else |
|
665 | - unset($settings['base_theme_dir']); |
|
678 | + if (!empty($backup_base_theme_dir)) { |
|
679 | + $settings['base_theme_dir'] = $backup_base_theme_dir; |
|
680 | + } else { |
|
681 | + unset($settings['base_theme_dir']); |
|
682 | + } |
|
666 | 683 | |
667 | 684 | // Get the language files and data... |
668 | 685 | foreach ($context['languages'] as $lang) |
@@ -691,13 +708,15 @@ discard block |
||
691 | 708 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
692 | 709 | { |
693 | 710 | // Default? |
694 | - if (empty($row['lngfile']) || !isset($languages[$row['lngfile']])) |
|
695 | - $row['lngfile'] = $language; |
|
711 | + if (empty($row['lngfile']) || !isset($languages[$row['lngfile']])) { |
|
712 | + $row['lngfile'] = $language; |
|
713 | + } |
|
696 | 714 | |
697 | - if (!isset($languages[$row['lngfile']]) && isset($languages['english'])) |
|
698 | - $languages['english']['count'] += $row['num_users']; |
|
699 | - elseif (isset($languages[$row['lngfile']])) |
|
700 | - $languages[$row['lngfile']]['count'] += $row['num_users']; |
|
715 | + if (!isset($languages[$row['lngfile']]) && isset($languages['english'])) { |
|
716 | + $languages['english']['count'] += $row['num_users']; |
|
717 | + } elseif (isset($languages[$row['lngfile']])) { |
|
718 | + $languages[$row['lngfile']]['count'] += $row['num_users']; |
|
719 | + } |
|
701 | 720 | } |
702 | 721 | $smcFunc['db_free_result']($request); |
703 | 722 | |
@@ -737,13 +756,15 @@ discard block |
||
737 | 756 | |
738 | 757 | call_integration_hook('integrate_language_settings', array(&$config_vars)); |
739 | 758 | |
740 | - if ($return_config) |
|
741 | - return $config_vars; |
|
759 | + if ($return_config) { |
|
760 | + return $config_vars; |
|
761 | + } |
|
742 | 762 | |
743 | 763 | // Get our languages. No cache |
744 | 764 | getLanguages(false); |
745 | - foreach ($context['languages'] as $lang) |
|
746 | - $config_vars['language'][4][$lang['filename']] = array($lang['filename'], $lang['name']); |
|
765 | + foreach ($context['languages'] as $lang) { |
|
766 | + $config_vars['language'][4][$lang['filename']] = array($lang['filename'], $lang['name']); |
|
767 | + } |
|
747 | 768 | |
748 | 769 | // Saving settings? |
749 | 770 | if (isset($_REQUEST['save'])) |
@@ -753,8 +774,9 @@ discard block |
||
753 | 774 | call_integration_hook('integrate_save_language_settings', array(&$config_vars)); |
754 | 775 | |
755 | 776 | saveSettings($config_vars); |
756 | - if (!$settings_not_writable && !$settings_backup_fail) |
|
757 | - $_SESSION['adm-save'] = true; |
|
777 | + if (!$settings_not_writable && !$settings_backup_fail) { |
|
778 | + $_SESSION['adm-save'] = true; |
|
779 | + } |
|
758 | 780 | redirectexit('action=admin;area=languages;sa=settings'); |
759 | 781 | } |
760 | 782 | |
@@ -763,10 +785,11 @@ discard block |
||
763 | 785 | $context['settings_title'] = $txt['language_settings']; |
764 | 786 | $context['save_disabled'] = $settings_not_writable; |
765 | 787 | |
766 | - if ($settings_not_writable) |
|
767 | - $context['settings_message'] = '<div class="centertext"><strong>' . $txt['settings_not_writable'] . '</strong></div><br>'; |
|
768 | - elseif ($settings_backup_fail) |
|
769 | - $context['settings_message'] = '<div class="centertext"><strong>' . $txt['admin_backup_fail'] . '</strong></div><br>'; |
|
788 | + if ($settings_not_writable) { |
|
789 | + $context['settings_message'] = '<div class="centertext"><strong>' . $txt['settings_not_writable'] . '</strong></div><br>'; |
|
790 | + } elseif ($settings_backup_fail) { |
|
791 | + $context['settings_message'] = '<div class="centertext"><strong>' . $txt['admin_backup_fail'] . '</strong></div><br>'; |
|
792 | + } |
|
770 | 793 | |
771 | 794 | // Fill the config array. |
772 | 795 | prepareServerSettingsContext($config_vars); |
@@ -813,8 +836,9 @@ discard block |
||
813 | 836 | 'theme_dir' => $settings['default_theme_dir'], |
814 | 837 | ), |
815 | 838 | ); |
816 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
817 | - $themes[$row['id_theme']][$row['variable']] = $row['value']; |
|
839 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
840 | + $themes[$row['id_theme']][$row['variable']] = $row['value']; |
|
841 | + } |
|
818 | 842 | $smcFunc['db_free_result']($request); |
819 | 843 | |
820 | 844 | // This will be where we look |
@@ -841,14 +865,16 @@ discard block |
||
841 | 865 | // Check we have themes with a path and a name - just in case - and add the path. |
842 | 866 | foreach ($themes as $id => $data) |
843 | 867 | { |
844 | - if (count($data) != 2) |
|
845 | - unset($themes[$id]); |
|
846 | - elseif (is_dir($data['theme_dir'] . '/languages')) |
|
847 | - $lang_dirs[$id] = $data['theme_dir'] . '/languages'; |
|
868 | + if (count($data) != 2) { |
|
869 | + unset($themes[$id]); |
|
870 | + } elseif (is_dir($data['theme_dir'] . '/languages')) { |
|
871 | + $lang_dirs[$id] = $data['theme_dir'] . '/languages'; |
|
872 | + } |
|
848 | 873 | |
849 | 874 | // How about image directories? |
850 | - if (is_dir($data['theme_dir'] . '/images/' . $context['lang_id'])) |
|
851 | - $images_dirs[$id] = $data['theme_dir'] . '/images/' . $context['lang_id']; |
|
875 | + if (is_dir($data['theme_dir'] . '/images/' . $context['lang_id'])) { |
|
876 | + $images_dirs[$id] = $data['theme_dir'] . '/images/' . $context['lang_id']; |
|
877 | + } |
|
852 | 878 | } |
853 | 879 | |
854 | 880 | $current_file = $file_id ? $lang_dirs[$theme_id] . '/' . $file_id . '.' . $context['lang_id'] . '.php' : ''; |
@@ -862,15 +888,17 @@ discard block |
||
862 | 888 | while ($entry = $dir->read()) |
863 | 889 | { |
864 | 890 | // We're only after the files for this language. |
865 | - if (preg_match('~^([A-Za-z]+)\.' . $context['lang_id'] . '\.php$~', $entry, $matches) == 0) |
|
866 | - continue; |
|
891 | + if (preg_match('~^([A-Za-z]+)\.' . $context['lang_id'] . '\.php$~', $entry, $matches) == 0) { |
|
892 | + continue; |
|
893 | + } |
|
867 | 894 | |
868 | - if (!isset($context['possible_files'][$theme])) |
|
869 | - $context['possible_files'][$theme] = array( |
|
895 | + if (!isset($context['possible_files'][$theme])) { |
|
896 | + $context['possible_files'][$theme] = array( |
|
870 | 897 | 'id' => $theme, |
871 | 898 | 'name' => $themes[$theme]['name'], |
872 | 899 | 'files' => array(), |
873 | 900 | ); |
901 | + } |
|
874 | 902 | |
875 | 903 | $context['possible_files'][$theme]['files'][] = array( |
876 | 904 | 'id' => $matches[1], |
@@ -899,31 +927,36 @@ discard block |
||
899 | 927 | { |
900 | 928 | $_SESSION['last_backup_for'] = $context['lang_id'] . '$$$'; |
901 | 929 | $result = package_create_backup('backup_lang_' . $context['lang_id']); |
902 | - if (!$result) |
|
903 | - fatal_lang_error('could_not_language_backup', false); |
|
930 | + if (!$result) { |
|
931 | + fatal_lang_error('could_not_language_backup', false); |
|
932 | + } |
|
904 | 933 | } |
905 | 934 | |
906 | 935 | // Second, loop through the array to remove the files. |
907 | 936 | foreach ($lang_dirs as $curPath) |
908 | 937 | { |
909 | - foreach ($context['possible_files'][1]['files'] as $lang) |
|
910 | - if (file_exists($curPath . '/' . $lang['id'] . '.' . $context['lang_id'] . '.php')) |
|
938 | + foreach ($context['possible_files'][1]['files'] as $lang) { |
|
939 | + if (file_exists($curPath . '/' . $lang['id'] . '.' . $context['lang_id'] . '.php')) |
|
911 | 940 | unlink($curPath . '/' . $lang['id'] . '.' . $context['lang_id'] . '.php'); |
941 | + } |
|
912 | 942 | |
913 | 943 | // Check for the email template. |
914 | - if (file_exists($curPath . '/EmailTemplates.' . $context['lang_id'] . '.php')) |
|
915 | - unlink($curPath . '/EmailTemplates.' . $context['lang_id'] . '.php'); |
|
944 | + if (file_exists($curPath . '/EmailTemplates.' . $context['lang_id'] . '.php')) { |
|
945 | + unlink($curPath . '/EmailTemplates.' . $context['lang_id'] . '.php'); |
|
946 | + } |
|
916 | 947 | } |
917 | 948 | |
918 | 949 | // Third, the agreement file. |
919 | - if (file_exists($boarddir . '/agreement.' . $context['lang_id'] . '.txt')) |
|
920 | - unlink($boarddir . '/agreement.' . $context['lang_id'] . '.txt'); |
|
950 | + if (file_exists($boarddir . '/agreement.' . $context['lang_id'] . '.txt')) { |
|
951 | + unlink($boarddir . '/agreement.' . $context['lang_id'] . '.txt'); |
|
952 | + } |
|
921 | 953 | |
922 | 954 | // Fourth, a related images folder, if it exists... |
923 | - if (!empty($images_dirs)) |
|
924 | - foreach ($images_dirs as $curPath) |
|
955 | + if (!empty($images_dirs)) { |
|
956 | + foreach ($images_dirs as $curPath) |
|
925 | 957 | if (is_dir($curPath)) |
926 | 958 | deltree($curPath); |
959 | + } |
|
927 | 960 | |
928 | 961 | // Members can no longer use this language. |
929 | 962 | $smcFunc['db_query']('', ' |
@@ -1010,13 +1043,14 @@ discard block |
||
1010 | 1043 | foreach ($_POST['edit'] as $k => $v) |
1011 | 1044 | { |
1012 | 1045 | // Only try to save if 'edit' was specified and if the string has changed |
1013 | - if ($v == 'edit' && isset($_POST['entry'][$k]) && isset($_POST['comp'][$k]) && $_POST['entry'][$k] != $_POST['comp'][$k]) |
|
1014 | - $save_strings[$k] = cleanLangString($_POST['entry'][$k], false); |
|
1046 | + if ($v == 'edit' && isset($_POST['entry'][$k]) && isset($_POST['comp'][$k]) && $_POST['entry'][$k] != $_POST['comp'][$k]) { |
|
1047 | + $save_strings[$k] = cleanLangString($_POST['entry'][$k], false); |
|
1048 | + } |
|
1015 | 1049 | |
1016 | 1050 | // Record any add or remove requests. We'll decide on them later. |
1017 | - elseif ($v == 'remove') |
|
1018 | - $remove_strings[] = $k; |
|
1019 | - elseif ($v == 'add' && isset($_POST['entry'][$k])) |
|
1051 | + elseif ($v == 'remove') { |
|
1052 | + $remove_strings[] = $k; |
|
1053 | + } elseif ($v == 'add' && isset($_POST['entry'][$k])) |
|
1020 | 1054 | { |
1021 | 1055 | $add_strings[$k] = array( |
1022 | 1056 | 'group' => isset($_POST['grp'][$k]) ? $_POST['grp'][$k] : 'txt', |
@@ -1056,8 +1090,9 @@ discard block |
||
1056 | 1090 | { |
1057 | 1091 | $group = !empty($special_groups[$file_id][$matches[1]]) ? $special_groups[$file_id][$matches[1]] : $matches[1]; |
1058 | 1092 | |
1059 | - if (isset($allows_add_remove[$file_id]['add']) && in_array($matches[1], $allows_add_remove[$file_id]['add'])) |
|
1060 | - $context['can_add_lang_entry'][$group] = true; |
|
1093 | + if (isset($allows_add_remove[$file_id]['add']) && in_array($matches[1], $allows_add_remove[$file_id]['add'])) { |
|
1094 | + $context['can_add_lang_entry'][$group] = true; |
|
1095 | + } |
|
1061 | 1096 | |
1062 | 1097 | $entries[$matches[2]] = array( |
1063 | 1098 | 'type' => $matches[1], |
@@ -1079,8 +1114,9 @@ discard block |
||
1079 | 1114 | { |
1080 | 1115 | $group = !empty($special_groups[$file_id][$matches[1]]) ? $special_groups[$file_id][$matches[1]] : $matches[1]; |
1081 | 1116 | |
1082 | - if (isset($allows_add_remove[$file_id]['add']) && in_array($matches[1], $allows_add_remove[$file_id]['add'])) |
|
1083 | - $context['can_add_lang_entry'][$group] = true; |
|
1117 | + if (isset($allows_add_remove[$file_id]['add']) && in_array($matches[1], $allows_add_remove[$file_id]['add'])) { |
|
1118 | + $context['can_add_lang_entry'][$group] = true; |
|
1119 | + } |
|
1084 | 1120 | |
1085 | 1121 | $entries[$matches[2]] = array( |
1086 | 1122 | 'type' => $matches[1], |
@@ -1100,8 +1136,9 @@ discard block |
||
1100 | 1136 | { |
1101 | 1137 | // Ignore some things we set separately. |
1102 | 1138 | $ignore_files = array('lang_character_set', 'lang_locale', 'lang_dictionary', 'lang_spelling', 'lang_rtl'); |
1103 | - if (in_array($entryKey, $ignore_files)) |
|
1104 | - continue; |
|
1139 | + if (in_array($entryKey, $ignore_files)) { |
|
1140 | + continue; |
|
1141 | + } |
|
1105 | 1142 | |
1106 | 1143 | // These are arrays that need breaking out. |
1107 | 1144 | $arrays = array('days', 'days_short', 'months', 'months_titles', 'months_short'); |
@@ -1134,9 +1171,9 @@ discard block |
||
1134 | 1171 | { |
1135 | 1172 | $save_cache['entries'][$cur_index] = strtr($save_strings[$entryKey . '-+- ' . $cur_index], array('\'' => '')); |
1136 | 1173 | $save_cache['enabled'] = true; |
1174 | + } else { |
|
1175 | + $save_cache['entries'][$cur_index] = $subValue; |
|
1137 | 1176 | } |
1138 | - else |
|
1139 | - $save_cache['entries'][$cur_index] = $subValue; |
|
1140 | 1177 | |
1141 | 1178 | $context['file_entries'][$entryValue['group']][] = array( |
1142 | 1179 | 'key' => $entryKey . '-+- ' . $cur_index, |
@@ -1159,9 +1196,9 @@ discard block |
||
1159 | 1196 | { |
1160 | 1197 | $items[] = $k2 . ' => \'' . $v2 . '\''; |
1161 | 1198 | $cur_index = $k2; |
1199 | + } else { |
|
1200 | + $items[] = '\'' . $v2 . '\''; |
|
1162 | 1201 | } |
1163 | - else |
|
1164 | - $items[] = '\'' . $v2 . '\''; |
|
1165 | 1202 | |
1166 | 1203 | $cur_index++; |
1167 | 1204 | } |
@@ -1171,15 +1208,15 @@ discard block |
||
1171 | 1208 | 'replace' => '$' . $entryValue['type'] . '[\'' . $entryKey . '\'] = array(' . implode(', ', $items) . ');', |
1172 | 1209 | ); |
1173 | 1210 | } |
1174 | - } |
|
1175 | - else |
|
1211 | + } else |
|
1176 | 1212 | { |
1177 | 1213 | // Saving? |
1178 | 1214 | if (isset($save_strings[$entryKey]) && $save_strings[$entryKey] != $entryValue['entry']) |
1179 | 1215 | { |
1180 | 1216 | // @todo Fix this properly. |
1181 | - if ($save_strings[$entryKey] == '') |
|
1182 | - $save_strings[$entryKey] = '\'\''; |
|
1217 | + if ($save_strings[$entryKey] == '') { |
|
1218 | + $save_strings[$entryKey] = '\'\''; |
|
1219 | + } |
|
1183 | 1220 | |
1184 | 1221 | // Set the new value. |
1185 | 1222 | $entryValue['entry'] = $save_strings[$entryKey]; |
@@ -1218,8 +1255,9 @@ discard block |
||
1218 | 1255 | { |
1219 | 1256 | $type = isset($special_types[$string_val['group']]) ? $special_types[$string_val['group']] : $string_val['group']; |
1220 | 1257 | |
1221 | - if (!in_array($type, $allows_add_remove[$file_id]['add'])) |
|
1222 | - continue; |
|
1258 | + if (!in_array($type, $allows_add_remove[$file_id]['add'])) { |
|
1259 | + continue; |
|
1260 | + } |
|
1223 | 1261 | |
1224 | 1262 | $final_saves[$string_key] = array( |
1225 | 1263 | 'find' => "\n\n?".'>', |
@@ -1234,8 +1272,9 @@ discard block |
||
1234 | 1272 | checkSession(); |
1235 | 1273 | |
1236 | 1274 | $file_contents = implode('', file($current_file)); |
1237 | - foreach ($final_saves as $save) |
|
1238 | - $file_contents = strtr($file_contents, array($save['find'] => $save['replace'])); |
|
1275 | + foreach ($final_saves as $save) { |
|
1276 | + $file_contents = strtr($file_contents, array($save['find'] => $save['replace'])); |
|
1277 | + } |
|
1239 | 1278 | |
1240 | 1279 | // Save the actual changes. |
1241 | 1280 | $fp = fopen($current_file, 'w+'); |
@@ -1293,8 +1332,9 @@ discard block |
||
1293 | 1332 | } |
1294 | 1333 | |
1295 | 1334 | // If we saved, redirect. |
1296 | - if ($madeSave) |
|
1297 | - redirectexit('action=admin;area=languages;sa=editlang;lid=' . $context['lang_id']); |
|
1335 | + if ($madeSave) { |
|
1336 | + redirectexit('action=admin;area=languages;sa=editlang;lid=' . $context['lang_id']); |
|
1337 | + } |
|
1298 | 1338 | |
1299 | 1339 | createToken('admin-mlang'); |
1300 | 1340 | } |
@@ -1326,8 +1366,9 @@ discard block |
||
1326 | 1366 | // Toggle the escape. |
1327 | 1367 | $is_escape = !$is_escape; |
1328 | 1368 | // If we're now escaped don't add this string. |
1329 | - if ($is_escape) |
|
1330 | - continue; |
|
1369 | + if ($is_escape) { |
|
1370 | + continue; |
|
1371 | + } |
|
1331 | 1372 | } |
1332 | 1373 | // Special case - parsed string with line break etc? |
1333 | 1374 | elseif (($string{$i} == 'n' || $string{$i} == 't') && $in_string == 2 && $is_escape) |
@@ -1344,11 +1385,13 @@ discard block |
||
1344 | 1385 | if ($in_string != 2 && ($in_string != 1 || !$is_escape)) |
1345 | 1386 | { |
1346 | 1387 | // Is it the end of a single quote string? |
1347 | - if ($in_string == 1) |
|
1348 | - $in_string = 0; |
|
1388 | + if ($in_string == 1) { |
|
1389 | + $in_string = 0; |
|
1390 | + } |
|
1349 | 1391 | // Otherwise it's the start! |
1350 | - else |
|
1351 | - $in_string = 1; |
|
1392 | + else { |
|
1393 | + $in_string = 1; |
|
1394 | + } |
|
1352 | 1395 | |
1353 | 1396 | // Don't actually include this character! |
1354 | 1397 | continue; |
@@ -1361,19 +1404,22 @@ discard block |
||
1361 | 1404 | if ($in_string != 1 && ($in_string != 2 || !$is_escape)) |
1362 | 1405 | { |
1363 | 1406 | // Is it the end of a double quote string? |
1364 | - if ($in_string == 2) |
|
1365 | - $in_string = 0; |
|
1407 | + if ($in_string == 2) { |
|
1408 | + $in_string = 0; |
|
1409 | + } |
|
1366 | 1410 | // Otherwise it's the start! |
1367 | - else |
|
1368 | - $in_string = 2; |
|
1411 | + else { |
|
1412 | + $in_string = 2; |
|
1413 | + } |
|
1369 | 1414 | |
1370 | 1415 | // Don't actually include this character! |
1371 | 1416 | continue; |
1372 | 1417 | } |
1373 | 1418 | } |
1374 | 1419 | // A join/space outside of a string is simply removed. |
1375 | - elseif ($in_string == 0 && (empty($string{$i}) || $string{$i} == '.')) |
|
1376 | - continue; |
|
1420 | + elseif ($in_string == 0 && (empty($string{$i}) || $string{$i} == '.')) { |
|
1421 | + continue; |
|
1422 | + } |
|
1377 | 1423 | // Start of a variable? |
1378 | 1424 | elseif ($in_string == 0 && $string{$i} == '$') |
1379 | 1425 | { |
@@ -1407,8 +1453,7 @@ discard block |
||
1407 | 1453 | |
1408 | 1454 | // Unhtml then rehtml the whole thing! |
1409 | 1455 | $new_string = $smcFunc['htmlspecialchars'](un_htmlspecialchars($new_string)); |
1410 | - } |
|
1411 | - else |
|
1456 | + } else |
|
1412 | 1457 | { |
1413 | 1458 | // Keep track of what we're doing... |
1414 | 1459 | $in_string = 0; |
@@ -1437,10 +1482,11 @@ discard block |
||
1437 | 1482 | preg_match('~\{%([\$A-Za-z0-9\'\[\]_-]+)%\}~', substr($string, $i), $matches); |
1438 | 1483 | if (!empty($matches[1])) |
1439 | 1484 | { |
1440 | - if ($in_string == 1) |
|
1441 | - $new_string .= '\' . '; |
|
1442 | - elseif ($new_string) |
|
1443 | - $new_string .= ' . '; |
|
1485 | + if ($in_string == 1) { |
|
1486 | + $new_string .= '\' . '; |
|
1487 | + } elseif ($new_string) { |
|
1488 | + $new_string .= ' . '; |
|
1489 | + } |
|
1444 | 1490 | |
1445 | 1491 | $new_string .= $matches[1]; |
1446 | 1492 | $i += strlen($matches[1]) + 3; |
@@ -1453,8 +1499,9 @@ discard block |
||
1453 | 1499 | elseif ($string{$i} == '<') |
1454 | 1500 | { |
1455 | 1501 | // Probably HTML? |
1456 | - if ($string{$i + 1} != ' ') |
|
1457 | - $in_html = true; |
|
1502 | + if ($string{$i + 1} != ' ') { |
|
1503 | + $in_html = true; |
|
1504 | + } |
|
1458 | 1505 | // Assume we need an entity... |
1459 | 1506 | else |
1460 | 1507 | { |
@@ -1466,8 +1513,9 @@ discard block |
||
1466 | 1513 | elseif ($string{$i} == '>') |
1467 | 1514 | { |
1468 | 1515 | // Will it be HTML? |
1469 | - if ($in_html) |
|
1470 | - $in_html = false; |
|
1516 | + if ($in_html) { |
|
1517 | + $in_html = false; |
|
1518 | + } |
|
1471 | 1519 | // Otherwise we need an entity... |
1472 | 1520 | else |
1473 | 1521 | { |
@@ -1476,8 +1524,9 @@ discard block |
||
1476 | 1524 | } |
1477 | 1525 | } |
1478 | 1526 | // Is it a slash? If so escape it... |
1479 | - if ($string{$i} == '\\') |
|
1480 | - $new_string .= '\\'; |
|
1527 | + if ($string{$i} == '\\') { |
|
1528 | + $new_string .= '\\'; |
|
1529 | + } |
|
1481 | 1530 | // The infamous double quote? |
1482 | 1531 | elseif ($string{$i} == '"') |
1483 | 1532 | { |
@@ -1500,10 +1549,11 @@ discard block |
||
1500 | 1549 | } |
1501 | 1550 | |
1502 | 1551 | // If we ended as a string then close it off. |
1503 | - if ($in_string == 1) |
|
1504 | - $new_string .= '\''; |
|
1505 | - elseif ($in_string == 2) |
|
1506 | - $new_string .= '"'; |
|
1552 | + if ($in_string == 1) { |
|
1553 | + $new_string .= '\''; |
|
1554 | + } elseif ($in_string == 2) { |
|
1555 | + $new_string .= '"'; |
|
1556 | + } |
|
1507 | 1557 | } |
1508 | 1558 | |
1509 | 1559 | return $new_string; |
@@ -36,11 +36,12 @@ discard block |
||
36 | 36 | } |
37 | 37 | |
38 | 38 | // An error? |
39 | - if (!empty($context['error_message'])) |
|
40 | - echo ' |
|
39 | + if (!empty($context['error_message'])) { |
|
40 | + echo ' |
|
41 | 41 | <div class="errorbox"> |
42 | 42 | ', $context['error_message'], ' |
43 | 43 | </div>'; |
44 | + } |
|
44 | 45 | |
45 | 46 | // Provide something of an introduction... |
46 | 47 | echo ' |
@@ -67,11 +68,12 @@ discard block |
||
67 | 68 | // If the files are not writable, we might! |
68 | 69 | if (!empty($context['still_not_writable'])) |
69 | 70 | { |
70 | - if (!empty($context['package_ftp']['error'])) |
|
71 | - echo ' |
|
71 | + if (!empty($context['package_ftp']['error'])) { |
|
72 | + echo ' |
|
72 | 73 | <div class="errorbox"> |
73 | 74 | ', $context['package_ftp']['error'], ' |
74 | 75 | </div>'; |
76 | + } |
|
75 | 77 | |
76 | 78 | echo ' |
77 | 79 | <div class="cat_bar"> |
@@ -150,11 +152,12 @@ discard block |
||
150 | 152 | </div>'; |
151 | 153 | |
152 | 154 | // Not writable? Oops, show an error for ya. |
153 | - if (!empty($context['lang_file_not_writable_message'])) |
|
154 | - echo ' |
|
155 | + if (!empty($context['lang_file_not_writable_message'])) { |
|
156 | + echo ' |
|
155 | 157 | <div class="errorbox"> |
156 | 158 | ', $context['lang_file_not_writable_message'], ' |
157 | 159 | </div>'; |
160 | + } |
|
158 | 161 | |
159 | 162 | // Show the language entries |
160 | 163 | echo ' |
@@ -199,9 +202,10 @@ discard block |
||
199 | 202 | <input type="submit" name="save_main" value="', $txt['save'], '"', $context['lang_file_not_writable_message'] || !empty($context['file_entries']) ? ' disabled' : '', ' class="button">'; |
200 | 203 | |
201 | 204 | // Allow deleting entries. English can't be deleted though. |
202 | - if ($context['lang_id'] != 'english') |
|
203 | - echo ' |
|
205 | + if ($context['lang_id'] != 'english') { |
|
206 | + echo ' |
|
204 | 207 | <input type="submit" name="delete_main" value="', $txt['delete'], '"', $context['lang_file_not_writable_message'] || !empty($context['file_entries']) ? ' disabled' : '', ' onclick="confirm(\'', $txt['languages_delete_confirm'], '\');" class="button">'; |
208 | + } |
|
205 | 209 | |
206 | 210 | echo ' |
207 | 211 | </div><!-- .windowbg --> |
@@ -224,9 +228,10 @@ discard block |
||
224 | 228 | echo ' |
225 | 229 | <optgroup label="', $theme['name'], '">'; |
226 | 230 | |
227 | - foreach ($theme['files'] as $file) |
|
228 | - echo ' |
|
231 | + foreach ($theme['files'] as $file) { |
|
232 | + echo ' |
|
229 | 233 | <option value="', $id_theme, '+', $file['id'], '"', $file['selected'] ? ' selected' : '', '>', $file['name'], '</option>'; |
234 | + } |
|
230 | 235 | |
231 | 236 | echo ' |
232 | 237 | </optgroup>'; |
@@ -241,11 +246,12 @@ discard block |
||
241 | 246 | </div><!-- .information -->'; |
242 | 247 | |
243 | 248 | // Is it not writable? Show an error. |
244 | - if (!empty($context['entries_not_writable_message'])) |
|
245 | - echo ' |
|
249 | + if (!empty($context['entries_not_writable_message'])) { |
|
250 | + echo ' |
|
246 | 251 | <div class="errorbox"> |
247 | 252 | ', $context['entries_not_writable_message'], ' |
248 | 253 | </div>'; |
254 | + } |
|
249 | 255 | |
250 | 256 | // Already have some file entries? |
251 | 257 | if (!empty($context['file_entries'])) |
@@ -274,8 +280,8 @@ discard block |
||
274 | 280 | </dt> |
275 | 281 | <dd id="entry_', $entry_num, '">'; |
276 | 282 | |
277 | - if ($entry['can_remove']) |
|
278 | - echo ' |
|
283 | + if ($entry['can_remove']) { |
|
284 | + echo ' |
|
279 | 285 | <span style="margin-right: 1ch; white-space: nowrap"> |
280 | 286 | <input id="entry_', $entry_num, '_none" class="entry_toggle" type="radio" name="edit[', $entry['key'], ']" value="" data-target="#entry_', $entry_num, '" checked> |
281 | 287 | <label for="entry_', $entry_num, '_none">', $txt['no_change'], '</label> |
@@ -288,10 +294,11 @@ discard block |
||
288 | 294 | <input id="entry_', $entry_num, '_remove" class="entry_toggle" type="radio" name="edit[', $entry['key'], ']" value="remove" data-target="#entry_', $entry_num, '"> |
289 | 295 | <label for="entry_', $entry_num, '_remove">', $txt['remove'], '</label> |
290 | 296 | </span>'; |
291 | - else |
|
292 | - echo ' |
|
297 | + } else { |
|
298 | + echo ' |
|
293 | 299 | <input id="entry_', $entry_num, '_edit" class="entry_toggle" type="checkbox" name="edit[', $entry['key'], ']" value="edit" data-target="#entry_', $entry_num, '"> |
294 | 300 | <label for="entry_', $entry_num, '_edit">', $txt['edit'], '</label>'; |
301 | + } |
|
295 | 302 | |
296 | 303 | echo ' |
297 | 304 | </span> |
@@ -351,12 +358,13 @@ discard block |
||
351 | 358 | <input type="text" name="smf_add" size="40" value="', !empty($context['smf_search_term']) ? $context['smf_search_term'] : '', '">'; |
352 | 359 | |
353 | 360 | // Do we have some errors? Too bad. Display a little error box. |
354 | - if (!empty($context['smf_error'])) |
|
355 | - echo ' |
|
361 | + if (!empty($context['smf_error'])) { |
|
362 | + echo ' |
|
356 | 363 | <div> |
357 | 364 | <br> |
358 | 365 | <p class="errorbox">', $txt['add_language_error_' . $context['smf_error']], '</p> |
359 | 366 | </div>'; |
367 | + } |
|
360 | 368 | |
361 | 369 | echo ' |
362 | 370 | </fieldset> |