2000-09-28 16:28:34 +02:00
|
|
|
<?php
|
|
|
|
/**************************************************************************\
|
2000-11-05 07:47:24 +01:00
|
|
|
* phpGroupWare - Setup *
|
2000-09-28 16:28:34 +02:00
|
|
|
* http://www.phpgroupware.org *
|
|
|
|
* -------------------------------------------- *
|
|
|
|
* This program is free software; you can redistribute it and/or modify it *
|
|
|
|
* under the terms of the GNU General Public License as published by the *
|
|
|
|
* Free Software Foundation; either version 2 of the License, or (at your *
|
|
|
|
* option) any later version. *
|
|
|
|
\**************************************************************************/
|
|
|
|
|
|
|
|
/* $Id$ */
|
|
|
|
|
|
|
|
// Include to check user authorization against the
|
|
|
|
// password in ../header.inc.php to protect all of the setup
|
|
|
|
// pages from unauthorized use.
|
2000-11-21 18:56:56 +01:00
|
|
|
|
2000-11-17 16:49:03 +01:00
|
|
|
function setup_header($title = "")
|
2000-11-17 16:04:04 +01:00
|
|
|
{
|
2000-11-19 11:49:31 +01:00
|
|
|
global $phpgw_info;
|
2000-11-17 16:04:04 +01:00
|
|
|
|
2000-11-19 11:49:31 +01:00
|
|
|
echo '<title>phpGroupWare setup ' . $title . '</title><BODY BGCOLOR="FFFFFF" margintop="0" marginleft="0" '
|
|
|
|
. 'marginright="0" marginbottom="0"><table border="0" width="100%"><tr>'
|
|
|
|
. '<td align="left" bgcolor="486591"> <font color="fefefe">phpGroupWare version '
|
2000-11-21 18:56:56 +01:00
|
|
|
. $phpgw_info["server"]["version"] . ' setup</font></td><td align="right" bgcolor="486591">';
|
|
|
|
echo "<form action='".$PHP_SELF."' method='POST'>\n";
|
|
|
|
echo " <input type='hidden' name='FormLogout' value='True'>\n";
|
|
|
|
echo " <input type='submit' name='Logout' value='Logout'>\n";
|
|
|
|
echo " </form>\n";
|
|
|
|
echo "</td></tr></table>";
|
2000-11-17 16:04:04 +01:00
|
|
|
}
|
2000-09-28 16:28:34 +02:00
|
|
|
|
2000-11-17 16:49:03 +01:00
|
|
|
function loginForm($err="")
|
|
|
|
{
|
2000-11-21 18:56:56 +01:00
|
|
|
global $phpgw_info, $phpgw_domain, $SetupDomain, $SetupPW, $PHP_SELF;
|
2000-11-17 16:49:03 +01:00
|
|
|
|
2000-11-21 16:20:01 +01:00
|
|
|
setup_header("Please login");
|
2000-11-19 11:49:31 +01:00
|
|
|
echo "<p><body bgcolor='#ffffff'>\n";
|
|
|
|
echo "<table border=\"0\" align=\"center\">\n";
|
|
|
|
echo " <tr bgcolor=\"486591\">\n";
|
|
|
|
echo " <td colspan=\"2\"><font color=\"fefefe\"> <b>Setup Login</b></font></td>\n";
|
|
|
|
echo " </tr>\n";
|
|
|
|
if ($err != "") {
|
|
|
|
echo " <tr bgcolor='#e6e6e6'><td colspan='2'><font color='#ff0000'>".$err."</font></td></tr>\n";
|
|
|
|
}
|
|
|
|
echo " <tr bgcolor=\"e6e6e6\">\n";
|
|
|
|
echo " <td><form action='".$PHP_SELF."' method='POST'>\n";
|
2000-11-21 16:20:01 +01:00
|
|
|
if (count($phpgw_domain) > 1){
|
2000-11-19 17:09:10 +01:00
|
|
|
echo " <table><tr><td>Domain: </td><td><input type='text' name='FormDomain' value=''></td></tr>\n";
|
2000-11-19 11:49:31 +01:00
|
|
|
echo " <tr><td>Password: </td><td><input type='password' name='FormPW' value=''></td></tr></table>\n";
|
|
|
|
}else{
|
2000-11-19 11:22:15 +01:00
|
|
|
echo " <input type='password' name='FormPW' value=''>\n";
|
2000-11-21 16:20:01 +01:00
|
|
|
echo " <input type='hidden' name='FormDomain' value='".$phpgw_info["server"]["default_domain"]."'>\n";
|
2000-11-19 11:49:31 +01:00
|
|
|
}
|
|
|
|
echo " <input type='submit' name='Login' value='Login'>\n";
|
|
|
|
echo " </form></td>\n";
|
|
|
|
echo " </tr>\n";
|
|
|
|
echo "</table>\n";
|
|
|
|
echo "</body></html>\n";
|
2000-11-17 16:49:03 +01:00
|
|
|
}
|
2000-09-28 16:28:34 +02:00
|
|
|
|
2000-11-21 18:56:56 +01:00
|
|
|
if (!isset($phpgw_domain)) {
|
|
|
|
setup_header("Upgrade your header.inc.php");
|
|
|
|
echo "<br><b>You will need to upgrade your header.inc.php before you can continue with this setup</b>";
|
|
|
|
exit;
|
|
|
|
}
|
2000-11-21 16:20:01 +01:00
|
|
|
reset($phpgw_domain);
|
|
|
|
$default_domain = each($phpgw_domain);
|
|
|
|
$phpgw_info["server"]["default_domain"] = $default_domain[0];
|
|
|
|
unset ($default_domain); // we kill this for security reasons
|
|
|
|
|
2000-11-21 18:56:56 +01:00
|
|
|
if (isset($FormLogout)) {
|
|
|
|
setcookie("SetupPW"); // scrub the old one
|
|
|
|
setcookie("SetupDomain"); // scrub the old one
|
|
|
|
loginForm("You have sucessfully logged out");
|
|
|
|
exit;
|
|
|
|
} elseif (isset($SetupPW)) {
|
|
|
|
if ($SetupPW != $phpgw_domain[$SetupDomain]["config_passwd"]) {
|
|
|
|
setcookie("SetupPW"); // scrub the old one
|
|
|
|
setcookie("SetupDomain"); // scrub the old one
|
|
|
|
loginForm("Invalid session cookie (cookies must be enabled)");
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
} elseif (isset($FormPW)) {
|
2000-11-21 16:20:01 +01:00
|
|
|
if ($FormPW == $phpgw_domain[$FormDomain]["config_passwd"]) {
|
2000-11-21 18:56:56 +01:00
|
|
|
setcookie("SetupPW",$FormPW);
|
|
|
|
setcookie("SetupDomain",$FormDomain);
|
|
|
|
$SetupDomain = $FormDomain;
|
2000-11-19 11:49:31 +01:00
|
|
|
}else{
|
2000-11-21 16:20:01 +01:00
|
|
|
loginForm("Invalid password.");
|
|
|
|
exit;
|
2000-11-19 11:49:31 +01:00
|
|
|
}
|
2000-11-17 16:49:03 +01:00
|
|
|
} else {
|
2000-11-19 11:49:31 +01:00
|
|
|
loginForm();
|
|
|
|
exit;
|
2000-09-28 16:28:34 +02:00
|
|
|
}
|
2000-11-21 18:56:56 +01:00
|
|
|
|
2000-11-21 16:20:01 +01:00
|
|
|
/* Database setup */
|
2000-11-21 18:56:56 +01:00
|
|
|
include($phpgw_info["server"]["api_dir"] . "/phpgw_db_".$phpgw_domain[$SetupDomain]["db_type"].".inc.php");
|
2000-11-21 16:20:01 +01:00
|
|
|
$db = new db;
|
2000-11-21 18:56:56 +01:00
|
|
|
$db->Host = $phpgw_domain[$SetupDomain]["db_host"];
|
|
|
|
$db->Type = $phpgw_domain[$SetupDomain]["db_type"];
|
|
|
|
$db->Database = $phpgw_domain[$SetupDomain]["db_name"];
|
|
|
|
$db->User = $phpgw_domain[$SetupDomain]["db_user"];
|
|
|
|
$db->Password = $phpgw_domain[$SetupDomain]["db_pass"];
|
2000-11-20 19:23:16 +01:00
|
|
|
?>
|