diff options
-rw-r--r-- | phpBB/includes/acm/acm_file.php | 63 | ||||
-rw-r--r-- | phpBB/includes/db/firebird.php | 41 | ||||
-rw-r--r-- | phpBB/includes/db/mssql.php | 36 | ||||
-rw-r--r-- | phpBB/includes/db/mssql_odbc.php | 36 | ||||
-rw-r--r-- | phpBB/includes/db/mysql.php | 42 | ||||
-rw-r--r-- | phpBB/includes/db/mysql4.php | 42 | ||||
-rw-r--r-- | phpBB/includes/db/mysqli.php | 38 | ||||
-rw-r--r-- | phpBB/includes/db/oracle.php | 36 | ||||
-rw-r--r-- | phpBB/includes/db/postgres.php | 36 | ||||
-rw-r--r-- | phpBB/includes/db/sqlite.php | 48 | ||||
-rw-r--r-- | phpBB/includes/functions_user.php | 10 | ||||
-rwxr-xr-x | phpBB/includes/search/fulltext_native.php | 2 | ||||
-rw-r--r-- | phpBB/includes/ucp/ucp_zebra.php | 82 | ||||
-rw-r--r-- | phpBB/language/en/ucp.php | 9 | ||||
-rw-r--r-- | phpBB/styles/subSilver/imageset/imageset.cfg | 2 |
15 files changed, 474 insertions, 49 deletions
diff --git a/phpBB/includes/acm/acm_file.php b/phpBB/includes/acm/acm_file.php index 8de53144ea..7cfc487518 100644 --- a/phpBB/includes/acm/acm_file.php +++ b/phpBB/includes/acm/acm_file.php @@ -19,6 +19,7 @@ class acm var $is_modified = false; var $sql_rowset = array(); + var $sql_row_pointer = array(); /** * Set cache path @@ -56,6 +57,7 @@ class acm unset($this->vars); unset($this->var_expires); unset($this->sql_rowset); + unset($this->sql_row_pointer); } /** @@ -311,6 +313,8 @@ class acm return false; } + $this->sql_row_pointer[$query_id] = 0; + return $query_id; } @@ -331,6 +335,7 @@ class acm $lines = array(); $query_id = sizeof($this->sql_rowset); $this->sql_rowset[$query_id] = array(); + $this->sql_row_pointer[$query_id] = 0; while ($row = $db->sql_fetchrow($query_result)) { @@ -361,7 +366,63 @@ class acm */ 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; } } diff --git a/phpBB/includes/db/firebird.php b/phpBB/includes/db/firebird.php index 8eec225c96..e77225ae02 100644 --- a/phpBB/includes/db/firebird.php +++ b/phpBB/includes/db/firebird.php @@ -22,7 +22,7 @@ if (!defined('SQL_LAYER')) { 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 @@ -93,6 +93,12 @@ class dbal_firebird extends dbal /** * 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) { @@ -160,6 +166,18 @@ class dbal_firebird extends dbal */ 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; } @@ -218,6 +236,8 @@ class dbal_firebird extends dbal */ function sql_fetchfield($field, $rownum = false, $query_id = false) { + global $cache; + if (!$query_id) { $query_id = $this->query_result; @@ -230,6 +250,11 @@ class dbal_firebird extends dbal $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); return isset($row[$field]) ? $row[$field] : false; } @@ -243,11 +268,18 @@ class dbal_firebird extends dbal */ function sql_rowseek($rownum, $query_id = false) { + global $cache; + if (!$query_id) { $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 for ($i = 0; $i < $rownum; $i++) { @@ -293,11 +325,18 @@ class dbal_firebird extends dbal */ 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); + } + if (isset($this->open_queries[(int) $query_id])) { unset($this->open_queries[(int) $query_id]); diff --git a/phpBB/includes/db/mssql.php b/phpBB/includes/db/mssql.php index 6ef8597c18..13a6fb8aab 100644 --- a/phpBB/includes/db/mssql.php +++ b/phpBB/includes/db/mssql.php @@ -22,7 +22,7 @@ if (!defined('SQL_LAYER')) { 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 @@ -103,6 +103,12 @@ class dbal_mssql extends dbal /** * 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) { @@ -203,11 +209,18 @@ class dbal_mssql extends dbal */ 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 ($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) { + global $cache; + if (!$query_id) { $query_id = $this->query_result; @@ -268,6 +283,11 @@ class dbal_mssql extends dbal $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); return isset($row[$field]) ? $row[$field] : false; } @@ -281,11 +301,18 @@ class dbal_mssql extends dbal */ function sql_rowseek($rownum, $query_id = false) { + global $cache; + if (!$query_id) { $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; } @@ -313,11 +340,18 @@ class dbal_mssql extends dbal */ 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); + } + if (isset($this->open_queries[$query_id])) { unset($this->open_queries[$query_id]); diff --git a/phpBB/includes/db/mssql_odbc.php b/phpBB/includes/db/mssql_odbc.php index 8f37206817..e1b2675a23 100644 --- a/phpBB/includes/db/mssql_odbc.php +++ b/phpBB/includes/db/mssql_odbc.php @@ -22,7 +22,7 @@ if (!defined('SQL_LAYER')) { 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 @@ -101,6 +101,12 @@ class dbal_mssql_odbc extends dbal /** * 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) { @@ -205,11 +211,18 @@ class dbal_mssql_odbc extends dbal */ 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 ($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) { + global $cache; + if (!$query_id) { $query_id = $this->query_result; @@ -259,6 +274,11 @@ class dbal_mssql_odbc extends dbal $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); return isset($row[$field]) ? $row[$field] : false; } @@ -272,11 +292,18 @@ class dbal_mssql_odbc extends dbal */ function sql_rowseek($rownum, $query_id = false) { + global $cache; + if (!$query_id) { $query_id = $this->query_result; } + if (isset($cache->sql_rowset[$query_id])) + { + return $cache->sql_rowseek($query_id, $rownum); + } + $this->sql_freeresult($query_id); $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) { + global $cache; + if (!$query_id) { $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])) { unset($this->open_queries[(int) $query_id]); diff --git a/phpBB/includes/db/mysql.php b/phpBB/includes/db/mysql.php index 60e56e2964..7e363721a9 100644 --- a/phpBB/includes/db/mysql.php +++ b/phpBB/includes/db/mysql.php @@ -22,7 +22,7 @@ if (!defined('SQL_LAYER')) { 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 @@ -89,6 +89,12 @@ class dbal_mysql extends dbal /** * 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) { @@ -171,11 +177,18 @@ class dbal_mysql extends dbal */ 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 ($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) { + global $cache; + if (!$query_id) { $query_id = $this->query_result; @@ -222,11 +237,22 @@ class dbal_mysql extends dbal { if ($rownum === false) { + if (isset($cache->sql_rowset[$query_id])) + { + return $cache->sql_fetchfield($query_id, $field); + } + $row = $this->sql_fetchrow($query_id); return isset($row[$field]) ? $row[$field] : false; } 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); } } @@ -240,11 +266,18 @@ class dbal_mysql extends dbal */ function sql_rowseek($rownum, $query_id = false) { + global $cache; + if (!$query_id) { $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; } @@ -261,11 +294,18 @@ class dbal_mysql extends dbal */ 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); + } + if (isset($this->open_queries[(int) $query_id])) { unset($this->open_queries[(int) $query_id]); diff --git a/phpBB/includes/db/mysql4.php b/phpBB/includes/db/mysql4.php index 6028a7085f..071f4c4b55 100644 --- a/phpBB/includes/db/mysql4.php +++ b/phpBB/includes/db/mysql4.php @@ -22,7 +22,7 @@ if (!defined('SQL_LAYER')) { 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 @@ -91,6 +91,12 @@ class dbal_mysql4 extends dbal /** * 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) { @@ -174,11 +180,18 @@ class dbal_mysql4 extends dbal */ 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 ($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) { + global $cache; + if (!$query_id) { $query_id = $this->query_result; @@ -225,11 +240,22 @@ class dbal_mysql4 extends dbal { if ($rownum === false) { + if (isset($cache->sql_rowset[$query_id])) + { + return $cache->sql_fetchfield($query_id, $field); + } + $row = $this->sql_fetchrow($query_id); return isset($row[$field]) ? $row[$field] : false; } 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); } } @@ -243,11 +269,18 @@ class dbal_mysql4 extends dbal */ function sql_rowseek($rownum, $query_id = false) { + global $cache; + if (!$query_id) { $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; } @@ -264,11 +297,18 @@ class dbal_mysql4 extends dbal */ 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); + } + if (isset($this->open_queries[(int) $query_id])) { unset($this->open_queries[(int) $query_id]); diff --git a/phpBB/includes/db/mysqli.php b/phpBB/includes/db/mysqli.php index 1257621729..f6a00fde3b 100644 --- a/phpBB/includes/db/mysqli.php +++ b/phpBB/includes/db/mysqli.php @@ -22,7 +22,7 @@ if (!defined('SQL_LAYER')) { 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 @@ -95,6 +95,12 @@ class dbal_mysqli extends dbal /** * 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) { @@ -173,11 +179,18 @@ class dbal_mysqli extends dbal */ 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 ($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) { + global $cache; + if (!$query_id) { $query_id = $this->query_result; @@ -227,6 +242,11 @@ class dbal_mysqli extends dbal $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); return isset($row[$field]) ? $row[$field] : false; } @@ -240,11 +260,18 @@ class dbal_mysqli extends dbal */ function sql_rowseek($rownum, $query_id = false) { + global $cache; + if (!$query_id) { $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; } @@ -261,18 +288,19 @@ class dbal_mysqli extends dbal */ function sql_freeresult($query_id = false) { + global $cache; + if (!$query_id) { $query_id = $this->query_result; } - // Make sure it is not a cached query - if (is_object($this->query_result)) + if (isset($cache->sql_rowset[$query_id])) { - return @mysqli_free_result($query_id); + return $cache->sql_freeresult($query_id); } - return false; + return @mysqli_free_result($query_id); } /** diff --git a/phpBB/includes/db/oracle.php b/phpBB/includes/db/oracle.php index 699005fd99..fc5bf6f78e 100644 --- a/phpBB/includes/db/oracle.php +++ b/phpBB/includes/db/oracle.php @@ -22,7 +22,7 @@ if(!defined('SQL_LAYER')) { 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 @@ -81,6 +81,12 @@ class dbal_oracle extends dbal /** * 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) { @@ -225,11 +231,18 @@ class dbal_oracle extends dbal */ 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); + } + $result = @ocifetchstatement($query_id, $this->rowset); // 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) { + global $cache; + if (!$query_id) { $query_id = $this->query_result; @@ -305,6 +320,11 @@ class dbal_oracle extends dbal $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); return isset($row[$field]) ? $row[$field] : false; } @@ -318,11 +338,18 @@ class dbal_oracle extends dbal */ function sql_rowseek($rownum, $query_id = false) { + global $cache; + if (!$query_id) { $query_id = $this->query_result; } + if (isset($cache->sql_rowset[$query_id])) + { + return $cache->sql_rowseek($query_id, $rownum); + } + if (!$query_id) { return false; @@ -380,11 +407,18 @@ class dbal_oracle extends dbal */ 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); + } + if (isset($this->open_queries[(int) $query_id])) { unset($this->open_queries[(int) $query_id]); diff --git a/phpBB/includes/db/postgres.php b/phpBB/includes/db/postgres.php index 3a8e52f78d..c928a936d9 100644 --- a/phpBB/includes/db/postgres.php +++ b/phpBB/includes/db/postgres.php @@ -22,7 +22,7 @@ if (!defined('SQL_LAYER')) { 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 @@ -120,6 +120,12 @@ class dbal_postgres extends dbal /** * 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) { @@ -212,11 +218,18 @@ class dbal_postgres extends dbal */ 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 ($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) { + global $cache; + if (!$query_id) { $query_id = $this->query_result; @@ -266,6 +281,11 @@ class dbal_postgres extends dbal $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); return isset($row[$field]) ? $row[$field] : false; } @@ -279,11 +299,18 @@ class dbal_postgres extends dbal */ function sql_rowseek($rownum, $query_id = false) { + global $cache; + if (!$query_id) { $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; } @@ -321,11 +348,18 @@ class dbal_postgres extends dbal */ 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); + } + if (isset($this->open_queries[(int) $query_id])) { unset($this->open_queries[(int) $query_id]); diff --git a/phpBB/includes/db/sqlite.php b/phpBB/includes/db/sqlite.php index 95f12175c3..152adfa42c 100644 --- a/phpBB/includes/db/sqlite.php +++ b/phpBB/includes/db/sqlite.php @@ -22,7 +22,7 @@ if (!defined('SQL_LAYER')) { 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 @@ -87,6 +87,12 @@ class dbal_sqlite extends dbal /** * 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) { @@ -169,11 +175,18 @@ class dbal_sqlite extends dbal */ 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 ($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) { + global $cache; + if (!$query_id) { $query_id = $this->query_result; @@ -218,15 +233,17 @@ class dbal_sqlite extends dbal if ($query_id) { - if ($rownum === false) + if ($rownum !== false) { - return @sqlite_column($query_id, $field); + $this->sql_rowseek($rownum, $query_id); } - else + + if (isset($cache->sql_rowset[$query_id])) { - $this->sql_rowseek($rownum, $query_id); - return @sqlite_column($query_id, $field); + return $cache->sql_fetchfield($query_id, $field); } + + return @sqlite_column($query_id, $field); } return false; @@ -238,11 +255,18 @@ class dbal_sqlite extends dbal */ function sql_rowseek($rownum, $query_id = false) { + global $cache; + if (!$query_id) { $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; } @@ -259,6 +283,18 @@ class dbal_sqlite extends dbal */ 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; } diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index b0c2d4a2b7..2c5f3ff89a 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -1032,6 +1032,8 @@ function validate_data($data, $val_ary) /** * 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) { @@ -1054,6 +1056,8 @@ function validate_string($string, $optional = false, $min = 0, $max = 0) /** * 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) { @@ -1076,6 +1080,8 @@ function validate_num($num, $optional = false, $min = 0, $max = 1E99) /** * 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) { @@ -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. * 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 +* +* @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) { @@ -1168,6 +1176,8 @@ function validate_username($username) /** * 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) { diff --git a/phpBB/includes/search/fulltext_native.php b/phpBB/includes/search/fulltext_native.php index 315e811fcd..674199d69f 100755 --- a/phpBB/includes/search/fulltext_native.php +++ b/phpBB/includes/search/fulltext_native.php @@ -770,7 +770,7 @@ class fulltext_native extends search_backend $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 $sql_topic_id $m_approve_fid_sql diff --git a/phpBB/includes/ucp/ucp_zebra.php b/phpBB/includes/ucp/ucp_zebra.php index b5cad8b38b..fb9925e248 100644 --- a/phpBB/includes/ucp/ucp_zebra.php +++ b/phpBB/includes/ucp/ucp_zebra.php @@ -23,9 +23,12 @@ class ucp_zebra $submit = (isset($_POST['submit']) || isset($_GET['add'])) ? true : false; $s_hidden_fields = ''; + $l_mode = strtoupper($mode); + if ($submit) { - $data = array(); + $data = $error = array(); + $updated = false; $var_ary = array( 'usernames' => array(0), @@ -37,15 +40,9 @@ class ucp_zebra $data[$var] = request_var($var, $default); } - $var_ary = array( - 'add' => array('string', false) - ); - - $error = validate_data($data, $var_ary); - - if ($data['add'] && !sizeof($error)) + if ($data['add']) { - $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 // 'nice' and automatically handle names added to one list present on @@ -71,26 +68,56 @@ class ucp_zebra } $db->sql_freeresult($result); - $data['add'] = array_diff($data['add'], $friends, $foes, array(strtolower($user->data['username']))); - unset($friends, $foes); + // remove friends from the username array + $n = sizeof($data['add']); + $data['add'] = array_diff($data['add'], $friends); + + 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']; + } - $data['add'] = implode(', ', preg_replace('#^[\s]*?(.*?)[\s]*?$#e', "\"'\" . \$db->sql_escape('\\1') . \"'\"", $data['add'])); + unset($friends, $foes, $n); + + $data['add'] = implode(', ', preg_replace('#^(.*?)$#', "'$1'", array_map(array(&$db, 'sql_escape'), $data['add']))); if ($data['add']) { $sql = 'SELECT user_id, user_type FROM ' . USERS_TABLE . ' 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); $user_id_ary = array(); 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']; } + else + { + $error[] = $user->lang['NOT_ADDED_' . $l_mode . '_ANONYMOUS']; + } } $db->sql_freeresult($result); @@ -110,6 +137,11 @@ class ucp_zebra $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 $user_id_ary = array_diff($user_id_ary, $perms); unset($perms); @@ -147,20 +179,18 @@ class ucp_zebra break; } } - } - else - { - $error[] = 'NOT_ADDED_' . strtoupper($mode); + + $updated = true; } 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 $data['usernames'] = array_map('intval', $data['usernames']); @@ -171,15 +201,15 @@ class ucp_zebra $db->sql_query($sql); } - if (!sizeof($error)) + if ($updated) { 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); } 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); $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&form=ucp&field=add'), @@ -210,7 +240,7 @@ class ucp_zebra ); $this->tpl_name = 'ucp_zebra_' . $mode; - $this->page_title = 'UCP_ZEBRA_' . strtoupper($mode); + $this->page_title = 'UCP_ZEBRA_' . $l_mode; } } diff --git a/phpBB/language/en/ucp.php b/phpBB/language/en/ucp.php index a5616e2955..afba253ee2 100644 --- a/phpBB/language/en/ucp.php +++ b/phpBB/language/en/ucp.php @@ -250,8 +250,13 @@ $lang = array_merge($lang, array( 'NOTIFY_METHOD_EXPLAIN' => 'Method for sending messages sent via this board.', 'NOTIFY_METHOD_IM' => 'Jabber only', 'NOTIFY_ON_PM' => 'Email me on new private messages', - 'NOT_ADDED_FRIENDS' => '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_ANONYMOUS' => 'You cannot add the anonymous user to your friends list.', + '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_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.', diff --git a/phpBB/styles/subSilver/imageset/imageset.cfg b/phpBB/styles/subSilver/imageset/imageset.cfg index 88103072c6..03315eedbb 100644 --- a/phpBB/styles/subSilver/imageset/imageset.cfg +++ b/phpBB/styles/subSilver/imageset/imageset.cfg @@ -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_center = voting_bar.gif*12* 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 |