Elgg  Version 6.1
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
ElggInstaller Class Reference

Elgg Installer. More...

Public Member Functions

 run ()
 Dispatches a request to one of the step controllers. More...
 
 batchInstall (array $params, bool $create_htaccess=false)
 A batch install of Elgg. More...
 

Public Attributes

const MARIADB_MINIMAL_VERSION = '10.6'
 
const MYSQL_MINIMAL_VERSION = '8.0'
 
const PHP_MINIMAL_VERSION = '8.1.0'
 

Protected Member Functions

 getApp ()
 Build the application needed by the installer. More...
 
 render (string $step, array $vars=[])
 Renders the data passed by a controller. More...
 
 runWelcome ()
 Step controllers. More...
 
 runRequirements (array $vars=[])
 Requirements controller. More...
 
 runDatabase (array $submissionVars=[])
 Database set up controller. More...
 
 runSettings (array $submissionVars=[])
 Site settings controller. More...
 
 runAdmin (array $submissionVars=[])
 Admin account controller. More...
 
 runComplete ()
 Controller for last step. More...
 
 getSteps ()
 Step management. More...
 
 getCurrentStep ()
 Returns current step. More...
 
 continueToNextStep (string $currentStep)
 Forwards the browser to the next step. More...
 
 getNextStep (string $currentStep)
 Get the next step as a string. More...
 
 getNextStepUrl (string $currentStep)
 Get the URL of the next step. More...
 
 determineInstallStatus ()
 Updates $this->has_completed according to the current installation. More...
 
 checkInstallCompletion (string $step)
 Security check to ensure the installer cannot be run after installation has finished. More...
 
 resumeInstall (string $step)
 Check if this is a case of a install being resumed and figure out where to continue from. More...
 
 finishBootstrapping (string $step)
 Bootstrapping. More...
 
 loadSettingsFile ()
 Load settings. More...
 
 makeFormSticky (array $formVars=[], array $submissionVars=[])
 Action handling methods. More...
 
 isInstallDirWritable (array &$report)
 Indicates whether the webserver can add settings.php on its own or not. More...
 
 checkSettingsFile (array &$report=[])
 Check that the settings file exists. More...
 
 checkPHP (array &$report)
 Check version of PHP, extensions, and variables. More...
 
 checkPhpExtensions (array &$phpReport)
 Check the server's PHP extensions. More...
 
 checkPhpDirectives (array &$phpReport)
 Check PHP parameters. More...
 
 checkRewriteRules (array &$report)
 Confirm that the rewrite rules are firing. More...
 
 countNumConditions (array $report, string $condition)
 Count the number of failures in the requirements report. More...
 
 validateDatabaseVars (array $submissionVars, array $formVars)
 Database support methods. More...
 
 checkDatabaseSettings (DbConfig $config)
 Confirm the settings for the database. More...
 
 createSettingsFile (array $params)
 Writes the settings file to the engine directory. More...
 
 connectToDatabase ()
 Bootstrap database connection before entire engine is available. More...
 
 installDatabase ()
 Create the database tables. More...
 
 createDataDirectory (array &$submissionVars, array $formVars)
 Site settings support methods. More...
 
 validateSettingsVars (array $submissionVars, array $formVars)
 Validate the site settings form variables. More...
 
 saveSiteSettings (array $submissionVars)
 Initialize the site including site entity, plugins, and configuration. More...
 
 validateAdminVars (array $submissionVars, array $formVars)
 Validate account form variables. More...
 
 createAdminAccount (array $submissionVars, bool $login=false)
 Create a user account for the admin. More...
 
 sanitizeInputValue ($input_value)
 Sanitize input to help prevent XSS. More...
 

Protected Attributes

array $steps
 
array $has_completed
 
array bool $is_action = false
 
 $app
 

Detailed Description

Elgg Installer.

Controller for installing Elgg. Supports both web-based on CLI installation.

This controller steps the user through the install process. The method for each step handles both the GET and POST requests. There is no XSS/CSRF protection on the POST processing since the installer is only run once by the administrator.

The installation process can be resumed by hitting the first page. The installer will try to figure out where to pick up again.

All the logic for the installation process is in this class, but it depends on the core libraries. To do this, we selectively load a subset of the core libraries for the first few steps and then load the entire engine once the database and site settings are configured. In addition, this controller does its own session handling until the database is setup.

There is an aborted attempt in the code at creating the data directory for users as a subdirectory of Elgg's root. The idea was to protect this directory through a .htaccess file. The problem is that a malicious user can upload a .htaccess of his own that overrides the protection for his user directory. The best solution is server level configuration that turns off AllowOverride for the data directory. See ticket #3453 for discussion on this.

Definition at line 41 of file ElggInstaller.php.

Member Function Documentation

ElggInstaller::batchInstall ( array  $params,
bool  $create_htaccess = false 
)

A batch install of Elgg.

All required parameters must be passed in as an associative array. See $requiredParams for a list of them. This creates the necessary files, loads the database, configures the site settings, and creates the admin account. If it fails, an exception is thrown. It does not check any of the requirements as the multiple step web installer does.

