Files
roundcubemail/program/actions/utils/killcache.php
Michael Voříšek e7d7e62146 Modernize more basic CS II (#9254)
* fix "integer_literal_case"

* fix "phpdoc_separation"

* fix "phpdoc_var_without_name"

* fix "operator_linebreak"

* fix "no_alias_language_construct_call"

* fix "list_syntax"

* fix "concat_space"

* fix "array_syntax"

* fix "binary_operator_spaces"

* fix "binary_operator_spaces" relaxed

* fix "phpdoc_types_order"

* fix "phpdoc_trim"

* fix "native_type_declaration_casing"

* fix "method_chaining_indentation"

* fix "phpdoc_no_package"

* fix "elseif"

* fix PHP CS Fixer config itself too

* fix "native_type_declaration_casing"
2023-12-17 13:14:45 +01:00

67 lines
2.5 KiB
PHP

<?php
/*
+-----------------------------------------------------------------------+
| This file is part of the Roundcube Webmail client |
| |
| Copyright (C) The Roundcube Dev Team |
| |
| Licensed under the GNU General Public License version 3 or |
| any later version with exceptions for skins & plugins. |
| See the README file for a full license statement. |
| |
| PURPOSE: |
| Delete rows from cache tables |
+-----------------------------------------------------------------------+
| Author: Dennis P. Nikolaenko <dennis@nikolaenko.ru> |
+-----------------------------------------------------------------------+
*/
class rcmail_action_utils_killcache extends rcmail_action
{
/**
* Request handler.
*
* @param array $args Arguments from the previous step(s)
*/
public function run($args = [])
{
$rcmail = rcmail::get_instance();
// don't allow public access if not in devel_mode
if (!$rcmail->config->get('devel_mode')) {
http_response_code(401);
exit("Access denied!");
}
// @TODO: transaction here (if supported by DB) would be a good thing
$res = $rcmail->db->query("DELETE FROM " . $rcmail->db->table_name('cache', true));
if ($err = $rcmail->db->is_error($res)) {
exit($err);
}
$res = $rcmail->db->query("DELETE FROM " . $rcmail->db->table_name('cache_shared', true));
if ($err = $rcmail->db->is_error($res)) {
exit($err);
}
$res = $rcmail->db->query("DELETE FROM " . $rcmail->db->table_name('cache_messages', true));
if ($err = $rcmail->db->is_error($res)) {
exit($err);
}
$res = $rcmail->db->query("DELETE FROM " . $rcmail->db->table_name('cache_index', true));
if ($err = $rcmail->db->is_error($res)) {
exit($err);
}
$res = $rcmail->db->query("DELETE FROM " . $rcmail->db->table_name('cache_thread', true));
if ($err = $rcmail->db->is_error($res)) {
exit($err);
}
echo "Cache cleared\n";
exit;
}
}