From: <ope...@li...> - 2002-07-09 01:25:35
|
Update of /cvsroot/openposs/Server In directory usw-pr-cvs1:/tmp/cvs-serv27433 Modified Files: index.php Log Message: Added module logic. Index: index.php =================================================================== RCS file: /cvsroot/openposs/Server/index.php,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** index.php 28 Jun 2002 02:11:44 -0000 1.7 --- index.php 9 Jul 2002 01:25:32 -0000 1.8 *************** *** 32,228 **** * System Includes * ******************************************************************************/ ! include_once("database.php"); ! include_once("./vars.inc"); ! ! /****************************************************************************** ! * 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 $HTTP_SESSION_VARS,$CONFIG_VARS; ! ! ! $Output = Theme_Menu_Open($CONFIG_VARS["MenuWidth"],_OPENPOSNAVTITLE); ! ! if (isset($HTTP_SESSION_VARS["openPOSAuthTok"])) ! { ! $Output .= $HTTP_SESSION_VARS["openPOSAuthTok"]." Logged In<p>"; ! } ! else ! { ! $Output .= "Not Logged In<p>"; ! } ! ! $menuArray = GetMenuEntries(); ! ! $Output .= "\n"; ! ! foreach($menuArray as $tmp) ! { ! $Output .= "<a class=\"menu\" href=\"/module/$tmp/module.php\">$tmp</a><br>\n"; ! } ! ! if($HTTP_SESSION_VARS["openPOSAuthRights"] == "SuperUser") ! { ! $Output .= Theme_Add_Menu_Link("./?action=admin", _OPENPOSADMINTITLE) . "<BR>"; ! } ! ! if ( strcmp($SystemConfig['modUserLogin'], "On")) ! { ! if (isset($HTTP_SESSION_VARS["openPOSAuthTok"])) ! { ! $Output .= Theme_Add_Menu_Link("./?action=logout", "Logout") . "<br>"; ! } ! else ! { ! $Output .= Theme_Add_Menu_Link("./?action=login", "Login") . "<br>"; ! } ! } ! $Output .= "\n<BR>"; ! $Output .= Theme_Menu_Close(); ! return $Output; ! } ! ! /****************************************************************************** ! * Function: GetMenuEntries() * ! * -------------------------------------------------------------------------- * ! * This function will access the db, and get all activem, showable menu * ! * menu entries. * ! * * ! * Returned Values * ! * $menuEntries of type Array * ! * * ! * Input Values * ! * None. * ! ******************************************************************************/ ! function GetMenuEntries() ! { ! $query = "SELECT * FROM modules WHERE status='A' AND menu='Y'"; ! $result = DB_Query($query); ! $menuEntires = DB_Fetch_Data_Array($result); ! return $menuEntires; ! } ! ! /****************************************************************************** ! * 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($UserName,$Password) { ! GLOBAL $HTTP_SESSION_VARS; ! $rights = Validate_Password($UserName, $Password); ! //echo "$rights"; ! if ($rights != FALSE) ! { ! $HTTP_SESSION_VARS["openPOSAuthTok"] = $UserName; ! //session_register("openPOSAuthTok"); ! ! //echo "<BR>$UserName = ".$HTTP_SESSION_VARS["openPOSAuthTok"]."<BR>"; ! ! $HTTP_SESSION_VARS["openPOSAuthRights"] = $rights; ! //session_register("openPOSAuthRights"); ! ! $HTTP_SESSION_VARS["action"] = "none"; ! //session_register("action"); ! ! $HTTP_SESSION_VARS["OutputLang"] = NULL; ! //session_register("OutputLang"); ! ! $HTTP_SESSION_VARS["OutputTheme"] = "Default"; ! //session_register("OutputTheme"); ! ! } ! else ! { ! //Not a valid login. figure out a way to pass an error message ! } ! ! header("HTTP/1.0 303 See Other"); ! header("Location: ./"); ! 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)) ! { ! session_unset(); ! session_destroy(); ! header("HTTP/1.0 303 See Other"); ! header("Location: ./"); - } - return; - } - /*End Functions - *******************************************************************************/ global $HTMLOutput, $OutputLang, $Action, $OutputTheme, $SystemConfig; global $UserName, $Password; ! if (!DBInit()) { die("Unable to connect to the database."); } --- 32,45 ---- * System Includes * ******************************************************************************/ ! include_once("./includes/database.php"); ! include_once("./includes/vars.inc"); ! include_once("./includes/functions.php"); global $HTMLOutput, $OutputLang, $Action, $OutputTheme, $SystemConfig; global $UserName, $Password; ! if (!DBInit()) ! { die("Unable to connect to the database."); } *************** *** 233,250 **** */ ! if (!isset($HTTP_SESSION_VARS["action"])) { $HTTP_SESSION_VARS["action"] = "none"; } ! if (!isset($HTTP_SESSION_VARS["OutputLang"])) { $HTTP_SESSION_VARS["OutputLang"] = "eng"; } ! if (!isset($HTTP_SESSION_VARS["OutputTheme"])) { $HTTP_SESSION_VARS["OutputTheme"] = "Default"; } ! //echo $HTTP_SESSION_VARS["openPOSAuthTok"]."<BR>"; ! if (isset($HTTP_SESSION_VARS["openPOSAuthTok"])) { $UserName = $HTTP_SESSION_VARS["openPOSAuthTok"]; } ! //echo $HTTP_SESSION_VARS["openPOSAuthTok"]."<BR>"; $themeFile = "theme/".$HTTP_SESSION_VARS["OutputTheme"]."/theme.php"; --- 50,73 ---- */ ! if (!isset($HTTP_SESSION_VARS["action"])) ! { $HTTP_SESSION_VARS["action"] = "none"; } ! ! if (!isset($HTTP_SESSION_VARS["OutputLang"])) ! { $HTTP_SESSION_VARS["OutputLang"] = "eng"; } ! ! if (!isset($HTTP_SESSION_VARS["OutputTheme"])) ! { $HTTP_SESSION_VARS["OutputTheme"] = "Default"; } ! ! if (isset($HTTP_SESSION_VARS["openPOSAuthTok"])) ! { $UserName = $HTTP_SESSION_VARS["openPOSAuthTok"]; } ! $themeFile = "theme/".$HTTP_SESSION_VARS["OutputTheme"]."/theme.php"; *************** *** 271,281 **** break; case "none": ! $HTMLOutput = Theme_Open_Page(_OPENPOSMAINTITLE); ! $HTMLOutput .= DisplayMainMenu(); $HTMLOutput .= Theme_Close_Page(); break; case "admin": ! $HTMLOutput = DisplayAdminMenu(); break; default: --- 94,136 ---- break; case "none": ! $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"]) ! { ! case "module": ! //module adminsration ! echo "Module admin"; ! $HTTP_GET_VARS["admin"] = NULL; ! break; ! ! case "user": ! //user administration ! echo "user admin"; ! $HTTP_GET_VARS["admin"] = NULL; ! break; ! ! case "system": ! //system administration ! echo "system admin"; ! $HTTP_GET_VARS["admin"] = NULL; ! break; ! ! default: ! include "./admin/index.php"; ! $HTTP_GET_VARS["admin"] = NULL; ! } ! } ! else ! { ! //display some nice message that you must be an admin ! echo _OPENPOSNORIGHTS; ! } ! echo Theme_Close_Page(); break; default: |