- function init($config_file){
- require $config_file;
- $PATHES["mw_dir"] .= $PATHES["mw_dir"] && substr($PATHES["mw_dir"], -1) != "/" ? "/" : "";
- $PATHES["mw_path"] .= $PATHES["mw_path"] && substr($PATHES["mw_path"], -1) != "/" ? "/" : "";
- if(!isset($CONFIG)) $CONFIG = array();
- $env = false;
- $this->set_env($env);
+ function param($name){
+ if(!isset($this->env)) return false;
+ return $this->env->param($name);
+ }
+
+ 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();
+ if(!$this->config_file){
+ if($this->DO_INSTALL){
+ $this->install();
+ exit;
+ }
+ return $this->get_error();
+ }
+ $env = $this->env();
+ 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(){
+ $REQUEST_URI = $_SERVER["REQUEST_URI"];
+ if(($n = strpos($REQUEST_URI, "?")) !== false){
+ $REQUEST_URI = substr($REQUEST_URI, 0, $n);
+ }
+ $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(
+ !$this->path_file
+ || !file_exists($this->path_file)
+ ){
+ $this->error("le fichier des chemins est introuvable");
+ return false;
+ }
+ require $this->path_file;
+ if(
+ !isset($PATHES)
+ || !is_array($PATHES)
+ ){
+ $this->error("variable PATHES non defini");
+ return false;
+ }
+ foreach($PATHES as $path_name => $path_value){
+ $this->pathes[$path_name] = $path_value;
+ $this->pathes[$path_name] .= $path_value && substr($path_value, -1) != "/" ? "/" : "";
+ }
+ if(
+ !isset($this->pathes["mw_dir"])
+ || !isset($this->pathes["mw_path"])
+ || !isset($this->pathes["content"])
+ ){
+ $this->error("variable PATHES incomplete");
+ return false;
+ }