diff --git a/header.inc.php.template b/header.inc.php.template index 6eff2868a8..62c0ec8fb4 100644 --- a/header.inc.php.template +++ b/header.inc.php.template @@ -30,6 +30,7 @@ $phpgw_info["server"]["server_root"] = "{SERVER_ROOT}"; $phpgw_info["server"]["include_root"] = "{INCLUDE_ROOT}"; + $phpgw_info["server"]["header_admin_password"] = "{HEADER_ADMIN_PASSWORD}"; $phpgw_domain["default"] = array ( "db_host" => "{DB_HOST}", @@ -80,7 +81,7 @@ \**************************************************************************/ $phpgw_info["server"]["api_inc"] = $phpgw_info["server"]["include_root"]."/phpgwapi/inc"; include($phpgw_info["server"]["server_root"]."/version.inc.php"); - $phpgw_info["server"]["versions"]["header"] = "1.8"; + $phpgw_info["server"]["versions"]["header"] = "1.9"; // This is a fix for NT if (!isset($phpgw_info["flags"]["noapi"]) || !$phpgw_info["flags"]["noapi"] == True){ diff --git a/setup/createheader.php b/setup/createheader.php index f53f869dd8..4cef9c43b4 100644 --- a/setup/createheader.php +++ b/setup/createheader.php @@ -3,9 +3,21 @@ include("./inc/functions.inc.php"); include("../version.inc.php"); - /* processing and discovery phase */ + /* authentication phase */ + $phpgw_info["setup"]["stage"]["header"] = $phpgw_setup->check_header(); + if ( $phpgw_info["setup"]["stage"]["header"] == 2){ + $phpgw_setup->show_header("Please set your header admin password",True); + }elseif ( $phpgw_info["setup"]["stage"]["header"] == 10){ + if (!$phpgw_setup->auth("Config")){ + $phpgw_setup->show_header("Please login",True); + $phpgw_setup->login_form(); + exit; + }else{ /* authentication settled. Moving to the database portion. */ + $phpgw_setup->loaddb(); + } + } + $phpgw_setup->check_header(); -//echo "phpgw_info[setup][stage]: ".$phpgw_info["setup"]["stage"]."
"; if ( $phpgw_info["setup"]["stage"] >= 1.4){ if (!$phpgw_setup->header_auth()){ $phpgw_setup->show_header("Please login",True); @@ -21,7 +33,6 @@ } - switch($action){ case "download": header("Content-disposition: attachment; filename=\"header.inc.php\""); diff --git a/setup/inc/phpgw_setup.inc.php b/setup/inc/phpgw_setup.inc.php index ee154cb500..5a7cc0f1cc 100644 --- a/setup/inc/phpgw_setup.inc.php +++ b/setup/inc/phpgw_setup.inc.php @@ -16,7 +16,7 @@ var $db; var $template; - function show_header($title = "",$nologoutbutton = False) + function show_header($title = "",$nologoutbutton = False, $logoutfrom = "config") { global $phpgw_info, $PHP_SELF; echo ' @@ -36,34 +36,33 @@ if ($nologoutbutton) { echo " "; } else { - echo 'Logout '; + echo 'Logout '; } echo ""; } - function loginForm($login_msg="", $header_login_msg="") + function login_form() { - global $phpgw_info, $phpgw_domain, $SetupDomain, $SetupPW, $PHP_SELF; + global $phpgw_info, $phpgw_domain, $PHP_SELF; + echo "

\n"; echo "\n"; - if ( $phpgw_info["setup"]["stage"] >= 1.4){ + if ($phpgw_info["setup"]["stage"]["header"] == 10){ echo " \n"; echo " \n"; echo " \n"; - if ($err != "") { - echo " \n"; - } + echo " \n"; echo " \n"; - echo " \n"; echo " \n"; } @@ -71,12 +70,10 @@ echo " \n"; echo " \n"; echo " \n"; - if ($err != "") { - echo " \n"; - } + echo " \n"; echo " \n"; - echo " \n"; echo " \n"; @@ -89,26 +86,26 @@ { global $phpgw_domain, $phpgw_info; if(!file_exists("../header.inc.php") || !is_file("../header.inc.php")) { - $phpgw_info["setup"]["stage"] = 1.1; $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"]["stage"] = 1.2; $phpgw_info["setup"]["header_msg"] = "Stage One (No header admin password set)"; + return 2; }elseif (!isset($phpgw_domain) || $phpgw_info["server"]["versions"]["header"] != $phpgw_info["server"]["versions"]["current_header"]) { - $phpgw_info["setup"]["stage"] = 1.3; $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"]["stage"] = 1.4; $phpgw_info["setup"]["header_msg"] = "Stage One (Completed)"; + return 10; } } } function generate_header() { - global $setting, $phpgw_setup; + global $setting, $phpgw_setup, $phpgw_info; $phpgw_setup->template->set_file(array("header" => "header.inc.php.template")); while(list($k,$v) = each($setting)) { @@ -117,86 +114,78 @@ return $phpgw_setup->template->parse("out","header"); } - function config_auth() + function auth($auth_type = "Config") { - global $phpgw_domain, $FormLogout, $FormDomain, $FormHeaderPW, $FormPW, $SetupDomain, $HTTP_POST_VARS, $login_msg; + global $phpgw_domain, $phpgw_info, $HTTP_POST_VARS, $FormLogout, $ConfigLogin, $HeaderLogin, $FormDomain, $FormPW, $ConfigDomain, $ConfigPW, $HeaderPW; if (isset($FormLogout)) { - setcookie("SetupPW"); // scrub the old one - setcookie("SetupDomain"); // scrub the old one - setcookie("HeaderPW"); // 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)"; + 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 ($FormPW == $phpgw_domain[$FormDomain]["config_passwd"]) { - setcookie("SetupPW",$FormPW); - setcookie("SetupDomain",$FormDomain); - $SetupDomain = $FormDomain; - return True; - }else{ - $login_msg = "Invalid password"; - return False; + 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 header_auth() - { - global $phpgw_domain, $FormHeaderPW, $FormHeaderLogout,$HTTP_POST_VARS, $header_login_msg; - if (isset($FormHeaderLogout)) { - setcookie("HeaderPW"); // scrub the old one - $header_login_msg = "You have sucessfully logged out"; - return False; - } elseif (isset($HeaderPW)) { - if ($HeaderPW != $phpgw_info["server"]["header_admin_password"]) { - setcookie("SetupPW"); // scrub the old one - setcookie("SetupDomain"); // scrub the old one - setcookie("HeaderPW"); // scrub the old one - $header_login_msg = "Invalid session cookie (cookies must be enabled)"; - return False; - }else{ - return True; - } - } elseif (isset($FormHeaderPW)) { - if ($FormHeaderPW == $phpgw_info["server"]["header_admin_password"]) { - setcookie("HeaderPW",$HeaderPW); - return True; - }else{ - $header_login_msg = "Invalid password"; - return False; - } - } else { - return False; - } - } - - function loaddb() { - global $phpgw_info, $phpgw_domain, $SetupDomain; + 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[$SetupDomain]["db_type"].".inc.php"); + include($phpgw_info["server"]["api_inc"] . "/phpgw_db_".$phpgw_domain[$ConfigDomain]["db_type"].".inc.php"); $this->db = new db; - $this->db->Host = $phpgw_domain[$SetupDomain]["db_host"]; - $this->db->Type = $phpgw_domain[$SetupDomain]["db_type"]; - $this->db->Database = $phpgw_domain[$SetupDomain]["db_name"]; - $this->db->User = $phpgw_domain[$SetupDomain]["db_user"]; - $this->db->Password = $phpgw_domain[$SetupDomain]["db_pass"]; + $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[$SetupDomain]["db_type"]); + $phpgw_schema_proc = new phpgw_schema_proc($phpgw_domain[$ConfigDomain]["db_type"]); } function check_db() @@ -214,23 +203,15 @@ } if (isset($phpgw_info["setup"]["oldver"]["phpgwapi"])){ if ($phpgw_info["setup"]["oldver"]["phpgwapi"] == $phpgw_info["server"]["versions"]["phpgwapi"]){ - $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"]["stage"] = 3.1; - $phpgw_info["setup"]["header_msg"] = "Stage 3 (Needs Configuration)"; - }else{ - $phpgw_info["setup"]["stage"] = 3.2; - $phpgw_info["setup"]["header_msg"] = "Stage 3 (Configuration OK)"; - } + $phpgw_info["setup"]["header_msg"] = "Stage 2 (Tables Complete)"; + return 10; }else{ - $phpgw_info["setup"]["stage"] = 2.4; $phpgw_info["setup"]["header_msg"] = "Stage 2 (Tables need upgrading)"; + return 4; } }else{ - $phpgw_info["setup"]["stage"] = 2.2; $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 */ @@ -240,16 +221,34 @@ */ $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"]["stage"] = 2.3; $phpgw_info["setup"]["header_msg"] = "Stage 2 (Create tables)"; + return 3; }else{ - $phpgw_info["setup"]["stage"] = 2.1; $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 (Configuration OK)"; + return 10; + }else{ + $phpgw_info["setup"]["header_msg"] = "Stage 3 (Needs Configuration)"; + return 1; } - $this->db->query("DROP TABLE phpgw_testrights"); } } diff --git a/setup/index.php b/setup/index.php index 5fcc93b71d..f777a409f4 100644 --- a/setup/index.php +++ b/setup/index.php @@ -17,24 +17,17 @@ $phpgw_info["flags"] = array("noheader" => True, "nonavbar" => True, "currentapp" => "home", "noapi" => True); include("./inc/functions.inc.php"); - /* processing and discovery phase */ - $phpgw_setup->check_header(); -//echo "phpgw_info[setup][stage]: ".$phpgw_info["setup"]["stage"]."
"; - if ( $phpgw_info["setup"]["stage"] >= 1.4){ - if (!$phpgw_setup->config_auth()){ + $phpgw_info["setup"]["stage"]["header"] = $phpgw_setup->check_header(); + if ( $phpgw_info["setup"]["stage"]["header"] == 10){ + if (!$phpgw_setup->auth("Config")){ $phpgw_setup->show_header("Please login",True); - $phpgw_setup->loginForm($login_msg); + $phpgw_setup->login_form(); exit; }else{ /* authentication settled. Moving to the database portion. */ $phpgw_setup->loaddb(); - $phpgw_setup->check_db(); - } - }else{ - if (!$phpgw_setup->header_auth()){ - $phpgw_setup->show_header("Header.inc.php needs updating",True); - $phpgw_setup->loginForm("", $header_login_msg); - exit; + $phpgw_info["setup"]["stage"]["db"] = $phpgw_setup->check_db(); + $phpgw_info["setup"]["stage"]["config"] = $phpgw_setup->check_config(); } } @@ -44,21 +37,21 @@ $submsg = "At your request, this script is going to take the evil action of deleting your existing tables and re-creating them in the new format."; $subaction = "deleted"; $phpgw_info["setup"]["currentver"]["phpgwapi"] = "drop"; - $phpgw_info["setup"]["stage"] = 2.5; + $phpgw_info["setup"]["stage"]["db"] = 5; break; case "Upgrade": $subtitle = "Upgrading Tables"; $submsg = "At your request, this script is going to attempt to upgrade your old tables to the new format."; $subaction = "upgraded"; $phpgw_info["setup"]["currentver"]["phpgwapi"] = "oldversion"; - $phpgw_info["setup"]["stage"] = 2.5; + $phpgw_info["setup"]["stage"]["db"] = 5; break; case "Create": $subtitle = "Creating Tables"; $submsg = "At your request, this script is going to attempt to the tables for you."; $subaction = "created"; $phpgw_info["setup"]["currentver"]["phpgwapi"] = "new"; - $phpgw_info["setup"]["stage"] = 2.5; + $phpgw_info["setup"]["stage"]["db"] = 5; break; } @@ -92,20 +85,20 @@ echo '
 Setup/Config Admin Login
".$login_msg."
".$phpgw_info["setup"]["ConfigLoginMSG"]."
\n"; + echo "
\n"; if (count($phpgw_domain) > 1){ - echo " \n"; - echo "
Domain:
Password:
\n"; + echo " \n"; + echo "
Domain:
Password:
\n"; }else{ reset($phpgw_domain); $default_domain = each($phpgw_domain); echo " \n"; echo " \n"; } - echo " \n"; + echo " \n"; echo "
 Header Admin Login
".$header_login_msg."
".$phpgw_info["setup"]["HeaderLoginMSG"]."
\n"; - echo " \n"; + echo "
\n"; + echo " \n"; echo " \n"; echo "
'; echo ' '; - if ($phpgw_info["setup"]["stage"] == 1.1) { - echo ''; - }elseif ($phpgw_info["setup"]["stage"] == 1.2 || $phpgw_info["setup"]["stage"] == 1.3) { - echo ''; - }elseif ($phpgw_info["setup"]["stage"] >= 1.4) { - echo ''; + }elseif ($phpgw_info["setup"]["stage"]["header"] == 2 || $phpgw_info["setup"]["stage"] == 3) { + echo ''; + }elseif ($phpgw_info["setup"]["stage"]["header"] == 10) { + echo ''; } echo ' '; - if ($phpgw_info["setup"]["stage"] < 2.1) { + if ($phpgw_info["setup"]["stage"]["header"] < 10) { echo ''; - }elseif ($phpgw_info["setup"]["stage"] == 2.1) { + }elseif ($phpgw_info["setup"]["stage"]["db"] <= 1) { echo ''; - }elseif ($phpgw_info["setup"]["stage"] == 2.2) { + }elseif ($phpgw_info["setup"]["stage"]["db"] == 2) { echo ''; - }elseif ($phpgw_info["setup"]["stage"] == 2.3) { + }elseif ($phpgw_info["setup"]["stage"]["db"] == 3) { /* commented out because I cannot accuratly figure out if the DB exists */ //echo ''; echo ''; - }elseif ($phpgw_info["setup"]["stage"] == 2.4) { + }elseif ($phpgw_info["setup"]["stage"]["db"] == 4) { echo ''; - }elseif ($phpgw_info["setup"]["stage"] == 2.5) { + }elseif ($phpgw_info["setup"]["stage"]["db"] == 5) { echo '
Step 1 - header.inc.php 
O
You have not created your header.inc.php yet.
O
Your header.inc.php is out of date. Please upgrade it.
X
+ if ($phpgw_info["setup"]["stage"]["header"] <= 1) { + echo '
OYou have not created your header.inc.php yet.
O
Your header.inc.php is out of date. Please upgrade it.
X
Your header.inc.php is in place and current.
Step 2 - database management 
ONot ready for this stage yet.
O
Your database does not exist.
O'; echo ' You appear to be running a pre-beta version of phpGroupWare
@@ -128,7 +121,7 @@ '; echo '
O
Your database exist, would you like to create your tables now?
OMake sure that your database is created and the account permissions are set.
'; @@ -153,7 +146,7 @@ echo '
'; echo "\n"; echo 'Once the database is setup correctly
the tables
O'; echo "You appear to be running version ".$phpgw_info["setup"]["oldver"]["phpgwapi"]." of phpGroupWare.
\n"; echo "We will automaticly update your tables/records to ".$phpgw_info["server"]["versions"]["phpgwapi"].", but we highly recommend backing up your tables in case the script causes damage to your data.\n"; @@ -168,7 +161,7 @@ echo "\n"; echo "\n"; echo '
O'; echo "\n"; echo " \n"; @@ -184,7 +177,7 @@ echo "
\n"; echo ''; echo ''; - }elseif ($phpgw_info["setup"]["stage"] >= 2.6) { + }elseif ($phpgw_info["setup"]["stage"]["db"] == 10) { echo ''; } echo ' '; - if ($phpgw_info["setup"]["stage"] < 3.1) { + if ($phpgw_info["setup"]["stage"]["db"] < 10) { echo ''; - }elseif ($phpgw_info["setup"]["stage"] == 3.1) { - echo ''; - }elseif ($phpgw_info["setup"]["stage"] == 3.2) { + }elseif ($phpgw_info["setup"]["stage"]["config"] == 10) { echo ''; } echo ' '; - if ($phpgw_info["setup"]["stage"] < 4.1) { + if ($phpgw_info["setup"]["stage"]["config"] < 10) { echo ''; - }elseif ($phpgw_info["setup"]["stage"] == 4.1) { - echo ''; - }elseif ($phpgw_info["setup"]["stage"] == 4.2) { - echo ''; + }elseif ($phpgw_info["setup"]["stage"]["lang"] <= 1) { + echo ''; + }elseif ($phpgw_info["setup"]["stage"]["lang"] == 10) { + echo ''; } echo ' '; - if ($phpgw_info["setup"]["stage"] < 5.1) { + if ($phpgw_info["setup"]["stage"]["lang"] < 10) { echo ''; - }elseif ($phpgw_info["setup"]["stage"] == 5.1) { - echo ''; - }elseif ($phpgw_info["setup"]["stage"] == 5.2) { - echo ''; + }elseif ($phpgw_info["setup"]["stage"]["apps"] <= 1) { + echo ''; + }elseif ($phpgw_info["setup"]["stage"]["apps"] == 10) { + echo ''; } - echo '
 $subtitle
XYour tables are current.'; echo "
\n"; echo "\n"; @@ -193,34 +186,33 @@ echo '
Step 3 - Configuration 
ONot ready for this stage yet.
OPlease phpGroupWare for your environment.'; + }elseif ($phpgw_info["setup"]["stage"]["config"] <= 1) { + echo '
OPlease configure phpGroupWare for your environment.'; echo ""; echo '
XConfiguration completed.'; echo "
"; echo '
Step 4 - language management 
ONot ready for this stage yet.
Ostage 4.1.
Ostage 4.2.
OYou are ready for this stage, but this stage is not yet written.
OThis stage is completed
Step 5 - Add-on Application Installation 
ONot ready for this stage yet.
Ostage 5.1.
Ostage 5.2.
OYou are ready for this stage, but this stage is not yet written.
OThis stage is completed
'; echo ""; ?> diff --git a/version.inc.php b/version.inc.php index a1d5a5e650..d94b4c80c9 100644 --- a/version.inc.php +++ b/version.inc.php @@ -12,4 +12,4 @@ /* $Id$ */ $phpgw_info["server"]["versions"]["phpgwapi"] = "0.9.8pre5"; - $phpgw_info["server"]["versions"]["current_header"] = "1.8"; + $phpgw_info["server"]["versions"]["current_header"] = "1.9";