Invision Power Services, Inc.
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @since 9 Sept 2013
* @version SVN_VERSION_NUMBER
*/
namespace IPSUtf8\Output\Browser;
/**
* Template Class
*/
class Template
{
public static function wrapper( $title="IPS Converter", $content="")
{
$iniTime = @ini_get('max_execution_time');
$execTime = ( is_numeric( $iniTime ) ) ? $iniTime : 30;
$url = \IPSUtf8\Output\Browser::$url;
$title = ( empty( $title ) ) ? 'IPS Converter' : $title;
$active = array( 'convert' => '', 'tools' => '', 'archive' => '' );
$hasArchive = \IPSUtf8\Session::i()->has_archive;
$controller = empty( \IPSUtf8\Request::i()->controller ) ? 'browser' : \IPSUtf8\Request::i()->controller;
$version = \IPSUtf8\Convert::VERSION_ID;
$copyrightDate = date('Y');
if ( $controller == 'browser' )
{
$active['convert'] = 'active';
}
else if ( $controller === 'archive' )
{
$active['archive'] = 'active';
}
else
{
$active['tools'] = 'active';
}
$html = <<IPS UTF8 Converter
Tools
EOFHTML;
if ( $msg !== null )
{
$html .= <<
EOFHTML; } if ( ! isset( \IPSUtf8\Request::i()->do ) ) { if ( $isUtf8 === true ) { $html .= <<
{$code}
EOFHTML;
return static::parse( $html );
}
/**
* Welcome page
*/
public static function error( $msg )
{
$html = <<{$msg}
EOFHTML; return static::parse( $html ); } /** * Welcome page */ public static function welcome( $isUtf8=false, $status, $percent=false, $controller='browser' ) { $convertClass = ( $controller === 'browser' ) ? '\IPSUtf8\Convert' : '\IPSUtf8\Convert\Archive'; $origUtf8Charset = \IPSUtf8\Db::i('utf8')->getCharset(); $canUseMb4 = ( version_compare( \IPSUtf8\Db::i()->server_info, '5.5.3', '>=' ) AND \IPSUtf8\Db::i('utf8')->set_charset('utf8mb4') !== FALSE ); \IPSUtf8\Db::i('utf8')->set_charset( $origUtf8Charset ); $badCollations = $convertClass::i()->getNonUtf8CollationTables(); $badTablesCnt = count( $convertClass::i()->getNonUtf8Tables() ); $path = ROOT_PATH; $dbCharSetIsCorrect = TRUE; $isUtf8mb4 = ( $isUtf8 === TRUE AND \IPSUtf8\Convert::i()->database_charset == 'utf8mb4' ); if ( file_exists( ROOT_PATH . '/conf_global.php' ) ) { require_once( ROOT_PATH . '/conf_global.php' ); if ( !isset( $INFO['sql_charset'] ) OR ! in_array( $INFO['sql_charset'], array( 'utf8', 'utf8mb4' ) ) ) { $dbCharSetIsCorrect = FALSE; } } if ( isset( \IPSUtf8\Request::i()->convert_anyway ) AND \IPSUtf8\Request::i()->convert_anyway == 1 ) { $badTablesCnt = \IPSUtf8\Session::i()->json['tableCount']; } $html = <<
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.
Run the Conversion
php {$path}/admin/convertutf8/cli.php
{$msg}
EOFHTML; return static::parse( $html ); } /** * Completed page */ public static function completed( $timeTaken ) { $html = <<The database has now been converted!
Conversion took {$timeTaken}
EOFHTML; return static::parse( $html ); } /** * Finish page */ public static function finished( $updated ) { $utfPrefix = \IPSUtf8\Db::i('utf8')->prefix; $normalPrefix = \IPSUtf8\Db::i()->prefix; $sessionData = \IPSUtf8\Session::i()->json; $sql_charset = ( array_key_exists( 'utf8mb4', $sessionData['charSets'] ) ) ? 'utf8mb4' : 'utf8'; /* Phil made me give him credit for some changes in this code */ $html = <<
The database has now been converted and the tables correctly renamed!
EOFHTML; if ( \IPSUtf8\Request::i()->controller === 'browser' ) { if( !$updated ) { $utf8mb4 = ( $sql_charset == 'utf8mb4' ) ? "\$INFO['sql_charset'] = '{$sql_charset}';{$utf8mb4}.