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