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
 public function httpGetForHtml()
 {
     $response = parent::httpGetForHtml();
     $openIdMode = $this->getRequest()->getParameter('openid_mode');
     if ($openIdMode) {
         switch ($openIdMode) {
             case 'cancel':
                 // Identification by means of OpenID failed.
                 throw new NotAuthenticatedException('OpenID athentication failed.');
             case 'id_res':
                 // The identity provider has validated the user, so it can
                 // be set as current (as long as it's authorised).
                 try {
                     $user = Users::getFromIdentityProvider(new GoogleIdentityProvider());
                     Users::setCurrent($user);
                     // Redirect users to either the URL they originally
                     // requested, or to the index if the former is not
                     // available.
                     $response = new Redirection($this->getRequest());
                     $response->setNextUrl(Application::getCurrent()->popLastLocator() ?: '/');
                 } catch (NotAuthenticatedException $exception) {
                     // The current OpenID data is not valid. Request again.
                     $response = $this->getRequestIdentificationResponse();
                 }
                 break;
             default:
                 throw new NotAuthenticatedException('Unsupported OpenID mode.');
         }
     } else {
         // No OpenID response is present, so just ask for identity.
         $response = $this->getRequestIdentificationResponse();
     }
     return $response;
 }
Esempio n. 4
0
 /**
  * Creates a data source.
  *
  * @param string $collectionName the collection or group of objects the
  * images are part of.
  * @param \Eix\Core\Settings $settings the data source configuration. Of special
  * consideration is the
  */
 protected function __construct($collectionName, $settings = null)
 {
     if ($settings == null) {
         $settings = Application::getCurrent()->getSettings()->data->sources->imageStore;
     }
     $this->baseLocation = $settings->locations->{$collectionName};
     // Set the collection.
     $this->collection = $collectionName;
 }
Esempio n. 5
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. 6
0
File: Html.php Progetto: eix/core
 public function __construct(HttpRequest $request = null)
 {
     $this->setContentType(self::CONTENT_TYPE);
     parent::__construct($request);
     // Set the initial title.
     try {
         $this->titleParts = array(Application::getCurrent()->getName());
     } catch (Exception $exception) {
         $this->titleParts = '';
     }
 }
Esempio n. 7
0
File: MongoDB.php Progetto: eix/core
 /**
  * Creates a data source based off a MongoDB database.
  *
  * @param string                   $collectionName the MongoDB collection name.
  * @param \Eix\Core\Settings $settings       the data source configuration.
  */
 protected function __construct($collectionName, $settings = null)
 {
     if ($settings == null) {
         $settings = Application::getCurrent()->getSettings()->data->sources->mongodb;
     }
     // Get a Mongo instance.
     $mongo = self::getConnector($settings);
     // Select the database.
     $database = $mongo->selectDB($settings->databaseName);
     // Select the collection.
     $this->collection = $database->selectCollection($collectionName);
 }
Esempio n. 8
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. 9
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. 10
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. 11
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.
     }
 }