Version 3.1.4
This commit is contained in:
1 parent
1d4720f3e2
commit
ae5c01cc78
2563 files changed
+283048
-240689
No files matched your search
+231
-52
@@ -1,18 +1,21 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* Invision Power Services
|
||||
* IP.Board v3.0.5
|
||||
* IP.Board v3.1.4
|
||||
* Database Abstraction Layer
|
||||
* Last Updated: $Date: 2009-12-07 21:58:39 -0500 (Mon, 07 Dec 2009) $
|
||||
* Last Updated: $Date: 2010-09-20 20:20:12 -0400 (Mon, 20 Sep 2010) $
|
||||
* </pre>
|
||||
*
|
||||
* @author $Author: bfarber $
|
||||
* @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: 351 $
|
||||
* @version $Revision: 467 $
|
||||
*
|
||||
* Basic Usage Examples
|
||||
* <code>
|
||||
@@ -265,6 +268,16 @@ interface interfaceDb
|
||||
*/
|
||||
public function checkBooleanFulltextSupport();
|
||||
|
||||
/**
|
||||
* Test to see whether an index exists in a table
|
||||
*
|
||||
* @access public
|
||||
* @param string Index name
|
||||
* @param string Table name
|
||||
* @return boolean Field exists or not
|
||||
*/
|
||||
public function checkForIndex( $index, $table );
|
||||
|
||||
/**
|
||||
* Test to see whether a field exists in a table
|
||||
*
|
||||
@@ -308,7 +321,7 @@ interface interfaceDb
|
||||
* @param string [Optional] Default value
|
||||
* @return resource Query id
|
||||
*/
|
||||
public function addField( $table, $field, $type, $default='' );
|
||||
public function addField( $table, $field, $type, $default=NULL );
|
||||
|
||||
/**
|
||||
* Add index to database column
|
||||
@@ -319,6 +332,7 @@ interface interfaceDb
|
||||
* @param string Fieldlist col1, col2
|
||||
* @param bool Is primary key?
|
||||
* @return resource Query id
|
||||
* @todo [Future] Add support for fulltext indexes (right now can only do generic index or primary key)
|
||||
*/
|
||||
public function addIndex( $table, $name, $fieldlist, $isPrimary=false );
|
||||
|
||||
@@ -366,6 +380,14 @@ interface interfaceDb
|
||||
*/
|
||||
public function getTableNames();
|
||||
|
||||
/**
|
||||
* Get array of field names in table
|
||||
*
|
||||
* @param string Table name
|
||||
* @return array SQL tables
|
||||
*/
|
||||
public function getFieldNames( $table );
|
||||
|
||||
/**
|
||||
* Determine if table already has a fulltext index
|
||||
*
|
||||
@@ -592,7 +614,14 @@ interface interfaceDb
|
||||
*/
|
||||
public function buildDateFormat( $column, $format );
|
||||
|
||||
/**
|
||||
/**
|
||||
* Build rand() string
|
||||
*
|
||||
* @return string SQL-formatted random order string
|
||||
*/
|
||||
public function buildRandomOrder();
|
||||
|
||||
/**
|
||||
* Build fulltext search string
|
||||
*
|
||||
* @param string Column to search against
|
||||
@@ -611,7 +640,18 @@ interface interfaceDb
|
||||
* @return mixed Output to screen, or return void
|
||||
*/
|
||||
public function throwFatalError( $the_error='' );
|
||||
|
||||
|
||||
/**
|
||||
* Returns a portion of a WHERE query suitable for use.
|
||||
* Specific to tables with a field that has a comma separated list of IDs.
|
||||
*
|
||||
* @param array Array of perm IDs
|
||||
* @param string DB field to search in
|
||||
* @param boolean check for '*' in the field to denote 'global'
|
||||
* @return mixed Output to screen, or return void
|
||||
*/
|
||||
public function buildWherePermission( array $ids, $field='', $incStarCheck=true );
|
||||
|
||||
/**
|
||||
* Logs SQL error message to log file
|
||||
*
|
||||
@@ -863,6 +903,15 @@ abstract class dbMain
|
||||
* @var string
|
||||
*/
|
||||
public $fieldEncapsulate = "'";
|
||||
|
||||
/**
|
||||
* Field name encapsulation character
|
||||
* @see http://community.invisionpower.com/tracker/issue-20621-postgresql-driver-field-names-not-properly-escaped/
|
||||
*
|
||||
* @access public
|
||||
* @var string
|
||||
*/
|
||||
public $fieldNameEncapsulate = '';
|
||||
|
||||
/**
|
||||
* db_driver constructor
|
||||
@@ -902,6 +951,18 @@ abstract class dbMain
|
||||
return $this->cur_query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Turns table identity insert on/off
|
||||
*
|
||||
* @access public
|
||||
* @param string Table name
|
||||
* @param string On or Off
|
||||
* @return string
|
||||
*/
|
||||
public function setTableIdentityInsert( $tableName, $status='OFF' )
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Takes array of set commands and generates a SQL formatted query
|
||||
*
|
||||
@@ -1107,6 +1168,19 @@ abstract class dbMain
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test to see whether an index exists in a table
|
||||
*
|
||||
* @access public
|
||||
* @param string Index name
|
||||
* @param string Table name
|
||||
* @return boolean Field exists or not
|
||||
*/
|
||||
public function checkForIndex( $index, $table )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test to see whether a field exists in a table
|
||||
*
|
||||
@@ -1255,6 +1329,28 @@ abstract class dbMain
|
||||
return $this->_triedToLoadCacheFiles[ $classname ];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a portion of a WHERE query suitable for use.
|
||||
* Specific to tables with a field that has a comma separated list of IDs.
|
||||
*
|
||||
* @param array Array of perm IDs
|
||||
* @param string DB field to search in
|
||||
* @param boolean check for '*' in the field to denote 'global'
|
||||
* @return mixed Output to screen, or return void
|
||||
*/
|
||||
public function buildWherePermission( array $ids, $field='', $incStarCheck=true )
|
||||
{
|
||||
/* Just use a LIKE chain for items without a specific implementation */
|
||||
$where = '(' . $this->buildLikeChain( $field, $ids ) . ')';
|
||||
|
||||
if ( $incStarCheck === true )
|
||||
{
|
||||
$where = ' OR ( ' . $field . '=\'*\' )';
|
||||
}
|
||||
|
||||
return $where;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load Query cache file
|
||||
*
|
||||
@@ -1316,7 +1412,7 @@ abstract class dbMain
|
||||
$v = $this->addSlashes( $v );
|
||||
}
|
||||
|
||||
$field_names .= "$k,";
|
||||
$field_names .= $this->fieldNameEncapsulate . "$k" . $this->fieldNameEncapsulate . ',';
|
||||
|
||||
//-----------------------------------------
|
||||
// Forcing data type?
|
||||
@@ -1348,7 +1444,7 @@ abstract class dbMain
|
||||
|
||||
else
|
||||
{
|
||||
if ( is_numeric( $v ) and intval($v) == $v )
|
||||
if ( is_numeric( $v ) and strcmp( intval($v), $v ) === 0 )
|
||||
{
|
||||
$field_values .= $v.",";
|
||||
}
|
||||
@@ -1442,7 +1538,7 @@ abstract class dbMain
|
||||
|
||||
else
|
||||
{
|
||||
if ( is_numeric( $v ) and intval($v) == $v )
|
||||
if ( is_numeric( $v ) and strcmp( intval($v), $v ) === 0 )
|
||||
{
|
||||
$return_string .= $k . "=" . $v . ",";
|
||||
}
|
||||
@@ -1532,7 +1628,7 @@ abstract class dbMain
|
||||
/**
|
||||
* Generates calc rows in the query if supported / runs count(*) if not
|
||||
*
|
||||
* @return boolean
|
||||
* @access protected
|
||||
* @return void Sets $this->_calcRows
|
||||
*/
|
||||
abstract protected function _buildCalcRows();
|
||||
@@ -1552,7 +1648,94 @@ abstract class dbMain
|
||||
|
||||
$this->error = $this->_getErrorString();
|
||||
$this->error_no = $this->_getErrorNumber();
|
||||
$errTemplate = 'ipsDriverError';
|
||||
$nonIPSErrors = array( '1012-1021', '1023-1027', '1030-1031', '1034-1043', '1129-1131', '1150-1153', 1194, 1195, '1203-1207' );
|
||||
|
||||
/* MySQL: Is this non IPS error? */
|
||||
if ( $this->usingClass == 'db_driver_mysql' )
|
||||
{
|
||||
if ( stristr( $this->error, 'has gone away') OR stristr( $this->error, 'connect to local mysql server through socket') )
|
||||
{
|
||||
$errTemplate = 'ipsServerError';
|
||||
}
|
||||
else if ( $this->error_no )
|
||||
{
|
||||
foreach( $nonIPSErrors as $id )
|
||||
{
|
||||
if ( strstr( $id, '-' ) )
|
||||
{
|
||||
list( $a, $b ) = explode( '-', $id );
|
||||
|
||||
if ( $a AND $b )
|
||||
{
|
||||
if ( $this->error_no >= $a AND $this->error_no <= $b )
|
||||
{
|
||||
$errTemplate = 'ipsServerError';
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( $this->error_no == intval( $id ) )
|
||||
{
|
||||
$errTemplate = 'ipsServerError';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Fetch debug information */
|
||||
$_debug = debug_backtrace();
|
||||
$_dString = '';
|
||||
|
||||
if ( is_array( $_debug ) and count( $_debug ) )
|
||||
{
|
||||
foreach( $_debug as $idx => $data )
|
||||
{
|
||||
/* Remove non-essential items */
|
||||
if ( $data['class'] == 'dbMain' OR $data['class'] == 'ips_DBRegistry' OR $data['class'] == 'ipsRegistry' OR $data['class'] == 'ipsController' OR $data['class'] == 'ipsCommand' OR $data['class'] == 'db_driver_mysql' )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$_dbString[ $idx ] = array( 'file' => $data['file'],
|
||||
'line' => $data['line'],
|
||||
'function' => $data['function'],
|
||||
'class' => $data['class'] );
|
||||
}
|
||||
}
|
||||
|
||||
$_error_string = "\n ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------";
|
||||
$_error_string .= "\n Date: ". date( 'r' );
|
||||
$_error_string .= "\n Error: " . $this->error_no . ' - ' . $this->error;
|
||||
$_error_string .= "\n IP Address: " . $_SERVER['REMOTE_ADDR'] . ' - ' . $_SERVER['REQUEST_URI'];
|
||||
$_error_string .= "\n ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------";
|
||||
$_error_string .= "\n " . $the_error;
|
||||
$_error_string .= "\n .--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------.";
|
||||
|
||||
if ( count( $_dbString ) )
|
||||
{
|
||||
$_error_string .= "\n | File | Function | Line No. |";
|
||||
$_error_string .= "\n |----------------------------------------------------------------------------+-------------------------------------------------------------------------------+-------------------|";
|
||||
|
||||
foreach( $_dbString as $i => $data )
|
||||
{
|
||||
if ( defined('DOC_IPS_ROOT_PATH') )
|
||||
{
|
||||
$data['file'] = str_replace( DOC_IPS_ROOT_PATH, '', $data['file'] );
|
||||
}
|
||||
|
||||
/* Reset */
|
||||
$data['func'] = "[" . $data['class'] . '].' . $data['function'];
|
||||
|
||||
/* Pad right */
|
||||
$data['file'] = str_pad( $data['file'], 75 );
|
||||
$data['func'] = str_pad( $data['func'], 78 );
|
||||
$data['line'] = str_pad( $data['line'], 18 );
|
||||
|
||||
$_error_string .= "\n | " . $data['file'] . "| " . $data['func'] . '| ' . $data['line'] . '|';
|
||||
$_error_string .= "\n '----------------------------------------------------------------------------+-------------------------------------------------------------------------------+-------------------'";
|
||||
}
|
||||
}
|
||||
|
||||
if ( $this->return_die == true )
|
||||
{
|
||||
$this->error = ( $this->error == "" ? $the_error : $this->error );
|
||||
@@ -1561,46 +1744,32 @@ abstract class dbMain
|
||||
}
|
||||
else if ( $this->obj['use_error_log'] AND $this->obj['error_log'] )
|
||||
{
|
||||
$_debug = debug_backtrace(FALSE);
|
||||
$_dString = '';
|
||||
|
||||
if ( is_array( $_debug ) and count( $_debug ) )
|
||||
{
|
||||
foreach( $_debug as $idx => $data )
|
||||
{
|
||||
/* Remove non-essential items */
|
||||
if ( $data['class'] == 'dbMain' OR $data['class'] == 'ips_DBRegistry' OR $data['class'] == 'ipsRegistry' OR $data['class'] == 'ipsController' OR $data['class'] == 'ipsCommand' )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$_dbString[ $idx ] = array( 'file' => $data['file'],
|
||||
'line' => $data['line'],
|
||||
'function' => $data['function'],
|
||||
'class' => $data['class'] );
|
||||
}
|
||||
}
|
||||
|
||||
$_error_string = "\n===================================================";
|
||||
$_error_string .= "\n Дата: ". date( 'r' );
|
||||
$_error_string .= "\n Номер ошибки: " . $this->error_no;
|
||||
$_error_string .= "\n Ошибка: " . $this->error;
|
||||
$_error_string .= "\n IP Адрес: " . $_SERVER['REMOTE_ADDR'];
|
||||
$_error_string .= "\n Страница: " . $_SERVER['REQUEST_URI'];
|
||||
$_error_string .= "\n Отладочная информация: " . var_export( $_dbString, TRUE );
|
||||
$_error_string .= "\n ".$the_error;
|
||||
|
||||
if ( $FH = @fopen( $this->obj['error_log'], 'a' ) )
|
||||
{
|
||||
@fwrite( $FH, $_error_string );
|
||||
@fclose( $FH );
|
||||
}
|
||||
|
||||
/* Write to latest log also */
|
||||
if ( is_dir( DOC_IPS_ROOT_PATH . 'cache' ) )
|
||||
{
|
||||
@file_put_contents( DOC_IPS_ROOT_PATH . 'cache/sql_error_latest.cgi', trim( $_error_string ) );
|
||||
}
|
||||
|
||||
if ( isset( $_SERVER['SERVER_PROTOCOL'] ) AND strstr( $_SERVER['SERVER_PROTOCOL'], '/1.0' ) )
|
||||
{
|
||||
@header( "HTTP/1.0 503 Service Unavailable" );
|
||||
}
|
||||
else
|
||||
{
|
||||
@header( "HTTP/1.1 503 Service Unavailable" );
|
||||
}
|
||||
|
||||
if( $this->use_template )
|
||||
{
|
||||
require_once( DOC_IPS_ROOT_PATH . 'cache/skin_cache/ipsDriverError.php' );
|
||||
require_once( DOC_IPS_ROOT_PATH . 'cache/skin_cache/'. $errTemplate . '.php' );
|
||||
$template = new ipsDriverErrorTemplate();
|
||||
print $template->showError();
|
||||
print $template->showError( $errTemplate == 'ipsServerError' ? true : false, $the_error );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1615,11 +1784,21 @@ abstract class dbMain
|
||||
{
|
||||
$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 .= "Date: ".date("l dS F Y h:i:s A");
|
||||
$the_error .= "\n\n" . $_error_string;
|
||||
|
||||
if ( isset( $_SERVER['SERVER_PROTOCOL'] ) AND strstr( $_SERVER['SERVER_PROTOCOL'], '/1.0' ) )
|
||||
{
|
||||
@header( "HTTP/1.0 503 Service Unavailable" );
|
||||
}
|
||||
else
|
||||
{
|
||||
@header( "HTTP/1.1 503 Service Unavailable" );
|
||||
}
|
||||
|
||||
if( $this->use_template )
|
||||
{
|
||||
require_once( DOC_IPS_ROOT_PATH . 'cache/skin_cache/ipsDriverError.php' );
|
||||
require_once( DOC_IPS_ROOT_PATH . 'cache/skin_cache/'. $errTemplate . '.php' );
|
||||
$template = new ipsDriverErrorTemplate();
|
||||
print $template->showError( true, $the_error );
|
||||
}
|
||||
@@ -1665,14 +1844,14 @@ abstract class dbMain
|
||||
if ( $query == '{start}' AND ( $this->obj['use_debug_log'] AND $this->obj['debug_log'] ) )
|
||||
{
|
||||
$_string = "\n\n\n\n\n==============================================================================";
|
||||
$_string .= "\n========================= НАЧАЛО ===================================";
|
||||
$_string .= "\n========================= START ===================================";
|
||||
$_string .= "\n========================= " . $_SERVER['PHP_SELF'] . '?' . $_SERVER['QUERY_STRING'] . " ===================================";
|
||||
$_string .= "\n==============================================================================";
|
||||
}
|
||||
else if ( $query == '{end}' AND ( $this->obj['use_debug_log'] AND $this->obj['debug_log'] ) )
|
||||
{
|
||||
$_string = "\n==============================================================================";
|
||||
$_string .= "\n========================= КОНЕЦ ===================================";
|
||||
$_string .= "\n========================= END ===================================";
|
||||
$_string .= "\n========================= " . $_SERVER['PHP_SELF'] . '?' . $_SERVER['QUERY_STRING'] . " ===================================";
|
||||
$_string .= "\n==============================================================================";
|
||||
}
|
||||
@@ -1680,9 +1859,9 @@ abstract class dbMain
|
||||
{
|
||||
$_string = "\n==============================================================================";
|
||||
$_string .= "\n URL: ". $_SERVER['PHP_SELF'] . $_SERVER['REQUEST_URI'];
|
||||
$_string .= "\n Дата: ". date( 'r' );
|
||||
$_string .= "\n IP адрес: " . $_SERVER['REMOTE_ADDR'];
|
||||
$_string .= "\n Затраченное время: ".$endtime;
|
||||
$_string .= "\n Date: ". date( 'r' );
|
||||
$_string .= "\n IP Address: " . $_SERVER['REMOTE_ADDR'];
|
||||
$_string .= "\n Time Taken: ".$endtime;
|
||||
$_string .= "\n ".$query;
|
||||
$_string .= "\n".$data;
|
||||
$_string .= "\n==============================================================================";
|
||||
|
||||
Reference in new issue
Block a user