diff options
-rw-r--r-- | check.php-dist | 95 |
1 files changed, 59 insertions, 36 deletions
diff --git a/check.php-dist b/check.php-dist index f7fc0e787..800339063 100644 --- a/check.php-dist +++ b/check.php-dist @@ -56,6 +56,9 @@ $rctest_config['from'] = '_yourfrom_'; ******************************************** */ +define('CHECK_OK', '<span class="success">OK</span>'); +define('CHECK_NOK', '<span class="fail">NOT OK</span>'); + error_reporting(E_ALL ^E_NOTICE); $include_path = dirname(__FILE__) . '/program/lib/'; @@ -64,10 +67,11 @@ $include_path .= dirname(__FILE__) . '/program/'; $include_path .= PATH_SEPARATOR; $include_path .= get_include_path(); +@ini_set('display_errors', 1); set_include_path($include_path); -$writable_dirs = array('logs/', 'temp/'); $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__); @@ -80,6 +84,8 @@ $check = basename(__FILE__); <style type="text/css"> /* <![CDATA[ */ label { display:block; } + th { text-align: left; } + h4 { margin-bottom: 0.2em; } .success { color:#006400;font-weight:bold !important; } .fail { color:#ff0000 !important;font-weight:bold !important; } /* ]]> */ @@ -93,24 +99,22 @@ $check = basename(__FILE__); From correctly set: <?php if ($rctest_config['from'] == '_yourfrom_') { - echo '<span class="fail">NOT OK</span>'; + echo CHECK_NOK; } else { echo $rctest_config['from'] . '<br /><br />'; echo '<i>We do not check if this is a <b>valid</b> email address. Since this serves as from & to, make sure it is correct!</i>'; } -?> -<br /> -<?php -echo '<h3>Check if directories are writable</h3>'; -echo '<p>RoundCube may need to write/save files into these directories.</p>'; -foreach ($writable_dirs AS $dir) { - echo "Directory $dir: "; - if (!is_writable($path . $dir)) { - echo '<span class="fail">NOT OK</span>'; - } else { - echo '<span class="success">OK</span>'; - } +echo '<h3>Check for required 3rd party libs</h3>'; +echo '<p>This also checks if the include path is set correctly.</p>'; + +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 "<br />"; } @@ -120,13 +124,32 @@ echo '<p>Checks if the files exist and if they are readable.</p>'; foreach ($create_files AS $file) { echo "File $file: "; if (file_exists($path . $file) && is_readable($path . $file)) { - echo '<span class="success">OK</span>'; + echo CHECK_OK; } else { - echo '<span class="fail">NOT OK</span>'; + echo CHECK_NOK; } echo '<br />'; } +echo '<h3>Check if directories are writable</h3>'; +echo '<p>RoundCube may need to write/save files into these directories.</p>'; +@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 "<br />"; + } +} else { + echo 'Could not open db.inc.php config file, or file is empty.<br />'; +} + echo '<h3>Check supplied DB settings</h3>'; @include $path . 'config/db.inc.php'; @@ -136,11 +159,11 @@ if (isset($rcmail_config)) { include_once 'MDB2.php'; $db = MDB2::connect($rcmail_config['db_dsnw']); if (!MDB2::IsError($db)) { - echo '<span class="success">OK</span>'; + echo CHECK_OK; $db->disconnect(); $db_working = true; } else { - echo '<span class="fail">NOT OK</span>'; + echo CHECK_NOK; } echo '<br />'; } else { @@ -163,9 +186,9 @@ if ($db_working === true) { $tz_diff = $tz_local - $tz_db; if ($tz_db != $tz_local) { - echo '<span class="fail">NOT OK</span>'; + echo CHECK_NOK; } else { - echo '<span class="success">OK</span>'; + echo CHECK_OK; } } else { echo 'Could not test (fix DB first).'; @@ -180,18 +203,18 @@ $file_uploads = ini_get('file_uploads'); echo '<h4>session.auto_start = 0</h4>'; echo 'status: '; if ($auto_start == 1) { - echo '<span class="fail">NOT OK</span>'; + echo CHECK_NOK; } else { - echo '<span class="success">OK</span>'; + echo CHECK_OK; } echo '<br />'; echo '<h4>file_uploads = On</h4>'; echo 'status: '; if ($file_uploads == 1) { - echo '<span class="success">OK</span>'; + echo CHECK_OK; } else { - echo '<span class="fail">NOT OK</span>'; + echo CHECK_NOK; } /* @@ -200,9 +223,9 @@ echo '<h4>session.save_path <i>is set</i></h4>'; echo 'status: '; $save_path = ini_get('session.save_path'); if (empty($save_path)) { - echo '<span class="fail">NOT OK</span>'; + echo CHECK_NOK; } else { - echo "<span class="success">OK</span>: $save_path"; + echo CHECK_OK . ": $save_path"; if (!file_exists($save_path)) { echo ', but it does not exist'; } else { @@ -214,7 +237,7 @@ if (empty($save_path)) { echo '<br />'; */ -@include_once $path . '/config/main.inc.php'; +@include $path . 'config/main.inc.php'; ?> <h3>Check email settings</h3> <?php @@ -228,7 +251,7 @@ if (is_array($rcmail_config) && count($rcmail_config)) { </tr> <tr><td valign="top"> <?php - echo 'SMTP: <span class="success">OK</span><br />'; + echo 'SMTP: ' . CHECK_OK . '<br />'; echo 'server: ' . $rcmail_config['smtp_server'] . '<br />'; echo 'port: ' . $rcmail_config['smtp_port'] . '<br />'; echo 'user: ' . (($rcmail_config['smtp_user'] == '%u')?'<i>use current session</i>':$rcmail_config['smtp_user']) . '<br />'; @@ -237,8 +260,8 @@ if (is_array($rcmail_config) && count($rcmail_config)) { ?> </td><td valign="top"> <?php - echo 'IMAP: <span class="success">OK</span><br />'; - echo 'server: ' . $rcmail_config['default_host'] . '<br />'; + echo 'IMAP: ' . CHECK_OK . '<br />'; + echo 'server: ' . (is_array($rcmail_config['default_host']) ? var_export($rcmail_config['default_host'], true) : $rcmail_config['default_host']) . '<br />'; echo 'port: ' . $rcmail_config['default_port'] . '<br />'; ?> </td></tr> @@ -266,7 +289,7 @@ Recipient:<br /> echo 'Trying to send email: '; if ($rctest_config['from'] == '_yourfrom_') { - echo '<span class="fail">NOT OK</span><br />'; + echo CHECK_NOK . '<br />'; echo '<i>Please edit $rctest_config in ' . basename(__FILE__) . '</i><br />'; } else { @@ -289,15 +312,15 @@ Recipient:<br /> $smtp_response = array(); if (smtp_mail($rctest_config['from'], $recipients, ($foo = $mail_object->txtHeaders($send_headers)), $body, $smtp_response)) { - echo '<span class="success">OK</span><br />'; + echo CHECK_OK . '<br />'; } else { - echo '<span class="fail">NOT OK</span>'; + echo CHECK_NOK; echo '<br />' . join('<br />', $smtp_response); } } } } else { - echo '<span class="fail">NOT OK</span>'; + echo CHECK_NOK; } ?> <h3>Test IMAP settings</h3> @@ -327,10 +350,10 @@ if ($rcmail_config['default_host'] == '') { $data['user'], $data['pass']); if ($result != true) { - echo '<span class="fail">NOT OK</span>'; + echo CHECK_NOK; echo '<br />Error return: ' . $iil_error; } else { - echo '<span class="success">OK</span>'; + echo CHECK_OK; } echo '<br />'; } |