From f17018962bfc6cc38a0b2ccc5f40a939f5fe49fa Mon Sep 17 00:00:00 2001 From: Damien Zammit Date: Tue, 10 Aug 2021 19:16:48 +1000 Subject: Use relative URLs instead of hardcoding domain --- h-source/admin/Application/Include/myFunctions.php | 12 ++++++------ h-source/admin/Library/Helper/Popup.php | 4 ++-- h-source/admin/Library/Theme.php | 4 ++-- h-source/admin/Library/Url.php | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) (limited to 'h-source/admin') diff --git a/h-source/admin/Application/Include/myFunctions.php b/h-source/admin/Application/Include/myFunctions.php index ab32bbf..355c181 100644 --- a/h-source/admin/Application/Include/myFunctions.php +++ b/h-source/admin/Application/Include/myFunctions.php @@ -166,7 +166,7 @@ function getLinkToUser($user) } else { - return "$user"; + return "$user"; } } @@ -271,7 +271,7 @@ function linkToNotebook($match) $hardware = new HardwareModel(); $clean['id_hard'] = (int)$match[2]; $name = encodeUrl($hardware->getTheModelName($clean['id_hard'])); - $href = "HTTP://".DOMAIN_NAME."/notebooks/view/".Lang::$current."/".$clean['id_hard']."/$name"; + $href = "/notebooks/view/".Lang::$current."/".$clean['id_hard']."/$name"; return (strcmp($name,'') !== 0) ? "".$name."" : $match[0]; } @@ -281,7 +281,7 @@ function linkToWifi($match) $hardware = new HardwareModel(); $clean['id_hard'] = (int)$match[2]; $name = encodeUrl($hardware->getTheModelName($clean['id_hard'])); - $href = "HTTP://".DOMAIN_NAME."/wifi/view/".Lang::$current."/".$clean['id_hard']."/$name"; + $href = "/wifi/view/".Lang::$current."/".$clean['id_hard']."/$name"; return (strcmp($name,'') !== 0) ? "".$name."" : $match[0]; } @@ -291,7 +291,7 @@ function linkToVideocard($match) $hardware = new HardwareModel(); $clean['id_hard'] = (int)$match[2]; $name = encodeUrl($hardware->getTheModelName($clean['id_hard'])); - $href = "HTTP://".DOMAIN_NAME."/videocards/view/".Lang::$current."/".$clean['id_hard']."/$name"; + $href = "/videocards/view/".Lang::$current."/".$clean['id_hard']."/$name"; return (strcmp($name,'') !== 0) ? "".$name."" : $match[0]; } @@ -309,10 +309,10 @@ function getMotivation($row,$controller) $clean['id_hard'] = (int)$row['deletion']['id_duplicate']; $hardware = new HardwareModel(); $name = encodeUrl($hardware->getTheModelName($clean['id_hard'])); - return "duplication of the model having id ".$clean['id_hard'].""; + return "duplication of the model having id ".$clean['id_hard'].""; } else { return "".$row['deletion']['object'].""; } -} \ No newline at end of file +} diff --git a/h-source/admin/Library/Helper/Popup.php b/h-source/admin/Library/Helper/Popup.php index 9ceac72..17ba908 100755 --- a/h-source/admin/Library/Helper/Popup.php +++ b/h-source/admin/Library/Helper/Popup.php @@ -78,10 +78,10 @@ class Helper_Popup extends Helper_Html { $this->viewArgs[$field] = $tempArg; } if (count($this->popupArray)>0) { - $returnString .= "\n"; + $returnString .= "\n"; } } return $returnString; } -} \ No newline at end of file +} diff --git a/h-source/admin/Library/Theme.php b/h-source/admin/Library/Theme.php index 692697e..afa3660 100755 --- a/h-source/admin/Library/Theme.php +++ b/h-source/admin/Library/Theme.php @@ -22,8 +22,8 @@ class Theme { function __construct($controller) { $this->controller = $controller; - $this->baseUrl = MOD_REWRITE_MODULE === true ? 'http://' . DOMAIN_NAME : 'http://' . DOMAIN_NAME . '/index.php'; - $this->baseUrlSrc = 'http://' . DOMAIN_NAME; + $this->baseUrl = MOD_REWRITE_MODULE === true ? '/admin' : '/admin/index.php'; + $this->baseUrlSrc = '/admin'; } diff --git a/h-source/admin/Library/Url.php b/h-source/admin/Library/Url.php index 4e2ca5e..54d6e3e 100755 --- a/h-source/admin/Library/Url.php +++ b/h-source/admin/Library/Url.php @@ -9,7 +9,7 @@ class Url { //get the url starting from the root folder public static function getRoot($pathFromRootFolder = null) { - $url = MOD_REWRITE_MODULE === true ? 'http://' . DOMAIN_NAME . '/' . $pathFromRootFolder : 'http://' . DOMAIN_NAME . '/index.php/' . $pathFromRootFolder; + $url = MOD_REWRITE_MODULE === true ? '/admin/' . $pathFromRootFolder : '/admin/index.php/' . $pathFromRootFolder; return $url; } -- cgit v1.2.3 From 7b2c76f23be47a8753cfe6d197843a82c6ebf26d Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Thu, 26 Aug 2021 11:24:58 +1000 Subject: Moving docker files to its own directory. Also applied the docker patch and removed some commented code. --- config-docker.patch | 81 ----------------------------- docker-compose.yml | 14 ----- docker/docker-compose.yml | 14 +++++ docker/readme-php5.sh | 18 +++++++ h-source/.htaccess | 15 ++---- h-source/Application/Hooks/BeforeChecks.php | 2 +- h-source/Config/Config.php | 8 +-- h-source/admin/Config/Config.php | 8 +-- readme-php5.sh | 20 ------- 9 files changed, 44 insertions(+), 136 deletions(-) delete mode 100644 config-docker.patch delete mode 100644 docker-compose.yml create mode 100644 docker/docker-compose.yml create mode 100755 docker/readme-php5.sh delete mode 100755 readme-php5.sh (limited to 'h-source/admin') diff --git a/config-docker.patch b/config-docker.patch deleted file mode 100644 index 34f8f8b..0000000 --- a/config-docker.patch +++ /dev/null @@ -1,81 +0,0 @@ -diff --git a/h-source/.htaccess b/h-source/.htaccess -index 56ccf22..61012e2 100755 ---- a/h-source/.htaccess -+++ b/h-source/.htaccess -@@ -1,7 +1,7 @@ - RewriteEngine On - --RewriteCond %{HTTPS} !^on$ --RewriteRule (.*) https://www.h-node.org/$1 [R,L] -+#RewriteCond %{HTTPS} !^on$ -+#RewriteRule (.*) https://www.h-node.org/$1 [R,L] - - # - # Options +FollowSymlinks -diff --git a/h-source/Application/Hooks/BeforeChecks.php b/h-source/Application/Hooks/BeforeChecks.php -index 6f200e6..47e7936 100755 ---- a/h-source/Application/Hooks/BeforeChecks.php -+++ b/h-source/Application/Hooks/BeforeChecks.php -@@ -13,7 +13,7 @@ if (!defined('EG')) die('Direct access not allowed!'); - - Params::$htmlentititiesCharset = "UTF-8"; - --Params::$useHttps = true; -+Params::$useHttps = false; - - Params::$allowedSanitizeFunc .= ",sanitizeString,sanitizeAlphanum"; - -diff --git a/h-source/Config/Config.php b/h-source/Config/Config.php -index bea5562..1290751 100755 ---- a/h-source/Config/Config.php -+++ b/h-source/Config/Config.php -@@ -23,10 +23,10 @@ - if (!defined('EG')) die('Direct access not allowed!'); - - --define('DB', ''); --define('USER', ''); -+define('DB', 'hnode'); -+define('USER', 'root'); - define('PWD', ''); --define('HOST', ''); -+define('HOST', 'localhost'); - - /*default controller name*/ - define('DEFAULT_CONTROLLER','home'); -@@ -35,7 +35,7 @@ define('DEFAULT_CONTROLLER','home'); - define('DEFAULT_ACTION','index'); - - /*website parameters*/ --define('DOMAIN_NAME','h-source'); -+define('DOMAIN_NAME','localhost'); - - /*type of database.*/ - //it can be: Mysql, Mysqli or None (first letter in uppercase) -diff --git a/h-source/admin/Config/Config.php b/h-source/admin/Config/Config.php -index 24d2e57..3f7866d 100755 ---- a/h-source/admin/Config/Config.php -+++ b/h-source/admin/Config/Config.php -@@ -6,10 +6,10 @@ - if (!defined('EG')) die('Direct access not allowed!'); - - --define('DB', ''); --define('USER', ''); -+define('DB', 'hnode'); -+define('USER', 'root'); - define('PWD', ''); --define('HOST', ''); -+define('HOST', 'localhost'); - - /*default controller name*/ - define('DEFAULT_CONTROLLER','adminusers'); -@@ -18,7 +18,7 @@ define('DEFAULT_CONTROLLER','adminusers'); - define('DEFAULT_ACTION','login'); - - /*website parameters*/ --define('DOMAIN_NAME','h-source/admin'); -+define('DOMAIN_NAME','localhost/admin'); - - /*type of database.*/ - //it can be: Mysql, Mysqli or None (first letter in uppercase) diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100644 index 3b70319..0000000 --- a/docker-compose.yml +++ /dev/null @@ -1,14 +0,0 @@ -# Image for LAMP based on Dockerfile in https://github.com/jakejarvis/docker-lamp-php5 -# WARNING: Not suitable for production environments, only for testing legacy php5 application. -# (Docker image supplementary files licenced under Apache 2.0) - -version: "3" -services: - lamp-php5: - image: docker.io/jakejarvis/lamp-php5:latest - ports: - - 80:80 - - 3306:3306 - volumes: - - "./h-source:/app" - - "./mysql:/var/lib/mysql" diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml new file mode 100644 index 0000000..c3f2349 --- /dev/null +++ b/docker/docker-compose.yml @@ -0,0 +1,14 @@ +# Image for LAMP based on Dockerfile in https://github.com/jakejarvis/docker-lamp-php5 +# WARNING: Not suitable for production environments, only for testing legacy php5 application. +# (Docker image supplementary files licenced under Apache 2.0) + +version: "3" +services: + lamp-php5: + image: docker.io/jakejarvis/lamp-php5:latest + ports: + - 80:80 + - 3306:3306 + volumes: + - "../h-source:/app" + - "./mysql:/var/lib/mysql" diff --git a/docker/readme-php5.sh b/docker/readme-php5.sh new file mode 100755 index 0000000..fb62a4d --- /dev/null +++ b/docker/readme-php5.sh @@ -0,0 +1,18 @@ +#!/bin/bash +# +# INSTRUCTIONS for testing with docker-lamp-php5: +# +# After the docker container spins up, +# the mysql password will be displayed. +# - MySQL on port 3306 +# - Apache on port 80 +# +# Don't forget to create the database: +# mysql -uadmin -pXXX -h127.0.0.1 +# > create database hnode; +# > ^D +# and populate the schema/initial data with: +# mysql -uadmin -pXXX -h127.0.0.1 hnode < ../h-source/tables.sql + +docker-compose up --build lamp-php5 + diff --git a/h-source/.htaccess b/h-source/.htaccess index 56ccf22..95ab62f 100755 --- a/h-source/.htaccess +++ b/h-source/.htaccess @@ -1,14 +1,5 @@ RewriteEngine On -RewriteCond %{HTTPS} !^on$ -RewriteRule (.*) https://www.h-node.org/$1 [R,L] - -# -# Options +FollowSymlinks -# RewriteEngine on - RewriteCond %{REQUEST_FILENAME} !-f - RewriteCond %{REQUEST_FILENAME} !-d - RewriteRule ^(.*)$ index.php?url=$1 [QSA,L] -# - - +RewriteCond %{REQUEST_FILENAME} !-f +RewriteCond %{REQUEST_FILENAME} !-d +RewriteRule ^(.*)$ index.php?url=$1 [QSA,L] diff --git a/h-source/Application/Hooks/BeforeChecks.php b/h-source/Application/Hooks/BeforeChecks.php index 6f200e6..47e7936 100755 --- a/h-source/Application/Hooks/BeforeChecks.php +++ b/h-source/Application/Hooks/BeforeChecks.php @@ -13,7 +13,7 @@ if (!defined('EG')) die('Direct access not allowed!'); Params::$htmlentititiesCharset = "UTF-8"; -Params::$useHttps = true; +Params::$useHttps = false; Params::$allowedSanitizeFunc .= ",sanitizeString,sanitizeAlphanum"; diff --git a/h-source/Config/Config.php b/h-source/Config/Config.php index bea5562..1290751 100755 --- a/h-source/Config/Config.php +++ b/h-source/Config/Config.php @@ -23,10 +23,10 @@ if (!defined('EG')) die('Direct access not allowed!'); -define('DB', ''); -define('USER', ''); +define('DB', 'hnode'); +define('USER', 'root'); define('PWD', ''); -define('HOST', ''); +define('HOST', 'localhost'); /*default controller name*/ define('DEFAULT_CONTROLLER','home'); @@ -35,7 +35,7 @@ define('DEFAULT_CONTROLLER','home'); define('DEFAULT_ACTION','index'); /*website parameters*/ -define('DOMAIN_NAME','h-source'); +define('DOMAIN_NAME','localhost'); /*type of database.*/ //it can be: Mysql, Mysqli or None (first letter in uppercase) diff --git a/h-source/admin/Config/Config.php b/h-source/admin/Config/Config.php index 24d2e57..3f7866d 100755 --- a/h-source/admin/Config/Config.php +++ b/h-source/admin/Config/Config.php @@ -6,10 +6,10 @@ if (!defined('EG')) die('Direct access not allowed!'); -define('DB', ''); -define('USER', ''); +define('DB', 'hnode'); +define('USER', 'root'); define('PWD', ''); -define('HOST', ''); +define('HOST', 'localhost'); /*default controller name*/ define('DEFAULT_CONTROLLER','adminusers'); @@ -18,7 +18,7 @@ define('DEFAULT_CONTROLLER','adminusers'); define('DEFAULT_ACTION','login'); /*website parameters*/ -define('DOMAIN_NAME','h-source/admin'); +define('DOMAIN_NAME','localhost/admin'); /*type of database.*/ //it can be: Mysql, Mysqli or None (first letter in uppercase) diff --git a/readme-php5.sh b/readme-php5.sh deleted file mode 100755 index 4bad3aa..0000000 --- a/readme-php5.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash -# -# INSTRUCTIONS for testing with docker-lamp-php5: -# -# After the docker container spins up, -# the mysql password will be displayed. -# - MySQL on port 3306 -# - Apache on port 80 -# -# Don't forget to create the database: -# mysql -uadmin -pXXX -h127.0.0.1 -# > create database hnode; -# > ^D -# and populate the schema/initial data with: -# mysql -uadmin -pXXX -h127.0.0.1 hnode < h-source/tables.sql - -patch -p1 < config-docker.patch - -docker-compose up --build lamp-php5 - -- cgit v1.2.3