Gazelle/sections/tools/development/clear_cache.php

82 lines
2.5 KiB
PHP
Raw Normal View History

2011-03-28 14:21:28 +00:00
<?
2013-05-02 08:00:23 +00:00
if (!check_perms('users_mod') || !check_perms('admin_clear_cache')) {
2011-03-28 14:21:28 +00:00
error(403);
}
2012-10-11 08:00:15 +00:00
View::show_header('Clear a cache key');
2011-03-28 14:21:28 +00:00
//Make sure the form was sent
2013-11-06 08:00:50 +00:00
if (!empty($_GET['key'])) {
if ($_GET['submit'] == 'Multi') {
$Keys = array_map('trim', preg_split('/\s+/', $_GET['key']));
2011-03-28 14:21:28 +00:00
} else {
2013-11-06 08:00:50 +00:00
$Keys = [trim($_GET['key'])];
2011-03-28 14:21:28 +00:00
}
}
2013-11-06 08:00:50 +00:00
if (isset($Keys) && $_GET['type'] == 'clear') {
foreach ($Keys as $Key) {
if (preg_match('/(.*?)(\d+)\.\.(\d+)$/', $Key, $Matches) && is_number($Matches[2]) && is_number($Matches[3])) {
for ($i = $Matches[2]; $i <= $Matches[3]; $i++) {
$Cache->delete_value($Matches[1].$i);
}
} else {
$Cache->delete_value($Key);
}
}
echo '<div class="save_message">Key(s) ' . implode(', ', array_map('display_str', $Keys)) . ' cleared!</div>';
}
2013-12-12 08:01:01 +00:00
$MultiKeyTooltip = 'Enter cache keys delimited by any amount of whitespace.';
2011-03-28 14:21:28 +00:00
?>
2012-08-19 08:00:19 +00:00
<div class="header">
<h2>Clear a cache key</h2>
</div>
2013-11-11 08:00:59 +00:00
<table class="layout" cellpadding="2" cellspacing="1" border="0" align="center">
<tr>
<td>Key</td>
<td>
<form class="manage_form" name="cache" method="get" action="">
<input type="hidden" name="action" value="clear_cache" />
2011-03-28 14:21:28 +00:00
<select name="type">
<option value="view">View</option>
<option value="clear">Clear</option>
</select>
2013-11-06 08:00:50 +00:00
<input type="text" name="key" id="key" class="inputtext" value="<?=(isset($_GET['key']) && $_GET['submit'] != 'Multi' ? display_str($_GET['key']) : '')?>" />
<input type="submit" name="submit" value="Single" class="submit" />
2013-11-11 08:00:59 +00:00
</form>
</td>
</tr>
2013-12-12 08:01:01 +00:00
<tr class="tooltip" title="<?=$MultiKeyTooltip?>">
2013-11-11 08:00:59 +00:00
<td>Multi-key</td>
<td>
<form class="manage_form" name="cache" method="get" action="">
<input type="hidden" name="action" value="clear_cache" />
2013-11-06 08:00:50 +00:00
<select name="type">
<option value="view">View</option>
<option value="clear">Clear</option>
</select>
<textarea type="text" name="key" id="key" class="inputtext"><?=(isset($_GET['key']) && $_GET['submit'] == 'Multi' ? display_str($_GET['key']) : '')?></textarea>
<input type="submit" name="submit" value="Multi" class="submit" />
2013-11-11 08:00:59 +00:00
</form>
</td>
</tr>
2013-12-12 08:01:01 +00:00
</table>
2013-11-06 08:00:50 +00:00
<?
if (isset($Keys) && $_GET['type'] == 'view') {
2013-12-12 08:01:01 +00:00
?>
<table class="layout" cellpadding="2" cellspacing="1" border="0" align="center" style="margin-top: 1em;">
<?
2013-11-06 08:00:50 +00:00
foreach ($Keys as $Key) {
?>
2013-11-11 08:00:59 +00:00
<tr>
<td><?=display_str($Key)?></td>
<td>
<pre><? var_dump($Cache->get_value($Key)); ?></pre>
</td>
</tr>
2013-12-12 08:01:01 +00:00
<? } ?>
2013-11-11 08:00:59 +00:00
</table>
2013-11-06 08:00:50 +00:00
<?
2013-12-12 08:01:01 +00:00
}
2013-11-06 08:00:50 +00:00
View::show_footer();