Completed
Push — 0.x ( a2b070...a5c73d )
by Akihito
09:21
created
var/www/admin/memcache/index.php 1 patch
Indentation   +335 added lines, -335 removed lines patch added patch discarded remove patch
@@ -48,73 +48,73 @@  discard block
 block discarded – undo
48 48
 ///////////MEMCACHE FUNCTIONS /////////////////////////////////////////////////////////////////////
49 49
 
50 50
 function get_host_port_from_server($server){
51
-	$values = explode(':', $server);
52
-	if (($values[0] == 'unix') && (!is_numeric( $values[1]))) {
53
-		return array($server, 0);
54
-	}
55
-	else {
56
-		return $values;
57
-	}
51
+    $values = explode(':', $server);
52
+    if (($values[0] == 'unix') && (!is_numeric( $values[1]))) {
53
+        return array($server, 0);
54
+    }
55
+    else {
56
+        return $values;
57
+    }
58 58
 }
59 59
 
60 60
 function sendMemcacheCommands($command){
61 61
     global $MEMCACHE_SERVERS;
62
-	$result = array();
62
+    $result = array();
63 63
 
64
-	foreach($MEMCACHE_SERVERS as $server){
65
-		$strs = get_host_port_from_server($server);
66
-		$host = $strs[0];
67
-		$port = $strs[1];
68
-		$result[$server] = sendMemcacheCommand($host,$port,$command);
69
-	}
70
-	return $result;
64
+    foreach($MEMCACHE_SERVERS as $server){
65
+        $strs = get_host_port_from_server($server);
66
+        $host = $strs[0];
67
+        $port = $strs[1];
68
+        $result[$server] = sendMemcacheCommand($host,$port,$command);
69
+    }
70
+    return $result;
71 71
 }
72 72
 function sendMemcacheCommand($server,$port,$command){
73 73
 
74
-	$s = @fsockopen($server,$port);
75
-	if (!$s){
76
-		die("Cant connect to:".$server.':'.$port);
77
-	}
74
+    $s = @fsockopen($server,$port);
75
+    if (!$s){
76
+        die("Cant connect to:".$server.':'.$port);
77
+    }
78 78
 
79
-	fwrite($s, $command."\r\n");
80
-
81
-	$buf='';
82
-	while ((!feof($s))) {
83
-		$buf .= fgets($s, 256);
84
-		if (strpos($buf,"END\r\n")!==false){ // stat says end
85
-		    break;
86
-		}
87
-		if (strpos($buf,"DELETED\r\n")!==false || strpos($buf,"NOT_FOUND\r\n")!==false){ // delete says these
88
-		    break;
89
-		}
90
-		if (strpos($buf,"OK\r\n")!==false){ // flush_all says ok
91
-		    break;
92
-		}
93
-	}
79
+    fwrite($s, $command."\r\n");
80
+
81
+    $buf='';
82
+    while ((!feof($s))) {
83
+        $buf .= fgets($s, 256);
84
+        if (strpos($buf,"END\r\n")!==false){ // stat says end
85
+            break;
86
+        }
87
+        if (strpos($buf,"DELETED\r\n")!==false || strpos($buf,"NOT_FOUND\r\n")!==false){ // delete says these
88
+            break;
89
+        }
90
+        if (strpos($buf,"OK\r\n")!==false){ // flush_all says ok
91
+            break;
92
+        }
93
+    }
94 94
     fclose($s);
95 95
     return parseMemcacheResults($buf);
96 96
 }
97 97
 function parseMemcacheResults($str){
98 98
     
99
-	$res = array();
100
-	$lines = explode("\r\n",$str);
101
-	$cnt = count($lines);
102
-	for($i=0; $i< $cnt; $i++){
103
-	    $line = $lines[$i];
104
-		$l = explode(' ',$line,3);
105
-		if (count($l)==3){
106
-			$res[$l[0]][$l[1]]=$l[2];
107
-			if ($l[0]=='VALUE'){ // next line is the value
108
-			    $res[$l[0]][$l[1]] = array();
109
-			    list ($flag,$size)=explode(' ',$l[2]);
110
-			    $res[$l[0]][$l[1]]['stat']=array('flag'=>$flag,'size'=>$size);
111
-			    $res[$l[0]][$l[1]]['value']=$lines[++$i];
112
-			}
113
-		}elseif($line=='DELETED' || $line=='NOT_FOUND' || $line=='OK'){
114
-		    return $line;
115
-		}
116
-	}
117
-	return $res;
99
+    $res = array();
100
+    $lines = explode("\r\n",$str);
101
+    $cnt = count($lines);
102
+    for($i=0; $i< $cnt; $i++){
103
+        $line = $lines[$i];
104
+        $l = explode(' ',$line,3);
105
+        if (count($l)==3){
106
+            $res[$l[0]][$l[1]]=$l[2];
107
+            if ($l[0]=='VALUE'){ // next line is the value
108
+                $res[$l[0]][$l[1]] = array();
109
+                list ($flag,$size)=explode(' ',$l[2]);
110
+                $res[$l[0]][$l[1]]['stat']=array('flag'=>$flag,'size'=>$size);
111
+                $res[$l[0]][$l[1]]['value']=$lines[++$i];
112
+            }
113
+        }elseif($line=='DELETED' || $line=='NOT_FOUND' || $line=='OK'){
114
+            return $line;
115
+        }
116
+    }
117
+    return $res;
118 118
 
119 119
 }
120 120
 
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
     list($host,$port) = get_host_port_from_server($server);
123 123
     $resp = sendMemcacheCommand($host,$port,'stats cachedump '.$slabId.' '.$limit);
124 124
 
125
-   return $resp;
125
+    return $resp;
126 126
 
127 127
 }
128 128
 
@@ -132,10 +132,10 @@  discard block
 block discarded – undo
132 132
     return $resp;
133 133
 }
134 134
 function getCacheItems(){
135
- $items = sendMemcacheCommands('stats items');
136
- $serverItems = array();
137
- $totalItems = array();
138
- foreach ($items as $server=>$itemlist){
135
+    $items = sendMemcacheCommands('stats items');
136
+    $serverItems = array();
137
+    $totalItems = array();
138
+    foreach ($items as $server=>$itemlist){
139 139
     $serverItems[$server] = array();
140 140
     $totalItems[$server]=0;
141 141
     if (!isset($itemlist['STAT'])){
@@ -152,91 +152,91 @@  discard block
 block discarded – undo
152 152
             }
153 153
         }
154 154
     }
155
- }
156
- return array('items'=>$serverItems,'counts'=>$totalItems);
155
+    }
156
+    return array('items'=>$serverItems,'counts'=>$totalItems);
157 157
 }
158 158
 function getMemcacheStats($total=true){
159
-	$resp = sendMemcacheCommands('stats');
160
-	if ($total){
161
-		$res = array();
162
-		foreach($resp as $server=>$r){
163
-			foreach($r['STAT'] as $key=>$row){
164
-				if (!isset($res[$key])){
165
-					$res[$key]=null;
166
-				}
167
-				switch ($key){
168
-					case 'pid':
169
-						$res['pid'][$server]=$row;
170
-						break;
171
-					case 'uptime':
172
-						$res['uptime'][$server]=$row;
173
-						break;
174
-					case 'time':
175
-						$res['time'][$server]=$row;
176
-						break;
177
-					case 'version':
178
-						$res['version'][$server]=$row;
179
-						break;
180
-					case 'pointer_size':
181
-						$res['pointer_size'][$server]=$row;
182
-						break;
183
-					case 'rusage_user':
184
-						$res['rusage_user'][$server]=$row;
185
-						break;
186
-					case 'rusage_system':
187
-						$res['rusage_system'][$server]=$row;
188
-						break;
189
-					case 'curr_items':
190
-						$res['curr_items']+=$row;
191
-						break;
192
-					case 'total_items':
193
-						$res['total_items']+=$row;
194
-						break;
195
-					case 'bytes':
196
-						$res['bytes']+=$row;
197
-						break;
198
-					case 'curr_connections':
199
-						$res['curr_connections']+=$row;
200
-						break;
201
-					case 'total_connections':
202
-						$res['total_connections']+=$row;
203
-						break;
204
-					case 'connection_structures':
205
-						$res['connection_structures']+=$row;
206
-						break;
207
-					case 'cmd_get':
208
-						$res['cmd_get']+=$row;
209
-						break;
210
-					case 'cmd_set':
211
-						$res['cmd_set']+=$row;
212
-						break;
213
-					case 'get_hits':
214
-						$res['get_hits']+=$row;
215
-						break;
216
-					case 'get_misses':
217
-						$res['get_misses']+=$row;
218
-						break;
219
-					case 'evictions':
220
-						$res['evictions']+=$row;
221
-						break;
222
-					case 'bytes_read':
223
-						$res['bytes_read']+=$row;
224
-						break;
225
-					case 'bytes_written':
226
-						$res['bytes_written']+=$row;
227
-						break;
228
-					case 'limit_maxbytes':
229
-						$res['limit_maxbytes']+=$row;
230
-						break;
231
-					case 'threads':
232
-						$res['rusage_system'][$server]=$row;
233
-						break;
234
-				}
235
-			}
236
-		}
237
-		return $res;
238
-	}
239
-	return $resp;
159
+    $resp = sendMemcacheCommands('stats');
160
+    if ($total){
161
+        $res = array();
162
+        foreach($resp as $server=>$r){
163
+            foreach($r['STAT'] as $key=>$row){
164
+                if (!isset($res[$key])){
165
+                    $res[$key]=null;
166
+                }
167
+                switch ($key){
168
+                    case 'pid':
169
+                        $res['pid'][$server]=$row;
170
+                        break;
171
+                    case 'uptime':
172
+                        $res['uptime'][$server]=$row;
173
+                        break;
174
+                    case 'time':
175
+                        $res['time'][$server]=$row;
176
+                        break;
177
+                    case 'version':
178
+                        $res['version'][$server]=$row;
179
+                        break;
180
+                    case 'pointer_size':
181
+                        $res['pointer_size'][$server]=$row;
182
+                        break;
183
+                    case 'rusage_user':
184
+                        $res['rusage_user'][$server]=$row;
185
+                        break;
186
+                    case 'rusage_system':
187
+                        $res['rusage_system'][$server]=$row;
188
+                        break;
189
+                    case 'curr_items':
190
+                        $res['curr_items']+=$row;
191
+                        break;
192
+                    case 'total_items':
193
+                        $res['total_items']+=$row;
194
+                        break;
195
+                    case 'bytes':
196
+                        $res['bytes']+=$row;
197
+                        break;
198
+                    case 'curr_connections':
199
+                        $res['curr_connections']+=$row;
200
+                        break;
201
+                    case 'total_connections':
202
+                        $res['total_connections']+=$row;
203
+                        break;
204
+                    case 'connection_structures':
205
+                        $res['connection_structures']+=$row;
206
+                        break;
207
+                    case 'cmd_get':
208
+                        $res['cmd_get']+=$row;
209
+                        break;
210
+                    case 'cmd_set':
211
+                        $res['cmd_set']+=$row;
212
+                        break;
213
+                    case 'get_hits':
214
+                        $res['get_hits']+=$row;
215
+                        break;
216
+                    case 'get_misses':
217
+                        $res['get_misses']+=$row;
218
+                        break;
219
+                    case 'evictions':
220
+                        $res['evictions']+=$row;
221
+                        break;
222
+                    case 'bytes_read':
223
+                        $res['bytes_read']+=$row;
224
+                        break;
225
+                    case 'bytes_written':
226
+                        $res['bytes_written']+=$row;
227
+                        break;
228
+                    case 'limit_maxbytes':
229
+                        $res['limit_maxbytes']+=$row;
230
+                        break;
231
+                    case 'threads':
232
+                        $res['rusage_system'][$server]=$row;
233
+                        break;
234
+                }
235
+            }
236
+        }
237
+        return $res;
238
+    }
239
+    return $resp;
240 240
 }
