From accadaaad69ac79825d584f1997bcb3ba55fab8a Mon Sep 17 00:00:00 2001 From: mcrane Date: Tue, 21 Apr 2009 13:18:26 -0600 Subject: FreeSWITCH add DISA, audio files, javascript include config.js modify recording js to use it --- .../freeswitch/call_forward_has_been_deleted.wav | Bin 0 -> 28668 bytes config/freeswitch/call_forward_has_been_set.wav | Bin 0 -> 30976 bytes config/freeswitch/disa.js | 78 +++++++ config/freeswitch/freeswitch.inc | 229 +++++++++++++-------- config/freeswitch/freeswitch.xml | 15 -- config/freeswitch/freeswitch_features.tmp | 58 ++++-- config/freeswitch/freeswitch_recordings.tmp | 9 +- .../please_enter_the_extension_number.wav | Bin 0 -> 32360 bytes .../freeswitch/please_enter_the_phone_number.wav | Bin 0 -> 26552 bytes config/freeswitch/please_enter_the_pin_number.wav | Bin 0 -> 27504 bytes 10 files changed, 268 insertions(+), 121 deletions(-) create mode 100644 config/freeswitch/call_forward_has_been_deleted.wav create mode 100644 config/freeswitch/call_forward_has_been_set.wav create mode 100644 config/freeswitch/disa.js create mode 100644 config/freeswitch/please_enter_the_extension_number.wav create mode 100644 config/freeswitch/please_enter_the_phone_number.wav create mode 100644 config/freeswitch/please_enter_the_pin_number.wav diff --git a/config/freeswitch/call_forward_has_been_deleted.wav b/config/freeswitch/call_forward_has_been_deleted.wav new file mode 100644 index 00000000..ebe6ed36 Binary files /dev/null and b/config/freeswitch/call_forward_has_been_deleted.wav differ diff --git a/config/freeswitch/call_forward_has_been_set.wav b/config/freeswitch/call_forward_has_been_set.wav new file mode 100644 index 00000000..58262852 Binary files /dev/null and b/config/freeswitch/call_forward_has_been_set.wav differ diff --git a/config/freeswitch/disa.js b/config/freeswitch/disa.js new file mode 100644 index 00000000..5cff6424 --- /dev/null +++ b/config/freeswitch/disa.js @@ -0,0 +1,78 @@ +include("/usr/local/freeswitch/scripts/config.js"); + + //var admin_pin = ""; //don't require a pin + //if you choose not to require a pin then then you may want to add a dialplan condition for a specific caller id + var predefined_destination = ""; //example: 9999 + //predefined_destination leave empty in most cases + //Use this to define a single destination + var digitmaxlength = 0; + var timeoutpin = 7500; + var timeouttransfer = 7500; + + function mycb( session, type, obj, arg ) { + try { + if ( type == "dtmf" ) { + console_log( "info", "digit: "+obj.digit+"\n" ); + if ( obj.digit == "#" ) { + //console_log( "info", "detected pound sign.\n" ); + exit = true; + return( false ); + } + + dtmf.digits += obj.digit; + + if ( dtmf.digits.length >= digitmaxlength ) { + exit = true; + return( false ); + } + } + } catch (e) { + console_log( "err", e+"\n" ); + } + return( true ); + } //end function mycb + + + //console_log( "info", "DISA Request\n" ); + + var dtmf = new Object( ); + dtmf.digits = ""; + + if ( session.ready( ) ) { + session.answer( ); + + if (admin_pin.length > 0) { + digitmaxlength = 6; + session.streamFile( "/usr/local/freeswitch/sounds/custom/8000/please_enter_the_pin_number.wav", mycb, "dtmf"); + session.collectInput( mycb, dtmf, timeoutpin ); + //console_log( "info", "DISA pin: " + dtmf.digits + "\n" ); + } + + if (dtmf.digits == admin_pin || admin_pin.length == 0) { + + //console_log( "info", "DISA pin is correct\n" ); + + us_ring = session.getVariable("us-ring"); + session.execute("set", "ringback="+us_ring); //set to ringtone + session.execute("set", "transfer_ringback="+us_ring); //set to ringtone + session.execute("set", "hangup_after_bridge=true"); + + if (predefined_destination.length == 0) { + dtmf.digits = ""; //clear dtmf digits to prepare for next dtmf request + digitmaxlength = 11; + session.streamFile( "/usr/local/freeswitch/sounds/custom/8000/please_enter_the_phone_number.wav", mycb, "dtmf"); + session.collectInput( mycb, dtmf, timeouttransfer ); + console_log( "info", "DISA Transfer: " + dtmf.digits + "\n" ); + session.execute("transfer", dtmf.digits + " XML default"); + } + else { + session.execute("transfer", predefined_destination + " XML default"); + } + + } + else { + session.streamFile( "/usr/local/freeswitch/sounds/custom/8000/your_pin_number_is_incorect_goodbye.wav", mycb, "dtmf"); + console_log( "info", "DISA Pin: " + dtmf.digits + " is incorrect\n" ); + } + + } diff --git a/config/freeswitch/freeswitch.inc b/config/freeswitch/freeswitch.inc index d3bc7883..09406d2a 100755 --- a/config/freeswitch/freeswitch.inc +++ b/config/freeswitch/freeswitch.inc @@ -256,7 +256,7 @@ function recording_js() //$tmp .= " session.execute(\"speak\", \"Please enter your pin number now.\");\n"; $tmp .= " digitmaxlength = 6;\n"; $tmp .= " session.execute(\"set\", \"playback_terminators=#\");\n"; - $tmp .= " session.streamFile( \"/usr/local/freeswitch/recordings/please_enter_your_pin_number.wav\", mycb, \"dtmf\");\n"; + $tmp .= " session.streamFile( \"/usr/local/www/freeswitch/sounds/custom/8000/please_enter_your_pin_number.wav\", mycb, \"dtmf\");\n"; $tmp .= " session.collectInput( mycb, dtmf, timeoutpin );\n"; $tmp .= " }\n"; $tmp .= "\n"; @@ -265,7 +265,7 @@ function recording_js() //$tmp .= " session.execute(\"set\", \"tts_engine=flite\");\n"; //$tmp .= " session.execute(\"set\", \"tts_voice=kal\");\n"; //$tmp .= " session.execute(\"speak\", \"Begin recording.\");\n"; - $tmp .= " session.streamFile( \"/usr/local/freeswitch/recordings/begin_recording.wav\", mycb, \"dtmf\");\n"; + $tmp .= " session.streamFile( \"/usr/local/www/freeswitch/sounds/custom/8000/begin_recording.wav\", mycb, \"dtmf\");\n"; $tmp .= " session.execute(\"set\", \"playback_terminators=#\");\n"; $tmp .= " session.execute(\"record\", \"/usr/local/freeswitch/recordings/temp\"+Year+Month+Day+Hours+Mins+Seconds+\".wav 180 200\");\n"; $tmp .= " }\n"; @@ -274,7 +274,7 @@ function recording_js() //$tmp .= " session.execute(\"set\", \"tts_engine=flite\");\n"; //$tmp .= " session.execute(\"set\", \"tts_voice=kal\");\n"; //$tmp .= " session.execute(\"speak\", \"Your pin number is incorect, goodbye.\");\n"; - $tmp .= " session.streamFile( \"/usr/local/freeswitch/recordings/your_pin_number_is_incorect_goodbye.wav\", mycb, \"dtmf\");\n"; + $tmp .= " session.streamFile( \"/usr/local/www/freeswitch/sounds/custom/8000/your_pin_number_is_incorect_goodbye.wav\", mycb, \"dtmf\");\n"; $tmp .= " }\n"; $tmp .= " session.hangup();\n"; $tmp .= "\n"; @@ -297,51 +297,60 @@ function sync_package_freeswitch_settings() foreach($config['installedpackages']['freeswitchsettings']['config'] as $rowhelper) { - $fout = fopen("/usr/local/freeswitch/conf/directory/default/default.xml","w"); - $tmpxml = "\n"; - $tmpxml .= " \n"; - $tmpxml .= " \n"; - $tmpxml .= " \n"; - $tmpxml .= " \n"; - $tmpxml .= " \n"; - $tmpxml .= " \n"; - $tmpxml .= " \n"; - $tmpxml .= " \n"; - $tmpxml .= " \n"; - $tmpxml .= "\n"; - fwrite($fout, $tmpxml); - unset($tmpxml); - fclose($fout); + $fout = fopen("/usr/local/freeswitch/conf/directory/default/default.xml","w"); + $tmpxml = "\n"; + $tmpxml .= " \n"; + $tmpxml .= " \n"; + $tmpxml .= " \n"; + $tmpxml .= " \n"; + $tmpxml .= " \n"; + $tmpxml .= " \n"; + $tmpxml .= " \n"; + $tmpxml .= " \n"; + $tmpxml .= " \n"; + $tmpxml .= "\n"; + fwrite($fout, $tmpxml); + unset($tmpxml); + fclose($fout); - $fout = fopen("/usr/local/freeswitch/conf/autoload_configs/event_socket.conf.xml","w"); - $tmpxml = "\n"; - $tmpxml .= " \n"; - $tmpxml .= " \n"; - $tmpxml .= " \n"; - $tmpxml .= " \n"; - $tmpxml .= " \n"; - $tmpxml .= " \n"; - $tmpxml .= ""; - fwrite($fout, $tmpxml); - unset($tmpxml, $event_socket_password); - fclose($fout); + $fout = fopen("/usr/local/freeswitch/conf/autoload_configs/event_socket.conf.xml","w"); + $tmpxml = "\n"; + $tmpxml .= " \n"; + $tmpxml .= " \n"; + $tmpxml .= " \n"; + $tmpxml .= " \n"; + $tmpxml .= " \n"; + $tmpxml .= " \n"; + $tmpxml .= ""; + fwrite($fout, $tmpxml); + unset($tmpxml, $event_socket_password); + fclose($fout); - $fout = fopen("/usr/local/freeswitch/conf/autoload_configs/xml_rpc.conf","w"); - $tmpxml = "\n"; - $tmpxml .= " \n"; - $tmpxml .= " \n"; - $tmpxml .= " \n"; - $tmpxml .= " \n"; - $tmpxml .= " \n"; - $tmpxml .= " \n"; - $tmpxml .= " \n"; - $tmpxml .= " \n"; - $tmpxml .= "\n"; - fwrite($fout, $tmpxml); - unset($tmpxml, $event_socket_password); - fclose($fout); + $fout = fopen("/usr/local/freeswitch/conf/autoload_configs/xml_rpc.conf","w"); + $tmpxml = "\n"; + $tmpxml .= " \n"; + $tmpxml .= " \n"; + $tmpxml .= " \n"; + $tmpxml .= " \n"; + $tmpxml .= " \n"; + $tmpxml .= " \n"; + $tmpxml .= " \n"; + $tmpxml .= " \n"; + $tmpxml .= "\n"; + fwrite($fout, $tmpxml); + unset($tmpxml, $event_socket_password); + fclose($fout); - recording_js(); + recording_js(); + + //config.js + $admin_pin = $config['installedpackages']['freeswitchsettings']['config'][0]['admin_pin']; + $fout = fopen("/usr/local/freeswitch/scripts/config.js","w"); + $tmp = "//javascript include\n\n"; + $tmp .= "var admin_pin = \"" . $admin_pin . "\";\n"; + fwrite($fout, $tmp); + unset($tmp); + fclose($fout); } @@ -1701,17 +1710,25 @@ function freeswitch_php_install_command() //remove some default config files that are not needed unlink_if_exists("/usr/local/freeswitch/conf/dialplan/default/01_example.com.xml"); - unlink_if_exists("/usr/local/freeswitch/conf/dialplan/public/00_inbound_did.xml"); + unlink_if_exists("/usr/local/freeswitch/conf/dialplan/public/00_inbound_did.xml"); - //copy audio files - exec("cp /tmp/please_enter_your_pin_number.wav /usr/local/freeswitch/recordings/please_enter_your_pin_number.wav"); - unlink_if_exists("/tmp/please_enter_your_pin_number.wav"); + if (!is_dir('/usr/local/www/freeswitch/sounds/custom/')) { + exec("mkdir /usr/local/www/freeswitch/sounds/custom/"); + } - exec("cp /tmp/begin_recording.wav /usr/local/freeswitch/recordings/begin_recording.wav"); - unlink_if_exists("/tmp/begin_recording.wav"); + if (!is_dir('/usr/local/www/freeswitch/sounds/custom/8000/')) { + exec("mkdir /usr/local/www/freeswitch/sounds/custom/8000/"); + } - exec("cp /tmp/your_pin_number_is_incorect_goodbye.wav /usr/local/freeswitch/recordings/your_pin_number_is_incorect_goodbye.wav"); - unlink_if_exists("/tmp/your_pin_number_is_incorect_goodbye.wav"); + //copy audio files + exec("cd /usr/local/www/freeswitch/sounds/custom/8000/;fetch http://www.pfsense.com/packages/config/freeswitch/please_enter_your_pin_number.wav"); + exec("cd /usr/local/www/freeswitch/sounds/custom/8000/;fetch http://www.pfsense.com/packages/config/freeswitch/please_enter_the_pin_number.wav"); + exec("cd /usr/local/www/freeswitch/sounds/custom/8000/;fetch http://www.pfsense.com/packages/config/freeswitch/please_enter_the_extension_number.wav"); + exec("cd /usr/local/www/freeswitch/sounds/custom/8000/;fetch http://www.pfsense.com/packages/config/freeswitch/please_enter_the_phone_number.wav"); + exec("cd /usr/local/www/freeswitch/sounds/custom/8000/;fetch http://www.pfsense.com/packages/config/freeswitch/call_forward_has_been_set.wav"); + exec("cd /usr/local/www/freeswitch/sounds/custom/8000/;fetch http://www.pfsense.com/packages/config/freeswitch/call_forward_has_been_deleted.wav"); + exec("cd /usr/local/www/freeswitch/sounds/custom/8000/;fetch http://www.pfsense.com/packages/config/freeswitch/begin_recording.wav"); + exec("cd /usr/local/www/freeswitch/sounds/custom/8000/;fetch http://www.pfsense.com/packages/config/freeswitch/your_pin_number_is_incorect_goodbye.wav"); //rename .so files from .1 to .so @@ -1803,6 +1820,9 @@ function freeswitch_php_install_command() exec("cp /tmp/freeswitch_time_conditions_edit.tmp /usr/local/www/freeswitch/freeswitch_time_conditions_edit.php"); unlink_if_exists("/tmp/freeswitch_time_conditions_edit.tmp"); + + exec("cp /tmp/disa.js /usr/local/www/freeswitch/scripts/disa.js"); + unlink_if_exists("/tmp/disa.js"); exec("cp /usr/local/freeswitch/htdocs/slim.swf /usr/local/www/freeswitch/slim.swf"); @@ -1872,36 +1892,82 @@ function freeswitch_php_install_command() $i++; } } - - $dialplanincludeid = guid(); - - $ent = array(); - $ent['dialplanincludeid'] = $dialplanincludeid; - $ent['extensionname'] = 'Recordings'; - $ent['order'] = '9000'; - $ent['context'] = 'default'; - $ent['enabled'] = 'true'; - $ent['descr'] = 'Default system recordings tool'; - $a_dialplan_includes[] = $ent; - unset($ent); - - $ent = array(); - $ent['dialplanincludeid'] = $dialplanincludeid; - $ent['tag'] = 'condition'; //condition, action, antiaction - $ent['fieldtype'] = 'destination_number'; - $ent['fielddata'] = '^732673$'; - $a_dialplan_include_details[] = $ent; - unset($ent); - - $ent = array(); - $ent['dialplanincludeid'] = $dialplanincludeid; - $ent['tag'] = 'action'; //condition, action, antiaction - $ent['fieldtype'] = 'javascript'; - $ent['fielddata'] = 'recordings.js'; - $a_dialplan_include_details[] = $ent; - unset($ent); + + //add recording to the dialplan + $dialplanincludeid = guid(); + + $ent = array(); + $ent['dialplanincludeid'] = $dialplanincludeid; + $ent['extensionname'] = 'Recordings'; + $ent['order'] = '9000'; + $ent['context'] = 'default'; + $ent['enabled'] = 'true'; + $ent['descr'] = '*732673 Default system recordings tool'; + $a_dialplan_includes[] = $ent; + unset($ent); + + $ent = array(); + $ent['dialplanincludeid'] = $dialplanincludeid; + $ent['tag'] = 'condition'; //condition, action, antiaction + $ent['fieldtype'] = 'destination_number'; + $ent['fielddata'] = '^\*(732673)$'; + $a_dialplan_include_details[] = $ent; + unset($ent); + + $ent = array(); + $ent['dialplanincludeid'] = $dialplanincludeid; + $ent['tag'] = 'action'; //condition, action, antiaction + $ent['fieldtype'] = 'javascript'; + $ent['fielddata'] = 'recordings.js'; + $a_dialplan_include_details[] = $ent; + unset($ent); write_config(); + + //delete dialplan DISA from the previous install + $disa_enabled = 'false'; + if (count($a_dialplan_includes) > 0) { + $i = 0; + foreach ($a_dialplan_includes as $ent) { + if ($ent['extensionname'] == "DISA") { + $disa_enabled = $ent['enabled']; + unset($a_dialplan_includes[$i]); + } + $i++; + } + } + if (strlen( + + //add the DISA to the dialplan + $dialplanincludeid = guid(); + + $ent = array(); + $ent['dialplanincludeid'] = $dialplanincludeid; + $ent['extensionname'] = 'DISA'; + $ent['order'] = '000'; + $ent['context'] = 'default'; + $ent['enabled'] = disa_enabled; + $ent['descr'] = '*3472 Direct Inward System Access'; + $a_dialplan_includes[] = $ent; + unset($ent); + + $ent = array(); + $ent['dialplanincludeid'] = $dialplanincludeid; + $ent['tag'] = 'condition'; //condition, action, antiaction, set + $ent['fieldtype'] = 'destination_number'; + $ent['fielddata'] = '^\*(3472)$'; + $a_dialplan_include_details[] = $ent; + unset($ent); + + $ent = array(); + $ent['dialplanincludeid'] = $dialplanincludeid; + $ent['tag'] = 'action'; //condition, action, antiaction, set + $ent['fieldtype'] = 'javascript'; + $ent['fielddata'] = 'disa.js'; + $a_dialplan_include_details[] = $ent; + unset($ent); + + write_config(); //prepare switch.conf.xml for voicemail to email $filename = "/usr/local/freeswitch/conf/autoload_configs/switch.conf.xml"; @@ -2168,6 +2234,7 @@ function freeswitch_php_install_command() exec("cp /usr/local/freeswitch/conf/directory/default/brian.xml /usr/local/freeswitch/conf/directory/default/brian.xml.noload"); unlink_if_exists("/usr/local/freeswitch/conf/directory/default/brian.xml"); unlink_if_exists("/usr/local/freeswitch/conf/directory/default/example.com.xml"); + unlink_if_exists("/usr/local/freeswitch/conf/directory/default/99999_enum.xml"); write_rcfile(array( "file" => "freeswitch.sh", diff --git a/config/freeswitch/freeswitch.xml b/config/freeswitch/freeswitch.xml index 7cde23c0..02079f2b 100644 --- a/config/freeswitch/freeswitch.xml +++ b/config/freeswitch/freeswitch.xml @@ -164,21 +164,6 @@ 0755 http://www.pfsense.com/packages/config/freeswitch/libiconv.so.3 - - /tmp/ - 0755 - http://www.pfsense.com/packages/config/freeswitch/please_enter_your_pin_number.wav - - - /tmp/ - 0755 - http://www.pfsense.com/packages/config/freeswitch/begin_recording.wav - - - /tmp/ - 0755 - http://www.pfsense.com/packages/config/freeswitch/your_pin_number_is_incorect_goodbye.wav - /tmp/ 0755 diff --git a/config/freeswitch/freeswitch_features.tmp b/config/freeswitch/freeswitch_features.tmp index 1929315f..62942ff8 100644 --- a/config/freeswitch/freeswitch_features.tmp +++ b/config/freeswitch/freeswitch_features.tmp @@ -104,11 +104,30 @@ include("head.inc"); calls to extensions, voicemail, queues, other IVR applications, and external phone numbers. - - - + + + +
+
+ + + + + + + + + +
Direct Inward System Access (DISA)
+ DISA allows inbound callers to make internal or external calls. For security reasons it is disabled by default. + To enable it first set a secure pin number from the Settings->Admin PIN Number. + Then go to Dialplan tab and find the DISA entry and edit it to set 'Enabled' to 'true'. + To use DISA dial *3427 (disa) enter the admin pin code and the extension or phone number you wish to call. +
+

