'."\n";
if ($phpgw_info['setup']['stage']['header'] == '10'){
echo ' '."\n";
echo ' Setup/Config Admin Login | '."\n";
echo '
'."\n";
echo ' '.$phpgw_info['setup']['ConfigLoginMSG'].' |
'."\n";
echo ' '."\n";
echo ' | '."\n";
echo '
'."\n";
}
echo ' '."\n";
echo ' Header Admin Login | '."\n";
echo '
'."\n";
echo ' '.$phpgw_info['setup']['HeaderLoginMSG'].' |
'."\n";
echo ' '."\n";
echo ' | '."\n";
echo '
'."\n";
echo '
'."\n";
echo ''."\n";
}
function check_header()
{
global $phpgw_domain, $phpgw_info;
if(!file_exists("../header.inc.php")) {
$phpgw_info["setup"]["header_msg"] = "Stage One";
return "1";
}else{
if (!isset($phpgw_info["server"]["header_admin_password"])){
$phpgw_info["setup"]["header_msg"] = "Stage One (No header admin password set)";
return "2";
}elseif (!isset($phpgw_domain)) {
$phpgw_info["setup"]["header_msg"] = "Stage One (Upgrade your header.inc.php)";
return "3";
}elseif ($phpgw_info["server"]["versions"]["header"] != $phpgw_info["server"]["versions"]["current_header"]) {
$phpgw_info["setup"]["header_msg"] = "Stage One (Upgrade your header.inc.php)";
return "3";
}
}
/* header.inc.php part settled. Moving to authentication */
$phpgw_info["setup"]["header_msg"] = "Stage One (Completed)";
return "10";
}
function generate_header()
{
global $setting, $phpgw_setup, $phpgw_info, $header_template;
$header_template->set_file(array("header" => "header.inc.php.template"));
while(list($k,$v) = each($setting)) {
$header_template->set_var(strtoupper($k),$v);
}
return $header_template->parse("out","header");
}
function auth($auth_type = "Config")
{
global $phpgw_domain, $phpgw_info, $HTTP_POST_VARS, $FormLogout, $ConfigLogin, $HeaderLogin, $FormDomain, $FormPW, $ConfigDomain, $ConfigPW, $HeaderPW;
if (isset($FormLogout)) {
if ($FormLogout == "config"){
setcookie("ConfigPW"); // scrub the old one
setcookie("ConfigDomain"); // scrub the old one
$phpgw_info["setup"]["ConfigLoginMSG"] = "You have sucessfully logged out";
return False;
}elseif($FormLogout == "header"){
setcookie("HeaderPW"); // scrub the old one
$phpgw_info["setup"]["HeaderLoginMSG"] = "You have sucessfully logged out";
return False;
}
} elseif (isset($ConfigPW)) {
if ($ConfigPW != $phpgw_domain[$ConfigDomain]["config_passwd"] && $auth_type == "Config") {
setcookie("ConfigPW"); // scrub the old one
setcookie("ConfigDomain"); // scrub the old one
$phpgw_info["setup"]["ConfigLoginMSG"] = "Invalid session cookie (cookies must be enabled)";
return False;
}else{
return True;
}
} elseif (isset($FormPW)) {
if (isset($ConfigLogin)){
if ($FormPW == $phpgw_domain[$FormDomain]["config_passwd"] && $auth_type == "Config") {
setcookie("HeaderPW"); // scrub the old one
setcookie("ConfigPW",$FormPW);
setcookie("ConfigDomain",$FormDomain);
$ConfigDomain = $FormDomain;
return True;
}else{
$phpgw_info["setup"]["ConfigLoginMSG"] = "Invalid password";
return False;
}
}elseif (isset($HeaderLogin)){
if ($FormPW == $phpgw_info["server"]["header_admin_password"] && $auth_type == "Header") {
setcookie("HeaderPW",$FormPW);
return True;
}else{
$phpgw_info["setup"]["HeaderLoginMSG"] = "Invalid password";
return False;
}
}
} elseif (isset($HeaderPW)) {
if ($HeaderPW != $phpgw_info["server"]["header_admin_password"] && $auth_type == "Header") {
setcookie("HeaderPW"); // scrub the old one
$phpgw_info["setup"]["HeaderLoginMSG"] = "Invalid session cookie (cookies must be enabled)";
return False;
}else{
return True;
}
} else {
return False;
}
}
function loaddb()
{
global $phpgw_info, $phpgw_domain, $ConfigDomain;
/* Database setup */
if (!isset($phpgw_info["server"]["api_inc"])) {
$phpgw_info["server"]["api_inc"] = PHPGW_SERVER_ROOT . "/phpgwapi/inc";
}
include($phpgw_info["server"]["api_inc"] . "/class.db_".$phpgw_domain[$ConfigDomain]["db_type"].".inc.php");
$this->db = new db;
$this->db->Host = $phpgw_domain[$ConfigDomain]["db_host"];
$this->db->Type = $phpgw_domain[$ConfigDomain]["db_type"];
$this->db->Database = $phpgw_domain[$ConfigDomain]["db_name"];
$this->db->User = $phpgw_domain[$ConfigDomain]["db_user"];
$this->db->Password = $phpgw_domain[$ConfigDomain]["db_pass"];
// $phpgw_schema_proc = new phpgw_schema_proc($phpgw_domain[$ConfigDomain]["db_type"]);
}
// This is a php3/4 compliant in_array(), used only below in check_db() so far
function isinarray($needle,$haystack='')
{
if($haystack == '')
{
settype($haystack,'array');
$haystack = Array();
}
for($i=0;$i