";
if (!$_REQUEST['parser_test']) {
echo "";
}
else if ($_REQUEST['parser_test'] == 1) {
// PHP Version - exclude PHP3
if (substr(phpversion(),0,1) == "3") {
("sorry, PHP 4 required!
Please download the current version at www.php.net. (exit)\n");
$_REQUEST['parser_test'] = "failed";
}
else if (substr(phpversion(),0,3) == "4.0") {
echo "The used PHP version is 4.0 - we strongly recommend you to update to a newer version.
";
$_REQUEST['parser_test'] = "update recommended";
}
else {
echo "The version of the used PHP parser is valid!";
$parser_test = "o.k.";
}
$_SESSION['parser_test'] =& $parser_test;
}
else echo "PHP version test done, result: ".$_REQUEST['parser_test']."";
// end parser test
// begin environment test
echo " **********************";
echo "
PHP environment test
";
// offer env test
if (!$_REQUEST['env_test']) {
echo "";
}
// env_test submitted, start test
else if ($_REQUEST['env_test'] == 1) {
echo '
';
// magic quotes runtime test
if (ini_get("magic_quotes_runtime")) {
echo "
".$red1."Please change the value of 'magic_quotes_runtime' in the php.ini to 'off'\n".$red2;
// add this string to the env-test variable
$_REQUEST['env_test'] = "
change magic_quotes_runtime to 'off' in the php.ini";
}
else echo "
variable 'magic_quotes_runtime' is set to off - o.k.!";
// use_trans_sid test
if (in_array(strtolower(ini_get("session.use_trans_sid")), array('on', '1'))) {
echo "
".$red1."The variable session.use_trans_sid is set to 1 -
this will cause problems if users run PHProjekt without cookies!
We recommend to set session.use_trans_sid to 0\n".$red2;
// add this string to the env-test variable
$_REQUEST['env_test'] = "
Recommendation: set session.use_trans_sid to 0";
}
else echo "
variable 'session.use_trans_sid' is set to off - o.k.!";
// open_basedir test
if (ini_get("open_basedir")) {
echo "
".$red1."Please delete the value of 'open_basedir' in the php.ini\n".$red2;
$_REQUEST['env_test'] .= "
delete the value of 'open_basedir' in the php.ini\n";
}
// open basedir correct?
else echo "
variable 'open_basedir' is empty - o.k.!";
// safe mode test
if ((ini_get("safe_mode") == "on") or (ini_get("safe_mode") == 1)) {
echo "
".$red1."your php runs in the safe mode configuration.
In this case the PHProjekt directory and all subdirectories have to be owned by the webserver.".$red2;
$_REQUEST['env_test'] .= "safe mode is on! -> the webserver must own all subdirectories of PHProjekt";
}
else echo "
variable 'safe_mode' is 'off' - o.k.!";
echo '
';
// if none of the above test has written an error message into the variable -> "o.k."! :-)
if ($_REQUEST['env_test'] == 1) $_REQUEST['env_test'] = "o.k.";
// write variable into session
$_SESSION['env_test'] =& $env_test;
}
// env_test done, show result
else echo "PHP environment test done, result: ".$_REQUEST['env_test']."";
// session test
echo " **********************";
echo "
Session Test
";
if (!$_REQUEST['session_test']) {
echo "";
$session_ok = 1;
$_SESSION['session_ok'] =& $session_ok;
}
else if ($_REQUEST['session_test'] == 1) {
// check whether session are enabled at all!!
if (!extension_loaded('session')) {
echo "
Panic - the php parser has been compiled without session support!
";
if (!$_REQUEST['db_test']) {
echo "Please enter your db access parameters, the script will try to connect to the database:\n";
echo "\n";
}
else if($_REQUEST['db_test'] == 1) {
// well ;-)
$db_host = $_REQUEST['db_host'];
$db_user = $_REQUEST['db_user'];
$db_pass = $_REQUEST['db_pass'];
$db_host2 = $_REQUEST['db_host2'];
$db_name = $_REQUEST['db_name'];
$db_type = $_REQUEST['db_type'];
// *** db test ***
// test mysql access
if ($db_type == "mysql") {
$link = mysql_connect($db_host,$db_user,$db_pass) or $_REQUEST['db_test'] = "failed";
}
// test interbase access
else if ($db_type == "interbase") {
$db_host2 = "$db_host:$db_name";
$link = ibase_connect($db_host2, $db_user, $db_pass) or $_REQUEST['db_test'] = "failed";
}
// test ms_sql
else if ($db_type == "ms_sql") {
$link = mssql_connect($db_host, $db_user, $db_pass) or $_REQUEST['db_test'] = "failed";
}
// test oracle
else if ($db_type == "oracle") {
$link = OCILogon($db_user, $db_pass, $db_name) or $_REQUEST['db_test'] = "failed";
$datestmt = OCIParse($link, "alter session set NLS_DATE_FORMAT='YYYY-MM-DD HH:MI:SS'");
OCIExecute($datestmt);
}
// test informix
else if ($db_type == "informix") {
if ($db_host == "") $db = $db_name;
else $db = $db_name."@".$db_host;
$link = ifx_connect($db, $db_user, $db_pass) or $_REQUEST['db_test'] = "failed";
}
// test postgres
else if ( $db_type == "postgresql" ) {
echo " Trying to connect to $db_name";
$link = pg_connect((($db_host == "") ? "" : "host = $db_host ").(($db_pass == "") ? "" : "password=$db_pass ")."dbname=$db_name user=$db_user");
echo " $link";
if (!$link) {
echo " Trying to connect to template1";
$link = pg_connect((($db_host == "") ? "" : "host = $db_host ").(($db_pass == "") ? "" : "password=$db_pass ")."dbname=template1 user=$db_user") or $_REQUEST['db_test'] = "failed";
echo " Trying to create database $db_name";
$result = pg_exec($link, "CREATE DATABASE $db_name") or $_REQUEST['db_test'] = "failed";
echo " Database create, closing connection to template1";
$link = pg_close($link) or die("Can't close database connection");
echo " Opening new connection to db $db_name";
$link = pg_connect((($db_host == "") ? "" : "host = $db_host ").(($db_pass == "") ? "" : "password=$db_pass ")."dbname=$db_name user=$db_user") or $_REQUEST['db_test'] = "failed";
}
}
// *** end test db access ***
// output error message
if ($db_error == 1 or !$link or (isset($conn) and !$conn)) {
echo "oops - no connection to the dataase! Reasons could be:
Wrong access parameter,
The database is not running,
The database hasn't been setup correctly,
The PHP parser has not been installed with this db support
Please fix it and try it again ...
";
$_REQUEST['db_test'] = "failed";
}
else {
echo "Seems that connecting the database has been successful :-)";
$_REQUEST['db_test'] = "o.k.";
}
$_SESSION['db_test'] =& $db_test;
}
else echo "Database access test done, result: ".$_REQUEST['db_test']."";
// end db test
// **********
// mail check
echo " **********************";
echo "
Mail Test
\n";
if (!$_REQUEST['email']) {
echo "Here you can test whether you are able to send and receive mails with PHProjekt.
Enter your email adress here, the script will send you an email: \n";
echo "\n";
}
else if ($_REQUEST['email'] <> 2) {
mail(urldecode($_REQUEST['email']),"PHProjekt Mail Test","Congratulations!\n Now you know that you can
use PHProjekt to send mails\n","From:$user_email\nReply-To:$user_email\nSender:$user_email\nReturn-Path:$user_email");
echo "Please check your mailbox whether you got a mail from PHProjekt. If not, you should examine the mail settings in your php.ini";
// imap extensions test
if (function_exists('imap_open')) {
echo " Checking your mail configuration ... the IMAP library is active, therefore you can use the full mail client";
$email_receive_test = "o.k.";
}
else {
echo " oh, the imap library from PHP is missing, at the moment you cannot install the full email client :-(
please tell your sysadmin or provider to install the imap library of php (not to be mixed with the imap server).";
$email_receive_test = "failed";
}
$_SESSION['email_receive_test'] =& $email_receive_test;
}
else echo "Email test done, result: receive email $email_receive_test";
// *********
// file test
echo " **********************";
echo "
File writing Test
";
if (!$_REQUEST['file_test']) {
echo " \n";
}
else if ($_REQUEST['file_test'] == 1) {
$fp = fopen("test_phprojekt.txt", 'w');
if (!$fp or $fp == "FALSE") {
echo "I couldn't write this file! Please give the webserver read and write permission for this directory!\n";
$_REQUEST['file_test'] = "failed";
}
else {
$fw = fwrite($fp,"This file was created for testing reasons. You can delete it.");
echo "test file successfully written! Now it will be deleted again ... \n";
$_REQUEST['file_test'] = "o.k.";
fclose($fp);
$delete = unlink("test_phprojekt.txt");
if (!$delete) {
echo ".. but it failed to erase this file!";
$_REQUEST['file_test'] = "failed";
}
}
// additional test - check whether file_uploads is set to "on"
if (ini_get("file_uploads") <> "1") {
echo "Please change the value of 'file_uploads' in the php.ini to 'on', otherwise you can't use the file or mail module!";
if ($_REQUEST['file_test'] == "o.k.") $_REQUEST['file_test'] .= " but please change 'file_uploads' in the php.ini to 'on'.";
}
$_SESSION['file_test'] =& $file_test;
}
else echo "file management test done, result: ".$_REQUEST['file_test']."";
echo " **********************";
echo "
If you want to run this test another time, please follow this link here\n";
echo "
";
// read and write permissions for root, attach, chat and upload directory
// blank screen problem! -> include of en.inc.php possible?
// next proof: file_uploads in the php.ini must be set to on ..
?>