\n"; $header .= "\n"; $header .= "\n"; if(isset($_GET['cookietest'])) { print $header; print "\n"; if(isset($_COOKIE['cookietest'])) print "Successfully set a test cookie\n"; else print "Failed to set a test cookie\n"; print "\n"; exit; } if(isset($_GET['includeconftest'])) { if(! is_readable('.ht-inc/conf.php')) { print "unreadable"; exit; } if(include('.ht-inc/conf.php')) print 'worked'; exit; } if(isset($_GET['includesecretstest'])) { if(! is_readable('.ht-inc/secrets.php')) { print "unreadable"; exit; } if(include('.ht-inc/secrets.php')) print 'worked'; exit; } $header .= "\n"; function exHandler($errno, $errmsg) { print "Error: $errmsg
"; } set_error_handler('exHandler'); function pass($msg) { print "
  • $msg
  • \n"; } function fail($msg) { print "
  • $msg
  • \n"; } function title($msg) { print "$msg ...
    \n"; } $myurl = "http://"; if(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == "on") $myurl = "https://"; $myurl .= $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; $includesecrets = 1; $includeconf = 1; if(! ip2long(getHostbyname($_SERVER['HTTP_HOST']))) { print $header; # php version print "PHP version: " . phpversion() . "

    \n"; title("Trying to resolve my hostname ({$_SERVER['HTTP_HOST']})"); print "\n"; $includesecrets = 0; $includeconf = 0; } # test including secrets.php $allowurlopen = ini_get('allow_url_fopen'); if($includesecrets) { $data = ''; if($fp = fopen("$myurl?includesecretstest=1", 'r')) { $data = fread($fp, 100); fclose($fp); } if($allowurlopen && (empty($data) || $data == 'unreadable')) { print $header; # php version print "PHP version: " . phpversion() . "

    \n"; title("Including .ht-inc/secrets.php"); print "\n"; $includesecrets = 0; $includeconf = 0; } } else { title("Including .ht-inc/secrets.php"); print "\n"; } # conf.php test if($includeconf) { $data = ''; if($fp = fopen("$myurl?includeconftest=1", 'r')) { $data = fread($fp, 100); fclose($fp); } $allowurlopen = ini_get('allow_url_fopen'); if($allowurlopen && (empty($data) || $data == 'unreadable')) { print $header; # php version print "PHP version: " . phpversion() . "

    \n"; title("Including .ht-inc/conf.php"); print "\n"; $includeconf = 0; } } else { title("Including .ht-inc/conf.php"); print "\n"; } # conf.php tests if($includeconf && include('.ht-inc/conf.php')) { $host = $_SERVER['HTTP_HOST']; if(! defined('COOKIEDOMAIN')) { print $header; # php version print "PHP version: " . phpversion() . "

    \n"; title("Including .ht-inc/conf.php"); print "\n"; title("Checking COOKIEDOMAIN setting in .ht-inc/conf.php"); print "\n"; } else { $len = strlen(COOKIEDOMAIN); if($len && substr_compare($host, COOKIEDOMAIN, 0 - $len, $len, true) != 0) { print $header; # php version print "PHP version: " . phpversion() . "

    \n"; title("Including .ht-inc/conf.php"); print "\n"; title("Checking COOKIEDOMAIN setting in .ht-inc/conf.php"); print "\n"; } else { $expire = time() + 10; setcookie("cookietest", 1, $expire, '/', COOKIEDOMAIN); print $header; # php version print "PHP version: " . phpversion() . "

    \n"; title("Including .ht-inc/conf.php"); print "\n"; title("Checking COOKIEDOMAIN setting in .ht-inc/conf.php"); print "\n"; } } # check for BASEURL starting with https title("Checking that BASEURL in conf.php is set to use https"); print "\n"; # check for SCRIPT being set title("Checking that SCRIPT is set appropriately"); print "\n"; # check for existance of maintenance directory title("Checking that .ht-inc/maintenance directory exists"); print "\n"; # check that we can write files to maintenance directory title("Checking that .ht-inc/maintenance directory is writable"); print "\n"; } # required extentions title("Testing for required php extensions"); if(version_compare(phpversion(), "5.2", "<")) $requiredexts = array('gd', 'mcrypt', 'mysql', 'openssl', 'sysvsem', 'xml', 'xmlrpc', 'session', 'pcre', 'sockets', 'ldap'); else $requiredexts = array('gd', 'mcrypt', 'mysql', 'openssl', 'sysvsem', 'xml', 'xmlrpc', 'session', 'pcre', 'sockets', 'json', 'ldap'); $exts = get_loaded_extensions(); $diff = array_diff($requiredexts, $exts); print "\n"; # secrets.php file and mysql connection if($includesecrets && include('.ht-inc/secrets.php')) { title("Checking values in .ht-inc/secrets.php"); print "\n"; if($trymysqlconnect && in_array('mysql', $exts) && in_array('sockets', $exts)) { title("Testing mysql connection"); print "\n"; } } # test mcrypt title("Testing mcrypt"); print "\n"; # encryption keys $privkeyok = 0; $pubkeyok = 0; if(in_array('openssl', $exts)) { title("checking openssl encryption keys"); print "\n"; title("Testing openssl encryption"); print "\n"; } # check dojo directories title("Testing for existance of dojo directory"); print "\n"; # check for jpgraph directory title("Testing for existance of jpgraph directory"); print "\n"; # php display errors title("Checking value of PHP display_errors"); $a = ini_get('display_errors'); print " \n"; ?>