[asterisk-users] GotoIf Dialplan inquiry

Doug Lytle support at drdos.info
Tue Jun 12 15:33:40 CDT 2007


Steve Finkelstein wrote:
> Hi all,
>
> I have the following in my extensions.conf:
>
>   


I use the mysql addon and create a subroutine that checks for black 
listed numbers.  I then call it at each entry point (For faxes as well):

; **************
; Auto attendant
; **************

exten => 734xxxxxxx,1,Gosub(check-blacklist,s,1)
exten => 734xxxxxxx,n,NoOP(Caller not blacklisted)
exten => 734xxxxxxx,n,Set(CALLERID(number)=91${CALLERIDNUM})
exten => 734xxxxxxx,n,Goto(auto_attend,s,1)


[check-blacklist]

exten => s,1,MYSQL(Connect connid localhost anonymous '' blacklisted)
exten => s,2,MYSQL(Query resultid ${connid} SELECT flag FROM 
BlackNumbers WHERE phone = ${CALLERIDNUM})
exten => s,3,MYSQL(Fetch fetchid ${resultid} results)
exten => s,4,MYSQL(Disconnect ${connid})
exten => s,5,MYSQL(Clear ${resultid})
exten => s,6,Set(BLACKLISTED=${results})
exten => s,7,GotoIf($["${BLACKLISTED}" = "YES"]?blacklisted,s,1)
exten => s,8,Return

[blacklisted]

exten => s,1,NoOP(Caller: ${CALLERIDNUM} is on the black list)
exten => s,n,SetCDRUserField(Blacklisted)
exten => s,n,Set(PRI_CAUSE=17)
exten => s,n,Hangup()

-- 
 
Ben Franklin quote:

"Those who would give up Essential Liberty to purchase a little Temporary Safety, deserve neither Liberty nor Safety."




More information about the asterisk-users mailing list