PHP Класс ElggInstaller, Elgg

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.
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$autoLogin
$isAction
$status
$steps

Открытые методы

Метод Описание
__construct ( ) Constructor bootstraps the Elgg engine
batchInstall ( array $params, boolean $createHtaccess = FALSE ) : void A batch install of Elgg
run ( string $step ) : void Dispatches a request to one of the step controllers
setAutoLogin ( boolean $flag ) : void Set the auto login flag

Защищенные методы

Метод Описание
admin ( array $submissionVars ) : void Admin account controller
bootstrapConfig ( ) : void Set up configuration variables
bootstrapEngine ( ) : void Load the essential libraries of the engine
checkDatabaseSettings ( string $user, string $password, string $dbname, string $host ) : boolean Confirm the settings for the database
checkInstallCompletion ( string $step ) : void 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.
checkPHP ( &$report ) : void Check version of PHP, extensions, and variables
checkPhpDirectives ( &$phpReport ) : void Check PHP parameters
checkPhpExtensions ( &$phpReport ) : void Check the server's PHP extensions
checkRewriteRules ( &$report ) : void Confirm that the rewrite rules are firing
checkSettingsFile ( &$report = [] ) : boolean Check that the settings file exists
complete ( ) : void Controller for last step
connectToDatabase ( ) : boolean Bootstrap database connection before entire engine is available
continueToNextStep ( string $currentStep ) : void Forwards the browser to the next step
countNumConditions ( array $report, string $condition ) : integer Count the number of failures in the requirements report
createAdminAccount ( array $submissionVars, boolean $login = FALSE ) : boolean Create a user account for the admin
createDataDirectory ( &$submissionVars, array $formVars ) : boolean Create the data directory if requested
createSettingsFile ( array $params ) : boolean Writes the settings file to the engine directory
database ( array $submissionVars ) : void Database set up controller
enablePlugins ( ) : void Enable a set of default plugins
finishBootstraping ( string $step ) : void Load remaining engine libraries and complete bootstrapping
getBaseUrl ( ) : string Get the best guess at the base URL
getNextStep ( string $currentStep ) : string Get the next step as a string
getNextStepUrl ( string $currentStep ) : string Get the URL of the next step
getPostVariables ( ) : array Return an associative array of post variables (could be selective based on expected variables)
getSteps ( ) : array Get an array of steps
installDatabase ( ) : boolean Create the database tables
isInstallDirWritable ( &$report ) : boolean Indicates whether the webserver can add settings.php on its own or not.
loadSettingsFile ( ) : void Load settings.php
makeFormSticky ( array $formVars, array $submissionVars ) : array If form is reshown, remember previously submitted variables
processRewriteTest ( ) : void Check if the request is coming from the URL rewrite test on the requirements page.
render ( string $step, array $vars = [] ) : void Renders the data passed by a controller
requirements ( array $vars ) : void Requirements controller
resumeInstall ( string $step ) : string 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.
saveSiteSettings ( array $submissionVars ) : boolean Initialize the site including site entity, plugins, and configuration
setInstallStatus ( ) : void Check the different install steps for completion
setSubtypeClasses ( ) : void Register classes for core objects
settings ( array $submissionVars ) : void Site settings controller
validateAdminVars ( array $submissionVars, array $formVars ) : boolean Validate account form variables
validateDatabaseVars ( array $submissionVars, array $formVars ) : boolean Validate the variables for the database step
validateSettingsVars ( array $submissionVars, array $formVars ) : boolean Validate the site settings form variables
welcome ( array $vars ) : void Welcome controller

Приватные методы

Метод Описание
getSettingsPath ( ) : string Returns the path to the root settings.php file.
isHttps ( ) : boolean

Описание методов

__construct() публичный Метод

Constructor bootstraps the Elgg engine
public __construct ( )

admin() защищенный Метод

Creates an admin user account
protected admin ( array $submissionVars ) : void
$submissionVars array Submitted vars
Результат void

batchInstall() публичный Метод

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. If the settings.php file exists, it will use that rather than the parameters passed to this function.
public batchInstall ( array $params, boolean $createHtaccess = FALSE ) : void
$params array Array of key value pairs
$createHtaccess boolean Should .htaccess be created
Результат void

bootstrapConfig() защищенный Метод

Set up configuration variables
protected bootstrapConfig ( ) : void
Результат void

bootstrapEngine() защищенный Метод

Load the essential libraries of the engine
protected bootstrapEngine ( ) : void
Результат void

checkDatabaseSettings() защищенный Метод

Confirm the settings for the database
protected checkDatabaseSettings ( string $user, string $password, string $dbname, string $host ) : boolean
$user string Username
$password string Password
$dbname string Database name
$host string Host
Результат boolean

checkInstallCompletion() защищенный Метод

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.
protected checkInstallCompletion ( string $step ) : void
$step string Installation step to check against
Результат void

checkPHP() защищенный Метод

Check version of PHP, extensions, and variables
protected checkPHP ( &$report ) : void
Результат void

checkPhpDirectives() защищенный Метод

Check PHP parameters
protected checkPhpDirectives ( &$phpReport ) : void
Результат void

checkPhpExtensions() защищенный Метод

Check the server's PHP extensions
protected checkPhpExtensions ( &$phpReport ) : void
Результат void

checkRewriteRules() защищенный Метод

Confirm that the rewrite rules are firing
protected checkRewriteRules ( &$report ) : void
Результат void

checkSettingsFile() защищенный Метод

Check that the settings file exists
protected checkSettingsFile ( &$report = [] ) : boolean
Результат boolean

complete() защищенный Метод

