diff --git a/.gitignore b/.gitignore index 229c4ce0..3e261e13 100644 --- a/.gitignore +++ b/.gitignore @@ -37,3 +37,4 @@ php_errors.log /.idea/ /mysqlDumpToTests.bat /public/lib/std/githubConfig.php +/node_modules/ \ No newline at end of file diff --git a/Setup/index.php b/Setup/index.php index c14ec877..29b0e485 100644 --- a/Setup/index.php +++ b/Setup/index.php @@ -1,65 +1,68 @@ 403 Forbidden

Your request cannot proceed as the" - . " this server has already been configured.

"; - die($refusal); - } - if(!isset($_SESSION)){ - sec_session_start(); - } - $arg1=filter_input(INPUT_GET,'q',FILTER_SANITIZE_STRING); - $max=filter_input(INPUT_GET,'e',FILTER_SANITIZE_STRING); - - $PAGES=[['wel','Welcome','?q=wel'],['lic','EULA','?q=lic'],['db','Database','?q=db'],['auth','Auth','?q=auth'],['settings','Settings','?q=settings'],['review','Review','?q=review'],['install','Install','?q=install'],['done','Complete','?q=complete']]; - $chained= TRUE; - - - if(isset($arg1)){ - $PAGE = $arg1 ?: $PAGES[0][0]; - } - else{ - $PAGE = "wel"; +if (!defined('include_base')){ + $include_base = $GLOBALS['basepath']; +} +include_once implode(DIRECTORY_SEPARATOR, array($include_base, 'TPSBIN', 'functions.php')); +//include_once "../TPSBIN/db_connect.php"; +if(file_exists(implode(DIRECTORY_SEPARATOR, array($include_base, 'TPSBIN','XML', 'DBSETTINGS.xml'))) + && !key_exists("max_page", $_SESSION)){ + http_response_code(403); + $refusal = "

403 Forbidden

Your request cannot proceed as the" + . " this server has already been configured.

"; + die($refusal); +} +if(!isset($_SESSION)){ + sec_session_start(); +} +$arg1=filter_input(INPUT_GET,'q',FILTER_SANITIZE_STRING); +$max=filter_input(INPUT_GET,'e',FILTER_SANITIZE_STRING); + +$PAGES=[['wel','Welcome','?q=wel'],['lic','EULA','?q=lic'],['db','Database','?q=db'],['auth','Auth','?q=auth'],['settings','Settings','?q=settings'],['review','Review','?q=review'],['install','Install','?q=install'],['done','Complete','?q=complete']]; +$chained= TRUE; + + +if(isset($arg1)){ + $PAGE = $arg1 ?: $PAGES[0][0]; +} +else{ + $PAGE = "wel"; +} +$enabled=[]; +if(!isset($_SESSION['max_page'])){ + $_SESSION['max_page']=0; +} + + +$chain_break=FALSE; +$i=0; +foreach ($PAGES as $entity){ + $e1=TRUE; + if($chained && $chain_break){ + $e1=FALSE; } - $enabled=[]; - if(!isset($_SESSION['max_page'])){ - $_SESSION['max_page']=0; + $enabled[$entity[0]]=$e1; + if(($entity[0]===$PAGE && !($i < $_SESSION['max_page'])) + || ($i>=$_SESSION['max_page'])){ + $chain_break=TRUE; } - + $i++; +} +unset($i); +$SETUP = TRUE; - $chain_break=FALSE; - $i=0; - foreach ($PAGES as $entity){ - $e1=TRUE; - if($chained && $chain_break){ - $e1=FALSE; - } - $enabled[$entity[0]]=$e1; - if(($entity[0]===$PAGE && !($i < $_SESSION['max_page'])) - || ($i>=$_SESSION['max_page'])){ - $chain_break=TRUE; - } - $i++; +if(isset($arg1)){ + if(isset($arg1['old'])){ + header("location: p1advins.php"); } - unset($i); - $SETUP = TRUE; - - if(isset($arg1)){ - if(isset($arg1['old'])){ - header("location: p1advins.php"); - } - else if(isset($arg1['q'])){ - $PAGE = urldecode($arg1['q']); - } + else if(isset($arg1['q'])){ + $PAGE = urldecode($arg1['q']); } - - //$enabled = ['wel'=>0,'lic'=>0,'db'=>0,'auth'=>0,'settings'=>0,'review'=>0,'done'=>0]; - - $stage=[]; - filter_input_array(INPUT_GET,$stage); +} + +//$enabled = ['wel'=>0,'lic'=>0,'db'=>0,'auth'=>0,'settings'=>0,'review'=>0,'done'=>0]; + +$stage=[]; +filter_input_array(INPUT_GET,$stage); ?> @@ -88,7 +91,7 @@ - +
@@ -115,7 +118,9 @@

