[Openfirst-cvscommit] base/config auth.php,1.4,1.5 dbase.php,1.3,1.4 install.php,1.13,1.14 modules.p
Brought to you by:
xtimg
From: <xt...@us...> - 2003-08-23 20:37:34
|
Update of /cvsroot/openfirst/base/config In directory sc8-pr-cvs1:/tmp/cvs-serv14947 Modified Files: auth.php dbase.php install.php modules.php Log Message: Replace mysql functions with new database functions, allowing multiple database types to be used easily. Modify module installer to handle more than just MySQL databases. Index: auth.php =================================================================== RCS file: /cvsroot/openfirst/base/config/auth.php,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** auth.php 20 Aug 2003 23:11:50 -0000 1.4 --- auth.php 23 Aug 2003 20:37:30 -0000 1.5 *************** *** 29,33 **** if(isset($encryption) == false) { $encryption = "crypt"; } - mysql_select_db($sqldatabase,$sqlconnection); // Provide functions for the various encryption types... --- 29,32 ---- *************** *** 80,97 **** if(isset($_SESSION['authcode'])) { $authcode = $_SESSION['authcode']; ! $query = mysql_query("SELECT * FROM ofirst_members WHERE authcode='$authcode';"); ! if(mysql_errno() == 0 && mysql_num_rows($query) == 1) { ! $user = mysql_fetch_object($query); } else { unset($_SESSION['authcode']); ! $query = mysql_query("SELECT * FROM ofirst_members WHERE user='" . $_POST["login"] . "';"); ! if(mysql_errno() == 0) { ! $user = mysql_fetch_object($query); ! if(mysql_num_rows($query) == 1) { if(cryptpassword($_POST["password"], $encryption, $user->password) == $user->password) { session_register("authcode"); $_SESSION["authcode"] = rand(1,50000000); ! $aquery = mysql_query("UPDATE ofirst_members SET authcode='" . $_SESSION["authcode"] . "' WHERE user='" . $_POST["login"] . "';"); } else { unset($user); --- 79,96 ---- if(isset($_SESSION['authcode'])) { $authcode = $_SESSION['authcode']; ! $query = ofirst_dbquery("SELECT * FROM ofirst_members WHERE authcode='$authcode';"); ! if(ofirst_dberrno() == 0 && ofirst_dbnum_rows($query) == 1) { ! $user = ofirst_dbfetch_object($query); } else { unset($_SESSION['authcode']); ! $query = ofirst_dbquery("SELECT * FROM ofirst_members WHERE user='" . $_POST["login"] . "';"); ! if(ofirst_dberrno() == 0) { ! $user = ofirst_dbfetch_object($query); ! if(ofirst_dbnum_rows($query) == 1) { if(cryptpassword($_POST["password"], $encryption, $user->password) == $user->password) { session_register("authcode"); $_SESSION["authcode"] = rand(1,50000000); ! $aquery = ofirst_dbquery("UPDATE ofirst_members SET authcode='" . $_SESSION["authcode"] . "' WHERE user='" . $_POST["login"] . "';"); } else { unset($user); *************** *** 102,113 **** } elseif(isset($_POST["login"]) == true && isset($_POST["password"]) == true) { ! $query = mysql_query("SELECT * FROM ofirst_members WHERE user='" . $_POST["login"] . "';"); ! if(mysql_errno() == 0) { ! $user = mysql_fetch_object($query); ! if(mysql_num_rows($query) == 1) { if(cryptpassword($_POST["password"], $encryption, $user->password) == $user->password) { session_register("authcode"); $_SESSION["authcode"] = rand(1,50000000); ! $aquery = mysql_query("UPDATE ofirst_members SET authcode='" . $_SESSION["authcode"] . "' WHERE user='" . $_POST["login"] . "';"); } else { unset($user); --- 101,112 ---- } elseif(isset($_POST["login"]) == true && isset($_POST["password"]) == true) { ! $query = ofirst_dbquery("SELECT * FROM ofirst_members WHERE user='" . $_POST["login"] . "';"); ! if(ofirst_dberrno() == 0) { ! $user = ofirst_dbfetch_object($query); ! if(ofirst_dbnum_rows($query) == 1) { if(cryptpassword($_POST["password"], $encryption, $user->password) == $user->password) { session_register("authcode"); $_SESSION["authcode"] = rand(1,50000000); ! $aquery = ofirst_dbquery("UPDATE ofirst_members SET authcode='" . $_SESSION["authcode"] . "' WHERE user='" . $_POST["login"] . "';"); } else { unset($user); *************** *** 118,127 **** ! if(mysql_errno() != 0) { // There was an error, check if it's because they didn't create the // members table. ! if(mysql_errno() == 1146) { echo("<p>Members table does not exist, therefore I am creating it.</p>"); ! $query = mysql_query("CREATE TABLE ofirst_members ( UNIQUE(user), user CHAR(128), --- 117,126 ---- ! if(ofirst_dberrno() != 0) { // There was an error, check if it's because they didn't create the // members table. ! if(ofirst_dberrno() == 1146) { echo("<p>Members table does not exist, therefore I am creating it.</p>"); ! $query = ofirst_dbquery("CREATE TABLE ofirst_members ( UNIQUE(user), user CHAR(128), *************** *** 147,155 **** skills TEXT );"); ! if(mysql_errno() == 0) { // Insert a default user 'administrator' and set them to have // administrative access and some password. ! $query = mysql_query("INSERT INTO ofirst_members (user, membertype, password) VALUES('admin', 'administrator', '" . cryptpassword("openfirst", $encryption) ."');"); --- 146,154 ---- skills TEXT );"); ! if(ofirst_dberrno() == 0) { // Insert a default user 'administrator' and set them to have // administrative access and some password. ! $query = ofirst_dbquery("INSERT INTO ofirst_members (user, membertype, password) VALUES('admin', 'administrator', '" . cryptpassword("openfirst", $encryption) ."');"); *************** *** 158,162 **** die(); } else { ! die(mysql_error()); } } --- 157,161 ---- die(); } else { ! die(ofirst_dberror()); } } *************** *** 164,169 **** if(isset($user->user)) { $query = "UPDATE ofirst_members SET lastseen='" . date("h:m:s M d, Y") . "' WHERE user='$user->user';"; ! $q = mysql_query($query); unset($q); } ! ?> \ No newline at end of file --- 163,168 ---- if(isset($user->user)) { $query = "UPDATE ofirst_members SET lastseen='" . date("h:m:s M d, Y") . "' WHERE user='$user->user';"; ! $q = ofirst_dbquery($query); unset($q); } ! ?> Index: dbase.php =================================================================== RCS file: /cvsroot/openfirst/base/config/dbase.php,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** dbase.php 23 Aug 2003 20:28:59 -0000 1.3 --- dbase.php 23 Aug 2003 20:37:30 -0000 1.4 *************** *** 103,113 **** global $dbasetype; if($dbasetype == "mysql") { ! if(function_exists("mysql_error") == false) { die("MySQL support is not available in your version of PHP. To use the openFIRST Web Portal Software, please either enable MySQL support, or choose another database type."); } if($linkidentifier != "") { ! return(mysql_error($linkidentifier)); } else { ! return(mysql_error()); } } elseif ($dbasetype == "mssql") { --- 103,113 ---- global $dbasetype; if($dbasetype == "mysql") { ! if(function_exists("ofirst_dberror") == false) { die("MySQL support is not available in your version of PHP. To use the openFIRST Web Portal Software, please either enable MySQL support, or choose another database type."); } if($linkidentifier != "") { ! return(ofirst_dberror($linkidentifier)); } else { ! return(ofirst_dberror()); } } elseif ($dbasetype == "mssql") { Index: install.php =================================================================== RCS file: /cvsroot/openfirst/base/config/install.php,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** install.php 29 Jun 2003 03:35:14 -0000 1.13 --- install.php 23 Aug 2003 20:37:30 -0000 1.14 *************** *** 26,30 **** * */ ! // Purpose: set up OpenFIRST modules -- currently only installs MySQL tables include("../config/globals.php"); --- 26,30 ---- * */ ! // Purpose: set up OpenFIRST modules include("../config/globals.php"); *************** *** 44,54 **** if(function_exists("glob")) { ! foreach (glob("../*/setup/*.mysql") as $filename) { ! $sqlf = str_replace(".", "-", str_replace(".mysql", "",substr(strrchr($filename, "/"), 1))); ! $dir = str_replace(".", "-", str_replace(".mysql", "", substr(strchr($filename, "/"), 1))); echo("<br /> <input type='checkbox' name='$dir'>$sqlf - $dir</input>"); if(isset($_POST[$dir]) == true && $_POST[$dir] == "on") { ! $q = mysql_query("CREATE table IF NOT EXISTS `ofirst_config` (`modulename` CHAR(25) NOT NULL, `showonmenu` BOOL, `active` BOOL, `adminnavigation` TEXT, `modulenavigation` TEXT, `includes` TEXT, PRIMARY KEY (`modulename`));"); --- 44,54 ---- if(function_exists("glob")) { ! foreach (glob("../*/setup/*.$dbasetype") as $filename) { ! $sqlf = str_replace(".", "-", str_replace(".$dbasetype", "",substr(strrchr($filename, "/"), 1))); ! $dir = str_replace(".", "-", str_replace(".$dbasetype", "", substr(strchr($filename, "/"), 1))); echo("<br /> <input type='checkbox' name='$dir'>$sqlf - $dir</input>"); if(isset($_POST[$dir]) == true && $_POST[$dir] == "on") { ! $q = ofirst_dbquery("CREATE table IF NOT EXISTS `ofirst_config` (`modulename` CHAR(25) NOT NULL, `showonmenu` BOOL, `active` BOOL, `adminnavigation` TEXT, `modulenavigation` TEXT, `includes` TEXT, PRIMARY KEY (`modulename`));"); *************** *** 58,62 **** while($line = fgets($sf)) { if(substr($line, 0, 2) != "--" && substr($line, 0, 1) != "#" && strlen($line) > 0) { ! $q = mysql_query(trim($line)); } } --- 58,62 ---- while($line = fgets($sf)) { if(substr($line, 0, 2) != "--" && substr($line, 0, 1) != "#" && strlen($line) > 0) { ! $q = ofirst_dbquery(trim($line)); } } *************** *** 74,83 **** if($fil != ".." && $fil != "." && $fil != "") { $filename = "../$file/setup/$fil"; ! $sqlf = str_replace(".", "-", str_replace(".mysql", "",substr(strrchr($filename, "/"), 1))); ! $dir = str_replace(".", "-", str_replace(".mysql", "", substr(strchr($filename, "/"), 1))); echo("<br /> <input type='checkbox' name='$dir'>$sqlf - $dir</input>"); if(isset($_POST[$dir]) == true && $_POST[$dir] == "on") { ! $q = mysql_query("CREATE table IF NOT EXISTS `ofirst_config` (`modulename` CHAR(25) NOT NULL, `showonmenu` BOOL, `active` BOOL, `adminnavigation` TEXT, `modulenavigation` TEXT, `includes` TEXT, PRIMARY KEY (`modulename`));"); --- 74,83 ---- if($fil != ".." && $fil != "." && $fil != "") { $filename = "../$file/setup/$fil"; ! $sqlf = str_replace(".", "-", str_replace(".$dbasetype", "",substr(strrchr($filename, "/"), 1))); ! $dir = str_replace(".", "-", str_replace(".$dbasetype", "", substr(strchr($filename, "/"), 1))); echo("<br /> <input type='checkbox' name='$dir'>$sqlf - $dir</input>"); if(isset($_POST[$dir]) == true && $_POST[$dir] == "on") { ! $q = ofirst_dbquery("CREATE table IF NOT EXISTS `ofirst_config` (`modulename` CHAR(25) NOT NULL, `showonmenu` BOOL, `active` BOOL, `adminnavigation` TEXT, `modulenavigation` TEXT, `includes` TEXT, PRIMARY KEY (`modulename`));"); *************** *** 88,92 **** while($line = fgets($sf, 4096)) { if(substr($line, 0, 2) != "--" && substr($line, 0, 1) != "#" && strlen($line) > 0) { ! $q = mysql_query(trim($line)); } } --- 88,92 ---- while($line = fgets($sf, 4096)) { if(substr($line, 0, 2) != "--" && substr($line, 0, 1) != "#" && strlen($line) > 0) { ! $q = ofirst_dbquery(trim($line)); } } Index: modules.php =================================================================== RCS file: /cvsroot/openfirst/base/config/modules.php,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** modules.php 28 Jun 2003 17:29:29 -0000 1.4 --- modules.php 23 Aug 2003 20:37:30 -0000 1.5 *************** *** 38,43 **** // Query for current module information and loop through with while ! $query = mysql_query("SELECT * FROM ofirst_config"); ! while($module = mysql_fetch_object($query)){ // Set values to update db for checkboxes if(isset($_POST[$module->modulename.'-active'])) { $active = "1"; } else { $active = "0"; } --- 38,43 ---- // Query for current module information and loop through with while ! $query = ofirst_dbquery("SELECT * FROM ofirst_config"); ! while($module = ofirst_dbfetch_object($query)){ // Set values to update db for checkboxes if(isset($_POST[$module->modulename.'-active'])) { $active = "1"; } else { $active = "0"; } *************** *** 45,53 **** // Creater query string then update information in database ! mysql_query("UPDATE ofirst_config SET modulename = '".$_POST[$module->modulename.'-modulename']."', includes = '".$_POST[$module->modulename.'-includes']."', showonmenu = '".$showonmenu."', ! active = '".$active."' WHERE modulename = '".$module->modulename."'") or die(mysql_error()); } --- 45,53 ---- // Creater query string then update information in database ! ofirst_dbquery("UPDATE ofirst_config SET modulename = '".$_POST[$module->modulename.'-modulename']."', includes = '".$_POST[$module->modulename.'-includes']."', showonmenu = '".$showonmenu."', ! active = '".$active."' WHERE modulename = '".$module->modulename."'") or die(ofirst_dberror()); } *************** *** 71,76 **** </tr> <?php ! $query = mysql_query("SELECT * FROM ofirst_config"); ! while($module = mysql_fetch_object($query)){ ?> <tr> --- 71,76 ---- </tr> <?php ! $query = ofirst_dbquery("SELECT * FROM ofirst_config"); ! while($module = ofirst_dbfetch_object($query)){ ?> <tr> |