v2.0 first push

This commit is contained in:
2015-08-24 23:03:22 +02:00
parent fceb61029a
commit 6622928299
47 changed files with 3608 additions and 925 deletions

View File

@@ -1,5 +1,86 @@
<?php
/*
MyThoughts 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('mythoughts');
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($_REQUEST['a'])?$_REQUEST['a']:'';
$sPage = isset($_GET['p'])?$_GET['p']:'index';
$sNickName = isset($_GET['nickname'])?$_GET['nickname']:'';
$iApiKey = isset($_GET['api'])?$_GET['api']:'';
$sContent = isset($_POST['content'])?$_POST['content']:'';
$iId = isset($_REQUEST['id'])?$_REQUEST['id']:0;
//Initiate class
$oMyThoughts = new MyThoughts($oClassManagement, __FILE__);
$bLoggedIn = $oMyThoughts->isLoggedIn();
$sResult = '';
if($sAction=='logmein') $sResult = $oMyThoughts->logMeIn($sToken);
elseif($sAction!='' && $bLoggedIn)
{
switch ($sAction)
{
case 'update':
$sResult = $oMyThoughts->updateThought($sContent, $iId);
break;
default:
$sResult = MyThoughts::getJsonResult(false, MyThoughts::NOT_FOUND);
}
}
elseif($sAction!='' && !$bLoggedIn)
{
if($oMyThoughts->checkApiKey($iApiKey))
{
switch ($sAction)
{
case '':
//$sResult = $oMyThoughts->apifunction();
break;
default:
$sResult = MyThoughts::getJsonResult(false, MyThoughts::NOT_FOUND);
}
}
elseif($sAction=='register') $sResult = $oMyThoughts->register($sNickName);
else $sResult = MyThoughts::getJsonResult(false, MyThoughts::UNAUTHORIZED);
}
else $sResult = $oMyThoughts->getPage($bLoggedIn);
$sDebug = ob_get_clean();
if(Settings::DEBUG && $sDebug!='') $oMyThoughts->addUncaughtError($sDebug);
echo $sResult;
/*
//load classes
session_start();
require_once 'config.php';
@@ -9,8 +90,6 @@ cleanPost($_POST);
cleanPost($_GET);
cleanPost($_REQUEST);
/* Reserved Variables and Default Values */
//general
$sPage = (isset($_GET['p']) && $_GET['p']!='')?$_GET['p']:'w';
$sPostToken = isset($_POST['post_token'])?$_POST['post_token']:'';
@@ -106,4 +185,6 @@ else
}
}
echo $oMyThougths->getPage();
*/
?>