diff --git a/Makefile b/Makefile index e339d926..15cfadb5 100755 --- a/Makefile +++ b/Makefile @@ -10,15 +10,15 @@ built-docs: docs/api/phpdoc.ini htdocs/*.php inc/*.php phpdoc -c docs/api/phpdoc.ini || echo "NOTICE: Failed to build optional API docs" touch built-docs -built-po: inc/always.php scripts/po/rebuild-translations.sh scripts/po/extract.pl po/*.po +built-po: htdocs/always.php scripts/po/rebuild-translations.sh scripts/po/extract.pl po/*.po scripts/po/rebuild-translations.sh touch built-po # # Insert the current version number into always.php # -inc/always.php: scripts/build-always.sh VERSION dba/davical.sql inc/always.php.in - scripts/build-always.sh inc/always.php +htdocs/always.php: scripts/build-always.sh VERSION dba/davical.sql inc/always.php.in + scripts/build-always.sh htdocs/always.php # # Build a release .tar.gz file in the directory above us diff --git a/htdocs/admin.php b/htdocs/admin.php index c5399b02..f2117974 100644 --- a/htdocs/admin.php +++ b/htdocs/admin.php @@ -1,5 +1,5 @@ template_usr = array( 'active' => true, $c->hide_TODO = true; // VTODO only visible to collection owner $c->readonly_webdav_collections = true; // WebDAV access is readonly -// Ensure that ../inc is in our included paths as early as possible -set_include_path( '../inc'. PATH_SEPARATOR. get_include_path()); - // Kind of private configuration values $c->total_query_time = 0; $c->dbg = array(); + // Utilities -require_once('AWLUtilities.php'); +if ( ! @include_once('AWLUtilities.php') ) { + $try_paths = array( + '../../awl/inc' + , '/usr/share/awl/inc' + , '/usr/local/share/awl/inc' + ); + foreach( $try_paths AS $awl_include_path ) { + if ( @file_exists($awl_include_path.'/AWLUtilities.php') ) { + set_include_path( $awl_include_path. PATH_SEPARATOR. get_include_path()); + break; + } + } + if ( ! @include_once('AWLUtilities.php') ) { + echo "Could not find the AWL libraries. Are they installed? Check your include_path in php.ini!\n"; + exit; + } +} + +// Ensure that ../inc is in our included paths as early as possible +set_include_path( '../inc'. PATH_SEPARATOR. get_include_path()); + /** 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']) ) { diff --git a/htdocs/caldav.php b/htdocs/caldav.php index 4308983e..f434400d 100644 --- a/htdocs/caldav.php +++ b/htdocs/caldav.php @@ -19,7 +19,7 @@ if ( isset($_SERVER['PATH_INFO']) && preg_match( '{^(/favicon.ico|davical.css|(i } exit(0); } -require_once('../inc/always.php'); +require_once('./always.php'); // dbg_error_log( 'caldav', ' User agent: %s', ((isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : 'Unfortunately Mulberry does not send a "User-agent" header with its requests :-(')) ); // dbg_log_array( 'headers', '_SERVER', $_SERVER, true ); require_once('HTTPAuthSession.php'); diff --git a/htdocs/freebusy.php b/htdocs/freebusy.php index bc0273aa..a97e8635 100644 --- a/htdocs/freebusy.php +++ b/htdocs/freebusy.php @@ -1,5 +1,5 @@ public_freebusy_url) && $c->public_freebusy_url ) { diff --git a/htdocs/help.php b/htdocs/help.php index 8e97c8f6..d9ed2500 100644 --- a/htdocs/help.php +++ b/htdocs/help.php @@ -1,5 +1,5 @@ LoginRequired(); diff --git a/htdocs/index.php b/htdocs/index.php index 713d68d6..3a6ff47c 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -7,7 +7,7 @@ if ( $_SERVER['REQUEST_METHOD'] != "GET" && $_SERVER['REQUEST_METHOD'] != "POST" exit; // Not that it should return from that! } -include("../inc/always.php"); +include("./always.php"); include("DAViCalSession.php"); $session->LoginRequired(); diff --git a/htdocs/public.php b/htdocs/public.php index c3494b55..6e5a2a37 100644 --- a/htdocs/public.php +++ b/htdocs/public.php @@ -8,7 +8,7 @@ * @copyright Catalyst .Net Ltd * @license http://gnu.org/copyleft/gpl.html GNU GPL v2 */ -require("../inc/always.php"); +require("./always.php"); dbg_error_log( "caldav", " User agent: %s", ((isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : "Unfortunately Mulberry does not send a 'User-agent' header with its requests :-(")) ); dbg_log_array( "headers", '_SERVER', $_SERVER, true ); require("PublicSession.php"); diff --git a/htdocs/setup.php b/htdocs/setup.php index b910f227..42262f9c 100644 --- a/htdocs/setup.php +++ b/htdocs/setup.php @@ -1,6 +1,6 @@ LoginRequired(); diff --git a/htdocs/upgrade.php b/htdocs/upgrade.php index ce03571b..a654a3ff 100644 --- a/htdocs/upgrade.php +++ b/htdocs/upgrade.php @@ -1,6 +1,6 @@ LoginRequired('Admin'); diff --git a/inc/always.php.in b/inc/always.php.in index f0628e62..3e6d5e04 100644 --- a/inc/always.php.in +++ b/inc/always.php.in @@ -6,6 +6,8 @@ * @license http://gnu.org/copyleft/gpl.html GNU GPL v2 or later */ +if ( preg_match('{/always.php$}', $_SERVER['SCRIPT_NAME'] ) ) header('Location: index.php'); + // Ensure the configuration starts out as an empty object. $c = (object) array(); @@ -57,16 +59,34 @@ $c->template_usr = array( 'active' => true, $c->hide_TODO = true; // VTODO only visible to collection owner $c->readonly_webdav_collections = true; // WebDAV access is readonly -// Ensure that ../inc is in our included paths as early as possible -set_include_path( '../inc'. PATH_SEPARATOR. get_include_path()); - // Kind of private configuration values $c->total_query_time = 0; $c->dbg = array(); + // Utilities -require_once('AWLUtilities.php'); +if ( ! @include_once('AWLUtilities.php') ) { + $try_paths = array( + '../../awl/inc' + , '/usr/share/awl/inc' + , '/usr/local/share/awl/inc' + ); + foreach( $try_paths AS $awl_include_path ) { + if ( @file_exists($awl_include_path.'/AWLUtilities.php') ) { + set_include_path( $awl_include_path. PATH_SEPARATOR. get_include_path()); + break; + } + } + if ( ! @include_once('AWLUtilities.php') ) { + echo "Could not find the AWL libraries. Are they installed? Check your include_path in php.ini!\n"; + exit; + } +} + +// Ensure that ../inc is in our included paths as early as possible +set_include_path( '../inc'. PATH_SEPARATOR. get_include_path()); + /** 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']) ) {