Version 4.1.19

This commit is contained in:
Neo committed 2025-12-19 05:38:56 -08:00
1 parent 28bd025b35
commit 2bd5025018
2674 files changed
+233518 -77766

No files matched your search

+1 -1
View File
@@ -3,7 +3,7 @@
/**
* @brief UTF-8 Conversion
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Tools
* @since 4 Sept 2013
+1 -1
View File
@@ -2,7 +2,7 @@
/**
* @brief UTF-8 Conversion
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Tools
* @since 4 Sept 2013
+12 -8
View File
@@ -2,9 +2,9 @@
/**
* @brief Init for UTF8 Conversion
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Tools
* @package IPS Community Suite
* @since 4 Sept 2013
* @version SVN_VERSION_NUMBER
*/
@@ -12,12 +12,12 @@
namespace IPSUtf8;
/**
* Class to contain IPS Social Suite autoloader and exception handler
* Class to contain IPS Community Suite autoloader and exception handler
*/
class IPSUtf8
{
/**
* Initiate IPS Social Suite UTF8 Converter, autoloader and exception handler
* Initiate IPS Community Suite UTF8 Converter, autoloader and exception handler
*
* @return void
*/
@@ -71,12 +71,16 @@ class IPSUtf8
public static function defaultConstants()
{
return array(
'IPB_LOCK' => TRUE, /* Lock conversion to only IP.Board Databases */
'FORCE_CONVERT' => FALSE, /* Enforce conversion */
'IPB_FIREWALL' => 1, /* This is a workaround for an old exploit to prevent upgrade issues */
'IPB_LOCK' => TRUE, /* Lock conversion to only IP.Board Databases */
'BYPASS_SAFETY_LOCK' => FALSE,
'FORCE_CONVERT' => FALSE, /* Enforce conversion */
'FORCE_CONVERT_CHARSET' => NULL,
'FORCE_CONVERT_METHOD' => NULL,
'SOURCE_DB_CHARSET' => NULL, /* If set, will force the source database connection to use this charset */
'UTF8_INSERT_ONLY' => FALSE, /* If true, and sql_charset is present and set to utf8 in conf_global.php, then the "fast" method will simply insert without converting. Useful for mixed collation databases where the utf8 tables are real utf8 */
'SOURCE_DB_CHARSET' => NULL, /* If set, will force the source database connection to use this charset */
'UTF8_INSERT_ONLY' => FALSE, /* If true, and sql_charset is present and set to utf8 in conf_global.php, then the "fast" method will simply insert without converting. Useful for mixed collation databases where the utf8 tables are real utf8 */
'FORCE_MULTI_CONVERT' => FALSE, /* Forces the converter to use CONVERT(CONVERT(CONVERT(x AS <SOURCE_DB_CHARSET>) AS BINARY) AS UTF8) which is needed in some random old data sets */
'LOG' => FALSE, /* Log Conversion Data */
);
}
@@ -2,9 +2,9 @@
/**
* @brief Web conversion process
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @package IPS Community Suite
* @since 9 Sept 2013
* @version SVN_VERSION_NUMBER
*/
+21 -30
View File
@@ -2,9 +2,9 @@
/**
* @brief Web conversion process
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @package IPS Community Suite
* @since 9 Sept 2013
* @version SVN_VERSION_NUMBER
*/
@@ -16,7 +16,7 @@ use \IPSUtf8\Output\Browser\Template;
* Web Conversion process
*/
class browser extends \IPSUtf8\Dispatcher\Controller
{
{
/**
* Execute
*
@@ -25,7 +25,7 @@ class browser extends \IPSUtf8\Dispatcher\Controller
public function manage()
{
$output = NULL;
switch( \IPSUtf8\Session::i()->status )
{
default:
@@ -36,7 +36,7 @@ class browser extends \IPSUtf8\Dispatcher\Controller
break;
}
}
/**
* Process
*
@@ -47,19 +47,19 @@ class browser extends \IPSUtf8\Dispatcher\Controller
if ( isset( \IPSUtf8\Request::i()->use_utf8mb4 ) )
{
$sessionData = \IPSUtf8\Session::i()->json;
$sessionData['use_utf8mb4'] = ( ! empty( \IPSUtf8\Request::i()->use_utf8mb4 ) ) ? 1 : 0;
\IPSUtf8\Session::i()->json = $sessionData;
\IPSUtf8\Session::i()->save();
}
\IPSUtf8\Convert::i()->process( 100 );
$json = \IPSUtf8\Session::i()->json;
$percent = round( ($json['convertedCount'] / \IPSUtf8\Convert::i()->getTotalRowsToConvert()) * 100, 2 );
$msg = "Processing " . \IPSUtf8\Session::i()->current_table . '<br>Row: ' . \IPSUtf8\Session::i()->current_row . ' of ' . \IPSUtf8\Session::i()->tables[ \IPSUtf8\Session::i()->current_table ]['count'] . ' - Total: ' . $percent . '%';
if ( ! \IPSUtf8\Request::i()->isAjax() )
{
\IPSUtf8\Output\Browser::i()->output = Template::process( \IPSUtf8\Session::i()->status, $percent, $msg );
@@ -69,7 +69,7 @@ class browser extends \IPSUtf8\Dispatcher\Controller
\IPSUtf8\Output\Browser::i()->sendOutput( json_encode( array( \IPSUtf8\Session::i()->status, $percent, $msg ) ), 200, 'application/json' );
}
}
/**
* Completed
*
@@ -80,7 +80,7 @@ class browser extends \IPSUtf8\Dispatcher\Controller
\IPSUtf8\Session::i()->reset();
return $this->welcome();
}
/**
* Completed
*
@@ -91,7 +91,7 @@ class browser extends \IPSUtf8\Dispatcher\Controller
\IPSUtf8\Convert::i()->finish();
\IPSUtf8\Output\Browser::i()->output = Template::completed( \IPSUtf8\Session::i()->timeTaken( true ) );
}
/**
* We're finished! (In a good way)
*
@@ -100,11 +100,10 @@ class browser extends \IPSUtf8\Dispatcher\Controller
public function finish()
{
\IPSUtf8\Convert::i()->renameTables();
\IPSUtf8\Convert::i()->deleteOriginalTables();
\IPSUtf8\Session::i()->status = null;
\IPSUtf8\Session::i()->completed_json = array();
\IPSUtf8\Session::i()->reset();
/* Attempt to automatically update conf_global.php */
$updated = FALSE;
@@ -136,7 +135,7 @@ class browser extends \IPSUtf8\Dispatcher\Controller
\IPSUtf8\Output\Browser::i()->output = Template::finished( $updated );
}
/**
* Welcome page
*
@@ -149,39 +148,31 @@ class browser extends \IPSUtf8\Dispatcher\Controller
@mkdir( THIS_PATH . '/tmp' );
@chmod( THIS_PATH . '/tmp', 0777 );
}
if ( ! is_writable( THIS_PATH . '/tmp' ) )
{
\IPSUtf8\Output\Browser::i()->error("Please ensure that '" . THIS_PATH . '/tmp' . "' is writable.");
exit();
}
if ( IPB_LOCK and ! \IPSUtf8\Session::i()->is_ipb )
{
\IPSUtf8\Output\Browser::i()->error("Cannot locate the IP.Board database tables. Please check to ensure the SQL Prefix if set, is correct in 'conf_global.php'.");
exit();
}
if ( ! count( \IPSUtf8\Session::i()->tables ) )
{
\IPSUtf8\Output\Browser::i()->error("No tables found for processing. Please check to ensure the correct database name and prefix are being used.");
exit();
}
if ( \IPSUtf8\Convert::i()->databaseIsUtf8() AND !count( \IPSUtf8\Convert::i()->getNonUtf8CollationTables() ) )
{
\IPSUtf8\Output\Browser::i()->error( 'The database tables are UTF-8, collations are correct and there is nothing to convert. You can <strong><a href="../upgrade">proceed with the upgrade</strong>.' );
exit();
}
$json = \IPSUtf8\Session::i()->json;
$percent = ( \IPSUtf8\Convert::i()->getTotalRowsToConvert() ) ? sprintf ("%6.2f", round( ($json['convertedCount'] / \IPSUtf8\Convert::i()->getTotalRowsToConvert() ) * 100, 2 ) ) : 100;
$percent = ( \IPSUtf8\Convert::i()->getTotalRowsToConvert() ) ? round( ($json['convertedCount'] / \IPSUtf8\Convert::i()->getTotalRowsToConvert() ) * 100, 2 ) : 100;
$isUtf8 = (boolean) ( \IPSUtf8\Convert::i()->databaseIsUtf8() );
$processing = (boolean) ( \IPSUtf8\Session::i()->status === 'processing' );
\IPSUtf8\Output\Browser::i()->output = Template::welcome( $isUtf8, \IPSUtf8\Session::i()->status, $percent );
}
}
+2 -2
View File
@@ -2,9 +2,9 @@
/**
* @brief Web conversion process
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @package IPS Community Suite
* @since 9 Sept 2013
* @version SVN_VERSION_NUMBER
*/
+11 -6
View File
@@ -2,9 +2,9 @@
/**
* @brief CLI conversion process
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @package IPS Community Suite
* @since 9 Sept 2013
* @version SVN_VERSION_NUMBER
*/
@@ -144,9 +144,11 @@ class cli
\IPSUtf8\Output\Cli::i()->sendOutput( "\n" . count( $convertClass::i()->getNonUtf8Tables() ) . " table(s) are not UTF-8 and need converting.\n");
$origUtf8Charset = \IPSUtf8\Db::i('utf8')->getCharset();
if ( version_compare( \IPSUtf8\Db::i()->server_info, '5.5.3', '>=' ) AND \IPSUtf8\Db::i('utf8')->set_charset('utf8mb4') !== FALSE )
$canMb4 = (bool) \IPSUtf8\Db::i('utf8')->set_charset( 'utf8mb4' );
\IPSUtf8\Db::i('utf8')->set_charset( $origUtf8Charset );
if ( version_compare( \IPSUtf8\Db::i()->server_info, '5.5.3', '>=' ) AND $canMb4 !== FALSE )
{
\IPSUtf8\Output\Cli::i()->sendOutput("Use 4-byte UTF-8 Encoding (utf8mb4)?\nSome non-common symbols (such as historical scripts, music symbols and Emoji) require more space in the database to be stored. If you choose 'no', users will not be able to use these symbols on your site. If 'yes', these characters will be able to be used, but the database will use more disk space.\n<choice>[y] Enter 'y' for Yes\n[n] Enter 'n' for No</choice>", 100 );
\IPSUtf8\Output\Cli::i()->sendOutput("Use 4-byte UTF-8 Encoding (utf8mb4)?\nSome non-common symbols (such as historical scripts, music symbols and Emoji) require more space in the database to be stored. If you choose 'no', users will not be able to use these symbols on your site. If 'yes', these characters will be able to be used, but the database will use more disk space.\n<choice>[y] Enter 'y' for Yes\n[n] Enter 'n' for No\n[x] Enter 'x' to exit</choice>", 100 );
$sessionData = \IPSUtf8\Session::i()->json;
@@ -154,15 +156,18 @@ class cli
{
$sessionData['use_utf8mb4'] = 1;
}
else
else if ( \IPSUtf8\Output\Cli::i()->response === 'n' )
{
$sessionData['use_utf8mb4'] = 0;
}
else
{
exit;
}
\IPSUtf8\Session::i()->json = $sessionData;
\IPSUtf8\Session::i()->save();
}
\IPSUtf8\Db::i('utf8')->set_charset( $origUtf8Charset );
\IPSUtf8\Output\Cli::i()->sendOutput( $intro );
+4 -4
View File
@@ -26,12 +26,12 @@
The converter will create new tables with the prefix "x_utf_". The converter will read your existing data, convert it to UTF-8 and then save it into the "x_utf_" prefixed tables.
</p>
<p>
Once the data conversion has taken place, you can test the conversion by editing your <code>conf_global.php</code> file to alter the <code>sql_prefix</code> and to make sure that the <code>sql_charset</code> is set to <code>utf8</code>. The exact instructions for this
Once the data conversion has taken place, you can test the conversion by editing your <code>conf_global.php</code> file to alter the <code>sql_tbl_prefix</code> and to make sure that the <code>sql_charset</code> is set to <code>utf8</code>. The exact instructions for this
are shown when the conversion has finished.
</p>
<p>
Once you are happy that the conversion is correct, you are prompted to <strong>finish</strong> the conversion. This will rename your existing database tables with the prefix "orig_" and the UTF-8 tables
will be renamed to your existing prefix. You are then prompted again to edit your <code>conf_global.php</code> file to alter the <code>sql_prefix</code>.
will be renamed to your existing prefix. You are then prompted again to edit your <code>conf_global.php</code> file to alter the <code>sql_tbl_prefix</code>.
</p>
<p>
You can then delete the "orig_" prefixed tables when you are happy that the conversion is complete and the original unconverted data is no longer required.
@@ -45,10 +45,10 @@
</p>
<h3>Getting Help</h3>
<p>
If you encounter any issues while using this conveter, please report the issue to our <a href="http://community.invisionpower.com/resources/bugs.html/_/ips-extras/">bug tracker</a>. When creating a new
If you encounter any issues while using this converter, please report the issue to our <a href="https://invisionpower.com/4bugtrack/">bug tracker</a>. When creating a new
bug report please copy and paste the "info" from the converter output.
<br />
Active IP.Board license holders can also request support via the <a href="https://invisionpower.com/clients">client center</a>.
Active IP.Board license holders can also request support via the <a href="https://invisionpower.com/clientarea">client center</a>.
<br />
If you're using the command line version, please run <code>php cli.php --info</code>. If you're using the web version, please click on the "Tools" button at the top. This information
will help us debug the issue. No sensitive data is ever revealed with this tool.
+1 -1
View File
@@ -2,7 +2,7 @@
/**
* @brief Archive table conversion module
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Tools
* @since 4 Sept 2013
+46 -26
View File
@@ -2,7 +2,7 @@
/**
* @brief Conversion module
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Tools
* @since 4 Sept 2013
@@ -16,7 +16,7 @@ namespace IPSUtf8;
*/
class Convert
{
const VERSION_ID = '1.1.18';
const VERSION_ID = '1.1.20';
/**
* @brief Data Store
@@ -147,7 +147,7 @@ class Convert
/* MB4? */
$sessionData = \IPSUtf8\Session::i()->json;
if ( isset( $sessionData['use_utf8mb4'] ) AND ! empty( $sessionData['use_utf8mb4'] ) )
if ( isset( $sessionData['use_utf8mb4'] ) AND $sessionData['use_utf8mb4'] )
{
static::$utf->set_charset( 'utf8mb4' );
}
@@ -301,13 +301,13 @@ class Convert
/* Even if the current charset is set to UTF-8, if the Table Charset is latin1, we need to use this method */
/* ... but only if the actual column isn't using utf8 */
$columnCollation = $schematic['definition']['columns'][$col]['collation'];
if ( defined( 'UTF8_INSERT_ONLY' ) AND UTF8_INSERT_ONLY === TRUE AND $tableCharSet == 'utf8' )
if ( UTF8_INSERT_ONLY === TRUE AND $tableCharSet == 'utf8' )
{
$select[] = 'CAST( `' . $col . '` AS BINARY )';
}
else if ( \IPSUtf8\Session::i()->current_charset != 'utf-8' OR ( $tableCharSet != 'utf8' AND ! in_array( $columnCollation, array( 'utf8_unicode_ci', 'utf8mb4_unicode_ci' ) ) ) OR ( $tableCharSet == 'utf8' AND mb_substr( $columnCollation, 0, 5 ) == 'latin' ) )
else if ( FORCE_MULTI_CONVERT === FALSE AND ( \IPSUtf8\Session::i()->current_charset != 'utf-8' OR ( $tableCharSet != 'utf8' AND ! in_array( $columnCollation, array( 'utf8_unicode_ci', 'utf8mb4_unicode_ci' ) ) ) OR ( $tableCharSet == 'utf8' AND mb_substr( $columnCollation, 0, 5 ) == 'latin' ) ) )
{
if ( \IPSUtf8\Session::i()->current_charset == 'iso-8859-1' OR mb_substr( $columnCollation, 0, 5 ) == 'latin' )
if ( \IPSUtf8\Session::i()->current_charset == 'iso-8859-1' AND mb_substr( $columnCollation, 0, 5 ) == 'latin' )
{
/* Casting as binary truncates non-latin characters, so if we are using real Latin1, just convert */
$select[] = 'CONVERT( `' . $col . '` USING utf8 )';
@@ -557,7 +557,7 @@ class Convert
/* Optimise */
$this->preInsert( $table );
$insertId = static::$utf->insert( $table['name'], $batch, false, true, $table );
$insertId = static::$utf->insert( $table['name'], $batch, true, true, $table );
if ( ! empty( static::$utf->error ) )
{
@@ -985,7 +985,7 @@ class Convert
$modify = array();
$hasUnique = FALSE;
/* Changing collation can cause issues for duplicate enries in unique keys */
/* Changing collation can cause issues for duplicate entries in unique keys */
if ( isset( $tableData['definition']['indexes'] ) )
{
foreach( $tableData['definition']['indexes'] as $key => $index )
@@ -1017,7 +1017,7 @@ class Convert
/* Let's try an alter first - below may not be necessary */
try
{
static::$utf->query( "ALTER TABLE `" . static::$db->prefix . $name . "` CONVERT TO CHARACTER SET " . $charset . " COLLATE " . $collation );
static::$utf->query( "ALTER TABLE `" . static::$db->prefix . $name . "` CONVERT TO CHARACTER SET " . $charset . " COLLATE " . $collation );
static::$utf->query( "ALTER TABLE `" . static::$db->prefix . $name . "` DEFAULT CHARACTER SET " . $charset . " COLLATE " . $collation );
}
catch( \IPSUtf8\Db\Exception $e )
@@ -1026,14 +1026,13 @@ class Convert
static::$utf->query( "RENAME TABLE `" . static::$db->prefix . $name . "` TO `" . static::$db->prefix . $name . "_temp`" );
static::log( $name . " has Unique Index - temp table created from main." );
static::$utf->query( "CREATE TABLE `" . static::$db->prefix . $name . "` LIKE `" . static::$db->prefix . $name . "_temp`" );
static::$utf->query( "ALTER TABLE `" . static::$db->prefix . $name . "` CONVERT TO CHARACTER SET " . $charset . " COLLATE " . $collation );
static::$utf->query( "ALTER TABLE `" . static::$db->prefix . $name . "` DEFAULT CHARACTER SET " . $charset . " COLLATE " . $collation );
static::log( $name . " created from temp table." );
static::$utf->query( "REPLACE INTO `" . static::$db->prefix . $name . "` SELECT * FROM `" . static::$db->prefix . $name . "_temp`" );
static::log( $name . " data copied to new table." );
static::$utf->query( "DROP TABLE `" . static::$db->prefix . $name . "_temp`" );
static::log( $name . "_temp dropped" );
static::$utf->query( "ALTER TABLE `" . static::$db->prefix . $name . "` CONVERT TO CHARACTER SET " . $charset . " COLLATE " . $collation );
static::$utf->query( "ALTER TABLE `" . static::$db->prefix . $name . "` DEFAULT CHARACTER SET " . $charset . " COLLATE " . $collation );
}
}
else
@@ -1078,6 +1077,12 @@ class Convert
/* Update table data */
\IPSUtf8\Session::i()->updateTableData();
/* Update character set if we're in IP.Board */
if ( static::$utf->checkForTable('core_sys_conf_settings' ) )
{
static::$utf->update( 'core_sys_conf_settings', array( 'conf_value' => '' ), array( 'conf_key=?', 'gb_char_set' ) );
}
}
/**
@@ -1085,7 +1090,7 @@ class Convert
*
* @param int $limit Process() method limit
* @param int $cycleCount Items processed if this was in the middle of process()
* @return void
* @return bool|null
*/
public function heal( $limit=250, $cycleCount=0 )
{
@@ -1147,6 +1152,8 @@ class Convert
/* Run again */
return $this->process( ( $limit - $cycleCount ), TRUE );
}
return null;
}
/**
@@ -1160,7 +1167,7 @@ class Convert
if ( \IPSUtf8\Session::i()->current_table AND isset( \IPSUtf8\Session::i()->tables[ \IPSUtf8\Session::i()->current_table ] ) )
{
/* Table selected and convertion in progress */
/* Table selected and conversion in progress */
$table = \IPSUtf8\Session::i()->tables[ \IPSUtf8\Session::i()->current_table ];
static::log( "Continuing with " . $table['name'] . ' (PKEY: ' . \IPSUtf8\Session::i()->current_pkey . ')' );
@@ -1502,6 +1509,16 @@ class Convert
return false;
}
/**
* Returns whether the database is IPS4 already
*
* @return boolean
*/
public function databaseIsIPS4()
{
return (boolean) static::$db->checkForTable( 'core_members' );
}
/**
* Returns whether the DB is UTF8 already
*
@@ -1686,19 +1703,22 @@ class Convert
*/
public static function log( $message )
{
$file = THIS_PATH . '/tmp/log_' . date('Y-m-d') . '.cgi';
$isNew = false;
if ( ! is_file( $file ) )
if ( LOG )
{
$isNew = true;
}
@file_put_contents( $file, "\n" . str_repeat( '-', 48 ) . "\n" . date('r') . "\n" . $message, FILE_APPEND );
if ( $isNew )
{
@chmod( $file, 0777 );
$file = THIS_PATH . '/tmp/log_' . date('Y-m-d') . '.cgi';
$isNew = false;
if ( ! is_file( $file ) )
{
$isNew = true;
}
@file_put_contents( $file, "\n" . str_repeat( '-', 48 ) . "\n" . date('r') . "\n" . $message, FILE_APPEND );
if ( $isNew )
{
@chmod( $file, 0777 );
}
}
}
+2 -2
View File
@@ -2,9 +2,9 @@
/**
* @brief Binding Class for Prepared Statements
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @package IPS Community Suite
* @since 18 Feb 2013
* @version SVN_VERSION_NUMBER
*/
+15 -6
View File
@@ -2,9 +2,9 @@
/**
* @brief Database Class
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @package IPS Community Suite
* @since 18 Feb 2013
* @version SVN_VERSION_NUMBER
*/
@@ -225,11 +225,20 @@ class Db extends \mysqli
*/
public function set_charset( $charset )
{
if ( $charset === 'utf8mb4' )
if ( mb_substr( $charset, 0, 4 ) == 'utf8' )
{
$this->charset = 'utf8mb4';
$this->collation = 'utf8mb4_unicode_ci';
$this->binaryCollation = 'utf8mb4_bin';
if ( $charset === 'utf8mb4' )
{
$this->charset = 'utf8mb4';
$this->collation = 'utf8mb4_unicode_ci';
$this->binaryCollation = 'utf8mb4_bin';
}
else
{
$this->charset = 'utf8';
$this->collation = 'utf8_unicode_ci';
$this->binaryCollation = 'utf8_bin';
}
}
return parent::set_charset( $charset );
+2 -2
View File
@@ -2,9 +2,9 @@
/**
* @brief Exception class for database errors
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @package IPS Community Suite
* @since 18 Feb 2013
* @version SVN_VERSION_NUMBER
*/
+3 -3
View File
@@ -2,9 +2,9 @@
/**
* @brief Database SELECT Statement
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @package IPS Community Suite
* @since 28 Aug 2013
* @version SVN_VERSION_NUMBER
*/
@@ -195,7 +195,7 @@ class Select implements \Iterator, \Countable
* Get first record
*
* @return array
* @throws \OutOfRangeException
* @throws \UnderflowException
*/
public function first()
{
@@ -2,7 +2,7 @@
/**
* @brief Dispatcher (Web)
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Tools
* @since 4 Sept 2013
@@ -22,6 +22,12 @@ class Browser extends \IPSUtf8\Dispatcher
*/
public function run()
{
/* Is this already IPS4 or has the lock been removed? */
if( ! \BYPASS_SAFETY_LOCK and \IPSUtf8\Convert::i()->databaseIsIPS4() )
{
\IPSUtf8\Output\Browser::i()->error( \IPSUtf8\Output\Browser\Template::errorAlreadyIPS4() );
}
$this->controller = ( \IPSUtf8\Request::i()->controller ) ? \IPSUtf8\Request::i()->controller : 'browser';
$fileLocation = \THIS_PATH . '/modules/browser/' . $this->controller . '.php';
+1 -1
View File
@@ -2,7 +2,7 @@
/**
* @brief Dispatcher (CLI)
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Tools
* @since 4 Sept 2013
@@ -2,9 +2,9 @@
/**
* @brief Abstract class that Controllers should extend
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @package IPS Community Suite
* @since 18 Feb 2013
* @version SVN_VERSION_NUMBER
*/
@@ -2,7 +2,7 @@
/**
* @brief Dispatcher
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Tools
* @since 4 Sept 2013
+3 -3
View File
@@ -2,9 +2,9 @@
/**
* @brief Output Class
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @package IPS Community Suite
* @since 9 Sept 2013
* @version SVN_VERSION_NUMBER
*/
@@ -51,7 +51,7 @@ class Browser extends \IPSUtf8\Output
public function error( $message )
{
/* Send output */
$this->sendOutput( \IPSUtf8\Output\Browser\Template::wrapper( "IPS Converter", \IPSUtf8\Output\Browser\Template::error( $message ), 500 ) );
$this->sendOutput( \IPSUtf8\Output\Browser\Template::wrapper( "IPS Converter", \IPSUtf8\Output\Browser\Template::error( $message ), true ), 500 );
exit();
}
@@ -2,9 +2,9 @@
/**
* @brief Template Class
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @package IPS Community Suite
* @since 9 Sept 2013
* @version SVN_VERSION_NUMBER
*/
@@ -16,7 +16,7 @@ namespace IPSUtf8\Output\Browser;
*/
class Template
{
public static function wrapper( $title="IPS Converter", $content="")
public static function wrapper( $title="IPS Converter", $content="", $isError=false )
{
$iniTime = @ini_get('max_execution_time');
$execTime = ( is_numeric( $iniTime ) ) ? $iniTime : 30;
@@ -53,6 +53,11 @@ class Template
<body data-url="{$url}">
<div class="container">
<div class="header">
EOFHTML;
if ( ! $isError )
{
$html .= <<<EOFHTML
<ul class="nav nav-pills pull-right">
<li class="{$active['convert']}"><a href="{url="?controller=browser"}">Convert</a></li>
EOFHTML;
@@ -66,6 +71,9 @@ EOFHTML;
$html .= <<<EOFHTML
<li class="{$active['tools']}"><a href="{url="?controller=tools"}">Tools</a></li>
</ul>
EOFHTML;
}
$html .= <<<EOFHTML
<h3 class="text-muted">IPS UTF8 Converter</h3>
</div>
{$content}
@@ -159,7 +167,7 @@ EOFHTML;
}
/**
* Welcome page
* Error page
*/
public static function error( $msg )
{
@@ -173,6 +181,28 @@ EOFHTML;
return static::parse( $html );
}
/**
* Error page explaining about database being IPS4 already
*/
public static function errorAlreadyIPS4()
{
$html = <<<EOFHTML
<p style="text-align:left">
The target database is already IPS4. There is no conversion required and the UTF8 converter is locked.
<br>To override this and unlock the UTF8 converter, please create a file called "constants.php" and upload it to your /admin/convertutf8/ directory with the following contents:
</p>
<p><textarea class="form-control" style="height:90px;">&lt;?php
define( 'BYPASS_SAFETY_LOCK', true );
</textarea>
</p>
<p class="text-danger">Please remember to remove the constants.php file when you are finished!</p>
EOFHTML;
return static::parse( $html );
}
/**
* Welcome page
*/
@@ -236,14 +266,13 @@ else if ( $isUtf8 === true )
The database is set to UTF-8, however {$cnt} table(s) have incorrect collations and need fixing.
<p><a class="btn btn-lg btn-info" href="{url="?controller=tools&amp;do=collation"}">Fix UTF-8 collations</a></p>
</p>
<p class="text-info">
If, after this process completes, you start to experience errors or see corrupt text, it is likely that you need to convert your data anyway. You can do this by clicking the button below.<br>
<a class='btn btn-info' href='{url="?controller={$controller}&amp;convert_anyway=1"}'>Run the Conversion</a>
</p>
EOFHTML;
}
else
{
/* If the charset stored for the gb_char_set setting is not utf-8, then we'll hit an endless loop unless we fix it here */
\IPSUtf8\Db::i()->update( 'core_sys_conf_settings', array( 'conf_value' => 'utf-8' ), array( 'conf_key=?', 'gb_char_set' ) );
$html .= <<<EOFHTML
<p class="text-info">
@@ -292,7 +321,8 @@ $label = 'Start using UTF-8 (utf8)';
<small>
If you have a large community, or are experiencing browser timeouts during conversion, you may wish to consider running the conversion via the Command Line.<br>
<code>
php {$path}/admin/convertutf8/cli.php
cd {$path}/admin/convertutf8
php cli.php
</code>
</small>
</div>
+2 -2
View File
@@ -2,9 +2,9 @@
/**
* @brief Output Class
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @package IPS Community Suite
* @since 9 Sept 2013
* @version SVN_VERSION_NUMBER
*/
+2 -2
View File
@@ -2,9 +2,9 @@
/**
* @brief Output Class
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @package IPS Community Suite
* @since 9 Sept 2013
* @version SVN_VERSION_NUMBER
*/
@@ -2,9 +2,9 @@
/**
* @brief Singleton Pattern
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @package IPS Community Suite
* @since 18 Feb 2013
* @version SVN_VERSION_NUMBER
*/
+2 -2
View File
@@ -2,9 +2,9 @@
/**
* @brief HTTP Request Class
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @package IPS Community Suite
* @since 18 Feb 2013
* @version SVN_VERSION_NUMBER
*/
+44 -3
View File
@@ -2,9 +2,9 @@
/**
* @brief Session Handler
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @package IPS Community Suite
* @since 6th Sept 2013
* @version SVN_VERSION_NUMBER
*/
@@ -372,6 +372,17 @@ class Session
{
continue;
}
/* Skip if it's an _old or _utftemp table */
if( mb_substr( $tableName, -4 ) == '_old' )
{
continue;
}
if( mb_substr( $tableName, -8 ) == '_utftemp' )
{
continue;
}
if ( mb_substr( $tableName, 0, mb_strlen( \IPSUtf8\Db::i()->prefix ) ) === \IPSUtf8\Db::i()->prefix )
{
@@ -396,7 +407,7 @@ class Session
$data['tableCount']++;
$row = \IPSUtf8\Db::i()->query( "SHOW CREATE TABLE `" . \IPSUtf8\Db::i()->prefix . "{$table}`" )->fetch_assoc();
if ( preg_match( '#\scharset=([a-z0-9]+?)(\s|$)#i', $row['Create Table'], $matches ) )
{
$tblCharset = $matches[1];
@@ -425,10 +436,40 @@ class Session
try
{
$test = @json_encode( $definition );
if ( json_last_error() != JSON_ERROR_NONE )
{
throw new \ErrorException;
}
}
catch( \ErrorException $e )
{
$definition = static::arrayWalkRecursive( $definition, function( $value ) { return utf8_encode( $value ); } );
/* Try it again - if it fails this time, remove the column comments as that is likely causing the issue if they have non-latin characters */
$test = @json_encode( $definition );
if ( json_last_error() != JSON_ERROR_NONE )
{
foreach( $definition['columns'] AS $column => $data )
{
if ( isset( $data['comment'] ) )
{
unset( $definition['columns'][ $column ]['comment'] );
}
}
}
}
/* If the collation is missing, let's do a table status check and see if we can figure it out */
if ( empty( $definition['collation'] ) )
{
$status = \IPSUtf8\Db::i()->query( "SHOW TABLE STATUS WHERE Name='" . \IPSUtf8\Db::i()->prefix . "{$table}'" )->fetch_assoc();
if( isset( $status['Collation'] ) )
{
$definition['collation'] = $status['Collation'];
}
}
/* Get other data */
+1 -1
View File
@@ -2,7 +2,7 @@
/**
* @brief Conversion module
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Tools
* @since 4 Sept 2013
@@ -2,7 +2,7 @@
/**
* @brief Conversion module
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Tools
* @since 4 Sept 2013
@@ -2,7 +2,7 @@
/**
* @brief Conversion module
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Tools
* @since 4 Sept 2013
+1 -1
View File
@@ -2,7 +2,7 @@
/**
* @brief Conversion module
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Tools
* @since 4 Sept 2013
@@ -2,7 +2,7 @@
/**
* @brief Conversion module
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Tools
* @since 4 Sept 2013