From: <ope...@li...> - 2002-08-04 16:03:12
|
Update of /cvsroot/openposs/Server In directory usw-pr-cvs1:/tmp/cvs-serv13681 Modified Files: install.php module.php index.php Log Message: Completed install routine. The server dir must be writable so that the routine can write the config.php file. After that is done, make the Server dir non writable. Index: install.php =================================================================== RCS file: /cvsroot/openposs/Server/install.php,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** install.php 27 Jun 2002 05:30:23 -0000 1.1 --- install.php 4 Aug 2002 16:03:08 -0000 1.2 *************** *** 1,36 **** ! <?php ! /****************************************************************************** ! * * ! * File Name: /install.php * ! * * ! * Created : Jun, 25 2001 * ! * * ! * Purpose : Provide the installation interface to the openPOS Server. * ! * * ! *----------------------------------------------------------------------------* ! * Change Log * ! *----------------------------------------------------------------------------* ! * Date | Description * ! * -------------+------------------------------------------------------------ * ! * Jun 25, 2002 | Initial Coding. * ! ******************************************************************************/ ! ! /****************************************************************************** ! * System Includes * ! ******************************************************************************/ ! include_once("database.php"); ! ! ! if (!DBInit()) { ! die("Unable to connect to the database."); ! } ! $OutputLang=$HTTP_GET_VARS["lang"]; ! $Action=$HTTP_GET_VARS["action"]; ! if (!isset($Action)) { ! $Action="none"; ! } ! if (!isset($OutputLang)) { ! $OutputLang="eng"; ! } ! ?> --- 1,315 ---- ! <?php ! session_start(); ! /****************************************************************************** ! * * ! * File Name: /install.php * ! * * ! * Created : Jun, 25 2001 * ! * * ! * Purpose : Provide the installation interface to the openPOS Server. * ! * * ! *----------------------------------------------------------------------------* ! * Change Log * ! *----------------------------------------------------------------------------* ! * Date | Description * ! * -------------+------------------------------------------------------------ * ! * Jun 25, 2002 | Initial Coding. * ! ******************************************************************************/ ! $currentDate = date("F j, Y"); ! /****************************************************************************** ! * System Includes * ! ******************************************************************************/ ! ! include_once("./includes/database.php"); ! include_once("./includes/functions.php"); ! include_once("./includes/vars.inc"); ! include "./includes/install.php"; ! ! //Check to see if system has already been installed: ! if(file_exists("./config.php")) ! { ! $DBConn = ADONewConnection($DBConfig['DBType']); ! $DBHandle = $DBConn->Connect($DBConfig['Server'], $DBConfig['UserName'], $DBConfig['Password'],$DBConfig['DBName']); ! if ($DBHandle) ! { ! $query = "SELECT Value FROM Configuration WHERE Parameter='systemInstalled'"; ! $result = $DBConn->Execute("$query"); ! $data[] = $result->fields; ! if($data[0]["Value"] == "Yes") ! { ! die("I'm already installed?!?!?!"); ! } ! } ! } ! ! if (!isset($_SESSION["OutputLang"])) { ! $_SESSION["OutputLang"] = "eng"; ! } ! if (!isset($_SESSION["OutputTheme"])) { ! $_SESSION["OutputTheme"] = "Default"; ! } ! $themeFile = "theme/".$_SESSION["OutputTheme"]."/theme.php"; ! include_once ($themeFile); ! $langFile = "language/".$_SESSION["OutputLang"]."/global.php"; ! include_once ($langFile); ! ! if($_SESSION["action"]=="submitted") ! { ! //Process Data ! $HTMLOutput = Theme_Open_Page(_OPENPOSINSTALLTITLE,"NO"); ! $HTMLOutput .= "<table width=\"50%\" border=0>"; ! ! //DB Connection ! $DBConn = ADONewConnection($_POST["dbtype"]); ! $DBHandle = $DBConn->Connect($_POST["server"], $_POST["username"], $_POST["password"]); ! if (!$DBHandle) ! { ! $test_result = _OPENPOSINSTALLBAD; ! $stop = TRUE; ! } ! else ! { ! $test_result = _OPENPOSINSTALLGOOD; ! DBClose(); ! } ! ! $HTMLOutput .= "<tr><TD>"._OPENPOSINSTALLDBCONNECT."</td><td>$test_result</td></tr>"; ! ! if($stop == TRUE) ! { ! ! $HTMLOutput .= "</table> A fatal error has occured. Please correct the above indicted error, and proceed again."; ! $HTMLOutput .= Theme_Close_Page(); ! $_SESSION["action"] = "none"; ! die($HTMLOutput); ! } ! $results = NULL; ! //Now, check for the existince of the database ! //$DBConn = ADONewConnection($_POST["dbtype"]); ! $DBHandle = $DBConn->Connect($_POST["server"], $_POST["username"], $_POST["password"], $_POST["dbname"]); ! if (!$DBHandle) ! { ! //db does not exists ! $test_result = _OPENPOSINSTALLBAD; ! $noDB = TRUE; ! } ! else ! { ! $test_result = _OPENPOSINSTALLGOOD; ! } ! ! $HTMLOutput .= "<tr><TD>"._OPENPOSINSTALLDBEXISTS."</td><td>$test_result</td></tr>"; ! $results = NULL; ! //if db does not exist, create it! ! if($noDB) ! { ! $DBHandle = $DBConn->Connect($_POST["server"], $_POST["username"], $_POST["password"]); ! $query = "CREATE DATABASE ".$_POST["dbname"]; ! $results = $DBConn->Execute($query); ! if(!$results) ! { ! //could not create db ! $test_result = _OPENPOSINSTALLBAD; ! $stop = TRUE; ! } ! else ! { ! //created db ! $test_result = _OPENPOSINSTALLGOOD; ! DBClose(); ! } ! $HTMLOutput .= "<tr><TD>"._OPENPOSINSTALLCREATEDB."</td><td>$test_result</td></tr>"; ! ! if($stop == TRUE) ! { ! $HTMLOutput .= "</table> A fatal error has occured. Please correct the above indicted error, and proceed again. See the install documentation for more information on common failures"; ! $HTMLOutput .= Theme_Close_Page(); ! $_SESSION["action"] = "none"; ! die($HTMLOutput); ! } ! } ! ! $results = NULL; ! $failure = 0; ! $DBHandle = $DBConn->Connect($_POST["server"], $_POST["username"], $_POST["password"], $_POST["dbname"]); ! ! foreach($installDBtables as $temp) ! { ! $results = NULL; ! $results = $DBConn->Execute($temp); ! ! if(!$results) ! { ! //could not create TABLE ! $failure++; ! } ! ! } ! if($failure != 0) ! { ! //could not create TABLES ! $test_result = _OPENPOSINSTALLBAD; ! $stop = TRUE; ! } ! else ! { ! //created table ! $test_result = _OPENPOSINSTALLGOOD; ! } ! $HTMLOutput .= "<tr><TD>"._OPENPOSINSTALLADDTABLES."</td><td>$test_result</td></tr>"; ! if($stop == TRUE) ! { ! ! $HTMLOutput .= "</table><p>A fatal error has occured. Please correct the above indicted error, and proceed again."; ! $HTMLOutput .= Theme_Close_Page(); ! $_SESSION["action"] = "none"; ! die($HTMLOutput); ! } ! ! //Now set the inital system configuration. ! $results = NULL; ! $failure = 0; ! foreach($installConfig as $temp) ! { ! $results = NULL; ! $results = $DBConn->Execute($temp); ! if(!$results) ! { ! //could not create TABLE ! $failure++; ! } ! } ! if($failure != 0) ! { ! //could not prime TABLES ! $test_result = _OPENPOSINSTALLBAD; ! $stop = TRUE; ! } ! else ! { ! //primed talbes ! $test_result = _OPENPOSINSTALLGOOD; ! } ! ! $HTMLOutput .= "<tr><TD>"._OPENPOSINSTALLPRIMETABLES."</td><td>$test_result</td></tr>"; ! ! if($stop == TRUE) ! { ! ! $HTMLOutput .= "</table><p>A fatal error has occured. Please correct the above indicted error, and proceed again."; ! $HTMLOutput .= Theme_Close_Page(); ! $_SESSION["action"] = "none"; ! die($HTMLOutput); ! } ! ! //Now write the config file: ! ! $fp = fopen("./config.php","w"); ! $result = fwrite($fp,$configTemplate); ! if($result == -1) ! { ! //could not config file ! $test_result = _OPENPOSINSTALLBAD; ! $stop = TRUE; ! } ! else ! { ! //config file written successfully ! $test_result = _OPENPOSINSTALLGOOD; ! } ! ! $HTMLOutput .= "<tr><TD>"._OPENPOSINSTALLCONFIGFILE."</td><td>$test_result</td></tr>"; ! ! if($stop == TRUE) ! { ! ! $HTMLOutput .= "</table><p>A fatal error has occured. Please correct the above indicted error, and proceed again."; ! $HTMLOutput .= Theme_Close_Page(); ! $_SESSION["action"] = "none"; ! die($HTMLOutput); ! } ! ! //Now set the systemInstalled flag to Yes: ! $query = "UPDATE Configuration SET Value='Yes' WHERE Parameter='systemInstalled'"; ! $results = NULL; ! $results = $DBConn->Execute($query); ! if(!$results) ! { ! //could not set flag ! $test_result = _OPENPOSINSTALLBAD; ! $stop = TRUE; ! } ! else ! { ! //config flag set successfully ! $test_result = _OPENPOSINSTALLGOOD; ! } ! ! $HTMLOutput .= "<tr><TD>"._OPENPOSINSTALLFLAGSET."</td><td>$test_result</td></tr>"; ! ! if($stop == TRUE) ! { ! ! $HTMLOutput .= "</table><p>A fatal error has occured. Please correct the above indicted error, and proceed again."; ! $HTMLOutput .= Theme_Close_Page(); ! $_SESSION["action"] = "none"; ! die($HTMLOutput); ! } ! ! //Now create the Admin user in the db ! $query = "INSERT INTO SystemUsers (UserName, FullName, Password, Active, SuperUser) VALUES ('".$_POST["adminUsername"]."', '".$_POST["adminFullName"]."', md5('".$_POST["adminPassword"]."'), 1, '127');"; ! $results = NULL; ! $results = $DBConn->Execute($query); ! if(!$results) ! { ! //could not set flag ! $test_result = _OPENPOSINSTALLBAD; ! $stop = TRUE; ! } ! else ! { ! //config flag set successfully ! $test_result = _OPENPOSINSTALLGOOD; ! } ! ! $HTMLOutput .= "<tr><TD>"._OPENPOSINSTALLADMIN."</td><td>$test_result</td></tr>"; ! ! if($stop == TRUE) ! { ! ! $HTMLOutput .= "</table><p>A fatal error has occured. Please correct the above indicted error, and proceed again."; ! $HTMLOutput .= Theme_Close_Page(); ! $_SESSION["action"] = "none"; ! die($HTMLOutput); ! } ! ! $HTMLOutput .= "</table>"; ! ! $HTMLOutput .= _OPENPOSINSTALLWELCOME; ! ! ! ! $HTMLOutput .= Theme_Close_Page(); ! ! echo $HTMLOutput; ! ! if (!DBClose()) ! { ! die("Unable to disconnect from the database."); ! } ! $_SESSION["action"] = "none"; ! } ! else ! { ! //display form for server, username, password, dbname, dbtype. ! //echo Theme_Open_Page(_OPENPOSINSTALLTITLE,"NO"); ! echo Install_Form_Screen("Database Configuration Information"); ! $action = "submitted"; ! session_register("action"); ! ! } ! ! ! ! ?> Index: module.php =================================================================== RCS file: /cvsroot/openposs/Server/module.php,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** module.php 9 Jul 2002 01:23:30 -0000 1.1 --- module.php 4 Aug 2002 16:03:09 -0000 1.2 *************** *** 92,101 **** } ! $HTMLOutput = Theme_Open_Page(_OPENPOSMAINTITLE); echo $HTMLOutput; ! include "./module/".$HTTP_GET_VARS["module"]."/module.php"; $HTMLOutput = Theme_Close_Page(); --- 92,102 ---- } ! $pageTitle = _OPENPOSMAINTITLE." :: ".$_GET["module"]; ! $HTMLOutput = Theme_Open_Page($pageTitle); echo $HTMLOutput; ! include "./module/".$_GET["module"]."/module.php"; $HTMLOutput = Theme_Close_Page(); Index: index.php =================================================================== RCS file: /cvsroot/openposs/Server/index.php,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** index.php 9 Jul 2002 01:25:32 -0000 1.8 --- index.php 4 Aug 2002 16:03:09 -0000 1.9 *************** *** 1,4 **** <?php ! /****************************************************************************** * * --- 1,4 ---- <?php ! session_start(); /****************************************************************************** * * *************** *** 22,27 **** * Begin Session * ******************************************************************************/ - session_start(); - if(isset($HTTP_GET_VARS["action"])) { --- 22,25 ---- *************** *** 36,43 **** include_once("./includes/functions.php"); - - global $HTMLOutput, $OutputLang, $Action, $OutputTheme, $SystemConfig; ! global $UserName, $Password; if (!DBInit()) { --- 34,39 ---- include_once("./includes/functions.php"); global $HTMLOutput, $OutputLang, $Action, $OutputTheme, $SystemConfig; ! global $UserName, $Password,$notInstalled; if (!DBInit()) { *************** *** 70,74 **** } - $themeFile = "theme/".$HTTP_SESSION_VARS["OutputTheme"]."/theme.php"; include_once ($themeFile); --- 66,69 ---- *************** *** 76,80 **** include_once ($langFile); - switch ($HTTP_SESSION_VARS["action"]) { --- 71,74 ---- *************** *** 87,91 **** $Password=$HTTP_GET_VARS["password"]; $HTTP_SESSION_VARS["action"] = "none"; ! ProcessLoginRequest($UserName,$Password); break; case "logout": --- 81,85 ---- $Password=$HTTP_GET_VARS["password"]; $HTTP_SESSION_VARS["action"] = "none"; ! ProcessLoginRequest($HTTP_GET_VARS["username"],$HTTP_GET_VARS["password"]); break; case "logout": *************** *** 96,104 **** $HTMLOutput = Theme_Open_Page(_OPENPOSMAINTITLE,"YES"); $HTMLOutput .= Theme_Close_Page(); - break; case "admin": echo Theme_Open_Page(_OPENPOSADMINTITLE); ! if($HTTP_SESSION_VARS["openPOSAuthRights"] != "User") { switch($HTTP_GET_VARS["admin"]) --- 90,97 ---- $HTMLOutput = Theme_Open_Page(_OPENPOSMAINTITLE,"YES"); $HTMLOutput .= Theme_Close_Page(); break; case "admin": echo Theme_Open_Page(_OPENPOSADMINTITLE); ! if($HTTP_SESSION_VARS["openPOSAuthRights"] == "127") { switch($HTTP_GET_VARS["admin"]) |