root/eaccelerator/tags/0.9.5-rc1/control.php

Revision 226, 11.3 kB (checked in by hans, 2 years ago)

DOH, forgot to remove an ini_set. Its to hot and sunny to be developing :P

  • Property svn:keywords set to svn:eol-style
Line 
1 <?php
2 /*
3    +----------------------------------------------------------------------+
4    | eAccelerator control panel                                           |
5    +----------------------------------------------------------------------+
6    | Copyright (c) 2004-2006 eAccelerator                                  |
7    | http://eaccelerator.net                                              |
8    +----------------------------------------------------------------------+
9    | This source file is subject to version 2.00 of the Zend license,     |
10    | that is bundled with this package in the file LICENSE, and is        |
11    | available through the world-wide-web at the following url:           |
12    | http://www.zend.com/license/2_00.txt.                                |
13    | If you did not receive a copy of the Zend license and are unable to  |
14    | obtain it through the world-wide-web, please send a note to          |
15    | license@zend.com so we can mail you a copy immediately.              |
16    +----------------------------------------------------------------------+
17
18    $ Id: $
19 */
20
21 if (!function_exists('eaccelerator_info')) {
22     die('eAccelerator isn\'t installed or isn\'t compiled with info support!');
23 }
24
25 /** config **/
26 $user = "admin";
27 $pw = "eAccelerator";
28 /** /config **/
29
30 /* {{{ auth */
31 if (!isset($_SERVER['PHP_AUTH_USER']) || !isset($_SERVER['PHP_AUTH_USER']) ||
32         $_SERVER['PHP_AUTH_USER'] != $user || $_SERVER['PHP_AUTH_PW'] != $pw) {
33     header('WWW-Authenticate: Basic realm="eAccelerator control panel"');
34     header('HTTP/1.0 401 Unauthorized');
35     exit;
36 }
37 /* }}} */
38
39 /* {{{ process any commands */
40 $info = eaccelerator_info();
41 if (isset($_POST['caching'])) {
42     if ($info['cache']) {
43         eaccelerator_caching(false);
44     } else {
45         eaccelerator_caching(true);
46     }
47 } else if (isset($_POST['optimizer']) && function_exists('eaccelerator_optimizer')) {
48     if ($info['optimizer']) {
49         eaccelerator_optimizer(false);
50     } else {
51         eaccelerator_optimizer(true);
52     }
53 } else if (isset($_POST['clear'])) {
54     eaccelerator_clear();
55 } else if (isset($_POST['clean'])) {
56     eaccelerator_clean();
57 } else if (isset($_POST['purge'])) {
58     eaccelerator_purge();
59 }
60 $info = eaccelerator_info();
61 /* }}} */
62
63 function compare($x, $y)
64 {
65   global $sortby;
66
67   if ( $x[$sortby] == $y[$sortby] )
68     return 0;
69   else if ( $x[$sortby] < $y[$sortby] )
70     return -1;
71   else
72     return 1;
73 }
74
75 function revcompare($x, $y)
76 {
77   global $sortby;
78
79   if ( $x[$sortby] == $y[$sortby] )
80     return 0;
81   else if ( $x[$sortby] < $y[$sortby] )
82     return 1;
83   else
84     return -1;
85 }
86   
87 /* {{{ create_script_table */
88 function create_script_table($list) {
89   global $sortby;
90
91   if (isset($_GET['order']) && ($_GET['order'] == "asc" || $_GET['order'] =="desc")) {
92     $order = $_GET['order'];
93   } else {
94     $order = "asc";
95   }
96  
97   if (isset($_GET['sort'])) {
98     switch ($_GET['sort']) {
99       case "mtime":
100       case "size":
101       case "reloads":
102       case "hits":
103         $sortby = $_GET['sort'];
104         ($order == "asc" ? uasort($list, 'compare') : uasort($list, 'revcompare'));
105         break;
106       default:
107         $sortby = "file";
108         ($order == "asc" ? uasort($list, 'compare') : uasort($list, 'revcompare'));
109     }
110   }
111
112 ?>
113     <table>
114         <tr>
115             <th><a href="<?=$_SERVER['PHP_SELF']?>?sort=file&order=<?=($order == "asc" ? "desc" : "asc")?>">Filename</a>&nbsp;<? if($sortby == "file") echo ($order == "asc" ? "&darr;" : "&uarr;")?></th>
116             <th><a href="<?=$_SERVER['PHP_SELF']?>?sort=mtime&order=<?=($order == "asc" ? "desc" : "asc")?>">MTime</a>&nbsp;<? if($sortby == "mtime") echo ($order == "asc" ? "&darr;" : "&uarr;")?></th>
117             <th><a href="<?=$_SERVER['PHP_SELF']?>?sort=size&order=<?=($order == "asc" ? "desc" : "asc")?>">Size</a>&nbsp;<? if($sortby == "size") echo ($order == "asc" ? "&darr;" : "&uarr;")?></th>
118             <th><a href="<?=$_SERVER['PHP_SELF']?>?sort=reloads&order=<?=($order == "asc" ? "desc" : "asc")?>">Reloads</a>&nbsp;<? if($sortby == "reloads") echo ($order == "asc" ? "&darr;" : "&uarr;")?></th>
119             <th><a href="<?=$_SERVER['PHP_SELF']?>?sort=hits&order=<?=($order == "asc" ? "desc" : "asc")?>">Hits</a>&nbsp;<? if($sortby == "hits") echo ($order == "asc" ? "&darr;" : "&uarr;")?></th>
120         </tr>
121     <?php
122           switch ($sortby) {
123             case "mtime":
124             case "size":
125             case "reloads":
126             case "hits":
127               ($order == "asc" ? uasort($list, 'compare') : uasort($list, 'revcompare'));
128               break;
129             case "file":
130             default:
131               $sortby = "file";
132               ($order == "asc" ? uasort($list, 'compare') : uasort($list, 'revcompare'));
133               
134           }
135
136           foreach($list as $script) { ?>
137         <tr>
138     <?php   if (function_exists('eaccelerator_dasm_file')) { ?>
139             <td class="e"><a href="dasm.php?file=<?php echo $script['file']; ?>"><?php echo $script['file']; ?></a></td>
140     <?php   } else { ?>
141             <td class="e"><?php echo $script['file']; ?></td>
142     <?php   } ?>
143             <td class="vr"><?php echo date('Y-m-d H:i', $script['mtime']); ?></td>
144             <td class="vr"><?php echo number_format($script['size'] / 1024, 2); ?> KB</td>
145             <td class="vr"><?php echo $script['reloads']; ?> (<?php echo $script['usecount']; ?>)</td>
146             <td class="vr"><?php echo $script['hits']; ?></td>
147         </tr>
148     <?php } ?>
149     </table>
150 <?php
151 }
152 /* }}} */
153
154 /* {{{ create_key_table */
155 function create_key_table($list) {
156 ?>
157     <table class="key">
158         <tr>
159             <th>Name</th>
160             <th>Created</th>
161             <th>Size</th>
162             <th>ttl</th>
163         </tr>
164 <?php
165     foreach($list as $key) {
166 ?>
167         <tr>
168             <td class="e"><?php echo $key['name']; ?></td>
169             <td class="vr"><?php echo date('Y-m-d H:i', $key['created']); ?></td>
170             <td class="vr"><?php echo number_format($key['size']/1024, 3); ?>KB</td>
171             <td class="vr"><?php
172                 if ($key['ttl'] == -1) {
173                     echo 'expired';
174                 } elseif ($key['ttl'] == 0) {
175                     echo 'none';
176                 } else {
177                     echo date('Y-m-d H:i', $key['ttl']);
178                 }
179             ?></td>
180         </tr>
181 <?php
182     }
183 ?>
184     </table>
185 <?php
186 }
187 /* }}} */
188
189 /* {{{ print_header */
190 function print_header() { ?>
191 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
192 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
193 <head>
194     <title>eAccelerator control panel</title>
195     <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
196     <meta http-equiv="Content-Style-Type" content="text/css" />
197     <meta http-equiv="Content-Language" content="en" />
198
199     <style type="text/css" media="all">
200         body {background-color: #ffffff; color: #000000;}
201         body, td, th, h1, h2 {font-family: sans-serif;}
202         pre {margin: 0px; font-family: monospace;}
203         a:link {color: #000099; text-decoration: none}
204         a:hover {text-decoration: underline;}
205         table {border-collapse: collapse; width: 800px;}
206         .center {text-align: center;}
207         .center table { margin-left: auto; margin-right: auto; text-align: left;}
208         .center th { text-align: center !important; }
209         td, th { border: 1px solid #000000; font-size: 75%; vertical-align: baseline;}
210         h1 {font-size: 150%;}
211         h2 {font-size: 125%;}
212         .p {text-align: left;}
213         .e {background-color: #ccccff; font-weight: bold; color: #000000;}
214         .h,th {background-color: #9999cc; font-weight: bold; color: #000000;}
215         .v,td {background-color: #cccccc; color: #000000;}
216         .vr{background-color: #cccccc; text-align: right; color: #000000; white-space: nowrap;}
217         img {float: right; border: 0px;}
218         hr {width: 600px; background-color: #cccccc; border: 0px; height: 1px; color: #000000;}
219         input {width: 150px}
220         h1 {width: 800px;  border: 1px solid #000000; margin-left: auto; margin-right: auto; background-color: #9999cc;}
221     </style>
222 </head>
223 <?php
224 }
225 /* }}} */
226 ?>
227
228 <?php print_header(); ?>
229 <body class="center">
230 <h1>eAccelerator <?php echo $info['version']; ?> control panel</h1>
231
232 <!-- {{{ information -->
233 <h2>Information</h2>
234 <table>
235 <tr>
236     <td class="e">Caching enabled</td>
237     <td><?php echo $info['cache'] ? 'yes':'no' ?></td>
238 </tr>
239 <tr>
240     <td class="e">Optimizer enabled</td>
241     <td><?php echo $info['optimizer'] ? 'yes':'no' ?></td>
242 </tr>
243 <tr>
244     <td class="e">Memory usage</td>
245     <td><?php echo number_format(100 * $info['memoryAllocated'] / $info['memorySize'], 2); ?>%
246         (<?php echo number_format($info['memoryAllocated'] / (1024*1024), 2); ?>MB/
247         <?php echo number_format($info['memorySize'] / (1024*1024), 2); ?>MB)</td>
248 </tr>
249 <tr>
250     <td class="e">Free memory</td>
251     <td><?php echo number_format($info['memoryAvailable'] / (1024*1024), 2); ?>MB</td>
252 </tr>
253 <tr>
254     <td class="e">Cached scripts</td>
255     <td><?php echo $info['cachedScripts']; ?></td>
256 </tr>
257 <tr>
258     <td class="e">Removed scripts</td>
259     <td><?php echo $info['removedScripts']; ?></td>
260 </tr>
261 <tr>
262     <td class="e">Cached keys</td>
263     <td><?php echo $info['cachedKeys']; ?></td>
264 </tr>
265 </table>
266 <!-- }}} -->
267
268 <!-- {{{ control -->
269 <h2>Actions</h2>
270 <form name="ea_control" method="post">
271     <table>
272         <tr>
273             <td class="e">Caching</td>
274             <td><input type="submit" name="caching" value="<?php echo $info['cache']?'disable':'enable'; ?>" /></td>
275         </tr>
276         <tr>
277             <td class="e">Optimizer</td>
278             <td><input type="submit" name="optimizer" value="<?php echo $info['optimizer']?'disable':'enable'; ?>" /></td>
279         </tr>
280         <tr>
281             <td class="e">Clear cache</td>
282             <td><input type="submit" name="clear" value="clear" title="remove all unused scripts and data from shared memory and disk cache" /></td>
283         </tr>
284         <tr>
285             <td class="e">Clean cache</td>
286             <td><input type="submit" name="clean" value="clean" title=" remove all expired scripts and data from shared memory and disk cache" /></td>
287         </tr>
288         <tr>
289             <td class="e">Purge cache</td>
290             <td><input type="submit" name="purge" value="purge" title="remove all 'removed' scripts from shared memory" /></td>
291         </tr>
292     </table>
293 </form>
294 <!-- }}} -->
295
296 <h2>Cached scripts</h2>
297 <?php create_script_table(eaccelerator_cached_scripts()); ?>
298
299 <h2>Removed scripts</h2>
300 <?php create_script_table(eaccelerator_removed_scripts()); ?>
301
302 <?php
303 if (function_exists('eaccelerator_get')) {
304     echo "<h2>Cached keys</h2>";
305     create_key_table(eaccelerator_list_keys());
306 }
307 ?>
308
309 <!-- {{{ footer -->
310 <br /><br />
311 <table>
312     <tr><td class="center">
313     <a href="http://eaccelerator.net"><img src="?=<?php echo $info['logo']; ?>" alt="eA logo" /></a>
314     <strong>Created by the eAccelerator team, <a href="http://eaccelerator.net">http://eaccelerator.net</a></strong><br /><br />
315     <nobr>eAccelerator <?php echo $info['version']; ?> [shm:<?php echo $info['shm_type']?> sem:<?php echo $info['sem_type']; ?>]</nobr><br />
316     <nobr>PHP <?php echo phpversion();?> [ZE <?php echo zend_version(); ?>]</nobr><br />
317     <nobr>Using <?php echo php_sapi_name();?> on <?php echo php_uname(); ?></nobr><br />
318     </td></tr>
319 </table>
320 <!-- }}} -->
321 </body>
322 </html>
323
324 <?php
325
326 /*
327  * Local variables:
328  * tab-width: 4
329  * c-basic-offset: 4
330  * End:
331  * vim600: noet sw=4 ts=4 fdm=marker
332  * vim<600: noet sw=4 ts=4
333  */
334
335 ?>
336
Note: See TracBrowser for help on using the browser.