aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB
diff options
context:
space:
mode:
authorMeik Sievertsen <acydburn@phpbb.com>2005-08-17 15:57:50 +0000
committerMeik Sievertsen <acydburn@phpbb.com>2005-08-17 15:57:50 +0000
commit4740e7dece880f5cda26976ba758fc31c769f231 (patch)
tree0c612bb72e483d67567eeb1f4b097b452487d6b3 /phpBB
parent1694af43aadb22686ee0ab2d045269fc2a9c3f82 (diff)
downloadforums-4740e7dece880f5cda26976ba758fc31c769f231.tar
forums-4740e7dece880f5cda26976ba758fc31c769f231.tar.gz
forums-4740e7dece880f5cda26976ba758fc31c769f231.tar.bz2
forums-4740e7dece880f5cda26976ba758fc31c769f231.tar.xz
forums-4740e7dece880f5cda26976ba758fc31c769f231.zip
- changed dbal class layout
git-svn-id: file:///svn/phpbb/trunk@5193 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB')
-rw-r--r--phpBB/common.php4
-rw-r--r--phpBB/includes/db/dbal.php196
-rw-r--r--phpBB/includes/db/firebird.php171
-rw-r--r--phpBB/includes/db/mssql.php164
-rw-r--r--phpBB/includes/db/mysql.php166
-rw-r--r--phpBB/includes/db/mysql4.php166
-rw-r--r--phpBB/includes/db/mysqli.php165
-rw-r--r--phpBB/includes/db/oracle.php159
-rw-r--r--phpBB/includes/db/postgres.php164
-rw-r--r--phpBB/includes/db/sqlite.php161
-rw-r--r--phpBB/includes/message_parser.php2
-rw-r--r--phpBB/install/install.php10
-rw-r--r--phpBB/language/en/admin.php2
-rw-r--r--phpBB/language/en/common.php5
-rw-r--r--phpBB/language/en/groups.php15
15 files changed, 308 insertions, 1242 deletions
diff --git a/phpBB/common.php b/phpBB/common.php
index 91f0d30814..0ce33d20fc 100644
--- a/phpBB/common.php
+++ b/phpBB/common.php
@@ -12,6 +12,8 @@
// says before continuing
die('This software is unsupported in any and all respects. By removing this notice (found in common.php) you are noting your acceptance of this. Do not ask support questions of any kind for this release at either area51.phpbb.com or www.phpbb.com. Support for this version will appear when the beta cycle begins');
+/**
+*/
if (!defined('IN_PHPBB'))
{
exit;
@@ -253,7 +255,7 @@ $user = new user();
$auth = new auth();
$template = new template();
$cache = new acm();
-$db = new sql_db();
+$db = new $sql_db();
// Connect to DB
$db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false);
diff --git a/phpBB/includes/db/dbal.php b/phpBB/includes/db/dbal.php
new file mode 100644
index 0000000000..70089aa11f
--- /dev/null
+++ b/phpBB/includes/db/dbal.php
@@ -0,0 +1,196 @@
+<?php
+/**
+*
+* @package dbal
+* @version $Id$
+* @copyright (c) 2005 phpBB Group
+* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+*
+*/
+
+/**
+* @package dbal
+* Database Abstraction Layer
+*/
+class dbal
+{
+ var $db_connect_id;
+ var $query_result;
+ var $return_on_error = false;
+ var $transaction = false;
+ var $sql_time = 0;
+ var $num_queries = 0;
+ var $open_queries = array();
+
+ function sql_return_on_error($fail = false)
+ {
+ $this->return_on_error = $fail;
+ }
+
+ function sql_num_queries()
+ {
+ return $this->num_queries;
+ }
+
+ // Idea for this from Ikonboard
+ function sql_build_array($query, $assoc_ary = false)
+ {
+ if (!is_array($assoc_ary))
+ {
+ return false;
+ }
+
+ $fields = array();
+ $values = array();
+ if ($query == 'INSERT')
+ {
+ foreach ($assoc_ary as $key => $var)
+ {
+ $fields[] = $key;
+
+ if (is_null($var))
+ {
+ $values[] = 'NULL';
+ }
+ elseif (is_string($var))
+ {
+ $values[] = "'" . $this->sql_escape($var) . "'";
+ }
+ else
+ {
+ $values[] = (is_bool($var)) ? intval($var) : $var;
+ }
+ }
+
+ $query = ' (' . implode(', ', $fields) . ') VALUES (' . implode(', ', $values) . ')';
+ }
+ else if ($query == 'UPDATE' || $query == 'SELECT')
+ {
+ $values = array();
+ foreach ($assoc_ary as $key => $var)
+ {
+ if (is_null($var))
+ {
+ $values[] = "$key = NULL";
+ }
+ elseif (is_string($var))
+ {
+ $values[] = "$key = '" . $this->sql_escape($var) . "'";
+ }
+ else
+ {
+ $values[] = (is_bool($var)) ? "$key = " . intval($var) : "$key = $var";
+ }
+ }
+ $query = implode(($query == 'UPDATE') ? ', ' : ' AND ', $values);
+ }
+
+ return $query;
+ }
+
+ function sql_error($sql = '')
+ {
+ $error = $this->db_sql_error();
+
+ if (!$this->return_on_error)
+ {
+ $this_page = (isset($_SERVER['PHP_SELF']) && !empty($_SERVER['PHP_SELF'])) ? $_SERVER['PHP_SELF'] : $_ENV['PHP_SELF'];
+ $this_page .= '&' . ((isset($_SERVER['QUERY_STRING']) && !empty($_SERVER['QUERY_STRING'])) ? $_SERVER['QUERY_STRING'] : (isset($_ENV['QUERY_STRING']) ? $_ENV['QUERY_STRING'] : ''));
+
+ $message = '<u>SQL ERROR</u> [ ' . SQL_LAYER . ' ]<br /><br />' . $error['message'] . ' [' . $error['code'] . ']<br /><br /><u>CALLING PAGE</u><br /><br />' . htmlspecialchars($this_page) . (($sql != '') ? '<br /><br /><u>SQL</u><br /><br />' . $sql : '') . '<br />';
+
+ if ($this->transaction)
+ {
+ $this->sql_transaction('rollback');
+ }
+
+ trigger_error($message, E_USER_ERROR);
+ }
+
+ return $error;
+ }
+
+ function sql_report($mode, $query = '')
+ {
+ if (empty($_GET['explain']))
+ {
+ return;
+ }
+
+ global $cache, $starttime, $phpbb_root_path;
+ static $curtime, $query_hold, $html_hold;
+ static $sql_report = '';
+ static $cache_num_queries = 0;
+
+ if (!$query && !empty($query_hold))
+ {
+ $query = $query_hold;
+ }
+
+ switch ($mode)
+ {
+ case 'display':
+ if (!empty($cache))
+ {
+ $cache->unload();
+ }
+ $this->sql_close();
+
+ $mtime = explode(' ', microtime());
+ $totaltime = $mtime[0] + $mtime[1] - $starttime;
+
+ echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8869-1"><meta http-equiv="Content-Style-Type" content="text/css"><link rel="stylesheet" href="' . $phpbb_root_path . 'adm/subSilver.css" type="text/css"><style type="text/css">' . "\n";
+ echo 'th { background-image: url(\'' . $phpbb_root_path . 'adm/images/cellpic3.gif\') }' . "\n";
+ echo 'td.cat { background-image: url(\'' . $phpbb_root_path . 'adm/images/cellpic1.gif\') }' . "\n";
+ echo '</style><title>' . $msg_title . '</title></head><body>';
+ echo '<table width="100%" cellspacing="0" cellpadding="0" border="0"><tr><td><a href="' . htmlspecialchars(preg_replace('/&explain=([^&]*)/', '', $_SERVER['REQUEST_URI'])) . '"><img src="' . $phpbb_root_path . 'adm/images/header_left.jpg" width="200" height="60" alt="phpBB Logo" title="phpBB Logo" border="0"/></a></td><td width="100%" background="' . $phpbb_root_path . 'adm/images/header_bg.jpg" height="60" align="right" nowrap="nowrap"><span class="maintitle">SQL Report</span> &nbsp; &nbsp; &nbsp;</td></tr></table><br clear="all"/><table width="95%" cellspacing="1" cellpadding="4" border="0" align="center"><tr><td height="40" align="center" valign="middle"><b>Page generated in ' . round($totaltime, 4) . " seconds with {$this->num_queries} queries" . (($cache_num_queries) ? " + $cache_num_queries " . (($cache_num_queries == 1) ? 'query' : 'queries') . ' returning data from cache' : '') . '</b></td></tr><tr><td align="center" nowrap="nowrap">Time spent on MySQL queries: <b>' . round($this->sql_time, 5) . 's</b> | Time spent on PHP: <b>' . round($totaltime - $this->sql_time, 5) . 's</b></td></tr></table><table width="95%" cellspacing="1" cellpadding="4" border="0" align="center"><tr><td>';
+ echo $sql_report;
+ echo '</td></tr></table><br /></body></html>';
+ exit;
+ break;
+
+ case 'stop':
+ $endtime = explode(' ', microtime());
+ $endtime = $endtime[0] + $endtime[1];
+
+ $sql_report .= '<hr width="100%"/><br /><table class="bg" width="100%" cellspacing="1" cellpadding="4" border="0"><tr><th>Query #' . $this->num_queries . '</th></tr><tr><td class="row1"><textarea style="font-family:\'Courier New\',monospace;width:100%" rows="5">' . preg_replace('/\t(AND|OR)(\W)/', "\$1\$2", htmlspecialchars(preg_replace('/[\s]*[\n\r\t]+[\n\r\s\t]*/', "\n", $query))) . '</textarea></td></tr></table> ' . $html_hold . '<p align="center">';
+
+ if ($this->query_result)
+ {
+ if (preg_match('/^(UPDATE|DELETE|REPLACE)/', $query))
+ {
+ $sql_report .= "Affected rows: <b>" . $this->sql_affectedrows($this->query_result) . '</b> | ';
+ }
+ $sql_report .= 'Before: ' . sprintf('%.5f', $curtime - $starttime) . 's | After: ' . sprintf('%.5f', $endtime - $starttime) . 's | Elapsed: <b>' . sprintf('%.5f', $endtime - $curtime) . 's</b>';
+ }
+ else
+ {
+ $error = $this->sql_error();
+ $sql_report .= '<b style="color: red">FAILED</b> - ' . SQL_LAYER . ' Error ' . $error['code'] . ': ' . htmlspecialchars($error['message']);
+ }
+
+ $sql_report .= '</p>';
+
+ $this->sql_time += $endtime - $curtime;
+ break;
+
+ default:
+
+ $this->_sql_report($mode, $query);
+
+ break;
+ }
+ }
+}
+
+if (!defined('IN_PHPBB'))
+{
+ exit;
+}
+
+/**
+* This variable holds the class name to use later
+*/
+$sql_db = 'dbal_' . $dbms;
+
+?> \ No newline at end of file
diff --git a/phpBB/includes/db/firebird.php b/phpBB/includes/db/firebird.php
index a785c7c8b7..797772e5e3 100644
--- a/phpBB/includes/db/firebird.php
+++ b/phpBB/includes/db/firebird.php
@@ -1,7 +1,7 @@
<?php
/**
*
-* @package dbal_firebird
+* @package dbal
* @version $Id$
* @copyright (c) 2005 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
@@ -14,23 +14,16 @@
if (!defined('SQL_LAYER'))
{
-define('SQL_LAYER', 'firebird');
+ define('SQL_LAYER', 'firebird');
+ include($phpbb_root_path . 'includes/db/dbal.' . $phpEx);
/**
-* @package dbal_firebird
+* @package dbal
* Firebird/Interbase Database Abstraction Layer
* Minimum Requirement is Firebird 1.5+/Interbase 7.1+
*/
-class sql_db
+class dbal_firebird extends dbal
{
- var $db_connect_id;
- var $query_result;
- var $return_on_error = false;
- var $transaction = false;
- var $sql_time = 0;
- var $num_queries = 0;
- var $open_queries = array();
-
var $last_query_text = '';
function sql_connect($sqlserver, $sqluser, $sqlpassword, $database, $port = false, $persistency = false)
@@ -71,16 +64,6 @@ class sql_db
return @ibase_close($this->db_connect_id);
}
- function sql_return_on_error($fail = false)
- {
- $this->return_on_error = $fail;
- }
-
- function sql_num_queries()
- {
- return $this->num_queries;
- }
-
function sql_transaction($status = 'begin')
{
switch ($status)
@@ -166,62 +149,6 @@ class sql_db
}
}
- // Idea for this from Ikonboard
- function sql_build_array($query, $assoc_ary = false)
- {
- if (!is_array($assoc_ary))
- {
- return false;
- }
-
- $fields = array();
- $values = array();
- if ($query == 'INSERT')
- {
- foreach ($assoc_ary as $key => $var)
- {
- $fields[] = $key;
-
- if (is_null($var))
- {
- $values[] = 'NULL';
- }
- elseif (is_string($var))
- {
- $values[] = "'" . $this->sql_escape($var) . "'";
- }
- else
- {
- $values[] = (is_bool($var)) ? intval($var) : $var;
- }
- }
-
- $query = ' (' . implode(', ', $fields) . ') VALUES (' . implode(', ', $values) . ')';
- }
- else if ($query == 'UPDATE' || $query == 'SELECT')
- {
- $values = array();
- foreach ($assoc_ary as $key => $var)
- {
- if (is_null($var))
- {
- $values[] = "$key = NULL";
- }
- elseif (is_string($var))
- {
- $values[] = "$key = '" . $this->sql_escape($var) . "'";
- }
- else
- {
- $values[] = (is_bool($var)) ? "$key = " . intval($var) : "$key = $var";
- }
- }
- $query = implode(($query == 'UPDATE') ? ', ' : ' AND ', $values);
- }
-
- return $query;
- }
-
// Other query methods
//
// NOTE :: Want to remove _ALL_ reliance on sql_numrows from core code ...
@@ -233,7 +160,7 @@ class sql_db
function sql_affectedrows()
{
- // TODO: hmm, maybe doing something similar as in mssql-odbc.php?
+ // TODO: hmm, maybe doing something similar as in mssql_odbc.php?
return ($this->query_result) ? true : false;
}
@@ -315,7 +242,7 @@ class sql_db
{
if (empty($this->row[$query_id]) && empty($this->rowset[$query_id]))
{
- if ($this->sql_fetchrow($query_id))
+ if ($this->row[$query_id] = $this->sql_fetchrow($query_id))
{
$result = $this->row[$query_id][$field];
}
@@ -397,68 +324,23 @@ class sql_db
return (@ini_get('magic_quotes_sybase') || strtolower(@ini_get('magic_quotes_sybase')) == 'on') ? str_replace('\\\'', '\'', addslashes($msg)) : str_replace('\'', '\'\'', stripslashes($msg));
}
- function sql_error($sql = '')
+ function db_sql_error()
{
- if (!$this->return_on_error)
- {
- $this_page =(!empty($_SERVER['PHP_SELF'])) ? $_SERVER['PHP_SELF'] : $_ENV['PHP_SELF'];
- $this_page .= '&' .((!empty($_SERVER['QUERY_STRING'])) ? $_SERVER['QUERY_STRING'] : $_ENV['QUERY_STRING']);
-
- $message = '<u>SQL ERROR</u> [ ' . SQL_LAYER . ' ]<br /><br />' . @ibase_errmsg() . '<br /><br /><u>CALLING PAGE</u><br /><br />' . $this_page .(($sql != '') ? '<br /><br /><u>SQL</u><br /><br />' . $sql : '') . '<br />';
-
- if ($this->transaction)
- {
- $this->sql_transaction('rollback');
- }
-
- trigger_error($message, E_USER_ERROR);
- }
-
- $result['message'] = @ibase_errmsg();
- $result['code'] = '';
-
- return $result;
+ return array(
+ 'message' => @ibase_errmsg(),
+ 'code' => ''
+ );
}
- function sql_report($mode, $query = '')
+ function _sql_report($mode, $query = '')
{
- if (empty($_GET['explain']))
- {
- return;
- }
-
global $cache, $starttime, $phpbb_root_path;
static $curtime, $query_hold, $html_hold;
static $sql_report = '';
static $cache_num_queries = 0;
- if (!$query && !empty($query_hold))
- {
- $query = $query_hold;
- }
-
switch ($mode)
{
- case 'display':
- if (!empty($cache))
- {
- $cache->unload();
- }
- $this->sql_close();
-
- $mtime = explode(' ', microtime());
- $totaltime = $mtime[0] + $mtime[1] - $starttime;
-
- echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8869-1"><meta http-equiv="Content-Style-Type" content="text/css"><link rel="stylesheet" href="' . $phpbb_root_path . 'adm/subSilver.css" type="text/css"><style type="text/css">' . "\n";
- echo 'th { background-image: url(\'' . $phpbb_root_path . 'adm/images/cellpic3.gif\') }' . "\n";
- echo 'td.cat { background-image: url(\'' . $phpbb_root_path . 'adm/images/cellpic1.gif\') }' . "\n";
- echo '</style><title>' . $msg_title . '</title></head><body>';
- echo '<table width="100%" cellspacing="0" cellpadding="0" border="0"><tr><td><a href="' . htmlspecialchars(preg_replace('/&explain=([^&]*)/', '', $_SERVER['REQUEST_URI'])) . '"><img src="' . $phpbb_root_path . 'adm/images/header_left.jpg" width="200" height="60" alt="phpBB Logo" title="phpBB Logo" border="0"/></a></td><td width="100%" background="' . $phpbb_root_path . 'adm/images/header_bg.jpg" height="60" align="right" nowrap="nowrap"><span class="maintitle">SQL Report</span> &nbsp; &nbsp; &nbsp;</td></tr></table><br clear="all"/><table width="95%" cellspacing="1" cellpadding="4" border="0" align="center"><tr><td height="40" align="center" valign="middle"><b>Page generated in ' . round($totaltime, 4) . " seconds with {$this->num_queries} queries" . (($cache_num_queries) ? " + $cache_num_queries " . (($cache_num_queries == 1) ? 'query' : 'queries') . ' returning data from cache' : '') . '</b></td></tr><tr><td align="center" nowrap="nowrap">Time spent on MySQL queries: <b>' . round($this->sql_time, 5) . 's</b> | Time spent on PHP: <b>' . round($totaltime - $this->sql_time, 5) . 's</b></td></tr></table><table width="95%" cellspacing="1" cellpadding="4" border="0" align="center"><tr><td>';
- echo $sql_report;
- echo '</td></tr></table><br /></body></html>';
- exit;
- break;
-
case 'start':
$query_hold = $query;
$html_hold = '';
@@ -493,35 +375,10 @@ class sql_db
@ibase_freeresult($result);
$cache_num_queries++;
break;
-
- case 'stop':
- $endtime = explode(' ', microtime());
- $endtime = $endtime[0] + $endtime[1];
-
- $sql_report .= '<hr width="100%"/><br /><table class="bg" width="100%" cellspacing="1" cellpadding="4" border="0"><tr><th>Query #' . $this->num_queries . '</th></tr><tr><td class="row1"><textarea style="font-family:\'Courier New\',monospace;width:100%" rows="5">' . preg_replace('/\t(AND|OR)(\W)/', "\$1\$2", htmlspecialchars(preg_replace('/[\s]*[\n\r\t]+[\n\r\s\t]*/', "\n", $query))) . '</textarea></td></tr></table> ' . $html_hold . '<p align="center">';
-
- if ($this->query_result)
- {
- if (preg_match('/^(UPDATE|DELETE|REPLACE)/', $query))
- {
- $sql_report .= "Affected rows: <b>" . $this->sql_affectedrows($this->query_result) . '</b> | ';
- }
- $sql_report .= 'Before: ' . sprintf('%.5f', $curtime - $starttime) . 's | After: ' . sprintf('%.5f', $endtime - $starttime) . 's | Elapsed: <b>' . sprintf('%.5f', $endtime - $curtime) . 's</b>';
- }
- else
- {
- $error = $this->sql_error();
- $sql_report .= '<b style="color: red">FAILED</b> - ' . SQL_LAYER . ' Error ' . $error['code'] . ': ' . htmlspecialchars($error['message']);
- }
-
- $sql_report .= '</p>';
-
- $this->sql_time += $endtime - $curtime;
- break;
}
}
-} // class sql_db
+}
} // if ... define
diff --git a/phpBB/includes/db/mssql.php b/phpBB/includes/db/mssql.php
index c13f2f2162..cb6b5123c0 100644
--- a/phpBB/includes/db/mssql.php
+++ b/phpBB/includes/db/mssql.php
@@ -1,7 +1,7 @@
<?php
/**
*
-* @package dbal_mssql
+* @package dbal
* @version $Id$
* @copyright (c) 2005 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
@@ -14,22 +14,16 @@
if (!defined('SQL_LAYER'))
{
-define('SQL_LAYER', 'mssql');
+ define('SQL_LAYER', 'mssql');
+ include($phpbb_root_path . 'includes/db/dbal.' . $phpEx);
/**
-* @package dbal_mssql
+* @package dbal
* MSSQL Database Abstraction Layer
* Minimum Requirement is MSSQL 2000+
*/
-class sql_db
+class dbal_mssql extends dbal
{
- var $db_connect_id;
- var $query_result;
- var $return_on_error = false;
- var $transaction = false;
- var $sql_time = 0;
- var $num_queries = 0;
- var $open_queries = array();
function sql_connect($sqlserver, $sqluser, $sqlpassword, $database, $port = false, $persistency = false)
{
@@ -75,16 +69,6 @@ class sql_db
return @mssql_close($this->db_connect_id);
}
- function sql_return_on_error($fail = false)
- {
- $this->return_on_error = $fail;
- }
-
- function sql_num_queries()
- {
- return $this->num_queries;
- }
-
function sql_transaction($status = 'begin')
{
switch ($status)
@@ -194,62 +178,6 @@ class sql_db
}
}
- // Idea for this from Ikonboard
- function sql_build_array($query, $assoc_ary = false)
- {
- if (!is_array($assoc_ary))
- {
- return false;
- }
-
- $fields = array();
- $values = array();
- if ($query == 'INSERT')
- {
- foreach ($assoc_ary as $key => $var)
- {
- $fields[] = $key;
-
- if (is_null($var))
- {
- $values[] = 'NULL';
- }
- elseif (is_string($var))
- {
- $values[] = "'" . $this->sql_escape($var) . "'";
- }
- else
- {
- $values[] = (is_bool($var)) ? intval($var) : $var;
- }
- }
-
- $query = ' (' . implode(', ', $fields) . ') VALUES (' . implode(', ', $values) . ')';
- }
- else if ($query == 'UPDATE' || $query == 'SELECT')
- {
- $values = array();
- foreach ($assoc_ary as $key => $var)
- {
- if (is_null($var))
- {
- $values[] = "$key = NULL";
- }
- elseif (is_string($var))
- {
- $values[] = "$key = '" . $this->sql_escape($var) . "'";
- }
- else
- {
- $values[] = (is_bool($var)) ? "$key = " . intval($var) : "$key = $var";
- }
- }
- $query = implode(($query == 'UPDATE') ? ', ' : ' AND ', $values);
- }
-
- return $query;
- }
-
// Other query methods
//
// NOTE :: Want to remove _ALL_ reliance on sql_numrows from core code ...
@@ -340,7 +268,7 @@ class sql_db
{
if (empty($this->row[$query_id]) && empty($this->rowset[$query_id]))
{
- if ($this->sql_fetchrow($query_id))
+ if ($this->row[$query_id] = $this->sql_fetchrow($query_id))
{
$result = $this->row[$query_id][$field];
}
@@ -418,70 +346,23 @@ class sql_db
return str_replace("'", "''", str_replace('\\', '\\\\', $msg));
}
- function sql_error($sql = '')
+ function db_sql_error()
{
- if (!$this->return_on_error)
- {
- $this_page = (isset($_SERVER['PHP_SELF']) && !empty($_SERVER['PHP_SELF'])) ? $_SERVER['PHP_SELF'] : $_ENV['PHP_SELF'];
- $this_page .= '&' . ((isset($_SERVER['QUERY_STRING']) && !empty($_SERVER['QUERY_STRING'])) ? $_SERVER['QUERY_STRING'] : (isset($_ENV['QUERY_STRING']) ? $_ENV['QUERY_STRING'] : ''));
-
- $message = '<u>SQL ERROR</u> [ ' . SQL_LAYER . ' ]<br /><br />' . @mssql_get_last_message() . '<br /><br /><u>CALLING PAGE</u><br /><br />' . htmlspecialchars($this_page) . (($sql != '') ? '<br /><br /><u>SQL</u><br /><br />' . $sql : '') . '<br />';
-
- if ($this->transaction)
- {
- $this->sql_transaction('rollback');
- }
-
- trigger_error($message, E_USER_ERROR);
- }
-
- $result = array(
+ return array(
'message' => @mssql_get_last_message($this->db_connect_id),
'code' => ''
);
-
- return $result;
}
- function sql_report($mode, $query = '')
+ function _sql_report($mode, $query = '')
{
- if (empty($_GET['explain']))
- {
- return;
- }
-
global $cache, $starttime, $phpbb_root_path;
static $curtime, $query_hold, $html_hold;
static $sql_report = '';
static $cache_num_queries = 0;
- if (!$query && !empty($query_hold))
- {
- $query = $query_hold;
- }
-
switch ($mode)
{
- case 'display':
- if (!empty($cache))
- {
- $cache->unload();
- }
- $this->sql_close();
-
- $mtime = explode(' ', microtime());
- $totaltime = $mtime[0] + $mtime[1] - $starttime;
-
- echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8869-1"><meta http-equiv="Content-Style-Type" content="text/css"><link rel="stylesheet" href="' . $phpbb_root_path . 'adm/subSilver.css" type="text/css"><style type="text/css">' . "\n";
- echo 'th { background-image: url(\'' . $phpbb_root_path . 'adm/images/cellpic3.gif\') }' . "\n";
- echo 'td.cat { background-image: url(\'' . $phpbb_root_path . 'adm/images/cellpic1.gif\') }' . "\n";
- echo '</style><title>' . $msg_title . '</title></head><body>';
- echo '<table width="100%" cellspacing="0" cellpadding="0" border="0"><tr><td><a href="' . htmlspecialchars(preg_replace('/&explain=([^&]*)/', '', $_SERVER['REQUEST_URI'])) . '"><img src="' . $phpbb_root_path . 'adm/images/header_left.jpg" width="200" height="60" alt="phpBB Logo" title="phpBB Logo" border="0"/></a></td><td width="100%" background="' . $phpbb_root_path . 'adm/images/header_bg.jpg" height="60" align="right" nowrap="nowrap"><span class="maintitle">SQL Report</span> &nbsp; &nbsp; &nbsp;</td></tr></table><br clear="all"/><table width="95%" cellspacing="1" cellpadding="4" border="0" align="center"><tr><td height="40" align="center" valign="middle"><b>Page generated in ' . round($totaltime, 4) . " seconds with {$this->num_queries} queries" . (($cache_num_queries) ? " + $cache_num_queries " . (($cache_num_queries == 1) ? 'query' : 'queries') . ' returning data from cache' : '') . '</b></td></tr><tr><td align="center" nowrap="nowrap">Time spent on MySQL queries: <b>' . round($this->sql_time, 5) . 's</b> | Time spent on PHP: <b>' . round($totaltime - $this->sql_time, 5) . 's</b></td></tr></table><table width="95%" cellspacing="1" cellpadding="4" border="0" align="center"><tr><td>';
- echo $sql_report;
- echo '</td></tr></table><br /></body></html>';
- exit;
- break;
-
case 'start':
$query_hold = $query;
$html_hold = '';
@@ -516,35 +397,10 @@ class sql_db
@mssql_free_result($result);
$cache_num_queries++;
break;
-
- case 'stop':
- $endtime = explode(' ', microtime());
- $endtime = $endtime[0] + $endtime[1];
-
- $sql_report .= '<hr width="100%"/><br /><table class="bg" width="100%" cellspacing="1" cellpadding="4" border="0"><tr><th>Query #' . $this->num_queries . '</th></tr><tr><td class="row1"><textarea style="font-family:\'Courier New\',monospace;width:100%" rows="5">' . preg_replace('/\t(AND|OR)(\W)/', "\$1\$2", htmlspecialchars(preg_replace('/[\s]*[\n\r\t]+[\n\r\s\t]*/', "\n", $query))) . '</textarea></td></tr></table> ' . $html_hold . '<p align="center">';
-
- if ($this->query_result)
- {
- if (preg_match('/^(UPDATE|DELETE|REPLACE)/', $query))
- {
- $sql_report .= "Affected rows: <b>" . $this->sql_affectedrows($this->query_result) . '</b> | ';
- }
- $sql_report .= 'Before: ' . sprintf('%.5f', $curtime - $starttime) . 's | After: ' . sprintf('%.5f', $endtime - $starttime) . 's | Elapsed: <b>' . sprintf('%.5f', $endtime - $curtime) . 's</b>';
- }
- else
- {
- $error = $this->sql_error();
- $sql_report .= '<b style="color: red">FAILED</b> - ' . SQL_LAYER . ' Error ' . $error['code'] . ': ' . htmlspecialchars($error['message']);
- }
-
- $sql_report .= '</p>';
-
- $this->sql_time += $endtime - $curtime;
- break;
}
}
-} // class sql_db
+}
} // if ... define
diff --git a/phpBB/includes/db/mysql.php b/phpBB/includes/db/mysql.php
index b12480e9f9..caf4300421 100644
--- a/phpBB/includes/db/mysql.php
+++ b/phpBB/includes/db/mysql.php
@@ -1,7 +1,7 @@
<?php
/**
*
-* @package dbal_mysql
+* @package dbal
* @version $Id$
* @copyright (c) 2005 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
@@ -14,22 +14,16 @@
if (!defined('SQL_LAYER'))
{
-define('SQL_LAYER', 'mysql');
+ define('SQL_LAYER', 'mysql');
+ include($phpbb_root_path . 'includes/db/dbal.' . $phpEx);
/**
-* @package dbal_mysql
+* @package dbal
* MySQL Database Abstraction Layer
* Minimum Requirement is 3.23+/4.0+/4.1+
*/
-class sql_db
+class dbal_mysql extends dbal
{
- var $db_connect_id;
- var $query_result;
- var $return_on_error = false;
- var $transaction = false;
- var $sql_time = 0;
- var $num_queries = 0;
- var $open_queries = array();
function sql_connect($sqlserver, $sqluser, $sqlpassword, $database, $port = false, $persistency = false)
{
@@ -72,16 +66,6 @@ class sql_db
return @mysql_close($this->db_connect_id);
}
- function sql_return_on_error($fail = false)
- {
- $this->return_on_error = $fail;
- }
-
- function sql_num_queries()
- {
- return $this->num_queries;
- }
-
function sql_transaction($status = 'begin')
{
switch ($status)
@@ -188,62 +172,6 @@ class sql_db
}
}
- // Idea for this from Ikonboard
- function sql_build_array($query, $assoc_ary = false)
- {
- if (!is_array($assoc_ary))
- {
- return false;
- }
-
- $fields = array();
- $values = array();
- if ($query == 'INSERT')
- {
- foreach ($assoc_ary as $key => $var)
- {
- $fields[] = $key;
-
- if (is_null($var))
- {
- $values[] = 'NULL';
- }
- elseif (is_string($var))
- {
- $values[] = "'" . $this->sql_escape($var) . "'";
- }
- else
- {
- $values[] = (is_bool($var)) ? intval($var) : $var;
- }
- }
-
- $query = ' (' . implode(', ', $fields) . ') VALUES (' . implode(', ', $values) . ')';
- }
- else if ($query == 'UPDATE' || $query == 'SELECT')
- {
- $values = array();
- foreach ($assoc_ary as $key => $var)
- {
- if (is_null($var))
- {
- $values[] = "$key = NULL";
- }
- elseif (is_string($var))
- {
- $values[] = "$key = '" . $this->sql_escape($var) . "'";
- }
- else
- {
- $values[] = (is_bool($var)) ? "$key = " . intval($var) : "$key = $var";
- }
- }
- $query = implode(($query == 'UPDATE') ? ', ' : ' AND ', $values);
- }
-
- return $query;
- }
-
// Other query methods
//
// NOTE :: Want to remove _ALL_ reliance on sql_numrows from core code ...
@@ -320,7 +248,7 @@ class sql_db
{
if (empty($this->row[$query_id]) && empty($this->rowset[$query_id]))
{
- if ($this->sql_fetchrow($query_id))
+ if ($this->row[$query_id] = $this->sql_fetchrow($query_id))
{
$result = $this->row[$query_id][$field];
}
@@ -380,70 +308,23 @@ class sql_db
return mysql_escape_string($msg);
}
- function sql_error($sql = '')
+ function db_sql_error()
{
- if (!$this->return_on_error)
- {
- $this_page = (isset($_SERVER['PHP_SELF']) && !empty($_SERVER['PHP_SELF'])) ? $_SERVER['PHP_SELF'] : $_ENV['PHP_SELF'];
- $this_page .= '&' . ((isset($_SERVER['QUERY_STRING']) && !empty($_SERVER['QUERY_STRING'])) ? $_SERVER['QUERY_STRING'] : (isset($_ENV['QUERY_STRING']) ? $_ENV['QUERY_STRING'] : ''));
-
- $message = '<u>SQL ERROR</u> [ ' . SQL_LAYER . ' ]<br /><br />' . @mysql_error() . '<br /><br /><u>CALLING PAGE</u><br /><br />' . htmlspecialchars($this_page) . (($sql != '') ? '<br /><br /><u>SQL</u><br /><br />' . $sql : '') . '<br />';
-
- if ($this->transaction)
- {
- $this->sql_transaction('rollback');
- }
-
- trigger_error($message, E_USER_ERROR);
- }
-
- $result = array(
+ return array(
'message' => @mysql_error(),
'code' => @mysql_errno()
);
-
- return $result;
}
- function sql_report($mode, $query = '')
+ function _sql_report($mode, $query = '')
{
- if (empty($_GET['explain']))
- {
- return;
- }
-
- global $db, $cache, $starttime, $phpbb_root_path;
+ global $cache, $starttime, $phpbb_root_path;
static $curtime, $query_hold, $html_hold;
static $sql_report = '';
static $cache_num_queries = 0;
- if (!$query && !empty($query_hold))
- {
- $query = $query_hold;
- }
-
switch ($mode)
{
- case 'display':
- if (!empty($cache))
- {
- $cache->unload();
- }
- $db->sql_close();
-
- $mtime = explode(' ', microtime());
- $totaltime = $mtime[0] + $mtime[1] - $starttime;
-
- echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8869-1"><meta http-equiv="Content-Style-Type" content="text/css"><link rel="stylesheet" href="' . $phpbb_root_path . 'adm/subSilver.css" type="text/css"><style type="text/css">' . "\n";
- echo 'th { background-image: url(\'' . $phpbb_root_path . 'adm/images/cellpic3.gif\') }' . "\n";
- echo 'td.cat { background-image: url(\'' . $phpbb_root_path . 'adm/images/cellpic1.gif\') }' . "\n";
- echo '</style><title>' . $msg_title . '</title></head><body>';
- echo '<table width="100%" cellspacing="0" cellpadding="0" border="0"><tr><td><a href="' . htmlspecialchars(preg_replace('/&explain=([^&]*)/', '', $_SERVER['REQUEST_URI'])) . '"><img src="' . $phpbb_root_path . 'adm/images/header_left.jpg" width="200" height="60" alt="phpBB Logo" title="phpBB Logo" border="0"/></a></td><td width="100%" background="' . $phpbb_root_path . 'adm/images/header_bg.jpg" height="60" align="right" nowrap="nowrap"><span class="maintitle">SQL Report</span> &nbsp; &nbsp; &nbsp;</td></tr></table><br clear="all"/><table width="95%" cellspacing="1" cellpadding="4" border="0" align="center"><tr><td height="40" align="center" valign="middle"><b>Page generated in ' . round($totaltime, 4) . " seconds with {$this->num_queries} queries" . (($cache_num_queries) ? " + $cache_num_queries " . (($cache_num_queries == 1) ? 'query' : 'queries') . ' returning data from cache' : '') . '</b></td></tr><tr><td align="center" nowrap="nowrap">Time spent on MySQL queries: <b>' . round($this->sql_time, 5) . 's</b> | Time spent on PHP: <b>' . round($totaltime - $this->sql_time, 5) . 's</b></td></tr></table><table width="95%" cellspacing="1" cellpadding="4" border="0" align="center"><tr><td>';
- echo $sql_report;
- echo '</td></tr></table><br /></body></html>';
- exit;
- break;
-
case 'start':
$query_hold = $query;
$html_hold = '';
@@ -525,34 +406,9 @@ class sql_db
mysql_free_result($result);
$cache_num_queries++;
break;
-
- case 'stop':
- $endtime = explode(' ', microtime());
- $endtime = $endtime[0] + $endtime[1];
-
- $sql_report .= '<hr width="100%"/><br /><table class="bg" width="100%" cellspacing="1" cellpadding="4" border="0"><tr><th>Query #' . $this->num_queries . '</th></tr><tr><td class="row1"><textarea style="font-family:\'Courier New\',monospace;width:100%" rows="5">' . preg_replace('/\t(AND|OR)(\W)/', "\$1\$2", htmlspecialchars(preg_replace('/[\s]*[\n\r\t]+[\n\r\s\t]*/', "\n", $query))) . '</textarea></td></tr></table> ' . $html_hold . '<p align="center">';
-
- if ($this->query_result)
- {
- if (preg_match('/^(UPDATE|DELETE|REPLACE)/', $query))
- {
- $sql_report .= "Affected rows: <b>" . $this->sql_affectedrows($this->query_result) . '</b> | ';
- }
- $sql_report .= 'Before: ' . sprintf('%.5f', $curtime - $starttime) . 's | After: ' . sprintf('%.5f', $endtime - $starttime) . 's | Elapsed: <b>' . sprintf('%.5f', $endtime - $curtime) . 's</b>';
- }
- else
- {
- $error = $this->sql_error();
- $sql_report .= '<b style="color: red">FAILED</b> - MySQL Error ' . $error['code'] . ': ' . htmlspecialchars($error['message']);
- }
-
- $sql_report .= '</p>';
-
- $this->sql_time += $endtime - $curtime;
- break;
}
}
-} // class sql_db
+}
} // if ... define
diff --git a/phpBB/includes/db/mysql4.php b/phpBB/includes/db/mysql4.php
index b411b91a7a..df176db329 100644
--- a/phpBB/includes/db/mysql4.php
+++ b/phpBB/includes/db/mysql4.php
@@ -1,7 +1,7 @@
<?php
/**
*
-* @package dbal_mysql4
+* @package dbal
* @version $Id$
* @copyright (c) 2005 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
@@ -14,22 +14,16 @@
if (!defined('SQL_LAYER'))
{
-define('SQL_LAYER', 'mysql4');
+ define('SQL_LAYER', 'mysql4');
+ include($phpbb_root_path . 'includes/db/dbal.' . $phpEx);
/**
-* @package dbal_mysql4
+* @package dbal
* MySQL4 Database Abstraction Layer
* Minimum Requirement is 4.0+/4.1+
*/
-class sql_db
+class dbal_mysql4 extends dbal
{
- var $db_connect_id;
- var $query_result;
- var $return_on_error = false;
- var $transaction = false;
- var $sql_time = 0;
- var $num_queries = 0;
- var $open_queries = array();
function sql_connect($sqlserver, $sqluser, $sqlpassword, $database, $port = false, $persistency = false)
{
@@ -72,16 +66,6 @@ class sql_db
return @mysql_close($this->db_connect_id);
}
- function sql_return_on_error($fail = false)
- {
- $this->return_on_error = $fail;
- }
-
- function sql_num_queries()
- {
- return $this->num_queries;
- }
-
function sql_transaction($status = 'begin')
{
switch ($status)
@@ -188,62 +172,6 @@ class sql_db
}
}
- // Idea for this from Ikonboard
- function sql_build_array($query, $assoc_ary = false)
- {
- if (!is_array($assoc_ary))
- {
- return false;
- }
-
- $fields = array();
- $values = array();
- if ($query == 'INSERT')
- {
- foreach ($assoc_ary as $key => $var)
- {
- $fields[] = $key;
-
- if (is_null($var))
- {
- $values[] = 'NULL';
- }
- elseif (is_string($var))
- {
- $values[] = "'" . $this->sql_escape($var) . "'";
- }
- else
- {
- $values[] = (is_bool($var)) ? intval($var) : $var;
- }
- }
-
- $query = ' (' . implode(', ', $fields) . ') VALUES (' . implode(', ', $values) . ')';
- }
- else if ($query == 'UPDATE' || $query == 'SELECT')
- {
- $values = array();
- foreach ($assoc_ary as $key => $var)
- {
- if (is_null($var))
- {
- $values[] = "$key = NULL";
- }
- elseif (is_string($var))
- {
- $values[] = "$key = '" . $this->sql_escape($var) . "'";
- }
- else
- {
- $values[] = (is_bool($var)) ? "$key = " . intval($var) : "$key = $var";
- }
- }
- $query = implode(($query == 'UPDATE') ? ', ' : ' AND ', $values);
- }
-
- return $query;
- }
-
// Other query methods
//
// NOTE :: Want to remove _ALL_ reliance on sql_numrows from core code ...
@@ -320,7 +248,7 @@ class sql_db
{
if (empty($this->row[$query_id]) && empty($this->rowset[$query_id]))
{
- if ($this->sql_fetchrow($query_id))
+ if ($this->row[$query_id] = $this->sql_fetchrow($query_id))
{
$result = $this->row[$query_id][$field];
}
@@ -380,70 +308,23 @@ class sql_db
return mysql_escape_string($msg);
}
- function sql_error($sql = '')
+ function db_sql_error()
{
- if (!$this->return_on_error)
- {
- $this_page = (isset($_SERVER['PHP_SELF']) && !empty($_SERVER['PHP_SELF'])) ? $_SERVER['PHP_SELF'] : $_ENV['PHP_SELF'];
- $this_page .= '&' . ((isset($_SERVER['QUERY_STRING']) && !empty($_SERVER['QUERY_STRING'])) ? $_SERVER['QUERY_STRING'] : (isset($_ENV['QUERY_STRING']) ? $_ENV['QUERY_STRING'] : ''));
-
- $message = '<u>SQL ERROR</u> [ ' . SQL_LAYER . ' ]<br /><br />' . @mysql_error() . '<br /><br /><u>CALLING PAGE</u><br /><br />' . htmlspecialchars($this_page) . (($sql != '') ? '<br /><br /><u>SQL</u><br /><br />' . $sql : '') . '<br />';
-
- if ($this->transaction)
- {
- $this->sql_transaction('rollback');
- }
-
- trigger_error($message, E_USER_ERROR);
- }
-
- $result = array(
+ return array(
'message' => @mysql_error(),
'code' => @mysql_errno()
);
-
- return $result;
}
- function sql_report($mode, $query = '')
+ function _sql_report($mode, $query = '')
{
- if (empty($_GET['explain']))
- {
- return;
- }
-
- global $db, $cache, $starttime, $phpbb_root_path;
+ global $cache, $starttime, $phpbb_root_path;
static $curtime, $query_hold, $html_hold;
static $sql_report = '';
static $cache_num_queries = 0;
- if (!$query && !empty($query_hold))
- {
- $query = $query_hold;
- }
-
switch ($mode)
{
- case 'display':
- if (!empty($cache))
- {
- $cache->unload();
- }
- $db->sql_close();
-
- $mtime = explode(' ', microtime());
- $totaltime = $mtime[0] + $mtime[1] - $starttime;
-
- echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8869-1"><meta http-equiv="Content-Style-Type" content="text/css"><link rel="stylesheet" href="' . $phpbb_root_path . 'adm/subSilver.css" type="text/css"><style type="text/css">' . "\n";
- echo 'th { background-image: url(\'' . $phpbb_root_path . 'adm/images/cellpic3.gif\') }' . "\n";
- echo 'td.cat { background-image: url(\'' . $phpbb_root_path . 'adm/images/cellpic1.gif\') }' . "\n";
- echo '</style><title>' . $msg_title . '</title></head><body>';
- echo '<table width="100%" cellspacing="0" cellpadding="0" border="0"><tr><td><a href="' . htmlspecialchars(preg_replace('/&explain=([^&]*)/', '', $_SERVER['REQUEST_URI'])) . '"><img src="' . $phpbb_root_path . 'adm/images/header_left.jpg" width="200" height="60" alt="phpBB Logo" title="phpBB Logo" border="0"/></a></td><td width="100%" background="' . $phpbb_root_path . 'adm/images/header_bg.jpg" height="60" align="right" nowrap="nowrap"><span class="maintitle">SQL Report</span> &nbsp; &nbsp; &nbsp;</td></tr></table><br clear="all"/><table width="95%" cellspacing="1" cellpadding="4" border="0" align="center"><tr><td height="40" align="center" valign="middle"><b>Page generated in ' . round($totaltime, 4) . " seconds with {$this->num_queries} queries" . (($cache_num_queries) ? " + $cache_num_queries " . (($cache_num_queries == 1) ? 'query' : 'queries') . ' returning data from cache' : '') . '</b></td></tr><tr><td align="center" nowrap="nowrap">Time spent on MySQL queries: <b>' . round($this->sql_time, 5) . 's</b> | Time spent on PHP: <b>' . round($totaltime - $this->sql_time, 5) . 's</b></td></tr></table><table width="95%" cellspacing="1" cellpadding="4" border="0" align="center"><tr><td>';
- echo $sql_report;
- echo '</td></tr></table><br /></body></html>';
- exit;
- break;
-
case 'start':
$query_hold = $query;
$html_hold = '';
@@ -525,34 +406,9 @@ class sql_db
mysql_free_result($result);
$cache_num_queries++;
break;
-
- case 'stop':
- $endtime = explode(' ', microtime());
- $endtime = $endtime[0] + $endtime[1];
-
- $sql_report .= '<hr width="100%"/><br /><table class="bg" width="100%" cellspacing="1" cellpadding="4" border="0"><tr><th>Query #' . $this->num_queries . '</th></tr><tr><td class="row1"><textarea style="font-family:\'Courier New\',monospace;width:100%" rows="5">' . preg_replace('/\t(AND|OR)(\W)/', "\$1\$2", htmlspecialchars(preg_replace('/[\s]*[\n\r\t]+[\n\r\s\t]*/', "\n", $query))) . '</textarea></td></tr></table> ' . $html_hold . '<p align="center">';
-
- if ($this->query_result)
- {
- if (preg_match('/^(UPDATE|DELETE|REPLACE)/', $query))
- {
- $sql_report .= "Affected rows: <b>" . $this->sql_affectedrows($this->query_result) . '</b> | ';
- }
- $sql_report .= 'Before: ' . sprintf('%.5f', $curtime - $starttime) . 's | After: ' . sprintf('%.5f', $endtime - $starttime) . 's | Elapsed: <b>' . sprintf('%.5f', $endtime - $curtime) . 's</b>';
- }
- else
- {
- $error = $this->sql_error();
- $sql_report .= '<b style="color: red">FAILED</b> - MySQL Error ' . $error['code'] . ': ' . htmlspecialchars($error['message']);
- }
-
- $sql_report .= '</p>';
-
- $this->sql_time += $endtime - $curtime;
- break;
}
}
-} // class sql_db
+}
} // if ... define
diff --git a/phpBB/includes/db/mysqli.php b/phpBB/includes/db/mysqli.php
index c4222ae4e5..9dcb5ec7c0 100644
--- a/phpBB/includes/db/mysqli.php
+++ b/phpBB/includes/db/mysqli.php
@@ -1,7 +1,7 @@
<?php
/**
*
-* @package dbal_mysqli
+* @package dbal
* @version $Id$
* @copyright (c) 2005 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
@@ -14,23 +14,16 @@
if (!defined('SQL_LAYER'))
{
-define('SQL_LAYER', 'mysqli');
+ define('SQL_LAYER', 'mysqli');
+ include($phpbb_root_path . 'includes/db/dbal.' . $phpEx);
/**
-* @package dbal_mysqli
+* @package dbal
* MySQLi Database Abstraction Layer
* Minimum Requirement is MySQL 4.1+ and the mysqli-extension
*/
-class sql_db
+class dbal_mysqli extends dbal
{
- var $db_connect_id;
- var $query_result;
- var $return_on_error = false;
- var $transaction = false;
- var $sql_time = 0;
- var $num_queries = 0;
- var $open_queries = array();
-
var $indexed = 0;
function sql_connect($sqlserver, $sqluser, $sqlpassword, $database, $port = false, $persistency = false)
@@ -71,16 +64,6 @@ class sql_db
return @mysqli_close($this->db_connect_id);
}
- function sql_return_on_error($fail = false)
- {
- $this->return_on_error = $fail;
- }
-
- function sql_num_queries()
- {
- return $this->num_queries;
- }
-
function sql_transaction($status = 'begin')
{
switch ($status)
@@ -189,62 +172,6 @@ class sql_db
}
}
- // Idea for this from Ikonboard
- function sql_build_array($query, $assoc_ary = false)
- {
- if (!is_array($assoc_ary))
- {
- return false;
- }
-
- $fields = array();
- $values = array();
- if ($query == 'INSERT')
- {
- foreach ($assoc_ary as $key => $var)
- {
- $fields[] = $key;
-
- if (is_null($var))
- {
- $values[] = 'NULL';
- }
- elseif (is_string($var))
- {
- $values[] = "'" . $this->sql_escape($var) . "'";
- }
- else
- {
- $values[] = (is_bool($var)) ? intval($var) : $var;
- }
- }
-
- $query = ' (' . implode(', ', $fields) . ') VALUES (' . implode(', ', $values) . ')';
- }
- else if ($query == 'UPDATE' || $query == 'SELECT')
- {
- $values = array();
- foreach ($assoc_ary as $key => $var)
- {
- if (is_null($var))
- {
- $values[] = "$key = NULL";
- }
- elseif (is_string($var))
- {
- $values[] = "$key = '" . $this->sql_escape($var) . "'";
- }
- else
- {
- $values[] = (is_bool($var)) ? "$key = " . intval($var) : "$key = $var";
- }
- }
- $query = implode(($query == 'UPDATE') ? ', ' : ' AND ', $values);
- }
-
- return $query;
- }
-
// Other query methods
//
// NOTE :: Want to remove _ALL_ reliance on sql_numrows from core code ...
@@ -392,70 +319,23 @@ class sql_db
return @mysqli_real_escape_string($this->db_connect_id, $msg);
}
- function sql_error($sql = '')
+ function db_sql_error()
{
- if (!$this->return_on_error)
- {
- $this_page = (isset($_SERVER['PHP_SELF']) && !empty($_SERVER['PHP_SELF'])) ? $_SERVER['PHP_SELF'] : $_ENV['PHP_SELF'];
- $this_page .= '&' . ((isset($_SERVER['QUERY_STRING']) && !empty($_SERVER['QUERY_STRING'])) ? $_SERVER['QUERY_STRING'] : (isset($_ENV['QUERY_STRING']) ? $_ENV['QUERY_STRING'] : ''));
-
- $message = '<u>SQL ERROR</u> [ ' . SQL_LAYER . ' ]<br /><br />' . @mysqli_error($this->db_connect_id) . '<br /><br /><u>CALLING PAGE</u><br /><br />' . htmlspecialchars($this_page) . (($sql != '') ? '<br /><br /><u>SQL</u><br /><br />' . $sql : '') . '<br />';
-
- if ($this->transaction)
- {
- $this->sql_transaction('rollback');
- }
-
- trigger_error($message, E_USER_ERROR);
- }
-
- $result = array(
+ return array(
'message' => @mysqli_error($this->db_connect_id),
'code' => @mysqli_errno($this->db_connect_id)
);
-
- return $result;
}
- function sql_report($mode, $query = '')
+ function _sql_report($mode, $query = '')
{
- if (empty($_GET['explain']))
- {
- return;
- }
-
- global $db, $cache, $starttime, $phpbb_root_path;
+ global $cache, $starttime, $phpbb_root_path;
static $curtime, $query_hold, $html_hold;
static $sql_report = '';
static $cache_num_queries = 0;
- if (!$query && !empty($query_hold))
- {
- $query = $query_hold;
- }
-
switch ($mode)
{
- case 'display':
- if (!empty($cache))
- {
- $cache->unload();
- }
- $db->sql_close();
-
- $mtime = explode(' ', microtime());
- $totaltime = $mtime[0] + $mtime[1] - $starttime;
-
- echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8869-1"><meta http-equiv="Content-Style-Type" content="text/css"><link rel="stylesheet" href="' . $phpbb_root_path . 'adm/subSilver.css" type="text/css"><style type="text/css">' . "\n";
- echo 'th { background-image: url(\'' . $phpbb_root_path . 'adm/images/cellpic3.gif\') }' . "\n";
- echo 'td.cat { background-image: url(\'' . $phpbb_root_path . 'adm/images/cellpic1.gif\') }' . "\n";
- echo '</style><title>' . $msg_title . '</title></head><body>';
- echo '<table width="100%" cellspacing="0" cellpadding="0" border="0"><tr><td><a href="' . htmlspecialchars(preg_replace('/&explain=([^&]*)/', '', $_SERVER['REQUEST_URI'])) . '"><img src="' . $phpbb_root_path . 'adm/images/header_left.jpg" width="200" height="60" alt="phpBB Logo" title="phpBB Logo" border="0"/></a></td><td width="100%" background="' . $phpbb_root_path . 'adm/images/header_bg.jpg" height="60" align="right" nowrap="nowrap"><span class="maintitle">SQL Report</span> &nbsp; &nbsp; &nbsp;</td></tr></table><br clear="all"/><table width="95%" cellspacing="1" cellpadding="4" border="0" align="center"><tr><td height="40" align="center" valign="middle"><b>Page generated in ' . round($totaltime, 4) . " seconds with {$this->num_queries} queries" . (($cache_num_queries) ? " + $cache_num_queries " . (($cache_num_queries == 1) ? 'query' : 'queries') . ' returning data from cache' : '') . '</b></td></tr><tr><td align="center" nowrap="nowrap">Time spent on MySQL queries: <b>' . round($this->sql_time, 5) . 's</b> | Time spent on PHP: <b>' . round($totaltime - $this->sql_time, 5) . 's</b></td></tr></table><table width="95%" cellspacing="1" cellpadding="4" border="0" align="center"><tr><td>';
- echo $sql_report;
- echo '</td></tr></table><br /></body></html>';
- exit;
- break;
-
case 'start':
$query_hold = $query;
$html_hold = '';
@@ -537,34 +417,9 @@ class sql_db
@mysqli_free_result($result);
$cache_num_queries++;
break;
-
- case 'stop':
- $endtime = explode(' ', microtime());
- $endtime = $endtime[0] + $endtime[1];
-
- $sql_report .= '<hr width="100%"/><br /><table class="bg" width="100%" cellspacing="1" cellpadding="4" border="0"><tr><th>Query #' . $this->num_queries . '</th></tr><tr><td class="row1"><textarea style="font-family:\'Courier New\',monospace;width:100%" rows="5">' . preg_replace('/\t(AND|OR)(\W)/', "\$1\$2", htmlspecialchars(preg_replace('/[\s]*[\n\r\t]+[\n\r\s\t]*/', "\n", $query))) . '</textarea></td></tr></table> ' . $html_hold . '<p align="center">';
-
- if ($this->query_result)
- {
- if (preg_match('/^(UPDATE|DELETE|REPLACE)/', $query))
- {
- $sql_report .= "Affected rows: <b>" . $this->sql_affectedrows($this->query_result) . '</b> | ';
- }
- $sql_report .= 'Before: ' . sprintf('%.5f', $curtime - $starttime) . 's | After: ' . sprintf('%.5f', $endtime - $starttime) . 's | Elapsed: <b>' . sprintf('%.5f', $endtime - $curtime) . 's</b>';
- }
- else
- {
- $error = $this->sql_error();
- $sql_report .= '<b style="color: red">FAILED</b> - MySQL Error ' . $error['code'] . ': ' . htmlspecialchars($error['message']);
- }
-
- $sql_report .= '</p>';
-
- $this->sql_time += $endtime - $curtime;
- break;
}
}
-} // class sql_db
+}
} // if ... define
diff --git a/phpBB/includes/db/oracle.php b/phpBB/includes/db/oracle.php
index ad4a25cf60..e281140b73 100644
--- a/phpBB/includes/db/oracle.php
+++ b/phpBB/includes/db/oracle.php
@@ -1,7 +1,7 @@
<?php
/**
*
-* @package dbal_oracle
+* @package dbal
* @version $Id$
* @copyright (c) 2005 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
@@ -14,22 +14,15 @@
if(!defined('SQL_LAYER'))
{
-define('SQL_LAYER', 'oracle');
+ define('SQL_LAYER', 'oracle');
+ include($phpbb_root_path . 'includes/db/dbal.' . $phpEx);
/**
-* @package dbal_oracle
+* @package dbal
* Oracle Database Abstraction Layer
*/
-class sql_db
+class dbal_oracle extends dbal
{
- var $db_connect_id;
- var $query_result;
- var $return_on_error = false;
- var $transaction = false;
- var $sql_time = 0;
- var $num_queries = 0;
- var $open_queries = array();
-
var $last_query_text = '';
function sql_connect($sqlserver, $sqluser, $sqlpassword, $database, $port = false, $persistency = false)
@@ -70,16 +63,6 @@ class sql_db
return @ocilogoff($this->db_connect_id);
}
- function sql_return_on_error($fail = false)
- {
- $this->return_on_error = $fail;
- }
-
- function sql_num_queries()
- {
- return $this->num_queries;
- }
-
function sql_transaction($status = 'begin')
{
switch ($status)
@@ -201,62 +184,6 @@ class sql_db
}
}
- // Idea for this from Ikonboard
- function sql_build_array($query, $assoc_ary = false)
- {
- if (!is_array($assoc_ary))
- {
- return false;
- }
-
- $fields = array();
- $values = array();
- if ($query == 'INSERT')
- {
- foreach ($assoc_ary as $key => $var)
- {
- $fields[] = $key;
-
- if (is_null($var))
- {
- $values[] = 'NULL';
- }
- elseif (is_string($var))
- {
- $values[] = "'" . $this->sql_escape($var) . "'";
- }
- else
- {
- $values[] = (is_bool($var)) ? intval($var) : $var;
- }
- }
-
- $query = ' (' . implode(', ', $fields) . ') VALUES (' . implode(', ', $values) . ')';
- }
- else if ($query == 'UPDATE' || $query == 'SELECT')
- {
- $values = array();
- foreach ($assoc_ary as $key => $var)
- {
- if (is_null($var))
- {
- $values[] = "$key = NULL";
- }
- elseif (is_string($var))
- {
- $values[] = "$key = '" . $this->sql_escape($var) . "'";
- }
- else
- {
- $values[] = (is_bool($var)) ? "$key = " . intval($var) : "$key = $var";
- }
- }
- $query = implode(($query == 'UPDATE') ? ', ' : ' AND ', $values);
- }
-
- return $query;
- }
-
// Other query methods
//
// NOTE :: Want to remove _ALL_ reliance on sql_numrows from core code ...
@@ -451,7 +378,7 @@ class sql_db
return str_replace("'", "''", str_replace('\\', '\\\\', $msg));
}
- function sql_error($sql = '')
+ function db_sql_error()
{
$error = @ocierror();
$error = (!$error) ? @ocierror($this->query_result) : $error;
@@ -466,63 +393,18 @@ class sql_db
$error = (isset($this->last_error_result) && $this->last_error_result) ? $this->last_error_result : array();
}
- if (!$this->return_on_error)
- {
- $this_page = (isset($_SERVER['PHP_SELF']) && !empty($_SERVER['PHP_SELF'])) ? $_SERVER['PHP_SELF'] : $_ENV['PHP_SELF'];
- $this_page .= '&' . ((isset($_SERVER['QUERY_STRING']) && !empty($_SERVER['QUERY_STRING'])) ? $_SERVER['QUERY_STRING'] : (isset($_ENV['QUERY_STRING']) ? $_ENV['QUERY_STRING'] : ''));
-
- $message = '<u>SQL ERROR</u> [ ' . SQL_LAYER . ' ]<br /><br />' . $error['message'] . ' [' . $error['code'] . ']<br /><br /><u>CALLING PAGE</u><br /><br />' . htmlspecialchars($this_page) . (($sql != '') ? '<br /><br /><u>SQL</u><br /><br />' . $sql : '') . '<br />';
-
- if ($this->transaction)
- {
- $this->sql_transaction('rollback');
- }
-
- trigger_error($message, E_USER_ERROR);
- }
-
return $error;
}
- function sql_report($mode, $query = '')
+ function _sql_report($mode, $query = '')
{
- if (empty($_GET['explain']))
- {
- return;
- }
-
global $cache, $starttime, $phpbb_root_path;
static $curtime, $query_hold, $html_hold;
static $sql_report = '';
static $cache_num_queries = 0;
- if (!$query && !empty($query_hold))
- {
- $query = $query_hold;
- }
-
switch ($mode)
{
- case 'display':
- if (!empty($cache))
- {
- $cache->unload();
- }
- $this->sql_close();
-
- $mtime = explode(' ', microtime());
- $totaltime = $mtime[0] + $mtime[1] - $starttime;
-
- echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8869-1"><meta http-equiv="Content-Style-Type" content="text/css"><link rel="stylesheet" href="' . $phpbb_root_path . 'adm/subSilver.css" type="text/css"><style type="text/css">' . "\n";
- echo 'th { background-image: url(\'' . $phpbb_root_path . 'adm/images/cellpic3.gif\') }' . "\n";
- echo 'td.cat { background-image: url(\'' . $phpbb_root_path . 'adm/images/cellpic1.gif\') }' . "\n";
- echo '</style><title>' . $msg_title . '</title></head><body>';
- echo '<table width="100%" cellspacing="0" cellpadding="0" border="0"><tr><td><a href="' . htmlspecialchars(preg_replace('/&explain=([^&]*)/', '', $_SERVER['REQUEST_URI'])) . '"><img src="' . $phpbb_root_path . 'adm/images/header_left.jpg" width="200" height="60" alt="phpBB Logo" title="phpBB Logo" border="0"/></a></td><td width="100%" background="' . $phpbb_root_path . 'adm/images/header_bg.jpg" height="60" align="right" nowrap="nowrap"><span class="maintitle">SQL Report</span> &nbsp; &nbsp; &nbsp;</td></tr></table><br clear="all"/><table width="95%" cellspacing="1" cellpadding="4" border="0" align="center"><tr><td height="40" align="center" valign="middle"><b>Page generated in ' . round($totaltime, 4) . " seconds with {$this->num_queries} queries" . (($cache_num_queries) ? " + $cache_num_queries " . (($cache_num_queries == 1) ? 'query' : 'queries') . ' returning data from cache' : '') . '</b></td></tr><tr><td align="center" nowrap="nowrap">Time spent on MySQL queries: <b>' . round($this->sql_time, 5) . 's</b> | Time spent on PHP: <b>' . round($totaltime - $this->sql_time, 5) . 's</b></td></tr></table><table width="95%" cellspacing="1" cellpadding="4" border="0" align="center"><tr><td>';
- echo $sql_report;
- echo '</td></tr></table><br /></body></html>';
- exit;
- break;
-
case 'start':
$query_hold = $query;
$html_hold = '';
@@ -560,36 +442,11 @@ class sql_db
@ocifreestatement($result);
$cache_num_queries++;
break;
-
- case 'stop':
- $endtime = explode(' ', microtime());
- $endtime = $endtime[0] + $endtime[1];
-
- $sql_report .= '<hr width="100%"/><br /><table class="bg" width="100%" cellspacing="1" cellpadding="4" border="0"><tr><th>Query #' . $this->num_queries . '</th></tr><tr><td class="row1"><textarea style="font-family:\'Courier New\',monospace;width:100%" rows="5">' . preg_replace('/\t(AND|OR)(\W)/', "\$1\$2", htmlspecialchars(preg_replace('/[\s]*[\n\r\t]+[\n\r\s\t]*/', "\n", $query))) . '</textarea></td></tr></table> ' . $html_hold . '<p align="center">';
-
- if ($this->query_result)
- {
- if (preg_match('/^(UPDATE|DELETE|REPLACE)/', $query))
- {
- $sql_report .= "Affected rows: <b>" . $this->sql_affectedrows($this->query_result) . '</b> | ';
- }
- $sql_report .= 'Before: ' . sprintf('%.5f', $curtime - $starttime) . 's | After: ' . sprintf('%.5f', $endtime - $starttime) . 's | Elapsed: <b>' . sprintf('%.5f', $endtime - $curtime) . 's</b>';
- }
- else
- {
- $error = $this->sql_error();
- $sql_report .= '<b style="color: red">FAILED</b> - ' . SQL_LAYER . ' Error ' . $error['code'] . ': ' . htmlspecialchars($error['message']);
- }
-
- $sql_report .= '</p>';
-
- $this->sql_time += $endtime - $curtime;
- break;
}
}
-} // class sql_db
+}
} // if ... define
diff --git a/phpBB/includes/db/postgres.php b/phpBB/includes/db/postgres.php
index 5db37d4da0..f16ecff2c6 100644
--- a/phpBB/includes/db/postgres.php
+++ b/phpBB/includes/db/postgres.php
@@ -1,7 +1,7 @@
<?php
/**
*
-* @package dbal_postgres
+* @package dbal
* @version $Id$
* @copyright (c) 2005 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
@@ -14,22 +14,16 @@
if (!defined('SQL_LAYER'))
{
-define('SQL_LAYER', 'postgresql');
+ define('SQL_LAYER', 'postgresql');
+ include($phpbb_root_path . 'includes/db/dbal.' . $phpEx);
/**
-* @package dbal_postgres
+* @package dbal
* PostgreSQL Database Abstraction Layer
* Minimum Requirement is Version 7.3+
*/
-class sql_db
+class dbal_postgres extends dbal
{
- var $db_connect_id;
- var $query_result;
- var $return_on_error = false;
- var $transaction = false;
- var $sql_time = 0;
- var $num_queries = 0;
- var $open_queries = array();
function sql_connect($sqlserver, $sqluser, $sqlpassword, $database, $port = false, $persistency = false)
{
@@ -97,16 +91,6 @@ class sql_db
return @pg_close($this->db_connect_id);
}
- function sql_return_on_error($fail = false)
- {
- $this->return_on_error = $fail;
- }
-
- function sql_num_queries()
- {
- return $this->num_queries;
- }
-
function sql_transaction($status = 'begin')
{
switch ($status)
@@ -208,62 +192,6 @@ class sql_db
}
}
- // Idea for this from Ikonboard
- function sql_build_array($query, $assoc_ary = false)
- {
- if (!is_array($assoc_ary))
- {
- return false;
- }
-
- $fields = array();
- $values = array();
- if ($query == 'INSERT')
- {
- foreach ($assoc_ary as $key => $var)
- {
- $fields[] = $key;
-
- if (is_null($var))
- {
- $values[] = 'NULL';
- }
- elseif (is_string($var))
- {
- $values[] = "'" . $this->sql_escape($var) . "'";
- }
- else
- {
- $values[] = (is_bool($var)) ? intval($var) : $var;
- }
- }
-
- $query = ' (' . implode(', ', $fields) . ') VALUES (' . implode(', ', $values) . ')';
- }
- else if ($query == 'UPDATE' || $query == 'SELECT')
- {
- $values = array();
- foreach ($assoc_ary as $key => $var)
- {
- if (is_null($var))
- {
- $values[] = "$key = NULL";
- }
- elseif (is_string($var))
- {
- $values[] = "$key = '" . $this->sql_escape($var) . "'";
- }
- else
- {
- $values[] = (is_bool($var)) ? "$key = " . intval($var) : "$key = $var";
- }
- }
- $query = implode(($query == 'UPDATE') ? ', ' : ' AND ', $values);
- }
-
- return $query;
- }
-
// Other query methods
//
// NOTE :: Want to remove _ALL_ reliance on sql_numrows from core code ...
@@ -370,7 +298,7 @@ class sql_db
{
if (empty($this->row[$query_id]) && empty($this->rowset[$query_id]))
{
- if ($this->sql_fetchrow($query_id))
+ if ($this->row[$query_id] = $this->sql_fetchrow($query_id))
{
$result = $this->row[$query_id][$field];
}
@@ -464,70 +392,23 @@ class sql_db
return str_replace("'", "''", str_replace('\\', '\\\\', $msg));
}
- function sql_error($sql = '')
+ function db_sql_error()
{
- if (!$this->return_on_error)
- {
- $this_page = (isset($_SERVER['PHP_SELF']) && !empty($_SERVER['PHP_SELF'])) ? $_SERVER['PHP_SELF'] : $_ENV['PHP_SELF'];
- $this_page .= '&' . ((isset($_SERVER['QUERY_STRING']) && !empty($_SERVER['QUERY_STRING'])) ? $_SERVER['QUERY_STRING'] : (isset($_ENV['QUERY_STRING']) ? $_ENV['QUERY_STRING'] : ''));
-
- $message = '<u>SQL ERROR</u> [ ' . SQL_LAYER . ' ]<br /><br />' . @pg_errormessage() . '<br /><br /><u>CALLING PAGE</u><br /><br />' . htmlspecialchars($this_page) . (($sql != '') ? '<br /><br /><u>SQL</u><br /><br />' . $sql : '') . '<br />';
-
- if ($this->transaction)
- {
- $this->sql_transaction('rollback');
- }
-
- trigger_error($message, E_USER_ERROR);
- }
-
- $result = array(
+ return array(
'message' => @pg_errormessage(),
'code' => ''
);
-
- return $result;
}
- function sql_report($mode, $query = '')
+ function _sql_report($mode, $query = '')
{
- if (empty($_GET['explain']))
- {
- return;
- }
-
global $cache, $starttime, $phpbb_root_path;
static $curtime, $query_hold, $html_hold;
static $sql_report = '';
static $cache_num_queries = 0;
- if (!$query && !empty($query_hold))
- {
- $query = $query_hold;
- }
-
switch ($mode)
{
- case 'display':
- if (!empty($cache))
- {
- $cache->unload();
- }
- $this->sql_close();
-
- $mtime = explode(' ', microtime());
- $totaltime = $mtime[0] + $mtime[1] - $starttime;
-
- echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8869-1"><meta http-equiv="Content-Style-Type" content="text/css"><link rel="stylesheet" href="' . $phpbb_root_path . 'adm/subSilver.css" type="text/css"><style type="text/css">' . "\n";
- echo 'th { background-image: url(\'' . $phpbb_root_path . 'adm/images/cellpic3.gif\') }' . "\n";
- echo 'td.cat { background-image: url(\'' . $phpbb_root_path . 'adm/images/cellpic1.gif\') }' . "\n";
- echo '</style><title>' . $msg_title . '</title></head><body>';
- echo '<table width="100%" cellspacing="0" cellpadding="0" border="0"><tr><td><a href="' . htmlspecialchars(preg_replace('/&explain=([^&]*)/', '', $_SERVER['REQUEST_URI'])) . '"><img src="' . $phpbb_root_path . 'adm/images/header_left.jpg" width="200" height="60" alt="phpBB Logo" title="phpBB Logo" border="0"/></a></td><td width="100%" background="' . $phpbb_root_path . 'adm/images/header_bg.jpg" height="60" align="right" nowrap="nowrap"><span class="maintitle">SQL Report</span> &nbsp; &nbsp; &nbsp;</td></tr></table><br clear="all"/><table width="95%" cellspacing="1" cellpadding="4" border="0" align="center"><tr><td height="40" align="center" valign="middle"><b>Page generated in ' . round($totaltime, 4) . " seconds with {$this->num_queries} queries" . (($cache_num_queries) ? " + $cache_num_queries " . (($cache_num_queries == 1) ? 'query' : 'queries') . ' returning data from cache' : '') . '</b></td></tr><tr><td align="center" nowrap="nowrap">Time spent on MySQL queries: <b>' . round($this->sql_time, 5) . 's</b> | Time spent on PHP: <b>' . round($totaltime - $this->sql_time, 5) . 's</b></td></tr></table><table width="95%" cellspacing="1" cellpadding="4" border="0" align="center"><tr><td>';
- echo $sql_report;
- echo '</td></tr></table><br /></body></html>';
- exit;
- break;
-
case 'start':
$query_hold = $query;
$html_hold = '';
@@ -562,35 +443,10 @@ class sql_db
@pg_freeresult($result);
$cache_num_queries++;
break;
-
- case 'stop':
- $endtime = explode(' ', microtime());
- $endtime = $endtime[0] + $endtime[1];
-
- $sql_report .= '<hr width="100%"/><br /><table class="bg" width="100%" cellspacing="1" cellpadding="4" border="0"><tr><th>Query #' . $this->num_queries . '</th></tr><tr><td class="row1"><textarea style="font-family:\'Courier New\',monospace;width:100%" rows="5">' . preg_replace('/\t(AND|OR)(\W)/', "\$1\$2", htmlspecialchars(preg_replace('/[\s]*[\n\r\t]+[\n\r\s\t]*/', "\n", $query))) . '</textarea></td></tr></table> ' . $html_hold . '<p align="center">';
-
- if ($this->query_result)
- {
- if (preg_match('/^(UPDATE|DELETE|REPLACE)/', $query))
- {
- $sql_report .= "Affected rows: <b>" . $this->sql_affectedrows($this->query_result) . '</b> | ';
- }
- $sql_report .= 'Before: ' . sprintf('%.5f', $curtime - $starttime) . 's | After: ' . sprintf('%.5f', $endtime - $starttime) . 's | Elapsed: <b>' . sprintf('%.5f', $endtime - $curtime) . 's</b>';
- }
- else
- {
- $error = $this->sql_error();
- $sql_report .= '<b style="color: red">FAILED</b> - ' . SQL_LAYER . ' Error ' . $error['code'] . ': ' . htmlspecialchars($error['message']);
- }
-
- $sql_report .= '</p>';
-
- $this->sql_time += $endtime - $curtime;
- break;
}
}
-} // class ... db_sql
+}
} // if ... defined
diff --git a/phpBB/includes/db/sqlite.php b/phpBB/includes/db/sqlite.php
index d74a535cea..1b20822284 100644
--- a/phpBB/includes/db/sqlite.php
+++ b/phpBB/includes/db/sqlite.php
@@ -1,7 +1,7 @@
<?php
/**
*
-* @package dbal_sqlite
+* @package dbal
* @version $Id$
* @copyright (c) 2005 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
@@ -14,20 +14,15 @@
if (!defined('SQL_LAYER'))
{
-define('SQL_LAYER', 'sqlite');
+ define('SQL_LAYER', 'sqlite');
+ include($phpbb_root_path . 'includes/db/dbal.' . $phpEx);
/**
-* @package dbal_sqlite
+* @package dbal
* Sqlite Database Abstraction Layer
*/
-class sql_db
+class dbal_sqlite extends dbal
{
- var $db_connect_id;
- var $query_result;
- var $return_on_error = false;
- var $transaction = false;
- var $sql_time = 0;
- var $num_queries = 0;
function sql_connect($sqlserver, $sqluser, $sqlpassword, $database, $port = false, $persistency = false)
{
@@ -60,16 +55,6 @@ class sql_db
return @sqlite_close($this->db_connect_id);
}
- function sql_return_on_error($fail = false)
- {
- $this->return_on_error = $fail;
- }
-
- function sql_num_queries()
- {
- return $this->num_queries;
- }
-
function sql_transaction($status = 'begin')
{
switch ($status)
@@ -172,62 +157,6 @@ class sql_db
}
}
- // Idea for this from Ikonboard
- function sql_build_array($query, $assoc_ary = false)
- {
- if (!is_array($assoc_ary))
- {
- return false;
- }
-
- $fields = array();
- $values = array();
- if ($query == 'INSERT')
- {
- foreach ($assoc_ary as $key => $var)
- {
- $fields[] = $key;
-
- if (is_null($var))
- {
- $values[] = 'NULL';
- }
- elseif (is_string($var))
- {
- $values[] = "'" . $this->sql_escape($var) . "'";
- }
- else
- {
- $values[] = (is_bool($var)) ? intval($var) : $var;
- }
- }
-
- $query = ' (' . implode(', ', $fields) . ') VALUES (' . implode(', ', $values) . ')';
- }
- else if ($query == 'UPDATE' || $query == 'SELECT')
- {
- $values = array();
- foreach ($assoc_ary as $key => $var)
- {
- if (is_null($var))
- {
- $values[] = "$key = NULL";
- }
- elseif (is_string($var))
- {
- $values[] = "$key = '" . $this->sql_escape($var) . "'";
- }
- else
- {
- $values[] = (is_bool($var)) ? "$key = " . intval($var) : "$key = $var";
- }
- }
- $query = implode(($query == 'UPDATE') ? ', ' : ' AND ', $values);
- }
-
- return $query;
- }
-
// Other query methods
//
// NOTE :: Want to remove _ALL_ reliance on sql_numrows from core code ...
@@ -336,70 +265,23 @@ class sql_db
return @sqlite_escape_string(stripslashes($msg));
}
- function sql_error($sql = '')
+ function db_sql_error()
{
- if (!$this->return_on_error)
- {
- $this_page = (isset($_SERVER['PHP_SELF']) && !empty($_SERVER['PHP_SELF'])) ? $_SERVER['PHP_SELF'] : $_ENV['PHP_SELF'];
- $this_page .= '&' . ((isset($_SERVER['QUERY_STRING']) && !empty($_SERVER['QUERY_STRING'])) ? $_SERVER['QUERY_STRING'] : (isset($_ENV['QUERY_STRING']) ? $_ENV['QUERY_STRING'] : ''));
-
- $message = '<u>SQL ERROR</u> [ ' . SQL_LAYER . ' ]<br /><br />' . @sqlite_error_string(@sqlite_last_error($this->db_connect_id)) . '<br /><br /><u>CALLING PAGE</u><br /><br />' . htmlspecialchars($this_page) . (($sql != '') ? '<br /><br /><u>SQL</u><br /><br />' . $sql : '') . '<br />';
-
- if ($this->transaction)
- {
- $this->sql_transaction('rollback');
- }
-
- trigger_error($message, E_USER_ERROR);
- }
-
- $result = array(
+ return array(
'message' => @sqlite_error_string(@sqlite_last_error($this->db_connect_id)),
'code' => @sqlite_last_error($this->db_connect_id)
);
-
- return $result;
}
- function sql_report($mode, $query = '')
+ function _sql_report($mode, $query = '')
{
- if (empty($_GET['explain']))
- {
- return;
- }
-
global $cache, $starttime, $phpbb_root_path;
static $curtime, $query_hold, $html_hold;
static $sql_report = '';
static $cache_num_queries = 0;
- if (!$query && !empty($query_hold))
- {
- $query = $query_hold;
- }
-
switch ($mode)
{
- case 'display':
- if (!empty($cache))
- {
- $cache->unload();
- }
- $this->sql_close();
-
- $mtime = explode(' ', microtime());
- $totaltime = $mtime[0] + $mtime[1] - $starttime;
-
- echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8869-1"><meta http-equiv="Content-Style-Type" content="text/css"><link rel="stylesheet" href="' . $phpbb_root_path . 'adm/subSilver.css" type="text/css"><style type="text/css">' . "\n";
- echo 'th { background-image: url(\'' . $phpbb_root_path . 'adm/images/cellpic3.gif\') }' . "\n";
- echo 'td.cat { background-image: url(\'' . $phpbb_root_path . 'adm/images/cellpic1.gif\') }' . "\n";
- echo '</style><title>' . $msg_title . '</title></head><body>';
- echo '<table width="100%" cellspacing="0" cellpadding="0" border="0"><tr><td><a href="' . htmlspecialchars(preg_replace('/&explain=([^&]*)/', '', $_SERVER['REQUEST_URI'])) . '"><img src="' . $phpbb_root_path . 'adm/images/header_left.jpg" width="200" height="60" alt="phpBB Logo" title="phpBB Logo" border="0"/></a></td><td width="100%" background="' . $phpbb_root_path . 'adm/images/header_bg.jpg" height="60" align="right" nowrap="nowrap"><span class="maintitle">SQL Report</span> &nbsp; &nbsp; &nbsp;</td></tr></table><br clear="all"/><table width="95%" cellspacing="1" cellpadding="4" border="0" align="center"><tr><td height="40" align="center" valign="middle"><b>Page generated in ' . round($totaltime, 4) . " seconds with {$this->num_queries} queries" . (($cache_num_queries) ? " + $cache_num_queries " . (($cache_num_queries == 1) ? 'query' : 'queries') . ' returning data from cache' : '') . '</b></td></tr><tr><td align="center" nowrap="nowrap">Time spent on MySQL queries: <b>' . round($this->sql_time, 5) . 's</b> | Time spent on PHP: <b>' . round($totaltime - $this->sql_time, 5) . 's</b></td></tr></table><table width="95%" cellspacing="1" cellpadding="4" border="0" align="center"><tr><td>';
- echo $sql_report;
- echo '</td></tr></table><br /></body></html>';
- exit;
- break;
-
case 'start':
$query_hold = $query;
$html_hold = '';
@@ -433,35 +315,10 @@ class sql_db
$cache_num_queries++;
break;
-
- case 'stop':
- $endtime = explode(' ', microtime());
- $endtime = $endtime[0] + $endtime[1];
-
- $sql_report .= '<hr width="100%"/><br /><table class="bg" width="100%" cellspacing="1" cellpadding="4" border="0"><tr><th>Query #' . $this->num_queries . '</th></tr><tr><td class="row1"><textarea style="font-family:\'Courier New\',monospace;width:100%" rows="5">' . preg_replace('/\t(AND|OR)(\W)/', "\$1\$2", htmlspecialchars(preg_replace('/[\s]*[\n\r\t]+[\n\r\s\t]*/', "\n", $query))) . '</textarea></td></tr></table> ' . $html_hold . '<p align="center">';
-
- if ($this->query_result)
- {
- if (preg_match('/^(UPDATE|DELETE|REPLACE)/', $query))
- {
- $sql_report .= "Affected rows: <b>" . $this->sql_affectedrows($this->query_result) . '</b> | ';
- }
- $sql_report .= 'Before: ' . sprintf('%.5f', $curtime - $starttime) . 's | After: ' . sprintf('%.5f', $endtime - $starttime) . 's | Elapsed: <b>' . sprintf('%.5f', $endtime - $curtime) . 's</b>';
- }
- else
- {
- $error = $this->sql_error();
- $sql_report .= '<b style="color: red">FAILED</b> - ' . SQL_LAYER . ' Error ' . $error['code'] . ': ' . htmlspecialchars($error['message']);
- }
-
- $sql_report .= '</p>';
-
- $this->sql_time += $endtime - $curtime;
- break;
}
}
-} // class sql_db
+}
} // if ... define
diff --git a/phpBB/includes/message_parser.php b/phpBB/includes/message_parser.php
index ad5503a1f9..5d352981e2 100644
--- a/phpBB/includes/message_parser.php
+++ b/phpBB/includes/message_parser.php
@@ -940,7 +940,7 @@ class parse_message extends bbcode_firstpass
switch (SQL_LAYER)
{
case 'mssql':
- case 'mssql-odbc':
+ case 'mssql_odbc':
$sql = 'SELECT *
FROM ' . SMILIES_TABLE . '
ORDER BY LEN(code) DESC';
diff --git a/phpBB/install/install.php b/phpBB/install/install.php
index cebc7097f9..e715fa86c2 100644
--- a/phpBB/install/install.php
+++ b/phpBB/install/install.php
@@ -113,7 +113,7 @@ $available_dbms = array(
'DELIM' => 'GO',
'COMMENTS' => 'remove_comments'
),
- 'mssql-odbc'=> array(
+ 'mssql_odbc'=> array(
'LABEL' => 'MS SQL Server [ ODBC ]',
'SCHEMA' => 'mssql',
'MODULE' => 'odbc',
@@ -1040,7 +1040,7 @@ if ($stage == 3)
include($phpbb_root_path . 'includes/db/' . $dbms . '.' . $phpEx);
// Instantiate the database
- $db = new sql_db();
+ $db = new $sql_db();
$db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false);
// We ship the Access schema complete, we don't need to create tables nor
@@ -1082,7 +1082,7 @@ if ($stage == 3)
switch ($dbms)
{
case 'mssql':
- case 'mssql-odbc':
+ case 'mssql_odbc':
$sql_query = preg_replace('#\# MSSQL IDENTITY (phpbb_[a-z_]+) (ON|OFF) \##s', 'SET IDENTITY_INSERT \1 \2', $sql_query);
break;
@@ -1385,7 +1385,7 @@ function connect_check_db($error_connect, &$error, &$dbms, &$table_prefix, &$dbh
include($phpbb_root_path . 'includes/db/' . $dbms . '.' . $phpEx);
// Instantiate it and set return on error true
- $db = new sql_db();
+ $db = new $sql_db();
$db->sql_return_on_error(true);
// Try and connect ...
@@ -1407,7 +1407,7 @@ function connect_check_db($error_connect, &$error, &$dbms, &$table_prefix, &$dbh
break;
case 'mssql':
- case 'mssql-odbc':
+ case 'mssql_odbc':
$sql = "SELECT name
FROM sysobjects
WHERE type='U'";
diff --git a/phpBB/language/en/admin.php b/phpBB/language/en/admin.php
index 141e6a6f5f..c566476aa1 100644
--- a/phpBB/language/en/admin.php
+++ b/phpBB/language/en/admin.php
@@ -1947,7 +1947,7 @@ $lang += array(
'DLL_MYSQL4' => 'MySQL 4.1+',
'DLL_MYSQLI' => 'MySQL 4.1+ with MySQLi Extension',
'DLL_MSSQL' => 'MSSQL Server 2000',
- 'DLL_MSSQL-ODBC' => 'MSSQL Server 2000 via ODBC',
+ 'DLL_MSSQL_ODBC' => 'MSSQL Server 2000 via ODBC',
'DLL_ORACLE' => 'Oracle',
'DLL_POSTGRES' => 'PostgreSQL 7.x',
'DLL_SQLITE' => 'SQLite',
diff --git a/phpBB/language/en/common.php b/phpBB/language/en/common.php
index 923cf8680b..44b20f25fc 100644
--- a/phpBB/language/en/common.php
+++ b/phpBB/language/en/common.php
@@ -48,6 +48,8 @@ $lang += array(
'ACCOUNT_NOT_ACTIVATED' => 'Your account has not been activated yet',
'ACP' => 'Administration Control Panel',
'ACTIVE_ERROR' => 'You have specified an inactive username. Please activate your account and try again. If you continue to have problems please contact a board administrator.',
+ 'ADMINISTRATOR' => 'Administrator',
+ 'ADMINISTRATORS' => 'Administrators',
'ALLOWED' => 'Allowed',
'ALL_FORUMS' => 'All Forums',
'ALL_MESSAGES' => 'All Messages',
@@ -124,6 +126,7 @@ $lang += array(
'FOLDER' => 'Folder',
'FORGOT_PASS' => 'I forgot my password',
'FORUM' => 'Forum',
+ 'FORUMS' => 'Forums',
'FORUMS_MARKED' => 'All forums have been marked read',
'FORUM_INDEX' => 'Board Index',
'FORUM_LOCATION' => 'Forum Location',
@@ -134,6 +137,7 @@ $lang += array(
'GO' => 'Go',
'GOTO_PAGE' => 'Goto page',
+ 'GROUP' => 'Group',
'GROUP_ERR_DESC_LONG' => 'Group description too long.',
'GROUP_ERR_TYPE' => 'Inappropriate group type specified.',
'GROUP_ERR_USERNAME' => 'No group name specified.',
@@ -360,6 +364,7 @@ $lang += array(
'SUBMIT' => 'Submit',
'TERMS_USE' => 'Terms of Use',
+ 'THE_TEAM' => 'The team',
'TIME' => 'Time',
'TOO_LONG_USER_PASSWORD' => 'The password you entered is too long.',
diff --git a/phpBB/language/en/groups.php b/phpBB/language/en/groups.php
index ca75316bf9..6570e4d3bb 100644
--- a/phpBB/language/en/groups.php
+++ b/phpBB/language/en/groups.php
@@ -29,7 +29,13 @@ if (empty($lang) || !is_array($lang))
// in a url you again do not need to specify an order e.g., 'Click %sHERE%s' is fine
$lang += array(
+ 'ALREADY_DEFAULT_GROUP' => 'The selected group is already your default group',
+ 'ALREADY_IN_GROUP' => 'You are already a member of the selected group',
+
+ 'CHANGED_DEFAULT_GROUP' => 'Successfully changed default group',
+
'GROUP_AVATAR' => 'Group avatar',
+ 'GROUP_CHANGE_DEFAULT' => 'Are you sure you want to change your default membership to the group "%s"?',
'GROUP_CLOSED' => 'Closed',
'GROUP_DESC' => 'Group description',
'GROUP_HIDDEN' => 'Hidden',
@@ -45,9 +51,16 @@ $lang += array(
'GROUP_IS_FREE' => 'This is a freely open group, all new members are welcome.',
'GROUP_IS_SPECIAL' => 'This is a special group, special groups are managed by the board administrators.',
+ 'LOG_USER_GROUP_CHANGE' => '<b>User changed default group</b><br />&#187; %s',
'LOGIN_EXPLAIN_GROUP' => 'You need to login to view group details',
- 'REMOVE_SELECTED' => 'Remove selected',
+ 'NOT_MEMBER_OF_GROUP' => 'The requested operation cannot be taken because you are not a member of the selected group',
+
+ 'PRIMARY_GROUP' => 'Primary group',
+
+ 'REMOVE_SELECTED' => 'Remove selected',
+
+ 'USER_GROUP_CHANGE' => 'From "%1$s" group to "%2$s"',
);
?> \ No newline at end of file