Completed
Push — 0.x ( a2b070...a5c73d )
by Akihito
09:21
created
var/www/admin/memcache/index.php 1 patch
Braces   +43 added lines, -24 removed lines patch added patch discarded remove patch
@@ -51,8 +51,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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'],
Please login to merge, or discard this patch.
var/www/admin/apc/apc.php 2 patches
Switch Indentation   +318 added lines, -318 removed lines patch added patch discarded remove patch
@@ -329,105 +329,105 @@  discard block
 block discarded – undo
329 329
 
330 330
 	switch ($MYREQUEST['IMG']) {
331 331
 
332
-	case 1:
333
-		$s=$mem['num_seg']*$mem['seg_size'];
334
-		$a=$mem['avail_mem'];
335
-		$x=$y=$size/2;
336
-		$fuzz = 0.000001;
337
-
338
-		// This block of code creates the pie chart.  It is a lot more complex than you
339
-		// would expect because we try to visualize any memory fragmentation as well.
340
-		$angle_from = 0;
341
-		$string_placement=array();
342
-		for($i=0; $i<$mem['num_seg']; $i++) {
343
-			$ptr = 0;
344
-			$free = $mem['block_lists'][$i];
345
-			uasort($free, 'block_sort');
346
-			foreach($free as $block) {
347
-				if($block['offset']!=$ptr) {       // Used block
348
-					$angle_to = $angle_from+($block['offset']-$ptr)/$s;
349
-					if(($angle_to+$fuzz)>1) $angle_to = 1;
350
-					if( ($angle_to*360) - ($angle_from*360) >= 1) {
351
-						fill_arc($image,$x,$y,$size,$angle_from*360,$angle_to*360,$col_black,$col_red);
352
-						if (($angle_to-$angle_from)>0.05) {
353
-							array_push($string_placement, array($angle_from,$angle_to));
354
-						}
355
-					}
356
-					$angle_from = $angle_to;
357
-				}
358
-				$angle_to = $angle_from+($block['size'])/$s;
359
-				if(($angle_to+$fuzz)>1) $angle_to = 1;
360
-				if( ($angle_to*360) - ($angle_from*360) >= 1) {
361
-					fill_arc($image,$x,$y,$size,$angle_from*360,$angle_to*360,$col_black,$col_green);
362
-					if (($angle_to-$angle_from)>0.05) {
363
-						array_push($string_placement, array($angle_from,$angle_to));
364
-					}
365
-				}
366
-				$angle_from = $angle_to;
367
-				$ptr = $block['offset']+$block['size'];
368
-			}
369
-			if ($ptr < $mem['seg_size']) { // memory at the end
370
-				$angle_to = $angle_from + ($mem['seg_size'] - $ptr)/$s;
371
-				if(($angle_to+$fuzz)>1) $angle_to = 1;
372
-				fill_arc($image,$x,$y,$size,$angle_from*360,$angle_to*360,$col_black,$col_red);
373
-				if (($angle_to-$angle_from)>0.05) {
374
-					array_push($string_placement, array($angle_from,$angle_to));
375
-				}
376
-			}
377
-		}
378
-		foreach ($string_placement as $angle) {
379
-			text_arc($image,$x,$y,$size,$angle[0]*360,$angle[1]*360,$col_black,bsize($s*($angle[1]-$angle[0])));
380
-		}
381
-		break;
382
-
383
-	case 2:
384
-		$s=$cache['nhits']+$cache['nmisses'];
385
-		$a=$cache['nhits'];
386
-
387
-		fill_box($image, 30,$size,50,$s ? (-$a*($size-21)/$s) : 0,$col_black,$col_green,sprintf("%.1f%%",$s ? $cache['nhits']*100/$s : 0));
388
-		fill_box($image,130,$size,50,$s ? -max(4,($s-$a)*($size-21)/$s) : 0,$col_black,$col_red,sprintf("%.1f%%",$s ? $cache['nmisses']*100/$s : 0));
389
-		break;
390
-
391
-	case 3:
392
-		$s=$mem['num_seg']*$mem['seg_size'];
393
-		$a=$mem['avail_mem'];
394
-		$x=130;
395
-		$y=1;
396
-		$j=1;
397
-
398
-		// This block of code creates the bar chart.  It is a lot more complex than you
399
-		// would expect because we try to visualize any memory fragmentation as well.
400
-		for($i=0; $i<$mem['num_seg']; $i++) {
401
-			$ptr = 0;
402
-			$free = $mem['block_lists'][$i];
403
-			uasort($free, 'block_sort');
404
-			foreach($free as $block) {
405
-				if($block['offset']!=$ptr) {       // Used block
406
-					$h=(GRAPH_SIZE-5)*($block['offset']-$ptr)/$s;
407
-					if ($h>0) {
408
-                                                $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);
411
-                                        }
412
-					$y+=$h;
413
-				}
414
-				$h=(GRAPH_SIZE-5)*($block['size'])/$s;
415
-				if ($h>0) {
416
-                                        $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);
419
-                                }
420
-				$y+=$h;
421
-				$ptr = $block['offset']+$block['size'];
422
-			}
423
-			if ($ptr < $mem['seg_size']) { // memory at the end
424
-				$h = (GRAPH_SIZE-5) * ($mem['seg_size'] - $ptr) / $s;
425
-				if ($h > 0) {
426
-					fill_box($image,$x,$y,50,$h,$col_black,$col_red,bsize($mem['seg_size']-$ptr),$j++);
427
-				}
428
-			}
429
-		}
430
-		break;
332
+	    case 1:
333
+		    $s=$mem['num_seg']*$mem['seg_size'];
334
+		    $a=$mem['avail_mem'];
335
+		    $x=$y=$size/2;
336
+		    $fuzz = 0.000001;
337
+
338
+		    // This block of code creates the pie chart.  It is a lot more complex than you
339
+		    // would expect because we try to visualize any memory fragmentation as well.
340
+		    $angle_from = 0;
341
+		    $string_placement=array();
342
+		    for($i=0; $i<$mem['num_seg']; $i++) {
343
+			    $ptr = 0;
344
+			    $free = $mem['block_lists'][$i];
345
+			    uasort($free, 'block_sort');
346
+			    foreach($free as $block) {
347
+				    if($block['offset']!=$ptr) {       // Used block
348
+					    $angle_to = $angle_from+($block['offset']-$ptr)/$s;
349
+					    if(($angle_to+$fuzz)>1) $angle_to = 1;
350
+					    if( ($angle_to*360) - ($angle_from*360) >= 1) {
351
+						    fill_arc($image,$x,$y,$size,$angle_from*360,$angle_to*360,$col_black,$col_red);
352
+						    if (($angle_to-$angle_from)>0.05) {
353
+							    array_push($string_placement, array($angle_from,$angle_to));
354
+						    }
355
+					    }
356
+					    $angle_from = $angle_to;
357
+				    }
358
+				    $angle_to = $angle_from+($block['size'])/$s;
359
+				    if(($angle_to+$fuzz)>1) $angle_to = 1;
360
+				    if( ($angle_to*360) - ($angle_from*360) >= 1) {
361
+					    fill_arc($image,$x,$y,$size,$angle_from*360,$angle_to*360,$col_black,$col_green);
362
+					    if (($angle_to-$angle_from)>0.05) {
363
+						    array_push($string_placement, array($angle_from,$angle_to));
364
+					    }
365
+				    }
366
+				    $angle_from = $angle_to;
367
+				    $ptr = $block['offset']+$block['size'];
368
+			    }
369
+			    if ($ptr < $mem['seg_size']) { // memory at the end
370
+				    $angle_to = $angle_from + ($mem['seg_size'] - $ptr)/$s;
371
+				    if(($angle_to+$fuzz)>1) $angle_to = 1;
372
+				    fill_arc($image,$x,$y,$size,$angle_from*360,$angle_to*360,$col_black,$col_red);
373
+				    if (($angle_to-$angle_from)>0.05) {
374
+					    array_push($string_placement, array($angle_from,$angle_to));
375
+				    }
376
+			    }
377
+		    }
378
+		    foreach ($string_placement as $angle) {
379
+			    text_arc($image,$x,$y,$size,$angle[0]*360,$angle[1]*360,$col_black,bsize($s*($angle[1]-$angle[0])));
380
+		    }
381
+		    break;
382
+
383
+	    case 2:
384
+		    $s=$cache['nhits']+$cache['nmisses'];
385
+		    $a=$cache['nhits'];
386
+
387
+		    fill_box($image, 30,$size,50,$s ? (-$a*($size-21)/$s) : 0,$col_black,$col_green,sprintf("%.1f%%",$s ? $cache['nhits']*100/$s : 0));
388
+		    fill_box($image,130,$size,50,$s ? -max(4,($s-$a)*($size-21)/$s) : 0,$col_black,$col_red,sprintf("%.1f%%",$s ? $cache['nmisses']*100/$s : 0));
389
+		    break;
390
+
391
+	    case 3:
392
+		    $s=$mem['num_seg']*$mem['seg_size'];
393
+		    $a=$mem['avail_mem'];
394
+		    $x=130;
395
+		    $y=1;
396
+		    $j=1;
397
+
398
+		    // This block of code creates the bar chart.  It is a lot more complex than you
399
+		    // would expect because we try to visualize any memory fragmentation as well.
400
+		    for($i=0; $i<$mem['num_seg']; $i++) {
401
+			    $ptr = 0;
402
+			    $free = $mem['block_lists'][$i];
403
+			    uasort($free, 'block_sort');
404
+			    foreach($free as $block) {
405
+				    if($block['offset']!=$ptr) {       // Used block
406
+					    $h=(GRAPH_SIZE-5)*($block['offset']-$ptr)/$s;
407
+					    if ($h>0) {
408
+                                                    $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);
411
+                                            }
412
+					    $y+=$h;
413
+				    }
414
+				    $h=(GRAPH_SIZE-5)*($block['size'])/$s;
415
+				    if ($h>0) {
416
+                                            $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);
419
+                                    }
420
+				    $y+=$h;
421
+				    $ptr = $block['offset']+$block['size'];
422
+			    }
423
+			    if ($ptr < $mem['seg_size']) { // memory at the end
424
+				    $h = (GRAPH_SIZE-5) * ($mem['seg_size'] - $ptr) / $s;
425
+				    if ($h > 0) {
426
+					    fill_box($image,$x,$y,50,$h,$col_black,$col_red,bsize($mem['seg_size']-$ptr),$j++);
427
+				    }
428
+			    }
429
+		    }
430
+		    break;
431 431
 
