[Openfirst-cvscommit] base/includes compatibility.php,NONE,1.1 modules.php,NONE,1.1 auth.php,1.1,1.2
Brought to you by:
xtimg
From: Astronouth7303 <ast...@us...> - 2005-05-26 21:00:44
|
Update of /cvsroot/openfirst/base/includes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25684/includes Modified Files: auth.php db_setup.php dbase.php globals.php sitesettings.tpl Added Files: compatibility.php modules.php Log Message: radical changes, with more to come Index: sitesettings.tpl =================================================================== RCS file: /cvsroot/openfirst/base/includes/sitesettings.tpl,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** sitesettings.tpl 25 May 2005 21:44:29 -0000 1.1 --- sitesettings.tpl 26 May 2005 21:00:03 -0000 1.2 *************** *** 8,35 **** * database, in the ofirst_config table. */ ! $dbasetype = %DBTYPE%; ! $encryption = %ENCRYPT%; ! $title = %TITLE%; ! $version = %VER%; ! $sqlserver = %DBSERVER%; ! $sqluser = %DBUSER%; ! $sqlpassword = %DBPASS%; ! $sqldatabase = %DBNAME%; ! $sqlconnection = ofirst_dbconnect("$sqlserver","$sqluser","$sqlpassword"); ! ofirst_select_db($sqldatabase); ! ! $pass_save_disabled=%COOKIE%; ! $regenabled=%REG%; ! $home = %HOME%; ! $header = %HEADER%; ! $footer = %FOOTER%; ! $mailnotify = %MASTERMAIL%; ! $mailfrom = %BOTMAIL%; ! $server = %SERVER%; ! $basepath = %BASEPATH%; ! $fbasepath = %FBASEPATH%; ?> --- 8,36 ---- * database, in the ofirst_config table. */ ! $DBaseType = %DBTYPE%; ! $Encryption = %ENCRYPT%; ! $Title = %TITLE%; ! $Version = %VER%; ! $sqlServer = %DBSERVER%; ! $sqlUser = %DBUSER%; ! $sqlPassword = %DBPASS%; ! $sqlDatabase = %DBNAME%; ! $sqlConnection = ofirst_dbconnect($sqlServer, $sqlUser, $sqlPassword); ! ofirst_select_db($sqlDatabase); + $PassSaveDisabled = %COOKIE%; + $regEnabled = %REG%; + $Server = %SERVER%; + $BasePath = %BASEPATH%; + $fBasePath = %FBASEPATH%; + $Home = %HOME%; + $StylePath = "$BasePath/style"; + $fStylePath = "$fBasePath/style"; + $Header = %HEADER%; + $Footer = %FOOTER%; + $MailNotify = %MASTERMAIL%; + $MailFrom = %BOTMAIL%; ?> Index: auth.php =================================================================== RCS file: /cvsroot/openfirst/base/includes/auth.php,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** auth.php 25 May 2005 21:44:29 -0000 1.1 --- auth.php 26 May 2005 21:00:03 -0000 1.2 *************** *** 87,92 **** echo " <br /><input type=checkbox name=savepass id=savepass value=1 checked /><label for=savepass>Save Password</label>"; } echo "</td></tr> ! <tr><td colspan='2'><a href=\"".$GLOBALS["basepath"]."/members/forgotten.php\">Forgot Password</a></td></tr> </table>"; --- 87,93 ---- echo " <br /><input type=checkbox name=savepass id=savepass value=1 checked /><label for=savepass>Save Password</label>"; } + global $BasePath; echo "</td></tr> ! <tr><td colspan='2'><a href=\"".htmlentities($BasePath)."/members/forgotten.php\">Forgot Password</a></td></tr> </table>"; *************** *** 157,161 **** session_register("authcode"); mt_srand(microtime() * 1000000); ! $_SESSION["authcode"] = (microtime()|mt_rand(1,mt_getrandmax())).substr($_SERVER["REMOTE_HOST"],0,40); $aquery = ofirst_dbquery("UPDATE ofirst_members SET authcode='" . $_SESSION["authcode"] . "' WHERE user='" . $_POST["login"] . "';"); if(!isset($pass_save_disabled)){ --- 158,162 ---- session_register("authcode"); mt_srand(microtime() * 1000000); ! $_SESSION["authcode"] = (microtime()|mt_rand(1,mt_getrandmax())).$_SERVER['REMOTE_ADDR']; $aquery = ofirst_dbquery("UPDATE ofirst_members SET authcode='" . $_SESSION["authcode"] . "' WHERE user='" . $_POST["login"] . "';"); if(!isset($pass_save_disabled)){ --- NEW FILE: compatibility.php --- <?php /* * openFIRST.base - includes/compatibility.php * * Copyright (C) 2003, * 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. * 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: Provides functions and constants not available in certain versions of PHP. if (!defined('PATH_SEPARATOR')) { switch ($ostype) { case osWINDOWS: define('PATH_SEPARATOR', ';'); break; case osUNIX: define('PATH_SEPARATOR', ':'); break; } } ?> Index: globals.php =================================================================== RCS file: /cvsroot/openfirst/base/includes/globals.php,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** globals.php 25 May 2005 22:45:12 -0000 1.1 --- globals.php 26 May 2005 21:00:03 -0000 1.2 *************** *** 1,5 **** <?php /* ! * openFIRST.base - config/globals.php * * Copyright (C) 2003, --- 1,5 ---- <?php /* ! * openFIRST.base - includes/globals.php * * Copyright (C) 2003, *************** *** 43,57 **** } if (substr(PHP_OS, 0, 3) == 'WIN') { ! $ostype = 'windows'; } else { ! $ostype = 'unix'; } ! if ($ostype == 'windows') { ! set_include_path( get_include_path().";$configdir/;."); ! } else { ! set_include_path( get_include_path().":$configdir/:."); ! } unset($configdir); --- 43,60 ---- } + define('osUNKNOWN', -1); + define('osUNIX', 0); + define('osWINDOWS', 1); + #Add more operating systems here + if (substr(PHP_OS, 0, 3) == 'WIN') { ! $osType = osWINDOWS; } else { ! $osType = osUNIX; } ! require_once('compatibility.php'); ! ! set_include_path( get_include_path().PATH_SEPARATOR."$configdir/".PATH_SEPARATOR."."); unset($configdir); *************** *** 61,64 **** --- 64,71 ---- require_once('sitesettings.php'); + if (!isset($sqlTablePrefix)) { + $sqlTablePrefix = 'ofirst_'; + } + if(function_exists("ofirst_dbconnect") == false) { die("Your version of PHP has not been compiled with SQL support, therefore the openFIRST web portal system cannot run on this system. Please contact your system administrator to request SQL support for your version of PHP."); *************** *** 73,82 **** // Determine what module the user is viewing ! $currentmodule = str_replace($basepath, '', $_SERVER['SCRIPT_NAME']); $currentmodule = substr($currentmodule, 1, strpos($currentmodule, '/', 2) - 1); - session_start(); // Include the functions using glob(); ! foreach (glob("$fbasepath/config/functions/*.php") as $filename) { include_once($filename); } --- 80,88 ---- // Determine what module the user is viewing ! $currentmodule = str_replace($BasePath, '', $_SERVER['SCRIPT_NAME']); $currentmodule = substr($currentmodule, 1, strpos($currentmodule, '/', 2) - 1); // Include the functions using glob(); ! foreach (glob("$fBasePath/includes/functions/*.php") as $filename) { include_once($filename); } *************** *** 89,93 **** function AddModule($code, $name, $version, $includes, $adminnav, $modulenav, $active, $show) { ! global $Modules; $Modules[$code] = array( 'name' => $name, --- 95,99 ---- function AddModule($code, $name, $version, $includes, $adminnav, $modulenav, $active, $show) { ! global $Modules, $BasePath; $Modules[$code] = array( 'name' => $name, *************** *** 96,99 **** --- 102,107 ---- 'admin' => $adminnav, 'nav' => $modulenav, + # 'admin' => str_ireplace('$BasePath', $BasePath, $adminnav), + # 'nav' => str_ireplace('$BasePath', $BasePath, $modulenav), 'active' => (bool)$active, 'show' => (bool)$show *************** *** 125,133 **** // Loop through the inclist and add them according to their paths foreach($inclist As $inc){ ! include_once("$fbasepath/$module->modulename/$inc"); } } else { // If there is only 1 include available then use this line to include it instead ! include_once("$fbasepath/$module->modulename/$module->includes"); } } --- 133,141 ---- // Loop through the inclist and add them according to their paths foreach($inclist As $inc){ ! include_once("$fBasePath/$module->modulename/$inc"); } } else { // If there is only 1 include available then use this line to include it instead ! include_once("$fBasePath/$module->modulename/$module->includes"); } } *************** *** 137,150 **** // If it is the current module then color the item if ($currentmodule == $module->modulename){ ! $headers .= " » <a class='menu selected' href='$basepath/$module->modulename'>".ucwords($module->modulename)."</a> | "; // Declare important variables so that headers can pick them up and preview them ! $adminnav = str_replace("\$basepath", $basepath, $module->adminnavigation) . " <a href='http://bugzilla.openfirst.org'>Report Bug</a>"; ! $subnav = str_replace("\$basepath", $basepath, $module->modulenavigation); } else { ! $headers .= " » <a class='menu' href='$basepath/$module->modulename'>".ucwords($module->modulename)."</a> | "; } --- 145,158 ---- // If it is the current module then color the item if ($currentmodule == $module->modulename){ ! $headers .= " » <a class='menu selected' href='$BasePath/$module->modulename'>".ucwords($module->modulename)."</a> | "; // Declare important variables so that headers can pick them up and preview them ! $adminnav = str_ireplace('$BasePath', $BasePath, $module->adminnavigation) . " <a href='http://bugzilla.openfirst.org'>Report Bug</a>"; ! $subnav = str_ireplace('$BasePath', $BasePath, $module->modulenavigation); } else { ! $headers .= " » <a class='menu' href='$BasePath/$module->modulename'>".ucwords($module->modulename)."</a> | "; } --- NEW FILE: modules.php --- <?php /* * openFIRST.base - includes/mdoules.php * * Copyright (C) 2003, * 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: Defines the Module class, which loads metadata about a module // and handles installation/removal/upgrading require_once('db_setup.php'); class Module { /*private*/ var $mName, $mCode, $mVersion, $mAuthor, $mMaintainer; /*private*/ var $mIncludes, $mNavBar, $mAdminBar, $mTables; // XML /*private*/ var $mxmlCurTag, $mRootElement; function Module($File) { $hXML = false; if (!($fp = @fopen($File, 'r'))) { return; } $hXML = xml_parser_create(); xml_set_object($hXML, $this); xml_set_element_handler($hXML, 'startElement', 'endElement'); xml_set_character_data_handler($hXML, 'characterData'); xml_parse($hXML, $this->getModuleDTD(), false); #Add predefined entities while ($data = fread($fp, 1024)) { if (!xml_parse($hXML, $data, feof($fp))) { xml_parser_free($hXML); unset($hXML); return; } } xml_parser_free($hXML); unset($hXML); } /*** STATIC FUNCTIONS ***/ /** Creates a Module object from a directory in the oF directory. */ /*static*/ function createFromDir($Dir) { global $fBasePath; return new Module("$fBasePath/$Dir/openfirst.info.xml"); } /** Creates a Module object from an absolute directory. */ /*static*/ function createFromAbsDir($Dir) { return new Module("$Dir/openfirst.info.xml"); } /** Creates a Module object from a specifc file. */ /*static*/ function createFromFile($File) { return new Module($File); } /*** PRIVATE FUNCTIONS ***/ /*private*/ function getModuleDTD() { /* global $BasePath, $StylePath; $xmlBasePath = str_replace(array('&', '<', '>', '"', '\'' ), array('&', '<', '>', '"e;', '''), $BasePath ); $xmlStylePath = str_replace(array('&', '<', '>', '"', '\'' ), array('&', '<', '>', '"e;', '''), $StylePath ); return "<!DOCTYPE module [ <!ENTITY BasePath \"$xmlBasePath\"> <!ENTITY StylePath \"$xmlStylePath\"> ]>";*/ return '<!DOCTYPE module [ <!ENTITY BasePath "$BasePath"> <!ENTITY StylePath "$StylePath"> ]>'; } /*** XML PARSER HOOKS ***/ function startElement($parser, $name, $attrs) { if (isset($this->mxmlCurTag)) { $this->mxmlCurTag =& $this->mxmlCurTag->addElement($name, $attrs); $this->mRootElement =& $this->mxmlCurTag; } else { $ClassName = $xmlClassNames['']; $this->mxmlCurTag =& new xmlElement($name, $attrs, $this); } } function endElement($parser, $name) { $this->mxmlCurTag =& $this->mxmlCurTag->getParent(); } function characterData($parser, $data) { $this->mxmlCurTag =& $this->mxmlCurTag->addCData($data); } } class xmlElement { var $Name, $Attributes, $Contents, $parent; /*public*/ function Element($Name, $Attributes, &$ParentElement=null) { $this->Name = $Name; $this->Attributes = $Attributes; $this->Contents = array(); $this->parent =& $ParentElement; } /*public*/ function addCData($Text) { return $this->Contents[] = $Text; } /*public*/ function &addElement($Name, $Attrs) { global $xmlClassNames; $ClassName = $xmlClassNames['Element']; return $this->Contents[] =& new $ClassName($Name, $Attrs, &$this); } /*public*/ function &getParent() { return $this->parent; } } ?> Index: dbase.php =================================================================== RCS file: /cvsroot/openfirst/base/includes/dbase.php,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** dbase.php 25 May 2005 21:44:29 -0000 1.1 --- dbase.php 26 May 2005 21:00:03 -0000 1.2 *************** *** 1,5 **** <?php /* ! * openFIRST.base - config/dbase.php * * Copyright (C) 2003, --- 1,5 ---- <?php /* ! * openFIRST.base - includes/dbase.php * * Copyright (C) 2003, *************** *** 27,31 **** // different versions. $lastquery = ''; ! if(isset($dbasetype) == false) { $dbasetype = "mysql"; } --- 27,31 ---- // different versions. $lastquery = ''; ! if(isset($DBaseType) == false) { $DBaseType = "mysql"; } *************** *** 41,46 **** function ofirst_dbconnect($server = "", $username = "", $password = "", $newlink = "", $intclientflags = "") { ! global $dbasetype, $connectdsn; ! if($dbasetype == "mysql") { if(function_exists("mysql_connect") == 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."); --- 41,46 ---- function ofirst_dbconnect($server = "", $username = "", $password = "", $newlink = "", $intclientflags = "") { ! global $DBaseType, $connectdsn; ! if($DBaseType == "mysql") { if(function_exists("mysql_connect") == 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."); *************** *** 53,62 **** return(mysql_connect($server, $username, $password)); } ! } elseif ($dbasetype == "mssql") { if(function_exists("mssql_connect") == false) { die("Microsoft SQL support is not available in your version of PHP. To use the openFIRST Web Portal Software, please either enable Microsoft SQL support, or choose another database type."); } return(mssql_connect($server, $username, $password)); ! } elseif ($dbasetype == "odbc") { if(function_exists("odbc_connect") == false) { die("ODBC support is not available in your version of PHP. To use the openFIRST Web Portal Software, please either enable ODBC support, or choose another database type."); --- 53,62 ---- return(mysql_connect($server, $username, $password)); } ! } elseif ($DBaseType == "mssql") { if(function_exists("mssql_connect") == false) { die("Microsoft SQL support is not available in your version of PHP. To use the openFIRST Web Portal Software, please either enable Microsoft SQL support, or choose another database type."); } return(mssql_connect($server, $username, $password)); ! } elseif ($DBaseType == "odbc") { if(function_exists("odbc_connect") == false) { die("ODBC support is not available in your version of PHP. To use the openFIRST Web Portal Software, please either enable ODBC support, or choose another database type."); *************** *** 72,77 **** function ofirst_select_db($databasename, $linkidentifier = "") { ! global $dbasetype, $connectdsn; ! if($dbasetype == "mysql") { if(function_exists("mysql_select_db") == 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."); --- 72,77 ---- function ofirst_select_db($databasename, $linkidentifier = "") { ! global $DBaseType, $connectdsn; ! if($DBaseType == "mysql") { if(function_exists("mysql_select_db") == 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."); *************** *** 82,86 **** return(mysql_select_db($databasename)); } ! } elseif ($dbasetype == "mssql") { if(function_exists("mssql_select_db") == false) { die("Microsoft SQL support is not available in your version of PHP. To use the openFIRST Web Portal Software, please either enable Microsoft SQL support, or choose another database type."); --- 82,86 ---- return(mysql_select_db($databasename)); } ! } elseif ($DBaseType == "mssql") { if(function_exists("mssql_select_db") == false) { die("Microsoft SQL support is not available in your version of PHP. To use the openFIRST Web Portal Software, please either enable Microsoft SQL support, or choose another database type."); *************** *** 97,102 **** function ofirst_dberrno($linkidentifier = "") { ! global $dbasetype; ! if($dbasetype == "mysql") { if(function_exists("mysql_errno") == 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."); --- 97,102 ---- function ofirst_dberrno($linkidentifier = "") { ! global $DBaseType; ! if($DBaseType == "mysql") { if(function_exists("mysql_errno") == 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."); *************** *** 107,116 **** return(mysql_errno()); } ! } elseif ($dbasetype == "mssql") { if(function_exists("mssql_connect") == false) { die("Microsoft SQL support is not available in your version of PHP. To use the openFIRST Web Portal Software, please either enable Microsoft SQL support, or choose another database type."); } return(0); ! } elseif ($dbasetype == "odbc") { if(function_exists("odbc_error") == false) { die("ODBC support is not enabled in your version of PHP. To use the openFIRST Web Portal Software, please either enable ODBC support, or choose another database type."); --- 107,116 ---- return(mysql_errno()); } ! } elseif ($DBaseType == "mssql") { if(function_exists("mssql_connect") == false) { die("Microsoft SQL support is not available in your version of PHP. To use the openFIRST Web Portal Software, please either enable Microsoft SQL support, or choose another database type."); } return(0); ! } elseif ($DBaseType == "odbc") { if(function_exists("odbc_error") == false) { die("ODBC support is not enabled in your version of PHP. To use the openFIRST Web Portal Software, please either enable ODBC support, or choose another database type."); *************** *** 126,131 **** function ofirst_dberror($linkidentifier = "") { ! 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."); --- 126,131 ---- function ofirst_dberror($linkidentifier = "") { ! 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."); *************** *** 136,145 **** return(mysql_error()); } ! } elseif ($dbasetype == "mssql") { if(function_exists("mssql_connect") == false) { die("Microsoft SQL support is not available in your version of PHP. To use the openFIRST Web Portal Software, please either enable Microsoft SQL support, or choose another database type."); } return(0); ! } elseif ($dbasetype == "odbc") { if(function_exists("odbc_errormsg") == false) { die("ODBC support is not available in your version of PHP. To use the openFIRST Web Portal Software, please either enable ODBC support, or choose another database type."); --- 136,145 ---- return(mysql_error()); } ! } elseif ($DBaseType == "mssql") { if(function_exists("mssql_connect") == false) { die("Microsoft SQL support is not available in your version of PHP. To use the openFIRST Web Portal Software, please either enable Microsoft SQL support, or choose another database type."); } return(0); ! } elseif ($DBaseType == "odbc") { if(function_exists("odbc_errormsg") == false) { die("ODBC support is not available in your version of PHP. To use the openFIRST Web Portal Software, please either enable ODBC support, or choose another database type."); *************** *** 155,162 **** function ofirst_dbquery($string, $linkidentifier = "", $batchsize = "") { ! global $dbasetype, $sqlconnection, $lastquery; $lastquery = "\$string = \"$string\", \$linkidentifier = \"$linkidentifier\", \$batchsize = \"$batchsize\""; ! if($dbasetype == "mysql") { if(function_exists("mysql_query") == 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."); --- 155,162 ---- function ofirst_dbquery($string, $linkidentifier = "", $batchsize = "") { ! global $DBaseType, $sqlconnection, $lastquery; $lastquery = "\$string = \"$string\", \$linkidentifier = \"$linkidentifier\", \$batchsize = \"$batchsize\""; ! if($DBaseType == "mysql") { if(function_exists("mysql_query") == 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."); *************** *** 167,171 **** return(mysql_query($string)); } ! } elseif($dbasetype == "mssql") { if(function_exists("mssql_query") == false) { die("Microsoft SQL support is not available in your version of PHP. To use the openFIRST Web Portal Software, please either enable Microsoft SQL support, or choose another database type."); --- 167,171 ---- return(mysql_query($string)); } ! } elseif($DBaseType == "mssql") { if(function_exists("mssql_query") == false) { die("Microsoft SQL support is not available in your version of PHP. To use the openFIRST Web Portal Software, please either enable Microsoft SQL support, or choose another database type."); *************** *** 178,182 **** return(mssql_query($string)); } ! } elseif ($dbasetype == "odbc") { if(function_exists("odbc_exec") == false) { die("ODBC support is not available in your version of PHP. To use the openFIRST Web Portal Software, please either enable ODBC support, or choose another database type."); --- 178,182 ---- return(mssql_query($string)); } ! } elseif ($DBaseType == "odbc") { if(function_exists("odbc_exec") == false) { die("ODBC support is not available in your version of PHP. To use the openFIRST Web Portal Software, please either enable ODBC support, or choose another database type."); *************** *** 189,204 **** function ofirst_dbfetch_object($resource, $rownumber = "") { ! global $dbasetype; ! if($dbasetype == "mysql") { if(function_exists("mysql_fetch_object") == 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."); } return(mysql_fetch_object($resource)); ! } elseif($dbasetype == "mssql") { if(function_exists("mssql_fetch_object") == false) { die("Microsoft SQL support is not available in your version of PHP. To use the openFIRST Web Portal Software, please either enable Microsoft SQL support, or choose another database type."); } return(mssql_fetch_object($resource)); ! } elseif($dbasetype == "odbc") { if(function_exists("odbc_fetch_object") == false) { die("ODBC support is not available in your version of PHP. To use the openFIRST Web Portal Software, please either enable ODBC support, or choose another database type."); --- 189,204 ---- function ofirst_dbfetch_object($resource, $rownumber = "") { ! global $DBaseType; ! if($DBaseType == "mysql") { if(function_exists("mysql_fetch_object") == 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."); } return(mysql_fetch_object($resource)); ! } elseif($DBaseType == "mssql") { if(function_exists("mssql_fetch_object") == false) { die("Microsoft SQL support is not available in your version of PHP. To use the openFIRST Web Portal Software, please either enable Microsoft SQL support, or choose another database type."); } return(mssql_fetch_object($resource)); ! } elseif($DBaseType == "odbc") { if(function_exists("odbc_fetch_object") == false) { die("ODBC support is not available in your version of PHP. To use the openFIRST Web Portal Software, please either enable ODBC support, or choose another database type."); *************** *** 216,221 **** function ofirst_dbnum_rows($resource) { ! global $dbasetype; ! if($dbasetype == "mysql") { if(function_exists("mysql_num_rows") == 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."); --- 216,221 ---- function ofirst_dbnum_rows($resource) { ! global $DBaseType; ! if($DBaseType == "mysql") { if(function_exists("mysql_num_rows") == 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."); *************** *** 223,227 **** if (!is_resource($resource)) return -1; return(mysql_num_rows($resource)); ! } elseif($dbasetype == "mssql") { if(function_exists("mssql_num_rows") == false) { die("Microsoft SQL support is not available in your version of PHP. To use the openFIRST Web Portal Software, please either enable Microsoft SQL support, or choose another database type."); --- 223,227 ---- if (!is_resource($resource)) return -1; return(mysql_num_rows($resource)); ! } elseif($DBaseType == "mssql") { if(function_exists("mssql_num_rows") == false) { die("Microsoft SQL support is not available in your version of PHP. To use the openFIRST Web Portal Software, please either enable Microsoft SQL support, or choose another database type."); *************** *** 229,233 **** if (!is_resource($resource)) return -1; return(mssql_num_rows($resource)); ! } elseif($dbasetype == "odbc") { if(function_exists("odbc_num_rows") == false) { die("ODBC support is not available in your version of PHP. To use the openFIRST Web Portal Software, please either enable ODBC support, or choose another database type."); --- 229,233 ---- if (!is_resource($resource)) return -1; return(mssql_num_rows($resource)); ! } elseif($DBaseType == "odbc") { if(function_exists("odbc_num_rows") == false) { die("ODBC support is not available in your version of PHP. To use the openFIRST Web Portal Software, please either enable ODBC support, or choose another database type."); *************** *** 244,255 **** function ofirst_dbname_version() { ! global $dbasetype; ! if($dbasetype == "mysql") { $v = ofirst_dbfetch_object(ofirst_dbquery("SELECT VERSION() AS mysql_version")); return "MySQL $v->mysql_version"; ! } elseif($dbasetype == "mssql") { $v = ofirst_dbquery("SELECT @@VERSION"); return "Microsoft SQL Server $v <br><strong>Warning:</strong> unconfirmed"; ! } elseif($dbasetype == "odbc") { return "ODBC"; } else { --- 244,255 ---- function ofirst_dbname_version() { ! global $DBaseType; ! if($DBaseType == "mysql") { $v = ofirst_dbfetch_object(ofirst_dbquery("SELECT VERSION() AS mysql_version")); return "MySQL $v->mysql_version"; ! } elseif($DBaseType == "mssql") { $v = ofirst_dbquery("SELECT @@VERSION"); return "Microsoft SQL Server $v <br><strong>Warning:</strong> unconfirmed"; ! } elseif($DBaseType == "odbc") { return "ODBC"; } else { *************** *** 259,271 **** function ofirst_dbsize() { ! global $dbasetype, $sqldatabase; ! if($dbasetype == "mysql") { $dbsize = 0; ! $dq = ofirst_dbquery("SHOW TABLE STATUS FROM $sqldatabase"); while($d = ofirst_dbfetch_object($dq)) { $dbsize += $d->Data_length + $d->Index_length; } return (int) (($dbsize + 0.5) / 1024 * 10) / 10 . " KB"; ! } elseif($dbasetype == "mssql") { $s = ofirst_dbfetch_object(ofirst_dbquery("SELECT ((SUM(size) * 8.0) * 1024.0) as dbsize FROM sysfiles")); return (int) (( $s->dbsize + 0.5) / 1024 * 10) / 10 . " KB"; --- 259,271 ---- function ofirst_dbsize() { ! global $DBaseType, $sqlDatabase; ! if($DBaseType == "mysql") { $dbsize = 0; ! $dq = ofirst_dbquery("SHOW TABLE STATUS FROM $sqlDatabase"); while($d = ofirst_dbfetch_object($dq)) { $dbsize += $d->Data_length + $d->Index_length; } return (int) (($dbsize + 0.5) / 1024 * 10) / 10 . " KB"; ! } elseif($DBaseType == "mssql") { $s = ofirst_dbfetch_object(ofirst_dbquery("SELECT ((SUM(size) * 8.0) * 1024.0) as dbsize FROM sysfiles")); return (int) (( $s->dbsize + 0.5) / 1024 * 10) / 10 . " KB"; *************** *** 278,285 **** function ofirst_dbcheck($linkidentifier = "") { #TODO: Write me! ! global $dbasetype; ! if($dbasetype == "mysql") { ! } elseif($dbasetype == "mssql") { ! } elseif($dbasetype == "odbc") { } exit(0); --- 278,285 ---- function ofirst_dbcheck($linkidentifier = "") { #TODO: Write me! ! global $DBaseType; ! if($DBaseType == "mysql") { ! } elseif($DBaseType == "mssql") { ! } elseif($DBaseType == "odbc") { } exit(0); *************** *** 366,371 **** function ofirst_dbescape($text) { ! global $dbasetype; ! if($dbasetype == "mysql") { return mysql_real_escape_string($text); # MS SQL and ODBC don't have specific escaping functions. --- 366,371 ---- function ofirst_dbescape($text) { ! global $DBaseType; ! if($DBaseType == "mysql") { return mysql_real_escape_string($text); # MS SQL and ODBC don't have specific escaping functions. *************** *** 377,388 **** } ! #Used for quoting field, table, and DB names function ofirst_dbquote_name($name) { ! return '`'.ofirst_dbescape($name).'`'; } #Used for quoting data function ofirst_dbquote_data($data) { ! return "'".ofirst_dbescape($data)."'"; } ?> --- 377,441 ---- } ! /** SQL escaping and quoting. ! * These functions escape various kinds of literals. ! * If an array is passed, it is assumed to be a list ! * of things to be passed and is merged. ! */ ! ! #Used for quoting field and DB names function ofirst_dbquote_name($name) { ! if (is_array($name)) { ! $value = ''; ! foreach ($name as $text) { ! $value .= ofirst_dbquote_name($text).','; ! } ! $value = substr($text, 0, -1); ! return $value; ! } else { ! return '`'.ofirst_dbescape($name).'`'; ! } ! } ! ! #Used for quoting table names. Includes table prefix. ! function ofirst_dbquote_table($name) { ! global $sqlTablePrefix; ! if (is_array($name)) { ! $value = ''; ! foreach ($name as $text) { ! $value .= ofirst_dbquote_table($text).','; ! } ! $value = substr($text, 0, -1); ! return $value; ! } else { ! return ofirst_dbquote_name("$sqlTablePrefix$name"); ! } } #Used for quoting data function ofirst_dbquote_data($data) { ! if (is_array($name)) { ! $value = ''; ! foreach ($name as $text) { ! $value .= ofirst_dbquote_data($text).','; ! } ! $value = substr($text, 0, -1); ! return $value; ! } else { ! return "'".ofirst_dbescape($data)."'"; ! } ! ! #Used to quote field-data pairs in the form of `field`='data' ! #passed like: ! # array( 'field' => 'data' ) ! function ofirst_dbquote_fd_pairs($pairs) { ! $value = ''; ! foreach ($pairs as $field => $data) { ! $value .= ofirst_dbquote_name($field); ! $value .= '='; ! $value .= ofirst_dbquote_data($data); ! $value .= ','; ! } ! $value = substr($text, 0, -1); ! return $value; } ?> Index: db_setup.php =================================================================== RCS file: /cvsroot/openfirst/base/includes/db_setup.php,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** db_setup.php 25 May 2005 21:44:29 -0000 1.1 --- db_setup.php 26 May 2005 21:00:03 -0000 1.2 *************** *** 26,90 **** require_once('dbase.php'); - /** An array of valid SQL types - * This won't be used for checking - */ - $sqlValidTypes = array( - /* After each type, there may be a list of options: - * length - can have the form TYPE(###) - * need length - must have the form TYPE(###) - * length&digits - can have the form TYPE(###, ###) - * length&bits - can have the form TYPE(###, ###) - * length or digits - can have the form TYPE(###) or TYPE(###, ###) - * - * Any options not in this list refer to literal attributes - */ - # These are from phpMyAdmin - 'VARCHAR', #need length, national, binary - 'TINYINT', #length, unsigned, zerofill - 'TEXT', #length - 'DATE', - 'SMALLINT', #length, unsigned, zerofill - 'MEDIUMINT', #length, unsigned, zerofill - - 'INT', #length, unsigned, zerofill - 'BIGINT', #length, unsigned, zerofill - 'FLOAT', #need length, unsigned, zerofill OR - #length&digits, unsigned, zerofill - 'DOUBLE', #length&bits, unsigned, zerofill - 'DECIMAL', #length or digits, unsigned, zerofill - 'DATETIME', - - 'TIMESTAMP', #length(14,12,8,6) - 'TIME', - 'YEAR', #length(2,4) - 'CHAR', #need length, national, binary, ascii, unicode OR - #(none) - 'TINYBLOB', - 'TINYTEXT', - - 'BLOB', #length - 'MEDIUMBLOB', - 'MEDIUMTEXT', - 'LONGBLOB', - 'LONGTEXT', - 'ENUM',#list of values - - 'SET',#list of values - - # These are additional types from the MySQL manual - 'BIT', #length - 'BOOL', - 'BOOLEAN', - 'INTEGER', #length, unsigned, zerofill - 'DOUBLE PRECISION', #length&digits, unsigned, zerofill - 'REAL', #length&digits, unsigned, zerofill - 'DEC', #length or digits, unsigned, zerofill - 'NUMERIC', #length or digits, unsigned, zerofill - 'FIXED', #length or digits, unsigned, zerofill - 'DATE', - 'BINARY', #need length - 'VARBINARY', #need length - ); - /** Gets an array of tables. * Uses the current DB connection. The key is the name, the content --- 26,29 ---- *************** *** 97,101 **** /** The class representing a table. * This is a wrapper for a SQL table. It allows access to fields, ! * keys, etc. Note that it does not handle records, just structure. */ class Table { --- 36,40 ---- /** 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 { *************** *** 138,141 **** --- 77,87 ---- } + /** + * Only stores meta-data about a table. Does not + * manipulate it. + */ + class liteTable { + } + /*** SQL Statements ***/ /* |