Fax Server: Misc enhancements, including multilingual and customizable cover page generation, fax resolution selection, etc. More to come.

FPDI and TCPDF libraries added to accommodate the above, and future enhancements.
This commit is contained in:
Nate Jones
2014-09-03 02:41:11 +00:00
parent 48bf64d15d
commit 21dc61fa8e
54 changed files with 67263 additions and 394 deletions

56
app/fax/app_defaults.php Normal file
View File

@@ -0,0 +1,56 @@
<?php
if ($domains_processed == 1) {
//define array of settings
$x = 0;
$array[$x]['default_setting_category'] = 'fax';
$array[$x]['default_setting_subcategory'] = 'cover_logo';
$array[$x]['default_setting_name'] = 'text';
$array[$x]['default_setting_value'] = '';
$array[$x]['default_setting_enabled'] = 'false';
$array[$x]['default_setting_description'] = 'Path to image/logo file displayed in the header of the cover sheet.';
$x++;
$array[$x]['default_setting_category'] = 'fax';
$array[$x]['default_setting_subcategory'] = 'cover_disclaimer';
$array[$x]['default_setting_name'] = 'text';
$array[$x]['default_setting_value'] = "The information contained in this facsimile message is intended for the sole confidential use of the designated recipient(s) and may contain confidential information. If you have received this information in error, any review, dissemination, distribution or copying of this information is strictly prohibited. Please notify us immediately and return the original message to us by mail or, if electronic, reroute back to the sender.";
$array[$x]['default_setting_enabled'] = 'false';
$array[$x]['default_setting_description'] = 'Disclaimer 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_name'] = 'text';
$array[$x]['default_setting_value'] = '';
$array[$x]['default_setting_enabled'] = 'false';
$array[$x]['default_setting_description'] = 'Contact information displayed below the logo in the cover sheet header.';
$x++;
//iterate and add each, if necessary
foreach ($array as $index => $default_settings) {
//add theme default settings
$sql = "select count(*) as num_rows from v_default_settings ";
$sql .= "where default_setting_category = 'fax' ";
$sql .= "and default_setting_subcategory = '".$default_settings['default_setting_subcategory']."' ";
$sql .= "and default_setting_name = '".$default_settings['default_setting_name']."' ";
$prep_statement = $db->prepare($sql);
if ($prep_statement) {
$prep_statement->execute();
$row = $prep_statement->fetch(PDO::FETCH_ASSOC);
unset($prep_statement);
if ($row['num_rows'] == 0) {
$orm = new orm;
$orm->name('default_settings');
$orm->save($array[$index]);
$message = $orm->message;
//print_r($message);
}
unset($row);
}
}
}
?>

View File

