page = ''; $this->root_path = $root_path; $this->root_url = ''; $this->lang = 'de'; $this->include_path = $this->root_path.'inc/'; $this->data_path = $this->root_path.'data/'.$this->lang.'/'; $this->template_path = $this->data_path.'templates/'; $this->mod_path = $this->data_path.'mods/'; $this->initUrl(); $this->template = $this->template_path.$template.'.tmpl.html'; if(file_exists($this->template)) { $this->page = join('', file($this->template)); } else { die('Template "'.$template.':'.$this->template.'" wurde nicht gefunden!'); } } function initUrl() { $tmpurl = explode('?', htmlspecialchars(urldecode($_SERVER['REQUEST_URI']))); $this->url = preg_split('/\//', $tmpurl[0], -1, PREG_SPLIT_NO_EMPTY); $this->url_options = $tmpurl[1]; if(isset($this->url[0])) { // check ob diese erlaubt ist // echo $this->url[0]; if($this->url[0] != 'error' && $this->url[2] == '') { @$this->validateUrl(strtolower($this->url[0])); } else { $this->error_id = 404103; $this->error_404(); } } else { $this->error_id = 404100; $this->url = array ( 0 => 'startseite' ); } } function validateUrl($path, $level = 0) { global $menu; foreach($menu as $item) { $valid = false; // echo ''.$this->parseUrl($item[$level]).':'.$path.''; if($this->parseUrl($item[$level]) == $path) { $level++; $valid = true; if(isset($this->url[$level+1])) { $valid = $this->validateUrl(strtolower($this->url[$level+1])); } if($valid) break; } } if(!$valid) { $this->error_id = 404101; $this->error_404(); return false; } } function deParseUrl($string) { $output = $string; $tags = array( ' ' => '_', "'" => '\|', 'fehler' => 'error' ); foreach($tags as $tag => $data) { $output = preg_replace('/'.$data.'/', $tag, $output); } $output = strtoupper($output); return $output; } function parseUrl($string) { $output = $string; $tags = array( ' ' => '_', "'" => '|', 'fehler' => 'error' ); foreach($tags as $tag => $data) { $output = preg_replace('/'.$tag.'/', $data, $output); } $output = strtolower($output); return $output; } function replace_tags($tags = array()) { if(sizeof($tags) > 0) { foreach( $tags as $tag => $data) { if(is_array($data)) { $this->page = eregi_replace('{' . $tag . '}', $this->parseModule($data['name']), $this->page); } else { $this->page = eregi_replace('{' . $tag . '}', $data, $this->page); } } } else die('Tags ungueltig!'); } function parseModule($module) { ob_start(); include($this->mod_path.$module.'.mod.php'); $buffer = ob_get_contents(); ob_end_clean(); return $buffer; } function error_404() { header("HTTP/1.0 404 Not Found"); $this->url = array ( 0 => 'error', 1 => '404'); } function error_503() { header("HTTP/1.0 503 Service Unavailable"); $this->url = array ( 0 => 'error', 1 => '404'); } function error_403() { $this->url = array ( 0 => 'error', 1 => '403'); } function output() { echo $this->page; } function redirect($path, $options = '') { header("Location: ".$this->root_url.$path.'?'.$options); exit; } // Var abfragen function getIncludePath() { return $this->include_path; } function getDataPath() { return $this->data_path; } } ?>