diff --git a/phpgwapi/inc/class.db.inc.php b/phpgwapi/inc/class.db.inc.php index 48a8be2a6b..cea5b1af8c 100644 --- a/phpgwapi/inc/class.db.inc.php +++ b/phpgwapi/inc/class.db.inc.php @@ -21,6 +21,15 @@ * @license LGPL */ + // 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['phpgw_info']['server']['db_type'])) { $GLOBALS['phpgw_info']['server']['db_type'] = 'mysql'; @@ -185,25 +194,46 @@ { $$name = $this->$name; } - $type = $this->Type; + $php_extension = $type = $this->Type; switch($this->Type) // convert to ADO db-type-names { case 'pgsql': - $type = 'postgres'; + $type = 'postgres'; // name in ADOdb // create our own pgsql connection-string, to allow unix domain soccets if !$Host $Host = "dbname=$this->Database".($this->Host ? " host=$this->Host".($this->Port ? " port=$this->Port" : '') : ''). " user=$this->User".($this->Password ? " password='".addslashes($this->Password)."'" : ''); $User = $Password = $Database = ''; // to indicate $Host is a connection-string break; + + case 'odbc_mssql': + $php_extension = 'odbc'; + $this->Type = 'mssql'; + // fall through case 'mssql': if ($this->Port) $Host .= ','.$this->Port; break; + + case 'odbc_oracle': + $php_extension = 'odbc'; + $this->Type = 'oracle'; + break; + case 'oracle': + $php_extension = $type = 'oci8'; + break; + + case 'sapdb': + $this->Type = 'maxdb'; + // fall through + case 'maxdb': + $type ='sapdb'; // name in ADOdb + $php_extension = 'odbc'; + break; + default: if ($this->Port) $Host .= ':'.$this->Port; break; } - if (!is_object($GLOBALS['phpgw']->ADOdb) || // we have no connection so far (is_object($GLOBALS['phpgw']->db) && // we connect to a different db, then the global one ($this->Type != $GLOBALS['phpgw']->db->Type || @@ -212,6 +242,12 @@ $this->Host != $GLOBALS['phpgw']->db->Host || $this->Port != $GLOBALS['phpgw']->db->Port))) { + if (!extension_loaded($php_extension) && (!function_exists('dl') || + !dl(PHP_SHLIB_PREFIX.$php_extension.'.'.PHP_SHLIB_SUFFIX))) + { + $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 0; // in case error-reporting = 'no' + } if (!is_object($GLOBALS['phpgw']->ADOdb)) // use the global object to store the connection { $this->Link_ID = &$GLOBALS['phpgw']->ADOdb; @@ -223,7 +259,7 @@ $this->Link_ID = ADONewConnection($type); if (!$this->Link_ID) { - $this->halt("No ADOdb support for '$type' !!!"); + $this->halt("No ADOdb support for '$type' ($this->Type) !!!"); return 0; // in case error-reporting = 'no' } $connect = $GLOBALS['phpgw_info']['server']['db_persistent'] ? 'PConnect' : 'Connect'; diff --git a/phpgwapi/inc/class.sessions.inc.php b/phpgwapi/inc/class.sessions.inc.php index 0226e47e86..cd26b88652 100644 --- a/phpgwapi/inc/class.sessions.inc.php +++ b/phpgwapi/inc/class.sessions.inc.php @@ -1324,8 +1324,21 @@ { $GLOBALS['phpgw_info']['server']['sessions_type'] = 'php4'; // the more performant default } - if ($GLOBALS['phpgw_info']['server']['sessions_type'] == 'php4' && !extension_loaded('session') && !@dl('session')) + // for php4 sessions, check if the extension is loaded, try loading it and fallback to db sessions if not + if ($GLOBALS['phpgw_info']['server']['sessions_type'] == 'php4' && !extension_loaded('session')) { - $GLOBALS['phpgw_info']['server']['sessions_type'] = 'db'; // fallback if we have no php4 sessions support + // 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 (!function_exists('dl') || !@dl(PHP_SHLIB_PREFIX.'session'.'.'.PHP_SHLIB_SUFFIX)) + { + $GLOBALS['phpgw_info']['server']['sessions_type'] = 'db'; // fallback if we have no php4 sessions support + } } include_once(PHPGW_API_INC.'/class.sessions_'.$GLOBALS['phpgw_info']['server']['sessions_type'].'.inc.php'); diff --git a/setup/check_install.php b/setup/check_install.php index d4944e0dda..f05f3e31b0 100644 --- a/setup/check_install.php +++ b/setup/check_install.php @@ -111,7 +111,11 @@ ), 'odbc' => array( 'func' => 'extension_check', - 'warning' => '
' . lang('The %1 extension is needed, if you plan to use a %2 database.','odbc','MaxDB') . '
', + 'warning' => '
' . lang('The %1 extension is needed, if you plan to use a %2 database.','odbc','MaxDB, MsSQL or Oracle') . '
', + ), + 'oci8' => array( + 'func' => 'extension_check', + 'warning' => '
' . lang('The %1 extension is needed, if you plan to use a %2 database.','oci','Oracle') . '
', ), 'mbstring' => array( 'func' => 'extension_check', diff --git a/setup/manageheader.php b/setup/manageheader.php index a857c0b5a3..589ed28ebb 100644 --- a/setup/manageheader.php +++ b/setup/manageheader.php @@ -21,6 +21,24 @@ ); include('./inc/functions.inc.php'); + // 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_' : ''); + } + /** + * 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); + } + $GLOBALS['phpgw_info']['server']['versions']['current_header'] = $setup_info['phpgwapi']['versions']['current_header']; $GLOBALS['phpgw_info']['server']['versions']['phpgwapi'] = $setup_info['phpgwapi']['version']; unset($setup_info); @@ -48,15 +66,19 @@ 'pgsql' => 'PostgreSQL', 'mysql' => 'MySQL', 'mssql' => 'MS SQL Server', + 'odbc_mssql' => 'MS SQL Server via ODBC', 'oracle' => 'Oracle', - 'sapdb' => 'SAP/Max DB', + 'odbc_oracle' => 'Oracle via ODBC', + 'sapdb' => 'SAP/Max DB via ODBC', ); $default_db_ports = array( 'pgsql' => 5432, 'mysql' => 3306, 'mssql' => 1433, + 'odbc_mssql' => '', 'oracle' => 1521, + 'odbc_oracle' => '', 'sapdb' => '', ); @@ -252,7 +274,7 @@ $detected .= '' . lang('Analysis') . ''. "\n"; $supported_db = array(); - if(extension_loaded('mysql') || function_exists('mysql_connect')) + if(check_load_extension('mysql') || function_exists('mysql_connect')) { $detected .= lang('You appear to have MySQL support enabled') . '
' . "\n"; $supported_db[] = 'mysql'; @@ -261,7 +283,7 @@ { $detected .= lang('No MySQL support found. Disabling') . '
' . "\n"; } - if(extension_loaded('pgsql') || function_exists('pg_connect')) + if(check_load_extension('pgsql') || function_exists('pg_connect')) { $detected .= lang('You appear to have PostgreSQL support enabled') . '
' . "\n"; $supported_db[] = 'pgsql'; @@ -270,7 +292,7 @@ { $detected .= lang('No PostgreSQL support found. Disabling') . '
' . "\n"; } - if(extension_loaded('mssql') || function_exists('mssql_connect')) + if(check_load_extension('mssql') || function_exists('mssql_connect')) { $detected .= lang('You appear to have Microsoft SQL Server support enabled') . '
' . "\n"; $supported_db[] = 'mssql'; @@ -279,35 +301,29 @@ { $detected .= lang('No Microsoft SQL Server support found. Disabling') . '
' . "\n"; } - if(extension_loaded('odbc')) + if(check_load_extension('odbc')) { $detected .= lang('You appear to have ODBC support enabled') . '
' . "\n"; // databases supported by the ODBC driver $supported_db[] = 'sapdb'; + $supported_db[] = 'odbc_mssql'; + $supported_db[] = 'odbc_oracle'; } else { $detected .= lang('No ODBC support found. Disabling') . '
' . "\n"; } -/* - if(extension_loaded('oci8')) + + if(check_load_extension('oci8')) { $detected .= lang('You appear to have Oracle V8 (OCI) support enabled') . '
' . "\n"; $supported_db[] = 'oracle'; } else { - if(extension_loaded('oracle')) - { - $detected .= lang('You appear to have Oracle support enabled') . '
' . "\n"; - $supported_db[] = 'oracle'; - } - else - { - $detected .= lang('No Oracle-DB support found. Disabling') . '
' . "\n"; - } + $detected .= lang('No Oracle-DB support found. Disabling') . '
' . "\n"; } -*/ + if(!count($supported_db)) { $detected .= '

' @@ -327,12 +343,12 @@ echo $detected; exit; } - else + if (check_load_extension('session')) { - $detected .= lang('You appear to be using PHP4. Enabling PHP4 sessions support') . '
' . "\n"; + $detected .= lang('You appear to have PHP4 session support. Enabling PHP4 sessions.') . '
' . "\n"; $supported_sessions_type[] = 'php4'; // makeing php4 sessions the default - $supported_sessions_type[] = 'db'; } + $supported_sessions_type[] = 'db'; @reset($default_db_ports); $js_default_db_ports = 'var default_db_ports = new Array();'."\n"; @@ -343,7 +359,7 @@ $setup_tpl->set_var('js_default_db_ports',$js_default_db_ports); /* - if(extension_loaded('xml') || function_exists('xml_parser_create')) + if(check_load_extension('xml') || function_exists('xml_parser_create')) { $detected .= lang('You appear to have XML support enabled') . '
' . "\n"; $xml_enabled = 'True'; @@ -503,7 +519,7 @@ /* These are a few of the advanced settings */ $GLOBALS['phpgw_info']['server']['db_persistent'] = True; - $GLOBALS['phpgw_info']['server']['mcrypt_enabled'] = extension_loaded('mcrypt'); + $GLOBALS['phpgw_info']['server']['mcrypt_enabled'] = check_load_extension('mcrypt'); $GLOBALS['phpgw_info']['server']['versions']['mcrypt'] = ''; srand((double)microtime()*1000000);