From: dj3c1t Date: Fri, 1 Nov 2013 17:42:52 +0000 (+0100) Subject: verification de la version X-Git-Tag: mtweb.0.11.3~3 X-Git-Url: http://git.dj3c1t.com/index.cgi?a=commitdiff_plain;h=a4819cb78b71363db14f8c568a9a2552ee8f58da;p=mtweb verification de la version --- diff --git a/mw/app/controllers/install/index.php b/mw/app/controllers/install/index.php index 1decc17..8cc63f0 100644 --- a/mw/app/controllers/install/index.php +++ b/mw/app/controllers/install/index.php @@ -29,7 +29,7 @@ "#--" => $table_prefix ) ); - $current_sgbd = "mw_pdo_sqlite"; + $current_sgbd = isset($sgbds["mw_pdo_sqlite"]) ? "mw_pdo_sqlite" : "mw_xml"; if($_POST){ if(!isset($_POST["sgbd"])){ $env->erreur("Parametre de SGBD manquant"); diff --git a/mw/app/data/modules/share/mw_data_versions.php b/mw/app/data/modules/share/mw_data_versions.php new file mode 100644 index 0000000..26bc0ee --- /dev/null +++ b/mw/app/data/modules/share/mw_data_versions.php @@ -0,0 +1,18 @@ +data_read( + array( + "table_name" => "versions", + "index_name" => "application", + "index_value" => $application_name + ) + ) + ) return $version["version"]; + return false; + } + + } diff --git a/mw/app/init/0400_config.php b/mw/app/init/0400_config.php index e51eefb..1566400 100644 --- a/mw/app/init/0400_config.php +++ b/mw/app/init/0400_config.php @@ -1,6 +1,6 @@ bdd("sgbd")) return; + if($this->bdd_ready() !== true) return; if(($config = $data->config()) !== false){ $this->set_config($config); $start_action_params_config = diff --git a/mw/app/init/0500_users.php b/mw/app/init/0500_users.php index 8d698ff..890c368 100644 --- a/mw/app/init/0500_users.php +++ b/mw/app/init/0500_users.php @@ -1,6 +1,6 @@ bdd("sgbd")) return; + if($this->bdd_ready() !== true) return; if($data->load_session() !== false){ if($data->init_roles() !== false){ if($data->init_actions_roles() === false){ diff --git a/mw/app/init/0600_check_instance.php b/mw/app/init/0600_check_instance.php deleted file mode 100644 index cd24e27..0000000 --- a/mw/app/init/0600_check_instance.php +++ /dev/null @@ -1,10 +0,0 @@ -check_instance()) !== false){ - if($check_instance_return !== true){ - $this->erreur($check_instance_return, true); - } - } - else $this->erreur("Impossible de verifier l'integrité de la base de donné", true); - -?> \ No newline at end of file diff --git a/mw/app/init/0700_links.php b/mw/app/init/0600_links.php similarity index 93% rename from mw/app/init/0700_links.php rename to mw/app/init/0600_links.php index 4aea816..7421160 100644 --- a/mw/app/init/0700_links.php +++ b/mw/app/init/0600_links.php @@ -1,5 +1,6 @@ bdd_ready() !== true) return; if($this->init_links()){ $this->set_link("users/infos", $this->url("users/infos"), "Compte", 10); $this->set_link("admin/users", $this->url("admin/users"), "Utilisateurs", 20); diff --git a/mw/app/init/0800_init_plugins.php b/mw/app/init/0700_init_plugins.php similarity index 89% rename from mw/app/init/0800_init_plugins.php rename to mw/app/init/0700_init_plugins.php index 699998e..a936fbe 100644 --- a/mw/app/init/0800_init_plugins.php +++ b/mw/app/init/0700_init_plugins.php @@ -1,5 +1,6 @@ bdd_ready() !== true) return; if(($plugins = $this->plugins("DESC")) !== false){ foreach($plugins as $plugin_name => $plugin){ if($plugin["installed"] && $plugin["enabled"]){ diff --git a/mw/app/out/default/views/admin/users/index.php b/mw/app/out/default/views/admin/users/index.php index d7ceb35..96d3f6e 100644 --- a/mw/app/out/default/views/admin/users/index.php +++ b/mw/app/out/default/views/admin/users/index.php @@ -14,9 +14,9 @@
  • Afficher les utilisateurs pour
  • @@ -30,9 +30,9 @@ ?>
  • diff --git a/mw/env/modules/mw_env_config.php b/mw/env/modules/mw_env_config.php index e9b2316..5f14e35 100644 --- a/mw/env/modules/mw_env_config.php +++ b/mw/env/modules/mw_env_config.php @@ -156,6 +156,15 @@ $this->bdd[$key] = $value; } + function bdd_ready(){ + if(!$this->bdd("sgbd")) return "aucun sgbd defini"; + $data = $this->data(); + if(!$data) return "objet data non defini"; + if(!$this->version("mtweb")) return "impossible de lire la version de mtweb"; + if($data->version("mtweb") != $this->version("mtweb")) return "la version de la base et du code sont différentes"; + return true; + } + function add_table_prefix($table_prefix){ if(is_array($table_prefix)){ foreach($table_prefix as $prefix_code => $prefix) $this->bdd["table_prefix"][$prefix_code] = $prefix; diff --git a/mw/mw_app.php b/mw/mw_app.php index d1f6148..990d7a7 100644 --- a/mw/mw_app.php +++ b/mw/mw_app.php @@ -38,9 +38,24 @@ 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) return true; - if($this->DO_SETUP) $this->setup(); - return $this->get_error(); + if(!$this->config_file){ + if($this->DO_SETUP){ + $this->setup(); + exit; + } + return $this->get_error(); + } + $env = $this->env(); + if(!$env->version("mtweb")){ + $this->error("impossible de lire la version du code"); + return $this->get_error(); + } + $data = $env->data(); + if($data->version("mtweb") != $env->version("mtweb")){ + $this->upgrade(); + exit; + } + return true; } function init_pathes(){ @@ -174,7 +189,10 @@ $etat = isset($_GET[$env->param("e")]) ? $_GET[$env->param("e")] : "install"; $env->run($etat, array(), false); $this->display(); - exit; + } + + function upgrade(){ + debug("la base de données doit être mise à jour"); } function error($content){