At 10:11 26/09/00 +1100, Hugh Irvine wrote:
>I must apologise to you, as it does appear that there is a problem with
>radacct.cgi and SQL databases in secure mode. I am very sorry that you have
>spent a rather frustrating time trying to make this work.

No problem, that was part of discovering Radiator... and PHP :-)

FF.
------------------------------------------------
This PHP script extracts user infos and displays them in a table (for each 
session, its date + time, length, bytes sent/received; at the bottom, total 
time spent + bytes sent/received since the first connection.)

http://www.acme.com/index.php3?username=jdoe&passwd=secret

<HTML>
<FONT FACE="Arial,sans-serif">

<?
         print("<H1>Statistiques connexion $username</H1>");

         setlocale ("LC_TIME", "fr_FR");

         $host="localhost";
         $user="root";
         $password="test";

         $db = mysql_connect($host,$user,$password);
         mysql_select_db("radius",$db);

         //Vérifier que mdp passé ds URL est correcte
         $localpasswd = mysql_query("SELECT PASSWORD FROM SUBSCRIBERS WHERE 
USERNAME like '$username'",$db);
         $row = mysql_fetch_array($localpasswd);
         $localpasswd = $row["PASSWORD"];

         if ($localpasswd != $passwd) {
                 printf("Mot de passe incorrecte.<P>");
         } else {
                 $result = mysql_query("SELECT * FROM ACCOUNTING WHERE 
USERNAME like '$username'",$db);


                 //additionner toutes les valeurs du champ ACCTSESSIONTIME 
pour obtenir total cumulé
                 printf("<TABLE BORDER WIDTH=100%%>");
                 printf("<TR>");
                 printf("<TD WIDTH=25%%><B>Date session</B></TD>");
                 printf("<TD WIDTH=25%%><B>Durée session</B></TD>");
                 printf("<TD WIDTH=25%%><B>Octets TX</B></TD>");
                 printf("<TD WIDTH=25%%><B>Octets RX</B></TD>");
                 printf("</TR>");

                 while ($myrow = mysql_fetch_array($result)) {

                         $connexion += $myrow["ACCTSESSIONTIME"];
                         $inbytes += $myrow["ACCTINPUTOCTETS"];
                         $outbytes += $myrow["ACCTOUTPUTOCTETS"];

                         if ($myrow["ACCTSESSIONTIME"]) {
                                 printf("<TR>");
                                 printf("<TD WIDTH=40%%>%s</TD>",strftime 
("%c", $myrow["TIME_STAMP"]) );

                                 if ($myrow["ACCTSESSIONTIME"] > 3600):
                                         printf("<TD WIDTH=20%%>%01.2f 
heures</TD>",$myrow["ACCTSESSIONTIME"] / 3600);
                                 elseif ($myrow["ACCTSESSIONTIME"] > 60):
                                         printf("<TD WIDTH=20%%>%01.2f 
minutes</TD>",$myrow["ACCTSESSIONTIME"] / 60);
                                 else :
                                         printf("<TD WIDTH=20%%>%01.2f 
secondes</TD>",$myrow["ACCTSESSIONTIME"]);
                                 endif;
                                 #printf("<TD 
WIDTH=20%%>%s</TD>",$myrow["ACCTSESSIONTIME"]);

                                 printf("<TD 
WIDTH=20%%>%s</TD>",$myrow["ACCTINPUTOCTETS"]);
                                 printf("<TD 
WIDTH=20%%>%s</TD>",$myrow["ACCTOUTPUTOCTETS"]);
                                 printf("</TR>");
                         }
                 }
                 printf("</TABLE>");


                 if ($connexion > 3600):
                         printf("<FONT COLOR=\"#3600FF\">Total connexion = 
%01.2f heure(s)</FONT><BR>",$connexion / 3600);
                 elseif ($connexion > 60):
                         printf("<FONT COLOR=\"#3600FF\">Total connexion = 
%01.2f minute(s)</FONT><BR>",$connexion / 60);
                 else:
                         printf ("<FONT COLOR=\"#3600FF\">Total connexion = 
%01.2f seconde(s)</FONT><BR>",$connexion);
                 endif;

                 printf("<FONT COLOR=\"#3600FF\">Total octets envoyés = %s 
octets</FONT><BR>",number_format($inbytes,0,",","."));
                 printf("<FONT COLOR=\"#3600FF\">Total octets reçus = %s 
octets</FONT><P>",number_format($outbytes,
0,",","."));

                 printf("<P><P><CENTER><a 
href=\"http://www.cablewanadoo.com\">Wanadoo</A></CENTER>");

         }

         setlocale ("LC_TIME", "C");

?>

</FONT>
</HTML>


===
Archive at http://www.starport.net/~radiator/
Announcements on [EMAIL PROTECTED]
To unsubscribe, email '[EMAIL PROTECTED]' with
'unsubscribe radiator' in the body of the message.

Reply via email to