80 lines
2.1 KiB
PHP
Executable File
80 lines
2.1 KiB
PHP
Executable File
<?php
|
|
|
|
/*
|
|
Main Project
|
|
http://git.lutran.fr/main.git
|
|
Copyright (C) 2015 François Lutran
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program. If not, see http://www.gnu.org/licenses
|
|
*/
|
|
|
|
/* Requests Handler */
|
|
|
|
//Start buffering
|
|
ob_start();
|
|
require_once '../objects/class_management.php';
|
|
$oClassManagement = new ClassManagement('main');
|
|
ToolBox::cleanPost($_POST);
|
|
ToolBox::cleanPost($_GET);
|
|
ToolBox::cleanPost($_REQUEST);
|
|
ToolBox::fixGlobalVars(isset($argv)?$argv:array());
|
|
|
|
//Available variables
|
|
$sToken = isset($_GET['token'])?$_GET['token']:'';
|
|
$sAction = isset($_GET['a'])?$_GET['a']:'';
|
|
$sPage = isset($_GET['p'])?$_GET['p']:'index';
|
|
$sLang = isset($_GET['l'])?$_GET['l']:(isset($_COOKIE['l'])?$_COOKIE['l']:'');
|
|
//...
|
|
|
|
//Initiate class
|
|
$oMain = new Main($oClassManagement, __FILE__, $sLang);
|
|
$bLoggedIn = $oMain->isLoggedIn();
|
|
|
|
$sResult = '';
|
|
if($sAction=='logmein') $sResult = $oMain->logMeIn($sToken);
|
|
elseif($sAction!='' && $bLoggedIn)
|
|
{
|
|
switch ($sAction)
|
|
{
|
|
case '':
|
|
$sResult = $oCvTheque->function();
|
|
break;
|
|
default:
|
|
$sResult = Main::getJsonResult(false, Main::NOT_FOUND);
|
|
}
|
|
}
|
|
elseif($sAction!='' && !$bLoggedIn)
|
|
{
|
|
if($oCvTheque->checkApiKey($iApiKey))
|
|
{
|
|
switch ($sAction)
|
|
{
|
|
case '':
|
|
$sResult = $oCvTheque->apifunction();
|
|
break;
|
|
default:
|
|
$sResult = CvTheque::getJsonResult(false, Main::NOT_FOUND);
|
|
}
|
|
}
|
|
else $sResult = CvTheque::getJsonResult(false, Main::UNAUTHORIZED);
|
|
}
|
|
elseif($bLoggedIn) $sResult = $oMain->getMainPage();
|
|
else $sResult = $oMain->getLogonPage();
|
|
|
|
$sDebug = ob_get_clean();
|
|
if(Settings::DEBUG && $sDebug!='') $oMain->addUncaughtError($sDebug);
|
|
|
|
echo $sResult;
|
|
|
|
?>
|