<?php
date_default_timezone_set("Europe/Berlin");
error_reporting(E_ALL);

include_once("classen/utils.php");
include_once("classen/HTML.php");
include_once("classen/RegionManager.php");

$RUNTIME = array();

include_once("config.php");

if(isset($_REQUEST['api']))
{
	if(file_exists("./api/".$_REQUEST['api'].".php")){
		if($_REQUEST['api'] == str_replace("/"," ",$_REQUEST['api']) and $_REQUEST['api'] == str_replace("\\"," ",$_REQUEST['api']) and $_REQUEST['api'] == str_replace(".."," ",$_REQUEST['api'])){
				include "./api/".$_REQUEST['api'].".php";
		}else{
			die("ERROR; ENDPOINT NOT EXIST");
		}
	}else{
		die("ERROR; ENDPOINT NOT EXIST");
	}

	die();
}

if(!isset($_REQUEST['page']))
	$_REQUEST['page'] = 'start';

if(file_exists("./pages/".$_REQUEST['page'].".php")){
	if($_REQUEST['page'] == str_replace("/"," ",$_REQUEST['page']) and $_REQUEST['page'] == str_replace("\\"," ",$_REQUEST['page']) and $_REQUEST['page'] == str_replace(".."," ",$_REQUEST['page'])){
			include "./pages/".$_REQUEST['page'].".php";
	}else{
		include "./pages/error.php";
	}
}else{
	include "./pages/error.php";
}
?>