thomascube
2008-02-11 b85bf8b3f46b9927117777baa149eb4ac818693f
commit | author | age
efc805 1 <?php
T 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.
24a423 39  * @todo     In devel-next, use bootstrap.
efc805 40  */
T 41
2b9b6b 42 $include_path  = dirname(__FILE__) . '/program/lib/';
24a423 43 $include_path .= PATH_SEPARATOR;
T 44 $include_path .= dirname(__FILE__) . '/program/';
45 $include_path .= PATH_SEPARATOR;
46 $include_path .= get_include_path();
47
2b9b6b 48 set_include_path($include_path);
T 49
efc805 50 $writable_dirs = array('logs/', 'temp/');
T 51 $create_files  = array('config/db.inc.php', 'config/main.inc.php');
52
53 $path = dirname(__FILE__) . '/';
731e0e 54 ?>
T 55 <html>
56 <head>
57     <link rel="shortcut icon" href="skins/default/images/favicon.ico"/>
58     <link rel="stylesheet" type="text/css" href="skins/default/common.css" />
59     <title>RoundCube :: check</title>
60 </head>
61 <body>
62 <img src="skins/default/images/roundcube_logo.png" width="165" height="55" border="0" alt="RoundCube Webmail" hspace="12" vspace="2"/>
efc805 63
731e0e 64 <?php
efc805 65 echo '<h3>Check if directories are writable</h3>';
T 66 echo '<p>RoundCube may need to write/save files into these directories.</p>';
67
68 foreach ($writable_dirs AS $dir) {
69     echo "Directory $dir: ";
70     if (!is_writable($path . $dir)) {
71         echo 'NOT OK';
72     } else {
73         echo 'OK';
74     }
75     echo "<br />";
76 }
77
78 echo '<h3>Check if you setup config files</h3>';
79 echo '<p>Checks if the files exist and if they are readable.</p>';
80
81 foreach ($create_files AS $file) {
82     echo "File $file: ";
83     if (file_exists($path . $file) && is_readable($path . $file)) {
84         echo 'OK';
85     } else {
86         echo 'NOT OK';
87     }
581213 88     echo '<br />';
efc805 89 }
T 90
91 echo '<h3>Check supplied DB settings</h3>';
92 @include $path . 'config/db.inc.php';
93
8bbe9d 94 $db_working = false;
efc805 95 if (isset($rcmail_config)) {
T 96     echo 'DB settings: ';
97     include_once 'MDB2.php';
98     $db = MDB2::connect($rcmail_config['db_dsnw']);
99     if (!MDB2::IsError($db)) {
100         echo 'OK';
101         $db->disconnect();
8bbe9d 102         $db_working = true;
efc805 103     } else {
T 104         echo 'NOT OK';
105     }
581213 106     echo '<br />';
efc805 107 } else {
T 108     echo 'Could not open db.inc.php config file, or file is empty.<br />';
109 }
581213 110
8bbe9d 111 echo '<h3>TimeZone</h3>';
731e0e 112 echo 'Checks if web- and databaseserver are in the same timezone.<br /><br />';
8bbe9d 113 echo 'Status: ';
T 114 if ($db_working === true) {
115     require_once 'include/rcube_mdb2.inc';
4212e7 116     $DB = new rcube_mdb2($rcmail_config['db_dsnw'], '', false);
8bbe9d 117     $DB->db_connect('w');
T 118     
be4d18 119     $tz_db    = "SELECT " . $DB->unixtimestamp($DB->now()) . " AS tz_db";
T 120     $tz_db    = $DB->query($tz_db);
121     $tz_db    = $DB->fetch_assoc($tz_db);
122     $tz_db    = (int) $tz_db['tz_db'];
123     $tz_local = (int) time();
124     $tz_diff  = $tz_local - $tz_db;
125
8bbe9d 126     if ($tz_db != $tz_local) {
T 127         echo 'NOT OK';
128     } else {
129         echo 'OK';
130     }
131 } else {
132     echo 'Could not test (fix DB first).';
133 }
134 echo '<br />';
135
581213 136 echo '<h3>Checking .ini settings</h3>';
T 137
138 $auto_start   = ini_get('session.auto_start');
139 $file_uploads = ini_get('file_uploads');
140
731e0e 141 echo '<h4>session.auto_start = 0</h4>';
8bbe9d 142 echo 'status: ';
581213 143 if ($auto_start == 1) {
T 144     echo 'NOT OK';
145 } else {
146     echo 'OK';
147 }
148 echo '<br />';
149
731e0e 150 echo '<h4>file_uploads = On</h4>';
8bbe9d 151 echo 'status: ';
581213 152 if ($file_uploads == 1) {
T 153     echo 'OK';
154 } else {
155     echo 'NOT OK';
156 }
8bbe9d 157
T 158 /*
159  * Probably not needed because we have a custom handler
731e0e 160 echo '<h4>session.save_path <i>is set</i></h4>';
8bbe9d 161 echo 'status: ';
T 162 $save_path = ini_get('session.save_path');
163 if (empty($save_path)) {
164     echo 'NOT OK';
165 } else {
166     echo "OK: $save_path";
167     if (!file_exists($save_path)) {
168         echo ', but it does not exist';
169     } else {
170         if (!is_readable($save_path) || !is_writable($save_path)) {
171             echo ', but permissions to read and/or write are missing';
172         }
173     }
174 }
581213 175 echo '<br />';
8bbe9d 176  */
be4d18 177 ?>
731e0e 178 </body>
T 179 </html>