/**
  * validation method
  * 
  * @access public
  * @return boolean
  */
 public function validate()
 {
     $valid = false;
     $sources = System_Registry_Configuration::get(System_Registry_Configuration::environment(), 'trusted_ip_sources');
     if (is_array($sources) && count($sources)) {
         $valid = in_array($_SERVER['REMOTE_ADDR'], $sources);
     }
     return $valid;
 }
Exemple #2
0
 /**
  * class constructor defines where phpmailer lives
  * 
  * @access public
  * @return void
  */
 public function __construct()
 {
     $php_mailer_settings = System_Registry_Configuration::get(System_Registry_Configuration::environment(), 'mail', 'phpmailer');
     $this->_library_path = $php_mailer_settings['library_path'];
     $this->_library_name = $php_mailer_settings['library_name'];
     /**
      * Set the phpmailer settings. 
      */
     $this->_settings = System_Registry_Configuration::get(System_Registry_Configuration::environment(), 'mail');
 }
Exemple #3
0
 /**
  * This method dispatches the current call
  * 
  * @access public
  * @return null
  */
 public function dispatch()
 {
     try {
         echo System_Request_Call::url(false, array(), true);
     } catch (Exception $e) {
         if (System_Registry_Configuration::environment() === 'development') {
             echo System_Registry_Storage::get('System_View_Load')->parse('../System/Exception/Page.phtml', array('e' => $e));
         } else {
             System_Request_Command_Abstract::setResponseStatus(401);
         }
     }
 }
Exemple #4
0
 /**
  * saves the file to the defined location
  * returns a System_Utility_File object to allow for further manipulation of the file
  *
  * @access public
  * @return System_Utility_File|boolean
  */
 public function save()
 {
     $result = $this->validateUpload();
     if ($result) {
         $upload_to = System_Registry_Configuration::get(System_Registry_Configuration::environment(), 'upload', 'directory');
         if (!$upload_to || !is_dir($upload_to) || !is_writable($upload_to)) {
             throw new Exception('The directory that you passed in either doesn\'t exist or isn\'t writable. Directory: ' . $upload_to);
         }
         $final_file = $upload_to . '/' . $this->_value['name'];
         if (!move_uploaded_file($this->_value['tmp_name'], $final_file)) {
             $result = false;
         } else {
             $result = new System_Utility_File($final_file);
         }
     }
     return $result;
 }
Exemple #5
0
 /**
  * method to send the email 
  *
  * @access public
  * @return System_Utility_Mail
  */
 public function send()
 {
     /**
      * Set the Proper From user from the settings. 
      */
     $from = isset($this->_settings['from']) ? $this->_settings['from'] : System_Registry_Configuration::get(System_Registry_Configuration::environment(), 'mail', 'from');
     /**
      * add all of the optional settings
      */
     if (isset($this->_settings['content'])) {
         $this->_value->content($this->_settings['content']);
     }
     if (isset($this->_settings['template'])) {
         $this->_value->template($this->_settings['template']);
     }
     if (isset($this->_settings['template_data'])) {
         $this->_value->templateData($this->_settings['template_data']);
     }
     if (isset($this->_settings['subject'])) {
         $this->_value->subject($this->_settings['subject']);
     }
     $this->_value->getLibrary()->from($from)->to($this->_settings['to'])->send();
     return $this;
 }
Exemple #6
0
 /**
  * adds a javascript package
  *
  * @param string $package -- the name of the package to be added
  * @access public
  * @return System_Registry_Root
  */
 public function addJsPackage($package)
 {
     $package = System_Registry_Configuration::get(System_Registry_Configuration::environment(), 'js', $package);
     $this->addJsFile($package);
     return $this;
 }
Exemple #7
0
 /**
  * creates the css head content for the current page
  *
  * @access private
  * @return String, css links and inline code
  */
 public function createcss()
 {
     /**
      * create the css links
      */
     $links = '';
     $files = $this->_registry->getCssFiles();
     $print_css_files = $this->_registry->getPrintCssFiles();
     $path = System_Registry_Configuration::get(System_Registry_Configuration::environment(), 'css', 'path');
     /**
      * Add all the CSS Files in the stack
      */
     foreach ($files as $def) {
         $links .= "<link rel=\"stylesheet\" href=\"" . $path . $def['file'] . "\" type=\"text/css\" media=\"" . $def['media'] . "\" />\n";
     }
     /**
      * Add all the Print Css files if there are any. 
      */
     foreach ($print_css_files as $print_file) {
         $links .= "<link rel=\"stylesheet\" href=\"" . $path . $print_file . "\" type=\"text/css\" media=\"print\" />\n";
     }
     /**
      * links the css fix files for lovely IE!!
      */
     $links .= '
         <!--[if IE 7]>
             <link rel="stylesheet" href="/assets/css/ie7fix.css" media="screen,projection" type="text/css" />
             <link rel="stylesheet" href="/assets/css/ie7fixprint.css" media="print" type="text/css" />
         <![endif]-->
         <!--[if IE 8]>
             <link rel="stylesheet" href="/assets/css/ie8fix.css" media="screen,projection" type="text/css" />
         <![endif]-->
     ';
     /**
      * create inline css
      */
     $css = $this->_registry->getInlinecss();
     $style = '';
     if (count($css)) {
         $inline = '';
         $count = count($css);
         $media = '';
         for ($x = 0; $x < $count; $x++) {
             $style .= $this->getInlineCssBlock($css[$x]['css'], $css[$x]['media']);
         }
     }
     /**
      * return the complete css code
      */
     return $links . $style;
 }
Exemple #8
0
 /**
  * Processes the user password by adding the salt to the end of the string, and encrypting it using a sha1 encryption.
  * 
  * @access public
  * @return $this
  */
 public function encodePassword()
 {
     $salt = System_Registry_Configuration::get(System_Registry_Configuration::environment(), 'salt');
     $salt = $salt ? $salt : '';
     if ($this->_value) {
         $this->_processed = sha1(md5($this->_value . $salt));
     }
     return $this;
 }
Exemple #9
0
 /**
  * gets the search settings from the System_Registry_Configuration settings object
  *
  * @access private
  * @return System_Search_Controller
  */
 private function getSettings()
 {
     $file = System_Registry_Configuration::get(System_Registry_Configuration::environment(), 'search');
     $this->_search_groups = $file[$this->_search_settings];
     return $this;
 }
Exemple #10
0
 /**
  * This function will force an SSL connection on the page.
  * @access protected
  * @param string $host - Overwrites the HTTP_HOST for the secure page. 
  * @return mixed
  */
 protected function forceSsl($host = false)
 {
     $www_host = $_SERVER["HTTP_HOST"];
     if ($host) {
         $www_host = $host;
     }
     if (!isset($_SERVER["HTTPS"]) && System_Registry_Configuration::environment() == 'production') {
         header("Location: https://" . $www_host . $_SERVER["REQUEST_URI"]);
     }
 }