432 432
 		case 4:
433 433
 			$s=$cache['nhits']+$cache['nmisses'];
@@ -754,41 +754,41 @@  discard block
 block discarded – undo
754 754
 // -----------------------------------------------
755 755
 // Host Stats
756 756
 // -----------------------------------------------
757
-case OB_HOST_STATS:
758
-	$mem_size = $mem['num_seg']*$mem['seg_size'];
759
-	$mem_avail= $mem['avail_mem'];
760
-	$mem_used = $mem_size-$mem_avail;
761
-	$seg_size = bsize($mem['seg_size']);
762
-	$req_rate_user = sprintf("%.2f", $cache['nhits'] ? (($cache['nhits']+$cache['nmisses'])/($time-$cache['stime'])) : 0);
763
-	$hit_rate_user = sprintf("%.2f", $cache['nhits'] ? (($cache['nhits'])/($time-$cache['stime'])) : 0);
764
-	$miss_rate_user = sprintf("%.2f", $cache['nmisses'] ? (($cache['nmisses'])/($time-$cache['stime'])) : 0);
765
-	$insert_rate_user = sprintf("%.2f", $cache['ninserts'] ? (($cache['ninserts'])/($time-$cache['stime'])) : 0);
766
-	$apcversion = phpversion('apcu');
767
-	$phpversion = phpversion();
768
-	$number_vars = $cache['nentries'];
769
-    $size_vars = bsize($cache['mem_size']);
770
-	$i=0;
771
-	echo <<< EOB
757
+    case OB_HOST_STATS:
758
+	    $mem_size = $mem['num_seg']*$mem['seg_size'];
759
+	    $mem_avail= $mem['avail_mem'];
760
+	    $mem_used = $mem_size-$mem_avail;
761
+	    $seg_size = bsize($mem['seg_size']);
762
+	    $req_rate_user = sprintf("%.2f", $cache['nhits'] ? (($cache['nhits']+$cache['nmisses'])/($time-$cache['stime'])) : 0);
763
+	    $hit_rate_user = sprintf("%.2f", $cache['nhits'] ? (($cache['nhits'])/($time-$cache['stime'])) : 0);
764
+	    $miss_rate_user = sprintf("%.2f", $cache['nmisses'] ? (($cache['nmisses'])/($time-$cache['stime'])) : 0);
765
+	    $insert_rate_user = sprintf("%.2f", $cache['ninserts'] ? (($cache['ninserts'])/($time-$cache['stime'])) : 0);
766
+	    $apcversion = phpversion('apcu');
767
+	    $phpversion = phpversion();
768
+	    $number_vars = $cache['nentries'];
769
+        $size_vars = bsize($cache['mem_size']);
770
+	    $i=0;
771
+	    echo <<< EOB
772 772
 		<div class="info div1"><h2>General Cache Information</h2>
