64 if (!isset($CONFIG)) {
65 $CONFIG =
new stdClass;
68 $this->CONFIG = $CONFIG;
70 $this->isAction = isset($_SERVER[
'REQUEST_METHOD']) && $_SERVER[
'REQUEST_METHOD'] ===
'POST';
80 set_error_handler(
'_elgg_php_error_handler');
81 set_exception_handler(
'_elgg_php_exception_handler');
83 _elgg_services()->translator->registerTranslations(
"{$this->getElggRoot()}/install/languages/", TRUE);
89 private function getElggRoot() {
90 return dirname(dirname(__DIR__));
105 $CONFIG->language =
'en';
111 $msg =
_elgg_services()->translator->translate(
'InstallationException:UnknownStep', array(
$step));
136 $this->autoLogin = (bool) $flag;
160 restore_error_handler();
161 restore_exception_handler();
164 'dbhost' =>
'localhost',
165 'dbprefix' =>
'elgg_',
169 $params = array_merge(
$defaults, $params);
171 $requiredParams = array(
183 foreach ($requiredParams as
$key) {
184 if (empty($params[$key])) {
185 $msg =
_elgg_services()->translator->translate(
'install:error:requiredfield', array($key));
191 $params[
'password1'] = $params[
'password2'] = $params[
'password'];
193 if ($createHtaccess) {
195 if (!$rewriteTester->createHtaccess($params[
'wwwroot'], $this->CONFIG->path)) {
202 if (!$this->status[
'config']) {
212 if (!$this->status[
'database']) {
297 $report[
'database'] = array(array(
298 'severity' =>
'info',
299 'message' =>
_elgg_services()->translator->translate(
'install:check:database')
311 'num_failures' => $numFailures,
312 'num_warnings' => $numWarnings,
335 'dbpassword' => array(
336 'type' =>
'password',
347 'value' =>
'localhost',
359 $this->isAction = TRUE;
362 if ($this->isAction) {
393 $params = array(
'variables' => $formVars,);
418 'value' =>
'My New Community',
421 'siteemail' => array(
436 'siteaccess' => array(
450 if ($this->isAction) {
473 $this->
render(
'settings', array(
'variables' => $formVars));
485 protected function admin($submissionVars) {
487 'displayname' => array(
502 'password1' => array(
503 'type' =>
'password',
506 'pattern' =>
'.{6,}',
508 'password2' => array(
509 'type' =>
'password',
515 if ($this->isAction) {
535 $this->CONFIG->translations[
$lang][
'install:admin:help:password1'] =
536 sprintf($this->CONFIG->translations[
$lang][
'install:admin:help:password1'],
537 $this->CONFIG->min_password_length);
541 $this->
render(
'admin', array(
'variables' => $formVars));
552 if ($this->autoLogin) {
553 $params[
'destination'] =
'admin';
555 $params[
'destination'] =
'index.php';
582 $this->isAction = FALSE;
594 $index = 1 + array_search($currentStep, $this->
steps);
595 if (isset($this->
steps[$index])) {
596 return $this->
steps[$index];
611 return _elgg_services()->config->getSiteUrl() .
"install.php?step=$nextStep";
623 if (!is_readable(
"{$this->CONFIG->path}engine/settings.php")) {
629 $this->status[
'config'] = TRUE;
633 $this->CONFIG->dbuser,
634 $this->CONFIG->dbpass,
635 $this->CONFIG->dbname,
636 $this->CONFIG->dbhost
638 if ($dbSettingsPass == FALSE) {
642 if (!include_once(
"{$this->CONFIG->path}engine/lib/database.php")) {
647 $query =
"show tables";
651 $table = (array) $table;
652 if (in_array(
"{$this->CONFIG->dbprefix}config", $table)) {
653 $this->status[
'database'] = TRUE;
656 if ($this->status[
'database'] == FALSE) {
665 $query =
"SELECT COUNT(*) AS total FROM {$this->CONFIG->dbprefix}config";
668 $this->status[
'settings'] = TRUE;
674 $query =
"SELECT COUNT(*) AS total FROM {$this->CONFIG->dbprefix}users_entity";
677 $this->status[
'admin'] = TRUE;
692 if (
$step !=
'complete') {
693 if (!in_array(FALSE, $this->status)) {
710 if (
$step !==
'welcome') {
714 if ($this->status[
'database'] == FALSE) {
718 if ($this->status[
'settings'] == FALSE) {
719 forward(
"install.php?step=settings");
722 if ($this->status[
'admin'] == FALSE) {
723 forward(
"install.php?step=admin");
727 forward(
"install.php?step=complete");
742 require_once $this->CONFIG->path .
'engine/load.php';
756 $dbIndex = array_search(
'database', $this->
getSteps());
757 $settingsIndex = array_search(
'settings', $this->
getSteps());
758 $adminIndex = array_search(
'admin', $this->
getSteps());
759 $completeIndex = array_search(
'complete', $this->
getSteps());
765 $stepIndex == $completeIndex;
766 if (!$useElggSession) {
767 session_name(
'Elgg_install');
769 _elgg_services()->events->unregisterHandler(
'boot',
'system',
'session_init');
772 if ($stepIndex > $dbIndex) {
775 $lib_dir = $this->CONFIG->path .
'engine/lib/';
802 'private_settings.php',
812 'deprecated-1.7.php',
813 'deprecated-1.8.php',
814 'deprecated-1.9.php',
819 if (!include_once(
$path)) {
825 _elgg_services()->translator->registerTranslations(
"{$this->getElggRoot()}/languages/");
826 $this->CONFIG->language =
'en';
828 if ($stepIndex > $settingsIndex) {
829 $this->CONFIG->site_guid = (int)
_elgg_services()->datalist->get(
'default_site');
830 $this->CONFIG->site_id = $this->CONFIG->site_guid;
831 $this->CONFIG->site =
get_entity($this->CONFIG->site_guid);
832 $this->CONFIG->dataroot =
_elgg_services()->datalist->get(
'dataroot');
846 $this->CONFIG->installer_running =
true;
849 $this->CONFIG->url = $this->CONFIG->wwwroot;
850 $this->CONFIG->path =
"{$this->getElggRoot()}/";
851 $this->CONFIG->viewpath = $this->CONFIG->path .
'views/';
852 $this->CONFIG->pluginspath = $this->CONFIG->path .
'mod/';
853 $this->CONFIG->context = array();
854 $this->CONFIG->entity_types = array(
'group',
'object',
'site',
'user');
857 $this->CONFIG->sitename =
'';
858 $this->CONFIG->sitedescription =
'';
861 $this->CONFIG->site_guid = 1;
867 private function isHttps() {
868 return (!empty($_SERVER[
"HTTPS"]) && $_SERVER[
"HTTPS"] ==
"on") ||
869 $_SERVER[
'SERVER_PORT'] == 443;
881 $protocol = $this->isHttps() ?
'https' :
'http';
883 if (isset($_SERVER[
"SERVER_PORT"])) {
884 $port =
':' . $_SERVER[
"SERVER_PORT"];
888 if ($port ==
':80' || $port ==
':443') {
891 $uri = isset($_SERVER[
'REQUEST_URI']) ? $_SERVER[
'REQUEST_URI'] :
'';
892 $cutoff = strpos($uri,
'install.php');
893 $uri = substr($uri, 0, $cutoff);
894 $serverName = isset($_SERVER[
'SERVER_NAME']) ? $_SERVER[
'SERVER_NAME'] :
'';
896 return "$protocol://{$serverName}$port{$uri}";
908 if (!include_once(
"{$this->CONFIG->path}engine/settings.php")) {
928 foreach ($_POST as $k => $v) {
943 foreach ($submissionVars as $field =>
$value) {
944 $formVars[$field][
'value'] =
$value;
963 $writable = is_writable(
"{$this->CONFIG->path}engine");
967 'severity' =>
'failure',
968 'message' =>
_elgg_services()->translator->translate(
'install:check:enginedir'),
987 if (!file_exists(
"{$this->CONFIG->path}engine/settings.php")) {
991 if (!is_readable(
"{$this->CONFIG->path}engine/settings.php")) {
994 'severity' =>
'failure',
995 'message' =>
_elgg_services()->translator->translate(
'install:check:readsettings'),
1011 $phpReport = array();
1013 $min_php_version =
'5.4.0';
1014 if (version_compare(PHP_VERSION, $min_php_version,
'<')) {
1015 $phpReport[] = array(
1016 'severity' =>
'failure',
1017 'message' =>
_elgg_services()->translator->translate(
'install:check:php:version', array($min_php_version, PHP_VERSION))
1025 if (count($phpReport) == 0) {
1026 $phpReport[] = array(
1027 'severity' =>
'pass',
1028 'message' =>
_elgg_services()->translator->translate(
'install:check:php:success')
1044 $requiredExtensions = array(
1050 foreach ($requiredExtensions as
$extension) {
1052 $phpReport[] = array(
1053 'severity' =>
'failure',
1054 'message' =>
_elgg_services()->translator->translate(
'install:check:php:extension', array($extension))
1059 $recommendedExtensions = array(
1062 foreach ($recommendedExtensions as $extension) {
1064 $phpReport[] = array(
1065 'severity' =>
'warning',
1066 'message' =>
_elgg_services()->translator->translate(
'install:check:php:extension:recommend', array($extension))
1080 if (ini_get(
'open_basedir')) {
1081 $phpReport[] = array(
1082 'severity' =>
'warning',
1083 'message' =>
_elgg_services()->translator->translate(
"install:check:php:open_basedir")
1087 if (ini_get(
'safe_mode')) {
1088 $phpReport[] = array(
1089 'severity' =>
'warning',
1090 'message' =>
_elgg_services()->translator->translate(
"install:check:php:safe_mode")
1094 if (ini_get(
'arg_separator.output') !==
'&') {
1095 $separator = htmlspecialchars(ini_get(
'arg_separator.output'));
1096 $msg =
_elgg_services()->translator->translate(
"install:check:php:arg_separator", array($separator));
1097 $phpReport[] = array(
1098 'severity' =>
'failure',
1103 if (ini_get(
'register_globals')) {
1104 $phpReport[] = array(
1105 'severity' =>
'failure',
1106 'message' =>
_elgg_services()->translator->translate(
"install:check:php:register_globals")
1110 if (ini_get(
'session.auto_start')) {
1111 $phpReport[] = array(
1112 'severity' =>
'failure',
1113 'message' =>
_elgg_services()->translator->translate(
"install:check:php:session.auto_start")
1130 $report[
'rewrite'] = array($tester->run(
$url, $this->CONFIG->path));
1140 if (strpos($_SERVER[
'REQUEST_URI'],
'rewrite.php') !== FALSE) {
1156 foreach (
$report as $category => $checks) {
1157 foreach ($checks as $check) {
1158 if ($check[
'severity'] === $condition) {
1182 foreach ($formVars as $field => $info) {
1183 if ($info[
'required'] == TRUE && !$submissionVars[$field]) {
1195 if (!preg_match(
"/^[a-zA-Z_][\w]*$/", $submissionVars[
'dbprefix'])) {
1201 $submissionVars[
'dbuser'],
1202 $submissionVars[
'dbpassword'],
1203 $submissionVars[
'dbname'],
1204 $submissionVars[
'dbhost']
1219 $config = new \Elgg\Database\Config((
object)[
1223 'dbname' => $dbname,
1225 $logger = new \Elgg\Logger(
new \
Elgg\PluginHooksService());
1226 $db = new \Elgg\Database($config, $logger);
1229 $db->getDataRow(
"SELECT 1");
1231 if (0 === strpos($e->getMessage(),
"Elgg couldn't connect")) {
1240 $version = $db->getServerVersion(\
Elgg\Database\Config::READ_WRITE);
1241 $required_version = 5.0;
1243 if ($points[0] < $required_version) {
1261 $templateFile =
"{$this->CONFIG->path}engine/settings.example.php";
1262 $template = file_get_contents($templateFile);
1268 foreach (
$params as $k => $v) {
1269 $template = str_replace(
"{{" . $k .
"}}", $v, $template);
1272 $settingsFilename =
"{$this->CONFIG->path}engine/settings.php";
1273 $result = file_put_contents($settingsFilename, $template);
1290 if (!include_once(
"{$this->CONFIG->path}engine/settings.php")) {
1291 register_error(
'Elgg could not load the settings file. It does not exist or there is a file permissions issue.');
1295 if (!include_once(
"{$this->CONFIG->path}engine/lib/database.php")) {
1319 _elgg_services()->db->runSqlScript(
"{$this->CONFIG->path}engine/schema/mysql.sql");
1321 $msg = $e->getMessage();
1322 if (strpos($msg,
'already exists')) {
1323 $msg =
_elgg_services()->translator->translate(
'install:error:tables_exist');
1346 if ($formVars[
'dataroot'][
'type'] !=
'combo') {
1351 if ($submissionVars[
'dataroot'] !=
'dataroot-checkbox') {
1356 if (file_exists($dir) || mkdir($dir, 0700)) {
1357 $submissionVars[
'dataroot'] = $dir;
1358 if (!file_exists(
"$dir/.htaccess")) {
1359 $htaccess =
"Order Deny,Allow\nDeny from All\n";
1360 if (!file_put_contents(
"$dir/.htaccess", $htaccess)) {
1381 foreach ($formVars as $field => $info) {
1382 $submissionVars[$field] = trim($submissionVars[$field]);
1383 if ($info[
'required'] == TRUE && $submissionVars[$field] ===
'') {
1391 if (stripos(PHP_OS,
'win') === 0) {
1392 if (strpos($submissionVars[
'dataroot'],
':') !== 1) {
1393 $msg =
_elgg_services()->translator->translate(
'install:error:relative_path', array($submissionVars[
'dataroot']));
1398 if (strpos($submissionVars[
'dataroot'],
'/') !== 0) {
1399 $msg =
_elgg_services()->translator->translate(
'install:error:relative_path', array($submissionVars[
'dataroot']));
1406 if (!file_exists($submissionVars[
'dataroot'])) {
1407 $msg =
_elgg_services()->translator->translate(
'install:error:datadirectoryexists', array($submissionVars[
'dataroot']));
1413 if (!is_writable($submissionVars[
'dataroot'])) {
1414 $msg =
_elgg_services()->translator->translate(
'install:error:writedatadirectory', array($submissionVars[
'dataroot']));
1419 if (!isset($this->CONFIG->data_dir_override) || !$this->CONFIG->data_dir_override) {
1421 if (stripos($submissionVars[
'dataroot'], $submissionVars[
'path']) === 0) {
1422 $msg =
_elgg_services()->translator->translate(
'install:error:locationdatadirectory', array($submissionVars[
'dataroot']));
1429 if ($submissionVars[
'siteemail'] && !
is_email_address($submissionVars[
'siteemail'])) {
1430 $msg =
_elgg_services()->translator->translate(
'install:error:emailaddress', array($submissionVars[
'siteemail']));
1456 $site->name = strip_tags($submissionVars[
'sitename']);
1457 $site->url = $submissionVars[
'wwwroot'];
1459 $site->email = $submissionVars[
'siteemail'];
1468 $this->CONFIG->site_guid =
$guid;
1469 $this->CONFIG->site_id =
$guid;
1470 $this->CONFIG->site =
$site;
1473 _elgg_services()->datalist->set(
'dataroot', $submissionVars[
'dataroot']);
1478 _elgg_services()->datalist->set(
'simplecache_lastupdate', time());
1489 _elgg_services()->configTable->set(
'default_access', $submissionVars[
'siteaccess'],
$site->getGUID());
1512 add_subtype(
"object",
"elgg_upgrade",
'ElggUpgrade');
1524 if ($plugin->getManifest()) {
1525 if ($plugin->getManifest()->getActivateOnInstall()) {
1526 $plugin->activate();
1528 if (in_array(
'theme', $plugin->getManifest()->getCategories())) {
1529 $plugin->setPriority(
'last');
1549 foreach ($formVars as $field => $info) {
1550 if ($info[
'required'] == TRUE && !$submissionVars[$field]) {
1557 if ($submissionVars[
'password1'] !== $submissionVars[
'password2']) {
1562 if (trim($submissionVars[
'password1']) ==
"") {
1567 $minLength =
_elgg_services()->configTable->get(
'min_password_length');
1568 if (strlen($submissionVars[
'password1']) < $minLength) {
1574 if ($submissionVars[
'email'] && !
is_email_address($submissionVars[
'email'])) {
1575 $msg =
_elgg_services()->translator->translate(
'install:error:emailaddress', array($submissionVars[
'email']));
1594 $submissionVars[
'username'],
1595 $submissionVars[
'password1'],
1596 $submissionVars[
'displayname'],
1597 $submissionVars[
'email']
1616 if (
$user->makeAdmin() == FALSE) {
1633 'cache_limiter' => session_cache_limiter(),
1637 $session =
new ElggSession(
new Symfony\Component\HttpFoundation\Session\Session($storage));
checkSettingsFile(&$report=array())
Check that the settings file exists.
$lib_dir
This file is used to make all of Elgg's code available without going through the boot process...
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.
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.
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.
checkEngineDir(&$report)
Requirement checks support methods.
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.
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.
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.
elgg_set_viewtype($viewtype="")
Manually set the viewtype.
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.
elgg echo
Translates a string.
checkPhpExtensions(&$phpReport)
Check the server's PHP extensions.
elgg global
Pointer to the global context.
bootstrapConfig()
Set up configuration variables.
elgg_view($view, $vars=array(), $bypass=false, $ignored=false, $viewtype= '')
Return a parsed view.
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.
getPostVariables()
Action handling methods.
loadSettingsFile()
Load settings.php.
__construct()
Constructor bootstraps the Elgg engine.
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.
createAdminAccount($submissionVars, $login=FALSE)
Create a user account for the admin.
static getMock()
Get an isolated ElggSession that does not persist between requests.
elgg_view_page($title, $body, $page_shell= 'default', $vars=array())
Assembles and outputs a full page.
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.
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
database($submissionVars)
Database set up controller.
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.
if(file_exists($welcome)) $vars
validateAdminVars($submissionVars, $formVars)
Admin account support methods.