241 241
 
242 242
 //////////////////////////////////////////////////////
@@ -273,24 +273,24 @@  discard block
 block discarded – undo
273 273
 // create graphics
274 274
 //
275 275
 function graphics_avail() {
276
-	return extension_loaded('gd');
276
+    return extension_loaded('gd');
277 277
 }
278 278
 
279 279
 function bsize($s) {
280
-	foreach (array('','K','M','G') as $i => $k) {
281
-		if ($s < 1024) break;
282
-		$s/=1024;
283
-	}
284
-	return sprintf("%5.1f %sBytes",$s,$k);
280
+    foreach (array('','K','M','G') as $i => $k) {
281
+        if ($s < 1024) break;
282
+        $s/=1024;
283
+    }
284
+    return sprintf("%5.1f %sBytes",$s,$k);
285 285
 }
286 286
 
287 287
 // create menu entry
288 288
 function menu_entry($ob,$title) {
289
-	global $PHP_SELF;
290
-	if ($ob==$_GET['op']){
291
-	    return "<li><a class=\"child_active\" href=\"$PHP_SELF&op=$ob\">$title</a></li>";
292
-	}
293
-	return "<li><a class=\"active\" href=\"$PHP_SELF&op=$ob\">$title</a></li>";
289
+    global $PHP_SELF;
290
+    if ($ob==$_GET['op']){
291
+        return "<li><a class=\"child_active\" href=\"$PHP_SELF&op=$ob\">$title</a></li>";
292
+    }
293
+    return "<li><a class=\"active\" href=\"$PHP_SELF&op=$ob\">$title</a></li>";
294 294
 }
295 295
 
296 296
 function getHeader(){
@@ -513,8 +513,8 @@  discard block
 block discarded – undo
513 513
 EOB;
514 514
 }
515 515
 echo
516
-	menu_entry(1,'View Host Stats'),
517
-	menu_entry(2,'Variables');
516
+    menu_entry(1,'View Host Stats'),
517
+    menu_entry(2,'Variables');
518 518
 
519 519
 echo <<<EOB
520 520
 	</ol>
@@ -548,115 +548,115 @@  discard block
 block discarded – undo
548 548
     $memcacheStatsSingle = getMemcacheStats(false);
549 549
 
550 550
     if (!graphics_avail()) {
551
-		exit(0);
552
-	}
551
+        exit(0);
552
+    }
553 553
 
554
-	function fill_box($im, $x, $y, $w, $h, $color1, $color2,$text='',$placeindex='') {
555
-		global $col_black;
556
-		$x1=$x+$w-1;
557
-		$y1=$y+$h-1;
558
-
559
-		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);
562
-		imagerectangle($im, $x, $y1, $x1, $y, $color1);
563
-		if ($text) {
564
-			if ($placeindex>0) {
565
-
566
-				if ($placeindex<16)
567
-				{
568
-					$px=5;
569
-					$py=$placeindex*12+6;
570
-					imagefilledrectangle($im, $px+90, $py+3, $px+90-4, $py-3, $color2);
571
-					imageline($im,$x,$y+$h/2,$px+90,$py,$color2);
572
-					imagestring($im,2,$px,$py-6,$text,$color1);
573
-
574
-				} else {
575
-					if ($placeindex<31) {
576
-						$px=$x+40*2;
577
-						$py=($placeindex-15)*12+6;
578
-					} else {
579
-						$px=$x+40*2+100*intval(($placeindex-15)/15);
580
-						$py=($placeindex%15)*12+6;
581
-					}
582
-					imagefilledrectangle($im, $px, $py+3, $px-4, $py-3, $color2);
583
-					imageline($im,$x+$w,$y+$h/2,$px,$py,$color2);
584
-					imagestring($im,2,$px+2,$py-6,$text,$color1);
585
-				}
586
-			} else {
587
-				imagestring($im,4,$x+5,$y1-16,$text,$color1);
588
-			}
589
-		}
590
-	}
554
+    function fill_box($im, $x, $y, $w, $h, $color1, $color2,$text='',$placeindex='') {
555
+        global $col_black;
556
+        $x1=$x+$w-1;
557
+        $y1=$y+$h-1;
558
+
559
+        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);
562
+        imagerectangle($im, $x, $y1, $x1, $y, $color1);
563
+        if ($text) {
564
+            if ($placeindex>0) {
565
+
566
+                if ($placeindex<16)
567
+                {
568
+                    $px=5;
569
+                    $py=$placeindex*12+6;
570
+                    imagefilledrectangle($im, $px+90, $py+3, $px+90-4, $py-3, $color2);
571
+                    imageline($im,$x,$y+$h/2,$px+90,$py,$color2);
572
+                    imagestring($im,2,$px,$py-6,$text,$color1);
573
+
574
+                } else {
575
+                    if ($placeindex<31) {
576
+                        $px=$x+40*2;
577
+                        $py=($placeindex-15)*12+6;
578
+                    } else {
579
+                        $px=$x+40*2+100*intval(($placeindex-15)/15);
580
+                        $py=($placeindex%15)*12+6;
581
+                    }
582
+                    imagefilledrectangle($im, $px, $py+3, $px-4, $py-3, $color2);
583
+                    imageline($im,$x+$w,$y+$h/2,$px,$py,$color2);
584
+                    imagestring($im,2,$px+2,$py-6,$text,$color1);
585
+                }
586
+            } else {
587
+                imagestring($im,4,$x+5,$y1-16,$text,$color1);
588
+            }
589
+        }
590
+    }
591 591
 
592 592
 
593 593
     function fill_arc($im, $centerX, $centerY, $diameter, $start, $end, $color1,$color2,$text='',$placeindex=0) {
594
-		$r=$diameter/2;
595
-		$w=deg2rad((360+$start+($end-$start)/2)%360);
596
-
597
-
598
-		if (function_exists("imagefilledarc")) {
599
-			// exists only if GD 2.0.1 is avaliable
600
-			imagefilledarc($im, $centerX+1, $centerY+1, $diameter, $diameter, $start, $end, $color1, IMG_ARC_PIE);
601
-			imagefilledarc($im, $centerX, $centerY, $diameter, $diameter, $start, $end, $color2, IMG_ARC_PIE);
602
-			imagefilledarc($im, $centerX, $centerY, $diameter, $diameter, $start, $end, $color1, IMG_ARC_NOFILL|IMG_ARC_EDGED);
603
-		} else {
604
-			imagearc($im, $centerX, $centerY, $diameter, $diameter, $start, $end, $color2);
605
-			imageline($im, $centerX, $centerY, $centerX + cos(deg2rad($start)) * $r, $centerY + sin(deg2rad($start)) * $r, $color2);
606
-			imageline($im, $centerX, $centerY, $centerX + cos(deg2rad($start+1)) * $r, $centerY + sin(deg2rad($start)) * $r, $color2);
607
-			imageline($im, $centerX, $centerY, $centerX + cos(deg2rad($end-1))   * $r, $centerY + sin(deg2rad($end))   * $r, $color2);
608
-			imageline($im, $centerX, $centerY, $centerX + cos(deg2rad($end))   * $r, $centerY + sin(deg2rad($end))   * $r, $color2);
609
-			imagefill($im,$centerX + $r*cos($w)/2, $centerY + $r*sin($w)/2, $color2);
610
-		}
611
-		if ($text) {
612
-			if ($placeindex>0) {
613
-				imageline($im,$centerX + $r*cos($w)/2, $centerY + $r*sin($w)/2,$diameter, $placeindex*12,$color1);
614
-				imagestring($im,4,$diameter, $placeindex*12,$text,$color1);
615
-
616
-			} else {
617
-				imagestring($im,4,$centerX + $r*cos($w)/2, $centerY + $r*sin($w)/2,$text,$color1);
618
-			}
619
-		}
620
-	}
621
-	$size = GRAPH_SIZE; // image size
622
-	$image = imagecreate($size+50, $size+10);
594
+        $r=$diameter/2;
595
+        $w=deg2rad((360+$start+($end-$start)/2)%360);
596
+
597
+
598
+        if (function_exists("imagefilledarc")) {
599
+            // exists only if GD 2.0.1 is avaliable
600
+            imagefilledarc($im, $centerX+1, $centerY+1, $diameter, $diameter, $start, $end, $color1, IMG_ARC_PIE);
601
+            imagefilledarc($im, $centerX, $centerY, $diameter, $diameter, $start, $end, $color2, IMG_ARC_PIE);
602
+            imagefilledarc($im, $centerX, $centerY, $diameter, $diameter, $start, $end, $color1, IMG_ARC_NOFILL|IMG_ARC_EDGED);
603
+        } else {
604
+            imagearc($im, $centerX, $centerY, $diameter, $diameter, $start, $end, $color2);
605
+            imageline($im, $centerX, $centerY, $centerX + cos(deg2rad($start)) * $r, $centerY + sin(deg2rad($start)) * $r, $color2);
606
+            imageline($im, $centerX, $centerY, $centerX + cos(deg2rad($start+1)) * $r, $centerY + sin(deg2rad($start)) * $r, $color2);
607
+            imageline($im, $centerX, $centerY, $centerX + cos(deg2rad($end-1))   * $r, $centerY + sin(deg2rad($end))   * $r, $color2);
608
+            imageline($im, $centerX, $centerY, $centerX + cos(deg2rad($end))   * $r, $centerY + sin(deg2rad($end))   * $r, $color2);
609
+            imagefill($im,$centerX + $r*cos($w)/2, $centerY + $r*sin($w)/2, $color2);
610
+        }
611
+        if ($text) {
612
+            if ($placeindex>0) {
613
+                imageline($im,$centerX + $r*cos($w)/2, $centerY + $r*sin($w)/2,$diameter, $placeindex*12,$color1);
614
+                imagestring($im,4,$diameter, $placeindex*12,$text,$color1);
623 615
 
624
-	$col_white = imagecolorallocate($image, 0xFF, 0xFF, 0xFF);
625
-	$col_red   = imagecolorallocate($image, 0xD0, 0x60,  0x30);
626
-	$col_green = imagecolorallocate($image, 0x60, 0xF0, 0x60);
627
-	$col_black = imagecolorallocate($image,   0,   0,   0);
616
+            } else {
617
+                imagestring($im,4,$centerX + $r*cos($w)/2, $centerY + $r*sin($w)/2,$text,$color1);
618
+            }
619
+        }
620
+    }
621
+    $size = GRAPH_SIZE; // image size
622
+    $image = imagecreate($size+50, $size+10);
623
+
624
+    $col_white = imagecolorallocate($image, 0xFF, 0xFF, 0xFF);
625
+    $col_red   = imagecolorallocate($image, 0xD0, 0x60,  0x30);
626
+    $col_green = imagecolorallocate($image, 0x60, 0xF0, 0x60);
627
+    $col_black = imagecolorallocate($image,   0,   0,   0);
628 628
 
629
-	imagecolortransparent($image,$col_white);
629
+    imagecolortransparent($image,$col_white);
630 630
 
631 631
     switch ($_GET['IMG']){
632 632
         case 1: // pie chart
633 633
             $tsize=$memcacheStats['limit_maxbytes'];
634
-    		$avail=$tsize-$memcacheStats['bytes'];
635
-    		$x=$y=$size/2;
636
-    		$angle_from = 0;
637
-    		$fuzz = 0.000001;
634
+            $avail=$tsize-$memcacheStats['bytes'];
635
+            $x=$y=$size/2;
636
+            $angle_from = 0;
637
+            $fuzz = 0.000001;
638 638
 
639 639
             foreach($memcacheStatsSingle as $serv=>$mcs) {
640
-    			$free = $mcs['STAT']['limit_maxbytes']-$mcs['STAT']['bytes'];
641
-    			$used = $mcs['STAT']['bytes'];
640
+                $free = $mcs['STAT']['limit_maxbytes']-$mcs['STAT']['bytes'];
641
+                $used = $mcs['STAT']['bytes'];
642 642
 
643 643
 
644 644
                 if ($free>0){
645
-    			// draw free
646
-    			    $angle_to = ($free*360)/$tsize;
645
+                // draw free
646
+                    $angle_to = ($free*360)/$tsize;
647 647
                     $perc =sprintf("%.2f%%", ($free *100) / $tsize) ;
648 648
 
649
-        			fill_arc($image,$x,$y,$size,$angle_from,$angle_from + $angle_to ,$col_black,$col_green,$perc);
650
-        			$angle_from = $angle_from + $angle_to ;
649
+                    fill_arc($image,$x,$y,$size,$angle_from,$angle_from + $angle_to ,$col_black,$col_green,$perc);
650
+                    $angle_from = $angle_from + $angle_to ;
651 651
                 }
652
-    			if ($used>0){
653
-    			// draw used
654
-        			$angle_to = ($used*360)/$tsize;
655
-        			$perc =sprintf("%.2f%%", ($used *100) / $tsize) ;
656
-        			fill_arc($image,$x,$y,$size,$angle_from,$angle_from + $angle_to ,$col_black,$col_red, '('.$perc.')' );
652
+                if ($used>0){
653
+                // draw used
654
+                    $angle_to = ($used*360)/$tsize;
655
+                    $perc =sprintf("%.2f%%", ($used *100) / $tsize) ;
656
+                    fill_arc($image,$x,$y,$size,$angle_from,$angle_from + $angle_to ,$col_black,$col_red, '('.$perc.')' );
657 657
                     $angle_from = $angle_from+ $angle_to ;
658
-    			}
659
-    			}
658
+                }
659
+                }
660 660
 
661 661
         break;
662 662
 
@@ -666,14 +666,14 @@  discard block
 block discarded – undo
666 666
             $misses = ($memcacheStats['get_misses']==0) ? 1:$memcacheStats['get_misses'];
667 667
             $total = $hits + $misses ;
668 668
 
669
-	       	fill_box($image, 30,$size,50,-$hits*($size-21)/$total,$col_black,$col_green,sprintf("%.1f%%",$hits*100/$total));
670
-		    fill_box($image,130,$size,50,-max(4,($total-$hits)*($size-21)/$total),$col_black,$col_red,sprintf("%.1f%%",$misses*100/$total));
671
-		break;
669
+                fill_box($image, 30,$size,50,-$hits*($size-21)/$total,$col_black,$col_green,sprintf("%.1f%%",$hits*100/$total));
670
+            fill_box($image,130,$size,50,-max(4,($total-$hits)*($size-21)/$total),$col_black,$col_red,sprintf("%.1f%%",$misses*100/$total));
671
+        break;
672 672
 		
673 673
     }
674 674
     header("Content-type: image/png");
675
-	imagepng($image);
676
-	exit;
675
+    imagepng($image);
676
+    exit;
677 677
 }
678 678
 
679 679
 echo getHeader();
@@ -682,14 +682,14 @@  discard block
 block discarded – undo
682 682
 switch ($_GET['op']) {
683 683
 
684 684
     case 1: // host stats
685
-    	$phpversion = phpversion();
685
+        $phpversion = phpversion();
686 686
         $memcacheStats = getMemcacheStats();
687 687
         $memcacheStatsSingle = getMemcacheStats(false);
688 688
 
689 689
         $mem_size = $memcacheStats['limit_maxbytes'];
690
-    	$mem_used = $memcacheStats['bytes'];
691
-	    $mem_avail= $mem_size-$mem_used;
692
-	    $startTime = time()-array_sum($memcacheStats['uptime']);
690
+        $mem_used = $memcacheStats['bytes'];
691
+        $mem_avail= $mem_size-$mem_used;
692
+        $startTime = time()-array_sum($memcacheStats['uptime']);
693 693
 
694 694
         $curr_items = $memcacheStats['curr_items'];
695 695
         $total_items = $memcacheStats['total_items'];
@@ -697,33 +697,33 @@  discard block
 block discarded – undo
697 697
         $misses = ($memcacheStats['get_misses']==0) ? 1:$memcacheStats['get_misses'];
698 698
         $sets = $memcacheStats['cmd_set'];
699 699
 
700
-       	$req_rate = sprintf("%.2f",($hits+$misses)/($time-$startTime));
701
-	    $hit_rate = sprintf("%.2f",($hits)/($time-$startTime));
702
-	    $miss_rate = sprintf("%.2f",($misses)/($time-$startTime));
703
-	    $set_rate = sprintf("%.2f",($sets)/($time-$startTime));
700
+            $req_rate = sprintf("%.2f",($hits+$misses)/($time-$startTime));
701
+        $hit_rate = sprintf("%.2f",($hits)/($time-$startTime));
702
+        $miss_rate = sprintf("%.2f",($misses)/($time-$startTime));
703
+        $set_rate = sprintf("%.2f",($sets)/($time-$startTime));
704 704
 
705
-	    echo <<< EOB
705
+        echo <<< EOB
706 706
 		<div class="info div1"><h2>General Cache Information</h2>
707 707
 		<table cellspacing=0><tbody>
708 708
 		<tr class=tr-1><td class=td-0>PHP Version</td><td>$phpversion</td></tr>
709 709
 EOB;
710
-		echo "<tr class=tr-0><td class=td-0>Memcached Host". ((count($MEMCACHE_SERVERS)>1) ? 's':'')."</td><td>";
711
-		$i=0;
712
-		if (!isset($_GET['singleout']) && count($MEMCACHE_SERVERS)>1){
713
-    		foreach($MEMCACHE_SERVERS as $server){
714
-    		      echo ($i+1).'. <a href="'.$PHP_SELF.'&singleout='.$i++.'">'.$server.'</a><br/>';
715
-    		}
716
-		}
717
-		else{
718
-		    echo '1.'.$MEMCACHE_SERVERS[0];
719
-		}
720
-		if (isset($_GET['singleout'])){
721
-		      echo '<a href="'.$PHP_SELF.'">(all servers)</a><br/>';
722
-		}
723
-		echo "</td></tr>\n";
724
-		echo "<tr class=tr-1><td class=td-0>Total Memcache Cache</td><td>".bsize($memcacheStats['limit_maxbytes'])."</td></tr>\n";
725
-
726
-	echo <<<EOB
710
+        echo "<tr class=tr-0><td class=td-0>Memcached Host". ((count($MEMCACHE_SERVERS)>1) ? 's':'')."</td><td>";
711
+        $i=0;
712
+        if (!isset($_GET['singleout']) && count($MEMCACHE_SERVERS)>1){
713
+            foreach($MEMCACHE_SERVERS as $server){
714
+                    echo ($i+1).'. <a href="'.$PHP_SELF.'&singleout='.$i++.'">'.$server.'</a><br/>';
715
+            }
716
+        }
717
+        else{
718
+            echo '1.'.$MEMCACHE_SERVERS[0];
719
+        }
720
+        if (isset($_GET['singleout'])){
721
+                echo '<a href="'.$PHP_SELF.'">(all servers)</a><br/>';
722
+        }
723
+        echo "</td></tr>\n";
724
+        echo "<tr class=tr-1><td class=td-0>Total Memcache Cache</td><td>".bsize($memcacheStats['limit_maxbytes'])."</td></tr>\n";
725
+
726
+    echo <<<EOB
727 727
 		</tbody></table>
728 728
 		</div>
729 729
 
@@ -732,13 +732,13 @@  discard block
 block discarded – undo
732 732
         foreach($MEMCACHE_SERVERS as $server){
733 733
             echo '<table cellspacing=0><tbody>';
734 734
             echo '<tr class=tr-1><td class=td-1>'.$server.'</td><td><a href="'.$PHP_SELF.'&server='.array_search($server,$MEMCACHE_SERVERS).'&op=6">[<b>Flush this server</b>]</a></td></tr>';
735
-    		echo '<tr class=tr-0><td class=td-0>Start Time</td><td>',date(DATE_FORMAT,$memcacheStatsSingle[$server]['STAT']['time']-$memcacheStatsSingle[$server]['STAT']['uptime']),'</td></tr>';
736
-    		echo '<tr class=tr-1><td class=td-0>Uptime</td><td>',duration($memcacheStatsSingle[$server]['STAT']['time']-$memcacheStatsSingle[$server]['STAT']['uptime']),'</td></tr>';
737
-    		echo '<tr class=tr-0><td class=td-0>Memcached Server Version</td><td>'.$memcacheStatsSingle[$server]['STAT']['version'].'</td></tr>';
738
-    		echo '<tr class=tr-1><td class=td-0>Used Cache Size</td><td>',bsize($memcacheStatsSingle[$server]['STAT']['bytes']),'</td></tr>';
739
-    		echo '<tr class=tr-0><td class=td-0>Total Cache Size</td><td>',bsize($memcacheStatsSingle[$server]['STAT']['limit_maxbytes']),'</td></tr>';
740
-    		echo '</tbody></table>';
741
-	   }
735
+            echo '<tr class=tr-0><td class=td-0>Start Time</td><td>',date(DATE_FORMAT,$memcacheStatsSingle[$server]['STAT']['time']-$memcacheStatsSingle[$server]['STAT']['uptime']),'</td></tr>';
736
+            echo '<tr class=tr-1><td class=td-0>Uptime</td><td>',duration($memcacheStatsSingle[$server]['STAT']['time']-$memcacheStatsSingle[$server]['STAT']['uptime']),'</td></tr>';
737
+            echo '<tr class=tr-0><td class=td-0>Memcached Server Version</td><td>'.$memcacheStatsSingle[$server]['STAT']['version'].'</td></tr>';
738
+            echo '<tr class=tr-1><td class=td-0>Used Cache Size</td><td>',bsize($memcacheStatsSingle[$server]['STAT']['bytes']),'</td></tr>';
739
+            echo '<tr class=tr-0><td class=td-0>Total Cache Size</td><td>',bsize($memcacheStatsSingle[$server]['STAT']['limit_maxbytes']),'</td></tr>';
740
+            echo '</tbody></table>';
741
+        }
742 742
     echo <<<EOB
743 743
 
744 744
 		</div>
@@ -746,28 +746,28 @@  discard block
 block discarded – undo
746 746
 		<table cellspacing=0><tbody>
747 747
 EOB;
748 748
 
749
-	$size='width='.(GRAPH_SIZE+50).' height='.(GRAPH_SIZE+10);
750
-	echo <<<EOB
749
+    $size='width='.(GRAPH_SIZE+50).' height='.(GRAPH_SIZE+10);
750
+    echo <<<EOB
751 751
 		<tr>
752 752
 		<td class=td-0>Cache Usage</td>
753 753
 		<td class=td-1>Hits &amp; Misses</td>
754 754
 		</tr>
755 755
 EOB;
756 756
 
757
-	echo
758
-		graphics_avail() ?
759
-			  '<tr>'.
760
-			  "<td class=td-0><img alt=\"\" $size src=\"$PHP_SELF&IMG=1&".(isset($_GET['singleout'])? 'singleout='.$_GET['singleout'].'&':'')."$time\"></td>".
761
-			  "<td class=td-1><img alt=\"\" $size src=\"$PHP_SELF&IMG=2&".(isset($_GET['singleout'])? 'singleout='.$_GET['singleout'].'&':'')."$time\"></td></tr>\n"
762
-			: "",
763
-		'<tr>',
764
-		'<td class=td-0><span class="green box">&nbsp;</span>Free: ',bsize($mem_avail).sprintf(" (%.1f%%)",$mem_avail*100/$mem_size),"</td>\n",
765
-		'<td class=td-1><span class="green box">&nbsp;</span>Hits: ',$hits.sprintf(" (%.1f%%)",$hits*100/($hits+$misses)),"</td>\n",
766
-		'</tr>',
767
-		'<tr>',
768
-		'<td class=td-0><span class="red box">&nbsp;</span>Used: ',bsize($mem_used ).sprintf(" (%.1f%%)",$mem_used *100/$mem_size),"</td>\n",
769
-		'<td class=td-1><span class="red box">&nbsp;</span>Misses: ',$misses.sprintf(" (%.1f%%)",$misses*100/($hits+$misses)),"</td>\n";
770
-		echo <<< EOB
757
+    echo
758
+        graphics_avail() ?
759
+              '<tr>'.
760
+                "<td class=td-0><img alt=\"\" $size src=\"$PHP_SELF&IMG=1&".(isset($_GET['singleout'])? 'singleout='.$_GET['singleout'].'&':'')."$time\"></td>".
761
+                "<td class=td-1><img alt=\"\" $size src=\"$PHP_SELF&IMG=2&".(isset($_GET['singleout'])? 'singleout='.$_GET['singleout'].'&':'')."$time\"></td></tr>\n"
762
+            : "",
763
+        '<tr>',
764
+        '<td class=td-0><span class="green box">&nbsp;</span>Free: ',bsize($mem_avail).sprintf(" (%.1f%%)",$mem_avail*100/$mem_size),"</td>\n",
765
+        '<td class=td-1><span class="green box">&nbsp;</span>Hits: ',$hits.sprintf(" (%.1f%%)",$hits*100/($hits+$misses)),"</td>\n",
766
+        '</tr>',
767
+        '<tr>',
768
+        '<td class=td-0><span class="red box">&nbsp;</span>Used: ',bsize($mem_used ).sprintf(" (%.1f%%)",$mem_used *100/$mem_size),"</td>\n",
769
+        '<td class=td-1><span class="red box">&nbsp;</span>Misses: ',$misses.sprintf(" (%.1f%%)",$misses*100/($hits+$misses)),"</td>\n";
770
+        echo <<< EOB
771 771
 	</tr>
772 772
 	</tbody></table>
773 773
 <br/>
@@ -789,31 +789,31 @@  discard block
 block discarded – undo
789 789
 
790 790
     case 2: // variables
791 791
 
792
-		$m=0;
793
-		$cacheItems= getCacheItems();
794
-		$items = $cacheItems['items'];
795
-		$totals = $cacheItems['counts'];
796
-		$maxDump = MAX_ITEM_DUMP;
797
-		foreach($items as $server => $entries) {
792
+        $m=0;
793
+        $cacheItems= getCacheItems();
794
+        $items = $cacheItems['items'];
795
+        $totals = $cacheItems['counts'];
796
+        $maxDump = MAX_ITEM_DUMP;
797
+        foreach($items as $server => $entries) {
798 798
 
799
-    	echo <<< EOB
799
+        echo <<< EOB
800 800
 
801 801
 			<div class="info"><table cellspacing=0><tbody>
802 802
 			<tr><th colspan="2">$server</th></tr>
803 803
 			<tr><th>Slab Id</th><th>Info</th></tr>
804 804
 EOB;
805 805
 
806
-			foreach($entries as $slabId => $slab) {
807
-			    $dumpUrl = $PHP_SELF.'&op=2&server='.(array_search($server,$MEMCACHE_SERVERS)).'&dumpslab='.$slabId;
808
-				echo
809
-					"<tr class=tr-$m>",
810
-					"<td class=td-0><center>",'<a href="',$dumpUrl,'">',$slabId,'</a>',"</center></td>",
811
-					"<td class=td-last><b>Item count:</b> ",$slab['number'],'<br/><b>Age:</b>',duration($time-$slab['age']),'<br/> <b>Evicted:</b>',((isset($slab['evicted']) && $slab['evicted']==1)? 'Yes':'No');
812
-					if ((isset($_GET['dumpslab']) && $_GET['dumpslab']==$slabId) &&  (isset($_GET['server']) && $_GET['server']==array_search($server,$MEMCACHE_SERVERS))){
813
-					    echo "<br/><b>Items: item</b><br/>";
814
-					    $items = dumpCacheSlab($server,$slabId,$slab['number']);
806
+            foreach($entries as $slabId => $slab) {
807
+                $dumpUrl = $PHP_SELF.'&op=2&server='.(array_search($server,$MEMCACHE_SERVERS)).'&dumpslab='.$slabId;
808
+                echo
809
+                    "<tr class=tr-$m>",
810
+                    "<td class=td-0><center>",'<a href="',$dumpUrl,'">',$slabId,'</a>',"</center></td>",
811
+                    "<td class=td-last><b>Item count:</b> ",$slab['number'],'<br/><b>Age:</b>',duration($time-$slab['age']),'<br/> <b>Evicted:</b>',((isset($slab['evicted']) && $slab['evicted']==1)? 'Yes':'No');
812
+                    if ((isset($_GET['dumpslab']) && $_GET['dumpslab']==$slabId) &&  (isset($_GET['server']) && $_GET['server']==array_search($server,$MEMCACHE_SERVERS))){
813
+                        echo "<br/><b>Items: item</b><br/>";
814
+                        $items = dumpCacheSlab($server,$slabId,$slab['number']);
815 815
                         // maybe someone likes to do a pagination here :)
816
-					    $i=1;
816
+                        $i=1;
817 817
                         foreach($items['ITEM'] as $itemKey=>$itemInfo){
818 818
                             $itemInfo = trim($itemInfo,'[ ]');
819 819
 
@@ -826,17 +826,17 @@  discard block
 block discarded – undo
826 826
                                 echo ',';
827 827
                             }
828 828
                         }
829
-					}
829
+                    }
830 830
 
831
-					echo "</td></tr>";
832
-				$m=1-$m;
833
-			}
834
-		echo <<<EOB
831
+                    echo "</td></tr>";
832
+                $m=1-$m;
833
+            }
834
+        echo <<<EOB
835 835
 			</tbody></table>
836 836
 			</div><hr/>
837 837
 EOB;
838 838
 }
839
-		break;
839
+        break;
840 840
 
841 841
     break;
842 842
 
@@ -859,16 +859,16 @@  discard block
 block discarded – undo
859 859
 EOB;
860 860
         if (!isset($r['VALUE'])) {
861 861
             echo "<tr><td class=td-0>",$theserver,"</td><td class=td-0>",$theKey,
862
-                 "</td><td>[The requested item was not found or has expired]</td>",
863
-                 "<td></td>","</tr>";
862
+                    "</td><td>[The requested item was not found or has expired]</td>",
863
+                    "<td></td>","</tr>";
864 864
         }
865 865
         else {
866 866
 
867 867
             echo "<tr><td class=td-0>",$theserver,"</td><td class=td-0>",$theKey,
868
-                 " <br/>flag:",$r['VALUE'][$theKey]['stat']['flag'],
869
-                 " <br/>Size:",bsize($r['VALUE'][$theKey]['stat']['size']),
870
-                 "</td><td>",chunk_split($r['VALUE'][$theKey]['value'],40),"</td>",
871
-                 '<td><a href="',$PHP_SELF,'&op=5&server=',(int)$_GET['server'],'&key=',base64_encode($theKey),"\">Delete</a></td>","</tr>";
868
+                    " <br/>flag:",$r['VALUE'][$theKey]['stat']['flag'],
869
+                    " <br/>Size:",bsize($r['VALUE'][$theKey]['stat']['size']),
870
+                    "</td><td>",chunk_split($r['VALUE'][$theKey]['value'],40),"</td>",
871
+                    '<td><a href="',$PHP_SELF,'&op=5&server=',(int)$_GET['server'],'&key=',base64_encode($theKey),"\">Delete</a></td>","</tr>";
872 872
         }
873 873
         echo <<<EOB
874 874
 			</tbody></table>
@@ -876,22 +876,22 @@  discard block
 block discarded – undo
876 876
 EOB;
877 877
     break;
878 878
     case 5: // item delete
879
-    	if (!isset($_GET['key']) || !isset($_GET['server'])){
880
-			echo "No key set!";
881
-			break;
879
+        if (!isset($_GET['key']) || !isset($_GET['server'])){
880
+            echo "No key set!";
881
+            break;
882 882
         }
883 883
         $theKey = htmlentities(base64_decode($_GET['key']));
884
-		$theserver = $MEMCACHE_SERVERS[(int)$_GET['server']];
885
-		list($h,$p) = get_host_port_from_server($theserver);
884
+        $theserver = $MEMCACHE_SERVERS[(int)$_GET['server']];
885
+        list($h,$p) = get_host_port_from_server($theserver);
886 886
         $r = sendMemcacheCommand($h,$p,'delete '.$theKey);
887 887
         echo 'Deleting '.$theKey.':'.$r;
888
-	break;
888
+    break;
889 889
     
890
-   case 6: // flush server
890
+    case 6: // flush server
891 891
         $theserver = $MEMCACHE_SERVERS[(int)$_GET['server']];
892 892
         $r = flushServer($theserver);
893 893
         echo 'Flush  '.$theserver.":".$r;
894
-   break;
894
+    break;
895 895
 }
896 896
 echo getFooter();
897 897
 
Please login to merge, or discard this patch.
var/www/admin/apc/apc.php 1 patch
Indentation   +555 added lines, -555 removed lines patch added patch discarded remove patch
@@ -37,13 +37,13 @@  discard block
 block discarded – undo
37 37
 ////////// BEGIN OF DEFAULT CONFIG AREA ///////////////////////////////////////////////////////////
38 38
 
39 39
 defaults('USE_AUTHENTICATION',0);			// Use (internal) authentication - best choice if
40
-											// no other authentication is available
41
-											// If set to 0:
42
-											//  There will be no further authentication. You
43
-											//  will have to handle this by yourself!
44
-											// If set to 1:
45
-											//  You need to change ADMIN_PASSWORD to make
46
-											//  this work!
40
+                                            // no other authentication is available
41
+                                            // If set to 0:
42
+                                            //  There will be no further authentication. You
43
+                                            //  will have to handle this by yourself!
44
+                                            // If set to 1:
45
+                                            //  You need to change ADMIN_PASSWORD to make
46
+                                            //  this work!
47 47
 defaults('ADMIN_USERNAME','apc'); 			// Admin Username
48 48
 defaults('ADMIN_PASSWORD','password');  	// Admin Password - CHANGE THIS TO ENABLE!!!
49 49
 
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 
63 63
 // "define if not defined"
64 64
 function defaults($d,$v) {
65
-	if (!defined($d)) define($d,$v); // or just @define(...)
65
+    if (!defined($d)) define($d,$v); // or just @define(...)
66 66
 }
67 67
 
68 68
 // rewrite $PHP_SELF to block XSS attacks
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 $host = php_uname('n');
73 73
 if($host) { $host = '('.$host.')'; }
74 74
 if (isset($_SERVER['SERVER_ADDR'])) {
75
-  $host .= ' ('.$_SERVER['SERVER_ADDR'].')';
75
+    $host .= ' ('.$_SERVER['SERVER_ADDR'].')';
76 76
 }
77 77
 
78 78
 // operation constants
@@ -82,50 +82,50 @@  discard block
 block discarded – undo
82 82
 
83 83
 // check validity of input variables
84 84
 $vardom=array(
85
-	'OB'	=> '/^\d+$/',			// operational mode switch
86
-	'CC'	=> '/^[01]$/',			// clear cache requested
87
-	'DU'	=> '/^.*$/',			// Delete User Key
88
-	'SH'	=> '/^[a-z0-9]+$/',		// shared object description
89
-
90
-	'IMG'	=> '/^[123]$/',			// image to generate
91
-	'LO'	=> '/^1$/',				// login requested
92
-
93
-	'COUNT'	=> '/^\d+$/',			// number of line displayed in list
94
-	'SCOPE'	=> '/^[AD]$/',			// list view scope
95
-	'SORT1'	=> '/^[AHSMCDTZ]$/',	// first sort key
96
-	'SORT2'	=> '/^[DA]$/',			// second sort key
97
-	'AGGR'	=> '/^\d+$/',			// aggregation by dir level
98
-	'SEARCH'	=> '~^[a-zA-Z0-9/_.-]*$~'			// aggregation by dir level
85
+    'OB'	=> '/^\d+$/',			// operational mode switch
86
+    'CC'	=> '/^[01]$/',			// clear cache requested
87
+    'DU'	=> '/^.*$/',			// Delete User Key
88
+    'SH'	=> '/^[a-z0-9]+$/',		// shared object description
89
+
90
+    'IMG'	=> '/^[123]$/',			// image to generate
91
+    'LO'	=> '/^1$/',				// login requested
92
+
93
+    'COUNT'	=> '/^\d+$/',			// number of line displayed in list
94
+    'SCOPE'	=> '/^[AD]$/',			// list view scope
95
+    'SORT1'	=> '/^[AHSMCDTZ]$/',	// first sort key
96
+    'SORT2'	=> '/^[DA]$/',			// second sort key
97
+    'AGGR'	=> '/^\d+$/',			// aggregation by dir level
98
+    'SEARCH'	=> '~^[a-zA-Z0-9/_.-]*$~'			// aggregation by dir level
99 99
 );
100 100
 
101 101
 // cache scope
102 102
 $scope_list=array(
103
-	'A' => 'cache_list',
104
-	'D' => 'deleted_list'
103
+    'A' => 'cache_list',
104
+    'D' => 'deleted_list'
105 105
 );
106 106
 
107 107
 // handle POST and GET requests
108 108
 if (empty($_REQUEST)) {
109
-	if (!empty($_GET) && !empty($_POST)) {
110
-		$_REQUEST = array_merge($_GET, $_POST);
111
-	} else if (!empty($_GET)) {
112
-		$_REQUEST = $_GET;
113
-	} else if (!empty($_POST)) {
114
-		$_REQUEST = $_POST;
115
-	} else {
116
-		$_REQUEST = array();
117
-	}
109
+    if (!empty($_GET) && !empty($_POST)) {
110
+        $_REQUEST = array_merge($_GET, $_POST);
111
+    } else if (!empty($_GET)) {
112
+        $_REQUEST = $_GET;
113
+    } else if (!empty($_POST)) {
114
+        $_REQUEST = $_POST;
115
+    } else {
116
+        $_REQUEST = array();
117
+    }
118 118
 }
119 119
 
120 120
 // check parameter syntax
121 121
 foreach($vardom as $var => $dom) {
122
-	if (!isset($_REQUEST[$var])) {
123
-		$MYREQUEST[$var]=NULL;
124
-	} else if (!is_array($_REQUEST[$var]) && preg_match($dom.'D',$_REQUEST[$var])) {
125
-		$MYREQUEST[$var]=$_REQUEST[$var];
126
-	} else {
127
-		$MYREQUEST[$var]=$_REQUEST[$var]=NULL;
128
-	}
122
+    if (!isset($_REQUEST[$var])) {
123
+        $MYREQUEST[$var]=NULL;
124
+    } else if (!is_array($_REQUEST[$var]) && preg_match($dom.'D',$_REQUEST[$var])) {
125
+        $MYREQUEST[$var]=$_REQUEST[$var];
126
+    } else {
127
+        $MYREQUEST[$var]=$_REQUEST[$var]=NULL;
128
+    }
129 129
 }
130 130
 
131 131
 // check parameter sematics
@@ -137,58 +137,58 @@  discard block
 block discarded – undo
137 137
 if (!isset($scope_list[$MYREQUEST['SCOPE']])) $MYREQUEST['SCOPE']='A';
138 138
 
139 139
 $MY_SELF=
140
-	"$PHP_SELF".
141
-	"?SCOPE=".$MYREQUEST['SCOPE'].
142
-	"&SORT1=".$MYREQUEST['SORT1'].
143
-	"&SORT2=".$MYREQUEST['SORT2'].
144
-	"&COUNT=".$MYREQUEST['COUNT'];
140
+    "$PHP_SELF".
141
+    "?SCOPE=".$MYREQUEST['SCOPE'].
142
+    "&SORT1=".$MYREQUEST['SORT1'].
143
+    "&SORT2=".$MYREQUEST['SORT2'].
144
+    "&COUNT=".$MYREQUEST['COUNT'];
145 145
 $MY_SELF_WO_SORT=
146
-	"$PHP_SELF".
147
-	"?SCOPE=".$MYREQUEST['SCOPE'].
148
-	"&COUNT=".$MYREQUEST['COUNT'];
146
+    "$PHP_SELF".
147
+    "?SCOPE=".$MYREQUEST['SCOPE'].
148
+    "&COUNT=".$MYREQUEST['COUNT'];
149 149
 
150 150
 // authentication needed?
151 151
 //
152 152
 if (!USE_AUTHENTICATION) {
153
-	$AUTHENTICATED=1;
153
+    $AUTHENTICATED=1;
154 154
 } else {
155
-	$AUTHENTICATED=0;
156
-	if (ADMIN_PASSWORD!='password' && ($MYREQUEST['LO'] == 1 || isset($_SERVER['PHP_AUTH_USER']))) {
155
+    $AUTHENTICATED=0;
156
+    if (ADMIN_PASSWORD!='password' && ($MYREQUEST['LO'] == 1 || isset($_SERVER['PHP_AUTH_USER']))) {
157 157
 
158
-		if (!isset($_SERVER['PHP_AUTH_USER']) ||
159
-			!isset($_SERVER['PHP_AUTH_PW']) ||
160
-			$_SERVER['PHP_AUTH_USER'] != ADMIN_USERNAME ||
161
-			$_SERVER['PHP_AUTH_PW'] != ADMIN_PASSWORD) {
162
-			Header("WWW-Authenticate: Basic realm=\"APC Login\"");
163
-			Header("HTTP/1.0 401 Unauthorized");
158
+        if (!isset($_SERVER['PHP_AUTH_USER']) ||
159
+            !isset($_SERVER['PHP_AUTH_PW']) ||
160
+            $_SERVER['PHP_AUTH_USER'] != ADMIN_USERNAME ||
161
+            $_SERVER['PHP_AUTH_PW'] != ADMIN_PASSWORD) {
162
+            Header("WWW-Authenticate: Basic realm=\"APC Login\"");
163
+            Header("HTTP/1.0 401 Unauthorized");
164 164
 
165
-			echo <<<EOB
165
+            echo <<<EOB
166 166
 				<html><body>
167 167
 				<h1>Rejected!</h1>
168 168
 				<big>Wrong Username or Password!</big><br/>&nbsp;<br/>&nbsp;
169 169
 				<big><a href='$PHP_SELF?OB={$MYREQUEST['OB']}'>Continue...</a></big>
170 170
 				</body></html>
171 171
 EOB;
172
-			exit;
172
+            exit;
173 173
 
174
-		} else {
175
-			$AUTHENTICATED=1;
176
-		}
177
-	}
174
+        } else {
175
+            $AUTHENTICATED=1;
176
+        }
177
+    }
178 178
 }
