Completed
Push — 0.x ( a2b070...a5c73d )
by Akihito
09:21
created
src/Provide/ApplicationLogger/ResourceLog/Writer/Zf2Log.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -59,7 +59,7 @@
 block discarded – undo
59 59
     }
60 60
 
61 61
     /**
62
-     * @param $hasServerInfo
62
+     * @param boolean $hasServerInfo
63 63
      *
64 64
      * @return string
65 65
      */
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -46,10 +46,10 @@
 block discarded – undo
46 46
         $this->pageId = rtrim(base64_encode(pack('H*', md5($_SERVER['REQUEST_TIME_FLOAT']))), '=');
47 47
         $id = "{$this->pageId}";
48 48
         /** @var $logger \Zend\Log\LoggerInterface */
49
-        $msg = "id:{$id}\treq:" . $request->toUriWithMethod();
50
-        $msg .= "\tcode:" . $result->code;
51
-        $msg .= "\tbody:" . json_encode($result->body);
52
-        $msg .= "\theader:" . json_encode($result->headers);
49
+        $msg = "id:{$id}\treq:".$request->toUriWithMethod();
50
+        $msg .= "\tcode:".$result->code;
51
+        $msg .= "\tbody:".json_encode($result->body);
52
+        $msg .= "\theader:".json_encode($result->headers);
53 53
         $path = $this->getPath(isset($_SERVER['PATH_INFO']));
54 54
         $msg .= "\tpath:$path";
