Fix some database problems, do not use the cache when creating users

This commit is contained in:
Robin Appelman 2010-07-05 11:37:50 +02:00
parent e4a83b68e9
commit d96793f14f
16 changed files with 5370 additions and 5369 deletions

View File

@ -329,11 +329,10 @@ class MDB2
{
if (!MDB2::classExists($class_name)) {
$file_name = str_replace('_', DIRECTORY_SEPARATOR, $class_name).'.php';
// echo $file_name;
if ($debug) {
$include = oc_include_once($file_name);
} else {
$include = @oc_include_once($file_name);
$include = oc_include_once($file_name);
}
if (!$include) {
if (!MDB2::fileExists($file_name)) {
@ -958,8 +957,12 @@ class MDB2
function fileExists($file)
{
// safe_mode does notwork with is_readable()
global $SERVERROOT;
if (!@ini_get('safe_mode')) {
$dirs = explode(PATH_SEPARATOR, ini_get('include_path'));
$dirs[]=$SERVERROOT;
$dirs[]=$SERVERROOT. DIRECTORY_SEPARATOR .'inc';
// print_r($dirs);die();
foreach ($dirs as $dir) {
if (is_readable($dir . DIRECTORY_SEPARATOR . $file)) {
return true;
@ -1920,7 +1923,6 @@ class MDB2_Driver_Common extends PEAR
if (PEAR::isError($err)) {
return $err;
}
// load module in a specific version
if ($version) {
if (method_exists($class_name, 'getClassName')) {

View File

@ -45,7 +45,7 @@
// $Id: mysql.php,v 1.12 2008/02/17 18:54:08 quipo Exp $
//
require_once 'MDB2/Driver/Function/Common.php';
oc_require_once('MDB2/Driver/Function/Common.php');
/**
* MDB2 MySQL driver for the function modules

View File

@ -1,115 +1,115 @@
<?php
// +----------------------------------------------------------------------+
// | PHP versions 4 and 5 |
// +----------------------------------------------------------------------+
// | Copyright (c) 1998-2008 Manuel Lemos, Tomas V.V.Cox, |
// | Stig. S. Bakken, Lukas Smith |
// | All rights reserved. |
// +----------------------------------------------------------------------+
// | MDB2 is a merge of PEAR DB and Metabases that provides a unified DB |
// | API as well as database abstraction for PHP applications. |
// | This LICENSE is in the BSD license style. |
// | |
// | Redistribution and use in source and binary forms, with or without |
// | modification, are permitted provided that the following conditions |
// | are met: |
// | |
// | Redistributions of source code must retain the above copyright |
// | notice, this list of conditions and the following disclaimer. |
// | |
// | Redistributions in binary form must reproduce the above copyright |
// | notice, this list of conditions and the following disclaimer in the |
// | documentation and/or other materials provided with the distribution. |
// | |
// | Neither the name of Manuel Lemos, Tomas V.V.Cox, Stig. S. Bakken, |
// | Lukas Smith nor the names of his contributors may be used to endorse |
// | or promote products derived from this software without specific prior|
// | written permission. |
// | |
// | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
// | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
// | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
// | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
// | REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
// | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
// | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS|
// | OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED |
// | AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
// | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY|
// | WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
// | POSSIBILITY OF SUCH DAMAGE. |
// +----------------------------------------------------------------------+
// | Author: Paul Cooper <pgc@ucecom.com> |
// +----------------------------------------------------------------------+
//
// $Id: pgsql.php,v 1.11 2008/11/09 19:46:50 quipo Exp $
require_once 'MDB2/Driver/Function/Common.php';
/**
* MDB2 MySQL driver for the function modules
*
* @package MDB2
* @category Database
* @author Lukas Smith <smith@pooteeweet.org>
*/
class MDB2_Driver_Function_pgsql extends MDB2_Driver_Function_Common
{
// {{{ executeStoredProc()
/**
* Execute a stored procedure and return any results
*
* @param string $name string that identifies the function to execute
* @param mixed $params array that contains the paramaters to pass the stored proc
* @param mixed $types array that contains the types of the columns in
* the result set
* @param mixed $result_class string which specifies which result class to use
* @param mixed $result_wrap_class string which specifies which class to wrap results in
* @return mixed a result handle or MDB2_OK on success, a MDB2 error on failure
* @access public
*/
function &executeStoredProc($name, $params = null, $types = null, $result_class = true, $result_wrap_class = false)
{
$db =& $this->getDBInstance();
if (PEAR::isError($db)) {
return $db;
}
$query = 'SELECT * FROM '.$name;
$query .= $params ? '('.implode(', ', $params).')' : '()';
return $db->query($query, $types, $result_class, $result_wrap_class);
}
// }}}
// {{{ unixtimestamp()
/**
* return string to call a function to get the unix timestamp from a iso timestamp
*
* @param string $expression
*
* @return string to call a variable with the timestamp
* @access public
*/
function unixtimestamp($expression)
{
return 'EXTRACT(EPOCH FROM DATE_TRUNC(\'seconds\', CAST ((' . $expression . ') AS TIMESTAMP)))';
}
// }}}
// {{{ random()
/**
* return string to call a function to get random value inside an SQL statement
*
* @return return string to generate float between 0 and 1
* @access public
*/
function random()
{
return 'RANDOM()';
}
// }}}
}
<?php
// +----------------------------------------------------------------------+
// | PHP versions 4 and 5 |
// +----------------------------------------------------------------------+
// | Copyright (c) 1998-2008 Manuel Lemos, Tomas V.V.Cox, |
// | Stig. S. Bakken, Lukas Smith |
// | All rights reserved. |
// +----------------------------------------------------------------------+
// | MDB2 is a merge of PEAR DB and Metabases that provides a unified DB |
// | API as well as database abstraction for PHP applications. |
// | This LICENSE is in the BSD license style. |
// | |
// | Redistribution and use in source and binary forms, with or without |
// | modification, are permitted provided that the following conditions |
// | are met: |
// | |
// | Redistributions of source code must retain the above copyright |
// | notice, this list of conditions and the following disclaimer. |
// | |
// | Redistributions in binary form must reproduce the above copyright |
// | notice, this list of conditions and the following disclaimer in the |
// | documentation and/or other materials provided with the distribution. |
// | |
// | Neither the name of Manuel Lemos, Tomas V.V.Cox, Stig. S. Bakken, |
// | Lukas Smith nor the names of his contributors may be used to endorse |
// | or promote products derived from this software without specific prior|
// | written permission. |
// | |
// | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
// | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
// | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
// | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
// | REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
// | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
// | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS|
// | OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED |
// | AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
// | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY|
// | WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
// | POSSIBILITY OF SUCH DAMAGE. |
// +----------------------------------------------------------------------+
// | Author: Paul Cooper <pgc@ucecom.com> |
// +----------------------------------------------------------------------+
//
// $Id: pgsql.php,v 1.11 2008/11/09 19:46:50 quipo Exp $
oc_require_once('MDB2/Driver/Function/Common.php');
/**
* MDB2 MySQL driver for the function modules
*
* @package MDB2
* @category Database
* @author Lukas Smith <smith@pooteeweet.org>
*/
class MDB2_Driver_Function_pgsql extends MDB2_Driver_Function_Common
{
// {{{ executeStoredProc()
/**
* Execute a stored procedure and return any results
*
* @param string $name string that identifies the function to execute
* @param mixed $params array that contains the paramaters to pass the stored proc
* @param mixed $types array that contains the types of the columns in
* the result set
* @param mixed $result_class string which specifies which result class to use
* @param mixed $result_wrap_class string which specifies which class to wrap results in
* @return mixed a result handle or MDB2_OK on success, a MDB2 error on failure
* @access public
*/
function &executeStoredProc($name, $params = null, $types = null, $result_class = true, $result_wrap_class = false)
{
$db =& $this->getDBInstance();
if (PEAR::isError($db)) {
return $db;
}
$query = 'SELECT * FROM '.$name;
$query .= $params ? '('.implode(', ', $params).')' : '()';
return $db->query($query, $types, $result_class, $result_wrap_class);
}
// }}}
// {{{ unixtimestamp()
/**
* return string to call a function to get the unix timestamp from a iso timestamp
*
* @param string $expression
*
* @return string to call a variable with the timestamp
* @access public
*/
function unixtimestamp($expression)
{
return 'EXTRACT(EPOCH FROM DATE_TRUNC(\'seconds\', CAST ((' . $expression . ') AS TIMESTAMP)))';
}
// }}}
// {{{ random()
/**
* return string to call a function to get random value inside an SQL statement
*
* @return return string to generate float between 0 and 1
* @access public
*/
function random()
{
return 'RANDOM()';
}
// }}}
}
?>

View File

@ -45,7 +45,7 @@
// $Id: sqlite.php,v 1.10 2008/02/17 18:54:08 quipo Exp $
//
require_once 'MDB2/Driver/Function/Common.php';
oc_require_once('MDB2/Driver/Function/Common.php');
/**
* MDB2 SQLite driver for the function modules

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -44,7 +44,7 @@
//
// $Id: pgsql.php,v 1.87 2008/11/29 14:09:59 afz Exp $
require_once 'MDB2/Driver/Manager/Common.php';
oc_require_once('MDB2/Driver/Manager/Common.php');
/**
* MDB2 MySQL driver for the management modules

View File

@ -46,7 +46,7 @@
// $Id: sqlite.php,v 1.76 2008/05/31 11:48:48 quipo Exp $
//
require_once 'MDB2/Driver/Manager/Common.php';
oc_require_once('MDB2/Driver/Manager/Common.php');
/**
* MDB2 SQLite driver for the management modules

File diff suppressed because it is too large Load Diff

View File

@ -45,7 +45,7 @@
// $Id: mysql.php,v 1.80 2008/03/26 21:15:37 quipo Exp $
//
require_once 'MDB2/Driver/Reverse/Common.php';
oc_require_once('MDB2/Driver/Reverse/Common.php');
/**
* MDB2 MySQL driver for the schema reverse engineering module

File diff suppressed because it is too large Load Diff

View File

@ -46,7 +46,7 @@
// $Id: sqlite.php,v 1.80 2008/05/03 10:30:14 quipo Exp $
//
require_once 'MDB2/Driver/Reverse/Common.php';
oc_require_once('MDB2/Driver/Reverse/Common.php');
/**
* MDB2 SQlite driver for the schema reverse engineering module

File diff suppressed because it is too large Load Diff

View File

@ -336,7 +336,7 @@ class OC_DB {
'portability' => MDB2_PORTABILITY_ALL,
'log_line_break' => '<br>',
'idxname_format' => '%s',
'debug' => false,
'debug' => true,
'quote_identifier' => true,
);
if($CONFIG_DBTYPE=='sqlite'){
@ -363,12 +363,12 @@ class OC_DB {
);
}
self::$DBConnection=&MDB2::factory($dsn,$options);
if (@PEAR::isError(self::$DBConnection)) {
if (PEAR::isError(self::$DBConnection)) {
echo('<b>can not connect to database, using '.$CONFIG_DBTYPE.'. ('.self::$DBConnection->getUserInfo().')</center>');
die(self::$DBConnection->getMessage());
}
self::$DBConnection->setFetchMode(MDB2_FETCHMODE_ASSOC);
self::$schema=&MDB2_Schema::factory($dsn,$options);
self::$schema=&MDB2_Schema::factory(self::$DBConnection);
}
}
@ -634,12 +634,12 @@ function oc_include_once($file){
global $CONFIG_HTTPFORCESSL;
global $CONFIG_DATEFORMAT;
global $CONFIG_INSTALLED;
if(is_file($file)){
return include_once($file);
}elseif(is_file($SERVERROOT.'/'.$file)){
if(is_file($SERVERROOT.'/'.$file)){
return include_once($SERVERROOT.'/'.$file);
}elseif(is_file($SERVERROOT.'/inc/'.$file)){
return include_once($SERVERROOT.'/inc/'.$file);
}elseif(is_file($file)){
return include_once($file);
}
}

View File

@ -209,7 +209,6 @@ class OC_CONFIG{
self::filldatabase();
}
}catch(Exception $e){
echo 'testin';
$error.='error while trying to fill the database<br/>';
}
if($CONFIG_DBTYPE=='sqlite'){

View File

@ -63,7 +63,7 @@ class OC_USER {
*
*/
public static function createuser($username,$password){
if(OC_USER::getuserid($username)!=0){
if(OC_USER::getuserid($username,true)!=0){
return false;
}else{
$usernameclean=strtolower($username);
@ -124,7 +124,7 @@ class OC_USER {
*
*/
public static function creategroup($groupname){
if(OC_USER::getgroupid($groupname)==0){
if(OC_USER::getgroupid($groupname,true)==0){
$groupname=OC_DB::escape($groupname);
$query="INSERT INTO `groups` (`group_name`) VALUES ('$groupname')";
$result=OC_DB::query($query);
@ -138,9 +138,9 @@ class OC_USER {
* get the id of a user
*
*/
public static function getuserid($username){
public static function getuserid($username,$nocache=false){
$usernameclean=strtolower($username);
if(isset($_SESSION['user_id_cache'][$usernameclean])){//try to use cached value to save an sql query
if(!$nocache and isset($_SESSION['user_id_cache'][$usernameclean])){//try to use cached value to save an sql query
return $_SESSION['user_id_cache'][$usernameclean];
}
$usernameclean=OC_DB::escape($usernameclean);
@ -161,8 +161,8 @@ class OC_USER {
* get the id of a group
*
*/
public static function getgroupid($groupname){
if(isset($_SESSION['group_id_cache'][$groupname])){//try to use cached value to save an sql query
public static function getgroupid($groupname,$nocache=false){
if(!$nocache and isset($_SESSION['group_id_cache'][$groupname])){//try to use cached value to save an sql query
return $_SESSION['group_id_cache'][$groupname];
}
$groupname=OC_DB::escape($groupname);
@ -183,8 +183,8 @@ class OC_USER {
* get the name of a group
*
*/
public static function getgroupname($groupid){
if($name=array_search($groupid,$_SESSION['group_id_cache'])){//try to use cached value to save an sql query
public static function getgroupname($groupid,$nocache=false){
if($nocache and $name=array_search($groupid,$_SESSION['group_id_cache'])){//try to use cached value to save an sql query
return $name;
}
$groupid=(integer)$groupid;