aboutsummaryrefslogtreecommitdiffstats
path: root/config/freeswitch
diff options
context:
space:
mode:
Diffstat (limited to 'config/freeswitch')
-rw-r--r--config/freeswitch/begin_recording.wavbin0 -> 19480 bytes
-rw-r--r--config/freeswitch/class.phpmailer.tmp1896
-rw-r--r--config/freeswitch/class.smtp.tmp1062
-rw-r--r--config/freeswitch/freeswitch.inc2234
-rw-r--r--config/freeswitch/freeswitch.xml477
-rw-r--r--config/freeswitch/freeswitch_cmd.tmp49
-rw-r--r--config/freeswitch/freeswitch_dialplan.xml136
-rw-r--r--config/freeswitch/freeswitch_dialplan_includes.tmp271
-rw-r--r--config/freeswitch/freeswitch_dialplan_includes_details.tmp53
-rw-r--r--config/freeswitch/freeswitch_dialplan_includes_details_edit.tmp375
-rw-r--r--config/freeswitch/freeswitch_dialplan_includes_edit.tmp524
-rw-r--r--config/freeswitch/freeswitch_extensions.tmp209
-rw-r--r--config/freeswitch/freeswitch_extensions.xml225
-rw-r--r--config/freeswitch/freeswitch_extensions_edit.tmp351
-rw-r--r--config/freeswitch/freeswitch_external.xml136
-rw-r--r--config/freeswitch/freeswitch_gateways.tmp209
-rw-r--r--config/freeswitch/freeswitch_gateways_edit.tmp596
-rw-r--r--config/freeswitch/freeswitch_internal.xml136
-rw-r--r--config/freeswitch/freeswitch_ivr.tmp216
-rw-r--r--config/freeswitch/freeswitch_ivr_edit.tmp582
-rw-r--r--config/freeswitch/freeswitch_ivr_options.tmp52
-rw-r--r--config/freeswitch/freeswitch_ivr_options_edit.tmp216
-rw-r--r--config/freeswitch/freeswitch_mailto.tmp240
-rw-r--r--config/freeswitch/freeswitch_modules.xml1216
-rw-r--r--config/freeswitch/freeswitch_public.xml135
-rw-r--r--config/freeswitch/freeswitch_public_includes.tmp275
-rw-r--r--config/freeswitch/freeswitch_public_includes_details.tmp53
-rw-r--r--config/freeswitch/freeswitch_public_includes_details_edit.tmp410
-rw-r--r--config/freeswitch/freeswitch_public_includes_edit.tmp524
-rw-r--r--config/freeswitch/freeswitch_recordings.tmp499
-rw-r--r--config/freeswitch/freeswitch_recordings_edit.tmp186
-rw-r--r--config/freeswitch/freeswitch_recordings_play.tmp71
-rw-r--r--config/freeswitch/freeswitch_status.tmp337
-rw-r--r--config/freeswitch/freeswitch_time_conditions.tmp191
-rw-r--r--config/freeswitch/freeswitch_time_conditions_edit.tmp215
-rw-r--r--config/freeswitch/freeswitch_vars.xml136
-rw-r--r--config/freeswitch/libncurses.so.5.6bin0 -> 127748 bytes
-rw-r--r--config/freeswitch/libogg.so.5.3bin0 -> 43004 bytes
-rw-r--r--config/freeswitch/libspandsp.so.1bin0 -> 1398998 bytes
-rw-r--r--config/freeswitch/libtinfo.so.5.6bin0 -> 187069 bytes
-rw-r--r--config/freeswitch/libvorbis.so.4bin0 -> 179138 bytes
-rw-r--r--config/freeswitch/mod_fax.so.1bin0 -> 80741 bytes
-rw-r--r--config/freeswitch/mod_shout.so.1bin0 -> 2147544 bytes
-rw-r--r--config/freeswitch/please_enter_your_pin_number.wavbin0 -> 28212 bytes
-rw-r--r--config/freeswitch/your_pin_number_is_incorect_goodbye.wavbin0 -> 43420 bytes
45 files changed, 14493 insertions, 0 deletions
diff --git a/config/freeswitch/begin_recording.wav b/config/freeswitch/begin_recording.wav
new file mode 100644
index 00000000..9e4992ca
--- /dev/null
+++ b/config/freeswitch/begin_recording.wav
Binary files differ
diff --git a/config/freeswitch/class.phpmailer.tmp b/config/freeswitch/class.phpmailer.tmp
new file mode 100644
index 00000000..2ddc30fd
--- /dev/null
+++ b/config/freeswitch/class.phpmailer.tmp
@@ -0,0 +1,1896 @@
+<?php
+/*~ class.phpmailer.php
+.---------------------------------------------------------------------------.
+| Software: PHPMailer - PHP email class |
+| Version: 2.0.2 |
+| Contact: via sourceforge.net support pages (also www.codeworxtech.com) |
+| Info: http://phpmailer.sourceforge.net |
+| Support: http://sourceforge.net/projects/phpmailer/ |
+| ------------------------------------------------------------------------- |
+| Author: Andy Prevost (project admininistrator) |
+| Author: Brent R. Matzelle (original founder) |
+| Copyright (c) 2004-2007, Andy Prevost. All Rights Reserved. |
+| Copyright (c) 2001-2003, Brent R. Matzelle |
+| ------------------------------------------------------------------------- |
+| License: Distributed under the Lesser General Public License (LGPL) |
+| http://www.gnu.org/copyleft/lesser.html |
+| This program is distributed in the hope that it will be useful - WITHOUT |
+| ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+| FITNESS FOR A PARTICULAR PURPOSE. |
+| ------------------------------------------------------------------------- |
+| We offer a number of paid services (www.codeworxtech.com): |
+| - Web Hosting on highly optimized fast and secure servers |
+| - Technology Consulting |
+| - Oursourcing (highly qualified programmers and graphic designers) |
+'---------------------------------------------------------------------------'
+
+/**
+ * PHPMailer - PHP email transport class
+ * @package PHPMailer
+ * @author Andy Prevost
+ * @copyright 2004 - 2008 Andy Prevost
+ */
+
+class PHPMailer {
+
+ /////////////////////////////////////////////////
+ // PROPERTIES, PUBLIC
+ /////////////////////////////////////////////////
+
+ /**
+ * Email priority (1 = High, 3 = Normal, 5 = low).
+ * @var int
+ */
+ var $Priority = 3;
+
+ /**
+ * Sets the CharSet of the message.
+ * @var string
+ */
+ var $CharSet = 'iso-8859-1';
+
+ /**
+ * Sets the Content-type of the message.
+ * @var string
+ */
+ var $ContentType = 'text/plain';
+
+ /**
+ * Sets the Encoding of the message. Options for this are "8bit",
+ * "7bit", "binary", "base64", and "quoted-printable".
+ * @var string
+ */
+ var $Encoding = '8bit';
+
+ /**
+ * Holds the most recent mailer error message.
+ * @var string
+ */
+ var $ErrorInfo = '';
+
+ /**
+ * Sets the From email address for the message.
+ * @var string
+ */
+ var $From = 'root@localhost';
+
+ /**
+ * Sets the From name of the message.
+ * @var string
+ */
+ var $FromName = 'Root User';
+
+ /**
+ * Sets the Sender email (Return-Path) of the message. If not empty,
+ * will be sent via -f to sendmail or as 'MAIL FROM' in smtp mode.
+ * @var string
+ */
+ var $Sender = '';
+
+ /**
+ * Sets the Subject of the message.
+ * @var string
+ */
+ var $Subject = '';
+
+ /**
+ * Sets the Body of the message. This can be either an HTML or text body.
+ * If HTML then run IsHTML(true).
+ * @var string
+ */
+ var $Body = '';
+
+ /**
+ * Sets the text-only body of the message. This automatically sets the
+ * email to multipart/alternative. This body can be read by mail
+ * clients that do not have HTML email capability such as mutt. Clients
+ * that can read HTML will view the normal Body.
+ * @var string
+ */
+ var $AltBody = '';
+
+ /**
+ * Sets word wrapping on the body of the message to a given number of
+ * characters.
+ * @var int
+ */
+ var $WordWrap = 0;
+
+ /**
+ * Method to send mail: ("mail", "sendmail", or "smtp").
+ * @var string
+ */
+ var $Mailer = 'mail';
+
+ /**
+ * Sets the path of the sendmail program.
+ * @var string
+ */
+ var $Sendmail = '/usr/sbin/sendmail';
+
+ /**
+ * Path to PHPMailer plugins. This is now only useful if the SMTP class
+ * is in a different directory than the PHP include path.
+ * @var string
+ */
+ var $PluginDir = '';
+
+ /**
+ * Holds PHPMailer version.
+ * @var string
+ */
+ var $Version = "2.0.2";
+
+ /**
+ * Sets the email address that a reading confirmation will be sent.
+ * @var string
+ */
+ var $ConfirmReadingTo = '';
+
+ /**
+ * Sets the hostname to use in Message-Id and Received headers
+ * and as default HELO string. If empty, the value returned
+ * by SERVER_NAME is used or 'localhost.localdomain'.
+ * @var string
+ */
+ var $Hostname = '';
+
+ /**
+ * Sets the message ID to be used in the Message-Id header.
+ * If empty, a unique id will be generated.
+ * @var string
+ */
+ var $MessageID = '';
+
+ /////////////////////////////////////////////////
+ // PROPERTIES FOR SMTP
+ /////////////////////////////////////////////////
+
+ /**
+ * Sets the SMTP hosts. All hosts must be separated by a
+ * semicolon. You can also specify a different port
+ * for each host by using this format: [hostname:port]
+ * (e.g. "smtp1.example.com:25;smtp2.example.com").
+ * Hosts will be tried in order.
+ * @var string
+ */
+ var $Host = 'localhost';
+
+ /**
+ * Sets the default SMTP server port.
+ * @var int
+ */
+ var $Port = 25;
+
+ /**
+ * Sets the SMTP HELO of the message (Default is $Hostname).
+ * @var string
+ */
+ var $Helo = '';
+
+ /**
+ * Sets connection prefix.
+ * Options are "", "ssl" or "tls"
+ * @var string
+ */
+ var $SMTPSecure = "";
+
+ /**
+ * Sets SMTP authentication. Utilizes the Username and Password variables.
+ * @var bool
+ */
+ var $SMTPAuth = false;
+
+ /**
+ * Sets SMTP username.
+ * @var string
+ */
+ var $Username = '';
+
+ /**
+ * Sets SMTP password.
+ * @var string
+ */
+ var $Password = '';
+
+ /**
+ * Sets the SMTP server timeout in seconds. This function will not
+ * work with the win32 version.
+ * @var int
+ */
+ var $Timeout = 10;
+
+ /**
+ * Sets SMTP class debugging on or off.
+ * @var bool
+ */
+ var $SMTPDebug = false;
+
+ /**
+ * Prevents the SMTP connection from being closed after each mail
+ * sending. If this is set to true then to close the connection
+ * requires an explicit call to SmtpClose().
+ * @var bool
+ */
+ var $SMTPKeepAlive = false;
+
+ /**
+ * Provides the ability to have the TO field process individual
+ * emails, instead of sending to entire TO addresses
+ * @var bool
+ */
+ var $SingleTo = false;
+
+ /////////////////////////////////////////////////
+ // PROPERTIES, PRIVATE
+ /////////////////////////////////////////////////
+
+ var $smtp = NULL;
+ var $to = array();
+ var $cc = array();
+ var $bcc = array();
+ var $ReplyTo = array();
+ var $attachment = array();
+ var $CustomHeader = array();
+ var $message_type = '';
+ var $boundary = array();
+ var $language = array();
+ var $error_count = 0;
+ var $LE = "\n";
+ var $sign_key_file = "";
+ var $sign_key_pass = "";
+
+ /////////////////////////////////////////////////
+ // METHODS, VARIABLES
+ /////////////////////////////////////////////////
+
+ /**
+ * Sets message type to HTML.
+ * @param bool $bool
+ * @return void
+ */
+ function IsHTML($bool) {
+ if($bool == true) {
+ $this->ContentType = 'text/html';
+ } else {
+ $this->ContentType = 'text/plain';
+ }
+ }
+
+ /**
+ * Sets Mailer to send message using SMTP.
+ * @return void
+ */
+ function IsSMTP() {
+ $this->Mailer = 'smtp';
+ }
+
+ /**
+ * Sets Mailer to send message using PHP mail() function.
+ * @return void
+ */
+ function IsMail() {
+ $this->Mailer = 'mail';
+ }
+
+ /**
+ * Sets Mailer to send message using the $Sendmail program.
+ * @return void
+ */
+ function IsSendmail() {
+ $this->Mailer = 'sendmail';
+ }
+
+ /**
+ * Sets Mailer to send message using the qmail MTA.
+ * @return void
+ */
+ function IsQmail() {
+ $this->Sendmail = '/var/qmail/bin/sendmail';
+ $this->Mailer = 'sendmail';
+ }
+
+ /////////////////////////////////////////////////
+ // METHODS, RECIPIENTS
+ /////////////////////////////////////////////////
+
+ /**
+ * Adds a "To" address.
+ * @param string $address
+ * @param string $name
+ * @return void
+ */
+ function AddAddress($address, $name = '') {
+ $cur = count($this->to);
+ $this->to[$cur][0] = trim($address);
+ $this->to[$cur][1] = $name;
+ }
+
+ /**
+ * Adds a "Cc" address. Note: this function works
+ * with the SMTP mailer on win32, not with the "mail"
+ * mailer.
+ * @param string $address
+ * @param string $name
+ * @return void
+ */
+ function AddCC($address, $name = '') {
+ $cur = count($this->cc);
+ $this->cc[$cur][0] = trim($address);
+ $this->cc[$cur][1] = $name;
+ }
+
+ /**
+ * Adds a "Bcc" address. Note: this function works
+ * with the SMTP mailer on win32, not with the "mail"
+ * mailer.
+ * @param string $address
+ * @param string $name
+ * @return void
+ */
+ function AddBCC($address, $name = '') {
+ $cur = count($this->bcc);
+ $this->bcc[$cur][0] = trim($address);
+ $this->bcc[$cur][1] = $name;
+ }
+
+ /**
+ * Adds a "Reply-To" address.
+ * @param string $address
+ * @param string $name
+ * @return void
+ */
+ function AddReplyTo($address, $name = '') {
+ $cur = count($this->ReplyTo);
+ $this->ReplyTo[$cur][0] = trim($address);
+ $this->ReplyTo[$cur][1] = $name;
+ }
+
+ /////////////////////////////////////////////////
+ // METHODS, MAIL SENDING
+ /////////////////////////////////////////////////
+
+ /**
+ * Creates message and assigns Mailer. If the message is
+ * not sent successfully then it returns false. Use the ErrorInfo
+ * variable to view description of the error.
+ * @return bool
+ */
+ function Send() {
+ $header = '';
+ $body = '';
+ $result = true;
+
+ if((count($this->to) + count($this->cc) + count($this->bcc)) < 1) {
+ $this->SetError($this->Lang('provide_address'));
+ return false;
+ }
+
+ /* Set whether the message is multipart/alternative */
+ if(!empty($this->AltBody)) {
+ $this->ContentType = 'multipart/alternative';
+ }
+
+ $this->error_count = 0; // reset errors
+ $this->SetMessageType();
+ $header .= $this->CreateHeader();
+ $body = $this->CreateBody();
+
+ if($body == '') {
+ return false;
+ }
+
+ /* Choose the mailer */
+ switch($this->Mailer) {
+ case 'sendmail':
+ $result = $this->SendmailSend($header, $body);
+ break;
+ case 'smtp':
+ $result = $this->SmtpSend($header, $body);
+ break;
+ case 'mail':
+ $result = $this->MailSend($header, $body);
+ break;
+ default:
+ $result = $this->MailSend($header, $body);
+ break;
+ //$this->SetError($this->Mailer . $this->Lang('mailer_not_supported'));
+ //$result = false;
+ //break;
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sends mail using the $Sendmail program.
+ * @access private
+ * @return bool
+ */
+ function SendmailSend($header, $body) {
+ if ($this->Sender != '') {
+ $sendmail = sprintf("%s -oi -f %s -t", escapeshellcmd($this->Sendmail), escapeshellarg($this->Sender));
+ } else {
+ $sendmail = sprintf("%s -oi -t", escapeshellcmd($this->Sendmail));
+ }
+
+ if(!@$mail = popen($sendmail, 'w')) {
+ $this->SetError($this->Lang('execute') . $this->Sendmail);
+ return false;
+ }
+
+ fputs($mail, $header);
+ fputs($mail, $body);
+
+ $result = pclose($mail);
+ if (version_compare(phpversion(), '4.2.3') == -1) {
+ $result = $result >> 8 & 0xFF;
+ }
+ if($result != 0) {
+ $this->SetError($this->Lang('execute') . $this->Sendmail);
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Sends mail using the PHP mail() function.
+ * @access private
+ * @return bool
+ */
+ function MailSend($header, $body) {
+
+ $to = '';
+ for($i = 0; $i < count($this->to); $i++) {
+ if($i != 0) { $to .= ', '; }
+ $to .= $this->AddrFormat($this->to[$i]);
+ }
+
+ $toArr = split(',', $to);
+
+ $params = sprintf("-oi -f %s", $this->Sender);
+ if ($this->Sender != '' && strlen(ini_get('safe_mode')) < 1) {
+ $old_from = ini_get('sendmail_from');
+ ini_set('sendmail_from', $this->Sender);
+ if ($this->SingleTo === true && count($toArr) > 1) {
+ foreach ($toArr as $key => $val) {
+ $rt = @mail($val, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params);
+ }
+ } else {
+ $rt = @mail($to, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params);
+ }
+ } else {
+ if ($this->SingleTo === true && count($toArr) > 1) {
+ foreach ($toArr as $key => $val) {
+ $rt = @mail($val, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params);
+ }
+ } else {
+ $rt = @mail($to, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header);
+ }
+ }
+
+ if (isset($old_from)) {
+ ini_set('sendmail_from', $old_from);
+ }
+
+ if(!$rt) {
+ $this->SetError($this->Lang('instantiate'));
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * Sends mail via SMTP using PhpSMTP (Author:
+ * Chris Ryan). Returns bool. Returns false if there is a
+ * bad MAIL FROM, RCPT, or DATA input.
+ * @access private
+ * @return bool
+ */
+ function SmtpSend($header, $body) {
+ include_once($this->PluginDir . 'class.smtp.php');
+ $error = '';
+ $bad_rcpt = array();
+
+ if(!$this->SmtpConnect()) {
+ return false;
+ }
+
+ $smtp_from = ($this->Sender == '') ? $this->From : $this->Sender;
+ if(!$this->smtp->Mail($smtp_from)) {
+ $error = $this->Lang('from_failed') . $smtp_from;
+ $this->SetError($error);
+ $this->smtp->Reset();
+ return false;
+ }
+
+ /* Attempt to send attach all recipients */
+ for($i = 0; $i < count($this->to); $i++) {
+ if(!$this->smtp->Recipient($this->to[$i][0])) {
+ $bad_rcpt[] = $this->to[$i][0];
+ }
+ }
+ for($i = 0; $i < count($this->cc); $i++) {
+ if(!$this->smtp->Recipient($this->cc[$i][0])) {
+ $bad_rcpt[] = $this->cc[$i][0];
+ }
+ }
+ for($i = 0; $i < count($this->bcc); $i++) {
+ if(!$this->smtp->Recipient($this->bcc[$i][0])) {
+ $bad_rcpt[] = $this->bcc[$i][0];
+ }
+ }
+
+ if(count($bad_rcpt) > 0) { // Create error message
+ for($i = 0; $i < count($bad_rcpt); $i++) {
+ if($i != 0) {
+ $error .= ', ';
+ }
+ $error .= $bad_rcpt[$i];
+ }
+ $error = $this->Lang('recipients_failed') . $error;
+ $this->SetError($error);
+ $this->smtp->Reset();
+ return false;
+ }
+
+ if(!$this->smtp->Data($header . $body)) {
+ $this->SetError($this->Lang('data_not_accepted'));
+ $this->smtp->Reset();
+ return false;
+ }
+ if($this->SMTPKeepAlive == true) {
+ $this->smtp->Reset();
+ } else {
+ $this->SmtpClose();
+ }
+
+ return true;
+ }
+
+ /**
+ * Initiates a connection to an SMTP server. Returns false if the
+ * operation failed.
+ * @access private
+ * @return bool
+ */
+ function SmtpConnect() {
+ if($this->smtp == NULL) {
+ $this->smtp = new SMTP();
+ }
+
+ $this->smtp->do_debug = $this->SMTPDebug;
+ $hosts = explode(';', $this->Host);
+ $index = 0;
+ $connection = ($this->smtp->Connected());
+
+ /* Retry while there is no connection */
+ while($index < count($hosts) && $connection == false) {
+ $hostinfo = array();
+ if(eregi('^(.+):([0-9]+)$', $hosts[$index], $hostinfo)) {
+ $host = $hostinfo[1];
+ $port = $hostinfo[2];
+ } else {
+ $host = $hosts[$index];
+ $port = $this->Port;
+ }
+
+ if($this->smtp->Connect(((!empty($this->SMTPSecure))?$this->SMTPSecure.'://':'').$host, $port, $this->Timeout)) {
+ if ($this->Helo != '') {
+ $this->smtp->Hello($this->Helo);
+ } else {
+ $this->smtp->Hello($this->ServerHostname());
+ }
+
+ $connection = true;
+ if($this->SMTPAuth) {
+ if(!$this->smtp->Authenticate($this->Username, $this->Password)) {
+ $this->SetError($this->Lang('authenticate'));
+ $this->smtp->Reset();
+ $connection = false;
+ }
+ }
+ }
+ $index++;
+ }
+ if(!$connection) {
+ $this->SetError($this->Lang('connect_host'));
+ }
+
+ return $connection;
+ }
+
+ /**
+ * Closes the active SMTP session if one exists.
+ * @return void
+ */
+ function SmtpClose() {
+ if($this->smtp != NULL) {
+ if($this->smtp->Connected()) {
+ $this->smtp->Quit();
+ $this->smtp->Close();
+ }
+ }
+ }
+
+ /**
+ * Sets the language for all class error messages. Returns false
+ * if it cannot load the language file. The default language type
+ * is English.
+ * @param string $lang_type Type of language (e.g. Portuguese: "br")
+ * @param string $lang_path Path to the language file directory
+ * @access public
+ * @return bool
+ */
+ function SetLanguage($lang_type, $lang_path = 'language/') {
+ if(file_exists($lang_path.'phpmailer.lang-'.$lang_type.'.php')) {
+ include($lang_path.'phpmailer.lang-'.$lang_type.'.php');
+ } elseif (file_exists($lang_path.'phpmailer.lang-en.php')) {
+ include($lang_path.'phpmailer.lang-en.php');
+ } else {
+ $this->SetError('Could not load language file');
+ return false;
+ }
+ $this->language = $PHPMAILER_LANG;
+
+ return true;
+ }
+
+ /////////////////////////////////////////////////
+ // METHODS, MESSAGE CREATION
+ /////////////////////////////////////////////////
+
+ /**
+ * Creates recipient headers.
+ * @access private
+ * @return string
+ */
+ function AddrAppend($type, $addr) {
+ $addr_str = $type . ': ';
+ $addr_str .= $this->AddrFormat($addr[0]);
+ if(count($addr) > 1) {
+ for($i = 1; $i < count($addr); $i++) {
+ $addr_str .= ', ' . $this->AddrFormat($addr[$i]);
+ }
+ }
+ $addr_str .= $this->LE;
+
+ return $addr_str;
+ }
+
+ /**
+ * Formats an address correctly.
+ * @access private
+ * @return string
+ */
+ function AddrFormat($addr) {
+ if(empty($addr[1])) {
+ $formatted = $this->SecureHeader($addr[0]);
+ } else {
+ $formatted = $this->EncodeHeader($this->SecureHeader($addr[1]), 'phrase') . " <" . $this->SecureHeader($addr[0]) . ">";
+ }
+
+ return $formatted;
+ }
+
+ /**
+ * Wraps message for use with mailers that do not
+ * automatically perform wrapping and for quoted-printable.
+ * Original written by philippe.
+ * @access private
+ * @return string
+ */
+ function WrapText($message, $length, $qp_mode = false) {
+ $soft_break = ($qp_mode) ? sprintf(" =%s", $this->LE) : $this->LE;
+ // If utf-8 encoding is used, we will need to make sure we don't
+ // split multibyte characters when we wrap
+ $is_utf8 = (strtolower($this->CharSet) == "utf-8");
+
+ $message = $this->FixEOL($message);
+ if (substr($message, -1) == $this->LE) {
+ $message = substr($message, 0, -1);
+ }
+
+ $line = explode($this->LE, $message);
+ $message = '';
+ for ($i=0 ;$i < count($line); $i++) {
+ $line_part = explode(' ', $line[$i]);
+ $buf = '';
+ for ($e = 0; $e<count($line_part); $e++) {
+ $word = $line_part[$e];
+ if ($qp_mode and (strlen($word) > $length)) {
+ $space_left = $length - strlen($buf) - 1;
+ if ($e != 0) {
+ if ($space_left > 20) {
+ $len = $space_left;
+ if ($is_utf8) {
+ $len = $this->UTF8CharBoundary($word, $len);
+ } elseif (substr($word, $len - 1, 1) == "=") {
+ $len--;
+ } elseif (substr($word, $len - 2, 1) == "=") {
+ $len -= 2;
+ }
+ $part = substr($word, 0, $len);
+ $word = substr($word, $len);
+ $buf .= ' ' . $part;
+ $message .= $buf . sprintf("=%s", $this->LE);
+ } else {
+ $message .= $buf . $soft_break;
+ }
+ $buf = '';
+ }
+ while (strlen($word) > 0) {
+ $len = $length;
+ if ($is_utf8) {
+ $len = $this->UTF8CharBoundary($word, $len);
+ } elseif (substr($word, $len - 1, 1) == "=") {
+ $len--;
+ } elseif (substr($word, $len - 2, 1) == "=") {
+ $len -= 2;
+ }
+ $part = substr($word, 0, $len);
+ $word = substr($word, $len);
+
+ if (strlen($word) > 0) {
+ $message .= $part . sprintf("=%s", $this->LE);
+ } else {
+ $buf = $part;
+ }
+ }
+ } else {
+ $buf_o = $buf;
+ $buf .= ($e == 0) ? $word : (' ' . $word);
+
+ if (strlen($buf) > $length and $buf_o != '') {
+ $message .= $buf_o . $soft_break;
+ $buf = $word;
+ }
+ }
+ }
+ $message .= $buf . $this->LE;
+ }
+
+ return $message;
+ }
+
+ /**
+ * Finds last character boundary prior to maxLength in a utf-8
+ * quoted (printable) encoded string.
+ * Original written by Colin Brown.
+ * @access private
+ * @param string $encodedText utf-8 QP text
+ * @param int $maxLength find last character boundary prior to this length
+ * @return int
+ */
+ function UTF8CharBoundary($encodedText, $maxLength) {
+ $foundSplitPos = false;
+ $lookBack = 3;
+ while (!$foundSplitPos) {
+ $lastChunk = substr($encodedText, $maxLength - $lookBack, $lookBack);
+ $encodedCharPos = strpos($lastChunk, "=");
+ if ($encodedCharPos !== false) {
+ // Found start of encoded character byte within $lookBack block.
+ // Check the encoded byte value (the 2 chars after the '=')
+ $hex = substr($encodedText, $maxLength - $lookBack + $encodedCharPos + 1, 2);
+ $dec = hexdec($hex);
+ if ($dec < 128) { // Single byte character.
+ // If the encoded char was found at pos 0, it will fit
+ // otherwise reduce maxLength to start of the encoded char
+ $maxLength = ($encodedCharPos == 0) ? $maxLength :
+ $maxLength - ($lookBack - $encodedCharPos);
+ $foundSplitPos = true;
+ } elseif ($dec >= 192) { // First byte of a multi byte character
+ // Reduce maxLength to split at start of character
+ $maxLength = $maxLength - ($lookBack - $encodedCharPos);
+ $foundSplitPos = true;
+ } elseif ($dec < 192) { // Middle byte of a multi byte character, look further back
+ $lookBack += 3;
+ }
+ } else {
+ // No encoded character found
+ $foundSplitPos = true;
+ }
+ }
+ return $maxLength;
+ }
+
+ /**
+ * Set the body wrapping.
+ * @access private
+ * @return void
+ */
+ function SetWordWrap() {
+ if($this->WordWrap < 1) {
+ return;
+ }
+
+ switch($this->message_type) {
+ case 'alt':
+ /* fall through */
+ case 'alt_attachments':
+ $this->AltBody = $this->WrapText($this->AltBody, $this->WordWrap);
+ break;
+ default:
+ $this->Body = $this->WrapText($this->Body, $this->WordWrap);
+ break;
+ }
+ }
+
+ /**
+ * Assembles message header.
+ * @access private
+ * @return string
+ */
+ function CreateHeader() {
+ $result = '';
+
+ /* Set the boundaries */
+ $uniq_id = md5(uniqid(time()));
+ $this->boundary[1] = 'b1_' . $uniq_id;
+ $this->boundary[2] = 'b2_' . $uniq_id;
+
+ $result .= $this->HeaderLine('Date', $this->RFCDate());
+ if($this->Sender == '') {
+ $result .= $this->HeaderLine('Return-Path', trim($this->From));
+ } else {
+ $result .= $this->HeaderLine('Return-Path', trim($this->Sender));
+ }
+
+ /* To be created automatically by mail() */
+ if($this->Mailer != 'mail') {
+ if(count($this->to) > 0) {
+ $result .= $this->AddrAppend('To', $this->to);
+ } elseif (count($this->cc) == 0) {
+ $result .= $this->HeaderLine('To', 'undisclosed-recipients:;');
+ }
+ if(count($this->cc) > 0) {
+ $result .= $this->AddrAppend('Cc', $this->cc);
+ }
+ }
+
+ $from = array();
+ $from[0][0] = trim($this->From);
+ $from[0][1] = $this->FromName;
+ $result .= $this->AddrAppend('From', $from);
+
+ /* sendmail and mail() extract Cc from the header before sending */
+ if((($this->Mailer == 'sendmail') || ($this->Mailer == 'mail')) && (count($this->cc) > 0)) {
+ $result .= $this->AddrAppend('Cc', $this->cc);
+ }
+
+ /* sendmail and mail() extract Bcc from the header before sending */
+ if((($this->Mailer == 'sendmail') || ($this->Mailer == 'mail')) && (count($this->bcc) > 0)) {
+ $result .= $this->AddrAppend('Bcc', $this->bcc);
+ }
+
+ if(count($this->ReplyTo) > 0) {
+ $result .= $this->AddrAppend('Reply-To', $this->ReplyTo);
+ }
+
+ /* mail() sets the subject itself */
+ if($this->Mailer != 'mail') {
+ $result .= $this->HeaderLine('Subject', $this->EncodeHeader($this->SecureHeader($this->Subject)));
+ }
+
+ if($this->MessageID != '') {
+ $result .= $this->HeaderLine('Message-ID',$this->MessageID);
+ } else {
+ $result .= sprintf("Message-ID: <%s@%s>%s", $uniq_id, $this->ServerHostname(), $this->LE);
+ }
+ $result .= $this->HeaderLine('X-Priority', $this->Priority);
+ $result .= $this->HeaderLine('X-Mailer', 'PHPMailer (phpmailer.sourceforge.net) [version ' . $this->Version . ']');
+
+ if($this->ConfirmReadingTo != '') {
+ $result .= $this->HeaderLine('Disposition-Notification-To', '<' . trim($this->ConfirmReadingTo) . '>');
+ }
+
+ // Add custom headers
+ for($index = 0; $index < count($this->CustomHeader); $index++) {
+ $result .= $this->HeaderLine(trim($this->CustomHeader[$index][0]), $this->EncodeHeader(trim($this->CustomHeader[$index][1])));
+ }
+ if (!$this->sign_key_file) {
+ $result .= $this->HeaderLine('MIME-Version', '1.0');
+ $result .= $this->GetMailMIME();
+ }
+
+ return $result;
+ }
+
+ /**
+ * Returns the message MIME.
+ * @access private
+ * @return string
+ */
+ function GetMailMIME() {
+ $result = '';
+ switch($this->message_type) {
+ case 'plain':
+ $result .= $this->HeaderLine('Content-Transfer-Encoding', $this->Encoding);
+ $result .= sprintf("Content-Type: %s; charset=\"%s\"", $this->ContentType, $this->CharSet);
+ break;
+ case 'attachments':
+ /* fall through */
+ case 'alt_attachments':
+ if($this->InlineImageExists()){
+ $result .= sprintf("Content-Type: %s;%s\ttype=\"text/html\";%s\tboundary=\"%s\"%s", 'multipart/related', $this->LE, $this->LE, $this->boundary[1], $this->LE);
+ } else {
+ $result .= $this->HeaderLine('Content-Type', 'multipart/mixed;');
+ $result .= $this->TextLine("\tboundary=\"" . $this->boundary[1] . '"');
+ }
+ break;
+ case 'alt':
+ $result .= $this->HeaderLine('Content-Type', 'multipart/alternative;');
+ $result .= $this->TextLine("\tboundary=\"" . $this->boundary[1] . '"');
+ break;
+ }
+
+ if($this->Mailer != 'mail') {
+ $result .= $this->LE.$this->LE;
+ }
+
+ return $result;
+ }
+
+ /**
+ * Assembles the message body. Returns an empty string on failure.
+ * @access private
+ * @return string
+ */
+ function CreateBody() {
+ $result = '';
+ if ($this->sign_key_file) {
+ $result .= $this->GetMailMIME();
+ }
+
+ $this->SetWordWrap();
+
+ switch($this->message_type) {
+ case 'alt':
+ $result .= $this->GetBoundary($this->boundary[1], '', 'text/plain', '');
+ $result .= $this->EncodeString($this->AltBody, $this->Encoding);
+ $result .= $this->LE.$this->LE;
+ $result .= $this->GetBoundary($this->boundary[1], '', 'text/html', '');
+ $result .= $this->EncodeString($this->Body, $this->Encoding);
+ $result .= $this->LE.$this->LE;
+ $result .= $this->EndBoundary($this->boundary[1]);
+ break;
+ case 'plain':
+ $result .= $this->EncodeString($this->Body, $this->Encoding);
+ break;
+ case 'attachments':
+ $result .= $this->GetBoundary($this->boundary[1], '', '', '');
+ $result .= $this->EncodeString($this->Body, $this->Encoding);
+ $result .= $this->LE;
+ $result .= $this->AttachAll();
+ break;
+ case 'alt_attachments':
+ $result .= sprintf("--%s%s", $this->boundary[1], $this->LE);
+ $result .= sprintf("Content-Type: %s;%s" . "\tboundary=\"%s\"%s", 'multipart/alternative', $this->LE, $this->boundary[2], $this->LE.$this->LE);
+ $result .= $this->GetBoundary($this->boundary[2], '', 'text/plain', '') . $this->LE; // Create text body
+ $result .= $this->EncodeString($this->AltBody, $this->Encoding);
+ $result .= $this->LE.$this->LE;
+ $result .= $this->GetBoundary($this->boundary[2], '', 'text/html', '') . $this->LE; // Create the HTML body
+ $result .= $this->EncodeString($this->Body, $this->Encoding);
+ $result .= $this->LE.$this->LE;
+ $result .= $this->EndBoundary($this->boundary[2]);
+ $result .= $this->AttachAll();
+ break;
+ }
+
+ if($this->IsError()) {
+ $result = '';
+ } else if ($this->sign_key_file) {
+ $file = tempnam("", "mail");
+ $fp = fopen($file, "w");
+ fwrite($fp, $result);
+ fclose($fp);
+ $signed = tempnam("", "signed");
+
+ if (@openssl_pkcs7_sign($file, $signed, "file://".$this->sign_key_file, array("file://".$this->sign_key_file, $this->sign_key_pass), null)) {
+ $fp = fopen($signed, "r");
+ $result = fread($fp, filesize($this->sign_key_file));
+ fclose($fp);
+ } else {
+ $this->SetError($this->Lang("signing").openssl_error_string());
+ $result = '';
+ }
+
+ unlink($file);
+ unlink($signed);
+ }
+
+ return $result;
+ }
+
+ /**
+ * Returns the start of a message boundary.
+ * @access private
+ */
+ function GetBoundary($boundary, $charSet, $contentType, $encoding) {
+ $result = '';
+ if($charSet == '') {
+ $charSet = $this->CharSet;
+ }
+ if($contentType == '') {
+ $contentType = $this->ContentType;
+ }
+ if($encoding == '') {
+ $encoding = $this->Encoding;
+ }
+ $result .= $this->TextLine('--' . $boundary);
+ $result .= sprintf("Content-Type: %s; charset = \"%s\"", $contentType, $charSet);
+ $result .= $this->LE;
+ $result .= $this->HeaderLine('Content-Transfer-Encoding', $encoding);
+ $result .= $this->LE;
+
+ return $result;
+ }
+
+ /**
+ * Returns the end of a message boundary.
+ * @access private
+ */
+ function EndBoundary($boundary) {
+ return $this->LE . '--' . $boundary . '--' . $this->LE;
+ }
+
+ /**
+ * Sets the message type.
+ * @access private
+ * @return void
+ */
+ function SetMessageType() {
+ if(count($this->attachment) < 1 && strlen($this->AltBody) < 1) {
+ $this->message_type = 'plain';
+ } else {
+ if(count($this->attachment) > 0) {
+ $this->message_type = 'attachments';
+ }
+ if(strlen($this->AltBody) > 0 && count($this->attachment) < 1) {
+ $this->message_type = 'alt';
+ }
+ if(strlen($this->AltBody) > 0 && count($this->attachment) > 0) {
+ $this->message_type = 'alt_attachments';
+ }
+ }
+ }
+
+ /* Returns a formatted header line.
+ * @access private
+ * @return string
+ */
+ function HeaderLine($name, $value) {
+ return $name . ': ' . $value . $this->LE;
+ }
+
+ /**
+ * Returns a formatted mail line.
+ * @access private
+ * @return string
+ */
+ function TextLine($value) {
+ return $value . $this->LE;
+ }
+
+ /////////////////////////////////////////////////
+ // CLASS METHODS, ATTACHMENTS
+ /////////////////////////////////////////////////
+
+ /**
+ * Adds an attachment from a path on the filesystem.
+ * Returns false if the file could not be found
+ * or accessed.
+ * @param string $path Path to the attachment.
+ * @param string $name Overrides the attachment name.
+ * @param string $encoding File encoding (see $Encoding).
+ * @param string $type File extension (MIME) type.
+ * @return bool
+ */
+ function AddAttachment($path, $name = '', $encoding = 'base64', $type = 'application/octet-stream') {
+ if(!@is_file($path)) {
+ $this->SetError($this->Lang('file_access') . $path);
+ return false;
+ }
+
+ $filename = basename($path);
+ if($name == '') {
+ $name = $filename;
+ }
+
+ $cur = count($this->attachment);
+ $this->attachment[$cur][0] = $path;
+ $this->attachment[$cur][1] = $filename;
+ $this->attachment[$cur][2] = $name;
+ $this->attachment[$cur][3] = $encoding;
+ $this->attachment[$cur][4] = $type;
+ $this->attachment[$cur][5] = false; // isStringAttachment
+ $this->attachment[$cur][6] = 'attachment';
+ $this->attachment[$cur][7] = 0;
+
+ return true;
+ }
+
+ /**
+ * Attaches all fs, string, and binary attachments to the message.
+ * Returns an empty string on failure.
+ * @access private
+ * @return string
+ */
+ function AttachAll() {
+ /* Return text of body */
+ $mime = array();
+
+ /* Add all attachments */
+ for($i = 0; $i < count($this->attachment); $i++) {
+ /* Check for string attachment */
+ $bString = $this->attachment[$i][5];
+ if ($bString) {
+ $string = $this->attachment[$i][0];
+ } else {
+ $path = $this->attachment[$i][0];
+ }
+
+ $filename = $this->attachment[$i][1];
+ $name = $this->attachment[$i][2];
+ $encoding = $this->attachment[$i][3];
+ $type = $this->attachment[$i][4];
+ $disposition = $this->attachment[$i][6];
+ $cid = $this->attachment[$i][7];
+
+ $mime[] = sprintf("--%s%s", $this->boundary[1], $this->LE);
+ $mime[] = sprintf("Content-Type: %s; name=\"%s\"%s", $type, $name, $this->LE);
+ $mime[] = sprintf("Content-Transfer-Encoding: %s%s", $encoding, $this->LE);
+
+ if($disposition == 'inline') {
+ $mime[] = sprintf("Content-ID: <%s>%s", $cid, $this->LE);
+ }
+
+ $mime[] = sprintf("Content-Disposition: %s; filename=\"%s\"%s", $disposition, $name, $this->LE.$this->LE);
+
+ /* Encode as string attachment */
+ if($bString) {
+ $mime[] = $this->EncodeString($string, $encoding);
+ if($this->IsError()) {
+ return '';
+ }
+ $mime[] = $this->LE.$this->LE;
+ } else {
+ $mime[] = $this->EncodeFile($path, $encoding);
+ if($this->IsError()) {
+ return '';
+ }
+ $mime[] = $this->LE.$this->LE;
+ }
+ }
+
+ $mime[] = sprintf("--%s--%s", $this->boundary[1], $this->LE);
+
+ return join('', $mime);
+ }
+
+ /**
+ * Encodes attachment in requested format. Returns an
+ * empty string on failure.
+ * @access private
+ * @return string
+ */
+ function EncodeFile ($path, $encoding = 'base64') {
+ if(!@$fd = fopen($path, 'rb')) {
+ $this->SetError($this->Lang('file_open') . $path);
+ return '';
+ }
+ $magic_quotes = get_magic_quotes_runtime();
+ set_magic_quotes_runtime(0);
+ $file_buffer = fread($fd, filesize($path));
+ $file_buffer = $this->EncodeString($file_buffer, $encoding);
+ fclose($fd);
+ set_magic_quotes_runtime($magic_quotes);
+
+ return $file_buffer;
+ }
+
+ /**
+ * Encodes string to requested format. Returns an
+ * empty string on failure.
+ * @access private
+ * @return string
+ */
+ function EncodeString ($str, $encoding = 'base64') {
+ $encoded = '';
+ switch(strtolower($encoding)) {
+ case 'base64':
+ /* chunk_split is found in PHP >= 3.0.6 */
+ $encoded = chunk_split(base64_encode($str), 76, $this->LE);
+ break;
+ case '7bit':
+ case '8bit':
+ $encoded = $this->FixEOL($str);
+ if (substr($encoded, -(strlen($this->LE))) != $this->LE)
+ $encoded .= $this->LE;
+ break;
+ case 'binary':
+ $encoded = $str;
+ break;
+ case 'quoted-printable':
+ $encoded = $this->EncodeQP($str);
+ break;
+ default:
+ $this->SetError($this->Lang('encoding') . $encoding);
+ break;
+ }
+ return $encoded;
+ }
+
+ /**
+ * Encode a header string to best of Q, B, quoted or none.
+ * @access private
+ * @return string
+ */
+ function EncodeHeader ($str, $position = 'text') {
+ $x = 0;
+
+ switch (strtolower($position)) {
+ case 'phrase':
+ if (!preg_match('/[\200-\377]/', $str)) {
+ /* Can't use addslashes as we don't know what value has magic_quotes_sybase. */
+ $encoded = addcslashes($str, "\0..\37\177\\\"");
+ if (($str == $encoded) && !preg_match('/[^A-Za-z0-9!#$%&\'*+\/=?^_`{|}~ -]/', $str)) {
+ return ($encoded);
+ } else {
+ return ("\"$encoded\"");
+ }
+ }
+ $x = preg_match_all('/[^\040\041\043-\133\135-\176]/', $str, $matches);
+ break;
+ case 'comment':
+ $x = preg_match_all('/[()"]/', $str, $matches);
+ /* Fall-through */
+ case 'text':
+ default:
+ $x += preg_match_all('/[\000-\010\013\014\016-\037\177-\377]/', $str, $matches);
+ break;
+ }
+
+ if ($x == 0) {
+ return ($str);
+ }
+
+ $maxlen = 75 - 7 - strlen($this->CharSet);
+ /* Try to select the encoding which should produce the shortest output */
+ if (strlen($str)/3 < $x) {
+ $encoding = 'B';
+ if (function_exists('mb_strlen') && $this->HasMultiBytes($str)) {
+ // Use a custom function which correctly encodes and wraps long
+ // multibyte strings without breaking lines within a character
+ $encoded = $this->Base64EncodeWrapMB($str);
+ } else {
+ $encoded = base64_encode($str);
+ $maxlen -= $maxlen % 4;
+ $encoded = trim(chunk_split($encoded, $maxlen, "\n"));
+ }
+ } else {
+ $encoding = 'Q';
+ $encoded = $this->EncodeQ($str, $position);
+ $encoded = $this->WrapText($encoded, $maxlen, true);
+ $encoded = str_replace('='.$this->LE, "\n", trim($encoded));
+ }
+
+ $encoded = preg_replace('/^(.*)$/m', " =?".$this->CharSet."?$encoding?\\1?=", $encoded);
+ $encoded = trim(str_replace("\n", $this->LE, $encoded));
+
+ return $encoded;
+ }
+
+ /**
+ * Checks if a string contains multibyte characters.
+ * @access private
+ * @param string $str multi-byte text to wrap encode
+ * @return bool
+ */
+ function HasMultiBytes($str) {
+ if (function_exists('mb_strlen')) {
+ return (strlen($str) > mb_strlen($str, $this->CharSet));
+ } else { // Assume no multibytes (we can't handle without mbstring functions anyway)
+ return False;
+ }
+ }
+
+ /**
+ * Correctly encodes and wraps long multibyte strings for mail headers
+ * without breaking lines within a character.
+ * Adapted from a function by paravoid at http://uk.php.net/manual/en/function.mb-encode-mimeheader.php
+ * @access private
+ * @param string $str multi-byte text to wrap encode
+ * @return string
+ */
+ function Base64EncodeWrapMB($str) {
+ $start = "=?".$this->CharSet."?B?";
+ $end = "?=";
+ $encoded = "";
+
+ $mb_length = mb_strlen($str, $this->CharSet);
+ // Each line must have length <= 75, including $start and $end
+ $length = 75 - strlen($start) - strlen($end);
+ // Average multi-byte ratio
+ $ratio = $mb_length / strlen($str);
+ // Base64 has a 4:3 ratio
+ $offset = $avgLength = floor($length * $ratio * .75);
+
+ for ($i = 0; $i < $mb_length; $i += $offset) {
+ $lookBack = 0;
+
+ do {
+ $offset = $avgLength - $lookBack;
+ $chunk = mb_substr($str, $i, $offset, $this->CharSet);
+ $chunk = base64_encode($chunk);
+ $lookBack++;
+ }
+ while (strlen($chunk) > $length);
+
+ $encoded .= $chunk . $this->LE;
+ }
+
+ // Chomp the last linefeed
+ $encoded = substr($encoded, 0, -strlen($this->LE));
+ return $encoded;
+ }
+
+ /**
+ * Encode string to quoted-printable.
+ * @access private
+ * @return string
+ */
+ function EncodeQP( $input = '', $line_max = 76, $space_conv = false ) {
+ $hex = array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F');
+ $lines = preg_split('/(?:\r\n|\r|\n)/', $input);
+ $eol = "\r\n";
+ $escape = '=';
+ $output = '';
+ while( list(, $line) = each($lines) ) {
+ $linlen = strlen($line);
+ $newline = '';
+ for($i = 0; $i < $linlen; $i++) {
+ $c = substr( $line, $i, 1 );
+ $dec = ord( $c );
+ if ( ( $i == 0 ) && ( $dec == 46 ) ) { // convert first point in the line into =2E
+ $c = '=2E';
+ }
+ if ( $dec == 32 ) {
+ if ( $i == ( $linlen - 1 ) ) { // convert space at eol only
+ $c = '=20';
+ } else if ( $space_conv ) {
+ $c = '=20';
+ }
+ } elseif ( ($dec == 61) || ($dec < 32 ) || ($dec > 126) ) { // always encode "\t", which is *not* required
+ $h2 = floor($dec/16);
+ $h1 = floor($dec%16);
+ $c = $escape.$hex[$h2].$hex[$h1];
+ }
+ if ( (strlen($newline) + strlen($c)) >= $line_max ) { // CRLF is not counted
+ $output .= $newline.$escape.$eol; // soft line break; " =\r\n" is okay
+ $newline = '';
+ // check if newline first character will be point or not
+ if ( $dec == 46 ) {
+ $c = '=2E';
+ }
+ }
+ $newline .= $c;
+ } // end of for
+ $output .= $newline.$eol;
+ } // end of while
+ return trim($output);
+ }
+
+ /**
+ * Encode string to q encoding.
+ * @access private
+ * @return string
+ */
+ function EncodeQ ($str, $position = 'text') {
+ /* There should not be any EOL in the string */
+ $encoded = preg_replace("[\r\n]", '', $str);
+
+ switch (strtolower($position)) {
+ case 'phrase':
+ $encoded = preg_replace("/([^A-Za-z0-9!*+\/ -])/e", "'='.sprintf('%02X', ord('\\1'))", $encoded);
+ break;
+ case 'comment':
+ $encoded = preg_replace("/([\(\)\"])/e", "'='.sprintf('%02X', ord('\\1'))", $encoded);
+ case 'text':
+ default:
+ /* Replace every high ascii, control =, ? and _ characters */
+ $encoded = preg_replace('/([\000-\011\013\014\016-\037\075\077\137\177-\377])/e',
+ "'='.sprintf('%02X', ord('\\1'))", $encoded);
+ break;
+ }
+
+ /* Replace every spaces to _ (more readable than =20) */
+ $encoded = str_replace(' ', '_', $encoded);
+
+ return $encoded;
+ }
+
+ /**
+ * Adds a string or binary attachment (non-filesystem) to the list.
+ * This method can be used to attach ascii or binary data,
+ * such as a BLOB record from a database.
+ * @param string $string String attachment data.
+ * @param string $filename Name of the attachment.
+ * @param string $encoding File encoding (see $Encoding).
+ * @param string $type File extension (MIME) type.
+ * @return void
+ */
+ function AddStringAttachment($string, $filename, $encoding = 'base64', $type = 'application/octet-stream') {
+ /* Append to $attachment array */
+ $cur = count($this->attachment);
+ $this->attachment[$cur][0] = $string;
+ $this->attachment[$cur][1] = $filename;
+ $this->attachment[$cur][2] = $filename;
+ $this->attachment[$cur][3] = $encoding;
+ $this->attachment[$cur][4] = $type;
+ $this->attachment[$cur][5] = true; // isString
+ $this->attachment[$cur][6] = 'attachment';
+ $this->attachment[$cur][7] = 0;
+ }
+
+ /**
+ * Adds an embedded attachment. This can include images, sounds, and
+ * just about any other document. Make sure to set the $type to an
+ * image type. For JPEG images use "image/jpeg" and for GIF images
+ * use "image/gif".
+ * @param string $path Path to the attachment.
+ * @param string $cid Content ID of the attachment. Use this to identify
+ * the Id for accessing the image in an HTML form.
+ * @param string $name Overrides the attachment name.
+ * @param string $encoding File encoding (see $Encoding).
+ * @param string $type File extension (MIME) type.
+ * @return bool
+ */
+ function AddEmbeddedImage($path, $cid, $name = '', $encoding = 'base64', $type = 'application/octet-stream') {
+
+ if(!@is_file($path)) {
+ $this->SetError($this->Lang('file_access') . $path);
+ return false;
+ }
+
+ $filename = basename($path);
+ if($name == '') {
+ $name = $filename;
+ }
+
+ /* Append to $attachment array */
+ $cur = count($this->attachment);
+ $this->attachment[$cur][0] = $path;
+ $this->attachment[$cur][1] = $filename;
+ $this->attachment[$cur][2] = $name;
+ $this->attachment[$cur][3] = $encoding;
+ $this->attachment[$cur][4] = $type;
+ $this->attachment[$cur][5] = false;
+ $this->attachment[$cur][6] = 'inline';
+ $this->attachment[$cur][7] = $cid;
+
+ return true;
+ }
+
+ /**
+ * Returns true if an inline attachment is present.
+ * @access private
+ * @return bool
+ */
+ function InlineImageExists() {
+ $result = false;
+ for($i = 0; $i < count($this->attachment); $i++) {
+ if($this->attachment[$i][6] == 'inline') {
+ $result = true;
+ break;
+ }
+ }
+
+ return $result;
+ }
+
+ /////////////////////////////////////////////////
+ // CLASS METHODS, MESSAGE RESET
+ /////////////////////////////////////////////////
+
+ /**
+ * Clears all recipients assigned in the TO array. Returns void.
+ * @return void
+ */
+ function ClearAddresses() {
+ $this->to = array();
+ }
+
+ /**
+ * Clears all recipients assigned in the CC array. Returns void.
+ * @return void
+ */
+ function ClearCCs() {
+ $this->cc = array();
+ }
+
+ /**
+ * Clears all recipients assigned in the BCC array. Returns void.
+ * @return void
+ */
+ function ClearBCCs() {
+ $this->bcc = array();
+ }
+
+ /**
+ * Clears all recipients assigned in the ReplyTo array. Returns void.
+ * @return void
+ */
+ function ClearReplyTos() {
+ $this->ReplyTo = array();
+ }
+
+ /**
+ * Clears all recipients assigned in the TO, CC and BCC
+ * array. Returns void.
+ * @return void
+ */
+ function ClearAllRecipients() {
+ $this->to = array();
+ $this->cc = array();
+ $this->bcc = array();
+ }
+
+ /**
+ * Clears all previously set filesystem, string, and binary
+ * attachments. Returns void.
+ * @return void
+ */
+ function ClearAttachments() {
+ $this->attachment = array();
+ }
+
+ /**
+ * Clears all custom headers. Returns void.
+ * @return void
+ */
+ function ClearCustomHeaders() {
+ $this->CustomHeader = array();
+ }
+
+ /////////////////////////////////////////////////
+ // CLASS METHODS, MISCELLANEOUS
+ /////////////////////////////////////////////////
+
+ /**
+ * Adds the error message to the error container.
+ * Returns void.
+ * @access private
+ * @return void
+ */
+ function SetError($msg) {
+ $this->error_count++;
+ $this->ErrorInfo = $msg;
+ }
+
+ /**
+ * Returns the proper RFC 822 formatted date.
+ * @access private
+ * @return string
+ */
+ function RFCDate() {
+ $tz = date('Z');
+ $tzs = ($tz < 0) ? '-' : '+';
+ $tz = abs($tz);
+ $tz = (int)($tz/3600)*100 + ($tz%3600)/60;
+ $result = sprintf("%s %s%04d", date('D, j M Y H:i:s'), $tzs, $tz);
+
+ return $result;
+ }
+
+ /**
+ * Returns the appropriate server variable. Should work with both
+ * PHP 4.1.0+ as well as older versions. Returns an empty string
+ * if nothing is found.
+ * @access private
+ * @return mixed
+ */
+ function ServerVar($varName) {
+ global $HTTP_SERVER_VARS;
+ global $HTTP_ENV_VARS;
+
+ if(!isset($_SERVER)) {
+ $_SERVER = $HTTP_SERVER_VARS;
+ if(!isset($_SERVER['REMOTE_ADDR'])) {
+ $_SERVER = $HTTP_ENV_VARS; // must be Apache
+ }
+ }
+
+ if(isset($_SERVER[$varName])) {
+ return $_SERVER[$varName];
+ } else {
+ return '';
+ }
+ }
+
+ /**
+ * Returns the server hostname or 'localhost.localdomain' if unknown.
+ * @access private
+ * @return string
+ */
+ function ServerHostname() {
+ if ($this->Hostname != '') {
+ $result = $this->Hostname;
+ } elseif ($this->ServerVar('SERVER_NAME') != '') {
+ $result = $this->ServerVar('SERVER_NAME');
+ } else {
+ $result = 'localhost.localdomain';
+ }
+
+ return $result;
+ }
+
+ /**
+ * Returns a message in the appropriate language.
+ * @access private
+ * @return string
+ */
+ function Lang($key) {
+ if(count($this->language) < 1) {
+ $this->SetLanguage('en'); // set the default language
+ }
+
+ if(isset($this->language[$key])) {
+ return $this->language[$key];
+ } else {
+ return 'Language string failed to load: ' . $key;
+ }
+ }
+
+ /**
+ * Returns true if an error occurred.
+ * @return bool
+ */
+ function IsError() {
+ return ($this->error_count > 0);
+ }
+
+ /**
+ * Changes every end of line from CR or LF to CRLF.
+ * @access private
+ * @return string
+ */
+ function FixEOL($str) {
+ $str = str_replace("\r\n", "\n", $str);
+ $str = str_replace("\r", "\n", $str);
+ $str = str_replace("\n", $this->LE, $str);
+ return $str;
+ }
+
+ /**
+ * Adds a custom header.
+ * @return void
+ */
+ function AddCustomHeader($custom_header) {
+ $this->CustomHeader[] = explode(':', $custom_header, 2);
+ }
+
+ /**
+ * Evaluates the message and returns modifications for inline images and backgrounds
+ * @access public
+ * @return $message
+ */
+ function MsgHTML($message,$basedir='') {
+ preg_match_all("/(src|background)=\"(.*)\"/Ui", $message, $images);
+ if(isset($images[2])) {
+ foreach($images[2] as $i => $url) {
+ // do not change urls for absolute images (thanks to corvuscorax)
+ if (!preg_match('/^[A-z][A-z]*:\/\//',$url)) {
+ $filename = basename($url);
+ $directory = dirname($url);
+ ($directory == '.')?$directory='':'';
+ $cid = 'cid:' . md5($filename);
+ $fileParts = split("\.", $filename);
+ $ext = $fileParts[1];
+ $mimeType = $this->_mime_types($ext);
+ if ( strlen($basedir) > 1 && substr($basedir,-1) != '/') { $basedir .= '/'; }
+ if ( strlen($directory) > 1 && substr($basedir,-1) != '/') { $directory .= '/'; }
+ $this->AddEmbeddedImage($basedir.$directory.$filename, md5($filename), $filename, 'base64', $mimeType);
+ if ( $this->AddEmbeddedImage($basedir.$directory.$filename, md5($filename), $filename, 'base64',$mimeType) ) {
+ $message = preg_replace("/".$images[1][$i]."=\"".preg_quote($url, '/')."\"/Ui", $images[1][$i]."=\"".$cid."\"", $message);
+ }
+ }
+ }
+ }
+ $this->IsHTML(true);
+ $this->Body = $message;
+ $textMsg = trim(strip_tags(preg_replace('/<(head|title|style|script)[^>]*>.*?<\/\\1>/s','',$message)));
+ if ( !empty($textMsg) && empty($this->AltBody) ) {
+ $this->AltBody = $textMsg;
+ }
+ if ( empty($this->AltBody) ) {
+ $this->AltBody = 'To view this email message, open the email in with HTML compatibility!' . "\n\n";
+ }
+ }
+
+ /**
+ * Gets the mime type of the embedded or inline image
+ * @access private
+ * @return mime type of ext
+ */
+ function _mime_types($ext = '') {
+ $mimes = array(
+ 'hqx' => 'application/mac-binhex40',
+ 'cpt' => 'application/mac-compactpro',
+ 'doc' => 'application/msword',
+ 'bin' => 'application/macbinary',
+ 'dms' => 'application/octet-stream',
+ 'lha' => 'application/octet-stream',
+ 'lzh' => 'application/octet-stream',
+ 'exe' => 'application/octet-stream',
+ 'class' => 'application/octet-stream',
+ 'psd' => 'application/octet-stream',
+ 'so' => 'application/octet-stream',
+ 'sea' => 'application/octet-stream',
+ 'dll' => 'application/octet-stream',
+ 'oda' => 'application/oda',
+ 'pdf' => 'application/pdf',
+ 'ai' => 'application/postscript',
+ 'eps' => 'application/postscript',
+ 'ps' => 'application/postscript',
+ 'smi' => 'application/smil',
+ 'smil' => 'application/smil',
+ 'mif' => 'application/vnd.mif',
+ 'xls' => 'application/vnd.ms-excel',
+ 'ppt' => 'application/vnd.ms-powerpoint',
+ 'wbxml' => 'application/vnd.wap.wbxml',
+ 'wmlc' => 'application/vnd.wap.wmlc',
+ 'dcr' => 'application/x-director',
+ 'dir' => 'application/x-director',
+ 'dxr' => 'application/x-director',
+ 'dvi' => 'application/x-dvi',
+ 'gtar' => 'application/x-gtar',
+ 'php' => 'application/x-httpd-php',
+ 'php4' => 'application/x-httpd-php',
+ 'php3' => 'application/x-httpd-php',
+ 'phtml' => 'application/x-httpd-php',
+ 'phps' => 'application/x-httpd-php-source',
+ 'js' => 'application/x-javascript',
+ 'swf' => 'application/x-shockwave-flash',
+ 'sit' => 'application/x-stuffit',
+ 'tar' => 'application/x-tar',
+ 'tgz' => 'application/x-tar',
+ 'xhtml' => 'application/xhtml+xml',
+ 'xht' => 'application/xhtml+xml',
+ 'zip' => 'application/zip',
+ 'mid' => 'audio/midi',
+ 'midi' => 'audio/midi',
+ 'mpga' => 'audio/mpeg',
+ 'mp2' => 'audio/mpeg',
+ 'mp3' => 'audio/mpeg',
+ 'aif' => 'audio/x-aiff',
+ 'aiff' => 'audio/x-aiff',
+ 'aifc' => 'audio/x-aiff',
+ 'ram' => 'audio/x-pn-realaudio',
+ 'rm' => 'audio/x-pn-realaudio',
+ 'rpm' => 'audio/x-pn-realaudio-plugin',
+ 'ra' => 'audio/x-realaudio',
+ 'rv' => 'video/vnd.rn-realvideo',
+ 'wav' => 'audio/x-wav',
+ 'bmp' => 'image/bmp',
+ 'gif' => 'image/gif',
+ 'jpeg' => 'image/jpeg',
+ 'jpg' => 'image/jpeg',
+ 'jpe' => 'image/jpeg',
+ 'png' => 'image/png',
+ 'tiff' => 'image/tiff',
+ 'tif' => 'image/tiff',
+ 'css' => 'text/css',
+ 'html' => 'text/html',
+ 'htm' => 'text/html',
+ 'shtml' => 'text/html',
+ 'txt' => 'text/plain',
+ 'text' => 'text/plain',
+ 'log' => 'text/plain',
+ 'rtx' => 'text/richtext',
+ 'rtf' => 'text/rtf',
+ 'xml' => 'text/xml',
+ 'xsl' => 'text/xml',
+ 'mpeg' => 'video/mpeg',
+ 'mpg' => 'video/mpeg',
+ 'mpe' => 'video/mpeg',
+ 'qt' => 'video/quicktime',
+ 'mov' => 'video/quicktime',
+ 'avi' => 'video/x-msvideo',
+ 'movie' => 'video/x-sgi-movie',
+ 'doc' => 'application/msword',
+ 'word' => 'application/msword',
+ 'xl' => 'application/excel',
+ 'eml' => 'message/rfc822'
+ );
+ return ( ! isset($mimes[strtolower($ext)])) ? 'application/octet-stream' : $mimes[strtolower($ext)];
+ }
+
+ /**
+ * Set (or reset) Class Objects (variables)
+ *
+ * Usage Example:
+ * $page->set('X-Priority', '3');
+ *
+ * @access public
+ * @param string $name Parameter Name
+ * @param mixed $value Parameter Value
+ * NOTE: will not work with arrays, there are no arrays to set/reset
+ */
+ function set ( $name, $value = '' ) {
+ if ( isset($this->$name) ) {
+ $this->$name = $value;
+ } else {
+ $this->SetError('Cannot set or reset variable ' . $name);
+ return false;
+ }
+ }
+
+ /**
+ * Read a file from a supplied filename and return it.
+ *
+ * @access public
+ * @param string $filename Parameter File Name
+ */
+ function getFile($filename) {
+ $return = '';
+ if ($fp = fopen($filename, 'rb')) {
+ while (!feof($fp)) {
+ $return .= fread($fp, 1024);
+ }
+ fclose($fp);
+ return $return;
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ * Strips newlines to prevent header injection.
+ * @access private
+ * @param string $str String
+ * @return string
+ */
+ function SecureHeader($str) {
+ $str = trim($str);
+ $str = str_replace("\r", "", $str);
+ $str = str_replace("\n", "", $str);
+ return $str;
+ }
+
+ /**
+ * Set the private key file and password to sign the message.
+ *
+ * @access public
+ * @param string $key_filename Parameter File Name
+ * @param string $key_pass Password for private key
+ */
+ function Sign($key_filename, $key_pass) {
+ $this->sign_key_file = $key_filename;
+ $this->sign_key_pass = $key_pass;
+ }
+
+}
+
+?>
diff --git a/config/freeswitch/class.smtp.tmp b/config/freeswitch/class.smtp.tmp
new file mode 100644
index 00000000..398c3ffb
--- /dev/null
+++ b/config/freeswitch/class.smtp.tmp
@@ -0,0 +1,1062 @@
+<?php
+/*~ class.smtp.php
+.---------------------------------------------------------------------------.
+| Software: PHPMailer - PHP email class |
+| Version: 2.0.2 |
+| Contact: via sourceforge.net support pages (also www.codeworxtech.com) |
+| Info: http://phpmailer.sourceforge.net |
+| Support: http://sourceforge.net/projects/phpmailer/ |
+| ------------------------------------------------------------------------- |
+| Author: Andy Prevost (project admininistrator) |
+| Author: Brent R. Matzelle (original founder) |
+| Copyright (c) 2004-2007, Andy Prevost. All Rights Reserved. |
+| Copyright (c) 2001-2003, Brent R. Matzelle |
+| ------------------------------------------------------------------------- |
+| License: Distributed under the Lesser General Public License (LGPL) |
+| http://www.gnu.org/copyleft/lesser.html |
+| This program is distributed in the hope that it will be useful - WITHOUT |
+| ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+| FITNESS FOR A PARTICULAR PURPOSE. |
+| ------------------------------------------------------------------------- |
+| We offer a number of paid services (www.codeworxtech.com): |
+| - Web Hosting on highly optimized fast and secure servers |
+| - Technology Consulting |
+| - Oursourcing (highly qualified programmers and graphic designers) |
+'---------------------------------------------------------------------------'
+
+/**
+ * SMTP is rfc 821 compliant and implements all the rfc 821 SMTP
+ * commands except TURN which will always return a not implemented
+ * error. SMTP also provides some utility methods for sending mail
+ * to an SMTP server.
+ * @package PHPMailer
+ * @author Chris Ryan
+ */
+
+class SMTP
+{
+ /**
+ * SMTP server port
+ * @var int
+ */
+ var $SMTP_PORT = 25;
+
+ /**
+ * SMTP reply line ending
+ * @var string
+ */
+ var $CRLF = "\r\n";
+
+ /**
+ * Sets whether debugging is turned on
+ * @var bool
+ */
+ var $do_debug; # the level of debug to perform
+
+ /**
+ * Sets VERP use on/off (default is off)
+ * @var bool
+ */
+ var $do_verp = false;
+
+ /**#@+
+ * @access private
+ */
+ var $smtp_conn; # the socket to the server
+ var $error; # error if any on the last call
+ var $helo_rply; # the reply the server sent to us for HELO
+ /**#@-*/
+
+ /**
+ * Initialize the class so that the data is in a known state.
+ * @access public
+ * @return void
+ */
+ function SMTP() {
+ $this->smtp_conn = 0;
+ $this->error = null;
+ $this->helo_rply = null;
+
+ $this->do_debug = 0;
+ }
+
+ /*************************************************************
+ * CONNECTION FUNCTIONS *
+ ***********************************************************/
+
+ /**
+ * Connect to the server specified on the port specified.
+ * If the port is not specified use the default SMTP_PORT.
+ * If tval is specified then a connection will try and be
+ * established with the server for that number of seconds.
+ * If tval is not specified the default is 30 seconds to
+ * try on the connection.
+ *
+ * SMTP CODE SUCCESS: 220
+ * SMTP CODE FAILURE: 421
+ * @access public
+ * @return bool
+ */
+ function Connect($host,$port=0,$tval=30) {
+ # set the error val to null so there is no confusion
+ $this->error = null;
+
+ # make sure we are __not__ connected
+ if($this->connected()) {
+ # ok we are connected! what should we do?
+ # for now we will just give an error saying we
+ # are already connected
+ $this->error = array("error" => "Already connected to a server");
+ return false;
+ }
+
+ if(empty($port)) {
+ $port = $this->SMTP_PORT;
+ }
+
+ #connect to the smtp server
+ $this->smtp_conn = fsockopen($host, # the host of the server
+ $port, # the port to use
+ $errno, # error number if any
+ $errstr, # error message if any
+ $tval); # give up after ? secs
+ # verify we connected properly
+ if(empty($this->smtp_conn)) {
+ $this->error = array("error" => "Failed to connect to server",
+ "errno" => $errno,
+ "errstr" => $errstr);
+ if($this->do_debug >= 1) {
+ echo "SMTP -> ERROR: " . $this->error["error"] .
+ ": $errstr ($errno)" . $this->CRLF;
+ }
+ return false;
+ }
+
+ # sometimes the SMTP server takes a little longer to respond
+ # so we will give it a longer timeout for the first read
+ // Windows still does not have support for this timeout function
+ if(substr(PHP_OS, 0, 3) != "WIN")
+ socket_set_timeout($this->smtp_conn, $tval, 0);
+
+ # get any announcement stuff
+ $announce = $this->get_lines();
+
+ # set the timeout of any socket functions at 1/10 of a second
+ //if(function_exists("socket_set_timeout"))
+ // socket_set_timeout($this->smtp_conn, 0, 100000);
+
+ if($this->do_debug >= 2) {
+ echo "SMTP -> FROM SERVER:" . $this->CRLF . $announce;
+ }
+
+ return true;
+ }
+
+ /**
+ * Performs SMTP authentication. Must be run after running the
+ * Hello() method. Returns true if successfully authenticated.
+ * @access public
+ * @return bool
+ */
+ function Authenticate($username, $password) {
+ // Start authentication
+ fputs($this->smtp_conn,"AUTH LOGIN" . $this->CRLF);
+
+ $rply = $this->get_lines();
+ $code = substr($rply,0,3);
+
+ if($code != 334) {
+ $this->error =
+ array("error" => "AUTH not accepted from server",
+ "smtp_code" => $code,
+ "smtp_msg" => substr($rply,4));
+ if($this->do_debug >= 1) {
+ echo "SMTP -> ERROR: " . $this->error["error"] .
+ ": " . $rply . $this->CRLF;
+ }
+ return false;
+ }
+
+ // Send encoded username
+ fputs($this->smtp_conn, base64_encode($username) . $this->CRLF);
+
+ $rply = $this->get_lines();
+ $code = substr($rply,0,3);
+
+ if($code != 334) {
+ $this->error =
+ array("error" => "Username not accepted from server",
+ "smtp_code" => $code,
+ "smtp_msg" => substr($rply,4));
+ if($this->do_debug >= 1) {
+ echo "SMTP -> ERROR: " . $this->error["error"] .
+ ": " . $rply . $this->CRLF;
+ }
+ return false;
+ }
+
+ // Send encoded password
+ fputs($this->smtp_conn, base64_encode($password) . $this->CRLF);
+
+ $rply = $this->get_lines();
+ $code = substr($rply,0,3);
+
+ if($code != 235) {
+ $this->error =
+ array("error" => "Password not accepted from server",
+ "smtp_code" => $code,
+ "smtp_msg" => substr($rply,4));
+ if($this->do_debug >= 1) {
+ echo "SMTP -> ERROR: " . $this->error["error"] .
+ ": " . $rply . $this->CRLF;
+ }
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * Returns true if connected to a server otherwise false
+ * @access private
+ * @return bool
+ */
+ function Connected() {
+ if(!empty($this->smtp_conn)) {
+ $sock_status = socket_get_status($this->smtp_conn);
+ if($sock_status["eof"]) {
+ # hmm this is an odd situation... the socket is
+ # valid but we are not connected anymore
+ if($this->do_debug >= 1) {
+ echo "SMTP -> NOTICE:" . $this->CRLF .
+ "EOF caught while checking if connected";
+ }
+ $this->Close();
+ return false;
+ }
+ return true; # everything looks good
+ }
+ return false;
+ }
+
+ /**
+ * Closes the socket and cleans up the state of the class.
+ * It is not considered good to use this function without
+ * first trying to use QUIT.
+ * @access public
+ * @return void
+ */
+ function Close() {
+ $this->error = null; # so there is no confusion
+ $this->helo_rply = null;
+ if(!empty($this->smtp_conn)) {
+ # close the connection and cleanup
+ fclose($this->smtp_conn);
+ $this->smtp_conn = 0;
+ }
+ }
+
+ /***************************************************************
+ * SMTP COMMANDS *
+ *************************************************************/
+
+ /**
+ * Issues a data command and sends the msg_data to the server
+ * finializing the mail transaction. $msg_data is the message
+ * that is to be send with the headers. Each header needs to be
+ * on a single line followed by a <CRLF> with the message headers
+ * and the message body being seperated by and additional <CRLF>.
+ *
+ * Implements rfc 821: DATA <CRLF>
+ *
+ * SMTP CODE INTERMEDIATE: 354
+ * [data]
+ * <CRLF>.<CRLF>
+ * SMTP CODE SUCCESS: 250
+ * SMTP CODE FAILURE: 552,554,451,452
+ * SMTP CODE FAILURE: 451,554
+ * SMTP CODE ERROR : 500,501,503,421
+ * @access public
+ * @return bool
+ */
+ function Data($msg_data) {
+ $this->error = null; # so no confusion is caused
+
+ if(!$this->connected()) {
+ $this->error = array(
+ "error" => "Called Data() without being connected");
+ return false;
+ }
+
+ fputs($this->smtp_conn,"DATA" . $this->CRLF);
+
+ $rply = $this->get_lines();
+ $code = substr($rply,0,3);
+
+ if($this->do_debug >= 2) {
+ echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
+ }
+
+ if($code != 354) {
+ $this->error =
+ array("error" => "DATA command not accepted from server",
+ "smtp_code" => $code,
+ "smtp_msg" => substr($rply,4));
+ if($this->do_debug >= 1) {
+ echo "SMTP -> ERROR: " . $this->error["error"] .
+ ": " . $rply . $this->CRLF;
+ }
+ return false;
+ }
+
+ # the server is ready to accept data!
+ # according to rfc 821 we should not send more than 1000
+ # including the CRLF
+ # characters on a single line so we will break the data up
+ # into lines by \r and/or \n then if needed we will break
+ # each of those into smaller lines to fit within the limit.
+ # in addition we will be looking for lines that start with
+ # a period '.' and append and additional period '.' to that
+ # line. NOTE: this does not count towards are limit.
+
+ # normalize the line breaks so we know the explode works
+ $msg_data = str_replace("\r\n","\n",$msg_data);
+ $msg_data = str_replace("\r","\n",$msg_data);
+ $lines = explode("\n",$msg_data);
+
+ # we need to find a good way to determine is headers are
+ # in the msg_data or if it is a straight msg body
+ # currently I am assuming rfc 822 definitions of msg headers
+ # and if the first field of the first line (':' sperated)
+ # does not contain a space then it _should_ be a header
+ # and we can process all lines before a blank "" line as
+ # headers.
+ $field = substr($lines[0],0,strpos($lines[0],":"));
+ $in_headers = false;
+ if(!empty($field) && !strstr($field," ")) {
+ $in_headers = true;
+ }
+
+ $max_line_length = 998; # used below; set here for ease in change
+
+ while(list(,$line) = @each($lines)) {
+ $lines_out = null;
+ if($line == "" && $in_headers) {
+ $in_headers = false;
+ }
+ # ok we need to break this line up into several
+ # smaller lines
+ while(strlen($line) > $max_line_length) {
+ $pos = strrpos(substr($line,0,$max_line_length)," ");
+
+ # Patch to fix DOS attack
+ if(!$pos) {
+ $pos = $max_line_length - 1;
+ }
+
+ $lines_out[] = substr($line,0,$pos);
+ $line = substr($line,$pos + 1);
+ # if we are processing headers we need to
+ # add a LWSP-char to the front of the new line
+ # rfc 822 on long msg headers
+ if($in_headers) {
+ $line = "\t" . $line;
+ }
+ }
+ $lines_out[] = $line;
+
+ # now send the lines to the server
+ while(list(,$line_out) = @each($lines_out)) {
+ if(strlen($line_out) > 0)
+ {
+ if(substr($line_out, 0, 1) == ".") {
+ $line_out = "." . $line_out;
+ }
+ }
+ fputs($this->smtp_conn,$line_out . $this->CRLF);
+ }
+ }
+
+ # ok all the message data has been sent so lets get this
+ # over with aleady
+ fputs($this->smtp_conn, $this->CRLF . "." . $this->CRLF);
+
+ $rply = $this->get_lines();
+ $code = substr($rply,0,3);
+
+ if($this->do_debug >= 2) {
+ echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
+ }
+
+ if($code != 250) {
+ $this->error =
+ array("error" => "DATA not accepted from server",
+ "smtp_code" => $code,
+ "smtp_msg" => substr($rply,4));
+ if($this->do_debug >= 1) {
+ echo "SMTP -> ERROR: " . $this->error["error"] .
+ ": " . $rply . $this->CRLF;
+ }
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Expand takes the name and asks the server to list all the
+ * people who are members of the _list_. Expand will return
+ * back and array of the result or false if an error occurs.
+ * Each value in the array returned has the format of:
+ * [ <full-name> <sp> ] <path>
+ * The definition of <path> is defined in rfc 821
+ *
+ * Implements rfc 821: EXPN <SP> <string> <CRLF>
+ *
+ * SMTP CODE SUCCESS: 250
+ * SMTP CODE FAILURE: 550
+ * SMTP CODE ERROR : 500,501,502,504,421
+ * @access public
+ * @return string array
+ */
+ function Expand($name) {
+ $this->error = null; # so no confusion is caused
+
+ if(!$this->connected()) {
+ $this->error = array(
+ "error" => "Called Expand() without being connected");
+ return false;
+ }
+
+ fputs($this->smtp_conn,"EXPN " . $name . $this->CRLF);
+
+ $rply = $this->get_lines();
+ $code = substr($rply,0,3);
+
+ if($this->do_debug >= 2) {
+ echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
+ }
+
+ if($code != 250) {
+ $this->error =
+ array("error" => "EXPN not accepted from server",
+ "smtp_code" => $code,
+ "smtp_msg" => substr($rply,4));
+ if($this->do_debug >= 1) {
+ echo "SMTP -> ERROR: " . $this->error["error"] .
+ ": " . $rply . $this->CRLF;
+ }
+ return false;
+ }
+
+ # parse the reply and place in our array to return to user
+ $entries = explode($this->CRLF,$rply);
+ while(list(,$l) = @each($entries)) {
+ $list[] = substr($l,4);
+ }
+
+ return $list;
+ }
+
+ /**
+ * Sends the HELO command to the smtp server.
+ * This makes sure that we and the server are in
+ * the same known state.
+ *
+ * Implements from rfc 821: HELO <SP> <domain> <CRLF>
+ *
+ * SMTP CODE SUCCESS: 250
+ * SMTP CODE ERROR : 500, 501, 504, 421
+ * @access public
+ * @return bool
+ */
+ function Hello($host="") {
+ $this->error = null; # so no confusion is caused
+
+ if(!$this->connected()) {
+ $this->error = array(
+ "error" => "Called Hello() without being connected");
+ return false;
+ }
+
+ # if a hostname for the HELO was not specified determine
+ # a suitable one to send
+ if(empty($host)) {
+ # we need to determine some sort of appopiate default
+ # to send to the server
+ $host = "localhost";
+ }
+
+ // Send extended hello first (RFC 2821)
+ if(!$this->SendHello("EHLO", $host))
+ {
+ if(!$this->SendHello("HELO", $host))
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * Sends a HELO/EHLO command.
+ * @access private
+ * @return bool
+ */
+ function SendHello($hello, $host) {
+ fputs($this->smtp_conn, $hello . " " . $host . $this->CRLF);
+
+ $rply = $this->get_lines();
+ $code = substr($rply,0,3);
+
+ if($this->do_debug >= 2) {
+ echo "SMTP -> FROM SERVER: " . $this->CRLF . $rply;
+ }
+
+ if($code != 250) {
+ $this->error =
+ array("error" => $hello . " not accepted from server",
+ "smtp_code" => $code,
+ "smtp_msg" => substr($rply,4));
+ if($this->do_debug >= 1) {
+ echo "SMTP -> ERROR: " . $this->error["error"] .
+ ": " . $rply . $this->CRLF;
+ }
+ return false;
+ }
+
+ $this->helo_rply = $rply;
+
+ return true;
+ }
+
+ /**
+ * Gets help information on the keyword specified. If the keyword
+ * is not specified then returns generic help, ussually contianing
+ * A list of keywords that help is available on. This function
+ * returns the results back to the user. It is up to the user to
+ * handle the returned data. If an error occurs then false is
+ * returned with $this->error set appropiately.
+ *
+ * Implements rfc 821: HELP [ <SP> <string> ] <CRLF>
+ *
+ * SMTP CODE SUCCESS: 211,214
+ * SMTP CODE ERROR : 500,501,502,504,421
+ * @access public
+ * @return string
+ */
+ function Help($keyword="") {
+ $this->error = null; # to avoid confusion
+
+ if(!$this->connected()) {
+ $this->error = array(
+ "error" => "Called Help() without being connected");
+ return false;
+ }
+
+ $extra = "";
+ if(!empty($keyword)) {
+ $extra = " " . $keyword;
+ }
+
+ fputs($this->smtp_conn,"HELP" . $extra . $this->CRLF);
+
+ $rply = $this->get_lines();
+ $code = substr($rply,0,3);
+
+ if($this->do_debug >= 2) {
+ echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
+ }
+
+ if($code != 211 && $code != 214) {
+ $this->error =
+ array("error" => "HELP not accepted from server",
+ "smtp_code" => $code,
+ "smtp_msg" => substr($rply,4));
+ if($this->do_debug >= 1) {
+ echo "SMTP -> ERROR: " . $this->error["error"] .
+ ": " . $rply . $this->CRLF;
+ }
+ return false;
+ }
+
+ return $rply;
+ }
+
+ /**
+ * Starts a mail transaction from the email address specified in
+ * $from. Returns true if successful or false otherwise. If True
+ * the mail transaction is started and then one or more Recipient
+ * commands may be called followed by a Data command.
+ *
+ * Implements rfc 821: MAIL <SP> FROM:<reverse-path> <CRLF>
+ *
+ * SMTP CODE SUCCESS: 250
+ * SMTP CODE SUCCESS: 552,451,452
+ * SMTP CODE SUCCESS: 500,501,421
+ * @access public
+ * @return bool
+ */
+ function Mail($from) {
+ $this->error = null; # so no confusion is caused
+
+ if(!$this->connected()) {
+ $this->error = array(
+ "error" => "Called Mail() without being connected");
+ return false;
+ }
+
+ $useVerp = ($this->do_verp ? "XVERP" : "");
+ fputs($this->smtp_conn,"MAIL FROM:<" . $from . ">" . $useVerp . $this->CRLF);
+
+ $rply = $this->get_lines();
+ $code = substr($rply,0,3);
+
+ if($this->do_debug >= 2) {
+ echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
+ }
+
+ if($code != 250) {
+ $this->error =
+ array("error" => "MAIL not accepted from server",
+ "smtp_code" => $code,
+ "smtp_msg" => substr($rply,4));
+ if($this->do_debug >= 1) {
+ echo "SMTP -> ERROR: " . $this->error["error"] .
+ ": " . $rply . $this->CRLF;
+ }
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Sends the command NOOP to the SMTP server.
+ *
+ * Implements from rfc 821: NOOP <CRLF>
+ *
+ * SMTP CODE SUCCESS: 250
+ * SMTP CODE ERROR : 500, 421
+ * @access public
+ * @return bool
+ */
+ function Noop() {
+ $this->error = null; # so no confusion is caused
+
+ if(!$this->connected()) {
+ $this->error = array(
+ "error" => "Called Noop() without being connected");
+ return false;
+ }
+
+ fputs($this->smtp_conn,"NOOP" . $this->CRLF);
+
+ $rply = $this->get_lines();
+ $code = substr($rply,0,3);
+
+ if($this->do_debug >= 2) {
+ echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
+ }
+
+ if($code != 250) {
+ $this->error =
+ array("error" => "NOOP not accepted from server",
+ "smtp_code" => $code,
+ "smtp_msg" => substr($rply,4));
+ if($this->do_debug >= 1) {
+ echo "SMTP -> ERROR: " . $this->error["error"] .
+ ": " . $rply . $this->CRLF;
+ }
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Sends the quit command to the server and then closes the socket
+ * if there is no error or the $close_on_error argument is true.
+ *
+ * Implements from rfc 821: QUIT <CRLF>
+ *
+ * SMTP CODE SUCCESS: 221
+ * SMTP CODE ERROR : 500
+ * @access public
+ * @return bool
+ */
+ function Quit($close_on_error=true) {
+ $this->error = null; # so there is no confusion
+
+ if(!$this->connected()) {
+ $this->error = array(
+ "error" => "Called Quit() without being connected");
+ return false;
+ }
+
+ # send the quit command to the server
+ fputs($this->smtp_conn,"quit" . $this->CRLF);
+
+ # get any good-bye messages
+ $byemsg = $this->get_lines();
+
+ if($this->do_debug >= 2) {
+ echo "SMTP -> FROM SERVER:" . $this->CRLF . $byemsg;
+ }
+
+ $rval = true;
+ $e = null;
+
+ $code = substr($byemsg,0,3);
+ if($code != 221) {
+ # use e as a tmp var cause Close will overwrite $this->error
+ $e = array("error" => "SMTP server rejected quit command",
+ "smtp_code" => $code,
+ "smtp_rply" => substr($byemsg,4));
+ $rval = false;
+ if($this->do_debug >= 1) {
+ echo "SMTP -> ERROR: " . $e["error"] . ": " .
+ $byemsg . $this->CRLF;
+ }
+ }
+
+ if(empty($e) || $close_on_error) {
+ $this->Close();
+ }
+
+ return $rval;
+ }
+
+ /**
+ * Sends the command RCPT to the SMTP server with the TO: argument of $to.
+ * Returns true if the recipient was accepted false if it was rejected.
+ *
+ * Implements from rfc 821: RCPT <SP> TO:<forward-path> <CRLF>
+ *
+ * SMTP CODE SUCCESS: 250,251
+ * SMTP CODE FAILURE: 550,551,552,553,450,451,452
+ * SMTP CODE ERROR : 500,501,503,421
+ * @access public
+ * @return bool
+ */
+ function Recipient($to) {
+ $this->error = null; # so no confusion is caused
+
+ if(!$this->connected()) {
+ $this->error = array(
+ "error" => "Called Recipient() without being connected");
+ return false;
+ }
+
+ fputs($this->smtp_conn,"RCPT TO:<" . $to . ">" . $this->CRLF);
+
+ $rply = $this->get_lines();
+ $code = substr($rply,0,3);
+
+ if($this->do_debug >= 2) {
+ echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
+ }
+
+ if($code != 250 && $code != 251) {
+ $this->error =
+ array("error" => "RCPT not accepted from server",
+ "smtp_code" => $code,
+ "smtp_msg" => substr($rply,4));
+ if($this->do_debug >= 1) {
+ echo "SMTP -> ERROR: " . $this->error["error"] .
+ ": " . $rply . $this->CRLF;
+ }
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Sends the RSET command to abort and transaction that is
+ * currently in progress. Returns true if successful false
+ * otherwise.
+ *
+ * Implements rfc 821: RSET <CRLF>
+ *
+ * SMTP CODE SUCCESS: 250
+ * SMTP CODE ERROR : 500,501,504,421
+ * @access public
+ * @return bool
+ */
+ function Reset() {
+ $this->error = null; # so no confusion is caused
+
+ if(!$this->connected()) {
+ $this->error = array(
+ "error" => "Called Reset() without being connected");
+ return false;
+ }
+
+ fputs($this->smtp_conn,"RSET" . $this->CRLF);
+
+ $rply = $this->get_lines();
+ $code = substr($rply,0,3);
+
+ if($this->do_debug >= 2) {
+ echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
+ }
+
+ if($code != 250) {
+ $this->error =
+ array("error" => "RSET failed",
+ "smtp_code" => $code,
+ "smtp_msg" => substr($rply,4));
+ if($this->do_debug >= 1) {
+ echo "SMTP -> ERROR: " . $this->error["error"] .
+ ": " . $rply . $this->CRLF;
+ }
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * Starts a mail transaction from the email address specified in
+ * $from. Returns true if successful or false otherwise. If True
+ * the mail transaction is started and then one or more Recipient
+ * commands may be called followed by a Data command. This command
+ * will send the message to the users terminal if they are logged
+ * in.
+ *
+ * Implements rfc 821: SEND <SP> FROM:<reverse-path> <CRLF>
+ *
+ * SMTP CODE SUCCESS: 250
+ * SMTP CODE SUCCESS: 552,451,452
+ * SMTP CODE SUCCESS: 500,501,502,421
+ * @access public
+ * @return bool
+ */
+ function Send($from) {
+ $this->error = null; # so no confusion is caused
+
+ if(!$this->connected()) {
+ $this->error = array(
+ "error" => "Called Send() without being connected");
+ return false;
+ }
+
+ fputs($this->smtp_conn,"SEND FROM:" . $from . $this->CRLF);
+
+ $rply = $this->get_lines();
+ $code = substr($rply,0,3);
+
+ if($this->do_debug >= 2) {
+ echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
+ }
+
+ if($code != 250) {
+ $this->error =
+ array("error" => "SEND not accepted from server",
+ "smtp_code" => $code,
+ "smtp_msg" => substr($rply,4));
+ if($this->do_debug >= 1) {
+ echo "SMTP -> ERROR: " . $this->error["error"] .
+ ": " . $rply . $this->CRLF;
+ }
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Starts a mail transaction from the email address specified in
+ * $from. Returns true if successful or false otherwise. If True
+ * the mail transaction is started and then one or more Recipient
+ * commands may be called followed by a Data command. This command
+ * will send the message to the users terminal if they are logged
+ * in and send them an email.
+ *
+ * Implements rfc 821: SAML <SP> FROM:<reverse-path> <CRLF>
+ *
+ * SMTP CODE SUCCESS: 250
+ * SMTP CODE SUCCESS: 552,451,452
+ * SMTP CODE SUCCESS: 500,501,502,421
+ * @access public
+ * @return bool
+ */
+ function SendAndMail($from) {
+ $this->error = null; # so no confusion is caused
+
+ if(!$this->connected()) {
+ $this->error = array(
+ "error" => "Called SendAndMail() without being connected");
+ return false;
+ }
+
+ fputs($this->smtp_conn,"SAML FROM:" . $from . $this->CRLF);
+
+ $rply = $this->get_lines();
+ $code = substr($rply,0,3);
+
+ if($this->do_debug >= 2) {
+ echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
+ }
+
+ if($code != 250) {
+ $this->error =
+ array("error" => "SAML not accepted from server",
+ "smtp_code" => $code,
+ "smtp_msg" => substr($rply,4));
+ if($this->do_debug >= 1) {
+ echo "SMTP -> ERROR: " . $this->error["error"] .
+ ": " . $rply . $this->CRLF;
+ }
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Starts a mail transaction from the email address specified in
+ * $from. Returns true if successful or false otherwise. If True
+ * the mail transaction is started and then one or more Recipient
+ * commands may be called followed by a Data command. This command
+ * will send the message to the users terminal if they are logged
+ * in or mail it to them if they are not.
+ *
+ * Implements rfc 821: SOML <SP> FROM:<reverse-path> <CRLF>
+ *
+ * SMTP CODE SUCCESS: 250
+ * SMTP CODE SUCCESS: 552,451,452
+ * SMTP CODE SUCCESS: 500,501,502,421
+ * @access public
+ * @return bool
+ */
+ function SendOrMail($from) {
+ $this->error = null; # so no confusion is caused
+
+ if(!$this->connected()) {
+ $this->error = array(
+ "error" => "Called SendOrMail() without being connected");
+ return false;
+ }
+
+ fputs($this->smtp_conn,"SOML FROM:" . $from . $this->CRLF);
+
+ $rply = $this->get_lines();
+ $code = substr($rply,0,3);
+
+ if($this->do_debug >= 2) {
+ echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
+ }
+
+ if($code != 250) {
+ $this->error =
+ array("error" => "SOML not accepted from server",
+ "smtp_code" => $code,
+ "smtp_msg" => substr($rply,4));
+ if($this->do_debug >= 1) {
+ echo "SMTP -> ERROR: " . $this->error["error"] .
+ ": " . $rply . $this->CRLF;
+ }
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * This is an optional command for SMTP that this class does not
+ * support. This method is here to make the RFC821 Definition
+ * complete for this class and __may__ be implimented in the future
+ *
+ * Implements from rfc 821: TURN <CRLF>
+ *
+ * SMTP CODE SUCCESS: 250
+ * SMTP CODE FAILURE: 502
+ * SMTP CODE ERROR : 500, 503
+ * @access public
+ * @return bool
+ */
+ function Turn() {
+ $this->error = array("error" => "This method, TURN, of the SMTP ".
+ "is not implemented");
+ if($this->do_debug >= 1) {
+ echo "SMTP -> NOTICE: " . $this->error["error"] . $this->CRLF;
+ }
+ return false;
+ }
+
+ /**
+ * Verifies that the name is recognized by the server.
+ * Returns false if the name could not be verified otherwise
+ * the response from the server is returned.
+ *
+ * Implements rfc 821: VRFY <SP> <string> <CRLF>
+ *
+ * SMTP CODE SUCCESS: 250,251
+ * SMTP CODE FAILURE: 550,551,553
+ * SMTP CODE ERROR : 500,501,502,421
+ * @access public
+ * @return int
+ */
+ function Verify($name) {
+ $this->error = null; # so no confusion is caused
+
+ if(!$this->connected()) {
+ $this->error = array(
+ "error" => "Called Verify() without being connected");
+ return false;
+ }
+
+ fputs($this->smtp_conn,"VRFY " . $name . $this->CRLF);
+
+ $rply = $this->get_lines();
+ $code = substr($rply,0,3);
+
+ if($this->do_debug >= 2) {
+ echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
+ }
+
+ if($code != 250 && $code != 251) {
+ $this->error =
+ array("error" => "VRFY failed on name '$name'",
+ "smtp_code" => $code,
+ "smtp_msg" => substr($rply,4));
+ if($this->do_debug >= 1) {
+ echo "SMTP -> ERROR: " . $this->error["error"] .
+ ": " . $rply . $this->CRLF;
+ }
+ return false;
+ }
+ return $rply;
+ }
+
+ /*******************************************************************
+ * INTERNAL FUNCTIONS *
+ ******************************************************************/
+
+ /**
+ * Read in as many lines as possible
+ * either before eof or socket timeout occurs on the operation.
+ * With SMTP we can tell if we have more lines to read if the
+ * 4th character is '-' symbol. If it is a space then we don't
+ * need to read anything else.
+ * @access private
+ * @return string
+ */
+ function get_lines() {
+ $data = "";
+ while($str = @fgets($this->smtp_conn,515)) {
+ if($this->do_debug >= 4) {
+ echo "SMTP -> get_lines(): \$data was \"$data\"" .
+ $this->CRLF;
+ echo "SMTP -> get_lines(): \$str is \"$str\"" .
+ $this->CRLF;
+ }
+ $data .= $str;
+ if($this->do_debug >= 4) {
+ echo "SMTP -> get_lines(): \$data is \"$data\"" . $this->CRLF;
+ }
+ # if the 4th character is a space then we are done reading
+ # so just break the loop
+ if(substr($str,3,1) == " ") { break; }
+ }
+ return $data;
+ }
+
+}
+
+
+ ?>
diff --git a/config/freeswitch/freeswitch.inc b/config/freeswitch/freeswitch.inc
new file mode 100644
index 00000000..82fa97b1
--- /dev/null
+++ b/config/freeswitch/freeswitch.inc
@@ -0,0 +1,2234 @@
+<?php
+/* $Id$ */
+/*
+/* ========================================================================== */
+/*
+ freeswitch.inc
+ Copyright (C) 2008 Mark J Crane
+ All rights reserved.
+
+ FreeSWITCH (TM)
+ http://www.freeswitch.org/
+ */
+/* ========================================================================== */
+/*
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+
+function guid()
+{
+ if (function_exists('com_create_guid')){
+ return com_create_guid();
+ }else{
+ mt_srand((double)microtime()*10000);//optional for php 4.2.0 and up.
+ $charid = strtoupper(md5(uniqid(rand(), true)));
+ $hyphen = chr(45);// "-"
+ $uuid = chr(123)// "{"
+ .substr($charid, 0, 8).$hyphen
+ .substr($charid, 8, 4).$hyphen
+ .substr($charid,12, 4).$hyphen
+ .substr($charid,16, 4).$hyphen
+ .substr($charid,20,12)
+ .chr(125);// "}"
+ return $uuid;
+ }
+}
+//echo guid();
+
+
+function pkg_is_service_running($servicename)
+{
+ exec("/bin/ps ax | awk '{ print $5 }'", $psout);
+ array_shift($psout);
+ foreach($psout as $line) {
+ $ps[] = trim(array_pop(explode(' ', array_pop(explode('/', $line)))));
+ }
+ if(is_service_running($servicename, $ps) or is_process_running($servicename) ) {
+ return true;
+ }
+ else {
+ return false;
+ }
+}
+
+
+function event_socket_create($host, $port, $password)
+{
+ //$host has been deprecated
+
+ //build the interface list
+ $i = 0; $ifdescrs = array('wan' => 'WAN', 'lan' => 'LAN');
+ for ($j = 1; isset($config['interfaces']['opt' . $j]); $j++) {
+ $ifdescrs['opt' . $j] = $config['interfaces']['opt' . $j]['descr'];
+ }
+
+ //get the interface ip addresses and try to connect to them
+ foreach ($ifdescrs as $ifdescr => $ifname){
+ $ifinfo = get_interface_info($ifdescr);
+ $interface_ip_address = $ifinfo['ipaddr'];
+
+ if (strlen($interface_ip_address) > 0) {
+
+ $fp = fsockopen($interface_ip_address, $port, $errno, $errdesc, 3);
+ socket_set_blocking($fp,false);
+
+ if (!$fp) {
+ //connection failed continue through the loop testing other addresses
+ //invalid handle
+ }
+ else {
+ //connected to the socket return the handle
+
+ while (!feof($fp)) {
+ $buffer = fgets($fp, 1024);
+ usleep(100); //allow time for reponse
+ if (trim($buffer) == "Content-Type: auth/request") {
+ fputs($fp, "auth $password\n\n");
+ break;
+ }
+ }
+ return $fp;
+ }
+
+ } //end if interface_ip_address
+ } //end foreach
+} //end function
+
+
+function event_socket_request($fp, $cmd)
+{
+ if ($fp) {
+ fputs($fp, $cmd."\n\n");
+ usleep(100); //allow time for reponse
+
+ $response = "";
+ $i = 0;
+ $contentlength = 0;
+ while (!feof($fp)) {
+ $buffer = fgets($fp, 4096);
+ if ($contentlength > 0) {
+ $response .= $buffer;
+ }
+
+ if ($contentlength == 0) { //if contentlenght is already don't process again
+ if (strlen(trim($buffer)) > 0) { //run only if buffer has content
+ $temparray = split(":", trim($buffer));
+ if ($temparray[0] == "Content-Length") {
+ $contentlength = trim($temparray[1]);
+ }
+ }
+ }
+
+ usleep(100); //allow time for reponse
+
+ //optional because of script timeout //don't let while loop become endless
+ if ($i > 10000) { break; }
+
+ if ($contentlength > 0) { //is contentlength set
+ //stop reading if all content has been read.
+ if (strlen($response) >= $contentlength) {
+ break;
+ }
+ }
+ $i++;
+ }
+
+ return $response;
+ }
+ else {
+ echo "no handle";
+ }
+}
+
+
+function event_socket_request_cmd($cmd)
+{
+ global $config;
+ $password = $config['installedpackages']['freeswitchsettings']['config'][0]['event_socket_password'];
+ $port = $config['installedpackages']['freeswitchsettings']['config'][0]['event_socket_port'];
+ $host = $config['interfaces']['lan']['ipaddr'];
+
+ if (pkg_is_service_running('freeswitch')) {
+ $fp = event_socket_create($host, $port, $password);
+ $response = event_socket_request($fp, $cmd);
+ fclose($fp);
+ }
+ unset($host, $port, $password);
+
+}
+
+function byte_convert( $bytes ) {
+
+ if ($bytes<=0)
+ return '0 Byte';
+
+ $convention=1000; //[1000->10^x|1024->2^x]
+ $s=array('B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB');
+ $e=floor(log($bytes,$convention));
+ return round($bytes/pow($convention,$e),2).' '.$s[$e];
+}
+
+function recording_js()
+{
+
+ global $config;
+ $admin_pin = $config['installedpackages']['freeswitchsettings']['config'][0]['admin_pin'];
+
+ $fout = fopen("/usr/local/freeswitch/scripts/recordings.js","w");
+ $tmp = " var pin = \"".$admin_pin."\";\n";
+ $tmp .= " //var pin = \"\"; //don't require a pin\n";
+ $tmp .= " //if you choose not to require a pin then then you may want to add a dialplan condition for a specific caller id\n";
+ $tmp .= "\n";
+ $tmp .= " var digitmaxlength = 0;\n";
+ $tmp .= " var timeoutpin = 7500;\n";
+ $tmp .= " var timeouttransfer = 7500;\n";
+ $tmp .= " var objdate = new Date();\n";
+ $tmp .= "\n";
+ $tmp .= " var adjusthours = 0; //Adjust Server time that is set to GMT 7 hours\n";
+ $tmp .= " var adjustoperator = \"-\"; //+ or -\n";
+ $tmp .= "\n";
+ $tmp .= " if (adjustoperator == \"-\") {\n";
+ $tmp .= " var objdate2 = new Date(objdate.getFullYear(),objdate.getMonth(),objdate.getDate(),(objdate.getHours() - adjusthours),objdate.getMinutes(),objdate.getSeconds());\n";
+ $tmp .= " }\n";
+ $tmp .= " if (adjustoperator == \"+\") {\n";
+ $tmp .= " var objdate2 = new Date(objdate.getFullYear(),objdate.getMonth(),objdate.getDate(),(objdate.getHours() + adjusthours),objdate.getMinutes(),objdate.getSeconds());\n";
+ $tmp .= " }\n";
+ $tmp .= "\n";
+ $tmp .= " var Hours = objdate2.getHours();\n";
+ $tmp .= " var Mins = objdate2.getMinutes();\n";
+ $tmp .= " var Seconds = objdate2.getSeconds();\n";
+ $tmp .= " var Month = objdate2.getMonth() + 1;\n";
+ $tmp .= " var Date = objdate2.getDate();\n";
+ $tmp .= " var Year = objdate2.getYear()\n";
+ $tmp .= " var Day = objdate2.getDay()+1;\n";
+ $tmp .= " var exit = false;\n";
+ $tmp .= "\n";
+ $tmp .= "\n";
+ $tmp .= " function mycb( session, type, data, arg ) {\n";
+ $tmp .= " if ( type == \"dtmf\" ) {\n";
+ $tmp .= " //console_log( \"info\", \"digit: \"+data.digit+\"\\n\" );\n";
+ $tmp .= " if ( data.digit == \"#\" ) {\n";
+ $tmp .= " //console_log( \"info\", \"detected pound sign.\\n\" );\n";
+ $tmp .= " return( true );\n";
+ $tmp .= " }\n";
+ $tmp .= " dtmf.digits += data.digit;\n";
+ $tmp .= "\n";
+ $tmp .= " if ( dtmf.digits.length < digitmaxlength ) {\n";
+ $tmp .= " return( true );\n";
+ $tmp .= " }\n";
+ $tmp .= " }\n";
+ $tmp .= " return( false );\n";
+ $tmp .= " }\n";
+ $tmp .= "\n";
+ $tmp .= " //console_log( \"info\", \"Recording Request\\n\" );\n";
+ $tmp .= "\n";
+ $tmp .= " var dtmf = new Object( );\n";
+ $tmp .= " dtmf.digits = \"\";\n";
+ $tmp .= "\n";
+ $tmp .= " if ( session.ready( ) ) {\n";
+ $tmp .= " session.answer( );\n";
+ $tmp .= "\n";
+
+ $tmp .= "\n";
+ $tmp .= " if (pin.length > 0) {\n";
+ //$tmp .= " session.execute(\"set\", \"tts_engine=flite\");\n";
+ //$tmp .= " session.execute(\"set\", \"tts_voice=kal\");\n";
+ //$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.collectInput( mycb, dtmf, timeoutpin );\n";
+ $tmp .= " }\n";
+ $tmp .= "\n";
+ $tmp .= " if (dtmf.digits == pin || pin.length == 0) {\n";
+ //$tmp .= " //console_log( \"info\", \"Recordings pin is correct\\n\" );\n";
+ //$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.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";
+ $tmp .= " else {\n";
+ $tmp .= " console_log( \"info\", \"Pin: \" + dtmf.digits + \" is incorrect\\n\" );\n";
+ //$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 .= " }\n";
+ $tmp .= " session.hangup();\n";
+ $tmp .= "\n";
+ $tmp .= " }";
+ fwrite($fout, $tmp);
+ unset($tmp);
+ fclose($fout);
+
+}
+
+
+function sync_package_freeswitch_settings()
+{
+
+ global $config;
+ if($config['installedpackages']['freeswitchsettings']['config'] != "") {
+
+ conf_mount_rw();
+ config_unlock();
+
+ foreach($config['installedpackages']['freeswitchsettings']['config'] as $rowhelper) {
+
+ $fout = fopen("/usr/local/freeswitch/conf/directory/default/default.xml","w");
+ $tmpxml = "<include>\n";
+ $tmpxml .= " <user id=\"default\"> <!--if id is numeric mailbox param is not necessary-->\n";
+ $tmpxml .= " <variables>\n";
+ $tmpxml .= " <!--all variables here will be set on all inbound calls that originate from this user -->\n";
+ $tmpxml .= " <!-- set these to take advantage of a dialplan localized to this user -->\n";
+ $tmpxml .= " <variable name=\"numbering_plan\" value=\"" . $rowhelper['numbering_plan'] . "\"/>\n";
+ $tmpxml .= " <variable name=\"default_gateway\" value=\"" . $rowhelper['default_gateway'] . "\"/>\n";
+ $tmpxml .= " <variable name=\"default_area_code\" value=\"" . $rowhelper['default_area_code'] . "\"/>\n";
+ $tmpxml .= " </variables>\n";
+ $tmpxml .= " </user>\n";
+ $tmpxml .= "</include>\n";
+ fwrite($fout, $tmpxml);
+ unset($tmpxml);
+ fclose($fout);
+
+ $fout = fopen("/usr/local/freeswitch/conf/autoload_configs/event_socket.conf.xml","w");
+ $tmpxml = "<configuration name=\"event_socket.conf\" description=\"Socket Client\">\n";
+ $tmpxml .= " <settings>\n";
+ $tmpxml .= " <param name=\"listen-ip\" value=\"0.0.0.0\"/>\n";
+ $tmpxml .= " <param name=\"listen-port\" value=\"" . $rowhelper['event_socket_port'] . "\"/>\n";
+ $tmpxml .= " <param name=\"password\" value=\"" . $rowhelper['event_socket_password'] . "\"/>\n";
+ $tmpxml .= " <!--<param name=\"apply-inbound-acl\" value=\"lan\"/>-->\n";
+ $tmpxml .= " </settings>\n";
+ $tmpxml .= "</configuration>";
+ fwrite($fout, $tmpxml);
+ unset($tmpxml, $event_socket_password);
+ fclose($fout);
+
+ $fout = fopen("/usr/local/freeswitch/conf/autoload_configs/xml_rpc.conf","w");
+ $tmpxml = "<configuration name=\"xml_rpc.conf\" description=\"XML RPC\">\n";
+ $tmpxml .= " <settings>\n";
+ $tmpxml .= " <!-- The port where you want to run the http service (default 8080) -->\n";
+ $tmpxml .= " <param name=\"http-port\" value=\"" . $rowhelper['xml_rpc_http_port'] . "\"/>\n";
+ $tmpxml .= " <!-- if all 3 of the following params exist all http traffic will require auth -->\n";
+ $tmpxml .= " <param name=\"auth-realm\" value=\"" . $rowhelper['xml_rpc_auth_realm'] . "\"/>\n";
+ $tmpxml .= " <param name=\"auth-user\" value=\"" . $rowhelper['xml_rpc_auth_user'] . "\"/>\n";
+ $tmpxml .= " <param name=\"auth-pass\" value=\"" . $rowhelper['xml_rpc_auth_pass'] . "\"/>\n";
+ $tmpxml .= " </settings>\n";
+ $tmpxml .= "</configuration>\n";
+ fwrite($fout, $tmpxml);
+ unset($tmpxml, $event_socket_password);
+ fclose($fout);
+
+ recording_js();
+
+ }
+
+ conf_mount_ro();
+ $cmd = "api reloadxml";
+ //event_socket_request_cmd($cmd);
+ unset($cmd);
+ }
+}
+
+
+function sync_package_freeswitch_dialplan()
+{
+
+ global $config;
+ conf_mount_rw();
+ config_unlock();
+
+ if(strlen($config['installedpackages']['freeswitchdialplan']['config'][0]['dialplan_default_xml']) == 0) {
+ /* dialplan not found in the pfsense config.xml get the default dialplan and save to config.xml. */
+ $filename = "/usr/local/freeswitch/conf/dialplan/default.xml";
+ $fout = fopen($filename,"r");
+ $tmpxml = fread($fout, filesize($filename));
+ $config['installedpackages']['freeswitchdialplan']['config'][0]['dialplan_default_xml'] = base64_encode($tmpxml);
+ unset($filename, $dialplan);
+ fclose($fout);
+ }
+ else {
+ /* found the dialplan in the pfsense config.xml save it to default.xml. */
+ $fout = fopen("/usr/local/freeswitch/conf/dialplan/default.xml","w");
+ $tmpxml = $config['installedpackages']['freeswitchdialplan']['config'][0]['dialplan_default_xml'];
+ fwrite($fout, base64_decode($tmpxml));
+ fclose($fout);
+ unset($tmpxml);
+ }
+
+ conf_mount_ro();
+ $cmd = "api reloadxml";
+ //event_socket_request_cmd($cmd);
+ unset($cmd);
+
+}
+
+
+function sync_package_freeswitch_extensions()
+{
+
+ global $config;
+ if($config['installedpackages']['freeswitchextensions']['config'] != "") {
+
+ conf_mount_rw();
+ config_unlock();
+
+ /* delete all old extensions to prepare for new ones */
+ unlink_if_exists("/usr/local/freeswitch/conf/directory/default/1*.xml");
+ unlink_if_exists("/usr/local/freeswitch/conf/directory/default/2*.xml");
+ unlink_if_exists("/usr/local/freeswitch/conf/directory/default/3*.xml");
+ unlink_if_exists("/usr/local/freeswitch/conf/directory/default/4*.xml");
+ unlink_if_exists("/usr/local/freeswitch/conf/directory/default/5*.xml");
+ unlink_if_exists("/usr/local/freeswitch/conf/directory/default/6*.xml");
+ unlink_if_exists("/usr/local/freeswitch/conf/directory/default/7*.xml");
+ unlink_if_exists("/usr/local/freeswitch/conf/directory/default/8*.xml");
+ unlink_if_exists("/usr/local/freeswitch/conf/directory/default/9*.xml");
+
+ foreach($config['installedpackages']['freeswitchextensions']['config'] as $rowhelper) {
+
+ $fout = fopen("/usr/local/freeswitch/conf/directory/default/".$rowhelper['extension'].".xml","w");
+
+ $tmpxml = "<include>\n";
+ if (strlen($rowhelper['cidr']) == 0) {
+ $tmpxml .= " <user id=\"" . $rowhelper['extension'] . "\" mailbox=\"" . $rowhelper['mailbox'] . "\">\n";
+ }
+ else {
+ $tmpxml .= " <user id=\"" . $rowhelper['extension'] . "\" mailbox=\"" . $rowhelper['mailbox'] . "\" cidr=\"" . $rowhelper['cidr'] . "\">\n";
+ }
+ $tmpxml .= " <params>\n";
+ $tmpxml .= " <param name=\"password\" value=\"" . $rowhelper['password'] . "\"/>\n";
+ $tmpxml .= " <param name=\"vm-password\" value=\"" . $rowhelper['vm-password'] . "\"/>\n";
+ if (strlen($rowhelper['vm-mailto']) > 0) {
+ $tmpxml .= " <param name=\"vm-email-all-messages\" value=\"true\"/>\n";
+
+ switch ($rowhelper['vm-attach-file']) {
+ case "true":
+ $tmpxml .= " <param name=\"vm-attach-file\" value=\"true\"/>\n";
+ break;
+ case "false":
+ $tmpxml .= " <param name=\"vm-attach-file\" value=\"false\"/>\n";
+ break;
+ default:
+ $tmpxml .= " <param name=\"vm-attach-file\" value=\"true\"/>\n";
+ }
+
+ $tmpxml .= " <param name=\"vm-mailto\" value=\"" . $rowhelper['vm-mailto'] . "\"/>\n";
+ }
+ if (strlen($rowhelper['auth-acl']) > 0) {
+ $tmpxml .= " <param name=\"auth-acl\" value=\"" . $rowhelper['auth-acl'] . "\"/>\n";
+ }
+ $tmpxml .= " </params>\n";
+ $tmpxml .= " <variables>\n";
+ $tmpxml .= " <variable name=\"toll_allow\" value=\"domestic,international,local\"/>\n";
+ $tmpxml .= " <variable name=\"accountcode\" value=\"" . $rowhelper['accountcode'] . "\"/>\n";
+ $tmpxml .= " <variable name=\"user_context\" value=\"" . $rowhelper['user_context'] . "\"/>\n";
+ if (strlen($rowhelper['effective_caller_id_number']) > 0) {
+ $tmpxml .= " <variable name=\"effective_caller_id_name\" value=\"" . $rowhelper['effective_caller_id_name'] . "\"/>\n";
+ $tmpxml .= " <variable name=\"effective_caller_id_number\" value=\"" . $rowhelper['effective_caller_id_number'] . "\"/>\n";
+ }
+ if (strlen($rowhelper['outbound_caller_id_number']) > 0) {
+ $tmpxml .= " <variable name=\"outbound_caller_id_name\" value=\"" . $rowhelper['outbound_caller_id_name'] . "\"/>\n";
+ $tmpxml .= " <variable name=\"outbound_caller_id_number\" value=\"" . $rowhelper['outbound_caller_id_number'] . "\"/>\n";
+ }
+ $tmpxml .= " </variables>\n";
+ $tmpxml .= " </user>\n";
+ $tmpxml .= "</include>\n";
+ fwrite($fout, $tmpxml);
+ unset($tmpxml);
+ fclose($fout);
+ }
+
+ conf_mount_ro();
+ $cmd = "api reloadxml";
+ //event_socket_request_cmd($cmd);
+ unset($cmd);
+
+ }
+}
+
+
+function sync_package_freeswitch_gateways()
+{
+
+ global $config;
+ if($config['installedpackages']['freeswitchgateways']['config'] != "") {
+
+ conf_mount_rw();
+ config_unlock();
+
+ /* delete all old gateways to prepare for new ones */
+ unlink_if_exists("/usr/local/freeswitch/conf/sip_profiles/external/*.xml");
+
+ foreach($config['installedpackages']['freeswitchgateways']['config'] as $rowhelper) {
+
+ if ($rowhelper['enabled'] != "false") {
+ $fout = fopen("/usr/local/freeswitch/conf/sip_profiles/external/".$rowhelper['gateway'].".xml","w");
+
+ $tmpxml .= "<include>\n";
+ $tmpxml .= " <gateway name=\"" . $rowhelper['gateway'] . "\">\n";
+ if (strlen($rowhelper['username']) > 0) {
+ $tmpxml .= " <param name=\"username\" value=\"" . $rowhelper['username'] . "\"/>\n";
+ }
+ if (strlen($rowhelper['password']) > 0) {
+ $tmpxml .= " <param name=\"password\" value=\"" . $rowhelper['password'] . "\"/>\n";
+ }
+ if (strlen($rowhelper['realm']) > 0) {
+ $tmpxml .= " <param name=\"realm\" value=\"" . $rowhelper['realm'] . "\"/>\n";
+ }
+ if (strlen($rowhelper['from-user']) > 0) {
+ $tmpxml .= " <param name=\"from-user\" value=\"" . $rowhelper['from-user'] . "\"/>\n";
+ }
+ if (strlen($rowhelper['from-domain']) > 0) {
+ $tmpxml .= " <param name=\"from-domain\" value=\"" . $rowhelper['from-domain'] . "\"/>\n";
+ }
+ if (strlen($rowhelper['proxy']) > 0) {
+ $tmpxml .= " <param name=\"proxy\" value=\"" . $rowhelper['proxy'] . "\"/>\n";
+ }
+ if (strlen($rowhelper['expire-seconds']) > 0) {
+ $tmpxml .= " <param name=\"expire-seconds\" value=\"" . $rowhelper['expire-seconds'] . "\"/>\n";
+ }
+ if (strlen($rowhelper['register']) > 0) {
+ $tmpxml .= " <param name=\"register\" value=\"" . $rowhelper['register'] . "\"/>\n";
+ }
+ if (strlen($rowhelper['register-transport']) > 0) {
+ $tmpxml .= " <param name=\"register-transport\" value=\"" . $rowhelper['register-transport'] . "\"/>\n";
+ }
+ if (strlen($rowhelper['retry-seconds']) > 0) {
+ $tmpxml .= " <param name=\"retry-seconds\" value=\"" . $rowhelper['retry-seconds'] . "\"/>\n";
+ }
+ if (strlen($rowhelper['extension']) > 0) {
+ $tmpxml .= " <param name=\"extension\" value=\"" . $rowhelper['extension'] . "\"/>\n";
+ }
+ if (strlen($rowhelper['context']) > 0) {
+ $tmpxml .= " <param name=\"context\" value=\"" . $rowhelper['context'] . "\"/>\n";
+ }
+ if (strlen($rowhelper['caller-id-in-from']) > 0) {
+ $tmpxml .= " <param name=\"context\" value=\"" . $rowhelper['context'] . "\"/>\n";
+ }
+ if (strlen($rowhelper['supress-cng']) > 0) {
+ $tmpxml .= " <param name=\"context\" value=\"" . $rowhelper['context'] . "\"/>\n";
+ }
+
+ $tmpxml .= " </gateway>\n";
+ $tmpxml .= "</include>";
+
+ fwrite($fout, $tmpxml);
+ unset($tmpxml);
+ fclose($fout);
+ }
+
+ }
+
+ conf_mount_ro();
+ $cmd = "api sofia profile external restart reloadxml";
+ //event_socket_request_cmd($cmd);
+ unset($cmd);
+
+ }
+
+}
+
+
+function sync_package_freeswitch_modules()
+{
+
+ global $config;
+ conf_mount_rw();
+ config_unlock();
+
+ foreach($config['installedpackages']['freeswitchmodules']['config'] as $rowhelper) {
+ $fout = fopen("/usr/local/freeswitch/conf/autoload_configs/modules.conf.xml","w");
+
+ $tmpxml ="";
+ $tmpxml .= "<configuration name=\"modules.conf\" description=\"Modules\">\n";
+ $tmpxml .= " <modules>\n";
+ $tmpxml .= "\n";
+ $tmpxml .= " <!-- Loggers (I'd load these first) -->\n";
+ if ($rowhelper['mod_console'] == "enable"){ $tmpxml .= " <load module=\"mod_console\"/>\n"; }
+ if ($rowhelper['mod_logfile'] == "enable"){ $tmpxml .= " <load module=\"mod_logfile\"/>\n"; }
+ if ($rowhelper['mod_syslog'] == "enable"){ $tmpxml .= " <load module=\"mod_syslog\"/>\n"; }
+ $tmpxml .= "\n";
+ if ($rowhelper['mod_yaml'] == "enable"){ $tmpxml .= " <load module=\"mod_yaml\"/>\n"; }
+ $tmpxml .= "\n";
+ $tmpxml .= " <!-- Multi-Faceted -->\n";
+ $tmpxml .= " <!-- mod_enum is a dialplan interface, an application interface and an api command interface -->\n";
+ if ($rowhelper['mod_enum'] == "enable"){ $tmpxml .= " <load module=\"mod_enum\"/>\n"; }
+ $tmpxml .= "\n";
+ $tmpxml .= " <!-- XML Interfaces -->\n";
+ if ($rowhelper['mod_xml_rpc'] == "enable"){ $tmpxml .= " <load module=\"mod_xml_rpc\"/>\n"; }
+ if ($rowhelper['mod_xml_curl'] == "enable"){ $tmpxml .= " <load module=\"mod_xml_curl\"/>\n"; }
+ if ($rowhelper['mod_xml_cdr'] == "enable"){ $tmpxml .= " <load module=\"mod_xml_cdr\"/>\n"; }
+ $tmpxml .= "\n";
+ $tmpxml .= " <!-- Event Handlers -->\n";
+ if ($rowhelper['mod_cdr_csv'] == "enable"){ $tmpxml .= " <load module=\"mod_cdr_csv\"/>\n"; }
+ if ($rowhelper['mod_event_multicast'] == "enable"){ $tmpxml .= " <load module=\"mod_event_multicast\"/>\n"; }
+ if ($rowhelper['mod_event_socket'] == "enable"){ $tmpxml .= " <load module=\"mod_event_socket\"/>\n"; }
+ if ($rowhelper['mod_zeroconf'] == "enable"){ $tmpxml .= " <load module=\"mod_zeroconf\"/>\n"; }
+ $tmpxml .= "\n";
+ $tmpxml .= " <!-- Directory Interfaces -->\n";
+ if ($rowhelper['mod_ldap'] == "enable"){ $tmpxml .= " <load module=\"mod_ldap\"/>\n"; }
+ $tmpxml .= "\n";
+ $tmpxml .= " <!-- Endpoints -->\n";
+ if ($rowhelper['mod_dingaling'] == "enable"){ $tmpxml .= " <load module=\"mod_dingaling\"/>\n"; }
+ if ($rowhelper['mod_iax'] == "enable"){ $tmpxml .= " <load module=\"mod_iax\"/>\n"; }
+ if ($rowhelper['mod_portaudio'] == "enable"){ $tmpxml .= " <load module=\"mod_portaudio\"/>\n"; }
+ if ($rowhelper['mod_alsa'] == "enable"){ $tmpxml .= " <load module=\"mod_alsa\"/>\n"; }
+ if ($rowhelper['mod_sofia'] == "enable"){ $tmpxml .= " <load module=\"mod_sofia\"/>\n"; }
+ if ($rowhelper['mod_loopback'] == "enable"){ $tmpxml .= " <load module=\"mod_loopback\"/>\n"; }
+ if ($rowhelper['mod_wanpipe'] == "enable"){ $tmpxml .= " <load module=\"mod_wanpipe\"/>\n"; }
+ if ($rowhelper['mod_woomera'] == "enable"){ $tmpxml .= " <load module=\"mod_woomera\"/>\n"; }
+ if ($rowhelper['mod_openzap'] == "enable"){ $tmpxml .= " <load module=\"mod_openzap\"/>\n"; }
+ $tmpxml .= "\n";
+ $tmpxml .= " <!-- Applications -->\n";
+ if ($rowhelper['mod_commands'] == "enable"){ $tmpxml .= " <load module=\"mod_commands\"/>\n"; }
+ if ($rowhelper['mod_conference'] == "enable"){ $tmpxml .= " <load module=\"mod_conference\"/>\n"; }
+ if ($rowhelper['mod_dptools'] == "enable"){ $tmpxml .= " <load module=\"mod_dptools\"/>\n"; }
+ if ($rowhelper['mod_expr'] == "enable"){ $tmpxml .= " <load module=\"mod_expr\"/>\n"; }
+ if ($rowhelper['mod_fax'] == "enable"){ $tmpxml .= " <load module=\"mod_fax\"/>\n"; }
+ if ($rowhelper['mod_fifo'] == "enable"){ $tmpxml .= " <load module=\"mod_fifo\"/>\n"; }
+ if ($rowhelper['mod_voicemail'] == "enable"){ $tmpxml .= " <load module=\"mod_voicemail\"/>\n"; }
+ if ($rowhelper['mod_limit'] == "enable"){ $tmpxml .= " <load module=\"mod_limit\"/>\n"; }
+ if ($rowhelper['mod_esf'] == "enable"){ $tmpxml .= " <load module=\"mod_esf\"/>\n"; }
+ if ($rowhelper['mod_fsv'] == "enable"){ $tmpxml .= " <load module=\"mod_fsv\"/>\n"; }
+ $tmpxml .= "\n";
+ $tmpxml .= " <!-- SNOM Module -->\n";
+ if ($rowhelper['mod_snom'] == "enable"){ $tmpxml .= " <load module=\"mod_snom\"/>\n"; }
+ $tmpxml .= "\n";
+ $tmpxml .= " <!-- Dialplan Interfaces -->\n";
+ if ($rowhelper['mod_dialplan_directory'] == "enable"){ $tmpxml .= " <load module=\"mod_dialplan_directory\"/>\n"; }
+ if ($rowhelper['mod_dialplan_xml'] == "enable"){ $tmpxml .= " <load module=\"mod_dialplan_xml\"/>\n"; }
+ if ($rowhelper['mod_dialplan_asterisk'] == "enable"){ $tmpxml .= " <load module=\"mod_dialplan_asterisk\"/>\n"; }
+ $tmpxml .= "\n";
+ $tmpxml .= " <!-- Codec Interfaces -->\n";
+ if ($rowhelper['mod_voipcodecs'] == "enable"){ $tmpxml .= " <load module=\"mod_voipcodecs\"/>\n"; }
+ if ($rowhelper['mod_g723_1'] == "enable"){ $tmpxml .= " <load module=\"mod_g723_1\"/>\n"; }
+ if ($rowhelper['mod_g729'] == "enable"){ $tmpxml .= " <load module=\"mod_g729\"/>\n"; }
+ if ($rowhelper['mod_amr'] == "enable"){ $tmpxml .= " <load module=\"mod_amr\"/>\n"; }
+ if ($rowhelper['mod_ilbc'] == "enable"){ $tmpxml .= " <load module=\"mod_ilbc\"/>\n"; }
+ if ($rowhelper['mod_speex'] == "enable"){ $tmpxml .= " <load module=\"mod_speex\"/>\n"; }
+ if ($rowhelper['mod_siren'] == "enable"){ $tmpxml .= " <load module=\"mod_siren\"/>\n"; }
+ if ($rowhelper['mod_celt'] == "enable"){ $tmpxml .= " <load module=\"mod_celt\"/>\n"; }
+ if ($rowhelper['mod_h26x'] == "enable"){ $tmpxml .= " <load module=\"mod_h26x\"/>\n"; }
+ $tmpxml .= "\n";
+ $tmpxml .= " <!-- File Format Interfaces -->\n";
+ if ($rowhelper['mod_sndfile'] == "enable"){ $tmpxml .= " <load module=\"mod_sndfile\"/>\n"; }
+ if ($rowhelper['mod_native_file'] == "enable"){ $tmpxml .= " <load module=\"mod_native_file\"/>\n"; }
+ $tmpxml .= " <!--For icecast/mp3 streams/files-->\n";
+ if ($rowhelper['mod_shout'] == "enable"){ $tmpxml .= " <load module=\"mod_shout\"/>\n"; }
+ $tmpxml .= " <!--For local streams (play all the files in a directory)-->\n";
+ if ($rowhelper['mod_local_stream'] == "enable"){ $tmpxml .= " <load module=\"mod_local_stream\"/>\n"; }
+ if ($rowhelper['mod_tone_stream'] == "enable"){ $tmpxml .= " <load module=\"mod_tone_stream\"/>\n"; }
+ $tmpxml .= "\n";
+ $tmpxml .= " <!-- Timers -->\n";
+ $tmpxml .= "\n";
+ $tmpxml .= " <!-- Languages -->\n";
+ if ($rowhelper['mod_spidermonkey'] == "enable"){ $tmpxml .= " <load module=\"mod_spidermonkey\"/>\n"; }
+ if ($rowhelper['mod_perl'] == "enable"){ $tmpxml .= " <load module=\"mod_perl\"/>\n"; }
+ if ($rowhelper['mod_python'] == "enable"){ $tmpxml .= " <load module=\"mod_python\"/>\n"; }
+ if ($rowhelper['mod_java'] == "enable"){ $tmpxml .= " <load module=\"mod_java\"/>\n"; }
+ if ($rowhelper['mod_lua'] == "enable"){ $tmpxml .= " <load module=\"mod_lua\"/>\n"; }
+ $tmpxml .= "\n";
+ $tmpxml .= " <!-- ASR /TTS -->\n";
+ if ($rowhelper['mod_flite'] == "enable"){ $tmpxml .= " <load module=\"mod_flite\"/>\n"; }
+ if ($rowhelper['mod_pocketsphinx'] == "enable"){ $tmpxml .= " <load module=\"mod_pocketsphinx\"/>\n"; }
+ if ($rowhelper['mod_cepstral'] == "enable"){ $tmpxml .= " <load module=\"mod_cepstral\"/>\n"; }
+ if ($rowhelper['mod_openmrcp'] == "enable"){ $tmpxml .= " <load module=\"mod_openmrcp\"/>\n"; }
+ if ($rowhelper['mod_rss'] == "enable"){ $tmpxml .= " <load module=\"mod_rss\"/>\n"; }
+ $tmpxml .= "\n";
+ $tmpxml .= " <!-- Say -->\n";
+ if ($rowhelper['mod_say_en'] == "enable"){ $tmpxml .= " <load module=\"mod_say_en\"/>\n"; }
+ if ($rowhelper['mod_say_zh'] == "enable"){ $tmpxml .= " <load module=\"mod_say_zh\"/>\n"; }
+ $tmpxml .= " </modules>\n";
+ $tmpxml .= "</configuration>";
+
+ fwrite($fout, $tmpxml);
+ unset($tmpxml);
+ fclose($fout);
+ }
+
+ conf_mount_ro();
+ $cmd = "api reloadxml";
+ //event_socket_request_cmd($cmd);
+ unset($cmd);
+
+}
+
+
+function sync_package_freeswitch_public()
+{
+
+ global $config;
+ conf_mount_rw();
+ config_unlock();
+
+ if(strlen($config['installedpackages']['freeswitchpublic']['config'][0]['public_xml']) == 0) {
+ /* dialplan_public_xml not found in the pfsense config.xml get the default public.xml and save to config.xml. */
+ $filename = "/usr/local/freeswitch/conf/dialplan/public.xml";
+ $fout = fopen($filename,"r");
+ $tmpxml = fread($fout, filesize($filename));
+ $tmpxml = str_replace("<anti-action application=\"export\" data=\"domain_name=\${sip_req_host}\"/>", "<!--<anti-action application=\"export\" data=\"domain_name=\${sip_req_host}\"/>-->", $tmpxml);
+ $config['installedpackages']['freeswitchpublic']['config'][0]['public_xml'] = base64_encode($tmpxml);
+ unset($filename, $tmpxml);
+ fclose($fout);
+ }
+ else {
+ /* found dialplan_public_xml in the pfsense config.xml save it to public.xml. */
+ $fout = fopen("/usr/local/freeswitch/conf/dialplan/public.xml","w");
+ $tmpxml = $config['installedpackages']['freeswitchpublic']['config'][0]['public_xml'];
+ fwrite($fout, base64_decode($tmpxml));
+ fclose($fout);
+ unset($tmpxml);
+ }
+
+ conf_mount_ro();
+ //$cmd = "api reloadxml";
+ //event_socket_request_cmd($cmd);
+ unset($cmd);
+
+}
+
+
+function sync_package_freeswitch_vars()
+{
+
+ global $config;
+ conf_mount_rw();
+ config_unlock();
+
+ if(strlen($config['installedpackages']['freeswitchvars']['config'][0]['vars_xml']) == 0) {
+ /* dialplan not found in the pfsense config.xml get the default dialplan and save to config.xml. */
+ $filename = "/usr/local/freeswitch/conf/vars.xml";
+ $fout = fopen($filename,"r");
+ $tmpxml = fread($fout, filesize($filename));
+ $config['installedpackages']['freeswitchvars']['config'][0]['vars_xml'] = base64_encode($tmpxml);
+ unset($filename, $dialplan);
+ fclose($fout);
+ }
+ else {
+ /* found the dialplan in the pfsense config.xml save it to default.xml. */
+ $fout = fopen("/usr/local/freeswitch/conf/vars.xml","w");
+ $tmpxml = $config['installedpackages']['freeswitchvars']['config'][0]['vars_xml'];
+ fwrite($fout, base64_decode($tmpxml));
+ fclose($fout);
+ unset($tmpxml);
+ }
+
+ conf_mount_ro();
+ $cmd = "api reloadxml";
+ //event_socket_request_cmd($cmd);
+ unset($cmd);
+
+}
+
+
+function sync_package_freeswitch_internal()
+{
+ global $config;
+ conf_mount_rw();
+ config_unlock();
+
+ if(strlen($config['installedpackages']['freeswitchinternal']['config'][0]['internal_xml']) == 0) {
+ /* internal_xml not found in the pfsense config.xml get the internal.xml and save to config.xml. */
+ $filename = "/usr/local/freeswitch/conf/sip_profiles/internal.xml";
+ $fout = fopen($filename,"r");
+ $tmpxml = fread($fout, filesize($filename));
+ $config['installedpackages']['freeswitchinternal']['config'][0]['internal_xml'] = base64_encode($tmpxml);
+ unset($filename, $dialplan);
+ fclose($fout);
+ }
+ else {
+ /* found the internal_xml in the pfsense config.xml save it to internal.xml. */
+ $fout = fopen("/usr/local/freeswitch/conf/sip_profiles/internal.xml","w");
+ $tmpxml = $config['installedpackages']['freeswitchinternal']['config'][0]['internal_xml'];
+ fwrite($fout, base64_decode($tmpxml));
+ fclose($fout);
+ unset($tmpxml);
+ }
+
+ conf_mount_ro();
+ $cmd = "api reloadxml";
+ //event_socket_request_cmd($cmd);
+ unset($cmd);
+
+}
+
+
+function sync_package_freeswitch_external()
+{
+ global $config;
+ conf_mount_rw();
+ config_unlock();
+
+ if(strlen($config['installedpackages']['freeswitchexternal']['config'][0]['external_xml']) == 0) {
+ /* external_xml not found in the pfsense config.xml get the external.xml and save to config.xml. */
+ $filename = "/usr/local/freeswitch/conf/sip_profiles/external.xml";
+ $fout = fopen($filename,"r");
+ $tmpxml = fread($fout, filesize($filename));
+ $config['installedpackages']['freeswitchexternal']['config'][0]['external_xml'] = base64_encode($tmpxml);
+ unset($filename, $dialplan);
+ fclose($fout);
+ }
+ else {
+ /* found the external_xml in the pfsense config.xml save it to external.xml. */
+ $fout = fopen("/usr/local/freeswitch/conf/sip_profiles/external.xml","w");
+ $tmpxml = $config['installedpackages']['freeswitchexternal']['config'][0]['external_xml'];
+ fwrite($fout, base64_decode($tmpxml));
+ fclose($fout);
+ unset($tmpxml);
+ }
+
+ conf_mount_ro();
+ $cmd = "api reloadxml";
+ //event_socket_request_cmd($cmd);
+ unset($cmd);
+
+}
+
+
+function get_recording_filename($id)
+{
+ global $config;
+ $a_recordings = &$config['installedpackages']['freeswitchrecordings']['config'];
+ if (count($a_recordings) > 0) {
+ global $config;
+ foreach($a_recordings as $rowhelper) {
+ if ($rowhelper['recordingid'] == $id) {
+ return $rowhelper['filename'];
+ }
+ }
+ }
+}
+
+
+function sync_package_freeswitch_ivr()
+{
+
+ global $config;
+ conf_mount_rw();
+ config_lock();
+
+ $a_ivr = &$config['installedpackages']['freeswitchivr']['config'];
+ if (count($a_ivr) > 0) {
+ foreach($a_ivr as $rowhelper) {
+
+ /*
+ $rowhelper['ivrid']
+ $rowhelper['ivrextension']
+ $rowhelper['ivrname']
+ $rowhelper['recordingid']
+ $rowhelper['ivrtimeout']
+ $rowhelper['ivrcontext']
+ $rowhelper['ivrconditionjs']
+ $rowhelper['ivrdescr']
+ */
+
+ $a_dialplan_includes = &$config['installedpackages']['freeswitchdialplanincludes']['config'];
+ $a_dialplan_include_details = &$config['installedpackages']['freeswitchdialplanincludedetails']['config'];
+
+
+ //add the IVR to the dialplan
+ if (strlen($rowhelper['ivrid']) > 0) {
+ $action = 'add'; //set default action to add
+ $i = 0;
+ if (count($a_dialplan_includes) > 0) {
+ foreach($a_dialplan_includes as $row) {
+
+ //$row['dialplanincludeid'];
+ //$row['extensionname'];
+ //$row['context'];
+ //$row['enabled'];
+ //echo "if (".$row['opt1name']." == \"ivrid\" && ".$row['opt1value']." == ".$rowhelper['ivrid'].") {\n";
+
+ if ($row['opt1name'] == "ivrid" && $row['opt1value'] == $rowhelper['ivrid']) {
+ //update
+ $action = 'update';
+ $dialplanincludeid = $row['dialplanincludeid'];
+ $extensionname = $row['extensionname'];
+ $order = $row['order'];
+ $context = $row['context'];
+ $enabled = $row['enabled'];
+ $descr = $row['descr'];
+ $opt1name = $row['opt1name'];
+ $opt1value = $row['opt1value'];
+ $id = $i;
+ //echo "update".$i."<br />\n";
+
+ }
+ $i++;
+
+ }
+ }
+
+
+ $ent = array();
+ if ($action == 'add') {
+
+ $dialplanincludeid = guid();
+ $ent['dialplanincludeid'] = $dialplanincludeid;
+ $ent['extensionname'] = $rowhelper['ivrextension'];
+ $ent['order'] = '9001'; //if update use the existing order number and extension name and desc
+ $ent['context'] = $rowhelper['ivrcontext'];
+ $ent['enabled'] = 'true';
+ $ent['descr'] = 'IVR';
+ $ent['opt1name'] = 'ivrid';
+ $ent['opt1value'] = $rowhelper['ivrid'];
+
+ //add to the config
+ $a_dialplan_includes[] = $ent;
+ unset($ent);
+
+ $ent = array();
+ $ent['dialplanincludeid'] = $dialplanincludeid;
+ $ent['tag'] = 'condition'; //condition, action, antiaction
+ $ent['fieldtype'] = 'destination_number';
+ $ent['fielddata'] = '^'.$rowhelper['ivrextension'].'$';
+ $a_dialplan_include_details[] = $ent;
+ unset($ent);
+
+ $ivrid = str_replace(array("{", "}"), "", $rowhelper['ivrid']);
+
+ $ent = array();
+ $ent['dialplanincludeid'] = $dialplanincludeid;
+ $ent['tag'] = 'action'; //condition, action, antiaction
+ $ent['fieldtype'] = 'javascript';
+ $ent['fielddata'] = 'ivr_'.$ivrid.'.js';
+ $a_dialplan_include_details[] = $ent;
+ unset($ent);
+
+ unset($ivrid);
+
+ }
+ if ($action == 'update') {
+
+ $ent['dialplanincludeid'] = $dialplanincludeid;
+ $ent['extensionname'] = $rowhelper['ivrextension'];
+ $ent['order'] = $order;
+ $ent['context'] = $context;
+ $ent['enabled'] = $enabled;
+ $ent['descr'] = $descr;
+ $ent['opt1name'] = $opt1name;
+ $ent['opt1value'] = $opt1value;
+
+ //update the config
+ $a_dialplan_includes[$id] = $ent;
+
+ unset($ent);
+ unset($extensionname);
+ unset($order);
+ unset($context);
+ unset($enabled);
+ unset($descr);
+ unset($opt1name);
+ unset($opt1value);
+ unset($id);
+ }
+ write_config();
+
+ sync_package_freeswitch_dialplan_includes();
+ unset($dialplanincludeid);
+
+ } //end if strlen ivrid; add the IVR to the dialplan
+
+ // Build the IVR javascript
+ $recording_action_filename = get_recording_filename($rowhelper['recordingidaction']);
+ $recording_antiaction_filename = get_recording_filename($rowhelper['recordingidantiaction']);
+
+ $password = $config['installedpackages']['freeswitchsettings']['config'][0]['event_socket_password'];
+ $port = $config['installedpackages']['freeswitchsettings']['config'][0]['event_socket_port'];
+ $host = $config['interfaces']['lan']['ipaddr'];
+
+ if (pkg_is_service_running('freeswitch')) {
+ $fp = event_socket_create($host, $port, $password);
+ $cmd = "api global_getvar domain";
+ $domain = trim(event_socket_request($fp, $cmd));
+ }
+
+
+ $tmp = ""; //make sure the variable starts with no value
+ $tmp .= "\n";
+ $tmp .= " var condition = true;\n";
+ $tmp .= "\n";
+ $tmp .= " var domain = \"".$domain."\"; //by default this is the ipv4 address of FreeSWITCH used for transfer to voicemail\n";
+ $tmp .= " var digitmaxlength = 0;\n";
+ $tmp .= " var objdate = new Date();\n";
+ $tmp .= "\n";
+ $tmp .= " var adjusthours = 0; //Adjust Server time that is set to GMT 7 hours\n";
+ $tmp .= " var adjustoperator = \"-\"; //+ or -\n";
+ $tmp .= "\n";
+ $tmp .= " if (adjustoperator == \"-\") {\n";
+ $tmp .= " var objdate2 = new Date(objdate.getFullYear(),objdate.getMonth(),objdate.getDate(),(objdate.getHours() - adjusthours),objdate.getMinutes(),objdate.getSeconds());\n";
+ $tmp .= " }\n";
+ $tmp .= " if (adjustoperator == \"+\") {\n";
+ $tmp .= " var objdate2 = new Date(objdate.getFullYear(),objdate.getMonth(),objdate.getDate(),(objdate.getHours() + adjusthours),objdate.getMinutes(),objdate.getSeconds());\n";
+ $tmp .= " }\n";
+ $tmp .= "\n";
+ $tmp .= " var Hours = objdate2.getHours();\n";
+ $tmp .= " var Mins = objdate2.getMinutes();\n";
+ $tmp .= " var Seconds = objdate2.getSeconds();\n";
+ $tmp .= " var Month = objdate2.getMonth() + 1;\n";
+ $tmp .= " var Date = objdate2.getDate();\n";
+ $tmp .= " var Year = objdate2.getYear()\n";
+ $tmp .= " var Day = objdate2.getDay()+1;\n";
+ $tmp .= " var exit = false;\n";
+ $tmp .= "\n";
+ $tmp .= "//console_log( \"info\", \"IVR Server Time is: \"+Hours+\":\"+Mins+\" \\n\" );\n";
+ $tmp .= "\n";
+ $tmp .= " function mycb( session, type, obj, arg ) {\n";
+ $tmp .= " try {\n";
+ $tmp .= " if ( type == \"dtmf\" ) {\n";
+ $tmp .= " console_log( \"info\", \"digit: \"+obj.digit+\"\\n\" );\n";
+ $tmp .= " if ( obj.digit == \"#\" ) {\n";
+ $tmp .= " //console_log( \"info\", \"detected pound sign.\\n\" );\n";
+ $tmp .= " exit = true;\n";
+ $tmp .= " return( false );\n";
+ $tmp .= " }\n";
+ $tmp .= "\n";
+ $tmp .= " dtmf.digits += obj.digit;\n";
+ $tmp .= "\n";
+ $tmp .= " if ( dtmf.digits.length >= digitmaxlength ) {\n";
+ $tmp .= " exit = true;\n";
+ $tmp .= " return( false );\n";
+ $tmp .= " }\n";
+ $tmp .= " }\n";
+ $tmp .= " } catch (e) {\n";
+ $tmp .= " console_log( \"err\", e+\"\\n\" );\n";
+ $tmp .= " }\n";
+ $tmp .= " return( true );\n";
+ $tmp .= " } //end function mycb\n";
+
+ $tmp .= "\n";
+ $tmp .= base64_decode($rowhelper['ivrconditionjs']);
+ $tmp .= "\n";
+ $tmp .= "\n";
+
+ //$tmp .= " //condition = true; //debugging\n";
+
+ $actiondirect = false;
+ $actioncount = 0;
+ foreach($config['installedpackages']['freeswitchivroptions']['config'] as $row) {
+ //find the correct IVR options with the correct action
+ if ($row['ivrid'] == $rowhelper['ivrid']) {
+ if ($row['optionaction'] == "action") {
+ $actioncount++;
+ if (strtolower($row['optionnumber']) == "n") { //direct the call now don't wait for dtmf
+ $actiondirect = true;
+ $actiondirecttype = $row['optiontype'];
+ $actiondirectdest = $row['optiondest'];
+ }
+ }
+ }
+ }
+ //$tmp .= "action count: ".$actioncount."<br />\n";
+ if ($actioncount > 0) {
+ if ($actiondirect) {
+
+ $tmp .= " if (condition) {\n";
+ $tmp .= " //direct\n";
+ $tmp .= " //console_log( \"info\", \"action direct\\n\" );\n";
+ if ($actiondirecttype == "extension") {
+ $tmp .= " session.execute(\"transfer\", \"".$actiondirectdest." XML default\"); //".$actiondirectdest."\n";
+ }
+ if ($actiondirecttype == "voicemail") {
+ //$tmp .= " session.execute(\"voicemail\", \"".$actiondirectdest." XML default\");\n";
+ $tmp .= " session.execute(\"voicemail\", \"default \"+domain+\" ".$actiondirectdest."\");\n";
+ }
+ $tmp .= "}\n";
+
+ }
+ else {
+ $tmp .= " if (condition) {\n";
+ $tmp .= " //action\n";
+ $tmp .= "\n";
+ $tmp .= " //console_log( \"info\", \"action call now don't wait for dtmf\\n\" );\n";
+ $tmp .= " var dtmf = new Object( );\n";
+ $tmp .= " dtmf.digits = \"\";\n";
+ $tmp .= " if ( session.ready( ) ) {\n";
+ $tmp .= " session.answer( );\n";
+ $tmp .= "\n";
+ $tmp .= " digitmaxlength = 1;\n";
+ $tmp .= " while (session.ready() && ! exit ) {\n";
+ $tmp .= " //session.streamFile( \"C:/Program Files/FreeSWITCH/sounds/".$recording_action_filename."\", mycb, \"dtmf ".$rowhelper['ivrtimeout']."\" );\n";
+ $tmp .= " session.streamFile( \"/usr/local/freeswitch/recordings/".$recording_action_filename."\", mycb, \"dtmf ".$rowhelper['ivrtimeout']."\" );\n";
+ $tmp .= " if (session.ready()) {\n";
+ $tmp .= " if (dtmf.digits == 0) {\n";
+ $tmp .= " dtmf.digits += session.getDigits(1, \"#\", ".($rowhelper['ivrtimeout']*1000)."); // ".$rowhelper['ivrtimeout']." seconds\n";
+ $tmp .= " if (dtmf.digits == 0) {\n";
+ //$tmp .= " console_log( "info", "time out option: " + dtmf.digits + "\n" );\n";
+
+ $a_ivr_options = &$config['installedpackages']['freeswitchivroptions']['config'];
+ //find the timeout IVR options with the correct action
+ if (count($a_ivr_options) > 0) {
+ foreach($a_ivr_options as $row) {
+
+ if ($row['ivrid'] == $rowhelper['ivrid']) {
+
+ if ($row['optionaction'] == "action") {
+ if (strtolower($row['optionnumber']) == "t") {
+ if ($row['optiontype'] == "extension") {
+ $tmp .= " session.execute(\"transfer\", \"".$row['optiondest']." XML default\"); //".$row['optiondescr']."\n";
+ }
+ if ($row['optiontype'] == "voicemail") {
+ //$tmp .= " session.execute(\"voicemail\", \"".$row['optiondest']." XML default\");\n";
+ $tmp .= " session.execute(\"voicemail\", \"default \"+domain+\" ".$row['optiondest']."\");\n";
+ }
+ }
+ } //end anti-action
+
+ } //end ivrid
+
+ } //end for each
+ } //if count
+
+
+ $tmp .= " }\n";
+ $tmp .= " else {\n";
+ $tmp .= " break; //dtmf found end the while loop\n";
+ $tmp .= " }\n";
+ $tmp .= " }\n";
+ $tmp .= " }\n";
+ $tmp .= " }\n";
+ $tmp .= "\n";
+ $tmp .= " //pickup the remaining digits\n";
+ //$tmp .= " //http://wiki.freeswitch.org/wiki/Session_getDigits\n";
+ //$tmp .= " //getDigits(length, terminators, timeout, digit_timeout, abs_timeout)\n";
+ //$tmp .= " //dtmf.digits += session.getDigits(2, \"#\", 3000); //allow up to 3 digits\n";
+ $tmp .= " dtmf.digits += session.getDigits(3, \"#\", 3000); //allow up to 4 digits\n";
+ $tmp .= "\n";
+ $tmp .= "\n";
+ //$tmp .= " console_log( \"info\", \"IVR Digit Pressed: \" + dtmf.digits + \"\\n\" );\n";
+
+
+ //action
+ $tmpaction = "";
+
+ $tmp .= " if ( dtmf.digits.length > \"0\" ) {\n";
+ $x = 0;
+ $a_ivr_options = &$config['installedpackages']['freeswitchivroptions']['config'];
+ if (count($a_ivr_options) > 0) {
+ foreach($a_ivr_options as $row) {
+
+ /*
+ $row['ivrid']
+ $row['optionnumber']
+ $row['optiontype']
+ $row['optionaction']
+ $row['optiondest']
+ $row['optiondescr']
+ */
+
+ $tmpactiondefault = "";
+
+ //find the correct IVR options with the correct action
+ if ($row['ivrid'] == $rowhelper['ivrid']){
+
+ if ($row['optionaction'] == "action") {
+ //$tmpaction .= "\n";
+
+ switch ($row['optionnumber']) {
+ //case "t":
+
+ //if ($row['optiontype'] == "extension") {
+ // $tmpactiondefault .= " session.execute(\"transfer\", \"".$row['optiondest']." XML default\"); //".$row['optiondescr']."\n";
+ //}
+ //if ($row['optiontype'] == "voicemail") {
+ // //$tmpactiondefault .= " session.execute(\"voicemail\", \"".$row['optiondest']." XML default\");\n";
+ // $tmpactiondefault .= " session.execute(\"voicemail\", \"default \"+domain+\" ".$row['optiondest']."\");\n";
+ //}
+
+ //break;
+ default:
+ //$tmpaction .= " //console_log( \"info\", \"IVR Detected 1 digit \\n\" );\n";
+ if ($x == 0) {
+ $tmpaction .= " if ( dtmf.digits == \"".$row['optionnumber']."\" ) { //".$row['optiondescr']."\n";
+ }
+ else {
+ $tmpaction .= " else if ( dtmf.digits == \"".$row['optionnumber']."\" ) { //".$row['optiondescr']."\n";
+ }
+ if ($row['optiontype'] == "extension") {
+ $tmpaction .= " session.execute(\"transfer\", \"".$row['optiondest']." XML default\");\n";
+ }
+ if ($row['optiontype'] == "voicemail") {
+ //$tmpaction .= " session.execute(\"voicemail\", \"".$row['optiondest']." XML default\");\n";
+ $tmpaction .= " session.execute(\"voicemail\", \"default \"+domain+\" ".$row['optiondest']."\");\n";
+ }
+ $tmpaction .= " }\n";
+
+
+ }
+
+ $x++;
+ } //end if action
+
+ } //end ivrid
+
+
+ } //end foreach
+ } //end if count
+
+ $tmp .= $tmpaction;
+ $tmp .= " else {\n";
+ $tmp .= " session.execute(\"transfer\", dtmf.digits+\" XML default\");\n";
+ //$tmp .= $tmpactiondefault;
+ $tmp .= " }\n";
+ $tmp .= "\n";
+ unset($tmpaction);
+
+
+ $tmp .= " } \n";
+ //$tmp .= " else if ( dtmf.digits.length == \"3\" ) {\n";
+ //$tmp .= " //Transfer to the extension the caller chose\n";
+ //$tmp .= " session.execute(\"transfer\", dtmf.digits+\" XML default\");\n";
+ //$tmp .= " } else {\n";
+ //$tmp .= $tmpactiondefault;
+ //$tmp .= " }\n";
+ $tmp .= "\n";
+ $tmp .= " } //end if session.ready\n";
+ $tmp .= "\n";
+ $tmp .= " }\n"; //end if condition
+
+ } //if ($actiondirect) {
+ } //actioncount
+
+ $antiactiondirect = false;
+ $antiactioncount = 0;
+ foreach($config['installedpackages']['freeswitchivroptions']['config'] as $row) {
+ //find the correct IVR options with the correct action
+ if ($row['ivrid'] == $rowhelper['ivrid']) {
+ if ($row['optionaction'] == "anti-action") {
+ $antiactioncount++;
+ if (strtolower($row['optionnumber']) == "n") { //direct the call now don't wait for dtmf
+ $antiactiondirect = true;
+ $antiactiondirecttype = $row['optiontype'];
+ $antiactiondirectdest = $row['optiondest'];
+ }
+ }
+ }
+ }
+ //$tmp .= "anti-action count: ".$antiactioncount."<br />\n";
+
+
+ if ($antiactioncount > 0) {
+ if ($antiactiondirect) {
+ $tmp .= " else {\n";
+ $tmp .= " //anti-action direct\n";
+ $tmp .= " //console_log( \"info\", \"anti-action call now don't wait for dtmf\\n\" );\n";
+ if ($antiactiondirecttype == "extension") {
+ $tmp .= " session.execute(\"transfer\", \"".$antiactiondirectdest." XML default\"); //".$antiactiondirectdest."\n";
+ }
+ if ($antiactiondirecttype == "voicemail") {
+ //$tmp .= " session.execute(\"voicemail\", \"".$antiactiondirectdest." XML default\");\n";
+ $tmp .= " session.execute(\"voicemail\", \"default \"+domain+\" ".$antiactiondirectdest."\");\n";
+ }
+ $tmp .= "}\n";
+ }
+ else {
+ $tmp .= " else {\n";
+ $tmp .= " //anti-action\n";
+ $tmp .= " //console_log( \"info\", \"anti-action options\\n\" );\n";
+ $tmp .= "\n";
+ $tmp .= " var dtmf = new Object( );\n";
+ $tmp .= " dtmf.digits = \"\";\n";
+ $tmp .= " if ( session.ready( ) ) {\n";
+ $tmp .= " session.answer( );\n";
+ $tmp .= "\n";
+ $tmp .= " digitmaxlength = 1;\n";
+ $tmp .= " while (session.ready() && ! exit ) {\n";
+ $tmp .= " session.streamFile( \"/usr/local/freeswitch/recordings/".$recording_antiaction_filename."\", mycb, \"dtmf ".$rowhelper['ivrtimeout']."\" );\n";
+ $tmp .= " if (session.ready()) {\n";
+ $tmp .= " if (dtmf.digits == 0) {\n";
+ $tmp .= " dtmf.digits += session.getDigits(1, \"#\", ".($rowhelper['ivrtimeout']*1000)."); // ".$rowhelper['ivrtimeout']." seconds\n";
+ $tmp .= " if (dtmf.digits == 0) {\n";
+ //$tmp .= " console_log( "info", "time out option: " + dtmf.digits + "\n" );\n";
+
+
+ //find the timeout IVR options with the correct action
+ if (count($a_ivr_options) > 0) {
+ foreach($a_ivr_options as $row) {
+
+ if ($row['ivrid'] == $rowhelper['ivrid']) {
+
+ if ($row['optionaction'] == "anti-action") {
+ if (strtolower($row['optionnumber']) == "t") {
+
+ if ($row['optiontype'] == "extension") {
+ $tmp .= " session.execute(\"transfer\", \"".$row['optiondest']." XML default\"); //".$row['optiondescr']."\n";
+ }
+ if ($row['optiontype'] == "voicemail") {
+ //$tmp .= " session.execute(\"voicemail\", \"".$row['optiondest']." XML default\");\n";
+ $tmp .= " session.execute(\"voicemail\", \"default \"+domain+\" ".$row['optiondest']."\");\n";
+ }
+ }
+
+ } //end anti-action
+
+ } //end ivrid
+
+ } //end for each
+ } //if count
+
+
+ $tmp .= " }\n";
+ $tmp .= " else {\n";
+ $tmp .= " break; //dtmf found end the while loop\n";
+ $tmp .= " }\n";
+
+ $tmp .= " }\n";
+ $tmp .= " }\n";
+ $tmp .= " }\n";
+ $tmp .= "\n";
+ $tmp .= " //pickup the remaining digits\n";
+ $tmp .= " //http://wiki.freeswitch.org/wiki/Session_getDigits\n";
+ $tmp .= " //getDigits(length, terminators, timeout, digit_timeout, abs_timeout)\n";
+ $tmp .= " dtmf.digits += session.getDigits(3, \"#\", 3000);\n";
+ $tmp .= "\n";
+ $tmp .= " console_log( \"info\", \"IVR Digit Pressed: \" + dtmf.digits + \"\\n\" );\n";
+ $tmp .= "\n";
+
+
+
+
+
+ $tmpantiaction = "";
+ $tmp .= " if ( dtmf.digits.length > \"0\" ) {\n";
+
+ $x = 0;
+ if (count($a_ivr_options) > 0) {
+ foreach($a_ivr_options as $row) {
+
+ /*
+ $row['ivrid']
+ $row['optionnumber']
+ $row['optiontype']
+ $row['optionaction']
+ $row['optiondest']
+ $row['optiondescr']
+ */
+ //$tmpantiactiondefault = "";
+
+ //find the correct IVR options with the correct action
+ if ($row['ivrid'] == $rowhelper['ivrid']) {
+
+ if ($row['optionaction'] == "anti-action") {
+
+ switch ($row['optionnumber']) {
+ //case "t":
+
+ //if ($row['optiontype'] == "extension") {
+ // $tmpantiactiondefault .= " session.execute(\"transfer\", \"".$row['optiondest']." XML default\"); //".$row['optiondescr']."\n";
+ //}
+ //if ($row['optiontype'] == "voicemail") {
+ // //$tmpantiactiondefault .= " session.execute(\"voicemail\", \"".$row['optiondest']." XML default\");\n";
+ // $tmpantiactiondefault .= " session.execute(\"voicemail\", \"default \"+domain+\" ".$row['optiondest']."\");\n";
+ //}
+
+ //break;
+ default:
+ //$tmpantiaction .= " //console_log( \"info\", \"IVR Detected 1 digit \\n\" );\n";
+
+ if ($x == 0) {
+ $tmpantiaction .= " if ( dtmf.digits == \"".$row['optionnumber']."\" ) { //".$row['optiondescr']."\n";
+ }
+ else {
+ $tmpantiaction .= " else if ( dtmf.digits == \"".$row['optionnumber']."\" ) { //".$row['optiondescr']."\n";
+ }
+
+ if ($row['optiontype'] == "extension") {
+ $tmpantiaction .= " session.execute(\"transfer\", \"".$row['optiondest']." XML default\");\n";
+ }
+ if ($row['optiontype'] == "voicemail") {
+ //$tmpantiaction .= " session.execute(\"voicemail\", \"".$row['optiondest']." XML default\");\n";
+ $tmpantiaction .= " session.execute(\"voicemail\", \"default \"+domain+\" ".$row['optiondest']."\");\n";
+ }
+ $tmpantiaction .= " }\n";
+
+
+ } //end switch
+
+ $x++;
+ } //end anti-action
+
+ } //end ivrid
+
+
+ } //end for each
+ } //if count
+
+ $tmp .= $tmpantiaction;
+ $tmp .= " else {\n";
+ $tmp .= " session.execute(\"transfer\", dtmf.digits+\" XML default\");\n";
+ //$tmp .= $tmpantiactiondefault;
+ $tmp .= " }\n";
+ $tmp .= "\n";
+ unset($tmpantiaction);
+
+ $tmp .= " } \n";
+ //$tmp .= " else if ( dtmf.digits.length == \"3\" ) {\n";
+ //$tmp .= " //Transfer to the extension the caller chose\n";
+ //$tmp .= " session.execute(\"transfer\", dtmf.digits+\" XML default\"); \n";
+ //$tmp .= " }\n";
+ //$tmp .= " else {\n";
+ //$tmp .= $tmpantiactiondefault;
+ //$tmp .= " }\n";
+ $tmp .= "\n";
+ $tmp .= " } //end if session.ready\n";
+ $tmp .= "\n";
+ $tmp .= " } //end if condition";
+
+ } //if ($antiactiondirect) {
+ } //antiactioncount
+ unset($tmpactiondefault);
+ unset($tmpantiactiondefault);
+
+ if (strlen($rowhelper['ivrid']) > 0) {
+ $ivrfilename = "ivr_".str_replace(array("{", "}"), "", $rowhelper['ivrid']).".js";
+ $fout = fopen("/usr/local/freeswitch/scripts/".$ivrfilename,"w");
+ fwrite($fout, $tmp);
+ unset($ivrfilename);
+ fclose($fout);
+ }
+
+ } //end foreach
+ } //end if count
+ conf_mount_ro();
+ config_unlock();
+
+} //end function
+
+
+
+function sync_package_freeswitch_dialplan_includes()
+{
+
+ global $config;
+ conf_mount_rw();
+ config_lock();
+
+ $a_dialplan_includes = &$config['installedpackages']['freeswitchdialplanincludes']['config'];
+ $a_dialplan_include_details = &$config['installedpackages']['freeswitchdialplanincludedetails']['config'];
+
+ if (count($a_dialplan_includes) > 0) {
+ foreach($config['installedpackages']['freeswitchdialplanincludes']['config'] as $rowhelper) {
+ $tmp = "";
+ $tmp .= "\n";
+
+ //$rowhelper['dialplanincludeid'];
+ //$rowhelper['extensionname'];
+ //$rowhelper['context'];
+ //$rowhelper['enabled'];
+
+ $tmp = "<extension name=\"".$rowhelper['extensionname']."\">\n";
+
+ if (count($a_dialplan_include_details) > 0) {
+
+ $conditioncount = 0;
+ $i = 0;
+ foreach ($a_dialplan_include_details as $ent) {
+ if ($ent['tag'] == "condition" && $rowhelper['dialplanincludeid'] == $ent['dialplanincludeid']) {
+ $conditioncount++;
+ $i++;
+ }
+ }
+
+ $i = 1;
+ foreach ($a_dialplan_include_details as $ent) {
+ if ($ent['tag'] == "condition" && $rowhelper['dialplanincludeid'] == $ent['dialplanincludeid']) {
+ if ($conditioncount == 1) { //single condition
+ //start tag
+ $tmp .= " <condition field=\"".$ent['fieldtype']."\" expression=\"".$ent['fielddata']."\">\n";
+ }
+ else { //more than one condition
+ if ($i < $conditioncount) {
+ //all tags should be self-closing except the last one
+ $tmp .= " <condition field=\"".$ent['fieldtype']."\" expression=\"".$ent['fielddata']."\"/>\n";
+ }
+ else {
+ //for the last tag use the start tag
+ $tmp .= " <condition field=\"".$ent['fieldtype']."\" expression=\"".$ent['fielddata']."\">\n";
+ }
+ }
+ $i++;
+ }
+ } //end for each
+
+ } //end if count
+
+ if (count($a_dialplan_include_details) > 0) {
+ $i = 0;
+ foreach ($a_dialplan_include_details as $ent) {
+ if ($ent['tag'] == "action" && $rowhelper['dialplanincludeid'] == $ent['dialplanincludeid']) {
+ $tmp .= " <action application=\"".$ent['fieldtype']."\" data=\"".$ent['fielddata']."\"/>\n";
+ }
+ $i++;
+ }
+ }
+
+ if (count($a_dialplan_include_details) > 0) {
+ $i = 0;
+ foreach ($a_dialplan_include_details as $ent) {
+ if ($ent['tag'] == "anti-action" && $rowhelper['dialplanincludeid'] == $ent['dialplanincludeid']) {
+ $tmp .= " <anti-action application=\"".$ent['fieldtype']."\" data=\"".$ent['fielddata']."\"/>\n";
+ }
+ $i++;
+ }
+ }
+
+ //if (count($a_dialplan_include_details) > 0) {
+ //foreach ($a_dialplan_include_details as $ent) {
+ // $i = 0;
+ // if ($ent['tag'] == "param" && $rowhelper['dialplanincludeid'] == $ent['dialplanincludeid']) {
+ //$ent['tag']
+ //$ent['fieldtype']
+ //$ent['fielddata']
+ // }
+ // $i++;
+ // }
+ //}
+
+ if ($conditioncount > 0) {
+ $tmp .= " </condition>\n";
+ }
+ unset ($conditioncount);
+ $tmp .= "</extension>\n";
+
+
+ if ($rowhelper['enabled'] == "true") {
+ $dialplanincludefilename = $rowhelper['order']."_".$rowhelper['extensionname'].".xml";
+ $fout = fopen("/usr/local/freeswitch/conf/dialplan/default/".$dialplanincludefilename,"w");
+ fwrite($fout, $tmp);
+ fclose($fout);
+ }
+ unset($dialplanincludefilename);
+ unset($tmp);
+
+
+ } //end foreach
+ } //if array count
+
+ conf_mount_ro();
+ config_unlock();
+
+}
+
+
+function sync_package_freeswitch_public_includes()
+{
+
+ global $config;
+ conf_mount_rw();
+ config_lock();
+
+ $a_public_includes = &$config['installedpackages']['freeswitchpublicincludes']['config'];
+ $a_public_include_details = &$config['installedpackages']['freeswitchpublicincludedetails']['config'];
+
+ if (count($a_public_includes) > 0) {
+ foreach($a_public_includes as $rowhelper) {
+ $tmp = "";
+ $tmp .= "\n";
+
+ //$rowhelper['publicincludeid'];
+ //$rowhelper['extensionname'];
+ //$rowhelper['context'];
+ //$rowhelper['enabled'];
+
+ $tmp = "<extension name=\"".$rowhelper['extensionname']."\">\n";
+
+ if (count($a_public_include_details) > 0) {
+
+ $conditioncount = 0;
+ $i = 0;
+ foreach ($a_public_include_details as $ent) {
+ if ($ent['tag'] == "condition" && $rowhelper['publicincludeid'] == $ent['publicincludeid']) {
+ $conditioncount++;
+ $i++;
+ }
+ }
+
+ $i = 1;
+ foreach ($a_public_include_details as $ent) {
+ if ($ent['tag'] == "condition" && $rowhelper['publicincludeid'] == $ent['publicincludeid']) {
+ if ($conditioncount == 1) { //single condition
+ //start tag
+ $tmp .= " <condition field=\"".$ent['fieldtype']."\" expression=\"".$ent['fielddata']."\">\n";
+ }
+ else { //more than one condition
+ if ($i < $conditioncount) {
+ //all tags should be self-closing except the last one
+ $tmp .= " <condition field=\"".$ent['fieldtype']."\" expression=\"".$ent['fielddata']."\"/>\n";
+ }
+ else {
+ //for the last tag use the start tag
+ $tmp .= " <condition field=\"".$ent['fieldtype']."\" expression=\"".$ent['fielddata']."\">\n";
+ }
+ }
+ $i++;
+ }
+ } //end for each
+
+ } //end if count
+
+
+ if (count($a_public_include_details) > 0) {
+ $i = 0;
+ foreach ($a_public_include_details as $ent) {
+ if ($ent['tag'] == "action" && $rowhelper['publicincludeid'] == $ent['publicincludeid']) {
+ $tmp .= " <action application=\"".$ent['fieldtype']."\" data=\"".$ent['fielddata']."\"/>\n";
+ }
+ $i++;
+ }
+ }
+
+ if (count($a_public_include_details) > 0) {
+ $i = 0;
+ foreach ($a_public_include_details as $ent) {
+ if ($ent['tag'] == "anti-action" && $rowhelper['publicincludeid'] == $ent['publicincludeid']) {
+ $tmp .= " <anti-action application=\"".$ent['fieldtype']."\" data=\"".$ent['fielddata']."\"/>\n";
+ }
+ $i++;
+ }
+ }
+
+ //if (count($a_public_include_details) > 0) {
+ //foreach ($a_public_include_details as $ent) {
+ // $i = 0;
+ // if ($ent['tag'] == "param" && $rowhelper['publicincludeid'] == $ent['publicincludeid']) {
+ //$ent['tag']
+ //$ent['fieldtype']
+ //$ent['fielddata']
+ // }
+ // $i++;
+ // }
+ //}
+
+ if ($conditioncount > 0) {
+ $tmp .= " </condition>\n";
+ }
+ unset ($conditioncount);
+ $tmp .= "</extension>\n";
+
+
+ if ($rowhelper['enabled'] == "true") {
+ $publicincludefilename = $rowhelper['order']."_".$rowhelper['extensionname'].".xml";
+ $fout = fopen("/usr/local/freeswitch/conf/dialplan/public/".$publicincludefilename,"w");
+ fwrite($fout, $tmp);
+ fclose($fout);
+ }
+ unset($publicincludefilename);
+ unset($tmp);
+
+
+ } //end foreach
+ } //end if count
+ conf_mount_ro();
+ config_unlock();
+
+}
+
+
+function sync_package_freeswitch()
+{
+
+ global $config;
+ sync_package_freeswitch_settings();
+ sync_package_freeswitch_dialplan();
+ sync_package_freeswitch_dialplan_includes();
+ sync_package_freeswitch_extensions();
+ sync_package_freeswitch_gateways();
+ sync_package_freeswitch_modules();
+ sync_package_freeswitch_public();
+ sync_package_freeswitch_public_includes();
+ sync_package_freeswitch_vars();
+ sync_package_freeswitch_internal();
+ sync_package_freeswitch_external();
+ //sync_package_freeswitch_recordings();
+ if (pkg_is_service_running('freeswitch')) {
+ sync_package_freeswitch_ivr();
+ }
+
+}
+
+
+function freeswitch_php_install_command()
+{
+
+ global $config;
+ conf_mount_rw();
+ config_lock();
+
+ //needed for mod_fax support
+ system('pkg_add -r spandsp');
+
+ if (!is_dir('/usr/local/www/freeswitch/')) {
+ exec("mkdir /usr/local/www/freeswitch/");
+ }
+
+ exec("tar zxvf /tmp/freeswitch.tgz -C /usr/local/");
+ unlink_if_exists("/tmp/freeswitch.tgz");
+
+ //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");
+
+ //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");
+
+ exec("cp /tmp/begin_recording.wav /usr/local/freeswitch/recordings/begin_recording.wav");
+ unlink_if_exists("/tmp/begin_recording.wav");
+
+ 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");
+
+
+ //rename .so files from .1 to .so
+ exec("cp /tmp/mod_shout.so.1 /usr/local/freeswitch/mod/mod_shout.so");
+ unlink_if_exists("/tmp/mod_shout.so.tmp");
+
+ exec("cp /tmp/mod_fax.so.1 /usr/local/freeswitch/mod/mod_fax.so");
+ unlink_if_exists("/tmp/mod_shout.so.tmp");
+
+
+ //rename PHP files from .tmp to .php
+ exec("cp /tmp/class.smtp.tmp /usr/local/www/freeswitch/class.smtp.php");
+ unlink_if_exists("/tmp/class.smtp.tmp");
+
+ exec("cp /tmp/class.phpmailer.tmp /usr/local/www/freeswitch/class.phpmailer.php");
+ unlink_if_exists("/tmp/class.phpmailer.tmp");
+
+ exec("cp /tmp/freeswitch_cmd.tmp /usr/local/www/freeswitch/freeswitch_cmd.php");
+ unlink_if_exists("/tmp/freeswitch_cmd.tmp");
+
+ exec("cp /tmp/freeswitch_dialplan_includes_details.tmp /usr/local/www/freeswitch/freeswitch_dialplan_includes_details.php");
+ unlink_if_exists("/tmp/freeswitch_dialplan_includes_details.tmp");
+
+ exec("cp /tmp/freeswitch_dialplan_includes_details_edit.tmp /usr/local/www/freeswitch/freeswitch_dialplan_includes_details_edit.php");
+ unlink_if_exists("/tmp/freeswitch_dialplan_includes_details_edit.tmp");
+
+ exec("cp /tmp/freeswitch_dialplan_includes.tmp /usr/local/www/freeswitch/freeswitch_dialplan_includes.php");
+ unlink_if_exists("/tmp/freeswitch_dialplan_includes.tmp");
+
+ exec("cp /tmp/freeswitch_dialplan_includes_edit.tmp /usr/local/www/freeswitch/freeswitch_dialplan_includes_edit.php");
+ unlink_if_exists("/tmp/freeswitch_dialplan_includes_edit.tmp");
+
+ exec("cp /tmp/freeswitch_extensions.tmp /usr/local/www/freeswitch/freeswitch_extensions.php");
+ unlink_if_exists("/tmp/freeswitch_extensions.tmp");
+
+ exec("cp /tmp/freeswitch_extensions_edit.tmp /usr/local/www/freeswitch/freeswitch_extensions_edit.php");
+ unlink_if_exists("/tmp/freeswitch_extensions_edit.tmp");
+
+ exec("cp /tmp/freeswitch_gateways.tmp /usr/local/www/freeswitch/freeswitch_gateways.php");
+ unlink_if_exists("/tmp/freeswitch_gateways.tmp");
+
+ exec("cp /tmp/freeswitch_gateways_edit.tmp /usr/local/www/freeswitch/freeswitch_gateways_edit.php");
+ unlink_if_exists("/tmp/freeswitch_gateways_edit.tmp");
+
+ exec("cp /tmp/freeswitch_ivr.tmp /usr/local/www/freeswitch/freeswitch_ivr.php");
+ unlink_if_exists("/tmp/freeswitch_ivr.tmp");
+
+ exec("cp /tmp/freeswitch_ivr_edit.tmp /usr/local/www/freeswitch/freeswitch_ivr_edit.php");
+ unlink_if_exists("/tmp/freeswitch_ivr_edit.tmp");
+
+ exec("cp /tmp/freeswitch_ivr_options.tmp /usr/local/www/freeswitch/freeswitch_ivr_options.php");
+ unlink_if_exists("/tmp/freeswitch_ivr_options.tmp");
+
+ exec("cp /tmp/freeswitch_ivr_options_edit.tmp /usr/local/www/freeswitch/freeswitch_ivr_options_edit.php");
+ unlink_if_exists("/tmp/freeswitch_ivr_options_edit.tmp");
+
+ exec("cp /tmp/freeswitch_public_includes.tmp /usr/local/www/freeswitch/freeswitch_public_includes.php");
+ unlink_if_exists("/tmp/freeswitch_public_includes.tmp");
+
+ exec("cp /tmp/freeswitch_public_includes_edit.tmp /usr/local/www/freeswitch/freeswitch_public_includes_edit.php");
+ unlink_if_exists("/tmp/freeswitch_public_includes_edit.tmp");
+
+ exec("cp /tmp/freeswitch_public_includes_details.tmp /usr/local/www/freeswitch/freeswitch_public_includes_details.php");
+ unlink_if_exists("/tmp/freeswitch_public_includes_details.tmp");
+
+ exec("cp /tmp/freeswitch_public_includes_details_edit.tmp /usr/local/www/freeswitch/freeswitch_public_includes_details_edit.php");
+ unlink_if_exists("/tmp/freeswitch_public_includes_details_edit.tmp");
+
+ exec("cp /tmp/freeswitch_mailto.tmp /usr/local/www/freeswitch/freeswitch_mailto.php");
+ unlink_if_exists("/tmp/freeswitch_mailto.tmp");
+
+ exec("cp /tmp/freeswitch_recordings.tmp /usr/local/www/freeswitch/freeswitch_recordings.php");
+ unlink_if_exists("/tmp/freeswitch_recordings.tmp");
+
+ exec("cp /tmp/freeswitch_recordings_edit.tmp /usr/local/www/freeswitch/freeswitch_recordings_edit.php");
+ unlink_if_exists("/tmp/freeswitch_recordings_edit.tmp");
+
+ exec("cp /tmp/freeswitch_recordings_play.tmp /usr/local/www/freeswitch/freeswitch_recordings_play.php");
+ unlink_if_exists("/tmp/freeswitch_recordings_play.tmp");
+
+ exec("cp /tmp/freeswitch_status.tmp /usr/local/www/freeswitch/freeswitch_status.php");
+ unlink_if_exists("/tmp/freeswitch_status.tmp");
+
+ exec("cp /tmp/freeswitch_time_conditions.tmp /usr/local/www/freeswitch/freeswitch_time_conditions.php");
+ unlink_if_exists("/tmp/freeswitch_time_conditions.tmp");
+
+ 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 /usr/local/freeswitch/htdocs/slim.swf /usr/local/www/freeswitch/slim.swf");
+
+ /* freeswitch settings defaults */
+ if (strlen($config['installedpackages']['freeswitchsettings']['config'][0]['numbering_plan']) == 0) {
+ $config['installedpackages']['freeswitchsettings']['config'][0]['numbering_plan'] = "US";
+ }
+ if(strlen($config['installedpackages']['freeswitchsettings']['config'][0]['event_socket_password']) == 0) {
+ $config['installedpackages']['freeswitchsettings']['config'][0]['event_socket_password'] = "ClueCon";
+ }
+ if (strlen($config['installedpackages']['freeswitchsettings']['config'][0]['event_socket_port']) == 0) {
+ $config['installedpackages']['freeswitchsettings']['config'][0]['event_socket_port'] = "8021";
+ }
+ if (strlen($config['installedpackages']['freeswitchsettings']['config'][0]['xml_rpc_http_port']) == 0) {
+ $config['installedpackages']['freeswitchsettings']['config'][0]['xml_rpc_http_port'] = "8787";
+ }
+ if (strlen($config['installedpackages']['freeswitchsettings']['config'][0]['xml_rpc_auth_realm']) == 0) {
+ $config['installedpackages']['freeswitchsettings']['config'][0]['xml_rpc_auth_realm'] = "freeswitch";
+ }
+ if (strlen($config['installedpackages']['freeswitchsettings']['config'][0]['xml_rpc_auth_user']) == 0) {
+ $config['installedpackages']['freeswitchsettings']['config'][0]['xml_rpc_auth_user'] = "freeswitch";
+ }
+ if (strlen($config['installedpackages']['freeswitchsettings']['config'][0]['xml_rpc_auth_pass']) == 0) {
+ $config['installedpackages']['freeswitchsettings']['config'][0]['xml_rpc_auth_pass'] = "works";
+ }
+ if (strlen($config['installedpackages']['freeswitchsettings']['config'][0]['admin_pin']) == 0) {
+ $config['installedpackages']['freeswitchsettings']['config'][0]['admin_pin'] = "7575";
+ }
+
+ $numbering_plan = $config['installedpackages']['freeswitchsettings']['config'][0]['numbering_plan'];
+ $event_socket_password = $config['installedpackages']['freeswitchsettings']['config'][0]['event_socket_password'];
+ $event_socket_port = $config['installedpackages']['freeswitchsettings']['config'][0]['event_socket_port'];
+ $xml_rpc_http_port = $config['installedpackages']['freeswitchsettings']['config'][0]['xml_rpc_http_port'];
+ $xml_rpc_auth_realm = $config['installedpackages']['freeswitchsettings']['config'][0]['xml_rpc_auth_realm'];
+ $xml_rpc_auth_user = $config['installedpackages']['freeswitchsettings']['config'][0]['xml_rpc_auth_user'];
+ $xml_rpc_auth_pass = $config['installedpackages']['freeswitchsettings']['config'][0]['xml_rpc_auth_pass'];
+ $admin_pin = $config['installedpackages']['freeswitchsettings']['config'][0]['admin_pin'];
+
+ //write the recording.js script
+ recording_js();
+
+ //add recording.js to the dialplan
+ $a_dialplan_includes = &$config['installedpackages']['freeswitchdialplanincludes']['config'];
+ $a_dialplan_include_details = &$config['installedpackages']['freeswitchdialplanincludedetails']['config'];
+
+ //delete dialplan recording from the previous install
+ if (count($a_dialplan_includes) > 0) {
+ $i = 0;
+ foreach ($a_dialplan_includes as $ent) {
+ if ($ent['extensionname'] == "Recordings") {
+ unset($a_dialplan_includes[$i]);
+ }
+ $i++;
+ }
+ }
+
+ //delete the recording dialplan details
+ if (count($a_dialplan_include_details) > 0) {
+ $i = 0;
+ foreach ($a_dialplan_include_details as $ent) {
+ if ($ent['fielddata'] == "^732673$") {
+ unset($a_dialplan_include_details[$i]);
+ }
+ if ($ent['fielddata'] == "recordings.js") {
+ unset($a_dialplan_include_details[$i]);
+ }
+ $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);
+
+ write_config();
+
+ //prepare switch.conf.xml for voicemail to email
+ $filename = "/usr/local/freeswitch/conf/autoload_configs/switch.conf.xml";
+ $handle = fopen($filename,"rb");
+ $contents = fread($handle, filesize($filename));
+ fclose($handle);
+
+ $handle = fopen($filename,"w");
+ $contents = str_replace("<param name=\"mailer-app\" value=\"sendmail\"/>", "<param name=\"mailer-app\" value=\"/usr/local/bin/php\"/>", $contents);
+ $contents = str_replace("<param name=\"mailer-app-args\" value=\"-t\"/>", "<param name=\"mailer-app-args\" value=\"/usr/local/www/freeswitch/freeswitch_mailto.php\"/>", $contents);
+ fwrite($handle, $contents);
+ unset($contents);
+ fclose($fout);
+ unset($filename);
+
+ //prepare shout.conf.xml for mod_shout
+ $fout = fopen("/usr/local/freeswitch/conf/autoload_configs/shout.conf.xml","w");
+ $tmpxml = "<configuration name=\"shout.conf\" description=\"mod shout config\">\n";
+ $tmpxml .= " <settings>\n";
+ $tmpxml .= " <!-- Don't change these unless you are insane -->\n";
+ $tmpxml .= " <param name=\"decoder\" value=\"i586\"/>\n";
+ $tmpxml .= " <!--<param name=\"volume\" value=\".1\"/>-->\n";
+ $tmpxml .= " <!--<param name=\"outscale\" value=\"8192\"/>-->\n";
+ $tmpxml .= " </settings>\n";
+ $tmpxml .= "</configuration>";
+ fwrite($fout, $tmpxml);
+ unset($tmpxml);
+ fclose($fout);
+
+ $fout = fopen("/usr/local/freeswitch/conf/autoload_configs/event_socket.conf.xml","w");
+ $tmpxml = "<configuration name=\"event_socket.conf\" description=\"Socket Client\">\n";
+ $tmpxml .= " <settings>\n";
+ $tmpxml .= " <param name=\"listen-ip\" value=\"". $config['interfaces']['lan']['ipaddr'] ."\"/>\n";
+ $tmpxml .= " <param name=\"listen-port\" value=\"". $event_socket_port ."\"/>\n";
+ $tmpxml .= " <param name=\"password\" value=\"". $event_socket_password ."\"/>\n";
+ $tmpxml .= " <!--<param name=\"apply-inbound-acl\" value=\"lan\"/>-->\n";
+ $tmpxml .= " </settings>\n";
+ $tmpxml .= "</configuration>";
+ fwrite($fout, $tmpxml);
+ unset($tmpxml);
+ fclose($fout);
+
+ /* freeswitch modules defaults */
+
+ if (strlen($config['installedpackages']['freeswitchmodules']['config'][0]['mod_console']) == 0) {
+ $config['installedpackages']['freeswitchmodules']['config'][0]['mod_console'] = "enable";
+ }
+ if (strlen($config['installedpackages']['freeswitchmodules']['config'][0]['mod_logfile']) == 0) {
+ $config['installedpackages']['freeswitchmodules']['config'][0]['mod_logfile'] = "enable";
+ }
+ if (strlen($config['installedpackages']['freeswitchmodules']['config'][0]['mod_syslog']) == 0) {
+ $config['installedpackages']['freeswitchmodules']['config'][0]['mod_syslog'] = "disable";
+ }
+ if (strlen($config['installedpackages']['freeswitchmodules']['config'][0]['mod_yaml']) == 0) {
+ $config['installedpackages']['freeswitchmodules']['config'][0]['mod_yaml'] = "disable";
+ }
+ if (strlen($config['installedpackages']['freeswitchmodules']['config'][0]['mod_enum']) == 0) {
+ $config['installedpackages']['freeswitchmodules']['config'][0]['mod_enum'] = "enable";
+ }
+ if (strlen($config['installedpackages']['freeswitchmodules']['config'][0]['mod_xml_rpc']) == 0) {
+ $config['installedpackages']['freeswitchmodules']['config'][0]['mod_xml_rpc'] = "disable";
+ }
+ if (strlen($config['installedpackages']['freeswitchmodules']['config'][0]['mod_xml_curl']) == 0) {
+ $config['installedpackages']['freeswitchmodules']['config'][0]['mod_xml_curl'] = "disable";
+ }
+ if (strlen($config['installedpackages']['freeswitchmodules']['config'][0]['mod_xml_cdr']) == 0) {
+ $config['installedpackages']['freeswitchmodules']['config'][0]['mod_xml_cdr'] = "disable";
+ }
+ if (strlen($config['installedpackages']['freeswitchmodules']['config'][0]['mod_cdr_csv']) == 0) {
+ $config['installedpackages']['freeswitchmodules']['config'][0]['mod_cdr_csv'] = "enable";
+ }
+ if (strlen($config['installedpackages']['freeswitchmodules']['config'][0]['mod_event_multicast']) == 0) {
+ $config['installedpackages']['freeswitchmodules']['config'][0]['mod_event_multicast'] = "disable";
+ }
+ if (strlen($config['installedpackages']['freeswitchmodules']['config'][0]['mod_event_socket']) == 0) {
+ $config['installedpackages']['freeswitchmodules']['config'][0]['mod_event_socket'] = "enable";
+ }
+ if (strlen($config['installedpackages']['freeswitchmodules']['config'][0]['mod_zeroconf']) == 0) {
+ $config['installedpackages']['freeswitchmodules']['config'][0]['mod_zeroconf'] = "disable";
+ }
+ if (strlen($config['installedpackages']['freeswitchmodules']['config'][0]['mod_ldap']) == 0) {
+ $config['installedpackages']['freeswitchmodules']['config'][0]['mod_ldap'] = "disable";
+ }
+ if (strlen($config['installedpackages']['freeswitchmodules']['config'][0]['mod_dingaling']) == 0) {
+ $config['installedpackages']['freeswitchmodules']['config'][0]['mod_dingaling'] = "disable";
+ }
+ if (strlen($config['installedpackages']['freeswitchmodules']['config'][0]['mod_iax']) == 0) {
+ $config['installedpackages']['freeswitchmodules']['config'][0]['mod_iax'] = "disable";
+ }
+ if (strlen($config['installedpackages']['freeswitchmodules']['config'][0]['mod_portaudio']) == 0) {
+ $config['installedpackages']['freeswitchmodules']['config'][0]['mod_portaudio'] = "disable";
+ }
+ if (strlen($config['installedpackages']['freeswitchmodules']['config'][0]['mod_alsa']) == 0) {
+ $config['installedpackages']['freeswitchmodules']['config'][0]['mod_alsa'] = "disable";
+ }
+ if (strlen($config['installedpackages']['freeswitchmodules']['config'][0]['mod_sofia']) == 0) {
+ $config['installedpackages']['freeswitchmodules']['config'][0]['mod_sofia'] = "enable";
+ }
+ if (strlen($config['installedpackages']['freeswitchmodules']['config'][0]['mod_loopback']) == 0) {
+ $config['installedpackages']['freeswitchmodules']['config'][0]['mod_loopback'] = "enable";
+ }
+ if (strlen($config['installedpackages']['freeswitchmodules']['config'][0]['mod_wanpipe']) == 0) {
+ $config['installedpackages']['freeswitchmodules']['config'][0]['mod_wanpipe'] = "disable";
+ }
+ if (strlen($config['installedpackages']['freeswitchmodules']['config'][0]['mod_woomera']) == 0) {
+ $config['installedpackages']['freeswitchmodules']['config'][0]['mod_woomera'] = "disable";
+ }
+ if (strlen($config['installedpackages']['freeswitchmodules']['config'][0]['mod_openzap']) == 0) {
+ $config['installedpackages']['freeswitchmodules']['config'][0]['mod_openzap'] = "disable";
+ }
+ if (strlen($config['installedpackages']['freeswitchmodules']['config'][0]['mod_commands']) == 0) {
+ $config['installedpackages']['freeswitchmodules']['config'][0]['mod_commands'] = "enable";
+ }
+ if (strlen($config['installedpackages']['freeswitchmodules']['config'][0]['mod_conference']) == 0) {
+ $config['installedpackages']['freeswitchmodules']['config'][0]['mod_conference'] = "enable";
+ }
+ if (strlen($config['installedpackages']['freeswitchmodules']['config'][0]['mod_dptools']) == 0) {
+ $config['installedpackages']['freeswitchmodules']['config'][0]['mod_dptools'] = "enable";
+ }
+ if (strlen($config['installedpackages']['freeswitchmodules']['config'][0]['mod_expr']) == 0) {
+ $config['installedpackages']['freeswitchmodules']['config'][0]['mod_expr'] = "enable";
+ }
+ if (strlen($config['installedpackages']['freeswitchmodules']['config'][0]['mod_fax']) == 0) {
+ $config['installedpackages']['freeswitchmodules']['config'][0]['mod_fax'] = "enable";
+ }
+ if (strlen($config['installedpackages']['freeswitchmodules']['config'][0]['mod_fifo']) == 0) {
+ $config['installedpackages']['freeswitchmodules']['config'][0]['mod_fifo'] = "enable";
+ }
+ if (strlen($config['installedpackages']['freeswitchmodules']['config'][0]['mod_voicemail']) == 0) {
+ $config['installedpackages']['freeswitchmodules']['config'][0]['mod_voicemail'] = "enable";
+ }
+ if (strlen($config['installedpackages']['freeswitchmodules']['config'][0]['mod_limit']) == 0) {
+ $config['installedpackages']['freeswitchmodules']['config'][0]['mod_limit'] = "enable";
+ }
+ if (strlen($config['installedpackages']['freeswitchmodules']['config'][0]['mod_esf']) == 0) {
+ $config['installedpackages']['freeswitchmodules']['config'][0]['mod_esf'] = "enable";
+ }
+ if (strlen($config['installedpackages']['freeswitchmodules']['config'][0]['mod_fsv']) == 0) {
+ $config['installedpackages']['freeswitchmodules']['config'][0]['mod_fsv'] = "enable";
+ }
+ if (strlen($config['installedpackages']['freeswitchmodules']['config'][0]['mod_snom']) == 0) {
+ $config['installedpackages']['freeswitchmodules']['config'][0]['mod_snom'] = "disable";
+ }
+ if (strlen($config['installedpackages']['freeswitchmodules']['config'][0]['mod_dialplan_directory']) == 0) {
+ $config['installedpackages']['freeswitchmodules']['config'][0]['mod_dialplan_directory'] = "disable";
+ }
+ if (strlen($config['installedpackages']['freeswitchmodules']['config'][0]['mod_dialplan_xml']) == 0) {
+ $config['installedpackages']['freeswitchmodules']['config'][0]['mod_dialplan_xml'] = "enable";
+ }
+ if (strlen($config['installedpackages']['freeswitchmodules']['config'][0]['mod_dialplan_asterisk']) == 0) {
+ $config['installedpackages']['freeswitchmodules']['config'][0]['mod_dialplan_asterisk'] = "enable";
+ }
+ if (strlen($config['installedpackages']['freeswitchmodules']['config'][0]['mod_voipcodecs']) == 0) {
+ $config['installedpackages']['freeswitchmodules']['config'][0]['mod_voipcodecs'] = "enable";
+ }
+ if (strlen($config['installedpackages']['freeswitchmodules']['config'][0]['mod_g723_1']) == 0) {
+ $config['installedpackages']['freeswitchmodules']['config'][0]['mod_g723_1'] = "enable";
+ }
+ if (strlen($config['installedpackages']['freeswitchmodules']['config'][0]['mod_g729']) == 0) {
+ $config['installedpackages']['freeswitchmodules']['config'][0]['mod_g729'] = "enable";
+ }
+ if (strlen($config['installedpackages']['freeswitchmodules']['config'][0]['mod_amr']) == 0) {
+ $config['installedpackages']['freeswitchmodules']['config'][0]['mod_amr'] = "enable";
+ }
+ if (strlen($config['installedpackages']['freeswitchmodules']['config'][0]['mod_ilbc']) == 0) {
+ $config['installedpackages']['freeswitchmodules']['config'][0]['mod_ilbc'] = "enable";
+ }
+ if (strlen($config['installedpackages']['freeswitchmodules']['config'][0]['mod_speex']) == 0) {
+ $config['installedpackages']['freeswitchmodules']['config'][0]['mod_speex'] = "enable";
+ }
+ if (strlen($config['installedpackages']['freeswitchmodules']['config'][0]['mod_siren']) == 0) {
+ $config['installedpackages']['freeswitchmodules']['config'][0]['mod_siren'] = "enable";
+ }
+ if (strlen($config['installedpackages']['freeswitchmodules']['config'][0]['mod_celt']) == 0) {
+ $config['installedpackages']['freeswitchmodules']['config'][0]['mod_celt'] = "enable";
+ }
+ if (strlen($config['installedpackages']['freeswitchmodules']['config'][0]['mod_h26x']) == 0) {
+ $config['installedpackages']['freeswitchmodules']['config'][0]['mod_h26x'] = "enable";
+ }
+ if (strlen($config['installedpackages']['freeswitchmodules']['config'][0]['mod_sndfile']) == 0) {
+ $config['installedpackages']['freeswitchmodules']['config'][0]['mod_sndfile'] = "enable";
+ }
+ if (strlen($config['installedpackages']['freeswitchmodules']['config'][0]['mod_native_file']) == 0) {
+ $config['installedpackages']['freeswitchmodules']['config'][0]['mod_native_file'] = "enable";
+ }
+ if (strlen($config['installedpackages']['freeswitchmodules']['config'][0]['mod_shout']) == 0) {
+ $config['installedpackages']['freeswitchmodules']['config'][0]['mod_shout'] = "disable";
+ }
+ if (strlen($config['installedpackages']['freeswitchmodules']['config'][0]['mod_local_stream']) == 0) {
+ $config['installedpackages']['freeswitchmodules']['config'][0]['mod_local_stream'] = "enable";
+ }
+ if (strlen($config['installedpackages']['freeswitchmodules']['config'][0]['mod_tone_stream']) == 0) {
+ $config['installedpackages']['freeswitchmodules']['config'][0]['mod_tone_stream'] = "enable";
+ }
+ if (strlen($config['installedpackages']['freeswitchmodules']['config'][0]['mod_spidermonkey']) == 0) {
+ $config['installedpackages']['freeswitchmodules']['config'][0]['mod_spidermonkey'] = "enable";
+ }
+ if (strlen($config['installedpackages']['freeswitchmodules']['config'][0]['mod_perl']) == 0) {
+ $config['installedpackages']['freeswitchmodules']['config'][0]['mod_perl'] = "disable";
+ }
+ if (strlen($config['installedpackages']['freeswitchmodules']['config'][0]['mod_python']) == 0) {
+ $config['installedpackages']['freeswitchmodules']['config'][0]['mod_python'] = "disable";
+ }
+ if (strlen($config['installedpackages']['freeswitchmodules']['config'][0]['mod_java']) == 0) {
+ $config['installedpackages']['freeswitchmodules']['config'][0]['mod_java'] = "disable";
+ }
+ if (strlen($config['installedpackages']['freeswitchmodules']['config'][0]['mod_lua']) == 0) {
+ $config['installedpackages']['freeswitchmodules']['config'][0]['mod_lua'] = "enable";
+ }
+ if (strlen($config['installedpackages']['freeswitchmodules']['config'][0]['mod_flite']) == 0) {
+ $config['installedpackages']['freeswitchmodules']['config'][0]['mod_flite'] = "disable";
+ }
+ if (strlen($config['installedpackages']['freeswitchmodules']['config'][0]['mod_pocketsphinx']) == 0) {
+ $config['installedpackages']['freeswitchmodules']['config'][0]['mod_pocketsphinx'] = "disable";
+ }
+ if (strlen($config['installedpackages']['freeswitchmodules']['config'][0]['mod_cepstral']) == 0) {
+ $config['installedpackages']['freeswitchmodules']['config'][0]['mod_cepstral'] = "disable";
+ }
+ if (strlen($config['installedpackages']['freeswitchmodules']['config'][0]['mod_openmrcp']) == 0) {
+ $config['installedpackages']['freeswitchmodules']['config'][0]['mod_openmrcp'] = "disable";
+ }
+ if (strlen($config['installedpackages']['freeswitchmodules']['config'][0]['mod_rss']) == 0) {
+ $config['installedpackages']['freeswitchmodules']['config'][0]['mod_rss'] = "disable";
+ }
+ if (strlen($config['installedpackages']['freeswitchmodules']['config'][0]['mod_say_en']) == 0) {
+ $config['installedpackages']['freeswitchmodules']['config'][0]['mod_say_en'] = "enable";
+ }
+ if (strlen($config['installedpackages']['freeswitchmodules']['config'][0]['mod_say_zh']) == 0) {
+ $config['installedpackages']['freeswitchmodules']['config'][0]['mod_say_zh'] = "disable";
+ }
+
+ // if backup file exists restore it
+ $filename = 'freeswitch.bak.tgz';
+
+ //extract a specific directory to /usr/local/freeswitch
+ if (file_exists('/tmp/'.$filename)) {
+ //echo "The file $filename exists";
+
+ //Recommended
+ system('cd /usr/local; tar xvpfz /tmp/'.$filename.' freeswitch/db/');
+ system('cd /usr/local; tar xvpfz /tmp/'.$filename.' freeswitch/log/');
+ system('cd /usr/local; tar xvpfz /tmp/'.$filename.' freeswitch/recordings/');
+ system('cd /usr/local; tar xvpfz /tmp/'.$filename.' freeswitch/scripts/');
+ system('cd /usr/local; tar xvpfz /tmp/'.$filename.' freeswitch/storage/');
+ system('cd /usr/local; tar xvpfz /tmp/'.$filename.' freeswitch/sounds/music/8000/');
+ system('cd /usr/local; tar xvpfz /tmp/'.$filename.' freeswitch/conf/ssl');
+
+ //Optional
+ //system('cd /usr/local; tar xvpfz /tmp/'.$filename.' freeswitch/conf/');
+ //system('cd /usr/local; tar xvpfz /tmp/'.$filename.' freeswitch/grammar/');
+ //system('cd /usr/local; tar xvpfz /tmp/'.$filename.' freeswitch/htdocs/');
+
+ unset($filename);
+ }
+
+ write_rcfile(array(
+ "file" => "freeswitch.sh",
+ "start" => "/usr/local/freeswitch/bin/./freeswitch -nc",
+ "stop" => "/usr/local/freeswitch/bin/./freeswitch -stop"
+ )
+ );
+
+ exec("rm -R /freeswitch");
+ 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");
+
+ write_rcfile(array(
+ "file" => "freeswitch.sh",
+ "start" => "/usr/local/freeswitch/bin/./freeswitch -nc",
+ "stop" => "/usr/local/freeswitch/bin/./freeswitch -stop"
+ )
+ );
+
+ sync_package_freeswitch();
+ $handle = popen("/usr/local/etc/rc.d/freeswitch.sh start", "r");
+ pclose($handle);
+
+ if (pkg_is_service_running('freeswitch')) {
+ sync_package_freeswitch_ivr();
+ }
+
+ $config['installedpackages']['freeswitchsettings']['config'][0]['freeswitch_version'] = "1.0.2 revision 11245.";
+ $config['installedpackages']['freeswitchsettings']['config'][0]['freeswitch_package_version'] = "0.7";
+
+ conf_mount_ro();
+ config_unlock();
+
+}
+
+
+function freeswitch_deinstall_command()
+{
+
+ conf_mount_rw();
+ config_lock();
+ exec("killall -9 freeswitch");
+ unlink_if_exists("/usr/local/pkg/freeswitch.xml");
+ unlink_if_exists("/usr/local/pkg/freeswitch.inc");
+ unlink_if_exists("/usr/local/pkg/freeswitch_dialplan.xml");
+ unlink_if_exists("/usr/local/pkg/freeswitch_extensions.xml");
+ unlink_if_exists("/usr/local/pkg/freeswitch_external.xml");
+ unlink_if_exists("/usr/local/pkg/freeswitch_internal.xml");
+ unlink_if_exists("/usr/local/pkg/freeswitch_modules.xml");
+ unlink_if_exists("/usr/local/pkg/freeswitch_public.xml");
+ unlink_if_exists("/usr/local/pkg/freeswitch_vars.xml");
+
+ unlink_if_exists("/usr/local/www/freeswitch/class.smtp.php");
+ unlink_if_exists("/usr/local/www/freeswitch/class.phpmailer.php");
+ unlink_if_exists("/usr/local/www/freeswitch/freeswitch_cmd.php");
+ unlink_if_exists("/usr/local/www/freeswitch/freeswitch_dialplan_includes_details.php");
+ unlink_if_exists("/usr/local/www/freeswitch/freeswitch_dialplan_includes_edit.php");
+ unlink_if_exists("/usr/local/www/freeswitch/freeswitch_dialplan_includes.php");
+ unlink_if_exists("/usr/local/www/freeswitch/freeswitch_dialplan_includes_details_edit.php");
+ unlink_if_exists("/usr/local/www/freeswitch/freeswitch_extensions.php");
+ unlink_if_exists("/usr/local/www/freeswitch/freeswitch_extensions_edit.php");
+ unlink_if_exists("/usr/local/www/freeswitch/freeswitch_ivr.php");
+ unlink_if_exists("/usr/local/www/freeswitch/freeswitch_ivr_edit.php");
+ unlink_if_exists("/usr/local/www/freeswitch/freeswitch_ivr_options_edit.php");
+ unlink_if_exists("/usr/local/www/freeswitch/freeswitch_ivr_options.php");
+ unlink_if_exists("/usr/local/www/freeswitch/freeswitch_gateways.php");
+ unlink_if_exists("/usr/local/www/freeswitch/freeswitch_gateways_edit.php");
+ unlink_if_exists("/usr/local/www/freeswitch/freeswitch_mailto.php");
+ unlink_if_exists("/usr/local/www/freeswitch/freeswitch_public_includes_details.php");
+ unlink_if_exists("/usr/local/www/freeswitch/freeswitch_public_includes_edit.php");
+ unlink_if_exists("/usr/local/www/freeswitch/freeswitch_public_includes.php");
+ unlink_if_exists("/usr/local/www/freeswitch/freeswitch_public_includes_details_edit.php");
+ unlink_if_exists("/usr/local/www/freeswitch/freeswitch_recordings.php");
+ unlink_if_exists("/usr/local/www/freeswitch/freeswitch_recordings_edit.php");
+ unlink_if_exists("/usr/local/www/freeswitch/freeswitch_recordings_play.php");
+ unlink_if_exists("/usr/local/www/freeswitch/freeswitch_time_conditions.php");
+ unlink_if_exists("/usr/local/www/freeswitch/freeswitch_time_conditions_edit.php");
+ unlink_if_exists("/usr/local/www/freeswitch/freeswitch_status.php");
+ unlink_if_exists("/usr/local/www/freeswitch/slim.swf");
+
+ exec("rm -R /usr/local/freeswitch/");
+ exec("rm -R /usr/local/www/freeswitch/");
+ unlink_if_exists("/usr/local/etc/rc.d/freeswitch.sh");
+ unlink_if_exists("/tmp/freeswitch.tar.gz");
+ unlink_if_exists("/tmp/pkg_mgr_FreeSWITCH.log");
+ conf_mount_ro();
+ config_unlock();
+
+}
+
+?> \ No newline at end of file
diff --git a/config/freeswitch/freeswitch.xml b/config/freeswitch/freeswitch.xml
new file mode 100644
index 00000000..7c557c30
--- /dev/null
+++ b/config/freeswitch/freeswitch.xml
@@ -0,0 +1,477 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<!DOCTYPE packagegui SYSTEM "./schema/packages.dtd">
+<?xml-stylesheet type="text/xsl" href="./xsl/package.xsl"?>
+<packagegui>
+ <copyright>
+ <![CDATA[
+/* $Id$ */
+/* ========================================================================== */
+/*
+ freeswitch.xml
+ Copyright (C) 2008 Mark J Crane
+ All rights reserved.
+
+ FreeSWITCH (TM)
+ http://www.freeswitch.org/
+ */
+/* ========================================================================== */
+/*
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+ */
+/* ========================================================================== */
+ ]]>
+ </copyright>
+ <description>FreeSWITCH is an open source telephony platform designed to facilitate the creation of voice and chat driven products scaling from a soft-phone up to a soft-switch. It can be used as a simple switching engine, a PBX, a media gateway or a media server to host IVR applications using simple scripts or XML to control the callflow.</description>
+ <requirements>Describe your package requirements here</requirements>
+ <faq>Currently there are no FAQ items provided.</faq>
+ <name>FreeSWITCH Settings</name>
+ <version>0.7</version>
+ <title>FreeSWITCH: Settings</title>
+ <include_file>/usr/local/pkg/freeswitch.inc</include_file>
+ <menu>
+ <name>FreeSWITCH</name>
+ <tooltiptext>Modify FreeSWITCH settings.</tooltiptext>
+ <section>Services</section>
+ <configfile>freeswitch.xml</configfile>
+ <url>/pkg_edit.php?xml=freeswitch.xml&amp;id=0</url>
+ </menu>
+ <service>
+ <name>freeswitch</name>
+ <rcfile>freeswitch.sh</rcfile>
+ <executable>freeswitch</executable>
+ <description>FreeSWITCH is an open source telephony platform designed to facilitate the creation of voice and chat driven products scaling from a soft-phone up to a soft-switch. It can be used as a simple switching engine, a PBX, a media gateway or a media server to host IVR applications using simple scripts or XML to control the callflow. </description>
+ </service>
+ <tabs>
+ <tab>
+ <text>Settings</text>
+ <url>/pkg_edit.php?xml=freeswitch.xml&amp;id=0</url>
+ <active/>
+ </tab>
+ <tab>
+ <text>Dialplan</text>
+ <url>/freeswitch/freeswitch_dialplan_includes.php</url>
+ </tab>
+ <tab>
+ <text>Extensions</text>
+ <url>/freeswitch/freeswitch_extensions.php</url>
+ </tab>
+ <tab>
+ <text>External</text>
+ <url>/pkg_edit.php?xml=freeswitch_external.xml&amp;id=0</url>
+ </tab>
+ <tab>
+ <text>Gateways</text>
+ <url>/freeswitch/freeswitch_gateways.php</url>
+ </tab>
+ <tab>
+ <text>Internal</text>
+ <url>/pkg_edit.php?xml=freeswitch_internal.xml&amp;id=0</url>
+ </tab>
+ <tab>
+ <text>IVR</text>
+ <url>/freeswitch/freeswitch_ivr.php</url>
+ </tab>
+ <tab>
+ <text>Modules</text>
+ <url>/pkg_edit.php?xml=freeswitch_modules.xml&amp;id=0</url>
+ </tab>
+ <tab>
+ <text>Public</text>
+ <url>/freeswitch/freeswitch_public_includes.php</url>
+ </tab>
+ <tab>
+ <text>Rec</text>
+ <url>/freeswitch/freeswitch_recordings.php</url>
+ </tab>
+ <tab>
+ <text>Status</text>
+ <url>/freeswitch/freeswitch_status.php</url>
+ </tab>
+ <tab>
+ <text>Vars</text>
+ <url>/pkg_edit.php?xml=freeswitch_vars.xml&amp;id=0</url>
+ </tab>
+ </tabs>
+ <configpath>installedpackages->package->$packagename->configuration->freeswitchsettings</configpath>
+ <additional_files_needed>
+ <prefix>/tmp/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.portableusbapps.com/packages/config/freeswitch/freeswitch.tgz</item>
+ </additional_files_needed>
+ <additional_files_needed>
+ <prefix>/usr/local/pkg/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.com/packages/config/freeswitch/freeswitch.inc</item>
+ </additional_files_needed>
+ <additional_files_needed>
+ <prefix>/usr/local/lib/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.com/packages/config/freeswitch/libtinfo.so.5.6</item>
+ </additional_files_needed>
+ <additional_files_needed>
+ <prefix>/usr/local/lib/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.com/packages/config/freeswitch/libncurses.so.5.6</item>
+ </additional_files_needed>
+ <additional_files_needed>
+ <prefix>/usr/local/lib/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.com/packages/config/freeswitch/libogg.so.5.3</item>
+ </additional_files_needed>
+ <additional_files_needed>
+ <prefix>/usr/local/lib/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.com/packages/config/freeswitch/libvorbis.so.4</item>
+ </additional_files_needed>
+ <additional_files_needed>
+ <prefix>/tmp/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.com/packages/config/freeswitch/mod_shout.so.1</item>
+ </additional_files_needed>
+ <additional_files_needed>
+ <prefix>/tmp/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.com/packages/config/freeswitch/mod_fax.so.1</item>
+ </additional_files_needed>
+ <additional_files_needed>
+ <prefix>/usr/local/lib/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.com/packages/config/freeswitch/libspandsp.so.1</item>
+ </additional_files_needed>
+ <additional_files_needed>
+ <prefix>/tmp/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.com/packages/config/freeswitch/please_enter_your_pin_number.wav</item>
+ </additional_files_needed>
+ <additional_files_needed>
+ <prefix>/tmp/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.com/packages/config/freeswitch/begin_recording.wav</item>
+ </additional_files_needed>
+ <additional_files_needed>
+ <prefix>/tmp/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.com/packages/config/freeswitch/your_pin_number_is_incorect_goodbye.wav</item>
+ </additional_files_needed>
+ <additional_files_needed>
+ <prefix>/tmp/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.com/packages/config/freeswitch/class.smtp.tmp</item>
+ </additional_files_needed>
+ <additional_files_needed>
+ <prefix>/tmp/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.com/packages/config/freeswitch/class.phpmailer.tmp</item>
+ </additional_files_needed>
+ <additional_files_needed>
+ <prefix>/tmp/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.com/packages/config/freeswitch/freeswitch_cmd.tmp</item>
+ </additional_files_needed>
+ <additional_files_needed>
+ <prefix>/usr/local/pkg/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.com/packages/config/freeswitch/freeswitch_dialplan.xml</item>
+ </additional_files_needed>
+ <additional_files_needed>
+ <prefix>/tmp/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.com/packages/config/freeswitch/freeswitch_dialplan_includes.tmp</item>
+ </additional_files_needed>
+ <additional_files_needed>
+ <prefix>/tmp/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.com/packages/config/freeswitch/freeswitch_dialplan_includes_edit.tmp</item>
+ </additional_files_needed>
+ <additional_files_needed>
+ <prefix>/tmp/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.com/packages/config/freeswitch/freeswitch_dialplan_includes_details.tmp</item>
+ </additional_files_needed>
+ <additional_files_needed>
+ <prefix>/tmp/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.com/packages/config/freeswitch/freeswitch_dialplan_includes_details_edit.tmp</item>
+ </additional_files_needed>
+ <additional_files_needed>
+ <prefix>/tmp/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.com/packages/config/freeswitch/freeswitch_extensions.tmp</item>
+ </additional_files_needed>
+ <additional_files_needed>
+ <prefix>/tmp/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.com/packages/config/freeswitch/freeswitch_extensions_edit.tmp</item>
+ </additional_files_needed>
+ <additional_files_needed>
+ <prefix>/usr/local/pkg/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.com/packages/config/freeswitch/freeswitch_external.xml</item>
+ </additional_files_needed>
+ <additional_files_needed>
+ <prefix>/tmp/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.com/packages/config/freeswitch/freeswitch_gateways.tmp</item>
+ </additional_files_needed>
+ <additional_files_needed>
+ <prefix>/tmp/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.com/packages/config/freeswitch/freeswitch_gateways_edit.tmp</item>
+ </additional_files_needed>
+ <additional_files_needed>
+ <prefix>/usr/local/pkg/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.com/packages/config/freeswitch/freeswitch_internal.xml</item>
+ </additional_files_needed>
+ <additional_files_needed>
+ <prefix>/tmp/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.com/packages/config/freeswitch/freeswitch_ivr.tmp</item>
+ </additional_files_needed>
+ <additional_files_needed>
+ <prefix>/tmp/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.com/packages/config/freeswitch/freeswitch_ivr_edit.tmp</item>
+ </additional_files_needed>
+ <additional_files_needed>
+ <prefix>/tmp/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.com/packages/config/freeswitch/freeswitch_ivr_options_edit.tmp</item>
+ </additional_files_needed>
+ <additional_files_needed>
+ <prefix>/tmp/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.com/packages/config/freeswitch/freeswitch_ivr_options.tmp</item>
+ </additional_files_needed>
+ <additional_files_needed>
+ <prefix>/tmp/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.com/packages/config/freeswitch/freeswitch_mailto.tmp</item>
+ </additional_files_needed>
+ <additional_files_needed>
+ <prefix>/usr/local/pkg/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.com/packages/config/freeswitch/freeswitch_modules.xml</item>
+ </additional_files_needed>
+ <additional_files_needed>
+ <prefix>/usr/local/pkg/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.com/packages/config/freeswitch/freeswitch_public.xml</item>
+ </additional_files_needed>
+ <additional_files_needed>
+ <prefix>/tmp/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.com/packages/config/freeswitch/freeswitch_public_includes.tmp</item>
+ </additional_files_needed>
+ <additional_files_needed>
+ <prefix>/tmp/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.com/packages/config/freeswitch/freeswitch_public_includes_edit.tmp</item>
+ </additional_files_needed>
+ <additional_files_needed>
+ <prefix>/tmp/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.com/packages/config/freeswitch/freeswitch_public_includes_details.tmp</item>
+ </additional_files_needed>
+ <additional_files_needed>
+ <prefix>/tmp/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.com/packages/config/freeswitch/freeswitch_public_includes_details_edit.tmp</item>
+ </additional_files_needed>
+ <additional_files_needed>
+ <prefix>/tmp/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.com/packages/config/freeswitch/freeswitch_recordings.tmp</item>
+ </additional_files_needed>
+ <additional_files_needed>
+ <prefix>/tmp/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.com/packages/config/freeswitch/freeswitch_recordings_edit.tmp</item>
+ </additional_files_needed>
+ <additional_files_needed>
+ <prefix>/tmp/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.com/packages/config/freeswitch/freeswitch_recordings_play.tmp</item>
+ </additional_files_needed>
+ <additional_files_needed>
+ <prefix>/tmp/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.com/packages/config/freeswitch/freeswitch_status.tmp</item>
+ </additional_files_needed>
+ <additional_files_needed>
+ <prefix>/tmp/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.com/packages/config/freeswitch/freeswitch_time_conditions.tmp</item>
+ </additional_files_needed>
+ <additional_files_needed>
+ <prefix>/tmp/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.com/packages/config/freeswitch/freeswitch_time_conditions_edit.tmp</item>
+ </additional_files_needed>
+ <additional_files_needed>
+ <prefix>/usr/local/pkg/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.com/packages/config/freeswitch/freeswitch_vars.xml</item>
+ </additional_files_needed>
+ <fields>
+ <field>
+ <fielddescr>Numbering Plan</fielddescr>
+ <fieldname>numbering_plan</fieldname>
+ <description>Enter the numbering plan here. example: US</description>
+ <type>input</type>
+ </field>
+ <field>
+ <fielddescr>Default Gateway</fielddescr>
+ <fieldname>default_gateway</fieldname>
+ <description>Enter the default gateway name here. example: asterlink.com</description>
+ <type>input</type>
+ </field>
+ <field>
+ <fielddescr>Default Area Code</fielddescr>
+ <fieldname>default_area_code</fieldname>
+ <description>Enter the area code here. example: 918</description>
+ <type>input</type>
+ </field>
+ <field>
+ <fielddescr>Event Socket Port</fielddescr>
+ <fieldname>event_socket_port</fieldname>
+ <description>Enter the event socket port here. default: 8021</description>
+ <type>input</type>
+ </field>
+ <field>
+ <fielddescr>Event Socket Password</fielddescr>
+ <fieldname>event_socket_password</fieldname>
+ <description>Enter the event socket password here. default: ClueCon</description>
+ <type>password</type>
+ </field>
+ <field>
+ <fielddescr>XML RPC HTTP Port</fielddescr>
+ <fieldname>xml_rpc_http_port</fieldname>
+ <description>Enter the XML RPC HTTP Port here. default: 8787</description>
+ <type>input</type>
+ </field>
+ <field>
+ <fielddescr>XML RPC Auth Realm</fielddescr>
+ <fieldname>xml_rpc_auth_realm</fieldname>
+ <description>Enter the XML RPC Auth Realm here. default: freeswitch</description>
+ <type>input</type>
+ </field>
+ <field>
+ <fielddescr>XML RPC Auth User</fielddescr>
+ <fieldname>xml_rpc_auth_user</fieldname>
+ <description>Enter the XML RPC Auth User here. default: freeswitch</description>
+ <type>input</type>
+ </field>
+ <field>
+ <fielddescr>XML RPC Auth Password</fielddescr>
+ <fieldname>xml_rpc_auth_pass</fieldname>
+ <description>Enter the XML RPC Auth Password here. default: works</description>
+ <type>password</type>
+ </field>
+ <field>
+ <fielddescr>Admin PIN Number</fielddescr>
+ <fieldname>admin_pin</fieldname>
+ <description>Enter a admin pin number. Used to authenticate the admin from the phone.</description>
+ <type>password</type>
+ </field>
+ <field>
+ <fielddescr>SMTP Host</fielddescr>
+ <fieldname>smtphost</fieldname>
+ <description>Enter the SMTP host address. If you using a different port append it on the end with a semi-colon. e.g. smtp.gmail.com:465</description>
+ <type>input</type>
+ </field>
+ <field>
+ <fielddescr>SMTP Secure</fielddescr>
+ <fieldname>smtpsecure</fieldname>
+ <description>Select the SMTP security. None, TLS, SSL</description>
+ <type>select</type>
+ <options>
+ <option>
+ <name>none</name>
+ <value></value>
+ </option>
+ <option>
+ <name>tls</name>
+ <value>tls</value>
+ </option>
+ <option>
+ <name>ssl</name>
+ <value>ssl</value>
+ </option>
+ </options>
+ </field>
+ <field>
+ <fielddescr>SMTP Auth</fielddescr>
+ <fieldname>smtpauth</fieldname>
+ <description>Use SMTP Authentication true or false.</description>
+ <type>select</type>
+ <options>
+ <option>
+ <name>true</name>
+ <value>true</value>
+ </option>
+ <option>
+ <name>false</name>
+ <value>false</value>
+ </option>
+ </options>
+ </field>
+ <field>
+ <fielddescr>SMTP Username</fielddescr>
+ <fieldname>smtpusername</fieldname>
+ <description>Enter the SMTP authentication username.</description>
+ <type>input</type>
+ </field>
+ <field>
+ <fielddescr>SMTP Password</fielddescr>
+ <fieldname>smtppassword</fieldname>
+ <description>Enter the SMTP authentication password.</description>
+ <type>password</type>
+ </field>
+ <field>
+ <fielddescr>SMTP From</fielddescr>
+ <fieldname>smtpfrom</fieldname>
+ <description>Enter the SMTP From email address.</description>
+ <type>input</type>
+ </field>
+ <field>
+ <fielddescr>SMTP From Name</fielddescr>
+ <fieldname>smtpfromname</fieldname>
+ <description>Enter the SMTP From Name.</description>
+ <type>input</type>
+ </field>
+ </fields>
+ <custom_add_php_command>
+ </custom_add_php_command>
+ <custom_php_resync_config_command>
+ sync_package_freeswitch_settings();
+ </custom_php_resync_config_command>
+ <custom_delete_php_command>
+ sync_package_freeswitch_settings();
+ </custom_delete_php_command>
+ <custom_php_install_command>
+ freeswitch_php_install_command();
+ </custom_php_install_command>
+ <custom_php_deinstall_command>
+ freeswitch_deinstall_command();
+ </custom_php_deinstall_command>
+</packagegui> \ No newline at end of file
diff --git a/config/freeswitch/freeswitch_cmd.tmp b/config/freeswitch/freeswitch_cmd.tmp
new file mode 100644
index 00000000..05ae77cf
--- /dev/null
+++ b/config/freeswitch/freeswitch_cmd.tmp
@@ -0,0 +1,49 @@
+<?php
+/* $Id$ */
+/*
+ freeswitch_cmd.php
+ Copyright (C) 2008 Mark J Crane
+ All rights reserved.
+
+ FreeSWITCH (TM)
+ http://www.freeswitch.org/
+
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+require("guiconfig.inc");
+require("/usr/local/pkg/freeswitch.inc");
+$cmd = $_GET['cmd'];
+
+
+$password = $config['installedpackages']['freeswitchsettings']['config'][0]['event_socket_password'];
+$port = $config['installedpackages']['freeswitchsettings']['config'][0]['event_socket_port'];
+$host = '';
+
+$fp = event_socket_create($host, $port, $password);
+$response = event_socket_request($fp, $cmd);
+fclose($fp);
+
+header("Location: /freeswitch/freeswitch_status.php?savemsg=".urlencode($response));
+
+?> \ No newline at end of file
diff --git a/config/freeswitch/freeswitch_dialplan.xml b/config/freeswitch/freeswitch_dialplan.xml
new file mode 100644
index 00000000..3ce35570
--- /dev/null
+++ b/config/freeswitch/freeswitch_dialplan.xml
@@ -0,0 +1,136 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<!DOCTYPE packagegui SYSTEM "./schema/packages.dtd">
+<packagegui>
+ <copyright>
+ <![CDATA[
+/* $Id$ */
+/* ========================================================================== */
+/*
+ freeswitch_dialplan.xml
+ Copyright (C) 2008 Mark J Crane
+ All rights reserved.
+
+ FreeSWITCH (TM)
+ http://www.freeswitch.org/
+
+
+ part of pfSense (http://www.pfSense.com)
+ Copyright (C) 2007 to whom it may belong
+ All rights reserved.
+
+ Based on m0n0wall (http://m0n0.ch/wall)
+ Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>.
+ All rights reserved.
+ */
+/* ========================================================================== */
+/*
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+ */
+/* ========================================================================== */
+ ]]>
+ </copyright>
+ <description>FreeSWITCH is an open source telephony platform designed to facilitate the creation of voice and chat driven products scaling from a soft-phone up to a soft-switch. It can be used as a simple switching engine, a PBX, a media gateway or a media server to host IVR applications using simple scripts or XML to control the callflow.</description>
+ <requirements>Describe your package requirements here</requirements>
+ <faq>Currently there are no FAQ items provided.</faq>
+ <name>freeswitchdialplan</name>
+ <version>0.1</version>
+ <title>FreeSWITCH: Dialplan</title>
+ <aftersaveredirect>pkg_edit.php?xml=freeswitch_dialplan.xml&amp;id=0</aftersaveredirect>
+ <include_file>/usr/local/pkg/freeswitch.inc</include_file>
+ <tabs>
+ <tab>
+ <text>Settings</text>
+ <url>/pkg_edit.php?xml=freeswitch.xml&amp;id=0</url>
+ </tab>
+ <tab>
+ <text>Dialplan</text>
+ <url>/freeswitch/freeswitch_dialplan_includes.php</url>
+ <active/>
+ </tab>
+ <tab>
+ <text>Extensions</text>
+ <url>/freeswitch/freeswitch_extensions.php</url>
+ </tab>
+ <tab>
+ <text>External</text>
+ <url>/pkg_edit.php?xml=freeswitch_external.xml&amp;id=0</url>
+ </tab>
+ <tab>
+ <text>Gateways</text>
+ <url>/freeswitch/freeswitch_gateways.php</url>
+ </tab>
+ <tab>
+ <text>Internal</text>
+ <url>/pkg_edit.php?xml=freeswitch_internal.xml&amp;id=0</url>
+ </tab>
+ <tab>
+ <text>IVR</text>
+ <url>/freeswitch/freeswitch_ivr.php</url>
+ </tab>
+ <tab>
+ <text>Modules</text>
+ <url>/pkg_edit.php?xml=freeswitch_modules.xml&amp;id=0</url>
+ </tab>
+ <tab>
+ <text>Public</text>
+ <url>/freeswitch/freeswitch_public_includes.php</url>
+ </tab>
+ <tab>
+ <text>Rec</text>
+ <url>/freeswitch/freeswitch_recordings.php</url>
+ </tab>
+ <tab>
+ <text>Status</text>
+ <url>/freeswitch/freeswitch_status.php</url>
+ </tab>
+ <tab>
+ <text>Vars</text>
+ <url>/pkg_edit.php?xml=freeswitch_vars.xml&amp;id=0</url>
+ </tab>
+ </tabs>
+ <configpath>installedpackages->package->$packagename->configuration->freeswitchdialplan</configpath>
+ <fields>
+ <field>
+ <fielddescr>&lt;b&gt;Default Dialplan&lt;/b&gt; &lt;br /&gt; &lt;br /&gt; The default dialplan is used to setup call destinations based on conditions and context. You can use the dialplan to send calls to gateways, IVRs, external numbers, to scripts, or any destination. </fielddescr>
+ <fieldname>dialplan_default_xml</fieldname>
+ <description>&lt;br /&gt;Path: /usr/local/freeswitch/conf/dialplan/default.xml &lt;br /&gt;&lt;br /&gt;</description>
+ <type>textarea</type>
+ <encoding>base64</encoding>
+ <wrap>off</wrap>
+ <size>30</size>
+ <cols>70</cols>
+ <rows>33</rows>
+ </field>
+ </fields>
+ <custom_php_command_before_form>
+ </custom_php_command_before_form>
+ <custom_php_after_head_command>
+ sync_package_freeswitch_dialplan();
+ </custom_php_after_head_command>
+ <custom_php_after_form_command>
+ </custom_php_after_form_command>
+ <custom_php_validation_command>
+ </custom_php_validation_command>
+ <custom_php_resync_config_command>
+ sync_package_freeswitch_dialplan();
+ </custom_php_resync_config_command>
+</packagegui> \ No newline at end of file
diff --git a/config/freeswitch/freeswitch_dialplan_includes.tmp b/config/freeswitch/freeswitch_dialplan_includes.tmp
new file mode 100644
index 00000000..4b7bacfa
--- /dev/null
+++ b/config/freeswitch/freeswitch_dialplan_includes.tmp
@@ -0,0 +1,271 @@
+<?php
+/* $Id$ */
+/*
+ freeswitch_dialplan_includes.php
+ Copyright (C) 2008 Mark J Crane
+ All rights reserved.
+
+ FreeSWITCH (TM)
+ http://www.freeswitch.org/
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+require("guiconfig.inc");
+require("/usr/local/pkg/freeswitch.inc");
+
+
+//freeswitchdialplanincludes
+ //dialplanincludeid
+ //extensionname
+ //context
+ //default
+ //enabled
+ //descr
+
+//freeswitchdialplanincludedetails
+
+ //dialplanincludeid
+ //tag
+ //condition
+ //action
+ //antiaction
+ //param
+ //tagorder
+ //1-20
+ //fieldtype
+
+ //fielddata
+
+
+$a_dialplan_includes = &$config['installedpackages']['freeswitchdialplanincludes']['config'];
+$a_dialplan_includes_details = &$config['installedpackages']['freeswitchdialplanincludedetails']['config'];
+
+
+if ($_GET['act'] == "del") {
+ if ($_GET['type'] == 'dialplanincludes') {
+
+ if ($a_dialplan_includes[$_GET['id']]) {
+
+ $dialplanincludeid = $a_dialplan_includes[$_GET['id']][dialplanincludeid];
+
+ $extensionname = $a_dialplan_includes[$_GET['id']][extensionname];
+ $order = $a_dialplan_includes[$_GET['id']][order];
+ $dialplanincludefilename = $order."_".$extensionname.".xml";
+
+ //delete the dialplan include details. aka. child data
+ if (count($a_dialplan_includes_details) > 0) {
+ $i=0;
+ foreach($a_dialplan_includes_details as $row) {
+ if ($row["dialplanincludeid"] == $dialplanincludeid) {
+ //echo "child id: ".$i."<br />\n";
+ unset($a_dialplan_includes_details[$i]);
+ }
+ $i++;
+ }
+ }
+
+ //if the dialplan include xml file exists then delete it
+ if (file_exists("/usr/local/freeswitch/conf/dialplan/default/".$dialplanincludefilename)) {
+ unlink("/usr/local/freeswitch/conf/dialplan/default/".$dialplanincludefilename);
+ }
+
+ unset($dialplanincludefilename);
+ unset($a_dialplan_includes[$_GET['id']]);
+ write_config();
+ sync_package_freeswitch_dialplan_includes();
+ header("Location: freeswitch_dialplan_includes.php");
+ exit;
+ }
+ }
+}
+
+include("head.inc");
+
+?>
+
+<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
+<?php include("fbegin.inc"); ?>
+<p class="pgtitle">FreeSWITCH: Dialplan</p>
+
+<div id="mainlevel">
+<table width="100%" border="0" cellpadding="0" cellspacing="0">
+<tr><td class="tabnavtbl">
+<?php
+
+ $tab_array = array();
+ $tab_array[] = array(gettext("Settings"), false, "/pkg_edit.php?xml=freeswitch.xml&amp;id=0");
+ $tab_array[] = array(gettext("Dialplan"), true, "/freeswitch/freeswitch_dialplan_includes.php");
+ $tab_array[] = array(gettext("Extensions"), false, "/freeswitch/freeswitch_extensions.php");
+ $tab_array[] = array(gettext("External"), false, "/pkg_edit.php?xml=freeswitch_external.xml&amp;id=0");
+ $tab_array[] = array(gettext("Gateways"), false, "/freeswitch/freeswitch_gateways.php");
+ $tab_array[] = array(gettext("Internal"), false, "/pkg_edit.php?xml=freeswitch_internal.xml&amp;id=0");
+ $tab_array[] = array(gettext("IVR"), false, "/freeswitch/freeswitch_ivr.php");
+ $tab_array[] = array(gettext("Modules"), false, "/pkg_edit.php?xml=freeswitch_modules.xml&amp;id=0");
+ $tab_array[] = array(gettext("Public"), false, "/freeswitch/freeswitch_public_includes.php");
+ $tab_array[] = array(gettext("Rec"), false, "/freeswitch/freeswitch_recordings.php");
+ $tab_array[] = array(gettext("Status"), false, "/freeswitch/freeswitch_status.php");
+ $tab_array[] = array(gettext("Vars"), false, "/pkg_edit.php?xml=freeswitch_vars.xml&amp;id=0");
+ display_top_tabs($tab_array);
+
+?>
+</td></tr>
+</table>
+
+<table width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr>
+ <td class="tabcont" >
+
+<form action="freeswitch_dialplan_includes.php" method="post" name="iform" id="iform">
+<?php
+
+
+//echo "<pre>";
+//print_r ($a_dialplan_includes);
+//echo "</pre>";
+
+
+//if ($config_change == 1) {
+// write_config();
+// $config_change = 0;
+//}
+
+//if ($savemsg) print_info_box($savemsg);
+//if (file_exists($d_hostsdirty_path)): echo"<p>";
+//print_info_box_np("This has been changed.<br>You must apply the changes in order for them to take effect.");
+//echo"<br />";
+//endif;
+
+?>
+
+ <br />
+ <br />
+
+ <table width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr>
+ <td><span class="vexpl"><span class="red"><strong>Dialplan
+ </strong></span></span>
+ </td>
+ <td align='right'>
+ <input type='button' value='default.xml' onclick="document.location.href='/pkg_edit.php?xml=freeswitch_dialplan.xml&id=0';">
+ </td>
+ </tr>
+ <tr>
+ <td colspan='2'>
+ <span class="vexpl">
+ The dialplan is used to setup call destinations based on conditions and context. You can use the dialplan to send calls to gateways, IVRs, external numbers, to scripts, or any destination.
+ </span>
+ </td>
+
+ </tr>
+ </table>
+
+ <br />
+ <br />
+ <br />
+
+ <table width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr>
+ <td width="20%" class="listhdrr">Extension Name</td>
+ <td width="25%" class="listhdrr">Order</td>
+ <td width="25%" class="listhdrr">Enabled</td>
+ <td width="50%" class="listhdr">Description</td>
+ <td width="10%" class="list">
+ <table border="0" cellspacing="0" cellpadding="1">
+ <tr>
+ <td width="17"></td>
+ <td valign="middle"><a href="freeswitch_dialplan_includes_edit.php"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"></a></td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+
+ <?php
+ $i = 0;
+ if (count($a_dialplan_includes) > 0) {
+ foreach ($a_dialplan_includes as $ent) {
+ ?>
+ <tr>
+ <td class="listlr" ondblclick="document.location='freeswitch_dialplan_includes_edit.php?id=<?=$i;?>'">
+ <?=$ent['extensionname']?>
+ </td>
+ <td class="listlr" ondblclick="document.location='freeswitch_dialplan_includes_edit.php?id=<?=$i;?>'">
+ <?=$ent['order']?>
+ </td>
+ <td class="listr" ondblclick="document.location='freeswitch_dialplan_includes_edit.php?id=<?=$i;?>';">
+ <?=$ent['enabled'];?>&nbsp;
+ </td>
+ <td class="listbg" ondblclick="document.location='freeswitch_dialplan_includes_edit.php?id=<?=$i;?>';">
+ <font color="#FFFFFF"><?=htmlspecialchars($ent['descr']);?>&nbsp;
+ </td>
+ <td valign="middle" nowrap class="list">
+ <table border="0" cellspacing="0" cellpadding="1">
+ <tr>
+ <td valign="middle"><a href="freeswitch_dialplan_includes_edit.php?id=<?=$i;?>"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" width="17" height="17" border="0"></a></td>
+ <td><a href="freeswitch_dialplan_includes.php?type=dialplanincludes&act=del&id=<?=$i;?>" onclick="return confirm('Do you really want to delete this?')"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0"></a></td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ <?php
+ $i++;
+ }
+ }
+ ?>
+ <tr>
+ <td class="list" colspan="4"></td>
+ <td class="list">
+ <table border="0" cellspacing="0" cellpadding="1">
+ <tr>
+ <td width="17"></td>
+ <td valign="middle"><a href="freeswitch_dialplan_includes_edit.php"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"></a></td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+
+ <tr>
+ <td class="list" colspan="4"></td>
+ <td class="list"></td>
+ </tr>
+ </table>
+
+</form>
+
+/usr/local/freeswitch/conf/dialplan/default/
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+
+</td>
+</tr>
+</table>
+
+</div>
+
+
+<?php include("fend.inc"); ?>
+</body>
+</html>
diff --git a/config/freeswitch/freeswitch_dialplan_includes_details.tmp b/config/freeswitch/freeswitch_dialplan_includes_details.tmp
new file mode 100644
index 00000000..7b14dae4
--- /dev/null
+++ b/config/freeswitch/freeswitch_dialplan_includes_details.tmp
@@ -0,0 +1,53 @@
+<?php
+/* $Id$ */
+/*
+ freeswitch_dialplan_includes_details.php
+ Copyright (C) 2008 Mark J Crane
+ All rights reserved.
+
+ FreeSWITCH (TM)
+ http://www.freeswitch.org/
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+require("guiconfig.inc");
+require("/usr/local/pkg/freeswitch.inc");
+
+
+$a_dialplan_include_details = &$config['installedpackages']['freeswitchdialplanincludedetails']['config'];
+
+
+if ($_GET['act'] == "del") {
+ if ($_GET['type'] == 'dialplanincludedetails') {
+ if ($a_dialplan_include_details[$_GET['id']]) {
+ unset($a_dialplan_include_details[$_GET['id']]);
+ write_config();
+ sync_package_freeswitch_dialplan_includes();
+ //touch($d_hostsdirty_path);
+ header("Location: freeswitch_dialplan_includes_edit.php?id=".$_GET['parentid']);
+ exit;
+ }
+ }
+}
+
+?> \ No newline at end of file
diff --git a/config/freeswitch/freeswitch_dialplan_includes_details_edit.tmp b/config/freeswitch/freeswitch_dialplan_includes_details_edit.tmp
new file mode 100644
index 00000000..391d46d7
--- /dev/null
+++ b/config/freeswitch/freeswitch_dialplan_includes_details_edit.tmp
@@ -0,0 +1,375 @@
+<?php
+/* $Id$ */
+/*
+
+ freeswitch_dialplan_includes_details_edit.php
+ Copyright (C) 2008 Mark J Crane
+ All rights reserved.
+
+ FreeSWITCH (TM)
+ http://www.freeswitch.org/
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+require("guiconfig.inc");
+require("/usr/local/pkg/freeswitch.inc");
+
+
+$a_dialplan_includes_details = &$config['installedpackages']['freeswitchdialplanincludedetails']['config'];
+
+$id = $_GET['id'];
+if (isset($_POST['id'])) {
+ $id = $_POST['id'];
+}
+
+$parentid = $_GET['parentid'];
+if (isset($_POST['parentid'])) {
+ $parentid = $_POST['parentid'];
+}
+
+$dialplanincludeid = $_GET['dialplanincludeid'];
+if (isset($_POST['dialplanincludeid'])) {
+ $dialplanincludeid = $_POST['dialplanincludeid'];
+}
+
+
+ //dialplanincludeid
+ //tag
+ //condition
+ //action
+ //antiaction
+ //param
+ //tagorder
+ //1-20
+ //fieldtype
+
+ //fielddata
+
+
+if (isset($id) && $a_dialplan_includes_details[$id]) {
+ $pconfig['dialplanincludeid'] = $a_dialplan_includes_details[$id]['dialplanincludeid'];
+ $pconfig['tag'] = $a_dialplan_includes_details[$id]['tag'];
+ //$pconfig['tagorder'] = $a_dialplan_includes_details[$id]['tagorder'];
+ $pconfig['fieldtype'] = $a_dialplan_includes_details[$id]['fieldtype'];
+ $pconfig['fielddata'] = $a_dialplan_includes_details[$id]['fielddata'];
+}
+//else {
+// if (isset($_GET['a'])) {
+// if ($_GET['a'] == "action"){ $pconfig['optionaction'] = "action"; }
+// if ($_GET['a'] == "antiaction"){ $pconfig['optionaction'] = "anti-action"; }
+// }
+//}
+
+
+
+if ($_POST) {
+
+ unset($input_errors);
+ $pconfig = $_POST;
+
+
+ if (!$input_errors) {
+
+ $ent = array();
+ $ent['dialplanincludeid'] = $_POST['dialplanincludeid'];
+ $ent['tag'] = $_POST['tag'];
+ //$ent['tagorder'] = $_POST['tagorder'];
+ $ent['fieldtype'] = $_POST['fieldtype'];
+ $ent['fielddata'] = $_POST['fielddata'];
+
+
+ if (isset($id) && $a_dialplan_includes_details[$id]) {
+ //update
+ $a_dialplan_includes_details[$id] = $ent;
+ }
+ else {
+ //add
+ $a_dialplan_includes_details[] = $ent;
+ }
+
+ write_config();
+ sync_package_freeswitch_dialplan_includes();
+
+ header("Location: freeswitch_dialplan_includes_edit.php?id=".$parentid);
+ exit;
+ }
+}
+
+include("head.inc");
+
+?>
+
+<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
+<?php include("fbegin.inc"); ?>
+<p class="pgtitle">FreeSWITCH: Dialplan: Details: Edit</p>
+
+<?php if ($input_errors) print_input_errors($input_errors); ?>
+
+<div id="mainlevel">
+<table width="100%" border="0" cellpadding="0" cellspacing="0">
+<tr><td class="tabnavtbl">
+<?php
+
+ $tab_array = array();
+ $tab_array[] = array(gettext("Settings"), false, "/pkg_edit.php?xml=freeswitch.xml&amp;id=0");
+ $tab_array[] = array(gettext("Dialplan"), true, "/freeswitch/freeswitch_dialplan_includes.php");
+ $tab_array[] = array(gettext("Extensions"), false, "/freeswitch/freeswitch_extensions.php");
+ $tab_array[] = array(gettext("External"), false, "/pkg_edit.php?xml=freeswitch_external.xml&amp;id=0");
+ $tab_array[] = array(gettext("Gateways"), false, "/freeswitch/freeswitch_gateways.php");
+ $tab_array[] = array(gettext("Internal"), false, "/pkg_edit.php?xml=freeswitch_internal.xml&amp;id=0");
+ $tab_array[] = array(gettext("IVR"), false, "/freeswitch/freeswitch_ivr.php");
+ $tab_array[] = array(gettext("Modules"), false, "/pkg_edit.php?xml=freeswitch_modules.xml&amp;id=0");
+ $tab_array[] = array(gettext("Public"), false, "/freeswitch/freeswitch_public_includes.php");
+ $tab_array[] = array(gettext("Rec"), false, "/freeswitch/freeswitch_recordings.php");
+ $tab_array[] = array(gettext("Status"), false, "/freeswitch/freeswitch_status.php");
+ $tab_array[] = array(gettext("Vars"), false, "/pkg_edit.php?xml=freeswitch_vars.xml&amp;id=0");
+ display_top_tabs($tab_array);
+
+?>
+</td></tr>
+</table>
+<table width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr>
+ <td class="tabcont" >
+
+ <form action="freeswitch_dialplan_includes_details_edit.php" method="post" name="iform" id="iform">
+ <table width="100%" border="0" cellpadding="6" cellspacing="0">
+ <tr>
+ <td width="22%" valign="top" class="vncellreq">Tag</td>
+ <td width="78%" class="vtable">
+ <script type="text/javascript">
+ function dialplan_include_details_tag_onchange() {
+ var tag = document.getElementById("form_tag").value;
+ if (tag == "condition") {
+ document.getElementById("label_fieldtype").innerHTML = "Field";
+ document.getElementById("label_fielddata").innerHTML = "Expression";
+ }
+ else if (tag == "action") {
+ document.getElementById("label_fieldtype").innerHTML = "Application";
+ document.getElementById("label_fielddata").innerHTML = "Data";
+ }
+ else if (tag == "anti-action") {
+ document.getElementById("label_fieldtype").innerHTML = "Application";
+ document.getElementById("label_fielddata").innerHTML = "Data";
+ }
+ else if (tag == "param") {
+ document.getElementById("label_fieldtype").innerHTML = "Name";
+ document.getElementById("label_fielddata").innerHTML = "Value";
+ }
+ if (tag == "") {
+ document.getElementById("label_fieldtype").innerHTML = "Type";
+ document.getElementById("label_fielddata").innerHTML = "Data";
+ }
+ }
+ </script>
+ <?php
+ echo " <select name='tag' class='formfld' id='form_tag' onchange='dialplan_include_details_tag_onchange();'>\n";
+ echo " <option></option>\n";
+ switch (htmlspecialchars($pconfig['tag'])) {
+ case "condition":
+ echo " <option selected='yes'>condition</option>\n";
+ echo " <option>action</option>\n";
+ echo " <option>anti-action</option>\n";
+ //echo " <option>param</option>\n";
+ break;
+ case "action":
+ echo " <option>condition</option>\n";
+ echo " <option selected='yes'>action</option>\n";
+ echo " <option>anti-action</option>\n";
+ //echo " <option>param</option>\n";
+ break;
+ case "anti-action":
+ echo " <option>condition</option>\n";
+ echo " <option>action</option>\n";
+ echo " <option selected='yes'>anti-action</option>\n";
+ //echo " <option>param</option>\n";
+ break;
+ case "param":
+ echo " <option>condition</option>\n";
+ echo " <option>action</option>\n";
+ echo " <option>anti-action</option>\n";
+ //echo " <option selected='yes'>param</option>\n";
+ break;
+ default:
+ echo " <option>condition</option>\n";
+ echo " <option>action</option>\n";
+ echo " <option>anti-action</option>\n";
+ //echo " <option>param</option>\n";
+ }
+ echo " </select>\n";
+
+ //condition
+ //field expression
+ //action
+ //application
+ //data
+ //antiaction
+ //application
+ //data
+ //param
+ //name
+ //value
+
+ ?>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncellreq" id="label_fieldtype">Type</td>
+ <td width="78%" class="vtable">
+ <input name="fieldtype" type="text" class="formfld" id="fieldtype" size="40" value="<?=htmlspecialchars($pconfig['fieldtype']);?>">
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncellreq" id="label_fielddata">Data</td>
+ <td width="78%" class="vtable">
+ <input name="fielddata" type="text" class="formfld" id="fielddata" size="40" value="<?=htmlspecialchars($pconfig['fielddata']);?>">
+ <br> <span class="vexpl"></span></td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top">&nbsp;</td>
+ <td width="78%">
+ <input name="dialplanincludeid" type="hidden" value="<?=$dialplanincludeid;?>">
+ <input name="parentid" type="hidden" value="<?=$parentid;?>">
+ <?php if (isset($id) && $a_dialplan_includes_details[$id]): ?>
+ <input name="id" type="hidden" value="<?=$id;?>">
+ <?php endif; ?>
+ <input name="Submit" type="submit" class="formbtn" value="Save"> <input class="formbtn" type="button" value="Cancel" onclick="history.back()">
+ </td>
+ </tr>
+ </table>
+ </form>
+
+ <br />
+ <br />
+ <b>Additional Information</b>
+ <br />
+ <br />
+ <a href='http://wiki.freeswitch.org/wiki/Dialplan_XML' target='_blank'>http://wiki.freeswitch.org/wiki/Dialplan_XML</a>
+
+ <br />
+ <br />
+ <br />
+ <br />
+
+ <b>Conditions</b>
+ <br />
+ <br />
+ Conditions are pattern matching tags that help FreeSwitch decide if the current call should be processed in this extension or not. When matching conditions against the current call you have several <b>fields</b> that you can compare against.
+ <ul>
+ <li><b>context</b></li>
+ <li><b>rdnis</b> Redirected Number, the directory number to which the call was last presented.</li>
+ <li><b>destination_number</b> Called Number, the number this call is trying to reach (within a given context)</li>
+ <li><b>dialplan</b> Name of the dialplan module that are used, the name is provided by each dialplan module. Example: XML</li>
+ <li><b>caller_id_name</b> Name of the caller (provided by the User Agent that has called us).</li>
+ <li><b>caller_id_number</b> Directory Number of the party who called (callee) -- can be masked (hidden)</li>
+ <li><b>ani</b> Automatic Number Identification, the number of the calling party (callee) -- cannot be masked</li>
+ <li><b>ani2</b> The type of device placing the call [1]</li>
+ <li><b>uuid</b> Unique identifier of the current call? (looks like a GUID)</li>
+ <li><b>source</b> Name of the FreeSwitch module that received the call (e.g. PortAudio)</li>
+ <li><b>chan_name</b> Name of the current channel (Example: PortAudio/1234). Give us examples when this one can be used.</li>
+ <li><b>network_addr</b> IP address of the signalling source for a VoIP call.</li>
+ </ul>
+ In addition to the above you can also do variables using the syntax ${variable} or api functions using the syntax %{api} {args}
+ <br />
+ <br />
+ Variables may be used in either the field or the expression, as follows
+
+ <br />
+ <br />
+ <br />
+ <br />
+
+ <b>Action and Anti-Actions</b>
+ <br />
+ <br />
+ Actions are executed when the <b>condition matches</b>. Anti-Actions are executed when the <b>condition does NOT match</b>.
+ Additional information on applications for Actions and Anti-Actions.<br />
+ <a href='http://wiki.freeswitch.org/wiki/Modules#Applications' target='_blank'>http://wiki.freeswitch.org/wiki/Modules#Applications</a>
+ <br />
+ <a href='http://wiki.freeswitch.org/wiki/Dialplan_Functions' target='_blank'>http://wiki.freeswitch.org/wiki/Dialplan_Functions</a>
+ <br />
+ <br />
+ <br />
+ The following is a partial list of <b>applications</b>.
+ <ul>
+ <li><b>answer</b> answer the call</li>
+ <li><b>bridge</b> bridge the call<li>
+ <li><b>cond</b></li>
+ <li><b>db</b> is a a runtime database either sqlite by default or odbc</li>
+ <li><b>global_set</b> allows setting of global vars similar to the ones found in vars.xml</li>
+ <li><b>group</b> allows grouping of several extensions for things like ring groups</li>
+ <li><b>expr</b></li>
+ <li><b>hangup</b> hangs up the call</li>
+ <li><b>info</b> sends call info to the console</li>
+ <li><b>javascript</b> run javascript .js files</li>
+ <li><b>playback</b></li>
+ <li><b>reject</b> reject the call</li>
+ <li><b>respond</b></li>
+ <li><b>ring_ready</b></li>
+ <li><b>set</b> set a variable</li>
+ <li><b>set_user</b></li>
+ <li><b>sleep</b></li>
+ <li><b>sofia_contact</b></li>
+ <li><b>transfer</b> transfer the call to another extension or number<li>
+ <li><b>voicemail</b> send the call to voicemail</li>
+ </ul>
+
+
+ <br />
+ <br />
+
+ <!--
+ <b>Param</b>
+ Example parameters by name and value
+ <br />
+ <a href='http://wiki.freeswitch.org/wiki/Special:Search?search=param&go=Go' target='_blank'>http://wiki.freeswitch.org/wiki/Special:Search?search=param&go=Go</a>
+ <ul>
+ <li><b>codec-ms</b> 20</li>
+ <li><b>codec-prefs</b> PCMU@20i</li>
+ <li><b>debug</b> 1</li>
+ <li><b>dialplan</b> XML</li>
+ <li><b>dtmf-duration</b> 100</li>
+ <li><b>rfc2833-pt</b>" 101</li>
+ <li><b>sip-port</b> 5060</li>
+ <li><b>use-rtp-timer</b> true</li>
+ </ul>
+ <br />
+ <br />
+ -->
+
+
+ <br />
+ <br />
+ <br />
+ <br />
+ <br />
+
+ </td>
+ </tr>
+</table>
+
+</div>
+
+<?php include("fend.inc"); ?>
+</body>
+</html>
diff --git a/config/freeswitch/freeswitch_dialplan_includes_edit.tmp b/config/freeswitch/freeswitch_dialplan_includes_edit.tmp
new file mode 100644
index 00000000..e838a277
--- /dev/null
+++ b/config/freeswitch/freeswitch_dialplan_includes_edit.tmp
@@ -0,0 +1,524 @@
+<?php
+/* $Id$ */
+/*
+
+ freeswitch_dialplan_includes_edit.php
+ Copyright (C) 2008 Mark J Crane
+ All rights reserved.
+
+ FreeSWITCH (TM)
+ http://www.freeswitch.org/
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+require("guiconfig.inc");
+require("/usr/local/pkg/freeswitch.inc");
+
+
+//freeswitchdialplanincludes
+ //dialplanincludeid
+ //extensionname
+ //context
+ //default
+ //enabled
+ //descr
+
+//
+
+
+
+$a_dialplan_includes = &$config['installedpackages']['freeswitchdialplanincludes']['config'];
+$a_dialplan_include_details = &$config['installedpackages']['freeswitchdialplanincludedetails']['config'];
+
+$id = $_GET['id'];
+if (isset($_POST['id'])) {
+ $id = $_POST['id'];
+}
+$parentid = $id;
+
+
+if (isset($id) && $a_dialplan_includes[$id]) {
+ $pconfig['dialplanincludeid'] = $a_dialplan_includes[$id]['dialplanincludeid'];
+ $dialplanincludeid = $a_dialplan_includes[$id]['dialplanincludeid'];
+ $pconfig['extensionname'] = $a_dialplan_includes[$id]['extensionname'];
+ $pconfig['order'] = $a_dialplan_includes[$id]['order'];
+ $pconfig['context'] = $a_dialplan_includes[$id]['context'];
+ $pconfig['enabled'] = $a_dialplan_includes[$id]['enabled'];
+ $pconfig['descr'] = $a_dialplan_includes[$id]['descr'];
+ $pconfig['opt1name'] = $a_dialplan_includes[$id]['opt1name'];
+ $pconfig['opt1value'] = $a_dialplan_includes[$id]['opt1value'];
+}
+
+if ($_POST) {
+
+ unset($input_errors);
+ $pconfig = $_POST;
+
+ if ($_GET['act'] == "del") {
+ if ($_GET['type'] == 'dialplanincludedetails') {
+ if ($a_dialplan_include_details[$_GET['id']]) {
+ unset($a_dialplan_include_details[$_GET['id']]);
+ write_config();
+ sync_package_freeswitch_dialplan_includes();
+ header("Location: freeswitch_dialplan_include_edit.php?id=".$_GET['id']);
+ exit;
+ }
+ }
+ }
+
+
+ if (!$input_errors) {
+
+ $ent = array();
+ if (strlen($_POST['dialplanincludeid']) > 0) {
+ //update
+ $ent['dialplanincludeid'] = $_POST['dialplanincludeid'];
+ }
+ else {
+ //add
+ $ent['dialplanincludeid'] = guid();
+ }
+ $ent['extensionname'] = $_POST['extensionname'];
+ $ent['order'] = $_POST['order'];
+ //$ent['context'] = $_POST['context'];
+ $ent['context'] = 'default';
+ $ent['enabled'] = $_POST['enabled'];
+ $ent['descr'] = $_POST['descr'];
+ $ent['opt1name'] = $_POST['opt1name'];
+ $ent['opt1value'] = $_POST['opt1value'];
+
+
+ if (isset($id) && $a_dialplan_includes[$id]) {
+
+ if (count($a_dialplan_includes)>0) {
+ foreach($a_dialplan_includes as $rowhelper) {
+
+ //$rowhelper['dialplanincludeid'];
+ //$rowhelper['extensionname'];
+ //$rowhelper['context'];
+ //$rowhelper['enabled'];
+
+ $filenamechanged = false;
+ if ($rowhelper['dialplanincludeid'] == $_POST['dialplanincludeid']) {
+
+ if ($rowhelper['extensionname'] != $_POST['extensionname']) {
+ //if the extension name has changed then remove the current dialplan xml file
+ //to prepare for the new file
+ $filenamechanged = true;
+ }
+ if ($rowhelper['order'] != $_POST['order']) {
+ //if the order has changed then remove the current dialplan xml file
+ //to prepare for the new file
+ $filenamechanged = true;
+ }
+ if ($_POST['enabled'] == "false") {
+ //if the extension name is disabled then remove the dialplan xml file
+ $filenamechanged = true;
+ }
+ if ($filenamechanged){
+ $dialplanincludefilename = $rowhelper['order']."_".$rowhelper['extensionname'].".xml";
+ if (file_exists("/usr/local/freeswitch/conf/dialplan/default/".$dialplanincludefilename)) {
+ unlink("/usr/local/freeswitch/conf/dialplan/default/".$dialplanincludefilename);
+ }
+ unset($dialplanincludefilename);
+ }
+
+ }
+ unset($filenamechanged);
+
+ } //end foreach
+ } //end count
+
+ //update the config
+ $a_dialplan_includes[$id] = $ent;
+ }
+ else {
+ //add to the config
+ $a_dialplan_includes[] = $ent;
+ }
+
+
+ write_config();
+ sync_package_freeswitch_dialplan_includes();
+
+ header("Location: freeswitch_dialplan_includes.php");
+ exit;
+ }
+}
+
+include("head.inc");
+
+?>
+
+<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
+<?php include("fbegin.inc"); ?>
+<p class="pgtitle">FreeSWITCH: Dialplan: Edit</p>
+
+<?php if ($input_errors) print_input_errors($input_errors); ?>
+
+
+<div id="mainlevel">
+<table width="100%" border="0" cellpadding="0" cellspacing="0">
+<tr><td class="tabnavtbl">
+<?php
+
+ $tab_array = array();
+ $tab_array[] = array(gettext("Settings"), false, "/pkg_edit.php?xml=freeswitch.xml&amp;id=0");
+ $tab_array[] = array(gettext("Dialplan"), true, "/freeswitch/freeswitch_dialplan_includes.php");
+ $tab_array[] = array(gettext("Extensions"), false, "/freeswitch/freeswitch_extensions.php");
+ $tab_array[] = array(gettext("External"), false, "/pkg_edit.php?xml=freeswitch_external.xml&amp;id=0");
+ $tab_array[] = array(gettext("Gateways"), false, "/freeswitch/freeswitch_gateways.php");
+ $tab_array[] = array(gettext("Internal"), false, "/pkg_edit.php?xml=freeswitch_internal.xml&amp;id=0");
+ $tab_array[] = array(gettext("IVR"), false, "/freeswitch/freeswitch_ivr.php");
+ $tab_array[] = array(gettext("Modules"), false, "/pkg_edit.php?xml=freeswitch_modules.xml&amp;id=0");
+ $tab_array[] = array(gettext("Public"), false, "/freeswitch/freeswitch_public_includes.php");
+ $tab_array[] = array(gettext("Rec"), false, "/freeswitch/freeswitch_recordings.php");
+ $tab_array[] = array(gettext("Status"), false, "/freeswitch/freeswitch_status.php");
+ $tab_array[] = array(gettext("Vars"), false, "/pkg_edit.php?xml=freeswitch_vars.xml&amp;id=0");
+ display_top_tabs($tab_array);
+
+?>
+</td></tr>
+</table>
+<table width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr>
+ <td class="tabcont" >
+
+ <table width="100%" border="0" cellpadding="6" cellspacing="0">
+ <tr>
+ <td><p><span class="vexpl"><span class="red"><strong>Dialplan:<br>
+ </strong></span>
+ Dialplan Include general settings.
+ </span></p></td>
+ </tr>
+ </table>
+ <br />
+
+ <form action="freeswitch_dialplan_includes_edit.php" method="post" name="iform" id="iform">
+ <table width="100%" border="0" cellpadding="6" cellspacing="0">
+ <tr>
+ <td width="22%" valign="top" class="vncellreq">Extension Name</td>
+ <td width="78%" class="vtable">
+ <input name="extensionname" type="text" class="formfld" id="extensionname" size="40" value="<?=htmlspecialchars($pconfig['extensionname']);?>">
+ <br />
+ Supported characters are 'a-z', 'A-Z', '0-9', underscore '_', and period '.'.
+ </td>
+ </tr>
+ <!--
+ <tr>
+ <td width="22%" valign="top" class="vncellreq">Context</td>
+ <td width="78%" class="vtable">
+ <input name="context" type="text" class="formfld" id="context" size="40" value="<?=htmlspecialchars($pconfig['context']);?>">
+ <br />
+ e.g. default
+ </td>
+ </tr>
+ -->
+
+ <tr>
+ <td width="22%" valign="top" class="vncellreq">Enabled</td>
+ <td width="78%" class="vtable">
+ <?php
+ echo " <select name='enabled' class='formfld'>\n";
+ echo " <option></option>\n";
+ switch (htmlspecialchars($pconfig['enabled'])) {
+ case "true":
+ echo " <option value='true' selected='yes'>true</option>\n";
+ echo " <option value='false'>false</option>\n";
+ break;
+ case "false":
+ echo " <option value='true'>true</option>\n";
+ echo " <option value='false' selected='yes'>false</option>\n";
+
+ break;
+ default:
+ echo " <option value='true' selected='yes'>true</option>\n";
+ echo " <option value='false'>false</option>\n";
+ }
+ echo " </select>\n";
+ ?>
+ </td>
+ </tr>
+
+ <tr>
+ <td width="22%" valign="top" class="vncellreq">Order</td>
+ <td width="78%" class="vtable">
+ <?php
+
+ echo " <select name='order' class='formfld'>\n";
+ echo " <option></option>\n";
+ if (strlen(htmlspecialchars($pconfig['order']))> 0) {
+ echo " <option selected='yes' value='".htmlspecialchars($pconfig['order'])."'>".htmlspecialchars($pconfig['order'])."</option>\n";
+ }
+ $i=0;
+ while($i<=999) {
+ if (strlen($i) == 1) {
+ echo " <option value='00$i'>00$i</option>\n";
+ }
+ if (strlen($i) == 2) {
+ echo " <option value='0$i'>0$i</option>\n";
+ }
+ if (strlen($i) == 3) {
+ echo " <option value='$i'>$i</option>\n";
+ }
+
+ $i++;
+ }
+ echo " </select>\n";
+ ?>
+ <br />
+ Processing of each dialplan include is determined by this order.
+ </td>
+ </tr>
+
+ <tr>
+ <td width="22%" valign="top" class="vncell">Description</td>
+ <td width="78%" class="vtable">
+ <input name="descr" type="text" class="formfld" id="descr" size="40" value="<?=htmlspecialchars($pconfig['descr']);?>">
+ <br> <span class="vexpl">You may enter a description here
+ for your reference (not parsed).</span></td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top">&nbsp;</td>
+ <td width="78%">
+ <input name="dialplanincludeid" type="hidden" value="<?=htmlspecialchars($pconfig['dialplanincludeid']);?>">
+ <?php
+ if (strlen($id) > 0 && $a_dialplan_includes[$id]) {
+ echo "\n";
+ echo " <input name=\"id\" type=\"hidden\" value=\"$id\">\n";
+ echo " <input name=\"opt1name\" type=\"hidden\" value=\"".htmlspecialchars($pconfig['opt1name'])."\">\n";
+ echo " <input name=\"opt1value\" type=\"hidden\" value=\"".htmlspecialchars($pconfig['opt1value'])."\">\n";
+ }
+ ?>
+ <input name="Submit" type="submit" class="formbtn" value="Save"> <input class="formbtn" type="button" value="Cancel" onclick="history.back()">
+ </td>
+ </tr>
+ </table>
+ </form>
+
+ <br>
+ <br>
+
+ <form action="freeswitch_dialplan_includes_edit.php" method="post" name="iform2" id="iform2">
+ <?php
+
+ //echo "<pre>";
+ //print_r ($a_dialplan_includes);
+ //echo "</pre>";
+
+ //if ($savemsg) print_info_box($savemsg);
+ //if (file_exists($d_hostsdirty_path)): echo"<p>";
+ //print_info_box_np("The FreeSWITCH recordings have been changed.<br>You must apply the changes in order for them to take effect.");
+ //echo"<br />";
+ //endif;
+
+ ?>
+
+
+ <table width="100%" border="0" cellpadding="6" cellspacing="0">
+ <tr>
+ <td><p><span class="vexpl"><span class="red"><strong>Conditions and Actions<br />
+ </strong></span>
+ The following conditions, actions and anti-actions are used in the dialplan to direct call flow. Each is processed in order until you reach the action tag which tells FreeSWITCH what action to perform. You are not limited to only one condition or action tag for a given extension.
+ </span></p></td>
+ </tr>
+ </table>
+ <br />
+
+ <table width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr>
+ <td width="20%" class="listhdrr">Tag</td>
+ <td width="20%" class="listhdrr">Type</td>
+ <td width="50%" class="listhdrr">Data</td>
+ <td width="10%" class="list">
+ <table border="0" cellspacing="0" cellpadding="1">
+ <tr>
+ <td width="17"></td>
+ <td valign="middle"><a href="freeswitch_dialplan_includes_details_edit.php?parentid=<?=$parentid;?>&dialplanincludeid=<?=$dialplanincludeid;?>&a=action"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"></a></td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+
+ <?php
+
+ $i = 0;
+ if (count($a_dialplan_include_details) > 0) {
+
+ foreach ($a_dialplan_include_details as $ent) {
+ if ($ent['tag'] == "condition" && $dialplanincludeid == $ent['dialplanincludeid']) {
+ ?>
+ <tr>
+ <td class="listlr" ondblclick="document.location='freeswitch_dialplan_includes_details_edit.php?id=<?=$i;?>&parentid=<?=$parentid;?>&dialplanincludeid=<?=$dialplanincludeid;?>'">
+ <?=$ent['tag']?>
+ </td>
+ <td class="listr" ondblclick="document.location='freeswitch_dialplan_includes_details_edit.php?id=<?=$i;?>&parentid=<?=$parentid;?>&dialplanincludeid=<?=$dialplanincludeid;?>';">
+ <?=$ent['fieldtype'];?>&nbsp;
+ </td>
+ <td class="listr" ondblclick="document.location='freeswitch_dialplan_includes_details_edit.php?id=<?=$i;?>&parentid=<?=$parentid;?>&dialplanincludeid=<?=$dialplanincludeid;?>';">
+ <?=$ent['fielddata'];?>&nbsp;
+ </td>
+ <td valign="middle" nowrap class="list">
+ <table border="0" cellspacing="0" cellpadding="1">
+ <tr>
+ <td valign="middle"><a href="freeswitch_dialplan_includes_details_edit.php?id=<?=$i;?>&parentid=<?=$parentid;?>&dialplanincludeid=<?=$dialplanincludeid;?>"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" width="17" height="17" border="0"></a></td>
+ <td><a href="freeswitch_dialplan_includes_details.php?type=dialplanincludedetails&act=del&id=<?=$i;?>&parentid=<?=$parentid;?>&dialplanincludeid=<?=$dialplanincludeid;?>" onclick="return confirm('Do you really want to delete this?')"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0"></a></td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ <?php
+ }
+ $i++;
+ }
+ }
+
+ $i = 0;
+ if (count($a_dialplan_include_details) > 0) {
+
+ foreach ($a_dialplan_include_details as $ent) {
+ if ($ent['tag'] == "action" && $dialplanincludeid == $ent['dialplanincludeid']) {
+ ?>
+ <tr>
+ <td class="listlr" ondblclick="document.location='freeswitch_dialplan_includes_details_edit.php?id=<?=$i;?>&parentid=<?=$parentid;?>&dialplanincludeid=<?=$dialplanincludeid;?>'">
+ <?=$ent['tag']?>
+ </td>
+ <td class="listr" ondblclick="document.location='freeswitch_dialplan_includes_details_edit.php?id=<?=$i;?>&parentid=<?=$parentid;?>&dialplanincludeid=<?=$dialplanincludeid;?>';">
+ <?=$ent['fieldtype'];?>&nbsp;
+ </td>
+ <td class="listr" ondblclick="document.location='freeswitch_dialplan_includes_details_edit.php?id=<?=$i;?>&parentid=<?=$parentid;?>&dialplanincludeid=<?=$dialplanincludeid;?>';">
+ <?=$ent['fielddata'];?>&nbsp;
+ </td>
+ <td valign="middle" nowrap class="list">
+ <table border="0" cellspacing="0" cellpadding="1">
+ <tr>
+ <td valign="middle"><a href="freeswitch_dialplan_includes_details_edit.php?id=<?=$i;?>&parentid=<?=$parentid;?>&dialplanincludeid=<?=$dialplanincludeid;?>"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" width="17" height="17" border="0"></a></td>
+ <td><a href="freeswitch_dialplan_includes_details.php?type=dialplanincludedetails&act=del&id=<?=$i;?>&parentid=<?=$parentid;?>&dialplanincludeid=<?=$dialplanincludeid;?>" onclick="return confirm('Do you really want to delete this?')"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0"></a></td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ <?php
+ }
+ $i++;
+ }
+ }
+
+ $i = 0;
+ if (count($a_dialplan_include_details) > 0) {
+
+ foreach ($a_dialplan_include_details as $ent) {
+ if ($ent['tag'] == "anti-action" && $dialplanincludeid == $ent['dialplanincludeid']) {
+ ?>
+ <tr>
+ <td class="listlr" ondblclick="document.location='freeswitch_dialplan_includes_details_edit.php?id=<?=$i;?>&parentid=<?=$parentid;?>&dialplanincludeid=<?=$dialplanincludeid;?>'">
+ <?=$ent['tag']?>
+ </td>
+ <td class="listr" ondblclick="document.location='freeswitch_dialplan_includes_details_edit.php?id=<?=$i;?>&parentid=<?=$parentid;?>&dialplanincludeid=<?=$dialplanincludeid;?>';">
+ <?=$ent['fieldtype'];?>&nbsp;
+ </td>
+ <td class="listr" ondblclick="document.location='freeswitch_dialplan_includes_details_edit.php?id=<?=$i;?>&parentid=<?=$parentid;?>&dialplanincludeid=<?=$dialplanincludeid;?>';">
+ <?=$ent['fielddata'];?>&nbsp;
+ </td>
+ <td valign="middle" nowrap class="list">
+ <table border="0" cellspacing="0" cellpadding="1">
+ <tr>
+ <td valign="middle"><a href="freeswitch_dialplan_includes_details_edit.php?id=<?=$i;?>&parentid=<?=$parentid;?>&dialplanincludeid=<?=$dialplanincludeid;?>"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" width="17" height="17" border="0"></a></td>
+ <td><a href="freeswitch_dialplan_includes_details.php?type=dialplanincludedetails&act=del&id=<?=$i;?>&parentid=<?=$parentid;?>&dialplanincludeid=<?=$dialplanincludeid;?>" onclick="return confirm('Do you really want to delete this?')"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0"></a></td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ <?php
+ }
+ $i++;
+ }
+ }
+
+ $i = 0;
+ if (count($a_dialplan_include_details) > 0) {
+
+ foreach ($a_dialplan_include_details as $ent) {
+ if ($ent['tag'] == "param" && $dialplanincludeid == $ent['dialplanincludeid']) {
+ ?>
+ <tr>
+ <td class="listlr" ondblclick="document.location='freeswitch_dialplan_includes_details_edit.php?id=<?=$i;?>&parentid=<?=$parentid;?>&dialplanincludeid=<?=$dialplanincludeid;?>'">
+ <?=$ent['tag']?>
+ </td>
+ <td class="listr" ondblclick="document.location='freeswitch_dialplan_includes_details_edit.php?id=<?=$i;?>&parentid=<?=$parentid;?>&dialplanincludeid=<?=$dialplanincludeid;?>';">
+ <?=$ent['fieldtype'];?>&nbsp;
+ </td>
+ <td class="listr" ondblclick="document.location='freeswitch_dialplan_includes_details_edit.php?id=<?=$i;?>&parentid=<?=$parentid;?>&dialplanincludeid=<?=$dialplanincludeid;?>';">
+ <?=$ent['fielddata'];?>&nbsp;
+ </td>
+ <td valign="middle" nowrap class="list">
+ <table border="0" cellspacing="0" cellpadding="1">
+ <tr>
+ <td valign="middle"><a href="freeswitch_dialplan_includes_details_edit.php?id=<?=$i;?>&parentid=<?=$parentid;?>&dialplanincludeid=<?=$dialplanincludeid;?>"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" width="17" height="17" border="0"></a></td>
+ <td><a href="freeswitch_dialplan_includes_details.php?type=dialplanincludedetails&act=del&id=<?=$i;?>&parentid=<?=$parentid;?>&dialplanincludeid=<?=$dialplanincludeid;?>" onclick="return confirm('Do you really want to delete this?')"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0"></a></td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ <?php
+ }
+ $i++;
+ }
+ }
+ ?>
+ <tr>
+ <td class="list" colspan="3"></td>
+ <td class="list">
+ <table border="0" cellspacing="0" cellpadding="1">
+ <tr>
+ <td width="17"></td>
+ <td valign="middle"><a href="freeswitch_dialplan_includes_details_edit.php?parentid=<?=$parentid;?>&dialplanincludeid=<?=$dialplanincludeid;?>&a=action"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"></a></td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+
+
+ <tr>
+ <td class="list" colspan="3"></td>
+ <td class="list"></td>
+ </tr>
+ </table>
+
+ </form>
+
+
+
+
+ <br>
+ <br>
+
+ </td>
+ </tr>
+</table>
+
+</div>
+
+<?php include("fend.inc"); ?>
+</body>
+</html>
diff --git a/config/freeswitch/freeswitch_extensions.tmp b/config/freeswitch/freeswitch_extensions.tmp
new file mode 100644
index 00000000..ca6f3d73
--- /dev/null
+++ b/config/freeswitch/freeswitch_extensions.tmp
@@ -0,0 +1,209 @@
+<?php
+/* $Id$ */
+/*
+ freeswitch_extensions.php
+ Copyright (C) 2008 Mark J Crane
+ All rights reserved.
+
+ FreeSWITCH (TM)
+ http://www.freeswitch.org/
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+require("guiconfig.inc");
+require("/usr/local/pkg/freeswitch.inc");
+
+$a_extensions = &$config['installedpackages']['freeswitchextensions']['config'];
+
+
+if ($_GET['act'] == "del") {
+ if ($_GET['type'] == 'extensions') {
+ if ($a_extensions[$_GET['id']]) {
+ unset($a_extensions[$_GET['id']]);
+ write_config();
+ header("Location: freeswitch_extensions.php");
+ exit;
+ }
+ }
+}
+
+include("head.inc");
+
+?>
+
+
+<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
+<?php include("fbegin.inc"); ?>
+<p class="pgtitle">FreeSWITCH: Extensions</p>
+
+<div id="mainlevel">
+<table width="100%" border="0" cellpadding="0" cellspacing="0">
+<tr><td class="tabnavtbl">
+<?php
+
+ $tab_array = array();
+ $tab_array[] = array(gettext("Settings"), false, "/pkg_edit.php?xml=freeswitch.xml&amp;id=0");
+ $tab_array[] = array(gettext("Dialplan"), false, "/freeswitch/freeswitch_dialplan_includes.php");
+ $tab_array[] = array(gettext("Extensions"), true, "/freeswitch/freeswitch_extensions.php");
+ $tab_array[] = array(gettext("External"), false, "/pkg_edit.php?xml=freeswitch_external.xml&amp;id=0");
+ $tab_array[] = array(gettext("Gateways"), false, "/freeswitch/freeswitch_gateways.php");
+ $tab_array[] = array(gettext("Internal"), false, "/pkg_edit.php?xml=freeswitch_internal.xml&amp;id=0");
+ $tab_array[] = array(gettext("IVR"), false, "/freeswitch/freeswitch_ivr.php");
+ $tab_array[] = array(gettext("Modules"), false, "/pkg_edit.php?xml=freeswitch_modules.xml&amp;id=0");
+ $tab_array[] = array(gettext("Public"), false, "/freeswitch/freeswitch_public_includes.php");
+ $tab_array[] = array(gettext("Rec"), false, "/freeswitch/freeswitch_recordings.php");
+ $tab_array[] = array(gettext("Status"), false, "/freeswitch/freeswitch_status.php");
+ $tab_array[] = array(gettext("Vars"), false, "/pkg_edit.php?xml=freeswitch_vars.xml&amp;id=0");
+ display_top_tabs($tab_array);
+
+?>
+</td></tr>
+</table>
+
+<table width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr>
+ <td class="tabcont" >
+
+<form action="freeswitch_extensions.php" method="post" name="iform" id="iform">
+<?php
+
+if ($config_change == 1) {
+ write_config();
+ $config_change = 0;
+}
+
+//if ($savemsg) print_info_box($savemsg);
+//if (file_exists($d_hostsdirty_path)): echo"<p>";
+//print_info_box_np("The FreeSWITCH extensions have been changed.<br>You must apply the changes in order for them to take effect.");
+//echo"<br />";
+//endif;
+
+?>
+ <table width="100%" border="0" cellpadding="6" cellspacing="0">
+ <tr>
+ <td><p><span class="vexpl"><span class="red"><strong>Extensions<br>
+ </strong></span>
+ Use this to configure your SIP extensions.
+ </p></td>
+ </tr>
+ </table>
+ <br />
+
+ <table width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr>
+ <td width="20%" class="listhdrr">Extension</td>
+ <td width="25%" class="listhdrr">Mail To</td>
+ <td width="25%" class="listhdrr">Call Group</td>
+ <td width="25%" class="listhdr">Description</td>
+ <td width="10%" class="list">
+
+ <table border="0" cellspacing="0" cellpadding="1">
+ <tr>
+ <td width="17"></td>
+ <td valign="middle"><a href="freeswitch_extensions_edit.php"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"></a></td>
+ </tr>
+ </table>
+
+ </td>
+ </tr>
+
+
+ <?php
+
+ $i = 0;
+ if (count($a_extensions) > 0) {
+
+ foreach ($a_extensions as $ent) {
+
+ ?>
+ <tr>
+ <td class="listr" ondblclick="document.location='freeswitch_extensions_edit.php?id=<?=$i;?>';">
+ <?=$ent['extension'];?>&nbsp;
+ </td>
+ <td class="listr" ondblclick="document.location='freeswitch_extensions_edit.php?id=<?=$i;?>';">
+ <?=$ent['vm-mailto'];?>&nbsp;
+ </td>
+ <td class="listr" ondblclick="document.location='freeswitch_extensions_edit.php?id=<?=$i;?>';">
+ <?=$ent['callgroup'];?>&nbsp;
+ </td>
+ <td class="listbg" ondblclick="document.location='freeswitch_extensions_edit.php?id=<?=$i;?>';">
+ <font color="#FFFFFF"><?=htmlspecialchars($ent['description']);?>&nbsp;
+ </td>
+ <td valign="middle" nowrap class="list">
+ <table border="0" cellspacing="0" cellpadding="1">
+ <tr>
+ <td valign="middle"><a href="freeswitch_extensions_edit.php?id=<?=$i;?>"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" width="17" height="17" border="0"></a></td>
+ <td><a href="freeswitch_extensions.php?type=extensions&act=del&id=<?=$i;?>" onclick="return confirm('Do you really want to delete this?')"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0"></a></td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ <?php
+
+ $i++;
+ }
+ }
+ ?>
+
+ <tr>
+ <td class="list" colspan="4"></td>
+ <td class="list">
+ <table border="0" cellspacing="0" cellpadding="1">
+ <tr>
+ <td width="17"></td>
+ <td valign="middle"><a href="freeswitch_extensions_edit.php"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"></a></td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+
+
+ <tr>
+ <td class="list" colspan="4"></td>
+ <td class="list"></td>
+ </tr>
+ </table>
+
+</form>
+
+
+/usr/local/freeswitch/conf/directory/default/
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+
+</td>
+</tr>
+</table>
+
+</div>
+
+
+<?php include("fend.inc"); ?>
+</body>
+</html>
diff --git a/config/freeswitch/freeswitch_extensions.xml b/config/freeswitch/freeswitch_extensions.xml
new file mode 100644
index 00000000..61277e97
--- /dev/null
+++ b/config/freeswitch/freeswitch_extensions.xml
@@ -0,0 +1,225 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<!DOCTYPE packagegui SYSTEM "./schema/packages.dtd">
+<packagegui>
+ <copyright>
+ <![CDATA[
+/* $Id$ */
+/* ========================================================================== */
+/*
+
+ freeswitch_extensions.xml
+ Copyright (C) 2008 Mark J Crane
+ All rights reserved.
+
+ FreeSWITCH (TM)
+ http://www.freeswitch.org/
+
+ part of pfSense (http://www.pfSense.com)
+ Copyright (C) 2007 to whom it may belong
+ All rights reserved.
+
+ Based on m0n0wall (http://m0n0.ch/wall)
+ Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>.
+ All rights reserved.
+ */
+/* ========================================================================== */
+/*
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+ */
+/* ========================================================================== */
+ ]]>
+ </copyright>
+ <description>FreeSWITCH is an open source telephony platform designed to facilitate the creation of voice and chat driven products scaling from a soft-phone up to a soft-switch. It can be used as a simple switching engine, a PBX, a media gateway or a media server to host IVR applications using simple scripts or XML to control the callflow.</description>
+ <requirements>Describe your package requirements here</requirements>
+ <faq>Currently there are no FAQ items provided.</faq>
+ <name>freeswitchextensions</name>
+ <version>0.1</version>
+ <title>FreeSWITCH: Extensions</title>
+ <include_file>/usr/local/pkg/freeswitch.inc</include_file>
+ <tabs>
+ <tab>
+ <text>Settings</text>
+ <url>/pkg_edit.php?xml=freeswitch.xml&amp;id=0</url>
+ </tab>
+ <tab>
+ <text>Dialplan</text>
+ <url>/freeswitch/freeswitch_dialplan_includes.php</url>
+ </tab>
+ <tab>
+ <text>Extensions</text>
+ <url>/freeswitch/freeswitch_extensions.php</url>
+ <active/>
+ </tab>
+ <tab>
+ <text>External</text>
+ <url>/pkg_edit.php?xml=freeswitch_external.xml&amp;id=0</url>
+ </tab>
+ <tab>
+ <text>Gateways</text>
+ <url>/freeswitch/freeswitch_gateways.php</url>
+ </tab>
+ <tab>
+ <text>Internal</text>
+ <url>/pkg_edit.php?xml=freeswitch_internal.xml&amp;id=0</url>
+ </tab>
+ <tab>
+ <text>IVR</text>
+ <url>/freeswitch/freeswitch_ivr.php</url>
+ </tab>
+ <tab>
+ <text>Modules</text>
+ <url>/pkg_edit.php?xml=freeswitch_modules.xml&amp;id=0</url>
+ </tab>
+ <tab>
+ <text>Public</text>
+ <url>/freeswitch/freeswitch_public_includes.php</url>
+ </tab>
+ <tab>
+ <text>Rec</text>
+ <url>/freeswitch/freeswitch_recordings.php</url>
+ </tab>
+ <tab>
+ <text>Status</text>
+ <url>/freeswitch/freeswitch_status.php</url>
+ </tab>
+ <tab>
+ <text>Vars</text>
+ <url>/pkg_edit.php?xml=freeswitch_vars.xml&amp;id=0</url>
+ </tab>
+ </tabs>
+ <configpath>installedpackages->package->$packagename->configuration->extensions</configpath>
+ <adddeleteeditpagefields>
+ <columnitem>
+ <fielddescr>Extension</fielddescr>
+ <fieldname>extension</fieldname>
+ </columnitem>
+ <columnitem>
+ <fielddescr>Mailbox</fielddescr>
+ <fieldname>mailbox</fieldname>
+ </columnitem>
+ <columnitem>
+ <fielddescr>Description</fielddescr>
+ <fieldname>description</fieldname>
+ </columnitem>
+ </adddeleteeditpagefields>
+ <fields>
+ <field>
+ <fielddescr>Extension</fielddescr>
+ <fieldname>extension</fieldname>
+ <description>Enter the extension here. The default configuration expects extension numbers between 1001 -1019. To use additional numbers for the extensions by adjusting the dialplan. In the in the dialplan under name="Local_Extension" adjust the regular expression="^(10[01][0-9])$".</description>
+ <type>input</type>
+ </field>
+ <field>
+ <fielddescr>Password</fielddescr>
+ <fieldname>password</fieldname>
+ <description>Enter the password here.</description>
+ <type>input</type>
+ </field>
+ <field>
+ <fielddescr>Mailbox</fielddescr>
+ <fieldname>mailbox</fieldname>
+ <description>Enter the mailbox here. Example: extension 1001 then mailbox 1001</description>
+ <type>input</type>
+ </field>
+ <field>
+ <fielddescr>Voicemail Password</fielddescr>
+ <fieldname>vm-password</fieldname>
+ <description>Enter the voicemail password here.</description>
+ <type>input</type>
+ </field>
+ <field>
+ <fielddescr>Account Code</fielddescr>
+ <fieldname>accountcode</fieldname>
+ <description>Enter the account code here. Example: extension 1001 then accountcode 1001</description>
+ <type>input</type>
+ </field>
+ <field>
+ <fielddescr>Effective Caller ID Name</fielddescr>
+ <fieldname>effective_caller_id_name</fieldname>
+ <description>Enter the effective caller id name here.</description>
+ <type>input</type>
+ </field>
+ <field>
+ <fielddescr>Effective Caller ID Number</fielddescr>
+ <fieldname>effective_caller_id_number</fieldname>
+ <description>Enter the effective caller id number here.</description>
+ <type>input</type>
+ </field>
+ <field>
+ <fielddescr>Outbound Caller ID Name</fielddescr>
+ <fieldname>outbound_caller_id_name</fieldname>
+ <description>Enter the outbound caller id name here.</description>
+ <type>input</type>
+ </field>
+ <field>
+ <fielddescr>Outbound Caller ID Number</fielddescr>
+ <fieldname>outbound_caller_id_number</fieldname>
+ <description>Enter the outbound caller id number here.</description>
+ <type>input</type>
+ </field>
+ <field>
+ <fielddescr>Voicemail Mail To</fielddescr>
+ <fieldname>vm-mailto</fieldname>
+ <description>Optional: Enter the email address to send voicemail to.</description>
+ <type>input</type>
+ </field>
+ <field>
+ <fielddescr>Voicemail Attach File</fielddescr>
+ <fieldname>vm-attach-file</fieldname>
+ <description>Choose whether to attach the file to the email.</description>
+ <type>select</type>
+ <options>
+ <option>
+ <name>true</name>
+ <value>true</value>
+ </option>
+ <option>
+ <name>false</name>
+ <value>false</value>
+ </option>
+ </options>
+ </field>
+
+ <field>
+ <fielddescr>User Context</fielddescr>
+ <fieldname>user_context</fieldname>
+ <description>Enter the user context here. Example: default</description>
+ <type>input</type>
+ </field>
+ <field>
+ <fielddescr>Extension Description</fielddescr>
+ <fieldname>description</fieldname>
+ <description>Enter the description of the extension here.</description>
+ <type>input</type>
+ </field>
+ </fields>
+ <custom_add_php_command>
+ </custom_add_php_command>
+ <custom_php_resync_config_command>
+ sync_package_freeswitch_extensions();
+ </custom_php_resync_config_command>
+ <custom_delete_php_command>
+ sync_package_freeswitch_extensions();
+ </custom_delete_php_command>
+ <custom_php_deinstall_command>
+ </custom_php_deinstall_command>
+</packagegui> \ No newline at end of file
diff --git a/config/freeswitch/freeswitch_extensions_edit.tmp b/config/freeswitch/freeswitch_extensions_edit.tmp
new file mode 100644
index 00000000..9b1639f5
--- /dev/null
+++ b/config/freeswitch/freeswitch_extensions_edit.tmp
@@ -0,0 +1,351 @@
+<?php
+/* $Id$ */
+/*
+
+ freeswitch_extensions_edit.php
+ Copyright (C) 2008 Mark J Crane
+ All rights reserved.
+
+ FreeSWITCH (TM)
+ http://www.freeswitch.org/
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+require("guiconfig.inc");
+require("/usr/local/pkg/freeswitch.inc");
+
+
+$a_extensions = &$config['installedpackages']['freeswitchextensions']['config'];
+
+$id = $_GET['id'];
+if (isset($_POST['id'])) {
+ $id = $_POST['id'];
+}
+
+if (isset($id) && $a_extensions[$id]) {
+
+ $pconfig['extension'] = $a_extensions[$id]['extension'];
+ $pconfig['password'] = $a_extensions[$id]['password'];
+ $pconfig['mailbox'] = $a_extensions[$id]['mailbox'];
+ $pconfig['vm-password'] = $a_extensions[$id]['vm-password'];
+ $pconfig['accountcode'] = $a_extensions[$id]['accountcode'];
+ $pconfig['effective_caller_id_name'] = $a_extensions[$id]['effective_caller_id_name'];
+ $pconfig['effective_caller_id_number'] = $a_extensions[$id]['effective_caller_id_number'];
+ $pconfig['effective_caller_id_number'] = $a_extensions[$id]['effective_caller_id_number'];
+ $pconfig['outbound_caller_id_name'] = $a_extensions[$id]['outbound_caller_id_name'];
+ $pconfig['outbound_caller_id_number'] = $a_extensions[$id]['outbound_caller_id_number'];
+ $pconfig['vm-mailto'] = $a_extensions[$id]['vm-mailto'];
+ $pconfig['vm-attach-file'] = $a_extensions[$id]['vm-attach-file'];
+ $pconfig['user_context'] = $a_extensions[$id]['user_context'];
+ $pconfig['callgroup'] = $a_extensions[$id]['callgroup'];
+ $pconfig['auth-acl'] = $a_extensions[$id]['auth-acl'];
+ $pconfig['cidr'] = $a_extensions[$id]['cidr'];
+ $pconfig['description'] = $a_extensions[$id]['description'];
+
+}
+
+if ($_POST) {
+
+ unset($input_errors);
+ $pconfig = $_POST;
+
+
+ if (!$input_errors) {
+
+ $ent = array();
+ $ent['extension'] = $_POST['extension'];
+ $ent['password'] = $_POST['password'];
+ $ent['mailbox'] = $_POST['mailbox'];
+ $ent['vm-password'] = $_POST['vm-password'];
+ $ent['accountcode'] = $_POST['accountcode'];
+ $ent['effective_caller_id_name'] = $_POST['effective_caller_id_name'];
+ $ent['effective_caller_id_number'] = $_POST['effective_caller_id_number'];
+ $ent['outbound_caller_id_name'] = $_POST['outbound_caller_id_name'];
+ $ent['outbound_caller_id_number'] = $_POST['outbound_caller_id_number'];
+ $ent['vm-mailto'] = $_POST['vm-mailto'];
+ $ent['vm-attach-file'] = $_POST['vm-attach-file'];
+ $ent['user_context'] = $_POST['user_context'];
+ $ent['callgroup'] = $_POST['callgroup'];
+ $ent['auth-acl'] = $_POST['auth-acl'];
+ $ent['cidr'] = $_POST['cidr'];
+
+ $ent['description'] = $_POST['description'];
+
+ if (isset($id) && $a_extensions[$id]) {
+ //update
+ $a_extensions[$id] = $ent;
+ }
+ else {
+ //add
+ $a_extensions[] = $ent;
+ }
+
+ write_config();
+ sync_package_freeswitch_extensions();
+
+ header("Location: freeswitch_extensions.php");
+ exit;
+ }
+}
+
+include("head.inc");
+
+?>
+
+<script type="text/javascript" language="JavaScript">
+
+function show_advanced_config() {
+ document.getElementById("showadvancedbox").innerHTML='';
+ aodiv = document.getElementById('showadvanced');
+ aodiv.style.display = "block";
+}
+
+</script>
+
+<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
+<?php include("fbegin.inc"); ?>
+<p class="pgtitle">FreeSWITCH: Extensions: Edit</p>
+<?php if ($input_errors) print_input_errors($input_errors); ?>
+
+
+<div id="mainlevel">
+<table width="100%" border="0" cellpadding="0" cellspacing="0">
+<tr><td class="tabnavtbl">
+<?php
+
+ $tab_array = array();
+ $tab_array[] = array(gettext("Settings"), false, "/pkg_edit.php?xml=freeswitch.xml&amp;id=0");
+ $tab_array[] = array(gettext("Dialplan"), false, "/freeswitch/freeswitch_dialplan_includes.php");
+ $tab_array[] = array(gettext("Extensions"), true, "/freeswitch/freeswitch_extensions.php");
+ $tab_array[] = array(gettext("External"), false, "/pkg_edit.php?xml=freeswitch_external.xml&amp;id=0");
+ $tab_array[] = array(gettext("Gateways"), false, "/freeswitch/freeswitch_gateways.php");
+ $tab_array[] = array(gettext("Internal"), false, "/pkg_edit.php?xml=freeswitch_internal.xml&amp;id=0");
+ $tab_array[] = array(gettext("IVR"), false, "/freeswitch/freeswitch_ivr.php");
+ $tab_array[] = array(gettext("Modules"), false, "/pkg_edit.php?xml=freeswitch_modules.xml&amp;id=0");
+ $tab_array[] = array(gettext("Public"), false, "/freeswitch/freeswitch_public_includes.php");
+ $tab_array[] = array(gettext("Rec"), false, "/freeswitch/freeswitch_recordings.php");
+ $tab_array[] = array(gettext("Status"), false, "/freeswitch/freeswitch_status.php");
+ $tab_array[] = array(gettext("Vars"), false, "/pkg_edit.php?xml=freeswitch_vars.xml&amp;id=0");
+ display_top_tabs($tab_array);
+
+?>
+</td></tr>
+</table>
+<table width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr>
+ <td class="tabcont" >
+
+
+ <table width="100%" border="0" cellpadding="6" cellspacing="0">
+ <tr>
+ <td><p><span class="vexpl"><span class="red"><strong>Extension Setup<br>
+ </strong></span>
+ /usr/local/freeswitch/conf/directory/default/
+ </p></td>
+ </tr>
+ </table>
+ <br />
+
+ <form action="freeswitch_extensions_edit.php" method="post" name="iform" id="iform">
+ <table width="100%" border="0" cellpadding="6" cellspacing="0">
+
+ <tr>
+ <td width="25%" valign="top" class="vncellreq">Extension</td>
+ <td width="75%" class="vtable">
+ <input name="extension" type="text" class="formfld" id="extension" size="40" value="<?=htmlspecialchars($pconfig['extension']);?>">
+ <br><span class="vexpl">Enter the extension here. The default configuration expects extension numbers between 1000 -1019. To use 3 digit extensions adjust the dialplan 'default.xml' under name="Local_Extension" change the regular expression="^(10[01][0-9])$" to expression="^(\d{3})$".<br></span>
+ </td>
+ </tr>
+ <tr>
+ <td width="25%" valign="top" class="vncellreq">Password</td>
+ <td width="75%" class="vtable">
+ <input name="password" type="password" class="formfld" id="password" size="40" value="<?=htmlspecialchars($pconfig['password']);?>">
+ <br><span class="vexpl">Enter the password here.<br></span>
+ </td>
+ </tr>
+ <tr>
+ <td width="25%" valign="top" class="vncellreq">Mailbox</td>
+ <td width="75%" class="vtable">
+ <input name="mailbox" type="text" class="formfld" id="mailbox" size="40" value="<?=htmlspecialchars($pconfig['mailbox']);?>">
+ <br><span class="vexpl">Enter the mailbox here. Example: extension 1001 then mailbox 1001<br></span>
+ </td>
+ </tr>
+ <tr>
+ <td width="25%" valign="top" class="vncellreq">Voicemail Password</td>
+ <td width="75%" class="vtable">
+ <input name="vm-password" type="password" class="formfld" id="vm-password" size="40" value="<?=htmlspecialchars($pconfig['vm-password']);?>">
+ <br><span class="vexpl">Enter the voicemail password here.<br></span>
+ </td>
+ </tr>
+ <tr>
+ <td width="25%" valign="top" class="vncellreq">Account Code</td>
+ <td width="75%" class="vtable">
+ <input name="accountcode" type="text" class="formfld" id="accountcode" size="40" value="<?=htmlspecialchars($pconfig['accountcode']);?>">
+ <br><span class="vexpl">Enter the account code here. Example: extension 1001 then accountcode 1001<br></span>
+ </td>
+ </tr>
+ <tr>
+ <td width="25%" valign="top" class="vncellreq" nowrap>Effective Caller ID Name</td>
+ <td width="75%" class="vtable">
+ <input name="effective_caller_id_name" type="text" class="formfld" id="effective_caller_id_name" size="40" value="<?=htmlspecialchars($pconfig['effective_caller_id_name']);?>">
+ <br><span class="vexpl">Enter the effective caller id name here.<br></span>
+ </td>
+ </tr>
+ <tr>
+ <td width="25%" valign="top" class="vncellreq" nowrap>Effective Caller ID Number</td>
+ <td width="75%" class="vtable">
+ <input name="effective_caller_id_number" type="text" class="formfld" id="effective_caller_id_number" size="40" value="<?=htmlspecialchars($pconfig['effective_caller_id_number']);?>">
+ <br><span class="vexpl">Enter the effective caller id number here.<br></span>
+ </td>
+ </tr>
+ <!--
+ <tr>
+ <td width="25%" valign="top" class="vncellreq" nowrap>Outbound Caller ID Name</td>
+ <td width="75%" class="vtable">
+ <input name="outbound_caller_id_name" type="text" class="formfld" id="outbound_caller_id_name" size="40" value="<?=htmlspecialchars($pconfig['outbound_caller_id_name']);?>">
+ <br><span class="vexpl">Enter the outbound caller id name here.<br></span>
+ </td>
+ </tr>
+ <tr>
+ <td width="25%" valign="top" class="vncellreq" nowrap>Outbound Caller ID Number</td>
+ <td width="75%" class="vtable">
+ <input name="outbound_caller_id_number" type="text" class="formfld" id="outbound_caller_id_number" size="40" value="<?=htmlspecialchars($pconfig['outbound_caller_id_number']);?>">
+ <br><span class="vexpl">Enter the outbound caller id number here.<br></span>
+ </td>
+ </tr>
+ -->
+ <tr>
+ <td width="25%" valign="top" class="vncellreq" nowrap>Voicemail Mail To</td>
+ <td width="75%" class="vtable">
+ <input name="vm-mailto" type="text" class="formfld" id="vm-mailto" size="40" value="<?=htmlspecialchars($pconfig['vm-mailto']);?>">
+ <br><span class="vexpl">Optional: Enter the email address to send voicemail to.<br></span>
+ </td>
+ </tr>
+ <tr>
+ <td width="25%" valign="top" class="vncellreq" nowrap>Voicemail Attach File</td>
+ <td width="75%" class="vtable">
+ <?php
+ echo " <select name='vm-attach-file' class='formfld'>\n";
+ echo " <option></option>\n";
+ switch (htmlspecialchars($pconfig['vm-attach-file'])) {
+ case "true":
+ echo " <option value='true' selected='yes'>true</option>\n";
+ echo " <option value='false'>false</option>\n";
+ break;
+ case "false":
+ echo " <option value='true'>true</option>\n";
+ echo " <option value='false' selected='yes'>false</option>\n";
+
+ break;
+ default:
+ echo " <option value='true' selected='yes'>true</option>\n";
+ echo " <option value='false'>false</option>\n";
+ }
+ echo " </select>\n";
+ ?>
+ Choose whether to attach the file to the email.
+ </td>
+ </tr>
+ <tr>
+ <td width="25%" valign="top" class="vncellreq">User Context</td>
+ <td width="75%" class="vtable">
+ <input name="user_context" type="text" class="formfld" id="user_context" size="40" value="<?=htmlspecialchars($pconfig['user_context']);?>">
+ <br><span class="vexpl">Enter the user context here. Example: default<br></span>
+ </td>
+ </tr>
+ <tr>
+ <td width="25%" valign="top" class="vncellreq">Call Group</td>
+ <td width="75%" class="vtable">
+ <input name="callgroup" type="text" class="formfld" id="callgroup" size="40" value="<?=htmlspecialchars($pconfig['callgroup']);?>">
+ <br><span class="vexpl">Enter the user call group here. Example: sales, support<br></span>
+ </td>
+ </tr>
+ </table>
+
+ <div id="showadvancedbox">
+ <table width="100%" border="0" cellpadding="6" cellspacing="0">
+ <tr>
+ <td width="25%" valign="top" class="vncell">Show Advanced</td>
+ <td width="75%" class="vtable">
+ <input type="button" onClick="show_advanced_config()" value="Advanced"></input></a>
+ </td>
+ </tr>
+ </table>
+ </div>
+ <div id="showadvanced" style="display:none">
+ <table width="100%" border="0" cellpadding="6" cellspacing="0">
+ <tr>
+ <td width="25%" valign="top" class="vncell">Auth-ACL</td>
+ <td width="75%" class="vtable">
+ <input name="auth-acl" type="text" class="formfld" id="auth-acl" size="40" value="<?=htmlspecialchars($pconfig['auth-acl']);?>">
+ <br> <span class="vexpl">Enter the auth acl here.<br></span>
+ </td>
+ </tr>
+ <tr>
+ <td valign="top" class="vncell">CIDR</td>
+ <td class="vtable">
+ <input name="cidr" type="text" class="formfld" id="cidr" size="40" value="<?=htmlspecialchars($pconfig['cidr']);?>">
+ <br> <span class="vexpl">Enter the cidr here.<br></span>
+ </td>
+ </tr>
+ </table>
+ </div>
+
+ <table width="100%" border="0" cellpadding="6" cellspacing="0">
+ <tr>
+ <td width="25%" valign="top" class="vncellreq">Extension Description</td>
+ <td width="75%" class="vtable">
+ <input name="description" type="text" class="formfld" id="description" size="40" value="<?=htmlspecialchars($pconfig['description']);?>">
+ <br><span class="vexpl">Enter the description of the extension here.<br></span>
+ </td>
+ </tr>
+ <tr>
+ <td valign="top">&nbsp;</td>
+ <td>
+ <input name="outbound_caller_id_name" type="hidden" class="formfld" id="outbound_caller_id_name" size="40" value="<?=htmlspecialchars($pconfig['outbound_caller_id_name']);?>">
+ <input name="outbound_caller_id_number" type="hidden" class="formfld" id="outbound_caller_id_number" size="40" value="<?=htmlspecialchars($pconfig['outbound_caller_id_number']);?>">
+ <input name="Submit" type="submit" class="formbtn" value="Save"> <input class="formbtn" type="button" value="Cancel" onclick="history.back()">
+ <?php if (isset($id) && $a_extensions[$id]): ?>
+ <input name="id" type="hidden" value="<?=$id;?>">
+ <?php endif; ?>
+ </td>
+ </tr>
+ </table>
+ </form>
+
+ <br>
+ <br>
+ <br>
+ <br>
+ <br>
+ <br>
+
+ </td>
+ </tr>
+</table>
+
+</div>
+
+<?php include("fend.inc"); ?>
+</body>
+</html>
diff --git a/config/freeswitch/freeswitch_external.xml b/config/freeswitch/freeswitch_external.xml
new file mode 100644
index 00000000..62fa9dd3
--- /dev/null
+++ b/config/freeswitch/freeswitch_external.xml
@@ -0,0 +1,136 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<!DOCTYPE packagegui SYSTEM "./schema/packages.dtd">
+<packagegui>
+ <copyright>
+ <![CDATA[
+/* $Id$ */
+/* ========================================================================== */
+/*
+
+ freeswitch_external.xml
+ Copyright (C) 2008 Mark J Crane
+ All rights reserved.
+
+ FreeSWITCH (TM)
+ http://www.freeswitch.org/
+
+ part of pfSense (http://www.pfSense.com)
+ Copyright (C) 2007 to whom it may belong
+ All rights reserved.
+
+ Based on m0n0wall (http://m0n0.ch/wall)
+ Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>.
+ All rights reserved.
+ */
+/* ========================================================================== */
+/*
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+ */
+/* ========================================================================== */
+ ]]>
+ </copyright>
+ <description>FreeSWITCH is an open source telephony platform designed to facilitate the creation of voice and chat driven products scaling from a soft-phone up to a soft-switch. It can be used as a simple switching engine, a PBX, a media gateway or a media server to host IVR applications using simple scripts or XML to control the callflow.</description>
+ <requirements>Describe your package requirements here</requirements>
+ <faq>Currently there are no FAQ items provided.</faq>
+ <name>freeswitchexternal</name>
+ <version>0.1</version>
+ <title>FreeSWITCH: External</title>
+ <aftersaveredirect>pkg_edit.php?xml=freeswitch_external.xml&amp;id=0</aftersaveredirect>
+ <include_file>/usr/local/pkg/freeswitch.inc</include_file>
+ <tabs>
+ <tab>
+ <text>Settings</text>
+ <url>/pkg_edit.php?xml=freeswitch.xml&amp;id=0</url>
+ </tab>
+ <tab>
+ <text>Dialplan</text>
+ <url>/freeswitch/freeswitch_dialplan_includes.php</url>
+ </tab>
+ <tab>
+ <text>Extensions</text>
+ <url>/freeswitch/freeswitch_extensions.php</url>
+ </tab>
+ <tab>
+ <text>External</text>
+ <url>/pkg_edit.php?xml=freeswitch_external.xml&amp;id=0</url>
+ <active/>
+ </tab>
+ <tab>
+ <text>Gateways</text>
+ <url>/freeswitch/freeswitch_gateways.php</url>
+ </tab>
+ <tab>
+ <text>Internal</text>
+ <url>/pkg_edit.php?xml=freeswitch_internal.xml&amp;id=0</url>
+ </tab>
+ <tab>
+ <text>IVR</text>
+ <url>/freeswitch/freeswitch_ivr.php</url>
+ </tab>
+ <tab>
+ <text>Modules</text>
+ <url>/pkg_edit.php?xml=freeswitch_modules.xml&amp;id=0</url>
+ </tab>
+ <tab>
+ <text>Public</text>
+ <url>/freeswitch/freeswitch_public_includes.php</url>
+ </tab>
+ <tab>
+ <text>Rec</text>
+ <url>/freeswitch/freeswitch_recordings.php</url>
+ </tab>
+ <tab>
+ <text>Status</text>
+ <url>/freeswitch/freeswitch_status.php</url>
+ </tab>
+ <tab>
+ <text>Vars</text>
+ <url>/pkg_edit.php?xml=freeswitch_vars.xml&amp;id=0</url>
+ </tab>
+ </tabs>
+ <configpath>installedpackages->package->$packagename->configuration->freeswitchexternal</configpath>
+ <fields>
+ <field>
+ <fielddescr>&lt;b&gt;External&lt;/b&gt; &lt;br /&gt; &lt;br /&gt;SIP external profile for outbound registrations.</fielddescr>
+ <fieldname>external_xml</fieldname>
+ <description>&lt;br /&gt;Path: /usr/local/freeswitch/conf/sip_profiles/external.xml &lt;br /&gt;&lt;br /&gt;</description>
+ <type>textarea</type>
+ <encoding>base64</encoding>
+ <wrap>off</wrap>
+ <size>30</size>
+ <cols>70</cols>
+ <rows>33</rows>
+ </field>
+ </fields>
+ <custom_php_command_before_form>
+ </custom_php_command_before_form>
+ <custom_php_after_head_command>
+ sync_package_freeswitch_external();
+ </custom_php_after_head_command>
+ <custom_php_after_form_command>
+ </custom_php_after_form_command>
+ <custom_php_validation_command>
+ </custom_php_validation_command>
+ <custom_php_resync_config_command>
+ sync_package_freeswitch_external();
+ </custom_php_resync_config_command>
+</packagegui> \ No newline at end of file
diff --git a/config/freeswitch/freeswitch_gateways.tmp b/config/freeswitch/freeswitch_gateways.tmp
new file mode 100644
index 00000000..75718a7c
--- /dev/null
+++ b/config/freeswitch/freeswitch_gateways.tmp
@@ -0,0 +1,209 @@
+<?php
+/* $Id$ */
+/*
+ freeswitch_gateways.php
+ Copyright (C) 2008 Mark J Crane
+ All rights reserved.
+
+ FreeSWITCH (TM)
+ http://www.freeswitch.org/
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+require("guiconfig.inc");
+require("/usr/local/pkg/freeswitch.inc");
+
+$a_gateways = &$config['installedpackages']['freeswitchgateways']['config'];
+
+
+if ($_GET['act'] == "del") {
+ if ($_GET['type'] == 'gateways') {
+ if ($a_gateways[$_GET['id']]) {
+ unset($a_gateways[$_GET['id']]);
+ write_config();
+ header("Location: freeswitch_gateways.php");
+ exit;
+ }
+ }
+}
+
+include("head.inc");
+
+?>
+
+
+<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
+<?php include("fbegin.inc"); ?>
+<p class="pgtitle">FreeSWITCH: Gateways</p>
+
+<div id="mainlevel">
+<table width="100%" border="0" cellpadding="0" cellspacing="0">
+<tr><td class="tabnavtbl">
+<?php
+
+ $tab_array = array();
+ $tab_array[] = array(gettext("Settings"), false, "/pkg_edit.php?xml=freeswitch.xml&amp;id=0");
+ $tab_array[] = array(gettext("Dialplan"), false, "/freeswitch/freeswitch_dialplan_includes.php");
+ $tab_array[] = array(gettext("Extensions"), false, "/freeswitch/freeswitch_extensions.php");
+ $tab_array[] = array(gettext("External"), false, "/pkg_edit.php?xml=freeswitch_external.xml&amp;id=0");
+ $tab_array[] = array(gettext("Gateways"), true, "/freeswitch/freeswitch_gateways.php");
+ $tab_array[] = array(gettext("Internal"), false, "/pkg_edit.php?xml=freeswitch_internal.xml&amp;id=0");
+ $tab_array[] = array(gettext("IVR"), false, "/freeswitch/freeswitch_ivr.php");
+ $tab_array[] = array(gettext("Modules"), false, "/pkg_edit.php?xml=freeswitch_modules.xml&amp;id=0");
+ $tab_array[] = array(gettext("Public"), false, "/freeswitch/freeswitch_public_includes.php");
+ $tab_array[] = array(gettext("Rec"), false, "/freeswitch/freeswitch_recordings.php");
+ $tab_array[] = array(gettext("Status"), false, "/freeswitch/freeswitch_status.php");
+ $tab_array[] = array(gettext("Vars"), false, "/pkg_edit.php?xml=freeswitch_vars.xml&amp;id=0");
+ display_top_tabs($tab_array);
+
+?>
+</td></tr>
+</table>
+
+<table width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr>
+ <td class="tabcont" >
+
+<form action="freeswitch_gateways.php" method="post" name="iform" id="iform">
+<?php
+
+if ($config_change == 1) {
+ write_config();
+ $config_change = 0;
+}
+
+//if ($savemsg) print_info_box($savemsg);
+//if (file_exists($d_hostsdirty_path)): echo"<p>";
+//print_info_box_np("The FreeSWITCH gateways have been changed.<br>You must apply the changes in order for them to take effect.");
+//echo"<br />";
+//endif;
+
+?>
+ <table width="100%" border="0" cellpadding="6" cellspacing="0">
+ <tr>
+ <td><p><span class="vexpl"><span class="red"><strong>Gateways<br>
+ </strong></span>
+ Use this to configure your SIP gateways also known as providers.
+ </p></td>
+ </tr>
+ </table>
+ <br />
+
+ <table width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr>
+ <td width="20%" class="listhdrr">Gateway</td>
+ <td width="25%" class="listhdrr">Context</td>
+ <td width="25%" class="listhdrr">Enabled</td>
+ <td width="25%" class="listhdr">Description</td>
+ <td width="10%" class="list">
+
+ <table border="0" cellspacing="0" cellpadding="1">
+ <tr>
+ <td width="17"></td>
+ <td valign="middle"><a href="freeswitch_gateways_edit.php"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"></a></td>
+ </tr>
+ </table>
+
+ </td>
+ </tr>
+
+
+ <?php
+
+ $i = 0;
+ if (count($a_gateways) > 0) {
+
+ foreach ($a_gateways as $ent) {
+
+ ?>
+ <tr>
+ <td class="listr" ondblclick="document.location='freeswitch_gateways_edit.php?id=<?=$i;?>';">
+ <?=$ent['gateway'];?>&nbsp;
+ </td>
+ <td class="listr" ondblclick="document.location='freeswitch_gateways_edit.php?id=<?=$i;?>';">
+ <?=$ent['context'];?>&nbsp;
+ </td>
+ <td class="listr" ondblclick="document.location='freeswitch_gateways_edit.php?id=<?=$i;?>';">
+ <?=$ent['enabled'];?>&nbsp;
+ </td>
+ <td class="listbg" ondblclick="document.location='freeswitch_gateways_edit.php?id=<?=$i;?>';">
+ <font color="#FFFFFF"><?=htmlspecialchars($ent['description']);?>&nbsp;
+ </td>
+ <td valign="middle" nowrap class="list">
+ <table border="0" cellspacing="0" cellpadding="1">
+ <tr>
+ <td valign="middle"><a href="freeswitch_gateways_edit.php?id=<?=$i;?>"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" width="17" height="17" border="0"></a></td>
+ <td><a href="freeswitch_gateways.php?type=gateways&act=del&id=<?=$i;?>" onclick="return confirm('Do you really want to delete this?')"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0"></a></td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ <?php
+
+ $i++;
+ }
+ }
+ ?>
+
+ <tr>
+ <td class="list" colspan="4"></td>
+ <td class="list">
+ <table border="0" cellspacing="0" cellpadding="1">
+ <tr>
+ <td width="17"></td>
+ <td valign="middle"><a href="freeswitch_gateways_edit.php"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"></a></td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+
+
+ <tr>
+ <td class="list" colspan="4"></td>
+ <td class="list"></td>
+ </tr>
+ </table>
+
+</form>
+
+
+/usr/local/freeswitch/conf/sip_profiles/external/
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+
+</td>
+</tr>
+</table>
+
+</div>
+
+
+<?php include("fend.inc"); ?>
+</body>
+</html>
diff --git a/config/freeswitch/freeswitch_gateways_edit.tmp b/config/freeswitch/freeswitch_gateways_edit.tmp
new file mode 100644
index 00000000..030f88cf
--- /dev/null
+++ b/config/freeswitch/freeswitch_gateways_edit.tmp
@@ -0,0 +1,596 @@
+<?php
+/* $Id$ */
+/*
+
+ freeswitch_gateways_edit.php
+ Copyright (C) 2008 Mark J Crane
+ All rights reserved.
+
+ FreeSWITCH (TM)
+ http://www.freeswitch.org/
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+require("guiconfig.inc");
+require("/usr/local/pkg/freeswitch.inc");
+
+
+$a_gateways = &$config['installedpackages']['freeswitchgateways']['config'];
+
+$id = $_GET['id'];
+if (isset($_POST['id'])) {
+ $id = $_POST['id'];
+}
+
+if (isset($id) && $a_gateways[$id]) {
+
+ $pconfig['gatewayid'] = $a_gateways[$id]['gatewayid'];
+ $gatewayid = $a_gateways[$id]['gatewayid'];
+ $pconfig['gateway'] = $a_gateways[$id]['gateway'];
+ $pconfig['username'] = $a_gateways[$id]['username'];
+ $pconfig['password'] = $a_gateways[$id]['password'];
+ $pconfig['realm'] = $a_gateways[$id]['realm'];
+ $pconfig['from-user'] = $a_gateways[$id]['from-user'];
+ $pconfig['from-domain'] = $a_gateways[$id]['from-domain'];
+ $pconfig['proxy'] = $a_gateways[$id]['proxy'];
+ $pconfig['expire-seconds'] = $a_gateways[$id]['expire-seconds'];
+ $pconfig['register'] = $a_gateways[$id]['register'];
+ $pconfig['register-transport'] = $a_gateways[$id]['register-transport'];
+ $pconfig['retry-seconds'] = $a_gateways[$id]['retry-seconds'];
+ $pconfig['extension'] = $a_gateways[$id]['extension'];
+ $pconfig['context'] = $a_gateways[$id]['context'];
+ $pconfig['caller-id-in-from'] = $a_gateways[$id]['caller-id-in-from'];
+ $pconfig['supress-cng'] = $a_gateways[$id]['supress-cng'];
+ $pconfig['enabled'] = $a_gateways[$id]['enabled'];
+ $pconfig['description'] = $a_gateways[$id]['description'];
+}
+
+if ($_POST) {
+
+ unset($input_errors);
+ $pconfig = $_POST;
+
+
+ if (!$input_errors) {
+
+ $ent = array();
+ if (strlen($_POST['ivrid']) > 0) {
+ $ent['gatewayid'] = $_POST['ivrid'];
+ }
+ else {
+ $ent['gatewayid'] = guid();
+ }
+ $ent['gateway'] = $_POST['gateway'];
+ $ent['username'] = $_POST['username'];
+ $ent['password'] = $_POST['password'];
+ $ent['realm'] = $_POST['realm'];
+ $ent['from-user'] = $_POST['from-user'];
+ $ent['from-domain'] = $_POST['from-domain'];
+ $ent['proxy'] = $_POST['proxy'];
+ $ent['expire-seconds'] = $_POST['expire-seconds'];
+ $ent['register'] = $_POST['register'];
+ $ent['register-transport'] = $_POST['register-transport'];
+ $ent['retry-seconds'] = $_POST['retry-seconds'];
+ $ent['extension'] = $_POST['extension'];
+ $ent['context'] = $_POST['context'];
+ $ent['caller-id-in-from'] = $_POST['caller-id-in-from'];
+ $ent['supress-cng'] = $_POST['supress-cng'];
+ $ent['enabled'] = $_POST['enabled'];
+ $ent['description'] = $_POST['description'];
+
+
+ if (isset($id) && $a_gateways[$id]) {
+ //update
+ $a_gateways[$id] = $ent;
+ }
+ else {
+ //add
+ $a_gateways[] = $ent;
+ }
+
+
+
+ if (strlen(trim($_POST['dialplan_expression']))> 0) {
+
+ $gatewayid = $_POST['gatewayid'];
+ $gateway = $_POST['gateway'];
+ $context = $_POST['context'];
+
+ $default_area_code = &$config['installedpackages']['freeswitchsettings']['config'][0]['default_area_code'];
+ $a_dialplan_includes = &$config['installedpackages']['freeswitchdialplanincludes']['config'];
+ $a_dialplan_include_details = &$config['installedpackages']['freeswitchdialplanincludedetails']['config'];
+
+
+ $tmp_array = split("\\\n", $_POST['dialplan_expression']);
+
+ foreach($tmp_array as $dialplan_expression) {
+
+ $dialplan_expression = trim($dialplan_expression);
+ if (strlen($dialplan_expression)>0) {
+
+ switch ($dialplan_expression) {
+ case "^(\d{7})$":
+ $action_data = "sofia/gateway/".$gateway."/1".$default_area_code."\$1";
+ $label = "7 digits";
+ $abbrv = "7d";
+ break;
+ case "^(\d{10})$":
+ $action_data = "sofia/gateway/".$gateway."/1\$1";
+ $label = "10 digits";
+ $abbrv = "10d";
+ break;
+ case "^(\d{11})$":
+ $action_data = "sofia/gateway/".$gateway."/\$1";
+ $label = "11 digits";
+ $abbrv = "11d";
+ break;
+ case "^311$":
+ $action_data = "sofia/gateway/".$gateway."/\$1";
+ $label = "311";
+ $abbrv = "311";
+ break;
+ case "^411$":
+ $action_data = "sofia/gateway/".$gateway."/\$1";
+ $label = "411";
+ $abbrv = "411";
+ break;
+ case "^911$":
+ $action_data = "sofia/gateway/".$gateway."/\$1";
+ $label = "911";
+ $abbrv = "911";
+ break;
+ case "^9(\d{3})$":
+ $action_data = "sofia/gateway/".$gateway."/1".$default_area_code."\$1";
+ $label = "dial 9, 3 digits";
+ $abbrv = "9.3d";
+ break;
+ case "^9(\d{4})$":
+ $action_data = "sofia/gateway/".$gateway."/1".$default_area_code."\$1";
+ $label = "dial 9, 4 digits";
+ $abbrv = "9.4d";
+ break;
+ case "^9(\d{7})$":
+ $action_data = "sofia/gateway/".$gateway."/1".$default_area_code."\$1";
+ $label = "dial 9, 7 digits";
+ $abbrv = "9.7d";
+ break;
+ case "^9(\d{10})$":
+ $action_data = "sofia/gateway/".$gateway."/\$1";
+ $label = "dial 9, 10 digits";
+ $abbrv = "9.10d";
+ break;
+ case "^9(\d{11})$":
+ $action_data = "sofia/gateway/".$gateway."/\$1";
+ $label = "dial 9, 11 digits";
+ $abbrv = "9.11d";
+ break;
+ case "^1?(8(00|55|66|77|88)[2-9]\d{6})$":
+ $action_data = "sofia/gateway/".$gateway."/\$1";
+ $label = "toll free";
+ $abbrv = "tollfree";
+ break;
+ default:
+ $action_data = "sofia/gateway/".$gateway."/\$1";
+ $label = $dialplan_expression;
+ $abbrv = $dialplan_expression;
+ }
+
+ $dialplanincludeid = guid();
+ $ent['dialplanincludeid'] = $dialplanincludeid;
+ $ent['extensionname'] = $gateway.".".$abbrv;
+ $ent['order'] = '9002'; //if update use the existing order number and extension name and desc
+ $ent['context'] = $context;
+ $ent['enabled'] = 'true';
+ $ent['descr'] = $label.' '.$gateway;
+ $ent['opt1name'] = 'gatewayid';
+ $ent['opt1value'] = $gatewayid;
+ $a_dialplan_includes[] = $ent;
+ unset($ent);
+
+ $ent = array();
+ $ent['dialplanincludeid'] = $dialplanincludeid;
+ $ent['tag'] = 'condition'; //condition, action, antiaction
+ $ent['fieldtype'] = 'destination_number';
+ $ent['fielddata'] = $dialplan_expression;
+ $a_dialplan_include_details[] = $ent;
+ unset($ent);
+
+ $ent = array();
+ $ent['dialplanincludeid'] = $dialplanincludeid;
+ $ent['tag'] = 'action'; //condition, action, antiaction
+ $ent['fieldtype'] = 'bridge';
+ $ent['fielddata'] = $action_data;
+ $a_dialplan_include_details[] = $ent;
+ unset($ent);
+
+ unset($label);
+ unset($abbrv);
+ unset($dialplan_expression);
+ unset($action_data);
+ } //if strlen
+ } //end for each
+ }
+
+ write_config();
+ sync_package_freeswitch_gateways();
+ sync_package_freeswitch_dialplan_includes();
+
+ header("Location: freeswitch_gateways.php");
+ exit;
+ }
+}
+
+include("head.inc");
+
+?>
+
+
+<script type="text/javascript" language="JavaScript">
+
+function enable_change(enable_over) {
+ var endis;
+ endis = !(document.iform.enable.checked || enable_over);
+ document.iform.range_from.disabled = endis;
+ document.iform.range_to.disabled = endis;
+}
+
+function show_advanced_config() {
+ document.getElementById("showadvancedbox").innerHTML='';
+ aodiv = document.getElementById('showadvanced');
+ aodiv.style.display = "block";
+}
+
+</script>
+
+
+<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
+<?php include("fbegin.inc"); ?>
+<p class="pgtitle">FreeSWITCH: Gateways: Edit</p>
+<?php if ($input_errors) print_input_errors($input_errors); ?>
+
+
+<div id="mainlevel">
+<table width="100%" border="0" cellpadding="0" cellspacing="0">
+<tr><td class="tabnavtbl">
+<?php
+
+ $tab_array = array();
+ $tab_array[] = array(gettext("Settings"), false, "/pkg_edit.php?xml=freeswitch.xml&amp;id=0");
+ $tab_array[] = array(gettext("Dialplan"), false, "/freeswitch/freeswitch_dialplan_includes.php");
+ $tab_array[] = array(gettext("Extensions"), false, "/freeswitch/freeswitch_extensions.php");
+ $tab_array[] = array(gettext("External"), false, "/pkg_edit.php?xml=freeswitch_external.xml&amp;id=0");
+ $tab_array[] = array(gettext("Gateways"), true, "/freeswitch/freeswitch_gateways.php");
+ $tab_array[] = array(gettext("Internal"), false, "/pkg_edit.php?xml=freeswitch_internal.xml&amp;id=0");
+ $tab_array[] = array(gettext("IVR"), false, "/freeswitch/freeswitch_ivr.php");
+ $tab_array[] = array(gettext("Modules"), false, "/pkg_edit.php?xml=freeswitch_modules.xml&amp;id=0");
+ $tab_array[] = array(gettext("Public"), false, "/freeswitch/freeswitch_public_includes.php");
+ $tab_array[] = array(gettext("Rec"), false, "/freeswitch/freeswitch_recordings.php");
+ $tab_array[] = array(gettext("Status"), false, "/freeswitch/freeswitch_status.php");
+ $tab_array[] = array(gettext("Vars"), false, "/pkg_edit.php?xml=freeswitch_vars.xml&amp;id=0");
+ display_top_tabs($tab_array);
+
+?>
+</td></tr>
+</table>
+<table width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr>
+ <td class="tabcont" >
+
+
+ <table width="100%" border="0" cellpadding="6" cellspacing="0">
+ <tr>
+ <td><p><span class="vexpl"><span class="red"><strong>Gateway Setup<br>
+ </strong></span>
+ The 'SIP Provider Examples' from the FreeSWITCH wiki can be used as reference to get started. <br />
+ <a href='http://wiki.freeswitch.org/wiki/SIP_Provider_Examples' target='_blank'>http://wiki.freeswitch.org/wiki/SIP_Provider_Examples</a>
+ </p></td>
+ </tr>
+ </table>
+ <br />
+
+ <form action="freeswitch_gateways_edit.php" method="post" name="iform" id="iform">
+ <table width="100%" border="0" cellpadding="6" cellspacing="0">
+ <tr>
+ <td width="22%" valign="top" class="vncellreq">Gateway</td>
+ <td width="78%" class="vtable">
+ <input name="gateway" type="text" class="formfld" id="gateway" size="40" value="<?=htmlspecialchars($pconfig['gateway']);?>">
+ <br><span class="vexpl">Enter the gateway name here.<br></span>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncellreq">Username</td>
+ <td width="78%" class="vtable">
+ <input name="username" type="text" class="formfld" id="username" size="40" value="<?=htmlspecialchars($pconfig['username']);?>">
+ <br><span class="vexpl">Enter the username here.<br></span>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncellreq">Password</td>
+ <td width="78%" class="vtable">
+ <input name="password" type="password" class="formfld" id="password" size="40" value="<?=htmlspecialchars($pconfig['password']);?>">
+ <br><span class="vexpl">Enter the password here.<br></span>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncellreq">From-user</td>
+ <td width="78%" class="vtable">
+ <input name="from-user" type="text" class="formfld" id="from-user" size="40" value="<?=htmlspecialchars($pconfig['from-user']);?>">
+ <br><span class="vexpl">Enter the from-user here.<br></span>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncellreq">From-domain</td>
+ <td width="78%" class="vtable">
+ <input name="from-domain" type="text" class="formfld" id="from-domain" size="40" value="<?=htmlspecialchars($pconfig['from-domain']);?>">
+ <br><span class="vexpl">Enter the from-domain here.<br></span>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncellreq">Proxy</td>
+ <td width="78%" class="vtable">
+ <input name="proxy" type="text" class="formfld" id="proxy" size="40" value="<?=htmlspecialchars($pconfig['proxy']);?>">
+ <br><span class="vexpl">Enter the proxy here.<br></span>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncellreq">Realm</td>
+ <td width="78%" class="vtable">
+ <input name="realm" type="text" class="formfld" id="realm" size="40" value="<?=htmlspecialchars($pconfig['realm']);?>">
+ <br><span class="vexpl">Enter the realm here.<br></span>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncellreq">Expire-seconds</td>
+ <td width="78%" class="vtable">
+ <input name="expire-seconds" type="text" class="formfld" id="expire-seconds" size="40" value="<?=htmlspecialchars($pconfig['expire-seconds']);?>">
+ <br><span class="vexpl">Enter the expire-seconds here. Example: 600<br></span>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncellreq">Register</td>
+ <td width="78%" class="vtable">
+ <?php
+ echo " <select name='register' class='formfld'>\n";
+ echo " <option></option>\n";
+ switch (htmlspecialchars($pconfig['register'])) {
+ case "true":
+ echo " <option value='true' selected='yes'>true</option>\n";
+ echo " <option value='false'>false</option>\n";
+ break;
+ case "false":
+ echo " <option value='true'>true</option>\n";
+ echo " <option value='false' selected='yes'>false</option>\n";
+
+ break;
+ default:
+ echo " <option value='true' selected='yes'>true</option>\n";
+ echo " <option value='false'>false</option>\n";
+ }
+ echo " </select>\n";
+ ?>
+ Choose whether to register.
+ </td>
+ </tr>
+
+ <tr>
+ <td width="22%" valign="top" class="vncellreq">Retry-seconds</td>
+ <td width="78%" class="vtable">
+ <input name="retry-seconds" type="text" class="formfld" id="retry-seconds" size="40" value="<?=htmlspecialchars($pconfig['retry-seconds']);?>">
+ <br> <span class="vexpl">Enter the retry_seconds here. Example: 30<br></span>
+ </td>
+ </tr>
+
+ <tr>
+ <td width="22%" valign="top" class="vncellreq">Context</td>
+ <td width="78%" class="vtable">
+ <input name="context" type="text" class="formfld" id="context" size="40" value="<?=htmlspecialchars($pconfig['context']);?>">
+ <br> <span class="vexpl">Enter the context here. Example: public<br></span>
+ </td>
+ </tr>
+ </table>
+ <div id="showadvancedbox">
+ <table width="100%" border="0" cellpadding="6" cellspacing="0">
+ <tr>
+ <td width="22%" valign="top" class="vncell">Show Advanced</td>
+ <td width="78%" class="vtable">
+ <input type="button" onClick="show_advanced_config()" value="Advanced"></input></a>
+ </td>
+ </tr>
+ </table>
+ </div>
+ <div id="showadvanced" style="display:none">
+ <table width="100%" border="0" cellpadding="6" cellspacing="0">
+ <tr>
+ <td width="22%" valign="top" class="vncell">Register-transport</td>
+ <td width="78%" class="vtable">
+ <?php
+ echo " <select name='register-transport' class='formfld'>\n";
+ echo " <option></option>\n";
+ switch (htmlspecialchars($pconfig['register-transport'])) {
+ case "udp":
+ echo " <option value='udp' selected='yes'>udp</option>\n";
+ echo " <option value='tcp'>tcp</option>\n";
+ break;
+ case "tcp":
+ echo " <option value='udp'>udp</option>\n";
+ echo " <option value='tcp' selected='yes'>tcp</option>\n";
+
+ break;
+ default:
+ echo " <option value='udp'>udp</option>\n";
+ echo " <option value='tcp'>tcp</option>\n";
+ }
+ echo " </select>\n";
+ ?>
+ Choose whether to register-transport.
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncell">Extension</td>
+ <td width="78%" class="vtable">
+ <input name="extension" type="text" class="formfld" id="extension" size="40" value="<?=htmlspecialchars($pconfig['extension']);?>">
+ <br> <span class="vexpl">Enter the extension here.<br></span>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncell">Caller-id-in-from</td>
+ <td width="78%" class="vtable">
+ <?php
+ echo " <select name='caller-id-in-from' class='formfld'>\n";
+ echo " <option></option>\n";
+ switch (htmlspecialchars($pconfig['caller-id-in-from'])) {
+ case "true":
+ echo " <option value='true' selected='yes'>true</option>\n";
+ echo " <option value='false'>false</option>\n";
+ break;
+ case "false":
+ echo " <option value='true'>true</option>\n";
+ echo " <option value='false' selected='yes'>false</option>\n";
+
+ break;
+ default:
+ echo " <option value='true'>true</option>\n";
+ echo " <option value='false'>false</option>\n";
+ }
+ echo " </select>\n";
+ ?>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncell">Supress-cng</td>
+ <td width="78%" class="vtable">
+ <?php
+ echo " <select name='supress-cng' class='formfld'>\n";
+ echo " <option></option>\n";
+ switch (htmlspecialchars($pconfig['supress-cng'])) {
+ case "true":
+ echo " <option value='true' selected='yes'>true</option>\n";
+ echo " <option value='false'>false</option>\n";
+ break;
+ case "false":
+ echo " <option value='true'>true</option>\n";
+ echo " <option value='false' selected='yes'>false</option>\n";
+
+ break;
+ default:
+ echo " <option value='true'>true</option>\n";
+ echo " <option value='false'>false</option>\n";
+ }
+ echo " </select>\n";
+ ?>
+ </td>
+ </tr>
+ </table>
+
+ </div>
+
+ <table width="100%" border="0" cellpadding="6" cellspacing="0">
+ <tr>
+ <td width="22%" valign="top" class="vncellreq">Enabled</td>
+ <td width="78%" class="vtable">
+ <?php
+ echo " <select name='enabled' class='formfld'>\n";
+ echo " <option></option>\n";
+ switch (htmlspecialchars($pconfig['enabled'])) {
+ case "true":
+ echo " <option value='true' selected='yes'>true</option>\n";
+ echo " <option value='false'>false</option>\n";
+ break;
+ case "false":
+ echo " <option value='true'>true</option>\n";
+ echo " <option value='false' selected='yes'>false</option>\n";
+
+ break;
+ default:
+ echo " <option value='true' selected='yes'>true</option>\n";
+ echo " <option value='false'>false</option>\n";
+ }
+ echo " </select>\n";
+ ?>
+ </td>
+ </tr>
+
+ <tr>
+ <td width="22%" valign="top" class="vncell">Dialplan Expression</td>
+ <td width="78%" class="vtable">
+ <?php
+ echo "<textarea name=\"dialplan_expression\" id=\"dialplan_expression\" cols=\"30\" rows=\"4\" wrap=\"off\"></textarea>\n";
+ ?>
+ <br>
+ <select name='dialplan_expression_select' id='dialplan_expression_select' onchange="document.getElementById('dialplan_expression').value += document.getElementById('dialplan_expression_select').value + '\n';" class='formfld'>
+ <option></option>
+ <option value='^(\d{7})$'>7 digits local</option>
+ <option value='^(\d{10})$'>10 digits long distance</option>
+ <option value='^(\d{11})$'>11 digits long distance</option>
+ <option value='^011(.*)$'>011 International</option>
+ <option value='^311$'>311 information</option>
+ <option value='^411$'>411 information</option>
+ <option value='^911$'>911 emergency</option>
+ <option value='^1?(8(00|55|66|77|88)[2-9]\d{6})$'>toll free</option>
+ <option value='^9(\d{3})$'>Dial 9 then 3 digits</option>
+ <option value='^9(\d{4})$'>Dial 9 then 4 digits</option>
+ <option value='^9(\d{7})$'>Dial 9 then 7 digits</option>
+ <option value='^9(\d{10})$'>Dial 9 then 10 digits</option>
+ <option value='^9(\d{11})$'>Dial 9 then 11 digits</option>
+ </select>
+ <span class="vexpl">
+ <br />
+ Shortcut to create the outbound dialplan entries for this Gateway. The entries are saved to and edited from the 'Dialplan' tab.
+ </span></td>
+ </tr>
+
+ <tr>
+ <td width="22%" valign="top" class="vncell">Gateway Description</td>
+ <td width="78%" class="vtable">
+ <input name="description" type="text" class="formfld" id="description" size="40" value="<?=htmlspecialchars($pconfig['description']);?>">
+ <br> <span class="vexpl">Enter the description of the gateway here.</span></td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top">&nbsp;</td>
+ <td width="78%">
+ <input name="Submit" type="submit" class="formbtn" value="Save"> <input class="formbtn" type="button" value="Cancel" onclick="history.back()">
+ <?php if (isset($id) && $a_gateways[$id]): ?>
+ <input name="id" type="hidden" value="<?=$id;?>">
+ <input name="gatewayid" type="hidden" value="<?=htmlspecialchars($pconfig['gatewayid']);?>">
+ <?php endif; ?>
+ </td>
+ </tr>
+ </table>
+ </form>
+
+ <br>
+ <br>
+ <br>
+ <br>
+ <br>
+ <br>
+
+ </td>
+ </tr>
+</table>
+
+</div>
+
+<?php include("fend.inc"); ?>
+</body>
+</html>
diff --git a/config/freeswitch/freeswitch_internal.xml b/config/freeswitch/freeswitch_internal.xml
new file mode 100644
index 00000000..4ae5848f
--- /dev/null
+++ b/config/freeswitch/freeswitch_internal.xml
@@ -0,0 +1,136 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<!DOCTYPE packagegui SYSTEM "./schema/packages.dtd">
+<packagegui>
+ <copyright>
+ <![CDATA[
+/* $Id$ */
+/* ========================================================================== */
+/*
+
+ freeswitch_internal.xml
+ Copyright (C) 2008 Mark J Crane
+ All rights reserved.
+
+ FreeSWITCH (TM)
+ http://www.freeswitch.org/
+
+ part of pfSense (http://www.pfSense.com)
+ Copyright (C) 2007 to whom it may belong
+ All rights reserved.
+
+ Based on m0n0wall (http://m0n0.ch/wall)
+ Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>.
+ All rights reserved.
+ */
+/* ========================================================================== */
+/*
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+ */
+/* ========================================================================== */
+ ]]>
+ </copyright>
+ <description>FreeSWITCH is an open source telephony platform designed to facilitate the creation of voice and chat driven products scaling from a soft-phone up to a soft-switch. It can be used as a simple switching engine, a PBX, a media gateway or a media server to host IVR applications using simple scripts or XML to control the callflow.</description>
+ <requirements>Describe your package requirements here</requirements>
+ <faq>Currently there are no FAQ items provided.</faq>
+ <name>freeswitchinternal</name>
+ <version>0.1</version>
+ <title>FreeSWITCH: Internal</title>
+ <aftersaveredirect>pkg_edit.php?xml=freeswitch_internal.xml&amp;id=0</aftersaveredirect>
+ <include_file>/usr/local/pkg/freeswitch.inc</include_file>
+ <tabs>
+ <tab>
+ <text>Settings</text>
+ <url>/pkg_edit.php?xml=freeswitch.xml&amp;id=0</url>
+ </tab>
+ <tab>
+ <text>Dialplan</text>
+ <url>/freeswitch/freeswitch_dialplan_includes.php</url>
+ </tab>
+ <tab>
+ <text>Extensions</text>
+ <url>/freeswitch/freeswitch_extensions.php</url>
+ </tab>
+ <tab>
+ <text>External</text>
+ <url>/pkg_edit.php?xml=freeswitch_external.xml&amp;id=0</url>
+ </tab>
+ <tab>
+ <text>Gateways</text>
+ <url>/freeswitch/freeswitch_gateways.php</url>
+ </tab>
+ <tab>
+ <text>Internal</text>
+ <url>/pkg_edit.php?xml=freeswitch_internal.xml&amp;id=0</url>
+ <active/>
+ </tab>
+ <tab>
+ <text>IVR</text>
+ <url>/freeswitch/freeswitch_ivr.php</url>
+ </tab>
+ <tab>
+ <text>Modules</text>
+ <url>/pkg_edit.php?xml=freeswitch_modules.xml&amp;id=0</url>
+ </tab>
+ <tab>
+ <text>Public</text>
+ <url>/freeswitch/freeswitch_public_includes.php</url>
+ </tab>
+ <tab>
+ <text>Rec</text>
+ <url>/freeswitch/freeswitch_recordings.php</url>
+ </tab>
+ <tab>
+ <text>Status</text>
+ <url>/freeswitch/freeswitch_status.php</url>
+ </tab>
+ <tab>
+ <text>Vars</text>
+ <url>/pkg_edit.php?xml=freeswitch_vars.xml&amp;id=0</url>
+ </tab>
+ </tabs>
+ <configpath>installedpackages->package->$packagename->configuration->freeswitchinternal</configpath>
+ <fields>
+ <field>
+ <fielddescr>&lt;b&gt;Internal&lt;/b&gt; &lt;br /&gt; &lt;br /&gt;SIP internal profile. </fielddescr>
+ <fieldname>internal_xml</fieldname>
+ <description>&lt;br /&gt;Path: /usr/local/freeswitch/conf/sip_profiles/internal.xml &lt;br /&gt;&lt;br /&gt;</description>
+ <type>textarea</type>
+ <encoding>base64</encoding>
+ <wrap>off</wrap>
+ <size>30</size>
+ <cols>70</cols>
+ <rows>33</rows>
+ </field>
+ </fields>
+ <custom_php_command_before_form>
+ </custom_php_command_before_form>
+ <custom_php_after_head_command>
+ sync_package_freeswitch_internal();
+ </custom_php_after_head_command>
+ <custom_php_after_form_command>
+ </custom_php_after_form_command>
+ <custom_php_validation_command>
+ </custom_php_validation_command>
+ <custom_php_resync_config_command>
+ sync_package_freeswitch_internal();
+ </custom_php_resync_config_command>
+</packagegui> \ No newline at end of file
diff --git a/config/freeswitch/freeswitch_ivr.tmp b/config/freeswitch/freeswitch_ivr.tmp
new file mode 100644
index 00000000..d05337ce
--- /dev/null
+++ b/config/freeswitch/freeswitch_ivr.tmp
@@ -0,0 +1,216 @@
+<?php
+/* $Id$ */
+/*
+ freeswitch_ivr.php
+ Copyright (C) 2008 Mark J Crane
+ All rights reserved.
+
+ FreeSWITCH (TM)
+ http://www.freeswitch.org/
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+require("guiconfig.inc");
+require("/usr/local/pkg/freeswitch.inc");
+
+
+$a_ivr = &$config['installedpackages']['freeswitchivr']['config'];
+
+
+if ($_GET['act'] == "del") {
+ if ($_GET['type'] == 'ivr') {
+ if ($a_ivr[$_GET['id']]) {
+ unset($a_ivr[$_GET['id']]);
+ write_config();
+ sync_package_freeswitch_ivr();
+ header("Location: freeswitch_ivr.php");
+ exit;
+ }
+ }
+}
+
+include("head.inc");
+
+?>
+
+<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
+<?php include("fbegin.inc"); ?>
+<p class="pgtitle">FreeSWITCH: IVR</p>
+
+<div id="mainlevel">
+<table width="100%" border="0" cellpadding="0" cellspacing="0">
+<tr><td class="tabnavtbl">
+<?php
+
+ $tab_array = array();
+ $tab_array[] = array(gettext("Settings"), false, "/pkg_edit.php?xml=freeswitch.xml&amp;id=0");
+ $tab_array[] = array(gettext("Dialplan"), false, "/freeswitch/freeswitch_dialplan_includes.php");
+ $tab_array[] = array(gettext("Extensions"), false, "/freeswitch/freeswitch_extensions.php");
+ $tab_array[] = array(gettext("External"), false, "/pkg_edit.php?xml=freeswitch_external.xml&amp;id=0");
+ $tab_array[] = array(gettext("Gateways"), false, "/freeswitch/freeswitch_gateways.php");
+ $tab_array[] = array(gettext("Internal"), false, "/pkg_edit.php?xml=freeswitch_internal.xml&amp;id=0");
+ $tab_array[] = array(gettext("IVR"), true, "/freeswitch/freeswitch_ivr.php");
+ $tab_array[] = array(gettext("Modules"), false, "/pkg_edit.php?xml=freeswitch_modules.xml&amp;id=0");
+ $tab_array[] = array(gettext("Public"), false, "/freeswitch/freeswitch_public_includes.php");
+ $tab_array[] = array(gettext("Rec"), false, "/freeswitch/freeswitch_recordings.php");
+ $tab_array[] = array(gettext("Status"), false, "/freeswitch/freeswitch_status.php");
+ $tab_array[] = array(gettext("Vars"), false, "/pkg_edit.php?xml=freeswitch_vars.xml&amp;id=0");
+ display_top_tabs($tab_array);
+
+?>
+</td></tr>
+</table>
+
+<table width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr>
+ <td class="tabcont" >
+
+<form action="freeswitch_ivr.php" method="post" name="iform" id="iform">
+<?php
+
+
+//echo "<pre>";
+//print_r ($a_ivr);
+//echo "</pre>";
+
+//build a list of recordings from the config.xml
+//$config_recording_list = '';
+//$i = 0;
+//if (count($a_ivr) > 0) {
+// foreach ($a_ivr as $ivrent) {
+// $config_recording_list .= $ivrent['filename']."|";
+// $i++;
+// }
+//}
+//echo "config recording list: ".$config_recording_list."<br />\n";
+
+
+//if ($config_change == 1) {
+// write_config();
+// $config_change = 0;
+//}
+
+//if ($savemsg) print_info_box($savemsg);
+//if (file_exists($d_hostsdirty_path)): echo"<p>";
+//print_info_box_np("The FreeSWITCH recordings have been changed.<br>You must apply the changes in order for them to take effect.");
+//echo"<br />";
+//endif;
+
+?>
+ <table width="100%" border="0" cellpadding="6" cellspacing="0">
+ <tr>
+ <td><p><span class="vexpl"><span class="red"><strong>IVR<br />
+ </strong></span>
+ An interactive voice response (IVR) often refered to as an Auto Attendant.
+ It associates a recording to multiple options that can be used to direct calls
+ to extensions, voicemail, queues, other IVR applications, and external
+ phone numbers.
+ </span></p></td>
+ </tr>
+ </table>
+ <br />
+
+ <table width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr>
+ <td width="20%" class="listhdrr">Extension</td>
+ <td width="25%" class="listhdrr">Name</td>
+ <td width="50%" class="listhdr">Description</td>
+ <td width="10%" class="list">
+ <table border="0" cellspacing="0" cellpadding="1">
+ <tr>
+ <td width="17"></td>
+ <td valign="middle"><a href="freeswitch_ivr_edit.php"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"></a></td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+
+ <?php
+ $i = 0;
+ if (count($a_ivr) > 0) {
+ foreach ($a_ivr as $ent) {
+ if (strlen($ent['ivrid']) > 0) {
+ ?>
+ <tr>
+ <td class="listlr" ondblclick="document.location='freeswitch_ivr_edit.php?id=<?=$i;?>'">
+ <?=$ent['ivrextension']?>
+ </td>
+ <td class="listr" ondblclick="document.location='freeswitch_ivr_edit.php?id=<?=$i;?>';">
+ <?=$ent['ivrname'];?>&nbsp;
+ </td>
+ <td class="listbg" ondblclick="document.location='freeswitch_ivr_edit.php?id=<?=$i;?>';">
+ <font color="#FFFFFF"><?=htmlspecialchars($ent['ivrdescr']);?>&nbsp;
+ </td>
+ <td valign="middle" nowrap class="list">
+ <table border="0" cellspacing="0" cellpadding="1">
+ <tr>
+ <td valign="middle"><a href="freeswitch_ivr_edit.php?id=<?=$i;?>"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" width="17" height="17" border="0"></a></td>
+ <td><a href="freeswitch_ivr.php?type=ivr&act=del&id=<?=$i;?>" onclick="return confirm('Do you really want to delete this?')"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0"></a></td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ <?php
+ }
+ $i++;
+ }
+ }
+ ?>
+ <tr>
+ <td class="list" colspan="3"></td>
+ <td class="list">
+ <table border="0" cellspacing="0" cellpadding="1">
+ <tr>
+ <td width="17"></td>
+ <td valign="middle"><a href="freeswitch_ivr_edit.php"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"></a></td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+
+ <tr>
+ <td class="list" colspan="3"></td>
+ <td class="list"></td>
+ </tr>
+ </table>
+
+</form>
+
+<br>
+<br>
+/usr/local/freeswitch/scripts/
+<br>
+<br>
+<br>
+<br>
+
+</td>
+</tr>
+</table>
+
+</div>
+
+
+<?php include("fend.inc"); ?>
+</body>
+</html>
diff --git a/config/freeswitch/freeswitch_ivr_edit.tmp b/config/freeswitch/freeswitch_ivr_edit.tmp
new file mode 100644
index 00000000..f9d4652d
--- /dev/null
+++ b/config/freeswitch/freeswitch_ivr_edit.tmp
@@ -0,0 +1,582 @@
+<?php
+/* $Id$ */
+/*
+
+ freeswitch_ivr_edit.php
+ Copyright (C) 2008 Mark J Crane
+ All rights reserved.
+
+ FreeSWITCH (TM)
+ http://www.freeswitch.org/
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+require("guiconfig.inc");
+require("/usr/local/pkg/freeswitch.inc");
+
+
+$a_ivr = &$config['installedpackages']['freeswitchivr']['config'];
+$a_ivr_options = &$config['installedpackages']['freeswitchivroptions']['config'];
+
+
+$id = $_GET['id'];
+if (isset($_POST['id'])) {
+ $id = $_POST['id'];
+}
+$parentid = $id;
+
+//set default $ivrconditionjs
+ $ivrconditionjs = "function isholiday( Month, Date ) {\n";
+ $ivrconditionjs .= " var Holiday = 0; //default false\n";
+ $ivrconditionjs .= " if (Month == \"12\" && Date == \"25\") {\n";
+ $ivrconditionjs .= " Holiday = 1; //true\n";
+ $ivrconditionjs .= " }\n";
+ $ivrconditionjs .= " if (Month == \"7\" && Date == \"4\") {\n";
+ $ivrconditionjs .= " Holiday = 1; //true\n";
+ $ivrconditionjs .= " }\n";
+ $ivrconditionjs .= " if (Month == \"1\" && Date == \"1\") {\n";
+ $ivrconditionjs .= " Holiday = 1; //true\n";
+ $ivrconditionjs .= " }\n";
+ $ivrconditionjs .= " if (Holiday == 1) {\n";
+ $ivrconditionjs .= " return true;\n";
+ $ivrconditionjs .= " }\n";
+ $ivrconditionjs .= " else {\n";
+ $ivrconditionjs .= " return false;\n";
+ $ivrconditionjs .= " }\n";
+ $ivrconditionjs .= "}\n";
+ $ivrconditionjs .= "\n";
+ $ivrconditionjs .= "function isweekday( Day ) {\n";
+ $ivrconditionjs .= " if (Day > 1 && Day < 7) {\n";
+ $ivrconditionjs .= " return true;\n";
+ $ivrconditionjs .= " }\n";
+ $ivrconditionjs .= " else {\n";
+ $ivrconditionjs .= " return false;\n";
+ $ivrconditionjs .= " }\n";
+ $ivrconditionjs .= "}\n";
+ $ivrconditionjs .= "\n";
+ $ivrconditionjs .= "function isweekend( Day ) {\n";
+ $ivrconditionjs .= " if (Day > 1 && Day < 7) {\n";
+ $ivrconditionjs .= " return false;\n";
+ $ivrconditionjs .= " }\n";
+ $ivrconditionjs .= " else {\n";
+ $ivrconditionjs .= " return true;\n";
+ $ivrconditionjs .= " }\n";
+ $ivrconditionjs .= "}\n";
+ $ivrconditionjs .= "\n";
+ $ivrconditionjs .= "function isofficehours( Hours ) {\n";
+ $ivrconditionjs .= " if (Hours >= 9 && Hours < 17) {\n";
+ $ivrconditionjs .= " return true;\n";
+ $ivrconditionjs .= " }\n";
+ $ivrconditionjs .= " else {\n";
+ $ivrconditionjs .= " return false;\n";
+ $ivrconditionjs .= " }\n";
+ $ivrconditionjs .= "}\n";
+ $ivrconditionjs .= "\n";
+ $ivrconditionjs .= "function isafterhours( Hours ) {\n";
+ $ivrconditionjs .= " if (Hours >= 9 && Hours < 17) {\n";
+ $ivrconditionjs .= " return false;\n";
+ $ivrconditionjs .= " }\n";
+ $ivrconditionjs .= " else {\n";
+ $ivrconditionjs .= " return true;\n";
+ $ivrconditionjs .= " }\n";
+ $ivrconditionjs .= "}\n";
+ $ivrconditionjs .= "\n";
+ $ivrconditionjs .= "//set default\n";
+ $ivrconditionjs .= "condition = true;\n";
+ $ivrconditionjs .= "\n";
+ $ivrconditionjs .= "//Holiday?\n";
+ $ivrconditionjs .= "if (isholiday( Month, Date )) {\n";
+ $ivrconditionjs .= " console_log( \"info\", \"holiday\\n\" );\n";
+ $ivrconditionjs .= " condition = false;\n";
+ $ivrconditionjs .= "}\n";
+ $ivrconditionjs .= "\n";
+ $ivrconditionjs .= "//Weekend?\n";
+ $ivrconditionjs .= "if (isweekend( Day )) {\n";
+ $ivrconditionjs .= " console_log( \"info\", \"weekend\\n\" );\n";
+ $ivrconditionjs .= " condition = false;\n";
+ $ivrconditionjs .= "}\n";
+ $ivrconditionjs .= "\n";
+ $ivrconditionjs .= "// After Hours?\n";
+ $ivrconditionjs .= "if (isafterhours( Hours )) {\n";
+ $ivrconditionjs .= " console_log( \"info\", \"after hours\\n\" );\n";
+ $ivrconditionjs .= " condition = false;\n";
+ $ivrconditionjs .= "}\n";
+ $ivrconditionjs .= "\n";
+
+
+if (isset($id) && $a_ivr[$id]) {
+ $pconfig['ivrid'] = $a_ivr[$id]['ivrid'];
+ $ivrid = $a_ivr[$id]['ivrid'];
+ $pconfig['ivrextension'] = $a_ivr[$id]['ivrextension'];
+ $pconfig['ivrname'] = $a_ivr[$id]['ivrname'];
+ $pconfig['recordingidaction'] = $a_ivr[$id]['recordingidaction'];
+ $pconfig['recordingidantiaction'] = $a_ivr[$id]['recordingidantiaction'];
+ $pconfig['ivrtimeout'] = $a_ivr[$id]['ivrtimeout'];
+ $pconfig['ivrcontext'] = $a_ivr[$id]['ivrcontext'];
+ $pconfig['ivrconditionjs'] = ($a_ivr[$id]['ivrconditionjs']);
+ $pconfig['ivrdescr'] = $a_ivr[$id]['ivrdescr'];
+}
+
+if ($_POST) {
+
+ unset($input_errors);
+ $pconfig = $_POST;
+
+
+ if ($_GET['act'] == "del") {
+ if ($_GET['type'] == 'options') {
+ if ($a_ivroptions[$_GET['optionid']]) {
+ unset($a_ivr_options[$_GET['optionid']]);
+ write_config();
+ sync_package_freeswitch_ivr();
+ //touch($d_hostsdirty_path);
+ header("Location: freeswitch_ivr_edit.php?id=".$_GET['id']);
+ exit;
+ }
+ }
+ }
+
+
+ if (!$input_errors) {
+
+ $ivrent = array();
+ if (strlen($_POST['ivrid']) > 0) {
+ $ivrent['ivrid'] = $_POST['ivrid'];
+ }
+ else {
+ $ivrent['ivrid'] = guid();
+ }
+ $ivrent['ivrextension'] = $_POST['ivrextension'];
+ $ivrent['ivrname'] = $_POST['ivrname'];
+ $ivrent['recordingidaction'] = $_POST['recordingidaction'];
+ $ivrent['recordingidantiaction'] = $_POST['recordingidantiaction'];
+ $ivrent['ivrtimeout'] = $_POST['ivrtimeout'];
+ $ivrent['ivrcontext'] = $_POST['ivrcontext'];
+ $ivrent['ivrconditionjs'] = base64_encode($_POST['ivrconditionjs']);
+ $ivrent['ivrdescr'] = $_POST['ivrdescr'];
+
+ if (isset($id) && $a_ivr[$id]) {
+ //update
+ $a_ivr[$id] = $ivrent;
+ }
+ else {
+ //add
+ $a_ivr[] = $ivrent;
+ }
+
+ //touch($d_hostsdirty_path);
+ write_config();
+ sync_package_freeswitch_ivr();
+
+ header("Location: freeswitch_ivr.php");
+ exit;
+ }
+}
+
+include("head.inc");
+
+?>
+
+<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
+<?php include("fbegin.inc"); ?>
+<p class="pgtitle">FreeSWITCH: IVR: Edit</p>
+<?php if ($input_errors) print_input_errors($input_errors); ?>
+
+
+<div id="mainlevel">
+<table width="100%" border="0" cellpadding="0" cellspacing="0">
+<tr><td class="tabnavtbl">
+<?php
+
+ $tab_array = array();
+ $tab_array[] = array(gettext("Settings"), false, "/pkg_edit.php?xml=freeswitch.xml&amp;id=0");
+ $tab_array[] = array(gettext("Dialplan"), false, "/freeswitch/freeswitch_dialplan_includes.php");
+ $tab_array[] = array(gettext("Extensions"), false, "/freeswitch/freeswitch_extensions.php");
+ $tab_array[] = array(gettext("External"), false, "/pkg_edit.php?xml=freeswitch_external.xml&amp;id=0");
+ $tab_array[] = array(gettext("Gateways"), false, "/freeswitch/freeswitch_gateways.php");
+ $tab_array[] = array(gettext("Internal"), false, "/pkg_edit.php?xml=freeswitch_internal.xml&amp;id=0");
+ $tab_array[] = array(gettext("IVR"), true, "/freeswitch/freeswitch_ivr.php");
+ $tab_array[] = array(gettext("Modules"), false, "/pkg_edit.php?xml=freeswitch_modules.xml&amp;id=0");
+ $tab_array[] = array(gettext("Public"), false, "/freeswitch/freeswitch_public_includes.php");
+ $tab_array[] = array(gettext("Rec"), false, "/freeswitch/freeswitch_recordings.php");
+ $tab_array[] = array(gettext("Status"), false, "/freeswitch/freeswitch_status.php");
+ $tab_array[] = array(gettext("Vars"), false, "/pkg_edit.php?xml=freeswitch_vars.xml&amp;id=0");
+ display_top_tabs($tab_array);
+
+?>
+</td></tr>
+</table>
+<table width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr>
+ <td class="tabcont" >
+
+ <table width="100%" border="0" cellpadding="6" cellspacing="0">
+ <tr>
+ <td><p><span class="vexpl"><span class="red"><strong>General Settings:<br>
+ </strong></span>
+ Interactive voice response general settings.
+ </span></p></td>
+ </tr>
+ </table>
+ <br />
+
+ <form action="freeswitch_ivr_edit.php" method="post" name="iform" id="iform">
+ <table width="100%" border="0" cellpadding="6" cellspacing="0">
+ <tr>
+ <td width="22%" valign="top" class="vncellreq">Extension</td>
+ <td width="78%" class="vtable">
+ <input name="ivrextension" type="text" class="formfld" id="ivrextension" size="40" value="<?=htmlspecialchars($pconfig['ivrextension']);?>">
+ <br> <span class="vexpl">e.g. <em>5002</em></span></td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncellreq">IVR Name</td>
+ <td width="78%" class="vtable">
+ <input name="ivrname" type="text" class="formfld" id="ivrname" size="40" value="<?=htmlspecialchars($pconfig['ivrname']);?>">
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncellreq">Recording Action</td>
+ <td width="78%" class="vtable">
+ <?php
+ $a_recordings = &$config['installedpackages']['freeswitchrecordings']['config'];
+ echo " <select name='recordingidaction' class='formfld'>\n";
+ echo " <option></option>\n";
+ if (count($a_recordings) > 0) {
+ foreach ($a_recordings as $ent) {
+ if (htmlspecialchars($pconfig['recordingidaction']) == $ent['recordingid']) {
+ echo " <option value='".$ent['recordingid']."' selected='yes'>".$ent['recordingname']."</option>\n";
+ }
+ else {
+ echo " <option value='".$ent['recordingid']."'>".$ent['recordingname']."</option>\n";
+ }
+ }
+ }
+ echo " </select>\n";
+ ?>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncellreq">Recording Anti-Action</td>
+ <td width="78%" class="vtable">
+ <?php
+ //$a_recordings = &$config['installedpackages']['freeswitchrecordings']['config'];
+ echo " <select name='recordingidantiaction' class='formfld'>\n";
+ echo " <option></option>\n";
+ if (count($a_recordings) > 0) {
+ foreach ($a_recordings as $ent) {
+ if (htmlspecialchars($pconfig['recordingidantiaction']) == $ent['recordingid']) {
+ echo " <option value='".$ent['recordingid']."' selected='yes'>".$ent['recordingname']."</option>\n";
+ }
+ else {
+ echo " <option value='".$ent['recordingid']."'>".$ent['recordingname']."</option>\n";
+ }
+ }
+ }
+ echo " </select>\n";
+ ?>
+ </td>
+ </tr>
+ <?php
+ if (strlen($pconfig['ivrtimeout']) == 0) {
+ $pconfig['ivrtimeout'] = 10; //set a default timeout
+ }
+ ?>
+ <tr>
+ <td width="22%" valign="top" class="vncellreq">Timeout</td>
+ <td width="78%" class="vtable">
+ <input name="ivrtimeout" type="text" class="formfld" id="ivrtimeout" size="40" value="<?=htmlspecialchars($pconfig['ivrtimeout']);?>">
+ <br><span class="vexpl">After the recording concludes the
+ timeout sets the time in seconds to continue to wait for DTMF.
+ If the DTMF is <br />not detected during that time the 't'
+ timeout option is executed.</span>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncell">Context</td>
+ <td width="78%" class="vtable">
+ <input name="ivrcontext" type="text" class="formfld" id="ivrextension" size="40" value="<?=htmlspecialchars($pconfig['ivrcontext']);?>">
+ <br> <span class="vexpl">e.g. <em>default</em></span></td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncell">Description</td>
+ <td width="78%" class="vtable">
+ <input name="ivrdescr" type="text" class="formfld" id="descr" size="40" value="<?=htmlspecialchars($pconfig['ivrdescr']);?>">
+ <br> <span class="vexpl">You may enter a description here
+ for your reference (not parsed).</span></td>
+ </tr>
+
+
+ <tr>
+ <td width="22%" valign="top" class="vncell">Javascript Condition</td>
+ <td width="78%" class="vtable">
+ <?php
+ if (strlen(htmlspecialchars(base64_decode($pconfig['ivrconditionjs']))) == 0) {
+ echo "<textarea name=\"ivrconditionjs\" cols=\"50\" rows=\"7\" wrap=\"off\">".$ivrconditionjs."</textarea>\n";
+ }
+ else {
+ echo "<textarea name=\"ivrconditionjs\" cols=\"50\" rows=\"7\" wrap=\"off\">".htmlspecialchars(base64_decode($pconfig['ivrconditionjs']))."</textarea>\n";
+ }
+ ?>
+ <br> <span class="vexpl">A simple valid condition is:
+ condition=true; To re-populate the default simply empty the
+ textarea and click on save. The following javascript variables
+ have been defined: Hours, Mins, Seconds, Month, Date, Year,
+ and Day.</span></td>
+ </tr>
+
+
+ <tr>
+ <td width="22%" valign="top">&nbsp;</td>
+ <td width="78%">
+ <input name="Submit" type="submit" class="formbtn" value="Save"> <input class="formbtn" type="button" value="Cancel" onclick="history.back()">
+ <input name="ivrid" type="hidden" value="<?=htmlspecialchars($pconfig['ivrid']);?>">
+ <?php if (isset($id) && $a_ivr[$id]): ?>
+ <input name="id" type="hidden" value="<?=$id;?>">
+ <?php endif; ?>
+ </td>
+ </tr>
+ </table>
+ </form>
+
+ <br>
+ <br>
+
+ <form action="freeswitch_ivr_edit.php" method="post" name="iform2" id="iform2">
+ <?php
+
+
+ //echo "<pre>";
+ //print_r ($a_ivr);
+ //echo "</pre>";
+
+ //if ($savemsg) print_info_box($savemsg);
+ //if (file_exists($d_hostsdirty_path)): echo"<p>";
+ //print_info_box_np("The FreeSWITCH recordings have been changed.<br>You must apply the changes in order for them to take effect.");
+ //echo"<br />";
+ //endif;
+
+ ?>
+
+ <table width="100%" border="0" cellpadding="6" cellspacing="0">
+ <tr>
+ <td><p><span class="vexpl"><span class="red"><strong><br>
+ </strong></span>
+ Options are the choices that are available to the caller when they
+ are calling the auto attendant. If the caller presses 2 then the call
+ is directed to the corresponding destination.
+ </span></p></td>
+ </tr>
+ </table>
+
+
+ <table width="100%" border="0" cellpadding="6" cellspacing="0">
+ <tr>
+ <td><p><span class="vexpl"><span class="red"><strong>Action<br />
+ </strong></span>
+ The options that are executed when the <b>condition matches.</b>
+ </span></p></td>
+ </tr>
+ </table>
+ <br />
+
+ <table width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr>
+ <td width="20%" class="listhdrr">Option</td>
+ <td width="25%" class="listhdrr">Type</td>
+ <td width="25%" class="listhdrr">Destination</td>
+ <td width="25%" class="listhdr">Description</td>
+ <td width="10%" class="list">
+ <table border="0" cellspacing="0" cellpadding="1">
+ <tr>
+ <td width="17"></td>
+ <td valign="middle"><a href="freeswitch_ivr_options_edit.php?parentid=<?=$parentid;?>&ivrid=<?=$ivrid;?>&a=action"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"></a></td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+
+ <?php
+ $i = 0;
+ if (count($a_ivr_options) > 0) {
+ foreach ($a_ivr_options as $ent) {
+ if ($ent['optionaction'] == "action" && $ivrid == $ent['ivrid']) {
+ ?>
+ <tr>
+ <td class="listlr" ondblclick="document.location='freeswitch_ivr_options_edit.php?id=<?=$i;?>&parentid=<?=$parentid;?>&ivrid=<?=$ivrid;?>'">
+ <?=$ent['optionnumber']?>
+ </td>
+ <td class="listr" ondblclick="document.location='freeswitch_ivr_options_edit.php?id=<?=$i;?>&parentid=<?=$parentid;?>&ivrid=<?=$ivrid;?>';">
+ <?=$ent['optiontype'];?>&nbsp;
+ </td>
+ <td class="listr" ondblclick="document.location='freeswitch_ivr_options_edit.php?id=<?=$i;?>&parentid=<?=$parentid;?>&ivrid=<?=$ivrid;?>';">
+ <?=$ent['optiondest'];?>&nbsp;
+ </td>
+ <td class="listbg" ondblclick="document.location='freeswitch_ivr_options_edit.php?id=<?=$id;?>&parentid=<?=$parentid;?>&ivrid=<?=$ivrid;?>';">
+ <font color="#FFFFFF"><?=htmlspecialchars($ent['optiondescr']);?>&nbsp;
+ </td>
+ <td valign="middle" nowrap class="list">
+ <table border="0" cellspacing="0" cellpadding="1">
+ <tr>
+ <td valign="middle"><a href="freeswitch_ivr_options_edit.php?id=<?=$i;?>&parentid=<?=$parentid;?>&ivrid=<?=$ivrid;?>"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" width="17" height="17" border="0"></a></td>
+ <td><a href="freeswitch_ivr_options.php?type=ivroptions&act=del&id=<?=$i;?>&parentid=<?=$parentid;?>&ivrid=<?=$ivrid;?>" onclick="return confirm('Do you really want to delete this recording?')"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0"></a></td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ <?php
+ }
+ $i++;
+ }
+ }
+ ?>
+ <tr>
+ <td class="list" colspan="4"></td>
+ <td class="list">
+ <table border="0" cellspacing="0" cellpadding="1">
+ <tr>
+ <td width="17"></td>
+ <td valign="middle"><a href="freeswitch_ivr_options_edit.php?parentid=<?=$parentid;?>&ivrid=<?=$ivrid;?>&a=action"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"></a></td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+
+
+ <tr>
+ <td class="list" colspan="4"></td>
+ <td class="list"></td>
+ </tr>
+ </table>
+
+ </form>
+
+
+
+ <form action="freeswitch_ivr_edit.php" method="post" name="iform2" id="iform2">
+ <?php
+
+
+ //echo "<pre>";
+ //print_r ($a_ivr);
+ //echo "</pre>";
+
+ //if ($savemsg) print_info_box($savemsg);
+ //if (file_exists($d_hostsdirty_path)): echo"<p>";
+ //print_info_box_np("The FreeSWITCH recordings have been changed.<br>You must apply the changes in order for them to take effect.");
+ //echo"<br />";
+ //endif;
+
+ ?>
+ <table width="100%" border="0" cellpadding="6" cellspacing="0">
+ <tr>
+ <td><p><span class="vexpl"><span class="red"><strong>Anti-Action<br />
+ </strong></span>
+ The options that are executed when the <b>condition does NOT match.</b>
+ </span></p></td>
+ </tr>
+ </table>
+ <br />
+
+ <table width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr>
+ <td width="20%" class="listhdrr">Option</td>
+ <td width="25%" class="listhdrr">Type</td>
+ <td width="25%" class="listhdrr">Destination</td>
+ <td width="25%" class="listhdr">Description</td>
+ <td width="10%" class="list">
+ <table border="0" cellspacing="0" cellpadding="1">
+ <tr>
+ <td width="17"></td>
+ <td valign="middle"><a href="freeswitch_ivr_options_edit.php?parentid=<?=$parentid;?>&ivrid=<?=$ivrid;?>&a=antiaction"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"></a></td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+
+ <?php
+ $i = 0;
+ if (count($a_ivr_options) > 0) {
+ foreach ($a_ivr_options as $ent) {
+ if ($ent['optionaction'] == "anti-action" && $ivrid == $ent['ivrid']) {
+ ?>
+ <tr>
+ <td class="listlr" ondblclick="document.location='freeswitch_ivr_options_edit.php?id=<?=$i;?>&parentid=<?=$parentid;?>&ivrid=<?=$ivrid;?>'">
+ <?=$ent['optionnumber']?>
+ </td>
+ <td class="listr" ondblclick="document.location='freeswitch_ivr_options_edit.php?id=<?=$i;?>&parentid=<?=$parentid;?>&ivrid=<?=$ivrid;?>';">
+ <?=$ent['optiontype'];?>&nbsp;
+ </td>
+ <td class="listr" ondblclick="document.location='freeswitch_ivr_options_edit.php?id=<?=$i;?>&parentid=<?=$parentid;?>&ivrid=<?=$ivrid;?>';">
+ <?=$ent['optiondest'];?>&nbsp;
+ </td>
+ <td class="listbg" ondblclick="document.location='freeswitch_ivr_options_edit.php?id=<?=$id;?>&parentid=<?=$parentid;?>&ivrid=<?=$ivrid;?>';">
+ <font color="#FFFFFF"><?=htmlspecialchars($ent['optiondescr']);?>&nbsp;
+ </td>
+ <td valign="middle" nowrap class="list">
+ <table border="0" cellspacing="0" cellpadding="1">
+ <tr>
+ <td valign="middle"><a href="freeswitch_ivr_options_edit.php?id=<?=$i;?>&parentid=<?=$parentid;?>&ivrid=<?=$ivrid;?>"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" width="17" height="17" border="0"></a></td>
+ <td><a href="freeswitch_ivr_options.php?type=ivroptions&act=del&id=<?=$i;?>&parentid=<?=$parentid;?>&ivrid=<?=$ivrid;?>" onclick="return confirm('Do you really want to delete this recording?')"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0"></a></td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ <?php
+ }
+ $i++;
+ }
+ }
+ ?>
+ <tr>
+ <td class="list" colspan="4"></td>
+ <td class="list">
+ <table border="0" cellspacing="0" cellpadding="1">
+ <tr>
+ <td width="17"></td>
+ <td valign="middle"><a href="freeswitch_ivr_options_edit.php?parentid=<?=$parentid;?>&ivrid=<?=$ivrid;?>&a=antiaction"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"></a></td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+
+
+ <tr>
+ <td class="list" colspan="4"></td>
+ <td class="list"></td>
+ </tr>
+ </table>
+
+ </form>
+
+ <br>
+ <br>
+
+ </td>
+ </tr>
+</table>
+
+</div>
+
+<?php include("fend.inc"); ?>
+</body>
+</html>
diff --git a/config/freeswitch/freeswitch_ivr_options.tmp b/config/freeswitch/freeswitch_ivr_options.tmp
new file mode 100644
index 00000000..8356bc58
--- /dev/null
+++ b/config/freeswitch/freeswitch_ivr_options.tmp
@@ -0,0 +1,52 @@
+<?php
+/* $Id$ */
+/*
+ freeswitch_ivr_options.php
+ Copyright (C) 2008 Mark J Crane
+ All rights reserved.
+
+ FreeSWITCH (TM)
+ http://www.freeswitch.org/
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+require("guiconfig.inc");
+require("/usr/local/pkg/freeswitch.inc");
+
+
+$a_ivr_options = &$config['installedpackages']['freeswitchivroptions']['config'];
+
+
+if ($_GET['act'] == "del") {
+ if ($_GET['type'] == 'ivroptions') {
+ if ($a_ivr_options[$_GET['id']]) {
+ unset($a_ivr_options[$_GET['id']]);
+ write_config();
+ sync_package_freeswitch_ivr();
+ header("Location: freeswitch_ivr_edit.php?id=".$_GET['parentid']);
+ exit;
+ }
+ }
+}
+
+?> \ No newline at end of file
diff --git a/config/freeswitch/freeswitch_ivr_options_edit.tmp b/config/freeswitch/freeswitch_ivr_options_edit.tmp
new file mode 100644
index 00000000..78975a7f
--- /dev/null
+++ b/config/freeswitch/freeswitch_ivr_options_edit.tmp
@@ -0,0 +1,216 @@
+<?php
+/* $Id$ */
+/*
+
+ freeswitch_recordings_edit.php
+ Copyright (C) 2008 Mark J Crane
+ All rights reserved.
+
+ FreeSWITCH (TM)
+ http://www.freeswitch.org/
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+require("guiconfig.inc");
+require("/usr/local/pkg/freeswitch.inc");
+
+
+$a_ivr_options = &$config['installedpackages']['freeswitchivroptions']['config'];
+
+$id = $_GET['id'];
+if (isset($_POST['id'])) {
+ $id = $_POST['id'];
+}
+
+$parentid = $_GET['parentid'];
+if (isset($_POST['parentid'])) {
+ $parentid = $_POST['parentid'];
+}
+
+$ivrid = $_GET['ivrid'];
+if (isset($_POST['ivrid'])) {
+ $ivrid = $_POST['ivrid'];
+}
+
+
+if (isset($id) && $a_ivr_options[$id]) {
+ $pconfig['optionaction'] = $a_ivr_options[$id]['optionaction'];
+ $pconfig['optionnumber'] = $a_ivr_options[$id]['optionnumber'];
+ $pconfig['optiontype'] = $a_ivr_options[$id]['optiontype'];
+ $pconfig['optiondest'] = $a_ivr_options[$id]['optiondest'];
+ $pconfig['optiondescr'] = $a_ivr_options[$id]['optiondescr'];
+}
+else {
+ if (isset($_GET['a'])) {
+ if ($_GET['a'] == "action"){ $pconfig['optionaction'] = "action"; }
+ if ($_GET['a'] == "antiaction"){ $pconfig['optionaction'] = "anti-action"; }
+ }
+}
+
+
+if ($_POST) {
+
+ unset($input_errors);
+ $pconfig = $_POST;
+
+
+ if (!$input_errors) {
+
+ $ivroptionent = array();
+ $ivroptionent['ivrid'] = $_POST['ivrid'];
+ $ivroptionent['optionnumber'] = $_POST['optionnumber'];
+ $ivroptionent['optiontype'] = $_POST['optiontype'];
+ $ivroptionent['optionaction'] = $_POST['optionaction'];
+ $ivroptionent['optiondest'] = $_POST['optiondest'];
+ $ivroptionent['optiondescr'] = $_POST['optiondescr'];
+
+ if (isset($id) && $a_ivr_options[$id]) {
+ //update
+ $a_ivr_options[$id] = $ivroptionent;
+ }
+ else {
+ //add
+ $a_ivr_options[] = $ivroptionent;
+ }
+
+
+ write_config();
+ sync_package_freeswitch_ivr();
+
+ header("Location: freeswitch_ivr_edit.php?id=".$parentid);
+ exit;
+ }
+}
+
+include("head.inc");
+
+?>
+
+<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
+<?php include("fbegin.inc"); ?>
+<p class="pgtitle">FreeSWITCH: IVR: Options: Edit</p>
+<?php if ($input_errors) print_input_errors($input_errors); ?>
+
+<div id="mainlevel">
+<table width="100%" border="0" cellpadding="0" cellspacing="0">
+<tr><td class="tabnavtbl">
+<?php
+
+ $tab_array = array();
+ $tab_array[] = array(gettext("Settings"), false, "/pkg_edit.php?xml=freeswitch.xml&amp;id=0");
+ $tab_array[] = array(gettext("Dialplan"), false, "/freeswitch/freeswitch_dialplan_includes.php");
+ $tab_array[] = array(gettext("Extensions"), false, "/freeswitch/freeswitch_extensions.php");
+ $tab_array[] = array(gettext("External"), false, "/pkg_edit.php?xml=freeswitch_external.xml&amp;id=0");
+ $tab_array[] = array(gettext("Gateways"), false, "/freeswitch/freeswitch_gateways.php");
+ $tab_array[] = array(gettext("Internal"), false, "/pkg_edit.php?xml=freeswitch_internal.xml&amp;id=0");
+ $tab_array[] = array(gettext("IVR"), true, "/freeswitch/freeswitch_ivr.php");
+ $tab_array[] = array(gettext("Modules"), false, "/pkg_edit.php?xml=freeswitch_modules.xml&amp;id=0");
+ $tab_array[] = array(gettext("Public"), false, "/freeswitch/freeswitch_public_includes.php");
+ $tab_array[] = array(gettext("Rec"), false, "/freeswitch/freeswitch_recordings.php");
+ $tab_array[] = array(gettext("Status"), false, "/freeswitch/freeswitch_status.php");
+ $tab_array[] = array(gettext("Vars"), false, "/pkg_edit.php?xml=freeswitch_vars.xml&amp;id=0");
+ display_top_tabs($tab_array);
+
+?>
+</td></tr>
+</table>
+<table width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr>
+ <td class="tabcont" >
+
+ <form action="freeswitch_ivr_options_edit.php" method="post" name="iform" id="iform">
+ <table width="100%" border="0" cellpadding="6" cellspacing="0">
+ <tr>
+ <td width="22%" valign="top" class="vncellreq">Option Number</td>
+ <td width="78%" class="vtable">
+ <input name="optionnumber" type="text" class="formfld" id="optionnumber" size="40" value="<?=htmlspecialchars($pconfig['optionnumber']);?>">
+ <br> <span class="vexpl">Option Number<br>
+ e.g. <em>1</em></span></td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncellreq">Type</td>
+ <td width="78%" class="vtable">
+ <?php
+ echo " <select name='optiontype' class='formfld'>\n";
+ echo " <option></option>\n";
+ if (htmlspecialchars($pconfig['optiontype']) == "extension") {
+ echo " <option selected='yes'>extension</option>\n";
+ }
+ else {
+ echo " <option>extension</option>\n";
+ }
+ if (htmlspecialchars($pconfig['optiontype']) == "voicemail") {
+ echo " <option selected='yes'>voicemail</option>\n";
+ }
+ else {
+ echo " <option>voicemail</option>\n";
+ }
+ echo " </select>\n";
+ ?>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncellreq">Destination</td>
+ <td width="78%" class="vtable">
+ <input name="optiondest" type="text" class="formfld" id="optiondest" size="40" value="<?=htmlspecialchars($pconfig['optiondest']);?>">
+ <br> <span class="vexpl">Destination<br>
+ e.g. <em>1001</em></span></td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncell">Description</td>
+ <td width="78%" class="vtable">
+ <input name="optiondescr" type="text" class="formfld" id="optiondescr" size="40" value="<?=htmlspecialchars($pconfig['optiondescr']);?>">
+ <br> <span class="vexpl">You may enter a description here
+ for your reference (not parsed).</span></td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top">&nbsp;</td>
+ <td width="78%">
+ <input name="ivrid" type="hidden" value="<?=$ivrid;?>">
+ <input name="parentid" type="hidden" value="<?=$parentid;?>">
+ <input name="optionaction" type="hidden" value="<?=$pconfig['optionaction'];?>">
+ <?php if (isset($id) && $a_ivr_options[$id]): ?>
+ <input name="id" type="hidden" value="<?=$id;?>">
+ <?php endif; ?>
+ <input name="Submit" type="submit" class="formbtn" value="Save"> <input class="formbtn" type="button" value="Cancel" onclick="history.back()">
+ </td>
+ </tr>
+ </table>
+ </form>
+
+ <br>
+ <br>
+ <br>
+ <br>
+ <br>
+ <br>
+
+ </td>
+ </tr>
+</table>
+
+</div>
+
+<?php include("fend.inc"); ?>
+</body>
+</html>
diff --git a/config/freeswitch/freeswitch_mailto.tmp b/config/freeswitch/freeswitch_mailto.tmp
new file mode 100644
index 00000000..23645570
--- /dev/null
+++ b/config/freeswitch/freeswitch_mailto.tmp
@@ -0,0 +1,240 @@
+<?php
+/* $Id$ */
+/*
+ freeswitch_mailto.php
+ Copyright (C) 2008 Mark J Crane
+ All rights reserved.
+
+ FreeSWITCH (TM)
+ http://www.freeswitch.org/
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+require_once("config.inc");
+require_once("/usr/local/pkg/freeswitch.inc");
+global $config;
+
+$tmp_smtphost = $config['installedpackages']['freeswitchsettings']['config'][0]['smtphost'];
+$tmp_smtpsecure = $config['installedpackages']['freeswitchsettings']['config'][0]['smtpsecure']; //options "", "TLS", "SSL"
+$tmp_smtpsecure = strtolower($tmp_smtpsecure);
+$tmp_smtpauth = $config['installedpackages']['freeswitchsettings']['config'][0]['smtpauth']; // SMTP authentication: true or false
+$tmp_smtpusername = $config['installedpackages']['freeswitchsettings']['config'][0]['smtpusername'];
+$tmp_smtppassword = $config['installedpackages']['freeswitchsettings']['config'][0]['smtppassword'];
+$tmp_smtpfrom = $config['installedpackages']['freeswitchsettings']['config'][0]['smtpfrom'];
+$tmp_smtpfromname = $config['installedpackages']['freeswitchsettings']['config'][0]['smtpfromname'];
+
+
+ini_set(max_execution_time,900); //15 minutes
+ini_set('memory_limit', '96M');
+$fd = fopen("php://stdin", "r");
+
+$email = file_get_contents ("php://stdin");
+
+fclose($fd);
+
+if($fd){
+ $fp = fopen("/tmp/voicemailtoemail.txt", "w");
+}
+
+
+ob_end_clean();
+ob_start();
+
+
+//get main header and body
+ $tmparray = split("\n\n", $email);
+ $mainheader = $tmparray[0];
+ $maincontent = substr($email, strlen($mainheader), strlen($email));
+
+//get the boundary
+ $tmparray = split("\n", $mainheader);
+ $contenttmp = $tmparray[1]; //Content-Type: multipart/mixed; boundary="XXXX_boundary_XXXX"
+ $tmparray = split('; ', $contenttmp); //boundary="XXXX_boundary_XXXX"
+ $contenttmp = $tmparray[1];
+ $tmparray = split('=', $contenttmp); //"XXXX_boundary_XXXX"
+ $boundary = $tmparray[1];
+ $boundary = trim($boundary,'"');
+ //echo "boundary: $boundary\n";
+
+//put the main headers into an array
+ $mainheaderarray = split("\n", $mainheader);
+ //print_r($mainheaderarray);
+ foreach ($mainheaderarray as $val) {
+ $tmparray = split(': ', $val);
+ //print_r($tmparray);
+ $var[$tmparray[0]] = trim($tmparray[1]);
+ }
+
+ $var['To'] = str_replace("<", "", $var['To']);
+ $var['To'] = str_replace(">", "", $var['To']);
+
+ echo "To: ".$var['To']."\n";
+ echo "From: ".$var['From']."\n";
+ echo "Subject: ".$var['Subject']."\n";
+ //print_r($var);
+ echo "\n\n";
+
+
+// split mime type multi-part into each part
+ $maincontent = str_replace($boundary."--", $boundary, $maincontent);
+ $tmparray = split("--".$boundary, $maincontent);
+
+// loop through each mime part
+ $i=0;
+ foreach ($tmparray as $mimepart) {
+
+ $mimearray = split("\n\n", $mimepart);
+ $subheader = $mimearray[0];
+ $headermimearray = split("\n", trim($subheader));
+
+ $x=0;
+ foreach ($headermimearray as $val) {
+ if(stristr($val, ':') === FALSE) {
+ $tmparray = split('=', $val); //':' not found
+ if (trim($tmparray[0]) == "boundary") {
+ $subboundary = $tmparray[1];
+ $subboundary = trim($subboundary,'"');
+ //echo "subboundary: ".$subboundary."\n";
+ }
+ }
+ else {
+ $tmparray = split(':', $val); //':' found
+ }
+
+ //print_r($tmparray);
+ $var[trim($tmparray[0])] = trim($tmparray[1]);
+ }
+ //print_r($var);
+
+
+ $contenttypearray = split(' ', $headermimearray[0]);
+
+ if ($contenttypearray[0] == "Content-Type:") {
+ $contenttype = trim($contenttypearray[1]);
+
+ switch ($contenttype) {
+ case "multipart/alternative;":
+
+ //echo "type: ".$contenttype."\n";
+ $content = trim(substr($mimepart, strlen($subheader), strlen($mimepart)));
+
+ $content = str_replace($subboundary."--", $subboundary, $content);
+ $tmpsubarray = split("--".$subboundary, $content);
+ foreach ($tmpsubarray as $mimesubsubpart) {
+
+ $mimesubsubarray = split("\n\n", $mimesubsubpart);
+ $subsubheader = $mimesubsubarray[0];
+
+ $headersubsubmimeearray = split("\n", trim($subsubheader));
+ $subsubcontenttypearray = split(' ', $headersubsubmimeearray[0]);
+ //echo "subsubcontenttypearray[0] ".$subsubcontenttypearray[0]."\n";
+
+ if ($subsubcontenttypearray[0] == "Content-Type:") {
+ $subsubcontenttype = trim($subsubcontenttypearray[1]);
+ switch ($subsubcontenttype) {
+ case "text/plain;":
+ $textplain = trim(substr($mimesubsubpart, strlen($subsubheader), strlen($mimesubsubpart)));
+ //echo "text/plain: $textplain\n";
+ break;
+ case "text/html;":
+ $texthtml = trim(substr($mimesubsubpart, strlen($subsubheader), strlen($mimesubsubpart)));
+ //echo "text/html: $texthtml\n";
+ break;
+ }
+ } //end if
+
+
+ } //end foreach
+
+ break;
+ case "audio/wav;":
+ //echo "type: ".$contenttype."\n";
+ $strwav = trim(substr($mimepart, strlen($subheader), strlen($mimepart)));
+ //echo "\n*** begin wav ***\n".$strwav."\n*** end wav ***\n";
+ break;
+
+ }//end switch
+ } //end if
+
+ $i++;
+
+ } //end foreach
+
+
+//send the email
+
+ include "class.phpmailer.php";
+ include "class.smtp.php"; ; // optional, gets called from within class.phpmailer.php if not already loaded
+
+ $mail = new PHPMailer();
+
+ $mail->IsSMTP(); // set mailer to use SMTP
+ $mail->SMTPAuth = $tmp_smtpauth; // turn on/off SMTP authentication
+ $mail->Host = $tmp_smtphost;
+ if (strlen($tmp_smtpsecure)>0) {
+ $mail->SMTPSecure = $tmp_smtpsecure;
+ }
+ if ($tmp_smtpauth) {
+ $mail->Username = $tmp_smtpusername;
+ $mail->Password = $tmp_smtppassword;
+ }
+
+
+ $mail->From = $tmp_smtpfrom;
+ $mail->FromName = $tmp_smtpfromname;
+ $mail->Subject = $var['Subject'];
+ $mail->AltBody = $textplain; // optional, comment out and test
+ $mail->MsgHTML($texthtml);
+
+
+ $tmp_to = $var['To'];
+ $tmp_to = str_replace(";", ",", $tmp_to);
+ $tmp_to_array = split(",", $tmp_to);
+ foreach($tmp_to_array as $tmp_to_row) {
+ if (strlen($tmp_to_row) > 0) {
+ $mail->AddAddress($tmp_to_row);
+ }
+ }
+
+ if (strlen($strwav) > 0) {
+ //$mail->AddAttachment("/usr/local/freeswitch/data/domain/example.wav"); // attachment
+ $filename='voicemail.wav'; $encoding = "base64"; $type = "audio/wav";
+ $mail->AddStringAttachment(base64_decode($strwav),$filename,$encoding,$type);
+ }
+ unset($strwav);
+
+ if(!$mail->Send()) {
+ echo "Mailer Error: " . $mail->ErrorInfo;
+ }
+ else {
+ echo "Message sent!";
+ }
+
+
+$content = ob_get_contents(); //get the output from the buffer
+ob_end_clean(); //clean the buffer
+
+fwrite($fp, $content);
+fclose($fp);
+
+?> \ No newline at end of file
diff --git a/config/freeswitch/freeswitch_modules.xml b/config/freeswitch/freeswitch_modules.xml
new file mode 100644
index 00000000..91620ac9
--- /dev/null
+++ b/config/freeswitch/freeswitch_modules.xml
@@ -0,0 +1,1216 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<!DOCTYPE packagegui SYSTEM "./schema/packages.dtd">
+<packagegui>
+ <copyright>
+ <![CDATA[
+/* $Id$ */
+/* ========================================================================== */
+/*
+ freeswitch_modules.xml
+ Copyright (C) 2008 Mark J Crane
+ All rights reserved.
+
+ FreeSWITCH (TM)
+ http://www.freeswitch.org/
+
+ part of pfSense (http://www.pfSense.com)
+ Copyright (C) 2007 to whom it may belong
+ All rights reserved.
+
+ Based on m0n0wall (http://m0n0.ch/wall)
+ Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>.
+ All rights reserved.
+ */
+/* ========================================================================== */
+/*
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+ */
+/* ========================================================================== */
+ ]]>
+ </copyright>
+ <description>FreeSWITCH is an open source telephony platform designed to facilitate the creation of voice and chat driven products scaling from a soft-phone up to a soft-switch. It can be used as a simple switching engine, a PBX, a media gateway or a media server to host IVR applications using simple scripts or XML to control the callflow.</description>
+ <requirements>Describe your package requirements here</requirements>
+ <faq>Currently there are no FAQ items provided.</faq>
+ <name>FreeSWITCH Modules</name>
+ <version>0.2</version>
+ <title>FreeSWITCH: Modules</title>
+ <include_file>/usr/local/pkg/freeswitch.inc</include_file>
+ <menu>
+ <name>FreeSWITCH</name>
+ <tooltiptext>Modify FreeSWITCH Modules.</tooltiptext>
+ <section>Services</section>
+ <configfile>freeswitch.xml</configfile>
+ <url>/pkg_edit.php?xml=freeswitch.xml&amp;id=0</url>
+ </menu>
+ <service>
+ <name>freeswitch</name>
+ <rcfile>freeswitch.sh</rcfile>
+ <executable>freeswitch</executable>
+ <description>FreeSWITCH is an open source telephony platform designed to facilitate the creation of voice and chat driven products scaling from a soft-phone up to a soft-switch. It can be used as a simple switching engine, a PBX, a media gateway or a media server to host IVR applications using simple scripts or XML to control the callflow.</description>
+ </service>
+ <tabs>
+ <tab>
+ <text>Settings</text>
+ <url>/pkg_edit.php?xml=freeswitch.xml&amp;id=0</url>
+ </tab>
+ <tab>
+ <text>Dialplan</text>
+ <url>/freeswitch/freeswitch_dialplan_includes.php</url>
+ </tab>
+ <tab>
+ <text>Extensions</text>
+ <url>/freeswitch/freeswitch_extensions.php</url>
+ </tab>
+ <tab>
+ <text>External</text>
+ <url>/pkg_edit.php?xml=freeswitch_external.xml&amp;id=0</url>
+ </tab>
+ <tab>
+ <text>Gateways</text>
+ <url>/freeswitch/freeswitch_gateways.php</url>
+ </tab>
+ <tab>
+ <text>Internal</text>
+ <url>/pkg_edit.php?xml=freeswitch_internal.xml&amp;id=0</url>
+ </tab>
+ <tab>
+ <text>IVR</text>
+ <url>/freeswitch/freeswitch_ivr.php</url>
+ </tab>
+ <tab>
+ <text>Modules</text>
+ <url>/pkg_edit.php?xml=freeswitch_modules.xml&amp;id=0</url>
+ <active/>
+ </tab>
+ <tab>
+ <text>Public</text>
+ <url>/freeswitch/freeswitch_public_includes.php</url>
+ </tab>
+ <tab>
+ <text>Rec</text>
+ <url>/freeswitch/freeswitch_recordings.php</url>
+ </tab>
+ <tab>
+ <text>Status</text>
+ <url>/freeswitch/freeswitch_status.php</url>
+ </tab>
+ <tab>
+ <text>Vars</text>
+ <url>/pkg_edit.php?xml=freeswitch_vars.xml&amp;id=0</url>
+ </tab>
+ </tabs>
+ <configpath>installedpackages->package->$packagename->configuration->freeswitchmodules</configpath>
+ <fields>
+ <field>
+ <fielddescr>&lt;b&gt;Loggers&lt;/b&gt;</fielddescr>
+ <fieldname>loggers</fieldname>
+ <description></description>
+ <type>listtopic</type>
+ </field>
+ <field>
+ <fielddescr>mod_console</fielddescr>
+ <fieldname>mod_console</fieldname>
+ <description>Send logs to the console.</description>
+ <type>select</type>
+ <options>
+ <option>
+ <name>enable</name>
+ <value>enable</value>
+ </option>
+ <option>
+ <name>disable</name>
+ <value>disable</value>
+ </option>
+ </options>
+ </field>
+ <field>
+ <fielddescr>mod_logfile</fielddescr>
+ <fieldname>mod_logfile</fieldname>
+ <description>Send logs to the local file system.</description>
+ <type>select</type>
+ <options>
+ <option>
+ <name>enable</name>
+ <value>enable</value>
+ </option>
+ <option>
+ <name>disable</name>
+ <value>disable</value>
+ </option>
+ </options>
+ </field>
+ <field>
+ <fielddescr>mod_syslog</fielddescr>
+ <fieldname>mod_syslog</fieldname>
+ <description>Send logs to a remote syslog server.</description>
+ <type>select</type>
+ <options>
+ <option>
+ <name>enable</name>
+ <value>enable</value>
+ </option>
+ <option>
+ <name>disable</name>
+ <value>disable</value>
+ </option>
+ </options>
+ </field>
+ <field>
+ <fielddescr>&lt;b&gt;Multi-Faceted&lt;/b&gt;</fielddescr>
+ <fieldname>multi-faceted</fieldname>
+ <description></description>
+ <type>listtopic</type>
+ </field>
+ <field>
+ <fielddescr>mod_enum</fielddescr>
+ <fieldname>mod_enum</fieldname>
+ <description>Route PSTN numbers over internet according to ENUM servers, such as e164.org.</description>
+ <type>select</type>
+ <options>
+ <option>
+ <name>enable</name>
+ <value>enable</value>
+ </option>
+ <option>
+ <name>disable</name>
+ <value>disable</value>
+ </option>
+ </options>
+ </field>
+ <field>
+ <fielddescr>&lt;b&gt;XML Interfaces&lt;/b&gt;</fielddescr>
+ <fieldname>xml_interfaces</fieldname>
+ <description></description>
+ <type>listtopic</type>
+ </field>
+ <field>
+ <fielddescr>mod_xml_rpc</fielddescr>
+ <fieldname>mod_xml_rpc</fieldname>
+ <description>XML Remote Procedure Calls. Issue commands from your web application.</description>
+ <type>select</type>
+ <options>
+ <option>
+ <name>enable</name>
+ <value>enable</value>
+ </option>
+ <option>
+ <name>disable</name>
+ <value>disable</value>
+ </option>
+ </options>
+ </field>
+ <field>
+ <fielddescr>mod_xml_curl</fielddescr>
+ <fieldname>mod_xml_curl</fieldname>
+ <description>XML Gateway Code. Configure FreeSWITCH from a web server on boot and on the fly.</description>
+ <type>select</type>
+ <options>
+ <option>
+ <name>enable</name>
+ <value>enable</value>
+ </option>
+ <option>
+ <name>disable</name>
+ <value>disable</value>
+ </option>
+ </options>
+ </field>
+ <field>
+ <fielddescr>mod_xml_cdr</fielddescr>
+ <fieldname>mod_xml_cdr</fieldname>
+ <description>XML based call detail record handler.</description>
+ <type>select</type>
+ <options>
+ <option>
+ <name>enable</name>
+ <value>enable</value>
+ </option>
+ <option>
+ <name>disable</name>
+ <value>disable</value>
+ </option>
+ </options>
+ </field>
+ <field>
+ <fielddescr>&lt;b&gt;Event Handlers&lt;/b&gt;</fielddescr>
+ <fieldname>event_handlers</fieldname>
+ <description></description>
+ <type>listtopic</type>
+ </field>
+ <field>
+ <fielddescr>mod_cdr_csv</fielddescr>
+ <fieldname>mod_cdr_csv</fieldname>
+ <description>CSV call detail record handler.</description>
+ <type>select</type>
+ <options>
+ <option>
+ <name>enable</name>
+ <value>enable</value>
+ </option>
+ <option>
+ <name>disable</name>
+ <value>disable</value>
+ </option>
+ </options>
+ </field>
+ <field>
+ <fielddescr>mod_event_multicast</fielddescr>
+ <fieldname>mod_event_multicast</fieldname>
+ <description>Broadcasts events to netmask.</description>
+ <type>select</type>
+ <options>
+ <option>
+ <name>enable</name>
+ <value>enable</value>
+ </option>
+ <option>
+ <name>disable</name>
+ <value>disable</value>
+ </option>
+ </options>
+ </field>
+ <field>
+ <fielddescr>mod_event_socket</fielddescr>
+ <fieldname>mod_event_socket</fieldname>
+ <description>Sends events via a single socket.</description>
+ <type>select</type>
+ <options>
+ <option>
+ <name>enable</name>
+ <value>enable</value>
+ </option>
+ <option>
+ <name>disable</name>
+ <value>disable</value>
+ </option>
+ </options>
+ </field>
+ <field>
+ <fielddescr>mod_zeroconf</fielddescr>
+ <fieldname>mod_zeroconf</fieldname>
+ <description>Support for zeroconf.</description>
+ <type>select</type>
+ <options>
+ <option>
+ <name>enable</name>
+ <value>enable</value>
+ </option>
+ <option>
+ <name>disable</name>
+ <value>disable</value>
+ </option>
+ </options>
+ </field>
+ <field>
+ <fielddescr>&lt;b&gt;Directory Interfaces&lt;/b&gt;</fielddescr>
+ <fieldname>directory_interfaces</fieldname>
+ <description></description>
+ <type>listtopic</type>
+ </field>
+ <field>
+ <fielddescr>mod_ldap</fielddescr>
+ <fieldname>mod_ldap</fieldname>
+ <description>LDAP module made to obtain dialplans, user accounts, etc.</description>
+ <type>select</type>
+ <options>
+ <option>
+ <name>enable</name>
+ <value>enable</value>
+ </option>
+ <option>
+ <name>disable</name>
+ <value>disable</value>
+ </option>
+ </options>
+ </field>
+ <field>
+ <fielddescr>&lt;b&gt;Endpoints&lt;/b&gt;</fielddescr>
+ <fieldname>endpoints</fieldname>
+ <description></description>
+ <type>listtopic</type>
+ </field>
+ <field>
+ <fielddescr>mod_dingaling</fielddescr>
+ <fieldname>mod_dingaling</fieldname>
+ <description>Jabber/GoogleTalk Talk integration module.</description>
+ <type>select</type>
+ <options>
+ <option>
+ <name>enable</name>
+ <value>enable</value>
+ </option>
+ <option>
+ <name>disable</name>
+ <value>disable</value>
+ </option>
+ </options>
+ </field>
+ <field>
+ <fielddescr>mod_iax</fielddescr>
+ <fieldname>mod_iax</fieldname>
+ <description>IAX2.</description>
+ <type>select</type>
+ <options>
+ <option>
+ <name>enable</name>
+ <value>enable</value>
+ </option>
+ <option>
+ <name>disable</name>
+ <value>disable</value>
+ </option>
+ </options>
+ </field>
+ <field>
+ <fielddescr>mod_portaudio</fielddescr>
+ <fieldname>mod_portaudio</fieldname>
+ <description>Voice through a local soundcard.</description>
+ <type>select</type>
+ <options>
+ <option>
+ <name>enable</name>
+ <value>enable</value>
+ </option>
+ <option>
+ <name>disable</name>
+ <value>disable</value>
+ </option>
+ </options>
+ </field>
+ <field>
+ <fielddescr>mod_alsa</fielddescr>
+ <fieldname>mod_alsa</fieldname>
+ <description></description>
+ <type>select</type>
+ <options>
+ <option>
+ <name>enable</name>
+ <value>enable</value>
+ </option>
+ <option>
+ <name>disable</name>
+ <value>disable</value>
+ </option>
+ </options>
+ </field>
+ <field>
+ <fielddescr>mod_sofia</fielddescr>
+ <fieldname>mod_sofia</fieldname>
+ <description>SIP module.</description>
+ <type>select</type>
+ <options>
+ <option>
+ <name>enable</name>
+ <value>enable</value>
+ </option>
+ <option>
+ <name>disable</name>
+ <value>disable</value>
+ </option>
+ </options>
+ </field>
+ <field>
+ <fielddescr>mod_loopback</fielddescr>
+ <fieldname>mod_loopback</fieldname>
+ <description>A loopback channel driver to make an outbound call as an inbound call.</description>
+ <type>select</type>
+ <options>
+ <option>
+ <name>enable</name>
+ <value>enable</value>
+ </option>
+ <option>
+ <name>disable</name>
+ <value>disable</value>
+ </option>
+ </options>
+ </field>
+ <field>
+ <fielddescr>mod_wanpipe</fielddescr>
+ <fieldname>mod_wanpipe</fieldname>
+ <description>T1/E1 Sangoma Card module.</description>
+ <type>select</type>
+ <options>
+ <option>
+ <name>enable</name>
+ <value>enable</value>
+ </option>
+ <option>
+ <name>disable</name>
+ <value>disable</value>
+ </option>
+ </options>
+ </field>
+ <field>
+ <fielddescr>mod_woomera</fielddescr>
+ <fieldname>mod_woomera</fieldname>
+ <description>H.323/Woomera module.</description>
+ <type>select</type>
+ <options>
+ <option>
+ <name>enable</name>
+ <value>enable</value>
+ </option>
+ <option>
+ <name>disable</name>
+ <value>disable</value>
+ </option>
+ </options>
+ </field>
+ <field>
+ <fielddescr>mod_openzap</fielddescr>
+ <fieldname>mod_openzap</fieldname>
+ <description>Interface to Zaptel hardware.</description>
+ <type>select</type>
+ <options>
+ <option>
+ <name>enable</name>
+ <value>enable</value>
+ </option>
+ <option>
+ <name>disable</name>
+ <value>disable</value>
+ </option>
+ </options>
+ </field>
+ <field>
+ <fielddescr>&lt;b&gt;Applications&lt;/b&gt;</fielddescr>
+ <fieldname>applications</fieldname>
+ <description></description>
+ <type>listtopic</type>
+ </field>
+ <field>
+ <fielddescr>mod_commands</fielddescr>
+ <fieldname>mod_commands</fieldname>
+ <description>A mass plethora of API interface commands.</description>
+ <type>select</type>
+ <options>
+ <option>
+ <name>enable</name>
+ <value>enable</value>
+ </option>
+ <option>
+ <name>disable</name>
+ <value>disable</value>
+ </option>
+ </options>
+ </field>
+ <field>
+ <fielddescr>mod_conference</fielddescr>
+ <fieldname>mod_conference</fieldname>
+ <description>Conference room module.</description>
+ <type>select</type>
+ <options>
+ <option>
+ <name>enable</name>
+ <value>enable</value>
+ </option>
+ <option>
+ <name>disable</name>
+ <value>disable</value>
+ </option>
+ </options>
+ </field>
+ <field>
+ <fielddescr>mod_dptools</fielddescr>
+ <fieldname>mod_dptools</fieldname>
+ <description>Dialplan Tools: provides a number of apps and utilities for the dialplan.</description>
+ <type>select</type>
+ <options>
+ <option>
+ <name>enable</name>
+ <value>enable</value>
+ </option>
+ <option>
+ <name>disable</name>
+ <value>disable</value>
+ </option>
+ </options>
+ </field>
+ <field>
+ <fielddescr>mod_expr</fielddescr>
+ <fieldname>mod_expr</fieldname>
+ <description>Brian Allen Vanderburgs expression evaluation library.</description>
+ <type>select</type>
+ <options>
+ <option>
+ <name>enable</name>
+ <value>enable</value>
+ </option>
+ <option>
+ <name>disable</name>
+ <value>disable</value>
+ </option>
+ </options>
+ </field>
+ <field>
+ <fielddescr>mod_fax</fielddescr>
+ <fieldname>mod_fax</fieldname>
+ <description>FAX provides fax send and receive.</description>
+ <type>select</type>
+ <options>
+ <option>
+ <name>enable</name>
+ <value>enable</value>
+ </option>
+ <option>
+ <name>disable</name>
+ <value>disable</value>
+ </option>
+ </options>
+ </field>
+ <field>
+ <fielddescr>mod_fifo</fielddescr>
+ <fieldname>mod_fifo</fieldname>
+ <description>FIFO provides custom call queues including call park.</description>
+ <type>select</type>
+ <options>
+ <option>
+ <name>enable</name>
+ <value>enable</value>
+ </option>
+ <option>
+ <name>disable</name>
+ <value>disable</value>
+ </option>
+ </options>
+ </field>
+ <field>
+ <fielddescr>mod_voicemail</fielddescr>
+ <fieldname>mod_voicemail</fieldname>
+ <description>Full featured voicemail module.</description>
+ <type>select</type>
+ <options>
+ <option>
+ <name>enable</name>
+ <value>enable</value>
+ </option>
+ <option>
+ <name>disable</name>
+ <value>disable</value>
+ </option>
+ </options>
+ </field>
+ <field>
+ <fielddescr>mod_limit</fielddescr>
+ <fieldname>mod_limit</fieldname>
+ <description>Resource limitation module.</description>
+ <type>select</type>
+ <options>
+ <option>
+ <name>enable</name>
+ <value>enable</value>
+ </option>
+ <option>
+ <name>disable</name>
+ <value>disable</value>
+ </option>
+ </options>
+ </field>
+ <field>
+ <fielddescr>mod_esf</fielddescr>
+ <fieldname>mod_esf</fieldname>
+ <description>Holds the multi cast paging application for SIP.</description>
+ <type>select</type>
+ <options>
+ <option>
+ <name>enable</name>
+ <value>enable</value>
+ </option>
+ <option>
+ <name>disable</name>
+ <value>disable</value>
+ </option>
+ </options>
+ </field>
+ <field>
+ <fielddescr>mod_fsv</fielddescr>
+ <fieldname>mod_fsv</fieldname>
+ <description>FreeSWITCH Video application (Recording and playback).</description>
+ <type>select</type>
+ <options>
+ <option>
+ <name>enable</name>
+ <value>enable</value>
+ </option>
+ <option>
+ <name>disable</name>
+ <value>disable</value>
+ </option>
+ </options>
+ </field>
+ <field>
+ <fielddescr>&lt;b&gt;SNOM Module&lt;/b&gt;</fielddescr>
+ <fieldname>snom_module</fieldname>
+ <description></description>
+ <type>listtopic</type>
+ </field>
+ <field>
+ <fielddescr>mod_snom</fielddescr>
+ <fieldname>mod_snom</fieldname>
+ <description></description>
+ <type>select</type>
+ <options>
+ <option>
+ <name>enable</name>
+ <value>enable</value>
+ </option>
+ <option>
+ <name>disable</name>
+ <value>disable</value>
+ </option>
+ </options>
+ </field>
+ <field>
+ <fielddescr>&lt;b&gt;Dialplan Interfaces&lt;/b&gt;</fielddescr>
+ <fieldname>dialplan_interfaces</fieldname>
+ <description></description>
+ <type>listtopic</type>
+ </field>
+ <field>
+ <fielddescr>mod_dialplan_directory</fielddescr>
+ <fieldname>mod_dialplan_directory</fieldname>
+ <description>Allows you to obtain a dialplan from a directory resource.</description>
+ <type>select</type>
+ <options>
+ <option>
+ <name>enable</name>
+ <value>enable</value>
+ </option>
+ <option>
+ <name>disable</name>
+ <value>disable</value>
+ </option>
+ </options>
+ </field>
+ <field>
+ <fielddescr>mod_dialplan_xml</fielddescr>
+ <fieldname>mod_dialplan_xml</fieldname>
+ <description>Allows you to program dialplans in XML format.</description>
+ <type>select</type>
+ <options>
+ <option>
+ <name>enable</name>
+ <value>enable</value>
+ </option>
+ <option>
+ <name>disable</name>
+ <value>disable</value>
+ </option>
+ </options>
+ </field>
+ <field>
+ <fielddescr>mod_dialplan_asterisk</fielddescr>
+ <fieldname>mod_dialplan_asterisk</fieldname>
+ <description>Allows you to create dialplans the old-fashioned way.</description>
+ <type>select</type>
+ <options>
+ <option>
+ <name>enable</name>
+ <value>enable</value>
+ </option>
+ <option>
+ <name>disable</name>
+ <value>disable</value>
+ </option>
+ </options>
+ </field>
+ <field>
+ <fielddescr>mod_yaml</fielddescr>
+ <fieldname>mod_yaml</fieldname>
+ <description>Allows you to program dialplans in YAML format.</description>
+ <type>select</type>
+ <options>
+ <option>
+ <name>enable</name>
+ <value>enable</value>
+ </option>
+ <option>
+ <name>disable</name>
+ <value>disable</value>
+ </option>
+ </options>
+ </field>
+ <field>
+ <fielddescr>&lt;b&gt;Codec Interfaces&lt;/b&gt;</fielddescr>
+ <fieldname>codec_interfaces</fieldname>
+ <description></description>
+ <type>listtopic</type>
+ </field>
+ <field>
+ <fielddescr>mod_voipcodecs</fielddescr>
+ <fieldname>mod_voipcodecs</fieldname>
+ <description></description>
+ <type>select</type>
+ <options>
+ <option>
+ <name>enable</name>
+ <value>enable</value>
+ </option>
+ <option>
+ <name>disable</name>
+ <value>disable</value>
+ </option>
+ </options>
+ </field>
+ <field>
+ <fielddescr>mod_g723_1</fielddescr>
+ <fieldname>mod_g723_1</fieldname>
+ <description>G.723.1 codec.</description>
+ <type>select</type>
+ <options>
+ <option>
+ <name>enable</name>
+ <value>enable</value>
+ </option>
+ <option>
+ <name>disable</name>
+ <value>disable</value>
+ </option>
+ </options>
+ </field>
+ <field>
+ <fielddescr>mod_g729</fielddescr>
+ <fieldname>mod_g729</fieldname>
+ <description>G729 codec is only supported in passthrough mode.</description>
+ <type>select</type>
+ <options>
+ <option>
+ <name>enable</name>
+ <value>enable</value>
+ </option>
+ <option>
+ <name>disable</name>
+ <value>disable</value>
+ </option>
+ </options>
+ </field>
+ <field>
+ <fielddescr>mod_amr</fielddescr>
+ <fieldname>mod_amr</fieldname>
+ <description>amr codec.</description>
+ <type>select</type>
+ <options>
+ <option>
+ <name>enable</name>
+ <value>enable</value>
+ </option>
+ <option>
+ <name>disable</name>
+ <value>disable</value>
+ </option>
+ </options>
+ </field>
+ <field>
+ <fielddescr>mod_ilbc</fielddescr>
+ <fieldname>mod_ilbc</fieldname>
+ <description>ILBC codec.</description>
+ <type>select</type>
+ <options>
+ <option>
+ <name>enable</name>
+ <value>enable</value>
+ </option>
+ <option>
+ <name>disable</name>
+ <value>disable</value>
+ </option>
+ </options>
+ </field>
+ <field>
+ <fielddescr>mod_speex</fielddescr>
+ <fieldname>mod_speex</fieldname>
+ <description>Speex codec.</description>
+ <type>select</type>
+ <options>
+ <option>
+ <name>enable</name>
+ <value>enable</value>
+ </option>
+ <option>
+ <name>disable</name>
+ <value>disable</value>
+ </option>
+ </options>
+ </field>
+ <field>
+ <fielddescr>mod_siren</fielddescr>
+ <fieldname>mod_siren</fieldname>
+ <description>Siren codec.</description>
+ <type>select</type>
+ <options>
+ <option>
+ <name>enable</name>
+ <value>enable</value>
+ </option>
+ <option>
+ <name>disable</name>
+ <value>disable</value>
+ </option>
+ </options>
+ </field>
+ <field>
+ <fielddescr>mod_celt</fielddescr>
+ <fieldname>mod_celt</fieldname>
+ <description>Celt codec.</description>
+ <type>select</type>
+ <options>
+ <option>
+ <name>enable</name>
+ <value>enable</value>
+ </option>
+ <option>
+ <name>disable</name>
+ <value>disable</value>
+ </option>
+ </options>
+ </field>
+ <field>
+ <fielddescr>mod_h26x</fielddescr>
+ <fieldname>mod_h26x</fieldname>
+ <description>H26X signed linear codec. Video Pass-thru.</description>
+ <type>select</type>
+ <options>
+ <option>
+ <name>enable</name>
+ <value>enable</value>
+ </option>
+ <option>
+ <name>disable</name>
+ <value>disable</value>
+ </option>
+ </options>
+ </field>
+ <field>
+ <fielddescr>&lt;b&gt;File Format Interfaces&lt;/b&gt;</fielddescr>
+ <fieldname>file_format_interfaces</fieldname>
+ <description></description>
+ <type>listtopic</type>
+ </field>
+ <field>
+ <fielddescr>mod_sndfile</fielddescr>
+ <fieldname>mod_sndfile</fieldname>
+ <description>Multi-format file format transcoder (WAV, etc).</description>
+ <type>select</type>
+ <options>
+ <option>
+ <name>enable</name>
+ <value>enable</value>
+ </option>
+ <option>
+ <name>disable</name>
+ <value>disable</value>
+ </option>
+ </options>
+ </field>
+ <field>
+ <fielddescr>mod_native_file</fielddescr>
+ <fieldname>mod_native_file</fieldname>
+ <description>File interface for codec specific file formats.</description>
+ <type>select</type>
+ <options>
+ <option>
+ <name>enable</name>
+ <value>enable</value>
+ </option>
+ <option>
+ <name>disable</name>
+ <value>disable</value>
+ </option>
+ </options>
+ </field>
+ <field>
+ <fielddescr>&lt;b&gt;Streams/Files&lt;/b&gt;</fielddescr>
+ <fieldname>streams_files</fieldname>
+ <description></description>
+ <type>listtopic</type>
+ </field>
+ <field>
+ <fielddescr>mod_shout</fielddescr>
+ <fieldname>mod_shout</fieldname>
+ <description>mp3 files and shoutcast streams.</description>
+ <type>select</type>
+ <options>
+ <option>
+ <name>enable</name>
+ <value>enable</value>
+ </option>
+ <option>
+ <name>disable</name>
+ <value>disable</value>
+ </option>
+ </options>
+ </field>
+ <field>
+ <fielddescr>mod_local_stream</fielddescr>
+ <fieldname>mod_local_stream</fieldname>
+ <description>For local streams (play all the files in a directory).</description>
+ <type>select</type>
+ <options>
+ <option>
+ <name>enable</name>
+ <value>enable</value>
+ </option>
+ <option>
+ <name>disable</name>
+ <value>disable</value>
+ </option>
+ </options>
+ </field>
+ <field>
+ <fielddescr>mod_tone_stream</fielddescr>
+ <fieldname>mod_tone_stream</fieldname>
+ <description>Generate tone streams.</description>
+ <type>select</type>
+ <options>
+ <option>
+ <name>enable</name>
+ <value>enable</value>
+ </option>
+ <option>
+ <name>disable</name>
+ <value>disable</value>
+ </option>
+ </options>
+ </field>
+ <field>
+ <fielddescr>&lt;b&gt;Languages&lt;/b&gt;</fielddescr>
+ <fieldname>languages</fieldname>
+ <description></description>
+ <type>listtopic</type>
+ </field>
+ <field>
+ <fielddescr>mod_spidermonkey</fielddescr>
+ <fieldname>mod_spidermonkey</fieldname>
+ <description>JavaScript support.</description>
+ <type>select</type>
+ <options>
+ <option>
+ <name>enable</name>
+ <value>enable</value>
+ </option>
+ <option>
+ <name>disable</name>
+ <value>disable</value>
+ </option>
+ </options>
+ </field>
+ <field>
+ <fielddescr>mod_perl</fielddescr>
+ <fieldname>mod_perl</fieldname>
+ <description>Perl support.</description>
+ <type>select</type>
+ <options>
+ <option>
+ <name>enable</name>
+ <value>enable</value>
+ </option>
+ <option>
+ <name>disable</name>
+ <value>disable</value>
+ </option>
+ </options>
+ </field>
+ <field>
+ <fielddescr>mod_python</fielddescr>
+ <fieldname>mod_python</fieldname>
+ <description>Python support.</description>
+ <type>select</type>
+ <options>
+ <option>
+ <name>enable</name>
+ <value>enable</value>
+ </option>
+ <option>
+ <name>disable</name>
+ <value>disable</value>
+ </option>
+ </options>
+ </field>
+ <field>
+ <fielddescr>mod_java</fielddescr>
+ <fieldname>mod_java</fieldname>
+ <description>Java support.</description>
+ <type>select</type>
+ <options>
+ <option>
+ <name>enable</name>
+ <value>enable</value>
+ </option>
+ <option>
+ <name>disable</name>
+ <value>disable</value>
+ </option>
+ </options>
+ </field>
+ <field>
+ <fielddescr>mod_lua</fielddescr>
+ <fieldname>mod_lua</fieldname>
+ <description>Lua support.</description>
+ <type>select</type>
+ <options>
+ <option>
+ <name>enable</name>
+ <value>enable</value>
+ </option>
+ <option>
+ <name>disable</name>
+ <value>disable</value>
+ </option>
+ </options>
+ </field>
+ <field>
+ <fielddescr>&lt;b&gt;ASR /TTS&lt;/b&gt;</fielddescr>
+ <fieldname>asr_tts</fieldname>
+ <description></description>
+ <type>listtopic</type>
+ </field>
+ <field>
+ <fielddescr>mod_flite</fielddescr>
+ <fieldname>mod_flite</fieldname>
+ <description>Free open source Text to Speech.</description>
+ <type>select</type>
+ <options>
+ <option>
+ <name>enable</name>
+ <value>enable</value>
+ </option>
+ <option>
+ <name>disable</name>
+ <value>disable</value>
+ </option>
+ </options>
+ </field>
+ <field>
+ <fielddescr>mod_pocketsphinx</fielddescr>
+ <fieldname>mod_pocketsphinx</fieldname>
+ <description>Free open source Speech Recognition.</description>
+ <type>select</type>
+ <options>
+ <option>
+ <name>enable</name>
+ <value>enable</value>
+ </option>
+ <option>
+ <name>disable</name>
+ <value>disable</value>
+ </option>
+ </options>
+ </field>
+ <field>
+ <fielddescr>mod_cepstral</fielddescr>
+ <fieldname>mod_cepstral</fieldname>
+ <description>Links into Cepstral for dynamic sound output. Not available on this build.</description>
+ <type>select</type>
+ <options>
+ <option>
+ <name>enable</name>
+ <value>enable</value>
+ </option>
+ <option>
+ <name>disable</name>
+ <value>disable</value>
+ </option>
+ </options>
+ </field>
+ <field>
+ <fielddescr>mod_openmrcp</fielddescr>
+ <fieldname>mod_openmrcp</fieldname>
+ <description>Module for an open MRCP implementation.</description>
+ <type>select</type>
+ <options>
+ <option>
+ <name>enable</name>
+ <value>enable</value>
+ </option>
+ <option>
+ <name>disable</name>
+ <value>disable</value>
+ </option>
+ </options>
+ </field>
+ <field>
+ <fielddescr>mod_rss</fielddescr>
+ <fieldname>mod_rss</fieldname>
+ <description>Reads RSS feeds via a TTS engine.</description>
+ <type>select</type>
+ <options>
+ <option>
+ <name>enable</name>
+ <value>enable</value>
+ </option>
+ <option>
+ <name>disable</name>
+ <value>disable</value>
+ </option>
+ </options>
+ </field>
+ <field>
+ <fielddescr>&lt;b&gt;Say&lt;/b&gt;</fielddescr>
+ <fieldname>say</fieldname>
+ <description></description>
+ <type>listtopic</type>
+ </field>
+ <field>
+ <fielddescr>mod_say_en</fielddescr>
+ <fieldname>mod_say_en</fieldname>
+ <description></description>
+ <type>select</type>
+ <options>
+ <option>
+ <name>enable</name>
+ <value>enable</value>
+ </option>
+ <option>
+ <name>disable</name>
+ <value>disable</value>
+ </option>
+ </options>
+ </field>
+ <field>
+ <fielddescr>mod_say_zh</fielddescr>
+ <fieldname>mod_say_zh</fieldname>
+ <description></description>
+ <type>select</type>
+ <options>
+ <option>
+ <name>enable</name>
+ <value>enable</value>
+ </option>
+ <option>
+ <name>disable</name>
+ <value>disable</value>
+ </option>
+ </options>
+ </field>
+ </fields>
+ <custom_add_php_command>
+ </custom_add_php_command>
+ <custom_php_resync_config_command>
+ sync_package_freeswitch_modules();
+ </custom_php_resync_config_command>
+ <custom_delete_php_command>
+ sync_package_freeswitch_modules();
+ </custom_delete_php_command>
+ <custom_php_deinstall_command>
+ </custom_php_deinstall_command>
+</packagegui> \ No newline at end of file
diff --git a/config/freeswitch/freeswitch_public.xml b/config/freeswitch/freeswitch_public.xml
new file mode 100644
index 00000000..fab77635
--- /dev/null
+++ b/config/freeswitch/freeswitch_public.xml
@@ -0,0 +1,135 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<!DOCTYPE packagegui SYSTEM "./schema/packages.dtd">
+<packagegui>
+ <copyright>
+ <![CDATA[
+/* $Id$ */
+/* ========================================================================== */
+/*
+ freeswitch_public.xml
+ Copyright (C) 2008 Mark J Crane
+ All rights reserved.
+
+ FreeSWITCH (TM)
+ http://www.freeswitch.org/
+
+ part of pfSense (http://www.pfSense.com)
+ Copyright (C) 2007 to whom it may belong
+ All rights reserved.
+
+ Based on m0n0wall (http://m0n0.ch/wall)
+ Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>.
+ All rights reserved.
+ */
+/* ========================================================================== */
+/*
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+ */
+/* ========================================================================== */
+ ]]>
+ </copyright>
+ <description>FreeSWITCH is an open source telephony platform designed to facilitate the creation of voice and chat driven products scaling from a soft-phone up to a soft-switch. It can be used as a simple switching engine, a PBX, a media gateway or a media server to host IVR applications using simple scripts or XML to control the callflow.</description>
+ <requirements>Describe your package requirements here</requirements>
+ <faq>Currently there are no FAQ items provided.</faq>
+ <name>freeswitchpublic</name>
+ <version>0.1</version>
+ <title>FreeSWITCH: Public</title>
+ <aftersaveredirect>pkg_edit.php?xml=freeswitch_public.xml&amp;id=0</aftersaveredirect>
+ <include_file>/usr/local/pkg/freeswitch.inc</include_file>
+ <tabs>
+ <tab>
+ <text>Settings</text>
+ <url>/pkg_edit.php?xml=freeswitch.xml&amp;id=0</url>
+ </tab>
+ <tab>
+ <text>Dialplan</text>
+ <url>/freeswitch/freeswitch_dialplan_includes.php</url>
+ </tab>
+ <tab>
+ <text>Extensions</text>
+ <url>/freeswitch/freeswitch_extensions.php</url>
+ </tab>
+ <tab>
+ <text>External</text>
+ <url>/pkg_edit.php?xml=freeswitch_external.xml&amp;id=0</url>
+ </tab>
+ <tab>
+ <text>Gateways</text>
+ <url>/freeswitch/freeswitch_gateways.php</url>
+ </tab>
+ <tab>
+ <text>Internal</text>
+ <url>/pkg_edit.php?xml=freeswitch_internal.xml&amp;id=0</url>
+ </tab>
+ <tab>
+ <text>IVR</text>
+ <url>/freeswitch/freeswitch_ivr.php</url>
+ </tab>
+ <tab>
+ <text>Modules</text>
+ <url>/pkg_edit.php?xml=freeswitch_modules.xml&amp;id=0</url>
+ </tab>
+ <tab>
+ <text>Public</text>
+ <url>/freeswitch/freeswitch_public_includes.php</url>
+ <active/>
+ </tab>
+ <tab>
+ <text>Rec</text>
+ <url>/freeswitch/freeswitch_recordings.php</url>
+ </tab>
+ <tab>
+ <text>Status</text>
+ <url>/freeswitch/freeswitch_status.php</url>
+ </tab>
+ <tab>
+ <text>Vars</text>
+ <url>/pkg_edit.php?xml=freeswitch_vars.xml&amp;id=0</url>
+ </tab>
+ </tabs>
+ <configpath>installedpackages->package->$packagename->configuration->freeswitchpublic</configpath>
+ <fields>
+ <field>
+ <fielddescr>&lt;b&gt;Public&lt;/b&gt; &lt;br /&gt; &lt;br /&gt;Directs inbound calls to extensions, IVRs, external numbers, and scripts. </fielddescr>
+ <fieldname>public_xml</fieldname>
+ <description>&lt;br /&gt;Path: /usr/local/freeswitch/conf/dialplan/public.xml &lt;br /&gt;&lt;br /&gt;</description>
+ <type>textarea</type>
+ <encoding>base64</encoding>
+ <wrap>off</wrap>
+ <size>30</size>
+ <cols>70</cols>
+ <rows>33</rows>
+ </field>
+ </fields>
+ <custom_php_command_before_form>
+ </custom_php_command_before_form>
+ <custom_php_after_head_command>
+ sync_package_freeswitch_public();
+ </custom_php_after_head_command>
+ <custom_php_after_form_command>
+ </custom_php_after_form_command>
+ <custom_php_validation_command>
+ </custom_php_validation_command>
+ <custom_php_resync_config_command>
+ sync_package_freeswitch_public();
+ </custom_php_resync_config_command>
+</packagegui> \ No newline at end of file
diff --git a/config/freeswitch/freeswitch_public_includes.tmp b/config/freeswitch/freeswitch_public_includes.tmp
new file mode 100644
index 00000000..66f733b3
--- /dev/null
+++ b/config/freeswitch/freeswitch_public_includes.tmp
@@ -0,0 +1,275 @@
+<?php
+/* $Id$ */
+/*
+ freeswitch_public_includes.php
+ Copyright (C) 2008 Mark J Crane
+ All rights reserved.
+
+ FreeSWITCH (TM)
+ http://www.freeswitch.org/
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+require("guiconfig.inc");
+require("/usr/local/pkg/freeswitch.inc");
+
+
+//freeswitchpublicincludes
+ //publicincludeid
+ //extensionname
+ //context
+ //default
+ //enabled
+ //descr
+
+//freeswitchpublicincludedetails
+
+ //publicincludeid
+ //tag
+ //condition
+ //action
+ //antiaction
+ //param
+ //tagorder
+ //1-20
+ //fieldtype
+
+ //fielddata
+
+
+$a_public_includes = &$config['installedpackages']['freeswitchpublicincludes']['config'];
+$a_public_includes_details = &$config['installedpackages']['freeswitchpublicincludedetails']['config'];
+
+
+if ($_GET['act'] == "del") {
+ if ($_GET['type'] == 'publicincludes') {
+
+ if ($a_public_includes[$_GET['id']]) {
+
+ $publicincludeid = $a_public_includes[$_GET['id']][publicincludeid];
+
+ $extensionname = $a_public_includes[$_GET['id']][extensionname];
+ $order = $a_public_includes[$_GET['id']][order];
+ $publicincludefilename = $order."_".$extensionname.".xml";
+
+ //delete the public include details. aka. child data
+ if (count($a_public_includes_details) > 0) {
+ $i=0;
+ if (count($a_public_includes_details) > 0) {
+ foreach($a_public_includes_details as $row) {
+ if ($row["publicincludeid"] == $publicincludeid) {
+ //echo "child id: ".$i."<br />\n";
+ unset($a_public_includes_details[$i]);
+ }
+ $i++;
+ }
+ }
+ }
+
+ //if the public include xml file exists then delete it
+ if (file_exists("/usr/local/freeswitch/conf/public/default/".$publicincludefilename)) {
+ unlink("/usr/local/freeswitch/conf/public/default/".$publicincludefilename);
+ }
+
+ unset($publicincludefilename);
+ unset($a_public_includes[$_GET['id']]);
+ write_config();
+ sync_package_freeswitch_public_includes();
+ header("Location: freeswitch_public_includes.php");
+ exit;
+ }
+ }
+}
+
+include("head.inc");
+
+?>
+
+<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
+<?php include("fbegin.inc"); ?>
+<p class="pgtitle">FreeSWITCH: Public</p>
+
+<div id="mainlevel">
+<table width="100%" border="0" cellpadding="0" cellspacing="0">
+<tr><td class="tabnavtbl">
+<?php
+
+ $tab_array = array();
+ $tab_array[] = array(gettext("Settings"), false, "/pkg_edit.php?xml=freeswitch.xml&amp;id=0");
+ $tab_array[] = array(gettext("Dialplan"), false, "/freeswitch/freeswitch_dialplan_includes.php");
+ $tab_array[] = array(gettext("Extensions"), false, "/freeswitch/freeswitch_extensions.php");
+ $tab_array[] = array(gettext("External"), false, "/pkg_edit.php?xml=freeswitch_external.xml&amp;id=0");
+ $tab_array[] = array(gettext("Gateways"), false, "/freeswitch/freeswitch_gateways.php");
+ $tab_array[] = array(gettext("Internal"), false, "/pkg_edit.php?xml=freeswitch_internal.xml&amp;id=0");
+ $tab_array[] = array(gettext("IVR"), false, "/freeswitch/freeswitch_ivr.php");
+ $tab_array[] = array(gettext("Modules"), false, "/pkg_edit.php?xml=freeswitch_modules.xml&amp;id=0");
+ $tab_array[] = array(gettext("Public"), true, "/freeswitch/freeswitch_public_includes.php");
+ $tab_array[] = array(gettext("Rec"), false, "/freeswitch/freeswitch_recordings.php");
+ $tab_array[] = array(gettext("Status"), false, "/freeswitch/freeswitch_status.php");
+ $tab_array[] = array(gettext("Vars"), false, "/pkg_edit.php?xml=freeswitch_vars.xml&amp;id=0");
+ display_top_tabs($tab_array);
+
+?>
+</td></tr>
+</table>
+
+<table width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr>
+ <td class="tabcont" >
+
+<form action="freeswitch_public_includes.php" method="post" name="iform" id="iform">
+<?php
+
+
+//echo "<pre>";
+//print_r ($a_public_includes);
+//echo "</pre>";
+
+
+//if ($config_change == 1) {
+// write_config();
+// $config_change = 0;
+//}
+
+//if ($savemsg) print_info_box($savemsg);
+//if (file_exists($d_hostsdirty_path)): echo"<p>";
+//print_info_box_np("The FreeSWITCH recordings have been changed.<br>You must apply the changes in order for them to take effect.");
+//echo"<br />";
+//endif;
+
+?>
+
+ <br />
+ <br />
+
+ <table width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr>
+ <td><span class="vexpl"><span class="red"><strong>Public
+ </strong></span></span>
+ </td>
+ <td align='right'>
+ <input type='button' value='public.xml' alt='' onclick="document.location.href='/pkg_edit.php?xml=freeswitch_public.xml&id=0';">
+ </td>
+ </tr>
+ <tr>
+ <td colspan='2'>
+ <span class="vexpl">
+ The public dialplan is used to route incoming calls to destinations based on conditions and context. It can send incoming calls to IVRs, extensions, external numbers, and scripts.
+ </span>
+ </td>
+
+ </tr>
+ </table>
+
+ <br />
+ <br />
+ <br />
+
+ <table width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr>
+ <td width="20%" class="listhdrr">Extension Name</td>
+ <td width="25%" class="listhdrr">Order</td>
+ <td width="25%" class="listhdrr">Enabled</td>
+ <td width="50%" class="listhdr">Description</td>
+ <td width="10%" class="list">
+ <table border="0" cellspacing="0" cellpadding="1">
+ <tr>
+ <td width="17"></td>
+ <td valign="middle"><a href="freeswitch_public_includes_edit.php"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"></a></td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+
+ <?php
+ $i = 0;
+ if (count($a_public_includes) > 0) {
+ foreach ($a_public_includes as $ent) {
+ if (strlen($ent['extensionname'].$ent['enabled']) > 0) {
+ ?>
+ <tr>
+ <td class="listlr" ondblclick="document.location='freeswitch_public_includes_edit.php?id=<?=$i;?>'">
+ <?=$ent['extensionname']?>
+ </td>
+ <td class="listlr" ondblclick="document.location='freeswitch_public_includes_edit.php?id=<?=$i;?>'">
+ <?=$ent['order']?>
+ </td>
+ <td class="listr" ondblclick="document.location='freeswitch_public_includes_edit.php?id=<?=$i;?>';">
+ <?=$ent['enabled'];?>&nbsp;
+ </td>
+ <td class="listbg" ondblclick="document.location='freeswitch_public_includes_edit.php?id=<?=$i;?>';">
+ <font color="#FFFFFF"><?=htmlspecialchars($ent['descr']);?>&nbsp;
+ </td>
+ <td valign="middle" nowrap class="list">
+ <table border="0" cellspacing="0" cellpadding="1">
+ <tr>
+ <td valign="middle"><a href="freeswitch_public_includes_edit.php?id=<?=$i;?>"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" width="17" height="17" border="0"></a></td>
+ <td><a href="freeswitch_public_includes.php?type=publicincludes&act=del&id=<?=$i;?>" onclick="return confirm('Do you really want to delete this?')"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0"></a></td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ <?php
+ } //end if strlen
+ $i++;
+ } //end for each
+ } //end if count
+ ?>
+ <tr>
+ <td class="list" colspan="4"></td>
+ <td class="list">
+ <table border="0" cellspacing="0" cellpadding="1">
+ <tr>
+ <td width="17"></td>
+ <td valign="middle"><a href="freeswitch_public_includes_edit.php"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"></a></td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+
+ <tr>
+ <td class="list" colspan="4"></td>
+ <td class="list"></td>
+ </tr>
+ </table>
+
+</form>
+
+/usr/local/freeswitch/conf/dialplan/public/
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+
+</td>
+</tr>
+</table>
+
+</div>
+
+
+<?php include("fend.inc"); ?>
+</body>
+</html>
diff --git a/config/freeswitch/freeswitch_public_includes_details.tmp b/config/freeswitch/freeswitch_public_includes_details.tmp
new file mode 100644
index 00000000..c28a7647
--- /dev/null
+++ b/config/freeswitch/freeswitch_public_includes_details.tmp
@@ -0,0 +1,53 @@
+<?php
+/* $Id$ */
+/*
+ freeswitch_public_includes_details.php
+ Copyright (C) 2008 Mark J Crane
+ All rights reserved.
+
+ FreeSWITCH (TM)
+ http://www.freeswitch.org/
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+require("guiconfig.inc");
+require("/usr/local/pkg/freeswitch.inc");
+
+
+$a_public_include_details = &$config['installedpackages']['freeswitchpublicincludedetails']['config'];
+
+
+if ($_GET['act'] == "del") {
+ if ($_GET['type'] == 'publicincludedetails') {
+ if ($a_public_include_details[$_GET['id']]) {
+ unset($a_public_include_details[$_GET['id']]);
+ write_config();
+ sync_package_freeswitch_public_includes();
+ //touch($d_hostsdirty_path);
+ header("Location: freeswitch_public_includes_edit.php?id=".$_GET['parentid']);
+ exit;
+ }
+ }
+}
+
+?> \ No newline at end of file
diff --git a/config/freeswitch/freeswitch_public_includes_details_edit.tmp b/config/freeswitch/freeswitch_public_includes_details_edit.tmp
new file mode 100644
index 00000000..821d9097
--- /dev/null
+++ b/config/freeswitch/freeswitch_public_includes_details_edit.tmp
@@ -0,0 +1,410 @@
+<?php
+/* $Id$ */
+/*
+
+ freeswitch_public_includes_details_edit.php
+ Copyright (C) 2008 Mark J Crane
+ All rights reserved.
+
+ FreeSWITCH (TM)
+ http://www.freeswitch.org/
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+require("guiconfig.inc");
+require("/usr/local/pkg/freeswitch.inc");
+
+
+$a_public_includes_details = &$config['installedpackages']['freeswitchpublicincludedetails']['config'];
+
+$id = $_GET['id'];
+if (isset($_POST['id'])) {
+ $id = $_POST['id'];
+}
+
+$parentid = $_GET['parentid'];
+if (isset($_POST['parentid'])) {
+ $parentid = $_POST['parentid'];
+}
+
+$publicincludeid = $_GET['publicincludeid'];
+if (isset($_POST['publicincludeid'])) {
+ $publicincludeid = $_POST['publicincludeid'];
+}
+
+
+ //publicincludeid
+ //tag
+ //condition
+ //action
+ //antiaction
+ //param
+ //tagorder
+ //1-20
+ //fieldtype
+
+ //fielddata
+
+
+if (isset($id) && $a_public_includes_details[$id]) {
+ $pconfig['publicincludeid'] = $a_public_includes_details[$id]['publicincludeid'];
+ $pconfig['tag'] = $a_public_includes_details[$id]['tag'];
+ //$pconfig['tagorder'] = $a_public_includes_details[$id]['tagorder'];
+ $pconfig['fieldtype'] = $a_public_includes_details[$id]['fieldtype'];
+ $pconfig['fielddata'] = $a_public_includes_details[$id]['fielddata'];
+}
+//else {
+// if (isset($_GET['a'])) {
+// if ($_GET['a'] == "action"){ $pconfig['optionaction'] = "action"; }
+// if ($_GET['a'] == "antiaction"){ $pconfig['optionaction'] = "anti-action"; }
+// }
+//}
+
+
+
+if ($_POST) {
+
+ unset($input_errors);
+ $pconfig = $_POST;
+
+
+ if (!$input_errors) {
+
+ $ent = array();
+ $ent['publicincludeid'] = $_POST['publicincludeid'];
+ $ent['tag'] = $_POST['tag'];
+ //$ent['tagorder'] = $_POST['tagorder'];
+ $ent['fieldtype'] = $_POST['fieldtype'];
+ $ent['fielddata'] = $_POST['fielddata'];
+
+
+ if (isset($id) && $a_public_includes_details[$id]) {
+ //update
+ $a_public_includes_details[$id] = $ent;
+ }
+ else {
+ //add
+ $a_public_includes_details[] = $ent;
+ }
+
+ //touch($d_hostsdirty_path);
+ write_config();
+ sync_package_freeswitch_public_includes();
+
+ header("Location: freeswitch_public_includes_edit.php?id=".$parentid);
+ exit;
+ }
+}
+
+include("head.inc");
+
+?>
+
+<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
+<?php include("fbegin.inc"); ?>
+<p class="pgtitle">FreeSWITCH: Public: Details: Edit</p>
+
+<?php if ($input_errors) print_input_errors($input_errors); ?>
+
+<div id="mainlevel">
+<table width="100%" border="0" cellpadding="0" cellspacing="0">
+<tr><td class="tabnavtbl">
+<?php
+
+ $tab_array = array();
+ $tab_array[] = array(gettext("Settings"), false, "/pkg_edit.php?xml=freeswitch.xml&amp;id=0");
+ $tab_array[] = array(gettext("Dialplan"), false, "/freeswitch/freeswitch_dialplan_includes.php");
+ $tab_array[] = array(gettext("Extensions"), false, "/freeswitch/freeswitch_extensions.php");
+ $tab_array[] = array(gettext("External"), false, "/pkg_edit.php?xml=freeswitch_external.xml&amp;id=0");
+ $tab_array[] = array(gettext("Gateways"), false, "/freeswitch/freeswitch_gateways.php");
+ $tab_array[] = array(gettext("Internal"), false, "/pkg_edit.php?xml=freeswitch_internal.xml&amp;id=0");
+ $tab_array[] = array(gettext("IVR"), false, "/freeswitch/freeswitch_ivr.php");
+ $tab_array[] = array(gettext("Modules"), false, "/pkg_edit.php?xml=freeswitch_modules.xml&amp;id=0");
+ $tab_array[] = array(gettext("Public"), true, "/freeswitch/freeswitch_public_includes.php");
+ $tab_array[] = array(gettext("Rec"), false, "/freeswitch/freeswitch_recordings.php");
+ $tab_array[] = array(gettext("Status"), false, "/freeswitch/freeswitch_status.php");
+ $tab_array[] = array(gettext("Vars"), false, "/pkg_edit.php?xml=freeswitch_vars.xml&amp;id=0");
+ display_top_tabs($tab_array);
+
+?>
+</td></tr>
+</table>
+<table width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr>
+ <td class="tabcont" >
+
+ <form action="freeswitch_public_includes_details_edit.php" method="post" name="iform" id="iform">
+ <table width="100%" border="0" cellpadding="6" cellspacing="0">
+ <tr>
+ <td width="22%" valign="top" class="vncellreq">Tag</td>
+ <td width="78%" class="vtable">
+ <script type="text/javascript">
+ function public_include_details_tag_onchange() {
+ var tag = document.getElementById("form_tag").value;
+ if (tag == "condition") {
+ document.getElementById("label_fieldtype").innerHTML = "Field";
+ document.getElementById("label_fielddata").innerHTML = "Expression";
+ }
+ else if (tag == "action") {
+ document.getElementById("label_fieldtype").innerHTML = "Application";
+ document.getElementById("label_fielddata").innerHTML = "Data";
+ }
+ else if (tag == "anti-action") {
+ document.getElementById("label_fieldtype").innerHTML = "Application";
+ document.getElementById("label_fielddata").innerHTML = "Data";
+ }
+ else if (tag == "param") {
+ document.getElementById("label_fieldtype").innerHTML = "Name";
+ document.getElementById("label_fielddata").innerHTML = "Value";
+ }
+ if (tag == "") {
+ document.getElementById("label_fieldtype").innerHTML = "Type";
+ document.getElementById("label_fielddata").innerHTML = "Data";
+ }
+ }
+ </script>
+ <?php
+ echo " <select name='tag' class='formfld' id='form_tag' onchange='public_include_details_tag_onchange();'>\n";
+ echo " <option></option>\n";
+ switch (htmlspecialchars($pconfig['tag'])) {
+ case "condition":
+ echo " <option selected='yes'>condition</option>\n";
+ echo " <option>action</option>\n";
+ echo " <option>anti-action</option>\n";
+ //echo " <option>param</option>\n";
+ break;
+ case "action":
+ echo " <option>condition</option>\n";
+ echo " <option selected='yes'>action</option>\n";
+ echo " <option>anti-action</option>\n";
+ //echo " <option>param</option>\n";
+ break;
+ case "anti-action":
+ echo " <option>condition</option>\n";
+ echo " <option>action</option>\n";
+ echo " <option selected='yes'>anti-action</option>\n";
+ //echo " <option>param</option>\n";
+ break;
+ case "param":
+ echo " <option>condition</option>\n";
+ echo " <option>action</option>\n";
+ echo " <option>anti-action</option>\n";
+ //echo " <option selected='yes'>param</option>\n";
+ break;
+ default:
+ echo " <option>condition</option>\n";
+ echo " <option>action</option>\n";
+ echo " <option>anti-action</option>\n";
+ //echo " <option>param</option>\n";
+ }
+ echo " </select>\n";
+
+ //condition
+ //field expression
+ //action
+ //application
+ //data
+ //antiaction
+ //application
+ //data
+ //param
+ //name
+ //value
+
+ ?>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncellreq" id="label_fieldtype">Type</td>
+ <td width="78%" class="vtable">
+ <input name="fieldtype" type="text" class="formfld" id="fieldtype" size="40" value="<?=htmlspecialchars($pconfig['fieldtype']);?>">
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncellreq" id="label_fielddata">Data</td>
+ <td width="78%" class="vtable">
+ <input name="fielddata" type="text" class="formfld" id="fielddata" size="40" value="<?=htmlspecialchars($pconfig['fielddata']);?>">
+ <br> <span class="vexpl"></span></td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top">&nbsp;</td>
+ <td width="78%">
+ <input name="publicincludeid" type="hidden" value="<?=$publicincludeid;?>">
+ <input name="parentid" type="hidden" value="<?=$parentid;?>">
+ <?php if (isset($id) && $a_public_includes_details[$id]): ?>
+ <input name="id" type="hidden" value="<?=$id;?>">
+ <?php endif; ?>
+ <input name="Submit" type="submit" class="formbtn" value="Save"> <input class="formbtn" type="button" value="Cancel" onclick="history.back()">
+ </td>
+ </tr>
+ </table>
+ </form>
+
+
+ <br />
+ <br />
+ <b>Example</b>
+ <br />
+ <br />
+ If the inbound call matches the DID 12085551234 then proceed to the action.
+ <br />
+ <br />
+ <table cellpadding='3'>
+ <tr><th class="vncellreq" width='75' align="left">Tag:</th><td class="vtable">condition</td></tr>
+ <tr><th class="vncellreq" align="left">Type:</th><td class="vtable">destination_number</td></tr>
+ <tr><th class="vncellreq" align="left">Data:</th><td class="vtable">^(12085551234)$</td></tr>
+ </table>
+
+ <br />
+ <br />
+
+ Transfer the inbound call to an IVR with extension of 5000.
+ <br />
+ <br />
+ <table cellpadding='3'>
+ <tr><th class="vncellreq" width='75' align="left">Tag:</th><td class="vtable">action</td></tr>
+ <tr><th class="vncellreq" align="left">Application:</th><td class="vtable">transfer</td></tr>
+ <tr><th class="vncellreq" align="left">Data:</th><td class="vtable">5000 XML default</td></tr>
+ </table>
+
+ <br />
+ <br />
+
+ Or transfer the inbound call to extension 1001.
+ <br />
+ <br />
+ <table cellpadding='3'>
+ <tr><th class="vncellreq" width='75' align="left">Tag:</th><td class="vtable">action</td></tr>
+ <tr><th class="vncellreq" align="left">Application:</th><td class="vtable">transfer</td></tr>
+ <tr><th class="vncellreq" align="left">Data:</th><td class="vtable">1001 XML default</td></tr>
+ </table>
+
+
+ <br />
+ <br />
+ <br />
+ <br />
+
+
+ <b>Conditions</b>
+ <br />
+ <br />
+ Conditions are pattern matching tags that help FreeSwitch decide if the current call should be processed in this extension or not. When matching conditions against the current call you have several <b>fields</b> that you can compare against.
+ <ul>
+ <li><b>context</b></li>
+ <li><b>rdnis</b> Redirected Number, the directory number to which the call was last presented.</li>
+ <li><b>destination_number</b> Called Number, the number this call is trying to reach (within a given context)</li>
+ <li><b>public</b> Name of the public module that are used, the name is provided by each public module. Example: XML</li>
+ <li><b>caller_id_name</b> Name of the caller (provided by the User Agent that has called us).</li>
+ <li><b>caller_id_number</b> Directory Number of the party who called (callee) -- can be masked (hidden)</li>
+ <li><b>ani</b> Automatic Number Identification, the number of the calling party (callee) -- cannot be masked</li>
+ <li><b>ani2</b> The type of device placing the call [1]</li>
+ <li><b>uuid</b> Unique identifier of the current call? (looks like a GUID)</li>
+ <li><b>source</b> Name of the FreeSwitch module that received the call (e.g. PortAudio)</li>
+ <li><b>chan_name</b> Name of the current channel (Example: PortAudio/1234). Give us examples when this one can be used.</li>
+ <li><b>network_addr</b> IP address of the signalling source for a VoIP call.</li>
+ </ul>
+ In addition to the above you can also do variables using the syntax ${variable} or api functions using the syntax %{api} {args}
+ <br />
+ <br />
+ Variables may be used in either the field or the expression, as follows
+
+ <br />
+ <br />
+ <br />
+ <br />
+
+ <b>Action and Anti-Actions</b>
+ <br />
+ <br />
+ Actions are executed when the <b>condition matches</b>. Anti-Actions are executed when the <b>condition does NOT match</b>.
+ Additional information on applications for Actions and Anti-Actions.<br />
+ <a href='http://wiki.freeswitch.org/wiki/Modules#Applications' target='_blank'>http://wiki.freeswitch.org/wiki/Modules#Applications</a>
+ <br />
+ <a href='http://wiki.freeswitch.org/wiki/public_Functions' target='_blank'>http://wiki.freeswitch.org/wiki/public_Functions</a>
+ <br />
+ <br />
+ <br />
+ The following is a partial list of <b>applications</b>.
+ <ul>
+ <li><b>answer</b> answer the call</li>
+ <li><b>bridge</b> bridge the call<li>
+ <li><b>cond</b></li>
+ <li><b>db</b> is a a runtime database either sqlite by default or odbc</li>
+ <li><b>global_set</b> allows setting of global vars similar to the ones found in vars.xml</li>
+ <li><b>group</b> allows grouping of several extensions for things like ring groups</li>
+ <li><b>expr</b></li>
+ <li><b>hangup</b> hangs up the call</li>
+ <li><b>info</b> sends call info to the console</li>
+ <li><b>javascript</b> run javascript .js files</li>
+ <li><b>playback</b></li>
+ <li><b>reject</b> reject the call</li>
+ <li><b>respond</b></li>
+ <li><b>ring_ready</b></li>
+ <li><b>set</b> set a variable</li>
+ <li><b>set_user</b></li>
+ <li><b>sleep</b></li>
+ <li><b>sofia_contact</b></li>
+ <li><b>transfer</b> transfer the call to another extension or number<li>
+ <li><b>voicemail</b> send the call to voicemail</li>
+ </ul>
+
+
+ <br />
+ <br />
+
+ <!--
+ <b>Param</b>
+ Example parameters by name and value
+ <br />
+ <a href='http://wiki.freeswitch.org/wiki/Special:Search?search=param&go=Go' target='_blank'>http://wiki.freeswitch.org/wiki/Special:Search?search=param&go=Go</a>
+ <ul>
+ <li><b>codec-ms</b> 20</li>
+ <li><b>codec-prefs</b> PCMU@20i</li>
+ <li><b>debug</b> 1</li>
+ <li><b>public</b> XML</li>
+ <li><b>dtmf-duration</b> 100</li>
+ <li><b>rfc2833-pt</b>" 101</li>
+ <li><b>sip-port</b> 5060</li>
+ <li><b>use-rtp-timer</b> true</li>
+ </ul>
+ <br />
+ <br />
+ -->
+
+
+ <br />
+ <br />
+ <br />
+ <br />
+ <br />
+
+ </td>
+ </tr>
+</table>
+
+</div>
+
+<?php include("fend.inc"); ?>
+</body>
+</html>
diff --git a/config/freeswitch/freeswitch_public_includes_edit.tmp b/config/freeswitch/freeswitch_public_includes_edit.tmp
new file mode 100644
index 00000000..94454fd3
--- /dev/null
+++ b/config/freeswitch/freeswitch_public_includes_edit.tmp
@@ -0,0 +1,524 @@
+<?php
+/* $Id$ */
+/*
+
+ freeswitch_public_includes_edit.php
+ Copyright (C) 2008 Mark J Crane
+ All rights reserved.
+
+ FreeSWITCH (TM)
+ http://www.freeswitch.org/
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+require("guiconfig.inc");
+require("/usr/local/pkg/freeswitch.inc");
+
+
+
+//freeswitchpublicincludes
+ //publicincludeid
+ //extensionname
+ //context
+ //default
+ //enabled
+ //descr
+
+//
+
+
+
+$a_public_includes = &$config['installedpackages']['freeswitchpublicincludes']['config'];
+$a_public_include_details = &$config['installedpackages']['freeswitchpublicincludedetails']['config'];
+
+$id = $_GET['id'];
+if (isset($_POST['id'])) {
+ $id = $_POST['id'];
+}
+$parentid = $id;
+
+
+
+if (isset($id) && $a_public_includes[$id]) {
+ $pconfig['publicincludeid'] = $a_public_includes[$id]['publicincludeid'];
+ $publicincludeid = $a_public_includes[$id]['publicincludeid'];
+ $pconfig['extensionname'] = $a_public_includes[$id]['extensionname'];
+ $pconfig['order'] = $a_public_includes[$id]['order'];
+ $pconfig['context'] = $a_public_includes[$id]['context'];
+ $pconfig['enabled'] = $a_public_includes[$id]['enabled'];
+ $pconfig['descr'] = $a_public_includes[$id]['descr'];
+ $pconfig['opt1name'] = $a_public_includes[$id]['opt1name'];
+ $pconfig['opt1value'] = $a_public_includes[$id]['opt1value'];
+}
+
+if ($_POST) {
+
+ unset($input_errors);
+ $pconfig = $_POST;
+
+ if ($_GET['act'] == "del") {
+ if ($_GET['type'] == 'publicincludedetails') {
+ if ($a_public_include_details[$_GET['id']]) {
+ unset($a_public_include_details[$_GET['id']]);
+ write_config();
+ sync_package_freeswitch_public_includes();
+ header("Location: freeswitch_public_include_edit.php?id=".$_GET['id']);
+ exit;
+ }
+ }
+ }
+
+
+ if (!$input_errors) {
+
+ $ent = array();
+ if (strlen($_POST['publicincludeid']) > 0) {
+ //update
+ $ent['publicincludeid'] = $_POST['publicincludeid'];
+ }
+ else {
+ //add
+ $ent['publicincludeid'] = guid();
+ }
+ $ent['extensionname'] = $_POST['extensionname'];
+ $ent['order'] = $_POST['order'];
+ //$ent['context'] = $_POST['context'];
+ $ent['context'] = 'default';
+ $ent['enabled'] = $_POST['enabled'];
+ $ent['descr'] = $_POST['descr'];
+ $ent['opt1name'] = $_POST['opt1name'];
+ $ent['opt1value'] = $_POST['opt1value'];
+
+
+
+ if (isset($id) && $a_public_includes[$id]) {
+ $a_public_includes = $config['installedpackages']['freeswitchpublicincludes']['config'];
+ if (count($a_public_includes) > 0) {
+ foreach($a_public_includes as $rowhelper) {
+
+ //$rowhelper['publicincludeid'];
+ //$rowhelper['extensionname'];
+ //$rowhelper['context'];
+ //$rowhelper['enabled'];
+
+ $filenamechanged = false;
+ if ($rowhelper['publicincludeid'] == $_POST['publicincludeid']) {
+
+ if ($rowhelper['extensionname'] != $_POST['extensionname']) {
+ //if the extension name has changed then remove the current public xml file
+ //to prepare for the new file
+ $filenamechanged = true;
+ }
+ if ($rowhelper['order'] != $_POST['order']) {
+ //if the order has changed then remove the current public xml file
+ //to prepare for the new file
+ $filenamechanged = true;
+ }
+ if ($_POST['enabled'] == "false") {
+ //if the extension name is disabled then remove the public xml file
+ $filenamechanged = true;
+ }
+ if ($filenamechanged){
+ $publicincludefilename = $rowhelper['order']."_".$rowhelper['extensionname'].".xml";
+ if (file_exists("/usr/local/freeswitch/conf/dialplan/public/".$publicincludefilename)) {
+ unlink("/usr/local/freeswitch/conf/dialplan/public/".$publicincludefilename);
+ }
+ unset($publicincludefilename);
+ }
+
+ }
+ unset($filenamechanged);
+
+ } //end foreach
+ } //end if count
+
+ //update the config
+ $a_public_includes[$id] = $ent;
+ }
+ else {
+ //add to the config
+ $a_public_includes[] = $ent;
+ }
+
+
+ write_config();
+ sync_package_freeswitch_public_includes();
+
+ header("Location: freeswitch_public_includes.php");
+ exit;
+ }
+}
+
+include("head.inc");
+
+?>
+
+<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
+<?php include("fbegin.inc"); ?>
+<p class="pgtitle">FreeSWITCH: Public: Edit</p>
+<?php if ($input_errors) print_input_errors($input_errors); ?>
+
+
+<div id="mainlevel">
+<table width="100%" border="0" cellpadding="0" cellspacing="0">
+<tr><td class="tabnavtbl">
+<?php
+
+ $tab_array = array();
+ $tab_array[] = array(gettext("Settings"), false, "/pkg_edit.php?xml=freeswitch.xml&amp;id=0");
+ $tab_array[] = array(gettext("Dialplan"), false, "/freeswitch/freeswitch_dialplan_includes.php");
+ $tab_array[] = array(gettext("Extensions"), false, "/freeswitch/freeswitch_extensions.php");
+ $tab_array[] = array(gettext("External"), false, "/pkg_edit.php?xml=freeswitch_external.xml&amp;id=0");
+ $tab_array[] = array(gettext("Gateways"), false, "/freeswitch/freeswitch_gateways.php");
+ $tab_array[] = array(gettext("Internal"), false, "/pkg_edit.php?xml=freeswitch_internal.xml&amp;id=0");
+ $tab_array[] = array(gettext("IVR"), false, "/freeswitch/freeswitch_ivr.php");
+ $tab_array[] = array(gettext("Modules"), false, "/pkg_edit.php?xml=freeswitch_modules.xml&amp;id=0");
+ $tab_array[] = array(gettext("Public"), true, "/freeswitch/freeswitch_public_includes.php");
+ $tab_array[] = array(gettext("Rec"), false, "/freeswitch/freeswitch_recordings.php");
+ $tab_array[] = array(gettext("Status"), false, "/freeswitch/freeswitch_status.php");
+ $tab_array[] = array(gettext("Vars"), false, "/pkg_edit.php?xml=freeswitch_vars.xml&amp;id=0");
+ display_top_tabs($tab_array);
+
+?>
+</td></tr>
+</table>
+<table width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr>
+ <td class="tabcont" >
+
+ <table width="100%" border="0" cellpadding="6" cellspacing="0">
+ <tr>
+ <td><p><span class="vexpl"><span class="red"><strong>Public:<br>
+ </strong></span>
+ Public Include general settings.
+ </span></p></td>
+ </tr>
+ </table>
+ <br />
+
+ <form action="freeswitch_public_includes_edit.php" method="post" name="iform" id="iform">
+ <table width="100%" border="0" cellpadding="6" cellspacing="0">
+ <tr>
+ <td width="22%" valign="top" class="vncellreq">Extension Name</td>
+ <td width="78%" class="vtable">
+ <input name="extensionname" type="text" class="formfld" id="extensionname" size="40" value="<?=htmlspecialchars($pconfig['extensionname']);?>">
+ <br />
+ Supported characters are 'a-z', 'A-Z', '0-9', underscore '_', and period '.'.
+ </td>
+ </tr>
+ <!--
+ <tr>
+ <td width="22%" valign="top" class="vncellreq">Context</td>
+ <td width="78%" class="vtable">
+ <input name="context" type="text" class="formfld" id="context" size="40" value="<?=htmlspecialchars($pconfig['context']);?>">
+ <br />
+ e.g. default
+ </td>
+ </tr>
+ -->
+
+ <tr>
+ <td width="22%" valign="top" class="vncellreq">Enabled</td>
+ <td width="78%" class="vtable">
+ <?php
+ echo " <select name='enabled' class='formfld'>\n";
+ echo " <option></option>\n";
+ switch (htmlspecialchars($pconfig['enabled'])) {
+ case "true":
+ echo " <option value='true' selected='yes'>true</option>\n";
+ echo " <option value='false'>false</option>\n";
+ break;
+ case "false":
+ echo " <option value='true'>true</option>\n";
+ echo " <option value='false' selected='yes'>false</option>\n";
+
+ break;
+ default:
+ echo " <option value='true' selected='yes'>true</option>\n";
+ echo " <option value='false'>false</option>\n";
+ }
+ echo " </select>\n";
+ ?>
+ </td>
+ </tr>
+
+ <tr>
+ <td width="22%" valign="top" class="vncellreq">Order</td>
+ <td width="78%" class="vtable">
+ <?php
+
+ echo " <select name='order' class='formfld'>\n";
+ echo " <option></option>\n";
+ if (strlen(htmlspecialchars($pconfig['order']))> 0) {
+ echo " <option selected='yes' value='".htmlspecialchars($pconfig['order'])."'>".htmlspecialchars($pconfig['order'])."</option>\n";
+ }
+ $i=0;
+ while($i<=999) {
+ if (strlen($i) == 1) {
+ echo " <option value='00$i'>00$i</option>\n";
+ }
+ if (strlen($i) == 2) {
+ echo " <option value='0$i'>0$i</option>\n";
+ }
+ if (strlen($i) == 3) {
+ echo " <option value='$i'>$i</option>\n";
+ }
+
+ $i++;
+ }
+ echo " </select>\n";
+ ?>
+ <br />
+ Processing of each public include is determined by this order.
+ </td>
+ </tr>
+
+ <tr>
+ <td width="22%" valign="top" class="vncell">Description</td>
+ <td width="78%" class="vtable">
+ <input name="descr" type="text" class="formfld" id="descr" size="40" value="<?=htmlspecialchars($pconfig['descr']);?>">
+ <br> <span class="vexpl">You may enter a description here
+ for your reference (not parsed).</span></td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top">&nbsp;</td>
+ <td width="78%">
+ <input name="publicincludeid" type="hidden" value="<?=htmlspecialchars($pconfig['publicincludeid']);?>">
+ <?php
+ if (strlen($id) > 0 && $a_public_includes[$id]) {
+ echo "\n";
+ echo " <input name=\"id\" type=\"hidden\" value=\"$id\">\n";
+ echo " <input name=\"opt1name\" type=\"hidden\" value=\"".htmlspecialchars($pconfig['opt1name'])."\">\n";
+ echo " <input name=\"opt1value\" type=\"hidden\" value=\"".htmlspecialchars($pconfig['opt1value'])."\">\n";
+ }
+ ?>
+ <input name="Submit" type="submit" class="formbtn" value="Save"> <input class="formbtn" type="button" value="Cancel" onclick="history.back()">
+ </td>
+ </tr>
+ </table>
+ </form>
+
+ <br>
+ <br>
+
+ <form action="freeswitch_public_includes_edit.php" method="post" name="iform2" id="iform2">
+ <?php
+
+ //echo "<pre>";
+ //print_r ($a_public_includes);
+ //echo "</pre>";
+
+ //if ($savemsg) print_info_box($savemsg);
+ //if (file_exists($d_hostsdirty_path)): echo"<p>";
+ //print_info_box_np("The FreeSWITCH recordings have been changed.<br>You must apply the changes in order for them to take effect.");
+ //echo"<br />";
+ //endif;
+
+ ?>
+
+
+ <table width="100%" border="0" cellpadding="6" cellspacing="0">
+ <tr>
+ <td><p><span class="vexpl"><span class="red"><strong>Conditions and Actions<br />
+ </strong></span>
+ The following conditions, actions and anti-actions are used in the public to direct call flow. Each is processed in order until you reach the action tag which tells FreeSWITCH what action to perform. You are not limited to only one condition or action tag for a given extension.
+ </span></p></td>
+ </tr>
+ </table>
+ <br />
+
+ <table width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr>
+ <td width="20%" class="listhdrr">Tag</td>
+ <td width="20%" class="listhdrr">Type</td>
+ <td width="50%" class="listhdrr">Data</td>
+ <td width="10%" class="list">
+ <table border="0" cellspacing="0" cellpadding="1">
+ <tr>
+ <td width="17"></td>
+ <td valign="middle"><a href="freeswitch_public_includes_details_edit.php?parentid=<?=$parentid;?>&publicincludeid=<?=$publicincludeid;?>&a=action"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"></a></td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+
+ <?php
+
+ $i = 0;
+ if (count($a_public_include_details) > 0) {
+
+ foreach ($a_public_include_details as $ent) {
+ if ($ent['tag'] == "condition" && $publicincludeid == $ent['publicincludeid']) {
+ ?>
+ <tr>
+ <td class="listlr" ondblclick="document.location='freeswitch_public_includes_details_edit.php?id=<?=$i;?>&parentid=<?=$parentid;?>&publicincludeid=<?=$publicincludeid;?>'">
+ <?=$ent['tag']?>
+ </td>
+ <td class="listr" ondblclick="document.location='freeswitch_public_includes_details_edit.php?id=<?=$i;?>&parentid=<?=$parentid;?>&publicincludeid=<?=$publicincludeid;?>';">
+ <?=$ent['fieldtype'];?>&nbsp;
+ </td>
+ <td class="listr" ondblclick="document.location='freeswitch_public_includes_details_edit.php?id=<?=$i;?>&parentid=<?=$parentid;?>&publicincludeid=<?=$publicincludeid;?>';">
+ <?=$ent['fielddata'];?>&nbsp;
+ </td>
+ <td valign="middle" nowrap class="list">
+ <table border="0" cellspacing="0" cellpadding="1">
+ <tr>
+ <td valign="middle"><a href="freeswitch_public_includes_details_edit.php?id=<?=$i;?>&parentid=<?=$parentid;?>&publicincludeid=<?=$publicincludeid;?>"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" width="17" height="17" border="0"></a></td>
+ <td><a href="freeswitch_public_includes_details.php?type=publicincludedetails&act=del&id=<?=$i;?>&parentid=<?=$parentid;?>&publicincludeid=<?=$publicincludeid;?>" onclick="return confirm('Do you really want to delete this?')"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0"></a></td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ <?php
+ }
+ $i++;
+ }
+ }
+
+ $i = 0;
+ if (count($a_public_include_details) > 0) {
+
+ foreach ($a_public_include_details as $ent) {
+ if ($ent['tag'] == "action" && $publicincludeid == $ent['publicincludeid']) {
+ ?>
+ <tr>
+ <td class="listlr" ondblclick="document.location='freeswitch_public_includes_details_edit.php?id=<?=$i;?>&parentid=<?=$parentid;?>&publicincludeid=<?=$publicincludeid;?>'">
+ <?=$ent['tag']?>
+ </td>
+ <td class="listr" ondblclick="document.location='freeswitch_public_includes_details_edit.php?id=<?=$i;?>&parentid=<?=$parentid;?>&publicincludeid=<?=$publicincludeid;?>';">
+ <?=$ent['fieldtype'];?>&nbsp;
+ </td>
+ <td class="listr" ondblclick="document.location='freeswitch_public_includes_details_edit.php?id=<?=$i;?>&parentid=<?=$parentid;?>&publicincludeid=<?=$publicincludeid;?>';">
+ <?=$ent['fielddata'];?>&nbsp;
+ </td>
+ <td valign="middle" nowrap class="list">
+ <table border="0" cellspacing="0" cellpadding="1">
+ <tr>
+ <td valign="middle"><a href="freeswitch_public_includes_details_edit.php?id=<?=$i;?>&parentid=<?=$parentid;?>&publicincludeid=<?=$publicincludeid;?>"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" width="17" height="17" border="0"></a></td>
+ <td><a href="freeswitch_public_includes_details.php?type=publicincludedetails&act=del&id=<?=$i;?>&parentid=<?=$parentid;?>&publicincludeid=<?=$publicincludeid;?>" onclick="return confirm('Do you really want to delete this?')"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0"></a></td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ <?php
+ }
+ $i++;
+ }
+ }
+
+ $i = 0;
+ if (count($a_public_include_details) > 0) {
+
+ foreach ($a_public_include_details as $ent) {
+ if ($ent['tag'] == "anti-action" && $publicincludeid == $ent['publicincludeid']) {
+ ?>
+ <tr>
+ <td class="listlr" ondblclick="document.location='freeswitch_public_includes_details_edit.php?id=<?=$i;?>&parentid=<?=$parentid;?>&publicincludeid=<?=$publicincludeid;?>'">
+ <?=$ent['tag']?>
+ </td>
+ <td class="listr" ondblclick="document.location='freeswitch_public_includes_details_edit.php?id=<?=$i;?>&parentid=<?=$parentid;?>&publicincludeid=<?=$publicincludeid;?>';">
+ <?=$ent['fieldtype'];?>&nbsp;
+ </td>
+ <td class="listr" ondblclick="document.location='freeswitch_public_includes_details_edit.php?id=<?=$i;?>&parentid=<?=$parentid;?>&publicincludeid=<?=$publicincludeid;?>';">
+ <?=$ent['fielddata'];?>&nbsp;
+ </td>
+ <td valign="middle" nowrap class="list">
+ <table border="0" cellspacing="0" cellpadding="1">
+ <tr>
+ <td valign="middle"><a href="freeswitch_public_includes_details_edit.php?id=<?=$i;?>&parentid=<?=$parentid;?>&publicincludeid=<?=$publicincludeid;?>"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" width="17" height="17" border="0"></a></td>
+ <td><a href="freeswitch_public_includes_details.php?type=publicincludedetails&act=del&id=<?=$i;?>&parentid=<?=$parentid;?>&publicincludeid=<?=$publicincludeid;?>" onclick="return confirm('Do you really want to delete this?')"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0"></a></td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ <?php
+ }
+ $i++;
+ }
+ }
+
+ $i = 0;
+ if (count($a_public_include_details) > 0) {
+
+ foreach ($a_public_include_details as $ent) {
+ if ($ent['tag'] == "param" && $publicincludeid == $ent['publicincludeid']) {
+ ?>
+ <tr>
+ <td class="listlr" ondblclick="document.location='freeswitch_public_includes_details_edit.php?id=<?=$i;?>&parentid=<?=$parentid;?>&publicincludeid=<?=$publicincludeid;?>'">
+ <?=$ent['tag']?>
+ </td>
+ <td class="listr" ondblclick="document.location='freeswitch_public_includes_details_edit.php?id=<?=$i;?>&parentid=<?=$parentid;?>&publicincludeid=<?=$publicincludeid;?>';">
+ <?=$ent['fieldtype'];?>&nbsp;
+ </td>
+ <td class="listr" ondblclick="document.location='freeswitch_public_includes_details_edit.php?id=<?=$i;?>&parentid=<?=$parentid;?>&publicincludeid=<?=$publicincludeid;?>';">
+ <?=$ent['fielddata'];?>&nbsp;
+ </td>
+ <td valign="middle" nowrap class="list">
+ <table border="0" cellspacing="0" cellpadding="1">
+ <tr>
+ <td valign="middle"><a href="freeswitch_public_includes_details_edit.php?id=<?=$i;?>&parentid=<?=$parentid;?>&publicincludeid=<?=$publicincludeid;?>"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" width="17" height="17" border="0"></a></td>
+ <td><a href="freeswitch_public_includes_details.php?type=publicincludedetails&act=del&id=<?=$i;?>&parentid=<?=$parentid;?>&publicincludeid=<?=$publicincludeid;?>" onclick="return confirm('Do you really want to delete this?')"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0"></a></td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ <?php
+ }
+ $i++;
+ }
+ }
+ ?>
+ <tr>
+ <td class="list" colspan="3"></td>
+ <td class="list">
+ <table border="0" cellspacing="0" cellpadding="1">
+ <tr>
+ <td width="17"></td>
+ <td valign="middle"><a href="freeswitch_public_includes_details_edit.php?parentid=<?=$parentid;?>&publicincludeid=<?=$publicincludeid;?>&a=action"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"></a></td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+
+
+ <tr>
+ <td class="list" colspan="3"></td>
+ <td class="list"></td>
+ </tr>
+ </table>
+
+ </form>
+
+
+ <br>
+ <br>
+
+ </td>
+ </tr>
+</table>
+
+</div>
+
+<?php include("fend.inc"); ?>
+</body>
+</html>
diff --git a/config/freeswitch/freeswitch_recordings.tmp b/config/freeswitch/freeswitch_recordings.tmp
new file mode 100644
index 00000000..7d9b539d
--- /dev/null
+++ b/config/freeswitch/freeswitch_recordings.tmp
@@ -0,0 +1,499 @@
+<?php
+/* $Id$ */
+/*
+ freeswitch_recordings.php
+ Copyright (C) 2008 Mark J Crane
+ All rights reserved.
+
+ FreeSWITCH (TM)
+ http://www.freeswitch.org/
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+require("guiconfig.inc");
+require("/usr/local/pkg/freeswitch.inc");
+
+$a_recordings = &$config['installedpackages']['freeswitchrecordings']['config'];
+$dir_recordings = '/usr/local/freeswitch/recordings/';
+$dir_music_on_hold_8000 = '/usr/local/freeswitch/sounds/music/8000/';
+
+if ($_GET['a'] == "download") {
+
+ session_cache_limiter('public');
+
+ if ($_GET['type'] = "rec") {
+ if (file_exists($dir_recordings.$_GET['filename'])) {
+ $fd = fopen($dir_recordings.$_GET['filename'], "rb");
+ if ($_GET['t'] == "bin") {
+ header("Content-Type: application/force-download");
+ header("Content-Type: application/octet-stream");
+ header("Content-Type: application/download");
+ header("Content-Description: File Transfer");
+ header('Content-Disposition: attachment; filename="'.$_GET['filename'].'"');
+ }
+ else {
+ $file_ext = substr($_GET['filename'], -3);
+ if ($file_ext == "wav") {
+ header("Content-Type: audio/x-wav");
+ }
+ if ($file_ext == "mp3") {
+ header("Content-Type: audio/mp3");
+ }
+ }
+ header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
+ header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past
+ header("Content-Length: " . filesize($dir_recordings.$_GET['filename']));
+ fpassthru($fd);
+ }
+ }
+
+ if ($_GET['type'] = "moh") {
+ if (file_exists($dir_music_on_hold_8000.$_GET['filename'])) {
+ $fd = fopen($dir_music_on_hold_8000.$_GET['filename'], "rb");
+ if ($_GET['t'] == "bin") {
+ header("Content-Type: application/force-download");
+ header("Content-Type: application/octet-stream");
+ header("Content-Type: application/download");
+ header("Content-Description: File Transfer");
+ header('Content-Disposition: attachment; filename="'.$_GET['filename'].'"');
+ }
+ else {
+ $file_ext = substr($_GET['filename'], -3);
+ if ($file_ext == "wav") {
+ header("Content-Type: audio/x-wav");
+ }
+ if ($file_ext == "mp3") {
+ header("Content-Type: audio/mp3");
+ }
+ }
+ header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
+ header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past
+ header("Content-Length: " . filesize($dir_music_on_hold_8000.$_GET['filename']));
+ fpassthru($fd);
+ }
+ }
+
+ exit;
+}
+else {
+ //echo $dir_recordings.$_GET['filename'];
+}
+
+if (($_POST['submit'] == "Upload") && is_uploaded_file($_FILES['ulfile']['tmp_name'])) {
+
+ if ($_POST['type'] == 'moh') {
+ move_uploaded_file($_FILES['ulfile']['tmp_name'], $dir_music_on_hold_8000 . $_FILES['ulfile']['name']);
+ $savemsg = "Uploaded file to $dir_music_on_hold_8000" . htmlentities($_FILES['ulfile']['name']);
+ //system('chmod -R 744 $dir_music_on_hold_8000*');
+ unset($_POST['txtCommand']);
+ }
+ if ($_POST['type'] == 'rec') {
+ move_uploaded_file($_FILES['ulfile']['tmp_name'], $dir_recordings . $_FILES['ulfile']['name']);
+ $savemsg = "Uploaded file to $dir_recordings" . htmlentities($_FILES['ulfile']['name']);
+ //system('chmod -R 744 $dir_recordings*');
+ unset($_POST['txtCommand']);
+ }
+}
+
+
+
+
+if ($_GET['act'] == "del") {
+ if ($_GET['type'] == 'rec') {
+ if ($a_recordings[$_GET['id']]) {
+ unlink_if_exists('/usr/local/freeswitch/recordings/'.$a_recordings[$_GET['id']]['filename']);
+ unset($a_recordings[$_GET['id']]);
+ write_config();
+ header("Location: freeswitch_recordings.php");
+ exit;
+ }
+ }
+
+ if ($_GET['type'] == 'moh') {
+ unlink_if_exists($dir_music_on_hold_8000.$_GET['filename']);
+ header("Location: freeswitch_recordings.php");
+ exit;
+ }
+
+}
+
+
+
+include("head.inc");
+
+?>
+
+<script>
+function EvalSound(soundobj) {
+ var thissound= eval("document."+soundobj);
+ thissound.Play();
+}
+</script>
+
+<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
+<?php include("fbegin.inc"); ?>
+<p class="pgtitle">FreeSWITCH: Recordings</p>
+
+<div id="mainlevel">
+<table width="100%" border="0" cellpadding="0" cellspacing="0">
+<tr><td class="tabnavtbl">
+<?php
+
+ $tab_array = array();
+ $tab_array[] = array(gettext("Settings"), false, "/pkg_edit.php?xml=freeswitch.xml&amp;id=0");
+ $tab_array[] = array(gettext("Dialplan"), false, "/freeswitch/freeswitch_dialplan_includes.php");
+ $tab_array[] = array(gettext("Extensions"), false, "/freeswitch/freeswitch_extensions.php");
+ $tab_array[] = array(gettext("External"), false, "/pkg_edit.php?xml=freeswitch_external.xml&amp;id=0");
+ $tab_array[] = array(gettext("Gateways"), false, "/freeswitch/freeswitch_gateways.php");
+ $tab_array[] = array(gettext("Internal"), false, "/pkg_edit.php?xml=freeswitch_internal.xml&amp;id=0");
+ $tab_array[] = array(gettext("IVR"), false, "/freeswitch/freeswitch_ivr.php");
+ $tab_array[] = array(gettext("Modules"), false, "/pkg_edit.php?xml=freeswitch_modules.xml&amp;id=0");
+ $tab_array[] = array(gettext("Public"), false, "/freeswitch/freeswitch_public_includes.php");
+ $tab_array[] = array(gettext("Rec"), true, "/freeswitch/freeswitch_recordings.php");
+ $tab_array[] = array(gettext("Status"), false, "/freeswitch/freeswitch_status.php");
+ $tab_array[] = array(gettext("Vars"), false, "/pkg_edit.php?xml=freeswitch_vars.xml&amp;id=0");
+ display_top_tabs($tab_array);
+
+?>
+</td></tr>
+</table>
+
+<table width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr>
+ <td class="tabcont" >
+
+<?php
+
+
+//build a list of recordings from the config.xml
+$config_recording_list = '';
+$i = 0;
+if (count($a_recordings) > 0) {
+ foreach ($a_recordings as $recordingent) {
+ $config_recording_list .= $recordingent['filename']."|";
+ $i++;
+ }
+}
+
+
+
+$config_change = 0;
+if (is_dir($dir_recordings)) {
+ if ($dh = opendir($dir_recordings)) {
+ while (($file = readdir($dh)) !== false) {
+ if (filetype($dir_recordings . $file) == "file") {
+
+ if (strpos($config_recording_list, $file) === false) {
+
+ //$handle = fopen($dir_recordings.$file,'rb');
+ //$file_content = fread($handle,filesize($dir_recordings.$file));
+ //fclose($handle);
+
+ $a_file = split("\.", $file);
+
+ $recordingent = array();
+ $recordingent['filename'] = $file;
+ $recordingent['recordingname'] = $a_file[0];
+ $recordingent['recordingid'] = guid();
+ //$recordingent['filecontent'] = base64_encode($file_content);
+ $recordingent['descr'] = 'Auto';
+
+ $a_recordings[] = $recordingent;
+ write_config();
+
+ unset($file_content);
+
+ }
+ else {
+ //echo "The file was found.<br/>";
+ }
+
+ }
+ }
+ closedir($dh);
+ }
+}
+
+
+
+//saved for future use if and when config.xml scales well
+ //enough to save the files inside it
+//$i = 0;
+//if (count($a_recordings) > 0) {
+// foreach ($a_recordings as $recordingent) {
+
+// if (!is_file($dir_recordings.$recordingent['filename'])) {
+ //echo "not found: ".$recordingent['filename']."<br />";
+
+ //recording not found restore the file from the config.xml
+ //$file_content = $recordingent['filecontent'];
+ //$handle = fopen($dir_recordings.$recordingent['filename'],'w');
+ //fwrite ($handle, base64_decode($file_content));
+ //unset($file_content);
+ //fclose($handle);
+ //$recordingent['filecontent'] = base64_encode($file_content);
+
+ // loop through recordings in the config.xml
+ // if the file does not exist remove it from the file system.
+ //unset($a_recordings[$i]);
+
+// $config_change = 1;
+// }
+// else {
+ //echo "found: ".$recordingent['filename']."<br />";
+// }
+
+// $i++;
+// }
+//}
+
+if ($config_change == 1) {
+ write_config();
+ $config_change = 0;
+}
+
+//if ($savemsg) print_info_box($savemsg);
+//if (file_exists($d_hostsdirty_path)): echo"<p>";
+//print_info_box_np("The FreeSWITCH recordings have been changed.<br>You must apply the changes in order for them to take effect.");
+//echo"<br />";
+//endif;
+
+?>
+ <table width="100%" border="0" cellpadding="6" cellspacing="0">
+ <tr>
+ <td><p><span class="vexpl"><span class="red"><strong>Recordings:<br>
+ </strong></span>
+ To make a recording dial extension 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.
+ </span></p></td>
+ </tr>
+ </table>
+
+ <br />
+
+ <div id="niftyOutter">
+ <form action="" method="POST" enctype="multipart/form-data" name="frmUpload" onSubmit="">
+ <table border='0'>
+ <tr>
+ <td width='50%'><b>location:</b> <?php echo $dir_recordings; ?></td>
+ <td valign="top" class="label">
+ <input name="type" type="hidden" value="rec">
+ </td>
+ <td align="right">File to upload:</td>
+ <td valign="top" class="label">
+ <input name="ulfile" type="file" class="button" id="ulfile">
+ <input name="submit" type="submit" class="button" id="upload" value="Upload">
+ </td>
+ </tr>
+ </table>
+ </div>
+ </form>
+
+ <table width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr>
+ <td width="30%" class="listhdrr">Filename (download)</td>
+ <td width="30%" class="listhdrr">Recording Name (play)</td>
+ <td width="30%" class="listhdr">Description</td>
+ <td width="10%" class="list">
+ <!--
+ <table border="0" cellspacing="0" cellpadding="1">
+ <tr>
+ <td width="17"></td>
+ <td valign="middle"><a href="freeswitch_recordings_edit.php"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"></a></td>
+ </tr>
+ </table>
+ -->
+ </td>
+ </tr>
+
+ <?php
+ $i = 0;
+ if (count($a_recordings) > 0) {
+ foreach ($a_recordings as $recordingent) {
+ ?>
+ <tr>
+ <td class="listlr" ondblclick="document.location='freeswitch_recordings_edit.php?id=<?=$i;?>'">
+ <a href="freeswitch_recordings.php?a=download&type=rec&t=bin&filename=<?=$recordingent['filename'];?>">
+ <?=$recordingent['filename']?>
+ </a>
+ </td>
+ <td class="listr" ondblclick="document.location='freeswitch_recordings_edit.php?id=<?=$i;?>';">
+ <a href="javascript:void(0);" onclick="window.open('freeswitch_recordings_play.php?a=download&type=rec&filename=<?=$recordingent['filename'];?>', 'play',' width=420,height=40,menubar=no,status=no,toolbar=no')">
+ <?=$recordingent['recordingname'];?>&nbsp;
+ </a>
+ </td>
+ <td class="listbg" ondblclick="document.location='freeswitch_recordings_edit.php?id=<?=$i;?>';">
+ <font color="#FFFFFF"><?=htmlspecialchars($recordingent['descr']);?>&nbsp;
+ </td>
+ <td valign="middle" nowrap class="list">
+ <table border="0" cellspacing="0" cellpadding="1">
+ <tr>
+ <td valign="middle"><a href="freeswitch_recordings_edit.php?id=<?=$i;?>"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" width="17" height="17" border="0"></a></td>
+ <td><a href="freeswitch_recordings.php?type=rec&act=del&id=<?=$i;?>" onclick="return confirm('Do you really want to delete this?')"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0"></a></td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ <?php
+ $i++;
+ } //end for each
+ } //end count
+ ?>
+
+ <!--
+ <tr>
+ <td class="list" colspan="3"></td>
+ <td class="list">
+ <table border="0" cellspacing="0" cellpadding="1">
+ <tr>
+ <td width="17"></td>
+ <td valign="middle"><a href="freeswitch_recordings_edit.php"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"></a></td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ -->
+
+ <tr>
+ <td class="list" colspan="3"></td>
+ <td class="list"></td>
+ </tr>
+ </table>
+
+
+
+ <br />
+ <br />
+ <br />
+
+ <table width="100%" border="0" cellpadding="6" cellspacing="0">
+ <tr>
+ <td><p><span class="vexpl"><span class="red"><strong>Music on Hold:<br>
+ </strong></span>
+ 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.
+ <!--Click on the 'Filename' to download it or the 'Recording Name' to
+ play the audio.-->
+ </span></p></td>
+ </tr>
+ </table>
+
+ <br />
+
+ <div id="niftyOutter">
+ <form action="" method="POST" enctype="multipart/form-data" name="frmUpload" onSubmit="">
+ <table border='0'>
+ <tr>
+ <td width='50%'><b>location:</b> <?php echo $dir_music_on_hold_8000; ?></td>
+ <td valign="top" class="label">
+ <input name="type" type="hidden" value="moh">
+ </td>
+ <td align="right">File to upload:</td>
+ <td valign="top" class="label">
+ <input name="ulfile" type="file" class="button" id="ulfile">
+ <input name="submit" type="submit" class="button" id="upload" value="Upload">
+ </td>
+ </tr>
+ </table>
+ </div>
+ </form>
+
+
+ <table width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr>
+ <td width="28%" class="listhdrr">File Name (download)</td>
+ <td width="28%" class="listhdrr">Name (play)</td>
+ <td width="25%" class="listhdr">Last Modified</td>
+ <td width="10%" class="listhdr" nowrap>Size</td>
+ </tr>
+
+ <?php
+
+ if ($handle = opendir($dir_music_on_hold_8000)) {
+ while (false !== ($file = readdir($handle))) {
+ if ($file != "." && $file != ".." && is_file($dir_music_on_hold_8000.$file)) {
+
+ $tmp_filesize = filesize($dir_music_on_hold_8000.$file);
+ $tmp_filesize = byte_convert($tmp_filesize);
+
+ echo "<tr>\n";
+ echo " <td class=\"listlr\" ondblclick=\"\">\n";
+ echo " <a href=\"freeswitch_recordings.php?a=download&type=moh&t=bin&filename=".$file."\">\n";
+ echo " $file";
+ echo " </a>";
+ echo " </td>\n";
+ echo " <td class=\"listlr\" ondblclick=\"\">\n";
+ echo " <a href=\"javascript:void(0);\" onclick=\"window.open('freeswitch_recordings_play.php?a=download&type=moh&filename=".$file."', 'play',' width=420,height=40,menubar=no,status=no,toolbar=no')\">\n";
+ $tmp_file_array = split("\.",$file);
+ echo " ".$tmp_file_array[0];
+ echo " </a>";
+ echo " </td>\n";
+ echo " <td class=\"listlr\" ondblclick=\"\">\n";
+ echo date ("F d Y H:i:s", filemtime($dir_music_on_hold_8000.$file));
+ echo " </td>\n";
+ echo " <td class=\"listlr\" ondblclick=\"\">\n";
+ echo " ".$tmp_filesize;
+ echo " </td>\n";
+ echo " <td valign=\"middle\" nowrap class=\"list\">\n";
+ echo " <table border=\"0\" cellspacing=\"0\" cellpadding=\"1\">\n";
+ echo " <tr>\n";
+ //echo " <td valign=\"middle\"><a href=\"freeswitch_recordings.php?id=$i\"><img src=\"/themes/".$g['theme']."/images/icons/icon_e.gif\" width=\"17\" height=\"17\" border=\"0\"></a></td>\n";
+ echo " <td><a href=\"freeswitch_recordings.php?type=moh&act=del&filename=".$file."\" onclick=\"return confirm('Do you really want to delete this file?')\"><img src=\"/themes/". $g['theme']."/images/icons/icon_x.gif\" width=\"17\" height=\"17\" border=\"0\"></a></td>\n";
+ echo " </tr>\n";
+ echo " </table>\n";
+ echo " </td>\n";
+ echo "</tr>\n";
+
+ }
+ }
+ closedir($handle);
+ }
+ ?>
+
+ <tr>
+ <td class="list" colspan="3"></td>
+ <td class="list"></td>
+ </tr>
+ </table>
+
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+
+</td>
+</tr>
+</table>
+
+</div>
+
+
+<?php include("fend.inc"); ?>
+</body>
+</html>
diff --git a/config/freeswitch/freeswitch_recordings_edit.tmp b/config/freeswitch/freeswitch_recordings_edit.tmp
new file mode 100644
index 00000000..18612b93
--- /dev/null
+++ b/config/freeswitch/freeswitch_recordings_edit.tmp
@@ -0,0 +1,186 @@
+<?php
+/* $Id$ */
+/*
+
+ freeswitch_recordings_edit.php
+ Copyright (C) 2008 Mark J Crane
+ All rights reserved.
+
+ FreeSWITCH (TM)
+ http://www.freeswitch.org/
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+require("guiconfig.inc");
+require("/usr/local/pkg/freeswitch.inc");
+
+
+$a_recordings = &$config['installedpackages']['freeswitchrecordings']['config'];
+
+
+$id = $_GET['id'];
+if (isset($_POST['id'])) {
+ $id = $_POST['id'];
+}
+
+if (isset($id) && $a_recordings[$id]) {
+ $pconfig['filename'] = $a_recordings[$id]['filename'];
+ $pconfig['recordingname'] = $a_recordings[$id]['recordingname'];
+ $pconfig['recordingid'] = $a_recordings[$id]['recordingid'];
+ $pconfig['descr'] = $a_recordings[$id]['descr'];
+}
+
+if ($_POST) {
+
+ unset($input_errors);
+ $pconfig = $_POST;
+
+
+ if (!$input_errors) {
+
+
+ $recordingent = array();
+ $recordingent['recordingname'] = $_POST['recordingname'];
+ $recordingent['descr'] = $_POST['descr'];
+
+
+ if (isset($id) && $a_recordings[$id]) {
+ //update
+ if (strlen($_POST['recordingid']) > 0) {
+ $recordingent['recordingid'] = $_POST['recordingid'];
+ }
+ else {
+ $recordingent['recordingid'] = guid();
+ }
+
+ $recordingent['filename'] = $_POST['filename'];
+
+ //if file name is not the same then rename the file
+ if ($_POST['filename'] != $_POST['filename_orig']) {
+ rename('/usr/local/freeswitch/recordings/'.$_POST['filename_orig'], '/usr/local/freeswitch/recordings/'.$_POST['filename']);
+ }
+ $a_recordings[$id] = $recordingent;
+ }
+ else {
+ //add
+ $recordingent['filename'] = $_POST['filename'];
+ $a_recordings[] = $recordingent;
+ }
+
+ write_config();
+
+ header("Location: freeswitch_recordings.php");
+ exit;
+ }
+}
+
+include("head.inc");
+
+?>
+
+<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
+<?php include("fbegin.inc"); ?>
+<p class="pgtitle">FreeSWITCH: Recordings: Edit</p>
+<?php if ($input_errors) print_input_errors($input_errors); ?>
+
+
+<div id="mainlevel">
+<table width="100%" border="0" cellpadding="0" cellspacing="0">
+<tr><td class="tabnavtbl">
+<?php
+
+ $tab_array = array();
+ $tab_array[] = array(gettext("Settings"), false, "/pkg_edit.php?xml=freeswitch.xml&amp;id=0");
+ $tab_array[] = array(gettext("Dialplan"), false, "/freeswitch/freeswitch_dialplan_includes.php");
+ $tab_array[] = array(gettext("Extensions"), false, "/freeswitch/freeswitch_extensions.php");
+ $tab_array[] = array(gettext("External"), false, "/pkg_edit.php?xml=freeswitch_external.xml&amp;id=0");
+ $tab_array[] = array(gettext("Gateways"), false, "/freeswitch/freeswitch_gateways.php");
+ $tab_array[] = array(gettext("Internal"), false, "/pkg_edit.php?xml=freeswitch_internal.xml&amp;id=0");
+ $tab_array[] = array(gettext("IVR"), false, "/freeswitch/freeswitch_ivr.php");
+ $tab_array[] = array(gettext("Modules"), false, "/pkg_edit.php?xml=freeswitch_modules.xml&amp;id=0");
+ $tab_array[] = array(gettext("Public"), false, "/freeswitch/freeswitch_public_includes.php");
+ $tab_array[] = array(gettext("Rec"), true, "/freeswitch/freeswitch_recordings.php");
+ $tab_array[] = array(gettext("Status"), false, "/freeswitch/freeswitch_status.php");
+ $tab_array[] = array(gettext("Vars"), false, "/pkg_edit.php?xml=freeswitch_vars.xml&amp;id=0");
+ display_top_tabs($tab_array);
+
+?>
+</td></tr>
+</table>
+<table width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr>
+ <td class="tabcont" >
+
+ <form action="freeswitch_recordings_edit.php" method="post" name="iform" id="iform">
+ <table width="100%" border="0" cellpadding="6" cellspacing="0">
+ <tr>
+ <td width="22%" valign="top" class="vncellreq">Filename</td>
+ <td width="78%" class="vtable">
+ <input name="filename" type="text" class="formfld" id="filename" size="40" value="<?=htmlspecialchars($pconfig['filename']);?>">
+ <br> <span class="vexpl">Name of the file<br>
+ e.g. <em>example.wav</em></span></td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncellreq">Recording Name</td>
+ <td width="78%" class="vtable">
+ <input name="recordingname" type="text" class="formfld" id="recordingname" size="40" value="<?=htmlspecialchars($pconfig['recordingname']);?>">
+ <br> <span class="vexpl">Recording Name<br>
+ e.g. <em>recordingx</em></span></td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncell">Description</td>
+ <td width="78%" class="vtable">
+ <input name="descr" type="text" class="formfld" id="descr" size="40" value="<?=htmlspecialchars($pconfig['descr']);?>">
+ <br> <span class="vexpl">You may enter a description here
+ for your reference (not parsed).</span></td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top">&nbsp;</td>
+ <td width="78%">
+ <input name="Submit" type="submit" class="formbtn" value="Save"> <input class="formbtn" type="button" value="Cancel" onclick="history.back()">
+ <?php if (isset($id) && $a_recordings[$id]): ?>
+ <input name="filename_orig" type="hidden" value="<?=htmlspecialchars($pconfig['filename']);?>">
+ <input name="id" type="hidden" value="<?=$id;?>">
+ <input name="recordingid" type="hidden" value="<?=htmlspecialchars($pconfig['recordingid']);?>">
+ <?php endif; ?>
+ </td>
+ </tr>
+ </table>
+ </form>
+
+ <br>
+ <br>
+ <br>
+ <br>
+ <br>
+ <br>
+
+ </td>
+ </tr>
+</table>
+
+</div>
+
+<?php include("fend.inc"); ?>
+</body>
+</html>
diff --git a/config/freeswitch/freeswitch_recordings_play.tmp b/config/freeswitch/freeswitch_recordings_play.tmp
new file mode 100644
index 00000000..8dfb90c2
--- /dev/null
+++ b/config/freeswitch/freeswitch_recordings_play.tmp
@@ -0,0 +1,71 @@
+<?php
+/* $Id$ */
+/*
+
+ freeswitch_recordings_play.php
+ Copyright (C) 2008 Mark J Crane
+ All rights reserved.
+
+ FreeSWITCH (TM)
+ http://www.freeswitch.org/
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+$filename = $_GET['filename'];
+$type = $_GET['type']; //moh //rec
+
+?>
+<html>
+<head>
+</head>
+<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
+
+<table width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr>
+ <td align='center'>
+ <b>file: <?=$filename?></b>
+ </td>
+ </tr>
+ <tr>
+ <td align='center'>
+ <?php
+
+ $file_ext = substr($_GET['filename'], -3);
+ if ($file_ext == "wav") {
+ echo "<embed src=\"freeswitch_recordings.php?a=download&type=".$type."&filename=".$filename."\" autostart=true width=200 height=40 name=\"sound".$$filename."\" enablejavascript=\"true\">\n";
+ }
+ if ($file_ext == "mp3") {
+ echo "<object type=\"application/x-shockwave-flash\" width=\"400\" height=\"17\" data=\"slim.swf?autoplay=true&song_title=".urlencode($filename)."&song_url=".urlencode("/freeswitch/freeswitch_recordings.php?a=download&type=".$type."&filename=".$filename)."\">\n";
+ echo "<param name=\"movie\" value=\"slim.swf?autoplay=true&song_url=".urlencode("/freeswitch/freeswitch_recordings.php?a=download&type=".$type."&filename=".$filename)."\" />\n";
+ echo "<param name=\"quality\" value=\"high\"/>\n";
+ echo "<param name=\"bgcolor\" value=\"#E6E6E6\"/>\n";
+ echo "</object>\n";
+ }
+
+ ?>
+ </td>
+ </tr>
+</table>
+
+</body>
+</html>
diff --git a/config/freeswitch/freeswitch_status.tmp b/config/freeswitch/freeswitch_status.tmp
new file mode 100644
index 00000000..2d84a6ec
--- /dev/null
+++ b/config/freeswitch/freeswitch_status.tmp
@@ -0,0 +1,337 @@
+<?php
+/* $Id$ */
+/*
+ freeswitch_status.php
+ Copyright (C) 2008 Mark J Crane
+ All rights reserved.
+
+ FreeSWITCH (TM)
+ http://www.freeswitch.org/
+
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+require("guiconfig.inc");
+require("/usr/local/pkg/freeswitch.inc");
+
+
+if ($_GET['a'] == "download") {
+ if ($_GET['t'] == "logs") {
+ $tmp = '/usr/local/freeswitch/log/';
+ $filename = 'freeswitch.log';
+ }
+ if ($_GET['t'] == "cdrcsv") {
+ $tmp = '/usr/local/freeswitch/log/cdr-csv/';
+ $filename = 'Master.csv';
+ }
+ if ($_GET['t'] == "backup") {
+ $tmp = '/tmp/';
+ $filename = 'freeswitch.bak.tgz';
+ system('cd /usr/local/;tar cvzf /tmp/freeswitch.bak.tgz freeswitch');
+ }
+ session_cache_limiter('public');
+ $fd = fopen($tmp.$filename, "rb");
+ header("Content-Type: binary/octet-stream");
+ header("Content-Length: " . filesize($tmp.$filename));
+ header('Content-Disposition: attachment; filename="'.$filename.'"');
+ fpassthru($fd);
+ exit;
+}
+
+if ($_GET['a'] == "other") {
+ if ($_GET['t'] == "restore") {
+ $tmp = '/tmp/';
+ $filename = 'freeswitch.bak.tgz';
+
+ //extract a specific directory to /usr/local/freeswitch
+ if (file_exists('/tmp/'.$filename)) {
+ //echo "The file $filename exists";
+
+ //Recommended
+ system('cd /usr/local; tar xvpfz /tmp/'.$filename.' freeswitch/db/');
+ system('cd /usr/local; tar xvpfz /tmp/'.$filename.' freeswitch/log/');
+ system('cd /usr/local; tar xvpfz /tmp/'.$filename.' freeswitch/recordings/');
+ system('cd /usr/local; tar xvpfz /tmp/'.$filename.' freeswitch/scripts/');
+ system('cd /usr/local; tar xvpfz /tmp/'.$filename.' freeswitch/storage/');
+
+ //Optional
+ //system('cd /usr/local; tar xvpfz /tmp/'.$filename.' freeswitch/conf/');
+ //system('cd /usr/local; tar xvpfz /tmp/'.$filename.' freeswitch/grammar/');
+ //system('cd /usr/local; tar xvpfz /tmp/'.$filename.' freeswitch/htdocs/');
+ //system('cd /usr/local; tar xvpfz /tmp/'.$filename.' freeswitch/sounds/');
+
+ header( 'Location: freeswitch_status.php?savemsg=Backup+has+been+restored.' ) ;
+ }
+ else {
+ header( 'Location: freeswitch_status.php?savemsg=Restore+failed.+Backup+file+not+found.' ) ;
+ }
+
+ exit;
+ }
+}
+
+include("head.inc");
+
+$password = $config['installedpackages']['freeswitchsettings']['config'][0]['event_socket_password'];
+$port = $config['installedpackages']['freeswitchsettings']['config'][0]['event_socket_port'];
+$host = $config['interfaces']['lan']['ipaddr'];
+
+$savemsg = $_GET["savemsg"];
+
+//if freeswitch is not running then start it
+if (!pkg_is_service_running('freeswitch')) {
+ $handle = popen("/usr/local/etc/rc.d/freeswitch.sh start", "r");
+ pclose($handle);
+}
+?>
+<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
+<?php include("fbegin.inc"); ?>
+
+<p class="pgtitle">FreeSWITCH: Status</font></p>
+
+<?php
+if ($savemsg) {
+ print_info_box($savemsg);
+}
+?>
+
+<div id="mainlevel">
+<table width="100%" border="0" cellpadding="0" cellspacing="0">
+<tr><td class="tabnavtbl">
+<?php
+
+ $tab_array = array();
+ $tab_array[] = array(gettext("Settings"), false, "/pkg_edit.php?xml=freeswitch.xml&amp;id=0");
+ $tab_array[] = array(gettext("Dialplan"), false, "/freeswitch/freeswitch_dialplan_includes.php");
+ $tab_array[] = array(gettext("Extensions"), false, "/freeswitch/freeswitch_extensions.php");
+ $tab_array[] = array(gettext("External"), false, "/pkg_edit.php?xml=freeswitch_external.xml&amp;id=0");
+ $tab_array[] = array(gettext("Gateways"), false, "/freeswitch/freeswitch_gateways.php");
+ $tab_array[] = array(gettext("Internal"), false, "/pkg_edit.php?xml=freeswitch_internal.xml&amp;id=0");
+ $tab_array[] = array(gettext("IVR"), false, "/freeswitch/freeswitch_ivr.php");
+ $tab_array[] = array(gettext("Modules"), false, "/pkg_edit.php?xml=freeswitch_modules.xml&amp;id=0");
+ $tab_array[] = array(gettext("Public"), false, "/freeswitch/freeswitch_public_includes.php");
+ $tab_array[] = array(gettext("Rec"), false, "/freeswitch/freeswitch_recordings.php");
+ $tab_array[] = array(gettext("Status"), true, "/freeswitch/freeswitch_status.php");
+ $tab_array[] = array(gettext("Vars"), false, "/pkg_edit.php?xml=freeswitch_vars.xml&amp;id=0");
+ display_top_tabs($tab_array);
+
+?>
+</td></tr>
+</table>
+<table width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr>
+ <td class="tabcont" >
+
+<?php
+
+echo "<br /><br />\n\n";
+
+
+$fp = event_socket_create($host, $port, $password);
+$cmd = "api sofia status";
+$response = event_socket_request($fp, $cmd);
+echo "<table width='690' cellpadding='0' cellspacing='0' border='0'>\n";
+echo "<tr>\n";
+echo "<td width='50%'>\n";
+echo " <b>sofia status</b> \n";
+echo "</td>\n";
+echo "<td width='50%' align='right'>\n";
+echo " <input type='button' value='reloadxml' onclick=\"document.location.href='/freeswitch/freeswitch_cmd.php?cmd=api+reloadxml';\" />\n";
+echo "</td>\n";
+echo "</tr>\n";
+echo "</table>\n";
+echo "<pre style=\"font-size: 9pt;\">\n";
+echo $response;
+echo "</pre>\n";
+fclose($fp);
+echo "<br /><br />\n\n";
+
+
+$fp = event_socket_create($host, $port, $password);
+$cmd = "api sofia status profile internal";
+$response = event_socket_request($fp, $cmd);
+echo "<table width='690' cellpadding='0' cellspacing='0' border='0'>\n";
+echo "<tr>\n";
+echo "<td width='50%'>\n";
+echo " <b>sofia status profile internal</b> \n";
+echo "</td>\n";
+echo "<td width='50%' align='right'>\n";
+echo " <input type='button' value='start' onclick=\"document.location.href='/freeswitch/freeswitch_cmd.php?cmd=api+sofia+profile+internal+start';\" />\n";
+echo " <input type='button' value='stop' onclick=\"document.location.href='/freeswitch/freeswitch_cmd.php?cmd=api+sofia+profile+internal+stop';\" />\n";
+echo " <input type='button' value='flush_inbound_reg' onclick=\"document.location.href='/freeswitch/freeswitch_cmd.php?cmd=api+sofia+profile+internal+flush_inbound_reg';\" />\n";
+echo "</td>\n";
+echo "</tr>\n";
+echo "</table>\n";
+echo "<pre style=\"font-size: 9pt;\">\n";
+echo $response;
+echo "</pre>\n";
+fclose($fp);
+echo "<br /><br />\n\n";
+
+
+$fp = event_socket_create($host, $port, $password);
+$cmd = "api sofia status profile external";
+$response = event_socket_request($fp, $cmd);
+echo "<table width='690' cellpadding='0' cellspacing='0' border='0'>\n";
+echo "<tr>\n";
+echo "<td width='50%'>\n";
+echo " <b>sofia status profile external</b> \n";
+echo "</td>\n";
+echo "<td width='50%' align='right'>\n";
+echo " <input type='button' value='start' onclick=\"document.location.href='/freeswitch/freeswitch_cmd.php?cmd=api+sofia+profile+external+start+reloadxml';\" />\n";
+echo " <input type='button' value='stop' onclick=\"document.location.href='/freeswitch/freeswitch_cmd.php?cmd=api+sofia+profile+external+stop';\" />\n";
+echo " <input type='button' value='restart' onclick=\"document.location.href='/freeswitch/freeswitch_cmd.php?cmd=api+sofia+profile+external+restart+reloadxml';\" />\n";
+echo " <input type='button' value='rescan' onclick=\"document.location.href='/freeswitch/freeswitch_cmd.php?cmd=api+sofia+profile+external+rescan+reloadxml';\" />\n";
+echo "</td>\n";
+echo "</tr>\n";
+echo "</table>\n";
+echo "<pre style=\"font-size: 9pt;\">\n";
+echo $response;
+echo "</pre>\n";
+fclose($fp);
+echo "<br /><br />\n\n";
+
+
+$fp = event_socket_create($host, $port, $password);
+$cmd = "api status";
+$response = event_socket_request($fp, $cmd);
+echo "<b>status</b><br />\n";
+echo "<pre style=\"font-size: 9pt;\">\n";
+echo $response;
+echo "</pre>\n";
+fclose($fp);
+echo "<br /><br />\n\n";
+
+
+$fp = event_socket_create($host, $port, $password);
+$cmd = "api show channels";
+$response = event_socket_request($fp, $cmd);
+echo "<b>show channels</b>\n";
+if (strlen($response) > 40) {
+ echo "<textarea cols='85' rows='10' wrap='off'>\n";
+ echo $response;
+ echo "</textarea>\n";
+}
+else {
+ echo "<pre style=\"font-size: 9pt;\">\n";
+ echo $response;
+ echo "</pre>\n";
+}
+fclose($fp);
+echo "<br /><br />\n\n";
+echo "<br /><br />\n\n";
+
+
+$fp = event_socket_create($host, $port, $password);
+$cmd = "api show calls";
+$response = event_socket_request($fp, $cmd);
+echo "<b>show calls</b>\n";
+if (strlen($response) > 40) {
+ echo "<textarea cols='85' rows='10' wrap='off'>\n";
+ echo $response;
+ echo "</textarea>\n";
+}
+else {
+ echo "<pre style=\"font-size: 9pt;\">\n";
+ echo $response;
+ echo "</pre>\n";
+}
+fclose($fp);
+echo "<br /><br />\n\n";
+echo "<br /><br />\n\n";
+
+
+echo "<table width='690' cellpadding='0' cellspacing='0' border='0'>\n";
+echo "<tr>\n";
+echo "<td width='80%'>\n";
+echo "<b>Backup / Restore</b><br />\n";
+echo "The 'backup' button will tar gzip /usr/local/freeswitch/ to /tmp/freeswitch.bak.tgz it then presents a file to download. \n";
+echo "If the backup file does not exist in /tmp/freeswitch.bak.tgz then the 'restore' button will be hidden. \n";
+echo "Use Diagnostics->Command->File to upload: to browse to the file and then click on upload it now ready to be restored. \n";
+echo "<br /><br />\n";
+echo "</td>\n";
+echo "<td width='20%' valign='middle' align='right'>\n";
+echo " <input type='button' value='backup' onclick=\"document.location.href='/freeswitch/freeswitch_status.php?a=download&t=backup';\" />\n";
+if (file_exists('/tmp/freeswitch.bak.tgz')) {
+ echo " <input type='button' value='restore' onclick=\"document.location.href='/freeswitch/freeswitch_status.php?a=other&t=restore';\" />\n";
+}
+echo "</td>\n";
+echo "</tr>\n";
+echo "</table>\n";
+echo "<br /><br />\n\n";
+
+
+echo "<table width='690' cellpadding='0' cellspacing='0' border='0'>\n";
+echo "<tr>\n";
+echo "<td width='50%'>\n";
+echo "<b>Call Detail Records</b><br />\n";
+echo "/usr/local/freeswitch/log/cdr-csv/Master.csv<br /><br />\n";
+echo "</td>\n";
+echo "<td width='50%' align='right'>\n";
+echo " <input type='button' value='download cdr csv' onclick=\"document.location.href='/freeswitch/freeswitch_status.php?a=download&t=cdrcsv';\" />\n";echo "</td>\n";
+echo "</tr>\n";
+echo "</table>\n";
+echo "<br /><br />\n\n";
+
+
+echo "<table width='690' cellpadding='0' cellspacing='0' border='0'>\n";
+echo "<tr>\n";
+echo "<td width='50%'>\n";
+echo "<b>Logs</b><br />\n";
+echo "/usr/local/freeswitch/log/cdr-csv/freeswitch.log<br /><br />\n";
+echo "</td>\n";
+echo "<td width='50%' align='right'>\n";
+echo " <input type='button' value='download logs' onclick=\"document.location.href='/freeswitch/freeswitch_status.php?a=download&t=logs';\" />\n";
+echo "</tr>\n";
+echo "</table>\n";
+echo "<br /><br />\n\n";
+
+
+echo "<b>tail -n 100 /usr/local/freeswitch/log/freeswitch.log</b><br />\n";
+echo "<textarea cols='85' rows='30' wrap='off'>\n";
+echo system("tail -n 100 /usr/local/freeswitch/log/freeswitch.log");
+echo "</textarea>\n";
+echo "<br /><br />\n\n";
+
+
+//$fp = event_socket_create($host, $port, $password);
+//$cmd = "api sofia ";
+//$response = event_socket_request($fp, $cmd);
+//echo "<b>api sofia</b><br />\n";
+//echo "<pre style=\"font-size: 9pt;\">\n";
+//echo $response;
+//echo "</pre>\n";
+//fclose($fp);
+//echo "<br /><br />\n\n";
+
+?>
+
+ </td>
+ </tr>
+</table>
+
+</div>
+<?php include("fend.inc"); ?>
+
+</body>
+</html>
diff --git a/config/freeswitch/freeswitch_time_conditions.tmp b/config/freeswitch/freeswitch_time_conditions.tmp
new file mode 100644
index 00000000..617bb5cf
--- /dev/null
+++ b/config/freeswitch/freeswitch_time_conditions.tmp
@@ -0,0 +1,191 @@
+<?php
+/* $Id$ */
+/*
+ freeswitch_time_conditions.php
+ Copyright (C) 2008 Mark J Crane
+ All rights reserved.
+
+ FreeSWITCH (TM)
+ http://www.freeswitch.org/
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+require("guiconfig.inc");
+require("/usr/local/pkg/freeswitch.inc");
+
+
+$a_ivr_options = &$config['installedpackages']['freeswitchivroptions']['config'];
+
+
+if ($_GET['act'] == "del") {
+ if ($_GET['type'] == 'ivroptions') {
+ if ($a_ivr_options[$_GET['id']]) {
+ unset($a_ivr_options[$_GET['id']]);
+ write_config();
+ //touch($d_hostsdirty_path);
+ header("Location: freeswitch_ivr_edit.php?id=".$_GET['parentid']);
+ exit;
+ }
+ }
+}
+
+
+include("head.inc");
+
+?>
+
+<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
+<?php include("fbegin.inc"); ?>
+<p class="pgtitle">FreeSWITCH: IVR: Options</p>
+
+<div id="mainlevel">
+<table width="100%" border="0" cellpadding="0" cellspacing="0">
+<tr><td class="tabnavtbl">
+<?php
+
+ $tab_array = array();
+ $tab_array[] = array(gettext("Settings"), false, "/pkg_edit.php?xml=freeswitch.xml&amp;id=0");
+ $tab_array[] = array(gettext("Dialplan"), false, "/freeswitch/freeswitch_dialplan_includes.php");
+ $tab_array[] = array(gettext("Extensions"), false, "/freeswitch/freeswitch_extensions.php");
+ $tab_array[] = array(gettext("External"), false, "/pkg_edit.php?xml=freeswitch_external.xml&amp;id=0");
+ $tab_array[] = array(gettext("Gateways"), false, "/freeswitch/freeswitch_gateways.php");
+ $tab_array[] = array(gettext("Internal"), false, "/pkg_edit.php?xml=freeswitch_internal.xml&amp;id=0");
+ $tab_array[] = array(gettext("IVR"), true, "/freeswitch/freeswitch_ivr.php");
+ $tab_array[] = array(gettext("Modules"), false, "/pkg_edit.php?xml=freeswitch_modules.xml&amp;id=0");
+ $tab_array[] = array(gettext("Public"), false, "/freeswitch/freeswitch_public_includes.php");
+ $tab_array[] = array(gettext("Rec"), false, "/freeswitch/freeswitch_recordings.php");
+ $tab_array[] = array(gettext("Status"), false, "/freeswitch/freeswitch_status.php");
+ $tab_array[] = array(gettext("Vars"), false, "/pkg_edit.php?xml=freeswitch_vars.xml&amp;id=0");
+ display_top_tabs($tab_array);
+
+?>
+</td></tr>
+</table>
+
+<table width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr>
+ <td class="tabcont" >
+
+<form action="freeswitch_ivr_options.php" method="post" name="iform" id="iform">
+<?php
+
+
+//echo "<pre>";
+//print_r ($a_ivr);
+//echo "</pre>";
+
+//if ($savemsg) print_info_box($savemsg);
+//if (file_exists($d_hostsdirty_path)): echo"<p>";
+//print_info_box_np("The FreeSWITCH recordings have been changed.<br>You must apply the changes in order for them to take effect.");
+//echo"<br />";
+//endif;
+
+?>
+ <table width="100%" border="0" cellpadding="6" cellspacing="0">
+ <tr>
+ <td><p><span class="vexpl"><span class="red"><strong>Note:<br>
+ </strong></span>
+ To make a recording dial extension 700 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.
+ </span></p></td>
+ </tr>
+ </table>
+ <br />
+
+ <table width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr>
+ <td width="20%" class="listhdrr">Filename</td>
+ <td width="25%" class="listhdrr">Name</td>
+ <td width="25%" class="listhdr">Description</td>
+ <td width="10%" class="list">
+ <table border="0" cellspacing="0" cellpadding="1">
+ <tr>
+ <td width="17"></td>
+ <td valign="middle"><a href="freeswitch_ivr_edit.php"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"></a></td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+
+ <?php $i = 0; foreach ($a_ivr as $ivrent): ?>
+ <tr>
+ <td class="listlr" ondblclick="document.location='freeswitch_ivr_edit.php?id=<?=$i;?>'">
+ <a href="javascript:void(0)" onclick="window.open('freeswitch_recordings_play.php?a=download&filename=<?=$recordingent['filename'];?>', 'play',' width=300,height=40,menubar=no,status=no,toolbar=no')">
+ <?=$ivrent['filename']?>
+ </a>
+ </td>
+ <td class="listr" ondblclick="document.location='freeswitch_ivr_edit.php?id=<?=$i;?>';">
+ <?=$ivrent['recordingname'];?>&nbsp;
+ </td>
+ <td class="listbg" ondblclick="document.location='freeswitch_ivr_edit.php?id=<?=$i;?>';">
+ <font color="#FFFFFF"><?=htmlspecialchars($recordingent['descr']);?>&nbsp;
+ </td>
+ <td valign="middle" nowrap class="list">
+ <table border="0" cellspacing="0" cellpadding="1">
+ <tr>
+ <td valign="middle"><a href="freeswitch_ivr_edit.php?id=<?=$i;?>"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" width="17" height="17" border="0"></a></td>
+ <td><a href="freeswitch_ivr_options.php?type=ivroption&act=del&id=<?=$i;?>" onclick="return confirm('Do you really want to delete this?')"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0"></a></td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ <?php $i++; endforeach; ?>
+ <tr>
+ <td class="list" colspan="3"></td>
+ <td class="list">
+ <table border="0" cellspacing="0" cellpadding="1">
+ <tr>
+ <td width="17"></td>
+ <td valign="middle"><a href="freeswitch_ivr_options_edit.php"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"></a></td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+
+
+ <tr>
+ <td class="list" colspan="3"></td>
+ <td class="list"></td>
+ </tr>
+ </table>
+
+</form>
+
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+
+</td>
+</tr>
+</table>
+
+</div>
+
+
+<?php include("fend.inc"); ?>
+</body>
+</html>
diff --git a/config/freeswitch/freeswitch_time_conditions_edit.tmp b/config/freeswitch/freeswitch_time_conditions_edit.tmp
new file mode 100644
index 00000000..c40b84f8
--- /dev/null
+++ b/config/freeswitch/freeswitch_time_conditions_edit.tmp
@@ -0,0 +1,215 @@
+<?php
+/* $Id$ */
+/*
+
+ freeswitch_time_conditions_edit.php
+ Copyright (C) 2008 Mark J Crane
+ All rights reserved.
+
+ FreeSWITCH (TM)
+ http://www.freeswitch.org/
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+require("guiconfig.inc");
+require("/usr/local/pkg/freeswitch.inc");
+
+
+$a_ivr_options = &$config['installedpackages']['freeswitchtimeconditions']['config'];
+
+$id = $_GET['id'];
+if (isset($_POST['id'])) {
+ $id = $_POST['id'];
+}
+
+//$parentid = $_GET['parentid'];
+//if (isset($_POST['parentid'])) {
+// $parentid = $_POST['parentid'];
+//}
+
+//$ivrid = $_GET['ivrid'];
+//if (isset($_POST['ivrid'])) {
+// $ivrid = $_POST['ivrid'];
+//}
+
+if (isset($id) && $a_ivr_options[$id]) {
+ $pconfig['conditionname'] = $a_ivr_options[$id]['conditionname'];
+ $pconfig['conditionstartday'] = $a_ivr_options[$id]['conditionstartday'];
+ $pconfig['conditionstarthrs'] = $a_ivr_options[$id]['conditionstarthrs'];
+ $pconfig['conditionstartmin'] = $a_ivr_options[$id]['conditionstartmin'];
+
+ $pconfig['conditionendday'] = $a_ivr_options[$id]['conditionendday'];
+ $pconfig['conditionendhrs'] = $a_ivr_options[$id]['conditionstarthrs'];
+ $pconfig['conditionendmin'] = $a_ivr_options[$id]['conditionendmin'];
+
+ $pconfig['conditionaction'] = $a_ivr_options[$id]['conditionaction'];
+ $pconfig['conditionantiaction'] = $a_ivr_options[$id]['conditionantiaction'];
+ $pconfig['conditionjavascript'] = $a_ivr_options[$id]['conditionjavascript'];
+ $pconfig['conditiondescr'] = $a_ivr_options[$id]['conditiondescr'];
+}
+
+
+
+if ($_POST) {
+
+ unset($input_errors);
+ $pconfig = $_POST;
+
+ if (!$input_errors) {
+
+ $ivroptionent = array();
+ $ivroptionent['ivrid'] = $_POST['ivrid'];
+ $ivroptionent['optionnumber'] = $_POST['optionnumber'];
+ $ivroptionent['optiontype'] = $_POST['optiontype'];
+ $ivroptionent['optiondest'] = $_POST['optiondest'];
+ $ivroptionent['optiondescr'] = $_POST['optiondescr'];
+
+ if (isset($id) && $a_ivr_options[$id]) {
+ //update
+ $a_ivr_options[$id] = $ivroptionent;
+ }
+ else {
+ //add
+ $a_ivr_options[] = $ivroptionent;
+ }
+
+ //touch($d_hostsdirty_path);
+ write_config();
+
+ header("Location: freeswitch_ivr_edit.php?id=".$parentid);
+ exit;
+ }
+}
+
+$pgtitle = "FreeSWITCH: IVR: Options: Edit";
+include("head.inc");
+
+?>
+
+<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
+<?php include("fbegin.inc"); ?>
+<p class="pgtitle"><?=$pgtitle?></p>
+<?php if ($input_errors) print_input_errors($input_errors); ?>
+
+<div id="mainlevel">
+<table width="100%" border="0" cellpadding="0" cellspacing="0">
+<tr><td class="tabnavtbl">
+<?php
+
+ $tab_array = array();
+ $tab_array[] = array(gettext("Settings"), false, "/pkg_edit.php?xml=freeswitch.xml&amp;id=0");
+ $tab_array[] = array(gettext("Dialplan"), false, "/freeswitch/freeswitch_dialplan_includes.php");
+ $tab_array[] = array(gettext("Extensions"), false, "/freeswitch/freeswitch_extensions.php");
+ $tab_array[] = array(gettext("External"), false, "/pkg_edit.php?xml=freeswitch_external.xml&amp;id=0");
+ $tab_array[] = array(gettext("Gateways"), false, "/freeswitch/freeswitch_gateways.php");
+ $tab_array[] = array(gettext("Internal"), false, "/pkg_edit.php?xml=freeswitch_internal.xml&amp;id=0");
+ $tab_array[] = array(gettext("IVR"), true, "/freeswitch/freeswitch_ivr.php");
+ $tab_array[] = array(gettext("Modules"), false, "/pkg_edit.php?xml=freeswitch_modules.xml&amp;id=0");
+ $tab_array[] = array(gettext("Public"), false, "/freeswitch/freeswitch_public_includes.php");
+ $tab_array[] = array(gettext("Rec"), false, "/freeswitch/freeswitch_recordings.php");
+ $tab_array[] = array(gettext("Status"), false, "/freeswitch/freeswitch_status.php");
+ $tab_array[] = array(gettext("Vars"), false, "/pkg_edit.php?xml=freeswitch_vars.xml&amp;id=0");
+ display_top_tabs($tab_array);
+
+?>
+</td></tr>
+</table>
+<table width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr>
+ <td class="tabcont" >
+
+ <form action="freeswitch_ivr_options_edit.php" method="post" name="iform" id="iform">
+ <table width="100%" border="0" cellpadding="6" cellspacing="0">
+ <tr>
+ <td width="22%" valign="top" class="vncellreq">Option Number</td>
+ <td width="78%" class="vtable">
+ <input name="optionnumber" type="text" class="formfld" id="optionnumber" size="40" value="<?=htmlspecialchars($pconfig['optionnumber']);?>">
+ <br> <span class="vexpl">Option Number<br>
+ e.g. <em>1</em></span></td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncellreq">Type</td>
+ <td width="78%" class="vtable">
+ <?php
+ echo " <select name='optiontype' class='formfld'>\n";
+ echo " <option></option>\n";
+ if (htmlspecialchars($pconfig['optiontype']) == "extension") {
+ echo " <option selected='yes'>extension</option>\n";
+ }
+ else {
+ echo " <option>extension</option>\n";
+ }
+ if (htmlspecialchars($pconfig['optiontype']) == "voicemail") {
+ echo " <option selected='yes'>voicemail</option>\n";
+ }
+ else {
+ echo " <option>voicemail</option>\n";
+ }
+ echo " </select>\n";
+ ?>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncellreq">Destination</td>
+ <td width="78%" class="vtable">
+ <input name="optiondest" type="text" class="formfld" id="optiondest" size="40" value="<?=htmlspecialchars($pconfig['optiondest']);?>">
+ <br> <span class="vexpl">Destination<br>
+ e.g. <em>1001</em></span></td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncell">Description</td>
+ <td width="78%" class="vtable">
+ <input name="optiondescr" type="text" class="formfld" id="optiondescr" size="40" value="<?=htmlspecialchars($pconfig['optiondescr']);?>">
+ <br> <span class="vexpl">You may enter a description here
+ for your reference (not parsed).</span></td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top">&nbsp;</td>
+ <td width="78%">
+ <input name="ivrid" type="hidden" value="<?=$ivrid;?>">
+ <input name="parentid" type="hidden" value="<?=$parentid;?>">
+ <?php if (isset($id) && $a_ivr_options[$id]): ?>
+ <input name="id" type="hidden" value="<?=$id;?>">
+ <?php endif; ?>
+ <input name="Submit" type="submit" class="formbtn" value="Save"> <input class="formbtn" type="button" value="Cancel" onclick="history.back()">
+ </td>
+ </tr>
+ </table>
+ </form>
+
+ <br>
+ <br>
+ <br>
+ <br>
+ <br>
+ <br>
+
+ </td>
+ </tr>
+</table>
+
+</div>
+
+<?php include("fend.inc"); ?>
+</body>
+</html>
diff --git a/config/freeswitch/freeswitch_vars.xml b/config/freeswitch/freeswitch_vars.xml
new file mode 100644
index 00000000..ac4246b9
--- /dev/null
+++ b/config/freeswitch/freeswitch_vars.xml
@@ -0,0 +1,136 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<!DOCTYPE packagegui SYSTEM "./schema/packages.dtd">
+<packagegui>
+ <copyright>
+ <![CDATA[
+/* $Id$ */
+/* ========================================================================== */
+/*
+
+ freeswitch_vars.xml
+ Copyright (C) 2008 Mark J Crane
+ All rights reserved.
+
+ FreeSWITCH (TM)
+ http://www.freeswitch.org/
+
+ part of pfSense (http://www.pfSense.com)
+ Copyright (C) 2007 to whom it may belong
+ All rights reserved.
+
+ Based on m0n0wall (http://m0n0.ch/wall)
+ Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>.
+ All rights reserved.
+ */
+/* ========================================================================== */
+/*
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+ */
+/* ========================================================================== */
+ ]]>
+ </copyright>
+ <description>FreeSWITCH is an open source telephony platform designed to facilitate the creation of voice and chat driven products scaling from a soft-phone up to a soft-switch. It can be used as a simple switching engine, a PBX, a media gateway or a media server to host IVR applications using simple scripts or XML to control the callflow.</description>
+ <requirements>Describe your package requirements here</requirements>
+ <faq>Currently there are no FAQ items provided.</faq>
+ <name>freeswitchvars</name>
+ <version>0.1</version>
+ <title>FreeSWITCH: Vars</title>
+ <aftersaveredirect>pkg_edit.php?xml=freeswitch_vars.xml&amp;id=0</aftersaveredirect>
+ <include_file>/usr/local/pkg/freeswitch.inc</include_file>
+ <tabs>
+ <tab>
+ <text>Settings</text>
+ <url>/pkg_edit.php?xml=freeswitch.xml&amp;id=0</url>
+ </tab>
+ <tab>
+ <text>Dialplan</text>
+ <url>/freeswitch/freeswitch_dialplan_includes.php</url>
+ </tab>
+ <tab>
+ <text>Extensions</text>
+ <url>/freeswitch/freeswitch_extensions.php</url>
+ </tab>
+ <tab>
+ <text>External</text>
+ <url>/pkg_edit.php?xml=freeswitch_external.xml&amp;id=0</url>
+ </tab>
+ <tab>
+ <text>Gateways</text>
+ <url>/freeswitch/freeswitch_gateways.php</url>
+ </tab>
+ <tab>
+ <text>Internal</text>
+ <url>/pkg_edit.php?xml=freeswitch_internal.xml&amp;id=0</url>
+ </tab>
+ <tab>
+ <text>IVR</text>
+ <url>/freeswitch/freeswitch_ivr.php</url>
+ </tab>
+ <tab>
+ <text>Modules</text>
+ <url>/pkg_edit.php?xml=freeswitch_modules.xml&amp;id=0</url>
+ </tab>
+ <tab>
+ <text>Public</text>
+ <url>/freeswitch/freeswitch_public_includes.php</url>
+ </tab>
+ <tab>
+ <text>Rec</text>
+ <url>/freeswitch/freeswitch_recordings.php</url>
+ </tab>
+ <tab>
+ <text>Status</text>
+ <url>/freeswitch/freeswitch_status.php</url>
+ </tab>
+ <tab>
+ <text>Vars</text>
+ <url>/pkg_edit.php?xml=freeswitch_vars.xml&amp;id=0</url>
+ <active/>
+ </tab>
+ </tabs>
+ <configpath>installedpackages->package->$packagename->configuration->freeswitchvars</configpath>
+ <fields>
+ <field>
+ <fielddescr>&lt;b&gt;Vars&lt;/b&gt; &lt;br /&gt; &lt;br /&gt;Define preprocessor variables here. Can be accessed in the xml configation with $${var_name}.</fielddescr>
+ <fieldname>vars_xml</fieldname>
+ <description>&lt;br /&gt;Path: /usr/local/freeswitch/conf/vars.xml &lt;br /&gt;&lt;br /&gt;</description>
+ <type>textarea</type>
+ <encoding>base64</encoding>
+ <wrap>off</wrap>
+ <size>30</size>
+ <cols>70</cols>
+ <rows>33</rows>
+ </field>
+ </fields>
+ <custom_php_command_before_form>
+ </custom_php_command_before_form>
+ <custom_php_after_head_command>
+ sync_package_freeswitch_vars();
+ </custom_php_after_head_command>
+ <custom_php_after_form_command>
+ </custom_php_after_form_command>
+ <custom_php_validation_command>
+ </custom_php_validation_command>
+ <custom_php_resync_config_command>
+ sync_package_freeswitch_vars();
+ </custom_php_resync_config_command>
+</packagegui> \ No newline at end of file
diff --git a/config/freeswitch/libncurses.so.5.6 b/config/freeswitch/libncurses.so.5.6
new file mode 100644
index 00000000..3b40374c
--- /dev/null
+++ b/config/freeswitch/libncurses.so.5.6
Binary files differ
diff --git a/config/freeswitch/libogg.so.5.3 b/config/freeswitch/libogg.so.5.3
new file mode 100644
index 00000000..d230b68e
--- /dev/null
+++ b/config/freeswitch/libogg.so.5.3
Binary files differ
diff --git a/config/freeswitch/libspandsp.so.1 b/config/freeswitch/libspandsp.so.1
new file mode 100644
index 00000000..177b8c22
--- /dev/null
+++ b/config/freeswitch/libspandsp.so.1
Binary files differ
diff --git a/config/freeswitch/libtinfo.so.5.6 b/config/freeswitch/libtinfo.so.5.6
new file mode 100644
index 00000000..1263ec79
--- /dev/null
+++ b/config/freeswitch/libtinfo.so.5.6
Binary files differ
diff --git a/config/freeswitch/libvorbis.so.4 b/config/freeswitch/libvorbis.so.4
new file mode 100644
index 00000000..ec91ac85
--- /dev/null
+++ b/config/freeswitch/libvorbis.so.4
Binary files differ
diff --git a/config/freeswitch/mod_fax.so.1 b/config/freeswitch/mod_fax.so.1
new file mode 100644
index 00000000..68bd05d0
--- /dev/null
+++ b/config/freeswitch/mod_fax.so.1
Binary files differ
diff --git a/config/freeswitch/mod_shout.so.1 b/config/freeswitch/mod_shout.so.1
new file mode 100644
index 00000000..26d9b94b
--- /dev/null
+++ b/config/freeswitch/mod_shout.so.1
Binary files differ
diff --git a/config/freeswitch/please_enter_your_pin_number.wav b/config/freeswitch/please_enter_your_pin_number.wav
new file mode 100644
index 00000000..46263917
--- /dev/null
+++ b/config/freeswitch/please_enter_your_pin_number.wav
Binary files differ
diff --git a/config/freeswitch/your_pin_number_is_incorect_goodbye.wav b/config/freeswitch/your_pin_number_is_incorect_goodbye.wav
new file mode 100644
index 00000000..5683bb8e
--- /dev/null
+++ b/config/freeswitch/your_pin_number_is_incorect_goodbye.wav
Binary files differ