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.
파일 보기 프로젝트 열기: elgg/elgg 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$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