+++ /dev/null
-<?php
-
- // --------------------------------------------------------------
- // chemins
- //
-
- $PATHES = array(
-
- // chemin HTTP de l'installation
- // (dossier, sur le site, qui contient le fichier index.php)
- // absolu a partir de la racine HTTP du site
- //
- // installation dans un dossier :
- // "web" => "/chemin/du/dossier"
- //
- // installation a la racine :
- "web" => "/",
-
- // chemin HTTP du dossier "mw"
- // absolu a partir de la racine HTTP du site
- "mw_path" => "/mw",
-
- // chemin du dossier "mw" sur le systeme d'exploitation
- // relatif au dossier de l'installation
- // ou absolu dans le systeme de fichiers
- "mw_dir" => "mw",
-
- // dossier des contenus editables par l'application
- // relatif au dossier de l'installation
- "content" => "content"
- );
-
- // --------------------------------------------------------------
- // base de donnees
- //
-
- // mtweb propose deux modes de stockage des donnees
- //
- // - dans des fichiers XML
- //
- // - ou en utilisant un gestionnaire de base de donnees SQL
- //
- // ci-dessous deux exemples de configurations pour la connexion
- // une pour XML (par defaut) et l'autre pour MySql (commentee)
-
- // --------------------------- XML
-
- $bdd = array(
- // on utilise stockage de donnees dans des fichiers XML
- "sgbd" => "xml",
- // les fichiers XML sont enregistres dans le repertoire :
- "host" => "content/data/xml",
- // dans ce repertoire, la base de donnees est dans le dossier :
- "base" => "mw"
- );
-
-/*
- // --------------------------- MYSQL
- //
- // pour utiliser MySql, importez la base de donnees :
- //
- // mysql -u mysql_user -p < content/data/mysql/mtweb.sql
- //
- // et remplacez avec vos parametres de connexion :
-
- $bdd = array(
- // on utilise MySql avec PDO (driver pdo_mysql)
- "sgbd" => "pdo_mysql",
- // hote du serveur MySql
- "host" => "localhost",
- // nom de la base de donnees
- "base" => "mtweb",
- // prefixe pour les noms des tables (*)
- "table_prefix" => "mw_",
- // identification pour la connexion sur le serveur MySql
- "user" => "mysql_user",
- "password" => "mysql_password"
- );
-
- // (*) le script mtweb.sql cree les tables avec le prefixe mw_
- // adaptez le script si vous utiliez un autre prefix
-*/
-
-?>
\ No newline at end of file
--- /dev/null
+<?php
+
+ // --------------------------- MYSQL
+
+ $bdd = array(
+ // on utilise MySql (driver mysql)
+ "sgbd" => "mysql",
+ // hote du serveur MySql
+ "host" => "[bdd_host]",
+ // nom de la base de donnees
+ "base" => "[bdd_base]",
+ // prefixe pour les noms des tables (*)
+ "table_prefix" => "[bdd_prefix]",
+ // identification pour la connexion sur le serveur MySql
+ "user" => "[bdd_user]",
+ "password" => "[bdd_password]"
+ );
+
+?>
\ No newline at end of file
--- /dev/null
+<?php
+
+ // --------------------------- PDO MYSQL
+
+ $bdd = array(
+ // on utilise MySql avec PDO (driver pdo_mysql)
+ "sgbd" => "pdo_mysql",
+ // hote du serveur MySql
+ "host" => "[bdd_host]",
+ // nom de la base de donnees
+ "base" => "[bdd_base]",
+ // prefixe pour les noms des tables (*)
+ "table_prefix" => "[bdd_prefix]",
+ // identification pour la connexion sur le serveur MySql
+ "user" => "[bdd_user]",
+ "password" => "[bdd_password]"
+ );
+
+?>
\ No newline at end of file
--- /dev/null
+<?php
+
+ // --------------------------- PDO SQLite
+
+ $bdd = array(
+ // on utilise SQLite avec PDO (driver pdo_sqlite)
+ "sgbd" => "pdo_sqlite",
+ // repertoire contenant le fichier de base de donnees SQLite
+ "host" => "[bdd_host]",
+ // fichier de base de donnees SQLite
+ "base" => "[bdd_base]",
+ // prefixe pour les noms des tables
+ "table_prefix" => "[bdd_prefix]"
+ );
+
+?>
\ No newline at end of file
--- /dev/null
+<?php
+
+ // --------------------------- XML
+
+ $bdd = array(
+ // on utilise stockage de donnees dans des fichiers XML
+ "sgbd" => "xml",
+ // les fichiers XML sont enregistres dans le repertoire :
+ "host" => "[bdd_host]",
+ // dans ce repertoire, la base de donnees est dans le dossier :
+ "base" => "[bdd_base]"
+ );
+
+?>
\ No newline at end of file
+++ /dev/null
--- phpMyAdmin SQL Dump\r
--- version 3.3.2deb1ubuntu1\r
--- http://www.phpmyadmin.net\r
---\r
--- Serveur: localhost\r
--- Généré le : Dim 26 Mai 2013 à 15:46\r
--- Version du serveur: 5.1.69\r
--- Version de PHP: 5.3.2-1ubuntu4.19\r
-\r
-SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";\r
-\r
---\r
--- Base de données: `mtweb`\r
---\r
-\r
--- --------------------------------------------------------\r
-\r
---\r
--- Structure de la table `mw_actions_roles`\r
---\r
-\r
-CREATE TABLE IF NOT EXISTS `mw_actions_roles` (\r
- `id` int(11) NOT NULL AUTO_INCREMENT,\r
- `action` varchar(255) NOT NULL,\r
- `id_role` int(11) NOT NULL,\r
- PRIMARY KEY (`id`),\r
- KEY `id_role` (`id_role`)\r
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=21 ;\r
-\r
---\r
--- Contenu de la table `mw_actions_roles`\r
---\r
-\r
-INSERT INTO `mw_actions_roles` (`id`, `action`, `id_role`) VALUES\r
-(13, 'admin', 1),\r
-(14, 'users', 2),\r
-(19, 'users/identification', 0),\r
-(20, 'config', 3);\r
-\r
--- --------------------------------------------------------\r
-\r
---\r
--- Structure de la table `mw_config`\r
---\r
-\r
-CREATE TABLE IF NOT EXISTS `mw_config` (\r
- `id` int(11) NOT NULL AUTO_INCREMENT,\r
- `key` varchar(255) NOT NULL,\r
- `value` text NOT NULL,\r
- PRIMARY KEY (`id`)\r
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=38 ;\r
-\r
---\r
--- Contenu de la table `mw_config`\r
---\r
-\r
-INSERT INTO `mw_config` (`id`, `key`, `value`) VALUES\r
-(1, 'site_name', 'mtweb'),\r
-(2, 'max_list', '10'),\r
-(3, 'description', ''),\r
-(4, 'out', 'default'),\r
-(5, 'start_action', ''),\r
-(6, 'contact_form', '0'),\r
-(8, 'email', ''),\r
-(9, 'captcha', '0'),\r
-(16, 'start_action_params', ''),\r
-(20, 'out_navig_menu_top', 'on'),\r
-(22, 'out_colonne', 'on'),\r
-(29, 'default_allow', '1');\r
-\r
--- --------------------------------------------------------\r
-\r
---\r
--- Structure de la table `mw_roles`\r
---\r
-\r
-CREATE TABLE IF NOT EXISTS `mw_roles` (\r
- `id` int(11) NOT NULL AUTO_INCREMENT,\r
- `nom` varchar(255) NOT NULL,\r
- `intitule` varchar(255) NOT NULL,\r
- KEY `id` (`id`)\r
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=4 ;\r
-\r
---\r
--- Contenu de la table `mw_roles`\r
---\r
-\r
-INSERT INTO `mw_roles` (`id`, `nom`, `intitule`) VALUES\r
-(0, 'guest', 'invité'),\r
-(1, 'admin', 'administrateur'),\r
-(2, 'membre', 'membre'),\r
-(3, 'webmaster', 'webmaster');\r
-\r
--- --------------------------------------------------------\r
-\r
---\r
--- Structure de la table `mw_users`\r
---\r
-\r
-CREATE TABLE IF NOT EXISTS `mw_users` (\r
- `id` int(11) NOT NULL AUTO_INCREMENT,\r
- `login` varchar(255) NOT NULL,\r
- `password` varchar(255) NOT NULL,\r
- `email` varchar(255) NOT NULL,\r
- PRIMARY KEY (`id`)\r
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=20 ;\r
-\r
---\r
--- Contenu de la table `mw_users`\r
---\r
-\r
-INSERT INTO `mw_users` (`id`, `login`, `password`, `email`) VALUES\r
-(19, 'admin', '25e4ee4e9229397b6b17776bfceaf8e7', 'admin@domain.tld');\r
-\r
--- --------------------------------------------------------\r
-\r
---\r
--- Structure de la table `mw_users_roles`\r
---\r
-\r
-CREATE TABLE IF NOT EXISTS `mw_users_roles` (\r
- `id_user` int(11) NOT NULL,\r
- `id_role` int(11) NOT NULL,\r
- PRIMARY KEY (`id_user`,`id_role`),\r
- KEY `id_role` (`id_role`)\r
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;\r
-\r
---\r
--- Contenu de la table `mw_users_roles`\r
---\r
-\r
-INSERT INTO `mw_users_roles` (`id_user`, `id_role`) VALUES\r
-(19, 1),\r
-(19, 2),\r
-(19, 3);\r
-\r
---\r
--- Contraintes pour les tables exportées\r
---
--- DECOMMENTER POUR AJOUTER LES CONTRAINTES\r
-\r
---\r
--- Contraintes pour la table `mw_actions_roles`\r
---\r
--- ALTER TABLE `mw_actions_roles`\r
--- ADD CONSTRAINT `mw_actions_roles_ibfk_1` FOREIGN KEY (`id_role`) REFERENCES `mw_roles` (`id`);\r
-\r
---\r
--- Contraintes pour la table `mw_users_roles`\r
---\r
--- ALTER TABLE `mw_users_roles`\r
--- ADD CONSTRAINT `mw_users_roles_ibfk_1` FOREIGN KEY (`id_user`) REFERENCES `mw_users` (`id`),\r
--- ADD CONSTRAINT `mw_users_roles_ibfk_2` FOREIGN KEY (`id_role`) REFERENCES `mw_roles` (`id`);\r
+++ /dev/null
-189
\ No newline at end of file
+++ /dev/null
-<tuple>
- <action><![CDATA[users/identification]]></action>
- <id_role><![CDATA[0]]></id_role>
-</tuple>
+++ /dev/null
-<tuple>
- <action><![CDATA[admin]]></action>
- <id_role><![CDATA[1]]></id_role>
-</tuple>
+++ /dev/null
-<tuple>
- <action><![CDATA[users]]></action>
- <id_role><![CDATA[2]]></id_role>
-</tuple>
+++ /dev/null
-<tuple>
- <action><![CDATA[config]]></action>
- <id_role><![CDATA[3]]></id_role>
-</tuple>
+++ /dev/null
-59
\ No newline at end of file
+++ /dev/null
-<tuple>
- <key><![CDATA[site_name]]></key>
- <value><![CDATA[mtweb]]></value>
-</tuple>
+++ /dev/null
-<tuple>
- <key><![CDATA[max_list]]></key>
- <value><![CDATA[10]]></value>
-</tuple>
+++ /dev/null
-<tuple>
- <key><![CDATA[description]]></key>
- <value><![CDATA[]]></value>
-</tuple>
+++ /dev/null
-<tuple>
- <key><![CDATA[out]]></key>
- <value><![CDATA[default]]></value>
-</tuple>
+++ /dev/null
-<tuple>
- <key><![CDATA[start_action]]></key>
- <value><![CDATA[]]></value>
-</tuple>
+++ /dev/null
-<tuple>
- <key><![CDATA[contact_form]]></key>
- <value><![CDATA[0]]></value>
-</tuple>
+++ /dev/null
-<tuple>
- <key><![CDATA[email]]></key>
- <value><![CDATA[]]></value>
-</tuple>
+++ /dev/null
-<tuple>
- <key><![CDATA[captcha]]></key>
- <value><![CDATA[0]]></value>
-</tuple>
+++ /dev/null
-<tuple>
- <key><![CDATA[out_navig_menu_top]]></key>
- <value><![CDATA[on]]></value>
-</tuple>
+++ /dev/null
-<tuple>
- <key><![CDATA[out_colonne]]></key>
- <value><![CDATA[on]]></value>
-</tuple>
+++ /dev/null
-<tuple>
- <key><![CDATA[start_action_params]]></key>
- <value><![CDATA[]]></value>
-</tuple>
+++ /dev/null
-<tuple>
- <key><![CDATA[default_allow]]></key>
- <value><![CDATA[1]]></value>
-</tuple>
+++ /dev/null
-5
\ No newline at end of file
+++ /dev/null
-<tuple>
- <nom><![CDATA[guest]]></nom>
- <intitule><![CDATA[invité]]></intitule>
-</tuple>
+++ /dev/null
-<tuple>
- <nom><![CDATA[admin]]></nom>
- <intitule><![CDATA[administrateur]]></intitule>
-</tuple>
+++ /dev/null
-<tuple>
- <nom><![CDATA[membre]]></nom>
- <intitule><![CDATA[membre]]></intitule>
-</tuple>
+++ /dev/null
-<tuple>
- <nom><![CDATA[webmaster]]></nom>
- <intitule><![CDATA[webmaster]]></intitule>
-</tuple>
+++ /dev/null
-18
\ No newline at end of file
+++ /dev/null
-<tuple>
- <login><![CDATA[admin]]></login>
- <password><![CDATA[25e4ee4e9229397b6b17776bfceaf8e7]]></password>
- <email><![CDATA[admin@domain.tld]]></email>
-</tuple>
+++ /dev/null
-33
\ No newline at end of file
+++ /dev/null
-<tuple>
- <id_user><![CDATA[18]]></id_user>
- <id_role><![CDATA[1]]></id_role>
-</tuple>
+++ /dev/null
-<tuple>
- <id_user><![CDATA[18]]></id_user>
- <id_role><![CDATA[2]]></id_role>
-</tuple>
+++ /dev/null
-<tuple>
- <id_user><![CDATA[18]]></id_user>
- <id_role><![CDATA[3]]></id_role>
-</tuple>
<?php
require "mw/mw_app.php";
- $app = new mw_app();
- if($app->init("config.php")){
- $app->run();
- $app->display();
- }
+ $app = new mw_app("pathes.php");
+ if($app->init() && $app->run()) $app->display();
+// else $app->show_logs();
?>
\ No newline at end of file
--- /dev/null
+<?php
+
+ class mw_install_index extends mw_controller{
+
+ var $config_file;
+
+ function validate(){
+ $env = $this->env();
+ $this->config_file = $env->path("content")."config/config.php";
+ if(file_exists($this->config_file)) return "le site est deja installé";
+ return true;
+ }
+
+ function index(){
+ $env = $this->env();
+ $data = $env->data();
+ $admin = array(
+ "login" => "",
+ "email" => "",
+ "password" => ""
+ );
+ if(($sgbds = $data->sgbds()) === false){
+ $env->erreur("impossible de lister les sgbds disponibles");
+ return;
+ }
+ $table_prefix = isset($_POST["table_prefix"]) ? $_POST["table_prefix"] : "mw_";
+ $env->add_table_prefix(
+ array(
+ "#--" => $table_prefix
+ )
+ );
+ $current_sgbd = "mw_pdo_sqlite";
+ if($_POST){
+ if(!isset($_POST["sgbd"])){
+ $env->erreur("Parametre de SGBD manquant");
+ return;
+ }
+ $current_sgbd = $_POST["sgbd"];
+ $SGBD_FOUND = false;
+ foreach($sgbds as $class_name => $sgbd){
+ if($current_sgbd == $class_name){
+ $SGBD_FOUND = true;
+ break;
+ }
+ }
+ if(!$SGBD_FOUND){
+ $env->erreur("SGBD inconnu: ".$current_sgbd);
+ return;
+ }
+ if(!file_exists($template_file = $env->path("content")."config/templates/".$current_sgbd.".php")){
+ $env->erreur("le fichier de template pour la configuration avec ".$current_sgbd." n'existe pas");
+ return;
+ }
+ $params = array(
+ "host" => isset($_POST[$current_sgbd."_host"]) ? $_POST[$current_sgbd."_host"] : "",
+ "base" => isset($_POST[$current_sgbd."_base"]) ? $_POST[$current_sgbd."_base"] : "",
+ "user" => isset($_POST[$current_sgbd."_user"]) ? $_POST[$current_sgbd."_user"] : "",
+ "password" => isset($_POST[$current_sgbd."_password"]) ? $_POST[$current_sgbd."_password"] : ""
+ );
+ $admin = array(
+ "login" => trim($_POST["admin_login"]),
+ "email" => trim($_POST["admin_email"]),
+ "password" => $_POST["admin_password"]
+ );
+ if(!$admin["login"]){
+ $env->message("merci de choisir un login pour l'administrateur");
+ }
+ if(!$admin["email"]){
+ $env->message("merci de préciser l'email de l'administrateur");
+ }
+ if($admin["password"]){
+ if($admin["password"] != $_POST["admin_password_confirm"]){
+ $env->message("la confirmation du mot de passe est incorrecte");
+ }
+ }
+ else $env->message("merci de choisir un mot de passe pour l'administrateur");
+ if(!$env->messages()){
+ $sgbds[$current_sgbd] = null;
+ $impl = new $current_sgbd($params);
+ $sgbds[$current_sgbd] = $impl;
+ $data->set_sgbd(
+ new mw_sgbd(
+ $sgbds[$current_sgbd],
+ $env
+ )
+ );
+ $data->load_modules($env->path("mw_dir")."app/", "data/modules/".($current_sgbd == "mw_xml" ? "xml" : "sql")."/");
+ if(
+ $current_sgbd == "mw_xml"
+ ){
+ if(($res = $data->install_xml($params)) !== true){
+ $env->message($res);
+ }
+ }
+ elseif(
+ $current_sgbd == "mw_mysql"
+ || $current_sgbd == "mw_pdo_mysql"
+ ){
+ if(($res = $data->install_sql($params)) !== true){
+ $env->message($res);
+ }
+ }
+ elseif(
+ $current_sgbd == "mw_pdo_sqlite"
+ ){
+ if(($res = $data->install_sqlite($params)) !== true){
+ $env->message($res);
+ }
+ }
+ }
+ if(!$env->messages()){
+ if(($roles = $data->init_roles()) === false){
+ $env->erreur("la base de données a été installée mais impossible de lire la liste des roles");
+ return;
+ }
+ $admin_roles = array();
+ foreach($roles as $id_role => $role){
+ if(
+ ($role["nom"] == "admin")
+ || ($role["nom"] == "membre")
+ || ($role["nom"] == "webmaster")
+ ){
+ $admin_roles[] = $id_role;
+ }
+ }
+ if(!$data->add_user($admin["login"], md5($admin["password"]), $admin["email"], $admin_roles)){
+ $env->erreur("la base de données a été installée mais impossible d'ajouter l'administrateur");
+ return;
+ }
+ }
+ if(!$env->messages()){
+ if(!$content = @file_get_contents($template_file)){
+ $env->erreur("impossible de lire le fichier de template pour la configuration avec ".$current_sgbd);
+ return;
+ }
+ if(
+ @file_put_contents(
+ $this->config_file,
+ str_replace(
+ array(
+ "[bdd_host]",
+ "[bdd_base]",
+ "[bdd_prefix]",
+ "[bdd_user]",
+ "[bdd_password]"
+ ),
+ array(
+ $params["host"],
+ $params["base"],
+ $table_prefix,
+ $params["user"],
+ $params["password"]
+ ),
+ $content
+ )
+ ) === false
+ ){
+ $env->erreur("impossible de créer le fichier de configuration");
+ return;
+ }
+ $env->redirect(
+ $env->url(),
+ "le site a été installé"
+ );
+ }
+ }
+ $env->set_out("sgbds", $sgbds);
+ $env->set_out("current_sgbd", $current_sgbd);
+ $env->set_out("table_prefix", $table_prefix);
+ $env->set_out("admin", $admin);
+ }
+
+ }
+
+?>
\ No newline at end of file
function extention_ok(&$env) { return $this->EXTENTION_OK; }
- function mw_mysql($host, $base, $user, $password){
- $this->host = $host;
- $this->base = $base;
- $this->user = $user;
- $this->password = $password;
+ function authentication_required() { return true; }
+
+ function sgbd_name() { return "MySql"; }
+
+ function mw_mysql($params = array()){
+ $this->host = isset($params["host"]) ? $params["host"] : "localhost";
+ $this->base = isset($params["base"]) ? $params["base"] : "mtweb";
+ $this->user = isset($params["user"]) ? $params["user"] : "";
+ $this->password = isset($params["password"]) ? $params["password"] : "";
$this->EXTENTION_OK = function_exists("mysql_connect");
}
function extention_ok(&$env) { return $this->EXTENTION_OK; }
- function mw_pdo_mysql($host, $base, $user, $password){
- $this->host = $host;
- $this->base = $base;
- $this->user = $user;
- $this->password = $password;
+ function authentication_required() { return true; }
+
+ function sgbd_name() { return "PDO MySql"; }
+
+ function mw_pdo_mysql($params = array()){
+ $this->host = isset($params["host"]) ? $params["host"] : "localhost";
+ $this->base = isset($params["base"]) ? $params["base"] : "mtweb";
+ $this->user = isset($params["user"]) ? $params["user"] : "";
+ $this->password = isset($params["password"]) ? $params["password"] : "";
$this->EXTENTION_OK = (extension_loaded("pdo") && extension_loaded("pdo_mysql"));
}
--- /dev/null
+<?php
+
+ class mw_pdo_sqlite{
+
+ var $link;
+
+ var $host;
+ var $base;
+ var $user;
+ var $password;
+
+ var $EXTENTION_OK;
+
+ function get_link(){
+ return $this->link;
+ }
+
+ function extention_ok(&$env) { return $this->EXTENTION_OK; }
+
+ function authentication_required() { return false; }
+
+ function sgbd_name() { return "PDO SQLite"; }
+
+ function mw_pdo_sqlite($params = array()){
+ $this->host = isset($params["host"]) ? $params["host"] : "content/data/sqlite";
+ $this->base = isset($params["base"]) ? $params["base"] : "mtweb.db";
+ $this->user = isset($params["user"]) ? $params["user"] : "";
+ $this->password = isset($params["password"]) ? $params["password"] : "";
+ $this->EXTENTION_OK = (extension_loaded("pdo") && extension_loaded("pdo_sqlite"));
+ }
+
+ function connect($host, $base, $user, $password){
+ if($host) $host .= substr($host, -1) != "/" ? "/" : "";
+ try{
+ $this->link = null;
+ $this->link = new PDO("sqlite:".$host.$base);
+ $this->link->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
+ $this->link->query("PRAGMA encoding = 'UTF-8'");
+ }
+ catch(PDOException $e){
+ throw new Exception($this->exception_out("Impossible d'etablir une connection au serveur"));
+ }
+ return true;
+ }
+
+ function select_db($db_name){\r
+ $this->base = $db_name;\r
+ return $this->connect($this->host, $this->base, $this->user, $this->password);\r
+ }
+
+ function desc_table($table_name){
+ $sql = "SELECT * from information_schema.columns where table_name='".$table_name."'";
+ $rst = $this->query($sql);
+ $desc = array(
+ "name" => $table_name,
+ "attributs" => array()
+ );
+ try{
+ while($v_rst = $this->fetch_assoc($rst)){\r
+ $desc["attributs"][$v_rst["COLUMN_NAME"]] = array(
+ "name" => $v_rst["COLUMN_NAME"],
+ "prymary_key" => $v_rst["COLUMN_KEY"] == "PRI" ? true : false,
+ "auto_increment" => $v_rst["EXTRA"] == "auto_increment" ? true : false
+ );
+ }\r
+ $this->free_result($rst);
+ }
+ catch(Exception $e){
+ throw new Exception($this->exception_out("Impossible de lire la description de la table"));
+ }
+ return $desc;
+ }
+
+ function table_exists($table_name){
+ if(!$this->link) $this->connect($this->host, $this->base, $this->user, $this->password);\r
+ $EXISTS = false;
+ try{
+ $rst = $this->query("SELECT name FROM sqlite_master WHERE type='table'");
+ while($v_rst = $rst->fetch()){\r
+ if($v_rst[0] == $table_name){
+ $EXISTS = true;
+ break;
+ }\r
+ }\r
+ $this->free_result($rst);
+ }
+ catch(Exception $e){
+ throw new Exception($this->exception_out("Impossible de savoir si la table existe"));
+ }
+ return $EXISTS;\r
+ }
+
+ function field_exists($table_name, $field_name){
+ if(!$this->link) $this->connect($this->host, $this->base, $this->user, $this->password);\r
+ if(!($desc = $this->desc_table($table_name))){
+ throw new Exception($this->exception_out("Impossible de lire la description de la table"));
+ }
+ $EXISTS = false;
+ foreach($desc["attributs"] as $attribut_name => $attribut){
+ if($field_name == $attribut_name){
+ $EXISTS = true;
+ break;
+ }
+ }
+ return $EXISTS;
+ }
+
+ function query($query_string){\r
+ if(!$this->link) $this->connect($this->host, $this->base, $this->user, $this->password);\r
+ if(!($result = $this->link->query($query_string))){
+ throw new Exception($this->exception_out("Syntaxe invalide dans une requete"));
+ }
+ return $result;\r
+ }
+
+ function fetch_assoc($rst){
+ if(!$this->link){
+ throw new Exception($this->exception_out("fetch_assoc sans connexion"));
+ }
+ if(!$rst){
+ throw new Exception($this->exception_out("fetch_assoc sans result handler"));
+ }
+ try{
+ $tuple = $rst->fetch(PDO::FETCH_ASSOC);
+ }
+ catch(Exception $e){
+ throw new Exception($this->exception_out("erreur fetch_assoc"));
+ }
+ return $tuple;
+ }
+
+ function insert_id(){
+ if(!$this->link){
+ throw new Exception($this->exception_out("insert_id sans connexion"));
+ }
+ try{
+ $id = $this->link->lastInsertId();
+ }
+ catch(Exception $e){
+ throw new Exception($this->exception_out("erreur insert_id"));
+ }
+ return $id;
+ }
+
+ function free_result($rst){
+ if(!$this->link){
+ throw new Exception($this->exception_out("free_result sans connexion"));
+ }
+ if(!$rst){
+ throw new Exception($this->exception_out("free_result sans result handler"));
+ }
+ try{
+ $rst->closeCursor();
+ $rst = null;
+ }
+ catch(Exception $e){
+ throw new Exception($this->exception_out("erreur free_result"));
+ }
+ return true;
+ }
+
+ function close(){
+ $this->link = null;
+ return true;
+ }
+
+ function exception_out($message){\r
+ return "[erreur] sqlite : ".$message;\r
+ }
+
+ }
+
+?>
\ No newline at end of file
var $data_handlers;
var $last_data_handler;
- function mw_xml($host, $base, $user, $password){
- $this->init_xml_env($host, $base, $user, $password);
+ function mw_xml($params = array()){
+ $this->init_xml_env(
+ isset($params["host"]) ? $params["host"] : "content/data/xml",
+ isset($params["base"]) ? $params["base"] : "mw",
+ isset($params["user"]) ? $params["user"] : "",
+ isset($params["password"]) ? $params["password"] : ""
+ );
$this->EXTENTION_OK = true;
}
return $this->EXTENTION_OK;
}
+ function authentication_required() { return false; }
+
+ function sgbd_name() { return "XML"; }
+
function init_xml_env($host, $base, $user, $password){
$this->host = $host.($host && substr($host, -1) != "/" ? "/" : "");
$this->base = $base.($base && substr($base, -1) != "/" ? "/" : "");
return false;
}
- function add_data($data_path, $data){
+ function add_data($data_path, $data, $index = null){
$dh = ++$this->last_data_handler;
$this->data_handlers[$dh] = new mw_xml_data_handler($this->xml_data, $data_path);
if($this->data_handlers[$dh]->open_data(false)){
- $res = $this->data_handlers[$dh]->add_data($data);
+ $res = $this->data_handlers[$dh]->add_data($data, $index);
if($res) $res = $this->last_index($dh);
$this->close_data($dh);
return $res;
return false;
}
- function add_data($data){
- $index = $this->inc_index();
+ function add_data($data, $index = null){
+ if(!isset($index)) $index = $this->inc_index();
if(isset($index)){
if(is_array($data)) return $this->xml_data->add_data($this->data_path, $index, $data);
}
--- /dev/null
+<?php
+
+ class mw_data_sgbds extends mw_data{
+
+ function sgbds(){
+ $env = $this->env();
+ $sgbds = array();
+ $impls_dir = $env->app_file("data/impl");
+ if(!file_exists($impls_dir) || !is_dir($impls_dir)){
+ return false;
+ }
+ if($dh = opendir($impls_dir)){
+ $OK = true;
+ while($OK && ($impl_file = readdir($dh)) !== false){
+ if(substr($impl_file, 0 ,1) !== "." && substr($impl_file, -4) == ".php"){
+ require_once $impls_dir."/".$impl_file;
+ if(class_exists($class_name = substr($impl_file, 0, -4))){
+ if(
+ method_exists($class_name, "sgbd_name")
+ && method_exists($class_name, "extention_ok")
+ ){
+ $impl = new $class_name();
+ if($impl->extention_ok($env)) $sgbds[$class_name] = $impl;
+ }
+ }
+ }
+ }
+ }
+ else{
+ return false;
+ }
+ return $sgbds;
+ }
+
+ }
+
+?>
\ No newline at end of file
--- /dev/null
+<?php
+
+ class mw_data_sql_install extends mw_data{
+
+ function install_sql($params){
+ $env = $this->env();
+ $data = $env->data();
+ $sgbd = $data->sgbd();
+ $host = isset($params["host"]) ? $params["host"] : "";
+ $base = isset($params["base"]) ? $params["base"] : "";
+ $user = isset($params["user"]) ? $params["user"] : "";
+ $password = isset($params["password"]) ? $params["password"] : "";
+ try{
+ $sgbd->connect(
+ $host,
+ $base,
+ $user,
+ $password
+ );
+ $sgbd->select_db($base);
+ }
+ catch(Exception $e){
+ return $e->getMessage();
+ }
+ try{
+ $EXISTS =
+ $sgbd->table_exists("#--actions_roles")
+ || $sgbd->table_exists("#--config")
+ || $sgbd->table_exists("#--roles")
+ || $sgbd->table_exists("#--users")
+ || $sgbd->table_exists("#--users_roles");
+ }
+ catch(Exception $e){
+ return "impossible de savoir si les tables existent deja";
+ }
+ if($EXISTS){
+ return "des tables a installer existent deja en base. installation annulee";
+ }
+ try{
+
+ $sql =
+ "SET SQL_MODE=\"NO_AUTO_VALUE_ON_ZERO\"";
+ $sgbd->query($sql);
+
+ $sql =
+ "CREATE TABLE #--actions_roles("\r
+ ." id int(11) NOT NULL AUTO_INCREMENT,"\r
+ ." `action` varchar(255) NOT NULL,"\r
+ ." id_role int(11) NOT NULL,"\r
+ ." PRIMARY KEY (id),"\r
+ ." KEY id_role(id_role)"\r
+ .") DEFAULT CHARSET=utf8";
+ $sgbd->query($sql);
+
+ $sql =
+ "CREATE TABLE #--config("\r
+ ." id int(11) NOT NULL AUTO_INCREMENT,"\r
+ ." `key` varchar(255) NOT NULL,"\r
+ ." `value` text NOT NULL,"\r
+ ." PRIMARY KEY (id)"\r
+ .") DEFAULT CHARSET=utf8";
+ $sgbd->query($sql);
+
+ $sql =
+ "CREATE TABLE #--roles("\r
+ ." id int(11) NOT NULL AUTO_INCREMENT,"\r
+ ." nom varchar(255) NOT NULL,"\r
+ ." intitule varchar(255) NOT NULL,"\r
+ ." KEY id (id)"\r
+ .") DEFAULT CHARSET=utf8";
+ $sgbd->query($sql);
+
+ $sql =
+ "CREATE TABLE #--users("\r
+ ." id int(11) NOT NULL AUTO_INCREMENT,"\r
+ ." login varchar(255) NOT NULL,"\r
+ ." password varchar(255) NOT NULL,"\r
+ ." email varchar(255) NOT NULL,"\r
+ ." PRIMARY KEY (id)"\r
+ .") DEFAULT CHARSET=utf8";
+ $sgbd->query($sql);
+
+ $sql =
+ "CREATE TABLE #--users_roles("\r
+ ." id_user int(11) NOT NULL,"\r
+ ." id_role int(11) NOT NULL,"\r
+ ." PRIMARY KEY (id_user,id_role),"\r
+ ." KEY id_role(id_role)"\r
+ .") DEFAULT CHARSET=utf8";
+ $sgbd->query($sql);
+
+ }
+ catch(Exception $e){
+ return "imposible de creer les tables en base";
+ }
+ try{
+ $sql =
+ "INSERT INTO #--actions_roles(`id`, `action`, `id_role`) VALUES"\r
+ ."(13, 'admin', 1),"\r
+ ."(14, 'users', 2),"\r
+ ."(19, 'users/identification', 0),"\r
+ ."(20, 'config', 3)";
+ $sgbd->query($sql);
+
+ $sql =
+ "INSERT INTO #--config(id, `key`, `value`) VALUES"\r
+ ."(1, 'site_name', 'mtweb'),"\r
+ ."(2, 'max_list', '10'),"\r
+ ."(3, 'description', ''),"\r
+ ."(4, 'out', 'default'),"\r
+ ."(5, 'start_action', ''),"\r
+ ."(6, 'contact_form', '0'),"\r
+ ."(8, 'email', ''),"\r
+ ."(9, 'captcha', '0'),"\r
+ ."(16, 'start_action_params', ''),"\r
+ ."(20, 'out_navig_menu_top', 'on'),"\r
+ ."(22, 'out_colonne', 'on'),"\r
+ ."(29, 'default_allow', '1')";
+ $sgbd->query($sql);
+
+ $sql =
+ "INSERT INTO #--roles(`id`, `nom`, `intitule`) VALUES"\r
+ ."(0, 'guest', 'invité'),"\r
+ ."(1, 'admin', 'administrateur'),"\r
+ ."(2, 'membre', 'membre'),"\r
+ ."(3, 'webmaster', 'webmaster')";
+ $sgbd->query($sql);
+
+ }
+ catch(Exception $e){
+ return "les tables ont ete ajoutees en base mais impossible d'y enregistrer les valeurs par defaut.";
+ }
+ return true;
+ }
+
+ }
+
+?>
\ No newline at end of file
--- /dev/null
+<?php
+
+ class mw_data_sqlite_install extends mw_data{
+
+ function install_sqlite($params){
+ $env = $this->env();
+ $data = $env->data();
+ $sgbd = $data->sgbd();
+ $host = isset($params["host"]) ? $params["host"] : "";
+ $base = isset($params["base"]) ? $params["base"] : "";
+ $user = isset($params["user"]) ? $params["user"] : "";
+ $password = isset($params["password"]) ? $params["password"] : "";
+ if(!$host || !$base) return "paramètres manquant pour la base SQLite";
+ if(!is_dir($host)){
+ $parent_dir = dirname($host);
+ if(is_dir($parent_dir)) @mkdir($host);
+ if(!is_dir($host)) return "impossible de créer le répertoire des données SQLite";
+ }
+ try{
+ $sgbd->connect(
+ $host,
+ $base,
+ $user,
+ $password
+ );
+ $sgbd->select_db($base);
+ }
+ catch(Exception $e){
+ return $e->getMessage();
+ }
+ try{
+ $EXISTS =
+ $sgbd->table_exists("#--actions_roles")
+ || $sgbd->table_exists("#--config")
+ || $sgbd->table_exists("#--roles")
+ || $sgbd->table_exists("#--users")
+ || $sgbd->table_exists("#--users_roles");
+ }
+ catch(Exception $e){
+ return "impossible de savoir si les tables existent deja";
+ }
+ if($EXISTS){
+ return "des tables a installer existent deja en base. installation annulee";
+ }
+ try{
+
+ $sql =
+ "CREATE TABLE #--actions_roles("\r
+ ." id INTEGER PRIMARY KEY AUTOINCREMENT,"
+ ." `action` TEXT NOT NULL,"\r
+ ." id_role INTEGER NOT NULL"\r
+ .")";
+ $sgbd->query($sql);
+
+ $sql =
+ "CREATE TABLE #--config("\r
+ ." id INTEGER PRIMARY KEY AUTOINCREMENT,"\r
+ ." `key` TEXT NOT NULL,"\r
+ ." `value` TEXT NOT NULL"\r
+ .")";
+ $sgbd->query($sql);
+
+ $sql =
+ "CREATE TABLE #--roles("\r
+ ." id INTEGER PRIMARY KEY AUTOINCREMENT,"\r
+ ." nom TEXT NOT NULL,"\r
+ ." intitule TEXT NOT NULL"\r
+ .")";
+ $sgbd->query($sql);
+
+ $sql =
+ "CREATE TABLE #--users("\r
+ ." id INTEGER PRIMARY KEY AUTOINCREMENT,"\r
+ ." login TEXT NOT NULL,"\r
+ ." password TEXT NOT NULL,"\r
+ ." email TEXT NOT NULL"\r
+ .")";
+ $sgbd->query($sql);
+
+ $sql =
+ "CREATE TABLE #--users_roles("\r
+ ." id INTEGER PRIMARY KEY AUTOINCREMENT,"\r
+ ." id_user INTEGER NOT NULL,"\r
+ ." id_role INTEGER NOT NULL"
+ .")";
+ $sgbd->query($sql);
+
+ }
+ catch(Exception $e){
+ return "imposible de creer les tables en base. ".$e->getMessage();
+ }
+ try{
+ $sql =
+ "INSERT INTO #--actions_roles (`id`, `action`, `id_role`) VALUES (13, 'admin', 1)";\r
+ $sgbd->query($sql);
+ $sql =
+ "INSERT INTO #--actions_roles (`id`, `action`, `id_role`) VALUES (14, 'users', 2)";
+ $sgbd->query($sql);
+ $sql =
+ "INSERT INTO #--actions_roles (`id`, `action`, `id_role`) VALUES (19, 'users/identification', 0)";
+ $sgbd->query($sql);
+ $sql =
+ "INSERT INTO #--actions_roles (`id`, `action`, `id_role`) VALUES (20, 'config', 3)";\r
+ $sgbd->query($sql);
+
+ $sql =
+ "INSERT INTO #--config(id, `key`, `value`) VALUES (1, 'site_name', 'mtweb')";\r
+ $sgbd->query($sql);
+ $sql =
+ "INSERT INTO #--config(id, `key`, `value`) VALUES (2, 'max_list', '10')";
+ $sgbd->query($sql);
+ $sql =
+ "INSERT INTO #--config(id, `key`, `value`) VALUES (3, 'description', '')";\r
+ $sgbd->query($sql);
+ $sql =
+ "INSERT INTO #--config(id, `key`, `value`) VALUES (4, 'out', 'default')";
+ $sgbd->query($sql);
+ $sql =
+ "INSERT INTO #--config(id, `key`, `value`) VALUES (5, 'start_action', '')";\r
+ $sgbd->query($sql);
+ $sql =
+ "INSERT INTO #--config(id, `key`, `value`) VALUES (6, 'contact_form', '0')";
+ $sgbd->query($sql);
+ $sql =
+ "INSERT INTO #--config(id, `key`, `value`) VALUES (8, 'email', '')";\r
+ $sgbd->query($sql);
+ $sql =
+ "INSERT INTO #--config(id, `key`, `value`) VALUES (9, 'captcha', '0')";
+ $sgbd->query($sql);
+ $sql =
+ "INSERT INTO #--config(id, `key`, `value`) VALUES (16, 'start_action_params', '')";\r
+ $sgbd->query($sql);
+ $sql =
+ "INSERT INTO #--config(id, `key`, `value`) VALUES (20, 'out_navig_menu_top', 'on')";
+ $sgbd->query($sql);
+ $sql =
+ "INSERT INTO #--config(id, `key`, `value`) VALUES (22, 'out_colonne', 'on')";\r
+ $sgbd->query($sql);
+ $sql =
+ "INSERT INTO #--config(id, `key`, `value`) VALUES (29, 'default_allow', '1')";
+ $sgbd->query($sql);
+
+ $sql =
+ "INSERT INTO #--roles(`id`, `nom`, `intitule`) VALUES (0, 'guest', 'invité')";\r
+ $sgbd->query($sql);
+ $sql =
+ "INSERT INTO #--roles(`id`, `nom`, `intitule`) VALUES (1, 'admin', 'administrateur')";
+ $sgbd->query($sql);
+ $sql =
+ "INSERT INTO #--roles(`id`, `nom`, `intitule`) VALUES (2, 'membre', 'membre')";
+ $sgbd->query($sql);
+ $sql =
+ "INSERT INTO #--roles(`id`, `nom`, `intitule`) VALUES (3, 'webmaster', 'webmaster')";
+ $sgbd->query($sql);
+
+ }
+ catch(Exception $e){
+ return "les tables ont ete ajoutees en base mais impossible d'y enregistrer les valeurs par defaut.";
+ }
+ return true;
+ }
+
+ }
+
+?>
\ No newline at end of file
--- /dev/null
+<?php
+
+ class mw_data_xml_install extends mw_data{
+
+ function install_xml($params){
+ $env = $this->env();
+ $data = $env->data();
+ $sgbd = $data->sgbd();
+ $host = isset($params["host"]) ? $params["host"] : "";
+ $base = isset($params["base"]) ? $params["base"] : "";
+ $user = isset($params["user"]) ? $params["user"] : "";
+ $password = isset($params["password"]) ? $params["password"] : "";
+ if(!$host || !$base) return "paramètres manquant pour la base XML";
+ $host .= substr($host, -1) == "/" ? "" : "/";
+ if(!is_dir($host)){
+ $parent_dir = dirname($host);
+ if(is_dir($parent_dir)) @mkdir($host);
+ if(!is_dir($host)) return "impossible de créer le répertoire des données XML";
+ }
+ $base_dir = $host.$base;
+ if(!is_dir($base_dir)) @mkdir($base_dir);
+ if(!is_dir($base_dir)) return "impossible de créer le dossier de la base XML";
+ $base .= substr($base, -1) == "/" ? "" : "/";
+ if(
+ !$sgbd->connect(
+ $host,
+ $base,
+ $user,
+ $password
+ )
+ || !$sgbd->select_db($base)
+ ){
+ return "impossible de se connecter à la base XML";
+ }
+ $ERROR = false;
+ $EXISTS = false;
+ if(!$ERROR && !$EXISTS) $EXISTS = $sgbd->data_exists("actions_roles");
+ $ERROR = !isset($EXISTS);
+ if(!$ERROR && !$EXISTS) $EXISTS = $sgbd->data_exists("config");
+ $ERROR = !isset($EXISTS);
+ if(!$ERROR && !$EXISTS) $EXISTS = $sgbd->data_exists("roles");
+ $ERROR = !isset($EXISTS);
+ if(!$ERROR && !$EXISTS) $EXISTS = $sgbd->data_exists("users");
+ $ERROR = !isset($EXISTS);
+ if(!$ERROR && !$EXISTS) $EXISTS = $sgbd->data_exists("users_roles");
+ $ERROR = !isset($EXISTS);
+ if($ERROR){
+ return "impossible de savoir si les tables existent deja";
+ }
+ if($EXISTS){
+ return "des tables a installer existent deja en base. installation annulee";
+ }
+ if(!$ERROR) if(!$sgbd->create_data("actions_roles")) $ERROR = true;
+ if(!$ERROR) if(!$sgbd->create_data("config")) $ERROR = true;
+ 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){
+ return "imposible de creer les tables en base";
+ }
+
+ // ------------------------------------ actions_roles
+ if(!$ERROR) if(
+ !$sgbd->add_data(
+ "actions_roles",
+ array(
+ "action" => "admin",
+ "id_role" => 1
+ )
+ )
+ ) $ERROR = true;
+ if(!$ERROR) if(
+ !$sgbd->add_data(
+ "actions_roles",
+ array(
+ "action" => "users",
+ "id_role" => 2
+ )
+ )
+ ) $ERROR = true;
+ if(!$ERROR) if(
+ !$sgbd->add_data(
+ "actions_roles",
+ array(
+ "action" => "users/identification",
+ "id_role" => 0
+ )
+ )
+ ) $ERROR = true;
+ if(!$ERROR) if(
+ !$sgbd->add_data(
+ "actions_roles",
+ array(
+ "action" => "config",
+ "id_role" => 3
+ )
+ )
+ ) $ERROR = true;
+
+ // ------------------------------------ config
+ if(!$ERROR) if(
+ !$sgbd->add_data(
+ "config",
+ array(
+ "key" => "site_name",
+ "value" => "mtweb"
+ )
+ )
+ ) $ERROR = true;
+ if(!$ERROR) if(
+ !$sgbd->add_data(
+ "config",
+ array(
+ "key" => "max_list",
+ "value" => "10"
+ )
+ )
+ ) $ERROR = true;
+ if(!$ERROR) if(
+ !$sgbd->add_data(
+ "config",
+ array(
+ "key" => "description",
+ "value" => ""
+ )
+ )
+ ) $ERROR = true;
+ if(!$ERROR) if(
+ !$sgbd->add_data(
+ "config",
+ array(
+ "key" => "out",
+ "value" => "default"
+ )
+ )
+ ) $ERROR = true;
+ if(!$ERROR) if(
+ !$sgbd->add_data(
+ "config",
+ array(
+ "key" => "start_action",
+ "value" => ""
+ )
+ )
+ ) $ERROR = true;
+ if(!$ERROR) if(
+ !$sgbd->add_data(
+ "config",
+ array(
+ "key" => "contact_form",
+ "value" => "0"
+ )
+ )
+ ) $ERROR = true;
+ if(!$ERROR) if(
+ !$sgbd->add_data(
+ "config",
+ array(
+ "key" => "email",
+ "value" => ""
+ )
+ )
+ ) $ERROR = true;
+ if(!$ERROR) if(
+ !$sgbd->add_data(
+ "config",
+ array(
+ "key" => "captcha",
+ "value" => "0"
+ )
+ )
+ ) $ERROR = true;
+ if(!$ERROR) if(
+ !$sgbd->add_data(
+ "config",
+ array(
+ "key" => "start_action_params",
+ "value" => ""
+ )
+ )
+ ) $ERROR = true;
+ if(!$ERROR) if(
+ !$sgbd->add_data(
+ "config",
+ array(
+ "key" => "out_navig_menu_top",
+ "value" => "on"
+ )
+ )
+ ) $ERROR = true;
+ if(!$ERROR) if(
+ !$sgbd->add_data(
+ "config",
+ array(
+ "key" => "out_colonne",
+ "value" => "on"
+ )
+ )
+ ) $ERROR = true;
+ if(!$ERROR) if(
+ !$sgbd->add_data(
+ "config",
+ array(
+ "key" => "default_allow",
+ "value" => "1"
+ )
+ )
+ ) $ERROR = true;
+
+ // ------------------------------------ roles
+ if(!$ERROR){
+ $res = $sgbd->add_data(
+ "roles",
+ array(
+ "nom" => "guest",
+ "intitule" => "invité"
+ ),
+ 0
+ );
+ if(!isset($res)) $ERROR = true;
+ }
+ if(!$ERROR) if(
+ !$sgbd->add_data(
+ "roles",
+ array(
+ "nom" => "admin",
+ "intitule" => "administrateur"
+ )
+ )
+ ) $ERROR = true;
+ if(!$ERROR) if(
+ !$sgbd->add_data(
+ "roles",
+ array(
+ "nom" => "membre",
+ "intitule" => "membre"
+ )
+ )
+ ) $ERROR = true;
+ if(!$ERROR) if(
+ !$sgbd->add_data(
+ "roles",
+ array(
+ "nom" => "webmaster",
+ "intitule" => "webmaster"
+ )
+ )
+ ) $ERROR = true;
+
+ if($ERROR){
+ return "les tables ont ete ajoutees en base mais impossible d'y enregistrer les valeurs par defaut.";
+ }
+
+ return true;
+ }
+
+ }
+
+?>
\ No newline at end of file
return $this->sgbd_impl->extention_ok($this->env);
}
+ function authentication_required(){
+ return $this->sgbd_impl->authentication_required();
+ }
+
function connect($host, $base, $user, $password){
return $this->sgbd_impl->connect($host, $base, $user, $password);
}
return $this->sgbd_impl->fetch_data($dh);
}
- function add_data($data_path, $data){
+ function add_data($data_path, $data, $index = null){
if(!method_exists($this->sgbd_impl, "add_data")) return false;
- return $this->sgbd_impl->add_data($data_path, $data);
+ return $this->sgbd_impl->add_data($data_path, $data, $index);
}
function last_index($dh){
if(!class_exists("mw_sgbd")) require_once $this->app_file("data/mw_sgbd.php");
if(!class_exists("mw_data")) require_once $this->app_file("data/mw_data.php");
- if($this->app_file_exists("data/impl/mw_".$this->bdd("sgbd").".php")){
+ if(($plugins = $this->plugins("DESC")) === false){
+ $this->erreur("Impossible de lire les plugins pour charger les modules de donnees", true);
+ }
+ $data = new mw_data(true);
+ if($this->bdd("sgbd")){
+ if(!$this->app_file_exists("data/impl/mw_".$this->bdd("sgbd").".php")){
+ $this->erreur("Impossible de trouver le fichier d'implementation du sgbd ".$this->bdd("sgbd"), true);
+ }
$sgbd_impl = "mw_".$this->bdd("sgbd");
if(!class_exists($sgbd_impl)) require_once $this->app_file("data/impl/".$sgbd_impl.".php");
- if(class_exists($sgbd_impl)){
- if(($plugins = $this->plugins("DESC")) !== false){
- $data = new mw_data(true);
- foreach($plugins as $plugin_name => $plugin){
- if($plugin["installed"] && $plugin["enabled"]){
- $data->load_modules($this->path("mw_dir")."plugins/".$plugin_name."/app/", "data/modules/share/");
- $data->load_modules($this->path("mw_dir")."plugins/".$plugin_name."/app/", "data/modules/".($this->bdd("sgbd") == "xml" ? "xml" : "sql")."/");
- }
- }
- $data->load_modules($this->path("mw_dir")."app/", "data/modules/share/");
- $data->load_modules($this->path("mw_dir")."app/", "data/modules/".($this->bdd("sgbd") == "xml" ? "xml" : "sql")."/");
- $sgbd = new mw_sgbd(
- new $sgbd_impl(
- $this->bdd("host"),
- $this->bdd("base"),
- $this->bdd("user"),
- $this->bdd("password")
- ),
- $this
- );
- if($sgbd->extention_ok()){
- $data->set_sgbd($sgbd);
- $data->set_env($this);
- $this->set_data($data);
- }
- else $this->erreur("L'extention php ".$this->bdd("sgbd")." n'est pas installée", true);
+ if(!class_exists($sgbd_impl)){
+ $this->erreur("Impossible de trouver la classe d'implementation du sgbd ".$this->bdd("sgbd"), true);
+ }
+ $sgbd = new mw_sgbd(
+ new $sgbd_impl(
+ array(
+ "host" => $this->bdd("host"),
+ "base" => $this->bdd("base"),
+ "user" => $this->bdd("user"),
+ "password" => $this->bdd("password")
+ )
+ ),
+ $this
+ );
+ if(!$sgbd->extention_ok()){
+ $this->erreur("L'extention php ".$this->bdd("sgbd")." n'est pas installée", true);
+ }
+ }
+ foreach($plugins as $plugin_name => $plugin){
+ if($plugin["installed"] && $plugin["enabled"]){
+ $data->load_modules($this->path("mw_dir")."plugins/".$plugin_name."/app/", "data/modules/share/");
+ if($this->bdd("sgbd")){
+ $data->load_modules($this->path("mw_dir")."plugins/".$plugin_name."/app/", "data/modules/".($this->bdd("sgbd") == "xml" ? "xml" : "sql")."/");
}
- else $this->erreur("Impossible de lire les plugins pour charger les modules de donnees");
}
- else $this->erreur("Impossible de trouver la classe d'implementation du sgbd ".$this->bdd("sgbd"), true);
}
- else $this->erreur("Impossible de trouver le fichier d'implementation du sgbd ".$this->bdd("sgbd"), true);
+ $data->load_modules($this->path("mw_dir")."app/", "data/modules/share/");
+ if($this->bdd("sgbd")){
+ $data->load_modules($this->path("mw_dir")."app/", "data/modules/".($this->bdd("sgbd") == "xml" ? "xml" : "sql")."/");
+ $data->set_sgbd($sgbd);
+ }
+ $data->set_env($this);
+ $this->set_data($data);
?>
\ No newline at end of file
<?php
+ if(!$this->bdd("sgbd")) return;
if(($config = $data->config()) !== false){
$this->set_config($config);
$start_action_params_config =
<?php
+ if(!$this->bdd("sgbd")) return;
if($data->load_session() !== false){
if($data->init_roles() !== false){
if($data->init_actions_roles() === false){
--- /dev/null
+#sgbds .sgbd{
+ display: none;
+}
+
+#sgbds .sgbd.current{
+ display: block;
+}
+
+#colonne p{
+ font-size: 1em;
+ color: #333333;
+ padding: 1em;
+}
\ No newline at end of file
--- /dev/null
+<!doctype html>
+<html>
+ <head>
+<?php require $this->out_file("views/install/head.php"); ?>
+ </head>
+ <body>
+
+ <header id="main_header">
+ <div class="content">
+<?php require $this->out_file("views/install/header.php"); ?>
+ </div>
+ </header>
+
+ <div id="main">
+ <div class="content">
+
+ <div id="colonne" class="admin">
+<?php require $this->out_file("views/install/colonne.php"); ?>
+ </div>
+
+ <div id="center">
+<?php require $this->out_file("views/messages.php"); ?>
+<?php if($layout["content"] && $this->out_file_exists($layout["content"])) require $this->out_file($layout["content"]); ?>
+ </div>
+
+ </div>
+ </div>
+
+ <footer id="main_footer">
+ <div class="content">
+<?php require $this->out_file("views/install/footer.php"); ?>
+ </div>
+ </footer>
+
+ </body>
+</html>
--- /dev/null
+$(document).ready(
+ function(){
+ init_install();
+ }
+);
+
+function init_install(){
+ $("#sgbd").change(
+ function(){
+ var class_name = $(this).find("option:selected").val();
+ $("#sgbds .sgbd").removeClass("current");
+ $("#sgbd_" + class_name).addClass("current");
+ }
+ );
+}
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<layout>
+
+ <install page="install.php">
+ <index content="views/install/index.php" />
+ </install>
+
+</layout>
\ No newline at end of file
<layout>
<users page="index.php">
- <identification page="simple.php" content="views/users/identification.php" />
+ <identification page="index.php" content="views/users/identification.php" />
<infos page="compte.php" content="views/users/infos/edit.php" />
</users>
</head>
<body>
- <header id="main_header">
- <div class="content">
-<?php require $this->out_file("views/header.php"); ?>
- </div>
- </header>
-
<div id="main">
<div class="content">
</div>
</div>
- <footer id="main_footer">
- <div class="content">
-<?php require $this->out_file("views/footer.php"); ?>
- </div>
- </footer>
-
</body>
</html>
<li>
<label for="ptitcaptcha_entry">anti-spam</label>
<div class="form_input">
- <?php echo PtitCaptchaHelper::generateImgTags($this->path("mw_path")."libs/"); ?><br />
+ <?php echo PtitCaptchaHelper::generateImgTags($this->path("web").$this->path("mw_path")."libs/"); ?><br />
<?php echo PtitCaptchaHelper::generateInputTags(); ?>
</div>
</li>
--- /dev/null
+<ul>
+ <li><a href="http://mtweb.dj3c1t.com/">mtweb</a></li>
+</ul>
--- /dev/null
+ <meta charset="UTF-8">
+
+ <title>Mtweb - installation</title>
+
+ <!--[if lt IE 9]>\r
+ <script type="text/javascript" src="<?php echo $this->out_url("js/html5.js"); ?>"></script>\r
+ <![endif]-->
+
+ <script type="text/javascript"> mw_site_url = "<?php echo $this->path("web") ?>"; </script>
+ <?php foreach($this->js_files() as $js_file) : ?>
+ <script type="text/javascript" src="<?php echo $js_file; ?>"></script>
+ <?php endforeach; ?>
+
+ <?php foreach($this->css_files() as $css_file) : ?>
+ <link rel="stylesheet" type="text/css" href="<?php echo $css_file; ?>" />
+ <?php endforeach; ?>
+
+ <?php if($this->out_file_exists("js/script.js")) : ?>
+ <script type="text/javascript" src="<?php echo $this->out_url("js/script.js"); ?>"></script>
+ <?php endif; ?>
+ <?php if($this->out_file_exists("js/actions/".$this->etat("mod").".js")) : ?>
+ <script type="text/javascript" src="<?php echo $this->out_url("js/actions/".$this->etat("mod").".js"); ?>"></script>
+ <?php endif; ?>
+ <?php if($this->out_file_exists("js/actions/".$this->etat("mod")."_".$this->etat("controller").".js")) : ?>
+ <script type="text/javascript" src="<?php echo $this->out_url("js/actions/".$this->etat("mod")."_".$this->etat("controller").".js"); ?>"></script>
+ <?php endif; ?>
+ <?php if($this->out_file_exists("js/actions/".$this->etat("mod")."_".$this->etat("controller")."_".$this->etat("action").".js")) : ?>
+ <script type="text/javascript" src="<?php echo $this->out_url("js/actions/".$this->etat("mod")."_".$this->etat("controller")."_".$this->etat("action").".js"); ?>"></script>
+ <?php endif; ?>
+
+ <?php if($this->out_file_exists("css/style.css")) : ?>
+ <link rel="stylesheet" type="text/css" href="<?php echo $this->out_url("css/style.css"); ?>" />
+ <?php endif; ?>
+ <?php if($this->out_file_exists("css/actions/".$this->etat("mod").".css")) : ?>
+ <link rel="stylesheet" type="text/css" href="<?php echo $this->out_url("css/actions/".$this->etat("mod").".css"); ?>" />
+ <?php endif; ?>
+ <?php if($this->out_file_exists("css/actions/".$this->etat("mod")."_".$this->etat("controller").".css")) : ?>
+ <link rel="stylesheet" type="text/css" href="<?php echo $this->out_url("css/actions/".$this->etat("mod")."_".$this->etat("controller").".css"); ?>" />
+ <?php endif; ?>
+ <?php if($this->out_file_exists("css/actions/".$this->etat("mod")."_".$this->etat("controller")."_".$this->etat("action").".css")) : ?>
+ <link rel="stylesheet" type="text/css" href="<?php echo $this->out_url("css/actions/".$this->etat("mod")."_".$this->etat("controller")."_".$this->etat("action").".css"); ?>" />
+ <?php endif; ?>
\ No newline at end of file
--- /dev/null
+<h1>Mtweb - installation</h1>
\ No newline at end of file
--- /dev/null
+<?php if($this->out["sgbds"]) : ?>
+
+<form action="<?php echo $this->url("install"); ?>" method="post">
+ <fieldset>
+ <legend>Stockage des données</legend>
+ <ul>
+ <li>
+ <label>Mode de stockage</label>
+ <div class="form_input">
+ <select name="sgbd" id="sgbd">
+ <?php foreach($this->out["sgbds"] as $class_name => $sgbd) : ?>
+ <option value="<?php echo $class_name; ?>"<?php echo $class_name == $this->out["current_sgbd"] ? " selected" : ""; ?>>
+ <?php echo $sgbd->sgbd_name(); ?>
+ </option>
+ <?php endforeach; ?>
+ </select>
+ </div>
+ </li>
+ </ul>
+
+ <div id="sgbds">
+ <?php foreach($this->out["sgbds"] as $class_name => $sgbd) : ?>
+ <div class="sgbd<?php echo $class_name == $this->out["current_sgbd"] ? " current" : ""; ?>" id="sgbd_<?php echo $class_name; ?>">
+ <ul>
+ <li>
+ <label>Host</label>
+ <div class="form_input">
+ <input type="text" name="<?php echo $class_name; ?>_host" value="<?php echo isset($sgbd->host) ? $sgbd->host : ""; ?>" />
+ </div>
+ </li>
+ <li>
+ <label>Base</label>
+ <div class="form_input">
+ <input type="text" name="<?php echo $class_name; ?>_base" value="<?php echo isset($sgbd->base) ? $sgbd->base : ""; ?>" />
+ </div>
+ </li>
+ <?php if($sgbd->authentication_required()) : ?>
+ <li>
+ <label>User</label>
+ <div class="form_input">
+ <input type="text" name="<?php echo $class_name; ?>_user" value="<?php echo isset($sgbd->user) ? $sgbd->user : ""; ?>" />
+ </div>
+ </li>
+ <li>
+ <label>Password</label>
+ <div class="form_input">
+ <input type="password" name="<?php echo $class_name; ?>_password" />
+ </div>
+ </li>
+ <?php endif; ?>
+ </ul>
+ </div>
+ <?php endforeach; ?>
+ </div>
+
+ <ul>
+ <li>
+ <label>Table prefix</label>
+ <div class="form_input">
+ <input type="text" name="table_prefix" value="<?php echo $this->out("table_prefix"); ?>" />
+ </div>
+ </li>
+ </ul>
+
+ </fieldset>
+
+ <fieldset>
+ <legend>Compte administrateur</legend>
+ <p>
+
+ </p>
+ <ul>
+ <li>
+ <label>Login</label>
+ <div class="form_input">
+ <input type="text" name="admin_login" value="<?php echo $this->out["admin"]["login"]; ?>" />
+ </div>
+ </li>
+ <li>
+ <label>Email</label>
+ <div class="form_input">
+ <input type="text" name="admin_email" value="<?php echo $this->out["admin"]["email"]; ?>" />
+ </div>
+ </li>
+ <li>
+ <label>Mot de passe</label>
+ <div class="form_input">
+ <input type="password" name="admin_password" />
+ </div>
+ </li>
+ <li>
+ <label>Confirmez le mot de passe</label>
+ <div class="form_input">
+ <input type="password" name="admin_password_confirm" />
+ </div>
+ </li>
+ </ul>
+ </fieldset>
+
+ <fieldset>
+ <ul>
+ <li>
+ <div class="form_buttons">
+ <input type="submit" value="Installer" />
+ </div>
+ </li>
+ </ul>
+ </fieldset>
+
+</form>
+
+<?php else : ?>
+
+<p>Aucune implémentation de SGBD trouvée</p>
+
+<?php endif; ?>
\ No newline at end of file
}
function data(){
- return $this->data;
+ return isset($this->data) ? $this->data : false;
}
}
function out_url($file, $PRIORITE = "DESC"){
$out_file = $this->_out_file($file, $PRIORITE);
- return $out_file ? $this->path("mw_path").$out_file : $file;
+ return $out_file ? $this->path("web").$this->path("mw_path").$out_file : $file;
}
function _out_file($file, $PRIORITE = "DESC"){
}
function set_plugin_data($plugin_name, $data){
+ if(!is_dir($this->plugins_data_dir())) @mkdir($this->plugins_data_dir());
+ if(!is_dir($this->plugins_data_dir())) return false;
$data_file = $this->plugin_data_file($plugin_name);
$content = serialize($data);
$OK = false;
var $controllers;
function user(){
- $data = $this->data();
+ if(!($data = $this->data())) return array();
return $data->get_session_user();
}
}
function action_allowed($etat, $CHECK_FORMAT = true){
+ if(!$this->bdd("sgbd")) return false;
$data = $this->data();
if($CHECK_FORMAT) $etat = $this->valid_etat($etat);
if($etat === false){
class mw_app{
var $env;
+ var $path_file;
+ var $pathes;
+ var $config_file;
+ var $config;
+ var $bdd;
+ var $INITED;
+ var $logs;
+ var $DO_SETUP;
+
+ function mw_app($path_file){
+
+ // executer le setup si le fichier de config est absent
+ $this->DO_SETUP = true;
+
+ $this->path_file = $path_file;
+ $this->pathes = array();
+ $this->config_file = "";
+ $this->config = array();
+ $this->bdd = array();
+ $this->INITED = false;
+ $this->logs = array();
+ }
function set_env(&$env){
$this->env =& $env;
return $this->env;
}
- 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();
+ 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(){
$env = false;
$this->set_env($env);
if(
- ($sxml_class_file = (file_exists($PATHES["mw_dir"]."libs/sxml.php") ? $PATHES["mw_dir"]."libs/sxml.php" : ""))
- && ($empty_class_file = (file_exists($PATHES["mw_dir"]."libs/empty_class.php") ? $PATHES["mw_dir"]."libs/empty_class.php" : ""))
- && ($env_class_file = (file_exists($PATHES["mw_dir"]."env/mw_env.php") ? $PATHES["mw_dir"]."env/mw_env.php" : ""))
+ ($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" : ""))
){
if(!class_exists("sxml")) require_once $sxml_class_file;
if(!class_exists("empty_class")) require_once $empty_class_file;
){
$env = new mw_env(true);
$this->set_env($env);
- $env->load_modules($PATHES["mw_dir"], "env/modules/");
- $env->set_config_file($config_file);
- $env->set_PATHES($PATHES);
+ $env->load_modules($this->pathes["mw_dir"], "env/modules/");
+ $env->set_config_file($this->config_file);
+ $env->set_PATHES($this->pathes);
$env->init_plugins();
- $env->load_config($bdd, $CONFIG);
+ $env->load_config($this->bdd, $this->config);
$env->init();
}
}
}
function run($etat = "", $params = array(), $valid_role = true){
- $env = $this->env();
- $etat = ($etat === false ? false : ($etat ? $etat : (isset($_GET[$env->param("e")]) ? $_GET[$env->param("e")] : "")));
- if($etat !== false) $env->run($etat, $params, $valid_role);
+ if($this->INITED){
+ $env = $this->env();
+ $etat = ($etat === false ? false : ($etat ? $etat : (isset($_GET[$env->param("e")]) ? $_GET[$env->param("e")] : "")));
+ if($etat !== false) $env->run($etat, $params, $valid_role);
+ return true;
+ }
+ $this->log("run sans init. l'application ne s'est pas executee");
+ return false;
}
function display(){
}
}
+ function log($content){
+ $this->logs[] = array(
+ "time" => date("Y-m-d H:i:s"),
+ "value" => $content
+ );
+ }
+
+ function setup(){
+ if($this->DO_SETUP){
+ $env = $this->env();
+ $etat = isset($_GET[$env->param("e")]) ? $_GET[$env->param("e")] : "install";
+ $env->run($etat, array(), false);
+ $this->display();
+ exit;
+ }
+ }
+
+ function show_logs(){
+ foreach($this->logs as $log_time => $log_value){
+ $log_value = is_bool($log_value) ? "bool(".($log_value ? "true" : "false").")" : $log_value;
+ echo PHP_SAPI == "cli" ?
+ "\n".print_r($log_value, true)."\n"
+ : "<pre>".htmlentities(print_r($log_value, true), ENT_QUOTES, "UTF-8")."</pre>";
+ }
+ }
+
}
?>
\ No newline at end of file
--- /dev/null
+<?php
+
+ // --------------------------------------------------------------
+ // chemins
+ //
+
+ $PATHES = array(
+
+ //
+ // dossier des contenus editables par l'application
+ // relatif au dossier qui contient le fichier d'appel
+ //
+ // PHP doit pouvoir acceder en ecriture sur ce dossier
+ // ainsi que sur toute l'arborescence a partir de ce dossier
+ //
+ "content" => "content",
+
+ //
+ // chemin HTTP du dossier "mw"
+ // relatif au dossier qui contient le fichier d'appel
+ //
+ "mw_path" => "mw",
+
+ //
+ // chemin du dossier "mw" sur le systeme d'exploitation
+ // relatif au dossier qui contient le fichier d'appel
+ // ou absolu dans le systeme de fichiers
+ //
+ "mw_dir" => "mw"
+
+ );
+
+?>
\ No newline at end of file
installation :
--------------
- # installation rapide (*) :
-
- l'archive mtweb.<version>.tar.gz contient un dossier "mtweb"
- - uploadez le contenu de ce dossier "mtweb" sur votre site
-
- Si vous faites l'installation ailleurs qu'a la racine du site
- (si le fichier index.php n'est pas a la racine du site), adaptez
- le fichier config.php pour y renseigner le chemin de l'installation
- (plus de détails dans le fichier config.php)
+ - uploadez le contenu de ce dossier sur votre site
- assurez-vous que Php a le droit d'ecrire dans le dossier "content"
(et dans ses fichiers et sous-dossiers)
- pour une premiere utilisation, vous pouvez vous identifier avec :
-
- - login: admin
- - pass: adminpass
-
-
- (*) avant de rendre votre installation publique :
-
- - changez le mot de passe de l'utilisateur "admin"
-
- - ou creez un autre utilisateur avec un role administrateur
- puis supprimez l'utilisateur "admin"
-
-
- # utiliser MySql :
-
- par defaut, mtweb stocke ses donnees dans des fichiers XML, dans le
- dossier "content".
-
- pour utiliser le stockage de donnees MySql :
-
- - importez les tables avec le script "content/data/mysql/mtweb.sql"
-
- - dans le fichier "config.php" :
- - commentez la partie relative aux donnees XML
- - decommentez la partie relative aux donnees MySql
- - et adaptez les parametres de connexion pour MySql
- (plus de details dans le fichier config.php)
+ - rendez-vous, avec votre navigateur, sur le dossier uploadé et
+ suivez l'installation en ligne
documentation :