Parameters
array$paramsArray of key value pairs
bool$create_htaccessShould .htaccess be created
Returns
void
Exceptions
InstallationException

Definition at line 187 of file ElggInstaller.php.

ElggInstaller::checkDatabaseSettings ( DbConfig  $config)
protected

Confirm the settings for the database.

Parameters
DbConfig$configdatabase configuration
Returns
bool

Definition at line 1202 of file ElggInstaller.php.

ElggInstaller::checkInstallCompletion ( string  $step)
protected

Security check to ensure the installer cannot be run after installation has finished.

If this is detected, the viewer is sent to the front page.

Parameters
string$stepInstallation step to check against
Returns
|null

Definition at line 788 of file ElggInstaller.php.

ElggInstaller::checkPHP ( array &  $report)
protected

Check version of PHP, extensions, and variables.

Parameters
array$reportThe requirements report array
Returns
void

Definition at line 955 of file ElggInstaller.php.

ElggInstaller::checkPhpDirectives ( array &  $phpReport)
protected

Check PHP parameters.

Parameters
array$phpReportThe PHP requirements report array
Returns
void

Definition at line 1024 of file ElggInstaller.php.

ElggInstaller::checkPhpExtensions ( array &  $phpReport)
protected

Check the server's PHP extensions.

Parameters
array$phpReportThe PHP requirements report array
Returns
void

Definition at line 986 of file ElggInstaller.php.

ElggInstaller::checkRewriteRules ( array &  $report)
protected

Confirm that the rewrite rules are firing.

Parameters
array$reportThe requirements report array
Returns
void

Definition at line 1069 of file ElggInstaller.php.

ElggInstaller::checkSettingsFile ( array &  $report = [])
protected

Check that the settings file exists.

Parameters
array$reportThe requirements report array
Returns
bool

Definition at line 931 of file ElggInstaller.php.

ElggInstaller::connectToDatabase ( )
protected

Bootstrap database connection before entire engine is available.

Returns
bool

Definition at line 1293 of file ElggInstaller.php.

ElggInstaller::continueToNextStep ( string  $currentStep)
protected

Forwards the browser to the next step.

Parameters
string$currentStepCurrent installation step
Returns

Definition at line 676 of file ElggInstaller.php.

ElggInstaller::countNumConditions ( array  $report,
string  $condition 
)
protected

Count the number of failures in the requirements report.

Parameters
array$reportThe requirements report array
string$condition'failure' or 'warning'
Returns
int

Definition at line 1086 of file ElggInstaller.php.

ElggInstaller::createAdminAccount ( array  $submissionVars,
bool  $login = false 
)
protected

Create a user account for the admin.

Parameters
array$submissionVarsSubmitted vars
bool$loginLogin in the admin user?
Returns
bool

Definition at line 1532 of file ElggInstaller.php.

ElggInstaller::createDataDirectory ( array &  $submissionVars,
array  $formVars 
)
protected

Site settings support methods.

Create the data directory if requested

Parameters
array$submissionVarsSubmitted vars
array$formVarsVariables in the form
Returns
bool

Definition at line 1331 of file ElggInstaller.php.

ElggInstaller::createSettingsFile ( array  $params)
protected

Writes the settings file to the engine directory.

Parameters
array$paramsArray of inputted params from the user
Returns
bool

Definition at line 1240 of file ElggInstaller.php.

ElggInstaller::determineInstallStatus ( )
protected

Updates $this->has_completed according to the current installation.

Returns
void
Exceptions
InstallationException

Definition at line 715 of file ElggInstaller.php.

ElggInstaller::finishBootstrapping ( string  $step)
protected

Bootstrapping.

Load remaining engine libraries and complete bootstrapping

Parameters
string$stepWhich step to boot strap for. Required because boot strapping is different until the DB is populated.
Returns
void

Definition at line 843 of file ElggInstaller.php.

ElggInstaller::getApp ( )
protected

Build the application needed by the installer.

Returns
Application
Exceptions
InstallationException

Definition at line 110 of file ElggInstaller.php.

ElggInstaller::getCurrentStep ( )
protected

Returns current step.

Returns
string

Definition at line 663 of file ElggInstaller.php.

ElggInstaller::getNextStep ( string  $currentStep)
protected

Get the next step as a string.

Parameters
string$currentStepCurrent installation step
Returns
string

Definition at line 689 of file ElggInstaller.php.

ElggInstaller::getNextStepUrl ( string  $currentStep)
protected

Get the URL of the next step.

Parameters
string$currentStepCurrent installation step
Returns
string

Definition at line 702 of file ElggInstaller.php.

ElggInstaller::getSteps ( )
protected

Step management.

Get an array of steps

Returns
array

Definition at line 654 of file ElggInstaller.php.

ElggInstaller::installDatabase ( )
protected

Create the database tables.

Returns
bool

Definition at line 1311 of file ElggInstaller.php.

