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');
87 $CONFIG->language =
'en';
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_',
148 'path' => $CONFIG->path,
152 $params = array_merge(
$defaults, $params);
154 $requiredParams = array(
166 foreach ($requiredParams as
$key) {
167 if (empty($params[$key])) {
168 $msg =
elgg_echo(
'install:error:requiredfield', array($key));
174 $params[
'password1'] = $params[
'password2'] = $params[
'password'];
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(
416 'value' => $CONFIG->path,
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'],
525 $CONFIG->min_password_length);
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";
639 $table = (array) $table;
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");
730 $lib_dir = $CONFIG->path .
'engine/lib/';
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) {
789 $lib_dir = $CONFIG->path .
'engine/lib/';
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) {
842 $CONFIG->site_guid = (int)
datalist_get(
'default_site');
843 $CONFIG->site_id = $CONFIG->site_guid;
844 $CONFIG->site =
get_entity($CONFIG->site_guid);
860 if (!isset($CONFIG)) {
861 $CONFIG =
new stdClass;
865 $CONFIG->url = $CONFIG->wwwroot;
866 $CONFIG->path = dirname(dirname(__FILE__)) .
'/';
867 $CONFIG->viewpath = $CONFIG->path .
'views/';
868 $CONFIG->pluginspath = $CONFIG->path .
'mod/';
869 $CONFIG->context = array();
870 $CONFIG->entity_types = array(
'group',
'object',
'site',
'user');
872 $CONFIG->sitename =
'';
873 $CONFIG->sitedescription =
'';
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',
1066 'message' =>
elgg_echo(
'install:check:php:extension', array($extension))
1071 $recommendedExtensions = array(
1074 foreach ($recommendedExtensions as $extension) {
1076 $phpReport[] = array(
1077 'severity' =>
'warning',
1078 'message' =>
elgg_echo(
'install:check:php:extension:recommend', array($extension))
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")
1142 $report[
'rewrite'] = array($tester->run(
$url, $CONFIG->path));
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'];
1474 $CONFIG->site_guid =
$guid;
1475 $CONFIG->site_id =
$guid;
1476 $CONFIG->site =
$site;
1493 set_config(
'default_access', $submissionVars[
'siteaccess'],
$site->getGUID());
1515 add_subtype(
"object",
"elgg_upgrade",
'ElggUpgrade');
1527 if ($plugin->getManifest()) {
1528 if ($plugin->getManifest()->getActivateOnInstall()) {
1529 $plugin->activate();
1531 if (in_array(
'theme', $plugin->getManifest()->getCategories())) {
1532 $plugin->setPriority(
'last');
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) {
checkSettingsFile(&$report=array())
Check that the settings file exists.
get_current_language()
Detect the current language being used by the current site or logged in user.
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.
get_config($name, $site_guid=0)
Gets a configuration value.
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 ElggEntities 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_echo($message_key, $args=array(), $language="")
Given a message key, returns an appropriately translated full-text string.
elgg_set_ignore_access($ignore=true)
Set if Elgg's access system should be ignored.
datalist_get($name)
Get the value of a datalist element.
makeFormSticky($formVars, $submissionVars)
If form is reshown, remember previously submitted variables.
datalist_set($name, $value)
Set the value for a datalist element.
elgg echo
Translates a string.
checkPhpExtensions(&$phpReport)
Check the server's PHP extensions.
elgg global
Pointer to the global context.
elgg_get_site_url($site_guid=0)
Get the URL for the current (or specified) site.
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.
login(ElggUser $user, $persistent=false)
Logs in a specified ElggUser.
validateDatabaseVars($submissionVars, $formVars)
Database support methods.
elgg system_message
Wrapper function for system_messages.
createSettingsFile($params)
Writes the settings file to the engine directory.
run_sql_script($scriptlocation)
Runs a full database script from disk.
get_data($query, $callback="")
Retrieve rows from the database.
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.
register_translations($path, $load_all=false)
When given a full path, finds translation files and loads them.
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
elgg_trigger_event($event, $object_type, $object=null)
Trigger an Elgg Event and attempt to run all handler callbacks registered to that event...
database($submissionVars)
Database set up controller.
elgg_unregister_event_handler($event, $object_type, $callback)
Unregisters a callback for an event.
run($step)
Dispatches a request to one of the step controllers.
_elgg_generate_plugin_entities()
Discovers plugins in the plugins_path setting and creates ElggPlugin entities for them if they don't ...
get_entity($guid)
Loads and returns an entity object from a guid.
if(file_exists($welcome)) $vars
validateAdminVars($submissionVars, $formVars)
Admin account support methods.
set_config($name, $value, $site_guid=0)
Add or update a config setting.