[ previous ] [ next ] [ threads ]
 
 From:  "T. Lechat" <m0n0wall at lechat dot org>
 To:  "Adam Nellemann" <adam at nellemann dot nu>, <m0n0wall at lists dot m0n0 dot ch>
 Subject:  Re: [m0n0wall] How to Display the traffic graph directly?
 Date:  Tue, 28 Dec 2004 01:51:32 +0100
> I would like to display certain pages (or parts thereof) from the
> m0n0wall web GUI, either as part of a composite web-page (ie. with
> other status pages shown in other frames) or on my Active Desktop. In
> order to do so, it is, among other things, necessary to somehow
> "pre-provide" the userid/password, as the page(s) will otherwise not
> show (or alternativly, ask for this information, which is also not
> acceptable).

Hi,

One way (not the best, but a working solution) to achieve your goal is to 
use an intermediate web server with php and put the following script in it :
This script call m0n0wall webgui with the basic authentification, parse the 
returned page to change some url, and send result to your browser.
For exemple, name it as m0n0.php, and your new webserver is 
http://myinternalwebserver
From now, call http://myinternalwebserver/m0n0.php

And oh surprise, traffic graph is now working...

You can change $page to whatever you want.

Thierry

<?php
$ip="192.168.1.1"; // m0n0wall webgui ip
$port="80";             // m0n0wall webgui port
$page="graph.php"; // m0n0wall trafficgraph page
$get="ifnum=ng0&ifname=WAN"; // m0n0wall trafficgraph get string
$user="myuser"; // m0n0wall user
$password="mypassword"; //m0n0wall password

/**************/
/*   Do request   */
/*************/
if($_GET['ifstats'])
{
 $page="ifstats.cgi";
 $get=$_GET['ifstats'];
}

parse_str($get);

$auth=base64_encode($user.":".$password);

$msg = <<< EOT
GET /$page?$get  HTTP/1.0
Authorization: Basic $auth\r\n\r\n
EOT;

$sock=fsockopen($ip,$port,$errno,$errstr,$timeout);
$z=fputs($sock,$msg,strlen($msg));
while ($buffer=fgets($sock,4096)) $out.=$buffer;
fclose($sock);
$outa=explode("\r\n\r\n",$out,2);
if(!$outa[1]) $outa=explode("\n\n",$out,2);
if(eregi('svg',$outa[0]))
{
 $outa[1]=str_replace("ifstats.cgi?$ifnum","{$_SERVER["PHP_SELF"]}?ifstats=$ifnum",$outa[1]);
header("Content-type: image/svg+xml");}echo $outa[1];?>