Setup

- +
diff --git a/Setup/setup.auth.php b/Setup/setup.auth.php index b6515800..8ac9cf39 100644 --- a/Setup/setup.auth.php +++ b/Setup/setup.auth.php @@ -7,6 +7,7 @@ }*/ ?> 403 Forbidden

The requested resource cannot" diff --git a/Setup/setup.common.php b/Setup/setup.common.php new file mode 100644 index 00000000..5f5a8ccc --- /dev/null +++ b/Setup/setup.common.php @@ -0,0 +1,33 @@ + 403 Forbidden

The requested resource cannot" diff --git a/Setup/setup.createdb.php b/Setup/setup.createdb.php index c94302f4..f6759c15 100644 --- a/Setup/setup.createdb.php +++ b/Setup/setup.createdb.php @@ -5,7 +5,8 @@ * To change this template file, choose Tools | Templates * and open the template in the editor. */ -if(file_exists("../TPSBIN/XML/DBSETTINGS.xml")){ +include implode(DIRECTORY_SEPARATOR, [dirname(__FILE__), 'setup.common.php']); +if(file_exists($xml_path)){ http_response_code(403); $refusal = "

403 Forbidden

Your request cannot proceed as the" . " this server has already been configured.

"; @@ -21,7 +22,7 @@ $CHECKDB=false; $return=[]; -include_once "../TPSBIN/functions.php"; +include_once implode(DIRECTORY_SEPARATOR, [$directory, 'TPSBIN', 'functions.php']); if(!isset($_SESSION)){ sec_session_start(); } diff --git a/Setup/setup.createxml.php b/Setup/setup.createxml.php index d5058103..f54893fa 100644 --- a/Setup/setup.createxml.php +++ b/Setup/setup.createxml.php @@ -1,5 +1,6 @@ 403 Forbidden

Your request cannot proceed as the" . " this server has already been configured.

"; @@ -24,7 +25,7 @@ */ -include_once '../TPSBIN/functions.php'; +include_once implode(DIRECTORY_SEPARATOR, [$directory, 'TPSBIN', 'functions.php']); $URR=$_SESSION['user']; $PDR=$_SESSION['password']; @@ -71,8 +72,8 @@ } //if(function(){ -if($doc->save('../TPSBIN/XML/DBSETTINGS.xml')){ - if(chmod('../TPSBIN/XML/DBSETTINGS.xml',0600)){ +if($doc->save($xml_path)){ + if(chmod($xml_path,0600)){ print json_encode(array("status"=>"Complete"));#,"value"=>$SERV)); } else{ @@ -81,7 +82,7 @@ } else{ http_response_code(500); - print json_encode(array("status"=>"Fail"));#,"value"=>$SERV)); + print json_encode(array("status"=>"Fail","value"=>$SERV)); } /*}) diff --git a/Setup/setup.database.php b/Setup/setup.database.php index 5ad08bde..b4802b0e 100644 --- a/Setup/setup.database.php +++ b/Setup/setup.database.php @@ -1,5 +1,6 @@ 403 Forbidden

Your request cannot proceed as the" . " this server has already been configured.

"; diff --git a/Setup/setup.licence.php b/Setup/setup.licence.php index 94dd5bf1..76c1ca70 100644 --- a/Setup/setup.licence.php +++ b/Setup/setup.licence.php @@ -5,7 +5,8 @@ if(isset($_GET['m'])){ $message=urldecode($_GET['m']); }*/ -if(file_exists("../TPSBIN/XML/DBSETTINGS.xml")){ +include implode(DIRECTORY_SEPARATOR, [dirname(__FILE__), 'setup.common.php']); +if(file_exists($xml_path)){ http_response_code(403); $refusal = "

403 Forbidden

Your request cannot proceed as the" . " this server has already been configured.

"; @@ -39,14 +40,17 @@

