- acm_file uses an index pointer to the current row instead of shifting the result array now [Bug #2451]

- all dbals adjusted to use the cache in sql_fetchfield, sql_rowseek, sql_numrows and sql_freeresult [Bug #2451]
- use include_once for dbal.php to at least theoretically allow connections to multiple databases at once
- added a space to an SQL query [Bug #3506]
- detailed information on adding friends/foes [Bugs #2509, #2499]
- e modifier stands for evil, so I removed it ;-)
- corrected progress_bar image filename in imageset.cfg [Bug #3374]


git-svn-id: file:///svn/phpbb/trunk@6225 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Nils Adermann 2006-08-01 16:14:14 +00:00
parent ced8624b8e
commit 09081e410f
15 changed files with 475 additions and 50 deletions

View file

@ -19,6 +19,7 @@ class acm
var $is_modified = false; var $is_modified = false;
var $sql_rowset = array(); var $sql_rowset = array();
var $sql_row_pointer = array();
/** /**
* Set cache path * Set cache path
@ -56,6 +57,7 @@ class acm
unset($this->vars); unset($this->vars);
unset($this->var_expires); unset($this->var_expires);
unset($this->sql_rowset); unset($this->sql_rowset);
unset($this->sql_row_pointer);
} }
/** /**
@ -311,6 +313,8 @@ class acm
return false; return false;
} }
$this->sql_row_pointer[$query_id] = 0;
return $query_id; return $query_id;
} }
@ -331,6 +335,7 @@ class acm
$lines = array(); $lines = array();
$query_id = sizeof($this->sql_rowset); $query_id = sizeof($this->sql_rowset);
$this->sql_rowset[$query_id] = array(); $this->sql_rowset[$query_id] = array();
$this->sql_row_pointer[$query_id] = 0;
while ($row = $db->sql_fetchrow($query_result)) while ($row = $db->sql_fetchrow($query_result))
{ {
@ -361,7 +366,63 @@ class acm
*/ */
function sql_fetchrow($query_id) function sql_fetchrow($query_id)
{ {
return array_shift($this->sql_rowset[$query_id]); if ($this->sql_row_pointer[$query_id] < sizeof($this->sql_rowset[$query_id]))
{
return $this->sql_rowset[$query_id][$this->sql_row_pointer[$query_id]++];
}
return false;
}
/**
* Fetch the number of rows from cache (database)
*/
function sql_numrows($query_id)
{
return sizeof($this->sql_rowset[$query_id]);
}
/**
* Fetch a field from the current row of a cached database result (database)
*/
function sql_fetchfield($query_id, $field)
{
if ($this->sql_row_pointer[$query_id] < sizeof($this->sql_rowset[$query_id]))
{
return $this->sql_rowset[$query_id][$this->sql_row_pointer[$query_id]];
}
return false;
}
/**
* Seek a specific row in an a cached database result (database)
*/
function sql_rowseek($query_id, $rownum)
{
if ($rownum >= sizeof($this->sql_rowset[$query_id]))
{
return false;
}
$this->sql_row_pointer[$query_id] = $rownum;
return true;
}
/**
* Free memory used for a cached database result (database)
*/
function sql_freeresult($query_id)
{
if (!isset($this->sql_rowset[$query_id]))
{
return false;
}
unset($this->sql_rowset[$query_id]);
unset($this->sql_row_pointer[$query_id]);
return true;
} }
} }

View file

@ -22,7 +22,7 @@ if (!defined('SQL_LAYER'))
{ {
define('SQL_LAYER', 'firebird'); define('SQL_LAYER', 'firebird');
include($phpbb_root_path . 'includes/db/dbal.' . $phpEx); include_once($phpbb_root_path . 'includes/db/dbal.' . $phpEx);
/** /**
* Firebird/Interbase Database Abstraction Layer * Firebird/Interbase Database Abstraction Layer
@ -93,6 +93,12 @@ class dbal_firebird extends dbal
/** /**
* Base query method * Base query method
*
* @param string $query Contains the SQL query which shall be executed
* @param int $cache_ttl Either 0 to avoid caching or the time in seconds which the result shall be kept in cache
* @return mixed When casted to bool the returned value returns true on success and false on failure
*
* @access public
*/ */
function sql_query($query = '', $cache_ttl = 0) function sql_query($query = '', $cache_ttl = 0)
{ {
@ -160,6 +166,18 @@ class dbal_firebird extends dbal
*/ */
function sql_numrows($query_id = false) function sql_numrows($query_id = false)
{ {
global $cache;
if (!$query_id)
{
$query_id = $this->query_result;
}
if (isset($cache->sql_rowset[$query_id]))
{
return $cache->sql_numrows($query_id);
}
return false; return false;
} }
@ -218,6 +236,8 @@ class dbal_firebird extends dbal
*/ */
function sql_fetchfield($field, $rownum = false, $query_id = false) function sql_fetchfield($field, $rownum = false, $query_id = false)
{ {
global $cache;
if (!$query_id) if (!$query_id)
{ {
$query_id = $this->query_result; $query_id = $this->query_result;
@ -230,6 +250,11 @@ class dbal_firebird extends dbal
$this->sql_rowseek($rownum, $query_id); $this->sql_rowseek($rownum, $query_id);
} }
if (isset($cache->sql_rowset[$query_id]))
{
return $cache->sql_fetchfield($query_id, $field);
}
$row = $this->sql_fetchrow($query_id); $row = $this->sql_fetchrow($query_id);
return isset($row[$field]) ? $row[$field] : false; return isset($row[$field]) ? $row[$field] : false;
} }
@ -243,11 +268,18 @@ class dbal_firebird extends dbal
*/ */
function sql_rowseek($rownum, $query_id = false) function sql_rowseek($rownum, $query_id = false)
{ {
global $cache;
if (!$query_id) if (!$query_id)
{ {
$query_id = $this->query_result; $query_id = $this->query_result;
} }
if (isset($cache->sql_rowset[$query_id]))
{
return $cache->sql_rowseek($query_id, $rownum);
}
// We do not fetch the row for rownum == 0 because then the next resultset would be the second row // We do not fetch the row for rownum == 0 because then the next resultset would be the second row
for ($i = 0; $i < $rownum; $i++) for ($i = 0; $i < $rownum; $i++)
{ {
@ -293,11 +325,18 @@ class dbal_firebird extends dbal
*/ */
function sql_freeresult($query_id = false) function sql_freeresult($query_id = false)
{ {
global $cache;
if (!$query_id) if (!$query_id)
{ {
$query_id = $this->query_result; $query_id = $this->query_result;
} }
if (isset($cache->sql_rowset[$query_id]))
{
return $cache->sql_freeresult($query_id);
}
if (isset($this->open_queries[(int) $query_id])) if (isset($this->open_queries[(int) $query_id]))
{ {
unset($this->open_queries[(int) $query_id]); unset($this->open_queries[(int) $query_id]);

View file

@ -22,7 +22,7 @@ if (!defined('SQL_LAYER'))
{ {
define('SQL_LAYER', 'mssql'); define('SQL_LAYER', 'mssql');
include($phpbb_root_path . 'includes/db/dbal.' . $phpEx); include_once($phpbb_root_path . 'includes/db/dbal.' . $phpEx);
/** /**
* MSSQL Database Abstraction Layer * MSSQL Database Abstraction Layer
@ -103,6 +103,12 @@ class dbal_mssql extends dbal
/** /**
* Base query method * Base query method
*
* @param string $query Contains the SQL query which shall be executed
* @param int $cache_ttl Either 0 to avoid caching or the time in seconds which the result shall be kept in cache
* @return mixed When casted to bool the returned value returns true on success and false on failure
*
* @access public
*/ */
function sql_query($query = '', $cache_ttl = 0) function sql_query($query = '', $cache_ttl = 0)
{ {
@ -203,11 +209,18 @@ class dbal_mssql extends dbal
*/ */
function sql_numrows($query_id = false) function sql_numrows($query_id = false)
{ {
global $cache;
if (!$query_id) if (!$query_id)
{ {
$query_id = $this->query_result; $query_id = $this->query_result;
} }
if (isset($cache->sql_rowset[$query_id]))
{
return $cache->sql_numrows($query_id);
}
return ($query_id) ? @mssql_num_rows($query_id) : false; return ($query_id) ? @mssql_num_rows($query_id) : false;
} }
@ -256,6 +269,8 @@ class dbal_mssql extends dbal
*/ */
function sql_fetchfield($field, $rownum = false, $query_id = false) function sql_fetchfield($field, $rownum = false, $query_id = false)
{ {
global $cache;
if (!$query_id) if (!$query_id)
{ {
$query_id = $this->query_result; $query_id = $this->query_result;
@ -268,6 +283,11 @@ class dbal_mssql extends dbal
$this->sql_rowseek($rownum, $query_id); $this->sql_rowseek($rownum, $query_id);
} }
if (isset($cache->sql_rowset[$query_id]))
{
return $cache->sql_fetchfield($query_id, $field);
}
$row = $this->sql_fetchrow($query_id); $row = $this->sql_fetchrow($query_id);
return isset($row[$field]) ? $row[$field] : false; return isset($row[$field]) ? $row[$field] : false;
} }
@ -281,11 +301,18 @@ class dbal_mssql extends dbal
*/ */
function sql_rowseek($rownum, $query_id = false) function sql_rowseek($rownum, $query_id = false)
{ {
global $cache;
if (!$query_id) if (!$query_id)
{ {
$query_id = $this->query_result; $query_id = $this->query_result;
} }
if (isset($cache->sql_rowset[$query_id]))
{
return $cache->sql_rowseek($query_id, $rownum);
}
return ($query_id) ? @mssql_data_seek($query_id, $rownum) : false; return ($query_id) ? @mssql_data_seek($query_id, $rownum) : false;
} }
@ -313,11 +340,18 @@ class dbal_mssql extends dbal
*/ */
function sql_freeresult($query_id = false) function sql_freeresult($query_id = false)
{ {
global $cache;
if (!$query_id) if (!$query_id)
{ {
$query_id = $this->query_result; $query_id = $this->query_result;
} }
if (isset($cache->sql_rowset[$query_id]))
{
return $cache->sql_freeresult($query_id);
}
if (isset($this->open_queries[$query_id])) if (isset($this->open_queries[$query_id]))
{ {
unset($this->open_queries[$query_id]); unset($this->open_queries[$query_id]);

View file

@ -22,7 +22,7 @@ if (!defined('SQL_LAYER'))
{ {
define('SQL_LAYER', 'mssql_odbc'); define('SQL_LAYER', 'mssql_odbc');
include($phpbb_root_path . 'includes/db/dbal.' . $phpEx); include_once($phpbb_root_path . 'includes/db/dbal.' . $phpEx);
/** /**
* Unified ODBC functions * Unified ODBC functions
@ -101,6 +101,12 @@ class dbal_mssql_odbc extends dbal
/** /**
* Base query method * Base query method
*
* @param string $query Contains the SQL query which shall be executed
* @param int $cache_ttl Either 0 to avoid caching or the time in seconds which the result shall be kept in cache
* @return mixed When casted to bool the returned value returns true on success and false on failure
*
* @access public
*/ */
function sql_query($query = '', $cache_ttl = 0) function sql_query($query = '', $cache_ttl = 0)
{ {
@ -205,11 +211,18 @@ class dbal_mssql_odbc extends dbal
*/ */
function sql_numrows($query_id = false) function sql_numrows($query_id = false)
{ {
global $cache;
if (!$query_id) if (!$query_id)
{ {
$query_id = $this->query_result; $query_id = $this->query_result;
} }
if (isset($cache->sql_rowset[$query_id]))
{
return $cache->sql_numrows($query_id);
}
return ($query_id) ? @odbc_num_rows($query_id) : false; return ($query_id) ? @odbc_num_rows($query_id) : false;
} }
@ -247,6 +260,8 @@ class dbal_mssql_odbc extends dbal
*/ */
function sql_fetchfield($field, $rownum = false, $query_id = false) function sql_fetchfield($field, $rownum = false, $query_id = false)
{ {
global $cache;
if (!$query_id) if (!$query_id)
{ {
$query_id = $this->query_result; $query_id = $this->query_result;
@ -259,6 +274,11 @@ class dbal_mssql_odbc extends dbal
$this->sql_rowseek($rownum, $query_id); $this->sql_rowseek($rownum, $query_id);
} }
if (isset($cache->sql_rowset[$query_id]))
{
return $cache->sql_fetchfield($query_id, $field);
}
$row = $this->sql_fetchrow($query_id); $row = $this->sql_fetchrow($query_id);
return isset($row[$field]) ? $row[$field] : false; return isset($row[$field]) ? $row[$field] : false;
} }
@ -272,11 +292,18 @@ class dbal_mssql_odbc extends dbal
*/ */
function sql_rowseek($rownum, $query_id = false) function sql_rowseek($rownum, $query_id = false)
{ {
global $cache;
if (!$query_id) if (!$query_id)
{ {
$query_id = $this->query_result; $query_id = $this->query_result;
} }
if (isset($cache->sql_rowset[$query_id]))
{
return $cache->sql_rowseek($query_id, $rownum);
}
$this->sql_freeresult($query_id); $this->sql_freeresult($query_id);
$query_id = $this->sql_query($this->last_query_text); $query_id = $this->sql_query($this->last_query_text);
@ -323,11 +350,18 @@ class dbal_mssql_odbc extends dbal
*/ */
function sql_freeresult($query_id = false) function sql_freeresult($query_id = false)
{ {
global $cache;
if (!$query_id) if (!$query_id)
{ {
$query_id = $this->query_result; $query_id = $this->query_result;
} }
if (isset($cache->sql_rowset[$query_id]))
{
return $cache->sql_freeresult($query_id);
}
if (isset($this->open_queries[(int) $query_id])) if (isset($this->open_queries[(int) $query_id]))
{ {
unset($this->open_queries[(int) $query_id]); unset($this->open_queries[(int) $query_id]);

View file

@ -22,7 +22,7 @@ if (!defined('SQL_LAYER'))
{ {
define('SQL_LAYER', 'mysql'); define('SQL_LAYER', 'mysql');
include($phpbb_root_path . 'includes/db/dbal.' . $phpEx); include_once($phpbb_root_path . 'includes/db/dbal.' . $phpEx);
/** /**
* MySQL Database Abstraction Layer * MySQL Database Abstraction Layer
@ -89,6 +89,12 @@ class dbal_mysql extends dbal
/** /**
* Base query method * Base query method
*
* @param string $query Contains the SQL query which shall be executed
* @param int $cache_ttl Either 0 to avoid caching or the time in seconds which the result shall be kept in cache
* @return mixed When casted to bool the returned value returns true on success and false on failure
*
* @access public
*/ */
function sql_query($query = '', $cache_ttl = 0) function sql_query($query = '', $cache_ttl = 0)
{ {
@ -171,11 +177,18 @@ class dbal_mysql extends dbal
*/ */
function sql_numrows($query_id = false) function sql_numrows($query_id = false)
{ {
global $cache;
if (!$query_id) if (!$query_id)
{ {
$query_id = $this->query_result; $query_id = $this->query_result;
} }
if (isset($cache->sql_rowset[$query_id]))
{
return $cache->sql_numrows($query_id);
}
return ($query_id) ? @mysql_num_rows($query_id) : false; return ($query_id) ? @mysql_num_rows($query_id) : false;
} }
@ -213,6 +226,8 @@ class dbal_mysql extends dbal
*/ */
function sql_fetchfield($field, $rownum = false, $query_id = false) function sql_fetchfield($field, $rownum = false, $query_id = false)
{ {
global $cache;
if (!$query_id) if (!$query_id)
{ {
$query_id = $this->query_result; $query_id = $this->query_result;
@ -222,11 +237,22 @@ class dbal_mysql extends dbal
{ {
if ($rownum === false) if ($rownum === false)
{ {
if (isset($cache->sql_rowset[$query_id]))
{
return $cache->sql_fetchfield($query_id, $field);
}
$row = $this->sql_fetchrow($query_id); $row = $this->sql_fetchrow($query_id);
return isset($row[$field]) ? $row[$field] : false; return isset($row[$field]) ? $row[$field] : false;
} }
else else
{ {
if (isset($cache->sql_rowset[$query_id]))
{
$cache->sql_rowseek($query_id, $rownum);
return $cache->sql_fetchfield($query_id, $field);
}
return @mysql_result($query_id, $rownum, $field); return @mysql_result($query_id, $rownum, $field);
} }
} }
@ -240,11 +266,18 @@ class dbal_mysql extends dbal
*/ */
function sql_rowseek($rownum, $query_id = false) function sql_rowseek($rownum, $query_id = false)
{ {
global $cache;
if (!$query_id) if (!$query_id)
{ {
$query_id = $this->query_result; $query_id = $this->query_result;
} }
if (isset($cache->sql_rowset[$query_id]))
{
return $cache->sql_rowseek($query_id, $rownum);
}
return ($query_id) ? @mysql_data_seek($query_id, $rownum) : false; return ($query_id) ? @mysql_data_seek($query_id, $rownum) : false;
} }
@ -261,11 +294,18 @@ class dbal_mysql extends dbal
*/ */
function sql_freeresult($query_id = false) function sql_freeresult($query_id = false)
{ {
global $cache;
if (!$query_id) if (!$query_id)
{ {
$query_id = $this->query_result; $query_id = $this->query_result;
} }
if (isset($cache->sql_rowset[$query_id]))
{
return $cache->sql_freeresult($query_id);
}
if (isset($this->open_queries[(int) $query_id])) if (isset($this->open_queries[(int) $query_id]))
{ {
unset($this->open_queries[(int) $query_id]); unset($this->open_queries[(int) $query_id]);

View file

@ -22,7 +22,7 @@ if (!defined('SQL_LAYER'))
{ {
define('SQL_LAYER', 'mysql4'); define('SQL_LAYER', 'mysql4');
include($phpbb_root_path . 'includes/db/dbal.' . $phpEx); include_once($phpbb_root_path . 'includes/db/dbal.' . $phpEx);
/** /**
* MySQL4 Database Abstraction Layer * MySQL4 Database Abstraction Layer
@ -91,6 +91,12 @@ class dbal_mysql4 extends dbal
/** /**
* Base query method * Base query method
*
* @param string $query Contains the SQL query which shall be executed
* @param int $cache_ttl Either 0 to avoid caching or the time in seconds which the result shall be kept in cache
* @return mixed When casted to bool the returned value returns true on success and false on failure
*
* @access public
*/ */
function sql_query($query = '', $cache_ttl = 0) function sql_query($query = '', $cache_ttl = 0)
{ {
@ -174,11 +180,18 @@ class dbal_mysql4 extends dbal
*/ */
function sql_numrows($query_id = false) function sql_numrows($query_id = false)
{ {
global $cache;
if (!$query_id) if (!$query_id)
{ {
$query_id = $this->query_result; $query_id = $this->query_result;
} }
if (isset($cache->sql_rowset[$query_id]))
{
return $cache->sql_numrows($query_id);
}
return ($query_id) ? @mysql_num_rows($query_id) : false; return ($query_id) ? @mysql_num_rows($query_id) : false;
} }
@ -216,6 +229,8 @@ class dbal_mysql4 extends dbal
*/ */
function sql_fetchfield($field, $rownum = false, $query_id = false) function sql_fetchfield($field, $rownum = false, $query_id = false)
{ {
global $cache;
if (!$query_id) if (!$query_id)
{ {
$query_id = $this->query_result; $query_id = $this->query_result;
@ -225,11 +240,22 @@ class dbal_mysql4 extends dbal
{ {
if ($rownum === false) if ($rownum === false)
{ {
if (isset($cache->sql_rowset[$query_id]))
{
return $cache->sql_fetchfield($query_id, $field);
}
$row = $this->sql_fetchrow($query_id); $row = $this->sql_fetchrow($query_id);
return isset($row[$field]) ? $row[$field] : false; return isset($row[$field]) ? $row[$field] : false;
} }
else else
{ {
if (isset($cache->sql_rowset[$query_id]))
{
$cache->sql_rowseek($query_id, $rownum);
return $cache->sql_fetchfield($query_id, $field);
}
return @mysql_result($query_id, $rownum, $field); return @mysql_result($query_id, $rownum, $field);
} }
} }
@ -243,11 +269,18 @@ class dbal_mysql4 extends dbal
*/ */
function sql_rowseek($rownum, $query_id = false) function sql_rowseek($rownum, $query_id = false)
{ {
global $cache;
if (!$query_id) if (!$query_id)
{ {
$query_id = $this->query_result; $query_id = $this->query_result;
} }
if (isset($cache->sql_rowset[$query_id]))
{
return $cache->sql_rowseek($query_id, $rownum);
}
return ($query_id) ? @mysql_data_seek($query_id, $rownum) : false; return ($query_id) ? @mysql_data_seek($query_id, $rownum) : false;
} }
@ -264,11 +297,18 @@ class dbal_mysql4 extends dbal
*/ */
function sql_freeresult($query_id = false) function sql_freeresult($query_id = false)
{ {
global $cache;
if (!$query_id) if (!$query_id)
{ {
$query_id = $this->query_result; $query_id = $this->query_result;
} }
if (isset($cache->sql_rowset[$query_id]))
{
return $cache->sql_freeresult($query_id);
}
if (isset($this->open_queries[(int) $query_id])) if (isset($this->open_queries[(int) $query_id]))
{ {
unset($this->open_queries[(int) $query_id]); unset($this->open_queries[(int) $query_id]);

View file

@ -22,7 +22,7 @@ if (!defined('SQL_LAYER'))
{ {
define('SQL_LAYER', 'mysqli'); define('SQL_LAYER', 'mysqli');
include($phpbb_root_path . 'includes/db/dbal.' . $phpEx); include_once($phpbb_root_path . 'includes/db/dbal.' . $phpEx);
/** /**
* MySQLi Database Abstraction Layer * MySQLi Database Abstraction Layer
@ -95,6 +95,12 @@ class dbal_mysqli extends dbal
/** /**
* Base query method * Base query method
*
* @param string $query Contains the SQL query which shall be executed
* @param int $cache_ttl Either 0 to avoid caching or the time in seconds which the result shall be kept in cache
* @return mixed When casted to bool the returned value returns true on success and false on failure
*
* @access public
*/ */
function sql_query($query = '', $cache_ttl = 0) function sql_query($query = '', $cache_ttl = 0)
{ {
@ -173,11 +179,18 @@ class dbal_mysqli extends dbal
*/ */
function sql_numrows($query_id = false) function sql_numrows($query_id = false)
{ {
global $cache;
if (!$query_id) if (!$query_id)
{ {
$query_id = $this->query_result; $query_id = $this->query_result;
} }
if (isset($cache->sql_rowset[$query_id]))
{
return $cache->sql_numrows($query_id);
}
return ($query_id) ? @mysqli_num_rows($query_id) : false; return ($query_id) ? @mysqli_num_rows($query_id) : false;
} }
@ -215,6 +228,8 @@ class dbal_mysqli extends dbal
*/ */
function sql_fetchfield($field, $rownum = false, $query_id = false) function sql_fetchfield($field, $rownum = false, $query_id = false)
{ {
global $cache;
if (!$query_id) if (!$query_id)
{ {
$query_id = $this->query_result; $query_id = $this->query_result;
@ -227,6 +242,11 @@ class dbal_mysqli extends dbal
$this->sql_rowseek($rownum, $query_id); $this->sql_rowseek($rownum, $query_id);
} }
if (isset($cache->sql_rowset[$query_id]))
{
return $cache->sql_fetchfield($query_id, $field);
}
$row = $this->sql_fetchrow($query_id); $row = $this->sql_fetchrow($query_id);
return isset($row[$field]) ? $row[$field] : false; return isset($row[$field]) ? $row[$field] : false;
} }
@ -240,11 +260,18 @@ class dbal_mysqli extends dbal
*/ */
function sql_rowseek($rownum, $query_id = false) function sql_rowseek($rownum, $query_id = false)
{ {
global $cache;
if (!$query_id) if (!$query_id)
{ {
$query_id = $this->query_result; $query_id = $this->query_result;
} }
if (isset($cache->sql_rowset[$query_id]))
{
return $cache->sql_rowseek($query_id, $rownum);
}
return ($query_id) ? @mysqli_data_seek($query_id, $rownum) : false; return ($query_id) ? @mysqli_data_seek($query_id, $rownum) : false;
} }
@ -261,18 +288,19 @@ class dbal_mysqli extends dbal
*/ */
function sql_freeresult($query_id = false) function sql_freeresult($query_id = false)
{ {
global $cache;
if (!$query_id) if (!$query_id)
{ {
$query_id = $this->query_result; $query_id = $this->query_result;
} }
// Make sure it is not a cached query if (isset($cache->sql_rowset[$query_id]))
if (is_object($this->query_result))
{ {
return @mysqli_free_result($query_id); return $cache->sql_freeresult($query_id);
} }
return false; return @mysqli_free_result($query_id);
} }
/** /**

View file

@ -22,7 +22,7 @@ if(!defined('SQL_LAYER'))
{ {
define('SQL_LAYER', 'oracle'); define('SQL_LAYER', 'oracle');
include($phpbb_root_path . 'includes/db/dbal.' . $phpEx); include_once($phpbb_root_path . 'includes/db/dbal.' . $phpEx);
/** /**
* Oracle Database Abstraction Layer * Oracle Database Abstraction Layer
@ -81,6 +81,12 @@ class dbal_oracle extends dbal
/** /**
* Base query method * Base query method
*
* @param string $query Contains the SQL query which shall be executed
* @param int $cache_ttl Either 0 to avoid caching or the time in seconds which the result shall be kept in cache
* @return mixed When casted to bool the returned value returns true on success and false on failure
*
* @access public
*/ */
function sql_query($query = '', $cache_ttl = 0) function sql_query($query = '', $cache_ttl = 0)
{ {
@ -225,11 +231,18 @@ class dbal_oracle extends dbal
*/ */
function sql_numrows($query_id = false) function sql_numrows($query_id = false)
{ {
global $cache;
if (!$query_id) if (!$query_id)
{ {
$query_id = $this->query_result; $query_id = $this->query_result;
} }
if (isset($cache->sql_rowset[$query_id]))
{
return $cache->sql_numrows($query_id);
}
$result = @ocifetchstatement($query_id, $this->rowset); $result = @ocifetchstatement($query_id, $this->rowset);
// OCIFetchStatment kills our query result so we have to execute the statment again // OCIFetchStatment kills our query result so we have to execute the statment again
@ -293,6 +306,8 @@ class dbal_oracle extends dbal
*/ */
function sql_fetchfield($field, $rownum = false, $query_id = false) function sql_fetchfield($field, $rownum = false, $query_id = false)
{ {
global $cache;
if (!$query_id) if (!$query_id)
{ {
$query_id = $this->query_result; $query_id = $this->query_result;
@ -305,6 +320,11 @@ class dbal_oracle extends dbal
$this->sql_rowseek($rownum, $query_id); $this->sql_rowseek($rownum, $query_id);
} }
if (isset($cache->sql_rowset[$query_id]))
{
return $cache->sql_fetchfield($query_id, $field);
}
$row = $this->sql_fetchrow($query_id); $row = $this->sql_fetchrow($query_id);
return isset($row[$field]) ? $row[$field] : false; return isset($row[$field]) ? $row[$field] : false;
} }
@ -318,11 +338,18 @@ class dbal_oracle extends dbal
*/ */
function sql_rowseek($rownum, $query_id = false) function sql_rowseek($rownum, $query_id = false)
{ {
global $cache;
if (!$query_id) if (!$query_id)
{ {
$query_id = $this->query_result; $query_id = $this->query_result;
} }
if (isset($cache->sql_rowset[$query_id]))
{
return $cache->sql_rowseek($query_id, $rownum);
}
if (!$query_id) if (!$query_id)
{ {
return false; return false;
@ -380,11 +407,18 @@ class dbal_oracle extends dbal
*/ */
function sql_freeresult($query_id = false) function sql_freeresult($query_id = false)
{ {
global $cache;
if (!$query_id) if (!$query_id)
{ {
$query_id = $this->query_result; $query_id = $this->query_result;
} }
if (isset($cache->sql_rowset[$query_id]))
{
return $cache->sql_freeresult($query_id);
}
if (isset($this->open_queries[(int) $query_id])) if (isset($this->open_queries[(int) $query_id]))
{ {
unset($this->open_queries[(int) $query_id]); unset($this->open_queries[(int) $query_id]);

View file

@ -22,7 +22,7 @@ if (!defined('SQL_LAYER'))
{ {
define('SQL_LAYER', 'postgres'); define('SQL_LAYER', 'postgres');
include($phpbb_root_path . 'includes/db/dbal.' . $phpEx); include_once($phpbb_root_path . 'includes/db/dbal.' . $phpEx);
/** /**
* PostgreSQL Database Abstraction Layer * PostgreSQL Database Abstraction Layer
@ -120,6 +120,12 @@ class dbal_postgres extends dbal
/** /**
* Base query method * Base query method
*
* @param string $query Contains the SQL query which shall be executed
* @param int $cache_ttl Either 0 to avoid caching or the time in seconds which the result shall be kept in cache
* @return mixed When casted to bool the returned value returns true on success and false on failure
*
* @access public
*/ */
function sql_query($query = '', $cache_ttl = 0) function sql_query($query = '', $cache_ttl = 0)
{ {
@ -212,11 +218,18 @@ class dbal_postgres extends dbal
*/ */
function sql_numrows($query_id = false) function sql_numrows($query_id = false)
{ {
global $cache;
if (!$query_id) if (!$query_id)
{ {
$query_id = $this->query_result; $query_id = $this->query_result;
} }
if (isset($cache->sql_rowset[$query_id]))
{
return $cache->sql_numrows($query_id);
}
return ($query_id) ? @pg_num_rows($query_id) : false; return ($query_id) ? @pg_num_rows($query_id) : false;
} }
@ -254,6 +267,8 @@ class dbal_postgres extends dbal
*/ */
function sql_fetchfield($field, $rownum = false, $query_id = false) function sql_fetchfield($field, $rownum = false, $query_id = false)
{ {
global $cache;
if (!$query_id) if (!$query_id)
{ {
$query_id = $this->query_result; $query_id = $this->query_result;
@ -266,6 +281,11 @@ class dbal_postgres extends dbal
$this->sql_rowseek($rownum, $query_id); $this->sql_rowseek($rownum, $query_id);
} }
if (isset($cache->sql_rowset[$query_id]))
{
return $cache->sql_fetchfield($query_id, $field);
}
$row = $this->sql_fetchrow($query_id); $row = $this->sql_fetchrow($query_id);
return isset($row[$field]) ? $row[$field] : false; return isset($row[$field]) ? $row[$field] : false;
} }
@ -279,11 +299,18 @@ class dbal_postgres extends dbal
*/ */
function sql_rowseek($rownum, $query_id = false) function sql_rowseek($rownum, $query_id = false)
{ {
global $cache;
if (!$query_id) if (!$query_id)
{ {
$query_id = $this->query_result; $query_id = $this->query_result;
} }
if (isset($cache->sql_rowset[$query_id]))
{
return $cache->sql_rowseek($query_id, $rownum);
}
return ($query_id) ? @pg_result_seek($query_id, $rownum) : false; return ($query_id) ? @pg_result_seek($query_id, $rownum) : false;
} }
@ -321,11 +348,18 @@ class dbal_postgres extends dbal
*/ */
function sql_freeresult($query_id = false) function sql_freeresult($query_id = false)
{ {
global $cache;
if (!$query_id) if (!$query_id)
{ {
$query_id = $this->query_result; $query_id = $this->query_result;
} }
if (isset($cache->sql_rowset[$query_id]))
{
return $cache->sql_freeresult($query_id);
}
if (isset($this->open_queries[(int) $query_id])) if (isset($this->open_queries[(int) $query_id]))
{ {
unset($this->open_queries[(int) $query_id]); unset($this->open_queries[(int) $query_id]);

View file

@ -22,7 +22,7 @@ if (!defined('SQL_LAYER'))
{ {
define('SQL_LAYER', 'sqlite'); define('SQL_LAYER', 'sqlite');
include($phpbb_root_path . 'includes/db/dbal.' . $phpEx); include_once($phpbb_root_path . 'includes/db/dbal.' . $phpEx);
/** /**
* Sqlite Database Abstraction Layer * Sqlite Database Abstraction Layer
@ -87,6 +87,12 @@ class dbal_sqlite extends dbal
/** /**
* Base query method * Base query method
*
* @param string $query Contains the SQL query which shall be executed
* @param int $cache_ttl Either 0 to avoid caching or the time in seconds which the result shall be kept in cache
* @return mixed When casted to bool the returned value returns true on success and false on failure
*
* @access public
*/ */
function sql_query($query = '', $cache_ttl = 0) function sql_query($query = '', $cache_ttl = 0)
{ {
@ -169,11 +175,18 @@ class dbal_sqlite extends dbal
*/ */
function sql_numrows($query_id = false) function sql_numrows($query_id = false)
{ {
global $cache;
if (!$query_id) if (!$query_id)
{ {
$query_id = $this->query_result; $query_id = $this->query_result;
} }
if (isset($cache->sql_rowset[$query_id]))
{
return $cache->sql_numrows($query_id);
}
return ($query_id) ? @sqlite_num_rows($query_id) : false; return ($query_id) ? @sqlite_num_rows($query_id) : false;
} }
@ -211,6 +224,8 @@ class dbal_sqlite extends dbal
*/ */
function sql_fetchfield($field, $rownum = false, $query_id = false) function sql_fetchfield($field, $rownum = false, $query_id = false)
{ {
global $cache;
if (!$query_id) if (!$query_id)
{ {
$query_id = $this->query_result; $query_id = $this->query_result;
@ -218,15 +233,17 @@ class dbal_sqlite extends dbal
if ($query_id) if ($query_id)
{ {
if ($rownum === false) if ($rownum !== false)
{
return @sqlite_column($query_id, $field);
}
else
{ {
$this->sql_rowseek($rownum, $query_id); $this->sql_rowseek($rownum, $query_id);
return @sqlite_column($query_id, $field);
} }
if (isset($cache->sql_rowset[$query_id]))
{
return $cache->sql_fetchfield($query_id, $field);
}
return @sqlite_column($query_id, $field);
} }
return false; return false;
@ -238,11 +255,18 @@ class dbal_sqlite extends dbal
*/ */
function sql_rowseek($rownum, $query_id = false) function sql_rowseek($rownum, $query_id = false)
{ {
global $cache;
if (!$query_id) if (!$query_id)
{ {
$query_id = $this->query_result; $query_id = $this->query_result;
} }
if (isset($cache->sql_rowset[$query_id]))
{
return $cache->sql_rowseek($query_id, $rownum);
}
return ($query_id) ? @sqlite_seek($query_id, $rownum) : false; return ($query_id) ? @sqlite_seek($query_id, $rownum) : false;
} }
@ -259,6 +283,18 @@ class dbal_sqlite extends dbal
*/ */
function sql_freeresult($query_id = false) function sql_freeresult($query_id = false)
{ {
global $cache;
if (!$query_id)
{
$query_id = $this->query_result;
}
if (isset($cache->sql_rowset[$query_id]))
{
return $cache->sql_freeresult($query_id);
}
return true; return true;
} }

View file

@ -1032,6 +1032,8 @@ function validate_data($data, $val_ary)
/** /**
* Validate String * Validate String
*
* @return boolean|string Either false if validation succeeded or a string which will be used as the error message (with the variable name appended)
*/ */
function validate_string($string, $optional = false, $min = 0, $max = 0) function validate_string($string, $optional = false, $min = 0, $max = 0)
{ {
@ -1054,6 +1056,8 @@ function validate_string($string, $optional = false, $min = 0, $max = 0)
/** /**
* Validate Number * Validate Number
*
* @return boolean|string Either false if validation succeeded or a string which will be used as the error message (with the variable name appended)
*/ */
function validate_num($num, $optional = false, $min = 0, $max = 1E99) function validate_num($num, $optional = false, $min = 0, $max = 1E99)
{ {
@ -1076,6 +1080,8 @@ function validate_num($num, $optional = false, $min = 0, $max = 1E99)
/** /**
* Validate Match * Validate Match
*
* @return boolean|string Either false if validation succeeded or a string which will be used as the error message (with the variable name appended)
*/ */
function validate_match($string, $optional = false, $match) function validate_match($string, $optional = false, $match)
{ {
@ -1096,6 +1102,8 @@ function validate_match($string, $optional = false, $match)
* Check to see if the username has been taken, or if it is disallowed. * Check to see if the username has been taken, or if it is disallowed.
* Also checks if it includes the " character, which we don't allow in usernames. * Also checks if it includes the " character, which we don't allow in usernames.
* Used for registering, changing names, and posting anonymously with a username * Used for registering, changing names, and posting anonymously with a username
*
* @return boolean|string Either false if validation succeeded or a string which will be used as the error message (with the variable name appended)
*/ */
function validate_username($username) function validate_username($username)
{ {
@ -1168,6 +1176,8 @@ function validate_username($username)
/** /**
* Check to see if email address is banned or already present in the DB * Check to see if email address is banned or already present in the DB
*
* @return boolean|string Either false if validation succeeded or a string which will be used as the error message (with the variable name appended)
*/ */
function validate_email($email) function validate_email($email)
{ {

View file

@ -770,7 +770,7 @@ class fulltext_native extends search_backend
$sql = 'SELECT COUNT(DISTINCT t.topic_id) as total_results'; $sql = 'SELECT COUNT(DISTINCT t.topic_id) as total_results';
} }
$sql .= 'FROM ' . TOPICS_TABLE . ' t, ' . POSTS_TABLE . " p $sql .= ' FROM ' . TOPICS_TABLE . ' t, ' . POSTS_TABLE . " p
WHERE $sql_author WHERE $sql_author
$sql_topic_id $sql_topic_id
$m_approve_fid_sql $m_approve_fid_sql

View file

@ -23,9 +23,12 @@ class ucp_zebra
$submit = (isset($_POST['submit']) || isset($_GET['add'])) ? true : false; $submit = (isset($_POST['submit']) || isset($_GET['add'])) ? true : false;
$s_hidden_fields = ''; $s_hidden_fields = '';
$l_mode = strtoupper($mode);
if ($submit) if ($submit)
{ {
$data = array(); $data = $error = array();
$updated = false;
$var_ary = array( $var_ary = array(
'usernames' => array(0), 'usernames' => array(0),
@ -37,15 +40,9 @@ class ucp_zebra
$data[$var] = request_var($var, $default); $data[$var] = request_var($var, $default);
} }
$var_ary = array( if ($data['add'])
'add' => array('string', false)
);
$error = validate_data($data, $var_ary);
if ($data['add'] && !sizeof($error))
{ {
$data['add'] = array_map('strtolower', explode("\n", $data['add'])); $data['add'] = array_map('trim', array_map('strtolower', explode("\n", $data['add'])));
// Do these name/s exist on a list already? If so, ignore ... we could be // Do these name/s exist on a list already? If so, ignore ... we could be
// 'nice' and automatically handle names added to one list present on // 'nice' and automatically handle names added to one list present on
@ -71,26 +68,56 @@ class ucp_zebra
} }
$db->sql_freeresult($result); $db->sql_freeresult($result);
$data['add'] = array_diff($data['add'], $friends, $foes, array(strtolower($user->data['username']))); // remove friends from the username array
unset($friends, $foes); $n = sizeof($data['add']);
$data['add'] = array_diff($data['add'], $friends);
$data['add'] = implode(', ', preg_replace('#^[\s]*?(.*?)[\s]*?$#e', "\"'\" . \$db->sql_escape('\\1') . \"'\"", $data['add'])); if (sizeof($data['add']) < $n && $mode == 'foes')
{
$error[] = $user->lang['NOT_ADDED_FOES_FRIENDS'];
}
// remove foes from the username array
$n = sizeof($data['add']);
$data['add'] = array_diff($data['add'], $foes);
if (sizeof($data['add']) < $n && $mode == 'friends')
{
$error[] = $user->lang['NOT_ADDED_FRIENDS_FOES'];
}
// remove the user himself from the username array
$n = sizeof($data['add']);
$data['add'] = array_diff($data['add'], array(strtolower($user->data['username'])));
if (sizeof($data['add']) < $n)
{
$error[] = $user->lang['NOT_ADDED_' . $l_mode . '_SELF'];
}
unset($friends, $foes, $n);
$data['add'] = implode(', ', preg_replace('#^(.*?)$#', "'$1'", array_map(array(&$db, 'sql_escape'), $data['add'])));
if ($data['add']) if ($data['add'])
{ {
$sql = 'SELECT user_id, user_type $sql = 'SELECT user_id, user_type
FROM ' . USERS_TABLE . ' FROM ' . USERS_TABLE . '
WHERE LOWER(username) IN (' . $data['add'] . ') WHERE LOWER(username) IN (' . $data['add'] . ')
AND user_type NOT IN (' . USER_IGNORE . ', ' . USER_INACTIVE . ')'; AND user_type <> ' . USER_INACTIVE;
$result = $db->sql_query($sql); $result = $db->sql_query($sql);
$user_id_ary = array(); $user_id_ary = array();
while ($row = $db->sql_fetchrow($result)) while ($row = $db->sql_fetchrow($result))
{ {
if ($row['user_id'] != ANONYMOUS) if ($row['user_id'] != ANONYMOUS && $row['user_type'] != USER_IGNORE)
{ {
$user_id_ary[] = $row['user_id']; $user_id_ary[] = $row['user_id'];
} }
else
{
$error[] = $user->lang['NOT_ADDED_' . $l_mode . '_ANONYMOUS'];
}
} }
$db->sql_freeresult($result); $db->sql_freeresult($result);
@ -110,6 +137,11 @@ class ucp_zebra
$perms = array_unique($perms); $perms = array_unique($perms);
if (sizeof($perms))
{
$error[] = $user->lang['NOT_ADDED_FOES_MOD_ADMIN'];
}
// This may not be right ... it may yield true when perms equate to deny // This may not be right ... it may yield true when perms equate to deny
$user_id_ary = array_diff($user_id_ary, $perms); $user_id_ary = array_diff($user_id_ary, $perms);
unset($perms); unset($perms);
@ -147,20 +179,18 @@ class ucp_zebra
break; break;
} }
} }
}
else $updated = true;
{
$error[] = 'NOT_ADDED_' . strtoupper($mode);
} }
unset($user_id_ary); unset($user_id_ary);
} }
else else if (!sizeof($error))
{ {
$error[] = 'USER_NOT_FOUND_OR_INACTIVE'; $error[] = $user->lang['USER_NOT_FOUND_OR_INACTIVE'];
} }
} }
} }
else if (sizeof($data['usernames']) && !sizeof($error)) else if (sizeof($data['usernames']))
{ {
// Force integer values // Force integer values
$data['usernames'] = array_map('intval', $data['usernames']); $data['usernames'] = array_map('intval', $data['usernames']);
@ -171,15 +201,15 @@ class ucp_zebra
$db->sql_query($sql); $db->sql_query($sql);
} }
if (!sizeof($error)) if ($updated)
{ {
meta_refresh(3, $this->u_action); meta_refresh(3, $this->u_action);
$message = $user->lang[strtoupper($mode) . '_UPDATED'] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>'); $message = $user->lang[$l_mode . '_UPDATED'] . '<br />' . implode('<br />', $error) . ((sizeof($error)) ? '<br />' : '') . '<br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>');
trigger_error($message); trigger_error($message);
} }
else else
{ {
$template->assign_var('ERROR', implode('<br />', preg_replace('#^([A-Z_]+)$#e', "(!empty(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '\\1'", $error))); $template->assign_var('ERROR', implode('<br />', $error));
} }
} }
@ -200,7 +230,7 @@ class ucp_zebra
$db->sql_freeresult($result); $db->sql_freeresult($result);
$template->assign_vars(array( $template->assign_vars(array(
'L_TITLE' => $user->lang['UCP_ZEBRA_' . strtoupper($mode)], 'L_TITLE' => $user->lang['UCP_ZEBRA_' . $l_mode],
'U_SEARCH_USER' => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=searchuser&amp;form=ucp&amp;field=add'), 'U_SEARCH_USER' => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=searchuser&amp;form=ucp&amp;field=add'),
@ -210,7 +240,7 @@ class ucp_zebra
); );
$this->tpl_name = 'ucp_zebra_' . $mode; $this->tpl_name = 'ucp_zebra_' . $mode;
$this->page_title = 'UCP_ZEBRA_' . strtoupper($mode); $this->page_title = 'UCP_ZEBRA_' . $l_mode;
} }
} }

View file

@ -250,8 +250,13 @@ $lang = array_merge($lang, array(
'NOTIFY_METHOD_EXPLAIN' => 'Method for sending messages sent via this board.', 'NOTIFY_METHOD_EXPLAIN' => 'Method for sending messages sent via this board.',
'NOTIFY_METHOD_IM' => 'Jabber only', 'NOTIFY_METHOD_IM' => 'Jabber only',
'NOTIFY_ON_PM' => 'Email me on new private messages', 'NOTIFY_ON_PM' => 'Email me on new private messages',
'NOT_ADDED_FRIENDS' => 'You cannot add the anonymous user to your friends list.', 'NOT_ADDED_FRIENDS_ANONYMOUS' => 'You cannot add the anonymous user to your friends list.',
'NOT_ADDED_FOES' => 'Usernames not added to foes list because of administrator/moderator status or because you tried to add the anonymous user.', 'NOT_ADDED_FRIENDS_FOES' => 'You cannot add users to your friends list who are on your foes list',
'NOT_ADDED_FRIENDS_SELF' => 'You cannot add yourself to the friends list',
'NOT_ADDED_FOES_MOD_ADMIN' => 'You cannot add administrators and moderators to your foes list.',
'NOT_ADDED_FOES_ANONYMOUS' => 'You cannot add the anonymous user to your foes list.',
'NOT_ADDED_FOES_FRIENDS' => 'You cannot add users to your foes list who are on your friends list.',
'NOT_ADDED_FOES_SELF' => 'You cannot add yourself to the foes list.',
'NOT_AGREE' => 'I do not agree to these terms', 'NOT_AGREE' => 'I do not agree to these terms',
'NOT_ENOUGH_SPACE_FOLDER' => 'The destination folder "%s" seems to be full. The requested action has not been taken.', 'NOT_ENOUGH_SPACE_FOLDER' => 'The destination folder "%s" seems to be full. The requested action has not been taken.',
'NOT_MOVED_MESSAGE' => 'You have 1 private message currently on hold because of full folder.', 'NOT_MOVED_MESSAGE' => 'You have 1 private message currently on hold because of full folder.',

View file

@ -101,4 +101,4 @@ img_folder_global_new_post = folder_announce_new_posted.gif*18*19
img_poll_left = vote_lcap.gif*12*4 img_poll_left = vote_lcap.gif*12*4
img_poll_center = voting_bar.gif*12* img_poll_center = voting_bar.gif*12*
img_poll_right = vote_rcap.gif*12*4 img_poll_right = vote_rcap.gif*12*4
img_attach_progress_bar = attach_progress_bar.gif*16*280 img_attach_progress_bar = progress_bar.gif*16*280