773 773
 		<table cellspacing=0><tbody>
774 774
 		<tr class=tr-0><td class=td-0>APCu Version</td><td>$apcversion</td></tr>
775 775
 		<tr class=tr-1><td class=td-0>PHP Version</td><td>$phpversion</td></tr>
776
-EOB;
776
+    EOB;
777 777
 
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";
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";
782 782
 
783
-	echo <<<EOB
784
-		<tr class=tr-0><td class=td-0>Shared Memory</td><td>{$mem['num_seg']} Segment(s) with $seg_size
783
+	    echo <<<EOB
784
+    		<tr class=tr-0><td class=td-0>Shared Memory</td><td>{$mem['num_seg']} Segment(s) with $seg_size
785 785
     <br/> ({$cache['memory_type']} memory)
786 786
     </td></tr>
787 787
 EOB;
788
-	echo   '<tr class=tr-1><td class=td-0>Start Time</td><td>',date(DATE_FORMAT,$cache['stime']),'</td></tr>';
789
-	echo   '<tr class=tr-0><td class=td-0>Uptime</td><td>',duration($cache['stime']),'</td></tr>';
790
-	echo   '<tr class=tr-1><td class=td-0>File Upload Support</td><td>',$cache['file_upload_progress'],'</td></tr>';
791
-	echo <<<EOB
788
+	    echo   '<tr class=tr-1><td class=td-0>Start Time</td><td>',date(DATE_FORMAT,$cache['stime']),'</td></tr>';
789
+	    echo   '<tr class=tr-0><td class=td-0>Uptime</td><td>',duration($cache['stime']),'</td></tr>';
790
+	    echo   '<tr class=tr-1><td class=td-0>File Upload Support</td><td>',$cache['file_upload_progress'],'</td></tr>';
791
+	    echo <<<EOB
792 792
 		</tbody></table>
793 793
 		</div>
794 794
 
@@ -810,46 +810,46 @@  discard block
 block discarded – undo
810 810
 		<div class="info div2"><h2>Runtime Settings</h2><table cellspacing=0><tbody>
811 811
 EOB;
812 812
 
813
-	$j = 0;
814
-	foreach (ini_get_all('apcu') as $k => $v) {
815
-		echo "<tr class=tr-$j><td class=td-0>",$k,"</td><td>",str_replace(',',',<br />',$v['local_value']),"</td></tr>\n";
816
-		$j = 1 - $j;
817
-	}
813
+	    $j = 0;
814
+	    foreach (ini_get_all('apcu') as $k => $v) {
815
+		    echo "<tr class=tr-$j><td class=td-0>",$k,"</td><td>",str_replace(',',',<br />',$v['local_value']),"</td></tr>\n";
816
+		    $j = 1 - $j;
817
+	    }
818 818
 
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";
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";
823 823
 
