Version 1.1.1
This commit is contained in:
1 parent
aabfdc1f57
commit
7ef3d1712a
179 files changed
+57457
-44972
No files matched your search
@@ -2,10 +2,10 @@
|
||||
|
||||
/*
|
||||
+--------------------------------------------------------------------------
|
||||
| IBFORUMS v1
|
||||
| Invision Board v1.1
|
||||
| ========================================
|
||||
| by Matthew Mecham and David Baxter
|
||||
| (c) 2001,2002 IBForums
|
||||
| by Matthew Mecham
|
||||
| (c) 2001,2002 Invision Power Services
|
||||
| http://www.ibforums.com
|
||||
| ========================================
|
||||
| Web: http://www.ibforums.com
|
||||
@@ -33,12 +33,15 @@ class db_driver {
|
||||
"persistent" => "0" ,
|
||||
"sql_tbl_prefix" => "ibf_" ,
|
||||
"cached_queries" => array(),
|
||||
'debug' => 0,
|
||||
);
|
||||
|
||||
var $query_id = "";
|
||||
var $connection_id = "";
|
||||
var $query_count = 0;
|
||||
var $record_row = array();
|
||||
var $return_die = 0;
|
||||
var $error = "";
|
||||
|
||||
/*========================================================================*/
|
||||
// Connect to the database
|
||||
@@ -74,7 +77,7 @@ class db_driver {
|
||||
/*========================================================================*/
|
||||
|
||||
function query($the_query) {
|
||||
|
||||
|
||||
//--------------------------------------
|
||||
// Change the table prefix if needed
|
||||
//--------------------------------------
|
||||
@@ -84,6 +87,13 @@ class db_driver {
|
||||
$the_query = preg_replace("/ibf_(\S+?)([\s\.,]|$)/", $this->obj['sql_tbl_prefix']."\\1\\2", $the_query);
|
||||
}
|
||||
|
||||
if ($this->obj['debug'])
|
||||
{
|
||||
global $Debug, $ibforums;
|
||||
|
||||
$Debug->startTimer();
|
||||
}
|
||||
|
||||
$this->query_id = mysql_query($the_query, $this->connection_id);
|
||||
|
||||
if (! $this->query_id )
|
||||
@@ -91,7 +101,77 @@ class db_driver {
|
||||
$this->fatal_error("mySQL query error: $the_query");
|
||||
}
|
||||
|
||||
$this->query_count++;
|
||||
if ($this->obj['debug'])
|
||||
{
|
||||
$endtime = $Debug->endTimer();
|
||||
|
||||
if ( preg_match( "/^select/i", $the_query ) )
|
||||
{
|
||||
$eid = mysql_query("EXPLAIN $the_query", $this->connection_id);
|
||||
$ibforums->debug_html .= "<table width='95%' border='1' cellpadding='6' cellspacing='0' bgcolor='#FFE8F3' align='center'>
|
||||
<tr>
|
||||
<td colspan='8' style='font-size:14px' bgcolor='#FFC5Cb'><b>Select Query</b></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan='8' style='font-family:courier new, courier, monaco, arial;font-size:14px'>$the_query</td>
|
||||
</tr>
|
||||
<tr bgcolor='#FFC5Cb'>
|
||||
<td><b>table</b></td><td><b>type</b></td><td><b>possible_keys</b></td>
|
||||
<td><b>key</b></td><td><b>key_len</b></td><td><b>ref</b></td>
|
||||
<td><b>rows</b></td><td><b>Extra</b></td>
|
||||
</tr>\n";
|
||||
while( $array = mysql_fetch_array($eid) )
|
||||
{
|
||||
$type_col = '#FFFFFF';
|
||||
|
||||
if ($array['type'] == 'ref' or $array['type'] == 'eq_ref' or $array['type'] == 'const')
|
||||
{
|
||||
$type_col = '#D8FFD4';
|
||||
}
|
||||
else if ($array['type'] == 'ALL')
|
||||
{
|
||||
$type_col = '#FFEEBA';
|
||||
}
|
||||
|
||||
$ibforums->debug_html .= "<tr bgcolor='#FFFFFF'>
|
||||
<td>$array[table] </td>
|
||||
<td bgcolor='$type_col'>$array[type] </td>
|
||||
<td>$array[possible_keys] </td>
|
||||
<td>$array[key] </td>
|
||||
<td>$array[key_len] </td>
|
||||
<td>$array[ref] </td>
|
||||
<td>$array[rows] </td>
|
||||
<td>$array[Extra] </td>
|
||||
</tr>\n";
|
||||
}
|
||||
|
||||
if ($endtime > 0.1)
|
||||
{
|
||||
$endtime = "<span style='color:red'><b>$endtime</b></span>";
|
||||
}
|
||||
|
||||
$ibforums->debug_html .= "<tr>
|
||||
<td colspan='8' bgcolor='#FFD6DC' style='font-size:14px'><b>mySQL time</b>: $endtime</b></td>
|
||||
</tr>
|
||||
</table>\n<br />\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
$ibforums->debug_html .= "<table width='95%' border='1' cellpadding='6' cellspacing='0' bgcolor='#FEFEFE' align='center'>
|
||||
<tr>
|
||||
<td style='font-size:14px' bgcolor='#EFEFEF'><b>Non Select Query</b></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style='font-family:courier new, courier, monaco, arial;font-size:14px'>$the_query</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style='font-size:14px' bgcolor='#EFEFEF'><b>mySQL time</b>: $endtime</span></td>
|
||||
</tr>
|
||||
</table><br />\n\n";
|
||||
}
|
||||
}
|
||||
|
||||
$this->query_count++;
|
||||
|
||||
$this->obj['cached_queries'][] = $the_query;
|
||||
|
||||
@@ -167,7 +247,46 @@ class db_driver {
|
||||
|
||||
function close_db() {
|
||||
return mysql_close($this->connection_id);
|
||||
}
|
||||
}
|
||||
|
||||
/*========================================================================*/
|
||||
// Return an array of tables
|
||||
/*========================================================================*/
|
||||
|
||||
function get_table_names() {
|
||||
|
||||
$result = mysql_list_tables($this->obj['sql_database']);
|
||||
$num_tables = @mysql_numrows($result);
|
||||
for ($i = 0; $i < $num_tables; $i++)
|
||||
{
|
||||
$tables[] = mysql_tablename($result, $i);
|
||||
}
|
||||
|
||||
mysql_free_result($result);
|
||||
|
||||
return $tables;
|
||||
}
|
||||
|
||||
/*========================================================================*/
|
||||
// Return an array of fields
|
||||
/*========================================================================*/
|
||||
|
||||
function get_result_fields($query_id="") {
|
||||
|
||||
if ($query_id == "")
|
||||
{
|
||||
$query_id = $this->query_id;
|
||||
}
|
||||
|
||||
while ($field = mysql_fetch_field($query_id))
|
||||
{
|
||||
$Fields[] = $field;
|
||||
}
|
||||
|
||||
//mysql_free_result($query_id);
|
||||
|
||||
return $Fields;
|
||||
}
|
||||
|
||||
/*========================================================================*/
|
||||
// Basic error handler
|
||||
@@ -176,6 +295,15 @@ class db_driver {
|
||||
function fatal_error($the_error) {
|
||||
global $INFO;
|
||||
|
||||
|
||||
// Are we simply returning the error?
|
||||
|
||||
if ($this->return_die == 1)
|
||||
{
|
||||
$this->error = mysql_error();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
$the_error .= "\n\nmySQL error: ".mysql_error()."\n";
|
||||
$the_error .= "mySQL error code: ".mysql_errno()."\n";
|
||||
$the_error .= "Date: ".date("l dS of F Y h:i:s A");
|
||||
@@ -206,6 +334,7 @@ class db_driver {
|
||||
|
||||
foreach ($data as $k => $v) {
|
||||
$v = preg_replace( "/'/", "\\'", $v );
|
||||
//$v = preg_replace( "/#/", "\\#", $v );
|
||||
$field_names .= "$k,";
|
||||
$field_values .= "'$v',";
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user