[afnog] phpMyPrepaid
Sunday A Folayan
sfolayan at skannet.com.ng
Mon Oct 17 19:55:02 EAT 2005
Heck .. baby sitting is interesting. Changing diapers is the tough one ;-)
Cheers.
SF.
At 01:02 PM 10/17/2005, Alex Gondwe wrote:
>Sunday,
>
>Thanks alot for youe help. I modified your cscript to
>take out the expired user from the system. The session
>timeout is also working fine. I can now see the sun at
>the end of the tunnel.
>
>It took a lot of soft drink, head scratching and foot
>stamping.
>
>The baby seems to be singing the right tune now.
>
>TTHanks once again.
>
>--- Sunday A Folayan <sfolayan at skannet.com.ng> wrote:
>
> > Alex,
> >
> > You need to hack the code to get the baby to sing as
> > you want :-)
> >
> > At 02:39 PM 10/14/2005, Alex Gondwe wrote:
> >
> > >Hello, All,
> > >
> > >I have setup a computer running fedora core 2. I
> > have
> > >installed chillispot, Freeradius and
> > >phpMyPrepaid.0.3.0RC1. I can authenticate
> > >wireless,dialup clients and NAS quite alright.
> > >Accounting is also working fine.
> >
> > Cool. Installing phpMyPrepaid on an existing FreeBSD
> > Radius Server, I got
> > it to work in 7 minutes flat.
> >
> > >My problem is that if I use phpMyPrepaid:
> > >
> > >1. The the client does not get booted out after
> > >exceeding the number of minutes allocated to a
> > >particular prepaid card.
> >
> > You need a session-time-out attribute, apart from
> > the
> > default Max-All-Session attribute that phpMyPrepaid
> > adds for you.
> >
> > Edit the file: CrCards/DBinsert.php
> >
> > Copy lines 9 and 10 to be 11 and 12.
> >
> > ensure lines 11 and 12 match this:
> > $q3= "INSERT INTO radcheck (UserName ,
> > Attribute, op, Value)
> > VALUES('$id','Session-Timeout',':=','$sec')";
> > $insert3 = mysql_query($q3) or
> > die(mysql_error());
> >
> > >2. When the prepaid card has expired, it is still
> > >possible to authenticate using the username and
> > >password associated with the card.
> >
> > You need a script to ensure that Sessions that have
> > been used up are rejected
> >
> > From the file: UsedCards.php,
> > // We need to select all accounts in
> > radcheck that have a
> > Max-All-Session Value
> > // which is >= to SUM(AcctSessionTime)
> >
> > I got the idea that used up sessions will have
> > sum(AcctSessionTime) >
> > Max-All-Session, so I went borrowing some of their
> > codes to come up wit ha
> > cleanup script.
> >
> > ==CUT BEGIN
> > <?php
> > include("config.inc.php");
> > // We need to set Auth-Type := Reject for
> > all accounts in radcheck
> > that
> > // have a Max-All-Session Value which is
> > >= to SUM(AcctSessionTime)
> > $query = "SELECT UserName, Value FROM radcheck
> > WHERE Attribute LIKE
> > 'Max-All-Session'";
> > $result = mysql_query($query) or
> > die(mysql_error());
> > while($row = mysql_fetch_object($result)) {
> > $user = $row->UserName;
> > $Val = $row->Value;
> > $q2 = "SELECT SUM(AcctSessionTime) as
> > TotalSessionTime FROM
> > radacct WHERE UserName LIKE '$user'";
> > $numresults=mysql_query($q2);
> > $numrows=mysql_num_rows($numresults);
> > $res2 = mysql_query($q2) or
> > die(mysql_error());
> > while($r2 = mysql_fetch_object($res2)) {
> > $used = $r2->TotalSessionTime;
> > if(!isset($used)) { $used = -1; } //
> > These lines are to catch
> > errors, NULLS and non numbers
> > if(!is_numeric($used)) { $used = -1; }
> > if(!isset($Val)) { $Val = 0; }
> > if(!is_numeric($Val)) { $Val = 0; }
> > echo "$user $used $Val\n";
> > if ($used >= $Val) {
> > //Flag as expired
> > $qsf= "INSERT INTO radcheck (UserName ,
> > Attribute, op, Value)
> > VALUES('$id','Auth-Type',':=','Reject')";
> > $insertsf = mysql_query($qsf) or
> > die(mysql_error());
> > }
> > }
> > }
> > ?>
> > == CUT END
> >
> > save this file, and run it with:
> > php cleanup.php
> >
> > It should emit some debug info, for you to know it
> > is working.
> >
> > add the following to your crontab, so that the
> > script is run every 5 minutes
> >
> > */5 * * * * /path_to_your_phpMyPrepaid/cleanup.php
> > 1>/dev/null 2>/dev/null
> >
> > >Has anybody successifully done a simillar
> > >installation before. Can someone help!!!
> >
> > There you are. I hope I have been of help.
> >
> >
> > >Regards Alex Gondwe
> > >Malawi
> >
> > Sunday A. Folayan.
> > Nigeria.
> >
> >
More information about the afnog
mailing list