+ @@ -132,11 +151,11 @@ include("head.inc"); - -
Open - Music on hold can be in WAV or MP3 format. To play MP3 you must have mod_shout enabled - on the 'Modules' tab. For best performance upload 16bit 8khz/16khz Mono WAV files. + + Music on hold can be in WAV format. For best performance upload 16bit 8khz/16khz Mono WAV files.
+ +

@@ -148,24 +167,21 @@ include("head.inc"); Open - To make a recording dial extension 732673 (record) or you can make a 16bit 8khz/16khz + To make a recording dial *732673 (record) or you can make a 16bit 8khz/16khz Mono WAV file then copy it to the following directory then refresh the page to play it back. Click on the 'Filename' to download it or the 'Recording Name' to play the audio. - - + + -
-
- -
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
diff --git a/config/freeswitch/freeswitch_recordings.tmp b/config/freeswitch/freeswitch_recordings.tmp index 62d81ae2..6fb1a2e8 100644 --- a/config/freeswitch/freeswitch_recordings.tmp +++ b/config/freeswitch/freeswitch_recordings.tmp @@ -281,7 +281,7 @@ if ($config_change == 1) {

Recordings:
- To make a recording dial extension 732673 (record) or you can make a + To make a recording dial *732673 (record) or you can make a 16bit 8khz/16khz Mono WAV file then copy it to the following directory then refresh the page to play it back. Click on the 'Filename' to download it or the 'Recording Name' to @@ -391,9 +391,10 @@ if ($config_change == 1) {

Music on Hold:
- Music on hold can be in WAV or MP3 format. To play MP3 you must have - mod_shout enabled on the 'Modules' tab. For best performance - upload 16bit 8khz/16khz Mono WAV files. + + Music on hold can be in WAV or MP3 format. + For best performance upload 16bit 8khz/16khz Mono WAV files.

diff --git a/config/freeswitch/please_enter_the_extension_number.wav b/config/freeswitch/please_enter_the_extension_number.wav new file mode 100644 index 00000000..d9384b0f Binary files /dev/null and b/config/freeswitch/please_enter_the_extension_number.wav differ diff --git a/config/freeswitch/please_enter_the_phone_number.wav b/config/freeswitch/please_enter_the_phone_number.wav new file mode 100644 index 00000000..9cb4057b Binary files /dev/null and b/config/freeswitch/please_enter_the_phone_number.wav differ diff --git a/config/freeswitch/please_enter_the_pin_number.wav b/config/freeswitch/please_enter_the_pin_number.wav new file mode 100644 index 00000000..107728a5 Binary files /dev/null and b/config/freeswitch/please_enter_the_pin_number.wav differ -- cgit v1.2.3