55 55
         try {
Please login to merge, or discard this patch.
src/Provide/ResourceView/DevTemplateEngineRenderer.php 2 patches
Doc Comments   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
      *
228 228
      * @param string $file
229 229
      *
230
-     * @return mixed
230
+     * @return string
231 231
      * @return string
232 232
      */
233 233
     private function makeRelativePath($file)
@@ -240,9 +240,9 @@  discard block
 block discarded – undo
240 240
     /**
241 241
      * Return label
242 242
      *
243
-     * @param                $body
243
+     * @param                string $body
244 244
      * @param ResourceObject $resourceObject
245
-     * @param                $templateFile
245
+     * @param                string $templateFile
246 246
      *
247 247
      * @return string
248 248
      */
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
 
266 266
     /**
267 267
      * @param ResourceObject $resourceObject
268
-     * @param                $labelColor
268
+     * @param                string $labelColor
269 269
      * @param                $templateFile
270 270
      * @param                $body
271 271
      *
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
             $this->templateEngineAdapter->assignAll($resourceObject->body);
182 182
         }
183 183
         // rendering with original render
184
-        $view =  $this->templateEngineRenderer->render($resourceObject);
184
+        $view = $this->templateEngineRenderer->render($resourceObject);
185 185
 
186 186
         // add tool bar
187 187
         $resourceObject->view = $view;
@@ -273,10 +273,10 @@  discard block
 block discarded – undo
273 273
      */
274 274
     private function addResourceMetaInfo(ResourceObject $resourceObject, $labelColor, $templateFile, $body)
275 275
     {
276
-        $resourceName = ($resourceObject->uri ? : get_class($resourceObject));
276
+        $resourceName = ($resourceObject->uri ?: get_class($resourceObject));
277 277
         // code editor
278 278
         $ref = new ReflectionObject($resourceObject);
279
-        $codeFile = ($resourceObject instanceof WeavedInterface) ? $ref->getParentClass()->getFileName(): $ref->getFileName();
279
+        $codeFile = ($resourceObject instanceof WeavedInterface) ? $ref->getParentClass()->getFileName() : $ref->getFileName();
280 280
         $codeFile = $this->makeRelativePath($codeFile);
281 281
         $var = $this->getVar($resourceObject->body);
282 282
         $resourceKey = spl_object_hash($resourceObject);
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
 
285 285
         $resourceBody = preg_replace_callback(
286 286
             '/<!-- resource(.*?)resource_tab_end -->/s',
287
-            function ($matches) {
287
+            function($matches) {
288 288
                 $uri = substr(explode(' ', $matches[1])[0], 1);
289 289
                 preg_match('/ <!-- resource_body_start -->(.*?)<!-- resource_body_end -->/s', $matches[1], $resourceBodyMatch);
290 290
                 return "<!-- resource:$uri -->{$resourceBodyMatch[1]}<!-- /resource:$uri -->";
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
         );
294 294
         $resourceBodyHtml = highlight_string($resourceBody, true);
295 295
         $info = $this->getResourceInfo($resourceObject);
296
-        $rmReturn = function ($str) {
296
+        $rmReturn = function($str) {
297 297
             return str_replace("\n", '', $str);
298 298
         };
299 299
         $result = <<<EOT
@@ -369,16 +369,16 @@  discard block
 block discarded – undo
369 369
         }
370 370
         array_walk_recursive(
371 371
             $body,
372
-            function (&$value) {
372
+            function(&$value) {
373 373
                 if ($value instanceof Request) {
374
-                    $value = '(Request)' . $value->toUri();
374
+                    $value = '(Request)'.$value->toUri();
375 375
                 }
376 376
                 if ($value instanceof ResourceObject) {
377 377
                     $value = $value->body;
378 378
                 }
379 379
                 if (is_object($value)) {
380 380
                     /** @var $value object */
381
-                    $value = '(object) ' . get_class($value);
381
+                    $value = '(object) '.get_class($value);
382 382
                 }
383 383
             }
384 384
         );
@@ -413,7 +413,7 @@  discard block
 block discarded – undo
413 413
      */
414 414
     private function getParamsInfo(ResourceObject $resourceObject)
415 415
     {
416
-        $result = self::BADGE_ARGS . self::DIV_WELL;
416
+        $result = self::BADGE_ARGS.self::DIV_WELL;
417 417
         if (isset($resourceObject->headers[DevInvoker::HEADER_PARAMS])) {
418 418
             $params = json_decode($resourceObject->headers[DevInvoker::HEADER_PARAMS], true);
419 419
         } else {
@@ -441,7 +441,7 @@  discard block
 block discarded – undo
441 441
         /** @noinspection PhpUndefinedVariableInspection */
442 442
         $result .= "<ul>{$paramInfo}</ul>";
443 443
 
444
-        return $result . '</div>';
444
+        return $result.'</div>';
445 445
     }
446 446
 
447 447
     /**
@@ -453,9 +453,9 @@  discard block
 block discarded – undo
453 453
      */
454 454
     private function getInterceptorInfo(ResourceObject $resourceObject)
455 455
     {
456
-        $result = self::BADGE_INTERCEPTORS . self::DIV_WELL;
456
+        $result = self::BADGE_INTERCEPTORS.self::DIV_WELL;
457 457
         if (!isset($resourceObject->headers[DevInvoker::HEADER_INTERCEPTORS])) {
458
-            return $result . 'n/a</div>';
458
+            return $result.'n/a</div>';
459 459
         }
460 460
         $result .= '<ul class="unstyled">';
461 461
         $interceptors = json_decode($resourceObject->headers[DevInvoker::HEADER_INTERCEPTORS], true);
@@ -486,9 +486,9 @@  discard block
 block discarded – undo
486 486
             $resourceObject->headers[CacheLoader::HEADER_CACHE],
487 487
             true
488 488
         ) : false;
489
-        $result = self::BADGE_CACHE . self::DIV_WELL;
489
+        $result = self::BADGE_CACHE.self::DIV_WELL;
490 490
         if ($cache === false) {
491
-            return $result . 'n/a</div>';
491
+            return $result.'n/a</div>';
492 492
         }
493 493
         $iconLife = self::ICON_LIFE;
494 494
         $iconTime = self::ICON_TIME;
@@ -508,7 +508,7 @@  discard block
 block discarded – undo
508 508
             $result .= "Read {$iconLife} {$life} {$iconTime} {$time}";
509 509
         }
510 510
 
511
-        return $result . '</div>';
511
+        return $result.'</div>';
512 512
     }
513 513
 
514 514
     /**
@@ -521,7 +521,7 @@  discard block
 block discarded – undo
521 521
     private function getProfileInfo(ResourceObject $resourceObject)
522 522
     {
523 523
         // memory, time
524
-        $result = self::BADGE_PROFILE . self::DIV_WELL;
524
+        $result = self::BADGE_PROFILE.self::DIV_WELL;
525 525
         if (isset($resourceObject->headers[DevInvoker::HEADER_EXECUTION_TIME])) {
526 526
             $time = number_format($resourceObject->headers[DevInvoker::HEADER_EXECUTION_TIME], 3);
527 527
         } else {
Please login to merge, or discard this patch.
src/Provide/ResourceView/HalFactory.php 1 patch
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -11,7 +11,6 @@
 block discarded – undo
11 11
 use Nocarrier\Hal;
12 12
 use BEAR\Resource\Link;
13 13
 use Ray\Di\Di\Inject;
14
-use Ray\Di\Di\Named;
15 14
 
16 15
 class HalFactory implements HalFactoryInterface
17 16
 {
Please login to merge, or discard this patch.
src/Provide/WebResponse/HttpFoundation.php 2 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -6,7 +6,6 @@
 block discarded – undo
6 6
  */
7 7
 namespace BEAR\Package\Provide\WebResponse;
8 8
 
9
-use BEAR\Resource\ResourceObject as Page;
10 9
 use BEAR\Resource\ResourceObject;
11 10
 use BEAR\Resource\RenderInterface;
12 11
 use BEAR\Sunday\Exception\InvalidResourceType;
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
      */
115 115
     public function render(RenderInterface $renderer = null)
116 116
     {
117
-        $this->view = is_null($renderer) ?  (string) $this->resource : $renderer->render($this->resource);
117
+        $this->view = is_null($renderer) ? (string) $this->resource : $renderer->render($this->resource);
118 118
 
119 119
         return $this;
120 120
     }
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
         // compliant with RFC 2616.
131 131
         $this->response;
132 132
 
133
-        if (! $this->isCli) {
133
+        if (!$this->isCli) {
134 134
             $this->response->send();
135 135
             return $this;
136 136
         }
Please login to merge, or discard this patch.
var/www/admin/apc/apc.php 5 patches
Doc Comments   +4 added lines patch added patch discarded remove patch
@@ -465,6 +465,10 @@
 block discarded – undo
465 465
 }
466 466
 
467 467
 // create menu entry
468
+/**
469
+ * @param integer $ob
470
+ * @param string $title
471
+ */
468 472
 function menu_entry($ob,$title) {
469 473
 	global $MYREQUEST,$MY_SELF;
470 474
 	if ($MYREQUEST['OB']!=$ob) {
Please login to merge, or discard this 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.
Switch Indentation   +318 added lines, -318 removed lines patch added patch discarded remove patch
@@ -329,105 +329,105 @@  discard block
 block discarded – undo
329 329
 
330 330
 	switch ($MYREQUEST['IMG']) {
331 331
 
332
-	case 1:
333
-		$s=$mem['num_seg']*$mem['seg_size'];
334
-		$a=$mem['avail_mem'];
335
-		$x=$y=$size/2;
336
-		$fuzz = 0.000001;
337
-
338
-		// This block of code creates the pie chart.  It is a lot more complex than you
339
-		// would expect because we try to visualize any memory fragmentation as well.
340
-		$angle_from = 0;
341
-		$string_placement=array();
342
-		for($i=0; $i<$mem['num_seg']; $i++) {
343
-			$ptr = 0;
344
-			$free = $mem['block_lists'][$i];
345
-			uasort($free, 'block_sort');
346
-			foreach($free as $block) {
347
-				if($block['offset']!=$ptr) {       // Used block
348
-					$angle_to = $angle_from+($block['offset']-$ptr)/$s;
349
-					if(($angle_to+$fuzz)>1) $angle_to = 1;
350
-					if( ($angle_to*360) - ($angle_from*360) >= 1) {
351
-						fill_arc($image,$x,$y,$size,$angle_from*360,$angle_to*360,$col_black,$col_red);
352
-						if (($angle_to-$angle_from)>0.05) {
353
-							array_push($string_placement, array($angle_from,$angle_to));
354
-						}
355
-					}
356
-					$angle_from = $angle_to;
357
-				}
358
-				$angle_to = $angle_from+($block['size'])/$s;
359
-				if(($angle_to+$fuzz)>1) $angle_to = 1;
360
-				if( ($angle_to*360) - ($angle_from*360) >= 1) {
361
-					fill_arc($image,$x,$y,$size,$angle_from*360,$angle_to*360,$col_black,$col_green);
362
-					if (($angle_to-$angle_from)>0.05) {
363
-						array_push($string_placement, array($angle_from,$angle_to));
364
-					}
365
-				}
366
-				$angle_from = $angle_to;
367
-				$ptr = $block['offset']+$block['size'];
368
-			}
369
-			if ($ptr < $mem['seg_size']) { // memory at the end
370
-				$angle_to = $angle_from + ($mem['seg_size'] - $ptr)/$s;
371
-				if(($angle_to+$fuzz)>1) $angle_to = 1;
372
-				fill_arc($image,$x,$y,$size,$angle_from*360,$angle_to*360,$col_black,$col_red);
373
-				if (($angle_to-$angle_from)>0.05) {
374
-					array_push($string_placement, array($angle_from,$angle_to));
375
-				}
376
-			}
377
-		}
378
-		foreach ($string_placement as $angle) {
379
-			text_arc($image,$x,$y,$size,$angle[0]*360,$angle[1]*360,$col_black,bsize($s*($angle[1]-$angle[0])));
380
-		}
381
-		break;
382
-
383
-	case 2:
384
-		$s=$cache['nhits']+$cache['nmisses'];
385
-		$a=$cache['nhits'];
386
-
387
-		fill_box($image, 30,$size,50,$s ? (-$a*($size-21)/$s) : 0,$col_black,$col_green,sprintf("%.1f%%",$s ? $cache['nhits']*100/$s : 0));
388
-		fill_box($image,130,$size,50,$s ? -max(4,($s-$a)*($size-21)/$s) : 0,$col_black,$col_red,sprintf("%.1f%%",$s ? $cache['nmisses']*100/$s : 0));
389
-		break;
390
-
391
-	case 3:
392
-		$s=$mem['num_seg']*$mem['seg_size'];
393
-		$a=$mem['avail_mem'];
394
-		$x=130;
395
-		$y=1;
396
-		$j=1;
397
-
398
-		// This block of code creates the bar chart.  It is a lot more complex than you
399
-		// would expect because we try to visualize any memory fragmentation as well.
400
-		for($i=0; $i<$mem['num_seg']; $i++) {
401
-			$ptr = 0;
402
-			$free = $mem['block_lists'][$i];
403
-			uasort($free, 'block_sort');
404
-			foreach($free as $block) {
405
-				if($block['offset']!=$ptr) {       // Used block
406
-					$h=(GRAPH_SIZE-5)*($block['offset']-$ptr)/$s;
407
-					if ($h>0) {
408
-                                                $j++;
409
-						if($j<75) fill_box($image,$x,$y,50,$h,$col_black,$col_red,bsize($block['offset']-$ptr),$j);
410
-                                                else fill_box($image,$x,$y,50,$h,$col_black,$col_red);
411
-                                        }
412
-					$y+=$h;
413
-				}
414
-				$h=(GRAPH_SIZE-5)*($block['size'])/$s;
415
-				if ($h>0) {
416
-                                        $j++;
417
-					if($j<75) fill_box($image,$x,$y,50,$h,$col_black,$col_green,bsize($block['size']),$j);
418
-					else fill_box($image,$x,$y,50,$h,$col_black,$col_green);
419
-                                }
420
-				$y+=$h;
421
-				$ptr = $block['offset']+$block['size'];
422
-			}
423
-			if ($ptr < $mem['seg_size']) { // memory at the end
424
-				$h = (GRAPH_SIZE-5) * ($mem['seg_size'] - $ptr) / $s;
425
-				if ($h > 0) {
426
-					fill_box($image,$x,$y,50,$h,$col_black,$col_red,bsize($mem['seg_size']-$ptr),$j++);
427
-				}
428
-			}
429
-		}
430
-		break;
332
+	    case 1:
333
+		    $s=$mem['num_seg']*$mem['seg_size'];
334
+		    $a=$mem['avail_mem'];
335
+		    $x=$y=$size/2;
336
+		    $fuzz = 0.000001;
337
+
338
+		    // This block of code creates the pie chart.  It is a lot more complex than you
339
+		    // would expect because we try to visualize any memory fragmentation as well.
340
+		    $angle_from = 0;
341
+		    $string_placement=array();
342
+		    for($i=0; $i<$mem['num_seg']; $i++) {
343
+			    $ptr = 0;
344
+			    $free = $mem['block_lists'][$i];
345
+			    uasort($free, 'block_sort');
346
+			    foreach($free as $block) {
347
+				    if($block['offset']!=$ptr) {       // Used block
348
+					    $angle_to = $angle_from+($block['offset']-$ptr)/$s;
349
+					    if(($angle_to+$fuzz)>1) $angle_to = 1;
350
+					    if( ($angle_to*360) - ($angle_from*360) >= 1) {
351
+						    fill_arc($image,$x,$y,$size,$angle_from*360,$angle_to*360,$col_black,$col_red);
352
+						    if (($angle_to-$angle_from)>0.05) {
353
+							    array_push($string_placement, array($angle_from,$angle_to));
354
+						    }
355
+					    }
356
+					    $angle_from = $angle_to;
357
+				    }
358
+				    $angle_to = $angle_from+($block['size'])/$s;
359
+				    if(($angle_to+$fuzz)>1) $angle_to = 1;
360
+				    if( ($angle_to*360) - ($angle_from*360) >= 1) {
361
+					    fill_arc($image,$x,$y,$size,$angle_from*360,$angle_to*360,$col_black,$col_green);
362
+					    if (($angle_to-$angle_from)>0.05) {
363
+						    array_push($string_placement, array($angle_from,$angle_to));
364
+					    }
365
+				    }
366
+				    $angle_from = $angle_to;
367
+				    $ptr = $block['offset']+$block['size'];
368
+			    }
369
+			    if ($ptr < $mem['seg_size']) { // memory at the end
370
+				    $angle_to = $angle_from + ($mem['seg_size'] - $ptr)/$s;
371
+				    if(($angle_to+$fuzz)>1) $angle_to = 1;
372
+				    fill_arc($image,$x,$y,$size,$angle_from*360,$angle_to*360,$col_black,$col_red);
373
+				    if (($angle_to-$angle_from)>0.05) {
374
+					    array_push($string_placement, array($angle_from,$angle_to));
375
+				    }
376
+			    }
377
+		    }
378
+		    foreach ($string_placement as $angle) {
379
+			    text_arc($image,$x,$y,$size,$angle[0]*360,$angle[1]*360,$col_black,bsize($s*($angle[1]-$angle[0])));
380
+		    }
381
+		    break;
382
+
383
+	    case 2:
384
+		    $s=$cache['nhits']+$cache['nmisses'];
385
+		    $a=$cache['nhits'];
386
+
387
+		    fill_box($image, 30,$size,50,$s ? (-$a*($size-21)/$s) : 0,$col_black,$col_green,sprintf("%.1f%%",$s ? $cache['nhits']*100/$s : 0));
388
+		    fill_box($image,130,$size,50,$s ? -max(4,($s-$a)*($size-21)/$s) : 0,$col_black,$col_red,sprintf("%.1f%%",$s ? $cache['nmisses']*100/$s : 0));
389
+		    break;
390
+
391
+	    case 3:
392
+		    $s=$mem['num_seg']*$mem['seg_size'];
393
+		    $a=$mem['avail_mem'];
394
+		    $x=130;
395
+		    $y=1;
396
+		    $j=1;
397
+
398
+		    // This block of code creates the bar chart.  It is a lot more complex than you
399
+		    // would expect because we try to visualize any memory fragmentation as well.
400
+		    for($i=0; $i<$mem['num_seg']; $i++) {
401
+			    $ptr = 0;
402
+			    $free = $mem['block_lists'][$i];
403
+			    uasort($free, 'block_sort');
404
+			    foreach($free as $block) {
405
+				    if($block['offset']!=$ptr) {       // Used block
406
+					    $h=(GRAPH_SIZE-5)*($block['offset']-$ptr)/$s;
407
+					    if ($h>0) {
408
+                                                    $j++;
409
+						    if($j<75) fill_box($image,$x,$y,50,$h,$col_black,$col_red,bsize($block['offset']-$ptr),$j);
410
+                                                    else fill_box($image,$x,$y,50,$h,$col_black,$col_red);
411
+                                            }
412
+					    $y+=$h;
413
+				    }
414
+				    $h=(GRAPH_SIZE-5)*($block['size'])/$s;
415
+				    if ($h>0) {
416
+                                            $j++;
417
+					    if($j<75) fill_box($image,$x,$y,50,$h,$col_black,$col_green,bsize($block['size']),$j);
418
+					    else fill_box($image,$x,$y,50,$h,$col_black,$col_green);
419
+                                    }
420
+				    $y+=$h;
421
+				    $ptr = $block['offset']+$block['size'];
422
+			    }
423
+			    if ($ptr < $mem['seg_size']) { // memory at the end
424
+				    $h = (GRAPH_SIZE-5) * ($mem['seg_size'] - $ptr) / $s;
425
+				    if ($h > 0) {
426
+					    fill_box($image,$x,$y,50,$h,$col_black,$col_red,bsize($mem['seg_size']-$ptr),$j++);
427
+				    }
428
+			    }
429
+		    }
430
+		    break;
431 431
 
432 432
 		case 4:
433 433
 			$s=$cache['nhits']+$cache['nmisses'];
@@ -754,41 +754,41 @@  discard block
 block discarded – undo
754 754
 // -----------------------------------------------
755 755
 // Host Stats
756 756
 // -----------------------------------------------
757
-case OB_HOST_STATS:
758
-	$mem_size = $mem['num_seg']*$mem['seg_size'];
759
-	$mem_avail= $mem['avail_mem'];
760
-	$mem_used = $mem_size-$mem_avail;
761
-	$seg_size = bsize($mem['seg_size']);
762
-	$req_rate_user = sprintf("%.2f", $cache['nhits'] ? (($cache['nhits']+$cache['nmisses'])/($time-$cache['stime'])) : 0);
763
-	$hit_rate_user = sprintf("%.2f", $cache['nhits'] ? (($cache['nhits'])/($time-$cache['stime'])) : 0);
764
-	$miss_rate_user = sprintf("%.2f", $cache['nmisses'] ? (($cache['nmisses'])/($time-$cache['stime'])) : 0);
765
-	$insert_rate_user = sprintf("%.2f", $cache['ninserts'] ? (($cache['ninserts'])/($time-$cache['stime'])) : 0);
766
-	$apcversion = phpversion('apcu');
767
-	$phpversion = phpversion();
768
-	$number_vars = $cache['nentries'];
769
-    $size_vars = bsize($cache['mem_size']);
770
-	$i=0;
771
-	echo <<< EOB
757
+    case OB_HOST_STATS:
758
+	    $mem_size = $mem['num_seg']*$mem['seg_size'];
759
+	    $mem_avail= $mem['avail_mem'];
760
+	    $mem_used = $mem_size-$mem_avail;
761
+	    $seg_size = bsize($mem['seg_size']);
762
+	    $req_rate_user = sprintf("%.2f", $cache['nhits'] ? (($cache['nhits']+$cache['nmisses'])/($time-$cache['stime'])) : 0);
763
+	    $hit_rate_user = sprintf("%.2f", $cache['nhits'] ? (($cache['nhits'])/($time-$cache['stime'])) : 0);
764
+	    $miss_rate_user = sprintf("%.2f", $cache['nmisses'] ? (($cache['nmisses'])/($time-$cache['stime'])) : 0);
765
+	    $insert_rate_user = sprintf("%.2f", $cache['ninserts'] ? (($cache['ninserts'])/($time-$cache['stime'])) : 0);
766
+	    $apcversion = phpversion('apcu');
767
+	    $phpversion = phpversion();
768
+	    $number_vars = $cache['nentries'];
769
+        $size_vars = bsize($cache['mem_size']);
770
+	    $i=0;
771
+	    echo <<< EOB
772 772
 		<div class="info div1"><h2>General Cache Information</h2>
773 773
 		<table cellspacing=0><tbody>
774 774
 		<tr class=tr-0><td class=td-0>APCu Version</td><td>$apcversion</td></tr>
775 775
 		<tr class=tr-1><td class=td-0>PHP Version</td><td>$phpversion</td></tr>
776
-EOB;
776
+    EOB;
777 777
 
778
-	if(!empty($_SERVER['SERVER_NAME']))
779
-		echo "<tr class=tr-0><td class=td-0>APCu Host</td><td>{$_SERVER['SERVER_NAME']} $host</td></tr>\n";
780
-	if(!empty($_SERVER['SERVER_SOFTWARE']))
781
-		echo "<tr class=tr-1><td class=td-0>Server Software</td><td>{$_SERVER['SERVER_SOFTWARE']}</td></tr>\n";
778
+	    if(!empty($_SERVER['SERVER_NAME']))
779
+		    echo "<tr class=tr-0><td class=td-0>APCu Host</td><td>{$_SERVER['SERVER_NAME']} $host</td></tr>\n";
780
+	    if(!empty($_SERVER['SERVER_SOFTWARE']))
781
+		    echo "<tr class=tr-1><td class=td-0>Server Software</td><td>{$_SERVER['SERVER_SOFTWARE']}</td></tr>\n";
782 782
 
783
-	echo <<<EOB
784
-		<tr class=tr-0><td class=td-0>Shared Memory</td><td>{$mem['num_seg']} Segment(s) with $seg_size
783
+	    echo <<<EOB
784
+    		<tr class=tr-0><td class=td-0>Shared Memory</td><td>{$mem['num_seg']} Segment(s) with $seg_size
785 785
     <br/> ({$cache['memory_type']} memory)
786 786
     </td></tr>
787 787
 EOB;
788
-	echo   '<tr class=tr-1><td class=td-0>Start Time</td><td>',date(DATE_FORMAT,$cache['stime']),'</td></tr>';
789
-	echo   '<tr class=tr-0><td class=td-0>Uptime</td><td>',duration($cache['stime']),'</td></tr>';
790
-	echo   '<tr class=tr-1><td class=td-0>File Upload Support</td><td>',$cache['file_upload_progress'],'</td></tr>';
791
-	echo <<<EOB
788
+	    echo   '<tr class=tr-1><td class=td-0>Start Time</td><td>',date(DATE_FORMAT,$cache['stime']),'</td></tr>';
789
+	    echo   '<tr class=tr-0><td class=td-0>Uptime</td><td>',duration($cache['stime']),'</td></tr>';
790
+	    echo   '<tr class=tr-1><td class=td-0>File Upload Support</td><td>',$cache['file_upload_progress'],'</td></tr>';
791
+	    echo <<<EOB
792 792
 		</tbody></table>
793 793
 		</div>
794 794
 
@@ -810,46 +810,46 @@  discard block
 block discarded – undo
810 810
 		<div class="info div2"><h2>Runtime Settings</h2><table cellspacing=0><tbody>
811 811
 EOB;
812 812
 
813
-	$j = 0;
814
-	foreach (ini_get_all('apcu') as $k => $v) {
815
-		echo "<tr class=tr-$j><td class=td-0>",$k,"</td><td>",str_replace(',',',<br />',$v['local_value']),"</td></tr>\n";
816
-		$j = 1 - $j;
817
-	}
813
+	    $j = 0;
814
+	    foreach (ini_get_all('apcu') as $k => $v) {
815
+		    echo "<tr class=tr-$j><td class=td-0>",$k,"</td><td>",str_replace(',',',<br />',$v['local_value']),"</td></tr>\n";
816
+		    $j = 1 - $j;
817
+	    }
818 818
 
819
-	if($mem['num_seg']>1 || $mem['num_seg']==1 && count($mem['block_lists'][0])>1)
820
-		$mem_note = "Memory Usage<br /><font size=-2>(multiple slices indicate fragments)</font>";
821
-	else
822
-		$mem_note = "Memory Usage";
819
+	    if($mem['num_seg']>1 || $mem['num_seg']==1 && count($mem['block_lists'][0])>1)
820
+		    $mem_note = "Memory Usage<br /><font size=-2>(multiple slices indicate fragments)</font>";
821
+	    else
822
+		    $mem_note = "Memory Usage";
823 823
 
824
-	echo <<< EOB
824
+	    echo <<< EOB
825 825
 		</tbody></table>
826 826
 		</div>
827 827
 
828 828
 		<div class="graph div3"><h2>Host Status Diagrams</h2>
829 829
 		<table cellspacing=0><tbody>
830 830
 EOB;
831
-	$size='width='.(GRAPH_SIZE+50).' height='.(GRAPH_SIZE+10);
832
-echo <<<EOB
831
+	    $size='width='.(GRAPH_SIZE+50).' height='.(GRAPH_SIZE+10);
832
+    echo <<<EOB
833 833
 		<tr>
834 834
 		<td class=td-0>$mem_note</td>
835 835
 		<td class=td-1>Hits &amp; Misses</td>
836 836
 		</tr>
837 837
 EOB;
838 838
 
839
-	echo
840
-		graphics_avail() ?
841
-			  '<tr>'.
842
-			  "<td class=td-0><img alt=\"\" $size src=\"$PHP_SELF?IMG=1&$time\"></td>".
843
-			  "<td class=td-1><img alt=\"\" $size src=\"$PHP_SELF?IMG=2&$time\"></td></tr>\n"
844
-			: "",
845
-		'<tr>',
846
-		'<td class=td-0><span class="green box">&nbsp;</span>Free: ',bsize($mem_avail).sprintf(" (%.1f%%)",$mem_avail*100/$mem_size),"</td>\n",
847
-		'<td class=td-1><span class="green box">&nbsp;</span>Hits: ',$cache['nhits'].@sprintf(" (%.1f%%)",$cache['nhits']*100/($cache['nhits']+$cache['nmisses'])),"</td>\n",
848
-		'</tr>',
849
-		'<tr>',
850
-		'<td class=td-0><span class="red box">&nbsp;</span>Used: ',bsize($mem_used ).sprintf(" (%.1f%%)",$mem_used *100/$mem_size),"</td>\n",
851
-		'<td class=td-1><span class="red box">&nbsp;</span>Misses: ',$cache['nmisses'].@sprintf(" (%.1f%%)",$cache['nmisses']*100/($cache['nhits']+$cache['nmisses'])),"</td>\n";
852
-	echo <<< EOB
839
+	    echo
840
+		    graphics_avail() ?
841
+			      '<tr>'.
842
+			      "<td class=td-0><img alt=\"\" $size src=\"$PHP_SELF?IMG=1&$time\"></td>".
843
+			      "<td class=td-1><img alt=\"\" $size src=\"$PHP_SELF?IMG=2&$time\"></td></tr>\n"
844
+			    : "",
845
+		    '<tr>',
846
+		    '<td class=td-0><span class="green box">&nbsp;</span>Free: ',bsize($mem_avail).sprintf(" (%.1f%%)",$mem_avail*100/$mem_size),"</td>\n",
847
+		    '<td class=td-1><span class="green box">&nbsp;</span>Hits: ',$cache['nhits'].@sprintf(" (%.1f%%)",$cache['nhits']*100/($cache['nhits']+$cache['nmisses'])),"</td>\n",
848
+		    '</tr>',
849
+		    '<tr>',
850
+		    '<td class=td-0><span class="red box">&nbsp;</span>Used: ',bsize($mem_used ).sprintf(" (%.1f%%)",$mem_used *100/$mem_size),"</td>\n",
851
+		    '<td class=td-1><span class="red box">&nbsp;</span>Misses: ',$cache['nmisses'].@sprintf(" (%.1f%%)",$cache['nmisses']*100/($cache['nhits']+$cache['nmisses'])),"</td>\n";
852
+	    echo <<< EOB
853 853
 		</tr>
854 854
 		</tbody></table>
855 855
 
@@ -860,141 +860,141 @@  discard block
 block discarded – undo
860 860
 		<td class=td-0 colspan=2><br/>
861 861
 EOB;
862 862
 
863
-	// Fragementation: (freeseg - 1) / total_seg
864
-	$nseg = $freeseg = $fragsize = $freetotal = 0;
865
-	for($i=0; $i<$mem['num_seg']; $i++) {
866
-		$ptr = 0;
867
-		foreach($mem['block_lists'][$i] as $block) {
868
-			if ($block['offset'] != $ptr) {
869
-				++$nseg;
870
-			}
871
-			$ptr = $block['offset'] + $block['size'];
872
-                        /* Only consider blocks <5M for the fragmentation % */
873
-                        if($block['size']<(5*1024*1024)) $fragsize+=$block['size'];
874
-                        $freetotal+=$block['size'];
875
-		}
876
-		$freeseg += count($mem['block_lists'][$i]);
877
-	}
878
-
879
-	if ($freeseg > 1) {
880
-		$frag = sprintf("%.2f%% (%s out of %s in %d fragments)", ($fragsize/$freetotal)*100,bsize($fragsize),bsize($freetotal),$freeseg);
881
-	} else {
882
-		$frag = "0%";
883
-	}
884
-
885
-	if (graphics_avail()) {
886
-		$size='width='.(2*GRAPH_SIZE+150).' height='.(GRAPH_SIZE+10);
887
-		echo <<<EOB
888
-			<img alt="" $size src="$PHP_SELF?IMG=3&$time">
889
-EOB;
890
-	}
891
-	echo <<<EOB
892
-		</br>Fragmentation: $frag
863
+	    // Fragementation: (freeseg - 1) / total_seg
864
+	    $nseg = $freeseg = $fragsize = $freetotal = 0;
865
+	    for($i=0; $i<$mem['num_seg']; $i++) {
866
+		    $ptr = 0;
867
+		    foreach($mem['block_lists'][$i] as $block) {
868
+			    if ($block['offset'] != $ptr) {
869
+				    ++$nseg;
870
+			    }
871
+			    $ptr = $block['offset'] + $block['size'];
872
+                            /* Only consider blocks <5M for the fragmentation % */
873
+                            if($block['size']<(5*1024*1024)) $fragsize+=$block['size'];
874
+                            $freetotal+=$block['size'];
875
+		    }
876
+		    $freeseg += count($mem['block_lists'][$i]);
877
+	    }
878
+
879
+	    if ($freeseg > 1) {
880
+		    $frag = sprintf("%.2f%% (%s out of %s in %d fragments)", ($fragsize/$freetotal)*100,bsize($fragsize),bsize($freetotal),$freeseg);
881
+	    } else {
882
+		    $frag = "0%";
883
+	    }
884
+
885
+	    if (graphics_avail()) {
886
+		    $size='width='.(2*GRAPH_SIZE+150).' height='.(GRAPH_SIZE+10);
887
+		    echo <<<EOB
888
+    			<img alt="" $size src="$PHP_SELF?IMG=3&$time">
889
+    EOB;
890
+	    }
891
+	    echo <<<EOB
892
+    		</br>Fragmentation: $frag
893 893
 		</td>
894 894
 		</tr>
895 895
 EOB;
896
-        if(isset($mem['adist'])) {
897
-          foreach($mem['adist'] as $i=>$v) {
898
-            $cur = pow(2,$i); $nxt = pow(2,$i+1)-1;
899
-            if($i==0) $range = "1";
900
-            else $range = "$cur - $nxt";
901
-            echo "<tr><th align=right>$range</th><td align=right>$v</td></tr>\n";
902
-          }
903
-        }
904
-        echo <<<EOB
896
+            if(isset($mem['adist'])) {
897
+              foreach($mem['adist'] as $i=>$v) {
898
+                $cur = pow(2,$i); $nxt = pow(2,$i+1)-1;
899
+                if($i==0) $range = "1";
900
+                else $range = "$cur - $nxt";
901
+                echo "<tr><th align=right>$range</th><td align=right>$v</td></tr>\n";
902
+              }
903
+            }
904
+            echo <<<EOB
905 905
 		</tbody></table>
906 906
 		</div>
907 907
 EOB;
908 908
 
909
-	break;
910
-
911
-
912
-// -----------------------------------------------
913
-// User Cache Entries
914
-// -----------------------------------------------
915
-case OB_USER_CACHE:
916
-	if (!$AUTHENTICATED) {
917
-    echo '<div class="error">You need to login to see the user values here!<br/>&nbsp;<br/>';
918
-		put_login_link("Login now!");
919
-		echo '</div>';
920
-		break;
921
-	}
922
-	$fieldname='key';
923
-	$fieldheading='User Entry Label';
924
-	$fieldkey='key';
925
-
926
-	$cols=6;
927
-	echo <<<EOB
909
+	    break;
910
+
911
+
912
+    // -----------------------------------------------
913
+    // User Cache Entries
914
+    // -----------------------------------------------
915
+    case OB_USER_CACHE:
916
+	    if (!$AUTHENTICATED) {
917
+        echo '<div class="error">You need to login to see the user values here!<br/>&nbsp;<br/>';
918
+		    put_login_link("Login now!");
919
+		    echo '</div>';
920
+		    break;
921
+	    }
922
+	    $fieldname='key';
923
+	    $fieldheading='User Entry Label';
924
+	    $fieldkey='key';
925
+
926
+	    $cols=6;
927
+	    echo <<<EOB
928 928
 		<div class=sorting><form>Scope:
929 929
 		<input type=hidden name=OB value={$MYREQUEST['OB']}>
930 930
 		<select name=SCOPE>
931 931
 EOB;
932
-	echo
933
-		"<option value=A",$MYREQUEST['SCOPE']=='A' ? " selected":"",">Active</option>",
934
-		"<option value=D",$MYREQUEST['SCOPE']=='D' ? " selected":"",">Deleted</option>",
935
-		"</select>",
936
-		", Sorting:<select name=SORT1>",
937
-		"<option value=H",$MYREQUEST['SORT1']=='H' ? " selected":"",">Hits</option>",
938
-		"<option value=Z",$MYREQUEST['SORT1']=='Z' ? " selected":"",">Size</option>",
939
-		"<option value=S",$MYREQUEST['SORT1']=='S' ? " selected":"",">$fieldheading</option>",
940
-		"<option value=A",$MYREQUEST['SORT1']=='A' ? " selected":"",">Last accessed</option>",
941
-		"<option value=M",$MYREQUEST['SORT1']=='M' ? " selected":"",">Last modified</option>",
942
-		"<option value=C",$MYREQUEST['SORT1']=='C' ? " selected":"",">Created at</option>",
943
-		"<option value=D",$MYREQUEST['SORT1']=='D' ? " selected":"",">Deleted at</option>";
944
-	if($fieldname=='info') echo
945
-		"<option value=D",$MYREQUEST['SORT1']=='T' ? " selected":"",">Timeout</option>";
946
-	echo
947
-		'</select>',
948
-		'<select name=SORT2>',
949
-		'<option value=D',$MYREQUEST['SORT2']=='D' ? ' selected':'','>DESC</option>',
950
-		'<option value=A',$MYREQUEST['SORT2']=='A' ? ' selected':'','>ASC</option>',
951
-		'</select>',
952
-		'<select name=COUNT onChange="form.submit()">',
953
-		'<option value=10 ',$MYREQUEST['COUNT']=='10' ? ' selected':'','>Top 10</option>',
954
-		'<option value=20 ',$MYREQUEST['COUNT']=='20' ? ' selected':'','>Top 20</option>',
955
-		'<option value=50 ',$MYREQUEST['COUNT']=='50' ? ' selected':'','>Top 50</option>',
956
-		'<option value=100',$MYREQUEST['COUNT']=='100'? ' selected':'','>Top 100</option>',
957
-		'<option value=150',$MYREQUEST['COUNT']=='150'? ' selected':'','>Top 150</option>',
958
-		'<option value=200',$MYREQUEST['COUNT']=='200'? ' selected':'','>Top 200</option>',
959
-		'<option value=500',$MYREQUEST['COUNT']=='500'? ' selected':'','>Top 500</option>',
960
-		'<option value=0  ',$MYREQUEST['COUNT']=='0'  ? ' selected':'','>All</option>',
961
-		'</select>',
962
-    '&nbsp; Search: <input name=SEARCH value="',$MYREQUEST['SEARCH'],'" type=text size=25/>',
963
-		'&nbsp;<input type=submit value="GO!">',
964
-		'</form></div>';
965
-
966
-  if (isset($MYREQUEST['SEARCH'])) {
967
-   // Don't use preg_quote because we want the user to be able to specify a
968
-   // regular expression subpattern.
969
-   $MYREQUEST['SEARCH'] = '/'.str_replace('/', '\\/', $MYREQUEST['SEARCH']).'/i';
970
-   if (preg_match($MYREQUEST['SEARCH'], 'test') === false) {
971
-     echo '<div class="error">Error: enter a valid regular expression as a search query.</div>';
972
-     break;
973
-   }
974
-  }
975
-
976
-  echo
977
-		'<div class="info"><table cellspacing=0><tbody>',
978
-		'<tr>',
979
-		'<th>',sortheader('S',$fieldheading,  "&OB=".$MYREQUEST['OB']),'</th>',
980
-		'<th>',sortheader('H','Hits',         "&OB=".$MYREQUEST['OB']),'</th>',
981
-		'<th>',sortheader('Z','Size',         "&OB=".$MYREQUEST['OB']),'</th>',
982
-		'<th>',sortheader('A','Last accessed',"&OB=".$MYREQUEST['OB']),'</th>',
983
-		'<th>',sortheader('M','Last modified',"&OB=".$MYREQUEST['OB']),'</th>',
984
-		'<th>',sortheader('C','Created at',   "&OB=".$MYREQUEST['OB']),'</th>';
985
-
986
-	if($fieldname=='info') {
987
-		$cols+=2;
988
-		 echo '<th>',sortheader('T','Timeout',"&OB=".$MYREQUEST['OB']),'</th>';
989
-	}
990
-	echo '<th>',sortheader('D','Deleted at',"&OB=".$MYREQUEST['OB']),'</th></tr>';
991
-
992
-	// builds list with alpha numeric sortable keys
993
-	//
994
-	$list = array();
932
+	    echo
933
+		    "<option value=A",$MYREQUEST['SCOPE']=='A' ? " selected":"",">Active</option>",
934
+		    "<option value=D",$MYREQUEST['SCOPE']=='D' ? " selected":"",">Deleted</option>",
935
+		    "</select>",
936
+		    ", Sorting:<select name=SORT1>",
937
+		    "<option value=H",$MYREQUEST['SORT1']=='H' ? " selected":"",">Hits</option>",
938
+		    "<option value=Z",$MYREQUEST['SORT1']=='Z' ? " selected":"",">Size</option>",
939
+		    "<option value=S",$MYREQUEST['SORT1']=='S' ? " selected":"",">$fieldheading</option>",
940
+		    "<option value=A",$MYREQUEST['SORT1']=='A' ? " selected":"",">Last accessed</option>",
941
+		    "<option value=M",$MYREQUEST['SORT1']=='M' ? " selected":"",">Last modified</option>",
942
+		    "<option value=C",$MYREQUEST['SORT1']=='C' ? " selected":"",">Created at</option>",
943
+		    "<option value=D",$MYREQUEST['SORT1']=='D' ? " selected":"",">Deleted at</option>";
944
+	    if($fieldname=='info') echo
945
+		    "<option value=D",$MYREQUEST['SORT1']=='T' ? " selected":"",">Timeout</option>";
946
+	    echo
947
+		    '</select>',
948
+		    '<select name=SORT2>',
949
+		    '<option value=D',$MYREQUEST['SORT2']=='D' ? ' selected':'','>DESC</option>',
950
+		    '<option value=A',$MYREQUEST['SORT2']=='A' ? ' selected':'','>ASC</option>',
951
+		    '</select>',
952
+		    '<select name=COUNT onChange="form.submit()">',
953
+		    '<option value=10 ',$MYREQUEST['COUNT']=='10' ? ' selected':'','>Top 10</option>',
954
+		    '<option value=20 ',$MYREQUEST['COUNT']=='20' ? ' selected':'','>Top 20</option>',
955
+		    '<option value=50 ',$MYREQUEST['COUNT']=='50' ? ' selected':'','>Top 50</option>',
956
+		    '<option value=100',$MYREQUEST['COUNT']=='100'? ' selected':'','>Top 100</option>',
957
+		    '<option value=150',$MYREQUEST['COUNT']=='150'? ' selected':'','>Top 150</option>',
958
+		    '<option value=200',$MYREQUEST['COUNT']=='200'? ' selected':'','>Top 200</option>',
959
+		    '<option value=500',$MYREQUEST['COUNT']=='500'? ' selected':'','>Top 500</option>',
960
+		    '<option value=0  ',$MYREQUEST['COUNT']=='0'  ? ' selected':'','>All</option>',
961
+		    '</select>',
962
+        '&nbsp; Search: <input name=SEARCH value="',$MYREQUEST['SEARCH'],'" type=text size=25/>',
963
+		    '&nbsp;<input type=submit value="GO!">',
964
+		    '</form></div>';
965
+
966
+      if (isset($MYREQUEST['SEARCH'])) {
967
+       // Don't use preg_quote because we want the user to be able to specify a
968
+       // regular expression subpattern.
969
+       $MYREQUEST['SEARCH'] = '/'.str_replace('/', '\\/', $MYREQUEST['SEARCH']).'/i';
970
+       if (preg_match($MYREQUEST['SEARCH'], 'test') === false) {
971
+         echo '<div class="error">Error: enter a valid regular expression as a search query.</div>';
972
+         break;
973
+       }
974
+      }
995 975
 
996
-	foreach($cache[$scope_list[$MYREQUEST['SCOPE']]] as $i => $entry) {
997
-		switch($MYREQUEST['SORT1']) {
976
+      echo
977
+		    '<div class="info"><table cellspacing=0><tbody>',
978
+		    '<tr>',
979
+		    '<th>',sortheader('S',$fieldheading,  "&OB=".$MYREQUEST['OB']),'</th>',
980
+		    '<th>',sortheader('H','Hits',         "&OB=".$MYREQUEST['OB']),'</th>',
981
+		    '<th>',sortheader('Z','Size',         "&OB=".$MYREQUEST['OB']),'</th>',
982
+		    '<th>',sortheader('A','Last accessed',"&OB=".$MYREQUEST['OB']),'</th>',
983
+		    '<th>',sortheader('M','Last modified',"&OB=".$MYREQUEST['OB']),'</th>',
984
+		    '<th>',sortheader('C','Created at',   "&OB=".$MYREQUEST['OB']),'</th>';
985
+
986
+	    if($fieldname=='info') {
987
+		    $cols+=2;
988
+		     echo '<th>',sortheader('T','Timeout',"&OB=".$MYREQUEST['OB']),'</th>';
989
+	    }
990
+	    echo '<th>',sortheader('D','Deleted at',"&OB=".$MYREQUEST['OB']),'</th></tr>';
991
+
992
+	    // builds list with alpha numeric sortable keys
993
+	    //
994
+	    $list = array();
995
+
996
+	    foreach($cache[$scope_list[$MYREQUEST['SCOPE']]] as $i => $entry) {
997
+		    switch($MYREQUEST['SORT1']) {
998 998
 			case 'A': $k=sprintf('%015d-',$entry['atime']);  	    break;
999 999
 			case 'H': $k=sprintf('%015d-',$entry['nhits']); 		break;
1000 1000
 			case 'Z': $k=sprintf('%015d-',$entry['mem_size']); 		break;
@@ -1003,7 +1003,7 @@  discard block
 block discarded – undo
1003 1003
 			case 'T': $k=sprintf('%015d-',$entry['ttl']);			break;
1004 1004
 			case 'D': $k=sprintf('%015d-',$entry['dtime']);      	break;
1005 1005
 			case 'S': $k=$entry["key"];								break;
1006
-		}
1006
+		    }
1007 1007
 		if (!$AUTHENTICATED) {
1008 1008
 			// hide all path entries if not logged in
1009 1009
 			$list[$k.$entry[$fieldname]]=preg_replace('/^.*(\\/|\\\\)/','*hidden*/',$entry);
@@ -1083,61 +1083,61 @@  discard block
 block discarded – undo
1083 1083
 // -----------------------------------------------
1084 1084
 // Version check
1085 1085
 // -----------------------------------------------
1086
-case OB_VERSION_CHECK:
1087
-	echo <<<EOB
1086
+    case OB_VERSION_CHECK:
1087
+	    echo <<<EOB
1088 1088
 		<div class="info"><h2>APCu Version Information</h2>
1089 1089
 		<table cellspacing=0><tbody>
1090 1090
 		<tr>
1091 1091
 		<th></th>
1092 1092
 		</tr>
1093 1093
 EOB;
1094
-  if (defined('PROXY')) {
1095
-    $ctxt = stream_context_create( array( 'http' => array( 'proxy' => PROXY, 'request_fulluri' => True ) ) );
1096
-    $rss = @file_get_contents("http://pecl.php.net/feeds/pkg_apcu.rss", False, $ctxt);
1097
-  } else {
1098
-    $rss = @file_get_contents("http://pecl.php.net/feeds/pkg_apcu.rss");
1099
-  }
1100
-	if (!$rss) {
1101
-		echo '<tr class="td-last center"><td>Unable to fetch version information.</td></tr>';
1102
-	} else {
1103
-		$apcversion = phpversion('apc');
1104
-
1105
-		preg_match('!<title>APCu ([0-9.]+)</title>!', $rss, $match);
1106
-		echo '<tr class="tr-0 center"><td>';
1107
-		if (version_compare($apcversion, $match[1], '>=')) {
1108
-			echo '<div class="ok">You are running the latest version of APCu ('.$apcversion.')</div>';
1109
-			$i = 3;
1110
-		} else {
1111
-			echo '<div class="failed">You are running an older version of APCu ('.$apcversion.'),
1094
+      if (defined('PROXY')) {
1095
+        $ctxt = stream_context_create( array( 'http' => array( 'proxy' => PROXY, 'request_fulluri' => True ) ) );
1096
+        $rss = @file_get_contents("http://pecl.php.net/feeds/pkg_apcu.rss", False, $ctxt);
1097
+      } else {
1098
+        $rss = @file_get_contents("http://pecl.php.net/feeds/pkg_apcu.rss");
1099
+      }
1100
+	    if (!$rss) {
1101
+		    echo '<tr class="td-last center"><td>Unable to fetch version information.</td></tr>';
1102
+	    } else {
1103
+		    $apcversion = phpversion('apc');
1104
+
1105
+		    preg_match('!<title>APCu ([0-9.]+)</title>!', $rss, $match);
1106
+		    echo '<tr class="tr-0 center"><td>';
1107
+		    if (version_compare($apcversion, $match[1], '>=')) {
1108
+			    echo '<div class="ok">You are running the latest version of APCu ('.$apcversion.')</div>';
1109
+			    $i = 3;
1110
+		    } else {
1111
+			    echo '<div class="failed">You are running an older version of APCu ('.$apcversion.'),
1112 1112
 				newer version '.$match[1].' is available at <a href="http://pecl.php.net/package/APCu/'.$match[1].'">
1113 1113
 				http://pecl.php.net/package/APCu/'.$match[1].'</a>
1114 1114
 				</div>';
1115
-			$i = -1;
1116
-		}
1117
-		echo '</td></tr>';
1118
-		echo '<tr class="tr-0"><td><h3>Change Log:</h3><br/>';
1119
-
1120
-		preg_match_all('!<(title|description)>([^<]+)</\\1>!', $rss, $match);
1121
-		next($match[2]); next($match[2]);
1122
-
1123
-		while (list(,$v) = each($match[2])) {
1124
-			list(,$ver) = explode(' ', $v, 2);
1125
-			if ($i < 0 && version_compare($apcversion, $ver, '>=')) {
1126
-				break;
1127
-			} else if (!$i--) {
1128
-				break;
1129
-			}
1130
-			echo "<b><a href=\"http://pecl.php.net/package/APCu/$ver\">".htmlspecialchars($v, ENT_QUOTES, 'UTF-8')."</a></b><br><blockquote>";
1131
-			echo nl2br(htmlspecialchars(current($match[2]), ENT_QUOTES, 'UTF-8'))."</blockquote>";
1132
-			next($match[2]);
1133
-		}
1134
-		echo '</td></tr>';
1135
-	}
1136
-	echo <<< EOB
1115
+			    $i = -1;
1116
+		    }
1117
+		    echo '</td></tr>';
1118
+		    echo '<tr class="tr-0"><td><h3>Change Log:</h3><br/>';
1119
+
1120
+		    preg_match_all('!<(title|description)>([^<]+)</\\1>!', $rss, $match);
1121
+		    next($match[2]); next($match[2]);
1122
+
1123
+		    while (list(,$v) = each($match[2])) {
1124
+			    list(,$ver) = explode(' ', $v, 2);
1125
+			    if ($i < 0 && version_compare($apcversion, $ver, '>=')) {
1126
+				    break;
1127
+			    } else if (!$i--) {
1128
+				    break;
1129
+			    }
1130
+			    echo "<b><a href=\"http://pecl.php.net/package/APCu/$ver\">".htmlspecialchars($v, ENT_QUOTES, 'UTF-8')."</a></b><br><blockquote>";
1131
+			    echo nl2br(htmlspecialchars(current($match[2]), ENT_QUOTES, 'UTF-8'))."</blockquote>";
1132
+			    next($match[2]);
1133
+		    }
1134
+		    echo '</td></tr>';
1135
+	    }
1136
+	    echo <<< EOB
1137 1137
 		</tbody></table>
1138 1138
 		</div>
1139 1139
 EOB;
1140
-	break;
1140
+	    break;
1141 1141
 
1142 1142
 }
1143 1143
 
Please login to merge, or discard this patch.
Spacing   +284 added lines, -284 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-$autoload = dirname(dirname(__DIR__)) . '/bootstrap/autoload.php';
3
+$autoload = dirname(dirname(__DIR__)).'/bootstrap/autoload.php';
4 4
 if (file_exists($autoload)) {
5 5
     include $autoload;
6 6
 }
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 
29 29
  */
30 30
 
31
-$VERSION='$Id$';
31
+$VERSION = '$Id$';
32 32
 
33 33
 ////////// READ OPTIONAL CONFIGURATION FILE ////////////
34 34
 if (file_exists("apc.conf.php")) include("apc.conf.php");
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 
37 37
 ////////// BEGIN OF DEFAULT CONFIG AREA ///////////////////////////////////////////////////////////
38 38
 
39
-defaults('USE_AUTHENTICATION',0);			// Use (internal) authentication - best choice if
39
+defaults('USE_AUTHENTICATION', 0); // Use (internal) authentication - best choice if
40 40
 											// no other authentication is available
41 41
 											// If set to 0:
42 42
 											//  There will be no further authentication. You
@@ -44,16 +44,16 @@  discard block
 block discarded – undo
44 44
 											// If set to 1:
45 45
 											//  You need to change ADMIN_PASSWORD to make
46 46
 											//  this work!
47
-defaults('ADMIN_USERNAME','apc'); 			// Admin Username
48
-defaults('ADMIN_PASSWORD','password');  	// Admin Password - CHANGE THIS TO ENABLE!!!
47
+defaults('ADMIN_USERNAME', 'apc'); // Admin Username
48
+defaults('ADMIN_PASSWORD', 'password'); // Admin Password - CHANGE THIS TO ENABLE!!!
49 49
 
50 50
 // (beckerr) I'm using a clear text password here, because I've no good idea how to let
51 51
 //           users generate a md5 or crypt password in a easy way to fill it in above
52 52
 
53 53
 //defaults('DATE_FORMAT', "d.m.Y H:i:s");	// German
54
-defaults('DATE_FORMAT', 'Y/m/d H:i:s'); 	// US
54
+defaults('DATE_FORMAT', 'Y/m/d H:i:s'); // US
55 55
 
56
-defaults('GRAPH_SIZE',200);					// Image size
56
+defaults('GRAPH_SIZE', 200); // Image size
57 57
 
58 58
 //defaults('PROXY', 'tcp://127.0.0.1:8080');
59 59
 
@@ -61,45 +61,45 @@  discard block
 block discarded – undo
61 61
 
62 62
 
63 63
 // "define if not defined"
64
-function defaults($d,$v) {
65
-	if (!defined($d)) define($d,$v); // or just @define(...)
64
+function defaults($d, $v) {
65
+	if (!defined($d)) define($d, $v); // or just @define(...)
66 66
 }
67 67
 
68 68
 // rewrite $PHP_SELF to block XSS attacks
69 69
 //
70
-$PHP_SELF= isset($_SERVER['PHP_SELF']) ? htmlentities(strip_tags($_SERVER['PHP_SELF'],''), ENT_QUOTES, 'UTF-8') : '';
70
+$PHP_SELF = isset($_SERVER['PHP_SELF']) ? htmlentities(strip_tags($_SERVER['PHP_SELF'], ''), ENT_QUOTES, 'UTF-8') : '';
71 71
 $time = time();
72 72
 $host = php_uname('n');
73
-if($host) { $host = '('.$host.')'; }
73
+if ($host) { $host = '('.$host.')'; }
74 74
 if (isset($_SERVER['SERVER_ADDR'])) {
75 75
   $host .= ' ('.$_SERVER['SERVER_ADDR'].')';
76 76
 }
77 77
 
78 78
 // operation constants
79
-define('OB_HOST_STATS',1);
80
-define('OB_USER_CACHE',2);
81
-define('OB_VERSION_CHECK',3);
79
+define('OB_HOST_STATS', 1);
80
+define('OB_USER_CACHE', 2);
81
+define('OB_VERSION_CHECK', 3);
82 82
 
83 83
 // check validity of input variables
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
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 98
 	'SEARCH'	=> '~^[a-zA-Z0-9/_.-]*$~'			// aggregation by dir level
99 99
 );
100 100
 
101 101
 // cache scope
102
-$scope_list=array(
102
+$scope_list = array(
103 103
 	'A' => 'cache_list',
104 104
 	'D' => 'deleted_list'
105 105
 );
@@ -118,31 +118,31 @@  discard block
 block discarded – undo
118 118
 }
119 119
 
120 120
 // check parameter syntax
121
-foreach($vardom as $var => $dom) {
121
+foreach ($vardom as $var => $dom) {
122 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];
123
+		$MYREQUEST[$var] = NULL;
124
+	} else if (!is_array($_REQUEST[$var]) && preg_match($dom.'D', $_REQUEST[$var])) {
125
+		$MYREQUEST[$var] = $_REQUEST[$var];
126 126
 	} else {
127
-		$MYREQUEST[$var]=$_REQUEST[$var]=NULL;
127
+		$MYREQUEST[$var] = $_REQUEST[$var] = NULL;
128 128
 	}
129 129
 }
130 130
 
131 131
 // check parameter sematics
132
-if (empty($MYREQUEST['SCOPE'])) $MYREQUEST['SCOPE']="A";
133
-if (empty($MYREQUEST['SORT1'])) $MYREQUEST['SORT1']="H";
134
-if (empty($MYREQUEST['SORT2'])) $MYREQUEST['SORT2']="D";
135
-if (empty($MYREQUEST['OB']))	$MYREQUEST['OB']=OB_HOST_STATS;
136
-if (!isset($MYREQUEST['COUNT'])) $MYREQUEST['COUNT']=20;
137
-if (!isset($scope_list[$MYREQUEST['SCOPE']])) $MYREQUEST['SCOPE']='A';
138
-
139
-$MY_SELF=
132
+if (empty($MYREQUEST['SCOPE'])) $MYREQUEST['SCOPE'] = "A";
133
+if (empty($MYREQUEST['SORT1'])) $MYREQUEST['SORT1'] = "H";
134
+if (empty($MYREQUEST['SORT2'])) $MYREQUEST['SORT2'] = "D";
135
+if (empty($MYREQUEST['OB']))	$MYREQUEST['OB'] = OB_HOST_STATS;
136
+if (!isset($MYREQUEST['COUNT'])) $MYREQUEST['COUNT'] = 20;
137
+if (!isset($scope_list[$MYREQUEST['SCOPE']])) $MYREQUEST['SCOPE'] = 'A';
138
+
139
+$MY_SELF =
140 140
 	"$PHP_SELF".
141 141
 	"?SCOPE=".$MYREQUEST['SCOPE'].
142 142
 	"&SORT1=".$MYREQUEST['SORT1'].
143 143
 	"&SORT2=".$MYREQUEST['SORT2'].
144 144
 	"&COUNT=".$MYREQUEST['COUNT'];
145
-$MY_SELF_WO_SORT=
145
+$MY_SELF_WO_SORT =
146 146
 	"$PHP_SELF".
147 147
 	"?SCOPE=".$MYREQUEST['SCOPE'].
148 148
 	"&COUNT=".$MYREQUEST['COUNT'];
@@ -150,10 +150,10 @@  discard block
 block discarded – undo
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 158
 		if (!isset($_SERVER['PHP_AUTH_USER']) ||
159 159
 			!isset($_SERVER['PHP_AUTH_PW']) ||
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
 			exit;
173 173
 
174 174
 		} else {
175
-			$AUTHENTICATED=1;
175
+			$AUTHENTICATED = 1;
176 176
 		}
177 177
 	}
178 178
 }
@@ -186,39 +186,39 @@  discard block
 block discarded – undo
186 186
 	apcu_delete($MYREQUEST['DU']);
187 187
 }
188 188
 
189
-if(!function_exists('apcu_cache_info')) {
189
+if (!function_exists('apcu_cache_info')) {
190 190
 	echo "No cache info available.  APC does not appear to be running.";
191 191
   exit;
192 192
 }
193 193
 
194 194
 $cache = apcu_cache_info();
195 195
 
196
-$mem=apcu_sma_info();
196
+$mem = apcu_sma_info();
197 197
 
198 198
 // don't cache this page
199 199
 //
200
-header("Cache-Control: no-store, no-cache, must-revalidate");  // HTTP/1.1
200
+header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1
201 201
 header("Cache-Control: post-check=0, pre-check=0", false);
202
-header("Pragma: no-cache");                                    // HTTP/1.0
202
+header("Pragma: no-cache"); // HTTP/1.0
203 203
 
204 204
 function duration($ts) {
205 205
     global $time;
206
-    $years = (int)((($time - $ts)/(7*86400))/52.177457);
207
-    $rem = (int)(($time-$ts)-($years * 52.177457 * 7 * 86400));
208
-    $weeks = (int)(($rem)/(7*86400));
209
-    $days = (int)(($rem)/86400) - $weeks*7;
210
-    $hours = (int)(($rem)/3600) - $days*24 - $weeks*7*24;
211
-    $mins = (int)(($rem)/60) - $hours*60 - $days*24*60 - $weeks*7*24*60;
206
+    $years = (int) ((($time - $ts) / (7 * 86400)) / 52.177457);
207
+    $rem = (int) (($time - $ts) - ($years * 52.177457 * 7 * 86400));
208
+    $weeks = (int) (($rem) / (7 * 86400));
209
+    $days = (int) (($rem) / 86400) - $weeks * 7;
210
+    $hours = (int) (($rem) / 3600) - $days * 24 - $weeks * 7 * 24;
211
+    $mins = (int) (($rem) / 60) - $hours * 60 - $days * 24 * 60 - $weeks * 7 * 24 * 60;
212 212
     $str = '';
213
-    if($years==1) $str .= "$years year, ";
214
-    if($years>1) $str .= "$years years, ";
215
-    if($weeks==1) $str .= "$weeks week, ";
216
-    if($weeks>1) $str .= "$weeks weeks, ";
217
-    if($days==1) $str .= "$days day,";
218
-    if($days>1) $str .= "$days days,";
219
-    if($hours == 1) $str .= " $hours hour and";
220
-    if($hours>1) $str .= " $hours hours and";
221
-    if($mins == 1) $str .= " 1 minute";
213
+    if ($years == 1) $str .= "$years year, ";
214
+    if ($years > 1) $str .= "$years years, ";
215
+    if ($weeks == 1) $str .= "$weeks week, ";
216
+    if ($weeks > 1) $str .= "$weeks weeks, ";
217
+    if ($days == 1) $str .= "$days day,";
218
+    if ($days > 1) $str .= "$days days,";
219
+    if ($hours == 1) $str .= " $hours hour and";
220
+    if ($hours > 1) $str .= " $hours hours and";
221
+    if ($mins == 1) $str .= " 1 minute";
222 222
     else $str .= " $mins minutes";
223 223
     return $str;
224 224
 }
@@ -234,207 +234,207 @@  discard block
 block discarded – undo
234 234
 		exit(0);
235 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);
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 240
 
241 241
 
242 242
 		if (function_exists("imagefilledarc")) {
243 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);
244
+			imagefilledarc($im, $centerX + 1, $centerY + 1, $diameter, $diameter, $start, $end, $color1, IMG_ARC_PIE);
245 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);
246
+			imagefilledarc($im, $centerX, $centerY, $diameter, $diameter, $start, $end, $color1, IMG_ARC_NOFILL | IMG_ARC_EDGED);
247 247
 		} else {
248 248
 			imagearc($im, $centerX, $centerY, $diameter, $diameter, $start, $end, $color2);
249 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);
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 254
 		}
255 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);
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 259
 
260 260
 			} else {
261
-				imagestring($im,4,$centerX + $r*cos($w)/2, $centerY + $r*sin($w)/2,$text,$color1);
261
+				imagestring($im, 4, $centerX + $r * cos($w) / 2, $centerY + $r * sin($w) / 2, $text, $color1);
262 262
 			}
