/** * 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; }
/** * 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'); }
/** * 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); } } }
/** * 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; }
/** * 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; }
/** * method used to set a {@link _settings} property * * @param string $key -- the key to be written in the * @param * @access public * @static * @return void */ public static function set() { $arr = array(); $args = func_get_args(); $count = count($args); /** * if the argument count is greater than zero * process the arguments as keys for the {@link $_settings} property * remove the last iteration from the arguments to use as the value * set each argument to a variable variable whose value is an array */ if ($count > 2) { $value = array_pop($args); $arg_count = count($args); $last = $arg_count - 1; foreach ($args as $key) { ${$key} = array(); } /** * loop through the arguments backwards and set their value to the previous iteration's variable variable * if it is the last iteration set it equal to the value * if it is the first one, set the arr value to the first iteration's variable variable * else, nest the values */ for ($i = $last; $i >= 0; $i--) { if ($i === $last) { $x = ${$args}[$i]; $x[$args[$i]] = $value; ${$args}[$i] = $x; } elseif ($i === 0) { $x = ${$args}[$i + 1]; $arr[$args[$i]] = $x; } else { $x = ${$args}[$i]; $y = ${$args}[$i + 1]; $x[$args[$i]] = $y; ${$args}[$i] = $x; } } } self::$_settings = array_merge_recursive(self::$_settings, $arr); }
/** * 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; }
/** * 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; }
/** * class constructor does nothing * * @access public * @return void */ public function __construct() { $this->_library_path = System_Registry_Configuration::get(System_Registry_Configuration::environment, 'mail', 'library', 'mailchimp'); $this->_library_name = 'MailChimp'; }
/** * 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; }
/** * 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; }
/** * 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"]); } }