Skip to content

Commit ebdf807

Browse files
authored
Merge pull request #12 from JorgenEvens/chore/cleanup-action-handling
[actions] cleanup of action detection.
2 parents 7361ffb + e6384f1 commit ebdf807

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

cache.php

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ function __construct($search = null) { parent::__construct('user', $search); }
3434
$realpathCacheTotal = machine_size(ini_get('realpath_cache_size'));
3535
}
3636

37+
function is_action($action) {
38+
return isset( $_GET['action'] ) && $_GET['action'] == $action;
39+
}
40+
3741
function percentage( $a, $b ) {
3842
return ( $a / $b ) * 100;
3943
}
@@ -188,12 +192,12 @@ function sort_list(&$list) {
188192
/* OPcache */
189193
/********************************/
190194
if (ENABLE_OPCACHE) {
191-
if( isset( $_GET['action'] ) && $_GET['action'] == 'op_restart' ) {
195+
if( is_action('op_restart') ) {
192196
opcache_reset();
193197
redirect('?');
194198
}
195199

196-
if( isset( $_GET['action'] ) && $_GET['action'] == 'op_delete' ) {
200+
if( is_action('op_delete') ) {
197201
$selector = get_selector();
198202

199203
foreach( $opcache['scripts'] as $key => $value ) {
@@ -209,12 +213,12 @@ function sort_list(&$list) {
209213
/* APC */
210214
/********************************/
211215
if (ENABLE_APC) {
212-
if( isset( $_GET['action'] ) && $_GET['action'] == 'apcu_restart' ) {
216+
if( is_action('apcu_restart') ) {
213217
apcu_delete( new ApcuIterator('#.*#') );
214218
redirect('?');
215219
}
216220

217-
if( isset( $_GET['action'] ) && $_GET['action'] == 'apcu_delete' ) {
221+
if( is_action('apcu_delete') ) {
218222
apcu_delete( new ApcuIterator(get_selector()) );
219223
redirect( '?action=apcu_select&selector=' . $_GET['selector'] );
220224
}
@@ -224,12 +228,12 @@ function sort_list(&$list) {
224228
/* realpath */
225229
/********************************/
226230
if (ENABLE_REALPATH) {
227-
if( isset( $_GET['action'] ) && $_GET['action'] == 'realpath_clear' ) {
231+
if( is_action('realpath_clear') ) {
228232
clearstatcache(true);
229233
redirect('?action=realpath_show#realpath');
230234
}
231235

232-
if( isset( $_GET['action'] ) && $_GET['action'] == 'realpath_delete' ) {
236+
if( is_action('realpath_delete') ) {
233237
$selector = get_selector();
234238

235239
foreach( $realpath as $item ) {
@@ -318,7 +322,7 @@ function sort_list(&$list) {
318322
</label>
319323
</form>
320324
</div>
321-
<?php if( isset( $_GET['action'] ) && $_GET['action'] == 'op_select' ): ?>
325+
<?php if( is_action('op_select') ): ?>
322326
<div>
323327
<h3>Keys matching <?=htmlentities('"'.$_GET['selector'].'"')?></h3>
324328
<table>
@@ -376,13 +380,13 @@ function sort_list(&$list) {
376380
<label><input type="checkbox" name="apcu_show_expired" <?=isset($_GET['apcu_show_expired'])?'checked="checked"':''?> />Show expired</label>
377381
</form>
378382
</div>
379-
<?php if( isset( $_GET['action'] ) && $_GET['action'] == 'apcu_view' ): ?>
383+
<?php if( is_action('apcu_view') ): ?>
380384
<div>
381385
<h3>Value for <?=htmlentities('"'.$_GET['selector'].'"')?></h3>
382386
<pre><?=htmlentities(var_export(apcu_fetch(urldecode($_GET['selector'])), true)); ?></pre>
383387
</div>
384388
<?php endif; ?>
385-
<?php if( isset( $_GET['action'] ) && $_GET['action'] == 'apcu_select' ): ?>
389+
<?php if( is_action('apcu_select') ): ?>
386390
<div>
387391
<h3>Keys matching <?=htmlentities('"'.$_GET['selector'].'"')?></h3>
388392
<table>
@@ -444,7 +448,7 @@ function sort_list(&$list) {
444448
</form>
445449
</div>
446450

447-
<?php if( isset( $_GET['action'] ) && $_GET['action'] == 'realpath_select' ): ?>
451+
<?php if( is_action('realpath_select') ): ?>
448452
<div>
449453
<table>
450454
<thead>

0 commit comments

Comments
 (0)