From c639822d6289aa679f48ebe38f8333df78789afc Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Sun, 3 Jan 2016 11:55:53 -0500 Subject: [PATCH 1/4] When Server is not set, us ZM_BASE_PATH --- web/includes/Server.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/web/includes/Server.php b/web/includes/Server.php index d254227ca..4ef6710db 100644 --- a/web/includes/Server.php +++ b/web/includes/Server.php @@ -34,7 +34,11 @@ class Server { } public function Url() { - return ZM_BASE_PROTOCOL . '://'. $this->Hostname(); + if ( $this->Id() ) { + return ZM_BASE_PROTOCOL . '://'. $this->Hostname(); + } else { + return ZM_BASE_PATH; + } } public function Hostname() { if ( isset( $this->{'Hostname'} ) and ( $this->{'Hostname'} != '' ) ) { From d25653089698372d265283bfed093fb950c0aebb Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Mon, 4 Jan 2016 09:36:45 -0500 Subject: [PATCH 2/4] return early if no servers are defined instead of logging a warning --- web/includes/functions.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/web/includes/functions.php b/web/includes/functions.php index e14eb369d..bc7218ad4 100644 --- a/web/includes/functions.php +++ b/web/includes/functions.php @@ -99,6 +99,10 @@ function CORSHeaders() { # The following is left for future reference/use. $valid = false; + $servers = dbFetchAll( 'SELECT * FROM Servers' ); + if ( ! sizeof($servers) ) { + return; + } foreach( dbFetchAll( 'SELECT * FROM Servers' ) as $row ) { $Server = new Server( $row ); if ( $_SERVER['HTTP_ORIGIN'] == $Server->Url() ) { From f72260733c430e0ae95d530ce2029e0d06792d26 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Mon, 4 Jan 2016 09:38:24 -0500 Subject: [PATCH 3/4] Only do CORSHeaders if there is more than 1 server --- web/includes/functions.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/web/includes/functions.php b/web/includes/functions.php index bc7218ad4..30b183385 100644 --- a/web/includes/functions.php +++ b/web/includes/functions.php @@ -100,7 +100,8 @@ function CORSHeaders() { # The following is left for future reference/use. $valid = false; $servers = dbFetchAll( 'SELECT * FROM Servers' ); - if ( ! sizeof($servers) ) { + if ( sizeof($servers) <= 1 ) { + # Only need CORSHeaders in the event that there are multiple servers in use. return; } foreach( dbFetchAll( 'SELECT * FROM Servers' ) as $row ) { From f5db14d8237c770a2f7b1d412d63a7813bd0949f Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Mon, 4 Jan 2016 13:46:05 -0500 Subject: [PATCH 4/4] return empty for the non multi-server case --- web/includes/Server.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/includes/Server.php b/web/includes/Server.php index 4ef6710db..e8402809c 100644 --- a/web/includes/Server.php +++ b/web/includes/Server.php @@ -37,7 +37,7 @@ class Server { if ( $this->Id() ) { return ZM_BASE_PROTOCOL . '://'. $this->Hostname(); } else { - return ZM_BASE_PATH; + return ''; } } public function Hostname() {