[Openfirst-cvscommit] base/config dbase.php,1.15.2.1,1.15.2.2 first.php,1.46,1.47 globals.php,1.4,1.
Brought to you by:
xtimg
From: Astronouth7303 <ast...@us...> - 2005-03-13 01:20:21
|
Update of /cvsroot/openfirst/base/config In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9875/config Modified Files: Tag: NewDB dbase.php No tag first.php globals.php Tag: NewDB globals.tpl Log Message: Last PEAR commit for now Index: first.php =================================================================== RCS file: /cvsroot/openfirst/base/config/first.php,v retrieving revision 1.46 retrieving revision 1.47 diff -C2 -d -r1.46 -r1.47 *** first.php 7 Jan 2005 20:31:06 -0000 1.46 --- first.php 13 Mar 2005 01:19:58 -0000 1.47 *************** *** 39,57 **** if(isset($_POST["ostype"])) { - include_once("./dbase.php"); $sqlserver = $_POST["sqlserver"]; $sqluser = $_POST["sqluser"]; $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"); ! ! /* Create database if it does not already exist */ ! ofirst_dbquery("CREATE DATABASE IF NOT EXISTS $sqldatabase;"); ! ofirst_select_db($sqldatabase); function GetVarValue($var) { ob_Start(); --- 39,66 ---- if(isset($_POST["ostype"])) { $sqlserver = $_POST["sqlserver"]; $sqluser = $_POST["sqluser"]; $sqlpassword = $_POST["sqlpassword"]; $sqldatabase = $_POST["sqldatabase"]; + $peardb = $_POST['peardb']; + include_once("./dbase.php"); 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."); } ! ofirst_dbcreate("$sqlserver","$sqluser","$sqlpassword", $sqldatabase); ! ofirst_dbconnect("$sqlserver","$sqluser","$sqlpassword"); ofirst_select_db($sqldatabase); + ofirst_dbquery("CREATE TABLE `ofirst_config` ( + `modulename` varchar(25) NOT NULL default '', + `showonmenu` tinyint(1) default NULL, + `active` tinyint(1) default NULL, + `adminnavigation` text, + `modulenavigation` text, + `includes` text, + PRIMARY KEY (`modulename`) + )"); + echo ofirst_dberror(); + function GetVarValue($var) { ob_Start(); Index: dbase.php =================================================================== RCS file: /cvsroot/openfirst/base/config/dbase.php,v retrieving revision 1.15.2.1 retrieving revision 1.15.2.2 diff -C2 -d -r1.15.2.1 -r1.15.2.2 *** dbase.php 6 Jan 2005 21:57:52 -0000 1.15.2.1 --- dbase.php 13 Mar 2005 01:19:58 -0000 1.15.2.2 *************** *** 26,38 **** // without having to be completely rewritten or released as two // different versions. ! $lastquery = ""; //Used for debugging if(isset($dbasetype) == false) { $dbasetype = "mysql"; } ! $connections = array(0 => array('conn' => NULL, 'res' => NULL, 'db' => NULL)); ! ! $connectdsn = ""; if(isset($peardb) && $peardb) { // Include the PEAR Database Abstraction Layer ! include_once("DB.php"); echo "PEAR is being used<br />\n"; } elseif(! isset($peardb)) { --- 26,43 ---- // without having to be completely rewritten or released as two // different versions. ! $lastquery = ''; //Used for debugging if(isset($dbasetype) == false) { $dbasetype = "mysql"; } ! #Note: This includes the capability to connect to multiple DBs of different types at the same time. ! $connections = array(0 => array('dbms' => NULL, # the PEAR DB object for the extension being used ! 'conn' => NULL, # the connection identifier, or DB_common in PEAR ! 'res' => NULL, # the last result, or DB_result in PEAR ! 'db' => NULL, # the currently selected DB ! 'dsn' => NULL # the PEAR DSN of the DB server ! )); ! if(isset($peardb) && $peardb) { // Include the PEAR Database Abstraction Layer ! include_once('DB.php'); echo "PEAR is being used<br />\n"; } elseif(! isset($peardb)) { *************** *** 45,57 **** global $connections, $dbasetype, $peardb; if($peardb) { ! $connections[$ID] = "$dbasetype://$username:$password@$server/"; return($ID); } elseif($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 != "") { $connections[$ID]['conn'] = mysql_connect($server, $username, $password, $newlink, $intclientflags); ! } elseif($newlink != "") { $connections[$ID]['conn'] = mysql_connect($server, $username, $password, $newlink); } else { --- 50,63 ---- global $connections, $dbasetype, $peardb; if($peardb) { ! $connections[$ID]['dbms'] =& DB::factory($dbasetype); ! $connections[$ID]['dsn'] = "$dbasetype://$username:$password@$server/"; return($ID); } elseif($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. (mysql_connect)"); } ! /*if($intclientflags != "") { $connections[$ID]['conn'] = mysql_connect($server, $username, $password, $newlink, $intclientflags); ! } else*/if($newlink != "") { $connections[$ID]['conn'] = mysql_connect($server, $username, $password, $newlink); } else { *************** *** 60,69 **** } 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."); } $connections[$ID]['conn'] = 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."); } if($newlink != "") { --- 66,75 ---- } 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. (mssql_connect)"); } $connections[$ID]['conn'] = 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. (odbc_connect)"); } if($newlink != "") { *************** *** 76,105 **** } function ofirst_select_db($databasename, $ID = 0) { global $connections, $dbasetype, $peardb; $connections[$ID]['db'] = $databasename; if($peardb) { ! $connections[$ID]['conn'] = $connections[$ID]['conn'] =& DB::connect($connections[$ID]['conn'].$databasename); ! if (DB::isError ($connections[$ID])) return FALSE; } elseif($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, $connections[$ID]['conn'])); - /* } 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(mssql_select_db($databasename, $connections[$ID]['conn'])); - /* } else { - return(mssql_select_db($databasename)); - / }*/ } elseif ($dbasetype == "odbc") { // ODBC doesn't require selecting a DB --- 82,155 ---- } + function ofirst_dbdisconnect($ID = 0) { + global $connections, $dbasetype, $peardb; + $connections[$ID]['db'] = $databasename; + if($peardb) { + if (DB::isConnection($connections[$ID]['conn'])) { + if ($connections[$ID]['res'] !== null) { + $connections[$ID]['res']->free(); + } + $connections[$ID]['res'] = null; + if (method_exists($connections[$ID]['conn'], 'disconnect')) { + $connections[$ID]['conn']->disconnect(); + } + $connections[$ID]['conn'] = null; + } + $connections[$ID]['dbms'] = null; + unset($connections[$ID]); + return true; + } elseif($dbasetype == "mysql") { + if(function_exists("mysql_close") == 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. (mysql_close)"); + } + $val = mysql_close($connections[$ID]['conn']); + if ($val) unset($connections[$ID]); + return $val; + } elseif ($dbasetype == "mssql") { + if(function_exists("mssql_close") == 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. (mssql_close)"); + } + $val = mssql_close($connections[$ID]['conn']); + if ($val) unset($connections[$ID]); + return $val; + } elseif ($dbasetype == "odbc") { + if(function_exists("odbc_close") == 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. (odbc_close)"); + } + $val = odbc_close($connections[$ID]['conn']); + if ($val) unset($connections[$ID]); + return $val; + } + } + function ofirst_select_db($databasename, $ID = 0) { global $connections, $dbasetype, $peardb; $connections[$ID]['db'] = $databasename; if($peardb) { ! if (DB::isConnection($connections[$ID]['conn'])) { ! if ($connections[$ID]['res'] !== null) { ! $connections[$ID]['res']->free(); ! } ! $connections[$ID]['res'] = null; ! if (method_exists($connections[$ID]['dbms'], 'disconnect')) { ! $connections[$ID]['conn']->disconnect(); ! } ! $connections[$ID]['conn'] = null; ! } ! echo $connections[$ID]['dsn'].$databasename."<br />\n"; ! $connections[$ID]['conn'] =& $connections[$ID]['dbms']->connect($connections[$ID]['dsn'].$databasename); ! if (DB::isError($connections[$ID]['conn'])) return FALSE; } elseif($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. (mysql_select_db)"); } return(mysql_select_db($databasename, $connections[$ID]['conn'])); } 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. (mssql_select_db)"); } return(mssql_select_db($databasename, $connections[$ID]['conn'])); } elseif ($dbasetype == "odbc") { // ODBC doesn't require selecting a DB *************** *** 111,142 **** global $connections, $dbasetype, $peardb; if($peardb) { ! // if($linkidentifier != "") { ! return(DB_Error::getCode($connections[$ID]['conn'])); #FIXME: Use last return ! /* } else { ! return(DB_Error::getCode()); ! }*/ } elseif($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($connections[$ID]['conn'])); - /* } 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); } 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."); } - // if($linkidentifier != "") { return(odbc_error($connections[$ID]['conn'])); - /* } else { - return(odbc_error()); - }*/ } exit(0); --- 161,186 ---- global $connections, $dbasetype, $peardb; if($peardb) { ! if (DB::isError($connections[$ID]['dbms'])) { ! return $connections[$ID]['dbms']->getCode(); ! } elseif (DB::isError($connections[$ID]['conn'])) { ! return $connections[$ID]['conn']->getCode(); ! } elseif (DB::isError($connections[$ID]['res'])) { ! return $connections[$ID]['res']->getCode(); ! } } elseif($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. (mysql_errno)"); } return(mysql_errno($connections[$ID]['conn'])); } 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. (mssql_connect)"); } 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. (odbc_error)"); } return(odbc_error($connections[$ID]['conn'])); } exit(0); *************** *** 146,177 **** global $connections, $dbasetype, $peardb; if($peardb) { ! // if($linkidentifier != "") { ! return(DB_Error::getMessage($connections[$ID]['conn'])); ! /* } else { ! return(DB_Error::getMessage()); ! }*/ } elseif($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($connections[$ID]['conn'])); - /* } else { - 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."); } - // if($linkidentifier != "") { return(odbc_errormsg($connections[$ID]['conn'])); - /* } else { - return(odbc_errormsg()); - }*/ } exit(0); --- 190,215 ---- global $connections, $dbasetype, $peardb; if($peardb) { ! if (DB::isError($connections[$ID]['dbms'])) { ! return DB::errorMessage($connections[$ID]['dbms']).' (in DBMS object)'; ! } elseif (DB::isError($connections[$ID]['conn'])) { ! return DB::errorMessage($connections[$ID]['conn']).' (in Connection object)'; ! } elseif (DB::isError($connections[$ID]['res'])) { ! return DB::errorMessage($connections[$ID]['res']).' (in Result object)'; ! } } elseif($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. (mysql_error)"); } return(mysql_error($connections[$ID]['conn'])); } 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. (mssql_connect)"); } 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. (odbc_errormsg)"); } return(odbc_errormsg($connections[$ID]['conn'])); } exit(0); *************** *** 179,219 **** function ofirst_dbquery($string, $ID = 0, $batchsize = "") { ! global $connections, $dbasetype, $peardb, $sqlconnection, $lastquery; ! $lastquery = "ofirst_dbquery(): \$string = \"$string\", \$linkidentifier = \"$linkidentifier\", \$batchsize = \"$batchsize\""; if($peardb) { if($batchsize != "") { ! return($sqlconnection->query($string, $connections[$ID]['conn'], $batchsize)); ! } else/*if($linkidentifier != "")*/ { ! return($sqlconnection->query($string, $connections[$ID]['conn'])); ! }/* else { ! return($sqlconnection->query($string)); ! }*/ } elseif($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, $connections[$ID]['conn'])); ! /* } 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, $connections[$ID]['conn'], $batchsize)); ! } else/*if($linkidentifier != "")*/ { ! return(mssql_query($string, $connections[$ID]['conn'])); ! }/* else { ! 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."); } // Note: this may be misleading, the variable names are not reflective of their content in this particular line, as the odbc function uses an order different from the other databases. ! return(odbc_exec($string, $connections[$ID]['conn'])); } exit(0); --- 217,260 ---- function ofirst_dbquery($string, $ID = 0, $batchsize = "") { ! global $connections, $dbasetype, $peardb, $lastquery; ! $lastquery = "ofirst_dbquery(): \$string = \"$string\", \$ID = \"$ID\", \$batchsize = \"$batchsize\""; if($peardb) { + if ($connections[$ID]['res'] !== null) { + $connections[$ID]['res']->free(); + } + $connections[$ID]['res'] = null; + if (DB::isError($connections[$ID]['conn'])) { + die('DB Error: '.ofirst_dberror().' ('.ofirst_dberrno().')'); + } if($batchsize != "") { ! $connections[$ID]['res'] =& $connections[$ID]['conn']->query($string, $connections[$ID]['conn'], $batchsize); ! } else { ! $connections[$ID]['res'] =& $connections[$ID]['conn']->query($string, $connections[$ID]['conn']); ! } ! return $ID; } elseif($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. (mysql_query)"); } ! $connections[$ID]['res'] = mysql_query($string, $connections[$ID]['conn']); ! return $ID; } 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. (mssql_query)"); } if($batchsize != "") { ! $connections[$ID]['res'] = mssql_query($string, $connections[$ID]['conn'], $batchsize); ! } else { ! $connections[$ID]['res'] = mssql_query($string, $connections[$ID]['conn']); ! } ! return $ID; } 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. (odbc_exec)"); } // Note: this may be misleading, the variable names are not reflective of their content in this particular line, as the odbc function uses an order different from the other databases. ! $connections[$ID]['res'] = odbc_exec($connections[$ID]['conn'], $string); ! return $ID; } exit(0); *************** *** 222,253 **** #FIXME: Make associative arrays #FIXME: Use $connections[$ID]['res'] ! function ofirst_dbfetch_object($resource, $rownumber = "", $ID = 0) { global $connections, $dbasetype, $peardb; if($peardb) { if($rownumber != "") { ! return(DB_FETCHMODE_OBJECT($resource, $rownumber)); } else { ! return(DB_FETCHMODE_OBJECT($resource)); } } elseif($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."); ! ! } if($rownumber != "") { ! return(odbc_fetch_object($resource, $rownumber)); } else { ! return(odbc_fetch_object($resource)); } } --- 263,293 ---- #FIXME: Make associative arrays #FIXME: Use $connections[$ID]['res'] ! function ofirst_dbfetch_object($ID = 0, $rownumber = "") { global $connections, $dbasetype, $peardb; if($peardb) { if($rownumber != "") { ! return($connections[$ID]['res']->fetchRow($rownumber)); } else { ! return($connections[$ID]['res']->fetchRow()); } } elseif($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. (mysql_fetch_object)"); } ! return(mysql_fetch_object($connections[$ID]['res'])); } 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. (mssql_fetch_object)"); } ! return(mssql_fetch_object($connections[$ID]['res'])); } 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. (odbc_fetch_object)"); ! } if($rownumber != "") { ! return(odbc_fetch_object($connections[$ID]['res'], $rownumber)); } else { ! return(odbc_fetch_object($connections[$ID]['res'])); } } *************** *** 257,284 **** #FIXME: Use $connections[$ID]['res'] ! function ofirst_dbnum_rows($resource) { global $connections, $dbasetype, $peardb; if($peardb) { ! if($resource != "") { ! return(DB_result::numRows($resource)); ! } else { ! return(DB_result::numRows()); ! } } elseif($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."); } ! 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."); } ! 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."); } ! if($resource != "") { ! return(odbc_num_rows($resource)); } else { return(odbc_num_rows()); --- 297,320 ---- #FIXME: Use $connections[$ID]['res'] ! function ofirst_dbnum_rows($ID = 0) { global $connections, $dbasetype, $peardb; if($peardb) { ! return($connections[$ID]['res']->numRows()); } elseif($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. (mysql_num_rows)"); } ! return(mysql_num_rows($connections[$ID]['res'])); } 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. (mssql_num_rows)"); } ! return(mssql_num_rows($connections[$ID]['res'])); } 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. (odbc_num_rows)"); } ! if($connections[$ID]['res'] != "") { ! return(odbc_num_rows($connections[$ID]['res'])); } else { return(odbc_num_rows()); *************** *** 291,297 **** global $connections, $dbasetype, $peardb; if($peardb) { ! return "PEAR DB"; } elseif($dbasetype == "mysql") { ! $v = ofirst_dbfetch_object(ofirst_dbquery("SELECT VERSION() AS mysql_version")); return "MySQL $v->mysql_version"; } elseif($dbasetype == "mssql") { --- 327,333 ---- global $connections, $dbasetype, $peardb; if($peardb) { ! return 'PEAR DB (API version '.$connections[$ID]['conn']->apiVersion().')'; } elseif($dbasetype == "mysql") { ! $v = ofirst_dbfetch_object(ofirst_dbquery("SELECT VERSION() AS mysql_version", $ID)); return "MySQL $v->mysql_version"; } elseif($dbasetype == "mssql") { *************** *** 309,319 **** if($dbasetype == "mysql") { $dbsize = 0; ! $dq = ofirst_dbquery("SHOW TABLE STATUS FROM " $connections[$ID]['db'], 0); ! 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", 0)); return (int) (( $s->dbsize + 0.5) / 1024 * 10) / 10 . " KB"; } else { --- 345,356 ---- if($dbasetype == "mysql") { $dbsize = 0; ! ofirst_dbquery("SHOW TABLE STATUS FROM ".$connections[$ID]['db'], $ID); ! while($d = ofirst_dbfetch_object($ID)) { $dbsize += $d->Data_length + $d->Index_length; } return (int) (($dbsize + 0.5) / 1024 * 10) / 10 . " KB"; } elseif($dbasetype == "mssql") { ! ofirst_dbquery("SELECT ((SUM(size) * 8.0) * 1024.0) as dbsize FROM sysfiles", $ID); ! $s = ofirst_dbfetch_object($ID); return (int) (( $s->dbsize + 0.5) / 1024 * 10) / 10 . " KB"; } else { *************** *** 321,323 **** --- 358,414 ---- } } + + function ofirst_dbcreate($server, $user, $password, $database) { + ofirst_dbconnect("$sqlserver","$sqluser","$sqlpassword"); + #TODO: Rewrite this so that we can do it in PEAR + if (!ofirst_select_db($sqldatabase)) { + /* Create database if it does not already exist */ + ofirst_dbquery("CREATE DATABASE IF NOT EXISTS $sqldatabase;"); + } + ofirst_select_db($sqldatabase); + ofirst_dbdisconnect(); + } + + function ofirst_dbclean_up() { + global $connections; + foreach ($connections as $key => $connect) { + ofirst_dbdisconnect($key); + } + } + + function ofirst_dbfree_result($ID = 0) { + global $connections, $dbasetype, $peardb; + if($peardb) { + if (method_exists($connections[$ID]['res'], 'free')) { + $connections[$ID]['res']->free(); + } + $connections[$ID]['res'] = null; + } elseif($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. (mysql_num_rows)"); + } + return(mysql_num_rows($connections[$ID]['res'])); + } 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. (mssql_num_rows)"); + } + return(mssql_num_rows($connections[$ID]['res'])); + } elseif($dbasetype == "odbc") { + if(function_exists("odbc_free_result") == 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. (odbc_free_result)"); + } + if($connections[$ID]['res'] !== null) { + if (odbc_free_result($connections[$ID]['res'])) { + $connections[$ID]['res'] = null; + return true; + } else { + return false; + } + } else { + return(odbc_num_rows()); + } + } + exit(0); + } + ?> Index: globals.tpl =================================================================== RCS file: /cvsroot/openfirst/base/config/globals.tpl,v retrieving revision 1.2.2.2 retrieving revision 1.2.2.3 diff -C2 -d -r1.2.2.2 -r1.2.2.3 *** globals.tpl 7 Jan 2005 20:30:35 -0000 1.2.2.2 --- globals.tpl 13 Mar 2005 01:19:58 -0000 1.2.2.3 *************** *** 31,35 **** $sqlconnection = ofirst_dbconnect("$sqlserver","$sqluser","$sqlpassword"); ! ofirst_select_db($sqldatabase); $pass_save_disabled=%COOKIE%; --- 31,37 ---- $sqlconnection = ofirst_dbconnect("$sqlserver","$sqluser","$sqlpassword"); ! if (!ofirst_select_db($sqldatabase)) { ! die('Unable to connect to the database and/or select table. The error was: '.ofirst_dberror(0).' ('.ofirst_dberrno(0).')'); ! } $pass_save_disabled=%COOKIE%; *************** *** 53,65 **** if(function_exists("glob")) { // Include the functions using glob(); ! if(is_readable(getcwd() . "/../config/functions/")) { ! foreach (glob(getcwd() . "/../config/functions/*.php") as $filename) { include($filename); } ! } elseif (is_readable(getcwd() . "/../../config/functions/")) { foreach (glob(getcwd() . "/../../config/functions/*.php") as $filename) { include($filename); } ! } } else { // Include the functions without using glob(); --- 55,67 ---- if(function_exists("glob")) { // Include the functions using glob(); ! // if(is_readable("$fbasepath/config/functions/")) { ! foreach (glob("$fbasepath/config/functions/*.php") as $filename) { include($filename); } ! /* } elseif (is_readable(getcwd() . "/../../config/functions/")) { foreach (glob(getcwd() . "/../../config/functions/*.php") as $filename) { include($filename); } ! }*/ } else { // Include the functions without using glob(); Index: globals.php =================================================================== RCS file: /cvsroot/openfirst/base/config/globals.php,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** globals.php 7 Jan 2005 20:28:25 -0000 1.4 --- globals.php 13 Mar 2005 01:19:58 -0000 1.5 *************** *** 1,115 **** <?php /* ! * openFIRST base configuration file ! * This file has been automatically generated by first.php. ! * it contains the basic configuration options required to ! * operate the OpenFIRST web portal software. Note, that ! * most configuration options are now stored in the MySQL ! * database, in the ofirst_config table. ! */ ! $dbasetype = %DBTYPE%; ! $peardb = %PEAR%; ! $ostype = %OS%; ! if ($ostype == "windows") { ! ini_set("include_path", ini_get("include_path") . ";../config/;."); ! } else { ! ini_set("include_path", ini_get("include_path") . ":../config/:."); ! } ! include_once('dbase.php'); ! ! $encryption = %ENCRYPT%; ! ! $title = %TITLE%; ! $version = %VER%; ! $sqlserver = %DBSERVER%; ! $sqluser = %DBUSER%; ! $sqlpassword = %DBPASS%; ! $sqldatabase = %DBNAME%; ! 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."); ! } ! ! $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%; ! $basepath = %BASEPATH%; ! $fbasepath = %FBASEPATH; ! ! // Determine what module the user is viewing ! ! $currentmodule = str_replace($basepath, "", $_SERVER["SCRIPT_NAME"]); ! $currentmodule = substr($currentmodule, 1, strpos($currentmodule, "/", 2) - 1); ! ! #FIXME: Use $fbasepath instead of getcwd() ! session_start(); ! include('auth.php'); ! if(function_exists("glob")) { ! // Include the functions using glob(); ! if(is_readable(getcwd() . "/../config/functions/")) { ! foreach (glob(getcwd() . "/../config/functions/*.php") as $filename) { ! include($filename); ! } ! } elseif (is_readable(getcwd() . "/../../config/functions/")) { ! foreach (glob(getcwd() . "/../../config/functions/*.php") as $filename) { ! include($filename); ! } ! } ! } else { ! // Include the functions without using glob(); ! } ! ! $headers = ""; ! ! $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) { ! // Check if there are includes that need to be included ! if(! $module->includes == ""){ ! // If the list is not empty then explode the value and put it into inclist ! $inclist = explode(",",$module->includes); ! // This is to remove an error that you have if you don't check if there are more then 2 ! if(count($inclist) >= 2){ ! ! // Loop through the inclist and add them according to their paths ! foreach($inclist As $inc){ ! include("$fbasepath/$module->modulename/$inc"); ! } ! } else { ! // If there is only 1 include available then use this line to include it instead ! include("$fbasepath/$module->modulename/$module->includes"); ! } ! } ! ! // If the module has requested to be shown on the menu then add it ! if( (bool) $module->showonmenu == true) { ! // If it is the current module then color the item ! if ($currentmodule == $module->modulename){ ! $headers .= " » <font color='red'><u><a class='menu' href='$basepath/$module->modulename'>".ucwords($module->modulename)."</a></u></font> |"; ! ! // 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> |"; ! } ! } ! } ! } } ! ! session_write_close(); ! ?> --- 1,15 ---- <?php /* ! * openFIRST globals.php ! * This is a placeholder file. It will be recreated ! * by first.php when you first access and configure ! * your OpenFIRST portal software. ! */ ! if(file_exists("../config/first.php")) { ! header("Location: ../config/first.php"); ! } elseif(file_exists("config/first.php")) { ! header("Location: config/first.php"); ! } elseif(file_exists("../../config/first.php")) { ! header("Location: ../../config/first.php"); } ! ?> \ No newline at end of file |