54 private $view_path =
'';
68 if (!isset($CONFIG)) {
77 $this->CONFIG = $CONFIG;
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) {
111 $CONFIG->language =
'en';
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_',
177 $params = array_merge(
$defaults, $params);
179 $requiredParams = array(
191 foreach ($requiredParams as
$key) {
192 if (empty($params[$key])) {
193 $msg =
_elgg_services()->translator->translate(
'install:error:requiredfield', array($key));
199 $params[
'password1'] = $params[
'password2'] = $params[
'password'];
201 if ($createHtaccess) {
203 if (!$rewriteTester->createHtaccess($params[
'wwwroot'],
Directory\Local::root()->
getPath())) {
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);
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";
672 $table = (array) $table;
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}";
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',
1089 'message' =>
_elgg_services()->translator->translate(
'install:check:php:extension', array($extension))
1094 $recommendedExtensions = array(
1097 foreach ($recommendedExtensions as $extension) {
1099 $phpReport[] = array(
1100 'severity' =>
'warning',
1101 'message' =>
_elgg_services()->translator->translate(
'install:check:php:extension:recommend', array($extension))
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"));
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) {
1549 if ($plugin->getManifest()) {
1550 if ($plugin->getManifest()->getActivateOnInstall()) {
1551 $plugin->activate();
1553 if (in_array(
'theme', $plugin->getManifest()->getCategories())) {
1554 $plugin->setPriority(
'last');
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']
1641 if (
$user->makeAdmin() == FALSE) {
1658 'cache_limiter' => session_cache_limiter(),
checkSettingsFile(&$report=array())
Check that the settings file exists.
A simple directory abstraction.
elgg_get_upgrade_files($upgrade_path=null)
Returns a list of upgrade files relative to the $upgrade_path dir.
batchInstall(array $params, $createHtaccess=FALSE)
A batch install of Elgg.
createDataDirectory(&$submissionVars, $formVars)
Site settings support methods.
if(!array_key_exists($filename, $text_files)) $file
setSubtypeClasses()
Register classes for core objects.
bootstrapEngine()
Bootstraping.
countNumConditions($report, $condition)
Count the number of failures in the requirements report.
processRewriteTest()
Check if the request is coming from the URL rewrite test on the requirements page.
if($guid==elgg_get_logged_in_user_guid()) $name
finishBootstraping($step)
Load remaining engine libraries and complete bootstraping (see start.php)
checkPhpDirectives(&$phpReport)
Check PHP parameters.
welcome($vars)
Step controllers.
sanitise_filepath($path, $append_slash=true)
Sanitise file paths ensuring that they begin and end with slashes etc.
$_ELGG translations
String translations for the current language.
setInstallStatus()
Check the different install steps for completion.
installDatabase()
Create the database tables.
checkInstallCompletion($step)
Security check to ensure the installer cannot be run after installation has finished.
getNextStep($currentStep)
Get the next step as a string.
$guid
Removes an admin notice.
requirements($vars)
Requirements controller.
elgg forward
Meant to mimic the php forward() function by simply redirecting the user to another page...
getSteps()
Step management.
$upgrades
Lists pending upgrades.
register_user($username, $password, $name, $email, $allow_multiple_emails=false)
Registers a user, returning false if the username already exists.
checkPHP(&$report)
Check version of PHP, extensions, and variables.
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two steps
validateSettingsVars($submissionVars, $formVars)
Validate the site settings form variables.
resumeInstall($step)
Check if this is a case of a install being resumed and figure out where to continue from...
settings($submissionVars)
Site settings controller.
continueToNextStep($currentStep)
Forwards the browser to the next step.
getPath($path= '')
Get the absolute path to the given directory-relative path.
render($step, $vars=array())
Renders the data passed by a controller.
getNextStepUrl($currentStep)
Get the URL of the next step.
add_subtype($type, $subtype, $class="")
Register with a certain type and subtype to be loaded as a specific class.
getBaseUrl()
Get the best guess at the base URL.
elgg_set_ignore_access($ignore=true)
Set if Elgg's access system should be ignored.
makeFormSticky($formVars, $submissionVars)
If form is reshown, remember previously submitted variables.
if(elgg_extract('required', $vars)) $field
elgg_set_viewtype($viewtype="")
Manually set the viewtype.
elgg echo
Translates a string.
checkPhpExtensions(&$phpReport)
Check the server's PHP extensions.
elgg_view($view, $vars=array(), $ignore1=false, $ignore2=false, $viewtype= '')
Return a parsed view.
elgg global
Pointer to the global context.
bootstrapConfig()
Set up configuration variables.
_elgg_services(\Elgg\Di\ServiceProvider $services=null)
Get the global service provider.
checkRewriteRules(&$report)
Confirm that the rewrite rules are firing.
validateDatabaseVars($submissionVars, $formVars)
Database support methods.
elgg system_message
Wrapper function for system_messages.
createSettingsFile($params)
Writes the settings file to the engine directory.
enablePlugins()
Enable a set of default plugins.
elgg_get_plugins($status= 'active', $site_guid=null)
Returns an ordered list of plugins.
elgg_get_version($human_readable=false)
Get the current Elgg version information.
complete()
Controller for last step.
elgg register_error
Wrapper function for system_messages.
isInstallDirWritable(&$report)
Requirement checks support methods.
getPostVariables()
Action handling methods.
loadSettingsFile()
Load settings.php.
__construct()
Constructor bootstraps the Elgg engine.
var sprintf
sprintf() for JavaScript 0.7-beta1 http://www.diveintojavascript.com/projects/javascript-sprintf ...
admin($submissionVars)
Admin account controller.
login(\ElggUser $user, $persistent=false)
Logs in a specified .
checkDatabaseSettings($user, $password, $dbname, $host)
Confirm the settings for the database.
static elggDir()
Returns a directory that points to the root of Elgg, but not necessarily the install root...
createAdminAccount($submissionVars, $login=FALSE)
Create a user account for the admin.
static getMock()
Get an isolated ElggSession that does not persist between requests.
connectToDatabase()
Bootstrap database connection before entire engine is available.
setAutoLogin($flag)
Set the auto login flag.
saveSiteSettings($submissionVars)
Initialize the site including site entity, plugins, and configuration.
_elgg_session_boot()
Initializes the session and checks for the remember me cookie.
database($submissionVars)
Database set up controller.
http free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
run($step)
Dispatches a request to one of the step controllers.
_elgg_generate_plugin_entities()
Discovers plugins in the plugins_path setting and creates entities for them if they don't exist...
get_entity($guid)
Loads and returns an entity object from a guid.
elgg_view_page($title, $body, $page_shell= 'default', $vars=array())
Assembles and outputs a full page.
validateAdminVars($submissionVars, $formVars)
Admin account support methods.