source: github/check.php-dist @ 8b661f6

HEADcourier-fixdev-browser-capabilitiespdorelease-0.6release-0.7release-0.8
Last change on this file since 8b661f6 was 8b661f6, checked in by till <till@…>, 5 years ago
  • added a comment in regard to 'from' in check.php-dist
  • Property mode set to 100644
File size: 9.9 KB
Line 
1<?php
2/**
3 * Copyright (c) 2008, Till Klampaeckel
4 *
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without modification,
8 * are permitted provided that the following conditions are met:
9 *
10 *  * Redistributions of source code must retain the above copyright notice, this
11 *    list of conditions and the following disclaimer.
12 *  * Redistributions in binary form must reproduce the above copyright notice, this
13 *    list of conditions and the following disclaimer in the documentation and/or
14 *    other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
20 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
23 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
24 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
25 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 *
28 * PHP Version 5
29 *
30 * @category Config
31 * @package  RoundCube
32 * @author   Till Klampaeckel <till@php.net>
33 * @license  http://www.opensource.org/licenses/bsd-license.php The BSD License
34 * @version  CVS: $Id$
35 * @link     https://svn.roundcube.net/trunk
36 * @todo     Check IMAP settings.
37 * @todo     Check SMTP settings.
38 * @todo     HTML/CSS to make it pretty.
39 * @todo     In devel-next, use bootstrap.
40 * @todo     Refactor to use RoundCube classes.
41 */
42
43$rctest_config         = array();
44
45/**
46 * @var string Please edit this to an email address, such as yourname@example.org.
47 *             This email address serves as from and to for the test emails.
48 */
49$rctest_config['from'] = '_yourfrom_';
50
51/*
52 ********************************************
53 ********************************************
54 ** Don't edit anything else in this file. **
55 ** Unless (of course) you know what you   **
56 ** are doing.                             **
57 ********************************************
58 ********************************************
59 */
60
61$include_path  = dirname(__FILE__) . '/program/lib/';
62$include_path .= PATH_SEPARATOR;
63$include_path .= dirname(__FILE__) . '/program/';
64$include_path .= PATH_SEPARATOR;
65$include_path .= get_include_path();
66
67set_include_path($include_path);
68
69$writable_dirs = array('logs/', 'temp/');
70$create_files  = array('config/db.inc.php', 'config/main.inc.php');
71
72$path = dirname(__FILE__) . '/';
73?>
74<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/2002/REC-xhtml1-20020801/DTD/xhtml1-transitional.dtd">
75<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
76<head>
77    <link rel="shortcut icon" href="skins/default/images/favicon.ico"/>
78    <link rel="stylesheet" type="text/css" href="skins/default/common.css" />
79    <style type="text/css">
80    /* <![CDATA[ */
81    label { display:block; }
82    .success { color:#006400;font-weight:bold !important; }
83    .fail { color:#ff0000 !important;font-weight:bold !important; }
84    /* ]]> */
85    </style>
86    <title>RoundCube :: check</title>
87</head>
88<body>
89<img src="skins/default/images/roundcube_logo.png" width="165" height="55" border="0" alt="RoundCube Webmail" hspace="12" vspace="2"/>
90
91<h3>Check <?php echo basename(__FILE__); ?> Configuration</h3>
92From correctly set:
93<?php
94if ($rctest_config['from'] == '_yourfrom_') {
95    echo '<span class="fail">NOT OK</span></span>';
96} else {
97    echo $rctest_config['from'] . '<br /><br />';
98    echo '<i>We do not check if this is a <b>valid</b> email address. Since this serves as from &amp; to, make sure it is correct!</i>';
99}
100?>
101<br />
102<?php
103echo '<h3>Check if directories are writable</h3>';
104echo '<p>RoundCube may need to write/save files into these directories.</p>';
105
106foreach ($writable_dirs AS $dir) {
107    echo "Directory $dir: ";
108    if (!is_writable($path . $dir)) {
109        echo '<span class="fail">NOT OK</span></span>';
110    } else {
111        echo '<span class="success">OK</span>';
112    }
113    echo "<br />";
114}
115
116echo '<h3>Check if you setup config files</h3>';
117echo '<p>Checks if the files exist and if they are readable.</p>';
118
119foreach ($create_files AS $file) {
120    echo "File $file: ";
121    if (file_exists($path . $file) && is_readable($path . $file)) {
122        echo '<span class="success">OK</span>';
123    } else {
124        echo '<span class="fail">NOT OK</span></span>';
125    }
126    echo '<br />';
127}
128
129echo '<h3>Check supplied DB settings</h3>';
130@include $path . 'config/db.inc.php';
131
132$db_working = false;
133if (isset($rcmail_config)) {
134    echo 'DB settings: ';
135    include_once 'MDB2.php';
136    $db = MDB2::connect($rcmail_config['db_dsnw']);
137    if (!MDB2::IsError($db)) {
138        echo '<span class="success">OK</span>';
139        $db->disconnect();
140        $db_working = true;
141    } else {
142        echo '<span class="fail">NOT OK</span></span>';
143    }
144    echo '<br />';
145} else {
146    echo 'Could not open db.inc.php config file, or file is empty.<br />';
147}
148
149echo '<h3>TimeZone</h3>';
150echo 'Checks if web- and databaseserver are in the same timezone.<br /><br />';
151echo 'Status: ';
152if ($db_working === true) {
153    require_once 'include/rcube_mdb2.inc';
154    $DB = new rcube_mdb2($rcmail_config['db_dsnw'], '', false);
155    $DB->db_connect('w');
156   
157    $tz_db    = "SELECT " . $DB->unixtimestamp($DB->now()) . " AS tz_db";
158    $tz_db    = $DB->query($tz_db);
159    $tz_db    = $DB->fetch_assoc($tz_db);
160    $tz_db    = (int) $tz_db['tz_db'];
161    $tz_local = (int) time();
162    $tz_diff  = $tz_local - $tz_db;
163
164    if ($tz_db != $tz_local) {
165        echo '<span class="fail">NOT OK</span></span>';
166    } else {
167        echo '<span class="success">OK</span>';
168    }
169} else {
170    echo 'Could not test (fix DB first).';
171}
172echo '<br />';
173
174echo '<h3>Checking .ini settings</h3>';
175
176$auto_start   = ini_get('session.auto_start');
177$file_uploads = ini_get('file_uploads');
178
179echo '<h4>session.auto_start = 0</h4>';
180echo 'status: ';
181if ($auto_start == 1) {
182    echo '<span class="fail">NOT OK</span></span>';
183} else {
184    echo '<span class="success">OK</span>';
185}
186echo '<br />';
187
188echo '<h4>file_uploads = On</h4>';
189echo 'status: ';
190if ($file_uploads == 1) {
191    echo '<span class="success">OK</span>';
192} else {
193    echo '<span class="fail">NOT OK</span></span>';
194}
195
196/*
197 * Probably not needed because we have a custom handler
198echo '<h4>session.save_path <i>is set</i></h4>';
199echo 'status: ';
200$save_path = ini_get('session.save_path');
201if (empty($save_path)) {
202    echo '<span class="fail">NOT OK</span></span>';
203} else {
204    echo "<span class="success">OK</span>: $save_path";
205    if (!file_exists($save_path)) {
206        echo ', but it does not exist';
207    } else {
208        if (!is_readable($save_path) || !is_writable($save_path)) {
209            echo ', but permissions to read and/or write are missing';
210        }
211    }
212}
213echo '<br />';
214 */
215
216@include_once $path . '/config/main.inc.php';
217?>
218<h3>Check email settings</h3>
219<h4>SMTP Settings</h4>
220<?php
221echo 'Fetch config from config/main.inc.php: ';
222if (is_array($rcmail_config) && count($rcmail_config)) {
223    echo '<span class="success">OK</span><br />';
224    echo 'server: ' . $rcmail_config['smtp_server'] . '<br />';
225    echo 'port: ' . $rcmail_config['smtp_port'] . '<br />';
226    echo 'user: ' . (($rcmail_config['smtp_user'] == '%u')?'<i>use current session</i>':$rcmail_config['smtp_user']) . '<br />';
227    echo 'pass: ' . (($rcmail_config['smtp_pass'] == '%p')?'<i>use current session</i>':$rcmail_config['smtp_pass']) . '<br />';
228    //var_dump($rcmail_config);
229?>
230<h3>Test SMTP settings - send an email</h3>
231<p>Don't abuse this!</p>
232<form action="check.php" method="post">
233<?php
234if ($rcmail_config['smtp_server'] != ''):
235    if ($rcmail_config['smtp_user'] == '%u'):
236?>
237<label>Username:</label><input type="text" name="smtp_test[user]" />
238<label>Passwort:</label><input type="text" name="smtp_test[pass]" /><br />
239<?php
240    endif;
241endif;
242?>
243Recipient:<br />
244<?php echo $rctest_config['from']; ?><br /><br />
245<input type="submit" value="send an email" />
246</form>
247<?php
248    if ($_SERVER['REQUEST_METHOD'] == 'POST') {
249
250        echo 'Trying to send email: ';
251        if ($rctest_config['from'] == '_yourfrom_') {
252            echo '<span class="fail">NOT OK</span></span><br />';
253            echo '<i>Please edit $rctest_config in ' . basename(__FILE__) . '</i><br />';
254        } else {
255
256            $data = $_POST['smtp_test'];
257
258            require_once 'Mail.php';
259
260            $recipients = $rctest_config['from'];
261
262            $headers['From']    = $rctest_config['from'];
263            $headers['To']      = $recipients;
264            $headers['Subject'] = 'Test message from RoundCube';
265
266            $body = 'This is a test to confirm that RoundCube can send email.';
267
268            $params      = array();
269            $mail_driver = '';
270
271            if ($rcmail_config['smtp_server'] != '') {
272                $mail_driver = 'smtp';
273
274                if (isset($data['user'])) {
275                    $params['username'] = $data['user'];
276                    $params['password'] = $data['pass'];
277                    $params['auth']     = true;
278                }
279
280                $params['host'] = $rcmail_config['smtp_server'];
281                $params['port'] = $rcmail_config['smtp_port'];
282
283            } else {
284                $mail_driver = 'mail';
285            }
286
287            $mail_object =& Mail::factory($mail_driver, $params);
288            $status = $mail_object->send($recipients, $headers, $body);
289            if (!PEAR::isError($status)) {
290                echo '<span class="success">OK</span><br />';
291            } else {
292                echo '<span class="fail">NOT OK</span></span>';
293                echo '<br />' . $status->getMessage();
294            }
295        }
296    }
297} else {
298    echo '<span class="fail">NOT OK</span></span>';
299}
300?>
301</body>
302</html>
Note: See TracBrowser for help on using the repository browser.