Fax Server: Send faxes to multiple recipients at once, customizable 'Subject Tag' for Remote Inbox viewing, preparations for Email-to-Fax functionality.

This commit is contained in:
Nate Jones 2014-11-29 13:32:42 +00:00
parent 3ec3f8ca2e
commit c3f0a450c2
7 changed files with 870 additions and 668 deletions

View File

@ -235,7 +235,19 @@
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = "fax_email_connection_mailbox";
$apps[$x]['db'][$y]['fields'][$z]['type'] = "text";
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "Mailbox folder to read.";
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "Mailbox folder to monitor.";
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = "fax_email_inbound_subject_tag";
$apps[$x]['db'][$y]['fields'][$z]['type'] = "text";
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "Subject tag to detect inbound faxes.";
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = "fax_email_outbound_subject_tag";
$apps[$x]['db'][$y]['fields'][$z]['type'] = "text";
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "Subject tag to detect outbound faxes.";
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = "fax_email_outbound_authorized_senders";
$apps[$x]['db'][$y]['fields'][$z]['type'] = "text";
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "Authorized email-to-fax sender addresses.";
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = "fax_pin_number";
$apps[$x]['db'][$y]['fields'][$z]['type'] = "text";

View File

@ -248,10 +248,10 @@
$text['label-email_connection_validate']['pt-pt'] = "Validar Certificado";
$text['label-email_connection_validate']['fr-fr'] = "Valider le Certificat";
$text['description-email_connection_validate']['en-us'] = "Enable server certificate validation (select 'False' for self-signed certificates).";
$text['description-email_connection_validate']['es-cl'] = "Activar la validación del certificado del servidor (seleccione 'Falso' para certificados con firma).";
$text['description-email_connection_validate']['pt-pt'] = "Habilitar a validação do certificado do servidor (selecione 'Não' para os certificados auto-assinados).";
$text['description-email_connection_validate']['fr-fr'] = "Activer la validation du certificat du serveur (sélectionner 'Non' pour les certificats auto-signés).";
$text['description-email_connection_validate']['en-us'] = "Enable server certificate validation.<br>(Select 'False' for self-signed certificates.)";
$text['description-email_connection_validate']['es-cl'] = "Activar la validación del certificado del servidor.<br>(Seleccione 'Falso' para certificados con firma.)";
$text['description-email_connection_validate']['pt-pt'] = "Habilitar a validação do certificado do servidor.<br>(Selecione 'Não' para os certificados auto-assinados.)";
$text['description-email_connection_validate']['fr-fr'] = "Activer la validation du certificat du serveur.<br>(Sélectionner 'Non' pour les certificats auto-signés.)";
$text['label-email_connection_username']['en-us'] = "Username";
$text['label-email_connection_username']['es-cl'] = "Nombre de usuario";
@ -278,10 +278,65 @@
$text['label-email_connection_mailbox']['pt-pt'] = "Pasta Caixa";
$text['label-email_connection_mailbox']['fr-fr'] = "Dossier Boîte aux Lettres";
$text['description-email_connection_mailbox']['en-us'] = "Enter the remote folder name to view.";
$text['description-email_connection_mailbox']['es-cl'] = "Escriba el nombre de la carpeta a distancia para ver.";
$text['description-email_connection_mailbox']['pt-pt'] = "Digite o nome da pasta remota para ver.";
$text['description-email_connection_mailbox']['fr-fr'] = "Entrez le nom du dossier à distance pour voir.";
$text['description-email_connection_mailbox']['en-us'] = "Enter the remote folder name to monitor.";
$text['description-email_connection_mailbox']['es-cl'] = "Escriba el nombre de la carpeta remota para monitorear.";
$text['description-email_connection_mailbox']['pt-pt'] = "Digite o nome da pasta remoto para monitorar.";
$text['description-email_connection_mailbox']['fr-fr'] = "Entrez le nom du dossier à distance pour surveiller.";
$text['label-advanced_settings']['en-us'] = "Advanced Settings";
$text['label-advanced_settings']['es-cl'] = "Configuración Avanzada";
$text['label-advanced_settings']['pt-pt'] = "Configurações Avançadas";
$text['label-advanced_settings']['fr-fr'] = "Paramètres Avancés";
$text['description-advanced_settings']['en-us'] = "Configure the settings below to enable Remote Inbox and Email-to-Fax functionality.";
$text['description-advanced_settings']['es-cl'] = "Configure las opciones de abajo para permitir que la bandeja de entrada remota y funcionalidad-Email-a-Fax.";
$text['description-advanced_settings']['pt-pt'] = "Defina as configurações abaixo para permitir Inbox remoto e funcionalidade Email-to-Fax.";
$text['description-advanced_settings']['fr-fr'] = "Configurez les paramètres ci-dessous pour activer la boîte de réception à distance et la fonctionnalité Email-à-Fax.";
$text['label-email_account_connection']['en-us'] = "Account Connection";
$text['label-email_account_connection']['es-cl'] = "Conexión Cuenta";
$text['label-email_account_connection']['pt-pt'] = "Connection Conta";
$text['label-email_account_connection']['fr-fr'] = "Compte Connexion";
$text['label-email_remote_inbox']['en-us'] = "Remote Inbox";
$text['label-email_remote_inbox']['es-cl'] = "Bandeja de Entrada Remota";
$text['label-email_remote_inbox']['pt-pt'] = "Inbox Remoto";
$text['label-email_remote_inbox']['fr-fr'] = "Boîte de Réception à Distance";
$text['label-email_inbound_subject_tag']['en-us'] = "Subject Tag";
$text['label-email_inbound_subject_tag']['es-cl'] = "Asunto Tag";
$text['label-email_inbound_subject_tag']['pt-pt'] = "Assunto Tag";
$text['label-email_inbound_subject_tag']['fr-fr'] = "Tag Sujet";
$text['description-email_inbound_subject_tag']['en-us'] = "Set the email subject tag for inbound faxes.";
$text['description-email_inbound_subject_tag']['es-cl'] = "Ajuste la etiqueta de asunto del correo electrónico para los faxes entrantes.";
$text['description-email_inbound_subject_tag']['pt-pt'] = "Defina a tag e-mail assunto para faxes recebidos.";
$text['description-email_inbound_subject_tag']['fr-fr'] = "Réglez le tag objet du courriel pour les fax entrants.";
$text['label-email_email-to-fax']['en-us'] = "Email-to-Fax";
$text['label-email_email-to-fax']['es-cl'] = "Email-a-Fax";
$text['label-email_email-to-fax']['pt-pt'] = "Email-to-Fax";
$text['label-email_email-to-fax']['fr-fr'] = "Email-à-Fax";
$text['label-email_outbound_subject_tag']['en-us'] = "Subject Tag";
$text['label-email_outbound_subject_tag']['es-cl'] = "Asunto Tag";
$text['label-email_outbound_subject_tag']['pt-pt'] = "Assunto Tag";
$text['label-email_outbound_subject_tag']['fr-fr'] = "Tag Sujet";
$text['description-email_outbound_subject_tag']['en-us'] = "Set the email subject tag for outbound faxes.";
$text['description-email_outbound_subject_tag']['es-cl'] = "Ajuste la etiqueta de asunto del correo electrónico para los faxes salientes.";
$text['description-email_outbound_subject_tag']['pt-pt'] = "Defina a tag e-mail assunto para faxes de saída.";
$text['description-email_outbound_subject_tag']['fr-fr'] = "Réglez le tag objet du courriel pour les fax sortants.";
$text['label-email_outbound_authorized_senders']['en-us'] = "Authorized Senders";
$text['label-email_outbound_authorized_senders']['es-cl'] = "Los Remitentes Autorizados";
$text['label-email_outbound_authorized_senders']['pt-pt'] = "Remetentes Autorizados";
$text['label-email_outbound_authorized_senders']['fr-fr'] = "Expéditeurs Autorisés";
$text['description-email_outbound_authorized_senders']['en-us'] = "Define the email address(es) allowed to send faxes through this server.";
$text['description-email_outbound_authorized_senders']['es-cl'] = "Definir la dirección de correo electrónico(es) pueden enviar faxes a través de este servidor.";
$text['description-email_outbound_authorized_senders']['pt-pt'] = "Defina o endereço de e-mail(s) permissão para enviar faxes através deste servidor.";
$text['description-email_outbound_authorized_senders']['fr-fr'] = "Définir l'adresse e-mail(s) autorisé à envoyer des télécopies via ce serveur.";
$text['option-true']['en-us'] = "True";
$text['option-true']['es-cl'] = "Verdadero";
@ -408,10 +463,10 @@
$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 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'] = "Entrez le numéro de fax du destinataire.";
$text['description-fax-number']['en-us'] = "Enter the recipient fax number(s).";
$text['description-fax-number']['es-cl'] = "Introduzca el número(s) de fax del destinatario.";
$text['description-fax-number']['pt-pt'] = "Digite o número do(s) de fax do destinatário.";
$text['description-fax-number']['fr-fr'] = "Entrez le numéro(s) de fax du destinataire.";
$text['label-fax-subject']['en-us'] = "Subject";
$text['label-fax-subject']['es-cl'] = "Asunto";

