added mutli-domain support. Still have a bug when going to the config page. It will not work for one of my test domains, and Im not sure why

This commit is contained in:
seek3r 2000-11-19 10:49:31 +00:00
parent 561deb921c
commit 36f7b3e13b
3 changed files with 79 additions and 44 deletions

View File

@ -25,11 +25,19 @@
include($phpgw_info["server"]["api_dir"] . "/phpgw_db_".$phpgw_info["server"]["db_type"].".inc.php"); include($phpgw_info["server"]["api_dir"] . "/phpgw_db_".$phpgw_info["server"]["db_type"].".inc.php");
$db = new db; $db = new db;
$db->Host = $phpgw_info["server"]["db_host"]; if ($phpgw_info["multiable_domains"] != True){
$db->Type = $phpgw_info["server"]["db_type"]; $db->Host = $phpgw_info["server"]["db_host"];
$db->Database = $phpgw_info["server"]["db_name"]; $db->Type = $phpgw_info["server"]["db_type"];
$db->User = $phpgw_info["server"]["db_user"]; $db->Database = $phpgw_info["server"]["db_name"];
$db->Password = $phpgw_info["server"]["db_pass"]; $db->User = $phpgw_info["server"]["db_user"];
$db->Password = $phpgw_info["server"]["db_pass"];
}else{
$db->Host = $domains[$SetupDomain]["db_host"];
$db->Type = $domains[$SetupDomain]["db_type"];
$db->Database = $domains[$SetupDomain]["db_name"];
$db->User = $domains[$SetupDomain]["db_user"];
$db->Password = $domains[$SetupDomain]["db_pass"];
}
if ($newsettings["auth_type"] != "ldap") { if ($newsettings["auth_type"] != "ldap") {
setup_header(); setup_header();

View File

@ -17,61 +17,80 @@
function setup_header($title = "") function setup_header($title = "")
{ {
global $phpgw_info; global $phpgw_info;
echo '<title>phpGroupWare setup ' . $title . '</title><BODY BGCOLOR="FFFFFF" margintop="0" marginleft="0" ' echo '<title>phpGroupWare setup ' . $title . '</title><BODY BGCOLOR="FFFFFF" margintop="0" marginleft="0" '
. 'marginright="0" marginbottom="0"><table border="0" width="100%"><tr>' . 'marginright="0" marginbottom="0"><table border="0" width="100%"><tr>'
. '<td align="left" bgcolor="486591">&nbsp;<font color="fefefe">phpGroupWare version ' . '<td align="left" bgcolor="486591">&nbsp;<font color="fefefe">phpGroupWare version '
. $phpgw_info["server"]["version"] . ' setup</font></td></tr></table>'; . $phpgw_info["server"]["version"] . ' setup</font></td></tr></table>';
} }
function loginForm($err="") function loginForm($err="")
{ {
global $PHP_SELF; global $phpgw_info, $domain, $PHP_SELF;
setup_header("Please login"); setup_header("Please login");
echo "<p><body bgcolor='#ffffff'>\n"; echo "<p><body bgcolor='#ffffff'>\n";
echo "<table border=\"0\" align=\"center\">\n"; echo "<table border=\"0\" align=\"center\">\n";
echo " <tr bgcolor=\"486591\">\n"; echo " <tr bgcolor=\"486591\">\n";
echo " <td colspan=\"2\"><font color=\"fefefe\">&nbsp;<b>Setup Login</b></font></td>\n"; echo " <td colspan=\"2\"><font color=\"fefefe\">&nbsp;<b>Setup Login</b></font></td>\n";
echo " </tr>\n"; echo " </tr>\n";
if ($err != "") { if ($err != "") {
echo " <tr bgcolor='#e6e6e6'><td colspan='2'><font color='#ff0000'>".$err."</font></td></tr>\n"; echo " <tr bgcolor='#e6e6e6'><td colspan='2'><font color='#ff0000'>".$err."</font></td></tr>\n";
} }
echo " <tr bgcolor=\"e6e6e6\">\n"; echo " <tr bgcolor=\"e6e6e6\">\n";
echo " <td><form action='".$PHP_SELF."' method='POST'>\n"; echo " <td><form action='".$PHP_SELF."' method='POST'>\n";
if ($phpgw_info["multiable_domains"] == True){ if ($phpgw_info["multiable_domains"] == True){
echo " <input type='text' name='domain' value=''><br>\n"; echo " <table><tr><td>Domain: </td><td><input type='text' name='domain' value=''></td></tr>\n";
echo " <input type='password' name='FormPW' value=''><br>\n"; echo " <tr><td>Password: </td><td><input type='password' name='FormPW' value=''></td></tr></table>\n";
}else{ }else{
echo " <input type='password' name='FormPW' value=''>\n"; echo " <input type='password' name='FormPW' value=''>\n";
} }
echo " <input type='submit' name='Login' value='Login'>\n"; echo " <input type='submit' name='Login' value='Login'>\n";
echo " </form></td>\n"; echo " </form></td>\n";
echo " </tr>\n"; echo " </tr>\n";
echo "</table>\n"; echo "</table>\n";
echo "</body></html>\n"; echo "</body></html>\n";
} }
if (isset($FormPW)) { if (isset($FormPW)) {
if ($FormPW != $phpgw_info["server"]["config_passwd"]) { if ($phpgw_info["multiable_domains"] == True){
if ($FormPW != $domains[$domain]["config_passwd"]) {
loginForm("Invalid password."); loginForm("Invalid password.");
exit; exit;
} }
// Valid login, fall through and set the cookie }else{
$SetupCookie = $FormPW; if ($FormPW != $phpgw_info["server"]["config_passwd"]) {
loginForm("Invalid password.");
exit;
}
}
// Valid login, fall through and set the cookie
$SetupCookie = $FormPW;
} else if (isset($SetupCookie)) { } else if (isset($SetupCookie)) {
if ($SetupCookie != $phpgw_info["server"]["config_passwd"]) { if ($phpgw_info["multiable_domains"] == True){
if ($SetupCookie != $domains[$SetupDomain]["config_passwd"]) {
setcookie("SetupCookie",""); // scrub the old one
setcookie("SetupDomain",""); // scrub the old one
loginForm("Invalid session cookie (cookies must be enabled)");
exit;
}
}else{
if ($SetupCookie != $phpgw_info["server"]["config_passwd"]) {
setcookie("SetupCookie",""); // scrub the old one setcookie("SetupCookie",""); // scrub the old one
loginForm("Invalid session cookie (cookies must be enabled)"); loginForm("Invalid session cookie (cookies must be enabled)");
exit; exit;
} }
}
} else { } else {
loginForm(); loginForm();
exit; exit;
} }
// Auth ok. // Auth ok.
setcookie("SetupCookie","$SetupCookie"); setcookie("SetupCookie","$SetupCookie");
if ($phpgw_info["multiable_domains"] == True){
setcookie("SetupDomain","$domain");
}
?> ?>

View File

@ -42,11 +42,19 @@
} }
$db = new db; $db = new db;
$db->Host = $phpgw_info["server"]["db_host"]; if ($phpgw_info["multiable_domains"] != True){
$db->Type = $phpgw_info["server"]["db_type"]; $db->Host = $phpgw_info["server"]["db_host"];
$db->Database = $phpgw_info["server"]["db_name"]; $db->Type = $phpgw_info["server"]["db_type"];
$db->User = $phpgw_info["server"]["db_user"]; $db->Database = $phpgw_info["server"]["db_name"];
$db->Password = $phpgw_info["server"]["db_pass"]; $db->User = $phpgw_info["server"]["db_user"];
$db->Password = $phpgw_info["server"]["db_pass"];
}else{
$db->Host = $domains[$SetupDomain]["db_host"];
$db->Type = $domains[$SetupDomain]["db_type"];
$db->Database = $domains[$SetupDomain]["db_name"];
$db->User = $domains[$SetupDomain]["db_user"];
$db->Password = $domains[$SetupDomain]["db_pass"];
}
// $db->Halt_On_Error = "report"; // $db->Halt_On_Error = "report";
$db->Halt_On_Error = "no"; $db->Halt_On_Error = "no";