<?php
namespace be\myconcept;
use Registry;
use Exception;
ERROR_REPORTING(E_ALL);
define('DIR_ROOT',dirname(__FILE__));
$gooddomains=array('lab.myconcept.be','myconcept.be','www.myconcept.be');
if(!in_array($_SERVER['SERVER_NAME'],$gooddomains)){header('location:https://myconcept.be');exit();}
elseif(isset($_SERVER['REQUEST_SCHEME'])&&($_SERVER['REQUEST_SCHEME']!='https')){
	header('Status: 301 Moved Permanently', false, 301);    
	header('location:https://'.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']);
	exit();
}
try {
	require(DIR_ROOT.'/brain/_config.php');
	require(DIR_ROOT.'/brain/_registry.php');
	Registry::loadClass('be\myconcept\php\session');
	set_error_handler('be\myconcept\php\ErrorHandler::onPHPError');
	try {
		site\PageController::loadRegistry();
		if(!site\PageController::useCache()){
			site\PageController::defineActions();
			site\PageController::process();
		}
	}
	catch (site\PageControllerException $e){
		header(net\http\Output::HTTP_404); 
		echo '<h1>PC Exception</h1>';
		echo '<p>Visitor should need help</p>';
		php\ErrorHandler::onPHPException($e);
	}
	catch (Exception $e){
		Registry::$is_cachable=false;
		if($e->getMessage()==net\http\Output::HTTP_404){
			net\http\Output::notFound();
		}else {
			php\ErrorHandler::onPHPException($e);
		}
	}
	Registry::save();
}
catch (Exception $e){
	php\ErrorHandler::onPHPException($e);
}