|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* EGgroupware administration |
|
4
|
|
|
* |
|
5
|
|
|
* @link http://www.egroupware.org |
|
6
|
|
|
* @package admin |
|
7
|
|
|
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License |
|
8
|
|
|
* @version $Id$ |
|
9
|
|
|
*/ |
|
10
|
|
|
|
|
11
|
|
|
$GLOBALS['egw_info']['flags'] = array( |
|
12
|
|
|
'noheader' => True, |
|
13
|
|
|
'nonavbar' => True, |
|
14
|
|
|
'currentapp' => 'admin' |
|
15
|
|
|
); |
|
16
|
|
|
include('../header.inc.php'); |
|
17
|
|
|
|
|
18
|
|
|
if ($GLOBALS['egw']->acl->check('info_access',1,'admin')) |
|
19
|
|
|
{ |
|
20
|
|
|
$GLOBALS['egw']->redirect_link('/index.php'); |
|
21
|
|
|
} |
|
22
|
|
|
|
|
23
|
|
|
/* |
|
24
|
|
|
+----------------------------------------------------------------------+ |
|
25
|
|
|
| APC | |
|
26
|
|
|
+----------------------------------------------------------------------+ |
|
27
|
|
|
| Copyright (c) 2006-2011 The PHP Group | |
|
28
|
|
|
+----------------------------------------------------------------------+ |
|
29
|
|
|
| This source file is subject to version 3.01 of the PHP license, | |
|
30
|
|
|
| that is bundled with this package in the file LICENSE, and is | |
|
31
|
|
|
| available through the world-wide-web at the following url: | |
|
32
|
|
|
| http://www.php.net/license/3_01.txt | |
|
33
|
|
|
| If you did not receive a copy of the PHP license and are unable to | |
|
34
|
|
|
| obtain it through the world-wide-web, please send a note to | |
|
35
|
|
|
| [email protected] so we can mail you a copy immediately. | |
|
36
|
|
|
+----------------------------------------------------------------------+ |
|
37
|
|
|
| Authors: Ralf Becker <[email protected]> | |
|
38
|
|
|
| Rasmus Lerdorf <[email protected]> | |
|
39
|
|
|
| Ilia Alshanetsky <[email protected]> | |
|
40
|
|
|
+----------------------------------------------------------------------+ |
|
41
|
|
|
|
|
42
|
|
|
All other licensing and usage conditions are those of the PHP Group. |
|
43
|
|
|
|
|
44
|
|
|
*/ |
|
45
|
|
|
|
|
46
|
|
|
$VERSION='$Id$'; |
|
47
|
|
|
|
|
48
|
|
|
////////// READ OPTIONAL CONFIGURATION FILE //////////// |
|
49
|
|
|
if (file_exists("apc.conf.php")) include("apc.conf.php"); |
|
50
|
|
|
//////////////////////////////////////////////////////// |
|
51
|
|
|
|
|
52
|
|
|
////////// BEGIN OF DEFAULT CONFIG AREA /////////////////////////////////////////////////////////// |
|
53
|
|
|
|
|
54
|
|
|
defaults('USE_AUTHENTICATION',1); // Use (internal) authentication - best choice if |
|
55
|
|
|
// no other authentication is available |
|
56
|
|
|
// If set to 0: |
|
57
|
|
|
// There will be no further authentication. You |
|
58
|
|
|
// will have to handle this by yourself! |
|
59
|
|
|
// If set to 1: |
|
60
|
|
|
// You need to change ADMIN_PASSWORD to make |
|
61
|
|
|
// this work! |
|
62
|
|
|
defaults('ADMIN_USERNAME','apc'); // Admin Username |
|
63
|
|
|
defaults('ADMIN_PASSWORD','password'); // Admin Password - CHANGE THIS TO ENABLE!!! |
|
64
|
|
|
|
|
65
|
|
|
// (beckerr) I'm using a clear text password here, because I've no good idea how to let |
|
66
|
|
|
// users generate a md5 or crypt password in a easy way to fill it in above |
|
67
|
|
|
|
|
68
|
|
|
//defaults('DATE_FORMAT', "d.m.Y H:i:s"); // German |
|
69
|
|
|
defaults('DATE_FORMAT', 'Y/m/d H:i:s'); // US |
|
70
|
|
|
|
|
71
|
|
|
defaults('GRAPH_SIZE',200); // Image size |
|
72
|
|
|
|
|
73
|
|
|
//defaults('PROXY', 'tcp://127.0.0.1:8080'); |
|
74
|
|
|
|
|
75
|
|
|
////////// END OF DEFAULT CONFIG AREA ///////////////////////////////////////////////////////////// |
|
76
|
|
|
|
|
77
|
|
|
|
|
78
|
|
|
// "define if not defined" |
|
79
|
|
|
function defaults($d,$v) { |
|
80
|
|
|
if (!defined($d)) define($d,$v); // or just @define(...) |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
// rewrite $PHP_SELF to block XSS attacks |
|
84
|
|
|
// |
|
85
|
|
|
$PHP_SELF= isset($_SERVER['PHP_SELF']) ? htmlentities(strip_tags($_SERVER['PHP_SELF'],''), ENT_QUOTES, 'UTF-8') : ''; |
|
86
|
|
|
$time = time(); |
|
87
|
|
|
$host = php_uname('n'); |
|
88
|
|
|
if($host) { $host = '('.$host.')'; } |
|
89
|
|
|
if (isset($_SERVER['SERVER_ADDR'])) { |
|
90
|
|
|
$host .= ' ('.$_SERVER['SERVER_ADDR'].')'; |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
|
|
// operation constants |
|
94
|
|
|
define('OB_HOST_STATS',1); |
|
95
|
|
|
define('OB_USER_CACHE',2); |
|
96
|
|
|
define('OB_VERSION_CHECK',3); |
|
97
|
|
|
|
|
98
|
|
|
// check validity of input variables |
|
99
|
|
|
$vardom=array( |
|
100
|
|
|
'OB' => '/^\d+$/', // operational mode switch |
|
101
|
|
|
'CC' => '/^[01]$/', // clear cache requested |
|
102
|
|
|
'DU' => '/^.*$/', // Delete User Key |
|
103
|
|
|
'SH' => '/^[a-z0-9]+$/', // shared object description |
|
104
|
|
|
|
|
105
|
|
|
'IMG' => '/^[123]$/', // image to generate |
|
106
|
|
|
'LO' => '/^1$/', // login requested |
|
107
|
|
|
|
|
108
|
|
|
'COUNT' => '/^\d+$/', // number of line displayed in list |
|
109
|
|
|
'SCOPE' => '/^[AD]$/', // list view scope |
|
110
|
|
|
'SORT1' => '/^[AHSMCDTZ]$/', // first sort key |
|
111
|
|
|
'SORT2' => '/^[DA]$/', // second sort key |
|
112
|
|
|
'AGGR' => '/^\d+$/', // aggregation by dir level |
|
113
|
|
|
'SEARCH' => '~^[a-zA-Z0-9/_.-]*$~' // aggregation by dir level |
|
114
|
|
|
); |
|
115
|
|
|
|
|
116
|
|
|
// cache scope |
|
117
|
|
|
$scope_list=array( |
|
118
|
|
|
'A' => 'cache_list', |
|
119
|
|
|
'D' => 'deleted_list' |
|
120
|
|
|
); |
|
121
|
|
|
|
|
122
|
|
|
// handle POST and GET requests |
|
123
|
|
|
if (empty($_REQUEST)) { |
|
124
|
|
|
if (!empty($_GET) && !empty($_POST)) { |
|
125
|
|
|
$_REQUEST = array_merge($_GET, $_POST); |
|
126
|
|
|
} else if (!empty($_GET)) { |
|
127
|
|
|
$_REQUEST = $_GET; |
|
128
|
|
|
} else if (!empty($_POST)) { |
|
129
|
|
|
$_REQUEST = $_POST; |
|
130
|
|
|
} else { |
|
131
|
|
|
$_REQUEST = array(); |
|
132
|
|
|
} |
|
133
|
|
|
} |
|
134
|
|
|
|
|
135
|
|
|
// check parameter syntax |
|
136
|
|
|
foreach($vardom as $var => $dom) { |
|
137
|
|
|
if (!isset($_REQUEST[$var])) { |
|
138
|
|
|
$MYREQUEST[$var]=NULL; |
|
139
|
|
|
} else if (!is_array($_REQUEST[$var]) && preg_match($dom.'D',$_REQUEST[$var])) { |
|
140
|
|
|
$MYREQUEST[$var]=$_REQUEST[$var]; |
|
141
|
|
|
} else { |
|
142
|
|
|
$MYREQUEST[$var]=$_REQUEST[$var]=NULL; |
|
143
|
|
|
} |
|
144
|
|
|
} |
|
145
|
|
|
|
|
146
|
|
|
// check parameter sematics |
|
147
|
|
|
if (empty($MYREQUEST['SCOPE'])) $MYREQUEST['SCOPE']="A"; |
|
148
|
|
|
if (empty($MYREQUEST['SORT1'])) $MYREQUEST['SORT1']="H"; |
|
149
|
|
|
if (empty($MYREQUEST['SORT2'])) $MYREQUEST['SORT2']="D"; |
|
150
|
|
|
if (empty($MYREQUEST['OB'])) $MYREQUEST['OB']=OB_HOST_STATS; |
|
151
|
|
|
if (!isset($MYREQUEST['COUNT'])) $MYREQUEST['COUNT']=20; |
|
152
|
|
|
if (!isset($scope_list[$MYREQUEST['SCOPE']])) $MYREQUEST['SCOPE']='A'; |
|
153
|
|
|
|
|
154
|
|
|
$MY_SELF= |
|
155
|
|
|
"$PHP_SELF". |
|
156
|
|
|
"?SCOPE=".$MYREQUEST['SCOPE']. |
|
157
|
|
|
"&SORT1=".$MYREQUEST['SORT1']. |
|
158
|
|
|
"&SORT2=".$MYREQUEST['SORT2']. |
|
159
|
|
|
"&COUNT=".$MYREQUEST['COUNT']; |
|
160
|
|
|
$MY_SELF_WO_SORT= |
|
161
|
|
|
"$PHP_SELF". |
|
162
|
|
|
"?SCOPE=".$MYREQUEST['SCOPE']. |
|
163
|
|
|
"&COUNT=".$MYREQUEST['COUNT']; |
|
164
|
|
|
|
|
165
|
|
|
// authentication needed? |
|
166
|
|
|
// |
|
167
|
|
|
if (!USE_AUTHENTICATION) { |
|
|
|
|
|
|
168
|
|
|
$AUTHENTICATED=1; |
|
169
|
|
|
} else { |
|
170
|
|
|
$AUTHENTICATED=0; |
|
171
|
|
|
if (ADMIN_PASSWORD!='password' && ($MYREQUEST['LO'] == 1 || isset($_SERVER['PHP_AUTH_USER']))) { |
|
|
|
|
|
|
172
|
|
|
|
|
173
|
|
|
if (!isset($_SERVER['PHP_AUTH_USER']) || |
|
174
|
|
|
!isset($_SERVER['PHP_AUTH_PW']) || |
|
175
|
|
|
$_SERVER['PHP_AUTH_USER'] != ADMIN_USERNAME || |
|
|
|
|
|
|
176
|
|
|
$_SERVER['PHP_AUTH_PW'] != ADMIN_PASSWORD) { |
|
177
|
|
|
Header("WWW-Authenticate: Basic realm=\"APC Login\""); |
|
178
|
|
|
Header("HTTP/1.0 401 Unauthorized"); |
|
179
|
|
|
|
|
180
|
|
|
echo <<<EOB |
|
181
|
|
|
<html><body> |
|
182
|
|
|
<h1>Rejected!</h1> |
|
183
|
|
|
<big>Wrong Username or Password!</big><br/> <br/> |
|
184
|
|
|
<big><a href='$PHP_SELF?OB={$MYREQUEST['OB']}'>Continue...</a></big> |
|
185
|
|
|
</body></html> |
|
186
|
|
|
EOB; |
|
187
|
|
|
exit; |
|
188
|
|
|
|
|
189
|
|
|
} else { |
|
190
|
|
|
$AUTHENTICATED=1; |
|
191
|
|
|
} |
|
192
|
|
|
} |
|
193
|
|
|
} |
|
194
|
|
|
|
|
195
|
|
|
// clear cache |
|
196
|
|
|
if ($AUTHENTICATED && isset($MYREQUEST['CC']) && $MYREQUEST['CC']) { |
|
197
|
|
|
apcu_clear_cache(); |
|
198
|
|
|
} |
|
199
|
|
|
|
|
200
|
|
|
if ($AUTHENTICATED && !empty($MYREQUEST['DU'])) { |
|
201
|
|
|
apcu_delete($MYREQUEST['DU']); |
|
202
|
|
|
} |
|
203
|
|
|
|
|
204
|
|
|
if(!function_exists('apcu_cache_info')) { |
|
205
|
|
|
echo "No cache info available. APC does not appear to be running."; |
|
206
|
|
|
exit; |
|
207
|
|
|
} |
|
208
|
|
|
|
|
209
|
|
|
$cache = apcu_cache_info(); |
|
210
|
|
|
|
|
211
|
|
|
$mem=apcu_sma_info(); |
|
212
|
|
|
|
|
213
|
|
|
// don't cache this page |
|
214
|
|
|
// |
|
215
|
|
|
header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1 |
|
216
|
|
|
header("Cache-Control: post-check=0, pre-check=0", false); |
|
217
|
|
|
header("Pragma: no-cache"); // HTTP/1.0 |
|
218
|
|
|
|
|
219
|
|
|
function duration($ts) { |
|
220
|
|
|
global $time; |
|
221
|
|
|
$years = (int)((($time - $ts)/(7*86400))/52.177457); |
|
222
|
|
|
$rem = (int)(($time-$ts)-($years * 52.177457 * 7 * 86400)); |
|
223
|
|
|
$weeks = (int)(($rem)/(7*86400)); |
|
224
|
|
|
$days = (int)(($rem)/86400) - $weeks*7; |
|
225
|
|
|
$hours = (int)(($rem)/3600) - $days*24 - $weeks*7*24; |
|
226
|
|
|
$mins = (int)(($rem)/60) - $hours*60 - $days*24*60 - $weeks*7*24*60; |
|
227
|
|
|
$str = ''; |
|
228
|
|
|
if($years==1) $str .= "$years year, "; |
|
229
|
|
|
if($years>1) $str .= "$years years, "; |
|
230
|
|
|
if($weeks==1) $str .= "$weeks week, "; |
|
231
|
|
|
if($weeks>1) $str .= "$weeks weeks, "; |
|
232
|
|
|
if($days==1) $str .= "$days day,"; |
|
233
|
|
|
if($days>1) $str .= "$days days,"; |
|
234
|
|
|
if($hours == 1) $str .= " $hours hour and"; |
|
235
|
|
|
if($hours>1) $str .= " $hours hours and"; |
|
236
|
|
|
if($mins == 1) $str .= " 1 minute"; |
|
237
|
|
|
else $str .= " $mins minutes"; |
|
238
|
|
|
return $str; |
|
239
|
|
|
} |
|
240
|
|
|
|
|
241
|
|
|
// create graphics |
|
242
|
|
|
// |
|
243
|
|
|
function graphics_avail() { |
|
244
|
|
|
return extension_loaded('gd'); |
|
245
|
|
|
} |
|
246
|
|
|
if (isset($MYREQUEST['IMG'])) |
|
247
|
|
|
{ |
|
248
|
|
|
if (!graphics_avail()) { |
|
249
|
|
|
exit(0); |
|
250
|
|
|
} |
|
251
|
|
|
|
|
252
|
|
|
function fill_arc($im, $centerX, $centerY, $diameter, $start, $end, $color1,$color2,$text='',$placeindex=0) { |
|
253
|
|
|
$r=$diameter/2; |
|
254
|
|
|
$w=deg2rad((360+$start+($end-$start)/2)%360); |
|
255
|
|
|
|
|
256
|
|
|
|
|
257
|
|
|
if (function_exists("imagefilledarc")) { |
|
258
|
|
|
// exists only if GD 2.0.1 is avaliable |
|
259
|
|
|
imagefilledarc($im, $centerX+1, $centerY+1, $diameter, $diameter, $start, $end, $color1, IMG_ARC_PIE); |
|
260
|
|
|
imagefilledarc($im, $centerX, $centerY, $diameter, $diameter, $start, $end, $color2, IMG_ARC_PIE); |
|
261
|
|
|
imagefilledarc($im, $centerX, $centerY, $diameter, $diameter, $start, $end, $color1, IMG_ARC_NOFILL|IMG_ARC_EDGED); |
|
262
|
|
|
} else { |
|
263
|
|
|
imagearc($im, $centerX, $centerY, $diameter, $diameter, $start, $end, $color2); |
|
264
|
|
|
imageline($im, $centerX, $centerY, $centerX + cos(deg2rad($start)) * $r, $centerY + sin(deg2rad($start)) * $r, $color2); |
|
265
|
|
|
imageline($im, $centerX, $centerY, $centerX + cos(deg2rad($start+1)) * $r, $centerY + sin(deg2rad($start)) * $r, $color2); |
|
266
|
|
|
imageline($im, $centerX, $centerY, $centerX + cos(deg2rad($end-1)) * $r, $centerY + sin(deg2rad($end)) * $r, $color2); |
|
267
|
|
|
imageline($im, $centerX, $centerY, $centerX + cos(deg2rad($end)) * $r, $centerY + sin(deg2rad($end)) * $r, $color2); |
|
268
|
|
|
imagefill($im,$centerX + $r*cos($w)/2, $centerY + $r*sin($w)/2, $color2); |
|
269
|
|
|
} |
|
270
|
|
|
if ($text) { |
|
271
|
|
|
if ($placeindex>0) { |
|
272
|
|
|
imageline($im,$centerX + $r*cos($w)/2, $centerY + $r*sin($w)/2,$diameter, $placeindex*12,$color1); |
|
273
|
|
|
imagestring($im,4,$diameter, $placeindex*12,$text,$color1); |
|
274
|
|
|
|
|
275
|
|
|
} else { |
|
276
|
|
|
imagestring($im,4,$centerX + $r*cos($w)/2, $centerY + $r*sin($w)/2,$text,$color1); |
|
277
|
|
|
} |
|
278
|
|
|
} |
|
279
|
|
|
} |
|
280
|
|
|
|
|
281
|
|
|
function text_arc($im, $centerX, $centerY, $diameter, $start, $end, $color1,$text,$placeindex=0) { |
|
282
|
|
|
$r=$diameter/2; |
|
283
|
|
|
$w=deg2rad((360+$start+($end-$start)/2)%360); |
|
284
|
|
|
|
|
285
|
|
|
if ($placeindex>0) { |
|
286
|
|
|
imageline($im,$centerX + $r*cos($w)/2, $centerY + $r*sin($w)/2,$diameter, $placeindex*12,$color1); |
|
287
|
|
|
imagestring($im,4,$diameter, $placeindex*12,$text,$color1); |
|
288
|
|
|
|
|
289
|
|
|
} else { |
|
290
|
|
|
imagestring($im,4,$centerX + $r*cos($w)/2, $centerY + $r*sin($w)/2,$text,$color1); |
|
291
|
|
|
} |
|
292
|
|
|
} |
|
293
|
|
|
|
|
294
|
|
|
function fill_box($im, $x, $y, $w, $h, $color1, $color2,$text='',$placeindex='') { |
|
295
|
|
|
global $col_black; |
|
296
|
|
|
$x1=$x+$w-1; |
|
297
|
|
|
$y1=$y+$h-1; |
|
298
|
|
|
|
|
299
|
|
|
imagerectangle($im, $x, $y1, $x1+1, $y+1, $col_black); |
|
300
|
|
|
if($y1>$y) imagefilledrectangle($im, $x, $y, $x1, $y1, $color2); |
|
301
|
|
|
else imagefilledrectangle($im, $x, $y1, $x1, $y, $color2); |
|
302
|
|
|
imagerectangle($im, $x, $y1, $x1, $y, $color1); |
|
303
|
|
|
if ($text) { |
|
304
|
|
|
if ($placeindex>0) { |
|
305
|
|
|
|
|
306
|
|
|
if ($placeindex<16) |
|
307
|
|
|
{ |
|
308
|
|
|
$px=5; |
|
309
|
|
|
$py=$placeindex*12+6; |
|
310
|
|
|
imagefilledrectangle($im, $px+90, $py+3, $px+90-4, $py-3, $color2); |
|
311
|
|
|
imageline($im,$x,$y+$h/2,$px+90,$py,$color2); |
|
312
|
|
|
imagestring($im,2,$px,$py-6,$text,$color1); |
|
313
|
|
|
|
|
314
|
|
|
} else { |
|
315
|
|
|
if ($placeindex<31) { |
|
316
|
|
|
$px=$x+40*2; |
|
317
|
|
|
$py=($placeindex-15)*12+6; |
|
318
|
|
|
} else { |
|
319
|
|
|
$px=$x+40*2+100*intval(($placeindex-15)/15); |
|
320
|
|
|
$py=($placeindex%15)*12+6; |
|
321
|
|
|
} |
|
322
|
|
|
imagefilledrectangle($im, $px, $py+3, $px-4, $py-3, $color2); |
|
323
|
|
|
imageline($im,$x+$w,$y+$h/2,$px,$py,$color2); |
|
324
|
|
|
imagestring($im,2,$px+2,$py-6,$text,$color1); |
|
325
|
|
|
} |
|
326
|
|
|
} else { |
|
327
|
|
|
imagestring($im,4,$x+5,$y1-16,$text,$color1); |
|
328
|
|
|
} |
|
329
|
|
|
} |
|
330
|
|
|
} |
|
331
|
|
|
|
|
332
|
|
|
|
|
333
|
|
|
$size = GRAPH_SIZE; // image size |
|
|
|
|
|
|
334
|
|
|
if ($MYREQUEST['IMG']==3) |
|
335
|
|
|
$image = imagecreate(2*$size+150, $size+10); |
|
336
|
|
|
else |
|
337
|
|
|
$image = imagecreate($size+50, $size+10); |
|
338
|
|
|
|
|
339
|
|
|
$col_white = imagecolorallocate($image, 0xFF, 0xFF, 0xFF); |
|
340
|
|
|
$col_red = imagecolorallocate($image, 0xD0, 0x60, 0x30); |
|
341
|
|
|
$col_green = imagecolorallocate($image, 0x60, 0xF0, 0x60); |
|
342
|
|
|
$col_black = imagecolorallocate($image, 0, 0, 0); |
|
343
|
|
|
imagecolortransparent($image,$col_white); |
|
344
|
|
|
|
|
345
|
|
|
switch ($MYREQUEST['IMG']) { |
|
346
|
|
|
|
|
347
|
|
|
case 1: |
|
348
|
|
|
$s=$mem['num_seg']*$mem['seg_size']; |
|
349
|
|
|
$a=$mem['avail_mem']; |
|
350
|
|
|
$x=$y=$size/2; |
|
351
|
|
|
$fuzz = 0.000001; |
|
352
|
|
|
|
|
353
|
|
|
// This block of code creates the pie chart. It is a lot more complex than you |
|
354
|
|
|
// would expect because we try to visualize any memory fragmentation as well. |
|
355
|
|
|
$angle_from = 0; |
|
356
|
|
|
$string_placement=array(); |
|
357
|
|
|
for($i=0; $i<$mem['num_seg']; $i++) { |
|
358
|
|
|
$ptr = 0; |
|
359
|
|
|
$free = $mem['block_lists'][$i]; |
|
360
|
|
|
uasort($free, 'block_sort'); |
|
361
|
|
|
foreach($free as $block) { |
|
362
|
|
|
if($block['offset']!=$ptr) { // Used block |
|
363
|
|
|
$angle_to = $angle_from+($block['offset']-$ptr)/$s; |
|
364
|
|
|
if(($angle_to+$fuzz)>1) $angle_to = 1; |
|
365
|
|
|
if( ($angle_to*360) - ($angle_from*360) >= 1) { |
|
366
|
|
|
fill_arc($image,$x,$y,$size,$angle_from*360,$angle_to*360,$col_black,$col_red); |
|
367
|
|
|
if (($angle_to-$angle_from)>0.05) { |
|
368
|
|
|
array_push($string_placement, array($angle_from,$angle_to)); |
|
369
|
|
|
} |
|
370
|
|
|
} |
|
371
|
|
|
$angle_from = $angle_to; |
|
372
|
|
|
} |
|
373
|
|
|
$angle_to = $angle_from+($block['size'])/$s; |
|
374
|
|
|
if(($angle_to+$fuzz)>1) $angle_to = 1; |
|
375
|
|
|
if( ($angle_to*360) - ($angle_from*360) >= 1) { |
|
376
|
|
|
fill_arc($image,$x,$y,$size,$angle_from*360,$angle_to*360,$col_black,$col_green); |
|
377
|
|
|
if (($angle_to-$angle_from)>0.05) { |
|
378
|
|
|
array_push($string_placement, array($angle_from,$angle_to)); |
|
379
|
|
|
} |
|
380
|
|
|
} |
|
381
|
|
|
$angle_from = $angle_to; |
|
382
|
|
|
$ptr = $block['offset']+$block['size']; |
|
383
|
|
|
} |
|
384
|
|
|
if ($ptr < $mem['seg_size']) { // memory at the end |
|
385
|
|
|
$angle_to = $angle_from + ($mem['seg_size'] - $ptr)/$s; |
|
386
|
|
|
if(($angle_to+$fuzz)>1) $angle_to = 1; |
|
387
|
|
|
fill_arc($image,$x,$y,$size,$angle_from*360,$angle_to*360,$col_black,$col_red); |
|
388
|
|
|
if (($angle_to-$angle_from)>0.05) { |
|
389
|
|
|
array_push($string_placement, array($angle_from,$angle_to)); |
|
390
|
|
|
} |
|
391
|
|
|
} |
|
392
|
|
|
} |
|
393
|
|
|
foreach ($string_placement as $angle) { |
|
394
|
|
|
text_arc($image,$x,$y,$size,$angle[0]*360,$angle[1]*360,$col_black,bsize($s*($angle[1]-$angle[0]))); |
|
395
|
|
|
} |
|
396
|
|
|
break; |
|
397
|
|
|
|
|
398
|
|
|
case 2: |
|
399
|
|
|
$s=$cache['num_hits']+$cache['num_misses']; |
|
400
|
|
|
$a=$cache['num_hits']; |
|
401
|
|
|
|
|
402
|
|
|
fill_box($image, 30,$size,50,$s ? (-$a*($size-21)/$s) : 0,$col_black,$col_green,sprintf("%.1f%%",$s ? $cache['num_hits']*100/$s : 0)); |
|
403
|
|
|
fill_box($image,130,$size,50,$s ? -max(4,($s-$a)*($size-21)/$s) : 0,$col_black,$col_red,sprintf("%.1f%%",$s ? $cache['num_misses']*100/$s : 0)); |
|
404
|
|
|
break; |
|
405
|
|
|
|
|
406
|
|
|
case 3: |
|
407
|
|
|
$s=$mem['num_seg']*$mem['seg_size']; |
|
408
|
|
|
$a=$mem['avail_mem']; |
|
409
|
|
|
$x=130; |
|
410
|
|
|
$y=1; |
|
411
|
|
|
$j=1; |
|
412
|
|
|
|
|
413
|
|
|
// This block of code creates the bar chart. It is a lot more complex than you |
|
414
|
|
|
// would expect because we try to visualize any memory fragmentation as well. |
|
415
|
|
|
for($i=0; $i<$mem['num_seg']; $i++) { |
|
416
|
|
|
$ptr = 0; |
|
417
|
|
|
$free = $mem['block_lists'][$i]; |
|
418
|
|
|
uasort($free, 'block_sort'); |
|
419
|
|
|
foreach($free as $block) { |
|
420
|
|
|
if($block['offset']!=$ptr) { // Used block |
|
421
|
|
|
$h=(GRAPH_SIZE-5)*($block['offset']-$ptr)/$s; |
|
422
|
|
|
if ($h>0) { |
|
423
|
|
|
$j++; |
|
424
|
|
|
if($j<75) fill_box($image,$x,$y,50,$h,$col_black,$col_red,bsize($block['offset']-$ptr),$j); |
|
425
|
|
|
else fill_box($image,$x,$y,50,$h,$col_black,$col_red); |
|
426
|
|
|
} |
|
427
|
|
|
$y+=$h; |
|
428
|
|
|
} |
|
429
|
|
|
$h=(GRAPH_SIZE-5)*($block['size'])/$s; |
|
430
|
|
|
if ($h>0) { |
|
431
|
|
|
$j++; |
|
432
|
|
|
if($j<75) fill_box($image,$x,$y,50,$h,$col_black,$col_green,bsize($block['size']),$j); |
|
433
|
|
|
else fill_box($image,$x,$y,50,$h,$col_black,$col_green); |
|
434
|
|
|
} |
|
435
|
|
|
$y+=$h; |
|
436
|
|
|
$ptr = $block['offset']+$block['size']; |
|
437
|
|
|
} |
|
438
|
|
|
if ($ptr < $mem['seg_size']) { // memory at the end |
|
439
|
|
|
$h = (GRAPH_SIZE-5) * ($mem['seg_size'] - $ptr) / $s; |
|
440
|
|
|
if ($h > 0) { |
|
441
|
|
|
fill_box($image,$x,$y,50,$h,$col_black,$col_red,bsize($mem['seg_size']-$ptr),$j++); |
|
442
|
|
|
} |
|
443
|
|
|
} |
|
444
|
|
|
} |
|
445
|
|
|
break; |
|
446
|
|
|
|
|
447
|
|
|
case 4: |
|
448
|
|
|
$s=$cache['num_hits']+$cache['num_misses']; |
|
449
|
|
|
$a=$cache['num_hits']; |
|
450
|
|
|
|
|
451
|
|
|
fill_box($image, 30,$size,50,$s ? -$a*($size-21)/$s : 0,$col_black,$col_green,sprintf("%.1f%%", $s ? $cache['num_hits']*100/$s : 0)); |
|
452
|
|
|
fill_box($image,130,$size,50,$s ? -max(4,($s-$a)*($size-21)/$s) : 0,$col_black,$col_red,sprintf("%.1f%%", $s ? $cache['num_misses']*100/$s : 0)); |
|
453
|
|
|
break; |
|
454
|
|
|
} |
|
455
|
|
|
|
|
456
|
|
|
header("Content-type: image/png"); |
|
457
|
|
|
imagepng($image); |
|
458
|
|
|
exit; |
|
459
|
|
|
} |
|
460
|
|
|
|
|
461
|
|
|
// pretty printer for byte values |
|
462
|
|
|
// |
|
463
|
|
|
function bsize($s) { |
|
464
|
|
|
foreach (array('','K','M','G') as $i => $k) { |
|
465
|
|
|
if ($s < 1024) break; |
|
466
|
|
|
$s/=1024; |
|
467
|
|
|
} |
|
468
|
|
|
return sprintf("%5.1f %sBytes",$s,$k); |
|
|
|
|
|
|
469
|
|
|
} |
|
470
|
|
|
|
|
471
|
|
|
// sortable table header in "scripts for this host" view |
|
472
|
|
|
function sortheader($key,$name,$extra='') { |
|
473
|
|
|
global $MYREQUEST, $MY_SELF_WO_SORT; |
|
474
|
|
|
|
|
475
|
|
|
if ($MYREQUEST['SORT1']==$key) { |
|
476
|
|
|
$MYREQUEST['SORT2'] = $MYREQUEST['SORT2']=='A' ? 'D' : 'A'; |
|
477
|
|
|
} |
|
478
|
|
|
return "<a class=sortable href=\"$MY_SELF_WO_SORT$extra&SORT1=$key&SORT2=".$MYREQUEST['SORT2']."\">$name</a>"; |
|
479
|
|
|
|
|
480
|
|
|
} |
|
481
|
|
|
|
|
482
|
|
|
// create menu entry |
|
483
|
|
|
function menu_entry($ob,$title) { |
|
484
|
|
|
global $MYREQUEST,$MY_SELF; |
|
485
|
|
|
if ($MYREQUEST['OB']!=$ob) { |
|
486
|
|
|
return "<li><a href=\"$MY_SELF&OB=$ob\">$title</a></li>"; |
|
487
|
|
|
} else if (empty($MYREQUEST['SH'])) { |
|
488
|
|
|
return "<li><span class=active>$title</span></li>"; |
|
489
|
|
|
} else { |
|
490
|
|
|
return "<li><a class=\"child_active\" href=\"$MY_SELF&OB=$ob\">$title</a></li>"; |
|
491
|
|
|
} |
|
492
|
|
|
} |
|
493
|
|
|
|
|
494
|
|
|
function put_login_link($s="Login") |
|
495
|
|
|
{ |
|
496
|
|
|
global $MY_SELF,$MYREQUEST,$AUTHENTICATED; |
|
497
|
|
|
// needs ADMIN_PASSWORD to be changed! |
|
498
|
|
|
// |
|
499
|
|
|
if (!USE_AUTHENTICATION) { |
|
|
|
|
|
|
500
|
|
|
return; |
|
501
|
|
|
} else if (ADMIN_PASSWORD=='password') |
|
|
|
|
|
|
502
|
|
|
{ |
|
503
|
|
|
print <<<EOB |
|
504
|
|
|
<a href="#" onClick="javascript:alert('You need to set a password at the top of apc.php before this will work!');return false";>$s</a> |
|
505
|
|
|
EOB; |
|
506
|
|
|
} else if ($AUTHENTICATED) { |
|
507
|
|
|
print <<<EOB |
|
508
|
|
|
'{$_SERVER['PHP_AUTH_USER']}' logged in! |
|
509
|
|
|
EOB; |
|
510
|
|
|
} else{ |
|
511
|
|
|
print <<<EOB |
|
512
|
|
|
<a href="$MY_SELF&LO=1&OB={$MYREQUEST['OB']}">$s</a> |
|
513
|
|
|
EOB; |
|
514
|
|
|
} |
|
515
|
|
|
} |
|
516
|
|
|
|
|
517
|
|
|
function block_sort($array1, $array2) |
|
518
|
|
|
{ |
|
519
|
|
|
if ($array1['offset'] > $array2['offset']) { |
|
520
|
|
|
return 1; |
|
521
|
|
|
} else { |
|
522
|
|
|
return -1; |
|
523
|
|
|
} |
|
524
|
|
|
} |
|
525
|
|
|
|
|
526
|
|
|
|
|
527
|
|
|
?> |
|
528
|
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> |
|
529
|
|
|
<html> |
|
530
|
|
|
<head><title>APCu INFO <?php echo $host ?></title> |
|
531
|
|
|
<style><!-- |
|
532
|
|
|
body { background:white; font-size:100.01%; margin:0; padding:0; } |
|
533
|
|
|
body,p,td,th,input,submit { font-size:0.8em;font-family:arial,helvetica,sans-serif; } |
|
534
|
|
|
* html body {font-size:0.8em} |
|
535
|
|
|
* html p {font-size:0.8em} |
|
536
|
|
|
* html td {font-size:0.8em} |
|
537
|
|
|
* html th {font-size:0.8em} |
|
538
|
|
|
* html input {font-size:0.8em} |
|
539
|
|
|
* html submit {font-size:0.8em} |
|
540
|
|
|
td { vertical-align:top } |
|
541
|
|
|
a { color:black; font-weight:none; text-decoration:none; } |
|
542
|
|
|
a:hover { text-decoration:underline; } |
|
543
|
|
|
div.content { padding:1em 1em 1em 1em; position:absolute; width:97%; z-index:100; } |
|
544
|
|
|
|
|
545
|
|
|
|
|
546
|
|
|
div.head div.login { |
|
547
|
|
|
position:absolute; |
|
548
|
|
|
right: 1em; |
|
549
|
|
|
top: 1.2em; |
|
550
|
|
|
color:white; |
|
551
|
|
|
width:6em; |
|
552
|
|
|
} |
|
553
|
|
|
div.head div.login a { |
|
554
|
|
|
position:absolute; |
|
555
|
|
|
right: 0em; |
|
556
|
|
|
background:rgb(119,123,180); |
|
557
|
|
|
border:solid rgb(102,102,153) 2px; |
|
558
|
|
|
color:white; |
|
559
|
|
|
font-weight:bold; |
|
560
|
|
|
padding:0.1em 0.5em 0.1em 0.5em; |
|
561
|
|
|
text-decoration:none; |
|
562
|
|
|
} |
|
563
|
|
|
div.head div.login a:hover { |
|
564
|
|
|
background:rgb(193,193,244); |
|
565
|
|
|
} |
|
566
|
|
|
|
|
567
|
|
|
h1.apc { background:rgb(153,153,204); margin:0; padding:0.5em 1em 0.5em 1em; } |
|
568
|
|
|
* html h1.apc { margin-bottom:-7px; } |
|
569
|
|
|
h1.apc a:hover { text-decoration:none; color:rgb(90,90,90); } |
|
570
|
|
|
h1.apc div.logo span.logo { |
|
571
|
|
|
background:rgb(119,123,180); |
|
572
|
|
|
color:black; |
|
573
|
|
|
border-right: solid black 1px; |
|
574
|
|
|
border-bottom: solid black 1px; |
|
575
|
|
|
font-style:italic; |
|
576
|
|
|
font-size:1em; |
|
577
|
|
|
padding-left:1.2em; |
|
578
|
|
|
padding-right:1.2em; |
|
579
|
|
|
text-align:right; |
|
580
|
|
|
} |
|
581
|
|
|
h1.apc div.logo span.name { color:white; font-size:0.7em; padding:0 0.8em 0 2em; } |
|
582
|
|
|
h1.apc div.nameinfo { color:white; display:inline; font-size:0.4em; margin-left: 3em; } |
|
583
|
|
|
h1.apc div.copy { color:black; font-size:0.4em; position:absolute; right:1em; } |
|
584
|
|
|
hr.apc { |
|
585
|
|
|
background:white; |
|
586
|
|
|
border-bottom:solid rgb(102,102,153) 1px; |
|
587
|
|
|
border-style:none; |
|
588
|
|
|
border-top:solid rgb(102,102,153) 10px; |
|
589
|
|
|
height:12px; |
|
590
|
|
|
margin:0; |
|
591
|
|
|
margin-top:1px; |
|
592
|
|
|
padding:0; |
|
593
|
|
|
} |
|
594
|
|
|
|
|
595
|
|
|
ol,menu { margin:1em 0 0 0; padding:0.2em; margin-left:1em;} |
|
596
|
|
|
ol.menu li { display:inline; margin-right:0.7em; list-style:none; font-size:85%} |
|
597
|
|
|
ol.menu a { |
|
598
|
|
|
background:rgb(153,153,204); |
|
599
|
|
|
border:solid rgb(102,102,153) 2px; |
|
600
|
|
|
color:white; |
|
601
|
|
|
font-weight:bold; |
|
602
|
|
|
margin-right:0em; |
|
603
|
|
|
padding:0.1em 0.5em 0.1em 0.5em; |
|
604
|
|
|
text-decoration:none; |
|
605
|
|
|
margin-left: 5px; |
|
606
|
|
|
} |
|
607
|
|
|
ol.menu a.child_active { |
|
608
|
|
|
background:rgb(153,153,204); |
|
609
|
|
|
border:solid rgb(102,102,153) 2px; |
|
610
|
|
|
color:white; |
|
611
|
|
|
font-weight:bold; |
|
612
|
|
|
margin-right:0em; |
|
613
|
|
|
padding:0.1em 0.5em 0.1em 0.5em; |
|
614
|
|
|
text-decoration:none; |
|
615
|
|
|
border-left: solid black 5px; |
|
616
|
|
|
margin-left: 0px; |
|
617
|
|
|
} |
|
618
|
|
|
ol.menu span.active { |
|
619
|
|
|
background:rgb(153,153,204); |
|
620
|
|
|
border:solid rgb(102,102,153) 2px; |
|
621
|
|
|
color:black; |
|
622
|
|
|
font-weight:bold; |
|
623
|
|
|
margin-right:0em; |
|
624
|
|
|
padding:0.1em 0.5em 0.1em 0.5em; |
|
625
|
|
|
text-decoration:none; |
|
626
|
|
|
border-left: solid black 5px; |
|
627
|
|
|
} |
|
628
|
|
|
ol.menu span.inactive { |
|
629
|
|
|
background:rgb(193,193,244); |
|
630
|
|
|
border:solid rgb(182,182,233) 2px; |
|
631
|
|
|
color:white; |
|
632
|
|
|
font-weight:bold; |
|
633
|
|
|
margin-right:0em; |
|
634
|
|
|
padding:0.1em 0.5em 0.1em 0.5em; |
|
635
|
|
|
text-decoration:none; |
|
636
|
|
|
margin-left: 5px; |
|
637
|
|
|
} |
|
638
|
|
|
ol.menu a:hover { |
|
639
|
|
|
background:rgb(193,193,244); |
|
640
|
|
|
text-decoration:none; |
|
641
|
|
|
} |
|
642
|
|
|
|
|
643
|
|
|
|
|
644
|
|
|
div.info { |
|
645
|
|
|
background:rgb(204,204,204); |
|
646
|
|
|
border:solid rgb(204,204,204) 1px; |
|
647
|
|
|
margin-bottom:1em; |
|
648
|
|
|
} |
|
649
|
|
|
div.info h2 { |
|
650
|
|
|
background:rgb(204,204,204); |
|
651
|
|
|
color:black; |
|
652
|
|
|
font-size:1em; |
|
653
|
|
|
margin:0; |
|
654
|
|
|
padding:0.1em 1em 0.1em 1em; |
|
655
|
|
|
} |
|
656
|
|
|
div.info table { |
|
657
|
|
|
border:solid rgb(204,204,204) 1px; |
|
658
|
|
|
border-spacing:0; |
|
659
|
|
|
width:100%; |
|
660
|
|
|
} |
|
661
|
|
|
div.info table th { |
|
662
|
|
|
background:rgb(204,204,204); |
|
663
|
|
|
color:white; |
|
664
|
|
|
margin:0; |
|
665
|
|
|
padding:0.1em 1em 0.1em 1em; |
|
666
|
|
|
} |
|
667
|
|
|
div.info table th a.sortable { color:black; } |
|
668
|
|
|
div.info table tr.tr-0 { background:rgb(238,238,238); } |
|
669
|
|
|
div.info table tr.tr-1 { background:rgb(221,221,221); } |
|
670
|
|
|
div.info table td { padding:0.3em 1em 0.3em 1em; } |
|
671
|
|
|
div.info table td.td-0 { border-right:solid rgb(102,102,153) 1px; white-space:nowrap; } |
|
672
|
|
|
div.info table td.td-n { border-right:solid rgb(102,102,153) 1px; } |
|
673
|
|
|
div.info table td h3 { |
|
674
|
|
|
color:black; |
|
675
|
|
|
font-size:1.1em; |
|
676
|
|
|
margin-left:-0.3em; |
|
677
|
|
|
} |
|
678
|
|
|
|
|
679
|
|
|
div.graph { margin-bottom:1em } |
|
680
|
|
|
div.graph h2 { background:rgb(204,204,204);; color:black; font-size:1em; margin:0; padding:0.1em 1em 0.1em 1em; } |
|
681
|
|
|
div.graph table { border:solid rgb(204,204,204) 1px; color:black; font-weight:normal; width:100%; } |
|
682
|
|
|
div.graph table td.td-0 { background:rgb(238,238,238); } |
|
683
|
|
|
div.graph table td.td-1 { background:rgb(221,221,221); } |
|
684
|
|
|
div.graph table td { padding:0.2em 1em 0.4em 1em; } |
|
685
|
|
|
|
|
686
|
|
|
div.div1,div.div2 { margin-bottom:1em; width:35em; } |
|
687
|
|
|
div.div3 { position:absolute; left:40em; top:1em; width:580px; } |
|
688
|
|
|
//div.div3 { position:absolute; left:37em; top:1em; right:1em; } |
|
689
|
|
|
|
|
690
|
|
|
div.sorting { margin:1.5em 0em 1.5em 2em } |
|
691
|
|
|
.center { text-align:center } |
|
692
|
|
|
.aright { position:absolute;right:1em } |
|
693
|
|
|
.right { text-align:right } |
|
694
|
|
|
.ok { color:rgb(0,200,0); font-weight:bold} |
|
695
|
|
|
.failed { color:rgb(200,0,0); font-weight:bold} |
|
696
|
|
|
|
|
697
|
|
|
span.box { |
|
698
|
|
|
border: black solid 1px; |
|
699
|
|
|
border-right:solid black 2px; |
|
700
|
|
|
border-bottom:solid black 2px; |
|
701
|
|
|
padding:0 0.5em 0 0.5em; |
|
702
|
|
|
margin-right:1em; |
|
703
|
|
|
} |
|
704
|
|
|
span.green { background:#60F060; padding:0 0.5em 0 0.5em} |
|
705
|
|
|
span.red { background:#D06030; padding:0 0.5em 0 0.5em } |
|
706
|
|
|
|
|
707
|
|
|
div.authneeded { |
|
708
|
|
|
background:rgb(238,238,238); |
|
709
|
|
|
border:solid rgb(204,204,204) 1px; |
|
710
|
|
|
color:rgb(200,0,0); |
|
711
|
|
|
font-size:1.2em; |
|
712
|
|
|
font-weight:bold; |
|
713
|
|
|
padding:2em; |
|
714
|
|
|
text-align:center; |
|
715
|
|
|
} |
|
716
|
|
|
|
|
717
|
|
|
input { |
|
718
|
|
|
background:rgb(153,153,204); |
|
719
|
|
|
border:solid rgb(102,102,153) 2px; |
|
720
|
|
|
color:white; |
|
721
|
|
|
font-weight:bold; |
|
722
|
|
|
margin-right:1em; |
|
723
|
|
|
padding:0.1em 0.5em 0.1em 0.5em; |
|
724
|
|
|
} |
|
725
|
|
|
//--> |
|
726
|
|
|
</style> |
|
727
|
|
|
</head> |
|
728
|
|
|
<body> |
|
729
|
|
|
<div class="head"> |
|
730
|
|
|
<h1 class="apc"> |
|
731
|
|
|
<div class="logo"><span class="logo"><a href="http://pecl.php.net/package/APCu">APCu</a></span></div> |
|
732
|
|
|
<div class="nameinfo">User Cache</div> |
|
733
|
|
|
</h1> |
|
734
|
|
|
<div class="login"> |
|
735
|
|
|
<?php put_login_link(); ?> |
|
736
|
|
|
</div> |
|
737
|
|
|
<hr class="apc"> |
|
738
|
|
|
</div> |
|
739
|
|
|
|
|
740
|
|
|
<?php |
|
741
|
|
|
// Display main Menu |
|
742
|
|
|
echo <<<EOB |
|
743
|
|
|
<ol class=menu> |
|
744
|
|
|
<li><a href="$MY_SELF&OB={$MYREQUEST['OB']}&SH={$MYREQUEST['SH']}">Refresh Data</a></li> |
|
745
|
|
|
EOB; |
|
746
|
|
|
echo |
|
747
|
|
|
menu_entry(OB_HOST_STATS,'View Host Stats'), |
|
748
|
|
|
menu_entry(OB_USER_CACHE,'User Cache Entries'), |
|
749
|
|
|
menu_entry(OB_VERSION_CHECK,'Version Check'); |
|
750
|
|
|
|
|
751
|
|
|
if ($AUTHENTICATED) { |
|
752
|
|
|
echo <<<EOB |
|
753
|
|
|
<li><a class="aright" href="$MY_SELF&CC=1&OB={$MYREQUEST['OB']}" onClick="javascript:return confirm('Are you sure?');">Clear Cache</a></li> |
|
754
|
|
|
EOB; |
|
755
|
|
|
} |
|
756
|
|
|
echo <<<EOB |
|
757
|
|
|
</ol> |
|
758
|
|
|
EOB; |
|
759
|
|
|
|
|
760
|
|
|
|
|
761
|
|
|
// CONTENT |
|
762
|
|
|
echo <<<EOB |
|
763
|
|
|
<div class=content> |
|
764
|
|
|
EOB; |
|
765
|
|
|
|
|
766
|
|
|
// MAIN SWITCH STATEMENT |
|
767
|
|
|
|
|
768
|
|
|
switch ($MYREQUEST['OB']) { |
|
769
|
|
|
// ----------------------------------------------- |
|
770
|
|
|
// Host Stats |
|
771
|
|
|
// ----------------------------------------------- |
|
772
|
|
|
case OB_HOST_STATS: |
|
773
|
|
|
$mem_size = $mem['num_seg']*$mem['seg_size']; |
|
774
|
|
|
$mem_avail= $mem['avail_mem']; |
|
775
|
|
|
$mem_used = $mem_size-$mem_avail; |
|
776
|
|
|
$seg_size = bsize($mem['seg_size']); |
|
777
|
|
|
$req_rate_user = sprintf("%.2f", $cache['num_hits'] ? (($cache['num_hits']+$cache['num_misses'])/($time-$cache['start_time'])) : 0); |
|
778
|
|
|
$hit_rate_user = sprintf("%.2f", $cache['num_hits'] ? (($cache['num_hits'])/($time-$cache['start_time'])) : 0); |
|
779
|
|
|
$miss_rate_user = sprintf("%.2f", $cache['num_misses'] ? (($cache['num_misses'])/($time-$cache['start_time'])) : 0); |
|
780
|
|
|
$insert_rate_user = sprintf("%.2f", $cache['num_inserts'] ? (($cache['num_inserts'])/($time-$cache['start_time'])) : 0); |
|
781
|
|
|
$apcversion = phpversion('apcu'); |
|
782
|
|
|
$phpversion = phpversion(); |
|
783
|
|
|
$number_vars = $cache['num_entries']; |
|
784
|
|
|
$size_vars = bsize($cache['mem_size']); |
|
785
|
|
|
$i=0; |
|
786
|
|
|
echo <<< EOB |
|
787
|
|
|
<div class="info div1"><h2>General Cache Information</h2> |
|
788
|
|
|
<table cellspacing=0><tbody> |
|
789
|
|
|
<tr class=tr-0><td class=td-0>APCu Version</td><td>$apcversion</td></tr> |
|
790
|
|
|
<tr class=tr-1><td class=td-0>PHP Version</td><td>$phpversion</td></tr> |
|
791
|
|
|
EOB; |
|
792
|
|
|
|
|
793
|
|
|
if(!empty($_SERVER['SERVER_NAME'])) |
|
794
|
|
|
echo "<tr class=tr-0><td class=td-0>APCu Host</td><td>{$_SERVER['SERVER_NAME']} $host</td></tr>\n"; |
|
795
|
|
|
if(!empty($_SERVER['SERVER_SOFTWARE'])) |
|
796
|
|
|
echo "<tr class=tr-1><td class=td-0>Server Software</td><td>{$_SERVER['SERVER_SOFTWARE']}</td></tr>\n"; |
|
797
|
|
|
|
|
798
|
|
|
echo <<<EOB |
|
799
|
|
|
<tr class=tr-0><td class=td-0>Shared Memory</td><td>{$mem['num_seg']} Segment(s) with $seg_size |
|
800
|
|
|
<br/> ({$cache['memory_type']} memory) |
|
801
|
|
|
</td></tr> |
|
802
|
|
|
EOB; |
|
803
|
|
|
echo '<tr class=tr-1><td class=td-0>Start Time</td><td>',date(DATE_FORMAT,$cache['start_time']),'</td></tr>'; |
|
|
|
|
|
|
804
|
|
|
echo '<tr class=tr-0><td class=td-0>Uptime</td><td>',duration($cache['start_time']),'</td></tr>'; |
|
805
|
|
|
echo <<<EOB |
|
806
|
|
|
</tbody></table> |
|
807
|
|
|
</div> |
|
808
|
|
|
|
|
809
|
|
|
<div class="info div1"><h2>Cache Information</h2> |
|
810
|
|
|
<table cellspacing=0> |
|
811
|
|
|
<tbody> |
|
812
|
|
|
<tr class=tr-0><td class=td-0>Cached Variables</td><td>$number_vars ($size_vars)</td></tr> |
|
813
|
|
|
<tr class=tr-1><td class=td-0>Hits</td><td>{$cache['num_hits']}</td></tr> |
|
814
|
|
|
<tr class=tr-0><td class=td-0>Misses</td><td>{$cache['num_misses']}</td></tr> |
|
815
|
|
|
<tr class=tr-1><td class=td-0>Request Rate (hits, misses)</td><td>$req_rate_user cache requests/second</td></tr> |
|
816
|
|
|
<tr class=tr-0><td class=td-0>Hit Rate</td><td>$hit_rate_user cache requests/second</td></tr> |
|
817
|
|
|
<tr class=tr-1><td class=td-0>Miss Rate</td><td>$miss_rate_user cache requests/second</td></tr> |
|
818
|
|
|
<tr class=tr-0><td class=td-0>Insert Rate</td><td>$insert_rate_user cache requests/second</td></tr> |
|
819
|
|
|
<tr class=tr-1><td class=td-0>Cache full count</td><td>{$cache['expunges']}</td></tr> |
|
820
|
|
|
</tbody> |
|
821
|
|
|
</table> |
|
822
|
|
|
</div> |
|
823
|
|
|
|
|
824
|
|
|
<div class="info div2"><h2>Runtime Settings</h2><table cellspacing=0><tbody> |
|
825
|
|
|
EOB; |
|
826
|
|
|
|
|
827
|
|
|
$j = 0; |
|
828
|
|
|
foreach (ini_get_all('apcu') as $k => $v) { |
|
829
|
|
|
echo "<tr class=tr-$j><td class=td-0>",$k,"</td><td>",str_replace(',',',<br />',$v['local_value']),"</td></tr>\n"; |
|
830
|
|
|
$j = 1 - $j; |
|
831
|
|
|
} |
|
832
|
|
|
|
|
833
|
|
|
if($mem['num_seg']>1 || $mem['num_seg']==1 && count($mem['block_lists'][0])>1) |
|
834
|
|
|
$mem_note = "Memory Usage<br /><font size=-2>(multiple slices indicate fragments)</font>"; |
|
835
|
|
|
else |
|
836
|
|
|
$mem_note = "Memory Usage"; |
|
837
|
|
|
|
|
838
|
|
|
echo <<< EOB |
|
839
|
|
|
</tbody></table> |
|
840
|
|
|
</div> |
|
841
|
|
|
|
|
842
|
|
|
<div class="graph div3"><h2>Host Status Diagrams</h2> |
|
843
|
|
|
<table cellspacing=0><tbody> |
|
844
|
|
|
EOB; |
|
845
|
|
|
$size='width='.(GRAPH_SIZE+50).' height='.(GRAPH_SIZE+10); |
|
846
|
|
|
echo <<<EOB |
|
847
|
|
|
<tr> |
|
848
|
|
|
<td class=td-0>$mem_note</td> |
|
849
|
|
|
<td class=td-1>Hits & Misses</td> |
|
850
|
|
|
</tr> |
|
851
|
|
|
EOB; |
|
852
|
|
|
|
|
853
|
|
|
echo |
|
854
|
|
|
graphics_avail() ? |
|
855
|
|
|
'<tr>'. |
|
856
|
|
|
"<td class=td-0><img alt=\"\" $size src=\"$PHP_SELF?IMG=1&$time\"></td>". |
|
857
|
|
|
"<td class=td-1><img alt=\"\" $size src=\"$PHP_SELF?IMG=2&$time\"></td></tr>\n" |
|
858
|
|
|
: "", |
|
859
|
|
|
'<tr>', |
|
860
|
|
|
'<td class=td-0><span class="green box"> </span>Free: ',bsize($mem_avail).sprintf(" (%.1f%%)",$mem_avail*100/$mem_size),"</td>\n", |
|
861
|
|
|
'<td class=td-1><span class="green box"> </span>Hits: ',$cache['num_hits'].@sprintf(" (%.1f%%)",$cache['num_hits']*100/($cache['num_hits']+$cache['num_misses'])),"</td>\n", |
|
862
|
|
|
'</tr>', |
|
863
|
|
|
'<tr>', |
|
864
|
|
|
'<td class=td-0><span class="red box"> </span>Used: ',bsize($mem_used).sprintf(" (%.1f%%)",$mem_used *100/$mem_size),"</td>\n", |
|
865
|
|
|
'<td class=td-1><span class="red box"> </span>Misses: ',$cache['num_misses'].@sprintf(" (%.1f%%)",$cache['num_misses']*100/($cache['num_hits']+$cache['num_misses'])),"</td>\n"; |
|
866
|
|
|
echo <<< EOB |
|
867
|
|
|
</tr> |
|
868
|
|
|
</tbody></table> |
|
869
|
|
|
|
|
870
|
|
|
<br/> |
|
871
|
|
|
<h2>Detailed Memory Usage and Fragmentation</h2> |
|
872
|
|
|
<table cellspacing=0><tbody> |
|
873
|
|
|
<tr> |
|
874
|
|
|
<td class=td-0 colspan=2><br/> |
|
875
|
|
|
EOB; |
|
876
|
|
|
|
|
877
|
|
|
// Fragementation: (freeseg - 1) / total_seg |
|
878
|
|
|
$nseg = $freeseg = $fragsize = $freetotal = 0; |
|
879
|
|
|
for($i=0; $i<$mem['num_seg']; $i++) { |
|
880
|
|
|
$ptr = 0; |
|
881
|
|
|
foreach($mem['block_lists'][$i] as $block) { |
|
882
|
|
|
if ($block['offset'] != $ptr) { |
|
883
|
|
|
++$nseg; |
|
884
|
|
|
} |
|
885
|
|
|
$ptr = $block['offset'] + $block['size']; |
|
886
|
|
|
/* Only consider blocks <5M for the fragmentation % */ |
|
887
|
|
|
if($block['size']<(5*1024*1024)) $fragsize+=$block['size']; |
|
888
|
|
|
$freetotal+=$block['size']; |
|
889
|
|
|
} |
|
890
|
|
|
$freeseg += count($mem['block_lists'][$i]); |
|
891
|
|
|
} |
|
892
|
|
|
|
|
893
|
|
|
if ($freeseg > 1) { |
|
894
|
|
|
$frag = sprintf("%.2f%% (%s out of %s in %d fragments)", ($fragsize/$freetotal)*100,bsize($fragsize),bsize($freetotal),$freeseg); |
|
895
|
|
|
} else { |
|
896
|
|
|
$frag = "0%"; |
|
897
|
|
|
} |
|
898
|
|
|
|
|
899
|
|
|
if (graphics_avail()) { |
|
900
|
|
|
$size='width='.(2*GRAPH_SIZE+150).' height='.(GRAPH_SIZE+10); |
|
901
|
|
|
echo <<<EOB |
|
902
|
|
|
<img alt="" $size src="$PHP_SELF?IMG=3&$time"> |
|
903
|
|
|
EOB; |
|
904
|
|
|
} |
|
905
|
|
|
echo <<<EOB |
|
906
|
|
|
</br>Fragmentation: $frag |
|
907
|
|
|
</td> |
|
908
|
|
|
</tr> |
|
909
|
|
|
EOB; |
|
910
|
|
|
if(isset($mem['adist'])) { |
|
911
|
|
|
foreach($mem['adist'] as $i=>$v) { |
|
912
|
|
|
$cur = pow(2,$i); $nxt = pow(2,$i+1)-1; |
|
913
|
|
|
if($i==0) $range = "1"; |
|
914
|
|
|
else $range = "$cur - $nxt"; |
|
915
|
|
|
echo "<tr><th align=right>$range</th><td align=right>$v</td></tr>\n"; |
|
916
|
|
|
} |
|
917
|
|
|
} |
|
918
|
|
|
echo <<<EOB |
|
919
|
|
|
</tbody></table> |
|
920
|
|
|
</div> |
|
921
|
|
|
EOB; |
|
922
|
|
|
|
|
923
|
|
|
break; |
|
924
|
|
|
|
|
925
|
|
|
|
|
926
|
|
|
// ----------------------------------------------- |
|
927
|
|
|
// User Cache Entries |
|
928
|
|
|
// ----------------------------------------------- |
|
929
|
|
|
case OB_USER_CACHE: |
|
930
|
|
|
if (!$AUTHENTICATED) { |
|
931
|
|
|
echo '<div class="error">You need to login to see the user values here!<br/> <br/>'; |
|
932
|
|
|
put_login_link("Login now!"); |
|
933
|
|
|
echo '</div>'; |
|
934
|
|
|
break; |
|
935
|
|
|
} |
|
936
|
|
|
$fieldname='info'; |
|
937
|
|
|
$fieldheading='User Entry Label'; |
|
938
|
|
|
$fieldkey='info'; |
|
939
|
|
|
|
|
940
|
|
|
$cols=6; |
|
941
|
|
|
echo <<<EOB |
|
942
|
|
|
<div class=sorting><form>Scope: |
|
943
|
|
|
<input type=hidden name=OB value={$MYREQUEST['OB']}> |
|
944
|
|
|
<select name=SCOPE> |
|
945
|
|
|
EOB; |
|
946
|
|
|
echo |
|
947
|
|
|
"<option value=A",$MYREQUEST['SCOPE']=='A' ? " selected":"",">Active</option>", |
|
948
|
|
|
"<option value=D",$MYREQUEST['SCOPE']=='D' ? " selected":"",">Deleted</option>", |
|
949
|
|
|
"</select>", |
|
950
|
|
|
", Sorting:<select name=SORT1>", |
|
951
|
|
|
"<option value=H",$MYREQUEST['SORT1']=='H' ? " selected":"",">Hits</option>", |
|
952
|
|
|
"<option value=Z",$MYREQUEST['SORT1']=='Z' ? " selected":"",">Size</option>", |
|
953
|
|
|
"<option value=S",$MYREQUEST['SORT1']=='S' ? " selected":"",">$fieldheading</option>", |
|
954
|
|
|
"<option value=A",$MYREQUEST['SORT1']=='A' ? " selected":"",">Last accessed</option>", |
|
955
|
|
|
"<option value=M",$MYREQUEST['SORT1']=='M' ? " selected":"",">Last modified</option>", |
|
956
|
|
|
"<option value=C",$MYREQUEST['SORT1']=='C' ? " selected":"",">Created at</option>", |
|
957
|
|
|
"<option value=D",$MYREQUEST['SORT1']=='D' ? " selected":"",">Deleted at</option>"; |
|
958
|
|
|
if($fieldname=='info') echo |
|
|
|
|
|
|
959
|
|
|
"<option value=D",$MYREQUEST['SORT1']=='T' ? " selected":"",">Timeout</option>"; |
|
960
|
|
|
echo |
|
961
|
|
|
'</select>', |
|
962
|
|
|
'<select name=SORT2>', |
|
963
|
|
|
'<option value=D',$MYREQUEST['SORT2']=='D' ? ' selected':'','>DESC</option>', |
|
964
|
|
|
'<option value=A',$MYREQUEST['SORT2']=='A' ? ' selected':'','>ASC</option>', |
|
965
|
|
|
'</select>', |
|
966
|
|
|
'<select name=COUNT onChange="form.submit()">', |
|
967
|
|
|
'<option value=10 ',$MYREQUEST['COUNT']=='10' ? ' selected':'','>Top 10</option>', |
|
968
|
|
|
'<option value=20 ',$MYREQUEST['COUNT']=='20' ? ' selected':'','>Top 20</option>', |
|
969
|
|
|
'<option value=50 ',$MYREQUEST['COUNT']=='50' ? ' selected':'','>Top 50</option>', |
|
970
|
|
|
'<option value=100',$MYREQUEST['COUNT']=='100'? ' selected':'','>Top 100</option>', |
|
971
|
|
|
'<option value=150',$MYREQUEST['COUNT']=='150'? ' selected':'','>Top 150</option>', |
|
972
|
|
|
'<option value=200',$MYREQUEST['COUNT']=='200'? ' selected':'','>Top 200</option>', |
|
973
|
|
|
'<option value=500',$MYREQUEST['COUNT']=='500'? ' selected':'','>Top 500</option>', |
|
974
|
|
|
'<option value=0 ',$MYREQUEST['COUNT']=='0' ? ' selected':'','>All</option>', |
|
975
|
|
|
'</select>', |
|
976
|
|
|
' Search: <input name=SEARCH value="',$MYREQUEST['SEARCH'],'" type=text size=25/>', |
|
977
|
|
|
' <input type=submit value="GO!">', |
|
978
|
|
|
'</form></div>'; |
|
979
|
|
|
|
|
980
|
|
|
if (isset($MYREQUEST['SEARCH'])) { |
|
981
|
|
|
// Don't use preg_quote because we want the user to be able to specify a |
|
982
|
|
|
// regular expression subpattern. |
|
983
|
|
|
$MYREQUEST['SEARCH'] = '/'.str_replace('/', '\\/', $MYREQUEST['SEARCH']).'/i'; |
|
984
|
|
|
if (preg_match($MYREQUEST['SEARCH'], 'test') === false) { |
|
985
|
|
|
echo '<div class="error">Error: enter a valid regular expression as a search query.</div>'; |
|
986
|
|
|
break; |
|
987
|
|
|
} |
|
988
|
|
|
} |
|
989
|
|
|
|
|
990
|
|
|
echo |
|
991
|
|
|
'<div class="info"><table cellspacing=0><tbody>', |
|
992
|
|
|
'<tr>', |
|
993
|
|
|
'<th>',sortheader('S',$fieldheading, "&OB=".$MYREQUEST['OB']),'</th>', |
|
994
|
|
|
'<th>',sortheader('H','Hits', "&OB=".$MYREQUEST['OB']),'</th>', |
|
995
|
|
|
'<th>',sortheader('Z','Size', "&OB=".$MYREQUEST['OB']),'</th>', |
|
996
|
|
|
'<th>',sortheader('A','Last accessed',"&OB=".$MYREQUEST['OB']),'</th>', |
|
997
|
|
|
'<th>',sortheader('M','Last modified',"&OB=".$MYREQUEST['OB']),'</th>', |
|
998
|
|
|
'<th>',sortheader('C','Created at', "&OB=".$MYREQUEST['OB']),'</th>'; |
|
999
|
|
|
|
|
1000
|
|
|
if($fieldname=='info') { |
|
|
|
|
|
|
1001
|
|
|
$cols+=2; |
|
1002
|
|
|
echo '<th>',sortheader('T','Timeout',"&OB=".$MYREQUEST['OB']),'</th>'; |
|
1003
|
|
|
} |
|
1004
|
|
|
echo '<th>',sortheader('D','Deleted at',"&OB=".$MYREQUEST['OB']),'</th></tr>'; |
|
1005
|
|
|
|
|
1006
|
|
|
// builds list with alpha numeric sortable keys |
|
1007
|
|
|
// |
|
1008
|
|
|
$list = array(); |
|
1009
|
|
|
|
|
1010
|
|
|
foreach($cache[$scope_list[$MYREQUEST['SCOPE']]] as $i => $entry) { |
|
1011
|
|
|
switch($MYREQUEST['SORT1']) { |
|
1012
|
|
|
case 'A': $k=sprintf('%015d-',$entry['access_time']); break; |
|
1013
|
|
|
case 'H': $k=sprintf('%015d-',$entry['num_hits']); break; |
|
1014
|
|
|
case 'Z': $k=sprintf('%015d-',$entry['mem_size']); break; |
|
1015
|
|
|
case 'M': $k=sprintf('%015d-',$entry['mtime']); break; |
|
1016
|
|
|
case 'C': $k=sprintf('%015d-',$entry['creation_time']); break; |
|
1017
|
|
|
case 'T': $k=sprintf('%015d-',$entry['ttl']); break; |
|
1018
|
|
|
case 'D': $k=sprintf('%015d-',$entry['deletion_time']); break; |
|
1019
|
|
|
case 'S': $k=$entry["info"]; break; |
|
1020
|
|
|
} |
|
1021
|
|
|
if (!$AUTHENTICATED) { |
|
1022
|
|
|
// hide all path entries if not logged in |
|
1023
|
|
|
$list[$k.$entry[$fieldname]]=preg_replace('/^.*(\\/|\\\\)/','*hidden*/',$entry); |
|
1024
|
|
|
} else { |
|
1025
|
|
|
$list[$k.$entry[$fieldname]]=$entry; |
|
1026
|
|
|
} |
|
1027
|
|
|
} |
|
1028
|
|
|
|
|
1029
|
|
|
if ($list) { |
|
1030
|
|
|
// sort list |
|
1031
|
|
|
// |
|
1032
|
|
|
switch ($MYREQUEST['SORT2']) { |
|
1033
|
|
|
case "A": krsort($list); break; |
|
1034
|
|
|
case "D": ksort($list); break; |
|
1035
|
|
|
} |
|
1036
|
|
|
|
|
1037
|
|
|
// output list |
|
1038
|
|
|
$i=0; |
|
1039
|
|
|
foreach($list as $k => $entry) { |
|
1040
|
|
|
if(!$MYREQUEST['SEARCH'] || preg_match($MYREQUEST['SEARCH'], $entry[$fieldname]) != 0) { |
|
1041
|
|
|
$sh=md5($entry["info"]); |
|
1042
|
|
|
$field_value = htmlentities(strip_tags($entry[$fieldname],''), ENT_QUOTES, 'UTF-8'); |
|
1043
|
|
|
echo |
|
1044
|
|
|
'<tr id="key-'. $sh .'" class=tr-',$i%2,'>', |
|
1045
|
|
|
"<td class=td-0><a href=\"$MY_SELF&OB=",$MYREQUEST['OB'],"&SH=",$sh,"#key-". $sh ."\">",$field_value,'</a></td>', |
|
1046
|
|
|
'<td class="td-n center">',$entry['num_hits'],'</td>', |
|
1047
|
|
|
'<td class="td-n right">',$entry['mem_size'],'</td>', |
|
1048
|
|
|
'<td class="td-n center">',date(DATE_FORMAT,$entry['access_time']),'</td>', |
|
1049
|
|
|
'<td class="td-n center">',date(DATE_FORMAT,$entry['mtime']),'</td>', |
|
1050
|
|
|
'<td class="td-n center">',date(DATE_FORMAT,$entry['creation_time']),'</td>'; |
|
1051
|
|
|
|
|
1052
|
|
|
if($fieldname=='info') { |
|
1053
|
|
|
if($entry['ttl']) |
|
1054
|
|
|
echo '<td class="td-n center">'.$entry['ttl'].' seconds</td>'; |
|
1055
|
|
|
else |
|
1056
|
|
|
echo '<td class="td-n center">None</td>'; |
|
1057
|
|
|
} |
|
1058
|
|
|
if ($entry['deletion_time']) { |
|
1059
|
|
|
|
|
1060
|
|
|
echo '<td class="td-last center">', date(DATE_FORMAT,$entry['deletion_time']), '</td>'; |
|
1061
|
|
|
} else if ($MYREQUEST['OB'] == OB_USER_CACHE) { |
|
1062
|
|
|
|
|
1063
|
|
|
echo '<td class="td-last center">'; |
|
1064
|
|
|
echo '[<a href="', $MY_SELF, '&OB=', $MYREQUEST['OB'], '&DU=', urlencode($entry[$fieldkey]), '">Delete Now</a>]'; |
|
1065
|
|
|
echo '</td>'; |
|
1066
|
|
|
} else { |
|
1067
|
|
|
echo '<td class="td-last center"> </td>'; |
|
1068
|
|
|
} |
|
1069
|
|
|
echo '</tr>'; |
|
1070
|
|
|
if ($sh == $MYREQUEST["SH"]) { |
|
1071
|
|
|
echo '<tr>'; |
|
1072
|
|
|
echo '<td colspan="7"><pre>'.htmlentities(print_r(apcu_fetch($entry['info']), 1)).'</pre></td>'; |
|
1073
|
|
|
echo '</tr>'; |
|
1074
|
|
|
} |
|
1075
|
|
|
$i++; |
|
1076
|
|
|
if ($i == $MYREQUEST['COUNT']) |
|
1077
|
|
|
break; |
|
1078
|
|
|
} |
|
1079
|
|
|
} |
|
1080
|
|
|
|
|
1081
|
|
|
} else { |
|
1082
|
|
|
echo '<tr class=tr-0><td class="center" colspan=',$cols,'><i>No data</i></td></tr>'; |
|
1083
|
|
|
} |
|
1084
|
|
|
echo <<< EOB |
|
1085
|
|
|
</tbody></table> |
|
1086
|
|
|
EOB; |
|
1087
|
|
|
|
|
1088
|
|
|
if ($list && $i < count($list)) { |
|
1089
|
|
|
echo "<a href=\"$MY_SELF&OB=",$MYREQUEST['OB'],"&COUNT=0\"><i>",count($list)-$i,' more available...</i></a>'; |
|
1090
|
|
|
} |
|
1091
|
|
|
|
|
1092
|
|
|
echo <<< EOB |
|
1093
|
|
|
</div> |
|
1094
|
|
|
EOB; |
|
1095
|
|
|
break; |
|
1096
|
|
|
|
|
1097
|
|
|
// ----------------------------------------------- |
|
1098
|
|
|
// Version check |
|
1099
|
|
|
// ----------------------------------------------- |
|
1100
|
|
|
case OB_VERSION_CHECK: |
|
1101
|
|
|
echo <<<EOB |
|
1102
|
|
|
<div class="info"><h2>APCu Version Information</h2> |
|
1103
|
|
|
<table cellspacing=0><tbody> |
|
1104
|
|
|
<tr> |
|
1105
|
|
|
<th></th> |
|
1106
|
|
|
</tr> |
|
1107
|
|
|
EOB; |
|
1108
|
|
|
if (defined('PROXY')) { |
|
1109
|
|
|
$ctxt = stream_context_create( array( 'http' => array( 'proxy' => PROXY, 'request_fulluri' => True ) ) ); |
|
|
|
|
|
|
1110
|
|
|
$rss = @file_get_contents("http://pecl.php.net/feeds/pkg_apcu.rss", False, $ctxt); |
|
1111
|
|
|
} else { |
|
1112
|
|
|
$rss = @file_get_contents("http://pecl.php.net/feeds/pkg_apcu.rss"); |
|
1113
|
|
|
} |
|
1114
|
|
|
if (!$rss) { |
|
1115
|
|
|
echo '<tr class="td-last center"><td>Unable to fetch version information.</td></tr>'; |
|
1116
|
|
|
} else { |
|
1117
|
|
|
$apcversion = phpversion('apcu'); |
|
1118
|
|
|
|
|
1119
|
|
|
preg_match('!<title>APCu ([0-9.]+)</title>!', $rss, $match); |
|
1120
|
|
|
echo '<tr class="tr-0 center"><td>'; |
|
1121
|
|
|
if (version_compare($apcversion, $match[1], '>=')) { |
|
1122
|
|
|
echo '<div class="ok">You are running the latest version of APCu ('.$apcversion.')</div>'; |
|
1123
|
|
|
$i = 3; |
|
1124
|
|
|
} else { |
|
1125
|
|
|
echo '<div class="failed">You are running an older version of APCu ('.$apcversion.'), |
|
1126
|
|
|
newer version '.$match[1].' is available at <a href="http://pecl.php.net/package/APCu/'.$match[1].'"> |
|
1127
|
|
|
http://pecl.php.net/package/APCu/'.$match[1].'</a> |
|
1128
|
|
|
</div>'; |
|
1129
|
|
|
$i = -1; |
|
1130
|
|
|
} |
|
1131
|
|
|
echo '</td></tr>'; |
|
1132
|
|
|
echo '<tr class="tr-0"><td><h3>Change Log:</h3><br/>'; |
|
1133
|
|
|
|
|
1134
|
|
|
preg_match_all('!<(title|description)>([^<]+)</\\1>!', $rss, $match); |
|
1135
|
|
|
next($match[2]); next($match[2]); |
|
1136
|
|
|
|
|
1137
|
|
|
while (list(,$v) = each($match[2])) { |
|
|
|
|
|
|
1138
|
|
|
list(,$ver) = explode(' ', $v, 2); |
|
1139
|
|
|
if ($i < 0 && version_compare($apcversion, $ver, '>=')) { |
|
1140
|
|
|
break; |
|
1141
|
|
|
} else if (!$i--) { |
|
1142
|
|
|
break; |
|
1143
|
|
|
} |
|
1144
|
|
|
echo "<b><a href=\"http://pecl.php.net/package/APCu/$ver\">".htmlspecialchars($v, ENT_QUOTES, 'UTF-8')."</a></b><br><blockquote>"; |
|
1145
|
|
|
echo nl2br(htmlspecialchars(current($match[2]), ENT_QUOTES, 'UTF-8'))."</blockquote>"; |
|
1146
|
|
|
next($match[2]); |
|
1147
|
|
|
} |
|
1148
|
|
|
echo '</td></tr>'; |
|
1149
|
|
|
} |
|
1150
|
|
|
echo <<< EOB |
|
1151
|
|
|
</tbody></table> |
|
1152
|
|
|
</div> |
|
1153
|
|
|
EOB; |
|
1154
|
|
|
break; |
|
1155
|
|
|
|
|
1156
|
|
|
} |
|
1157
|
|
|
|
|
1158
|
|
|
echo <<< EOB |
|
1159
|
|
|
</div> |
|
1160
|
|
|
EOB; |
|
1161
|
|
|
|
|
1162
|
|
|
?> |
|
1163
|
|
|
|
|
1164
|
|
|
<!-- <?php echo "\nBased on APCGUI By R.Becker\n$VERSION\n"?> --> |
|
1165
|
|
|
</body> |
|
1166
|
|
|
</html> |
|
1167
|
|
|
|