From 19881691bdef7beba3b9ed41049dab9b6f856f93 Mon Sep 17 00:00:00 2001 From: till Date: Mon, 11 Feb 2008 23:21:15 +0000 Subject: * removed check.php (security issue) * added check.php-dist * new in check(.php-dist): smtp check, prettyfied errors --- check.php | 179 ---------------------------------- check.php-dist | 297 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 297 insertions(+), 179 deletions(-) delete mode 100644 check.php create mode 100644 check.php-dist diff --git a/check.php b/check.php deleted file mode 100644 index 4378f17a7..000000000 --- a/check.php +++ /dev/null @@ -1,179 +0,0 @@ - - * @license http://www.opensource.org/licenses/bsd-license.php The BSD License - * @version CVS: $Id$ - * @link https://svn.roundcube.net/trunk - * @todo Check IMAP settings. - * @todo Check SMTP settings. - * @todo HTML/CSS to make it pretty. - * @todo In devel-next, use bootstrap. - */ - -$include_path = dirname(__FILE__) . '/program/lib/'; -$include_path .= PATH_SEPARATOR; -$include_path .= dirname(__FILE__) . '/program/'; -$include_path .= PATH_SEPARATOR; -$include_path .= get_include_path(); - -set_include_path($include_path); - -$writable_dirs = array('logs/', 'temp/'); -$create_files = array('config/db.inc.php', 'config/main.inc.php'); - -$path = dirname(__FILE__) . '/'; -?> - - - - - RoundCube :: check - - -RoundCube Webmail - -Check if directories are writable'; -echo '

RoundCube may need to write/save files into these directories.

'; - -foreach ($writable_dirs AS $dir) { - echo "Directory $dir: "; - if (!is_writable($path . $dir)) { - echo 'NOT OK'; - } else { - echo 'OK'; - } - 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 'OK'; - } else { - echo 'NOT OK'; - } - echo '
'; -} - -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 'OK'; - $db->disconnect(); - $db_working = true; - } else { - echo 'NOT OK'; - } - 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 'NOT OK'; - } else { - echo '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 'NOT OK'; -} else { - echo 'OK'; -} -echo '
'; - -echo '

file_uploads = On

'; -echo 'status: '; -if ($file_uploads == 1) { - echo 'OK'; -} else { - echo 'NOT OK'; -} - -/* - * 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 'NOT OK'; -} else { - echo "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 '
'; - */ -?> - - diff --git a/check.php-dist b/check.php-dist new file mode 100644 index 000000000..d1f3e295e --- /dev/null +++ b/check.php-dist @@ -0,0 +1,297 @@ + + * @license http://www.opensource.org/licenses/bsd-license.php The BSD License + * @version CVS: $Id$ + * @link https://svn.roundcube.net/trunk + * @todo Check IMAP settings. + * @todo Check SMTP settings. + * @todo HTML/CSS to make it pretty. + * @todo In devel-next, use bootstrap. + * @todo Refactor to use RoundCube classes. + */ + +$rctest_config = array(); +$rctest_config['from'] = '_yourfrom_'; + +/* + ******************************************** + ******************************************** + ** Don't edit anything else in this file. ** + ** Unless (of course) you know what you ** + ** are doing. ** + ******************************************** + ******************************************** + */ + +$include_path = dirname(__FILE__) . '/program/lib/'; +$include_path .= PATH_SEPARATOR; +$include_path .= dirname(__FILE__) . '/program/'; +$include_path .= PATH_SEPARATOR; +$include_path .= get_include_path(); + +set_include_path($include_path); + +$writable_dirs = array('logs/', 'temp/'); +$create_files = array('config/db.inc.php', 'config/main.inc.php'); + +$path = dirname(__FILE__) . '/'; +?> + + + + + + + RoundCube :: check + + +RoundCube Webmail + +

Check Configuration

+From correctly set: +NOT OK'; +} else { + echo $rctest_config['from'] . '

'; + echo 'We do not check if this is a valid email address. Since this serves as from & to, make sure it is correct!'; +} +?> +
+Check if directories are writable'; +echo '

RoundCube may need to write/save files into these directories.

'; + +foreach ($writable_dirs AS $dir) { + echo "Directory $dir: "; + if (!is_writable($path . $dir)) { + echo 'NOT OK'; + } else { + echo 'OK'; + } + 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 'OK'; + } else { + echo 'NOT OK'; + } + echo '
'; +} + +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 'OK'; + $db->disconnect(); + $db_working = true; + } else { + echo 'NOT OK'; + } + 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 'NOT OK'; + } else { + echo '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 'NOT OK'; +} else { + echo 'OK'; +} +echo '
'; + +echo '

file_uploads = On

'; +echo 'status: '; +if ($file_uploads == 1) { + echo 'OK'; +} else { + echo 'NOT OK'; +} + +/* + * 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 'NOT OK'; +} else { + echo "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_once $path . '/config/main.inc.php'; +?> +

Check email settings

+

SMTP Settings

+OK
'; + 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); +?> +

Test SMTP settings - send an email

+

Don't abuse this!

+
+ + +
+ +Recipient:
+

+ +
+NOT OK
'; + echo 'Please edit $rctest_config in ' . basename(__FILE__) . '
'; + } else { + + $data = $_POST['smtp_test']; + + require_once 'Mail.php'; + + $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.'; + + $params = array(); + $mail_driver = ''; + + if ($rcmail_config['smtp_server'] != '') { + $mail_driver = 'smtp'; + + if (isset($data['user'])) { + $params['username'] = $data['user']; + $params['password'] = $data['pass']; + $params['auth'] = true; + } + + $params['host'] = $rcmail_config['smtp_server']; + $params['port'] = $rcmail_config['smtp_port']; + + } else { + $mail_driver = 'mail'; + } + + $mail_object =& Mail::factory($mail_driver, $params); + $status = $mail_object->send($recipients, $headers, $body); + if (!PEAR::isError($status)) { + echo 'OK
'; + } else { + echo 'NOT OK'; + echo '
' . $status->getMessage(); + } + } + } +} else { + echo 'NOT OK'; +} +?> + + \ No newline at end of file -- cgit v1.2.3