From 2805239ac2dca632d02d32445a1c2b48e288f39a Mon Sep 17 00:00:00 2001 From: mcrane Date: Wed, 10 Jun 2009 04:53:10 -0600 Subject: FreeSWITCH package add new feature beta feature fax. --- config/freeswitch/fax_to_email.tmp | 178 +++++++ config/freeswitch/freeswitch.inc | 238 ++++++++- config/freeswitch/freeswitch_fax.tmp | 305 ++++++++++++ config/freeswitch/freeswitch_fax_edit.tmp | 723 ++++++++++++++++++++++++++++ config/freeswitch/freeswitch_features.tmp | 15 + config/freeswitch/freeswitch_hunt_group.tmp | 6 +- 6 files changed, 1448 insertions(+), 17 deletions(-) create mode 100644 config/freeswitch/fax_to_email.tmp create mode 100644 config/freeswitch/freeswitch_fax.tmp create mode 100644 config/freeswitch/freeswitch_fax_edit.tmp (limited to 'config') 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 @@ +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."
\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); + + // + // + $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); + + // + $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); + + // + $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); + + // + $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); + + // + $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); + + // + $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); + + // + $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 @@ + 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"); + +?> + + + + +

FreeSWITCH: FAX

+ +
+ + +
+ +
+ + + + + +
+ +
+"; +//print_info_box_np("The FreeSWITCH fax have been changed.
You must apply the changes in order for them to take effect."); +//echo"
"; +//endif; + +?> + + + + +

FAX
+
+ 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 tone detection on the Public tab. +

+
+ + + + + + + + + + + + + 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) { + ?> + + + + + + + + + + + + + + + + + + + + +
ExtensionNameEmailDomainDescription + + + + + + +
+ +
+   + +   + +   + +   + +   + + + + + + +
+
+ + + + + +
+
+ +
+ + +
+
+
+
+ + +
+ +
+ + + + + \ 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 @@ + 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"); + +?> + + + + + +

FreeSWITCH: FAX: Edit

+ + + +
+ + +
+ +
+ + + + +
+ + + + + + +

FAX Setup
+
+

+
+ +
+ + + + + + + + + + + + + + + + + + + +
Extension + +
Enter the fax extension here.
+
Name + +
Enter the name here.
+
Email + +
Optional: Enter the email address to send the FAX to.
+
Domain + +
Enter the domain here.
+
+ + + + + + + + +
Description + +
Enter the description here.
+
  + + + + + +
+
+ +
+
+
+
+ + + + + + + + + + + + +
+ Send +
+ 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. +
+
+ + + + + + + + + + +
+ Fax Number + + + Upload: + + + + + Gateway + + + 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 "\n"; + + ?> + + +
+ +
+
+ + + +
+
+
+
+ + + + + + +
+ Inbox + + location: +
+ +
+ + + + + + + + + + \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "\n"; + } + + } + } + closedir($handle); + } + ?> + + + + + +
File Name (download)DownloadViewLast ModifiedSize
\n"; + echo " \n"; + echo " $file"; + echo " "; + echo " \n"; + echo " \n"; + echo " pdf"; + echo " "; + echo " \n"; + echo " \n"; + echo " png"; + echo " "; + echo " \n"; + echo date ("F d Y H:i:s", filemtime($dir_fax_inbox.$file)); + echo " \n"; + echo " ".$tmp_filesize; + echo " \n"; + echo " \n"; + echo " \n"; + //echo " \n"; + echo " \n"; + echo " \n"; + echo "
\n"; + echo "
+ +
+
+
+
+ + + + + + +
+ Sent + + location: +
+ + + + + + + + + + + \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "\n"; + } + + } + } + closedir($handle); + } + ?> + + + + + +
File Name (download)DownloadViewLast ModifiedSize
\n"; + echo " \n"; + echo " $file"; + echo " "; + echo " \n"; + echo " \n"; + echo " pdf"; + echo " "; + echo " \n"; + echo " \n"; + echo " png"; + echo " "; + echo " \n"; + echo date ("F d Y H:i:s", filemtime($dir_fax_sent.$file)); + echo " \n"; + echo " ".$tmp_filesize; + echo " \n"; + echo " \n"; + echo " \n"; + //echo " \n"; + echo " \n"; + echo " \n"; + echo "
\n"; + echo "
+ + +
+
+
+
+ + +
+ +
+ + + + 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());

+ + + + + + + + + +
FAX
Open + Transmit and View Received Faxes. +
+ +
+
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(); -- cgit v1.2.3