Exemplo n.º 1
0
 public function initialize(IConfigParameter $configuration)
 {
     if (!extension_loaded('apc')) {
         throw new SoftwareSupportException("APC extension not loaded");
     }
     if ($configuration->get('id') === null) {
         throw new CacheException("Cache module must have id");
     }
     // Need checking for necessary cache id
     Project::getCacheManager()->set($configuration->get('id'), $this);
     parent::initialize($configuration);
 }
Exemplo n.º 2
0
 function setPathes(IConfigParameter $configuration)
 {
     $pc = $configuration->get('include_path');
     $version = $configuration->get('version');
     $pathes = explode(';', $pc);
     foreach ($pathes as $path) {
         $path = trim($path);
         if (is_string($path) && strlen($path) > 0) {
             $this->path($path, $version);
         }
     }
 }
Exemplo n.º 3
0
 function initialize(IConfigParameter $configuration)
 {
     $need = $configuration->get('autorization');
     if ($need === true) {
         $this->_needAutorization = true;
     } else {
         $this->_needAutorization = false;
     }
     $this->_login_controller = $configuration->get('login_controller');
     $this->_login_action = $configuration->get('login_action');
     $this->_common_config($configuration);
 }
Exemplo n.º 4
0
 function initialize(IConfigParameter $configuration)
 {
     //-----------------------------------------------------
     //set global variables
     /*$this->logDir=$logDir;
     		$this->logFile=$logFile;
     		if($countFile) $this->countFile=$this->logDir . "/$countFile";
     		$this->headerTitle=$headerTitle;
     		$this->logMode=$logMode;*/
     $this->logDir = $configuration->get('logDir');
     $this->logFile = $configuration->get('logFile');
     if ($configuration->get('countFile')) {
         $this->countFile = Project::NS()->path($this->logDir) . DIRECTORY_SEPARATOR . $configuration->get('countFile');
     }
     $this->headerTitle = $configuration->get('headerTitle');
     $this->logMode = $configuration->get('logMode');
     //generate log number
     //set counter file and log folder
     $countFile = $this->countFile;
     $logDir = $this->logDir;
     //verify log folder existence
     //if it doesn't I create it
     if (!is_dir($logDir)) {
         if (mkdir($logDir) === FALSE) {
             echo "Could not create log dir";
         }
     }
     //Counter INICILIZATION
     if (file_exists($countFile) === FALSE) {
         //if log counter file does not exist, I create it
         touch($countFile);
         //inicializing file in 0
         $initNumber = 0;
         $fp = fopen($countFile, "a");
         if (fwrite($fp, $initNumber) === FALSE) {
             echo "Could not write Counter file";
         }
         fclose($fp);
     }
     //------------------------------------------------------------
     //INCREMENT Counter
     //read counter
     $logNumber = trim(file_get_contents($countFile));
     $logNumber++;
     //increment counter
     //set log number in class var
     $this->logNumber = $logNumber;
     //write incremented counter value
     $fp = fopen($countFile, "w+");
     if (fwrite($fp, $logNumber) === FALSE) {
         echo "Could not write Counter file";
     }
     fclose($fp);
     //parent::init();
     $this->_common_config($configuration);
     //-----------------------------------------------------
 }
Exemplo n.º 5
0
 function initialize(IConfigParameter $configuration)
 {
     $dsn = $configuration->get('DSN');
     if (!$dsn) {
         $connection_file = $configuration->get('connection_file');
         if (!$connection_file) {
             throw new DbException("Connection file not defined");
         }
         $p = pathinfo($connection_file);
         $dir = Project::NS()->path($p['dirname']);
         $f = $dir . $p['basename'];
         if (!file_exists($f) || !is_file($f)) {
             throw new DbException("Connection file not exists");
         }
         $config = new ConfigParameter(file_get_contents($f));
         $dsn = $config->get('DSN');
         if (!$dsn) {
             throw new DbException("DSN not exitsts at connection file");
         }
     }
     $this->_caching = $configuration->get('caching');
     if ($configuration->get('cache_prefix')) {
         $this->_cache_prefix = $configuration->get('cache_prefix');
     }
     if ($configuration->get('cache_module_id')) {
         $this->_cache_module_id = $configuration->get('cache_module_id');
     } else {
         // No cache module defined
         // TODO:: write NOTICE to log
         $this->_caching = false;
     }
     $this->_DSN = $dsn;
     $this->_common_config($configuration);
     $this->_driver = DbSimple_Generic::connect($this->_DSN);
     if (!is_object($this->_driver)) {
         throw new DbException("No connection to database");
     }
     $this->_driver->query("SET NAMES utf8");
     $this->_driver->setLogger($configuration->get('native_logger'));
     //$this -> _driver -> setLogger('myLogger');
     Project::setDatabase($this);
 }
