Version 2.3.6

This commit is contained in:
Neo committed 2025-12-19 00:26:08 -08:00
1 parent a3bb603c96
commit 19b38c7c74
764 files changed
+143731 -118164

No files matched your search

+156 -48
View File
@@ -3,22 +3,15 @@
/*
+--------------------------------------------------------------------------
| Invision Power Services Kernel [DB Abstraction]
| Invision Power Board 2.2.2
| Invision Power Board
| =============================================
| by Matthew Mecham
| (c) 2001 - 2006 Invision Power Services, Inc.
| http://www.invisionpower.com
| =============================================
| Web: http://www.invisionboard.com
| http://www.ibresource.ru/products/invisionpowerboard/
| Time: Monday 05th of March 2007 10:10:55 PM
| Release: e3790216629e5a2aaf37070b32237f06
| Licence Info: http://www.invisionboard.com/?license
| http://www.ibresource.ru/license
+---------------------------------------------------------------------------
| INVISION POWER BOARD ÍÅ ßÂËßÅÒÑß ÁÅÑÏËÀÒÍÛÌ ÏÐÎÃÐÀÌÌÍÛÌ ÎÁÅÑÏÅ×ÅÍÈÅÌ!
| Ïðàâà íà ÏÎ ïðèíàäëåæàò Invision Power Services
| Ïðàâà íà ïåðåâîä IBResource (http://www.ibresource.ru)
| THIS IS NOT FREE / OPEN SOURCE SOFTWARE
+---------------------------------------------------------------------------
|
| > MySQLi Driver Module
@@ -78,6 +71,9 @@ class db_driver_mysql extends db_main
{
var $connect_failed = 0;
var $cached_fields = array();
var $cached_tables = array();
/*-------------------------------------------------------------------------*/
// Set up required vars
/*-------------------------------------------------------------------------*/
@@ -123,10 +119,23 @@ class db_driver_mysql extends db_main
// Connect
//-----------------------------------------
$this->connection_id = @mysqli_connect( $this->obj['sql_host'] ,
$this->obj['sql_user'] ,
$this->obj['sql_pass']
);
if( $this->obj['sql_port'] )
{
$this->connection_id = @mysqli_connect( $this->obj['sql_host'] ,
$this->obj['sql_user'] ,
$this->obj['sql_pass'],
$this->obj['sql_database'],
$this->obj['sql_port']
);
}
else
{
$this->connection_id = @mysqli_connect( $this->obj['sql_host'] ,
$this->obj['sql_user'] ,
$this->obj['sql_pass'],
$this->obj['sql_database']
);
}
if ( ! $this->connection_id )
{
@@ -135,37 +144,21 @@ class db_driver_mysql extends db_main
return FALSE;
}
if ( ! mysqli_select_db( $this->connection_id, $this->obj['sql_database'] ) )
/*if ( ! mysqli_select_db( $this->connection_id, $this->obj['sql_database'] ) )
{
$this->fatal_error();
return FALSE;
}
}*/
$this->sql_set_collation_and_cp();
mysqli_autocommit( $this->connection_id, TRUE );
unset( $this->obj['sql_host'] );
unset( $this->obj['sql_user'] );
unset( $this->obj['sql_pass'] );
return TRUE;
}
function sql_set_collation_and_cp()
{
$this->sql_get_version();
if ( $this->mysql_version >= 40101 )
{
$res = mysqli_query( $this->connection_id, "SHOW CHARSET LIKE '" . $this->obj['mysql_codepage'] . "'");
$charset = mysqli_fetch_row($res);
mysqli_query( $this->connection_id, "SET NAMES " . $this->obj['mysql_codepage'] );
mysqli_query( $this->connection_id, "SET CHARACTER SET " . $this->obj['mysql_codepage'] );
mysqli_query( $this->connection_id, "SET character_set_connection = " . $this->obj['mysql_codepage'] );
mysqli_query( $this->connection_id, "SET collation_connection = " . $charset[2] );
}
return TRUE;
}
function sql_can_subquery()
{
$this->sql_get_version();
@@ -211,7 +204,7 @@ class db_driver_mysql extends db_main
$this->is_shutdown = 1;
$return = $this->query( $query );
$this->no_prefix_convert = 0;
$this->is_shutdown = 1;
$this->is_shutdown = 0;
return $return;
}
else
@@ -274,6 +267,52 @@ class db_driver_mysql extends db_main
}
}
/*-------------------------------------------------------------------------*/
// Quick function: DO REPLACE INTO
/*-------------------------------------------------------------------------*/
function do_replace_into( $tbl, $arr, $where='', $shutdown=FALSE )
{
//-----------------------------------------
// Form query
//-----------------------------------------
$dba = $this->compile_db_insert_string( $arr );
$query = "REPLACE INTO ".$this->obj['sql_tbl_prefix']."$tbl ({$dba['FIELD_NAMES']}) VALUES({$dba['FIELD_VALUES']})";
//-----------------------------------------
// Shut down query?
//-----------------------------------------
$this->no_prefix_convert = 1;
if ( $shutdown )
{
if ( ! $this->obj['use_shutdown'] )
{
$this->is_shutdown = 1;
$return = $this->query( $query );
$this->no_prefix_convert = 0;
$this->is_shutdown = 1;
return $return;
}
else
{
$this->obj['shutdown_queries'][] = $query;
$this->no_prefix_convert = 0;
$this->cur_query = "";
}
}
else
{
$return = $this->query( $query );
$this->no_prefix_convert = 0;
return $return;
}
}
/*-------------------------------------------------------------------------*/
// SIMPLE: UPDATE
/*-------------------------------------------------------------------------*/
@@ -545,20 +584,20 @@ class db_driver_mysql extends db_main
if ( preg_match( "#(?:/\*|\*/)#i", $_tmp ) )
{
$this->fatal_error( "Íàñòðîéêè äðàéâåðà íå äîïóñêàþò èñïîëüçîâàíèå êîììåíòàðèåâ â SQL çàïðîñå.\nÈçìåíèòå àòðèáóò allow_sub_select íà 1 ó îáúåêòà äðàéâåðà äëÿ âûêëþ÷åíèÿ ýòîé ïðîâåðêè." );
$this->fatal_error( "You are not allowed to use comments in your SQL query.\nAdd \$this->ipsclass->DB->allow_sub_select=1; before any query construct to allow them" );
return false;
}
if ( preg_match( "#[^_a-zA-Z]union[^_a-zA-Z]#s", $_tmp ) )
{
$this->fatal_error( "Íàñòðîéêè äðàéâåðà íå ïîçâîëÿþò èñïîëüçîâàòü UNION-çàïðîñû.\nÈçìåíèòå àòðèáóò allow_sub_select íà 1 ó îáúåêòà äðàéâåðà äëÿ âûêëþ÷åíèÿ ýòîé ïðîâåðêè." );
$this->fatal_error( "UNION query joins are not allowed.\nAdd \$this->ipsclass->DB->allow_sub_select=1; before any query construct to allow them" );
return false;
}
else if ( preg_match_all( "#[^_a-zA-Z](select)[^_a-zA-Z]#s", $_tmp, $matches ) )
{
if ( count( $matches ) > 1 )
{
$this->fatal_error( "Íàñòðîéêè äðàéâåðà íå ïîçâîëÿþò èñïîëüçîâàòü âëîæåííûå SELECT â çàïðîñàõ.\nÈçìåíèòå àòðèáóò allow_sub_select íà 1 ó îáúåêòà äðàéâåðà äëÿ âûêëþ÷åíèÿ ýòîé ïðîâåðêè." );
$this->fatal_error( "SUB SELECT query joins are not allowed.\nAdd \$this->ipsclass->DB->allow_sub_select=1; before any query construct to allow them" );
return false;
}
}
@@ -580,7 +619,7 @@ class db_driver_mysql extends db_main
if (! $this->query_id )
{
$this->fatal_error($the_query);
$this->fatal_error("mySQL query error: $the_query");
}
//-----------------------------------------
@@ -704,7 +743,7 @@ class db_driver_mysql extends db_main
function fetch_row($query_id = "")
{
if ( !$query_id )
if ( ! $query_id )
{
$query_id = $this->query_id;
}
@@ -736,9 +775,16 @@ class db_driver_mysql extends db_main
// ADD FIELD
/*-------------------------------------------------------------------------*/
function sql_add_field( $table, $field_name, $field_type, $field_default="''" )
function sql_add_field( $table, $field_name, $field_type, $field_default='' )
{
$this->query( "ALTER TABLE ".$this->obj['sql_tbl_prefix']."{$table} ADD $field_name $field_type default {$field_default}" );
$default = 'NULL';
if( $field_default !== '' )
{
$default = "default {$field_default}";
}
$this->query( "ALTER TABLE ".$this->obj['sql_tbl_prefix']."{$table} ADD {$field_name} {$field_type} {$default}" );
}
/*-------------------------------------------------------------------------*/
@@ -774,8 +820,12 @@ class db_driver_mysql extends db_main
function sql_get_table_schematic( $table )
{
$this->return_die = 1;
$qid = $this->query( "SHOW CREATE TABLE ".$this->obj['sql_tbl_prefix']."{$table}" );
$this->return_die = 0;
if( $qid )
{
return $this->fetch_row($qid);
@@ -924,16 +974,29 @@ class db_driver_mysql extends db_main
function get_table_names()
{
if ( is_array( $this->cached_tables ) AND count( $this->cached_tables ) )
{
return $this->cached_tables;
}
$_tmp = $this->return_die;
$this->return_die = 1;
$tbl = $this->query( "SHOW TABLES FROM `{$this->obj['sql_database']}`" );
while( $result = mysqli_fetch_row($tbl) )
$this->return_die = $_tmp;
if( $tbl AND $this->get_num_rows($tbl) )
{
$tables[] = $result[0];
while( $result = mysqli_fetch_row($tbl) )
{
$this->cached_tables[] = $result[0];
}
}
mysqli_free_result($tbl);
return $tables;
return $this->cached_tables;
}
@@ -947,7 +1010,7 @@ class db_driver_mysql extends db_main
$return = 0;
if ( in_array( SQL_PREFIX.$table, $table_names ) )
if ( in_array( trim( $this->obj['sql_tbl_prefix'] . $table ), $table_names ) )
{
$return = 1;
}
@@ -955,7 +1018,52 @@ class db_driver_mysql extends db_main
unset($table_names);
return $return;
}
}
/*-------------------------------------------------------------------------*/
// Check if field exists
/*-------------------------------------------------------------------------*/
function field_exists($field, $table)
{
if( array_key_exists( $table, $this->cached_fields ) )
{
if( in_array( $field, $this->cached_fields[ $table ] ) )
{
return 1;
}
else
{
return 0;
}
}
$this->return_die = 1;
$this->error = "";
$return = 0;
$q = $this->query( "SHOW fields FROM " . $this->obj['sql_tbl_prefix'] . $table );
if( $q AND $this->get_num_rows($q) )
{
while( $check = $this->fetch_row($q) )
{
$this->cached_fields[ $table ][] = $check['Field'];
}
}
if ( !$this->failed AND in_array( $field, $this->cached_fields[ $table ] ) )
{
$return = 1;
}
$this->error = "";
$this->return_die = 0;
$this->error_no = 0;
$this->failed = 0;
return $return;
}
/*-------------------------------------------------------------------------*/
// Return an array of fields