From 4740e7dece880f5cda26976ba758fc31c769f231 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Wed, 17 Aug 2005 15:57:50 +0000 Subject: - changed dbal class layout git-svn-id: file:///svn/phpbb/trunk@5193 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/common.php | 4 +- phpBB/includes/db/dbal.php | 196 ++++++++++++++++++++++++++++++++++++++ phpBB/includes/db/firebird.php | 171 +++------------------------------ phpBB/includes/db/mssql.php | 164 ++----------------------------- phpBB/includes/db/mysql.php | 166 +++----------------------------- phpBB/includes/db/mysql4.php | 166 +++----------------------------- phpBB/includes/db/mysqli.php | 165 ++------------------------------ phpBB/includes/db/oracle.php | 159 ++----------------------------- phpBB/includes/db/postgres.php | 164 ++----------------------------- phpBB/includes/db/sqlite.php | 161 ++----------------------------- phpBB/includes/message_parser.php | 2 +- phpBB/install/install.php | 10 +- phpBB/language/en/admin.php | 2 +- phpBB/language/en/common.php | 5 + phpBB/language/en/groups.php | 15 ++- 15 files changed, 308 insertions(+), 1242 deletions(-) create mode 100644 phpBB/includes/db/dbal.php (limited to 'phpBB') 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 @@ +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 = 'SQL ERROR [ ' . SQL_LAYER . ' ]

' . $error['message'] . ' [' . $error['code'] . ']

CALLING PAGE

' . htmlspecialchars($this_page) . (($sql != '') ? '

SQL

' . $sql : '') . '
'; + + 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 '' . $msg_title . ''; + echo '
phpBB LogoSQL Report      

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' : '') . '
Time spent on MySQL queries: ' . round($this->sql_time, 5) . 's | Time spent on PHP: ' . round($totaltime - $this->sql_time, 5) . 's
'; + echo $sql_report; + echo '

'; + exit; + break; + + case 'stop': + $endtime = explode(' ', microtime()); + $endtime = $endtime[0] + $endtime[1]; + + $sql_report .= '

Query #' . $this->num_queries . '
' . $html_hold . '

'; + + if ($this->query_result) + { + if (preg_match('/^(UPDATE|DELETE|REPLACE)/', $query)) + { + $sql_report .= "Affected rows: " . $this->sql_affectedrows($this->query_result) . ' | '; + } + $sql_report .= 'Before: ' . sprintf('%.5f', $curtime - $starttime) . 's | After: ' . sprintf('%.5f', $endtime - $starttime) . 's | Elapsed: ' . sprintf('%.5f', $endtime - $curtime) . 's'; + } + else + { + $error = $this->sql_error(); + $sql_report .= 'FAILED - ' . SQL_LAYER . ' Error ' . $error['code'] . ': ' . htmlspecialchars($error['message']); + } + + $sql_report .= '

'; + + $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 @@ 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 = 'SQL ERROR [ ' . SQL_LAYER . ' ]

' . @ibase_errmsg() . '

CALLING PAGE

' . $this_page .(($sql != '') ? '

SQL

' . $sql : '') . '
'; - - 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 '' . $msg_title . ''; - echo '
phpBB LogoSQL Report      

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' : '') . '
Time spent on MySQL queries: ' . round($this->sql_time, 5) . 's | Time spent on PHP: ' . round($totaltime - $this->sql_time, 5) . 's
'; - echo $sql_report; - echo '

'; - 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 .= '

Query #' . $this->num_queries . '
' . $html_hold . '

'; - - if ($this->query_result) - { - if (preg_match('/^(UPDATE|DELETE|REPLACE)/', $query)) - { - $sql_report .= "Affected rows: " . $this->sql_affectedrows($this->query_result) . ' | '; - } - $sql_report .= 'Before: ' . sprintf('%.5f', $curtime - $starttime) . 's | After: ' . sprintf('%.5f', $endtime - $starttime) . 's | Elapsed: ' . sprintf('%.5f', $endtime - $curtime) . 's'; - } - else - { - $error = $this->sql_error(); - $sql_report .= 'FAILED - ' . SQL_LAYER . ' Error ' . $error['code'] . ': ' . htmlspecialchars($error['message']); - } - - $sql_report .= '

'; - - $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 @@ 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 = 'SQL ERROR [ ' . SQL_LAYER . ' ]

' . @mssql_get_last_message() . '

CALLING PAGE

' . htmlspecialchars($this_page) . (($sql != '') ? '

SQL

' . $sql : '') . '
'; - - 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 '' . $msg_title . ''; - echo '
phpBB LogoSQL Report      

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' : '') . '
Time spent on MySQL queries: ' . round($this->sql_time, 5) . 's | Time spent on PHP: ' . round($totaltime - $this->sql_time, 5) . 's
'; - echo $sql_report; - echo '

