Composer updated and 503 error added

This commit is contained in:
José Luis Garrido Labrador
2018-05-16 16:00:03 +02:00
parent aa35d5ce3b
commit 826fe3df0b
3 changed files with 37 additions and 27 deletions

View File

@@ -84,7 +84,7 @@ class Config
if(!Config::initialized())
Config::init();
$DB = Config::$config["database"];
return dbw_connect($DB["SGBD"],$DB["path"],$DB["db"],$DB["user"],$DB["password"]);
return dbw_connect($DB["SGBD"], $DB["path"], $DB["db"], $DB["user"], $DB["password"]);
}
/**

View File

@@ -20,18 +20,23 @@ $supported = ksonParse('data/supported.kson');
$loader = new Twig_Loader_Filesystem($path['html']);
$twig = new Twig_Environment($loader);
$user = array();
$db=null;
try {
$db = new DB();
}catch (Exception $ex){
sendHTTPError(503);
exit();
}
function run(){
global $user;
if(isset($_SESSION['sessionID'])){
$db = new DB();
global $db;
if($db->checkCookie($_SESSION['sessionID'],$_SESSION['token'])){
$user = $db->loadProfile($_SESSION['sessionID']);
}
}
if (isset($_POST["search"])){
//echo $_POST["search"];
//die();
firstPage(false,true);
}
else if ($_GET) {
@@ -66,6 +71,8 @@ function run(){
case "user":
user();
break;
case "error":
sendHTTPError($_GET['error']);
/*case "del":
deleteSource();*/
break;
@@ -96,6 +103,9 @@ function sendHTTPError($code){
case 404:
$text = "Page not found";
break;
case 503:
$text = "Database unavailable";
break;
case 500:
$text = "Internal server error";
break;
@@ -117,7 +127,7 @@ function sendHTTPError($code){
*/
function firstPage($filter=false,$globalSearch=false){
global $supported,$twig,$path,$user;
$db = new DB();
global $db;
if(!$filter and !$globalSearch) //Common index
if(isset($_GET["p"])) //If page (not 0)
$query = $db->loadLast($_GET["p"]);
@@ -185,7 +195,7 @@ function add(){
function codeViewer(){
global $supported,$twig,$path,$user;
$db = new DB();
global $db;
if(isset($_POST['lang'])){
$db->addSource($_GET['id'],$_POST['lang'],htmlentities($_POST['code']),$user["IDU"]);
@@ -331,7 +341,7 @@ function user(){
$passact = $_POST["passact"];
$newpass = $_POST["newpass"];
//echo "EEEEEOOO";
$db = new DB();
global $db;
if($db->checkPass($user['email'],$passact)){
$status=1;
$db->updatePass($user['IDU'],$newpass);