class mw_admin_index extends mw_controller{
- function index(){
+ public function index(){
$env = $this->env();
$env->run("admin/users");
}
}
-
-?>
\ No newline at end of file
class mw_admin_users extends mw_controller{
- var $roles;
+ public $roles;
- function validate(){
+ public function validate(){
$env = $this->env();
$data = $env->data();
if(($this->roles = $data->roles()) === false) return "impossible de lire la liste des roles";
return true;
}
- function index(){
+ public function index(){
$env = $this->env();
$data = $env->data();
if($this->roles) $env->set_out("roles", $this->roles);
else $env->erreur("impossible de lire la liste des utilisateurs");
}
- function add(){
+ public function add(){
$env = $this->env();
$data = $env->data();
if(!$this->roles){
$env->set_out("user", $user->get_values());
}
- function edit(){
+ public function edit(){
$env = $this->env();
if(!$this->roles){
$env->erreur("impossible de lire la liste des roles");
$env->set_out("user", $user->get_values());
}
- function del(){
+ public function del(){
$env = $this->env();
$user = $env->get_model("users");
if(!$user->load("login", $_GET[$env->param("id")])){
}
}
-
-?>
\ No newline at end of file
class mw_config_index extends mw_controller{
- function index(){
+ public function index(){
$env = $this->env();
$data = $env->data();
if(($config = $env->get_CONFIG()) === false){
}
}
-
-?>
\ No newline at end of file
class mw_config_plugins extends mw_controller{
- var $plugins;
+ public $plugins;
- function validate(){
+ public function validate(){
$env = $this->env();
if(($this->plugins = $env->plugins("DESC")) === false) return "impossible de lire la liste des plugins";
return true;
}
- function index(){
+ public function index(){
$env = $this->env();
if($this->plugins !== false){
if($_POST){
else $env->erreur("impossible de lire la liste des plugins");
}
- function install(){
+ public function install(){
$env = $this->env();
$plugin_name = $_GET[$env->param("id")];
if(isset($this->plugins[$plugin_name])){
else $env->erreur("impossible de trouver le plugin ".$plugin_name);
}
- function uninstall(){
+ public function uninstall(){
$env = $this->env();
$plugin_name = $_GET[$env->param("id")];
if(isset($this->plugins[$plugin_name])){
else $env->erreur("impossible de trouver le plugin ".$plugin_name);
}
- function enable(){
+ public function enable(){
$env = $this->env();
$plugin_name = $_GET[$env->param("id")];
if(isset($this->plugins[$plugin_name])){
else $env->erreur("impossible de trouver le plugin ".$plugin_name);
}
- function disable(){
+ public function disable(){
$env = $this->env();
$plugin_name = $_GET[$env->param("id")];
if(isset($this->plugins[$plugin_name])){
}
}
-
-?>
\ No newline at end of file
class mw_config_roles extends mw_controller{
- var $roles;
+ public $roles;
- function validate(){
+ public function validate(){
$env = $this->env();
$data = $env->data();
if(($this->roles = $data->roles()) === false) return "impossible de lire la liste des roles";
return true;
}
- function index(){
+ public function index(){
$env = $this->env();
$data = $env->data();
$roles = $this->roles;
$env->set_out("actions", $actions);
}
- function set_default_allow(){
+ public function set_default_allow(){
$env = $this->env();
$default_allow = $_GET[$env->param("id")];
if(!isset($default_allow) || ($default_allow !== "0" && $default_allow !== "1")){
);
}
- function add_role(){
+ public function add_role(){
$env = $this->env();
$data = $env->data();
$role = array(
$env->set_out("role", $role);
}
- function edit_role(){
+ public function edit_role(){
$env = $this->env();
$data = $env->data();
if(!isset($_GET[$env->param("id")]) || !($role = $data->get_role($_GET[$env->param("id")]))){
$env->set_out("role", $role);
}
- function save_role(){
+ public function save_role(){
$env = $this->env();
$data = $env->data();
if(!($role = $data->get_role($_POST["id_role"]))){
);
}
- function del_role(){
+ public function del_role(){
$env = $this->env();
$data = $env->data();
if(!isset($_GET[$env->param("id")]) || !($role = $data->get_role($_GET[$env->param("id")]))){
}
}
-
-?>
\ No newline at end of file
class mw_config_templates extends mw_controller{
- function index(){
+ public function index(){
$env = $this->env();
$data = $env->data();
if(($templates = $env->templates()) === false){
$env->set_out("out_config", $out_config);
}
- function options(){
+ public function options(){
$env = $this->env();
$data = $env->data();
if(($config = $env->get_CONFIG()) === false){
}
}
-
-?>
\ No newline at end of file
class mw_forms_contact extends mw_controller{
- function index(){
+ public function index(){
$env = $this->env();
if($env->config("contact_form") && $env->config("email")){
if($env->config("captcha")){
else $env->run("index");
}
- function __send_form($from, $titre, $message, $dest, $captcha){
+ public function __send_form($from, $titre, $message, $dest, $captcha){
$env = $this->env();
$env->set_out("ENVOYE", false);
if(!$captcha || PtitCaptchaHelper::checkCaptcha()){
}
}
-
-?>
\ No newline at end of file
class mw_index_index extends mw_controller{
- function index(){
+ public function index(){
$env = $this->env();
$start_action = $env->config("start_action");
if($start_action){
}
}
-
-?>
\ No newline at end of file
class mw_install_index extends mw_controller{
- var $config_file;
+ public $config_file;
- function validate(){
+ public 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(){
+ public function index(){
$env = $this->env();
$data = $env->data();
$admin = array(
}
}
-
-?>
\ No newline at end of file
class mw_reponses_html extends mw_controller{
- function index(){
+ public function index(){
}
- function redirect_javascript(){
+ public function redirect_javascript(){
}
- function erreur(){
+ public function erreur(){
}
}
-
-?>
\ No newline at end of file
class mw_upgrade_index extends mw_controller{
- function index(){
+ public function index(){
$env = $this->env();
$data = $env->data();
$env->set_out("data_version", $data->version("mtweb"));
$env->set_out("data_upgrades", $env->data_upgrades());
}
- function confirm_upgrade(){
+ public function confirm_upgrade(){
$env = $this->env();
if(!($user = $env->user())){
$env->redirect($env->url("upgrade"), "", 0);
class mw_upgrade_user extends mw_controller{
- function login(){
+ public function login(){
$env = $this->env();
if($_POST){
$data = $env->data();
}
}
- function logout(){
+ public function logout(){
$env = $this->env();
$data = $env->data();
$data->logout();
class mw_users_compte extends mw_controller{
- var $roles;
- var $user;
+ public $roles;
+ public $user;
+ public $validation_result;
- var $validation_result;
-
- function validate(){
+ public function validate(){
$this->validation_result = true;
if($this->validation_result === true) $this->validate_roles();
if($this->validation_result === true) $this->validate_user();
return $this->validation_result;
}
- function validate_roles(){
+ public function validate_roles(){
$env = $this->env();
$data = $env->data();
if(($this->roles = $data->roles()) !== false) $this->validation_result = true;
else $this->validation_result = "impossible de lire la liste des roles";
}
- function validate_user(){
+ public function validate_user(){
$env = $this->env();
if($this->user = $env->user()) $this->validation_result = true;
else $this->validation_result = "Vous devez être identifier pour accéder à cette page";
}
- function index(){
+ public function index(){
$env = $this->env();
if($this->validation_result === true){
$env->run("users/infos");
}
}
-
-?>
\ No newline at end of file
class mw_users_identification extends mw_controller{
- function index(){
+ public function index(){
}
- function login(){
+ public function login(){
$env = $this->env();
if($_POST){
$data = $env->data();
}
}
- function logout(){
+ public function logout(){
$env = $this->env();
$data = $env->data();
if($data->logout()){
else $env->message("Erreur lors de la deconnection. il se peut que vous soyez encore identifié");
}
- function check_logout(){
+ public function check_logout(){
$env = $this->env();
if($env->user()){
$env->erreur("deconnexion impossible. vous êtes toujours identifié sur le site.");
}
}
-
-?>
\ No newline at end of file
class mw_users_index extends mw_controller{
- function index(){
+ public function index(){
$env = $this->env();
$env->run("users/infos");
}
}
-
-?>
\ No newline at end of file
class mw_users_infos extends mw_controller{
- var $users_compte_controller;
+ public $users_compte_controller;
- function validate(){
+ public function validate(){
$env = $this->env();
if($this->users_compte_controller = $env->get_controller("users/compte")){
return $this->users_compte_controller->validate();
return "impossible de trouver le controller users/compte";
}
- function index(){
+ public function index(){
$env = $this->env();
$env->run("users/infos/edit");
}
- function edit(){
+ public function edit(){
$env = $this->env();
if(isset($this->users_compte_controller->user) && $this->users_compte_controller->user !== false){
$user = $this->users_compte_controller->user;
}
}
-
-?>
\ No newline at end of file
class mw_mysql{
- var $link;
-
- var $host;
- var $base;
- var $user;
- var $password;
-
- var $EXTENTION_OK;
-
- function extention_ok(&$env) { return $this->EXTENTION_OK; }
-
- function authentication_required() { return true; }
-
- function sgbd_name() { return "MySql"; }
-
- function mw_mysql($params = array()){
+ public $link;
+ public $host;
+ public $base;
+ public $user;
+ public $password;
+ public $EXTENTION_OK;
+
+ public function __construct($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->EXTENTION_OK = function_exists("mysql_connect");
}
- function connect($host, $base, $user, $password){
+ public function extention_ok(&$env){
+ return $this->EXTENTION_OK;
+ }
+
+ public function authentication_required(){
+ return true;
+ }
+
+ public function sgbd_name(){
+ return "MySql";
+ }
+
+ public function connect($host, $base, $user, $password){
$this->link = @mysql_connect($host, $user, $password);
if(!$this->link) throw new Exception($this->exception_out("Impossible d'etablir une connection au serveur"));
@mysql_query("SET NAMES 'utf8'");
return true;
}
- function select_db($db_name){\r
+ public function select_db($db_name){\r
$this->base = $db_name;\r
if(!$this->link) $this->connect($this->host, $this->base, $this->user, $this->password);\r
return $this->query("USE ".$db_name);\r
}
- function desc_table($table_name){
+ public function desc_table($table_name){
$sql = "SELECT * from information_schema.columns where table_name='".$table_name."'";
$rst = $this->query($sql);
$desc = array(
return $desc;
}
- function table_exists($table_name){\r
+ public function table_exists($table_name){\r
if(!$this->link) $this->connect($this->host, $this->base, $this->user, $this->password);\r
$EXISTS = false;
try{
return $EXISTS;
}
- function field_exists($table_name, $field_name){
+ public 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"));
return $EXISTS;
}
- function query($query_string){\r
+ public function query($query_string){\r
if(!$this->link) $this->connect($this->host, $this->base, $this->user, $this->password);\r
$result = @mysql_query($query_string, $this->link);\r
if(!$result) throw new Exception($this->exception_out("Syntaxe invalide dans une requete"));\r
return $result;\r
}
- function fetch_assoc($rst){
+ public function fetch_assoc($rst){
if($this->link){
if($rst){
return mysql_fetch_assoc($rst);
else throw new Exception($this->exception_out("fetch_assoc sans connexion"));
}
- function insert_id(){
+ public function insert_id(){
if($this->link){
return mysql_insert_id($this->link);
}
else throw new Exception($this->exception_out("insert_id sans connexion"));
}
- function free_result($rst){
+ public function free_result($rst){
if($this->link){
if($rst){
return mysql_free_result($rst);
else throw new Exception($this->exception_out("free_result sans connexion"));
}
- function close(){
+ public function close(){
if($this->link) return mysql_close($this->link);
return true;
}
- function exception_out($message){\r
+ public function exception_out($message){\r
return "[erreur] mysql : ".$message;\r
}
}
-
-?>
\ No newline at end of file
class mw_pdo_mysql{
- var $link;
-
- var $host;
- var $base;
- var $user;
- var $password;
-
- var $EXTENTION_OK;
+ public $link;
+ public $host;
+ public $base;
+ public $user;
+ public $password;
+ public $EXTENTION_OK;
+
+ public function __construct($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"));
+ }
- function get_link(){
+ public function get_link(){
return $this->link;
}
- function extention_ok(&$env) { return $this->EXTENTION_OK; }
-
- function authentication_required() { return true; }
+ public function extention_ok(&$env){
+ return $this->EXTENTION_OK;
+ }
- function sgbd_name() { return "PDO MySql"; }
+ public function authentication_required(){
+ return true;
+ }
- 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"));
+ public function sgbd_name(){
+ return "PDO MySql";
}
- function connect($host, $base, $user, $password){
+ public function connect($host, $base, $user, $password){
try{
$this->link = new PDO("mysql:host=".$host.";dbname=".$base, $user, $password);
$this->link->query("SET NAMES 'utf8'");
return true;
}
- function select_db($db_name){\r
+ public function select_db($db_name){\r
$this->base = $db_name;\r
if(!$this->link) $this->connect($this->host, $this->base, $this->user, $this->password);\r
return $this->query("USE ".$db_name);\r
}
- function desc_table($table_name){
+ public function desc_table($table_name){
$sql = "SELECT * from information_schema.columns where table_name='".$table_name."'";
$rst = $this->query($sql);
$desc = array(
return $desc;
}
- function table_exists($table_name){
+ public function table_exists($table_name){
if(!$this->link) $this->connect($this->host, $this->base, $this->user, $this->password);\r
$EXISTS = false;
try{
return $EXISTS;\r
}
- function field_exists($table_name, $field_name){
+ public 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"));
return $EXISTS;
}
- function query($query_string){\r
+ public 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){
+ public function fetch_assoc($rst){
if(!$this->link){
throw new Exception($this->exception_out("fetch_assoc sans connexion"));
}
return $tuple;
}
- function insert_id(){
+ public function insert_id(){
if(!$this->link){
throw new Exception($this->exception_out("insert_id sans connexion"));
}
return $id;
}
- function free_result($rst){
+ public function free_result($rst){
if(!$this->link){
throw new Exception($this->exception_out("free_result sans connexion"));
}
return true;
}
- function close(){
+ public function close(){
$this->link = null;
return true;
}
- function exception_out($message){\r
+ public function exception_out($message){\r
return "[erreur] mysql : ".$message;\r
}
}
-
-?>
\ No newline at end of file
class mw_pdo_sqlite{
- var $link;
-
- var $host;
- var $base;
- var $user;
- var $password;
-
- var $EXTENTION_OK;
+ public $link;
+ public $host;
+ public $base;
+ public $user;
+ public $password;
+ public $EXTENTION_OK;
+
+ public function __construct($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 get_link(){
+ public function get_link(){
return $this->link;
}
- function extention_ok(&$env) { return $this->EXTENTION_OK; }
-
- function authentication_required() { return false; }
+ public function extention_ok(&$env){
+ return $this->EXTENTION_OK;
+ }
- function sgbd_name() { return "PDO SQLite"; }
+ public function authentication_required(){
+ return false;
+ }
- 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"));
+ public function sgbd_name(){
+ return "PDO SQLite";
}
- function connect($host, $base, $user, $password){
+ public function connect($host, $base, $user, $password){
if($host) $host .= substr($host, -1) != "/" ? "/" : "";
try{
$this->link = null;
return true;
}
- function select_db($db_name){\r
+ public 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){
+ public function desc_table($table_name){
if(strpos($table_name, "'") !== false){
throw new Exception($this->exception_out("nom de table avec un simple quote"));
}
return $desc;
}
- function table_exists($table_name){
+ public function table_exists($table_name){
if(!$this->link) $this->connect($this->host, $this->base, $this->user, $this->password);\r
$EXISTS = false;
try{
return $EXISTS;\r
}
- function field_exists($table_name, $field_name){
+ public 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"));
return $EXISTS;
}
- function query($query_string){\r
+ public 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){
+ public function fetch_assoc($rst){
if(!$this->link){
throw new Exception($this->exception_out("fetch_assoc sans connexion"));
}
return $tuple;
}
- function insert_id(){
+ public function insert_id(){
if(!$this->link){
throw new Exception($this->exception_out("insert_id sans connexion"));
}
return $id;
}
- function free_result($rst){
+ public function free_result($rst){
if(!$this->link){
throw new Exception($this->exception_out("free_result sans connexion"));
}
return true;
}
- function close(){
+ public function close(){
$this->link = null;
return true;
}
- function exception_out($message){\r
+ public function exception_out($message){\r
return "[erreur] sqlite : ".$message;\r
}
}
-
-?>
\ No newline at end of file
class mw_xml{
- var $host;
- var $base;
- var $user;
- var $password;
-
- var $EXTENTION_OK;
-
- var $xml_data;
-
- var $data_handlers;
- var $last_data_handler;
-
- function mw_xml($params = array()){
+ public $host;
+ public $base;
+ public $user;
+ public $password;
+ public $EXTENTION_OK;
+ public $xml_data;
+ public $data_handlers;
+ public $last_data_handler;
+
+ public function __construct($params = array()){
$this->init_xml_env(
isset($params["host"]) ? $params["host"] : "content/data/xml",
isset($params["base"]) ? $params["base"] : "mw",
$this->EXTENTION_OK = true;
}
- function extention_ok(&$env){
+ public function extention_ok(&$env){
if($this->EXTENTION_OK){
if(
file_exists($env->app_file("data/impl/xml/mw_xml_data.php"))
return $this->EXTENTION_OK;
}
- function authentication_required() { return false; }
+ public function authentication_required(){
+ return false;
+ }
- function sgbd_name() { return "XML"; }
+ public function sgbd_name(){
+ return "XML";
+ }
- function init_xml_env($host, $base, $user, $password){
+ public function init_xml_env($host, $base, $user, $password){
$this->host = $host.($host && substr($host, -1) != "/" ? "/" : "");
$this->base = $base.($base && substr($base, -1) != "/" ? "/" : "");
$this->user = $user;
$this->last_data_handler = 0;
}
- function connect($host, $base, $user, $password){
+ public function connect($host, $base, $user, $password){
if($host.$base && is_dir($host.$base) && is_writable($host.$base)){
$this->init_xml_env($host, $base, $user, $password);
$this->xml_data = new mw_xml_data($this->host, $this->base);
return null;
}
- function select_db($base){
+ public function select_db($base){
$this->base = $base.($base && substr($base, -1) != "/" ? "/" : "");
return $this->connect($this->host, $this->base, $this->user, $this->password);
}
- function data_exists($data_path){
+ public function data_exists($data_path){
return is_dir($this->host.$this->base.$data_path);
}
- function create_data($data_path){
+ public function create_data($data_path){
if(!is_dir($this->host.$this->base.$data_path)) @mkdir($this->host.$this->base.$data_path);
if(is_dir($this->host.$this->base.$data_path)){
if($dh = $this->open_data($data_path, false)){
return null;
}
- function get_data($data_path, $data_id){
+ public function get_data($data_path, $data_id){
$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)){
return null;
}
- function open_data($data_path, $FETCH = true){
+ public function open_data($data_path, $FETCH = true){
$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($FETCH)){
return null;
}
- function fetch_data($dh){
+ public function fetch_data($dh){
if(isset($this->data_handlers[$dh])){
return $this->data_handlers[$dh]->fetch_assoc();
}
return false;
}
- function add_data($data_path, $data, $index = null){
+ public 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)){
return null;
}
- function last_index($dh){
+ public function last_index($dh){
if(isset($this->data_handlers[$dh])){
return $this->data_handlers[$dh]->last_index;
}
return null;
}
- function set_data($data_path, $data_id, $data){
+ public function set_data($data_path, $data_id, $data){
$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)){
return null;
}
- function del_data($data_path, $data_id){
+ public function del_data($data_path, $data_id){
$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)){
return null;
}
- function close_data($dh){
+ public function close_data($dh){
if(isset($this->data_handlers[$dh])){
$this->data_handlers[$dh]->close_data();
unset($this->data_handlers[$dh]);
}
}
- function remove_data($data_path){
+ public function remove_data($data_path){
$OK = strlen($data_path) > 0;
if($OK && is_dir($this->host.$this->base.$data_path) && is_writable($this->host.$this->base.$data_path)){
$data_path .= substr($data_path, -1) == "/" ? "" : "/";
}
}
-
-?>
\ No newline at end of file
class mw_xml_data{
- var $host;
- var $base;
+ public $host;
+ public $base;
+ public $sxml;
+ public $cache;
+ public $buffer;
- var $sxml;
-
- var $cache;
- var $buffer;
-
- function mw_xml_data($host, $base){
+ public function mw_xml_data($host, $base){
$this->host = $host.(substr($host, -1) != "/" ? "/" : "");
$this->base = $base.(substr($base, -1) != "/" ? "/" : "");
$this->cache = array();
}
- function host(){
+ public function host(){
return $this->host;
}
- function base(){
+ public function base(){
return $this->base;
}
- function use_cache(){
+ public function use_cache(){
return true;
}
- function set_cache($data_name, $data, $data_id){
+ public function set_cache($data_name, $data, $data_id){
if($this->use_cache()){
$this->cache[$data_name] = $data;
$this->cache[$data_name]["id"] = $data_id;
}
}
- function get_data($data_path, $data_id){
+ public function get_data($data_path, $data_id){
$data_name = $this->data_name($data_path, $data_id);
if(isset($this->cache[$data_name])) return $this->cache[$data_name];
if($this->buffer = @file_get_contents($data_name)){
return false;
}
- function add_data($data_path, $data_id, $data){
+ public function add_data($data_path, $data_id, $data){
return $this->_set_data($data_path, $data_id, $data);
}
- function set_data($data_path, $data_id, $data){
+ public function set_data($data_path, $data_id, $data){
return $this->_set_data($data_path, $data_id, $data);
}
- function _set_data($data_path, $data_id, $data){
+ public function _set_data($data_path, $data_id, $data){
if($fh = @fopen($this->data_name($data_path, $data_id), "w")){
$this->buffer = $this->serialize_data($data);
if(@fwrite($fh, $this->buffer) !== false){
return null;
}
- function del_data($data_path, $data_id){
+ public function del_data($data_path, $data_id){
$data_name = $this->data_name($data_path, $data_id);
if(isset($this->cache[$data_name])) unset($this->cache[$data_name]);
return @unlink($this->data_name($data_path, $data_id));
}
- function data_name($data_path, $data_id){
+ public function data_name($data_path, $data_id){
return $this->host.$this->base.$data_path.$data_id.".xml";
}
- function parse_data(){
+ public function parse_data(){
if(!isset($this->sxml)) $this->sxml = new sxml();
$this->sxml->parse($this->buffer);
if(isset($this->sxml->data["tuple"][0])){
return false;
}
- function serialize_data($data){
+ public function serialize_data($data){
$this->buffer = "<tuple>\n";
foreach($data as $key => $value){
if(isset($value)) $this->buffer .= " <".$key."><![CDATA[".$value."]]></".$key.">\n";
}
}
-
-?>
\ No newline at end of file
class mw_xml_data_handler{
- var $xml_data;
- var $data_path;
- var $data_path_handler;
- var $last_index;
+ public $xml_data;
+ public $data_path;
+ public $data_path_handler;
+ public $last_index;
- function mw_xml_data_handler($xml_data, $data_path){
+ public function mw_xml_data_handler($xml_data, $data_path){
$this->xml_data = $xml_data;
$this->data_path = $data_path.(substr($data_path, -1) != "/" ? "/" : "");
}
- function get_data($data_id){
+ public function get_data($data_id){
if(file_exists($this->xml_data->host().$this->xml_data->base().$this->data_path.$data_id.".xml")){
return $this->xml_data->get_data($this->data_path, $data_id);
}
return false;
}
- function open_data($FETCH = true){
+ public function open_data($FETCH = true){
clearstatcache();
$INDEX_OK = false;
if($this->xml_data->host() && $this->xml_data->base() && $this->data_path){
}
}
- function fetch_assoc(){
+ public function fetch_assoc(){
if($this->data_path_handler){
$FORMAT_OK = false;
while(!$FORMAT_OK && ($data_file = @readdir($this->data_path_handler)) !== false){
return false;
}
- function add_data($data, $index = null){
+ public 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);
return null;
}
- function inc_index(){
+ public function inc_index(){
clearstatcache();
if(isset($this->last_index)){
$index = $this->last_index + 1;
return null;
}
- function set_data($data_file, $data){
+ public function set_data($data_file, $data){
if(preg_match("/^[0-9]+\.xml$/", $data_file)){
if(is_writable($this->xml_data->host().$this->xml_data->base().$this->data_path.$data_file)){
if(is_array($data)){
return null;
}
- function del_data($data_file){
+ public function del_data($data_file){
if(preg_match("/^[0-9]+\.xml$/", $data_file)){
if(is_file($this->xml_data->host().$this->xml_data->base().$this->data_path.$data_file)){
return $this->xml_data->del_data($this->data_path, substr($data_file, 0, -4));
return null;
}
- function close_data(){
+ public function close_data(){
$this->data_path= null;
if($this->data_path_handler) @closedir($this->data_path_handler);
$this->last_index = null;
}
}
-
-?>
\ No newline at end of file
class mw_model_users extends mw_model{
- var $roles;
+ public $roles;
// ----------------------------------------------------------------------------
// accesseurs
- function set_roles($roles){
+ public function set_roles($roles){
$this->roles = $roles;
}
- function get_roles(){
+ public function get_roles(){
return $this->roles;
}
- function clear_roles(){
+ public function clear_roles(){
$this->roles = null;
}
- function get_values(){
+ public function get_values(){
$values = array();
if(isset($this->roles)) $values["roles"] = $this->roles;
foreach($this->attributs as $attribut_name => $attribut){
return $values;
}
- function set_password($password){
+ public function set_password($password){
$this->attributs["password"]["value"] = $this->encode_password($password);
}
- function encode_password($password){
+ public function encode_password($password){
return md5($password);
}
// ----------------------------------------------------------------------------
// validation
- function valid_email($email){
+ public function valid_email($email){
if(!isset($email) || !$email){
return "merci de préciser un email";
}
return true;
}
- function valid_login($login){
+ public function valid_login($login){
if(!isset($login) || !$login){
return "merci de préciser un login";
}
return true;
}
- function valid_password($password){
+ public function valid_password($password){
if(!isset($password) || ($password == $this->encode_password(""))){
return "merci de préciser un mot de passe";
}
// ----------------------------------------------------------------------------
// CRUD
- function insert(){
+ public function insert(){
$data = $this->env->data();
$roles = $this->get_roles();
$this->clear_roles();
return $id_user;
}
- function load($index_name, $index_value){
+ public function load($index_name, $index_value){
$data = $this->env->data();
if(parent::load($index_name, $index_value) === false) return false;
if($this->get_id()){
return true;
}
- function update($index_name, $index_value = null){
+ public function update($index_name, $index_value = null){
$data = $this->env->data();
$roles = $this->get_roles();
$this->clear_roles();
return $res;
}
- function delete($index_name, $index_value = null){
+ public function delete($index_name, $index_value = null){
$data = $this->env->data();
if(!$data->clear_user_roles($this->get_id())) return false;
return parent::delete($index_name, $index_value);
}
}
-
-?>
\ No newline at end of file
class mw_data_auto_crud extends mw_data{
- function call_data_auto_crud($method_name, $arguments){
+ public function call_data_auto_crud($method_name, $arguments){
$r = false;
$sgbd = $this->sgbd();
}
}
-
-?>
\ No newline at end of file
class mw_data_config extends mw_data{
- function config($key = null){
+ public function config($key = null){
$value = false;
if(isset($key)){
$value = "";
return $value;
}
- function config_exists($key){
+ public function config_exists($key){
if(
(
$config = $this->data_read(
return $config ? 1 : 0;
}
- function set_config($key, $value){
+ public function set_config($key, $value){
if(
(
$config = $this->data_read(
}
}
- function del_config($key){
+ public function del_config($key){
return $this->data_delete(
array(
"table_name" => "config",
}
}
-
-?>
\ No newline at end of file
class mw_data_images extends mw_data{
- function img_size($file, $max_width, $max_height){
+ public function img_size($file, $max_width, $max_height){
$img_infos = @getimagesize($file);
$img_size = array();
if($img_infos){
class mw_data_init extends mw_data{
- var $env;
- var $sgbd;
+ public $env;
+ public $sgbd;
- function env(){
+ public function env(){
return $this->env;
}
- function sgbd(){
+ public function sgbd(){
return $this->sgbd;
}
- function set_env(&$env){
+ public function set_env(&$env){
$this->env = &$env;
}
- function set_sgbd(&$sgbd){
+ public function set_sgbd(&$sgbd){
$this->sgbd = &$sgbd;
}
- function table_prefix(){
+ public function table_prefix(){
return false;
}
}
-
-?>
\ No newline at end of file
class mw_data_links extends mw_data{
- var $links;
+ public $links;
- function init_links(){
+ public function init_links(){
$this->links = array();
return true;
}
- function load_link(&$links, $v_path, $url, $intitule = "", $position = 0){
+ public function load_link(&$links, $v_path, $url, $intitule = "", $position = 0){
if($path_item = array_shift($v_path)){
if(!isset($links[$path_item])) $links[$path_item] = array(
"nom" => $path_item,
}
}
- function valid_link_path($path){
+ public function valid_link_path($path){
$v_path = explode("/", $path);
$SYNTAX_OK = true;
foreach($v_path as $i => $path_item){
return $v_path && $SYNTAX_OK ? $v_path : false;
}
- function get_link($path = null){
+ public function get_link($path = null){
if(!isset($this->links)) $this->init_links();
if($this->links !== false){
if(!isset($path)) return $this->links;
return false;
}
- function _get_link($links, $v_path){
+ public function _get_link($links, $v_path){
if($path_item = array_shift($v_path)){
if(isset($links[$path_item])){
if($v_path) return $this->_get_link($links[$path_item]["subs"], $v_path);
}
}
- function set_link($path, $url, $intitule = "", $position = 0){
+ public function set_link($path, $url, $intitule = "", $position = 0){
if(!isset($this->links)) $this->init_links();
if($v_path = $this->valid_link_path($path)){
$this->load_link($this->links, $v_path, $url, $intitule, $position);
}
}
- function ordonne_links($links){
+ public function ordonne_links($links){
if(!is_array($links)) return false;
$values = array_values($links);
$maximum = count($values);
}
}
-
-?>
\ No newline at end of file
class mw_data_sgbds extends mw_data{
- function sgbds(){
+ public function sgbds(){
$env = $this->env();
$sgbds = array();
$impls_dir = $env->app_file("data/impl");
}
}
-
-?>
\ No newline at end of file
class mw_data_users_files extends mw_data{
- function check_user_uploads_dir($id_user = null){
+ public function check_user_uploads_dir($id_user = null){
$env = $this->env();
if(!isset($id_user)){
$user = $env->user();
}
}
-
-?>
\ No newline at end of file
class mw_data_users_sessions extends mw_data{
- var $user;
+ public $user;
- function login($login, $password, $reference_user = null){
+ public function login($login, $password, $reference_user = null){
if(($user = isset($reference_user) ? $reference_user : $this->user($login)) !== false){
if(isset($reference_user) && $login != $reference_user["login"]){
$this->clear_session();
return $user;
}
- function logout(){
+ public function logout(){
return $this->clear_session();
}
- function user_ok($user){
+ public function user_ok($user){
return
(isset($_SESSION[$this->app_session_key()]["id"]))
&& (isset($_SESSION[$this->app_session_key()]["pass"]))
&& ($_SESSION[$this->app_session_key()]["ip"] == $_SERVER["REMOTE_ADDR"]);
}
- function password_ok($user, $password){
+ public function password_ok($user, $password){
if(!$user) return false;
$OK =
(isset($_SESSION[$this->app_session_key()]["id"]))
# session
#
- function app_session_key(){
+ public function app_session_key(){
$env = $this->env();
return "mw_".str_replace("/", "_", $env->path("web"));
}
- function load_session($reference_user = null){
+ public function load_session($reference_user = null){
@session_start();
if(!isset($_SESSION[$this->app_session_key()]["id"])) $this->clear_session();
$user = array();
return $user;
}
- function set_session($user){
+ public function set_session($user){
if(!isset($_SESSION[$this->app_session_key()])) $this->clear_session();
$_SESSION[$this->app_session_key()]["user"] = $user["login"];
$_SESSION[$this->app_session_key()]["pass"] = md5($user["password"].$_SESSION[$this->app_session_key()]["id"]);
&& @setcookie($this->app_session_key()."_pass", $user["password"], time() + (60 * 60 * 24 * 7), "/");
}
- function clear_session(){
+ public function clear_session(){
unset($_SESSION[$this->app_session_key()]);
$_SESSION[$this->app_session_key()] = array(
"ip" => $_SERVER["REMOTE_ADDR"],
&& @setcookie($this->app_session_key()."_pass", "", 0, "/");
}
- function set_session_user($user){
+ public function set_session_user($user){
$this->set_session($user);
$this->user =& $user;
}
- function get_session_user(){
+ public function get_session_user(){
return $this->user;
}
}
-
-?>
\ No newline at end of file
class mw_data_utils extends mw_data{
- function eq($content){
+ public function eq($content){
return isset($content) ? "'".str_replace("'", "\'", $content)."'" : "NULL";
}
- function ordonne($list, $key, $order = "ASC"){
+ public function ordonne($list, $key, $order = "ASC"){
$values = array_values($list);
$maximum = count($values);
while($maximum > 0){
return $res;
}
- function upload($image, $upload_dir){
+ public function upload($image, $upload_dir){
$file = "";
$upload_dir .= $upload_dir && (substr($upload_dir, -1) != "/") ? "/" : "";
if($_FILES){
}
}
-
-?>
\ No newline at end of file
class mw_data_valid_config extends mw_data{
- function valid_config($input, $config = array()){
+ public function valid_config($input, $config = array()){
$res = array(
"config" => $config,
"messages" => array(),
}
}
-
-?>
\ No newline at end of file
class mw_data_versions extends mw_data{
- function version($application_name){
+ public function version($application_name){
if(
$version = $this->data_read(
array(
return false;
}
- function set_version($application_name, $version){
+ public function set_version($application_name, $version){
if(
(
$data_version = $this->data_read(
# parametres du sgbd
#
- function set_sgbd_param($key, $value){
+ public function set_sgbd_param($key, $value){
$env = $this->env();
if(($env->bdd("sgbd") == "pdo_mysql") || ($env->bdd("sgbd") == "mysql")){
return $this->set_sgbd_mysql_param($key, $value);
return false;
}
- function set_sgbd_mysql_param($key, $value){
+ public function set_sgbd_mysql_param($key, $value){
$sgbd = $this->sgbd();
$sql = "SET ".$key."=\"".$value."\"";
try{
# create table
#
- function data_create_table($params){
+ public function data_create_table($params){
$env = $this->env();
if($env->bdd("sgbd") == "pdo_sqlite"){
return $this->data_create_sqlite_table($params);
return $this->data_create_mysql_table($params);
}
- function data_create_mysql_table($params){
+ public function data_create_mysql_table($params){
$sgbd = $this->sgbd();
$table_name = isset($params["table_name"]) ? $params["table_name"] : "";
$fields = isset($params["fields"]) ? $params["fields"] : array();
return true;
}
- function data_create_sqlite_table($params){
+ public function data_create_sqlite_table($params){
$sgbd = $this->sgbd();
$table_name = isset($params["table_name"]) ? $params["table_name"] : "";
$fields = isset($params["fields"]) ? $params["fields"] : array();
# description
#
- function data_desc($params = array()){
+ public function data_desc($params = array()){
$sgbd = $this->sgbd();
$table_name = isset($params["table_name"]) ? $params["table_name"] : "";
if(!$table_name) return false;
# insert
#
- function data_insert($params = array()){
+ public function data_insert($params = array()){
$sgbd = $this->sgbd();
$table_name = isset($params["table_name"]) ? $params["table_name"] : "";
if(!$table_name) return false;
# read
#
- function data_read($params = array()){
+ public function data_read($params = array()){
$sgbd = $this->sgbd();
$table_name = isset($params["table_name"]) ? $params["table_name"] : "";
$index_name = isset($params["index_name"]) ? $params["index_name"] : "";
# update
#
- function data_update($params = array()){
+ public function data_update($params = array()){
$sgbd = $this->sgbd();
$table_name = isset($params["table_name"]) ? $params["table_name"] : false;
$values = (isset($params["values"]) && is_array($params["values"])) ? $params["values"] : false;
# delete
#
- function data_delete($params = array()){
+ public function data_delete($params = array()){
$sgbd = $this->sgbd();
$table_name = isset($params["table_name"]) ? $params["table_name"] : false;
$index_name = isset($params["index_name"]) ? $params["index_name"] : false;
# list
#
- function data_list($params = array()){
+ public function data_list($params = array()){
$sgbd = $this->sgbd();
$table_name = isset($params["table_name"]) ? $params["table_name"] : "";
if(!$table_name) return false;
}
}
-
-?>
\ No newline at end of file
class mw_data_sql_install extends mw_data{
- function install_sql($params){
+ public function install_sql($params){
$env = $this->env();
$data = $env->data();
$sgbd = $data->sgbd();
}
}
-
-?>
\ No newline at end of file
class mw_data_sql_users extends mw_data{
- var $users;
- var $user;
- var $roles;
- var $actions_roles;
+ public $users;
+ public $user;
+ public $roles;
+ public $actions_roles;
# ----------------------------------------------------------------------------------------
# users
#
- function users($start = 0, $alpha = null, $id_role = null){
+ public function users($start = 0, $alpha = null, $id_role = null){
$sgbd = $this->sgbd();
$env = $this->env();
$users = array("list" => array(), "total" => 0);
return $users;
}
- function list_user_roles($id_user){
+ public function list_user_roles($id_user){
$sgbd = $this->sgbd();
$roles = array();
try{
return $roles;
}
- function user_by_id($id){
+ public function user_by_id($id){
$env = $this->env();
$user = $env->get_model("users");
if($user->load("id", $id) === false) return false;
return $user->get_values();
}
- function user($login){
+ public function user($login){
$env = $this->env();
$user = $env->get_model("users");
if($user->load("login", $login) === false) return false;
return $user->get_values();
}
- function user_exists($login){
+ public function user_exists($login){
$sgbd = $this->sgbd();
$EXISTS = 0;
try{
return $EXISTS;
}
- function add_user($login, $password, $email, $roles){
+ public function add_user($login, $password, $email, $roles){
$sgbd = $this->sgbd();
$user_id = false;
try{
return $user_id;
}
- function set_user($id, $login, $password, $email, $roles){
+ public function set_user($id, $login, $password, $email, $roles){
$sgbd = $this->sgbd();
try{
$sql =
return true;
}
- function clear_user_roles($id_user){
+ public function clear_user_roles($id_user){
$sgbd = $this->sgbd();
try{
$sql = "DELETE FROM #--users_roles WHERE id_user=".$this->eq($id_user);
return true;
}
- function add_user_role($id_user, $id_role){
+ public function add_user_role($id_user, $id_role){
$sgbd = $this->sgbd();
try{
$sql =
return true;
}
- function del_user($login){
+ public function del_user($login){
if(($user = $this->user($login)) !== false){
$sgbd = $this->sgbd();
try{
# roles
#
- function init_roles(){
+ public function init_roles(){
$sgbd = $this->sgbd();
$this->roles = array();
try{
return $this->roles;
}
- function roles(){
+ public function roles(){
if(!isset($this->roles)) return false;
return $this->roles;
}
- function add_role($nom, $intitule){
+ public function add_role($nom, $intitule){
$sgbd = $this->sgbd();
try{
$sql =
return $id_role;
}
- function get_role($id){
+ public function get_role($id){
if($id === "0") return array(
"id" => 0,
"nom" => "",
return $role;
}
- function set_role($id, $nom, $intitule){
+ public function set_role($id, $nom, $intitule){
$sgbd = $this->sgbd();
try{
$sql =
return true;
}
- function clear_role_actions($id_role){
+ public function clear_role_actions($id_role){
$sgbd = $this->sgbd();
try{
$sql = "DELETE FROM #--actions_roles WHERE id_role=".$this->eq($id_role);
return true;
}
- function clear_role_users($id_role){
+ public function clear_role_users($id_role){
$sgbd = $this->sgbd();
try{
$sql = "DELETE FROM #--users_roles WHERE id_role=".$this->eq($id_role);
return true;
}
- function add_role_action($id_role, $action){
+ public function add_role_action($id_role, $action){
$sgbd = $this->sgbd();
try{
$sql = "INSERT INTO #--actions_roles(action, id_role) VALUES(".$this->eq($action).", ".$this->eq($id_role).")";
return $id_action_role;
}
- function del_role($id_role){
+ public function del_role($id_role){
$sgbd = $this->sgbd();
try{
$sql = "DELETE FROM #--roles WHERE id=".$this->eq($id_role);
return true;
}
- function get_user_roles(){
+ public function get_user_roles(){
$user_roles = array();
$user = $this->get_session_user();
if($user && isset($user["id"])){
return $user_roles;
}
- function init_actions_roles(){
+ public function init_actions_roles(){
if(!isset($this->roles)) return false;
$this->actions_roles = $this->read_actions_roles();
return $this->actions_roles;
}
- function read_actions_roles($params = array()){
+ public function read_actions_roles($params = array()){
$group_by_action = isset($params["group_by_action"]) ? $params["group_by_action"] : false;
$sgbd = $this->sgbd();
$actions_roles = array();
return $actions_roles;
}
- function get_action_roles($mod, $controller = "index", $action = "index"){
+ public function get_action_roles($mod, $controller = "index", $action = "index"){
$sgbd = $this->sgbd();
$roles = array();
try{
return $roles;
}
- function get_actions($id_role = null){
+ public function get_actions($id_role = null){
$env = $this->env();
if($actions = $env->get_actions()){
if(($actions_roles = $this->read_actions_roles(array("group_by_action" => true))) !== false){
}
}
-
-?>
\ No newline at end of file
class mw_data_sqlite_install extends mw_data{
- function install_sqlite($params){
+ public function install_sqlite($params){
$env = $this->env();
$data = $env->data();
$sgbd = $data->sgbd();
}
}
-
-?>
\ No newline at end of file
# insert
#
- function data_insert($params = array()){
+ public function data_insert($params = array()){
$table_name = isset($params["table_name"]) ? $params["table_name"] : "";
if(!$table_name) return false;
$values = (isset($params["values"]) && is_array($params["values"])) ? $params["values"] : false;
# read
#
- function data_read($params = array()){
+ public function data_read($params = array()){
$sgbd = $this->sgbd();
$table_name = isset($params["table_name"]) ? $params["table_name"] : "";
$index_name = isset($params["index_name"]) ? $params["index_name"] : "";
# update
#
- function data_update($params = array()){
+ public function data_update($params = array()){
$sgbd = $this->sgbd();
$table_name = isset($params["table_name"]) ? $params["table_name"] : false;
$values = (isset($params["values"]) && is_array($params["values"])) ? $params["values"] : false;
# delete
#
- function data_delete($params = array()){
+ public function data_delete($params = array()){
$sgbd = $this->sgbd();
$table_name = isset($params["table_name"]) ? $params["table_name"] : false;
$index_name = isset($params["index_name"]) ? $params["index_name"] : false;
# list
#
- function data_list($params = array()){
+ public function data_list($params = array()){
$sgbd = $this->sgbd();
$table_name = isset($params["table_name"]) ? $params["table_name"] : "";
if(!$table_name) return false;
}
}
-
-?>
\ No newline at end of file
class mw_data_xml_install extends mw_data{
- function install_xml($params){
+ public function install_xml($params){
$env = $this->env();
$data = $env->data();
$sgbd = $data->sgbd();
}
}
-
-?>
\ No newline at end of file
class mw_data_xml_users extends mw_data{
- var $users;
- var $user;
- var $roles;
- var $actions_roles;
+ public $users;
+ public $user;
+ public $roles;
+ public $actions_roles;
# ----------------------------------------------------------------------------------------
# users
#
- function users($start = 0, $alpha = null, $id_role = null){
+ public function users($start = 0, $alpha = null, $id_role = null){
$sgbd = $this->sgbd();
$env = $this->env();
$users = array("list" => array(), "total" => 0);
return $users;
}
- function list_user_roles($id_user){
+ public function list_user_roles($id_user){
$sgbd = $this->sgbd();
$roles = array();
if($rst = $sgbd->open_data("users_roles")){
return $roles;
}
- function user_by_id($id){
+ public function user_by_id($id){
$env = $this->env();
$user = $env->get_model("users");
if($user->load("id", $id) === false) return false;
return $user->get_values();
}
- function user($login){
+ public function user($login){
$env = $this->env();
$user = $env->get_model("users");
if($user->load("login", $login) === false) return false;
return $user->get_values();
}
- function user_exists($login){
+ public function user_exists($login){
$sgbd = $this->sgbd();
$EXISTS = 0;
if($rst = $sgbd->open_data("users")){
return $EXISTS;
}
- function add_user($login, $password, $email, $roles){
+ public function add_user($login, $password, $email, $roles){
$sgbd = $this->sgbd();
if(
(
return $id_user;
}
- function set_user($id, $login, $password, $email, $roles){
+ public function set_user($id, $login, $password, $email, $roles){
$sgbd = $this->sgbd();
if(
!$sgbd->set_data(
return true;
}
- function clear_user_roles($id_user){
+ public function clear_user_roles($id_user){
$sgbd = $this->sgbd();
if($rst = $sgbd->open_data("users_roles")){
$OK = true;
return $OK;
}
- function add_user_role($id_user, $id_role){
+ public function add_user_role($id_user, $id_role){
$sgbd = $this->sgbd();
$OK = $sgbd->add_data(
"users_roles",
return true;
}
- function del_user($login){
+ public function del_user($login){
if(($user = $this->user($login)) !== false){
$sgbd = $this->sgbd();
if(!$sgbd->del_data("users", $user["id"])) return false;
# roles
#
- function init_roles(){
+ public function init_roles(){
$sgbd = $this->sgbd();
$this->roles = array();
if($rst = $sgbd->open_data("roles")){
return $this->roles;
}
- function roles(){
+ public function roles(){
if(!isset($this->roles)) return false;
return $this->roles;
}
- function add_role($nom, $intitule){
+ public function add_role($nom, $intitule){
$sgbd = $this->sgbd();
$id_role = $sgbd->add_data(
"roles",
return $id_role;
}
- function get_role($id){
+ public function get_role($id){
if($id === "0") return array(
"id" => 0,
"nom" => "",
return $role ? $role : array();
}
- function set_role($id, $nom, $intitule){
+ public function set_role($id, $nom, $intitule){
$sgbd = $this->sgbd();
if(
!$sgbd->set_data(
return true;
}
- function clear_role_actions($id_role){
+ public function clear_role_actions($id_role){
$sgbd = $this->sgbd();
if($rst = $sgbd->open_data("actions_roles")){
$OK = true;
return false;
}
- function clear_role_users($id_role){
+ public function clear_role_users($id_role){
$sgbd = $this->sgbd();
if($rst = $sgbd->open_data("users_roles")){
$OK = true;
return false;
}
- function add_role_action($id_role, $action){
+ public function add_role_action($id_role, $action){
$sgbd = $this->sgbd();
$id_action_role = $sgbd->add_data(
"actions_roles",
return $sgbd->del_data("roles", $id_role) ? true : false;
}
- function get_user_roles(){
+ public function get_user_roles(){
$user_roles = array();
$user = $this->get_session_user();
if($user && isset($user["id"])){
return $user_roles;
}
- function init_actions_roles(){
+ public function init_actions_roles(){
if(!isset($this->roles)) return false;
$this->actions_roles = $this->read_actions_roles();
return $this->actions_roles;
}
- function read_actions_roles($params = array()){
+ public function read_actions_roles($params = array()){
if(!isset($this->roles)) return false;
$group_by_action = isset($params["group_by_action"]) ? $params["group_by_action"] : false;
$sgbd = $this->sgbd();
return $actions_roles;
}
- function get_action_roles($mod, $controller = "index", $action = "index"){
+ public function get_action_roles($mod, $controller = "index", $action = "index"){
$sgbd = $this->sgbd();
$roles = array();
if($rst = $sgbd->open_data("actions_roles")){
return $roles;
}
- function get_actions($id_role = null){
+ public function get_actions($id_role = null){
$env = $this->env();
if($actions = $env->get_actions()){
if(($actions_roles = $this->read_actions_roles(array("group_by_action" => true))) !== false){
}
}
-
-?>
\ No newline at end of file
class mtweb_sql_version_0_11_2 extends mw_data_version{
- function version(){
+ public function version(){
return "0.11.2";
}
- function do_upgrade(){
+ public function do_upgrade(){
$env = $this->env();
$data = $env->data();
class mtweb_xml_version_0_11_2 extends mw_data_version{
- function version(){
+ public function version(){
return "0.11.2";
}
- function do_upgrade(){
+ public function do_upgrade(){
$env = $this->env();
$data = $env->data();
class mw_helper_out extends mw_helper{
- function pagination_menu($current, $total, $max, $base_url, $start_param, $legende = null){
+ public function pagination_menu($current, $total, $max, $base_url, $start_param, $legende = null){
$navig = "";
if($max && $total > $max){
if(isset($legende)){
return $navig;
}
- function esc_attr($content){
+ public function esc_attr($content){
return htmlspecialchars($content, ENT_COMPAT, "UTF-8");
}
- function get_menu_ul($menu, $indent = ""){
+ public function get_menu_ul($menu, $indent = ""){
$html = "";
if($menu["subs"]){
$html .= $indent."<div class=\"menu\"><ul>\n";
}
}
-
-?>
\ No newline at end of file
: "<pre class=\"debug\">".htmlentities(print_r($content, true), ENT_QUOTES, "UTF-8")."</pre>";
}
endif;
-
-?>
\ No newline at end of file
}
unset($process);
}
-
-?>
\ No newline at end of file
$this->set_config(array("start_action_params" => $start_action_params_config));
}
else $this->erreur("Impossible de lire la configuration en base", true);
-
-?>
\ No newline at end of file
else $this->erreur("Impossible de charger les statuts des utilisateurs", true);
}
else $this->erreur("Impossible de charger la session", true);
-
-?>
\ No newline at end of file
$this->set_link("config/plugins", $this->url("config/plugins"), "Plugins", 40);
}
else $this->erreur("impossible de charger les liens", true);
-
-?>
\ No newline at end of file
}
}
else $this->erreur("erreur lors de l'initialisation des plugins", true);
-
-?>
\ No newline at end of file
class mw_observer_login extends mw_observer{
- function action_permission_denied(){
+ public function action_permission_denied(){
$env = $this->env();
if(!$env->user()){
$env->erreur("Merci de vous identifier", "users/identification");
}
}
- function user_login($params){
+ public function user_login($params){
$env = $this->env();
$redirect_action = "index";
$redirect_params = array();
}
}
-
-?>
\ No newline at end of file
class mw_template_default extends mw_template{
- function get_template_infos(){
+ public function get_template_infos(){
return array(
"name" => "Default"
);
}
- function get_out_config(){
+ public function get_out_config(){
$out_config = parent::get_out_config();
$out_config["navig_menu_top"] = array(
"type" => "checkbox",
return $out_config;
}
- function init(){
+ public function init(){
$this->add_js_file($this->out_url("js/jquery-1.8.3.min.js"));
if($this->is_running("users/identification")){
$this->add_js_file($this->out_url("js/md5.js"));
}
}
-
-?>
\ No newline at end of file
class mw_env_app_files extends mw_env{
- function app_file_exists($file, $PRIORITE = "ASC"){
+ public function app_file_exists($file, $PRIORITE = "ASC"){
$app_file = $this->_app_file($file, $PRIORITE);
return $app_file ? true : false;
}
- function app_file($file, $PRIORITE = "ASC"){
+ public function app_file($file, $PRIORITE = "ASC"){
$app_file = $this->_app_file($file, $PRIORITE);
return $app_file ? $app_file : $file;
}
- function _app_file($file, $PRIORITE = "ASC"){
+ public function _app_file($file, $PRIORITE = "ASC"){
$app_file = false;
if($PRIORITE == "ASC" && file_exists($this->path("mw_dir")."app/".$file)) return $this->path("mw_dir")."app/".$file;
if(($plugins = $this->plugins($PRIORITE)) !== false){
}
}
-
-?>
\ No newline at end of file
class mw_env_cli extends mw_env{
- var $argv;
- var $etat;
- var $login;
- var $password;
- var $params;
- var $INITED;
+ public $argv;
+ public $etat;
+ public $login;
+ public $password;
+ public $params;
+ public $INITED;
- function run_cli($argv){
+ public function run_cli($argv){
if(PHP_SAPI != "cli"){
$this->INITED = false;
return "php cli uniquement";
return true;
}
- function inited(){
+ public function inited(){
return isset($this->INITED) && $this->INITED;
}
- function parse_cli_arguments(){
+ public function parse_cli_arguments(){
if(!$this->inited()) return "cli not inited";
$FIRST = false;
$SECOND = false;
return true;
}
- function init_cli_user(){
+ public function init_cli_user(){
if(!$this->inited()) return "cli not inited";
$data = $this->data();
if($this->login){
return true;
}
- function cmd_prompt($prompt, $SILENT = false){
+ public function cmd_prompt($prompt, $SILENT = false){
if(preg_match('/^win/i', PHP_OS)){
$vbscript = sys_get_temp_dir().'prompt_password.vbs';
file_put_contents(
}
}
-
-?>
\ No newline at end of file
class mw_env_config extends mw_env{
- var $xml_parser;
- var $config_file;
- var $PATHES;
- var $PARAMS;
- var $CONFIG;
- var $bdd;
- var $actions;
-
- function load_config($bdd, $CONFIG){
+ public $xml_parser;
+ public $config_file;
+ public $PATHES;
+ public $PARAMS;
+ public $CONFIG;
+ public $bdd;
+ public $actions;
+
+ public function load_config($bdd, $CONFIG){
if(true){
$this->bdd = $bdd;
$this->bdd["table_prefix"] = array();
else $this->erreur("impossible de trouver le fichier de configuration pour l'installation", true);
}
- function _load_config($app_config_file, $bdd){
+ public function _load_config($app_config_file, $bdd){
$this->xml_parser->parse(file_get_contents($app_config_file));
$app_config = $this->xml_parser->data["config"][0];
if(isset($app_config["subs"]["params"])){
}
}
- function get_config_file(){
+ public function get_config_file(){
return $this->config_file;
}
- function set_config_file($config_file){
+ public function set_config_file($config_file){
$this->config_file = $config_file;
}
- function get_PATHES(){
+ public function get_PATHES(){
return $this->PATHES;
}
- function path($name){
+ public function path($name){
return isset($this->PATHES[$name]) ? $this->PATHES[$name] : "";
}
- function set_PATHES($PATHES){
+ public function set_PATHES($PATHES){
foreach($PATHES as $path_name => $path_value){
if($path_value && substr($path_value, -1) != "/") $PATHES[$path_name] .= "/";
}
$this->PATHES = $PATHES;
}
- function get_PARAMS(){
+ public function get_PARAMS(){
return $this->PARAMS;
}
- function param($name){
+ public function param($name){
return isset($this->PARAMS[$name]) ? $this->PARAMS[$name] : "";
}
- function get_CONFIG(){
+ public function get_CONFIG(){
return $this->CONFIG;
}
- function config($name){
+ public function config($name){
return isset($this->CONFIG[$name]) ? $this->CONFIG[$name] : null;
}
- function set_config($config){
+ public function set_config($config){
if(is_array($config)){
foreach($config as $key => $value) $this->CONFIG[$key] = $value;
return true;
return false;
}
- function get_bdd(){
+ public function get_bdd(){
return $this->bdd;
}
- function bdd($name){
+ public function bdd($name){
return isset($this->bdd[$name]) ? $this->bdd[$name] : null;
}
- function set_bdd($key, $value){
+ public function set_bdd($key, $value){
$this->bdd[$key] = $value;
}
- function bdd_ready(){
+ public function bdd_ready(){
if(!$this->bdd("sgbd")) return "aucun sgbd defini";
$data = $this->data();
if(!$data) return "objet data non defini";
return true;
}
- function add_table_prefix($table_prefix){
+ public function add_table_prefix($table_prefix){
if(is_array($table_prefix)){
foreach($table_prefix as $prefix_code => $prefix) $this->bdd["table_prefix"][$prefix_code] = $prefix;
return true;
return false;
}
- function get_actions(){
+ public function get_actions(){
return isset($this->actions) ? $this->actions : array();
}
}
-
-?>
\ No newline at end of file
class mw_env_data extends mw_env{
- var $data;
+ public $data;
- function set_data(&$data){
+ public function set_data(&$data){
$this->data = &$data;
}
- function data(){
+ public function data(){
return isset($this->data) ? $this->data : false;
}
class mw_data extends empty_class{
- function call_default($inst, $method_name, $arguments){
+ public function call_default($inst, $method_name, $arguments){
return $this->call_data_auto_crud($method_name, $arguments);
}
class mw_sgbd{
- var $sgbd_impl;
- var $env;
+ public $sgbd_impl;
+ public $env;
- function mw_sgbd($sgbd_impl, $env){
+ public function __construct($sgbd_impl, $env){
$this->sgbd_impl = $sgbd_impl;
$this->env = $env;
}
- function extention_ok(){
+ public function extention_ok(){
return $this->sgbd_impl->extention_ok($this->env);
}
- function authentication_required(){
+ public function authentication_required(){
return $this->sgbd_impl->authentication_required();
}
- function connect($host, $base, $user, $password){
+ public function connect($host, $base, $user, $password){
return $this->sgbd_impl->connect($host, $base, $user, $password);
}
- function select_db($db_name){
+ public function select_db($db_name){
return $this->sgbd_impl->select_db($db_name);
}
# SQL
#
- function desc_table($table_name){
+ public function desc_table($table_name){
if(!method_exists($this->sgbd_impl, "desc_table")) return false;
return $this->sgbd_impl->desc_table(
($prefix_codes = array_keys($this->env->bdd("table_prefix"))) ?
);
}
- function table_exists($table_name){
+ public function table_exists($table_name){
if(!method_exists($this->sgbd_impl, "table_exists")) return false;
return $this->sgbd_impl->table_exists(
($prefix_codes = array_keys($this->env->bdd("table_prefix"))) ?
);
}
- function field_exists($table_name, $field_name){
+ public function field_exists($table_name, $field_name){
if(!method_exists($this->sgbd_impl, "field_exists")) return false;
return $this->sgbd_impl->field_exists(
(
);
}
- function query($sql){
+ public function query($sql){
if(!method_exists($this->sgbd_impl, "query")) return false;
return $this->sgbd_impl->query(
($prefix_codes = array_keys($this->env->bdd("table_prefix"))) ?
);
}
- function insert_id(){
+ public function insert_id(){
if(!method_exists($this->sgbd_impl, "insert_id")) return false;
return $this->sgbd_impl->insert_id();
}
- function fetch_assoc($rst){
+ public function fetch_assoc($rst){
if(!method_exists($this->sgbd_impl, "fetch_assoc")) return false;
return $this->sgbd_impl->fetch_assoc($rst);
}
- function free_result($rst){
+ public function free_result($rst){
if(!method_exists($this->sgbd_impl, "")) return false;
return $this->sgbd_impl->free_result($rst);
}
- function close(){
+ public function close(){
if(!method_exists($this->sgbd_impl, "")) return false;
return $this->sgbd_impl->close();
}
# XML
#
- function data_exists($data_path){
+ public function data_exists($data_path){
if(!method_exists($this->sgbd_impl, "data_exists")) return false;
return $this->sgbd_impl->data_exists($data_path);
}
- function create_data($data_path){
+ public function create_data($data_path){
if(!method_exists($this->sgbd_impl, "create_data")) return false;
return $this->sgbd_impl->create_data($data_path);
}
- function get_data($data_path, $data_id){
+ public function get_data($data_path, $data_id){
if(!method_exists($this->sgbd_impl, "get_data")) return false;
return $this->sgbd_impl->get_data($data_path, $data_id);
}
- function open_data($data_path, $FETCH = true){
+ public function open_data($data_path, $FETCH = true){
if(!method_exists($this->sgbd_impl, "open_data")) return false;
return $this->sgbd_impl->open_data($data_path, $FETCH);
}
- function fetch_data($dh){
+ public function fetch_data($dh){
if(!method_exists($this->sgbd_impl, "fetch_data")) return false;
return $this->sgbd_impl->fetch_data($dh);
}
- function add_data($data_path, $data, $index = null){
+ public 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, $index);
}
- function last_index($dh){
+ public function last_index($dh){
if(!method_exists($this->sgbd_impl, "last_index")) return false;
return $this->sgbd_impl->last_index($dh);
}
- function set_data($data_path, $data_id, $data){
+ public function set_data($data_path, $data_id, $data){
if(!method_exists($this->sgbd_impl, "set_data")) return false;
return $this->sgbd_impl->set_data($data_path, $data_id, $data);
}
- function del_data($data_path, $data_id){
+ public function del_data($data_path, $data_id){
if(!method_exists($this->sgbd_impl, "del_data")) return false;
return $this->sgbd_impl->del_data($data_path, $data_id);
}
- function close_data($dh){
+ public function close_data($dh){
if(!method_exists($this->sgbd_impl, "close_data")) return false;
return $this->sgbd_impl->close_data($dh);
}
- function remove_data($data_path){
+ public function remove_data($data_path){
if(!method_exists($this->sgbd_impl, "remove_data")) return false;
return $this->sgbd_impl->remove_data($data_path);
}
}
-
-?>
\ No newline at end of file
class mw_env_data_upgrade extends mw_env{
- var $data_upgrades;
- var $UPGRADE_REQUIRED;
+ public $data_upgrades;
+ public $UPGRADE_REQUIRED;
- function data_upgrades(){
+ public function data_upgrades(){
return $this->data_upgrades;
}
- function init_data_upgrades(){
+ public function init_data_upgrades(){
$impl_dir = ($this->bdd("sgbd") == "xml" ? "xml" : "sql")."/";
$versions_dir = $this->path("mw_dir")."app/data/upgrades/".$impl_dir;
if(is_dir($versions_dir)){
return true;
}
- function data_upgrade_required($RELOAD = false){
+ public function data_upgrade_required($RELOAD = false){
if(!isset($this->data_upgrades)){
if(($res = $this->init_data_upgrades()) !== true){
return $res;
return $this->UPGRADE_REQUIRED;
}
- function do_data_upgrade(){
+ public function do_data_upgrade(){
if(!isset($this->data_upgrades)) return false;
foreach($this->data_upgrades as $data_upgrade){
if($data_upgrade->upgrade_required() && ($res = $data_upgrade->do_upgrade()) !== true){
}
+ // -------------------------------------------------------------------------------------------
+ // class mw_data_upgrade
+ //
+
class mw_data_upgrade{
- var $application_name;
- var $versions;
- var $env;
+ public $application_name;
+ public $versions;
+ public $env;
- function mw_data_upgrade($env, $application_name){
+ public function __construct($env, $application_name){
$this->env = $env;
$this->application_name = $application_name;
}
- function env(){
+ public function env(){
return isset($this->env) ? $this->env : false;
}
- function load_versions($versions_dir){
+ public function load_versions($versions_dir){
if($dh = opendir($versions_dir)){
$versions_dir .= $versions_dir && substr($versions_dir, -1) != "/" ? "/" : "";
while(($file = readdir($dh)) !== false){
return true;
}
- function load_version($versions_dir, $version_file){
+ public function load_version($versions_dir, $version_file){
if(
!$version_file
|| !file_exists($versions_dir.$version_file)
return $this->add_version($version);
}
- function add_version($version){
+ public function add_version($version){
if(!$version->version()) return false;
if(!isset($this->versions)) $this->versions = array();
$tmp = array();
return true;
}
- function upgrade_required(){
+ public function upgrade_required(){
if(!isset($this->versions)) return false;
foreach($this->versions as $version){
if($version->upgrade_required()) return true;
return false;
}
- function do_upgrade(){
+ public function do_upgrade(){
if(!isset($this->versions)) return true;
foreach($this->versions as $version){
if($version->upgrade_required() && ($res = $version->do_upgrade()) !== true){
}
- class mw_data_version{
+ // -------------------------------------------------------------------------------------------
+ // class mw_data_version
+ //
- var $env;
- var $application_name;
+ abstract class mw_data_version{
- function version(){
- return false;
+ public $env;
+ public $application_name;
+
+ public function __construct($env, $application_name){
+ $this->env = $env;
+ $this->application_name = $application_name;
}
- function application_name(){
- return $this->application_name;
+ public function version(){
+ return false;
}
- function mw_data_version($env, $application_name){
- $this->env = $env;
- $this->application_name = $application_name;
+ public function application_name(){
+ return $this->application_name;
}
- function env(){
+ public function env(){
return isset($this->env) ? $this->env : false;
}
- function upgrade_required(){
+ public function upgrade_required(){
if(!isset($this->application_name)) return false;
if(!$this->version()) return false;
$env = $this->env();
return version_compare($data_version, $this->version()) < 0;
}
- function do_upgrade(){
+ public function do_upgrade(){
return true;
}
- function set_data_version(){
+ public function set_data_version(){
if(!isset($this->application_name)) return false;
if(!$this->version()) return false;
$env = $this->env();
class mw_env_helpers extends mw_env{
- var $helpers;
+ public $helpers;
- function init_helpers(){
+ public function init_helpers(){
$this->helpers = false;
$helpers_files = array();
if(($plugins = $this->plugins()) !== false){
return true;
}
- function helper($helper_name){
+ public function helper($helper_name){
if(!isset($this->helpers)) $this->init_helpers();
if($this->helpers === false || !isset($this->helpers[$helper_name])) return false;
if(!isset($this->helpers[$helper_name]["file"])) return false;
return false;
}
- function init_helper($helper_name){
+ public function init_helper($helper_name){
if(!isset($this->helpers[$helper_name]["impl"])){
if(!class_exists($helper_name)){
if(
}
- class mw_helper{
+ // -------------------------------------------------------------------------------------------
+ // class mw_helper
+ //
- var $env;
+ abstract class mw_helper{
- function set_env(&$env){
+ public $env;
+
+ public function set_env(&$env){
$this->env = &$env;
}
- function env(){
+ public function env(){
return $this->env;
}
}
-
-?>
\ No newline at end of file
class mw_env_init extends mw_env{
- function init(){
+ public function init(){
$init_files = array();
if(($plugins = $this->plugins()) !== false){
foreach($plugins as $plugin_name => $plugin){
}
}
-
-?>
\ No newline at end of file
class mw_env_links extends mw_env{
- function init_links(){
+ public function init_links(){
$data = $this->data();
return $data->init_links();
}
- function get_link($path = null){
+ public function get_link($path = null){
$data = $this->data();
return $data->get_link($path);
}
- function set_link($path, $url, $intitule = "", $position = 0){
+ public function set_link($path, $url, $intitule = "", $position = 0){
$data = $this->data();
return $data->set_link($path, $url, $intitule, $position);
}
}
-
-?>
\ No newline at end of file
class mw_env_messages extends mw_env{
- function erreur($message, $EXIT = false){
+ public function erreur($message, $EXIT = false){
if($EXIT === true){
echo "[erreur] ".$message;
exit();
}
}
- function erreurs(){\r
+ public function erreurs(){\r
$erreurs = $this->out("erreur");\r
if(isset($erreurs)) return $erreurs;\r
return array();\r
}
- function message($message){
+ public function message($message){
$messages = $this->out("messages");
if(!isset($messages)) $messages = array();
$messages[] = $message;
$this->set_out("messages", $messages);
}
- function messages(){
+ public function messages(){
$messages = $this->out("messages");
if(isset($messages)) return $messages;
return array();
}
}
-
-?>
\ No newline at end of file
class mw_env_models extends mw_env{
- function get_model($model_name, $default_values = array(), $RETURN_INSERT_ID = false){
+ public function get_model($model_name, $default_values = array(), $RETURN_INSERT_ID = false){
$model_class_name = "mw_model_".$model_name;
if(!class_exists($model_class_name)){
if($this->app_file_exists("data/models/".$model_name.".php")){
}
+ // -------------------------------------------------------------------------------------------
+ // class mw_model
+ //
+
class mw_model{
- var $env;
- var $model_name;
- var $attributs;
+ public $env;
+ public $model_name;
+ public $attributs;
+ public $RETURN_INSERT_ID;
- var $RETURN_INSERT_ID;
+ public function __construct(&$env, $model_name, $default_values = array(), $RETURN_INSERT_ID = false){
+ $this->env = &$env;
+ $this->model_name = $model_name;
+ $this->attributs = array();
+ $this->RETURN_INSERT_ID = $RETURN_INSERT_ID;
+ foreach($default_values as $attribut_name => $attribut_value){
+ $set_function = "set_".$attribut_name;
+ $this->$set_function($attribut_value);
+ }
+ }
- function env(){
+ public function env(){
return $this->env;
}
- function get_values(){
+ public function get_values(){
$values = array();
foreach($this->attributs as $attribut_name => $attribut){
$values[$attribut_name] = isset($attribut["value"]) ? $attribut["value"] : null;
return $values;
}
- function mw_model(&$env, $model_name, $default_values = array(), $RETURN_INSERT_ID = false){
- $this->env = &$env;
- $this->model_name = $model_name;
- $this->attributs = array();
- $this->RETURN_INSERT_ID = $RETURN_INSERT_ID;
- foreach($default_values as $attribut_name => $attribut_value){
- $set_function = "set_".$attribut_name;
- $this->$set_function($attribut_value);
- }
- }
-
- function load($index_name, $index_value){
+ public function load($index_name, $index_value){
if(!isset($this->model_name)) return false;
$data = $this->env->data();
if(
return true;
}
- function __call($method_name, $arguments){
- $r = false;
- if(substr($method_name, 0, 4) == "get_"){
- if(
- ($attribut_name = substr($method_name, 4))
- ){
- if(isset($this->attributs[$attribut_name]["value"])){
- $r = $this->attributs[$attribut_name]["value"];
- }
- else $r = null;
- }
- }
- elseif(substr($method_name, 0, 4) == "set_"){
- if(
- ($attribut_name = substr($method_name, 4))
- && isset($arguments[0])
- ){
- if(!isset($this->attributs[$attribut_name])) $this->attributs[$attribut_name] = array();
- $this->attributs[$attribut_name]["value"] = $arguments[0];
- $r = true;
- }
- }
- elseif(substr($method_name, 0, 6) == "valid_"){
- if(
- ($attribut_name = substr($method_name, 6))
- && isset($arguments[0])
- ){
- $r = true;
- }
- }
- return $r;
- }
-
- function insert(){
+ public function insert(){
if(!isset($this->model_name)) return false;
$data = $this->env->data();
return $data->data_insert(
);
}
- function update($index_name, $index_value = null){
+ public function update($index_name, $index_value = null){
if(!isset($this->model_name)) return false;
$data = $this->env->data();
if(!isset($index_value)){
);
}
- function delete($index_name, $index_value = null){
+ public function delete($index_name, $index_value = null){
if(!isset($this->model_name)) return false;
$data = $this->env->data();
if(!isset($index_value)){
);
}
- function valid(){
+ public function valid(){
$res = array(
"VALID" => true,
"messages" => array()
return $res;
}
- }
+ public function __call($method_name, $arguments){
+ $r = false;
+ if(substr($method_name, 0, 4) == "get_"){
+ if(
+ ($attribut_name = substr($method_name, 4))
+ ){
+ if(isset($this->attributs[$attribut_name]["value"])){
+ $r = $this->attributs[$attribut_name]["value"];
+ }
+ else $r = null;
+ }
+ }
+ elseif(substr($method_name, 0, 4) == "set_"){
+ if(
+ ($attribut_name = substr($method_name, 4))
+ && isset($arguments[0])
+ ){
+ if(!isset($this->attributs[$attribut_name])) $this->attributs[$attribut_name] = array();
+ $this->attributs[$attribut_name]["value"] = $arguments[0];
+ $r = true;
+ }
+ }
+ elseif(substr($method_name, 0, 6) == "valid_"){
+ if(
+ ($attribut_name = substr($method_name, 6))
+ && isset($arguments[0])
+ ){
+ $r = true;
+ }
+ }
+ return $r;
+ }
-?>
\ No newline at end of file
+ }
class mw_env_observers extends mw_env{
- var $observers;
+ public $observers;
- function init_observers(){
+ public function init_observers(){
$observers_files = array();
if(($plugins = $this->plugins()) !== false){
foreach($plugins as $plugin_name => $plugin){
return $observers;
}
- function call_observers($observer_call, $params = array()){
+ public function call_observers($observer_call, $params = array()){
if(!isset($this->observers)){
$this->observers = $this->init_observers();
}
}
- class mw_observer{
+ // -------------------------------------------------------------------------------------------
+ // class mw_observer
+ //
- var $env;
+ abstract class mw_observer{
- function set_env(&$env){
+ public $env;
+
+ public function set_env(&$env){
$this->env = &$env;
}
- function env(){
+ public function env(){
return $this->env;
}
}
-
-?>
\ No newline at end of file
class mw_env_out extends mw_env{
- var $out;
- var $out_config;
- var $layout;
-
- var $js_files;
- var $css_files;
-
- var $template;
+ public $out;
+ public $out_config;
+ public $layout;
+ public $js_files;
+ public $css_files;
+ public $template;
// ---------------------------------------------------------------------------------
// out vars
//
- function set_out($key, $value){
+ public function set_out($key, $value){
$this->out[$key] = $value;
return $value;
}
- function get_out(){
+ public function get_out(){
return $this->out;
}
- function out($key){
+ public function out($key){
return isset($this->out[$key]) ? $this->out[$key] : null;
}
// templates
//
- function templates(){
+ public function templates(){
if(($out_pathes = $this->out_pathes()) === false) return false;
$templates = array();
$current_out_path = $this->config("out");
return $templates;
}
- function get_template(){
+ public function get_template(){
if(isset($this->template)) return $this->template;
$this->template = $this->_get_template();
return $this->template;
}
- function _get_template(){
+ public function _get_template(){
$template_class_name = "mw_template";
if($this->out_file_exists("template.php")){
$template_class_file = $this->out_file("template.php");
return $template;
}
- function out_pathes(){
+ public function out_pathes(){
$pathes = array();
if(($plugins = $this->plugins()) !== false){
foreach($plugins as $plugin_name => $plugin){
return $pathes;
}
- function _out_pathes($out_dir, $pathes = array()){
+ public function _out_pathes($out_dir, $pathes = array()){
if($dh = opendir($out_dir)){
while(($file = readdir($dh)) !== false){
if(is_dir($out_dir.$file) && substr($file, 0 ,1) != "." && !in_array($file, $pathes)) $pathes[] = $file;
// out files
//
- function out_file_exists($file, $PRIORITE = "DESC"){
+ public function out_file_exists($file, $PRIORITE = "DESC"){
$out_file = $this->_out_file($file, $PRIORITE);
return $out_file ? true : false;
}
- function out_file($file, $PRIORITE = "DESC"){
+ public function out_file($file, $PRIORITE = "DESC"){
$out_file = $this->_out_file($file, $PRIORITE);
return $out_file ? $this->path("mw_dir").$out_file : $file;
}
- function out_url($file, $PRIORITE = "DESC"){
+ public function out_url($file, $PRIORITE = "DESC"){
$out_file = $this->_out_file($file, $PRIORITE);
return $out_file ? $this->path("web").$this->path("mw_path").$out_file : $file;
}
- function _out_file($file, $PRIORITE = "DESC"){
+ public function _out_file($file, $PRIORITE = "DESC"){
$out_file = false;
if($PRIORITE == "ASC"){
$tmp_out_file = "app/out/".$this->config("out")."/".$file;
// js / css files
//
- function js_files(){
+ public function js_files(){
if(!isset($this->js_files)) $this->js_files = array();
$files = array();
foreach($this->js_files as $url => $enabled){
return $files;
}
- function add_js_file($url){
+ public function add_js_file($url){
if(!isset($this->js_files)) $this->js_files = array();
$this->js_files[$url] = true;
}
- function remove_js_file($url){
+ public function remove_js_file($url){
if(isset($this->js_files) && isset($this->js_files[$url])){
unset($this->js_files[$url]);
}
}
- function css_files(){
+ public function css_files(){
if(!isset($this->css_files)) $this->css_files = array();
$files = array();
foreach($this->css_files as $url => $enabled){
return $files;
}
- function add_css_file($url){
+ public function add_css_file($url){
if(!isset($this->css_files)) $this->css_files = array();
$this->css_files[$url] = true;
}
- function remove_css_file($url){
+ public function remove_css_file($url){
if(isset($this->css_files) && isset($this->css_files[$url])){
unset($this->css_files[$url]);
}
// out config
//
- function set_out_config($out_config){
+ public function set_out_config($out_config){
$this->out_config = $out_config;
return $this->out_config;
}
- function get_out_config(){
+ public function get_out_config(){
return isset($this->out_config) ? $this->out_config : array();
}
- function out_config($name){
+ public function out_config($name){
if(isset($this->out_config)){
$CONFIG = $this->get_CONFIG();
return isset($CONFIG["out_".$name]) ? $CONFIG["out_".$name] : (isset($this->out_config[$name]) ? $this->out_config[$name]["default"] : "");
// layouts
//
- function layout(){
+ public function layout(){
return $this->layout;
}
- function init_layout(){
+ public function init_layout(){
$this->layout = array();
$this->_init_layout("index");
if(($mod = $this->etat("mod")) != "index") $this->_init_layout($mod);
return $this->get_layout();
}
- function _init_layout($mod){
+ public function _init_layout($mod){
if(($plugins = $this->plugins("ASC")) !== false){
$layout_file = false;
$tmp_layout_file = $this->path("mw_dir")."app/out/".$this->config("out")."/layouts/".$mod.".xml";
}
}
- function load_layout($layout_file){
+ public function load_layout($layout_file){
if(file_exists($layout_file)){
$xml_parser = new sxml();
$xml_parser->parse(file_get_contents($layout_file));
return false;
}
- function get_layout(){
+ public function get_layout(){
$mod = $this->etat("mod");
$controller = $this->etat("controller");
$action = $this->etat("action");
}
+ // -------------------------------------------------------------------------------------------
+ // class mw_template
+ //
+
class mw_template extends empty_class{
- var $out;
- var $ENV_SET;
- var $template_infos;
+ public $out;
+ public $ENV_SET;
+ public $template_infos;
- function set_env(&$env){
+ public function set_env(&$env){
$this->modules = array("env" => $env);
$this->ENV_SET = true;
$this->set_out_config($this->get_out_config());
$this->set_template_infos($this->get_template_infos());
}
- function render_layout($layout = null){
+ public function render_layout($layout = null){
if(!isset($this->ENV_SET) || !$this->ENV_SET) return false;
if(!isset($layout)) $layout = $this->init_layout();
$this->out = $this->get_out();
}
}
- function get_template_info($key){
+ public function get_template_info($key){
return isset($this->template_infos[$key]) ? $this->template_infos[$key] : "";
}
- function init(){
+ public function init(){
return true;
}
- function init_script(){
+ public function init_script(){
return false;
}
- function get_out_config(){
+ public function get_out_config(){
$out_config = array();
if($this->ENV_SET){
$env = $this->modules["env"];
return $out_config;
}
- function set_template_infos($template_infos){
+ public function set_template_infos($template_infos){
$this->template_infos = $template_infos;
}
- function get_template_infos(){
+ public function get_template_infos(){
return array();
}
}
-
-?>
\ No newline at end of file
class mw_env_plugins extends mw_env{
- var $plugins_asc;
- var $plugins_desc;
+ public $plugins_asc;
+ public $plugins_desc;
- function plugins($PRIORITE = "ASC"){
+ public function plugins($PRIORITE = "ASC"){
$this->init_plugins($PRIORITE);
if($PRIORITE == "ASC") return $this->plugins_asc;
if($PRIORITE == "DESC") return $this->plugins_desc;
# init
#
- function init_plugins($PRIORITE = "ASC", $RELOAD = false){
+ public function init_plugins($PRIORITE = "ASC", $RELOAD = false){
if(!$RELOAD && (isset($this->plugins_asc) || isset($this->plugins_desc))){
if($PRIORITE == "ASC"){
if(!isset($this->plugins_asc)) $this->plugins_asc = $this->ordonne_plugins($this->plugins_desc, $PRIORITE);
}
}
- function ordonne_plugins($plugins, $PRIORITE = "ASC"){
+ public function ordonne_plugins($plugins, $PRIORITE = "ASC"){
$values = array_values($plugins);
$maximum = count($values);
while($maximum > 0){
return $res;
}
- function plugin_call($impl, $method){
+ public function plugin_call($impl, $method){
if(method_exists($impl, $method)) return $impl->$method($this);
}
- function loaded_plugins(){
+ public function loaded_plugins(){
if($plugins = $this->plugins()){
foreach($plugins as $plugin_name => $plugin){
$plugin["impl"]->loaded($this);
# impl
#
- function plugin_impl($plugin_name){
+ public function plugin_impl($plugin_name){
$plugin = false;
if(file_exists($this->path("mw_dir")."plugins")){
if(substr($plugin_name, 0 ,1) !== "." && is_dir($this->path("mw_dir")."plugins/".$plugin_name)){
# data
#
- function plugins_data_dir(){
+ public function plugins_data_dir(){
return $this->path("content")."data/plugins/";
}
- function plugin_data_file($plugin_name){
+ public function plugin_data_file($plugin_name){
return $this->plugins_data_dir().$plugin_name;
}
- function plugin_data($plugin_name){
+ public function plugin_data($plugin_name){
$data_file = $this->plugin_data_file($plugin_name);
$data = array();
if(file_exists($data_file)){
return $data;
}
- function set_plugin_data($plugin_name, $data){
+ public 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);
return $OK;
}
- function del_plugin_data($plugin_name){
+ public function del_plugin_data($plugin_name){
$data_file = $this->plugin_data_file($plugin_name);
if(file_exists($data_file)) return @unlink($data_file);
return true;
}
- class mw_plugin{
+ // -------------------------------------------------------------------------------------------
+ // class mw_plugin
+ //
- function title(){
+ abstract class mw_plugin{
+
+ public function title(){
return "(sans titre)";
}
- function description(){
+ public function description(){
return "";
}
- function loaded($env){
+ public function loaded($env){
}
- function install($env){
+ public function install($env){
return true;
}
- function uninstall($env){
+ public function uninstall($env){
return true;
}
- function enable($env){
+ public function enable($env){
return true;
}
- function disable($env){
+ public function disable($env){
return true;
}
- function init($env){
+ public function init($env){
return true;
}
}
-
-?>
\ No newline at end of file
class mw_env_run extends mw_env{
- var $etat;
- var $controllers;
+ public $etat;
+ public $controllers;
- function user(){
+ public function user(){
if(!($data = $this->data())) return array();
return $data->get_session_user();
}
- function set_etat($etat, $valid_role = true){
+ public function set_etat($etat, $valid_role = true){
if(($this->etat = $this->valid_etat($etat)) !== false){
if(!$valid_role || $this->action_allowed($this->etat, false)){
return $this->etat;
return false;
}
- function valid_etat($etat){
+ public function valid_etat($etat){
$_etat = array(
"mod" => "",
"controller" => "",
return false;
}
- function etat_is_valid(){
+ public function etat_is_valid(){
return $this->valid_etat($this->etat);
}
- function action_allowed($etat, $CHECK_FORMAT = true){
+ public function action_allowed($etat, $CHECK_FORMAT = true){
if(!$this->bdd("sgbd")) return false;
$data = $this->data();
if($CHECK_FORMAT) $etat = $this->valid_etat($etat);
return $OK;
}
- function run($etat, $params = array(), $valid_role = true){
+ public function run($etat, $params = array(), $valid_role = true){
if($this->set_etat($etat, $valid_role)){
if($controller = $this->get_controller($this->etat("mod")."/".$this->etat("controller"))){
$action_method = $this->etat("action");
}
}
- function is_running($etat){
+ public function is_running($etat){
$_etat = array();
if(is_array($etat)){
if(isset($etat["mod"])){
return $IS_RUNNING;
}
- function etat($name = null){
+ public function etat($name = null){
if(!isset($name)) return $this->etat;
return $this->etat[$name];
}
- function get_controller($controller_path){
+ public function get_controller($controller_path){
if($etat = $this->valid_etat($controller_path)){
if(!isset($this->controllers)) $this->controllers = array();
if(!isset($this->controllers[$etat["mod"]])) $this->controllers[$etat["mod"]] = array();
}
- class mw_controller{
+ // -------------------------------------------------------------------------------------------
+ // class mw_controller
+ //
- var $env;
+ abstract class mw_controller{
- function set_env(&$env){
+ public $env;
+
+ public function set_env(&$env){
$this->env = &$env;
}
- function env(){
+ public function env(){
return $this->env;
}
- function validate(){
+ public function validate(){
return true;
}
- function prepare_inputs(){
+ public function prepare_inputs(){
return true;
}
}
-
-?>
\ No newline at end of file
class mw_env_urls extends mw_env{
- var $additional_get_params;
+ public $additional_get_params;
- function init_additional_get_params(){
+ public function init_additional_get_params(){
$this->additional_get_params = array();
$_params = $_SERVER["QUERY_STRING"];
$v_params = explode("&", $_params);
}
}
- function is_a_param($key){
+ public function is_a_param($key){
foreach($this->get_PARAMS() as $_key => $_value) if(strcmp($key, $_value) == 0) return true;
return false;
}
- function url($action = "", $_params = array(), $script_name = null){
+ public 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 = "";
return $this->path("web").$script_name.$get_params;
}
- function redirect($url, $message, $wait = 1){
+ public function redirect($url, $message, $wait = 1){
$this->set_etat("reponses/html/redirect_javascript", false);
$this->set_out(
"redirect",
}
}
-
-?>
\ No newline at end of file
class mw_env_versions extends mw_env{
- var $xml_parser;
- var $versions;
+ public $xml_parser;
+ public $versions;
- function version($application){
+ public function version($application){
return isset($this->versions[$application]) ? $this->versions[$application] : false;
}
- function load_versions(){
+ public function load_versions(){
$this->xml_parser = new sxml();
$app_config_file = $this->path("mw_dir")."app/config.xml";
if(file_exists($app_config_file)){
else $this->erreur("impossible de lire les fichiers de configuration pour les plugins", true);
}
- function _load_version($app_name, $app_config_file){
+ public function _load_version($app_name, $app_config_file){
$this->xml_parser->parse(file_get_contents($app_config_file));
$app_config = $this->xml_parser->data["config"][0];
if(isset($app_config["subs"]["version"][0]["data"])){
}
}
- function load_plugin_version($plugin_name){
+ public function load_plugin_version($plugin_name){
$app_config_file = $this->path("mw_dir")."plugins/".$plugin_name."/app/config.xml";
if(file_exists($app_config_file)){
$this->_load_version($plugin_name, $app_config_file);
}
}
-
-?>
\ No newline at end of file
class mw_env extends empty_class{
}
-
-?>
\ No newline at end of file
}
}
-
-?>
\ No newline at end of file
* @param string $baseuri : relative or absolute path to folder containing this file on web
* @return IMG Tag
*/
- static function generateImgTags($baseuri)
+ public static function generateImgTags($baseuri)
{
return "<a class=\"ptitcaptcha\" href=\"#\"><img alt=\"???\" title=\"?\"".
" src=\"".$baseuri."ptitcaptcha.php?pck=".$GLOBALS['ptitcaptcha_akey']."\"".
*
* @return input hidden tag
*/
- static function generateHiddenTags()
+ public static function generateHiddenTags()
{
return "<input type=\"hidden\" name=\"ptitcaptcha_key\" value=\"".$GLOBALS['ptitcaptcha_akey']."\"/>";
}
*
* @return input tag
*/
- static function generateInputTags()
+ public static function generateInputTags()
{
return "<input type=\"text\" name=\"ptitcaptcha_entry\" id=\"ptitcaptcha_entry\" value=\"\"/>";
}
*
* @return boolean (true=correct, false=incorrect)
*/
- static function checkCaptcha()
+ public static function checkCaptcha()
{
if( isset($_POST['ptitcaptcha_entry']) &&
$_POST['ptitcaptcha_entry'] == PtitCaptchaHelper::_getDisplayText($_POST['ptitcaptcha_key']))
* @param string $pck
* @return string
*/
- static function _getDisplayText($pck) // internal function
+ public static function _getDisplayText($pck) // internal function
{
$src=md5(PTITCAPTCHA_ENTROPY.$pck);
$txt="";
return $txt;
}
}
-
-
+
+
// If script called directly : generate image
if(basename($_SERVER["SCRIPT_NAME"])=="ptitcaptcha.php" && isset($_GET["pck"]))
{
imagepng($image);
imagedestroy($image);
}
-
-?>
\ No newline at end of file
}
}
-
-?>
\ No newline at end of file
class mw_app{
- var $env;
- var $path_file;
- var $pathes;
- var $config_file;
- var $config;
- var $bdd;
- var $error;
- var $DO_INSTALL;
-
- function mw_app($path_file, $DO_INSTALL = false){
+ public $env;
+ public $path_file;
+ public $pathes;
+ public $config_file;
+ public $config;
+ public $bdd;
+ public $error;
+ public $DO_INSTALL;
+
+ public function __construct($path_file, $DO_INSTALL = false){
$this->DO_INSTALL = $DO_INSTALL;
$this->path_file = $path_file;
$this->pathes = array();
$this->error = false;
}
- function set_env(&$env){
+ public function set_env(&$env){
$this->env =& $env;
}
- function env(){
+ public function env(){
return $this->env;
}
- function param($name){
+ public function param($name){
if(!isset($this->env)) return false;
return $this->env->param($name);
}
- function init(){
+ public function init(){
if(!$this->init_pathes()) return $this->get_error();
if(!$this->init_config()) return $this->get_error();
if(!$this->init_env()) return $this->get_error();
return true;
}
- function init_pathes(){
+ public function init_pathes(){
$REQUEST_URI = $_SERVER["REQUEST_URI"];
if(($n = strpos($REQUEST_URI, "?")) !== false){
$REQUEST_URI = substr($REQUEST_URI, 0, $n);
return true;
}
- function init_config(){
+ public function init_config(){
if(file_exists($config_file = $this->pathes["content"]."config/config.php")){
$this->config_file = $config_file;
require_once $this->config_file;
return true;
}
- function init_env(){
+ public function init_env(){
if(
!($sxml_class_file = (file_exists($this->pathes["mw_dir"]."libs/sxml.php") ? $this->pathes["mw_dir"]."libs/sxml.php" : ""))
|| !($empty_class_file = (file_exists($this->pathes["mw_dir"]."libs/empty_class.php") ? $this->pathes["mw_dir"]."libs/empty_class.php" : ""))
return true;
}
- function run($etat = "", $params = array(), $valid_role = true){
+ public function run($etat = "", $params = array(), $valid_role = true){
$env = $this->env();
if(!is_callable(array($env, "run"))) return false;
$env->run($etat);
return true;
}
- function run_mod($mod_name, $valid_role = true){
+ public function run_mod($mod_name, $valid_role = true){
$env = $this->env();
$etat = false;
if(isset($_GET[$env->param("e")])){
return true;
}
- function install(){
+ public function install(){
if($this->run_mod("install", false)){
$this->display();
}
}
- function upgrade(){
+ public function upgrade(){
$env = $this->env();
$data = $env->data();
$data->load_session();
}
}
- function display(){
+ public function display(){
$env = $this->env();
if($env->etat_is_valid()){
$template = $env->get_template();
}
}
- function error($content){
+ public function error($content){
$this->error = $content;
}
- function get_error(){
+ public function get_error(){
return isset($this->error) && $this->error ? $this->error : false;
}