824
-	echo <<< EOB
824
+	    echo <<< EOB
825 825
 		</tbody></table>
826 826
 		</div>
827 827
 
828 828
 		<div class="graph div3"><h2>Host Status Diagrams</h2>
829 829
 		<table cellspacing=0><tbody>
830 830
 EOB;
831
-	$size='width='.(GRAPH_SIZE+50).' height='.(GRAPH_SIZE+10);
832
-echo <<<EOB
831
+	    $size='width='.(GRAPH_SIZE+50).' height='.(GRAPH_SIZE+10);
832
+    echo <<<EOB
833 833
 		<tr>
834 834
 		<td class=td-0>$mem_note</td>
835 835
 		<td class=td-1>Hits &amp; Misses</td>
836 836
 		</tr>
837 837
 EOB;
838 838
 
839
-	echo
840
-		graphics_avail() ?
841
-			  '<tr>'.
842
-			  "<td class=td-0><img alt=\"\" $size src=\"$PHP_SELF?IMG=1&$time\"></td>".
843
-			  "<td class=td-1><img alt=\"\" $size src=\"$PHP_SELF?IMG=2&$time\"></td></tr>\n"
844
-			: "",
845
-		'<tr>',
846
-		'<td class=td-0><span class="green box">&nbsp;</span>Free: ',bsize($mem_avail).sprintf(" (%.1f%%)",$mem_avail*100/$mem_size),"</td>\n",
847
-		'<td class=td-1><span class="green box">&nbsp;</span>Hits: ',$cache['nhits'].@sprintf(" (%.1f%%)",$cache['nhits']*100/($cache['nhits']+$cache['nmisses'])),"</td>\n",
848
-		'</tr>',
849
-		'<tr>',
850
-		'<td class=td-0><span class="red box">&nbsp;</span>Used: ',bsize($mem_used ).sprintf(" (%.1f%%)",$mem_used *100/$mem_size),"</td>\n",
851
-		'<td class=td-1><span class="red box">&nbsp;</span>Misses: ',$cache['nmisses'].@sprintf(" (%.1f%%)",$cache['nmisses']*100/($cache['nhits']+$cache['nmisses'])),"</td>\n";
852
-	echo <<< EOB
839
+	    echo
840
+		    graphics_avail() ?
841
+			      '<tr>'.
842
+			      "<td class=td-0><img alt=\"\" $size src=\"$PHP_SELF?IMG=1&$time\"></td>".
843
+			      "<td class=td-1><img alt=\"\" $size src=\"$PHP_SELF?IMG=2&$time\"></td></tr>\n"
844
+			    : "",
845
+		    '<tr>',
846
+		    '<td class=td-0><span class="green box">&nbsp;</span>Free: ',bsize($mem_avail).sprintf(" (%.1f%%)",$mem_avail*100/$mem_size),"</td>\n",
847
+		    '<td class=td-1><span class="green box">&nbsp;</span>Hits: ',$cache['nhits'].@sprintf(" (%.1f%%)",$cache['nhits']*100/($cache['nhits']+$cache['nmisses'])),"</td>\n",
848
+		    '</tr>',
849
+		    '<tr>',
850
+		    '<td class=td-0><span class="red box">&nbsp;</span>Used: ',bsize($mem_used ).sprintf(" (%.1f%%)",$mem_used *100/$mem_size),"</td>\n",
851
+		    '<td class=td-1><span class="red box">&nbsp;</span>Misses: ',$cache['nmisses'].@sprintf(" (%.1f%%)",$cache['nmisses']*100/($cache['nhits']+$cache['nmisses'])),"</td>\n";
852
+	    echo <<< EOB
853 853
 		</tr>
854 854
 		</tbody></table>
855 855
 
@@ -860,141 +860,141 @@  discard block
 block discarded – undo
860 860
 		<td class=td-0 colspan=2><br/>
861 861
 EOB;
862 862
 
