Пример #1
0
 /**
  *
  * @todo Consider using request and response as controller constructor
  *       params?
  */
 function __construct()
 {
     $this->_server = Oops_Server::getInstance();
     $this->_request = Oops_Server::getRequest();
     $this->_response = Oops_Server::getResponse();
     $this->_config = Oops_Server::getConfig();
 }
Пример #2
0
 function getContentType()
 {
     $ret = 'text/plain';
     $cfg = Oops_Server::getConfig();
     if (strlen($charset = $cfg->oops->charset)) {
         $ret .= "; charset={$charset}";
     }
     return $ret;
 }
Пример #3
0
 /**
  *
  * @return Oops_Cache_Manager_Interface
  */
 public static function getInstance()
 {
     if (!isset(self::$_instance)) {
         $cfg = new Oops_Cache_Defconf();
         $cfg->mergeConfig(Oops_Server::getConfig()->cache);
         self::$_instance = $cfg->manager == 'cascade' ? new Oops_Cache_Manager_Cascade($cfg) : new Oops_Cache_Manager_Plain($cfg);
     }
     return self::$_instance;
 }
Пример #4
0
 function getContentType()
 {
     // @todo Consider moving this into Oops_Server
     $ret = 'text/html';
     $cfg = Oops_Server::getConfig();
     if (strlen($charset = $cfg->oops->charset)) {
         $ret .= "; charset={$charset}";
     }
     return $ret;
 }
Пример #5
0
 private static function _initHandler()
 {
     // @todo merge given config to the default one to avoid missing fields
     $sessCfg = Oops_Server::getConfig()->session;
     $handlerClass = 'Oops_Session_' . $sessCfg->handler;
     if (!class_exists($handlerClass)) {
         $handlerClass = 'Oops_Session_Native';
     }
     self::$session = new Oops_Session_Native($sessCfg);
 }
Пример #6
0
 public function __construct($url = null)
 {
     $this->_curl = curl_init($url);
     $this->_url = $url;
     curl_setopt($this->_curl, CURLOPT_FAILONERROR, 1);
     curl_setopt($this->_curl, CURLOPT_FOLLOWLOCATION, true);
     curl_setopt($this->_curl, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($this->_curl, CURLOPT_TIMEOUT, self::TIMEOUT);
     curl_setopt($this->_curl, CURLOPT_CONNECTTIMEOUT, self::CONNECTTIMEOUT);
     curl_setopt($this->_curl, CURLOPT_POST, 0);
     $cfg = Oops_Server::getConfig();
     if (is_string($cfg->oops->proxy)) {
         curl_setopt($this->_curl, CURLOPT_PROXY, $cfg->oops->proxy);
     }
 }
Пример #7
0
 protected static function _initTemplatesPath()
 {
     if (!isset(self::$templatesPath)) {
         $config = Oops_Server::getConfig();
         $oopsConfig = $config->get('oops');
         if (is_object($oopsConfig)) {
             self::$templatesPath = $oopsConfig->get('templates_path');
         }
         if (!strlen(self::$templatesPath)) {
             self::$templatesPath = './application/templates';
         }
         if (!is_dir(self::$templatesPath)) {
             throw new Exception("Template_Helper/Invalid templates path :: " . self::$templatesPath);
         }
     }
 }
Пример #8
0
 public static function allow()
 {
     if (!isset(self::$_allow)) {
         self::$_allow = false;
         $requestKeyValue = (string) Oops_Server::getConfig()->oops->debug_key;
         if (strlen($requestKeyValue) && isset($_REQUEST['debug']) && $_REQUEST['debug'] == $requestKeyValue) {
             return self::$_allow = true;
         }
         $debug_ip = (string) Oops_Server::getConfig()->oops->debug_ip;
         if (!strlen($debug_ip)) {
             $debug_ip = '127.0.0.1/24';
         }
         $remote = ip2long($_SERVER['REMOTE_ADDR']);
         if ($remote === false) {
             return self::$_allow = false;
         }
         $ips = explode(',', $debug_ip);
         foreach ($ips as $ip) {
             list($ip, $mask) = explode('/', trim($ip));
             $mask = (int) $mask;
             if ($mask > 32 || $mask < 0) {
                 // Invalid mask
                 continue;
             }
             $allowed = ip2long($ip);
             if ($allowed === false) {
                 // Invalid IP
                 continue;
             }
             $push = 32 - $mask;
             if ($remote >> $push == $allowed >> $push) {
                 self::$_allow = true;
                 break;
             }
         }
     }
     return self::$_allow;
 }
Пример #9
0
 public static function getConfig()
 {
     return Oops_Server::getConfig()->MySQL;
 }