@@ -68,14 +68,18 @@ discard block |
||
| 68 | 68 | |
| 69 | 69 | // Check if we have done this already. |
| 70 | 70 | if (isset($expanded[$ip])) |
| 71 | - return $expanded[$ip]; |
|
| 71 | + { |
|
| 72 | + return $expanded[$ip]; |
|
| 73 | + } |
|
| 72 | 74 | |
| 73 | 75 | // Expand the IP out. |
| 74 | 76 | $expanded_ip = explode(':', expandIPv6($ip)); |
| 75 | 77 | |
| 76 | 78 | $new_ip = array(); |
| 77 | 79 | foreach ($expanded_ip as $int) |
| 78 | - $new_ip[] = hexdec($int); |
|
| 80 | + { |
|
| 81 | + $new_ip[] = hexdec($int); |
|
| 82 | + } |
|
| 79 | 83 | |
| 80 | 84 | // Save this in case of repeated use. |
| 81 | 85 | $expanded[$ip] = $new_ip; |
@@ -97,7 +101,9 @@ discard block |
||
| 97 | 101 | |
| 98 | 102 | // Check if we have done this already. |
| 99 | 103 | if (isset($converted[$addr])) |
| 100 | - return $converted[$addr]; |
|
| 104 | + { |
|
| 105 | + return $converted[$addr]; |
|
| 106 | + } |
|
| 101 | 107 | |
| 102 | 108 | // Check if there are segments missing, insert if necessary. |
| 103 | 109 | if (strpos($addr, '::') !== false) |
@@ -123,17 +129,22 @@ discard block |
||
| 123 | 129 | |
| 124 | 130 | $limit = count($part[0]) + count($part[1]); |
| 125 | 131 | for ($i = 0; $i < (8 - $limit); $i++) |
| 126 | - array_push($missing, '0000'); |
|
| 132 | + { |
|
| 133 | + array_push($missing, '0000'); |
|
| 134 | + } |
|
| 127 | 135 | |
| 128 | 136 | $part = array_merge($part[0], $missing, $part[1]); |
| 129 | 137 | } |
| 130 | - else |
|
| 131 | - $part = explode(':', $addr); |
|
| 138 | + else { |
|
| 139 | + $part = explode(':', $addr); |
|
| 140 | + } |
|
| 132 | 141 | |
| 133 | 142 | // Pad each segment until it has 4 digits. |
| 134 | 143 | foreach ($part as &$p) |
| 135 | - while (strlen($p) < 4) |
|
| 144 | + { |
|
| 145 | + while (strlen($p) < 4) |
|
| 136 | 146 | $p = '0' . $p; |
| 147 | + } |
|
| 137 | 148 | |
| 138 | 149 | unset($p); |
| 139 | 150 | |
@@ -145,10 +156,13 @@ discard block |
||
| 145 | 156 | |
| 146 | 157 | // Quick check to make sure the length is as expected. |
| 147 | 158 | if (!$strict_check || strlen($result) == 39) |
| 148 | - return $result; |
|
| 149 | - else |
|
| 150 | - return false; |
|
| 151 | -} |
|
| 159 | + { |
|
| 160 | + return $result; |
|
| 161 | + } |
|
| 162 | + else { |
|
| 163 | + return false; |
|
| 164 | + } |
|
| 165 | + } |
|
| 152 | 166 | |
| 153 | 167 | /** |
| 154 | 168 | * Adds html entities to the array/variable. Uses two underscores to guard against overloading. |
@@ -168,11 +182,15 @@ discard block |
||
| 168 | 182 | function htmlspecialchars__recursive($var, $level = 0) |
| 169 | 183 | { |
| 170 | 184 | if (!is_array($var)) |
| 171 | - return Util::htmlspecialchars($var, ENT_QUOTES); |
|
| 185 | + { |
|
| 186 | + return Util::htmlspecialchars($var, ENT_QUOTES); |
|
| 187 | + } |
|
| 172 | 188 | |
| 173 | 189 | // Add the htmlspecialchars to every element. |
| 174 | 190 | foreach ($var as $k => $v) |
| 175 | - $var[$k] = $level > 25 ? null : htmlspecialchars__recursive($v, $level + 1); |
|
| 191 | + { |
|
| 192 | + $var[$k] = $level > 25 ? null : htmlspecialchars__recursive($v, $level + 1); |
|
| 193 | + } |
|
| 176 | 194 | |
| 177 | 195 | return $var; |
| 178 | 196 | } |
@@ -197,11 +215,15 @@ discard block |
||
| 197 | 215 | { |
| 198 | 216 | // Remove spaces (32), tabs (9), returns (13, 10, and 11), nulls (0), and hard spaces. (160) |
| 199 | 217 | if (!is_array($var)) |
| 200 | - return Util::htmltrim($var); |
|
| 218 | + { |
|
| 219 | + return Util::htmltrim($var); |
|
| 220 | + } |
|
| 201 | 221 | |
| 202 | 222 | // Go through all the elements and remove the whitespace. |
| 203 | 223 | foreach ($var as $k => $v) |
| 204 | - $var[$k] = $level > 25 ? null : htmltrim__recursive($v, $level + 1); |
|
| 224 | + { |
|
| 225 | + $var[$k] = $level > 25 ? null : htmltrim__recursive($v, $level + 1); |
|
| 226 | + } |
|
| 205 | 227 | |
| 206 | 228 | return $var; |
| 207 | 229 | } |
@@ -270,15 +292,21 @@ discard block |
||
| 270 | 292 | |
| 271 | 293 | // If $scripturl is set to nothing, or the SID is not defined (SSI?) just quit. |
| 272 | 294 | if ($scripturl == '' || !defined('SID')) |
| 273 | - return $buffer; |
|
| 295 | + { |
|
| 296 | + return $buffer; |
|
| 297 | + } |
|
| 274 | 298 | |
| 275 | 299 | // Do nothing if the session is cookied, or they are a crawler - guests are caught by redirectexit(). |
| 276 | 300 | if (empty($_COOKIE) && SID != '' && !isBrowser('possibly_robot')) |
| 277 | - $buffer = preg_replace('/(?<!<link rel="canonical" href=)"' . preg_quote($scripturl, '/') . '(?!\?' . preg_quote(SID, '/') . ')\\??/', '"' . $scripturl . '?' . SID . '&', $buffer); |
|
| 301 | + { |
|
| 302 | + $buffer = preg_replace('/(?<!<link rel="canonical" href=)"' . preg_quote($scripturl, '/') . '(?!\?' . preg_quote(SID, '/') . ')\\??/', '"' . $scripturl . '?' . SID . '&', $buffer); |
|
| 303 | + } |
|
| 278 | 304 | |
| 279 | 305 | // Debugging templates, are we? |
| 280 | 306 | elseif (isset($_GET['debug'])) |
| 281 | - $buffer = preg_replace('/(?<!<link rel="canonical" href=)"' . preg_quote($scripturl, '/') . '\\??/', '"' . $scripturl . '?debug;', $buffer); |
|
| 307 | + { |
|
| 308 | + $buffer = preg_replace('/(?<!<link rel="canonical" href=)"' . preg_quote($scripturl, '/') . '\\??/', '"' . $scripturl . '?debug;', $buffer); |
|
| 309 | + } |
|
| 282 | 310 | |
| 283 | 311 | // This should work even in 4.2.x, just not CGI without cgi.fix_pathinfo. |
| 284 | 312 | if (!empty($modSettings['queryless_urls']) && detectServer()->supportRewrite()) |
@@ -301,7 +329,10 @@ discard block |
||
| 301 | 329 | global $scripturl; |
| 302 | 330 | |
| 303 | 331 | if (!isBrowser('possibly_robot') && empty($_COOKIE) && defined('SID') && SID != '') |
| 304 | - return '"' . $scripturl . '/' . strtr($matches[1], '&;=', '//,') . '.html?' . SID . (isset($matches[2]) ? $matches[2] : '') . '"'; |
|
| 305 | - else |
|
| 306 | - return '"' . $scripturl . '/' . strtr($matches[1], '&;=', '//,') . '.html' . (isset($matches[2]) ? $matches[2] : '') . '"'; |
|
| 307 | -} |
|
| 332 | + { |
|
| 333 | + return '"' . $scripturl . '/' . strtr($matches[1], '&;=', '//,') . '.html?' . SID . (isset($matches[2]) ? $matches[2] : '') . '"'; |
|
| 334 | + } |
|
| 335 | + else { |
|
| 336 | + return '"' . $scripturl . '/' . strtr($matches[1], '&;=', '//,') . '.html' . (isset($matches[2]) ? $matches[2] : '') . '"'; |
|
| 337 | + } |
|
| 338 | + } |
|
@@ -62,9 +62,12 @@ |
||
| 62 | 62 | public function __get($key) |
| 63 | 63 | { |
| 64 | 64 | if (isset($this->data[$key])) |
| 65 | - return $this->data[$key]; |
|
| 66 | - else |
|
| 67 | - return null; |
|
| 65 | + { |
|
| 66 | + return $this->data[$key]; |
|
| 67 | + } |
|
| 68 | + else { |
|
| 69 | + return null; |
|
| 70 | + } |
|
| 68 | 71 | } |
| 69 | 72 | |
| 70 | 73 | /** |
@@ -48,14 +48,17 @@ discard block |
||
| 48 | 48 | $context['cal_maxyear'] = (int) date('Y') + (int) $modSettings['cal_limityear']; |
| 49 | 49 | |
| 50 | 50 | if (self::$_make_event) |
| 51 | - return array( |
|
| 51 | + { |
|
| 52 | + return array( |
|
| 52 | 53 | array('prepare_post', array('Calendar_Post_Module', 'prepare_post'), array()), |
| 53 | 54 | array('prepare_context', array('Calendar_Post_Module', 'prepare_context'), array()), |
| 54 | 55 | array('before_save_post', array('Calendar_Post_Module', 'before_save_post'), array()), |
| 55 | 56 | array('after_save_post', array('Calendar_Post_Module', 'after_save_post'), array()), |
| 56 | 57 | ); |
| 57 | - else |
|
| 58 | - return array(); |
|
| 58 | + } |
|
| 59 | + else { |
|
| 60 | + return array(); |
|
| 61 | + } |
|
| 59 | 62 | } |
| 60 | 63 | |
| 61 | 64 | /** |
@@ -74,7 +77,9 @@ discard block |
||
| 74 | 77 | public function before_save_post($post_errors) |
| 75 | 78 | { |
| 76 | 79 | if (!isset($_REQUEST['deleteevent']) && Util::htmltrim($_POST['evtitle']) === '') |
| 77 | - $post_errors->addError('no_event'); |
|
| 80 | + { |
|
| 81 | + $post_errors->addError('no_event'); |
|
| 82 | + } |
|
| 78 | 83 | } |
| 79 | 84 | |
| 80 | 85 | /** |
@@ -124,7 +129,9 @@ discard block |
||
| 124 | 129 | |
| 125 | 130 | // Delete it? |
| 126 | 131 | if (isset($_REQUEST['deleteevent'])) |
| 127 | - $event->remove(); |
|
| 132 | + { |
|
| 133 | + $event->remove(); |
|
| 134 | + } |
|
| 128 | 135 | // ... or just update it? |
| 129 | 136 | else |
| 130 | 137 | { |
@@ -175,7 +182,9 @@ discard block |
||
| 175 | 182 | |
| 176 | 183 | // They might want to pick a board. |
| 177 | 184 | if (!isset($context['current_board'])) |
| 178 | - $context['current_board'] = 0; |
|
| 185 | + { |
|
| 186 | + $context['current_board'] = 0; |
|
| 187 | + } |
|
| 179 | 188 | |
| 180 | 189 | // Start loading up the event info. |
| 181 | 190 | $context['event'] = array(); |
@@ -195,9 +204,13 @@ discard block |
||
| 195 | 204 | |
| 196 | 205 | // Make sure the user is allowed to edit this event. |
| 197 | 206 | if ($event_info['member'] != $user_info['id']) |
| 198 | - isAllowedTo('calendar_edit_any'); |
|
| 207 | + { |
|
| 208 | + isAllowedTo('calendar_edit_any'); |
|
| 209 | + } |
|
| 199 | 210 | elseif (!allowedTo('calendar_edit_any')) |
| 200 | - isAllowedTo('calendar_edit_own'); |
|
| 211 | + { |
|
| 212 | + isAllowedTo('calendar_edit_own'); |
|
| 213 | + } |
|
| 201 | 214 | |
| 202 | 215 | $context['event']['month'] = $event_info['month']; |
| 203 | 216 | $context['event']['day'] = $event_info['day']; |
@@ -212,35 +225,50 @@ discard block |
||
| 212 | 225 | |
| 213 | 226 | // You must have a month and year specified! |
| 214 | 227 | if (isset($_REQUEST['month'])) |
| 215 | - $context['event']['month'] = (int) $_REQUEST['month']; |
|
| 216 | - else |
|
| 217 | - $context['event']['month'] = $today['mon']; |
|
| 228 | + { |
|
| 229 | + $context['event']['month'] = (int) $_REQUEST['month']; |
|
| 230 | + } |
|
| 231 | + else { |
|
| 232 | + $context['event']['month'] = $today['mon']; |
|
| 233 | + } |
|
| 218 | 234 | |
| 219 | 235 | if (isset($_REQUEST['year'])) |
| 220 | - $context['event']['year'] = (int) $_REQUEST['year']; |
|
| 221 | - else |
|
| 222 | - $context['event']['year'] = $today['year']; |
|
| 236 | + { |
|
| 237 | + $context['event']['year'] = (int) $_REQUEST['year']; |
|
| 238 | + } |
|
| 239 | + else { |
|
| 240 | + $context['event']['year'] = $today['year']; |
|
| 241 | + } |
|
| 223 | 242 | |
| 224 | 243 | if (isset($_REQUEST['day'])) |
| 225 | - $context['event']['day'] = (int) $_REQUEST['day']; |
|
| 226 | - else |
|
| 227 | - $context['event']['day'] = $context['event']['month'] == $today['mon'] ? $today['mday'] : 0; |
|
| 244 | + { |
|
| 245 | + $context['event']['day'] = (int) $_REQUEST['day']; |
|
| 246 | + } |
|
| 247 | + else { |
|
| 248 | + $context['event']['day'] = $context['event']['month'] == $today['mon'] ? $today['mday'] : 0; |
|
| 249 | + } |
|
| 228 | 250 | |
| 229 | 251 | $context['event']['span'] = isset($_REQUEST['span']) ? $_REQUEST['span'] : 1; |
| 230 | 252 | |
| 231 | 253 | // Make sure the year and month are in the valid range. |
| 232 | 254 | if ($context['event']['month'] < 1 || $context['event']['month'] > 12) |
| 233 | - throw new Elk_Exception('invalid_month', false); |
|
| 255 | + { |
|
| 256 | + throw new Elk_Exception('invalid_month', false); |
|
| 257 | + } |
|
| 234 | 258 | |
| 235 | 259 | if ($context['event']['year'] < $modSettings['cal_minyear'] || $context['event']['year'] > (int) date('Y') + (int) $modSettings['cal_limityear']) |
| 236 | - throw new Elk_Exception('invalid_year', false); |
|
| 260 | + { |
|
| 261 | + throw new Elk_Exception('invalid_year', false); |
|
| 262 | + } |
|
| 237 | 263 | |
| 238 | 264 | // Get a list of boards they can post in. |
| 239 | 265 | require_once(SUBSDIR . '/Boards.subs.php'); |
| 240 | 266 | |
| 241 | 267 | $boards = boardsAllowedTo('post_new'); |
| 242 | 268 | if (empty($boards)) |
| 243 | - throw new Elk_Exception('cannot_post_new', 'user'); |
|
| 269 | + { |
|
| 270 | + throw new Elk_Exception('cannot_post_new', 'user'); |
|
| 271 | + } |
|
| 244 | 272 | |
| 245 | 273 | // Load a list of boards for this event in the context. |
| 246 | 274 | $boardListOptions = array( |
@@ -68,8 +68,9 @@ discard block |
||
| 68 | 68 | array('after_save_post', array('Attachments_Post_Module', 'after_save_post'), array('msgOptions')), |
| 69 | 69 | ); |
| 70 | 70 | } |
| 71 | - else |
|
| 72 | - return array(); |
|
| 71 | + else { |
|
| 72 | + return array(); |
|
| 73 | + } |
|
| 73 | 74 | } |
| 74 | 75 | |
| 75 | 76 | /** |
@@ -106,7 +107,9 @@ discard block |
||
| 106 | 107 | $context['attachments']['current'] = array(); |
| 107 | 108 | |
| 108 | 109 | if ($this->_attach_errors->hasErrors()) |
| 109 | - $post_errors->addError(array('attachments_errors' => $this->_attach_errors)); |
|
| 110 | + { |
|
| 111 | + $post_errors->addError(array('attachments_errors' => $this->_attach_errors)); |
|
| 112 | + } |
|
| 110 | 113 | } |
| 111 | 114 | |
| 112 | 115 | /** |
@@ -143,12 +146,16 @@ discard block |
||
| 143 | 146 | { |
| 144 | 147 | $attachments['quantity'] = count($context['attachments']['current']); |
| 145 | 148 | foreach ($context['attachments']['current'] as $attachment) |
| 146 | - $attachments['total_size'] += $attachment['size']; |
|
| 149 | + { |
|
| 150 | + $attachments['total_size'] += $attachment['size']; |
|
| 151 | + } |
|
| 147 | 152 | } |
| 148 | 153 | |
| 149 | 154 | // A bit of house keeping first. |
| 150 | 155 | if (!empty($_SESSION['temp_attachments']) && count($_SESSION['temp_attachments']) == 1) |
| 151 | - unset($_SESSION['temp_attachments']); |
|
| 156 | + { |
|
| 157 | + unset($_SESSION['temp_attachments']); |
|
| 158 | + } |
|
| 152 | 159 | |
| 153 | 160 | if (!empty($_SESSION['temp_attachments'])) |
| 154 | 161 | { |
@@ -175,7 +182,9 @@ discard block |
||
| 175 | 182 | foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
| 176 | 183 | { |
| 177 | 184 | if (strpos($attachID, 'post_tmp_' . $user_info['id'] . '_') === false) |
| 178 | - continue; |
|
| 185 | + { |
|
| 186 | + continue; |
|
| 187 | + } |
|
| 179 | 188 | |
| 180 | 189 | if (file_exists($attachment['tmp_name'])) |
| 181 | 190 | { |
@@ -190,9 +199,12 @@ discard block |
||
| 190 | 199 | { |
| 191 | 200 | // Since, they don't belong here. Let's inform the user that they exist.. |
| 192 | 201 | if (!empty($topic)) |
| 193 | - $delete_url = $scripturl . '?action=post' . (!empty($_REQUEST['msg']) ? (';msg=' . $_REQUEST['msg']) : '') . (!empty($_REQUEST['last_msg']) ? (';last_msg=' . $_REQUEST['last_msg']) : '') . ';topic=' . $topic . ';delete_temp'; |
|
| 194 | - else |
|
| 195 | - $delete_url = $scripturl . '?action=post;board=' . $board . ';delete_temp'; |
|
| 202 | + { |
|
| 203 | + $delete_url = $scripturl . '?action=post' . (!empty($_REQUEST['msg']) ? (';msg=' . $_REQUEST['msg']) : '') . (!empty($_REQUEST['last_msg']) ? (';last_msg=' . $_REQUEST['last_msg']) : '') . ';topic=' . $topic . ';delete_temp'; |
|
| 204 | + } |
|
| 205 | + else { |
|
| 206 | + $delete_url = $scripturl . '?action=post;board=' . $board . ';delete_temp'; |
|
| 207 | + } |
|
| 196 | 208 | |
| 197 | 209 | // Compile a list of the files to show the user. |
| 198 | 210 | $file_list = array(); |
@@ -227,11 +239,15 @@ discard block |
||
| 227 | 239 | { |
| 228 | 240 | // Skipping over these |
| 229 | 241 | if (isset($context['ignore_temp_attachments']) || isset($_SESSION['temp_attachments']['post']['files'])) |
| 230 | - break; |
|
| 242 | + { |
|
| 243 | + break; |
|
| 244 | + } |
|
| 231 | 245 | |
| 232 | 246 | // Initial errors (such as missing directory), we can recover |
| 233 | 247 | if ($attachID != 'initial_error' && strpos($attachID, 'post_tmp_' . $user_info['id'] . '_') === false) |
| 234 | - continue; |
|
| 248 | + { |
|
| 249 | + continue; |
|
| 250 | + } |
|
| 235 | 251 | |
| 236 | 252 | if ($attachID === 'initial_error') |
| 237 | 253 | { |
@@ -252,7 +268,9 @@ discard block |
||
| 252 | 268 | $txt['error_attach_errors'] = empty($txt['error_attach_errors']) ? '<br />' : ''; |
| 253 | 269 | $txt['error_attach_errors'] .= sprintf($txt['attach_warning'], $attachment['name']) . '<div class="attachmenterrors">'; |
| 254 | 270 | foreach ($attachment['errors'] as $error) |
| 255 | - $txt['error_attach_errors'] .= (is_array($error) ? vsprintf($txt[$error[0]], $error[1]) : $txt[$error]) . '<br />'; |
|
| 271 | + { |
|
| 272 | + $txt['error_attach_errors'] .= (is_array($error) ? vsprintf($txt[$error[0]], $error[1]) : $txt[$error]) . '<br />'; |
|
| 273 | + } |
|
| 256 | 274 | $txt['error_attach_errors'] .= '</div>'; |
| 257 | 275 | $this->_attach_errors->addError('attach_errors'); |
| 258 | 276 | } |
@@ -275,7 +293,9 @@ discard block |
||
| 275 | 293 | $attachments['total_size'] += $attachment['size']; |
| 276 | 294 | |
| 277 | 295 | if (!isset($context['files_in_session_warning'])) |
| 278 | - $context['files_in_session_warning'] = $txt['attached_files_in_session']; |
|
| 296 | + { |
|
| 297 | + $context['files_in_session_warning'] = $txt['attached_files_in_session']; |
|
| 298 | + } |
|
| 279 | 299 | |
| 280 | 300 | $context['attachments']['current'][] = array( |
| 281 | 301 | 'name' => '<span class="underline">' . htmlspecialchars($attachment['name'], ENT_COMPAT, 'UTF-8') . '</span>', |
@@ -312,9 +332,12 @@ discard block |
||
| 312 | 332 | $context['attachments']['quantity'] = $attachments['quantity']; |
| 313 | 333 | $context['attachments']['restrictions'] = array(); |
| 314 | 334 | if (!empty($modSettings['attachmentCheckExtensions'])) |
| 315 | - $context['attachments']['allowed_extensions'] = strtr(strtolower($modSettings['attachmentExtensions']), array(',' => ', ')); |
|
| 316 | - else |
|
| 317 | - $context['attachments']['allowed_extensions'] = ''; |
|
| 335 | + { |
|
| 336 | + $context['attachments']['allowed_extensions'] = strtr(strtolower($modSettings['attachmentExtensions']), array(',' => ', ')); |
|
| 337 | + } |
|
| 338 | + else { |
|
| 339 | + $context['attachments']['allowed_extensions'] = ''; |
|
| 340 | + } |
|
| 318 | 341 | $context['attachments']['template'] = 'template_add_new_attachments'; |
| 319 | 342 | |
| 320 | 343 | $attachmentRestrictionTypes = array('attachmentNumPerPostLimit', 'attachmentPostLimit', 'attachmentSizeLimit'); |
@@ -328,9 +351,13 @@ discard block |
||
| 328 | 351 | |
| 329 | 352 | // Show some numbers. |
| 330 | 353 | if ($type === 'attachmentNumPerPostLimit') |
| 331 | - $context['attachments']['restrictions'][] = sprintf($txt['attach_remaining'], '<span id="' . $type . '">' . ($modSettings['attachmentNumPerPostLimit'] - $attachments['quantity']) . '</span>'); |
|
| 354 | + { |
|
| 355 | + $context['attachments']['restrictions'][] = sprintf($txt['attach_remaining'], '<span id="' . $type . '">' . ($modSettings['attachmentNumPerPostLimit'] - $attachments['quantity']) . '</span>'); |
|
| 356 | + } |
|
| 332 | 357 | elseif ($type === 'attachmentPostLimit') |
| 333 | - $context['attachments']['restrictions'][] = sprintf($txt['attach_available'], '<span id="' . $type . '">' . byte_format(max(($modSettings['attachmentPostLimit'] * 1024) - $attachments['total_size'], 0)) . '</span>'); |
|
| 358 | + { |
|
| 359 | + $context['attachments']['restrictions'][] = sprintf($txt['attach_available'], '<span id="' . $type . '">' . byte_format(max(($modSettings['attachmentPostLimit'] * 1024) - $attachments['total_size'], 0)) . '</span>'); |
|
| 360 | + } |
|
| 334 | 361 | } |
| 335 | 362 | } |
| 336 | 363 | } |
@@ -352,7 +379,9 @@ discard block |
||
| 352 | 379 | $this->saveAttachments($msg); |
| 353 | 380 | |
| 354 | 381 | if ($this->_attach_errors->hasErrors()) |
| 355 | - $post_errors->addError(array('attachments_errors' => $this->_attach_errors)); |
|
| 382 | + { |
|
| 383 | + $post_errors->addError(array('attachments_errors' => $this->_attach_errors)); |
|
| 384 | + } |
|
| 356 | 385 | } |
| 357 | 386 | |
| 358 | 387 | /** |
@@ -377,9 +406,12 @@ discard block |
||
| 377 | 406 | $attachID = getAttachmentIdFromPublic($dummy); |
| 378 | 407 | |
| 379 | 408 | if (strpos($attachID, 'post_tmp_' . $user_info['id'] . '_') !== false) |
| 380 | - $keep_temp[] = $attachID; |
|
| 381 | - else |
|
| 382 | - $keep_ids[] = (int) $attachID; |
|
| 409 | + { |
|
| 410 | + $keep_temp[] = $attachID; |
|
| 411 | + } |
|
| 412 | + else { |
|
| 413 | + $keep_ids[] = (int) $attachID; |
|
| 414 | + } |
|
| 383 | 415 | } |
| 384 | 416 | |
| 385 | 417 | if (isset($_SESSION['temp_attachments'])) |
@@ -387,7 +419,9 @@ discard block |
||
| 387 | 419 | foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
| 388 | 420 | { |
| 389 | 421 | 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) |
| 390 | - continue; |
|
| 422 | + { |
|
| 423 | + continue; |
|
| 424 | + } |
|
| 391 | 425 | |
| 392 | 426 | unset($_SESSION['temp_attachments'][$attachID]); |
| 393 | 427 | @unlink($attachment['tmp_name']); |
@@ -412,9 +446,12 @@ discard block |
||
| 412 | 446 | { |
| 413 | 447 | require_once(SUBSDIR . '/Attachments.subs.php'); |
| 414 | 448 | if (!empty($msg)) |
| 415 | - processAttachments((int) $msg); |
|
| 416 | - else |
|
| 417 | - processAttachments(); |
|
| 449 | + { |
|
| 450 | + processAttachments((int) $msg); |
|
| 451 | + } |
|
| 452 | + else { |
|
| 453 | + processAttachments(); |
|
| 454 | + } |
|
| 418 | 455 | } |
| 419 | 456 | } |
| 420 | 457 | |
@@ -437,7 +474,9 @@ discard block |
||
| 437 | 474 | foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
| 438 | 475 | { |
| 439 | 476 | if ($attachID !== 'initial_error' && strpos($attachID, 'post_tmp_' . $user_info['id'] . '_') === false) |
| 440 | - continue; |
|
| 477 | + { |
|
| 478 | + continue; |
|
| 479 | + } |
|
| 441 | 480 | |
| 442 | 481 | // If there was an initial error just show that message. |
| 443 | 482 | if ($attachID === 'initial_error') |
@@ -466,7 +505,9 @@ discard block |
||
| 466 | 505 | { |
| 467 | 506 | $this->_saved_attach_id[] = $attachmentOptions['id']; |
| 468 | 507 | if (!empty($attachmentOptions['thumb'])) |
| 469 | - $this->_saved_attach_id[] = $attachmentOptions['thumb']; |
|
| 508 | + { |
|
| 509 | + $this->_saved_attach_id[] = $attachmentOptions['thumb']; |
|
| 510 | + } |
|
| 470 | 511 | |
| 471 | 512 | $msgOptions['body'] = preg_replace('~\[attachurl(?:.*?)\]' . $attachment['public_attachid'] . '\[\/attachurl\]~', '[attachurl]' . $attachmentOptions['id'] . '[/attachurl]', $msgOptions['body']); |
| 472 | 513 | $msgOptions['body'] = preg_replace('~\[attach(.*?)\]' . $attachment['public_attachid'] . '\[\/attach\]~', '[attach$1]' . $attachmentOptions['id'] . '[/attach]', $msgOptions['body']); |
@@ -482,7 +523,9 @@ discard block |
||
| 482 | 523 | } |
| 483 | 524 | |
| 484 | 525 | if (!empty($this->_saved_attach_id) && $msgOptions['icon'] === 'xx') |
| 485 | - $msgOptions['icon'] = 'clip'; |
|
| 526 | + { |
|
| 527 | + $msgOptions['icon'] = 'clip'; |
|
| 528 | + } |
|
| 486 | 529 | } |
| 487 | 530 | |
| 488 | 531 | /** |
@@ -493,6 +536,8 @@ discard block |
||
| 493 | 536 | public function after_save_post($msgOptions) |
| 494 | 537 | { |
| 495 | 538 | if ($this->_is_new_message && !empty($this->_saved_attach_id)) |
| 496 | - bindMessageAttachments($msgOptions['id'], $this->_saved_attach_id); |
|
| 539 | + { |
|
| 540 | + bindMessageAttachments($msgOptions['id'], $this->_saved_attach_id); |
|
| 541 | + } |
|
| 497 | 542 | } |
| 498 | 543 | } |
@@ -162,7 +162,9 @@ discard block |
||
| 162 | 162 | { |
| 163 | 163 | // Un-wordwrap the email, create a line by line array broken on the newlines |
| 164 | 164 | if ($bbc_br === true) |
| 165 | - $data = str_replace('[br]', "\n", $data); |
|
| 165 | + { |
|
| 166 | + $data = str_replace('[br]', "\n", $data); |
|
| 167 | + } |
|
| 166 | 168 | $temp = explode("\n", $data); |
| 167 | 169 | |
| 168 | 170 | // Remove any 'stuck' whitespace using the trim value function on all lines |
@@ -219,19 +221,24 @@ discard block |
||
| 219 | 221 | $this->_body_array[$i - 1]['content'] = $this->_body_array[$i - 1]['content'] . "\n"; |
| 220 | 222 | $this->_in_list = 0; |
| 221 | 223 | } |
| 222 | - else |
|
| 223 | - $this->_body_array[$i]['content'] = ' ' . trim($this->_body_array[$i]['content']); |
|
| 224 | + else { |
|
| 225 | + $this->_body_array[$i]['content'] = ' ' . trim($this->_body_array[$i]['content']); |
|
| 226 | + } |
|
| 224 | 227 | } |
| 225 | 228 | |
| 226 | 229 | // Long line in a sig ... but not a link then lets bail out might be a ps or something |
| 227 | 230 | if ($this->_found_sig && ($this->_body_array[$i]['length'] > $this->_sig_longline) && (substr($this->_body_array[$i]['content'], 0, 4) !== 'www.')) |
| 228 | - $this->_found_sig = false; |
|
| 231 | + { |
|
| 232 | + $this->_found_sig = false; |
|
| 233 | + } |
|
| 229 | 234 | |
| 230 | 235 | // Blank line, if its not two in a row and not the start of a bbc code then insert a newline |
| 231 | 236 | if ($this->_body_array[$i]['content'] == '') |
| 232 | 237 | { |
| 233 | 238 | if ((isset($this->_body_array[$i - 1])) && ($this->_body_array[$i - 1]['content'] !== "\n") && (substr($this->_body_array[$i - 1]['content'], 0, 1) !== '[') && ($this->_body_array[$i - 1]['length'] > $this->_maillist_short_line)) |
| 234 | - $this->_body_array[$i]['content'] = "\n\n"; |
|
| 239 | + { |
|
| 240 | + $this->_body_array[$i]['content'] = "\n\n"; |
|
| 241 | + } |
|
| 235 | 242 | } |
| 236 | 243 | // Lists like a. a) 1. 1) |
| 237 | 244 | elseif ($this->_body_array[$i]['list_item']) |
@@ -249,9 +256,12 @@ discard block |
||
| 249 | 256 | elseif (!empty($this->_maillist_leftover_remove) && preg_match('~^((\[b\]){0,2}(' . $this->_maillist_leftover_remove . ')(\[\/b\]){0,2})~', $this->_body_array[$i]['content'])) |
| 250 | 257 | { |
| 251 | 258 | if ($this->_in_quote) |
| 252 | - $this->_body_array[$i]['content'] = "\n"; |
|
| 253 | - else |
|
| 254 | - $this->_body_array[$i]['content'] = $this->_body_array[$i]['content'] . "\n"; |
|
| 259 | + { |
|
| 260 | + $this->_body_array[$i]['content'] = "\n"; |
|
| 261 | + } |
|
| 262 | + else { |
|
| 263 | + $this->_body_array[$i]['content'] = $this->_body_array[$i]['content'] . "\n"; |
|
| 264 | + } |
|
| 255 | 265 | } |
| 256 | 266 | // Line starts with a link ..... |
| 257 | 267 | elseif (in_array(substr($this->_body_array[$i]['content'], 0, 4), array('www.', 'WWW.', 'http', 'HTTP'))) |
@@ -270,9 +280,12 @@ discard block |
||
| 270 | 280 | { |
| 271 | 281 | // Its a wrap ... maybe |
| 272 | 282 | if ($i > 0) |
| 273 | - $para_check = $this->_body_array[$i]['length'] - $this->_body_array[$i - 1]['length']; |
|
| 274 | - else |
|
| 275 | - $para_check = 1; |
|
| 283 | + { |
|
| 284 | + $para_check = $this->_body_array[$i]['length'] - $this->_body_array[$i - 1]['length']; |
|
| 285 | + } |
|
| 286 | + else { |
|
| 287 | + $para_check = 1; |
|
| 288 | + } |
|
| 276 | 289 | |
| 277 | 290 | // If this line is longer than the line above it we need to do some extra checks |
| 278 | 291 | if (($i > 0) && ($this->_body_array[$i - 1]['length'] > $this->_maillist_short_line) && !$this->_found_sig && !$this->_in_code && !$this->_in_bbclist) |
@@ -280,28 +293,40 @@ discard block |
||
| 280 | 293 | // If the previous short line did not end in a period or it did and the next line does not start |
| 281 | 294 | // with a capital and passes para check then it wraps |
| 282 | 295 | if ((substr($this->_body_array[$i - 1]['content'], -1) !== '.') || (substr($this->_body_array[$i - 1]['content'], -1) === '.' && $para_check < $this->_para_check && ($this->_body_array[$i]['content'][0] !== strtoupper($this->_body_array[$i]['content'][0])))) |
| 283 | - $this->_body_array[$i]['content'] .= ''; |
|
| 284 | - else |
|
| 285 | - $this->_body_array[$i]['content'] = "\n" . $this->_body_array[$i]['content']; |
|
| 296 | + { |
|
| 297 | + $this->_body_array[$i]['content'] .= ''; |
|
| 298 | + } |
|
| 299 | + else { |
|
| 300 | + $this->_body_array[$i]['content'] = "\n" . $this->_body_array[$i]['content']; |
|
| 301 | + } |
|
| 286 | 302 | } |
| 287 | 303 | elseif ($para_check < 5) |
| 288 | - $this->_body_array[$i]['content'] = "\n" . $this->_body_array[$i]['content']; |
|
| 304 | + { |
|
| 305 | + $this->_body_array[$i]['content'] = "\n" . $this->_body_array[$i]['content']; |
|
| 306 | + } |
|
| 289 | 307 | // A very short line (but not a empty one) followed by a very long line |
| 290 | 308 | elseif (isset($this->_body_array[$i - 1]) && !empty($this->_body_array[$i - 1]['content']) && $para_check > $this->_sig_longline && $this->_body_array[$i - 1]['length'] < 3) |
| 291 | - $this->_body_array[$i]['content'] .= ''; |
|
| 292 | - else |
|
| 293 | - $this->_body_array[$i]['content'] = "\n\n" . $this->_body_array[$i]['content']; |
|
| 309 | + { |
|
| 310 | + $this->_body_array[$i]['content'] .= ''; |
|
| 311 | + } |
|
| 312 | + else { |
|
| 313 | + $this->_body_array[$i]['content'] = "\n\n" . $this->_body_array[$i]['content']; |
|
| 314 | + } |
|
| 294 | 315 | } |
| 295 | 316 | } |
| 296 | 317 | |
| 297 | 318 | // Close any open quotes we may have left behind |
| 298 | 319 | for ($quotes = 1; $quotes <= $this->_in_quote; $quotes++) |
| 299 | - $this->_body_array[$i + $quotes]['content'] = '[/quote]'; |
|
| 320 | + { |
|
| 321 | + $this->_body_array[$i + $quotes]['content'] = '[/quote]'; |
|
| 322 | + } |
|
| 300 | 323 | |
| 301 | 324 | // Join the message back together while dropping null index's |
| 302 | 325 | $temp = array(); |
| 303 | 326 | foreach ($this->_body_array as $key => $values) |
| 304 | - $temp[] = $values['content']; |
|
| 327 | + { |
|
| 328 | + $temp[] = $values['content']; |
|
| 329 | + } |
|
| 305 | 330 | $this->_body = trim(implode(' ', array_values($temp))); |
| 306 | 331 | } |
| 307 | 332 | |
@@ -354,7 +379,9 @@ discard block |
||
| 354 | 379 | |
| 355 | 380 | // Any htmlenties that we want to remove, like ms smart ones? |
| 356 | 381 | if (preg_match('~“|”|–|—|‘|’~', $this->_body)) |
| 357 | - $this->_body = html_entity_decode($this->_body, ENT_QUOTES, 'UTF-8'); |
|
| 382 | + { |
|
| 383 | + $this->_body = html_entity_decode($this->_body, ENT_QUOTES, 'UTF-8'); |
|
| 384 | + } |
|
| 358 | 385 | |
| 359 | 386 | // Avoid double encoding later on |
| 360 | 387 | $this->_body = htmlspecialchars_decode($this->_body, ENT_QUOTES); |
@@ -364,7 +391,9 @@ discard block |
||
| 364 | 391 | |
| 365 | 392 | // And its 1252 variants |
| 366 | 393 | if (strcasecmp($charset, 'UTF-8') !== 0) |
| 367 | - $this->_body = strtr($this->_body, array(chr(145) => "'", chr(146) => "'", chr(147) => '"', chr(148) => '"', chr(150) => '-', chr(151) => '--', chr(133) => '...')); |
|
| 394 | + { |
|
| 395 | + $this->_body = strtr($this->_body, array(chr(145) => "'", chr(146) => "'", chr(147) => '"', chr(148) => '"', chr(150) => '-', chr(151) => '--', chr(133) => '...')); |
|
| 396 | + } |
|
| 368 | 397 | } |
| 369 | 398 | |
| 370 | 399 | /** |
@@ -381,10 +410,14 @@ discard block |
||
| 381 | 410 | { |
| 382 | 411 | // Make sure it is not a single line quote |
| 383 | 412 | if (!preg_match('~\[/quote\]?~', $var)) |
| 384 | - $this->_in_quote++; |
|
| 413 | + { |
|
| 414 | + $this->_in_quote++; |
|
| 415 | + } |
|
| 385 | 416 | } |
| 386 | 417 | elseif (preg_match('~\[/quote\]?~', $var)) |
| 387 | - $this->_in_quote--; |
|
| 418 | + { |
|
| 419 | + $this->_in_quote--; |
|
| 420 | + } |
|
| 388 | 421 | } |
| 389 | 422 | |
| 390 | 423 | /** |
@@ -396,13 +429,19 @@ discard block |
||
| 396 | 429 | { |
| 397 | 430 | // Not in a sig yet, the line starts with a sig key as defined by the ACP, and its a short line of text |
| 398 | 431 | if (!$this->_found_sig && !empty($this->_maillist_sig_keys) && (preg_match('~^(' . $this->_maillist_sig_keys . ')~i', $this->_body_array[$i]['content']) && ($this->_body_array[$i]['length'] < $this->_maillist_short_line))) |
| 399 | - return true; |
|
| 432 | + { |
|
| 433 | + return true; |
|
| 434 | + } |
|
| 400 | 435 | // The line is simply just their name |
| 401 | 436 | elseif (($this->_body_array[$i]['content'] === $this->_real_name) && !$this->_found_sig) |
| 402 | - return true; |
|
| 437 | + { |
|
| 438 | + return true; |
|
| 439 | + } |
|
| 403 | 440 | // check for universal sig dashes |
| 404 | 441 | elseif (!$this->_found_sig && preg_match('~^-- \n~m', $this->_body_array[$i]['content'])) |
| 405 | - return true; |
|
| 442 | + { |
|
| 443 | + return true; |
|
| 444 | + } |
|
| 406 | 445 | |
| 407 | 446 | return false; |
| 408 | 447 | } |
@@ -421,10 +460,14 @@ discard block |
||
| 421 | 460 | { |
| 422 | 461 | // Make sure it is not a single line code |
| 423 | 462 | if (!preg_match('~\[/code\]?~', $var)) |
| 424 | - $this->_in_code++; |
|
| 463 | + { |
|
| 464 | + $this->_in_code++; |
|
| 465 | + } |
|
| 425 | 466 | } |
| 426 | 467 | elseif (preg_match('~\[/code\]?~', $var)) |
| 427 | - $this->_in_code--; |
|
| 468 | + { |
|
| 469 | + $this->_in_code--; |
|
| 470 | + } |
|
| 428 | 471 | } |
| 429 | 472 | |
| 430 | 473 | /** |
@@ -438,10 +481,14 @@ discard block |
||
| 438 | 481 | { |
| 439 | 482 | // Starting a bbc list |
| 440 | 483 | if (preg_match('~\[list\]?~', $var)) |
| 441 | - $this->_in_bbclist++; |
|
| 484 | + { |
|
| 485 | + $this->_in_bbclist++; |
|
| 486 | + } |
|
| 442 | 487 | // Ending a bbc list |
| 443 | 488 | elseif (preg_match('~\[\/list\]?~', $var)) |
| 444 | - $this->_in_bbclist--; |
|
| 489 | + { |
|
| 490 | + $this->_in_bbclist--; |
|
| 491 | + } |
|
| 445 | 492 | } |
| 446 | 493 | |
| 447 | 494 | /** |
@@ -460,7 +507,9 @@ discard block |
||
| 460 | 507 | || preg_match('~' . chr(187) . '~', $var) |
| 461 | 508 | || preg_match('~^[ \t]?\* ?~m', $var) |
| 462 | 509 | ) |
| 463 | - $this->_in_plainlist++; |
|
| 510 | + { |
|
| 511 | + $this->_in_plainlist++; |
|
| 512 | + } |
|
| 464 | 513 | |
| 465 | 514 | return $this->_in_plainlist !== $temp; |
| 466 | 515 | } |
@@ -1383,7 +1383,9 @@ |
||
| 1383 | 1383 | { |
| 1384 | 1384 | $string = base64_decode($string); |
| 1385 | 1385 | if (isset($this->headers['content-type']) && strpos($this->headers['content-type'], 'text/') === false) |
| 1386 | - return $string; |
|
| 1386 | + { |
|
| 1387 | + return $string; |
|
| 1388 | + } |
|
| 1387 | 1389 | } |
| 1388 | 1390 | |
| 1389 | 1391 | // Convert this to utf-8 if needed. |
@@ -54,7 +54,9 @@ discard block |
||
| 54 | 54 | |
| 55 | 55 | // The function is not even on ... |
| 56 | 56 | if (empty($modSettings['maillist_enabled'])) |
| 57 | - return false; |
|
| 57 | + { |
|
| 58 | + return false; |
|
| 59 | + } |
|
| 58 | 60 | |
| 59 | 61 | // Our mail parser and our main subs |
| 60 | 62 | require_once(SUBSDIR . '/Emailpost.subs.php'); |
@@ -67,7 +69,9 @@ discard block |
||
| 67 | 69 | $email_message = new Email_Parse(); |
| 68 | 70 | $email_message->read_data($data, BOARDDIR); |
| 69 | 71 | if (!$email_message->raw_message) |
| 70 | - return false; |
|
| 72 | + { |
|
| 73 | + return false; |
|
| 74 | + } |
|
| 71 | 75 | |
| 72 | 76 | // Ask for an html version (if available) and some needed details |
| 73 | 77 | $email_message->read_email(true, $email_message->raw_message); |
@@ -101,11 +105,15 @@ discard block |
||
| 101 | 105 | |
| 102 | 106 | // If the feature is on but the post/pm function is not enabled, just log the message. |
| 103 | 107 | if (empty($modSettings['pbe_post_enabled']) && empty($modSettings['pbe_pm_enabled'])) |
| 104 | - return pbe_emailError('error_email_notenabled', $email_message); |
|
| 108 | + { |
|
| 109 | + return pbe_emailError('error_email_notenabled', $email_message); |
|
| 110 | + } |
|
| 105 | 111 | |
| 106 | 112 | // Spam I am? |
| 107 | 113 | if ($email_message->load_spam() && !$force) |
| 108 | - return pbe_emailError('error_found_spam', $email_message); |
|
| 114 | + { |
|
| 115 | + return pbe_emailError('error_found_spam', $email_message); |
|
| 116 | + } |
|
| 109 | 117 | |
| 110 | 118 | // Load the user from the database based on the sending email address |
| 111 | 119 | $email_message->email['from'] = !empty($email_message->email['from']) ? strtolower($email_message->email['from']) : ''; |
@@ -113,11 +121,15 @@ discard block |
||
| 113 | 121 | |
| 114 | 122 | // Can't find this email in our database, a non-user, a spammer, a looser, a poser or even worse? |
| 115 | 123 | if (empty($pbe)) |
| 116 | - return pbe_emailError('error_not_find_member', $email_message); |
|
| 124 | + { |
|
| 125 | + return pbe_emailError('error_not_find_member', $email_message); |
|
| 126 | + } |
|
| 117 | 127 | |
| 118 | 128 | // Find the message security key, without it we are not going anywhere ever |
| 119 | 129 | if (empty($email_message->message_key_id)) |
| 120 | - return pbe_emailError('error_missing_key', $email_message); |
|
| 130 | + { |
|
| 131 | + return pbe_emailError('error_missing_key', $email_message); |
|
| 132 | + } |
|
| 121 | 133 | |
| 122 | 134 | require_once(SUBSDIR . '/Emailpost.subs.php'); |
| 123 | 135 | // Good we have a key, who was it sent to? |
@@ -126,15 +138,21 @@ discard block |
||
| 126 | 138 | // Can't find this key in the database, either |
| 127 | 139 | // a) spam attempt or b) replying with an expired/consumed key |
| 128 | 140 | if (empty($key_owner) && !$force) |
| 129 | - return pbe_emailError('error_' . ($email_message->message_type === 'p' ? 'pm_' : '') . 'not_find_entry', $email_message); |
|
| 141 | + { |
|
| 142 | + return pbe_emailError('error_' . ($email_message->message_type === 'p' ? 'pm_' : '') . 'not_find_entry', $email_message); |
|
| 143 | + } |
|
| 130 | 144 | |
| 131 | 145 | // The key received was not sent to this member ... how we love those email aggregators |
| 132 | 146 | if (strtolower($key_owner) !== $email_message->email['from'] && !$force) |
| 133 | - return pbe_emailError('error_key_sender_match', $email_message); |
|
| 147 | + { |
|
| 148 | + return pbe_emailError('error_key_sender_match', $email_message); |
|
| 149 | + } |
|
| 134 | 150 | |
| 135 | 151 | // In maintenance mode, just log it for now |
| 136 | 152 | if (!empty($maintenance) && $maintenance !== 2 && !$pbe['user_info']['is_admin'] && !$user_info['is_admin']) |
| 137 | - return pbe_emailError('error_in_maintenance_mode', $email_message); |
|
| 153 | + { |
|
| 154 | + return pbe_emailError('error_in_maintenance_mode', $email_message); |
|
| 155 | + } |
|
| 138 | 156 | |
| 139 | 157 | // The email looks valid, now on to check the actual user trying to make the post/pm |
| 140 | 158 | // lets load the topic/message info and any additional permissions we need |
@@ -145,7 +163,9 @@ discard block |
||
| 145 | 163 | // Load the message/topic details |
| 146 | 164 | $topic_info = query_load_message($email_message->message_type, $email_message->message_id, $pbe); |
| 147 | 165 | if (empty($topic_info)) |
| 148 | - return pbe_emailError('error_topic_gone', $email_message); |
|
| 166 | + { |
|
| 167 | + return pbe_emailError('error_topic_gone', $email_message); |
|
| 168 | + } |
|
| 149 | 169 | |
| 150 | 170 | // Load board permissions |
| 151 | 171 | query_load_permissions('board', $pbe, $topic_info); |
@@ -170,7 +190,9 @@ discard block |
||
| 170 | 190 | |
| 171 | 191 | // Load in the correct Re: for the language |
| 172 | 192 | if ($language === $pbe['user_info']['language']) |
| 173 | - $pbe['response_prefix'] = $txt['response_prefix']; |
|
| 193 | + { |
|
| 194 | + $pbe['response_prefix'] = $txt['response_prefix']; |
|
| 195 | + } |
|
| 174 | 196 | else |
| 175 | 197 | { |
| 176 | 198 | loadLanguage('index', $language, false); |
@@ -194,10 +216,14 @@ discard block |
||
| 194 | 216 | |
| 195 | 217 | // Time to make a Post or a PM, first up topic and message replies |
| 196 | 218 | if ($email_message->message_type === 't' || $email_message->message_type === 'm') |
| 197 | - $result = pbe_create_post($pbe, $email_message, $topic_info); |
|
| 219 | + { |
|
| 220 | + $result = pbe_create_post($pbe, $email_message, $topic_info); |
|
| 221 | + } |
|
| 198 | 222 | // Must be a PM then |
| 199 | 223 | elseif ($email_message->message_type === 'p') |
| 200 | - $result = pbe_create_pm($pbe, $email_message, $pm_info); |
|
| 224 | + { |
|
| 225 | + $result = pbe_create_pm($pbe, $email_message, $pm_info); |
|
| 226 | + } |
|
| 201 | 227 | |
| 202 | 228 | if (!empty($result)) |
| 203 | 229 | { |
@@ -230,7 +256,9 @@ discard block |
||
| 230 | 256 | |
| 231 | 257 | // The function is not even on ... |
| 232 | 258 | if (empty($modSettings['maillist_enabled'])) |
| 233 | - return false; |
|
| 259 | + { |
|
| 260 | + return false; |
|
| 261 | + } |
|
| 234 | 262 | |
| 235 | 263 | // Our mail parser and our main subs |
| 236 | 264 | require_once(SUBSDIR . '/Emailpost.subs.php'); |
@@ -243,7 +271,9 @@ discard block |
||
| 243 | 271 | $email_message = new Email_Parse(); |
| 244 | 272 | $email_message->read_data($data, BOARDDIR); |
| 245 | 273 | if (!$email_message->raw_message) |
| 246 | - return false; |
|
| 274 | + { |
|
| 275 | + return false; |
|
| 276 | + } |
|
| 247 | 277 | |
| 248 | 278 | // Parse the header and some needed details |
| 249 | 279 | $email_message->read_email(true, $email_message->raw_message); |
@@ -284,7 +314,9 @@ discard block |
||
| 284 | 314 | |
| 285 | 315 | // If the feature is on but the post/pm function is not enabled, just log the message. |
| 286 | 316 | if (empty($modSettings['pbe_post_enabled'])) |
| 287 | - return pbe_emailError('error_email_notenabled', $email_message); |
|
| 317 | + { |
|
| 318 | + return pbe_emailError('error_email_notenabled', $email_message); |
|
| 319 | + } |
|
| 288 | 320 | |
| 289 | 321 | // Load the user from the database based on the sending email address |
| 290 | 322 | $email_message->email['from'] = !empty($email_message->email['from']) ? strtolower($email_message->email['from']) : ''; |
@@ -292,20 +324,28 @@ discard block |
||
| 292 | 324 | |
| 293 | 325 | // Can't find this email as one of our users? |
| 294 | 326 | if (empty($pbe)) |
| 295 | - return pbe_emailError('error_not_find_member', $email_message); |
|
| 327 | + { |
|
| 328 | + return pbe_emailError('error_not_find_member', $email_message); |
|
| 329 | + } |
|
| 296 | 330 | |
| 297 | 331 | // Getting hammy with it? |
| 298 | 332 | if ($email_message->load_spam()) |
| 299 | - return pbe_emailError('error_found_spam', $email_message); |
|
| 333 | + { |
|
| 334 | + return pbe_emailError('error_found_spam', $email_message); |
|
| 335 | + } |
|
| 300 | 336 | |
| 301 | 337 | // The board that this email address corresponds to |
| 302 | 338 | $board_number = pbe_find_board_number($email_message); |
| 303 | 339 | if (empty($board_number)) |
| 304 | - return pbe_emailError('error_not_find_board', $email_message); |
|
| 340 | + { |
|
| 341 | + return pbe_emailError('error_not_find_board', $email_message); |
|
| 342 | + } |
|
| 305 | 343 | |
| 306 | 344 | // In maintenance mode so just save it for the moderators to deal with |
| 307 | 345 | if (!empty($maintenance) && $maintenance !== 2 && !$pbe['user_info']['is_admin'] && !$user_info['is_admin']) |
| 308 | - return pbe_emailError('error_in_maintenance_mode', $email_message); |
|
| 346 | + { |
|
| 347 | + return pbe_emailError('error_in_maintenance_mode', $email_message); |
|
| 348 | + } |
|
| 309 | 349 | |
| 310 | 350 | // Any additional spam / security checking |
| 311 | 351 | call_integration_hook('integrate_mailist_checks_before', array($email_message, $pbe)); |
@@ -313,7 +353,9 @@ discard block |
||
| 313 | 353 | // To post a NEW topic, we need some board details for where it goes |
| 314 | 354 | $board_info = query_load_board_details($board_number, $pbe); |
| 315 | 355 | if (empty($board_info)) |
| 316 | - return pbe_emailError('error_board_gone', $email_message); |
|
| 356 | + { |
|
| 357 | + return pbe_emailError('error_board_gone', $email_message); |
|
| 358 | + } |
|
| 317 | 359 | |
| 318 | 360 | // Load up this users permissions for that board |
| 319 | 361 | query_load_permissions('board', $pbe, $board_info); |
@@ -353,7 +395,9 @@ discard block |
||
| 353 | 395 | $email_message = new Email_Parse(); |
| 354 | 396 | $email_message->read_data($data, BOARDDIR); |
| 355 | 397 | if (!$email_message->raw_message) |
| 356 | - return false; |
|
| 398 | + { |
|
| 399 | + return false; |
|
| 400 | + } |
|
| 357 | 401 | |
| 358 | 402 | // Ask for an html version (if available) and some needed details |
| 359 | 403 | $email_message->read_email(true, $email_message->raw_message); |
@@ -369,13 +413,18 @@ discard block |
||
| 369 | 413 | if (!empty($email_message->attachments) && !empty($modSettings['maillist_allow_attachments']) && !empty($modSettings['attachmentEnable']) && $modSettings['attachmentEnable'] == 1) |
| 370 | 414 | { |
| 371 | 415 | if ($email_message->message_type === 'p') |
| 372 | - $text .= "\n\n" . $txt['error_no_pm_attach'] . "\n"; |
|
| 373 | - else |
|
| 374 | - $attachment_count = count($email_message->attachments); |
|
| 416 | + { |
|
| 417 | + $text .= "\n\n" . $txt['error_no_pm_attach'] . "\n"; |
|
| 418 | + } |
|
| 419 | + else { |
|
| 420 | + $attachment_count = count($email_message->attachments); |
|
| 421 | + } |
|
| 375 | 422 | } |
| 376 | 423 | |
| 377 | 424 | if ($attachment_count) |
| 378 | - $text .= "\n\n" . sprintf($txt['email_attachments'], $attachment_count); |
|
| 425 | + { |
|
| 426 | + $text .= "\n\n" . sprintf($txt['email_attachments'], $attachment_count); |
|
| 427 | + } |
|
| 379 | 428 | |
| 380 | 429 | // Return the parsed and formatted body and who it was sent to for the template |
| 381 | 430 | return array('body' => $text, 'to' => implode(' & ', $email_message->email['to']) . (!empty($email_message->email['cc']) ? ', ' . implode(' & ', $email_message->email['cc']) : '')); |
@@ -404,37 +453,54 @@ discard block |
||
| 404 | 453 | // Validate they have permission to reply |
| 405 | 454 | $becomesApproved = true; |
| 406 | 455 | if (!in_array('postby_email', $pbe['user_info']['permissions']) && !$pbe['user_info']['is_admin']) |
| 407 | - return pbe_emailError('error_permission', $email_message); |
|
| 456 | + { |
|
| 457 | + return pbe_emailError('error_permission', $email_message); |
|
| 458 | + } |
|
| 408 | 459 | elseif ($topic_info['locked'] && !$pbe['user_info']['is_admin'] && !in_array('moderate_forum', $pbe['user_info']['permissions'])) |
| 409 | - return pbe_emailError('error_locked', $email_message); |
|
| 460 | + { |
|
| 461 | + return pbe_emailError('error_locked', $email_message); |
|
| 462 | + } |
|
| 410 | 463 | elseif ($topic_info['id_member_started'] === $pbe['profile']['id_member'] && !$pbe['user_info']['is_admin']) |
| 411 | 464 | { |
| 412 | 465 | if ($modSettings['postmod_active'] && in_array('post_unapproved_replies_any', $pbe['user_info']['permissions']) && (!in_array('post_reply_any', $pbe['user_info']['permissions']))) |
| 413 | - $becomesApproved = false; |
|
| 466 | + { |
|
| 467 | + $becomesApproved = false; |
|
| 468 | + } |
|
| 414 | 469 | elseif (!in_array('post_reply_own', $pbe['user_info']['permissions'])) |
| 415 | - return pbe_emailError('error_cant_reply', $email_message); |
|
| 470 | + { |
|
| 471 | + return pbe_emailError('error_cant_reply', $email_message); |
|
| 472 | + } |
|
| 416 | 473 | } |
| 417 | 474 | elseif (!$pbe['user_info']['is_admin']) |
| 418 | 475 | { |
| 419 | 476 | if ($modSettings['postmod_active'] && in_array('post_unapproved_replies_any', $pbe['user_info']['permissions']) && (!in_array('post_reply_any', $pbe['user_info']['permissions']))) |
| 420 | - $becomesApproved = false; |
|
| 477 | + { |
|
| 478 | + $becomesApproved = false; |
|
| 479 | + } |
|
| 421 | 480 | elseif (!in_array('post_reply_any', $pbe['user_info']['permissions'])) |
| 422 | - return pbe_emailError('error_cant_reply', $email_message); |
|
| 481 | + { |
|
| 482 | + return pbe_emailError('error_cant_reply', $email_message); |
|
| 483 | + } |
|
| 423 | 484 | } |
| 424 | 485 | |
| 425 | 486 | // Convert to BBC and Format the message |
| 426 | 487 | $html = $email_message->html_found; |
| 427 | 488 | $text = pbe_load_text($html, $email_message, $pbe); |
| 428 | 489 | if (empty($text)) |
| 429 | - return pbe_emailError('error_no_message', $email_message); |
|
| 490 | + { |
|
| 491 | + return pbe_emailError('error_no_message', $email_message); |
|
| 492 | + } |
|
| 430 | 493 | |
| 431 | 494 | // Seriously? Attachments? |
| 432 | 495 | if (!empty($email_message->attachments) && !empty($modSettings['maillist_allow_attachments']) && !empty($modSettings['attachmentEnable']) && $modSettings['attachmentEnable'] == 1) |
| 433 | 496 | { |
| 434 | 497 | if (($modSettings['postmod_active'] && in_array('post_unapproved_attachments', $pbe['user_info']['permissions'])) || in_array('post_attachment', $pbe['user_info']['permissions'])) |
| 435 | - $attachIDs = pbe_email_attachments($pbe, $email_message); |
|
| 436 | - else |
|
| 437 | - $text .= "\n\n" . $txt['error_no_attach'] . "\n"; |
|
| 498 | + { |
|
| 499 | + $attachIDs = pbe_email_attachments($pbe, $email_message); |
|
| 500 | + } |
|
| 501 | + else { |
|
| 502 | + $text .= "\n\n" . $txt['error_no_attach'] . "\n"; |
|
| 503 | + } |
|
| 438 | 504 | } |
| 439 | 505 | |
| 440 | 506 | // Setup the post variables. |
@@ -511,17 +577,23 @@ discard block |
||
| 511 | 577 | |
| 512 | 578 | // Can they send? |
| 513 | 579 | if (!$pbe['user_info']['is_admin'] && !in_array('pm_send', $pbe['user_info']['permissions'])) |
| 514 | - return pbe_emailError('error_pm_not_allowed', $email_message); |
|
| 580 | + { |
|
| 581 | + return pbe_emailError('error_pm_not_allowed', $email_message); |
|
| 582 | + } |
|
| 515 | 583 | |
| 516 | 584 | // Convert the PM to BBC and Format the message |
| 517 | 585 | $html = $email_message->html_found; |
| 518 | 586 | $text = pbe_load_text($html, $email_message, $pbe); |
| 519 | 587 | if (empty($text)) |
| 520 | - return pbe_emailError('error_no_message', $email_message); |
|
| 588 | + { |
|
| 589 | + return pbe_emailError('error_no_message', $email_message); |
|
| 590 | + } |
|
| 521 | 591 | |
| 522 | 592 | // If they tried to attach a file, just say sorry |
| 523 | 593 | if (!empty($email_message->attachments) && !empty($modSettings['maillist_allow_attachments']) && !empty($modSettings['attachmentEnable']) && $modSettings['attachmentEnable'] == 1) |
| 524 | - $text .= "\n\n" . $txt['error_no_pm_attach'] . "\n"; |
|
| 594 | + { |
|
| 595 | + $text .= "\n\n" . $txt['error_no_pm_attach'] . "\n"; |
|
| 596 | + } |
|
| 525 | 597 | |
| 526 | 598 | // For sending the message... |
| 527 | 599 | $from = array( |
@@ -538,7 +610,9 @@ discard block |
||
| 538 | 610 | |
| 539 | 611 | // Assuming all went well, mark this as read, replied to and update the unread counter |
| 540 | 612 | if (!empty($pm_result)) |
| 541 | - query_mark_pms($email_message, $pbe); |
|
| 613 | + { |
|
| 614 | + query_mark_pms($email_message, $pbe); |
|
| 615 | + } |
|
| 542 | 616 | |
| 543 | 617 | return !empty($pm_result); |
| 544 | 618 | } |
@@ -568,23 +642,33 @@ discard block |
||
| 568 | 642 | |
| 569 | 643 | // It does not work like that |
| 570 | 644 | if (empty($pbe) || empty($email_message)) |
| 571 | - return false; |
|
| 645 | + { |
|
| 646 | + return false; |
|
| 647 | + } |
|
| 572 | 648 | |
| 573 | 649 | // We have the board info, and their permissions - do they have a right to start a new topic? |
| 574 | 650 | $becomesApproved = true; |
| 575 | 651 | if (!$pbe['user_info']['is_admin']) |
| 576 | 652 | { |
| 577 | 653 | if (!in_array('postby_email', $pbe['user_info']['permissions'])) |
| 578 | - return pbe_emailError('error_permission', $email_message); |
|
| 654 | + { |
|
| 655 | + return pbe_emailError('error_permission', $email_message); |
|
| 656 | + } |
|
| 579 | 657 | elseif ($modSettings['postmod_active'] && in_array('post_unapproved_topics', $pbe['user_info']['permissions']) && (!in_array('post_new', $pbe['user_info']['permissions']))) |
| 580 | - $becomesApproved = false; |
|
| 658 | + { |
|
| 659 | + $becomesApproved = false; |
|
| 660 | + } |
|
| 581 | 661 | elseif (!in_array('post_new', $pbe['user_info']['permissions'])) |
| 582 | - return pbe_emailError('error_cant_start', $email_message); |
|
| 662 | + { |
|
| 663 | + return pbe_emailError('error_cant_start', $email_message); |
|
| 664 | + } |
|
| 583 | 665 | } |
| 584 | 666 | |
| 585 | 667 | // Approving all new topics by email anyway, smart admin this one is ;) |
| 586 | 668 | if (!empty($modSettings['maillist_newtopic_needsapproval'])) |
| 587 | - $becomesApproved = false; |
|
| 669 | + { |
|
| 670 | + $becomesApproved = false; |
|
| 671 | + } |
|
| 588 | 672 | |
| 589 | 673 | // First on the agenda the subject |
| 590 | 674 | $subject = pbe_clean_email_subject($email_message->subject); |
@@ -592,23 +676,32 @@ discard block |
||
| 592 | 676 | |
| 593 | 677 | // Not to long not to short |
| 594 | 678 | if (Util::strlen($subject) > 100) |
| 595 | - $subject = Util::substr($subject, 0, 100); |
|
| 679 | + { |
|
| 680 | + $subject = Util::substr($subject, 0, 100); |
|
| 681 | + } |
|
| 596 | 682 | elseif ($subject == '') |
| 597 | - return pbe_emailError('error_no_subject', $email_message); |
|
| 683 | + { |
|
| 684 | + return pbe_emailError('error_no_subject', $email_message); |
|
| 685 | + } |
|
| 598 | 686 | |
| 599 | 687 | // The message itself will need a bit of work |
| 600 | 688 | $html = $email_message->html_found; |
| 601 | 689 | $text = pbe_load_text($html, $email_message, $pbe); |
| 602 | 690 | if (empty($text)) |
| 603 | - return pbe_emailError('error_no_message', $email_message); |
|
| 691 | + { |
|
| 692 | + return pbe_emailError('error_no_message', $email_message); |
|
| 693 | + } |
|
| 604 | 694 | |
| 605 | 695 | // Build the attachment array if needed |
| 606 | 696 | if (!empty($email_message->attachments) && !empty($modSettings['maillist_allow_attachments']) && !empty($modSettings['attachmentEnable']) && $modSettings['attachmentEnable'] == 1) |
| 607 | 697 | { |
| 608 | 698 | if (($modSettings['postmod_active'] && in_array('post_unapproved_attachments', $pbe['user_info']['permissions'])) || in_array('post_attachment', $pbe['user_info']['permissions'])) |
| 609 | - $attachIDs = pbe_email_attachments($pbe, $email_message); |
|
| 610 | - else |
|
| 611 | - $text .= "\n\n" . $txt['error_no_attach'] . "\n"; |
|
| 699 | + { |
|
| 700 | + $attachIDs = pbe_email_attachments($pbe, $email_message); |
|
| 701 | + } |
|
| 702 | + else { |
|
| 703 | + $text .= "\n\n" . $txt['error_no_attach'] . "\n"; |
|
| 704 | + } |
|
| 612 | 705 | } |
| 613 | 706 | |
| 614 | 707 | // If we get to this point ... then its time to play, lets start a topic ! |
@@ -688,8 +781,9 @@ discard block |
||
| 688 | 781 | $text = $email_message->plain_body; |
| 689 | 782 | $html = false; |
| 690 | 783 | } |
| 691 | - else |
|
| 692 | - $text = un_htmlspecialchars($email_message->body); |
|
| 784 | + else { |
|
| 785 | + $text = un_htmlspecialchars($email_message->body); |
|
| 786 | + } |
|
| 693 | 787 | |
| 694 | 788 | // Run filters now, before the data is manipulated |
| 695 | 789 | $text = pbe_filter_email_message($text); |
@@ -703,7 +797,9 @@ discard block |
||
| 703 | 797 | // Do we even have a message left to post? |
| 704 | 798 | $text = Util::htmltrim($text); |
| 705 | 799 | if (empty($text)) |
| 706 | - return ''; |
|
| 800 | + { |
|
| 801 | + return ''; |
|
| 802 | + } |
|
| 707 | 803 | |
| 708 | 804 | // This will be taken care of by sendpm |
| 709 | 805 | if ($email_message->message_type !== 'p') |
@@ -95,7 +95,9 @@ discard block |
||
| 95 | 95 | $context['last_ip'] = $user_profile[$this->_memID]['member_ip']; |
| 96 | 96 | |
| 97 | 97 | if ($context['last_ip'] != $user_profile[$this->_memID]['member_ip2']) |
| 98 | - $context['last_ip2'] = $user_profile[$this->_memID]['member_ip2']; |
|
| 98 | + { |
|
| 99 | + $context['last_ip2'] = $user_profile[$this->_memID]['member_ip2']; |
|
| 100 | + } |
|
| 99 | 101 | |
| 100 | 102 | $context['member']['name'] = $user_profile[$this->_memID]['real_name']; |
| 101 | 103 | |
@@ -184,10 +186,14 @@ discard block |
||
| 184 | 186 | $context['error_ips'] = array(); |
| 185 | 187 | |
| 186 | 188 | foreach ($ips['message_ips'] as $ip) |
| 187 | - $context['ips'][] = '<a href="' . $scripturl . '?action=profile;area=history;sa=ip;searchip=' . $ip . ';u=' . $this->_memID . '">' . $ip . '</a>'; |
|
| 189 | + { |
|
| 190 | + $context['ips'][] = '<a href="' . $scripturl . '?action=profile;area=history;sa=ip;searchip=' . $ip . ';u=' . $this->_memID . '">' . $ip . '</a>'; |
|
| 191 | + } |
|
| 188 | 192 | |
| 189 | 193 | foreach ($ips['error_ips'] as $ip) |
| 190 | - $context['error_ips'][] = '<a href="' . $scripturl . '?action=profile;area=history;sa=ip;searchip=' . $ip . ';u=' . $this->_memID . '">' . $ip . '</a>'; |
|
| 194 | + { |
|
| 195 | + $context['error_ips'][] = '<a href="' . $scripturl . '?action=profile;area=history;sa=ip;searchip=' . $ip . ';u=' . $this->_memID . '">' . $ip . '</a>'; |
|
| 196 | + } |
|
| 191 | 197 | |
| 192 | 198 | // Find other users that might use the same IP. |
| 193 | 199 | $context['members_in_range'] = array(); |
@@ -197,7 +203,9 @@ discard block |
||
| 197 | 203 | { |
| 198 | 204 | $members_in_range = getMembersInRange($all_ips, $this->_memID); |
| 199 | 205 | foreach ($members_in_range as $row) |
| 200 | - $context['members_in_range'][$row['id_member']] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
| 206 | + { |
|
| 207 | + $context['members_in_range'][$row['id_member']] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
| 208 | + } |
|
| 201 | 209 | } |
| 202 | 210 | |
| 203 | 211 | loadTemplate('ProfileHistory'); |
@@ -234,7 +242,9 @@ discard block |
||
| 234 | 242 | |
| 235 | 243 | // Searching? |
| 236 | 244 | if (isset($this->_req->query->searchip)) |
| 237 | - $context['ip'] = trim($this->_req->query->searchip); |
|
| 245 | + { |
|
| 246 | + $context['ip'] = trim($this->_req->query->searchip); |
|
| 247 | + } |
|
| 238 | 248 | |
| 239 | 249 | if (preg_match('/^\d{1,3}\.(\d{1,3}|\*)\.(\d{1,3}|\*)\.(\d{1,3}|\*)$/', $context['ip']) == 0 |
| 240 | 250 | && isValidIPv6($context['ip']) === false) |
@@ -246,7 +256,9 @@ discard block |
||
| 246 | 256 | $ip_string = strpos($ip_var, '%') === false ? '= {string:ip_address}' : 'LIKE {string:ip_address}'; |
| 247 | 257 | |
| 248 | 258 | if (empty($context['history_area'])) |
| 249 | - $context['page_title'] = $txt['trackIP'] . ' - ' . $context['ip']; |
|
| 259 | + { |
|
| 260 | + $context['page_title'] = $txt['trackIP'] . ' - ' . $context['ip']; |
|
| 261 | + } |
|
| 250 | 262 | |
| 251 | 263 | // Fetch the members that are associated with the ip's |
| 252 | 264 | require_once(SUBSDIR . '/Members.subs.php'); |
@@ -471,9 +483,12 @@ discard block |
||
| 471 | 483 | global $scripturl, $txt, $context; |
| 472 | 484 | |
| 473 | 485 | if ($this->_memID == 0) |
| 474 | - $context['base_url'] = $scripturl . '?action=trackip'; |
|
| 475 | - else |
|
| 476 | - $context['base_url'] = $scripturl . '?action=profile;area=history;sa=ip;u=' . $this->_memID; |
|
| 486 | + { |
|
| 487 | + $context['base_url'] = $scripturl . '?action=trackip'; |
|
| 488 | + } |
|
| 489 | + else { |
|
| 490 | + $context['base_url'] = $scripturl . '?action=profile;area=history;sa=ip;u=' . $this->_memID; |
|
| 491 | + } |
|
| 477 | 492 | |
| 478 | 493 | // Start with the user messages. |
| 479 | 494 | $listOptions = array( |
@@ -34,7 +34,9 @@ discard block |
||
| 34 | 34 | if ($topic) |
| 35 | 35 | { |
| 36 | 36 | if (isset($_SESSION['last_topic_id']) && $_SESSION['last_topic_id'] == $topic) |
| 37 | - $force = false; |
|
| 37 | + { |
|
| 38 | + $force = false; |
|
| 39 | + } |
|
| 38 | 40 | $_SESSION['last_topic_id'] = $topic; |
| 39 | 41 | } |
| 40 | 42 | } |
@@ -48,7 +50,9 @@ discard block |
||
| 48 | 50 | |
| 49 | 51 | // Don't mark them as online more than every so often. |
| 50 | 52 | if (!empty($_SESSION['log_time']) && $_SESSION['log_time'] >= (time() - 8) && !$force) |
| 51 | - return; |
|
| 53 | + { |
|
| 54 | + return; |
|
| 55 | + } |
|
| 52 | 56 | |
| 53 | 57 | if (!empty($modSettings['who_enabled'])) |
| 54 | 58 | { |
@@ -56,13 +60,16 @@ discard block |
||
| 56 | 60 | |
| 57 | 61 | // In the case of a dlattach action, session_var may not be set. |
| 58 | 62 | if (!isset($context['session_var'])) |
| 59 | - $context['session_var'] = $_SESSION['session_var']; |
|
| 63 | + { |
|
| 64 | + $context['session_var'] = $_SESSION['session_var']; |
|
| 65 | + } |
|
| 60 | 66 | |
| 61 | 67 | unset($serialized['sesc'], $serialized[$context['session_var']]); |
| 62 | 68 | $serialized = serialize($serialized); |
| 63 | 69 | } |
| 64 | - else |
|
| 65 | - $serialized = ''; |
|
| 70 | + else { |
|
| 71 | + $serialized = ''; |
|
| 72 | + } |
|
| 66 | 73 | |
| 67 | 74 | // Guests use 0, members use their session ID. |
| 68 | 75 | $session_id = $user_info['is_guest'] ? 'ip' . $user_info['ip'] : session_id(); |
@@ -87,19 +94,24 @@ discard block |
||
| 87 | 94 | |
| 88 | 95 | updateLogOnline($session_id, $serialized); |
| 89 | 96 | } |
| 90 | - else |
|
| 91 | - $_SESSION['log_time'] = 0; |
|
| 97 | + else { |
|
| 98 | + $_SESSION['log_time'] = 0; |
|
| 99 | + } |
|
| 92 | 100 | |
| 93 | 101 | // Otherwise, we have to delete and insert. |
| 94 | 102 | if (empty($_SESSION['log_time'])) |
| 95 | - insertdeleteLogOnline($session_id, $serialized, $do_delete); |
|
| 103 | + { |
|
| 104 | + insertdeleteLogOnline($session_id, $serialized, $do_delete); |
|
| 105 | + } |
|
| 96 | 106 | |
| 97 | 107 | // Mark your session as being logged. |
| 98 | 108 | $_SESSION['log_time'] = time(); |
| 99 | 109 | |
| 100 | 110 | // Well, they are online now. |
| 101 | 111 | if (empty($_SESSION['timeOnlineUpdated'])) |
| 102 | - $_SESSION['timeOnlineUpdated'] = time(); |
|
| 112 | + { |
|
| 113 | + $_SESSION['timeOnlineUpdated'] = time(); |
|
| 114 | + } |
|
| 103 | 115 | |
| 104 | 116 | // Set their login time, if not already done within the last minute. |
| 105 | 117 | if (ELK != 'SSI' && !empty($user_info['last_login']) && $user_info['last_login'] < time() - 60) |
@@ -109,14 +121,18 @@ discard block |
||
| 109 | 121 | |
| 110 | 122 | // Don't count longer than 15 minutes. |
| 111 | 123 | if (time() - $_SESSION['timeOnlineUpdated'] > 60 * 15) |
| 112 | - $_SESSION['timeOnlineUpdated'] = time(); |
|
| 124 | + { |
|
| 125 | + $_SESSION['timeOnlineUpdated'] = time(); |
|
| 126 | + } |
|
| 113 | 127 | |
| 114 | 128 | $user_settings['total_time_logged_in'] += time() - $_SESSION['timeOnlineUpdated']; |
| 115 | 129 | require_once(SUBSDIR . '/Members.subs.php'); |
| 116 | 130 | updateMemberData($user_info['id'], array('last_login' => time(), 'member_ip' => $user_info['ip'], 'member_ip2' => $req->ban_ip(), 'total_time_logged_in' => $user_settings['total_time_logged_in'])); |
| 117 | 131 | |
| 118 | 132 | if ($cache->levelHigherThan(1)) |
| 119 | - $cache->put('user_settings-' . $user_info['id'], $user_settings, 60); |
|
| 133 | + { |
|
| 134 | + $cache->put('user_settings-' . $user_info['id'], $user_settings, 60); |
|
| 135 | + } |
|
| 120 | 136 | |
| 121 | 137 | $user_info['total_time_logged_in'] += time() - $_SESSION['timeOnlineUpdated']; |
| 122 | 138 | $_SESSION['timeOnlineUpdated'] = time(); |
@@ -182,12 +198,18 @@ discard block |
||
| 182 | 198 | static $cache_stats = array(); |
| 183 | 199 | |
| 184 | 200 | if (empty($modSettings['trackStats'])) |
| 185 | - return false; |
|
| 201 | + { |
|
| 202 | + return false; |
|
| 203 | + } |
|
| 186 | 204 | |
| 187 | 205 | if (!empty($stats)) |
| 188 | - return $cache_stats = array_merge($cache_stats, $stats); |
|
| 206 | + { |
|
| 207 | + return $cache_stats = array_merge($cache_stats, $stats); |
|
| 208 | + } |
|
| 189 | 209 | elseif (empty($cache_stats)) |
| 190 | - return false; |
|
| 210 | + { |
|
| 211 | + return false; |
|
| 212 | + } |
|
| 191 | 213 | |
| 192 | 214 | $setStringUpdate = array(); |
| 193 | 215 | $insert_keys = array(); |
@@ -202,9 +224,12 @@ discard block |
||
| 202 | 224 | $setStringUpdate[] = $field . ' = ' . ($change === '+' ? $field . ' + 1' : '{int:' . $field . '}'); |
| 203 | 225 | |
| 204 | 226 | if ($change === '+') |
| 205 | - $cache_stats[$field] = 1; |
|
| 206 | - else |
|
| 207 | - $update_parameters[$field] = $change; |
|
| 227 | + { |
|
| 228 | + $cache_stats[$field] = 1; |
|
| 229 | + } |
|
| 230 | + else { |
|
| 231 | + $update_parameters[$field] = $change; |
|
| 232 | + } |
|
| 208 | 233 | |
| 209 | 234 | $insert_keys[$field] = 'int'; |
| 210 | 235 | } |
@@ -271,38 +296,50 @@ discard block |
||
| 271 | 296 | |
| 272 | 297 | // No point in doing anything, if the log isn't even enabled. |
| 273 | 298 | if (empty($modSettings['modlog_enabled'])) |
| 274 | - return false; |
|
| 299 | + { |
|
| 300 | + return false; |
|
| 301 | + } |
|
| 275 | 302 | |
| 276 | 303 | foreach ($logs as $log) |
| 277 | 304 | { |
| 278 | 305 | if (!isset($log_types[$log['log_type']])) |
| 279 | - continue; |
|
| 306 | + { |
|
| 307 | + continue; |
|
| 308 | + } |
|
| 280 | 309 | |
| 281 | 310 | // Do we have something to log here, after all? |
| 282 | 311 | if (!is_array($log['extra'])) |
| 283 | - trigger_error('logActions(): data is not an array with action \'' . $log['action'] . '\'', E_USER_NOTICE); |
|
| 312 | + { |
|
| 313 | + trigger_error('logActions(): data is not an array with action \'' . $log['action'] . '\'', E_USER_NOTICE); |
|
| 314 | + } |
|
| 284 | 315 | |
| 285 | 316 | // Pull out the parts we want to store separately, but also make sure that the data is proper |
| 286 | 317 | if (isset($log['extra']['topic'])) |
| 287 | 318 | { |
| 288 | 319 | if (!is_numeric($log['extra']['topic'])) |
| 289 | - trigger_error('logActions(): data\'s topic is not a number', E_USER_NOTICE); |
|
| 320 | + { |
|
| 321 | + trigger_error('logActions(): data\'s topic is not a number', E_USER_NOTICE); |
|
| 322 | + } |
|
| 290 | 323 | |
| 291 | 324 | $topic_id = empty($log['extra']['topic']) ? 0 : (int) $log['extra']['topic']; |
| 292 | 325 | unset($log['extra']['topic']); |
| 293 | 326 | } |
| 294 | - else |
|
| 295 | - $topic_id = 0; |
|
| 327 | + else { |
|
| 328 | + $topic_id = 0; |
|
| 329 | + } |
|
| 296 | 330 | |
| 297 | 331 | if (isset($log['extra']['message'])) |
| 298 | 332 | { |
| 299 | 333 | if (!is_numeric($log['extra']['message'])) |
| 300 | - trigger_error('logActions(): data\'s message is not a number', E_USER_NOTICE); |
|
| 334 | + { |
|
| 335 | + trigger_error('logActions(): data\'s message is not a number', E_USER_NOTICE); |
|
| 336 | + } |
|
| 301 | 337 | $msg_id = empty($log['extra']['message']) ? 0 : (int) $log['extra']['message']; |
| 302 | 338 | unset($log['extra']['message']); |
| 303 | 339 | } |
| 304 | - else |
|
| 305 | - $msg_id = 0; |
|
| 340 | + else { |
|
| 341 | + $msg_id = 0; |
|
| 342 | + } |
|
| 306 | 343 | |
| 307 | 344 | // @todo cache this? |
| 308 | 345 | // Is there an associated report on this? |
@@ -318,23 +355,30 @@ discard block |
||
| 318 | 355 | } |
| 319 | 356 | |
| 320 | 357 | if (isset($log['extra']['member']) && !is_numeric($log['extra']['member'])) |
| 321 | - trigger_error('logActions(): data\'s member is not a number', E_USER_NOTICE); |
|
| 358 | + { |
|
| 359 | + trigger_error('logActions(): data\'s member is not a number', E_USER_NOTICE); |
|
| 360 | + } |
|
| 322 | 361 | |
| 323 | 362 | if (isset($log['extra']['board'])) |
| 324 | 363 | { |
| 325 | 364 | if (!is_numeric($log['extra']['board'])) |
| 326 | - trigger_error('logActions(): data\'s board is not a number', E_USER_NOTICE); |
|
| 365 | + { |
|
| 366 | + trigger_error('logActions(): data\'s board is not a number', E_USER_NOTICE); |
|
| 367 | + } |
|
| 327 | 368 | |
| 328 | 369 | $board_id = empty($log['extra']['board']) ? 0 : (int) $log['extra']['board']; |
| 329 | 370 | unset($log['extra']['board']); |
| 330 | 371 | } |
| 331 | - else |
|
| 332 | - $board_id = 0; |
|
| 372 | + else { |
|
| 373 | + $board_id = 0; |
|
| 374 | + } |
|
| 333 | 375 | |
| 334 | 376 | if (isset($log['extra']['board_to'])) |
| 335 | 377 | { |
| 336 | 378 | if (!is_numeric($log['extra']['board_to'])) |
| 337 | - trigger_error('logActions(): data\'s board_to is not a number', E_USER_NOTICE); |
|
| 379 | + { |
|
| 380 | + trigger_error('logActions(): data\'s board_to is not a number', E_USER_NOTICE); |
|
| 381 | + } |
|
| 338 | 382 | |
| 339 | 383 | if (empty($board_id)) |
| 340 | 384 | { |
@@ -344,9 +388,12 @@ discard block |
||
| 344 | 388 | } |
| 345 | 389 | |
| 346 | 390 | if (isset($log['extra']['member_affected'])) |
| 347 | - $memID = $log['extra']['member_affected']; |
|
| 348 | - else |
|
| 349 | - $memID = $user_info['id']; |
|
| 391 | + { |
|
| 392 | + $memID = $log['extra']['member_affected']; |
|
| 393 | + } |
|
| 394 | + else { |
|
| 395 | + $memID = $user_info['id']; |
|
| 396 | + } |
|
| 350 | 397 | |
| 351 | 398 | $inserts[] = array( |
| 352 | 399 | time(), $log_types[$log['log_type']], $memID, $user_info['ip'], $log['action'], |