mirror of
https://github.com/fusionpbx/fusionpbx.git
synced 2025-12-30 00:53:50 +00:00
Fax: Upgrade script to generate and store meta-data from existing fax files, fix Lua script to insert correct fax file path into db, JavaScript prompt corrections, adjust redirect after send to use new interface, fix delete so files on file system are removed (using path from db), fix paging and sorting on Inbox and Sent, fix TIF to PDF conversion for viewing sent/received faxes (if PDF version not present).
This commit is contained in:
@@ -160,13 +160,13 @@ $text['message-delete']['pt-br'] = "Remoção Efetuada";
|
||||
$text['message-delete']['pl'] = "Usunięto poprawnie";
|
||||
$text['message-delete']['sv-se'] = "Borttagning Klar";
|
||||
|
||||
$text['message-confirm-delete']['en-us'] = "Are you sure you want to delete this?";
|
||||
$text['message-confirm-delete']['es-cl'] = "¿Realmente desea eliminar esto?";
|
||||
$text['message-confirm-delete']['pt-pt'] = "Tem a certeza que deseja remover?";
|
||||
$text['message-confirm-delete']['fr-fr'] = "Voulez-vous vraiment supprimer cela?";
|
||||
$text['message-confirm-delete']['pt-br'] = "Deseja realmente remover isto?";
|
||||
$text['message-confirm-delete']['pl'] = "Czy na pewno chcesz to usunąć?";
|
||||
$text['message-confirm-delete']['sv-se'] = "Vill du verkligen radera detta?";
|
||||
$text['confirm-delete']['en-us'] = "Are you sure you want to delete this?";
|
||||
$text['confirm-delete']['es-cl'] = "¿Realmente desea eliminar esto?";
|
||||
$text['confirm-delete']['pt-pt'] = "Tem a certeza que deseja remover?";
|
||||
$text['confirm-delete']['fr-fr'] = "Voulez-vous vraiment supprimer cela?";
|
||||
$text['confirm-delete']['pt-br'] = "Deseja realmente remover isto?";
|
||||
$text['confirm-delete']['pl'] = "Czy na pewno chcesz to usunąć?";
|
||||
$text['confirm-delete']['sv-se'] = "Vill du verkligen radera detta?";
|
||||
|
||||
$text['message-cannot_connect']['en-us'] = "Connection Failed";
|
||||
$text['message-cannot_connect']['es-cl'] = "Error de Conexión";
|
||||
@@ -1352,14 +1352,6 @@ $text['confirm-ext']['pl'] = "Proszę wprowadzić numer wewnętrzny";
|
||||
$text['confirm-ext']['sv-se'] = "Por favor indique: Extensión ";
|
||||
$text['confirm-ext']['es-cl'] = "";
|
||||
|
||||
$text['confirm-delete']['en-us'] = "Delete Complete";
|
||||
$text['confirm-delete']['es-cl'] = "Eliminación Completada";
|
||||
$text['confirm-delete']['pt-pt'] = "Remoção Efectuada";
|
||||
$text['confirm-delete']['fr-fr'] = "Supprimé";
|
||||
$text['confirm-delete']['pt-br'] = "Deseja realmente remover isto?";
|
||||
$text['confirm-delete']['pl'] = "Czy na pewno chcesz to usunąć?";
|
||||
$text['confirm-delete']['sv-se'] = "Borttagning slutförd";
|
||||
|
||||
$text['confirm-copy-info']['en-us'] = "Do you really want to copy this?";
|
||||
$text['confirm-copy-info']['es-cl'] = "¿Desea realmente copiar esto?";
|
||||
$text['confirm-copy-info']['pt-pt'] = "Deseja realmente copiar isto?";
|
||||
|
||||
@@ -152,8 +152,14 @@ require_once "resources/paging.php";
|
||||
echo " <a href='fax_send.php?id=".$row['fax_uuid']."'>".$text['label-new']."</a> ";
|
||||
}
|
||||
if (permission_exists('fax_inbox_view')) {
|
||||
$file = ($row['fax_email_connection_host'] != '' && $row['fax_email_connection_mailbox'] != '') ? "fax_box_remote.php" : "fax_files.php";
|
||||
$box = ($row['fax_email_connection_host'] != '' && $row['fax_email_connection_mailbox'] != '') ? $row['fax_email_connection_mailbox'] : 'inbox';
|
||||
if ($row['fax_email_connection_host'] != '') {
|
||||
$file = "fax_box_remote.php";
|
||||
$box = $row['fax_email_connection_mailbox'];
|
||||
}
|
||||
else {
|
||||
$file = "fax_files.php";
|
||||
$box = 'inbox';
|
||||
}
|
||||
echo " <a href='".$file."?id=".$row['fax_uuid']."&box=".$box."'>".$text['label-inbox']."</a> ";
|
||||
}
|
||||
if (permission_exists('fax_sent_view')) {
|
||||
@@ -169,7 +175,7 @@ require_once "resources/paging.php";
|
||||
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>";
|
||||
echo "<a href='fax_delete.php?id=".$row['fax_uuid']."' alt='".$text['button-delete']."' onclick=\"return confirm('".$text['confirm-delete']."')\">$v_link_label_delete</a>";
|
||||
}
|
||||
echo " </td>\n";
|
||||
echo "</tr>\n";
|
||||
|
||||
@@ -1,478 +0,0 @@
|
||||
<?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-2015
|
||||
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_extension_view')) {
|
||||
//access granted
|
||||
}
|
||||
else {
|
||||
echo "access denied";
|
||||
exit;
|
||||
}
|
||||
|
||||
//add multi-lingual support
|
||||
$language = new text;
|
||||
$text = $language->get();
|
||||
|
||||
//get the fax_extension and save it as a variable
|
||||
if (strlen($_REQUEST["fax_extension"]) > 0) {
|
||||
$fax_extension = check_str($_REQUEST["fax_extension"]);
|
||||
}
|
||||
|
||||
//get fax extension
|
||||
if (strlen($_GET['id']) > 0) {
|
||||
//get the key
|
||||
$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_name = $row["fax_name"];
|
||||
$fax_extension = $row["fax_extension"];
|
||||
//limit to one row
|
||||
break;
|
||||
}
|
||||
unset ($prep_statement);
|
||||
}
|
||||
|
||||
//set the fax directory
|
||||
$fax_dir = $_SESSION['switch']['storage']['dir'].'/fax'.((count($_SESSION["domains"]) > 1) ? '/'.$_SESSION['domain_name'] : null);
|
||||
|
||||
//delete a fax
|
||||
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" && 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" && 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
|
||||
if ($_GET['a'] == "download") {
|
||||
session_cache_limiter('public');
|
||||
//test to see if it is in the inbox or sent directory.
|
||||
if ($_GET['type'] == "fax_inbox") {
|
||||
if (file_exists($fax_dir.'/'.check_str($_GET['ext']).'/inbox/'.check_str($_GET['filename']))) {
|
||||
$tmp_faxdownload_file = $fax_dir.'/'.check_str($_GET['ext']).'/inbox/'.check_str($_GET['filename']);
|
||||
}
|
||||
}
|
||||
else if ($_GET['type'] == "fax_sent") {
|
||||
if (file_exists($fax_dir.'/'.check_str($_GET['ext']).'/sent/'.check_str($_GET['filename']))) {
|
||||
$tmp_faxdownload_file = $fax_dir.'/'.check_str($_GET['ext']).'/sent/'.check_str($_GET['filename']);
|
||||
}
|
||||
}
|
||||
//let's see if we found it.
|
||||
if (strlen($tmp_faxdownload_file) > 0) {
|
||||
$fd = fopen($tmp_faxdownload_file, "rb");
|
||||
if ($_GET['t'] == "bin") {
|
||||
header("Content-Type: application/force-download");
|
||||
header("Content-Type: application/octet-stream");
|
||||
header("Content-Description: File Transfer");
|
||||
header('Content-Disposition: attachment; filename="'.check_str($_GET['filename']).'"');
|
||||
}
|
||||
else {
|
||||
$file_ext = substr(check_str($_GET['filename']), -3);
|
||||
if ($file_ext == "tif") {
|
||||
header("Content-Type: image/tiff");
|
||||
}
|
||||
else if ($file_ext == "png") {
|
||||
header("Content-Type: image/png");
|
||||
}
|
||||
else if ($file_ext == "jpg") {
|
||||
header('Content-Type: image/jpeg');
|
||||
}
|
||||
else if ($file_ext == "pdf") {
|
||||
header("Content-Type: application/pdf");
|
||||
}
|
||||
}
|
||||
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($tmp_faxdownload_file));
|
||||
fpassthru($fd);
|
||||
}
|
||||
else {
|
||||
echo "".$text['label-file']."";
|
||||
}
|
||||
exit;
|
||||
}
|
||||
|
||||
//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);
|
||||
}
|
||||
}
|
||||
|
||||
//show the header
|
||||
require_once "resources/header.php";
|
||||
|
||||
//show the inbox
|
||||
if ($_REQUEST['box'] == 'inbox' && permission_exists('fax_inbox_view')) {
|
||||
echo "<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n";
|
||||
echo " <tr>\n";
|
||||
echo " <td align='left' valign='top'>\n";
|
||||
echo " <b>".$text['header-inbox'].": <span style='color: #000;'>".$fax_name." (".$fax_extension.")</span></b>\n";
|
||||
echo " </td>\n";
|
||||
echo " <td width='70%' align='right' valign='top'>\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 "<br>\n";
|
||||
|
||||
$c = 0;
|
||||
$row_style["0"] = "row_style0";
|
||||
$row_style["1"] = "row_style1";
|
||||
|
||||
echo "<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n";
|
||||
echo " <tr>\n";
|
||||
echo " <th width='60%'>".$text['table-file']."</th>\n";
|
||||
echo " <th width='10%'>".$text['table-view']."</th>\n";
|
||||
echo " <th width='20%'>".$text['table-modified']."</th>\n";
|
||||
echo " <th width='10%' nowrap>".$text['table-size']."</th>\n";
|
||||
echo " </tr>";
|
||||
|
||||
if ($handle = opendir($dir_fax_inbox)) {
|
||||
//build an array of the files in the inbox
|
||||
$i = 0;
|
||||
$files = array();
|
||||
while (false !== ($file = readdir($handle))) {
|
||||
if ($file != "." && $file != ".." && is_file($dir_fax_inbox.'/'.$file)) {
|
||||
$file_path = $dir_fax_inbox.'/'.$file;
|
||||
$modified = filemtime($file_path);
|
||||
$index = $modified.$file;
|
||||
$files[$index]['file'] = $file;
|
||||
$files[$index]['name'] = substr($file, 0, -4);
|
||||
$files[$index]['ext'] = substr($file, -3);
|
||||
//$files[$index]['path'] = $file_path;
|
||||
$files[$index]['size'] = filesize($file_path);
|
||||
$files[$index]['size_bytes'] = byte_convert(filesize($file_path));
|
||||
$files[$index]['modified'] = filemtime($file_path);
|
||||
$file_name_array[$i++] = $index;
|
||||
}
|
||||
}
|
||||
closedir($handle);
|
||||
//order the index array
|
||||
sort($file_name_array,SORT_STRING);
|
||||
|
||||
//loop through the file array
|
||||
foreach($file_name_array as $i) {
|
||||
if (strtolower($files[$i]['ext']) == "tif") {
|
||||
$file = $files[$i]['file'];
|
||||
$file_name = $files[$i]['name'];
|
||||
$file_ext = $files[$i]['ext'];
|
||||
$file_modified = $files[$i]['modified'];
|
||||
$file_size_bytes = byte_convert($files[$i]['size']);
|
||||
if (!file_exists($dir_fax_inbox.'/'.$file_name.".pdf")) {
|
||||
//convert the tif to pdf
|
||||
chdir($dir_fax_inbox);
|
||||
if (is_file("/usr/local/bin/tiff2pdf")) {
|
||||
exec("/usr/local/bin/tiff2pdf -f -o ".$file_name.".pdf ".$dir_fax_inbox.'/'.$file_name.".tif");
|
||||
}
|
||||
if (is_file("/usr/bin/tiff2pdf")) {
|
||||
exec("/usr/bin/tiff2pdf -f -o ".$file_name.".pdf ".$dir_fax_inbox.'/'.$file_name.".tif");
|
||||
}
|
||||
}
|
||||
//if (!file_exists($dir_fax_inbox.'/'.$file_name.".jpg")) {
|
||||
// //convert the tif to jpg
|
||||
// chdir($dir_fax_inbox);
|
||||
// if (is_file("/usr/local/bin/tiff2rgba")) {
|
||||
// exec("/usr/local/bin/tiff2rgba ".$file_name.".tif ".$dir_fax_inbox.'/'.$file_name.".jpg");
|
||||
// }
|
||||
// if (is_file("/usr/bin/tiff2rgba")) {
|
||||
// exec("/usr/bin/tiff2rgba ".$file_name.".tif ".$dir_fax_inbox.'/'.$file_name.".jpg");
|
||||
// }
|
||||
//}
|
||||
echo "<tr>\n";
|
||||
echo " <td class='".$row_style[$c]."' ondblclick=\"\">\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_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>";
|
||||
}
|
||||
else {
|
||||
echo " \n";
|
||||
}
|
||||
echo " </td>\n";
|
||||
|
||||
//echo " <td class='".$row_style[$c]."' ondblclick=\"\">\n";
|
||||
//if (file_exists($dir_fax_inbox.'/'.$file_name.".jpg")) {
|
||||
// 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>";
|
||||
//}
|
||||
//else {
|
||||
// echo " \n";
|
||||
//}
|
||||
//echo " </td>\n";
|
||||
|
||||
echo " <td class='".$row_style[$c]."' ondblclick=\"\">\n";
|
||||
echo " ".date("F d Y H:i:s", $file_modified);
|
||||
echo " </td>\n";
|
||||
|
||||
echo " <td class='".$row_style[$c]."' ondblclick=\"\">\n";
|
||||
echo " ".$file_size_bytes;
|
||||
echo " </td>\n";
|
||||
|
||||
echo " <td valign=\"middle\" nowrap class=\"list\">\n";
|
||||
echo " <table border=\"0\" cellspacing=\"0\" cellpadding=\"1\">\n";
|
||||
echo " <tr>\n";
|
||||
if (permission_exists('fax_inbox_delete')) {
|
||||
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";
|
||||
echo " </td>\n";
|
||||
echo "</tr>\n";
|
||||
$c = ($c) ? 0 : 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
echo " <tr>\n";
|
||||
echo " <td class=\"list\" colspan=\"3\"></td>\n";
|
||||
echo " <td class=\"list\"></td>\n";
|
||||
echo " </tr>\n";
|
||||
echo "</table>\n";
|
||||
echo "<br><br><br>\n";
|
||||
if (if_group('superadmin')) {
|
||||
echo "<strong>".$text['label-location'].":</strong> ".$dir_fax_inbox;
|
||||
}
|
||||
echo "<br /><br />\n";
|
||||
}
|
||||
|
||||
//show the sent box
|
||||
if ($_REQUEST['box'] == 'sent' && permission_exists('fax_sent_view')) {
|
||||
echo "<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n";
|
||||
echo " <tr>\n";
|
||||
echo " <td align='left' valign='top'>\n";
|
||||
echo " <b>".$text['header-sent'].": <span style='color: #000;'>".$fax_name." (".$fax_extension.")</span></b>\n";
|
||||
echo " </td>\n";
|
||||
echo " <td width='70%' align='right' valign='top'>\n";
|
||||
echo " <input type='button' class='btn' name='' alt='".$text['button-back']."' onclick=\"window.location='fax.php'\" value='".$text['button-back']."'>\n";
|
||||
echo " </td>\n";
|
||||
echo " </tr>\n";
|
||||
echo "</table>\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 " </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 sent box
|
||||
$i = 0;
|
||||
$files = array();
|
||||
while (false !== ($file = readdir($handle))) {
|
||||
if ($file != "." && $file != ".." && is_file($dir_fax_sent.'/'.$file)) {
|
||||
$file_path = $dir_fax_sent.'/'.$file;
|
||||
$modified = filemtime($file_path);
|
||||
$index = $modified.$file;
|
||||
$files[$index]['file'] = $file;
|
||||
$files[$index]['name'] = substr($file, 0, -4);
|
||||
$files[$index]['ext'] = substr($file, -3);
|
||||
//$files[$index]['path'] = $file_path;
|
||||
$files[$index]['size'] = filesize($file_path);
|
||||
$files[$index]['size_bytes'] = byte_convert(filesize($file_path));
|
||||
$files[$index]['modified'] = filemtime($file_path);
|
||||
$file_name_array[$i++] = $index;
|
||||
}
|
||||
}
|
||||
closedir($handle);
|
||||
//order the index array
|
||||
rsort($file_name_array,SORT_STRING);
|
||||
|
||||
//loop through the file array
|
||||
foreach($file_name_array as $i) {
|
||||
if (strtolower($files[$i]['ext']) == "tif") {
|
||||
$file = $files[$i]['file'];
|
||||
$file_name = $files[$i]['name'];
|
||||
$file_ext = $files[$i]['ext'];
|
||||
$file_modified = $files[$i]['modified'];
|
||||
$file_size_bytes = byte_convert($files[$i]['size']);
|
||||
|
||||
if (!file_exists($dir_fax_sent.'/'.$file_name.".pdf")) {
|
||||
//convert the tif to pdf
|
||||
chdir($dir_fax_sent);
|
||||
if (is_file("/usr/local/bin/tiff2pdf")) {
|
||||
exec("/usr/local/bin/tiff2pdf -f -o ".$file_name.".pdf ".$dir_fax_sent.'/'.$file_name.".tif");
|
||||
}
|
||||
if (is_file("/usr/bin/tiff2pdf")) {
|
||||
exec("/usr/bin/tiff2pdf -f -o ".$file_name.".pdf ".$dir_fax_sent.'/'.$file_name.".tif");
|
||||
}
|
||||
}
|
||||
if (!file_exists($dir_fax_sent.'/'.$file_name.".jpg")) {
|
||||
//convert the tif to jpg
|
||||
//chdir($dir_fax_sent);
|
||||
//if (is_file("/usr/local/bin/tiff2rgba")) {
|
||||
// exec("/usr/local/bin/tiff2rgba -c jpeg -n ".$file_name.".tif ".$dir_fax_sent.'/'.$file_name.".jpg");
|
||||
//}
|
||||
//if (is_file("/usr/bin/tiff2rgba")) {
|
||||
// exec("/usr/bin/tiff2rgba -c lzw -n ".$file_name.".tif ".$dir_fax_sent.'/'.$file_name.".jpg");
|
||||
//}
|
||||
}
|
||||
echo "<tr>\n";
|
||||
echo " <td class='".$row_style[$c]."' ondblclick=\"\">\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_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>";
|
||||
}
|
||||
else {
|
||||
echo " \n";
|
||||
}
|
||||
echo " </td>\n";
|
||||
//echo " <td class='".$row_style[$c]."' ondblclick=\"\">\n";
|
||||
//if (file_exists($dir_fax_sent.'/'.$file_name.".jpg")) {
|
||||
// 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>";
|
||||
//}
|
||||
//else {
|
||||
// echo " \n";
|
||||
//}
|
||||
//echo " </td>\n";
|
||||
echo " <td class='".$row_style[$c]."' ondblclick=\"\">\n";
|
||||
echo " ".date("F d Y H:i:s", $file_modified);
|
||||
echo " </td>\n";
|
||||
|
||||
echo " <td class=\"".$row_style[$c]."\" ondblclick=\"list\">\n";
|
||||
echo " ".$file_size_bytes;
|
||||
echo " </td>\n";
|
||||
|
||||
echo " <td class='' valign=\"middle\" nowrap>\n";
|
||||
echo " <table border=\"0\" cellspacing=\"0\" cellpadding=\"1\">\n";
|
||||
echo " <tr>\n";
|
||||
if (permission_exists('fax_sent_delete')) {
|
||||
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";
|
||||
echo " </td>\n";
|
||||
echo "</tr>\n";
|
||||
$c = ($c) ? 0 : 1;
|
||||
} //check if the file is a .tif file
|
||||
}
|
||||
}
|
||||
echo " <tr>\n";
|
||||
echo " <td class=\"list\" colspan=\"3\"></td>\n";
|
||||
echo " <td class=\"list\"></td>\n";
|
||||
echo " </tr>\n";
|
||||
echo " </table>\n";
|
||||
echo " <br><br><br>\n";
|
||||
if (if_group('superadmin')) {
|
||||
echo "<strong>".$text['label-location'].":</strong> ".$dir_fax_sent;
|
||||
}
|
||||
echo "<br /><br />\n";
|
||||
}
|
||||
echo " </td>";
|
||||
echo " </tr>";
|
||||
echo "</table>";
|
||||
|
||||
//show the footer
|
||||
require_once "resources/footer.php";
|
||||
?>
|
||||
@@ -91,7 +91,7 @@ else {
|
||||
}
|
||||
|
||||
//redirect the user
|
||||
$_SESSION["message"] = $text['confirm-delete'];
|
||||
$_SESSION["message"] = $text['message-delete'];
|
||||
header("Location: fax.php");
|
||||
return;
|
||||
|
||||
|
||||
@@ -151,7 +151,7 @@ else {
|
||||
$db->exec(check_sql($sql));
|
||||
|
||||
//redirect the browser
|
||||
$_SESSION["message"] = $text['confirm-delete'];
|
||||
$_SESSION["message"] = $text['message-delete'];
|
||||
header("Location: fax_edit.php?id=".$fax_uuid);
|
||||
return;
|
||||
}
|
||||
@@ -767,7 +767,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
|
||||
echo " <tr>\n";
|
||||
echo " <td class='vtable'>".$field['username']."</td>\n";
|
||||
echo " <td>\n";
|
||||
echo " <a href='fax_edit.php?id=".$fax_uuid."&domain_uuid=".$_SESSION['domain_uuid']."&user_uuid=".$field['user_uuid']."&a=delete' alt='delete' onclick=\"return confirm('".$text['message-confirm-delete']."')\">$v_link_label_delete</a>\n";
|
||||
echo " <a href='fax_edit.php?id=".$fax_uuid."&domain_uuid=".$_SESSION['domain_uuid']."&user_uuid=".$field['user_uuid']."&a=delete' alt='delete' onclick=\"return confirm('".$text['confirm-delete']."')\">$v_link_label_delete</a>\n";
|
||||
echo " </td>\n";
|
||||
echo " </tr>\n";
|
||||
$assigned_user_uuids[] = $field['user_uuid'];
|
||||
|
||||
@@ -42,20 +42,19 @@ else {
|
||||
|
||||
//get the id
|
||||
if (isset($_REQUEST["id"])) {
|
||||
$id = check_str($_REQUEST["id"]);
|
||||
$fax_file_uuid = check_str($_REQUEST["id"]);
|
||||
}
|
||||
|
||||
//validate the id
|
||||
if (strlen($id) > 0) {
|
||||
if (strlen($fax_file_uuid) > 0) {
|
||||
//get the fax file data
|
||||
$sql = "select * from v_fax_files ";
|
||||
$sql .= "where fax_file_uuid = '$id' ";
|
||||
//echo $sql."\n";
|
||||
$sql .= "where fax_file_uuid = '".$fax_file_uuid."' ";
|
||||
$sql .= "and domain_uuid = '".$_SESSION['domain_uuid']."' ";
|
||||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
||||
foreach ($result as &$row) {
|
||||
$domain_uuid = $row["domain_uuid"];
|
||||
$fax_uuid = $row["fax_uuid"];
|
||||
$fax_mode = $row["fax_mode"];
|
||||
$fax_file_path = $row["fax_file_path"];
|
||||
@@ -63,57 +62,42 @@ else {
|
||||
}
|
||||
unset($prep_statement);
|
||||
|
||||
//get the fax file data
|
||||
$sql = "select * from v_fax_files ";
|
||||
$sql .= "where fax_uuid = '$fax_uuid' ";
|
||||
$sql .= "and domain_uuid = '$domain_uuid' ";
|
||||
//echo $sql."\n";
|
||||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
||||
foreach ($result as &$row) {
|
||||
$fax_extension = $row["fax_extension"];
|
||||
}
|
||||
unset($prep_statement);
|
||||
|
||||
//delete fax_file
|
||||
$sql = "delete from v_fax_files ";
|
||||
$sql .= "where fax_file_uuid = '$id' ";
|
||||
$sql .= "and domain_uuid = '$domain_uuid' ";
|
||||
//echo $sql."\n";
|
||||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
unset($prep_statement);
|
||||
|
||||
//set the type
|
||||
if ($fax_mode == 'rx') {
|
||||
$type = 'inbox';
|
||||
if ($fax_mode == 'rx') { $type = 'inbox'; }
|
||||
if ($fax_mode == 'tx') { $type = 'sent'; }
|
||||
|
||||
//delete fax file(s)
|
||||
if (substr_count($fax_file_path, '/temp/') > 0) {
|
||||
$fax_file_path = str_replace('/temp/', '/'.$type.'/', $fax_file_path);
|
||||
}
|
||||
if ($fax_mode == 'tx') {
|
||||
$type = 'sent';
|
||||
if (file_exists($fax_file_path)) {
|
||||
@unlink($fax_file_path);
|
||||
}
|
||||
if ($fax_file_type == 'tif') {
|
||||
$fax_file_path = str_replace('.tif', '.pdf', $fax_file_path);
|
||||
if (file_exists($fax_file_path)) {
|
||||
@unlink($fax_file_path);
|
||||
}
|
||||
}
|
||||
else if ($fax_file_type == 'pdf') {
|
||||
$fax_file_path = str_replace('.pdf', '.tif', $fax_file_path);
|
||||
if (file_exists($fax_file_path)) {
|
||||
@unlink($fax_file_path);
|
||||
}
|
||||
}
|
||||
|
||||
//set the fax directory
|
||||
$fax_dir = $_SESSION['switch']['storage']['dir'].'/fax'.((count($_SESSION["domains"]) > 1) ? '/'.$_SESSION['domain_name'] : null);
|
||||
$file = basename($row['fax_file_path']);
|
||||
$file_ext = substr($file, -3);
|
||||
$dir_fax = $fax_dir.'/'.$fax_extension.'/'.$type;
|
||||
if (strtolower(substr($file, -3)) == "tif" || strtolower(substr($file, -3)) == "pdf") {
|
||||
$file_name = substr($file, 0, (strlen($file) -4));
|
||||
}
|
||||
//delete fax file record
|
||||
$sql = "delete from v_fax_files ";
|
||||
$sql .= "where fax_file_uuid = '".$fax_file_uuid."' ";
|
||||
$sql .= "and domain_uuid = '".$_SESSION['domain_uuid']."' ";
|
||||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
unset($prep_statement);
|
||||
|
||||
//if the file does not exist then remove temp/ out of the path
|
||||
if (!file_exists($fax_file_path)) {
|
||||
$file = str_replace("temp/", $type."/", $file);
|
||||
}
|
||||
|
||||
//delete the files
|
||||
unlink($dir_fax.'/'.$file_name.'.tif');
|
||||
unlink($dir_fax.'/'.$file_name.'.pdf');
|
||||
$_SESSION['message'] = $text['message-delete'];
|
||||
}
|
||||
|
||||
//redirect the user
|
||||
$_SESSION['message'] = $text['message-delete'];
|
||||
header('Location: fax_files.php?id='.$fax_uuid.'&box='.$type);
|
||||
|
||||
?>
|
||||
@@ -51,13 +51,13 @@ else {
|
||||
}
|
||||
if (if_group("superadmin") || if_group("admin")) {
|
||||
//show all fax extensions
|
||||
$sql = "select * from v_fax ";
|
||||
$sql = "select fax_name, fax_extension 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 = "select fax_name, fax_extension 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' ";
|
||||
@@ -88,6 +88,56 @@ else {
|
||||
//set the fax directory
|
||||
$fax_dir = $_SESSION['switch']['storage']['dir'].'/fax'.((count($_SESSION["domains"]) > 1) ? '/'.$_SESSION['domain_name'] : null);
|
||||
|
||||
//download the fax
|
||||
if ($_GET['a'] == "download") {
|
||||
session_cache_limiter('public');
|
||||
//test to see if it is in the inbox or sent directory.
|
||||
if ($_GET['type'] == "fax_inbox") {
|
||||
if (file_exists($fax_dir.'/'.check_str($_GET['ext']).'/inbox/'.check_str($_GET['filename']))) {
|
||||
$tmp_faxdownload_file = $fax_dir.'/'.check_str($_GET['ext']).'/inbox/'.check_str($_GET['filename']);
|
||||
}
|
||||
}
|
||||
else if ($_GET['type'] == "fax_sent") {
|
||||
if (file_exists($fax_dir.'/'.check_str($_GET['ext']).'/sent/'.check_str($_GET['filename']))) {
|
||||
$tmp_faxdownload_file = $fax_dir.'/'.check_str($_GET['ext']).'/sent/'.check_str($_GET['filename']);
|
||||
}
|
||||
}
|
||||
//let's see if we found it.
|
||||
if (strlen($tmp_faxdownload_file) > 0) {
|
||||
$fd = fopen($tmp_faxdownload_file, "rb");
|
||||
if ($_GET['t'] == "bin") {
|
||||
header("Content-Type: application/force-download");
|
||||
header("Content-Type: application/octet-stream");
|
||||
header("Content-Description: File Transfer");
|
||||
header('Content-Disposition: attachment; filename="'.check_str($_GET['filename']).'"');
|
||||
}
|
||||
else {
|
||||
$file_ext = substr(check_str($_GET['filename']), -3);
|
||||
if ($file_ext == "tif") {
|
||||
header("Content-Type: image/tiff");
|
||||
}
|
||||
else if ($file_ext == "png") {
|
||||
header("Content-Type: image/png");
|
||||
}
|
||||
else if ($file_ext == "jpg") {
|
||||
header('Content-Type: image/jpeg');
|
||||
}
|
||||
else if ($file_ext == "pdf") {
|
||||
header("Content-Type: application/pdf");
|
||||
}
|
||||
}
|
||||
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($tmp_faxdownload_file));
|
||||
fpassthru($fd);
|
||||
}
|
||||
else {
|
||||
echo "".$text['label-file']."";
|
||||
}
|
||||
exit;
|
||||
}
|
||||
|
||||
//get the fax extension
|
||||
if (strlen($fax_extension) > 0) {
|
||||
//set the fax directories. example /usr/local/freeswitch/storage/fax/329/inbox
|
||||
@@ -122,17 +172,8 @@ else {
|
||||
require_once "resources/header.php";
|
||||
require_once "resources/paging.php";
|
||||
|
||||
//show the content
|
||||
echo "<div align='center'>";
|
||||
echo "<table width='100%' border='0' cellpadding='0' cellspacing='2'>\n";
|
||||
echo "<tr class='border'>\n";
|
||||
echo " <td align=\"center\">\n";
|
||||
echo " <br />";
|
||||
|
||||
//show the header
|
||||
//$text['title-fax_files']
|
||||
//$text['description-fax_file']
|
||||
echo "<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n";
|
||||
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
|
||||
echo " <tr>\n";
|
||||
echo " <td align='left' valign='top'>\n";
|
||||
if ($_REQUEST['box'] == 'inbox' && permission_exists('fax_inbox_view')) {
|
||||
@@ -159,7 +200,6 @@ else {
|
||||
if ($_REQUEST['box'] == 'sent') {
|
||||
$sql .= "and fax_mode = 'tx' ";
|
||||
}
|
||||
if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; }
|
||||
$prep_statement = $db->prepare($sql);
|
||||
if ($prep_statement) {
|
||||
$prep_statement->execute();
|
||||
@@ -173,12 +213,12 @@ else {
|
||||
}
|
||||
|
||||
//prepare to page the results
|
||||
$rows_per_page = 10;
|
||||
$param = "";
|
||||
$rows_per_page = 50;
|
||||
$param = "&id=".$_GET['id']."&box=".$_GET['box']."&order_by=".$_GET['order_by']."&order=".$_GET['order'];
|
||||
$page = $_GET['page'];
|
||||
if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; }
|
||||
list($paging_controls, $rows_per_page, $var3) = paging($num_rows, $param, $rows_per_page);
|
||||
$offset = $rows_per_page * $page;
|
||||
if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; }
|
||||
list($paging_controls, $rows_per_page, $var3) = paging($num_rows, $param, $rows_per_page);
|
||||
$offset = $rows_per_page * $page;
|
||||
|
||||
//get the list
|
||||
$sql = "select * from v_fax_files ";
|
||||
@@ -190,7 +230,7 @@ else {
|
||||
if ($_REQUEST['box'] == 'sent') {
|
||||
$sql .= "and fax_mode = 'tx' ";
|
||||
}
|
||||
if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; }
|
||||
$sql .= "order by ".((strlen($order_by) > 0) ? $order_by.' '.$order : "fax_date desc")." ";
|
||||
$sql .= "limit $rows_per_page offset $offset ";
|
||||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
@@ -203,21 +243,18 @@ else {
|
||||
$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_caller_id_name', $text['label-fax_caller_id_name'], $order_by, $order, "&id=".$_GET['id']."&box=".$_GET['box']."&page=".$_GET['page']);
|
||||
echo th_order_by('fax_caller_id_number', $text['label-fax_caller_id_number'], $order_by, $order, "&id=".$_GET['id']."&box=".$_GET['box']."&page=".$_GET['page']);
|
||||
if ($_REQUEST['box'] == 'sent') {
|
||||
echo th_order_by('fax_destination', $text['label-fax_destination'], $order_by, $order, "&id=".$_GET['id']."&box=".$_GET['box']."&page=".$_GET['page']);
|
||||
}
|
||||
echo "<th width=''>".$text['table-file']."</th>\n";
|
||||
echo "<th width='10%'>".$text['table-view']."</th>\n";
|
||||
echo th_order_by('fax_number', $text['label-fax_number'], $order_by, $order);
|
||||
//echo th_order_by('fax_file_type', $text['label-fax_file_type'], $order_by, $order);
|
||||
//echo th_order_by('fax_file_path', $text['label-fax_file_path'], $order_by, $order);
|
||||
echo th_order_by('fax_caller_id_name', $text['label-fax_caller_id_name'], $order_by, $order);
|
||||
echo th_order_by('fax_caller_id_number', $text['label-fax_caller_id_number'], $order_by, $order);
|
||||
echo th_order_by('fax_date', $text['label-fax_date'], $order_by, $order);
|
||||
//echo th_order_by('fax_epoch', $text['label-fax_epoch'], $order_by, $order);
|
||||
//echo th_order_by('fax_base64', $text['label-fax_base64'], $order_by, $order);
|
||||
echo "<td> </td>\n";
|
||||
echo "<tr>\n";
|
||||
echo th_order_by('fax_date', $text['label-fax_date'], $order_by, $order, "&id=".$_GET['id']."&box=".$_GET['box']."&page=".$_GET['page']);
|
||||
echo "<td style='width: 25px;' class='list_control_icons'> </td>\n";
|
||||
echo "</tr>\n";
|
||||
if ($result_count > 0) {
|
||||
foreach($result as $row) {
|
||||
$file = basename($row['fax_file_path']);
|
||||
@@ -239,43 +276,85 @@ else {
|
||||
file_put_contents($dir_fax_sent.'/'.$file, base64_decode($row['fax_base64']));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
//convert the tif to pdf
|
||||
if (!file_exists($dir_fax_inbox.'/'.$file_name.".pdf")) {
|
||||
if ($_REQUEST['box'] == 'inbox' && permission_exists('fax_inbox_view')) {
|
||||
chdir($dir_fax_inbox);
|
||||
if (is_file("/usr/local/bin/tiff2pdf")) {
|
||||
exec("/usr/local/bin/tiff2pdf -f -o ".$file_name.".pdf ".$dir_fax_inbox.'/'.$file_name.".tif");
|
||||
}
|
||||
if (is_file("/usr/bin/tiff2pdf")) {
|
||||
exec("/usr/bin/tiff2pdf -f -o ".$file_name.".pdf ".$dir_fax_inbox.'/'.$file_name.".tif");
|
||||
}
|
||||
}
|
||||
if ($_REQUEST['box'] == 'sent' && permission_exists('fax_sent_view')) {
|
||||
chdir($dir_fax_sent);
|
||||
if (is_file("/usr/local/bin/tiff2pdf")) {
|
||||
exec("/usr/local/bin/tiff2pdf -f -o ".$file_name.".pdf ".$dir_fax_sent.'/'.$file_name.".tif");
|
||||
}
|
||||
if (is_file("/usr/bin/tiff2pdf")) {
|
||||
exec("/usr/bin/tiff2pdf -f -o ".$file_name.".pdf ".$dir_fax_sent.'/'.$file_name.".tif");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
echo "<tr ".$tr_link.">\n";
|
||||
echo "<tr>\n";
|
||||
echo " <td class='".$row_style[$c]."' ondblclick=\"\">\n";
|
||||
//convert the tif to pdf
|
||||
unset($dir_fax);
|
||||
if ($_REQUEST['box'] == 'inbox' && permission_exists('fax_inbox_view')) {
|
||||
echo " <a href=\"fax_box.php?id=".$fax_uuid."&a=download&type=fax_inbox&t=bin&ext=".urlencode($fax_extension)."&filename=".urlencode($file)."\">\n";
|
||||
if (!file_exists($dir_fax_inbox.'/'.$file_name.".pdf")) {
|
||||
$dir_fax = $dir_fax_inbox;
|
||||
}
|
||||
}
|
||||
if ($_REQUEST['box'] == 'sent' && permission_exists('fax_sent_view')) {
|
||||
echo " <a href=\"fax_box.php?id=".$fax_uuid."&a=download&type=fax_sent&t=bin&ext=".urlencode($fax_extension)."&filename=".urlencode($file)."\">\n";
|
||||
if (!file_exists($dir_fax_sent.'/'.$file_name.".pdf")) {
|
||||
$dir_fax = $dir_fax_sent;
|
||||
}
|
||||
}
|
||||
if ($dir_fax != '') {
|
||||
chdir($dir_fax);
|
||||
//get fax resolution (ppi, W & H)
|
||||
$resp = exec("tiffinfo ".$file_name.".tif | grep 'Resolution:'");
|
||||
$resp_array = explode(' ', trim($resp));
|
||||
$ppi_w = (int) $resp_array[1];
|
||||
$ppi_h = (int) $resp_array[2];
|
||||
unset($resp_array);
|
||||
$gs_r = $ppi_w.'x'.$ppi_h; //used by ghostscript
|
||||
//get page dimensions/size (pixels/inches, W & H)
|
||||
$resp = exec("tiffinfo ".$file_name.".tif | grep 'Image Width:'");
|
||||
$resp_array = explode(' ', trim($resp));
|
||||
$pix_w = $resp_array[2];
|
||||
$pix_h = $resp_array[5];
|
||||
unset($resp_array);
|
||||
$gs_g = $pix_w.'x'.$pix_h; //used by ghostscript
|
||||
$page_width = $pix_w / $ppi_w;
|
||||
$page_height = $pix_h / $ppi_h;
|
||||
if ($page_width > 8.4 && $page_height > 13) {
|
||||
$page_width = 8.5;
|
||||
$page_height = 14;
|
||||
$page_size = 'legal';
|
||||
}
|
||||
else if ($page_width > 8.4 && $page_height < 12) {
|
||||
$page_width = 8.5;
|
||||
$page_height = 11;
|
||||
$page_size = 'letter';
|
||||
}
|
||||
else if ($page_width < 8.4 && $page_height > 11) {
|
||||
$page_width = 8.3;
|
||||
$page_height = 11.7;
|
||||
$page_size = 'a4';
|
||||
}
|
||||
//generate pdf (a work around, as tiff2pdf improperly inverts the colors)
|
||||
$cmd_tif2pdf = "tiff2pdf -i -u i -p ".$page_size." -w ".$page_width." -l ".$page_height." -f -o ".$dir_fax_temp.'/'.$file_name.".pdf ".$dir_fax.'/'.$file_name.".tif";
|
||||
//echo $cmd_tif2pdf."<br>";
|
||||
exec($cmd_tif2pdf);
|
||||
chdir($dir_fax_temp);
|
||||
$cmd_pdf2tif = "gs -q -sDEVICE=tiffg3 -r".$gs_r." -g".$gs_g." -dNOPAUSE -sOutputFile=".$file_name."_temp.tif -- ".$file_name.".pdf -c quit";
|
||||
//echo $cmd_pdf2tif."<br>";
|
||||
exec($cmd_pdf2tif); //convert pdf to tif
|
||||
@unlink($dir_fax_temp.'/'.$file_name.".pdf");
|
||||
$cmd_tif2pdf = "tiff2pdf -i -u i -p ".$page_size." -w ".$page_width." -l ".$page_height." -f -o ".$dir_fax.'/'.$file_name.".pdf ".$dir_fax_temp.'/'.$file_name."_temp.tif";
|
||||
//echo $cmd_tif2pdf."<br>";
|
||||
exec($cmd_tif2pdf);
|
||||
@unlink($dir_fax_temp.'/'.$file_name."_temp.tif");
|
||||
}
|
||||
echo "</td></tr>";
|
||||
echo "<tr ".$tr_link.">\n";
|
||||
echo " <td valign='top' class='".$row_style[$c]."'>".$row['fax_caller_id_name']." </td>\n";
|
||||
echo " <td valign='top' class='".$row_style[$c]."'>".format_phone($row['fax_caller_id_number'])." </td>\n";
|
||||
if ($_REQUEST['box'] == 'sent') {
|
||||
echo " <td valign='top' class='".$row_style[$c]."'>".format_phone($row['fax_destination'])." </td>\n";
|
||||
}
|
||||
echo " <td class='".$row_style[$c]."' ondblclick=\"\">\n";
|
||||
if ($_REQUEST['box'] == 'inbox' && permission_exists('fax_inbox_view')) {
|
||||
echo " <a href=\"fax_files.php?id=".$fax_uuid."&a=download&type=fax_inbox&t=bin&ext=".urlencode($fax_extension)."&filename=".urlencode($file)."\">\n";
|
||||
}
|
||||
if ($_REQUEST['box'] == 'sent' && permission_exists('fax_sent_view')) {
|
||||
echo " <a href=\"fax_files.php?id=".$fax_uuid."&a=download&type=fax_sent&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";
|
||||
echo " <td class='".$row_style[$c]."' ondblclick=''>\n";
|
||||
if ($_REQUEST['box'] == 'inbox') {
|
||||
$dir_fax = $dir_fax_inbox;
|
||||
}
|
||||
@@ -284,65 +363,33 @@ else {
|
||||
}
|
||||
if (file_exists($dir_fax.'/'.$file_name.".pdf")) {
|
||||
if ($_REQUEST['box'] == 'inbox' && permission_exists('fax_inbox_view')) {
|
||||
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 " <a href=\"fax_files.php?id=".$fax_uuid."&a=download&type=fax_inbox&t=bin&ext=".urlencode($fax_extension)."&filename=".urlencode($file_name).".pdf\">PDF</a>\n";
|
||||
}
|
||||
if ($_REQUEST['box'] == 'sent' && permission_exists('fax_sent_view')) {
|
||||
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 " <a href=\"fax_files.php?id=".$fax_uuid."&a=download&type=fax_sent&t=bin&ext=".urlencode($fax_extension)."&filename=".urlencode($file_name).".pdf\">PDF</a>\n";
|
||||
}
|
||||
echo " PDF";
|
||||
echo " </a>";
|
||||
}
|
||||
else {
|
||||
echo " \n";
|
||||
}
|
||||
echo " </td>\n";
|
||||
//echo " <td valign='top' class='".$row_style[$c]."'>".basename($row['fax_file_path'])." </td>\n";
|
||||
//echo " <td valign='top' class='".$row_style[$c]."'>PDF </td>\n";
|
||||
echo " <td valign='top' class='".$row_style[$c]."'>".$row['fax_number']." </td>\n";
|
||||
//echo " <td valign='top' class='".$row_style[$c]."'>".$row['fax_file_type']." </td>\n";
|
||||
echo " <td valign='top' class='".$row_style[$c]."'>".$row['fax_caller_id_name']." </td>\n";
|
||||
echo " <td valign='top' class='".$row_style[$c]."'>".$row['fax_caller_id_number']." </td>\n";
|
||||
echo " <td valign='top' class='".$row_style[$c]."'>".date("F d Y H:i:s", strtotime($row['fax_date']))." </td>\n";
|
||||
//echo " <td valign='top' class='".$row_style[$c]."'>".$row['fax_epoch']." </td>\n";
|
||||
//echo " <td valign='top' class='".$row_style[$c]."'>".$row['fax_base64']." </td>\n";
|
||||
echo " <td>";
|
||||
//if (permission_exists('fax_file_edit')) {
|
||||
// echo "<a href='fax_file_edit.php?id=".$row['fax_file_uuid']."' alt='".$text['button-edit']."'>$v_link_label_edit</a>";
|
||||
//}
|
||||
echo " <td style='width: 25px;' class='list_control_icons'>";
|
||||
if (permission_exists('fax_file_delete')) {
|
||||
echo "<a href='fax_file_delete.php?id=".$row['fax_file_uuid']."' alt='".$text['button-delete']."' onclick=\"return confirm('".$text['confirm-delete']."')\">$v_link_label_delete</a>";
|
||||
}
|
||||
echo " </td>\n";
|
||||
echo "</tr>\n";
|
||||
if ($c==0) { $c=1; } else { $c=0; }
|
||||
$c = ($c) ? 0 : 1;
|
||||
} //end foreach
|
||||
unset($sql, $result, $row_count);
|
||||
} //end if results
|
||||
|
||||
//show the paging controls
|
||||
echo "<tr>\n";
|
||||
echo "<td colspan='11' align='left'>\n";
|
||||
echo " <table width='100%' cellpadding='0' cellspacing='0'>\n";
|
||||
echo " <tr>\n";
|
||||
echo " <td width='33.3%' nowrap='nowrap'> </td>\n";
|
||||
echo " <td width='33.3%' align='center' nowrap='nowrap'>$paging_controls</td>\n";
|
||||
echo " <td class='list_control_icons'>";
|
||||
echo " ";
|
||||
echo " </td>\n";
|
||||
echo " </tr>\n";
|
||||
echo " </table>\n";
|
||||
echo "</td>\n";
|
||||
echo "</tr>\n";
|
||||
|
||||
echo "</table>";
|
||||
echo "</div>";
|
||||
echo "<br /><br />";
|
||||
|
||||
//close the table and div
|
||||
echo "</td>";
|
||||
echo "</tr>";
|
||||
echo "</table>";
|
||||
echo "</div>";
|
||||
echo "<div align='center'>".$paging_controls."</div>\n";
|
||||
echo "<br /><br />";
|
||||
|
||||
//include the footer
|
||||
|
||||
@@ -187,11 +187,13 @@ else {
|
||||
|
||||
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
|
||||
echo " <tr>\n";
|
||||
echo " <th width='30%'>".$text['label-email_received']."</th>\n";
|
||||
echo " <th width='60%'>".$text['label-email-fax']."</th>\n";
|
||||
echo " <th width='10%'>".$text['label-email_size']."</th>\n";
|
||||
echo " <th>".$text['label-fax_caller_id_name']."</th>\n";
|
||||
echo " <th>".$text['label-fax_caller_id_number']."</th>\n";
|
||||
echo " <th>".$text['table-file']."</th>\n";
|
||||
echo " <th>".$text['label-email_size']."</th>\n";
|
||||
echo " <th>".$text['label-email_received']."</th>\n";
|
||||
if (permission_exists('fax_inbox_delete')) {
|
||||
echo " <td class='list_control_icons'> </td>\n";
|
||||
echo " <td style='width: 25px;' class='list_control_icons'> </td>\n";
|
||||
}
|
||||
echo " </tr>";
|
||||
|
||||
@@ -202,19 +204,24 @@ else {
|
||||
foreach ($emails as $email_id) {
|
||||
$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";
|
||||
echo " <td valign='top' class='".$row_style[$c]."'><a href='?id=".$fax_uuid."&email_id=".$email_id."&download'>".$attachment[0]['filename']."</a></td>\n";
|
||||
echo " <td valign='top' class='".$row_style[$c]."'>".byte_convert(strlen($attachment[0]['attachment']))."</td>\n";
|
||||
$file_name = $attachment[0]['filename'];
|
||||
$caller_id_name = substr($file_name, 0, strpos($file_name, '-'));
|
||||
$caller_id_number = (is_numeric($caller_id_name)) ? format_phone((int) $caller_id_name) : null;
|
||||
echo " <tr ".(($metadata[0]['seen'] == 0) ? "style='font-weight: bold;'" : null).">\n";
|
||||
echo " <td valign='top' class='".$row_style[$c]."'>".$caller_id_name."</td>\n";
|
||||
echo " <td valign='top' class='".$row_style[$c]."'>".$caller_id_number."</td>\n";
|
||||
echo " <td valign='top' class='".$row_style[$c]."'><a href='?id=".$fax_uuid."&email_id=".$email_id."&download'>".$file_name."</a></td>\n";
|
||||
echo " <td valign='top' class='".$row_style[$c]."'>".byte_convert(strlen($attachment[0]['attachment']))."</td>\n";
|
||||
echo " <td valign='top' class='".$row_style[$c]."'>".$metadata[0]['date']."</td>\n";
|
||||
if (permission_exists('fax_inbox_delete')) {
|
||||
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 " <td style='width: 25px;' class='list_control_icons'><a href='?id=".$fax_uuid."&email_id=".$email_id."&delete' onclick=\"return confirm('".$text['confirm-delete']."')\">".$v_link_label_delete."</a></td>\n";
|
||||
}
|
||||
echo "</tr>\n";
|
||||
echo " </tr>\n";
|
||||
// $fax_message = imap_fetchbody($connection, $email_id, '1.1', FT_UID);
|
||||
// if ($fax_message == '') {
|
||||
// $fax_message = imap_fetchbody($connection, $email_id, '1', FT_UID);
|
||||
// }
|
||||
$c = ($c) ? 0 : 1;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -196,14 +196,17 @@ if (!$included) {
|
||||
//set resolution
|
||||
switch ($fax_resolution) {
|
||||
case 'fine':
|
||||
$gs_r = '204x196'; $gs_g = ((int) ($page_width * 204)).'x'.((int) ($page_height * 196));
|
||||
$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));
|
||||
$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));
|
||||
$gs_r = '204x98';
|
||||
$gs_g = ((int) ($page_width * 204)).'x'.((int) ($page_height * 98));
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -573,7 +576,7 @@ if (!$included) {
|
||||
if (!$included) {
|
||||
//redirect the browser
|
||||
$_SESSION["message"] = $response;
|
||||
header("Location: fax_box.php?id=".$fax_uuid."&box=sent");
|
||||
header("Location: fax_files.php?id=".$fax_uuid."&box=sent");
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
@@ -340,6 +340,7 @@
|
||||
table.insert(sql, "'" .. sip_to_user .. "', ");
|
||||
end
|
||||
table.insert(sql, "'tif', ");
|
||||
fax_file = string.gsub(fax_file, '/temp/', '/sent/');
|
||||
table.insert(sql, "'" .. fax_file .. "', ");
|
||||
table.insert(sql, "'" .. origination_caller_id_name .. "', ");
|
||||
table.insert(sql, "'" .. origination_caller_id_number .. "', ");
|
||||
|
||||
Reference in New Issue
Block a user