863
-	// Fragementation: (freeseg - 1) / total_seg
864
-	$nseg = $freeseg = $fragsize = $freetotal = 0;
865
-	for($i=0; $i<$mem['num_seg']; $i++) {
866
-		$ptr = 0;
867
-		foreach($mem['block_lists'][$i] as $block) {
868
-			if ($block['offset'] != $ptr) {
869
-				++$nseg;
870
-			}
871
-			$ptr = $block['offset'] + $block['size'];
872
-                        /* Only consider blocks <5M for the fragmentation % */
873
-                        if($block['size']<(5*1024*1024)) $fragsize+=$block['size'];
874
-                        $freetotal+=$block['size'];
875
-		}
876
-		$freeseg += count($mem['block_lists'][$i]);
877
-	}
878
-
879
-	if ($freeseg > 1) {
880
-		$frag = sprintf("%.2f%% (%s out of %s in %d fragments)", ($fragsize/$freetotal)*100,bsize($fragsize),bsize($freetotal),$freeseg);
881
-	} else {
882
-		$frag = "0%";
883
-	}
884
-
885
-	if (graphics_avail()) {
886
-		$size='width='.(2*GRAPH_SIZE+150).' height='.(GRAPH_SIZE+10);
887
-		echo <<<EOB
888
-			<img alt="" $size src="$PHP_SELF?IMG=3&$time">
889
-EOB;
890
-	}
891
-	echo <<<EOB
892
-		</br>Fragmentation: $frag
863
+	    // Fragementation: (freeseg - 1) / total_seg
864
+	    $nseg = $freeseg = $fragsize = $freetotal = 0;
865
+	    for($i=0; $i<$mem['num_seg']; $i++) {
866
+		    $ptr = 0;
867
+		    foreach($mem['block_lists'][$i] as $block) {
868
+			    if ($block['offset'] != $ptr) {
869
+				    ++$nseg;
870
+			    }
871
+			    $ptr = $block['offset'] + $block['size'];
872
+                            /* Only consider blocks <5M for the fragmentation % */
873
+                            if($block['size']<(5*1024*1024)) $fragsize+=$block['size'];
874
+                            $freetotal+=$block['size'];
875
+		    }
876
+		    $freeseg += count($mem['block_lists'][$i]);
877
+	    }
878
+
879
+	    if ($freeseg > 1) {
880
+		    $frag = sprintf("%.2f%% (%s out of %s in %d fragments)", ($fragsize/$freetotal)*100,bsize($fragsize),bsize($freetotal),$freeseg);
881
+	    } else {
882
+		    $frag = "0%";
883
+	    }
884
+
885
+	    if (graphics_avail()) {
886
+		    $size='width='.(2*GRAPH_SIZE+150).' height='.(GRAPH_SIZE+10);
887
+		    echo <<<EOB
888
+    			<img alt="" $size src="$PHP_SELF?IMG=3&$time">
889
+    EOB;
890
+	    }
891
+	    echo <<<EOB
892
+    		</br>Fragmentation: $frag
893 893
 		</td>
894 894
 		</tr>
895 895
 EOB;
896
-        if(isset($mem['adist'])) {
897
-          foreach($mem['adist'] as $i=>$v) {
898
-            $cur = pow(2,$i); $nxt = pow(2,$i+1)-1;
899
-            if($i==0) $range = "1";
900
-            else $range = "$cur - $nxt";
901
-            echo "<tr><th align=right>$range</th><td align=right>$v</td></tr>\n";
902
-          }
903
-        }
904
-        echo <<<EOB
896
+            if(isset($mem['adist'])) {
897
+              foreach($mem['adist'] as $i=>$v) {
898
+                $cur = pow(2,$i); $nxt = pow(2,$i+1)-1;
899
+                if($i==0) $range = "1";
900
+                else $range = "$cur - $nxt";
901
+                echo "<tr><th align=right>$range</th><td align=right>$v</td></tr>\n";
902
+              }
903
+            }
904
+            echo <<<EOB
905 905
 		</tbody></table>
906 906
 		</div>
907 907
 EOB;
908 908
 
909
-	break;
910
-
911
-
912
-// -----------------------------------------------
913
-// User Cache Entries
914
-// -----------------------------------------------
915
-case OB_USER_CACHE:
916
-	if (!$AUTHENTICATED) {
917
-    echo '<div class="error">You need to login to see the user values here!<br/>&nbsp;<br/>';
918
-		put_login_link("Login now!");
919
-		echo '</div>';
920
-		break;
921
-	}
922
-	$fieldname='key';
923
-	$fieldheading='User Entry Label';
924
-	$fieldkey='key';
925
-
926
-	$cols=6;
927
-	echo <<<EOB
909
+	    break;
910
+
911
+
912
+    // -----------------------------------------------
913
+    // User Cache Entries
914
+    // -----------------------------------------------
915
+    case OB_USER_CACHE:
916
+	    if (!$AUTHENTICATED) {
917
+        echo '<div class="error">You need to login to see the user values here!<br/>&nbsp;<br/>';
918
+		    put_login_link("Login now!");
919
+		    echo '</div>';
920
+		    break;
921
+	    }
922
+	    $fieldname='key';
923
+	    $fieldheading='User Entry Label';
924
+	    $fieldkey='key';
925
+
926
+	    $cols=6;
927
+	    echo <<<EOB
928 928
 		<div class=sorting><form>Scope:
929 929
 		<input type=hidden name=OB value={$MYREQUEST['OB']}>
930 930
 		<select name=SCOPE>
931 931
 EOB;
