fix #136, annoying warnings when is enabled open_basedir or disabled url fopen
[elgg.git] / sanitychecks.php
blobb199cfc6d1694478076de3aeea38acee1e2c8877
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 (/).';
32 if (ini_get('register_globals')) {
33 // this shouldn't be needed due to the htaccess file, but just in case...
34 $diemessages[] = "
35 Configuration problem: The PHP setting 'register_globals', which is a huge security risk, is turned on.
36 There should be a line in the .htaccess file as follows: <code>php_flag register_globals off</code>
37 If the line is present but has a # at the start, remove the # character.
42 switch ($CFG->dbtype) {
43 case 'mysql':
44 $funcheck = 'mysql_query';
45 break;
46 case 'postgres7':
47 $funcheck = 'pg_query';
48 break;
50 if (!function_exists($funcheck)) {
51 // people have been having a spot of trouble installing elgg without the mysql php module...
52 $diemessages[] = "
53 Installation problem: Can't find the PHP MySQL or Postgresql module.
54 Even with PHP and MySQL or Postgresql installed, sometimes the module to connect them is missing.
55 Please check your PHP installation.
60 if (count($diemessages)) {
61 $diebody = '<html><body><h1>Elgg isn\'t ready to run. :(</h1><ul>';
62 $diebody .= '<li>' . implode("</li><li>", $diemessages) . '</li>';
63 $diebody .= '</ul><p>Please read the INSTALL and config-dist.php files for more information,';
64 $diebody .= '<a href="_elggadmin/">or click here to use the friendly installer</a>.</p>';
65 $diebody .= '</body></html>';
66 die($diebody);
67 } else {
68 unset($diemessages);