Version 2.3.6
This commit is contained in:
1 parent
a3bb603c96
commit
19b38c7c74
764 files changed
+143731
-118164
No files matched your search
@@ -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
|
||||
@@ -75,6 +68,8 @@ if ( ! defined('IPS_MAIN_DB_CLASS_LEGACY') )
|
||||
*/
|
||||
class db_driver_mysql extends db_main
|
||||
{
|
||||
var $cached_fields = array();
|
||||
var $cached_tables = array();
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
// Set up required vars
|
||||
@@ -153,30 +148,13 @@ class db_driver_mysql extends db_main
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
$this->sql_set_collation_and_cp();
|
||||
|
||||
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 = mysql_query( "SHOW CHARSET LIKE '" . $this->obj['mysql_codepage'] . "'", $this->connection_id );
|
||||
|
||||
$charset = mysql_fetch_row($res);
|
||||
|
||||
mysql_query( "SET NAMES " . $this->obj['mysql_codepage'], $this->connection_id );
|
||||
mysql_query( "SET CHARACTER SET " . $this->obj['mysql_codepage'], $this->connection_id );
|
||||
mysql_query( "SET character_set_connection = " . $this->obj['mysql_codepage'], $this->connection_id );
|
||||
mysql_query( "SET collation_connection = " . $charset[2], $this->connection_id );
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
function sql_can_subquery()
|
||||
{
|
||||
$this->sql_get_version();
|
||||
@@ -240,6 +218,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;
|
||||
}
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
// Quick function: DO INSERT
|
||||
/*-------------------------------------------------------------------------*/
|
||||
@@ -556,20 +580,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;
|
||||
}
|
||||
}
|
||||
@@ -591,7 +615,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");
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
@@ -620,7 +644,7 @@ class db_driver_mysql extends db_main
|
||||
$_data .= "\n+------------------------------------------------------------------------------+";
|
||||
}
|
||||
|
||||
$this->write_debug_log( $query, $_data, $endtime );
|
||||
$this->write_debug_log( $the_query, $_data, $endtime );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -747,9 +771,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}" );
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
@@ -785,8 +816,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);
|
||||
@@ -941,17 +976,22 @@ 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;
|
||||
}
|
||||
|
||||
$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);
|
||||
$this->cached_tables[] = mysql_tablename($result, $i);
|
||||
}
|
||||
|
||||
// free result docs say only for select, explain, describe, show queries
|
||||
//mysql_free_result($result);
|
||||
|
||||
return $tables;
|
||||
return $this->cached_tables;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
@@ -964,7 +1004,7 @@ class db_driver_mysql extends db_main
|
||||
|
||||
$return = 0;
|
||||
|
||||
if ( in_array( SQL_PREFIX.$table, $table_names ) )
|
||||
if ( in_array( $this->obj['sql_tbl_prefix'].$table, $table_names ) )
|
||||
{
|
||||
$return = 1;
|
||||
}
|
||||
@@ -973,6 +1013,52 @@ class db_driver_mysql extends db_main
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
@@ -1001,9 +1087,14 @@ class db_driver_mysql extends db_main
|
||||
|
||||
function _get_error_number()
|
||||
{
|
||||
$conid = $this->connection_id ? $this->connection_id : '';
|
||||
|
||||
return @mysql_errno( $conid );
|
||||
if( $this->connection_id )
|
||||
{
|
||||
return @mysql_errno( $this->connection_id );
|
||||
}
|
||||
else
|
||||
{
|
||||
return @mysql_errno();
|
||||
}
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
@@ -1012,9 +1103,14 @@ class db_driver_mysql extends db_main
|
||||
|
||||
function _get_error_string()
|
||||
{
|
||||
$conid = $this->connection_id ? $this->connection_id : '';
|
||||
|
||||
return @mysql_error( $conid );
|
||||
if( $this->connection_id )
|
||||
{
|
||||
return @mysql_error( $this->connection_id );
|
||||
}
|
||||
else
|
||||
{
|
||||
return @mysql_error();
|
||||
}
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
Reference in new issue
Block a user