</al>
</controleur>
</module>
+
<module name="admin" title="Administration">
<controleur name="index" title="Accueil">
<al title="Accueil de l'administration">
<action name="index" />
</al>
</controleur>
- <controleur name="config" title="Configuration">
- <al title="Editer la configuration du site">
- <action name="index" />
- </al>
- </controleur>
<controleur name="users" title="Utilisateurs">
<al title="Lister les utilisateurs">
<action name="index" />
<action name="del" />
</al>
</controleur>
+ </module>
+
+ <module name="config" title="Configuration">
+ <controleur name="index" title="Accueil">
+ <al title="Configuration générale du site">
+ <action name="index" />
+ </al>
+ </controleur>
<controleur name="plugins" title="Plugins">
<al title="Gerer les plugins">
<action name="index" />
</al>
</controleur>
</module>
+
+
<module name="users" title="Utilisateurs">
<controleur name="infos" title="Compte">
<al title="Editer ses informations d'utilisateur">
<action name="index" />
<action name="login" />
<action name="logout" />
+ <action name="check_logout" />
</al>
</controleur>
</module>
if(!isset($this->sxml)) $this->sxml = new sxml();
$this->sxml->parse($this->buffer);
$this->buffer = $this->sxml->data["config"][0];
- if($this->buffer["subs"]) foreach($this->buffer["subs"] as $key => $value){
+ if(isset($this->buffer["subs"]) && $this->buffer["subs"]) foreach($this->buffer["subs"] as $key => $value){
$config[$key] = array(
"type" => $value[0]["attrs"]["type"],
"default" => $value[0]["attrs"]["default"],
--- /dev/null
+<?php
+
+ class mw_data_valid_config extends mw_data{
+
+ function valid_config($input, $config = array()){
+ $res = array(
+ "config" => $config,
+ "messages" => array(),
+ "erreurs" => array()
+ );
+ if(isset($input["site_name"])) $res["config"]["site_name"] = $input["site_name"];
+ if(isset($input["description"])) $res["config"]["description"] = $input["description"];
+ if(isset($input["max_list"]) && $input["max_list"]){
+ $res["config"]["max_list"] = $input["max_list"];
+ if(!preg_match("/^[0-9]+$/", $res["config"]["max_list"])){
+ $res["messages"][] = "la taille maximum des listes doit être un nombre";
+ }
+ }
+ else $res["config"]["max_list"] = "";
+ if(isset($input["contact_form"]) && $input["contact_form"]){
+ $res["config"]["contact_form"] = "1";
+ if(!isset($input["email"]) || !trim($input["email"])){
+ $res["messages"][] = "merci de préciser un email pour le formulaire de contact";
+ }
+ }
+ else $res["config"]["contact_form"] = "0";
+ if(isset($input["email"])) $res["config"]["email"] = trim($input["email"]);
+ if(isset($input["captcha"]) && $input["captcha"]) $res["config"]["captcha"] = "1";
+ else $res["config"]["captcha"] = "0";
+ return $res;
+ }
+
+ }
+
+?>
\ No newline at end of file
function load_session(){
@session_start();
if(!isset($_SESSION["id"])) $this->clear_session();
- if(
- $user = (
- isset($_COOKIE["user"]) || isset($_SESSION["user"]) ?
- $this->user(isset($_COOKIE["user"]) ? $_COOKIE["user"] : $_SESSION["user"])
- : array()
- )
- ){
- if(isset($_COOKIE["user"])) $this->set_session($user);
+ $user = array();
+ if(isset($_SESSION["user"])){
+ $user = $this->user($_SESSION["user"]);
+ }
+ elseif(isset($_COOKIE["user"]) && isset($_COOKIE["pass"])){
+ if($user = $this->user($_COOKIE["user"])){
+ $user["password"] = $_COOKIE["pass"];
+ $this->set_session($user);
+ }
+ }
+ if($user){
if(!$this->user_ok($user)){
$this->clear_session();
$user = array();
}
}
+ else $user = array();
$this->user = $user;
return $user;
}
$_SESSION["user"] = $user["login"];
$_SESSION["pass"] = md5($user["password"].$_SESSION["id"]);
$env = $this->env();
- return setcookie("user", $user["login"], time() + (60 * 60 * 24 * 7), $env->path("web"));
+ return
+ setcookie("user", $user["login"], time() + (60 * 60 * 24 * 7), $env->path("web"))
+ && setcookie("pass", $user["password"], time() + (60 * 60 * 24 * 7), $env->path("web"));
}
function clear_session(){
$_SESSION["ip"] = $_SERVER["REMOTE_ADDR"];
$_SESSION["id"] = md5(rand());
$env = $this->env();
- return setcookie("user", "", 0, $env->path("web"));
+ return
+ setcookie("user", "", 0, $env->path("web"))
+ && setcookie("pass", "", 0, $env->path("web"));
}
function get_session_user(){
<?php
if($this->init_links()){
- $this->set_link("admin/config", $this->url("admin/config"), "Configuration", 10);
$this->set_link("admin/users", $this->url("admin/users"), "Utilisateurs", 20);
- $this->set_link("admin/users/list", $this->url("admin/users/index"), "Liste des utilisateurs", 10);
- $this->set_link("admin/users/roles", $this->url("admin/users/roles"), "Rôles", 20);
- $this->set_link("admin/plugins", $this->url("admin/plugins"), "Plugins", 30);
+ $this->set_link("config/config", $this->url("config"), "Configuration générale", 10);
+ $this->set_link("config/template", $this->url("config/templates"), "Template", 20);
+ $this->set_link("config/roles", $this->url("config/roles"), "Rôles", 30);
+ $this->set_link("config/plugins", $this->url("config/plugins"), "Plugins", 40);
}
else $this->erreur("impossible de charger les liens", true);
+++ /dev/null
-<?php
-
- class mw_admin_config extends mw_mod{
-
- function index(&$env){
- $data = $env->data();
- if(($CONFIG = $env->get_CONFIG()) !== false){
- if(!$CONFIG["out"]) $CONFIG["out"] = "dist";
- $env->set_out("config", $CONFIG);
- if(($out_config = $env->get_out_config()) !== false){
- $env->set_out("out_config", $out_config);
- if($env->set_out("out_pathes", $env->out_pathes()) !== false){
- if($_POST){
- $env->set_out("config", $_POST);
- if(preg_match("/^[0-9]+$/", $_POST["max_list"])){
- if(!isset($_POST["contact_form"]) || trim($_POST["email"])){
- $CONTINUE = true;
- if($CONTINUE && $data->set_config("site_name", $_POST["site_name"]));
- else $CONTINUE = false;
- if($CONTINUE && $data->set_config("description", $_POST["description"]));
- else $CONTINUE = false;
- if($CONTINUE && $data->set_config("max_list", $_POST["max_list"]));
- else $CONTINUE = false;
- if($CONTINUE && $data->set_config("contact_form", isset($_POST["contact_form"]) ? "1" : "0"));
- else $CONTINUE = false;
- if($CONTINUE && $data->set_config("email", $_POST["email"]));
- else $CONTINUE = false;
- if($CONTINUE && $data->set_config("captcha", isset($_POST["captcha"]) ? "1" : "0"));
- else $CONTINUE = false;
- if($CONTINUE && $data->set_config("out", $_POST["out"]));
- else $CONTINUE = false;
- if($CONTINUE){
- foreach($out_config as $key => $values){
- if($data->set_config("out_".$key, isset($_POST["out_".$key]) ? $_POST["out_".$key] : "") === false){
- $CONTINUE = false;
- break;
- }
- }
- }
- if($CONTINUE) $env->redirect(
- $env->url("admin/config"),
- "la configuration a été enregistrée"
- );
- else $env->erreur("Impossible d'enregistrer la configuration");
- }
- else $env->message("merci de préciser un email pour le formulaire de contact");
- }
- else $env->message("la taille maximum des listes doit être un nombre");
- }
- }
- else $env->erreur("Impossible de lire la liste des templates");
- }
- else $env->erreur("Impossible de lire l configuration du templates");
- }
- else $env->erreur("Impossible de lire la configuration");
- }
-
- }
-
-?>
\ No newline at end of file
class mw_admin_index extends mw_mod{
function index(&$env){
- $env->run("admin/config");
+ $env->run("admin/users");
}
}
function validate(&$env){
$data = $env->data();
- if(($this->roles = $data->roles()) === false) return "impossible de lire la liste des statuts";
+ if(($this->roles = $data->roles()) === false) return "impossible de lire la liste des roles";
return true;
}
- // ------------------------------------------------------------------------------------
- // utilisateurs
- //
-
function index(&$env){
$data = $env->data();
if($this->roles) $env->set_out("roles", $this->roles);
else $env->erreur("Impossible de lire les informations de cet utilisateur");
}
- // ------------------------------------------------------------------------------------
- // roles
- //
-
- function set_default_allow(&$env){
- $default_allow = $_GET[$env->param("id")];
- if(!isset($default_allow) || ($default_allow !== "0" && $default_allow !== "1")){
- $env->erreur("parametre default_allow invalide");
- return;
- }
- $data = $env->data();
- if(!$data->set_config("default_allow", $default_allow)){
- $env->erreur("impossible de mettre a jour la configuration default_allow");
- return;
- }
- $env->redirect(
- $env->url("admin/users/roles"),
- "la configuration default_allow a été enregistrée"
- );
- }
-
- function roles(&$env){
- $data = $env->data();
- $roles = $data->roles();
- $id_role = isset($_GET[$env->param("id")]) && $_GET[$env->param("id")] ? $_GET[$env->param("id")] : 0;
- $env->set_out("id_role", $id_role);
- if(!isset($roles) || $roles === false){
- $env->erreur("impossible de lire la liste des roles");
- return;
- }
- $env->set_out("roles", $roles);
- if(($actions = $data->get_actions($id_role)) === false){
- $env->erreur("impossible de lire la liste des droits d'acces");
- return;
- }
- $env->set_out("actions", $actions);
-
- }
-
- function add_role(&$env){
- $data = $env->data();
- $role = array(
- "nom" => "",
- "intitule" => ""
- );
- if($_POST){
- if(!($role["nom"] = $_POST["nom"])) $env->message("merci de preciser un nom");
- if(!($role["intitule"] = $_POST["intitule"])) $env->message("merci de preciser un intitule");
- if(!$env->messages()){
- if(($id_role = $data->add_role($role["nom"], $role["intitule"])) !== false){
- $env->redirect(
- $env->url("admin/users/roles", array("id" => $id_role)),
- "le rôle a été enregistré"
- );
- }
- else $env->erreur("impossible d'enregistrer les informations du role");
- }
- }
- $env->set_out("role", $role);
- }
-
- function edit_role(&$env){
- $data = $env->data();
- if(!isset($_GET[$env->param("id")]) || !($role = $data->get_role($_GET[$env->param("id")]))){
- $env->erreur("impossible de lire les informations du role");
- return;
- }
- if($_POST){
- if(!($role["nom"] = $_POST["nom"])) $env->message("merci de preciser un nom");
- if(!($role["intitule"] = $_POST["intitule"])) $env->message("merci de preciser un intitule");
- if(!$env->messages()){
- if($data->set_role($role["id"], $role["nom"], $role["intitule"])){
- $env->redirect(
- $env->url("admin/users/roles", array("id" => $role["id"])),
- "le rôle a été enregistré"
- );
- }
- else $env->erreur("impossible d'enregistrer les informations du role");
- }
- }
- $env->set_out("role", $role);
- }
-
- function save_role(&$env){
- $data = $env->data();
- if(!($role = $data->get_role($_POST["id_role"]))){
- $env->erreur("impossible de lire les informations du role");
- return;
- }
- if(!$data->clear_role_actions($role["id"])){
- $env->erreur("impossible de supprimer les actions du role");
- return;
- }
- $action_roles = array();
- $als = array();
- foreach($_POST as $key => $value){
- if(substr($key, 0, 7) == "module_" && ($action = substr($key, 7))) $action_roles[$action] = $role["id"];
- elseif(substr($key, 0, 11) == "controleur_" && ($action = substr($key, 11))) $action_roles[$action] = $role["id"];
- elseif(substr($key, 0, 3) == "al_" && ($al_index = substr($key, 3))) $als[] = $al_index;
- }
- foreach($als as $al_index){
- $al_prefix = "action_".$al_index."_";
- $al_prefix_length = strlen($al_prefix);
- foreach($_POST as $key => $value){
- if(substr($key, 0, $al_prefix_length) == $al_prefix) $action_roles[$value] = $role["id"];
- }
- }
- foreach($action_roles as $action => $id_role){
- if(!$data->add_role_action($id_role, $action)){
- $env->erreur("impossible d'enregistrer les actions du role");
- return;
- }
- }
- $env->redirect(
- $env->url("admin/users/roles", array("id" => $role["id"])),
- "les actions du rôle ont été enregistrées"
- );
- }
-
- function del_role(&$env){
- $data = $env->data();
- if(!isset($_GET[$env->param("id")]) || !($role = $data->get_role($_GET[$env->param("id")]))){
- $env->erreur("impossible de lire les informations du role");
- return;
- }
- if($data->clear_role_actions($role["id"])){
- if($data->clear_role_users($role["id"])){
- if($data->del_role($role["id"])){
- $env->redirect(
- $env->url("admin/users/roles"),
- "le rôle a été effacé"
- );
- }
- else $env->erreur("impossible de supprimer le role");
- }
- else $env->erreur("impossible de supprimer le role aux utilisateurs");
- }
- else $env->erreur("impossible de supprimer les actions du role");
- }
-
}
?>
\ No newline at end of file
--- /dev/null
+<?php
+
+ class mw_config_index extends mw_mod{
+
+ function index(&$env){
+ $data = $env->data();
+ if(($config = $env->get_CONFIG()) === false){
+ $env->erreur("Impossible de lire la configuration");
+ return;
+ }
+ if($_POST){
+ $res = $data->valid_config($_POST);
+ $config = $res["config"];
+ if($res["messages"]) foreach($res["messages"] as $message) $env->message($message);
+ if(!$env->messages()){
+ foreach($config as $key => $value){
+ if($data->set_config($key, $value) === false){
+ $env->erreur("erreur lors de l'enregistrement de la configuration");
+ return;
+ }
+ }
+ $env->redirect(
+ $env->url("config"),
+ "la configuration a été enregistrée"
+ );
+ }
+ }
+ $env->set_out("config", $config);
+ }
+
+ }
+
+?>
\ No newline at end of file
<?php
- class mw_admin_plugins extends mw_mod{
+ class mw_config_plugins extends mw_mod{
var $plugins;
}
if($OK){
$env->redirect(
- $env->url("admin/plugins/index"),
+ $env->url("config/plugins/index"),
"les priorités des plugins ont été enregistrées"
);
}
);
if($env->set_plugin_data($plugin_name, $plugin_data)){
$env->redirect(
- $env->url("admin/plugins/index"),
+ $env->url("config/plugins/index"),
"le plugin a été installé"
);
}
);
if($env->set_plugin_data($plugin_name, $plugin_data)){
$env->redirect(
- $env->url("admin/plugins/index"),
+ $env->url("config/plugins/index"),
"le plugin a été désinstallé"
);
}
);
if($env->set_plugin_data($plugin_name, $plugin_data)){
$env->redirect(
- $env->url("admin/plugins/index"),
+ $env->url("config/plugins/index"),
"le plugin a été activé"
);
}
);
if($env->set_plugin_data($plugin_name, $plugin_data)){
$env->redirect(
- $env->url("admin/plugins/index"),
+ $env->url("config/plugins/index"),
"le plugin a été désactivé"
);
}
--- /dev/null
+<?php
+
+ class mw_config_roles extends mw_mod{
+
+ var $roles;
+
+ function validate(&$env){
+ $data = $env->data();
+ if(($this->roles = $data->roles()) === false) return "impossible de lire la liste des roles";
+ return true;
+ }
+
+ function index(&$env){
+ $data = $env->data();
+ $roles = $this->roles;
+ $id_role = isset($_GET[$env->param("id")]) && $_GET[$env->param("id")] ? $_GET[$env->param("id")] : 0;
+ if(!isset($roles) || $roles === false){
+ $env->erreur("impossible de lire la liste des roles");
+ return;
+ }
+ if(($actions = $data->get_actions($id_role)) === false){
+ $env->erreur("impossible de lire la liste des droits d'acces");
+ return;
+ }
+ $env->set_out("roles", $roles);
+ $env->set_out("id_role", $id_role);
+ $env->set_out("actions", $actions);
+ }
+
+ function set_default_allow(&$env){
+ $default_allow = $_GET[$env->param("id")];
+ if(!isset($default_allow) || ($default_allow !== "0" && $default_allow !== "1")){
+ $env->erreur("parametre default_allow invalide");
+ return;
+ }
+ $data = $env->data();
+ if(!$data->set_config("default_allow", $default_allow)){
+ $env->erreur("impossible de mettre a jour la configuration default_allow");
+ return;
+ }
+ $env->redirect(
+ $env->url("config/roles"),
+ "la configuration default_allow a été enregistrée"
+ );
+ }
+
+ function add_role(&$env){
+ $data = $env->data();
+ $role = array(
+ "nom" => "",
+ "intitule" => ""
+ );
+ if($_POST){
+ if(!($role["nom"] = $_POST["nom"])) $env->message("merci de preciser un nom");
+ if(!($role["intitule"] = $_POST["intitule"])) $env->message("merci de preciser un intitule");
+ if(!$env->messages()){
+ if(($id_role = $data->add_role($role["nom"], $role["intitule"])) !== false){
+ $env->redirect(
+ $env->url("config/roles", array("id" => $id_role)),
+ "le rôle a été enregistré"
+ );
+ }
+ else $env->erreur("impossible d'enregistrer les informations du role");
+ }
+ }
+ $env->set_out("role", $role);
+ }
+
+ function edit_role(&$env){
+ $data = $env->data();
+ if(!isset($_GET[$env->param("id")]) || !($role = $data->get_role($_GET[$env->param("id")]))){
+ $env->erreur("impossible de lire les informations du role");
+ return;
+ }
+ if($_POST){
+ if(!($role["nom"] = $_POST["nom"])) $env->message("merci de preciser un nom");
+ if(!($role["intitule"] = $_POST["intitule"])) $env->message("merci de preciser un intitule");
+ if(!$env->messages()){
+ if($data->set_role($role["id"], $role["nom"], $role["intitule"])){
+ $env->redirect(
+ $env->url("config/roles", array("id" => $role["id"])),
+ "le rôle a été enregistré"
+ );
+ }
+ else $env->erreur("impossible d'enregistrer les informations du role");
+ }
+ }
+ $env->set_out("role", $role);
+ }
+
+ function save_role(&$env){
+ $data = $env->data();
+ if(!($role = $data->get_role($_POST["id_role"]))){
+ $env->erreur("impossible de lire les informations du role");
+ return;
+ }
+ if(!$data->clear_role_actions($role["id"])){
+ $env->erreur("impossible de supprimer les actions du role");
+ return;
+ }
+ $action_roles = array();
+ $als = array();
+ foreach($_POST as $key => $value){
+ if(substr($key, 0, 7) == "module_" && ($action = substr($key, 7))) $action_roles[$action] = $role["id"];
+ elseif(substr($key, 0, 11) == "controleur_" && ($action = substr($key, 11))) $action_roles[$action] = $role["id"];
+ elseif(substr($key, 0, 3) == "al_" && ($al_index = substr($key, 3))) $als[] = $al_index;
+ }
+ foreach($als as $al_index){
+ $al_prefix = "action_".$al_index."_";
+ $al_prefix_length = strlen($al_prefix);
+ foreach($_POST as $key => $value){
+ if(substr($key, 0, $al_prefix_length) == $al_prefix) $action_roles[$value] = $role["id"];
+ }
+ }
+ foreach($action_roles as $action => $id_role){
+ if(!$data->add_role_action($id_role, $action)){
+ $env->erreur("impossible d'enregistrer les actions du role");
+ return;
+ }
+ }
+ $env->redirect(
+ $env->url("config/roles", array("id" => $role["id"])),
+ "les actions du rôle ont été enregistrées"
+ );
+ }
+
+ function del_role(&$env){
+ $data = $env->data();
+ if(!isset($_GET[$env->param("id")]) || !($role = $data->get_role($_GET[$env->param("id")]))){
+ $env->erreur("impossible de lire les informations du role");
+ return;
+ }
+ if($data->clear_role_actions($role["id"])){
+ if($data->clear_role_users($role["id"])){
+ if($data->del_role($role["id"])){
+ $env->redirect(
+ $env->url("config/roles"),
+ "le rôle a été effacé"
+ );
+ }
+ else $env->erreur("impossible de supprimer le role");
+ }
+ else $env->erreur("impossible de supprimer le role aux utilisateurs");
+ }
+ else $env->erreur("impossible de supprimer les actions du role");
+ }
+
+ }
+
+?>
\ No newline at end of file
--- /dev/null
+<?php
+
+ class mw_config_templates extends mw_mod{
+
+ function index(&$env){
+ $data = $env->data();
+ if(($out_pathes = $env->out_pathes()) === false){
+ $env->erreur("Impossible de lire la liste des templates");
+ return;
+ }
+ if(($out_config = $env->get_out_config()) === false){
+ $env->erreur("Impossible de lire la configuration du template");
+ return;
+ }
+ if($_POST){
+ $template = isset($_POST["out"]) ? $_POST["out"] : "";
+ if(!$template) $template = $env->config("default_out");
+ if(!$env->app_file_exists("out/".$template)){
+ $env->erreur("impossible de trouver le template");
+ return;
+ }
+ if($data->set_config("out", $template) === false){
+ $env->erreur("erreur lors de l'enregistrement du template");
+ return;
+ }
+ $env->redirect(
+ $env->url("config/templates/index"),
+ "la configuration a été enregistrée"
+ );
+ }
+ $env->set_out("out_pathes", $out_pathes);
+ $env->set_out("out_config", $out_config);
+ }
+
+ function options(&$env){
+ $data = $env->data();
+ if(($config = $env->get_CONFIG()) === false){
+ $env->erreur("Impossible de lire la configuration");
+ return;
+ }
+ if(($out_config = $env->get_out_config()) === false){
+ $env->erreur("Impossible de lire la configuration du template");
+ return;
+ }
+ if($_POST){
+ foreach($out_config as $key => $values){
+ if($data->set_config("out_".$key, isset($_POST["out_".$key]) ? $_POST["out_".$key] : "") === false){
+ $env->erreur("erreur lors de l'enregistrement de la configuration du template");
+ return;
+ }
+ }
+ $env->redirect(
+ $env->url("config/templates/options"),
+ "la configuration a été enregistrée"
+ );
+ }
+ $env->set_out("config", $config);
+ $env->set_out("out_config", $out_config);
+ }
+
+ }
+
+?>
\ No newline at end of file
}
function login(&$env){
- $data = $env->data();
- if($data->login(trim($_POST['login']), trim($_POST['pass']))){
- $env->redirect(
- isset($_POST["from"]) ? urldecode($_POST["from"]) : $env->url(),
- "Vous êtes maintenant identifié en tant que ".$_POST['login']
- );
+ if($_POST){
+ $data = $env->data();
+ if($data->login(trim($_POST['login']), trim($_POST['pass']))){
+ $redirect_action = "index";
+ $redirect_params = array();
+ if(isset($_SESSION["action_after_login"])){
+ $redirect_action = $_SESSION["action_after_login"];
+ unset($_SESSION["action_after_login"]);
+ }
+ if(isset($_SESSION["params_after_login"])){
+ if(!($redirect_params = @unserialize($_SESSION["params_after_login"]))) $redirect_params = array();
+ unset($_SESSION["params_after_login"]);
+ }
+ $env->redirect(
+ $env->url($redirect_action, $redirect_params),
+ "Vous êtes maintenant identifié en tant que ".$_POST['login']
+ );
+ }
+ else $env->message("Idantifiants incorrects");
}
- else $env->message("Identifiants incorrects");
}
function logout(&$env){
$data = $env->data();
if($data->logout()){
$env->redirect(
- $env->url(),
- "Vous n'êtes plus identifié sur le site"
+ $env->url("users/identification/check_logout"),
+ "Deconnexion en cours...",
+ 0
);
}
else $env->message("Erreur lors de la deconnection. il se peut que vous soyez encore identifié");
}
+ function check_logout(&$env){
+ if($env->user()){
+ $env->erreur("deconnexion impossible. vous êtes toujours identifié sur le site.");
+ }
+ else{
+ $redirect_action = "index";
+ $redirect_params = array();
+ if(isset($_SESSION["action_after_logout"])){
+ $redirect_action = $_SESSION["action_after_logout"];
+ unset($_SESSION["action_after_logout"]);
+ }
+ if(isset($_SESSION["params_after_logout"])){
+ if(!($redirect_params = @unserialize($_SESSION["params_after_logout"]))) $redirect_params = array();
+ unset($_SESSION["params_after_logout"]);
+ }
+ $env->redirect(
+ $env->url($redirect_action, $redirect_params),
+ "Vous n'êtes plus identifié sur le site"
+ );
+ }
+ }
+
}
?>
\ No newline at end of file
--- /dev/null
+<!doctype html>
+<html>
+ <head>
+<?php require $this->out_file("views/head.php"); ?>
+ </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 id="colonne" class="admin">
+<?php require $this->out_file("views/config/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/footer.php"); ?>
+ </div>
+ </footer>
+
+ </body>
+</html>
<admin page="admin.php">
<index content="views/admin/index.php" />
<users>
- <index content="views/admin/users/list.php" />
+ <index content="views/admin/users/index.php" />
<add content="views/admin/users/add.php" />
<edit content="views/admin/users/edit.php" />
- <roles content="views/admin/users/roles.php" />
- <add_role content="views/admin/users/add_role.php" />
- <edit_role content="views/admin/users/edit_role.php" />
</users>
- <config content="views/admin/config.php" />
- <plugins>
- <index content="views/admin/plugins/list.php" />
- </plugins>
</admin>
</layout>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<layout>
+
+ <config page="config.php">
+ <index content="views/config/index.php" />
+ <templates>
+ <index content="views/config/templates/index.php" />
+ <options content="views/config/templates/options.php" />
+ </templates>
+ <roles>
+ <index content="views/config/roles/index.php" />
+ <add_role content="views/config/roles/add.php" />
+ <edit_role content="views/config/roles/edit.php" />
+ </roles>
+ <plugins>
+ <index content="views/config/plugins/index.php" />
+ </plugins>
+ </config>
+
+</layout>
\ No newline at end of file
<label>rôle</label>
<div class="form_input">
<ul>
- <?php foreach($this->out["roles"] as $id_role => $role) : ?>
+ <?php foreach($this->out["roles"] as $id_role => $role) : if($id_role) : ?>
<li>
<input type="checkbox" name="role_<?php echo $id_role; ?>"<?php
echo in_array($id_role, $this->out["user"]["roles"]) ? " checked" : "";
?> />
<?php echo $role["intitule"]; ?>
</li>
- <?php endforeach; ?>
+ <?php endif; endforeach; ?>
</ul>
</div>
</li>
<label>rôle</label>
<div class="form_input">
<ul>
- <?php foreach($this->out["roles"] as $id_role => $role) : ?>
+ <?php foreach($this->out["roles"] as $id_role => $role) : if($id_role) : ?>
<li>
<input type="checkbox" name="role_<?php echo $id_role; ?>"<?php
echo in_array($id_role, $this->out["user"]["roles"]) ? " checked" : "";
?> />
<?php echo $role["intitule"]; ?>
</li>
- <?php endforeach; ?>
+ <?php endif; endforeach; ?>
</ul>
</div>
</li>
<li>
<select onchange="document.location=this.options[this.selectedIndex].value;">
<option value="<?php echo $this->url("admin/users", $users_params); ?>"<?php echo $_GET[$this->param("role")] ? "" : " selected=\"selected\""; ?>>Tous les roles</option>
- <?php foreach($this->out["roles"] as $role) : $users_params["role"] = $role["id"]; ?>
+ <?php foreach($this->out["roles"] as $role) : if($role["id"]) : $users_params["role"] = $role["id"]; ?>
<option value="<?php echo $this->url("admin/users", $users_params); ?>"<?php echo $_GET[$this->param("role")] == $role["id"] ? " selected=\"selected\"" : ""; ?>><?php echo $role["intitule"]; ?></option>
- <?php endforeach; ?>
+ <?php endif; endforeach; ?>
</select>
</li>
<?php endif; ?>
--- /dev/null
+<?php $data = $this->data(); if(($config_menu = $data->get_link("config")) && $config_menu["subs"]) : ?>
+
+<?php echo get_menu_ul($config_menu); ?>
+
+<?php endif; ?>
\ No newline at end of file
<h2>Configuration</h2>
-<form name="config_form" action="<?php echo $this->url("admin/config"); ?>" method="post">
+<form name="config_form" action="<?php echo $this->url("config"); ?>" method="post">
<fieldset>
<legend>Configuration générale</legend>
<input type="text" name="max_list" id="max_list" value="<?php echo $this->out["config"]["max_list"]; ?>" />
</div>
</li>
- </ul>
- </fieldset>
-
- <?php if($this->out["out_pathes"]) : ?>
- <fieldset>
- <legend>Affichage du site</legend>
- <ul>
- <li>
- <label for="out">template</label>
- <?php
-
- $template = $this->config("out");
- $FOUND = false;
- foreach($this->out["out_pathes"] as $out_path) { if($template == $out_path) { $FOUND = true; break; } }
- if(!$FOUND) $template = $this->config("default_out");
-
- ?>
- <div class="form_input">
- <select name="out" id="out">
- <?php foreach($this->out["out_pathes"] as $out_path) : ?>
- <option value="<?php echo $out_path; ?>"<?php echo $template == $out_path ? " selected=\"selected\"" : ""; ?>><?php echo $out_path; ?></option>
- <?php endforeach; ?>
- </select>
- </div>
- </li>
- <?php foreach($this->out["out_config"] as $key => $config) : if($config["type"] == "checkbox") : ?>
- <li>
- <label for="<?php echo "out_".$key; ?>"> </label>
- <div class="form_input">
- <input type="checkbox" name="<?php echo "out_".$key; ?>" id="<?php echo "out_".$key; ?>"<?php echo (isset($this->out["config"]["out_".$key]) ? $this->out["config"]["out_".$key] : $config["default"]) ? " checked=\"checked\"" : ""; ?> />
- <?php echo $config["text"]; ?>
- </div>
- </li>
- <?php endif; endforeach; ?>
<li>
<div class="form_buttons">
<input type="submit" value="Enregistrer" />
</li>
</ul>
</fieldset>
- <?php endif; ?>
</form>
<?php if($this->out["plugins"]) : ?>
-<form name="plugins_form" action="<?php echo $this->url("admin/plugins"); ?>" method="post">
+<form name="plugins_form" action="<?php echo $this->url("config/plugins"); ?>" method="post">
<fieldset>
<ul>
<?php $data = $this->data(); foreach($this->out["plugins"] as $plugin_name => $plugin) : ?>
<?php echo $plugin["description"]; ?>
<ul class="plugin_links">
<?php if($plugin["installed"]) : ?>
- <li><a href="<?php echo $this->url("admin/plugins/uninstall", array("id" => $plugin_name)); ?>"
+ <li><a href="<?php echo $this->url("config/plugins/uninstall", array("id" => $plugin_name)); ?>"
onclick="return confirm('si le plugin stocke des donnees, elles seront perdues')">désinstaller</a></li>
<?php if($plugin["enabled"]) : ?>
<?php if(($admin_link = $data->get_link("plugins/admin/".$plugin_name)) && $admin_link["url"]) : ?>
<li><a href="<?php echo $admin_link["url"]; ?>"><?php echo $admin_link["intitule"]; ?></a></li>
<?php endif; ?>
- <li><a href="<?php echo $this->url("admin/plugins/disable", array("id" => $plugin_name)); ?>">désactiver</a></li>
+ <li><a href="<?php echo $this->url("config/plugins/disable", array("id" => $plugin_name)); ?>">désactiver</a></li>
<?php else : ?>
- <li><a href="<?php echo $this->url("admin/plugins/enable", array("id" => $plugin_name)); ?>">activer</a></li>
+ <li><a href="<?php echo $this->url("config/plugins/enable", array("id" => $plugin_name)); ?>">activer</a></li>
<?php endif; ?>
<?php else : ?>
- <li><a href="<?php echo $this->url("admin/plugins/install", array("id" => $plugin_name)); ?>">installer</a></li>
+ <li><a href="<?php echo $this->url("config/plugins/install", array("id" => $plugin_name)); ?>">installer</a></li>
<?php endif; ?>
<li>priorité : <input type="text" size="4" name="priorite_<?php echo $plugin_name; ?>" value="<?php echo $plugin["priorite"] ? $plugin["priorite"] : "0"; ?>" /></li>
</ul>
<h2>Ajouter un rôle</h2>
<ul class="buttons">
- <li><a href="<?php echo $this->url("admin/users/roles"); ?>">Retour à la liste des actions</a></li>
+ <li><a href="<?php echo $this->url("config/roles"); ?>">Retour à la liste des actions</a></li>
</ul>
-<form name="role_form" action="<?php echo $this->url("admin/users/add_role"); ?>" method="post">
+<form name="role_form" action="<?php echo $this->url("config/roles/add_role"); ?>" method="post">
<fieldset>
<ul>
<li>
<h2>Editer un rôle</h2>
<ul class="buttons">
- <li><a href="<?php echo $this->url("admin/users/roles", array("id" => $this->out["role"]["id"])); ?>">Retour à la liste des actions</a></li>
- <li><a href="<?php echo $this->url("admin/users/del_role", array("id" => $this->out["role"]["id"])); ?>"
+ <li><a href="<?php echo $this->url("config/roles", array("id" => $this->out["role"]["id"])); ?>">Retour à la liste des actions</a></li>
+ <li><a href="<?php echo $this->url("config/roles/del_role", array("id" => $this->out["role"]["id"])); ?>"
class="admin_link"
title="supprimer ce role"
onclick="return confirm('Supprimer ce role ?')"><img src="<?php echo $this->out_url("icons/del.gif"); ?>" /></a></li>
</ul>
-<form name="role_form" action="<?php echo $this->url("admin/users/edit_role", array("id" => $this->out["role"]["id"])); ?>" method="post">
+<form name="role_form" action="<?php echo $this->url("config/roles/edit_role", array("id" => $this->out["role"]["id"])); ?>" method="post">
<fieldset>
<ul>
<li>
<p>
<label for="default_allow">Autoriser l'accès par défaut</label>
<select id="default_allow" onchange="document.location=this.options[this.selectedIndex].value;">
- <option value="<?php echo $this->url("admin/users/set_default_allow", array("id" => "1")); ?>"<?php echo $this->config("default_allow") ? " selected" : ""; ?>>oui</option>
- <option value="<?php echo $this->url("admin/users/set_default_allow", array("id" => "0")); ?>"<?php echo $this->config("default_allow") ? "" : " selected"; ?> />non</option>
+ <option value="<?php echo $this->url("config/roles/set_default_allow", array("id" => "1")); ?>"<?php echo $this->config("default_allow") ? " selected" : ""; ?>>oui</option>
+ <option value="<?php echo $this->url("config/roles/set_default_allow", array("id" => "0")); ?>"<?php echo $this->config("default_allow") ? "" : " selected"; ?> />non</option>
</select>
</p>
<br />
<h3>
Autorisations d'accès pour
<select onchange="document.location=this.options[this.selectedIndex].value;">
- <option value="<?php echo $this->url("admin/users/roles", array("id" => 0)); ?>">Visiteurs non identifiés</option>
<?php foreach($this->out["roles"] as $id_role => $role) : ?>
- <option value="<?php echo $this->url("admin/users/roles", array("id" => $id_role)); ?>"<?php echo $this->out["id_role"] == $id_role ? " selected" : ""; ?>><?php echo $role["intitule"]; ?></option>
+ <option value="<?php echo $this->url("config/roles", array("id" => $id_role)); ?>"<?php echo $this->out["id_role"] == $id_role ? " selected" : ""; ?>><?php echo $role["intitule"]; ?></option>
<?php endforeach; ?>
</select>
<?php if($this->out["id_role"]) : ?>
- <a href="<?php echo $this->url("admin/users/edit_role", array("id" => $this->out["id_role"])); ?>"
+ <a href="<?php echo $this->url("config/roles/edit_role", array("id" => $this->out["id_role"])); ?>"
class="admin_link"
title="modifier ce role"><img src="<?php echo $this->out_url("icons/edit.gif"); ?>" /></a>
- <a href="<?php echo $this->url("admin/users/del_role", array("id" => $this->out["id_role"])); ?>"
+ <a href="<?php echo $this->url("config/roles/del_role", array("id" => $this->out["id_role"])); ?>"
class="admin_link"
title="supprimer ce role"><img src="<?php echo $this->out_url("icons/del.gif"); ?>"
onclick="return confirm('Supprimer ce role ?')"/></a>
<?php endif; ?>
- <a href="<?php echo $this->url("admin/users/add_role"); ?>"
+ <a href="<?php echo $this->url("config/roles/add_role"); ?>"
class="admin_link"
title="ajouter un role"><img src="<?php echo $this->out_url("icons/add.gif"); ?>" /></a>
</h3>
<?php if($this->out["actions"]) : ?>
-<form action="<?php echo $this->url("admin/users/save_role"); ?>" method="post">
+<form action="<?php echo $this->url("config/roles/save_role"); ?>" method="post">
<input type="hidden" name="id_role" value="<?php echo $this->out["id_role"]; ?>" />
<ul class="actions">
<?php $index_al = 0; foreach($this->out["actions"] as $module_name => $module) : ?>
--- /dev/null
+<h2>Template</h2>
+
+<?php if($this->out["out_pathes"]) : ?>
+
+<form name="config_form" action="<?php echo $this->url("config/templates"); ?>" method="post">
+
+ <fieldset>
+ <ul>
+ <li>
+ <label for="out">template</label>
+ <?php
+
+ $template = $this->config("out");
+ $FOUND = false;
+ foreach($this->out["out_pathes"] as $out_path) { if($template == $out_path) { $FOUND = true; break; } }
+ if(!$FOUND) $template = $this->config("default_out");
+
+ ?>
+ <div class="form_input">
+ <select name="out" id="out">
+ <?php foreach($this->out["out_pathes"] as $out_path) : ?>
+ <option value="<?php echo $out_path; ?>"<?php echo $template == $out_path ? " selected=\"selected\"" : ""; ?>><?php echo $out_path; ?></option>
+ <?php endforeach; ?>
+ </select>
+ </div>
+ </li>
+ <?php if($this->out["out_config"]) : ?>
+ <li>
+ <label> </label>
+ <div class="form_input">
+ Ce template a des <a href="<?php echo $this->url("config/templates/options"); ?>">options</a>
+ </div>
+ </li>
+ <?php endif; ?>
+ <li>
+ <div class="form_buttons">
+ <input type="submit" value="Enregistrer" />
+ </div>
+ </li>
+ </ul>
+ </fieldset>
+
+</form>
+
+<?php else : ?>
+
+<p>Aucun template</p>
+
+<?php endif; ?>
--- /dev/null
+<h2>Options du template</h2>
+
+<?php if($this->out["out_config"]) : ?>
+
+<form name="out_config_form" action="<?php echo $this->url("config/templates/options"); ?>" method="post">
+ <input type="hidden" name="do_post" value="1" />
+ <fieldset>
+ <ul>
+ <?php foreach($this->out["out_config"] as $key => $config) : if($config["type"] == "checkbox") : ?>
+ <li>
+ <label for="<?php echo "out_".$key; ?>"> </label>
+ <div class="form_input">
+ <input type="checkbox" name="<?php echo "out_".$key; ?>" id="<?php echo "out_".$key; ?>"<?php echo (isset($this->out["config"]["out_".$key]) ? $this->out["config"]["out_".$key] : $config["default"]) ? " checked=\"checked\"" : ""; ?> />
+ <?php echo $config["text"]; ?>
+ </div>
+ </li>
+ <?php endif; endforeach; ?>
+ <li>
+ <div class="form_buttons">
+ <input type="submit" value="Enregistrer" />
+ </div>
+ </li>
+ </ul>
+ </fieldset>
+
+</form>
+
+<?php else : ?>
+
+<p>Aucune option pour ce template</p>
+
+<?php endif; ?>
<?php if($this->action_allowed("admin")) : ?>
<li><a href="<?php echo $this->url("admin"); ?>">admin</a></li>
<?php endif; ?>
+<?php if($this->action_allowed("config")) : ?>
+ <li><a href="<?php echo $this->url("config"); ?>">config</a></li>
+<?php endif; ?>
<li><a href="<?php echo $this->url("users/identification/logout"); ?>">deconnexion</a></li>
<?php endif; ?>
<li><a href="http://mtweb.dj3c1t.com/">mtweb</a></li>
<form action="<?php echo $this->url("forms/contact"); ?>" method="post">
<fieldset>
<legend>Contact</legend>
+ <?php if($this->config("captcha")) : ?>
<?php echo PtitCaptchaHelper::generateHiddenTags(); ?>
+ <?php endif; ?>
<ul>
<li>
<label for="email">email</label>
return false;
}
- function url($action = "", $_params = array(), $script_name = "index.php"){
+ function url($action = "", $_params = array(), $script_name = null){
+ $script_name = isset($script_name) ? $script_name : ($this->config("script_name") ? $this->config("script_name") : "index.php");
if($action) $_params["e"] = $action;
$get_params = "";
if(isset($this->additional_get_params)) foreach($this->additional_get_params as $key => $value) $get_params .= ($get_params ? "&" : "?").$key."=".$value;
"wait" => $wait
)
);
+ if(!$wait && !headers_sent()){
+ header("Location: ".str_replace("&", "&", $url));
+ }
}
}