]> git.pld-linux.org Git - packages/cacti-template-lighttpd.git/blob - fixes.patch
70f7580f5c90d874229d63c7588a80671cda49b6
[packages/cacti-template-lighttpd.git] / fixes.patch
1 --- lighttpd_stats_1.0/ss_lighttpd_stats.php    2008-10-05 17:59:04.134098093 +0300
2 +++ lighttpd_stats_1.0/ss_lighttpd_stats.php    2008-10-05 18:07:11.707053483 +0300
3 @@ -1,3 +1,4 @@
4 +#!/usr/bin/php
5  <?php
6  //
7  // +----------------------------------------------------------------------+
8 @@ -21,9 +22,6 @@
9  //
10  //
11  
12 -/* display no errors */
13 -error_reporting(0);
14 -
15  if (!isset($called_by_script_server)) {
16          include_once(dirname(__FILE__) . "/../include/config.php");
17          array_shift($_SERVER["argv"]);
18 @@ -47,8 +45,8 @@
19                 $status = lighttpdStatus::getStatus($host);
20                 $return = '';
21  
22 -               foreach($variables as $status_var => $cacti_var){
23 -                       if(isset($status[$status_var])){
24 +               foreach ($variables as $status_var => $cacti_var){
25 +                       if (isset($status[$status_var])) {
26                                 $return .= sprintf('%s:%s ', $cacti_var, $status[$status_var]);
27                         }
28                 }
29 @@ -84,7 +82,7 @@
30                                 throw new Exception('Host not found');
31                         }
32  
33 -                       $fh = @fsockopen($address, 80, $errno, $errstr, self::QUERY_TIMEOUT);
34 +                       $fh = fsockopen($address, 80, $errno, $errstr, self::QUERY_TIMEOUT);
35  
36                         if(!$fh || !is_resource($fh)){
37                                 throw new Exception($errstr, $errno);
38 @@ -112,20 +110,24 @@
39                                 throw new Exception('');
40                         }
41  
42 -                       $lines = explode("\n", $status);
43 +                       list($headers, $body) = explode("\r\n\r\n", $status);
44 +                       $headers = explode("\r\n", $headers);
45  
46                         // check response code
47                         // should be "HTTP/1.1 200 OK"
48 -                       if(trim($lines[0]) != 'HTTP/1.1 200 OK'){
49 -                               throw new Exception($lines[0]);
50 +                       // can be also "HTTP/1.0 200 OK" if routed via proxy
51 +                       $http_status = trim($headers[0]);
52 +                       if ($http_status != 'HTTP/1.0 200 OK' && $http_status != 'HTTP/1.1 200 OK'){
53 +                               throw new Exception($http_status);
54                         }
55  
56                         $vars = array();
57  
58 -                       foreach($lines as $line){
59 +                       $body = explode("\n", $body);
60 +                       foreach($body as $line){
61                                 $line = trim($line);
62  
63 -                               if(preg_match('/(.+): (.+)/', $line, $matches)){
64 +                               if (preg_match('/^(.+): (.+)/', $line, $matches)){
65                                         $vars[$matches[1]] = intval($matches[2]);
66                                 }
67                         }
68 @@ -140,2 +141,0 @@
69 -
70 -?>
This page took 0.059847 seconds and 2 git commands to generate.