'; - 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 .= '

Query #' . $this->num_queries . '
' . $html_hold . '

'; - - if ($this->query_result) - { - if (preg_match('/^(UPDATE|DELETE|REPLACE)/', $query)) - { - $sql_report .= "Affected rows: " . $this->sql_affectedrows($this->query_result) . ' | '; - } - $sql_report .= 'Before: ' . sprintf('%.5f', $curtime - $starttime) . 's | After: ' . sprintf('%.5f', $endtime - $starttime) . 's | Elapsed: ' . sprintf('%.5f', $endtime - $curtime) . 's'; - } - else - { - $error = $this->sql_error(); - $sql_report .= 'FAILED - ' . SQL_LAYER . ' Error ' . $error['code'] . ': ' . htmlspecialchars($error['message']); - } - - $sql_report .= '

'; - - $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 @@ 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 = 'SQL ERROR [ ' . SQL_LAYER . ' ]

' . @mysql_error() . '

CALLING PAGE

' . htmlspecialchars($this_page) . (($sql != '') ? '

SQL

' . $sql : '') . '
'; - - 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 '' . $msg_title . ''; - echo '
phpBB LogoSQL Report      

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' : '') . '
Time spent on MySQL queries: ' . round($this->sql_time, 5) . 's | Time spent on PHP: ' . round($totaltime - $this->sql_time, 5) . 's
'; - echo $sql_report; - echo '

'; - 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 .= '

Query #' . $this->num_queries . '
' . $html_hold . '

'; - - if ($this->query_result) - { - if (preg_match('/^(UPDATE|DELETE|REPLACE)/', $query)) - { - $sql_report .= "Affected rows: " . $this->sql_affectedrows($this->query_result) . ' | '; - } - $sql_report .= 'Before: ' . sprintf('%.5f', $curtime - $starttime) . 's | After: ' . sprintf('%.5f', $endtime - $starttime) . 's | Elapsed: ' . sprintf('%.5f', $endtime - $curtime) . 's'; - } - else - { - $error = $this->sql_error(); - $sql_report .= 'FAILED - MySQL Error ' . $error['code'] . ': ' . htmlspecialchars($error['message']); - } - - $sql_report .= '

'; - - $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 @@ 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 = 'SQL ERROR [ ' . SQL_LAYER . ' ]

' . @mysql_error() . '

CALLING PAGE

' . htmlspecialchars($this_page) . (($sql != '') ? '

SQL

' . $sql : '') . '
'; - - 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 '' . $msg_title . ''; - echo '
phpBB LogoSQL Report      

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' : '') . '
Time spent on MySQL queries: ' . round($this->sql_time, 5) . 's | Time spent on PHP: ' . round($totaltime - $this->sql_time, 5) . 's
'; - echo $sql_report; - echo '

'; - 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 .= '

Query #' . $this->num_queries . '
' . $html_hold . '

'; - - if ($this->query_result) - { - if (preg_match('/^(UPDATE|DELETE|REPLACE)/', $query)) - { - $sql_report .= "Affected rows: " . $this->sql_affectedrows($this->query_result) . ' | '; - } - $sql_report .= 'Before: ' . sprintf('%.5f', $curtime - $starttime) . 's | After: ' . sprintf('%.5f', $endtime - $starttime) . 's | Elapsed: ' . sprintf('%.5f', $endtime - $curtime) . 's'; - } - else - { - $error = $this->sql_error(); - $sql_report .= 'FAILED - MySQL Error ' . $error['code'] . ': ' . htmlspecialchars($error['message']); - } - - $sql_report .= '

'; - - $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 @@ 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 = 'SQL ERROR [ ' . SQL_LAYER . ' ]

' . @mysqli_error($this->db_connect_id) . '

CALLING PAGE

' . htmlspecialchars($this_page) . (($sql != '') ? '

SQL

' . $sql : '') . '
'; - - 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 '' . $msg_title . ''; - echo '
phpBB LogoSQL Report      

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' : '') . '
Time spent on MySQL queries: ' . round($this->sql_time, 5) . 's | Time spent on PHP: ' . round($totaltime - $this->sql_time, 5) . 's
'; - echo $sql_report; - echo '

'; - 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 .= '

Query #' . $this->num_queries . '
' . $html_hold . '

'; - - if ($this->query_result) - { - if (preg_match('/^(UPDATE|DELETE|REPLACE)/', $query)) - { - $sql_report .= "Affected rows: " . $this->sql_affectedrows($this->query_result) . ' | '; - } - $sql_report .= 'Before: ' . sprintf('%.5f', $curtime - $starttime) . 's | After: ' . sprintf('%.5f', $endtime - $starttime) . 's | Elapsed: ' . sprintf('%.5f', $endtime - $curtime) . 's'; - } - else - { - $error = $this->sql_error(); - $sql_report .= 'FAILED - MySQL Error ' . $error['code'] . ': ' . htmlspecialchars($error['message']); - } - - $sql_report .= '

