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');
856 $this->CONFIG->sitename =
'';
857 $this->CONFIG->sitedescription =
'';
863 private function isHttps() {
864 return (!empty($_SERVER[
"HTTPS"]) && $_SERVER[
"HTTPS"] ==
"on") ||
865 $_SERVER[
'SERVER_PORT'] == 443;
877 $protocol = $this->isHttps() ?
'https' :
'http';
879 if (isset($_SERVER[
"SERVER_PORT"])) {
880 $port =
':' . $_SERVER[
"SERVER_PORT"];
884 if ($port ==
':80' || $port ==
':443') {
887 $uri = isset($_SERVER[
'REQUEST_URI']) ? $_SERVER[
'REQUEST_URI'] :
'';
888 $cutoff = strpos($uri,
'install.php');
889 $uri = substr($uri, 0, $cutoff);
890 $serverName = isset($_SERVER[
'SERVER_NAME']) ? $_SERVER[
'SERVER_NAME'] :
'';
892 return "$protocol://{$serverName}$port{$uri}";
904 if (!include_once(
"{$this->CONFIG->path}engine/settings.php")) {
924 foreach ($_POST as $k => $v) {
939 foreach ($submissionVars as $field =>
$value) {
940 $formVars[$field][
'value'] =
$value;
959 $writable = is_writable(
"{$this->CONFIG->path}engine");
963 'severity' =>
'failure',
964 'message' =>
_elgg_services()->translator->translate(
'install:check:enginedir'),
983 if (!file_exists(
"{$this->CONFIG->path}engine/settings.php")) {
987 if (!is_readable(
"{$this->CONFIG->path}engine/settings.php")) {
990 'severity' =>
'failure',
991 'message' =>
_elgg_services()->translator->translate(
'install:check:readsettings'),
1007 $phpReport = array();
1009 $min_php_version =
'5.4.0';
1010 if (version_compare(PHP_VERSION, $min_php_version,
'<')) {
1011 $phpReport[] = array(
1012 'severity' =>
'failure',
1013 'message' =>
_elgg_services()->translator->translate(
'install:check:php:version', array($min_php_version, PHP_VERSION))
1021 if (count($phpReport) == 0) {
1022 $phpReport[] = array(
1023 'severity' =>
'pass',
1024 'message' =>
_elgg_services()->translator->translate(
'install:check:php:success')
1040 $requiredExtensions = array(
1046 foreach ($requiredExtensions as
$extension) {
1048 $phpReport[] = array(
1049 'severity' =>
'failure',
1050 'message' =>
_elgg_services()->translator->translate(
'install:check:php:extension', array($extension))
1055 $recommendedExtensions = array(
1058 foreach ($recommendedExtensions as $extension) {
1060 $phpReport[] = array(
1061 'severity' =>
'warning',
1062 'message' =>
_elgg_services()->translator->translate(
'install:check:php:extension:recommend', array($extension))
1076 if (ini_get(
'open_basedir')) {
1077 $phpReport[] = array(
1078 'severity' =>
'warning',
1079 'message' =>
_elgg_services()->translator->translate(
"install:check:php:open_basedir")
1083 if (ini_get(
'safe_mode')) {
1084 $phpReport[] = array(
1085 'severity' =>
'warning',
1086 'message' =>
_elgg_services()->translator->translate(
"install:check:php:safe_mode")
1090 if (ini_get(
'arg_separator.output') !==
'&') {
1091 $separator = htmlspecialchars(ini_get(
'arg_separator.output'));
1092 $msg =
_elgg_services()->translator->translate(
"install:check:php:arg_separator", array($separator));
1093 $phpReport[] = array(
1094 'severity' =>
'failure',
1099 if (ini_get(
'register_globals')) {
1100 $phpReport[] = array(
1101 'severity' =>
'failure',
1102 'message' =>
_elgg_services()->translator->translate(
"install:check:php:register_globals")
1106 if (ini_get(
'session.auto_start')) {
1107 $phpReport[] = array(
1108 'severity' =>
'failure',
1109 'message' =>
_elgg_services()->translator->translate(
"install:check:php:session.auto_start")
1126 $report[
'rewrite'] = array($tester->run(
$url, $this->CONFIG->path));
1136 if (strpos($_SERVER[
'REQUEST_URI'],
'rewrite.php') !== FALSE) {
1152 foreach (
$report as $category => $checks) {
1153 foreach ($checks as $check) {
1154 if ($check[
'severity'] === $condition) {
1178 foreach ($formVars as $field => $info) {
1179 if ($info[
'required'] == TRUE && !$submissionVars[$field]) {
1191 if (!preg_match(
"/^[a-zA-Z_][\w]*$/", $submissionVars[
'dbprefix'])) {
1197 $submissionVars[
'dbuser'],
1198 $submissionVars[
'dbpassword'],
1199 $submissionVars[
'dbname'],
1200 $submissionVars[
'dbhost']
1216 if ($mysql_dblink == FALSE) {
1221 $result = mysql_select_db($dbname, $mysql_dblink);
1224 $required_version = 5.0;
1225 $version = mysql_get_server_info();
1227 if ($points[0] < $required_version) {
1232 mysql_close($mysql_dblink);
1251 $templateFile =
"{$this->CONFIG->path}engine/settings.example.php";
1252 $template = file_get_contents($templateFile);
1258 foreach (
$params as $k => $v) {
1259 $template = str_replace(
"{{" . $k .
"}}", $v, $template);
1262 $settingsFilename =
"{$this->CONFIG->path}engine/settings.php";
1263 $result = file_put_contents($settingsFilename, $template);
1280 if (!include_once(
"{$this->CONFIG->path}engine/settings.php")) {
1281 register_error(
'Elgg could not load the settings file. It does not exist or there is a file permissions issue.');
1285 if (!include_once(
"{$this->CONFIG->path}engine/lib/database.php")) {
1309 _elgg_services()->db->runSqlScript(
"{$this->CONFIG->path}engine/schema/mysql.sql");
1311 $msg = $e->getMessage();
1312 if (strpos($msg,
'already exists')) {
1313 $msg =
_elgg_services()->translator->translate(
'install:error:tables_exist');
1336 if ($formVars[
'dataroot'][
'type'] !=
'combo') {
1341 if ($submissionVars[
'dataroot'] !=
'dataroot-checkbox') {
1346 if (file_exists($dir) || mkdir($dir, 0700)) {
1347 $submissionVars[
'dataroot'] = $dir;
1348 if (!file_exists(
"$dir/.htaccess")) {
1349 $htaccess =
"Order Deny,Allow\nDeny from All\n";
1350 if (!file_put_contents(
"$dir/.htaccess", $htaccess)) {
1371 foreach ($formVars as $field => $info) {
1372 $submissionVars[$field] = trim($submissionVars[$field]);
1373 if ($info[
'required'] == TRUE && $submissionVars[$field] ===
'') {
1381 if (stripos(PHP_OS,
'win') === 0) {
1382 if (strpos($submissionVars[
'dataroot'],
':') !== 1) {
1383 $msg =
_elgg_services()->translator->translate(
'install:error:relative_path', array($submissionVars[
'dataroot']));
1388 if (strpos($submissionVars[
'dataroot'],
'/') !== 0) {
1389 $msg =
_elgg_services()->translator->translate(
'install:error:relative_path', array($submissionVars[
'dataroot']));
1396 if (!file_exists($submissionVars[
'dataroot'])) {
1397 $msg =
_elgg_services()->translator->translate(
'install:error:datadirectoryexists', array($submissionVars[
'dataroot']));
1403 if (!is_writable($submissionVars[
'dataroot'])) {
1404 $msg =
_elgg_services()->translator->translate(
'install:error:writedatadirectory', array($submissionVars[
'dataroot']));
1409 if (!isset($this->CONFIG->data_dir_override) || !$this->CONFIG->data_dir_override) {
1411 if (stripos($submissionVars[
'dataroot'], $submissionVars[
'path']) === 0) {
1412 $msg =
_elgg_services()->translator->translate(
'install:error:locationdatadirectory', array($submissionVars[
'dataroot']));
1419 if ($submissionVars[
'siteemail'] && !
is_email_address($submissionVars[
'siteemail'])) {
1420 $msg =
_elgg_services()->translator->translate(
'install:error:emailaddress', array($submissionVars[
'siteemail']));
1447 $site->name = strip_tags($submissionVars[
'sitename']);
1448 $site->url = $submissionVars[
'wwwroot'];
1450 $site->email = $submissionVars[
'siteemail'];
1459 $this->CONFIG->site_guid =
$guid;
1460 $this->CONFIG->site_id =
$guid;
1461 $this->CONFIG->site =
$site;
1464 _elgg_services()->datalist->set(
'path', $submissionVars[
'path']);
1465 _elgg_services()->datalist->set(
'dataroot', $submissionVars[
'dataroot']);
1470 _elgg_services()->datalist->set(
'simplecache_lastupdate', time());
1478 _elgg_services()->configTable->set(
'default_access', $submissionVars[
'siteaccess'],
$site->getGUID());
1501 add_subtype(
"object",
"elgg_upgrade",
'ElggUpgrade');
1513 if ($plugin->getManifest()) {
1514 if ($plugin->getManifest()->getActivateOnInstall()) {
1515 $plugin->activate();
1517 if (in_array(
'theme', $plugin->getManifest()->getCategories())) {
1518 $plugin->setPriority(
'last');
1538 foreach ($formVars as $field => $info) {
1539 if ($info[
'required'] == TRUE && !$submissionVars[$field]) {
1546 if ($submissionVars[
'password1'] !== $submissionVars[
'password2']) {
1551 if (trim($submissionVars[
'password1']) ==
"") {
1556 $minLength =
_elgg_services()->configTable->get(
'min_password_length');
1557 if (strlen($submissionVars[
'password1']) < $minLength) {
1563 if ($submissionVars[
'email'] && !
is_email_address($submissionVars[
'email'])) {
1564 $msg =
_elgg_services()->translator->translate(
'install:error:emailaddress', array($submissionVars[
'email']));
1583 $submissionVars[
'username'],
1584 $submissionVars[
'password1'],
1585 $submissionVars[
'displayname'],
1586 $submissionVars[
'email']
1605 if (
$user->makeAdmin() == FALSE) {
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.
if(!$autoload_available) _elgg_services()
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.
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.