Send final tif and pdf to the sent box

Prevents having to save them to temp and then to sent box.
This commit is contained in:
FusionPBX
2022-04-23 19:37:49 -06:00
committed by GitHub
parent 742a648cb0
commit 37a0718d44
+26 -24
View File
@@ -572,24 +572,25 @@ if (!function_exists('fax_split_dtmf')) {
foreach ($tif_files as $tif_file) { foreach ($tif_files as $tif_file) {
$cmd .= correct_path($tif_file) . ' '; $cmd .= correct_path($tif_file) . ' ';
} }
$cmd .= correct_path($dir_fax_temp.'/'.$fax_instance_uuid.'.tif'); $cmd .= correct_path($dir_fax_sent.'/'.$fax_instance_uuid.'.tif');
//echo($cmd . "<br/>\n"); //echo($cmd . "<br/>\n");
exec($cmd); exec($cmd);
foreach ($tif_files as $tif_file) {
@unlink($tif_file);
}
//generate pdf from tif //generate pdf from tif
$cmd = exec('which tiff2pdf').' -u i -p '.$fax_page_size. $cmd = exec('which tiff2pdf').' -u i -p '.$fax_page_size.
' -w '.$page_width. ' -w '.$page_width.
' -l '.$page_height. ' -l '.$page_height.
' -f -o '. ' -f -o '.
correct_path($dir_fax_temp.'/'.$fax_instance_uuid.'.pdf').' '. correct_path($dir_fax_sent.'/'.$fax_instance_uuid.'.pdf').' '.
correct_path($dir_fax_temp.'/'.$fax_instance_uuid.'.tif'); correct_path($dir_fax_sent.'/'.$fax_instance_uuid.'.tif');
exec($cmd); exec($cmd);
//echo $cmd."<br />\n"; //echo $cmd."<br />\n";
//remove the extra files
foreach ($tif_files as $tif_file) {
@unlink($tif_file);
}
} }
elseif (!$included) { elseif (!$included) {
//nothing to send, redirect the browser //nothing to send, redirect the browser
@@ -601,19 +602,21 @@ if (!function_exists('fax_split_dtmf')) {
//preview, if requested //preview, if requested
if (($_REQUEST['submit'] != '') && ($_REQUEST['submit'] == 'preview')) { if (($_REQUEST['submit'] != '') && ($_REQUEST['submit'] == 'preview')) {
unset($file_type); unset($file_type);
if (file_exists($dir_fax_temp.'/'.$fax_instance_uuid.'.pdf')) { if (file_exists($dir_fax_sent.'/'.$fax_instance_uuid.'.pdf')) {
$file_path = $dir_fax_sent.'/'.$fax_instance_uuid.".pdf";
$file_type = 'pdf'; $file_type = 'pdf';
$content_type = 'application/pdf'; $content_type = 'application/pdf';
@unlink($dir_fax_temp.'/'.$fax_instance_uuid.".tif"); @unlink($dir_fax_sent.'/'.$fax_instance_uuid.".tif");
} }
else if (file_exists($dir_fax_temp.'/'.$fax_instance_uuid.'.tif')) { else if (file_exists($dir_fax_sent.'/'.$fax_instance_uuid.'.tif')) {
$file_path = $dir_fax_sent.'/'.$fax_instance_uuid.".tif";
$file_type = 'tif'; $file_type = 'tif';
$content_type = 'image/tiff'; $content_type = 'image/tiff';
@unlink($dir_fax_temp.'/'.$fax_instance_uuid.".pdf"); @unlink($dir_fax_sent.'/'.$fax_instance_uuid.".pdf");
} }
if ($file_type != '') { if ($file_type != '') {
//push download //push download
$fd = fopen($dir_fax_temp.'/'.$fax_instance_uuid.'.'.$file_type, "rb"); $fd = fopen($file_path, "rb");
header("Content-Type: application/force-download"); header("Content-Type: application/force-download");
header("Content-Type: application/octet-stream"); header("Content-Type: application/octet-stream");
header("Content-Type: application/download"); header("Content-Type: application/download");
@@ -623,9 +626,9 @@ if (!function_exists('fax_split_dtmf')) {
header('Accept-Ranges: bytes'); header('Accept-Ranges: bytes');
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 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("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // date in the past
header("Content-Length: ".filesize($dir_fax_temp.'/'.$fax_instance_uuid.'.'.$file_type)); header("Content-Length: ".filesize($file_path));
fpassthru($fd); fpassthru($fd);
@unlink($dir_fax_temp.'/'.$fax_instance_uuid.".".$file_type); @unlink($file_path);
} }
exit; exit;
} }
@@ -659,11 +662,19 @@ if (!function_exists('fax_split_dtmf')) {
$mail_to_address = $mail_to_address_user; $mail_to_address = $mail_to_address_user;
} }
//move the generated tif (and pdf) files to the sent directory
//if (file_exists($dir_fax_temp.'/'.$fax_instance_uuid.".tif")) {
// copy($dir_fax_temp.'/'.$fax_instance_uuid.".tif", $dir_fax_sent.'/'.$fax_instance_uuid.".tif");
//}
//if (file_exists($dir_fax_temp.'/'.$fax_instance_uuid.".pdf")) {
// copy($dir_fax_temp.'/'.$fax_instance_uuid.".pdf ", $dir_fax_sent.'/'.$fax_instance_uuid.".pdf");
//}
//set the fax //set the fax
$fax_queue_uuid = uuid(); $fax_queue_uuid = uuid();
//send the fax //send the fax
$fax_file = $dir_fax_temp."/".$fax_instance_uuid.".tif"; $fax_file = $dir_fax_sent."/".$fax_instance_uuid.".tif";
$common_variables .= "fax_queue_uuid='" . $fax_queue_uuid . "',"; $common_variables .= "fax_queue_uuid='" . $fax_queue_uuid . "',";
$common_variables = "for_fax=1,"; $common_variables = "for_fax=1,";
$common_variables .= "accountcode='" . $fax_accountcode . "',"; $common_variables .= "accountcode='" . $fax_accountcode . "',";
@@ -771,15 +782,6 @@ if (!function_exists('fax_split_dtmf')) {
} }
} }
//move the generated tif (and pdf) files to the sent directory
if (file_exists($dir_fax_temp.'/'.$fax_instance_uuid.".tif")) {
copy($dir_fax_temp.'/'.$fax_instance_uuid.".tif", $dir_fax_sent.'/'.$fax_instance_uuid.".tif");
}
if (file_exists($dir_fax_temp.'/'.$fax_instance_uuid.".pdf")) {
copy($dir_fax_temp.'/'.$fax_instance_uuid.".pdf ", $dir_fax_sent.'/'.$fax_instance_uuid.".pdf");
}
//redirect the browser //redirect the browser
if (!$included && is_uuid($fax_uuid)) { if (!$included && is_uuid($fax_uuid)) {
if ($_SESSION['fax_queue']['enabled']['boolean']) { if ($_SESSION['fax_queue']['enabled']['boolean']) {