Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ambiorixg12/b6ba261b25d86d382f8a4afb20f86ce7 to your computer and use it in GitHub Desktop.
Save ambiorixg12/b6ba261b25d86d382f8a4afb20f86ce7 to your computer and use it in GitHub Desktop.
Allows to foward calls from one extensions to any other destination, and validate caller using the voicemail password
;;;;/etc/asterisk/extensions_override_freepbx.conf
[app-cf-on]
include => app-cf-on-custom
exten => lang-playback,1,GosubIf($[${DIALPLAN_EXISTS(app-cf-on,${CHANNEL(language)})}]?app-cf-on,${CHANNEL(language)},${ARG1}():app-cf-on,en,${ARG1}())
exten => lang-playback,n,Return()
exten => *72,1,Answer
exten => *72,n,Wait(1)
same=>n,Read(fromext,ent-target-attendant,11)
same=>n,Set(pass=${SHELL(php /var/www/html/vm-pass.php ${fromext})})
same=>n,Noop(......... Voicemail pass ${pass}........)
same=>n,Read(pass2,agent-pass)
same => n,GotoIf($["${pass:0:-1}"="${pass2}"]?allow:disallow)
same=>n,Hangup()
same=>n(disallow),playback(im-sorry)
same=>n,Hangup()
exten => *72,n(allow),GotoIf($["${fromext}"!=""]?startread)
exten => *72,n,Playback(agent-loggedoff)
exten => *72,n,Macro(hangupcall,)
exten => *72,n(startread),Gosub(app-cf-on,lang-playback,1(hook_1))
exten => *72,n,GotoIf($["foo${toext}"="foo"]?startread)
exten => *72,n,Wait(1)
exten => *72,n,Set(DB(CF/${fromext})=${toext})
exten => *72,n,Set(STATE=BUSY)
exten => *72,n,Gosub(app-cf-on,sstate,1())
exten => *72,n,Gosub(app-cf-on,lang-playback,1(hook_2))
exten => *72,n,Macro(hangupcall,)
;;;;;;;;;;;php script ;;;;;;;;;;;;;;;
<?php
echo $password=shell_exec("cat /etc/asterisk/voicemail.conf | grep $argv[1] | awk '{print $3}' | awk -F , '{print $1}'| sed -r '/^\s*$/d'");
exit();
?>
;;;;;;;;;;;;;;
to deactivate call foward add this code /etc/asterisk/extensions_custom.conf
[from-internal-custom]
exten => *173,1,Answer
exten => *173,n,Wait(1)
same=>n(fromext),Read(fromext,ent-target-attendant,11)
same=>n,GotoIf($["${fromext}"=""]?fromext)
exten => *173,n,Noop(Deleting: CF/${fromext} ${DB_DELETE(CF/${fromext})})
exten => *173,n,Set(STATE=NOT_INUSE)
exten => *173,n,Gosub(app-cf-off,sstate,1())
exten => *173,n,Gosub(app-cf-off,lang-playback,1(hook_0))
exten => *173,n,Macro(hangupcall,)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment