Version 3.1.4

This commit is contained in:
Neo committed 2025-12-19 00:32:22 -08:00
1 parent 1d4720f3e2
commit ae5c01cc78
2563 files changed
+283048 -240689

No files matched your search

+86 -80
View File
@@ -1,18 +1,21 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.0.5
* IP.Board v3.1.4
* MySQL Database Driver :: MySQLi client
* Last Updated: $Date: 2009-09-15 08:34:24 -0400 (Tue, 15 Sep 2009) $
* Last Updated: $Date: 2010-10-06 12:04:54 -0400 (Wed, 06 Oct 2010) $
* </pre>
*
* @author $Author: matt $
* @author $Author: mmecham $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.iinvisionpower.com/community/board/license.html
* @package Invision Power Services Kernel
* @link http://www.iinvisionpower.com
* @license http://www.invisionpower.com/community/board/license.html
* @package IP.Board
* @subpackage Kernel
* @link http://www.invisionpower.com
* @since Monday 28th February 2005 16:46
* @version $Revision: 327 $
* @version $Revision: 473 $
*/
class db_driver_mysql extends db_main_mysql implements interfaceDb
@@ -24,7 +27,7 @@ class db_driver_mysql extends db_main_mysql implements interfaceDb
* @var boolean Connection failed
*/
private $connect_failed = false;
/**
* constructor
*
@@ -37,11 +40,11 @@ class db_driver_mysql extends db_main_mysql implements interfaceDb
{
define( 'MYSQLI_USED', 1 );
}
//--------------------------------------
// Set up any required connect vars here
//--------------------------------------
$this->connect_vars['mysql_tbl_type'] = "";
}
@@ -56,28 +59,28 @@ class db_driver_mysql extends db_main_mysql implements interfaceDb
//-----------------------------------------
// Done SQL prefix yet?
//-----------------------------------------
$this->_setPrefix();
//-----------------------------------------
// Load query file
//-----------------------------------------
$this->_loadCacheFile();
//-----------------------------------------
// Connect
//-----------------------------------------
/* Did we add a port inline? */
if ( ! $this->obj['sql_port'] AND strstr( $this->obj['sql_host'], ':' ) )
{
list( $host, $port ) = explode( ':', $this->obj['sql_host'] );
$this->obj['sql_host'] = $host;
$this->obj['sql_port'] = intval( $port );
}
if( $this->obj['sql_port'] )
{
$this->connection_id = @mysqli_connect( $this->obj['sql_host'] ,
@@ -95,28 +98,29 @@ class db_driver_mysql extends db_main_mysql implements interfaceDb
$this->obj['sql_database']
);
}
if ( ! $this->connection_id )
{
$this->usingClass = 'db_driver_mysql';
$this->connect_failed = true;
$this->throwFatalError();
return FALSE;
}
mysqli_autocommit( $this->connection_id, TRUE );
//-----------------------------------------
// Remove sensitive data
//-----------------------------------------
unset( $this->obj['sql_host'] );
unset( $this->obj['sql_user'] );
unset( $this->obj['sql_pass'] );
//-----------------------------------------
// If there's a charset set, run it
//-----------------------------------------
if( $this->obj['sql_charset'] )
{
$this->query( "SET NAMES '{$this->obj['sql_charset']}'" );
@@ -134,7 +138,7 @@ class db_driver_mysql extends db_main_mysql implements interfaceDb
return TRUE;
}
/**
* Close database connection
*
@@ -148,7 +152,7 @@ class db_driver_mysql extends db_main_mysql implements interfaceDb
return @mysqli_close( $this->connection_id );
}
}
/**
* Execute a direct database query
*
@@ -162,12 +166,12 @@ class db_driver_mysql extends db_main_mysql implements interfaceDb
//-----------------------------------------
// Change the table prefix if needed
//-----------------------------------------
if ( $this->no_prefix_convert )
{
$bypass = 1;
}
if ( ! $bypass )
{
if ( $this->obj['sql_tbl_prefix'] != "ibf_" and ! $this->prefix_changed )
@@ -218,7 +222,7 @@ class db_driver_mysql extends db_main_mysql implements interfaceDb
}
}
}
//-----------------------------------------
// Run the query
//-----------------------------------------
@@ -228,7 +232,7 @@ class db_driver_mysql extends db_main_mysql implements interfaceDb
//-----------------------------------------
// Reset array...
//-----------------------------------------
$this->force_data_type = array();
$this->allow_sub_select = false;
@@ -236,25 +240,25 @@ class db_driver_mysql extends db_main_mysql implements interfaceDb
{
$this->throwFatalError("mySQL query error: $the_query");
}
//-----------------------------------------
// Logging?
//-----------------------------------------
if ( ( $this->obj['use_debug_log'] AND $this->obj['debug_log'] ) OR ( $this->obj['use_bad_log'] AND $this->obj['bad_log'] ) OR ( $this->obj['use_slow_log'] AND $this->obj['slow_log'] ) )
{
$endtime = IPSDebug::endTimer();
$_data = '';
if ( preg_match( "/^(?:\()?select/i", $the_query ) )
{
$eid = mysqli_query($this->connection_id, "EXPLAIN {$the_query}");
$_bad = false;
while( $array = mysqli_fetch_array($eid) )
{
$array['extra'] = isset( $array['extra'] ) ? $array['extra'] : '';
$_data .= "\n+------------------------------------------------------------------------------+";
$_data .= "\n|Table: ". $array['table'];
$_data .= "\n|Type: ". $array['type'];
@@ -265,18 +269,18 @@ class db_driver_mysql extends db_main_mysql implements interfaceDb
$_data .= "\n|Rows: ". $array['rows'];
$_data .= "\n|Extra: ". $array['Extra'];
//$_data .= "\n+------------------------------------------------------------------------------+";
if ( ( $this->obj['use_bad_log'] AND $this->obj['bad_log'] ) AND stristr( $array['Extra'], 'filesort' ) OR stristr( $array['Extra'], 'temporary' ) )
{
$this->writeDebugLog( $the_query, $_data, $endtime, $this->obj['bad_log'], TRUE );
}
if ( ( $this->obj['use_slow_log'] AND $this->obj['slow_log'] ) AND $endtime >= $this->obj['use_slow_log'] )
{
$this->writeDebugLog( $the_query, $_data, $endtime, $this->obj['slow_log'], TRUE );
}
}
if ( $this->obj['use_debug_log'] AND $this->obj['debug_log'] )
{
$this->writeDebugLog( $the_query, $_data, $endtime );
@@ -290,22 +294,22 @@ class db_driver_mysql extends db_main_mysql implements interfaceDb
}
}
}
//-----------------------------------------
// Debugging?
//-----------------------------------------
if ($this->obj['debug'])
{
$endtime = IPSDebug::endTimer();
$memoryUsed = IPSDebug::setMemoryDebugFlag( '', $_MEMORY );
$memory = '';
$shutdown = $this->is_shutdown ? 'SHUTDOWN QUERY: ' : '';
if ( preg_match( "/^(?:\()?select/i", $the_query ) )
{
$eid = mysqli_query( $this->connection_id, "EXPLAIN {$the_query}" );
$this->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>{$shutdown}Select Query</b></td>
@@ -321,7 +325,7 @@ class db_driver_mysql extends db_main_mysql implements interfaceDb
while( $array = mysqli_fetch_array($eid) )
{
$type_col = '#FFFFFF';
if ($array['type'] == 'ref' or $array['type'] == 'eq_ref' or $array['type'] == 'const')
{
$type_col = '#D8FFD4';
@@ -330,7 +334,7 @@ class db_driver_mysql extends db_main_mysql implements interfaceDb
{
$type_col = '#FFEEBA';
}
$this->debug_html .= "<tr bgcolor='#FFFFFF'>
<td>$array[table]&nbsp;</td>
<td bgcolor='$type_col'>$array[type]&nbsp;</td>
@@ -342,19 +346,19 @@ class db_driver_mysql extends db_main_mysql implements interfaceDb
<td>$array[Extra]&nbsp;</td>
</tr>\n";
}
$this->sql_time += $endtime;
if ($endtime > 0.1)
{
$endtime = "<span style='color:red'><b>$endtime</b></span>";
}
if ( $memoryUsed )
{
$memory = '<br />Memory Used: ' . IPSLib::sizeFormat( $memoryUsed, TRUE );
}
$this->debug_html .= "<tr>
<td colspan='8' bgcolor='#FFD6DC' style='font-size:14px'><b>MySQL time</b>: $endtime{$memory}</b></td>
</tr>
@@ -375,11 +379,11 @@ class db_driver_mysql extends db_main_mysql implements interfaceDb
</table><br />\n\n";
}
}
$this->query_count++;
$this->obj['cached_queries'][] = $the_query;
return $this->query_id;
}
@@ -393,7 +397,7 @@ class db_driver_mysql extends db_main_mysql implements interfaceDb
{
return mysqli_affected_rows( $this->connection_id );
}
/**
* Retrieve number of rows in result set
*
@@ -410,7 +414,7 @@ class db_driver_mysql extends db_main_mysql implements interfaceDb
return mysqli_num_rows( $query_id );
}
/**
* Retrieve latest autoincrement insert id
*
@@ -421,7 +425,7 @@ class db_driver_mysql extends db_main_mysql implements interfaceDb
{
return mysqli_insert_id($this->connection_id);
}
/**
* Retrieve the current thread id
*
@@ -431,8 +435,8 @@ class db_driver_mysql extends db_main_mysql implements interfaceDb
public function getThreadId()
{
return mysqli_thread_id($this->connection_id);
}
}
/**
* Free result set from memory
*
@@ -446,10 +450,10 @@ class db_driver_mysql extends db_main_mysql implements interfaceDb
{
$query_id = $this->query_id;
}
@mysqli_free_result( $query_id );
}
/**
* Retrieve row from database
*
@@ -460,14 +464,14 @@ class db_driver_mysql extends db_main_mysql implements interfaceDb
public function fetch( $query_id=null )
{
//$_MEMORY = IPSDebug::getMemoryDebugFlag();
if ( ! $query_id )
{
$query_id = $this->query_id;
}
$this->record_row = mysqli_fetch_assoc( $query_id );
/*if ( is_array( $this->record_row ) )
{
$tmp = $this->record_row;
@@ -490,11 +494,13 @@ $this->_tmpT += $poo;*/
{
$calcRowsHandle = mysqli_query( $this->connection_id, "SELECT FOUND_ROWS() as " . $alias );
$val = mysqli_fetch_assoc( $calcRowsHandle );
$this->obj['cached_queries'][] = "SELECT FOUND_ROWS() as " . $alias;
$val = mysqli_fetch_assoc( $calcRowsHandle );
return intval( $val[ $alias ] );
}
/**
* Get array of fields in result set
*
@@ -505,17 +511,17 @@ $this->_tmpT += $poo;*/
public function getResultFields( $query_id=null )
{
$fields = array();
if ( !$query_id )
{
$query_id = $this->query_id;
}
while( $field = mysqli_fetch_field($query_id) )
{
$fields[] = $field;
}
return $fields;
}
@@ -531,14 +537,14 @@ $this->_tmpT += $poo;*/
{
return $this->cached_tables;
}
$current = $this->return_die;
$this->return_die = true;
$qid = $this->query( "SHOW TABLES FROM `{$this->obj['sql_database']}`" );
$this->return_die = $current;
if( $qid AND $this->getTotalRows($qid) )
{
while( $result = mysqli_fetch_array($qid) )
@@ -546,11 +552,11 @@ $this->_tmpT += $poo;*/
$this->cached_tables[] = $result[0];
}
}
mysqli_free_result($qid);
return $this->cached_tables;
}
}
/**
* Retrieve SQL server version
@@ -563,13 +569,13 @@ $this->_tmpT += $poo;*/
if ( ! $this->sql_version and ! $this->true_version )
{
$version = mysqli_get_server_info($this->connection_id);
$this->true_version = $version;
$tmp = explode( '.', preg_replace( "#[^\d\.]#", "\\1", $version ) );
$this->sql_version = sprintf('%d%02d%02d', $tmp[0], $tmp[1], $tmp[2] );
}
return $this->sql_version;
}
@@ -582,7 +588,7 @@ $this->_tmpT += $poo;*/
*/
public function addSlashes( $t )
{
return mysqli_real_escape_string( $this->connection_id, $t );
return @mysqli_real_escape_string( $this->connection_id, $t );
}
/**
@@ -602,7 +608,7 @@ $this->_tmpT += $poo;*/
return mysqli_errno( $this->connection_id );
}
}
/**
* Get SQL error message
*
@@ -610,7 +616,7 @@ $this->_tmpT += $poo;*/
* @return string Error message
*/
protected function _getErrorString()
{
{
if( $this->connect_failed )
{
return mysqli_connect_error( );
@@ -620,6 +626,6 @@ $this->_tmpT += $poo;*/
return mysqli_error( $this->connection_id );
}
}
} // end class