summaryrefslogtreecommitdiff
path: root/server/index.php
diff options
context:
space:
mode:
authorEole <EoleDev@outlook.fr>2016-04-27 16:42:28 +0200
committerEole <EoleDev@outlook.fr>2016-04-27 16:42:28 +0200
commit49f416dc5061032e0514ea0cfeceaca37d13e432 (patch)
tree1202ac2a6fa860b8929afdc886c94fc50bd0a1de /server/index.php
parentc7edd70b5e5b0f5159c78ce3d924d4e7f60db816 (diff)
parentc9202d9113210981ae47df40511645da2ee140df (diff)
Merge branch 'develop' into Eole_Graph
Conflicts: client/index.html client/js/controllers/home/home.js client/partials/home/home.html
Diffstat (limited to 'server/index.php')
-rwxr-xr-xserver/index.php130
1 files changed, 80 insertions, 50 deletions
diff --git a/server/index.php b/server/index.php
index 31feb08..25c7c2e 100755
--- a/server/index.php
+++ b/server/index.php
@@ -1,60 +1,90 @@
<?php
- require "vendor/autoload.php";
- include_once("config.inc.php");
- include_once("init.php");
+/**
+* File containing the code for the API door.
+*
+* @version 1.0 Initialisation of this file
+* @since 1.0 Core application's file
+*
+* @author Eole 'eoledev at outlook . fr'
+*
+*/
+
+/*
+*/
+//loading dependencies
+require "vendor/autoload.php";
+//Include general config file
+include_once("config.inc.php");
+//Include API initialisation
+include_once("init.php");
+
+if(isset($_POST["task"]) && isset($_POST["action"])){
+ $task = $_POST["task"];
+ $action = $_POST["action"];
+}else if(isset($_POST["task"]) && $_POST["task"] == "Authenticate" || $_POST["task"] == "Deauthenticate"){
+ $task = $_POST["task"];
+}else{
+ $App->setOutput("Error", "Invalid Request!");
+ $App->show();
+ exit();
+}
+
+//Authentification and deauthentification request
+if($task == "Authenticate"){
- if(isset($_POST["task"]) && isset($_POST["action"])){
- $task = $_POST["task"];
- $action = $_POST["action"];
- }else if(isset($_POST["task"]) && $_POST["task"] == "Authenticate" || $_POST["task"] == "Deauthenticate"){
- $task = $_POST["task"];
- }else{
- //Gestion Erreur
- }
+ $App->authenticate();
+ $App->show();
- if($task == "Authenticate"){
-
- $App->authenticate();
+}else if($task == "Deauthenticate"){
+
+ $App->deauthenticate();
+ $App->show();
+
+}else if($App->checkToken()){
+ //Task switcher and task's file loader
+ switch($task)
+ {
+ case "identity":
+ include_once("core/Identity.php");
+ $identityObject = new identity($App);
+ $identityObject->action($action);
$App->show();
+ break;
- }else if($task == "Deauthenticate"){
-
- $App->deauthenticate();
+ case "network":
+ include_once("core/Network.php");
+ $networkObject = new network($App);
+ $networkObject->action($action);
$App->show();
+ break;
- }else{
- switch($task)
- {
- case "identity":
- include_once("core/Identity.php");
- $identityObject = new identity($App);
- $identityObject->action($action);
- $App->show();
- break;
-
- case "network":
- include_once("core/Network.php");
- $networkObject = new network($App);
- $networkObject->action($action);
- $App->show();
- break;
-
- case "image":
- include_once("core/Image.php");
- $imageObject = new image($App);
- $imageObject->action($action);
- $App->show();
- break;
-
- case "compute":
- include_once("core/Compute.php");
- $computeObject = new compute($App);
- $computeObject->action($action);
- $App->show();
- break;
- }
+ case "image":
+ include_once("core/Image.php");
+ $imageObject = new image($App);
+ $imageObject->action($action);
+ $App->show();
+ break;
+
+ case "compute":
+ include_once("core/Compute.php");
+ $computeObject = new compute($App);
+ $computeObject->action($action);
+ $App->show();
+ break;
+ case "networkLayer3":
+ include_once("core/NetworkLayer3.php");
+ $computeObject = new networkLayer3($App);
+ $computeObject->action($action);
+ $App->show();
+ break;
}
-
-
+}else{
+ //Request without authentication
+ $App->setOutput("Error", "Token Invalide");
+ $App->show();
+}
+
+
+