From: <ope...@li...> - 2002-06-26 00:43:24
|
Update of /cvsroot/openposs/Server In directory usw-pr-cvs1:/tmp/cvs-serv3787 Modified Files: index.php Log Message: Made documentation and style changes Index: index.php =================================================================== RCS file: /cvsroot/openposs/Server/index.php,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** index.php 25 Jun 2002 03:18:53 -0000 1.4 --- index.php 26 Jun 2002 00:43:20 -0000 1.5 *************** *** 1,229 **** ! <?php ! /****************************************************************************** ! * * ! * File Name: /lang/eng/something.php * ! * * ! * Created : Apr, 21 2001 * ! * * ! * Purpose : Provide the initial point of contact to the openPOS server. * ! * * ! *----------------------------------------------------------------------------* ! * Change Log * ! *----------------------------------------------------------------------------* ! * Date | Description * ! * -------------+------------------------------------------------------------ * ! * Apr 6, 2002 | Moved the database code into database.php * ! * -------------+------------------------------------------------------------ * ! * Apr 6, 2002 | Initial Coding. * ! ******************************************************************************/ ! ! ! /****************************************************************************** ! * System Includes * ! ******************************************************************************/ ! include_once("database.php"); ! ! /****************************************************************************** ! * Function: ReadConfigFromDatabase() * ! * -------------------------------------------------------------------------- * ! * This function is used to read the configuration from the database table * ! * openPOS.Configuration. * ! * * ! * Returned Values * ! * None. * ! * * ! * Input Values * ! * None. * ! ******************************************************************************/ ! function ReadConfigFromDatabase() { ! ! } ! ! /****************************************************************************** ! * Function: DisplayMainMenu() * ! * -------------------------------------------------------------------------- * ! * This function will display the main menu when the user is accessing the * ! * system via a web browser. * ! * * ! * Returned Values * ! * HTML Page text to return to the client. * ! * * ! * Input Values * ! * None. * ! ******************************************************************************/ ! function DisplayMainMenu() { ! GLOBAL $UserName; ! $Output = Theme_Open_Page(_OPENPOSMAINTITLE); ! $Output .= Theme_Open_Table("99%"); ! $Output .= Theme_Open_Row(); ! $Output .= Theme_Open_Data_Cell("Right", "15%"); ! if (isset($UserName)) { ! $Output .= $UserName." Logged In<br>"; ! } else { ! $Output .= "Not Logged In<br>"; ! } ! $Output .= "<br><br><B>" . _OPENPOSNAVTITLE . "</B><br>"; ! if ( strcmp($SystemConfig['modUserLogin'], "On")) { ! if (isset($UserName)) { ! $Output .= Theme_Add_Link("/Server/?action=logout", "Logout") . "<br>"; ! } else { ! $Output .= Theme_Add_Link("/Server/?action=login", "Login") . "<br>"; ! } ! } ! $Output .= Theme_Add_Link("/Server/?action=admin", _OPENPOSADMINTITLE ); ! $Output .= Theme_Close_Data_Cell().Theme_Open_Data_Cell(); ! $Output .= Theme_Close_Data_Cell(); ! $Output .= Theme_Close_Row(); ! $Output .= Theme_Close_Table(); ! $Output .= Theme_Close_Page(); ! return $Output; ! } ! ! /****************************************************************************** ! * Function: DisplayAdminMenu() * ! * -------------------------------------------------------------------------- * ! * This function will display the administration menu when the user is * ! * accessing the system via a web browser. * ! * * ! * Returned Values * ! * HTML Page text to return to the client. * ! * * ! * Input Values * ! * None. * ! ******************************************************************************/ ! function DisplayAdminMenu() { ! $Output = Theme_Open_Page(_OPENPOSADMINTITLE); ! $Output .= Theme_Close_Page(); ! return $Output; ! } ! ! /****************************************************************************** ! * Function: DisplayError() * ! * -------------------------------------------------------------------------- * ! * This function will display the administration menu when the user is * ! * accessing the system via a web browser. * ! * * ! * Returned Values * ! * HTML Page text to return to the client. * ! * * ! * Input Values * ! * None. * ! ******************************************************************************/ ! function DisplayError() { ! $Output = Theme_Open_Page( _OPENPOSERRORTITLE ); ! $Output .= "<DIV ALIGN=\"CENTER\"><H3>ERROR: Incorrect Parameters sent to the server. Please contact your support section.</H3></DIV>"; ! $Output .= Theme_Close_Page(); ! return $Output; ! } ! ! /****************************************************************************** ! * Function: ProcessLoginRequest() * ! * -------------------------------------------------------------------------- * ! * This function will display the administration menu when the user is * ! * accessing the system via a web browser. * ! * * ! * Returned Values * ! * HTML Code to log the user in. This code is generated from the theme.php * ! * file. This way the login screen can be customised. * ! * * ! * Input Values * ! * None. * ! ******************************************************************************/ ! function ProcessLoginRequest() { ! GLOBAL $Action, $UserName, $Password; ! // Validate the password against the database, and if all is well ! // we will create a cookie, and return to the main menu. ! if (Validate_Password($UserName, $Password) == 1) { ! setcookie("openPOSAuthTok", $UserName, time()+3600); ! } ! header("HTTP/1.0 303 See Other"); ! header("Location: /Server/"); ! return; ! } ! ! /****************************************************************************** ! * Function: ProcessLogoutRequest() * ! * -------------------------------------------------------------------------- * ! * This function will display the administration menu when the user is * ! * accessing the system via a web browser. * ! * * ! * Returned Values * ! * None. * ! * * ! * Input Values * ! * None. * ! ******************************************************************************/ ! function ProcessLogoutRequest() { ! GLOBAL $Action, $UserName; ! if (isset($UserName)) { ! setcookie("openPOSAuthTok", $UserName, time()-3600); ! header("HTTP/1.0 303 See Other"); ! header("Location: /Server/"); ! unset($UserName); ! } ! return; ! } ! ! /****************************************************************************** ! * Function: DisplayAdminMenu() * ! * -------------------------------------------------------------------------- * ! * This function will display the administration menu when the user is * ! * accessing the system via a web browser. * ! * * ! * Returned Values * ! * None. * ! * * ! * Input Values * ! * None. * ! ******************************************************************************/ ! global $HTMLOutput, $OutputLang, $Action, $OutputTheme, $SystemConfig; ! global $UserName, $Password; ! if (!DBInit()) { ! die("Unable to connect to the database."); ! } ! $OutputLang=$HTTP_GET_VARS["lang"]; ! $Action=$HTTP_GET_VARS["action"]; ! $OutputTheme=$HTTP_GET_VARS["theme"]; ! if (!isset($Action)) { ! $Action="none"; ! } ! if (!isset($OutputLang)) { ! $OutputLang="eng"; ! } ! if (!isset($OutputTheme)) { ! $OutputTheme="Default"; ! } ! if (isset($openPOSAuthTok)) { ! $UserName = $openPOSAuthTok; ! } ! include_once ("theme/$OutputTheme/theme.php"); ! include_once ("language/$OutputLang/global.php"); ! switch ($Action) { ! case "login": ! $HTMLOutput = Theme_Login_Screen(); ! break; ! case "submitlogin": ! $UserName=$HTTP_GET_VARS["username"]; ! $Password=$HTTP_GET_VARS["password"]; ! ProcessLoginRequest(); ! break; ! case "logout": ! ProcessLogoutRequest(); ! break; ! case "none": ! $HTMLOutput = DisplayMainMenu(); ! break; ! case "admin": ! $HTMLOutput = DisplayAdminMenu(); ! break; ! default: ! $HTMLOutput = DisplayError(); ! break; ! } ! if (!DBClose()) { ! die("Unable to disconnect from the database."); ! } ! if (isset($HTMLOutput)) { ! echo $HTMLOutput; ! } ! ?> --- 1,218 ---- ! <?php ! /****************************************************************************** ! * * ! * File Name: index.php * ! * * ! * Created : Apr, 21 2001 * ! * * ! * Purpose : Provide the initial point of contact to the openPOS server. * ! * * ! *----------------------------------------------------------------------------* ! * Change Log * ! *----------------------------------------------------------------------------* ! * Date | Description * ! * -------------+------------------------------------------------------------ * ! * Apr 6, 2002 | Moved the database code into database.php * ! * -------------+------------------------------------------------------------ * ! * Apr 6, 2002 | Initial Coding. * ! ******************************************************************************/ ! ! ! /****************************************************************************** ! * System Includes * ! ******************************************************************************/ ! include_once("database.php"); ! ! /****************************************************************************** ! * Function: ReadConfigFromDatabase() * ! * -------------------------------------------------------------------------- * ! * This function is used to read the configuration from the database table * ! * openPOS.Configuration. * ! * * ! * Returned Values * ! * None. * ! * * ! * Input Values * ! * None. * ! ******************************************************************************/ ! function ReadConfigFromDatabase() { ! ! } ! ! /****************************************************************************** ! * Function: DisplayMainMenu() * ! * -------------------------------------------------------------------------- * ! * This function will display the main menu when the user is accessing the * ! * system via a web browser. * ! * * ! * Returned Values * ! * HTML Page text to return to the client. * ! * * ! * Input Values * ! * None. * ! ******************************************************************************/ ! function DisplayMainMenu() { ! GLOBAL $UserName; ! $Output = Theme_Open_Page(_OPENPOSMAINTITLE); ! $Output .= Theme_Open_Table("99%"); ! $Output .= Theme_Open_Row(); ! $Output .= Theme_Open_Data_Cell("Right", "15%"); ! if (isset($UserName)) { ! $Output .= $UserName." Logged In<br>"; ! } else { ! $Output .= "Not Logged In<br>"; ! } ! $Output .= "<br><br><B>" . _OPENPOSNAVTITLE . "</B><br>"; ! if ( strcmp($SystemConfig['modUserLogin'], "On")) { ! if (isset($UserName)) { ! $Output .= Theme_Add_Link("/Server/?action=logout", "Logout") . "<br>"; ! } else { ! $Output .= Theme_Add_Link("/Server/?action=login", "Login") . "<br>"; ! } ! } ! $Output .= Theme_Add_Link("/Server/?action=admin", _OPENPOSADMINTITLE ); ! $Output .= Theme_Close_Data_Cell().Theme_Open_Data_Cell(); ! $Output .= Theme_Close_Data_Cell(); ! $Output .= Theme_Close_Row(); ! $Output .= Theme_Close_Table(); ! $Output .= Theme_Close_Page(); ! return $Output; ! } ! ! /****************************************************************************** ! * Function: DisplayAdminMenu() * ! * -------------------------------------------------------------------------- * ! * This function will display the administration menu when the user is * ! * accessing the system via a web browser. * ! * * ! * Returned Values * ! * HTML Page text to return to the client. * ! * * ! * Input Values * ! * None. * ! ******************************************************************************/ ! function DisplayAdminMenu() { ! $Output = Theme_Open_Page(_OPENPOSADMINTITLE); ! $Output .= Theme_Close_Page(); ! return $Output; ! } ! ! /****************************************************************************** ! * Function: DisplayError() * ! * -------------------------------------------------------------------------- * ! * This function will display the error messages to the user. * ! * * ! * Returned Values * ! * HTML Page text to return to the client. * ! * * ! * Input Values * ! * None. * ! ******************************************************************************/ ! function DisplayError() { ! $Output = Theme_Open_Page( _OPENPOSERRORTITLE ); ! $Output .= "<DIV ALIGN=\"CENTER\"><H3>ERROR: Incorrect Parameters sent to the server. Please contact your support section.</H3></DIV>"; ! $Output .= Theme_Close_Page(); ! return $Output; ! } ! ! /****************************************************************************** ! * Function: ProcessLoginRequest() * ! * -------------------------------------------------------------------------- * ! * This function will validate user, and then set cookie if user is valid. * ! * * ! * Returned Values * ! * None. * ! * * ! * * ! * Input Values * ! * None. * ! ******************************************************************************/ ! function ProcessLoginRequest() { ! GLOBAL $Action, $UserName, $Password; ! // Validate the password against the database, and if all is well ! // we will create a cookie, and return to the main menu. ! if (Validate_Password($UserName, $Password) == 1) { ! setcookie("openPOSAuthTok", $UserName, time()+3600); ! } ! header("HTTP/1.0 303 See Other"); ! header("Location: /Server/"); ! return; ! } ! ! /****************************************************************************** ! * Function: ProcessLogoutRequest() * ! * -------------------------------------------------------------------------- * ! * This function will destroy the users session, logging them out * ! * * ! * Returned Values * ! * None. * ! * * ! * Input Values * ! * None. * ! ******************************************************************************/ ! function ProcessLogoutRequest() ! { ! GLOBAL $Action, $UserName; ! if (isset($UserName)) { ! setcookie("openPOSAuthTok", $UserName, time()-3600); ! header("HTTP/1.0 303 See Other"); ! header("Location: /Server/"); ! unset($UserName); ! } ! return; ! } ! ! /*End Functions ! *******************************************************************************/ ! ! global $HTMLOutput, $OutputLang, $Action, $OutputTheme, $SystemConfig; ! global $UserName, $Password; ! if (!DBInit()) { ! die("Unable to connect to the database."); ! } ! $OutputLang=$HTTP_GET_VARS["lang"]; ! $Action=$HTTP_GET_VARS["action"]; ! $OutputTheme=$HTTP_GET_VARS["theme"]; ! if (!isset($Action)) { ! $Action="none"; ! } ! if (!isset($OutputLang)) { ! $OutputLang="eng"; ! } ! if (!isset($OutputTheme)) { ! $OutputTheme="Default"; ! } ! if (isset($openPOSAuthTok)) { ! $UserName = $openPOSAuthTok; ! } ! include_once ("theme/$OutputTheme/theme.php"); ! include_once ("language/$OutputLang/global.php"); ! switch ($Action) { ! case "login": ! $HTMLOutput = Theme_Login_Screen(); ! break; ! case "submitlogin": ! $UserName=$HTTP_GET_VARS["username"]; ! $Password=$HTTP_GET_VARS["password"]; ! ProcessLoginRequest(); ! break; ! case "logout": ! ProcessLogoutRequest(); ! break; ! case "none": ! $HTMLOutput = DisplayMainMenu(); ! break; ! case "admin": ! $HTMLOutput = DisplayAdminMenu(); ! break; ! default: ! $HTMLOutput = DisplayError(); ! break; ! } ! if (!DBClose()) { ! die("Unable to disconnect from the database."); ! } ! if (isset($HTMLOutput)) { ! echo $HTMLOutput; ! } ! ?> |