config_file = $config_file; if(file_exists($config_file)) { $config = simplexml_load_file($config_file); foreach($config->pathes[0] as $path_name => $path_value) { $this->PATHES[$path_name] = utf8_decode($path_value); } $this->PARAMS = array(); foreach($config->params[0] as $code_param => $get_param) { $this->PARAMS[$code_param] = utf8_decode($get_param); } $this->CONFIG = array(); foreach($config->config[0] as $config_param => $config_value) { $this->CONFIG[$config_param] = utf8_decode($config_value); } $this->init_base_url(); $this->acces = array(); $this->prefix = utf8_decode($config->prefix); $this->DEFAULT_ALLOW = false; } else { echo "[erreur] config : impossible de trouver le fichier de configuration pour l'installation"; exit(); } } function set_config($config) { if(is_array($config)) { foreach($config as $key => $value) $this->CONFIG[$key] = $value; return true; } return false; } function init_base_url() { $_params = $_SERVER["QUERY_STRING"]; $v_params = explode("&", $_params); $this->base_url = $_SERVER["SCRIPT_NAME"]."?"; $FIRST = true; foreach($v_params as $param) { $key = strpos($param, "=") === false ? $param : substr($param, 0, strpos($param, "=")); if(!$this->is_a_param($key)) { if(!$FIRST) $this->base_url .= "&"; else $FIRST = false; $this->base_url .= $param; } } } function is_a_param($key) { foreach($this->PARAMS as $_key => $_value) if(strcmp($key, $_value) == 0) return true; return false; } function path($name) { return $this->PATHES[$name]; } function param($name) { return $this->PARAMS[$name]; } function config($name) { return $this->CONFIG[$name]; } function url($_params) { $url = $this->base_url; foreach($_params as $key => $value) { $url .= strcmp(substr($url, -1, 1), "?") == 0 ? "" : "&"; $url .= $this->param($key)."=".$value; } return $url; } function action_ok($action) { return ( isset($this->acces["actions"][$action]) ? $this->acces["actions"][$action][$this->user["statut"]] :($this->DEFAULT_ALLOW ? true : false) ); } function interface_ok($interface) { return ( isset($this->acces["interfaces"][$interface]) ? $this->acces["interfaces"][$interface][$this->user["statut"]] :($this->DEFAULT_ALLOW ? true : false) ); } function out_file_exists($file) { return file_exists("out/".$file); } function out_file($file) { return "out/".$file; } } ?>