Community discussions

MikroTik App
 
Sandor1k
just joined
Topic Author
Posts: 22
Joined: Sat May 23, 2009 1:18 pm

Charts on php

Mon Jul 27, 2009 2:02 pm

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
 
lzzl551
just joined
Posts: 10
Joined: Thu Dec 04, 2008 2:59 pm

Re: Charts on php

Tue Jul 28, 2009 11:13 am

php?没有看懂,沙发
 
User avatar
sady
Frequent Visitor
Frequent Visitor
Posts: 84
Joined: Fri Jul 11, 2008 11:30 am
Location: Russia

Re: Charts on php

Tue Jul 28, 2009 7:03 pm

It is great! Thank You!!!!
Please, please, Open Dude Source! Pleaaaaseeeee!!!!!
 
Sandor1k
just joined
Topic Author
Posts: 22
Joined: Sat May 23, 2009 1:18 pm

Re: Charts on php

Sun Nov 28, 2010 5:52 pm

it works on freebsd or Linux?

Who is online

Users browsing this forum: No registered users and 11 guests