+ 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($env->data_upgrade_required()){
+ $this->upgrade();
+ exit;
+ }
+ return true;
+ }
+
+ 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->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;
+ }
+ if(
+ !file_exists($this->pathes["content"])
+ || !is_dir($this->pathes["content"])
+ ){
+ $this->error("dossier content introuvable");
+ return false;
+ }
+ if(!is_writable($this->pathes["content"])){
+ $this->error("Php ne peut pas ecrire dans le dossier 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{
+ if(!$this->DO_INSTALL){
+ $this->error("fichier config.php manquant");
+ return false;
+ }
+ }
+ return true;
+ }
+
+ 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" : ""))
+ || !($env_class_file = (file_exists($this->pathes["mw_dir"]."env/mw_env.php") ? $this->pathes["mw_dir"]."env/mw_env.php" : ""))
+ ){
+ $this->error("des fichiers sont introuvables. impossible d'initialiser l'environnement");
+ return false;
+ }
+ if(!class_exists("sxml")) require_once $sxml_class_file;
+ if(!class_exists("empty_class")) require_once $empty_class_file;
+ if(!class_exists("mw_env")) require_once $env_class_file;