Version 3.2.3

This commit is contained in:
Neo committed 2025-12-19 00:34:03 -08:00
1 parent ae5c01cc78
commit 78706903a2
2641 files changed
+228363 -201264

No files matched your search

+1 -1
View File
@@ -5,6 +5,6 @@
<hr>
You have reached this page in error, please use your back button to return to the forum.
<hr>
<a href="http://www.invisionboard.com/">IP.Board</a>
<a href="http://www.invisionpower.com">IP.Board</a>
</body>
</html>
+78 -57
View File
@@ -1,48 +1,56 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.1.4
* MySQL Database Diagnostic Methods
* Last Updated: $Date: 2010-10-18 16:58:05 -0400 (Mon, 18 Oct 2010) $
* </pre>
*
* @author $Author: bfarber $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/community/board/license.html
* @package IP.Board
* @subpackage Kernel
* @link http://www.invisionpower.com
* @file mysql_tools.php Provides methods to diagnostic a MySQL database
*~TERABYTE_DOC_READY~
* $Copyright: (c) 2001 - 2011 Invision Power Services, Inc.$
* $License: This is NULLED!
* $Author: bfarber $
* @since Tuesday 1st March 2005 15:40
* @version $Revision: 478 $
* $LastChangedDate: 2011-09-14 20:13:56 -0400 (Wed, 14 Sep 2011) $
* @version v3.2.3
* $Revision: 9491 $
*/
/**
*
* @class db_tools
* @brief Provides methods to diagnostic a MySQL database
* @note The file is automatically loaded based on the driver value in conf_global.php
*
*/
class db_tools
{
/**
* Missing column/table/index flag
* Boolean flag that holds data about missing column/table/index
*
* @var boolean Table/index has issues
* @access public
* @var $has_issues
*/
public $has_issues = false;
public $has_issues = false;
/**
* Internal mapping - ignore me
* Array with an internal mapping of tables/columns
*
* @var array Table/column mappings
* @access private
* @var $_mapping
*/
private $_mapping = array();
protected $_mapping = array();
/**
* Diagnose table indexes
*
* @access public
* @param array Array of create table/index statements to check
* @param array Array of issues to fix
* @return array Array of results
* @param array $sql_statements Array of create table/index statements to check
* @param string $issues_to_fix String of the issue to fix, can be set to 'all' to fix everything
* @return @e array Array of results
*
* <b>Example Usage:</b>
* @code
* // Retrieve results
* $results = $this->dbIndexDiag( $sql_statements );
* // Retrieve results and fix a index
* $results = $this->dbIndexDiag( $sql_statements, $issues_to_fix );
* // Retrieve results and fix all indexes
* $results = $this->dbIndexDiag( $sql_statements, 'all' );
* @endcode
*/
public function dbIndexDiag( $sql_statements, $issues_to_fix='' )
{
@@ -83,10 +91,12 @@ class db_tools
/* Remove backticks */
$definition = str_replace( '`', '', $definition );
$definition = preg_replace( "#CREATE\s+TABLE\s+IF\s+NOT\s+EXISTS\s+#i", "CREATE TABLE ", $definition );
//-----------------------------------------
// Is this a create table statement?
//-----------------------------------------
if ( preg_match( "#CREATE\s+TABLE\s+?(.+?)\s+?\(#ie", $definition, $tablename ) )
{
$tableName = $tablename[1];
@@ -125,17 +135,6 @@ class db_tools
$final_primary = array( $primary_key ? $primary_key : $primary_fields, $primary_fields );
}
}
$table_array[$i] = $tableName;
//-----------------------------------------
// We found a primary key, store it
//-----------------------------------------
if ( count( $final_primary ) )
{
$primary_array[$i] = $final_primary;
}
}
//-----------------------------------------
@@ -228,7 +227,7 @@ class db_tools
if( isset( $data['primary'] ) && is_array($data['primary']) AND count($data['primary']) )
{
$index_name = $data['primary'][0];
$index_name = preg_replace( "/[^a-zA-Z0-9]/", '_', $data['primary'][0] );
$index_cols = $data['primary'][1];
$ok = 0;
@@ -351,6 +350,7 @@ class db_tools
$index_name = $indexes[0];
$_checkName = $index_name;
$index_cols = str_replace( ' ', '', $indexes[1] ? $indexes[1] : $index_name );
$index_name = preg_replace( "/[^a-zA-Z0-9]/", '_', $index_name );
$ok = 0;
@@ -477,10 +477,19 @@ class db_tools
/**
* Diagnose table structure
*
* @access public
* @param array Array of create table/index statements to check
* @param array Array of issues to fix
* @return array Array of results
* @param array $sql_statements Array of create table/columns statements to check
* @param string $issues_to_fix String of the issue to fix, can be set to 'all' to fix everything
* @return @e array Array of results
*
* <b>Example Usage:</b>
* @code
* // Retrieve results
* $results = $this->dbTableDiag( $sql_statements );
* // Retrieve results and fix a table/column
* $results = $this->dbTableDiag( $sql_statements, $issues_to_fix );
* // Retrieve results and fix all tables/columns
* $results = $this->dbTableDiag( $sql_statements, 'all' );
* @endcode
*/
public function dbTableDiag( $sql_statements, $issues_to_fix='' )
{
@@ -512,6 +521,8 @@ class db_tools
/* Remove backticks */
$the_table = str_replace( '`', '', $the_table );
$the_table = preg_replace( "#CREATE\s+TABLE\s+IF\s+NOT\s+EXISTS\s+#i", "CREATE TABLE ", $the_table );
//-----------------------------------------
// Is this a create table statement?
@@ -565,6 +576,16 @@ class db_tools
$temp = preg_split( "/[\s]+/" , trim($col) );
$columnName = $temp[0];
//-----------------------------------------
// Ignore custom profile fields
// @link http://community.invisionpower.com/tracker/issue-27495-database-checker-find-removed-custom-profile-fields
//-----------------------------------------
if( $tableName == 'pfields_content' AND strpos( $columnName, 'field_' ) === 0 )
{
continue;
}
//-----------------------------------------
// If this is a real column, map it
@@ -746,21 +767,21 @@ class db_tools
}
return array( 'error_count' => $error_count, 'results' => $output );
}
}
/**
* Remove ticks from statement
*
* @access private
* @param string String
* @return string String with ticks removed
*/
private function _sqlStripTicks( $data )
* Remove ticks from statement
*
* @param string $data String to clean
* @return @e string String with ticks removed
*
* <b>Example Usage:</b>
* @code
* $query = $this->_sqlStripTicks( $data );
* @endcode
*/
protected function _sqlStripTicks( $data )
{
return str_replace( "`", "", $data );
}
}
?>
}