Invision Power Services, Inc.
* @copyright (c) Invision Power Services, Inc.
* @license https://www.invisioncommunity.com/legal/standards/
* @package Invision Community
* @since 9 Sept 2013
*/
namespace IPSUtf8\Output\Browser;
/**
* Template Class
*/
class Template
{
public static function wrapper( $title="IPS Converter", $content="", $isError=false )
{
$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 = preg_replace( "/[^a-zA-Z0-9]/", '', 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 = <<Tools
EOFHTML;
if ( $msg !== null )
{
$html .= <<
EOFHTML; } if ( ! isset( \IPSUtf8\Request::i()->do ) ) { if ( $isUtf8 === true ) { $html .= <<
{$code}
EOFHTML;
return static::parse( $html );
}
/**
* Error page
*/
public static function error( $msg )
{
$html = <<{$msg}
EOFHTML; return static::parse( $html ); } /** * Error page explaining about database being Invision Community already */ public static function errorAlreadyIPS4() { $html = <<
Please remember to remove the constants.php file when you are finished!
EOFHTML; return static::parse( $html ); } /** * Welcome page */ public static function welcome( $isUtf8, $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 = <<
cd {$path}/admin/convertutf8
php 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}.