Столбец ID - первичный, автоинкремент, индекс, не пустой. Phone_num INT(11) caller_name VARCHAR(40) sector VARCHAR(10) phonetype INT(1).
Настройка MySQL callerid lookup source:
хост localhost
база данных call-sector
запрос SELECT caller_name FROM call-sector.clid WHERE phone_num LIKE '%[Callerid(num)]';
пользователь root
пароль какой-то пароль.
В базе пока единственная строка
1|79ХХХХХХХХХ|Иван Иванович Иванов|сектор1|0
Входящий маршрут с транка должен, по-идее, смотреть в базу, оттуда выдергивать имя позвонившего и отдавать уже тому, кто попросит.
PRIME_BBCODE_SPOILER_SHOW PRIME_BBCODE_SPOILER:
[cidlookup]
include => cidlookup-custom
exten => cidlookup_1,1,GotoIf($[${DB_EXISTS(cidname/${CALLERID(num)})} = 1]?cidlookup,cidlookup_return,1)
exten => cidlookup_1,n,MYSQL(Connect connid localhost root какой-то пароль call-sector)
exten => cidlookup_1,n,MYSQL(Query resultid ${connid} SET NAMES utf8)
exten => cidlookup_1,n,MYSQL(Query resultid ${connid} SELECT caller_name FROM call-sector.clid WHERE phone_num LIKE '%[Callerid(num)]';)
exten => cidlookup_1,n,MYSQL(Fetch fetchid ${resultid} CALLERID(name))
;exten => cidlookup_1,n,MYSQL(Clear ${resultid})
exten => cidlookup_1,n,MYSQL(Disconnect ${connid})
exten => cidlookup_1,n,Set(DB(cidname/${CALLERID(num)})=${CALLERID(name)})
exten => cidlookup_1,n,Return()
exten => cidlookup_return,1,ExecIf($["${DB(cidname/${CALLERID(num)})}" != ""]?Set(CALLERID(name)=${DB(cidname/${CALLERID(num)})}))
exten => cidlookup_return,n,Return()
include => cidlookup-custom
exten => cidlookup_1,1,GotoIf($[${DB_EXISTS(cidname/${CALLERID(num)})} = 1]?cidlookup,cidlookup_return,1)
exten => cidlookup_1,n,MYSQL(Connect connid localhost root какой-то пароль call-sector)
exten => cidlookup_1,n,MYSQL(Query resultid ${connid} SET NAMES utf8)
exten => cidlookup_1,n,MYSQL(Query resultid ${connid} SELECT caller_name FROM call-sector.clid WHERE phone_num LIKE '%[Callerid(num)]';)
exten => cidlookup_1,n,MYSQL(Fetch fetchid ${resultid} CALLERID(name))
;exten => cidlookup_1,n,MYSQL(Clear ${resultid})
exten => cidlookup_1,n,MYSQL(Disconnect ${connid})
exten => cidlookup_1,n,Set(DB(cidname/${CALLERID(num)})=${CALLERID(name)})
exten => cidlookup_1,n,Return()
exten => cidlookup_return,1,ExecIf($["${DB(cidname/${CALLERID(num)})}" != ""]?Set(CALLERID(name)=${DB(cidname/${CALLERID(num)})}))
exten => cidlookup_return,n,Return()
PRIME_BBCODE_SPOILER_SHOW PRIME_BBCODE_SPOILER:
== Using SIP RTP TOS bits 184
== Using SIP RTP CoS mark 5
-- Executing [4000@from-pstn:1] Set("SIP/6001-00001dbd", "__FROM_DID=4000") in new stack
-- Executing [4000@from-pstn:2] Gosub("SIP/6001-00001dbd", "app-blacklist-check,s,1") in new stack
-- Executing [s@app-blacklist-check:1] GotoIf("SIP/6001-00001dbd", "0?blacklisted") in new stack
-- Executing [s@app-blacklist-check:2] Set("SIP/6001-00001dbd", "CALLED_BLACKLIST=1") in new stack
-- Executing [s@app-blacklist-check:3] Return("SIP/6001-00001dbd", "") in new stack
-- Executing [4000@from-pstn:3] Gosub("SIP/6001-00001dbd", "cidlookup,cidlookup_1,1") in new stack
-- Executing [cidlookup_1@cidlookup:1] GotoIf("SIP/6001-00001dbd", "1?cidlookup,cidlookup_return,1") in new stack
-- Goto (cidlookup,cidlookup_return,1)
-- Executing [cidlookup_return@cidlookup:1] ExecIf("SIP/6001-00001dbd", "1?Set(CALLERID(name)=79ХХХХХХХХХ)") in new stack
-- Executing [cidlookup_return@cidlookup:2] Return("SIP/6001-00001dbd", "") in new stack
-- Executing [4000@from-pstn:4] Set("SIP/6001-00001dbd", "CHANNEL(language)=ru") in new stack
-- Executing [4000@from-pstn:5] ExecIf("SIP/6001-00001dbd", "0 ?Set(CALLERID(name)=79ХХХХХХХХХ)") in new stack
-- Executing [4000@from-pstn:6] Wait("SIP/6001-00001dbd", "1") in new stack
-- Executing [4000@from-pstn:7] Set("SIP/6001-00001dbd", "__CALLINGPRES_SV=allowed_not_screened") in new stack
-- Executing [4000@from-pstn:8] Set("SIP/6001-00001dbd", "CALLERPRES()=allowed_not_screened") in new stack
-- Executing [4000@from-pstn:9] Goto("SIP/6001-00001dbd", "from-did-direct,1001,1") in new stack
-- Goto (from-did-direct,1001,1)
-- Executing [1001@from-did-direct:1] Macro("SIP/6001-00001dbd", "exten-vm,1001,1001") in new stack
-- Executing [s@macro-exten-vm:1] Macro("SIP/6001-00001dbd", "user-callerid,") in new stack
-- Executing [s@macro-user-callerid:1] Set("SIP/6001-00001dbd", "AMPUSER=79ХХХХХХХХХ") in new stack
-- Executing [s@macro-user-callerid:2] GotoIf("SIP/6001-00001dbd", "0?report") in new stack
-- Executing [s@macro-user-callerid:3] ExecIf("SIP/6001-00001dbd", "1?Set(REALCALLERIDNUM=79ХХХХХХХХХ)") in new stack
-- Executing [s@macro-user-callerid:4] Set("SIP/6001-00001dbd", "AMPUSER=") in new stack
-- Executing [s@macro-user-callerid:5] Set("SIP/6001-00001dbd", "AMPUSERCIDNAME=") in new stack
-- Executing [s@macro-user-callerid:6] GotoIf("SIP/6001-00001dbd", "1?report") in new stack
-- Goto (macro-user-callerid,s,10)
-- Executing [s@macro-user-callerid:10] GotoIf("SIP/6001-00001dbd", "0?continue") in new stack
-- Executing [s@macro-user-callerid:11] Set("SIP/6001-00001dbd", "__TTL=64") in new stack
-- Executing [s@macro-user-callerid:12] GotoIf("SIP/6001-00001dbd", "1?continue") in new stack
-- Goto (macro-user-callerid,s,19)
-- Executing [s@macro-user-callerid:19] Set("SIP/6001-00001dbd", "CALLERID(number)=79ХХХХХХХХХ") in new stack
-- Executing [s@macro-user-callerid:20] Set("SIP/6001-00001dbd", "CALLERID(name)=79ХХХХХХХХХ") in new stack
-- Executing [s@macro-user-callerid:21] NoOp("SIP/6001-00001dbd", "Using CallerID "79ХХХХХХХХХ" <79ХХХХХХХХХ>") in new stack
-- Executing [s@macro-exten-vm:2] Set("SIP/6001-00001dbd", "RingGroupMethod=none") in new stack
-- Executing [s@macro-exten-vm:3] Set("SIP/6001-00001dbd", "VMBOX=1001") in new stack
-- Executing [s@macro-exten-vm:4] Set("SIP/6001-00001dbd", "__EXTTOCALL=1001") in new stack
-- Executing [s@macro-exten-vm:5] Set("SIP/6001-00001dbd", "CFUEXT=") in new stack
-- Executing [s@macro-exten-vm:6] Set("SIP/6001-00001dbd", "CFBEXT=") in new stack
-- Executing [s@macro-exten-vm:7] Set("SIP/6001-00001dbd", "RT=120") in new stack
-- Executing [s@macro-exten-vm:8] Macro("SIP/6001-00001dbd", "record-enable,1001,IN") in new stack
-- Executing [s@macro-record-enable:1] GotoIf("SIP/6001-00001dbd", "1?check") in new stack
-- Goto (macro-record-enable,s,4)
== Using SIP RTP CoS mark 5
-- Executing [4000@from-pstn:1] Set("SIP/6001-00001dbd", "__FROM_DID=4000") in new stack
-- Executing [4000@from-pstn:2] Gosub("SIP/6001-00001dbd", "app-blacklist-check,s,1") in new stack
-- Executing [s@app-blacklist-check:1] GotoIf("SIP/6001-00001dbd", "0?blacklisted") in new stack
-- Executing [s@app-blacklist-check:2] Set("SIP/6001-00001dbd", "CALLED_BLACKLIST=1") in new stack
-- Executing [s@app-blacklist-check:3] Return("SIP/6001-00001dbd", "") in new stack
-- Executing [4000@from-pstn:3] Gosub("SIP/6001-00001dbd", "cidlookup,cidlookup_1,1") in new stack
-- Executing [cidlookup_1@cidlookup:1] GotoIf("SIP/6001-00001dbd", "1?cidlookup,cidlookup_return,1") in new stack
-- Goto (cidlookup,cidlookup_return,1)
-- Executing [cidlookup_return@cidlookup:1] ExecIf("SIP/6001-00001dbd", "1?Set(CALLERID(name)=79ХХХХХХХХХ)") in new stack
-- Executing [cidlookup_return@cidlookup:2] Return("SIP/6001-00001dbd", "") in new stack
-- Executing [4000@from-pstn:4] Set("SIP/6001-00001dbd", "CHANNEL(language)=ru") in new stack
-- Executing [4000@from-pstn:5] ExecIf("SIP/6001-00001dbd", "0 ?Set(CALLERID(name)=79ХХХХХХХХХ)") in new stack
-- Executing [4000@from-pstn:6] Wait("SIP/6001-00001dbd", "1") in new stack
-- Executing [4000@from-pstn:7] Set("SIP/6001-00001dbd", "__CALLINGPRES_SV=allowed_not_screened") in new stack
-- Executing [4000@from-pstn:8] Set("SIP/6001-00001dbd", "CALLERPRES()=allowed_not_screened") in new stack
-- Executing [4000@from-pstn:9] Goto("SIP/6001-00001dbd", "from-did-direct,1001,1") in new stack
-- Goto (from-did-direct,1001,1)
-- Executing [1001@from-did-direct:1] Macro("SIP/6001-00001dbd", "exten-vm,1001,1001") in new stack
-- Executing [s@macro-exten-vm:1] Macro("SIP/6001-00001dbd", "user-callerid,") in new stack
-- Executing [s@macro-user-callerid:1] Set("SIP/6001-00001dbd", "AMPUSER=79ХХХХХХХХХ") in new stack
-- Executing [s@macro-user-callerid:2] GotoIf("SIP/6001-00001dbd", "0?report") in new stack
-- Executing [s@macro-user-callerid:3] ExecIf("SIP/6001-00001dbd", "1?Set(REALCALLERIDNUM=79ХХХХХХХХХ)") in new stack
-- Executing [s@macro-user-callerid:4] Set("SIP/6001-00001dbd", "AMPUSER=") in new stack
-- Executing [s@macro-user-callerid:5] Set("SIP/6001-00001dbd", "AMPUSERCIDNAME=") in new stack
-- Executing [s@macro-user-callerid:6] GotoIf("SIP/6001-00001dbd", "1?report") in new stack
-- Goto (macro-user-callerid,s,10)
-- Executing [s@macro-user-callerid:10] GotoIf("SIP/6001-00001dbd", "0?continue") in new stack
-- Executing [s@macro-user-callerid:11] Set("SIP/6001-00001dbd", "__TTL=64") in new stack
-- Executing [s@macro-user-callerid:12] GotoIf("SIP/6001-00001dbd", "1?continue") in new stack
-- Goto (macro-user-callerid,s,19)
-- Executing [s@macro-user-callerid:19] Set("SIP/6001-00001dbd", "CALLERID(number)=79ХХХХХХХХХ") in new stack
-- Executing [s@macro-user-callerid:20] Set("SIP/6001-00001dbd", "CALLERID(name)=79ХХХХХХХХХ") in new stack
-- Executing [s@macro-user-callerid:21] NoOp("SIP/6001-00001dbd", "Using CallerID "79ХХХХХХХХХ" <79ХХХХХХХХХ>") in new stack
-- Executing [s@macro-exten-vm:2] Set("SIP/6001-00001dbd", "RingGroupMethod=none") in new stack
-- Executing [s@macro-exten-vm:3] Set("SIP/6001-00001dbd", "VMBOX=1001") in new stack
-- Executing [s@macro-exten-vm:4] Set("SIP/6001-00001dbd", "__EXTTOCALL=1001") in new stack
-- Executing [s@macro-exten-vm:5] Set("SIP/6001-00001dbd", "CFUEXT=") in new stack
-- Executing [s@macro-exten-vm:6] Set("SIP/6001-00001dbd", "CFBEXT=") in new stack
-- Executing [s@macro-exten-vm:7] Set("SIP/6001-00001dbd", "RT=120") in new stack
-- Executing [s@macro-exten-vm:8] Macro("SIP/6001-00001dbd", "record-enable,1001,IN") in new stack
-- Executing [s@macro-record-enable:1] GotoIf("SIP/6001-00001dbd", "1?check") in new stack
-- Goto (macro-record-enable,s,4)
PRIME_BBCODE_SPOILER_SHOW PRIME_BBCODE_SPOILER:
== Using SIP RTP TOS bits 184
== Using SIP RTP CoS mark 5
-- Executing [4000@from-pstn:1] Set("SIP/6001-00001dc6", "__FROM_DID=4000") in new stack
-- Executing [4000@from-pstn:2] Gosub("SIP/6001-00001dc6", "app-blacklist-check,s,1") in new stack
-- Executing [s@app-blacklist-check:1] GotoIf("SIP/6001-00001dc6", "0?blacklisted") in new stack
-- Executing [s@app-blacklist-check:2] Set("SIP/6001-00001dc6", "CALLED_BLACKLIST=1") in new stack
-- Executing [s@app-blacklist-check:3] Return("SIP/6001-00001dc6", "") in new stack
-- Executing [4000@from-pstn:3] Gosub("SIP/6001-00001dc6", "cidlookup,cidlookup_1,1") in new stack
-- Executing [cidlookup_1@cidlookup:1] GotoIf("SIP/6001-00001dc6", "1?cidlookup,cidlookup_return,1") in new stack
-- Goto (cidlookup,cidlookup_return,1)
-- Executing [cidlookup_return@cidlookup:1] ExecIf("SIP/6001-00001dc6", "1?Set(CALLERID(name)=Иванов Иван Иванович)") in new stack
-- Executing [cidlookup_return@cidlookup:2] Return("SIP/6001-00001dc6", "") in new stack
-- Executing [4000@from-pstn:4] Set("SIP/6001-00001dc6", "CHANNEL(language)=ru") in new stack
-- Executing [4000@from-pstn:5] ExecIf("SIP/6001-00001dc6", "0 ?Set(CALLERID(name)=79ХХХХХХХХХ)") in new stack
-- Executing [4000@from-pstn:6] Wait("SIP/6001-00001dc6", "1") in new stack
-- Executing [4000@from-pstn:7] Set("SIP/6001-00001dc6", "__CALLINGPRES_SV=allowed_not_screened") in new stack
-- Executing [4000@from-pstn:8] Set("SIP/6001-00001dc6", "CALLERPRES()=allowed_not_screened") in new stack
-- Executing [4000@from-pstn:9] Goto("SIP/6001-00001dc6", "from-did-direct,1001,1") in new stack
-- Goto (from-did-direct,1001,1)
-- Executing [1001@from-did-direct:1] Macro("SIP/6001-00001dc6", "exten-vm,1001,1001") in new stack
-- Executing [s@macro-exten-vm:1] Macro("SIP/6001-00001dc6", "user-callerid,") in new stack
-- Executing [s@macro-user-callerid:1] Set("SIP/6001-00001dc6", "AMPUSER=79ХХХХХХХХХ") in new stack
-- Executing [s@macro-user-callerid:2] GotoIf("SIP/6001-00001dc6", "0?report") in new stack
-- Executing [s@macro-user-callerid:3] ExecIf("SIP/6001-00001dc6", "1?Set(REALCALLERIDNUM=79ХХХХХХХХХ)") in new stack
-- Executing [s@macro-user-callerid:4] Set("SIP/6001-00001dc6", "AMPUSER=") in new stack
-- Executing [s@macro-user-callerid:5] Set("SIP/6001-00001dc6", "AMPUSERCIDNAME=") in new stack
-- Executing [s@macro-user-callerid:6] GotoIf("SIP/6001-00001dc6", "1?report") in new stack
-- Goto (macro-user-callerid,s,10)
-- Executing [s@macro-user-callerid:10] GotoIf("SIP/6001-00001dc6", "0?continue") in new stack
-- Executing [s@macro-user-callerid:11] Set("SIP/6001-00001dc6", "__TTL=64") in new stack
-- Executing [s@macro-user-callerid:12] GotoIf("SIP/6001-00001dc6", "1?continue") in new stack
-- Goto (macro-user-callerid,s,19)
-- Executing [s@macro-user-callerid:19] Set("SIP/6001-00001dc6", "CALLERID(number)=79ХХХХХХХХХ") in new stack
-- Executing [s@macro-user-callerid:20] Set("SIP/6001-00001dc6", "CALLERID(name)=Иванов Иван Иванович") in new stack
-- Executing [s@macro-user-callerid:21] NoOp("SIP/6001-00001dc6", "Using CallerID "Иванов Иван Иванович" <79ХХХХХХХХХ>") in new stack
-- Executing [s@macro-exten-vm:2] Set("SIP/6001-00001dc6", "RingGroupMethod=none") in new stack
-- Executing [s@macro-exten-vm:3] Set("SIP/6001-00001dc6", "VMBOX=1001") in new stack
-- Executing [s@macro-exten-vm:4] Set("SIP/6001-00001dc6", "__EXTTOCALL=1001") in new stack
-- Executing [s@macro-exten-vm:5] Set("SIP/6001-00001dc6", "CFUEXT=") in new stack
-- Executing [s@macro-exten-vm:6] Set("SIP/6001-00001dc6", "CFBEXT=") in new stack
-- Executing [s@macro-exten-vm:7] Set("SIP/6001-00001dc6", "RT=120") in new stack
-- Executing [s@macro-exten-vm:8] Macro("SIP/6001-00001dc6", "record-enable,1001,IN") in new stack
-- Executing [s@macro-record-enable:1] GotoIf("SIP/6001-00001dc6", "1?check") in new stack
-- Goto (macro-record-enable,s,4)
== Using SIP RTP CoS mark 5
-- Executing [4000@from-pstn:1] Set("SIP/6001-00001dc6", "__FROM_DID=4000") in new stack
-- Executing [4000@from-pstn:2] Gosub("SIP/6001-00001dc6", "app-blacklist-check,s,1") in new stack
-- Executing [s@app-blacklist-check:1] GotoIf("SIP/6001-00001dc6", "0?blacklisted") in new stack
-- Executing [s@app-blacklist-check:2] Set("SIP/6001-00001dc6", "CALLED_BLACKLIST=1") in new stack
-- Executing [s@app-blacklist-check:3] Return("SIP/6001-00001dc6", "") in new stack
-- Executing [4000@from-pstn:3] Gosub("SIP/6001-00001dc6", "cidlookup,cidlookup_1,1") in new stack
-- Executing [cidlookup_1@cidlookup:1] GotoIf("SIP/6001-00001dc6", "1?cidlookup,cidlookup_return,1") in new stack
-- Goto (cidlookup,cidlookup_return,1)
-- Executing [cidlookup_return@cidlookup:1] ExecIf("SIP/6001-00001dc6", "1?Set(CALLERID(name)=Иванов Иван Иванович)") in new stack
-- Executing [cidlookup_return@cidlookup:2] Return("SIP/6001-00001dc6", "") in new stack
-- Executing [4000@from-pstn:4] Set("SIP/6001-00001dc6", "CHANNEL(language)=ru") in new stack
-- Executing [4000@from-pstn:5] ExecIf("SIP/6001-00001dc6", "0 ?Set(CALLERID(name)=79ХХХХХХХХХ)") in new stack
-- Executing [4000@from-pstn:6] Wait("SIP/6001-00001dc6", "1") in new stack
-- Executing [4000@from-pstn:7] Set("SIP/6001-00001dc6", "__CALLINGPRES_SV=allowed_not_screened") in new stack
-- Executing [4000@from-pstn:8] Set("SIP/6001-00001dc6", "CALLERPRES()=allowed_not_screened") in new stack
-- Executing [4000@from-pstn:9] Goto("SIP/6001-00001dc6", "from-did-direct,1001,1") in new stack
-- Goto (from-did-direct,1001,1)
-- Executing [1001@from-did-direct:1] Macro("SIP/6001-00001dc6", "exten-vm,1001,1001") in new stack
-- Executing [s@macro-exten-vm:1] Macro("SIP/6001-00001dc6", "user-callerid,") in new stack
-- Executing [s@macro-user-callerid:1] Set("SIP/6001-00001dc6", "AMPUSER=79ХХХХХХХХХ") in new stack
-- Executing [s@macro-user-callerid:2] GotoIf("SIP/6001-00001dc6", "0?report") in new stack
-- Executing [s@macro-user-callerid:3] ExecIf("SIP/6001-00001dc6", "1?Set(REALCALLERIDNUM=79ХХХХХХХХХ)") in new stack
-- Executing [s@macro-user-callerid:4] Set("SIP/6001-00001dc6", "AMPUSER=") in new stack
-- Executing [s@macro-user-callerid:5] Set("SIP/6001-00001dc6", "AMPUSERCIDNAME=") in new stack
-- Executing [s@macro-user-callerid:6] GotoIf("SIP/6001-00001dc6", "1?report") in new stack
-- Goto (macro-user-callerid,s,10)
-- Executing [s@macro-user-callerid:10] GotoIf("SIP/6001-00001dc6", "0?continue") in new stack
-- Executing [s@macro-user-callerid:11] Set("SIP/6001-00001dc6", "__TTL=64") in new stack
-- Executing [s@macro-user-callerid:12] GotoIf("SIP/6001-00001dc6", "1?continue") in new stack
-- Goto (macro-user-callerid,s,19)
-- Executing [s@macro-user-callerid:19] Set("SIP/6001-00001dc6", "CALLERID(number)=79ХХХХХХХХХ") in new stack
-- Executing [s@macro-user-callerid:20] Set("SIP/6001-00001dc6", "CALLERID(name)=Иванов Иван Иванович") in new stack
-- Executing [s@macro-user-callerid:21] NoOp("SIP/6001-00001dc6", "Using CallerID "Иванов Иван Иванович" <79ХХХХХХХХХ>") in new stack
-- Executing [s@macro-exten-vm:2] Set("SIP/6001-00001dc6", "RingGroupMethod=none") in new stack
-- Executing [s@macro-exten-vm:3] Set("SIP/6001-00001dc6", "VMBOX=1001") in new stack
-- Executing [s@macro-exten-vm:4] Set("SIP/6001-00001dc6", "__EXTTOCALL=1001") in new stack
-- Executing [s@macro-exten-vm:5] Set("SIP/6001-00001dc6", "CFUEXT=") in new stack
-- Executing [s@macro-exten-vm:6] Set("SIP/6001-00001dc6", "CFBEXT=") in new stack
-- Executing [s@macro-exten-vm:7] Set("SIP/6001-00001dc6", "RT=120") in new stack
-- Executing [s@macro-exten-vm:8] Macro("SIP/6001-00001dc6", "record-enable,1001,IN") in new stack
-- Executing [s@macro-record-enable:1] GotoIf("SIP/6001-00001dc6", "1?check") in new stack
-- Goto (macro-record-enable,s,4)