Version 2.2.0 RC-1

This commit is contained in:
Neo committed 2025-12-19 00:22:37 -08:00
1 parent f73f8bff6d
commit 22f1b963ee
1034 files changed
+178610 -70897

No files matched your search

+183 -58
View File
@@ -2,25 +2,16 @@
/*
+--------------------------------------------------------------------------
| Invision Power Board 2.1.7
| Invision Power Services Kernel [DB Abstraction]
| Invision Power Board
| =============================================
| by Matthew Mecham
| (c) 2001 - 2005 Invision Power Services, Inc.
| (c) 2001 - 2006 Invision Power Services, Inc.
| http://www.invisionpower.com
| =============================================
| Web: http://www.invisionboard.com
| http://www.ibresource.ru/products/invisionpowerboard/
| Time: Tuesday 18th of July 2006 05:56:00 PM
| Release: 52f408a29988b02f45b5e6f4ba5af0ae
| Licence Info: http://www.invisionboard.com/?license
| http://www.ibresource.ru/license
+---------------------------------------------------------------------------
| INVISION POWER BOARD IS NOT FREE / OPEN SOURCE!
+---------------------------------------------------------------------------
| INVISION POWER BOARD ÍÅ ßÂËßÅÒÑß ÁÅÑÏËÀÒÍÛÌ ÏÐÎÃÐÀÌÌÍÛÌ ÎÁÅÑÏÅ×ÅÍÈÅÌ!
| Ïðàâà íà ÏÎ ïðèíàäëåæàò Invision Power Services
| Ïðàâà íà ïåðåâîä IBResource (http://www.ibresource.ru)
| THIS IS NOT FREE / OPEN SOURCE SOFTWARE
+---------------------------------------------------------------------------
|
| > Core Module
@@ -80,6 +71,19 @@
* @version 2.1
*/
//-----------------------------------------
// Allow SUB SELECTS?
//-----------------------------------------
/**
* This can be overridden by using
* $DB->allow_sub_select = 1;
* before any query construct
*/
define( 'IPS_DB_ALLOW_SUB_SELECTS', 0 );
class db_main
{
# Global OBJECT
@@ -89,19 +93,21 @@ class db_main
*
* @var array
*/
var $obj = array ( "sql_database" => "" ,
"sql_user" => "root" ,
"sql_pass" => "" ,
"sql_host" => "localhost",
"sql_port" => "" ,
"persistent" => "0" ,
"sql_tbl_prefix" => "ibf_" ,
"cached_queries" => array() ,
'shutdown_queries' => array() ,
'debug' => 0 ,
'use_shutdown' => 1 ,
'query_cache_file' => '' ,
'force_new_connection' => 0 ,
var $obj = array ( "sql_database" => "" ,
"sql_user" => "root" ,
"sql_pass" => "" ,
"sql_host" => "localhost",
"sql_port" => "" ,
"persistent" => "0" ,
"sql_tbl_prefix" => "ibf_" ,
"cached_queries" => array() ,
'shutdown_queries' => array() ,
'debug' => 0 ,
'use_shutdown' => 1 ,
'query_cache_file' => '' ,
'force_new_connection' => 0 ,
'error_log' => '' ,
'use_error_log' => 0 ,
);
/**
@@ -109,7 +115,8 @@ class db_main
*
* @var string
*/
var $error = "";
var $error = "";
var $error_no = "";
/**
* Return error message or die inline
@@ -229,6 +236,17 @@ class db_main
* @var string
*/
var $sql_queries_name = 'sql_queries';
var $mysql_version;
var $true_version;
/*
* Allow sub selects for this query
*
* @var int
*/
var $allow_sub_select = 0;
/*-------------------------------------------------------------------------*/
// Constructor
@@ -302,7 +320,7 @@ class db_main
{
if ( ! file_exists( $filepath ) )
{
print "Íåâîçìîæíî íàéòè $filepath!";
print "Cannot locate $filepath - exiting!";
exit();
}
else
@@ -465,6 +483,17 @@ class db_main
$this->do_insert( $tbl, $arr, TRUE );
}
/*-------------------------------------------------------------------------*/
// Quick function: DO DELETE
/*-------------------------------------------------------------------------*/
function do_delete( $table, $where="" )
{
$this->build_and_exec_query( array( 'delete' => $table,
'where' => $where ) );
}
/*-------------------------------------------------------------------------*/
// Simple elements
/*-------------------------------------------------------------------------*/
@@ -477,34 +506,39 @@ class db_main
function build_query( $a )
{
if ( $a['select'] )
if ( isset($a['select']) && $a['select'] )
{
if ( is_array( $a['add_join'] ) )
if ( isset($a['add_join']) && is_array( $a['add_join'] ) )
{
$this->simple_select_with_join( $a['select'], $a['from'], $a['where'], $a['add_join'] );
$this->simple_select_with_join( $a['select'], $a['from'], isset($a['where']) ? $a['where'] : '', $a['add_join'] );
}
else
{
$this->simple_select( $a['select'], $a['from'], $a['where'] );
$this->simple_select( $a['select'], $a['from'], isset($a['where']) ? $a['where'] : '' );
}
}
if ( $a['update'] )
if ( isset($a['update']) && $a['update'] )
{
$this->simple_update( $a['update'], $a['set'], $a['where'], $a['lowpro'] );
$this->simple_update( $a['update'], $a['set'], isset($a['where']) ? $a['where'] : '', isset($a['lowpro']) ? $a['lowpro'] : '' );
}
if ( $a['delete'] )
if ( isset($a['delete']) && $a['delete'] )
{
$this->simple_delete( $a['delete'], $a['where'] );
}
if ( $a['order'] )
if ( isset($a['group']) && $a['group'] )
{
$this->simple_group( $a['group'] );
}
if ( isset($a['order']) && $a['order'] )
{
$this->simple_order( $a['order'] );
}
if ( is_array( $a['limit'] ) )
if ( isset($a['limit']) && is_array( $a['limit'] ) )
{
$this->simple_limit( $a['limit'][0], $a['limit'][1] );
}
@@ -529,7 +563,7 @@ class db_main
$ci = $this->exec_query();
if ( $a['select'] )
if ( isset($a['select']) AND $a['select'] )
{
return $this->fetch_row( $ci );
}
@@ -658,7 +692,8 @@ class db_main
{
return $this->query_count;
}
/*-------------------------------------------------------------------------*/
// Flushes the in memory query string
/*-------------------------------------------------------------------------*/
@@ -687,29 +722,57 @@ class db_main
function fatal_error($the_error="")
{
// Are we simply returning the error?
//-----------------------------------------
// INIT
//-----------------------------------------
if ($this->return_die == 1)
$this->error = $this->_get_error_string();
$this->error_no = $this->_get_error_number();
if ( $this->return_die == 1 )
{
$this->error = $this->_get_error_string();
$this->error_no = $this->_get_error_number();
$this->failed = 1;
$this->error = ( $this->error == "" ? $the_error : $this->error );
$this->failed = 1;
return;
}
else if ( $this->obj['use_error_log'] AND $this->obj['error_log'] )
{
$_error_string = "\n===================================================";
$_error_string .= "\n Date: ". date( 'r' );
$_error_string .= "\n Error Number: " . $this->error_no;
$_error_string .= "\n Error: " . $this->error;
$_error_string .= "\n IP Address: " . $_SERVER['REMOTE_ADDR'];
$_error_string .= "\n ".$the_error;
if ( $FH = @fopen( $this->obj['error_log'], 'a' ) )
{
@fwrite( $FH, $_error_string );
@fclose( $FH );
}
print "<html><head><title>IPS Driver Error</title>
<style>P,BODY{ font-family:arial,sans-serif; font-size:11px; }</style></head><body>
<blockquote><h1>IPS Driver Error</h1><b>There appears to be an error with the database.</b><br>
You can try to refresh the page by clicking <a href=\"javascript:window.location=window.location;\">here</a>
</body></html>";
}
else
{
$the_error .= "\n\nSQL error: ".$this->error."\n";
$the_error .= "SQL error code: ".$this->error_no."\n";
$the_error .= "Date: ".date("l dS \o\f F Y h:i:s A");
$the_error .= "\n\nSQL error: ".$this->_get_error_string()."\n";
$the_error .= "SQL error code: ".$this->error_no."\n";
$the_error .= "Date: ".date("j.n.Y, G:i");
$out = "<html><head><title>IPS Driver Error</title>
<style>P,BODY{ font-family:arial,sans-serif; font-size:11px; }</style></head><body>
&nbsp;<br><br><blockquote><b>Îøèáêà ñ áàçîé äàííûõ.</b><br>
Âû ìîæåòå ïîïðîáîâàòü îáíîâèòü ýòó ñòðàíèöó, íàæàâ <a href=\"javascript:window.location=window.location;\">ñþäà</a>.
<br><br><b>Âîçâðàùàåìàÿ îøèáêà</b><br>
<form name='mysql'><textarea rows=\"15\" cols=\"60\">".htmlspecialchars($the_error)."</textarea></form><br>Ïðèíîñèì ñâîè èçâèíåíèÿ çà ïðåäîñòàâëåííûå íåóäîáñòâà.</blockquote></body></html>";
$out = "<html><head><title>IPS Driver Error</title>
<style>P,BODY{ font-family:arial,sans-serif; font-size:11px; }</style></head><body>
<blockquote><h1>IPS Driver Error</h1><b>There appears to be an error with the database.</b><br>
You can try to refresh the page by clicking <a href=\"javascript:window.location=window.location;\">here</a>.
<br><br><b>Error Returned</b><br>
<form name='mysql'><textarea rows=\"15\" cols=\"60\">".htmlspecialchars($the_error)."</textarea></form><br>We apologise for any inconvenience</blockquote></body></html>";
print $out;
print $out;
}
exit();
}
@@ -741,7 +804,7 @@ class db_main
$add_slashes = 0;
}
if ( $this->no_escape_fields[ $k ] )
if ( isset($this->no_escape_fields[ $k ]) AND $this->no_escape_fields[ $k ] )
{
$add_slashes = 0;
}
@@ -757,7 +820,7 @@ class db_main
// Forcing data type?
//-----------------------------------------
if ( $this->force_data_type[ $k ] )
if ( isset($this->force_data_type[ $k ]) AND $this->force_data_type[ $k ] )
{
if ( $this->force_data_type[ $k ] == 'string' )
{
@@ -831,7 +894,7 @@ class db_main
$add_slashes = 0;
}
if ( $this->no_escape_fields[ $k ] )
if ( isset($this->no_escape_fields[ $k ]) && $this->no_escape_fields[ $k ] )
{
$add_slashes = 0;
}
@@ -845,7 +908,7 @@ class db_main
// Forcing data type?
//-----------------------------------------
if ( $this->force_data_type[ $k ] )
if ( isset($this->force_data_type[ $k ]) && $this->force_data_type[ $k ] )
{
if ( $this->force_data_type[ $k ] == 'string' )
{
@@ -901,6 +964,68 @@ class db_main
# Driver specific
}
/*-------------------------------------------------------------------------*/
// Removes quotes from a DB query
/*-------------------------------------------------------------------------*/
function remove_all_quotes( $t )
{
//-----------------------------------------
// Remove quotes
//-----------------------------------------
$t = preg_replace( "#\\\{1,}[\"']#s", "", $t );
$t = preg_replace( "#'[^'].*'#s" , "", $t );
$t = preg_replace( "#\"[^\"].*\"#s" , "", $t );
$t = preg_replace( "#\"\"#s" , "", $t );
$t = preg_replace( "#''#s" , "", $t );
//-----------------------------------------
// Remove comments
//-----------------------------------------
$t = preg_replace( "#/\*(.??)\*/#s", "", $t );
$t = preg_replace( "#/\*.+?\*/#s", "", $t );
return $t;
}
/*-------------------------------------------------------------------------*/
// Basic error handler
/*-------------------------------------------------------------------------*/
/**
* Prints SQL error message
*
* @param string Additional error message
*
* @return integer Optional, if var $return_die is set to 1
*/
function write_debug_log( $query, $data, $endtime )
{
//-----------------------------------------
// INIT
//-----------------------------------------
if ( $this->obj['use_debug_log'] AND $this->obj['debug_log'] )
{
$_string = "\n==============================================================================";
$_string .= "\n Date: ". date( 'r' );
$_string .= "\n IP Address: " . $_SERVER['REMOTE_ADDR'];
$_string .= "\n Time Taken: ".$endtime;
$_string .= "\n ".$query;
$_string .= "\n==============================================================================";
$_string .= "\n".$data;
if ( $FH = @fopen( $this->obj['debug_log'], 'a' ) )
{
@fwrite( $FH, $_string );
@fclose( $FH );
}
}
}
/*-------------------------------------------------------------------------*/
// INTERNAL: Get error number
/*-------------------------------------------------------------------------*/