'; - - $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 @@ 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 = 'SQL ERROR [ ' . SQL_LAYER . ' ]

' . $error['message'] . ' [' . $error['code'] . ']

CALLING PAGE

' . htmlspecialchars($this_page) . (($sql != '') ? '

SQL

' . $sql : '') . '
'; - - 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 '' . $msg_title . ''; - echo '
phpBB LogoSQL Report      

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' : '') . '
Time spent on MySQL queries: ' . round($this->sql_time, 5) . 's | Time spent on PHP: ' . round($totaltime - $this->sql_time, 5) . 's
'; - echo $sql_report; - echo '

'; - 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 .= '

Query #' . $this->num_queries . '
' . $html_hold . '

'; - - if ($this->query_result) - { - if (preg_match('/^(UPDATE|DELETE|REPLACE)/', $query)) - { - $sql_report .= "Affected rows: " . $this->sql_affectedrows($this->query_result) . ' | '; - } - $sql_report .= 'Before: ' . sprintf('%.5f', $curtime - $starttime) . 's | After: ' . sprintf('%.5f', $endtime - $starttime) . 's | Elapsed: ' . sprintf('%.5f', $endtime - $curtime) . 's'; - } - else - { - $error = $this->sql_error(); - $sql_report .= 'FAILED - ' . SQL_LAYER . ' Error ' . $error['code'] . ': ' . htmlspecialchars($error['message']); - } - - $sql_report .= '

'; - - $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 @@ 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 = 'SQL ERROR [ ' . SQL_LAYER . ' ]

' . @pg_errormessage() . '

CALLING PAGE

' . htmlspecialchars($this_page) . (($sql != '') ? '

SQL

' . $sql : '') . '
'; - - 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 '' . $msg_title . ''; - echo '
phpBB LogoSQL Report      

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' : '') . '
Time spent on MySQL queries: ' . round($this->sql_time, 5) . 's | Time spent on PHP: ' . round($totaltime - $this->sql_time, 5) . 's
'; - echo $sql_report; - echo '

'; - 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 .= '

Query #' . $this->num_queries . '
' . $html_hold . '

'; - - if ($this->query_result) - { - if (preg_match('/^(UPDATE|DELETE|REPLACE)/', $query)) - { - $sql_report .= "Affected rows: " . $this->sql_affectedrows($this->query_result) . ' | '; - } - $sql_report .= 'Before: ' . sprintf('%.5f', $curtime - $starttime) . 's | After: ' . sprintf('%.5f', $endtime - $starttime) . 's | Elapsed: ' . sprintf('%.5f', $endtime - $curtime) . 's'; - } - else - { - $error = $this->sql_error(); - $sql_report .= 'FAILED - ' . SQL_LAYER . ' Error ' . $error['code'] . ': ' . htmlspecialchars($error['message']); - } - - $sql_report .= '

'; - - $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 @@ 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 = 'SQL ERROR [ ' . SQL_LAYER . ' ]

' . @sqlite_error_string(@sqlite_last_error($this->db_connect_id)) . '

CALLING PAGE

' . htmlspecialchars($this_page) . (($sql != '') ? '

SQL

' . $sql : '') . '
'; - - 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 '' . $msg_title . ''; - echo '
phpBB LogoSQL Report      

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' : '') . '
Time spent on MySQL queries: ' . round($this->sql_time, 5) . 's | Time spent on PHP: ' . round($totaltime - $this->sql_time, 5) . 's
'; - echo $sql_report; - echo '

'; - 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 .= '

Query #' . $this->num_queries . '
' . $html_hold . '

'; - - if ($this->query_result) - { - if (preg_match('/^(UPDATE|DELETE|REPLACE)/', $query)) - { - $sql_report .= "Affected rows: " . $this->sql_affectedrows($this->query_result) . ' | '; - } - $sql_report .= 'Before: ' . sprintf('%.5f', $curtime - $starttime) . 's | After: ' . sprintf('%.5f', $endtime - $starttime) . 's | Elapsed: ' . sprintf('%.5f', $endtime - $curtime) . 's'; - } - else - { - $error = $this->sql_error(); - $sql_report .= 'FAILED - ' . SQL_LAYER . ' Error ' . $error['code'] . ': ' . htmlspecialchars($error['message']); - } - - $sql_report .= '

'; - - $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' => 'User changed default group
» %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 -- cgit v1.2.1