[quote=“bira_more”]I think - best will be if you start using AGI scripts. astcc - asterisk calling card system is based on same things - prompts for digits, then query’s etc.
You can use anything you want - PHP, Perl, even executables written in C/C++.[/quote]
Yes I read a lot about that, but people also recommend the cmd MySQL, so I’m figuring out what to use.
I have digged up the following what might be a good one to change:
voip-info.org/wiki/view/MySQ … k+RealTime
Check incoming CALLERID for Blacklist
This is a simple way to keep a blacklist of phone numbers that you don't want to allow to call you/your company. The Macro will quickly check a MySQL database for the incoming callerid. If the callerid exist and the block is enabled, then the caller will get placed into the [blacklistednumber] context.
Create a new table in you MySQL RealTime connection.
CREATE TABLE `blacklist` (
`id` int(11) NOT NULL auto_increment,
`callerid` varchar(10) NOT NULL default '',
`blockenabled` char(1) NOT NULL default '1',
`notes` longtext NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
insert into `blacklist` values('1','5556671212','1','Spammer');
The blockenabled column should equal 1 to enable the block. Set this to 0 (zero), if you wish to disable blocking the number.
Insert the following Macro and context into your dial plan.
[globals]
realdb_host=hostnameformysqldb
realdb_user=mysqldbuser
realdb_pass=mysqldbpassword
realdb_db=mysqldbthatcontainsthevoicemailusers
[macro-checkblacklist]
; This Macro will check the blacklist table to see if the callerid of the
; caller exist and blockenabled =1 (TRUE). If the callerid is listed, then
; tell the caller they have been blacklisted and politely HangUp()
;
; ${ARG1} = CallerID of incoming call
;
exten => s,1,MYSQL(Connect connid ${realdb_host} ${realdb_user} ${realdb_pass} ${realdb_db})
exten => s,2,MYSQL(Query resultid ${connid} SELECT\ callerid\ from\ blacklist\ where\ callerid=${ARG1} and blockenabled = 1)
exten => s,3,MYSQL(Fetch fetchid ${resultid} blacklistid)
exten => s,4,MYSQL(Clear ${resultid})
exten => s,5,MYSQL(Disconnect ${connid})
exten => s,6,GoToIf($["${blacklistid}" = ""]?7:fail,1)
exten => s,7,NoOp(${blacklistid})
; If the callerid is listed in the database, then send to blacklistednumber
; context
;
exten => fail,1,NoOp(${blacklistid})
exten => fail,2,GoTo(blacklistednumber,s,1)
[blacklistednumber]
; This is where a call will land if the macro-checkblacklist decides that
; the number should not be allowed to dial the company.
exten => s,1,Wait(2)
exten => s,2,Playback(privacy-you-are-blacklisted)
exten => s,3,Zapateller()
exten => s,4,HangUp()
The last step is to call the macro when a call arrives. On the context for your zap channels, add this line:
[zaptel-incoming]
;Incoming context for PRI.
;
exten => 8005551193,1,Macro(checkblacklist,${CALLERID(num)})
exten => 8005551193,2,Dial(SIP/Phone)
If someone has some comments or advises on this one, always welcome !