From 2706174b8da129385d816c677cd7e7686e7d78d6 Mon Sep 17 00:00:00 2001 From: Andrew McMillan Date: Sun, 29 Mar 2009 22:19:09 +1300 Subject: [PATCH] Handle it if the webserver doesn't set SERVER_NAME --- inc/always.php.in | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/inc/always.php.in b/inc/always.php.in index ffd2fded..d490dd82 100644 --- a/inc/always.php.in +++ b/inc/always.php.in @@ -16,7 +16,7 @@ unset($session); unset($request); unset($dbconn); $c->sysabbr = 'davical'; $c->admin_email = 'admin@davical.example.com'; $c->system_name = "DAViCal CalDAV Server"; -$c->domain_name = $_SERVER['SERVER_NAME']; +$c->domain_name = (isset($_SERVER['SERVER_NAME'])?$_SERVER['SERVER_NAME']:$_SERVER['SERVER_ADDR']); $c->save_time_zone_defs = true; $c->collections_always_exist = false; $c->allow_get_email_visibility = false; @@ -43,6 +43,11 @@ $c->dbg = array(); // Utilities require_once("AWLUtilities.php"); +/** We actually discovered this and worked around it earlier, but we can't log it until the utilties are loaded */ +if ( !isset($_SERVER['SERVER_NAME']) ) { + @dbg_error_log( "WARN", "Your webserver is not setting the SERVER_NAME parameter. You may need to set \$c->domain_name in your configuration. Using IP address meanhwhile..." ); +} + /** * Calculate the simplest form of reference to this page, excluding the PATH_INFO following the script name. */