HEX
Server: Apache/2.4.59 (Debian)
System: Linux skycube.cz 4.19.0-25-amd64 #1 SMP Debian 4.19.289-2 (2023-08-08) x86_64
User: ilya (534)
PHP: 7.3.31-1~deb10u7
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,
Upload Files
File: /var/www/ilya/data/www/irkboard.ru/admin/setup/applications/upgrade/sections/convert.php
<?php
/**
 * Invision Power Services
 * IP.Board v3.0.0
 * Upgrader: Database Convertion
 *
 * @author 		Tony
 * @copyright	(c) 2009 IBResource.ru
 * @license		http://www.invisionpower.com/community/board/license.html
 * @package		Invision Power Board
 * @link		http://www.invisionpower.com
 *
 */

class upgrade_convert extends ipsCommand
{
	/**
	 * Execute selected method
	 *
	 * @access	public
	 * @param	object		Registry object
	 * @return	void
	 */
	public function doExecute( ipsRegistry $registry ) {

        // uncomment to skip this step
        //$this->registry->autoLoadNextAction( 'apps' );

        if( strtolower( $this->settings['sql_driver'] ) == 'mysql' ) {

            $utf8_ok = FALSE;
            $table_prefix = $this->registry->dbFunctions()->getPrefix(); // PREFIX CAN BE EMPTY !

            $this->DB->return_die       = 1;
            $this->DB->allow_sub_select = 1;
            $this->DB->error			= '';

            if( substr( $this->DB->getSqlVersion(), 0, 1 ) >= 5 ) {
                $query = "SELECT table_collation FROM INFORMATION_SCHEMA.TABLES WHERE table_schema = '{$this->settings['sql_database']}' AND table_name LIKE '{$table_prefix}%'";

                $this->DB->query( $query );

                if ( $this->DB->error ) {
                    $this->registry->output->addError( nl2br( $query ) . '<br /><br />' . $this->DB->error );
                }
                else {

                    $utf8_ok = TRUE;

                    while( $r = $this->DB->fetch() ) {

                        if ( strpos( $r['table_collation'], 'utf8' ) !== 0 ) {
                            $utf8_ok = FALSE;
                            break;
                        }
                    }
                }
            }
            else {
                $tables = Array( 'posts', 'forums' );

                foreach( $tables as $table ) {

                    $table = $table_prefix . $table;
                    $query = 'SHOW CREATE TABLE ' . $table;

                    $this->DB->query( $query );

                    if ( $this->DB->error ) {
                        $this->registry->output->addError( nl2br( $query ) . '<br /><br />' . $this->DB->error );
                        $utf8_ok = FALSE;
                        break;
                    }

                    $code = $this->DB->fetch();

                    if ( preg_match( '/ DEFAULT CHARSET=utf8/', $code['Create Table'] )) {
                        $utf8_ok = TRUE;
                    }
                    else {
                        $utf8_ok = FALSE;
                    }
                }
            }

            if( $utf8_ok ) {
                $this->registry->autoLoadNextAction( 'apps' );
            }
            else {
                $this->registry->output->setNextAction( '' );
                $this->registry->output->setHideButton( TRUE );
                $this->registry->output->setTitle( 'Конвертация базы данных' );
                $this->registry->output->addContent( $this->registry->output->template()->page_convert() );
                $this->registry->output->sendOutput();
            }
        }
        else {
            $this->registry->autoLoadNextAction( 'apps' );
        }
    }
}