Controller for last step
protected complete ( ) : void
Результат void

connectToDatabase() защищенный Метод

Bootstrap database connection before entire engine is available
protected connectToDatabase ( ) : boolean
Результат boolean

continueToNextStep() защищенный Метод

Forwards the browser to the next step
protected continueToNextStep ( string $currentStep ) : void
$currentStep string Current installation step
Результат void

countNumConditions() защищенный Метод

Count the number of failures in the requirements report
protected countNumConditions ( array $report, string $condition ) : integer
$report array The requirements report array
$condition string 'failure' or 'warning'
Результат integer

createAdminAccount() защищенный Метод

Create a user account for the admin
protected createAdminAccount ( array $submissionVars, boolean $login = FALSE ) : boolean
$submissionVars array Submitted vars
$login boolean Login in the admin user?
Результат boolean

createDataDirectory() защищенный Метод

Create the data directory if requested
protected createDataDirectory ( &$submissionVars, array $formVars ) : boolean
$formVars array Variables in the form
Результат boolean

createSettingsFile() защищенный Метод

Writes the settings file to the engine directory
protected createSettingsFile ( array $params ) : boolean
$params array Array of inputted params from the user
Результат boolean

database() защищенный Метод

Creates the settings.php file and creates the database tables
protected database ( array $submissionVars ) : void
$submissionVars array Submitted form variables
Результат void

enablePlugins() защищенный Метод

Enable a set of default plugins
protected enablePlugins ( ) : void
Результат void

finishBootstraping() защищенный Метод

Load remaining engine libraries and complete bootstrapping
protected finishBootstraping ( string $step ) : void
$step string Which step to boot strap for. Required because boot strapping is different until the DB is populated.
Результат void

getBaseUrl() защищенный Метод

Get the best guess at the base URL
protected getBaseUrl ( ) : string
Результат string

getNextStep() защищенный Метод

Get the next step as a string
protected getNextStep ( string $currentStep ) : string
$currentStep string Current installation step
Результат string

getNextStepUrl() защищенный Метод

Get the URL of the next step
protected getNextStepUrl ( string $currentStep ) : string
$currentStep string Current installation step
Результат string

getPostVariables() защищенный Метод

Does not filter as person installing the site should not be attempting XSS attacks. If filtering is added, it should not be done for passwords.
protected getPostVariables ( ) : array
Результат array

getSteps() защищенный Метод

Get an array of steps
protected getSteps ( ) : array
Результат array

installDatabase() защищенный Метод

Create the database tables
protected installDatabase ( ) : boolean
Результат boolean

isInstallDirWritable() защищенный Метод

Indicates whether the webserver can add settings.php on its own or not.
protected isInstallDirWritable ( &$report ) : boolean
Результат boolean

loadSettingsFile() защищенный Метод

Load settings.php
protected loadSettingsFile ( ) : void
Результат void

makeFormSticky() защищенный Метод

If form is reshown, remember previously submitted variables
protected makeFormSticky ( array $formVars, array $submissionVars ) : array
$formVars array Vars int he form
$submissionVars array Submitted vars
Результат array

processRewriteTest() защищенный Метод

Check if the request is coming from the URL rewrite test on the requirements page.
protected processRewriteTest ( ) : void
Результат void

render() защищенный Метод

Renders the data passed by a controller
protected render ( string $step, array $vars = [] ) : void
$step string The current step
$vars array Array of vars to pass to the view
Результат void

requirements() защищенный Метод

Checks version of php, libraries, permissions, and rewrite rules
protected requirements ( array $vars ) : void
$vars array Vars
Результат void

resumeInstall() защищенный Метод

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.
protected resumeInstall ( string $step ) : string
$step string Installation step to resume from
Результат string

run() публичный Метод

Dispatches a request to one of the step controllers
public run ( string $step ) : void
$step string The installation step to run
Результат void

saveSiteSettings() защищенный Метод

Initialize the site including site entity, plugins, and configuration
protected saveSiteSettings ( array $submissionVars ) : boolean
$submissionVars array Submitted vars
Результат boolean

setAutoLogin() публичный Метод

Set the auto login flag
public setAutoLogin ( boolean $flag ) : void
$flag boolean Auto login
Результат void

setInstallStatus() защищенный Метод

Check the different install steps for completion
protected setInstallStatus ( ) : void
Результат void

setSubtypeClasses() защищенный Метод

Register classes for core objects
protected setSubtypeClasses ( ) : void
Результат void

settings() защищенный Метод

Sets the site name, URL, data directory, etc.
protected settings ( array $submissionVars ) : void
$submissionVars array Submitted vars
Результат void

validateAdminVars() защищенный Метод

Validate account form variables
protected validateAdminVars ( array $submissionVars, array $formVars ) : boolean
$submissionVars array Submitted vars
$formVars array Form vars
Результат boolean

validateDatabaseVars() защищенный Метод

Validate the variables for the database step
protected validateDatabaseVars ( array $submissionVars, array $formVars ) : boolean
$submissionVars array Submitted vars
$formVars array Vars in the form
Результат boolean

validateSettingsVars() защищенный Метод

Validate the site settings form variables
protected validateSettingsVars ( array $submissionVars, array $formVars ) : boolean
$submissionVars array Submitted vars
$formVars array Vars in the form
Результат boolean

welcome() защищенный Метод

Welcome controller
protected welcome ( array $vars ) : void
$vars array Not used
Результат void

Описание свойств

$autoLogin защищенное свойство

protected $autoLogin

$isAction защищенное свойство

protected $isAction

$status защищенное свойство

protected $status

$steps защищенное свойство

protected $steps