From: <ope...@li...> - 2002-08-04 16:06:24
|
Update of /cvsroot/openposs/Server/includes In directory usw-pr-cvs1:/tmp/cvs-serv14567/includes Modified Files: database.php functions.php Added Files: install.php Log Message: Cleaned up logic. Compatable with Output_buffer=off and register_globals=Off. Added install routine. --- NEW FILE: install.php --- <?php $installDBtables[] = "CREATE TABLE ".$_POST["dbname"].".Configuration (`Parameter` varchar(255) NOT NULL default '',`Value` varchar(255) NOT NULL default '');"; $installDBtables[] = "CREATE TABLE ".$_POST["dbname"].".Stock_list (sku int(6) unsigned zerofill NOT NULL auto_increment,Product varchar(100) NOT NULL default '',Description text,catagory int(6) NOT NULL default '999999',OrderCode varchar(50) NOT NULL default '',ScanCode varchar(50) NOT NULL default '',Cost decimal(7,2) unsigned NOT NULL default '0.00',Price decimal(7,2) NOT NULL default '0.00',StockLevel int(11) NOT NULL default '0',MinStockLevel int(11) NOT NULL default '0',StorageCap int(11) NOT NULL default '0',ShelfCap int(11) NOT NULL default '0',PRIMARY KEY (sku));"; $installDBtables[] = "CREATE TABLE ".$_POST["dbname"].".SystemUsers (uid int auto_increment PRIMARY KEY,UserName varchar(255) NOT NULL default '',FullName varchar(255) NOT NULL default '',Password varchar(255) NOT NULL default '',Active tinyint NOT NULL default 0,SuperUser tinyint NOT NULL default 0);"; $installDBtables[] = "CREATE TABLE ".$_POST["dbname"].".SystemGroups (gid int auto_increment PRIMARY KEY,GroupName varchar(255) NOT NULL default '',Active tinyint NOT NULL default 1);"; $installDBtables[] = "CREATE TABLE ".$_POST["dbname"].".modules (name varchar(25) NOT NULL default '',desciption varchar(100) default NULL,version varchar(15) NOT NULL default '',status enum('A','I') NOT NULL default 'I',menu enum('Y','N') NOT NULL default 'N',UNIQUE KEY name (name)) TYPE=MyISAM;"; $installDBtables[] = "CREATE TABLE ".$_POST["dbname"].".UserToGroup (uid int NOT NULL PRIMARY KEY,gid int NOT NULL,KEY idx_gid (gid));"; $installDBtables[] = "CREATE TABLE ".$_POST["dbname"].".UserRights (uid int PRIMARY KEY,Access int);"; $installDBtables[] = "CREATE TABLE ".$_POST["dbname"].".GroupRights (gid int PRIMARY KEY,ACCESS int);"; $installDBtables[] = "CREATE TABLE ".$_POST["dbname"].".AuditLog (aid int auto_increment PRIMARY KEY,uid int,DT datetime, Action varchar(255),KEY idx_AuditLog_uid (uid));"; $installDBtables[] = "CREATE TABLE ".$_POST["dbname"].".Transactions (tid int auto_increment PRIMARY KEY,uid int,oid int,term_ip varchar(15),DT datetime,KEY idx_Transaction_uid (uid));"; $installDBtables[] = "CREATE TABLE ".$_POST["dbname"].".OrderItems (iid int PRIMARY KEY,sid int);"; $installDBtables[] = "CREATE TABLE ".$_POST["dbname"].".Orders (oid int auto_increment PRIMARY KEY,iid int,cid int);"; $installDBtables[] = "CREATE TABLE ".$_POST["dbname"].".Customers (cid int auto_increment PRIMARY KEY,Surname varchar(255),GivenNames varchar(255),PostalAddress varchar(255),PostalSuburb varchar(255),PostalState char(5),PostalZip char(10),PostalCountry varchar(255),BillingAddress varchar(255),BillingSuburb varchar(255),BillingState char(5),BillingZip char(10),BillingCountry varchar(255),HomePhone varchar(25) NULL,WorkPhone varchar(25) NULL,OtherPhone varchar(25) NULL,KEY idx_Customer_Surname (Surname(10)));"; $installDBtables[] = "CREATE TABLE ".$_POST["dbname"].".inv_catagories (id int(6) unsigned NOT NULL auto_increment,name varchar(50) NOT NULL default '',description varchar(150) default NULL,parent int(6) unsigned NOT NULL default '0',active enum('A','I') NOT NULL default 'A',PRIMARY KEY (id));"; $installConfig[] = "INSERT INTO ".$_POST["dbname"].".modules VALUES ('Transaction', 'The transaction module', '0.1.0', 'A', 'Y');"; $installConfig[] = "INSERT INTO ".$_POST["dbname"].".modules VALUES ('Inventory', 'The inventory management module', '0.1.0', 'A', 'Y');"; $installConfig[] = "INSERT INTO ".$_POST["dbname"].".modules VALUES ('Quote', NULL, '0.1.0', 'A', 'Y');"; $installConfig[] = "INSERT INTO ".$_POST["dbname"].".modules VALUES ('Scheduling', NULL, '0.1.0', 'A', 'Y');"; //$installConfig[] = "INSERT INTO ".$_POST["dbname"].".SystemUsers (UserName, FullName, Password, Active, SuperUser) VALUES ('Admin', 'openPOS Admin User', '7c524cbe562633af1c281279e048dc5b', 1, '127');"; $installConfig[] = "INSERT INTO ".$_POST["dbname"].".Configuration (`Parameter`, `Value`) VALUES ('DBVersion', 'DEV 0.1');"; $installConfig[] = "INSERT INTO ".$_POST["dbname"].".Configuration (`Parameter`, `Value`) VALUES ('modUserManage', 'On');"; $installConfig[] = "INSERT INTO ".$_POST["dbname"].".Configuration (`Parameter`, `Value`) VALUES ('modUserLogin', 'On');"; $installConfig[] = "INSERT INTO ".$_POST["dbname"].".Configuration (`Parameter`, `Value`) VALUES ('modUserSecurity', 'On');"; $installConfig[] = "INSERT INTO ".$_POST["dbname"].".Configuration (`Parameter`, `Value`) VALUES ('modUserTypes', 'On');"; $installConfig[] = "INSERT INTO ".$_POST["dbname"].".Configuration (`Parameter`, `Value`) VALUES ('systemInstalled', 'No');"; /****************************************************************************** * Function: Install_Form_Screen() * * -------------------------------------------------------------------------- * * This function is used to produce a HTML web page that is used as the * * install page for the openPOS System. * * * * Returned Values * * HTML Webpage. * * * * Input Values * * None. * ******************************************************************************/ function Install_Form_Screen($title) { global $DBTypesADODB; $Output = Theme_Open_Page(_OPENPOSINSTALLTITLE,"NO")."<DIV ALIGN=\"CENTER\">"; $Output .= "<FORM ACTION=\"$PHP_SELF\" METHOD=\"POST\">"; $Output .= Theme_Menu_Open("500",_OPENPOSINSTALLFORM)."<CENTER>".Theme_Open_Table("100%"); $Output .= Theme_Open_Row().Theme_Open_Data_Cell("Right","35%"); $Output .= "Server Name:".Theme_Close_Data_Cell().Theme_Open_Data_Cell(); $Output .= "<INPUT TYPE=\"TEXT\" NAME=\"server\">"; $Output .= Theme_Close_Data_Cell().Theme_Close_Row(); $Output .= Theme_Open_Row().Theme_Open_Data_Cell("Right","35%"); $Output .= "Username".Theme_Close_Data_Cell().Theme_Open_Data_Cell(); $Output .= "<INPUT TYPE=\"TEXT\" NAME=\"username\">"; $Output .= Theme_Close_Data_Cell().Theme_Close_Row(); $Output .= Theme_Open_Row().Theme_Open_Data_Cell("Right","35%"); $Output .= "Password".Theme_Close_Data_Cell().Theme_Open_Data_Cell(); $Output .= "<INPUT TYPE=\"PASSWORD\" NAME=\"password\">".Theme_Close_Data_Cell(); $Output .= Theme_Close_Row().Theme_Open_Row(); $Output .= Theme_Open_Row().Theme_Open_Data_Cell("Right","35%"); $Output .= "Database Name".Theme_Close_Data_Cell().Theme_Open_Data_Cell(); $Output .= "<INPUT TYPE=\"TEXT\" NAME=\"dbname\">"; $Output .= Theme_Close_Data_Cell().Theme_Close_Row(); $Output .= Theme_Open_Row().Theme_Open_Data_Cell("Right","35%"); $Output .= "Database Type".Theme_Close_Data_Cell().Theme_Open_Data_Cell(); $Output .= "<SELECT NAME=\"dbtype\" SIZE=1>"; $Output .= $DBTypesADODB; $Output .= "</SELECT>\n"; $Output .= Theme_Close_Data_Cell().Theme_Close_Row().Theme_Close_Table(); $Output .= "<hr width=\"85%\">"; $Output .= Theme_Open_Table("100%"); $Output .= Theme_Open_Row().Theme_Open_Data_Cell("Right","35%"); $Output .= "System Admin Username:".Theme_Close_Data_Cell().Theme_Open_Data_Cell(); $Output .= "<INPUT TYPE=\"TEXT\" NAME=\"adminUsername\">"; $Output .= Theme_Close_Data_Cell().Theme_Close_Row(); $Output .= Theme_Open_Row().Theme_Open_Data_Cell("Right","35%"); $Output .= "System Admin Password:".Theme_Close_Data_Cell().Theme_Open_Data_Cell(); $Output .= "<INPUT TYPE=\"PASSWORD\" NAME=\"adminPassword\">"; $Output .= Theme_Close_Data_Cell().Theme_Close_Row(); $Output .= Theme_Open_Row().Theme_Open_Data_Cell("Right","35%"); $Output .= "Admin Full Name:".Theme_Close_Data_Cell().Theme_Open_Data_Cell(); $Output .= "<INPUT TYPE=\"TEXT\" NAME=\"adminFullName\">"; $Output .= Theme_Close_Data_Cell().Theme_Close_Row(); $Output .= Theme_Open_Data_Cell("CENTER","","2"); $Output .= "<BUTTON NAME=\"submit\" VALUE=\"submit\" TYPE=\"submit\">Login</BUTTON> "; $Output .= "<BUTTON NAME=\"cancel\" TITLE=\"Cancel\" TYPE=\"submit\">Cancel</BUTTON>".Theme_Close_Data_Cell(); $Output .= Theme_Close_Row(); $Output .= Theme_Close_Table().Theme_Menu_Close()."</FORM></DIV>".Theme_Close_Page(); return $Output; } //****************Config File Template************************** $configTemplate = "<?php # # Filename: config.php # Date : $currentDate # Purpose : To provide initial configuration information prior to getting the # database connection up and running. # ############################################################################### # Last Update | Who | Changes Made # #-------------+-----+---------------------------------------------------------# # Apr 6, 2002 | BAC | Initial file design # ############################################################################### # Who Key # BAC - Brian A Cheeseman # \$DBConfig['Server']=\"".$_POST["server"]."\"; \$DBConfig['UserName']=\"".$_POST["username"]."\"; \$DBConfig['Password']=\"".$_POST["password"]."\"; \$DBConfig['DBName']=\"".$_POST["dbname"]."\"; \$DBConfig['DBType']=\"".$_POST["dbtype"]."\"; \$DBConfig['CurrentVersion']=\"DEV 0.1\"; \$DBFields['desc'] = \"Description\"; \$DBFields['ordc'] = \"OrderCode\"; \$DBFields['scnc'] = \"ScanCode\"; \$DBFields['pric'] = \"Price\"; \$DBFields['stkl'] = \"StockLevel\"; \$DBFields['minl'] = \"MinStockLevel\"; \$DBFields['stor'] = \"StorageCap\"; \$DBFields['shel'] = \"ShelfCap\"; ?>"; ?> Index: database.php =================================================================== RCS file: /cvsroot/openposs/Server/includes/database.php,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** database.php 14 Jul 2002 19:54:09 -0000 1.1 --- database.php 4 Aug 2002 16:06:21 -0000 1.2 *************** *** 14,19 **** # BAC - Brian A Cheeseman # ! ! include_once('config.php'); // Include the database connection information. define('ADODB_DIR', 'adodb'); // define the location of the adodb software. include_once('adodb/adodb.inc.php'); // Include the adodb database code. --- 14,33 ---- # BAC - Brian A Cheeseman # ! if(file_exists("./config.php")) ! { ! include_once('config.php'); // Include the database connection information. ! } ! else ! { ! //Most likley, the install routine has not been completed. ! if($PHP_SELF != "/Server/install.php") ! { ! session_unset(); ! session_destroy(); ! $_SESSION["action"] = NULL; ! die("<center><h3>You must complete the <a href=\"./install.php\">install</a> routine before you can use the OpenPOS System. ! Please see the install documentation.<p> </h3></center>"); ! } ! } define('ADODB_DIR', 'adodb'); // define the location of the adodb software. include_once('adodb/adodb.inc.php'); // Include the adodb database code. *************** *** 49,53 **** // Create a Handle to the database. $DBHandle = $DBConn->Connect($DBServer, $DBUserName, $DBPassword, $DBName); ! if (!$DBHandle) { die("Failed to connect to $DBType://$DBUserName:$DBPassword@$DBServer/$DBName\n".$DBConn->ErrorMsg()); } --- 63,68 ---- // Create a Handle to the database. $DBHandle = $DBConn->Connect($DBServer, $DBUserName, $DBPassword, $DBName); ! if (!$DBHandle) ! { die("Failed to connect to $DBType://$DBUserName:$DBPassword@$DBServer/$DBName\n".$DBConn->ErrorMsg()); } *************** *** 73,86 **** //Check to see if the install routine has been completed ! if($SystemConfig["systemInstalled"] == "No") ! { ! //The install routine has not been run. Direct them to it. ! die("<center><h3>You must complete the install.php routine before you can use the OpenPOS System. ! Please see the install documentation.<p> Note: Since the OpenPOS System is still in the ! early stages of development, you will need to go into the table <i>configuration</i> of the ! <i>openPOS</i> database and adjust the value of the field \"systemInstalled\" to \"Yes\". In ! the near future, we will have a working install script, but that may be the last item completed ! before release 0.1.0.</h3></center>"); ! } return true; } --- 88,92 ---- //Check to see if the install routine has been completed ! return true; } *************** *** 120,123 **** --- 126,130 ---- * $UserName, $Password * ******************************************************************************/ + //Perhaps this should be moved to an all purpose 'funcitons' file? cws function Validate_Password($UserName, $Password) *************** *** 128,131 **** --- 135,140 ---- $ADODB_FETCH_MODE = ADODB_FETCH_NUM; $result = $DBConn->Execute($sql); + //$rows = $result->NumRows(); + //echo "$rows <br>"; if ($result->NumRows() > 0) { *************** *** 155,159 **** { GLOBAL $DBConn; ! if ($result === false) die("failed"); while (!$result->EOF) { --- 164,171 ---- { GLOBAL $DBConn; ! if ($result === false) ! { ! return FALSE; ! } while (!$result->EOF) { *************** *** 163,167 **** return $data_array; } - - ?> --- 175,177 ---- Index: functions.php =================================================================== RCS file: /cvsroot/openposs/Server/includes/functions.php,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** functions.php 14 Jul 2002 19:54:09 -0000 1.1 --- functions.php 4 Aug 2002 16:06:21 -0000 1.2 *************** *** 12,18 **** * None. * ******************************************************************************/ ! function DisplayMainMenu() { ! GLOBAL $HTTP_SESSION_VARS,$CONFIG_VARS; $Output = Theme_Menu_Open($CONFIG_VARS["MenuWidth"],_OPENPOSNAVTITLE); --- 12,19 ---- * None. * ******************************************************************************/ ! function DisplayMainMenu() ! { + GLOBAL $HTTP_SESSION_VARS,$CONFIG_VARS; $Output = Theme_Menu_Open($CONFIG_VARS["MenuWidth"],_OPENPOSNAVTITLE); *************** *** 127,131 **** function ProcessLoginRequest($UserName,$Password) { GLOBAL $HTTP_SESSION_VARS; ! $rights = Validate_Password($UserName, $Password); //echo "$rights"; if ($rights != FALSE) --- 128,132 ---- function ProcessLoginRequest($UserName,$Password) { GLOBAL $HTTP_SESSION_VARS; ! $rights = Validate_Password($UserName,$Password); //echo "$rights"; if ($rights != FALSE) *************** *** 141,145 **** //Not a valid login. figure out a way to pass an error message } - header("HTTP/1.0 303 See Other"); header("Location: ./"); --- 142,145 ---- *************** *** 167,177 **** header("HTTP/1.0 303 See Other"); header("Location: ./"); - } return; } /*End Functions *******************************************************************************/ - ?> --- 167,178 ---- header("HTTP/1.0 303 See Other"); header("Location: ./"); } return; } + + + /*End Functions *******************************************************************************/ ?> |