X-Git-Url: http://git.dj3c1t.com/?a=blobdiff_plain;f=mw%2Fmw_app.php;h=4e328b7a252109639c9d7c216ac61f81e7f618d4;hb=refs%2Fheads%2Fmaster;hp=5349b795ac2f4de8fd5d522c071080d2a57cd05e;hpb=441212b3fdf07852be95c4a59315aa39a7264249;p=mtweb diff --git a/mw/mw_app.php b/mw/mw_app.php index 5349b79..4e328b7 100644 --- a/mw/mw_app.php +++ b/mw/mw_app.php @@ -2,16 +2,16 @@ class mw_app{ - var $env; - var $path_file; - var $pathes; - var $config_file; - var $config; - var $bdd; - var $error; - var $DO_INSTALL; - - function mw_app($path_file, $DO_INSTALL = false){ + public $env; + public $path_file; + public $pathes; + public $config_file; + public $config; + public $bdd; + public $error; + public $DO_INSTALL; + + public function __construct($path_file, $DO_INSTALL = false){ $this->DO_INSTALL = $DO_INSTALL; $this->path_file = $path_file; $this->pathes = array(); @@ -21,20 +21,20 @@ $this->error = false; } - function set_env(&$env){ + public function set_env(&$env){ $this->env =& $env; } - function env(){ + public function env(){ return $this->env; } - function param($name){ + public function param($name){ if(!isset($this->env)) return false; return $this->env->param($name); } - function init(){ + public function init(){ if(!$this->init_pathes()) return $this->get_error(); if(!$this->init_config()) return $this->get_error(); if(!$this->init_env()) return $this->get_error(); @@ -46,18 +46,25 @@ return $this->get_error(); } $env = $this->env(); - if($env->data_upgrade_required()){ + if(($res = $env->data_upgrade_required()) === true){ $this->upgrade(); exit; } + else{ + if($res !== false){ + $this->error($res); + return $this->get_error(); + } + } return true; } - function init_pathes(){ - if(($n = strpos($_SERVER["REQUEST_URI"], "?")) !== false){ - $_SERVER["REQUEST_URI"] = substr($_SERVER["REQUEST_URI"], 0, $n); + public function init_pathes(){ + $REQUEST_URI = $_SERVER["REQUEST_URI"]; + if(($n = strpos($REQUEST_URI, "?")) !== false){ + $REQUEST_URI = substr($REQUEST_URI, 0, $n); } - $web_path = explode("/", preg_replace('#/+#','/',$_SERVER["REQUEST_URI"])); + $web_path = explode("/", preg_replace('#/+#','/',$REQUEST_URI)); $this->pathes["web"] = ""; for($i = 0; $i < count($web_path) - 1; $i++) $this->pathes["web"] .= $web_path[$i]."/"; if( @@ -94,14 +101,18 @@ $this->error("dossier content introuvable"); return false; } - if(!is_writable($this->pathes["content"])){ + if( + !is_writable($this->pathes["content"]) + || !is_writable($this->pathes["content"]."config") + || !is_writable($this->pathes["content"]."data") + ){ $this->error("Php ne peut pas ecrire dans le dossier content"); return false; } return true; } - function init_config(){ + public function init_config(){ if(file_exists($config_file = $this->pathes["content"]."config/config.php")){ $this->config_file = $config_file; require_once $this->config_file; @@ -131,7 +142,7 @@ return true; } - function init_env(){ + public function init_env(){ if( !($sxml_class_file = (file_exists($this->pathes["mw_dir"]."libs/sxml.php") ? $this->pathes["mw_dir"]."libs/sxml.php" : "")) || !($empty_class_file = (file_exists($this->pathes["mw_dir"]."libs/empty_class.php") ? $this->pathes["mw_dir"]."libs/empty_class.php" : "")) @@ -156,22 +167,26 @@ $env->load_modules($this->pathes["mw_dir"], "env/modules/"); $env->set_config_file($this->config_file); $env->set_PATHES($this->pathes); - $env->init_plugins(); - $env->load_versions(); + $env->load_plugins(); $env->load_config($this->bdd, $this->config); + $env->load_data(); + $env->load_sgbd(); + $env->plugins_loaded(); + $env->load_versions(); + $env->load_data_upgrades(); $env->init(); - $env->init_data_upgrades(); + $env->init_plugins(); return true; } - function run($etat = "", $params = array(), $valid_role = true){ + public function run($etat = "", $params = array(), $valid_role = true){ $env = $this->env(); if(!is_callable(array($env, "run"))) return false; $env->run($etat); return true; } - function run_mod($mod_name, $valid_role = true){ + public function run_mod($mod_name, $valid_role = true){ $env = $this->env(); $etat = false; if(isset($_GET[$env->param("e")])){ @@ -188,19 +203,22 @@ return true; } - function install(){ + public function install(){ if($this->run_mod("install", false)){ $this->display(); } } - function upgrade(){ + public function upgrade(){ + $env = $this->env(); + $data = $env->data(); + $data->load_session(); if($this->run_mod("upgrade", false)){ $this->display(); } } - function display(){ + public function display(){ $env = $this->env(); if($env->etat_is_valid()){ $template = $env->get_template(); @@ -209,11 +227,11 @@ } } - function error($content){ + public function error($content){ $this->error = $content; } - function get_error(){ + public function get_error(){ return isset($this->error) && $this->error ? $this->error : false; }