ElggInstaller::isInstallDirWritable ( array &  $report)
protected

Indicates whether the webserver can add settings.php on its own or not.

Parameters
array$reportThe requirements report object
Returns
bool

Definition at line 909 of file ElggInstaller.php.

ElggInstaller::loadSettingsFile ( )
protected

Load settings.

Returns
void
Exceptions
InstallationException

Definition at line 866 of file ElggInstaller.php.

ElggInstaller::makeFormSticky ( array  $formVars = [],
array  $submissionVars = [] 
)
protected

Action handling methods.

If form is reshown, remember previously submitted variables

Parameters
array$formVarsVars int he form
array$submissionVarsSubmitted vars
Returns
array

Definition at line 892 of file ElggInstaller.php.

ElggInstaller::render ( string  $step,
array  $vars = [] 
)
protected

Renders the data passed by a controller.

Parameters
string$stepThe current step
array$varsArray of vars to pass to the view
Returns

Definition at line 297 of file ElggInstaller.php.

ElggInstaller::resumeInstall ( string  $step)
protected

Check if this is a case of a install being resumed and figure out where to continue from.

Returns the best guess on the step.

Parameters
string$stepInstallation step to resume from
Returns
|null

Definition at line 809 of file ElggInstaller.php.

ElggInstaller::run ( )

Dispatches a request to one of the step controllers.

Returns

Definition at line 75 of file ElggInstaller.php.

ElggInstaller::runAdmin ( array  $submissionVars = [])
protected

Admin account controller.

Creates an admin user account

Parameters
array$submissionVarsSubmitted vars
Returns

Definition at line 551 of file ElggInstaller.php.

ElggInstaller::runComplete ( )
protected

Controller for last step.

Returns

Definition at line 627 of file ElggInstaller.php.

ElggInstaller::runDatabase ( array  $submissionVars = [])
protected

Database set up controller.

Creates the settings.php file and creates the database tables

Parameters
array$submissionVarsSubmitted form variables
Returns

Definition at line 378 of file ElggInstaller.php.

ElggInstaller::runRequirements ( array  $vars = [])
protected

Requirements controller.

Checks version of php, libraries, permissions, and rewrite rules

Parameters
array$varsVars
Returns

Definition at line 338 of file ElggInstaller.php.

ElggInstaller::runSettings ( array  $submissionVars = [])
protected

Site settings controller.

Sets the site name, URL, data directory, etc.

Parameters
array$submissionVarsSubmitted vars
Returns

Definition at line 493 of file ElggInstaller.php.

ElggInstaller::runWelcome ( )
protected

Step controllers.

Welcome controller

Returns

Definition at line 325 of file ElggInstaller.php.

ElggInstaller::sanitizeInputValue (   $input_value)
protected

Sanitize input to help prevent XSS.

Parameters
mixed$input_valuethe input to sanitize
Returns
mixed

Definition at line 1580 of file ElggInstaller.php.

ElggInstaller::saveSiteSettings ( array  $submissionVars)
protected

Initialize the site including site entity, plugins, and configuration.

Parameters
array$submissionVarsSubmitted vars
Returns
bool

Definition at line 1397 of file ElggInstaller.php.

ElggInstaller::validateAdminVars ( array  $submissionVars,
array  $formVars 
)
protected

Validate account form variables.

Parameters
array$submissionVarsSubmitted vars
array$formVarsForm vars
Returns
bool

Definition at line 1481 of file ElggInstaller.php.

ElggInstaller::validateDatabaseVars ( array  $submissionVars,
array  $formVars 
)
protected

Database support methods.

Validate the variables for the database step

Parameters
array$submissionVarsSubmitted vars
array$formVarsVars in the form
Returns
bool

Definition at line 1111 of file ElggInstaller.php.

ElggInstaller::validateSettingsVars ( array  $submissionVars,
array  $formVars 
)
protected

Validate the site settings form variables.

Parameters
array$submissionVarsSubmitted vars
array$formVarsVars in the form
Returns
bool

Definition at line 1366 of file ElggInstaller.php.

Member Data Documentation

ElggInstaller::$app
protected

Definition at line 68 of file ElggInstaller.php.

array ElggInstaller::$has_completed
protected
Initial value:
= [
'config' => false

Definition at line 56 of file ElggInstaller.php.

array bool ElggInstaller::$is_action = false
protected

Definition at line 63 of file ElggInstaller.php.

array ElggInstaller::$steps
protected
Initial value:
= [
'welcome',
'requirements',
'database',
'settings',
'admin',
'complete',
]

Definition at line 47 of file ElggInstaller.php.

const ElggInstaller::MARIADB_MINIMAL_VERSION = '10.6'

Definition at line 43 of file ElggInstaller.php.

const ElggInstaller::MYSQL_MINIMAL_VERSION = '8.0'

Definition at line 44 of file ElggInstaller.php.

const ElggInstaller::PHP_MINIMAL_VERSION = '8.1.0'

Definition at line 45 of file ElggInstaller.php.


The documentation for this class was generated from the following file: