Black List implementation by res_odbc and Macro in Asterisk .
DATABASE Script :
vim /etc/odbc.ini
vim /etc/asterisk/res_odbc.conf
vim /etc/asterisk/func_odbc.conf
-------------- Asterisk Dial Plan -----------
--------- Asterisk Macro ------------------
DATABASE Script :
CREATE DATABASE sabz; CREATE TABLE `BlackList` ( `id` int(11) NOT NULL AUTO_INCREMENT, `calldate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `callerid` varchar(40) NOT NULL DEFAULT '', PRIMARY KEY (`id`) ) ENGINE=MyISAM AUTO_INCREMENT=6 DEFAULT CHARSET=latin1; CREATE USER 'sabz'@'localhost' IDENTIFIED BY 'mypassword'; GRANT ALL PRIVILEGES ON sabz.* TO 'sabz'@'localhost'; FLUSH PRIVILEGES;
vim /etc/odbc.ini
[sabz] Description = MySQL connection to 'Sabz' database Driver = MySQL Database = sabz Server = localhost User = sabz Password = mypassword Port = 3306 Socket = /run/mysqld/mysqld.sock
vim /etc/asterisk/res_odbc.conf
[sabz] Description = MySQL connection to 'Sabz' database Driver = MySQL Database = sabz Server = localhost User = sabz Password = mypassword Port = 3306 Socket = /run/mysqld/mysqld.sock
vim /etc/asterisk/func_odbc.conf
[SABZ] dsn=sabz readsql=SELECT COUNT(*) FROM BlackList WHERE callerid='${SQL_ESC(${ARG1})}' synopsis=Check if a caller is in BlackList
-------------- Asterisk Dial Plan -----------
exten => 63563,1,Answer() same => n,Macro(BlackList,${CALLERID(num)}) same => n(NotBlackList),NoOP() same => n,Goto(KhailiSabz-IVR,s,1)
--------- Asterisk Macro ------------------
[macro-BlackList] exten => s,1,Set(CALLERID=${ARG1}) same => n,Set(CDR(accountcode)=BlackList) same => n,GotoIf($[${ODBC_SABZ(${CALLERID})}]?busy) same => n,GotoIf($[${ODBC_SABZ(${CALLERID:2})}]?busy) same => n,GotoIf($[${ODBC_SABZ(${CALLERID:1})}]?busy) same => n(dial),Goto(${MACRO_CONTEXT},${MACRO_EXTEN},NotBlackList) same => n,Hangup() same => n(busy),Playback(beep) same => n,Playback(beep) same => n,Playback(beep) same => n,Hangup
Comments
Post a Comment