179 179
 
180 180
 // clear cache
181 181
 if ($AUTHENTICATED && isset($MYREQUEST['CC']) && $MYREQUEST['CC']) {
182
-	apcu_clear_cache();
182
+    apcu_clear_cache();
183 183
 }
184 184
 
185 185
 if ($AUTHENTICATED && !empty($MYREQUEST['DU'])) {
186
-	apcu_delete($MYREQUEST['DU']);
186
+    apcu_delete($MYREQUEST['DU']);
187 187
 }
188 188
 
189 189
 if(!function_exists('apcu_cache_info')) {
190
-	echo "No cache info available.  APC does not appear to be running.";
191
-  exit;
190
+    echo "No cache info available.  APC does not appear to be running.";
191
+    exit;
192 192
 }
193 193
 
194 194
 $cache = apcu_cache_info();
@@ -226,286 +226,286 @@  discard block
 block discarded – undo
226 226
 // create graphics
227 227
 //
228 228
 function graphics_avail() {
229
-	return extension_loaded('gd');
229
+    return extension_loaded('gd');
230 230
 }
231 231
 if (isset($MYREQUEST['IMG']))
232 232
 {
233
-	if (!graphics_avail()) {
234
-		exit(0);
235
-	}
233
+    if (!graphics_avail()) {
234
+        exit(0);
235
+    }
236 236
 
237
-	function fill_arc($im, $centerX, $centerY, $diameter, $start, $end, $color1,$color2,$text='',$placeindex=0) {
238
-		$r=$diameter/2;
239
-		$w=deg2rad((360+$start+($end-$start)/2)%360);
240
-
241
-
242
-		if (function_exists("imagefilledarc")) {
243
-			// exists only if GD 2.0.1 is avaliable
244
-			imagefilledarc($im, $centerX+1, $centerY+1, $diameter, $diameter, $start, $end, $color1, IMG_ARC_PIE);
245
-			imagefilledarc($im, $centerX, $centerY, $diameter, $diameter, $start, $end, $color2, IMG_ARC_PIE);
246
-			imagefilledarc($im, $centerX, $centerY, $diameter, $diameter, $start, $end, $color1, IMG_ARC_NOFILL|IMG_ARC_EDGED);
247
-		} else {
248
-			imagearc($im, $centerX, $centerY, $diameter, $diameter, $start, $end, $color2);
249
-			imageline($im, $centerX, $centerY, $centerX + cos(deg2rad($start)) * $r, $centerY + sin(deg2rad($start)) * $r, $color2);
250
-			imageline($im, $centerX, $centerY, $centerX + cos(deg2rad($start+1)) * $r, $centerY + sin(deg2rad($start)) * $r, $color2);
251
-			imageline($im, $centerX, $centerY, $centerX + cos(deg2rad($end-1))   * $r, $centerY + sin(deg2rad($end))   * $r, $color2);
252
-			imageline($im, $centerX, $centerY, $centerX + cos(deg2rad($end))   * $r, $centerY + sin(deg2rad($end))   * $r, $color2);
253
-			imagefill($im,$centerX + $r*cos($w)/2, $centerY + $r*sin($w)/2, $color2);
254
-		}
255
-		if ($text) {
256
-			if ($placeindex>0) {
257
-				imageline($im,$centerX + $r*cos($w)/2, $centerY + $r*sin($w)/2,$diameter, $placeindex*12,$color1);
258
-				imagestring($im,4,$diameter, $placeindex*12,$text,$color1);
259
-
260
-			} else {
261
-				imagestring($im,4,$centerX + $r*cos($w)/2, $centerY + $r*sin($w)/2,$text,$color1);
262
-			}
263
-		}
264
-	}
237
+    function fill_arc($im, $centerX, $centerY, $diameter, $start, $end, $color1,$color2,$text='',$placeindex=0) {
238
+        $r=$diameter/2;
239
+        $w=deg2rad((360+$start+($end-$start)/2)%360);
265 240
 
266
-	function text_arc($im, $centerX, $centerY, $diameter, $start, $end, $color1,$text,$placeindex=0) {
267
-		$r=$diameter/2;
268
-		$w=deg2rad((360+$start+($end-$start)/2)%360);
269 241
 
270
-		if ($placeindex>0) {
271
-			imageline($im,$centerX + $r*cos($w)/2, $centerY + $r*sin($w)/2,$diameter, $placeindex*12,$color1);
272
-			imagestring($im,4,$diameter, $placeindex*12,$text,$color1);
273
-
274
-		} else {
275
-			imagestring($im,4,$centerX + $r*cos($w)/2, $centerY + $r*sin($w)/2,$text,$color1);
276
-		}
277
-	}
242
+        if (function_exists("imagefilledarc")) {
243
+            // exists only if GD 2.0.1 is avaliable
244
+            imagefilledarc($im, $centerX+1, $centerY+1, $diameter, $diameter, $start, $end, $color1, IMG_ARC_PIE);
245
+            imagefilledarc($im, $centerX, $centerY, $diameter, $diameter, $start, $end, $color2, IMG_ARC_PIE);
246
+            imagefilledarc($im, $centerX, $centerY, $diameter, $diameter, $start, $end, $color1, IMG_ARC_NOFILL|IMG_ARC_EDGED);
247
+        } else {
248
+            imagearc($im, $centerX, $centerY, $diameter, $diameter, $start, $end, $color2);
249
+            imageline($im, $centerX, $centerY, $centerX + cos(deg2rad($start)) * $r, $centerY + sin(deg2rad($start)) * $r, $color2);
250
+            imageline($im, $centerX, $centerY, $centerX + cos(deg2rad($start+1)) * $r, $centerY + sin(deg2rad($start)) * $r, $color2);
251
+            imageline($im, $centerX, $centerY, $centerX + cos(deg2rad($end-1))   * $r, $centerY + sin(deg2rad($end))   * $r, $color2);
252
+            imageline($im, $centerX, $centerY, $centerX + cos(deg2rad($end))   * $r, $centerY + sin(deg2rad($end))   * $r, $color2);
253
+            imagefill($im,$centerX + $r*cos($w)/2, $centerY + $r*sin($w)/2, $color2);
254
+        }
255
+        if ($text) {
256
+            if ($placeindex>0) {
257
+                imageline($im,$centerX + $r*cos($w)/2, $centerY + $r*sin($w)/2,$diameter, $placeindex*12,$color1);
258
+                imagestring($im,4,$diameter, $placeindex*12,$text,$color1);
259
+
260
+            } else {
261
+                imagestring($im,4,$centerX + $r*cos($w)/2, $centerY + $r*sin($w)/2,$text,$color1);
262
+            }
263
+        }
264
+    }
278 265
 
279
-	function fill_box($im, $x, $y, $w, $h, $color1, $color2,$text='',$placeindex='') {
280
-		global $col_black;
281
-		$x1=$x+$w-1;
282
-		$y1=$y+$h-1;
283
-
284
-		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);
287
-		imagerectangle($im, $x, $y1, $x1, $y, $color1);
288
-		if ($text) {
289
-			if ($placeindex>0) {
290
-
291
-				if ($placeindex<16)
292
-				{
293
-					$px=5;
294
-					$py=$placeindex*12+6;
295
-					imagefilledrectangle($im, $px+90, $py+3, $px+90-4, $py-3, $color2);
296
-					imageline($im,$x,$y+$h/2,$px+90,$py,$color2);
297
-					imagestring($im,2,$px,$py-6,$text,$color1);
298
-
299
-				} else {
300
-					if ($placeindex<31) {
301
-						$px=$x+40*2;
302
-						$py=($placeindex-15)*12+6;
303
-					} else {
304
-						$px=$x+40*2+100*intval(($placeindex-15)/15);
305
-						$py=($placeindex%15)*12+6;
306
-					}
307
-					imagefilledrectangle($im, $px, $py+3, $px-4, $py-3, $color2);
308
-					imageline($im,$x+$w,$y+$h/2,$px,$py,$color2);
309
-					imagestring($im,2,$px+2,$py-6,$text,$color1);
310
-				}
311
-			} else {
312
-				imagestring($im,4,$x+5,$y1-16,$text,$color1);
313
-			}
314
-		}
315
-	}
266
+    function text_arc($im, $centerX, $centerY, $diameter, $start, $end, $color1,$text,$placeindex=0) {
267
+        $r=$diameter/2;
268
+        $w=deg2rad((360+$start+($end-$start)/2)%360);
316 269
 
270
+        if ($placeindex>0) {
271
+            imageline($im,$centerX + $r*cos($w)/2, $centerY + $r*sin($w)/2,$diameter, $placeindex*12,$color1);
272
+            imagestring($im,4,$diameter, $placeindex*12,$text,$color1);
317 273
 
318
-	$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);
323
-
324
-	$col_white = imagecolorallocate($image, 0xFF, 0xFF, 0xFF);
325
-	$col_red   = imagecolorallocate($image, 0xD0, 0x60,  0x30);
326
-	$col_green = imagecolorallocate($image, 0x60, 0xF0, 0x60);
327
-	$col_black = imagecolorallocate($image,   0,   0,   0);
328
-	imagecolortransparent($image,$col_white);
329
-
330
-	switch ($MYREQUEST['IMG']) {
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) {
274
+        } else {
275
+            imagestring($im,4,$centerX + $r*cos($w)/2, $centerY + $r*sin($w)/2,$text,$color1);
276
+        }
277
+    }
278
+
279
+    function fill_box($im, $x, $y, $w, $h, $color1, $color2,$text='',$placeindex='') {
280
+        global $col_black;
281
+        $x1=$x+$w-1;
282
+        $y1=$y+$h-1;
283
+
284
+        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);
287
+        imagerectangle($im, $x, $y1, $x1, $y, $color1);
288
+        if ($text) {
289
+            if ($placeindex>0) {
290
+
291
+                if ($placeindex<16)
292
+                {
293
+                    $px=5;
294
+                    $py=$placeindex*12+6;
295
+                    imagefilledrectangle($im, $px+90, $py+3, $px+90-4, $py-3, $color2);
296
+                    imageline($im,$x,$y+$h/2,$px+90,$py,$color2);
297
+                    imagestring($im,2,$px,$py-6,$text,$color1);
298
+
299
+                } else {
300
+                    if ($placeindex<31) {
301
+                        $px=$x+40*2;
302
+                        $py=($placeindex-15)*12+6;
303
+                    } else {
304
+                        $px=$x+40*2+100*intval(($placeindex-15)/15);
305
+                        $py=($placeindex%15)*12+6;
306
+                    }
307
+                    imagefilledrectangle($im, $px, $py+3, $px-4, $py-3, $color2);
308
+                    imageline($im,$x+$w,$y+$h/2,$px,$py,$color2);
309
+                    imagestring($im,2,$px+2,$py-6,$text,$color1);
310
+                }
311
+            } else {
312
+                imagestring($im,4,$x+5,$y1-16,$text,$color1);
313
+            }
314
+        }
315
+    }
316
+
317
+
318
+    $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);
323
+
324
+    $col_white = imagecolorallocate($image, 0xFF, 0xFF, 0xFF);
325
+    $col_red   = imagecolorallocate($image, 0xD0, 0x60,  0x30);
326
+    $col_green = imagecolorallocate($image, 0x60, 0xF0, 0x60);
327
+    $col_black = imagecolorallocate($image,   0,   0,   0);
328
+    imagecolortransparent($image,$col_white);
329
+
330
+    switch ($MYREQUEST['IMG']) {
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 408
                                                 $j++;
409
-						if($j<75) fill_box($image,$x,$y,50,$h,$col_black,$col_red,bsize($block['offset']-$ptr),$j);
409
+                        if($j<75) fill_box($image,$x,$y,50,$h,$col_black,$col_red,bsize($block['offset']-$ptr),$j);
410 410
                                                 else fill_box($image,$x,$y,50,$h,$col_black,$col_red);
411 411
                                         }
