I'm playing with the idea of setting up accounts with a limited number of
hours per month. I'm not using any commercial billing system
(Platypus,emerald) to do this, only a mysql database. Has anyone played
with this? Here are some ideas I have, I'm hoping someone with better ideas
will share theirs.
First, I would add two columns to my mysql subscribers table, max_time_month
and elapsed_time_month. max_time_month, if defined, would be the number of
seconds we're going to allow the user to log on per month.
elapsed_time_month is reset to zero at the beginning of each month with
cron, and it grows each time the user logs off (we add Acct-Session-Time
each time).
So, my auth statement would look something like this:
AuthSelect select password, '' as CHECKATTR, if(elapsed_time_month <
max_time_month && (max_time_month - elapsed_time_month ) > 36000,
'Session-Timeout=36000',
concat('Session-Timeout=',max_time_month-elapsed_time_month)) as REPLYATTR
from subscribers where username='%n' and suspended = 0;
(I haven't tested the SQL yet, so don't cut and paste this!)
So, we set 36000 seconds as the default Session-Timeout. If the user has
more than 36000 seconds remaining, we only allow them to have 36000 seconds
for this session. If they have less than 36000 seconds remaining, we only
allow them to stay on for as long as they have remaining. If they happen
to have 0 seconds remaining, we go ahead and authenticate them, but give
them a zero second timeout (bad idea?). One problem I just noticed is that
if I do not have a max_time_month defined, the user will never get on.
Maybe I'd have to set a very high default?
Next, we have to process the stop accounting records. Here's where I get
confused.
Could I do something like this:
AcctSQLStatement update subscribers set
elapsed_time_month=elapsed_time_month+%{Acct-Session-Time};
It seems I'd have to use an AccountingStopsOnly here somewhere. How would I
do this and keep logging everything to my detail file? Wow, am I getting
too complex here? Is there a better way?
Thanks,
Randy Cosby
InfoWest, Inc.
435-674-0165 x11
Fax: 603-462-6427
---
http://www.infowest.com
http://www.devshed.com
http://www.32bit.com
===
Archive at http://www.thesite.com.au/~radiator/
To unsubscribe, email '[EMAIL PROTECTED]' with
'unsubscribe radiator' in the body of the message.