View File

@ -27,6 +27,8 @@
include "root.php";
require_once "resources/require.php";
require_once "resources/check_auth.php";
require_once "resources/functions/object_to_array.php";
require_once "resources/functions/parse_attachments.php";
if (permission_exists('fax_inbox_view')) {
//access granted
}
@ -79,6 +81,7 @@ else {
$fax_email_connection_username = $row["fax_email_connection_username"];
$fax_email_connection_password = $row["fax_email_connection_password"];
$fax_email_connection_mailbox = $row["fax_email_connection_mailbox"];
$fax_email_inbound_subject_tag = $row["fax_email_inbound_subject_tag"];
break;
}
unset ($prep_statement);
@ -88,7 +91,7 @@ else {
$fax_email_connection .= ($fax_email_connection_security != '') ? "/".$fax_email_connection_security : "/notls";
$fax_email_connection .= "/".(($fax_email_connection_validate == 'false') ? "no" : null)."validate-cert";
$fax_email_connection .= "}".$fax_email_connection_mailbox;
if (!$mailbox = imap_open($fax_email_connection, $fax_email_connection_username, $fax_email_connection_password)) {
if (!$connection = imap_open($fax_email_connection, $fax_email_connection_username, $fax_email_connection_password)) {
$_SESSION["message_mood"] = 'negative';
$_SESSION["message"] = $text['message-cannot_connect']."(".imap_last_error().")";
header("Location: fax.php");
@ -107,7 +110,7 @@ else {
//download attachment
if (isset($_GET['download'])) {
$attachment = get_attachments($mailbox, $email_id, FT_UID);
$attachment = parse_attachments($connection, $email_id, FT_UID);
$file_type = pathinfo($attachment[0]['filename'], PATHINFO_EXTENSION);
switch ($file_type) {
case "pdf" : header("Content-Type: application/pdf"); break;
@ -130,9 +133,9 @@ else {
//delete email
if (isset($_GET['delete']) && permission_exists('fax_inbox_delete')) {
$attachment = get_attachments($mailbox, $email_id, FT_UID);
if (imap_delete($mailbox, $email_id, FT_UID)) {
if (imap_expunge($mailbox)) {
$attachment = parse_attachments($connection, $email_id, FT_UID);
if (imap_delete($connection, $email_id, FT_UID)) {
if (imap_expunge($connection)) {
//clean up local inbox copy
$fax_dir = $_SESSION['switch']['storage']['dir'].'/fax'.((count($_SESSION["domains"]) > 1) ? '/'.$_SESSION['domain_name'] : null);
@unlink($fax_dir.'/'.$fax_extension.'/inbox/'.$attachment[0]['filename']);
@ -161,7 +164,7 @@ else {
}
//get emails
$emails = imap_search($mailbox, 'SUBJECT "Fax"', SE_UID);
$emails = imap_search($connection, "SUBJECT \"".$fax_email_inbound_subject_tag."\"", SE_UID);
//show the header
require_once "resources/header.php";
@ -199,8 +202,8 @@ else {
rsort($emails); // most recent on top
foreach ($emails as $email_id) {
$metadata = object_to_array(imap_fetch_overview($mailbox, $email_id, FT_UID));
$attachment = get_attachments($mailbox, $email_id, FT_UID);
$metadata = object_to_array(imap_fetch_overview($connection, $email_id, FT_UID));
$attachment = parse_attachments($connection, $email_id, FT_UID);
echo "<tr ".(($metadata[0]['seen'] == 0) ? "style='font-weight: bold;'" : null).">\n";
echo " <td valign='top' class='".$row_style[$c]."'>".$metadata[0]['date']."</td>\n";
@ -210,8 +213,10 @@ else {
echo " <td class='list_control_icons'><a href='?id=".$fax_uuid."&email_id=".$email_id."&delete' onclick=\"return confirm('".$text['message-confirm-delete']."')\">$v_link_label_delete</a></td>\n";
}
echo "</tr>\n";
//$message = imap_fetchbody($mailbox, $email_id, 2, FT_UID);
//echo $message;
// $fax_message = imap_fetchbody($connection, $email_id, '1.1', FT_UID);
// if ($fax_message == '') {
// $fax_message = imap_fetchbody($connection, $email_id, '1', FT_UID);
// }
}
}
@ -230,57 +235,4 @@ imap_close($inbox);
//show the footer
require_once "resources/footer.php";
//functions used above
function object_to_array($obj) {
if (!is_object($obj) && !is_array($obj)) { return $obj; }
if (is_object($obj)) { $obj = get_object_vars($obj); }
return array_map('object_to_array', $obj);
}
function get_attachments($connection, $message_number, $option = '') {
$attachments = array();
$structure = imap_fetchstructure($connection, $message_number, $option);
if(isset($structure->parts) && count($structure->parts)) {
for($i = 0; $i < count($structure->parts); $i++) {
if($structure->parts[$i]->ifdparameters) {
foreach($structure->parts[$i]->dparameters as $object) {
if(strtolower($object->attribute) == 'filename') {
$attachments[$i]['is_attachment'] = true;
$attachments[$i]['filename'] = $object->value;
}
}
}
if($structure->parts[$i]->ifparameters) {
foreach($structure->parts[$i]->parameters as $object) {
if(strtolower($object->attribute) == 'name') {
$attachments[$i]['is_attachment'] = true;
$attachments[$i]['name'] = $object->value;
}
}
}
if($attachments[$i]['is_attachment']) {
$attachments[$i]['attachment'] = imap_fetchbody($connection, $message_number, $i+1, $option);
if($structure->parts[$i]->encoding == 3) { // 3 = BASE64
$attachments[$i]['attachment'] = base64_decode($attachments[$i]['attachment']);
}
elseif($structure->parts[$i]->encoding == 4) { // 4 = QUOTED-PRINTABLE
$attachments[$i]['attachment'] = quoted_printable_decode($attachments[$i]['attachment']);
}
}
unset($attachments[$i]['is_attachment']);
}
}
return array_values($attachments); //reindex
}
?>

View File

@ -107,6 +107,9 @@ else {
$fax_email_connection_username = check_str($_POST["fax_email_connection_username"]);
$fax_email_connection_password = check_str($_POST["fax_email_connection_password"]);
$fax_email_connection_mailbox = check_str($_POST["fax_email_connection_mailbox"]);
$fax_email_inbound_subject_tag = check_str($_POST["fax_email_inbound_subject_tag"]);
$fax_email_outbound_subject_tag = check_str($_POST["fax_email_outbound_subject_tag"]);
$fax_email_outbound_authorized_senders = $_POST["fax_email_outbound_authorized_senders"];
//$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"]);
@ -221,6 +224,16 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
//add or update the database
if ($_POST["persistformvar"] != "true") {
//prep authorized senders
if (sizeof($fax_email_outbound_authorized_senders) > 0) {
foreach ($fax_email_outbound_authorized_senders as $sender_num => $sender) {
$sender = check_str($sender);
if ($sender == '' || !valid_email($sender)) { unset($fax_email_outbound_authorized_senders[$sender_num]); }
}
$fax_email_outbound_authorized_senders = implode(',', $fax_email_outbound_authorized_senders);
}
if ($action == "add" && permission_exists('fax_extension_add')) {
//prepare the unique identifiers
$fax_uuid = uuid();
@ -244,6 +257,9 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
$sql .= "fax_email_connection_username, ";
$sql .= "fax_email_connection_password, ";
$sql .= "fax_email_connection_mailbox, ";
$sql .= "fax_email_inbound_subject_tag, ";
$sql .= "fax_email_outbound_subject_tag, ";
$sql .= "fax_email_outbound_authorized_senders, ";
//$sql .= "fax_pin_number, ";
$sql .= "fax_caller_id_name, ";
$sql .= "fax_caller_id_number, ";
@ -269,6 +285,9 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
$sql .= "'$fax_email_connection_username', ";
$sql .= "'$fax_email_connection_password', ";
$sql .= "'$fax_email_connection_mailbox', ";
$sql .= "'$fax_email_inbound_subject_tag', ";
$sql .= "'$fax_email_outbound_subject_tag', ";
$sql .= "'$fax_email_outbound_authorized_senders', ";
//$sql .= "'$fax_pin_number', ";
$sql .= "'$fax_caller_id_name', ";
$sql .= "'$fax_caller_id_number', ";
@ -303,6 +322,9 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
$sql .= "fax_email_connection_username = '$fax_email_connection_username', ";
$sql .= "fax_email_connection_password = '$fax_email_connection_password', ";
$sql .= "fax_email_connection_mailbox = '$fax_email_connection_mailbox', ";
$sql .= "fax_email_inbound_subject_tag = '$fax_email_inbound_subject_tag', ";
$sql .= "fax_email_outbound_subject_tag = '$fax_email_outbound_subject_tag', ";
$sql .= "fax_email_outbound_authorized_senders = '$fax_email_outbound_authorized_senders', ";
//$sql .= "fax_pin_number = '$fax_pin_number', ";
$sql .= "fax_caller_id_name = '$fax_caller_id_name', ";
$sql .= "fax_caller_id_number = '$fax_caller_id_number', ";
@ -540,6 +562,9 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
$fax_email_connection_username = $row["fax_email_connection_username"];
$fax_email_connection_password = $row["fax_email_connection_password"];
$fax_email_connection_mailbox = $row["fax_email_connection_mailbox"];
$fax_email_inbound_subject_tag = $row["fax_email_inbound_subject_tag"];
$fax_email_outbound_subject_tag = $row["fax_email_outbound_subject_tag"];
$fax_email_outbound_authorized_senders = $row["fax_email_outbound_authorized_senders"];
//$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"];
@ -562,13 +587,22 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
//advanced button js
echo "<script type='text/javascript' language='JavaScript'>\n";
echo "function toggle_advanced(advanced_id) {\n";
echo " $('#'+advanced_id).slideToggle(800);\n";
echo "}\n";
echo " function toggle_advanced(advanced_id) {\n";
echo " $('#'+advanced_id).toggle();\n";
echo " if ($('#'+advanced_id).is(':visible')) {\n";
echo " $('#page').animate({scrollTop: $('#'+advanced_id).offset().top - 80}, 'slow');\n";
echo " }\n";
echo " }\n";
echo " function add_sender() {\n";
echo " var newdiv = document.createElement('div');\n";
echo " newdiv.innerHTML = \"<input type='text' class='formfld' style='width: 225px; min-width: 225px; max-width: 225px; margin-top: 3px;' name='fax_email_outbound_authorized_senders[]' maxlength='255'>\";";
echo " document.getElementById('authorized_senders').appendChild(newdiv);";
echo " }\n";
echo "</script>\n";
//fax extension form
echo "<form method='post' name='frm' action=''>\n";
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo " <tr>\n";
echo " <td align='left' width='30%' valign='top' nowrap><b>".$text['header-fax_server_settings']."</b><br><br></td>\n";
@ -636,112 +670,14 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
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";
if (function_exists("imap_open")) {
echo " <input type='button' class='btn' value='".$text['button-advanced']."' onclick=\"toggle_advanced('advanced_email_connection');\">\n";
if (function_exists("imap_open") && file_exists("fax_box_remote.php")) {
echo "<input type='button' class='btn' value='".$text['button-advanced']."' onclick=\"toggle_advanced('advanced_email_connection');\">\n";
}
echo "<br />\n";
echo " ".$text['description-email']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "</table>\n";
echo "<div id='advanced_email_connection' ".(($fax_email_connection_host == '') ? "style='display: none;'" : null).">\n";
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo "<tr>\n";
echo "<td width='30%' class='vncell' valign='top' align='left' nowrap>\n";
echo " ".$text['label-email_connection_type']."\n";
echo "</td>\n";
echo "<td width='70%' class='vtable' align='left'>\n";
echo " <select class='formfld' name='fax_email_connection_type'>\n";
echo " <option value='imap'>IMAP</option>\n";
echo " <option value='pop3' ".(($fax_email_connection_type == 'pop3') ? "selected" : null).">POP3</option>\n";
echo " </select>\n";
echo "<br />\n";
echo " ".$text['description-email_connection_type']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap>\n";
echo " ".$text['label-email_connection_server']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='fax_email_connection_host' maxlength='255' value=\"$fax_email_connection_host\">&nbsp;:&nbsp;";
echo "<input class='formfld' style='width: 50px; min-width: 50px; max-width: 50px;' type='text' name='fax_email_connection_port' maxlength='5' value=\"$fax_email_connection_port\">\n";
echo "<br />\n";
echo " ".$text['description-email_connection_server']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap>\n";
echo " ".$text['label-email_connection_security']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <select class='formfld' name='fax_email_connection_security'>\n";
echo " <option value=''></option>\n";
echo " <option value='ssl' ".(($fax_email_connection_security == 'ssl') ? "selected" : null).">SSL</option>\n";
echo " <option value='tls' ".(($fax_email_connection_security == 'tls') ? "selected" : null).">TLS</option>\n";
echo " </select>\n";
echo "<br />\n";
echo " ".$text['description-email_connection_security']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap>\n";
echo " ".$text['label-email_connection_validate']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <select class='formfld' name='fax_email_connection_validate'>\n";
echo " <option value='true'>".$text['option-true']."</option>\n";
echo " <option value='false' ".(($fax_email_connection_validate == 'false') ? "selected" : null).">".$text['option-false']."</option>\n";
echo " </select>\n";
echo "<br />\n";
echo " ".$text['description-email_connection_validate']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap>\n";
echo " ".$text['label-email_connection_username']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='fax_email_connection_username' maxlength='255' value=\"$fax_email_connection_username\">\n";
echo "<br />\n";
echo " ".$text['description-email_connection_username']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap>\n";
echo " ".$text['label-email_connection_password']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='fax_email_connection_password' maxlength='255' value=\"$fax_email_connection_password\">\n";
echo "<br />\n";
echo " ".$text['description-email_connection_password']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap>\n";
echo " ".$text['label-email_connection_mailbox']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='fax_email_connection_mailbox' maxlength='255' value=\"$fax_email_connection_mailbox\">\n";
echo "<br />\n";
echo " ".$text['description-email_connection_mailbox']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "</table>\n";
echo "</div>\n";
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
//echo "<tr>\n";
//echo "<td class='vncell' valign='top' align='left' nowrap>\n";
//echo " ".$text['label-pin']."\n";
@ -780,12 +716,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
echo " ".$text['label-forward']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
if (is_numeric($fax_forward_number)) {
echo " <input class='formfld' type='text' name='fax_forward_number' maxlength='255' value=\"".format_phone($fax_forward_number)."\">\n";
}
else {
echo " <input class='formfld' type='text' name='fax_forward_number' maxlength='255' value=\"".$fax_forward_number."\">\n";
}
echo " <input class='formfld' type='text' name='fax_forward_number' maxlength='255' value=\"".((is_numeric($fax_forward_number)) ? format_phone($fax_forward_number) : $fax_forward_number)."\">\n";
echo "<br />\n";
echo "".$text['description-forward-number']."\n";
echo "</td>\n";
@ -878,10 +809,207 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
echo " </td>\n";
echo " </tr>";
echo "</table>";
echo "</form>";
echo "<br />\n";
if (function_exists("imap_open") && file_exists("fax_box_remote.php")) {
echo "<div id='advanced_email_connection' ".(($fax_email_connection_host == '') ? "style='display: none;'" : null).">\n";
echo "<b>".$text['label-advanced_settings']."</b><br><br>";
echo $text['description-advanced_settings']."<br><br>";
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo " <tr>";
echo " <td width='50%' valign='top'>";
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo "<tr>";
echo "<td colspan='2'>";
echo " <span style='font-weight: bold; color: #000;'>".$text['label-email_account_connection']."</span><br><br>";
echo "</td>";
echo "</tr>\n";
echo "<tr>\n";
echo "<td width='30%' class='vncell' valign='top' align='left' nowrap>\n";
echo " ".$text['label-email_connection_type']."\n";
echo "</td>\n";
echo "<td width='70%' class='vtable' align='left'>\n";
echo " <select class='formfld' name='fax_email_connection_type'>\n";
echo " <option value='imap'>IMAP</option>\n";
echo " <option value='pop3' ".(($fax_email_connection_type == 'pop3') ? "selected" : null).">POP3</option>\n";
echo " </select>\n";
echo "<br />\n";
echo " ".$text['description-email_connection_type']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap>\n";
echo " ".$text['label-email_connection_server']."\n";
echo "</td>\n";
echo "<td class='vtable' style='white-space: nowrap;' align='left'>\n";
echo " <input class='formfld' type='text' name='fax_email_connection_host' maxlength='255' value=\"$fax_email_connection_host\">&nbsp;:&nbsp;";
echo "<input class='formfld' style='width: 50px; min-width: 50px; max-width: 50px;' type='text' name='fax_email_connection_port' maxlength='5' value=\"$fax_email_connection_port\">\n";
echo "<br />\n";
echo " ".$text['description-email_connection_server']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap>\n";
echo " ".$text['label-email_connection_security']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <select class='formfld' name='fax_email_connection_security'>\n";
echo " <option value=''></option>\n";
echo " <option value='ssl' ".(($fax_email_connection_security == 'ssl') ? "selected" : null).">SSL</option>\n";
echo " <option value='tls' ".(($fax_email_connection_security == 'tls') ? "selected" : null).">TLS</option>\n";
echo " </select>\n";
echo "<br />\n";
echo " ".$text['description-email_connection_security']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap>\n";
echo " ".$text['label-email_connection_validate']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <select class='formfld' name='fax_email_connection_validate'>\n";
echo " <option value='true'>".$text['option-true']."</option>\n";
echo " <option value='false' ".(($fax_email_connection_validate == 'false') ? "selected" : null).">".$text['option-false']."</option>\n";
echo " </select>\n";
echo "<br />\n";
echo " ".$text['description-email_connection_validate']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap>\n";
echo " ".$text['label-email_connection_username']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='fax_email_connection_username' maxlength='255' value=\"$fax_email_connection_username\">\n";
echo "<br />\n";
echo " ".$text['description-email_connection_username']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap>\n";
echo " ".$text['label-email_connection_password']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='fax_email_connection_password' maxlength='255' value=\"$fax_email_connection_password\">\n";
echo "<br />\n";
echo " ".$text['description-email_connection_password']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap>\n";
echo " ".$text['label-email_connection_mailbox']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='fax_email_connection_mailbox' maxlength='255' value=\"$fax_email_connection_mailbox\">\n";
echo "<br />\n";
echo " ".$text['description-email_connection_mailbox']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "</table>\n";
echo " </td>";
echo " <td style='white-space: nowrap;'>&nbsp;&nbsp;&nbsp;&nbsp;</td>";
echo " <td width='50%' valign='top'>";
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo "<tr>";
echo "<td colspan='2'>";
echo " <span style='font-weight: bold; color: #000;'>".$text['label-email_remote_inbox']."</span><br><br>";
echo "</td>";
echo "</tr>\n";
echo "<tr>\n";
echo "<td width='30%' class='vncell' valign='top' align='left' nowrap>\n";
echo " ".$text['label-email_inbound_subject_tag']."\n";
echo "</td>\n";
echo "<td width='70%' class='vtable' align='left'>\n";
echo " <span style='font-size: 18px;'>[ <input class='formfld' type='text' name='fax_email_inbound_subject_tag' maxlength='255' value=\"$fax_email_inbound_subject_tag\"> ]</span>\n";
echo "<br />\n";
echo " ".$text['description-email_inbound_subject_tag']."\n";
echo "</td>\n";
echo "</tr>\n";
if (file_exists("fax_emails.php")) {
echo "<tr>";
echo "<td colspan='2'>";
echo " <br><br>";
echo " <span style='font-weight: bold; color: #000;'>".$text['label-email_email-to-fax']."</span><br><br>";
echo "</td>";
echo "</tr>\n";
echo "<tr>\n";
echo "<td width='30%' class='vncell' valign='top' align='left' nowrap>\n";
echo " ".$text['label-email_outbound_subject_tag']."\n";
echo "</td>\n";
echo "<td width='70%' class='vtable' align='left'>\n";
echo " <span style='font-size: 18px;'>[ <input class='formfld' type='text' name='fax_email_outbound_subject_tag' maxlength='255' value=\"$fax_email_outbound_subject_tag\"> ]</span>\n";
echo "<br />\n";
echo " ".$text['description-email_outbound_subject_tag']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap>\n";
echo " ".$text['label-email_outbound_authorized_senders']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left' valign='top'>\n";
echo " <table cellpadding='0' cellspacing='0' border='0'>";
echo " <tr>";
echo " <td id='authorized_senders'>";
if (substr_count($fax_email_outbound_authorized_senders, ',') > 0) {
$senders = explode(',', $fax_email_outbound_authorized_senders);
}
else {
$senders[] = $fax_email_outbound_authorized_senders;
}
$senders[] = ''; // empty one
foreach ($senders as $sender_num => $sender) {
echo " <input class='formfld' style='width: 225px; min-width: 225px; max-width: 225px; ".(($sender_num > 0) ? "margin-top: 3px;" : null)."' type='text' name='fax_email_outbound_authorized_senders[]' maxlength='255' value=\"$sender\">".((sizeof($senders) > 0 && $sender_num < (sizeof($senders) - 1) ) ? "<br>" : null);
}
echo " </td>";
echo " <td style='vertical-align: bottom;'>";
echo " <a href='javascript:void(0);' onclick='add_sender();'>$v_link_label_add</a>";
echo " </td>";
echo " </tr>";
echo " </table>";
echo " ".$text['description-email_outbound_authorized_senders']."\n";
echo "</td>\n";
echo "</tr>\n";
}
echo "</table>\n";
echo " </td>";
echo " </tr>";
echo " <tr>";
echo " <td colspan='3' style='text-align: right;'>";
echo " <br><input type='submit' name='submit' class='btn' value='".$text['button-save']."'>\n";
echo " </td>";
echo " <tr>";
echo "</table>";
echo "<br>";
echo "</div>\n";
}
echo "</form>";
//show the footer
require_once "resources/footer.php";
?>

View File

@ -24,29 +24,32 @@
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')) {
if (!$included) {
include "root.php";
require_once "resources/require.php";
require_once "resources/check_auth.php";
if (permission_exists('fax_send')) {
//access granted
}
else {
}
else {
echo "access denied";
exit;
}
}
//add multi-lingual support
//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
//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
//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")) {
@ -78,26 +81,19 @@ 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;
}
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';
}
//set the fax directory
$fax_dir = $_SESSION['switch']['storage']['dir'].'/fax'.((count($_SESSION["domains"]) > 1) ? '/'.$_SESSION['domain_name'] : null);
}
//get the fax extension
if (strlen($fax_extension) > 0) {
@ -129,50 +125,28 @@ 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 (if necessary) and send the fax
//send the fax
$continue = false;
if (!$included) {
if (($_POST['action'] == "send")) {
$fax_number = check_str($_POST['fax_number']);
if (strlen($fax_number) > 0) {
$fax_number = preg_replace("~[^0-9]~", "",$fax_number);
$fax_numbers = $_POST['fax_numbers'];
if (sizeof($fax_numbers) > 0) {
foreach ($fax_numbers as $index => $fax_number) {
$fax_numbers[$index] = preg_replace("~[^0-9]~", "", $fax_number);
if ($fax_numbers[$index] == '') { unset($fax_numbers[$index]); }
}
sort($fax_numbers);
}
$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_header = check_str($_POST['fax_header']);
$fax_sender = check_str($_POST['fax_sender']);
$fax_recipient = check_str($_POST['fax_recipient']);
@ -182,6 +156,16 @@ else {
$fax_page_size = check_str($_POST['fax_page_size']);
$fax_footer = check_str($_POST['fax_footer']);
$continue = true;
}
}
else {
//all necessary local and session variables should
//be already set by now by file including this one
$continue = true;
}
if ($continue) {
//determine page size
switch ($fax_page_size) {
case 'a4' :
@ -200,52 +184,33 @@ else {
//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;
case 'normal':
default:
$gs_r = '204x98'; $gs_g = ((int) ($page_width * 204)).'x'.((int) ($page_height * 98));
break;
}
// process uploaded files, if any
// process uploaded or emailed files (if any)
$fax_page_count = 0;
foreach ($_FILES['fax_files']['tmp_name'] as $index => $fax_tmp_name) {
if (
is_uploaded_file($fax_tmp_name)
&& $_FILES['fax_files']['error'][$index] == 0
&& $_FILES['fax_files']['size'][$index] > 0
) {
$_files = (!$included) ? $_FILES['fax_files'] : $emailed_files;
foreach ($_files['tmp_name'] as $index => $fax_tmp_name) {
$uploaded_file = (!$included) ? is_uploaded_file($fax_tmp_name) : true;
if ( $uploaded_file && $_files['error'][$index] == 0 && $_files['size'][$index] > 0 ) {
//get the file extension
$fax_file_extension = strtolower(pathinfo($_FILES['fax_files']['name'][$index], PATHINFO_EXTENSION));
$fax_file_extension = strtolower(pathinfo($_files['name'][$index], PATHINFO_EXTENSION));
if ($fax_file_extension == "tiff") { $fax_file_extension = "tif"; }
//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;
}
$disallowed_file_extensions = explode(',','sh,ssh,so,dll,exe,bat,vbs,zip,rar,z,tar,tbz,tgz,gz');
if (in_array($fax_file_extension, $disallowed_file_extensions) || $fax_file_extension == '') { continue; }
$fax_name = $_FILES['fax_files']['name'][$index];
$fax_name = $_files['name'][$index];
$fax_name = preg_replace('/\\.[^.\\s]{3,4}$/', '', $fax_name);
$fax_name = str_replace(" ", "_", $fax_name);
@ -267,8 +232,10 @@ else {
$fax_name = str_replace("+", "_", $fax_name);
$fax_name = str_replace("=", "_", $fax_name);
if (!$included) {
//move uploaded file
move_uploaded_file($_FILES['fax_files']['tmp_name'][$index], $dir_fax_temp.'/'.$fax_name.'.'.$fax_file_extension);
move_uploaded_file($_files['tmp_name'][$index], $dir_fax_temp.'/'.$fax_name.'.'.$fax_file_extension);
}
//convert uploaded file to pdf, if necessary
if ($fax_file_extension != "pdf" && $fax_file_extension != "tif") {
@ -362,7 +329,7 @@ else {
}
//header
if (isset($_SESSION['fax']['cover_header']['text'])) {
if ($fax_header != '') {
$pdf -> SetLeftMargin(0.5);
$pdf -> SetFont("times", "", 10);
$pdf -> Write(0.3, $fax_header);
@ -381,7 +348,7 @@ else {
//field labels
$pdf -> SetFont("times", "B", 12);
if ($fax_recipient != '' || $fax_number != '') {
if ($fax_recipient != '' || sizeof($fax_numbers) > 0) {
$pdf -> Text($x + 0.5, $y + 2.0, strtoupper($text['label-fax-recipient']).":");
}
if ($fax_sender != '' || $fax_caller_id_number != '') {
@ -399,14 +366,19 @@ else {
$pdf -> SetXY($x + 2.0, $y + 1.95);
if ($fax_recipient != '') {
$pdf -> Write(0.3, $fax_recipient);
if ($fax_number != '') {
$pdf -> Write(0.3, ' ('.format_phone($fax_number).')');
}
if (sizeof($fax_numbers) > 0) {
$fax_number_string = ($fax_recipient != '') ? ' (' : null;
$fax_number_string .= format_phone($fax_numbers[0]);
if (sizeof($fax_numbers) > 1) {
for ($n = 1; $n <= sizeof($fax_numbers); $n++) {
if ($n == 4) { break; }
$fax_number_string .= ', '.format_phone($fax_numbers[$n]);
}
}
else {
if ($fax_number != '') {
$pdf -> Write(0.3, format_phone($fax_number));
}
$fax_number_string .= (sizeof($fax_numbers) > 4) ? ', +'.(sizeof($fax_numbers) - 4) : null;
$fax_number_string .= ($fax_recipient != '') ? ')' : null;
$pdf -> Write(0.3, $fax_number_string);
}
$pdf -> SetXY($x + 2.0, $y + 2.25);
if ($fax_sender != '') {
@ -479,12 +451,14 @@ else {
@unlink($dir_fax_temp.'/'.$fax_instance_uuid."_temp.tif");
}
else {
if (!$included) {
//nothing to send, redirect the browser
$_SESSION['message_mood'] = 'negative';
$_SESSION["message"] = $text['message-invalid-fax'];
header("Location: fax_send.php?id=".$fax_uuid);
exit;
}
}
//preview, if requested
if ($_REQUEST['submit'] == $text['button-preview']) {
@ -519,12 +493,7 @@ else {
}
//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'];
}
$mailfrom_address = (isset($_SESSION['fax']['smtp_from']['var'])) ? $_SESSION['fax']['smtp_from']['var'] : $_SESSION['email']['smtp_from']['var'];
$sql = "select fax_email from v_fax where fax_uuid = '".$fax_uuid."'; ";
$prep_statement = $db->prepare(check_sql($sql));
@ -532,6 +501,7 @@ else {
$result = $prep_statement->fetch(PDO::FETCH_NAMED);
$mailto_address_fax = $result["fax_email"];
if (!included) {
$sql = "select contact_uuid from v_users where user_uuid = '".$_SESSION['user_uuid']."'; ";
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
@ -542,8 +512,12 @@ else {
$prep_statement->execute();
$result = $prep_statement->fetch(PDO::FETCH_NAMED);
$mailto_address_user = $result["contact_email"];
}
else {
//use email-to-fax from address
}
if ($mailto_address_user != $mailto_address_fax) {
if ($mailto_address_fax != '' && $mailto_address_user != $mailto_address_fax) {
$mailto_address = "'".$mailto_address_fax."\,".$mailto_address_user."'";
}
else {
@ -551,6 +525,7 @@ else {
}
//send the fax
foreach ($fax_numbers as $fax_number) {
$fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);
if ($fp) {
//prepare the fax command
@ -573,6 +548,7 @@ else {
$uuid = str_replace("+OK ", "", $response);
fclose($fp);
}
}
//wait for a few seconds
sleep(5);
@ -583,17 +559,22 @@ else {
exec("cp ".$dir_fax_temp.'/'.$fax_instance_uuid.".pdf ".$dir_fax_sent.'/'.$fax_instance_uuid.".pdf");
}
if (!$included) {
//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
if (!$included) {
//show the header
require_once "resources/header.php";
//javascript to toggle input/select boxes
//javascript to toggle input/select boxes, add fax numbers
echo "<script language='JavaScript' type='text/javascript' src='".PROJECT_PATH."/resources/javascript/reset_file_input.js'></script>\n";
echo "<script language='JavaScript' type='text/javascript'>";
@ -632,9 +613,15 @@ else {
echo " }";
echo " }";
echo " function add_fax_number() {\n";
echo " var newdiv = document.createElement('div');\n";
echo " newdiv.innerHTML = \"<input type='text' name='fax_numbers[]' class='formfld' style='width: 150px; min-width: 150px; max-width: 150px; margin-top: 3px;' maxlength='25'>\";";
echo " document.getElementById('fax_numbers').appendChild(newdiv);";
echo " }\n";
echo "</script>";
//fax extension form
//fax extension form
echo "<form action='' method='POST' enctype='multipart/form-data' name='frmUpload' onSubmit=''>\n";
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo "<tr>\n";
@ -753,7 +740,7 @@ else {
echo " </select>\n";
}
unset ($prep_statement);
echo " <input type='text' name='fax_recipient' id='fax_recipient' class='formfld' style='' value=''>\n";
echo " <input type='text' name='fax_recipient' id='fax_recipient' class='formfld' style='max-width: 250px;' value=''>\n";
if ($result_count > 0) {
echo " <input type='button' id='btn_toggle_recipient' class='btn' name='' alt='".$text['button-back']."' value='&#9665;' onclick=\"toggle('fax_recipient');\">\n";
}
@ -767,8 +754,16 @@ else {
echo " ".$text['label-fax-number']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input type='text' name='fax_number' id='fax_number' class='formfld' style='' value=''>\n";
echo " <br />\n";
echo " <table cellpadding='0' cellspacing='0' border='0'>";
echo " <tr>";
echo " <td id='fax_numbers'>";
echo " <input type='text' name='fax_numbers[]' id='fax_number' class='formfld' style='width: 150px; min-width: 150px; max-width: 150px;' maxlength='25'>\n";
echo " </td>";
echo " <td style='vertical-align: bottom;'>";
echo " <a href='javascript:void(0);' onclick='add_fax_number();'>$v_link_label_add</a>";
echo " </td>";
echo " </tr>";
echo " </table>";
echo " ".$text['description-fax-number']."\n";
echo "</td>\n";
echo "</tr>\n";
@ -866,11 +861,14 @@ else {
echo "</table>";
echo "</form>\n";
//show the footer
//show the footer
require_once "resources/footer.php";
// used by pdf generation
function showgrid($pdf) {
}
// used for initial element alignment during 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) {
@ -888,6 +886,6 @@ else {
$pdf -> Text($x+0.01,$y+0.035,$x.",".$y);
}
}
}
}
*/
?>

View File

@ -0,0 +1,9 @@
<?php
function object_to_array($obj) {
if (!is_object($obj) && !is_array($obj)) { return $obj; }
if (is_object($obj)) { $obj = get_object_vars($obj); }
return array_map('object_to_array', $obj);
}
?>

View File

@ -0,0 +1,48 @@
<?php
function parse_attachments($connection, $message_number, $option = '') {
$attachments = array();
$structure = imap_fetchstructure($connection, $message_number, $option);
if(isset($structure->parts) && count($structure->parts)) {
for($i = 0; $i < count($structure->parts); $i++) {
if($structure->parts[$i]->ifdparameters) {
foreach($structure->parts[$i]->dparameters as $object) {
if(strtolower($object->attribute) == 'filename') {
$attachments[$i]['is_attachment'] = true;
$attachments[$i]['filename'] = $object->value;
}
}
}
if($structure->parts[$i]->ifparameters) {
foreach($structure->parts[$i]->parameters as $object) {
if(strtolower($object->attribute) == 'name') {
$attachments[$i]['is_attachment'] = true;
$attachments[$i]['name'] = $object->value;
}
}
}
if($attachments[$i]['is_attachment']) {
$attachments[$i]['attachment'] = imap_fetchbody($connection, $message_number, $i+1, $option);
if($structure->parts[$i]->encoding == 3) { // 3 = BASE64
$attachments[$i]['attachment'] = base64_decode($attachments[$i]['attachment']);
$attachments[$i]['size'] = strlen($attachments[$i]['attachment']);
}
elseif($structure->parts[$i]->encoding == 4) { // 4 = QUOTED-PRINTABLE
$attachments[$i]['attachment'] = quoted_printable_decode($attachments[$i]['attachment']);
$attachments[$i]['size'] = strlen($attachments[$i]['attachment']);
}
}
unset($attachments[$i]['is_attachment']);
}
}
return array_values($attachments); //reindex
}
?>