(RADIATOR) Can you use SQL if statements in radiator?
Toomas Kärner
tomkar at estpak.ee
Thu Nov 27 00:33:51 CST 2003
Hi,
Here's an example how I do my prepaid cards (it's different now already but
it fit's you) and there's no need for sql if statements.
#################################################
<AuthBy SQL>
Identifier AcctStartOnlyPrepaidCard
DBSource
DBUsername
DBAuth
IgnoreAuthentication
AccountingStartsOnly
AcctSQLStatement UPDATE cards SET \
START = from_unixtime(%{Timestamp}), \
END = from_unixtime(%{Timestamp} +
START_CREDIT), \
START_CREDIT = NULL \
WHERE username='%n' and \
ACTIVE = 'Yes' and \
START_CREDIT is not null
</AuthBy>
#################################################
<AuthBy SQL>
Identifier AuthPrepaidCard
DBSource
DBUsername
DBAuth
AuthSelect select \
TYPE, \
ACTIVE, \
LOCKED_TO, \
unix_timestamp(end), \
unix_timestamp(expires), \
PASSWORD, \
rate, \
rate, \
start_credit, \
(unix_timestamp(end) - unix_timestamp()) \
from cards where \
USERNAME ='%n'
AuthColumnDef 0, ETC-Realm,check
AuthColumnDef 1, ETC-Active,check
AuthColumnDef 2, NAS-Port, check
AuthColumnDef 3, Expiration, check
AuthColumnDef 4, Expiration, check
AuthColumnDef 5, User-Password, check
AuthColumnDef 6, Nomadix-Bw-Down, reply
AuthColumnDef 7, Nomadix-Bw-Up, reply
AuthColumnDef 8, Session-Timeout, reply
AuthColumnDef 9, Session-Timeout, reply
DefaultSimultaneousUse 1
NoDefault
RejectEmptyPassword
AddToReplyIfNotExist
Nomadix-Bw-Down=2000,Nomadix-Bw-Up=2000,Idle-Timeout=900
AcctSQLStatement insert into .....
</AuthBy>
#################################################
<Realm pre1h>
AuthLog LoginFailureLog
RewriteUsername s/^([^@]+).*/$1/
RejectHasReason
AuthByPolicy ContinueUntilReject
AuthBy AcctStartOnlyPrepaidCard
AuthBy AuthPrepaidCard
PostAuthHook file:"/home/radius/etc/hooks/wn/PostAuthHook.pl"
</Realm pre1h>
#################################################
----- Original Message -----
From: "Craig Gittens" <cgittens at sunbeach.net>
To: "Radiator" <radiator at open.com.au>
Sent: Wednesday, November 26, 2003 11:51 PM
Subject: (RADIATOR) Can you use SQL if statements in radiator?
> Hey guys,
>
> I am trying to get a new product to work where when the username and
> password is used and is valid then it would update the SQL database with
an
> end date for the product. So I need this logic to work in a SQL statement
in
> Radiator:
>
> User is a valid user and is allowed online,
> User entry gets update in SQL with a date I set (today + 30 days)
>
> If not then it would not update the user entry of course....
>
> Is this possible? I have tried SQL Functions but they can't update a
> permanent table.
>
> Regards,
>
> Craig.
>
>
> ===
> Archive at http://www.open.com.au/archives/radiator/
> Announcements on radiator-announce at open.com.au
> To unsubscribe, email 'majordomo at open.com.au' with
> 'unsubscribe radiator' in the body of the message.
===
Archive at http://www.open.com.au/archives/radiator/
Announcements on radiator-announce at open.com.au
To unsubscribe, email 'majordomo at open.com.au' with
'unsubscribe radiator' in the body of the message.
More information about the radiator
mailing list