[Openfirst-cvscommit] base/includes Module.php,1.4,1.5 auth.php,1.3,1.4 db_setup.php,1.3,1.4 globals
Brought to you by:
xtimg
From: Astronouth7303 <ast...@us...> - 2005-06-30 03:28:08
|
Update of /cvsroot/openfirst/base/includes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9432/includes Modified Files: Module.php auth.php db_setup.php globals.php Log Message: damn! was using $ofDB! Changed all instances of $ofDB to $ogDB Index: auth.php =================================================================== RCS file: /cvsroot/openfirst/base/includes/auth.php,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** auth.php 30 Jun 2005 02:34:55 -0000 1.3 --- auth.php 30 Jun 2005 03:27:57 -0000 1.4 *************** *** 52,59 **** function logout(){ ! global $ofDB; if(isset($GLOBALS["user"]->user)) { #FIXME: Bad SQL Handling ! $q = $ofDB->query("UPDATE ofirst_members SET authcode = NULL WHERE user='".$GLOBALS["user"]->user."';"); } } --- 52,59 ---- function logout(){ ! global $ogDB; if(isset($GLOBALS["user"]->user)) { #FIXME: Bad SQL Handling ! $q = $ogDB->query("UPDATE ofirst_members SET authcode = NULL WHERE user='".$GLOBALS["user"]->user."';"); } } *************** *** 105,109 **** function InitUser() { ! global $pass_save_disabled, $encryption, $user, $ofDB; // Determine if the user has already logged in with this session. If // they have, set variables indicating this. If they have not, make a --- 105,109 ---- function InitUser() { ! global $pass_save_disabled, $encryption, $user, $ogDB; // Determine if the user has already logged in with this session. If // they have, set variables indicating this. If they have not, make a *************** *** 126,132 **** #FIXME: Bad SQL handling ! $query = $ofDB->query("SELECT * FROM ofirst_members WHERE authcode='$authcode';"); ! if ($ofDB->errorNumber() == 0 && $ofDB->numberOfRows($query) == 1 && $authcode != 0 ) { ! $user = $ofDB->fetchObject($query); } else { unset($_SESSION['authcode']); --- 126,132 ---- #FIXME: Bad SQL handling ! $query = $ogDB->query("SELECT * FROM ofirst_members WHERE authcode='$authcode';"); ! if ($ogDB->errorNumber() == 0 && $ogDB->numberOfRows($query) == 1 && $authcode != 0 ) { ! $user = $ogDB->fetchObject($query); } else { unset($_SESSION['authcode']); *************** *** 137,144 **** if (isset($_POST["login"])){ #FIXME: Bad SQL handling ! $query = $ofDB->query("SELECT * FROM ofirst_members WHERE user='" . $_POST["login"] . "';"); ! if ($ofDB->errorNumber() == 0) { ! $user = $ofDB->fetchObject($query); ! if ($ofDB->numberOfRows($query) == 1) { if (cryptpassword($_POST["password"], false, $user->password) == $user->password) { session_register("authcode"); --- 137,144 ---- if (isset($_POST["login"])){ #FIXME: Bad SQL handling ! $query = $ogDB->query("SELECT * FROM ofirst_members WHERE user='" . $_POST["login"] . "';"); ! if ($ogDB->errorNumber() == 0) { ! $user = $ogDB->fetchObject($query); ! if ($ogDB->numberOfRows($query) == 1) { if (cryptpassword($_POST["password"], false, $user->password) == $user->password) { session_register("authcode"); *************** *** 146,150 **** $_SESSION["authcode"] = (microtime()|mt_rand(1,mt_getrandmax())).substr(gethostbyaddr($_SERVER["REMOTE_ADDR"]),0,40); #FIXME: Bad SQL handling ! $aquery = $ofDB->query("UPDATE ofirst_members SET authcode='" . $_SESSION["authcode"] . "' WHERE user='" . $_POST["login"] . "';"); } else { unset($user); --- 146,150 ---- $_SESSION["authcode"] = (microtime()|mt_rand(1,mt_getrandmax())).substr(gethostbyaddr($_SERVER["REMOTE_ADDR"]),0,40); #FIXME: Bad SQL handling ! $aquery = $ogDB->query("UPDATE ofirst_members SET authcode='" . $_SESSION["authcode"] . "' WHERE user='" . $_POST["login"] . "';"); } else { unset($user); *************** *** 157,164 **** #FIXME: Bad SQL handling ! $query = $ofDB->query("SELECT * FROM ofirst_members WHERE user='{$_POST['login']}';"); ! if ($ofDB->errorNumber() == 0) { ! $user = $ofDB->fetchObject($query); ! if ($ofDB->numberOfRows($query) == 1) { if (cryptpassword($_POST["password"], $encryption, $user->password) == $user->password) { session_register("authcode"); --- 157,164 ---- #FIXME: Bad SQL handling ! $query = $ogDB->query("SELECT * FROM ofirst_members WHERE user='{$_POST['login']}';"); ! if ($ogDB->errorNumber() == 0) { ! $user = $ogDB->fetchObject($query); ! if ($ogDB->numberOfRows($query) == 1) { if (cryptpassword($_POST["password"], $encryption, $user->password) == $user->password) { session_register("authcode"); *************** *** 166,170 **** $_SESSION["authcode"] = (microtime()|mt_rand(1,mt_getrandmax())).$_SERVER['REMOTE_ADDR']; #FIXME: Bad SQL handling ! $aquery = $ofDB->query("UPDATE ofirst_members SET authcode='" . $_SESSION["authcode"] . "' WHERE user='" . $_POST["login"] . "';"); if(!isset($pass_save_disabled)){ if(isset($_POST["savepass"])&&$_POST["savepass"]="1"){ --- 166,170 ---- $_SESSION["authcode"] = (microtime()|mt_rand(1,mt_getrandmax())).$_SERVER['REMOTE_ADDR']; #FIXME: Bad SQL handling ! $aquery = $ogDB->query("UPDATE ofirst_members SET authcode='" . $_SESSION["authcode"] . "' WHERE user='" . $_POST["login"] . "';"); if(!isset($pass_save_disabled)){ if(isset($_POST["savepass"])&&$_POST["savepass"]="1"){ *************** *** 191,195 **** #FIXME: Bad SQL handling $query = "UPDATE ofirst_members SET lastseen='" . date("h:i:s M d, Y") . "' WHERE user='$user->user';"; ! $q = $ofDB->query($query); unset($q); } --- 191,195 ---- #FIXME: Bad SQL handling $query = "UPDATE ofirst_members SET lastseen='" . date("h:i:s M d, Y") . "' WHERE user='$user->user';"; ! $q = $ogDB->query($query); unset($q); } Index: Module.php =================================================================== RCS file: /cvsroot/openfirst/base/includes/Module.php,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Module.php 30 Jun 2005 02:34:55 -0000 1.4 --- Module.php 30 Jun 2005 03:27:57 -0000 1.5 *************** *** 36,49 **** */ /*public*/ function getIDFromDir($dir) { ! global $ofDB; #$dir = strtolower($dir); //Should I do this? if (!isset($this->dirs[$dir])) { ! $sql = 'SELECT '.$ofDB->quoteField('modulename'). ! ' FROM '.$ofDB->quoteTable('config'). ! ' WHERE '.$ofDB->quoteFDPairs(array('dir'=>$dir), ' AND '). ' LIMIT 0,1'; ! $res = $ofDB->query($sql); ! $row = $ofDB->fetchObject($res); ! $ofDB->freeResult($res); $this->dirs[$dir] = $row->modulename; } --- 36,49 ---- */ /*public*/ function getIDFromDir($dir) { ! global $ogDB; #$dir = strtolower($dir); //Should I do this? if (!isset($this->dirs[$dir])) { ! $sql = 'SELECT '.$ogDB->quoteField('modulename'). ! ' FROM '.$ogDB->quoteTable('config'). ! ' WHERE '.$ogDB->quoteFDPairs(array('dir'=>$dir), ' AND '). ' LIMIT 0,1'; ! $res = $ogDB->query($sql); ! $row = $ogDB->fetchObject($res); ! $ogDB->freeResult($res); $this->dirs[$dir] = $row->modulename; } *************** *** 52,65 **** /*public*/ function getDirsFromID($ID) { ! global $ofDB; if (!isset($this->ids[$ID])) { ! $sql = 'SELECT '.$ofDB->quoteField('dir'). ! ' FROM '.$ofDB->quoteTable('config'). ! ' WHERE '.$ofDB->quoteFDPairs(array('modulename'=>$ID), ' AND '); ! $res = $ofDB->query($sql); ! while ($row = $ofDB->fetchObject($res)) { $this->ids[$ID][] = $row->dir; } ! $ofDB->freeResult($res); } return $this->ids[$ID]; --- 52,65 ---- /*public*/ function getDirsFromID($ID) { ! global $ogDB; if (!isset($this->ids[$ID])) { ! $sql = 'SELECT '.$ogDB->quoteField('dir'). ! ' FROM '.$ogDB->quoteTable('config'). ! ' WHERE '.$ogDB->quoteFDPairs(array('modulename'=>$ID), ' AND '); ! $res = $ogDB->query($sql); ! while ($row = $ogDB->fetchObject($res)) { $this->ids[$ID][] = $row->dir; } ! $ogDB->freeResult($res); } return $this->ids[$ID]; *************** *** 102,110 **** function Module($dir) { ! global $ofDB; ! $sql = 'SELECT * FROM '.$ofDB->quoteTable('config').' WHERE '.$ofDB->quoteFDPairs(array('dir'=>$dir), ' AND ').' LIMIT 0,1'; ! $res = $ofDB->query($sql); ! $mod = $ofDB->fetchObject($res); ! $ofDB->freeResult($res); $this->mName = $mod->label; --- 102,110 ---- function Module($dir) { ! global $ogDB; ! $sql = 'SELECT * FROM '.$ogDB->quoteTable('config').' WHERE '.$ogDB->quoteFDPairs(array('dir'=>$dir), ' AND ').' LIMIT 0,1'; ! $res = $ogDB->query($sql); ! $mod = $ogDB->fetchObject($res); ! $ogDB->freeResult($res); $this->mName = $mod->label; *************** *** 129,133 **** $this->mActive = $mod->active; ! $ofDB->freeResult($res); } --- 129,133 ---- $this->mActive = $mod->active; ! $ogDB->freeResult($res); } Index: globals.php =================================================================== RCS file: /cvsroot/openfirst/base/includes/globals.php,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** globals.php 30 Jun 2005 02:34:55 -0000 1.10 --- globals.php 30 Jun 2005 03:27:57 -0000 1.11 *************** *** 73,78 **** require_once('sitesettings.php'); ! $ofDB = new DataBase($DBaseType, $sqlServer, $sqlUser, $sqlPassword); ! $ofDB->selectDB($sqlDatabase); --- 73,78 ---- require_once('sitesettings.php'); ! $ogDB = new DataBase($DBaseType, $sqlServer, $sqlUser, $sqlPassword); ! $ogDB->selectDB($sqlDatabase); *************** *** 96,105 **** */ $ogModuleManager = new ModuleManager; ! $res = $ofDB->query('SELECT '.$ofDB->quoteField('dir'). ! ' FROM '.$ofDB->quoteTable('config')); ! if($ofDB->errorNumber() != 0) { trigger_error('Error while listing modules!', E_USER_ERROR); } ! while($mod =& $ofDB->fetchObject($res)) { $dir = $mod->dir; $module =& $ogModuleManager->addModuleFromDir($dir); --- 96,105 ---- */ $ogModuleManager = new ModuleManager; ! $res = $ogDB->query('SELECT '.$ogDB->quoteField('dir'). ! ' FROM '.$ogDB->quoteTable('config')); ! if($ogDB->errorNumber() != 0) { trigger_error('Error while listing modules!', E_USER_ERROR); } ! while($mod =& $ogDB->fetchObject($res)) { $dir = $mod->dir; $module =& $ogModuleManager->addModuleFromDir($dir); *************** *** 116,120 **** } } ! $ofDB->freeResult($res); if (!preg_match('/\A[a-zA-Z0-9]+\z/',session_id())) { --- 116,120 ---- } } ! $ogDB->freeResult($res); if (!preg_match('/\A[a-zA-Z0-9]+\z/',session_id())) { Index: db_setup.php =================================================================== RCS file: /cvsroot/openfirst/base/includes/db_setup.php,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** db_setup.php 31 May 2005 22:16:58 -0000 1.3 --- db_setup.php 30 Jun 2005 03:27:57 -0000 1.4 *************** *** 1,112 **** ! <?php ! /* ! * openFIRST.base - config/db_setup.php ! * ! * Copyright (C) 2005, ! * openFIRST Project ! * Original Author: Jamie Bliss <ja...@op...> ! * ! * This program is free software; you can redistribute it and/or modify ! * it under the terms of the GNU General Public License as published by ! * the Free Software Foundation; either version 2 of the License, or ! * (at your option) any later version. ! * ! * This program is distributed in the hope that it will be useful, ! * but WITHOUT ANY WARRANTY; without even the implied warranty of ! * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! * GNU General Public License for more details. ! * ! * You should have received a copy of the GNU General Public License ! * along with this program; if not, write to the Free Software ! * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ! * ! */ ! // Purpose: Allow easy and stable configuration of database tables. This ! // includes both setup and modification of said tables. ! require_once('dbase.php'); ! require_once('modules.php'); ! ! /** Gets an array of tables. ! * Uses the current DB connection. The key is the name, the content ! * is a Table class ! */ ! function GetTables() { ! # ! } ! ! /** The class representing a table. ! * This is a wrapper for a SQL table. It allows access to fields, ! * keys, etc. THIS SHOULD NOT BE USED FOR QUERIES! ! */ ! class Table { ! var $mName, $mFields, $mRecords; ! ! /** Constructor ! */ ! function Table() { ! $this->mName = ''; ! $this->mFields = array(); ! $this->mRecords = array(); ! } ! ! /*static*/ function createFromXML($tag) { ! if (!(is_object($tag) && is_a($tag, 'xmlElement'))) return false; ! if ($tag->Name != 'TABLE') return false; ! ! } ! ! /*static*/ function createFromDB($Name) { ! # ! } ! ! /** Gets an array of current fields. ! * The returned array contains just the field names, in order. ! */ ! function getFields() { ! # ! } ! ! /** Adds a field to the table. ! * @param $Name The name of the new field ! * @param $Type The type of the new field ! * @param $Options An associative array of options. Certain elements ! * are required under certain conditions. ! */ ! function addField($Name, $Type, $Options=array()) { ! # ! } ! ! function getFieldType($Name) { ! # ! } ! ! function getFieldOptions($Name) { ! # ! } ! ! function alterField($Name, $Type, $Options) { ! # ! } ! } ! ! /** ! * Only stores meta-data about a table. Does not ! * manipulate it. ! */ ! class liteTable { ! } ! ! /*** SQL Statements ***/ ! /* ! Get information on a table: ! DESCRIBE `{TABLE NAME}` ! Which returns a series of "records" with the "fields": ! Field - some kind of string - Name ! Type - a type (with length and all) - data type ! Null - SET('YES') - whether it can be null ! Key - SET('MUL','PRI','UNI') - what kind of key it is ! Default - the same type as the field - the default value ! Extra - SET('auto_increment') - ! */ ! ! ?> --- 1,112 ---- ! <?php ! /* ! * openFIRST.base - config/db_setup.php ! * ! * Copyright (C) 2005, ! * openFIRST Project ! * Original Author: Jamie Bliss <ja...@op...> ! * ! * This program is free software; you can redistribute it and/or modify ! * it under the terms of the GNU General Public License as published by ! * the Free Software Foundation; either version 2 of the License, or ! * (at your option) any later version. ! * ! * This program is distributed in the hope that it will be useful, ! * but WITHOUT ANY WARRANTY; without even the implied warranty of ! * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! * GNU General Public License for more details. ! * ! * You should have received a copy of the GNU General Public License ! * along with this program; if not, write to the Free Software ! * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ! * ! */ ! // Purpose: Allow easy and stable configuration of database tables. This ! // includes both setup and modification of said tables. ! require_once('dbase.php'); ! #require_once('modules.php'); ! ! /** Gets an array of tables. ! * Uses the current DB connection. The key is the name, the content ! * is a Table class ! */ ! function GetTables() { ! # ! } ! ! /** The class representing a table. ! * This is a wrapper for a SQL table. It allows access to fields, ! * keys, etc. THIS SHOULD NOT BE USED FOR QUERIES! ! */ ! class Table { ! var $mName, $mFields, $mRecords; ! ! /** Constructor ! */ ! function Table() { ! $this->mName = ''; ! $this->mFields = array(); ! $this->mRecords = array(); ! } ! ! /*static*/ function createFromXML($tag) { ! if (!(is_object($tag) && is_a($tag, 'xmlElement'))) return false; ! if ($tag->Name != 'TABLE') return false; ! ! } ! ! /*static*/ function createFromDB($Name) { ! # ! } ! ! /** Gets an array of current fields. ! * The returned array contains just the field names, in order. ! */ ! function getFields() { ! # ! } ! ! /** Adds a field to the table. ! * @param $Name The name of the new field ! * @param $Type The type of the new field ! * @param $Options An associative array of options. Certain elements ! * are required under certain conditions. ! */ ! function addField($Name, $Type, $Options=array()) { ! # ! } ! ! function getFieldType($Name) { ! # ! } ! ! function getFieldOptions($Name) { ! # ! } ! ! function alterField($Name, $Type, $Options) { ! # ! } ! } ! ! /** ! * Only stores meta-data about a table. Does not ! * manipulate it. ! */ ! class liteTable { ! } ! ! /*** SQL Statements ***/ ! /* ! Get information on a table: ! DESCRIBE `{TABLE NAME}` ! Which returns a series of "records" with the "fields": ! Field - some kind of string - Name ! Type - a type (with length and all) - data type ! Null - SET('YES') - whether it can be null ! Key - SET('MUL','PRI','UNI') - what kind of key it is ! Default - the same type as the field - the default value ! Extra - SET('auto_increment') - ! */ ! ! ?> |