263 263
 		}
264 264
 	}
265 265
 
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);
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 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);
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 273
 
274 274
 		} else {
275
-			imagestring($im,4,$centerX + $r*cos($w)/2, $centerY + $r*sin($w)/2,$text,$color1);
275
+			imagestring($im, 4, $centerX + $r * cos($w) / 2, $centerY + $r * sin($w) / 2, $text, $color1);
276 276
 		}
277 277
 	}
278 278
 
279
-	function fill_box($im, $x, $y, $w, $h, $color1, $color2,$text='',$placeindex='') {
279
+	function fill_box($im, $x, $y, $w, $h, $color1, $color2, $text = '', $placeindex = '') {
280 280
 		global $col_black;
281
-		$x1=$x+$w-1;
282
-		$y1=$y+$h-1;
281
+		$x1 = $x + $w - 1;
282
+		$y1 = $y + $h - 1;
283 283
 
284
-		imagerectangle($im, $x, $y1, $x1+1, $y+1, $col_black);
285
-		if($y1>$y) imagefilledrectangle($im, $x, $y, $x1, $y1, $color2);
284
+		imagerectangle($im, $x, $y1, $x1 + 1, $y + 1, $col_black);
285
+		if ($y1 > $y) imagefilledrectangle($im, $x, $y, $x1, $y1, $color2);
286 286
 		else imagefilledrectangle($im, $x, $y1, $x1, $y, $color2);
287 287
 		imagerectangle($im, $x, $y1, $x1, $y, $color1);
288 288
 		if ($text) {
289
-			if ($placeindex>0) {
289
+			if ($placeindex > 0) {
290 290
 
291
-				if ($placeindex<16)
291
+				if ($placeindex < 16)
292 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);
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 298
 
299 299
 				} else {
300
-					if ($placeindex<31) {
301
-						$px=$x+40*2;
302
-						$py=($placeindex-15)*12+6;
300
+					if ($placeindex < 31) {
301
+						$px = $x + 40 * 2;
302
+						$py = ($placeindex - 15) * 12 + 6;
303 303
 					} else {
304
-						$px=$x+40*2+100*intval(($placeindex-15)/15);
305
-						$py=($placeindex%15)*12+6;
304
+						$px = $x + 40 * 2 + 100 * intval(($placeindex - 15) / 15);
305
+						$py = ($placeindex % 15) * 12 + 6;
306 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);
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 310
 				}
311 311
 			} else {
312
-				imagestring($im,4,$x+5,$y1-16,$text,$color1);
312
+				imagestring($im, 4, $x + 5, $y1 - 16, $text, $color1);
313 313
 			}
314 314
 		}
315 315
 	}
316 316
 
317 317
 
318 318
 	$size = GRAPH_SIZE; // image size
319
-	if ($MYREQUEST['IMG']==3)
320
-		$image = imagecreate(2*$size+150, $size+10);
319
+	if ($MYREQUEST['IMG'] == 3)
320
+		$image = imagecreate(2 * $size + 150, $size + 10);
321 321
 	else
322
-		$image = imagecreate($size+50, $size+10);
322
+		$image = imagecreate($size + 50, $size + 10);
323 323
 
324 324
 	$col_white = imagecolorallocate($image, 0xFF, 0xFF, 0xFF);
325
-	$col_red   = imagecolorallocate($image, 0xD0, 0x60,  0x30);
325
+	$col_red   = imagecolorallocate($image, 0xD0, 0x60, 0x30);
326 326
 	$col_green = imagecolorallocate($image, 0x60, 0xF0, 0x60);
327
-	$col_black = imagecolorallocate($image,   0,   0,   0);
328
-	imagecolortransparent($image,$col_white);
327
+	$col_black = imagecolorallocate($image, 0, 0, 0);
328
+	imagecolortransparent($image, $col_white);
329 329
 
330 330
 	switch ($MYREQUEST['IMG']) {
331 331
 
332 332
 	case 1:
333
-		$s=$mem['num_seg']*$mem['seg_size'];
334
-		$a=$mem['avail_mem'];
335
-		$x=$y=$size/2;
333
+		$s = $mem['num_seg'] * $mem['seg_size'];
334
+		$a = $mem['avail_mem'];
335
+		$x = $y = $size / 2;
336 336
 		$fuzz = 0.000001;
337 337
 
338 338
 		// This block of code creates the pie chart.  It is a lot more complex than you
339 339
 		// would expect because we try to visualize any memory fragmentation as well.
340 340
 		$angle_from = 0;
341
-		$string_placement=array();
342
-		for($i=0; $i<$mem['num_seg']; $i++) {
341
+		$string_placement = array();
342
+		for ($i = 0; $i < $mem['num_seg']; $i++) {
343 343
 			$ptr = 0;
344 344
 			$free = $mem['block_lists'][$i];
345 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));
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 354
 						}
355 355
 					}
