diff --git a/app/fax/app_defaults.php b/app/fax/app_defaults.php index f85339b81a..9dc7b5865e 100644 --- a/app/fax/app_defaults.php +++ b/app/fax/app_defaults.php @@ -19,16 +19,16 @@ if ($domains_processed == 1) { $array[$x]['default_setting_description'] = 'Notice displayed in the footer of the cover sheet.'; $x++; $array[$x]['default_setting_category'] = 'fax'; - $array[$x]['default_setting_subcategory'] = 'cover_contact_info'; + $array[$x]['default_setting_subcategory'] = 'cover_header'; $array[$x]['default_setting_name'] = 'text'; $array[$x]['default_setting_value'] = ''; $array[$x]['default_setting_enabled'] = 'false'; - $array[$x]['default_setting_description'] = 'Default contact information to appear beneath the logo in the header of the cover page.'; + $array[$x]['default_setting_description'] = 'Default information displayed beneath the logo in the header of the cover sheet.'; $x++; $array[$x]['default_setting_category'] = 'fax'; $array[$x]['default_setting_subcategory'] = 'page_size'; $array[$x]['default_setting_name'] = 'text'; - $array[$x]['default_setting_value'] = 'auto'; + $array[$x]['default_setting_value'] = 'letter'; $array[$x]['default_setting_enabled'] = 'true'; $array[$x]['default_setting_description'] = 'Set the default page size of new faxes.'; $x++; diff --git a/app/fax/app_languages.php b/app/fax/app_languages.php index 1f29e5c33f..c84e23f4d1 100644 --- a/app/fax/app_languages.php +++ b/app/fax/app_languages.php @@ -258,45 +258,45 @@ $text['label-file']['pt-pt'] = "Ficheiro não encontrado."; $text['label-file']['fr-fr'] = "Fichier non trové"; - $text['description-2']['en-us'] = "To send a fax, upload a PDF or TIF (requires LibreOffice) file."; - $text['description-2']['es-cl'] = "Para enviar un fax puede subir un archivo .tif o si ghost script está instalado entonces también puede enviar un fax subiendo un archivo PDF."; - $text['description-2']['pt-pt'] = "Para enviar um fax pode carregar um ficheiro .tif ou, se o ghost script tiver sido instalado, enviar um fax, carregando um ficheiro .pdf."; - $text['description-2']['fr-fr'] = "Pour envoyer un fax, vous pouvez télécharger un fichier TIF. Si ghost script a été installé, vous pouvez également utiliser un fichier PDF."; + $text['description-2']['en-us'] = "To send a fax, upload a PDF or TIF file. To generate a cover sheet, enter a Subject and/or Message below."; + $text['description-2']['es-cl'] = "Para enviar un fax, cargar un archivo PDF o TIF. Para generar una hoja de presentación, escriba un asunto y / o mensaje a continuación."; + $text['description-2']['pt-pt'] = "Pour envoyer un fax, télécharger un fichier PDF ou TIF. Para gerar uma folha de rosto, digite um assunto e / ou mensagem abaixo."; + $text['description-2']['fr-fr'] = "Pour envoyer un fax, télécharger un fichier PDF ou TIF. Pour générer une feuille de couverture, entrer un sujet et / ou un message ci-dessous."; - $text['description-3']['en-us'] = "View status of the fax transmission by viewing the logs from the Status tab or by watching the response from the console."; - $text['description-3']['es-cl'] = "Cuando envie un fax puede ver el estado de la transmision revisando los logs desde la pestaña Estado o viendo la respuesta desde la consola."; - $text['description-3']['pt-pt'] = "Ao enviar um fax pode ver o estado da transmissão, visualizando os logs da tab Estado ou visualizando a resposta através da consola."; - $text['description-3']['fr-fr'] = ""; + $text['description-3']['en-us'] = "Install LibreOffice for additional file format support (DOC, DOCX, XLS, XLSX, ODT, OTT, RTF, etc). View the status of a fax transmission on the Active Calls page, in the Log Viewer, or by watching the results in the switch console."; + $text['description-3']['es-cl'] = "Instalar LibreOffice de apoyo adicional de formato de archivo (DOC, DOCX, XLS, XLSX, ODT, OTT, RTF, ...). Ver el estado de una transmisión de fax en la página de llamadas activas, el Visor de registro, o por ver los resultados en la consola del switch."; + $text['description-3']['pt-pt'] = "Instalar LibreOffice para suporte adicional formato de arquivo (DOC, DOCX, XLS, XLSX, ODT, OTT, RTF, ...). Exibir o status de uma transmissão de fax na página de chamadas ativas, o Log Viewer, ou assistindo os resultados no console switch."; + $text['description-3']['fr-fr'] = "Installer LibreOffice pour un soutien supplémentaire de format de fichier (DOC, DOCX, XLS, XLSX, ODT, OTT, RTF, ...). Afficher l'état d'une transmission de télécopie sur la page Appels actifs, le Log Viewer, ou en regardant les résultats dans la console du commutateur."; $text['label-fax-sender']['en-us'] = "From"; $text['label-fax-sender']['es-cl'] = "Remitente"; $text['label-fax-sender']['pt-pt'] = "Sender"; $text['label-fax-sender']['fr-fr'] = "Expéditeur"; - $text['description-fax-sender']['en-us'] = "Enter the sender's name for the cover page (optional)."; - $text['description-fax-sender']['es-cl'] = "Introduzca el nombre del remitente (opcional)."; - $text['description-fax-sender']['pt-pt'] = "Digite o nome do remetente (opcional)."; - $text['description-fax-sender']['fr-fr'] = "Entrez le nom de l'expéditeur (facultatif)."; + $text['description-fax-sender']['en-us'] = "Enter the sender's name for the cover sheet (optional)."; + $text['description-fax-sender']['es-cl'] = "Introduzca el nombre del remitente para la portada (opcional)."; + $text['description-fax-sender']['pt-pt'] = "Digite o nome do remetente para a folha de rosto (opcional)."; + $text['description-fax-sender']['fr-fr'] = "Entrez le nom de l'expéditeur pour la feuille de couverture (en option)."; - $text['label-fax-contact-info']['en-us'] = "Contact Info"; - $text['label-fax-contact-info']['es-cl'] = "Información de Contacto"; - $text['label-fax-contact-info']['pt-pt'] = "Informações de Contato"; - $text['label-fax-contact-info']['fr-fr'] = "Contacter"; + $text['label-fax-header']['en-us'] = "Header"; + $text['label-fax-header']['es-cl'] = "Header"; + $text['label-fax-header']['pt-pt'] = "Cabeçalho"; + $text['label-fax-header']['fr-fr'] = "Tête"; - $text['description-fax-contact-info']['en-us'] = "Contact information to appear beneath the logo on the cover page (optional)."; - $text['description-fax-contact-info']['es-cl'] = "La información de contacto para aparecer debajo del logotipo en la portada (opcional)."; - $text['description-fax-contact-info']['pt-pt'] = "Informações de contato para aparecer abaixo do logotipo na página de rosto (opcional)."; - $text['description-fax-contact-info']['fr-fr'] = "Contactez-indications à faire figurer sous le logo sur la page de couverture (en option)."; + $text['description-fax-header']['en-us'] = "Displayed beneath the logo in the header of the cover sheet (optional)."; + $text['description-fax-header']['es-cl'] = "Aparece debajo del logotipo en la cabecera de la portada (opcional)."; + $text['description-fax-header']['pt-pt'] = "Exibido abaixo do logotipo no cabeçalho da folha de rosto (opcional)."; + $text['description-fax-header']['fr-fr'] = "Affiché sous le logo dans l'en-tête de la feuille de couverture (en option)."; $text['label-fax-recipient']['en-us'] = "To"; $text['label-fax-recipient']['es-cl'] = "Destinatario"; $text['label-fax-recipient']['pt-pt'] = "Destinatário"; $text['label-fax-recipient']['fr-fr'] = "Destinataire"; - $text['description-fax-recipient']['en-us'] = "Enter the recipient's name for the cover page (optional)."; - $text['description-fax-recipient']['es-cl'] = "Introduzca el nombre del destinatario (opcional)."; - $text['description-fax-recipient']['pt-pt'] = "Digite o nome do destinatário (opcional)."; - $text['description-fax-recipient']['fr-fr'] = "Entrez le nom du destinataire (facultatif)."; + $text['description-fax-recipient']['en-us'] = "Enter the recipient's name for the cover sheet (optional)."; + $text['description-fax-recipient']['es-cl'] = "Introduzca el nombre del destinatario de la portada (opcional)."; + $text['description-fax-recipient']['pt-pt'] = "Digite o nome do destinatário para a folha de rosto (opcional)."; + $text['description-fax-recipient']['fr-fr'] = "Entrez le nom du destinataire de la feuille de couverture (en option)."; $text['label-fax-number']['en-us'] = "Fax Number"; $text['label-fax-number']['es-cl'] = "Número de Fax"; @@ -313,30 +313,30 @@ $text['label-fax-subject']['pt-pt'] = "Assunto"; $text['label-fax-subject']['fr-fr'] = "Sujet"; - $text['description-fax-subject']['en-us'] = "Enter a subject for the cover page (optional)."; + $text['description-fax-subject']['en-us'] = "Enter a subject for the cover sheet (optional)."; $text['description-fax-subject']['es-cl'] = "Escriba un asunto para la portada (opcional)."; - $text['description-fax-subject']['pt-pt'] = "Introduza um assunto para a capa (opcional)."; - $text['description-fax-subject']['fr-fr'] = "Entrez un sujet pour la page de couverture (en option)."; + $text['description-fax-subject']['pt-pt'] = "Insira um assunto para a folha de rosto (opcional)."; + $text['description-fax-subject']['fr-fr'] = "Entrez l'objet de la feuille de couverture (en option)."; $text['label-fax-message']['en-us'] = "Message"; $text['label-fax-message']['es-cl'] = "Mensaje"; $text['label-fax-message']['pt-pt'] = "Mensagem"; $text['label-fax-message']['fr-fr'] = "Message"; - $text['description-fax-message']['en-us'] = "Enter a message for the cover page (optional)."; + $text['description-fax-message']['en-us'] = "Enter a message for the cover sheet (optional)."; $text['description-fax-message']['es-cl'] = "Escriba un mensaje para la portada (opcional)."; - $text['description-fax-message']['pt-pt'] = "Digite uma mensagem para a página de rosto (opcional)."; - $text['description-fax-message']['fr-fr'] = "Entrez un message pour la page de couverture (en option)."; + $text['description-fax-message']['pt-pt'] = "Digite uma mensagem para a folha de rosto (opcional)."; + $text['description-fax-message']['fr-fr'] = "Entrez un message pour la feuille de couverture (en option)."; $text['label-fax-footer']['en-us'] = "Footer"; $text['label-fax-footer']['es-cl'] = "Pie de Página"; $text['label-fax-footer']['pt-pt'] = "Rodapé"; $text['label-fax-footer']['fr-fr'] = "Footer"; - $text['description-fax-confidentiality']['en-us'] = "Displayed in the footer of the cover sheet (optional)."; - $text['description-fax-confidentiality']['es-cl'] = "Se muestra en el pie de página de la portada (opcional)."; - $text['description-fax-confidentiality']['pt-pt'] = "Exibido no rodapé da folha de rosto (opcional)."; - $text['description-fax-confidentiality']['fr-fr'] = "Affiché dans le bas de la feuille de couverture (en option)."; + $text['description-fax-footer']['en-us'] = "Displayed in the footer of the cover sheet (optional)."; + $text['description-fax-footer']['es-cl'] = "Se muestra en el pie de página de la portada (opcional)."; + $text['description-fax-footer']['pt-pt'] = "Exibido no rodapé da folha de rosto (opcional)."; + $text['description-fax-footer']['fr-fr'] = "Affiché dans le bas de la feuille de couverture (en option)."; $text['label-fax-resolution']['en-us'] = "Resolution"; $text['label-fax-resolution']['es-cl'] = "Resolución"; @@ -373,11 +373,6 @@ $text['description-fax-page-size']['pt-pt'] = "Selecione o tamanho da página para transmitir."; $text['description-fax-page-size']['fr-fr'] = "Sélectionnez le format de page pour nous transmettre."; - $text['option-fax-page-size-auto']['en-us'] = "Auto"; - $text['option-fax-page-size-auto']['es-cl'] = "Automático"; - $text['option-fax-page-size-auto']['pt-pt'] = "Automático"; - $text['option-fax-page-size-auto']['fr-fr'] = "Automatique"; - $text['label-fax-fax']['en-us'] = "FAX"; $text['label-fax-fax']['es-cl'] = "Facsímil"; $text['label-fax-fax']['pt-pt'] = "Fax"; diff --git a/app/fax/fax_send.php b/app/fax/fax_send.php index 4d43d84635..233e5b6780 100644 --- a/app/fax/fax_send.php +++ b/app/fax/fax_send.php @@ -173,8 +173,8 @@ else { $fax_forward_number = preg_replace("~[^0-9]~", "",$fax_forward_number); } + $fax_header = check_str($_POST['fax_header']); $fax_sender = check_str($_POST['fax_sender']); - $fax_contact_info = check_str($_POST['fax_contact_info']); $fax_recipient = check_str($_POST['fax_recipient']); $fax_subject = check_str($_POST['fax_subject']); $fax_message = check_str($_POST['fax_message']); @@ -182,6 +182,35 @@ else { $fax_page_size = check_str($_POST['fax_page_size']); $fax_footer = check_str($_POST['fax_footer']); + //determine page size + switch ($fax_page_size) { + case 'a4' : + $page_width = 8.3; //in + $page_height = 11.7; //in + break; + case 'legal' : + $page_width = 8.5; //in + $page_height = 14; //in + break; + case 'letter' : + default : + $page_width = 8.5; //in + $page_height = 11; //in + } + + //set resolution + switch ($fax_resolution) { + case 'normal': + $gs_r = '204x98'; $gs_g = ((int) ($page_width * 204)).'x'.((int) ($page_height * 98)); + break; + case 'fine': + $gs_r = '204x196'; $gs_g = ((int) ($page_width * 204)).'x'.((int) ($page_height * 196)); + break; + case 'superfine': + $gs_r = '408x391'; $gs_g = ((int) ($page_width * 408)).'x'.((int) ($page_height * 391)); + break; + } + // process uploaded files, if any foreach ($_FILES['fax_files']['tmp_name'] as $index => $fax_tmp_name) { if ( @@ -192,10 +221,28 @@ else { //get the file extension $fax_file_extension = strtolower(pathinfo($_FILES['fax_files']['name'][$index], PATHINFO_EXTENSION)); - if ($fax_file_extension == "tiff" || $fax_file_extension == "tif") { $fax_file_extension = "tif"; } + if ($fax_file_extension == "tiff") { $fax_file_extension = "tif"; } - //skip files other than pdf and tif (for now) - if ($fax_file_extension != 'pdf' && $fax_file_extension != 'tif') { continue; } + //block unauthorized files + if ( + $fax_file_extension == 'sh' || + $fax_file_extension == 'ssh' || + $fax_file_extension == 'so' || + $fax_file_extension == 'dll' || + $fax_file_extension == 'exe' || + $fax_file_extension == 'bat' || + $fax_file_extension == 'vbs' || + $fax_file_extension == 'zip' || + $fax_file_extension == 'rar' || + $fax_file_extension == 'z' || + $fax_file_extension == 'tar' || + $fax_file_extension == 'tbz' || + $fax_file_extension == 'tgz' || + $fax_file_extension == 'gz' || + $fax_file_extension == '' + ) { + continue; + } $fax_name = $_FILES['fax_files']['name'][$index]; $fax_name = preg_replace('/\\.[^.\\s]{3,4}$/', '', $fax_name); @@ -223,80 +270,41 @@ else { move_uploaded_file($_FILES['fax_files']['tmp_name'][$index], $dir_fax_temp.'/'.$fax_name.'.'.$fax_file_extension); //convert uploaded file to pdf, if necessary - if ($fax_file_extension != "pdf") { + if ($fax_file_extension != "pdf" && $fax_file_extension != "tif") { chdir($dir_fax_temp); - exec("export HOME=/tmp && libreoffice --headless --convert-to pdf --outdir ".$dir_fax_temp." ".$dir_fax_temp.'/'.$fax_name.'.'.$fax_file_extension); + exec("libreoffice --headless --convert-to pdf --outdir ".$dir_fax_temp." ".$dir_fax_temp.'/'.$fax_name.'.'.$fax_file_extension); + @unlink($dir_fax_temp.'/'.$fax_name.'.'.$fax_file_extension); } - //add file to arrays - $uploaded_file_names[] = $fax_name.'.'.$fax_file_extension; - $pdf_files[] = $dir_fax_temp.'/'.$fax_name.'.pdf'; + //convert uploaded pdf to tif + if (file_exists($dir_fax_temp.'/'.$fax_name.'.pdf')) { + chdir($dir_fax_temp); + exec("gs -q -sDEVICE=tiffg3 -r".$gs_r." -g".$gs_g." -dNOPAUSE -sOutputFile=".$fax_name.".tif -- ".$fax_name.".pdf -c quit"); //convert pdf to tif + @unlink($dir_fax_temp.'/'.$fax_name.'.pdf'); + } + //add file to array + $tif_files[] = $dir_fax_temp.'/'.$fax_name.'.tif'; } //if } //foreach - //load pdf libraries - require_once("resources/tcpdf/tcpdf.php"); - require_once("resources/fpdi/fpdi.php"); - - $pdf = new FPDI('P', 'in'); - $pdf -> SetAutoPageBreak(false); - $pdf -> setPrintHeader(false); - $pdf -> setPrintFooter(false); - $pdf -> SetMargins(0, 0, 0, true); - - //Get the bad PDF into a good (sort of) PDF, but don't have a dynamic method to obtain the correct page size first, so is a guess. - // chdir($dir_fax_temp); - // exec("gs -q -sDEVICE=tiffg3 -r204x196 -g1687x2291 -dNOPAUSE -sOutputFile=".$fax_name."_converted.tif -- ".$fax_name.".pdf -c quit"); - // exec("mv ".$dir_fax_temp.'/'.$fax_name.".pdf ".$dir_fax_temp.'/'.$fax_name."_uploaded.pdf"); - // exec("libreoffice --headless --convert-to pdf --outdir ".$dir_fax_temp." ".$dir_fax_temp.'/'.$fax_name.'_converted.tif'); - // echo "Done"; - // exit; - - $page_count = 0; - if (is_array($pdf_files) && sizeof($pdf_files) > 0) { - //determine total pages - foreach ($pdf_files as $pdf_file) { - $page_count += $pdf -> setSourceFile($pdf_file); - } - } - - //determine page size - switch ($fax_page_size) { - case 'auto' : - if ($page_count > 0) { - // retrieve from uploaded file - $pdf -> setSourceFile($pdf_files[0]); - $tmpl = $pdf -> ImportPage(1); - $page_size = $pdf -> getTemplateSize($tmpl); - $page_width = round($page_size['w'], 2, PHP_ROUND_HALF_DOWN); - $page_height = round($page_size['h'], 2, PHP_ROUND_HALF_DOWN); - } - else { - $page_width = 8.5; //in - $page_height = 11; //in - } - break; - case 'a4' : - $page_width = 8.3; //in - $page_height = 11.7; //in - break; - case 'legal' : - $page_width = 8.5; //in - $page_height = 14; //in - break; - case 'letter' : - default : - $page_width = 8.5; //in - $page_height = 11; //in - } - // unique id for this fax $fax_instance_uuid = uuid(); //generate cover page, merge with pdf if ($fax_subject != '' || $fax_message != '') { + //load pdf libraries + require_once("resources/tcpdf/tcpdf.php"); + require_once("resources/fpdi/fpdi.php"); + + // initialize pdf + $pdf = new FPDI('P', 'in'); + $pdf -> SetAutoPageBreak(false); + $pdf -> setPrintHeader(false); + $pdf -> setPrintFooter(false); + $pdf -> SetMargins(0, 0, 0, true); + //add blank page $pdf -> AddPage('P', array($page_width, $page_height)); @@ -343,15 +351,15 @@ else { $pdf -> Image($logo, 0.5, 0.4, 2.5, 0.9, null, null, 'N', true, 300, null, false, false, 0, true); } else { - //set position for contact info, if enabled + //set position for header text, if enabled $pdf -> SetXY($x + 0.5, $y + 0.4); } - //contact info - if (isset($_SESSION['fax']['cover_contact_info']['text'])) { + //header + if (isset($_SESSION['fax']['cover_header']['text'])) { $pdf -> SetLeftMargin(0.5); $pdf -> SetFont("times", "", 10); - $pdf -> Write(0.3, $fax_contact_info); + $pdf -> Write(0.3, $fax_header); } //fax, cover sheet @@ -428,42 +436,41 @@ else { $pdf -> MultiCell(7.5, 0.75, $fax_footer, 0, 'C', false); } - // save cover pdf file and add to array of pages - if (is_array($pdf_files) && sizeof($pdf_files) > 0) { - array_unshift($pdf_files, $dir_fax_temp.'/'.$fax_instance_uuid.'_cover.pdf'); - } - else { - $pdf_files[] = $dir_fax_temp.'/'.$fax_instance_uuid.'_cover.pdf'; - } + // save cover pdf $pdf -> Output($dir_fax_temp.'/'.$fax_instance_uuid.'_cover.pdf', "F"); // Display [I]nline, Save to [F]ile, [D]ownload + + //convert pdf to tif, add to array of pages, delete pdf + if (file_exists($dir_fax_temp.'/'.$fax_instance_uuid.'_cover.pdf')) { + chdir($dir_fax_temp); + exec("gs -q -sDEVICE=tiffg3 -r".$gs_r." -g".$gs_g." -dNOPAUSE -sOutputFile=".$fax_instance_uuid."_cover.tif -- ".$fax_instance_uuid."_cover.pdf -c quit"); + if (is_array($tif_files) && sizeof($tif_files) > 0) { + array_unshift($tif_files, $dir_fax_temp.'/'.$fax_instance_uuid.'_cover.tif'); + } + else { + $tif_files[] = $dir_fax_temp.'/'.$fax_instance_uuid.'_cover.tif'; + } + @unlink($dir_fax_temp.'/'.$fax_instance_uuid.'_cover.pdf'); + } } - //create new pdf object - unset($pdf); - $pdf = new FPDI('P', 'in'); - $pdf -> SetAutoPageBreak(false); - $pdf -> setPrintHeader(false); - $pdf -> setPrintFooter(false); - $pdf -> SetMargins(0, 0, 0, true); - - //combine pages into single pdf, delete temporary cover pdf (if exists) - if (is_array($pdf_files) && sizeof($pdf_files) > 0) { - foreach ($pdf_files as $pdf_file) { - $pdf_file_pages = $pdf -> setSourceFile($pdf_file); - for ($p = 1; $p <= $pdf_file_pages; $p++) { - $tmpl = $pdf -> ImportPage($p); - if ($fax_page_size == 'auto') { - //use individual page dimensions - $page_size = $pdf -> getTemplateSize($tmpl); - $page_width = round($page_size['w'], 2, PHP_ROUND_HALF_DOWN); - $page_height = round($page_size['h'], 2, PHP_ROUND_HALF_DOWN); - } - $pdf -> AddPage('P', array($page_width, $page_height)); - $pdf -> useTemplate($tmpl); - } + //combine tif files into single multi-page tif + if (is_array($tif_files) && sizeof($tif_files) > 0) { + $cmd = "tiffcp -c none "; + foreach ($tif_files as $tif_file) { + $cmd .= $tif_file.' '; } - $pdf -> Output($dir_fax_temp.'/'.$fax_instance_uuid.'.pdf', "F"); // Display [I]nline, Save to [F]ile, [D]ownload (or a combination - eg. 'FI' or 'FD') - @unlink($dir_fax_temp.'/'.$fax_instance_uuid.'_cover.pdf'); + $cmd .= $dir_fax_temp.'/'.$fax_instance_uuid.'.tif'; + exec($cmd); + foreach ($tif_files as $tif_file) { + @unlink($tif_file); + } + //generate pdf (a work around, as tiff2pdf was improperly inverting the colors) + exec("tiff2pdf -u i -p ".$fax_page_size." -w ".$page_width." -l ".$page_height." -f -o ".$dir_fax_temp.'/'.$fax_instance_uuid.".pdf ".$dir_fax_temp.'/'.$fax_instance_uuid.".tif"); + chdir($dir_fax_temp); + exec("gs -q -sDEVICE=tiffg3 -r".$gs_r." -g".$gs_g." -dNOPAUSE -sOutputFile=".$fax_instance_uuid."_temp.tif -- ".$fax_instance_uuid.".pdf -c quit"); //convert pdf to tif + @unlink($dir_fax_temp.'/'.$fax_instance_uuid.".pdf"); + exec("tiff2pdf -u i -p ".$fax_page_size." -w ".$page_width." -l ".$page_height." -f -o ".$dir_fax_temp.'/'.$fax_instance_uuid.".pdf ".$dir_fax_temp.'/'.$fax_instance_uuid."_temp.tif"); + @unlink($dir_fax_temp.'/'.$fax_instance_uuid."_temp.tif"); } else { //nothing to send, redirect the browser @@ -473,44 +480,34 @@ else { exit; } - //convert pdf to tif - if (file_exists($dir_fax_temp.'/'.$fax_instance_uuid.'.pdf')) { - switch ($fax_resolution) { - case 'normal': - $r = '204x98'; $g = ((int) ($page_width * 204)).'x'.((int) ($page_height * 98)); - break; - case 'fine': - $r = '204x196'; $g = ((int) ($page_width * 204)).'x'.((int) ($page_height * 196)); - break; - case 'superfine': - $r = '408x391'; $g = ((int) ($page_width * 408)).'x'.((int) ($page_height * 391)); - break; - } - chdir($dir_fax_temp); - exec("gs -q -sDEVICE=tiffg3 -r".$r." -g".$g." -dNOPAUSE -sOutputFile=".$fax_instance_uuid.".tif -- ".$fax_instance_uuid.".pdf -c quit"); - } - //preview, if requested if ($_REQUEST['submit'] == $text['button-preview']) { - if (file_exists($dir_fax_temp.'/'.$fax_instance_uuid.'.tif')) { - //delete pdf and uploaded files - @unlink($dir_fax_temp.'/'.$fax_instance_uuid.'.pdf'); - foreach ($uploaded_file_names as $uploaded_file_name) { - @unlink($dir_fax_temp.'/'.$uploaded_file_name); - } + unset($file_type); + if (file_exists($dir_fax_temp.'/'.$fax_instance_uuid.'.pdf')) { + $file_type = 'pdf'; + $content_type = 'application/pdf'; + @unlink($dir_fax_temp.'/'.$fax_instance_uuid.".tif"); + } + else if (file_exists($dir_fax_temp.'/'.$fax_instance_uuid.'.tif')) { + $file_type = 'tif'; + $content_type = 'image/tiff'; + @unlink($dir_fax_temp.'/'.$fax_instance_uuid.".pdf"); + } + if ($file_type != '') { //push download - $fd = fopen($dir_fax_temp.'/'.$fax_instance_uuid.'.tif', "rb"); + $fd = fopen($dir_fax_temp.'/'.$fax_instance_uuid.'.'.$file_type, "rb"); 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="'.$fax_instance_uuid.'.tif"'); - header("Content-Type: image/tiff"); + header('Content-Disposition: attachment; filename="'.$fax_instance_uuid.'.'.$file_type.'"'); + header("Content-Type: ".$content_type); header('Accept-Ranges: bytes'); 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_temp.'/'.$fax_instance_uuid.'.tif')); + header("Content-Length: ".filesize($dir_fax_temp.'/'.$fax_instance_uuid.'.'.$file_type)); fpassthru($fd); + @unlink($dir_fax_temp.'/'.$fax_instance_uuid.".".$file_type); } exit; } @@ -574,28 +571,12 @@ else { //wait for a few seconds sleep(5); - //move the generated tif and pdf files to the sent directory + //move the generated tif (and pdf) files to the sent directory exec("cp ".$dir_fax_temp.'/'.$fax_instance_uuid.".tif ".$dir_fax_sent.'/'.$fax_instance_uuid.".tif"); if (file_exists($dir_fax_temp.'/'.$fax_instance_uuid.".pdf")) { exec("cp ".$dir_fax_temp.'/'.$fax_instance_uuid.".pdf ".$dir_fax_sent.'/'.$fax_instance_uuid.".pdf"); } - //copy the original uploaded file to the sent box - foreach ($_SESSION['fax']['save'] as $row) { - if ($row == "all" || $row == "original") { - if (is_array($uploaded_file_names) && sizeof($uploaded_file_names) > 0) { - foreach ($uploaded_file_names as $uploaded_file_name) { - exec('cp '.$dir_fax_temp.'/'.$uploaded_file_name.' '.$dir_fax_sent.'/'.$uploaded_file_name); - } - } - } - } - - //delete uploaded files from temp - foreach ($uploaded_file_names as $uploaded_file_name) { - @unlink($dir_fax_temp.'/'.$uploaded_file_name); - } - //redirect the browser $_SESSION["message"] = $response; header("Location: fax_box.php?id=".$fax_uuid."&box=sent"); @@ -647,12 +628,22 @@ else { echo "\n"; echo " \n"; echo " \n"; echo " \n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; echo "\n"; echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; echo "\n"; echo "
\n"; - //pkg_add -r ghostscript8-nox11; rehash - echo " ".$text['description-2']." \n"; + echo " ".$text['description-2']." ".((if_group('superadmin')) ? $text['description-3'] : null)." \n"; echo "

\n"; echo "
\n"; + echo " ".$text['label-fax-header']."\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo " ".$text['description-fax-header']."\n"; + echo "
\n"; echo " ".$text['label-fax-sender']."\n"; @@ -664,17 +655,6 @@ else { echo "
\n"; - echo " ".$text['label-fax-contact-info']."\n"; - echo "\n"; - echo " \n"; - echo "
\n"; - echo " ".$text['description-fax-contact-info']."\n"; - echo "
\n"; echo " ".$text['label-fax-recipient']."\n"; @@ -769,7 +749,7 @@ else { echo " "; for ($f = 1; $f <= 3; $f++) { echo " 1) ? "style='display: none;'" : null).">"; - echo " 1) ? "style='margin-top: 3px;'" : null)." accept='image/tiff,application/pdf' onchange=\"".(($f < 3) ? "document.getElementById('fax_file_".($f+1)."').style.display='';" : null)." list_selected_files(".$f.");\" multiple='multiple'>
"; + echo " 1) ? "style='margin-top: 3px;'" : null)." onchange=\"".(($f < 3) ? "document.getElementById('fax_file_".($f+1)."').style.display='';" : null)." list_selected_files(".$f.");\" multiple='multiple'>
"; echo " "; echo "
\n"; } @@ -798,7 +778,6 @@ else { echo "
\n"; echo " \n"; - echo " "; echo " "; echo " "; echo " ";