aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--config/freeswitch/fax_to_email.tmp178
-rw-r--r--config/freeswitch/freeswitch.inc238
-rw-r--r--config/freeswitch/freeswitch_fax.tmp305
-rw-r--r--config/freeswitch/freeswitch_fax_edit.tmp723
-rw-r--r--config/freeswitch/freeswitch_features.tmp15
-rw-r--r--config/freeswitch/freeswitch_hunt_group.tmp6
6 files changed, 1448 insertions, 17 deletions
diff --git a/config/freeswitch/fax_to_email.tmp b/config/freeswitch/fax_to_email.tmp
new file mode 100644
index 00000000..fec291fb
--- /dev/null
+++ b/config/freeswitch/fax_to_email.tmp
@@ -0,0 +1,178 @@
+<?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("/etc/inc/config.inc");
+require_once("/usr/local/pkg/freeswitch.inc");
+global $config;
+
+//ob_end_clean();
+//ob_start();
+
+echo "\n---------------------------------\n";
+
+
+$phpversion = substr(phpversion(), 0, 1);
+if ($phpversion == '4') {
+ $faxemail = $_REQUEST["email"];
+ $faxextension = $_REQUEST["extension"];
+ $faxname = $_REQUEST["name"];
+}
+else {
+ $tmparray = explode("=", $_SERVER["argv"][1]);
+ $faxemail = $tmparray[1];
+ unset($tmparray);
+
+ $tmparray = explode("=", $_SERVER["argv"][2]);
+ $faxextension = $tmparray[1];
+ unset($tmparray);
+
+ $tmparray = explode("=", $_SERVER["argv"][3]);
+ $faxname = $tmparray[1];
+ unset($tmparray);
+}
+
+//echo "faxemail $faxemail\n";
+//echo "faxextension $faxextension\n";
+//echo "faxname $faxname\n";
+//echo "cd $dir_fax; /usr/local/bin/tiff2png ".$dir_fax.$faxname.".png\n";
+
+
+$dir_fax = '/usr/local/freeswitch/storage/fax/'.$faxextension.'/inbox/';
+
+
+if (!file_exists($dir_fax.$faxname.".png")) {
+ //cd /usr/local/freeswitch/storage/fax/9975/inbox/;/usr/local/bin/tiff2png /usr/local/freeswitch/storage/fax/9975/inbox/1001-2009-06-06-01-15-11.tif
+ //echo "cd $dir_fax; /usr/local/bin/tiff2png ".$dir_fax.$faxname.".tif\n";
+ exec("cd $dir_fax; /usr/local/bin/tiff2png ".$dir_fax.$faxname.".tif");
+}
+
+if (!file_exists($dir_fax.$faxname.".pdf")) {
+ //echo "cd $dir_fax; /usr/local/bin/tiff2pdf -f -o ".$faxname.".pdf ".$dir_fax.$faxname.".tif\n";
+ exec("cd $dir_fax; /usr/local/bin/tiff2pdf -f -o ".$faxname.".pdf ".$dir_fax.$faxname.".tif");
+}
+
+
+$tmp_subject = "Fax Received: ".$faxname;
+$tmp_textplain = "\nFax Received:\n";
+$tmp_textplain .= "Name: ".$faxname."\n";
+$tmp_textplain .= "Extension: ".$faxextension."\n";
+$tmp_texthtml = $tmp_textplain;
+
+
+$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/faxtoemail.txt", "w");
+//}
+
+
+
+
+
+
+
+//send the email
+
+ include "/usr/local/www/packages/freeswitch/class.phpmailer.php";
+ include "/usr/local/www/packages/freeswitch/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;
+ }
+
+ echo "tmp_smtpfrom: $tmp_smtpfrom\n";
+ echo "tmp_smtpfromname: $tmp_smtpfromname\n";
+ echo "tmp_subject: $tmp_subject\n";
+
+ $mail->From = $tmp_smtpfrom;
+ $mail->FromName = $tmp_smtpfromname;
+ $mail->Subject = $tmp_subject;
+ $mail->AltBody = $tmp_textplain; // optional, comment out and test
+ $mail->MsgHTML($tmp_texthtml);
+
+
+ $tmp_to = $faxemail;
+ $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) {
+ echo "tmp_to_row: $tmp_to_row\n";
+ $mail->AddAddress($tmp_to_row);
+ }
+ }
+
+ if (strlen($faxname) > 0) {
+ $mail->AddAttachment($dir_fax.$faxname.'.tif'); // tif attachment
+ $mail->AddAttachment($dir_fax.$faxname.'.pdf'); // pdf attachment
+ $mail->AddAttachment($dir_fax.$faxname.'.png'); // png attachment
+ //$filename='fax.tif'; $encoding = "base64"; $type = "image/tif";
+ //$mail->AddStringAttachment(base64_decode($strfax),$filename,$encoding,$type);
+ }
+
+ 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.inc b/config/freeswitch/freeswitch.inc
index d630ea3e..4813dfac 100644
--- a/config/freeswitch/freeswitch.inc
+++ b/config/freeswitch/freeswitch.inc
@@ -60,6 +60,8 @@ function build_menu() {
$menu_selected = false;
if ($_SERVER["SCRIPT_NAME"] == "/packages/freeswitch/freeswitch_features.php") { $menu_selected = true; }
+ if ($_SERVER["SCRIPT_NAME"] == "/packages/freeswitch/freeswitch_fax.php") { $menu_selected = true; }
+ if ($_SERVER["SCRIPT_NAME"] == "/packages/freeswitch/freeswitch_fax_edit.php") { $menu_selected = true; }
if ($_SERVER["SCRIPT_NAME"] == "/packages/freeswitch/freeswitch_ivr.php") { $menu_selected = true; }
if ($_SERVER["SCRIPT_NAME"] == "/packages/freeswitch/freeswitch_ivr_edit.php") { $menu_selected = true; }
if ($_SERVER["SCRIPT_NAME"] == "/packages/freeswitch/freeswitch_ivr_options_edit.php") { $menu_selected = true; }
@@ -1060,7 +1062,7 @@ function sync_package_freeswitch_hunt_group()
$dialplanincludeid = guid();
$ent['dialplanincludeid'] = $dialplanincludeid;
- $ent['extensionname'] = $rowhelper['ivrextension'];
+ $ent['extensionname'] = $rowhelper['huntgroupname'];
$ent['order'] = '9001'; //if update use the existing order number and extension name and desc
$ent['context'] = $rowhelper['huntgroupcontext'];
$ent['enabled'] = 'true';
@@ -1096,7 +1098,7 @@ function sync_package_freeswitch_hunt_group()
if ($action == 'update') {
$ent['dialplanincludeid'] = $dialplanincludeid;
- $ent['extensionname'] = $rowhelper['huntgroupextension'];
+ $ent['extensionname'] = $rowhelper['huntgroupname'];
$ent['order'] = $order;
$ent['context'] = $context;
$ent['enabled'] = $enabled;
@@ -1167,12 +1169,14 @@ function sync_package_freeswitch_hunt_group()
}
//order the array
- function cmp_hunt_group_order($a, $b) {
- if ($a["destinationorder"] > $b["destinationorder"]) {
- return 1;
- }
- else {
- return 0;
+ if (!function_exists(cmp_hunt_group_order)) {
+ function cmp_hunt_group_order($a, $b) {
+ if ($a["destinationorder"] > $b["destinationorder"]) {
+ return 1;
+ }
+ else {
+ return 0;
+ }
}
}
@@ -1232,14 +1236,16 @@ function sync_package_freeswitch_hunt_group()
case "simultaneous":
//print_r($tmp_array);
$x = 0;
- foreach ($tmp_array as $row) {
- if ($x < 1) {
- $tmp_buffer = $row["data"];
- }
- else {
- $tmp_buffer .= "+\",\"+".$row["data"];
+ if(count($tmp_array) > 0) {
+ foreach ($tmp_array as $row) {
+ if ($x < 1) {
+ $tmp_buffer = $row["data"];
+ }
+ else {
+ $tmp_buffer .= "+\",\"+".$row["data"];
+ }
+ $x++;
}
- $x++;
}
$delimiter = ",";
@@ -1303,6 +1309,199 @@ function sync_package_freeswitch_hunt_group()
} //end function
+function sync_package_freeswitch_fax()
+{
+
+ global $config;
+ conf_mount_rw();
+ config_lock();
+
+ //loop through all faxes
+ $a_fax = &$config['installedpackages']['freeswitchfax']['config'];
+ if (count($a_fax) > 0) {
+ foreach($a_fax as $rowhelper) {
+
+ //get the fax information such as the name and description
+ //$rowhelper['faxid']
+ //$rowhelper['faxextension']
+ //$rowhelper['faxname']
+ //$rowhelper['faxemail']
+ //$rowhelper['faxdomain']
+ //$rowhelper['faxdescription']
+
+ //add each fax extension to the dialplan
+ $a_dialplan_includes = &$config['installedpackages']['freeswitchdialplanincludes']['config'];
+ $a_dialplan_include_details = &$config['installedpackages']['freeswitchdialplanincludedetails']['config'];
+
+ //determine if the entry should be an add, or update to the dialplan
+ if (strlen($rowhelper['faxid']) > 0) {
+ $action = 'add'; //set default action to add
+ $i = 0;
+ if (count($a_dialplan_includes) > 0) {
+
+ foreach($a_dialplan_includes as $row) {
+
+ //$row['faxid'];
+ //$row['faxname'];
+ //$row['context'];
+ //$row['enabled'];
+
+ if ($row['opt1name'] == "faxid" && $row['opt1value'] == $rowhelper['faxid']) {
+ //update
+ $action = 'update';
+
+ $dialplanincludeid = $rowhelper['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";
+
+ if (file_exists("/usr/local/freeswitch/conf/dialplan/default/".$order."_".$extensionname.".xml")){
+ unlink("/usr/local/freeswitch/conf/dialplan/default/".$order."_".$extensionname.".xml");
+ }
+ }
+ $i++;
+
+ }
+ }
+
+ $ent = array();
+ if ($action == 'add') {
+ $faxid = $rowhelper['faxid'];
+ if (strlen($rowhelper['faxname']) > 0) {
+ $ent['dialplanincludeid'] = $faxid;
+ $ent['extensionname'] = $rowhelper['faxname'];
+ $ent['order'] = '9001'; //if update use the existing order number and extension name and desc
+ $ent['context'] = "default";
+ //$ent['context'] = $rowhelper['huntgroupcontext'];
+ $ent['enabled'] = 'true';
+ $ent['descr'] = 'fax';
+ $ent['opt1name'] = 'faxid';
+ $ent['opt1value'] = $rowhelper['faxid'];
+
+ //add to the config
+ $a_dialplan_includes[] = $ent;
+ unset($ent);
+
+ //<!-- default ${domain_name} -->
+ //<condition field="destination_number" expression="^\*9978$">
+ $ent = array();
+ $ent['dialplanincludeid'] = $faxid;
+ $ent['tag'] = 'condition'; //condition, action, antiaction
+ $ent['fieldorder'] = '000';
+ $ent['fieldtype'] = 'destination_number';
+ $ent['fielddata'] = '^'.$rowhelper['faxextension'].'$';
+ $a_dialplan_include_details[] = $ent;
+ unset($ent);
+
+ //<action application="answer" />
+ $ent = array();
+ $ent['dialplanincludeid'] = $faxid;
+ $ent['tag'] = 'action'; //condition, action, antiaction
+ $ent['fieldorder'] = '001';
+ $ent['fieldtype'] = 'answer';
+ $ent['fielddata'] = '';
+ $a_dialplan_include_details[] = $ent;
+ unset($ent);
+
+ //<action application="playback" data="silence_stream://2000"/>
+ $ent = array();
+ $ent['dialplanincludeid'] = $faxid;
+ $ent['tag'] = 'action'; //condition, action, antiaction
+ $ent['fieldorder'] = '002';
+ $ent['fieldtype'] = 'playback';
+ $ent['fielddata'] = 'silence_stream://2000';
+ $a_dialplan_include_details[] = $ent;
+ unset($ent);
+
+ //<action application="set" data="last_fax=${caller_id_number}-${strftime(%Y-%m-%d-%H-%M-%S)}"/>
+ $ent = array();
+ $ent['dialplanincludeid'] = $faxid;
+ $ent['tag'] = 'action'; //condition, action, antiaction
+ $ent['fieldorder'] = '003';
+ $ent['fieldtype'] = 'set';
+ $ent['fielddata'] = 'last_fax=${caller_id_number}-${strftime(%Y-%m-%d-%H-%M-%S)}';
+ $a_dialplan_include_details[] = $ent;
+ unset($ent);
+
+ //<action application="rxfax" data="/usr/local/freeswitch/storage/fax/inbox/${last_fax}.tif"/>
+ $ent = array();
+ $ent['dialplanincludeid'] = $faxid;
+ $ent['tag'] = 'action'; //condition, action, antiaction
+ $ent['fieldorder'] = '004';
+ $ent['fieldtype'] = 'rxfax';
+ $ent['fielddata'] = '/usr/local/freeswitch/storage/fax/'.$rowhelper['faxextension'].'/inbox/${last_fax}.tif';
+ $a_dialplan_include_details[] = $ent;
+ unset($ent);
+
+ //<action application="system" data="/opt/freeswitch/scripts/emailfax.sh USER DOMAIN /usr/local/freeswitch/storage/fax/inbox/9872/${last_fax}.tif"/>
+ $ent = array();
+ $ent['dialplanincludeid'] = $faxid;
+ $ent['tag'] = 'action'; //condition, action, antiaction
+ $ent['fieldorder'] = '005';
+ $ent['fieldtype'] = 'system';
+ $ent['fielddata'] = '/usr/local/bin/php /usr/local/www/packages/freeswitch/fax_to_email.php email='.$rowhelper['faxemail'].' extension='.$rowhelper['faxextension'].' name=${last_fax} >> /tmp/fax.txt';
+ $a_dialplan_include_details[] = $ent;
+ unset($ent);
+
+ //<action application="hangup"/>
+ $ent = array();
+ $ent['dialplanincludeid'] = $faxid;
+ $ent['tag'] = 'action'; //condition, action, antiaction
+ $ent['fieldorder'] = '006';
+ $ent['fieldtype'] = 'hangup';
+ $ent['fielddata'] = '';
+ $a_dialplan_include_details[] = $ent;
+ unset($ent);
+ }
+
+ unset($faxid);
+
+ }
+ if ($action == 'update') {
+
+ $ent['dialplanincludeid'] = $rowhelper['faxid'];
+ $ent['extensionname'] = $rowhelper['faxname'];
+ $ent['order'] = $order;
+ $ent['context'] = $context;
+ $ent['enabled'] = $enabled;
+ $ent['descr'] = $faxdescription;
+ $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 faxid; add the fax to the dialplan
+
+ } //end foreach
+ } //end if count
+ conf_mount_ro();
+ config_unlock();
+
+} //end function
+
+
function get_recording_filename($id)
{
global $config;
@@ -2243,6 +2442,15 @@ function freeswitch_php_install_command()
if (!is_dir('/usr/local/www/packages/freeswitch/')) {
exec("mkdir /usr/local/www/packages/freeswitch/");
}
+
+ if (!is_dir('/usr/local/freeswitch/storage/fax/')) {
+ exec("mkdir /usr/local/freeswitch/storage/fax/");
+ }
+
+ if (!is_dir('/usr/local/freeswitch/storage/fax/receive/')) {
+ exec("mkdir /usr/local/freeswitch/storage/fax/receive/");
+ }
+
//$struname = exec('uname -v');
//if (stristr($struname, 'FreeBSD 7.0')) {
// $freebsd_version = "7.0";
diff --git a/config/freeswitch/freeswitch_fax.tmp b/config/freeswitch/freeswitch_fax.tmp
new file mode 100644
index 00000000..38992663
--- /dev/null
+++ b/config/freeswitch/freeswitch_fax.tmp
@@ -0,0 +1,305 @@
+<?php
+/* $Id$ */
+/*
+ freeswitch_fax.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_fax = &$config['installedpackages']['freeswitchfax']['config'];
+$dir_fax = '/usr/local/freeswitch/storage/fax/inbox/';
+
+if ($_GET['act'] == "del") {
+ if ($_GET['type'] == 'fax') {
+ if ($a_fax[$_GET['id']]) {
+
+ $faxid = $a_fax[$_GET['id']][faxid];
+ $faxname = $a_fax[$_GET['id']][faxname];
+
+ $a_dialplan_includes = &$config['installedpackages']['freeswitchdialplanincludes']['config'];
+ $a_dialplan_includes_details = &$config['installedpackages']['freeswitchdialplanincludedetails']['config'];
+
+ //delete the dialplan include
+ if (count($a_dialplan_includes) > 0) {
+ $i=0;
+ foreach($a_dialplan_includes as $row) {
+ if ($row["dialplanincludeid"] == $faxid) {
+ $order = $row['order'];
+ unset($a_dialplan_includes[$i]);
+ }
+ $i++;
+ }
+ }
+
+ //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"] == $faxid) {
+ unset($a_dialplan_includes_details[$i]);
+ }
+ $i++;
+ }
+ }
+
+ if (file_exists("/usr/local/freeswitch/conf/dialplan/default/".$order."_".$faxname.".xml")){
+ unlink("/usr/local/freeswitch/conf/dialplan/default/".$order."_".$faxname.".xml");
+ }
+
+ //remove fax entries
+ unset($a_fax[$_GET['id']]);
+
+ write_config();
+ header("Location: freeswitch_fax.php");
+ exit;
+ }
+ }
+}
+
+if ($_GET['a'] == "download") {
+
+ session_cache_limiter('public');
+
+ if ($_GET['type'] = "fax_file") {
+ if (file_exists($dir_fax.$_GET['filename'])) {
+ $fd = fopen($dir_fax.$_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 == "png") {
+ header("Content-Type: image/png");
+ }
+ }
+ 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_fax.$_GET['filename']));
+ fpassthru($fd);
+ }
+ }
+
+ exit;
+}
+else {
+ //echo $dir_fax.$_GET['filename'];
+}
+
+
+if ($_GET['act'] == "del") {
+ if ($_GET['type'] == 'fax_file') {
+ //if ($a_fax[$_GET['id']]) {
+ $tmp_file_array = split("\.",$_GET['filename']);
+ $file_name = $tmp_file_array[0];
+ $file_ext = $tmp_file_array[1];
+ unlink_if_exists($dir_fax.$file_name.".pdf");
+ unlink_if_exists($dir_fax.$file_name.".png");
+ unlink_if_exists($dir_fax.$file_name.".tif");
+ //unset($a_fax[$_GET['id']]);
+ write_config();
+ header("Location: freeswitch_fax.php");
+ exit;
+ //}
+ }
+
+}
+
+include("head.inc");
+
+?>
+
+
+<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
+<?php include("fbegin.inc"); ?>
+<p class="pgtitle">FreeSWITCH: FAX</p>
+
+<div id="mainlevel">
+<table width="100%" border="0" cellpadding="0" cellspacing="0">
+<tr><td class="tabnavtbl">
+<?php
+
+display_top_tabs(build_menu());
+
+?>
+</td></tr>
+</table>
+
+<table width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr>
+ <td class="tabcont" >
+
+<form action="freeswitch_fax.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 fax 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>FAX<br>
+ </strong></span>
+ To receive a FAX setup a fax extension and then direct the incoming FAX with a dedicated number or you can detect the FAX tone by using <a href='http://wiki.freeswitch.org/wiki/Misc._Dialplan_Tools_tone_detect' target='_blank'>tone detection</a> on the Public tab.
+ </p></td>
+ </tr>
+ </table>
+ <br />
+
+ <table width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr>
+ <td width="40" class="listhdrr">Extension</td>
+ <td width="40" class="listhdrr" nowrap>Name</td>
+ <td width="40%" class="listhdrr" nowrap>Email</td>
+ <td width="40" class="listhdrr">Domain</td>
+ <td width="50%" class="listhdr">Description</td>
+ <td width="40" class="list">
+
+ <table border="0" cellspacing="0" cellpadding="1">
+ <tr>
+ <td width="17"></td>
+ <td valign="middle"><a href="freeswitch_fax_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
+
+ //create a temporary id for the array
+ $i = 0;
+ if (count($a_fax) > 0) {
+ foreach ($a_fax as $ent) {
+ $a_fax[$i]['id'] = $i;
+ $i++;
+ }
+ }
+
+ //order the array
+ function cmp_number($a, $b) {
+ if ($a["faxextension"] > $b["faxextension"]) {
+ return 1;
+ }
+ else {
+ return 0;
+ }
+ }
+ if (count($a_fax) > 0) { usort($a_fax, "cmp_number"); }
+
+ $i = 0;
+ if (count($a_fax) > 0) {
+
+ foreach ($a_fax as $ent) {
+ if (strlen($ent['faxextension']) > 0) {
+ ?>
+ <tr>
+ <td class="listr" ondblclick="document.location='freeswitch_fax_edit.php?id=<?=$ent['id'];?>';">
+ <?=$ent['faxextension'];?>&nbsp;
+ </td>
+ <td class="listr" ondblclick="document.location='freeswitch_fax_edit.php?id=<?=$ent['id'];?>';">
+ <?=$ent['faxname'];?>&nbsp;
+ </td>
+ <td class="listr" ondblclick="document.location='freeswitch_fax_edit.php?id=<?=$ent['id'];?>';">
+ <?=$ent['faxemail'];?>&nbsp;
+ </td>
+ <td class="listr" ondblclick="document.location='freeswitch_fax_edit.php?id=<?=$ent['id'];?>';">
+ <?=$ent['faxdomain'];?>&nbsp;
+ </td>
+ <td class="listbg" ondblclick="document.location='freeswitch_fax_edit.php?id=<?=$ent['id'];?>';">
+ <font color="#FFFFFF"><?=htmlspecialchars($ent['faxdescription']);?>&nbsp;
+ </td>
+ <td valign="middle" nowrap class="list">
+ <table border="0" cellspacing="0" cellpadding="1">
+ <tr>
+ <td valign="middle"><a href="freeswitch_fax_edit.php?id=<?=$ent['id'];?>"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" width="17" height="17" border="0"></a></td>
+ <td><a href="freeswitch_fax.php?type=fax&act=del&id=<?=$ent['id'];?>" 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="5"></td>
+ <td class="list">
+ <table border="0" cellspacing="0" cellpadding="1">
+ <tr>
+ <td width="17"></td>
+ <td valign="middle"><a href="freeswitch_fax_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="5"></td>
+ <td class="list"></td>
+ </tr>
+ </table>
+
+</form>
+
+
+<br />
+<br />
+<br />
+<br />
+
+
+</td>
+</tr>
+</table>
+
+</div>
+
+
+<?php include("fend.inc"); ?>
+</body>
+</html> \ No newline at end of file
diff --git a/config/freeswitch/freeswitch_fax_edit.tmp b/config/freeswitch/freeswitch_fax_edit.tmp
new file mode 100644
index 00000000..43b22cf3
--- /dev/null
+++ b/config/freeswitch/freeswitch_fax_edit.tmp
@@ -0,0 +1,723 @@
+<?php
+/* $Id$ */
+/*
+ freeswitch_fax_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_fax = &$config['installedpackages']['freeswitchfax']['config'];
+
+$id = $_GET['id'];
+if (strlen($id) == 0) {
+ $id = $_POST['id'];
+}
+$parentid = $id;
+
+if (isset($id) && $a_fax[$id]) {
+ $pconfig['faxid'] = $a_fax[$id]['faxid'];
+ $faxid = $a_fax[$id]['faxid'];
+ $pconfig['faxextension'] = $a_fax[$id]['faxextension'];
+ $pconfig['faxname'] = $a_fax[$id]['faxname'];
+ $pconfig['faxemail'] = $a_fax[$id]['faxemail'];
+ $pconfig['faxdomain'] = $a_fax[$id]['faxdomain'];
+ $pconfig['faxdescription'] = $a_fax[$id]['faxdescription'];
+}
+
+
+$dir_fax_inbox = '/usr/local/freeswitch/storage/fax/'.$pconfig['faxextension'].'/inbox/';
+$dir_fax_sent = '/usr/local/freeswitch/storage/fax/'.$pconfig['faxextension'].'/sent/';
+$dir_fax_temp = '/usr/local/freeswitch/storage/fax/'.$pconfig['faxextension'].'/temp/';
+
+if ($_GET['act'] == "del") {
+ if ($_GET['type'] == 'fax') {
+ if ($a_fax[$_GET['id']]) {
+
+ $faxid = $a_fax[$_GET['id']][faxid];
+ $faxname = $a_fax[$_GET['id']][faxname];
+
+ $a_dialplan_includes = &$config['installedpackages']['freeswitchdialplanincludes']['config'];
+ $a_dialplan_includes_details = &$config['installedpackages']['freeswitchdialplanincludedetails']['config'];
+
+ //delete the dialplan include
+ if (count($a_dialplan_includes) > 0) {
+ $i=0;
+ foreach($a_dialplan_includes as $row) {
+ if ($row["dialplanincludeid"] == $faxid) {
+ $order = $row['order'];
+ unset($a_dialplan_includes[$i]);
+ }
+ $i++;
+ }
+ }
+
+ //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"] == $faxid) {
+ unset($a_dialplan_includes_details[$i]);
+ }
+ $i++;
+ }
+ }
+
+ if (file_exists("/usr/local/freeswitch/conf/dialplan/default/".$order."_".$faxname.".xml")){
+ unlink("/usr/local/freeswitch/conf/dialplan/default/".$order."_".$faxname.".xml");
+ }
+
+ //remove fax entries
+ unset($a_fax[$_GET['id']]);
+
+ write_config();
+ header("Location: freeswitch_fax.php");
+ exit;
+ }
+ }
+}
+
+if (($_POST['type'] == "fax_send") && is_uploaded_file($_FILES['fax_file']['tmp_name'])) {
+
+ $fax_number = $_POST['fax_number'];
+ $fax_name = $_FILES['fax_file']['name'];
+ $fax_name = str_replace(".tif", "", $fax_name);
+ $fax_name = str_replace(".tiff", "", $fax_name);
+ $fax_name = str_replace(".pdf", "", $fax_name);
+ $fax_gateway = $_POST['fax_gateway'];
+
+ $password = $config['installedpackages']['freeswitchsettings']['config'][0]['event_socket_password'];
+ $port = $config['installedpackages']['freeswitchsettings']['config'][0]['event_socket_port'];
+ $host = $config['interfaces']['lan']['ipaddr'];
+
+ //upload the file
+ move_uploaded_file($_FILES['fax_file']['tmp_name'], $dir_fax_temp.$_FILES['fax_file']['name']);
+
+ $fax_file_extension = substr($dir_fax_temp.$_FILES['fax_file']['name'], -4);
+ if ($fax_file_extension == ".pdf") {
+ exec("cd ".$dir_fax_temp.";gs -q -sDEVICE=tiffg3 -r204x98 -dNOPAUSE -sOutputFile=".$fax_name.".tif -- ".$fax_name.".pdf -c quit");
+ //exec("rm ".$dir_fax_temp.$fax_name.".pdf");
+ }
+ if ($fax_file_extension == ".tiff") {
+ exec("cp ".$dir_fax_temp.$fax_name.".tiff ".$dir_fax_temp.$fax_name.".tif");
+ exec("rm ".$dir_fax_temp.$fax_name.".tiff");
+ }
+
+ //send the fax
+ $fp = event_socket_create($host, $port, $password);
+ $cmd = "api originate [absolute_codec_string=PCMU]sofia/gateway/".$fax_gateway."/".$fax_number." &txfax(".$dir_fax_temp.$fax_name.".tif)";
+ $response = event_socket_request($fp, $cmd);
+ $response = str_replace("\n", "", $response);
+ $uuid = str_replace("+OK ", "", $response);
+ fclose($fp);
+
+ //if ($response >= 1) {
+ // $fp = event_socket_create($host, $port, $password);
+ // $cmd = "api uuid_getvar ".$uuid." fax_result_text";
+ // echo $cmd."\n";
+ // $response = event_socket_request($fp, $cmd);
+ // $response = trim($response);
+ // fclose($fp);
+ //}
+
+ sleep(5);
+
+ //copy the .tif to the sent directory
+ exec("cp ".$dir_fax_temp.$fax_name.".tif ".$dir_fax_sent.$fax_name.".tif");
+
+ //delete the .tif from the temp directory
+ //exec("rm ".$dir_fax_temp.$fax_name.".tif");
+
+ //convert the tif to pdf and png
+ exec("cd $dir_fax_sent; /usr/local/bin/tiff2png ".$dir_fax_sent.$fax_name.".tif");
+ exec("cd $dir_fax_sent; /usr/local/bin/tiff2pdf -f -o ".$fax_name.".pdf ".$dir_fax_sent.$fax_name.".tif");
+
+ header("Location: freeswitch_fax_edit.php?id=".$id."&msg=".$response);
+ exit;
+}
+
+if ($_GET['a'] == "download") {
+
+ session_cache_limiter('public');
+
+ if ($_GET['type'] == "fax_inbox") {
+
+ if (file_exists($dir_fax_inbox.$_GET['filename'])) {
+
+ $fd = fopen($dir_fax_inbox.$_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 == "png") {
+ header("Content-Type: image/png");
+ }
+ }
+ 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_fax_inbox.$_GET['filename']));
+ fpassthru($fd);
+ }
+ else {
+ echo "not found";
+ }
+ exit;
+ }
+
+}
+else {
+ //echo $dir_fax_inbox.$_GET['filename'];
+}
+
+
+if ($_GET['a'] == "download") {
+
+ session_cache_limiter('public');
+
+ if ($_GET['type'] == "fax_sent") {
+ if (file_exists($dir_fax_sent.$_GET['filename'])) {
+ $fd = fopen($dir_fax_sent.$_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 == "png") {
+ header("Content-Type: image/png");
+ }
+ }
+ 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_fax_sent.$_GET['filename']));
+ fpassthru($fd);
+ }
+
+ }
+
+ exit;
+}
+else {
+ //echo $dir_fax_inbox.$_GET['filename'];
+}
+
+
+if ($_GET['act'] == "del") {
+ if ($_GET['type'] == 'fax_inbox') {
+ //if ($a_fax[$_GET['id']]) {
+ $tmp_file_array = split("\.",$_GET['filename']);
+ $file_name = $tmp_file_array[0];
+ $file_ext = $tmp_file_array[1];
+ unlink_if_exists($dir_fax_inbox.$file_name.".pdf");
+ unlink_if_exists($dir_fax_inbox.$file_name.".png");
+ unlink_if_exists($dir_fax_inbox.$file_name.".tif");
+ //unset($a_fax[$_GET['id']]);
+ write_config();
+ header("Location: freeswitch_fax.php");
+ exit;
+ //}
+ }
+}
+
+
+if ($_GET['act'] == "del") {
+ if ($_GET['type'] == 'fax_sent') {
+ //if ($a_fax[$_GET['id']]) {
+ $tmp_file_array = split("\.",$_GET['filename']);
+ $file_name = $tmp_file_array[0];
+ $file_ext = $tmp_file_array[1];
+ unlink_if_exists($dir_fax_sent.$file_name.".pdf");
+ unlink_if_exists($dir_fax_sent.$file_name.".png");
+ unlink_if_exists($dir_fax_sent.$file_name.".tif");
+ //unset($a_fax[$_GET['id']]);
+ write_config();
+ header("Location: freeswitch_fax.php");
+ exit;
+ //}
+ }
+}
+
+
+if ($_POST) {
+
+ unset($input_errors);
+ $pconfig = $_POST;
+
+ if (!$input_errors) {
+
+ $ent = array();
+ if (strlen($_POST['faxid']) > 0) {
+ $ent['faxid'] = $_POST['faxid'];
+ }
+ else {
+ $ent['faxid'] = guid();
+ }
+ $ent['faxextension'] = $_POST['faxextension'];
+ $ent['faxname'] = $_POST['faxname'];
+ $ent['faxemail'] = $_POST['faxemail'];
+ $ent['faxdomain'] = $_POST['faxdomain'];
+ $ent['faxdescription'] = $_POST['faxdescription'];
+
+ if (isset($id) && $a_fax[$id]) {
+ //update
+ $a_fax[$id] = $ent;
+ }
+ else {
+ //add
+ $a_fax[] = $ent;
+ }
+
+ if (!is_dir('/usr/local/freeswitch/storage/fax/')) {
+ exec("mkdir /usr/local/freeswitch/storage/fax/");
+ }
+
+ $faxfolder = '/usr/local/freeswitch/storage/fax/'.$_POST['faxextension'];
+ if (!is_dir($faxfolder)) {
+ exec('mkdir '.$faxfolder);
+ }
+ if (!is_dir($faxfolder.'/inbox/')) {
+ exec('mkdir '.$faxfolder.'/inbox/');
+ }
+ if (!is_dir($faxfolder.'/sent/')) {
+ exec('mkdir '.$faxfolder.'/sent/');
+ }
+ if (!is_dir($faxfolder.'/temp/')) {
+ exec('mkdir '.$faxfolder.'/temp/');
+ }
+ write_config();
+ sync_package_freeswitch_fax();
+
+ header("Location: freeswitch_fax.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: FAX: 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
+
+display_top_tabs(build_menu());
+
+?>
+</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>FAX Setup<br>
+ </strong></span>
+ </p></td>
+ </tr>
+ </table>
+ <br />
+
+ <form action="freeswitch_fax_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="faxextension" type="text" class="formfld unknown" id="faxextension" size="40" value="<?=htmlspecialchars($pconfig['faxextension']);?>">
+ <br><span class="vexpl">Enter the fax extension here.<br></span>
+ </td>
+ </tr>
+ <tr>
+ <td width="25%" valign="top" class="vncellreq">Name</td>
+ <td width="75%" class="vtable">
+ <input name="faxname" type="text" class="formfld unknown" id="faxname" size="40" value="<?=htmlspecialchars($pconfig['faxname']);?>">
+ <br><span class="vexpl">Enter the name here.<br></span>
+ </td>
+ </tr>
+ <tr>
+ <td width="25%" valign="top" class="vncellreq">Email</td>
+ <td width="75%" class="vtable">
+ <input name="faxemail" type="text" class="formfld unknown" id="faxemail" size="40" value="<?=htmlspecialchars($pconfig['faxemail']);?>">
+ <br><span class="vexpl">Optional: Enter the email address to send the FAX to.<br></span>
+ </td>
+ </tr>
+ <tr>
+ <td width="25%" valign="top" class="vncellreq">Domain</td>
+ <td width="75%" class="vtable">
+ <input name="faxdomain" type="text" class="formfld unknown" id="faxdomain" size="40" value="<?=htmlspecialchars($pconfig['faxdomain']);?>">
+ <br><span class="vexpl">Enter the domain here.<br></span>
+ </td>
+ </tr>
+ <!--
+ <tr>
+ <td width="25%" valign="top" class="vncellreq" nowrap>Attach File</td>
+ <td width="75%" class="vtable">
+ <?php
+ /*
+ echo " <select name='vm-attach-file' class='formfld unknown'>\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>
+ -->
+
+ <table width="100%" border="0" cellpadding="6" cellspacing="0">
+ <tr>
+ <td width="25%" valign="top" class="vncellreq">Description</td>
+ <td width="75%" class="vtable">
+ <input name="faxdescription" type="text" class="formfld unknown" id="faxdescription" size="40" value="<?=htmlspecialchars($pconfig['faxdescription']);?>">
+ <br><span class="vexpl">Enter the description here.<br></span>
+ </td>
+ </tr>
+ <tr>
+ <td valign="top">&nbsp;</td>
+ <td>
+ <input name="faxid" type="hidden" value="<?=htmlspecialchars($pconfig['faxid']);?>">
+ <?php if (isset($id) && $a_fax[$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 />
+
+
+ <table width="100%" border="0" cellpadding="3" cellspacing="0">
+ <tr>
+ <td width='30%'>
+ <span class="vexpl"><span class="red"><strong>Send</strong></span>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ To send a fax you can upload a .tif file or if ghost script has been installed then you can also send a fax by uploading a PDF. (pkg_add -r ghostscript8-nox11; rehash)
+ When sending a fax you can view status of the transmission by viewing the logs from the Status tab or by watching the response from the FreeSWITCH console.
+ </td>
+ </tr>
+ <tr>
+ <td align='right' nowrap>
+ <form action="" method="POST" enctype="multipart/form-data" name="frmUpload" onSubmit="">
+ <table border='0' cellpadding='3' cellspacing='0' width='100%'>
+ <tr>
+ <td valign="middle" class="label">
+ Fax Number
+ </td>
+ <td valign="top" class="label">
+ <input type="text" name="fax_number" value="">
+ </td>
+ <td align="left">Upload:</td>
+ <td valign="top" class="label">
+ <input name="id" type="hidden" value="$id">
+ <input name="type" type="hidden" value="fax_send">
+ <input name="fax_file" type="file" class="button" id="fax_file">
+ </td>
+ <td valign="middle" class="label">
+ Gateway
+ </td>
+ <td valign="top" class="label">
+
+ <?php
+ //create a temporary id for the array
+ $a_gateways = &$config['installedpackages']['freeswitchgateways']['config'];
+
+ $i = 0;
+ if (count($a_gateways) > 0) {
+ foreach ($a_gateways as $ent) {
+ $a_gateways[$i]['id'] = $i;
+ $i++;
+ }
+ }
+
+ //order the array
+ function cmp_string($a, $b) {
+ return strcmp($a["gateway"], $b["gateway"]);
+ }
+ if (count($a_gateways) > 0) { usort($a_gateways, "cmp_string"); }
+
+ echo "<select name='fax_gateway' class='formfld'>";
+ $i = 0;
+ if (count($a_gateways) > 0) {
+
+ foreach ($a_gateways as $ent) {
+ echo "<option>".$ent['gateway']."</option>\n";
+ }
+ }
+ echo "</select>\n";
+
+ ?>
+ </td>
+ <td>
+ <input name="submit" type="submit" class="button" id="upload" value="Send FAX">
+ </td>
+ </tr>
+ </table>
+ </div>
+ </form>
+ </td>
+ </tr>
+ </table>
+
+
+
+ <br />
+ <br />
+ <br />
+ <br />
+
+ <table width="100%" border="0" cellpadding="5" cellspacing="0">
+ <tr>
+ <td>
+ <span class="vexpl"><span class="red"><strong>Inbox</strong></span>
+ </td>
+ <td align='right'>
+ <b>location:</b> <?php echo $dir_fax_inbox; ?>
+ </td>
+ </tr>
+ </table>
+
+ <div id="niftyOutter">
+ <table width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr>
+ <td width="50%" class="listhdrr">File Name (download)</td>
+ <td width="10%" class="listhdrr">Download</td>
+ <td width="10%" class="listhdrr">View</td>
+ <td width="20%" class="listhdr">Last Modified</td>
+ <td width="10%" class="listhdr" nowrap>Size</td>
+ </tr>
+
+ <?php
+
+ if ($handle = opendir($dir_fax_inbox)) {
+ while (false !== ($file = readdir($handle))) {
+ if ($file != "." && $file != ".." && is_file($dir_fax_inbox.$file)) {
+
+ $tmp_filesize = filesize($dir_fax_inbox.$file);
+ $tmp_filesize = byte_convert($tmp_filesize);
+
+ $tmp_file_array = split("\.",$file);
+ $file_name = $tmp_file_array[0];
+ $file_ext = $tmp_file_array[1];
+
+ if ($file_ext == "tif") {
+
+ echo "<tr>\n";
+ echo " <td class=\"listlr\" ondblclick=\"\">\n";
+ echo " <a href=\"freeswitch_fax_edit.php?id=".$id."&a=download&type=fax_inbox&t=bin&filename=".$file."\">\n";
+ echo " $file";
+ echo " </a>";
+ echo " </td>\n";
+ echo " <td class=\"listlr\" ondblclick=\"\">\n";
+ echo " <a href=\"freeswitch_fax_edit.php?id=".$id."&a=download&type=fax_inbox&t=bin&filename=".$file_name.".pdf\">\n";
+ echo " pdf";
+ echo " </a>";
+ echo " </td>\n";
+ echo " <td class=\"listlr\" ondblclick=\"\">\n";
+ echo " <a href=\"freeswitch_fax_edit.php?id=".$id."&a=download&type=fax_inbox&t=png&filename=".$file_name.".png\" target=\"_blank\">\n";
+ echo " png";
+ echo " </a>";
+ echo " </td>\n";
+ echo " <td class=\"listlr\" ondblclick=\"\">\n";
+ echo date ("F d Y H:i:s", filemtime($dir_fax_inbox.$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_fax_edit.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_fax_edit.php?id=".$id."&type=fax_inbox&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 />
+
+ <table width="100%" border="0" cellpadding="5" cellspacing="0">
+ <tr>
+ <td>
+ <span class="vexpl"><span class="red"><strong>Sent</strong></span>
+ </td>
+ <td align='right'>
+ <b>location:</b> <?php echo $dir_fax_sent; ?>
+ </td>
+ </tr>
+ </table>
+
+ <table width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr>
+ <td width="50%" class="listhdrr">File Name (download)</td>
+ <td width="10%" class="listhdrr">Download</td>
+ <td width="10%" class="listhdrr">View</td>
+ <td width="20%" class="listhdr">Last Modified</td>
+ <td width="10%" class="listhdr" nowrap>Size</td>
+ </tr>
+
+ <?php
+
+ if ($handle = opendir($dir_fax_sent)) {
+ while (false !== ($file = readdir($handle))) {
+ if ($file != "." && $file != ".." && is_file($dir_fax_sent.$file)) {
+
+ $tmp_filesize = filesize($dir_fax_sent.$file);
+ $tmp_filesize = byte_convert($tmp_filesize);
+
+ $tmp_file_array = split("\.",$file);
+ $file_name = $tmp_file_array[0];
+ $file_ext = $tmp_file_array[1];
+
+ if ($file_ext == "tif") {
+
+ echo "<tr>\n";
+ echo " <td class=\"listlr\" ondblclick=\"\">\n";
+ echo " <a href=\"freeswitch_fax_edit.php?id=".$id."&a=download&type=fax_sent&t=bin&filename=".$file."\">\n";
+ echo " $file";
+ echo " </a>";
+ echo " </td>\n";
+ echo " <td class=\"listlr\" ondblclick=\"\">\n";
+ echo " <a href=\"freeswitch_fax_edit.php?id=".$id."&a=download&type=fax_sent&t=bin&filename=".$file_name.".pdf\">\n";
+ echo " pdf";
+ echo " </a>";
+ echo " </td>\n";
+ echo " <td class=\"listlr\" ondblclick=\"\">\n";
+ echo " <a href=\"freeswitch_fax_edit.php?id=".$id."&a=download&type=fax_sent&t=png&filename=".$file_name.".png\" target=\"_blank\">\n";
+ echo " png";
+ echo " </a>";
+ echo " </td>\n";
+ echo " <td class=\"listlr\" ondblclick=\"\">\n";
+ echo date ("F d Y H:i:s", filemtime($dir_fax_sent.$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_fax_edit.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_fax_edit.php?id=".$id."&type=fax_sent&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 />
+
+
+ </td>
+ </tr>
+</table>
+
+</div>
+
+<?php include("fend.inc"); ?>
+</body>
+</html>
diff --git a/config/freeswitch/freeswitch_features.tmp b/config/freeswitch/freeswitch_features.tmp
index d97ebe9e..1a2ed969 100644
--- a/config/freeswitch/freeswitch_features.tmp
+++ b/config/freeswitch/freeswitch_features.tmp
@@ -119,6 +119,21 @@ display_top_tabs(build_menu());
<br />
<br />
+
+ <table width="100%" border="0" cellpadding="6" cellspacing="0">
+ <tr>
+ <td class="listtopic" colspan='2'>FAX</td>
+ </tr>
+ <tr>
+ <td width='10%' class="vncell"><a href='freeswitch_fax.php'>Open</a></td>
+ <td class="vtable">
+ Transmit and View Received Faxes.
+ </td>
+ </tr>
+ </table>
+
+ <br />
+ <br />
<table width="100%" border="0" cellpadding="6" cellspacing="0">
<tr>
diff --git a/config/freeswitch/freeswitch_hunt_group.tmp b/config/freeswitch/freeswitch_hunt_group.tmp
index 10a20eb8..5448396a 100644
--- a/config/freeswitch/freeswitch_hunt_group.tmp
+++ b/config/freeswitch/freeswitch_hunt_group.tmp
@@ -38,9 +38,11 @@ $a_hunt_group = &$config['installedpackages']['freeswitchhuntgroup']['config'];
if ($_GET['act'] == "del") {
- if ($_GET['type'] == 'hunt_group') {
+ if ($_GET['type'] == 'huntgroup') {
if ($a_hunt_group[$_GET['id']]) {
- unlink("/usr/local/freeswitch/scripts/hunt_group_".$_GET['huntgroupid'].".js");
+ if file_exists("/usr/local/freeswitch/scripts/huntgroup_".$_GET['huntgroupid'].".js")) {
+ unlink("/usr/local/freeswitch/scripts/huntgroup_".$_GET['huntgroupid'].".js");
+ }
unset($a_hunt_group[$_GET['id']]);
write_config();
sync_package_freeswitch_hunt_group();