@@ -51,8 +51,7 @@ discard block |
||
51 | 51 | $values = explode(':', $server); |
52 | 52 | if (($values[0] == 'unix') && (!is_numeric( $values[1]))) { |
53 | 53 | return array($server, 0); |
54 | - } |
|
55 | - else { |
|
54 | + } else { |
|
56 | 55 | return $values; |
57 | 56 | } |
58 | 57 | } |
@@ -110,7 +109,7 @@ discard block |
||
110 | 109 | $res[$l[0]][$l[1]]['stat']=array('flag'=>$flag,'size'=>$size); |
111 | 110 | $res[$l[0]][$l[1]]['value']=$lines[++$i]; |
112 | 111 | } |
113 | - }elseif($line=='DELETED' || $line=='NOT_FOUND' || $line=='OK'){ |
|
112 | + } elseif($line=='DELETED' || $line=='NOT_FOUND' || $line=='OK'){ |
|
114 | 113 | return $line; |
115 | 114 | } |
116 | 115 | } |
@@ -257,16 +256,35 @@ discard block |
||
257 | 256 | $hours = (int)(($rem)/3600) - $days*24 - $weeks*7*24; |
258 | 257 | $mins = (int)(($rem)/60) - $hours*60 - $days*24*60 - $weeks*7*24*60; |
259 | 258 | $str = ''; |
260 | - if($years==1) $str .= "$years year, "; |
|
261 | - if($years>1) $str .= "$years years, "; |
|
262 | - if($weeks==1) $str .= "$weeks week, "; |
|
263 | - if($weeks>1) $str .= "$weeks weeks, "; |
|
264 | - if($days==1) $str .= "$days day,"; |
|
265 | - if($days>1) $str .= "$days days,"; |
|
266 | - if($hours == 1) $str .= " $hours hour and"; |
|
267 | - if($hours>1) $str .= " $hours hours and"; |
|
268 | - if($mins == 1) $str .= " 1 minute"; |
|
269 | - else $str .= " $mins minutes"; |
|
259 | + if($years==1) { |
|
260 | + $str .= "$years year, "; |
|
261 | + } |
|
262 | + if($years>1) { |
|
263 | + $str .= "$years years, "; |
|
264 | + } |
|
265 | + if($weeks==1) { |
|
266 | + $str .= "$weeks week, "; |
|
267 | + } |
|
268 | + if($weeks>1) { |
|
269 | + $str .= "$weeks weeks, "; |
|
270 | + } |
|
271 | + if($days==1) { |
|
272 | + $str .= "$days day,"; |
|
273 | + } |
|
274 | + if($days>1) { |
|
275 | + $str .= "$days days,"; |
|
276 | + } |
|
277 | + if($hours == 1) { |
|
278 | + $str .= " $hours hour and"; |
|
279 | + } |
|
280 | + if($hours>1) { |
|
281 | + $str .= " $hours hours and"; |
|
282 | + } |
|
283 | + if($mins == 1) { |
|
284 | + $str .= " 1 minute"; |
|
285 | + } else { |
|
286 | + $str .= " $mins minutes"; |
|
287 | + } |
|
270 | 288 | return $str; |
271 | 289 | } |
272 | 290 | |
@@ -278,7 +296,9 @@ discard block |
||
278 | 296 | |
279 | 297 | function bsize($s) { |
280 | 298 | foreach (array('','K','M','G') as $i => $k) { |
281 | - if ($s < 1024) break; |
|
299 | + if ($s < 1024) { |
|
300 | + break; |
|
301 | + } |
|
282 | 302 | $s/=1024; |
283 | 303 | } |
284 | 304 | return sprintf("%5.1f %sBytes",$s,$k); |
@@ -506,8 +526,7 @@ discard block |
||
506 | 526 | echo <<<EOB |
507 | 527 | <li><a href="$PHP_SELF&op={$_GET['op']}">Refresh Data</a></li> |
508 | 528 | EOB; |
509 | -} |
|
510 | -else { |
|
529 | +} else { |
|
511 | 530 | echo <<<EOB |
512 | 531 | <li><a href="$PHP_SELF&op=2}">Back</a></li> |
513 | 532 | EOB; |
@@ -557,8 +576,11 @@ discard block |
||
557 | 576 | $y1=$y+$h-1; |
558 | 577 | |
559 | 578 | imagerectangle($im, $x, $y1, $x1+1, $y+1, $col_black); |
560 | - if($y1>$y) imagefilledrectangle($im, $x, $y, $x1, $y1, $color2); |
|
561 | - else imagefilledrectangle($im, $x, $y1, $x1, $y, $color2); |
|
579 | + if($y1>$y) { |
|
580 | + imagefilledrectangle($im, $x, $y, $x1, $y1, $color2); |
|
581 | + } else { |
|
582 | + imagefilledrectangle($im, $x, $y1, $x1, $y, $color2); |
|
583 | + } |
|
562 | 584 | imagerectangle($im, $x, $y1, $x1, $y, $color1); |
563 | 585 | if ($text) { |
564 | 586 | if ($placeindex>0) { |
@@ -713,8 +735,7 @@ discard block |
||
713 | 735 | foreach($MEMCACHE_SERVERS as $server){ |
714 | 736 | echo ($i+1).'. <a href="'.$PHP_SELF.'&singleout='.$i++.'">'.$server.'</a><br/>'; |
715 | 737 | } |
716 | - } |
|
717 | - else{ |
|
738 | + } else{ |
|
718 | 739 | echo '1.'.$MEMCACHE_SERVERS[0]; |
719 | 740 | } |
720 | 741 | if (isset($_GET['singleout'])){ |
@@ -821,8 +842,7 @@ discard block |
||
821 | 842 | echo '<a href="',$PHP_SELF,'&op=4&server=',(array_search($server,$MEMCACHE_SERVERS)),'&key=',base64_encode($itemKey).'">',$itemKey,'</a>'; |
822 | 843 | if ($i++ % 10 == 0) { |
823 | 844 | echo '<br/>'; |
824 | - } |
|
825 | - elseif ($i!=$slab['number']+1){ |
|
845 | + } elseif ($i!=$slab['number']+1){ |
|
826 | 846 | echo ','; |
827 | 847 | } |
828 | 848 | } |
@@ -861,8 +881,7 @@ discard block |
||
861 | 881 | echo "<tr><td class=td-0>",$theserver,"</td><td class=td-0>",$theKey, |
862 | 882 | "</td><td>[The requested item was not found or has expired]</td>", |
863 | 883 | "<td></td>","</tr>"; |
864 | - } |
|
865 | - else { |
|
884 | + } else { |
|
866 | 885 | |
867 | 886 | echo "<tr><td class=td-0>",$theserver,"</td><td class=td-0>",$theKey, |
868 | 887 | " <br/>flag:",$r['VALUE'][$theKey]['stat']['flag'], |
@@ -31,7 +31,9 @@ discard block |
||
31 | 31 | $VERSION='$Id$'; |
32 | 32 | |
33 | 33 | ////////// READ OPTIONAL CONFIGURATION FILE //////////// |
34 | -if (file_exists("apc.conf.php")) include("apc.conf.php"); |
|
34 | +if (file_exists("apc.conf.php")) { |
|
35 | + include("apc.conf.php"); |
|
36 | +} |
|
35 | 37 | //////////////////////////////////////////////////////// |
36 | 38 | |
37 | 39 | ////////// BEGIN OF DEFAULT CONFIG AREA /////////////////////////////////////////////////////////// |
@@ -62,7 +64,10 @@ discard block |
||
62 | 64 | |
63 | 65 | // "define if not defined" |
64 | 66 | function defaults($d,$v) { |
65 | - if (!defined($d)) define($d,$v); // or just @define(...) |
|
67 | + if (!defined($d)) { |
|
68 | + define($d,$v); |
|
69 | + } |
|
70 | + // or just @define(...) |
|
66 | 71 | } |
67 | 72 | |
68 | 73 | // rewrite $PHP_SELF to block XSS attacks |
@@ -129,12 +134,24 @@ discard block |
||
129 | 134 | } |
130 | 135 | |
131 | 136 | // check parameter sematics |
132 | -if (empty($MYREQUEST['SCOPE'])) $MYREQUEST['SCOPE']="A"; |
|
133 | -if (empty($MYREQUEST['SORT1'])) $MYREQUEST['SORT1']="H"; |
|
134 | -if (empty($MYREQUEST['SORT2'])) $MYREQUEST['SORT2']="D"; |
|
135 | -if (empty($MYREQUEST['OB'])) $MYREQUEST['OB']=OB_HOST_STATS; |
|
136 | -if (!isset($MYREQUEST['COUNT'])) $MYREQUEST['COUNT']=20; |
|
137 | -if (!isset($scope_list[$MYREQUEST['SCOPE']])) $MYREQUEST['SCOPE']='A'; |
|
137 | +if (empty($MYREQUEST['SCOPE'])) { |
|
138 | + $MYREQUEST['SCOPE']="A"; |
|
139 | +} |
|
140 | +if (empty($MYREQUEST['SORT1'])) { |
|
141 | + $MYREQUEST['SORT1']="H"; |
|
142 | +} |
|
143 | +if (empty($MYREQUEST['SORT2'])) { |
|
144 | + $MYREQUEST['SORT2']="D"; |
|
145 | +} |
|
146 | +if (empty($MYREQUEST['OB'])) { |
|
147 | + $MYREQUEST['OB']=OB_HOST_STATS; |
|
148 | +} |
|
149 | +if (!isset($MYREQUEST['COUNT'])) { |
|
150 | + $MYREQUEST['COUNT']=20; |
|
151 | +} |
|
152 | +if (!isset($scope_list[$MYREQUEST['SCOPE']])) { |
|
153 | + $MYREQUEST['SCOPE']='A'; |
|
154 | +} |
|
138 | 155 | |
139 | 156 | $MY_SELF= |
140 | 157 | "$PHP_SELF". |
@@ -210,16 +227,35 @@ discard block |
||
210 | 227 | $hours = (int)(($rem)/3600) - $days*24 - $weeks*7*24; |
211 | 228 | $mins = (int)(($rem)/60) - $hours*60 - $days*24*60 - $weeks*7*24*60; |
212 | 229 | $str = ''; |
213 | - if($years==1) $str .= "$years year, "; |
|
214 | - if($years>1) $str .= "$years years, "; |
|
215 | - if($weeks==1) $str .= "$weeks week, "; |
|
216 | - if($weeks>1) $str .= "$weeks weeks, "; |
|
217 | - if($days==1) $str .= "$days day,"; |
|
218 | - if($days>1) $str .= "$days days,"; |
|
219 | - if($hours == 1) $str .= " $hours hour and"; |
|
220 | - if($hours>1) $str .= " $hours hours and"; |
|
221 | - if($mins == 1) $str .= " 1 minute"; |
|
222 | - else $str .= " $mins minutes"; |
|
230 | + if($years==1) { |
|
231 | + $str .= "$years year, "; |
|
232 | + } |
|
233 | + if($years>1) { |
|
234 | + $str .= "$years years, "; |
|
235 | + } |
|
236 | + if($weeks==1) { |
|
237 | + $str .= "$weeks week, "; |
|
238 | + } |
|
239 | + if($weeks>1) { |
|
240 | + $str .= "$weeks weeks, "; |
|
241 | + } |
|
242 | + if($days==1) { |
|
243 | + $str .= "$days day,"; |
|
244 | + } |
|
245 | + if($days>1) { |
|
246 | + $str .= "$days days,"; |
|
247 | + } |
|
248 | + if($hours == 1) { |
|
249 | + $str .= " $hours hour and"; |
|
250 | + } |
|
251 | + if($hours>1) { |
|
252 | + $str .= " $hours hours and"; |
|
253 | + } |
|
254 | + if($mins == 1) { |
|
255 | + $str .= " 1 minute"; |
|
256 | + } else { |
|
257 | + $str .= " $mins minutes"; |
|
258 | + } |
|
223 | 259 | return $str; |
224 | 260 | } |
225 | 261 | |
@@ -282,8 +318,11 @@ discard block |
||
282 | 318 | $y1=$y+$h-1; |
283 | 319 | |
284 | 320 | imagerectangle($im, $x, $y1, $x1+1, $y+1, $col_black); |
285 | - if($y1>$y) imagefilledrectangle($im, $x, $y, $x1, $y1, $color2); |
|
286 | - else imagefilledrectangle($im, $x, $y1, $x1, $y, $color2); |
|
321 | + if($y1>$y) { |
|
322 | + imagefilledrectangle($im, $x, $y, $x1, $y1, $color2); |
|
323 | + } else { |
|
324 | + imagefilledrectangle($im, $x, $y1, $x1, $y, $color2); |
|
325 | + } |
|
287 | 326 | imagerectangle($im, $x, $y1, $x1, $y, $color1); |
288 | 327 | if ($text) { |
289 | 328 | if ($placeindex>0) { |
@@ -316,10 +355,11 @@ discard block |
||
316 | 355 | |
317 | 356 | |
318 | 357 | $size = GRAPH_SIZE; // image size |
319 | - if ($MYREQUEST['IMG']==3) |
|
320 | - $image = imagecreate(2*$size+150, $size+10); |
|
321 | - else |
|
322 | - $image = imagecreate($size+50, $size+10); |
|
358 | + if ($MYREQUEST['IMG']==3) { |
|
359 | + $image = imagecreate(2*$size+150, $size+10); |
|
360 | + } else { |
|
361 | + $image = imagecreate($size+50, $size+10); |
|
362 | + } |
|
323 | 363 | |
324 | 364 | $col_white = imagecolorallocate($image, 0xFF, 0xFF, 0xFF); |
325 | 365 | $col_red = imagecolorallocate($image, 0xD0, 0x60, 0x30); |
@@ -346,7 +386,9 @@ discard block |
||
346 | 386 | foreach($free as $block) { |
347 | 387 | if($block['offset']!=$ptr) { // Used block |
348 | 388 | $angle_to = $angle_from+($block['offset']-$ptr)/$s; |
349 | - if(($angle_to+$fuzz)>1) $angle_to = 1; |
|
389 | + if(($angle_to+$fuzz)>1) { |
|
390 | + $angle_to = 1; |
|
391 | + } |
|
350 | 392 | if( ($angle_to*360) - ($angle_from*360) >= 1) { |
351 | 393 | fill_arc($image,$x,$y,$size,$angle_from*360,$angle_to*360,$col_black,$col_red); |
352 | 394 | if (($angle_to-$angle_from)>0.05) { |
@@ -356,7 +398,9 @@ discard block |
||
356 | 398 | $angle_from = $angle_to; |
357 | 399 | } |
358 | 400 | $angle_to = $angle_from+($block['size'])/$s; |
359 | - if(($angle_to+$fuzz)>1) $angle_to = 1; |
|
401 | + if(($angle_to+$fuzz)>1) { |
|
402 | + $angle_to = 1; |
|
403 | + } |
|
360 | 404 | if( ($angle_to*360) - ($angle_from*360) >= 1) { |
361 | 405 | fill_arc($image,$x,$y,$size,$angle_from*360,$angle_to*360,$col_black,$col_green); |
362 | 406 | if (($angle_to-$angle_from)>0.05) { |
@@ -368,7 +412,9 @@ discard block |
||
368 | 412 | } |
369 | 413 | if ($ptr < $mem['seg_size']) { // memory at the end |
370 | 414 | $angle_to = $angle_from + ($mem['seg_size'] - $ptr)/$s; |
371 | - if(($angle_to+$fuzz)>1) $angle_to = 1; |
|
415 | + if(($angle_to+$fuzz)>1) { |
|
416 | + $angle_to = 1; |
|
417 | + } |
|
372 | 418 | fill_arc($image,$x,$y,$size,$angle_from*360,$angle_to*360,$col_black,$col_red); |
373 | 419 | if (($angle_to-$angle_from)>0.05) { |
374 | 420 | array_push($string_placement, array($angle_from,$angle_to)); |
@@ -406,16 +452,22 @@ discard block |
||
406 | 452 | $h=(GRAPH_SIZE-5)*($block['offset']-$ptr)/$s; |
407 | 453 | if ($h>0) { |
408 | 454 | $j++; |
409 | - if($j<75) fill_box($image,$x,$y,50,$h,$col_black,$col_red,bsize($block['offset']-$ptr),$j); |
|
410 | - else fill_box($image,$x,$y,50,$h,$col_black,$col_red); |
|
455 | + if($j<75) { |
|
456 | + fill_box($image,$x,$y,50,$h,$col_black,$col_red,bsize($block['offset']-$ptr),$j); |
|
457 | + } else { |
|
458 | + fill_box($image,$x,$y,50,$h,$col_black,$col_red); |
|
459 | + } |
|
411 | 460 | } |
412 | 461 | $y+=$h; |
413 | 462 | } |
414 | 463 | $h=(GRAPH_SIZE-5)*($block['size'])/$s; |
415 | 464 | if ($h>0) { |
416 | 465 | $j++; |
417 | - if($j<75) fill_box($image,$x,$y,50,$h,$col_black,$col_green,bsize($block['size']),$j); |
|
418 | - else fill_box($image,$x,$y,50,$h,$col_black,$col_green); |
|
466 | + if($j<75) { |
|
467 | + fill_box($image,$x,$y,50,$h,$col_black,$col_green,bsize($block['size']),$j); |
|
468 | + } else { |
|
469 | + fill_box($image,$x,$y,50,$h,$col_black,$col_green); |
|
470 | + } |
|
419 | 471 | } |
420 | 472 | $y+=$h; |
421 | 473 | $ptr = $block['offset']+$block['size']; |
@@ -447,7 +499,9 @@ discard block |
||
447 | 499 | // |
448 | 500 | function bsize($s) { |
449 | 501 | foreach (array('','K','M','G') as $i => $k) { |
450 | - if ($s < 1024) break; |
|
502 | + if ($s < 1024) { |
|
503 | + break; |
|
504 | + } |
|
451 | 505 | $s/=1024; |
452 | 506 | } |
453 | 507 | return sprintf("%5.1f %sBytes",$s,$k); |
@@ -775,10 +829,12 @@ discard block |
||
775 | 829 | <tr class=tr-1><td class=td-0>PHP Version</td><td>$phpversion</td></tr> |
776 | 830 | EOB; |
777 | 831 | |
778 | - if(!empty($_SERVER['SERVER_NAME'])) |
|
779 | - echo "<tr class=tr-0><td class=td-0>APCu Host</td><td>{$_SERVER['SERVER_NAME']} $host</td></tr>\n"; |
|
780 | - if(!empty($_SERVER['SERVER_SOFTWARE'])) |
|
781 | - echo "<tr class=tr-1><td class=td-0>Server Software</td><td>{$_SERVER['SERVER_SOFTWARE']}</td></tr>\n"; |
|
832 | + if(!empty($_SERVER['SERVER_NAME'])) { |
|
833 | + echo "<tr class=tr-0><td class=td-0>APCu Host</td><td>{$_SERVER['SERVER_NAME']} $host</td></tr>\n"; |
|
834 | + } |
|
835 | + if(!empty($_SERVER['SERVER_SOFTWARE'])) { |
|
836 | + echo "<tr class=tr-1><td class=td-0>Server Software</td><td>{$_SERVER['SERVER_SOFTWARE']}</td></tr>\n"; |
|
837 | + } |
|
782 | 838 | |
783 | 839 | echo <<<EOB |
784 | 840 | <tr class=tr-0><td class=td-0>Shared Memory</td><td>{$mem['num_seg']} Segment(s) with $seg_size |
@@ -816,10 +872,11 @@ discard block |
||
816 | 872 | $j = 1 - $j; |
817 | 873 | } |
818 | 874 | |
819 | - if($mem['num_seg']>1 || $mem['num_seg']==1 && count($mem['block_lists'][0])>1) |
|
820 | - $mem_note = "Memory Usage<br /><font size=-2>(multiple slices indicate fragments)</font>"; |
|
821 | - else |
|
822 | - $mem_note = "Memory Usage"; |
|
875 | + if($mem['num_seg']>1 || $mem['num_seg']==1 && count($mem['block_lists'][0])>1) { |
|
876 | + $mem_note = "Memory Usage<br /><font size=-2>(multiple slices indicate fragments)</font>"; |
|
877 | + } else { |
|
878 | + $mem_note = "Memory Usage"; |
|
879 | + } |
|
823 | 880 | |
824 | 881 | echo <<< EOB |
825 | 882 | </tbody></table> |
@@ -870,7 +927,9 @@ discard block |
||
870 | 927 | } |
871 | 928 | $ptr = $block['offset'] + $block['size']; |
872 | 929 | /* Only consider blocks <5M for the fragmentation % */ |
873 | - if($block['size']<(5*1024*1024)) $fragsize+=$block['size']; |
|
930 | + if($block['size']<(5*1024*1024)) { |
|
931 | + $fragsize+=$block['size']; |
|
932 | + } |
|
874 | 933 | $freetotal+=$block['size']; |
875 | 934 | } |
876 | 935 | $freeseg += count($mem['block_lists'][$i]); |
@@ -896,8 +955,11 @@ discard block |
||
896 | 955 | if(isset($mem['adist'])) { |
897 | 956 | foreach($mem['adist'] as $i=>$v) { |
898 | 957 | $cur = pow(2,$i); $nxt = pow(2,$i+1)-1; |
899 | - if($i==0) $range = "1"; |
|
900 | - else $range = "$cur - $nxt"; |
|
958 | + if($i==0) { |
|
959 | + $range = "1"; |
|
960 | + } else { |
|
961 | + $range = "$cur - $nxt"; |
|
962 | + } |
|
901 | 963 | echo "<tr><th align=right>$range</th><td align=right>$v</td></tr>\n"; |
902 | 964 | } |
903 | 965 | } |
@@ -941,8 +1003,10 @@ discard block |
||
941 | 1003 | "<option value=M",$MYREQUEST['SORT1']=='M' ? " selected":"",">Last modified</option>", |
942 | 1004 | "<option value=C",$MYREQUEST['SORT1']=='C' ? " selected":"",">Created at</option>", |
943 | 1005 | "<option value=D",$MYREQUEST['SORT1']=='D' ? " selected":"",">Deleted at</option>"; |
944 | - if($fieldname=='info') echo |
|
1006 | + if($fieldname=='info') { |
|
1007 | + echo |
|
945 | 1008 | "<option value=D",$MYREQUEST['SORT1']=='T' ? " selected":"",">Timeout</option>"; |
1009 | + } |
|
946 | 1010 | echo |
947 | 1011 | '</select>', |
948 | 1012 | '<select name=SORT2>', |
@@ -1036,10 +1100,11 @@ discard block |
||
1036 | 1100 | '<td class="td-n center">',date(DATE_FORMAT,$entry['ctime']),'</td>'; |
1037 | 1101 | |
1038 | 1102 | if($fieldname=='info') { |
1039 | - if($entry['ttl']) |
|
1040 | - echo '<td class="td-n center">'.$entry['ttl'].' seconds</td>'; |
|
1041 | - else |
|
1042 | - echo '<td class="td-n center">None</td>'; |
|
1103 | + if($entry['ttl']) { |
|
1104 | + echo '<td class="td-n center">'.$entry['ttl'].' seconds</td>'; |
|
1105 | + } else { |
|
1106 | + echo '<td class="td-n center">None</td>'; |
|
1107 | + } |
|
1043 | 1108 | } |
1044 | 1109 | if ($entry['dtime']) { |
1045 | 1110 | |
@@ -1059,8 +1124,9 @@ discard block |
||
1059 | 1124 | echo '</tr>'; |
1060 | 1125 | } |
1061 | 1126 | $i++; |
1062 | - if ($i == $MYREQUEST['COUNT']) |
|
1063 | - break; |
|
1127 | + if ($i == $MYREQUEST['COUNT']) { |
|
1128 | + break; |
|
1129 | + } |
|
1064 | 1130 | } |
1065 | 1131 | } |
1066 | 1132 |