- completely reworked HTML code in setup.php
- moved admin creation code from create_admin.php to functions.php,
function create_admin
- several related changes in functions.inc.php:
- use table_by_key() directly instead of the cached variables (which
are empty if config.inc.php was not read before functions.php)
- add an additional (optional) parameter $setup to db_connect, changed
many die(msg) calls to $error_message .= msg.
If $setup is given, the return value is array($link, $error_text)
instead of $link
- db_connect now checks for invalid $CONF['database_type']
git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@135 a1433add-5e2c-0410-b055-b7f2511e0802
print "<p/>DEBUG INFORMATION:<br/>MySQL 3.x / 4.0 functions not available!<br/>database_type = 'mysql' in config.inc.php, are you using a different database? $DEBUG_TEXT";
$error_text .= "<p/>DEBUG INFORMATION:<br/>MySQL 3.x / 4.0 functions not available!<br/>database_type = 'mysql' in config.inc.php, are you using a different database? $DEBUG_TEXT";
die();
}
}
}
}
elseif ($CONF['database_type'] == "mysqli")
if ($CONF['database_type'] == "mysqli")
{
{
if (function_exists ("mysqli_connect"))
if (function_exists ("mysqli_connect"))
{
{
$link = @mysqli_connect ($CONF['database_host'], $CONF['database_user'], $CONF['database_password']) or die ("<p/>DEBUG INFORMATION:<br/>Connect: " . mysqli_connect_error () . "$DEBUG_TEXT");
print "<p/>DEBUG INFORMATION:<br/>MySQL 4.1 functions not available!<br/>database_type = 'mysqli' in config.inc.php, are you using a different database? $DEBUG_TEXT";
$error_text .= "<p/>DEBUG INFORMATION:<br/>MySQL 4.1 functions not available!<br/>database_type = 'mysqli' in config.inc.php, are you using a different database? $DEBUG_TEXT";
$link = @pg_pconnect ($connect_string) or die ("<p/>DEBUG INFORMATION:<br/>Connect: failed to connect to database. $DEBUG_TEXT");
$link = @pg_pconnect ($connect_string) or $error_text .= ("<p/>DEBUG INFORMATION:<br/>Connect: failed to connect to database. $DEBUG_TEXT");
pg_set_client_encoding($link, 'UNICODE');
if ($link) pg_set_client_encoding($link, 'UNICODE');
}
}
else
else
{
{
print "<p/>DEBUG INFORMATION:<br/>PostgreSQL functions not available!<br/>database_type = 'pgsql' in config.inc.php, are you using a different database? $DEBUG_TEXT";
$error_text .= "<p/>DEBUG INFORMATION:<br/>PostgreSQL functions not available!<br/>database_type = 'pgsql' in config.inc.php, are you using a different database? $DEBUG_TEXT";
die();
}
}
}
}
else
{
$error_text = "<p/>DEBUG INFORMATION:<br/>Invalid \$CONF['database_type']! Please fix your config.inc.php! $DEBUG_TEXT";
}
if ($link)
if ($setup)
{
return array($link, $error_text);
}
elseif ($error_text != "")
{
print $error_text;
die();
}
elseif ($link)
{
{
return $link;
return $link;
}
}
@ -1846,6 +1866,106 @@ function gen_show_status ($show_alias)
return $stat_string;
return $stat_string;
}
}
/*
Called by create-admin.php and setup.php
Returns:
array(
'error' => 0, # 0 on success, otherwise > 0
'tMessage' => '', # success / failure message
'pAdminCreate_admin_username_text' => '', # help text / error message for username
'pAdminCreate_admin_password_text' => '' # error message for username
)
*/
function create_admin($fUsername, $fPassword, $fPassword2, $fDomains, $no_generate_password=0)