66 if (!isset($CONFIG)) {
67 $CONFIG =
new stdClass;
72 $_ELGG =
new stdClass;
75 $this->CONFIG = $CONFIG;
77 $this->isAction = isset($_SERVER[
'REQUEST_METHOD']) && $_SERVER[
'REQUEST_METHOD'] ===
'POST';
87 set_error_handler(
'_elgg_php_error_handler');
88 set_exception_handler(
'_elgg_php_exception_handler');
91 _elgg_services()->translator->registerTranslations(\
Elgg\Application::elggDir()->getPath(
"/install/languages/"), TRUE);
92 _elgg_services()->views->registerPluginViews(\
Elgg\Application::elggDir()->getPath(
"/"));
103 public function run($step) {
107 $CONFIG->language =
'en';
112 if (!in_array($step, $this->
getSteps())) {
113 $msg =
_elgg_services()->translator->translate(
'InstallationException:UnknownStep', array($step));
139 $this->autoLogin = (bool) $flag;
163 restore_error_handler();
164 restore_exception_handler();
167 'dbhost' =>
'localhost',
168 'dbprefix' =>
'elgg_',
173 $params = array_merge(
$defaults, $params);
175 $requiredParams = array(
187 foreach ($requiredParams as
$key) {
188 if (empty($params[$key])) {
189 $msg =
_elgg_services()->translator->translate(
'install:error:requiredfield', array($key));
195 $params[
'password1'] = $params[
'password2'] = $params[
'password'];
197 if ($createHtaccess) {
199 if (!$rewriteTester->createHtaccess($params[
'wwwroot'],
Directory\Local::root()->
getPath())) {
206 if (!$this->status[
'config']) {
216 if (!$this->status[
'database']) {
301 $report[
'database'] = array(array(
302 'severity' =>
'info',
303 'message' =>
_elgg_services()->translator->translate(
'install:check:database')
315 'num_failures' => $numFailures,
316 'num_warnings' => $numWarnings,
339 'dbpassword' => array(
340 'type' =>
'password',
351 'value' =>
'localhost',
360 'type' =>
'dropdown',
362 'options' => \DateTimeZone::listIdentifiers(),
369 $this->isAction = TRUE;
372 if ($this->isAction) {
403 $params = array(
'variables' => $formVars,);
428 'value' =>
'My New Community',
431 'siteemail' => array(
446 'siteaccess' => array(
460 if ($this->isAction) {
483 $this->
render(
'settings', array(
'variables' => $formVars));
495 protected function admin($submissionVars) {
497 'displayname' => array(
512 'password1' => array(
513 'type' =>
'password',
516 'pattern' =>
'.{6,}',
518 'password2' => array(
519 'type' =>
'password',
525 if ($this->isAction) {
545 $GLOBALS[
'_ELGG']->translations[
$lang][
'install:admin:help:password1'] =
547 $this->CONFIG->min_password_length);
551 $this->
render(
'admin', array(
'variables' => $formVars));
562 if ($this->autoLogin) {
563 $params[
'destination'] =
'admin';
565 $params[
'destination'] =
'index.php';
592 $this->isAction = FALSE;
604 $index = 1 + array_search($currentStep, $this->
steps);
605 if (isset($this->
steps[$index])) {
606 return $this->
steps[$index];
621 return _elgg_services()->config->getSiteUrl() .
"install.php?step=$nextStep";
631 if (!is_readable($this->getSettingsPath())) {
637 $this->status[
'config'] = TRUE;
641 $this->CONFIG->dbuser,
642 $this->CONFIG->dbpass,
643 $this->CONFIG->dbname,
644 $this->CONFIG->dbhost
647 if ($dbSettingsPass == FALSE) {
651 if (!include_once(\
Elgg\Application::elggDir()->getPath(
"engine/lib/database.php"))) {
656 $query =
"show tables";
660 $table = (array) $table;
661 if (in_array(
"{$this->CONFIG->dbprefix}config", $table)) {
662 $this->status[
'database'] = TRUE;
665 if ($this->status[
'database'] == FALSE) {
674 $query =
"SELECT COUNT(*) AS total FROM {$this->CONFIG->dbprefix}config";
677 $this->status[
'settings'] = TRUE;
683 $query =
"SELECT COUNT(*) AS total FROM {$this->CONFIG->dbprefix}users_entity";
686 $this->status[
'admin'] = TRUE;
701 if ($step !=
'complete') {
702 if (!in_array(FALSE, $this->status)) {
719 if ($step !==
'welcome') {
723 if ($this->status[
'database'] == FALSE) {
727 if ($this->status[
'settings'] == FALSE) {
728 forward(
"install.php?step=settings");
731 if ($this->status[
'admin'] == FALSE) {
732 forward(
"install.php?step=admin");
736 forward(
"install.php?step=complete");
749 $config = new \Elgg\Config($this->CONFIG);
750 $services = new \Elgg\Di\ServiceProvider($config);
751 (new \Elgg\Application($services))->loadCore();
765 $dbIndex = array_search(
'database', $this->
getSteps());
766 $settingsIndex = array_search(
'settings', $this->
getSteps());
767 $adminIndex = array_search(
'admin', $this->
getSteps());
768 $completeIndex = array_search(
'complete', $this->
getSteps());
769 $stepIndex = array_search($step, $this->
getSteps());
774 $stepIndex == $completeIndex;
775 if (!$useElggSession) {
776 session_name(
'Elgg_install');
778 _elgg_services()->events->unregisterHandler(
'boot',
'system',
'session_init');
781 if ($stepIndex > $dbIndex) {
811 'private_settings.php',
821 'deprecated-1.9.php',
824 foreach ($lib_files as
$file) {
825 if (!include_once($lib_dir->getPath($file))) {
831 _elgg_services()->translator->registerTranslations(\
Elgg\Application::elggDir()->getPath(
"/languages/"));
832 $this->CONFIG->language =
'en';
834 if ($stepIndex > $settingsIndex) {
835 $this->CONFIG->site_guid = (int)
_elgg_services()->datalist->get(
'default_site');
836 $this->CONFIG->site_id = $this->CONFIG->site_guid;
837 $this->CONFIG->site =
get_entity($this->CONFIG->site_guid);
838 $this->CONFIG->dataroot =
_elgg_services()->datalist->get(
'dataroot');
853 $this->CONFIG->installer_running =
true;
856 $this->CONFIG->url = $this->CONFIG->wwwroot;
858 $GLOBALS[
'_ELGG']->view_path = $this->CONFIG->path .
'views/';
859 $this->CONFIG->pluginspath = $this->CONFIG->path .
'mod/';
860 $this->CONFIG->context = array();
861 $this->CONFIG->entity_types = array(
'group',
'object',
'site',
'user');
864 $this->CONFIG->sitename =
'';
865 $this->CONFIG->sitedescription =
'';
868 $this->CONFIG->site_guid = 1;
874 private function isHttps() {
875 return (!empty($_SERVER[
"HTTPS"]) && $_SERVER[
"HTTPS"] ==
"on") ||
876 (!empty($_SERVER[
'SERVER_PORT']) && $_SERVER[
'SERVER_PORT'] == 443);
888 $protocol = $this->isHttps() ?
'https' :
'http';
890 if (isset($_SERVER[
"SERVER_PORT"])) {
891 $port =
':' . $_SERVER[
"SERVER_PORT"];
895 if ($port ==
':80' || $port ==
':443') {
898 $uri = isset($_SERVER[
'REQUEST_URI']) ? $_SERVER[
'REQUEST_URI'] :
'';
899 $cutoff = strpos($uri,
'install.php');
900 $uri = substr($uri, 0, $cutoff);
901 $serverName = isset($_SERVER[
'SERVER_NAME']) ? $_SERVER[
'SERVER_NAME'] :
'';
903 return "$protocol://{$serverName}$port{$uri}";
913 if (!include_once($this->getSettingsPath())) {
933 foreach ($_POST as $k => $v) {
966 $root = Directory\Local::root()->getPath();
969 if (0 === strpos($abs_path, $root)) {
970 $relative_path = substr($abs_path, strlen($root));
972 $relative_path = $abs_path;
974 $relative_path = rtrim($relative_path,
'/\\');
976 $writable = is_writable(
Directory\Local::root()->getPath(
'elgg-config'));
980 'severity' =>
'failure',
981 'message' =>
_elgg_services()->translator->translate(
'install:check:installdir', [$relative_path]),
1000 if (!file_exists($this->getSettingsPath())) {
1004 if (!is_readable($this->getSettingsPath())) {
1007 'severity' =>
'failure',
1008 'message' =>
_elgg_services()->translator->translate(
'install:check:readsettings'),
1021 private function getSettingsPath() {
1022 return Directory\Local::root()->getPath(
"elgg-config/settings.php");
1033 $phpReport = array();
1035 $min_php_version =
'5.5.0';
1036 if (version_compare(PHP_VERSION, $min_php_version,
'<')) {
1037 $phpReport[] = array(
1038 'severity' =>
'failure',
1039 'message' =>
_elgg_services()->translator->translate(
'install:check:php:version', array($min_php_version, PHP_VERSION))
1047 if (count($phpReport) == 0) {
1048 $phpReport[] = array(
1049 'severity' =>
'pass',
1050 'message' =>
_elgg_services()->translator->translate(
'install:check:php:success')
1066 $requiredExtensions = array(
1072 foreach ($requiredExtensions as
$extension) {
1074 $phpReport[] = array(
1075 'severity' =>
'failure',
1076 'message' =>
_elgg_services()->translator->translate(
'install:check:php:extension', array($extension))
1081 $recommendedExtensions = array(
1084 foreach ($recommendedExtensions as $extension) {
1086 $phpReport[] = array(
1087 'severity' =>
'warning',
1088 'message' =>
_elgg_services()->translator->translate(
'install:check:php:extension:recommend', array($extension))
1102 if (ini_get(
'open_basedir')) {
1103 $phpReport[] = array(
1104 'severity' =>
'warning',
1105 'message' =>
_elgg_services()->translator->translate(
"install:check:php:open_basedir")
1109 if (ini_get(
'safe_mode')) {
1110 $phpReport[] = array(
1111 'severity' =>
'warning',
1112 'message' =>
_elgg_services()->translator->translate(
"install:check:php:safe_mode")
1116 if (ini_get(
'arg_separator.output') !==
'&') {
1117 $separator = htmlspecialchars(ini_get(
'arg_separator.output'));
1118 $msg =
_elgg_services()->translator->translate(
"install:check:php:arg_separator", array($separator));
1119 $phpReport[] = array(
1120 'severity' =>
'failure',
1125 if (ini_get(
'register_globals')) {
1126 $phpReport[] = array(
1127 'severity' =>
'failure',
1128 'message' =>
_elgg_services()->translator->translate(
"install:check:php:register_globals")
1132 if (ini_get(
'session.auto_start')) {
1133 $phpReport[] = array(
1134 'severity' =>
'failure',
1135 'message' =>
_elgg_services()->translator->translate(
"install:check:php:session.auto_start")
1162 if (strpos($_SERVER[
'REQUEST_URI'],
'rewrite.php') !== FALSE) {
1163 echo \Elgg\Application::REWRITE_TEST_OUTPUT;
1178 foreach (
$report as $category => $checks) {
1179 foreach ($checks as $check) {
1180 if ($check[
'severity'] === $condition) {
1205 if (
$info[
'required'] == TRUE && !$submissionVars[
$field]) {
1217 if (!preg_match(
"/^[a-zA-Z_][\w]*$/", $submissionVars[
'dbprefix'])) {
1223 $submissionVars[
'dbuser'],
1224 $submissionVars[
'dbpassword'],
1225 $submissionVars[
'dbname'],
1226 $submissionVars[
'dbhost']
1241 $config = new \Elgg\Database\Config((
object)[
1245 'dbname' => $dbname,
1247 $db = new \Elgg\Database($config);
1250 $db->getDataRow(
"SELECT 1");
1252 if (0 === strpos($e->getMessage(),
"Elgg couldn't connect")) {
1261 $version = $db->getServerVersion(\
Elgg\Database\Config::READ_WRITE);
1262 $required_version = 5.0;
1264 if ($points[0] < $required_version) {
1286 foreach (
$params as $k => $v) {
1287 $template = str_replace(
"{{" . $k .
"}}", $v, $template);
1290 $result = file_put_contents($this->getSettingsPath(), $template);
1307 if (!include_once($this->getSettingsPath())) {
1308 register_error(
'Elgg could not load the settings file. It does not exist or there is a file permissions issue.');
1312 if (!include_once(\
Elgg\Application::elggDir()->getPath(
"engine/lib/database.php"))) {
1336 _elgg_services()->db->runSqlScript(\
Elgg\Application::elggDir()->getPath(
"/engine/schema/mysql.sql"));
1338 $msg = $e->getMessage();
1339 if (strpos($msg,
'already exists')) {
1340 $msg =
_elgg_services()->translator->translate(
'install:error:tables_exist');
1363 if ($formVars[
'dataroot'][
'type'] !=
'combo') {
1368 if ($submissionVars[
'dataroot'] !=
'dataroot-checkbox') {
1373 if (file_exists($dir) || mkdir($dir, 0700)) {
1374 $submissionVars[
'dataroot'] = $dir;
1375 if (!file_exists(
"$dir/.htaccess")) {
1376 $htaccess =
"Order Deny,Allow\nDeny from All\n";
1377 if (!file_put_contents(
"$dir/.htaccess", $htaccess)) {
1399 $submissionVars[
$field] = trim($submissionVars[
$field]);
1400 if (
$info[
'required'] == TRUE && $submissionVars[$field] ===
'') {
1408 if (stripos(PHP_OS,
'win') === 0) {
1409 if (strpos($submissionVars[
'dataroot'],
':') !== 1) {
1410 $msg =
_elgg_services()->translator->translate(
'install:error:relative_path', array($submissionVars[
'dataroot']));
1415 if (strpos($submissionVars[
'dataroot'],
'/') !== 0) {
1416 $msg =
_elgg_services()->translator->translate(
'install:error:relative_path', array($submissionVars[
'dataroot']));
1423 if (!file_exists($submissionVars[
'dataroot'])) {
1424 $msg =
_elgg_services()->translator->translate(
'install:error:datadirectoryexists', array($submissionVars[
'dataroot']));
1430 if (!is_writable($submissionVars[
'dataroot'])) {
1431 $msg =
_elgg_services()->translator->translate(
'install:error:writedatadirectory', array($submissionVars[
'dataroot']));
1436 if (!isset($this->CONFIG->data_dir_override) || !$this->CONFIG->data_dir_override) {
1438 if (stripos($submissionVars[
'dataroot'], $submissionVars[
'path']) === 0) {
1439 $msg =
_elgg_services()->translator->translate(
'install:error:locationdatadirectory', array($submissionVars[
'dataroot']));
1446 if ($submissionVars[
'siteemail'] && !
is_email_address($submissionVars[
'siteemail'])) {
1447 $msg =
_elgg_services()->translator->translate(
'install:error:emailaddress', array($submissionVars[
'siteemail']));
1473 $site->name = strip_tags($submissionVars[
'sitename']);
1474 $site->url = $submissionVars[
'wwwroot'];
1476 $site->email = $submissionVars[
'siteemail'];
1485 $this->CONFIG->site_guid =
$guid;
1486 $this->CONFIG->site_id =
$guid;
1487 $this->CONFIG->site =
$site;
1490 _elgg_services()->datalist->set(
'dataroot', $submissionVars[
'dataroot']);
1503 _elgg_services()->configTable->set(
'default_access', $submissionVars[
'siteaccess'],
$site->getGUID());
1526 add_subtype(
"object",
"elgg_upgrade",
'ElggUpgrade');
1537 foreach ($plugins as
$plugin) {
1538 if ($plugin->getManifest()) {
1539 if ($plugin->getManifest()->getActivateOnInstall()) {
1540 $plugin->activate();
1542 if (in_array(
'theme', $plugin->getManifest()->getCategories())) {
1543 $plugin->setPriority(
'last');
1564 if (
$info[
'required'] == TRUE && !$submissionVars[
$field]) {
1571 if ($submissionVars[
'password1'] !== $submissionVars[
'password2']) {
1576 if (trim($submissionVars[
'password1']) ==
"") {
1581 $minLength =
_elgg_services()->configTable->get(
'min_password_length');
1582 if (strlen($submissionVars[
'password1']) < $minLength) {
1588 if ($submissionVars[
'email'] && !
is_email_address($submissionVars[
'email'])) {
1589 $msg =
_elgg_services()->translator->translate(
'install:error:emailaddress', array($submissionVars[
'email']));
1608 $submissionVars[
'username'],
1609 $submissionVars[
'password1'],
1610 $submissionVars[
'displayname'],
1611 $submissionVars[
'email']
1630 if (
$user->makeAdmin() == FALSE) {
1647 '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.