<?php
/**
* Filename.......: eval.php
* Project........: V-webmail
* Last Modified..: $Date: 2002/09/04 15:43:50 $
* CVS Revision...: $Revision: 1.2 $
* Copyright......: 2001, 2002 Richard Heyes
*/

/**
* File uploads ini flag
*/
	if (!ini_get('file_uploads')) {
		$fileuploads_error = true;
	}

/**
* Safe mode
*/
	if (ini_get('safe_mode')) {
		$safemode_error = true;
	}

/**
* Session detection
*/
	session_name('VwebmailEval');
	session_start();

	if (ini_get('register_globals')) {
		$session_error = !isset($session_test);
		session_register('session_test');
		$session_test = 'Set';
	} else {
		$session_error = !isset($HTTP_SESSION_VARS['session_test']);
		$HTTP_SESSION_VARS['session_test'] = 'Set';
	}

	// A redirect to negate the need for the user to refresh.
	// This way we can be more certain about session support.
	if (!isset($HTTP_GET_VARS['eval']) OR empty($HTTP_GET_VARS['eval'])) {
		header('Location: ./' . basename($HTTP_SERVER_VARS['PHP_SELF']) . '?eval=1');
		exit;
	}

/**
* What version are we running?
*/
	preg_match('/([3-5])\.([0-9])\.([0-9])/', phpversion(), $matches);
	$major_ver = $matches[1];
	$med_ver   = $matches[2];
	$minor_ver = $matches[3];
	
	$version_error = ( $major_ver < 4 OR ($minor_ver < 6 AND $med_ver == 0) );

/**
* Do we have the imap extension?
*/
	$imap_error = !extension_loaded('imap');

/**
* Are short tags enabled?
*/
	$short_tags_error = (strtolower(ini_get('short_open_tag')) == 'off' OR ini_get('short_open_tag') == '0');

?>
<html>
<head>
	<title>Configuration check</title>
	<style type="text/css">
	<!--
		body,td {font-family: Arial, Verdana, Helvetica, Sans-Serif}
	// -->
	</style>
</head>
<body>

<h2 align="center">Configuration check</h2>

<p align="center">
	<font color="green"><strong>Please read all of this</strong></font>
</p>

<h3>Safe mode</h3>

<p>
	<!-- <?php if($safemode_error):?> -->
	Status: <font color="red"><strong>Safe mode is on!</strong></font>

	<!-- <?php else:?> -->

	Status: <font color="green"><strong>Safe mode is not on</strong></font>
    <!-- <?php endif?> -->
</p>

<p>
	V-webmail behaviour with safe_mode turned on is undefined. In theory there should be no severe
	problems, however support for safe_mode is still under investigation (ie being tested). As such
	you are <strong>strongly</strong> urged to not use safe_mode in conjunction with V-webmail.
</p>
<p>
	Other safe mode related options such as <strong>open_basedir</strong> or <strong>disable_functions</strong>
	can also have adverse effects.
</p>

<h3>File uploads</h3>

<p>
	<!-- <?php if($fileuploads_error):?> -->
	Status: <font color="red"><strong>File uploads are Off!</strong></font>

	<!-- <?php else:?> -->

	Status: <font color="green"><strong>File uploads are On</strong></font>
    <!-- <?php endif?> -->
</p>

<p>
	With the file_uploads ini setting turned off (the default with recent versions of RedHat) the compose page
	(which is effectively a file upload form) will not function correctly, and you will be unable to send mail.
</p>

<h3>IMAP Extension</h3>

<p>
	<!-- <?php if($imap_error):?> -->
	Status: <font color="red"><strong>IMAP Extension not loaded!</strong></font>

	<!-- <?php else:?> -->

	Status: <font color="green"><strong>IMAP Extension loaded</strong></font>
    <!-- <?php endif?> -->
</p>

<p>
	V-webmail needs the IMAP extension to communicate with the IMAP or POP3 server. If you do not have
	this extension, you may need to recompile PHP with IMAP support (most commonly on Unix/Linux).
</p>

<p>
	If you have Windows, you may be able to simply uncomment the appropriate line in your php.ini file. The line
	looks like this: <i>extension=php_imap.dll</i>. Uncommenting means removing the semi-colon (;) at the
	beginning of the line. If you do this, you may also need to correctly set the extension_dir line, which
	would look like this: <i>extension_dir = c:/httpd/php/extensions</i>. This path should point to where
	the extensions (.dll files under Windows) reside.
</p>

<h3>Minimum version</h3>

<p>
	<!-- <?php if($version_error):?> -->
	Version: <font color="red"><strong><?php echo phpversion()?> - Insufficient!</strong></font>

	<!-- <?php else:?> -->

	Version: <font color="green"><strong><?php echo phpversion()?> - OK</strong></font>
    <!-- <?php endif?> -->
</p>

<p>
	To operate correctly V-webmail requires a minimum php version of <strong>4.0.4pl1</strong>. The detected version
	of PHP is shown above. If you do not have the minimum required version, you will need to upgrade. If you are running
	a version prior to 4.1.2, you should also consider upgrading for security reasons.
</p>

<h3>Short open tag</h3>

</p>
	<!-- <?php if($short_tags_error):?> -->
	Short open tags: <font color="red"><strong>Disabled!</strong></font>

	<!-- <?php else:?> -->

	Short open tags: <font color="green"><strong>Enabled</strong></font>
    <!-- <?php endif?> -->
</p>

<p>
	V-webmails' templates are done using a restricted set of php commands. To make things more legible
	short tags are used throughout, (Syntax is as such: <span style="font-family: monospace; font-size: 10pt">&lt;?if($var):?&gt; ... &lt;?endif?&gt;</span>). If short
	open tags are not enabled, the template system will not function.
</p>


<h3>Session support</h3>

<p>
	<!-- <?php if($session_error):?> -->
	Enabled: <font color="red"><strong>Unknown</strong></font>
</p>
<p>
	<strong>Important!</strong>
	Session support is unknown. Due to this script running itself twice (it redirects to itself
	on the first run) it's very likely one of the following is causing a problem:
</p>

	<ul>
		<li>The session data save path (in your php.ini)</li>
		<li>Permissions on the session data directory</li>
		<li>The session.use_cookies setting (in your php.ini)</li>
	</ul>

	<!-- <?php else:?> -->

	Enabled: <font color="green"><strong>Yes</strong></font>
    <!-- <?php endif?> -->
</p>

<p>
	V-webmail relies heavily on the session support of PHP and as such cannot function without it. This script tries to
	determine session support by redirecting to itself no the first run. The session support can then be verified on the
	second run. If at this point session support is still unknown, there is most likely a configuration problem.
</p>
</body>
</html>