@@ -23,15 +23,15 @@ discard block |
||
23 | 23 | { |
24 | 24 | global $context, $txt; |
25 | 25 | |
26 | - if (!empty($context['simple_action'])) |
|
27 | - echo ' |
|
26 | + if (!empty($context['simple_action'])) { |
|
27 | + echo ' |
|
28 | 28 | <strong> |
29 | 29 | ', $context['error_title'], ' |
30 | 30 | </strong><br> |
31 | 31 | <div ', $context['error_code'], 'class="padding"> |
32 | 32 | ', $context['error_message'], ' |
33 | 33 | </div>'; |
34 | - else |
|
34 | + } else |
|
35 | 35 | { |
36 | 36 | echo ' |
37 | 37 | <div id="fatal_error"> |
@@ -85,21 +85,23 @@ discard block |
||
85 | 85 | |
86 | 86 | $error_types = array(); |
87 | 87 | |
88 | - foreach ($context['error_types'] as $type => $details) |
|
89 | - $error_types[] = ($details['is_selected'] ? '<img src="' . $settings['images_url'] . '/selected.png" alt=""> ' : '') . '<a href="' . $details['url'] . '" ' . ($details['is_selected'] ? 'style="font-weight: bold;"' : '') . ' title="' . $details['description'] . '">' . $details['label'] . '</a>'; |
|
88 | + foreach ($context['error_types'] as $type => $details) { |
|
89 | + $error_types[] = ($details['is_selected'] ? '<img src="' . $settings['images_url'] . '/selected.png" alt=""> ' : '') . '<a href="' . $details['url'] . '" ' . ($details['is_selected'] ? 'style="font-weight: bold;"' : '') . ' title="' . $details['description'] . '">' . $details['label'] . '</a>'; |
|
90 | + } |
|
90 | 91 | |
91 | 92 | echo ' |
92 | 93 | ', implode(' | ', $error_types), ' |
93 | 94 | </td> |
94 | 95 | </tr>'; |
95 | 96 | |
96 | - if ($context['has_filter']) |
|
97 | - echo ' |
|
97 | + if ($context['has_filter']) { |
|
98 | + echo ' |
|
98 | 99 | <tr> |
99 | 100 | <td colspan="3" class="windowbg"> |
100 | 101 | <strong>', $txt['applying_filter'], ':</strong> ', $context['filter']['entity'], ' ', $context['filter']['value']['html'], ' [<a href="', $scripturl, '?action=admin;area=logs;sa=errorlog', $context['sort_direction'] == 'down' ? ';desc' : '', '">', $txt['clear_filter'], '</a>] |
101 | 102 | </td> |
102 | 103 | </tr>'; |
104 | + } |
|
103 | 105 | |
104 | 106 | echo ' |
105 | 107 | <tr> |
@@ -110,11 +112,12 @@ discard block |
||
110 | 112 | </tr>'; |
111 | 113 | |
112 | 114 | // No errors, then show a message |
113 | - if (count($context['errors']) == 0) |
|
114 | - echo ' |
|
115 | + if (count($context['errors']) == 0) { |
|
116 | + echo ' |
|
115 | 117 | <tr class="windowbg"> |
116 | 118 | <td class="centertext" colspan="2">', $txt['errlog_no_entries'], '</td> |
117 | 119 | </tr>'; |
120 | + } |
|
118 | 121 | |
119 | 122 | // We have some errors, must be some mods installed :P |
120 | 123 | foreach ($context['errors'] as $error) |
@@ -128,19 +131,21 @@ discard block |
||
128 | 131 | <a href="', $scripturl, '?action=admin;area=logs;sa=errorlog', $context['sort_direction'] == 'down' ? '' : ';desc', $context['has_filter'] ? $context['filter']['href'] : '', '" title="', $txt['reverse_direction'], '"><span class="generic_icons sort_' . $context['sort_direction'] . '"></span></a> |
129 | 132 | ', $error['time'], '<br>'; |
130 | 133 | |
131 | - if (!empty($error['member']['ip'])) |
|
132 | - echo ' |
|
134 | + if (!empty($error['member']['ip'])) { |
|
135 | + echo ' |
|
133 | 136 | <a href="', $scripturl, '?action=admin;area=logs;sa=errorlog', $context['sort_direction'] == 'down' ? ';desc' : '', ';filter=ip;value=', $error['member']['ip'], '" title="', $txt['apply_filter'], ': ', $txt['filter_only_ip'], '"><span class="generic_icons filter centericon"></span></a> |
134 | 137 | <strong><a href="', $scripturl, '?action=trackip;searchip=', $error['member']['ip'], '">', $error['member']['ip'], '</a></strong>'; |
138 | + } |
|
135 | 139 | |
136 | 140 | echo ' |
137 | 141 | </div> |
138 | 142 | <div class="error_info">'; |
139 | 143 | |
140 | - if ($error['member']['session'] != '') |
|
141 | - echo ' |
|
144 | + if ($error['member']['session'] != '') { |
|
145 | + echo ' |
|
142 | 146 | <a href="', $scripturl, '?action=admin;area=logs;sa=errorlog', $context['sort_direction'] == 'down' ? ';desc' : '', ';filter=session;value=', $error['member']['session'], '" title="', $txt['apply_filter'], ': ', $txt['filter_only_session'], '"><span class="generic_icons filter centericon"></span></a> |
143 | 147 | ', $error['member']['session'], '<br>'; |
148 | + } |
|
144 | 149 | |
145 | 150 | echo ' |
146 | 151 | <a href="', $scripturl, '?action=admin;area=logs;sa=errorlog', $context['sort_direction'] == 'down' ? ';desc' : '', ';filter=error_type;value=', $error['error_type']['type'], '" title="', $txt['apply_filter'], ': ', $txt['filter_only_type'], '"><span class="generic_icons filter centericon"></span></a> |
@@ -154,8 +159,8 @@ discard block |
||
154 | 159 | <a href="', $error['url']['html'], '">', $error['url']['html'], '</a> |
155 | 160 | </div>'; |
156 | 161 | |
157 | - if (!empty($error['file'])) |
|
158 | - echo ' |
|
162 | + if (!empty($error['file'])) { |
|
163 | + echo ' |
|
159 | 164 | <div class="error_location"> |
160 | 165 | <a href="', $scripturl, '?action=admin;area=logs;sa=errorlog', $context['sort_direction'] == 'down' ? ';desc' : '', ';filter=file;value=', $error['file']['search'], '" title="', $txt['apply_filter'], ': ', $txt['filter_only_file'], '"><span class="generic_icons filter"></span></a> |
161 | 166 | <div> |
@@ -163,6 +168,7 @@ discard block |
||
163 | 168 | ', $txt['line'], ': ', $error['file']['line'], ' |
164 | 169 | </div> |
165 | 170 | </div>'; |
171 | + } |
|
166 | 172 | |
167 | 173 | echo ' |
168 | 174 | </td> |
@@ -190,9 +196,10 @@ discard block |
||
190 | 196 | </div> |
191 | 197 | </div>'; |
192 | 198 | |
193 | - if ($context['sort_direction'] == 'down') |
|
194 | - echo ' |
|
199 | + if ($context['sort_direction'] == 'down') { |
|
200 | + echo ' |
|
195 | 201 | <input type="hidden" name="desc" value="1">'; |
202 | + } |
|
196 | 203 | |
197 | 204 | echo ' |
198 | 205 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -41,37 +41,43 @@ discard block |
||
41 | 41 | define('TIME_START', microtime(true)); |
42 | 42 | |
43 | 43 | // Just being safe... |
44 | -foreach (array('db_character_set', 'cachedir') as $variable) |
|
44 | +foreach (array('db_character_set', 'cachedir') as $variable) { |
|
45 | 45 | if (isset($GLOBALS[$variable])) |
46 | 46 | unset($GLOBALS[$variable]); |
47 | +} |
|
47 | 48 | |
48 | 49 | // Get the forum's settings for database and file paths. |
49 | 50 | require_once(dirname(__FILE__) . '/Settings.php'); |
50 | 51 | |
51 | 52 | // Make absolutely sure the cache directory is defined. |
52 | -if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache')) |
|
53 | +if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache')) { |
|
53 | 54 | $cachedir = $boarddir . '/cache'; |
55 | +} |
|
54 | 56 | |
55 | 57 | // Don't do john didley if the forum's been shut down competely. |
56 | -if ($maintenance == 2) |
|
58 | +if ($maintenance == 2) { |
|
57 | 59 | die($mmessage); |
60 | +} |
|
58 | 61 | |
59 | 62 | // Fix for using the current directory as a path. |
60 | -if (substr($sourcedir, 0, 1) == '.' && substr($sourcedir, 1, 1) != '.') |
|
63 | +if (substr($sourcedir, 0, 1) == '.' && substr($sourcedir, 1, 1) != '.') { |
|
61 | 64 | $sourcedir = dirname(__FILE__) . substr($sourcedir, 1); |
65 | +} |
|
62 | 66 | |
63 | 67 | // Have we already turned this off? If so, exist gracefully. |
64 | -if (file_exists($cachedir . '/cron.lock')) |
|
68 | +if (file_exists($cachedir . '/cron.lock')) { |
|
65 | 69 | obExit_cron(); |
70 | +} |
|
66 | 71 | |
67 | 72 | // Before we go any further, if this is not a CLI request, we need to do some checking. |
68 | 73 | if (!FROM_CLI) |
69 | 74 | { |
70 | 75 | // We will clean up $_GET shortly. But we want to this ASAP. |
71 | 76 | $ts = isset($_GET['ts']) ? (int) $_GET['ts'] : 0; |
72 | - if ($ts <= 0 || $ts % 15 != 0 || time() - $ts < 0 || time() - $ts > 20) |
|
73 | - obExit_cron(); |
|
74 | -} |
|
77 | + if ($ts <= 0 || $ts % 15 != 0 || time() - $ts < 0 || time() - $ts > 20) { |
|
78 | + obExit_cron(); |
|
79 | + } |
|
80 | + } |
|
75 | 81 | |
76 | 82 | // Load the most important includes. In general, a background should be loading its own dependencies. |
77 | 83 | require_once($sourcedir . '/Errors.php'); |
@@ -123,8 +129,9 @@ discard block |
||
123 | 129 | global $smcFunc; |
124 | 130 | |
125 | 131 | // Check we haven't run over our time limit. |
126 | - if (microtime(true) - TIME_START > MAX_CRON_TIME) |
|
127 | - return false; |
|
132 | + if (microtime(true) - TIME_START > MAX_CRON_TIME) { |
|
133 | + return false; |
|
134 | + } |
|
128 | 135 | |
129 | 136 | // Try to find a task. Specifically, try to find one that hasn't been claimed previously, or failing that, |
130 | 137 | // a task that was claimed but failed for whatever reason and failed long enough ago. We should not care |
@@ -159,14 +166,12 @@ discard block |
||
159 | 166 | // Update the time and go back. |
160 | 167 | $row['claimed_time'] = time(); |
161 | 168 | return $row; |
162 | - } |
|
163 | - else |
|
169 | + } else |
|
164 | 170 | { |
165 | 171 | // Uh oh, we just missed it. Try to claim another one, and let it fall through if there aren't any. |
166 | 172 | return fetch_task(); |
167 | 173 | } |
168 | - } |
|
169 | - else |
|
174 | + } else |
|
170 | 175 | { |
171 | 176 | // No dice. Clean up and go home. |
172 | 177 | $smcFunc['db_free_result']($request); |
@@ -187,8 +192,9 @@ discard block |
||
187 | 192 | if (!empty($task_details['task_file'])) |
188 | 193 | { |
189 | 194 | $include = strtr(trim($task_details['task_file']), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir)); |
190 | - if (file_exists($include)) |
|
191 | - require_once($include); |
|
195 | + if (file_exists($include)) { |
|
196 | + require_once($include); |
|
197 | + } |
|
192 | 198 | } |
193 | 199 | |
194 | 200 | if (empty($task_details['task_class'])) |
@@ -204,8 +210,7 @@ discard block |
||
204 | 210 | $details = empty($task_details['task_data']) ? array() : $smcFunc['json_decode']($task_details['task_data'], true); |
205 | 211 | $bgtask = new $task_details['task_class']($details); |
206 | 212 | return $bgtask->execute(); |
207 | - } |
|
208 | - else |
|
213 | + } else |
|
209 | 214 | { |
210 | 215 | log_error('Invalid background task specified: (class: ' . $task_details['task_class'] . ', ' . (empty($task_details['task_file']) ? ' no file' : ' to load ' . $task_details['task_file']) . ')'); |
211 | 216 | return true; // So we clear it from the queue. |
@@ -224,8 +229,9 @@ discard block |
||
224 | 229 | $scripturl = $boardurl . '/index.php'; |
225 | 230 | |
226 | 231 | // These keys shouldn't be set...ever. |
227 | - if (isset($_REQUEST['GLOBALS']) || isset($_COOKIE['GLOBALS'])) |
|
228 | - die('Invalid request variable.'); |
|
232 | + if (isset($_REQUEST['GLOBALS']) || isset($_COOKIE['GLOBALS'])) { |
|
233 | + die('Invalid request variable.'); |
|
234 | + } |
|
229 | 235 | |
230 | 236 | // Save some memory.. (since we don't use these anyway.) |
231 | 237 | unset($GLOBALS['HTTP_POST_VARS'], $GLOBALS['HTTP_POST_VARS']); |
@@ -246,26 +252,28 @@ discard block |
||
246 | 252 | global $modSettings; |
247 | 253 | |
248 | 254 | // Ignore errors if we're ignoring them or they are strict notices from PHP 5 |
249 | - if (error_reporting() == 0) |
|
250 | - return; |
|
255 | + if (error_reporting() == 0) { |
|
256 | + return; |
|
257 | + } |
|
251 | 258 | |
252 | 259 | $error_type = 'cron'; |
253 | 260 | |
254 | 261 | log_error($error_level . ': ' . $error_string, $error_type, $file, $line); |
255 | 262 | |
256 | 263 | // If this is an E_ERROR or E_USER_ERROR.... die. Violently so. |
257 | - if ($error_level % 255 == E_ERROR) |
|
258 | - die('No direct access...'); |
|
259 | -} |
|
264 | + if ($error_level % 255 == E_ERROR) { |
|
265 | + die('No direct access...'); |
|
266 | + } |
|
267 | + } |
|
260 | 268 | |
261 | 269 | /** |
262 | 270 | * The exit function |
263 | 271 | */ |
264 | 272 | function obExit_cron() |
265 | 273 | { |
266 | - if (FROM_CLI) |
|
267 | - die(0); |
|
268 | - else |
|
274 | + if (FROM_CLI) { |
|
275 | + die(0); |
|
276 | + } else |
|
269 | 277 | { |
270 | 278 | header('Content-Type: image/gif'); |
271 | 279 | die("\x47\x49\x46\x38\x39\x61\x01\x00\x01\x00\x80\x00\x00\x00\x00\x00\x00\x00\x00\x21\xF9\x04\x01\x00\x00\x00\x00\x2C\x00\x00\x00\x00\x01\x00\x01\x00\x00\x02\x02\x44\x01\x00\x3B"); |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 4 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | class Attachments |
20 | 21 | { |
@@ -70,16 +71,18 @@ discard block |
||
70 | 71 | |
71 | 72 | $this->_sa = !empty($_REQUEST['sa']) ? $smcFunc['htmlspecialchars']($smcFunc['htmltrim']($_REQUEST['sa'])) : false; |
72 | 73 | |
73 | - if ($this->_canPostAttachment && $this->_sa && in_array($this->_sa, $this->_subActions)) |
|
74 | - $this->{$this->_sa}(); |
|
74 | + if ($this->_canPostAttachment && $this->_sa && in_array($this->_sa, $this->_subActions)) { |
|
75 | + $this->{$this->_sa}(); |
|
76 | + } |
|
75 | 77 | |
76 | 78 | // Just send a generic message. |
77 | - else |
|
78 | - $this->setResponse(array( |
|
79 | + else { |
|
80 | + $this->setResponse(array( |
|
79 | 81 | 'text' => $this->_sa == 'add' ? 'attach_error_title' : 'attached_file_deleted_error', |
80 | 82 | 'type' => 'error', |
81 | 83 | 'data' => false, |
82 | 84 | )); |
85 | + } |
|
83 | 86 | |
84 | 87 | // Back to the future, oh, to the browser! |
85 | 88 | $this->sendResponse(); |
@@ -95,12 +98,13 @@ discard block |
||
95 | 98 | $attachID = !empty($_REQUEST['attach']) && is_numeric($_REQUEST['attach']) ? (int) $_REQUEST['attach'] : 0; |
96 | 99 | |
97 | 100 | // Need something to work with. |
98 | - if (!$attachID || (!empty($_SESSION['already_attached']) && !isset($_SESSION['already_attached'][$attachID]))) |
|
99 | - return $this->setResponse(array( |
|
101 | + if (!$attachID || (!empty($_SESSION['already_attached']) && !isset($_SESSION['already_attached'][$attachID]))) { |
|
102 | + return $this->setResponse(array( |
|
100 | 103 | 'text' => 'attached_file_deleted_error', |
101 | 104 | 'type' => 'error', |
102 | 105 | 'data' => false, |
103 | 106 | )); |
107 | + } |
|
104 | 108 | |
105 | 109 | // Lets pass some params and see what happens :P |
106 | 110 | $affectedMessage = removeAttachments(array('id_attach' => $attachID), '', true, true); |
@@ -119,19 +123,21 @@ discard block |
||
119 | 123 | public function add() |
120 | 124 | { |
121 | 125 | // You gotta be able to post attachments. |
122 | - if (!$this->_canPostAttachment) |
|
123 | - return $this->setResponse(array( |
|
126 | + if (!$this->_canPostAttachment) { |
|
127 | + return $this->setResponse(array( |
|
124 | 128 | 'text' => 'attached_file_cannot', |
125 | 129 | 'type' => 'error', |
126 | 130 | 'data' => false, |
127 | 131 | )); |
132 | + } |
|
128 | 133 | |
129 | 134 | // Process them at once! |
130 | 135 | $this->processAttachments(); |
131 | 136 | |
132 | 137 | // The attachments was created and moved the the right folder, time to update the DB. |
133 | - if (!empty($_SESSION['temp_attachments'])) |
|
134 | - $this->createAtttach(); |
|
138 | + if (!empty($_SESSION['temp_attachments'])) { |
|
139 | + $this->createAtttach(); |
|
140 | + } |
|
135 | 141 | |
136 | 142 | // Set the response. |
137 | 143 | $this->setResponse(); |
@@ -144,8 +150,9 @@ discard block |
||
144 | 150 | { |
145 | 151 | global $context, $modSettings, $smcFunc, $user_info, $txt; |
146 | 152 | |
147 | - if (!isset($_FILES['attachment']['name'])) |
|
148 | - $_FILES['attachment']['tmp_name'] = array(); |
|
153 | + if (!isset($_FILES['attachment']['name'])) { |
|
154 | + $_FILES['attachment']['tmp_name'] = array(); |
|
155 | + } |
|
149 | 156 | |
150 | 157 | // If there are attachments, calculate the total size and how many. |
151 | 158 | $context['attachments']['total_size'] = 0; |
@@ -155,25 +162,30 @@ discard block |
||
155 | 162 | if (isset($_REQUEST['msg'])) |
156 | 163 | { |
157 | 164 | $context['attachments']['quantity'] = count($context['current_attachments']); |
158 | - foreach ($context['current_attachments'] as $attachment) |
|
159 | - $context['attachments']['total_size'] += $attachment['size']; |
|
165 | + foreach ($context['current_attachments'] as $attachment) { |
|
166 | + $context['attachments']['total_size'] += $attachment['size']; |
|
167 | + } |
|
160 | 168 | } |
161 | 169 | |
162 | 170 | // A bit of house keeping first. |
163 | - if (!empty($_SESSION['temp_attachments']) && count($_SESSION['temp_attachments']) == 1) |
|
164 | - unset($_SESSION['temp_attachments']); |
|
171 | + if (!empty($_SESSION['temp_attachments']) && count($_SESSION['temp_attachments']) == 1) { |
|
172 | + unset($_SESSION['temp_attachments']); |
|
173 | + } |
|
165 | 174 | |
166 | 175 | // Our infamous SESSION var, we are gonna have soo much fun with it! |
167 | - if (!isset($_SESSION['temp_attachments'])) |
|
168 | - $_SESSION['temp_attachments'] = array(); |
|
176 | + if (!isset($_SESSION['temp_attachments'])) { |
|
177 | + $_SESSION['temp_attachments'] = array(); |
|
178 | + } |
|
169 | 179 | |
170 | 180 | // Make sure we're uploading to the right place. |
171 | - if (!empty($modSettings['automanage_attachments'])) |
|
172 | - automanage_attachments_check_directory(); |
|
181 | + if (!empty($modSettings['automanage_attachments'])) { |
|
182 | + automanage_attachments_check_directory(); |
|
183 | + } |
|
173 | 184 | |
174 | 185 | // Is the attachments folder actually there? |
175 | - if (!empty($context['dir_creation_error'])) |
|
176 | - $this->_generalErrors[] = $context['dir_creation_error']; |
|
186 | + if (!empty($context['dir_creation_error'])) { |
|
187 | + $this->_generalErrors[] = $context['dir_creation_error']; |
|
188 | + } |
|
177 | 189 | |
178 | 190 | // The current attach folder ha some issues... |
179 | 191 | elseif (!is_dir($this->_attchDir)) |
@@ -198,13 +210,12 @@ discard block |
||
198 | 210 | ); |
199 | 211 | list ($context['attachments']['quantity'], $context['attachments']['total_size']) = $smcFunc['db_fetch_row']($request); |
200 | 212 | $smcFunc['db_free_result']($request); |
201 | - } |
|
202 | - |
|
203 | - else |
|
204 | - $context['attachments'] = array( |
|
213 | + } else { |
|
214 | + $context['attachments'] = array( |
|
205 | 215 | 'quantity' => 0, |
206 | 216 | 'total_size' => 0, |
207 | 217 | ); |
218 | + } |
|
208 | 219 | |
209 | 220 | // Check for other general errors here. |
210 | 221 | |
@@ -212,9 +223,10 @@ discard block |
||
212 | 223 | if (!empty($this->_generalErrors)) |
213 | 224 | { |
214 | 225 | // And delete the files 'cos they ain't going nowhere. |
215 | - foreach ($_FILES['attachment']['tmp_name'] as $n => $dummy) |
|
216 | - if (file_exists($_FILES['attachment']['tmp_name'][$n])) |
|
226 | + foreach ($_FILES['attachment']['tmp_name'] as $n => $dummy) { |
|
227 | + if (file_exists($_FILES['attachment']['tmp_name'][$n])) |
|
217 | 228 | unlink($_FILES['attachment']['tmp_name'][$n]); |
229 | + } |
|
218 | 230 | |
219 | 231 | $_FILES['attachment']['tmp_name'] = array(); |
220 | 232 | |
@@ -225,26 +237,29 @@ discard block |
||
225 | 237 | // Loop through $_FILES['attachment'] array and move each file to the current attachments folder. |
226 | 238 | foreach ($_FILES['attachment']['tmp_name'] as $n => $dummy) |
227 | 239 | { |
228 | - if ($_FILES['attachment']['name'][$n] == '') |
|
229 | - continue; |
|
240 | + if ($_FILES['attachment']['name'][$n] == '') { |
|
241 | + continue; |
|
242 | + } |
|
230 | 243 | |
231 | 244 | // First, let's first check for PHP upload errors. |
232 | 245 | $errors = array(); |
233 | 246 | if (!empty($_FILES['attachment']['error'][$n])) |
234 | 247 | { |
235 | - if ($_FILES['attachment']['error'][$n] == 2) |
|
236 | - $errors[] = array('file_too_big', array($modSettings['attachmentSizeLimit'])); |
|
237 | - |
|
238 | - else |
|
239 | - log_error($_FILES['attachment']['name'][$n] . ': ' . $txt['php_upload_error_' . $_FILES['attachment']['error'][$n]]); |
|
248 | + if ($_FILES['attachment']['error'][$n] == 2) { |
|
249 | + $errors[] = array('file_too_big', array($modSettings['attachmentSizeLimit'])); |
|
250 | + } else { |
|
251 | + log_error($_FILES['attachment']['name'][$n] . ': ' . $txt['php_upload_error_' . $_FILES['attachment']['error'][$n]]); |
|
252 | + } |
|
240 | 253 | |
241 | 254 | // Log this one, because... |
242 | - if ($_FILES['attachment']['error'][$n] == 6) |
|
243 | - log_error($_FILES['attachment']['name'][$n] . ': ' . $txt['php_upload_error_6'], 'critical'); |
|
255 | + if ($_FILES['attachment']['error'][$n] == 6) { |
|
256 | + log_error($_FILES['attachment']['name'][$n] . ': ' . $txt['php_upload_error_6'], 'critical'); |
|
257 | + } |
|
244 | 258 | |
245 | 259 | // Weird, no errors were cached, still fill out a generic one. |
246 | - if (empty($errors)) |
|
247 | - $errors[] = 'attach_php_error'; |
|
260 | + if (empty($errors)) { |
|
261 | + $errors[] = 'attach_php_error'; |
|
262 | + } |
|
248 | 263 | } |
249 | 264 | |
250 | 265 | // Try to move and rename the file before doing any more checks on it. |
@@ -256,8 +271,9 @@ discard block |
||
256 | 271 | { |
257 | 272 | // The reported MIME type of the attachment might not be reliable. |
258 | 273 | // Fortunately, PHP 5.3+ lets us easily verify the real MIME type. |
259 | - if (function_exists('mime_content_type')) |
|
260 | - $_FILES['attachment']['type'][$n] = mime_content_type($_FILES['attachment']['tmp_name'][$n]); |
|
274 | + if (function_exists('mime_content_type')) { |
|
275 | + $_FILES['attachment']['type'][$n] = mime_content_type($_FILES['attachment']['tmp_name'][$n]); |
|
276 | + } |
|
261 | 277 | |
262 | 278 | $_SESSION['temp_attachments'][$attachID] = array( |
263 | 279 | 'name' => $smcFunc['htmlspecialchars'](basename($_FILES['attachment']['name'][$n])), |
@@ -269,16 +285,18 @@ discard block |
||
269 | 285 | ); |
270 | 286 | |
271 | 287 | // Move the file to the attachments folder with a temp name for now. |
272 | - if (@move_uploaded_file($_FILES['attachment']['tmp_name'][$n], $destName)) |
|
273 | - smf_chmod($destName, 0644); |
|
288 | + if (@move_uploaded_file($_FILES['attachment']['tmp_name'][$n], $destName)) { |
|
289 | + smf_chmod($destName, 0644); |
|
290 | + } |
|
274 | 291 | |
275 | 292 | // This is madness!! |
276 | 293 | else |
277 | 294 | { |
278 | 295 | // File couldn't be moved. |
279 | 296 | $_SESSION['temp_attachments'][$attachID]['errors'][] = 'attach_timeout'; |
280 | - if (file_exists($_FILES['attachment']['tmp_name'][$n])) |
|
281 | - unlink($_FILES['attachment']['tmp_name'][$n]); |
|
297 | + if (file_exists($_FILES['attachment']['tmp_name'][$n])) { |
|
298 | + unlink($_FILES['attachment']['tmp_name'][$n]); |
|
299 | + } |
|
282 | 300 | } |
283 | 301 | } |
284 | 302 | |
@@ -291,13 +309,15 @@ discard block |
||
291 | 309 | 'errors' => $errors, |
292 | 310 | ); |
293 | 311 | |
294 | - if (file_exists($_FILES['attachment']['tmp_name'][$n])) |
|
295 | - unlink($_FILES['attachment']['tmp_name'][$n]); |
|
312 | + if (file_exists($_FILES['attachment']['tmp_name'][$n])) { |
|
313 | + unlink($_FILES['attachment']['tmp_name'][$n]); |
|
314 | + } |
|
296 | 315 | } |
297 | 316 | |
298 | 317 | // If there's no errors to this point. We still do need to apply some additional checks before we are finished. |
299 | - if (empty($_SESSION['temp_attachments'][$attachID]['errors'])) |
|
300 | - attachmentChecks($attachID); |
|
318 | + if (empty($_SESSION['temp_attachments'][$attachID]['errors'])) { |
|
319 | + attachmentChecks($attachID); |
|
320 | + } |
|
301 | 321 | } |
302 | 322 | |
303 | 323 | // Mod authors, finally a hook to hang an alternate attachment upload system upon |
@@ -344,14 +364,15 @@ discard block |
||
344 | 364 | |
345 | 365 | $_SESSION['already_attached'][$attachmentOptions['attachID']] = $attachmentOptions['attachID']; |
346 | 366 | |
347 | - if (!empty($attachmentOptions['thumb'])) |
|
348 | - $_SESSION['already_attached'][$attachmentOptions['thumb']] = $attachmentOptions['thumb']; |
|
367 | + if (!empty($attachmentOptions['thumb'])) { |
|
368 | + $_SESSION['already_attached'][$attachmentOptions['thumb']] = $attachmentOptions['thumb']; |
|
369 | + } |
|
349 | 370 | |
350 | - if ($this->_msg) |
|
351 | - assignAttachments($_SESSION['already_attached'], $this->_msg); |
|
371 | + if ($this->_msg) { |
|
372 | + assignAttachments($_SESSION['already_attached'], $this->_msg); |
|
373 | + } |
|
352 | 374 | } |
353 | - } |
|
354 | - else |
|
375 | + } else |
|
355 | 376 | { |
356 | 377 | // Sort out the errors for display and delete any associated files. |
357 | 378 | $log_these = array('attachments_no_create', 'attachments_no_write', 'attach_timeout', 'ran_out_of_space', 'cant_access_upload_path', 'attach_0_byte_file'); |
@@ -363,14 +384,16 @@ discard block |
||
363 | 384 | if (!is_array($error)) |
364 | 385 | { |
365 | 386 | $attachmentOptions['errors'][] = $txt[$error]; |
366 | - if (in_array($error, $log_these)) |
|
367 | - log_error($attachment['name'] . ': ' . $txt[$error], 'critical'); |
|
387 | + if (in_array($error, $log_these)) { |
|
388 | + log_error($attachment['name'] . ': ' . $txt[$error], 'critical'); |
|
389 | + } |
|
390 | + } else { |
|
391 | + $attachmentOptions['errors'][] = vsprintf($txt[$error[0]], $error[1]); |
|
368 | 392 | } |
369 | - else |
|
370 | - $attachmentOptions['errors'][] = vsprintf($txt[$error[0]], $error[1]); |
|
371 | 393 | } |
372 | - if (file_exists($attachment['tmp_name'])) |
|
373 | - unlink($attachment['tmp_name']); |
|
394 | + if (file_exists($attachment['tmp_name'])) { |
|
395 | + unlink($attachment['tmp_name']); |
|
396 | + } |
|
374 | 397 | } |
375 | 398 | |
376 | 399 | // You don't need to know. |
@@ -382,8 +405,9 @@ discard block |
||
382 | 405 | } |
383 | 406 | |
384 | 407 | // Temp save this on the db. |
385 | - if (!empty($_SESSION['already_attached'])) |
|
386 | - $this->_attachSuccess = $_SESSION['already_attached']; |
|
408 | + if (!empty($_SESSION['already_attached'])) { |
|
409 | + $this->_attachSuccess = $_SESSION['already_attached']; |
|
410 | + } |
|
387 | 411 | |
388 | 412 | unset($_SESSION['temp_attachments']); |
389 | 413 | } |
@@ -403,14 +427,16 @@ discard block |
||
403 | 427 | if ($this->_sa == 'add') |
404 | 428 | { |
405 | 429 | // Is there any generic errors? made some sense out of them! |
406 | - if ($this->_generalErrors) |
|
407 | - foreach ($this->_generalErrors as $k => $v) |
|
430 | + if ($this->_generalErrors) { |
|
431 | + foreach ($this->_generalErrors as $k => $v) |
|
408 | 432 | $this->_generalErrors[$k] = (is_array($v) ? vsprintf($txt[$v[0]], $v[1]) : $txt[$v]); |
433 | + } |
|
409 | 434 | |
410 | 435 | // Gotta urlencode the filename. |
411 | - if ($this->_attachResults) |
|
412 | - foreach ($this->_attachResults as $k => $v) |
|
436 | + if ($this->_attachResults) { |
|
437 | + foreach ($this->_attachResults as $k => $v) |
|
413 | 438 | $this->_attachResults[$k]['name'] = urlencode($this->_attachResults[$k]['name']); |
439 | + } |
|
414 | 440 | |
415 | 441 | $this->_response = array( |
416 | 442 | 'files' => $this->_attachResults ? $this->_attachResults : false, |
@@ -419,9 +445,10 @@ discard block |
||
419 | 445 | } |
420 | 446 | |
421 | 447 | // Rest of us mere mortals gets no special treatment... |
422 | - elseif (!empty($data)) |
|
423 | - if (!empty($data['text']) && !empty($txt[$data['text']])) |
|
448 | + elseif (!empty($data)) { |
|
449 | + if (!empty($data['text']) && !empty($txt[$data['text']])) |
|
424 | 450 | $this->_response['text'] = $txt[$data['text']]; |
451 | + } |
|
425 | 452 | } |
426 | 453 | |
427 | 454 | protected function sendResponse() |
@@ -430,11 +457,11 @@ discard block |
||
430 | 457 | |
431 | 458 | ob_end_clean(); |
432 | 459 | |
433 | - if (!empty($modSettings['CompressedOutput'])) |
|
434 | - @ob_start('ob_gzhandler'); |
|
435 | - |
|
436 | - else |
|
437 | - ob_start(); |
|
460 | + if (!empty($modSettings['CompressedOutput'])) { |
|
461 | + @ob_start('ob_gzhandler'); |
|
462 | + } else { |
|
463 | + ob_start(); |
|
464 | + } |
|
438 | 465 | |
439 | 466 | // Set the header. |
440 | 467 | header('Content-Type: application/json; charset='. $context['character_set'] .''); |
@@ -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 | * Load the $modSettings array. |
@@ -25,13 +26,14 @@ discard block |
||
25 | 26 | global $cache_enable, $sourcedir, $context; |
26 | 27 | |
27 | 28 | // Most database systems have not set UTF-8 as their default input charset. |
28 | - if (!empty($db_character_set)) |
|
29 | - $smcFunc['db_query']('', ' |
|
29 | + if (!empty($db_character_set)) { |
|
30 | + $smcFunc['db_query']('', ' |
|
30 | 31 | SET NAMES {string:db_character_set}', |
31 | 32 | array( |
32 | 33 | 'db_character_set' => $db_character_set, |
33 | 34 | ) |
34 | 35 | ); |
36 | + } |
|
35 | 37 | |
36 | 38 | // We need some caching support, maybe. |
37 | 39 | loadCacheAccelerator(); |
@@ -46,28 +48,36 @@ discard block |
||
46 | 48 | ) |
47 | 49 | ); |
48 | 50 | $modSettings = array(); |
49 | - if (!$request) |
|
50 | - display_db_error(); |
|
51 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
52 | - $modSettings[$row[0]] = $row[1]; |
|
51 | + if (!$request) { |
|
52 | + display_db_error(); |
|
53 | + } |
|
54 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
55 | + $modSettings[$row[0]] = $row[1]; |
|
56 | + } |
|
53 | 57 | $smcFunc['db_free_result']($request); |
54 | 58 | |
55 | 59 | // Do a few things to protect against missing settings or settings with invalid values... |
56 | - if (empty($modSettings['defaultMaxTopics']) || $modSettings['defaultMaxTopics'] <= 0 || $modSettings['defaultMaxTopics'] > 999) |
|
57 | - $modSettings['defaultMaxTopics'] = 20; |
|
58 | - if (empty($modSettings['defaultMaxMessages']) || $modSettings['defaultMaxMessages'] <= 0 || $modSettings['defaultMaxMessages'] > 999) |
|
59 | - $modSettings['defaultMaxMessages'] = 15; |
|
60 | - if (empty($modSettings['defaultMaxMembers']) || $modSettings['defaultMaxMembers'] <= 0 || $modSettings['defaultMaxMembers'] > 999) |
|
61 | - $modSettings['defaultMaxMembers'] = 30; |
|
62 | - if (empty($modSettings['defaultMaxListItems']) || $modSettings['defaultMaxListItems'] <= 0 || $modSettings['defaultMaxListItems'] > 999) |
|
63 | - $modSettings['defaultMaxListItems'] = 15; |
|
60 | + if (empty($modSettings['defaultMaxTopics']) || $modSettings['defaultMaxTopics'] <= 0 || $modSettings['defaultMaxTopics'] > 999) { |
|
61 | + $modSettings['defaultMaxTopics'] = 20; |
|
62 | + } |
|
63 | + if (empty($modSettings['defaultMaxMessages']) || $modSettings['defaultMaxMessages'] <= 0 || $modSettings['defaultMaxMessages'] > 999) { |
|
64 | + $modSettings['defaultMaxMessages'] = 15; |
|
65 | + } |
|
66 | + if (empty($modSettings['defaultMaxMembers']) || $modSettings['defaultMaxMembers'] <= 0 || $modSettings['defaultMaxMembers'] > 999) { |
|
67 | + $modSettings['defaultMaxMembers'] = 30; |
|
68 | + } |
|
69 | + if (empty($modSettings['defaultMaxListItems']) || $modSettings['defaultMaxListItems'] <= 0 || $modSettings['defaultMaxListItems'] > 999) { |
|
70 | + $modSettings['defaultMaxListItems'] = 15; |
|
71 | + } |
|
64 | 72 | |
65 | 73 | // We excpiclity do not use $smcFunc['json_decode'] here yet, as $smcFunc is not fully loaded. |
66 | - if (!is_array($modSettings['attachmentUploadDir'])) |
|
67 | - $modSettings['attachmentUploadDir'] = smf_json_decode($modSettings['attachmentUploadDir'], true); |
|
74 | + if (!is_array($modSettings['attachmentUploadDir'])) { |
|
75 | + $modSettings['attachmentUploadDir'] = smf_json_decode($modSettings['attachmentUploadDir'], true); |
|
76 | + } |
|
68 | 77 | |
69 | - if (!empty($cache_enable)) |
|
70 | - cache_put_data('modSettings', $modSettings, 90); |
|
78 | + if (!empty($cache_enable)) { |
|
79 | + cache_put_data('modSettings', $modSettings, 90); |
|
80 | + } |
|
71 | 81 | } |
72 | 82 | |
73 | 83 | $modSettings['cache_enable'] = $cache_enable; |
@@ -87,8 +97,9 @@ discard block |
||
87 | 97 | }; |
88 | 98 | $fix_utf8mb4 = function($string) use ($utf8, $smcFunc) |
89 | 99 | { |
90 | - if (!$utf8 || $smcFunc['db_mb4']) |
|
91 | - return $string; |
|
100 | + if (!$utf8 || $smcFunc['db_mb4']) { |
|
101 | + return $string; |
|
102 | + } |
|
92 | 103 | |
93 | 104 | $i = 0; |
94 | 105 | $len = strlen($string); |
@@ -100,18 +111,15 @@ discard block |
||
100 | 111 | { |
101 | 112 | $new_string .= $string[$i]; |
102 | 113 | $i++; |
103 | - } |
|
104 | - elseif ($ord < 224) |
|
114 | + } elseif ($ord < 224) |
|
105 | 115 | { |
106 | 116 | $new_string .= $string[$i] . $string[$i + 1]; |
107 | 117 | $i += 2; |
108 | - } |
|
109 | - elseif ($ord < 240) |
|
118 | + } elseif ($ord < 240) |
|
110 | 119 | { |
111 | 120 | $new_string .= $string[$i] . $string[$i + 1] . $string[$i + 2]; |
112 | 121 | $i += 3; |
113 | - } |
|
114 | - elseif ($ord < 248) |
|
122 | + } elseif ($ord < 248) |
|
115 | 123 | { |
116 | 124 | // Magic happens. |
117 | 125 | $val = (ord($string[$i]) & 0x07) << 18; |
@@ -155,8 +163,7 @@ discard block |
||
155 | 163 | { |
156 | 164 | $result = array_search($needle, array_slice($haystack_arr, $offset)); |
157 | 165 | return is_int($result) ? $result + $offset : false; |
158 | - } |
|
159 | - else |
|
166 | + } else |
|
160 | 167 | { |
161 | 168 | $needle_arr = preg_split('~(&#' . (empty($modSettings['disableEntityCheck']) ? '\d{1,7}' : '021') . ';|"|&|<|>| |.)~' . ($utf8 ? 'u' : '') . '', $ent_check($needle), -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); |
162 | 169 | $needle_size = count($needle_arr); |
@@ -165,8 +172,9 @@ discard block |
||
165 | 172 | while ((int) $result === $result) |
166 | 173 | { |
167 | 174 | $offset += $result; |
168 | - if (array_slice($haystack_arr, $offset, $needle_size) === $needle_arr) |
|
169 | - return $offset; |
|
175 | + if (array_slice($haystack_arr, $offset, $needle_size) === $needle_arr) { |
|
176 | + return $offset; |
|
177 | + } |
|
170 | 178 | $result = array_search($needle_arr[0], array_slice($haystack_arr, ++$offset)); |
171 | 179 | } |
172 | 180 | return false; |
@@ -204,8 +212,9 @@ discard block |
||
204 | 212 | $string = $ent_check($string); |
205 | 213 | preg_match('~^(' . $ent_list . '|.){' . $smcFunc['strlen'](substr($string, 0, $length)) . '}~' . ($utf8 ? 'u' : ''), $string, $matches); |
206 | 214 | $string = $matches[0]; |
207 | - while (strlen($string) > $length) |
|
208 | - $string = preg_replace('~(?:' . $ent_list . '|.)$~' . ($utf8 ? 'u' : ''), '', $string); |
|
215 | + while (strlen($string) > $length) { |
|
216 | + $string = preg_replace('~(?:' . $ent_list . '|.)$~' . ($utf8 ? 'u' : ''), '', $string); |
|
217 | + } |
|
209 | 218 | return $string; |
210 | 219 | }, |
211 | 220 | 'ucfirst' => $utf8 ? function($string) use (&$smcFunc) |
@@ -215,8 +224,9 @@ discard block |
||
215 | 224 | 'ucwords' => $utf8 ? function($string) use (&$smcFunc) |
216 | 225 | { |
217 | 226 | $words = preg_split('~([\s\r\n\t]+)~', $string, -1, PREG_SPLIT_DELIM_CAPTURE); |
218 | - for ($i = 0, $n = count($words); $i < $n; $i += 2) |
|
219 | - $words[$i] = $smcFunc['ucfirst']($words[$i]); |
|
227 | + for ($i = 0, $n = count($words); $i < $n; $i += 2) { |
|
228 | + $words[$i] = $smcFunc['ucfirst']($words[$i]); |
|
229 | + } |
|
220 | 230 | return implode('', $words); |
221 | 231 | } : 'ucwords', |
222 | 232 | 'json_decode' => 'smf_json_decode', |
@@ -224,16 +234,17 @@ discard block |
||
224 | 234 | ); |
225 | 235 | |
226 | 236 | // Setting the timezone is a requirement for some functions. |
227 | - if (isset($modSettings['default_timezone']) && in_array($modSettings['default_timezone'], timezone_identifiers_list())) |
|
228 | - date_default_timezone_set($modSettings['default_timezone']); |
|
229 | - else |
|
237 | + if (isset($modSettings['default_timezone']) && in_array($modSettings['default_timezone'], timezone_identifiers_list())) { |
|
238 | + date_default_timezone_set($modSettings['default_timezone']); |
|
239 | + } else |
|
230 | 240 | { |
231 | 241 | // Get PHP's default timezone, if set |
232 | 242 | $ini_tz = ini_get('date.timezone'); |
233 | - if (!empty($ini_tz)) |
|
234 | - $modSettings['default_timezone'] = $ini_tz; |
|
235 | - else |
|
236 | - $modSettings['default_timezone'] = ''; |
|
243 | + if (!empty($ini_tz)) { |
|
244 | + $modSettings['default_timezone'] = $ini_tz; |
|
245 | + } else { |
|
246 | + $modSettings['default_timezone'] = ''; |
|
247 | + } |
|
237 | 248 | |
238 | 249 | // If date.timezone is unset, invalid, or just plain weird, make a best guess |
239 | 250 | if (!in_array($modSettings['default_timezone'], timezone_identifiers_list())) |
@@ -251,22 +262,26 @@ discard block |
||
251 | 262 | if (($modSettings['load_average'] = cache_get_data('loadavg', 90)) == null) |
252 | 263 | { |
253 | 264 | $modSettings['load_average'] = @file_get_contents('/proc/loadavg'); |
254 | - if (!empty($modSettings['load_average']) && preg_match('~^([^ ]+?) ([^ ]+?) ([^ ]+)~', $modSettings['load_average'], $matches) != 0) |
|
255 | - $modSettings['load_average'] = (float) $matches[1]; |
|
256 | - elseif (($modSettings['load_average'] = @`uptime`) != null && preg_match('~load average[s]?: (\d+\.\d+), (\d+\.\d+), (\d+\.\d+)~i', $modSettings['load_average'], $matches) != 0) |
|
257 | - $modSettings['load_average'] = (float) $matches[1]; |
|
258 | - else |
|
259 | - unset($modSettings['load_average']); |
|
265 | + if (!empty($modSettings['load_average']) && preg_match('~^([^ ]+?) ([^ ]+?) ([^ ]+)~', $modSettings['load_average'], $matches) != 0) { |
|
266 | + $modSettings['load_average'] = (float) $matches[1]; |
|
267 | + } elseif (($modSettings['load_average'] = @`uptime`) != null && preg_match('~load average[s]?: (\d+\.\d+), (\d+\.\d+), (\d+\.\d+)~i', $modSettings['load_average'], $matches) != 0) { |
|
268 | + $modSettings['load_average'] = (float) $matches[1]; |
|
269 | + } else { |
|
270 | + unset($modSettings['load_average']); |
|
271 | + } |
|
260 | 272 | |
261 | - if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0) |
|
262 | - cache_put_data('loadavg', $modSettings['load_average'], 90); |
|
273 | + if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0) { |
|
274 | + cache_put_data('loadavg', $modSettings['load_average'], 90); |
|
275 | + } |
|
263 | 276 | } |
264 | 277 | |
265 | - if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0) |
|
266 | - call_integration_hook('integrate_load_average', array($modSettings['load_average'])); |
|
278 | + if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0) { |
|
279 | + call_integration_hook('integrate_load_average', array($modSettings['load_average'])); |
|
280 | + } |
|
267 | 281 | |
268 | - if (!empty($modSettings['loadavg_forum']) && !empty($modSettings['load_average']) && $modSettings['load_average'] >= $modSettings['loadavg_forum']) |
|
269 | - display_loadavg_error(); |
|
282 | + if (!empty($modSettings['loadavg_forum']) && !empty($modSettings['load_average']) && $modSettings['load_average'] >= $modSettings['loadavg_forum']) { |
|
283 | + display_loadavg_error(); |
|
284 | + } |
|
270 | 285 | } |
271 | 286 | |
272 | 287 | // Is post moderation alive and well? Everywhere else assumes this has been defined, so let's make sure it is. |
@@ -287,8 +302,9 @@ discard block |
||
287 | 302 | if (defined('SMF_INTEGRATION_SETTINGS')) |
288 | 303 | { |
289 | 304 | $integration_settings = $smcFunc['json_decode'](SMF_INTEGRATION_SETTINGS, true); |
290 | - foreach ($integration_settings as $hook => $function) |
|
291 | - add_integration_function($hook, $function, '', false); |
|
305 | + foreach ($integration_settings as $hook => $function) { |
|
306 | + add_integration_function($hook, $function, '', false); |
|
307 | + } |
|
292 | 308 | } |
293 | 309 | |
294 | 310 | // Any files to pre include? |
@@ -298,8 +314,9 @@ discard block |
||
298 | 314 | foreach ($pre_includes as $include) |
299 | 315 | { |
300 | 316 | $include = strtr(trim($include), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir)); |
301 | - if (file_exists($include)) |
|
302 | - require_once($include); |
|
317 | + if (file_exists($include)) { |
|
318 | + require_once($include); |
|
319 | + } |
|
303 | 320 | } |
304 | 321 | } |
305 | 322 | |
@@ -405,27 +422,28 @@ discard block |
||
405 | 422 | break; |
406 | 423 | } |
407 | 424 | } |
425 | + } else { |
|
426 | + $id_member = 0; |
|
408 | 427 | } |
409 | - else |
|
410 | - $id_member = 0; |
|
411 | 428 | |
412 | 429 | if (empty($id_member) && isset($_COOKIE[$cookiename])) |
413 | 430 | { |
414 | 431 | $cookie_data = $smcFunc['json_decode']($_COOKIE[$cookiename], true, false); |
415 | 432 | |
416 | - if (empty($cookie_data)) |
|
417 | - $cookie_data = safe_unserialize($_COOKIE[$cookiename]); |
|
433 | + if (empty($cookie_data)) { |
|
434 | + $cookie_data = safe_unserialize($_COOKIE[$cookiename]); |
|
435 | + } |
|
418 | 436 | |
419 | 437 | list ($id_member, $password) = $cookie_data; |
420 | 438 | $id_member = !empty($id_member) && strlen($password) > 0 ? (int) $id_member : 0; |
421 | - } |
|
422 | - elseif (empty($id_member) && isset($_SESSION['login_' . $cookiename]) && ($_SESSION['USER_AGENT'] == $_SERVER['HTTP_USER_AGENT'] || !empty($modSettings['disableCheckUA']))) |
|
439 | + } elseif (empty($id_member) && isset($_SESSION['login_' . $cookiename]) && ($_SESSION['USER_AGENT'] == $_SERVER['HTTP_USER_AGENT'] || !empty($modSettings['disableCheckUA']))) |
|
423 | 440 | { |
424 | 441 | // @todo Perhaps we can do some more checking on this, such as on the first octet of the IP? |
425 | 442 | $cookie_data = $smcFunc['json_decode']($_SESSION['login_' . $cookiename]); |
426 | 443 | |
427 | - if (empty($cookie_data)) |
|
428 | - $cookie_data = safe_unserialize($_SESSION['login_' . $cookiename]); |
|
444 | + if (empty($cookie_data)) { |
|
445 | + $cookie_data = safe_unserialize($_SESSION['login_' . $cookiename]); |
|
446 | + } |
|
429 | 447 | |
430 | 448 | list ($id_member, $password, $login_span) = $cookie_data; |
431 | 449 | $id_member = !empty($id_member) && strlen($password) == 128 && $login_span > time() ? (int) $id_member : 0; |
@@ -450,30 +468,34 @@ discard block |
||
450 | 468 | $user_settings = $smcFunc['db_fetch_assoc']($request); |
451 | 469 | $smcFunc['db_free_result']($request); |
452 | 470 | |
453 | - if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($user_settings['avatar'], 'http://') !== false) |
|
454 | - $user_settings['avatar'] = strtr($boardurl, array('http://' => 'https://')) . '/proxy.php?request=' . urlencode($user_settings['avatar']) . '&hash=' . md5($user_settings['avatar'] . $image_proxy_secret); |
|
471 | + if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($user_settings['avatar'], 'http://') !== false) { |
|
472 | + $user_settings['avatar'] = strtr($boardurl, array('http://' => 'https://')) . '/proxy.php?request=' . urlencode($user_settings['avatar']) . '&hash=' . md5($user_settings['avatar'] . $image_proxy_secret); |
|
473 | + } |
|
455 | 474 | |
456 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) |
|
457 | - cache_put_data('user_settings-' . $id_member, $user_settings, 60); |
|
475 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { |
|
476 | + cache_put_data('user_settings-' . $id_member, $user_settings, 60); |
|
477 | + } |
|
458 | 478 | } |
459 | 479 | |
460 | 480 | // Did we find 'im? If not, junk it. |
461 | 481 | if (!empty($user_settings)) |
462 | 482 | { |
463 | 483 | // As much as the password should be right, we can assume the integration set things up. |
464 | - if (!empty($already_verified) && $already_verified === true) |
|
465 | - $check = true; |
|
484 | + if (!empty($already_verified) && $already_verified === true) { |
|
485 | + $check = true; |
|
486 | + } |
|
466 | 487 | // SHA-512 hash should be 128 characters long. |
467 | - elseif (strlen($password) == 128) |
|
468 | - $check = hash_salt($user_settings['passwd'], $user_settings['password_salt']) == $password; |
|
469 | - else |
|
470 | - $check = false; |
|
488 | + elseif (strlen($password) == 128) { |
|
489 | + $check = hash_salt($user_settings['passwd'], $user_settings['password_salt']) == $password; |
|
490 | + } else { |
|
491 | + $check = false; |
|
492 | + } |
|
471 | 493 | |
472 | 494 | // Wrong password or not activated - either way, you're going nowhere. |
473 | 495 | $id_member = $check && ($user_settings['is_activated'] == 1 || $user_settings['is_activated'] == 11) ? (int) $user_settings['id_member'] : 0; |
496 | + } else { |
|
497 | + $id_member = 0; |
|
474 | 498 | } |
475 | - else |
|
476 | - $id_member = 0; |
|
477 | 499 | |
478 | 500 | // If we no longer have the member maybe they're being all hackey, stop brute force! |
479 | 501 | if (!$id_member) |
@@ -502,8 +524,9 @@ discard block |
||
502 | 524 | |
503 | 525 | list ($tfamember, $tfasecret) = $tfa_data; |
504 | 526 | |
505 | - if (!isset($tfamember, $tfasecret) || (int) $tfamember != $id_member) |
|
506 | - $tfasecret = null; |
|
527 | + if (!isset($tfamember, $tfasecret) || (int) $tfamember != $id_member) { |
|
528 | + $tfasecret = null; |
|
529 | + } |
|
507 | 530 | } |
508 | 531 | |
509 | 532 | if (empty($tfasecret) || hash_salt($user_settings['tfa_backup'], $user_settings['password_salt']) != $tfasecret) |
@@ -523,10 +546,12 @@ discard block |
||
523 | 546 | // Are we forcing 2FA? Need to check if the user groups actually require 2FA |
524 | 547 | elseif (!empty($modSettings['tfa_mode']) && $modSettings['tfa_mode'] >= 2 && $id_member && empty($user_settings['tfa_secret'])) |
525 | 548 | { |
526 | - if ($modSettings['tfa_mode'] == 2) //only do this if we are just forcing SOME membergroups |
|
549 | + if ($modSettings['tfa_mode'] == 2) { |
|
550 | + //only do this if we are just forcing SOME membergroups |
|
527 | 551 | { |
528 | 552 | //Build an array of ALL user membergroups. |
529 | 553 | $full_groups = array($user_settings['id_group']); |
554 | + } |
|
530 | 555 | if (!empty($user_settings['additional_groups'])) |
531 | 556 | { |
532 | 557 | $full_groups = array_merge($full_groups, explode(',', $user_settings['additional_groups'])); |
@@ -546,15 +571,17 @@ discard block |
||
546 | 571 | ); |
547 | 572 | $row = $smcFunc['db_fetch_assoc']($request); |
548 | 573 | $smcFunc['db_free_result']($request); |
574 | + } else { |
|
575 | + $row['total'] = 1; |
|
549 | 576 | } |
550 | - else |
|
551 | - $row['total'] = 1; //simplifies logics in the next "if" |
|
577 | + //simplifies logics in the next "if" |
|
552 | 578 | |
553 | 579 | $area = !empty($_REQUEST['area']) ? $_REQUEST['area'] : ''; |
554 | 580 | $action = !empty($_REQUEST['action']) ? $_REQUEST['action'] : ''; |
555 | 581 | |
556 | - if ($row['total'] > 0 && !in_array($action, array('profile', 'logout')) || ($action == 'profile' && $area != 'tfasetup')) |
|
557 | - redirectexit('action=profile;area=tfasetup;forced'); |
|
582 | + if ($row['total'] > 0 && !in_array($action, array('profile', 'logout')) || ($action == 'profile' && $area != 'tfasetup')) { |
|
583 | + redirectexit('action=profile;area=tfasetup;forced'); |
|
584 | + } |
|
558 | 585 | } |
559 | 586 | } |
560 | 587 | |
@@ -591,33 +618,37 @@ discard block |
||
591 | 618 | updateMemberData($id_member, array('id_msg_last_visit' => (int) $modSettings['maxMsgID'], 'last_login' => time(), 'member_ip' => $_SERVER['REMOTE_ADDR'], 'member_ip2' => $_SERVER['BAN_CHECK_IP'])); |
592 | 619 | $user_settings['last_login'] = time(); |
593 | 620 | |
594 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) |
|
595 | - cache_put_data('user_settings-' . $id_member, $user_settings, 60); |
|
621 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { |
|
622 | + cache_put_data('user_settings-' . $id_member, $user_settings, 60); |
|
623 | + } |
|
596 | 624 | |
597 | - if (!empty($modSettings['cache_enable'])) |
|
598 | - cache_put_data('user_last_visit-' . $id_member, $_SESSION['id_msg_last_visit'], 5 * 3600); |
|
625 | + if (!empty($modSettings['cache_enable'])) { |
|
626 | + cache_put_data('user_last_visit-' . $id_member, $_SESSION['id_msg_last_visit'], 5 * 3600); |
|
627 | + } |
|
599 | 628 | } |
629 | + } elseif (empty($_SESSION['id_msg_last_visit'])) { |
|
630 | + $_SESSION['id_msg_last_visit'] = $user_settings['id_msg_last_visit']; |
|
600 | 631 | } |
601 | - elseif (empty($_SESSION['id_msg_last_visit'])) |
|
602 | - $_SESSION['id_msg_last_visit'] = $user_settings['id_msg_last_visit']; |
|
603 | 632 | |
604 | 633 | $username = $user_settings['member_name']; |
605 | 634 | |
606 | - if (empty($user_settings['additional_groups'])) |
|
607 | - $user_info = array( |
|
635 | + if (empty($user_settings['additional_groups'])) { |
|
636 | + $user_info = array( |
|
608 | 637 | 'groups' => array($user_settings['id_group'], $user_settings['id_post_group']) |
609 | 638 | ); |
610 | - else |
|
611 | - $user_info = array( |
|
639 | + } else { |
|
640 | + $user_info = array( |
|
612 | 641 | 'groups' => array_merge( |
613 | 642 | array($user_settings['id_group'], $user_settings['id_post_group']), |
614 | 643 | explode(',', $user_settings['additional_groups']) |
615 | 644 | ) |
616 | 645 | ); |
646 | + } |
|
617 | 647 | |
618 | 648 | // Because history has proven that it is possible for groups to go bad - clean up in case. |
619 | - foreach ($user_info['groups'] as $k => $v) |
|
620 | - $user_info['groups'][$k] = (int) $v; |
|
649 | + foreach ($user_info['groups'] as $k => $v) { |
|
650 | + $user_info['groups'][$k] = (int) $v; |
|
651 | + } |
|
621 | 652 | |
622 | 653 | // This is a logged in user, so definitely not a spider. |
623 | 654 | $user_info['possibly_robot'] = false; |
@@ -631,8 +662,7 @@ discard block |
||
631 | 662 | $time_system = new DateTime('now', $tz_system); |
632 | 663 | $time_user = new DateTime('now', $tz_user); |
633 | 664 | $user_info['time_offset'] = ($tz_user->getOffset($time_user) - $tz_system->getOffset($time_system)) / 3600; |
634 | - } |
|
635 | - else |
|
665 | + } else |
|
636 | 666 | { |
637 | 667 | // !!! Compatibility. |
638 | 668 | $user_info['time_offset'] = empty($user_settings['time_offset']) ? 0 : $user_settings['time_offset']; |
@@ -646,8 +676,9 @@ discard block |
||
646 | 676 | $user_info = array('groups' => array(-1)); |
647 | 677 | $user_settings = array(); |
648 | 678 | |
649 | - if (isset($_COOKIE[$cookiename]) && empty($context['tfa_member'])) |
|
650 | - $_COOKIE[$cookiename] = ''; |
|
679 | + if (isset($_COOKIE[$cookiename]) && empty($context['tfa_member'])) { |
|
680 | + $_COOKIE[$cookiename] = ''; |
|
681 | + } |
|
651 | 682 | |
652 | 683 | // Expire the 2FA cookie |
653 | 684 | if (isset($_COOKIE[$cookiename . '_tfa']) && empty($context['tfa_member'])) |
@@ -664,19 +695,20 @@ discard block |
||
664 | 695 | } |
665 | 696 | |
666 | 697 | // Create a login token if it doesn't exist yet. |
667 | - if (!isset($_SESSION['token']['post-login'])) |
|
668 | - createToken('login'); |
|
669 | - else |
|
670 | - list ($context['login_token_var'],,, $context['login_token']) = $_SESSION['token']['post-login']; |
|
698 | + if (!isset($_SESSION['token']['post-login'])) { |
|
699 | + createToken('login'); |
|
700 | + } else { |
|
701 | + list ($context['login_token_var'],,, $context['login_token']) = $_SESSION['token']['post-login']; |
|
702 | + } |
|
671 | 703 | |
672 | 704 | // Do we perhaps think this is a search robot? Check every five minutes just in case... |
673 | 705 | if ((!empty($modSettings['spider_mode']) || !empty($modSettings['spider_group'])) && (!isset($_SESSION['robot_check']) || $_SESSION['robot_check'] < time() - 300)) |
674 | 706 | { |
675 | 707 | require_once($sourcedir . '/ManageSearchEngines.php'); |
676 | 708 | $user_info['possibly_robot'] = SpiderCheck(); |
709 | + } elseif (!empty($modSettings['spider_mode'])) { |
|
710 | + $user_info['possibly_robot'] = isset($_SESSION['id_robot']) ? $_SESSION['id_robot'] : 0; |
|
677 | 711 | } |
678 | - elseif (!empty($modSettings['spider_mode'])) |
|
679 | - $user_info['possibly_robot'] = isset($_SESSION['id_robot']) ? $_SESSION['id_robot'] : 0; |
|
680 | 712 | // If we haven't turned on proper spider hunts then have a guess! |
681 | 713 | else |
682 | 714 | { |
@@ -724,8 +756,9 @@ discard block |
||
724 | 756 | $user_info['groups'] = array_unique($user_info['groups']); |
725 | 757 | |
726 | 758 | // Make sure that the last item in the ignore boards array is valid. If the list was too long it could have an ending comma that could cause problems. |
727 | - if (!empty($user_info['ignoreboards']) && empty($user_info['ignoreboards'][$tmp = count($user_info['ignoreboards']) - 1])) |
|
728 | - unset($user_info['ignoreboards'][$tmp]); |
|
759 | + if (!empty($user_info['ignoreboards']) && empty($user_info['ignoreboards'][$tmp = count($user_info['ignoreboards']) - 1])) { |
|
760 | + unset($user_info['ignoreboards'][$tmp]); |
|
761 | + } |
|
729 | 762 | |
730 | 763 | // Allow the user to change their language. |
731 | 764 | if (!empty($modSettings['userLanguage'])) |
@@ -738,13 +771,14 @@ discard block |
||
738 | 771 | $user_info['language'] = strtr($_GET['language'], './\\:', '____'); |
739 | 772 | |
740 | 773 | // Make it permanent for members. |
741 | - if (!empty($user_info['id'])) |
|
742 | - updateMemberData($user_info['id'], array('lngfile' => $user_info['language'])); |
|
743 | - else |
|
744 | - $_SESSION['language'] = $user_info['language']; |
|
774 | + if (!empty($user_info['id'])) { |
|
775 | + updateMemberData($user_info['id'], array('lngfile' => $user_info['language'])); |
|
776 | + } else { |
|
777 | + $_SESSION['language'] = $user_info['language']; |
|
778 | + } |
|
779 | + } elseif (!empty($_SESSION['language']) && isset($languages[strtr($_SESSION['language'], './\\:', '____')])) { |
|
780 | + $user_info['language'] = strtr($_SESSION['language'], './\\:', '____'); |
|
745 | 781 | } |
746 | - elseif (!empty($_SESSION['language']) && isset($languages[strtr($_SESSION['language'], './\\:', '____')])) |
|
747 | - $user_info['language'] = strtr($_SESSION['language'], './\\:', '____'); |
|
748 | 782 | } |
749 | 783 | |
750 | 784 | $temp = build_query_board($user_info['id']); |
@@ -807,9 +841,9 @@ discard block |
||
807 | 841 | } |
808 | 842 | |
809 | 843 | // Remember redirection is the key to avoiding fallout from your bosses. |
810 | - if (!empty($topic)) |
|
811 | - redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg']); |
|
812 | - else |
|
844 | + if (!empty($topic)) { |
|
845 | + redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg']); |
|
846 | + } else |
|
813 | 847 | { |
814 | 848 | loadPermissions(); |
815 | 849 | loadTheme(); |
@@ -827,10 +861,11 @@ discard block |
||
827 | 861 | if (!empty($modSettings['cache_enable']) && (empty($topic) || $modSettings['cache_enable'] >= 3)) |
828 | 862 | { |
829 | 863 | // @todo SLOW? |
830 | - if (!empty($topic)) |
|
831 | - $temp = cache_get_data('topic_board-' . $topic, 120); |
|
832 | - else |
|
833 | - $temp = cache_get_data('board-' . $board, 120); |
|
864 | + if (!empty($topic)) { |
|
865 | + $temp = cache_get_data('topic_board-' . $topic, 120); |
|
866 | + } else { |
|
867 | + $temp = cache_get_data('board-' . $board, 120); |
|
868 | + } |
|
834 | 869 | |
835 | 870 | if (!empty($temp)) |
836 | 871 | { |
@@ -868,8 +903,9 @@ discard block |
||
868 | 903 | $row = $smcFunc['db_fetch_assoc']($request); |
869 | 904 | |
870 | 905 | // Set the current board. |
871 | - if (!empty($row['id_board'])) |
|
872 | - $board = $row['id_board']; |
|
906 | + if (!empty($row['id_board'])) { |
|
907 | + $board = $row['id_board']; |
|
908 | + } |
|
873 | 909 | |
874 | 910 | // Basic operating information. (globals... :/) |
875 | 911 | $board_info = array( |
@@ -905,21 +941,23 @@ discard block |
||
905 | 941 | |
906 | 942 | do |
907 | 943 | { |
908 | - if (!empty($row['id_moderator'])) |
|
909 | - $board_info['moderators'][$row['id_moderator']] = array( |
|
944 | + if (!empty($row['id_moderator'])) { |
|
945 | + $board_info['moderators'][$row['id_moderator']] = array( |
|
910 | 946 | 'id' => $row['id_moderator'], |
911 | 947 | 'name' => $row['real_name'], |
912 | 948 | 'href' => $scripturl . '?action=profile;u=' . $row['id_moderator'], |
913 | 949 | 'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['id_moderator'] . '">' . $row['real_name'] . '</a>' |
914 | 950 | ); |
951 | + } |
|
915 | 952 | |
916 | - if (!empty($row['id_moderator_group'])) |
|
917 | - $board_info['moderator_groups'][$row['id_moderator_group']] = array( |
|
953 | + if (!empty($row['id_moderator_group'])) { |
|
954 | + $board_info['moderator_groups'][$row['id_moderator_group']] = array( |
|
918 | 955 | 'id' => $row['id_moderator_group'], |
919 | 956 | 'name' => $row['group_name'], |
920 | 957 | 'href' => $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'], |
921 | 958 | 'link' => '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'] . '">' . $row['group_name'] . '</a>' |
922 | 959 | ); |
960 | + } |
|
923 | 961 | } |
924 | 962 | while ($row = $smcFunc['db_fetch_assoc']($request)); |
925 | 963 | |
@@ -951,12 +989,12 @@ discard block |
||
951 | 989 | if (!empty($modSettings['cache_enable']) && (empty($topic) || $modSettings['cache_enable'] >= 3)) |
952 | 990 | { |
953 | 991 | // @todo SLOW? |
954 | - if (!empty($topic)) |
|
955 | - cache_put_data('topic_board-' . $topic, $board_info, 120); |
|
992 | + if (!empty($topic)) { |
|
993 | + cache_put_data('topic_board-' . $topic, $board_info, 120); |
|
994 | + } |
|
956 | 995 | cache_put_data('board-' . $board, $board_info, 120); |
957 | 996 | } |
958 | - } |
|
959 | - else |
|
997 | + } else |
|
960 | 998 | { |
961 | 999 | // Otherwise the topic is invalid, there are no moderators, etc. |
962 | 1000 | $board_info = array( |
@@ -970,8 +1008,9 @@ discard block |
||
970 | 1008 | $smcFunc['db_free_result']($request); |
971 | 1009 | } |
972 | 1010 | |
973 | - if (!empty($topic)) |
|
974 | - $_GET['board'] = (int) $board; |
|
1011 | + if (!empty($topic)) { |
|
1012 | + $_GET['board'] = (int) $board; |
|
1013 | + } |
|
975 | 1014 | |
976 | 1015 | if (!empty($board)) |
977 | 1016 | { |
@@ -981,10 +1020,12 @@ discard block |
||
981 | 1020 | // Now check if the user is a moderator. |
982 | 1021 | $user_info['is_mod'] = isset($board_info['moderators'][$user_info['id']]) || count(array_intersect($user_info['groups'], $moderator_groups)) != 0; |
983 | 1022 | |
984 | - if (count(array_intersect($user_info['groups'], $board_info['groups'])) == 0 && !$user_info['is_admin']) |
|
985 | - $board_info['error'] = 'access'; |
|
986 | - if (!empty($modSettings['deny_boards_access']) && count(array_intersect($user_info['groups'], $board_info['deny_groups'])) != 0 && !$user_info['is_admin']) |
|
987 | - $board_info['error'] = 'access'; |
|
1023 | + if (count(array_intersect($user_info['groups'], $board_info['groups'])) == 0 && !$user_info['is_admin']) { |
|
1024 | + $board_info['error'] = 'access'; |
|
1025 | + } |
|
1026 | + if (!empty($modSettings['deny_boards_access']) && count(array_intersect($user_info['groups'], $board_info['deny_groups'])) != 0 && !$user_info['is_admin']) { |
|
1027 | + $board_info['error'] = 'access'; |
|
1028 | + } |
|
988 | 1029 | |
989 | 1030 | // Build up the linktree. |
990 | 1031 | $context['linktree'] = array_merge( |
@@ -1007,8 +1048,9 @@ discard block |
||
1007 | 1048 | $context['current_board'] = $board; |
1008 | 1049 | |
1009 | 1050 | // No posting in redirection boards! |
1010 | - if (!empty($_REQUEST['action']) && $_REQUEST['action'] == 'post' && !empty($board_info['redirect'])) |
|
1011 | - $board_info['error'] == 'post_in_redirect'; |
|
1051 | + if (!empty($_REQUEST['action']) && $_REQUEST['action'] == 'post' && !empty($board_info['redirect'])) { |
|
1052 | + $board_info['error'] == 'post_in_redirect'; |
|
1053 | + } |
|
1012 | 1054 | |
1013 | 1055 | // Hacker... you can't see this topic, I'll tell you that. (but moderators can!) |
1014 | 1056 | if (!empty($board_info['error']) && (!empty($modSettings['deny_boards_access']) || $board_info['error'] != 'access' || !$user_info['is_mod'])) |
@@ -1034,24 +1076,23 @@ discard block |
||
1034 | 1076 | ob_end_clean(); |
1035 | 1077 | header('HTTP/1.1 403 Forbidden'); |
1036 | 1078 | die; |
1037 | - } |
|
1038 | - elseif ($board_info['error'] == 'post_in_redirect') |
|
1079 | + } elseif ($board_info['error'] == 'post_in_redirect') |
|
1039 | 1080 | { |
1040 | 1081 | // Slightly different error message here... |
1041 | 1082 | fatal_lang_error('cannot_post_redirect', false); |
1042 | - } |
|
1043 | - elseif ($user_info['is_guest']) |
|
1083 | + } elseif ($user_info['is_guest']) |
|
1044 | 1084 | { |
1045 | 1085 | loadLanguage('Errors'); |
1046 | 1086 | is_not_guest($txt['topic_gone']); |
1087 | + } else { |
|
1088 | + fatal_lang_error('topic_gone', false); |
|
1047 | 1089 | } |
1048 | - else |
|
1049 | - fatal_lang_error('topic_gone', false); |
|
1050 | 1090 | } |
1051 | 1091 | |
1052 | - if ($user_info['is_mod']) |
|
1053 | - $user_info['groups'][] = 3; |
|
1054 | -} |
|
1092 | + if ($user_info['is_mod']) { |
|
1093 | + $user_info['groups'][] = 3; |
|
1094 | + } |
|
1095 | + } |
|
1055 | 1096 | |
1056 | 1097 | /** |
1057 | 1098 | * Load this user's permissions. |
@@ -1072,8 +1113,9 @@ discard block |
||
1072 | 1113 | asort($cache_groups); |
1073 | 1114 | $cache_groups = implode(',', $cache_groups); |
1074 | 1115 | // If it's a spider then cache it different. |
1075 | - if ($user_info['possibly_robot']) |
|
1076 | - $cache_groups .= '-spider'; |
|
1116 | + if ($user_info['possibly_robot']) { |
|
1117 | + $cache_groups .= '-spider'; |
|
1118 | + } |
|
1077 | 1119 | |
1078 | 1120 | if ($modSettings['cache_enable'] >= 2 && !empty($board) && ($temp = cache_get_data('permissions:' . $cache_groups . ':' . $board, 240)) != null && time() - 240 > $modSettings['settings_updated']) |
1079 | 1121 | { |
@@ -1081,9 +1123,9 @@ discard block |
||
1081 | 1123 | banPermissions(); |
1082 | 1124 | |
1083 | 1125 | return; |
1126 | + } elseif (($temp = cache_get_data('permissions:' . $cache_groups, 240)) != null && time() - 240 > $modSettings['settings_updated']) { |
|
1127 | + list ($user_info['permissions'], $removals) = $temp; |
|
1084 | 1128 | } |
1085 | - elseif (($temp = cache_get_data('permissions:' . $cache_groups, 240)) != null && time() - 240 > $modSettings['settings_updated']) |
|
1086 | - list ($user_info['permissions'], $removals) = $temp; |
|
1087 | 1129 | } |
1088 | 1130 | |
1089 | 1131 | // If it is detected as a robot, and we are restricting permissions as a special group - then implement this. |
@@ -1105,23 +1147,26 @@ discard block |
||
1105 | 1147 | $removals = array(); |
1106 | 1148 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1107 | 1149 | { |
1108 | - if (empty($row['add_deny'])) |
|
1109 | - $removals[] = $row['permission']; |
|
1110 | - else |
|
1111 | - $user_info['permissions'][] = $row['permission']; |
|
1150 | + if (empty($row['add_deny'])) { |
|
1151 | + $removals[] = $row['permission']; |
|
1152 | + } else { |
|
1153 | + $user_info['permissions'][] = $row['permission']; |
|
1154 | + } |
|
1112 | 1155 | } |
1113 | 1156 | $smcFunc['db_free_result']($request); |
1114 | 1157 | |
1115 | - if (isset($cache_groups)) |
|
1116 | - cache_put_data('permissions:' . $cache_groups, array($user_info['permissions'], $removals), 240); |
|
1158 | + if (isset($cache_groups)) { |
|
1159 | + cache_put_data('permissions:' . $cache_groups, array($user_info['permissions'], $removals), 240); |
|
1160 | + } |
|
1117 | 1161 | } |
1118 | 1162 | |
1119 | 1163 | // Get the board permissions. |
1120 | 1164 | if (!empty($board)) |
1121 | 1165 | { |
1122 | 1166 | // Make sure the board (if any) has been loaded by loadBoard(). |
1123 | - if (!isset($board_info['profile'])) |
|
1124 | - fatal_lang_error('no_board'); |
|
1167 | + if (!isset($board_info['profile'])) { |
|
1168 | + fatal_lang_error('no_board'); |
|
1169 | + } |
|
1125 | 1170 | |
1126 | 1171 | $request = $smcFunc['db_query']('', ' |
1127 | 1172 | SELECT permission, add_deny |
@@ -1137,20 +1182,23 @@ discard block |
||
1137 | 1182 | ); |
1138 | 1183 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1139 | 1184 | { |
1140 | - if (empty($row['add_deny'])) |
|
1141 | - $removals[] = $row['permission']; |
|
1142 | - else |
|
1143 | - $user_info['permissions'][] = $row['permission']; |
|
1185 | + if (empty($row['add_deny'])) { |
|
1186 | + $removals[] = $row['permission']; |
|
1187 | + } else { |
|
1188 | + $user_info['permissions'][] = $row['permission']; |
|
1189 | + } |
|
1144 | 1190 | } |
1145 | 1191 | $smcFunc['db_free_result']($request); |
1146 | 1192 | } |
1147 | 1193 | |
1148 | 1194 | // Remove all the permissions they shouldn't have ;). |
1149 | - if (!empty($modSettings['permission_enable_deny'])) |
|
1150 | - $user_info['permissions'] = array_diff($user_info['permissions'], $removals); |
|
1195 | + if (!empty($modSettings['permission_enable_deny'])) { |
|
1196 | + $user_info['permissions'] = array_diff($user_info['permissions'], $removals); |
|
1197 | + } |
|
1151 | 1198 | |
1152 | - if (isset($cache_groups) && !empty($board) && $modSettings['cache_enable'] >= 2) |
|
1153 | - cache_put_data('permissions:' . $cache_groups . ':' . $board, array($user_info['permissions'], null), 240); |
|
1199 | + if (isset($cache_groups) && !empty($board) && $modSettings['cache_enable'] >= 2) { |
|
1200 | + cache_put_data('permissions:' . $cache_groups . ':' . $board, array($user_info['permissions'], null), 240); |
|
1201 | + } |
|
1154 | 1202 | |
1155 | 1203 | // Banned? Watch, don't touch.. |
1156 | 1204 | banPermissions(); |
@@ -1162,17 +1210,18 @@ discard block |
||
1162 | 1210 | { |
1163 | 1211 | require_once($sourcedir . '/Subs-Auth.php'); |
1164 | 1212 | rebuildModCache(); |
1213 | + } else { |
|
1214 | + $user_info['mod_cache'] = $_SESSION['mc']; |
|
1165 | 1215 | } |
1166 | - else |
|
1167 | - $user_info['mod_cache'] = $_SESSION['mc']; |
|
1168 | 1216 | |
1169 | 1217 | // This is a useful phantom permission added to the current user, and only the current user while they are logged in. |
1170 | 1218 | // For example this drastically simplifies certain changes to the profile area. |
1171 | 1219 | $user_info['permissions'][] = 'is_not_guest'; |
1172 | 1220 | // And now some backwards compatibility stuff for mods and whatnot that aren't expecting the new permissions. |
1173 | 1221 | $user_info['permissions'][] = 'profile_view_own'; |
1174 | - if (in_array('profile_view', $user_info['permissions'])) |
|
1175 | - $user_info['permissions'][] = 'profile_view_any'; |
|
1222 | + if (in_array('profile_view', $user_info['permissions'])) { |
|
1223 | + $user_info['permissions'][] = 'profile_view_any'; |
|
1224 | + } |
|
1176 | 1225 | } |
1177 | 1226 | } |
1178 | 1227 | |
@@ -1190,8 +1239,9 @@ discard block |
||
1190 | 1239 | global $image_proxy_enabled, $image_proxy_secret, $boardurl; |
1191 | 1240 | |
1192 | 1241 | // Can't just look for no users :P. |
1193 | - if (empty($users)) |
|
1194 | - return array(); |
|
1242 | + if (empty($users)) { |
|
1243 | + return array(); |
|
1244 | + } |
|
1195 | 1245 | |
1196 | 1246 | // Pass the set value |
1197 | 1247 | $context['loadMemberContext_set'] = $set; |
@@ -1206,8 +1256,9 @@ discard block |
||
1206 | 1256 | for ($i = 0, $n = count($users); $i < $n; $i++) |
1207 | 1257 | { |
1208 | 1258 | $data = cache_get_data('member_data-' . $set . '-' . $users[$i], 240); |
1209 | - if ($data == null) |
|
1210 | - continue; |
|
1259 | + if ($data == null) { |
|
1260 | + continue; |
|
1261 | + } |
|
1211 | 1262 | |
1212 | 1263 | $loaded_ids[] = $data['id_member']; |
1213 | 1264 | $user_profile[$data['id_member']] = $data; |
@@ -1274,16 +1325,19 @@ discard block |
||
1274 | 1325 | $row['avatar_original'] = !empty($row['avatar']) ? $row['avatar'] : ''; |
1275 | 1326 | |
1276 | 1327 | // Take care of proxying avatar if required, do this here for maximum reach |
1277 | - if ($image_proxy_enabled && !empty($row['avatar']) && stripos($row['avatar'], 'http://') !== false) |
|
1278 | - $row['avatar'] = $boardurl . '/proxy.php?request=' . urlencode($row['avatar']) . '&hash=' . md5($row['avatar'] . $image_proxy_secret); |
|
1328 | + if ($image_proxy_enabled && !empty($row['avatar']) && stripos($row['avatar'], 'http://') !== false) { |
|
1329 | + $row['avatar'] = $boardurl . '/proxy.php?request=' . urlencode($row['avatar']) . '&hash=' . md5($row['avatar'] . $image_proxy_secret); |
|
1330 | + } |
|
1279 | 1331 | |
1280 | 1332 | // Keep track of the member's normal member group |
1281 | 1333 | $row['primary_group'] = $row['member_group']; |
1282 | 1334 | |
1283 | - if (isset($row['member_ip'])) |
|
1284 | - $row['member_ip'] = inet_dtop($row['member_ip']); |
|
1285 | - if (isset($row['member_ip2'])) |
|
1286 | - $row['member_ip2'] = inet_dtop($row['member_ip2']); |
|
1335 | + if (isset($row['member_ip'])) { |
|
1336 | + $row['member_ip'] = inet_dtop($row['member_ip']); |
|
1337 | + } |
|
1338 | + if (isset($row['member_ip2'])) { |
|
1339 | + $row['member_ip2'] = inet_dtop($row['member_ip2']); |
|
1340 | + } |
|
1287 | 1341 | $new_loaded_ids[] = $row['id_member']; |
1288 | 1342 | $loaded_ids[] = $row['id_member']; |
1289 | 1343 | $row['options'] = array(); |
@@ -1302,8 +1356,9 @@ discard block |
||
1302 | 1356 | 'loaded_ids' => $new_loaded_ids, |
1303 | 1357 | ) |
1304 | 1358 | ); |
1305 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1306 | - $user_profile[$row['id_member']]['options'][$row['variable']] = $row['value']; |
|
1359 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1360 | + $user_profile[$row['id_member']]['options'][$row['variable']] = $row['value']; |
|
1361 | + } |
|
1307 | 1362 | $smcFunc['db_free_result']($request); |
1308 | 1363 | } |
1309 | 1364 | |
@@ -1314,10 +1369,11 @@ discard block |
||
1314 | 1369 | { |
1315 | 1370 | foreach ($loaded_ids as $a_member) |
1316 | 1371 | { |
1317 | - if (!empty($user_profile[$a_member]['additional_groups'])) |
|
1318 | - $groups = array_merge(array($user_profile[$a_member]['id_group']), explode(',', $user_profile[$a_member]['additional_groups'])); |
|
1319 | - else |
|
1320 | - $groups = array($user_profile[$a_member]['id_group']); |
|
1372 | + if (!empty($user_profile[$a_member]['additional_groups'])) { |
|
1373 | + $groups = array_merge(array($user_profile[$a_member]['id_group']), explode(',', $user_profile[$a_member]['additional_groups'])); |
|
1374 | + } else { |
|
1375 | + $groups = array($user_profile[$a_member]['id_group']); |
|
1376 | + } |
|
1321 | 1377 | |
1322 | 1378 | $temp = array_intersect($groups, array_keys($board_info['moderator_groups'])); |
1323 | 1379 | |
@@ -1330,8 +1386,9 @@ discard block |
||
1330 | 1386 | |
1331 | 1387 | if (!empty($new_loaded_ids) && !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 3) |
1332 | 1388 | { |
1333 | - for ($i = 0, $n = count($new_loaded_ids); $i < $n; $i++) |
|
1334 | - cache_put_data('member_data-' . $set . '-' . $new_loaded_ids[$i], $user_profile[$new_loaded_ids[$i]], 240); |
|
1389 | + for ($i = 0, $n = count($new_loaded_ids); $i < $n; $i++) { |
|
1390 | + cache_put_data('member_data-' . $set . '-' . $new_loaded_ids[$i], $user_profile[$new_loaded_ids[$i]], 240); |
|
1391 | + } |
|
1335 | 1392 | } |
1336 | 1393 | |
1337 | 1394 | // Are we loading any moderators? If so, fix their group data... |
@@ -1357,14 +1414,17 @@ discard block |
||
1357 | 1414 | foreach ($temp_mods as $id) |
1358 | 1415 | { |
1359 | 1416 | // By popular demand, don't show admins or global moderators as moderators. |
1360 | - if ($user_profile[$id]['id_group'] != 1 && $user_profile[$id]['id_group'] != 2) |
|
1361 | - $user_profile[$id]['member_group'] = $row['member_group']; |
|
1417 | + if ($user_profile[$id]['id_group'] != 1 && $user_profile[$id]['id_group'] != 2) { |
|
1418 | + $user_profile[$id]['member_group'] = $row['member_group']; |
|
1419 | + } |
|
1362 | 1420 | |
1363 | 1421 | // If the Moderator group has no color or icons, but their group does... don't overwrite. |
1364 | - if (!empty($row['icons'])) |
|
1365 | - $user_profile[$id]['icons'] = $row['icons']; |
|
1366 | - if (!empty($row['member_group_color'])) |
|
1367 | - $user_profile[$id]['member_group_color'] = $row['member_group_color']; |
|
1422 | + if (!empty($row['icons'])) { |
|
1423 | + $user_profile[$id]['icons'] = $row['icons']; |
|
1424 | + } |
|
1425 | + if (!empty($row['member_group_color'])) { |
|
1426 | + $user_profile[$id]['member_group_color'] = $row['member_group_color']; |
|
1427 | + } |
|
1368 | 1428 | } |
1369 | 1429 | } |
1370 | 1430 | |
@@ -1386,12 +1446,14 @@ discard block |
||
1386 | 1446 | static $loadedLanguages = array(); |
1387 | 1447 | |
1388 | 1448 | // If this person's data is already loaded, skip it. |
1389 | - if (isset($dataLoaded[$user])) |
|
1390 | - return true; |
|
1449 | + if (isset($dataLoaded[$user])) { |
|
1450 | + return true; |
|
1451 | + } |
|
1391 | 1452 | |
1392 | 1453 | // We can't load guests or members not loaded by loadMemberData()! |
1393 | - if ($user == 0) |
|
1394 | - return false; |
|
1454 | + if ($user == 0) { |
|
1455 | + return false; |
|
1456 | + } |
|
1395 | 1457 | if (!isset($user_profile[$user])) |
1396 | 1458 | { |
1397 | 1459 | trigger_error('loadMemberContext(): member id ' . $user . ' not previously loaded by loadMemberData()', E_USER_WARNING); |
@@ -1417,12 +1479,16 @@ discard block |
||
1417 | 1479 | $buddy_list = !empty($profile['buddy_list']) ? explode(',', $profile['buddy_list']) : array(); |
1418 | 1480 | |
1419 | 1481 | //We need a little fallback for the membergroup icons. If it doesn't exist in the current theme, fallback to default theme |
1420 | - if (isset($profile['icons'][1]) && file_exists($settings['actual_theme_dir'] . '/images/membericons/' . $profile['icons'][1])) //icon is set and exists |
|
1482 | + if (isset($profile['icons'][1]) && file_exists($settings['actual_theme_dir'] . '/images/membericons/' . $profile['icons'][1])) { |
|
1483 | + //icon is set and exists |
|
1421 | 1484 | $group_icon_url = $settings['images_url'] . '/membericons/' . $profile['icons'][1]; |
1422 | - elseif (isset($profile['icons'][1])) //icon is set and doesn't exist, fallback to default |
|
1485 | + } elseif (isset($profile['icons'][1])) { |
|
1486 | + //icon is set and doesn't exist, fallback to default |
|
1423 | 1487 | $group_icon_url = $settings['default_images_url'] . '/membericons/' . $profile['icons'][1]; |
1424 | - else //not set, bye bye |
|
1488 | + } else { |
|
1489 | + //not set, bye bye |
|
1425 | 1490 | $group_icon_url = ''; |
1491 | + } |
|
1426 | 1492 | |
1427 | 1493 | // These minimal values are always loaded |
1428 | 1494 | $memberContext[$user] = array( |
@@ -1441,8 +1507,9 @@ discard block |
||
1441 | 1507 | if ($context['loadMemberContext_set'] != 'minimal') |
1442 | 1508 | { |
1443 | 1509 | // Go the extra mile and load the user's native language name. |
1444 | - if (empty($loadedLanguages)) |
|
1445 | - $loadedLanguages = getLanguages(); |
|
1510 | + if (empty($loadedLanguages)) { |
|
1511 | + $loadedLanguages = getLanguages(); |
|
1512 | + } |
|
1446 | 1513 | |
1447 | 1514 | $memberContext[$user] += array( |
1448 | 1515 | 'username_color' => '<span ' . (!empty($profile['member_group_color']) ? 'style="color:' . $profile['member_group_color'] . ';"' : '') . '>' . $profile['member_name'] . '</span>', |
@@ -1497,31 +1564,33 @@ discard block |
||
1497 | 1564 | { |
1498 | 1565 | if (!empty($modSettings['gravatarOverride']) || (!empty($modSettings['gravatarEnabled']) && stristr($profile['avatar'], 'gravatar://'))) |
1499 | 1566 | { |
1500 | - if (!empty($modSettings['gravatarAllowExtraEmail']) && stristr($profile['avatar'], 'gravatar://') && strlen($profile['avatar']) > 11) |
|
1501 | - $image = get_gravatar_url($smcFunc['substr']($profile['avatar'], 11)); |
|
1502 | - else |
|
1503 | - $image = get_gravatar_url($profile['email_address']); |
|
1504 | - } |
|
1505 | - else |
|
1567 | + if (!empty($modSettings['gravatarAllowExtraEmail']) && stristr($profile['avatar'], 'gravatar://') && strlen($profile['avatar']) > 11) { |
|
1568 | + $image = get_gravatar_url($smcFunc['substr']($profile['avatar'], 11)); |
|
1569 | + } else { |
|
1570 | + $image = get_gravatar_url($profile['email_address']); |
|
1571 | + } |
|
1572 | + } else |
|
1506 | 1573 | { |
1507 | 1574 | // So it's stored in the member table? |
1508 | 1575 | if (!empty($profile['avatar'])) |
1509 | 1576 | { |
1510 | 1577 | $image = (stristr($profile['avatar'], 'http://') || stristr($profile['avatar'], 'https://')) ? $profile['avatar'] : $modSettings['avatar_url'] . '/' . $profile['avatar']; |
1578 | + } elseif (!empty($profile['filename'])) { |
|
1579 | + $image = $modSettings['custom_avatar_url'] . '/' . $profile['filename']; |
|
1511 | 1580 | } |
1512 | - elseif (!empty($profile['filename'])) |
|
1513 | - $image = $modSettings['custom_avatar_url'] . '/' . $profile['filename']; |
|
1514 | 1581 | // Right... no avatar...use the default one |
1515 | - else |
|
1516 | - $image = $modSettings['avatar_url'] . '/default.png'; |
|
1582 | + else { |
|
1583 | + $image = $modSettings['avatar_url'] . '/default.png'; |
|
1584 | + } |
|
1517 | 1585 | } |
1518 | - if (!empty($image)) |
|
1519 | - $memberContext[$user]['avatar'] = array( |
|
1586 | + if (!empty($image)) { |
|
1587 | + $memberContext[$user]['avatar'] = array( |
|
1520 | 1588 | 'name' => $profile['avatar'], |
1521 | 1589 | 'image' => '<img class="avatar" src="' . $image . '" alt="avatar_' . $profile['member_name'] . '">', |
1522 | 1590 | 'href' => $image, |
1523 | 1591 | 'url' => $image, |
1524 | 1592 | ); |
1593 | + } |
|
1525 | 1594 | } |
1526 | 1595 | |
1527 | 1596 | // Are we also loading the members custom fields into context? |
@@ -1529,35 +1598,41 @@ discard block |
||
1529 | 1598 | { |
1530 | 1599 | $memberContext[$user]['custom_fields'] = array(); |
1531 | 1600 | |
1532 | - if (!isset($context['display_fields'])) |
|
1533 | - $context['display_fields'] = $smcFunc['json_decode']($modSettings['displayFields'], true); |
|
1601 | + if (!isset($context['display_fields'])) { |
|
1602 | + $context['display_fields'] = $smcFunc['json_decode']($modSettings['displayFields'], true); |
|
1603 | + } |
|
1534 | 1604 | |
1535 | 1605 | foreach ($context['display_fields'] as $custom) |
1536 | 1606 | { |
1537 | - if (!isset($custom['col_name']) || trim($custom['col_name']) == '' || empty($profile['options'][$custom['col_name']])) |
|
1538 | - continue; |
|
1607 | + if (!isset($custom['col_name']) || trim($custom['col_name']) == '' || empty($profile['options'][$custom['col_name']])) { |
|
1608 | + continue; |
|
1609 | + } |
|
1539 | 1610 | |
1540 | 1611 | $value = $profile['options'][$custom['col_name']]; |
1541 | 1612 | |
1542 | 1613 | // Don't show the "disabled" option for the "gender" field. |
1543 | - if ($custom['col_name'] == 'cust_gender' && $value == 'Disabled') |
|
1544 | - continue; |
|
1614 | + if ($custom['col_name'] == 'cust_gender' && $value == 'Disabled') { |
|
1615 | + continue; |
|
1616 | + } |
|
1545 | 1617 | |
1546 | 1618 | // BBC? |
1547 | - if ($custom['bbc']) |
|
1548 | - $value = parse_bbc($value); |
|
1619 | + if ($custom['bbc']) { |
|
1620 | + $value = parse_bbc($value); |
|
1621 | + } |
|
1549 | 1622 | // ... or checkbox? |
1550 | - elseif (isset($custom['type']) && $custom['type'] == 'check') |
|
1551 | - $value = $value ? $txt['yes'] : $txt['no']; |
|
1623 | + elseif (isset($custom['type']) && $custom['type'] == 'check') { |
|
1624 | + $value = $value ? $txt['yes'] : $txt['no']; |
|
1625 | + } |
|
1552 | 1626 | |
1553 | 1627 | // Enclosing the user input within some other text? |
1554 | - if (!empty($custom['enclose'])) |
|
1555 | - $value = strtr($custom['enclose'], array( |
|
1628 | + if (!empty($custom['enclose'])) { |
|
1629 | + $value = strtr($custom['enclose'], array( |
|
1556 | 1630 | '{SCRIPTURL}' => $scripturl, |
1557 | 1631 | '{IMAGES_URL}' => $settings['images_url'], |
1558 | 1632 | '{DEFAULT_IMAGES_URL}' => $settings['default_images_url'], |
1559 | 1633 | '{INPUT}' => $value, |
1560 | 1634 | )); |
1635 | + } |
|
1561 | 1636 | |
1562 | 1637 | $memberContext[$user]['custom_fields'][] = array( |
1563 | 1638 | 'title' => !empty($custom['title']) ? $custom['title'] : $custom['col_name'], |
@@ -1584,8 +1659,9 @@ discard block |
||
1584 | 1659 | global $smcFunc, $txt, $scripturl, $settings; |
1585 | 1660 | |
1586 | 1661 | // Do not waste my time... |
1587 | - if (empty($users) || empty($params)) |
|
1588 | - return false; |
|
1662 | + if (empty($users) || empty($params)) { |
|
1663 | + return false; |
|
1664 | + } |
|
1589 | 1665 | |
1590 | 1666 | // Make sure it's an array. |
1591 | 1667 | $users = !is_array($users) ? array($users) : array_unique($users); |
@@ -1609,31 +1685,36 @@ discard block |
||
1609 | 1685 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1610 | 1686 | { |
1611 | 1687 | // BBC? |
1612 | - if (!empty($row['bbc'])) |
|
1613 | - $row['value'] = parse_bbc($row['value']); |
|
1688 | + if (!empty($row['bbc'])) { |
|
1689 | + $row['value'] = parse_bbc($row['value']); |
|
1690 | + } |
|
1614 | 1691 | |
1615 | 1692 | // ... or checkbox? |
1616 | - elseif (isset($row['type']) && $row['type'] == 'check') |
|
1617 | - $row['value'] = !empty($row['value']) ? $txt['yes'] : $txt['no']; |
|
1693 | + elseif (isset($row['type']) && $row['type'] == 'check') { |
|
1694 | + $row['value'] = !empty($row['value']) ? $txt['yes'] : $txt['no']; |
|
1695 | + } |
|
1618 | 1696 | |
1619 | 1697 | // Enclosing the user input within some other text? |
1620 | - if (!empty($row['enclose'])) |
|
1621 | - $row['value'] = strtr($row['enclose'], array( |
|
1698 | + if (!empty($row['enclose'])) { |
|
1699 | + $row['value'] = strtr($row['enclose'], array( |
|
1622 | 1700 | '{SCRIPTURL}' => $scripturl, |
1623 | 1701 | '{IMAGES_URL}' => $settings['images_url'], |
1624 | 1702 | '{DEFAULT_IMAGES_URL}' => $settings['default_images_url'], |
1625 | 1703 | '{INPUT}' => un_htmlspecialchars($row['value']), |
1626 | 1704 | )); |
1705 | + } |
|
1627 | 1706 | |
1628 | 1707 | // Send a simple array if there is just 1 param |
1629 | - if (count($params) == 1) |
|
1630 | - $return[$row['id_member']] = $row; |
|
1708 | + if (count($params) == 1) { |
|
1709 | + $return[$row['id_member']] = $row; |
|
1710 | + } |
|
1631 | 1711 | |
1632 | 1712 | // More than 1? knock yourself out... |
1633 | 1713 | else |
1634 | 1714 | { |
1635 | - if (!isset($return[$row['id_member']])) |
|
1636 | - $return[$row['id_member']] = array(); |
|
1715 | + if (!isset($return[$row['id_member']])) { |
|
1716 | + $return[$row['id_member']] = array(); |
|
1717 | + } |
|
1637 | 1718 | |
1638 | 1719 | $return[$row['id_member']][$row['variable']] = $row; |
1639 | 1720 | } |
@@ -1667,8 +1748,9 @@ discard block |
||
1667 | 1748 | global $context; |
1668 | 1749 | |
1669 | 1750 | // Don't know any browser! |
1670 | - if (empty($context['browser'])) |
|
1671 | - detectBrowser(); |
|
1751 | + if (empty($context['browser'])) { |
|
1752 | + detectBrowser(); |
|
1753 | + } |
|
1672 | 1754 | |
1673 | 1755 | return !empty($context['browser'][$browser]) || !empty($context['browser']['is_' . $browser]) ? true : false; |
1674 | 1756 | } |
@@ -1686,8 +1768,9 @@ discard block |
||
1686 | 1768 | global $context, $settings, $options, $sourcedir, $ssi_theme, $smcFunc, $language, $board, $image_proxy_enabled; |
1687 | 1769 | |
1688 | 1770 | // The theme was specified by parameter. |
1689 | - if (!empty($id_theme)) |
|
1690 | - $id_theme = (int) $id_theme; |
|
1771 | + if (!empty($id_theme)) { |
|
1772 | + $id_theme = (int) $id_theme; |
|
1773 | + } |
|
1691 | 1774 | // The theme was specified by REQUEST. |
1692 | 1775 | elseif (!empty($_REQUEST['theme']) && (!empty($modSettings['theme_allow']) || allowedTo('admin_forum'))) |
1693 | 1776 | { |
@@ -1695,54 +1778,61 @@ discard block |
||
1695 | 1778 | $_SESSION['id_theme'] = $id_theme; |
1696 | 1779 | } |
1697 | 1780 | // The theme was specified by REQUEST... previously. |
1698 | - elseif (!empty($_SESSION['id_theme']) && (!empty($modSettings['theme_allow']) || allowedTo('admin_forum'))) |
|
1699 | - $id_theme = (int) $_SESSION['id_theme']; |
|
1781 | + elseif (!empty($_SESSION['id_theme']) && (!empty($modSettings['theme_allow']) || allowedTo('admin_forum'))) { |
|
1782 | + $id_theme = (int) $_SESSION['id_theme']; |
|
1783 | + } |
|
1700 | 1784 | // The theme is just the user's choice. (might use ?board=1;theme=0 to force board theme.) |
1701 | - elseif (!empty($user_info['theme']) && !isset($_REQUEST['theme'])) |
|
1702 | - $id_theme = $user_info['theme']; |
|
1785 | + elseif (!empty($user_info['theme']) && !isset($_REQUEST['theme'])) { |
|
1786 | + $id_theme = $user_info['theme']; |
|
1787 | + } |
|
1703 | 1788 | // The theme was specified by the board. |
1704 | - elseif (!empty($board_info['theme'])) |
|
1705 | - $id_theme = $board_info['theme']; |
|
1789 | + elseif (!empty($board_info['theme'])) { |
|
1790 | + $id_theme = $board_info['theme']; |
|
1791 | + } |
|
1706 | 1792 | // The theme is the forum's default. |
1707 | - else |
|
1708 | - $id_theme = $modSettings['theme_guests']; |
|
1793 | + else { |
|
1794 | + $id_theme = $modSettings['theme_guests']; |
|
1795 | + } |
|
1709 | 1796 | |
1710 | 1797 | // We already load the basic stuff? |
1711 | 1798 | if (empty($settings['theme_id']) || $settings['theme_id'] != $id_theme ) |
1712 | 1799 | { |
1713 | 1800 | // Verify the id_theme... no foul play. |
1714 | 1801 | // Always allow the board specific theme, if they are overriding. |
1715 | - if (!empty($board_info['theme']) && $board_info['override_theme']) |
|
1716 | - $id_theme = $board_info['theme']; |
|
1802 | + if (!empty($board_info['theme']) && $board_info['override_theme']) { |
|
1803 | + $id_theme = $board_info['theme']; |
|
1804 | + } |
|
1717 | 1805 | // If they have specified a particular theme to use with SSI allow it to be used. |
1718 | - elseif (!empty($ssi_theme) && $id_theme == $ssi_theme) |
|
1719 | - $id_theme = (int) $id_theme; |
|
1720 | - elseif (!empty($modSettings['enableThemes']) && !allowedTo('admin_forum')) |
|
1806 | + elseif (!empty($ssi_theme) && $id_theme == $ssi_theme) { |
|
1807 | + $id_theme = (int) $id_theme; |
|
1808 | + } elseif (!empty($modSettings['enableThemes']) && !allowedTo('admin_forum')) |
|
1721 | 1809 | { |
1722 | 1810 | $themes = explode(',', $modSettings['enableThemes']); |
1723 | - if (!in_array($id_theme, $themes)) |
|
1724 | - $id_theme = $modSettings['theme_guests']; |
|
1725 | - else |
|
1726 | - $id_theme = (int) $id_theme; |
|
1811 | + if (!in_array($id_theme, $themes)) { |
|
1812 | + $id_theme = $modSettings['theme_guests']; |
|
1813 | + } else { |
|
1814 | + $id_theme = (int) $id_theme; |
|
1815 | + } |
|
1816 | + } else { |
|
1817 | + $id_theme = (int) $id_theme; |
|
1727 | 1818 | } |
1728 | - else |
|
1729 | - $id_theme = (int) $id_theme; |
|
1730 | 1819 | |
1731 | 1820 | $member = empty($user_info['id']) ? -1 : $user_info['id']; |
1732 | 1821 | |
1733 | 1822 | // Disable image proxy if we don't have SSL enabled |
1734 | - if (empty($modSettings['force_ssl']) || $modSettings['force_ssl'] < 2) |
|
1735 | - $image_proxy_enabled = false; |
|
1823 | + if (empty($modSettings['force_ssl']) || $modSettings['force_ssl'] < 2) { |
|
1824 | + $image_proxy_enabled = false; |
|
1825 | + } |
|
1736 | 1826 | |
1737 | 1827 | if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2 && ($temp = cache_get_data('theme_settings-' . $id_theme . ':' . $member, 60)) != null && time() - 60 > $modSettings['settings_updated']) |
1738 | 1828 | { |
1739 | 1829 | $themeData = $temp; |
1740 | 1830 | $flag = true; |
1831 | + } elseif (($temp = cache_get_data('theme_settings-' . $id_theme, 90)) != null && time() - 60 > $modSettings['settings_updated']) { |
|
1832 | + $themeData = $temp + array($member => array()); |
|
1833 | + } else { |
|
1834 | + $themeData = array(-1 => array(), 0 => array(), $member => array()); |
|
1741 | 1835 | } |
1742 | - elseif (($temp = cache_get_data('theme_settings-' . $id_theme, 90)) != null && time() - 60 > $modSettings['settings_updated']) |
|
1743 | - $themeData = $temp + array($member => array()); |
|
1744 | - else |
|
1745 | - $themeData = array(-1 => array(), 0 => array(), $member => array()); |
|
1746 | 1836 | |
1747 | 1837 | if (empty($flag)) |
1748 | 1838 | { |
@@ -1761,31 +1851,37 @@ discard block |
||
1761 | 1851 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
1762 | 1852 | { |
1763 | 1853 | // There are just things we shouldn't be able to change as members. |
1764 | - if ($row['id_member'] != 0 && in_array($row['variable'], array('actual_theme_url', 'actual_images_url', 'base_theme_dir', 'base_theme_url', 'default_images_url', 'default_theme_dir', 'default_theme_url', 'default_template', 'images_url', 'number_recent_posts', 'smiley_sets_default', 'theme_dir', 'theme_id', 'theme_layers', 'theme_templates', 'theme_url'))) |
|
1765 | - continue; |
|
1854 | + if ($row['id_member'] != 0 && in_array($row['variable'], array('actual_theme_url', 'actual_images_url', 'base_theme_dir', 'base_theme_url', 'default_images_url', 'default_theme_dir', 'default_theme_url', 'default_template', 'images_url', 'number_recent_posts', 'smiley_sets_default', 'theme_dir', 'theme_id', 'theme_layers', 'theme_templates', 'theme_url'))) { |
|
1855 | + continue; |
|
1856 | + } |
|
1766 | 1857 | |
1767 | 1858 | // If this is the theme_dir of the default theme, store it. |
1768 | - if (in_array($row['variable'], array('theme_dir', 'theme_url', 'images_url')) && $row['id_theme'] == '1' && empty($row['id_member'])) |
|
1769 | - $themeData[0]['default_' . $row['variable']] = $row['value']; |
|
1859 | + if (in_array($row['variable'], array('theme_dir', 'theme_url', 'images_url')) && $row['id_theme'] == '1' && empty($row['id_member'])) { |
|
1860 | + $themeData[0]['default_' . $row['variable']] = $row['value']; |
|
1861 | + } |
|
1770 | 1862 | |
1771 | 1863 | // If this isn't set yet, is a theme option, or is not the default theme.. |
1772 | - if (!isset($themeData[$row['id_member']][$row['variable']]) || $row['id_theme'] != '1') |
|
1773 | - $themeData[$row['id_member']][$row['variable']] = substr($row['variable'], 0, 5) == 'show_' ? $row['value'] == '1' : $row['value']; |
|
1864 | + if (!isset($themeData[$row['id_member']][$row['variable']]) || $row['id_theme'] != '1') { |
|
1865 | + $themeData[$row['id_member']][$row['variable']] = substr($row['variable'], 0, 5) == 'show_' ? $row['value'] == '1' : $row['value']; |
|
1866 | + } |
|
1774 | 1867 | } |
1775 | 1868 | $smcFunc['db_free_result']($result); |
1776 | 1869 | |
1777 | - if (!empty($themeData[-1])) |
|
1778 | - foreach ($themeData[-1] as $k => $v) |
|
1870 | + if (!empty($themeData[-1])) { |
|
1871 | + foreach ($themeData[-1] as $k => $v) |
|
1779 | 1872 | { |
1780 | 1873 | if (!isset($themeData[$member][$k])) |
1781 | 1874 | $themeData[$member][$k] = $v; |
1875 | + } |
|
1782 | 1876 | } |
1783 | 1877 | |
1784 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) |
|
1785 | - cache_put_data('theme_settings-' . $id_theme . ':' . $member, $themeData, 60); |
|
1878 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { |
|
1879 | + cache_put_data('theme_settings-' . $id_theme . ':' . $member, $themeData, 60); |
|
1880 | + } |
|
1786 | 1881 | // Only if we didn't already load that part of the cache... |
1787 | - elseif (!isset($temp)) |
|
1788 | - cache_put_data('theme_settings-' . $id_theme, array(-1 => $themeData[-1], 0 => $themeData[0]), 90); |
|
1882 | + elseif (!isset($temp)) { |
|
1883 | + cache_put_data('theme_settings-' . $id_theme, array(-1 => $themeData[-1], 0 => $themeData[0]), 90); |
|
1884 | + } |
|
1789 | 1885 | } |
1790 | 1886 | |
1791 | 1887 | $settings = $themeData[0]; |
@@ -1802,22 +1898,26 @@ discard block |
||
1802 | 1898 | $settings['template_dirs'][] = $settings['theme_dir']; |
1803 | 1899 | |
1804 | 1900 | // Based on theme (if there is one). |
1805 | - if (!empty($settings['base_theme_dir'])) |
|
1806 | - $settings['template_dirs'][] = $settings['base_theme_dir']; |
|
1901 | + if (!empty($settings['base_theme_dir'])) { |
|
1902 | + $settings['template_dirs'][] = $settings['base_theme_dir']; |
|
1903 | + } |
|
1807 | 1904 | |
1808 | 1905 | // Lastly the default theme. |
1809 | - if ($settings['theme_dir'] != $settings['default_theme_dir']) |
|
1810 | - $settings['template_dirs'][] = $settings['default_theme_dir']; |
|
1906 | + if ($settings['theme_dir'] != $settings['default_theme_dir']) { |
|
1907 | + $settings['template_dirs'][] = $settings['default_theme_dir']; |
|
1908 | + } |
|
1811 | 1909 | } |
1812 | 1910 | |
1813 | 1911 | |
1814 | - if (!$initialize) |
|
1815 | - return; |
|
1912 | + if (!$initialize) { |
|
1913 | + return; |
|
1914 | + } |
|
1816 | 1915 | |
1817 | 1916 | // Check to see if we're forcing SSL |
1818 | 1917 | if (!empty($modSettings['force_ssl']) && $modSettings['force_ssl'] == 2 && empty($maintenance) && |
1819 | - (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] == 'off') && SMF != 'SSI') |
|
1820 | - redirectexit(strtr($_SERVER['REQUEST_URL'], array('http://' => 'https://'))); |
|
1918 | + (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] == 'off') && SMF != 'SSI') { |
|
1919 | + redirectexit(strtr($_SERVER['REQUEST_URL'], array('http://' => 'https://'))); |
|
1920 | + } |
|
1821 | 1921 | |
1822 | 1922 | // Check to see if they're accessing it from the wrong place. |
1823 | 1923 | if (isset($_SERVER['HTTP_HOST']) || isset($_SERVER['SERVER_NAME'])) |
@@ -1825,8 +1925,9 @@ discard block |
||
1825 | 1925 | $detected_url = isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' ? 'https://' : 'http://'; |
1826 | 1926 | $detected_url .= empty($_SERVER['HTTP_HOST']) ? $_SERVER['SERVER_NAME'] . (empty($_SERVER['SERVER_PORT']) || $_SERVER['SERVER_PORT'] == '80' ? '' : ':' . $_SERVER['SERVER_PORT']) : $_SERVER['HTTP_HOST']; |
1827 | 1927 | $temp = preg_replace('~/' . basename($scripturl) . '(/.+)?$~', '', strtr(dirname($_SERVER['PHP_SELF']), '\\', '/')); |
1828 | - if ($temp != '/') |
|
1829 | - $detected_url .= $temp; |
|
1928 | + if ($temp != '/') { |
|
1929 | + $detected_url .= $temp; |
|
1930 | + } |
|
1830 | 1931 | } |
1831 | 1932 | if (isset($detected_url) && $detected_url != $boardurl) |
1832 | 1933 | { |
@@ -1838,8 +1939,9 @@ discard block |
||
1838 | 1939 | foreach ($aliases as $alias) |
1839 | 1940 | { |
1840 | 1941 | // Rip off all the boring parts, spaces, etc. |
1841 | - if ($detected_url == trim($alias) || strtr($detected_url, array('http://' => '', 'https://' => '')) == trim($alias)) |
|
1842 | - $do_fix = true; |
|
1942 | + if ($detected_url == trim($alias) || strtr($detected_url, array('http://' => '', 'https://' => '')) == trim($alias)) { |
|
1943 | + $do_fix = true; |
|
1944 | + } |
|
1843 | 1945 | } |
1844 | 1946 | } |
1845 | 1947 | |
@@ -1847,21 +1949,23 @@ discard block |
||
1847 | 1949 | if (empty($do_fix) && strtr($detected_url, array('://' => '://www.')) == $boardurl && (empty($_GET) || count($_GET) == 1) && SMF != 'SSI') |
1848 | 1950 | { |
1849 | 1951 | // Okay, this seems weird, but we don't want an endless loop - this will make $_GET not empty ;). |
1850 | - if (empty($_GET)) |
|
1851 | - redirectexit('wwwRedirect'); |
|
1852 | - else |
|
1952 | + if (empty($_GET)) { |
|
1953 | + redirectexit('wwwRedirect'); |
|
1954 | + } else |
|
1853 | 1955 | { |
1854 | 1956 | $k = key($_GET); |
1855 | 1957 | $v = current($_GET); |
1856 | 1958 | |
1857 | - if ($k != 'wwwRedirect') |
|
1858 | - redirectexit('wwwRedirect;' . $k . '=' . $v); |
|
1959 | + if ($k != 'wwwRedirect') { |
|
1960 | + redirectexit('wwwRedirect;' . $k . '=' . $v); |
|
1961 | + } |
|
1859 | 1962 | } |
1860 | 1963 | } |
1861 | 1964 | |
1862 | 1965 | // #3 is just a check for SSL... |
1863 | - if (strtr($detected_url, array('https://' => 'http://')) == $boardurl) |
|
1864 | - $do_fix = true; |
|
1966 | + if (strtr($detected_url, array('https://' => 'http://')) == $boardurl) { |
|
1967 | + $do_fix = true; |
|
1968 | + } |
|
1865 | 1969 | |
1866 | 1970 | // Okay, #4 - perhaps it's an IP address? We're gonna want to use that one, then. (assuming it's the IP or something...) |
1867 | 1971 | if (!empty($do_fix) || preg_match('~^http[s]?://(?:[\d\.:]+|\[[\d:]+\](?::\d+)?)(?:$|/)~', $detected_url) == 1) |
@@ -1896,8 +2000,9 @@ discard block |
||
1896 | 2000 | $board_info['moderators'][$k]['link'] = strtr($dummy['link'], array('"' . $oldurl => '"' . $boardurl)); |
1897 | 2001 | } |
1898 | 2002 | } |
1899 | - foreach ($context['linktree'] as $k => $dummy) |
|
1900 | - $context['linktree'][$k]['url'] = strtr($dummy['url'], array($oldurl => $boardurl)); |
|
2003 | + foreach ($context['linktree'] as $k => $dummy) { |
|
2004 | + $context['linktree'][$k]['url'] = strtr($dummy['url'], array($oldurl => $boardurl)); |
|
2005 | + } |
|
1901 | 2006 | } |
1902 | 2007 | } |
1903 | 2008 | // Set up the contextual user array. |
@@ -1916,16 +2021,16 @@ discard block |
||
1916 | 2021 | 'email' => $user_info['email'], |
1917 | 2022 | 'ignoreusers' => $user_info['ignoreusers'], |
1918 | 2023 | ); |
1919 | - if (!$context['user']['is_guest']) |
|
1920 | - $context['user']['name'] = $user_info['name']; |
|
1921 | - elseif ($context['user']['is_guest'] && !empty($txt['guest_title'])) |
|
1922 | - $context['user']['name'] = $txt['guest_title']; |
|
2024 | + if (!$context['user']['is_guest']) { |
|
2025 | + $context['user']['name'] = $user_info['name']; |
|
2026 | + } elseif ($context['user']['is_guest'] && !empty($txt['guest_title'])) { |
|
2027 | + $context['user']['name'] = $txt['guest_title']; |
|
2028 | + } |
|
1923 | 2029 | |
1924 | 2030 | // Determine the current smiley set. |
1925 | 2031 | $user_info['smiley_set'] = (!in_array($user_info['smiley_set'], explode(',', $modSettings['smiley_sets_known'])) && $user_info['smiley_set'] != 'none') || empty($modSettings['smiley_sets_enable']) ? (!empty($settings['smiley_sets_default']) ? $settings['smiley_sets_default'] : $modSettings['smiley_sets_default']) : $user_info['smiley_set']; |
1926 | 2032 | $context['user']['smiley_set'] = $user_info['smiley_set']; |
1927 | - } |
|
1928 | - else |
|
2033 | + } else |
|
1929 | 2034 | { |
1930 | 2035 | // What to do when there is no $user_info (e.g., an error very early in the login process) |
1931 | 2036 | $context['user'] = array( |
@@ -1959,18 +2064,24 @@ discard block |
||
1959 | 2064 | } |
1960 | 2065 | |
1961 | 2066 | // Some basic information... |
1962 | - if (!isset($context['html_headers'])) |
|
1963 | - $context['html_headers'] = ''; |
|
1964 | - if (!isset($context['javascript_files'])) |
|
1965 | - $context['javascript_files'] = array(); |
|
1966 | - if (!isset($context['css_files'])) |
|
1967 | - $context['css_files'] = array(); |
|
1968 | - if (!isset($context['css_header'])) |
|
1969 | - $context['css_header'] = array(); |
|
1970 | - if (!isset($context['javascript_inline'])) |
|
1971 | - $context['javascript_inline'] = array('standard' => array(), 'defer' => array()); |
|
1972 | - if (!isset($context['javascript_vars'])) |
|
1973 | - $context['javascript_vars'] = array(); |
|
2067 | + if (!isset($context['html_headers'])) { |
|
2068 | + $context['html_headers'] = ''; |
|
2069 | + } |
|
2070 | + if (!isset($context['javascript_files'])) { |
|
2071 | + $context['javascript_files'] = array(); |
|
2072 | + } |
|
2073 | + if (!isset($context['css_files'])) { |
|
2074 | + $context['css_files'] = array(); |
|
2075 | + } |
|
2076 | + if (!isset($context['css_header'])) { |
|
2077 | + $context['css_header'] = array(); |
|
2078 | + } |
|
2079 | + if (!isset($context['javascript_inline'])) { |
|
2080 | + $context['javascript_inline'] = array('standard' => array(), 'defer' => array()); |
|
2081 | + } |
|
2082 | + if (!isset($context['javascript_vars'])) { |
|
2083 | + $context['javascript_vars'] = array(); |
|
2084 | + } |
|
1974 | 2085 | |
1975 | 2086 | $context['login_url'] = (!empty($modSettings['force_ssl']) && $modSettings['force_ssl'] < 2 ? strtr($scripturl, array('http://' => 'https://')) : $scripturl) . '?action=login2'; |
1976 | 2087 | $context['menu_separator'] = !empty($settings['use_image_buttons']) ? ' ' : ' | '; |
@@ -1982,16 +2093,18 @@ discard block |
||
1982 | 2093 | $context['current_action'] = isset($_REQUEST['action']) ? $smcFunc['htmlspecialchars']($_REQUEST['action']) : null; |
1983 | 2094 | $context['current_subaction'] = isset($_REQUEST['sa']) ? $_REQUEST['sa'] : null; |
1984 | 2095 | $context['can_register'] = empty($modSettings['registration_method']) || $modSettings['registration_method'] != 3; |
1985 | - if (isset($modSettings['load_average'])) |
|
1986 | - $context['load_average'] = $modSettings['load_average']; |
|
2096 | + if (isset($modSettings['load_average'])) { |
|
2097 | + $context['load_average'] = $modSettings['load_average']; |
|
2098 | + } |
|
1987 | 2099 | |
1988 | 2100 | // Detect the browser. This is separated out because it's also used in attachment downloads |
1989 | 2101 | detectBrowser(); |
1990 | 2102 | |
1991 | 2103 | // Set the top level linktree up. |
1992 | 2104 | // Note that if we're dealing with certain very early errors (e.g., login) the linktree might not be set yet... |
1993 | - if (empty($context['linktree'])) |
|
1994 | - $context['linktree'] = array(); |
|
2105 | + if (empty($context['linktree'])) { |
|
2106 | + $context['linktree'] = array(); |
|
2107 | + } |
|
1995 | 2108 | array_unshift($context['linktree'], array( |
1996 | 2109 | 'url' => $scripturl, |
1997 | 2110 | 'name' => $context['forum_name_html_safe'] |
@@ -2000,8 +2113,9 @@ discard block |
||
2000 | 2113 | // This allows sticking some HTML on the page output - useful for controls. |
2001 | 2114 | $context['insert_after_template'] = ''; |
2002 | 2115 | |
2003 | - if (!isset($txt)) |
|
2004 | - $txt = array(); |
|
2116 | + if (!isset($txt)) { |
|
2117 | + $txt = array(); |
|
2118 | + } |
|
2005 | 2119 | |
2006 | 2120 | $simpleActions = array( |
2007 | 2121 | 'findmember', |
@@ -2047,9 +2161,10 @@ discard block |
||
2047 | 2161 | |
2048 | 2162 | // See if theres any extra param to check. |
2049 | 2163 | $requiresXML = false; |
2050 | - foreach ($extraParams as $key => $extra) |
|
2051 | - if (isset($_REQUEST[$extra])) |
|
2164 | + foreach ($extraParams as $key => $extra) { |
|
2165 | + if (isset($_REQUEST[$extra])) |
|
2052 | 2166 | $requiresXML = true; |
2167 | + } |
|
2053 | 2168 | |
2054 | 2169 | // Output is fully XML, so no need for the index template. |
2055 | 2170 | if (isset($_REQUEST['xml']) && (in_array($context['current_action'], $xmlActions) || $requiresXML)) |
@@ -2064,37 +2179,39 @@ discard block |
||
2064 | 2179 | { |
2065 | 2180 | loadLanguage('index+Modifications'); |
2066 | 2181 | $context['template_layers'] = array(); |
2067 | - } |
|
2068 | - |
|
2069 | - else |
|
2182 | + } else |
|
2070 | 2183 | { |
2071 | 2184 | // Custom templates to load, or just default? |
2072 | - if (isset($settings['theme_templates'])) |
|
2073 | - $templates = explode(',', $settings['theme_templates']); |
|
2074 | - else |
|
2075 | - $templates = array('index'); |
|
2185 | + if (isset($settings['theme_templates'])) { |
|
2186 | + $templates = explode(',', $settings['theme_templates']); |
|
2187 | + } else { |
|
2188 | + $templates = array('index'); |
|
2189 | + } |
|
2076 | 2190 | |
2077 | 2191 | // Load each template... |
2078 | - foreach ($templates as $template) |
|
2079 | - loadTemplate($template); |
|
2192 | + foreach ($templates as $template) { |
|
2193 | + loadTemplate($template); |
|
2194 | + } |
|
2080 | 2195 | |
2081 | 2196 | // ...and attempt to load their associated language files. |
2082 | 2197 | $required_files = implode('+', array_merge($templates, array('Modifications'))); |
2083 | 2198 | loadLanguage($required_files, '', false); |
2084 | 2199 | |
2085 | 2200 | // Custom template layers? |
2086 | - if (isset($settings['theme_layers'])) |
|
2087 | - $context['template_layers'] = explode(',', $settings['theme_layers']); |
|
2088 | - else |
|
2089 | - $context['template_layers'] = array('html', 'body'); |
|
2201 | + if (isset($settings['theme_layers'])) { |
|
2202 | + $context['template_layers'] = explode(',', $settings['theme_layers']); |
|
2203 | + } else { |
|
2204 | + $context['template_layers'] = array('html', 'body'); |
|
2205 | + } |
|
2090 | 2206 | } |
2091 | 2207 | |
2092 | 2208 | // Initialize the theme. |
2093 | 2209 | loadSubTemplate('init', 'ignore'); |
2094 | 2210 | |
2095 | 2211 | // Allow overriding the board wide time/number formats. |
2096 | - if (empty($user_settings['time_format']) && !empty($txt['time_format'])) |
|
2097 | - $user_info['time_format'] = $txt['time_format']; |
|
2212 | + if (empty($user_settings['time_format']) && !empty($txt['time_format'])) { |
|
2213 | + $user_info['time_format'] = $txt['time_format']; |
|
2214 | + } |
|
2098 | 2215 | |
2099 | 2216 | // Set the character set from the template. |
2100 | 2217 | $context['character_set'] = empty($modSettings['global_character_set']) ? $txt['lang_character_set'] : $modSettings['global_character_set']; |
@@ -2102,12 +2219,14 @@ discard block |
||
2102 | 2219 | $context['right_to_left'] = !empty($txt['lang_rtl']); |
2103 | 2220 | |
2104 | 2221 | // Guests may still need a name. |
2105 | - if ($context['user']['is_guest'] && empty($context['user']['name'])) |
|
2106 | - $context['user']['name'] = $txt['guest_title']; |
|
2222 | + if ($context['user']['is_guest'] && empty($context['user']['name'])) { |
|
2223 | + $context['user']['name'] = $txt['guest_title']; |
|
2224 | + } |
|
2107 | 2225 | |
2108 | 2226 | // Any theme-related strings that need to be loaded? |
2109 | - if (!empty($settings['require_theme_strings'])) |
|
2110 | - loadLanguage('ThemeStrings', '', false); |
|
2227 | + if (!empty($settings['require_theme_strings'])) { |
|
2228 | + loadLanguage('ThemeStrings', '', false); |
|
2229 | + } |
|
2111 | 2230 | |
2112 | 2231 | // Make a special URL for the language. |
2113 | 2232 | $settings['lang_images_url'] = $settings['images_url'] . '/' . (!empty($txt['image_lang']) ? $txt['image_lang'] : $user_info['language']); |
@@ -2118,8 +2237,9 @@ discard block |
||
2118 | 2237 | // Here is my luvly Responsive CSS |
2119 | 2238 | loadCSSFile('responsive.css', array('force_current' => false, 'validate' => true, 'minimize' => true), 'smf_responsive'); |
2120 | 2239 | |
2121 | - if ($context['right_to_left']) |
|
2122 | - loadCSSFile('rtl.css', array(), 'smf_rtl'); |
|
2240 | + if ($context['right_to_left']) { |
|
2241 | + loadCSSFile('rtl.css', array(), 'smf_rtl'); |
|
2242 | + } |
|
2123 | 2243 | |
2124 | 2244 | // We allow theme variants, because we're cool. |
2125 | 2245 | $context['theme_variant'] = ''; |
@@ -2127,14 +2247,17 @@ discard block |
||
2127 | 2247 | if (!empty($settings['theme_variants'])) |
2128 | 2248 | { |
2129 | 2249 | // Overriding - for previews and that ilk. |
2130 | - if (!empty($_REQUEST['variant'])) |
|
2131 | - $_SESSION['id_variant'] = $_REQUEST['variant']; |
|
2250 | + if (!empty($_REQUEST['variant'])) { |
|
2251 | + $_SESSION['id_variant'] = $_REQUEST['variant']; |
|
2252 | + } |
|
2132 | 2253 | // User selection? |
2133 | - if (empty($settings['disable_user_variant']) || allowedTo('admin_forum')) |
|
2134 | - $context['theme_variant'] = !empty($_SESSION['id_variant']) ? $_SESSION['id_variant'] : (!empty($options['theme_variant']) ? $options['theme_variant'] : ''); |
|
2254 | + if (empty($settings['disable_user_variant']) || allowedTo('admin_forum')) { |
|
2255 | + $context['theme_variant'] = !empty($_SESSION['id_variant']) ? $_SESSION['id_variant'] : (!empty($options['theme_variant']) ? $options['theme_variant'] : ''); |
|
2256 | + } |
|
2135 | 2257 | // If not a user variant, select the default. |
2136 | - if ($context['theme_variant'] == '' || !in_array($context['theme_variant'], $settings['theme_variants'])) |
|
2137 | - $context['theme_variant'] = !empty($settings['default_variant']) && in_array($settings['default_variant'], $settings['theme_variants']) ? $settings['default_variant'] : $settings['theme_variants'][0]; |
|
2258 | + if ($context['theme_variant'] == '' || !in_array($context['theme_variant'], $settings['theme_variants'])) { |
|
2259 | + $context['theme_variant'] = !empty($settings['default_variant']) && in_array($settings['default_variant'], $settings['theme_variants']) ? $settings['default_variant'] : $settings['theme_variants'][0]; |
|
2260 | + } |
|
2138 | 2261 | |
2139 | 2262 | // Do this to keep things easier in the templates. |
2140 | 2263 | $context['theme_variant'] = '_' . $context['theme_variant']; |
@@ -2143,20 +2266,23 @@ discard block |
||
2143 | 2266 | if (!empty($context['theme_variant'])) |
2144 | 2267 | { |
2145 | 2268 | loadCSSFile('index' . $context['theme_variant'] . '.css', array(), 'smf_index' . $context['theme_variant']); |
2146 | - if ($context['right_to_left']) |
|
2147 | - loadCSSFile('rtl' . $context['theme_variant'] . '.css', array(), 'smf_rtl' . $context['theme_variant']); |
|
2269 | + if ($context['right_to_left']) { |
|
2270 | + loadCSSFile('rtl' . $context['theme_variant'] . '.css', array(), 'smf_rtl' . $context['theme_variant']); |
|
2271 | + } |
|
2148 | 2272 | } |
2149 | 2273 | } |
2150 | 2274 | |
2151 | 2275 | // Let's be compatible with old themes! |
2152 | - if (!function_exists('template_html_above') && in_array('html', $context['template_layers'])) |
|
2153 | - $context['template_layers'] = array('main'); |
|
2276 | + if (!function_exists('template_html_above') && in_array('html', $context['template_layers'])) { |
|
2277 | + $context['template_layers'] = array('main'); |
|
2278 | + } |
|
2154 | 2279 | |
2155 | 2280 | $context['tabindex'] = 1; |
2156 | 2281 | |
2157 | 2282 | // Compatibility. |
2158 | - if (!isset($settings['theme_version'])) |
|
2159 | - $modSettings['memberCount'] = $modSettings['totalMembers']; |
|
2283 | + if (!isset($settings['theme_version'])) { |
|
2284 | + $modSettings['memberCount'] = $modSettings['totalMembers']; |
|
2285 | + } |
|
2160 | 2286 | |
2161 | 2287 | // Default JS variables for use in every theme |
2162 | 2288 | $context['javascript_vars'] = array( |
@@ -2175,18 +2301,18 @@ discard block |
||
2175 | 2301 | ); |
2176 | 2302 | |
2177 | 2303 | // Add the JQuery library to the list of files to load. |
2178 | - if (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'cdn') |
|
2179 | - loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js', array('external' => true), 'smf_jquery'); |
|
2180 | - |
|
2181 | - elseif (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'local') |
|
2182 | - loadJavaScriptFile('jquery-3.2.1.min.js', array('seed' => false), 'smf_jquery'); |
|
2183 | - |
|
2184 | - elseif (isset($modSettings['jquery_source'], $modSettings['jquery_custom']) && $modSettings['jquery_source'] == 'custom') |
|
2185 | - loadJavaScriptFile($modSettings['jquery_custom'], array('external' => true), 'smf_jquery'); |
|
2304 | + if (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'cdn') { |
|
2305 | + loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js', array('external' => true), 'smf_jquery'); |
|
2306 | + } elseif (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'local') { |
|
2307 | + loadJavaScriptFile('jquery-3.2.1.min.js', array('seed' => false), 'smf_jquery'); |
|
2308 | + } elseif (isset($modSettings['jquery_source'], $modSettings['jquery_custom']) && $modSettings['jquery_source'] == 'custom') { |
|
2309 | + loadJavaScriptFile($modSettings['jquery_custom'], array('external' => true), 'smf_jquery'); |
|
2310 | + } |
|
2186 | 2311 | |
2187 | 2312 | // Auto loading? template_javascript() will take care of the local half of this. |
2188 | - else |
|
2189 | - loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js', array('external' => true), 'smf_jquery'); |
|
2313 | + else { |
|
2314 | + loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js', array('external' => true), 'smf_jquery'); |
|
2315 | + } |
|
2190 | 2316 | |
2191 | 2317 | // Queue our JQuery plugins! |
2192 | 2318 | loadJavaScriptFile('smf_jquery_plugins.js', array('minimize' => true), 'smf_jquery_plugins'); |
@@ -2209,12 +2335,12 @@ discard block |
||
2209 | 2335 | require_once($sourcedir . '/ScheduledTasks.php'); |
2210 | 2336 | |
2211 | 2337 | // What to do, what to do?! |
2212 | - if (empty($modSettings['next_task_time']) || $modSettings['next_task_time'] < time()) |
|
2213 | - AutoTask(); |
|
2214 | - else |
|
2215 | - ReduceMailQueue(); |
|
2216 | - } |
|
2217 | - else |
|
2338 | + if (empty($modSettings['next_task_time']) || $modSettings['next_task_time'] < time()) { |
|
2339 | + AutoTask(); |
|
2340 | + } else { |
|
2341 | + ReduceMailQueue(); |
|
2342 | + } |
|
2343 | + } else |
|
2218 | 2344 | { |
2219 | 2345 | $type = empty($modSettings['next_task_time']) || $modSettings['next_task_time'] < time() ? 'task' : 'mailq'; |
2220 | 2346 | $ts = $type == 'mailq' ? $modSettings['mail_next_send'] : $modSettings['next_task_time']; |
@@ -2265,8 +2391,9 @@ discard block |
||
2265 | 2391 | foreach ($theme_includes as $include) |
2266 | 2392 | { |
2267 | 2393 | $include = strtr(trim($include), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir'])); |
2268 | - if (file_exists($include)) |
|
2269 | - require_once($include); |
|
2394 | + if (file_exists($include)) { |
|
2395 | + require_once($include); |
|
2396 | + } |
|
2270 | 2397 | } |
2271 | 2398 | } |
2272 | 2399 | |
@@ -2296,16 +2423,19 @@ discard block |
||
2296 | 2423 | // Do any style sheets first, cause we're easy with those. |
2297 | 2424 | if (!empty($style_sheets)) |
2298 | 2425 | { |
2299 | - if (!is_array($style_sheets)) |
|
2300 | - $style_sheets = array($style_sheets); |
|
2426 | + if (!is_array($style_sheets)) { |
|
2427 | + $style_sheets = array($style_sheets); |
|
2428 | + } |
|
2301 | 2429 | |
2302 | - foreach ($style_sheets as $sheet) |
|
2303 | - loadCSSFile($sheet . '.css', array(), $sheet); |
|
2430 | + foreach ($style_sheets as $sheet) { |
|
2431 | + loadCSSFile($sheet . '.css', array(), $sheet); |
|
2432 | + } |
|
2304 | 2433 | } |
2305 | 2434 | |
2306 | 2435 | // No template to load? |
2307 | - if ($template_name === false) |
|
2308 | - return true; |
|
2436 | + if ($template_name === false) { |
|
2437 | + return true; |
|
2438 | + } |
|
2309 | 2439 | |
2310 | 2440 | $loaded = false; |
2311 | 2441 | foreach ($settings['template_dirs'] as $template_dir) |
@@ -2320,12 +2450,14 @@ discard block |
||
2320 | 2450 | |
2321 | 2451 | if ($loaded) |
2322 | 2452 | { |
2323 | - if ($db_show_debug === true) |
|
2324 | - $context['debug']['templates'][] = $template_name . ' (' . basename($template_dir) . ')'; |
|
2453 | + if ($db_show_debug === true) { |
|
2454 | + $context['debug']['templates'][] = $template_name . ' (' . basename($template_dir) . ')'; |
|
2455 | + } |
|
2325 | 2456 | |
2326 | 2457 | // If they have specified an initialization function for this template, go ahead and call it now. |
2327 | - if (function_exists('template_' . $template_name . '_init')) |
|
2328 | - call_user_func('template_' . $template_name . '_init'); |
|
2458 | + if (function_exists('template_' . $template_name . '_init')) { |
|
2459 | + call_user_func('template_' . $template_name . '_init'); |
|
2460 | + } |
|
2329 | 2461 | } |
2330 | 2462 | // Hmmm... doesn't exist?! I don't suppose the directory is wrong, is it? |
2331 | 2463 | elseif (!file_exists($settings['default_theme_dir']) && file_exists($boarddir . '/Themes/default')) |
@@ -2345,13 +2477,14 @@ discard block |
||
2345 | 2477 | loadTemplate($template_name); |
2346 | 2478 | } |
2347 | 2479 | // Cause an error otherwise. |
2348 | - elseif ($template_name != 'Errors' && $template_name != 'index' && $fatal) |
|
2349 | - fatal_lang_error('theme_template_error', 'template', array((string) $template_name)); |
|
2350 | - elseif ($fatal) |
|
2351 | - die(log_error(sprintf(isset($txt['theme_template_error']) ? $txt['theme_template_error'] : 'Unable to load Themes/default/%s.template.php!', (string) $template_name), 'template')); |
|
2352 | - else |
|
2353 | - return false; |
|
2354 | -} |
|
2480 | + elseif ($template_name != 'Errors' && $template_name != 'index' && $fatal) { |
|
2481 | + fatal_lang_error('theme_template_error', 'template', array((string) $template_name)); |
|
2482 | + } elseif ($fatal) { |
|
2483 | + die(log_error(sprintf(isset($txt['theme_template_error']) ? $txt['theme_template_error'] : 'Unable to load Themes/default/%s.template.php!', (string) $template_name), 'template')); |
|
2484 | + } else { |
|
2485 | + return false; |
|
2486 | + } |
|
2487 | + } |
|
2355 | 2488 | |
2356 | 2489 | /** |
2357 | 2490 | * Load a sub-template. |
@@ -2369,17 +2502,19 @@ discard block |
||
2369 | 2502 | { |
2370 | 2503 | global $context, $txt, $db_show_debug; |
2371 | 2504 | |
2372 | - if ($db_show_debug === true) |
|
2373 | - $context['debug']['sub_templates'][] = $sub_template_name; |
|
2505 | + if ($db_show_debug === true) { |
|
2506 | + $context['debug']['sub_templates'][] = $sub_template_name; |
|
2507 | + } |
|
2374 | 2508 | |
2375 | 2509 | // Figure out what the template function is named. |
2376 | 2510 | $theme_function = 'template_' . $sub_template_name; |
2377 | - if (function_exists($theme_function)) |
|
2378 | - $theme_function(); |
|
2379 | - elseif ($fatal === false) |
|
2380 | - fatal_lang_error('theme_template_error', 'template', array((string) $sub_template_name)); |
|
2381 | - elseif ($fatal !== 'ignore') |
|
2382 | - die(log_error(sprintf(isset($txt['theme_template_error']) ? $txt['theme_template_error'] : 'Unable to load the %s sub template!', (string) $sub_template_name), 'template')); |
|
2511 | + if (function_exists($theme_function)) { |
|
2512 | + $theme_function(); |
|
2513 | + } elseif ($fatal === false) { |
|
2514 | + fatal_lang_error('theme_template_error', 'template', array((string) $sub_template_name)); |
|
2515 | + } elseif ($fatal !== 'ignore') { |
|
2516 | + die(log_error(sprintf(isset($txt['theme_template_error']) ? $txt['theme_template_error'] : 'Unable to load the %s sub template!', (string) $sub_template_name), 'template')); |
|
2517 | + } |
|
2383 | 2518 | |
2384 | 2519 | // Are we showing debugging for templates? Just make sure not to do it before the doctype... |
2385 | 2520 | if (allowedTo('admin_forum') && isset($_REQUEST['debug']) && !in_array($sub_template_name, array('init', 'main_below')) && ob_get_length() > 0 && !isset($_REQUEST['xml'])) |
@@ -2416,8 +2551,9 @@ discard block |
||
2416 | 2551 | $params['validate'] = isset($params['validate']) ? $params['validate'] : true; |
2417 | 2552 | |
2418 | 2553 | // If this is an external file, automatically set this to false. |
2419 | - if (!empty($params['external'])) |
|
2420 | - $params['minimize'] = false; |
|
2554 | + if (!empty($params['external'])) { |
|
2555 | + $params['minimize'] = false; |
|
2556 | + } |
|
2421 | 2557 | |
2422 | 2558 | // Account for shorthand like admin.css?alp21 filenames |
2423 | 2559 | $has_seed = strpos($fileName, '.css?'); |
@@ -2434,13 +2570,10 @@ discard block |
||
2434 | 2570 | { |
2435 | 2571 | $fileUrl = $settings['default_theme_url'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']); |
2436 | 2572 | $filePath = $settings['default_theme_dir'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']); |
2573 | + } else { |
|
2574 | + $fileUrl = false; |
|
2437 | 2575 | } |
2438 | - |
|
2439 | - else |
|
2440 | - $fileUrl = false; |
|
2441 | - } |
|
2442 | - |
|
2443 | - else |
|
2576 | + } else |
|
2444 | 2577 | { |
2445 | 2578 | $fileUrl = $settings[$themeRef . '_url'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']); |
2446 | 2579 | $filePath = $settings[$themeRef . '_dir'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']); |
@@ -2455,12 +2588,14 @@ discard block |
||
2455 | 2588 | } |
2456 | 2589 | |
2457 | 2590 | // Add it to the array for use in the template |
2458 | - if (!empty($fileName)) |
|
2459 | - $context['css_files'][$id] = array('fileUrl' => $fileUrl, 'filePath' => $filePath, 'fileName' => $fileName, 'options' => $params); |
|
2591 | + if (!empty($fileName)) { |
|
2592 | + $context['css_files'][$id] = array('fileUrl' => $fileUrl, 'filePath' => $filePath, 'fileName' => $fileName, 'options' => $params); |
|
2593 | + } |
|
2460 | 2594 | |
2461 | - if (!empty($context['right_to_left']) && !empty($params['rtl'])) |
|
2462 | - loadCSSFile($params['rtl'], array_diff_key($params, array('rtl' => 0))); |
|
2463 | -} |
|
2595 | + if (!empty($context['right_to_left']) && !empty($params['rtl'])) { |
|
2596 | + loadCSSFile($params['rtl'], array_diff_key($params, array('rtl' => 0))); |
|
2597 | + } |
|
2598 | + } |
|
2464 | 2599 | |
2465 | 2600 | /** |
2466 | 2601 | * Add a block of inline css code to be executed later |
@@ -2477,8 +2612,9 @@ discard block |
||
2477 | 2612 | global $context; |
2478 | 2613 | |
2479 | 2614 | // Gotta add something... |
2480 | - if (empty($css)) |
|
2481 | - return false; |
|
2615 | + if (empty($css)) { |
|
2616 | + return false; |
|
2617 | + } |
|
2482 | 2618 | |
2483 | 2619 | $context['css_header'][] = $css; |
2484 | 2620 | } |
@@ -2513,8 +2649,9 @@ discard block |
||
2513 | 2649 | $params['validate'] = isset($params['validate']) ? $params['validate'] : true; |
2514 | 2650 | |
2515 | 2651 | // If this is an external file, automatically set this to false. |
2516 | - if (!empty($params['external'])) |
|
2517 | - $params['minimize'] = false; |
|
2652 | + if (!empty($params['external'])) { |
|
2653 | + $params['minimize'] = false; |
|
2654 | + } |
|
2518 | 2655 | |
2519 | 2656 | // Account for shorthand like admin.js?alp21 filenames |
2520 | 2657 | $has_seed = strpos($fileName, '.js?'); |
@@ -2531,16 +2668,12 @@ discard block |
||
2531 | 2668 | { |
2532 | 2669 | $fileUrl = $settings['default_theme_url'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']); |
2533 | 2670 | $filePath = $settings['default_theme_dir'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']); |
2534 | - } |
|
2535 | - |
|
2536 | - else |
|
2671 | + } else |
|
2537 | 2672 | { |
2538 | 2673 | $fileUrl = false; |
2539 | 2674 | $filePath = false; |
2540 | 2675 | } |
2541 | - } |
|
2542 | - |
|
2543 | - else |
|
2676 | + } else |
|
2544 | 2677 | { |
2545 | 2678 | $fileUrl = $settings[$themeRef . '_url'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']); |
2546 | 2679 | $filePath = $settings[$themeRef . '_dir'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']); |
@@ -2555,9 +2688,10 @@ discard block |
||
2555 | 2688 | } |
2556 | 2689 | |
2557 | 2690 | // Add it to the array for use in the template |
2558 | - if (!empty($fileName)) |
|
2559 | - $context['javascript_files'][$id] = array('fileUrl' => $fileUrl, 'filePath' => $filePath, 'fileName' => $fileName, 'options' => $params); |
|
2560 | -} |
|
2691 | + if (!empty($fileName)) { |
|
2692 | + $context['javascript_files'][$id] = array('fileUrl' => $fileUrl, 'filePath' => $filePath, 'fileName' => $fileName, 'options' => $params); |
|
2693 | + } |
|
2694 | + } |
|
2561 | 2695 | |
2562 | 2696 | /** |
2563 | 2697 | * Add a Javascript variable for output later (for feeding text strings and similar to JS) |
@@ -2571,9 +2705,10 @@ discard block |
||
2571 | 2705 | { |
2572 | 2706 | global $context; |
2573 | 2707 | |
2574 | - if (!empty($key) && (!empty($value) || $value === '0')) |
|
2575 | - $context['javascript_vars'][$key] = !empty($escape) ? JavaScriptEscape($value) : $value; |
|
2576 | -} |
|
2708 | + if (!empty($key) && (!empty($value) || $value === '0')) { |
|
2709 | + $context['javascript_vars'][$key] = !empty($escape) ? JavaScriptEscape($value) : $value; |
|
2710 | + } |
|
2711 | + } |
|
2577 | 2712 | |
2578 | 2713 | /** |
2579 | 2714 | * Add a block of inline Javascript code to be executed later |
@@ -2590,8 +2725,9 @@ discard block |
||
2590 | 2725 | { |
2591 | 2726 | global $context; |
2592 | 2727 | |
2593 | - if (empty($javascript)) |
|
2594 | - return false; |
|
2728 | + if (empty($javascript)) { |
|
2729 | + return false; |
|
2730 | + } |
|
2595 | 2731 | |
2596 | 2732 | $context['javascript_inline'][($defer === true ? 'defer' : 'standard')][] = $javascript; |
2597 | 2733 | } |
@@ -2612,15 +2748,18 @@ discard block |
||
2612 | 2748 | static $already_loaded = array(); |
2613 | 2749 | |
2614 | 2750 | // Default to the user's language. |
2615 | - if ($lang == '') |
|
2616 | - $lang = isset($user_info['language']) ? $user_info['language'] : $language; |
|
2751 | + if ($lang == '') { |
|
2752 | + $lang = isset($user_info['language']) ? $user_info['language'] : $language; |
|
2753 | + } |
|
2617 | 2754 | |
2618 | 2755 | // Do we want the English version of language file as fallback? |
2619 | - if (empty($modSettings['disable_language_fallback']) && $lang != 'english') |
|
2620 | - loadLanguage($template_name, 'english', false); |
|
2756 | + if (empty($modSettings['disable_language_fallback']) && $lang != 'english') { |
|
2757 | + loadLanguage($template_name, 'english', false); |
|
2758 | + } |
|
2621 | 2759 | |
2622 | - if (!$force_reload && isset($already_loaded[$template_name]) && $already_loaded[$template_name] == $lang) |
|
2623 | - return $lang; |
|
2760 | + if (!$force_reload && isset($already_loaded[$template_name]) && $already_loaded[$template_name] == $lang) { |
|
2761 | + return $lang; |
|
2762 | + } |
|
2624 | 2763 | |
2625 | 2764 | // Make sure we have $settings - if not we're in trouble and need to find it! |
2626 | 2765 | if (empty($settings['default_theme_dir'])) |
@@ -2631,8 +2770,9 @@ discard block |
||
2631 | 2770 | |
2632 | 2771 | // What theme are we in? |
2633 | 2772 | $theme_name = basename($settings['theme_url']); |
2634 | - if (empty($theme_name)) |
|
2635 | - $theme_name = 'unknown'; |
|
2773 | + if (empty($theme_name)) { |
|
2774 | + $theme_name = 'unknown'; |
|
2775 | + } |
|
2636 | 2776 | |
2637 | 2777 | // For each file open it up and write it out! |
2638 | 2778 | foreach (explode('+', $template_name) as $template) |
@@ -2674,8 +2814,9 @@ discard block |
||
2674 | 2814 | $found = true; |
2675 | 2815 | |
2676 | 2816 | // setlocale is required for basename() & pathinfo() to work properly on the selected language |
2677 | - if (!empty($txt['lang_locale']) && !empty($modSettings['global_character_set'])) |
|
2678 | - setlocale(LC_CTYPE, $txt['lang_locale'] . '.' . $modSettings['global_character_set']); |
|
2817 | + if (!empty($txt['lang_locale']) && !empty($modSettings['global_character_set'])) { |
|
2818 | + setlocale(LC_CTYPE, $txt['lang_locale'] . '.' . $modSettings['global_character_set']); |
|
2819 | + } |
|
2679 | 2820 | |
2680 | 2821 | break; |
2681 | 2822 | } |
@@ -2715,8 +2856,9 @@ discard block |
||
2715 | 2856 | } |
2716 | 2857 | |
2717 | 2858 | // Keep track of what we're up to soldier. |
2718 | - if ($db_show_debug === true) |
|
2719 | - $context['debug']['language_files'][] = $template_name . '.' . $lang . ' (' . $theme_name . ')'; |
|
2859 | + if ($db_show_debug === true) { |
|
2860 | + $context['debug']['language_files'][] = $template_name . '.' . $lang . ' (' . $theme_name . ')'; |
|
2861 | + } |
|
2720 | 2862 | |
2721 | 2863 | // Remember what we have loaded, and in which language. |
2722 | 2864 | $already_loaded[$template_name] = $lang; |
@@ -2762,8 +2904,9 @@ discard block |
||
2762 | 2904 | ) |
2763 | 2905 | ); |
2764 | 2906 | // In the EXTREMELY unlikely event this happens, give an error message. |
2765 | - if ($smcFunc['db_num_rows']($result) == 0) |
|
2766 | - fatal_lang_error('parent_not_found', 'critical'); |
|
2907 | + if ($smcFunc['db_num_rows']($result) == 0) { |
|
2908 | + fatal_lang_error('parent_not_found', 'critical'); |
|
2909 | + } |
|
2767 | 2910 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
2768 | 2911 | { |
2769 | 2912 | if (!isset($boards[$row['id_board']])) |
@@ -2780,8 +2923,8 @@ discard block |
||
2780 | 2923 | ); |
2781 | 2924 | } |
2782 | 2925 | // If a moderator exists for this board, add that moderator for all children too. |
2783 | - if (!empty($row['id_moderator'])) |
|
2784 | - foreach ($boards as $id => $dummy) |
|
2926 | + if (!empty($row['id_moderator'])) { |
|
2927 | + foreach ($boards as $id => $dummy) |
|
2785 | 2928 | { |
2786 | 2929 | $boards[$id]['moderators'][$row['id_moderator']] = array( |
2787 | 2930 | 'id' => $row['id_moderator'], |
@@ -2789,11 +2932,12 @@ discard block |
||
2789 | 2932 | 'href' => $scripturl . '?action=profile;u=' . $row['id_moderator'], |
2790 | 2933 | 'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['id_moderator'] . '">' . $row['real_name'] . '</a>' |
2791 | 2934 | ); |
2935 | + } |
|
2792 | 2936 | } |
2793 | 2937 | |
2794 | 2938 | // If a moderator group exists for this board, add that moderator group for all children too |
2795 | - if (!empty($row['id_moderator_group'])) |
|
2796 | - foreach ($boards as $id => $dummy) |
|
2939 | + if (!empty($row['id_moderator_group'])) { |
|
2940 | + foreach ($boards as $id => $dummy) |
|
2797 | 2941 | { |
2798 | 2942 | $boards[$id]['moderator_groups'][$row['id_moderator_group']] = array( |
2799 | 2943 | 'id' => $row['id_moderator_group'], |
@@ -2801,6 +2945,7 @@ discard block |
||
2801 | 2945 | 'href' => $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'], |
2802 | 2946 | 'link' => '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'] . '">' . $row['group_name'] . '</a>' |
2803 | 2947 | ); |
2948 | + } |
|
2804 | 2949 | } |
2805 | 2950 | } |
2806 | 2951 | $smcFunc['db_free_result']($result); |
@@ -2827,23 +2972,27 @@ discard block |
||
2827 | 2972 | if (!$use_cache || ($context['languages'] = cache_get_data('known_languages', !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] < 1 ? 86400 : 3600)) == null) |
2828 | 2973 | { |
2829 | 2974 | // If we don't have our ucwords function defined yet, let's load the settings data. |
2830 | - if (empty($smcFunc['ucwords'])) |
|
2831 | - reloadSettings(); |
|
2975 | + if (empty($smcFunc['ucwords'])) { |
|
2976 | + reloadSettings(); |
|
2977 | + } |
|
2832 | 2978 | |
2833 | 2979 | // If we don't have our theme information yet, let's get it. |
2834 | - if (empty($settings['default_theme_dir'])) |
|
2835 | - loadTheme(0, false); |
|
2980 | + if (empty($settings['default_theme_dir'])) { |
|
2981 | + loadTheme(0, false); |
|
2982 | + } |
|
2836 | 2983 | |
2837 | 2984 | // Default language directories to try. |
2838 | 2985 | $language_directories = array( |
2839 | 2986 | $settings['default_theme_dir'] . '/languages', |
2840 | 2987 | ); |
2841 | - if (!empty($settings['actual_theme_dir']) && $settings['actual_theme_dir'] != $settings['default_theme_dir']) |
|
2842 | - $language_directories[] = $settings['actual_theme_dir'] . '/languages'; |
|
2988 | + if (!empty($settings['actual_theme_dir']) && $settings['actual_theme_dir'] != $settings['default_theme_dir']) { |
|
2989 | + $language_directories[] = $settings['actual_theme_dir'] . '/languages'; |
|
2990 | + } |
|
2843 | 2991 | |
2844 | 2992 | // We possibly have a base theme directory. |
2845 | - if (!empty($settings['base_theme_dir'])) |
|
2846 | - $language_directories[] = $settings['base_theme_dir'] . '/languages'; |
|
2993 | + if (!empty($settings['base_theme_dir'])) { |
|
2994 | + $language_directories[] = $settings['base_theme_dir'] . '/languages'; |
|
2995 | + } |
|
2847 | 2996 | |
2848 | 2997 | // Remove any duplicates. |
2849 | 2998 | $language_directories = array_unique($language_directories); |
@@ -2857,20 +3006,21 @@ discard block |
||
2857 | 3006 | foreach ($language_directories as $language_dir) |
2858 | 3007 | { |
2859 | 3008 | // Can't look in here... doesn't exist! |
2860 | - if (!file_exists($language_dir)) |
|
2861 | - continue; |
|
3009 | + if (!file_exists($language_dir)) { |
|
3010 | + continue; |
|
3011 | + } |
|
2862 | 3012 | |
2863 | 3013 | $dir = dir($language_dir); |
2864 | 3014 | while ($entry = $dir->read()) |
2865 | 3015 | { |
2866 | 3016 | // Look for the index language file... For good measure skip any "index.language-utf8.php" files |
2867 | - if (!preg_match('~^index\.(.+[^-utf8])\.php$~', $entry, $matches)) |
|
2868 | - continue; |
|
2869 | - |
|
2870 | - if (!empty($langList) && !empty($langList[$matches[1]])) |
|
2871 | - $langName = $langList[$matches[1]]; |
|
3017 | + if (!preg_match('~^index\.(.+[^-utf8])\.php$~', $entry, $matches)) { |
|
3018 | + continue; |
|
3019 | + } |
|
2872 | 3020 | |
2873 | - else |
|
3021 | + if (!empty($langList) && !empty($langList[$matches[1]])) { |
|
3022 | + $langName = $langList[$matches[1]]; |
|
3023 | + } else |
|
2874 | 3024 | { |
2875 | 3025 | $langName = $smcFunc['ucwords'](strtr($matches[1], array('_' => ' '))); |
2876 | 3026 | |
@@ -2911,12 +3061,14 @@ discard block |
||
2911 | 3061 | } |
2912 | 3062 | |
2913 | 3063 | // Do we need to store the lang list? |
2914 | - if (empty($langList)) |
|
2915 | - updateSettings(array('langList' => $smcFunc['json_encode']($catchLang))); |
|
3064 | + if (empty($langList)) { |
|
3065 | + updateSettings(array('langList' => $smcFunc['json_encode']($catchLang))); |
|
3066 | + } |
|
2916 | 3067 | |
2917 | 3068 | // Let's cash in on this deal. |
2918 | - if (!empty($modSettings['cache_enable'])) |
|
2919 | - cache_put_data('known_languages', $context['languages'], !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] < 1 ? 86400 : 3600); |
|
3069 | + if (!empty($modSettings['cache_enable'])) { |
|
3070 | + cache_put_data('known_languages', $context['languages'], !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] < 1 ? 86400 : 3600); |
|
3071 | + } |
|
2920 | 3072 | } |
2921 | 3073 | |
2922 | 3074 | return $context['languages']; |
@@ -2939,8 +3091,9 @@ discard block |
||
2939 | 3091 | global $modSettings, $options, $txt; |
2940 | 3092 | static $censor_vulgar = null, $censor_proper; |
2941 | 3093 | |
2942 | - if ((!empty($options['show_no_censored']) && !empty($modSettings['allow_no_censored']) && !$force) || empty($modSettings['censor_vulgar']) || trim($text) === '') |
|
2943 | - return $text; |
|
3094 | + if ((!empty($options['show_no_censored']) && !empty($modSettings['allow_no_censored']) && !$force) || empty($modSettings['censor_vulgar']) || trim($text) === '') { |
|
3095 | + return $text; |
|
3096 | + } |
|
2944 | 3097 | |
2945 | 3098 | // If they haven't yet been loaded, load them. |
2946 | 3099 | if ($censor_vulgar == null) |
@@ -2968,9 +3121,9 @@ discard block |
||
2968 | 3121 | { |
2969 | 3122 | $func = !empty($modSettings['censorIgnoreCase']) ? 'str_ireplace' : 'str_replace'; |
2970 | 3123 | $text = $func($censor_vulgar, $censor_proper, $text); |
3124 | + } else { |
|
3125 | + $text = preg_replace($censor_vulgar, $censor_proper, $text); |
|
2971 | 3126 | } |
2972 | - else |
|
2973 | - $text = preg_replace($censor_vulgar, $censor_proper, $text); |
|
2974 | 3127 | |
2975 | 3128 | return $text; |
2976 | 3129 | } |
@@ -2996,38 +3149,42 @@ discard block |
||
2996 | 3149 | @ini_set('track_errors', '1'); |
2997 | 3150 | |
2998 | 3151 | // Don't include the file more than once, if $once is true. |
2999 | - if ($once && in_array($filename, $templates)) |
|
3000 | - return; |
|
3152 | + if ($once && in_array($filename, $templates)) { |
|
3153 | + return; |
|
3154 | + } |
|
3001 | 3155 | // Add this file to the include list, whether $once is true or not. |
3002 | - else |
|
3003 | - $templates[] = $filename; |
|
3156 | + else { |
|
3157 | + $templates[] = $filename; |
|
3158 | + } |
|
3004 | 3159 | |
3005 | 3160 | // Are we going to use eval? |
3006 | 3161 | if (empty($modSettings['disableTemplateEval'])) |
3007 | 3162 | { |
3008 | 3163 | $file_found = file_exists($filename) && eval('?' . '>' . rtrim(file_get_contents($filename))) !== false; |
3009 | 3164 | $settings['current_include_filename'] = $filename; |
3010 | - } |
|
3011 | - else |
|
3165 | + } else |
|
3012 | 3166 | { |
3013 | 3167 | $file_found = file_exists($filename); |
3014 | 3168 | |
3015 | - if ($once && $file_found) |
|
3016 | - require_once($filename); |
|
3017 | - elseif ($file_found) |
|
3018 | - require($filename); |
|
3169 | + if ($once && $file_found) { |
|
3170 | + require_once($filename); |
|
3171 | + } elseif ($file_found) { |
|
3172 | + require($filename); |
|
3173 | + } |
|
3019 | 3174 | } |
3020 | 3175 | |
3021 | 3176 | if ($file_found !== true) |
3022 | 3177 | { |
3023 | 3178 | ob_end_clean(); |
3024 | - if (!empty($modSettings['enableCompressedOutput'])) |
|
3025 | - @ob_start('ob_gzhandler'); |
|
3026 | - else |
|
3027 | - ob_start(); |
|
3179 | + if (!empty($modSettings['enableCompressedOutput'])) { |
|
3180 | + @ob_start('ob_gzhandler'); |
|
3181 | + } else { |
|
3182 | + ob_start(); |
|
3183 | + } |
|
3028 | 3184 | |
3029 | - if (isset($_GET['debug'])) |
|
3030 | - header('Content-Type: application/xhtml+xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
3185 | + if (isset($_GET['debug'])) { |
|
3186 | + header('Content-Type: application/xhtml+xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
3187 | + } |
|
3031 | 3188 | |
3032 | 3189 | // Don't cache error pages!! |
3033 | 3190 | header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); |
@@ -3046,12 +3203,13 @@ discard block |
||
3046 | 3203 | echo '<!DOCTYPE html> |
3047 | 3204 | <html', !empty($context['right_to_left']) ? ' dir="rtl"' : '', '> |
3048 | 3205 | <head>'; |
3049 | - if (isset($context['character_set'])) |
|
3050 | - echo ' |
|
3206 | + if (isset($context['character_set'])) { |
|
3207 | + echo ' |
|
3051 | 3208 | <meta charset="', $context['character_set'], '">'; |
3209 | + } |
|
3052 | 3210 | |
3053 | - if (!empty($maintenance) && !allowedTo('admin_forum')) |
|
3054 | - echo ' |
|
3211 | + if (!empty($maintenance) && !allowedTo('admin_forum')) { |
|
3212 | + echo ' |
|
3055 | 3213 | <title>', $mtitle, '</title> |
3056 | 3214 | </head> |
3057 | 3215 | <body> |
@@ -3059,8 +3217,8 @@ discard block |
||
3059 | 3217 | ', $mmessage, ' |
3060 | 3218 | </body> |
3061 | 3219 | </html>'; |
3062 | - elseif (!allowedTo('admin_forum')) |
|
3063 | - echo ' |
|
3220 | + } elseif (!allowedTo('admin_forum')) { |
|
3221 | + echo ' |
|
3064 | 3222 | <title>', $txt['template_parse_error'], '</title> |
3065 | 3223 | </head> |
3066 | 3224 | <body> |
@@ -3068,16 +3226,18 @@ discard block |
||
3068 | 3226 | ', $txt['template_parse_error_message'], ' |
3069 | 3227 | </body> |
3070 | 3228 | </html>'; |
3071 | - else |
|
3229 | + } else |
|
3072 | 3230 | { |
3073 | 3231 | require_once($sourcedir . '/Subs-Package.php'); |
3074 | 3232 | |
3075 | 3233 | $error = fetch_web_data($boardurl . strtr($filename, array($boarddir => '', strtr($boarddir, '\\', '/') => ''))); |
3076 | 3234 | $error_array = error_get_last(); |
3077 | - if (empty($error) && ini_get('track_errors') && !empty($error_array)) |
|
3078 | - $error = $error_array['message']; |
|
3079 | - if (empty($error)) |
|
3080 | - $error = $txt['template_parse_errmsg']; |
|
3235 | + if (empty($error) && ini_get('track_errors') && !empty($error_array)) { |
|
3236 | + $error = $error_array['message']; |
|
3237 | + } |
|
3238 | + if (empty($error)) { |
|
3239 | + $error = $txt['template_parse_errmsg']; |
|
3240 | + } |
|
3081 | 3241 | |
3082 | 3242 | $error = strtr($error, array('<b>' => '<strong>', '</b>' => '</strong>')); |
3083 | 3243 | |
@@ -3088,11 +3248,12 @@ discard block |
||
3088 | 3248 | <h3>', $txt['template_parse_error'], '</h3> |
3089 | 3249 | ', sprintf($txt['template_parse_error_details'], strtr($filename, array($boarddir => '', strtr($boarddir, '\\', '/') => ''))); |
3090 | 3250 | |
3091 | - if (!empty($error)) |
|
3092 | - echo ' |
|
3251 | + if (!empty($error)) { |
|
3252 | + echo ' |
|
3093 | 3253 | <hr> |
3094 | 3254 | |
3095 | 3255 | <div style="margin: 0 20px;"><pre>', strtr(strtr($error, array('<strong>' . $boarddir => '<strong>...', '<strong>' . strtr($boarddir, '\\', '/') => '<strong>...')), '\\', '/'), '</pre></div>'; |
3256 | + } |
|
3096 | 3257 | |
3097 | 3258 | // I know, I know... this is VERY COMPLICATED. Still, it's good. |
3098 | 3259 | if (preg_match('~ <strong>(\d+)</strong><br( /)?' . '>$~i', $error, $match) != 0) |
@@ -3102,10 +3263,11 @@ discard block |
||
3102 | 3263 | $data2 = preg_split('~\<br( /)?\>~', $data2); |
3103 | 3264 | |
3104 | 3265 | // Fix the PHP code stuff... |
3105 | - if (!isBrowser('gecko')) |
|
3106 | - $data2 = str_replace("\t", '<span style="white-space: pre;">' . "\t" . '</span>', $data2); |
|
3107 | - else |
|
3108 | - $data2 = str_replace('<pre style="display: inline;">' . "\t" . '</pre>', "\t", $data2); |
|
3266 | + if (!isBrowser('gecko')) { |
|
3267 | + $data2 = str_replace("\t", '<span style="white-space: pre;">' . "\t" . '</span>', $data2); |
|
3268 | + } else { |
|
3269 | + $data2 = str_replace('<pre style="display: inline;">' . "\t" . '</pre>', "\t", $data2); |
|
3270 | + } |
|
3109 | 3271 | |
3110 | 3272 | // Now we get to work around a bug in PHP where it doesn't escape <br>s! |
3111 | 3273 | $j = -1; |
@@ -3113,8 +3275,9 @@ discard block |
||
3113 | 3275 | { |
3114 | 3276 | $j++; |
3115 | 3277 | |
3116 | - if (substr_count($line, '<br>') == 0) |
|
3117 | - continue; |
|
3278 | + if (substr_count($line, '<br>') == 0) { |
|
3279 | + continue; |
|
3280 | + } |
|
3118 | 3281 | |
3119 | 3282 | $n = substr_count($line, '<br>'); |
3120 | 3283 | for ($i = 0; $i < $n; $i++) |
@@ -3133,38 +3296,42 @@ discard block |
||
3133 | 3296 | // Figure out what the color coding was before... |
3134 | 3297 | $line = max($match[1] - 9, 1); |
3135 | 3298 | $last_line = ''; |
3136 | - for ($line2 = $line - 1; $line2 > 1; $line2--) |
|
3137 | - if (strpos($data2[$line2], '<') !== false) |
|
3299 | + for ($line2 = $line - 1; $line2 > 1; $line2--) { |
|
3300 | + if (strpos($data2[$line2], '<') !== false) |
|
3138 | 3301 | { |
3139 | 3302 | if (preg_match('~(<[^/>]+>)[^<]*$~', $data2[$line2], $color_match) != 0) |
3140 | 3303 | $last_line = $color_match[1]; |
3304 | + } |
|
3141 | 3305 | break; |
3142 | 3306 | } |
3143 | 3307 | |
3144 | 3308 | // Show the relevant lines... |
3145 | 3309 | for ($n = min($match[1] + 4, count($data2) + 1); $line <= $n; $line++) |
3146 | 3310 | { |
3147 | - if ($line == $match[1]) |
|
3148 | - echo '</pre><div style="background-color: #ffb0b5;"><pre style="margin: 0;">'; |
|
3311 | + if ($line == $match[1]) { |
|
3312 | + echo '</pre><div style="background-color: #ffb0b5;"><pre style="margin: 0;">'; |
|
3313 | + } |
|
3149 | 3314 | |
3150 | 3315 | echo '<span style="color: black;">', sprintf('%' . strlen($n) . 's', $line), ':</span> '; |
3151 | - if (isset($data2[$line]) && $data2[$line] != '') |
|
3152 | - echo substr($data2[$line], 0, 2) == '</' ? preg_replace('~^</[^>]+>~', '', $data2[$line]) : $last_line . $data2[$line]; |
|
3316 | + if (isset($data2[$line]) && $data2[$line] != '') { |
|
3317 | + echo substr($data2[$line], 0, 2) == '</' ? preg_replace('~^</[^>]+>~', '', $data2[$line]) : $last_line . $data2[$line]; |
|
3318 | + } |
|
3153 | 3319 | |
3154 | 3320 | if (isset($data2[$line]) && preg_match('~(<[^/>]+>)[^<]*$~', $data2[$line], $color_match) != 0) |
3155 | 3321 | { |
3156 | 3322 | $last_line = $color_match[1]; |
3157 | 3323 | echo '</', substr($last_line, 1, 4), '>'; |
3324 | + } elseif ($last_line != '' && strpos($data2[$line], '<') !== false) { |
|
3325 | + $last_line = ''; |
|
3326 | + } elseif ($last_line != '' && $data2[$line] != '') { |
|
3327 | + echo '</', substr($last_line, 1, 4), '>'; |
|
3158 | 3328 | } |
3159 | - elseif ($last_line != '' && strpos($data2[$line], '<') !== false) |
|
3160 | - $last_line = ''; |
|
3161 | - elseif ($last_line != '' && $data2[$line] != '') |
|
3162 | - echo '</', substr($last_line, 1, 4), '>'; |
|
3163 | 3329 | |
3164 | - if ($line == $match[1]) |
|
3165 | - echo '</pre></div><pre style="margin: 0;">'; |
|
3166 | - else |
|
3167 | - echo "\n"; |
|
3330 | + if ($line == $match[1]) { |
|
3331 | + echo '</pre></div><pre style="margin: 0;">'; |
|
3332 | + } else { |
|
3333 | + echo "\n"; |
|
3334 | + } |
|
3168 | 3335 | } |
3169 | 3336 | |
3170 | 3337 | echo '</pre></div>'; |
@@ -3188,8 +3355,9 @@ discard block |
||
3188 | 3355 | global $db_type, $db_name, $ssi_db_user, $ssi_db_passwd, $sourcedir, $db_prefix, $db_port; |
3189 | 3356 | |
3190 | 3357 | // Figure out what type of database we are using. |
3191 | - if (empty($db_type) || !file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php')) |
|
3192 | - $db_type = 'mysql'; |
|
3358 | + if (empty($db_type) || !file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php')) { |
|
3359 | + $db_type = 'mysql'; |
|
3360 | + } |
|
3193 | 3361 | |
3194 | 3362 | // Load the file for the database. |
3195 | 3363 | require_once($sourcedir . '/Subs-Db-' . $db_type . '.php'); |
@@ -3197,8 +3365,9 @@ discard block |
||
3197 | 3365 | $db_options = array(); |
3198 | 3366 | |
3199 | 3367 | // Add in the port if needed |
3200 | - if (!empty($db_port)) |
|
3201 | - $db_options['port'] = $db_port; |
|
3368 | + if (!empty($db_port)) { |
|
3369 | + $db_options['port'] = $db_port; |
|
3370 | + } |
|
3202 | 3371 | |
3203 | 3372 | // If we are in SSI try them first, but don't worry if it doesn't work, we have the normal username and password we can use. |
3204 | 3373 | if (SMF == 'SSI' && !empty($ssi_db_user) && !empty($ssi_db_passwd)) |
@@ -3217,13 +3386,15 @@ discard block |
||
3217 | 3386 | } |
3218 | 3387 | |
3219 | 3388 | // Safe guard here, if there isn't a valid connection lets put a stop to it. |
3220 | - if (!$db_connection) |
|
3221 | - display_db_error(); |
|
3389 | + if (!$db_connection) { |
|
3390 | + display_db_error(); |
|
3391 | + } |
|
3222 | 3392 | |
3223 | 3393 | // If in SSI mode fix up the prefix. |
3224 | - if (SMF == 'SSI') |
|
3225 | - db_fix_prefix($db_prefix, $db_name); |
|
3226 | -} |
|
3394 | + if (SMF == 'SSI') { |
|
3395 | + db_fix_prefix($db_prefix, $db_name); |
|
3396 | + } |
|
3397 | + } |
|
3227 | 3398 | |
3228 | 3399 | /** |
3229 | 3400 | * Try to load up a supported caching method. This is saved in $cacheAPI if we are not overriding it. |
@@ -3237,10 +3408,11 @@ discard block |
||
3237 | 3408 | global $sourcedir, $cacheAPI, $cache_accelerator; |
3238 | 3409 | |
3239 | 3410 | // Not overriding this and we have a cacheAPI, send it back. |
3240 | - if (empty($overrideCache) && is_object($cacheAPI)) |
|
3241 | - return $cacheAPI; |
|
3242 | - elseif (is_null($cacheAPI)) |
|
3243 | - $cacheAPI = false; |
|
3411 | + if (empty($overrideCache) && is_object($cacheAPI)) { |
|
3412 | + return $cacheAPI; |
|
3413 | + } elseif (is_null($cacheAPI)) { |
|
3414 | + $cacheAPI = false; |
|
3415 | + } |
|
3244 | 3416 | |
3245 | 3417 | // Make sure our class is in session. |
3246 | 3418 | require_once($sourcedir . '/Class-CacheAPI.php'); |
@@ -3261,8 +3433,9 @@ discard block |
||
3261 | 3433 | if (!$testAPI->isSupported()) |
3262 | 3434 | { |
3263 | 3435 | // Can we save ourselves? |
3264 | - if (!empty($fallbackSMF) && is_null($overrideCache) && $tryAccelerator != 'smf') |
|
3265 | - return loadCacheAccelerator(null, false); |
|
3436 | + if (!empty($fallbackSMF) && is_null($overrideCache) && $tryAccelerator != 'smf') { |
|
3437 | + return loadCacheAccelerator(null, false); |
|
3438 | + } |
|
3266 | 3439 | return false; |
3267 | 3440 | } |
3268 | 3441 | |
@@ -3274,9 +3447,9 @@ discard block |
||
3274 | 3447 | { |
3275 | 3448 | $cacheAPI = $testAPI; |
3276 | 3449 | return $cacheAPI; |
3450 | + } else { |
|
3451 | + return $testAPI; |
|
3277 | 3452 | } |
3278 | - else |
|
3279 | - return $testAPI; |
|
3280 | 3453 | } |
3281 | 3454 | } |
3282 | 3455 | |
@@ -3296,8 +3469,9 @@ discard block |
||
3296 | 3469 | |
3297 | 3470 | // @todo Why are we doing this if caching is disabled? |
3298 | 3471 | |
3299 | - if (function_exists('call_integration_hook')) |
|
3300 | - call_integration_hook('pre_cache_quick_get', array(&$key, &$file, &$function, &$params, &$level)); |
|
3472 | + if (function_exists('call_integration_hook')) { |
|
3473 | + call_integration_hook('pre_cache_quick_get', array(&$key, &$file, &$function, &$params, &$level)); |
|
3474 | + } |
|
3301 | 3475 | |
3302 | 3476 | /* Refresh the cache if either: |
3303 | 3477 | 1. Caching is disabled. |
@@ -3311,16 +3485,19 @@ discard block |
||
3311 | 3485 | require_once($sourcedir . '/' . $file); |
3312 | 3486 | $cache_block = call_user_func_array($function, $params); |
3313 | 3487 | |
3314 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= $level) |
|
3315 | - cache_put_data($key, $cache_block, $cache_block['expires'] - time()); |
|
3488 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= $level) { |
|
3489 | + cache_put_data($key, $cache_block, $cache_block['expires'] - time()); |
|
3490 | + } |
|
3316 | 3491 | } |
3317 | 3492 | |
3318 | 3493 | // Some cached data may need a freshening up after retrieval. |
3319 | - if (!empty($cache_block['post_retri_eval'])) |
|
3320 | - eval($cache_block['post_retri_eval']); |
|
3494 | + if (!empty($cache_block['post_retri_eval'])) { |
|
3495 | + eval($cache_block['post_retri_eval']); |
|
3496 | + } |
|
3321 | 3497 | |
3322 | - if (function_exists('call_integration_hook')) |
|
3323 | - call_integration_hook('post_cache_quick_get', array(&$cache_block)); |
|
3498 | + if (function_exists('call_integration_hook')) { |
|
3499 | + call_integration_hook('post_cache_quick_get', array(&$cache_block)); |
|
3500 | + } |
|
3324 | 3501 | |
3325 | 3502 | return $cache_block['data']; |
3326 | 3503 | } |
@@ -3347,8 +3524,9 @@ discard block |
||
3347 | 3524 | global $smcFunc, $cache_enable, $cacheAPI; |
3348 | 3525 | global $cache_hits, $cache_count, $db_show_debug; |
3349 | 3526 | |
3350 | - if (empty($cache_enable) || empty($cacheAPI)) |
|
3351 | - return; |
|
3527 | + if (empty($cache_enable) || empty($cacheAPI)) { |
|
3528 | + return; |
|
3529 | + } |
|
3352 | 3530 | |
3353 | 3531 | $cache_count = isset($cache_count) ? $cache_count + 1 : 1; |
3354 | 3532 | if (isset($db_show_debug) && $db_show_debug === true) |
@@ -3361,12 +3539,14 @@ discard block |
||
3361 | 3539 | $value = $value === null ? null : (isset($smcFunc['json_encode']) ? $smcFunc['json_encode']($value) : json_encode($value)); |
3362 | 3540 | $cacheAPI->putData($key, $value, $ttl); |
3363 | 3541 | |
3364 | - if (function_exists('call_integration_hook')) |
|
3365 | - call_integration_hook('cache_put_data', array(&$key, &$value, &$ttl)); |
|
3542 | + if (function_exists('call_integration_hook')) { |
|
3543 | + call_integration_hook('cache_put_data', array(&$key, &$value, &$ttl)); |
|
3544 | + } |
|
3366 | 3545 | |
3367 | - if (isset($db_show_debug) && $db_show_debug === true) |
|
3368 | - $cache_hits[$cache_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st)); |
|
3369 | -} |
|
3546 | + if (isset($db_show_debug) && $db_show_debug === true) { |
|
3547 | + $cache_hits[$cache_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st)); |
|
3548 | + } |
|
3549 | + } |
|
3370 | 3550 | |
3371 | 3551 | /** |
3372 | 3552 | * Gets the value from the cache specified by key, so long as it is not older than ttl seconds. |
@@ -3382,8 +3562,9 @@ discard block |
||
3382 | 3562 | global $smcFunc, $cache_enable, $cacheAPI; |
3383 | 3563 | global $cache_hits, $cache_count, $cache_misses, $cache_count_misses, $db_show_debug; |
3384 | 3564 | |
3385 | - if (empty($cache_enable) || empty($cacheAPI)) |
|
3386 | - return; |
|
3565 | + if (empty($cache_enable) || empty($cacheAPI)) { |
|
3566 | + return; |
|
3567 | + } |
|
3387 | 3568 | |
3388 | 3569 | $cache_count = isset($cache_count) ? $cache_count + 1 : 1; |
3389 | 3570 | if (isset($db_show_debug) && $db_show_debug === true) |
@@ -3403,16 +3584,18 @@ discard block |
||
3403 | 3584 | |
3404 | 3585 | if (empty($value)) |
3405 | 3586 | { |
3406 | - if (!is_array($cache_misses)) |
|
3407 | - $cache_misses = array(); |
|
3587 | + if (!is_array($cache_misses)) { |
|
3588 | + $cache_misses = array(); |
|
3589 | + } |
|
3408 | 3590 | |
3409 | 3591 | $cache_count_misses = isset($cache_count_misses) ? $cache_count_misses + 1 : 1; |
3410 | 3592 | $cache_misses[$cache_count_misses] = array('k' => $original_key, 'd' => 'get'); |
3411 | 3593 | } |
3412 | 3594 | } |
3413 | 3595 | |
3414 | - if (function_exists('call_integration_hook') && isset($value)) |
|
3415 | - call_integration_hook('cache_get_data', array(&$key, &$ttl, &$value)); |
|
3596 | + if (function_exists('call_integration_hook') && isset($value)) { |
|
3597 | + call_integration_hook('cache_get_data', array(&$key, &$ttl, &$value)); |
|
3598 | + } |
|
3416 | 3599 | |
3417 | 3600 | return empty($value) ? null : (isset($smcFunc['json_encode']) ? $smcFunc['json_decode']($value, true) : smf_json_decode($value, true)); |
3418 | 3601 | } |
@@ -3434,8 +3617,9 @@ discard block |
||
3434 | 3617 | global $cacheAPI; |
3435 | 3618 | |
3436 | 3619 | // If we can't get to the API, can't do this. |
3437 | - if (empty($cacheAPI)) |
|
3438 | - return; |
|
3620 | + if (empty($cacheAPI)) { |
|
3621 | + return; |
|
3622 | + } |
|
3439 | 3623 | |
3440 | 3624 | // Ask the API to do the heavy lifting. cleanCache also calls invalidateCache to be sure. |
3441 | 3625 | $cacheAPI->cleanCache($type); |
@@ -3460,8 +3644,9 @@ discard block |
||
3460 | 3644 | global $modSettings, $boardurl, $smcFunc, $image_proxy_enabled, $image_proxy_secret; |
3461 | 3645 | |
3462 | 3646 | // Come on! |
3463 | - if (empty($data)) |
|
3464 | - return array(); |
|
3647 | + if (empty($data)) { |
|
3648 | + return array(); |
|
3649 | + } |
|
3465 | 3650 | |
3466 | 3651 | // Set a nice default var. |
3467 | 3652 | $image = ''; |
@@ -3469,11 +3654,11 @@ discard block |
||
3469 | 3654 | // Gravatar has been set as mandatory! |
3470 | 3655 | if (!empty($modSettings['gravatarOverride'])) |
3471 | 3656 | { |
3472 | - if (!empty($modSettings['gravatarAllowExtraEmail']) && !empty($data['avatar']) && stristr($data['avatar'], 'gravatar://')) |
|
3473 | - $image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11)); |
|
3474 | - |
|
3475 | - else if (!empty($data['email'])) |
|
3476 | - $image = get_gravatar_url($data['email']); |
|
3657 | + if (!empty($modSettings['gravatarAllowExtraEmail']) && !empty($data['avatar']) && stristr($data['avatar'], 'gravatar://')) { |
|
3658 | + $image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11)); |
|
3659 | + } else if (!empty($data['email'])) { |
|
3660 | + $image = get_gravatar_url($data['email']); |
|
3661 | + } |
|
3477 | 3662 | } |
3478 | 3663 | |
3479 | 3664 | // Look if the user has a gravatar field or has set an external url as avatar. |
@@ -3485,54 +3670,60 @@ discard block |
||
3485 | 3670 | // Gravatar. |
3486 | 3671 | if (stristr($data['avatar'], 'gravatar://')) |
3487 | 3672 | { |
3488 | - if ($data['avatar'] == 'gravatar://') |
|
3489 | - $image = get_gravatar_url($data['email']); |
|
3490 | - |
|
3491 | - elseif (!empty($modSettings['gravatarAllowExtraEmail'])) |
|
3492 | - $image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11)); |
|
3673 | + if ($data['avatar'] == 'gravatar://') { |
|
3674 | + $image = get_gravatar_url($data['email']); |
|
3675 | + } elseif (!empty($modSettings['gravatarAllowExtraEmail'])) { |
|
3676 | + $image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11)); |
|
3677 | + } |
|
3493 | 3678 | } |
3494 | 3679 | |
3495 | 3680 | // External url. |
3496 | 3681 | else |
3497 | 3682 | { |
3498 | 3683 | // Using ssl? |
3499 | - if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($data['avatar'], 'http://') !== false) |
|
3500 | - $image = strtr($boardurl, array('http://' => 'https://')) . '/proxy.php?request=' . urlencode($data['avatar']) . '&hash=' . md5($data['avatar'] . $image_proxy_secret); |
|
3684 | + if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($data['avatar'], 'http://') !== false) { |
|
3685 | + $image = strtr($boardurl, array('http://' => 'https://')) . '/proxy.php?request=' . urlencode($data['avatar']) . '&hash=' . md5($data['avatar'] . $image_proxy_secret); |
|
3686 | + } |
|
3501 | 3687 | |
3502 | 3688 | // Just a plain external url. |
3503 | - else |
|
3504 | - $image = (stristr($data['avatar'], 'http://') || stristr($data['avatar'], 'https://')) ? $data['avatar'] : $modSettings['avatar_url'] . '/' . $data['avatar']; |
|
3689 | + else { |
|
3690 | + $image = (stristr($data['avatar'], 'http://') || stristr($data['avatar'], 'https://')) ? $data['avatar'] : $modSettings['avatar_url'] . '/' . $data['avatar']; |
|
3691 | + } |
|
3505 | 3692 | } |
3506 | 3693 | } |
3507 | 3694 | |
3508 | 3695 | // Perhaps this user has an attachment as avatar... |
3509 | - else if (!empty($data['filename'])) |
|
3510 | - $image = $modSettings['custom_avatar_url'] . '/' . $data['filename']; |
|
3696 | + else if (!empty($data['filename'])) { |
|
3697 | + $image = $modSettings['custom_avatar_url'] . '/' . $data['filename']; |
|
3698 | + } |
|
3511 | 3699 | |
3512 | 3700 | // Right... no avatar... use our default image. |
3513 | - else |
|
3514 | - $image = $modSettings['avatar_url'] . '/default.png'; |
|
3701 | + else { |
|
3702 | + $image = $modSettings['avatar_url'] . '/default.png'; |
|
3703 | + } |
|
3515 | 3704 | } |
3516 | 3705 | |
3517 | 3706 | call_integration_hook('integrate_set_avatar_data', array(&$image, &$data)); |
3518 | 3707 | |
3519 | 3708 | // At this point in time $image has to be filled unless you chose to force gravatar and the user doesn't have the needed data to retrieve it... thus a check for !empty() is still needed. |
3520 | - if (!empty($image)) |
|
3521 | - return array( |
|
3709 | + if (!empty($image)) { |
|
3710 | + return array( |
|
3522 | 3711 | 'name' => !empty($data['avatar']) ? $data['avatar'] : '', |
3523 | 3712 | 'image' => '<img class="avatar" src="' . $image . '" />', |
3524 | 3713 | 'href' => $image, |
3525 | 3714 | 'url' => $image, |
3526 | 3715 | ); |
3716 | + } |
|
3527 | 3717 | |
3528 | 3718 | // Fallback to make life easier for everyone... |
3529 | - else |
|
3530 | - return array( |
|
3719 | + else { |
|
3720 | + return array( |
|
3531 | 3721 | 'name' => '', |
3532 | 3722 | 'image' => '', |
3533 | 3723 | 'href' => '', |
3534 | 3724 | 'url' => '', |
3535 | 3725 | ); |
3536 | -} |
|
3726 | + } |
|
3727 | + } |
|
3537 | 3728 | |
3538 | 3729 | ?> |
3539 | 3730 | \ No newline at end of file |
@@ -15,8 +15,9 @@ discard block |
||
15 | 15 | * @version 2.1 Beta 4 |
16 | 16 | */ |
17 | 17 | |
18 | -if (!defined('SMF')) |
|
18 | +if (!defined('SMF')) { |
|
19 | 19 | die('No direct access...'); |
20 | +} |
|
20 | 21 | |
21 | 22 | /** |
22 | 23 | * Log an error, if the error logging is enabled. |
@@ -41,17 +42,19 @@ discard block |
||
41 | 42 | // are we in a loop? |
42 | 43 | if($error_call > 2) |
43 | 44 | { |
44 | - if (!isset($db_show_debug) || $db_show_debug === false) |
|
45 | - $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); |
|
46 | - else |
|
47 | - $backtrace = debug_backtrace(); |
|
45 | + if (!isset($db_show_debug) || $db_show_debug === false) { |
|
46 | + $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); |
|
47 | + } else { |
|
48 | + $backtrace = debug_backtrace(); |
|
49 | + } |
|
48 | 50 | var_dump($backtrace); |
49 | 51 | die('Error loop.'); |
50 | 52 | } |
51 | 53 | |
52 | 54 | // Check if error logging is actually on. |
53 | - if (empty($modSettings['enableErrorLogging'])) |
|
54 | - return $error_message; |
|
55 | + if (empty($modSettings['enableErrorLogging'])) { |
|
56 | + return $error_message; |
|
57 | + } |
|
55 | 58 | |
56 | 59 | // Basically, htmlspecialchars it minus &. (for entities!) |
57 | 60 | $error_message = strtr($error_message, array('<' => '<', '>' => '>', '"' => '"')); |
@@ -59,33 +62,39 @@ discard block |
||
59 | 62 | |
60 | 63 | // Add a file and line to the error message? |
61 | 64 | // Don't use the actual txt entries for file and line but instead use %1$s for file and %2$s for line |
62 | - if ($file == null) |
|
63 | - $file = ''; |
|
64 | - else |
|
65 | - // Window style slashes don't play well, lets convert them to the unix style. |
|
65 | + if ($file == null) { |
|
66 | + $file = ''; |
|
67 | + } else { |
|
68 | + // Window style slashes don't play well, lets convert them to the unix style. |
|
66 | 69 | $file = str_replace('\\', '/', $file); |
70 | + } |
|
67 | 71 | |
68 | - if ($line == null) |
|
69 | - $line = 0; |
|
70 | - else |
|
71 | - $line = (int) $line; |
|
72 | + if ($line == null) { |
|
73 | + $line = 0; |
|
74 | + } else { |
|
75 | + $line = (int) $line; |
|
76 | + } |
|
72 | 77 | |
73 | 78 | // Just in case there's no id_member or IP set yet. |
74 | - if (empty($user_info['id'])) |
|
75 | - $user_info['id'] = 0; |
|
76 | - if (empty($user_info['ip'])) |
|
77 | - $user_info['ip'] = ''; |
|
79 | + if (empty($user_info['id'])) { |
|
80 | + $user_info['id'] = 0; |
|
81 | + } |
|
82 | + if (empty($user_info['ip'])) { |
|
83 | + $user_info['ip'] = ''; |
|
84 | + } |
|
78 | 85 | |
79 | 86 | // Find the best query string we can... |
80 | 87 | $query_string = empty($_SERVER['QUERY_STRING']) ? (empty($_SERVER['REQUEST_URL']) ? '' : str_replace($scripturl, '', $_SERVER['REQUEST_URL'])) : $_SERVER['QUERY_STRING']; |
81 | 88 | |
82 | 89 | // Don't log the session hash in the url twice, it's a waste. |
83 | - if (!empty($smcFunc['htmlspecialchars'])) |
|
84 | - $query_string = $smcFunc['htmlspecialchars']((SMF == 'SSI' || SMF == 'BACKGROUND' ? '' : '?') . preg_replace(array('~;sesc=[^&;]+~', '~' . session_name() . '=' . session_id() . '[&;]~'), array(';sesc', ''), $query_string)); |
|
90 | + if (!empty($smcFunc['htmlspecialchars'])) { |
|
91 | + $query_string = $smcFunc['htmlspecialchars']((SMF == 'SSI' || SMF == 'BACKGROUND' ? '' : '?') . preg_replace(array('~;sesc=[^&;]+~', '~' . session_name() . '=' . session_id() . '[&;]~'), array(';sesc', ''), $query_string)); |
|
92 | + } |
|
85 | 93 | |
86 | 94 | // Just so we know what board error messages are from. |
87 | - if (isset($_POST['board']) && !isset($_GET['board'])) |
|
88 | - $query_string .= ($query_string == '' ? 'board=' : ';board=') . $_POST['board']; |
|
95 | + if (isset($_POST['board']) && !isset($_GET['board'])) { |
|
96 | + $query_string .= ($query_string == '' ? 'board=' : ';board=') . $_POST['board']; |
|
97 | + } |
|
89 | 98 | |
90 | 99 | // What types of categories do we have? |
91 | 100 | $known_error_types = array( |
@@ -146,12 +155,14 @@ discard block |
||
146 | 155 | global $txt; |
147 | 156 | |
148 | 157 | // Send the appropriate HTTP status header - set this to 0 or false if you don't want to send one at all |
149 | - if (!empty($status)) |
|
150 | - send_http_status($status); |
|
158 | + if (!empty($status)) { |
|
159 | + send_http_status($status); |
|
160 | + } |
|
151 | 161 | |
152 | 162 | // We don't have $txt yet, but that's okay... |
153 | - if (empty($txt)) |
|
154 | - die($error); |
|
163 | + if (empty($txt)) { |
|
164 | + die($error); |
|
165 | + } |
|
155 | 166 | |
156 | 167 | log_error_online($error, false); |
157 | 168 | setup_fatal_error_context($log ? log_error($error, $log) : $error); |
@@ -178,8 +189,9 @@ discard block |
||
178 | 189 | static $fatal_error_called = false; |
179 | 190 | |
180 | 191 | // Send the status header - set this to 0 or false if you don't want to send one at all |
181 | - if (!empty($status)) |
|
182 | - send_http_status($status); |
|
192 | + if (!empty($status)) { |
|
193 | + send_http_status($status); |
|
194 | + } |
|
183 | 195 | |
184 | 196 | // Try to load a theme if we don't have one. |
185 | 197 | if (empty($context['theme_loaded']) && empty($fatal_error_called)) |
@@ -189,8 +201,9 @@ discard block |
||
189 | 201 | } |
190 | 202 | |
191 | 203 | // If we have no theme stuff we can't have the language file... |
192 | - if (empty($context['theme_loaded'])) |
|
193 | - die($error); |
|
204 | + if (empty($context['theme_loaded'])) { |
|
205 | + die($error); |
|
206 | + } |
|
194 | 207 | |
195 | 208 | $reload_lang_file = true; |
196 | 209 | // Log the error in the forum's language, but don't waste the time if we aren't logging |
@@ -226,8 +239,9 @@ discard block |
||
226 | 239 | global $settings, $modSettings, $db_show_debug; |
227 | 240 | |
228 | 241 | // Ignore errors if we're ignoring them or they are strict notices from PHP 5 |
229 | - if (error_reporting() == 0) |
|
230 | - return; |
|
242 | + if (error_reporting() == 0) { |
|
243 | + return; |
|
244 | + } |
|
231 | 245 | |
232 | 246 | if (strpos($file, 'eval()') !== false && !empty($settings['current_include_filename'])) |
233 | 247 | { |
@@ -235,19 +249,22 @@ discard block |
||
235 | 249 | $count = count($array); |
236 | 250 | for ($i = 0; $i < $count; $i++) |
237 | 251 | { |
238 | - if ($array[$i]['function'] != 'loadSubTemplate') |
|
239 | - continue; |
|
252 | + if ($array[$i]['function'] != 'loadSubTemplate') { |
|
253 | + continue; |
|
254 | + } |
|
240 | 255 | |
241 | 256 | // This is a bug in PHP, with eval, it seems! |
242 | - if (empty($array[$i]['args'])) |
|
243 | - $i++; |
|
257 | + if (empty($array[$i]['args'])) { |
|
258 | + $i++; |
|
259 | + } |
|
244 | 260 | break; |
245 | 261 | } |
246 | 262 | |
247 | - if (isset($array[$i]) && !empty($array[$i]['args'])) |
|
248 | - $file = realpath($settings['current_include_filename']) . ' (' . $array[$i]['args'][0] . ' sub template - eval?)'; |
|
249 | - else |
|
250 | - $file = realpath($settings['current_include_filename']) . ' (eval?)'; |
|
263 | + if (isset($array[$i]) && !empty($array[$i]['args'])) { |
|
264 | + $file = realpath($settings['current_include_filename']) . ' (' . $array[$i]['args'][0] . ' sub template - eval?)'; |
|
265 | + } else { |
|
266 | + $file = realpath($settings['current_include_filename']) . ' (eval?)'; |
|
267 | + } |
|
251 | 268 | } |
252 | 269 | |
253 | 270 | if (isset($db_show_debug) && $db_show_debug === true) |
@@ -256,8 +273,9 @@ discard block |
||
256 | 273 | if ($error_level % 255 != E_ERROR) |
257 | 274 | { |
258 | 275 | $temporary = ob_get_contents(); |
259 | - if (substr($temporary, -2) == '="') |
|
260 | - echo '"'; |
|
276 | + if (substr($temporary, -2) == '="') { |
|
277 | + echo '"'; |
|
278 | + } |
|
261 | 279 | } |
262 | 280 | |
263 | 281 | // Debugging! This should look like a PHP error message. |
@@ -273,23 +291,27 @@ discard block |
||
273 | 291 | call_integration_hook('integrate_output_error', array($message, $error_type, $error_level, $file, $line)); |
274 | 292 | |
275 | 293 | // Dying on these errors only causes MORE problems (blank pages!) |
276 | - if ($file == 'Unknown') |
|
277 | - return; |
|
294 | + if ($file == 'Unknown') { |
|
295 | + return; |
|
296 | + } |
|
278 | 297 | |
279 | 298 | // If this is an E_ERROR or E_USER_ERROR.... die. Violently so. |
280 | - if ($error_level % 255 == E_ERROR) |
|
281 | - obExit(false); |
|
282 | - else |
|
283 | - return; |
|
299 | + if ($error_level % 255 == E_ERROR) { |
|
300 | + obExit(false); |
|
301 | + } else { |
|
302 | + return; |
|
303 | + } |
|
284 | 304 | |
285 | 305 | // If this is an E_ERROR, E_USER_ERROR, E_WARNING, or E_USER_WARNING.... die. Violently so. |
286 | - if ($error_level % 255 == E_ERROR || $error_level % 255 == E_WARNING) |
|
287 | - fatal_error(allowedTo('admin_forum') ? $message : $error_string, false); |
|
306 | + if ($error_level % 255 == E_ERROR || $error_level % 255 == E_WARNING) { |
|
307 | + fatal_error(allowedTo('admin_forum') ? $message : $error_string, false); |
|
308 | + } |
|
288 | 309 | |
289 | 310 | // We should NEVER get to this point. Any fatal error MUST quit, or very bad things can happen. |
290 | - if ($error_level % 255 == E_ERROR) |
|
291 | - die('No direct access...'); |
|
292 | -} |
|
311 | + if ($error_level % 255 == E_ERROR) { |
|
312 | + die('No direct access...'); |
|
313 | + } |
|
314 | + } |
|
293 | 315 | |
294 | 316 | /** |
295 | 317 | * It is called by {@link fatal_error()} and {@link fatal_lang_error()}. |
@@ -305,24 +327,28 @@ discard block |
||
305 | 327 | |
306 | 328 | // Attempt to prevent a recursive loop. |
307 | 329 | ++$level; |
308 | - if ($level > 1) |
|
309 | - return false; |
|
330 | + if ($level > 1) { |
|
331 | + return false; |
|
332 | + } |
|
310 | 333 | |
311 | 334 | // Maybe they came from dlattach or similar? |
312 | - if (SMF != 'SSI' && SMF != 'BACKGROUND' && empty($context['theme_loaded'])) |
|
313 | - loadTheme(); |
|
335 | + if (SMF != 'SSI' && SMF != 'BACKGROUND' && empty($context['theme_loaded'])) { |
|
336 | + loadTheme(); |
|
337 | + } |
|
314 | 338 | |
315 | 339 | // Don't bother indexing errors mate... |
316 | 340 | $context['robot_no_index'] = true; |
317 | 341 | |
318 | - if (!isset($context['error_title'])) |
|
319 | - $context['error_title'] = $txt['error_occured']; |
|
342 | + if (!isset($context['error_title'])) { |
|
343 | + $context['error_title'] = $txt['error_occured']; |
|
344 | + } |
|
320 | 345 | $context['error_message'] = isset($context['error_message']) ? $context['error_message'] : $error_message; |
321 | 346 | |
322 | 347 | $context['error_code'] = isset($error_code) ? 'id="' . $error_code . '" ' : ''; |
323 | 348 | |
324 | - if (empty($context['page_title'])) |
|
325 | - $context['page_title'] = $context['error_title']; |
|
349 | + if (empty($context['page_title'])) { |
|
350 | + $context['page_title'] = $context['error_title']; |
|
351 | + } |
|
326 | 352 | |
327 | 353 | loadTemplate('Errors'); |
328 | 354 | $context['sub_template'] = 'fatal_error'; |
@@ -330,23 +356,26 @@ discard block |
||
330 | 356 | // If this is SSI, what do they want us to do? |
331 | 357 | if (SMF == 'SSI') |
332 | 358 | { |
333 | - if (!empty($ssi_on_error_method) && $ssi_on_error_method !== true && is_callable($ssi_on_error_method)) |
|
334 | - $ssi_on_error_method(); |
|
335 | - elseif (empty($ssi_on_error_method) || $ssi_on_error_method !== true) |
|
336 | - loadSubTemplate('fatal_error'); |
|
359 | + if (!empty($ssi_on_error_method) && $ssi_on_error_method !== true && is_callable($ssi_on_error_method)) { |
|
360 | + $ssi_on_error_method(); |
|
361 | + } elseif (empty($ssi_on_error_method) || $ssi_on_error_method !== true) { |
|
362 | + loadSubTemplate('fatal_error'); |
|
363 | + } |
|
337 | 364 | |
338 | 365 | // No layers? |
339 | - if (empty($ssi_on_error_method) || $ssi_on_error_method !== true) |
|
340 | - exit; |
|
366 | + if (empty($ssi_on_error_method) || $ssi_on_error_method !== true) { |
|
367 | + exit; |
|
368 | + } |
|
341 | 369 | } |
342 | 370 | // Alternatively from the cron call? |
343 | 371 | elseif (SMF == 'BACKGROUND') |
344 | 372 | { |
345 | 373 | // We can't rely on even having language files available. |
346 | - if (defined('FROM_CLI') && FROM_CLI) |
|
347 | - echo 'cron error: ', $context['error_message']; |
|
348 | - else |
|
349 | - echo 'An error occurred. More information may be available in your logs.'; |
|
374 | + if (defined('FROM_CLI') && FROM_CLI) { |
|
375 | + echo 'cron error: ', $context['error_message']; |
|
376 | + } else { |
|
377 | + echo 'An error occurred. More information may be available in your logs.'; |
|
378 | + } |
|
350 | 379 | exit; |
351 | 380 | } |
352 | 381 | |
@@ -374,8 +403,8 @@ discard block |
||
374 | 403 | |
375 | 404 | set_fatal_error_headers(); |
376 | 405 | |
377 | - if (!empty($maintenance)) |
|
378 | - echo '<!DOCTYPE html> |
|
406 | + if (!empty($maintenance)) { |
|
407 | + echo '<!DOCTYPE html> |
|
379 | 408 | <html> |
380 | 409 | <head> |
381 | 410 | <meta name="robots" content="noindex"> |
@@ -386,6 +415,7 @@ discard block |
||
386 | 415 | ', $mmessage, ' |
387 | 416 | </body> |
388 | 417 | </html>'; |
418 | + } |
|
389 | 419 | |
390 | 420 | die(); |
391 | 421 | } |
@@ -407,15 +437,17 @@ discard block |
||
407 | 437 | // For our purposes, we're gonna want this on if at all possible. |
408 | 438 | $modSettings['cache_enable'] = '1'; |
409 | 439 | |
410 | - if (($temp = cache_get_data('db_last_error', 600)) !== null) |
|
411 | - $db_last_error = max($db_last_error, $temp); |
|
440 | + if (($temp = cache_get_data('db_last_error', 600)) !== null) { |
|
441 | + $db_last_error = max($db_last_error, $temp); |
|
442 | + } |
|
412 | 443 | |
413 | 444 | if ($db_last_error < time() - 3600 * 24 * 3 && empty($maintenance) && !empty($db_error_send)) |
414 | 445 | { |
415 | 446 | // Avoid writing to the Settings.php file if at all possible; use shared memory instead. |
416 | 447 | cache_put_data('db_last_error', time(), 600); |
417 | - if (($temp = cache_get_data('db_last_error', 600)) === null) |
|
418 | - logLastDatabaseError(); |
|
448 | + if (($temp = cache_get_data('db_last_error', 600)) === null) { |
|
449 | + logLastDatabaseError(); |
|
450 | + } |
|
419 | 451 | |
420 | 452 | // Language files aren't loaded yet :(. |
421 | 453 | $db_error = @$smcFunc['db_error']($db_connection); |
@@ -496,12 +528,14 @@ discard block |
||
496 | 528 | global $smcFunc, $user_info, $modSettings; |
497 | 529 | |
498 | 530 | // Don't bother if Who's Online is disabled. |
499 | - if (empty($modSettings['who_enabled'])) |
|
500 | - return; |
|
531 | + if (empty($modSettings['who_enabled'])) { |
|
532 | + return; |
|
533 | + } |
|
501 | 534 | |
502 | 535 | // Maybe they came from SSI or similar where sessions are not recorded? |
503 | - if (SMF == 'SSI' || SMF == 'BACKGROUND') |
|
504 | - return; |
|
536 | + if (SMF == 'SSI' || SMF == 'BACKGROUND') { |
|
537 | + return; |
|
538 | + } |
|
505 | 539 | |
506 | 540 | $session_id = !empty($user_info['is_guest']) ? 'ip' . $user_info['ip'] : session_id(); |
507 | 541 | |
@@ -527,8 +561,9 @@ discard block |
||
527 | 561 | $url = $smcFunc['json_decode']($url, true); |
528 | 562 | $url['error'] = $error; |
529 | 563 | |
530 | - if (!empty($sprintf)) |
|
531 | - $url['error_params'] = $sprintf; |
|
564 | + if (!empty($sprintf)) { |
|
565 | + $url['error_params'] = $sprintf; |
|
566 | + } |
|
532 | 567 | |
533 | 568 | $smcFunc['db_query']('', ' |
534 | 569 | UPDATE {db_prefix}log_online |
@@ -559,10 +594,11 @@ discard block |
||
559 | 594 | |
560 | 595 | $protocol = preg_match('~HTTP/1\.[01]~i', $_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0'; |
561 | 596 | |
562 | - if (!isset($statuses[$code])) |
|
563 | - header($protocol . ' 500 Internal Server Error'); |
|
564 | - else |
|
565 | - header($protocol . ' ' . $code . ' ' . $statuses[$code]); |
|
566 | -} |
|
597 | + if (!isset($statuses[$code])) { |
|
598 | + header($protocol . ' 500 Internal Server Error'); |
|
599 | + } else { |
|
600 | + header($protocol . ' ' . $code . ' ' . $statuses[$code]); |
|
601 | + } |
|
602 | + } |
|
567 | 603 | |
568 | 604 | ?> |
569 | 605 | \ No newline at end of file |
@@ -14,8 +14,9 @@ discard block |
||
14 | 14 | * @version 2.1 Beta 4 |
15 | 15 | */ |
16 | 16 | |
17 | -if (!defined('SMF')) |
|
17 | +if (!defined('SMF')) { |
|
18 | 18 | die('No direct access...'); |
19 | +} |
|
19 | 20 | |
20 | 21 | /** |
21 | 22 | * Handles showing the post screen, loading the post to be modified, and loading any post quoted. |
@@ -35,12 +36,14 @@ discard block |
||
35 | 36 | global $sourcedir, $smcFunc, $language; |
36 | 37 | |
37 | 38 | loadLanguage('Post'); |
38 | - if (!empty($modSettings['drafts_post_enabled'])) |
|
39 | - loadLanguage('Drafts'); |
|
39 | + if (!empty($modSettings['drafts_post_enabled'])) { |
|
40 | + loadLanguage('Drafts'); |
|
41 | + } |
|
40 | 42 | |
41 | 43 | // You can't reply with a poll... hacker. |
42 | - if (isset($_REQUEST['poll']) && !empty($topic) && !isset($_REQUEST['msg'])) |
|
43 | - unset($_REQUEST['poll']); |
|
44 | + if (isset($_REQUEST['poll']) && !empty($topic) && !isset($_REQUEST['msg'])) { |
|
45 | + unset($_REQUEST['poll']); |
|
46 | + } |
|
44 | 47 | |
45 | 48 | // Posting an event? |
46 | 49 | $context['make_event'] = isset($_REQUEST['calendar']); |
@@ -54,8 +57,9 @@ discard block |
||
54 | 57 | $context['auto_notify'] = !empty($context['notify_prefs']['msg_auto_notify']); |
55 | 58 | |
56 | 59 | // You must be posting to *some* board. |
57 | - if (empty($board) && !$context['make_event']) |
|
58 | - fatal_lang_error('no_board', false); |
|
60 | + if (empty($board) && !$context['make_event']) { |
|
61 | + fatal_lang_error('no_board', false); |
|
62 | + } |
|
59 | 63 | |
60 | 64 | require_once($sourcedir . '/Subs-Post.php'); |
61 | 65 | |
@@ -78,10 +82,11 @@ discard block |
||
78 | 82 | array( |
79 | 83 | 'msg' => (int) $_REQUEST['msg'], |
80 | 84 | )); |
81 | - if ($smcFunc['db_num_rows']($request) != 1) |
|
82 | - unset($_REQUEST['msg'], $_POST['msg'], $_GET['msg']); |
|
83 | - else |
|
84 | - list ($topic) = $smcFunc['db_fetch_row']($request); |
|
85 | + if ($smcFunc['db_num_rows']($request) != 1) { |
|
86 | + unset($_REQUEST['msg'], $_POST['msg'], $_GET['msg']); |
|
87 | + } else { |
|
88 | + list ($topic) = $smcFunc['db_fetch_row']($request); |
|
89 | + } |
|
85 | 90 | $smcFunc['db_free_result']($request); |
86 | 91 | } |
87 | 92 | |
@@ -108,33 +113,36 @@ discard block |
||
108 | 113 | $smcFunc['db_free_result']($request); |
109 | 114 | |
110 | 115 | // If this topic already has a poll, they sure can't add another. |
111 | - if (isset($_REQUEST['poll']) && $pollID > 0) |
|
112 | - unset($_REQUEST['poll']); |
|
116 | + if (isset($_REQUEST['poll']) && $pollID > 0) { |
|
117 | + unset($_REQUEST['poll']); |
|
118 | + } |
|
113 | 119 | |
114 | 120 | if (empty($_REQUEST['msg'])) |
115 | 121 | { |
116 | - if ($user_info['is_guest'] && !allowedTo('post_reply_any') && (!$modSettings['postmod_active'] || !allowedTo('post_unapproved_replies_any'))) |
|
117 | - is_not_guest(); |
|
122 | + if ($user_info['is_guest'] && !allowedTo('post_reply_any') && (!$modSettings['postmod_active'] || !allowedTo('post_unapproved_replies_any'))) { |
|
123 | + is_not_guest(); |
|
124 | + } |
|
118 | 125 | |
119 | 126 | // By default the reply will be approved... |
120 | 127 | $context['becomes_approved'] = true; |
121 | 128 | if ($id_member_poster != $user_info['id'] || $user_info['is_guest']) |
122 | 129 | { |
123 | - if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_any') && !allowedTo('post_reply_any')) |
|
124 | - $context['becomes_approved'] = false; |
|
125 | - else |
|
126 | - isAllowedTo('post_reply_any'); |
|
127 | - } |
|
128 | - elseif (!allowedTo('post_reply_any')) |
|
130 | + if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_any') && !allowedTo('post_reply_any')) { |
|
131 | + $context['becomes_approved'] = false; |
|
132 | + } else { |
|
133 | + isAllowedTo('post_reply_any'); |
|
134 | + } |
|
135 | + } elseif (!allowedTo('post_reply_any')) |
|
129 | 136 | { |
130 | - if ($modSettings['postmod_active'] && ((allowedTo('post_unapproved_replies_own') && !allowedTo('post_reply_own')) || allowedTo('post_unapproved_replies_any'))) |
|
131 | - $context['becomes_approved'] = false; |
|
132 | - else |
|
133 | - isAllowedTo('post_reply_own'); |
|
137 | + if ($modSettings['postmod_active'] && ((allowedTo('post_unapproved_replies_own') && !allowedTo('post_reply_own')) || allowedTo('post_unapproved_replies_any'))) { |
|
138 | + $context['becomes_approved'] = false; |
|
139 | + } else { |
|
140 | + isAllowedTo('post_reply_own'); |
|
141 | + } |
|
134 | 142 | } |
143 | + } else { |
|
144 | + $context['becomes_approved'] = true; |
|
135 | 145 | } |
136 | - else |
|
137 | - $context['becomes_approved'] = true; |
|
138 | 146 | |
139 | 147 | $context['can_lock'] = allowedTo('lock_any') || ($user_info['id'] == $id_member_poster && allowedTo('lock_own')); |
140 | 148 | $context['can_sticky'] = allowedTo('make_sticky'); |
@@ -146,18 +154,19 @@ discard block |
||
146 | 154 | $context['sticky'] = isset($_REQUEST['sticky']) ? !empty($_REQUEST['sticky']) : $sticky; |
147 | 155 | |
148 | 156 | // Check whether this is a really old post being bumped... |
149 | - if (!empty($modSettings['oldTopicDays']) && $lastPostTime + $modSettings['oldTopicDays'] * 86400 < time() && empty($sticky) && !isset($_REQUEST['subject'])) |
|
150 | - $post_errors[] = array('old_topic', array($modSettings['oldTopicDays'])); |
|
151 | - } |
|
152 | - else |
|
157 | + if (!empty($modSettings['oldTopicDays']) && $lastPostTime + $modSettings['oldTopicDays'] * 86400 < time() && empty($sticky) && !isset($_REQUEST['subject'])) { |
|
158 | + $post_errors[] = array('old_topic', array($modSettings['oldTopicDays'])); |
|
159 | + } |
|
160 | + } else |
|
153 | 161 | { |
154 | 162 | $context['becomes_approved'] = true; |
155 | 163 | if ((!$context['make_event'] || !empty($board))) |
156 | 164 | { |
157 | - if ($modSettings['postmod_active'] && !allowedTo('post_new') && allowedTo('post_unapproved_topics')) |
|
158 | - $context['becomes_approved'] = false; |
|
159 | - else |
|
160 | - isAllowedTo('post_new'); |
|
165 | + if ($modSettings['postmod_active'] && !allowedTo('post_new') && allowedTo('post_unapproved_topics')) { |
|
166 | + $context['becomes_approved'] = false; |
|
167 | + } else { |
|
168 | + isAllowedTo('post_new'); |
|
169 | + } |
|
161 | 170 | } |
162 | 171 | |
163 | 172 | $locked = 0; |
@@ -193,20 +202,24 @@ discard block |
||
193 | 202 | } |
194 | 203 | |
195 | 204 | // Don't allow a post if it's locked and you aren't all powerful. |
196 | - if ($locked && !allowedTo('moderate_board')) |
|
197 | - fatal_lang_error('topic_locked', false); |
|
205 | + if ($locked && !allowedTo('moderate_board')) { |
|
206 | + fatal_lang_error('topic_locked', false); |
|
207 | + } |
|
198 | 208 | // Check the users permissions - is the user allowed to add or post a poll? |
199 | 209 | if (isset($_REQUEST['poll']) && $modSettings['pollMode'] == '1') |
200 | 210 | { |
201 | 211 | // New topic, new poll. |
202 | - if (empty($topic)) |
|
203 | - isAllowedTo('poll_post'); |
|
212 | + if (empty($topic)) { |
|
213 | + isAllowedTo('poll_post'); |
|
214 | + } |
|
204 | 215 | // This is an old topic - but it is yours! Can you add to it? |
205 | - elseif ($user_info['id'] == $id_member_poster && !allowedTo('poll_add_any')) |
|
206 | - isAllowedTo('poll_add_own'); |
|
216 | + elseif ($user_info['id'] == $id_member_poster && !allowedTo('poll_add_any')) { |
|
217 | + isAllowedTo('poll_add_own'); |
|
218 | + } |
|
207 | 219 | // If you're not the owner, can you add to any poll? |
208 | - else |
|
209 | - isAllowedTo('poll_add_any'); |
|
220 | + else { |
|
221 | + isAllowedTo('poll_add_any'); |
|
222 | + } |
|
210 | 223 | |
211 | 224 | require_once($sourcedir . '/Subs-Members.php'); |
212 | 225 | $allowedVoteGroups = groupsAllowedTo('poll_vote', $board); |
@@ -235,8 +248,9 @@ discard block |
||
235 | 248 | if ($context['make_event']) |
236 | 249 | { |
237 | 250 | // They might want to pick a board. |
238 | - if (!isset($context['current_board'])) |
|
239 | - $context['current_board'] = 0; |
|
251 | + if (!isset($context['current_board'])) { |
|
252 | + $context['current_board'] = 0; |
|
253 | + } |
|
240 | 254 | |
241 | 255 | // Start loading up the event info. |
242 | 256 | $context['event'] = array(); |
@@ -250,10 +264,11 @@ discard block |
||
250 | 264 | isAllowedTo('calendar_post'); |
251 | 265 | |
252 | 266 | // We want a fairly compact version of the time, but as close as possible to the user's settings. |
253 | - if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) |
|
254 | - $time_string = '%k:%M'; |
|
255 | - else |
|
256 | - $time_string = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]); |
|
267 | + if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) { |
|
268 | + $time_string = '%k:%M'; |
|
269 | + } else { |
|
270 | + $time_string = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]); |
|
271 | + } |
|
257 | 272 | |
258 | 273 | $js_time_string = str_replace( |
259 | 274 | array('%H', '%k', '%I', '%l', '%M', '%p', '%P', '%r', '%R', '%S', '%T', '%X'), |
@@ -275,8 +290,7 @@ discard block |
||
275 | 290 | require_once($sourcedir . '/Subs-Calendar.php'); |
276 | 291 | $eventProperties = getEventProperties($context['event']['id']); |
277 | 292 | $context['event'] = array_merge($context['event'], $eventProperties); |
278 | - } |
|
279 | - else |
|
293 | + } else |
|
280 | 294 | { |
281 | 295 | // Get the current event information. |
282 | 296 | require_once($sourcedir . '/Subs-Calendar.php'); |
@@ -284,15 +298,18 @@ discard block |
||
284 | 298 | $context['event'] = array_merge($context['event'], $eventProperties); |
285 | 299 | |
286 | 300 | // Make sure the year and month are in the valid range. |
287 | - if ($context['event']['month'] < 1 || $context['event']['month'] > 12) |
|
288 | - fatal_lang_error('invalid_month', false); |
|
289 | - if ($context['event']['year'] < $modSettings['cal_minyear'] || $context['event']['year'] > $modSettings['cal_maxyear']) |
|
290 | - fatal_lang_error('invalid_year', false); |
|
301 | + if ($context['event']['month'] < 1 || $context['event']['month'] > 12) { |
|
302 | + fatal_lang_error('invalid_month', false); |
|
303 | + } |
|
304 | + if ($context['event']['year'] < $modSettings['cal_minyear'] || $context['event']['year'] > $modSettings['cal_maxyear']) { |
|
305 | + fatal_lang_error('invalid_year', false); |
|
306 | + } |
|
291 | 307 | |
292 | 308 | // Get a list of boards they can post in. |
293 | 309 | $boards = boardsAllowedTo('post_new'); |
294 | - if (empty($boards)) |
|
295 | - fatal_lang_error('cannot_post_new', 'user'); |
|
310 | + if (empty($boards)) { |
|
311 | + fatal_lang_error('cannot_post_new', 'user'); |
|
312 | + } |
|
296 | 313 | |
297 | 314 | // Load a list of boards for this event in the context. |
298 | 315 | require_once($sourcedir . '/Subs-MessageIndex.php'); |
@@ -411,10 +428,11 @@ discard block |
||
411 | 428 | |
412 | 429 | if (!empty($context['new_replies'])) |
413 | 430 | { |
414 | - if ($context['new_replies'] == 1) |
|
415 | - $txt['error_new_replies'] = isset($_GET['last_msg']) ? $txt['error_new_reply_reading'] : $txt['error_new_reply']; |
|
416 | - else |
|
417 | - $txt['error_new_replies'] = sprintf(isset($_GET['last_msg']) ? $txt['error_new_replies_reading'] : $txt['error_new_replies'], $context['new_replies']); |
|
431 | + if ($context['new_replies'] == 1) { |
|
432 | + $txt['error_new_replies'] = isset($_GET['last_msg']) ? $txt['error_new_reply_reading'] : $txt['error_new_reply']; |
|
433 | + } else { |
|
434 | + $txt['error_new_replies'] = sprintf(isset($_GET['last_msg']) ? $txt['error_new_replies_reading'] : $txt['error_new_replies'], $context['new_replies']); |
|
435 | + } |
|
418 | 436 | |
419 | 437 | $post_errors[] = 'new_replies'; |
420 | 438 | |
@@ -426,9 +444,9 @@ discard block |
||
426 | 444 | // Get a response prefix (like 'Re:') in the default forum language. |
427 | 445 | if (!isset($context['response_prefix']) && !($context['response_prefix'] = cache_get_data('response_prefix'))) |
428 | 446 | { |
429 | - if ($language === $user_info['language']) |
|
430 | - $context['response_prefix'] = $txt['response_prefix']; |
|
431 | - else |
|
447 | + if ($language === $user_info['language']) { |
|
448 | + $context['response_prefix'] = $txt['response_prefix']; |
|
449 | + } else |
|
432 | 450 | { |
433 | 451 | loadLanguage('index', $language, false); |
434 | 452 | $context['response_prefix'] = $txt['response_prefix']; |
@@ -441,8 +459,9 @@ discard block |
||
441 | 459 | // Do we have a body, but an error happened. |
442 | 460 | if (isset($_REQUEST['message']) || isset($_REQUEST['quickReply']) || !empty($context['post_error'])) |
443 | 461 | { |
444 | - if (isset($_REQUEST['quickReply'])) |
|
445 | - $_REQUEST['message'] = $_REQUEST['quickReply']; |
|
462 | + if (isset($_REQUEST['quickReply'])) { |
|
463 | + $_REQUEST['message'] = $_REQUEST['quickReply']; |
|
464 | + } |
|
446 | 465 | |
447 | 466 | // Validate inputs. |
448 | 467 | if (empty($context['post_error'])) |
@@ -450,15 +469,17 @@ discard block |
||
450 | 469 | // This means they didn't click Post and get an error. |
451 | 470 | $really_previewing = true; |
452 | 471 | |
453 | - } |
|
454 | - else |
|
472 | + } else |
|
455 | 473 | { |
456 | - if (!isset($_REQUEST['subject'])) |
|
457 | - $_REQUEST['subject'] = ''; |
|
458 | - if (!isset($_REQUEST['message'])) |
|
459 | - $_REQUEST['message'] = ''; |
|
460 | - if (!isset($_REQUEST['icon'])) |
|
461 | - $_REQUEST['icon'] = 'xx'; |
|
474 | + if (!isset($_REQUEST['subject'])) { |
|
475 | + $_REQUEST['subject'] = ''; |
|
476 | + } |
|
477 | + if (!isset($_REQUEST['message'])) { |
|
478 | + $_REQUEST['message'] = ''; |
|
479 | + } |
|
480 | + if (!isset($_REQUEST['icon'])) { |
|
481 | + $_REQUEST['icon'] = 'xx'; |
|
482 | + } |
|
462 | 483 | |
463 | 484 | // They are previewing if they asked to preview (i.e. came from quick reply). |
464 | 485 | $really_previewing = !empty($_POST['preview']); |
@@ -474,8 +495,9 @@ discard block |
||
474 | 495 | $form_message = $smcFunc['htmlspecialchars']($_REQUEST['message'], ENT_QUOTES); |
475 | 496 | |
476 | 497 | // Make sure the subject isn't too long - taking into account special characters. |
477 | - if ($smcFunc['strlen']($form_subject) > 100) |
|
478 | - $form_subject = $smcFunc['substr']($form_subject, 0, 100); |
|
498 | + if ($smcFunc['strlen']($form_subject) > 100) { |
|
499 | + $form_subject = $smcFunc['substr']($form_subject, 0, 100); |
|
500 | + } |
|
479 | 501 | |
480 | 502 | if (isset($_REQUEST['poll'])) |
481 | 503 | { |
@@ -487,8 +509,9 @@ discard block |
||
487 | 509 | $_POST['options'] = empty($_POST['options']) ? array() : htmlspecialchars__recursive($_POST['options']); |
488 | 510 | foreach ($_POST['options'] as $option) |
489 | 511 | { |
490 | - if (trim($option) == '') |
|
491 | - continue; |
|
512 | + if (trim($option) == '') { |
|
513 | + continue; |
|
514 | + } |
|
492 | 515 | |
493 | 516 | $context['choices'][] = array( |
494 | 517 | 'id' => $choice_id++, |
@@ -550,13 +573,14 @@ discard block |
||
550 | 573 | $context['preview_subject'] = $form_subject; |
551 | 574 | |
552 | 575 | censorText($context['preview_subject']); |
576 | + } else { |
|
577 | + $context['preview_subject'] = '<em>' . $txt['no_subject'] . '</em>'; |
|
553 | 578 | } |
554 | - else |
|
555 | - $context['preview_subject'] = '<em>' . $txt['no_subject'] . '</em>'; |
|
556 | 579 | |
557 | 580 | // Protect any CDATA blocks. |
558 | - if (isset($_REQUEST['xml'])) |
|
559 | - $context['preview_message'] = strtr($context['preview_message'], array(']]>' => ']]]]><![CDATA[>')); |
|
581 | + if (isset($_REQUEST['xml'])) { |
|
582 | + $context['preview_message'] = strtr($context['preview_message'], array(']]>' => ']]]]>< == 0) |
|
599 | - fatal_lang_error('no_board', false); |
|
622 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
623 | + fatal_lang_error('no_board', false); |
|
624 | + } |
|
600 | 625 | $row = $smcFunc['db_fetch_assoc']($request); |
601 | 626 | |
602 | 627 | $attachment_stuff = array($row); |
603 | - while ($row2 = $smcFunc['db_fetch_assoc']($request)) |
|
604 | - $attachment_stuff[] = $row2; |
|
628 | + while ($row2 = $smcFunc['db_fetch_assoc']($request)) { |
|
629 | + $attachment_stuff[] = $row2; |
|
630 | + } |
|
605 | 631 | $smcFunc['db_free_result']($request); |
606 | 632 | |
607 | 633 | if ($row['id_member'] == $user_info['id'] && !allowedTo('modify_any')) |
608 | 634 | { |
609 | 635 | // Give an extra five minutes over the disable time threshold, so they can type - assuming the post is public. |
610 | - if ($row['approved'] && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) |
|
611 | - fatal_lang_error('modify_post_time_passed', false); |
|
612 | - elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_own')) |
|
613 | - isAllowedTo('modify_replies'); |
|
614 | - else |
|
615 | - isAllowedTo('modify_own'); |
|
636 | + if ($row['approved'] && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) { |
|
637 | + fatal_lang_error('modify_post_time_passed', false); |
|
638 | + } elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_own')) { |
|
639 | + isAllowedTo('modify_replies'); |
|
640 | + } else { |
|
641 | + isAllowedTo('modify_own'); |
|
642 | + } |
|
643 | + } elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_any')) { |
|
644 | + isAllowedTo('modify_replies'); |
|
645 | + } else { |
|
646 | + isAllowedTo('modify_any'); |
|
616 | 647 | } |
617 | - elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_any')) |
|
618 | - isAllowedTo('modify_replies'); |
|
619 | - else |
|
620 | - isAllowedTo('modify_any'); |
|
621 | 648 | |
622 | 649 | if ($context['can_announce'] && !empty($row['id_action'])) |
623 | 650 | { |
@@ -641,8 +668,9 @@ discard block |
||
641 | 668 | |
642 | 669 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
643 | 670 | { |
644 | - if ($row['filesize'] <= 0) |
|
645 | - continue; |
|
671 | + if ($row['filesize'] <= 0) { |
|
672 | + continue; |
|
673 | + } |
|
646 | 674 | $context['current_attachments'][$row['id_attach']] = array( |
647 | 675 | 'name' => $smcFunc['htmlspecialchars']($row['filename']), |
648 | 676 | 'size' => $row['filesize'], |
@@ -712,29 +740,32 @@ discard block |
||
712 | 740 | ) |
713 | 741 | ); |
714 | 742 | // The message they were trying to edit was most likely deleted. |
715 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
716 | - fatal_lang_error('no_message', false); |
|
743 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
744 | + fatal_lang_error('no_message', false); |
|
745 | + } |
|
717 | 746 | $row = $smcFunc['db_fetch_assoc']($request); |
718 | 747 | |
719 | 748 | $attachment_stuff = array($row); |
720 | - while ($row2 = $smcFunc['db_fetch_assoc']($request)) |
|
721 | - $attachment_stuff[] = $row2; |
|
749 | + while ($row2 = $smcFunc['db_fetch_assoc']($request)) { |
|
750 | + $attachment_stuff[] = $row2; |
|
751 | + } |
|
722 | 752 | $smcFunc['db_free_result']($request); |
723 | 753 | |
724 | 754 | if ($row['id_member'] == $user_info['id'] && !allowedTo('modify_any')) |
725 | 755 | { |
726 | 756 | // Give an extra five minutes over the disable time threshold, so they can type - assuming the post is public. |
727 | - if ($row['approved'] && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) |
|
728 | - fatal_lang_error('modify_post_time_passed', false); |
|
729 | - elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_own')) |
|
730 | - isAllowedTo('modify_replies'); |
|
731 | - else |
|
732 | - isAllowedTo('modify_own'); |
|
757 | + if ($row['approved'] && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) { |
|
758 | + fatal_lang_error('modify_post_time_passed', false); |
|
759 | + } elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_own')) { |
|
760 | + isAllowedTo('modify_replies'); |
|
761 | + } else { |
|
762 | + isAllowedTo('modify_own'); |
|
763 | + } |
|
764 | + } elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_any')) { |
|
765 | + isAllowedTo('modify_replies'); |
|
766 | + } else { |
|
767 | + isAllowedTo('modify_any'); |
|
733 | 768 | } |
734 | - elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_any')) |
|
735 | - isAllowedTo('modify_replies'); |
|
736 | - else |
|
737 | - isAllowedTo('modify_any'); |
|
738 | 769 | |
739 | 770 | if ($context['can_announce'] && !empty($row['id_action'])) |
740 | 771 | { |
@@ -761,15 +792,17 @@ discard block |
||
761 | 792 | $context['icon'] = $row['icon']; |
762 | 793 | |
763 | 794 | // Show an "approve" box if the user can approve it, and the message isn't approved. |
764 | - if (!$row['approved'] && !$context['show_approval']) |
|
765 | - $context['show_approval'] = allowedTo('approve_posts'); |
|
795 | + if (!$row['approved'] && !$context['show_approval']) { |
|
796 | + $context['show_approval'] = allowedTo('approve_posts'); |
|
797 | + } |
|
766 | 798 | |
767 | 799 | // Sort the attachments so they are in the order saved |
768 | 800 | $temp = array(); |
769 | 801 | foreach ($attachment_stuff as $attachment) |
770 | 802 | { |
771 | - if ($attachment['filesize'] >= 0 && !empty($modSettings['attachmentEnable'])) |
|
772 | - $temp[$attachment['id_attach']] = $attachment; |
|
803 | + if ($attachment['filesize'] >= 0 && !empty($modSettings['attachmentEnable'])) { |
|
804 | + $temp[$attachment['id_attach']] = $attachment; |
|
805 | + } |
|
773 | 806 | |
774 | 807 | } |
775 | 808 | ksort($temp); |
@@ -831,14 +864,16 @@ discard block |
||
831 | 864 | 'is_approved' => 1, |
832 | 865 | ) |
833 | 866 | ); |
834 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
835 | - fatal_lang_error('quoted_post_deleted', false); |
|
867 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
868 | + fatal_lang_error('quoted_post_deleted', false); |
|
869 | + } |
|
836 | 870 | list ($form_subject, $mname, $mdate, $form_message) = $smcFunc['db_fetch_row']($request); |
837 | 871 | $smcFunc['db_free_result']($request); |
838 | 872 | |
839 | 873 | // Add 'Re: ' to the front of the quoted subject. |
840 | - if (trim($context['response_prefix']) != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0) |
|
841 | - $form_subject = $context['response_prefix'] . $form_subject; |
|
874 | + if (trim($context['response_prefix']) != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0) { |
|
875 | + $form_subject = $context['response_prefix'] . $form_subject; |
|
876 | + } |
|
842 | 877 | |
843 | 878 | // Censor the message and subject. |
844 | 879 | censorText($form_message); |
@@ -851,10 +886,11 @@ discard block |
||
851 | 886 | for ($i = 0, $n = count($parts); $i < $n; $i++) |
852 | 887 | { |
853 | 888 | // It goes 0 = outside, 1 = begin tag, 2 = inside, 3 = close tag, repeat. |
854 | - if ($i % 4 == 0) |
|
855 | - $parts[$i] = preg_replace_callback('~\[html\](.+?)\[/html\]~is', function($m) |
|
889 | + if ($i % 4 == 0) { |
|
890 | + $parts[$i] = preg_replace_callback('~\[html\](.+?)\[/html\]~is', function($m) |
|
856 | 891 | { |
857 | 892 | return '[html]' . preg_replace('~<br\s?/?' . '>~i', '<br /><br>', "$m[1]") . '[/html]'; |
893 | + } |
|
858 | 894 | }, $parts[$i]); |
859 | 895 | } |
860 | 896 | $form_message = implode('', $parts); |
@@ -863,8 +899,9 @@ discard block |
||
863 | 899 | $form_message = preg_replace('~<br ?/?' . '>~i', "\n", $form_message); |
864 | 900 | |
865 | 901 | // Remove any nested quotes, if necessary. |
866 | - if (!empty($modSettings['removeNestedQuotes'])) |
|
867 | - $form_message = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $form_message); |
|
902 | + if (!empty($modSettings['removeNestedQuotes'])) { |
|
903 | + $form_message = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $form_message); |
|
904 | + } |
|
868 | 905 | |
869 | 906 | // Add a quote string on the front and end. |
870 | 907 | $form_message = '[quote author=' . $mname . ' link=msg=' . (int) $_REQUEST['quote'] . ' date=' . $mdate . ']' . "\n" . rtrim($form_message) . "\n" . '[/quote]'; |
@@ -876,15 +913,15 @@ discard block |
||
876 | 913 | $form_subject = $first_subject; |
877 | 914 | |
878 | 915 | // Add 'Re: ' to the front of the subject. |
879 | - if (trim($context['response_prefix']) != '' && $form_subject != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0) |
|
880 | - $form_subject = $context['response_prefix'] . $form_subject; |
|
916 | + if (trim($context['response_prefix']) != '' && $form_subject != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0) { |
|
917 | + $form_subject = $context['response_prefix'] . $form_subject; |
|
918 | + } |
|
881 | 919 | |
882 | 920 | // Censor the subject. |
883 | 921 | censorText($form_subject); |
884 | 922 | |
885 | 923 | $form_message = ''; |
886 | - } |
|
887 | - else |
|
924 | + } else |
|
888 | 925 | { |
889 | 926 | $form_subject = isset($_GET['subject']) ? $_GET['subject'] : ''; |
890 | 927 | $form_message = ''; |
@@ -902,13 +939,15 @@ discard block |
||
902 | 939 | if (isset($_REQUEST['msg'])) |
903 | 940 | { |
904 | 941 | $context['attachments']['quantity'] = count($context['current_attachments']); |
905 | - foreach ($context['current_attachments'] as $attachment) |
|
906 | - $context['attachments']['total_size'] += $attachment['size']; |
|
942 | + foreach ($context['current_attachments'] as $attachment) { |
|
943 | + $context['attachments']['total_size'] += $attachment['size']; |
|
944 | + } |
|
907 | 945 | } |
908 | 946 | |
909 | 947 | // A bit of house keeping first. |
910 | - if (!empty($_SESSION['temp_attachments']) && count($_SESSION['temp_attachments']) == 1) |
|
911 | - unset($_SESSION['temp_attachments']); |
|
948 | + if (!empty($_SESSION['temp_attachments']) && count($_SESSION['temp_attachments']) == 1) { |
|
949 | + unset($_SESSION['temp_attachments']); |
|
950 | + } |
|
912 | 951 | |
913 | 952 | if (!empty($_SESSION['temp_attachments'])) |
914 | 953 | { |
@@ -917,9 +956,10 @@ discard block |
||
917 | 956 | { |
918 | 957 | foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
919 | 958 | { |
920 | - if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false) |
|
921 | - if (file_exists($attachment['tmp_name'])) |
|
959 | + if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false) { |
|
960 | + if (file_exists($attachment['tmp_name'])) |
|
922 | 961 | unlink($attachment['tmp_name']); |
962 | + } |
|
923 | 963 | } |
924 | 964 | $post_errors[] = 'temp_attachments_gone'; |
925 | 965 | $_SESSION['temp_attachments'] = array(); |
@@ -933,8 +973,9 @@ discard block |
||
933 | 973 | // See if any files still exist before showing the warning message and the files attached. |
934 | 974 | foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
935 | 975 | { |
936 | - if (strpos($attachID, 'post_tmp_' . $user_info['id']) === false) |
|
937 | - continue; |
|
976 | + if (strpos($attachID, 'post_tmp_' . $user_info['id']) === false) { |
|
977 | + continue; |
|
978 | + } |
|
938 | 979 | |
939 | 980 | if (file_exists($attachment['tmp_name'])) |
940 | 981 | { |
@@ -944,20 +985,21 @@ discard block |
||
944 | 985 | break; |
945 | 986 | } |
946 | 987 | } |
947 | - } |
|
948 | - else |
|
988 | + } else |
|
949 | 989 | { |
950 | 990 | // Since, they don't belong here. Let's inform the user that they exist.. |
951 | - if (!empty($topic)) |
|
952 | - $delete_url = $scripturl . '?action=post' . (!empty($_REQUEST['msg']) ? (';msg=' . $_REQUEST['msg']) : '') . (!empty($_REQUEST['last_msg']) ? (';last_msg=' . $_REQUEST['last_msg']) : '') . ';topic=' . $topic . ';delete_temp'; |
|
953 | - else |
|
954 | - $delete_url = $scripturl . '?action=post;board=' . $board . ';delete_temp'; |
|
991 | + if (!empty($topic)) { |
|
992 | + $delete_url = $scripturl . '?action=post' . (!empty($_REQUEST['msg']) ? (';msg=' . $_REQUEST['msg']) : '') . (!empty($_REQUEST['last_msg']) ? (';last_msg=' . $_REQUEST['last_msg']) : '') . ';topic=' . $topic . ';delete_temp'; |
|
993 | + } else { |
|
994 | + $delete_url = $scripturl . '?action=post;board=' . $board . ';delete_temp'; |
|
995 | + } |
|
955 | 996 | |
956 | 997 | // Compile a list of the files to show the user. |
957 | 998 | $file_list = array(); |
958 | - foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
|
959 | - if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false) |
|
999 | + foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) { |
|
1000 | + if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false) |
|
960 | 1001 | $file_list[] = $attachment['name']; |
1002 | + } |
|
961 | 1003 | |
962 | 1004 | $_SESSION['temp_attachments']['post']['files'] = $file_list; |
963 | 1005 | $file_list = '<div class="attachments">' . implode('<br>', $file_list) . '</div>'; |
@@ -969,8 +1011,7 @@ discard block |
||
969 | 1011 | |
970 | 1012 | $post_errors[] = array('temp_attachments_found', array($delete_url, $goback_url, $file_list)); |
971 | 1013 | $context['ignore_temp_attachments'] = true; |
972 | - } |
|
973 | - else |
|
1014 | + } else |
|
974 | 1015 | { |
975 | 1016 | $post_errors[] = array('temp_attachments_lost', array($delete_url, $file_list)); |
976 | 1017 | $context['ignore_temp_attachments'] = true; |
@@ -978,16 +1019,19 @@ discard block |
||
978 | 1019 | } |
979 | 1020 | } |
980 | 1021 | |
981 | - if (!empty($context['we_are_history'])) |
|
982 | - $post_errors[] = $context['we_are_history']; |
|
1022 | + if (!empty($context['we_are_history'])) { |
|
1023 | + $post_errors[] = $context['we_are_history']; |
|
1024 | + } |
|
983 | 1025 | |
984 | 1026 | foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
985 | 1027 | { |
986 | - if (isset($context['ignore_temp_attachments']) || isset($_SESSION['temp_attachments']['post']['files'])) |
|
987 | - break; |
|
1028 | + if (isset($context['ignore_temp_attachments']) || isset($_SESSION['temp_attachments']['post']['files'])) { |
|
1029 | + break; |
|
1030 | + } |
|
988 | 1031 | |
989 | - if ($attachID != 'initial_error' && strpos($attachID, 'post_tmp_' . $user_info['id']) === false) |
|
990 | - continue; |
|
1032 | + if ($attachID != 'initial_error' && strpos($attachID, 'post_tmp_' . $user_info['id']) === false) { |
|
1033 | + continue; |
|
1034 | + } |
|
991 | 1035 | |
992 | 1036 | if ($attachID == 'initial_error') |
993 | 1037 | { |
@@ -1002,15 +1046,17 @@ discard block |
||
1002 | 1046 | { |
1003 | 1047 | $txt['error_attach_errors'] = empty($txt['error_attach_errors']) ? '<br>' : ''; |
1004 | 1048 | $txt['error_attach_errors'] .= vsprintf($txt['attach_warning'], $attachment['name']) . '<div style="padding: 0 1em;">'; |
1005 | - foreach ($attachment['errors'] as $error) |
|
1006 | - $txt['error_attach_errors'] .= (is_array($error) ? vsprintf($txt[$error[0]], $error[1]) : $txt[$error]) . '<br >'; |
|
1049 | + foreach ($attachment['errors'] as $error) { |
|
1050 | + $txt['error_attach_errors'] .= (is_array($error) ? vsprintf($txt[$error[0]], $error[1]) : $txt[$error]) . '<br >'; |
|
1051 | + } |
|
1007 | 1052 | $txt['error_attach_errors'] .= '</div>'; |
1008 | 1053 | $post_errors[] = 'attach_errors'; |
1009 | 1054 | |
1010 | 1055 | // Take out the trash. |
1011 | 1056 | unset($_SESSION['temp_attachments'][$attachID]); |
1012 | - if (file_exists($attachment['tmp_name'])) |
|
1013 | - unlink($attachment['tmp_name']); |
|
1057 | + if (file_exists($attachment['tmp_name'])) { |
|
1058 | + unlink($attachment['tmp_name']); |
|
1059 | + } |
|
1014 | 1060 | continue; |
1015 | 1061 | } |
1016 | 1062 | |
@@ -1023,8 +1069,9 @@ discard block |
||
1023 | 1069 | |
1024 | 1070 | $context['attachments']['quantity']++; |
1025 | 1071 | $context['attachments']['total_size'] += $attachment['size']; |
1026 | - if (!isset($context['files_in_session_warning'])) |
|
1027 | - $context['files_in_session_warning'] = $txt['attached_files_in_session']; |
|
1072 | + if (!isset($context['files_in_session_warning'])) { |
|
1073 | + $context['files_in_session_warning'] = $txt['attached_files_in_session']; |
|
1074 | + } |
|
1028 | 1075 | |
1029 | 1076 | $context['current_attachments'][$attachID] = array( |
1030 | 1077 | 'name' => '<u>' . $smcFunc['htmlspecialchars']($attachment['name']) . '</u>', |
@@ -1052,8 +1099,9 @@ discard block |
||
1052 | 1099 | } |
1053 | 1100 | |
1054 | 1101 | // If they came from quick reply, and have to enter verification details, give them some notice. |
1055 | - if (!empty($_REQUEST['from_qr']) && !empty($context['require_verification'])) |
|
1056 | - $post_errors[] = 'need_qr_verification'; |
|
1102 | + if (!empty($_REQUEST['from_qr']) && !empty($context['require_verification'])) { |
|
1103 | + $post_errors[] = 'need_qr_verification'; |
|
1104 | + } |
|
1057 | 1105 | |
1058 | 1106 | /* |
1059 | 1107 | * There are two error types: serious and minor. Serious errors |
@@ -1070,52 +1118,56 @@ discard block |
||
1070 | 1118 | { |
1071 | 1119 | loadLanguage('Errors'); |
1072 | 1120 | $context['error_type'] = 'minor'; |
1073 | - foreach ($post_errors as $post_error) |
|
1074 | - if (is_array($post_error)) |
|
1121 | + foreach ($post_errors as $post_error) { |
|
1122 | + if (is_array($post_error)) |
|
1075 | 1123 | { |
1076 | 1124 | $post_error_id = $post_error[0]; |
1125 | + } |
|
1077 | 1126 | $context['post_error'][$post_error_id] = vsprintf($txt['error_' . $post_error_id], $post_error[1]); |
1078 | 1127 | |
1079 | 1128 | // If it's not a minor error flag it as such. |
1080 | - if (!in_array($post_error_id, $minor_errors)) |
|
1081 | - $context['error_type'] = 'serious'; |
|
1082 | - } |
|
1083 | - else |
|
1129 | + if (!in_array($post_error_id, $minor_errors)) { |
|
1130 | + $context['error_type'] = 'serious'; |
|
1131 | + } |
|
1132 | + } else |
|
1084 | 1133 | { |
1085 | 1134 | $context['post_error'][$post_error] = $txt['error_' . $post_error]; |
1086 | 1135 | |
1087 | 1136 | // If it's not a minor error flag it as such. |
1088 | - if (!in_array($post_error, $minor_errors)) |
|
1089 | - $context['error_type'] = 'serious'; |
|
1137 | + if (!in_array($post_error, $minor_errors)) { |
|
1138 | + $context['error_type'] = 'serious'; |
|
1139 | + } |
|
1090 | 1140 | } |
1091 | 1141 | } |
1092 | 1142 | |
1093 | 1143 | // What are you doing? Posting a poll, modifying, previewing, new post, or reply... |
1094 | - if (isset($_REQUEST['poll'])) |
|
1095 | - $context['page_title'] = $txt['new_poll']; |
|
1096 | - elseif ($context['make_event']) |
|
1097 | - $context['page_title'] = $context['event']['id'] == -1 ? $txt['calendar_post_event'] : $txt['calendar_edit']; |
|
1098 | - elseif (isset($_REQUEST['msg'])) |
|
1099 | - $context['page_title'] = $txt['modify_msg']; |
|
1100 | - elseif (isset($_REQUEST['subject'], $context['preview_subject'])) |
|
1101 | - $context['page_title'] = $txt['preview'] . ' - ' . strip_tags($context['preview_subject']); |
|
1102 | - elseif (empty($topic)) |
|
1103 | - $context['page_title'] = $txt['start_new_topic']; |
|
1104 | - else |
|
1105 | - $context['page_title'] = $txt['post_reply']; |
|
1144 | + if (isset($_REQUEST['poll'])) { |
|
1145 | + $context['page_title'] = $txt['new_poll']; |
|
1146 | + } elseif ($context['make_event']) { |
|
1147 | + $context['page_title'] = $context['event']['id'] == -1 ? $txt['calendar_post_event'] : $txt['calendar_edit']; |
|
1148 | + } elseif (isset($_REQUEST['msg'])) { |
|
1149 | + $context['page_title'] = $txt['modify_msg']; |
|
1150 | + } elseif (isset($_REQUEST['subject'], $context['preview_subject'])) { |
|
1151 | + $context['page_title'] = $txt['preview'] . ' - ' . strip_tags($context['preview_subject']); |
|
1152 | + } elseif (empty($topic)) { |
|
1153 | + $context['page_title'] = $txt['start_new_topic']; |
|
1154 | + } else { |
|
1155 | + $context['page_title'] = $txt['post_reply']; |
|
1156 | + } |
|
1106 | 1157 | |
1107 | 1158 | // Build the link tree. |
1108 | - if (empty($topic)) |
|
1109 | - $context['linktree'][] = array( |
|
1159 | + if (empty($topic)) { |
|
1160 | + $context['linktree'][] = array( |
|
1110 | 1161 | 'name' => '<em>' . $txt['start_new_topic'] . '</em>' |
1111 | 1162 | ); |
1112 | - else |
|
1113 | - $context['linktree'][] = array( |
|
1163 | + } else { |
|
1164 | + $context['linktree'][] = array( |
|
1114 | 1165 | 'url' => $scripturl . '?topic=' . $topic . '.' . $_REQUEST['start'], |
1115 | 1166 | 'name' => $form_subject, |
1116 | 1167 | 'extra_before' => '<span><strong class="nav">' . $context['page_title'] . ' (</strong></span>', |
1117 | 1168 | 'extra_after' => '<span><strong class="nav">)</strong></span>' |
1118 | 1169 | ); |
1170 | + } |
|
1119 | 1171 | |
1120 | 1172 | $context['subject'] = addcslashes($form_subject, '"'); |
1121 | 1173 | $context['message'] = str_replace(array('"', '<', '>', ' '), array('"', '<', '>', ' '), $form_message); |
@@ -1159,8 +1211,9 @@ discard block |
||
1159 | 1211 | // Message icons - customized icons are off? |
1160 | 1212 | $context['icons'] = getMessageIcons($board); |
1161 | 1213 | |
1162 | - if (!empty($context['icons'])) |
|
1163 | - $context['icons'][count($context['icons']) - 1]['is_last'] = true; |
|
1214 | + if (!empty($context['icons'])) { |
|
1215 | + $context['icons'][count($context['icons']) - 1]['is_last'] = true; |
|
1216 | + } |
|
1164 | 1217 | |
1165 | 1218 | // Are we starting a poll? if set the poll icon as selected if its available |
1166 | 1219 | if (isset($_REQUEST['poll'])) |
@@ -1180,8 +1233,9 @@ discard block |
||
1180 | 1233 | for ($i = 0, $n = count($context['icons']); $i < $n; $i++) |
1181 | 1234 | { |
1182 | 1235 | $context['icons'][$i]['selected'] = $context['icon'] == $context['icons'][$i]['value']; |
1183 | - if ($context['icons'][$i]['selected']) |
|
1184 | - $context['icon_url'] = $context['icons'][$i]['url']; |
|
1236 | + if ($context['icons'][$i]['selected']) { |
|
1237 | + $context['icon_url'] = $context['icons'][$i]['url']; |
|
1238 | + } |
|
1185 | 1239 | } |
1186 | 1240 | if (empty($context['icon_url'])) |
1187 | 1241 | { |
@@ -1195,8 +1249,9 @@ discard block |
||
1195 | 1249 | )); |
1196 | 1250 | } |
1197 | 1251 | |
1198 | - if (!empty($topic) && !empty($modSettings['topicSummaryPosts'])) |
|
1199 | - getTopic(); |
|
1252 | + if (!empty($topic) && !empty($modSettings['topicSummaryPosts'])) { |
|
1253 | + getTopic(); |
|
1254 | + } |
|
1200 | 1255 | |
1201 | 1256 | // If the user can post attachments prepare the warning labels. |
1202 | 1257 | if ($context['can_post_attachment']) |
@@ -1207,12 +1262,13 @@ discard block |
||
1207 | 1262 | $context['attachment_restrictions'] = array(); |
1208 | 1263 | $context['allowed_extensions'] = strtr(strtolower($modSettings['attachmentExtensions']), array(',' => ', ')); |
1209 | 1264 | $attachmentRestrictionTypes = array('attachmentNumPerPostLimit', 'attachmentPostLimit', 'attachmentSizeLimit'); |
1210 | - foreach ($attachmentRestrictionTypes as $type) |
|
1211 | - if (!empty($modSettings[$type])) |
|
1265 | + foreach ($attachmentRestrictionTypes as $type) { |
|
1266 | + if (!empty($modSettings[$type])) |
|
1212 | 1267 | { |
1213 | 1268 | // Show the max number of attachments if not 0. |
1214 | 1269 | if ($type == 'attachmentNumPerPostLimit') |
1215 | 1270 | $context['attachment_restrictions'][] = sprintf($txt['attach_remaining'], $modSettings['attachmentNumPerPostLimit'] - $context['attachments']['quantity']); |
1271 | + } |
|
1216 | 1272 | } |
1217 | 1273 | } |
1218 | 1274 | |
@@ -1246,8 +1302,8 @@ discard block |
||
1246 | 1302 | |
1247 | 1303 | if (!empty($context['current_attachments'])) |
1248 | 1304 | { |
1249 | - foreach ($context['current_attachments'] as $key => $mock) |
|
1250 | - addInlineJavaScript(' |
|
1305 | + foreach ($context['current_attachments'] as $key => $mock) { |
|
1306 | + addInlineJavaScript(' |
|
1251 | 1307 | current_attachments.push({ |
1252 | 1308 | name: '. JavaScriptEscape($mock['name']) . ', |
1253 | 1309 | size: '. $mock['size'] . ', |
@@ -1256,6 +1312,7 @@ discard block |
||
1256 | 1312 | type: '. JavaScriptEscape(!empty($mock['mime_type']) ? $mock['mime_type'] : '') . ', |
1257 | 1313 | thumbID: '. (!empty($mock['thumb']) ? $mock['thumb'] : 0) . ' |
1258 | 1314 | });', true); |
1315 | + } |
|
1259 | 1316 | } |
1260 | 1317 | |
1261 | 1318 | // File Upload. |
@@ -1340,8 +1397,9 @@ discard block |
||
1340 | 1397 | |
1341 | 1398 | |
1342 | 1399 | // Finally, load the template. |
1343 | - if (!isset($_REQUEST['xml'])) |
|
1344 | - loadTemplate('Post'); |
|
1400 | + if (!isset($_REQUEST['xml'])) { |
|
1401 | + loadTemplate('Post'); |
|
1402 | + } |
|
1345 | 1403 | |
1346 | 1404 | call_integration_hook('integrate_post_end'); |
1347 | 1405 | } |
@@ -1362,13 +1420,14 @@ discard block |
||
1362 | 1420 | // Sneaking off, are we? |
1363 | 1421 | if (empty($_POST) && empty($topic)) |
1364 | 1422 | { |
1365 | - if (empty($_SERVER['CONTENT_LENGTH'])) |
|
1366 | - redirectexit('action=post;board=' . $board . '.0'); |
|
1367 | - else |
|
1368 | - fatal_lang_error('post_upload_error', false); |
|
1423 | + if (empty($_SERVER['CONTENT_LENGTH'])) { |
|
1424 | + redirectexit('action=post;board=' . $board . '.0'); |
|
1425 | + } else { |
|
1426 | + fatal_lang_error('post_upload_error', false); |
|
1427 | + } |
|
1428 | + } elseif (empty($_POST) && !empty($topic)) { |
|
1429 | + redirectexit('action=post;topic=' . $topic . '.0'); |
|
1369 | 1430 | } |
1370 | - elseif (empty($_POST) && !empty($topic)) |
|
1371 | - redirectexit('action=post;topic=' . $topic . '.0'); |
|
1372 | 1431 | |
1373 | 1432 | // No need! |
1374 | 1433 | $context['robot_no_index'] = true; |
@@ -1380,8 +1439,9 @@ discard block |
||
1380 | 1439 | $post_errors = array(); |
1381 | 1440 | |
1382 | 1441 | // If the session has timed out, let the user re-submit their form. |
1383 | - if (checkSession('post', '', false) != '') |
|
1384 | - $post_errors[] = 'session_timeout'; |
|
1442 | + if (checkSession('post', '', false) != '') { |
|
1443 | + $post_errors[] = 'session_timeout'; |
|
1444 | + } |
|
1385 | 1445 | |
1386 | 1446 | // Wrong verification code? |
1387 | 1447 | if (!$user_info['is_admin'] && !$user_info['is_mod'] && !empty($modSettings['posts_require_captcha']) && ($user_info['posts'] < $modSettings['posts_require_captcha'] || ($user_info['is_guest'] && $modSettings['posts_require_captcha'] == -1))) |
@@ -1391,33 +1451,38 @@ discard block |
||
1391 | 1451 | 'id' => 'post', |
1392 | 1452 | ); |
1393 | 1453 | $context['require_verification'] = create_control_verification($verificationOptions, true); |
1394 | - if (is_array($context['require_verification'])) |
|
1395 | - $post_errors = array_merge($post_errors, $context['require_verification']); |
|
1454 | + if (is_array($context['require_verification'])) { |
|
1455 | + $post_errors = array_merge($post_errors, $context['require_verification']); |
|
1456 | + } |
|
1396 | 1457 | } |
1397 | 1458 | |
1398 | 1459 | require_once($sourcedir . '/Subs-Post.php'); |
1399 | 1460 | loadLanguage('Post'); |
1400 | 1461 | |
1401 | 1462 | // Drafts enabled and needed? |
1402 | - if (!empty($modSettings['drafts_post_enabled']) && (isset($_POST['save_draft']) || isset($_POST['id_draft']))) |
|
1403 | - require_once($sourcedir . '/Drafts.php'); |
|
1463 | + if (!empty($modSettings['drafts_post_enabled']) && (isset($_POST['save_draft']) || isset($_POST['id_draft']))) { |
|
1464 | + require_once($sourcedir . '/Drafts.php'); |
|
1465 | + } |
|
1404 | 1466 | |
1405 | 1467 | // First check to see if they are trying to delete any current attachments. |
1406 | 1468 | if (isset($_POST['attach_del'])) |
1407 | 1469 | { |
1408 | 1470 | $keep_temp = array(); |
1409 | 1471 | $keep_ids = array(); |
1410 | - foreach ($_POST['attach_del'] as $dummy) |
|
1411 | - if (strpos($dummy, 'post_tmp_' . $user_info['id']) !== false) |
|
1472 | + foreach ($_POST['attach_del'] as $dummy) { |
|
1473 | + if (strpos($dummy, 'post_tmp_' . $user_info['id']) !== false) |
|
1412 | 1474 | $keep_temp[] = $dummy; |
1413 | - else |
|
1414 | - $keep_ids[] = (int) $dummy; |
|
1475 | + } |
|
1476 | + else { |
|
1477 | + $keep_ids[] = (int) $dummy; |
|
1478 | + } |
|
1415 | 1479 | |
1416 | - if (isset($_SESSION['temp_attachments'])) |
|
1417 | - foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
|
1480 | + if (isset($_SESSION['temp_attachments'])) { |
|
1481 | + foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
|
1418 | 1482 | { |
1419 | 1483 | if ((isset($_SESSION['temp_attachments']['post']['files'], $attachment['name']) && in_array($attachment['name'], $_SESSION['temp_attachments']['post']['files'])) || in_array($attachID, $keep_temp) || strpos($attachID, 'post_tmp_' . $user_info['id']) === false) |
1420 | 1484 | continue; |
1485 | + } |
|
1421 | 1486 | |
1422 | 1487 | unset($_SESSION['temp_attachments'][$attachID]); |
1423 | 1488 | unlink($attachment['tmp_name']); |
@@ -1459,12 +1524,14 @@ discard block |
||
1459 | 1524 | $smcFunc['db_free_result']($request); |
1460 | 1525 | |
1461 | 1526 | // Though the topic should be there, it might have vanished. |
1462 | - if (!is_array($topic_info)) |
|
1463 | - fatal_lang_error('topic_doesnt_exist', 404); |
|
1527 | + if (!is_array($topic_info)) { |
|
1528 | + fatal_lang_error('topic_doesnt_exist', 404); |
|
1529 | + } |
|
1464 | 1530 | |
1465 | 1531 | // Did this topic suddenly move? Just checking... |
1466 | - if ($topic_info['id_board'] != $board) |
|
1467 | - fatal_lang_error('not_a_topic'); |
|
1532 | + if ($topic_info['id_board'] != $board) { |
|
1533 | + fatal_lang_error('not_a_topic'); |
|
1534 | + } |
|
1468 | 1535 | |
1469 | 1536 | // Do the permissions and approval stuff... |
1470 | 1537 | $becomesApproved = true; |
@@ -1487,49 +1554,50 @@ discard block |
||
1487 | 1554 | if (!empty($topic) && !isset($_REQUEST['msg'])) |
1488 | 1555 | { |
1489 | 1556 | // Don't allow a post if it's locked. |
1490 | - if ($topic_info['locked'] != 0 && !allowedTo('moderate_board')) |
|
1491 | - fatal_lang_error('topic_locked', false); |
|
1557 | + if ($topic_info['locked'] != 0 && !allowedTo('moderate_board')) { |
|
1558 | + fatal_lang_error('topic_locked', false); |
|
1559 | + } |
|
1492 | 1560 | |
1493 | 1561 | // Sorry, multiple polls aren't allowed... yet. You should stop giving me ideas :P. |
1494 | - if (isset($_REQUEST['poll']) && $topic_info['id_poll'] > 0) |
|
1495 | - unset($_REQUEST['poll']); |
|
1496 | - |
|
1497 | - elseif ($topic_info['id_member_started'] != $user_info['id']) |
|
1498 | - { |
|
1499 | - if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_any') && !allowedTo('post_reply_any')) |
|
1500 | - $becomesApproved = false; |
|
1501 | - |
|
1502 | - else |
|
1503 | - isAllowedTo('post_reply_any'); |
|
1504 | - } |
|
1505 | - elseif (!allowedTo('post_reply_any')) |
|
1562 | + if (isset($_REQUEST['poll']) && $topic_info['id_poll'] > 0) { |
|
1563 | + unset($_REQUEST['poll']); |
|
1564 | + } elseif ($topic_info['id_member_started'] != $user_info['id']) |
|
1565 | + { |
|
1566 | + if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_any') && !allowedTo('post_reply_any')) { |
|
1567 | + $becomesApproved = false; |
|
1568 | + } else { |
|
1569 | + isAllowedTo('post_reply_any'); |
|
1570 | + } |
|
1571 | + } elseif (!allowedTo('post_reply_any')) |
|
1506 | 1572 | { |
1507 | - if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_own') && !allowedTo('post_reply_own')) |
|
1508 | - $becomesApproved = false; |
|
1509 | - |
|
1510 | - else |
|
1511 | - isAllowedTo('post_reply_own'); |
|
1573 | + if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_own') && !allowedTo('post_reply_own')) { |
|
1574 | + $becomesApproved = false; |
|
1575 | + } else { |
|
1576 | + isAllowedTo('post_reply_own'); |
|
1577 | + } |
|
1512 | 1578 | } |
1513 | 1579 | |
1514 | 1580 | if (isset($_POST['lock'])) |
1515 | 1581 | { |
1516 | 1582 | // Nothing is changed to the lock. |
1517 | - if ((empty($topic_info['locked']) && empty($_POST['lock'])) || (!empty($_POST['lock']) && !empty($topic_info['locked']))) |
|
1518 | - unset($_POST['lock']); |
|
1583 | + if ((empty($topic_info['locked']) && empty($_POST['lock'])) || (!empty($_POST['lock']) && !empty($topic_info['locked']))) { |
|
1584 | + unset($_POST['lock']); |
|
1585 | + } |
|
1519 | 1586 | |
1520 | 1587 | // You're have no permission to lock this topic. |
1521 | - elseif (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $topic_info['id_member_started'])) |
|
1522 | - unset($_POST['lock']); |
|
1588 | + elseif (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $topic_info['id_member_started'])) { |
|
1589 | + unset($_POST['lock']); |
|
1590 | + } |
|
1523 | 1591 | |
1524 | 1592 | // You are allowed to (un)lock your own topic only. |
1525 | 1593 | elseif (!allowedTo('lock_any')) |
1526 | 1594 | { |
1527 | 1595 | // You cannot override a moderator lock. |
1528 | - if ($topic_info['locked'] == 1) |
|
1529 | - unset($_POST['lock']); |
|
1530 | - |
|
1531 | - else |
|
1532 | - $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
1596 | + if ($topic_info['locked'] == 1) { |
|
1597 | + unset($_POST['lock']); |
|
1598 | + } else { |
|
1599 | + $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
1600 | + } |
|
1533 | 1601 | } |
1534 | 1602 | // Hail mighty moderator, (un)lock this topic immediately. |
1535 | 1603 | else |
@@ -1537,19 +1605,21 @@ discard block |
||
1537 | 1605 | $_POST['lock'] = empty($_POST['lock']) ? 0 : 1; |
1538 | 1606 | |
1539 | 1607 | // Did someone (un)lock this while you were posting? |
1540 | - if (isset($_POST['already_locked']) && $_POST['already_locked'] != $topic_info['locked']) |
|
1541 | - $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'locked'; |
|
1608 | + if (isset($_POST['already_locked']) && $_POST['already_locked'] != $topic_info['locked']) { |
|
1609 | + $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'locked'; |
|
1610 | + } |
|
1542 | 1611 | } |
1543 | 1612 | } |
1544 | 1613 | |
1545 | 1614 | // So you wanna (un)sticky this...let's see. |
1546 | - if (isset($_POST['sticky']) && ($_POST['sticky'] == $topic_info['is_sticky'] || !allowedTo('make_sticky'))) |
|
1547 | - unset($_POST['sticky']); |
|
1548 | - elseif (isset($_POST['sticky'])) |
|
1615 | + if (isset($_POST['sticky']) && ($_POST['sticky'] == $topic_info['is_sticky'] || !allowedTo('make_sticky'))) { |
|
1616 | + unset($_POST['sticky']); |
|
1617 | + } elseif (isset($_POST['sticky'])) |
|
1549 | 1618 | { |
1550 | 1619 | // Did someone (un)sticky this while you were posting? |
1551 | - if (isset($_POST['already_sticky']) && $_POST['already_sticky'] != $topic_info['is_sticky']) |
|
1552 | - $post_errors[] = 'topic_' . (empty($topic_info['is_sticky']) ? 'un' : '') . 'sticky'; |
|
1620 | + if (isset($_POST['already_sticky']) && $_POST['already_sticky'] != $topic_info['is_sticky']) { |
|
1621 | + $post_errors[] = 'topic_' . (empty($topic_info['is_sticky']) ? 'un' : '') . 'sticky'; |
|
1622 | + } |
|
1553 | 1623 | } |
1554 | 1624 | |
1555 | 1625 | // If drafts are enabled, then pass this off |
@@ -1576,26 +1646,31 @@ discard block |
||
1576 | 1646 | |
1577 | 1647 | // Do like, the permissions, for safety and stuff... |
1578 | 1648 | $becomesApproved = true; |
1579 | - if ($modSettings['postmod_active'] && !allowedTo('post_new') && allowedTo('post_unapproved_topics')) |
|
1580 | - $becomesApproved = false; |
|
1581 | - else |
|
1582 | - isAllowedTo('post_new'); |
|
1649 | + if ($modSettings['postmod_active'] && !allowedTo('post_new') && allowedTo('post_unapproved_topics')) { |
|
1650 | + $becomesApproved = false; |
|
1651 | + } else { |
|
1652 | + isAllowedTo('post_new'); |
|
1653 | + } |
|
1583 | 1654 | |
1584 | 1655 | if (isset($_POST['lock'])) |
1585 | 1656 | { |
1586 | 1657 | // New topics are by default not locked. |
1587 | - if (empty($_POST['lock'])) |
|
1588 | - unset($_POST['lock']); |
|
1658 | + if (empty($_POST['lock'])) { |
|
1659 | + unset($_POST['lock']); |
|
1660 | + } |
|
1589 | 1661 | // Besides, you need permission. |
1590 | - elseif (!allowedTo(array('lock_any', 'lock_own'))) |
|
1591 | - unset($_POST['lock']); |
|
1662 | + elseif (!allowedTo(array('lock_any', 'lock_own'))) { |
|
1663 | + unset($_POST['lock']); |
|
1664 | + } |
|
1592 | 1665 | // A moderator-lock (1) can override a user-lock (2). |
1593 | - else |
|
1594 | - $_POST['lock'] = allowedTo('lock_any') ? 1 : 2; |
|
1666 | + else { |
|
1667 | + $_POST['lock'] = allowedTo('lock_any') ? 1 : 2; |
|
1668 | + } |
|
1595 | 1669 | } |
1596 | 1670 | |
1597 | - if (isset($_POST['sticky']) && (empty($_POST['sticky']) || !allowedTo('make_sticky'))) |
|
1598 | - unset($_POST['sticky']); |
|
1671 | + if (isset($_POST['sticky']) && (empty($_POST['sticky']) || !allowedTo('make_sticky'))) { |
|
1672 | + unset($_POST['sticky']); |
|
1673 | + } |
|
1599 | 1674 | |
1600 | 1675 | // Saving your new topic as a draft first? |
1601 | 1676 | if (!empty($modSettings['drafts_post_enabled']) && isset($_POST['save_draft'])) |
@@ -1620,31 +1695,37 @@ discard block |
||
1620 | 1695 | 'id_msg' => $_REQUEST['msg'], |
1621 | 1696 | ) |
1622 | 1697 | ); |
1623 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
1624 | - fatal_lang_error('cant_find_messages', false); |
|
1698 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
1699 | + fatal_lang_error('cant_find_messages', false); |
|
1700 | + } |
|
1625 | 1701 | $row = $smcFunc['db_fetch_assoc']($request); |
1626 | 1702 | $smcFunc['db_free_result']($request); |
1627 | 1703 | |
1628 | - if (!empty($topic_info['locked']) && !allowedTo('moderate_board')) |
|
1629 | - fatal_lang_error('topic_locked', false); |
|
1704 | + if (!empty($topic_info['locked']) && !allowedTo('moderate_board')) { |
|
1705 | + fatal_lang_error('topic_locked', false); |
|
1706 | + } |
|
1630 | 1707 | |
1631 | 1708 | if (isset($_POST['lock'])) |
1632 | 1709 | { |
1633 | 1710 | // Nothing changes to the lock status. |
1634 | - if ((empty($_POST['lock']) && empty($topic_info['locked'])) || (!empty($_POST['lock']) && !empty($topic_info['locked']))) |
|
1635 | - unset($_POST['lock']); |
|
1711 | + if ((empty($_POST['lock']) && empty($topic_info['locked'])) || (!empty($_POST['lock']) && !empty($topic_info['locked']))) { |
|
1712 | + unset($_POST['lock']); |
|
1713 | + } |
|
1636 | 1714 | // You're simply not allowed to (un)lock this. |
1637 | - elseif (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $topic_info['id_member_started'])) |
|
1638 | - unset($_POST['lock']); |
|
1715 | + elseif (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $topic_info['id_member_started'])) { |
|
1716 | + unset($_POST['lock']); |
|
1717 | + } |
|
1639 | 1718 | // You're only allowed to lock your own topics. |
1640 | 1719 | elseif (!allowedTo('lock_any')) |
1641 | 1720 | { |
1642 | 1721 | // You're not allowed to break a moderator's lock. |
1643 | - if ($topic_info['locked'] == 1) |
|
1644 | - unset($_POST['lock']); |
|
1722 | + if ($topic_info['locked'] == 1) { |
|
1723 | + unset($_POST['lock']); |
|
1724 | + } |
|
1645 | 1725 | // Lock it with a soft lock or unlock it. |
1646 | - else |
|
1647 | - $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
1726 | + else { |
|
1727 | + $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
1728 | + } |
|
1648 | 1729 | } |
1649 | 1730 | // You must be the moderator. |
1650 | 1731 | else |
@@ -1652,44 +1733,46 @@ discard block |
||
1652 | 1733 | $_POST['lock'] = empty($_POST['lock']) ? 0 : 1; |
1653 | 1734 | |
1654 | 1735 | // Did someone (un)lock this while you were posting? |
1655 | - if (isset($_POST['already_locked']) && $_POST['already_locked'] != $topic_info['locked']) |
|
1656 | - $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'locked'; |
|
1736 | + if (isset($_POST['already_locked']) && $_POST['already_locked'] != $topic_info['locked']) { |
|
1737 | + $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'locked'; |
|
1738 | + } |
|
1657 | 1739 | } |
1658 | 1740 | } |
1659 | 1741 | |
1660 | 1742 | // Change the sticky status of this topic? |
1661 | - if (isset($_POST['sticky']) && (!allowedTo('make_sticky') || $_POST['sticky'] == $topic_info['is_sticky'])) |
|
1662 | - unset($_POST['sticky']); |
|
1663 | - elseif (isset($_POST['sticky'])) |
|
1743 | + if (isset($_POST['sticky']) && (!allowedTo('make_sticky') || $_POST['sticky'] == $topic_info['is_sticky'])) { |
|
1744 | + unset($_POST['sticky']); |
|
1745 | + } elseif (isset($_POST['sticky'])) |
|
1664 | 1746 | { |
1665 | 1747 | // Did someone (un)sticky this while you were posting? |
1666 | - if (isset($_POST['already_sticky']) && $_POST['already_sticky'] != $topic_info['is_sticky']) |
|
1667 | - $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'stickied'; |
|
1748 | + if (isset($_POST['already_sticky']) && $_POST['already_sticky'] != $topic_info['is_sticky']) { |
|
1749 | + $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'stickied'; |
|
1750 | + } |
|
1668 | 1751 | } |
1669 | 1752 | |
1670 | 1753 | if ($row['id_member'] == $user_info['id'] && !allowedTo('modify_any')) |
1671 | 1754 | { |
1672 | - if ((!$modSettings['postmod_active'] || $row['approved']) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) |
|
1673 | - fatal_lang_error('modify_post_time_passed', false); |
|
1674 | - elseif ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('modify_own')) |
|
1675 | - isAllowedTo('modify_replies'); |
|
1676 | - else |
|
1677 | - isAllowedTo('modify_own'); |
|
1678 | - } |
|
1679 | - elseif ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('modify_any')) |
|
1755 | + if ((!$modSettings['postmod_active'] || $row['approved']) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) { |
|
1756 | + fatal_lang_error('modify_post_time_passed', false); |
|
1757 | + } elseif ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('modify_own')) { |
|
1758 | + isAllowedTo('modify_replies'); |
|
1759 | + } else { |
|
1760 | + isAllowedTo('modify_own'); |
|
1761 | + } |
|
1762 | + } elseif ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('modify_any')) |
|
1680 | 1763 | { |
1681 | 1764 | isAllowedTo('modify_replies'); |
1682 | 1765 | |
1683 | 1766 | // If you're modifying a reply, I say it better be logged... |
1684 | 1767 | $moderationAction = true; |
1685 | - } |
|
1686 | - else |
|
1768 | + } else |
|
1687 | 1769 | { |
1688 | 1770 | isAllowedTo('modify_any'); |
1689 | 1771 | |
1690 | 1772 | // Log it, assuming you're not modifying your own post. |
1691 | - if ($row['id_member'] != $user_info['id']) |
|
1692 | - $moderationAction = true; |
|
1773 | + if ($row['id_member'] != $user_info['id']) { |
|
1774 | + $moderationAction = true; |
|
1775 | + } |
|
1693 | 1776 | } |
1694 | 1777 | |
1695 | 1778 | // If drafts are enabled, then lets send this off to save |
@@ -1727,20 +1810,24 @@ discard block |
||
1727 | 1810 | $_POST['guestname'] = !isset($_POST['guestname']) ? '' : trim($_POST['guestname']); |
1728 | 1811 | $_POST['email'] = !isset($_POST['email']) ? '' : trim($_POST['email']); |
1729 | 1812 | |
1730 | - if ($_POST['guestname'] == '' || $_POST['guestname'] == '_') |
|
1731 | - $post_errors[] = 'no_name'; |
|
1732 | - if ($smcFunc['strlen']($_POST['guestname']) > 25) |
|
1733 | - $post_errors[] = 'long_name'; |
|
1813 | + if ($_POST['guestname'] == '' || $_POST['guestname'] == '_') { |
|
1814 | + $post_errors[] = 'no_name'; |
|
1815 | + } |
|
1816 | + if ($smcFunc['strlen']($_POST['guestname']) > 25) { |
|
1817 | + $post_errors[] = 'long_name'; |
|
1818 | + } |
|
1734 | 1819 | |
1735 | 1820 | if (empty($modSettings['guest_post_no_email'])) |
1736 | 1821 | { |
1737 | 1822 | // Only check if they changed it! |
1738 | 1823 | if (!isset($row) || $row['poster_email'] != $_POST['email']) |
1739 | 1824 | { |
1740 | - if (!allowedTo('moderate_forum') && (!isset($_POST['email']) || $_POST['email'] == '')) |
|
1741 | - $post_errors[] = 'no_email'; |
|
1742 | - if (!allowedTo('moderate_forum') && !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) |
|
1743 | - $post_errors[] = 'bad_email'; |
|
1825 | + if (!allowedTo('moderate_forum') && (!isset($_POST['email']) || $_POST['email'] == '')) { |
|
1826 | + $post_errors[] = 'no_email'; |
|
1827 | + } |
|
1828 | + if (!allowedTo('moderate_forum') && !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) { |
|
1829 | + $post_errors[] = 'bad_email'; |
|
1830 | + } |
|
1744 | 1831 | } |
1745 | 1832 | |
1746 | 1833 | // Now make sure this email address is not banned from posting. |
@@ -1756,75 +1843,89 @@ discard block |
||
1756 | 1843 | } |
1757 | 1844 | |
1758 | 1845 | // Coming from the quickReply? |
1759 | - if (isset($_POST['quickReply'])) |
|
1760 | - $_POST['message'] = $_POST['quickReply']; |
|
1846 | + if (isset($_POST['quickReply'])) { |
|
1847 | + $_POST['message'] = $_POST['quickReply']; |
|
1848 | + } |
|
1761 | 1849 | |
1762 | 1850 | // Check the subject and message. |
1763 | - if (!isset($_POST['subject']) || $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['subject'])) === '') |
|
1764 | - $post_errors[] = 'no_subject'; |
|
1765 | - if (!isset($_POST['message']) || $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['message']), ENT_QUOTES) === '') |
|
1766 | - $post_errors[] = 'no_message'; |
|
1767 | - elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_POST['message']) > $modSettings['max_messageLength']) |
|
1768 | - $post_errors[] = array('long_message', array($modSettings['max_messageLength'])); |
|
1769 | - else |
|
1851 | + if (!isset($_POST['subject']) || $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['subject'])) === '') { |
|
1852 | + $post_errors[] = 'no_subject'; |
|
1853 | + } |
|
1854 | + if (!isset($_POST['message']) || $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['message']), ENT_QUOTES) === '') { |
|
1855 | + $post_errors[] = 'no_message'; |
|
1856 | + } elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_POST['message']) > $modSettings['max_messageLength']) { |
|
1857 | + $post_errors[] = array('long_message', array($modSettings['max_messageLength'])); |
|
1858 | + } else |
|
1770 | 1859 | { |
1771 | 1860 | // Prepare the message a bit for some additional testing. |
1772 | 1861 | $_POST['message'] = $smcFunc['htmlspecialchars']($_POST['message'], ENT_QUOTES); |
1773 | 1862 | |
1774 | 1863 | // Preparse code. (Zef) |
1775 | - if ($user_info['is_guest']) |
|
1776 | - $user_info['name'] = $_POST['guestname']; |
|
1864 | + if ($user_info['is_guest']) { |
|
1865 | + $user_info['name'] = $_POST['guestname']; |
|
1866 | + } |
|
1777 | 1867 | preparsecode($_POST['message']); |
1778 | 1868 | |
1779 | 1869 | // Let's see if there's still some content left without the tags. |
1780 | - if ($smcFunc['htmltrim'](strip_tags(parse_bbc($_POST['message'], false), implode('', $context['allowed_html_tags']))) === '' && (!allowedTo('admin_forum') || strpos($_POST['message'], '[html]') === false)) |
|
1781 | - $post_errors[] = 'no_message'; |
|
1870 | + if ($smcFunc['htmltrim'](strip_tags(parse_bbc($_POST['message'], false), implode('', $context['allowed_html_tags']))) === '' && (!allowedTo('admin_forum') || strpos($_POST['message'], '[html]') === false)) { |
|
1871 | + $post_errors[] = 'no_message'; |
|
1872 | + } |
|
1873 | + } |
|
1874 | + if (isset($_POST['calendar']) && !isset($_REQUEST['deleteevent']) && $smcFunc['htmltrim']($_POST['evtitle']) === '') { |
|
1875 | + $post_errors[] = 'no_event'; |
|
1782 | 1876 | } |
1783 | - if (isset($_POST['calendar']) && !isset($_REQUEST['deleteevent']) && $smcFunc['htmltrim']($_POST['evtitle']) === '') |
|
1784 | - $post_errors[] = 'no_event'; |
|
1785 | 1877 | // You are not! |
1786 | - if (isset($_POST['message']) && strtolower($_POST['message']) == 'i am the administrator.' && !$user_info['is_admin']) |
|
1787 | - fatal_error('Knave! Masquerader! Charlatan!', false); |
|
1878 | + if (isset($_POST['message']) && strtolower($_POST['message']) == 'i am the administrator.' && !$user_info['is_admin']) { |
|
1879 | + fatal_error('Knave! Masquerader! Charlatan!', false); |
|
1880 | + } |
|
1788 | 1881 | |
1789 | 1882 | // Validate the poll... |
1790 | 1883 | if (isset($_REQUEST['poll']) && $modSettings['pollMode'] == '1') |
1791 | 1884 | { |
1792 | - if (!empty($topic) && !isset($_REQUEST['msg'])) |
|
1793 | - fatal_lang_error('no_access', false); |
|
1885 | + if (!empty($topic) && !isset($_REQUEST['msg'])) { |
|
1886 | + fatal_lang_error('no_access', false); |
|
1887 | + } |
|
1794 | 1888 | |
1795 | 1889 | // This is a new topic... so it's a new poll. |
1796 | - if (empty($topic)) |
|
1797 | - isAllowedTo('poll_post'); |
|
1890 | + if (empty($topic)) { |
|
1891 | + isAllowedTo('poll_post'); |
|
1892 | + } |
|
1798 | 1893 | // Can you add to your own topics? |
1799 | - elseif ($user_info['id'] == $topic_info['id_member_started'] && !allowedTo('poll_add_any')) |
|
1800 | - isAllowedTo('poll_add_own'); |
|
1894 | + elseif ($user_info['id'] == $topic_info['id_member_started'] && !allowedTo('poll_add_any')) { |
|
1895 | + isAllowedTo('poll_add_own'); |
|
1896 | + } |
|
1801 | 1897 | // Can you add polls to any topic, then? |
1802 | - else |
|
1803 | - isAllowedTo('poll_add_any'); |
|
1898 | + else { |
|
1899 | + isAllowedTo('poll_add_any'); |
|
1900 | + } |
|
1804 | 1901 | |
1805 | - if (!isset($_POST['question']) || trim($_POST['question']) == '') |
|
1806 | - $post_errors[] = 'no_question'; |
|
1902 | + if (!isset($_POST['question']) || trim($_POST['question']) == '') { |
|
1903 | + $post_errors[] = 'no_question'; |
|
1904 | + } |
|
1807 | 1905 | |
1808 | 1906 | $_POST['options'] = empty($_POST['options']) ? array() : htmltrim__recursive($_POST['options']); |
1809 | 1907 | |
1810 | 1908 | // Get rid of empty ones. |
1811 | - foreach ($_POST['options'] as $k => $option) |
|
1812 | - if ($option == '') |
|
1909 | + foreach ($_POST['options'] as $k => $option) { |
|
1910 | + if ($option == '') |
|
1813 | 1911 | unset($_POST['options'][$k], $_POST['options'][$k]); |
1912 | + } |
|
1814 | 1913 | |
1815 | 1914 | // What are you going to vote between with one choice?!? |
1816 | - if (count($_POST['options']) < 2) |
|
1817 | - $post_errors[] = 'poll_few'; |
|
1818 | - elseif (count($_POST['options']) > 256) |
|
1819 | - $post_errors[] = 'poll_many'; |
|
1915 | + if (count($_POST['options']) < 2) { |
|
1916 | + $post_errors[] = 'poll_few'; |
|
1917 | + } elseif (count($_POST['options']) > 256) { |
|
1918 | + $post_errors[] = 'poll_many'; |
|
1919 | + } |
|
1820 | 1920 | } |
1821 | 1921 | |
1822 | 1922 | if ($posterIsGuest) |
1823 | 1923 | { |
1824 | 1924 | // If user is a guest, make sure the chosen name isn't taken. |
1825 | 1925 | require_once($sourcedir . '/Subs-Members.php'); |
1826 | - if (isReservedName($_POST['guestname'], 0, true, false) && (!isset($row['poster_name']) || $_POST['guestname'] != $row['poster_name'])) |
|
1827 | - $post_errors[] = 'bad_name'; |
|
1926 | + if (isReservedName($_POST['guestname'], 0, true, false) && (!isset($row['poster_name']) || $_POST['guestname'] != $row['poster_name'])) { |
|
1927 | + $post_errors[] = 'bad_name'; |
|
1928 | + } |
|
1828 | 1929 | } |
1829 | 1930 | // If the user isn't a guest, get his or her name and email. |
1830 | 1931 | elseif (!isset($_REQUEST['msg'])) |
@@ -1855,8 +1956,9 @@ discard block |
||
1855 | 1956 | } |
1856 | 1957 | |
1857 | 1958 | // Make sure the user isn't spamming the board. |
1858 | - if (!isset($_REQUEST['msg'])) |
|
1859 | - spamProtection('post'); |
|
1959 | + if (!isset($_REQUEST['msg'])) { |
|
1960 | + spamProtection('post'); |
|
1961 | + } |
|
1860 | 1962 | |
1861 | 1963 | // At about this point, we're posting and that's that. |
1862 | 1964 | ignore_user_abort(true); |
@@ -1869,32 +1971,36 @@ discard block |
||
1869 | 1971 | $_POST['modify_reason'] = empty($_POST['modify_reason']) ? '' : strtr($smcFunc['htmlspecialchars']($_POST['modify_reason']), array("\r" => '', "\n" => '', "\t" => '')); |
1870 | 1972 | |
1871 | 1973 | // At this point, we want to make sure the subject isn't too long. |
1872 | - if ($smcFunc['strlen']($_POST['subject']) > 100) |
|
1873 | - $_POST['subject'] = $smcFunc['substr']($_POST['subject'], 0, 100); |
|
1974 | + if ($smcFunc['strlen']($_POST['subject']) > 100) { |
|
1975 | + $_POST['subject'] = $smcFunc['substr']($_POST['subject'], 0, 100); |
|
1976 | + } |
|
1874 | 1977 | |
1875 | 1978 | // Same with the "why did you edit this" text. |
1876 | - if ($smcFunc['strlen']($_POST['modify_reason']) > 100) |
|
1877 | - $_POST['modify_reason'] = $smcFunc['substr']($_POST['modify_reason'], 0, 100); |
|
1979 | + if ($smcFunc['strlen']($_POST['modify_reason']) > 100) { |
|
1980 | + $_POST['modify_reason'] = $smcFunc['substr']($_POST['modify_reason'], 0, 100); |
|
1981 | + } |
|
1878 | 1982 | |
1879 | 1983 | // Make the poll... |
1880 | 1984 | if (isset($_REQUEST['poll'])) |
1881 | 1985 | { |
1882 | 1986 | // Make sure that the user has not entered a ridiculous number of options.. |
1883 | - if (empty($_POST['poll_max_votes']) || $_POST['poll_max_votes'] <= 0) |
|
1884 | - $_POST['poll_max_votes'] = 1; |
|
1885 | - elseif ($_POST['poll_max_votes'] > count($_POST['options'])) |
|
1886 | - $_POST['poll_max_votes'] = count($_POST['options']); |
|
1887 | - else |
|
1888 | - $_POST['poll_max_votes'] = (int) $_POST['poll_max_votes']; |
|
1987 | + if (empty($_POST['poll_max_votes']) || $_POST['poll_max_votes'] <= 0) { |
|
1988 | + $_POST['poll_max_votes'] = 1; |
|
1989 | + } elseif ($_POST['poll_max_votes'] > count($_POST['options'])) { |
|
1990 | + $_POST['poll_max_votes'] = count($_POST['options']); |
|
1991 | + } else { |
|
1992 | + $_POST['poll_max_votes'] = (int) $_POST['poll_max_votes']; |
|
1993 | + } |
|
1889 | 1994 | |
1890 | 1995 | $_POST['poll_expire'] = (int) $_POST['poll_expire']; |
1891 | 1996 | $_POST['poll_expire'] = $_POST['poll_expire'] > 9999 ? 9999 : ($_POST['poll_expire'] < 0 ? 0 : $_POST['poll_expire']); |
1892 | 1997 | |
1893 | 1998 | // Just set it to zero if it's not there.. |
1894 | - if (!isset($_POST['poll_hide'])) |
|
1895 | - $_POST['poll_hide'] = 0; |
|
1896 | - else |
|
1897 | - $_POST['poll_hide'] = (int) $_POST['poll_hide']; |
|
1999 | + if (!isset($_POST['poll_hide'])) { |
|
2000 | + $_POST['poll_hide'] = 0; |
|
2001 | + } else { |
|
2002 | + $_POST['poll_hide'] = (int) $_POST['poll_hide']; |
|
2003 | + } |
|
1898 | 2004 | $_POST['poll_change_vote'] = isset($_POST['poll_change_vote']) ? 1 : 0; |
1899 | 2005 | |
1900 | 2006 | $_POST['poll_guest_vote'] = isset($_POST['poll_guest_vote']) ? 1 : 0; |
@@ -1903,16 +2009,19 @@ discard block |
||
1903 | 2009 | { |
1904 | 2010 | require_once($sourcedir . '/Subs-Members.php'); |
1905 | 2011 | $allowedVoteGroups = groupsAllowedTo('poll_vote', $board); |
1906 | - if (!in_array(-1, $allowedVoteGroups['allowed'])) |
|
1907 | - $_POST['poll_guest_vote'] = 0; |
|
2012 | + if (!in_array(-1, $allowedVoteGroups['allowed'])) { |
|
2013 | + $_POST['poll_guest_vote'] = 0; |
|
2014 | + } |
|
1908 | 2015 | } |
1909 | 2016 | |
1910 | 2017 | // If the user tries to set the poll too far in advance, don't let them. |
1911 | - if (!empty($_POST['poll_expire']) && $_POST['poll_expire'] < 1) |
|
1912 | - fatal_lang_error('poll_range_error', false); |
|
2018 | + if (!empty($_POST['poll_expire']) && $_POST['poll_expire'] < 1) { |
|
2019 | + fatal_lang_error('poll_range_error', false); |
|
2020 | + } |
|
1913 | 2021 | // Don't allow them to select option 2 for hidden results if it's not time limited. |
1914 | - elseif (empty($_POST['poll_expire']) && $_POST['poll_hide'] == 2) |
|
1915 | - $_POST['poll_hide'] = 1; |
|
2022 | + elseif (empty($_POST['poll_expire']) && $_POST['poll_hide'] == 2) { |
|
2023 | + $_POST['poll_hide'] = 1; |
|
2024 | + } |
|
1916 | 2025 | |
1917 | 2026 | // Clean up the question and answers. |
1918 | 2027 | $_POST['question'] = $smcFunc['htmlspecialchars']($_POST['question']); |
@@ -1926,13 +2035,15 @@ discard block |
||
1926 | 2035 | { |
1927 | 2036 | $attachIDs = array(); |
1928 | 2037 | $attach_errors = array(); |
1929 | - if (!empty($context['we_are_history'])) |
|
1930 | - $attach_errors[] = '<dd>' . $txt['error_temp_attachments_flushed'] . '<br><br></dd>'; |
|
2038 | + if (!empty($context['we_are_history'])) { |
|
2039 | + $attach_errors[] = '<dd>' . $txt['error_temp_attachments_flushed'] . '<br><br></dd>'; |
|
2040 | + } |
|
1931 | 2041 | |
1932 | 2042 | foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
1933 | 2043 | { |
1934 | - if ($attachID != 'initial_error' && strpos($attachID, 'post_tmp_' . $user_info['id']) === false) |
|
1935 | - continue; |
|
2044 | + if ($attachID != 'initial_error' && strpos($attachID, 'post_tmp_' . $user_info['id']) === false) { |
|
2045 | + continue; |
|
2046 | + } |
|
1936 | 2047 | |
1937 | 2048 | // If there was an initial error just show that message. |
1938 | 2049 | if ($attachID == 'initial_error') |
@@ -1961,12 +2072,13 @@ discard block |
||
1961 | 2072 | if (createAttachment($attachmentOptions)) |
1962 | 2073 | { |
1963 | 2074 | $attachIDs[] = $attachmentOptions['id']; |
1964 | - if (!empty($attachmentOptions['thumb'])) |
|
1965 | - $attachIDs[] = $attachmentOptions['thumb']; |
|
2075 | + if (!empty($attachmentOptions['thumb'])) { |
|
2076 | + $attachIDs[] = $attachmentOptions['thumb']; |
|
2077 | + } |
|
1966 | 2078 | } |
2079 | + } else { |
|
2080 | + $attach_errors[] = '<dt> </dt>'; |
|
1967 | 2081 | } |
1968 | - else |
|
1969 | - $attach_errors[] = '<dt> </dt>'; |
|
1970 | 2082 | |
1971 | 2083 | if (!empty($attachmentOptions['errors'])) |
1972 | 2084 | { |
@@ -1978,14 +2090,16 @@ discard block |
||
1978 | 2090 | if (!is_array($error)) |
1979 | 2091 | { |
1980 | 2092 | $attach_errors[] = '<dd>' . $txt[$error] . '</dd>'; |
1981 | - if (in_array($error, $log_these)) |
|
1982 | - log_error($attachment['name'] . ': ' . $txt[$error], 'critical'); |
|
2093 | + if (in_array($error, $log_these)) { |
|
2094 | + log_error($attachment['name'] . ': ' . $txt[$error], 'critical'); |
|
2095 | + } |
|
2096 | + } else { |
|
2097 | + $attach_errors[] = '<dd>' . vsprintf($txt[$error[0]], $error[1]) . '</dd>'; |
|
1983 | 2098 | } |
1984 | - else |
|
1985 | - $attach_errors[] = '<dd>' . vsprintf($txt[$error[0]], $error[1]) . '</dd>'; |
|
1986 | 2099 | } |
1987 | - if (file_exists($attachment['tmp_name'])) |
|
1988 | - unlink($attachment['tmp_name']); |
|
2100 | + if (file_exists($attachment['tmp_name'])) { |
|
2101 | + unlink($attachment['tmp_name']); |
|
2102 | + } |
|
1989 | 2103 | } |
1990 | 2104 | } |
1991 | 2105 | unset($_SESSION['temp_attachments']); |
@@ -2026,24 +2140,24 @@ discard block |
||
2026 | 2140 | ); |
2027 | 2141 | |
2028 | 2142 | call_integration_hook('integrate_poll_add_edit', array($id_poll, false)); |
2143 | + } else { |
|
2144 | + $id_poll = 0; |
|
2029 | 2145 | } |
2030 | - else |
|
2031 | - $id_poll = 0; |
|
2032 | 2146 | |
2033 | 2147 | // Creating a new topic? |
2034 | 2148 | $newTopic = empty($_REQUEST['msg']) && empty($topic); |
2035 | 2149 | |
2036 | 2150 | // Check the icon. |
2037 | - if (!isset($_POST['icon'])) |
|
2038 | - $_POST['icon'] = 'xx'; |
|
2039 | - |
|
2040 | - else |
|
2151 | + if (!isset($_POST['icon'])) { |
|
2152 | + $_POST['icon'] = 'xx'; |
|
2153 | + } else |
|
2041 | 2154 | { |
2042 | 2155 | $_POST['icon'] = $smcFunc['htmlspecialchars']($_POST['icon']); |
2043 | 2156 | |
2044 | 2157 | // Need to figure it out if this is a valid icon name. |
2045 | - if ((!file_exists($settings['theme_dir'] . '/images/post/' . $_POST['icon'] . '.png')) && (!file_exists($settings['default_theme_dir'] . '/images/post/' . $_POST['icon'] . '.png'))) |
|
2046 | - $_POST['icon'] = 'xx'; |
|
2158 | + if ((!file_exists($settings['theme_dir'] . '/images/post/' . $_POST['icon'] . '.png')) && (!file_exists($settings['default_theme_dir'] . '/images/post/' . $_POST['icon'] . '.png'))) { |
|
2159 | + $_POST['icon'] = 'xx'; |
|
2160 | + } |
|
2047 | 2161 | } |
2048 | 2162 | |
2049 | 2163 | // Collect all parameters for the creation or modification of a post. |
@@ -2084,8 +2198,9 @@ discard block |
||
2084 | 2198 | } |
2085 | 2199 | |
2086 | 2200 | // This will save some time... |
2087 | - if (empty($approve_has_changed)) |
|
2088 | - unset($msgOptions['approved']); |
|
2201 | + if (empty($approve_has_changed)) { |
|
2202 | + unset($msgOptions['approved']); |
|
2203 | + } |
|
2089 | 2204 | |
2090 | 2205 | modifyPost($msgOptions, $topicOptions, $posterOptions); |
2091 | 2206 | } |
@@ -2094,8 +2209,9 @@ discard block |
||
2094 | 2209 | { |
2095 | 2210 | createPost($msgOptions, $topicOptions, $posterOptions); |
2096 | 2211 | |
2097 | - if (isset($topicOptions['id'])) |
|
2098 | - $topic = $topicOptions['id']; |
|
2212 | + if (isset($topicOptions['id'])) { |
|
2213 | + $topic = $topicOptions['id']; |
|
2214 | + } |
|
2099 | 2215 | } |
2100 | 2216 | |
2101 | 2217 | // Assign the previously uploaded attachments to the brand new message. |
@@ -2107,8 +2223,9 @@ discard block |
||
2107 | 2223 | } |
2108 | 2224 | |
2109 | 2225 | // If we had a draft for this, its time to remove it since it was just posted |
2110 | - if (!empty($modSettings['drafts_post_enabled']) && !empty($_POST['id_draft'])) |
|
2111 | - DeleteDraft($_POST['id_draft']); |
|
2226 | + if (!empty($modSettings['drafts_post_enabled']) && !empty($_POST['id_draft'])) { |
|
2227 | + DeleteDraft($_POST['id_draft']); |
|
2228 | + } |
|
2112 | 2229 | |
2113 | 2230 | // Editing or posting an event? |
2114 | 2231 | if (isset($_POST['calendar']) && (!isset($_REQUEST['eventid']) || $_REQUEST['eventid'] == -1)) |
@@ -2127,8 +2244,7 @@ discard block |
||
2127 | 2244 | 'member' => $user_info['id'], |
2128 | 2245 | ); |
2129 | 2246 | insertEvent($eventOptions); |
2130 | - } |
|
2131 | - elseif (isset($_POST['calendar'])) |
|
2247 | + } elseif (isset($_POST['calendar'])) |
|
2132 | 2248 | { |
2133 | 2249 | $_REQUEST['eventid'] = (int) $_REQUEST['eventid']; |
2134 | 2250 | |
@@ -2156,14 +2272,15 @@ discard block |
||
2156 | 2272 | } |
2157 | 2273 | |
2158 | 2274 | // Delete it? |
2159 | - if (isset($_REQUEST['deleteevent'])) |
|
2160 | - $smcFunc['db_query']('', ' |
|
2275 | + if (isset($_REQUEST['deleteevent'])) { |
|
2276 | + $smcFunc['db_query']('', ' |
|
2161 | 2277 | DELETE FROM {db_prefix}calendar |
2162 | 2278 | WHERE id_event = {int:id_event}', |
2163 | 2279 | array( |
2164 | 2280 | 'id_event' => $_REQUEST['eventid'], |
2165 | 2281 | ) |
2166 | 2282 | ); |
2283 | + } |
|
2167 | 2284 | // ... or just update it? |
2168 | 2285 | else |
2169 | 2286 | { |
@@ -2205,9 +2322,8 @@ discard block |
||
2205 | 2322 | array($user_info['id'], $topic, 0), |
2206 | 2323 | array('id_member', 'id_topic', 'id_board') |
2207 | 2324 | ); |
2208 | - } |
|
2209 | - elseif (!$newTopic) |
|
2210 | - $smcFunc['db_query']('', ' |
|
2325 | + } elseif (!$newTopic) { |
|
2326 | + $smcFunc['db_query']('', ' |
|
2211 | 2327 | DELETE FROM {db_prefix}log_notify |
2212 | 2328 | WHERE id_member = {int:current_member} |
2213 | 2329 | AND id_topic = {int:current_topic}', |
@@ -2216,16 +2332,20 @@ discard block |
||
2216 | 2332 | 'current_topic' => $topic, |
2217 | 2333 | ) |
2218 | 2334 | ); |
2335 | + } |
|
2219 | 2336 | |
2220 | 2337 | // Log an act of moderation - modifying. |
2221 | - if (!empty($moderationAction)) |
|
2222 | - logAction('modify', array('topic' => $topic, 'message' => (int) $_REQUEST['msg'], 'member' => $row['id_member'], 'board' => $board)); |
|
2338 | + if (!empty($moderationAction)) { |
|
2339 | + logAction('modify', array('topic' => $topic, 'message' => (int) $_REQUEST['msg'], 'member' => $row['id_member'], 'board' => $board)); |
|
2340 | + } |
|
2223 | 2341 | |
2224 | - if (isset($_POST['lock']) && $_POST['lock'] != 2) |
|
2225 | - logAction(empty($_POST['lock']) ? 'unlock' : 'lock', array('topic' => $topicOptions['id'], 'board' => $topicOptions['board'])); |
|
2342 | + if (isset($_POST['lock']) && $_POST['lock'] != 2) { |
|
2343 | + logAction(empty($_POST['lock']) ? 'unlock' : 'lock', array('topic' => $topicOptions['id'], 'board' => $topicOptions['board'])); |
|
2344 | + } |
|
2226 | 2345 | |
2227 | - if (isset($_POST['sticky'])) |
|
2228 | - logAction(empty($_POST['sticky']) ? 'unsticky' : 'sticky', array('topic' => $topicOptions['id'], 'board' => $topicOptions['board'])); |
|
2346 | + if (isset($_POST['sticky'])) { |
|
2347 | + logAction(empty($_POST['sticky']) ? 'unsticky' : 'sticky', array('topic' => $topicOptions['id'], 'board' => $topicOptions['board'])); |
|
2348 | + } |
|
2229 | 2349 | |
2230 | 2350 | // Returning to the topic? |
2231 | 2351 | if (!empty($_REQUEST['goback'])) |
@@ -2244,26 +2364,31 @@ discard block |
||
2244 | 2364 | ); |
2245 | 2365 | } |
2246 | 2366 | |
2247 | - if ($board_info['num_topics'] == 0) |
|
2248 | - cache_put_data('board-' . $board, null, 120); |
|
2367 | + if ($board_info['num_topics'] == 0) { |
|
2368 | + cache_put_data('board-' . $board, null, 120); |
|
2369 | + } |
|
2249 | 2370 | |
2250 | 2371 | call_integration_hook('integrate_post2_end'); |
2251 | 2372 | |
2252 | - if (!empty($_POST['announce_topic'])) |
|
2253 | - redirectexit('action=announce;sa=selectgroup;topic=' . $topic . (!empty($_POST['move']) && allowedTo('move_any') ? ';move' : '') . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
2373 | + if (!empty($_POST['announce_topic'])) { |
|
2374 | + redirectexit('action=announce;sa=selectgroup;topic=' . $topic . (!empty($_POST['move']) && allowedTo('move_any') ? ';move' : '') . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
2375 | + } |
|
2254 | 2376 | |
2255 | - if (!empty($_POST['move']) && allowedTo('move_any')) |
|
2256 | - redirectexit('action=movetopic;topic=' . $topic . '.0' . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
2377 | + if (!empty($_POST['move']) && allowedTo('move_any')) { |
|
2378 | + redirectexit('action=movetopic;topic=' . $topic . '.0' . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
2379 | + } |
|
2257 | 2380 | |
2258 | 2381 | // Return to post if the mod is on. |
2259 | - if (isset($_REQUEST['msg']) && !empty($_REQUEST['goback'])) |
|
2260 | - redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg'], isBrowser('ie')); |
|
2261 | - elseif (!empty($_REQUEST['goback'])) |
|
2262 | - redirectexit('topic=' . $topic . '.new#new', isBrowser('ie')); |
|
2382 | + if (isset($_REQUEST['msg']) && !empty($_REQUEST['goback'])) { |
|
2383 | + redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg'], isBrowser('ie')); |
|
2384 | + } elseif (!empty($_REQUEST['goback'])) { |
|
2385 | + redirectexit('topic=' . $topic . '.new#new', isBrowser('ie')); |
|
2386 | + } |
|
2263 | 2387 | // Dut-dut-duh-duh-DUH-duh-dut-duh-duh! *dances to the Final Fantasy Fanfare...* |
2264 | - else |
|
2265 | - redirectexit('board=' . $board . '.0'); |
|
2266 | -} |
|
2388 | + else { |
|
2389 | + redirectexit('board=' . $board . '.0'); |
|
2390 | + } |
|
2391 | + } |
|
2267 | 2392 | |
2268 | 2393 | /** |
2269 | 2394 | * Handle the announce topic function (action=announce). |
@@ -2281,8 +2406,9 @@ discard block |
||
2281 | 2406 | |
2282 | 2407 | validateSession(); |
2283 | 2408 | |
2284 | - if (empty($topic)) |
|
2285 | - fatal_lang_error('topic_gone', false); |
|
2409 | + if (empty($topic)) { |
|
2410 | + fatal_lang_error('topic_gone', false); |
|
2411 | + } |
|
2286 | 2412 | |
2287 | 2413 | loadLanguage('Post'); |
2288 | 2414 | loadTemplate('Post'); |
@@ -2309,8 +2435,9 @@ discard block |
||
2309 | 2435 | global $txt, $context, $topic, $board_info, $smcFunc; |
2310 | 2436 | |
2311 | 2437 | $groups = array_merge($board_info['groups'], array(1)); |
2312 | - foreach ($groups as $id => $group) |
|
2313 | - $groups[$id] = (int) $group; |
|
2438 | + foreach ($groups as $id => $group) { |
|
2439 | + $groups[$id] = (int) $group; |
|
2440 | + } |
|
2314 | 2441 | |
2315 | 2442 | $context['groups'] = array(); |
2316 | 2443 | if (in_array(0, $groups)) |
@@ -2353,8 +2480,9 @@ discard block |
||
2353 | 2480 | 'group_list' => $groups, |
2354 | 2481 | ) |
2355 | 2482 | ); |
2356 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
2357 | - $context['groups'][$row['id_group']]['name'] = $row['group_name']; |
|
2483 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2484 | + $context['groups'][$row['id_group']]['name'] = $row['group_name']; |
|
2485 | + } |
|
2358 | 2486 | $smcFunc['db_free_result']($request); |
2359 | 2487 | |
2360 | 2488 | // Get the subject of the topic we're about to announce. |
@@ -2396,16 +2524,19 @@ discard block |
||
2396 | 2524 | $context['start'] = empty($_REQUEST['start']) ? 0 : (int) $_REQUEST['start']; |
2397 | 2525 | $groups = array_merge($board_info['groups'], array(1)); |
2398 | 2526 | |
2399 | - if (isset($_POST['membergroups'])) |
|
2400 | - $_POST['who'] = explode(',', $_POST['membergroups']); |
|
2527 | + if (isset($_POST['membergroups'])) { |
|
2528 | + $_POST['who'] = explode(',', $_POST['membergroups']); |
|
2529 | + } |
|
2401 | 2530 | |
2402 | 2531 | // Check whether at least one membergroup was selected. |
2403 | - if (empty($_POST['who'])) |
|
2404 | - fatal_lang_error('no_membergroup_selected'); |
|
2532 | + if (empty($_POST['who'])) { |
|
2533 | + fatal_lang_error('no_membergroup_selected'); |
|
2534 | + } |
|
2405 | 2535 | |
2406 | 2536 | // Make sure all membergroups are integers and can access the board of the announcement. |
2407 | - foreach ($_POST['who'] as $id => $mg) |
|
2408 | - $_POST['who'][$id] = in_array((int) $mg, $groups) ? (int) $mg : 0; |
|
2537 | + foreach ($_POST['who'] as $id => $mg) { |
|
2538 | + $_POST['who'][$id] = in_array((int) $mg, $groups) ? (int) $mg : 0; |
|
2539 | + } |
|
2409 | 2540 | |
2410 | 2541 | // Get the topic subject and censor it. |
2411 | 2542 | $request = $smcFunc['db_query']('', ' |
@@ -2451,12 +2582,13 @@ discard block |
||
2451 | 2582 | if ($smcFunc['db_num_rows']($request) == 0) |
2452 | 2583 | { |
2453 | 2584 | logAction('announce_topic', array('topic' => $topic), 'user'); |
2454 | - if (!empty($_REQUEST['move']) && allowedTo('move_any')) |
|
2455 | - redirectexit('action=movetopic;topic=' . $topic . '.0' . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
2456 | - elseif (!empty($_REQUEST['goback'])) |
|
2457 | - redirectexit('topic=' . $topic . '.new;boardseen#new', isBrowser('ie')); |
|
2458 | - else |
|
2459 | - redirectexit('board=' . $board . '.0'); |
|
2585 | + if (!empty($_REQUEST['move']) && allowedTo('move_any')) { |
|
2586 | + redirectexit('action=movetopic;topic=' . $topic . '.0' . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
2587 | + } elseif (!empty($_REQUEST['goback'])) { |
|
2588 | + redirectexit('topic=' . $topic . '.new;boardseen#new', isBrowser('ie')); |
|
2589 | + } else { |
|
2590 | + redirectexit('board=' . $board . '.0'); |
|
2591 | + } |
|
2460 | 2592 | } |
2461 | 2593 | |
2462 | 2594 | $announcements = array(); |
@@ -2475,8 +2607,9 @@ discard block |
||
2475 | 2607 | foreach ($rows as $row) |
2476 | 2608 | { |
2477 | 2609 | // Force them to have it? |
2478 | - if (empty($prefs[$row['id_member']]['announcements'])) |
|
2479 | - continue; |
|
2610 | + if (empty($prefs[$row['id_member']]['announcements'])) { |
|
2611 | + continue; |
|
2612 | + } |
|
2480 | 2613 | |
2481 | 2614 | $cur_language = empty($row['lngfile']) || empty($modSettings['userLanguage']) ? $language : $row['lngfile']; |
2482 | 2615 | |
@@ -2504,8 +2637,9 @@ discard block |
||
2504 | 2637 | } |
2505 | 2638 | |
2506 | 2639 | // For each language send a different mail - low priority... |
2507 | - foreach ($announcements as $lang => $mail) |
|
2508 | - sendmail($mail['recipients'], $mail['subject'], $mail['body'], null, 'ann-' . $lang, $mail['is_html'], 5); |
|
2640 | + foreach ($announcements as $lang => $mail) { |
|
2641 | + sendmail($mail['recipients'], $mail['subject'], $mail['body'], null, 'ann-' . $lang, $mail['is_html'], 5); |
|
2642 | + } |
|
2509 | 2643 | |
2510 | 2644 | $context['percentage_done'] = round(100 * $context['start'] / $modSettings['latestMember'], 1); |
2511 | 2645 | |
@@ -2515,9 +2649,10 @@ discard block |
||
2515 | 2649 | $context['sub_template'] = 'announcement_send'; |
2516 | 2650 | |
2517 | 2651 | // Go back to the correct language for the user ;). |
2518 | - if (!empty($modSettings['userLanguage'])) |
|
2519 | - loadLanguage('Post'); |
|
2520 | -} |
|
2652 | + if (!empty($modSettings['userLanguage'])) { |
|
2653 | + loadLanguage('Post'); |
|
2654 | + } |
|
2655 | + } |
|
2521 | 2656 | |
2522 | 2657 | /** |
2523 | 2658 | * Get the topic for display purposes. |
@@ -2530,12 +2665,13 @@ discard block |
||
2530 | 2665 | { |
2531 | 2666 | global $topic, $modSettings, $context, $smcFunc, $counter, $options; |
2532 | 2667 | |
2533 | - if (isset($_REQUEST['xml'])) |
|
2534 | - $limit = ' |
|
2668 | + if (isset($_REQUEST['xml'])) { |
|
2669 | + $limit = ' |
|
2535 | 2670 | LIMIT ' . (empty($context['new_replies']) ? '0' : $context['new_replies']); |
2536 | - else |
|
2537 | - $limit = empty($modSettings['topicSummaryPosts']) ? '' : ' |
|
2671 | + } else { |
|
2672 | + $limit = empty($modSettings['topicSummaryPosts']) ? '' : ' |
|
2538 | 2673 | LIMIT ' . (int) $modSettings['topicSummaryPosts']; |
2674 | + } |
|
2539 | 2675 | |
2540 | 2676 | // If you're modifying, get only those posts before the current one. (otherwise get all.) |
2541 | 2677 | $request = $smcFunc['db_query']('', ' |
@@ -2573,8 +2709,9 @@ discard block |
||
2573 | 2709 | 'is_ignored' => !empty($modSettings['enable_buddylist']) && !empty($options['posts_apply_ignore_list']) && in_array($row['id_member'], $context['user']['ignoreusers']), |
2574 | 2710 | ); |
2575 | 2711 | |
2576 | - if (!empty($context['new_replies'])) |
|
2577 | - $context['new_replies']--; |
|
2712 | + if (!empty($context['new_replies'])) { |
|
2713 | + $context['new_replies']--; |
|
2714 | + } |
|
2578 | 2715 | } |
2579 | 2716 | $smcFunc['db_free_result']($request); |
2580 | 2717 | } |
@@ -2591,8 +2728,9 @@ discard block |
||
2591 | 2728 | global $sourcedir, $smcFunc; |
2592 | 2729 | |
2593 | 2730 | loadLanguage('Post'); |
2594 | - if (!isset($_REQUEST['xml'])) |
|
2595 | - loadTemplate('Post'); |
|
2731 | + if (!isset($_REQUEST['xml'])) { |
|
2732 | + loadTemplate('Post'); |
|
2733 | + } |
|
2596 | 2734 | |
2597 | 2735 | include_once($sourcedir . '/Subs-Post.php'); |
2598 | 2736 | |
@@ -2623,8 +2761,9 @@ discard block |
||
2623 | 2761 | $smcFunc['db_free_result']($request); |
2624 | 2762 | |
2625 | 2763 | $context['sub_template'] = 'quotefast'; |
2626 | - if (!empty($row)) |
|
2627 | - $can_view_post = $row['approved'] || ($row['id_member'] != 0 && $row['id_member'] == $user_info['id']) || allowedTo('approve_posts', $row['id_board']); |
|
2764 | + if (!empty($row)) { |
|
2765 | + $can_view_post = $row['approved'] || ($row['id_member'] != 0 && $row['id_member'] == $user_info['id']) || allowedTo('approve_posts', $row['id_board']); |
|
2766 | + } |
|
2628 | 2767 | |
2629 | 2768 | if (!empty($can_view_post)) |
2630 | 2769 | { |
@@ -2657,8 +2796,9 @@ discard block |
||
2657 | 2796 | } |
2658 | 2797 | |
2659 | 2798 | // Remove any nested quotes. |
2660 | - if (!empty($modSettings['removeNestedQuotes'])) |
|
2661 | - $row['body'] = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $row['body']); |
|
2799 | + if (!empty($modSettings['removeNestedQuotes'])) { |
|
2800 | + $row['body'] = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $row['body']); |
|
2801 | + } |
|
2662 | 2802 | |
2663 | 2803 | $lb = "\n"; |
2664 | 2804 | |
@@ -2684,14 +2824,14 @@ discard block |
||
2684 | 2824 | 'time' => '', |
2685 | 2825 | ), |
2686 | 2826 | ); |
2687 | - } |
|
2688 | - else |
|
2689 | - $context['quote'] = array( |
|
2827 | + } else { |
|
2828 | + $context['quote'] = array( |
|
2690 | 2829 | 'xml' => '', |
2691 | 2830 | 'mozilla' => '', |
2692 | 2831 | 'text' => '', |
2693 | 2832 | ); |
2694 | -} |
|
2833 | + } |
|
2834 | + } |
|
2695 | 2835 | |
2696 | 2836 | /** |
2697 | 2837 | * Used to edit the body or subject of a message inline |
@@ -2703,8 +2843,9 @@ discard block |
||
2703 | 2843 | global $user_info, $context, $smcFunc, $language, $board_info; |
2704 | 2844 | |
2705 | 2845 | // We have to have a topic! |
2706 | - if (empty($topic)) |
|
2707 | - obExit(false); |
|
2846 | + if (empty($topic)) { |
|
2847 | + obExit(false); |
|
2848 | + } |
|
2708 | 2849 | |
2709 | 2850 | checkSession('get'); |
2710 | 2851 | require_once($sourcedir . '/Subs-Post.php'); |
@@ -2730,31 +2871,35 @@ discard block |
||
2730 | 2871 | 'guest_id' => 0, |
2731 | 2872 | ) |
2732 | 2873 | ); |
2733 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
2734 | - fatal_lang_error('no_board', false); |
|
2874 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
2875 | + fatal_lang_error('no_board', false); |
|
2876 | + } |
|
2735 | 2877 | $row = $smcFunc['db_fetch_assoc']($request); |
2736 | 2878 | $smcFunc['db_free_result']($request); |
2737 | 2879 | |
2738 | 2880 | // Change either body or subject requires permissions to modify messages. |
2739 | 2881 | if (isset($_POST['message']) || isset($_POST['subject']) || isset($_REQUEST['icon'])) |
2740 | 2882 | { |
2741 | - if (!empty($row['locked'])) |
|
2742 | - isAllowedTo('moderate_board'); |
|
2883 | + if (!empty($row['locked'])) { |
|
2884 | + isAllowedTo('moderate_board'); |
|
2885 | + } |
|
2743 | 2886 | |
2744 | 2887 | if ($row['id_member'] == $user_info['id'] && !allowedTo('modify_any')) |
2745 | 2888 | { |
2746 | - if ((!$modSettings['postmod_active'] || $row['approved']) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) |
|
2747 | - fatal_lang_error('modify_post_time_passed', false); |
|
2748 | - elseif ($row['id_member_started'] == $user_info['id'] && !allowedTo('modify_own')) |
|
2749 | - isAllowedTo('modify_replies'); |
|
2750 | - else |
|
2751 | - isAllowedTo('modify_own'); |
|
2889 | + if ((!$modSettings['postmod_active'] || $row['approved']) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) { |
|
2890 | + fatal_lang_error('modify_post_time_passed', false); |
|
2891 | + } elseif ($row['id_member_started'] == $user_info['id'] && !allowedTo('modify_own')) { |
|
2892 | + isAllowedTo('modify_replies'); |
|
2893 | + } else { |
|
2894 | + isAllowedTo('modify_own'); |
|
2895 | + } |
|
2752 | 2896 | } |
2753 | 2897 | // Otherwise, they're locked out; someone who can modify the replies is needed. |
2754 | - elseif ($row['id_member_started'] == $user_info['id'] && !allowedTo('modify_any')) |
|
2755 | - isAllowedTo('modify_replies'); |
|
2756 | - else |
|
2757 | - isAllowedTo('modify_any'); |
|
2898 | + elseif ($row['id_member_started'] == $user_info['id'] && !allowedTo('modify_any')) { |
|
2899 | + isAllowedTo('modify_replies'); |
|
2900 | + } else { |
|
2901 | + isAllowedTo('modify_any'); |
|
2902 | + } |
|
2758 | 2903 | |
2759 | 2904 | // Only log this action if it wasn't your message. |
2760 | 2905 | $moderationAction = $row['id_member'] != $user_info['id']; |
@@ -2766,10 +2911,10 @@ discard block |
||
2766 | 2911 | $_POST['subject'] = strtr($smcFunc['htmlspecialchars']($_POST['subject']), array("\r" => '', "\n" => '', "\t" => '')); |
2767 | 2912 | |
2768 | 2913 | // Maximum number of characters. |
2769 | - if ($smcFunc['strlen']($_POST['subject']) > 100) |
|
2770 | - $_POST['subject'] = $smcFunc['substr']($_POST['subject'], 0, 100); |
|
2771 | - } |
|
2772 | - elseif (isset($_POST['subject'])) |
|
2914 | + if ($smcFunc['strlen']($_POST['subject']) > 100) { |
|
2915 | + $_POST['subject'] = $smcFunc['substr']($_POST['subject'], 0, 100); |
|
2916 | + } |
|
2917 | + } elseif (isset($_POST['subject'])) |
|
2773 | 2918 | { |
2774 | 2919 | $post_errors[] = 'no_subject'; |
2775 | 2920 | unset($_POST['subject']); |
@@ -2781,13 +2926,11 @@ discard block |
||
2781 | 2926 | { |
2782 | 2927 | $post_errors[] = 'no_message'; |
2783 | 2928 | unset($_POST['message']); |
2784 | - } |
|
2785 | - elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_POST['message']) > $modSettings['max_messageLength']) |
|
2929 | + } elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_POST['message']) > $modSettings['max_messageLength']) |
|
2786 | 2930 | { |
2787 | 2931 | $post_errors[] = 'long_message'; |
2788 | 2932 | unset($_POST['message']); |
2789 | - } |
|
2790 | - else |
|
2933 | + } else |
|
2791 | 2934 | { |
2792 | 2935 | $_POST['message'] = $smcFunc['htmlspecialchars']($_POST['message'], ENT_QUOTES); |
2793 | 2936 | |
@@ -2803,31 +2946,34 @@ discard block |
||
2803 | 2946 | |
2804 | 2947 | if (isset($_POST['lock'])) |
2805 | 2948 | { |
2806 | - if (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $row['id_member'])) |
|
2807 | - unset($_POST['lock']); |
|
2808 | - elseif (!allowedTo('lock_any')) |
|
2949 | + if (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $row['id_member'])) { |
|
2950 | + unset($_POST['lock']); |
|
2951 | + } elseif (!allowedTo('lock_any')) |
|
2809 | 2952 | { |
2810 | - if ($row['locked'] == 1) |
|
2811 | - unset($_POST['lock']); |
|
2812 | - else |
|
2813 | - $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
2953 | + if ($row['locked'] == 1) { |
|
2954 | + unset($_POST['lock']); |
|
2955 | + } else { |
|
2956 | + $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
2957 | + } |
|
2958 | + } elseif (!empty($row['locked']) && !empty($_POST['lock']) || $_POST['lock'] == $row['locked']) { |
|
2959 | + unset($_POST['lock']); |
|
2960 | + } else { |
|
2961 | + $_POST['lock'] = empty($_POST['lock']) ? 0 : 1; |
|
2814 | 2962 | } |
2815 | - elseif (!empty($row['locked']) && !empty($_POST['lock']) || $_POST['lock'] == $row['locked']) |
|
2816 | - unset($_POST['lock']); |
|
2817 | - else |
|
2818 | - $_POST['lock'] = empty($_POST['lock']) ? 0 : 1; |
|
2819 | 2963 | } |
2820 | 2964 | |
2821 | - if (isset($_POST['sticky']) && !allowedTo('make_sticky')) |
|
2822 | - unset($_POST['sticky']); |
|
2965 | + if (isset($_POST['sticky']) && !allowedTo('make_sticky')) { |
|
2966 | + unset($_POST['sticky']); |
|
2967 | + } |
|
2823 | 2968 | |
2824 | 2969 | if (isset($_POST['modify_reason'])) |
2825 | 2970 | { |
2826 | 2971 | $_POST['modify_reason'] = strtr($smcFunc['htmlspecialchars']($_POST['modify_reason']), array("\r" => '', "\n" => '', "\t" => '')); |
2827 | 2972 | |
2828 | 2973 | // Maximum number of characters. |
2829 | - if ($smcFunc['strlen']($_POST['modify_reason']) > 100) |
|
2830 | - $_POST['modify_reason'] = $smcFunc['substr']($_POST['modify_reason'], 0, 100); |
|
2974 | + if ($smcFunc['strlen']($_POST['modify_reason']) > 100) { |
|
2975 | + $_POST['modify_reason'] = $smcFunc['substr']($_POST['modify_reason'], 0, 100); |
|
2976 | + } |
|
2831 | 2977 | } |
2832 | 2978 | |
2833 | 2979 | if (empty($post_errors)) |
@@ -2864,8 +3010,9 @@ discard block |
||
2864 | 3010 | } |
2865 | 3011 | } |
2866 | 3012 | // If nothing was changed there's no need to add an entry to the moderation log. |
2867 | - else |
|
2868 | - $moderationAction = false; |
|
3013 | + else { |
|
3014 | + $moderationAction = false; |
|
3015 | + } |
|
2869 | 3016 | |
2870 | 3017 | modifyPost($msgOptions, $topicOptions, $posterOptions); |
2871 | 3018 | |
@@ -2883,9 +3030,9 @@ discard block |
||
2883 | 3030 | // Get the proper (default language) response prefix first. |
2884 | 3031 | if (!isset($context['response_prefix']) && !($context['response_prefix'] = cache_get_data('response_prefix'))) |
2885 | 3032 | { |
2886 | - if ($language === $user_info['language']) |
|
2887 | - $context['response_prefix'] = $txt['response_prefix']; |
|
2888 | - else |
|
3033 | + if ($language === $user_info['language']) { |
|
3034 | + $context['response_prefix'] = $txt['response_prefix']; |
|
3035 | + } else |
|
2889 | 3036 | { |
2890 | 3037 | loadLanguage('index', $language, false); |
2891 | 3038 | $context['response_prefix'] = $txt['response_prefix']; |
@@ -2907,8 +3054,9 @@ discard block |
||
2907 | 3054 | ); |
2908 | 3055 | } |
2909 | 3056 | |
2910 | - if (!empty($moderationAction)) |
|
2911 | - logAction('modify', array('topic' => $topic, 'message' => $row['id_msg'], 'member' => $row['id_member'], 'board' => $board)); |
|
3057 | + if (!empty($moderationAction)) { |
|
3058 | + logAction('modify', array('topic' => $topic, 'message' => $row['id_msg'], 'member' => $row['id_member'], 'board' => $board)); |
|
3059 | + } |
|
2912 | 3060 | } |
2913 | 3061 | |
2914 | 3062 | if (isset($_REQUEST['xml'])) |
@@ -2949,8 +3097,7 @@ discard block |
||
2949 | 3097 | ); |
2950 | 3098 | |
2951 | 3099 | censorText($context['message']['subject']); |
2952 | - } |
|
2953 | - else |
|
3100 | + } else |
|
2954 | 3101 | { |
2955 | 3102 | $context['message'] = array( |
2956 | 3103 | 'id' => $row['id_msg'], |
@@ -2962,15 +3109,16 @@ discard block |
||
2962 | 3109 | loadLanguage('Errors'); |
2963 | 3110 | foreach ($post_errors as $post_error) |
2964 | 3111 | { |
2965 | - if ($post_error == 'long_message') |
|
2966 | - $context['message']['errors'][] = sprintf($txt['error_' . $post_error], $modSettings['max_messageLength']); |
|
2967 | - else |
|
2968 | - $context['message']['errors'][] = $txt['error_' . $post_error]; |
|
3112 | + if ($post_error == 'long_message') { |
|
3113 | + $context['message']['errors'][] = sprintf($txt['error_' . $post_error], $modSettings['max_messageLength']); |
|
3114 | + } else { |
|
3115 | + $context['message']['errors'][] = $txt['error_' . $post_error]; |
|
3116 | + } |
|
2969 | 3117 | } |
2970 | 3118 | } |
3119 | + } else { |
|
3120 | + obExit(false); |
|
3121 | + } |
|
2971 | 3122 | } |
2972 | - else |
|
2973 | - obExit(false); |
|
2974 | -} |
|
2975 | 3123 | |
2976 | 3124 | ?> |
2977 | 3125 | \ No newline at end of file |
@@ -12,8 +12,9 @@ discard block |
||
12 | 12 | */ |
13 | 13 | |
14 | 14 | // Don't do anything if SMF is already loaded. |
15 | -if (defined('SMF')) |
|
15 | +if (defined('SMF')) { |
|
16 | 16 | return true; |
17 | +} |
|
17 | 18 | |
18 | 19 | define('SMF', 'SSI'); |
19 | 20 | |
@@ -28,16 +29,18 @@ discard block |
||
28 | 29 | $time_start = microtime(true); |
29 | 30 | |
30 | 31 | // Just being safe... |
31 | -foreach (array('db_character_set', 'cachedir') as $variable) |
|
32 | +foreach (array('db_character_set', 'cachedir') as $variable) { |
|
32 | 33 | if (isset($GLOBALS[$variable])) |
33 | 34 | unset($GLOBALS[$variable]); |
35 | +} |
|
34 | 36 | |
35 | 37 | // Get the forum's settings for database and file paths. |
36 | 38 | require_once(dirname(__FILE__) . '/Settings.php'); |
37 | 39 | |
38 | 40 | // Make absolutely sure the cache directory is defined. |
39 | -if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache')) |
|
41 | +if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache')) { |
|
40 | 42 | $cachedir = $boarddir . '/cache'; |
43 | +} |
|
41 | 44 | |
42 | 45 | $ssi_error_reporting = error_reporting(E_ALL); |
43 | 46 | /* Set this to one of three values depending on what you want to happen in the case of a fatal error. |
@@ -48,12 +51,14 @@ discard block |
||
48 | 51 | $ssi_on_error_method = false; |
49 | 52 | |
50 | 53 | // Don't do john didley if the forum's been shut down completely. |
51 | -if ($maintenance == 2 && (!isset($ssi_maintenance_off) || $ssi_maintenance_off !== true)) |
|
54 | +if ($maintenance == 2 && (!isset($ssi_maintenance_off) || $ssi_maintenance_off !== true)) { |
|
52 | 55 | die($mmessage); |
56 | +} |
|
53 | 57 | |
54 | 58 | // Fix for using the current directory as a path. |
55 | -if (substr($sourcedir, 0, 1) == '.' && substr($sourcedir, 1, 1) != '.') |
|
59 | +if (substr($sourcedir, 0, 1) == '.' && substr($sourcedir, 1, 1) != '.') { |
|
56 | 60 | $sourcedir = dirname(__FILE__) . substr($sourcedir, 1); |
61 | +} |
|
57 | 62 | |
58 | 63 | // Load the important includes. |
59 | 64 | require_once($sourcedir . '/QueryString.php'); |
@@ -78,34 +83,38 @@ discard block |
||
78 | 83 | cleanRequest(); |
79 | 84 | |
80 | 85 | // Seed the random generator? |
81 | -if (empty($modSettings['rand_seed']) || mt_rand(1, 250) == 69) |
|
86 | +if (empty($modSettings['rand_seed']) || mt_rand(1, 250) == 69) { |
|
82 | 87 | smf_seed_generator(); |
88 | +} |
|
83 | 89 | |
84 | 90 | // Check on any hacking attempts. |
85 | -if (isset($_REQUEST['GLOBALS']) || isset($_COOKIE['GLOBALS'])) |
|
91 | +if (isset($_REQUEST['GLOBALS']) || isset($_COOKIE['GLOBALS'])) { |
|
86 | 92 | die('No direct access...'); |
87 | -elseif (isset($_REQUEST['ssi_theme']) && (int) $_REQUEST['ssi_theme'] == (int) $ssi_theme) |
|
93 | +} elseif (isset($_REQUEST['ssi_theme']) && (int) $_REQUEST['ssi_theme'] == (int) $ssi_theme) { |
|
88 | 94 | die('No direct access...'); |
89 | -elseif (isset($_COOKIE['ssi_theme']) && (int) $_COOKIE['ssi_theme'] == (int) $ssi_theme) |
|
95 | +} elseif (isset($_COOKIE['ssi_theme']) && (int) $_COOKIE['ssi_theme'] == (int) $ssi_theme) { |
|
90 | 96 | die('No direct access...'); |
91 | -elseif (isset($_REQUEST['ssi_layers'], $ssi_layers) && (@get_magic_quotes_gpc() ? stripslashes($_REQUEST['ssi_layers']) : $_REQUEST['ssi_layers']) == $ssi_layers) |
|
97 | +} elseif (isset($_REQUEST['ssi_layers'], $ssi_layers) && (@get_magic_quotes_gpc() ? stripslashes($_REQUEST['ssi_layers']) : $_REQUEST['ssi_layers']) == $ssi_layers) { |
|
92 | 98 | die('No direct access...'); |
93 | -if (isset($_REQUEST['context'])) |
|
99 | +} |
|
100 | +if (isset($_REQUEST['context'])) { |
|
94 | 101 | die('No direct access...'); |
102 | +} |
|
95 | 103 | |
96 | 104 | // Gzip output? (because it must be boolean and true, this can't be hacked.) |
97 | -if (isset($ssi_gzip) && $ssi_gzip === true && ini_get('zlib.output_compression') != '1' && ini_get('output_handler') != 'ob_gzhandler' && version_compare(PHP_VERSION, '4.2.0', '>=')) |
|
105 | +if (isset($ssi_gzip) && $ssi_gzip === true && ini_get('zlib.output_compression') != '1' && ini_get('output_handler') != 'ob_gzhandler' && version_compare(PHP_VERSION, '4.2.0', '>=')) { |
|
98 | 106 | ob_start('ob_gzhandler'); |
99 | -else |
|
107 | +} else { |
|
100 | 108 | $modSettings['enableCompressedOutput'] = '0'; |
109 | +} |
|
101 | 110 | |
102 | 111 | // Primarily, this is to fix the URLs... |
103 | 112 | ob_start('ob_sessrewrite'); |
104 | 113 | |
105 | 114 | // Start the session... known to scramble SSI includes in cases... |
106 | -if (!headers_sent()) |
|
115 | +if (!headers_sent()) { |
|
107 | 116 | loadSession(); |
108 | -else |
|
117 | +} else |
|
109 | 118 | { |
110 | 119 | if (isset($_COOKIE[session_name()]) || isset($_REQUEST[session_name()])) |
111 | 120 | { |
@@ -139,12 +148,14 @@ discard block |
||
139 | 148 | loadTheme(isset($ssi_theme) ? (int) $ssi_theme : 0); |
140 | 149 | |
141 | 150 | // @todo: probably not the best place, but somewhere it should be set... |
142 | -if (!headers_sent()) |
|
151 | +if (!headers_sent()) { |
|
143 | 152 | header('Content-Type: text/html; charset=' . (empty($modSettings['global_character_set']) ? (empty($txt['lang_character_set']) ? 'ISO-8859-1' : $txt['lang_character_set']) : $modSettings['global_character_set'])); |
153 | +} |
|
144 | 154 | |
145 | 155 | // Take care of any banning that needs to be done. |
146 | -if (isset($_REQUEST['ssi_ban']) || (isset($ssi_ban) && $ssi_ban === true)) |
|
156 | +if (isset($_REQUEST['ssi_ban']) || (isset($ssi_ban) && $ssi_ban === true)) { |
|
147 | 157 | is_not_banned(); |
158 | +} |
|
148 | 159 | |
149 | 160 | // Do we allow guests in here? |
150 | 161 | if (empty($ssi_guest_access) && empty($modSettings['allow_guestAccess']) && $user_info['is_guest'] && basename($_SERVER['PHP_SELF']) != 'SSI.php') |
@@ -159,17 +170,19 @@ discard block |
||
159 | 170 | { |
160 | 171 | $context['template_layers'] = $ssi_layers; |
161 | 172 | template_header(); |
162 | -} |
|
163 | -else |
|
173 | +} else { |
|
164 | 174 | setupThemeContext(); |
175 | +} |
|
165 | 176 | |
166 | 177 | // Make sure they didn't muss around with the settings... but only if it's not cli. |
167 | -if (isset($_SERVER['REMOTE_ADDR']) && !isset($_SERVER['is_cli']) && session_id() == '') |
|
178 | +if (isset($_SERVER['REMOTE_ADDR']) && !isset($_SERVER['is_cli']) && session_id() == '') { |
|
168 | 179 | trigger_error($txt['ssi_session_broken'], E_USER_NOTICE); |
180 | +} |
|
169 | 181 | |
170 | 182 | // Without visiting the forum this session variable might not be set on submit. |
171 | -if (!isset($_SESSION['USER_AGENT']) && (!isset($_GET['ssi_function']) || $_GET['ssi_function'] !== 'pollVote')) |
|
183 | +if (!isset($_SESSION['USER_AGENT']) && (!isset($_GET['ssi_function']) || $_GET['ssi_function'] !== 'pollVote')) { |
|
172 | 184 | $_SESSION['USER_AGENT'] = $_SERVER['HTTP_USER_AGENT']; |
185 | +} |
|
173 | 186 | |
174 | 187 | // Have the ability to easily add functions to SSI. |
175 | 188 | call_integration_hook('integrate_SSI'); |
@@ -178,11 +191,13 @@ discard block |
||
178 | 191 | if (basename($_SERVER['PHP_SELF']) == 'SSI.php') |
179 | 192 | { |
180 | 193 | // You shouldn't just access SSI.php directly by URL!! |
181 | - if (!isset($_GET['ssi_function'])) |
|
182 | - die(sprintf($txt['ssi_not_direct'], $user_info['is_admin'] ? '\'' . addslashes(__FILE__) . '\'' : '\'SSI.php\'')); |
|
194 | + if (!isset($_GET['ssi_function'])) { |
|
195 | + die(sprintf($txt['ssi_not_direct'], $user_info['is_admin'] ? '\'' . addslashes(__FILE__) . '\'' : '\'SSI.php\'')); |
|
196 | + } |
|
183 | 197 | // Call a function passed by GET. |
184 | - if (function_exists('ssi_' . $_GET['ssi_function']) && (!empty($modSettings['allow_guestAccess']) || !$user_info['is_guest'])) |
|
185 | - call_user_func('ssi_' . $_GET['ssi_function']); |
|
198 | + if (function_exists('ssi_' . $_GET['ssi_function']) && (!empty($modSettings['allow_guestAccess']) || !$user_info['is_guest'])) { |
|
199 | + call_user_func('ssi_' . $_GET['ssi_function']); |
|
200 | + } |
|
186 | 201 | exit; |
187 | 202 | } |
188 | 203 | |
@@ -199,9 +214,10 @@ discard block |
||
199 | 214 | */ |
200 | 215 | function ssi_shutdown() |
201 | 216 | { |
202 | - if (!isset($_GET['ssi_function']) || $_GET['ssi_function'] != 'shutdown') |
|
203 | - template_footer(); |
|
204 | -} |
|
217 | + if (!isset($_GET['ssi_function']) || $_GET['ssi_function'] != 'shutdown') { |
|
218 | + template_footer(); |
|
219 | + } |
|
220 | + } |
|
205 | 221 | |
206 | 222 | /** |
207 | 223 | * Display a welcome message, like: Hey, User, you have 0 messages, 0 are new. |
@@ -214,15 +230,17 @@ discard block |
||
214 | 230 | |
215 | 231 | if ($output_method == 'echo') |
216 | 232 | { |
217 | - if ($context['user']['is_guest']) |
|
218 | - echo sprintf($txt[$context['can_register'] ? 'welcome_guest_register' : 'welcome_guest'], $txt['guest_title'], $context['forum_name_html_safe'], $scripturl . '?action=login', 'return reqOverlayDiv(this.href, ' . JavaScriptEscape($txt['login']) . ');', $scripturl . '?action=signup'); |
|
219 | - else |
|
220 | - echo $txt['hello_member'], ' <strong>', $context['user']['name'], '</strong>', allowedTo('pm_read') ? ', ' . (empty($context['user']['messages']) ? $txt['msg_alert_no_messages'] : (($context['user']['messages'] == 1 ? sprintf($txt['msg_alert_one_message'], $scripturl . '?action=pm') : sprintf($txt['msg_alert_many_message'], $scripturl . '?action=pm', $context['user']['messages'])) . ', ' . ($context['user']['unread_messages'] == 1 ? $txt['msg_alert_one_new'] : sprintf($txt['msg_alert_many_new'], $context['user']['unread_messages'])))) : ''; |
|
233 | + if ($context['user']['is_guest']) { |
|
234 | + echo sprintf($txt[$context['can_register'] ? 'welcome_guest_register' : 'welcome_guest'], $txt['guest_title'], $context['forum_name_html_safe'], $scripturl . '?action=login', 'return reqOverlayDiv(this.href, ' . JavaScriptEscape($txt['login']) . ');', $scripturl . '?action=signup'); |
|
235 | + } else { |
|
236 | + echo $txt['hello_member'], ' <strong>', $context['user']['name'], '</strong>', allowedTo('pm_read') ? ', ' . (empty($context['user']['messages']) ? $txt['msg_alert_no_messages'] : (($context['user']['messages'] == 1 ? sprintf($txt['msg_alert_one_message'], $scripturl . '?action=pm') : sprintf($txt['msg_alert_many_message'], $scripturl . '?action=pm', $context['user']['messages'])) . ', ' . ($context['user']['unread_messages'] == 1 ? $txt['msg_alert_one_new'] : sprintf($txt['msg_alert_many_new'], $context['user']['unread_messages'])))) : ''; |
|
237 | + } |
|
221 | 238 | } |
222 | 239 | // Don't echo... then do what?! |
223 | - else |
|
224 | - return $context['user']; |
|
225 | -} |
|
240 | + else { |
|
241 | + return $context['user']; |
|
242 | + } |
|
243 | + } |
|
226 | 244 | |
227 | 245 | /** |
228 | 246 | * Display a menu bar, like is displayed at the top of the forum. |
@@ -233,12 +251,14 @@ discard block |
||
233 | 251 | { |
234 | 252 | global $context; |
235 | 253 | |
236 | - if ($output_method == 'echo') |
|
237 | - template_menu(); |
|
254 | + if ($output_method == 'echo') { |
|
255 | + template_menu(); |
|
256 | + } |
|
238 | 257 | // What else could this do? |
239 | - else |
|
240 | - return $context['menu_buttons']; |
|
241 | -} |
|
258 | + else { |
|
259 | + return $context['menu_buttons']; |
|
260 | + } |
|
261 | + } |
|
242 | 262 | |
243 | 263 | /** |
244 | 264 | * Show a logout link. |
@@ -250,20 +270,23 @@ discard block |
||
250 | 270 | { |
251 | 271 | global $context, $txt, $scripturl; |
252 | 272 | |
253 | - if ($redirect_to != '') |
|
254 | - $_SESSION['logout_url'] = $redirect_to; |
|
273 | + if ($redirect_to != '') { |
|
274 | + $_SESSION['logout_url'] = $redirect_to; |
|
275 | + } |
|
255 | 276 | |
256 | 277 | // Guests can't log out. |
257 | - if ($context['user']['is_guest']) |
|
258 | - return false; |
|
278 | + if ($context['user']['is_guest']) { |
|
279 | + return false; |
|
280 | + } |
|
259 | 281 | |
260 | 282 | $link = '<a href="' . $scripturl . '?action=logout;' . $context['session_var'] . '=' . $context['session_id'] . '">' . $txt['logout'] . '</a>'; |
261 | 283 | |
262 | - if ($output_method == 'echo') |
|
263 | - echo $link; |
|
264 | - else |
|
265 | - return $link; |
|
266 | -} |
|
284 | + if ($output_method == 'echo') { |
|
285 | + echo $link; |
|
286 | + } else { |
|
287 | + return $link; |
|
288 | + } |
|
289 | + } |
|
267 | 290 | |
268 | 291 | /** |
269 | 292 | * Recent post list: [board] Subject by Poster Date |
@@ -279,17 +302,17 @@ discard block |
||
279 | 302 | global $modSettings, $context; |
280 | 303 | |
281 | 304 | // Excluding certain boards... |
282 | - if ($exclude_boards === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0) |
|
283 | - $exclude_boards = array($modSettings['recycle_board']); |
|
284 | - else |
|
285 | - $exclude_boards = empty($exclude_boards) ? array() : (is_array($exclude_boards) ? $exclude_boards : array($exclude_boards)); |
|
305 | + if ($exclude_boards === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0) { |
|
306 | + $exclude_boards = array($modSettings['recycle_board']); |
|
307 | + } else { |
|
308 | + $exclude_boards = empty($exclude_boards) ? array() : (is_array($exclude_boards) ? $exclude_boards : array($exclude_boards)); |
|
309 | + } |
|
286 | 310 | |
287 | 311 | // What about including certain boards - note we do some protection here as pre-2.0 didn't have this parameter. |
288 | 312 | if (is_array($include_boards) || (int) $include_boards === $include_boards) |
289 | 313 | { |
290 | 314 | $include_boards = is_array($include_boards) ? $include_boards : array($include_boards); |
291 | - } |
|
292 | - elseif ($include_boards != null) |
|
315 | + } elseif ($include_boards != null) |
|
293 | 316 | { |
294 | 317 | $include_boards = array(); |
295 | 318 | } |
@@ -326,8 +349,9 @@ discard block |
||
326 | 349 | { |
327 | 350 | global $modSettings; |
328 | 351 | |
329 | - if (empty($post_ids)) |
|
330 | - return; |
|
352 | + if (empty($post_ids)) { |
|
353 | + return; |
|
354 | + } |
|
331 | 355 | |
332 | 356 | // Allow the user to request more than one - why not? |
333 | 357 | $post_ids = is_array($post_ids) ? $post_ids : array($post_ids); |
@@ -362,8 +386,9 @@ discard block |
||
362 | 386 | global $scripturl, $txt, $user_info; |
363 | 387 | global $modSettings, $smcFunc, $context; |
364 | 388 | |
365 | - if (!empty($modSettings['enable_likes'])) |
|
366 | - $context['can_like'] = allowedTo('likes_like'); |
|
389 | + if (!empty($modSettings['enable_likes'])) { |
|
390 | + $context['can_like'] = allowedTo('likes_like'); |
|
391 | + } |
|
367 | 392 | |
368 | 393 | // Find all the posts. Newer ones will have higher IDs. |
369 | 394 | $request = $smcFunc['db_query']('substring', ' |
@@ -429,12 +454,13 @@ discard block |
||
429 | 454 | ); |
430 | 455 | |
431 | 456 | // Get the likes for each message. |
432 | - if (!empty($modSettings['enable_likes'])) |
|
433 | - $posts[$row['id_msg']]['likes'] = array( |
|
457 | + if (!empty($modSettings['enable_likes'])) { |
|
458 | + $posts[$row['id_msg']]['likes'] = array( |
|
434 | 459 | 'count' => $row['likes'], |
435 | 460 | 'you' => in_array($row['id_msg'], prepareLikesContext($row['id_topic'])), |
436 | 461 | 'can_like' => !$context['user']['is_guest'] && $row['id_member'] != $context['user']['id'] && !empty($context['can_like']), |
437 | 462 | ); |
463 | + } |
|
438 | 464 | } |
439 | 465 | $smcFunc['db_free_result']($request); |
440 | 466 | |
@@ -442,13 +468,14 @@ discard block |
||
442 | 468 | call_integration_hook('integrate_ssi_queryPosts', array(&$posts)); |
443 | 469 | |
444 | 470 | // Just return it. |
445 | - if ($output_method != 'echo' || empty($posts)) |
|
446 | - return $posts; |
|
471 | + if ($output_method != 'echo' || empty($posts)) { |
|
472 | + return $posts; |
|
473 | + } |
|
447 | 474 | |
448 | 475 | echo ' |
449 | 476 | <table style="border: none" class="ssi_table">'; |
450 | - foreach ($posts as $post) |
|
451 | - echo ' |
|
477 | + foreach ($posts as $post) { |
|
478 | + echo ' |
|
452 | 479 | <tr> |
453 | 480 | <td style="text-align: right; vertical-align: top; white-space: nowrap"> |
454 | 481 | [', $post['board']['link'], '] |
@@ -462,6 +489,7 @@ discard block |
||
462 | 489 | ', $post['time'], ' |
463 | 490 | </td> |
464 | 491 | </tr>'; |
492 | + } |
|
465 | 493 | echo ' |
466 | 494 | </table>'; |
467 | 495 | } |
@@ -479,25 +507,26 @@ discard block |
||
479 | 507 | global $settings, $scripturl, $txt, $user_info; |
480 | 508 | global $modSettings, $smcFunc, $context; |
481 | 509 | |
482 | - if ($exclude_boards === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0) |
|
483 | - $exclude_boards = array($modSettings['recycle_board']); |
|
484 | - else |
|
485 | - $exclude_boards = empty($exclude_boards) ? array() : (is_array($exclude_boards) ? $exclude_boards : array($exclude_boards)); |
|
510 | + if ($exclude_boards === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0) { |
|
511 | + $exclude_boards = array($modSettings['recycle_board']); |
|
512 | + } else { |
|
513 | + $exclude_boards = empty($exclude_boards) ? array() : (is_array($exclude_boards) ? $exclude_boards : array($exclude_boards)); |
|
514 | + } |
|
486 | 515 | |
487 | 516 | // Only some boards?. |
488 | 517 | if (is_array($include_boards) || (int) $include_boards === $include_boards) |
489 | 518 | { |
490 | 519 | $include_boards = is_array($include_boards) ? $include_boards : array($include_boards); |
491 | - } |
|
492 | - elseif ($include_boards != null) |
|
520 | + } elseif ($include_boards != null) |
|
493 | 521 | { |
494 | 522 | $output_method = $include_boards; |
495 | 523 | $include_boards = array(); |
496 | 524 | } |
497 | 525 | |
498 | 526 | $icon_sources = array(); |
499 | - foreach ($context['stable_icons'] as $icon) |
|
500 | - $icon_sources[$icon] = 'images_url'; |
|
527 | + foreach ($context['stable_icons'] as $icon) { |
|
528 | + $icon_sources[$icon] = 'images_url'; |
|
529 | + } |
|
501 | 530 | |
502 | 531 | // Find all the posts in distinct topics. Newer ones will have higher IDs. |
503 | 532 | $request = $smcFunc['db_query']('substring', ' |
@@ -522,13 +551,15 @@ discard block |
||
522 | 551 | ) |
523 | 552 | ); |
524 | 553 | $topics = array(); |
525 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
526 | - $topics[$row['id_topic']] = $row; |
|
554 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
555 | + $topics[$row['id_topic']] = $row; |
|
556 | + } |
|
527 | 557 | $smcFunc['db_free_result']($request); |
528 | 558 | |
529 | 559 | // Did we find anything? If not, bail. |
530 | - if (empty($topics)) |
|
531 | - return array(); |
|
560 | + if (empty($topics)) { |
|
561 | + return array(); |
|
562 | + } |
|
532 | 563 | |
533 | 564 | $recycle_board = !empty($modSettings['recycle_enable']) && !empty($modSettings['recycle_board']) ? (int) $modSettings['recycle_board'] : 0; |
534 | 565 | |
@@ -556,19 +587,22 @@ discard block |
||
556 | 587 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
557 | 588 | { |
558 | 589 | $row['body'] = strip_tags(strtr(parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']), array('<br>' => ' '))); |
559 | - if ($smcFunc['strlen']($row['body']) > 128) |
|
560 | - $row['body'] = $smcFunc['substr']($row['body'], 0, 128) . '...'; |
|
590 | + if ($smcFunc['strlen']($row['body']) > 128) { |
|
591 | + $row['body'] = $smcFunc['substr']($row['body'], 0, 128) . '...'; |
|
592 | + } |
|
561 | 593 | |
562 | 594 | // Censor the subject. |
563 | 595 | censorText($row['subject']); |
564 | 596 | censorText($row['body']); |
565 | 597 | |
566 | 598 | // Recycled icon |
567 | - if (!empty($recycle_board) && $topics[$row['id_topic']]['id_board']) |
|
568 | - $row['icon'] = 'recycled'; |
|
599 | + if (!empty($recycle_board) && $topics[$row['id_topic']]['id_board']) { |
|
600 | + $row['icon'] = 'recycled'; |
|
601 | + } |
|
569 | 602 | |
570 | - if (!empty($modSettings['messageIconChecks_enable']) && !isset($icon_sources[$row['icon']])) |
|
571 | - $icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
603 | + if (!empty($modSettings['messageIconChecks_enable']) && !isset($icon_sources[$row['icon']])) { |
|
604 | + $icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
605 | + } |
|
572 | 606 | |
573 | 607 | // Build the array. |
574 | 608 | $posts[] = array( |
@@ -607,13 +641,14 @@ discard block |
||
607 | 641 | call_integration_hook('integrate_ssi_recentTopics', array(&$posts)); |
608 | 642 | |
609 | 643 | // Just return it. |
610 | - if ($output_method != 'echo' || empty($posts)) |
|
611 | - return $posts; |
|
644 | + if ($output_method != 'echo' || empty($posts)) { |
|
645 | + return $posts; |
|
646 | + } |
|
612 | 647 | |
613 | 648 | echo ' |
614 | 649 | <table style="border: none" class="ssi_table">'; |
615 | - foreach ($posts as $post) |
|
616 | - echo ' |
|
650 | + foreach ($posts as $post) { |
|
651 | + echo ' |
|
617 | 652 | <tr> |
618 | 653 | <td style="text-align: right; vertical-align: top; white-space: nowrap"> |
619 | 654 | [', $post['board']['link'], '] |
@@ -627,6 +662,7 @@ discard block |
||
627 | 662 | ', $post['time'], ' |
628 | 663 | </td> |
629 | 664 | </tr>'; |
665 | + } |
|
630 | 666 | echo ' |
631 | 667 | </table>'; |
632 | 668 | } |
@@ -651,27 +687,30 @@ discard block |
||
651 | 687 | ) |
652 | 688 | ); |
653 | 689 | $return = array(); |
654 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
655 | - $return[] = array( |
|
690 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
691 | + $return[] = array( |
|
656 | 692 | 'id' => $row['id_member'], |
657 | 693 | 'name' => $row['real_name'], |
658 | 694 | 'href' => $scripturl . '?action=profile;u=' . $row['id_member'], |
659 | 695 | 'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>', |
660 | 696 | 'posts' => $row['posts'] |
661 | 697 | ); |
698 | + } |
|
662 | 699 | $smcFunc['db_free_result']($request); |
663 | 700 | |
664 | 701 | // If mods want to do somthing with this list of members, let them do that now. |
665 | 702 | call_integration_hook('integrate_ssi_topPoster', array(&$return)); |
666 | 703 | |
667 | 704 | // Just return all the top posters. |
668 | - if ($output_method != 'echo') |
|
669 | - return $return; |
|
705 | + if ($output_method != 'echo') { |
|
706 | + return $return; |
|
707 | + } |
|
670 | 708 | |
671 | 709 | // Make a quick array to list the links in. |
672 | 710 | $temp_array = array(); |
673 | - foreach ($return as $member) |
|
674 | - $temp_array[] = $member['link']; |
|
711 | + foreach ($return as $member) { |
|
712 | + $temp_array[] = $member['link']; |
|
713 | + } |
|
675 | 714 | |
676 | 715 | echo implode(', ', $temp_array); |
677 | 716 | } |
@@ -703,8 +742,8 @@ discard block |
||
703 | 742 | ) |
704 | 743 | ); |
705 | 744 | $boards = array(); |
706 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
707 | - $boards[] = array( |
|
745 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
746 | + $boards[] = array( |
|
708 | 747 | 'id' => $row['id_board'], |
709 | 748 | 'num_posts' => $row['num_posts'], |
710 | 749 | 'num_topics' => $row['num_topics'], |
@@ -713,14 +752,16 @@ discard block |
||
713 | 752 | 'href' => $scripturl . '?board=' . $row['id_board'] . '.0', |
714 | 753 | 'link' => '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>' |
715 | 754 | ); |
755 | + } |
|
716 | 756 | $smcFunc['db_free_result']($request); |
717 | 757 | |
718 | 758 | // If mods want to do somthing with this list of boards, let them do that now. |
719 | 759 | call_integration_hook('integrate_ssi_topBoards', array(&$boards)); |
720 | 760 | |
721 | 761 | // If we shouldn't output or have nothing to output, just jump out. |
722 | - if ($output_method != 'echo' || empty($boards)) |
|
723 | - return $boards; |
|
762 | + if ($output_method != 'echo' || empty($boards)) { |
|
763 | + return $boards; |
|
764 | + } |
|
724 | 765 | |
725 | 766 | echo ' |
726 | 767 | <table class="ssi_table"> |
@@ -729,13 +770,14 @@ discard block |
||
729 | 770 | <th style="text-align: left">', $txt['board_topics'], '</th> |
730 | 771 | <th style="text-align: left">', $txt['posts'], '</th> |
731 | 772 | </tr>'; |
732 | - foreach ($boards as $sBoard) |
|
733 | - echo ' |
|
773 | + foreach ($boards as $sBoard) { |
|
774 | + echo ' |
|
734 | 775 | <tr> |
735 | 776 | <td>', $sBoard['link'], $sBoard['new'] ? ' <a href="' . $sBoard['href'] . '"><span class="new_posts">' . $txt['new'] . '</span></a>' : '', '</td> |
736 | 777 | <td style="text-align: right">', comma_format($sBoard['num_topics']), '</td> |
737 | 778 | <td style="text-align: right">', comma_format($sBoard['num_posts']), '</td> |
738 | 779 | </tr>'; |
780 | + } |
|
739 | 781 | echo ' |
740 | 782 | </table>'; |
741 | 783 | } |
@@ -768,12 +810,13 @@ discard block |
||
768 | 810 | ) |
769 | 811 | ); |
770 | 812 | $topic_ids = array(); |
771 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
772 | - $topic_ids[] = $row['id_topic']; |
|
813 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
814 | + $topic_ids[] = $row['id_topic']; |
|
815 | + } |
|
773 | 816 | $smcFunc['db_free_result']($request); |
817 | + } else { |
|
818 | + $topic_ids = array(); |
|
774 | 819 | } |
775 | - else |
|
776 | - $topic_ids = array(); |
|
777 | 820 | |
778 | 821 | $request = $smcFunc['db_query']('', ' |
779 | 822 | SELECT m.subject, m.id_topic, t.num_views, t.num_replies |
@@ -812,8 +855,9 @@ discard block |
||
812 | 855 | // If mods want to do somthing with this list of topics, let them do that now. |
813 | 856 | call_integration_hook('integrate_ssi_topTopics', array(&$topics, $type)); |
814 | 857 | |
815 | - if ($output_method != 'echo' || empty($topics)) |
|
816 | - return $topics; |
|
858 | + if ($output_method != 'echo' || empty($topics)) { |
|
859 | + return $topics; |
|
860 | + } |
|
817 | 861 | |
818 | 862 | echo ' |
819 | 863 | <table class="ssi_table"> |
@@ -822,8 +866,8 @@ discard block |
||
822 | 866 | <th style="text-align: left">', $txt['views'], '</th> |
823 | 867 | <th style="text-align: left">', $txt['replies'], '</th> |
824 | 868 | </tr>'; |
825 | - foreach ($topics as $sTopic) |
|
826 | - echo ' |
|
869 | + foreach ($topics as $sTopic) { |
|
870 | + echo ' |
|
827 | 871 | <tr> |
828 | 872 | <td style="text-align: left"> |
829 | 873 | ', $sTopic['link'], ' |
@@ -831,6 +875,7 @@ discard block |
||
831 | 875 | <td style="text-align: right">', comma_format($sTopic['num_views']), '</td> |
832 | 876 | <td style="text-align: right">', comma_format($sTopic['num_replies']), '</td> |
833 | 877 | </tr>'; |
878 | + } |
|
834 | 879 | echo ' |
835 | 880 | </table>'; |
836 | 881 | } |
@@ -866,12 +911,13 @@ discard block |
||
866 | 911 | { |
867 | 912 | global $txt, $context; |
868 | 913 | |
869 | - if ($output_method == 'echo') |
|
870 | - echo ' |
|
914 | + if ($output_method == 'echo') { |
|
915 | + echo ' |
|
871 | 916 | ', sprintf($txt['welcome_newest_member'], $context['common_stats']['latest_member']['link']), '<br>'; |
872 | - else |
|
873 | - return $context['common_stats']['latest_member']; |
|
874 | -} |
|
917 | + } else { |
|
918 | + return $context['common_stats']['latest_member']; |
|
919 | + } |
|
920 | + } |
|
875 | 921 | |
876 | 922 | /** |
877 | 923 | * Fetches a random member. |
@@ -920,8 +966,9 @@ discard block |
||
920 | 966 | } |
921 | 967 | |
922 | 968 | // Just to be sure put the random generator back to something... random. |
923 | - if ($random_type != '') |
|
924 | - mt_srand(time()); |
|
969 | + if ($random_type != '') { |
|
970 | + mt_srand(time()); |
|
971 | + } |
|
925 | 972 | |
926 | 973 | return $result; |
927 | 974 | } |
@@ -934,8 +981,9 @@ discard block |
||
934 | 981 | */ |
935 | 982 | function ssi_fetchMember($member_ids = array(), $output_method = 'echo') |
936 | 983 | { |
937 | - if (empty($member_ids)) |
|
938 | - return; |
|
984 | + if (empty($member_ids)) { |
|
985 | + return; |
|
986 | + } |
|
939 | 987 | |
940 | 988 | // Can have more than one member if you really want... |
941 | 989 | $member_ids = is_array($member_ids) ? $member_ids : array($member_ids); |
@@ -960,8 +1008,9 @@ discard block |
||
960 | 1008 | */ |
961 | 1009 | function ssi_fetchGroupMembers($group_id = null, $output_method = 'echo') |
962 | 1010 | { |
963 | - if ($group_id === null) |
|
964 | - return; |
|
1011 | + if ($group_id === null) { |
|
1012 | + return; |
|
1013 | + } |
|
965 | 1014 | |
966 | 1015 | $query_where = ' |
967 | 1016 | id_group = {int:id_group} |
@@ -988,8 +1037,9 @@ discard block |
||
988 | 1037 | { |
989 | 1038 | global $smcFunc, $memberContext; |
990 | 1039 | |
991 | - if ($query_where === null) |
|
992 | - return; |
|
1040 | + if ($query_where === null) { |
|
1041 | + return; |
|
1042 | + } |
|
993 | 1043 | |
994 | 1044 | // Fetch the members in question. |
995 | 1045 | $request = $smcFunc['db_query']('', ' |
@@ -1002,12 +1052,14 @@ discard block |
||
1002 | 1052 | )) |
1003 | 1053 | ); |
1004 | 1054 | $members = array(); |
1005 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1006 | - $members[] = $row['id_member']; |
|
1055 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1056 | + $members[] = $row['id_member']; |
|
1057 | + } |
|
1007 | 1058 | $smcFunc['db_free_result']($request); |
1008 | 1059 | |
1009 | - if (empty($members)) |
|
1010 | - return array(); |
|
1060 | + if (empty($members)) { |
|
1061 | + return array(); |
|
1062 | + } |
|
1011 | 1063 | |
1012 | 1064 | // If mods want to do somthing with this list of members, let them do that now. |
1013 | 1065 | call_integration_hook('integrate_ssi_queryMembers', array(&$members)); |
@@ -1016,23 +1068,25 @@ discard block |
||
1016 | 1068 | loadMemberData($members); |
1017 | 1069 | |
1018 | 1070 | // Draw the table! |
1019 | - if ($output_method == 'echo') |
|
1020 | - echo ' |
|
1071 | + if ($output_method == 'echo') { |
|
1072 | + echo ' |
|
1021 | 1073 | <table style="border: none" class="ssi_table">'; |
1074 | + } |
|
1022 | 1075 | |
1023 | 1076 | $query_members = array(); |
1024 | 1077 | foreach ($members as $member) |
1025 | 1078 | { |
1026 | 1079 | // Load their context data. |
1027 | - if (!loadMemberContext($member)) |
|
1028 | - continue; |
|
1080 | + if (!loadMemberContext($member)) { |
|
1081 | + continue; |
|
1082 | + } |
|
1029 | 1083 | |
1030 | 1084 | // Store this member's information. |
1031 | 1085 | $query_members[$member] = $memberContext[$member]; |
1032 | 1086 | |
1033 | 1087 | // Only do something if we're echo'ing. |
1034 | - if ($output_method == 'echo') |
|
1035 | - echo ' |
|
1088 | + if ($output_method == 'echo') { |
|
1089 | + echo ' |
|
1036 | 1090 | <tr> |
1037 | 1091 | <td style="text-align: right; vertical-align: top; white-space: nowrap"> |
1038 | 1092 | ', $query_members[$member]['link'], ' |
@@ -1040,12 +1094,14 @@ discard block |
||
1040 | 1094 | <br>', $query_members[$member]['avatar']['image'], ' |
1041 | 1095 | </td> |
1042 | 1096 | </tr>'; |
1097 | + } |
|
1043 | 1098 | } |
1044 | 1099 | |
1045 | 1100 | // End the table if appropriate. |
1046 | - if ($output_method == 'echo') |
|
1047 | - echo ' |
|
1101 | + if ($output_method == 'echo') { |
|
1102 | + echo ' |
|
1048 | 1103 | </table>'; |
1104 | + } |
|
1049 | 1105 | |
1050 | 1106 | // Send back the data. |
1051 | 1107 | return $query_members; |
@@ -1060,8 +1116,9 @@ discard block |
||
1060 | 1116 | { |
1061 | 1117 | global $txt, $scripturl, $modSettings, $smcFunc; |
1062 | 1118 | |
1063 | - if (!allowedTo('view_stats')) |
|
1064 | - return; |
|
1119 | + if (!allowedTo('view_stats')) { |
|
1120 | + return; |
|
1121 | + } |
|
1065 | 1122 | |
1066 | 1123 | $totals = array( |
1067 | 1124 | 'members' => $modSettings['totalMembers'], |
@@ -1090,8 +1147,9 @@ discard block |
||
1090 | 1147 | // If mods want to do somthing with the board stats, let them do that now. |
1091 | 1148 | call_integration_hook('integrate_ssi_boardStats', array(&$totals)); |
1092 | 1149 | |
1093 | - if ($output_method != 'echo') |
|
1094 | - return $totals; |
|
1150 | + if ($output_method != 'echo') { |
|
1151 | + return $totals; |
|
1152 | + } |
|
1095 | 1153 | |
1096 | 1154 | echo ' |
1097 | 1155 | ', $txt['total_members'], ': <a href="', $scripturl . '?action=mlist">', comma_format($totals['members']), '</a><br> |
@@ -1120,8 +1178,8 @@ discard block |
||
1120 | 1178 | call_integration_hook('integrate_ssi_whosOnline', array(&$return)); |
1121 | 1179 | |
1122 | 1180 | // Add some redundancy for backwards compatibility reasons. |
1123 | - if ($output_method != 'echo') |
|
1124 | - return $return + array( |
|
1181 | + if ($output_method != 'echo') { |
|
1182 | + return $return + array( |
|
1125 | 1183 | 'users' => $return['users_online'], |
1126 | 1184 | 'guests' => $return['num_guests'], |
1127 | 1185 | 'hidden' => $return['num_users_hidden'], |
@@ -1129,29 +1187,35 @@ discard block |
||
1129 | 1187 | 'num_users' => $return['num_users_online'], |
1130 | 1188 | 'total_users' => $return['num_users_online'] + $return['num_guests'], |
1131 | 1189 | ); |
1190 | + } |
|
1132 | 1191 | |
1133 | 1192 | echo ' |
1134 | 1193 | ', comma_format($return['num_guests']), ' ', $return['num_guests'] == 1 ? $txt['guest'] : $txt['guests'], ', ', comma_format($return['num_users_online']), ' ', $return['num_users_online'] == 1 ? $txt['user'] : $txt['users']; |
1135 | 1194 | |
1136 | 1195 | $bracketList = array(); |
1137 | - if (!empty($user_info['buddies'])) |
|
1138 | - $bracketList[] = comma_format($return['num_buddies']) . ' ' . ($return['num_buddies'] == 1 ? $txt['buddy'] : $txt['buddies']); |
|
1139 | - if (!empty($return['num_spiders'])) |
|
1140 | - $bracketList[] = comma_format($return['num_spiders']) . ' ' . ($return['num_spiders'] == 1 ? $txt['spider'] : $txt['spiders']); |
|
1141 | - if (!empty($return['num_users_hidden'])) |
|
1142 | - $bracketList[] = comma_format($return['num_users_hidden']) . ' ' . $txt['hidden']; |
|
1196 | + if (!empty($user_info['buddies'])) { |
|
1197 | + $bracketList[] = comma_format($return['num_buddies']) . ' ' . ($return['num_buddies'] == 1 ? $txt['buddy'] : $txt['buddies']); |
|
1198 | + } |
|
1199 | + if (!empty($return['num_spiders'])) { |
|
1200 | + $bracketList[] = comma_format($return['num_spiders']) . ' ' . ($return['num_spiders'] == 1 ? $txt['spider'] : $txt['spiders']); |
|
1201 | + } |
|
1202 | + if (!empty($return['num_users_hidden'])) { |
|
1203 | + $bracketList[] = comma_format($return['num_users_hidden']) . ' ' . $txt['hidden']; |
|
1204 | + } |
|
1143 | 1205 | |
1144 | - if (!empty($bracketList)) |
|
1145 | - echo ' (' . implode(', ', $bracketList) . ')'; |
|
1206 | + if (!empty($bracketList)) { |
|
1207 | + echo ' (' . implode(', ', $bracketList) . ')'; |
|
1208 | + } |
|
1146 | 1209 | |
1147 | 1210 | echo '<br> |
1148 | 1211 | ', implode(', ', $return['list_users_online']); |
1149 | 1212 | |
1150 | 1213 | // Showing membergroups? |
1151 | - if (!empty($settings['show_group_key']) && !empty($return['membergroups'])) |
|
1152 | - echo '<br> |
|
1214 | + if (!empty($settings['show_group_key']) && !empty($return['membergroups'])) { |
|
1215 | + echo '<br> |
|
1153 | 1216 | [' . implode('] [', $return['membergroups']) . ']'; |
1154 | -} |
|
1217 | + } |
|
1218 | + } |
|
1155 | 1219 | |
1156 | 1220 | /** |
1157 | 1221 | * Just like whosOnline except it also logs the online presence. |
@@ -1162,11 +1226,12 @@ discard block |
||
1162 | 1226 | { |
1163 | 1227 | writeLog(); |
1164 | 1228 | |
1165 | - if ($output_method != 'echo') |
|
1166 | - return ssi_whosOnline($output_method); |
|
1167 | - else |
|
1168 | - ssi_whosOnline($output_method); |
|
1169 | -} |
|
1229 | + if ($output_method != 'echo') { |
|
1230 | + return ssi_whosOnline($output_method); |
|
1231 | + } else { |
|
1232 | + ssi_whosOnline($output_method); |
|
1233 | + } |
|
1234 | + } |
|
1170 | 1235 | |
1171 | 1236 | // Shows a login box. |
1172 | 1237 | /** |
@@ -1179,11 +1244,13 @@ discard block |
||
1179 | 1244 | { |
1180 | 1245 | global $scripturl, $txt, $user_info, $context; |
1181 | 1246 | |
1182 | - if ($redirect_to != '') |
|
1183 | - $_SESSION['login_url'] = $redirect_to; |
|
1247 | + if ($redirect_to != '') { |
|
1248 | + $_SESSION['login_url'] = $redirect_to; |
|
1249 | + } |
|
1184 | 1250 | |
1185 | - if ($output_method != 'echo' || !$user_info['is_guest']) |
|
1186 | - return $user_info['is_guest']; |
|
1251 | + if ($output_method != 'echo' || !$user_info['is_guest']) { |
|
1252 | + return $user_info['is_guest']; |
|
1253 | + } |
|
1187 | 1254 | |
1188 | 1255 | // Create a login token |
1189 | 1256 | createToken('login'); |
@@ -1235,8 +1302,9 @@ discard block |
||
1235 | 1302 | |
1236 | 1303 | $boardsAllowed = array_intersect(boardsAllowedTo('poll_view'), boardsAllowedTo('poll_vote')); |
1237 | 1304 | |
1238 | - if (empty($boardsAllowed)) |
|
1239 | - return array(); |
|
1305 | + if (empty($boardsAllowed)) { |
|
1306 | + return array(); |
|
1307 | + } |
|
1240 | 1308 | |
1241 | 1309 | $request = $smcFunc['db_query']('', ' |
1242 | 1310 | SELECT p.id_poll, p.question, t.id_topic, p.max_votes, p.guest_vote, p.hide_results, p.expire_time |
@@ -1269,12 +1337,14 @@ discard block |
||
1269 | 1337 | $smcFunc['db_free_result']($request); |
1270 | 1338 | |
1271 | 1339 | // This user has voted on all the polls. |
1272 | - if (empty($row) || !is_array($row)) |
|
1273 | - return array(); |
|
1340 | + if (empty($row) || !is_array($row)) { |
|
1341 | + return array(); |
|
1342 | + } |
|
1274 | 1343 | |
1275 | 1344 | // If this is a guest who's voted we'll through ourselves to show poll to show the results. |
1276 | - if ($user_info['is_guest'] && (!$row['guest_vote'] || (isset($_COOKIE['guest_poll_vote']) && in_array($row['id_poll'], explode(',', $_COOKIE['guest_poll_vote']))))) |
|
1277 | - return ssi_showPoll($row['id_topic'], $output_method); |
|
1345 | + if ($user_info['is_guest'] && (!$row['guest_vote'] || (isset($_COOKIE['guest_poll_vote']) && in_array($row['id_poll'], explode(',', $_COOKIE['guest_poll_vote']))))) { |
|
1346 | + return ssi_showPoll($row['id_topic'], $output_method); |
|
1347 | + } |
|
1278 | 1348 | |
1279 | 1349 | $request = $smcFunc['db_query']('', ' |
1280 | 1350 | SELECT COUNT(DISTINCT id_member) |
@@ -1338,8 +1408,9 @@ discard block |
||
1338 | 1408 | // If mods want to do somthing with this list of polls, let them do that now. |
1339 | 1409 | call_integration_hook('integrate_ssi_recentPoll', array(&$return, $topPollInstead)); |
1340 | 1410 | |
1341 | - if ($output_method != 'echo') |
|
1342 | - return $return; |
|
1411 | + if ($output_method != 'echo') { |
|
1412 | + return $return; |
|
1413 | + } |
|
1343 | 1414 | |
1344 | 1415 | if ($allow_view_results) |
1345 | 1416 | { |
@@ -1348,19 +1419,20 @@ discard block |
||
1348 | 1419 | <strong>', $return['question'], '</strong><br> |
1349 | 1420 | ', !empty($return['allowed_warning']) ? $return['allowed_warning'] . '<br>' : ''; |
1350 | 1421 | |
1351 | - foreach ($return['options'] as $option) |
|
1352 | - echo ' |
|
1422 | + foreach ($return['options'] as $option) { |
|
1423 | + echo ' |
|
1353 | 1424 | <label for="', $option['id'], '">', $option['vote_button'], ' ', $option['option'], '</label><br>'; |
1425 | + } |
|
1354 | 1426 | |
1355 | 1427 | echo ' |
1356 | 1428 | <input type="submit" value="', $txt['poll_vote'], '" class="button"> |
1357 | 1429 | <input type="hidden" name="poll" value="', $return['id'], '"> |
1358 | 1430 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
1359 | 1431 | </form>'; |
1432 | + } else { |
|
1433 | + echo $txt['poll_cannot_see']; |
|
1434 | + } |
|
1360 | 1435 | } |
1361 | - else |
|
1362 | - echo $txt['poll_cannot_see']; |
|
1363 | -} |
|
1364 | 1436 | |
1365 | 1437 | /** |
1366 | 1438 | * Shows the poll from the specified topic |
@@ -1374,13 +1446,15 @@ discard block |
||
1374 | 1446 | |
1375 | 1447 | $boardsAllowed = boardsAllowedTo('poll_view'); |
1376 | 1448 | |
1377 | - if (empty($boardsAllowed)) |
|
1378 | - return array(); |
|
1449 | + if (empty($boardsAllowed)) { |
|
1450 | + return array(); |
|
1451 | + } |
|
1379 | 1452 | |
1380 | - if ($topic === null && isset($_REQUEST['ssi_topic'])) |
|
1381 | - $topic = (int) $_REQUEST['ssi_topic']; |
|
1382 | - else |
|
1383 | - $topic = (int) $topic; |
|
1453 | + if ($topic === null && isset($_REQUEST['ssi_topic'])) { |
|
1454 | + $topic = (int) $_REQUEST['ssi_topic']; |
|
1455 | + } else { |
|
1456 | + $topic = (int) $topic; |
|
1457 | + } |
|
1384 | 1458 | |
1385 | 1459 | $request = $smcFunc['db_query']('', ' |
1386 | 1460 | SELECT |
@@ -1401,17 +1475,18 @@ discard block |
||
1401 | 1475 | ); |
1402 | 1476 | |
1403 | 1477 | // Either this topic has no poll, or the user cannot view it. |
1404 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
1405 | - return array(); |
|
1478 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
1479 | + return array(); |
|
1480 | + } |
|
1406 | 1481 | |
1407 | 1482 | $row = $smcFunc['db_fetch_assoc']($request); |
1408 | 1483 | $smcFunc['db_free_result']($request); |
1409 | 1484 | |
1410 | 1485 | // Check if they can vote. |
1411 | 1486 | $already_voted = false; |
1412 | - if (!empty($row['expire_time']) && $row['expire_time'] < time()) |
|
1413 | - $allow_vote = false; |
|
1414 | - elseif ($user_info['is_guest']) |
|
1487 | + if (!empty($row['expire_time']) && $row['expire_time'] < time()) { |
|
1488 | + $allow_vote = false; |
|
1489 | + } elseif ($user_info['is_guest']) |
|
1415 | 1490 | { |
1416 | 1491 | // There's a difference between "allowed to vote" and "already voted"... |
1417 | 1492 | $allow_vote = $row['guest_vote']; |
@@ -1421,10 +1496,9 @@ discard block |
||
1421 | 1496 | { |
1422 | 1497 | $already_voted = true; |
1423 | 1498 | } |
1424 | - } |
|
1425 | - elseif (!empty($row['voting_locked']) || !allowedTo('poll_vote', $row['id_board'])) |
|
1426 | - $allow_vote = false; |
|
1427 | - else |
|
1499 | + } elseif (!empty($row['voting_locked']) || !allowedTo('poll_vote', $row['id_board'])) { |
|
1500 | + $allow_vote = false; |
|
1501 | + } else |
|
1428 | 1502 | { |
1429 | 1503 | $request = $smcFunc['db_query']('', ' |
1430 | 1504 | SELECT id_member |
@@ -1506,8 +1580,9 @@ discard block |
||
1506 | 1580 | // If mods want to do somthing with this poll, let them do that now. |
1507 | 1581 | call_integration_hook('integrate_ssi_showPoll', array(&$return)); |
1508 | 1582 | |
1509 | - if ($output_method != 'echo') |
|
1510 | - return $return; |
|
1583 | + if ($output_method != 'echo') { |
|
1584 | + return $return; |
|
1585 | + } |
|
1511 | 1586 | |
1512 | 1587 | if ($return['allow_vote']) |
1513 | 1588 | { |
@@ -1516,17 +1591,17 @@ discard block |
||
1516 | 1591 | <strong>', $return['question'], '</strong><br> |
1517 | 1592 | ', !empty($return['allowed_warning']) ? $return['allowed_warning'] . '<br>' : ''; |
1518 | 1593 | |
1519 | - foreach ($return['options'] as $option) |
|
1520 | - echo ' |
|
1594 | + foreach ($return['options'] as $option) { |
|
1595 | + echo ' |
|
1521 | 1596 | <label for="', $option['id'], '">', $option['vote_button'], ' ', $option['option'], '</label><br>'; |
1597 | + } |
|
1522 | 1598 | |
1523 | 1599 | echo ' |
1524 | 1600 | <input type="submit" value="', $txt['poll_vote'], '" class="button"> |
1525 | 1601 | <input type="hidden" name="poll" value="', $return['id'], '"> |
1526 | 1602 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
1527 | 1603 | </form>'; |
1528 | - } |
|
1529 | - else |
|
1604 | + } else |
|
1530 | 1605 | { |
1531 | 1606 | echo ' |
1532 | 1607 | <div class="ssi_poll"> |
@@ -1606,27 +1681,32 @@ discard block |
||
1606 | 1681 | 'is_approved' => 1, |
1607 | 1682 | ) |
1608 | 1683 | ); |
1609 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
1610 | - die; |
|
1684 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
1685 | + die; |
|
1686 | + } |
|
1611 | 1687 | $row = $smcFunc['db_fetch_assoc']($request); |
1612 | 1688 | $smcFunc['db_free_result']($request); |
1613 | 1689 | |
1614 | - if (!empty($row['voting_locked']) || ($row['selected'] != -1 && !$user_info['is_guest']) || (!empty($row['expire_time']) && time() > $row['expire_time'])) |
|
1615 | - redirectexit('topic=' . $row['id_topic'] . '.0'); |
|
1690 | + if (!empty($row['voting_locked']) || ($row['selected'] != -1 && !$user_info['is_guest']) || (!empty($row['expire_time']) && time() > $row['expire_time'])) { |
|
1691 | + redirectexit('topic=' . $row['id_topic'] . '.0'); |
|
1692 | + } |
|
1616 | 1693 | |
1617 | 1694 | // Too many options checked? |
1618 | - if (count($_REQUEST['options']) > $row['max_votes']) |
|
1619 | - redirectexit('topic=' . $row['id_topic'] . '.0'); |
|
1695 | + if (count($_REQUEST['options']) > $row['max_votes']) { |
|
1696 | + redirectexit('topic=' . $row['id_topic'] . '.0'); |
|
1697 | + } |
|
1620 | 1698 | |
1621 | 1699 | // It's a guest who has already voted? |
1622 | 1700 | if ($user_info['is_guest']) |
1623 | 1701 | { |
1624 | 1702 | // Guest voting disabled? |
1625 | - if (!$row['guest_vote']) |
|
1626 | - redirectexit('topic=' . $row['id_topic'] . '.0'); |
|
1703 | + if (!$row['guest_vote']) { |
|
1704 | + redirectexit('topic=' . $row['id_topic'] . '.0'); |
|
1705 | + } |
|
1627 | 1706 | // Already voted? |
1628 | - elseif (isset($_COOKIE['guest_poll_vote']) && in_array($row['id_poll'], explode(',', $_COOKIE['guest_poll_vote']))) |
|
1629 | - redirectexit('topic=' . $row['id_topic'] . '.0'); |
|
1707 | + elseif (isset($_COOKIE['guest_poll_vote']) && in_array($row['id_poll'], explode(',', $_COOKIE['guest_poll_vote']))) { |
|
1708 | + redirectexit('topic=' . $row['id_topic'] . '.0'); |
|
1709 | + } |
|
1630 | 1710 | } |
1631 | 1711 | |
1632 | 1712 | $sOptions = array(); |
@@ -1680,11 +1760,13 @@ discard block |
||
1680 | 1760 | { |
1681 | 1761 | global $scripturl, $txt, $context; |
1682 | 1762 | |
1683 | - if (!allowedTo('search_posts')) |
|
1684 | - return; |
|
1763 | + if (!allowedTo('search_posts')) { |
|
1764 | + return; |
|
1765 | + } |
|
1685 | 1766 | |
1686 | - if ($output_method != 'echo') |
|
1687 | - return $scripturl . '?action=search'; |
|
1767 | + if ($output_method != 'echo') { |
|
1768 | + return $scripturl . '?action=search'; |
|
1769 | + } |
|
1688 | 1770 | |
1689 | 1771 | echo ' |
1690 | 1772 | <form action="', $scripturl, '?action=search2" method="post" accept-charset="', $context['character_set'], '"> |
@@ -1706,8 +1788,9 @@ discard block |
||
1706 | 1788 | // If mods want to do somthing with the news, let them do that now. Don't need to pass the news line itself, since it is already in $context. |
1707 | 1789 | call_integration_hook('integrate_ssi_news'); |
1708 | 1790 | |
1709 | - if ($output_method != 'echo') |
|
1710 | - return $context['random_news_line']; |
|
1791 | + if ($output_method != 'echo') { |
|
1792 | + return $context['random_news_line']; |
|
1793 | + } |
|
1711 | 1794 | |
1712 | 1795 | echo $context['random_news_line']; |
1713 | 1796 | } |
@@ -1721,8 +1804,9 @@ discard block |
||
1721 | 1804 | { |
1722 | 1805 | global $scripturl, $modSettings, $user_info; |
1723 | 1806 | |
1724 | - if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view') || !allowedTo('profile_view')) |
|
1725 | - return; |
|
1807 | + if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view') || !allowedTo('profile_view')) { |
|
1808 | + return; |
|
1809 | + } |
|
1726 | 1810 | |
1727 | 1811 | $eventOptions = array( |
1728 | 1812 | 'include_birthdays' => true, |
@@ -1733,13 +1817,15 @@ discard block |
||
1733 | 1817 | // The ssi_todaysCalendar variants all use the same hook and just pass on $eventOptions so the hooked code can distinguish different cases if necessary |
1734 | 1818 | call_integration_hook('integrate_ssi_calendar', array(&$return, $eventOptions)); |
1735 | 1819 | |
1736 | - if ($output_method != 'echo') |
|
1737 | - return $return['calendar_birthdays']; |
|
1820 | + if ($output_method != 'echo') { |
|
1821 | + return $return['calendar_birthdays']; |
|
1822 | + } |
|
1738 | 1823 | |
1739 | - foreach ($return['calendar_birthdays'] as $member) |
|
1740 | - echo ' |
|
1824 | + foreach ($return['calendar_birthdays'] as $member) { |
|
1825 | + echo ' |
|
1741 | 1826 | <a href="', $scripturl, '?action=profile;u=', $member['id'], '"><span class="fix_rtl_names">' . $member['name'] . '</span>' . (isset($member['age']) ? ' (' . $member['age'] . ')' : '') . '</a>' . (!$member['is_last'] ? ', ' : ''); |
1742 | -} |
|
1827 | + } |
|
1828 | + } |
|
1743 | 1829 | |
1744 | 1830 | /** |
1745 | 1831 | * Shows today's holidays. |
@@ -1750,8 +1836,9 @@ discard block |
||
1750 | 1836 | { |
1751 | 1837 | global $modSettings, $user_info; |
1752 | 1838 | |
1753 | - if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) |
|
1754 | - return; |
|
1839 | + if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) { |
|
1840 | + return; |
|
1841 | + } |
|
1755 | 1842 | |
1756 | 1843 | $eventOptions = array( |
1757 | 1844 | 'include_holidays' => true, |
@@ -1762,8 +1849,9 @@ discard block |
||
1762 | 1849 | // The ssi_todaysCalendar variants all use the same hook and just pass on $eventOptions so the hooked code can distinguish different cases if necessary |
1763 | 1850 | call_integration_hook('integrate_ssi_calendar', array(&$return, $eventOptions)); |
1764 | 1851 | |
1765 | - if ($output_method != 'echo') |
|
1766 | - return $return['calendar_holidays']; |
|
1852 | + if ($output_method != 'echo') { |
|
1853 | + return $return['calendar_holidays']; |
|
1854 | + } |
|
1767 | 1855 | |
1768 | 1856 | echo ' |
1769 | 1857 | ', implode(', ', $return['calendar_holidays']); |
@@ -1777,8 +1865,9 @@ discard block |
||
1777 | 1865 | { |
1778 | 1866 | global $modSettings, $user_info; |
1779 | 1867 | |
1780 | - if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) |
|
1781 | - return; |
|
1868 | + if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) { |
|
1869 | + return; |
|
1870 | + } |
|
1782 | 1871 | |
1783 | 1872 | $eventOptions = array( |
1784 | 1873 | 'include_events' => true, |
@@ -1789,14 +1878,16 @@ discard block |
||
1789 | 1878 | // The ssi_todaysCalendar variants all use the same hook and just pass on $eventOptions so the hooked code can distinguish different cases if necessary |
1790 | 1879 | call_integration_hook('integrate_ssi_calendar', array(&$return, $eventOptions)); |
1791 | 1880 | |
1792 | - if ($output_method != 'echo') |
|
1793 | - return $return['calendar_events']; |
|
1881 | + if ($output_method != 'echo') { |
|
1882 | + return $return['calendar_events']; |
|
1883 | + } |
|
1794 | 1884 | |
1795 | 1885 | foreach ($return['calendar_events'] as $event) |
1796 | 1886 | { |
1797 | - if ($event['can_edit']) |
|
1798 | - echo ' |
|
1887 | + if ($event['can_edit']) { |
|
1888 | + echo ' |
|
1799 | 1889 | <a href="' . $event['modify_href'] . '" style="color: #ff0000;">*</a> '; |
1890 | + } |
|
1800 | 1891 | echo ' |
1801 | 1892 | ' . $event['link'] . (!$event['is_last'] ? ', ' : ''); |
1802 | 1893 | } |
@@ -1811,8 +1902,9 @@ discard block |
||
1811 | 1902 | { |
1812 | 1903 | global $modSettings, $txt, $scripturl, $user_info; |
1813 | 1904 | |
1814 | - if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) |
|
1815 | - return; |
|
1905 | + if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) { |
|
1906 | + return; |
|
1907 | + } |
|
1816 | 1908 | |
1817 | 1909 | $eventOptions = array( |
1818 | 1910 | 'include_birthdays' => allowedTo('profile_view'), |
@@ -1825,19 +1917,22 @@ discard block |
||
1825 | 1917 | // The ssi_todaysCalendar variants all use the same hook and just pass on $eventOptions so the hooked code can distinguish different cases if necessary |
1826 | 1918 | call_integration_hook('integrate_ssi_calendar', array(&$return, $eventOptions)); |
1827 | 1919 | |
1828 | - if ($output_method != 'echo') |
|
1829 | - return $return; |
|
1920 | + if ($output_method != 'echo') { |
|
1921 | + return $return; |
|
1922 | + } |
|
1830 | 1923 | |
1831 | - if (!empty($return['calendar_holidays'])) |
|
1832 | - echo ' |
|
1924 | + if (!empty($return['calendar_holidays'])) { |
|
1925 | + echo ' |
|
1833 | 1926 | <span class="holiday">' . $txt['calendar_prompt'] . ' ' . implode(', ', $return['calendar_holidays']) . '<br></span>'; |
1927 | + } |
|
1834 | 1928 | if (!empty($return['calendar_birthdays'])) |
1835 | 1929 | { |
1836 | 1930 | echo ' |
1837 | 1931 | <span class="birthday">' . $txt['birthdays_upcoming'] . '</span> '; |
1838 | - foreach ($return['calendar_birthdays'] as $member) |
|
1839 | - echo ' |
|
1932 | + foreach ($return['calendar_birthdays'] as $member) { |
|
1933 | + echo ' |
|
1840 | 1934 | <a href="', $scripturl, '?action=profile;u=', $member['id'], '"><span class="fix_rtl_names">', $member['name'], '</span>', isset($member['age']) ? ' (' . $member['age'] . ')' : '', '</a>', !$member['is_last'] ? ', ' : ''; |
1935 | + } |
|
1841 | 1936 | echo ' |
1842 | 1937 | <br>'; |
1843 | 1938 | } |
@@ -1847,9 +1942,10 @@ discard block |
||
1847 | 1942 | <span class="event">' . $txt['events_upcoming'] . '</span> '; |
1848 | 1943 | foreach ($return['calendar_events'] as $event) |
1849 | 1944 | { |
1850 | - if ($event['can_edit']) |
|
1851 | - echo ' |
|
1945 | + if ($event['can_edit']) { |
|
1946 | + echo ' |
|
1852 | 1947 | <a href="' . $event['modify_href'] . '" style="color: #ff0000;">*</a> '; |
1948 | + } |
|
1853 | 1949 | echo ' |
1854 | 1950 | ' . $event['link'] . (!$event['is_last'] ? ', ' : ''); |
1855 | 1951 | } |
@@ -1873,25 +1969,29 @@ discard block |
||
1873 | 1969 | loadLanguage('Stats'); |
1874 | 1970 | |
1875 | 1971 | // Must be integers.... |
1876 | - if ($limit === null) |
|
1877 | - $limit = isset($_GET['limit']) ? (int) $_GET['limit'] : 5; |
|
1878 | - else |
|
1879 | - $limit = (int) $limit; |
|
1880 | - |
|
1881 | - if ($start === null) |
|
1882 | - $start = isset($_GET['start']) ? (int) $_GET['start'] : 0; |
|
1883 | - else |
|
1884 | - $start = (int) $start; |
|
1885 | - |
|
1886 | - if ($board !== null) |
|
1887 | - $board = (int) $board; |
|
1888 | - elseif (isset($_GET['board'])) |
|
1889 | - $board = (int) $_GET['board']; |
|
1890 | - |
|
1891 | - if ($length === null) |
|
1892 | - $length = isset($_GET['length']) ? (int) $_GET['length'] : 0; |
|
1893 | - else |
|
1894 | - $length = (int) $length; |
|
1972 | + if ($limit === null) { |
|
1973 | + $limit = isset($_GET['limit']) ? (int) $_GET['limit'] : 5; |
|
1974 | + } else { |
|
1975 | + $limit = (int) $limit; |
|
1976 | + } |
|
1977 | + |
|
1978 | + if ($start === null) { |
|
1979 | + $start = isset($_GET['start']) ? (int) $_GET['start'] : 0; |
|
1980 | + } else { |
|
1981 | + $start = (int) $start; |
|
1982 | + } |
|
1983 | + |
|
1984 | + if ($board !== null) { |
|
1985 | + $board = (int) $board; |
|
1986 | + } elseif (isset($_GET['board'])) { |
|
1987 | + $board = (int) $_GET['board']; |
|
1988 | + } |
|
1989 | + |
|
1990 | + if ($length === null) { |
|
1991 | + $length = isset($_GET['length']) ? (int) $_GET['length'] : 0; |
|
1992 | + } else { |
|
1993 | + $length = (int) $length; |
|
1994 | + } |
|
1895 | 1995 | |
1896 | 1996 | $limit = max(0, $limit); |
1897 | 1997 | $start = max(0, $start); |
@@ -1909,17 +2009,19 @@ discard block |
||
1909 | 2009 | ); |
1910 | 2010 | if ($smcFunc['db_num_rows']($request) == 0) |
1911 | 2011 | { |
1912 | - if ($output_method == 'echo') |
|
1913 | - die($txt['ssi_no_guests']); |
|
1914 | - else |
|
1915 | - return array(); |
|
2012 | + if ($output_method == 'echo') { |
|
2013 | + die($txt['ssi_no_guests']); |
|
2014 | + } else { |
|
2015 | + return array(); |
|
2016 | + } |
|
1916 | 2017 | } |
1917 | 2018 | list ($board) = $smcFunc['db_fetch_row']($request); |
1918 | 2019 | $smcFunc['db_free_result']($request); |
1919 | 2020 | |
1920 | 2021 | $icon_sources = array(); |
1921 | - foreach ($context['stable_icons'] as $icon) |
|
1922 | - $icon_sources[$icon] = 'images_url'; |
|
2022 | + foreach ($context['stable_icons'] as $icon) { |
|
2023 | + $icon_sources[$icon] = 'images_url'; |
|
2024 | + } |
|
1923 | 2025 | |
1924 | 2026 | if (!empty($modSettings['enable_likes'])) |
1925 | 2027 | { |
@@ -1942,12 +2044,14 @@ discard block |
||
1942 | 2044 | ) |
1943 | 2045 | ); |
1944 | 2046 | $posts = array(); |
1945 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1946 | - $posts[] = $row['id_first_msg']; |
|
2047 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2048 | + $posts[] = $row['id_first_msg']; |
|
2049 | + } |
|
1947 | 2050 | $smcFunc['db_free_result']($request); |
1948 | 2051 | |
1949 | - if (empty($posts)) |
|
1950 | - return array(); |
|
2052 | + if (empty($posts)) { |
|
2053 | + return array(); |
|
2054 | + } |
|
1951 | 2055 | |
1952 | 2056 | // Find the posts. |
1953 | 2057 | $request = $smcFunc['db_query']('', ' |
@@ -1977,24 +2081,28 @@ discard block |
||
1977 | 2081 | $last_space = strrpos($row['body'], ' '); |
1978 | 2082 | $last_open = strrpos($row['body'], '<'); |
1979 | 2083 | $last_close = strrpos($row['body'], '>'); |
1980 | - if (empty($last_space) || ($last_space == $last_open + 3 && (empty($last_close) || (!empty($last_close) && $last_close < $last_open))) || $last_space < $last_open || $last_open == $length - 6) |
|
1981 | - $cutoff = $last_open; |
|
1982 | - elseif (empty($last_close) || $last_close < $last_open) |
|
1983 | - $cutoff = $last_space; |
|
2084 | + if (empty($last_space) || ($last_space == $last_open + 3 && (empty($last_close) || (!empty($last_close) && $last_close < $last_open))) || $last_space < $last_open || $last_open == $length - 6) { |
|
2085 | + $cutoff = $last_open; |
|
2086 | + } elseif (empty($last_close) || $last_close < $last_open) { |
|
2087 | + $cutoff = $last_space; |
|
2088 | + } |
|
1984 | 2089 | |
1985 | - if ($cutoff !== false) |
|
1986 | - $row['body'] = $smcFunc['substr']($row['body'], 0, $cutoff); |
|
2090 | + if ($cutoff !== false) { |
|
2091 | + $row['body'] = $smcFunc['substr']($row['body'], 0, $cutoff); |
|
2092 | + } |
|
1987 | 2093 | $row['body'] .= '...'; |
1988 | 2094 | } |
1989 | 2095 | |
1990 | 2096 | $row['body'] = parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']); |
1991 | 2097 | |
1992 | - if (!empty($recycle_board) && $row['id_board'] == $recycle_board) |
|
1993 | - $row['icon'] = 'recycled'; |
|
2098 | + if (!empty($recycle_board) && $row['id_board'] == $recycle_board) { |
|
2099 | + $row['icon'] = 'recycled'; |
|
2100 | + } |
|
1994 | 2101 | |
1995 | 2102 | // Check that this message icon is there... |
1996 | - if (!empty($modSettings['messageIconChecks_enable']) && !isset($icon_sources[$row['icon']])) |
|
1997 | - $icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
2103 | + if (!empty($modSettings['messageIconChecks_enable']) && !isset($icon_sources[$row['icon']])) { |
|
2104 | + $icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
2105 | + } |
|
1998 | 2106 | |
1999 | 2107 | censorText($row['subject']); |
2000 | 2108 | censorText($row['body']); |
@@ -2031,16 +2139,18 @@ discard block |
||
2031 | 2139 | } |
2032 | 2140 | $smcFunc['db_free_result']($request); |
2033 | 2141 | |
2034 | - if (empty($return)) |
|
2035 | - return $return; |
|
2142 | + if (empty($return)) { |
|
2143 | + return $return; |
|
2144 | + } |
|
2036 | 2145 | |
2037 | 2146 | $return[count($return) - 1]['is_last'] = true; |
2038 | 2147 | |
2039 | 2148 | // If mods want to do somthing with this list of posts, let them do that now. |
2040 | 2149 | call_integration_hook('integrate_ssi_boardNews', array(&$return)); |
2041 | 2150 | |
2042 | - if ($output_method != 'echo') |
|
2043 | - return $return; |
|
2151 | + if ($output_method != 'echo') { |
|
2152 | + return $return; |
|
2153 | + } |
|
2044 | 2154 | |
2045 | 2155 | foreach ($return as $news) |
2046 | 2156 | { |
@@ -2092,9 +2202,10 @@ discard block |
||
2092 | 2202 | echo ' |
2093 | 2203 | </div>'; |
2094 | 2204 | |
2095 | - if (!$news['is_last']) |
|
2096 | - echo ' |
|
2205 | + if (!$news['is_last']) { |
|
2206 | + echo ' |
|
2097 | 2207 | <hr>'; |
2208 | + } |
|
2098 | 2209 | } |
2099 | 2210 | } |
2100 | 2211 | |
@@ -2108,8 +2219,9 @@ discard block |
||
2108 | 2219 | { |
2109 | 2220 | global $user_info, $scripturl, $modSettings, $txt, $context, $smcFunc; |
2110 | 2221 | |
2111 | - if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) |
|
2112 | - return; |
|
2222 | + if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) { |
|
2223 | + return; |
|
2224 | + } |
|
2113 | 2225 | |
2114 | 2226 | // Find all events which are happening in the near future that the member can see. |
2115 | 2227 | $request = $smcFunc['db_query']('', ' |
@@ -2135,20 +2247,23 @@ discard block |
||
2135 | 2247 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
2136 | 2248 | { |
2137 | 2249 | // Check if we've already come by an event linked to this same topic with the same title... and don't display it if we have. |
2138 | - if (!empty($duplicates[$row['title'] . $row['id_topic']])) |
|
2139 | - continue; |
|
2250 | + if (!empty($duplicates[$row['title'] . $row['id_topic']])) { |
|
2251 | + continue; |
|
2252 | + } |
|
2140 | 2253 | |
2141 | 2254 | // Censor the title. |
2142 | 2255 | censorText($row['title']); |
2143 | 2256 | |
2144 | - if ($row['start_date'] < strftime('%Y-%m-%d', forum_time(false))) |
|
2145 | - $date = strftime('%Y-%m-%d', forum_time(false)); |
|
2146 | - else |
|
2147 | - $date = $row['start_date']; |
|
2257 | + if ($row['start_date'] < strftime('%Y-%m-%d', forum_time(false))) { |
|
2258 | + $date = strftime('%Y-%m-%d', forum_time(false)); |
|
2259 | + } else { |
|
2260 | + $date = $row['start_date']; |
|
2261 | + } |
|
2148 | 2262 | |
2149 | 2263 | // If the topic it is attached to is not approved then don't link it. |
2150 | - if (!empty($row['id_first_msg']) && !$row['approved']) |
|
2151 | - $row['id_board'] = $row['id_topic'] = $row['id_first_msg'] = 0; |
|
2264 | + if (!empty($row['id_first_msg']) && !$row['approved']) { |
|
2265 | + $row['id_board'] = $row['id_topic'] = $row['id_first_msg'] = 0; |
|
2266 | + } |
|
2152 | 2267 | |
2153 | 2268 | $allday = (empty($row['start_time']) || empty($row['end_time']) || empty($row['timezone']) || !in_array($row['timezone'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) ? true : false; |
2154 | 2269 | |
@@ -2174,24 +2289,27 @@ discard block |
||
2174 | 2289 | } |
2175 | 2290 | $smcFunc['db_free_result']($request); |
2176 | 2291 | |
2177 | - foreach ($return as $mday => $array) |
|
2178 | - $return[$mday][count($array) - 1]['is_last'] = true; |
|
2292 | + foreach ($return as $mday => $array) { |
|
2293 | + $return[$mday][count($array) - 1]['is_last'] = true; |
|
2294 | + } |
|
2179 | 2295 | |
2180 | 2296 | // If mods want to do somthing with this list of events, let them do that now. |
2181 | 2297 | call_integration_hook('integrate_ssi_recentEvents', array(&$return)); |
2182 | 2298 | |
2183 | - if ($output_method != 'echo' || empty($return)) |
|
2184 | - return $return; |
|
2299 | + if ($output_method != 'echo' || empty($return)) { |
|
2300 | + return $return; |
|
2301 | + } |
|
2185 | 2302 | |
2186 | 2303 | // Well the output method is echo. |
2187 | 2304 | echo ' |
2188 | 2305 | <span class="event">' . $txt['events'] . '</span> '; |
2189 | - foreach ($return as $mday => $array) |
|
2190 | - foreach ($array as $event) |
|
2306 | + foreach ($return as $mday => $array) { |
|
2307 | + foreach ($array as $event) |
|
2191 | 2308 | { |
2192 | 2309 | if ($event['can_edit']) |
2193 | 2310 | echo ' |
2194 | 2311 | <a href="' . $event['modify_href'] . '" style="color: #ff0000;">*</a> '; |
2312 | + } |
|
2195 | 2313 | |
2196 | 2314 | echo ' |
2197 | 2315 | ' . $event['link'] . (!$event['is_last'] ? ', ' : ''); |
@@ -2210,8 +2328,9 @@ discard block |
||
2210 | 2328 | global $smcFunc; |
2211 | 2329 | |
2212 | 2330 | // If $id is null, this was most likely called from a query string and should do nothing. |
2213 | - if ($id === null) |
|
2214 | - return; |
|
2331 | + if ($id === null) { |
|
2332 | + return; |
|
2333 | + } |
|
2215 | 2334 | |
2216 | 2335 | $request = $smcFunc['db_query']('', ' |
2217 | 2336 | SELECT passwd, member_name, is_activated |
@@ -2243,8 +2362,9 @@ discard block |
||
2243 | 2362 | $attachments_boards = boardsAllowedTo('view_attachments'); |
2244 | 2363 | |
2245 | 2364 | // No boards? Adios amigo. |
2246 | - if (empty($attachments_boards)) |
|
2247 | - return array(); |
|
2365 | + if (empty($attachments_boards)) { |
|
2366 | + return array(); |
|
2367 | + } |
|
2248 | 2368 | |
2249 | 2369 | // Is it an array? |
2250 | 2370 | $attachment_ext = (array) $attachment_ext; |
@@ -2328,8 +2448,9 @@ discard block |
||
2328 | 2448 | call_integration_hook('integrate_ssi_recentAttachments', array(&$attachments)); |
2329 | 2449 | |
2330 | 2450 | // So you just want an array? Here you can have it. |
2331 | - if ($output_method == 'array' || empty($attachments)) |
|
2332 | - return $attachments; |
|
2451 | + if ($output_method == 'array' || empty($attachments)) { |
|
2452 | + return $attachments; |
|
2453 | + } |
|
2333 | 2454 | |
2334 | 2455 | // Give them the default. |
2335 | 2456 | echo ' |
@@ -2340,14 +2461,15 @@ discard block |
||
2340 | 2461 | <th style="text-align: left; padding: 2">', $txt['downloads'], '</th> |
2341 | 2462 | <th style="text-align: left; padding: 2">', $txt['filesize'], '</th> |
2342 | 2463 | </tr>'; |
2343 | - foreach ($attachments as $attach) |
|
2344 | - echo ' |
|
2464 | + foreach ($attachments as $attach) { |
|
2465 | + echo ' |
|
2345 | 2466 | <tr> |
2346 | 2467 | <td>', $attach['file']['link'], '</td> |
2347 | 2468 | <td>', $attach['member']['link'], '</td> |
2348 | 2469 | <td style="text-align: center">', $attach['file']['downloads'], '</td> |
2349 | 2470 | <td>', $attach['file']['filesize'], '</td> |
2350 | 2471 | </tr>'; |
2472 | + } |
|
2351 | 2473 | echo ' |
2352 | 2474 | </table>'; |
2353 | 2475 | } |