v1.0.0 RC 1

This commit is contained in:
2014-06-14 18:04:27 +02:00
parent 16387ca7d1
commit 8da730253d
109 changed files with 10834 additions and 8132 deletions

101
index.php
View File

@@ -1,11 +1,28 @@
<?php
/* 1st page on load */
/*
Databap Project
http://git.lutran.fr/databap.git
Copyright (C) 2014 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
*/
//load classes
ob_start();
require_once 'config.php';
$oClassManagement = new ClassManagement();
require_once 'classmanagement.php';
$oClassManagement = new ClassManagement('databap');
//Global values
ToolBox::cleanPost($_POST);
@@ -16,30 +33,30 @@ ToolBox::fixGlobalVars(isset($argv)?$argv:array());
//Global variables (reserved names) and default values
$sPage = isset($_GET['p'])?$_GET['p']:'welcome';
$sAction = isset($_GET['a'])?$_GET['a']:'';
$oCode = isset($_REQUEST['code'])?$_REQUEST['code']:false;
$oUser = isset($_REQUEST['user'])?$_REQUEST['user']:'';
$sAuthName = isset($_POST['auth_name'])?$_POST['auth_name']:'';
$sAuthCompany = isset($_POST['auth_company'])?$_POST['auth_company']:'';
$sToken = isset($_GET['auth_token'])?$_GET['auth_token']:'';
$sToken = isset($_REQUEST['auth_token'])?$_REQUEST['auth_token']:'';
$sOldToken = isset($_POST['old_auth_token'])?$_POST['old_auth_token']:'';
$sNewToken = isset($_POST['new_auth_token'])?$_POST['new_auth_token']:'';
$sContent = isset($_POST['content'])?$_POST['content']:'';
$sCategory = isset($_GET['cat'])?$_GET['cat']:'';
$sTitle = isset($_POST['title'])?$_POST['title']:'';
$sDescription = isset($_POST['description'])?$_POST['description']:'';
$sLink = isset($_REQUEST['link_escaped'])?$_REQUEST['link_escaped']:'';
$sSearchWords = isset($_GET['keywords'])?$_GET['keywords']:'';
$sKeyWords = isset($_REQUEST['keywords'])?$_REQUEST['keywords']:'';
$sMessage = isset($_POST['message'])?$_POST['message']:'';
$sChan = isset($_REQUEST['chan'])?$_REQUEST['chan']:'';
$asAttendees = isset($_REQUEST['attendees'])?$_REQUEST['attendees']:'';
$bFirstConn = isset($_GET['first_conn'])?$_GET['first_conn']:false;
$iMessageId = isset($_GET['message_id'])?$_GET['message_id']:0;
$iProcId = isset($_GET['proc_id'])?$_GET['proc_id']:0;
$iItemId = isset($_GET['id'])?$_GET['id']:0;
$oItemId = isset($_REQUEST['id'])?$_REQUEST['id']:0;
$sSystem = isset($_POST['id'])?$_POST['system']:0;
$sResult = '';
//Launching application
$oDatabap = new Databap($oClassManagement);
//Auth check
$bUserOk = $oDatabap->logMeIn($sAuthName, $sAuthCompany, $sToken, $sAction);
$bUserOk = $oDatabap->logMeIn($sToken, $sAction);
//if connected
if($bUserOk && $sAction!=Databap::EXT_ACCESS)
@@ -60,40 +77,49 @@ if($bUserOk && $sAction!=Databap::EXT_ACCESS)
$sResult = $oDatabap->addCode(array('description'=>$sDescription, 'content'=>$sContent, 'link'=>$sLink));
break;
case 'edit_code':
$sResult = $oDatabap->editCode($oCode, $sContent);
$sResult = $oDatabap->editCode($oItemId, $sContent);
break;
case 'read_code':
if($oCode!==false) $sResult = $oDatabap->getColoredCode($oCode);
if($oItemId!==false) $sResult = $oDatabap->getColoredCode($oItemId);
break;
case 'nude_code':
if($oCode!==false) $sResult = $oDatabap->getNudeCode($oCode);
if($oItemId!==false) $sResult = $oDatabap->getNudeCode($oItemId);
break;
case 'raw_code':
if($oCode!==false) $sResult = $oDatabap->getRawCode($oCode);
if($oItemId!==false) $sResult = $oDatabap->getRawCode($oItemId);
break;
case 'dl_code':
if($oCode!==false) $sResult = $oDatabap->getSavedCode($oCode);
if($oItemId!==false) $sResult = $oDatabap->getSavedCode($oItemId);
break;
case 'dl_file':
$sResult = $oDatabap->getFile($iItemId);
$sResult = $oDatabap->getFile($oItemId);
break;
case 'print_code':
if($oCode!==false) $sResult = $oDatabap->getPrintCode($oCode);
if($oItemId!==false) $sResult = $oDatabap->getRawCode($oItemId, true);
break;
case 'add_procedure':
$sResult = $oDatabap->addProcedure($_POST);
break;
case 'get_procedure':
$sResult = $oDatabap->getProcedure($iProcId);
$sResult = $oDatabap->getProcedure($oItemId);
break;
case 'add_doc':
$sResult = $oDatabap->addDoc($_POST);
break;
case 'get_doc':
$sResult = $oDatabap->getDoc($iItemId);
$sResult = $oDatabap->getDoc($oItemId);
break;
case 'add_table':
$sResult = $oDatabap->addTable($sSystem, $sTitle, $sDescription, $sKeyWords, $oItemId);
break;
case 'get_table':
$sResult = $oDatabap->getTable($oItemId);
break;
case 'get_article':
$sResult = $oDatabap->getArticle($oItemId);
break;
case 'art_redirect':
$sResult = $oDatabap->redirectArticle($iItemId);
$sResult = $oDatabap->redirectArticle($oItemId);
break;
case 'upload_image':
$sResult = $oDatabap->uploadImage();
@@ -102,16 +128,16 @@ if($bUserOk && $sAction!=Databap::EXT_ACCESS)
$sResult = $oDatabap->uploadDoc();
break;
case 'url':
$sResult = $oDatabap->checkValue(MySqlManager::URL_TABLE, array('phrase'=>$sLink));
$sResult = $oDatabap->checkValue(Databap::URL_TABLE, array('phrase'=>$sLink));
break;
case 'user_info':
$sResult = $oDatabap->getUserInfo($oDatabap->getUserId(), true);
break;
case 'profile':
$sResult = $oDatabap->getProfile($oUser);
$sResult = $oDatabap->getProfile($oItemId);
break;
case 'search':
$sResult = $oDatabap->getResults($sSearchWords);
$sResult = $oDatabap->getResults($sKeyWords);
break;
case 'code_block':
$sResult = $oDatabap->getCodeBlock();
@@ -131,6 +157,9 @@ if($bUserOk && $sAction!=Databap::EXT_ACCESS)
case 'messages':
$sResult = $oDatabap->getMessages($iMessageId);
break;
case 'news':
$sResult = $oDatabap->getNews();
break;
case 'connected_users':
$sResult = $oDatabap->getConnectedUsers(true);
break;
@@ -140,6 +169,9 @@ if($bUserOk && $sAction!=Databap::EXT_ACCESS)
case 'set_options':
$sResult = $oDatabap->setOptions($_POST, false);
break;
case 'set_pass':
$sResult = $oDatabap->checkSetPass($sOldToken, $sNewToken);
break;
case 'list':
$sResult = $oDatabap->getItemList();
break;
@@ -157,20 +189,20 @@ if($bUserOk && $sAction!=Databap::EXT_ACCESS)
$asInfo = explode('-', strtolower($oUser));
$sResult = 'User added. Id='.$oDatabap->addUser($asInfo[0], $asInfo[1], $asInfo[2]);
break;
case 'reset_token':
$sResult = print_r($oDatabap->resetToken(), true);
break;
case 'build_index':
$oDatabap->buildCompleteIndex();
$sResult = 'Index ok';
break;
case 'install_queries':
$oMySqlInstall = new MySqlManager();
case 'install_queries':
$oMySqlInstall = new MySqlManager(Settings::DB_SERVER, Settings::DB_LOGIN, Settings::DB_PASS, Settings::DB_NAME, Databap::getSqlOptions(), Settings::DB_ENC);
$sResult = $oMySqlInstall->getFullInstallQuery();
break;
case 'reset_chan_safe_names':
$sResult = $oDatabap->resetChanSafeNames();
break;
case 'init_pass': //TODO delete in v1.0.1
$sResult = $oDatabap->resetAllPass();
break;
}
}
}
@@ -201,6 +233,7 @@ elseif($bUserOk && $sAction==Databap::EXT_ACCESS)
break;
}
}
elseif($sResult=='') $sResult = 'No Clearance';
}
elseif($sAction!='')
{
@@ -210,15 +243,13 @@ elseif($sAction!='')
else
{
//$oDatabap->setExpectedPage($_SERVER['REQUEST_URI']);
$oPage = new Mask('logon');
$oPage->setTag('name', $sAuthName);
$oPage->setTag('company', $sAuthCompany);
$sResult = $oPage->getMask();
$sResult = $oDatabap->getLogonPage($sToken=='');
}
//clean unwanted error log
ob_end_clean();
//$sDebug = ob_get_clean();
//TODO unify file name with PhpObject Class
$sDebug = ob_get_clean();
if(Settings::DEBUG && $sDebug!='') file_put_contents('log.html', print_r($sDebug, true)."\n\n", FILE_APPEND);
echo $sResult;
//echo json_encode($sDebug);