phpGroupWare version '.$phpgw_info["server"]["version"].' setup '; if ($nologoutbutton) { echo " "; } else { echo 'Logout '; } echo "
"; } function loginForm($err="") { global $phpgw_info, $phpgw_domain, $SetupDomain, $SetupPW, $PHP_SELF; echo "

\n"; echo "\n"; echo " \n"; echo " \n"; echo " \n"; if ($err != "") { echo " \n"; } echo " \n"; echo " \n"; echo " \n"; echo "
 Setup Login
".$err."
\n"; if (count($phpgw_domain) > 1){ echo " \n"; echo "
Domain:
Password:
\n"; }else{ reset($phpgw_domain); $default_domain = each($phpgw_domain); echo " \n"; echo " \n"; } echo " \n"; echo "
\n"; echo "\n"; } function check_header() { global $phpgw_domain, $phpgw_info, $stage, $header_msg; if(!file_exists("../header.inc.php") || !is_file("../header.inc.php")) { $stage = 1.1; $header_msg = "Stage One"; }else{ include("../header.inc.php"); if (!isset($phpgw_domain) || $phpgw_info["server"]["header_version"] != $phpgw_info["server"]["current_header_version"]) { $stage = 1.2; $header_msg = "Stage One (Upgrade your header.inc.php)"; }else{ /* header.inc.php part settled. Moving to authentication */ $stage = 1.3; $header_msg = "Stage One (Completed)"; } } } function generate_header(){ Global $SCRIPT_FILENAME, $HTTP_POST_VARS, $k, $v; $ftemplate = fopen(dirname($SCRIPT_FILENAME)."/../header.inc.php.template","r"); if($ftemplate){ $ftemplate = fopen(dirname($SCRIPT_FILENAME)."/../header.inc.php.template","r"); $template = fread($ftemplate,filesize(dirname($SCRIPT_FILENAME)."/../header.inc.php.template")); fclose($ftemplate); while(list($k,$v) = each($HTTP_POST_VARS)) { $template = ereg_replace("__".strtoupper($k)."__",$v,$template); } return $template; }else{ echo "Could not open the header template for reading!
"; exit; } } function auth() { global $phpgw_domain, $FormLogout, $FormDomain, $FormPW, $SetupPW, $SetupDomain, $db, $HTTP_POST_VARS, $login_msg; if (isset($FormLogout)) { setcookie("SetupPW"); // scrub the old one setcookie("SetupDomain"); // scrub the old one $login_msg = "You have sucessfully logged out"; return False; } elseif (isset($SetupPW)) { if ($SetupPW != $phpgw_domain[$SetupDomain]["config_passwd"]) { setcookie("SetupPW"); // scrub the old one setcookie("SetupDomain"); // scrub the old one $login_msg = "Invalid session cookie (cookies must be enabled)"; return False; }else{ return True; } } elseif (isset($FormPW)) { if ($FormPW == $phpgw_domain[$FormDomain]["config_passwd"]) { setcookie("SetupPW",$FormPW); setcookie("SetupDomain",$FormDomain); $SetupDomain = $FormDomain; return True; }else{ $login_msg = "Invalid password"; return False; } } else { return False; } } function loaddb() { global $phpgw_info, $phpgw_domain, $SetupDomain, $db; /* Database setup */ $phpgw_info["server"]["api_dir"] = $phpgw_info["server"]["include_root"]."/phpgwapi"; include($phpgw_info["server"]["api_dir"] . "/phpgw_db_".$phpgw_domain[$SetupDomain]["db_type"].".inc.php"); $db = new db; $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"]; } function check_db() { global $phpgw_info, $oldversion, $db, $stage, $header_msg; $db->Halt_On_Error = "no"; $tables = $db->table_names(); if (is_array($tables) && count($tables) > 0){ /* tables exists. checking for post beta version */ $db->query("select app_version from applications where app_name='admin'"); $db->next_record(); $oldversion = $db->f("app_version"); if (isset($oldversion)){ if ($oldversion == $phpgw_info["server"]["version"]){ $db->query("select config_value from config where config_name='freshinstall'"); $db->next_record(); $configed = $db->f("config_value"); if ($configed){ $stage = 3.1; $header_msg = "Stage 3 (Needs Configuration)"; }else{ $stage = 3.2; $header_msg = "Stage 3 (Configuration OK)"; } }else{ $stage = 2.4; $header_msg = "Stage 2 (Tables need upgrading)"; } }else{ $stage = 2.2; $header_msg = "Stage 2 (Tables appear to be pre-beta)"; } }else{ /* no tables, so checking if we can create them */ /* I cannot get either to work properly $isdb = $db->connect("kljkjh", "localhost", "phpgroupware", "phpgr0upwar3"); */ $db_rights = $db->query("CREATE TABLE phpgw_testrights ( testfield varchar(5) NOT NULL )"); if (isset($db_rights)){ //if (isset($isdb)){ $stage = 2.3; $header_msg = "Stage 2 (Create tables)"; }else{ $stage = 2.1; $header_msg = "Stage 2 (Create Database)"; } $db->query("DROP TABLE phpgw_testrights"); } } ?>