Version 3.3.4

This commit is contained in:
Neo committed 2025-12-19 00:35:52 -08:00
1 parent 78706903a2
commit fb6b5baabc
2206 files changed
+409828 -382984

No files matched your search

+30 -20
View File
@@ -4,12 +4,12 @@
* @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!
* $License: http://www.invisionpower.com/company/standards.php#license$
* $Author: bfarber $
* @since Tuesday 1st March 2005 15:40
* $LastChangedDate: 2011-09-14 20:13:56 -0400 (Wed, 14 Sep 2011) $
* @version v3.2.3
* $Revision: 9491 $
* $LastChangedDate: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
* @version v3.3.4
* $Revision: 10914 $
*/
/**
@@ -24,14 +24,14 @@ class db_tools
/**
* Boolean flag that holds data about missing column/table/index
*
* @var $has_issues
* @var bool
*/
public $has_issues = false;
/**
* Array with an internal mapping of tables/columns
*
* @var $_mapping
* @var array
*/
protected $_mapping = array();
@@ -40,7 +40,7 @@ class db_tools
*
* @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
* @return @e array
*
* <b>Example Usage:</b>
* @code
@@ -100,12 +100,12 @@ class db_tools
if ( preg_match( "#CREATE\s+TABLE\s+?(.+?)\s+?\(#ie", $definition, $tablename ) )
{
$tableName = $tablename[1];
//-----------------------------------------
// Does the table have a primary key?
//-----------------------------------------
if ( preg_match( "#\s+?PRIMARY\s+?KEY\s+?(?:(\w+?)\s+?)?\((.*?)\)(?:(?:[,\s+?$])?\((.+?)\))?#is", $definition, $fields ) )
if ( preg_match( "#\s+?PRIMARY\s+?KEY\s+?(?:(\w+?)\s*)?\((.*?)\)(?:(?:[,\s+?$])?\((.+?)\))?#is", $definition, $fields ) )
{
$final_primary = array();
@@ -179,7 +179,7 @@ class db_tools
//-----------------------------------------
// We have some indexes for this table
//-----------------------------------------
if( $tableName AND ( $primary_key OR count($final_keys) ) )
{
$indexes[] = array( 'table' => $tableName,
@@ -271,7 +271,8 @@ class db_tools
if( preg_replace( '#^' . ipsRegistry::$settings['sql_tbl_prefix'] . '(.+?)#', "\\1", $issues_to_fix ) == $data['table'] OR $issues_to_fix == 'all' )
{
ipsRegistry::DB()->query( $query_needed );
$r = ipsRegistry::DB()->query( $query_needed );
$output['ran'][] = array( 'q' => $query_needed, 'status' => $r );
break;
}
@@ -310,7 +311,8 @@ class db_tools
{
$ok = 1;
ipsRegistry::DB()->query( $query_needed );
$r = ipsRegistry::DB()->query( $query_needed );
$output['ran'][] = array( 'q' => $query_needed, 'status' => $r );
}
else
{
@@ -408,7 +410,8 @@ class db_tools
if( preg_replace( '#^' . ipsRegistry::$settings['sql_tbl_prefix'] . '(.+?)#', "\\1", $issues_to_fix ) == $data['table'] OR $issues_to_fix == 'all' )
{
ipsRegistry::DB()->query( $query_needed );
$r = ipsRegistry::DB()->query( $query_needed );
$output['ran'][] = array( 'q' => $query_needed, 'status' => $r );
continue 2;
}
@@ -443,7 +446,8 @@ class db_tools
if( preg_replace( '#^' . ipsRegistry::$settings['sql_tbl_prefix'] . '(.+?)#', "\\1", $issues_to_fix ) == $data['table'] OR $issues_to_fix == 'all' )
{
ipsRegistry::DB()->query( $query_needed );
$r = ipsRegistry::DB()->query( $query_needed );
$output['ran'][] = array( 'q' => $query_needed, 'status' => $r );
$ok = 1;
}
@@ -479,7 +483,7 @@ class db_tools
*
* @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
* @return @e array
*
* <b>Example Usage:</b>
* @code
@@ -496,7 +500,7 @@ class db_tools
//-----------------------------------------
// Init
//-----------------------------------------
$queries_needed = array();
$tables_needed = array();
$table_definitions = array();
@@ -649,7 +653,13 @@ class db_tools
if( preg_replace( '#^' . ipsRegistry::$settings['sql_tbl_prefix'] . '(.+?)#', "\\1", $issues_to_fix ) == $tableNoPrefix OR $issues_to_fix == 'all' )
{
ipsRegistry::DB()->query( $table_definitions[ $tableName ] );
if ( ipsRegistry::$settings['sql_tbl_prefix'] )
{
$the_table = preg_replace( "#^CREATE TABLE(?:\s+?)?(\S+)#is", "CREATE TABLE " . ipsRegistry::$settings['sql_tbl_prefix'] ."\\1 ", $the_table );
}
$r = ipsRegistry::DB()->query( $the_table );
$output['ran'][] = array( 'q' => $the_table, 'status' => $r );
continue;
}
@@ -717,8 +727,8 @@ class db_tools
if( preg_replace( '#^' . ipsRegistry::$settings['sql_tbl_prefix'] . '(.+?)#', "\\1", $issues_to_fix ) == $tableNoPrefix OR $issues_to_fix == 'all' )
{
ipsRegistry::DB()->query( $query_needed );
$r = ipsRegistry::DB()->query( $query_needed );
$output['ran'][] = array( 'q' => $query_needed, 'status' => $r );
continue;
}
@@ -773,7 +783,7 @@ class db_tools
* Remove ticks from statement
*
* @param string $data String to clean
* @return @e string String with ticks removed
* @return @e string
*
* <b>Example Usage:</b>
* @code