source: subversion/trunk/roundcubemail/check.php @ 1007

Last change on this file since 1007 was 1007, checked in by till, 5 years ago
  • fixed notice ($dbclass)
File size: 4.5 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 */
41
42$include_path  = dirname(__FILE__) . '/program/lib/';
43$include_path .= PATH_SEPARATOR;
44$include_path .= dirname(__FILE__) . '/program/';
45$include_path .= PATH_SEPARATOR;
46$include_path .= get_include_path();
47
48set_include_path($include_path);
49
50$writable_dirs = array('logs/', 'temp/');
51$create_files  = array('config/db.inc.php', 'config/main.inc.php');
52
53$path = dirname(__FILE__) . '/';
54
55echo '<h3>Check if directories are writable</h3>';
56echo '<p>RoundCube may need to write/save files into these directories.</p>';
57
58foreach ($writable_dirs AS $dir) {
59    echo "Directory $dir: ";
60    if (!is_writable($path . $dir)) {
61        echo 'NOT OK';
62    } else {
63        echo 'OK';
64    }
65    echo "<br />";
66}
67
68echo '<h3>Check if you setup config files</h3>';
69echo '<p>Checks if the files exist and if they are readable.</p>';
70
71foreach ($create_files AS $file) {
72    echo "File $file: ";
73    if (file_exists($path . $file) && is_readable($path . $file)) {
74        echo 'OK';
75    } else {
76        echo 'NOT OK';
77    }
78    echo '<br />';
79}
80
81echo '<h3>Check supplied DB settings</h3>';
82@include $path . 'config/db.inc.php';
83
84$db_working = false;
85if (isset($rcmail_config)) {
86    echo 'DB settings: ';
87    include_once 'MDB2.php';
88    $db = MDB2::connect($rcmail_config['db_dsnw']);
89    if (!MDB2::IsError($db)) {
90        echo 'OK';
91        $db->disconnect();
92        $db_working = true;
93    } else {
94        echo 'NOT OK';
95    }
96    echo '<br />';
97} else {
98    echo 'Could not open db.inc.php config file, or file is empty.<br />';
99}
100
101echo '<h3>TimeZone</h3>';
102echo 'Status: ';
103if ($db_working === true) {
104    require_once 'include/rcube_mdb2.inc';
105    $DB = new rcube_mdb2($rcmail_config['db_dsnw'], '', false);
106    $DB->db_connect('w');
107   
108    $tz_db    = $DB->unixtimestamp();
109    $tz_local = time();
110    if ($tz_db != $tz_local) {
111        echo 'NOT OK';
112    } else {
113        echo 'OK';
114    }
115} else {
116    echo 'Could not test (fix DB first).';
117}
118echo '<br />';
119
120echo '<h3>Checking .ini settings</h3>';
121
122$auto_start   = ini_get('session.auto_start');
123$file_uploads = ini_get('file_uploads');
124
125echo '<h4>session.auto_start</h4>';
126echo 'status: ';
127if ($auto_start == 1) {
128    echo 'NOT OK';
129} else {
130    echo 'OK';
131}
132echo '<br />';
133
134echo '<h4>file_uploads</h4>';
135echo 'status: ';
136if ($file_uploads == 1) {
137    echo 'OK';
138} else {
139    echo 'NOT OK';
140}
141
142/*
143 * Probably not needed because we have a custom handler
144echo '<h4>session.save_path</h4>';
145echo 'status: ';
146$save_path = ini_get('session.save_path');
147if (empty($save_path)) {
148    echo 'NOT OK';
149} else {
150    echo "OK: $save_path";
151    if (!file_exists($save_path)) {
152        echo ', but it does not exist';
153    } else {
154        if (!is_readable($save_path) || !is_writable($save_path)) {
155            echo ', but permissions to read and/or write are missing';
156        }
157    }
158}
159echo '<br />';
160 */
161?>
Note: See TracBrowser for help on using the repository browser.