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

Elgg Installer. More...

Public Member Functions

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

Protected Member Functions

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

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 35 of file ElggInstaller.php.

Member Function Documentation

ElggInstaller::batchInstall ( array  $params,
  $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 186 of file ElggInstaller.php.

ElggInstaller::checkDatabaseSettings (   $user,
  $password,
  $dbname,
  $host 
)
protected

Confirm the settings for the database.

Parameters
string$userUsername
string$passwordPassword
string$dbnameDatabase name
string$hostHost
Returns
bool

Definition at line 1216 of file ElggInstaller.php.

ElggInstaller::checkInstallCompletion (   $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 787 of file ElggInstaller.php.

ElggInstaller::checkPHP ( $report)
protected

Check version of PHP, extensions, and variables.

Parameters
array$reportThe requirements report array
Returns
void

Definition at line 963 of file ElggInstaller.php.

ElggInstaller::checkPhpDirectives ( $phpReport)
protected

Check PHP parameters.

Parameters
array$phpReportThe PHP requirements report array
Returns
void

Definition at line 1032 of file ElggInstaller.php.

ElggInstaller::checkPhpExtensions ( $phpReport)
protected

Check the server's PHP extensions.

Parameters
array$phpReportThe PHP requirements report array
Returns
void

Definition at line 995 of file ElggInstaller.php.

ElggInstaller::checkRewriteRules ( $report)
protected

Confirm that the rewrite rules are firing.

Parameters
array$reportThe requirements report array
Returns
void
Exceptions
InstallationException

Definition at line 1079 of file ElggInstaller.php.

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

Check that the settings file exists.

Parameters
array$reportThe requirements report array
Returns
bool

Definition at line 939 of file ElggInstaller.php.

ElggInstaller::connectToDatabase ( )
protected

Bootstrap database connection before entire engine is available.

Returns
bool
Exceptions
InstallationException

Definition at line 1309 of file ElggInstaller.php.

ElggInstaller::continueToNextStep (   $currentStep)
protected

Forwards the browser to the next step.

Parameters
string$currentStepCurrent installation step
Returns
Exceptions
InstallationException

Definition at line 665 of file ElggInstaller.php.

ElggInstaller::countNumConditions (   $report,
  $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 1098 of file ElggInstaller.php.

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

Create a user account for the admin.

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

Definition at line 1555 of file ElggInstaller.php.

ElggInstaller::createDataDirectory ( $submissionVars,
  $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 1347 of file ElggInstaller.php.

ElggInstaller::createSessionFromDatabase ( )
protected

Setup session.

Returns
void
Exceptions
InstallationException

Definition at line 1634 of file ElggInstaller.php.

ElggInstaller::createSessionFromFile ( )
protected

Setup session.

Returns
void
Exceptions
InstallationException

Definition at line 1621 of file ElggInstaller.php.

ElggInstaller::createSettingsFile (   $params)
protected

Writes the settings file to the engine directory.

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

Definition at line 1259 of file ElggInstaller.php.

ElggInstaller::determineInstallStatus ( )
protected

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

Returns
void
Exceptions
InstallationException

Definition at line 708 of file ElggInstaller.php.

ElggInstaller::finishBootstrapping (   $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
Exceptions
InstallationException

Definition at line 839 of file ElggInstaller.php.

ElggInstaller::getApp ( )
protected

Build the application needed by the installer.

Returns
Application
Exceptions
InstallationException

Definition at line 107 of file ElggInstaller.php.

ElggInstaller::getNextStep (   $currentStep)
protected

Get the next step as a string.

Parameters
string$currentStepCurrent installation step
Returns
string

Definition at line 678 of file ElggInstaller.php.

ElggInstaller::getNextStepUrl (   $currentStep)
protected

Get the URL of the next step.

Parameters
string$currentStepCurrent installation step
Returns
string
Exceptions
InstallationException

Definition at line 695 of file ElggInstaller.php.

ElggInstaller::getSteps ( )
protected

Step management.

Get an array of steps

Returns
array

Definition at line 653 of file ElggInstaller.php.

ElggInstaller::installDatabase ( )
protected

Create the database tables.

Returns
bool

Definition at line 1327 of file ElggInstaller.php.

ElggInstaller::isInstallDirWritable ( $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 916 of file ElggInstaller.php.

ElggInstaller::loadSettingsFile ( )
protected

Load settings.

Returns
void
Exceptions
InstallationException

Definition at line 872 of file ElggInstaller.php.

ElggInstaller::makeFormSticky (   $formVars,
  $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 899 of file ElggInstaller.php.

ElggInstaller::render (   $step,
  $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 290 of file ElggInstaller.php.

ElggInstaller::resumeInstall (   $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 804 of file ElggInstaller.php.

ElggInstaller::run ( )

Dispatches a request to one of the step controllers.

Returns
Exceptions
InstallationException

Definition at line 68 of file ElggInstaller.php.

ElggInstaller::runAdmin (   $submissionVars)
protected

Admin account controller.

Creates an admin user account

Parameters
array$submissionVarsSubmitted vars
Returns
Exceptions
InstallationException

Definition at line 551 of file ElggInstaller.php.

ElggInstaller::runComplete ( )
protected

Controller for last step.

Returns

Definition at line 626 of file ElggInstaller.php.

ElggInstaller::runDatabase (   $submissionVars)
protected

Database set up controller.

Creates the settings.php file and creates the database tables

Parameters
array$submissionVarsSubmitted form variables
Returns
Exceptions
ConfigurationException

Definition at line 384 of file ElggInstaller.php.

ElggInstaller::runRequirements (   $vars)
protected

Requirements controller.

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

Parameters
array$varsVars
Returns
Exceptions
InstallationException

Definition at line 334 of file ElggInstaller.php.

ElggInstaller::runSettings (   $submissionVars)
protected

Site settings controller.

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

Parameters
array$submissionVarsSubmitted vars
Returns

Definition at line 492 of file ElggInstaller.php.

ElggInstaller::runWelcome (   $vars)
protected

Step controllers.

Welcome controller

Parameters
array$varsNot used
Returns

Definition at line 320 of file ElggInstaller.php.

ElggInstaller::saveSiteSettings (   $submissionVars)
protected

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

Parameters
array$submissionVarsSubmitted vars
Returns
bool
Exceptions
InstallationException

Definition at line 1414 of file ElggInstaller.php.

ElggInstaller::setAutoLogin (   $flag)

Set the auto login flag.

Parameters
bool$flagAuto login
Returns
void

Definition at line 167 of file ElggInstaller.php.

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

Validate account form variables.

Parameters
array$submissionVarsSubmitted vars
array$formVarsForm vars
Returns
bool
Exceptions
InstallationException

Definition at line 1503 of file ElggInstaller.php.

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

Database support methods.

Validate the variables for the database step

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

Definition at line 1125 of file ElggInstaller.php.

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

Validate the site settings form variables.

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

Definition at line 1382 of file ElggInstaller.php.


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