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

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