VCL-1085 - Configuring VCL Website to use custom port
applied patch submitted by Junaid Ali
conf-default.php and testsetup.php: create $host variable from
$_SERVER['HTTP_HOST'] and strip off port portion if it exists;
use in place of anywhere $_SERVER['HTTP_HOST'] was used
utils.php: modified initGlobals: remove port part from
$_SERVER['HTTP_HOST'] before using to create $uniqid variable
diff --git a/web/.ht-inc/conf-default.php b/web/.ht-inc/conf-default.php
index 255991b..e64ea50 100644
--- a/web/.ht-inc/conf-default.php
+++ b/web/.ht-inc/conf-default.php
@@ -56,11 +56,15 @@
####################### end required modifications ###########################
+$host = $_SERVER['HTTP_HOST'];
+if (strpos($host, ':')) {
+ $host = substr($host, 0, strpos($host, ':'));
+}
define("BASEURL", "https://{$_SERVER['HTTP_HOST']}/vcl"); // no trailing slash - all of the URL except /index.php
define("SCRIPT", "/index.php"); // this should only be "/index.php" unless you rename index.php to something else
define("HOMEURL", "https://{$_SERVER['HTTP_HOST']}/vcl/"); // url to go to when someone clicks HOME or Logout
-define("COOKIEDOMAIN", "{$_SERVER['HTTP_HOST']}"); // domain in which cookies are set
+define("COOKIEDOMAIN", "$host"); // domain in which cookies are set
define("DEFAULTGROUP", "adminUsers"); // if a user is in no groups, use reservation
// length attriubtes from this group
diff --git a/web/.ht-inc/utils.php b/web/.ht-inc/utils.php
index 7c98834..d53bb20 100644
--- a/web/.ht-inc/utils.php
+++ b/web/.ht-inc/utils.php
@@ -125,7 +125,12 @@
$days = array(i('Sunday'), i('Monday'), i('Tuesday'), i('Wednesday'), i('Thursday'), i('Friday'), i('Saturday'));
$phpVerArr = explode('.', phpversion());
$phpVer = $phpVerArr[0];
- $uniqid = uniqid($_SERVER['HTTP_HOST'] . "-" . getmypid() . "-");
+
+ $host = $_SERVER['HTTP_HOST'];
+ if(strpos($host, ':')) {
+ $host = substr($host, 0, strpos($host, ':'));
+ }
+ $uniqid = uniqid($host . "-" . getmypid() . "-");
$passwdArray = array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K',
'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V',
diff --git a/web/testsetup.php b/web/testsetup.php
index ba3e5ae..8f384d2 100644
--- a/web/testsetup.php
+++ b/web/testsetup.php
@@ -79,14 +79,18 @@
$includesecrets = 1;
$includeconf = 1;
+$host = $_SERVER['HTTP_HOST'];
+if (strpos($host, ':')) {
+ $host = substr($host, 0, strpos($host, ':'));
+}
-if(! ip2long(getHostbyname($_SERVER['HTTP_HOST']))) {
+if(! ip2long(getHostbyname($host))) {
print $header;
# php version
print "PHP version: " . phpversion() . "<br><br>\n";
- title("Trying to resolve my hostname ({$_SERVER['HTTP_HOST']})");
+ title("Trying to resolve my hostname ($host)");
print "<ul>\n";
- fail("unable to resolve my hostname; ensure {$_SERVER['HTTP_HOST']} is in DNS or create an entry for it in /etc/hosts");
+ fail("unable to resolve my hostname; ensure $host is in DNS or create an entry for it in /etc/hosts");
print "</ul>\n";
$includesecrets = 0;
$includeconf = 0;
@@ -160,8 +164,7 @@
# conf.php tests
$createcryptkey = 0;
-if($includeconf && include('.ht-inc/conf.php')) {
- $host = $_SERVER['HTTP_HOST'];
+if($includeconf && include('.ht-inc/conf.php')) {
if(! defined('COOKIEDOMAIN')) {
print $header;
# php version