]> git.donarmstrong.com Git - roundcube.git/blob - bin/killcache.php
Merge commit 'upstream/0.2_stable' 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-2008, 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 1955 2008-10-07 19:11:06Z alec $
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
34 $dbh =& MDB2::factory($config->get('db_dsnw'), $options);
35 if (PEAR::isError($dbh)) {
36         exit($mdb2->getMessage());
37 }
38
39 //TODO: transaction here (if supported by DB) would be a good thing
40 $res =& $dbh->exec("DELETE FROM cache");
41 if (PEAR::isError($res)) {
42   $dbh->disconnect();
43   exit($res->getMessage());
44 };
45
46 $res =& $dbh->exec("DELETE FROM messages");
47 if (PEAR::isError($res)) {
48   $dbh->disconnect();
49   exit($res->getMessage());
50 };
51
52 echo "Cache cleared\n";
53
54 $dbh->disconnect();
55
56 ?>