<?php

if (empty($_GET['page'])) {
	header('Location: index.php?page=index');
	exit(0);
}

// Inclusion des fonctions php appelées dans le site
require('php/functions.php');
require('php/connect.php');
?>

<!DOCTYPE html>
<html lang="fr">
<meta charset="UTF-8">
<head>
	<title>Chambord</title>
	<link rel="stylesheet" href="css/style.css" media="screen" title="no title">
	<link rel="stylesheet" href="css/print.css" type="text/css" media="print" />
	<link rel="stylesheet" type="text/css" href="ckeditor/contents.css" />

</head>
<body class="home">


	<div id="page"><!-- DEBUT conteneur général n2 : page -->

		<?php //include("include/header_links.php"); ?>

		<!-- DEBUT tete -->
		<header>
			<?php include("include/header.php"); ?>
			<?php //include("include/menu_main.php"); ?>
		</header>
		<!-- FIN tete -->

		<!-- DEBUT section -->
		<main>
			<?php
			session_start();
			$reqPwd = $bdd->prepare('SELECT * FROM acces WHERE id = :id');
			$reqPwd->execute(['id' => 0]);
			$dataPwd = $reqPwd->fetch();

			if (!isset($_SESSION['firstname'])) {
				if($dataPwd['acces'] == 1 ) {


					require('include/login.php');

				} else {
					if ($_GET['page'] == 'index') {
						include('include/page_index.php');
					} else if ($_GET['page'] == 'zones') {
						include('include/page_zones.php');
					} else if ($_GET['page'] == 'plan'){
						include('include/page_plan.php');
					} else if ($_GET['page'] == 'arbo'){
						include('include/page_arbo.php');
					}
				}
			}

			else {
				if ($_GET['page'] == 'index') {
					include('include/page_index.php');
				} else if ($_GET['page'] == 'zones') {
					include('include/page_zones.php');
				} else if ($_GET['page'] == 'plan'){
					include('include/page_plan.php');
				} else if ($_GET['page'] == 'arbo'){
					include('include/page_arbo.php');
				}
			}

			?>
		</main>
		<!-- FIN section -->



	</div><!-- FIN conteneur général n2 : page -->
	<!-- DEBUT pied -->
	<?php
		if (isset($_SESSION['firstname']) && $_GET['page'] == 'index') {
			print('<footer class="footer2 clearfix">');
			include("include/footer.php");
			print('</footer>');
		}
	
	?>


	<!-- FIN pied -->
	<script type="text/javascript" src="js/jquery.min.js"></script>
	<script type="text/javascript" src="js/jquery-ui-1.9.2.custom.min.js"></script>
	<script type="text/javascript" src="js/jquery.dtpicker.js"></script>
	<script type="text/javascript" src="js/ImageMaps-master/jquery.imageMaps.js"></script>
	<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.3.4/jspdf.debug.js"></script>
	<script type="text/javascript" src="js/index.js"></script>
	<script type="text/javascript" src="js/pdf.js"></script>

</body>
</html>
