2019-03-29 19:13:32 -05:00
< ? php
/*
* e107 website system
*
* Copyright ( C ) 2008 - 2012 e107 Inc ( e107 . org )
* Released under the terms and conditions of the
* GNU General Public License ( http :// www . gnu . org / licenses / gpl . txt )
*
* e107 v2 . x Installation file
*
*/
// minimal software version
2023-11-28 12:31:50 -08:00
define ( 'MIN_PHP_VERSION' , '7.4' );
2019-03-29 19:13:32 -05:00
define ( 'MIN_MYSQL_VERSION' , '4.1.2' );
define ( 'MAKE_INSTALL_LOG' , true );
// ensure CHARSET is UTF-8 if used
//define('CHARSET', 'utf-8');
/* Default Options and Paths for Installer */
$MySQLprefix = 'e107_' ;
$HANDLERS_DIRECTORY = " e107_handlers/ " ; // needed for e107 class init
header ( 'Content-type: text/html; charset=utf-8' );
define ( " e107_INIT " , TRUE );
2021-11-29 13:45:02 -08:00
define ( " DEFAULT_INSTALL_THEME " , 'bootstrap5' );
2022-04-07 07:15:30 -07:00
define ( 'HELPICON' , " <span class='e-tip glyphicon glyphicon-question-sign' style='float:right;padding-top:3px'></span> " ); // <i class="glyphicon glyphicon-question-sign"></i>
2019-03-29 19:13:32 -05:00
2019-06-03 15:27:36 -07:00
$e107info = array ();
2019-03-29 19:13:32 -05:00
require_once ( " e107_admin/ver.php " );
define ( " e_VERSION " , $e107info [ 'e107_version' ]);
2020-12-10 15:52:48 -08:00
$e_ROOT = realpath ( __DIR__ . " / " );
2019-06-03 15:27:36 -07:00
if (( substr ( $e_ROOT , - 1 ) !== '/' ) && ( substr ( $e_ROOT , - 1 ) !== '\\' ) )
{
$e_ROOT .= DIRECTORY_SEPARATOR ; // Should function correctly on both windows and Linux now.
}
define ( 'e_ROOT' , $e_ROOT );
unset ( $e_ROOT );
class installLog
{
2020-12-26 08:02:34 -08:00
const logFile = " e107Install.log " ;
2019-06-03 15:27:36 -07:00
2023-09-11 23:11:52 +02:00
/**
* @ param Throwable $exception
* @ return void
*/
static function exceptionHandler ( $exception )
2019-06-03 15:27:36 -07:00
{
$message = $exception -> getMessage ();
self :: add ( $message , " error " );
}
2020-12-26 08:02:34 -08:00
static function errorHandler ( $errno = null , $errstr = null , $errfile = null , $errline = null )
2019-06-03 15:27:36 -07:00
{
2021-02-05 19:57:53 -08:00
$error = " Error on line " . $errline . " in file " . $errfile . " : " . $errstr ;
2019-06-03 15:27:36 -07:00
switch ( $errno )
{
case E_ERROR :
case E_CORE_ERROR :
case E_COMPILE_ERROR :
case E_PARSE :
self :: add ( $error , " fatal " );
break ;
case E_USER_ERROR :
case E_RECOVERABLE_ERROR :
self :: add ( $error , " error " );
break ;
case E_WARNING :
case E_CORE_WARNING :
case E_COMPILE_WARNING :
case E_USER_WARNING :
self :: add ( $error , " warn " );
break ;
case E_NOTICE :
case E_USER_NOTICE :
self :: add ( $error , " notice " );
break ;
case E_STRICT :
self :: add ( $error , " debug " );
break ;
default :
2021-02-05 19:57:53 -08:00
if ( ! empty ( $errno ))
{
self :: add ( $error , " warn " );
}
2019-06-03 15:27:36 -07:00
}
2019-03-29 19:13:32 -05:00
2021-02-05 19:57:53 -08:00
return true ;
2019-06-03 15:27:36 -07:00
}
static function clear ()
{
2020-12-21 17:46:32 -08:00
if ( ! MAKE_INSTALL_LOG || ! is_writable ( __DIR__ ))
2019-06-03 15:27:36 -07:00
{
return null ;
}
2020-12-10 15:52:48 -08:00
$logFile = __DIR__ . '/' . self :: logFile ;
2019-06-03 15:27:36 -07:00
file_put_contents ( $logFile , '' );
}
/**
* Write a line of text to the log file ( if enabled ) - prepend time / date , append \n
* @ param string $message
* @ param string $type
* @ return null
*/
static function add ( $message , $type = 'info' )
{
2020-12-21 17:46:32 -08:00
if ( ! MAKE_INSTALL_LOG || ! is_writable ( __DIR__ ))
2019-06-03 15:27:36 -07:00
{
return null ;
}
2020-12-10 15:52:48 -08:00
$logFile = __DIR__ . '/' . self :: logFile ; // e107InstallLog.log';
2019-06-03 15:27:36 -07:00
$now = time ();
2021-11-29 13:45:02 -08:00
$message = $now . ', ' . date ( 'c' ) . " \t " . $type . " \t " . $message . " \n " ;
2019-06-03 15:27:36 -07:00
file_put_contents ( $logFile , $message , FILE_APPEND );
return null ;
}
}
set_exception_handler ( array ( 'installLog' , 'exceptionHandler' ));
set_error_handler ( array ( 'installLog' , " errorHandler " ));
register_shutdown_function ( array ( 'installLog' , " errorHandler " ));
2019-03-29 19:13:32 -05:00
2021-02-05 19:57:53 -08:00
2019-03-29 19:13:32 -05:00
/* define ( " e_UC_PUBLIC " , 0 );
define ( " e_UC_MAINADMIN " , 250 );
define ( " e_UC_READONLY " , 251 );
define ( " e_UC_GUEST " , 252 );
define ( " e_UC_MEMBER " , 253 );
define ( " e_UC_ADMIN " , 254 );
define ( " e_UC_NOBODY " , 255 ); */
2019-06-03 15:27:36 -07:00
define ( " E107_INSTALL " , true );
2019-03-29 19:13:32 -05:00
2020-12-26 08:02:34 -08:00
if ( $_SERVER [ 'QUERY_STRING' ] !== " debug " ) // install.php?debug
2019-03-29 19:13:32 -05:00
{
error_reporting ( 0 ); // suppress all errors unless debugging.
}
else
{
2019-06-03 15:27:36 -07:00
error_reporting ( E_ALL );
2019-03-29 19:13:32 -05:00
}
2020-12-21 17:46:32 -08:00
if ( $_SERVER [ 'QUERY_STRING' ] === 'clear' )
2019-03-29 19:13:32 -05:00
{
unset ( $_SESSION );
}
//error_reporting(E_ALL);
2020-12-26 08:02:34 -08:00
/* function e107_ini_set ( $var , $value )
2019-03-29 19:13:32 -05:00
{
if ( function_exists ( 'ini_set' ))
{
ini_set ( $var , $value );
}
2020-12-26 08:02:34 -08:00
} */
2019-03-29 19:13:32 -05:00
// setup some php options
2020-12-21 17:46:32 -08:00
ini_set ( 'arg_separator.output' , '&' );
ini_set ( 'session.use_only_cookies' , 1 );
ini_set ( 'session.use_trans_sid' , 0 );
2019-03-29 19:13:32 -05:00
if ( function_exists ( 'date_default_timezone_set' ))
{
date_default_timezone_set ( 'UTC' );
}
2020-12-18 09:39:02 -08:00
define ( 'MAGIC_QUOTES_GPC' , false ); // (ini_get('magic_quotes_gpc') ? true : false));
2019-03-29 19:13:32 -05:00
2020-12-21 17:46:32 -08:00
$php_version = PHP_VERSION ;
2019-03-29 19:13:32 -05:00
if ( version_compare ( $php_version , MIN_PHP_VERSION , " < " ))
{
die_fatal_error ( 'A minimum version of PHP ' . MIN_PHP_VERSION . ' is required' ); // no LAN DEF translation accepted by lower versions <5.3
}
2019-11-04 13:18:26 +01:00
// Check needed to continue (extension check in stage 4 is too late)
if ( ! class_exists ( 'DOMDocument' , false ))
{
die_fatal_error ( " You need to install the DOM extension to install e107. " ); // NO LAN
}
2019-03-29 19:13:32 -05:00
// Ensure that '.' is the first part of the include path
$inc_path = explode ( PATH_SEPARATOR , ini_get ( 'include_path' ));
2020-12-21 17:46:32 -08:00
if ( $inc_path [ 0 ] !== " . " )
2019-03-29 19:13:32 -05:00
{
array_unshift ( $inc_path , " . " );
$inc_path = implode ( PATH_SEPARATOR , $inc_path );
2020-12-26 08:02:34 -08:00
ini_set ( " include_path " , $inc_path );
2019-03-29 19:13:32 -05:00
}
unset ( $inc_path );
if ( ! function_exists ( " mysql_connect " ) && ! defined ( 'PDO::ATTR_DRIVER_NAME' ))
{
die_fatal_error ( " e107 requires PHP to be installed or compiled with PDO or the MySQL extension to work correctly, please see the MySQL manual for more information. " );
}
# Check for the realpath(). Some hosts (I'm looking at you, Awardspace) are totally dumb and
# they think that disabling realpath() will somehow (I'm assuming) help improve their pathetic
# local security. Fact is, it just prevents apps from doing their proper local inclusion security
# checks. So, we refuse to work with these people.
$functions_ok = true ;
$disabled_functions = ini_get ( 'disable_functions' );
if ( trim ( $disabled_functions ) != '' )
{
$disabled_functions = explode ( ',' , $disabled_functions );
foreach ( $disabled_functions as $function )
{
2020-12-21 17:46:32 -08:00
if ( trim ( $function ) === " realpath " )
2019-03-29 19:13:32 -05:00
{
$functions_ok = false ;
}
}
}
if ( $functions_ok == true && function_exists ( " realpath " ) == false )
{
$functions_ok = false ;
}
if ( $functions_ok == false )
{
die_fatal_error ( " e107 requires the realpath() function to be enabled and your host appears to have disabled it. This function is required for some <b>important</b> security checks and there is <b>NO workaround</b>. Please contact your host for more information. " );
}
//obsolete $installer_folder_name = 'e107_install';
include_once ( " ./ { $HANDLERS_DIRECTORY } core_functions.php " );
include_once ( " ./ { $HANDLERS_DIRECTORY } e107_class.php " );
function check_class ( $whatever = '' )
{
2019-06-03 15:27:36 -07:00
unset ( $whatever );
2019-03-29 19:13:32 -05:00
return true ;
}
function getperms ( $arg , $ap = '' )
{
2019-06-03 15:27:36 -07:00
unset ( $arg , $ap );
2019-03-29 19:13:32 -05:00
return true ;
}
$override = array ();
if ( isset ( $_POST [ 'previous_steps' ]))
{
$tmp = unserialize ( base64_decode ( $_POST [ 'previous_steps' ]));
2021-01-25 09:14:45 -08:00
$override = ( isset ( $tmp [ 'paths' ]) && isset ( $tmp [ 'paths' ][ 'hash' ])) ? array ( 'site_path' => $tmp [ 'paths' ][ 'hash' ]) : array ();
2019-03-29 19:13:32 -05:00
unset ( $tmp );
2019-11-04 22:37:43 +01:00
unset ( $tmpadminpass1 );
2019-03-29 19:13:32 -05:00
}
//$e107_paths = compact('ADMIN_DIRECTORY', 'FILES_DIRECTORY', 'IMAGES_DIRECTORY', 'THEMES_DIRECTORY', 'PLUGINS_DIRECTORY', 'HANDLERS_DIRECTORY', 'LANGUAGES_DIRECTORY', 'HELP_DIRECTORY', 'CACHE_DIRECTORY', 'DOWNLOADS_DIRECTORY', 'UPLOADS_DIRECTORY', 'MEDIA_DIRECTORY', 'LOGS_DIRECTORY', 'SYSTEM_DIRECTORY', 'CORE_DIRECTORY');
$e107_paths = array ();
$e107 = e107 :: getInstance ();
2020-12-10 15:52:48 -08:00
$ebase = realpath ( __DIR__ );
2019-03-29 19:13:32 -05:00
if ( $e107 -> initInstall ( $e107_paths , $ebase , $override ) === false )
{
die_fatal_error ( " Error creating the following empty file: <b> " . $ebase . DIRECTORY_SEPARATOR . " e107_config.php</b><br />Please create it manually and then run the installation again. " );
}
2020-12-26 08:02:34 -08:00
2019-03-29 19:13:32 -05:00
unset ( $e107_paths , $override , $ebase );
// NEW - session handler
require_once ( e_HANDLER . 'session_handler.php' );
define ( 'e_SECURITY_LEVEL' , e_session :: SECURITY_LEVEL_NONE );
define ( 'e_COOKIE' , 'e107install' );
e107 :: getSession (); // starts session, creates default namespace
// session_start();
function include_lan ( $path , $force = false )
{
2019-06-03 15:27:36 -07:00
unset ( $force );
2019-03-29 19:13:32 -05:00
return include ( $path );
}
//obsolete $e107->e107_dirs['INSTALLER'] = "{$installer_folder_name}/";
if ( isset ( $_GET [ 'create_tables' ]))
{
create_tables_unattended ();
exit ;
}
$e_install = new e_install ();
$e_forms = new e_forms ();
$e_install -> template -> SetTag ( " installer_css_http " , $_SERVER [ 'PHP_SELF' ] . " ?object=stylesheet " );
//obsolete $e_install->template->SetTag("installer_folder_http", e_HTTP.$installer_folder_name."/");
$e_install -> template -> SetTag ( " files_dir_http " , e_FILE_ABS );
$e_install -> renderPage ();
/**
* Set Cookie
* @ param string $name
* @ param string $value
* @ param integer $expire seconds
* @ param string $path
* @ param string $domain
* @ param boolean $secure
* @ return void
*/
2019-06-03 15:27:36 -07:00
function cookie ( $name , $value , $expire = 0 , $path = e_HTTP , $domain = '' , $secure = false )
2019-03-29 19:13:32 -05:00
{
2019-06-03 15:27:36 -07:00
setcookie ( $name , $value , $expire , $path , $domain , ( bool ) $secure );
2019-03-29 19:13:32 -05:00
}
class e_install
{
2020-12-08 07:29:17 -08:00
// private $paths;
public $template ;
private $debug_info ;
// private $debug_db_info;
private $e107 ;
public $previous_steps ;
private $stage ;
private $post_data ;
private $required = array ();
private $session ;
2019-03-29 19:13:32 -05:00
protected $pdo = false ;
protected $debug = false ;
// public function __construct()
function __construct ()
{
// notice removal, required from various core routines
define ( 'USERID' , 1 );
define ( 'USER' , true );
define ( 'ADMIN' , true );
2019-06-03 15:27:36 -07:00
// define('e_UC_MAINADMIN', 250);
2019-03-29 19:13:32 -05:00
define ( 'E107_DEBUG_LEVEL' , 0 );
2020-12-21 17:46:32 -08:00
if ( $_SERVER [ 'QUERY_STRING' ] === " debug " )
2019-03-29 19:13:32 -05:00
{
$this -> debug = true ;
}
if ( defined ( 'PDO::ATTR_DRIVER_NAME' ))
{
$this -> pdo = true ;
define ( 'e_PDO' , true );
}
if ( ! empty ( $this -> previous_steps [ 'mysql' ][ 'prefix' ]))
{
define ( 'MPREFIX' , $this -> previous_steps [ 'mysql' ][ 'prefix' ]);
}
$tp = e107 :: getParser ();
// session instance
$this -> session = e107 :: getSession ();
2019-06-03 15:27:36 -07:00
// $this->logLine('Query string: ');
$this -> template = new SimpleTemplate ();
if ( ob_get_level () > 1 )
2019-03-29 19:13:32 -05:00
{
2019-06-03 15:27:36 -07:00
while ( @ ob_end_clean ())
2019-03-29 19:13:32 -05:00
{
2019-06-03 15:27:36 -07:00
unset ( $whatever );
2019-03-29 19:13:32 -05:00
}
}
global $e107 ;
$this -> e107 = $e107 ;
if ( isset ( $_POST [ 'previous_steps' ]))
{
$this -> previous_steps = unserialize ( base64_decode ( $_POST [ 'previous_steps' ]));
2019-11-04 22:37:43 +01:00
// Save unfiltered admin password (#4004) - " are transformed into "
2021-01-25 09:14:45 -08:00
$tmpadminpass2 = ( isset ( $this -> previous_steps [ 'admin' ])) ? $this -> previous_steps [ 'admin' ][ 'password' ] : '' ;
2019-11-04 22:37:43 +01:00
2019-03-29 19:13:32 -05:00
$this -> previous_steps = $tp -> filter ( $this -> previous_steps );
2019-11-04 22:37:43 +01:00
// Restore unfiltered admin password
$this -> previous_steps [ 'admin' ][ 'password' ] = $tmpadminpass2 ;
2019-03-29 19:13:32 -05:00
unset ( $_POST [ 'previous_steps' ]);
2019-11-04 22:37:43 +01:00
unset ( $tmpadminpass2 );
2019-03-29 19:13:32 -05:00
}
else
{
$this -> previous_steps = array ();
}
$this -> get_lan_file ();
$this -> post_data = $tp -> filter ( $_POST );
$this -> template -> SetTag ( 'required' , '' );
if ( isset ( $this -> previous_steps [ 'language' ]))
{
define ( " e_LANGUAGE " , $this -> previous_steps [ 'language' ]);
include_lan ( e_LANGUAGEDIR . e_LANGUAGE . " / " . e_LANGUAGE . " .php " );
include_lan ( e_LANGUAGEDIR . e_LANGUAGE . " /admin/lan_admin.php " );
}
}
function add_button ( $id , $title = '' , $align = " right " , $type = " submit " )
{
global $e_forms ;
$e_forms -> form .= " <div class='buttons-bar inline' style='text-align: { $align } ; z-index: 10;'> " ;
2020-12-21 17:46:32 -08:00
if ( $id !== 'start' )
2019-03-29 19:13:32 -05:00
{
// $this->form .= "<a class='btn btn-large ' href='javascript:history.go(-1)'>« ".LAN_BACK."</a> ";
$prevStage = ( $this -> stage - 1 );
$e_forms -> form .= " <button class='btn btn-default btn-secondary btn-large no-validate ' name='back' value=' " . $prevStage . " ' type='submit'>« " . LAN_BACK . " </button> " ;
}
2020-12-21 17:46:32 -08:00
if ( $id !== 'back' )
2019-03-29 19:13:32 -05:00
{
$e_forms -> form .= " <input type=' { $type } ' id=' { $id } ' name=' { $id } ' value=' { $title } »' class='btn btn-large btn-primary' /> " ;
}
$e_forms -> form .= " </div> \n " ;
}
function renderPage ()
{
if ( ! isset ( $_POST [ 'stage' ]))
{
$_POST [ 'stage' ] = 1 ;
}
2020-12-12 11:32:23 -08:00
$_POST [ 'stage' ] = ( int ) $_POST [ 'stage' ];
2019-03-29 19:13:32 -05:00
if ( ! empty ( $_POST [ 'back' ]))
{
2020-12-12 11:32:23 -08:00
$_POST [ 'stage' ] = ( int ) $_POST [ 'back' ];
2019-03-29 19:13:32 -05:00
}
switch ( $_POST [ 'stage' ])
{
case 1 :
$this -> stage_1 ();
break ;
case 2 :
$this -> stage_2 ();
break ;
case 3 :
$this -> stage_3 ();
break ;
case 4 :
$this -> stage_4 ();
break ;
case 5 :
$this -> stage_5 ();
break ;
case 6 :
$this -> stage_6 ();
break ;
case 7 :
$this -> stage_7 ();
break ;
case 8 :
$this -> stage_8 ();
break ;
default :
$this -> raise_error ( " Install stage information from client makes no sense to me. " );
}
2020-12-21 17:46:32 -08:00
if ( $_SERVER [ 'QUERY_STRING' ] === " debug " )
2019-03-29 19:13:32 -05:00
{
$this -> template -> SetTag ( " debug_info " , print_a ( $this -> previous_steps , TRUE ));
}
else
{
2019-06-03 15:27:36 -07:00
$this -> template -> SetTag ( " debug_info " , ( ! empty ( $this -> debug_info ) ? print_a ( $this -> debug_info , TRUE ) . " Backtrace:<br /> " . print_a ( $this , TRUE ) : " " ));
2019-03-29 19:13:32 -05:00
}
echo $this -> template -> ParseTemplate ( template_data (), TEMPLATE_TYPE_DATA );
}
function raise_error ( $details )
{
$this -> debug_info [] = array (
'info' => array (
'details' => $details ,
'backtrace' => debug_backtrace ()
)
);
}
function display_required ()
{
if ( empty ( $this -> required ))
{
return ;
}
$this -> required = array_filter ( $this -> required );
if ( ! empty ( $this -> required ))
{
$this -> template -> SetTag ( " required " , " <div class='message'> " . implode ( " <br /> " , $this -> required ) . " </div> " );
$this -> required = array ();
}
}
2019-06-03 15:27:36 -07:00
/**
* Stage 1
* @ return null
*/
2019-03-29 19:13:32 -05:00
private function stage_1 ()
{
global $e_forms ;
$this -> stage = 1 ;
2019-06-03 15:27:36 -07:00
installLog :: clear ();
installLog :: add ( 'Stage 1 started' );
2019-03-29 19:13:32 -05:00
$this -> template -> SetTag ( " installation_heading " , LANINS_001 );
$this -> template -> SetTag ( " stage_pre " , LANINS_002 );
$this -> template -> SetTag ( " stage_num " , LANINS_003 );
$this -> template -> SetTag ( " stage_title " , LANINS_004 );
$this -> template -> SetTag ( " percent " , 10 );
$this -> template -> SetTag ( " bartype " , 'warning' );
2020-12-21 17:46:32 -08:00
$e_forms -> start_form ( " language_select " , $_SERVER [ 'PHP_SELF' ] . ( $_SERVER [ 'QUERY_STRING' ] === " debug " ? " ?debug " : " " ));
2019-03-29 19:13:32 -05:00
$e_forms -> add_select_item ( " language " , $this -> get_languages (), " English " );
$this -> finish_form ();
$this -> add_button ( " start " , LAN_CONTINUE );
$output = "
< div style = 'text-align: center;' >
< div class = 'alert alert-info alert-block text-center' >
< label for = 'language' > " .LANINS_005. " </ label >
</ div > \n
< br /> \n
< div class = 'col-md-offset-4 col-md-6' >
" . $e_forms->return_form (). "
</ div >< br />
</ div > " ;
$this -> template -> SetTag ( " stage_content " , $output );
2019-06-03 15:27:36 -07:00
installLog :: add ( 'Stage 1 completed' );
return null ;
2019-03-29 19:13:32 -05:00
}
private function stage_2 ()
{
global $e_forms ;
$this -> stage = 2 ;
2019-06-03 15:27:36 -07:00
installLog :: add ( 'Stage 2 started' );
2019-03-29 19:13:32 -05:00
if ( ! empty ( $_POST [ 'language' ]))
{
$this -> previous_steps [ 'language' ] = $_POST [ 'language' ];
}
$this -> template -> SetTag ( " installation_heading " , LANINS_001 );
$this -> template -> SetTag ( " stage_pre " , LANINS_002 );
$this -> template -> SetTag ( " stage_num " , LANINS_021 );
$this -> template -> SetTag ( " stage_title " , LANINS_022 );
$this -> template -> SetTag ( " percent " , 25 );
$this -> template -> SetTag ( " bartype " , 'warning' );
if ( ! isset ( $this -> previous_steps [ 'mysql' ][ 'createdb' ]))
{
$this -> previous_steps [ 'mysql' ][ 'createdb' ] = 1 ; // default to yes.
}
// $this->template->SetTag("onload", "document.getElementById('name').focus()");
// $page_info = nl2br(LANINS_023);
$page_info = " <div class='alert alert-block alert-info'> " . LANINS_141 . " </div> " ;
2020-12-21 17:46:32 -08:00
$e_forms -> start_form ( " versions " , $_SERVER [ 'PHP_SELF' ] . ( $_SERVER [ 'QUERY_STRING' ] === " debug " ? " ?debug " : " " ));
$isrequired = (( $_SERVER [ 'SERVER_ADDR' ] === " 127.0.0.1 " ) || ( $_SERVER [ 'SERVER_ADDR' ] === " localhost " ) || ( $_SERVER [ 'SERVER_ADDR' ] === " ::1 " ) || preg_match ( '/^192\.168\.\d{1,3}\.\d{1,3}$/' , $_SERVER [ 'SERVER_ADDR' ])) ? " " : " required='required' " ; // Deals with IP V6, and 192.168.x.x address ranges, could be improved to validate x.x to a valid IP but for this use, I dont think its required to be that picky.
2019-03-29 19:13:32 -05:00
$output = "
< div style = 'width: 100%; padding-left: auto; padding-right: auto;' >
< table class = 'table table-striped table-bordered' >
< tr >
2022-04-07 07:15:30 -07:00
< td style = 'border-top: 1px solid #999;' >< label for = 'server' > " .LANINS_024. " </ label > " .HELPICON. "
< span class = 'field-help' > " .LANINS_030. " </ span ></ td >
2019-03-29 19:13:32 -05:00
< td style = 'border-top: 1px solid #999;' >
< input class = 'form-control input-large' type = 'text' id = 'server' name = 'server' autofocus size = '40' value = '".varset($this->previous_steps[' mysql '][' server '],' localhost ')."' maxlength = '100' required = 'required' />
2022-04-07 07:15:30 -07:00
2019-03-29 19:13:32 -05:00
</ td >
</ tr >
< tr >
2022-04-07 07:15:30 -07:00
< td >< label for = 'name' > " .LANINS_025. " </ label > " .HELPICON. " < span class = 'field-help' > " .LANINS_031. " </ span ></ td >
2019-03-29 19:13:32 -05:00
< td >
< input class = 'form-control input-large' type = 'text' name = 'name' id = 'name' value = '".varset($this->previous_steps[' mysql '][' user '])."' size = '40' maxlength = '100' required = 'required' />
</ td >
</ tr >
< tr >
2022-04-07 07:15:30 -07:00
< td >< label for = 'password' > " .LANINS_026. " </ label > " .HELPICON. " < span class = 'field-help' > " .LANINS_032. " </ span ></ td >
2019-03-29 19:13:32 -05:00
< td >
< input class = 'form-control input-large' type = 'password' name = 'password' size = '40' id = 'password' value = '".varset($this->previous_steps[' mysql '][' password '])."' maxlength = '100' { $isrequired } pattern = '[^\x22]+' />
2022-04-07 07:15:30 -07:00
2019-03-29 19:13:32 -05:00
</ td >
</ tr >
< tr >
2022-04-07 07:15:30 -07:00
< td >< label for = 'db' > " .LANINS_027. " </ label > " .HELPICON. " < span class = 'field-help' > " .LANINS_033. " </ span ></ td >
2019-03-29 19:13:32 -05:00
< td class = 'form-inline' >
2021-01-27 17:33:57 -08:00
< input class = 'form-control input-large' type = 'text' name = 'db' size = '20' id = 'db' value = '".varset($this->previous_steps[' mysql '][' db '])."' maxlength = '100' required = 'required' pattern = '^[a-zA-Z0-9][a-zA-Z0-9_-]*' />
2019-03-29 19:13:32 -05:00
< label class = 'checkbox-inline' >< input type = 'checkbox' name = 'createdb' value = '1' " .( $this->previous_steps ['mysql']['createdb'] ==1 ? " checked = 'checked' " : " " ). " />< small > " .LANINS_028. " </ small ></ label >
2022-04-07 07:15:30 -07:00
2019-03-29 19:13:32 -05:00
</ td >
</ tr >
< tr >
2022-04-07 07:15:30 -07:00
< td >< label for = 'prefix' > " .LANINS_029. " </ label > " .HELPICON. " < span class = 'field-help' > " .LANINS_034. " </ span ></ td >
2019-03-29 19:13:32 -05:00
< td >
< input class = 'form-control input-large' type = 'text' name = 'prefix' size = '20' id = 'prefix' value = 'e107_' pattern = '[a-z0-9]*_$' maxlength = '100' required = 'required' />
</ td >
</ tr >
</ table >
< br />< br />
</ div >
\n " ;
$e_forms -> add_plain_html ( $output );
$this -> finish_form ();
$this -> add_button ( " submit " , LAN_CONTINUE );
$this -> template -> SetTag ( " stage_content " , $page_info . $e_forms -> return_form ());
2019-06-03 15:27:36 -07:00
installLog :: add ( 'Stage 2 completed' );
2019-03-29 19:13:32 -05:00
}
/**
* Replace hash paths and create folders if needed .
*
2019-06-03 15:27:36 -07:00
* @ return null
2019-03-29 19:13:32 -05:00
*/
private function updatePaths ()
{
$hash = $this -> e107 -> makeSiteHash ( $this -> previous_steps [ 'mysql' ][ 'db' ], $this -> previous_steps [ 'mysql' ][ 'prefix' ]);
$this -> e107 -> site_path = $hash ;
$this -> previous_steps [ 'paths' ][ 'hash' ] = $hash ;
2019-06-03 15:27:36 -07:00
installLog :: add ( " Directory Hash Set: " . $hash );
2019-03-29 19:13:32 -05:00
$omit = array ( 'FILES_DIRECTORY' , 'WEB_IMAGES_DIRECTORY' );
foreach ( $this -> e107 -> e107_dirs as $dir => $p )
{
if ( in_array ( $dir , $omit )) { continue ; }
$this -> e107 -> e107_dirs [ $dir ] = str_replace ( " [hash] " , $hash , $this -> e107 -> e107_dirs [ $dir ]);
if ( ! is_dir ( $this -> e107 -> e107_dirs [ $dir ]))
{
@ mkdir ( $this -> e107 -> e107_dirs [ $dir ]);
}
}
2019-06-03 15:27:36 -07:00
return null ;
2019-03-29 19:13:32 -05:00
}
private function stage_3 ()
{
global $e_forms ;
2019-06-03 15:27:36 -07:00
2019-03-29 19:13:32 -05:00
$this -> stage = 3 ;
2019-06-03 15:27:36 -07:00
$alertType = 'warning' ;
installLog :: add ( 'Stage 3 started' );
2019-03-29 19:13:32 -05:00
$this -> template -> SetTag ( " installation_heading " , LANINS_001 );
$this -> template -> SetTag ( " stage_pre " , LANINS_002 );
$this -> template -> SetTag ( " stage_num " , LANINS_036 );
$this -> template -> SetTag ( " onload " , " document.getElementById('name').focus() " );
$this -> template -> SetTag ( " percent " , 40 );
$this -> template -> SetTag ( " bartype " , 'warning' );
$tp = e107 :: getParser ();
if ( ! empty ( $_POST [ 'server' ]))
{
$this -> previous_steps [ 'mysql' ][ 'server' ] = trim ( $tp -> filter ( $_POST [ 'server' ]));
$this -> previous_steps [ 'mysql' ][ 'user' ] = trim ( $tp -> filter ( $_POST [ 'name' ]));
$this -> previous_steps [ 'mysql' ][ 'password' ] = trim ( $tp -> filter ( $_POST [ 'password' ]));
$this -> previous_steps [ 'mysql' ][ 'db' ] = trim ( $tp -> filter ( $_POST [ 'db' ]));
2020-12-08 07:29:17 -08:00
$this -> previous_steps [ 'mysql' ][ 'createdb' ] = isset ( $_POST [ 'createdb' ]) && $_POST [ 'createdb' ] == true ;
2019-03-29 19:13:32 -05:00
$this -> previous_steps [ 'mysql' ][ 'prefix' ] = trim ( $tp -> filter ( $_POST [ 'prefix' ]));
2019-06-03 15:27:36 -07:00
$this -> setDb ();
2019-03-29 19:13:32 -05:00
}
if ( ! empty ( $_POST [ 'overwritedb' ]))
{
$this -> previous_steps [ 'mysql' ][ 'overwritedb' ] = 1 ;
}
2020-12-08 07:29:17 -08:00
$success = $this -> check_name ( $this -> previous_steps [ 'mysql' ][ 'db' ]) && $this -> check_name ( $this -> previous_steps [ 'mysql' ][ 'prefix' ], TRUE );
2019-03-29 19:13:32 -05:00
if ( $success )
{
$success = $this -> checkDbFields ( $this -> previous_steps [ 'mysql' ]); // Check for invalid characters
}
if ( ! $success || $this -> previous_steps [ 'mysql' ][ 'server' ] == " " || $this -> previous_steps [ 'mysql' ][ 'user' ] == " " )
{
$this -> stage = 3 ;
$this -> template -> SetTag ( " stage_num " , LANINS_021 );
2020-12-21 17:46:32 -08:00
$e_forms -> start_form ( " versions " , $_SERVER [ 'PHP_SELF' ] . ( $_SERVER [ 'QUERY_STRING' ] === " debug " ? " ?debug " : " " ));
2019-03-29 19:13:32 -05:00
$head = LANINS_039 . " <br /><br /> \n " ;
$output = "
< div style = 'width: 100%; padding-left: auto; padding-right: auto;' >
2019-06-03 15:27:36 -07:00
< table class = 'table table-bordered table-striped' >
2019-03-29 19:13:32 -05:00
< tr >
< td style = 'border-top: 1px solid #999;' >< label for = 'server' > " .LANINS_024. " </ label ></ td >
< td style = 'border-top: 1px solid #999;' >< input class = 'form-control' type = 'text' id = 'server' name = 'server' size = '40' value = '{$this->previous_steps[' mysql '][' server ']}' maxlength = '100' required /></ td >
< td style = 'width: 40%; border-top: 1px solid #999;' > " .LANINS_030. " </ td >
</ tr >
< tr >
< td >< label for = 'name' > " .LANINS_025. " </ label ></ td >
< td >< input class = 'form-control' type = 'text' name = 'name' id = 'name' size = '40' value = '{$this->previous_steps[' mysql '][' user ']}' maxlength = '100' onload = 'this.focus()' /></ td >
< td > " .LANINS_031. " </ td >
</ tr >
< tr >
< td >< label for = 'password' > " .LANINS_026. " </ label ></ td >
< td >< input class = 'form-control' type = 'password' name = 'password' id = 'password' size = '40' value = '{$this->previous_steps[' mysql '][' password ']}' maxlength = '100' /></ td >
< td > " .LANINS_032. " </ td >
</ tr >
< tr >
< td >< label for = 'db' > " .LANINS_027. " </ label ></ td >
< td >< input type = 'text' name = 'db' id = 'db' size = '20' value = '{$this->previous_steps[' mysql '][' db ']}' maxlength = '100' />
2019-06-03 15:27:36 -07:00
< br />< label class = 'defaulttext' >< input type = 'checkbox' name = 'createdb' " .( $this->previous_steps ['mysql']['createdb'] == 1 ? " checked = 'checked' " : " " ) . " value = '1' /> " .LANINS_028. " </ label ></ td >
2019-03-29 19:13:32 -05:00
< td > " .LANINS_033. " </ td >
</ tr >
< tr >
< td >< label for = 'prefix' > " .LANINS_029. " </ label ></ td >
< td >< input type = 'text' name = 'prefix' id = 'prefix' size = '20' value = '{$this->previous_steps[' mysql '][' prefix ']}' maxlength = '100' /></ td >
< td > " .LANINS_034. " </ td >
</ tr > " ;
if ( ! $success )
{
$output .= " <tr><td colspan='3'> " . LANINS_105 . " </td></tr> " ;
}
$output .= "
</ table >
< br />< br />
</ div >
\n " ;
$e_forms -> add_plain_html ( $output );
$this -> add_button ( " submit " , LAN_CONTINUE );
$this -> template -> SetTag ( " stage_title " , LANINS_040 );
}
else
{
$this -> template -> SetTag ( " stage_title " , LANINS_037 . ( $this -> previous_steps [ 'mysql' ][ 'createdb' ] == 1 ? LANINS_038 : " " ));
$sql = e107 :: getDb ();
if ( ! $res = $sql -> connect ( $this -> previous_steps [ 'mysql' ][ 'server' ], $this -> previous_steps [ 'mysql' ][ 'user' ], $this -> previous_steps [ 'mysql' ][ 'password' ]))
// if (!$res = @mysql_connect($this->previous_steps['mysql']['server'], $this->previous_steps['mysql']['user'], $this->previous_steps['mysql']['password']))
{
$success = FALSE ;
2020-12-21 17:46:32 -08:00
$e_forms -> start_form ( " versions " , $_SERVER [ 'PHP_SELF' ] . ( $_SERVER [ 'QUERY_STRING' ] === " debug " ? " ?debug " : " " ));
2019-03-29 19:13:32 -05:00
$page_content = LANINS_041 . nl2br ( " \n \n <b> " . LANINS_083 . " \n </b><i> " . $sql -> getLastErrorText () . " </i> " );
$alertType = 'error' ;
}
elseif (( $this -> previous_steps [ 'mysql' ][ 'createdb' ] == 1 ) && empty ( $this -> previous_steps [ 'mysql' ][ 'overwritedb' ]) && $sql -> database ( $this -> previous_steps [ 'mysql' ][ 'db' ], $this -> previous_steps [ 'mysql' ][ 'prefix' ]))
{
2020-12-21 17:46:32 -08:00
$e_forms -> start_form ( " versions " , $_SERVER [ 'PHP_SELF' ] . ( $_SERVER [ 'QUERY_STRING' ] === " debug " ? " ?debug " : " " ));
2019-03-29 19:13:32 -05:00
$head = str_replace ( '[x]' , '<b>' . $this -> previous_steps [ 'mysql' ][ 'db' ] . '</b>' , " <div class='alert alert-warning'> " . LANINS_127 . " </div> " );
$alertType = 'error' ;
$this -> add_button ( 'overwritedb' , LANINS_128 );
/* $e_forms -> add_plain_html ( "
< input type = 'submit' id = 'overwritedb' name = 'overwritedb' value = \ " " . LANINS_128 . " » \" class='btn btn-large btn-primary' /> "
); */
$this -> finish_form ( 3 );
$this -> template -> SetTag ( " stage_content " , " <div class='alert alert-block alert- { $alertType } '> " . $head . " </div> " . $e_forms -> return_form ());
2019-06-03 15:27:36 -07:00
installLog :: add ( 'Stage 3 completed' );
2019-03-29 19:13:32 -05:00
return ;
}
else
{
2020-12-21 17:46:32 -08:00
$e_forms -> start_form ( " versions " , $_SERVER [ 'PHP_SELF' ] . ( $_SERVER [ 'QUERY_STRING' ] === " debug " ? " ?debug " : " " ));
2019-03-29 19:13:32 -05:00
$page_content = " <span class='glyphicon glyphicon-ok'></span> " . LANINS_042 ;
// @TODO Check database version here?
/*
$mysql_note = mysql_get_server_info ();
if ( version_compare ( $mysql_note , MIN_MYSQL_VERSION , '>=' ))
{
$success = FALSE ;
}
*/
// Do brute force for now - Should be enough
if ( ! empty ( $this -> previous_steps [ 'mysql' ][ 'overwritedb' ]))
{
if ( $this -> dbqry ( 'DROP DATABASE `' . $this -> previous_steps [ 'mysql' ][ 'db' ] . '` ' ))
{
$page_content .= " <br /><span class='glyphicon glyphicon-ok'></span> " . LANINS_136 ;
}
else
{
$success = false ;
$page_content .= " <br /><br /> " . LANINS_043 . nl2br ( " \n \n <b> " . LANINS_083 . " \n </b><i> " . e107 :: getDb () -> getLastErrorText () . " </i> " );
}
}
if ( $this -> previous_steps [ 'mysql' ][ 'createdb' ] == 1 )
{
$notification = " <br /><span class='glyphicon glyphicon-ok'></span> " . LANINS_044 ;
Convert and run e107 using the MySQL/MariaDB utf8mb4 character set and
InnoDB storage engine
Components affected:
* `db_verify` now checks and corrects the table storage engine
* `db_verify` now checks and corrects the table default character set
* Note: Field character sets can still be overridden
* Note: When correcting, the entire table is converted to the target
charset.
* The alt_auth plugin now connects via PDO using the e107 default
charset, utf8mb4
* `e_db_pdo` now sets the charset to utf8mb4. This is currently not
customizable because it was previously not customizable.
* `install.php` now generates an `e107_config.php` file with
`$mySQLcharset = 'utf8mb4';`, though this option is not actually used.
* `install.php` now removes plugin tables before installing plugins.
* `e_db_mysql` now only accepts the `utf8mb4` charset. Previously, it
only accepted the `utf8` charset.
* `e_db_mysql` now configures `mysqli_real_escape_string` to match the
new default charset, `utf8mb4`.
* Plugin installations now use the preferred MySQL table storage engines
and charsets.
The preferred MySQL table storage engines are now mapped like so:
* If `ENGINE=MyISAM` is specified, the actual storage engine set will be
the first available of: InnoDB, Aria, Maria, MyISAM
* If `ENGINE=Aria` is specified, the actual storage engine set will be
the first available of: Aria, Maria, MyISAM
* If `ENGINE=InnoDB` is specified, the actual storage engine set will be
the first available of: InnoDB, XtraDB
* If `ENGINE=XtraDB` is specified, the actual storage engine set will be
the first available of: XtraDB, InnoDB
The preferred MySQL character set is now aliased like so:
* `utf8` => `utf8mb4`
* `utf8mb3` => `utf8mb3`
* `utf8mb4` => `utf8mb4`
Fixes: #4501
2021-05-22 00:46:35 -05:00
$query = 'CREATE DATABASE `' . $this -> previous_steps [ 'mysql' ][ 'db' ] . '` CHARACTER SET `utf8mb4` ' ;
2019-03-29 19:13:32 -05:00
}
else
{
$notification = " <br /><span class='glyphicon glyphicon-ok'></span> " . LANINS_137 ;
Convert and run e107 using the MySQL/MariaDB utf8mb4 character set and
InnoDB storage engine
Components affected:
* `db_verify` now checks and corrects the table storage engine
* `db_verify` now checks and corrects the table default character set
* Note: Field character sets can still be overridden
* Note: When correcting, the entire table is converted to the target
charset.
* The alt_auth plugin now connects via PDO using the e107 default
charset, utf8mb4
* `e_db_pdo` now sets the charset to utf8mb4. This is currently not
customizable because it was previously not customizable.
* `install.php` now generates an `e107_config.php` file with
`$mySQLcharset = 'utf8mb4';`, though this option is not actually used.
* `install.php` now removes plugin tables before installing plugins.
* `e_db_mysql` now only accepts the `utf8mb4` charset. Previously, it
only accepted the `utf8` charset.
* `e_db_mysql` now configures `mysqli_real_escape_string` to match the
new default charset, `utf8mb4`.
* Plugin installations now use the preferred MySQL table storage engines
and charsets.
The preferred MySQL table storage engines are now mapped like so:
* If `ENGINE=MyISAM` is specified, the actual storage engine set will be
the first available of: InnoDB, Aria, Maria, MyISAM
* If `ENGINE=Aria` is specified, the actual storage engine set will be
the first available of: Aria, Maria, MyISAM
* If `ENGINE=InnoDB` is specified, the actual storage engine set will be
the first available of: InnoDB, XtraDB
* If `ENGINE=XtraDB` is specified, the actual storage engine set will be
the first available of: XtraDB, InnoDB
The preferred MySQL character set is now aliased like so:
* `utf8` => `utf8mb4`
* `utf8mb3` => `utf8mb3`
* `utf8mb4` => `utf8mb4`
Fixes: #4501
2021-05-22 00:46:35 -05:00
$query = 'ALTER DATABASE `' . $this -> previous_steps [ 'mysql' ][ 'db' ] . '` CHARACTER SET `utf8mb4` ' ;
2019-03-29 19:13:32 -05:00
}
if ( ! $this -> dbqry ( $query ))
{
$success = false ;
$alertType = 'error' ;
$page_content .= " <br /><br /> " ;
$page_content .= ( empty ( $this -> previous_steps [ 'mysql' ][ 'createdb' ])) ? LANINS_129 : LANINS_043 ;
$page_content .= nl2br ( " \n \n <b> " . LANINS_083 . " \n </b><i> " . e107 :: getDb () -> getLastErrorText () . " </i> " );
}
else
{
Convert and run e107 using the MySQL/MariaDB utf8mb4 character set and
InnoDB storage engine
Components affected:
* `db_verify` now checks and corrects the table storage engine
* `db_verify` now checks and corrects the table default character set
* Note: Field character sets can still be overridden
* Note: When correcting, the entire table is converted to the target
charset.
* The alt_auth plugin now connects via PDO using the e107 default
charset, utf8mb4
* `e_db_pdo` now sets the charset to utf8mb4. This is currently not
customizable because it was previously not customizable.
* `install.php` now generates an `e107_config.php` file with
`$mySQLcharset = 'utf8mb4';`, though this option is not actually used.
* `install.php` now removes plugin tables before installing plugins.
* `e_db_mysql` now only accepts the `utf8mb4` charset. Previously, it
only accepted the `utf8` charset.
* `e_db_mysql` now configures `mysqli_real_escape_string` to match the
new default charset, `utf8mb4`.
* Plugin installations now use the preferred MySQL table storage engines
and charsets.
The preferred MySQL table storage engines are now mapped like so:
* If `ENGINE=MyISAM` is specified, the actual storage engine set will be
the first available of: InnoDB, Aria, Maria, MyISAM
* If `ENGINE=Aria` is specified, the actual storage engine set will be
the first available of: Aria, Maria, MyISAM
* If `ENGINE=InnoDB` is specified, the actual storage engine set will be
the first available of: InnoDB, XtraDB
* If `ENGINE=XtraDB` is specified, the actual storage engine set will be
the first available of: XtraDB, InnoDB
The preferred MySQL character set is now aliased like so:
* `utf8` => `utf8mb4`
* `utf8mb3` => `utf8mb3`
* `utf8mb4` => `utf8mb4`
Fixes: #4501
2021-05-22 00:46:35 -05:00
$this -> dbqry ( 'SET NAMES `utf8mb4`' );
2019-03-29 19:13:32 -05:00
$page_content .= $notification ; // "
}
}
if ( $success )
{
// $page_content .= "<br /><br />".LANINS_045."<br /><br />";
$this -> add_button ( " submit " , LAN_CONTINUE );
$alertType = 'success' ;
}
else
{
$this -> add_button ( " back " , LAN_CONTINUE );
}
$head = $page_content ;
}
if ( $success )
2019-06-03 15:27:36 -07:00
{
2019-03-29 19:13:32 -05:00
$this -> finish_form ();
2019-06-03 15:27:36 -07:00
}
2019-03-29 19:13:32 -05:00
else
{
$this -> finish_form ( 3 );
}
2019-06-03 15:27:36 -07:00
2019-03-29 19:13:32 -05:00
$this -> template -> SetTag ( " stage_content " , " <div class='alert alert-block alert- { $alertType } '> " . $head . " </div> " . $e_forms -> return_form ());
2019-06-03 15:27:36 -07:00
installLog :: add ( 'Stage 3 completed' );
return null ;
2019-03-29 19:13:32 -05:00
}
private function stage_4 ()
{
global $e_forms ;
$this -> stage = 4 ;
2019-06-03 15:27:36 -07:00
installLog :: add ( 'Stage 4 started' );
2019-03-29 19:13:32 -05:00
$this -> template -> SetTag ( " installation_heading " , LANINS_001 );
$this -> template -> SetTag ( " stage_pre " , LANINS_002 );
$this -> template -> SetTag ( " stage_num " , LANINS_007 );
$this -> template -> SetTag ( " stage_title " , LANINS_008 );
$this -> template -> SetTag ( " percent " , 50 );
$this -> template -> SetTag ( " bartype " , 'warning' );
2020-12-08 07:29:17 -08:00
$not_writable = $this -> check_writable_perms (); // Some directories MUST be writable
2019-03-29 19:13:32 -05:00
$opt_writable = $this -> check_writable_perms ( 'can_write' ); // Some directories CAN optionally be writable
$version_fail = false ;
$perms_errors = " " ;
$mysql_pass = false ;
2019-06-03 15:27:36 -07:00
$this -> setDb ();
2019-03-29 19:13:32 -05:00
if ( count ( $not_writable ))
{
$perms_pass = false ;
foreach ( $not_writable as $file )
{
2020-12-21 17:46:32 -08:00
$perms_errors .= ( substr ( $file , - 1 ) === " / " ? LANINS_010a : LANINS_010 ) . " <br /><b> { $file } </b><br /> \n " ;
2019-03-29 19:13:32 -05:00
}
$perms_notes = LANINS_018 ;
}
elseif ( count ( $opt_writable ))
{
$perms_pass = true ;
foreach ( $opt_writable as $file )
{
2020-12-21 17:46:32 -08:00
$perms_errors .= ( substr ( $file , - 1 ) === " / " ? LANINS_010a : LANINS_010 ) . " <br /><b> { $file } </b><br /> \n " ;
2019-03-29 19:13:32 -05:00
}
$perms_notes = LANINS_106 ;
}
elseif ( filesize ( 'e107_config.php' ) > 1 )
{ // Must start from an empty e107_config.php
$perms_pass = FALSE ;
$perms_errors = LANINS_121 ;
$perms_notes = " <span class='glyphicon glyphicon-remove'></span> " . LANINS_122 ;
}
else
{
$perms_pass = true ;
$perms_errors = " " ;
$perms_notes = " <span class='glyphicon glyphicon-ok'></span> " . LANINS_017 ;
}
if ( ! function_exists ( " mysql_connect " ) && ! defined ( 'PDO::ATTR_DRIVER_NAME' ))
{
$version_fail = true ;
$mysql_note = LAN_ERROR ;
$mysql_help = LANINS_012 ;
}
elseif ( ! e107 :: getDb () -> connect ( $this -> previous_steps [ 'mysql' ][ 'server' ], $this -> previous_steps [ 'mysql' ][ 'user' ], $this -> previous_steps [ 'mysql' ][ 'password' ]))
// elseif (!@mysql_connect($this->previous_steps['mysql']['server'], $this->previous_steps['mysql']['user'], $this->previous_steps['mysql']['password']))
{
$mysql_note = LAN_ERROR ;
$mysql_help = LANINS_013 ;
}
else
{
// $mysql_note = mysql_get_server_info();
$mysql_note = e107 :: getDb () -> getServerInfo ();
if ( $this -> pdo == true )
{
$mysql_note .= " (PDO) " ;
}
if ( version_compare ( $mysql_note , MIN_MYSQL_VERSION , '>=' ))
{
$mysql_help = " <span class='glyphicon glyphicon-ok'></span> " . LANINS_017 ;
$mysql_pass = true ;
}
else
{
$mysql_help = " <span class='glyphicon glyphicon-remove'></span> " . LANINS_105 ;
}
}
2020-12-21 17:46:32 -08:00
$php_version = PHP_VERSION ;
2019-03-29 19:13:32 -05:00
if ( version_compare ( $php_version , MIN_PHP_VERSION , " >= " ))
{
$php_help = " <span class='glyphicon glyphicon-ok'></span> " . LANINS_017 ;
}
else
{
$php_help = " <span class='glyphicon glyphicon-remove'></span> " . LANINS_019 ;
}
2020-12-21 17:46:32 -08:00
$e_forms -> start_form ( " versions " , $_SERVER [ 'PHP_SELF' ] . ( $_SERVER [ 'QUERY_STRING' ] === " debug " ? " ?debug " : " " ));
2019-03-29 19:13:32 -05:00
$permColor = ( $perms_pass == true ) ? " text-success " : " text-danger " ;
$PHPColor = ( $version_fail == false ) ? " text-success " : " text-danger " ;
$mysqlColor = ( $mysql_pass == true ) ? " text-success " : " text-danger " ;
2019-06-03 15:27:36 -07:00
2019-03-29 19:13:32 -05:00
$extensionCheck = array (
2021-02-12 14:32:20 -08:00
'pdo' => array ( 'label' => " PDO (MySQL) " , 'status' => extension_loaded ( 'pdo_mysql' ), 'url' => 'https:/php.net/manual/en/book.pdo.php' ),
'xml' => array ( 'label' => LANINS_050 , 'status' => function_exists ( 'utf8_encode' ) && class_exists ( 'DOMDocument' , false ), 'url' => 'http://php.net/manual/en/ref.xml.php' ),
'exif' => array ( 'label' => LANINS_048 , 'status' => function_exists ( 'exif_imagetype' ), 'url' => 'http://php.net/manual/en/book.exif.php' ),
'fileinfo' => array ( 'label' => " FileInfo. Extension " , 'status' => extension_loaded ( 'fileinfo' ), 'url' => 'https://www.php.net/manual/en/book.fileinfo' ),
'curl' => array ( 'label' => 'Curl Library' , 'status' => function_exists ( 'curl_version' ), 'url' => 'http://php.net/manual/en/book.curl.php' ),
'gd' => array ( 'label' => 'GD Library' , 'status' => function_exists ( 'gd_info' ), 'url' => 'http://php.net/manual/en/book.image.php' ),
'mb' => array ( 'label' => 'MB String Library' , 'status' => function_exists ( 'mb_strimwidth' ), 'url' => 'http://php.net/manual/en/book.mbstring.php' ),
2019-03-29 19:13:32 -05:00
);
$output = "
< table class = 'table table-striped table-bordered' style = 'width: 100%; margin-left: auto; margin-right: auto;' >
< tr >
< td style = 'width: 20%;' > " .LANINS_014. " </ td >
< td style = 'width: 40%;' > { $perms_errors } </ td >
< td class = '{$permColor}' style = 'width: 40%;' > { $perms_notes } </ td >
</ tr >
< tr >
< td > " .LANINS_015. " </ td >
< td > { $php_version } </ td >
< td class = '{$PHPColor}' > { $php_help } </ td >
</ tr >
< tr >
< td > MySQL </ td >
< td > { $mysql_note } </ td >
< td class = '{$mysqlColor}' > { $mysql_help } </ td >
</ tr > " ;
foreach ( $extensionCheck as $ext )
{
$statusText = ( $ext [ 'status' ] === true ) ? LANINS_051 : LANINS_052 ;
$statusColor = ( $ext [ 'status' ] === true ) ? " text-success " : " text-error " ;
$statusIcon = ( $ext [ 'status' ] === true ) ? " <i class='glyphicon glyphicon-ok'></i> " . LANINS_017 : str_replace ( array ( " [x] " , '[y]' ), array ( $ext [ 'label' ], " <a href=' " . $ext [ 'url' ] . " '>php.net</a> " ), LANINS_145 );
$output .= "
< tr >
< td > " . $ext['label'] . " </ td >
< td > " . $statusText . " </ td >
< td class = '".$statusColor."' > " . $statusIcon . " </ td >
</ tr > " ;
}
$output .= "
</ table > \n " ;
if ( ! $perms_pass || (( $extensionCheck [ 'xml' ][ 'status' ] !== true )))
{
$this -> add_button ( " retest_perms " , LANINS_009 );
$this -> stage = 3 ; // make the installer jump back a step
}
2021-01-25 09:14:45 -08:00
elseif ( ! $version_fail && ( $extensionCheck [ 'xml' ][ 'status' ] == true ))
2019-03-29 19:13:32 -05:00
{
$this -> add_button ( " continue_install " , LAN_CONTINUE );
}
$this -> finish_form ();
$this -> template -> SetTag ( " stage_content " , $output . $e_forms -> return_form ());
2019-06-03 15:27:36 -07:00
installLog :: add ( 'Stage 4 completed' );
2019-03-29 19:13:32 -05:00
}
/**
* Install stage 5 - collect Admin Login Data .
*
* @ return string HTML form of stage 5.
*/
private function stage_5 ()
{
global $e_forms ;
2019-06-03 15:27:36 -07:00
$this -> setDb ();
$this -> updatePaths (); // update dynamic paths and create media and system directories - requires mysql info.
2019-03-29 19:13:32 -05:00
$this -> stage = 5 ;
2019-06-03 15:27:36 -07:00
installLog :: add ( 'Stage 5 started' );
2019-03-29 19:13:32 -05:00
$this -> display_required ();
$this -> template -> SetTag ( " installation_heading " , LANINS_001 );
$this -> template -> SetTag ( " stage_pre " , LANINS_002 );
$this -> template -> SetTag ( " stage_num " , LANINS_046 );
$this -> template -> SetTag ( " stage_title " , defset ( 'LANINS_147' , 'Administration' ));
// $this->template->SetTag("onload", "document.getElementById('u_name').focus()");
$this -> template -> SetTag ( " percent " , 60 );
$this -> template -> SetTag ( " bartype " , 'warning' );
2020-12-21 17:46:32 -08:00
$e_forms -> start_form ( " admin_info " , $_SERVER [ 'PHP_SELF' ] . ( $_SERVER [ 'QUERY_STRING' ] === " debug " ? " ?debug " : " " ));
2019-03-29 19:13:32 -05:00
$output = "
< div style = 'width: 100%; padding-left: auto; padding-right: auto;' >
< table class = 'table table-striped table-bordered' >
< colgroup >
< col style = 'width:35%' />
< col />
</ colgroup >
< tr >
2022-04-07 07:15:30 -07:00
< td >< label for = 'u_name' > " .LANINS_072. " </ label > " .HELPICON. " < span class = 'field-help' > " .LANINS_073. " </ span ></ td >
2019-03-29 19:13:32 -05:00
< td >
< input class = 'form-control' type = 'text' autofocus name = 'u_name' id = 'u_name' placeholder = 'admin' size = '30' required = 'required' value = '".(isset($this->previous_steps[' admin '][' user ']) ? $this->previous_steps[' admin '][' user '] : "")."' maxlength = '60' />
2022-04-07 07:15:30 -07:00
2019-03-29 19:13:32 -05:00
</ td >
</ tr >
< tr >
2022-04-07 07:15:30 -07:00
< td >< label for = 'd_name' > " .LANINS_074. " </ label > " .HELPICON. " < span class = 'field-help' > " .LANINS_123. " </ span ></ td >
2019-03-29 19:13:32 -05:00
< td >
< input class = 'form-control' type = 'text' name = 'd_name' id = 'd_name' size = '30' placeholder = 'Administrator' value = '".(isset($this->previous_steps[' admin '][' display ']) ? $this->previous_steps[' admin '][' display '] : "")."' maxlength = '60' />
2022-04-07 07:15:30 -07:00
2019-03-29 19:13:32 -05:00
</ td >
</ tr >
< tr >
2022-04-07 07:15:30 -07:00
< td >< label for = 'pass1' > " .LANINS_076. " </ label > " .HELPICON. " < span class = 'field-help' > " .LANINS_124. " </ span ></ td >
2019-03-29 19:13:32 -05:00
< td >
< input class = 'form-control' type = 'password' name = 'pass1' size = '30' id = 'pass1' value = '' maxlength = '60' required = 'required' />
2022-04-07 07:15:30 -07:00
2019-03-29 19:13:32 -05:00
</ td >
</ tr >
< tr >
2022-04-07 07:15:30 -07:00
< td >< label for = 'pass2' > " .LANINS_078. " </ label > " .HELPICON. " < span class = 'field-help' > " .LANINS_079. " </ span ></ td >
2019-03-29 19:13:32 -05:00
< td >
< input class = 'form-control' type = 'password' name = 'pass2' size = '30' id = 'pass2' value = '' maxlength = '60' required = 'required' />
2022-04-07 07:15:30 -07:00
2019-03-29 19:13:32 -05:00
</ td >
</ tr >
< tr >
2022-04-07 07:15:30 -07:00
< td >< label for = 'email' > " .LANINS_080. " </ label > " .HELPICON. " < span class = 'field-help' > " .LANINS_081. " </ span ></ td >
2019-03-29 19:13:32 -05:00
< td >
< input class = 'form-control' type = 'text' name = 'email' size = '30' id = 'email' required = 'required' placeholder = 'admin@mysite.com' value = '".(isset($this->previous_steps[' admin '][' email ']) ? $this->previous_steps[' admin '][' email '] : ' ')."' maxlength = '100' />
2022-04-07 07:15:30 -07:00
2019-03-29 19:13:32 -05:00
</ td >
</ tr >
</ table >
< table class = 'table table-striped table-bordered' >
< colgroup >
< col style = 'width:35%' />
< col />
</ colgroup >
< tr >
< td >< label for = 'admincss' > " .LANINS_146. " </ label ></ td >
< td > " ;
$d = $this -> get_theme_xml ( 'bootstrap3' );
$opts = array ();
foreach ( $d [ 'css' ] as $val )
{
$key = $val [ 'name' ];
2021-02-04 16:22:25 -08:00
if ( $key !== 'css/modern-light.css' && ( $key !== 'css/modern-dark.css' ))
2019-03-29 19:13:32 -05:00
{
continue ;
}
$opts [ $key ] = array (
'title' => $val [ 'info' ],
'preview' => e_THEME . " bootstrap3/ " . $val [ 'thumbnail' ],
'description' => '' ,
'category' => ''
);
}
2021-02-05 19:04:35 -08:00
$output .= $this -> thumbnailSelector ( 'admincss' , $opts , 'css/modern-dark.css' );
2019-03-29 19:13:32 -05:00
$output .= "
</ td >
</ tr >
</ table >
< br />< br />
</ div >
\n " ;
$e_forms -> add_plain_html ( $output );
$this -> finish_form ();
$this -> add_button ( " submit " , LAN_CONTINUE );
$this -> template -> SetTag ( " stage_content " , $e_forms -> return_form ());
2019-06-03 15:27:36 -07:00
installLog :: add ( 'Stage 5 completed' );
return null ;
2019-03-29 19:13:32 -05:00
}
/**
* Collect User ' s Website Preferences
*
* @ return string HTML form of stage 6.
*/
private function stage_6 ()
{
global $e_forms ;
$tp = e107 :: getParser ();
$this -> stage = 6 ;
2019-06-03 15:27:36 -07:00
installLog :: add ( 'Stage 6 started' );
2019-03-29 19:13:32 -05:00
// -------------------- Save Step 5 Data -------------------------
if ( ! vartrue ( $this -> previous_steps [ 'admin' ][ 'user' ]) || varset ( $_POST [ 'u_name' ]))
{
$_POST [ 'u_name' ] = str_replace ( array ( " ' " , '"' ), " " , $_POST [ 'u_name' ]);
$this -> previous_steps [ 'admin' ][ 'user' ] = $tp -> filter ( $_POST [ 'u_name' ]);
}
if ( ! vartrue ( $this -> previous_steps [ 'admin' ][ 'display' ]) || varset ( $_POST [ 'd_name' ]))
{
$_POST [ 'd_name' ] = str_replace ( array ( " ' " , '"' ), " " , $_POST [ 'd_name' ]);
if ( $_POST [ 'd_name' ] == " " )
{
$this -> previous_steps [ 'admin' ][ 'display' ] = $tp -> filter ( $_POST [ 'u_name' ]);
}
else
{
$this -> previous_steps [ 'admin' ][ 'display' ] = $tp -> filter ( $_POST [ 'd_name' ]);
}
}
if ( ! vartrue ( $this -> previous_steps [ 'admin' ][ 'email' ]) || varset ( $_POST [ 'email' ]))
{
$this -> previous_steps [ 'admin' ][ 'email' ] = $tp -> filter ( $_POST [ 'email' ], 'email' );
}
if ( varset ( $_POST [ 'pass1' ]) || ! vartrue ( $this -> previous_steps [ 'admin' ][ 'password' ]))
{
if ( $_POST [ 'pass1' ] != $_POST [ 'pass2' ])
{
$this -> required [ 'pass1' ] = LANINS_049 ; // passwords don't match.
}
elseif ( ! vartrue ( $_POST [ 'pass1' ]))
{
$this -> required [ 'pass1' ] = LANINS_077 ;
}
else
{
$this -> previous_steps [ 'admin' ][ 'password' ] = $_POST [ 'pass1' ];
}
}
if ( ! empty ( $_POST [ 'admincss' ]))
{
$this -> previous_steps [ 'prefs' ][ 'admincss' ] = $tp -> filter ( $_POST [ 'admincss' ]);
}
else // empty
{
$this -> previous_steps [ 'prefs' ][ 'admincss' ] = 'css/bootstrap-dark.min.css' ;
}
// ------------- Validate Step 5 Data. --------------------------
if ( ! vartrue ( $this -> previous_steps [ 'admin' ][ 'user' ]) || ! vartrue ( $this -> previous_steps [ 'admin' ][ 'password' ]))
{
$this -> required [ 'u_name' ] = LANINS_086 ; //
}
if ( ! empty ( $this -> required [ 'u_name' ]) || ! empty ( $this -> required [ 'pass1' ]))
{
return $this -> stage_5 ();
}
// required for various core routines
if ( ! defined ( 'USERNAME' ))
{
define ( 'USERNAME' , $this -> previous_steps [ 'admin' ][ 'user' ]);
define ( 'USEREMAIL' , $this -> previous_steps [ 'admin' ][ 'email' ]);
}
// ------------- Step 6 Form --------------------------------
$this -> display_required ();
$this -> template -> SetTag ( " installation_heading " , LANINS_001 );
$this -> template -> SetTag ( " stage_pre " , LANINS_002 );
$this -> template -> SetTag ( " stage_num " , LANINS_056 );
$this -> template -> SetTag ( " stage_title " , LANINS_117 ); // Website Preferences;
// $this->template->SetTag("onload", "document.getElementById('sitename').focus()");
$this -> template -> SetTag ( " percent " , 70 );
$this -> template -> SetTag ( " bartype " , 'warning' );
2020-12-21 17:46:32 -08:00
$e_forms -> start_form ( " pref_info " , $_SERVER [ 'PHP_SELF' ] . ( $_SERVER [ 'QUERY_STRING' ] === " debug " ? " ?debug " : " " ));
2019-03-29 19:13:32 -05:00
$output = "
< div style = 'width: 100%; padding-left: auto; padding-right: auto; margin-bottom:20px' >
< table class = 'table table-striped' >
< colgroup >
< col class = 'col-label' />
< col class = 'col-control' />
</ colgroup >
< tr >
< td >< label for = 'sitename' > " .LANINS_107. " </ label ></ td >
< td >
< input class = 'form-control' type = 'text' autofocus placeholder = \ " " . LANINS_108 . " \" required='required' name='sitename' id='sitename' size='30' value=' " . ( vartrue ( $_POST [ 'sitename' ]) ? $_POST [ 'sitename' ] : " " ) . " ' maxlength='60' />
</ td >
</ tr >
< tr >
< td >< label > " .LANINS_109. " </ label ></ td >
< td style = 'padding-right:0' >
" ;
$themes = $this -> get_themes ();
$opts = array ();
foreach ( $themes as $val )
{
/* if ( $val != 'bootstrap3' && $val != 'voux' )
{
continue ;
} */
$themeInfo = $this -> get_theme_xml ( $val );
2021-02-05 19:57:53 -08:00
2019-03-29 19:13:32 -05:00
$opts [ $val ] = array (
'title' => vartrue ( $themeInfo [ '@attributes' ][ 'name' ]),
'category' => vartrue ( $themeInfo [ 'category' ]),
'preview' => e_THEME . $val . " / " . $themeInfo [ 'thumbnail' ],
'description' => vartrue ( $themeInfo [ 'info' ])
);
2021-02-05 19:57:53 -08:00
2019-03-29 19:13:32 -05:00
/* $title = vartrue ( $themeInfo [ '@attributes' ][ 'name' ]);
$category = vartrue ( $themeInfo [ 'category' ]);
$preview = e_THEME . $val . " / " . $themeInfo [ 'thumbnail' ];
$description = vartrue ( $themeInfo [ 'info' ]);
if ( ! is_readable ( $preview ))
{
continue ;
}
$thumbnail = " <img class='img-responsive img-fluid thumbnail' src=' " . $preview . " ' alt=' " . $val . " ' /> " ;
$selected = ( $val === DEFAULT_INSTALL_THEME ) ? " checked " : " " ;
$output .= "
< div class = 'col-md-6 theme-cell' >
< label class = 'theme-selection' title = \ " " . $description . " \" ><input type='radio' name='sitetheme' value=' { $val } ' required='required' $selected />
< div > " . $thumbnail . "
< h5 > " . $title . " < small > ( " . $category . " ) </ small >< span class = 'glyphicon glyphicon-ok text-success' ></ span ></ h5 >
</ div >
</ label >
</ div > " ;*/
}
$output .= $this -> thumbnailSelector ( 'sitetheme' , $opts , DEFAULT_INSTALL_THEME );
$output .= "
</ td >
</ tr >
< tr >
< td >< label for = 'install_plugins' > " .LANINS_118. " </ label ></ td >
< td >
< input type = 'checkbox' name = 'install_plugins' checked = 'checked' id = 'install_plugins' value = '1' />
< span class = 'field-help' > " .LANINS_119. " </ span >
</ td >
</ tr >
< tr >
< td >< label for = 'generate_content' > " .LANINS_111. " </ label ></ td >
< td >
< input type = 'checkbox' name = 'generate_content' checked = 'checked' id = 'generate_content' value = '1' />
< span class = 'field-help' > " .LANINS_112. " </ span >
</ td >
</ tr >
</ table >
< br />< br />
</ div >
\n " ;
$e_forms -> add_plain_html ( $output );
$this -> finish_form ();
$this -> add_button ( " submit " , LAN_CONTINUE );
$this -> template -> SetTag ( " stage_content " , $e_forms -> return_form ());
2019-06-03 15:27:36 -07:00
installLog :: add ( 'Stage 6 completed' );
return null ;
2019-03-29 19:13:32 -05:00
}
private function thumbnailSelector ( $name , $opts , $default = '' )
{
$ret = '' ;
foreach ( $opts as $key => $val )
{
if ( ! is_readable ( $val [ 'preview' ]) || ! is_file ( $val [ 'preview' ]))
{
continue ;
}
$thumbnail = " <img class='img-responsive img-fluid thumbnail' src=' " . $val [ 'preview' ] . " ' alt=' " . $key . " ' /> " ;
$selected = ( $key === $default ) ? " checked " : " " ;
$categoryInfo = ! empty ( $val [ 'category' ]) ? " <small>( " . $val [ 'category' ] . " )</small> " : " " ;
$ret .= "
< div class = 'col-md-6 theme-cell' >
< label class = 'theme-selection' title = \ " " . $val [ 'description' ] . " \" ><input type='radio' name=' " . $name . " ' value=' { $key } ' required='required' $selected />
< div > " . $thumbnail . "
< h5 > " . $val['title'] . " " . $categoryInfo . " < span class = 'glyphicon glyphicon-ok text-success' ></ span ></ h5 >
</ div >
</ label >
</ div > " ;
}
return $ret ;
}
private function stage_7 ()
{
global $e_forms ;
$tp = e107 :: getParser ();
$this -> e107 -> e107_dirs [ 'SYSTEM_DIRECTORY' ] = str_replace ( " [hash] " , $this -> e107 -> site_path , $this -> e107 -> e107_dirs [ 'SYSTEM_DIRECTORY' ]);
$this -> e107 -> e107_dirs [ 'CACHE_DIRECTORY' ] = str_replace ( " [hash] " , $this -> e107 -> site_path , $this -> e107 -> e107_dirs [ 'CACHE_DIRECTORY' ]);
$this -> e107 -> e107_dirs [ 'SYSTEM_DIRECTORY' ] = str_replace ( " / " . $this -> e107 -> site_path , " " , $this -> e107 -> e107_dirs [ 'SYSTEM_DIRECTORY' ]);
$this -> e107 -> e107_dirs [ 'MEDIA_DIRECTORY' ] = str_replace ( " / " . $this -> e107 -> site_path , " " , $this -> e107 -> e107_dirs [ 'MEDIA_DIRECTORY' ]);
$this -> stage = 7 ;
2019-06-03 15:27:36 -07:00
installLog :: add ( 'Stage 7 started' );
2019-03-29 19:13:32 -05:00
// required for various core routines
if ( ! defined ( 'USERNAME' ))
{
define ( 'USERNAME' , $this -> previous_steps [ 'admin' ][ 'user' ]);
define ( 'USEREMAIL' , $this -> previous_steps [ 'admin' ][ 'email' ]);
}
if ( varset ( $_POST [ 'sitename' ]))
{
$this -> previous_steps [ 'prefs' ][ 'sitename' ] = $tp -> filter ( $_POST [ 'sitename' ]);
}
if ( varset ( $_POST [ 'sitetheme' ]))
{
$this -> previous_steps [ 'prefs' ][ 'sitetheme' ] = $tp -> filter ( $_POST [ 'sitetheme' ]);
}
if ( varset ( $_POST [ 'generate_content' ]))
{
$this -> previous_steps [ 'generate_content' ] = $tp -> filter ( $_POST [ 'generate_content' ], 'int' );
}
if ( varset ( $_POST [ 'install_plugins' ]))
{
$this -> previous_steps [ 'install_plugins' ] = $tp -> filter ( $_POST [ 'install_plugins' ], 'int' );
}
// Validate
if ( ! vartrue ( $this -> previous_steps [ 'prefs' ][ 'sitename' ]))
{
$this -> required [ 'sitename' ] = LANINS_113 ; // 'Please enter a website name.'; // should be used to highlight the required field. (using css for example)
}
if ( ! vartrue ( $this -> previous_steps [ 'prefs' ][ 'sitetheme' ]))
{
$this -> required [ 'sitetheme' ] = LANINS_114 ; // 'Please select a theme.';
}
if ( ! empty ( $this -> required [ 'sitetheme' ]) || ! empty ( $this -> required [ 'sitename' ]))
{
return $this -> stage_6 ();
}
$config_file = " <?php
/*
* e107 website system
*
* Copyright ( C ) 2008 - " .date('Y'). " e107 Inc ( e107 . org )
* Released under the terms and conditions of the
* GNU General Public License ( http :// www . gnu . org / licenses / gpl . txt )
*
* e107 configuration file
*
* This file has been generated by the installation script on " .date('r'). " .
*/
\ $mySQLserver = '{$this->previous_steps[' mysql '][' server ']}' ;
\ $mySQLuser = '{$this->previous_steps[' mysql '][' user ']}' ;
\ $mySQLpassword = '{$this->previous_steps[' mysql '][' password ']}' ;
\ $mySQLdefaultdb = '{$this->previous_steps[' mysql '][' db ']}' ;
\ $mySQLprefix = '{$this->previous_steps[' mysql '][' prefix ']}' ;
Convert and run e107 using the MySQL/MariaDB utf8mb4 character set and
InnoDB storage engine
Components affected:
* `db_verify` now checks and corrects the table storage engine
* `db_verify` now checks and corrects the table default character set
* Note: Field character sets can still be overridden
* Note: When correcting, the entire table is converted to the target
charset.
* The alt_auth plugin now connects via PDO using the e107 default
charset, utf8mb4
* `e_db_pdo` now sets the charset to utf8mb4. This is currently not
customizable because it was previously not customizable.
* `install.php` now generates an `e107_config.php` file with
`$mySQLcharset = 'utf8mb4';`, though this option is not actually used.
* `install.php` now removes plugin tables before installing plugins.
* `e_db_mysql` now only accepts the `utf8mb4` charset. Previously, it
only accepted the `utf8` charset.
* `e_db_mysql` now configures `mysqli_real_escape_string` to match the
new default charset, `utf8mb4`.
* Plugin installations now use the preferred MySQL table storage engines
and charsets.
The preferred MySQL table storage engines are now mapped like so:
* If `ENGINE=MyISAM` is specified, the actual storage engine set will be
the first available of: InnoDB, Aria, Maria, MyISAM
* If `ENGINE=Aria` is specified, the actual storage engine set will be
the first available of: Aria, Maria, MyISAM
* If `ENGINE=InnoDB` is specified, the actual storage engine set will be
the first available of: InnoDB, XtraDB
* If `ENGINE=XtraDB` is specified, the actual storage engine set will be
the first available of: XtraDB, InnoDB
The preferred MySQL character set is now aliased like so:
* `utf8` => `utf8mb4`
* `utf8mb3` => `utf8mb3`
* `utf8mb4` => `utf8mb4`
Fixes: #4501
2021-05-22 00:46:35 -05:00
\ $mySQLcharset = 'utf8mb4' ;
2019-03-29 19:13:32 -05:00
\ $ADMIN_DIRECTORY = '{$this->e107->e107_dirs[' ADMIN_DIRECTORY ']}' ;
\ $FILES_DIRECTORY = '{$this->e107->e107_dirs[' FILES_DIRECTORY ']}' ;
\ $IMAGES_DIRECTORY = '{$this->e107->e107_dirs[' IMAGES_DIRECTORY ']}' ;
\ $THEMES_DIRECTORY = '{$this->e107->e107_dirs[' THEMES_DIRECTORY ']}' ;
\ $PLUGINS_DIRECTORY = '{$this->e107->e107_dirs[' PLUGINS_DIRECTORY ']}' ;
\ $HANDLERS_DIRECTORY = '{$this->e107->e107_dirs[' HANDLERS_DIRECTORY ']}' ;
\ $LANGUAGES_DIRECTORY = '{$this->e107->e107_dirs[' LANGUAGES_DIRECTORY ']}' ;
\ $HELP_DIRECTORY = '{$this->e107->e107_dirs[' HELP_DIRECTORY ']}' ;
\ $MEDIA_DIRECTORY = '{$this->e107->e107_dirs[' MEDIA_DIRECTORY ']}' ;
\ $SYSTEM_DIRECTORY = '{$this->e107->e107_dirs[' SYSTEM_DIRECTORY ']}' ;
2021-11-29 13:45:02 -08:00
\ $E107_CONFIG = [ 'site_path' => '{$this->previous_steps[' paths '][' hash ']}' ];
2019-03-29 19:13:32 -05:00
// -- Optional --
2023-03-24 13:06:30 -07:00
// define('e_EMAIL_CRITICAL', '".$this->previous_steps['admin']['email']."'); // email the admin (and share no details with the user) if a critical error occurs.
// define('e_LOG_CRITICAL', true); // log critical errors but do not display them to user. (similar to above, but no email is sent - instead error goes into a log file)
2019-03-29 19:13:32 -05:00
// define('e_DEBUG', true); // Enable debug mode to allow displaying of errors
// define('e_HTTP_STATIC', 'https://static.mydomain.com/'); // Use a static subdomain for js/css/images etc.
// define('e_MOD_REWRITE_STATIC', true); // Rewrite static image urls.
// define('e_GIT', 'path-to-git'); // Path to GIT for developers
// define('X-FRAME-SAMEORIGIN', false); // Option to override X-Frame-Options
// define('e_PDO, true); // Enable PDO mode (used in PHP > 7 and when mysql_* methods are not available)
" ;
/*
if ( $this -> pdo == true )
{
$config_file .= 'define("e_PDO", true);' ;
$config_file .= " \n \n " ;
} */
2024-04-08 16:02:44 -07:00
// New format e107 v2.4+
$config_file = " <?php
/*
* e107 website system
*
* Copyright ( C ) 2008 - " .date('Y'). " e107 Inc ( e107 . org )
* Released under the terms and conditions of the
* GNU General Public License ( http :// www . gnu . org / licenses / gpl . txt )
*
* e107 configuration file
*
* This file has been generated by the installation script on " .date('r'). " .
*/
// -- Optional --
// const e_EMAIL_CRITICAL = '{$this->previous_steps['admin']['email']}'; // email the admin (and share no details with the user) if a critical error occurs.
// const e_LOG_CRITICAL = true; // log critical errors but do not display them to user. (similar to above, but no email is sent - instead error goes into a log file)
// const e_DEBUG = true; // Enable debug mode to allow displaying of errors
// const e_HTTP_STATIC = 'https://static.mydomain.com/'; // Use a static subdomain for js/css/images etc.
// const e_MOD_REWRITE_STATIC = true; // Rewrite static image urls.
// const e_GIT = 'path-to-git'; // Path to GIT for developers
// const X_FRAME_SAMEORIGIN = false; // Option to override X-Frame-Options
return [
'database' => [
'server' => '{$this->previous_steps[' mysql '][' server ']}' ,
'user' => '{$this->previous_steps[' mysql '][' user ']}' ,
'password' => '{$this->previous_steps[' mysql '][' password ']}' ,
'defaultdb' => '{$this->previous_steps[' mysql '][' db ']}' ,
'prefix' => '{$this->previous_steps[' mysql '][' prefix ']}' ,
'charset' => 'utf8mb4' ,
],
'paths' => [
'admin' => '{$this->e107->e107_dirs[' ADMIN_DIRECTORY ']}' ,
'files' => '{$this->e107->e107_dirs[' FILES_DIRECTORY ']}' ,
'images' => '{$this->e107->e107_dirs[' IMAGES_DIRECTORY ']}' ,
'themes' => '{$this->e107->e107_dirs[' THEMES_DIRECTORY ']}' ,
'plugins' => '{$this->e107->e107_dirs[' PLUGINS_DIRECTORY ']}' ,
'handlers' => '{$this->e107->e107_dirs[' HANDLERS_DIRECTORY ']}' ,
'languages' => '{$this->e107->e107_dirs[' LANGUAGES_DIRECTORY ']}' ,
'help' => '{$this->e107->e107_dirs[' HELP_DIRECTORY ']}' ,
'media' => '{$this->e107->e107_dirs[' MEDIA_DIRECTORY ']}' ,
'system' => '{$this->e107->e107_dirs[' SYSTEM_DIRECTORY ']}' ,
],
'site' => [
'site_path' => '{$this->previous_steps[' paths '][' hash ']}' ,
]
];
" ;
2019-03-29 19:13:32 -05:00
$config_result = $this -> write_config ( $config_file );
if ( $config_result )
{
2019-06-03 15:27:36 -07:00
// $page = $config_result."<br />";
installLog :: add ( 'Error writing config file: ' . $config_result );
}
else
{
installLog :: add ( 'Config file written successfully' );
2019-03-29 19:13:32 -05:00
}
// Data is okay - Continue.
// $this->previous_steps['prefs']['sitename'] = $_POST['sitename'];
// $this->previous_steps['prefs']['sitetheme'] = $_POST['sitetheme'];
// $this->previous_steps['generate_content'] = $_POST['generate_content'];
$this -> template -> SetTag ( " installation_heading " , LANINS_001 );
$this -> template -> SetTag ( " stage_pre " , LANINS_002 );
$this -> template -> SetTag ( " stage_num " , LANINS_058 );
$this -> template -> SetTag ( " stage_title " , LANINS_055 );
$this -> template -> SetTag ( " percent " , 80 );
$this -> template -> SetTag ( " bartype " , 'warning' );
2020-12-21 17:46:32 -08:00
$e_forms -> start_form ( " confirmation " , $_SERVER [ 'PHP_SELF' ] . ( $_SERVER [ 'QUERY_STRING' ] === " debug " ? " ?debug " : " " ));
2019-03-29 19:13:32 -05:00
$page = '<div class="alert alert-success">' . nl2br ( LANINS_057 ) . '</div>' ;
$this -> finish_form ();
$this -> add_button ( " submit " , LAN_CONTINUE );
$this -> template -> SetTag ( " stage_content " , $page . $e_forms -> return_form ());
2019-06-03 15:27:36 -07:00
installLog :: add ( 'Stage 7 completed' );
return null ;
2019-03-29 19:13:32 -05:00
}
/**
* Stage 8 - actually create database and set up the site
*
2019-06-03 15:27:36 -07:00
* @ return null
2019-03-29 19:13:32 -05:00
*/
private function stage_8 ()
{
global $e_forms ;
//$system_dir = str_replace("/".$this->e107->site_path,"",$this->e107->e107_dirs['SYSTEM_DIRECTORY']);
//$media_dir = str_replace("/".$this->e107->site_path,"",$this->e107->e107_dirs['MEDIA_DIRECTORY']);
// required for various core routines
if ( ! defined ( 'USERNAME' ))
{
define ( 'USERNAME' , $this -> previous_steps [ 'admin' ][ 'user' ]);
define ( 'USEREMAIL' , $this -> previous_steps [ 'admin' ][ 'email' ]);
}
2019-06-03 15:27:36 -07:00
$this -> setDb ();
define ( 'THEME' , e_THEME . $this -> previous_steps [ 'prefs' ][ 'sitetheme' ] . '/' );
define ( 'THEME_ABS' , e_THEME_ABS . $this -> previous_steps [ 'prefs' ][ 'sitetheme' ] . '/' );
define ( 'USERCLASS_LIST' , '253,247,254,250,251,0' );
2019-03-29 19:13:32 -05:00
$this -> stage = 8 ;
2019-06-03 15:27:36 -07:00
installLog :: add ( 'Stage 8 started' );
2019-03-29 19:13:32 -05:00
$this -> template -> SetTag ( " installation_heading " , LANINS_001 );
$this -> template -> SetTag ( " stage_pre " , LANINS_002 );
$this -> template -> SetTag ( " stage_num " , LANINS_120 );
$this -> template -> SetTag ( " stage_title " , LANINS_071 );
$this -> template -> SetTag ( " percent " , 100 );
$this -> template -> SetTag ( " bartype " , 'success' );
$htaccessError = $this -> htaccess ();
$this -> saveFileTypes ();
$e_forms -> start_form ( " confirmation " , " index.php " );
$errors = $this -> create_tables ();
2019-06-03 15:27:36 -07:00
if ( ! empty ( $errors ))
2019-03-29 19:13:32 -05:00
{
2019-06-03 15:27:36 -07:00
installLog :: add ( 'Errors creating tables: ' . $errors );
2019-03-29 19:13:32 -05:00
$page = $errors . " <br /> " ;
$alertType = 'error' ;
}
else
{
$alertType = 'success' ;
2019-06-03 15:27:36 -07:00
installLog :: add ( 'Tables created successfully' );
2019-03-29 19:13:32 -05:00
$this -> import_configuration ();
$page = nl2br ( LANINS_125 ) . " <br /> " ;
$page .= ( is_writable ( 'e107_config.php' )) ? " <br /> " . str_replace ( " e107_config.php " , " <b>e107_config.php</b> " , LANINS_126 ) : " " ;
if ( $htaccessError )
{
$page .= " <br /> " . $htaccessError ;
}
$this -> add_button ( 'submit' , LAN_CONTINUE );
}
2023-10-29 08:15:29 -07:00
2019-03-29 19:13:32 -05:00
$this -> stats ();
2023-10-29 08:15:29 -07:00
$this -> finish_form ();
2019-03-29 19:13:32 -05:00
$this -> template -> SetTag ( " stage_content " , " <div class='alert alert-block alert- { $alertType } '> " . $page . " </div> " . $e_forms -> return_form ());
2019-06-03 15:27:36 -07:00
installLog :: add ( 'Stage 8 completed' );
2019-03-29 19:13:32 -05:00
e107 :: getMessage () -> reset ( false , false , true );
2019-06-03 15:27:36 -07:00
return null ;
2019-03-29 19:13:32 -05:00
}
private function saveFileTypes ()
{
$data = ' < ? xml version = " 1.0 " encoding = " utf-8 " ?>
< e107Filetypes >
2021-04-21 16:48:04 -07:00
< class name = " member " type = " zip,gz,jpg,jpeg,png,gif,webp,xml,pdf " maxupload = " 2M " />
< class name = " admin " type = " zip,gz,jpg,jpeg,png,gif,webp,xml,pdf " maxupload = " 10M " />
2023-03-24 13:06:30 -07:00
< class name = " main " type = " zip,gz,rar,jpg,jpeg,png,gif,webp,xml,pdf,ppt,pptx,mov,mp4,mp3,doc,docx,xls,xlsm,mp3,mp4,wav,ogg,webm,mid,midi,torrent,txt,dmg,msi " maxupload = " 50M " />
2019-03-29 19:13:32 -05:00
</ e107Filetypes > ' ;
return file_put_contents ( $this -> e107 -> e107_dirs [ 'SYSTEM_DIRECTORY' ] . " filetypes.xml " , $data );
}
protected function stats ()
{
global $e_forms ;
2023-10-29 08:15:29 -07:00
$data = array ( 'name' => $this -> previous_steps [ 'prefs' ][ 'sitename' ], 'theme' => $this -> previous_steps [ 'prefs' ][ 'sitetheme' ], 'language' => $this -> previous_steps [ 'language' ], 'url' => $_SERVER [ 'SCRIPT_URI' ], 'version' => defset ( 'e_VERSION' ), 'php' => defset ( 'PHP_VERSION' ));
$base = base64_encode ( http_build_query ( $data , '' , '&' ));
2019-03-29 19:13:32 -05:00
$url = " https://e107.org/e-install/ " . $base ;
$e_forms -> add_plain_html ( " <img src=' " . $url . " ' style='width:1px; height:1px' /> " );
}
/**
* htaccess - handle the . htaccess file
*
* @ return string $error
*/
protected function htaccess ()
{
$error = " " ;
if ( ! file_exists ( " .htaccess " ))
{
if ( ! rename ( " e107.htaccess " , " .htaccess " ))
{
$error = LANINS_142 ;
}
2020-12-21 17:46:32 -08:00
elseif ( $_SERVER [ 'QUERY_STRING' ] === " debug " )
2019-03-29 19:13:32 -05:00
{
rename ( " .htaccess " , " e107.htaccess " );
$error = " DEBUG: Rename from e107.htaccess to .htaccess was successful " ;
}
}
elseif ( file_exists ( " e107.htaccess " ))
{
$srch = array ( '[b]' , '[/b]' );
$repl = array ( '<b>' , '</b>' );
$error = str_replace ( $srch , $repl , LANINS_144 ); // too early to use e107::getParser() so use str_replace();
}
return $error ;
}
/**
* Import and generate preferences and default content .
*
* @ return boolean
*/
public function import_configuration ()
{
2019-06-03 15:27:36 -07:00
installLog :: add ( 'Starting configuration import' );
2019-03-29 19:13:32 -05:00
// PRE-CONFIG start - create and register blank config instances - do not load!
$config_aliases = array (
'core' ,
'core_backup' ,
'emote' ,
'menu' ,
'search' ,
'notify' ,
);
foreach ( $config_aliases as $alias )
{
e107 :: getConfig ( $alias , false ) -> clearPrefCache ();
}
// PRE-CONFIG end
// Basic stuff to get the handlers/classes to work.
// $udirs = "admin/|plugins/|temp";
// $e_SELF = $_SERVER['PHP_SELF'];
// $e_HTTP = preg_replace("#".$udirs."#i", "", substr($e_SELF, 0, strrpos($e_SELF, "/"))."/");
// define("MAGIC_QUOTES_GPC", (ini_get('magic_quotes_gpc') ? true : false));
// define('CHARSET', 'utf-8');
// define("e_LANGUAGE", $this->previous_steps['language']);
// define('e_SELF', 'http://'.$_SERVER['HTTP_HOST']) . ($_SERVER['PHP_SELF'] ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_FILENAME']);
$themeImportFile = array ();
$themeImportFile [ 0 ] = $this -> e107 -> e107_dirs [ 'THEMES_DIRECTORY' ] . $this -> previous_steps [ 'prefs' ][ 'sitetheme' ] . " /install.xml " ;
$themeImportFile [ 1 ] = $this -> e107 -> e107_dirs [ 'THEMES_DIRECTORY' ] . $this -> previous_steps [ 'prefs' ][ 'sitetheme' ] . " /install/install.xml " ;
// $themeImportFile[3] = $this->e107->e107_dirs['CORE_DIRECTORY']. "xml/default_install.xml";
$XMLImportfile = false ;
if ( vartrue ( $this -> previous_steps [ 'generate_content' ]))
{
foreach ( $themeImportFile as $file )
{
if ( is_readable ( $file ))
{
$XMLImportfile = $file ;
break ;
}
}
}
$tp = e107 :: getParser ();
define ( 'PREVIEWTHEMENAME' , " " ); // Notice Removal.
// include_lan($this->e107->e107_dirs['LANGUAGES_DIRECTORY'].$this->previous_steps['language']."/lan_prefs.php");
include_lan ( $this -> e107 -> e107_dirs [ 'LANGUAGES_DIRECTORY' ] . $this -> previous_steps [ 'language' ] . " /admin/lan_theme.php " );
2019-06-03 15:27:36 -07:00
2019-03-29 19:13:32 -05:00
$coreConfig = $this -> e107 -> e107_dirs [ 'CORE_DIRECTORY' ] . " xml/default_install.xml " ;
$ret = e107 :: getXml () -> e107Import ( $coreConfig , 'replace' , true , false ); // Add core pref values
2019-06-03 15:27:36 -07:00
installLog :: add ( 'Attempting to Write Core Prefs.' );
installLog :: add ( print_r ( $ret , true ));
2019-03-29 19:13:32 -05:00
/*
if ( $XMLImportfile ) // We cannot rely on themes to include all prefs..so use 'replace'.
{
$ret2 = e107 :: getXml () -> e107Import ( $XMLImportfile , 'replace' , true , false ); // Overwrite specific core pref and tables entries.
2019-06-03 15:27:36 -07:00
installLog :: add ( 'Attempting to write Theme Prefs/Tables (install.xml)' );
installLog :: add ( print_r ( $ret2 , true ));
2019-03-29 19:13:32 -05:00
}
*/ //Create default plugin-table entries.
// e107::getConfig('core')->clearPrefCache();
2019-06-03 15:27:36 -07:00
installLog :: add ( 'Updating Plugin Tables' );
e107 :: getPlug ();
// e107::getPlugin()->update_plugins_table('update');
installLog :: add ( 'Plugins table updated' );
2019-03-29 19:13:32 -05:00
// Install Theme-required plugins
2020-12-21 17:46:32 -08:00
if ( vartrue ( $this -> previous_steps [ 'install_plugins' ]) && ( $themeInfo = $this -> get_theme_xml ( $this -> previous_steps [ 'prefs' ][ 'sitetheme' ])) && isset ( $themeInfo [ 'plugins' ][ 'plugin' ]))
2019-03-29 19:13:32 -05:00
{
2022-04-06 19:33:03 -07:00
$themeName = $this -> previous_steps [ 'prefs' ][ 'sitetheme' ];
2020-12-21 17:46:32 -08:00
foreach ( $themeInfo [ 'plugins' ][ 'plugin' ] as $k => $plug )
2019-03-29 19:13:32 -05:00
{
2020-12-21 17:46:32 -08:00
$this -> install_plugin ( $plug [ '@attributes' ][ 'name' ]);
2022-04-06 19:33:03 -07:00
installLog :: add ( 'Theme-related (' . $themeName . ') plugin installed: ' . $plug [ '@attributes' ][ 'name' ]);
2019-03-29 19:13:32 -05:00
}
}
2019-06-03 15:27:36 -07:00
installLog :: add ( 'Updating addon Prefs' );
2019-03-29 19:13:32 -05:00
e107 :: getSingleton ( 'e107plugin' ) -> save_addon_prefs ( 'update' ); // save plugin addon pref-lists. eg. e_latest_list.
2019-06-03 15:27:36 -07:00
installLog :: add ( 'Addon prefs saved' );
2019-03-29 19:13:32 -05:00
// do this AFTER any required plugins are installated.
if ( $XMLImportfile ) // We cannot rely on themes to include all prefs..so use 'replace'.
{
$ret2 = e107 :: getXml () -> e107Import ( $XMLImportfile , 'replace' , true , false ); // Overwrite specific core pref and tables entries.
2019-06-03 15:27:36 -07:00
installLog :: add ( 'Attempting to write Theme Prefs/Tables (install.xml)' );
installLog :: add ( print_r ( $ret2 , true ));
2019-03-29 19:13:32 -05:00
}
$tm = e107 :: getSingleton ( 'themeHandler' );
$tm -> noLog = true ; // false to enable log
$tm -> setTheme ( $this -> previous_steps [ 'prefs' ][ 'sitetheme' ], false );
// Admin log fix - don't allow logs to be called inside pref handler
// FIX
2020-12-08 07:29:17 -08:00
e107 :: getConfig () -> setParam ( 'nologs' , true ); // change to false to enable log
$pref = e107 :: getConfig () -> getPref ();
2019-03-29 19:13:32 -05:00
// Set Preferences defined during install - overwriting those that may exist in the XML.
$this -> previous_steps [ 'prefs' ][ 'sitelanguage' ] = $this -> previous_steps [ 'language' ];
$this -> previous_steps [ 'prefs' ][ 'sitelang_init' ] = $this -> previous_steps [ 'language' ];
$this -> previous_steps [ 'prefs' ][ 'siteadmin' ] = $this -> previous_steps [ 'admin' ][ 'display' ];
$this -> previous_steps [ 'prefs' ][ 'siteadminemail' ] = $this -> previous_steps [ 'admin' ][ 'email' ];
$this -> previous_steps [ 'prefs' ][ 'install_date' ] = time ();
$this -> previous_steps [ 'prefs' ][ 'siteurl' ] = e_HTTP ;
$this -> previous_steps [ 'prefs' ][ 'sitetag' ] = " e107 Website System " ;
$this -> previous_steps [ 'prefs' ][ 'sitedisclaimer' ] = '' ;
$this -> previous_steps [ 'prefs' ][ 'replyto_name' ] = $this -> previous_steps [ 'admin' ][ 'display' ];
$this -> previous_steps [ 'prefs' ][ 'replyto_email' ] = $this -> previous_steps [ 'admin' ][ 'email' ];
// Cookie name fix, ended up with 406 error when non-latin words used
$cookiename = preg_replace ( '/[^a-z0-9]/i' , '' , trim ( $this -> previous_steps [ 'prefs' ][ 'sitename' ]));
$this -> previous_steps [ 'prefs' ][ 'cookie_name' ] = ( $cookiename ? substr ( $cookiename , 0 , 4 ) . '_' : 'e_' ) . 'cookie' ;
### URL related prefs
// set all prefs so that they are available, required for adminReadModules() - it checks which plugins are installed
2020-12-08 07:29:17 -08:00
e107 :: getConfig () -> setPref ( $this -> previous_steps [ 'prefs' ]);
2019-03-29 19:13:32 -05:00
$url_modules = eRouter :: adminReadModules ();
$url_locations = eRouter :: adminBuildLocations ( $url_modules );
$url_config = eRouter :: adminBuildConfig ( array (), $url_modules );
2022-04-06 18:22:35 -07:00
2019-03-29 19:13:32 -05:00
$this -> previous_steps [ 'prefs' ][ 'url_aliases' ] = array ();
2022-04-07 07:15:30 -07:00
$this -> previous_steps [ 'prefs' ][ 'url_config' ] = $url_config ;
2019-03-29 19:13:32 -05:00
$this -> previous_steps [ 'prefs' ][ 'url_modules' ] = $url_modules ;
$this -> previous_steps [ 'prefs' ][ 'url_locations' ] = $url_locations ;
2022-04-06 18:22:35 -07:00
2019-03-29 19:13:32 -05:00
eRouter :: clearCache ();
2019-06-03 15:27:36 -07:00
installLog :: add ( 'Core URL config set to default state' );
2019-03-29 19:13:32 -05:00
$us = e107 :: getUserSession ();
if ( $us -> passwordAPIExists () === true )
{
$this -> previous_steps [ 'prefs' ][ 'passwordEncoding' ] = PASSWORD_E107_PHP ;
$pwdEncoding = PASSWORD_E107_PHP ;
}
else
{
$pwdEncoding = PASSWORD_E107_MD5 ; // default already in default_install.xml
}
// Set prefs, save
2020-12-08 07:29:17 -08:00
e107 :: getConfig () -> setPref ( $this -> previous_steps [ 'prefs' ]);
e107 :: getConfig () -> save ( FALSE , TRUE , FALSE ); // save preferences made during install.
2019-06-03 15:27:36 -07:00
installLog :: add ( 'Core prefs set to install choices' );
2019-03-29 19:13:32 -05:00
// Create the admin user - replacing any that may be been included in the XML.
$hash = $us -> HashPassword ( $this -> previous_steps [ 'admin' ][ 'password' ], $this -> previous_steps [ 'admin' ][ 'user' ], $pwdEncoding );
$ip = $_SERVER [ 'REMOTE_ADDR' ];
$userp = " 1, ' { $this -> previous_steps [ 'admin' ][ 'display' ] } ', ' { $this -> previous_steps [ 'admin' ][ 'user' ] } ', '', ' " . $hash . " ', '', ' { $this -> previous_steps [ 'admin' ][ 'email' ] } ', '', '', 0, " . time () . " , 0, 0, 0, 0, 0, ' { $ip } ', 0, '', 0, 1, '', '', '0', '', " . time () . " , '' " ;
2019-06-03 15:27:36 -07:00
// $qry = "REPLACE INTO {$this->previous_steps['mysql']['prefix']}user VALUES ({$userp})";
2019-03-29 19:13:32 -05:00
$this -> dbqry ( " REPLACE INTO { $this -> previous_steps [ 'mysql' ][ 'prefix' ] } user VALUES ( { $userp } ) " );
2019-06-03 15:27:36 -07:00
installLog :: add ( 'Admin user created' );
2019-03-29 19:13:32 -05:00
// Add Default user-extended values;
$extendedQuery = " REPLACE INTO ` { $this -> previous_steps [ 'mysql' ][ 'prefix' ] } user_extended` (`user_extended_id` , `user_hidden_fields`) VALUES ('1', NULL ); " ;
$this -> dbqry ( $extendedQuery );
e107 :: getDb () -> close ();
// mysql_close($this->dbLink);
e107 :: getMessage () -> reset ( false , false , true );
2019-06-03 15:27:36 -07:00
unset ( $tp , $pref );
2019-03-29 19:13:32 -05:00
return false ;
}
/**
* Install a Theme required plugin .
*
* @ param string $plugpath - plugin folder name
2019-06-03 15:27:36 -07:00
* @ return null
2019-03-29 19:13:32 -05:00
*/
2019-06-03 15:27:36 -07:00
public function install_plugin ( $plugpath )
2019-03-29 19:13:32 -05:00
{
Convert and run e107 using the MySQL/MariaDB utf8mb4 character set and
InnoDB storage engine
Components affected:
* `db_verify` now checks and corrects the table storage engine
* `db_verify` now checks and corrects the table default character set
* Note: Field character sets can still be overridden
* Note: When correcting, the entire table is converted to the target
charset.
* The alt_auth plugin now connects via PDO using the e107 default
charset, utf8mb4
* `e_db_pdo` now sets the charset to utf8mb4. This is currently not
customizable because it was previously not customizable.
* `install.php` now generates an `e107_config.php` file with
`$mySQLcharset = 'utf8mb4';`, though this option is not actually used.
* `install.php` now removes plugin tables before installing plugins.
* `e_db_mysql` now only accepts the `utf8mb4` charset. Previously, it
only accepted the `utf8` charset.
* `e_db_mysql` now configures `mysqli_real_escape_string` to match the
new default charset, `utf8mb4`.
* Plugin installations now use the preferred MySQL table storage engines
and charsets.
The preferred MySQL table storage engines are now mapped like so:
* If `ENGINE=MyISAM` is specified, the actual storage engine set will be
the first available of: InnoDB, Aria, Maria, MyISAM
* If `ENGINE=Aria` is specified, the actual storage engine set will be
the first available of: Aria, Maria, MyISAM
* If `ENGINE=InnoDB` is specified, the actual storage engine set will be
the first available of: InnoDB, XtraDB
* If `ENGINE=XtraDB` is specified, the actual storage engine set will be
the first available of: XtraDB, InnoDB
The preferred MySQL character set is now aliased like so:
* `utf8` => `utf8mb4`
* `utf8mb3` => `utf8mb3`
* `utf8mb4` => `utf8mb4`
Fixes: #4501
2021-05-22 00:46:35 -05:00
$plugin_handler = e107 :: getPlugin ();
$plugin_handler -> XmlTables ( 'uninstall' , [ 'plugin_path' => $plugpath ], [ 'delete_tables' => true ]);
$plugin_handler -> install ( $plugpath );
2019-03-29 19:13:32 -05:00
e107 :: getMessage () -> reset ( false , false , true );
2019-06-03 15:27:36 -07:00
return null ;
2019-03-29 19:13:32 -05:00
}
/**
* Check a DB name or table prefix - anything starting with a numeric followed by 'e' causes problems .
* Return TRUE if acceptable , FALSE if unacceptable
* Empty string returns the value of $blank_ok ( caller should set TRUE for prefix , FALSE for DB name )
*
* @ param string $str
* @ param boolean $blank_ok [ optional ]
* @ return boolean
*/
function check_name ( $str , $blank_ok = FALSE )
{
if ( $str == '' )
2020-12-21 17:46:32 -08:00
{
2019-03-29 19:13:32 -05:00
return $blank_ok ;
2020-12-21 17:46:32 -08:00
}
2019-03-29 19:13:32 -05:00
if ( preg_match ( " #^ \ d+[e|E]# " , $str ))
2020-12-21 17:46:32 -08:00
{
return false ;
}
2019-03-29 19:13:32 -05:00
return TRUE ;
}
/**
* checkDbFields - Check an array of db - related fields for illegal characters
*
* @ param array $fields
* @ return boolean TRUE for OK , FALSE for invalid character
*/
function checkDbFields ( $fields )
{
2020-12-21 17:46:32 -08:00
if ( ! is_array ( $fields ))
{
return false ;
}
2019-03-29 19:13:32 -05:00
foreach ( array ( 'server' , 'user' , 'db' , 'prefix' ) as $key )
{
2020-12-21 17:46:32 -08:00
if ( isset ( $fields [ $key ]) && strtr ( $fields [ $key ], " '; " , ' ' ) != $fields [ $key ])
2019-03-29 19:13:32 -05:00
{
2020-12-21 17:46:32 -08:00
return FALSE ; // Invalid character found
2019-03-29 19:13:32 -05:00
}
}
return TRUE ;
}
function get_lan_file ()
{
if ( ! empty ( $_POST [ 'language' ]))
{
$this -> previous_steps [ 'language' ] = $_POST [ 'language' ];
}
if ( ! isset ( $this -> previous_steps [ 'language' ]))
{
$this -> previous_steps [ 'language' ] = " English " ;
}
include_lan ( $this -> e107 -> e107_dirs [ 'LANGUAGES_DIRECTORY' ] . $this -> previous_steps [ 'language' ] . " /lan_installer.php " );
// $this->lan_file = "{$this->e107->e107_dirs['LANGUAGES_DIRECTORY']}{$this->previous_steps['language']}/lan_installer.php";
// if(is_readable($this->lan_file))
// {
// include($this->lan_file);
// }
// elseif(is_readable("{$this->e107->e107_dirs['LANGUAGES_DIRECTORY']}English/lan_installer.php"))
// {
// include("{$this->e107->e107_dirs['LANGUAGES_DIRECTORY']}English/lan_installer.php");
// }
// else
// {
// $this->raise_error("Fatal: Could not get valid language file for installation.");
// }
}
/**
* get_languages - check language folder for language names
*
* @ return array $lanlist
*/
function get_languages ()
{
$handle = opendir ( $this -> e107 -> e107_dirs [ 'LANGUAGES_DIRECTORY' ]);
$lanlist = array ();
while ( $file = readdir ( $handle ))
{
2020-12-21 17:46:32 -08:00
if ( $file !== " . " && $file !== " .. " && $file !== " / " && $file !== " CVS " && $file !== 'index.html' )
2019-03-29 19:13:32 -05:00
{
if ( file_exists ( " ./ { $this -> e107 -> e107_dirs [ 'LANGUAGES_DIRECTORY' ] } { $file } /lan_installer.php " ))
{
$lanlist [] = $file ;
}
}
}
closedir ( $handle );
return $lanlist ;
}
/**
* get_themes - check theme folder for theme names
*
* @ return array $themelist
*/
function get_themes ()
{
2022-04-06 18:22:35 -07:00
return [ 'bootstrap5' , 'voux' ];
2019-03-29 19:13:32 -05:00
$handle = opendir ( $this -> e107 -> e107_dirs [ 'THEMES_DIRECTORY' ]);
$themelist = array ();
while ( $file = readdir ( $handle ))
{
2020-12-21 17:46:32 -08:00
if ( is_dir ( $this -> e107 -> e107_dirs [ 'THEMES_DIRECTORY' ] . $file ) && $file !== '_blank' )
2019-03-29 19:13:32 -05:00
{
if ( is_readable ( " ./ { $this -> e107 -> e107_dirs [ 'THEMES_DIRECTORY' ] } { $file } /theme.xml " ))
{
$themelist [] = $file ;
}
}
}
closedir ( $handle );
return $themelist ;
}
/**
* get_theme_xml - check theme . xml file of specific theme
*
* @ param string $theme_folder
* @ return array | bool $xmlArray OR boolean FALSE if result is no array
*/
function get_theme_xml ( $theme_folder )
{
if ( ! defined ( " SITEURL " ))
{
define ( " SITEURL " , " " );
}
$path = $this -> e107 -> e107_dirs [ 'THEMES_DIRECTORY' ] . $theme_folder . " /theme.xml " ;
if ( ! is_readable ( $path ))
{
return FALSE ;
}
// require_once($this->e107->e107_dirs['HANDLERS_DIRECTORY']."theme_handler.php");
// $tm = new themeHandler;
$xmlArray = e107 :: getTheme ( $theme_folder , $this -> debug ) -> get ();
return ( is_array ( $xmlArray )) ? $xmlArray : false ;
}
/**
* finish_form - pass data along forms
*
2019-06-03 15:27:36 -07:00
* @ param bool $force_stage [ optional ]
* @ return null
2019-03-29 19:13:32 -05:00
*/
function finish_form ( $force_stage = false )
{
global $e_forms ;
if ( $this -> previous_steps )
{
$e_forms -> add_hidden_data ( " previous_steps " , base64_encode ( serialize ( $this -> previous_steps )));
}
$e_forms -> add_hidden_data ( " stage " , ( $force_stage ? $force_stage : ( $this -> stage + 1 )));
2019-06-03 15:27:36 -07:00
return null ;
2019-03-29 19:13:32 -05:00
}
/**
* check_writable_perms - check writable permissions
*
* @ param string $list [ default 'must_write' ]
* @ return array $bad_files
*/
function check_writable_perms ( $list = 'must_write' )
{
$bad_files = array ();
$system_dirs = $this -> e107 -> e107_dirs ;
$system_dirs [ 'MEDIA_DIRECTORY' ] = str_replace ( " [hash]/ " , " " , $system_dirs [ 'MEDIA_DIRECTORY' ]);
$system_dirs [ 'SYSTEM_DIRECTORY' ] = str_replace ( " [hash]/ " , " " , $system_dirs [ 'SYSTEM_DIRECTORY' ]);
$data [ 'must_write' ] = 'e107_config.php|{$MEDIA_DIRECTORY}|{$SYSTEM_DIRECTORY}' ; // all-sub folders are created on-the-fly
$data [ 'can_write' ] = '{$PLUGINS_DIRECTORY}|{$THEMES_DIRECTORY}|{$WEB_DIRECTORY}cache|{$WEB_DIRECTORY}lib' ;
2020-12-21 17:46:32 -08:00
if ( ! isset ( $data [ $list ]))
{
return $bad_files ;
}
2019-06-03 15:27:36 -07:00
$find = array ();
$replace = array ();
2019-03-29 19:13:32 -05:00
foreach ( $system_dirs as $dir_name => $value )
{
$find [] = " { \$ { $dir_name } } " ;
$replace [] = " ./ $value " ;
}
$data [ $list ] = str_replace ( $find , $replace , $data [ $list ]);
$files = explode ( " | " , trim ( $data [ $list ]));
foreach ( $files as $file )
{
if ( ! is_writable ( $file ))
{
$bad_files [] = str_replace ( " ./ " , " " , $file );
}
}
return $bad_files ;
}
/**
* Create Core MySQL tables
*
* @ return string | FALSE error code or FALSE if no errors are detected
*/
public function create_tables ()
{
// $link = mysql_connect($this->previous_steps['mysql']['server'], $this->previous_steps['mysql']['user'], $this->previous_steps['mysql']['password']);
2019-06-03 15:27:36 -07:00
$sql = e107 :: getDb ();
installLog :: add ( " Starting Table Creation " );
$link = $sql -> connect ( $this -> previous_steps [ 'mysql' ][ 'server' ], $this -> previous_steps [ 'mysql' ][ 'user' ], $this -> previous_steps [ 'mysql' ][ 'password' ]);
2019-03-29 19:13:32 -05:00
if ( ! $link )
{
2019-06-03 15:27:36 -07:00
return nl2br ( LANINS_084 . " \n \n <b> " . LANINS_083 . " \n </b><i> " . $sql -> getLastErrorText () . " </i> " );
2019-03-29 19:13:32 -05:00
}
2019-06-03 15:27:36 -07:00
installLog :: add ( " DB Connection made " );
2020-12-08 07:29:17 -08:00
// $dbLink = $link; // Needed for mysql_close() to work round bug in PHP 5.3
2019-03-29 19:13:32 -05:00
// $db_selected = mysql_select_db($this->previous_steps['mysql']['db'], $link);
2019-06-03 15:27:36 -07:00
$db_selected = $sql -> database ( $this -> previous_steps [ 'mysql' ][ 'db' ], $this -> previous_steps [ 'mysql' ][ 'prefix' ]);
2019-03-29 19:13:32 -05:00
if ( ! $db_selected )
{
return nl2br ( LANINS_085 . " ' { $this -> previous_steps [ 'mysql' ][ 'db' ] } ' \n \n <b> " . LANINS_083 . " \n </b><i> " . e107 :: getDb () -> getLastErrorText () . " </i> " );
}
2019-06-03 15:27:36 -07:00
installLog :: add ( " DB Database Selected " );
2019-03-29 19:13:32 -05:00
$filename = " { $this -> e107 -> e107_dirs [ 'CORE_DIRECTORY' ] } sql/core_sql.php " ;
$fd = fopen ( $filename , " r " );
$sql_data = fread ( $fd , filesize ( $filename ));
$sql_data = preg_replace ( " # \ / \ *.*? \ * \ /#mis " , '' , $sql_data ); // Strip comments
fclose ( $fd );
if ( ! $sql_data )
{
return nl2br ( LANINS_060 ) . " <br /><br /> " ;
}
preg_match_all ( " /create(.*?)(?:myisam|innodb);/si " , $sql_data , $result );
// Force UTF-8 again
Convert and run e107 using the MySQL/MariaDB utf8mb4 character set and
InnoDB storage engine
Components affected:
* `db_verify` now checks and corrects the table storage engine
* `db_verify` now checks and corrects the table default character set
* Note: Field character sets can still be overridden
* Note: When correcting, the entire table is converted to the target
charset.
* The alt_auth plugin now connects via PDO using the e107 default
charset, utf8mb4
* `e_db_pdo` now sets the charset to utf8mb4. This is currently not
customizable because it was previously not customizable.
* `install.php` now generates an `e107_config.php` file with
`$mySQLcharset = 'utf8mb4';`, though this option is not actually used.
* `install.php` now removes plugin tables before installing plugins.
* `e_db_mysql` now only accepts the `utf8mb4` charset. Previously, it
only accepted the `utf8` charset.
* `e_db_mysql` now configures `mysqli_real_escape_string` to match the
new default charset, `utf8mb4`.
* Plugin installations now use the preferred MySQL table storage engines
and charsets.
The preferred MySQL table storage engines are now mapped like so:
* If `ENGINE=MyISAM` is specified, the actual storage engine set will be
the first available of: InnoDB, Aria, Maria, MyISAM
* If `ENGINE=Aria` is specified, the actual storage engine set will be
the first available of: Aria, Maria, MyISAM
* If `ENGINE=InnoDB` is specified, the actual storage engine set will be
the first available of: InnoDB, XtraDB
* If `ENGINE=XtraDB` is specified, the actual storage engine set will be
the first available of: XtraDB, InnoDB
The preferred MySQL character set is now aliased like so:
* `utf8` => `utf8mb4`
* `utf8mb3` => `utf8mb3`
* `utf8mb4` => `utf8mb4`
Fixes: #4501
2021-05-22 00:46:35 -05:00
$this -> dbqry ( 'SET NAMES `utf8mb4`' );
2019-03-29 19:13:32 -05:00
$srch = array ( " CREATE TABLE " , " ( " );
$repl = array ( " DROP TABLE IF EXISTS " , " " );
foreach ( $result [ 0 ] as $sql_table )
{
$sql_table = preg_replace ( " /create table \ s/si " , " CREATE TABLE { $this -> previous_steps [ 'mysql' ][ 'prefix' ] } " , $sql_table );
// Drop existing tables before creating.
$tmp = explode ( " \n " , $sql_table );
$drop_table = str_replace ( $srch , $repl , $tmp [ 0 ]);
$this -> dbqry ( $drop_table );
2019-06-03 15:27:36 -07:00
if ( ! $this -> dbqry ( $sql_table ))
2019-03-29 19:13:32 -05:00
{
2019-06-03 15:27:36 -07:00
installLog :: add ( " Query Failed in " . $filename . " : " . $sql_table , 'error' );
2019-03-29 19:13:32 -05:00
return nl2br ( LANINS_061 . " \n \n <b> " . LANINS_083 . " \n </b><i> " . e107 :: getDb () -> getLastErrorText () . " </i> " );
}
}
return FALSE ;
}
function write_config ( $data )
{
$e107_config = 'e107_config.php' ;
$fp = @ fopen ( $e107_config , 'w' );
if ( !@ fwrite ( $fp , $data ))
{
@ fclose ( $fp );
return nl2br ( LANINS_070 );
}
@ fclose ( $fp );
@ chmod ( $e107_config , 0644 ); // correct permissions.
return false ;
}
2019-06-03 15:27:36 -07:00
private function setDb ()
{
$sqlInfo = array (
'mySQLserver' => $this -> previous_steps [ 'mysql' ][ 'server' ],
'mySQLuser' => $this -> previous_steps [ 'mysql' ][ 'user' ],
'mySQLpassword' => $this -> previous_steps [ 'mysql' ][ 'password' ],
'mySQLdefaultdb' => $this -> previous_steps [ 'mysql' ][ 'db' ],
'mySQLprefix' => $this -> previous_steps [ 'mysql' ][ 'prefix' ]
);
$this -> e107 -> initInstallSql ( $sqlInfo );
}
private function dbqry ( $qry )
2019-03-29 19:13:32 -05:00
{
$sql = e107 :: getDb ();
2019-06-03 15:27:36 -07:00
$return = $sql -> db_Query ( $qry );
if ( $return === false )
{
installLog :: add ( 'Query Failed: ' . $qry , 'error' );
}
return $return ;
2019-03-29 19:13:32 -05:00
/* if ( $error = $sql -> getLastErrorNumber ())
{
$errorInfo = 'Query Error [#' . $error . ']: ' . $sql -> getLastErrorText () . " \n Query: { $qry } " ;
$this -> debug_db_info [ 'db_error_log' ][] = $errorInfo ;
return false ;
}
return true ; */
}
}
class e_forms
{
2020-12-08 07:29:17 -08:00
public $form ;
private $opened ;
2019-03-29 19:13:32 -05:00
function start_form ( $id , $action , $method = " post " )
{
$this -> form = " \n <form method=' { $method } ' id=' { $id } ' action=' { $action } '> \n " ;
$this -> opened = true ;
}
function add_select_item ( $id , $labels , $selected )
{
$this -> form .= "
< select class = 'form-control input-large' name = '{$id}' id = '{$id}' > \n " ;
foreach ( $labels as $label )
{
$this -> form .= " <option value=' " . $label . " ' " . ( $label == $selected ? " selected='selected' " : " " ) . " > { $label } </option> \n " ;
}
$this -> form .= " </select> \n " ;
}
function add_hidden_data ( $id , $data )
{
$this -> form .= " <input type='hidden' name=' { $id } ' value=' { $data } ' /> \n " ;
}
function add_plain_html ( $html_data )
{
$this -> form .= $html_data ;
}
function return_form ()
{
if ( $this -> opened == true )
{
$this -> form .= " </form> \n " ;
}
$this -> opened = false ;
return $this -> form ;
}
}
function create_tables_unattended ()
{
//If username or password not specified, exit
if ( ! isset ( $_GET [ 'username' ]) || ! isset ( $_GET [ 'password' ]))
{
return false ;
}
$mySQLserver = null ;
2019-06-03 15:27:36 -07:00
$mySQLuser = null ;
$mySQLpassword = null ;
$mySQLdefaultdb = null ;
$mySQLprefix = null ;
2019-03-29 19:13:32 -05:00
if ( file_exists ( 'e107_config.php' ))
{
@ include ( 'e107_config.php' );
} else {
return false ;
}
//If mysql info not set, config file is not created properly
if ( ! isset ( $mySQLuser ) || ! isset ( $mySQLpassword ) || ! isset ( $mySQLdefaultdb ) || ! isset ( $mySQLprefix ))
{
return false ;
}
// If specified username and password does not match the ones in config, exit
if ( $_GET [ 'username' ] !== $mySQLuser || $_GET [ 'password' ] !== $mySQLpassword )
{
return false ;
}
$einstall = new e_install ();
$einstall -> previous_steps [ 'mysql' ][ 'server' ] = $mySQLserver ;
$einstall -> previous_steps [ 'mysql' ][ 'user' ] = $mySQLuser ;
$einstall -> previous_steps [ 'mysql' ][ 'password' ] = $mySQLpassword ;
$einstall -> previous_steps [ 'mysql' ][ 'db' ] = $mySQLdefaultdb ;
$einstall -> previous_steps [ 'mysql' ][ 'prefix' ] = $mySQLprefix ;
$einstall -> previous_steps [ 'language' ] = ( isset ( $_GET [ 'language' ]) ? $_GET [ 'language' ] : 'English' );
$einstall -> previous_steps [ 'admin' ][ 'display' ] = ( isset ( $_GET [ 'admin_display' ]) ? $_GET [ 'admin_display' ] : 'admin' );
$einstall -> previous_steps [ 'admin' ][ 'user' ] = ( isset ( $_GET [ 'admin_user' ]) ? $_GET [ 'admin_user' ] : 'admin' );
$einstall -> previous_steps [ 'admin' ][ 'password' ] = ( isset ( $_GET [ 'admin_password' ]) ? $_GET [ 'admin_password' ] : 'admin_password' );
$einstall -> previous_steps [ 'admin' ][ 'email' ] = ( isset ( $_GET [ 'admin_email' ]) ? $_GET [ 'admin_email' ] : 'admin_email@xxx.com' );
2020-12-12 11:32:23 -08:00
$einstall -> previous_steps [ 'generate_content' ] = isset ( $_GET [ 'gen' ]) ? ( int ) $_GET [ 'gen' ] : 1 ;
$einstall -> previous_steps [ 'install_plugins' ] = isset ( $_GET [ 'plugins' ]) ? ( int ) $_GET [ 'plugins' ] : 1 ;
2019-03-29 19:13:32 -05:00
$einstall -> previous_steps [ 'prefs' ][ 'sitename' ] = isset ( $_GET [ 'sitename' ]) ? urldecode ( $_GET [ 'sitename' ]) : LANINS_113 ;
$einstall -> previous_steps [ 'prefs' ][ 'sitetheme' ] = isset ( $_GET [ 'theme' ]) ? urldecode ( $_GET [ 'theme' ]) : 'bootstrap3' ;
//@include_once("./{$HANDLERS_DIRECTORY}e107_class.php");
//$e107_paths = compact('ADMIN_DIRECTORY', 'FILES_DIRECTORY', 'IMAGES_DIRECTORY', 'THEMES_DIRECTORY', 'PLUGINS_DIRECTORY', 'HANDLERS_DIRECTORY', 'LANGUAGES_DIRECTORY', 'HELP_DIRECTORY', 'CACHE_DIRECTORY', 'DOWNLOADS_DIRECTORY', 'UPLOADS_DIRECTORY');
//$e107 = e107::getInstance();
//$e107->init($e107_paths, realpath(dirname(__FILE__)));
//$einstall->e107 = &$e107;
//FIXME - does not appear to work for import_configuration. ie. tables are blank except for user table.
$einstall -> create_tables ();
$einstall -> import_configuration ();
return true ;
}
class SimpleTemplate
{
2020-12-08 07:29:17 -08:00
private $Tags = array ();
private $open_tag = " { " ;
private $close_tag = " } " ;
2019-03-29 19:13:32 -05:00
function __construct ()
{
define ( " TEMPLATE_TYPE_FILE " , 0 );
define ( " TEMPLATE_TYPE_DATA " , 1 );
}
function SetTag ( $TagName , $Data )
{
$this -> Tags [ $TagName ] = array ( 'Tag' => $TagName ,
'Data' => $Data
);
}
2021-01-25 09:14:45 -08:00
/*
2019-03-29 19:13:32 -05:00
function RemoveTag ( $TagName )
{
unset ( $this -> Tags [ $TagName ]);
}
function ClearTags ()
{
$this -> Tags = array ();
2021-01-25 09:14:45 -08:00
} */
2019-03-29 19:13:32 -05:00
function ParseTemplate ( $Template , $template_type = TEMPLATE_TYPE_FILE )
{
if ( $template_type == TEMPLATE_TYPE_DATA )
{
$TemplateData = $Template ;
}
else
{
$TemplateData = file_get_contents ( $Template );
}
foreach ( $this -> Tags as $Tag )
{
$TemplateData = str_replace ( $this -> open_tag . $Tag [ 'Tag' ] . $this -> close_tag , $Tag [ 'Data' ], $TemplateData );
}
return $TemplateData ;
}
}
function template_data ()
{
2020-12-08 07:29:17 -08:00
return ' <! DOCTYPE html >
2019-03-29 19:13:32 -05:00
< html lang = " en " >
< head >
< meta charset = " utf-8 " >
< title > { installation_heading } :: { stage_pre }{ stage_num } - { stage_title } </ title >
< meta name = " viewport " content = " width=device-width, initial-scale=1.0 " >
< link href = " '.e_THEME.'bootstrap3/css/bootstrap-dark.min.css " rel = " stylesheet " >
< link href = " '.e_THEME.'bootstrap3/admin_style.css " rel = " stylesheet " >
< link rel = " icon " href = " favicon.ico " type = " image/x-icon " />
2022-03-31 08:24:34 -07:00
< style >
2019-03-29 19:13:32 -05:00
body { padding - top : 40 px ; padding - bottom : 40 px ; background - color : #181818; }
. container - narrow { margin : 0 auto ; max - width : 800 px ; }
. container - narrow > hr { margin : 30 px 0 ; }
. nav { margin - top : 35 px ; }
. buttons - bar { margin : 20 px 30 px 10 px 0 px }
. tooltip - inner { font - size : 110 % ; }
div . masthead { margin - bottom : 30 px }
h4 { margin - left : 10 px ; margin - bottom : 20 px ; color : #181818; }
#version { position:relative; left:50px; top:-20px; }
. well { border - radius : 12 px }
. theme - cell { margin - bottom : 15 px ; padding - left : 0 ; padding - right : 5 px }
. theme - cell . thumbnail { margin - bottom : 5 px ; height : 170 px ; width : auto }
. theme - cell h5 { padding - left : 8 px ; margin - top : 0 ; font - weight : bold }
label . theme - selection > input { visibility : hidden ; position : absolute ; }
label . theme - selection > input + div { cursor : pointer ; border : 2 px solid transparent ; border - radius : 6 px }
label . theme - selection > input : checked + div { border : 2 px solid #337ab7; }
label . theme - selection > input + div span { visibility : hidden ; float : right ; margin - right : 10 px ; color : #337ab7 }
label . theme - selection > input : checked + div span { visibility : initial ; }
div . tooltip { width : 320 px }
</ style >
<!-- HTML5 shim , for IE6 - 8 support of HTML5 elements -->
<!-- [ if lt IE 9 ] >
2023-10-29 08:15:29 -07:00
< script src = " https://cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.js " ></ script >
2019-03-29 19:13:32 -05:00
<! [ endif ] -->
</ head >
< body >
< div class = " container-narrow " >
< div class = " masthead " >
< ul class = " nav nav-pills pull-right " >
< li style = " width:200px;text-align:center " >< a href = " # " > '.LANINS_134.' & #58 {stage_pre} {stage_num} '.LANINS_135.' 8</a>
< div class = " progress progress- { bartype} " >
< div class = " progress-bar bar " style = " width: { percent}% " ></ div >
</ div >
</ li >
</ ul >
< h3 class = " muted " >
< img src = " '.e_IMAGE.'admin_images/credits_logo.png " alt = " e107 " />
</ h3 >
</ div >
< div class = " panel panel-default " >
< div class = " panel-heading " >
< h3 class = " panel-title " > { stage_title } </ h3 >
</ div >
< div class = " panel-body " >
{ stage_content }
</ div >
</ div >
< div class = " footer " >
< p class = " pull-left " >& copy ; e107 Inc . '.date("Y").' </ p >
< p class = " pull-right " > '.LAN_VERSION.' & #58 '.e_VERSION.'</p>
</ div >
< div > { debug_info } </ div >
</ div > <!-- / container -->
<!-- The javascript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
2022-03-31 08:24:34 -07:00
< script src = " https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js " ></ script >
< script src = " https://netdna.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js " ></ script >
2019-03-29 19:13:32 -05:00
2022-03-31 08:24:34 -07:00
< script >
2019-03-29 19:13:32 -05:00
$ ( document ) . ready ( function ()
{
2022-04-07 07:15:30 -07:00
$ ( " .e-tip,input,textarea,select,label " ) . each ( function ( c ) {
2019-03-29 19:13:32 -05:00
var t = $ ( this ) . nextAll ( " .field-help " );
t . hide ();
$ ( this ) . tooltip ({
title : function () {
var tip = t . html ();
return tip ;
},
fade : true ,
html : true ,
placement : " right " ,
delay : { show : 200 , hide : 200 }
});
});
// disable validation for back-button.
$ ( " .no-validate " ) . click ( function () {
$ ( " form " ) . attr ( " novalidate " , true );
});
});
</ script >
</ body >
</ html >
' ;
2020-12-08 07:29:17 -08:00
2019-03-29 19:13:32 -05:00
}
/**
2019-06-03 15:27:36 -07:00
* Render a Fatal error and halt installation .
*
* @ param $error
*/
2019-03-29 19:13:32 -05:00
function die_fatal_error ( $error )
{
2020-12-26 08:02:34 -08:00
2019-03-29 19:13:32 -05:00
define ( " e_IMAGE " , " e107_images/ " );
define ( " e_JS " , " e107_web/js/ " );
define ( " e_THEME " , " e107_themes/ " );
define ( " e_LANGUAGEDIR " , " e107_languages/ " );
include ( e_LANGUAGEDIR . " English/English.php " );
include ( e_LANGUAGEDIR . " English/lan_installer.php " );
$var = array ();
$var [ " installation_heading " ] = LANINS_001 ;
$var [ " stage_pre " ] = LANINS_002 ;
$var [ " stage_num " ] = LANINS_003 ;
$var [ " stage_title " ] = LAN_ERROR ;
$var [ " percent " ] = 10 ;
$var [ " bartype " ] = 'danger' ;
$var [ 'stage_content' ] = " <div class='alert alert-error alert-block'> " . $error . " </div> " ;
$var [ 'debug_info' ] = '' ;
$template = template_data ();
foreach ( $var as $k => $val )
{
$template = str_replace ( " { " . $k . " } " , $val , $template );
}
echo $template ;
exit ;
}