Added new files according to the configuration + replaced router call + index(init router, AuthSystem, Repo)

This commit is contained in:
xdrm-brackets 2017-12-10 20:38:40 +01:00
parent 9617384941
commit da3d3678eb
6 changed files with 31 additions and 71 deletions

View File

@ -1 +0,0 @@
52add802518cc5e81705e05f44abb920bc0cbf674bba0166e4c229022f4301bb

View File

@ -1,12 +1,11 @@
{
"nxtic": {
"apache": "/vhost/nxtic",
"git": "/vhost/git-repositories/nxtic"
},
"prod-releaser": {
"apache": "/vhost/prod-releaser",
"git": "/vhost/git-repositories/prod-release.php"
"ndli1718": {
"dir": "/vhost/ndli1718",
"cmd" : [
"git pull origin master",
"npm run release"
]
}
}

View File

@ -1,13 +0,0 @@
{
"local" : {
"host" : "http://prod-releaser/",
"root" : "/"
},
"remote" : {
"host" : "https://prod-releaser.xdrm.io/",
"root" : "/"
}
}

View File

@ -1,3 +0,0 @@
groupadd w-x-b;
usermod -a -G w-x-b www-data;
chgrp -R w-x-b .;

View File

@ -1,54 +1,20 @@
<?php define('__ROOT__', dirname(dirname(__FILE__)) );
require_once __ROOT__.'/al.php';
<?php require_once '../autoloader.php';
use \router\core\Router;
use \api\core\ModuleRequest;
use \api\core\ModuleResponse;
use \api\core\Authentification;
use \error\core\Error;
use \api\core\Request;
use \api\core\AuthSystemDefault;
use \database\core\Repo;
use \database\core\DatabaseDriver;
/* (1) Start session */
session_start();
/*******************************************/
/* DEBUGGER */
/*******************************************/
debug();
/*******************************************/
/* (2) Set default Driver for Repos */
Repo::setDriver(DatabaseDriver::get());
/* [1] Gestion des authentifications et des droits
=========================================================*/
/* (1) On met à jour l'authentification et les permissions */
Authentification::check();
$auth = Authentification::auth();
/* (3) Set default AuthSystem */
Request::setAuthSystem(new AuthSystemDefault);
/* (4) launch router */
Router::launch($_GET['url']);
/* [3] On initialise le routeur
===================================================*/
/* (1) New Router */
$R = new Router( $_GET['url'] );
/* [2] host.xxx/api/{module}/{method} -> api
=========================================================*/
$R->post('api(?:/(.*))?', function($url){
$request = ModuleRequest::fromPost($url, $_POST);
$answer = $request->dispatch();
// Si c'est une réponse
if( $answer instanceof ModuleResponse )
echo $answer->serialize();
});
/* [3] Any other URL -> homepage
=========================================================*/
$R->get('.+', function(){ http_response_code(417); exit(); });
$R->post('.+', function(){ http_response_code(417); exit(); });
/* [8] Launch Router
===================================================*/
$R->run();
?>

12
view/home.php Normal file
View File

@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>404</title>
</head>
<body>
</body>
</html>