\r\n --> \n
Cause all the .php files containing lines ending with \r\n to instead end with \n.
DYI with:
find fusionpbx -type f -name '*.php' -exec dos2unix '{}' \;
This commit is contained in:
+174
-174
@@ -1,175 +1,175 @@
|
||||
<?php
|
||||
|
||||
if ($domains_processed == 1) {
|
||||
|
||||
//define array of settings
|
||||
$x = 0;
|
||||
$array[$x]['default_setting_category'] = 'fax';
|
||||
$array[$x]['default_setting_subcategory'] = 'allowed_extension';
|
||||
$array[$x]['default_setting_name'] = 'array';
|
||||
$array[$x]['default_setting_value'] = '.pdf';
|
||||
$array[$x]['default_setting_enabled'] = 'true';
|
||||
$array[$x]['default_setting_description'] = '';
|
||||
$x = 0;
|
||||
$array[$x]['default_setting_category'] = 'fax';
|
||||
$array[$x]['default_setting_subcategory'] = 'allowed_extension';
|
||||
$array[$x]['default_setting_name'] = 'array';
|
||||
$array[$x]['default_setting_value'] = '.tif';
|
||||
$array[$x]['default_setting_enabled'] = 'true';
|
||||
$array[$x]['default_setting_description'] = '';
|
||||
$x = 0;
|
||||
$array[$x]['default_setting_category'] = 'fax';
|
||||
$array[$x]['default_setting_subcategory'] = 'allowed_extension';
|
||||
$array[$x]['default_setting_name'] = 'array';
|
||||
$array[$x]['default_setting_value'] = '.tiff';
|
||||
$array[$x]['default_setting_enabled'] = 'true';
|
||||
$array[$x]['default_setting_description'] = '';
|
||||
$x++;
|
||||
$array[$x]['default_setting_category'] = 'fax';
|
||||
$array[$x]['default_setting_subcategory'] = 'cover_logo';
|
||||
$array[$x]['default_setting_name'] = 'text';
|
||||
$array[$x]['default_setting_value'] = '';
|
||||
$array[$x]['default_setting_enabled'] = 'false';
|
||||
$array[$x]['default_setting_description'] = 'Path to image/logo file displayed in the header of the cover sheet.';
|
||||
$x++;
|
||||
$array[$x]['default_setting_category'] = 'fax';
|
||||
$array[$x]['default_setting_subcategory'] = 'cover_font';
|
||||
$array[$x]['default_setting_name'] = 'text';
|
||||
$array[$x]['default_setting_value'] = 'times';
|
||||
$array[$x]['default_setting_enabled'] = 'false';
|
||||
$array[$x]['default_setting_description'] = 'Font used to generate cover page. Can be full path to .ttf file or font name alredy installed.';
|
||||
$x++;
|
||||
$array[$x]['default_setting_category'] = 'fax';
|
||||
$array[$x]['default_setting_subcategory'] = 'cover_footer';
|
||||
$array[$x]['default_setting_name'] = 'text';
|
||||
$array[$x]['default_setting_value'] = "The information contained in this facsimile is intended for the sole confidential use of the recipient(s) designated above, and may contain confidential and legally privileged information. If you are not the intended recipient, you are hereby notified that the review, disclosure, dissemination, distribution, copying, duplication in any form, and taking of any action in regards to the contents of this document - except with respect to its direct delivery to the intended recipient - is strictly prohibited. Please notify the sender immediately and destroy this cover sheet and all attachments. If stored or viewed electronically, please permanently delete it from your system.";
|
||||
$array[$x]['default_setting_enabled'] = 'true';
|
||||
$array[$x]['default_setting_description'] = 'Notice displayed in the footer of the cover sheet.';
|
||||
$x++;
|
||||
$array[$x]['default_setting_category'] = 'fax';
|
||||
$array[$x]['default_setting_subcategory'] = 'cover_header';
|
||||
$array[$x]['default_setting_name'] = 'text';
|
||||
$array[$x]['default_setting_value'] = '';
|
||||
$array[$x]['default_setting_enabled'] = 'false';
|
||||
$array[$x]['default_setting_description'] = 'Default information displayed beneath the logo in the header of the cover sheet.';
|
||||
$x++;
|
||||
$array[$x]['default_setting_category'] = 'fax';
|
||||
$array[$x]['default_setting_subcategory'] = 'page_size';
|
||||
$array[$x]['default_setting_name'] = 'text';
|
||||
$array[$x]['default_setting_value'] = 'letter';
|
||||
$array[$x]['default_setting_enabled'] = 'true';
|
||||
$array[$x]['default_setting_description'] = 'Set the default page size of new faxes.';
|
||||
$x++;
|
||||
$array[$x]['default_setting_category'] = 'fax';
|
||||
$array[$x]['default_setting_subcategory'] = 'resolution';
|
||||
$array[$x]['default_setting_name'] = 'text';
|
||||
$array[$x]['default_setting_value'] = 'normal';
|
||||
$array[$x]['default_setting_enabled'] = 'true';
|
||||
$array[$x]['default_setting_description'] = 'Set the default transmission quality of new faxes.';
|
||||
$x++;
|
||||
$array[$x]['default_setting_category'] = 'fax';
|
||||
$array[$x]['default_setting_subcategory'] = 'variable';
|
||||
$array[$x]['default_setting_name'] = 'array';
|
||||
$array[$x]['default_setting_value'] = 'fax_enable_t38=true';
|
||||
$array[$x]['default_setting_enabled'] = 'true';
|
||||
$array[$x]['default_setting_description'] = 'Enable T.38';
|
||||
$x++;
|
||||
$array[$x]['default_setting_category'] = 'fax';
|
||||
$array[$x]['default_setting_subcategory'] = 'variable';
|
||||
$array[$x]['default_setting_name'] = 'array';
|
||||
$array[$x]['default_setting_value'] = 'fax_enable_t38_request=false';
|
||||
$array[$x]['default_setting_enabled'] = 'true';
|
||||
$array[$x]['default_setting_description'] = 'Send a T38 reinvite when a fax tone is detected.';
|
||||
$x++;
|
||||
$array[$x]['default_setting_category'] = 'fax';
|
||||
$array[$x]['default_setting_subcategory'] = 'keep_local';
|
||||
$array[$x]['default_setting_name'] = 'boolean';
|
||||
$array[$x]['default_setting_value'] = 'true';
|
||||
$array[$x]['default_setting_enabled'] = 'true';
|
||||
$array[$x]['default_setting_description'] = 'Keep the file after sending or receiving the fax.';
|
||||
$x++;
|
||||
$array[$x]['default_setting_category'] = 'fax';
|
||||
$array[$x]['default_setting_subcategory'] = 'send_mode';
|
||||
$array[$x]['default_setting_name'] = 'text';
|
||||
$array[$x]['default_setting_value'] = 'queue';
|
||||
$array[$x]['default_setting_enabled'] = 'false';
|
||||
$array[$x]['default_setting_description'] = '';
|
||||
$x++;
|
||||
$array[$x]['default_setting_category'] = 'fax';
|
||||
$array[$x]['default_setting_subcategory'] = 'send_retry_limit';
|
||||
$array[$x]['default_setting_name'] = 'numeric';
|
||||
$array[$x]['default_setting_value'] = '5';
|
||||
$array[$x]['default_setting_enabled'] = 'true';
|
||||
$array[$x]['default_setting_description'] = 'Number of attempts to send fax (count only calls with answer)';
|
||||
$x++;
|
||||
$array[$x]['default_setting_category'] = 'fax';
|
||||
$array[$x]['default_setting_subcategory'] = 'send_retry_interval';
|
||||
$array[$x]['default_setting_name'] = 'numeric';
|
||||
$array[$x]['default_setting_value'] = '15';
|
||||
$array[$x]['default_setting_enabled'] = 'true';
|
||||
$array[$x]['default_setting_description'] = 'Delay before we make next call after answered call';
|
||||
$x++;
|
||||
$array[$x]['default_setting_category'] = 'fax';
|
||||
$array[$x]['default_setting_subcategory'] = 'send_no_answer_retry_limit';
|
||||
$array[$x]['default_setting_name'] = 'numeric';
|
||||
$array[$x]['default_setting_value'] = '3';
|
||||
$array[$x]['default_setting_enabled'] = 'true';
|
||||
$array[$x]['default_setting_description'] = 'Number of unanswered attempts in sequence';
|
||||
$x++;
|
||||
$array[$x]['default_setting_category'] = 'fax';
|
||||
$array[$x]['default_setting_subcategory'] = 'send_no_answer_retry_interval';
|
||||
$array[$x]['default_setting_name'] = 'numeric';
|
||||
$array[$x]['default_setting_value'] = '30';
|
||||
$array[$x]['default_setting_enabled'] = 'true';
|
||||
$array[$x]['default_setting_description'] = 'Delay before we make next call after no answered call';
|
||||
$x++;
|
||||
$array[$x]['default_setting_category'] = 'fax';
|
||||
$array[$x]['default_setting_subcategory'] = 'send_no_answer_limit';
|
||||
$array[$x]['default_setting_name'] = 'numeric';
|
||||
$array[$x]['default_setting_value'] = '3';
|
||||
$array[$x]['default_setting_enabled'] = 'true';
|
||||
$array[$x]['default_setting_description'] = 'Giveup reach the destination after this number of sequences';
|
||||
$x++;
|
||||
$array[$x]['default_setting_category'] = 'fax';
|
||||
$array[$x]['default_setting_subcategory'] = 'send_no_answer_interval';
|
||||
$array[$x]['default_setting_name'] = 'numeric';
|
||||
$array[$x]['default_setting_value'] = '300';
|
||||
$array[$x]['default_setting_enabled'] = 'true';
|
||||
$array[$x]['default_setting_description'] = 'Delay before next call sequence';
|
||||
$x++;
|
||||
//get an array of the default settings
|
||||
$sql = "select * from v_default_settings ";
|
||||
$prep_statement = $db->prepare($sql);
|
||||
$prep_statement->execute();
|
||||
$default_settings = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
||||
unset ($prep_statement, $sql);
|
||||
|
||||
//find the missing default settings
|
||||
$x = 0;
|
||||
foreach ($array as $setting) {
|
||||
$found = false;
|
||||
$missing[$x] = $setting;
|
||||
foreach ($default_settings as $row) {
|
||||
if (trim($row['default_setting_subcategory']) == trim($setting['default_setting_subcategory'])) {
|
||||
$found = true;
|
||||
//remove items from the array that were found
|
||||
unset($missing[$x]);
|
||||
}
|
||||
}
|
||||
$x++;
|
||||
}
|
||||
|
||||
//add the missing default settings
|
||||
foreach ($missing as $row) {
|
||||
//add the default settings
|
||||
$orm = new orm;
|
||||
$orm->name('default_settings');
|
||||
$orm->save($row);
|
||||
$message = $orm->message;
|
||||
unset($orm);
|
||||
}
|
||||
unset($missing);
|
||||
|
||||
}
|
||||
|
||||
<?php
|
||||
|
||||
if ($domains_processed == 1) {
|
||||
|
||||
//define array of settings
|
||||
$x = 0;
|
||||
$array[$x]['default_setting_category'] = 'fax';
|
||||
$array[$x]['default_setting_subcategory'] = 'allowed_extension';
|
||||
$array[$x]['default_setting_name'] = 'array';
|
||||
$array[$x]['default_setting_value'] = '.pdf';
|
||||
$array[$x]['default_setting_enabled'] = 'true';
|
||||
$array[$x]['default_setting_description'] = '';
|
||||
$x = 0;
|
||||
$array[$x]['default_setting_category'] = 'fax';
|
||||
$array[$x]['default_setting_subcategory'] = 'allowed_extension';
|
||||
$array[$x]['default_setting_name'] = 'array';
|
||||
$array[$x]['default_setting_value'] = '.tif';
|
||||
$array[$x]['default_setting_enabled'] = 'true';
|
||||
$array[$x]['default_setting_description'] = '';
|
||||
$x = 0;
|
||||
$array[$x]['default_setting_category'] = 'fax';
|
||||
$array[$x]['default_setting_subcategory'] = 'allowed_extension';
|
||||
$array[$x]['default_setting_name'] = 'array';
|
||||
$array[$x]['default_setting_value'] = '.tiff';
|
||||
$array[$x]['default_setting_enabled'] = 'true';
|
||||
$array[$x]['default_setting_description'] = '';
|
||||
$x++;
|
||||
$array[$x]['default_setting_category'] = 'fax';
|
||||
$array[$x]['default_setting_subcategory'] = 'cover_logo';
|
||||
$array[$x]['default_setting_name'] = 'text';
|
||||
$array[$x]['default_setting_value'] = '';
|
||||
$array[$x]['default_setting_enabled'] = 'false';
|
||||
$array[$x]['default_setting_description'] = 'Path to image/logo file displayed in the header of the cover sheet.';
|
||||
$x++;
|
||||
$array[$x]['default_setting_category'] = 'fax';
|
||||
$array[$x]['default_setting_subcategory'] = 'cover_font';
|
||||
$array[$x]['default_setting_name'] = 'text';
|
||||
$array[$x]['default_setting_value'] = 'times';
|
||||
$array[$x]['default_setting_enabled'] = 'false';
|
||||
$array[$x]['default_setting_description'] = 'Font used to generate cover page. Can be full path to .ttf file or font name alredy installed.';
|
||||
$x++;
|
||||
$array[$x]['default_setting_category'] = 'fax';
|
||||
$array[$x]['default_setting_subcategory'] = 'cover_footer';
|
||||
$array[$x]['default_setting_name'] = 'text';
|
||||
$array[$x]['default_setting_value'] = "The information contained in this facsimile is intended for the sole confidential use of the recipient(s) designated above, and may contain confidential and legally privileged information. If you are not the intended recipient, you are hereby notified that the review, disclosure, dissemination, distribution, copying, duplication in any form, and taking of any action in regards to the contents of this document - except with respect to its direct delivery to the intended recipient - is strictly prohibited. Please notify the sender immediately and destroy this cover sheet and all attachments. If stored or viewed electronically, please permanently delete it from your system.";
|
||||
$array[$x]['default_setting_enabled'] = 'true';
|
||||
$array[$x]['default_setting_description'] = 'Notice displayed in the footer of the cover sheet.';
|
||||
$x++;
|
||||
$array[$x]['default_setting_category'] = 'fax';
|
||||
$array[$x]['default_setting_subcategory'] = 'cover_header';
|
||||
$array[$x]['default_setting_name'] = 'text';
|
||||
$array[$x]['default_setting_value'] = '';
|
||||
$array[$x]['default_setting_enabled'] = 'false';
|
||||
$array[$x]['default_setting_description'] = 'Default information displayed beneath the logo in the header of the cover sheet.';
|
||||
$x++;
|
||||
$array[$x]['default_setting_category'] = 'fax';
|
||||
$array[$x]['default_setting_subcategory'] = 'page_size';
|
||||
$array[$x]['default_setting_name'] = 'text';
|
||||
$array[$x]['default_setting_value'] = 'letter';
|
||||
$array[$x]['default_setting_enabled'] = 'true';
|
||||
$array[$x]['default_setting_description'] = 'Set the default page size of new faxes.';
|
||||
$x++;
|
||||
$array[$x]['default_setting_category'] = 'fax';
|
||||
$array[$x]['default_setting_subcategory'] = 'resolution';
|
||||
$array[$x]['default_setting_name'] = 'text';
|
||||
$array[$x]['default_setting_value'] = 'normal';
|
||||
$array[$x]['default_setting_enabled'] = 'true';
|
||||
$array[$x]['default_setting_description'] = 'Set the default transmission quality of new faxes.';
|
||||
$x++;
|
||||
$array[$x]['default_setting_category'] = 'fax';
|
||||
$array[$x]['default_setting_subcategory'] = 'variable';
|
||||
$array[$x]['default_setting_name'] = 'array';
|
||||
$array[$x]['default_setting_value'] = 'fax_enable_t38=true';
|
||||
$array[$x]['default_setting_enabled'] = 'true';
|
||||
$array[$x]['default_setting_description'] = 'Enable T.38';
|
||||
$x++;
|
||||
$array[$x]['default_setting_category'] = 'fax';
|
||||
$array[$x]['default_setting_subcategory'] = 'variable';
|
||||
$array[$x]['default_setting_name'] = 'array';
|
||||
$array[$x]['default_setting_value'] = 'fax_enable_t38_request=false';
|
||||
$array[$x]['default_setting_enabled'] = 'true';
|
||||
$array[$x]['default_setting_description'] = 'Send a T38 reinvite when a fax tone is detected.';
|
||||
$x++;
|
||||
$array[$x]['default_setting_category'] = 'fax';
|
||||
$array[$x]['default_setting_subcategory'] = 'keep_local';
|
||||
$array[$x]['default_setting_name'] = 'boolean';
|
||||
$array[$x]['default_setting_value'] = 'true';
|
||||
$array[$x]['default_setting_enabled'] = 'true';
|
||||
$array[$x]['default_setting_description'] = 'Keep the file after sending or receiving the fax.';
|
||||
$x++;
|
||||
$array[$x]['default_setting_category'] = 'fax';
|
||||
$array[$x]['default_setting_subcategory'] = 'send_mode';
|
||||
$array[$x]['default_setting_name'] = 'text';
|
||||
$array[$x]['default_setting_value'] = 'queue';
|
||||
$array[$x]['default_setting_enabled'] = 'false';
|
||||
$array[$x]['default_setting_description'] = '';
|
||||
$x++;
|
||||
$array[$x]['default_setting_category'] = 'fax';
|
||||
$array[$x]['default_setting_subcategory'] = 'send_retry_limit';
|
||||
$array[$x]['default_setting_name'] = 'numeric';
|
||||
$array[$x]['default_setting_value'] = '5';
|
||||
$array[$x]['default_setting_enabled'] = 'true';
|
||||
$array[$x]['default_setting_description'] = 'Number of attempts to send fax (count only calls with answer)';
|
||||
$x++;
|
||||
$array[$x]['default_setting_category'] = 'fax';
|
||||
$array[$x]['default_setting_subcategory'] = 'send_retry_interval';
|
||||
$array[$x]['default_setting_name'] = 'numeric';
|
||||
$array[$x]['default_setting_value'] = '15';
|
||||
$array[$x]['default_setting_enabled'] = 'true';
|
||||
$array[$x]['default_setting_description'] = 'Delay before we make next call after answered call';
|
||||
$x++;
|
||||
$array[$x]['default_setting_category'] = 'fax';
|
||||
$array[$x]['default_setting_subcategory'] = 'send_no_answer_retry_limit';
|
||||
$array[$x]['default_setting_name'] = 'numeric';
|
||||
$array[$x]['default_setting_value'] = '3';
|
||||
$array[$x]['default_setting_enabled'] = 'true';
|
||||
$array[$x]['default_setting_description'] = 'Number of unanswered attempts in sequence';
|
||||
$x++;
|
||||
$array[$x]['default_setting_category'] = 'fax';
|
||||
$array[$x]['default_setting_subcategory'] = 'send_no_answer_retry_interval';
|
||||
$array[$x]['default_setting_name'] = 'numeric';
|
||||
$array[$x]['default_setting_value'] = '30';
|
||||
$array[$x]['default_setting_enabled'] = 'true';
|
||||
$array[$x]['default_setting_description'] = 'Delay before we make next call after no answered call';
|
||||
$x++;
|
||||
$array[$x]['default_setting_category'] = 'fax';
|
||||
$array[$x]['default_setting_subcategory'] = 'send_no_answer_limit';
|
||||
$array[$x]['default_setting_name'] = 'numeric';
|
||||
$array[$x]['default_setting_value'] = '3';
|
||||
$array[$x]['default_setting_enabled'] = 'true';
|
||||
$array[$x]['default_setting_description'] = 'Giveup reach the destination after this number of sequences';
|
||||
$x++;
|
||||
$array[$x]['default_setting_category'] = 'fax';
|
||||
$array[$x]['default_setting_subcategory'] = 'send_no_answer_interval';
|
||||
$array[$x]['default_setting_name'] = 'numeric';
|
||||
$array[$x]['default_setting_value'] = '300';
|
||||
$array[$x]['default_setting_enabled'] = 'true';
|
||||
$array[$x]['default_setting_description'] = 'Delay before next call sequence';
|
||||
$x++;
|
||||
//get an array of the default settings
|
||||
$sql = "select * from v_default_settings ";
|
||||
$prep_statement = $db->prepare($sql);
|
||||
$prep_statement->execute();
|
||||
$default_settings = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
||||
unset ($prep_statement, $sql);
|
||||
|
||||
//find the missing default settings
|
||||
$x = 0;
|
||||
foreach ($array as $setting) {
|
||||
$found = false;
|
||||
$missing[$x] = $setting;
|
||||
foreach ($default_settings as $row) {
|
||||
if (trim($row['default_setting_subcategory']) == trim($setting['default_setting_subcategory'])) {
|
||||
$found = true;
|
||||
//remove items from the array that were found
|
||||
unset($missing[$x]);
|
||||
}
|
||||
}
|
||||
$x++;
|
||||
}
|
||||
|
||||
//add the missing default settings
|
||||
foreach ($missing as $row) {
|
||||
//add the default settings
|
||||
$orm = new orm;
|
||||
$orm->name('default_settings');
|
||||
$orm->save($row);
|
||||
$message = $orm->message;
|
||||
unset($orm);
|
||||
}
|
||||
unset($missing);
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
+145
-145
@@ -1,146 +1,146 @@
|
||||
<?php
|
||||
/*
|
||||
FusionPBX
|
||||
Version: MPL 1.1
|
||||
|
||||
The contents of this file are subject to the Mozilla Public License Version
|
||||
1.1 (the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
http://www.mozilla.org/MPL/
|
||||
|
||||
Software distributed under the License is distributed on an "AS IS" basis,
|
||||
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
for the specific language governing rights and limitations under the
|
||||
License.
|
||||
|
||||
The Original Code is FusionPBX
|
||||
|
||||
The Initial Developer of the Original Code is
|
||||
Mark J Crane <markjcrane@fusionpbx.com>
|
||||
Portions created by the Initial Developer are Copyright (C) 2008-2012
|
||||
the Initial Developer. All Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
Mark J Crane <markjcrane@fusionpbx.com>
|
||||
*/
|
||||
include "root.php";
|
||||
require_once "resources/require.php";
|
||||
require_once "resources/check_auth.php";
|
||||
require_once "resources/paging.php";
|
||||
if (permission_exists('fax_extension_add')) {
|
||||
//access granted
|
||||
}
|
||||
else {
|
||||
echo "access denied";
|
||||
exit;
|
||||
}
|
||||
|
||||
//add multi-lingual support
|
||||
$language = new text;
|
||||
$text = $language->get();
|
||||
|
||||
//set the http get/post variable(s) to a php variable
|
||||
if (isset($_REQUEST["id"])) {
|
||||
$fax_uuid = check_str($_REQUEST["id"]);
|
||||
}
|
||||
|
||||
//get the data
|
||||
$sql = "select * from v_fax ";
|
||||
$sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' ";
|
||||
$sql .= "and fax_uuid = '$fax_uuid' ";
|
||||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
||||
if (count($result) == 0) {
|
||||
echo "access denied";
|
||||
exit;
|
||||
}
|
||||
foreach ($result as &$row) {
|
||||
$fax_extension = $row["fax_extension"];
|
||||
$fax_name = $row["fax_name"];
|
||||
$fax_email = $row["fax_email"];
|
||||
$fax_email_connection_type = $row["fax_email_connection_type"];
|
||||
$fax_email_connection_host = $row["fax_email_connection_host"];
|
||||
$fax_email_connection_port = $row["fax_email_connection_port"];
|
||||
$fax_email_connection_security = $row["fax_email_connection_security"];
|
||||
$fax_email_connection_validate = $row["fax_email_connection_validate"];
|
||||
$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"];
|
||||
$fax_forward_number = $row["fax_forward_number"];
|
||||
$fax_description = 'copy: '.$row["fax_description"];
|
||||
}
|
||||
unset ($prep_statement);
|
||||
|
||||
//copy the fax extension
|
||||
$fax_uuid = uuid();
|
||||
$dialplan_uuid = uuid();
|
||||
$sql = "insert into v_fax ";
|
||||
$sql .= "(";
|
||||
$sql .= "domain_uuid, ";
|
||||
$sql .= "fax_uuid, ";
|
||||
$sql .= "dialplan_uuid, ";
|
||||
$sql .= "fax_extension, ";
|
||||
$sql .= "fax_name, ";
|
||||
$sql .= "fax_email, ";
|
||||
$sql .= "fax_email_connection_type, ";
|
||||
$sql .= "fax_email_connection_host, ";
|
||||
$sql .= "fax_email_connection_port, ";
|
||||
$sql .= "fax_email_connection_security, ";
|
||||
$sql .= "fax_email_connection_validate, ";
|
||||
$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, ";
|
||||
if (strlen($fax_forward_number) > 0) {
|
||||
$sql .= "fax_forward_number, ";
|
||||
}
|
||||
$sql .= "fax_description ";
|
||||
$sql .= ")";
|
||||
$sql .= "values ";
|
||||
$sql .= "(";
|
||||
$sql .= "'".$_SESSION['domain_uuid']."', ";
|
||||
$sql .= "'$fax_uuid', ";
|
||||
$sql .= "'$dialplan_uuid', ";
|
||||
$sql .= "'$fax_extension', ";
|
||||
$sql .= "'$fax_name', ";
|
||||
$sql .= "'$fax_email', ";
|
||||
$sql .= "'$fax_email_connection_type', ";
|
||||
$sql .= "'$fax_email_connection_host', ";
|
||||
$sql .= "'$fax_email_connection_port', ";
|
||||
$sql .= "'$fax_email_connection_security', ";
|
||||
$sql .= "'$fax_email_connection_validate', ";
|
||||
$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', ";
|
||||
if (strlen($fax_forward_number) > 0) {
|
||||
$sql .= "'$fax_forward_number', ";
|
||||
}
|
||||
$sql .= "'$fax_description' ";
|
||||
$sql .= ")";
|
||||
$db->exec(check_sql($sql));
|
||||
unset($sql);
|
||||
|
||||
//redirect the user
|
||||
$_SESSION["message"] = $text['confirm-copy'];
|
||||
header("Location: fax.php");
|
||||
return;
|
||||
|
||||
<?php
|
||||
/*
|
||||
FusionPBX
|
||||
Version: MPL 1.1
|
||||
|
||||
The contents of this file are subject to the Mozilla Public License Version
|
||||
1.1 (the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
http://www.mozilla.org/MPL/
|
||||
|
||||
Software distributed under the License is distributed on an "AS IS" basis,
|
||||
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
for the specific language governing rights and limitations under the
|
||||
License.
|
||||
|
||||
The Original Code is FusionPBX
|
||||
|
||||
The Initial Developer of the Original Code is
|
||||
Mark J Crane <markjcrane@fusionpbx.com>
|
||||
Portions created by the Initial Developer are Copyright (C) 2008-2012
|
||||
the Initial Developer. All Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
Mark J Crane <markjcrane@fusionpbx.com>
|
||||
*/
|
||||
include "root.php";
|
||||
require_once "resources/require.php";
|
||||
require_once "resources/check_auth.php";
|
||||
require_once "resources/paging.php";
|
||||
if (permission_exists('fax_extension_add')) {
|
||||
//access granted
|
||||
}
|
||||
else {
|
||||
echo "access denied";
|
||||
exit;
|
||||
}
|
||||
|
||||
//add multi-lingual support
|
||||
$language = new text;
|
||||
$text = $language->get();
|
||||
|
||||
//set the http get/post variable(s) to a php variable
|
||||
if (isset($_REQUEST["id"])) {
|
||||
$fax_uuid = check_str($_REQUEST["id"]);
|
||||
}
|
||||
|
||||
//get the data
|
||||
$sql = "select * from v_fax ";
|
||||
$sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' ";
|
||||
$sql .= "and fax_uuid = '$fax_uuid' ";
|
||||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
||||
if (count($result) == 0) {
|
||||
echo "access denied";
|
||||
exit;
|
||||
}
|
||||
foreach ($result as &$row) {
|
||||
$fax_extension = $row["fax_extension"];
|
||||
$fax_name = $row["fax_name"];
|
||||
$fax_email = $row["fax_email"];
|
||||
$fax_email_connection_type = $row["fax_email_connection_type"];
|
||||
$fax_email_connection_host = $row["fax_email_connection_host"];
|
||||
$fax_email_connection_port = $row["fax_email_connection_port"];
|
||||
$fax_email_connection_security = $row["fax_email_connection_security"];
|
||||
$fax_email_connection_validate = $row["fax_email_connection_validate"];
|
||||
$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"];
|
||||
$fax_forward_number = $row["fax_forward_number"];
|
||||
$fax_description = 'copy: '.$row["fax_description"];
|
||||
}
|
||||
unset ($prep_statement);
|
||||
|
||||
//copy the fax extension
|
||||
$fax_uuid = uuid();
|
||||
$dialplan_uuid = uuid();
|
||||
$sql = "insert into v_fax ";
|
||||
$sql .= "(";
|
||||
$sql .= "domain_uuid, ";
|
||||
$sql .= "fax_uuid, ";
|
||||
$sql .= "dialplan_uuid, ";
|
||||
$sql .= "fax_extension, ";
|
||||
$sql .= "fax_name, ";
|
||||
$sql .= "fax_email, ";
|
||||
$sql .= "fax_email_connection_type, ";
|
||||
$sql .= "fax_email_connection_host, ";
|
||||
$sql .= "fax_email_connection_port, ";
|
||||
$sql .= "fax_email_connection_security, ";
|
||||
$sql .= "fax_email_connection_validate, ";
|
||||
$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, ";
|
||||
if (strlen($fax_forward_number) > 0) {
|
||||
$sql .= "fax_forward_number, ";
|
||||
}
|
||||
$sql .= "fax_description ";
|
||||
$sql .= ")";
|
||||
$sql .= "values ";
|
||||
$sql .= "(";
|
||||
$sql .= "'".$_SESSION['domain_uuid']."', ";
|
||||
$sql .= "'$fax_uuid', ";
|
||||
$sql .= "'$dialplan_uuid', ";
|
||||
$sql .= "'$fax_extension', ";
|
||||
$sql .= "'$fax_name', ";
|
||||
$sql .= "'$fax_email', ";
|
||||
$sql .= "'$fax_email_connection_type', ";
|
||||
$sql .= "'$fax_email_connection_host', ";
|
||||
$sql .= "'$fax_email_connection_port', ";
|
||||
$sql .= "'$fax_email_connection_security', ";
|
||||
$sql .= "'$fax_email_connection_validate', ";
|
||||
$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', ";
|
||||
if (strlen($fax_forward_number) > 0) {
|
||||
$sql .= "'$fax_forward_number', ";
|
||||
}
|
||||
$sql .= "'$fax_description' ";
|
||||
$sql .= ")";
|
||||
$db->exec(check_sql($sql));
|
||||
unset($sql);
|
||||
|
||||
//redirect the user
|
||||
$_SESSION["message"] = $text['confirm-copy'];
|
||||
header("Location: fax.php");
|
||||
return;
|
||||
|
||||
?>
|
||||
+1041
-1041
File diff suppressed because it is too large
Load Diff
+386
-386
@@ -1,387 +1,387 @@
|
||||
<?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) 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/functions/object_to_array.php";
|
||||
require_once "resources/functions/parse_message.php";
|
||||
require_once "resources/classes/text.php";
|
||||
|
||||
//get accounts to monitor
|
||||
$sql = "select * from v_fax ";
|
||||
$sql .= "where fax_email_connection_host <> '' ";
|
||||
$sql .= "and fax_email_connection_host is not null ";
|
||||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
||||
unset($sql, $prep_statement);
|
||||
|
||||
function arr_to_map(&$arr){
|
||||
if(is_array($arr)){
|
||||
$map = Array();
|
||||
foreach($arr as &$val){
|
||||
$map[$val] = true;
|
||||
}
|
||||
return $map;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if (sizeof($result) != 0) {
|
||||
|
||||
//load default settings
|
||||
$default_settings = load_default_settings();
|
||||
|
||||
//get event socket connection parameters
|
||||
$sql = "select event_socket_ip_address, event_socket_port, event_socket_password from v_settings";
|
||||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
$record = $prep_statement->fetch(PDO::FETCH_NAMED);
|
||||
$event_socket['ip_address'] = $record['event_socket_ip_address'];
|
||||
$event_socket['port'] = $record['event_socket_port'];
|
||||
$event_socket['password'] = $record['event_socket_password'];
|
||||
unset($sql, $prep_statement, $record);
|
||||
|
||||
$fax_send_mode_default = $_SESSION['fax']['send_mode']['text'];
|
||||
if(strlen($fax_send_mode_default) == 0){
|
||||
$fax_send_mode_default = 'direct';
|
||||
}
|
||||
$fax_cover_font_default = $_SESSION['fax']['cover_font']['text'];
|
||||
|
||||
$fax_allowed_extension_default = arr_to_map($_SESSION['fax']['allowed_extension']);
|
||||
if($fax_allowed_extension_default == false){
|
||||
$tmp = Array('.pdf', '.tiff', '.tif');
|
||||
$fax_allowed_extension_default = arr_to_map($tmp);
|
||||
}
|
||||
|
||||
foreach ($result as $row) {
|
||||
//get fax server and account connection details
|
||||
$fax_uuid = $row["fax_uuid"];
|
||||
$domain_uuid = $row["domain_uuid"];
|
||||
$fax_extension = $row["fax_extension"];
|
||||
$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_email_connection_type = $row["fax_email_connection_type"];
|
||||
$fax_email_connection_host = $row["fax_email_connection_host"];
|
||||
$fax_email_connection_port = $row["fax_email_connection_port"];
|
||||
$fax_email_connection_security = $row["fax_email_connection_security"];
|
||||
$fax_email_connection_validate = $row["fax_email_connection_validate"];
|
||||
$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_outbound_subject_tag = $row["fax_email_outbound_subject_tag"];
|
||||
$fax_email_outbound_authorized_senders = $row["fax_email_outbound_authorized_senders"];
|
||||
$fax_send_greeting = $row["fax_send_greeting"];
|
||||
|
||||
//load default settings, then domain settings over top
|
||||
unset($_SESSION);
|
||||
$_SESSION = $default_settings;
|
||||
load_domain_settings($domain_uuid);
|
||||
|
||||
$fax_send_mode = $_SESSION['fax']['send_mode']['text'];
|
||||
if(strlen($fax_send_mode) == 0){
|
||||
$fax_send_mode = $fax_send_mode_default;
|
||||
}
|
||||
|
||||
$fax_cover_font = $_SESSION['fax']['cover_font']['text'];
|
||||
if(strlen($fax_cover_font) == 0){
|
||||
$fax_cover_font = $fax_cover_font_default;
|
||||
}
|
||||
|
||||
$fax_allowed_extension = arr_to_map($_SESSION['fax']['allowed_extension']);
|
||||
if($fax_allowed_extension == false){
|
||||
$fax_allowed_extension = $fax_allowed_extension_default;
|
||||
}
|
||||
|
||||
//load event socket connection parameters
|
||||
$_SESSION['event_socket_ip_address'] = $event_socket['ip_address'];
|
||||
$_SESSION['event_socket_port'] = $event_socket['port'];
|
||||
$_SESSION['event_socket_password'] = $event_socket['password'];
|
||||
|
||||
//get domain name, set local and session variables
|
||||
$sql = "select domain_name from v_domains where domain_uuid = '".$domain_uuid."'";
|
||||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
$record = $prep_statement->fetch(PDO::FETCH_NAMED);
|
||||
$domain_name = $record['domain_name'];
|
||||
$_SESSION['domain_name'] = $record['domain_name'];
|
||||
$_SESSION['domain_uuid'] = $domain_uuid;
|
||||
unset($sql, $prep_statement, $record);
|
||||
|
||||
//set needed variables
|
||||
$fax_page_size = $_SESSION['fax']['page_size']['text'];
|
||||
$fax_resolution = $_SESSION['fax']['resolution']['text'];
|
||||
$fax_header = $_SESSION['fax']['cover_header']['text'];
|
||||
$fax_footer = $_SESSION['fax']['cover_footer']['text'];
|
||||
$fax_sender = $fax_caller_id_name;
|
||||
|
||||
//open account connection
|
||||
$fax_email_connection = "{".$fax_email_connection_host.":".$fax_email_connection_port."/".$fax_email_connection_type;
|
||||
$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 (!$connection = imap_open($fax_email_connection, $fax_email_connection_username, $fax_email_connection_password)) {
|
||||
print_r(imap_errors());
|
||||
continue; // try next account
|
||||
}
|
||||
|
||||
//get emails
|
||||
if ($emails = imap_search($connection, "SUBJECT \"[".$fax_email_outbound_subject_tag."]\"", SE_UID)) {
|
||||
|
||||
//get authorized sender(s)
|
||||
if (substr_count($fax_email_outbound_authorized_senders, ',') > 0) {
|
||||
$authorized_senders = explode(',', $fax_email_outbound_authorized_senders);
|
||||
}
|
||||
else {
|
||||
$authorized_senders[] = $fax_email_outbound_authorized_senders;
|
||||
}
|
||||
|
||||
sort($emails); // oldest first
|
||||
foreach ($emails as $email_id) {
|
||||
$metadata = object_to_array(imap_fetch_overview($connection, $email_id, FT_UID));
|
||||
|
||||
//format from address
|
||||
$tmp = object_to_array(imap_rfc822_parse_adrlist($metadata[0]['from'], null));
|
||||
$metadata[0]['from'] = $tmp[0]['mailbox']."@".$tmp[0]['host'];
|
||||
|
||||
//check sender
|
||||
$sender_authorized = false;
|
||||
foreach ($authorized_senders as $authorized_sender) {
|
||||
if (substr_count($metadata[0]['from'], $authorized_sender) > 0) { $sender_authorized = true; }
|
||||
}
|
||||
|
||||
if ($sender_authorized) {
|
||||
|
||||
//add multi-lingual support
|
||||
$language = new text;
|
||||
$text = $language->get();
|
||||
|
||||
//sent sender address (used in api call)
|
||||
$mailto_address_user = $metadata[0]['from'];
|
||||
|
||||
//parse recipient fax number(s)
|
||||
$fax_subject = $metadata[0]['subject'];
|
||||
$tmp = explode(']', $fax_subject); //closing bracket of subject tag
|
||||
$tmp = $tmp[1];
|
||||
$tmp = str_replace(':', ',', $tmp);
|
||||
$tmp = str_replace(';', ',', $tmp);
|
||||
$tmp = str_replace('|', ',', $tmp);
|
||||
if (substr_count($tmp, ',') > 0) {
|
||||
$fax_numbers = explode(',', $tmp);
|
||||
}
|
||||
else {
|
||||
$fax_numbers[] = $tmp;
|
||||
}
|
||||
unset($fax_subject); //clear so not on cover page
|
||||
|
||||
$message = parse_message($connection, $email_id, FT_UID);
|
||||
|
||||
//get email body (if any) for cover page
|
||||
$fax_message = '';
|
||||
|
||||
//Debug print
|
||||
print('attachments:' . "\n");
|
||||
foreach($message['attachments'] as &$attachment){
|
||||
print(' - ' . $attachment['type'] . ' - ' . $attachment['name'] . ': ' . $attachment['size'] . ' disposition: ' . $attachment['disposition'] . "\n");
|
||||
}
|
||||
print('messages:' . "\n");
|
||||
foreach($message['messages'] as &$msg){
|
||||
print(' - ' . $msg['type'] . ' - ' . $msg['size'] . "\n");
|
||||
// print($msg['data']);
|
||||
// print("\n--------------------------------------------------------\n");
|
||||
}
|
||||
|
||||
foreach($message['messages'] as &$msg){
|
||||
if(($msg['size'] > 0) && ($msg['type'] == 'text/plain')) {
|
||||
$fax_message = $msg['data'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($fax_message != '') {
|
||||
$fax_message = strip_tags($fax_message);
|
||||
$fax_message = str_replace("\r\n\r\n", "\r\n", $fax_message);
|
||||
}
|
||||
|
||||
// set fax directory (used for pdf creation - cover and/or attachments)
|
||||
$fax_dir = $_SESSION['switch']['storage']['dir'].'/fax'.(($domain_name != '') ? '/'.$domain_name : null);
|
||||
|
||||
//handle attachments (if any)
|
||||
$emailed_files = Array();
|
||||
$attachments = $message['attachments'];
|
||||
if (sizeof($attachments) > 0) {
|
||||
foreach ($attachments as &$attachment) {
|
||||
$fax_file_extension = pathinfo($attachment['name'], PATHINFO_EXTENSION);
|
||||
|
||||
//block unknown files
|
||||
if ($fax_file_extension == '') {continue; }
|
||||
//block unauthorized files
|
||||
if (!$fax_allowed_extension['.' . $fax_file_extension]) { continue; }
|
||||
//support only attachments
|
||||
if($attachment['disposition'] != 'attachment'){ continue; }
|
||||
|
||||
//store attachment in local fax temp folder
|
||||
$local_filepath = $fax_dir.'/'.$fax_extension.'/temp/'.$attachment['name'];
|
||||
file_put_contents($local_filepath, $attachment['data']);
|
||||
|
||||
//load files array with attachments
|
||||
$emailed_files['error'][] = 0;
|
||||
$emailed_files['size'][] = $attachment['size'];
|
||||
$emailed_files['tmp_name'][] = $attachment['name'];
|
||||
$emailed_files['name'][] = $attachment['name'];
|
||||
}
|
||||
}
|
||||
|
||||
//Debug print
|
||||
print('***********************' . "\n");
|
||||
print('fax message:' . "\n");
|
||||
print(' - length: ' . strlen($fax_message) . "\n");
|
||||
print('fax files [' . sizeof($emailed_files['name']) . ']:' . "\n");
|
||||
for($i = 0; $i < sizeof($emailed_files['name']);++$i){
|
||||
print(' - ' . $emailed_files['name'][$i] . ' - ' . $emailed_files['size'][$i] . "\n");
|
||||
}
|
||||
print('***********************' . "\n");
|
||||
|
||||
//send fax
|
||||
$cwd = getcwd();
|
||||
$included = true;
|
||||
require("fax_send.php");
|
||||
if($cwd){
|
||||
chdir($cwd);
|
||||
}
|
||||
|
||||
//reset variables
|
||||
unset($fax_numbers);
|
||||
}
|
||||
|
||||
//delete email
|
||||
if (imap_delete($connection, $email_id, FT_UID)) {
|
||||
imap_expunge($connection);
|
||||
}
|
||||
}
|
||||
unset($authorized_senders);
|
||||
}
|
||||
|
||||
//close account connection
|
||||
imap_close($connection);
|
||||
}
|
||||
}
|
||||
|
||||
//functions used above
|
||||
function load_default_settings() {
|
||||
global $db;
|
||||
|
||||
$sql = "select * from v_default_settings ";
|
||||
$sql .= "where default_setting_enabled = 'true' ";
|
||||
try {
|
||||
$prep_statement = $db->prepare($sql . " order by default_setting_order asc ");
|
||||
$prep_statement->execute();
|
||||
}
|
||||
catch(PDOException $e) {
|
||||
$prep_statement = $db->prepare($sql);
|
||||
$prep_statement->execute();
|
||||
}
|
||||
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
||||
//load the settings into an array
|
||||
foreach ($result as $row) {
|
||||
$name = $row['default_setting_name'];
|
||||
$category = $row['default_setting_category'];
|
||||
$subcategory = $row['default_setting_subcategory'];
|
||||
if (strlen($subcategory) == 0) {
|
||||
if ($name == "array") {
|
||||
$settings[$category][] = $row['default_setting_value'];
|
||||
}
|
||||
else {
|
||||
$settings[$category][$name] = $row['default_setting_value'];
|
||||
}
|
||||
} else {
|
||||
if ($name == "array") {
|
||||
$settings[$category][$subcategory][] = $row['default_setting_value'];
|
||||
}
|
||||
else {
|
||||
$settings[$category][$subcategory][$name] = $row['default_setting_value'];
|
||||
$settings[$category][$subcategory][$name] = $row['default_setting_value'];
|
||||
}
|
||||
}
|
||||
}
|
||||
return $settings;
|
||||
}
|
||||
|
||||
function load_domain_settings($domain_uuid) {
|
||||
global $db;
|
||||
|
||||
if ($domain_uuid) {
|
||||
$sql = "select * from v_domain_settings ";
|
||||
$sql .= "where domain_uuid = '" . $domain_uuid . "' ";
|
||||
$sql .= "and domain_setting_enabled = 'true' ";
|
||||
try {
|
||||
$prep_statement = $db->prepare($sql . " order by domain_setting_order asc ");
|
||||
$prep_statement->execute();
|
||||
}
|
||||
catch(PDOException $e) {
|
||||
$prep_statement = $db->prepare($sql);
|
||||
$prep_statement->execute();
|
||||
}
|
||||
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
||||
//unset the arrays that domains are overriding
|
||||
foreach ($result as $row) {
|
||||
$name = $row['domain_setting_name'];
|
||||
$category = $row['domain_setting_category'];
|
||||
$subcategory = $row['domain_setting_subcategory'];
|
||||
if ($name == "array") {
|
||||
unset($_SESSION[$category][$subcategory]);
|
||||
}
|
||||
}
|
||||
//set the settings as a session
|
||||
foreach ($result as $row) {
|
||||
$name = $row['domain_setting_name'];
|
||||
$category = $row['domain_setting_category'];
|
||||
$subcategory = $row['domain_setting_subcategory'];
|
||||
if (strlen($subcategory) == 0) {
|
||||
//$$category[$name] = $row['domain_setting_value'];
|
||||
if ($name == "array") {
|
||||
$_SESSION[$category][] = $row['domain_setting_value'];
|
||||
}
|
||||
else {
|
||||
$_SESSION[$category][$name] = $row['domain_setting_value'];
|
||||
}
|
||||
} else {
|
||||
//$$category[$subcategory][$name] = $row['domain_setting_value'];
|
||||
if ($name == "array") {
|
||||
$_SESSION[$category][$subcategory][] = $row['domain_setting_value'];
|
||||
}
|
||||
else {
|
||||
$_SESSION[$category][$subcategory][$name] = $row['domain_setting_value'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
<?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) 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/functions/object_to_array.php";
|
||||
require_once "resources/functions/parse_message.php";
|
||||
require_once "resources/classes/text.php";
|
||||
|
||||
//get accounts to monitor
|
||||
$sql = "select * from v_fax ";
|
||||
$sql .= "where fax_email_connection_host <> '' ";
|
||||
$sql .= "and fax_email_connection_host is not null ";
|
||||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
||||
unset($sql, $prep_statement);
|
||||
|
||||
function arr_to_map(&$arr){
|
||||
if(is_array($arr)){
|
||||
$map = Array();
|
||||
foreach($arr as &$val){
|
||||
$map[$val] = true;
|
||||
}
|
||||
return $map;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if (sizeof($result) != 0) {
|
||||
|
||||
//load default settings
|
||||
$default_settings = load_default_settings();
|
||||
|
||||
//get event socket connection parameters
|
||||
$sql = "select event_socket_ip_address, event_socket_port, event_socket_password from v_settings";
|
||||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
$record = $prep_statement->fetch(PDO::FETCH_NAMED);
|
||||
$event_socket['ip_address'] = $record['event_socket_ip_address'];
|
||||
$event_socket['port'] = $record['event_socket_port'];
|
||||
$event_socket['password'] = $record['event_socket_password'];
|
||||
unset($sql, $prep_statement, $record);
|
||||
|
||||
$fax_send_mode_default = $_SESSION['fax']['send_mode']['text'];
|
||||
if(strlen($fax_send_mode_default) == 0){
|
||||
$fax_send_mode_default = 'direct';
|
||||
}
|
||||
$fax_cover_font_default = $_SESSION['fax']['cover_font']['text'];
|
||||
|
||||
$fax_allowed_extension_default = arr_to_map($_SESSION['fax']['allowed_extension']);
|
||||
if($fax_allowed_extension_default == false){
|
||||
$tmp = Array('.pdf', '.tiff', '.tif');
|
||||
$fax_allowed_extension_default = arr_to_map($tmp);
|
||||
}
|
||||
|
||||
foreach ($result as $row) {
|
||||
//get fax server and account connection details
|
||||
$fax_uuid = $row["fax_uuid"];
|
||||
$domain_uuid = $row["domain_uuid"];
|
||||
$fax_extension = $row["fax_extension"];
|
||||
$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_email_connection_type = $row["fax_email_connection_type"];
|
||||
$fax_email_connection_host = $row["fax_email_connection_host"];
|
||||
$fax_email_connection_port = $row["fax_email_connection_port"];
|
||||
$fax_email_connection_security = $row["fax_email_connection_security"];
|
||||
$fax_email_connection_validate = $row["fax_email_connection_validate"];
|
||||
$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_outbound_subject_tag = $row["fax_email_outbound_subject_tag"];
|
||||
$fax_email_outbound_authorized_senders = $row["fax_email_outbound_authorized_senders"];
|
||||
$fax_send_greeting = $row["fax_send_greeting"];
|
||||
|
||||
//load default settings, then domain settings over top
|
||||
unset($_SESSION);
|
||||
$_SESSION = $default_settings;
|
||||
load_domain_settings($domain_uuid);
|
||||
|
||||
$fax_send_mode = $_SESSION['fax']['send_mode']['text'];
|
||||
if(strlen($fax_send_mode) == 0){
|
||||
$fax_send_mode = $fax_send_mode_default;
|
||||
}
|
||||
|
||||
$fax_cover_font = $_SESSION['fax']['cover_font']['text'];
|
||||
if(strlen($fax_cover_font) == 0){
|
||||
$fax_cover_font = $fax_cover_font_default;
|
||||
}
|
||||
|
||||
$fax_allowed_extension = arr_to_map($_SESSION['fax']['allowed_extension']);
|
||||
if($fax_allowed_extension == false){
|
||||
$fax_allowed_extension = $fax_allowed_extension_default;
|
||||
}
|
||||
|
||||
//load event socket connection parameters
|
||||
$_SESSION['event_socket_ip_address'] = $event_socket['ip_address'];
|
||||
$_SESSION['event_socket_port'] = $event_socket['port'];
|
||||
$_SESSION['event_socket_password'] = $event_socket['password'];
|
||||
|
||||
//get domain name, set local and session variables
|
||||
$sql = "select domain_name from v_domains where domain_uuid = '".$domain_uuid."'";
|
||||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
$record = $prep_statement->fetch(PDO::FETCH_NAMED);
|
||||
$domain_name = $record['domain_name'];
|
||||
$_SESSION['domain_name'] = $record['domain_name'];
|
||||
$_SESSION['domain_uuid'] = $domain_uuid;
|
||||
unset($sql, $prep_statement, $record);
|
||||
|
||||
//set needed variables
|
||||
$fax_page_size = $_SESSION['fax']['page_size']['text'];
|
||||
$fax_resolution = $_SESSION['fax']['resolution']['text'];
|
||||
$fax_header = $_SESSION['fax']['cover_header']['text'];
|
||||
$fax_footer = $_SESSION['fax']['cover_footer']['text'];
|
||||
$fax_sender = $fax_caller_id_name;
|
||||
|
||||
//open account connection
|
||||
$fax_email_connection = "{".$fax_email_connection_host.":".$fax_email_connection_port."/".$fax_email_connection_type;
|
||||
$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 (!$connection = imap_open($fax_email_connection, $fax_email_connection_username, $fax_email_connection_password)) {
|
||||
print_r(imap_errors());
|
||||
continue; // try next account
|
||||
}
|
||||
|
||||
//get emails
|
||||
if ($emails = imap_search($connection, "SUBJECT \"[".$fax_email_outbound_subject_tag."]\"", SE_UID)) {
|
||||
|
||||
//get authorized sender(s)
|
||||
if (substr_count($fax_email_outbound_authorized_senders, ',') > 0) {
|
||||
$authorized_senders = explode(',', $fax_email_outbound_authorized_senders);
|
||||
}
|
||||
else {
|
||||
$authorized_senders[] = $fax_email_outbound_authorized_senders;
|
||||
}
|
||||
|
||||
sort($emails); // oldest first
|
||||
foreach ($emails as $email_id) {
|
||||
$metadata = object_to_array(imap_fetch_overview($connection, $email_id, FT_UID));
|
||||
|
||||
//format from address
|
||||
$tmp = object_to_array(imap_rfc822_parse_adrlist($metadata[0]['from'], null));
|
||||
$metadata[0]['from'] = $tmp[0]['mailbox']."@".$tmp[0]['host'];
|
||||
|
||||
//check sender
|
||||
$sender_authorized = false;
|
||||
foreach ($authorized_senders as $authorized_sender) {
|
||||
if (substr_count($metadata[0]['from'], $authorized_sender) > 0) { $sender_authorized = true; }
|
||||
}
|
||||
|
||||
if ($sender_authorized) {
|
||||
|
||||
//add multi-lingual support
|
||||
$language = new text;
|
||||
$text = $language->get();
|
||||
|
||||
//sent sender address (used in api call)
|
||||
$mailto_address_user = $metadata[0]['from'];
|
||||
|
||||
//parse recipient fax number(s)
|
||||
$fax_subject = $metadata[0]['subject'];
|
||||
$tmp = explode(']', $fax_subject); //closing bracket of subject tag
|
||||
$tmp = $tmp[1];
|
||||
$tmp = str_replace(':', ',', $tmp);
|
||||
$tmp = str_replace(';', ',', $tmp);
|
||||
$tmp = str_replace('|', ',', $tmp);
|
||||
if (substr_count($tmp, ',') > 0) {
|
||||
$fax_numbers = explode(',', $tmp);
|
||||
}
|
||||
else {
|
||||
$fax_numbers[] = $tmp;
|
||||
}
|
||||
unset($fax_subject); //clear so not on cover page
|
||||
|
||||
$message = parse_message($connection, $email_id, FT_UID);
|
||||
|
||||
//get email body (if any) for cover page
|
||||
$fax_message = '';
|
||||
|
||||
//Debug print
|
||||
print('attachments:' . "\n");
|
||||
foreach($message['attachments'] as &$attachment){
|
||||
print(' - ' . $attachment['type'] . ' - ' . $attachment['name'] . ': ' . $attachment['size'] . ' disposition: ' . $attachment['disposition'] . "\n");
|
||||
}
|
||||
print('messages:' . "\n");
|
||||
foreach($message['messages'] as &$msg){
|
||||
print(' - ' . $msg['type'] . ' - ' . $msg['size'] . "\n");
|
||||
// print($msg['data']);
|
||||
// print("\n--------------------------------------------------------\n");
|
||||
}
|
||||
|
||||
foreach($message['messages'] as &$msg){
|
||||
if(($msg['size'] > 0) && ($msg['type'] == 'text/plain')) {
|
||||
$fax_message = $msg['data'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($fax_message != '') {
|
||||
$fax_message = strip_tags($fax_message);
|
||||
$fax_message = str_replace("\r\n\r\n", "\r\n", $fax_message);
|
||||
}
|
||||
|
||||
// set fax directory (used for pdf creation - cover and/or attachments)
|
||||
$fax_dir = $_SESSION['switch']['storage']['dir'].'/fax'.(($domain_name != '') ? '/'.$domain_name : null);
|
||||
|
||||
//handle attachments (if any)
|
||||
$emailed_files = Array();
|
||||
$attachments = $message['attachments'];
|
||||
if (sizeof($attachments) > 0) {
|
||||
foreach ($attachments as &$attachment) {
|
||||
$fax_file_extension = pathinfo($attachment['name'], PATHINFO_EXTENSION);
|
||||
|
||||
//block unknown files
|
||||
if ($fax_file_extension == '') {continue; }
|
||||
//block unauthorized files
|
||||
if (!$fax_allowed_extension['.' . $fax_file_extension]) { continue; }
|
||||
//support only attachments
|
||||
if($attachment['disposition'] != 'attachment'){ continue; }
|
||||
|
||||
//store attachment in local fax temp folder
|
||||
$local_filepath = $fax_dir.'/'.$fax_extension.'/temp/'.$attachment['name'];
|
||||
file_put_contents($local_filepath, $attachment['data']);
|
||||
|
||||
//load files array with attachments
|
||||
$emailed_files['error'][] = 0;
|
||||
$emailed_files['size'][] = $attachment['size'];
|
||||
$emailed_files['tmp_name'][] = $attachment['name'];
|
||||
$emailed_files['name'][] = $attachment['name'];
|
||||
}
|
||||
}
|
||||
|
||||
//Debug print
|
||||
print('***********************' . "\n");
|
||||
print('fax message:' . "\n");
|
||||
print(' - length: ' . strlen($fax_message) . "\n");
|
||||
print('fax files [' . sizeof($emailed_files['name']) . ']:' . "\n");
|
||||
for($i = 0; $i < sizeof($emailed_files['name']);++$i){
|
||||
print(' - ' . $emailed_files['name'][$i] . ' - ' . $emailed_files['size'][$i] . "\n");
|
||||
}
|
||||
print('***********************' . "\n");
|
||||
|
||||
//send fax
|
||||
$cwd = getcwd();
|
||||
$included = true;
|
||||
require("fax_send.php");
|
||||
if($cwd){
|
||||
chdir($cwd);
|
||||
}
|
||||
|
||||
//reset variables
|
||||
unset($fax_numbers);
|
||||
}
|
||||
|
||||
//delete email
|
||||
if (imap_delete($connection, $email_id, FT_UID)) {
|
||||
imap_expunge($connection);
|
||||
}
|
||||
}
|
||||
unset($authorized_senders);
|
||||
}
|
||||
|
||||
//close account connection
|
||||
imap_close($connection);
|
||||
}
|
||||
}
|
||||
|
||||
//functions used above
|
||||
function load_default_settings() {
|
||||
global $db;
|
||||
|
||||
$sql = "select * from v_default_settings ";
|
||||
$sql .= "where default_setting_enabled = 'true' ";
|
||||
try {
|
||||
$prep_statement = $db->prepare($sql . " order by default_setting_order asc ");
|
||||
$prep_statement->execute();
|
||||
}
|
||||
catch(PDOException $e) {
|
||||
$prep_statement = $db->prepare($sql);
|
||||
$prep_statement->execute();
|
||||
}
|
||||
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
||||
//load the settings into an array
|
||||
foreach ($result as $row) {
|
||||
$name = $row['default_setting_name'];
|
||||
$category = $row['default_setting_category'];
|
||||
$subcategory = $row['default_setting_subcategory'];
|
||||
if (strlen($subcategory) == 0) {
|
||||
if ($name == "array") {
|
||||
$settings[$category][] = $row['default_setting_value'];
|
||||
}
|
||||
else {
|
||||
$settings[$category][$name] = $row['default_setting_value'];
|
||||
}
|
||||
} else {
|
||||
if ($name == "array") {
|
||||
$settings[$category][$subcategory][] = $row['default_setting_value'];
|
||||
}
|
||||
else {
|
||||
$settings[$category][$subcategory][$name] = $row['default_setting_value'];
|
||||
$settings[$category][$subcategory][$name] = $row['default_setting_value'];
|
||||
}
|
||||
}
|
||||
}
|
||||
return $settings;
|
||||
}
|
||||
|
||||
function load_domain_settings($domain_uuid) {
|
||||
global $db;
|
||||
|
||||
if ($domain_uuid) {
|
||||
$sql = "select * from v_domain_settings ";
|
||||
$sql .= "where domain_uuid = '" . $domain_uuid . "' ";
|
||||
$sql .= "and domain_setting_enabled = 'true' ";
|
||||
try {
|
||||
$prep_statement = $db->prepare($sql . " order by domain_setting_order asc ");
|
||||
$prep_statement->execute();
|
||||
}
|
||||
catch(PDOException $e) {
|
||||
$prep_statement = $db->prepare($sql);
|
||||
$prep_statement->execute();
|
||||
}
|
||||
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
||||
//unset the arrays that domains are overriding
|
||||
foreach ($result as $row) {
|
||||
$name = $row['domain_setting_name'];
|
||||
$category = $row['domain_setting_category'];
|
||||
$subcategory = $row['domain_setting_subcategory'];
|
||||
if ($name == "array") {
|
||||
unset($_SESSION[$category][$subcategory]);
|
||||
}
|
||||
}
|
||||
//set the settings as a session
|
||||
foreach ($result as $row) {
|
||||
$name = $row['domain_setting_name'];
|
||||
$category = $row['domain_setting_category'];
|
||||
$subcategory = $row['domain_setting_subcategory'];
|
||||
if (strlen($subcategory) == 0) {
|
||||
//$$category[$name] = $row['domain_setting_value'];
|
||||
if ($name == "array") {
|
||||
$_SESSION[$category][] = $row['domain_setting_value'];
|
||||
}
|
||||
else {
|
||||
$_SESSION[$category][$name] = $row['domain_setting_value'];
|
||||
}
|
||||
} else {
|
||||
//$$category[$subcategory][$name] = $row['domain_setting_value'];
|
||||
if ($name == "array") {
|
||||
$_SESSION[$category][$subcategory][] = $row['domain_setting_value'];
|
||||
}
|
||||
else {
|
||||
$_SESSION[$category][$subcategory][$name] = $row['domain_setting_value'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
+102
-102
@@ -1,103 +1,103 @@
|
||||
<?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) 2015
|
||||
the Initial Developer. All Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
Mark J Crane <markjcrane@fusionpbx.com>
|
||||
*/
|
||||
require_once "root.php";
|
||||
require_once "resources/require.php";
|
||||
require_once "resources/check_auth.php";
|
||||
if (permission_exists('fax_file_delete')) {
|
||||
//access granted
|
||||
}
|
||||
else {
|
||||
echo "access denied";
|
||||
exit;
|
||||
}
|
||||
|
||||
//add multi-lingual support
|
||||
require_once "app_languages.php";
|
||||
foreach($text as $key => $value) {
|
||||
$text[$key] = $value[$_SESSION['domain']['language']['code']];
|
||||
}
|
||||
|
||||
//get the id
|
||||
if (isset($_REQUEST["id"])) {
|
||||
$fax_file_uuid = check_str($_REQUEST["id"]);
|
||||
}
|
||||
|
||||
//validate the id
|
||||
if (strlen($fax_file_uuid) > 0) {
|
||||
//get the fax file data
|
||||
$sql = "select * 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();
|
||||
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
||||
foreach ($result as &$row) {
|
||||
$fax_uuid = $row["fax_uuid"];
|
||||
$fax_mode = $row["fax_mode"];
|
||||
$fax_file_path = $row["fax_file_path"];
|
||||
$fax_file_type = $row["fax_file_type"];
|
||||
}
|
||||
unset($prep_statement);
|
||||
|
||||
//set the type
|
||||
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 (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);
|
||||
}
|
||||
}
|
||||
|
||||
//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);
|
||||
|
||||
$_SESSION['message'] = $text['message-delete'];
|
||||
}
|
||||
|
||||
//redirect the user
|
||||
header('Location: fax_files.php?id='.$fax_uuid.'&box='.$type);
|
||||
|
||||
<?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) 2015
|
||||
the Initial Developer. All Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
Mark J Crane <markjcrane@fusionpbx.com>
|
||||
*/
|
||||
require_once "root.php";
|
||||
require_once "resources/require.php";
|
||||
require_once "resources/check_auth.php";
|
||||
if (permission_exists('fax_file_delete')) {
|
||||
//access granted
|
||||
}
|
||||
else {
|
||||
echo "access denied";
|
||||
exit;
|
||||
}
|
||||
|
||||
//add multi-lingual support
|
||||
require_once "app_languages.php";
|
||||
foreach($text as $key => $value) {
|
||||
$text[$key] = $value[$_SESSION['domain']['language']['code']];
|
||||
}
|
||||
|
||||
//get the id
|
||||
if (isset($_REQUEST["id"])) {
|
||||
$fax_file_uuid = check_str($_REQUEST["id"]);
|
||||
}
|
||||
|
||||
//validate the id
|
||||
if (strlen($fax_file_uuid) > 0) {
|
||||
//get the fax file data
|
||||
$sql = "select * 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();
|
||||
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
||||
foreach ($result as &$row) {
|
||||
$fax_uuid = $row["fax_uuid"];
|
||||
$fax_mode = $row["fax_mode"];
|
||||
$fax_file_path = $row["fax_file_path"];
|
||||
$fax_file_type = $row["fax_file_type"];
|
||||
}
|
||||
unset($prep_statement);
|
||||
|
||||
//set the type
|
||||
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 (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);
|
||||
}
|
||||
}
|
||||
|
||||
//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);
|
||||
|
||||
$_SESSION['message'] = $text['message-delete'];
|
||||
}
|
||||
|
||||
//redirect the user
|
||||
header('Location: fax_files.php?id='.$fax_uuid.'&box='.$type);
|
||||
|
||||
?>
|
||||
+393
-393
@@ -1,394 +1,394 @@
|
||||
<?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) 2015
|
||||
the Initial Developer. All Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
Mark J Crane <markjcrane@fusionpbx.com>
|
||||
*/
|
||||
require_once "root.php";
|
||||
require_once "resources/require.php";
|
||||
require_once "resources/check_auth.php";
|
||||
if (permission_exists('fax_file_view')) {
|
||||
//access granted
|
||||
}
|
||||
else {
|
||||
echo "access denied";
|
||||
exit;
|
||||
}
|
||||
|
||||
//add multi-lingual support
|
||||
$language = new text;
|
||||
$text = $language->get();
|
||||
|
||||
//get variables used to control the order
|
||||
$order_by = check_str($_GET["order_by"]);
|
||||
$order = check_str($_GET["order"]);
|
||||
|
||||
//get fax extension
|
||||
if (strlen($_GET['id']) > 0) {
|
||||
if (is_uuid($_GET["id"])) {
|
||||
$fax_uuid = $_GET["id"];
|
||||
}
|
||||
if (if_group("superadmin") || if_group("admin")) {
|
||||
//show all fax extensions
|
||||
$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 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' ";
|
||||
$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/'.$_SESSION['domain_name'];
|
||||
|
||||
//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);
|
||||
}
|
||||
}
|
||||
|
||||
//additional includes
|
||||
require_once "resources/header.php";
|
||||
require_once "resources/paging.php";
|
||||
|
||||
//prepare to page the results
|
||||
$sql = "select count(*) as num_rows from v_fax_files ";
|
||||
$sql .= "where fax_uuid = '$fax_uuid' ";
|
||||
$sql .= "and domain_uuid = '$domain_uuid' ";
|
||||
if ($_REQUEST['box'] == 'inbox') {
|
||||
$sql .= "and fax_mode = 'rx' ";
|
||||
}
|
||||
if ($_REQUEST['box'] == 'sent') {
|
||||
$sql .= "and fax_mode = 'tx' ";
|
||||
}
|
||||
$prep_statement = $db->prepare($sql);
|
||||
if ($prep_statement) {
|
||||
$prep_statement->execute();
|
||||
$row = $prep_statement->fetch(PDO::FETCH_ASSOC);
|
||||
if ($row['num_rows'] > 0) {
|
||||
$num_rows = $row['num_rows'];
|
||||
}
|
||||
else {
|
||||
$num_rows = '0';
|
||||
}
|
||||
}
|
||||
|
||||
//prepare to page the results
|
||||
$rows_per_page = ($_SESSION['domain']['paging']['numeric'] != '') ? $_SESSION['domain']['paging']['numeric'] : 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;
|
||||
|
||||
//get the list
|
||||
$sql = "select * from v_fax_files ";
|
||||
$sql .= "where fax_uuid = '$fax_uuid' ";
|
||||
$sql .= "and domain_uuid = '$domain_uuid' ";
|
||||
if ($_REQUEST['box'] == 'inbox') {
|
||||
$sql .= "and fax_mode = 'rx' ";
|
||||
}
|
||||
if ($_REQUEST['box'] == 'sent') {
|
||||
$sql .= "and fax_mode = 'tx' ";
|
||||
}
|
||||
$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();
|
||||
$fax_files = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
||||
unset ($prep_statement, $sql);
|
||||
|
||||
//show the header
|
||||
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')) {
|
||||
echo " <b>".$text['header-inbox'].": <span style='color: #000;'>".$fax_name." (".$fax_extension.")</span></b>\n";
|
||||
}
|
||||
if ($_REQUEST['box'] == 'sent' && permission_exists('fax_sent_view')) {
|
||||
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='back' onclick=\"window.location='fax.php'\" value='".$text['button-back']."'>\n";
|
||||
echo " </td>\n";
|
||||
echo " </tr>\n";
|
||||
echo "</table>\n";
|
||||
echo "<br>\n";
|
||||
|
||||
//show the table and content
|
||||
$c = 0;
|
||||
$row_style["0"] = "row_style0";
|
||||
$row_style["1"] = "row_style1";
|
||||
|
||||
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_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 ($num_rows > 0) {
|
||||
foreach($fax_files as $row) {
|
||||
$file = basename($row['fax_file_path']);
|
||||
if (strtolower(substr($file, -3)) == "tif" || strtolower(substr($file, -3)) == "pdf") {
|
||||
$file_name = substr($file, 0, (strlen($file) -4));
|
||||
}
|
||||
$file_ext = $row['fax_file_type'];
|
||||
|
||||
//decode the base64
|
||||
if (strlen($row['fax_base64']) > 0) {
|
||||
if ($_REQUEST['box'] == 'inbox' && permission_exists('fax_inbox_view')) {
|
||||
if (!file_exists($dir_fax_inbox.'/'.$file)) {
|
||||
file_put_contents($dir_fax_inbox.'/'.$file, base64_decode($row['fax_base64']));
|
||||
}
|
||||
}
|
||||
if ($_REQUEST['box'] == 'sent' && permission_exists('fax_sent_view')) {
|
||||
if (!file_exists($dir_fax_sent.'/'.$file)) {
|
||||
//decode the base64
|
||||
file_put_contents($dir_fax_sent.'/'.$file, base64_decode($row['fax_base64']));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//convert the tif to pdf
|
||||
unset($dir_fax);
|
||||
if ($_REQUEST['box'] == 'inbox' && permission_exists('fax_inbox_view')) {
|
||||
if (!file_exists($dir_fax_inbox.'/'.$file_name.".pdf")) {
|
||||
$dir_fax = $dir_fax_inbox;
|
||||
}
|
||||
}
|
||||
if ($_REQUEST['box'] == 'sent' && permission_exists('fax_sent_view')) {
|
||||
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";
|
||||
if ($_REQUEST['box'] == 'inbox') {
|
||||
$dir_fax = $dir_fax_inbox;
|
||||
}
|
||||
if ($_REQUEST['box'] == 'sent') {
|
||||
$dir_fax = $dir_fax_sent;
|
||||
}
|
||||
if (file_exists($dir_fax.'/'.$file_name.".pdf")) {
|
||||
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_name).".pdf\">PDF</a>\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_name).".pdf\">PDF</a>\n";
|
||||
}
|
||||
}
|
||||
else {
|
||||
echo " \n";
|
||||
}
|
||||
echo " </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 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";
|
||||
$c = ($c) ? 0 : 1;
|
||||
} //end foreach
|
||||
unset($sql, $fax_files);
|
||||
} //end if results
|
||||
|
||||
//show the paging controls
|
||||
echo "</table>";
|
||||
echo "<br /><br />";
|
||||
|
||||
echo "<div align='center'>".$paging_controls."</div>\n";
|
||||
echo "<br /><br />";
|
||||
|
||||
//include the footer
|
||||
require_once "resources/footer.php";
|
||||
<?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) 2015
|
||||
the Initial Developer. All Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
Mark J Crane <markjcrane@fusionpbx.com>
|
||||
*/
|
||||
require_once "root.php";
|
||||
require_once "resources/require.php";
|
||||
require_once "resources/check_auth.php";
|
||||
if (permission_exists('fax_file_view')) {
|
||||
//access granted
|
||||
}
|
||||
else {
|
||||
echo "access denied";
|
||||
exit;
|
||||
}
|
||||
|
||||
//add multi-lingual support
|
||||
$language = new text;
|
||||
$text = $language->get();
|
||||
|
||||
//get variables used to control the order
|
||||
$order_by = check_str($_GET["order_by"]);
|
||||
$order = check_str($_GET["order"]);
|
||||
|
||||
//get fax extension
|
||||
if (strlen($_GET['id']) > 0) {
|
||||
if (is_uuid($_GET["id"])) {
|
||||
$fax_uuid = $_GET["id"];
|
||||
}
|
||||
if (if_group("superadmin") || if_group("admin")) {
|
||||
//show all fax extensions
|
||||
$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 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' ";
|
||||
$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/'.$_SESSION['domain_name'];
|
||||
|
||||
//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);
|
||||
}
|
||||
}
|
||||
|
||||
//additional includes
|
||||
require_once "resources/header.php";
|
||||
require_once "resources/paging.php";
|
||||
|
||||
//prepare to page the results
|
||||
$sql = "select count(*) as num_rows from v_fax_files ";
|
||||
$sql .= "where fax_uuid = '$fax_uuid' ";
|
||||
$sql .= "and domain_uuid = '$domain_uuid' ";
|
||||
if ($_REQUEST['box'] == 'inbox') {
|
||||
$sql .= "and fax_mode = 'rx' ";
|
||||
}
|
||||
if ($_REQUEST['box'] == 'sent') {
|
||||
$sql .= "and fax_mode = 'tx' ";
|
||||
}
|
||||
$prep_statement = $db->prepare($sql);
|
||||
if ($prep_statement) {
|
||||
$prep_statement->execute();
|
||||
$row = $prep_statement->fetch(PDO::FETCH_ASSOC);
|
||||
if ($row['num_rows'] > 0) {
|
||||
$num_rows = $row['num_rows'];
|
||||
}
|
||||
else {
|
||||
$num_rows = '0';
|
||||
}
|
||||
}
|
||||
|
||||
//prepare to page the results
|
||||
$rows_per_page = ($_SESSION['domain']['paging']['numeric'] != '') ? $_SESSION['domain']['paging']['numeric'] : 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;
|
||||
|
||||
//get the list
|
||||
$sql = "select * from v_fax_files ";
|
||||
$sql .= "where fax_uuid = '$fax_uuid' ";
|
||||
$sql .= "and domain_uuid = '$domain_uuid' ";
|
||||
if ($_REQUEST['box'] == 'inbox') {
|
||||
$sql .= "and fax_mode = 'rx' ";
|
||||
}
|
||||
if ($_REQUEST['box'] == 'sent') {
|
||||
$sql .= "and fax_mode = 'tx' ";
|
||||
}
|
||||
$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();
|
||||
$fax_files = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
||||
unset ($prep_statement, $sql);
|
||||
|
||||
//show the header
|
||||
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')) {
|
||||
echo " <b>".$text['header-inbox'].": <span style='color: #000;'>".$fax_name." (".$fax_extension.")</span></b>\n";
|
||||
}
|
||||
if ($_REQUEST['box'] == 'sent' && permission_exists('fax_sent_view')) {
|
||||
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='back' onclick=\"window.location='fax.php'\" value='".$text['button-back']."'>\n";
|
||||
echo " </td>\n";
|
||||
echo " </tr>\n";
|
||||
echo "</table>\n";
|
||||
echo "<br>\n";
|
||||
|
||||
//show the table and content
|
||||
$c = 0;
|
||||
$row_style["0"] = "row_style0";
|
||||
$row_style["1"] = "row_style1";
|
||||
|
||||
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_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 ($num_rows > 0) {
|
||||
foreach($fax_files as $row) {
|
||||
$file = basename($row['fax_file_path']);
|
||||
if (strtolower(substr($file, -3)) == "tif" || strtolower(substr($file, -3)) == "pdf") {
|
||||
$file_name = substr($file, 0, (strlen($file) -4));
|
||||
}
|
||||
$file_ext = $row['fax_file_type'];
|
||||
|
||||
//decode the base64
|
||||
if (strlen($row['fax_base64']) > 0) {
|
||||
if ($_REQUEST['box'] == 'inbox' && permission_exists('fax_inbox_view')) {
|
||||
if (!file_exists($dir_fax_inbox.'/'.$file)) {
|
||||
file_put_contents($dir_fax_inbox.'/'.$file, base64_decode($row['fax_base64']));
|
||||
}
|
||||
}
|
||||
if ($_REQUEST['box'] == 'sent' && permission_exists('fax_sent_view')) {
|
||||
if (!file_exists($dir_fax_sent.'/'.$file)) {
|
||||
//decode the base64
|
||||
file_put_contents($dir_fax_sent.'/'.$file, base64_decode($row['fax_base64']));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//convert the tif to pdf
|
||||
unset($dir_fax);
|
||||
if ($_REQUEST['box'] == 'inbox' && permission_exists('fax_inbox_view')) {
|
||||
if (!file_exists($dir_fax_inbox.'/'.$file_name.".pdf")) {
|
||||
$dir_fax = $dir_fax_inbox;
|
||||
}
|
||||
}
|
||||
if ($_REQUEST['box'] == 'sent' && permission_exists('fax_sent_view')) {
|
||||
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";
|
||||
if ($_REQUEST['box'] == 'inbox') {
|
||||
$dir_fax = $dir_fax_inbox;
|
||||
}
|
||||
if ($_REQUEST['box'] == 'sent') {
|
||||
$dir_fax = $dir_fax_sent;
|
||||
}
|
||||
if (file_exists($dir_fax.'/'.$file_name.".pdf")) {
|
||||
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_name).".pdf\">PDF</a>\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_name).".pdf\">PDF</a>\n";
|
||||
}
|
||||
}
|
||||
else {
|
||||
echo " \n";
|
||||
}
|
||||
echo " </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 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";
|
||||
$c = ($c) ? 0 : 1;
|
||||
} //end foreach
|
||||
unset($sql, $fax_files);
|
||||
} //end if results
|
||||
|
||||
//show the paging controls
|
||||
echo "</table>";
|
||||
echo "<br /><br />";
|
||||
|
||||
echo "<div align='center'>".$paging_controls."</div>\n";
|
||||
echo "<br /><br />";
|
||||
|
||||
//include the footer
|
||||
require_once "resources/footer.php";
|
||||
?>
|
||||
+243
-243
@@ -1,243 +1,243 @@
|
||||
<?php
|
||||
/*
|
||||
FusionPBX
|
||||
Version: MPL 1.1
|
||||
|
||||
The contents of this file are subject to the Mozilla Public License Version
|
||||
1.1 (the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
http://www.mozilla.org/MPL/
|
||||
|
||||
Software distributed under the License is distributed on an "AS IS" basis,
|
||||
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
for the specific language governing rights and limitations under the
|
||||
License.
|
||||
|
||||
The Original Code is FusionPBX
|
||||
|
||||
The Initial Developer of the Original Code is
|
||||
Mark J Crane <markjcrane@fusionpbx.com>
|
||||
Portions created by the Initial Developer are Copyright (C) 2008-2012
|
||||
the Initial Developer. All Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
Mark J Crane <markjcrane@fusionpbx.com>
|
||||
James Rose <james.o.rose@gmail.com>
|
||||
*/
|
||||
include "root.php";
|
||||
require_once "resources/require.php";
|
||||
require_once "resources/check_auth.php";
|
||||
require_once "resources/functions/object_to_array.php";
|
||||
require_once "resources/functions/parse_attachments.php";
|
||||
if (permission_exists('fax_inbox_view')) {
|
||||
//access granted
|
||||
}
|
||||
else {
|
||||
echo "access denied";
|
||||
exit;
|
||||
}
|
||||
|
||||
//add multi-lingual support
|
||||
$language = new text;
|
||||
$text = $language->get();
|
||||
|
||||
//get fax server uuid, set connection parameters
|
||||
if (strlen($_GET['id']) > 0) {
|
||||
$fax_uuid = check_str($_GET["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")) {
|
||||
echo "access denied";
|
||||
exit;
|
||||
}
|
||||
}
|
||||
foreach ($result as &$row) {
|
||||
$fax_name = $row["fax_name"];
|
||||
$fax_extension = $row["fax_extension"];
|
||||
$fax_email_connection_type = $row["fax_email_connection_type"];
|
||||
$fax_email_connection_host = $row["fax_email_connection_host"];
|
||||
$fax_email_connection_port = $row["fax_email_connection_port"];
|
||||
$fax_email_connection_security = $row["fax_email_connection_security"];
|
||||
$fax_email_connection_validate = $row["fax_email_connection_validate"];
|
||||
$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);
|
||||
|
||||
// make connection
|
||||
$fax_email_connection = "{".$fax_email_connection_host.":".$fax_email_connection_port."/".$fax_email_connection_type;
|
||||
$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 (!$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");
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
header("Location: fax.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
//message action
|
||||
if ($_GET['email_id'] != '') {
|
||||
$email_id = check_str($_GET['email_id']);
|
||||
|
||||
//download attachment
|
||||
if (isset($_GET['download'])) {
|
||||
$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;
|
||||
case "tif" : header("Contet-Type: image/tiff"); break;
|
||||
}
|
||||
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: ".strlen($attachment[0]['attachment']));
|
||||
$browser = $_SERVER["HTTP_USER_AGENT"];
|
||||
if (preg_match("/MSIE 5.5/", $browser) || preg_match("/MSIE 6.0/", $browser)) {
|
||||
header("Content-Disposition: filename=\"".$attachment[0]['filename']."\"");
|
||||
}
|
||||
else {
|
||||
header("Content-Disposition: attachment; filename=\"".$attachment[0]['filename']."\"");
|
||||
}
|
||||
header("Content-Transfer-Encoding: binary");
|
||||
echo $attachment[0]['attachment'];
|
||||
exit;
|
||||
}
|
||||
|
||||
//delete email
|
||||
if (isset($_GET['delete']) && permission_exists('fax_inbox_delete')) {
|
||||
$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/'.$_SESSION['domain_name'];
|
||||
@unlink($fax_dir.'/'.$fax_extension.'/inbox/'.$attachment[0]['filename']);
|
||||
//redirect user
|
||||
$_SESSION["message"] = $text['message-delete'];
|
||||
header("Location: ?id=".$fax_uuid);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
else {
|
||||
//redirect user
|
||||
$_SESSION["message_mood"] = "negative";
|
||||
$_SESSION["message"] = $text['message-delete_failed'];
|
||||
header("Location: ?id=".$fax_uuid);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
else {
|
||||
//redirect user
|
||||
$_SESSION["message_mood"] = "negative";
|
||||
$_SESSION["message"] = $text['message-delete_failed'];
|
||||
header("Location: ?id=".$fax_uuid);
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//get emails
|
||||
$emails = imap_search($connection, "SUBJECT \"".$fax_email_inbound_subject_tag."\"", SE_UID);
|
||||
|
||||
//show the header
|
||||
require_once "resources/header.php";
|
||||
|
||||
$row_style["0"] = "row_style0";
|
||||
$row_style["1"] = "row_style1";
|
||||
|
||||
//show the inbox
|
||||
$c = 0;
|
||||
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' alt='".$text['button-back']."' onclick=\"window.location='fax.php';\" value='".$text['button-back']."'>\n";
|
||||
echo " <input type='button' class='btn' alt='".$text['button-refresh']."' onclick=\"document.location.reload();\" value='".$text['button-refresh']."'>\n";
|
||||
echo " </td>\n";
|
||||
echo " </tr>\n";
|
||||
echo "</table>\n";
|
||||
echo "<br><br>\n";
|
||||
|
||||
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
|
||||
echo " <tr>\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 style='width: 25px;' class='list_control_icons'> </td>\n";
|
||||
}
|
||||
echo " </tr>";
|
||||
|
||||
if ($emails) {
|
||||
|
||||
rsort($emails); // most recent on top
|
||||
|
||||
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);
|
||||
$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 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";
|
||||
// $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;
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
echo "<tr valign='top'>\n";
|
||||
echo " <td colspan='4' style='text-align: center;'><br><br>".$text['message-no_faxes_found']."<br><br></td>\n";
|
||||
echo "</tr>\n";
|
||||
}
|
||||
|
||||
echo "</table>";
|
||||
echo "<br><br>";
|
||||
|
||||
/* close the connection */
|
||||
imap_close($connection);
|
||||
|
||||
|
||||
//show the footer
|
||||
require_once "resources/footer.php";
|
||||
?>
|
||||
<?php
|
||||
/*
|
||||
FusionPBX
|
||||
Version: MPL 1.1
|
||||
|
||||
The contents of this file are subject to the Mozilla Public License Version
|
||||
1.1 (the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
http://www.mozilla.org/MPL/
|
||||
|
||||
Software distributed under the License is distributed on an "AS IS" basis,
|
||||
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
for the specific language governing rights and limitations under the
|
||||
License.
|
||||
|
||||
The Original Code is FusionPBX
|
||||
|
||||
The Initial Developer of the Original Code is
|
||||
Mark J Crane <markjcrane@fusionpbx.com>
|
||||
Portions created by the Initial Developer are Copyright (C) 2008-2012
|
||||
the Initial Developer. All Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
Mark J Crane <markjcrane@fusionpbx.com>
|
||||
James Rose <james.o.rose@gmail.com>
|
||||
*/
|
||||
include "root.php";
|
||||
require_once "resources/require.php";
|
||||
require_once "resources/check_auth.php";
|
||||
require_once "resources/functions/object_to_array.php";
|
||||
require_once "resources/functions/parse_attachments.php";
|
||||
if (permission_exists('fax_inbox_view')) {
|
||||
//access granted
|
||||
}
|
||||
else {
|
||||
echo "access denied";
|
||||
exit;
|
||||
}
|
||||
|
||||
//add multi-lingual support
|
||||
$language = new text;
|
||||
$text = $language->get();
|
||||
|
||||
//get fax server uuid, set connection parameters
|
||||
if (strlen($_GET['id']) > 0) {
|
||||
$fax_uuid = check_str($_GET["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")) {
|
||||
echo "access denied";
|
||||
exit;
|
||||
}
|
||||
}
|
||||
foreach ($result as &$row) {
|
||||
$fax_name = $row["fax_name"];
|
||||
$fax_extension = $row["fax_extension"];
|
||||
$fax_email_connection_type = $row["fax_email_connection_type"];
|
||||
$fax_email_connection_host = $row["fax_email_connection_host"];
|
||||
$fax_email_connection_port = $row["fax_email_connection_port"];
|
||||
$fax_email_connection_security = $row["fax_email_connection_security"];
|
||||
$fax_email_connection_validate = $row["fax_email_connection_validate"];
|
||||
$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);
|
||||
|
||||
// make connection
|
||||
$fax_email_connection = "{".$fax_email_connection_host.":".$fax_email_connection_port."/".$fax_email_connection_type;
|
||||
$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 (!$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");
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
header("Location: fax.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
//message action
|
||||
if ($_GET['email_id'] != '') {
|
||||
$email_id = check_str($_GET['email_id']);
|
||||
|
||||
//download attachment
|
||||
if (isset($_GET['download'])) {
|
||||
$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;
|
||||
case "tif" : header("Contet-Type: image/tiff"); break;
|
||||
}
|
||||
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: ".strlen($attachment[0]['attachment']));
|
||||
$browser = $_SERVER["HTTP_USER_AGENT"];
|
||||
if (preg_match("/MSIE 5.5/", $browser) || preg_match("/MSIE 6.0/", $browser)) {
|
||||
header("Content-Disposition: filename=\"".$attachment[0]['filename']."\"");
|
||||
}
|
||||
else {
|
||||
header("Content-Disposition: attachment; filename=\"".$attachment[0]['filename']."\"");
|
||||
}
|
||||
header("Content-Transfer-Encoding: binary");
|
||||
echo $attachment[0]['attachment'];
|
||||
exit;
|
||||
}
|
||||
|
||||
//delete email
|
||||
if (isset($_GET['delete']) && permission_exists('fax_inbox_delete')) {
|
||||
$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/'.$_SESSION['domain_name'];
|
||||
@unlink($fax_dir.'/'.$fax_extension.'/inbox/'.$attachment[0]['filename']);
|
||||
//redirect user
|
||||
$_SESSION["message"] = $text['message-delete'];
|
||||
header("Location: ?id=".$fax_uuid);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
else {
|
||||
//redirect user
|
||||
$_SESSION["message_mood"] = "negative";
|
||||
$_SESSION["message"] = $text['message-delete_failed'];
|
||||
header("Location: ?id=".$fax_uuid);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
else {
|
||||
//redirect user
|
||||
$_SESSION["message_mood"] = "negative";
|
||||
$_SESSION["message"] = $text['message-delete_failed'];
|
||||
header("Location: ?id=".$fax_uuid);
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//get emails
|
||||
$emails = imap_search($connection, "SUBJECT \"".$fax_email_inbound_subject_tag."\"", SE_UID);
|
||||
|
||||
//show the header
|
||||
require_once "resources/header.php";
|
||||
|
||||
$row_style["0"] = "row_style0";
|
||||
$row_style["1"] = "row_style1";
|
||||
|
||||
//show the inbox
|
||||
$c = 0;
|
||||
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' alt='".$text['button-back']."' onclick=\"window.location='fax.php';\" value='".$text['button-back']."'>\n";
|
||||
echo " <input type='button' class='btn' alt='".$text['button-refresh']."' onclick=\"document.location.reload();\" value='".$text['button-refresh']."'>\n";
|
||||
echo " </td>\n";
|
||||
echo " </tr>\n";
|
||||
echo "</table>\n";
|
||||
echo "<br><br>\n";
|
||||
|
||||
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
|
||||
echo " <tr>\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 style='width: 25px;' class='list_control_icons'> </td>\n";
|
||||
}
|
||||
echo " </tr>";
|
||||
|
||||
if ($emails) {
|
||||
|
||||
rsort($emails); // most recent on top
|
||||
|
||||
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);
|
||||
$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 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";
|
||||
// $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;
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
echo "<tr valign='top'>\n";
|
||||
echo " <td colspan='4' style='text-align: center;'><br><br>".$text['message-no_faxes_found']."<br><br></td>\n";
|
||||
echo "</tr>\n";
|
||||
}
|
||||
|
||||
echo "</table>";
|
||||
echo "<br><br>";
|
||||
|
||||
/* close the connection */
|
||||
imap_close($connection);
|
||||
|
||||
|
||||
//show the footer
|
||||
require_once "resources/footer.php";
|
||||
?>
|
||||
|
||||
+1103
-1103
File diff suppressed because it is too large
Load Diff
+247
-247
@@ -1,248 +1,248 @@
|
||||
<?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>
|
||||
Copyright (C) 2015
|
||||
All Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
Mark J Crane <markjcrane@fusionpbx.com>
|
||||
*/
|
||||
|
||||
/**
|
||||
* cache class provides an abstracted cache
|
||||
*
|
||||
* @method string dialplan - builds the dialplan for the fax servers
|
||||
*/
|
||||
//define the fax class
|
||||
if (!class_exists('fax')) {
|
||||
class fax {
|
||||
/**
|
||||
* define the variables
|
||||
*/
|
||||
public $domain_uuid;
|
||||
public $fax_uuid;
|
||||
public $dialplan_uuid;
|
||||
public $fax_name;
|
||||
public $fax_description;
|
||||
public $fax_extension;
|
||||
public $fax_forward_number;
|
||||
public $destination_number;
|
||||
private $forward_prefix;
|
||||
|
||||
/**
|
||||
* Called when the object is created
|
||||
*/
|
||||
public function __construct() {
|
||||
//place holder
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when there are no references to a particular object
|
||||
* unset the variables used in the class
|
||||
*/
|
||||
public function __destruct() {
|
||||
foreach ($this as $key => $value) {
|
||||
unset($this->$key);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a dialplan for call center
|
||||
* @var string $domain_uuid the multi-tenant id
|
||||
* @var string $value string to be cached
|
||||
*/
|
||||
public function dialplan() {
|
||||
|
||||
//normalize the fax forward number
|
||||
if (strlen($this->fax_forward_number) > 3) {
|
||||
//$fax_forward_number = preg_replace("~[^0-9]~", "",$fax_forward_number);
|
||||
$this->fax_forward_number = str_replace(" ", "", $this->fax_forward_number);
|
||||
$this->fax_forward_number = str_replace("-", "", $this->fax_forward_number);
|
||||
}
|
||||
|
||||
//set the forward prefix
|
||||
if (strripos($this->fax_forward_number, '$1') === false) {
|
||||
$this->forward_prefix = ''; //not found
|
||||
} else {
|
||||
$this->forward_prefix = $this->forward_prefix.$this->fax_forward_number.'#'; //found
|
||||
}
|
||||
|
||||
//delete previous dialplan
|
||||
if (strlen($this->dialplan_uuid) > 0) {
|
||||
//delete the previous dialplan
|
||||
$sql = "delete from v_dialplans ";
|
||||
$sql .= "where dialplan_uuid = '".$this->dialplan_uuid."' ";
|
||||
$sql .= "and domain_uuid = '".$this->domain_uuid."' ";
|
||||
$this->db->exec($sql);
|
||||
|
||||
$sql = "delete from v_dialplan_details ";
|
||||
$sql .= "where dialplan_uuid = '".$this->dialplan_uuid."' ";
|
||||
$sql .= "and domain_uuid = '".$this->domain_uuid."' ";
|
||||
$this->db->exec($sql);
|
||||
unset($sql);
|
||||
}
|
||||
unset($prep_statement);
|
||||
|
||||
//build the dialplan array
|
||||
$dialplan["app_uuid"] = "24108154-4ac3-1db6-1551-4731703a4440";
|
||||
$dialplan["domain_uuid"] = $this->domain_uuid;
|
||||
$dialplan["dialplan_name"] = ($this->fax_name != '') ? $this->fax_name : format_phone($this->destination_number);
|
||||
$dialplan["dialplan_number"] = $this->fax_extension;
|
||||
$dialplan["dialplan_context"] = $_SESSION['context'];
|
||||
$dialplan["dialplan_continue"] = "false";
|
||||
$dialplan["dialplan_order"] = "310";
|
||||
$dialplan["dialplan_enabled"] = "true";
|
||||
$dialplan["dialplan_description"] = $this->fax_description;
|
||||
$dialplan_detail_order = 10;
|
||||
|
||||
//add the public condition
|
||||
$y = 1;
|
||||
$dialplan["dialplan_details"][$y]["domain_uuid"] = $this->domain_uuid;
|
||||
$dialplan["dialplan_details"][$y]["dialplan_detail_tag"] = "condition";
|
||||
$dialplan["dialplan_details"][$y]["dialplan_detail_type"] = "destination_number";
|
||||
$dialplan["dialplan_details"][$y]["dialplan_detail_data"] = "^".$this->destination_number."\$";
|
||||
$dialplan["dialplan_details"][$y]["dialplan_detail_break"] = "";
|
||||
$dialplan["dialplan_details"][$y]["dialplan_detail_group"] = "1";
|
||||
$dialplan["dialplan_details"][$y]["dialplan_detail_order"] = $y * 10;
|
||||
$y++;
|
||||
$dialplan["dialplan_details"][$y]["domain_uuid"] = $this->domain_uuid;
|
||||
$dialplan["dialplan_details"][$y]["dialplan_detail_tag"] = "action";
|
||||
$dialplan["dialplan_details"][$y]["dialplan_detail_type"] = "answer";
|
||||
$dialplan["dialplan_details"][$y]["dialplan_detail_data"] = "";
|
||||
$dialplan["dialplan_details"][$y]["dialplan_detail_group"] = "1";
|
||||
$dialplan["dialplan_details"][$y]["dialplan_detail_order"] = $y * 10;
|
||||
$y++;
|
||||
$dialplan["dialplan_details"][$y]["domain_uuid"] = $this->domain_uuid;
|
||||
$dialplan["dialplan_details"][$y]["dialplan_detail_tag"] = "action";
|
||||
$dialplan["dialplan_details"][$y]["dialplan_detail_type"] = "set";
|
||||
$dialplan["dialplan_details"][$y]["dialplan_detail_data"] = "fax_uuid=".$this->fax_uuid;
|
||||
$dialplan["dialplan_details"][$y]["dialplan_detail_group"] = "1";
|
||||
$dialplan["dialplan_details"][$y]["dialplan_detail_order"] = $y * 10;
|
||||
$y++;
|
||||
$dialplan["dialplan_details"][$y]["domain_uuid"] = $this->domain_uuid;
|
||||
$dialplan["dialplan_details"][$y]["dialplan_detail_tag"] = "action";
|
||||
$dialplan["dialplan_details"][$y]["dialplan_detail_type"] = "set";
|
||||
$dialplan["dialplan_details"][$y]["dialplan_detail_data"] = "api_hangup_hook=lua app/fax/resources/scripts/hangup_rx.lua";
|
||||
$dialplan["dialplan_details"][$y]["dialplan_detail_group"] = "1";
|
||||
$dialplan["dialplan_details"][$y]["dialplan_detail_order"] = $y * 10;
|
||||
$y++;
|
||||
foreach($_SESSION['fax']['variable'] as $data) {
|
||||
$dialplan["dialplan_details"][$y]["domain_uuid"] = $this->domain_uuid;
|
||||
$dialplan["dialplan_details"][$y]["dialplan_detail_tag"] = "action";
|
||||
$dialplan["dialplan_details"][$y]["dialplan_detail_type"] = "set";
|
||||
if (substr($data,0,8) == "inbound:") {
|
||||
$dialplan["dialplan_details"][$y]["dialplan_detail_data"] = substr($data,8,strlen($data));
|
||||
}
|
||||
elseif (substr($data,0,9) == "outbound:") {}
|
||||
else {
|
||||
$dialplan["dialplan_details"][$y]["dialplan_detail_data"] = $data;
|
||||
}
|
||||
$dialplan["dialplan_details"][$y]["dialplan_detail_group"] = "1";
|
||||
$dialplan["dialplan_details"][$y]["dialplan_detail_order"] = $y * 10;
|
||||
$y++;
|
||||
}
|
||||
$dialplan["dialplan_details"][$y]["domain_uuid"] = $this->domain_uuid;
|
||||
$dialplan["dialplan_details"][$y]["dialplan_detail_tag"] = "action";
|
||||
$dialplan["dialplan_details"][$y]["dialplan_detail_type"] = "set";
|
||||
if (strlen($_SESSION['fax']['last_fax']['text']) > 0) {
|
||||
$dialplan["dialplan_details"][$y]["dialplan_detail_data"] = "last_fax=".$_SESSION['fax']['last_fax']['text'];
|
||||
}
|
||||
else {
|
||||
$dialplan["dialplan_details"][$y]["dialplan_detail_data"] = "last_fax=\${caller_id_number}-\${strftime(%Y-%m-%d-%H-%M-%S)}";
|
||||
}
|
||||
$dialplan["dialplan_details"][$y]["dialplan_detail_group"] = "1";
|
||||
$dialplan["dialplan_details"][$y]["dialplan_detail_order"] = $y * 10;
|
||||
$y++;
|
||||
$dialplan["dialplan_details"][$y]["domain_uuid"] = $this->domain_uuid;
|
||||
$dialplan["dialplan_details"][$y]["dialplan_detail_tag"] = "action";
|
||||
$dialplan["dialplan_details"][$y]["dialplan_detail_type"] = "playback";
|
||||
$dialplan["dialplan_details"][$y]["dialplan_detail_data"] = "silence_stream://2000";
|
||||
$dialplan["dialplan_details"][$y]["dialplan_detail_group"] = "1";
|
||||
$dialplan["dialplan_details"][$y]["dialplan_detail_order"] = $y * 10;
|
||||
$y++;
|
||||
$dialplan["dialplan_details"][$y]["domain_uuid"] = $this->domain_uuid;
|
||||
$dialplan["dialplan_details"][$y]["dialplan_detail_tag"] = "action";
|
||||
$dialplan["dialplan_details"][$y]["dialplan_detail_type"] = "rxfax";
|
||||
$dialplan["dialplan_details"][$y]["dialplan_detail_data"] = $_SESSION['switch']['storage']['dir'].'/fax/'.$_SESSION['domain_name'].'/'.$this->fax_extension.'/inbox/'.$this->forward_prefix.'${last_fax}.tif';
|
||||
$dialplan["dialplan_details"][$y]["dialplan_detail_group"] = "1";
|
||||
$dialplan["dialplan_details"][$y]["dialplan_detail_order"] = $y * 10;
|
||||
$y++;
|
||||
$dialplan["dialplan_details"][$y]["domain_uuid"] = $this->domain_uuid;
|
||||
$dialplan["dialplan_details"][$y]["dialplan_detail_tag"] = "action";
|
||||
$dialplan["dialplan_details"][$y]["dialplan_detail_type"] = "hangup";
|
||||
$dialplan["dialplan_details"][$y]["dialplan_detail_data"] = "";
|
||||
$dialplan["dialplan_details"][$y]["dialplan_detail_group"] = "1";
|
||||
$dialplan["dialplan_details"][$y]["dialplan_detail_order"] = $y * 10;
|
||||
$y++;
|
||||
|
||||
//add the dialplan permission
|
||||
$p = new permissions;
|
||||
$p->add("dialplan_add", 'temp');
|
||||
$p->add("dialplan_detail_add", 'temp');
|
||||
$p->add("dialplan_edit", 'temp');
|
||||
$p->add("dialplan_detail_edit", 'temp');
|
||||
|
||||
//save the dialplan
|
||||
$orm = new orm;
|
||||
$orm->name('dialplans');
|
||||
$orm->save($dialplan);
|
||||
$dialplan_response = $orm->message;
|
||||
$this->dialplan_uuid = $dialplan_response['uuid'];
|
||||
|
||||
//if new dialplan uuid then update the call center queue
|
||||
$sql = "update v_fax ";
|
||||
$sql .= "set dialplan_uuid = '".$this->dialplan_uuid."' ";
|
||||
$sql .= "where fax_uuid = '".$this->fax_uuid."' ";
|
||||
$sql .= "and domain_uuid = '".$this->domain_uuid."' ";
|
||||
$this->db->exec($sql);
|
||||
unset($sql);
|
||||
|
||||
//remove the temporary permission
|
||||
$p->delete("dialplan_add", 'temp');
|
||||
$p->delete("dialplan_detail_add", 'temp');
|
||||
$p->delete("dialplan_edit", 'temp');
|
||||
$p->delete("dialplan_detail_edit", 'temp');
|
||||
|
||||
//synchronize the xml config
|
||||
save_dialplan_xml();
|
||||
|
||||
//clear the cache
|
||||
$cache = new cache;
|
||||
$cache->delete("dialplan:".$_SESSION['context']);
|
||||
|
||||
//return the dialplan_uuid
|
||||
return $dialplan_response;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
$o = new fax;
|
||||
$c->domain_uuid = "";
|
||||
$c->dialplan_uuid = "";
|
||||
$c->fax_name = "";
|
||||
$c->fax_extension = $fax_extension;
|
||||
$c->fax_forward_number = $fax_forward_number;
|
||||
$c->destination_number = $fax_destination_number;
|
||||
$c->fax_description = $fax_description;
|
||||
$c->dialplan();
|
||||
*/
|
||||
|
||||
<?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>
|
||||
Copyright (C) 2015
|
||||
All Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
Mark J Crane <markjcrane@fusionpbx.com>
|
||||
*/
|
||||
|
||||
/**
|
||||
* cache class provides an abstracted cache
|
||||
*
|
||||
* @method string dialplan - builds the dialplan for the fax servers
|
||||
*/
|
||||
//define the fax class
|
||||
if (!class_exists('fax')) {
|
||||
class fax {
|
||||
/**
|
||||
* define the variables
|
||||
*/
|
||||
public $domain_uuid;
|
||||
public $fax_uuid;
|
||||
public $dialplan_uuid;
|
||||
public $fax_name;
|
||||
public $fax_description;
|
||||
public $fax_extension;
|
||||
public $fax_forward_number;
|
||||
public $destination_number;
|
||||
private $forward_prefix;
|
||||
|
||||
/**
|
||||
* Called when the object is created
|
||||
*/
|
||||
public function __construct() {
|
||||
//place holder
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when there are no references to a particular object
|
||||
* unset the variables used in the class
|
||||
*/
|
||||
public function __destruct() {
|
||||
foreach ($this as $key => $value) {
|
||||
unset($this->$key);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a dialplan for call center
|
||||
* @var string $domain_uuid the multi-tenant id
|
||||
* @var string $value string to be cached
|
||||
*/
|
||||
public function dialplan() {
|
||||
|
||||
//normalize the fax forward number
|
||||
if (strlen($this->fax_forward_number) > 3) {
|
||||
//$fax_forward_number = preg_replace("~[^0-9]~", "",$fax_forward_number);
|
||||
$this->fax_forward_number = str_replace(" ", "", $this->fax_forward_number);
|
||||
$this->fax_forward_number = str_replace("-", "", $this->fax_forward_number);
|
||||
}
|
||||
|
||||
//set the forward prefix
|
||||
if (strripos($this->fax_forward_number, '$1') === false) {
|
||||
$this->forward_prefix = ''; //not found
|
||||
} else {
|
||||
$this->forward_prefix = $this->forward_prefix.$this->fax_forward_number.'#'; //found
|
||||
}
|
||||
|
||||
//delete previous dialplan
|
||||
if (strlen($this->dialplan_uuid) > 0) {
|
||||
//delete the previous dialplan
|
||||
$sql = "delete from v_dialplans ";
|
||||
$sql .= "where dialplan_uuid = '".$this->dialplan_uuid."' ";
|
||||
$sql .= "and domain_uuid = '".$this->domain_uuid."' ";
|
||||
$this->db->exec($sql);
|
||||
|
||||
$sql = "delete from v_dialplan_details ";
|
||||
$sql .= "where dialplan_uuid = '".$this->dialplan_uuid."' ";
|
||||
$sql .= "and domain_uuid = '".$this->domain_uuid."' ";
|
||||
$this->db->exec($sql);
|
||||
unset($sql);
|
||||
}
|
||||
unset($prep_statement);
|
||||
|
||||
//build the dialplan array
|
||||
$dialplan["app_uuid"] = "24108154-4ac3-1db6-1551-4731703a4440";
|
||||
$dialplan["domain_uuid"] = $this->domain_uuid;
|
||||
$dialplan["dialplan_name"] = ($this->fax_name != '') ? $this->fax_name : format_phone($this->destination_number);
|
||||
$dialplan["dialplan_number"] = $this->fax_extension;
|
||||
$dialplan["dialplan_context"] = $_SESSION['context'];
|
||||
$dialplan["dialplan_continue"] = "false";
|
||||
$dialplan["dialplan_order"] = "310";
|
||||
$dialplan["dialplan_enabled"] = "true";
|
||||
$dialplan["dialplan_description"] = $this->fax_description;
|
||||
$dialplan_detail_order = 10;
|
||||
|
||||
//add the public condition
|
||||
$y = 1;
|
||||
$dialplan["dialplan_details"][$y]["domain_uuid"] = $this->domain_uuid;
|
||||
$dialplan["dialplan_details"][$y]["dialplan_detail_tag"] = "condition";
|
||||
$dialplan["dialplan_details"][$y]["dialplan_detail_type"] = "destination_number";
|
||||
$dialplan["dialplan_details"][$y]["dialplan_detail_data"] = "^".$this->destination_number."\$";
|
||||
$dialplan["dialplan_details"][$y]["dialplan_detail_break"] = "";
|
||||
$dialplan["dialplan_details"][$y]["dialplan_detail_group"] = "1";
|
||||
$dialplan["dialplan_details"][$y]["dialplan_detail_order"] = $y * 10;
|
||||
$y++;
|
||||
$dialplan["dialplan_details"][$y]["domain_uuid"] = $this->domain_uuid;
|
||||
$dialplan["dialplan_details"][$y]["dialplan_detail_tag"] = "action";
|
||||
$dialplan["dialplan_details"][$y]["dialplan_detail_type"] = "answer";
|
||||
$dialplan["dialplan_details"][$y]["dialplan_detail_data"] = "";
|
||||
$dialplan["dialplan_details"][$y]["dialplan_detail_group"] = "1";
|
||||
$dialplan["dialplan_details"][$y]["dialplan_detail_order"] = $y * 10;
|
||||
$y++;
|
||||
$dialplan["dialplan_details"][$y]["domain_uuid"] = $this->domain_uuid;
|
||||
$dialplan["dialplan_details"][$y]["dialplan_detail_tag"] = "action";
|
||||
$dialplan["dialplan_details"][$y]["dialplan_detail_type"] = "set";
|
||||
$dialplan["dialplan_details"][$y]["dialplan_detail_data"] = "fax_uuid=".$this->fax_uuid;
|
||||
$dialplan["dialplan_details"][$y]["dialplan_detail_group"] = "1";
|
||||
$dialplan["dialplan_details"][$y]["dialplan_detail_order"] = $y * 10;
|
||||
$y++;
|
||||
$dialplan["dialplan_details"][$y]["domain_uuid"] = $this->domain_uuid;
|
||||
$dialplan["dialplan_details"][$y]["dialplan_detail_tag"] = "action";
|
||||
$dialplan["dialplan_details"][$y]["dialplan_detail_type"] = "set";
|
||||
$dialplan["dialplan_details"][$y]["dialplan_detail_data"] = "api_hangup_hook=lua app/fax/resources/scripts/hangup_rx.lua";
|
||||
$dialplan["dialplan_details"][$y]["dialplan_detail_group"] = "1";
|
||||
$dialplan["dialplan_details"][$y]["dialplan_detail_order"] = $y * 10;
|
||||
$y++;
|
||||
foreach($_SESSION['fax']['variable'] as $data) {
|
||||
$dialplan["dialplan_details"][$y]["domain_uuid"] = $this->domain_uuid;
|
||||
$dialplan["dialplan_details"][$y]["dialplan_detail_tag"] = "action";
|
||||
$dialplan["dialplan_details"][$y]["dialplan_detail_type"] = "set";
|
||||
if (substr($data,0,8) == "inbound:") {
|
||||
$dialplan["dialplan_details"][$y]["dialplan_detail_data"] = substr($data,8,strlen($data));
|
||||
}
|
||||
elseif (substr($data,0,9) == "outbound:") {}
|
||||
else {
|
||||
$dialplan["dialplan_details"][$y]["dialplan_detail_data"] = $data;
|
||||
}
|
||||
$dialplan["dialplan_details"][$y]["dialplan_detail_group"] = "1";
|
||||
$dialplan["dialplan_details"][$y]["dialplan_detail_order"] = $y * 10;
|
||||
$y++;
|
||||
}
|
||||
$dialplan["dialplan_details"][$y]["domain_uuid"] = $this->domain_uuid;
|
||||
$dialplan["dialplan_details"][$y]["dialplan_detail_tag"] = "action";
|
||||
$dialplan["dialplan_details"][$y]["dialplan_detail_type"] = "set";
|
||||
if (strlen($_SESSION['fax']['last_fax']['text']) > 0) {
|
||||
$dialplan["dialplan_details"][$y]["dialplan_detail_data"] = "last_fax=".$_SESSION['fax']['last_fax']['text'];
|
||||
}
|
||||
else {
|
||||
$dialplan["dialplan_details"][$y]["dialplan_detail_data"] = "last_fax=\${caller_id_number}-\${strftime(%Y-%m-%d-%H-%M-%S)}";
|
||||
}
|
||||
$dialplan["dialplan_details"][$y]["dialplan_detail_group"] = "1";
|
||||
$dialplan["dialplan_details"][$y]["dialplan_detail_order"] = $y * 10;
|
||||
$y++;
|
||||
$dialplan["dialplan_details"][$y]["domain_uuid"] = $this->domain_uuid;
|
||||
$dialplan["dialplan_details"][$y]["dialplan_detail_tag"] = "action";
|
||||
$dialplan["dialplan_details"][$y]["dialplan_detail_type"] = "playback";
|
||||
$dialplan["dialplan_details"][$y]["dialplan_detail_data"] = "silence_stream://2000";
|
||||
$dialplan["dialplan_details"][$y]["dialplan_detail_group"] = "1";
|
||||
$dialplan["dialplan_details"][$y]["dialplan_detail_order"] = $y * 10;
|
||||
$y++;
|
||||
$dialplan["dialplan_details"][$y]["domain_uuid"] = $this->domain_uuid;
|
||||
$dialplan["dialplan_details"][$y]["dialplan_detail_tag"] = "action";
|
||||
$dialplan["dialplan_details"][$y]["dialplan_detail_type"] = "rxfax";
|
||||
$dialplan["dialplan_details"][$y]["dialplan_detail_data"] = $_SESSION['switch']['storage']['dir'].'/fax/'.$_SESSION['domain_name'].'/'.$this->fax_extension.'/inbox/'.$this->forward_prefix.'${last_fax}.tif';
|
||||
$dialplan["dialplan_details"][$y]["dialplan_detail_group"] = "1";
|
||||
$dialplan["dialplan_details"][$y]["dialplan_detail_order"] = $y * 10;
|
||||
$y++;
|
||||
$dialplan["dialplan_details"][$y]["domain_uuid"] = $this->domain_uuid;
|
||||
$dialplan["dialplan_details"][$y]["dialplan_detail_tag"] = "action";
|
||||
$dialplan["dialplan_details"][$y]["dialplan_detail_type"] = "hangup";
|
||||
$dialplan["dialplan_details"][$y]["dialplan_detail_data"] = "";
|
||||
$dialplan["dialplan_details"][$y]["dialplan_detail_group"] = "1";
|
||||
$dialplan["dialplan_details"][$y]["dialplan_detail_order"] = $y * 10;
|
||||
$y++;
|
||||
|
||||
//add the dialplan permission
|
||||
$p = new permissions;
|
||||
$p->add("dialplan_add", 'temp');
|
||||
$p->add("dialplan_detail_add", 'temp');
|
||||
$p->add("dialplan_edit", 'temp');
|
||||
$p->add("dialplan_detail_edit", 'temp');
|
||||
|
||||
//save the dialplan
|
||||
$orm = new orm;
|
||||
$orm->name('dialplans');
|
||||
$orm->save($dialplan);
|
||||
$dialplan_response = $orm->message;
|
||||
$this->dialplan_uuid = $dialplan_response['uuid'];
|
||||
|
||||
//if new dialplan uuid then update the call center queue
|
||||
$sql = "update v_fax ";
|
||||
$sql .= "set dialplan_uuid = '".$this->dialplan_uuid."' ";
|
||||
$sql .= "where fax_uuid = '".$this->fax_uuid."' ";
|
||||
$sql .= "and domain_uuid = '".$this->domain_uuid."' ";
|
||||
$this->db->exec($sql);
|
||||
unset($sql);
|
||||
|
||||
//remove the temporary permission
|
||||
$p->delete("dialplan_add", 'temp');
|
||||
$p->delete("dialplan_detail_add", 'temp');
|
||||
$p->delete("dialplan_edit", 'temp');
|
||||
$p->delete("dialplan_detail_edit", 'temp');
|
||||
|
||||
//synchronize the xml config
|
||||
save_dialplan_xml();
|
||||
|
||||
//clear the cache
|
||||
$cache = new cache;
|
||||
$cache->delete("dialplan:".$_SESSION['context']);
|
||||
|
||||
//return the dialplan_uuid
|
||||
return $dialplan_response;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
$o = new fax;
|
||||
$c->domain_uuid = "";
|
||||
$c->dialplan_uuid = "";
|
||||
$c->fax_name = "";
|
||||
$c->fax_extension = $fax_extension;
|
||||
$c->fax_forward_number = $fax_forward_number;
|
||||
$c->destination_number = $fax_destination_number;
|
||||
$c->fax_description = $fax_description;
|
||||
$c->dialplan();
|
||||
*/
|
||||
|
||||
?>
|
||||
@@ -1,9 +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);
|
||||
}
|
||||
|
||||
<?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);
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -1,145 +1,145 @@
|
||||
<?php
|
||||
|
||||
function parse_message($connection, $message_number, $option = null, $to_charset = 'UTF-8') {
|
||||
$result = Array('messages'=>Array(),'attachments'=>Array());
|
||||
$structure = imap_fetchstructure($connection, $message_number, $option);
|
||||
|
||||
if (isset($structure->parts)) {
|
||||
$flatten = parse_message_flatten($structure->parts);
|
||||
}
|
||||
else {
|
||||
$flatten = Array(1 => $structure);
|
||||
}
|
||||
|
||||
foreach($flatten as $id => &$part){
|
||||
switch($part->type) {
|
||||
case TYPETEXT:
|
||||
$message = parse_message_decode_text($connection, $part, $message_number, $id, $option, $to_charset);
|
||||
$result['messages'][] = $message;
|
||||
break;
|
||||
|
||||
case TYPEAPPLICATION: case TYPEAUDIO: case TYPEIMAGE: case TYPEVIDEO: case TYPEOTHER:
|
||||
$attachment = parse_message_decode_attach($connection, $part, $message_number, $id, $option);
|
||||
if($attachment){
|
||||
$result['attachments'][] = $attachment;
|
||||
}
|
||||
break;
|
||||
|
||||
case TYPEMULTIPART: case TYPEMESSAGE:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
function parse_message_decode_text($connection, &$part, $message_number, $id, $option, $to_charset){
|
||||
$msg = parse_message_fetch_body($connection, $part, $message_number, $id, $option);
|
||||
|
||||
if($msg && $to_charset){
|
||||
$charset = '';
|
||||
if(isset($part->parameters) && count($part->parameters)) {
|
||||
foreach($part->parameters as &$parameter){
|
||||
if($parameter->attribute == 'CHARSET') {
|
||||
$charset = $parameter->value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if($charset){
|
||||
$msg = mb_convert_encoding($msg, $to_charset, $charset);
|
||||
}
|
||||
$msg = trim($msg);
|
||||
}
|
||||
|
||||
return Array(
|
||||
'data' => $msg,
|
||||
'type' => parse_message_get_type($part),
|
||||
'size' => strlen($msg),
|
||||
);
|
||||
}
|
||||
|
||||
function parse_message_decode_attach($connection, &$part, $message_number, $id, $option){
|
||||
$filename = false;
|
||||
|
||||
if($part->ifdparameters) {
|
||||
foreach($part->dparameters as $object) {
|
||||
if(strtolower($object->attribute) == 'filename') {
|
||||
$filename = $object->value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($part->ifparameters) {
|
||||
foreach($part->parameters as $object) {
|
||||
if(strtolower($object->attribute) == 'name') {
|
||||
$filename = $object->value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!$filename) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$body = parse_message_fetch_body($connection, $part, $message_number, $id, $option);
|
||||
|
||||
return Array(
|
||||
'data' => $body,
|
||||
'type' => parse_message_get_type($part),
|
||||
'name' => $filename,
|
||||
'size' => strlen($body),
|
||||
'disposition' => $part->disposition,
|
||||
);
|
||||
}
|
||||
|
||||
function parse_message_fetch_body($connection, &$part, $message_number, $id, $option){
|
||||
$body = imap_fetchbody($connection, $message_number, $id, $option);
|
||||
if($part->encoding == ENCBASE64){
|
||||
$body = base64_decode($body);
|
||||
}
|
||||
else if($part->encoding == ENCQUOTEDPRINTABLE){
|
||||
$body = quoted_printable_decode($body);
|
||||
}
|
||||
return $body;
|
||||
}
|
||||
|
||||
function parse_message_get_type(&$part){
|
||||
$types = Array(
|
||||
TYPEMESSAGE => 'message',
|
||||
TYPEMULTIPART => 'multipart',
|
||||
TYPEAPPLICATION => 'application',
|
||||
TYPEAUDIO => 'audio',
|
||||
TYPEIMAGE => 'image',
|
||||
TYPETEXT => 'text',
|
||||
TYPEVIDEO => 'video',
|
||||
TYPEMODEL => 'model',
|
||||
TYPEOTHER => 'other',
|
||||
);
|
||||
|
||||
return $types[$part->type] . '/' . strtolower($part->subtype);
|
||||
}
|
||||
|
||||
function parse_message_flatten(&$structure, &$result = array(), $prefix = '', $index = 1, $fullPrefix = true) {
|
||||
foreach($structure as &$part) {
|
||||
if(isset($part->parts)) {
|
||||
if($part->type == TYPEMESSAGE) {
|
||||
parse_message_flatten($part->parts, $result, $prefix.$index.'.', 0, false);
|
||||
}
|
||||
elseif($fullPrefix) {
|
||||
parse_message_flatten($part->parts, $result, $prefix.$index.'.');
|
||||
}
|
||||
else {
|
||||
parse_message_flatten($part->parts, $result, $prefix);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$result[$prefix.$index] = $part;
|
||||
}
|
||||
$index++;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
<?php
|
||||
|
||||
function parse_message($connection, $message_number, $option = null, $to_charset = 'UTF-8') {
|
||||
$result = Array('messages'=>Array(),'attachments'=>Array());
|
||||
$structure = imap_fetchstructure($connection, $message_number, $option);
|
||||
|
||||
if (isset($structure->parts)) {
|
||||
$flatten = parse_message_flatten($structure->parts);
|
||||
}
|
||||
else {
|
||||
$flatten = Array(1 => $structure);
|
||||
}
|
||||
|
||||
foreach($flatten as $id => &$part){
|
||||
switch($part->type) {
|
||||
case TYPETEXT:
|
||||
$message = parse_message_decode_text($connection, $part, $message_number, $id, $option, $to_charset);
|
||||
$result['messages'][] = $message;
|
||||
break;
|
||||
|
||||
case TYPEAPPLICATION: case TYPEAUDIO: case TYPEIMAGE: case TYPEVIDEO: case TYPEOTHER:
|
||||
$attachment = parse_message_decode_attach($connection, $part, $message_number, $id, $option);
|
||||
if($attachment){
|
||||
$result['attachments'][] = $attachment;
|
||||
}
|
||||
break;
|
||||
|
||||
case TYPEMULTIPART: case TYPEMESSAGE:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
function parse_message_decode_text($connection, &$part, $message_number, $id, $option, $to_charset){
|
||||
$msg = parse_message_fetch_body($connection, $part, $message_number, $id, $option);
|
||||
|
||||
if($msg && $to_charset){
|
||||
$charset = '';
|
||||
if(isset($part->parameters) && count($part->parameters)) {
|
||||
foreach($part->parameters as &$parameter){
|
||||
if($parameter->attribute == 'CHARSET') {
|
||||
$charset = $parameter->value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if($charset){
|
||||
$msg = mb_convert_encoding($msg, $to_charset, $charset);
|
||||
}
|
||||
$msg = trim($msg);
|
||||
}
|
||||
|
||||
return Array(
|
||||
'data' => $msg,
|
||||
'type' => parse_message_get_type($part),
|
||||
'size' => strlen($msg),
|
||||
);
|
||||
}
|
||||
|
||||
function parse_message_decode_attach($connection, &$part, $message_number, $id, $option){
|
||||
$filename = false;
|
||||
|
||||
if($part->ifdparameters) {
|
||||
foreach($part->dparameters as $object) {
|
||||
if(strtolower($object->attribute) == 'filename') {
|
||||
$filename = $object->value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($part->ifparameters) {
|
||||
foreach($part->parameters as $object) {
|
||||
if(strtolower($object->attribute) == 'name') {
|
||||
$filename = $object->value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!$filename) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$body = parse_message_fetch_body($connection, $part, $message_number, $id, $option);
|
||||
|
||||
return Array(
|
||||
'data' => $body,
|
||||
'type' => parse_message_get_type($part),
|
||||
'name' => $filename,
|
||||
'size' => strlen($body),
|
||||
'disposition' => $part->disposition,
|
||||
);
|
||||
}
|
||||
|
||||
function parse_message_fetch_body($connection, &$part, $message_number, $id, $option){
|
||||
$body = imap_fetchbody($connection, $message_number, $id, $option);
|
||||
if($part->encoding == ENCBASE64){
|
||||
$body = base64_decode($body);
|
||||
}
|
||||
else if($part->encoding == ENCQUOTEDPRINTABLE){
|
||||
$body = quoted_printable_decode($body);
|
||||
}
|
||||
return $body;
|
||||
}
|
||||
|
||||
function parse_message_get_type(&$part){
|
||||
$types = Array(
|
||||
TYPEMESSAGE => 'message',
|
||||
TYPEMULTIPART => 'multipart',
|
||||
TYPEAPPLICATION => 'application',
|
||||
TYPEAUDIO => 'audio',
|
||||
TYPEIMAGE => 'image',
|
||||
TYPETEXT => 'text',
|
||||
TYPEVIDEO => 'video',
|
||||
TYPEMODEL => 'model',
|
||||
TYPEOTHER => 'other',
|
||||
);
|
||||
|
||||
return $types[$part->type] . '/' . strtolower($part->subtype);
|
||||
}
|
||||
|
||||
function parse_message_flatten(&$structure, &$result = array(), $prefix = '', $index = 1, $fullPrefix = true) {
|
||||
foreach($structure as &$part) {
|
||||
if(isset($part->parts)) {
|
||||
if($part->type == TYPEMESSAGE) {
|
||||
parse_message_flatten($part->parts, $result, $prefix.$index.'.', 0, false);
|
||||
}
|
||||
elseif($fullPrefix) {
|
||||
parse_message_flatten($part->parts, $result, $prefix.$index.'.');
|
||||
}
|
||||
else {
|
||||
parse_message_flatten($part->parts, $result, $prefix);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$result[$prefix.$index] = $part;
|
||||
}
|
||||
$index++;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user