<?php
    header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1 
    header("Cache-Control: post-check=0, pre-check=0", false); 
    header("Cache-Control: private");
    header("Pragma: no-cache");
    header('Content-Type:text/html; Charset=UTF-8');
	
	ob_start();

	session_start();

	define("BASEURL", "/");

	require("db.php");
	include 'models/classes.php';
	$query = array();
	$parts = parse_url($_SERVER["REQUEST_URI"]);
	if(isset($parts['query'])){
		parse_str($parts['query'], $query);
		if(isset($query) && count($query)>0){
			foreach ($query as $key => $value) {
				$_REQUEST[$key] = $value;
			}
		}
	}
	$ctrl = "home"; // Page de connexion par défaut
	$defautColor = "#61b47c";
	// Par défaut on affiche le TABLEAU DE BORD
	if(isset($_REQUEST['page']) ){
		$ctrl = $_REQUEST['page'];
	}
	require_once("fonctions.php");  

	switch($ctrl){	
		case 'home':{ 
			$page_title = "Accueil";
			include("views/header.php");
			include("views/menu.php");
			include("views/home.php");
			include("views/footer.php");
			break;
		}
		case 'about':{ 
			$page_title = "Apropos";
			include("views/header.php");
			include("views/menu.php");
			include("views/about.php");
			include("views/footer.php");
			break;
		}
		case 'produit':{ 
			$page_title = "produit";
			include("views/header.php");
			include("views/menu.php");
			include("views/produit.php");
			include("views/footer.php");
			break;
		}
		case 'faq':{ 
			$page_title = "faq";
			include("views/header.php");
			include("views/menu.php");
			include("views/faq.php");
			include("views/footer.php");
			break;
		}
        case 'serviceall':{ 
			$page_title = "faq";
			include("views/header.php");
			include("views/menu.php");
			include("views/serviceall.php");
			include("views/footer.php");
			break;
		}

		case 'service':{ 
			$cible = isset($_GET['cible'])? $_GET['cible'] : "load";
			switch($cible){
				default:{
					if (is_numeric($cible)) {
						$_REQUEST['id'] = $cible;
						$page_title = "Services";
						include("views/header.php");
						include("views/menu.php");
						include("views/services.php");
						include("views/footer.php");
					}					
				break;
				}
			}
			break;
		}
		case 'propos':{ 
			$cible = isset($_GET['cible'])? $_GET['cible'] : "load";
			switch($cible){
				case 'load':
					$page_title = "Services";
					include("views/header.php");
					include("views/menu.php");
					include("views/btp.php");
					include("views/footer.php");
				break;
				default:{
					$page_title = "Services";
					include("views/header.php");
					include("views/menu.php");
					include("views/about.php");
					include("views/footer.php");
				break;
				}
			}
		break;
		}
		case 'mediatheque':{ 
			$page_title = "galerie";
			include("views/header.php");
			include("views/menu.php");
			include("views/galerie.php");
			include("views/footer.php");
			break;
		}
		case 'actu':{ 
			$cible = isset($_GET['cible'])? $_GET['cible'] : "load";
			switch($cible){
				case 'load':
					$page_title = "galerie";
					include("views/header.php");
					include("views/menu.php");
					include("views/actu.php");
					include("views/footer.php");
					break;
				default:{
					if(is_numeric($cible)){
						$page_title = "galerie";
						include("views/header.php");
						include("views/menu.php");
						include("views/detail_actu.php");
						include("views/footer.php");
					}
				break;
				}
			}
			break;
		}
		case 'contact':{ 
			$page_title = "Contact";
			include("views/header.php");
			include("views/menu.php");
			include("views/contact.php");
			include("views/footer.php");
			break;
		}

		case 'message':{ 
			Actualite::message();
			break;
		}
		case 'logout':{ 
			header("Location:se_deconnecter.php");
			break;
		}
		default:{
			header("Location: home");
			/*header('location:../views/error.php');*/
          
		}
	}
	ob_end_flush();
?>