mivita/_static/index.php
2018-10-29 09:39:31 +01:00

76 lines
No EOL
1.9 KiB
PHP

<?php
define('SERVER', 'http://'.$_SERVER['HTTP_HOST']);
function get_template(){
if($_SERVER['REQUEST_URI'] == "" || $_SERVER['REQUEST_URI'] == "/"){
return 'start';
}
if(strpos($_SERVER['REQUEST_URI'], "/") !== false){
$uri = explode("/", $_SERVER['REQUEST_URI']);
$uri = array_filter($uri);
if(count($uri) == 1){
return $uri[1];
}
//longer the 1
//product show
if( in_array('show', $uri) && $uri[2] == 'show' && in_array('produkte', $uri) && $uri[1] == 'produkte'){
return array('show' => $uri[3], 'file' => 'produkte-show');
}
//categorie
if(in_array('produkte', $uri) && $uri[1] == 'produkte'){
return array('categorie' => $uri[2], 'file' => 'produkte');
}
if( in_array('show', $uri) && $uri[2] == 'show' && in_array('produkte', $uri) && $uri[1] == 'produkte'){
return array('show' => $uri[3], 'file' => 'produkte-show');
}
//categorie
if(in_array('geschaeftsmodell', $uri) && $uri[1] == 'geschaeftsmodell'){
return array('businessmodel' => $uri[2], 'file' => $uri[2]);
}
return $uri;
}
}
function convert_to_url($name){
$name = htmlspecialchars(strip_tags(trim(strtolower($name))));
$d1 = array("ä" , "ö", "ü", "ß", "Ä", "Ö", "Ü", " ");
$d2 = array("ae" , "oe", "ue", "ss", "Ae", "Oe", "Ue", "-");
$name = str_replace($d1, $d2, $name);
return rawurlencode($name);
}
$contact = false;
$template = get_template();
if(!is_array($template)){
if($template == "kontakt"){
$contact = true;
}
$pfad = './templates/'.$template.'.php';
require($pfad);
}
if(is_array($template)){
//produkte
if(!empty($template['categorie'])){
$product_categorie = $template['categorie'];
}
if(!empty($template['show'])){
$slug = $template['show'];
}
//geschäftsmodell
if(!empty($template['businessmodel'])){
$businessmodel_categorie = $template['businessmodel'];
}
$pfad = './templates/'.$template['file'].'.php';
require($pfad);
}
?>