From 1858e4d7685782550789fd8c228e55ae319bc37a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gerry=20Wei=C3=9Fbach?= Date: Mon, 30 Jun 2014 09:13:10 +0200 Subject: Check for basedir and baseurl If these configuration values are not set php will throw an unnecessary NOTICE. --- inc/init.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'inc/init.php') diff --git a/inc/init.php b/inc/init.php index a937b934d..7340f4191 100644 --- a/inc/init.php +++ b/inc/init.php @@ -411,7 +411,7 @@ function getBaseURL($abs=null){ //if canonical url enabled always return absolute if(is_null($abs)) $abs = $conf['canonical']; - if($conf['basedir']){ + if(!empty($conf['basedir'])){ $dir = $conf['basedir']; }elseif(substr($_SERVER['SCRIPT_NAME'],-4) == '.php'){ $dir = dirname($_SERVER['SCRIPT_NAME']); @@ -438,7 +438,7 @@ function getBaseURL($abs=null){ if(!$abs) return $dir; //use config option if available, trim any slash from end of baseurl to avoid multiple consecutive slashes in the path - if($conf['baseurl']) return rtrim($conf['baseurl'],'/').$dir; + if(!empty($conf['baseurl'])) return rtrim($conf['baseurl'],'/').$dir; //split hostheader into host and port if(isset($_SERVER['HTTP_HOST'])){ -- cgit v1.2.3 From 0f8f7aaa42dc1e95a0d7a1cac126263bdb17686b Mon Sep 17 00:00:00 2001 From: Danny Lin Date: Fri, 31 Oct 2014 18:40:52 +0800 Subject: Move check after libraries are loaded, so that $conf['compression'] is not turned off in the case that gzopen doesn't exist while gzopen64 does exist, as inc/compatibility.php ought to have fixed. --- inc/init.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'inc/init.php') diff --git a/inc/init.php b/inc/init.php index 24920a17d..d0d9101e6 100644 --- a/inc/init.php +++ b/inc/init.php @@ -178,14 +178,6 @@ $_REQUEST = array_merge($_GET,$_POST); // we don't want a purge URL to be digged if(isset($_REQUEST['purge']) && !empty($_SERVER['HTTP_REFERER'])) unset($_REQUEST['purge']); -// disable gzip if not available -if($conf['compression'] == 'bz2' && !function_exists('bzopen')){ - $conf['compression'] = 'gz'; -} -if($conf['compression'] == 'gz' && !function_exists('gzopen')){ - $conf['compression'] = 0; -} - // precalculate file creation modes init_creationmodes(); @@ -201,6 +193,14 @@ if (empty($plugin_controller_class)) $plugin_controller_class = 'Doku_Plugin_Con // load libraries require_once(DOKU_INC.'inc/load.php'); +// disable gzip if not available +if($conf['compression'] == 'bz2' && !function_exists('bzopen')){ + $conf['compression'] = 'gz'; +} +if($conf['compression'] == 'gz' && !function_exists('gzopen')){ + $conf['compression'] = 0; +} + // input handle class global $INPUT; $INPUT = new Input(); -- cgit v1.2.3 From 79e79377626799a77c11aa7849cb9c64305590c8 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Wed, 7 Jan 2015 10:47:45 +0100 Subject: Remove error supression for file_exists() In an older version of PHP a file_exists() call would issue a warning when the file did not exist. This was fixed in later PHP releases. Since we require PHP 5.3 now, there's no need to supress any error here anymore. This might even give a minor performance boost. --- inc/init.php | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'inc/init.php') diff --git a/inc/init.php b/inc/init.php index 12bb6f588..91bc77f98 100644 --- a/inc/init.php +++ b/inc/init.php @@ -16,7 +16,7 @@ $config_cascade = array(); // if available load a preload config file $preload = fullpath(dirname(__FILE__)).'/preload.php'; -if (@file_exists($preload)) include($preload); +if (file_exists($preload)) include($preload); // define the include path if(!defined('DOKU_INC')) define('DOKU_INC',fullpath(dirname(__FILE__).'/../').'/'); @@ -28,7 +28,7 @@ if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); if(!defined('DOKU_CONF')) define('DOKU_CONF',DOKU_INC.'conf/'); // check for error reporting override or set error reporting to sane values -if (!defined('DOKU_E_LEVEL') && @file_exists(DOKU_CONF.'report_e_all')) { +if (!defined('DOKU_E_LEVEL') && file_exists(DOKU_CONF.'report_e_all')) { define('DOKU_E_LEVEL', E_ALL); } if (!defined('DOKU_E_LEVEL')) { @@ -65,7 +65,7 @@ $conf = array(); foreach (array('default','local','protected') as $config_group) { if (empty($config_cascade['main'][$config_group])) continue; foreach ($config_cascade['main'][$config_group] as $config_file) { - if (@file_exists($config_file)) { + if (file_exists($config_file)) { include($config_file); } } @@ -79,7 +79,7 @@ $license = array(); foreach (array('default','local') as $config_group) { if (empty($config_cascade['license'][$config_group])) continue; foreach ($config_cascade['license'][$config_group] as $config_file) { - if(@file_exists($config_file)){ + if(file_exists($config_file)){ include($config_file); } } @@ -272,7 +272,7 @@ function init_lang($langCode) { //load the language files require(DOKU_INC.'inc/lang/en/lang.php'); foreach ($config_cascade['lang']['core'] as $config_file) { - if (@file_exists($config_file . 'en/lang.php')) { + if (file_exists($config_file . 'en/lang.php')) { include($config_file . 'en/lang.php'); } } @@ -282,7 +282,7 @@ function init_lang($langCode) { require(DOKU_INC."inc/lang/$langCode/lang.php"); } foreach ($config_cascade['lang']['core'] as $config_file) { - if (@file_exists($config_file . "$langCode/lang.php")) { + if (file_exists($config_file . "$langCode/lang.php")) { include($config_file . "$langCode/lang.php"); } } @@ -298,7 +298,7 @@ function init_files(){ $files = array($conf['indexdir'].'/page.idx'); foreach($files as $file){ - if(!@file_exists($file)){ + if(!file_exists($file)){ $fh = @fopen($file,'a'); if($fh){ fclose($fh); @@ -312,7 +312,7 @@ function init_files(){ # create title index (needs to have same length as page.idx) /* $file = $conf['indexdir'].'/title.idx'; - if(!@file_exists($file)){ + if(!file_exists($file)){ $pages = file($conf['indexdir'].'/page.idx'); $pages = count($pages); $fh = @fopen($file,'a'); @@ -339,9 +339,9 @@ function init_files(){ function init_path($path){ // check existence $p = fullpath($path); - if(!@file_exists($p)){ + if(!file_exists($p)){ $p = fullpath(DOKU_INC.$path); - if(!@file_exists($p)){ + if(!file_exists($p)){ return ''; } } @@ -352,7 +352,7 @@ function init_path($path){ } // check accessability (execute bit) for directories - if(@is_dir($p) && !@file_exists("$p/.")){ + if(@is_dir($p) && !file_exists("$p/.")){ return ''; } @@ -593,7 +593,7 @@ function fullpath($path,$exists=false){ $finalpath = $root.implode('/', $newpath); // check for existence when needed (except when unit testing) - if($exists && !defined('DOKU_UNITTEST') && !@file_exists($finalpath)) { + if($exists && !defined('DOKU_UNITTEST') && !file_exists($finalpath)) { return false; } return $finalpath; -- cgit v1.2.3 From 0a4266d4abdf928b71e0eb0164595ce5d3f162f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elan=20Ruusam=C3=A4e?= Date: Tue, 10 Feb 2015 14:48:08 +0200 Subject: consistency: failure exit with status code 1 --- inc/init.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'inc/init.php') diff --git a/inc/init.php b/inc/init.php index 91bc77f98..bc9ab6d70 100644 --- a/inc/init.php +++ b/inc/init.php @@ -535,7 +535,7 @@ function nice_die($msg){ EOT; - exit; + exit(1); } /** -- cgit v1.2.3 From 605f8e8d0e501057749c50581087ce05089c1af3 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Fri, 15 May 2015 15:17:39 +0200 Subject: added composer setup and the first composer package php-archive --- inc/init.php | 1 + 1 file changed, 1 insertion(+) (limited to 'inc/init.php') diff --git a/inc/init.php b/inc/init.php index bc9ab6d70..6d271dfb0 100644 --- a/inc/init.php +++ b/inc/init.php @@ -191,6 +191,7 @@ global $plugin_controller_class, $plugin_controller; if (empty($plugin_controller_class)) $plugin_controller_class = 'Doku_Plugin_Controller'; // load libraries +require_once(DOKU_INC.'vendor/autoload.php'); require_once(DOKU_INC.'inc/load.php'); // disable gzip if not available -- cgit v1.2.3