* @license http://www.opensource.org/licenses/bsd-license.php The BSD License
* @version CVS: $Id$
* @link https://svn.roundcube.net/trunk
* @todo HTML/CSS to make it pretty.
* @todo In devel-next, use bootstrap.
* @todo Refactor to use RoundCube classes.
*/
$rctest_config = array();
/**
* @var string Please edit this to an email address, such as yourname@example.org.
* This email address serves as from and to for the test emails.
*/
$rctest_config['from'] = '_yourfrom_';
/*
********************************************
********************************************
** Don't edit anything else in this file. **
** Unless (of course) you know what you **
** are doing. **
********************************************
********************************************
*/
define('CHECK_OK', 'OK ');
define('CHECK_NOK', 'NOT OK ');
error_reporting(E_ALL ^E_NOTICE);
$include_path = dirname(__FILE__) . '/program/lib/';
$include_path .= PATH_SEPARATOR;
$include_path .= dirname(__FILE__) . '/program/';
$include_path .= PATH_SEPARATOR;
$include_path .= get_include_path();
@ini_set('display_errors', 1);
set_include_path($include_path);
$create_files = array('config/db.inc.php', 'config/main.inc.php');
$required_libs = array('PEAR' => 'PEAR.php', 'DB' => 'DB.php', 'Net_SMTP' => 'Net/SMTP.php', 'Mail_mime' => 'Mail/mime.php', 'iilConnection' => 'lib/imap.inc');
$path = dirname(__FILE__) . '/';
$check = basename(__FILE__);
?>
RoundCube :: check
Check Configuration
From correctly set:
';
echo 'We do not check if this is a valid email address. Since this serves as from & to, make sure it is correct! ';
}
echo 'Check for required 3rd party libs ';
echo 'This also checks if the include path is set correctly.
';
foreach ($required_libs as $classname => $file) {
@include_once $file;
echo "$classname: ";
if (class_exists($classname))
echo CHECK_OK;
else
echo CHECK_NOK . "; Failed to load $file";
echo " ";
}
echo 'Check if you setup config files ';
echo 'Checks if the files exist and if they are readable.
';
foreach ($create_files AS $file) {
echo "File $file: ";
if (file_exists($path . $file) && is_readable($path . $file)) {
echo CHECK_OK;
} else {
echo CHECK_NOK;
}
echo ' ';
}
echo 'Check if directories are writable ';
echo 'RoundCube may need to write/save files into these directories.
';
@include $path . 'config/main.inc.php';
if (isset($rcmail_config)) {
foreach (array($rcmail_config['temp_dir'], $rcmail_config['log_dir']) AS $dir) {
$dir = $dir{0} == '/' ? $dir : $path . $dir;
echo "Directory $dir: ";
if (!is_writable($dir)) {
echo CHECK_NOK;
} else {
echo CHECK_OK;
}
echo " ";
}
} else {
echo 'Could not open db.inc.php config file, or file is empty. ';
}
echo 'Check supplied DB settings ';
@include $path . 'config/db.inc.php';
$db_working = false;
if (isset($rcmail_config)) {
echo 'DB settings: ';
include_once 'MDB2.php';
$db = MDB2::connect($rcmail_config['db_dsnw']);
if (!MDB2::IsError($db)) {
echo CHECK_OK;
$db->disconnect();
$db_working = true;
} else {
echo CHECK_NOK;
}
echo ' ';
} else {
echo 'Could not open db.inc.php config file, or file is empty. ';
}
echo 'TimeZone ';
echo 'Checks if web- and databaseserver are in the same timezone. ';
echo 'Status: ';
if ($db_working === true) {
require_once 'include/rcube_mdb2.inc';
$DB = new rcube_mdb2($rcmail_config['db_dsnw'], '', false);
$DB->db_connect('w');
$tz_db = "SELECT " . $DB->unixtimestamp($DB->now()) . " AS tz_db";
$tz_db = $DB->query($tz_db);
$tz_db = $DB->fetch_assoc($tz_db);
$tz_db = (int) $tz_db['tz_db'];
$tz_local = (int) time();
$tz_diff = $tz_local - $tz_db;
if ($tz_db != $tz_local) {
echo CHECK_NOK;
} else {
echo CHECK_OK;
}
} else {
echo 'Could not test (fix DB first).';
}
echo ' ';
echo 'Checking .ini settings ';
$auto_start = ini_get('session.auto_start');
$file_uploads = ini_get('file_uploads');
echo 'session.auto_start = 0 ';
echo 'status: ';
if ($auto_start == 1) {
echo CHECK_NOK;
} else {
echo CHECK_OK;
}
echo ' ';
echo 'file_uploads = On ';
echo 'status: ';
if ($file_uploads == 1) {
echo CHECK_OK;
} else {
echo CHECK_NOK;
}
/*
* Probably not needed because we have a custom handler
echo 'session.save_path is set ';
echo 'status: ';
$save_path = ini_get('session.save_path');
if (empty($save_path)) {
echo CHECK_NOK;
} else {
echo CHECK_OK . ": $save_path";
if (!file_exists($save_path)) {
echo ', but it does not exist';
} else {
if (!is_readable($save_path) || !is_writable($save_path)) {
echo ', but permissions to read and/or write are missing';
}
}
}
echo ' ';
*/
@include $path . 'config/main.inc.php';
?>
Check email settings
';
if (is_array($rcmail_config) && count($rcmail_config)) {
?>
SMTP Settings
IMAP Settings
';
echo 'server: ' . $rcmail_config['smtp_server'] . ' ';
echo 'port: ' . $rcmail_config['smtp_port'] . ' ';
echo 'user: ' . (($rcmail_config['smtp_user'] == '%u')?'use current session ':$rcmail_config['smtp_user']) . ' ';
echo 'pass: ' . (($rcmail_config['smtp_pass'] == '%p')?'use current session ':$rcmail_config['smtp_pass']) . ' ';
//var_dump($rcmail_config);
?>
';
echo 'server: ' . (is_array($rcmail_config['default_host']) ? var_export($rcmail_config['default_host'], true) : $rcmail_config['default_host']) . ' ';
echo 'port: ' . $rcmail_config['default_port'] . ' ';
?>
Test SMTP settings - send an email
Don't abuse this!
';
echo 'Please edit $rctest_config in ' . basename(__FILE__) . ' ';
} else {
$data = $_POST['smtp_test'];
$CONFIG = $rcmail_config;
require_once 'lib/rc_mail_mime.inc';
require_once 'include/rcube_smtp.inc';
$recipients = $rctest_config['from'];
$headers['From'] = $rctest_config['from'];
$headers['To'] = $recipients;
$headers['Subject'] = 'Test message from RoundCube';
$body = 'This is a test to confirm that RoundCube can send email.';
$mail_object = new rc_mail_mime();
$mail_object->headers($headers);
$smtp_response = array();
if (smtp_mail($rctest_config['from'], $recipients, ($foo = $mail_object->txtHeaders($send_headers)), $body, $smtp_response)) {
echo CHECK_OK . ' ';
} else {
echo CHECK_NOK;
echo ' ' . join(' ', $smtp_response);
}
}
}
} else {
echo CHECK_NOK;
}
?>
Test IMAP settings
We cannot test, default_host is not set in config/main.inc.php.';
} else {
?>
Error return: ' . $iil_error;
} else {
echo CHECK_OK;
}
echo ' ';
}
}
?>