54 private $view_path =
'';
74 $_ELGG =
new stdClass;
79 $this->isAction = isset($_SERVER[
'REQUEST_METHOD']) && $_SERVER[
'REQUEST_METHOD'] ===
'POST';
91 set_error_handler(
'_elgg_php_error_handler');
92 set_exception_handler(
'_elgg_php_exception_handler');
95 _elgg_services()->translator->registerTranslations(\
Elgg\Application::elggDir()->getPath(
"/install/languages/"), TRUE);
96 _elgg_services()->views->registerPluginViews(\
Elgg\Application::elggDir()->getPath(
"/"));
107 public function run($step) {
116 if (!in_array($step, $this->
getSteps())) {
117 $msg =
_elgg_services()->translator->translate(
'InstallationException:UnknownStep', array($step));
143 $this->autoLogin = (bool) $flag;
167 restore_error_handler();
168 restore_exception_handler();
171 'dbhost' =>
'localhost',
172 'dbprefix' =>
'elgg_',
179 $requiredParams = array(
191 foreach ($requiredParams as
$key) {
193 $msg =
_elgg_services()->translator->translate(
'install:error:requiredfield', array(
$key));
201 if ($createHtaccess) {
210 if (!$this->status[
'config']) {
220 if (!$this->status[
'database']) {
305 $report[
'database'] = array(array(
306 'severity' =>
'info',
307 'message' =>
_elgg_services()->translator->translate(
'install:check:database')
319 'num_failures' => $numFailures,
320 'num_warnings' => $numWarnings,
343 'dbpassword' => array(
344 'type' =>
'password',
355 'value' =>
'localhost',
364 'type' =>
'dropdown',
366 'options' => \DateTimeZone::listIdentifiers(),
373 $this->isAction = TRUE;
376 if ($this->isAction) {
407 $params = array(
'variables' => $formVars,);
432 'value' =>
'My New Community',
435 'siteemail' => array(
450 'siteaccess' => array(
464 if ($this->isAction) {
487 $this->
render(
'settings', array(
'variables' => $formVars));
499 protected function admin($submissionVars) {
501 'displayname' => array(
516 'password1' => array(
517 'type' =>
'password',
520 'pattern' =>
'.{6,}',
522 'password2' => array(
523 'type' =>
'password',
529 if ($this->isAction) {
549 $GLOBALS[
'_ELGG']->translations[
$lang][
'install:admin:help:password1'] =
551 $this->CONFIG->min_password_length);
555 $this->
render(
'admin', array(
'variables' => $formVars));
566 if ($this->autoLogin) {
567 $params[
'destination'] =
'admin';
569 $params[
'destination'] =
'index.php';
596 $this->isAction = FALSE;
608 $index = 1 + array_search($currentStep, $this->steps);
609 if (isset($this->steps[
$index])) {
610 return $this->steps[
$index];
625 return _elgg_services()->config->getSiteUrl() .
"install.php?step=$nextStep";
635 $settings_found =
false;
638 $settings_found =
true;
643 if (!$settings_found) {
649 $this->status[
'config'] = TRUE;
653 $this->CONFIG->dbuser,
654 $this->CONFIG->dbpass,
655 $this->CONFIG->dbname,
656 $this->CONFIG->dbhost
659 if ($dbSettingsPass == FALSE) {
663 if (!include_once(\
Elgg\Application::elggDir()->getPath(
"engine/lib/database.php"))) {
668 $query =
"show tables";
673 if (in_array(
"{$this->CONFIG->dbprefix}config",
$table)) {
674 $this->status[
'database'] = TRUE;
677 if ($this->status[
'database'] == FALSE) {
686 $query =
"SELECT COUNT(*) AS total FROM {$this->CONFIG->dbprefix}config";
689 $this->status[
'settings'] = TRUE;
695 $query =
"SELECT COUNT(*) AS total FROM {$this->CONFIG->dbprefix}users_entity";
698 $this->status[
'admin'] = TRUE;
713 if ($step !=
'complete') {
714 if (!in_array(FALSE, $this->status)) {
731 if ($step !==
'welcome') {
735 if ($this->status[
'database'] == FALSE) {
739 if ($this->status[
'settings'] == FALSE) {
740 forward(
"install.php?step=settings");
743 if ($this->status[
'admin'] == FALSE) {
744 forward(
"install.php?step=admin");
748 forward(
"install.php?step=complete");
761 $config = new \Elgg\Config($this->CONFIG);
762 $services = new \Elgg\Di\ServiceProvider($config);
763 (new \Elgg\Application($services))->loadCore();
777 $dbIndex = array_search(
'database', $this->
getSteps());
778 $settingsIndex = array_search(
'settings', $this->
getSteps());
779 $adminIndex = array_search(
'admin', $this->
getSteps());
780 $completeIndex = array_search(
'complete', $this->
getSteps());
781 $stepIndex = array_search($step, $this->
getSteps());
786 $stepIndex == $completeIndex;
787 if (!$useElggSession) {
788 session_name(
'Elgg_install');
790 _elgg_services()->events->unregisterHandler(
'boot',
'system',
'session_init');
793 if ($stepIndex > $dbIndex) {
823 'private_settings.php',
833 'deprecated-1.9.php',
836 foreach ($lib_files as
$file) {
837 if (!include_once($lib_dir->getPath(
$file))) {
843 _elgg_services()->translator->registerTranslations(\
Elgg\Application::elggDir()->getPath(
"/languages/"));
844 $this->CONFIG->language =
'en';
846 if ($stepIndex > $settingsIndex) {
847 $this->CONFIG->site_guid = (int)
_elgg_services()->datalist->get(
'default_site');
848 $this->CONFIG->site_id = $this->CONFIG->site_guid;
849 $this->CONFIG->site =
get_entity($this->CONFIG->site_guid);
850 $this->CONFIG->dataroot =
_elgg_services()->datalist->get(
'dataroot');
865 $this->CONFIG->installer_running =
true;
868 $this->CONFIG->url = $this->CONFIG->wwwroot;
870 $this->view_path = $this->CONFIG->path .
'views/';
871 $this->CONFIG->pluginspath = $this->CONFIG->path .
'mod/';
872 $this->CONFIG->context = array();
873 $this->CONFIG->entity_types = array(
'group',
'object',
'site',
'user');
876 $this->CONFIG->sitename =
'';
877 $this->CONFIG->sitedescription =
'';
880 $this->CONFIG->site_guid = 1;
886 private function isHttps() {
887 return (!empty($_SERVER[
"HTTPS"]) && strtolower($_SERVER[
"HTTPS"]) !==
"off") ||
888 (!empty($_SERVER[
'SERVER_PORT']) && $_SERVER[
'SERVER_PORT'] == 443);
900 $protocol = $this->isHttps() ?
'https' :
'http';
902 if (isset($_SERVER[
"SERVER_PORT"])) {
903 $port =
':' . $_SERVER[
"SERVER_PORT"];
907 if ($port ==
':80' || $port ==
':443') {
910 $uri = isset($_SERVER[
'REQUEST_URI']) ? $_SERVER[
'REQUEST_URI'] :
'';
911 $cutoff = strpos($uri,
'install.php');
912 $uri = substr($uri, 0, $cutoff);
913 $serverName = isset($_SERVER[
'SERVER_NAME']) ? $_SERVER[
'SERVER_NAME'] :
'';
915 return "$protocol://{$serverName}$port{$uri}";
927 }
catch (\Exception
$e) {
928 $msg =
_elgg_services()->translator->translate(
'InstallationException:CannotLoadSettings');
948 foreach ($_POST as $k => $v) {
981 $root = Directory\Local::root()->getPath();
984 if (0 === strpos($abs_path, $root)) {
985 $relative_path = substr($abs_path, strlen($root));
987 $relative_path = $abs_path;
989 $relative_path = rtrim($relative_path,
'/\\');
991 $writable = is_writable(
Directory\Local::root()->getPath(
'elgg-config'));
995 'severity' =>
'failure',
996 'message' =>
_elgg_services()->translator->translate(
'install:check:installdir', [$relative_path]),
1013 if (!is_file($this->getSettingsPath())) {
1017 if (!is_readable($this->getSettingsPath())) {
1020 'severity' =>
'failure',
1021 'message' =>
_elgg_services()->translator->translate(
'install:check:readsettings'),
1034 private function getSettingsPath() {
1035 return Directory\Local::root()->getPath(
"elgg-config/settings.php");
1046 $phpReport = array();
1048 $min_php_version =
'5.6.0';
1049 if (version_compare(PHP_VERSION, $min_php_version,
'<')) {
1050 $phpReport[] = array(
1051 'severity' =>
'failure',
1052 'message' =>
_elgg_services()->translator->translate(
'install:check:php:version', array($min_php_version, PHP_VERSION))
1060 if (count($phpReport) == 0) {
1061 $phpReport[] = array(
1062 'severity' =>
'pass',
1063 'message' =>
_elgg_services()->translator->translate(
'install:check:php:success')
1079 $requiredExtensions = array(
1085 foreach ($requiredExtensions as
$extension) {
1087 $phpReport[] = array(
1088 'severity' =>
'failure',
1094 $recommendedExtensions = array(
1097 foreach ($recommendedExtensions as
$extension) {
1099 $phpReport[] = array(
1100 'severity' =>
'warning',
1115 if (ini_get(
'open_basedir')) {
1116 $phpReport[] = array(
1117 'severity' =>
'warning',
1118 'message' =>
_elgg_services()->translator->translate(
"install:check:php:open_basedir")
1122 if (ini_get(
'safe_mode')) {
1123 $phpReport[] = array(
1124 'severity' =>
'warning',
1125 'message' =>
_elgg_services()->translator->translate(
"install:check:php:safe_mode")
1129 if (ini_get(
'arg_separator.output') !==
'&') {
1130 $separator = htmlspecialchars(ini_get(
'arg_separator.output'));
1131 $msg =
_elgg_services()->translator->translate(
"install:check:php:arg_separator", array($separator));
1132 $phpReport[] = array(
1133 'severity' =>
'failure',
1138 if (ini_get(
'register_globals')) {
1139 $phpReport[] = array(
1140 'severity' =>
'failure',
1141 'message' =>
_elgg_services()->translator->translate(
"install:check:php:register_globals")
1145 if (ini_get(
'session.auto_start')) {
1146 $phpReport[] = array(
1147 'severity' =>
'failure',
1148 'message' =>
_elgg_services()->translator->translate(
"install:check:php:session.auto_start")
1175 if (strpos($_SERVER[
'REQUEST_URI'],
'rewrite.php') !== FALSE) {
1176 echo \Elgg\Application::REWRITE_TEST_OUTPUT;
1191 foreach (
$report as $category => $checks) {
1192 foreach ($checks as $check) {
1193 if ($check[
'severity'] === $condition) {
1218 if (
$info[
'required'] == TRUE && !$submissionVars[
$field]) {
1230 if (!preg_match(
"/^[a-zA-Z_][\w]*$/", $submissionVars[
'dbprefix'])) {
1236 $submissionVars[
'dbuser'],
1237 $submissionVars[
'dbpassword'],
1238 $submissionVars[
'dbname'],
1239 $submissionVars[
'dbhost']
1254 $config = new \Elgg\Database\Config((
object)[
1258 'dbname' => $dbname,
1260 $db = new \Elgg\Database($config);
1263 $db->getDataRow(
"SELECT 1");
1265 if (0 === strpos(
$e->getMessage(),
"Elgg couldn't connect")) {
1274 $version = $db->getServerVersion(\
Elgg\Database\Config::READ_WRITE);
1275 $required_version = 5.0;
1277 if ($points[0] < $required_version) {
1299 foreach (
$params as $k => $v) {
1300 $template = str_replace(
"{{" . $k .
"}}", $v, $template);
1303 $result = file_put_contents($this->getSettingsPath(), $template);
1318 if (!include_once($this->getSettingsPath())) {
1319 register_error(
'Elgg could not load the settings file. It does not exist or there is a file permissions issue.');
1323 if (!include_once(\
Elgg\Application::elggDir()->getPath(
"engine/lib/database.php"))) {
1347 _elgg_services()->db->runSqlScript(\
Elgg\Application::elggDir()->getPath(
"/engine/schema/mysql.sql"));
1348 }
catch (Exception
$e) {
1349 $msg =
$e->getMessage();
1350 if (strpos($msg,
'already exists')) {
1351 $msg =
_elgg_services()->translator->translate(
'install:error:tables_exist');
1374 if ($formVars[
'dataroot'][
'type'] !=
'combo') {
1379 if ($submissionVars[
'dataroot'] !=
'dataroot-checkbox') {
1384 if (file_exists($dir) || mkdir($dir, 0700)) {
1385 $submissionVars[
'dataroot'] = $dir;
1386 if (!file_exists(
"$dir/.htaccess")) {
1387 $htaccess =
"Order Deny,Allow\nDeny from All\n";
1388 if (!file_put_contents(
"$dir/.htaccess", $htaccess)) {
1410 $submissionVars[
$field] = trim($submissionVars[
$field]);
1411 if (
$info[
'required'] == TRUE && $submissionVars[
$field] ===
'') {
1419 if (stripos(PHP_OS,
'win') === 0) {
1420 if (strpos($submissionVars[
'dataroot'],
':') !== 1) {
1421 $msg =
_elgg_services()->translator->translate(
'install:error:relative_path', array($submissionVars[
'dataroot']));
1426 if (strpos($submissionVars[
'dataroot'],
'/') !== 0) {
1427 $msg =
_elgg_services()->translator->translate(
'install:error:relative_path', array($submissionVars[
'dataroot']));
1434 if (!file_exists($submissionVars[
'dataroot'])) {
1435 $msg =
_elgg_services()->translator->translate(
'install:error:datadirectoryexists', array($submissionVars[
'dataroot']));
1441 if (!is_writable($submissionVars[
'dataroot'])) {
1442 $msg =
_elgg_services()->translator->translate(
'install:error:writedatadirectory', array($submissionVars[
'dataroot']));
1447 if (!isset($this->CONFIG->data_dir_override) || !$this->CONFIG->data_dir_override) {
1449 if (stripos($submissionVars[
'dataroot'], $submissionVars[
'path']) === 0) {
1450 $msg =
_elgg_services()->translator->translate(
'install:error:locationdatadirectory', array($submissionVars[
'dataroot']));
1457 if ($submissionVars[
'siteemail'] && !
is_email_address($submissionVars[
'siteemail'])) {
1458 $msg =
_elgg_services()->translator->translate(
'install:error:emailaddress', array($submissionVars[
'siteemail']));
1484 $site->name = strip_tags($submissionVars[
'sitename']);
1485 $site->url = $submissionVars[
'wwwroot'];
1487 $site->email = $submissionVars[
'siteemail'];
1496 $this->CONFIG->site_guid =
$guid;
1497 $this->CONFIG->site_id =
$guid;
1498 $this->CONFIG->site =
$site;
1501 _elgg_services()->datalist->set(
'dataroot', $submissionVars[
'dataroot']);
1514 _elgg_services()->configTable->set(
'default_access', $submissionVars[
'siteaccess'],
$site->getGUID());
1537 add_subtype(
"object",
"elgg_upgrade",
'ElggUpgrade');
1548 foreach ($plugins as
$plugin) {
1550 if (
$plugin->getManifest()->getActivateOnInstall()) {
1553 if (in_array(
'theme',
$plugin->getManifest()->getCategories())) {
1575 if (
$info[
'required'] == TRUE && !$submissionVars[
$field]) {
1582 if ($submissionVars[
'password1'] !== $submissionVars[
'password2']) {
1587 if (trim($submissionVars[
'password1']) ==
"") {
1592 $minLength =
_elgg_services()->configTable->get(
'min_password_length');
1593 if (strlen($submissionVars[
'password1']) < $minLength) {
1599 if ($submissionVars[
'email'] && !
is_email_address($submissionVars[
'email'])) {
1600 $msg =
_elgg_services()->translator->translate(
'install:error:emailaddress', array($submissionVars[
'email']));
1619 $submissionVars[
'username'],
1620 $submissionVars[
'password1'],
1621 $submissionVars[
'displayname'],
1622 $submissionVars[
'email']
1624 }
catch (Exception
$e) {
1641 if (
$user->makeAdmin() == FALSE) {
1658 'cache_limiter' => session_cache_limiter(),
1660 $storage =
new Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage(
$options,
$handler);
1662 $session =
new ElggSession(
new Symfony\Component\HttpFoundation\Session\Session($storage));
if($guid==elgg_get_logged_in_user_guid()) $name
checkDatabaseSettings($user, $password, $dbname, $host)
Confirm the settings for the database.
continueToNextStep($currentStep)
Forwards the browser to the next step.
makeFormSticky($formVars, $submissionVars)
If form is reshown, remember previously submitted variables.
checkPhpExtensions(&$phpReport)
Check the server's PHP extensions.
validateDatabaseVars($submissionVars, $formVars)
Database support methods.
setAutoLogin($flag)
Set the auto login flag.
getPostVariables()
Action handling methods.
getBaseUrl()
Get the best guess at the base URL.
isInstallDirWritable(&$report)
Requirement checks support methods.
checkInstallCompletion($step)
Security check to ensure the installer cannot be run after installation has finished.
welcome($vars)
Step controllers.
createDataDirectory(&$submissionVars, $formVars)
Site settings support methods.
render($step, $vars=array())
Renders the data passed by a controller.
finishBootstraping($step)
Load remaining engine libraries and complete bootstraping (see start.php)
saveSiteSettings($submissionVars)
Initialize the site including site entity, plugins, and configuration.
getSteps()
Step management.
setSubtypeClasses()
Register classes for core objects.
checkSettingsFile(&$report=array())
Check that the settings file exists.
checkPhpDirectives(&$phpReport)
Check PHP parameters.
checkPHP(&$report)
Check version of PHP, extensions, and variables.
validateSettingsVars($submissionVars, $formVars)
Validate the site settings form variables.
processRewriteTest()
Check if the request is coming from the URL rewrite test on the requirements page.
bootstrapConfig()
Set up configuration variables.
countNumConditions($report, $condition)
Count the number of failures in the requirements report.
batchInstall(array $params, $createHtaccess=FALSE)
A batch install of Elgg.
validateAdminVars($submissionVars, $formVars)
Admin account support methods.
__construct()
Constructor bootstraps the Elgg engine.
setInstallStatus()
Check the different install steps for completion.
resumeInstall($step)
Check if this is a case of a install being resumed and figure out where to continue from.
getNextStep($currentStep)
Get the next step as a string.
createSettingsFile($params)
Writes the settings file to the engine directory.
requirements($vars)
Requirements controller.
createAdminAccount($submissionVars, $login=FALSE)
Create a user account for the admin.
settings($submissionVars)
Site settings controller.
bootstrapEngine()
Bootstraping.
admin($submissionVars)
Admin account controller.
connectToDatabase()
Bootstrap database connection before entire engine is available.
database($submissionVars)
Database set up controller.
complete()
Controller for last step.
getNextStepUrl($currentStep)
Get the URL of the next step.
loadSettingsFile()
Load settings.php.
checkRewriteRules(&$report)
Confirm that the rewrite rules are firing.
enablePlugins()
Enable a set of default plugins.
installDatabase()
Create the database tables.
run($step)
Dispatches a request to one of the step controllers.
static getMock()
Get an isolated ElggSession that does not persist between requests.
static elggDir()
Returns a directory that points to the root of Elgg, but not necessarily the install root.
$_ELGG translations
String translations for the current language.
$guid
Removes an admin notice.
register_error($error)
Display an error on next page load.
sanitise_filepath($path, $append_slash=true)
Sanitise file paths ensuring that they begin and end with slashes etc.
system_message($message)
Display a system message on next page load.
elgg_get_version($human_readable=false)
Get the current Elgg version information.
forward($location="", $reason='system')
Forward to $location.
elgg_set_ignore_access($ignore=true)
Set if Elgg's access system should be ignored.
_elgg_services(\Elgg\Di\ServiceProvider $services=null)
Get the global service provider.
elgg_get_plugins($status='active', $site_guid=null)
Returns an ordered list of plugins.
_elgg_generate_plugin_entities()
Discovers plugins in the plugins_path setting and creates \ElggPlugin entities for them if they don't...
elgg_get_upgrade_files($upgrade_path=null)
Returns a list of upgrade files relative to the $upgrade_path dir.
get_entity($guid)
Loads and returns an entity object from a guid.
add_subtype($type, $subtype, $class="")
Register \ElggEntities with a certain type and subtype to be loaded as a specific class.
if(elgg_extract('required', $vars)) $field
A simple directory abstraction.
getPath($path='')
Get the absolute path to the given directory-relative path.
elgg_view_page($title, $body, $page_shell='default', $vars=array())
Assembles and outputs a full page.
elgg_view($view, $vars=array(), $ignore1=false, $ignore2=false, $viewtype='')
Return a parsed view.
elgg_set_viewtype($viewtype="")
Manually set the viewtype.
if(!array_key_exists($filename, $text_files)) $file
login(\ElggUser $user, $persistent=false)
Logs in a specified \ElggUser.
_elgg_session_boot()
Initializes the session and checks for the remember me cookie.
$upgrades
Lists pending upgrades.
register_user($username, $password, $name, $email, $allow_multiple_emails=false)
Registers a user, returning false if the username already exists.