/
sanitychecks.php
executable file
·86 lines (67 loc) · 3.48 KB
/
sanitychecks.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<?php
// Sanity checks - conditions under which Elgg will refuse to run
global $CFG;
$diemessages = array();
if ($CFG->dirroot == "") {
$diemessages[] = 'Configuration problem: The <code>$CFG->dirroot</code> setting in config.php is empty.';
} elseif (substr($CFG->dirroot, -1) != "/") {
$diemessages[] = 'Configuration problem: The <code>$CFG->dirroot</code> setting in config.php must end with a forward slash (/).';
} elseif (!file_exists($CFG->dirroot)) {
//this needs checking now, because includes.php needs it to work
$diemessages[] = 'Configuration problem: The <code>$CFG->dirroot</code> setting in config.php points to a directory that does not exist.';
} elseif (!is_dir($CFG->dirroot)) {
$diemessages[] = 'Configuration problem: The <code>$CFG->dirroot</code> setting in config.php points to a location that is not a directory.';
}
if (!preg_match('#^https?://.+#', $CFG->wwwroot)) {
$diemessages[] = 'Configuration problem: The <code>$CFG->wwwroot</code> setting in config.php is empty or not a valid URL.';
} elseif (substr($CFG->wwwroot, -1) != "/") {
$diemessages[] = 'Configuration problem: The <code>$CFG->wwwroot</code> setting in config.php must end with a forward slash (/).';
}
if ($CFG->dataroot == "") {
$diemessages[] = 'Configuration problem: The <code>$CFG->dataroot</code> setting in config.php is empty.';
} elseif (substr($CFG->dataroot, -1) != "/") {
$diemessages[] = 'Configuration problem: The <code>$CFG->dataroot</code> setting in config.php must end with a forward slash (/).';
}
// Set defaults for some variables
if (!isset($CFG->publicinvite)) {
$CFG->publicinvite = $CFG->publicreg;
}
if (!isset($CFG->emailfilter)) {
$CFG->emailfilter = "";
}
if (!isset($CFG->walledgarden)) {
$CFG->walledgarden = 0;
}
if (ini_get('register_globals')) {
// this shouldn't be needed due to the htaccess file, but just in case...
$diemessages[] = "
Configuration problem: The PHP setting 'register_globals', which is a huge security risk, is turned on.
There should be a line in the .htaccess file as follows: <code>php_flag register_globals off</code>
If the line is present but has a # at the start, remove the # character.
";
}
switch ($CFG->dbtype) {
case 'mysql':
$funcheck = 'mysql_query';
break;
case 'postgres7':
$funcheck = 'pg_query';
break;
}
if (!function_exists($funcheck)) {
// people have been having a spot of trouble installing elgg without the mysql php module...
$diemessages[] = "
Installation problem: Can't find the PHP MySQL or Postgresql module.
Even with PHP and MySQL or Postgresql installed, sometimes the module to connect them is missing.
Please check your PHP installation.
";
}
if (count($diemessages)) {
$diebody = '<html><body><h1>Error - Elgg cannot run</h1><ul>';
$diebody .= '<li>' . implode("</li><li>", $diemessages) . '</li>';
$diebody .= '</ul><p>Please read the INSTALL and config-dist.php files for more information.</p></body></html>';
die($diebody);
} else {
unset($diemessages);
}
?>