Added support for specifying the database port number

This commit is contained in:
shrykedude 2003-12-08 04:50:23 +00:00
parent b8d36e17c2
commit f17337d3b7
13 changed files with 107 additions and 22 deletions

View File

@ -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 @@
*/<!-- BEGIN domain -->
$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}',

View File

@ -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'];

View File

@ -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)

View File

@ -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 )
{

View File

@ -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.");

View File

@ -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;

View File

@ -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

View File

@ -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;

View File

@ -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'];

View File

@ -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;

View File

@ -88,6 +88,7 @@ datetime port.<br>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

View File

@ -213,10 +213,12 @@
$detected .= '<tr class="th"><td colspan="2">' . lang('Analysis') . '</td></tr><tr><td colspan="2">'. "\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') . '<br>' . "\n";
$supported_db[] = 'mysql';
$default_db_ports['mysql'] = '3306';
}
else
{
@ -226,6 +228,7 @@
{
$detected .= lang('You appear to have PostgreSQL support enabled') . '<br>' . "\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') . '<br>' . "\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') . '<br>' . "\n";
$supported_db[] = 'oracle';
$default_db_ports['oracle'] = '1521';
}
else
{
@ -251,6 +256,7 @@
{
$detected .= lang('You appear to have Oracle support enabled') . '<br>' . "\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'));

View File

@ -1,5 +1,21 @@
<!-- BEGIN manageheader -->
<script language="JavaScript" type="text/javascript">
<!--
{js_default_db_ports}
function setDefaultDBPort(selectBox,portField)
{
//alert("select: " + selectBox + "; portField: " + portField);
if(selectBox.selectedIndex != -1 && selectBox.options[selectBox.selectedIndex].value)
{
//alert("value = " + selectBox.options[selectBox.selectedIndex].value);
portField.value = default_db_ports[selectBox.options[selectBox.selectedIndex].value];
}
return false;
}
//-->
</script>
<table border="0" width="90%" cellspacing="0" cellpadding="0" align="center">
<tbody><tr><td>
@ -8,7 +24,7 @@
<tr class="th">
<th colspan="2">{lang_settings}</th>
</tr>
<form action="manageheader.php" method="post">
<form name="domain_settings" action="manageheader.php" method="post">
<input type="hidden" name="setting[write_config]" value="true">
<tr>
<td colspan="2"><b>{lang_serverroot}</b>
@ -97,9 +113,21 @@
<tr class="th">
<td>{lang_domain}:</td>&nbsp;<td><input name="domains[{db_domain}]" value="{db_domain}">&nbsp;&nbsp;<input type="checkbox" name="deletedomain[{db_domain}]">&nbsp;<font color="fefefe">{lang_delete}</font></td>
</tr>
<tr>
<td><b>{lang_dbtype}</b><br>
<select name="setting_{db_domain}[db_type]" onchange="setDefaultDBPort(this,this.form['setting_{db_domain}[db_port]']);">
{dbtype_options}
</select>
</td>
<td>{lang_whichdb}</td>
</tr>
<tr>
<td><b>{lang_dbhost}</b><br><input type="text" name="setting_{db_domain}[db_host]" value="{db_host}"></td><td>{lang_dbhostdescr}</td>
</tr>
<tr>
<tr>
<td><b>{lang_dbport}</b><br><input type="text" name="setting_{db_domain}[db_port]" value="{db_port}"></td><td>{lang_dbportdescr}</td>
</tr>
<tr>
<td><b>{lang_dbname}</b><br><input type="text" name="setting_{db_domain}[db_name]" value="{db_name}"></td><td>{lang_dbnamedescr}</td>
</tr>
@ -109,14 +137,6 @@
<tr>
<td><b>{lang_dbpass}</b><br><input type="text" name="setting_{db_domain}[db_pass]" value="{db_pass}"></td><td>{lang_dbpassdescr}</td>
</tr>
<tr>
<td><b>{lang_dbtype}</b><br>
<select name="setting_{db_domain}[db_type]">
{dbtype_options}
</select>
</td>
<td>{lang_whichdb}</td>
</tr>
<tr>
<td><b>{lang_configpass}</b><br><input type="text" name="setting_{db_domain}[config_pass]" value="{config_pass}"></td>
<td>{lang_passforconfig}</td>