57 require_once(dirname(__FILE__) .
"/ElggRewriteTester.php");
59 $this->isAction = isset($_SERVER[
'REQUEST_METHOD']) && $_SERVER[
'REQUEST_METHOD'] ===
'POST';
69 set_error_handler(
'_elgg_php_error_handler');
70 set_exception_handler(
'_elgg_php_exception_handler');
93 $msg =
elgg_echo(
'InstallationException:UnknownStep', array(
$step));
118 $this->autoLogin = (bool) $flag;
142 restore_error_handler();
143 restore_exception_handler();
146 'dbhost' =>
'localhost',
147 'dbprefix' =>
'elgg_',
154 $requiredParams = array(
166 foreach ($requiredParams as
$key) {
168 $msg =
elgg_echo(
'install:error:requiredfield', array(
$key));
176 if ($createHtaccess) {
178 if (!$rewriteTester->createHtaccess(
$params[
'wwwroot'],
$CONFIG->path)) {
185 if (!$this->status[
'config']) {
195 if (!$this->status[
'database']) {
280 $report[
'database'] = array(array(
281 'severity' =>
'info',
282 'message' =>
elgg_echo(
'install:check:database')
294 'num_failures' => $numFailures,
295 'num_warnings' => $numWarnings,
318 'dbpassword' => array(
319 'type' =>
'password',
330 'value' =>
'localhost',
342 $this->isAction = TRUE;
345 if ($this->isAction) {
376 $params = array(
'variables' => $formVars,);
401 'value' =>
'My New Community',
404 'siteemail' => array(
424 'siteaccess' => array(
438 if ($this->isAction) {
461 $this->
render(
'settings', array(
'variables' => $formVars));
473 protected function admin($submissionVars) {
475 'displayname' => array(
490 'password1' => array(
491 'type' =>
'password',
494 'pattern' =>
'.{6,}',
496 'password2' => array(
497 'type' =>
'password',
503 if ($this->isAction) {
523 $CONFIG->translations[
$lang][
'install:admin:help:password1'] =
524 sprintf(
$CONFIG->translations[
$lang][
'install:admin:help:password1'],
529 $this->
render(
'admin', array(
'variables' => $formVars));
540 if ($this->autoLogin) {
541 $params[
'destination'] =
'admin';
543 $params[
'destination'] =
'index.php';
570 $this->isAction = FALSE;
582 $index = 1 + array_search($currentStep, $this->steps);
583 if (isset($this->steps[$index])) {
584 return $this->steps[$index];
611 if (!is_readable(
"{$CONFIG->path}engine/settings.php")) {
617 $this->status[
'config'] = TRUE;
626 if ($dbSettingsPass == FALSE) {
630 if (!include_once(
"{$CONFIG->path}engine/lib/database.php")) {
635 $query =
"show tables";
640 if (in_array(
"{$CONFIG->dbprefix}config",
$table)) {
641 $this->status[
'database'] = TRUE;
644 if ($this->status[
'database'] == FALSE) {
653 $query =
"SELECT COUNT(*) AS total FROM {$CONFIG->dbprefix}config";
656 $this->status[
'settings'] = TRUE;
662 $query =
"SELECT COUNT(*) AS total FROM {$CONFIG->dbprefix}users_entity";
665 $this->status[
'admin'] = TRUE;
680 if (
$step !=
'complete') {
681 if (!in_array(FALSE, $this->status)) {
698 if (
$step !==
'welcome') {
702 if ($this->status[
'database'] == FALSE) {
706 if ($this->status[
'settings'] == FALSE) {
707 forward(
"install.php?step=settings");
710 if ($this->status[
'admin'] == FALSE) {
711 forward(
"install.php?step=admin");
715 forward(
"install.php?step=complete");
733 $required_files = array(
749 foreach ($required_files as $file) {
751 if (!include(
$path)) {
752 echo
"Could not load file '$path'. "
753 .
'Please check your Elgg installation for all required files.';
770 $dbIndex = array_search(
'database', $this->
getSteps());
771 $settingsIndex = array_search(
'settings', $this->
getSteps());
772 $adminIndex = array_search(
'admin', $this->
getSteps());
773 $completeIndex = array_search(
'complete', $this->
getSteps());
779 $stepIndex == $completeIndex;
780 if (!$useElggSession) {
781 session_name(
'Elgg_install');
786 if ($stepIndex > $dbIndex) {
816 'private_settings.php',
826 'deprecated-1.7.php',
827 'deprecated-1.8.php',
828 'deprecated-1.9.php',
833 if (!include_once(
$path)) {
841 if ($stepIndex > $settingsIndex) {
865 $CONFIG->url =
$CONFIG->wwwroot;
866 $CONFIG->path = dirname(dirname(__FILE__)) .
'/';
870 $CONFIG->entity_types = array(
'group',
'object',
'site',
'user');
879 private function isHttps() {
880 return (!empty($_SERVER[
"HTTPS"]) && $_SERVER[
"HTTPS"] ==
"on") ||
881 $_SERVER[
'SERVER_PORT'] == 443;
893 $protocol = $this->isHttps() ?
'https' :
'http';
895 if (isset($_SERVER[
"SERVER_PORT"])) {
896 $port =
':' . $_SERVER[
"SERVER_PORT"];
900 if ($port ==
':80' || $port ==
':443') {
903 $uri = isset($_SERVER[
'REQUEST_URI']) ? $_SERVER[
'REQUEST_URI'] :
'';
904 $cutoff = strpos($uri,
'install.php');
905 $uri = substr($uri, 0, $cutoff);
906 $serverName = isset($_SERVER[
'SERVER_NAME']) ? $_SERVER[
'SERVER_NAME'] :
'';
908 return "$protocol://{$serverName}$port{$uri}";
920 if (!include_once(
"{$CONFIG->path}engine/settings.php")) {
940 foreach ($_POST as $k => $v) {
955 foreach ($submissionVars as $field =>
$value) {
956 $formVars[$field][
'value'] =
$value;
975 $writable = is_writable(
"{$CONFIG->path}engine");
979 'severity' =>
'failure',
980 'message' =>
elgg_echo(
'install:check:enginedir'),
999 if (!file_exists(
"{$CONFIG->path}engine/settings.php")) {
1003 if (!is_readable(
"{$CONFIG->path}engine/settings.php")) {
1006 'severity' =>
'failure',
1007 'message' =>
elgg_echo(
'install:check:readsettings'),
1023 $phpReport = array();
1025 $elgg_php_version =
'5.2.0';
1026 if (version_compare(PHP_VERSION, $elgg_php_version,
'<')) {
1027 $phpReport[] = array(
1028 'severity' =>
'failure',
1029 'message' =>
elgg_echo(
'install:check:php:version', array($elgg_php_version, PHP_VERSION))
1037 if (count($phpReport) == 0) {
1038 $phpReport[] = array(
1039 'severity' =>
'pass',
1040 'message' =>
elgg_echo(
'install:check:php:success')
1056 $requiredExtensions = array(
1062 foreach ($requiredExtensions as
$extension) {
1064 $phpReport[] = array(
1065 'severity' =>
'failure',
1071 $recommendedExtensions = array(
1074 foreach ($recommendedExtensions as
$extension) {
1076 $phpReport[] = array(
1077 'severity' =>
'warning',
1092 if (ini_get(
'open_basedir')) {
1093 $phpReport[] = array(
1094 'severity' =>
'warning',
1095 'message' =>
elgg_echo(
"install:check:php:open_basedir")
1099 if (ini_get(
'safe_mode')) {
1100 $phpReport[] = array(
1101 'severity' =>
'warning',
1102 'message' =>
elgg_echo(
"install:check:php:safe_mode")
1106 if (ini_get(
'arg_separator.output') !==
'&') {
1107 $separator = htmlspecialchars(ini_get(
'arg_separator.output'));
1108 $msg =
elgg_echo(
"install:check:php:arg_separator", array($separator));
1109 $phpReport[] = array(
1110 'severity' =>
'failure',
1115 if (ini_get(
'register_globals')) {
1116 $phpReport[] = array(
1117 'severity' =>
'failure',
1118 'message' =>
elgg_echo(
"install:check:php:register_globals")
1122 if (ini_get(
'session.auto_start')) {
1123 $phpReport[] = array(
1124 'severity' =>
'failure',
1125 'message' =>
elgg_echo(
"install:check:php:session.auto_start")
1152 if (strpos($_SERVER[
'REQUEST_URI'],
'rewrite.php') !== FALSE) {
1168 foreach (
$report as $category => $checks) {
1169 foreach ($checks as $check) {
1170 if ($check[
'severity'] === $condition) {
1194 foreach ($formVars as $field => $info) {
1195 if ($info[
'required'] == TRUE && !$submissionVars[$field]) {
1207 if (!preg_match(
"/^[a-zA-Z_][\w]*$/", $submissionVars[
'dbprefix'])) {
1213 $submissionVars[
'dbuser'],
1214 $submissionVars[
'dbpassword'],
1215 $submissionVars[
'dbname'],
1216 $submissionVars[
'dbhost']
1232 if ($mysql_dblink == FALSE) {
1237 $result = mysql_select_db($dbname, $mysql_dblink);
1240 $required_version = 5.0;
1241 $version = mysql_get_server_info();
1243 if ($points[0] < $required_version) {
1248 mysql_close($mysql_dblink);
1267 $templateFile =
"{$CONFIG->path}engine/settings.example.php";
1268 $template = file_get_contents($templateFile);
1274 foreach (
$params as $k => $v) {
1275 $template = str_replace(
"{{" . $k .
"}}", $v, $template);
1278 $settingsFilename =
"{$CONFIG->path}engine/settings.php";
1279 $result = file_put_contents($settingsFilename, $template);
1296 if (!include_once(
"{$CONFIG->path}engine/settings.php")) {
1297 register_error(
'Elgg could not load the settings file. It does not exist or there is a file permissions issue.');
1301 if (!include_once(
"{$CONFIG->path}engine/lib/database.php")) {
1326 }
catch (Exception
$e) {
1327 $msg =
$e->getMessage();
1328 if (strpos($msg,
'already exists')) {
1329 $msg =
elgg_echo(
'install:error:tables_exist');
1351 if ($formVars[
'dataroot'][
'type'] !=
'combo') {
1356 if ($submissionVars[
'dataroot'] !=
'dataroot-checkbox') {
1361 if (file_exists($dir) || mkdir($dir, 0700)) {
1362 $submissionVars[
'dataroot'] = $dir;
1363 if (!file_exists(
"$dir/.htaccess")) {
1364 $htaccess =
"Order Deny,Allow\nDeny from All\n";
1365 if (!file_put_contents(
"$dir/.htaccess", $htaccess)) {
1386 foreach ($formVars as $field => $info) {
1387 $submissionVars[$field] = trim($submissionVars[$field]);
1388 if ($info[
'required'] == TRUE && $submissionVars[$field] ===
'') {
1396 if (stripos(PHP_OS,
'win') === 0) {
1397 if (strpos($submissionVars[
'dataroot'],
':') !== 1) {
1398 $msg =
elgg_echo(
'install:error:relative_path', array($submissionVars[
'dataroot']));
1403 if (strpos($submissionVars[
'dataroot'],
'/') !== 0) {
1404 $msg =
elgg_echo(
'install:error:relative_path', array($submissionVars[
'dataroot']));
1411 if (!file_exists($submissionVars[
'dataroot'])) {
1412 $msg =
elgg_echo(
'install:error:datadirectoryexists', array($submissionVars[
'dataroot']));
1418 if (!is_writable($submissionVars[
'dataroot'])) {
1419 $msg =
elgg_echo(
'install:error:writedatadirectory', array($submissionVars[
'dataroot']));
1424 if (!isset(
$CONFIG->data_dir_override) || !
$CONFIG->data_dir_override) {
1426 if (stripos($submissionVars[
'dataroot'], $submissionVars[
'path']) === 0) {
1427 $msg =
elgg_echo(
'install:error:locationdatadirectory', array($submissionVars[
'dataroot']));
1434 if ($submissionVars[
'siteemail'] && !
is_email_address($submissionVars[
'siteemail'])) {
1435 $msg =
elgg_echo(
'install:error:emailaddress', array($submissionVars[
'siteemail']));
1462 $site->name = strip_tags($submissionVars[
'sitename']);
1463 $site->url = $submissionVars[
'wwwroot'];
1465 $site->email = $submissionVars[
'siteemail'];
1493 set_config(
'default_access', $submissionVars[
'siteaccess'],
$site->getGUID());
1515 add_subtype(
"object",
"elgg_upgrade",
'ElggUpgrade');
1528 if (
$plugin->getManifest()->getActivateOnInstall()) {
1531 if (in_array(
'theme',
$plugin->getManifest()->getCategories())) {
1552 foreach ($formVars as $field => $info) {
1553 if ($info[
'required'] == TRUE && !$submissionVars[$field]) {
1560 if ($submissionVars[
'password1'] !== $submissionVars[
'password2']) {
1565 if (trim($submissionVars[
'password1']) ==
"") {
1570 $minLength =
get_config(
'min_password_length');
1571 if (strlen($submissionVars[
'password1']) < $minLength) {
1577 if ($submissionVars[
'email'] && !
is_email_address($submissionVars[
'email'])) {
1578 $msg =
elgg_echo(
'install:error:emailaddress', array($submissionVars[
'email']));
1597 $submissionVars[
'username'],
1598 $submissionVars[
'password1'],
1599 $submissionVars[
'displayname'],
1600 $submissionVars[
'email']
1602 }
catch (Exception
$e) {
1619 if (
$user->makeAdmin() == FALSE) {
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.
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.
checkEngineDir(&$report)
Requirement checks support methods.
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.
datalist_get($name)
Get the value of a datalist element.
datalist_set($name, $value)
Set the value for a datalist element.
elgg_get_site_url($site_guid=0)
Get the URL for the current (or specified) site.
set_config($name, $value, $site_guid=0)
Add or update a config setting.
get_config($name, $site_guid=0)
Gets a configuration value.
$guid
Removes an admin notice.
register_error($error)
Display an error on next page load.
elgg_trigger_event($event, $object_type, $object=null)
Trigger an Elgg Event and attempt to run all handler callbacks registered to that event,...
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.
elgg_unregister_event_handler($event, $object_type, $callback)
Unregisters a callback for an event.
forward($location="", $reason='system')
Forward to $location.
elgg_set_ignore_access($ignore=true)
Set if Elgg's access system should be ignored.
get_data($query, $callback="")
Retrieve rows from the database.
run_sql_script($scriptlocation)
Runs a full database script from disk.
get_current_language()
Detect the current language being used by the current site or logged in user.
elgg_echo($message_key, $args=array(), $language="")
Given a message key, returns an appropriately translated full-text string.
register_translations($path, $load_all=false)
When given a full path, finds translation files and loads them.
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.
_elgg_session_boot()
Initializes the session and checks for the remember me cookie.
login(ElggUser $user, $persistent=false)
Logs in a specified ElggUser.
if(file_exists($welcome)) $vars
$upgrades
Lists pending upgrades.
register_user($username, $password, $name, $email, $allow_multiple_emails=false)
Registers a user, returning false if the username already exists.
elgg_view_page($title, $body, $page_shell='default', $vars=array())
Assembles and outputs a full page.
elgg_view($view, $vars=array(), $bypass=false, $ignored=false, $viewtype='')
Return a parsed view.
elgg_set_viewtype($viewtype="")
Manually set the viewtype.