932
-	echo
933
-		"<option value=A",$MYREQUEST['SCOPE']=='A' ? " selected":"",">Active</option>",
934
-		"<option value=D",$MYREQUEST['SCOPE']=='D' ? " selected":"",">Deleted</option>",
935
-		"</select>",
936
-		", Sorting:<select name=SORT1>",
937
-		"<option value=H",$MYREQUEST['SORT1']=='H' ? " selected":"",">Hits</option>",
938
-		"<option value=Z",$MYREQUEST['SORT1']=='Z' ? " selected":"",">Size</option>",
939
-		"<option value=S",$MYREQUEST['SORT1']=='S' ? " selected":"",">$fieldheading</option>",
940
-		"<option value=A",$MYREQUEST['SORT1']=='A' ? " selected":"",">Last accessed</option>",
941
-		"<option value=M",$MYREQUEST['SORT1']=='M' ? " selected":"",">Last modified</option>",
942
-		"<option value=C",$MYREQUEST['SORT1']=='C' ? " selected":"",">Created at</option>",
943
-		"<option value=D",$MYREQUEST['SORT1']=='D' ? " selected":"",">Deleted at</option>";
944
-	if($fieldname=='info') echo
945
-		"<option value=D",$MYREQUEST['SORT1']=='T' ? " selected":"",">Timeout</option>";
946
-	echo
947
-		'</select>',
948
-		'<select name=SORT2>',
949
-		'<option value=D',$MYREQUEST['SORT2']=='D' ? ' selected':'','>DESC</option>',
950
-		'<option value=A',$MYREQUEST['SORT2']=='A' ? ' selected':'','>ASC</option>',
951
-		'</select>',
952
-		'<select name=COUNT onChange="form.submit()">',
953
-		'<option value=10 ',$MYREQUEST['COUNT']=='10' ? ' selected':'','>Top 10</option>',
954
-		'<option value=20 ',$MYREQUEST['COUNT']=='20' ? ' selected':'','>Top 20</option>',
955
-		'<option value=50 ',$MYREQUEST['COUNT']=='50' ? ' selected':'','>Top 50</option>',
956
-		'<option value=100',$MYREQUEST['COUNT']=='100'? ' selected':'','>Top 100</option>',
957
-		'<option value=150',$MYREQUEST['COUNT']=='150'? ' selected':'','>Top 150</option>',
958
-		'<option value=200',$MYREQUEST['COUNT']=='200'? ' selected':'','>Top 200</option>',
959
-		'<option value=500',$MYREQUEST['COUNT']=='500'? ' selected':'','>Top 500</option>',
960
-		'<option value=0  ',$MYREQUEST['COUNT']=='0'  ? ' selected':'','>All</option>',
961
-		'</select>',
962
-    '&nbsp; Search: <input name=SEARCH value="',$MYREQUEST['SEARCH'],'" type=text size=25/>',
963
-		'&nbsp;<input type=submit value="GO!">',
964
-		'</form></div>';
965
-
966
-  if (isset($MYREQUEST['SEARCH'])) {
967
-   // Don't use preg_quote because we want the user to be able to specify a
968
-   // regular expression subpattern.
969
-   $MYREQUEST['SEARCH'] = '/'.str_replace('/', '\\/', $MYREQUEST['SEARCH']).'/i';
970
-   if (preg_match($MYREQUEST['SEARCH'], 'test') === false) {
971
-     echo '<div class="error">Error: enter a valid regular expression as a search query.</div>';
972
-     break;
973
-   }
974
-  }
975
-
976
-  echo
977
-		'<div class="info"><table cellspacing=0><tbody>',
978
-		'<tr>',
979
-		'<th>',sortheader('S',$fieldheading,  "&OB=".$MYREQUEST['OB']),'</th>',
980
-		'<th>',sortheader('H','Hits',         "&OB=".$MYREQUEST['OB']),'</th>',
981
-		'<th>',sortheader('Z','Size',         "&OB=".$MYREQUEST['OB']),'</th>',
982
-		'<th>',sortheader('A','Last accessed',"&OB=".$MYREQUEST['OB']),'</th>',
983
-		'<th>',sortheader('M','Last modified',"&OB=".$MYREQUEST['OB']),'</th>',
984
-		'<th>',sortheader('C','Created at',   "&OB=".$MYREQUEST['OB']),'</th>';
985
-
986
-	if($fieldname=='info') {
987
-		$cols+=2;
988
-		 echo '<th>',sortheader('T','Timeout',"&OB=".$MYREQUEST['OB']),'</th>';
989
-	}
990
-	echo '<th>',sortheader('D','Deleted at',"&OB=".$MYREQUEST['OB']),'</th></tr>';
991
-
992
-	// builds list with alpha numeric sortable keys
993
-	//
994
-	$list = array();
932
+	    echo
933
+		    "<option value=A",$MYREQUEST['SCOPE']=='A' ? " selected":"",">Active</option>",
934
+		    "<option value=D",$MYREQUEST['SCOPE']=='D' ? " selected":"",">Deleted</option>",
935
+		    "</select>",
936
+		    ", Sorting:<select name=SORT1>",
937
+		    "<option value=H",$MYREQUEST['SORT1']=='H' ? " selected":"",">Hits</option>",
938
+		    "<option value=Z",$MYREQUEST['SORT1']=='Z' ? " selected":"",">Size</option>",
939
+		    "<option value=S",$MYREQUEST['SORT1']=='S' ? " selected":"",">$fieldheading</option>",
940
+		    "<option value=A",$MYREQUEST['SORT1']=='A' ? " selected":"",">Last accessed</option>",
941
+		    "<option value=M",$MYREQUEST['SORT1']=='M' ? " selected":"",">Last modified</option>",
942
+		    "<option value=C",$MYREQUEST['SORT1']=='C' ? " selected":"",">Created at</option>",
943
+		    "<option value=D",$MYREQUEST['SORT1']=='D' ? " selected":"",">Deleted at</option>";
944
+	    if($fieldname=='info') echo
945
+		    "<option value=D",$MYREQUEST['SORT1']=='T' ? " selected":"",">Timeout</option>";
946
+	    echo
947
+		    '</select>',
948
+		    '<select name=SORT2>',
949
+		    '<option value=D',$MYREQUEST['SORT2']=='D' ? ' selected':'','>DESC</option>',
950
+		    '<option value=A',$MYREQUEST['SORT2']=='A' ? ' selected':'','>ASC</option>',
951
+		    '</select>',
952
+		    '<select name=COUNT onChange="form.submit()">',
953
+		    '<option value=10 ',$MYREQUEST['COUNT']=='10' ? ' selected':'','>Top 10</option>',
954
+		    '<option value=20 ',$MYREQUEST['COUNT']=='20' ? ' selected':'','>Top 20</option>',
955
+		    '<option value=50 ',$MYREQUEST['COUNT']=='50' ? ' selected':'','>Top 50</option>',
956
+		    '<option value=100',$MYREQUEST['COUNT']=='100'? ' selected':'','>Top 100</option>',
957
+		    '<option value=150',$MYREQUEST['COUNT']=='150'? ' selected':'','>Top 150</option>',
958
+		    '<option value=200',$MYREQUEST['COUNT']=='200'? ' selected':'','>Top 200</option>',
959
+		    '<option value=500',$MYREQUEST['COUNT']=='500'? ' selected':'','>Top 500</option>',
960
+		    '<option value=0  ',$MYREQUEST['COUNT']=='0'  ? ' selected':'','>All</option>',
961
+		    '</select>',
962
+        '&nbsp; Search: <input name=SEARCH value="',$MYREQUEST['SEARCH'],'" type=text size=25/>',
963
+		    '&nbsp;<input type=submit value="GO!">',
964
+		    '</form></div>';
965
+
966
+      if (isset($MYREQUEST['SEARCH'])) {
967
+       // Don't use preg_quote because we want the user to be able to specify a
968
+       // regular expression subpattern.
969
+       $MYREQUEST['SEARCH'] = '/'.str_replace('/', '\\/', $MYREQUEST['SEARCH']).'/i';
970
+       if (preg_match($MYREQUEST['SEARCH'], 'test') === false) {
971
+         echo '<div class="error">Error: enter a valid regular expression as a search query.</div>';
972
+         break;
973
+       }
974
+      }
995 975
 