412
-					$y+=$h;
413
-				}
414
-				$h=(GRAPH_SIZE-5)*($block['size'])/$s;
415
-				if ($h>0) {
412
+                    $y+=$h;
413
+                }
414
+                $h=(GRAPH_SIZE-5)*($block['size'])/$s;
415
+                if ($h>0) {
416 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);
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 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
-
432
-		case 4:
433
-			$s=$cache['nhits']+$cache['nmisses'];
434
-			$a=$cache['nhits'];
435
-
436
-			fill_box($image, 30,$size,50,$s ? -$a*($size-21)/$s : 0,$col_black,$col_green,sprintf("%.1f%%", $s ? $cache['nhits']*100/$s : 0));
437
-			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));
438
-		break;
439
-	}
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
+
432
+        case 4:
433
+            $s=$cache['nhits']+$cache['nmisses'];
434
+            $a=$cache['nhits'];
435
+
436
+            fill_box($image, 30,$size,50,$s ? -$a*($size-21)/$s : 0,$col_black,$col_green,sprintf("%.1f%%", $s ? $cache['nhits']*100/$s : 0));
437
+            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));
438
+        break;
439
+    }
440 440
 
441
-	header("Content-type: image/png");
442
-	imagepng($image);
443
-	exit;
441
+    header("Content-type: image/png");
442
+    imagepng($image);
443
+    exit;
444 444
 }
445 445
 
446 446
 // pretty printer for byte values
447 447
 //
448 448
 function bsize($s) {
449
-	foreach (array('','K','M','G') as $i => $k) {
450
-		if ($s < 1024) break;
451
-		$s/=1024;
452
-	}
453
-	return sprintf("%5.1f %sBytes",$s,$k);
449
+    foreach (array('','K','M','G') as $i => $k) {
450
+        if ($s < 1024) break;
451
+        $s/=1024;
452
+    }
453
+    return sprintf("%5.1f %sBytes",$s,$k);
454 454
 }
455 455
 
456 456
 // sortable table header in "scripts for this host" view
457 457
 function sortheader($key,$name,$extra='') {
458
-	global $MYREQUEST, $MY_SELF_WO_SORT;
458
+    global $MYREQUEST, $MY_SELF_WO_SORT;
459 459
 
460
-	if ($MYREQUEST['SORT1']==$key) {
461
-		$MYREQUEST['SORT2'] = $MYREQUEST['SORT2']=='A' ? 'D' : 'A';
462
-	}
463
-	return "<a class=sortable href=\"$MY_SELF_WO_SORT$extra&SORT1=$key&SORT2=".$MYREQUEST['SORT2']."\">$name</a>";
460
+    if ($MYREQUEST['SORT1']==$key) {
461
+        $MYREQUEST['SORT2'] = $MYREQUEST['SORT2']=='A' ? 'D' : 'A';
462
+    }
463
+    return "<a class=sortable href=\"$MY_SELF_WO_SORT$extra&SORT1=$key&SORT2=".$MYREQUEST['SORT2']."\">$name</a>";
464 464
 
465 465
 }
466 466
 
467 467
 // create menu entry
468 468
 function menu_entry($ob,$title) {
469
-	global $MYREQUEST,$MY_SELF;
470
-	if ($MYREQUEST['OB']!=$ob) {
471
-		return "<li><a href=\"$MY_SELF&OB=$ob\">$title</a></li>";
472
-	} else if (empty($MYREQUEST['SH'])) {
473
-		return "<li><span class=active>$title</span></li>";
474
-	} else {
475
-		return "<li><a class=\"child_active\" href=\"$MY_SELF&OB=$ob\">$title</a></li>";
476
-	}
469
+    global $MYREQUEST,$MY_SELF;
470
+    if ($MYREQUEST['OB']!=$ob) {
471
+        return "<li><a href=\"$MY_SELF&OB=$ob\">$title</a></li>";
472
+    } else if (empty($MYREQUEST['SH'])) {
473
+        return "<li><span class=active>$title</span></li>";
474
+    } else {
475
+        return "<li><a class=\"child_active\" href=\"$MY_SELF&OB=$ob\">$title</a></li>";
476
+    }
477 477
 }
478 478
 
479 479
 function put_login_link($s="Login")
480 480
 {
481
-	global $MY_SELF,$MYREQUEST,$AUTHENTICATED;
482
-	// needs ADMIN_PASSWORD to be changed!
483
-	//
484
-	if (!USE_AUTHENTICATION) {
485
-		return;
486
-	} else if (ADMIN_PASSWORD=='password')
487
-	{
488
-		print <<<EOB
481
+    global $MY_SELF,$MYREQUEST,$AUTHENTICATED;
482
+    // needs ADMIN_PASSWORD to be changed!
483
+    //
484
+    if (!USE_AUTHENTICATION) {
485
+        return;
486
+    } else if (ADMIN_PASSWORD=='password')
487
+    {
488
+        print <<<EOB
489 489
 			<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>
490 490
 EOB;
491
-	} else if ($AUTHENTICATED) {
492
-		print <<<EOB
491
+    } else if ($AUTHENTICATED) {
492
+        print <<<EOB
493 493
 			'{$_SERVER['PHP_AUTH_USER']}'&nbsp;logged&nbsp;in!
494 494
 EOB;
495
-	} else{
496
-		print <<<EOB
495
+    } else{
496
+        print <<<EOB
497 497
 			<a href="$MY_SELF&LO=1&OB={$MYREQUEST['OB']}">$s</a>
498 498
 EOB;
499
-	}
499
+    }
500 500
 }
501 501
 
502 502
 function block_sort($array1, $array2)
503 503
 {
504
-	if ($array1['offset'] > $array2['offset']) {
505
-		return 1;
506
-	} else {
507
-		return -1;
508
-	}
504
+    if ($array1['offset'] > $array2['offset']) {
505
+        return 1;
506
+    } else {
507
+        return -1;
508
+    }
509 509
 }
510 510
 
511 511
 
@@ -729,12 +729,12 @@  discard block
 block discarded – undo
729 729
 	<li><a href="$MY_SELF&OB={$MYREQUEST['OB']}&SH={$MYREQUEST['SH']}">Refresh Data</a></li>
730 730
 EOB;
731 731
 echo
732
-	menu_entry(OB_HOST_STATS,'View Host Stats'),
733
-	menu_entry(OB_USER_CACHE,'User Cache Entries'),
734
-	menu_entry(OB_VERSION_CHECK,'Version Check');
732
+    menu_entry(OB_HOST_STATS,'View Host Stats'),
733
+    menu_entry(OB_USER_CACHE,'User Cache Entries'),
734
+    menu_entry(OB_VERSION_CHECK,'Version Check');
735 735
 
736 736
 if ($AUTHENTICATED) {
737
-	echo <<<EOB
737
+    echo <<<EOB
738 738
 		<li><a class="aright" href="$MY_SELF&CC=1&OB={$MYREQUEST['OB']}" onClick="javascript:return confirm('Are you sure?');">Clear Cache</a></li>
739 739
 EOB;
740 740
 }
@@ -755,40 +755,40 @@  discard block
 block discarded – undo
755 755
 // Host Stats
756 756
 // -----------------------------------------------
757 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'];
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 769
     $size_vars = bsize($cache['mem_size']);
770
-	$i=0;
771
-	echo <<< EOB
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 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
783
+    echo <<<EOB
784 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,25 +810,25 @@  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);
831
+    $size='width='.(GRAPH_SIZE+50).' height='.(GRAPH_SIZE+10);
832 832
 echo <<<EOB
833 833
 		<tr>
834 834
 		<td class=td-0>$mem_note</td>
@@ -836,20 +836,20 @@  discard block
 block discarded – undo
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,284 +860,284 @@  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'];
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 872
                         /* Only consider blocks <5M for the fragmentation % */
873 873
                         if($block['size']<(5*1024*1024)) $fragsize+=$block['size'];
874 874
                         $freetotal+=$block['size'];
875
-		}
876
-		$freeseg += count($mem['block_lists'][$i]);
877
-	}
875
+        }
876
+        $freeseg += count($mem['block_lists'][$i]);
877
+    }
878 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
-	}
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 884
 
885
-	if (graphics_avail()) {
886
-		$size='width='.(2*GRAPH_SIZE+150).' height='.(GRAPH_SIZE+10);
887
-		echo <<<EOB
885
+    if (graphics_avail()) {
886
+        $size='width='.(2*GRAPH_SIZE+150).' height='.(GRAPH_SIZE+10);
887
+        echo <<<EOB
888 888
 			<img alt="" $size src="$PHP_SELF?IMG=3&$time">
889 889
 EOB;
890
-	}
891
-	echo <<<EOB
890
+    }
891
+    echo <<<EOB
892 892
 		</br>Fragmentation: $frag
