Esempio n. 1
0
File: Html.php Progetto: eix/contact
 /**
  * Sends the contact message.
  */
 private function sendMessage($senderName, $senderAddress, $message)
 {
     // Check that all data is present.
     $errors = array();
     if (empty($senderName)) {
         $errors[] = _('Your name is missing.');
     }
     if (empty($senderAddress)) {
         $errors[] = _('Your e-mail address is missing.');
     }
     if (empty($message)) {
         $errors[] = _('The message is empty.');
     }
     // No validation errors? Proceed with the sending.
     if (empty($errors)) {
         try {
             $messageData = PHP_EOL . PHP_EOL . '----------------------------' . PHP_EOL . PHP_EOL . 'User agent: ' . @$_SERVER['HTTP_USER_AGENT'] . PHP_EOL . 'Origin URL: ' . @$_SERVER['REMOTE_ADDR'] . PHP_EOL . 'Cookie: ' . @$_SERVER['HTTP_COOKIE'] . PHP_EOL . 'Request: ' . serialize($_REQUEST);
             $settings = \Eix\Core\Application::getSettings();
             $mailMessage = new \Eix\Services\Net\Mail\Message();
             $mailMessage->setSender($senderAddress, $senderName);
             $mailMessage->setBody($message . $messageData);
             $mailMessage->addRecipient($settings->mail->sender->address, $settings->mail->sender->name);
             $mailMessage->setSubject($settings->modules->contactForm->subject);
             $mailMessage->send();
         } catch (\Exception $exception) {
             $errors = array('source' => 'server', 'messages' => $exception->getMessage());
         }
     } else {
         $errors = array('source' => 'validation', 'messages' => $errors);
     }
     return $errors;
 }
Esempio n. 2
0
File: Http.php Progetto: eix/core
 public function __construct($settings = null)
 {
     if (empty($settings)) {
         $settings = Application::getSettings()->data->sources->http;
     }
     self::$settings = $settings;
 }
Esempio n. 3
0
File: Page.php Progetto: eix/core
 public function getPage()
 {
     if (empty($this->page)) {
         $this->page = $this->getRequest()->getParameter('page');
         if (empty($this->page)) {
             $this->page = Application::getSettings()->routes->defaults->page;
         }
     }
     return $this->page;
 }
Esempio n. 4
0
File: XslPage.php Progetto: eix/core
 /**
  *
  * @param  type           $templateId
  * @param  type           $data
  * @throws MediaException
  */
 public function __construct($templateId, $data)
 {
     if (empty($templateId)) {
         throw new MediaException('No template has been specified.');
     }
     $this->templateId = $templateId;
     $this->data = $data;
     // An XML document is created to hold data.
     $this->dataDocument = new Library\Dom(Application::getCurrent()->getSettings()->resources->templates->response);
     if (empty(self::$pagesLocation)) {
         self::$pagesLocation = Application::getSettings()->resources->pages->location;
     }
     if (empty(self::$locale)) {
         self::$locale = Application::getCurrent()->getLocale();
     }
 }
Esempio n. 5
0
File: Http.php Progetto: eix/core
 /**
  * Finds out which locale the request would want for the response.
  */
 public function getLocale()
 {
     // Use the intl extension if present.
     if (class_exists('\\Locale')) {
         $locale = \Locale::acceptFromHttp(@$_SERVER['HTTP_ACCEPT_LANGUAGE']);
     }
     // If no locale was obtained, resort to the default one.
     if (empty($locale)) {
         $locale = Application::getSettings()->locale->default;
     }
     return $locale;
 }
Esempio n. 6
0
File: Message.php Progetto: eix/core
 /**
  * Sends the current mail message.
  */
 public function send()
 {
     $settings = Application::getSettings()->mail;
     $mailTransport = new Transport(@$settings->smtp->host ?: 'localhost', @$settings->smtp->port ?: 25, @$settings->smtp->timeout ?: 15);
     $mailTransport->setUser(@$settings->smtp->user, @$settings->smtp->password);
     $mailTransport->addMessage($this);
     $mailTransport->send();
 }
Esempio n. 7
0
File: Logger.php Progetto: eix/core
 public function exception(\Throwable $throwable)
 {
     try {
         if (@Application::getSettings()->logging->exceptions) {
             $this->error('[EXCEPTION] ' . $throwable . PHP_EOL . $throwable->getTraceAsString());
         }
     } catch (SettingsException $throwable) {
         // No setting present, throwable will not be logged.
     }
 }