/** * Intercept a request for a cached image from the proxy and output it * * @param string|bool $error If non-false, an error that occurred when validating the request */ protected function _outputImage($error) { if (empty(XenForo_Application::getOptions()->imageLinkProxy['images'])) { $error = 'disabled'; } /* @var $proxyModel XenForo_Model_ImageProxy */ $proxyModel = XenForo_Model::create('XenForo_Model_ImageProxy'); $image = false; if (!$error) { $urlParts = parse_url($this->_url); if ($this->_isLocalHost($urlParts['host']) && (empty($_SERVER['SERVER_NAME']) || !$this->_isLocalHost($_SERVER['SERVER_NAME']))) { $error = 'local_url'; } } if (!$error) { $image = $proxyModel->getImage($this->_url); if ($image) { $image = $proxyModel->prepareImage($image); if ($image['use_file']) { $proxyModel->logImageView($image); $eTag = !empty($_SERVER['HTTP_IF_NONE_MATCH']) ? $_SERVER['HTTP_IF_NONE_MATCH'] : null; if ($eTag && $eTag == '"' . $image['fetch_date'] . '"') { $this->_response->setHttpResponseCode(304); $this->_response->clearHeader('Last-Modified'); $this->_response->sendHeaders(); return; } } else { $image = false; $error = 'retrieve_failed'; } } } if (!$image) { $image = $proxyModel->getPlaceHolderImage(); } $imageTypes = array('image/gif', 'image/jpeg', 'image/pjpeg', 'image/png'); if (in_array($image['mime_type'], $imageTypes)) { $this->_response->setHeader('Content-type', $image['mime_type'], true); $this->_setDownloadFileName($image['file_name'], true); } else { $this->_response->setHeader('Content-type', 'application/octet-stream', true); $this->_setDownloadFileName($image['file_name']); } if (!$error) { $this->_response->setHeader('ETag', '"' . $image['fetch_date'] . '"', true); } if ($image['file_size']) { $this->_response->setHeader('Content-Length', $image['file_size'], true); } $this->_response->setHeader('X-Content-Type-Options', 'nosniff'); if ($error) { $this->_response->setHeader('X-Proxy-Error', $error); } $this->_response->sendHeaders(); $imageData = new XenForo_FileOutput($image['file_path']); $imageData->output(); }
public function save() { $subject = $this->_options['email_subject_template']['option_value']; $recipient = trim($this->_options['email_recipient_email']['option_value']); if (strpos($recipient, ',') !== false) { $recipient = explode(',', $recipient); foreach ($recipient as &$recip) { $recip = trim($recip); } } $sender = trim($this->_options['email_sender_email']['option_value']); $format = $this->_options['email_format']['option_value']; // default to visitor's e-mail address, but stop execution for guests if ($sender == '') { if (!XenForo_Visitor::getUserId()) { return false; } else { $sender = XenForo_Visitor::getInstance()->email; } } if ($this->_options['email_message_template']['option_value'] == '') { $message = ''; foreach ($this->_templateFields as $field) { if ($this->_options['email_hide_empty_fields']['option_value'] == array() || $this->_options['email_hide_empty_fields']['option_value'] !== array() && $field['value'] != '') { $message .= $field['title'] . ': ' . $field['value'] . PHP_EOL; } } } else { $message = $this->_options['email_message_template']['option_value']; } $transport = XenForo_Mail::getDefaultTransport(); $mailObj = new Zend_Mail('utf-8'); $mailObj->setSubject($subject)->addTo($recipient)->setFrom(XenForo_Application::getOptions()->defaultEmailAddress)->setReplyTo($sender); if ($this->_attachmentHash) { $attachmentModel = XenForo_Model::create('XenForo_Model_Attachment'); $attachments = $attachmentModel->getAttachmentsByTempHash($this->_attachmentHash); foreach ($attachments as $attachmentId => $attachment) { $attachmentData = $attachmentModel->getAttachmentDataById($attachment['data_id']); $attachmentDataFile = $attachmentModel->getAttachmentDataFilePath($attachmentData); $fileOutput = new XenForo_FileOutput($attachmentDataFile); $mailAttachment = $mailObj->createAttachment($fileOutput->getContents()); $mailAttachment->filename = $attachmentData['filename']; // delete the attachment as it is no longer needed $dw = XenForo_DataWriter::create('XenForo_DataWriter_Attachment'); $dw->setExistingData($attachment); $dw->delete(); } } $options = XenForo_Application::get('options'); $bounceEmailAddress = $options->bounceEmailAddress; if (!$bounceEmailAddress) { $bounceEmailAddress = $options->defaultEmailAddress; } $mailObj->setReturnPath($bounceEmailAddress); // create plain text message $bbCodeParserText = new XenForo_BbCode_Parser(XenForo_BbCode_Formatter_Base::create('Text')); $messageText = new XenForo_BbCode_TextWrapper($message, $bbCodeParserText); if ($format == 'html') { // create html message $bbCodeParserHtml = new XenForo_BbCode_Parser(XenForo_BbCode_Formatter_Base::create('HtmlEmail')); $messageHtml = new XenForo_BbCode_TextWrapper($message, $bbCodeParserHtml); $mailObj->setBodyHtml(htmlspecialchars_decode($messageHtml))->setBodyText($messageText); } else { $mailObj->setBodyText($messageText); } $mailObj->send($transport); }