alecpl
2010-04-21 93c01888547210f54bd593d0774f9f63ec38f7a7
commit | author | age
155bbb 1 <?php
A 2 /*
3
4  +-----------------------------------------------------------------------+
5  | bin/killcache.php                                                     |
6  |                                                                       |
7  | This file is part of the RoundCube Webmail client                     |
cbbef3 8  | Copyright (C) 2005-2009, RoundCube Dev. - Switzerland                 |
155bbb 9  | Licensed under the GNU GPL                                            |
A 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$
19
20 */
21
22 define('INSTALL_PATH', realpath(dirname(__FILE__).'/..') . '/');
b113c5 23 require INSTALL_PATH . 'program/include/iniset.php';
155bbb 24
A 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']) {
b113c5 29     header("HTTP/1.0 401 Access denied");
T 30     die("Access denied!");
155bbb 31 }
A 32
b113c5 33 $options = array(
T 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 );
155bbb 42
b113c5 43 $dbh = MDB2::factory($config->get('db_dsnw'), $options);
155bbb 44 if (PEAR::isError($dbh)) {
b113c5 45     exit($mdb2->getMessage());
155bbb 46 }
A 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)) {
b113c5 51     $dbh->disconnect();
T 52     exit($res->getMessage());
53 }
155bbb 54
A 55 $res =& $dbh->exec("DELETE FROM messages");
56 if (PEAR::isError($res)) {
b113c5 57     $dbh->disconnect();
T 58     exit($res->getMessage());
59 }
155bbb 60
A 61 echo "Cache cleared\n";
62
63 $dbh->disconnect();
64
65 ?>