Hello,
I am trying to create a php script whic authenticates a user
[usernames and passwords are stored in a mysql database] and then
creates MRTG like graphs for that particular user from data stored in
RRDtool format. I have MRTG populating the RRDtool databases and I
also have a user authentication script. I am not able to get a script
which will create the graphs for me. I know that there is a PHP module
for RRD but since I am not knowledgeble in PHP, I don't know if I can
script it.
==AUTHENITCATION SCRIP [showstats.php]==
<?
if ((!$username) || (!$password)) {
header("Location: index.html");
exit;
}
$db_name = "*****";
$table_name = "****";
$connection = @mysql_connect("localhost", "****", "****")
or die("Couldn't connect.");
$db = mysql_select_db($db_name, $connection)
or die("Couldn't select database.");
$sql = "SELECT * FROM $table_name
WHERE UserName = \"$username\" AND Password = password(\"$password\")
";
$result = mysql_query($sql)
or die ("Can't execute query.");
mysql_close($connection);
$num = mysql_numrows($result);
if ($num != 0)
{
$msg = "<P><B>Customer:</B> [$username]</p>";
}
else
{
header("Location: bad_login.html");
exit;
}
?>
<HTML>
<HEAD>
<TITLE>Traffic Analysis Stats for <? echo $username ?></TITLE>
</HEAD>
<BODY>
<? echo "$msg"; ?>
<BR>
</BODY>
</HTML>
==END OF AUTHENITCATION SCRIPT==
I am looking for someone to write me the script to creat the MRTG like
graphs. If my authentication script needs work, I would appreciate any
suggestions. The graphing script needs to take the "Target" name as a
parameter.
If you cannot write the whole script for me, I would appreciate if you
can show me to the correct resources which will allow me to write the
script myself. Please note that I am very [very very] new to PHP. I do
a bit of coding in perl. If the whole authentication/graphing can be
done in perl, that is fine too. If you can modify the 14all.pl script
or similar script, that fine too. Thanks much.
- V. |