@@ -25,15 +25,20 @@
$text['label-destination-number']['pt-pt'] = "Número de Destino";
$text['label-destination-number']['fr-fr'] = "Numéro d'appelant";
$text['label-inbox']['en-us'] = "Inbox";
$text['label-inbox']['es-cl'] = "Bandeja de Entrada";
$text['label-inbox']['pt-pt'] = "Entrada";
$text['label-inbox']['fr-fr'] = "";
$text['header-send']['en-us'] = "New Fax";
$text['header-send']['es-cl'] = "Nueva Fax";
$text['header-send']['pt-pt'] = "Enviar um Fax";
$text['header-send']['fr-fr'] = "Nouveau Fax";
$text['label-sent']['en-us'] = "Sent";
$text['label-sent']['es-cl'] = "Enviado";
$text['label-sent']['pt-pt'] = "Enviado";
$text['label-sent']['fr-fr'] = "";
$text['header-inbox']['en-us'] = "Inbox";
$text['header-inbox']['es-cl'] = "Bandeja de entrada";
$text['header-inbox']['pt-pt'] = "Caixa de entrada";
$text['header-inbox']['fr-fr'] = "Boîte de réception";
$text['header-sent']['en-us'] = "Sent Faxes";
$text['header-sent']['es-cl'] = "Los Faxes Enviados";
$text['header-sent']['pt-pt'] = "Faxes Enviados";
$text['header-sent']['fr-fr'] = "Fax Envoyés";
$text['label-name']['en-us'] = "Name";
$text['label-name']['es-cl'] = "Nombre";
@@ -45,15 +50,35 @@
$text['label-email']['pt-pt'] = "Email";
$text['label-email']['fr-fr'] = "Courriel";
$text['label-tools']['en-us'] = "Tools";
$text['label-tools']['es-cl'] = "Herramientas";
$text['label-tools']['pt-pt'] = "Ferramentas";
$text['label-tools']['fr-fr'] = "Outils";
$text['label-new']['en-us'] = "New";
$text['label-new']['es-cl'] = "Nueva";
$text['label-new']['pt-pt'] = "Nova";
$text['label-new']['fr-fr'] = "Nouveau";
$text['label-inbox']['en-us'] = "Inbox";
$text['label-inbox']['es-cl'] = "Bandeja de Entrada";
$text['label-inbox']['pt-pt'] = "Caixa de Entrada";
$text['label-inbox']['fr-fr'] = "Boîte de Réception";
$text['label-sent']['en-us'] = "Sent";
$text['label-sent']['es-cl'] = "Enviado";
$text['label-sent']['pt-pt'] = "Enviados";
$text['label-sent']['fr-fr'] = "Expédié";
$text['label-description']['en-us'] = "Description";
$text['label-description']['es-cl'] = "Descripción";
$text['label-description']['pt-pt'] = "Descrição";
$text['label-description']['fr-fr'] = "Description";
$text['label-upload']['en-us'] = "Upload";
$text['label-upload']['es-cl'] = "Subir";
$text['label-upload']['pt-pt'] = "Carregar";
$text['label-upload']['fr-fr'] = "Télécharegr";
$text['label-fax_file']['en-us'] = "Fax File";
$text['label-fax_file']['es-cl'] = "Subir";
$text['label-fax_file']['pt-pt'] = "Carregar";
$text['label-fax_file']['fr-fr'] = "Télécharegr";
$text['description-upload']['en-us'] = "Select the file to upload and send as a fax.";
$text['description-upload']['es-cl'] = "Seleccione el archivo a subir y enviar como fax.";
@@ -80,6 +105,11 @@
$text['button-settings']['pt-pt'] = "Configurações";
$text['button-settings']['fr-fr'] = "Configuration";
$text['button-preview']['en-us'] = "Preview";
$text['button-preview']['es-cl'] = "Prevista";
$text['button-preview']['pt-pt'] = "Pré-Visualização";
$text['button-preview']['fr-fr'] = "Avant-Première";
$text['button-send']['en-us'] = "Send";
$text['button-send']['es-cl'] = "Enviar";
$text['button-send']['pt-pt'] = "Enviar";
@@ -128,15 +158,10 @@
$text['confirm-fax']['pt-pt'] = "Por favor indique: um ficheiro para enviar Fax";
$text['confirm-fax']['fr-fr'] = "Merci d'indiquer: Un Fichier à émettre";
$text['confirm-fax-add']['en-us'] = "Fax Add";
$text['confirm-fax-add']['es-cl'] = "Agregar Fax";
$text['confirm-fax-add']['pt-pt'] = "Adição de Fax";
$text['confirm-fax-add']['fr-fr'] = "Ajout de Fax";
$text['confirm-fax-edit']['en-us'] = "Fax";
$text['confirm-fax-edit']['es-cl'] = "Fax";
$text['confirm-fax-edit']['pt-pt'] = "Fax";
$text['confirm-fax-edit']['fr-fr'] = "Fax";
$text['header-fax_server_settings']['en-us'] = "Fax Server Settings";
$text['header-fax_server_settings']['es-cl'] = "Configuración del Servidor de Fax";
$text['header-fax_server_settings']['pt-pt'] = "Configurações do Servidor de Fax";
$text['header-fax_server_settings']['fr-fr'] = "Paramètres Fax Server";
$text['confirm-copy-info']['en-us'] = "Do you really want to copy this?";
$text['confirm-copy-info']['es-cl'] = "&iquest;Desea realmente copiar esto?";
@@ -228,29 +253,119 @@
$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 you can upload a .tif file or if ghost script has been installed then you can also send a fax by uploading a PDF.";
$text['description-2']['en-us'] = "To send a fax, upload a <strong>TIF</strong> or (if ghost script has been installed) <strong>PDF</strong> 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 <b>TIF</b>. Si ghost script a été installé, vous pouvez également utiliser un fichier <b>PDF</b>.";
$text['description-3']['en-us'] = "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 console.";
$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['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['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['label-fax-number']['en-us'] = "Fax Number";
$text['label-fax-number']['es-cl'] = "Número de Fax";
$text['label-fax-number']['pt-pt'] = "Número de Fax";
$text['label-fax-number']['fr-fr'] = "Numéro de Fax";
$text['description-fax-number']['en-us'] = "Enter the number here.";
$text['description-fax-number']['en-us'] = "Enter the recipient's fax number.";
$text['description-fax-number']['es-cl'] = "Ingrese el número aquí.";
$text['description-fax-number']['pt-pt'] = "Introduza aqui o número.";
$text['description-fax-number']['fr-fr'] = "";
$text['label-location']['en-us'] = "location";
$text['label-location']['es-cl'] = "localización";
$text['label-location']['pt-pt'] = "localização";
$text['label-fax-subject']['en-us'] = "Subject";
$text['label-fax-subject']['es-cl'] = "Asunto";
$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']['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['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']['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['label-fax-resolution']['en-us'] = "Resolution";
$text['label-fax-resolution']['es-cl'] = "Resolución";
$text['label-fax-resolution']['pt-pt'] = "Resolução";
$text['label-fax-resolution']['fr-fr'] = "Résolution";
$text['description-fax-resolution']['en-us'] = "Select the transmission quality.";
$text['description-fax-resolution']['es-cl'] = "Seleccione la calidad de la transmisión.";
$text['description-fax-resolution']['pt-pt'] = "Selecione a qualidade da transmissão.";
$text['description-fax-resolution']['fr-fr'] = "Sélectionnez la qualité de transmission.";
$text['option-fax-resolution-normal']['en-us'] = "Normal";
$text['option-fax-resolution-normal']['es-cl'] = "Normal";
$text['option-fax-resolution-normal']['pt-pt'] = "Normal";
$text['option-fax-resolution-normal']['fr-fr'] = "Normal";
$text['option-fax-resolution-fine']['en-us'] = "Fine";
$text['option-fax-resolution-fine']['es-cl'] = "Fine";
$text['option-fax-resolution-fine']['pt-pt'] = "Belas";
$text['option-fax-resolution-fine']['fr-fr'] = "Fin";
$text['option-fax-resolution-superfine']['en-us'] = "Superfine";
$text['option-fax-resolution-superfine']['es-cl'] = "Superfino";
$text['option-fax-resolution-superfine']['pt-pt'] = "Extrafino";
$text['option-fax-resolution-superfine']['fr-fr'] = "Superfin";
$text['label-fax-fax']['en-us'] = "FAX";
$text['label-fax-fax']['es-cl'] = "Facsímil";
$text['label-fax-fax']['pt-pt'] = "Fax";
$text['label-fax-fax']['fr-fr'] = "Télécopie";
$text['label-fax-cover-sheet']['en-us'] = "COVER SHEET";
$text['label-fax-cover-sheet']['es-cl'] = "CARTA DE PRESENTACIÓN";
$text['label-fax-cover-sheet']['pt-pt'] = "CARTA DE APRESENTAÇÃO";
$text['label-fax-cover-sheet']['fr-fr'] = "LETTRE DE MOTIVATION";
$text['label-fax-attached']['en-us'] = "Attached";
$text['label-fax-attached']['es-cl'] = "Adjunto";
$text['label-fax-attached']['pt-pt'] = "Anexado";
$text['label-fax-attached']['fr-fr'] = "Attaché";
$text['label-fax-page']['en-us'] = "Page";
$text['label-fax-page']['es-cl'] = "Página";
$text['label-fax-page']['pt-pt'] = "Página";
$text['label-fax-page']['fr-fr'] = "Page";
$text['label-fax-pages']['en-us'] = "Pages";
$text['label-fax-pages']['es-cl'] = "Páginas";
$text['label-fax-pages']['pt-pt'] = "Páginas";
$text['label-fax-pages']['fr-fr'] = "Pages";
$text['label-location']['en-us'] = "Location";
$text['label-location']['es-cl'] = "Localización";
$text['label-location']['pt-pt'] = "Localização";
$text['label-location']['fr-fr'] = "Localisation";
$text['table-file']['en-us'] = "File Name (Download)";
@@ -272,5 +387,4 @@
$text['table-size']['es-cl'] = "Tamaño";
$text['table-size']['pt-pt'] = "Tamanho";
$text['table-size']['fr-fr'] = "Taille";
?>

View File

@@ -37,9 +37,7 @@ require_once "resources/header.php";
require_once "resources/paging.php";
//add multi-lingual support
echo "<!--\n";
require_once "app_languages.php";
echo "-->\n";
foreach($text as $key => $value) {
$text[$key] = $value[$_SESSION['domain']['language']['code']];
}
@@ -49,21 +47,15 @@ require_once "resources/paging.php";
$order = check_str($_GET["order"]);
//show the content
echo "<div align='center'>\n";
echo "<table width='100%' border='0' cellpadding='0' cellspacing='2'>\n";
echo "<tr class='border'>\n";
echo " <td align=\"center\">\n";
echo " <br>\n";
echo " <table width=\"100%\" border=\"0\" cellpadding=\"6\" cellspacing=\"0\">\n";
echo " <tr>\n";
echo " <td align='left'>\n";
echo " <span class=\"title\">".$text['title']."</span><br />\n";
echo " ".$text['description']."\n";
echo " \n";
echo " </td>\n";
echo " </tr>\n";
echo " </table>\n";
echo " <br />\n";
echo "<table width='100%' border='0' cellpadding='6' cellspacing='0'>\n";
echo " <tr>\n";
echo " <td align='left'>\n";
echo " <span class=\"title\">".$text['title']."</span><br /><br />\n";
echo " ".$text['description']."\n";
echo " </td>\n";
echo " </tr>\n";
echo "</table>\n";
echo "<br />\n";
if (if_group("superadmin") || if_group("admin")) {
//show all fax extensions
@@ -125,12 +117,12 @@ require_once "resources/paging.php";
$row_style["0"] = "row_style0";
$row_style["1"] = "row_style1";
echo "<div align='center'>\n";
echo "<table class='tr_hover' width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo "<tr>\n";
echo th_order_by('fax_name', $text['label-name'], $order_by, $order);
echo th_order_by('fax_extension', $text['label-extension'], $order_by, $order);
echo th_order_by('fax_email', $text['label-email'], $order_by, $order);
echo "<th>".$text['label-tools']."</th>";
echo th_order_by('fax_description', $text['label-description'], $order_by, $order);
echo "<td align='right' width='42'>\n";
if (permission_exists('fax_extension_add')) {
@@ -144,11 +136,11 @@ require_once "resources/paging.php";
//remove the backslash
$row['fax_email'] = str_replace("\\", "", $row['fax_email']);
//show the fax extensions
$tr_link = (permission_exists('fax_extension_edit')) ? "href='fax_view.php?id=".$row['fax_uuid']."'" : null;
$tr_link = (permission_exists('fax_extension_edit')) ? "href='fax_edit.php?id=".$row['fax_uuid']."'" : null;
echo "<tr ".$tr_link.">\n";
echo " <td valign='top' class='".$row_style[$c]."'>";
if (permission_exists('fax_extension_edit')) {
echo "<a href='fax_view.php?id=".$row['fax_uuid']."'>".$row['fax_name']."</a>";
echo "<a href='fax_edit.php?id=".$row['fax_uuid']."'>".$row['fax_name']."</a>";
}
else {
echo $row['fax_name'];
@@ -156,10 +148,21 @@ require_once "resources/paging.php";
echo " </td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>".$row['fax_extension']."</td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>".$row['fax_email']."&nbsp;</td>\n";
echo " <td valign='top' class='".$row_style[$c]." tr_link_void'>";
if (permission_exists('fax_send')) {
echo " <a href='fax_send.php?id=".$row['fax_uuid']."'>".$text['label-new']."</a>&nbsp;&nbsp;";
}
if (permission_exists('fax_inbox_view')) {
echo " <a href='fax_box.php?id=".$row['fax_uuid']."&box=inbox'>".$text['label-inbox']."</a>&nbsp;&nbsp;";
}
if (permission_exists('fax_sent_view')) {
echo " <a href='fax_box.php?id=".$row['fax_uuid']."&box=sent'>".$text['label-sent']."</a>";
}
echo " </td>\n";
echo " <td valign='top' class='row_stylebg' width='35%'>".$row['fax_description']."&nbsp;</td>\n";
echo " <td class='list_control_icons'>";
if (permission_exists('fax_extension_edit')) {
echo "<a href='fax_view.php?id=".$row['fax_uuid']."' alt='".$text['button-edit']."'>$v_link_label_edit</a>";
echo "<a href='fax_edit.php?id=".$row['fax_uuid']."' alt='".$text['button-edit']."'>$v_link_label_edit</a>";
}
if (permission_exists('fax_extension_delete')) {
echo "<a href='fax_delete.php?id=".$row['fax_uuid']."' alt='".$text['button-delete']."' onclick=\"return confirm('".$text['message-confirm-delete']."')\">$v_link_label_delete</a>";
@@ -173,7 +176,7 @@ require_once "resources/paging.php";
} //end if results
echo "<tr>\n";
echo "<td colspan='5'>\n";
echo "<td colspan='6'>\n";
echo " <table width='100%' cellpadding='0' cellspacing='0'>\n";
echo " <tr>\n";
echo " <td width='33.3%' nowrap>&nbsp;</td>\n";
@@ -187,17 +190,14 @@ require_once "resources/paging.php";
echo " </table>\n";
echo "</td>\n";
echo "</tr>\n";
echo "</table>";
echo "</div>";
echo "<br><br>";
echo "<br><br>";
echo "<br><br>";
echo "</td>";
echo "</tr>";
echo "</table>";
echo "</div>";
echo "<br><br>";
//show the footer
require_once "resources/footer.php";

View File

@@ -46,8 +46,8 @@ else {
$fax_extension = check_str($_REQUEST["fax_extension"]);
}
//pre-populate the form
if (strlen($_GET['id']) > 0 && $_POST["persistformvar"] != "true") {
//get fax extension
if (strlen($_GET['id']) > 0) {
$fax_uuid = check_str($_GET["id"]);
if (if_group("superadmin") || if_group("admin")) {
//show all fax extensions
@@ -78,13 +78,6 @@ else {
foreach ($result as &$row) {
//set database fields as variables
$fax_extension = $row["fax_extension"];
$fax_name = $row["fax_name"];
$fax_email = $row["fax_email"];
$fax_pin_number = $row["fax_pin_number"];
$fax_caller_id_name = $row["fax_caller_id_name"];
$fax_caller_id_number = $row["fax_caller_id_number"];
$fax_forward_number = $row["fax_forward_number"];
$fax_description = $row["fax_description"];
//limit to one row
break;
}
@@ -100,19 +93,25 @@ else {
}
//delete a fax
if ($_GET['a'] == "del" && permission_exists('fax_inbox_delete')) {
if ($_GET['a'] == "del") {
$file_name = substr(check_str($_GET['filename']), 0, -4);
$file_ext = substr(check_str($_GET['filename']), -3);
if ($_GET['type'] == "fax_inbox") {
if ($_GET['type'] == "fax_inbox" && permission_exists('fax_inbox_delete')) {
unlink($fax_dir.'/'.$fax_extension.'/inbox/'.$file_name.".tif");
unlink($fax_dir.'/'.$fax_extension.'/inbox/'.$file_name.".pdf");
$box = 'inbox';
}
if ($_GET['type'] == "fax_sent") {
if ($_GET['type'] == "fax_sent" && permission_exists('fax_sent_delete')) {
unlink($fax_dir.'/'.$fax_extension.'/sent/'.$file_name.".tif");
unlink($fax_dir.'/'.$fax_extension.'/sent/'.$file_name.".pdf");
$box = 'sent';
}
unset($file_name);
unset($file_ext);
$_SESSION["message"] = $text['confirm-delete'];
header("Location: fax_box.php?id=".$fax_uuid."&box=".$box);
exit;
}
//download the fax
@@ -196,299 +195,22 @@ else {
}
}
//set the action as an add or an update
if (isset($_REQUEST["id"])) {
$action = "update";
$fax_uuid = check_str($_REQUEST["id"]);
}
else {
$action = "add";
}
//get the http post values and set them as php variables
if (count($_POST)>0) {
$fax_name = check_str($_POST["fax_name"]);
$fax_email = check_str($_POST["fax_email"]);
$fax_pin_number = check_str($_POST["fax_pin_number"]);
$fax_caller_id_name = check_str($_POST["fax_caller_id_name"]);
$fax_caller_id_number = check_str($_POST["fax_caller_id_number"]);
$fax_forward_number = check_str($_POST["fax_forward_number"]);
if (strlen($fax_forward_number) > 0) {
$fax_forward_number = preg_replace("~[^0-9]~", "",$fax_forward_number);
}
$fax_description = check_str($_POST["fax_description"]);
}
//clear file status cache
clearstatcache();
//upload and send the fax
if (($_POST['type'] == "fax_send") && is_uploaded_file($_FILES['fax_file']['tmp_name'])) {
$fax_number = check_str($_POST['fax_number']);
if (strlen($fax_number) > 0) {
$fax_number = preg_replace("~[^0-9]~", "",$fax_number);
}
$fax_name = $_FILES['fax_file']['name'];
$fax_name = preg_replace('/\\.[^.\\s]{3,4}$/', '', $fax_name);
$fax_name = str_replace(" ", "_", $fax_name);
//$fax_name = str_ireplace(".tif", "", $fax_name);
//$fax_name = str_ireplace(".tiff", "", $fax_name);
//$fax_name = str_ireplace(".pdf", "", $fax_name);
//lua doesn't seem to like special chars with env:GetHeader
$fax_name = str_replace(";", "_", $fax_name);
$fax_name = str_replace(",", "_", $fax_name);
$fax_name = str_replace("'", "_", $fax_name);
$fax_name = str_replace("!", "_", $fax_name);
$fax_name = str_replace("@", "_", $fax_name);
$fax_name = str_replace("#", "_", $fax_name);
$fax_name = str_replace("$", "_", $fax_name);
$fax_name = str_replace("%", "_", $fax_name);
$fax_name = str_replace("^", "_", $fax_name);
$fax_name = str_replace("`", "_", $fax_name);
$fax_name = str_replace("~", "_", $fax_name);
$fax_name = str_replace("&", "_", $fax_name);
$fax_name = str_replace("(", "_", $fax_name);
$fax_name = str_replace(")", "_", $fax_name);
$fax_name = str_replace("+", "_", $fax_name);
$fax_name = str_replace("=", "_", $fax_name);
$provider_type = check_str($_POST['provider_type']);
$fax_uuid = check_str($_POST["id"]);
$fax_caller_id_name = check_str($_POST['fax_caller_id_name']);
$fax_caller_id_number = check_str($_POST['fax_caller_id_number']);
$fax_forward_number = check_str($_POST['fax_forward_number']);
if (strlen($fax_forward_number) > 0) {
$fax_forward_number = preg_replace("~[^0-9]~", "",$fax_forward_number);
}
//get the fax file extension
$fax_file_extension = '.'. pathinfo($_FILES['fax_file']['name'], PATHINFO_EXTENSION);
if (strtolower($fax_file_extension) == ".tiff") { $fax_file_extension = ".tif"; }
if (strtolower($fax_file_extension) == ".tif") { $fax_file_extension = ".tif"; }
if (strtolower($fax_file_extension) == ".pdf") { $fax_file_extension = ".pdf"; }
//upload the file
move_uploaded_file($_FILES['fax_file']['tmp_name'], $dir_fax_temp.'/'.$fax_name.$fax_file_extension);
//file conversion
if ($fax_file_extension == ".pdf") {
chdir($dir_fax_temp);
exec("gs -q -sDEVICE=tiffg3 -r204x196 -g1728x2156 -dNOPAUSE -sOutputFile=".$fax_name.".tif -- ".$fax_name.".pdf -c quit");
} else {
exec("export HOME=/tmp && libreoffice --headless --convert-to pdf --outdir ".$dir_fax_temp." ".$dir_fax_temp.'/'.$fax_name.$fax_file_extension);
}
//if the tif does not exist then convert the pdf to a tif
if(file_exists($dir_fax_temp.'/'.$fax_name.'.pdf') && !file_exists($dir_fax_temp.'/'.$fax_name.'.tif')){
chdir($dir_fax_temp);
exec("gs -q -sDEVICE=tiffg3 -r204x196 -g1728x2156 -dNOPAUSE -sOutputFile=".$fax_name.".tif -- ".$fax_name.".pdf -c quit");
}
//get some more info to send the fax
if (isset($_SESSION['fax']['smtp_from']['var'])) {
$mailfrom_address = $_SESSION['fax']['smtp_from']['var'];
}
else {
$mailfrom_address = $_SESSION['email']['smtp_from']['var'];
}
//echo 'mail from: '.$mailfrom_address.'<br>';
$sql = "select fax_email from v_fax where fax_uuid = '".$fax_uuid."'; ";
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
$result = $prep_statement->fetch(PDO::FETCH_NAMED);
$mailto_address_fax = $result["fax_email"];
//echo 'mail address fax: '.$mailto_address_fax.'<br>';
$sql = "select contact_uuid from v_users where user_uuid = '".$_SESSION['user_uuid']."'; ";
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
$result = $prep_statement->fetch(PDO::FETCH_NAMED);
//print_r($result);
$sql = "select contact_email from v_contacts where contact_uuid = '".$result["contact_uuid"]."'; ";
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
$result = $prep_statement->fetch(PDO::FETCH_NAMED);
//print_r($result);
$mailto_address_user = $result["contact_email"];
//echo 'mail address user: '.$mailto_address_user.'<br>';
if ($mailto_address_user != $mailto_address_fax) {
$mailto_address = "'".$mailto_address_fax."\,".$mailto_address_user."'";
}
else {
$mailto_address = $mailto_address_user;
}
//send the fax
$fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);
if ($fp) {
//prepare the fax command
$route_array = outbound_route_to_bridge($_SESSION['domain_uuid'], $fax_number);
$fax_file = $dir_fax_temp."/".$fax_name.".tif";
if (count($route_array) == 0) {
//send the internal call to the registered extension
$fax_uri = "user/".$fax_number."@".$_SESSION['domain_name'];
$t38 = "";
}
else {
//send the external call
$fax_uri = $route_array[0];
$t38 = "fax_enable_t38=true,fax_enable_t38_request=true,";
}
$cmd = "api originate {mailto_address='".$mailto_address."',mailfrom_address='".$mailfrom_address."',origination_caller_id_name='".$fax_caller_id_name."',origination_caller_id_number='".$fax_caller_id_number."',fax_ident='".$fax_caller_id_number."',fax_header='".$fax_caller_id_name."',fax_uri=".$fax_uri.",fax_file='".$fax_file."',fax_retry_attempts=1,fax_retry_limit=20,fax_retry_sleep=180,fax_verbose=true,fax_use_ecm=off,".$t38."api_hangup_hook='lua fax_retry.lua'}".$fax_uri." &txfax('".$fax_file."')";
//send the command to event socket
$response = event_socket_request($fp, $cmd);
$response = str_replace("\n", "", $response);
$uuid = str_replace("+OK ", "", $response);
fclose($fp);
}
//wait for a few seconds
sleep(5);
//copy the .tif to the sent directory
exec("cp ".$dir_fax_temp.'/'.$fax_name.".tif ".$dir_fax_sent.'/'.$fax_name.".tif");
//copy the .pdf to the sent directory
if (file_exists($dir_fax_temp.'/'.$fax_name.".pdf")) {
exec("cp ".$dir_fax_temp.'/'.$fax_name.".pdf ".$dir_fax_sent.'/'.$fax_name.".pdf");
}
//copy the original file to the sent box
foreach ($_SESSION['fax']['save'] as $row) {
if ($row == "all" || $row == "original") {
if ($fax_file_extension != ".pdf" || $fax_file_extension != ".tif") {
exec("cp ".$dir_fax_temp.'/'.$fax_name.".pdf ".$dir_fax_sent.'/'.$fax_name.$fax_file_extension);
}
}
}
//convert the tif to pdf and png
//chdir($dir_fax_sent);
//which tiff2pdf
//if (is_file("/usr/local/bin/tiff2png")) {
// exec($_SESSION['switch']['bin']['dir']."/tiff2png ".$dir_fax_sent.$fax_name.".tif");
// exec($_SESSION['switch']['bin']['dir']."/tiff2pdf -f -o ".$fax_name.".pdf ".$dir_fax_sent.$fax_name.".tif");
//}
//redirect the browser
header("Location: fax_view.php?id=".$fax_uuid."&msg=".$response);
exit;
} //end upload and send fax
//delete the fax
if ($_GET['a'] == "del") {
$fax_extension = check_str($_GET["fax_extension"]);
if ($_GET['type'] == "fax_inbox" && permission_exists('fax_inbox_delete')) {
unlink($fax_dir.'/'.$fax_extension.'/inbox/'.check_str($_GET['filename']));
}
if ($_GET['type'] == "fax_sent" && permission_exists('fax_sent_delete')) {
unlink($fax_dir.'/'.$fax_extension.'/sent/'.check_str($_GET['filename']));
}
}
//show the header
require_once "resources/header.php";
//fax extension form
echo "<div align='center'>";
echo "<table border='0' cellpadding='0' cellspacing='2'>\n";
echo "<tr class='border'>\n";
echo " <td align=\"left\">\n";
echo " <br>";
echo "<div align='center'>\n";
echo "<table width='100%' border='0' cellpadding='6' cellspacing='0'>\n";
echo "<tr>\n";
echo " <td align='left' width='30%'>\n";
echo " <span class=\"title\">".$text['title']."</span>\n";
echo " </td>\n";
echo " <td width='70%' align='right'>\n";
echo " <input type='button' class='btn' name='' alt='back' onclick=\"window.location='fax.php'\" value='".$text['button-back']."'>\n";
if (permission_exists('fax_extension_add') || permission_exists('fax_extension_edit')) {
echo " <input type='button' class='btn' name='' alt='settings' onclick=\"window.location='fax_edit.php?id=$fax_uuid'\" value='".$text['button-settings']."'>\n";
}
echo " </td>\n";
echo "</tr>\n";
echo "</table>\n";
echo "</div>\n";
echo "<form action=\"\" method=\"POST\" enctype=\"multipart/form-data\" name=\"frmUpload\" onSubmit=\"\">\n";
echo "<div align='center'>\n";
echo "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"3\">\n";
echo " <tr>\n";
echo " <td colspan='2' align='left'>\n";
//pkg_add -r ghostscript8-nox11; rehash
echo " ".$text['description-2']." \n";
echo " ".$text['description-3']."\n";
echo " <br /><br />\n";
echo " </td>\n";
echo " </tr>\n";
echo "<tr>\n";
echo "<td class='vncellreq' valign='top' align='left' nowrap>\n";
echo " ".$text['label-fax-number'].":\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input type=\"text\" name=\"fax_number\" class='formfld' style='' value=\"\">\n";
echo "<br />\n";
echo "".$text['description-fax-number']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncellreq' valign='top' align='left' nowrap>\n";
echo " ".$text['label-upload'].":\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input name=\"id\" type=\"hidden\" value=\"\$id\">\n";
echo " <input name=\"type\" type=\"hidden\" value=\"fax_send\">\n";
echo " <input name=\"fax_file\" type=\"file\" class=\"formfld fileinput\" id=\"fax_file\" accept=\"image/tiff,application/pdf\">\n";
echo " <br />\n";
echo " ".$text['description-upload']."\n";
echo "</td>\n";
echo "</tr>\n";
echo " <tr>\n";
echo " <td colspan='2' align='right'>\n";
echo " <input type=\"hidden\" name=\"fax_caller_id_name\" value=\"".$fax_caller_id_name."\">\n";
echo " <input type=\"hidden\" name=\"fax_caller_id_number\" value=\"".$fax_caller_id_number."\">\n";
echo " <input type=\"hidden\" name=\"fax_extension\" value=\"".$fax_extension."\">\n";
echo " <input type=\"hidden\" name=\"id\" value=\"".$fax_uuid."\">\n";
echo " <input name=\"submit\" type=\"submit\" class=\"btn\" id=\"upload\" value=\"".$text['button-send']."\">\n";
echo " </td>\n";
echo " </tr>";
echo "</table>";
echo "</div>\n";
echo "</form>\n";
//show the inbox
if (permission_exists('fax_inbox_view')) {
echo "\n";
echo "\n";
echo " <br /><br />\n";
echo "\n";
if ($_REQUEST['box'] == 'inbox' && permission_exists('fax_inbox_view')) {
echo " <table width=\"100%\" border=\"0\" cellpadding=\"5\" cellspacing=\"0\">\n";
echo " <tr>\n";
echo " <td align='left'>\n";
echo " <span class=\"vexpl\"><span class=\"title\">".$text['label-inbox']." ".$fax_extension."</span>\n";
echo " <span class=\"vexpl\"><span class=\"title\">".$text['header-inbox']." ".$fax_extension."</span>\n";
echo " </td>\n";
echo " <td align='right'>";
if ($v_path_show) {
echo "<strong>".$text['label-location'].":</strong>&nbsp;";
echo $dir_fax_inbox."&nbsp; &nbsp; &nbsp;";
}
echo " <td width='70%' align='right'>\n";
echo " <input type='button' class='btn' name='' alt='back' onclick=\"window.location='fax.php'\" value='".$text['button-back']."'>\n";
echo " </td>\n";
echo " </tr>\n";
echo " </table>\n";
echo "\n";
echo "<br>\n";
$c = 0;
$row_style["0"] = "row_style0";
@@ -497,10 +219,10 @@ else {
echo " <div id=\"\">\n";
echo " <table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n";
echo " <tr>\n";
echo " <th width=\"60%\" class=\"listhdrr\">".$text['table-file']."</td>\n";
echo " <th width=\"10%\" class=\"listhdrr\">".$text['table-view']."</td>\n";
echo " <th width=\"20%\" class=\"listhdr\">".$text['table-modified']."</td>\n";
echo " <th width=\"10%\" class=\"listhdr\" nowrap>".$text['table-size']."</td>\n";
echo " <th width='60%'>".$text['table-file']."</td>\n";
echo " <th width='10%'>".$text['table-view']."</td>\n";
echo " <th width='20%'>".$text['table-modified']."</td>\n";
echo " <th width='10%' nowrap>".$text['table-size']."</td>\n";
echo " </tr>";
if ($handle = opendir($dir_fax_inbox)) {
@@ -556,14 +278,14 @@ else {
//}
echo "<tr>\n";
echo " <td class='".$row_style[$c]."' ondblclick=\"\">\n";
echo " <a href=\"fax_view.php?id=".$fax_uuid."&a=download&type=fax_inbox&t=bin&ext=".urlencode($fax_extension)."&filename=".urlencode($file)."\">\n";
echo " <a href=\"fax_box.php?id=".$fax_uuid."&a=download&type=fax_inbox&t=bin&ext=".urlencode($fax_extension)."&filename=".urlencode($file)."\">\n";
echo " $file_name";
echo " </a>";
echo " </td>\n";
echo " <td class='".$row_style[$c]."' ondblclick=\"\">\n";
if (file_exists($dir_fax_inbox.'/'.$file_name.".pdf")) {
echo " <a href=\"fax_view.php?id=".$fax_uuid."&a=download&type=fax_inbox&t=bin&ext=".urlencode($fax_extension)."&filename=".urlencode($file_name).".pdf\">\n";
echo " <a href=\"fax_box.php?id=".$fax_uuid."&a=download&type=fax_inbox&t=bin&ext=".urlencode($fax_extension)."&filename=".urlencode($file_name).".pdf\">\n";
echo " PDF";
echo " </a>";
}
@@ -574,7 +296,7 @@ else {
//echo " <td class='".$row_style[$c]."' ondblclick=\"\">\n";
//if (file_exists($dir_fax_inbox.'/'.$file_name.".jpg")) {
// echo " <a href=\"fax_view.php?id=".$fax_uuid."&a=download&type=fax_inbox&t=jpg&ext=".$fax_extension."&filename=".$file_name.".jpg\" target=\"_blank\">\n";
// echo " <a href=\"fax_box.php?id=".$fax_uuid."&a=download&type=fax_inbox&t=jpg&ext=".$fax_extension."&filename=".$file_name.".jpg\" target=\"_blank\">\n";
// echo " jpg";
// echo " </a>";
//}
@@ -595,7 +317,7 @@ else {
echo " <table border=\"0\" cellspacing=\"0\" cellpadding=\"1\">\n";
echo " <tr>\n";
if (permission_exists('fax_inbox_delete')) {
echo " <td><a href=\"fax_view.php?id=".$fax_uuid."&type=fax_inbox&a=del&fax_extension=".urlencode($fax_extension)."&filename=".urlencode($file)."\" onclick=\"return confirm('".$text['confirm-delete']."')\">$v_link_label_delete</a></td>\n";
echo " <td><a href=\"fax_box.php?id=".$fax_uuid."&type=fax_inbox&a=del&fax_extension=".urlencode($fax_extension)."&filename=".urlencode($file)."\" onclick=\"return confirm('".$text['message-confirm-delete']."')\">$v_link_label_delete</a></td>\n";
}
echo " </tr>\n";
echo " </table>\n";
@@ -610,34 +332,39 @@ else {
echo " </tr>\n";
echo " </table>\n";
echo "\n";
echo " <br /><br /><br />\n";
echo " <br />\n";
if (if_group('superadmin')) {
echo "<strong>".$text['label-location'].":</strong>&nbsp;&nbsp;".$dir_fax_inbox;
}
echo "<br /><br />\n";
echo "\n";
}
//show the sent box
if (permission_exists('fax_sent_view')) {
if ($_REQUEST['box'] == 'sent' && permission_exists('fax_sent_view')) {
echo "<table width=\"100%\" border=\"0\" cellpadding=\"5\" cellspacing=\"0\">\n";
echo " <tr>\n";
echo " <td align='left'>\n";
echo " <span class=\"vexpl\"><span class=\"title\">".$text['label-sent']."</span>\n";
echo " <span class=\"vexpl\"><span class=\"title\">".$text['header-sent']."</span>\n";
echo " </td>\n";
echo " <td align='right'>\n";
if ($v_path_show) {
echo "<strong>".$text['label-location'].": </strong>\n";
echo $dir_fax_sent."&nbsp; &nbsp; &nbsp;\n";
}
echo " <td width='70%' align='right'>\n";
echo " <input type='button' class='btn' name='' alt='back' onclick=\"window.location='fax.php'\" value='".$text['button-back']."'>\n";
echo " </td>\n";
echo " </tr>\n";
echo "</table>\n";
echo "\n";
echo "<br>\n";
echo "<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n";
echo " <tr>\n";
echo " <th width=\"60%\">".$text['table-file']."</td>\n";
echo " <th width=\"10%\">".$text['table-view']."</td>\n";
echo " <th width=\"20%\">".$text['table-modified']."</td>\n";
echo " <th width=\"10%\" nowrap>".$text['table-size']."</td>\n";
echo " <th width='60%'>".$text['table-file']."</td>\n";
echo " <th width='10%'>".$text['table-view']."</td>\n";
echo " <th width='20%'>".$text['table-modified']."</td>\n";
echo " <th width='10%' nowrap>".$text['table-size']."</td>\n";
echo " </tr>";
$c = 0;
$row_style["0"] = "row_style0";
$row_style["1"] = "row_style1";
if ($handle = opendir($dir_fax_sent)) {
//build an array of the files in the inbox
$i = 0;
@@ -692,13 +419,13 @@ else {
}
echo "<tr>\n";
echo " <td class='".$row_style[$c]."' ondblclick=\"\">\n";
echo " <a href=\"fax_view.php?id=".$fax_uuid."&a=download&type=fax_sent&t=bin&ext=".urlencode($fax_extension)."&filename=".urlencode($file)."\">\n";
echo " <a href=\"fax_box.php?id=".$fax_uuid."&a=download&type=fax_sent&t=bin&ext=".urlencode($fax_extension)."&filename=".urlencode($file)."\">\n";
echo " $file";
echo " </a>";
echo " </td>\n";
echo " <td class='".$row_style[$c]."' ondblclick=\"\">\n";
if (file_exists($dir_fax_sent.'/'.$file_name.".pdf")) {
echo " <a href=\"fax_view.php?id=".$fax_uuid."&a=download&type=fax_sent&t=bin&ext=".urlencode($fax_extension)."&filename=".urlencode($file_name).".pdf\">\n";
echo " <a href=\"fax_box.php?id=".$fax_uuid."&a=download&type=fax_sent&t=bin&ext=".urlencode($fax_extension)."&filename=".urlencode($file_name).".pdf\">\n";
echo " PDF";
echo " </a>";
}
@@ -708,7 +435,7 @@ else {
echo " </td>\n";
//echo " <td class='".$row_style[$c]."' ondblclick=\"\">\n";
//if (file_exists($dir_fax_sent.'/'.$file_name.".jpg")) {
// echo " <a href=\"fax_view.php?id=".$fax_uuid."&a=download&type=fax_sent&t=jpg&ext=".$fax_extension."&filename=".$file_name.".jpg\" target=\"_blank\">\n";
// echo " <a href=\"fax_box.php?id=".$fax_uuid."&a=download&type=fax_sent&t=jpg&ext=".$fax_extension."&filename=".$file_name.".jpg\" target=\"_blank\">\n";
// echo " jpg";
// echo " </a>";
//}
@@ -728,7 +455,7 @@ else {
echo " <table border=\"0\" cellspacing=\"0\" cellpadding=\"1\">\n";
echo " <tr>\n";
if (permission_exists('fax_sent_delete')) {
echo " <td><a href=\"fax_view.php?id=".$fax_uuid."&type=fax_sent&a=del&fax_extension=".urlencode($fax_extension)."&filename=".urlencode($file)."\" onclick=\"return confirm('".$text['confirm-delete']."')\">$v_link_label_delete</a></td>\n";
echo " <td><a href=\"fax_box.php?id=".$fax_uuid."&type=fax_sent&a=del&fax_extension=".urlencode($fax_extension)."&filename=".urlencode($file)."\" onclick=\"return confirm('".$text['message-confirm-delete']."')\">$v_link_label_delete</a></td>\n";
}
echo " </tr>\n";
echo " </table>\n";
@@ -745,9 +472,10 @@ else {
echo " </table>\n";
echo "\n";
echo " <br />\n";
echo " <br />\n";
echo " <br />\n";
echo " <br />\n";
if (if_group('superadmin')) {
echo "<strong>".$text['label-location'].":</strong>&nbsp;&nbsp;".$dir_fax_sent;
}
echo "<br /><br />\n";
}
echo " </td>";
echo " </tr>";

View File

@@ -525,13 +525,8 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
echo "<form method='post' name='frm' action=''>\n";
echo "<table width='100%' border='0' cellpadding='6' cellspacing='0'>\n";
echo " <tr>\n";
if ($action == "add") {
echo " <td align='left' width='30%' nowrap><b>".$text['confirm-fax-add']."</b></td>\n";
}
if ($action == "update") {
echo " <td align='left' width='30%' nowrap><b>".$text['confirm-fax-edit']."</b></td>\n";
}
echo " <td width='70%' align='right'>\n";
echo " <td align='left' width='30%' valign='top' nowrap><b>".$text['header-fax_server_settings']."</b><br><br></td>\n";
echo " <td width='70%' valign='top' align='right'>\n";
echo " <input type='button' class='btn' name='' alt='back' onclick=\"window.location='fax.php'\" value='".$text['button-back']."'>\n";
if ((if_group("admin") || if_group("superadmin")) && $action == "update") {
echo " <input type='button' class='btn' name='' alt='copy' onclick=\"if (confirm('".$text['confirm-copy-info']."')){window.location='fax_copy.php?id=".$fax_uuid."';}\" value='".$text['button-copy']."'>\n";
@@ -544,7 +539,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap>\n";
echo " ".$text['label-email'].":\n";
echo " ".$text['label-email']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='fax_email' maxlength='255' value=\"$fax_email\">\n";
@@ -558,7 +553,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
echo "<tr>\n";
echo "<td class='vncellreq' valign='top' align='left' nowrap>\n";
echo " ".$text['label-name'].":\n";
echo " ".$text['label-name']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='fax_name' maxlength='255' value=\"$fax_name\">\n";
@@ -569,7 +564,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
echo "<tr>\n";
echo "<td class='vncellreq' valign='top' align='left' nowrap>\n";
echo " ".$text['label-extension'].":\n";
echo " ".$text['label-extension']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='fax_extension' maxlength='255' value=\"$fax_extension\">\n";
@@ -580,7 +575,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap>\n";
echo " ".$text['label-destination-number'].":\n";
echo " ".$text['label-destination-number']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='fax_destination_number' maxlength='255' value=\"$fax_destination_number\">\n";
@@ -591,7 +586,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap>\n";
echo " ".$text['label-email'].":\n";
echo " ".$text['label-email']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='fax_email' maxlength='255' value=\"$fax_email\">\n";
@@ -602,7 +597,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
//echo "<tr>\n";
//echo "<td class='vncell' valign='top' align='left' nowrap>\n";
//echo " ".$text['label-pin'].":\n";
//echo " ".$text['label-pin']."\n";
//echo "</td>\n";
//echo "<td class='vtable' align='left'>\n";
//echo " <input class='formfld' type='text' name='fax_pin_number' maxlength='255' value=\"$fax_pin_number\">\n";
@@ -613,7 +608,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap>\n";
echo " ".$text['label-caller-id-name'].":\n";
echo " ".$text['label-caller-id-name']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='fax_caller_id_name' maxlength='255' value=\"$fax_caller_id_name\">\n";
@@ -624,7 +619,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap>\n";
echo " ".$text['label-caller-id-number'].":\n";
echo " ".$text['label-caller-id-number']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='fax_caller_id_number' maxlength='255' value=\"$fax_caller_id_number\">\n";
@@ -635,7 +630,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap>\n";
echo " ".$text['label-forward'].":\n";
echo " ".$text['label-forward']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
if (is_numeric($fax_forward_number)) {
@@ -652,7 +647,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
if (if_group("admin") || if_group("superadmin")) {
if ($action == "update") {
echo " <tr>";
echo " <td class='vncell' valign='top'>".$text['label-user-list'].":</td>";
echo " <td class='vncell' valign='top'>".$text['label-user-list']."</td>";
echo " <td class='vtable'>";
$sql = "SELECT * FROM v_fax_users as e, v_users as u ";
@@ -704,7 +699,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap>\n";
echo " ".$text['label-description'].":\n";
echo " ".$text['label-description']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='fax_description' maxlength='255' value=\"$fax_description\">\n";

638
app/fax/fax_send.php Normal file
View File

@@ -0,0 +1,638 @@
<?php
/*
FusionPBX
Version: MPL 1.1
The contents of this file are subject to the Mozilla Public License Version
1.1 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the
License.
The Original Code is FusionPBX
The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2008-2012
the Initial Developer. All Rights Reserved.
Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com>
James Rose <james.o.rose@gmail.com>
*/
include "root.php";
require_once "resources/require.php";
require_once "resources/check_auth.php";
if (permission_exists('fax_send')) {
//access granted
}
else {
echo "access denied";
exit;
}
//add multi-lingual support
require_once "app_languages.php";
foreach($text as $key => $value) {
$text[$key] = $value[$_SESSION['domain']['language']['code']];
}
//get the fax_extension and save it as a variable
if (strlen($_REQUEST["fax_extension"]) > 0) {
$fax_extension = check_str($_REQUEST["fax_extension"]);
}
//pre-populate the form
if (strlen($_REQUEST['id']) > 0 && $_POST["persistformvar"] != "true") {
$fax_uuid = check_str($_REQUEST["id"]);
if (if_group("superadmin") || if_group("admin")) {
//show all fax extensions
$sql = "select * from v_fax ";
$sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' ";
$sql .= "and fax_uuid = '$fax_uuid' ";
}
else {
//show only assigned fax extensions
$sql = "select * from v_fax as f, v_fax_users as u ";
$sql .= "where f.fax_uuid = u.fax_uuid ";
$sql .= "and f.domain_uuid = '".$_SESSION['domain_uuid']."' ";
$sql .= "and f.fax_uuid = '$fax_uuid' ";
$sql .= "and u.user_uuid = '".$_SESSION['user_uuid']."' ";
}
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
if (count($result) == 0) {
if (if_group("superadmin") || if_group("admin")) {
//allow access
}
else {
echo "access denied";
exit;
}
}
foreach ($result as &$row) {
//set database fields as variables
$fax_extension = $row["fax_extension"];
$fax_name = $row["fax_name"];
$fax_email = $row["fax_email"];
$fax_pin_number = $row["fax_pin_number"];
$fax_caller_id_name = $row["fax_caller_id_name"];
$fax_caller_id_number = $row["fax_caller_id_number"];
$fax_forward_number = $row["fax_forward_number"];
$fax_description = $row["fax_description"];
//limit to one row
break;
}
unset ($prep_statement);
}
//set the fax directory
if (count($_SESSION["domains"]) > 1) {
$fax_dir = $_SESSION['switch']['storage']['dir'].'/fax/'.$_SESSION['domain_name'];
}
else {
$fax_dir = $_SESSION['switch']['storage']['dir'].'/fax';
}
//get the fax extension
if (strlen($fax_extension) > 0) {
//set the fax directories. example /usr/local/freeswitch/storage/fax/329/inbox
$dir_fax_inbox = $fax_dir.'/'.$fax_extension.'/inbox';
$dir_fax_sent = $fax_dir.'/'.$fax_extension.'/sent';
$dir_fax_temp = $fax_dir.'/'.$fax_extension.'/temp';
//make sure the directories exist
if (!is_dir($_SESSION['switch']['storage']['dir'])) {
mkdir($_SESSION['switch']['storage']['dir']);
chmod($dir_fax_sent,0774);
}
if (!is_dir($fax_dir.'/'.$fax_extension)) {
mkdir($fax_dir.'/'.$fax_extension,0774,true);
chmod($fax_dir.'/'.$fax_extension,0774);
}
if (!is_dir($dir_fax_inbox)) {
mkdir($dir_fax_inbox,0774,true);
chmod($dir_fax_inbox,0774);
}
if (!is_dir($dir_fax_sent)) {
mkdir($dir_fax_sent,0774,true);
chmod($dir_fax_sent,0774);
}
if (!is_dir($dir_fax_temp)) {
mkdir($dir_fax_temp,0774,true);
chmod($dir_fax_temp,0774);
}
}
//set the action as an add or an update
if (isset($_REQUEST["id"])) {
$action = "update";
$fax_uuid = check_str($_REQUEST["id"]);
}
else {
$action = "add";
}
//get the http post values and set them as php variables
if (count($_POST)>0) {
$fax_name = check_str($_POST["fax_name"]);
$fax_email = check_str($_POST["fax_email"]);
$fax_pin_number = check_str($_POST["fax_pin_number"]);
$fax_caller_id_name = check_str($_POST["fax_caller_id_name"]);
$fax_caller_id_number = check_str($_POST["fax_caller_id_number"]);
$fax_forward_number = check_str($_POST["fax_forward_number"]);
if (strlen($fax_forward_number) > 0) {
$fax_forward_number = preg_replace("~[^0-9]~", "",$fax_forward_number);
}
$fax_description = check_str($_POST["fax_description"]);
}
//clear file status cache
clearstatcache();
//upload and send the fax
if (($_POST['type'] == "fax_send") && is_uploaded_file($_FILES['fax_file']['tmp_name'])) {
$fax_number = check_str($_POST['fax_number']);
if (strlen($fax_number) > 0) {
$fax_number = preg_replace("~[^0-9]~", "",$fax_number);
}
$fax_name = $_FILES['fax_file']['name'];
$fax_name = preg_replace('/\\.[^.\\s]{3,4}$/', '', $fax_name);
$fax_name = str_replace(" ", "_", $fax_name);
//lua doesn't seem to like special chars with env:GetHeader
$fax_name = str_replace(";", "_", $fax_name);
$fax_name = str_replace(",", "_", $fax_name);
$fax_name = str_replace("'", "_", $fax_name);
$fax_name = str_replace("!", "_", $fax_name);
$fax_name = str_replace("@", "_", $fax_name);
$fax_name = str_replace("#", "_", $fax_name);
$fax_name = str_replace("$", "_", $fax_name);
$fax_name = str_replace("%", "_", $fax_name);
$fax_name = str_replace("^", "_", $fax_name);
$fax_name = str_replace("`", "_", $fax_name);
$fax_name = str_replace("~", "_", $fax_name);
$fax_name = str_replace("&", "_", $fax_name);
$fax_name = str_replace("(", "_", $fax_name);
$fax_name = str_replace(")", "_", $fax_name);
$fax_name = str_replace("+", "_", $fax_name);
$fax_name = str_replace("=", "_", $fax_name);
$provider_type = check_str($_POST['provider_type']);
$fax_uuid = check_str($_POST["id"]);
$fax_caller_id_name = check_str($_POST['fax_caller_id_name']);
$fax_caller_id_number = check_str($_POST['fax_caller_id_number']);
$fax_forward_number = check_str($_POST['fax_forward_number']);
if (strlen($fax_forward_number) > 0) {
$fax_forward_number = preg_replace("~[^0-9]~", "",$fax_forward_number);
}
$fax_sender = check_str($_POST['fax_sender']);
$fax_recipient = check_str($_POST['fax_recipient']);
$fax_subject = check_str($_POST['fax_subject']);
$fax_message = check_str($_POST['fax_message']);
$fax_resolution = check_str($_POST['fax_resolution']);
//get the fax file extension
$fax_file_extension = strtolower(pathinfo($_FILES['fax_file']['name'], PATHINFO_EXTENSION));
if ($fax_file_extension == "tiff" || $fax_file_extension == "tif") { $fax_file_extension = "tif"; }
//upload the file
move_uploaded_file($_FILES['fax_file']['tmp_name'], $dir_fax_temp.'/'.$fax_name.'.'.$fax_file_extension);
//convert uploaded file to pdf, if necessary
if ($fax_file_extension != "pdf") {
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);
}
//load pdf tools
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);
//determine total pages uploaded
$page_count = 0;
$pdf_files = array($dir_fax_temp.'/'.$fax_name.'.'.$fax_file_extension);
foreach ($pdf_files as $pdf_file) {
$page_count += $pdf -> setSourceFile($pdf_file);
}
//determine page size
$pdf -> setSourceFile($dir_fax_temp.'/'.$fax_name.'.'.$fax_file_extension);
$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);
//generate cover page, merge with pdf
if ($fax_subject != '' || $fax_message != '') {
//add blank page
$pdf -> AddPage('P', array($page_size['w'], $page_size['h']));
// content offset, if necessary
$x = 0;
$y = 0;
// output grid
//showgrid($pdf);
//logo
if (isset($_SESSION['fax']['cover_logo']['text'])) {
$logo = $_SESSION['fax']['cover_logo']['text'];
}
if (substr($logo, 0, 4) == 'http') {
$remote_filename = strtolower(pathinfo($logo, PATHINFO_BASENAME));
$remote_fileext = pathinfo($remote_filename, PATHINFO_EXTENSION);
if ($remote_fileext == 'gif' || $remote_fileext == 'jpg' || $remote_fileext == 'jpeg' || $remote_fileext == 'png' || $remote_fileext == 'bmp') {
if (!file_exists($dir_fax_temp.'/'.$remote_filename)) {
$raw = file_get_contents($logo);
if (file_put_contents($dir_fax_temp.'/'.$remote_filename, $raw)) {
$logo = $dir_fax_temp.'/'.$remote_filename;
}
else {
unset($logo);
}
}
else {
$logo = $dir_fax_temp.'/'.$remote_filename;
}
}
else {
unset($logo);
}
}
if ($logo == '') {
$logo = PROJECT_PATH."/app/fax/logo.jpg";
}
$pdf -> Image($logo, 0.5, 0.4, 2.5, 0.9, null, null, 'N', true, 300, null, false, false, 0, true);
//contact info
if (isset($_SESSION['fax']['cover_contact_info']['text'])) {
$pdf -> SetLeftMargin(0.5);
$pdf -> SetFont("times", "", 10);
$pdf -> Write(0.3, $_SESSION['fax']['cover_contact_info']['text']);
}
//fax, cover sheet
$pdf -> SetTextColor(0,0,0);
$pdf -> SetFont("times", "B", 55);
$pdf -> SetXY($x + 4.55, $y + 0.25);
$pdf -> Cell($x + 3.50, $y + 0.4, $text['label-fax-fax'], 0, 0, 'R', false, null, 0, false, 'T', 'T');
$pdf -> SetFont("times", "", 12);
$pdf -> SetFontSpacing(0.0425);
$pdf -> SetXY($x + 4.55, $y + 1.0);
$pdf -> Cell($x + 3.50, $y + 0.4, $text['label-fax-cover-sheet'], 0, 0, 'R', false, null, 0, false, 'T', 'T');
$pdf -> SetFontSpacing(0);
//field labels
$pdf -> SetFont("times", "B", 12);
$pdf -> Text($x + 0.5, $y + 2.0, strtoupper($text['label-fax-recipient']).":");
$pdf -> Text($x + 0.5, $y + 2.3, strtoupper($text['label-fax-sender']).":");
if ($page_count > 0) {
$pdf -> Text($x + 0.5, $y + 2.6, strtoupper($text['label-fax-attached']).":");
}
if ($fax_subject != '') {
$pdf -> Text($x + 0.5, $y + 2.9, strtoupper($text['label-fax-subject']).":");
}
//field values
$pdf -> SetFont("times", "", 12);
$pdf -> Text($x + 2.0, $y + 2.0, (($fax_recipient != '') ? $fax_recipient.' ('.format_phone($fax_number).')' : format_phone($fax_number)) );
$pdf -> Text($x + 2.0, $y + 2.3, (($fax_sender != '') ? $fax_sender.' ('.format_phone($fax_caller_id_number).')' : format_phone($fax_caller_id_number)) );
if ($page_count > 0) {
$pdf -> Text($x + 2.0, $y + 2.6, $page_count.' '.$text['label-fax-page'.(($page_count > 1) ? 's' : null)]);
}
if ($fax_subject != '') {
$pdf -> Text($x + 2.0, $y + 2.9, $fax_subject);
}
//message
if ($fax_message != '') {
$pdf -> Rect($x + 0.5, $y + 3.4, 7.5, 6.5, 'D');
$pdf -> SetFont("times", "", 12);
$pdf -> SetXY($x + 0.75, $y + 3.65);
$pdf -> MultiCell(7, 6, $fax_message, 0, 'L', false);
}
//disclaimer
if ($_SESSION['fax']['cover_disclaimer']['text'] != '') {
$pdf -> SetFont("helvetica", "", 8);
$pdf -> SetXY($x + 0.5, $y + 10.15);
$pdf -> MultiCell(7.5, 0.75, $_SESSION['fax']['cover_disclaimer']['text'], 0, 'C', false);
}
//import uploaded pdf pages
$pdf_files = array($dir_fax_temp.'/'.$fax_name.'.'.$fax_file_extension);
foreach ($pdf_files as $pdf_file) {
$page_count = $pdf -> setSourceFile($pdf_file);
for ($p = 1; $p <= $page_count; $p++) {
$tmpl = $pdf -> ImportPage($p);
$page_size = $pdf -> getTemplateSize($tmpl);
$pdf -> AddPage('P', array($page_size['w'], $page_size['h']));
$pdf -> useTemplate($tmpl);
}
}
// save new file with cover
$pdf -> Output($dir_fax_temp.'/'.$fax_name.'.'.$fax_file_extension, "F"); // Display [I]nline, Save to [F]ile, [D]ownload
}
//convert pdf to a tif
if (file_exists($dir_fax_temp.'/'.$fax_name.'.pdf')) {
@unlink($dir_fax_temp.'/'.$fax_name.'.tif');
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_name.".tif -- ".$fax_name.".pdf -c quit");
}
//preview, if requested
if ($_REQUEST['submit'] == $text['button-preview']) {
if (file_exists($dir_fax_temp.'/'.$fax_name.'.tif')) {
@unlink($dir_fax_temp.'/'.$fax_name.'.pdf');
$fd = fopen($dir_fax_temp.'/'.$fax_name.'.tif', "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_name.'.tif"');
header("Content-Type: image/tiff");
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_name.'.tif'));
fpassthru($fd);
}
exit;
}
//get some more info to send the fax
if (isset($_SESSION['fax']['smtp_from']['var'])) {
$mailfrom_address = $_SESSION['fax']['smtp_from']['var'];
}
else {
$mailfrom_address = $_SESSION['email']['smtp_from']['var'];
}
//echo 'mail from: '.$mailfrom_address.'<br>';
$sql = "select fax_email from v_fax where fax_uuid = '".$fax_uuid."'; ";
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
$result = $prep_statement->fetch(PDO::FETCH_NAMED);
$mailto_address_fax = $result["fax_email"];
//echo 'mail address fax: '.$mailto_address_fax.'<br>';
$sql = "select contact_uuid from v_users where user_uuid = '".$_SESSION['user_uuid']."'; ";
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
$result = $prep_statement->fetch(PDO::FETCH_NAMED);
//print_r($result);
$sql = "select contact_email from v_contacts where contact_uuid = '".$result["contact_uuid"]."'; ";
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
$result = $prep_statement->fetch(PDO::FETCH_NAMED);
//print_r($result);
$mailto_address_user = $result["contact_email"];
//echo 'mail address user: '.$mailto_address_user.'<br>';
if ($mailto_address_user != $mailto_address_fax) {
$mailto_address = "'".$mailto_address_fax."\,".$mailto_address_user."'";
}
else {
$mailto_address = $mailto_address_user;
}
//send the fax
$fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);
if ($fp) {
//prepare the fax command
$route_array = outbound_route_to_bridge($_SESSION['domain_uuid'], $fax_number);
$fax_file = $dir_fax_temp."/".$fax_name.".tif";
if (count($route_array) == 0) {
//send the internal call to the registered extension
$fax_uri = "user/".$fax_number."@".$_SESSION['domain_name'];
$t38 = "";
}
else {
//send the external call
$fax_uri = $route_array[0];
$t38 = "fax_enable_t38=true,fax_enable_t38_request=true,";
}
$cmd = "api originate {mailto_address='".$mailto_address."',mailfrom_address='".$mailfrom_address."',origination_caller_id_name='".$fax_caller_id_name."',origination_caller_id_number='".$fax_caller_id_number."',fax_ident='".$fax_caller_id_number."',fax_header='".$fax_caller_id_name."',fax_uri=".$fax_uri.",fax_file='".$fax_file."',fax_retry_attempts=1,fax_retry_limit=20,fax_retry_sleep=180,fax_verbose=true,fax_use_ecm=off,".$t38."api_hangup_hook='lua fax_retry.lua'}".$fax_uri." &txfax('".$fax_file."')";
//send the command to event socket
$response = event_socket_request($fp, $cmd);
$response = str_replace("\n", "", $response);
$uuid = str_replace("+OK ", "", $response);
fclose($fp);
}
//wait for a few seconds
sleep(5);
//copy the .tif to the sent directory
exec("cp ".$dir_fax_temp.'/'.$fax_name.".tif ".$dir_fax_sent.'/'.$fax_name.".tif");
//copy the .pdf to the sent directory
if (file_exists($dir_fax_temp.'/'.$fax_name.".pdf")) {
exec("cp ".$dir_fax_temp.'/'.$fax_name.".pdf ".$dir_fax_sent.'/'.$fax_name.".pdf");
}
//copy the original file to the sent box
foreach ($_SESSION['fax']['save'] as $row) {
if ($row == "all" || $row == "original") {
if ($fax_file_extension != "pdf" || $fax_file_extension != "tif") {
exec("cp ".$dir_fax_temp.'/'.$fax_name.".pdf ".$dir_fax_sent.'/'.$fax_name.'.'.$fax_file_extension);
}
}
}
//convert the tif to pdf and png
//chdir($dir_fax_sent);
//which tiff2pdf
//if (is_file("/usr/local/bin/tiff2png")) {
// exec($_SESSION['switch']['bin']['dir']."/tiff2png ".$dir_fax_sent.$fax_name.".tif");
// exec($_SESSION['switch']['bin']['dir']."/tiff2pdf -f -o ".$fax_name.".pdf ".$dir_fax_sent.$fax_name.".tif");
//}
//redirect the browser
$_SESSION["message"] = $response;
header("Location: fax_box.php?id=".$fax_uuid."&box=sent");
exit;
} //end upload and send fax
//show the header
require_once "resources/header.php";
//fax extension form
echo "<form action='' method='POST' enctype='multipart/form-data' name='frmUpload' onSubmit=''>\n";
echo "<table width='100%' border='0' cellpadding='6' cellspacing='0'>\n";
echo "<tr>\n";
echo " <td align='left' width='30%'>\n";
echo " <span class='title'>".$text['header-send']."</span>\n";
echo " </td>\n";
echo " <td width='70%' align='right'>\n";
echo " <input type='button' class='btn' name='' alt='back' onclick=\"window.location='fax.php'\" value='".$text['button-back']."'>\n";
echo " <input type='submit' name='submit' class='btn' id='preview' value='".$text['button-preview']."'>\n";
echo " <input name='submit' type='submit' class='btn' id='upload' value='".$text['button-send']."'>\n";
echo " </td>\n";
echo "</tr>\n";
echo "</table>\n";
echo "<table width='100%' border='0' cellspacing='0' cellpadding='3'>\n";
echo " <tr>\n";
echo " <td colspan='2' align='left'>\n";
//pkg_add -r ghostscript8-nox11; rehash
echo " ".$text['description-2']." \n";
echo " <br /><br />\n";
echo " </td>\n";
echo " </tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap>\n";
echo " ".$text['label-fax-sender']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input type='text' name='fax_sender' class='formfld' style='' value='".$fax_caller_id_name."'>\n";
echo "<br />\n";
echo "".$text['description-fax-sender']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap>\n";
echo " ".$text['label-fax-recipient']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input type='text' name='fax_recipient' class='formfld' style='' value=''>\n";
echo "<br />\n";
echo "".$text['description-fax-recipient']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncellreq' valign='top' align='left' nowrap>\n";
echo " ".$text['label-fax-number']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input type='text' name='fax_number' class='formfld' style='' value=''>\n";
echo "<br />\n";
echo "".$text['description-fax-number']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncellreq' valign='top' align='left' nowrap>\n";
echo " ".$text['label-fax_file']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input name='fax_file' type='file' class='formfld fileinput' id='fax_file' accept='image/tiff,application/pdf'>\n";
echo " <br />\n";
echo " ".$text['description-upload']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap>\n";
echo " ".$text['label-fax-resolution']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <select name='fax_resolution' class='formfld'>\n";
echo " <option value='normal'>".$text['option-fax-resolution-normal']."</option>\n";
echo " <option value='fine'>".$text['option-fax-resolution-fine']."</option>\n";
echo " <option value='superfine'>".$text['option-fax-resolution-superfine']."</option>\n";
echo " </select>\n";
echo "<br />\n";
echo "".$text['description-fax-resolution']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap>\n";
echo " ".$text['label-fax-subject']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input type='text' name='fax_subject' class='formfld' style='' value=''>\n";
echo "<br />\n";
echo "".$text['description-fax-subject']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap>\n";
echo " ".$text['label-fax-message']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <textarea type='text' name='fax_message' class='formfld' style='width: 50%; height: 150px;'></textarea>\n";
echo "<br />\n";
echo "".$text['description-fax-message']."\n";
echo "</td>\n";
echo "</tr>\n";
echo " <tr>\n";
echo " <td colspan='2' align='right'>\n";
echo " <input type='hidden' name='fax_caller_id_name' value='".$fax_caller_id_name."'>\n";
echo " <input type='hidden' name='fax_caller_id_number' value='".$fax_caller_id_number."'>\n";
echo " <input type='hidden' name='fax_extension' value='".$fax_extension."'>\n";
echo " <input type='hidden' name='id' value='".$fax_uuid."'>\n";
echo " <input type='hidden' name='type' value='fax_send'>\n";
echo " <input type='submit' name='submit' class='btn' id='preview' value='".$text['button-preview']."'>\n";
echo " <input type='submit' name='submit' class='btn' id='upload' value='".$text['button-send']."'>\n";
echo " </td>\n";
echo " </tr>";
echo "</table>";
echo "</form>\n";
//show the footer
require_once "resources/footer.php";
// ******************************************************************
/* potentially used by pdf generation */
function showgrid($pdf) {
// generate a grid for placement
for ($x=0; $x<=8.5; $x+=0.1) {
for ($y=0; $y<=11; $y+=0.1) {
$pdf -> SetTextColor(0,0,0);
$pdf -> SetFont("courier", "", 3);
$pdf -> Text($x-0.01,$y-0.01,".");
}
}
for ($x=0; $x<=9; $x+=1) {
for ($y=0; $y<=11; $y+=1) {
$pdf -> SetTextColor(255,0,0);
$pdf -> SetFont("times", "", 10);
$pdf -> Text($x-.02,$y-.01,".");
$pdf -> SetFont("courier", "", 4);
$pdf -> Text($x+0.01,$y+0.035,$x.",".$y);
}
}
}
?>

BIN
app/fax/logo.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB