+ function init(){
+ $this->INITED =
+ $this->init_pathes()
+ && $this->init_config()
+ && $this->init_env();
+ if(!$this->INITED) return false;
+ if($this->config_file) return true;
+ $this->setup();
+ return false;
+ }
+
+ function init_pathes(){
+ if(($n = strpos($_SERVER["REQUEST_URI"], "?")) !== false){
+ $_SERVER["REQUEST_URI"] = substr($_SERVER["REQUEST_URI"], 0, $n);
+ }
+ $web_path = explode("/", preg_replace('#/+#','/',$_SERVER["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->log("path_file introuvable: ".$this->path_file);
+ return false;
+ }
+ require_once $this->path_file;
+ if(
+ !isset($PATHES)
+ || !is_array($PATHES)
+ ){
+ $this->log("path_file: ".$this->path_file);
+ $this->log("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->log("variable PATHES incomplete");
+ return false;
+ }
+ if(
+ !file_exists($this->pathes["content"])
+ || !is_dir($this->pathes["content"])
+ ){
+ $this->log("dossier content introuvable: ".$this->pathes["content"]);
+ return false;
+ }
+ if(!is_writable($this->pathes["content"])){
+ $this->log("Php ne peut pas ecrire dans le dossier content: ".$this->pathes["content"]);
+ return false;
+ }
+ return true;
+ }
+
+ function init_config(){
+ if(file_exists($config_file = $this->pathes["content"]."config/config.php")){
+ $this->config_file = $config_file;
+ require_once $this->config_file;
+ if(
+ isset($CONFIG)
+ && is_array($CONFIG)
+ ){
+ foreach($CONFIG as $config_name => $config_value){
+ $this->config[$config_name] = $config_value;
+ }
+ }
+ if(
+ isset($bdd)
+ && is_array($bdd)
+ ){
+ foreach($bdd as $bdd_key => $bdd_value){
+ $this->bdd[$bdd_key] = $bdd_value;
+ }
+ }
+ }
+ else $this->log("pas de fichier de config: ".$config_file);
+ return true;
+ }
+
+ function init_env(){