1
1
<?php
2
+ if (!extension_loaded ('apcu ' )) {
3
+ function apcu_cache_info ($ limited = false ) { return apc_cache_info ('user ' , $ limited ); }
4
+ function apcu_sma_info ($ limited = false ) { return apc_sma_info ($ limited ); }
5
+ function apcu_fetch ($ key , &$ success ) { return apc_fetch ($ key , $ success ); }
6
+ function apcu_delete ($ key ) { return apc_delete ($ key ); }
7
+ class ApcuIterator extends ApcIterator {}
8
+ }
9
+
10
+ $ apcVersion = extension_loaded ('apcu ' ) ? 'APCu ' : 'APC ' ;
2
11
$ opcache = opcache_get_status (true );
3
12
$ apc = array (
4
- 'cache ' => apc_cache_info ( ' user ' ),
5
- 'sma ' => apc_sma_info (true )
13
+ 'cache ' => apcu_cache_info ( ),
14
+ 'sma ' => apcu_sma_info (true )
6
15
);
7
16
8
17
function percentage ( $ a , $ b ) {
@@ -46,7 +55,7 @@ function opcache_stat( $stat ) {
46
55
return $ opcache ['opcache_statistics ' ][$ stat ];
47
56
}
48
57
49
- function apc_mem ( $ key ) {
58
+ function apcu_mem ( $ key ) {
50
59
global $ apc ;
51
60
52
61
if ( $ key == 'total ' )
@@ -56,13 +65,13 @@ function apc_mem( $key ) {
56
65
return $ apc ['sma ' ]['avail_mem ' ];
57
66
58
67
if ( $ key == 'used ' )
59
- return apc_mem ('total ' ) - apc_mem ('free ' );
68
+ return apcu_mem ('total ' ) - apcu_mem ('free ' );
60
69
61
70
return 0 ;
62
71
63
72
}
64
73
65
- function apc_ref () {
74
+ function apcu_ref () {
66
75
global $ apc ;
67
76
68
77
if ( !empty ( $ apc ['cache ' ]['cache_list ' ] ) )
@@ -154,14 +163,14 @@ function sort_list(&$list) {
154
163
}
155
164
156
165
// APC
157
- if ( isset ( $ _GET ['action ' ] ) && $ _GET ['action ' ] == 'apc_restart ' ) {
158
- apc_delete ( new ApcIterator ('#.*# ' ) );
166
+ if ( isset ( $ _GET ['action ' ] ) && $ _GET ['action ' ] == 'apcu_restart ' ) {
167
+ apcu_delete ( new ApcuIterator ('#.*# ' ) );
159
168
redirect ('? ' );
160
169
}
161
170
162
- if ( isset ( $ _GET ['action ' ] ) && $ _GET ['action ' ] == 'apc_delete ' ) {
163
- apc_delete ( new ApcIterator ('user ' ,get_selector ()) );
164
- redirect ( '?action=apc_select &selector= ' . $ _GET ['selector ' ] );
171
+ if ( isset ( $ _GET ['action ' ] ) && $ _GET ['action ' ] == 'apcu_delete ' ) {
172
+ apcu_delete ( new ApcuIterator ('user ' ,get_selector ()) );
173
+ redirect ( '?action=apcu_select &selector= ' . $ _GET ['selector ' ] );
165
174
}
166
175
?> <html>
167
176
<head>
@@ -192,7 +201,7 @@ function sort_list(&$list) {
192
201
<body>
193
202
<div class="wrap">
194
203
<div>
195
- Goto: <a href="#opcache">PHP Opcache</a> or <a href="#apcu">APCu </a>
204
+ Goto: <a href="#opcache">PHP Opcache</a> or <a href="#apcu"><?= $ apcVersion ?> </a>
196
205
</div>
197
206
<h2 id="opcache">PHP Opcache</h2>
198
207
<div>
@@ -266,42 +275,42 @@ function sort_list(&$list) {
266
275
</div>
267
276
<?php endif ; ?>
268
277
269
- <h2 id="apcu">APCu </h2>
278
+ <h2 id="apcu"><?= $ apcVersion ?> </h2>
270
279
<div>
271
- <h3>Memory <?= human_size (apc_mem ('used ' ))?> of <?= human_size (apc_mem ('total ' ))?> </h3>
280
+ <h3>Memory <?= human_size (apcu_mem ('used ' ))?> of <?= human_size (apcu_mem ('total ' ))?> </h3>
272
281
<div class="full bar green">
273
- <div class="orange" style="width: <?= percentage (apc_mem ('used ' ), apc_mem ('total ' ))?> %"></div>
282
+ <div class="orange" style="width: <?= percentage (apcu_mem ('used ' ), apcu_mem ('total ' ))?> %"></div>
274
283
</div>
275
284
</div>
276
285
<div>
277
286
<h3>Actions</h3>
278
287
<form action="?" method="GET">
279
288
<label>Cache:
280
- <button name="action" value="apc_restart ">Restart</button>
289
+ <button name="action" value="apcu_restart ">Restart</button>
281
290
</label>
282
291
</form>
283
292
<form action="?" method="GET">
284
293
<label>Key(s):
285
294
<input name="selector" type="text" value="" placeholder=".*" />
286
295
</label>
287
- <button type="submit" name="action" value="apc_select ">Select</button>
288
- <button type="submit" name="action" value="apc_delete ">Delete</button>
289
- <label><input type="checkbox" name="apc_show_expired " <?= isset ($ _GET ['apc_show_expired ' ])?'checked="checked" ' :'' ?> />Show expired</label>
296
+ <button type="submit" name="action" value="apcu_select ">Select</button>
297
+ <button type="submit" name="action" value="apcu_delete ">Delete</button>
298
+ <label><input type="checkbox" name="apcu_show_expired " <?= isset ($ _GET ['apcu_show_expired ' ])?'checked="checked" ' :'' ?> />Show expired</label>
290
299
</form>
291
300
</div>
292
- <?php if ( isset ( $ _GET ['action ' ] ) && $ _GET ['action ' ] == 'apc_view ' ): ?>
301
+ <?php if ( isset ( $ _GET ['action ' ] ) && $ _GET ['action ' ] == 'apcu_view ' ): ?>
293
302
<div>
294
303
<h3>Value for <?= htmlentities ('" ' .$ _GET ['selector ' ].'" ' )?> </h3>
295
- <pre><?php var_dump ( apc_fetch (urldecode ($ _GET ['selector ' ])) ); ?> </pre>
304
+ <pre><?php var_dump ( apcu_fetch (urldecode ($ _GET ['selector ' ])) ); ?> </pre>
296
305
</div>
297
306
<?php endif ; ?>
298
- <?php if ( isset ( $ _GET ['action ' ] ) && $ _GET ['action ' ] == 'apc_select ' ): ?>
307
+ <?php if ( isset ( $ _GET ['action ' ] ) && $ _GET ['action ' ] == 'apcu_select ' ): ?>
299
308
<div>
300
309
<h3>Keys matching <?= htmlentities ('" ' .$ _GET ['selector ' ].'" ' )?> </h3>
301
310
<table>
302
311
<thead>
303
312
<tr>
304
- <th><a href="<?= sort_url (has_key (apc_ref (), 'key ' , 'info ' ))?> ">Key</a></th>
313
+ <th><a href="<?= sort_url (has_key (apcu_ref (), 'key ' , 'info ' ))?> ">Key</a></th>
305
314
<th><a href="<?= sort_url ('nhits ' )?> ">Hits</a></th>
306
315
<th><a href="<?= sort_url ('mem_size ' )?> ">Size</a></th>
307
316
<th><a href="<?= sort_url ('ttl ' )?> ">TTL</a></th>
@@ -314,7 +323,7 @@ function sort_list(&$list) {
314
323
315
324
<tbody>
316
325
<?php foreach ( sort_list ($ apc ['cache ' ]['cache_list ' ]) as $ item ):
317
- $ expired = !isset ( $ _GET ['apc_show_expired ' ] ) && $ item ['ttl ' ] > 0 && get_key ($ item , 'mtime ' , 'modification_time ' ) + $ item ['ttl ' ] < time ();
326
+ $ expired = !isset ( $ _GET ['apcu_show_expired ' ] ) && $ item ['ttl ' ] > 0 && get_key ($ item , 'mtime ' , 'modification_time ' ) + $ item ['ttl ' ] < time ();
318
327
if ( !preg_match (get_selector (), get_key ($ item , 'key ' , 'info ' )) || $ expired ) continue ;?>
319
328
<tr>
320
329
<td><?= get_key ($ item , 'key ' , 'info ' )?> </td>
@@ -323,8 +332,8 @@ function sort_list(&$list) {
323
332
<td><?= $ item ['ttl ' ]?> </td>
324
333
<td><?= date ('Y-m-d H:i ' , get_key ($ item , 'mtime ' , 'modification_time ' ) + $ item ['ttl ' ] )?> </td>
325
334
<td>
326
- <a href="?action=apc_delete &selector=<?= urlencode ('^ ' .get_key ($ item , 'key ' , 'info ' ).'$ ' )?> ">Delete</a>
327
- <a href="?action=apc_view &selector=<?= urlencode (get_key ($ item , 'key ' , 'info ' ))?> ">View</a>
335
+ <a href="?action=apcu_delete &selector=<?= urlencode ('^ ' .get_key ($ item , 'key ' , 'info ' ).'$ ' )?> ">Delete</a>
336
+ <a href="?action=apcu_view &selector=<?= urlencode (get_key ($ item , 'key ' , 'info ' ))?> ">View</a>
328
337
</td>
329
338
</tr>
330
339
<?php endforeach ; ?>
@@ -334,4 +343,4 @@ function sort_list(&$list) {
334
343
<?php endif ; ?>
335
344
</div>
336
345
</body>
337
- </html>
346
+ </html>
0 commit comments