diff --git a/calendar/inc/gradient.php b/calendar/inc/gradient.php index 113cf3689f..d79593d5ce 100644 --- a/calendar/inc/gradient.php +++ b/calendar/inc/gradient.php @@ -1,31 +1,16 @@ + * @package calendar + * @copyright (c) 2004-9 by Ralf Becker + * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License + * @version $Id$ + */ - /* $Id$ */ - -// some constanst for pre php4.3 -if (!defined('PHP_SHLIB_SUFFIX')) -{ - define('PHP_SHLIB_SUFFIX',strtoupper(substr(PHP_OS, 0,3)) == 'WIN' ? 'dll' : 'so'); -} -if (!defined('PHP_SHLIB_PREFIX')) -{ - define('PHP_SHLIB_PREFIX',PHP_SHLIB_SUFFIX == 'dll' ? 'php_' : ''); -} - -if (!extension_loaded('gd') && !@dl(PHP_SHLIB_PREFIX.'gd.'.PHP_SHLIB_SUFFIX)) -{ - die("Can't load the needed php-extension 'gd' !!!"); -} +check_load_extension('gd',true); // true = throw exception if not loadable foreach(array('width'=>1,'height'=>1,'color1'=>'000080','color2'=>'ffffff') as $name => $default) { @@ -84,4 +69,3 @@ else imagepng($image); } imagedestroy($image); -?> diff --git a/calendar/inc/round_corners.php b/calendar/inc/round_corners.php index c8bd42491d..9ee50443c4 100644 --- a/calendar/inc/round_corners.php +++ b/calendar/inc/round_corners.php @@ -1,31 +1,16 @@ + * @package calendar + * @copyright (c) 2004-9 by Ralf Becker + * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License + * @version $Id$ + */ - /* $Id$ */ - -// some constanst for pre php4.3 -if (!defined('PHP_SHLIB_SUFFIX')) -{ - define('PHP_SHLIB_SUFFIX',strtoupper(substr(PHP_OS, 0,3)) == 'WIN' ? 'dll' : 'so'); -} -if (!defined('PHP_SHLIB_PREFIX')) -{ - define('PHP_SHLIB_PREFIX',PHP_SHLIB_SUFFIX == 'dll' ? 'php_' : ''); -} - -if (!extension_loaded('gd') && !@dl(PHP_SHLIB_PREFIX.'gd.'.PHP_SHLIB_SUFFIX)) -{ - die("Can't load the needed php-extension 'gd' !!!"); -} +check_load_extension('gd',true); // true = throw exception if not loadable foreach(array('width'=>-20,'height'=>40,'border'=>1,'color'=>'000080','bgcolor'=>'0000FF') as $name => $default) { @@ -85,4 +70,3 @@ else imagepng($image); } imagedestroy($image); -?> diff --git a/etemplate/inc/class.etemplate_request.inc.php b/etemplate/inc/class.etemplate_request.inc.php index 9d3935411f..17ca4ab6a8 100644 --- a/etemplate/inc/class.etemplate_request.inc.php +++ b/etemplate/inc/class.etemplate_request.inc.php @@ -103,7 +103,7 @@ class etemplate_request { if (is_null(self::$request_class)) { - self::$request_class = extension_loaded('mcrypt') && function_exists('gzcompress') && + self::$request_class = check_load_extension('mcrypt') && function_exists('gzcompress') && self::init_crypt() ? __CLASS__ : 'etemplate_request_session'; } if (self::$request_class != __CLASS__) @@ -342,7 +342,7 @@ class etemplate_request { $key = $GLOBALS['egw_info']['server']['db_pass'].EGW_SERVER_ROOT; } - if (!extension_loaded('mcrypt') && (!function_exists('dl') || !@dl(PHP_SHLIB_PREFIX.'mcrypt'.'.'.PHP_SHLIB_SUFFIX))) + if (!check_load_extension('mcrypt')) { error_log(__METHOD__."() required PHP extension mcrypt not loaded and can not be loaded, eTemplate requests get NOT encrypted!"); return false; diff --git a/phpgwapi/inc/class.egw_db.inc.php b/phpgwapi/inc/class.egw_db.inc.php index 88a8f6adbb..32ac272a50 100644 --- a/phpgwapi/inc/class.egw_db.inc.php +++ b/phpgwapi/inc/class.egw_db.inc.php @@ -7,7 +7,7 @@ * @package api * @subpackage db * @author Ralf Becker - * @copyright (c) 2003-8 by Ralf Becker + * @copyright (c) 2003-9 by Ralf Becker * @version $Id$ */ @@ -46,15 +46,6 @@ * } */ -// some constanst for pre php4.3 -if (!defined('PHP_SHLIB_SUFFIX')) -{ - define('PHP_SHLIB_SUFFIX',strtoupper(substr(PHP_OS, 0,3)) == 'WIN' ? 'dll' : 'so'); -} -if (!defined('PHP_SHLIB_PREFIX')) -{ - define('PHP_SHLIB_PREFIX',PHP_SHLIB_SUFFIX == 'dll' ? 'php_' : ''); -} if(empty($GLOBALS['egw_info']['server']['db_type'])) { $GLOBALS['egw_info']['server']['db_type'] = 'mysql'; @@ -406,8 +397,7 @@ class egw_db $this->Host != $GLOBALS['egw']->db->Host || $this->Port != $GLOBALS['egw']->db->Port))) { - if (!extension_loaded($php_extension) && (!function_exists('dl') || - !dl(PHP_SHLIB_PREFIX.$php_extension.'.'.PHP_SHLIB_SUFFIX))) + if (!check_load_extension($php_extension)) { $this->halt("Necessary php database support for $this->Type (".PHP_SHLIB_PREFIX.$php_extension.'.'.PHP_SHLIB_SUFFIX.") not loaded and can't be loaded, exiting !!!"); return null; // in case error-reporting = 'no' diff --git a/phpgwapi/inc/class.egw_session.inc.php b/phpgwapi/inc/class.egw_session.inc.php index ab44c844f4..8233e5c55f 100644 --- a/phpgwapi/inc/class.egw_session.inc.php +++ b/phpgwapi/inc/class.egw_session.inc.php @@ -20,16 +20,6 @@ * @version $Id$ */ -// some constants for pre php4.3 -if (!defined('PHP_SHLIB_SUFFIX')) -{ - define('PHP_SHLIB_SUFFIX',$is_windows ? 'dll' : 'so'); -} -if (!defined('PHP_SHLIB_PREFIX')) -{ - define('PHP_SHLIB_PREFIX',PHP_SHLIB_SUFFIX == 'dll' ? 'php_' : ''); -} - /** * eGW session handling * @@ -381,7 +371,7 @@ class egw_session } if (is_null(self::$mcrypt)) { - if (!extension_loaded('mcrypt') && (!function_exists('dl') || !@dl(PHP_SHLIB_PREFIX.'mcrypt'.'.'.PHP_SHLIB_SUFFIX))) + if (!check_load_extension('mcrypt')) { error_log(__METHOD__."() required PHP extension mcrypt not loaded and can not be loaded, sessions get NOT encrypted!"); return false; diff --git a/phpgwapi/inc/class.egw_session_memcache.inc.php b/phpgwapi/inc/class.egw_session_memcache.inc.php index 51c7339e20..f064d0acd6 100644 --- a/phpgwapi/inc/class.egw_session_memcache.inc.php +++ b/phpgwapi/inc/class.egw_session_memcache.inc.php @@ -70,10 +70,8 @@ class egw_session_memcache */ public static function open($save_path, $session_name) { - if (!extension_loaded('memcache') && !dl(PHP_SHLIB_PREFIX.'memcache.'.PHP_SHLIB_SUFFIX)) - { - throw new Exception("Required PHP extension 'memcache' not loaded AND can NOT be loaded!"); - } + check_load_extension('memcache',true); // true = throw exception if not loadable + self::$memcache = new Memcache; foreach(explode(',',$save_path) as $path) { diff --git a/phpgwapi/inc/class.sqlfs_stream_wrapper.inc.php b/phpgwapi/inc/class.sqlfs_stream_wrapper.inc.php index b5da3b50a3..32b7853c3b 100644 --- a/phpgwapi/inc/class.sqlfs_stream_wrapper.inc.php +++ b/phpgwapi/inc/class.sqlfs_stream_wrapper.inc.php @@ -1462,10 +1462,7 @@ class sqlfs_stream_wrapper implements iface_stream_wrapper { foreach(array('pdo','pdo_'.self::$pdo_type) as $ext) { - if (!extension_loaded($ext) && function_exists('dl') && !dl($dl=PHP_SHLIB_PREFIX.$ext.'.'.PHP_SHLIB_SUFFIX)) - { - throw new Exception ("PHP extension '$ext' not loaded AND can NOT be loaded via dl('$dl')!"); - } + check_load_extension($ext,true); // true = throw Exception } $pdo_available = true; } diff --git a/setup/check_install.php b/setup/check_install.php index 5bac423c13..ce863e3b69 100644 --- a/setup/check_install.php +++ b/setup/check_install.php @@ -176,7 +176,7 @@ $checks = array( 'func' => 'php_ini_check', 'value' => 7, 'warning' => '
' . lang('The mbstring.func_overload = 7 is needed to fully support unicode (utf-8) or other multibyte-charsets.') . "
", - 'change' => extension_loaded('mbstring') || function_exists('dl') && @dl(PHP_SHLIB_PREFIX.'mbstring.'.PHP_SHLIB_SUFFIX) ? 'mbstring.func_overload = 7' : '', + 'change' => check_load_extension('mbstring') ? 'mbstring.func_overload = 7' : '', ), 'ldap' => array( 'func' => 'extension_check', @@ -422,7 +422,7 @@ function extension_check($name,$args) return True; // check only under windows } // we check for the existens of 'dl', as multithreaded webservers dont have it !!! - $available = extension_loaded($name) || function_exists('dl') && @dl(PHP_SHLIB_PREFIX.$name.'.'.PHP_SHLIB_SUFFIX); + $available = check_load_extension($name); echo '
'.($available ? $passed_icon : $warning_icon).' '.lang('Checking extension %1 is loaded or loadable',$name).': '.($available ? lang('True') : lang('False'))."
\n"; diff --git a/setup/inc/class.setup_header.inc.php b/setup/inc/class.setup_header.inc.php index 5014bbe4e1..169a96ffd3 100644 --- a/setup/inc/class.setup_header.inc.php +++ b/setup/inc/class.setup_header.inc.php @@ -75,7 +75,6 @@ class setup_header $GLOBALS['egw_info']['server']['show_domain_selectbox'] = false; $GLOBALS['egw_info']['server']['db_persistent'] = True; - $GLOBALS['egw_info']['server']['sessions_type'] = !$this->check_load_extension('session') ? 'db' :'php4'; $GLOBALS['egw_info']['login_template_set'] = 'idots'; $GLOBALS['egw_info']['server']['mcrypt_enabled'] = False; $GLOBALS['egw_info']['server']['versions']['mcrypt'] = ''; @@ -228,15 +227,6 @@ class setup_header return $iv; } - /** - * checks if a named extension is loaded or loadable - */ - function check_load_extension($extension) - { - return extension_loaded($extension) || - function_exists('dl') && @dl(PHP_SHLIB_PREFIX.$extension.'.'.PHP_SHLIB_SUFFIX); - } - function check_db_support(&$detected) { $supported_db = $detected = array(); @@ -254,7 +244,7 @@ class setup_header $ext = array_shift($data); $func_to_check = array_shift($data); $name = isset($this->db_fullnames[$db]) ? $this->db_fullnames[$db] : strtoupper($db); - if ($this->check_load_extension($ext) || $func_to_check && function_exists($func_to_check)) + if (check_load_extension($ext) || $func_to_check && function_exists($func_to_check)) { $detected[] = lang('You appear to have %1 support.',$name); $supported_db = array_merge($supported_db,$data);