356 356
 					$angle_from = $angle_to;
357 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));
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 364
 					}
365 365
 				}
366 366
 				$angle_from = $angle_to;
367
-				$ptr = $block['offset']+$block['size'];
367
+				$ptr = $block['offset'] + $block['size'];
368 368
 			}
369 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));
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 375
 				}
376 376
 			}
377 377
 		}
378 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])));
379
+			text_arc($image, $x, $y, $size, $angle[0] * 360, $angle[1] * 360, $col_black, bsize($s * ($angle[1] - $angle[0])));
380 380
 		}
381 381
 		break;
382 382
 
383 383
 	case 2:
384
-		$s=$cache['nhits']+$cache['nmisses'];
385
-		$a=$cache['nhits'];
384
+		$s = $cache['nhits'] + $cache['nmisses'];
385
+		$a = $cache['nhits'];
386 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));
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 389
 		break;
390 390
 
391 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;
392
+		$s = $mem['num_seg'] * $mem['seg_size'];
393
+		$a = $mem['avail_mem'];
394
+		$x = 130;
395
+		$y = 1;
396
+		$j = 1;
397 397
 
398 398
 		// This block of code creates the bar chart.  It is a lot more complex than you
399 399
 		// would expect because we try to visualize any memory fragmentation as well.
400
-		for($i=0; $i<$mem['num_seg']; $i++) {
400
+		for ($i = 0; $i < $mem['num_seg']; $i++) {
401 401
 			$ptr = 0;
402 402
 			$free = $mem['block_lists'][$i];
403 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) {
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);
410
-                                                else fill_box($image,$x,$y,50,$h,$col_black,$col_red);
409
+						if ($j < 75) fill_box($image, $x, $y, 50, $h, $col_black, $col_red, bsize($block['offset'] - $ptr), $j);
410
+                                                else fill_box($image, $x, $y, 50, $h, $col_black, $col_red);
411 411
                                         }
412
-					$y+=$h;
412
+					$y += $h;
413 413
 				}
414
-				$h=(GRAPH_SIZE-5)*($block['size'])/$s;
415
-				if ($h>0) {
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'];
420
+				$y += $h;
421
+				$ptr = $block['offset'] + $block['size'];
422 422
 			}
423 423
 			if ($ptr < $mem['seg_size']) { // memory at the end
424
-				$h = (GRAPH_SIZE-5) * ($mem['seg_size'] - $ptr) / $s;
424
+				$h = (GRAPH_SIZE - 5) * ($mem['seg_size'] - $ptr) / $s;
425 425
 				if ($h > 0) {
426
-					fill_box($image,$x,$y,50,$h,$col_black,$col_red,bsize($mem['seg_size']-$ptr),$j++);
426
+					fill_box($image, $x, $y, 50, $h, $col_black, $col_red, bsize($mem['seg_size'] - $ptr), $j++);
427 427
 				}
428 428
 			}
429 429
 		}
430 430
 		break;
431 431
 
432 432
 		case 4:
433
-			$s=$cache['nhits']+$cache['nmisses'];
434
-			$a=$cache['nhits'];
433
+			$s = $cache['nhits'] + $cache['nmisses'];
434
+			$a = $cache['nhits'];
435 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));
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 438
 		break;
439 439
 	}
440 440
 
@@ -446,28 +446,28 @@  discard block
 block discarded – undo
446 446
 // pretty printer for byte values
447 447
 //