license as $license_file){ if($n>0){ echo "

".$license_file->Segment."

"; } $file = $license_file->file; - $lic = file_get_contents($file); + $lic = file_get_contents(implode(DIRECTORY_SEPARATOR, [$current_directory, $file])); echo nl2br($lic); $n++; echo "

"; diff --git a/Setup/setup.postinstall.php b/Setup/setup.postinstall.php index 521cb742..993851f8 100644 --- a/Setup/setup.postinstall.php +++ b/Setup/setup.postinstall.php @@ -5,6 +5,8 @@ * To change this template file, choose Tools | Templates * and open the template in the editor. */ +include implode(DIRECTORY_SEPARATOR, [dirname(__FILE__), 'setup.common.php']); + error_reporting(0); if(!extension_loaded('mysqli')||!extension_loaded('PDO_MySQL')){ die(http_response_code(500)); @@ -13,7 +15,7 @@ $CHECKDB=false; $return=[]; -include_once "../TPSBIN/functions.php"; +include_once $function_path; if(!isset($_SESSION)){ sec_session_start(); } @@ -214,7 +216,7 @@ } //$mysqli->commit(); $mysqli->autocommit(TRUE); - $functions = \file_get_contents("setup.functions.sql"); + $functions = \file_get_contents($directory."setup.functions.sql"); //$functions = preg_replace("/[\\n\\r]+/", ' ' , $functions); $functions = preg_replace("/[?]+/", $callsign, $functions); diff --git a/Setup/setup.postinstall.update.php b/Setup/setup.postinstall.update.php index 047a29c2..0887936b 100644 --- a/Setup/setup.postinstall.update.php +++ b/Setup/setup.postinstall.update.php @@ -24,15 +24,16 @@ * THE SOFTWARE. */ +include implode(DIRECTORY_SEPARATOR, [dirname(__FILE__), 'setup.common.php']); //require_once '../Update/update.php'; -include_once "../TPSBIN/functions.php"; +include_once $function_path; define("HOST",$_SESSION['host']); define("PASSWORD",$_SESSION['password']); define("USER",$_SESSION['user']); define("DB",$_SESSION['database']); -$files = \glob("../Update/proc/*.json"); +$files = \glob(implode(DIRECTORY_SEPARATOR, [$directory, 'Update', 'proc', '*.json'])); $updates = array(); function installUpdate($Update_PKG){ diff --git a/Setup/setup.review.php b/Setup/setup.review.php index 360e3877..6d7dc31c 100644 --- a/Setup/setup.review.php +++ b/Setup/setup.review.php @@ -5,7 +5,8 @@ if(isset($_GET['m'])){ $message=urldecode($_GET['m']); }*/ - if(file_exists("../TPSBIN/XML/DBSETTINGS.xml")){ + include implode(DIRECTORY_SEPARATOR, [dirname(__FILE__), 'setup.common.php']); + if(file_exists($xml_path)){ http_response_code(403); $refusal = "

403 Forbidden

Your request cannot proceed as the" . " this server has already been configured.

"; diff --git a/Setup/setup.run.php b/Setup/setup.run.php index 9aacc617..5bce0c20 100644 --- a/Setup/setup.run.php +++ b/Setup/setup.run.php @@ -5,7 +5,8 @@ if(isset($_GET['m'])){ $message=urldecode($_GET['m']); }*/ - if(file_exists("../TPSBIN/XML/DBSETTINGS.xml")){ + include implode(DIRECTORY_SEPARATOR, [dirname(__FILE__), 'setup.common.php']); + if(file_exists($xml_path)){ http_response_code(403); $refusal = "

403 Forbidden

Your request cannot proceed as the" . " this server has already been configured.

"; diff --git a/Setup/setup.settings.php b/Setup/setup.settings.php index c0258d56..edd026ae 100644 --- a/Setup/setup.settings.php +++ b/Setup/setup.settings.php @@ -5,7 +5,8 @@ if(isset($_GET['m'])){ $message=urldecode($_GET['m']); }*/ - if(file_exists("../TPSBIN/XML/DBSETTINGS.xml")){ + include implode(DIRECTORY_SEPARATOR, [dirname(__FILE__), 'setup.common.php']); + if(file_exists($xml_path)){ http_response_code(403); $refusal = "

403 Forbidden

Your request cannot proceed as the" . " this server has already been configured.

"; diff --git a/Setup/setup.start.php b/Setup/setup.start.php index b94c36c3..3c57290c 100644 --- a/Setup/setup.start.php +++ b/Setup/setup.start.php @@ -5,7 +5,8 @@ if(isset($_GET['m'])){ $message=urldecode($_GET['m']); }*/ - if(file_exists("../TPSBIN/XML/DBSETTINGS.xml")){ + include implode(DIRECTORY_SEPARATOR, [dirname(__FILE__), 'setup.common.php']); + if(file_exists($xml_path)){ http_response_code(403); $refusal = "

403 Forbidden

Your request cannot proceed as the" . " this server has already been configured.

"; diff --git a/Setup/setup.vars.php b/Setup/setup.vars.php index 75097784..acb9c1c1 100644 --- a/Setup/setup.vars.php +++ b/Setup/setup.vars.php @@ -2,11 +2,11 @@ $DEBUG=FALSE; #$DEBUG = TRUE; +include implode(DIRECTORY_SEPARATOR, [dirname(__FILE__), 'setup.common.php']); +include $function_path; -include "../TPSBIN/functions.php"; if(is_session_started()===FALSE) { session_start(); } - if(file_exists("../TPSBIN/XML/DBSETTINGS.xml") - && !key_exists("max_page", $_SESSION)){ + if(file_exists($xml_path) && !key_exists("max_page", $_SESSION)){ http_response_code(403); $refusal = "

403 Forbidden

Your request cannot proceed as the" . " this server has already been configured.

"; diff --git a/TPSBIN/bs_menu.php b/TPSBIN/bs_menu.php index be5b4a62..a4d97ee1 100644 --- a/TPSBIN/bs_menu.php +++ b/TPSBIN/bs_menu.php @@ -30,7 +30,7 @@ $access=$_SESSION['access']; $opened_db=FALSE; - if(!$mysqli){ + if(!$mysqli && !$SETUP){ $opened_db=TRUE; require_once dirname(__FILE__).DIRECTORY_SEPARATOR."functions.php"; require_once dirname(__FILE__).DIRECTORY_SEPARATOR."db_connect.php"; @@ -132,7 +132,7 @@ 'Library_View'=>1,'Library_Create'=>1,'Library_Edit'=>1, 'Advert_View'=>0,'Advert_Edit'=>0,'Advert_Create'=>0, 'Audit_View'=>0]; - $base="../"; + $base=""; $opened_db=FALSE; $logo="Setup/opensource_logo.png"; } diff --git a/public/index.php b/public/index.php index ec4333d0..fc636f41 100644 --- a/public/index.php +++ b/public/index.php @@ -158,11 +158,58 @@ static public function ok($app, $data=NULL, $key="message", $code=200, $sessionName = "TPSSlimSession"; $sessionSecret = "Q7^nY{Zd'UO]Z`=L8X&`fV)Fn(LwH(vFwAm-y[z,YJD*vJj'WVYNC!+R3\cnF3I"; +$setupUrl = "/Setup/"; if(!file_exists("TPSBIN".DIRECTORY_SEPARATOR."XML". DIRECTORY_SEPARATOR."DBSETTINGS.xml")){ - header('Location: /Setup/'); - exit(); + if(filter_has_var(INPUT_SERVER, "REQUEST_URI")){ + $URI = filter_input(INPUT_SERVER, "REQUEST_URI"); + $URI_base = parse_url($URI); + $extension = pathinfo($URI, PATHINFO_EXTENSION); + if (!is_null($URI_base)){ + $uri_components = explode('/', ltrim($URI_base['path'], '/')); + } else { + $uri_components = ['']; + } + if ($URI_base['path'] != $setupUrl && !in_array($uri_components[0], ['js', 'TPSBIN']) && $extension == ''){ + //load twig + if(file_exists($autoload_path)){ + require_once($autoload_path); + } + elseif(file_exists($twig_path)&&file_exists($slim_path)){ + require_once $twig_path; + require_once $slim_path; + Twig_Autoloader::register(); + Slim\Slim::registerAutoloader(); + } + $app = new \Slim\Slim(array( + 'debug' => $debug, + 'view' => new \Slim\Views\Twig(), + )); + $app->response->redirect($setupUrl); + $app->run(); + $app->stop(); + } else if ($URI_base['path'] == $setupUrl) { + $base = '.'; + include_once 'Setup'.DIRECTORY_SEPARATOR.'index.php'; + exit(); + } else { + $base_path = dirname(dirname(__FILE__)); + $sys_path = implode(DIRECTORY_SEPARATOR, [$base_path, ltrim($URI_base['path'], '/')]); + if ($extension!='php') { + if (file_exists($sys_path)){ + echo file_get_contents($sys_path); + } + else{ + $app->response()->status(404); + $app->run(); + } + } else { + include $sys_path; + } + exit(); + } + } } require_once 'header.php';