893 893
 		</td>
894 894
 		</tr>
895 895
 EOB;
896 896
         if(isset($mem['adist'])) {
897
-          foreach($mem['adist'] as $i=>$v) {
897
+            foreach($mem['adist'] as $i=>$v) {
898 898
             $cur = pow(2,$i); $nxt = pow(2,$i+1)-1;
899 899
             if($i==0) $range = "1";
900 900
             else $range = "$cur - $nxt";
901 901
             echo "<tr><th align=right>$range</th><td align=right>$v</td></tr>\n";
902
-          }
902
+            }
903 903
         }
904 904
         echo <<<EOB
905 905
 		</tbody></table>
906 906
 		</div>
907 907
 EOB;
908 908
 
909
-	break;
909
+    break;
910 910
 
911 911
 
912 912
 // -----------------------------------------------
913 913
 // User Cache Entries
914 914
 // -----------------------------------------------
915 915
 case OB_USER_CACHE:
916
-	if (!$AUTHENTICATED) {
916
+    if (!$AUTHENTICATED) {
917 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
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>',
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 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();
995
-
996
-	foreach($cache[$scope_list[$MYREQUEST['SCOPE']]] as $i => $entry) {
997
-		switch($MYREQUEST['SORT1']) {
998
-			case 'A': $k=sprintf('%015d-',$entry['atime']);  	    break;
999
-			case 'H': $k=sprintf('%015d-',$entry['nhits']); 		break;
1000
-			case 'Z': $k=sprintf('%015d-',$entry['mem_size']); 		break;
1001
-			case 'M': $k=sprintf('%015d-',$entry['mtime']);			break;
1002
-			case 'C': $k=sprintf('%015d-',$entry['ctime']);	        break;
1003
-			case 'T': $k=sprintf('%015d-',$entry['ttl']);			break;
1004
-			case 'D': $k=sprintf('%015d-',$entry['dtime']);      	break;
1005
-			case 'S': $k=$entry["key"];								break;
1006
-		}
1007
-		if (!$AUTHENTICATED) {
1008
-			// hide all path entries if not logged in
1009
-			$list[$k.$entry[$fieldname]]=preg_replace('/^.*(\\/|\\\\)/','*hidden*/',$entry);
1010
-		} else {
1011
-			$list[$k.$entry[$fieldname]]=$entry;
1012
-		}
1013
-	}
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();
995
+
996
+    foreach($cache[$scope_list[$MYREQUEST['SCOPE']]] as $i => $entry) {
997
+        switch($MYREQUEST['SORT1']) {
998
+            case 'A': $k=sprintf('%015d-',$entry['atime']);  	    break;
999
+            case 'H': $k=sprintf('%015d-',$entry['nhits']); 		break;
1000
+            case 'Z': $k=sprintf('%015d-',$entry['mem_size']); 		break;
1001
+            case 'M': $k=sprintf('%015d-',$entry['mtime']);			break;
1002
+            case 'C': $k=sprintf('%015d-',$entry['ctime']);	        break;
1003
+            case 'T': $k=sprintf('%015d-',$entry['ttl']);			break;
1004
+            case 'D': $k=sprintf('%015d-',$entry['dtime']);      	break;
1005
+            case 'S': $k=$entry["key"];								break;
1006
+        }
1007
+        if (!$AUTHENTICATED) {
1008
+            // hide all path entries if not logged in
1009
+            $list[$k.$entry[$fieldname]]=preg_replace('/^.*(\\/|\\\\)/','*hidden*/',$entry);
1010
+        } else {
1011
+            $list[$k.$entry[$fieldname]]=$entry;
1012
+        }
1013
+    }
1014
+
1015
+    if ($list) {
1016
+        // sort list
1017
+        //
1018
+        switch ($MYREQUEST['SORT2']) {
1019
+            case "A":	krsort($list);	break;
1020
+            case "D":	ksort($list);	break;
1021
+        }
1014 1022
 
1015
-	if ($list) {
1016
-		// sort list
1017
-		//
1018
-		switch ($MYREQUEST['SORT2']) {
1019
-			case "A":	krsort($list);	break;
1020
-			case "D":	ksort($list);	break;
1021
-		}
1022
-
1023
-		// output list
1024
-		$i=0;
1025
-		foreach($list as $k => $entry) {
1026
-      if(!$MYREQUEST['SEARCH'] || preg_match($MYREQUEST['SEARCH'], $entry[$fieldname]) != 0) {
1027
-		$sh=md5($entry["key"]);
1023
+        // output list
1024
+        $i=0;
1025
+        foreach($list as $k => $entry) {
1026
+        if(!$MYREQUEST['SEARCH'] || preg_match($MYREQUEST['SEARCH'], $entry[$fieldname]) != 0) {
1027
+        $sh=md5($entry["key"]);
1028 1028
         $field_value = htmlentities(strip_tags($entry[$fieldname],''), ENT_QUOTES, 'UTF-8');
1029 1029
         echo
1030
-          '<tr class=tr-',$i%2,'>',
1031
-          "<td class=td-0><a href=\"$MY_SELF&OB=",$MYREQUEST['OB'],"&SH=",$sh,"\">",$field_value,'</a></td>',
1032
-          '<td class="td-n center">',$entry['nhits'],'</td>',
1033
-          '<td class="td-n right">',$entry['mem_size'],'</td>',
1034
-          '<td class="td-n center">',date(DATE_FORMAT,$entry['atime']),'</td>',
1035
-          '<td class="td-n center">',date(DATE_FORMAT,$entry['mtime']),'</td>',
1036
-          '<td class="td-n center">',date(DATE_FORMAT,$entry['ctime']),'</td>';
1030
+            '<tr class=tr-',$i%2,'>',
1031
+            "<td class=td-0><a href=\"$MY_SELF&OB=",$MYREQUEST['OB'],"&SH=",$sh,"\">",$field_value,'</a></td>',
1032
+            '<td class="td-n center">',$entry['nhits'],'</td>',
1033
+            '<td class="td-n right">',$entry['mem_size'],'</td>',
1034
+            '<td class="td-n center">',date(DATE_FORMAT,$entry['atime']),'</td>',
1035
+            '<td class="td-n center">',date(DATE_FORMAT,$entry['mtime']),'</td>',
1036
+            '<td class="td-n center">',date(DATE_FORMAT,$entry['ctime']),'</td>';
1037 1037
 
1038 1038
         if($fieldname=='info') {
1039
-          if($entry['ttl'])
1039
+            if($entry['ttl'])
1040 1040
             echo '<td class="td-n center">'.$entry['ttl'].' seconds</td>';
1041
-          else
1041
+            else
1042 1042
             echo '<td class="td-n center">None</td>';
1043 1043
         }
1044 1044
         if ($entry['dtime']) {
1045 1045
 
1046
-          echo '<td class="td-last center">', date(DATE_FORMAT,$entry['dtime']), '</td>';
1046
+            echo '<td class="td-last center">', date(DATE_FORMAT,$entry['dtime']), '</td>';
1047 1047
         } else if ($MYREQUEST['OB'] == OB_USER_CACHE) {
1048 1048
 
1049
-          echo '<td class="td-last center">';
1050
-          echo '[<a href="', $MY_SELF, '&OB=', $MYREQUEST['OB'], '&DU=', urlencode($entry[$fieldkey]), '">Delete Now</a>]';
1051
-          echo '</td>';
1049
+            echo '<td class="td-last center">';
1050
+            echo '[<a href="', $MY_SELF, '&OB=', $MYREQUEST['OB'], '&DU=', urlencode($entry[$fieldkey]), '">Delete Now</a>]';
1051
+            echo '</td>';
1052 1052
         } else {
1053
-          echo '<td class="td-last center"> &nbsp; </td>';
1053
+            echo '<td class="td-last center"> &nbsp; </td>';
1054 1054
         }
1055 1055
         echo '</tr>';
1056
-		if ($sh == $MYREQUEST["SH"]) {
1057
-			echo '<tr>';
1058
-			echo '<td colspan="7"><pre>'.htmlentities(print_r(apcu_fetch($entry['key']), 1)).'</pre></td>';
1059
-			echo '</tr>';
1060
-		}
1056
+        if ($sh == $MYREQUEST["SH"]) {
1057
+            echo '<tr>';
1058
+            echo '<td colspan="7"><pre>'.htmlentities(print_r(apcu_fetch($entry['key']), 1)).'</pre></td>';
1059
+            echo '</tr>';
1060
+        }
1061 1061
         $i++;
1062 1062
         if ($i == $MYREQUEST['COUNT'])
1063
-          break;
1064
-      }
1065
-		}
1063
+            break;
1064
+        }
1065
+        }
1066 1066
 
1067
-	} else {
1068
-		echo '<tr class=tr-0><td class="center" colspan=',$cols,'><i>No data</i></td></tr>';
1069
-	}
1070
-	echo <<< EOB
1067
+    } else {
1068
+        echo '<tr class=tr-0><td class="center" colspan=',$cols,'><i>No data</i></td></tr>';
1069
+    }
1070
+    echo <<< EOB
1071 1071
 		</tbody></table>
1072 1072
 EOB;
1073 1073
 
1074
-	if ($list && $i < count($list)) {
1075
-		echo "<a href=\"$MY_SELF&OB=",$MYREQUEST['OB'],"&COUNT=0\"><i>",count($list)-$i,' more available...</i></a>';
1076
-	}
1074
+    if ($list && $i < count($list)) {
1075
+        echo "<a href=\"$MY_SELF&OB=",$MYREQUEST['OB'],"&COUNT=0\"><i>",count($list)-$i,' more available...</i></a>';
1076
+    }
1077 1077
 
1078
-	echo <<< EOB
1078
+    echo <<< EOB
1079 1079
 		</div>
1080 1080
 EOB;
1081
-	break;
1081
+    break;
1082 1082
 
1083 1083
 // -----------------------------------------------
1084 1084
 // Version check
1085 1085
 // -----------------------------------------------
1086 1086
 case OB_VERSION_CHECK:
1087
-	echo <<<EOB
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')) {
1094
+    if (defined('PROXY')) {
1095 1095
     $ctxt = stream_context_create( array( 'http' => array( 'proxy' => PROXY, 'request_fulluri' => True ) ) );
1096 1096
     $rss = @file_get_contents("http://pecl.php.net/feeds/pkg_apcu.rss", False, $ctxt);
1097
-  } else {
1097
+    } else {
1098 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.'),
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.