Page 1 of 1

Charts on php

Posted: Mon Jul 27, 2009 2:02 pm
by Sandor1k
Good time of day! I would like to submit a script written in php, for the use of graphic charts to another page:
The first file graph.php responsible for input on the protocol itself http page the dude. We need this in order to use the graphics load of channels on any other page
<?php
$url = "http://172.31.31.2:90/dude/main.html";   # The page to enter
$ch = curl_init();    
$user = "admin"; # login
$pass = "password"; #password
curl_setopt($ch, CURLOPT_URL, $url);   
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);   
curl_setopt($ch, CURLOPT_POST, 1);   
curl_setopt($ch, CURLOPT_POSTFIELDS, "process=login&page=start&user=$user&password=$pass");   
curl_setopt($ch, CURLOPT_COOKIEJAR, 'D:/HTTP/graph/cookie.txt');   # local path to save cookies to file 
$result = curl_exec($ch);
$url = "http://172.31.31.2:90/dude/chart.png?page=chart_picture&download=yes&id=$i&num=$n"; #	
id = $i & num = $n is responsible for the identifier and the numbering (hour / day / week / year) 
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 0);    
curl_setopt($ch, CURLOPT_COOKIEFILE, 'D:/HTTP/graph/cookie.txt'); # local path to save cookies to file
$result = curl_exec($ch);         
curl_close($ch);      
echo $result;
?>

second file index.php displays images in the browser by passing variables $i and $n in the file graph.php
<title>MRTGS Index Page</title>
<H2 align=center>MRTGS Index Page</H2>
<meta http-equiv="refresh" content="60" url=index.php>
<?php
echo "<table ALIGN=CENTER BORDER=0 CELLPADDING=0 CELLSPACING=10>";

echo "<tr><td>";
$id = "598492";
$title = "Link pppoe1 --0800i-EA port 7";
echo "<div><b>$title</b></div>";
echo "<A HREF=./custom.php?i=$id><IMG BORDER=1 ALT=Test SRC=./graph.php?i=$id&n=0 width=500 height=300></A>";
echo "</td><td>";
$id = "598497";
$title = "Link pppoe2 --0800i-EA port 8";
echo "<div><b>$title</b></div>";
echo "<A HREF=./custom.php?i=$id><IMG BORDER=1 ALT=Test SRC=./graph.php?i=$id&n=0 width=500 height=300></A>";
echo "</td></tr>";

echo "</table>";
?>

third file custom.php prints detailed graphics on the index.php (hour / day / week / month / year):
<?php
echo "<table ALIGN=CENTER BORDER=0 CELLPADDING=0 CELLSPACING=10>";

echo "<tr><td>";
echo "<div><b>'Live' graph</b></div>";
echo "<img src=./graph.php?i=$i&n=0 border=1 width=500 height=300>";
echo "</td><td>";
echo "<div><b>'Daily' graph</b></div>";
echo "<img src=./graph.php?i=$i&n=1 border=1 width=500 height=300>";
echo "</td></tr>";

echo "<tr><td>";
echo "<div><b>'Weekly' graph</b></div>";
echo "<img src=./graph.php?i=$i&n=2 border=1 width=500 height=300>";
echo "</td><td>";
echo "<div><b>'Monthly' graph</b></div>";
echo "<img src=./graph.php?i=$i&n=3 border=1 width=500 height=300>";
echo "</td></tr>";

echo "<tr><td>";
echo "<div><b>'Yearly' graph</b></div>";
echo "<img src=./graph.php?i=$i&n=4 border=1 width=500 height=300>";
echo "</td></tr>";

echo "</table>";
?>
In the end, that's what is:
on index.php

Image
on custom.php

Image

P.s. Forgive me for my english :D

Re: Charts on php

Posted: Tue Jul 28, 2009 11:13 am
by lzzl551
php?没有看懂,沙发

Re: Charts on php

Posted: Tue Jul 28, 2009 7:03 pm
by sady
It is great! Thank You!!!!

Re: Charts on php

Posted: Sun Nov 28, 2010 5:52 pm
by Sandor1k
it works on freebsd or Linux?