From f17337d3b7cdf2f21f5fd94f2b0a379282a61bac Mon Sep 17 00:00:00 2001 From: shrykedude Date: Mon, 8 Dec 2003 04:50:23 +0000 Subject: [PATCH] Added support for specifying the database port number --- header.inc.php.template | 3 +- phpgwapi/inc/class.db.inc.php | 16 +++++++++- phpgwapi/inc/class.db_msql.inc.php | 7 ++++- phpgwapi/inc/class.db_mssql.inc.php | 7 ++++- phpgwapi/inc/class.db_mysql.inc.php | 11 +++++-- phpgwapi/inc/class.db_oracle.inc.php | 8 +++-- phpgwapi/inc/class.db_pgsql.inc.php | 7 +++-- phpgwapi/inc/class.db_sybase.inc.php | 6 +++- phpgwapi/inc/functions.inc.php | 3 ++ phpgwapi/setup/setup.inc.php | 2 +- setup/lang/phpgw_en.lang | 2 ++ setup/manageheader.php | 19 ++++++++++++ setup/templates/default/manageheader.tpl | 38 ++++++++++++++++++------ 13 files changed, 107 insertions(+), 22 deletions(-) diff --git a/header.inc.php.template b/header.inc.php.template index 90c02dcc91..0b9094cec3 100644 --- a/header.inc.php.template +++ b/header.inc.php.template @@ -92,7 +92,7 @@ $GLOBALS['phpgw_info']['server']['versions']['phpgwapi'] = $setup_info['phpgwapi']['version']; $GLOBALS['phpgw_info']['server']['versions']['current_header'] = $setup_info['phpgwapi']['versions']['current_header']; unset($setup_info); - $GLOBALS['phpgw_info']['server']['versions']['header'] = '1.24'; + $GLOBALS['phpgw_info']['server']['versions']['header'] = '1.25'; /* This is a fix for NT */ if(!isset($GLOBALS['phpgw_info']['flags']['noapi']) || !$GLOBALS['phpgw_info']['flags']['noapi'] == True) { @@ -107,6 +107,7 @@ */ $GLOBALS['phpgw_domain']['{DB_DOMAIN}'] = array ( 'db_host' => '{DB_HOST}', + 'db_port' => '{DB_PORT}', 'db_name' => '{DB_NAME}', 'db_user' => '{DB_USER}', 'db_pass' => '{DB_PASS}', diff --git a/phpgwapi/inc/class.db.inc.php b/phpgwapi/inc/class.db.inc.php index f7a06f1590..d95e027c12 100644 --- a/phpgwapi/inc/class.db.inc.php +++ b/phpgwapi/inc/class.db.inc.php @@ -42,6 +42,11 @@ */ var $Host = ''; + /** + * @var string $Port port number of database to connect to + */ + var $Port = ''; + /** * @var string $Database name of database to use */ @@ -143,7 +148,7 @@ * @param string $User name of database user (optional) * @var string $Password password for database user (optional) */ - function connect($Database = '', $Host = '', $User = '', $Password = '') + function connect($Database = '', $Host = '', $Port = '', $User = '', $Password = '') { /* Handle defaults */ if ($Database == '') @@ -154,6 +159,14 @@ { $Host = $this->Host; } + if ($Port == '') + { + $Port = $this->Port; + } + if (isset($Port)) + { + $Host = $Host.':'.$Port; + } if ($User == '') { $User = $this->User; @@ -162,6 +175,7 @@ { $Password = $this->Password; } + if (!$this->Link_ID) { $this->type = $GLOBALS['phpgw_info']['server']['db_type']; diff --git a/phpgwapi/inc/class.db_msql.inc.php b/phpgwapi/inc/class.db_msql.inc.php index 5433a505db..708123e3d9 100644 --- a/phpgwapi/inc/class.db_msql.inc.php +++ b/phpgwapi/inc/class.db_msql.inc.php @@ -17,7 +17,7 @@ class db { - function connect($Database = '', $Host = '', $User = '', $Password = '') + function connect($Database = '', $Host = '', $Port = '', $User = '', $Password = '') { /* Handle defaults */ if ($Database == '') @@ -28,6 +28,10 @@ { $Host = $this->Host; } + if ($Port == '') + { + $Port = $this->Port; + } if ($User == '') { $User = $this->User; @@ -36,6 +40,7 @@ { $Password = $this->Password; } + $Host = $Host.':'.$Port; // Not connected? Then connect? if (! $this->Link_ID) diff --git a/phpgwapi/inc/class.db_mssql.inc.php b/phpgwapi/inc/class.db_mssql.inc.php index a6d2532dae..b3b0422bfe 100644 --- a/phpgwapi/inc/class.db_mssql.inc.php +++ b/phpgwapi/inc/class.db_mssql.inc.php @@ -24,7 +24,7 @@ var $VEOF = -1; var $Transaction = false; - function connect($Database = '', $Host = '', $User = '', $Password = '') + function connect($Database = '', $Host = '', $Port = '', $User = '', $Password = '') { /* Handle defaults */ if ($Database == '') @@ -35,6 +35,10 @@ { $Host = $this->Host; } + if ($Port == '') + { + $Port = $this->Port; + } if ($User == '') { $User = $this->User; @@ -43,6 +47,7 @@ { $Password = $this->Password; } + $Host = $Host.':'.$Port; if (! $this->Link_ID ) { diff --git a/phpgwapi/inc/class.db_mysql.inc.php b/phpgwapi/inc/class.db_mysql.inc.php index 0e21435e53..c24f4d5e73 100644 --- a/phpgwapi/inc/class.db_mysql.inc.php +++ b/phpgwapi/inc/class.db_mysql.inc.php @@ -18,7 +18,7 @@ { /* public: this is an api revision, not a CVS revision. */ var $type = 'mysql'; - var $revision = '1.2'; + var $revision = '1.3'; function db($query = '') { @@ -26,7 +26,7 @@ } /* public: connection management */ - function connect($Database = '', $Host = '', $User = '', $Password = '') + function connect($Database = '', $Host = '', $Port = '', $User = '', $Password = '') { /* Handle defaults */ if ($Database == '') @@ -37,6 +37,10 @@ { $Host = $this->Host; } + if ($Port == '') + { + $Port = isset($this->Port) ? $this->Port : '3306'; + } if ($User == '') { $User = $this->User; @@ -45,6 +49,8 @@ { $Password = $this->Password; } + $Host = $Host.':'.$Port; + /* establish connection, select database */ if (! $this->Link_ID) { @@ -56,7 +62,6 @@ { $this->Link_ID=mysql_connect($Host, $User, $Password); } - if (!$this->Link_ID) { $this->halt(($GLOBALS['phpgw_info']['server']['db_persistent']?'p':'')."connect($Host, $User, \$Password) failed."); diff --git a/phpgwapi/inc/class.db_oracle.inc.php b/phpgwapi/inc/class.db_oracle.inc.php index cd92a4edfd..b6b735411f 100644 --- a/phpgwapi/inc/class.db_oracle.inc.php +++ b/phpgwapi/inc/class.db_oracle.inc.php @@ -24,7 +24,7 @@ /* copied from db_mysql for completeness */ /* public: identification constant. never change this. */ var $type = 'oracle'; - var $revision = '1.2'; + var $revision = '1.3'; /* public: constructor */ function db($query = '') @@ -32,7 +32,7 @@ $this->db_($query); } - function connect($Database = '', $Host = '', $User = '', $Password = '') + function connect($Database = '', $Host = '', $Port = '', $User = '', $Password = '') { /* Handle defaults */ if ($Database == '') @@ -43,6 +43,10 @@ { $Host = $this->Host; } + if ($Port == '') + { + $Port = $this->Port; + } if ($User == '') { $User = $this->User; diff --git a/phpgwapi/inc/class.db_pgsql.inc.php b/phpgwapi/inc/class.db_pgsql.inc.php index a631ca217e..a06a523408 100644 --- a/phpgwapi/inc/class.db_pgsql.inc.php +++ b/phpgwapi/inc/class.db_pgsql.inc.php @@ -36,7 +36,7 @@ $this->db_($query); } - function connect($Database = '', $Host = '', $User = '', $Password = '') + function connect($Database = '', $Host = '', $Port = '', $User = '', $Password = '') { /* Handle defaults */ if ($Database == '') @@ -47,6 +47,10 @@ { $Host = $this->Host; } + if ($Port == '') + { + $Port = $this->Port; + } if ($User == '') { $User = $this->User; @@ -55,7 +59,6 @@ { $Password = $this->Password; } - if (! $this->Link_ID) { $cstr = 'dbname=' . $Database diff --git a/phpgwapi/inc/class.db_sybase.inc.php b/phpgwapi/inc/class.db_sybase.inc.php index 9f1017f925..9e9ae9993f 100644 --- a/phpgwapi/inc/class.db_sybase.inc.php +++ b/phpgwapi/inc/class.db_sybase.inc.php @@ -20,7 +20,7 @@ class db { - function connect($Database = '', $Host = '', $User = '', $Password = '') + function connect($Database = '', $Host = '', $Port = '', $User = '', $Password = '') { /* Handle defaults */ if ($Database == '') @@ -31,6 +31,10 @@ { $Host = $this->Host; } + if ($Port == '') + { + $Port = $this->Port; + } if ($User == '') { $User = $this->User; diff --git a/phpgwapi/inc/functions.inc.php b/phpgwapi/inc/functions.inc.php index 64bd0e013a..e1f14ade3a 100644 --- a/phpgwapi/inc/functions.inc.php +++ b/phpgwapi/inc/functions.inc.php @@ -106,6 +106,7 @@ if (@isset($GLOBALS['phpgw_domain'][$GLOBALS['phpgw_info']['user']['domain']])) { $GLOBALS['phpgw_info']['server']['db_host'] = $GLOBALS['phpgw_domain'][$GLOBALS['phpgw_info']['user']['domain']]['db_host']; + $GLOBALS['phpgw_info']['server']['db_port'] = $GLOBALS['phpgw_domain'][$GLOBALS['phpgw_info']['user']['domain']]['db_port']; $GLOBALS['phpgw_info']['server']['db_name'] = $GLOBALS['phpgw_domain'][$GLOBALS['phpgw_info']['user']['domain']]['db_name']; $GLOBALS['phpgw_info']['server']['db_user'] = $GLOBALS['phpgw_domain'][$GLOBALS['phpgw_info']['user']['domain']]['db_user']; $GLOBALS['phpgw_info']['server']['db_pass'] = $GLOBALS['phpgw_domain'][$GLOBALS['phpgw_info']['user']['domain']]['db_pass']; @@ -114,6 +115,7 @@ else { $GLOBALS['phpgw_info']['server']['db_host'] = $GLOBALS['phpgw_domain'][$GLOBALS['phpgw_info']['server']['default_domain']]['db_host']; + $GLOBALS['phpgw_info']['server']['db_port'] = $GLOBALS['phpgw_domain'][$GLOBALS['phpgw_info']['server']['default_domain']]['db_port']; $GLOBALS['phpgw_info']['server']['db_name'] = $GLOBALS['phpgw_domain'][$GLOBALS['phpgw_info']['server']['default_domain']]['db_name']; $GLOBALS['phpgw_info']['server']['db_user'] = $GLOBALS['phpgw_domain'][$GLOBALS['phpgw_info']['server']['default_domain']]['db_user']; $GLOBALS['phpgw_info']['server']['db_pass'] = $GLOBALS['phpgw_domain'][$GLOBALS['phpgw_info']['server']['default_domain']]['db_pass']; @@ -137,6 +139,7 @@ \************************************************************************/ $GLOBALS['phpgw']->db = CreateObject('phpgwapi.db'); $GLOBALS['phpgw']->db->Host = $GLOBALS['phpgw_info']['server']['db_host']; + $GLOBALS['phpgw']->db->Port = $GLOBALS['phpgw_info']['server']['db_port']; $GLOBALS['phpgw']->db->Type = $GLOBALS['phpgw_info']['server']['db_type']; $GLOBALS['phpgw']->db->Database = $GLOBALS['phpgw_info']['server']['db_name']; $GLOBALS['phpgw']->db->User = $GLOBALS['phpgw_info']['server']['db_user']; diff --git a/phpgwapi/setup/setup.inc.php b/phpgwapi/setup/setup.inc.php index aa0bc68f0e..84d276ebe5 100755 --- a/phpgwapi/setup/setup.inc.php +++ b/phpgwapi/setup/setup.inc.php @@ -16,7 +16,7 @@ $setup_info['phpgwapi']['name'] = 'phpgwapi'; $setup_info['phpgwapi']['title'] = 'phpgwapi'; $setup_info['phpgwapi']['version'] = '0.9.99.008'; - $setup_info['phpgwapi']['versions']['current_header'] = '1.24'; + $setup_info['phpgwapi']['versions']['current_header'] = '1.25'; $setup_info['phpgwapi']['enable'] = 3; $setup_info['phpgwapi']['app_order'] = 1; diff --git a/setup/lang/phpgw_en.lang b/setup/lang/phpgw_en.lang index 9dcec8c01a..7fab6bcafe 100644 --- a/setup/lang/phpgw_en.lang +++ b/setup/lang/phpgw_en.lang @@ -88,6 +88,7 @@ datetime port.
if using port 13, please set firewall rules appropriately befo db host setup en DB Host db name setup en DB Name db password setup en DB Password +db port setup en DB Port db root password setup en DB root password db root username setup en DB root username db type setup en DB Type @@ -315,6 +316,7 @@ tables dropped setup en tables dropped tables installed, unless there are errors printed above setup en tables installed, unless there are errors printed above tables upgraded setup en tables upgraded target version setup en Target Version +TCP port number of database server setup en TCP port number of database server text entry setup en Text Entry the db_type in defaults (%1) is not supported on this server. using first supported type. setup en The db_type in defaults (%1) is not supported on this server. using first supported type. the file setup en the file diff --git a/setup/manageheader.php b/setup/manageheader.php index 0e8e254522..ac22aef481 100644 --- a/setup/manageheader.php +++ b/setup/manageheader.php @@ -213,10 +213,12 @@ $detected .= '' . lang('Analysis') . ''. "\n"; $supported_db = array(); + $default_db_ports = array(); if(extension_loaded('mysql') || function_exists('mysql_connect')) { $detected .= lang('You appear to have MySQL support enabled') . '
' . "\n"; $supported_db[] = 'mysql'; + $default_db_ports['mysql'] = '3306'; } else { @@ -226,6 +228,7 @@ { $detected .= lang('You appear to have PostgreSQL support enabled') . '
' . "\n"; $supported_db[] = 'pgsql'; + $default_db_ports['pgsql'] = '5432'; } else { @@ -235,6 +238,7 @@ { $detected .= lang('You appear to have Microsoft SQL Server support enabled') . '
' . "\n"; $supported_db[] = 'mssql'; + $default_db_ports['mssql'] = '1433'; } else { @@ -244,6 +248,7 @@ { $detected .= lang('You appear to have Oracle V8 (OCI) support enabled') . '
' . "\n"; $supported_db[] = 'oracle'; + $default_db_ports['oracle'] = '1521'; } else { @@ -251,6 +256,7 @@ { $detected .= lang('You appear to have Oracle support enabled') . '
' . "\n"; $supported_db[] = 'oracle'; + $default_db_ports['oracle'] = '1521'; } else { @@ -283,6 +289,14 @@ $supported_sessions_type[] = 'php4'; } + @reset($default_db_ports); + $js_default_db_ports = 'var default_db_ports = new Array();'."\n"; + while(list($k,$v) = @each($default_db_ports)) + { + $js_default_db_ports .= ' default_db_ports["'.$k.'"]="'.$v.'";'."\n"; + } + $setup_tpl->set_var('js_default_db_ports',$js_default_db_ports); + /* if(extension_loaded('xml') || function_exists('xml_parser_create')) { @@ -310,6 +324,7 @@ $setup_tpl->set_var('lang_delete',lang('Delete')); $setup_tpl->set_var('db_domain','default'); $setup_tpl->set_var('db_host','localhost'); + $setup_tpl->set_var('db_port','3306'); $setup_tpl->set_var('db_name','egroupware'); $setup_tpl->set_var('db_user','egroupware'); $setup_tpl->set_var('db_pass','your_password'); @@ -356,6 +371,7 @@ $setup_tpl->set_var('lang_delete',lang('Delete')); $setup_tpl->set_var('db_domain',$key); $setup_tpl->set_var('db_host',$GLOBALS['phpgw_domain'][$key]['db_host']); + $setup_tpl->set_var('db_port',$GLOBALS['phpgw_domain'][$key]['db_port']); $setup_tpl->set_var('db_name',$GLOBALS['phpgw_domain'][$key]['db_name']); $setup_tpl->set_var('db_user',$GLOBALS['phpgw_domain'][$key]['db_user']); $setup_tpl->set_var('db_pass',$GLOBALS['phpgw_domain'][$key]['db_pass']); @@ -414,6 +430,7 @@ $setup_tpl->set_var('lang_delete',lang('Delete')); $setup_tpl->set_var('db_domain','default'); $setup_tpl->set_var('db_host','localhost'); + $setup_tpl->set_var('db_port','3306'); $setup_tpl->set_var('db_name','egroupware'); $setup_tpl->set_var('db_user','egroupware'); $setup_tpl->set_var('db_pass','your_password'); @@ -557,6 +574,8 @@ $setup_tpl->set_var('lang_adminpass',lang('Admin password to header manager')); $setup_tpl->set_var('lang_dbhost',lang('DB Host')); $setup_tpl->set_var('lang_dbhostdescr',lang('Hostname/IP of database server')); + $setup_tpl->set_var('lang_dbport',lang('DB Port')); + $setup_tpl->set_var('lang_dbportdescr',lang('TCP port number of database server')); $setup_tpl->set_var('lang_dbname',lang('DB Name')); $setup_tpl->set_var('lang_dbnamedescr',lang('Name of database')); $setup_tpl->set_var('lang_dbuser',lang('DB User')); diff --git a/setup/templates/default/manageheader.tpl b/setup/templates/default/manageheader.tpl index f44bb3f352..b0756cae2a 100644 --- a/setup/templates/default/manageheader.tpl +++ b/setup/templates/default/manageheader.tpl @@ -1,5 +1,21 @@ + + - +   + + + + + + + + @@ -109,14 +137,6 @@ - - - -
@@ -8,7 +24,7 @@
{lang_settings}
{lang_serverroot} @@ -97,9 +113,21 @@
{lang_domain}:   {lang_delete}
{lang_dbtype}
+ +
{lang_whichdb}
{lang_dbhost}
{lang_dbhostdescr}
{lang_dbport}
{lang_dbportdescr}
{lang_dbname}
{lang_dbnamedescr}
{lang_dbpass}
{lang_dbpassdescr}
{lang_dbtype}
- -
{lang_whichdb}
{lang_configpass}
{lang_passforconfig}