[Openfirst-cvscommit] base/config dbase.php,NONE,1.1 first.php,1.19,1.20
Brought to you by:
xtimg
From: <xt...@us...> - 2003-08-23 19:54:37
|
Update of /cvsroot/openfirst/base/config In directory sc8-pr-cvs1:/tmp/cvs-serv9363 Modified Files: first.php Added Files: dbase.php Log Message: Add new database wrappers which will allow Microsoft SQL Support --- NEW FILE: dbase.php --- <?php /* * openFIRST.base - config/functions/dbase.php * * Copyright (C) 2003, * openFIRST Project * Original Author: Tim Ginn <tim...@po...> * * 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: Provide database functionality so that each module is // able to easily switch between, say, MySQL and MSSQL databases // without having to be completely rewritten or released as two // different versions. if(isset($dbasetype) == false) { $dbasetype = "mysql"; } // Wrapper for database selection. function ofirst_dbconnect($server = "", $username = "", $password = "", $newlink = "", $intclientflags = "") { global $dbasetype; 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."); } if($intclientflags != "") { return(mysql_connect($server, $username, $password, $newlink, $intclientflags)); } elseif($newlink != "") { return(mysql_connect($server, $username, $password, $newlink)); } else { 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)); } exit; } function ofirst_select_db($databasename, $linkidentifier) { global $dbasetype; 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."); } if($linkidentifier != "") { return(mysql_select_db($databasename, $linkidentifier)); } else { 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."); } if($linkidentifier != "") { return(mysql_select_db($databasename, $linkidentifier)); } else { return(mysql_select_db($databasename)); } } exit; } 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."); } if($linkidentifier != "") { return(mysql_errno($linkidentifier)); } else { 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); } exit; } function ofirst_dbquery($string, $linkidentifier = "", $batchsize = "") { global $dbasetype; 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."); } if($linkidentifier != "") { return(mysql_query($string, $linkidentifier)); } else { 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."); } if($batchsize != "") { return(mssql_query($string, $linkidentifier, $batchsize)); } elseif($linkidentifier != "") { return(mssql_query($string, $linkidentifier)); } else { return(mssql_query($string)); } } exit(0); } function ofirst_dbfetch_object($resource) { 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_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."); } return(mssql_fetch_object($resource)); } exit(0); } ?> Index: first.php =================================================================== RCS file: /cvsroot/openfirst/base/config/first.php,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** first.php 20 Aug 2003 14:40:09 -0000 1.19 --- first.php 23 Aug 2003 19:54:34 -0000 1.20 *************** *** 51,59 **** --- 51,62 ---- * database, in the ofirst_config table. */ + \$dbasetype = \"" . $_POST["dbasetype"] . "\"; \$ostype = '" . $_POST["ostype"] . "'; if (\$ostype == \"windows\") { ini_set(\"include_path\",\"../config/;.\"); + include('dbase.php'); } else { ini_set(\"include_path\",\"../config/:.\"); + include('dbase.php'); } \$title = '" . $_POST["title"] . "'; *************** *** 63,70 **** \$sqlpassword = '" . $_POST["sqlpassword"] . "'; \$sqldatabase = '" . $_POST["sqldatabase"] . "'; ! if(function_exists(\"mysql_connect\") == false) { die(\"Your version of PHP has not been compiled with MySQL support, therefore the openFIRST web portal system cannot run on this system. Please contact your system administrator to request MySQL support for your version of PHP.\"); } ! \$sqlconnection = mysql_connect(\"\$sqlserver\",\"\$sqluser\",\"\$sqlpassword\"); \$home = '" . $_POST["home"] . "'; --- 66,73 ---- \$sqlpassword = '" . $_POST["sqlpassword"] . "'; \$sqldatabase = '" . $_POST["sqldatabase"] . "'; ! if(function_exists(\"ofirst_dbconnect\") == false) { die(\"Your version of PHP has not been compiled with MySQL support, therefore the openFIRST web portal system cannot run on this system. Please contact your system administrator to request MySQL support for your version of PHP.\"); } ! \$sqlconnection = ofirst_dbconnect(\"\$sqlserver\",\"\$sqluser\",\"\$sqlpassword\"); \$home = '" . $_POST["home"] . "'; *************** *** 103,113 **** \$headers = \"\"; ! mysql_select_db(\$sqldatabase, \$sqlconnection); ! \$incl = mysql_query(\"SELECT * FROM ofirst_config\"); // If there is no error then run the module add feature ! if(mysql_errno() == 0) { // Begin to loop through modules from the databaes ! while(\$module = mysql_fetch_object(\$incl)) { // Check if the value is try, if it is then run an include if( (bool) \$module->active == true) { --- 106,116 ---- \$headers = \"\"; ! ofirst_select_db(\$sqldatabase, \$sqlconnection); ! \$incl = ofirst_dbquery(\"SELECT * FROM ofirst_config\"); // If there is no error then run the module add feature ! if(ofirst_dberrno() == 0) { // Begin to loop through modules from the databaes ! while(\$module = ofirst_dbfetch_object(\$incl)) { // Check if the value is try, if it is then run an include if( (bool) \$module->active == true) { *************** *** 199,208 **** </select> (UNIX includes variants, such as Linux, Mac OS X, and BeOS) </td></tr> <tr><td>Title of Software</td><td><input type="text" name="title" value="openFIRST" /></td></tr> <tr><td>Version of Software</td><td><input type="text" name="version" value="CVS" /></td></tr> ! <tr><td>MySQL Server Address</td><td><input type="text" name="sqlserver" value="localhost" /></td></tr> ! <tr><td>MySQL User Name</td><td><input type="text" name="sqluser" value="sqluser" /></td></tr> ! <tr><td>MySQL User Password</td><td><input type="password" name="sqlpassword" /></td></tr> ! <tr><td>MySQL Database Name (this database must already exist, it will not be automatically created)</td><td><input type="text" name="sqldatabase" value="openfirst" /></td></tr> <tr><td>Home site (the address scripts will use for linking to your main page)</td><td> <input type="text" name="home" value="http://openfirst.sourceforge.net"></td></tr> --- 202,215 ---- </select> (UNIX includes variants, such as Linux, Mac OS X, and BeOS) </td></tr> + <tr><td>Database Type</td><td><select name="dbasetype"> + <option value="mysql" selected="selected">MySQL</option> + <option value="mssql">Microsoft SQL</option> + </select> <tr><td>Title of Software</td><td><input type="text" name="title" value="openFIRST" /></td></tr> <tr><td>Version of Software</td><td><input type="text" name="version" value="CVS" /></td></tr> ! <tr><td>Database Server Address</td><td><input type="text" name="sqlserver" value="localhost" /></td></tr> ! <tr><td>Database User Name</td><td><input type="text" name="sqluser" value="sqluser" /></td></tr> ! <tr><td>Database User Password</td><td><input type="password" name="sqlpassword" /></td></tr> ! <tr><td>Database Name (this database must already exist, it will not be automatically created)</td><td><input type="text" name="sqldatabase" value="openfirst" /></td></tr> <tr><td>Home site (the address scripts will use for linking to your main page)</td><td> <input type="text" name="home" value="http://openfirst.sourceforge.net"></td></tr> |