cyrilleinvalides/choupas/www/admin/includes/auth.php

44 lines
815 B
PHP
Executable File

<?php
// Framework initialisation
include('app/load.php');
ini_set('display_errors', 'On');
return function ( $func, $next = null ) {
try {
if ( !Auth::get(Provider::get('invalides')->Model->users->Service->array)->getUser() )
die(header(sprintf(
'Location: login.php?next=%1$s',
urlencode($next ?: $_SERVER['REQUEST_URI'])
)));
return $func();
} catch ( Exception $e ) {
$exceptions = array();
do {
$exceptions[] = array(
'type' => get_class($e),
'message' => $e->getMessage(),
'file' => $e->getFile(),
'line' => $e->getLine(),
//'stack' => $e->getTrace(),
);
} while ( $e = $e->getPrevious() );
die(EngineSystem::get('back')
->load('pages/error.html')
->run(array('exceptions' => $exceptions))
->getData(''));
}
};
?>