110 lines
2.7 KiB
PHP
Executable File
110 lines
2.7 KiB
PHP
Executable File
<?php
|
|
|
|
//namespace Franzz\Spot;
|
|
|
|
/* Requests Handler */
|
|
|
|
//Start buffering
|
|
ob_start();
|
|
|
|
$oLoader = require __DIR__.'/vendor/autoload.php';
|
|
|
|
use Franzz\Objects\ToolBox;
|
|
use Franzz\Objects\Main;
|
|
use Franzz\Spot\Spot;
|
|
use Franzz\Spot\User;
|
|
|
|
ToolBox::cleanPost($_POST);
|
|
ToolBox::cleanPost($_GET);
|
|
ToolBox::cleanPost($_REQUEST);
|
|
ToolBox::fixGlobalVars(isset($argv)?$argv:array());
|
|
|
|
//Available variables
|
|
$sAction = isset($_REQUEST['a'])?$_REQUEST['a']:'';
|
|
$sTimezone = $_REQUEST['t'] ?? '';
|
|
$sName = isset($_GET['name'])?$_GET['name']:'';
|
|
$sContent = isset($_GET['content'])?$_GET['content']:'';
|
|
$iChunk = isset($_GET['chunk'])?$_GET['chunk']:0;
|
|
$iProjectId = $_REQUEST['id_project'] ?? 0;
|
|
$sField = isset($_REQUEST['field'])?$_REQUEST['field']:'';
|
|
$oValue = isset($_REQUEST['value'])?$_REQUEST['value']:'';
|
|
$iId = isset($_REQUEST['id'])?$_REQUEST['id']:0;
|
|
$sType = isset($_REQUEST['type'])?$_REQUEST['type']:'';
|
|
$sEmail = isset($_REQUEST['email'])?$_REQUEST['email']:'';
|
|
|
|
//Initiate class
|
|
$oSpot = new Spot(__FILE__, $sTimezone);
|
|
$oSpot->setProjectId($iProjectId);
|
|
|
|
$sResult = '';
|
|
if($sAction!='')
|
|
{
|
|
switch($sAction)
|
|
{
|
|
case 'markers':
|
|
$sResult = $oSpot->getMarkers();
|
|
break;
|
|
case 'feed':
|
|
$sResult = $oSpot->getNewsFeed($iChunk, $iId);
|
|
break;
|
|
case 'add_post':
|
|
$sResult = $oSpot->addPost($sName, $sContent);
|
|
break;
|
|
case 'subscribe':
|
|
$sResult = $oSpot->subscribe($sEmail);
|
|
break;
|
|
case 'unsubscribe':
|
|
$sResult = $oSpot->unsubscribe();
|
|
break;
|
|
case 'unsubscribe_email':
|
|
$sResult = $oSpot->unsubscribeFromEmail($iId);
|
|
break;
|
|
case 'update_project':
|
|
$sResult = $oSpot->updateProject();
|
|
break;
|
|
default:
|
|
if($oSpot->checkUserClearance(User::CLEARANCE_ADMIN))
|
|
{
|
|
switch($sAction)
|
|
{
|
|
case 'upload':
|
|
$sResult = $oSpot->upload();
|
|
break;
|
|
case 'add_comment':
|
|
$sResult = $oSpot->addComment($iId, $sContent);
|
|
break;
|
|
case 'admin_new':
|
|
$sResult = $oSpot->createProject();
|
|
break;
|
|
case 'admin_get':
|
|
$sResult = $oSpot->getAdminSettings();
|
|
break;
|
|
case 'admin_set':
|
|
$sResult = $oSpot->setAdminSettings($sType, $iId, $sField, $oValue);
|
|
break;
|
|
case 'admin_del':
|
|
$sResult = $oSpot->delAdminSettings($sType, $iId);
|
|
break;
|
|
case 'sync_pics':
|
|
$sResult = $oSpot->syncPics();
|
|
break;
|
|
case 'generate_cron':
|
|
$sResult = $oSpot->genCronFile();
|
|
break;
|
|
case 'sql':
|
|
$sResult = $oSpot->getDbBuildScript();
|
|
break;
|
|
default:
|
|
$sResult = Main::getJsonResult(false, Main::NOT_FOUND);
|
|
}
|
|
}
|
|
else $sResult = Main::getJsonResult(false, Main::NOT_FOUND);
|
|
}
|
|
}
|
|
else $sResult = $oSpot->getAppMainPage();
|
|
|
|
$sDebug = ob_get_clean();
|
|
if(Settings::DEBUG && $sDebug!='') $oSpot->addUncaughtError($sDebug);
|
|
|
|
echo $sResult;
|