]> git.donarmstrong.com Git - roundcube.git/blob - bin/killcache.php
Merge commit 'upstream/0.2.1' into unstable-import
[roundcube.git] / bin / killcache.php
1 <?php
2 /*
3
4  +-----------------------------------------------------------------------+
5  | bin/killcache.php                                                     |
6  |                                                                       |
7  | This file is part of the RoundCube Webmail client                     |
8  | Copyright (C) 2005-2009, RoundCube Dev. - Switzerland                 |
9  | Licensed under the GNU GPL                                            |
10  |                                                                       |
11  | PURPOSE:                                                              |
12  |   Delete rows from cache and messages tables                          |
13  |                                                                       |
14  +-----------------------------------------------------------------------+
15  | Author: Dennis P. Nikolaenko <dennis@nikolaenko.ru>                   |
16  +-----------------------------------------------------------------------+
17
18  $Id: killcache.php 2238 2009-01-17 03:27:41Z till $
19
20 */
21
22 define('INSTALL_PATH', realpath(dirname(__FILE__).'/..') . '/');
23 require INSTALL_PATH . 'program/include/iniset.php';
24
25 $config = new rcube_config();
26
27 // don't allow public access if not in devel_mode
28 if (!$config->get('devel_mode') && $_SERVER['REMOTE_ADDR']) {
29     header("HTTP/1.0 401 Access denied");
30     die("Access denied!");
31 }
32
33 $options = array(
34     'use_transactions' => false,
35     'log_line_break' => "\n",
36     'idxname_format' => '%s',
37     'debug' => false,
38     'quote_identifier' => true,
39     'force_defaults' => false,
40     'portability' => true
41 );
42
43 $dbh = MDB2::factory($config->get('db_dsnw'), $options);
44 if (PEAR::isError($dbh)) {
45     exit($mdb2->getMessage());
46 }
47
48 //TODO: transaction here (if supported by DB) would be a good thing
49 $res =& $dbh->exec("DELETE FROM cache");
50 if (PEAR::isError($res)) {
51     $dbh->disconnect();
52     exit($res->getMessage());
53 }
54
55 $res =& $dbh->exec("DELETE FROM messages");
56 if (PEAR::isError($res)) {
57     $dbh->disconnect();
58     exit($res->getMessage());
59 }
60
61 echo "Cache cleared\n";
62
63 $dbh->disconnect();
64
65 ?>