\n\n"; echo " phpGroupWare Setup"; if ($title != ""){echo " - ".$title;}; echo "\n"; echo " \n"; echo "\n"; echo ""; echo ""; echo " "; echo " "; } else { echo "Logout "; } echo "
 phpGroupWare version ".$phpgw_info["server"]["versions"]["phpgwapi"]." setup"; if ($nologoutbutton) { echo " 
"; } function login_form() { global $phpgw_info, $phpgw_domain, $PHP_SELF; echo "

\n"; echo "\n"; if ($phpgw_info["setup"]["stage"]["header"] == 10){ echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; } echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo "
 Setup/Config Admin Login
".$phpgw_info["setup"]["ConfigLoginMSG"]."
\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 "
 Header Admin Login
".$phpgw_info["setup"]["HeaderLoginMSG"]."
\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{ include("../header.inc.php"); 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"; }else{ /* 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($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; } } elseif (isset($FormPW)) { if (isset($ConfigLogin)){ if ($FormPW == $phpgw_domain[$FormDomain]["config_passwd"] && $auth_type == "Config") { 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; } } } 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_info["server"]["server_root"]."/phpgwapi/inc"; } include($phpgw_info["server"]["api_inc"] . "/phpgw_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"]); } function check_db() { global $phpgw_info; $this->db->Halt_On_Error = "no"; $tables = $this->db->table_names(); if (is_array($tables) && count($tables) > 0){ /* tables exists. checking for post beta version */ $this->db->query("select * from applications"); while (@$this->db->next_record()) { if ($this->db->f("app_name") == "admin"){$phpgw_info["setup"]["oldver"]["phpgwapi"] = $this->db->f("app_version");} $phpgw_info["setup"]["oldver"][$this->db->f("app_name")] = $this->db->f("app_version"); $phpgw_info["setup"][$this->db->f("app_name")]["title"] = $this->db->f("app_title"); } if (isset($phpgw_info["setup"]["oldver"]["phpgwapi"])){ if ($phpgw_info["setup"]["oldver"]["phpgwapi"] == $phpgw_info["server"]["versions"]["phpgwapi"]){ $phpgw_info["setup"]["header_msg"] = "Stage 2 (Tables Complete)"; return 10; }else{ $phpgw_info["setup"]["header_msg"] = "Stage 2 (Tables need upgrading)"; return 4; } }else{ $phpgw_info["setup"]["header_msg"] = "Stage 2 (Tables appear to be pre-beta)"; return 2; } }else{ /* no tables, so checking if we can create them */ /* I cannot get either to work properly $isdb = $this->db->connect("kljkjh", "localhost", "phpgroupware", "phpgr0upwar3"); */ $db_rights = $this->db->query("CREATE TABLE phpgw_testrights ( testfield varchar(5) NOT NULL )"); $this->db->query("DROP TABLE phpgw_testrights"); if (isset($db_rights)){ //if (isset($isdb)){ $phpgw_info["setup"]["header_msg"] = "Stage 2 (Create tables)"; return 3; }else{ $phpgw_info["setup"]["header_msg"] = "Stage 2 (Create Database)"; return 1; } } } function check_config() { global $phpgw_info; $this->db->Halt_On_Error = "no"; if ($phpgw_info["setup"]["stage"]["db"] == 10){ $this->db->query("select config_value from config where config_name='freshinstall'"); $this->db->next_record(); $configed = $this->db->f("config_value"); if ($configed){ $phpgw_info["setup"]["header_msg"] = "Stage 3 (Needs Configuration)"; return 1; }else{ $phpgw_info["setup"]["header_msg"] = "Stage 3 (Configuration OK)"; return 10; } } } function app_setups($appname = ""){ global $phpgw_info; $d = dir($phpgw_info["server"]["server_root"]); while($entry=$d->read()) { if (is_dir ($phpgw_info["server"]["server_root"]."/".$entry."/setup")){ echo $entry."
\n"; } } $d->close(); } function execute_script($script, $appname = ""){ global $phpgw_info, $phpgw_domain; if ($appname == ""){ $d = dir($phpgw_info["server"]["server_root"]); while($entry=$d->read()) { $f = $phpgw_info["server"]["server_root"]."/".$entry."/setup/version.inc.php"; if (file_exists ($f)){ include($f); }else{ $phpgw_info["server"]["versions"][$entry] = $phpgw_info["setup"]["currentver"]["phpgwapi"]; } $f = $phpgw_info["server"]["server_root"]."/".$entry."/setup/".$script.".inc.php"; if (file_exists ($f)){include($f);} } $d->close(); }else{ $f = $phpgw_info["server"]["server_root"]."/".$appname."/setup/".$script.".inc.php"; if (file_exists ($f)){include($f);} } } function update_app_version($appname, $tableschanged = True){ global $phpgw_info; if ($tableschanged == True){$phpgw_info["setup"]["tableschanged"] = True;} $this->db->query("update applications set app_version='".$phpgw_info["setup"]["currentver"]["phpgwapi"]."' where app_name='".$appname."'"); } function manage_tables(){ global $phpgw_domain, $phpgw_info; if ($phpgw_info["setup"]["currentver"]["phpgwapi"] == "drop"){ $this->execute_script("droptables"); } if ($phpgw_info["setup"]["currentver"]["phpgwapi"] == "new") { $this->execute_script("newtables"); $this->execute_script("common_default_records"); $this->execute_script("lang"); } if ($phpgw_info["setup"]["currentver"]["phpgwapi"] == "oldversion") { $phpgw_info["setup"]["currentver"]["phpgwapi"] = $phpgw_info["setup"]["oldver"]["phpgwapi"]; $this->execute_script("upgradetables"); } /* Not yet implemented if (!$phpgw_info["setup"]["tableschanged"] == True){ echo " \n"; echo " No table changes were needed. The script only updated your version setting.\n"; echo " \n"; } */ } function setup_header($title = "",$nologoutbutton = False) { global $phpgw_info, $PHP_SELF; // Ok, so it isn't the greatest idea, but it works for now. Setup needs to be rewritten. if ($phpgw_info["setup"]["dontshowtheheaderagain"]) { return False; } $phpgw_info["setup"]["dontshowtheheaderagain"] = True; ?> phpGroupWare setup <?php echo $title; ?>
 phpGroupWare version setup Logout '; } echo "
"; } } ?>