auth class
This commit is contained in:
67
index.php
67
index.php
@@ -1,5 +1,24 @@
|
||||
<?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
|
||||
@@ -12,27 +31,49 @@ 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
|
||||
$oWedding = new Main($oClassManagement, $sLang);
|
||||
switch($sAction)
|
||||
{
|
||||
case 'action':
|
||||
break;
|
||||
//...
|
||||
|
||||
default:
|
||||
$sResult = $oWedding->getPage($sPage);
|
||||
break;
|
||||
}
|
||||
$oMain = new Main($oClassManagement, __FILE__, $sLang);
|
||||
$bLoggedIn = $oCvTheque->isLoggedIn();
|
||||
|
||||
$sResult = '';
|
||||
if($sAction=='logmein') $sResult = $oMain->logMeIn($sToken);
|
||||
elseif($sAction!='' && $bLoggedIn)
|
||||
{
|
||||
switch ($sAction)
|
||||
{
|
||||
case '':
|
||||
$sResult = $oCvTheque->function();
|
||||
break;
|
||||
default:
|
||||
$sResult = Main::getJsonResult(false, CvTheque::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();
|
||||
|
||||
//Log and clean buffer
|
||||
$sDebug = ob_get_clean();
|
||||
if(Settings::DEBUG && $sDebug!='') dlog($sDebug, true);
|
||||
if(Settings::DEBUG && $sDebug!='') $oMain->addUncaughtError($sDebug);
|
||||
|
||||
echo $sResult;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user