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($v_conf_dir."/dialplan/default/".$order."_".$faxname.".xml")){ unlink($v_conf_dir."/dialplan/default/".$order."_".$faxname.".xml"); } //remove fax entries unset($a_fax[$_GET['id']]); write_config(); header("Location: v_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: v_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: v_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: v_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($v_storage_dir)) { exec("mkdir ".$v_storage_dir); } if (!is_dir($v_storage_dir.'/fax/')) { exec("mkdir ".$v_storage_dir."/fax/"); } $faxfolder = $v_storage_dir.'/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_v_fax(); header("Location: v_fax.php"); exit; } } include("head.inc"); ?> $v_label: FAX: Edit

\n"; } if ($input_errors) print_input_errors($input_errors); ?>

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) Download View Last Modified Size
\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) Download View Last Modified Size
\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 "