@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | // Just send a generic message. |
| 77 | 77 | else |
| 78 | 78 | $this->setResponse(array( |
| 79 | - 'text' => $this->_sa == 'add' ? 'attach_error_title' : 'attached_file_deleted_error', |
|
| 79 | + 'text' => $this->_sa == 'add' ? 'attach_error_title' : 'attached_file_deleted_error', |
|
| 80 | 80 | 'type' => 'error', |
| 81 | 81 | 'data' => false, |
| 82 | 82 | )); |
@@ -404,7 +404,7 @@ discard block |
||
| 404 | 404 | // Gotta urlencode the filename. |
| 405 | 405 | if ($this->_attachResults) |
| 406 | 406 | foreach ($this->_attachResults as $k => $v) |
| 407 | - $this->_attachResults[$k]['name'] = urlencode($this->_attachResults[$k]['name']); |
|
| 407 | + $this->_attachResults[$k]['name'] = urlencode($this->_attachResults[$k]['name']); |
|
| 408 | 408 | |
| 409 | 409 | $this->_response = array( |
| 410 | 410 | 'files' => $this->_attachResults ? $this->_attachResults : false, |
@@ -431,7 +431,7 @@ discard block |
||
| 431 | 431 | ob_start(); |
| 432 | 432 | |
| 433 | 433 | // Set the header. |
| 434 | - header('Content-Type: application/json; charset='. $context['character_set'] .''); |
|
| 434 | + header('Content-Type: application/json; charset=' . $context['character_set'] . ''); |
|
| 435 | 435 | |
| 436 | 436 | echo json_encode($this->_response ? $this->_response : array()); |
| 437 | 437 | |
@@ -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 | // Regardless of errors, pass the results. |
@@ -378,8 +401,9 @@ discard block |
||
| 378 | 401 | } |
| 379 | 402 | |
| 380 | 403 | // Temp save this on the db. |
| 381 | - if (!empty($_SESSION['already_attached'])) |
|
| 382 | - $this->_attachSuccess = $_SESSION['already_attached']; |
|
| 404 | + if (!empty($_SESSION['already_attached'])) { |
|
| 405 | + $this->_attachSuccess = $_SESSION['already_attached']; |
|
| 406 | + } |
|
| 383 | 407 | |
| 384 | 408 | unset($_SESSION['temp_attachments']); |
| 385 | 409 | } |
@@ -399,14 +423,16 @@ discard block |
||
| 399 | 423 | if ($this->_sa == 'add') |
| 400 | 424 | { |
| 401 | 425 | // Is there any generic errors? made some sense out of them! |
| 402 | - if ($this->_generalErrors) |
|
| 403 | - foreach ($this->_generalErrors as $k => $v) |
|
| 426 | + if ($this->_generalErrors) { |
|
| 427 | + foreach ($this->_generalErrors as $k => $v) |
|
| 404 | 428 | $this->_generalErrors[$k] = (is_array($v) ? vsprintf($txt[$v[0]], $v[1]) : $txt[$v]); |
| 429 | + } |
|
| 405 | 430 | |
| 406 | 431 | // Gotta urlencode the filename. |
| 407 | - if ($this->_attachResults) |
|
| 408 | - foreach ($this->_attachResults as $k => $v) |
|
| 432 | + if ($this->_attachResults) { |
|
| 433 | + foreach ($this->_attachResults as $k => $v) |
|
| 409 | 434 | $this->_attachResults[$k]['name'] = urlencode($this->_attachResults[$k]['name']); |
| 435 | + } |
|
| 410 | 436 | |
| 411 | 437 | $this->_response = array( |
| 412 | 438 | 'files' => $this->_attachResults ? $this->_attachResults : false, |
@@ -415,9 +441,10 @@ discard block |
||
| 415 | 441 | } |
| 416 | 442 | |
| 417 | 443 | // Rest of us mere mortals gets no special treatment... |
| 418 | - elseif (!empty($data)) |
|
| 419 | - if (!empty($data['text']) && !empty($txt[$data['text']])) |
|
| 444 | + elseif (!empty($data)) { |
|
| 445 | + if (!empty($data['text']) && !empty($txt[$data['text']])) |
|
| 420 | 446 | $this->_response['text'] = $txt[$data['text']]; |
| 447 | + } |
|
| 421 | 448 | } |
| 422 | 449 | |
| 423 | 450 | protected function sendResponse() |
@@ -426,11 +453,11 @@ discard block |
||
| 426 | 453 | |
| 427 | 454 | ob_end_clean(); |
| 428 | 455 | |
| 429 | - if (!empty($modSettings['CompressedOutput'])) |
|
| 430 | - @ob_start('ob_gzhandler'); |
|
| 431 | - |
|
| 432 | - else |
|
| 433 | - ob_start(); |
|
| 456 | + if (!empty($modSettings['CompressedOutput'])) { |
|
| 457 | + @ob_start('ob_gzhandler'); |
|
| 458 | + } else { |
|
| 459 | + ob_start(); |
|
| 460 | + } |
|
| 434 | 461 | |
| 435 | 462 | // Set the header. |
| 436 | 463 | header('Content-Type: application/json; charset='. $context['character_set'] .''); |
@@ -61,7 +61,7 @@ |
||
| 61 | 61 | $server = trim($servers[array_rand($servers)]); |
| 62 | 62 | |
| 63 | 63 | // Normal host names do not contain slashes, while e.g. unix sockets do. Assume alternative transport pipe with port 0. |
| 64 | - if (strpos($server,'/') !== false) |
|
| 64 | + if (strpos($server, '/') !== false) |
|
| 65 | 65 | $host = $server; |
| 66 | 66 | else |
| 67 | 67 | { |
@@ -11,8 +11,9 @@ discard block |
||
| 11 | 11 | * @version 2.1 Beta 4 |
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | -if (!defined('SMF')) |
|
| 14 | +if (!defined('SMF')) { |
|
| 15 | 15 | die('Hacking attempt...'); |
| 16 | +} |
|
| 16 | 17 | |
| 17 | 18 | /** |
| 18 | 19 | * Our Cache API class |
@@ -34,8 +35,9 @@ discard block |
||
| 34 | 35 | |
| 35 | 36 | $supported = class_exists('memcache'); |
| 36 | 37 | |
| 37 | - if ($test) |
|
| 38 | - return $supported; |
|
| 38 | + if ($test) { |
|
| 39 | + return $supported; |
|
| 40 | + } |
|
| 39 | 41 | return parent::isSupported() && $supported && !empty($cache_memcached); |
| 40 | 42 | } |
| 41 | 43 | |
@@ -61,9 +63,9 @@ discard block |
||
| 61 | 63 | $server = trim($servers[array_rand($servers)]); |
| 62 | 64 | |
| 63 | 65 | // Normal host names do not contain slashes, while e.g. unix sockets do. Assume alternative transport pipe with port 0. |
| 64 | - if (strpos($server,'/') !== false) |
|
| 65 | - $host = $server; |
|
| 66 | - else |
|
| 66 | + if (strpos($server,'/') !== false) { |
|
| 67 | + $host = $server; |
|
| 68 | + } else |
|
| 67 | 69 | { |
| 68 | 70 | $server = explode(':', $server); |
| 69 | 71 | $host = $server[0]; |
@@ -71,10 +73,11 @@ discard block |
||
| 71 | 73 | } |
| 72 | 74 | |
| 73 | 75 | // Don't wait too long: yes, we want the server, but we might be able to run the query faster! |
| 74 | - if (empty($db_persist)) |
|
| 75 | - $connected = $this->memcache->connect($host, $port); |
|
| 76 | - else |
|
| 77 | - $connected = $this->memcache->pconnect($host, $port); |
|
| 76 | + if (empty($db_persist)) { |
|
| 77 | + $connected = $this->memcache->connect($host, $port); |
|
| 78 | + } else { |
|
| 79 | + $connected = $this->memcache->pconnect($host, $port); |
|
| 80 | + } |
|
| 78 | 81 | } |
| 79 | 82 | |
| 80 | 83 | return $connected; |
@@ -90,8 +93,9 @@ discard block |
||
| 90 | 93 | $value = $this->memcache->get($key); |
| 91 | 94 | |
| 92 | 95 | // $value should return either data or false (from failure, key not found or empty array). |
| 93 | - if ($value === false) |
|
| 94 | - return null; |
|
| 96 | + if ($value === false) { |
|
| 97 | + return null; |
|
| 98 | + } |
|
| 95 | 99 | return $value; |
| 96 | 100 | } |
| 97 | 101 | |
@@ -132,8 +136,9 @@ discard block |
||
| 132 | 136 | $config_vars[] = $txt['cache_memcache_settings']; |
| 133 | 137 | $config_vars[] = array('cache_memcached', $txt['cache_memcache_servers'], 'file', 'text', 0, 'cache_memcached', 'postinput' => '<br /><div class="smalltext"><em>' . $txt['cache_memcache_servers_subtext'] . '</em></div>'); |
| 134 | 138 | |
| 135 | - if (!isset($context['settings_post_javascript'])) |
|
| 136 | - $context['settings_post_javascript'] = ''; |
|
| 139 | + if (!isset($context['settings_post_javascript'])) { |
|
| 140 | + $context['settings_post_javascript'] = ''; |
|
| 141 | + } |
|
| 137 | 142 | |
| 138 | 143 | $context['settings_post_javascript'] .= ' |
| 139 | 144 | $("#cache_accelerator").change(function (e) { |
@@ -19,10 +19,10 @@ |
||
| 19 | 19 | */ |
| 20 | 20 | class GroupAct_Notify_Background extends SMF_BackgroundTask |
| 21 | 21 | { |
| 22 | - /** |
|
| 23 | - * This executes the task - loads up the information, puts the email in the queue and inserts alerts as needed. |
|
| 24 | - * @return bool Always returns true |
|
| 25 | - */ |
|
| 22 | + /** |
|
| 23 | + * This executes the task - loads up the information, puts the email in the queue and inserts alerts as needed. |
|
| 24 | + * @return bool Always returns true |
|
| 25 | + */ |
|
| 26 | 26 | public function execute() |
| 27 | 27 | { |
| 28 | 28 | global $sourcedir, $smcFunc, $language, $modSettings; |
@@ -132,8 +132,9 @@ discard block |
||
| 132 | 132 | 'GROUPNAME' => $user['group_name'], |
| 133 | 133 | ); |
| 134 | 134 | |
| 135 | - if (!empty($custom_reason)) |
|
| 136 | - $replacements['REASON'] = $custom_reason; |
|
| 135 | + if (!empty($custom_reason)) { |
|
| 136 | + $replacements['REASON'] = $custom_reason; |
|
| 137 | + } |
|
| 137 | 138 | |
| 138 | 139 | $emaildata = loadEmailTemplate($email_template_name, $replacements, $user['language']); |
| 139 | 140 | |
@@ -142,8 +143,8 @@ discard block |
||
| 142 | 143 | } |
| 143 | 144 | |
| 144 | 145 | // Insert the alerts if any |
| 145 | - if (!empty($alert_rows)) |
|
| 146 | - $smcFunc['db_insert']('', |
|
| 146 | + if (!empty($alert_rows)) { |
|
| 147 | + $smcFunc['db_insert']('', |
|
| 147 | 148 | '{db_prefix}user_alerts', |
| 148 | 149 | array( |
| 149 | 150 | 'alert_time' => 'int', 'id_member' => 'int', 'content_type' => 'string', |
@@ -152,6 +153,7 @@ discard block |
||
| 152 | 153 | $alert_rows, |
| 153 | 154 | array() |
| 154 | 155 | ); |
| 156 | + } |
|
| 155 | 157 | } |
| 156 | 158 | |
| 157 | 159 | return true; |
@@ -20,7 +20,7 @@ |
||
| 20 | 20 | class MsgReportReply_Notify_Background extends SMF_BackgroundTask |
| 21 | 21 | { |
| 22 | 22 | /** |
| 23 | - * This executes the task - loads up the information, puts the email in the queue and inserts alerts as needed. |
|
| 23 | + * This executes the task - loads up the information, puts the email in the queue and inserts alerts as needed. |
|
| 24 | 24 | * @return bool Always returns true. |
| 25 | 25 | */ |
| 26 | 26 | public function execute() |
@@ -40,8 +40,9 @@ discard block |
||
| 40 | 40 | 'last_comment' => $this->_details['comment_id'], |
| 41 | 41 | ) |
| 42 | 42 | ); |
| 43 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
| 44 | - $possible_members[] = $row[0]; |
|
| 43 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
| 44 | + $possible_members[] = $row[0]; |
|
| 45 | + } |
|
| 45 | 46 | $smcFunc['db_free_result']($request); |
| 46 | 47 | |
| 47 | 48 | // Presumably, there are some people? |
@@ -50,8 +51,9 @@ discard block |
||
| 50 | 51 | $possible_members = array_flip(array_flip($possible_members)); |
| 51 | 52 | $possible_members = array_diff($possible_members, array($this->_details['sender_id'])); |
| 52 | 53 | } |
| 53 | - if (empty($possible_members)) |
|
| 54 | - return true; |
|
| 54 | + if (empty($possible_members)) { |
|
| 55 | + return true; |
|
| 56 | + } |
|
| 55 | 57 | |
| 56 | 58 | // We need to know who can moderate this board - and therefore who can see this report. |
| 57 | 59 | // First up, people who have moderate_board in the board this topic was in. |
@@ -67,8 +69,9 @@ discard block |
||
| 67 | 69 | 'current_board' => $this->_details['board_id'], |
| 68 | 70 | ) |
| 69 | 71 | ); |
| 70 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 71 | - $members[] = $row['id_member']; |
|
| 72 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 73 | + $members[] = $row['id_member']; |
|
| 74 | + } |
|
| 72 | 75 | $smcFunc['db_free_result']($request); |
| 73 | 76 | |
| 74 | 77 | // Thirdly, anyone assigned to be a moderator of this group as a group->board moderator. |
@@ -85,8 +88,9 @@ discard block |
||
| 85 | 88 | ) |
| 86 | 89 | ); |
| 87 | 90 | |
| 88 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 89 | - $members[] = $row['id_member']; |
|
| 91 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 92 | + $members[] = $row['id_member']; |
|
| 93 | + } |
|
| 90 | 94 | $smcFunc['db_free_result']($request); |
| 91 | 95 | |
| 92 | 96 | // So now we have two lists: the people who replied to a report in the past, |
@@ -108,8 +112,9 @@ discard block |
||
| 108 | 112 | { |
| 109 | 113 | foreach ($alert_bits as $type => $bitvalue) |
| 110 | 114 | { |
| 111 | - if ($pref_option['msg_report_reply'] & $bitvalue) |
|
| 112 | - $notifies[$type][] = $member; |
|
| 115 | + if ($pref_option['msg_report_reply'] & $bitvalue) { |
|
| 116 | + $notifies[$type][] = $member; |
|
| 117 | + } |
|
| 113 | 118 | } |
| 114 | 119 | } |
| 115 | 120 | |
@@ -170,8 +175,9 @@ discard block |
||
| 170 | 175 | ); |
| 171 | 176 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 172 | 177 | { |
| 173 | - if (empty($row['lngfile'])) |
|
| 174 | - $row['lngfile'] = $language; |
|
| 178 | + if (empty($row['lngfile'])) { |
|
| 179 | + $row['lngfile'] = $language; |
|
| 180 | + } |
|
| 175 | 181 | $emails[$row['lngfile']][$row['id_member']] = $row['email_address']; |
| 176 | 182 | } |
| 177 | 183 | $smcFunc['db_free_result']($request); |
@@ -203,8 +209,9 @@ discard block |
||
| 203 | 209 | $emaildata = loadEmailTemplate('reply_to_moderator', $replacements, empty($modSettings['userLanguage']) ? $language : $this_lang); |
| 204 | 210 | |
| 205 | 211 | // And do the actual sending... |
| 206 | - foreach ($recipients as $id_member => $email_address) |
|
| 207 | - sendmail($email_address, $emaildata['subject'], $emaildata['body'], null, 'rptrpy' . $this->_details['comment_id'], $emaildata['is_html'], 3); |
|
| 212 | + foreach ($recipients as $id_member => $email_address) { |
|
| 213 | + sendmail($email_address, $emaildata['subject'], $emaildata['body'], null, 'rptrpy' . $this->_details['comment_id'], $emaildata['is_html'], 3); |
|
| 214 | + } |
|
| 208 | 215 | } |
| 209 | 216 | } |
| 210 | 217 | |
@@ -19,7 +19,7 @@ |
||
| 19 | 19 | class Buddy_Notify_Background extends SMF_BackgroundTask |
| 20 | 20 | { |
| 21 | 21 | /** |
| 22 | - * This executes the task - loads up the info, sets the alerts and loads up the email queue. |
|
| 22 | + * This executes the task - loads up the info, sets the alerts and loads up the email queue. |
|
| 23 | 23 | * @return bool Always returns true |
| 24 | 24 | */ |
| 25 | 25 | public function execute() |
@@ -51,8 +51,9 @@ discard block |
||
| 51 | 51 | $birthdays = array(); |
| 52 | 52 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 53 | 53 | { |
| 54 | - if (!isset($birthdays[$row['lngfile']])) |
|
| 55 | - $birthdays[$row['lngfile']] = array(); |
|
| 54 | + if (!isset($birthdays[$row['lngfile']])) { |
|
| 55 | + $birthdays[$row['lngfile']] = array(); |
|
| 56 | + } |
|
| 56 | 57 | $birthdays[$row['lngfile']][$row['id_member']] = array( |
| 57 | 58 | 'name' => $row['real_name'], |
| 58 | 59 | 'email' => $row['email_address'] |
@@ -117,8 +118,8 @@ discard block |
||
| 117 | 118 | AddMailQueue(true); |
| 118 | 119 | |
| 119 | 120 | // Insert the alerts if any |
| 120 | - if (!empty($alert_rows)) |
|
| 121 | - $smcFunc['db_insert']('', |
|
| 121 | + if (!empty($alert_rows)) { |
|
| 122 | + $smcFunc['db_insert']('', |
|
| 122 | 123 | '{db_prefix}user_alerts', |
| 123 | 124 | array( |
| 124 | 125 | 'alert_time' => 'int', 'id_member' => 'int', 'content_type' => 'string', |
@@ -127,6 +128,7 @@ discard block |
||
| 127 | 128 | $alert_rows, |
| 128 | 129 | array() |
| 129 | 130 | ); |
| 131 | + } |
|
| 130 | 132 | } |
| 131 | 133 | |
| 132 | 134 | return true; |
@@ -18,10 +18,10 @@ |
||
| 18 | 18 | */ |
| 19 | 19 | class Birthday_Notify_Background extends SMF_BackgroundTask |
| 20 | 20 | { |
| 21 | - /** |
|
| 22 | - * This executes the task. It loads up the birthdays, figures out the greeting, etc. |
|
| 23 | - * @return bool Always returns true |
|
| 24 | - */ |
|
| 21 | + /** |
|
| 22 | + * This executes the task. It loads up the birthdays, figures out the greeting, etc. |
|
| 23 | + * @return bool Always returns true |
|
| 24 | + */ |
|
| 25 | 25 | public function execute() |
| 26 | 26 | { |
| 27 | 27 | global $txt, $smcFunc, $txtBirthdayEmails, $modSettings, $sourcedir; |
@@ -19,7 +19,7 @@ |
||
| 19 | 19 | class MemberReport_Notify_Background extends SMF_BackgroundTask |
| 20 | 20 | { |
| 21 | 21 | /** |
| 22 | - * This executes the task - loads up the information, puts the email in the queue and inserts alerts as needed. |
|
| 22 | + * This executes the task - loads up the information, puts the email in the queue and inserts alerts as needed. |
|
| 23 | 23 | * @return bool Always returns true. |
| 24 | 24 | */ |
| 25 | 25 | public function execute() |
@@ -46,9 +46,10 @@ discard block |
||
| 46 | 46 | |
| 47 | 47 | foreach ($prefs as $member => $pref_option) |
| 48 | 48 | { |
| 49 | - foreach ($alert_bits as $type => $bitvalue) |
|
| 50 | - if ($pref_option['member_report'] & $bitvalue) |
|
| 49 | + foreach ($alert_bits as $type => $bitvalue) { |
|
| 50 | + if ($pref_option['member_report'] & $bitvalue) |
|
| 51 | 51 | $notifies[$type][] = $member; |
| 52 | + } |
|
| 52 | 53 | } |
| 53 | 54 | |
| 54 | 55 | // Firstly, anyone who wants alerts. |
@@ -109,8 +110,9 @@ discard block |
||
| 109 | 110 | ); |
| 110 | 111 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 111 | 112 | { |
| 112 | - if (empty($row['lngfile'])) |
|
| 113 | - $row['lngfile'] = $language; |
|
| 113 | + if (empty($row['lngfile'])) { |
|
| 114 | + $row['lngfile'] = $language; |
|
| 115 | + } |
|
| 114 | 116 | $emails[$row['lngfile']][$row['id_member']] = $row['email_address']; |
| 115 | 117 | } |
| 116 | 118 | $smcFunc['db_free_result']($request); |
@@ -129,8 +131,9 @@ discard block |
||
| 129 | 131 | $emaildata = loadEmailTemplate('report_member_profile', $replacements, empty($modSettings['userLanguage']) ? $language : $this_lang); |
| 130 | 132 | |
| 131 | 133 | // And do the actual sending... |
| 132 | - foreach ($recipients as $id_member => $email_address) |
|
| 133 | - sendmail($email_address, $emaildata['subject'], $emaildata['body'], null, 'ureport' . $this->_details['report_id'], $emaildata['is_html'], 2); |
|
| 134 | + foreach ($recipients as $id_member => $email_address) { |
|
| 135 | + sendmail($email_address, $emaildata['subject'], $emaildata['body'], null, 'ureport' . $this->_details['report_id'], $emaildata['is_html'], 2); |
|
| 136 | + } |
|
| 134 | 137 | } |
| 135 | 138 | } |
| 136 | 139 | |
@@ -18,7 +18,7 @@ |
||
| 18 | 18 | class ApprovePost_Notify_Background extends SMF_BackgroundTask |
| 19 | 19 | { |
| 20 | 20 | /** |
| 21 | - * This executes the task - loads up the info, puts the email in the queue and inserts any alerts as needed. |
|
| 21 | + * This executes the task - loads up the info, puts the email in the queue and inserts any alerts as needed. |
|
| 22 | 22 | * @return bool Always returns true |
| 23 | 23 | */ |
| 24 | 24 | public function execute() |
@@ -54,8 +54,9 @@ discard block |
||
| 54 | 54 | } |
| 55 | 55 | $smcFunc['db_free_result']($request); |
| 56 | 56 | |
| 57 | - if (empty($members)) |
|
| 58 | - return true; |
|
| 57 | + if (empty($members)) { |
|
| 58 | + return true; |
|
| 59 | + } |
|
| 59 | 60 | |
| 60 | 61 | require_once($sourcedir . '/Subs-Notify.php'); |
| 61 | 62 | $members = array_unique($members); |
@@ -103,14 +104,15 @@ discard block |
||
| 103 | 104 | } |
| 104 | 105 | |
| 105 | 106 | // Insert the alerts if any |
| 106 | - if (!empty($alert_rows)) |
|
| 107 | - $smcFunc['db_insert']('', |
|
| 107 | + if (!empty($alert_rows)) { |
|
| 108 | + $smcFunc['db_insert']('', |
|
| 108 | 109 | '{db_prefix}user_alerts', |
| 109 | 110 | array('alert_time' => 'int', 'id_member' => 'int', 'id_member_started' => 'int', 'member_name' => 'string', |
| 110 | 111 | 'content_type' => 'string', 'content_id' => 'int', 'content_action' => 'string', 'is_read' => 'int', 'extra' => 'string'), |
| 111 | 112 | $alert_rows, |
| 112 | 113 | array() |
| 113 | 114 | ); |
| 115 | + } |
|
| 114 | 116 | |
| 115 | 117 | return true; |
| 116 | 118 | } |
@@ -19,7 +19,7 @@ |
||
| 19 | 19 | class Register_Notify_Background extends SMF_BackgroundTask |
| 20 | 20 | { |
| 21 | 21 | /** |
| 22 | - * This executes the task - loads up the information, puts the email in the queue and inserts alerts as needed. |
|
| 22 | + * This executes the task - loads up the information, puts the email in the queue and inserts alerts as needed. |
|
| 23 | 23 | * @return bool Always returns true. |
| 24 | 24 | */ |
| 25 | 25 | public function execute() |
@@ -43,9 +43,10 @@ discard block |
||
| 43 | 43 | |
| 44 | 44 | foreach ($prefs as $member => $pref_option) |
| 45 | 45 | { |
| 46 | - foreach ($alert_bits as $type => $bitvalue) |
|
| 47 | - if ($pref_option['member_register'] & $bitvalue) |
|
| 46 | + foreach ($alert_bits as $type => $bitvalue) { |
|
| 47 | + if ($pref_option['member_register'] & $bitvalue) |
|
| 48 | 48 | $notifies[$type][] = $member; |
| 49 | + } |
|
| 49 | 50 | } |
| 50 | 51 | |
| 51 | 52 | // Firstly, anyone who wants alerts. |
@@ -101,8 +102,9 @@ discard block |
||
| 101 | 102 | ); |
| 102 | 103 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 103 | 104 | { |
| 104 | - if (empty($row['lngfile'])) |
|
| 105 | - $row['lngfile'] = $language; |
|
| 105 | + if (empty($row['lngfile'])) { |
|
| 106 | + $row['lngfile'] = $language; |
|
| 107 | + } |
|
| 106 | 108 | $emails[$row['lngfile']][$row['id_member']] = $row['email_address']; |
| 107 | 109 | } |
| 108 | 110 | $smcFunc['db_free_result']($request); |
@@ -126,8 +128,9 @@ discard block |
||
| 126 | 128 | $emaildata = loadEmailTemplate($emailtype, $replacements, empty($modSettings['userLanguage']) ? $language : $this_lang); |
| 127 | 129 | |
| 128 | 130 | // And do the actual sending... |
| 129 | - foreach ($recipients as $id_member => $email_address) |
|
| 130 | - sendmail($email_address, $emaildata['subject'], $emaildata['body'], null, 'newmember' . $this->_details['new_member_id'], $emaildata['is_html'], 0); |
|
| 131 | + foreach ($recipients as $id_member => $email_address) { |
|
| 132 | + sendmail($email_address, $emaildata['subject'], $emaildata['body'], null, 'newmember' . $this->_details['new_member_id'], $emaildata['is_html'], 0); |
|
| 133 | + } |
|
| 131 | 134 | } |
| 132 | 135 | } |
| 133 | 136 | |