448 448
 function bsize($s) {
449
-	foreach (array('','K','M','G') as $i => $k) {
449
+	foreach (array('', 'K', 'M', 'G') as $i => $k) {
450 450
 		if ($s < 1024) break;
451
-		$s/=1024;
451
+		$s /= 1024;
452 452
 	}
453
-	return sprintf("%5.1f %sBytes",$s,$k);
453
+	return sprintf("%5.1f %sBytes", $s, $k);
454 454
 }
455 455
 
456 456
 // sortable table header in "scripts for this host" view
457
-function sortheader($key,$name,$extra='') {
457
+function sortheader($key, $name, $extra = '') {
458 458
 	global $MYREQUEST, $MY_SELF_WO_SORT;
459 459
 
460
-	if ($MYREQUEST['SORT1']==$key) {
461
-		$MYREQUEST['SORT2'] = $MYREQUEST['SORT2']=='A' ? 'D' : 'A';
460
+	if ($MYREQUEST['SORT1'] == $key) {
461
+		$MYREQUEST['SORT2'] = $MYREQUEST['SORT2'] == 'A' ? 'D' : 'A';
462 462
 	}
463 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
-function menu_entry($ob,$title) {
469
-	global $MYREQUEST,$MY_SELF;
470
-	if ($MYREQUEST['OB']!=$ob) {
468
+function menu_entry($ob, $title) {
469
+	global $MYREQUEST, $MY_SELF;
470
+	if ($MYREQUEST['OB'] != $ob) {
471 471
 		return "<li><a href=\"$MY_SELF&OB=$ob\">$title</a></li>";
472 472
 	} else if (empty($MYREQUEST['SH'])) {
473 473
 		return "<li><span class=active>$title</span></li>";
@@ -476,14 +476,14 @@  discard block
 block discarded – undo
476 476
 	}
477 477
 }
478 478
 
479
-function put_login_link($s="Login")
479
+function put_login_link($s = "Login")
480 480
 {
481
-	global $MY_SELF,$MYREQUEST,$AUTHENTICATED;
481
+	global $MY_SELF, $MYREQUEST, $AUTHENTICATED;
482 482
 	// needs ADMIN_PASSWORD to be changed!
483 483
 	//
484 484
 	if (!USE_AUTHENTICATION) {
485 485
 		return;
486
-	} else if (ADMIN_PASSWORD=='password')
486
+	} else if (ADMIN_PASSWORD == 'password')
487 487
 	{
488 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>
@@ -492,7 +492,7 @@  discard block
 block discarded – undo
492 492
 		print <<<EOB
493 493
 			'{$_SERVER['PHP_AUTH_USER']}'&nbsp;logged&nbsp;in!
494 494
 EOB;
495
-	} else{
495
+	} else {
496 496
 		print <<<EOB
497 497
 			<a href="$MY_SELF&LO=1&OB={$MYREQUEST['OB']}">$s</a>
498 498
 EOB;
@@ -729,9 +729,9 @@  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 737
 	echo <<<EOB
@@ -755,19 +755,19 @@  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;
758
+	$mem_size = $mem['num_seg'] * $mem['seg_size'];
759
+	$mem_avail = $mem['avail_mem'];
760
+	$mem_used = $mem_size - $mem_avail;
761 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);
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 766
 	$apcversion = phpversion('apcu');
767 767
 	$phpversion = phpversion();
768 768
 	$number_vars = $cache['nentries'];
769 769
     $size_vars = bsize($cache['mem_size']);
770
-	$i=0;
770
+	$i = 0;
771 771
 	echo <<< EOB
772 772
 		<div class="info div1"><h2>General Cache Information</h2>
773 773
 		<table cellspacing=0><tbody>
@@ -775,9 +775,9 @@  discard block
 block discarded – undo
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']))
778
+	if (!empty($_SERVER['SERVER_NAME']))
779 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']))
780
+	if (!empty($_SERVER['SERVER_SOFTWARE']))
781 781
 		echo "<tr class=tr-1><td class=td-0>Server Software</td><td>{$_SERVER['SERVER_SOFTWARE']}</td></tr>\n";
782 782
 
783 783
 	echo <<<EOB
@@ -785,9 +785,9 @@  discard block
 block discarded – undo
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>';
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 791
 	echo <<<EOB
792 792
 		</tbody></table>
793 793
 		</div>
@@ -812,11 +812,11 @@  discard block
 block discarded – undo
812 812
 
813 813
 	$j = 0;
814 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";
815
+		echo "<tr class=tr-$j><td class=td-0>", $k, "</td><td>", str_replace(',', ',<br />', $v['local_value']), "</td></tr>\n";
816 816
 		$j = 1 - $j;
817 817
 	}
818 818
 
819
-	if($mem['num_seg']>1 || $mem['num_seg']==1 && count($mem['block_lists'][0])>1)
819
+	if ($mem['num_seg'] > 1 || $mem['num_seg'] == 1 && count($mem['block_lists'][0]) > 1)
820 820
 		$mem_note = "Memory Usage<br /><font size=-2>(multiple slices indicate fragments)</font>";
821 821
 	else
822 822
 		$mem_note = "Memory Usage";
@@ -828,7 +828,7 @@  discard block
 block discarded – undo
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>
@@ -843,12 +843,12 @@  discard block
 block discarded – undo
843 843
 			  "<td class=td-1><img alt=\"\" $size src=\"$PHP_SELF?IMG=2&$time\"></td></tr>\n"
844 844
 			: "",
845 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",
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 848
 		'</tr>',
849 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";
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 852
 	echo <<< EOB
853 853
 		</tr>
854 854
 		</tbody></table>
@@ -862,28 +862,28 @@  discard block
 block discarded – undo
862 862
 
863 863
 	// Fragementation: (freeseg - 1) / total_seg
864 864
 	$nseg = $freeseg = $fragsize = $freetotal = 0;
865
-	for($i=0; $i<$mem['num_seg']; $i++) {
865
+	for ($i = 0; $i < $mem['num_seg']; $i++) {
866 866
 		$ptr = 0;
867
-		foreach($mem['block_lists'][$i] as $block) {
867
+		foreach ($mem['block_lists'][$i] as $block) {
868 868
 			if ($block['offset'] != $ptr) {
869 869
 				++$nseg;
870 870
 			}
871 871
 			$ptr = $block['offset'] + $block['size'];
872 872
                         /* Only consider blocks <5M for the fragmentation % */
873
-                        if($block['size']<(5*1024*1024)) $fragsize+=$block['size'];
874
-                        $freetotal+=$block['size'];
873
+                        if ($block['size'] < (5 * 1024 * 1024)) $fragsize += $block['size'];
874
+                        $freetotal += $block['size'];
875 875
 		}
876 876
 		$freeseg += count($mem['block_lists'][$i]);
877 877
 	}
878 878
 
879 879
 	if ($freeseg > 1) {
880
-		$frag = sprintf("%.2f%% (%s out of %s in %d fragments)", ($fragsize/$freetotal)*100,bsize($fragsize),bsize($freetotal),$freeseg);
880
+		$frag = sprintf("%.2f%% (%s out of %s in %d fragments)", ($fragsize / $freetotal) * 100, bsize($fragsize), bsize($freetotal), $freeseg);
881 881
 	} else {
882 882
 		$frag = "0%";
883 883
 	}
884 884
 
885 885
 	if (graphics_avail()) {
886
-		$size='width='.(2*GRAPH_SIZE+150).' height='.(GRAPH_SIZE+10);
886
+		$size = 'width='.(2 * GRAPH_SIZE + 150).' height='.(GRAPH_SIZE + 10);
887 887
 		echo <<<EOB
888 888
 			<img alt="" $size src="$PHP_SELF?IMG=3&$time">
889 889
 EOB;
@@ -893,10 +893,10 @@  discard block
 block discarded – undo
893 893
 		</td>
894 894
 		</tr>
895 895
 EOB;
896
-        if(isset($mem['adist'])) {
897
-          foreach($mem['adist'] as $i=>$v) {
898
-            $cur = pow(2,$i); $nxt = pow(2,$i+1)-1;
899
-            if($i==0) $range = "1";
896
+        if (isset($mem['adist'])) {
897
+          foreach ($mem['adist'] as $i=>$v) {
898
+            $cur = pow(2, $i); $nxt = pow(2, $i + 1) - 1;
899
+            if ($i == 0) $range = "1";
900 900
             else $range = "$cur - $nxt";
901 901
             echo "<tr><th align=right>$range</th><td align=right>$v</td></tr>\n";
902 902
           }
@@ -919,47 +919,47 @@  discard block
 block discarded – undo
919 919
 		echo '</div>';
920 920
 		break;
921 921
 	}
922
-	$fieldname='key';
923
-	$fieldheading='User Entry Label';
924
-	$fieldkey='key';
922
+	$fieldname = 'key';
923
+	$fieldheading = 'User Entry Label';
924
+	$fieldkey = 'key';
925 925
 
926
-	$cols=6;
926
+	$cols = 6;
927 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 932
 	echo
933
-		"<option value=A",$MYREQUEST['SCOPE']=='A' ? " selected":"",">Active</option>",
934
-		"<option value=D",$MYREQUEST['SCOPE']=='D' ? " selected":"",">Deleted</option>",
933
+		"<option value=A", $MYREQUEST['SCOPE'] == 'A' ? " selected" : "", ">Active</option>",
934
+		"<option value=D", $MYREQUEST['SCOPE'] == 'D' ? " selected" : "", ">Deleted</option>",
935 935
 		"</select>",
936 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>";
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 946
 	echo
947 947
 		'</select>',
948 948
 		'<select name=SORT2>',
949
-		'<option value=D',$MYREQUEST['SORT2']=='D' ? ' selected':'','>DESC</option>',
950
-		'<option value=A',$MYREQUEST['SORT2']=='A' ? ' selected':'','>ASC</option>',
949
+		'<option value=D', $MYREQUEST['SORT2'] == 'D' ? ' selected' : '', '>DESC</option>',
950
+		'<option value=A', $MYREQUEST['SORT2'] == 'A' ? ' selected' : '', '>ASC</option>',
951 951
 		'</select>',
952 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>',
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 961
 		'</select>',
962
-    '&nbsp; Search: <input name=SEARCH value="',$MYREQUEST['SEARCH'],'" type=text size=25/>',
962
+    '&nbsp; Search: <input name=SEARCH value="', $MYREQUEST['SEARCH'], '" type=text size=25/>',
963 963
 		'&nbsp;<input type=submit value="GO!">',
964 964
 		'</form></div>';
965 965
 
@@ -976,39 +976,39 @@  discard block
 block discarded – undo
976 976
   echo
977 977
 		'<div class="info"><table cellspacing=0><tbody>',
978 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>';
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 989
 	}
990
-	echo '<th>',sortheader('D','Deleted at',"&OB=".$MYREQUEST['OB']),'</th></tr>';
990
+	echo '<th>', sortheader('D', 'Deleted at', "&OB=".$MYREQUEST['OB']), '</th></tr>';
991 991
 
992 992
 	// builds list with alpha numeric sortable keys
993 993
 	//
994 994
 	$list = array();
995 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;
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 1006
 		}
1007 1007
 		if (!$AUTHENTICATED) {
1008 1008
 			// hide all path entries if not logged in
1009
-			$list[$k.$entry[$fieldname]]=preg_replace('/^.*(\\/|\\\\)/','*hidden*/',$entry);
1009
+			$list[$k.$entry[$fieldname]] = preg_replace('/^.*(\\/|\\\\)/', '*hidden*/', $entry);
1010 1010
 		} else {
1011
-			$list[$k.$entry[$fieldname]]=$entry;
1011
+			$list[$k.$entry[$fieldname]] = $entry;
1012 1012
 		}
1013 1013
 	}
1014 1014
 
@@ -1016,34 +1016,34 @@  discard block
 block discarded – undo
1016 1016
 		// sort list
1017 1017
 		//
1018 1018
 		switch ($MYREQUEST['SORT2']) {
1019
-			case "A":	krsort($list);	break;
1020
-			case "D":	ksort($list);	break;
1019
+			case "A":	krsort($list); break;
1020
+			case "D":	ksort($list); break;
1021 1021
 		}
1022 1022
 
1023 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
-        $field_value = htmlentities(strip_tags($entry[$fieldname],''), ENT_QUOTES, 'UTF-8');
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
+        $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>';
1037
-
1038
-        if($fieldname=='info') {
1039
-          if($entry['ttl'])
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
+
1038
+        if ($fieldname == 'info') {
1039
+          if ($entry['ttl'])
1040 1040
             echo '<td class="td-n center">'.$entry['ttl'].' seconds</td>';
1041 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 1049
           echo '<td class="td-last center">';
@@ -1065,14 +1065,14 @@  discard block
 block discarded – undo
1065 1065
 		}
1066 1066
 
1067 1067
 	} else {
1068
-		echo '<tr class=tr-0><td class="center" colspan=',$cols,'><i>No data</i></td></tr>';
1068
+		echo '<tr class=tr-0><td class="center" colspan=', $cols, '><i>No data</i></td></tr>';
1069 1069
 	}
1070 1070
 	echo <<< EOB
1071 1071
 		</tbody></table>
1072 1072
 EOB;
1073 1073
 
1074 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>';
1075
+		echo "<a href=\"$MY_SELF&OB=", $MYREQUEST['OB'], "&COUNT=0\"><i>", count($list) - $i, ' more available...</i></a>';
1076 1076
 	}
1077 1077
 
1078 1078
 	echo <<< EOB
@@ -1092,7 +1092,7 @@  discard block
 block discarded – undo
1092 1092
 		</tr>
1093 1093
 EOB;
1094 1094
   if (defined('PROXY')) {
1095
-    $ctxt = stream_context_create( array( 'http' => array( 'proxy' => PROXY, 'request_fulluri' => True ) ) );
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 1097
   } else {
1098 1098
     $rss = @file_get_contents("http://pecl.php.net/feeds/pkg_apcu.rss");
Please login to merge, or discard this patch.
Braces   +116 added lines, -50 removed lines patch added patch discarded remove patch
@@ -31,7 +31,9 @@  discard block
 block discarded – undo
31 31
 $VERSION='$Id$';
32 32
 
33 33
 ////////// READ OPTIONAL CONFIGURATION FILE ////////////
34
-if (file_exists("apc.conf.php")) include("apc.conf.php");
34
+if (file_exists("apc.conf.php")) {
35
+    include("apc.conf.php");
36
+}
35 37
 ////////////////////////////////////////////////////////
36 38
 
37 39
 ////////// BEGIN OF DEFAULT CONFIG AREA ///////////////////////////////////////////////////////////
@@ -62,7 +64,10 @@  discard block
 block discarded – undo
62 64
 
63 65
 // "define if not defined"
64 66
 function defaults($d,$v) {
65
-	if (!defined($d)) define($d,$v); // or just @define(...)
67
+	if (!defined($d)) {
68
+	    define($d,$v);
69
+	}
70
+	// or just @define(...)
66 71
 }
67 72
 
68 73
 // rewrite $PHP_SELF to block XSS attacks
@@ -129,12 +134,24 @@  discard block
 block discarded – undo
129 134
 }
130 135
 
131 136
 // check parameter sematics
132
-if (empty($MYREQUEST['SCOPE'])) $MYREQUEST['SCOPE']="A";
133
-if (empty($MYREQUEST['SORT1'])) $MYREQUEST['SORT1']="H";
134
-if (empty($MYREQUEST['SORT2'])) $MYREQUEST['SORT2']="D";
135
-if (empty($MYREQUEST['OB']))	$MYREQUEST['OB']=OB_HOST_STATS;
136
-if (!isset($MYREQUEST['COUNT'])) $MYREQUEST['COUNT']=20;
137
-if (!isset($scope_list[$MYREQUEST['SCOPE']])) $MYREQUEST['SCOPE']='A';
137
+if (empty($MYREQUEST['SCOPE'])) {
138
+    $MYREQUEST['SCOPE']="A";
139
+}
140
+if (empty($MYREQUEST['SORT1'])) {
141
+    $MYREQUEST['SORT1']="H";
142
+}
143
+if (empty($MYREQUEST['SORT2'])) {
144
+    $MYREQUEST['SORT2']="D";
145
+}
146
+if (empty($MYREQUEST['OB'])) {
147
+    $MYREQUEST['OB']=OB_HOST_STATS;
148
+}
149
+if (!isset($MYREQUEST['COUNT'])) {
150
+    $MYREQUEST['COUNT']=20;
151
+}
152
+if (!isset($scope_list[$MYREQUEST['SCOPE']])) {
153
+    $MYREQUEST['SCOPE']='A';
154
+}
138 155
 
139 156
 $MY_SELF=
140 157
 	"$PHP_SELF".
@@ -210,16 +227,35 @@  discard block
 block discarded – undo
210 227
     $hours = (int)(($rem)/3600) - $days*24 - $weeks*7*24;
211 228
     $mins = (int)(($rem)/60) - $hours*60 - $days*24*60 - $weeks*7*24*60;
212 229
     $str = '';
213
-    if($years==1) $str .= "$years year, ";
214
-    if($years>1) $str .= "$years years, ";
215
-    if($weeks==1) $str .= "$weeks week, ";
216
-    if($weeks>1) $str .= "$weeks weeks, ";
217
-    if($days==1) $str .= "$days day,";
218
-    if($days>1) $str .= "$days days,";
219
-    if($hours == 1) $str .= " $hours hour and";
220
-    if($hours>1) $str .= " $hours hours and";
221
-    if($mins == 1) $str .= " 1 minute";
222
-    else $str .= " $mins minutes";
230
+    if($years==1) {
231
+        $str .= "$years year, ";
232
+    }
233
+    if($years>1) {
234
+        $str .= "$years years, ";
235
+    }
236
+    if($weeks==1) {
237
+        $str .= "$weeks week, ";
238
+    }
239
+    if($weeks>1) {
240
+        $str .= "$weeks weeks, ";
241
+    }
242
+    if($days==1) {
243
+        $str .= "$days day,";
244
+    }
245
+    if($days>1) {
246
+        $str .= "$days days,";
247
+    }
248
+    if($hours == 1) {
249
+        $str .= " $hours hour and";
250
+    }
251
+    if($hours>1) {
252
+        $str .= " $hours hours and";
253
+    }
254
+    if($mins == 1) {
255
+        $str .= " 1 minute";
256
+    } else {
257
+        $str .= " $mins minutes";
258
+    }
223 259
     return $str;
224 260
 }
225 261
 
@@ -282,8 +318,11 @@  discard block
 block discarded – undo
282 318
 		$y1=$y+$h-1;
283 319
 
284 320
 		imagerectangle($im, $x, $y1, $x1+1, $y+1, $col_black);
285
-		if($y1>$y) imagefilledrectangle($im, $x, $y, $x1, $y1, $color2);
286
-		else imagefilledrectangle($im, $x, $y1, $x1, $y, $color2);
321
+		if($y1>$y) {
322
+		    imagefilledrectangle($im, $x, $y, $x1, $y1, $color2);
323
+		} else {
324
+		    imagefilledrectangle($im, $x, $y1, $x1, $y, $color2);
325
+		}
287 326
 		imagerectangle($im, $x, $y1, $x1, $y, $color1);
288 327
 		if ($text) {
289 328
 			if ($placeindex>0) {
@@ -316,10 +355,11 @@  discard block
 block discarded – undo
316 355
 
317 356
 
318 357
 	$size = GRAPH_SIZE; // image size
319
-	if ($MYREQUEST['IMG']==3)
320
-		$image = imagecreate(2*$size+150, $size+10);
321
-	else
322
-		$image = imagecreate($size+50, $size+10);
358
+	if ($MYREQUEST['IMG']==3) {
359
+			$image = imagecreate(2*$size+150, $size+10);
360
+	} else {
361
+			$image = imagecreate($size+50, $size+10);
362
+	}
323 363
 
324 364
 	$col_white = imagecolorallocate($image, 0xFF, 0xFF, 0xFF);
325 365
 	$col_red   = imagecolorallocate($image, 0xD0, 0x60,  0x30);
@@ -346,7 +386,9 @@  discard block
 block discarded – undo
346 386
 			foreach($free as $block) {
347 387
 				if($block['offset']!=$ptr) {       // Used block
348 388
 					$angle_to = $angle_from+($block['offset']-$ptr)/$s;
349
-					if(($angle_to+$fuzz)>1) $angle_to = 1;
389
+					if(($angle_to+$fuzz)>1) {
390
+					    $angle_to = 1;
391
+					}
350 392
 					if( ($angle_to*360) - ($angle_from*360) >= 1) {
351 393
 						fill_arc($image,$x,$y,$size,$angle_from*360,$angle_to*360,$col_black,$col_red);
352 394
 						if (($angle_to-$angle_from)>0.05) {
@@ -356,7 +398,9 @@  discard block
 block discarded – undo
356 398
 					$angle_from = $angle_to;
357 399
 				}
358 400
 				$angle_to = $angle_from+($block['size'])/$s;
359
-				if(($angle_to+$fuzz)>1) $angle_to = 1;
401
+				if(($angle_to+$fuzz)>1) {
402
+				    $angle_to = 1;
403
+				}
360 404
 				if( ($angle_to*360) - ($angle_from*360) >= 1) {
361 405
 					fill_arc($image,$x,$y,$size,$angle_from*360,$angle_to*360,$col_black,$col_green);
362 406
 					if (($angle_to-$angle_from)>0.05) {
@@ -368,7 +412,9 @@  discard block
 block discarded – undo
368 412
 			}
369 413
 			if ($ptr < $mem['seg_size']) { // memory at the end
370 414
 				$angle_to = $angle_from + ($mem['seg_size'] - $ptr)/$s;
371
-				if(($angle_to+$fuzz)>1) $angle_to = 1;
415
+				if(($angle_to+$fuzz)>1) {
416
+				    $angle_to = 1;
417
+				}
372 418
 				fill_arc($image,$x,$y,$size,$angle_from*360,$angle_to*360,$col_black,$col_red);
373 419
 				if (($angle_to-$angle_from)>0.05) {
374 420
 					array_push($string_placement, array($angle_from,$angle_to));
@@ -406,16 +452,22 @@  discard block
 block discarded – undo
406 452
 					$h=(GRAPH_SIZE-5)*($block['offset']-$ptr)/$s;
407 453
 					if ($h>0) {
408 454
                                                 $j++;
409
-						if($j<75) fill_box($image,$x,$y,50,$h,$col_black,$col_red,bsize($block['offset']-$ptr),$j);
410
-                                                else fill_box($image,$x,$y,50,$h,$col_black,$col_red);
455
+						if($j<75) {
456
+						    fill_box($image,$x,$y,50,$h,$col_black,$col_red,bsize($block['offset']-$ptr),$j);
457
+						} else {
458
+                                                    fill_box($image,$x,$y,50,$h,$col_black,$col_red);
459
+                                                }
411 460
                                         }
412 461
 					$y+=$h;
413 462
 				}
414 463
 				$h=(GRAPH_SIZE-5)*($block['size'])/$s;
415 464
 				if ($h>0) {
416 465
                                         $j++;
417
-					if($j<75) fill_box($image,$x,$y,50,$h,$col_black,$col_green,bsize($block['size']),$j);
418
-					else fill_box($image,$x,$y,50,$h,$col_black,$col_green);
466
+					if($j<75) {
467
+					    fill_box($image,$x,$y,50,$h,$col_black,$col_green,bsize($block['size']),$j);
468
+					} else {
469
+					    fill_box($image,$x,$y,50,$h,$col_black,$col_green);
470
+					}
419 471
                                 }
420 472
 				$y+=$h;
421 473
 				$ptr = $block['offset']+$block['size'];
@@ -447,7 +499,9 @@  discard block
 block discarded – undo
447 499
 //
448 500
 function bsize($s) {
449 501
 	foreach (array('','K','M','G') as $i => $k) {
450
-		if ($s < 1024) break;
502
+		if ($s < 1024) {
503
+		    break;
504
+		}
451 505
 		$s/=1024;
452 506
 	}
453 507
 	return sprintf("%5.1f %sBytes",$s,$k);
@@ -775,10 +829,12 @@  discard block
 block discarded – undo
775 829
 		<tr class=tr-1><td class=td-0>PHP Version</td><td>$phpversion</td></tr>
776 830
 EOB;
777 831
 
778
-	if(!empty($_SERVER['SERVER_NAME']))
779
-		echo "<tr class=tr-0><td class=td-0>APCu Host</td><td>{$_SERVER['SERVER_NAME']} $host</td></tr>\n";
780
-	if(!empty($_SERVER['SERVER_SOFTWARE']))
781
-		echo "<tr class=tr-1><td class=td-0>Server Software</td><td>{$_SERVER['SERVER_SOFTWARE']}</td></tr>\n";
832
+	if(!empty($_SERVER['SERVER_NAME'])) {
833
+			echo "<tr class=tr-0><td class=td-0>APCu Host</td><td>{$_SERVER['SERVER_NAME']} $host</td></tr>\n";
834
+	}
835
+	if(!empty($_SERVER['SERVER_SOFTWARE'])) {
836
+			echo "<tr class=tr-1><td class=td-0>Server Software</td><td>{$_SERVER['SERVER_SOFTWARE']}</td></tr>\n";
837
+	}
782 838
 
783 839
 	echo <<<EOB
784 840
 		<tr class=tr-0><td class=td-0>Shared Memory</td><td>{$mem['num_seg']} Segment(s) with $seg_size
@@ -816,10 +872,11 @@  discard block
 block discarded – undo
816 872
 		$j = 1 - $j;
817 873
 	}
818 874
 
819
-	if($mem['num_seg']>1 || $mem['num_seg']==1 && count($mem['block_lists'][0])>1)
820
-		$mem_note = "Memory Usage<br /><font size=-2>(multiple slices indicate fragments)</font>";
821
-	else
822
-		$mem_note = "Memory Usage";
875
+	if($mem['num_seg']>1 || $mem['num_seg']==1 && count($mem['block_lists'][0])>1) {
876
+			$mem_note = "Memory Usage<br /><font size=-2>(multiple slices indicate fragments)</font>";
877
+	} else {
878
+			$mem_note = "Memory Usage";
879
+	}
823 880
 
824 881
 	echo <<< EOB
825 882
 		</tbody></table>
@@ -870,7 +927,9 @@  discard block
 block discarded – undo
870 927
 			}
871 928
 			$ptr = $block['offset'] + $block['size'];
872 929
                         /* Only consider blocks <5M for the fragmentation % */
873
-                        if($block['size']<(5*1024*1024)) $fragsize+=$block['size'];
930
+                        if($block['size']<(5*1024*1024)) {
931
+                            $fragsize+=$block['size'];
932
+                        }
874 933
                         $freetotal+=$block['size'];
875 934
 		}
876 935
 		$freeseg += count($mem['block_lists'][$i]);
@@ -896,8 +955,11 @@  discard block
 block discarded – undo
896 955
         if(isset($mem['adist'])) {
897 956
           foreach($mem['adist'] as $i=>$v) {
898 957
             $cur = pow(2,$i); $nxt = pow(2,$i+1)-1;
899
-            if($i==0) $range = "1";
900
-            else $range = "$cur - $nxt";
958
+            if($i==0) {
959
+                $range = "1";
960
+            } else {
961
+                $range = "$cur - $nxt";
962
+            }
901 963
             echo "<tr><th align=right>$range</th><td align=right>$v</td></tr>\n";
902 964
           }
903 965
         }
@@ -941,8 +1003,10 @@  discard block
 block discarded – undo
941 1003
 		"<option value=M",$MYREQUEST['SORT1']=='M' ? " selected":"",">Last modified</option>",
942 1004
 		"<option value=C",$MYREQUEST['SORT1']=='C' ? " selected":"",">Created at</option>",
943 1005
 		"<option value=D",$MYREQUEST['SORT1']=='D' ? " selected":"",">Deleted at</option>";
944
-	if($fieldname=='info') echo
1006
+	if($fieldname=='info') {
1007
+	    echo
945 1008
 		"<option value=D",$MYREQUEST['SORT1']=='T' ? " selected":"",">Timeout</option>";
1009
+	}
946 1010
 	echo
947 1011
 		'</select>',
948 1012
 		'<select name=SORT2>',
@@ -1036,10 +1100,11 @@  discard block
 block discarded – undo
1036 1100
           '<td class="td-n center">',date(DATE_FORMAT,$entry['ctime']),'</td>';
1037 1101
 
1038 1102
         if($fieldname=='info') {
1039
-          if($entry['ttl'])
1040
-            echo '<td class="td-n center">'.$entry['ttl'].' seconds</td>';
1041
-          else
1042
-            echo '<td class="td-n center">None</td>';
1103
+          if($entry['ttl']) {
1104
+                      echo '<td class="td-n center">'.$entry['ttl'].' seconds</td>';
1105
+          } else {
1106
+                      echo '<td class="td-n center">None</td>';
1107
+          }
1043 1108
         }
1044 1109
         if ($entry['dtime']) {
1045 1110
 
@@ -1059,8 +1124,9 @@  discard block
 block discarded – undo
1059 1124
 			echo '</tr>';
1060 1125
 		}
1061 1126
         $i++;
1062
-        if ($i == $MYREQUEST['COUNT'])
1063
-          break;
1127
+        if ($i == $MYREQUEST['COUNT']) {
1128
+                  break;
1129
+        }
1064 1130
       }
1065 1131
 		}
1066 1132
 
Please login to merge, or discard this patch.
var/www/admin/memcache/index.php 4 patches
Doc Comments   +10 added lines patch added patch discarded remove patch
@@ -57,6 +57,9 @@  discard block
 block discarded – undo
57 57
 	}
58 58
 }
59 59
 
60
+/**
61
+ * @param string $command
62
+ */
60 63
 function sendMemcacheCommands($command){
61 64
     global $MEMCACHE_SERVERS;
62 65
 	$result = array();
@@ -94,6 +97,9 @@  discard block
 block discarded – undo
94 97
     fclose($s);
95 98
     return parseMemcacheResults($buf);
96 99
 }
100
+/**
101
+ * @param string $str
102
+ */
97 103
 function parseMemcacheResults($str){
98 104
     
99 105
 	$res = array();
@@ -285,6 +291,10 @@  discard block
 block discarded – undo
285 291
 }
286 292
 
287 293
 // create menu entry
294
+/**
295
+ * @param integer $ob
296
+ * @param string $title
297
+ */
288 298
 function menu_entry($ob,$title) {
289 299
 	global $PHP_SELF;
290 300
 	if ($ob==$_GET['op']){
Please login to merge, or discard this 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.
Spacing   +226 added lines, -226 removed lines patch added patch discarded remove patch
@@ -17,13 +17,13 @@  discard block
 block discarded – undo
17 17
   +----------------------------------------------------------------------+
18 18
 */
19 19
 
20
-$VERSION='$Id$';
20
+$VERSION = '$Id$';
21 21
 
22
-define('ADMIN_USERNAME',''); 	// Admin Username
23
-define('ADMIN_PASSWORD','');  	// Admin Password
24
-define('DATE_FORMAT','Y/m/d H:i:s');
25
-define('GRAPH_SIZE',200);
26
-define('MAX_ITEM_DUMP',50);
22
+define('ADMIN_USERNAME', ''); // Admin Username
23
+define('ADMIN_PASSWORD', ''); // Admin Password
24
+define('DATE_FORMAT', 'Y/m/d H:i:s');
25
+define('GRAPH_SIZE', 200);
26
+define('MAX_ITEM_DUMP', 50);
27 27
 
28 28
 $MEMCACHE_SERVERS[] = 'localhost:11211'; // add more as an array
29 29
 
@@ -47,9 +47,9 @@  discard block
 block discarded – undo
47 47
 
48 48
 ///////////MEMCACHE FUNCTIONS /////////////////////////////////////////////////////////////////////
49 49
 
50
-function get_host_port_from_server($server){
50
+function get_host_port_from_server($server) {
51 51
 	$values = explode(':', $server);
52
-	if (($values[0] == 'unix') && (!is_numeric( $values[1]))) {
52
+	if (($values[0] == 'unix') && (!is_numeric($values[1]))) {
53 53
 		return array($server, 0);
54 54
 	}
55 55
 	else {
@@ -57,60 +57,60 @@  discard block
 block discarded – undo
57 57
 	}
58 58
 }
59 59
 
60
-function sendMemcacheCommands($command){
60
+function sendMemcacheCommands($command) {
61 61
     global $MEMCACHE_SERVERS;
62 62
 	$result = array();
63 63
 
64
-	foreach($MEMCACHE_SERVERS as $server){
64
+	foreach ($MEMCACHE_SERVERS as $server) {
65 65
 		$strs = get_host_port_from_server($server);
66 66
 		$host = $strs[0];
67 67
 		$port = $strs[1];
68
-		$result[$server] = sendMemcacheCommand($host,$port,$command);
68
+		$result[$server] = sendMemcacheCommand($host, $port, $command);
69 69
 	}
70 70
 	return $result;
71 71
 }
72
-function sendMemcacheCommand($server,$port,$command){
72
+function sendMemcacheCommand($server, $port, $command) {
73 73
 
74
-	$s = @fsockopen($server,$port);
75
-	if (!$s){
74
+	$s = @fsockopen($server, $port);
75
+	if (!$s) {
76 76
 		die("Cant connect to:".$server.':'.$port);
77 77
 	}
78 78
 
79 79
 	fwrite($s, $command."\r\n");
80 80
 
81
-	$buf='';
81
+	$buf = '';
82 82
 	while ((!feof($s))) {
83 83
 		$buf .= fgets($s, 256);
84
-		if (strpos($buf,"END\r\n")!==false){ // stat says end
84
+		if (strpos($buf, "END\r\n") !== false) { // stat says end
85 85
 		    break;
86 86
 		}
87
-		if (strpos($buf,"DELETED\r\n")!==false || strpos($buf,"NOT_FOUND\r\n")!==false){ // delete says these
87
+		if (strpos($buf, "DELETED\r\n") !== false || strpos($buf, "NOT_FOUND\r\n") !== false) { // delete says these
88 88
 		    break;
89 89
 		}
90
-		if (strpos($buf,"OK\r\n")!==false){ // flush_all says ok
90
+		if (strpos($buf, "OK\r\n") !== false) { // flush_all says ok
91 91
 		    break;
92 92
 		}
93 93
 	}
94 94
     fclose($s);
95 95
     return parseMemcacheResults($buf);
96 96
 }
97
-function parseMemcacheResults($str){
97
+function parseMemcacheResults($str) {
98 98
     
99 99
 	$res = array();
100
-	$lines = explode("\r\n",$str);
100
+	$lines = explode("\r\n", $str);
101 101
 	$cnt = count($lines);
102
-	for($i=0; $i< $cnt; $i++){
102
+	for ($i = 0; $i < $cnt; $i++) {
103 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
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 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];
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 112
 			}
113
-		}elseif($line=='DELETED' || $line=='NOT_FOUND' || $line=='OK'){
113
+		}elseif ($line == 'DELETED' || $line == 'NOT_FOUND' || $line == 'OK') {
114 114
 		    return $line;
115 115
 		}
116 116
 	}
@@ -118,118 +118,118 @@  discard block
 block discarded – undo
118 118
 
119 119
 }
120 120
 
121
-function dumpCacheSlab($server,$slabId,$limit){
122
-    list($host,$port) = get_host_port_from_server($server);
123
-    $resp = sendMemcacheCommand($host,$port,'stats cachedump '.$slabId.' '.$limit);
121
+function dumpCacheSlab($server, $slabId, $limit) {
122
+    list($host, $port) = get_host_port_from_server($server);
123
+    $resp = sendMemcacheCommand($host, $port, 'stats cachedump '.$slabId.' '.$limit);
124 124
 
125 125
    return $resp;
126 126
 
127 127
 }
128 128
 
129
-function flushServer($server){
130
-    list($host,$port) = get_host_port_from_server($server);
131
-    $resp = sendMemcacheCommand($host,$port,'flush_all');
129
+function flushServer($server) {
130
+    list($host, $port) = get_host_port_from_server($server);
131
+    $resp = sendMemcacheCommand($host, $port, 'flush_all');
132 132
     return $resp;
133 133
 }
134
-function getCacheItems(){
134
+function getCacheItems() {
135 135
  $items = sendMemcacheCommands('stats items');
136 136
  $serverItems = array();
137 137
  $totalItems = array();
138
- foreach ($items as $server=>$itemlist){
138
+ foreach ($items as $server=>$itemlist) {
139 139
     $serverItems[$server] = array();
140
-    $totalItems[$server]=0;
141
-    if (!isset($itemlist['STAT'])){
140
+    $totalItems[$server] = 0;
141
+    if (!isset($itemlist['STAT'])) {
142 142
         continue;
143 143
     }
144 144
 
145 145
     $iteminfo = $itemlist['STAT'];
146 146
 
147
-    foreach($iteminfo as $keyinfo=>$value){
148
-        if (preg_match('/items\:(\d+?)\:(.+?)$/',$keyinfo,$matches)){
147
+    foreach ($iteminfo as $keyinfo=>$value) {
148
+        if (preg_match('/items\:(\d+?)\:(.+?)$/', $keyinfo, $matches)) {
149 149
             $serverItems[$server][$matches[1]][$matches[2]] = $value;
150
-            if ($matches[2]=='number'){
151
-                $totalItems[$server] +=$value;
150
+            if ($matches[2] == 'number') {
151
+                $totalItems[$server] += $value;
152 152
             }
153 153
         }
154 154
     }
155 155
  }
156
- return array('items'=>$serverItems,'counts'=>$totalItems);
156
+ return array('items'=>$serverItems, 'counts'=>$totalItems);
157 157
 }
158
-function getMemcacheStats($total=true){
158
+function getMemcacheStats($total = true) {
159 159
 	$resp = sendMemcacheCommands('stats');
160
-	if ($total){
160
+	if ($total) {
161 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;
162
+		foreach ($resp as $server=>$r) {
163
+			foreach ($r['STAT'] as $key=>$row) {
164
+				if (!isset($res[$key])) {
165
+					$res[$key] = null;
166 166
 				}
167
-				switch ($key){
167
+				switch ($key) {
168 168
 					case 'pid':
169
-						$res['pid'][$server]=$row;
169
+						$res['pid'][$server] = $row;
170 170
 						break;
171 171
 					case 'uptime':
172
-						$res['uptime'][$server]=$row;
172
+						$res['uptime'][$server] = $row;
173 173
 						break;
174 174
 					case 'time':
175
-						$res['time'][$server]=$row;
175
+						$res['time'][$server] = $row;
176 176
 						break;
177 177
 					case 'version':
178
-						$res['version'][$server]=$row;
178
+						$res['version'][$server] = $row;
179 179
 						break;
180 180
 					case 'pointer_size':
181
-						$res['pointer_size'][$server]=$row;
181
+						$res['pointer_size'][$server] = $row;
182 182
 						break;
183 183
 					case 'rusage_user':
184
-						$res['rusage_user'][$server]=$row;
184
+						$res['rusage_user'][$server] = $row;
185 185
 						break;
186 186
 					case 'rusage_system':
187
-						$res['rusage_system'][$server]=$row;
187
+						$res['rusage_system'][$server] = $row;
188 188
 						break;
189 189
 					case 'curr_items':
190
-						$res['curr_items']+=$row;
190
+						$res['curr_items'] += $row;
191 191
 						break;
192 192
 					case 'total_items':
193
-						$res['total_items']+=$row;
193
+						$res['total_items'] += $row;
194 194
 						break;
195 195
 					case 'bytes':
196
-						$res['bytes']+=$row;
196
+						$res['bytes'] += $row;
197 197
 						break;
198 198
 					case 'curr_connections':
199
-						$res['curr_connections']+=$row;
199
+						$res['curr_connections'] += $row;
200 200
 						break;
201 201
 					case 'total_connections':
202
-						$res['total_connections']+=$row;
202
+						$res['total_connections'] += $row;
203 203
 						break;
204 204
 					case 'connection_structures':
205
-						$res['connection_structures']+=$row;
205
+						$res['connection_structures'] += $row;
206 206
 						break;
207 207
 					case 'cmd_get':
208
-						$res['cmd_get']+=$row;
208
+						$res['cmd_get'] += $row;
209 209
 						break;
210 210
 					case 'cmd_set':
211
-						$res['cmd_set']+=$row;
211
+						$res['cmd_set'] += $row;
212 212
 						break;
213 213
 					case 'get_hits':
214
-						$res['get_hits']+=$row;
214
+						$res['get_hits'] += $row;
215 215
 						break;
216 216
 					case 'get_misses':
217
-						$res['get_misses']+=$row;
217
+						$res['get_misses'] += $row;
218 218
 						break;
219 219
 					case 'evictions':
220
-						$res['evictions']+=$row;
220
+						$res['evictions'] += $row;
221 221
 						break;
222 222
 					case 'bytes_read':
223
-						$res['bytes_read']+=$row;
223
+						$res['bytes_read'] += $row;
224 224
 						break;
225 225
 					case 'bytes_written':
226
-						$res['bytes_written']+=$row;
226
+						$res['bytes_written'] += $row;
227 227
 						break;
228 228
 					case 'limit_maxbytes':
229
-						$res['limit_maxbytes']+=$row;
229
+						$res['limit_maxbytes'] += $row;
230 230
 						break;
231 231
 					case 'threads':
232
-						$res['rusage_system'][$server]=$row;
232
+						$res['rusage_system'][$server] = $row;
233 233
 						break;
234 234
 				}
235 235
 			}
@@ -244,28 +244,28 @@  discard block
 block discarded – undo
244 244
 //
245 245
 // don't cache this page
246 246
 //
247
-header("Cache-Control: no-store, no-cache, must-revalidate");  // HTTP/1.1
247
+header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1
248 248
 header("Cache-Control: post-check=0, pre-check=0", false);
249
-header("Pragma: no-cache");                                    // HTTP/1.0
249
+header("Pragma: no-cache"); // HTTP/1.0
250 250
 
251 251
 function duration($ts) {
252 252
     global $time;
253
-    $years = (int)((($time - $ts)/(7*86400))/52.177457);
254
-    $rem = (int)(($time-$ts)-($years * 52.177457 * 7 * 86400));
255
-    $weeks = (int)(($rem)/(7*86400));
256
-    $days = (int)(($rem)/86400) - $weeks*7;
257
-    $hours = (int)(($rem)/3600) - $days*24 - $weeks*7*24;
258
-    $mins = (int)(($rem)/60) - $hours*60 - $days*24*60 - $weeks*7*24*60;
253
+    $years = (int) ((($time - $ts) / (7 * 86400)) / 52.177457);
254
+    $rem = (int) (($time - $ts) - ($years * 52.177457 * 7 * 86400));
255
+    $weeks = (int) (($rem) / (7 * 86400));
256
+    $days = (int) (($rem) / 86400) - $weeks * 7;
257
+    $hours = (int) (($rem) / 3600) - $days * 24 - $weeks * 7 * 24;
258
+    $mins = (int) (($rem) / 60) - $hours * 60 - $days * 24 * 60 - $weeks * 7 * 24 * 60;
259 259
     $str = '';
260
-    if($years==1) $str .= "$years year, ";
261
-    if($years>1) $str .= "$years years, ";
262
-    if($weeks==1) $str .= "$weeks week, ";
263
-    if($weeks>1) $str .= "$weeks weeks, ";
264
-    if($days==1) $str .= "$days day,";
265
-    if($days>1) $str .= "$days days,";
266
-    if($hours == 1) $str .= " $hours hour and";
267
-    if($hours>1) $str .= " $hours hours and";
268
-    if($mins == 1) $str .= " 1 minute";
260
+    if ($years == 1) $str .= "$years year, ";
261
+    if ($years > 1) $str .= "$years years, ";
262
+    if ($weeks == 1) $str .= "$weeks week, ";
263
+    if ($weeks > 1) $str .= "$weeks weeks, ";
264
+    if ($days == 1) $str .= "$days day,";
265
+    if ($days > 1) $str .= "$days days,";
266
+    if ($hours == 1) $str .= " $hours hour and";
267
+    if ($hours > 1) $str .= " $hours hours and";
268
+    if ($mins == 1) $str .= " 1 minute";
269 269
     else $str .= " $mins minutes";
270 270
     return $str;
271 271
 }
@@ -277,23 +277,23 @@  discard block
 block discarded – undo
277 277
 }
278 278
 
279 279
 function bsize($s) {
280
-	foreach (array('','K','M','G') as $i => $k) {
280
+	foreach (array('', 'K', 'M', 'G') as $i => $k) {
281 281
 		if ($s < 1024) break;
282
-		$s/=1024;
282
+		$s /= 1024;
283 283
 	}
284
-	return sprintf("%5.1f %sBytes",$s,$k);
284
+	return sprintf("%5.1f %sBytes", $s, $k);
285 285
 }
286 286
 
287 287
 // create menu entry
288
-function menu_entry($ob,$title) {
288
+function menu_entry($ob, $title) {
289 289
 	global $PHP_SELF;
290
-	if ($ob==$_GET['op']){
290
+	if ($ob == $_GET['op']) {
291 291
 	    return "<li><a class=\"child_active\" href=\"$PHP_SELF&op=$ob\">$title</a></li>";
292 292
 	}
293 293
 	return "<li><a class=\"active\" href=\"$PHP_SELF&op=$ob\">$title</a></li>";
294 294
 }
295 295
 
296
-function getHeader(){
296
+function getHeader() {
297 297
     $header = <<<EOB
298 298
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
299 299
 <html>
@@ -490,7 +490,7 @@  discard block
 block discarded – undo
490 490
 
491 491
     return $header;
492 492
 }
493
-function getFooter(){
493
+function getFooter() {
494 494
     global $VERSION;
495 495
     $footer = '</div><!-- Based on apc.php '.$VERSION.'--></body>
496 496
 </html>
@@ -499,10 +499,10 @@  discard block
 block discarded – undo
499 499
     return $footer;
500 500
 
501 501
 }
502
-function getMenu(){
502
+function getMenu() {
503 503
     global $PHP_SELF;
504 504
 echo "<ol class=menu>";
505
-if ($_GET['op']!=4){
505
+if ($_GET['op'] != 4) {
506 506
 echo <<<EOB
507 507
     <li><a href="$PHP_SELF&op={$_GET['op']}">Refresh Data</a></li>
508 508
 EOB;
@@ -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>
@@ -524,26 +524,26 @@  discard block
 block discarded – undo
524 524
 
525 525
 // TODO, AUTH
526 526
 
527
-$_GET['op'] = !isset($_GET['op'])? '1':$_GET['op'];
528
-$PHP_SELF= isset($_SERVER['PHP_SELF']) ? htmlentities(strip_tags($_SERVER['PHP_SELF'],'')) : '';
527
+$_GET['op'] = !isset($_GET['op']) ? '1' : $_GET['op'];
528
+$PHP_SELF = isset($_SERVER['PHP_SELF']) ? htmlentities(strip_tags($_SERVER['PHP_SELF'], '')) : '';
529 529
 
530
-$PHP_SELF=$PHP_SELF.'?';
530
+$PHP_SELF = $PHP_SELF.'?';
531 531
 $time = time();
532 532
 // sanitize _GET
533 533
 
534
-foreach($_GET as $key=>$g){
535
-    $_GET[$key]=htmlentities($g);
534
+foreach ($_GET as $key=>$g) {
535
+    $_GET[$key] = htmlentities($g);
536 536
 }
537 537
 
538 538
 
539 539
 // singleout
540 540
 // when singleout is set, it only gives details for that server.
541
-if (isset($_GET['singleout']) && $_GET['singleout']>=0 && $_GET['singleout'] <count($MEMCACHE_SERVERS)){
541
+if (isset($_GET['singleout']) && $_GET['singleout'] >= 0 && $_GET['singleout'] < count($MEMCACHE_SERVERS)) {
542 542
     $MEMCACHE_SERVERS = array($MEMCACHE_SERVERS[$_GET['singleout']]);
543 543
 }
544 544
 
545 545
 // display images
546
-if (isset($_GET['IMG'])){
546
+if (isset($_GET['IMG'])) {
547 547
     $memcacheStats = getMemcacheStats();
548 548
     $memcacheStatsSingle = getMemcacheStats(false);
549 549
 
@@ -551,110 +551,110 @@  discard block
 block discarded – undo
551 551
 		exit(0);
552 552
 	}
553 553
 
554
-	function fill_box($im, $x, $y, $w, $h, $color1, $color2,$text='',$placeindex='') {
554
+	function fill_box($im, $x, $y, $w, $h, $color1, $color2, $text = '', $placeindex = '') {
555 555
 		global $col_black;
556
-		$x1=$x+$w-1;
557
-		$y1=$y+$h-1;
556
+		$x1 = $x + $w - 1;
557
+		$y1 = $y + $h - 1;
558 558
 
559
-		imagerectangle($im, $x, $y1, $x1+1, $y+1, $col_black);
560
-		if($y1>$y) imagefilledrectangle($im, $x, $y, $x1, $y1, $color2);
559
+		imagerectangle($im, $x, $y1, $x1 + 1, $y + 1, $col_black);
560
+		if ($y1 > $y) imagefilledrectangle($im, $x, $y, $x1, $y1, $color2);
561 561
 		else imagefilledrectangle($im, $x, $y1, $x1, $y, $color2);
562 562
 		imagerectangle($im, $x, $y1, $x1, $y, $color1);
563 563
 		if ($text) {
564
-			if ($placeindex>0) {
564
+			if ($placeindex > 0) {
565 565
 
566
-				if ($placeindex<16)
566
+				if ($placeindex < 16)
567 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);
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 573
 
574 574
 				} else {
575
-					if ($placeindex<31) {
576
-						$px=$x+40*2;
577
-						$py=($placeindex-15)*12+6;
575
+					if ($placeindex < 31) {
576
+						$px = $x + 40 * 2;
577
+						$py = ($placeindex - 15) * 12 + 6;
578 578
 					} else {
579
-						$px=$x+40*2+100*intval(($placeindex-15)/15);
580
-						$py=($placeindex%15)*12+6;
579
+						$px = $x + 40 * 2 + 100 * intval(($placeindex - 15) / 15);
580
+						$py = ($placeindex % 15) * 12 + 6;
581 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);
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 585
 				}
586 586
 			} else {
587
-				imagestring($im,4,$x+5,$y1-16,$text,$color1);
587
+				imagestring($im, 4, $x + 5, $y1 - 16, $text, $color1);
588 588
 			}
589 589
 		}
590 590
 	}
591 591
 
592 592
 
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);
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 596
 
597 597
 
598 598
 		if (function_exists("imagefilledarc")) {
599 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);
600
+			imagefilledarc($im, $centerX + 1, $centerY + 1, $diameter, $diameter, $start, $end, $color1, IMG_ARC_PIE);
601 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);
602
+			imagefilledarc($im, $centerX, $centerY, $diameter, $diameter, $start, $end, $color1, IMG_ARC_NOFILL | IMG_ARC_EDGED);
603 603
 		} else {
604 604
 			imagearc($im, $centerX, $centerY, $diameter, $diameter, $start, $end, $color2);
605 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);
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 610
 		}
611 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);
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 615
 
616 616
 			} else {
617
-				imagestring($im,4,$centerX + $r*cos($w)/2, $centerY + $r*sin($w)/2,$text,$color1);
617
+				imagestring($im, 4, $centerX + $r * cos($w) / 2, $centerY + $r * sin($w) / 2, $text, $color1);
618 618
 			}
619 619
 		}
620 620
 	}
621 621
 	$size = GRAPH_SIZE; // image size
622
-	$image = imagecreate($size+50, $size+10);
622
+	$image = imagecreate($size + 50, $size + 10);
623 623
 
624 624
 	$col_white = imagecolorallocate($image, 0xFF, 0xFF, 0xFF);
625
-	$col_red   = imagecolorallocate($image, 0xD0, 0x60,  0x30);
625
+	$col_red   = imagecolorallocate($image, 0xD0, 0x60, 0x30);
626 626
 	$col_green = imagecolorallocate($image, 0x60, 0xF0, 0x60);
627
-	$col_black = imagecolorallocate($image,   0,   0,   0);
627
+	$col_black = imagecolorallocate($image, 0, 0, 0);
628 628
 
629
-	imagecolortransparent($image,$col_white);
629
+	imagecolortransparent($image, $col_white);
630 630
 
631
-    switch ($_GET['IMG']){
631
+    switch ($_GET['IMG']) {
632 632
         case 1: // pie chart
633
-            $tsize=$memcacheStats['limit_maxbytes'];
634
-    		$avail=$tsize-$memcacheStats['bytes'];
635
-    		$x=$y=$size/2;
633
+            $tsize = $memcacheStats['limit_maxbytes'];
634
+    		$avail = $tsize - $memcacheStats['bytes'];
635
+    		$x = $y = $size / 2;
636 636
     		$angle_from = 0;
637 637
     		$fuzz = 0.000001;
638 638
 
639
-            foreach($memcacheStatsSingle as $serv=>$mcs) {
640
-    			$free = $mcs['STAT']['limit_maxbytes']-$mcs['STAT']['bytes'];
639
+            foreach ($memcacheStatsSingle as $serv=>$mcs) {
640
+    			$free = $mcs['STAT']['limit_maxbytes'] - $mcs['STAT']['bytes'];
641 641
     			$used = $mcs['STAT']['bytes'];
642 642
 
643 643
 
644
-                if ($free>0){
644
+                if ($free > 0) {
645 645
     			// draw free
646
-    			    $angle_to = ($free*360)/$tsize;
647
-                    $perc =sprintf("%.2f%%", ($free *100) / $tsize) ;
646
+    			    $angle_to = ($free * 360) / $tsize;
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){
652
+    			if ($used > 0) {
653 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
-                    $angle_from = $angle_from+ $angle_to ;
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
+                    $angle_from = $angle_from + $angle_to;
658 658
     			}
659 659
     			}
660 660
 
@@ -662,12 +662,12 @@  discard block
 block discarded – undo
662 662
 
663 663
         case 2: // hit miss
664 664
 
665
-            $hits = ($memcacheStats['get_hits']==0) ? 1:$memcacheStats['get_hits'];
666
-            $misses = ($memcacheStats['get_misses']==0) ? 1:$memcacheStats['get_misses'];
667
-            $total = $hits + $misses ;
665
+            $hits = ($memcacheStats['get_hits'] == 0) ? 1 : $memcacheStats['get_hits'];
666
+            $misses = ($memcacheStats['get_misses'] == 0) ? 1 : $memcacheStats['get_misses'];
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));
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 671
 		break;
672 672
 		
673 673
     }
@@ -688,36 +688,36 @@  discard block
 block discarded – undo
688 688
 
689 689
         $mem_size = $memcacheStats['limit_maxbytes'];
690 690
     	$mem_used = $memcacheStats['bytes'];
691
-	    $mem_avail= $mem_size-$mem_used;
692
-	    $startTime = time()-array_sum($memcacheStats['uptime']);
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'];
696
-        $hits = ($memcacheStats['get_hits']==0) ? 1:$memcacheStats['get_hits'];
697
-        $misses = ($memcacheStats['get_misses']==0) ? 1:$memcacheStats['get_misses'];
696
+        $hits = ($memcacheStats['get_hits'] == 0) ? 1 : $memcacheStats['get_hits'];
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 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/>';
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 715
     		}
716 716
 		}
717
-		else{
717
+		else {
718 718
 		    echo '1.'.$MEMCACHE_SERVERS[0];
719 719
 		}
720
-		if (isset($_GET['singleout'])){
720
+		if (isset($_GET['singleout'])) {
721 721
 		      echo '<a href="'.$PHP_SELF.'">(all servers)</a><br/>';
722 722
 		}
723 723
 		echo "</td></tr>\n";
@@ -729,14 +729,14 @@  discard block
 block discarded – undo
729 729
 
730 730
 		<div class="info div1"><h2>Memcache Server Information</h2>
731 731
 EOB;
732
-        foreach($MEMCACHE_SERVERS as $server){
732
+        foreach ($MEMCACHE_SERVERS as $server) {
733 733
             echo '<table cellspacing=0><tbody>';
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>';
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 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>';
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 740
     		echo '</tbody></table>';
741 741
 	   }
742 742
     echo <<<EOB
@@ -746,7 +746,7 @@  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);
749
+	$size = 'width='.(GRAPH_SIZE + 50).' height='.(GRAPH_SIZE + 10);
750 750
 	echo <<<EOB
751 751
 		<tr>
752 752
 		<td class=td-0>Cache Usage</td>
@@ -757,16 +757,16 @@  discard block
 block discarded – undo
757 757
 	echo
758 758
 		graphics_avail() ?
759 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"
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 762
 			: "",
763 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",
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 766
 		'</tr>',
767 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";
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 770
 		echo <<< EOB
771 771
 	</tr>
772 772
 	</tbody></table>
@@ -789,12 +789,12 @@  discard block
 block discarded – undo
789 789
 
790 790
     case 2: // variables
791 791
 
792
-		$m=0;
793
-		$cacheItems= getCacheItems();
792
+		$m = 0;
793
+		$cacheItems = getCacheItems();
794 794
 		$items = $cacheItems['items'];
795 795
 		$totals = $cacheItems['counts'];
796 796
 		$maxDump = MAX_ITEM_DUMP;
797
-		foreach($items as $server => $entries) {
797
+		foreach ($items as $server => $entries) {
798 798
 
799 799
     	echo <<< EOB
800 800
 
@@ -803,33 +803,33 @@  discard block
 block discarded – undo
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;
806
+			foreach ($entries as $slabId => $slab) {
807
+			    $dumpUrl = $PHP_SELF.'&op=2&server='.(array_search($server, $MEMCACHE_SERVERS)).'&dumpslab='.$slabId;
808 808
 				echo
809 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))){
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 813
 					    echo "<br/><b>Items: item</b><br/>";
814
-					    $items = dumpCacheSlab($server,$slabId,$slab['number']);
814
+					    $items = dumpCacheSlab($server, $slabId, $slab['number']);
815 815
                         // maybe someone likes to do a pagination here :)
816
-					    $i=1;
817
-                        foreach($items['ITEM'] as $itemKey=>$itemInfo){
818
-                            $itemInfo = trim($itemInfo,'[ ]');
816
+					    $i = 1;
817
+                        foreach ($items['ITEM'] as $itemKey=>$itemInfo) {
818
+                            $itemInfo = trim($itemInfo, '[ ]');
819 819
 
820 820
 
821
-                            echo '<a href="',$PHP_SELF,'&op=4&server=',(array_search($server,$MEMCACHE_SERVERS)),'&key=',base64_encode($itemKey).'">',$itemKey,'</a>';
821
+                            echo '<a href="', $PHP_SELF, '&op=4&server=', (array_search($server, $MEMCACHE_SERVERS)), '&key=', base64_encode($itemKey).'">', $itemKey, '</a>';
822 822
                             if ($i++ % 10 == 0) {
823 823
                                 echo '<br/>';
824 824
                             }
825
-                            elseif ($i!=$slab['number']+1){
825
+                            elseif ($i != $slab['number'] + 1) {
826 826
                                 echo ',';
827 827
                             }
828 828
                         }
829 829
 					}
830 830
 
831 831
 					echo "</td></tr>";
832
-				$m=1-$m;
832
+				$m = 1 - $m;
833 833
 			}
834 834
 		echo <<<EOB
835 835
 			</tbody></table>
@@ -841,7 +841,7 @@  discard block
 block discarded – undo
841 841
     break;
842 842
 
843 843
     case 4: //item dump
844
-        if (!isset($_GET['key']) || !isset($_GET['server'])){
844
+        if (!isset($_GET['key']) || !isset($_GET['server'])) {
845 845
             echo "No key set!";
846 846
             break;
847 847
         }
@@ -850,25 +850,25 @@  discard block
 block discarded – undo
850 850
         // somebody has to do a fix to this.
851 851
         $theKey = htmlentities(base64_decode($_GET['key']));
852 852
 
853
-        $theserver = $MEMCACHE_SERVERS[(int)$_GET['server']];
854
-        list($h,$p) = get_host_port_from_server($theserver);
855
-        $r = sendMemcacheCommand($h,$p,'get '.$theKey);
853
+        $theserver = $MEMCACHE_SERVERS[(int) $_GET['server']];
854
+        list($h, $p) = get_host_port_from_server($theserver);
855
+        $r = sendMemcacheCommand($h, $p, 'get '.$theKey);
856 856
         echo <<<EOB
857 857
         <div class="info"><table cellspacing=0><tbody>
858 858
 			<tr><th>Server<th>Key</th><th>Value</th><th>Delete</th></tr>
859 859
 EOB;
860 860
         if (!isset($r['VALUE'])) {
861
-            echo "<tr><td class=td-0>",$theserver,"</td><td class=td-0>",$theKey,
861
+            echo "<tr><td class=td-0>", $theserver, "</td><td class=td-0>", $theKey,
862 862
                  "</td><td>[The requested item was not found or has expired]</td>",
863
-                 "<td></td>","</tr>";
863
+                 "<td></td>", "</tr>";
864 864
         }
865 865
         else {
866 866
 
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>";
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>";
872 872
         }
873 873
         echo <<<EOB
874 874
 			</tbody></table>
@@ -876,19 +876,19 @@  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'])){
879
+    	if (!isset($_GET['key']) || !isset($_GET['server'])) {
880 880
 			echo "No key set!";
881 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);
886
-        $r = sendMemcacheCommand($h,$p,'delete '.$theKey);
884
+		$theserver = $MEMCACHE_SERVERS[(int) $_GET['server']];
885
+		list($h, $p) = get_host_port_from_server($theserver);
886
+        $r = sendMemcacheCommand($h, $p, 'delete '.$theKey);
887 887
         echo 'Deleting '.$theKey.':'.$r;
888 888
 	break;
889 889
     
890 890
    case 6: // flush server
891
-        $theserver = $MEMCACHE_SERVERS[(int)$_GET['server']];
891
+        $theserver = $MEMCACHE_SERVERS[(int) $_GET['server']];
892 892
         $r = flushServer($theserver);
893 893
         echo 'Flush  '.$theserver.":".$r;
894 894
    break;
Please login to merge, or discard this patch.
Braces   +43 added lines, -24 removed lines patch added patch discarded remove patch
@@ -51,8 +51,7 @@  discard block
 block discarded – undo
51 51
 	$values = explode(':', $server);
52 52
 	if (($values[0] == 'unix') && (!is_numeric( $values[1]))) {
53 53
 		return array($server, 0);
54
-	}
55
-	else {
54
+	} else {
56 55
 		return $values;
57 56
 	}
58 57
 }
@@ -110,7 +109,7 @@  discard block
 block discarded – undo
110 109
 			    $res[$l[0]][$l[1]]['stat']=array('flag'=>$flag,'size'=>$size);
111 110
 			    $res[$l[0]][$l[1]]['value']=$lines[++$i];
112 111
 			}
113
-		}elseif($line=='DELETED' || $line=='NOT_FOUND' || $line=='OK'){
112
+		} elseif($line=='DELETED' || $line=='NOT_FOUND' || $line=='OK'){
114 113
 		    return $line;
115 114
 		}
116 115
 	}
@@ -257,16 +256,35 @@  discard block
 block discarded – undo
257 256
     $hours = (int)(($rem)/3600) - $days*24 - $weeks*7*24;
258 257
     $mins = (int)(($rem)/60) - $hours*60 - $days*24*60 - $weeks*7*24*60;
259 258
     $str = '';
260
-    if($years==1) $str .= "$years year, ";
261
-    if($years>1) $str .= "$years years, ";
262
-    if($weeks==1) $str .= "$weeks week, ";
263
-    if($weeks>1) $str .= "$weeks weeks, ";
264
-    if($days==1) $str .= "$days day,";
265
-    if($days>1) $str .= "$days days,";
266
-    if($hours == 1) $str .= " $hours hour and";
267
-    if($hours>1) $str .= " $hours hours and";
268
-    if($mins == 1) $str .= " 1 minute";
269
-    else $str .= " $mins minutes";
259
+    if($years==1) {
260
+        $str .= "$years year, ";
261
+    }
262
+    if($years>1) {
263
+        $str .= "$years years, ";
264
+    }
265
+    if($weeks==1) {
266
+        $str .= "$weeks week, ";
267
+    }
268
+    if($weeks>1) {
269
+        $str .= "$weeks weeks, ";
270
+    }
271
+    if($days==1) {
272
+        $str .= "$days day,";
273
+    }
274
+    if($days>1) {
275
+        $str .= "$days days,";
276
+    }
277
+    if($hours == 1) {
278
+        $str .= " $hours hour and";
279
+    }
280
+    if($hours>1) {
281
+        $str .= " $hours hours and";
282
+    }
283
+    if($mins == 1) {
284
+        $str .= " 1 minute";
285
+    } else {
286
+        $str .= " $mins minutes";
287
+    }
270 288
     return $str;
271 289
 }
272 290
 
@@ -278,7 +296,9 @@  discard block
 block discarded – undo
278 296
 
279 297
 function bsize($s) {
280 298
 	foreach (array('','K','M','G') as $i => $k) {
281
-		if ($s < 1024) break;
299
+		if ($s < 1024) {
300
+		    break;
301
+		}
282 302
 		$s/=1024;
283 303
 	}
284 304
 	return sprintf("%5.1f %sBytes",$s,$k);
@@ -506,8 +526,7 @@  discard block
 block discarded – undo
506 526
 echo <<<EOB
507 527
     <li><a href="$PHP_SELF&op={$_GET['op']}">Refresh Data</a></li>
508 528
 EOB;
509
-}
510
-else {
529
+} else {
511 530
 echo <<<EOB
512 531
     <li><a href="$PHP_SELF&op=2}">Back</a></li>
513 532
 EOB;
@@ -557,8 +576,11 @@  discard block
 block discarded – undo
557 576
 		$y1=$y+$h-1;
558 577
 
559 578
 		imagerectangle($im, $x, $y1, $x1+1, $y+1, $col_black);
560
-		if($y1>$y) imagefilledrectangle($im, $x, $y, $x1, $y1, $color2);
561
-		else imagefilledrectangle($im, $x, $y1, $x1, $y, $color2);
579
+		if($y1>$y) {
580
+		    imagefilledrectangle($im, $x, $y, $x1, $y1, $color2);
581
+		} else {
582
+		    imagefilledrectangle($im, $x, $y1, $x1, $y, $color2);
583
+		}
562 584
 		imagerectangle($im, $x, $y1, $x1, $y, $color1);
563 585
 		if ($text) {
564 586
 			if ($placeindex>0) {
@@ -713,8 +735,7 @@  discard block
 block discarded – undo
713 735
     		foreach($MEMCACHE_SERVERS as $server){
714 736
     		      echo ($i+1).'. <a href="'.$PHP_SELF.'&singleout='.$i++.'">'.$server.'</a><br/>';
715 737
     		}
716
-		}
717
-		else{
738
+		} else{
718 739
 		    echo '1.'.$MEMCACHE_SERVERS[0];
719 740
 		}
720 741
 		if (isset($_GET['singleout'])){
@@ -821,8 +842,7 @@  discard block
 block discarded – undo
821 842
                             echo '<a href="',$PHP_SELF,'&op=4&server=',(array_search($server,$MEMCACHE_SERVERS)),'&key=',base64_encode($itemKey).'">',$itemKey,'</a>';
822 843
                             if ($i++ % 10 == 0) {
823 844
                                 echo '<br/>';
824
-                            }
825
-                            elseif ($i!=$slab['number']+1){
845
+                            } elseif ($i!=$slab['number']+1){
826 846
                                 echo ',';
827 847
                             }
828 848
                         }
@@ -861,8 +881,7 @@  discard block
 block discarded – undo
861 881
             echo "<tr><td class=td-0>",$theserver,"</td><td class=td-0>",$theKey,
862 882
                  "</td><td>[The requested item was not found or has expired]</td>",
863 883
                  "<td></td>","</tr>";
864
-        }
865
-        else {
884
+        } else {
866 885
 
867 886
             echo "<tr><td class=td-0>",$theserver,"</td><td class=td-0>",$theKey,
868 887
                  " <br/>flag:",$r['VALUE'][$theKey]['stat']['flag'],
Please login to merge, or discard this patch.
var/www/dev/resource/item.php 2 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -8,8 +8,8 @@
 block discarded – undo
8 8
 class Controller
9 9
 {
10 10
     /**
11
-     * @param Doctrine\Common\Annotations\Reader             $reader
12
-     * @param BEAR\Sunday\Extension\Application\AppInterface $app
11
+     * @param Reader             $reader
12
+     * @param AppInterface $app
13 13
      *
14 14
      * @Ray\Di\Di\Inject
15 15
      */
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 
33 33
 control: {
34 34
     $mode = "Dev";
35
-    $app = require $appDir . '/bootstrap/instance.php';
35
+    $app = require $appDir.'/bootstrap/instance.php';
36 36
     /** @var $app \BEAR\Package\Provide\Application\AbstractApp */
37 37
     $appReflector = new ApplicationReflector($app);
38 38
     $resourceInfo = $appReflector->getResources()[$_GET['uri']];
@@ -95,5 +95,5 @@  discard block
 block discarded – undo
95 95
 
96 96
 EOT;
97 97
     // two step view
98
-    echo include $devDir . '/view/layout.php';
98
+    echo include $devDir.'/view/layout.php';
99 99
 }
Please login to merge, or discard this patch.
src/Installer.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -21,13 +21,13 @@  discard block
 block discarded – undo
21 21
         $version = $event->getComposer()->getPackage()->getPrettyVersion();
22 22
         $hash = $event->getComposer()->getLocker()->getLockData()['hash'];
23 23
         $packageDir = dirname(__DIR__);
24
-        file_put_contents($packageDir . '/VERSION', $version);
25
-        file_put_contents($packageDir . '/ID', $hash);
24
+        file_put_contents($packageDir.'/VERSION', $version);
25
+        file_put_contents($packageDir.'/ID', $hash);
26 26
 
27
-        $targetHello = dirname(__DIR__) . '/vendor/bear/demo-apps/Demo.Helloworld';
28
-        $targetSandbox = dirname(__DIR__) . '/vendor/bear/demo-apps/Demo.Sandbox';
29
-        $helloApp = dirname(__DIR__) . '/apps/Demo.Helloworld';
30
-        $sandboxApp = dirname(__DIR__) . '/apps/Demo.Sandbox';
27
+        $targetHello = dirname(__DIR__).'/vendor/bear/demo-apps/Demo.Helloworld';
28
+        $targetSandbox = dirname(__DIR__).'/vendor/bear/demo-apps/Demo.Sandbox';
29
+        $helloApp = dirname(__DIR__).'/apps/Demo.Helloworld';
30
+        $sandboxApp = dirname(__DIR__).'/apps/Demo.Sandbox';
31 31
 
32 32
         if (file_exists($helloApp)) {
33 33
             unlink($helloApp);
@@ -38,6 +38,6 @@  discard block
 block discarded – undo
38 38
         symlink($targetHello, $helloApp);
39 39
         symlink($targetSandbox, $sandboxApp);
40 40
 
41
-        include $packageDir . '/bin/bear.env';
41
+        include $packageDir.'/bin/bear.env';
42 42
     }
43 43
 }
Please login to merge, or discard this patch.
src/Dev/Dev.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
     ) {
99 99
         global $argv;
100 100
 
101
-        $this->web = $web ? : new Web;
101
+        $this->web = $web ?: new Web;
102 102
         if (is_null($server) && isset($_SERVER)) {
103 103
             $server = $_SERVER;
104 104
         }
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
         } elseif (isset($argv[2])) {
108 108
             $this->requestUri = $argv[2];
109 109
         }
110
-        $this->sapiName = $sapiName ? : php_sapi_name();
110
+        $this->sapiName = $sapiName ?: php_sapi_name();
111 111
     }
112 112
 
113 113
     /**
@@ -131,10 +131,10 @@  discard block
 block discarded – undo
131 131
 
132 132
         // stop
133 133
         register_shutdown_function(
134
-            function () {
134
+            function() {
135 135
                 $xhprof = xhprof_disable();
136 136
                 if (!$xhprof) {
137
-                    error_log('xhprof failed in ' . __FILE__);
137
+                    error_log('xhprof failed in '.__FILE__);
138 138
 
139 139
                     return;
140 140
                 }
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
         ini_set('xdebug.collect_params', 0);
160 160
         ini_set('xdebug.max_nesting_level', 500);
161 161
         ini_set('xdebug.file_link_format', '/dev/edit/?file=%f&line=$l');
162
-        if (! ini_get('date.timezone')) {
162
+        if (!ini_get('date.timezone')) {
163 163
             date_default_timezone_set('Asia/Tokyo');
164 164
         }
165 165
 
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
      */
172 172
     public function registerErrorHandler()
173 173
     {
174
-        set_error_handler( function ($errNo, $errStr, $errFile, $errLine) {
174
+        set_error_handler(function($errNo, $errStr, $errFile, $errLine) {
175 175
             if (error_reporting() === 0) {
176 176
 
177 177
                 // return in error-control operator(@)
@@ -208,10 +208,10 @@  discard block
 block discarded – undo
208 208
     public function registerExceptionHandler($logDir)
209 209
     {
210 210
         set_exception_handler(
211
-            function (\Exception $e) use ($logDir) {
211
+            function(\Exception $e) use ($logDir) {
212 212
                 $handler = new ExceptionHandler(
213 213
                     new SymfonyResponse(new ConsoleOutput),
214
-                    (dirname(__DIR__)) . '/Dev/Module/ExceptionHandle/template/exception.php'
214
+                    (dirname(__DIR__)).'/Dev/Module/ExceptionHandle/template/exception.php'
215 215
                 );
216 216
                 $handler->setLogDir($logDir);
217 217
                 $handler->handle($e);
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
     public function registerFatalErrorHandler()
251 251
     {
252 252
         register_shutdown_function(
253
-            function () {
253
+            function() {
254 254
                 if (PHP_SAPI === 'cli') {
255 255
                     return;
256 256
                 }
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
                 $outputBuffer = ob_get_clean();
270 270
                 error_log($outputBuffer);
271 271
                 http_response_code(500);
272
-                $html = require __DIR__ . '/view/fatal_error.php';
272
+                $html = require __DIR__.'/view/fatal_error.php';
273 273
                 echo $html;
274 274
                 exit(1);
275 275
             }
@@ -302,10 +302,10 @@  discard block
 block discarded – undo
302 302
         if (isset($this->app->router)) {
303 303
             $this->route($this->app);
304 304
         }
305
-        if (! $this->web->isDevWebService($this->sapiName, $this->requestUri)) {
305
+        if (!$this->web->isDevWebService($this->sapiName, $this->requestUri)) {
306 306
             return '';
307 307
         }
308
-        $requestUri = $requestUri ? : $_SERVER['REQUEST_URI'];
308
+        $requestUri = $requestUri ?: $_SERVER['REQUEST_URI'];
309 309
         $html = $this->web->service($requestUri, $this->app, $this->appDir);
310 310
 
311 311
         return $html;
@@ -327,7 +327,7 @@  discard block
 block discarded – undo
327 327
      */
328 328
     public function loadDevFunctions()
329 329
     {
330
-        error_log(__METHOD__  . ' is no longer necessary.');
330
+        error_log(__METHOD__.' is no longer necessary.');
331 331
 
332 332
         return $this;
333 333
     }
@@ -356,11 +356,11 @@  discard block
 block discarded – undo
356 356
      */
357 357
     private function getVendorDirectory()
358 358
     {
359
-        $vendorDir = dirname(dirname(__DIR__)) . '/vendor';
359
+        $vendorDir = dirname(dirname(__DIR__)).'/vendor';
360 360
 
361 361
         if (strpos(__DIR__, '/vendor/bear/package') !== false) {
362 362
             $baseDir = explode('/vendor/bear/package', __DIR__)[0];
363
-            $vendorDir = $baseDir . '/vendor';
363
+            $vendorDir = $baseDir.'/vendor';
364 364
         }
365 365
         return $vendorDir;
366 366
     }
Please login to merge, or discard this patch.