72 lines
1.4 KiB
PHP
Executable File
72 lines
1.4 KiB
PHP
Executable File
<?php
|
|
|
|
ini_set('display_errors', 'On');
|
|
|
|
// Framework initialisation
|
|
include('../app/load.php');
|
|
|
|
// rest
|
|
$next = !empty($_GET['next']) ? $_GET['next'] : '/admin';
|
|
$data = !empty($_POST['Auth']) ? $_POST['Auth'] : array();
|
|
$auth = Auth::get(Provider::get('banque')->Model->users->Service->array);
|
|
$user = $auth->getUser();
|
|
|
|
if ( array_key_exists('logout', $_GET) ) {
|
|
|
|
$auth->logout();
|
|
header(sprintf('Location: %1$s', '/'));
|
|
die($next);
|
|
|
|
} elseif ( $user ) {
|
|
|
|
return function ( $func ) {
|
|
|
|
try {
|
|
|
|
return $func();
|
|
|
|
} catch ( Exception $e ) {
|
|
|
|
$exceptions = array();
|
|
do {
|
|
|
|
$exceptions[] = array(
|
|
'type' => get_class($e),
|
|
'message' => $e->getMessage(),
|
|
//'stack' => $e->getTrace(),
|
|
'file' => $e->getFile(),
|
|
'line' => $e->getLine(),
|
|
);
|
|
|
|
} while ( $e = $e->getPrevious() );
|
|
|
|
die(EngineSystem::get('back')
|
|
->load('pages/error.html')
|
|
->run(array('exceptions' => $exceptions))
|
|
->getData(''));
|
|
|
|
}
|
|
|
|
};
|
|
|
|
} elseif ( $data ) {
|
|
|
|
try {
|
|
//~ print_r($auth);
|
|
$auth->login($data);
|
|
|
|
header(sprintf('Location: %1$s', $next));
|
|
die($next);
|
|
|
|
} catch ( Exception $e ) {
|
|
|
|
$data['message'] = $e->getMessage();
|
|
$a = EngineSystem::get('back')->load('pages/login.html')->run($data)->getData('');
|
|
|
|
}
|
|
|
|
} else $a = EngineSystem::get('back')->load('pages/login.html')->run()->getData('');
|
|
|
|
die($a);
|
|
|
|
?>
|