996
-	foreach($cache[$scope_list[$MYREQUEST['SCOPE']]] as $i => $entry) {
997
-		switch($MYREQUEST['SORT1']) {
976
+      echo
977
+		    '<div class="info"><table cellspacing=0><tbody>',
978
+		    '<tr>',
979
+		    '<th>',sortheader('S',$fieldheading,  "&OB=".$MYREQUEST['OB']),'</th>',
980
+		    '<th>',sortheader('H','Hits',         "&OB=".$MYREQUEST['OB']),'</th>',
981
+		    '<th>',sortheader('Z','Size',         "&OB=".$MYREQUEST['OB']),'</th>',
982
+		    '<th>',sortheader('A','Last accessed',"&OB=".$MYREQUEST['OB']),'</th>',
983
+		    '<th>',sortheader('M','Last modified',"&OB=".$MYREQUEST['OB']),'</th>',
984
+		    '<th>',sortheader('C','Created at',   "&OB=".$MYREQUEST['OB']),'</th>';
985
+
986
+	    if($fieldname=='info') {
987
+		    $cols+=2;
988
+		     echo '<th>',sortheader('T','Timeout',"&OB=".$MYREQUEST['OB']),'</th>';
989
+	    }
990
+	    echo '<th>',sortheader('D','Deleted at',"&OB=".$MYREQUEST['OB']),'</th></tr>';
991
+
992
+	    // builds list with alpha numeric sortable keys
993
+	    //
994
+	    $list = array();
995
+
996
+	    foreach($cache[$scope_list[$MYREQUEST['SCOPE']]] as $i => $entry) {
997
+		    switch($MYREQUEST['SORT1']) {
998 998
 			case 'A': $k=sprintf('%015d-',$entry['atime']);  	    break;
999 999
 			case 'H': $k=sprintf('%015d-',$entry['nhits']); 		break;
1000 1000
 			case 'Z': $k=sprintf('%015d-',$entry['mem_size']); 		break;
@@ -1003,7 +1003,7 @@  discard block
 block discarded – undo
1003 1003
 			case 'T': $k=sprintf('%015d-',$entry['ttl']);			break;
1004 1004
 			case 'D': $k=sprintf('%015d-',$entry['dtime']);      	break;
1005 1005
 			case 'S': $k=$entry["key"];								break;
1006
-		}
1006
+		    }
1007 1007
 		if (!$AUTHENTICATED) {
1008 1008
 			// hide all path entries if not logged in
1009 1009
 			$list[$k.$entry[$fieldname]]=preg_replace('/^.*(\\/|\\\\)/','*hidden*/',$entry);
@@ -1083,61 +1083,61 @@  discard block
 block discarded – undo
1083 1083
 // -----------------------------------------------
1084 1084
 // Version check
1085 1085
 // -----------------------------------------------
1086
-case OB_VERSION_CHECK:
1087
-	echo <<<EOB
1086
+    case OB_VERSION_CHECK:
1087
+	    echo <<<EOB
1088 1088
 		<div class="info"><h2>APCu Version Information</h2>
1089 1089
 		<table cellspacing=0><tbody>
1090 1090
 		<tr>
1091 1091
 		<th></th>
1092 1092
 		</tr>
1093 1093
 EOB;
1094
-  if (defined('PROXY')) {
1095
-    $ctxt = stream_context_create( array( 'http' => array( 'proxy' => PROXY, 'request_fulluri' => True ) ) );
1096
-    $rss = @file_get_contents("http://pecl.php.net/feeds/pkg_apcu.rss", False, $ctxt);
1097
-  } else {
1098
-    $rss = @file_get_contents("http://pecl.php.net/feeds/pkg_apcu.rss");
1099
-  }
1100
-	if (!$rss) {
1101
-		echo '<tr class="td-last center"><td>Unable to fetch version information.</td></tr>';
1102
-	} else {
1103
-		$apcversion = phpversion('apc');
1104
-
1105
-		preg_match('!<title>APCu ([0-9.]+)</title>!', $rss, $match);
1106
-		echo '<tr class="tr-0 center"><td>';
1107
-		if (version_compare($apcversion, $match[1], '>=')) {
1108
-			echo '<div class="ok">You are running the latest version of APCu ('.$apcversion.')</div>';
1109
-			$i = 3;
1110
-		} else {
1111
-			echo '<div class="failed">You are running an older version of APCu ('.$apcversion.'),
1094
+      if (defined('PROXY')) {
1095
+        $ctxt = stream_context_create( array( 'http' => array( 'proxy' => PROXY, 'request_fulluri' => True ) ) );
1096
+        $rss = @file_get_contents("http://pecl.php.net/feeds/pkg_apcu.rss", False, $ctxt);
1097
+      } else {
1098
+        $rss = @file_get_contents("http://pecl.php.net/feeds/pkg_apcu.rss");
1099
+      }
1100
+	    if (!$rss) {
1101
+		    echo '<tr class="td-last center"><td>Unable to fetch version information.</td></tr>';
1102
+	    } else {
1103
+		    $apcversion = phpversion('apc');
1104
+
1105
+		    preg_match('!<title>APCu ([0-9.]+)</title>!', $rss, $match);
1106
+		    echo '<tr class="tr-0 center"><td>';
1107
+		    if (version_compare($apcversion, $match[1], '>=')) {
1108
+			    echo '<div class="ok">You are running the latest version of APCu ('.$apcversion.')</div>';
1109
+			    $i = 3;
1110
+		    } else {
1111
+			    echo '<div class="failed">You are running an older version of APCu ('.$apcversion.'),
1112 1112
 				newer version '.$match[1].' is available at <a href="http://pecl.php.net/package/APCu/'.$match[1].'">
1113 1113
 				http://pecl.php.net/package/APCu/'.$match[1].'</a>
1114 1114
 				</div>';
1115
-			$i = -1;
1116
-		}
1117
-		echo '</td></tr>';
1118
-		echo '<tr class="tr-0"><td><h3>Change Log:</h3><br/>';
1119
-
1120
-		preg_match_all('!<(title|description)>([^<]+)</\\1>!', $rss, $match);
1121
-		next($match[2]); next($match[2]);
1122
-
1123
-		while (list(,$v) = each($match[2])) {
1124
-			list(,$ver) = explode(' ', $v, 2);
1125
-			if ($i < 0 && version_compare($apcversion, $ver, '>=')) {
1126
-				break;
1127
-			} else if (!$i--) {
1128
-				break;
1129
-			}
1130
-			echo "<b><a href=\"http://pecl.php.net/package/APCu/$ver\">".htmlspecialchars($v, ENT_QUOTES, 'UTF-8')."</a></b><br><blockquote>";
1131
-			echo nl2br(htmlspecialchars(current($match[2]), ENT_QUOTES, 'UTF-8'))."</blockquote>";
1132
-			next($match[2]);
1133
-		}
1134
-		echo '</td></tr>';
1135
-	}
1136
-	echo <<< EOB
1115
+			    $i = -1;
1116
+		    }
1117
+		    echo '</td></tr>';
1118
+		    echo '<tr class="tr-0"><td><h3>Change Log:</h3><br/>';
1119
+
1120
+		    preg_match_all('!<(title|description)>([^<]+)</\\1>!', $rss, $match);
1121
+		    next($match[2]); next($match[2]);
1122
+
1123
+		    while (list(,$v) = each($match[2])) {
1124
+			    list(,$ver) = explode(' ', $v, 2);
1125
+			    if ($i < 0 && version_compare($apcversion, $ver, '>=')) {
1126
+				    break;
1127
+			    } else if (!$i--) {
1128
+				    break;
1129
+			    }
1130
+			    echo "<b><a href=\"http://pecl.php.net/package/APCu/$ver\">".htmlspecialchars($v, ENT_QUOTES, 'UTF-8')."</a></b><br><blockquote>";
1131
+			    echo nl2br(htmlspecialchars(current($match[2]), ENT_QUOTES, 'UTF-8'))."</blockquote>";
1132
+			    next($match[2]);
1133
+		    }
1134
+		    echo '</td></tr>';
1135
+	    }
1136
+	    echo <<< EOB
1137 1137
 		</tbody></table>
1138 1138
 		</div>
1139 1139
 EOB;
1140
-	break;
1140
+	    break;
1141 1141
 
1142 1142
 }
1143 1143
 
Please login to merge, or discard this patch.
Braces   +116 added lines, -50 removed lines patch added patch discarded remove patch
@@ -31,7 +31,9 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.