Exemplo n.º 6
0
 function initialize(IConfigParameter $configuration)
 {
     $this->_templateDir = Project::NS()->path($configuration->get('template_dir'));
     if (!file_exists($this->_templateDir) || !is_dir($this->_templateDir)) {
         throw new TemplateException("Template manager: root template directory is not exists");
     }
     $this->_js_path = $configuration->get('js_path');
     $this->_css_path = $configuration->get('css_path');
     $this->_image_path = $configuration->get('image_path');
     $this->_cj_cache_path = $configuration->get('cj_cache_path');
     Project::setTemplateManager($this);
     $this->_common_config($configuration);
 }
Exemplo n.º 7
0
 public function initialize(IConfigParameter $configuration)
 {
     if (get_magic_quotes_gpc()) {
         HelpFunctions::strips($_GET);
         HelpFunctions::strips($_POST);
         HelpFunctions::strips($_COOKIE);
         HelpFunctions::strips($_REQUEST);
     }
     $this->_requestMethod = $_SERVER['REQUEST_METHOD'];
     if ($this->_requestMethod == 'GET') {
         $this->_request = $_GET;
     } elseif ($this->_requestMethod == 'POST') {
         $this->_request = $_POST;
     } else {
         $this->_request = array();
     }
     $this->_username = $this->getSubDomain($configuration->get('base_host'));
     $this->_rewrite = (bool) $configuration->get('rewrite');
     if ($this->_rewrite) {
         $request_key = $configuration->get('request_key');
         $this->_param_delimiter = $configuration->get('param_delimiter');
         $this->_value_delimiter = $configuration->get('value_delimiter');
         $query = $_GET[$request_key];
         $d = explode($this->_param_delimiter, $query);
         if (isset($d[0]) && strlen($d[0])) {
             $this->_current_action = trim($d[0]);
             unset($d[0]);
             // unset controller key
             foreach ($d as $item) {
                 $tmp = explode($this->_value_delimiter, $item);
                 if (isset($tmp[0])) {
                     $v0 = trim($tmp[0]);
                     $v1 = isset($tmp[1]) ? trim($tmp[1]) : null;
                     if (strlen($v0)) {
                         $this->_request_by_number[] = $v0;
                     }
                     if (strlen($v1 !== null)) {
                         if ($this->_requestMethod == 'GET' || $this->_requestMethod == 'POST' && !isset($this->_request[$v0])) {
                             $this->_request[$v0] = $v1;
                         }
                     }
                 }
             }
         }
     } else {
         die(__METHOD__ . "::" . __LINE__ . "::Non-rewrite mode need some changes after last modification this manager!!!!");
         $this->_request_controller_key = $configuration->get('request_service_key');
         // Only for non-rewrite mode
         $this->_request_action_key = $configuration->get('request_action_key');
         // Only for non-rewrite mode
         if (!$this->_request_controller_key) {
             throw new ConfigurationException('HttpRequest, non-rewrite mode: service key at request not configured');
         }
         if (isset($this->_request[$this->_request_controller_key])) {
             $this->_current_controller = $this->_request[$this->_request_controller_key];
         }
     }
     $this->_files = $_FILES;
     Project::setRequest($this);
     $this->_common_config($configuration);
 }