[general]
static = yes
writeprotect = no
clearglobalvars = no
autofallthrough=yes
[globals]
CONSOLE = Console/dsp
IAXINFO = guest
TRUNK = DAHDI/G2
TRUNKMSD = 1
QSCUSERID = 02****9220
PREFIX = 02**
p-ass = 02****92200
p-ass_1 = 02****92201
p-ass_2 = 02****92202
;******************************************************************************
[internal]
; outbound calls
exten => _+49.,1,Goto(out,0${EXTEN:3},1) ;Intern -> Extern alle Rurnummern die mit +49 beginnen
exten => _+.,1,Goto(out,0${EXTEN:1},1) ;Intern -> Extern alle Rurnummern die mit + beginnen
exten => _0.,1,Goto(out,${EXTEN},1) ;Intern -> Extern alle Rurnummern die mit 0 beginnen
exten => _ZXXXX.,1,Goto(out,${PREFIX}${EXTEN},1);Intern -> Extern alle RN die nicht mit 0 beginnen aber min 5 Ziffern haben
exten => _11[02],1,Goto(out,${EXTEN},1) ;Intern -> Extern Die Notrufnummern 110 und 112
exten => 911,1,Goto(out,${EXTEN},1) ;Intern -> Extern Die Notrufnummer 911
; internal calls
exten => _Z.,1,Goto(local,${EXTEN},1) ;Intern -> Intern alle Rurnummern die mit 1-9 beginnen
exten => _*.,1,Goto(local,${EXTEN},1) ;Intern -> Intern Zentrale über *0
exten => _02****9220X.,1,Goto(local,${EXTEN:10},1)
exten => _+492****9220X.,1,Goto(local,${EXTEN:12},1)
exten => _0049****59220X.,1,Goto(local,${EXTEN:13},1)
; fax
exten => 290,1,Goto(fax-receive,290,1) ;Intern -> Intern faxen
;******************************************************************************
[local]
exten => 290,1,Goto(fax-receive,290,1) ;Extern -> Softfax
exten => *290,1,Goto(fax-receive,290,1) ;Intern -> Softfax
;###################### SIP Telefone ######################
;Max Muster
exten => *272,1,Goto(272,1)
exten => 272,hint,SIP/272
exten => 272,1,NoOp(Begin 272)
exten => 272,n,Answer()
exten => 272,n,Wait(0.5)
exten => 272,n,System(php5 /etc/asterisk/callproto.php 1 ${UNIQUEID} 272 ${CALLERID(num)} 2 &)
exten => 272,n,GotoIf($[${inuse272}=1]?jmpInUse272:jmpNoUse272)
exten => 272,n(jmpInUse272),NoOp(InUse 272)
exten => 272,n,GotoIf($[${ISNULL(${CALLERID(num)})}]?jmpInUseNoCid272:jmpInUseCid272)
exten => 272,n(jmpNoUse272),NoOp(NoUse 272)
exten => 272,n,Set(inuse272=1)
exten => 272,n,Dial(SIP/272,10,tTwWm(freewelcome))
exten => 272,n,GotoIf($[${ISNULL(${CALLERID(num)})}]?jmpNoUseNoCid272:jmpNoUseCid272)
exten => 272,n(jmpInUseNoCid272),NoOp(InUseNoCid 272)
exten => 272,n,Dial(SIP/272,16,tTwWm(busynocid))
exten => 272,n,Dial(SIP/234,500,tTwWm(busynocid))
exten => 272,n,Goto(jmpEnd272)
exten => 272,n(jmpInUseCid272),NoOp(InUseCid 272)
exten => 272,n,AGI(sendcallback.php|272,${CALLERID(num)},${CDR(uniqueid)})
exten => 272,n,Dial(SIP/272,30,tTwWm(busycid))
exten => 272,n,Dial(SIP/234,500,tTwWm(busycid))
exten => 272,n,Goto(jmpEnd272)
exten => 272,n(jmpNoUseNoCid272),NoOp(NoUseNoCid 272)
exten => 272,n,Dial(SIP/272,15,tTwWm(freewelcomenocid))
exten => 272,n,Dial(SIP/234,500,tTwWm(freewelcomenocid))
exten => 272,n,Goto(jmpEnd272)
exten => 272,n(jmpNoUseCid272),NoOp(NoUseCid 272)
exten => 272,n,AGI(sendcallback.php,272,${CALLERID(num)},${CDR(uniqueid)})
exten => 272,n,Dial(SIP/272,20,tTwWm(freewelcomecid))
exten => 272,n,Dial(SIP/234,500,tTwWm(freewelcomecid))
exten => 272,n,Goto(jmpEnd272)
exten => 272,n(jmpEnd272),NoOp(End 272)
exten => 272,n,Set(inuse272=0)
exten => 272,n,System(php5 /etc/asterisk/callproto.php 2 ${UNIQUEID} ${ANSWEREDTIME} ${DIALEDTIME} &)
exten => 272,n,HangUp()
;Manni Muster
exten => *161,1,Goto(161,1)
exten => 161,hint,SIP/161
exten => 161,1,NoOp(Begin 161)
exten => 161,n,Answer()
exten => 161,n,Wait(0.5)
exten => 161,n,System(php5 /etc/asterisk/callproto.php 1 ${UNIQUEID} 161 ${CALLERID(num)} 2 &)
exten => 161,n,GotoIf($[${inuse161}=1]?jmpInUse161:jmpNoUse161)
exten => 161,n(jmpInUse161),NoOp(InUse 161)
exten => 161,n,GotoIf($[${ISNULL(${CALLERID(num)})}]?jmpInUseNoCid161:jmpInUseCid161)
exten => 161,n(jmpNoUse161),NoOp(NoUse 161)
exten => 161,n,Set(inuse161=1)
exten => 161,n,Dial(SIP/161,10,tTwWm(freewelcome))
exten => 161,n,GotoIf($[${ISNULL(${CALLERID(num)})}]?jmpNoUseNoCid161:jmpNoUseCid161)
exten => 161,n(jmpInUseNoCid161),NoOp(InUseNoCid 161)
exten => 161,n,Dial(SIP/161,16,tTwWm(busynocid))
exten => 161,n,Dial(SIP/152&SIP/246&SIP/214&SIP/151&SIP/160&SIP/221&SIP/131&SIP/212,500,tTwWm(busynocid))
exten => 161,n,Goto(jmpEnd161)
exten => 161,n(jmpInUseCid161),NoOp(InUseCid 161)
exten => 161,n,AGI(sendcallback.php|161,${CALLERID(num)},${CDR(uniqueid)})
exten => 161,n,Dial(SIP/161,30,tTwWm(busycid))
exten => 161,n,Dial(SIP/152&SIP/246&SIP/214&SIP/151&SIP/160&SIP/221&SIP/131&SIP/212,500,tTwWm(busycid))
exten => 161,n,Goto(jmpEnd161)
exten => 161,n(jmpNoUseNoCid161),NoOp(NoUseNoCid 161)
exten => 161,n,Dial(SIP/161,15,tTwWm(freewelcomenocid))
exten => 161,n,Dial(SIP/152&SIP/246&SIP/214&SIP/151&SIP/160&SIP/221&SIP/131&SIP/212,500,tTwWm(freewelcomenocid))
exten => 161,n,Goto(jmpEnd161)
exten => 161,n(jmpNoUseCid161),NoOp(NoUseCid 161)
exten => 161,n,AGI(sendcallback.php,161,${CALLERID(num)},${CDR(uniqueid)})
exten => 161,n,Dial(SIP/161,20,tTwWm(freewelcomecid))
exten => 161,n,Dial(SIP/152&SIP/246&SIP/214&SIP/151&SIP/160&SIP/221&SIP/131&SIP/212,500,tTwWm(freewelcomecid))
exten => 161,n,Goto(jmpEnd161)
exten => 161,n(jmpEnd161),NoOp(End 161)
exten => 161,n,Set(inuse161=0)
exten => 161,n,System(php5 /etc/asterisk/callproto.php 2 ${UNIQUEID} ${ANSWEREDTIME} ${DIALEDTIME} &)
exten => 161,n,HangUp()
;###################### Weiterleitng ######################
; Max Mustermum
exten => *321,1,Goto(redirect,03*********321,1)
exten => 321,1,Goto(redirect,03***********321,1)
; Monika Muster
exten => *322,1,Goto(redirect,03*********322,1)
exten => 322,1,Goto(redirect,03*********322,1)
;******************************************************************************
[Zentrale]
exten => *0,1,Goto(local,0,1)
exten => 0,1,Answer()
same => n,NoOp(Queue Zentrale...)
same => n,System(php5 /etc/asterisk/callproto.php 1 ${UNIQUEID} 0 ${CALLERID(num)} 2 &)
same => n,Queue(Zentrale,t,,,17)
same => n,NoOp(Queue Zentrale2...)
same => n,Queue(Zentrale2,t,,,60)
same => n,NoOp(Queue Zentrale2 ende...)
same => n,GotoIf($[${ISNULL(${CALLERID(num)})}]?jmpNoCidZentrale:jmpCidZentrale)
same => n(jmpNoCidZentrale),NoOp(NoCidZentrale)
same => n,AGI(sendcallback.php|Zentrale|Anonymous)
same => n,Playback(vm-goodbye)
same => n,Goto(jmpEndZentrale)
same => n(jmpCidZentrale),NoOp(CidZentrale)
same => n,AGI(sendcallback.php|Zentrale|${CALLERID(num)})
same => n,Playback(vm-goodbye)
same => n,Goto(jmpEndZentrale)
same => n(jmpEndZentrale),NoOp(EndZentrale)
same => n,System(php5 /etc/asterisk/callproto.php 2 ${UNIQUEID} ${ANSWEREDTIME} ${DIALEDTIME} &)
same => n,HangUp()
;******************************************************************************
[redirect]
exten => _X.,1,NoOp(REDIRECTING ${CALLERID(num)} -> ${EXTEN})
same => n,ExecIf($[${REGEX("^[0-9]{3}$" ${CALLERID(num)})}]?Set(CALLERID(num)=${QSCUSERID}${CALLERID(num)}))
same => n,Set(CALLERID(all)="${CALLERID(num)}" <${CALLERID(num)}>,a)
same => n,SIPAddHeader(P-Asserted-Identity: <sip:${p-ass}@sip.qsc.de:5060\;user=phone>)
same => n,SIPAddHeader(X-Best-Codec: ${CHANNEL(audionativeformat)})
same => n,Dial(SIP/${EXTEN}@qsc-0,120,tT)
same => n,Playback(invalid)
;******************************************************************************
[macro-from-sip]
exten => s,1,NoOp(macro-from-sip)
same => 2,Set(tmpcid=${CUT(ARG1,:,2)})
same => n,Set(BNUMBER=${CUT(tmpcid,@,1)})
same => n,Set(BNUMBER1=${BNUMBER:${LEN(${QSCUSERID})}})
same => n,AGI(phonebook_lookup.php)
same => n,Set(CALLERID(name)=${phonebook_name})
same => n,Goto(local,${BNUMBER1},1)
;******************************************************************************
[qsc-headers-0]
exten => _X.,1,NoOp(adding qsc-headers-0)
same => n,Set(CALLERID(all)="${CALLERID(num)}" <${QSCUSERID}${CALLERID(num)}>,a)
same => n,SIPAddHeader(P-Asserted-Identity: <sip:${p-ass}@sip.qsc.de:5060\;user=phone>)
same => n,Return()
[qsc-headers-1]
exten => _X.,1,NoOp(adding qsc-headers-1)
same => n,Set(CALLERID(all)="${CALLERID(num)}" <${QSCUSERID}${CALLERID(num)}>,a)
same => n,SIPAddHeader(P-Asserted-Identity: <sip:${p-ass_1}@sip.qsc.de:5060\;user=phone>)
same => n,Return()
[qsc-headers-2]
exten => _X.,1,NoOp(adding qsc-headers-2)
same => n,Set(CALLERID(all)="${CALLERID(num)}" <${QSCUSERID}${CALLERID(num)}>,a)
same => n,SIPAddHeader(P-Asserted-Identity: <sip:${p-ass_2}@sip.qsc.de:5060\;user=phone>)
same => n,Return()
;******************************************************************************
[out]
exten => _X.,1,NoOp(routing outgoing call)
same => n,Ringing
same => n,GoSubIf($[{CALLERID(num)}:0]?out-0,${EXTEN},1)
same => n,GoSubIf($[{CALLERID(num)}:1]?out-1,${EXTEN},1)
same => n,GoSubIf($[{CALLERID(num)}:2]?out-2,${EXTEN},1)
same => n,GoSub(out-0,${EXTEN},1)
same => n,Playback(invalid)
[out-0]
exten => _X.,1,NoOp(passing to out-0)
same => n,GoSub(qsc-headers-0,${EXTEN},1)
same => n,Dial(SIP/${EXTEN}@qsc-0,120,tT)
[out-1]
exten => _X.,1,NoOp(passing to out-1)
same => n,GoSub(qsc-headers-1,${EXTEN},1)
same => n,Dial(SIP/${EXTEN}@qsc-1,120,tT)
[out-2]
exten => _X.,1,NoOp(passing to out-2)
same => n,GoSub(qsc-headers-2,${EXTEN},1)
same => n,Dial(SIP/${EXTEN}@qsc-2,120,tT)
;******************************************************************************
[qsc-incoming]
; call-through (get extension from sip header)
;exten => _X.,1,ExecIf($["${SIP_HEADER(P-Called-Party-ID)}" != ""]?macro(from-sip,${SIP_HEADER(P-Called-Party-ID)}))
exten => _X.,1,ExecIf($[$<{SIP_HEADER(P-Called-Party-ID)}> != ""]?macro(from-sip,${SIP_HEADER(P-Called-Party-ID)}))
exten => _X.,2,ExecIf($[$<{SIP_HEADER(TO)}> != ""]?macro(from-sip,${SIP_HEADER(TO)}))
exten => _X.,n,Set(BNUMBER=${DNID})
exten => _X.,n,GotoIf($[${LEN(${BNUMBER})} > ${LEN(${QSCUSERID})}}]?6,7)
exten => _X.,n,Set(EXTNUMBER=${${BNUMBER}:${LEN(${QSCUSERID})}})
exten => _X.,n,Set(EXTNUMBER=${BNUMBER})
exten => _X.,n,Goto(local,${EXTNUMBER},1)
;******************************************************************************
[fax-receive]
exten => _X.,1,Noop(Receiving Fax ${CDR(uniqueid)})
same => n,Set(LOCALSTATIONID=*********************)
same => n,ReceiveFAX(/tmp/fax-${CDR(uniqueid)}.tif)
same => n,Hangup()
exten => h,1,Noop(Mailing Fax ${CDR(uniqueid)})
same => n,System(/etc/asterisk/fax2email.sh ${CDR(uniqueid)} ${CALLERID(num)} > /tmp/fax.log 2>&1)