Skip to content
This repository was archived by the owner on Nov 20, 2025. It is now read-only.
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,4 @@ php_errors.log
/.idea/
/mysqlDumpToTests.bat
/public/lib/std/githubConfig.php
/node_modules/
121 changes: 63 additions & 58 deletions Setup/index.php
Original file line number Diff line number Diff line change
@@ -1,65 +1,68 @@
<?php
include_once "../TPSBIN/functions.php";
//include_once "../TPSBIN/db_connect.php";
if(file_exists("../TPSBIN/XML/DBSETTINGS.xml")
&& !key_exists("max_page", $_SESSION)){
http_response_code(403);
$refusal = "<h1>403 Forbidden</h1><p>Your request cannot proceed as the"
. " this server has already been configured.</p>";
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 = "<h1>403 Forbidden</h1><p>Your request cannot proceed as the"
. " this server has already been configured.</p>";
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);
?>
<html lang="en"><head>
<meta charset="utf-8">
Expand Down Expand Up @@ -88,7 +91,7 @@
<style id="holderjs-style" type="text/css"></style></head>

<body>
<?php include "../TPSBIN/bs_menu.php"?>
<?php include implode(DIRECTORY_SEPARATOR, array($include_base, 'TPSBIN', 'bs_menu.php'))?>

<div class="container-fluid">
<div class="row">
Expand All @@ -115,7 +118,9 @@
</div>
<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main" id="content_head">
<h1 class="page-header">Setup</h1>
<?php include_once("setup.core.php");?>
<?php
include_once implode(DIRECTORY_SEPARATOR, array($include_base, "Setup", "setup.core.php"));
?>
</div>
</div>
</div>
Expand Down
1 change: 1 addition & 0 deletions Setup/setup.auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
}*/
?>
<?php
include implode(DIRECTORY_SEPARATOR, [dirname(__FILE__), 'setup.common.php']);
if(count(get_included_files()) ==1){
http_response_code(403);
$refusal = "<h1>403 Forbidden</h1><p>The requested resource cannot"
Expand Down
33 changes: 33 additions & 0 deletions Setup/setup.common.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

/*
* The MIT License
*
* Copyright 2019 James Oliver.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
$current_directory = dirname(__FILE__);
$directory = $current_directory; # for compatibility, @TODO: fix before merge
$root_directory = dirname($current_directory);
$function_path = implode(DIRECTORY_SEPARATOR, [$root_directory, 'TPSBIN', 'functions.php']);
$xml_path = implode(
DIRECTORY_SEPARATOR,
[$root_directory, 'TPSBIN', 'XML', 'DBSETTINGS.xml']
);
1 change: 1 addition & 0 deletions Setup/setup.complete.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
}*/
?>
<?php
include implode(DIRECTORY_SEPARATOR, [dirname(__FILE__), 'setup.common.php']);
if(count(get_included_files()) == 1){
http_response_code(403);
$refusal = "<h1>403 Forbidden</h1><p>The requested resource cannot"
Expand Down
5 changes: 3 additions & 2 deletions Setup/setup.createdb.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "<h1>403 Forbidden</h1><p>Your request cannot proceed as the"
. " this server has already been configured.</p>";
Expand All @@ -21,7 +22,7 @@
$CHECKDB=false;

$return=[];
include_once "../TPSBIN/functions.php";
include_once implode(DIRECTORY_SEPARATOR, [$directory, 'TPSBIN', 'functions.php']);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missed this one

if(!isset($_SESSION)){
sec_session_start();
}
Expand Down
11 changes: 6 additions & 5 deletions Setup/setup.createxml.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php
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 = "<h1>403 Forbidden</h1><p>Your request cannot proceed as the"
. " this server has already been configured.</p>";
Expand All @@ -24,7 +25,7 @@
*/


include_once '../TPSBIN/functions.php';
include_once implode(DIRECTORY_SEPARATOR, [$directory, 'TPSBIN', 'functions.php']);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and here


$URR=$_SESSION['user'];
$PDR=$_SESSION['password'];
Expand Down Expand Up @@ -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{
Expand All @@ -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));
}

/*})
Expand Down
3 changes: 2 additions & 1 deletion Setup/setup.database.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php
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 = "<h1>403 Forbidden</h1><p>Your request cannot proceed as the"
. " this server has already been configured.</p>";
Expand Down
10 changes: 7 additions & 3 deletions Setup/setup.licence.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "<h1>403 Forbidden</h1><p>Your request cannot proceed as the"
. " this server has already been configured.</p>";
Expand Down Expand Up @@ -39,14 +40,17 @@
<p>
<?php
// get licences
$lic_xml = simplexml_load_file("lics.xml");
$lic_xml = simplexml_load_file(
implode(DIRECTORY_SEPARATOR, [$current_directory, "lics.xml"])
);
assert(!is_null($lic_xml), "XML licence files not found");
$n = 0;
foreach( $lic_xml->license as $license_file){
if($n>0){
echo "<h3>".$license_file->Segment."</h3>";
}
$file = $license_file->file;
$lic = file_get_contents($file);
$lic = file_get_contents(implode(DIRECTORY_SEPARATOR, [$current_directory, $file]));
echo nl2br($lic);
$n++;
echo "<br><hr>";
Expand Down
6 changes: 4 additions & 2 deletions Setup/setup.postinstall.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -13,7 +15,7 @@
$CHECKDB=false;

$return=[];
include_once "../TPSBIN/functions.php";
include_once $function_path;
if(!isset($_SESSION)){
sec_session_start();
}
Expand Down Expand Up @@ -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);

Expand Down
5 changes: 3 additions & 2 deletions Setup/setup.postinstall.update.php
Original file line number Diff line number Diff line change
Expand Up @@ -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){
Expand Down
3 changes: 2 additions & 1 deletion Setup/setup.review.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "<h1>403 Forbidden</h1><p>Your request cannot proceed as the"
. " this server has already been configured.</p>";
Expand Down
3 changes: 2 additions & 1 deletion Setup/setup.run.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "<h1>403 Forbidden</h1><p>Your request cannot proceed as the"
. " this server has already been configured.</p>";
Expand Down
3 changes: 2 additions & 1 deletion Setup/setup.settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "<h1>403 Forbidden</h1><p>Your request cannot proceed as the"
. " this server has already been configured.</p>";
Expand Down
3 changes: 2 additions & 1 deletion Setup/setup.start.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "<h1>403 Forbidden</h1><p>Your request cannot proceed as the"
. " this server has already been configured.</p>";
Expand Down
6 changes: 3 additions & 3 deletions Setup/setup.vars.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "<h1>403 Forbidden</h1><p>Your request cannot proceed as the"
. " this server has already been configured.</p>";
Expand Down
Loading