<?xml version="1.0" encoding="UTF-8"?>
<config>
+ <version>0.11.2</version>
+
<bdd>
<table_prefix_code>#--</table_prefix_code>
</bdd>
"user" => isset($_POST[$current_sgbd."_user"]) ? $_POST[$current_sgbd."_user"] : "",
"password" => isset($_POST[$current_sgbd."_password"]) ? $_POST[$current_sgbd."_password"] : ""
);
+ $sgbds[$current_sgbd]->user = $params["user"];
$admin = array(
"login" => trim($_POST["admin_login"]),
"email" => trim($_POST["admin_email"]),
catch(Exception $e){
return $e->getMessage();
}
+ if(!($version = $env->version("mtweb"))){
+ return "impossible de lire la version de mtweb";
+ }
try{
$EXISTS =
$sgbd->table_exists("#--actions_roles")
|| $sgbd->table_exists("#--config")
|| $sgbd->table_exists("#--roles")
|| $sgbd->table_exists("#--users")
- || $sgbd->table_exists("#--users_roles");
+ || $sgbd->table_exists("#--users_roles")
+ || $sgbd->table_exists("#--versions");
}
catch(Exception $e){
return "impossible de savoir si les tables existent deja";
.") DEFAULT CHARSET=utf8";
$sgbd->query($sql);
+ $sql =
+ "CREATE TABLE #--versions("
+ ." id INT(11) NOT NULL AUTO_INCREMENT,"
+ ." application VARCHAR(255) NOT NULL,"
+ ." version VARCHAR(255) NOT NULL,"
+ ." PRIMARY KEY (id)"
+ .") DEFAULT CHARSET=utf8";
+ $sgbd->query($sql);
+
}
catch(Exception $e){
return "imposible de creer les tables en base";
."(3, 'webmaster', 'webmaster')";
$sgbd->query($sql);
+ $sql =
+ "INSERT INTO #--versions(`application`, `version`) VALUES"\r
+ ."('mtweb', ".$this->eq($version).")";
+ $sgbd->query($sql);
+
}
catch(Exception $e){
return "les tables ont ete ajoutees en base mais impossible d'y enregistrer les valeurs par defaut.";
catch(Exception $e){
return $e->getMessage();
}
+ if(!($version = $env->version("mtweb"))){
+ return "impossible de lire la version de mtweb";
+ }
try{
$EXISTS =
$sgbd->table_exists("#--actions_roles")
|| $sgbd->table_exists("#--config")
|| $sgbd->table_exists("#--roles")
|| $sgbd->table_exists("#--users")
- || $sgbd->table_exists("#--users_roles");
+ || $sgbd->table_exists("#--users_roles")
+ || $sgbd->table_exists("#--versions");
}
catch(Exception $e){
return "impossible de savoir si les tables existent deja";
.")";
$sgbd->query($sql);
+ $sql =
+ "CREATE TABLE #--versions("
+ ." id INTEGER PRIMARY KEY AUTOINCREMENT,"
+ ." application TEXT NOT NULL,"
+ ." version TEXT NOT NULL"
+ .")";
+ $sgbd->query($sql);
+
}
catch(Exception $e){
return "imposible de creer les tables en base. ".$e->getMessage();
"INSERT INTO #--roles(`id`, `nom`, `intitule`) VALUES (3, 'webmaster', 'webmaster')";
$sgbd->query($sql);
+ $sql =
+ "INSERT INTO #--versions(`application`, `version`) VALUES ('mtweb', ".$this->eq($version).")";
+ $sgbd->query($sql);
+
}
catch(Exception $e){
return "les tables ont ete ajoutees en base mais impossible d'y enregistrer les valeurs par defaut.";
){
return "impossible de se connecter à la base XML";
}
+ if(!($version = $env->version("mtweb"))){
+ return "impossible de lire la version de mtweb";
+ }
$ERROR = false;
$EXISTS = false;
if(!$ERROR && !$EXISTS) $EXISTS = $sgbd->data_exists("actions_roles");
$ERROR = !isset($EXISTS);
if(!$ERROR && !$EXISTS) $EXISTS = $sgbd->data_exists("users_roles");
$ERROR = !isset($EXISTS);
+ if(!$ERROR && !$EXISTS) $EXISTS = $sgbd->data_exists("versions");
+ $ERROR = !isset($EXISTS);
if($ERROR){
return "impossible de savoir si les tables existent deja";
}
if(!$ERROR) if(!$sgbd->create_data("roles")) $ERROR = true;
if(!$ERROR) if(!$sgbd->create_data("users")) $ERROR = true;
if(!$ERROR) if(!$sgbd->create_data("users_roles")) $ERROR = true;
+ if(!$ERROR) if(!$sgbd->create_data("versions")) $ERROR = true;
if($ERROR){
return "imposible de creer les tables en base";
}
)
) $ERROR = true;
+ // ------------------------------------ versions
+ if(!$ERROR){
+ $res = $sgbd->add_data(
+ "versions",
+ array(
+ "application" => "mtweb",
+ "version" => $version
+ ),
+ 0
+ );
+ if(!isset($res)) $ERROR = true;
+ }
+
if($ERROR){
return "les tables ont ete ajoutees en base mais impossible d'y enregistrer les valeurs par defaut.";
}
--- /dev/null
+<?php
+
+ class mw_env_versions extends mw_env{
+
+ var $xml_parser;
+ var $versions;
+
+ function version($application){
+ return isset($this->versions[$application]) ? $this->versions[$application] : false;
+ }
+
+ function load_versions(){
+ $this->xml_parser = new sxml();
+ $app_config_file = $this->path("mw_dir")."app/config.xml";
+ if(file_exists($app_config_file)){
+ $this->_load_version("mtweb", $app_config_file);
+ }
+ if(($plugins = $this->plugins()) !== false){
+ foreach($plugins as $plugin_name => $plugin){
+ $this->load_plugin_version($plugin_name);
+ }
+ }
+ else $this->erreur("impossible de lire les fichiers de configuration pour les plugins", true);
+ }
+
+ function _load_version($app_name, $app_config_file){
+ $this->xml_parser->parse(file_get_contents($app_config_file));
+ $app_config = $this->xml_parser->data["config"][0];
+ if(isset($app_config["subs"]["version"][0]["data"])){
+ $this->versions[$app_name] = $app_config["subs"]["version"][0]["data"];
+ }
+ }
+
+ function load_plugin_version($plugin_name){
+ $app_config_file = $this->path("mw_dir")."plugins/".$plugin_name."/app/config.xml";
+ if(file_exists($app_config_file)){
+ $this->_load_version($plugin_name, $app_config_file);
+ }
+ }
+
+ }
+
+?>
\ No newline at end of file
$env->set_config_file($this->config_file);
$env->set_PATHES($this->pathes);
$env->init_plugins();
+ $env->load_versions();
$env->load_config($this->bdd, $this->config);
$env->init();
return true;