Fork of FusionPBX but with LDAP kinda working
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1142 lines
42 KiB

2 years ago
  1. <?php
  2. /*
  3. FusionPBX
  4. Version: MPL 1.1
  5. The contents of this file are subject to the Mozilla Public License Version
  6. 1.1 (the "License"); you may not use this file except in compliance with
  7. the License. You may obtain a copy of the License at
  8. http://www.mozilla.org/MPL/
  9. Software distributed under the License is distributed on an "AS IS" basis,
  10. WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  11. for the specific language governing rights and limitations under the
  12. License.
  13. The Original Code is FusionPBX
  14. The Initial Developer of the Original Code is
  15. Mark J Crane <markjcrane@fusionpbx.com>
  16. Portions created by the Initial Developer are Copyright (C) 2008-2022
  17. the Initial Developer. All Rights Reserved.
  18. Contributor(s):
  19. Mark J Crane <markjcrane@fusionpbx.com>
  20. James Rose <james.o.rose@gmail.com>
  21. Luis Daniel Lucio Quiroz <dlucio@okay.com.mx>
  22. Errol Samuels <voiptology@gmail.com>
  23. Corey Moullas <cmoullas@emak.tech>
  24. */
  25. //set included to boolean
  26. if (!isset($included)) { $included = false; }
  27. //check if windows
  28. if (stristr(PHP_OS, 'WIN')) { $IS_WINDOWS = true; } else { $IS_WINDOWS = false; }
  29. //send email through browser
  30. if (!$included) {
  31. //includes
  32. include "root.php";
  33. require_once "resources/require.php";
  34. require_once "resources/check_auth.php";
  35. //check permissions
  36. if (permission_exists('fax_send')) {
  37. //access granted
  38. }
  39. else {
  40. echo "access denied";
  41. exit;
  42. }
  43. //add multi-lingual support
  44. $language = new text;
  45. $text = $language->get();
  46. //get the fax_extension and save it as a variable
  47. if (isset($_REQUEST["fax_extension"]) && is_numeric($_REQUEST["fax_extension"])) {
  48. $fax_extension = $_REQUEST["fax_extension"];
  49. }
  50. //pre-populate the form
  51. if (is_uuid($_REQUEST['id']) && $_POST["persistformvar"] != "true") {
  52. $fax_uuid = $_REQUEST["id"];
  53. if (permission_exists('fax_extension_view_domain')) {
  54. //show all fax extensions
  55. $sql = "select fax_uuid, fax_extension, fax_caller_id_name, fax_caller_id_number, ";
  56. $sql .= "fax_toll_allow, accountcode, fax_send_greeting ";
  57. $sql .= "from v_fax ";
  58. $sql .= "where domain_uuid = :domain_uuid ";
  59. $sql .= "and fax_uuid = :fax_uuid ";
  60. $parameters['domain_uuid'] = $_SESSION['domain_uuid'];
  61. $parameters['fax_uuid'] = $fax_uuid;
  62. }
  63. else {
  64. //show only assigned fax extensions
  65. $sql = "select f.fax_uuid, f.fax_extension, f.fax_caller_id_name, f.fax_caller_id_number, ";
  66. $sql .= "f.fax_toll_allow, f.accountcode, f.fax_send_greeting ";
  67. $sql .= "from v_fax as f, v_fax_users as u ";
  68. $sql .= "where f.fax_uuid = u.fax_uuid ";
  69. $sql .= "and f.domain_uuid = :domain_uuid ";
  70. $sql .= "and f.fax_uuid = :fax_uuid ";
  71. $sql .= "and u.user_uuid = :user_uuid ";
  72. $parameters['domain_uuid'] = $_SESSION['domain_uuid'];
  73. $parameters['fax_uuid'] = $fax_uuid;
  74. $parameters['user_uuid'] = $_SESSION['user_uuid'];
  75. }
  76. $database = new database;
  77. $row = $database->select($sql, $parameters, 'row');
  78. if (is_array($row) && @sizeof($row) != 0) {
  79. //set database fields as variables
  80. $fax_uuid = $row["fax_uuid"];
  81. $fax_extension = $row["fax_extension"];
  82. $fax_caller_id_name = $row["fax_caller_id_name"];
  83. $fax_caller_id_number = $row["fax_caller_id_number"];
  84. $fax_toll_allow = $row["fax_toll_allow"];
  85. $fax_accountcode = $row["accountcode"];
  86. $fax_send_greeting = $row["fax_send_greeting"];
  87. }
  88. else {
  89. if (!permission_exists('fax_extension_view_domain')) {
  90. echo "access denied";
  91. exit;
  92. }
  93. }
  94. unset($sql, $parameters, $row);
  95. }
  96. //set the fax directory
  97. $fax_dir = $_SESSION['switch']['storage']['dir'].'/fax/'.$_SESSION['domain_name'];
  98. //set fax cover font to generate pdf
  99. $fax_cover_font = $_SESSION['fax']['cover_font']['text'];
  100. }
  101. else {
  102. require_once "resources/classes/event_socket.php";
  103. }
  104. if (!function_exists('correct_path')) {
  105. function correct_path($p) {
  106. global $IS_WINDOWS;
  107. if ($IS_WINDOWS) {
  108. return str_replace('/', '\\', $p);
  109. }
  110. return $p;
  111. }
  112. }
  113. //define function gs_cmd
  114. if (!function_exists('gs_cmd')) {
  115. function gs_cmd($args) {
  116. global $IS_WINDOWS;
  117. if ($IS_WINDOWS) {
  118. return 'gswin32c '.$args;
  119. }
  120. return 'gs '.$args;
  121. }
  122. }
  123. //define function fax_split dtmf
  124. if (!function_exists('fax_split_dtmf')) {
  125. function fax_split_dtmf(&$fax_number, &$fax_dtmf){
  126. $tmp = array();
  127. $fax_dtmf = '';
  128. if (preg_match('/^\s*(.*?)\s*\((.*)\)\s*$/', $fax_number, $tmp)){
  129. $fax_number = $tmp[1];
  130. $fax_dtmf = $tmp[2];
  131. }
  132. }
  133. }
  134. //get the fax extension
  135. if (isset($fax_extension) && is_numeric($fax_extension)) {
  136. //set the fax directories. example /usr/local/freeswitch/storage/fax/329/inbox
  137. $dir_fax_inbox = $fax_dir.'/'.$fax_extension.'/inbox';
  138. $dir_fax_sent = $fax_dir.'/'.$fax_extension.'/sent';
  139. $dir_fax_temp = $fax_dir.'/'.$fax_extension.'/temp';
  140. //make sure the directories exist
  141. if (!is_dir($_SESSION['switch']['storage']['dir'])) {
  142. mkdir($_SESSION['switch']['storage']['dir'], 0770);
  143. }
  144. if (!is_dir($_SESSION['switch']['storage']['dir'].'/fax')) {
  145. mkdir($_SESSION['switch']['storage']['dir'].'/fax', 0770);
  146. }
  147. if (!is_dir($_SESSION['switch']['storage']['dir'].'/fax/'.$_SESSION['domain_name'])) {
  148. mkdir($_SESSION['switch']['storage']['dir'].'/fax/'.$_SESSION['domain_name'], 0770);
  149. }
  150. if (!is_dir($fax_dir.'/'.$fax_extension)) {
  151. mkdir($fax_dir.'/'.$fax_extension, 0770);
  152. }
  153. if (!is_dir($dir_fax_inbox)) {
  154. mkdir($dir_fax_inbox, 0770);
  155. }
  156. if (!is_dir($dir_fax_sent)) {
  157. mkdir($dir_fax_sent, 0770);
  158. }
  159. if (!is_dir($dir_fax_temp)) {
  160. mkdir($dir_fax_temp, 0770);
  161. }
  162. }
  163. //clear file status cache
  164. clearstatcache();
  165. //send the fax
  166. $continue = false;
  167. if (!$included) {
  168. if (($_POST['action'] == "send")) {
  169. //get the values from the HTTP POST
  170. $fax_numbers = $_POST['fax_numbers'];
  171. $fax_uuid = $_POST["id"];
  172. $fax_caller_id_name = $_POST['fax_caller_id_name'];
  173. $fax_caller_id_number = $_POST['fax_caller_id_number'];
  174. $fax_header = $_POST['fax_header'];
  175. $fax_sender = $_POST['fax_sender'];
  176. $fax_recipient = $_POST['fax_recipient'];
  177. $fax_subject = $_POST['fax_subject'];
  178. $fax_message = $_POST['fax_message'];
  179. $fax_resolution = $_POST['fax_resolution'];
  180. $fax_page_size = $_POST['fax_page_size'];
  181. $fax_footer = $_POST['fax_footer'];
  182. //validate the token
  183. $token = new token;
  184. if (!$token->validate($_SERVER['PHP_SELF'])) {
  185. message::add($text['message-invalid_token'],'negative');
  186. header('Location: fax_send.php'.(is_uuid($fax_uuid) ? '?id='.$fax_uuid : null));
  187. exit;
  188. }
  189. $continue = true;
  190. }
  191. }
  192. else {
  193. //all necessary local and session variables should
  194. //be already set by now by file including this one
  195. $continue = true;
  196. }
  197. //cleanup numbers
  198. if (isset($fax_numbers)) {
  199. foreach ($fax_numbers as $index => $fax_number) {
  200. fax_split_dtmf($fax_number, $fax_dtmf);
  201. $fax_number = preg_replace("~[^0-9]~", "", $fax_number);
  202. $fax_dtmf = preg_replace("~[^0-9Pp*#]~", "", $fax_dtmf);
  203. if ($fax_number != ''){
  204. if ($fax_dtmf != '') {$fax_number .= " (" . $fax_dtmf . ")";}
  205. $fax_numbers[$index] = $fax_number;
  206. }
  207. else{
  208. unset($fax_numbers[$index]);
  209. }
  210. }
  211. sort($fax_numbers);
  212. }
  213. if ($continue) {
  214. //determine page size
  215. switch ($fax_page_size) {
  216. case 'a4' :
  217. $page_width = 8.3; //in
  218. $page_height = 11.7; //in
  219. break;
  220. case 'legal' :
  221. $page_width = 8.5; //in
  222. $page_height = 14; //in
  223. break;
  224. case 'letter' :
  225. $page_width = 8.5; //in
  226. $page_height = 11; //in
  227. break;
  228. default :
  229. $page_width = 8.5; //in
  230. $page_height = 11; //in
  231. $fax_page_size = 'letter';
  232. }
  233. //set resolution
  234. switch ($fax_resolution) {
  235. case 'fine':
  236. $gs_r = '204x196';
  237. $gs_g = ((int) ($page_width * 204)).'x'.((int) ($page_height * 196));
  238. break;
  239. case 'superfine':
  240. $gs_r = '204x392';
  241. $gs_g = ((int) ($page_width * 204)).'x'.((int) ($page_height * 392));
  242. break;
  243. case 'normal':
  244. default:
  245. $gs_r = '204x98';
  246. $gs_g = ((int) ($page_width * 204)).'x'.((int) ($page_height * 98));
  247. break;
  248. }
  249. //process uploaded or emailed files (if any)
  250. $fax_page_count = 0;
  251. $_files = (!$included) ? $_FILES['fax_files'] : $emailed_files;
  252. unset($tif_files);
  253. foreach ($_files['tmp_name'] as $index => $fax_tmp_name) {
  254. $uploaded_file = (!$included) ? is_uploaded_file($fax_tmp_name) : true;
  255. if ( $uploaded_file && $_files['error'][$index] == 0 && $_files['size'][$index] > 0 ) {
  256. //get the file extension
  257. $fax_file_extension = strtolower(pathinfo($_files['name'][$index], PATHINFO_EXTENSION));
  258. if ($fax_file_extension == "tiff") { $fax_file_extension = "tif"; }
  259. //block unauthorized files
  260. $disallowed_file_extensions = explode(',','sh,ssh,so,dll,exe,bat,vbs,zip,rar,z,tar,tbz,tgz,gz');
  261. if (in_array($fax_file_extension, $disallowed_file_extensions) || $fax_file_extension == '') { continue; }
  262. //use a safe file name
  263. $fax_name = md5($_files['name'][$index]);
  264. //rename the file
  265. $attachment_file_name = $_files['name'][$index];
  266. if ($attachment_file_name != $fax_name.'.'.$fax_file_extension) {
  267. rename($dir_fax_temp.'/'.$attachment_file_name, $dir_fax_temp.'/'.$fax_name.'.'.$fax_file_extension);
  268. }
  269. unset($attachment_file_name);
  270. if (!$included) {
  271. //check if directory exists
  272. if (!is_dir($dir_fax_temp)) {
  273. mkdir($dir_fax_temp, 0770);
  274. }
  275. //move uploaded file
  276. move_uploaded_file($_files['tmp_name'][$index], $dir_fax_temp.'/'.$fax_name.'.'.$fax_file_extension);
  277. }
  278. //convert uploaded file to pdf, if necessary
  279. if ($fax_file_extension != "pdf" && $fax_file_extension != "tif") {
  280. chdir($dir_fax_temp);
  281. $command = $IS_WINDOWS ? '' : 'export HOME=/tmp && ';
  282. $command .= 'libreoffice --headless --convert-to pdf --outdir '.$dir_fax_temp.' '.$dir_fax_temp.'/'.escapeshellarg($fax_name).'.'.escapeshellarg($fax_file_extension);
  283. exec($command);
  284. @unlink($dir_fax_temp.'/'.$fax_name.'.'.$fax_file_extension);
  285. }
  286. //convert uploaded pdf to tif
  287. if (file_exists($dir_fax_temp.'/'.$fax_name.'.pdf')) {
  288. chdir($dir_fax_temp);
  289. //convert pdf to tif
  290. $cmd = exec('which gs')." -q -r".$gs_r." -g".$gs_g." -dBATCH -dPDFFitPage -dNOSAFER -dNOPAUSE -dBATCH -sOutputFile=".escapeshellarg($fax_name).".tif -sDEVICE=tiffg4 -Ilib stocht.ps -c \"{ .75 gt { 1 } { 0 } ifelse} settransfer\" -- ".escapeshellarg($fax_name).".pdf -c quit";
  291. // echo($cmd . "<br/>\n");
  292. exec($cmd);
  293. @unlink($dir_fax_temp.'/'.$fax_name.'.pdf');
  294. }
  295. //get the page count
  296. $cmd = exec('which tiffinfo')." ".correct_path($dir_fax_temp.'/'.$fax_name).".tif | grep \"Page Number\" | grep -c \"P\"";
  297. // echo($cmd . "<br/>\n");
  298. $tif_page_count = exec($cmd);
  299. if ($tif_page_count != '') {
  300. $fax_page_count += $tif_page_count;
  301. }
  302. //add file to array
  303. $tif_files[] = $dir_fax_temp.'/'.$fax_name.'.tif';
  304. } //if
  305. } //foreach
  306. // unique id for this fax
  307. $fax_instance_uuid = uuid();
  308. //generate cover page, merge with pdf
  309. if ($fax_subject != '' || $fax_message != '') {
  310. //load pdf libraries
  311. require_once("resources/tcpdf/tcpdf.php");
  312. require_once("resources/fpdi/fpdi.php");
  313. // initialize pdf
  314. $pdf = new FPDI('P', 'in');
  315. $pdf->SetAutoPageBreak(false);
  316. $pdf->setPrintHeader(false);
  317. $pdf->setPrintFooter(false);
  318. $pdf->SetMargins(0, 0, 0, true);
  319. if (strlen($fax_cover_font) > 0) {
  320. if (substr($fax_cover_font, -4) == '.ttf') {
  321. $pdf_font = TCPDF_FONTS::addTTFfont($fax_cover_font);
  322. }
  323. else {
  324. $pdf_font = $fax_cover_font;
  325. }
  326. }
  327. if (!$pdf_font) {
  328. $pdf_font = 'times';
  329. }
  330. //add blank page
  331. $pdf->AddPage('P', array($page_width, $page_height));
  332. // content offset, if necessary
  333. $x = 0;
  334. $y = 0;
  335. //logo
  336. $display_logo = false;
  337. if (!is_array($_SESSION['fax']['cover_logo'])) {
  338. $logo = $_SERVER['DOCUMENT_ROOT'].PROJECT_PATH."/app/fax/resources/images/logo.jpg";
  339. $display_logo = true;
  340. }
  341. else if (is_null($_SESSION['fax']['cover_logo']['text'])) {
  342. $logo = ''; //explicitly empty
  343. }
  344. else if ($_SESSION['fax']['cover_logo']['text'] != '') {
  345. if (substr($_SESSION['fax']['cover_logo']['text'], 0, 4) == 'http') {
  346. $logo = $_SESSION['fax']['cover_logo']['text'];
  347. }
  348. else if (substr($_SESSION['fax']['cover_logo']['text'], 0, 1) == '/') {
  349. if (substr($_SESSION['fax']['cover_logo']['text'], 0, strlen($_SERVER['DOCUMENT_ROOT'])) != $_SERVER['DOCUMENT_ROOT']) {
  350. $logo = $_SERVER['DOCUMENT_ROOT'].$_SESSION['fax']['cover_logo']['text'];
  351. }
  352. else {
  353. $logo = $_SESSION['fax']['cover_logo']['text'];
  354. }
  355. }
  356. }
  357. if (isset($logo) && $logo) {
  358. $logo_dirname = strtolower(pathinfo($logo, PATHINFO_DIRNAME));
  359. $logo_filename = strtolower(pathinfo($logo, PATHINFO_BASENAME));
  360. $logo_fileext = pathinfo($logo_filename, PATHINFO_EXTENSION);
  361. if (in_array($logo_fileext, ['gif','jpg','jpeg','png','bmp'])) {
  362. if (file_exists($logo_dirname.'/'.$logo_filename)) {
  363. $logo = $logo_dirname.'/'.$logo_filename;
  364. $display_logo = true;
  365. }
  366. else {
  367. $raw = file_get_contents($logo);
  368. if (file_put_contents($dir_fax_temp.'/'.$logo_filename, $raw)) {
  369. $logo = $dir_fax_temp.'/'.$logo_filename;
  370. $display_logo = true;
  371. }
  372. else {
  373. unset($logo);
  374. }
  375. }
  376. }
  377. else {
  378. unset($logo);
  379. }
  380. }
  381. if ($display_logo) {
  382. $pdf->Image($logo, 0.5, 0.4, 2.5, 0.9, null, null, 'N', true, 300, null, false, false, 0, true);
  383. }
  384. else {
  385. //set position for header text, if enabled
  386. $pdf->SetXY($x + 0.5, $y + 0.4);
  387. }
  388. //header
  389. if ($fax_header != '') {
  390. $pdf->SetLeftMargin(0.5);
  391. $pdf->SetFont($pdf_font, "", 10);
  392. $pdf->Write(0.3, $fax_header);
  393. }
  394. //fax, cover sheet
  395. $pdf->SetTextColor(0,0,0);
  396. $pdf->SetFont($pdf_font, "B", 55);
  397. $pdf->SetXY($x + 4.55, $y + 0.25);
  398. $pdf->Cell($x + 3.50, $y + 0.4, $text['label-fax-fax'], 0, 0, 'R', false, null, 0, false, 'T', 'T');
  399. $pdf->SetFont($pdf_font, "", 12);
  400. $pdf->SetFontSpacing(0.0425);
  401. $pdf->SetXY($x + 4.55, $y + 1.0);
  402. $pdf->Cell($x + 3.50, $y + 0.4, $text['label-fax-cover-sheet'], 0, 0, 'R', false, null, 0, false, 'T', 'T');
  403. $pdf->SetFontSpacing(0);
  404. //field labels
  405. $pdf->SetFont($pdf_font, "B", 12);
  406. if ($fax_recipient != '' || sizeof($fax_numbers) > 0) {
  407. $pdf->Text($x + 0.5, $y + 2.0, strtoupper($text['label-fax-recipient']).":");
  408. }
  409. if ($fax_sender != '' || $fax_caller_id_number != '') {
  410. $pdf->Text($x + 0.5, $y + 2.3, strtoupper($text['label-fax-sender']).":");
  411. }
  412. if ($fax_page_count > 0) {
  413. $pdf->Text($x + 0.5, $y + 2.6, strtoupper($text['label-fax-attached']).":");
  414. }
  415. if ($fax_subject != '') {
  416. $pdf->Text($x + 0.5, $y + 2.9, strtoupper($text['label-fax-subject']).":");
  417. }
  418. //field values
  419. $pdf->SetFont($pdf_font, "", 12);
  420. $pdf->SetXY($x + 2.0, $y + 1.95);
  421. if ($fax_recipient != '') {
  422. $pdf->Write(0.3, $fax_recipient);
  423. }
  424. if (sizeof($fax_numbers) > 0) {
  425. $fax_number_string = ($fax_recipient != '') ? ' (' : null;
  426. $fax_number_string .= format_phone($fax_numbers[0]);
  427. if (sizeof($fax_numbers) > 1) {
  428. for ($n = 1; $n <= sizeof($fax_numbers); $n++) {
  429. if ($n == 4) { break; }
  430. $fax_number_string .= ', '.format_phone($fax_numbers[$n]);
  431. }
  432. }
  433. $fax_number_string .= (sizeof($fax_numbers) > 4) ? ', +'.(sizeof($fax_numbers) - 4) : null;
  434. $fax_number_string .= ($fax_recipient != '') ? ')' : null;
  435. $pdf->Write(0.3, $fax_number_string);
  436. }
  437. $pdf->SetXY($x + 2.0, $y + 2.25);
  438. if ($fax_sender != '') {
  439. $pdf->Write(0.3, $fax_sender);
  440. if ($fax_caller_id_number != '') {
  441. $pdf->Write(0.3, ' ('.format_phone($fax_caller_id_number).')');
  442. }
  443. }
  444. else {
  445. if ($fax_caller_id_number != '') {
  446. $pdf->Write(0.3, format_phone($fax_caller_id_number));
  447. }
  448. }
  449. if ($fax_page_count > 0) {
  450. $pdf->Text($x + 2.0, $y + 2.6, $fax_page_count.' '.$text['label-fax-page'.(($fax_page_count > 1) ? 's' : null)]);
  451. }
  452. if ($fax_subject != '') {
  453. $pdf->Text($x + 2.0, $y + 2.9, $fax_subject);
  454. }
  455. //message
  456. if ($fax_message != '') {
  457. $pdf->SetAutoPageBreak(true, 0.6);
  458. $pdf->SetTopMargin(0.6);
  459. $pdf->SetFont($pdf_font, "", 12);
  460. $pdf->SetXY($x + 0.75, $y + 3.65);
  461. $pdf->MultiCell(7, 5.40, $fax_message, 0, 'L', false);
  462. }
  463. $pages = $pdf->getNumPages();
  464. if ($pages > 1) {
  465. //save ynew for last page
  466. $yn = $pdf->GetY();
  467. //first page
  468. $pdf->setPage(1, 0);
  469. $pdf->Rect($x + 0.5, $y + 3.4, 7.5, $page_height - 3.9, 'D');
  470. //2nd to n-th page
  471. for ($n = 2; $n < $pages; $n++) {
  472. $pdf->setPage($n, 0);
  473. $pdf->Rect($x + 0.5, $y + 0.5, 7.5, $page_height - 1, 'D');
  474. }
  475. //last page
  476. $pdf->setPage($pages, 0);
  477. $pdf->Rect($x + 0.5, 0.5, 7.5, $yn, 'D');
  478. $y = $yn;
  479. unset($yn);
  480. }
  481. else {
  482. $pdf->Rect($x + 0.5, $y + 3.4, 7.5, 6.25, 'D');
  483. $y = $pdf->GetY();
  484. }
  485. //footer
  486. if ($fax_footer != '') {
  487. $pdf->SetAutoPageBreak(true, 0.6);
  488. $pdf->SetTopMargin(0.6);
  489. $pdf->SetFont("helvetica", "", 8);
  490. $pdf->SetXY($x + 0.5, $y + 0.6);
  491. $pdf->MultiCell(7.5, 0.75, $fax_footer, 0, 'C', false);
  492. }
  493. $pdf->SetAutoPageBreak(false);
  494. $pdf->SetTopMargin(0);
  495. //save cover pdf
  496. $pdf->Output($dir_fax_temp.'/'.$fax_instance_uuid.'_cover.pdf', "F"); // Display [I]nline, Save to [F]ile, [D]ownload
  497. //convert pdf to tif, add to array of pages, delete pdf
  498. if (file_exists($dir_fax_temp.'/'.$fax_instance_uuid.'_cover.pdf')) {
  499. chdir($dir_fax_temp);
  500. $cmd = gs_cmd("-q -sDEVICE=tiffg32d -r".$gs_r." -g".$gs_g." -dBATCH -dPDFFitPage -dNOSAFER -dNOPAUSE -sOutputFile=".correct_path($fax_instance_uuid)."_cover.tif -- ".correct_path($fax_instance_uuid)."_cover.pdf -c quit");
  501. // echo($cmd . "<br/>\n");
  502. exec($cmd);
  503. if (is_array($tif_files) && sizeof($tif_files) > 0) {
  504. array_unshift($tif_files, $dir_fax_temp.'/'.$fax_instance_uuid.'_cover.tif');
  505. }
  506. else {
  507. $tif_files[] = $dir_fax_temp.'/'.$fax_instance_uuid.'_cover.tif';
  508. }
  509. @unlink($dir_fax_temp.'/'.$fax_instance_uuid.'_cover.pdf');
  510. }
  511. }
  512. //combine tif files into single multi-page tif
  513. if (is_array($tif_files) && sizeof($tif_files) > 0) {
  514. $cmd = exec('which tiffcp')." -c none ";
  515. foreach ($tif_files as $tif_file) {
  516. $cmd .= correct_path($tif_file) . ' ';
  517. }
  518. $cmd .= correct_path($dir_fax_sent.'/'.$fax_instance_uuid.'.tif');
  519. //echo($cmd . "<br/>\n");
  520. exec($cmd);
  521. //generate pdf from tif
  522. $cmd = exec('which tiff2pdf').' -u i -p '.$fax_page_size.
  523. ' -w '.$page_width.
  524. ' -l '.$page_height.
  525. ' -f -o '.
  526. correct_path($dir_fax_sent.'/'.$fax_instance_uuid.'.pdf').' '.
  527. correct_path($dir_fax_sent.'/'.$fax_instance_uuid.'.tif');
  528. exec($cmd);
  529. //echo $cmd."<br />\n";
  530. //remove the extra files
  531. foreach ($tif_files as $tif_file) {
  532. @unlink($tif_file);
  533. }
  534. }
  535. elseif (!$included) {
  536. //nothing to send, redirect the browser
  537. message::add($text['message-invalid-fax'], 'negative', 4000);
  538. header("Location: fax_send.php?id=".$fax_uuid);
  539. exit;
  540. }
  541. //preview, if requested
  542. if (($_REQUEST['submit'] != '') && ($_REQUEST['submit'] == 'preview')) {
  543. unset($file_type);
  544. if (file_exists($dir_fax_sent.'/'.$fax_instance_uuid.'.pdf')) {
  545. $file_path = $dir_fax_sent.'/'.$fax_instance_uuid.".pdf";
  546. $file_type = 'pdf';
  547. $content_type = 'application/pdf';
  548. @unlink($dir_fax_sent.'/'.$fax_instance_uuid.".tif");
  549. }
  550. else if (file_exists($dir_fax_sent.'/'.$fax_instance_uuid.'.tif')) {
  551. $file_path = $dir_fax_sent.'/'.$fax_instance_uuid.".tif";
  552. $file_type = 'tif';
  553. $content_type = 'image/tiff';
  554. @unlink($dir_fax_sent.'/'.$fax_instance_uuid.".pdf");
  555. }
  556. if ($file_type != '') {
  557. //push download
  558. $fd = fopen($file_path, "rb");
  559. header("Content-Type: application/force-download");
  560. header("Content-Type: application/octet-stream");
  561. header("Content-Type: application/download");
  562. header("Content-Description: File Transfer");
  563. header('Content-Disposition: attachment; filename="'.$fax_instance_uuid.'.'.$file_type.'"');
  564. header("Content-Type: ".$content_type);
  565. header('Accept-Ranges: bytes');
  566. header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
  567. header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // date in the past
  568. header("Content-Length: ".filesize($file_path));
  569. fpassthru($fd);
  570. @unlink($file_path);
  571. }
  572. exit;
  573. }
  574. //prepare variables send the fax
  575. $mail_from_address = (isset($_SESSION['fax']['smtp_from']['text'])) ? $_SESSION['fax']['smtp_from']['text'] : $_SESSION['email']['smtp_from']['text'];
  576. //get the fax mail to address and fax prefix
  577. $sql = "select * from v_fax where fax_uuid = :fax_uuid ";
  578. $parameters['fax_uuid'] = $fax_uuid;
  579. $database = new database;
  580. $row = $database->select($sql, $parameters, 'row');
  581. $mail_to_address = $row["fax_email"];
  582. $fax_prefix = $row["fax_prefix"];
  583. unset($sql, $parameters, $row);
  584. //for email to fax send email notification back to the email sender
  585. if ($included) {
  586. //use email-to-fax from address
  587. $mail_to_address = $sender_email;
  588. }
  589. else {
  590. //send fax through the browser
  591. }
  592. //move the generated tif (and pdf) files to the sent directory
  593. //if (file_exists($dir_fax_temp.'/'.$fax_instance_uuid.".tif")) {
  594. // copy($dir_fax_temp.'/'.$fax_instance_uuid.".tif", $dir_fax_sent.'/'.$fax_instance_uuid.".tif");
  595. //}
  596. //if (file_exists($dir_fax_temp.'/'.$fax_instance_uuid.".pdf")) {
  597. // copy($dir_fax_temp.'/'.$fax_instance_uuid.".pdf ", $dir_fax_sent.'/'.$fax_instance_uuid.".pdf");
  598. //}
  599. //set the fax
  600. $fax_queue_uuid = uuid();
  601. //send the fax
  602. $fax_file = $dir_fax_sent."/".$fax_instance_uuid.".tif";
  603. $common_variables .= "fax_queue_uuid='" . escapeshellarg($fax_queue_uuid) . "',";
  604. $common_variables = "for_fax=1,";
  605. $common_variables .= "accountcode='" . escapeshellarg($fax_accountcode) . "',";
  606. $common_variables .= "sip_h_X-accountcode='" . escapeshellarg($fax_accountcode) . "',";
  607. $common_variables .= "domain_uuid=" . escapeshellarg($_SESSION["domain_uuid"]) . ",";
  608. $common_variables .= "domain_name=" . escapeshellarg($_SESSION["domain_name"]) . ",";
  609. $common_variables .= "origination_caller_id_name='" . escapeshellarg($fax_caller_id_name) . "',";
  610. $common_variables .= "origination_caller_id_number='" . escapeshellarg($fax_caller_id_number) . "',";
  611. $common_variables .= "fax_ident='" . escapeshellarg($fax_caller_id_number) . "',";
  612. $common_variables .= "fax_header='" . escapeshellarg($fax_caller_id_name) . "',";
  613. $common_variables .= "fax_file='" . escapeshellarg($fax_file) . "',";
  614. foreach ($fax_numbers as $fax_number) {
  615. $fax_number = trim($fax_number);
  616. fax_split_dtmf($fax_number, $fax_dtmf);
  617. //prepare the fax command
  618. if (strlen($fax_toll_allow) > 0) {
  619. $channel_variables["toll_allow"] = $fax_toll_allow;
  620. }
  621. $route_array = outbound_route_to_bridge($_SESSION['domain_uuid'], $fax_prefix . $fax_number, $channel_variables);
  622. if (count($route_array) == 0) {
  623. //send the internal call to the registered extension
  624. $fax_uri = "user/".$fax_number."@".$_SESSION['domain_name'];
  625. $fax_variables = "";
  626. }
  627. else {
  628. //send the external call
  629. $fax_uri = $route_array[0];
  630. $fax_variables = "";
  631. foreach($_SESSION['fax']['variable'] as $variable) {
  632. $fax_variables .= escapeshellarg($variable).",";
  633. }
  634. }
  635. //build the fax dial string
  636. $dial_string = $common_variables;
  637. $dial_string .= $fax_variables;
  638. $dial_string .= "mailto_address='" . escapeshellarg($mail_to_address) . "',";
  639. $dial_string .= "mailfrom_address='" . escapeshellarg($mail_from_address) . "',";
  640. $dial_string .= "fax_uri=" . escapeshellarg($fax_uri) . ",";
  641. $dial_string .= "fax_retry_attempts=1" . ",";
  642. $dial_string .= "fax_retry_limit=20" . ",";
  643. $dial_string .= "fax_retry_sleep=180" . ",";
  644. $dial_string .= "fax_verbose=true" . ",";
  645. $dial_string .= "fax_use_ecm=off" . ",";
  646. if ($_SESSION['fax_queue']['enabled']['boolean']) {
  647. $dial_string .= "api_hangup_hook='lua app/fax/resources/scripts/hangup_tx.lua'";
  648. }
  649. else {
  650. $dial_string .= "api_hangup_hook='lua fax_retry.lua'";
  651. }
  652. $dial_string = "{" . $dial_string . "}" . $fax_uri." &txfax('".$fax_file."')";
  653. //add fax to the fax queue or send it directly
  654. if ($_SESSION['fax_queue']['enabled']['boolean']) {
  655. //build an array to add the fax to the queue
  656. $array['fax_queue'][0]['fax_queue_uuid'] = $fax_queue_uuid;
  657. $array['fax_queue'][0]['domain_uuid'] = $_SESSION['domain_uuid'];
  658. $array['fax_queue'][0]['fax_uuid'] = $fax_uuid;
  659. $array['fax_queue'][0]['fax_date'] = 'now()';
  660. $array['fax_queue'][0]['hostname'] = gethostname();
  661. $array['fax_queue'][0]['fax_caller_id_name'] = $fax_caller_id_name;
  662. $array['fax_queue'][0]['fax_caller_id_number'] = $fax_caller_id_number;
  663. $array['fax_queue'][0]['fax_number'] = $fax_number;
  664. $array['fax_queue'][0]['fax_prefix'] = $fax_prefix;
  665. $array['fax_queue'][0]['fax_email_address'] = $mail_to_address;
  666. $array['fax_queue'][0]['fax_file'] = $fax_file;
  667. $array['fax_queue'][0]['fax_status'] = 'waiting';
  668. //$array['fax_queue'][0]['fax_retry_date'] = $fax_retry_date;
  669. $array['fax_queue'][0]['fax_retry_count'] = 0;
  670. $array['fax_queue'][0]['fax_accountcode'] = $fax_accountcode;
  671. $array['fax_queue'][0]['fax_command'] = 'originate '.$dial_string;
  672. //add temporary permisison
  673. $p = new permissions;
  674. $p->add('fax_queue_add', 'temp');
  675. //save the data
  676. $database = new database;
  677. $database->app_name = 'fax queue';
  678. $database->app_uuid = '3656287f-4b22-4cf1-91f6-00386bf488f4';
  679. $database->save($array);
  680. //remove temporary permisison
  681. $p->delete('fax_queue_add', 'temp');
  682. //add message to show in the browser
  683. message::add($text['confirm-queued']);
  684. }
  685. else {
  686. //send the fax directly
  687. $fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);
  688. if ($fp) {
  689. $cmd = "api originate " . $dial_string;
  690. $response = event_socket_request($fp, $cmd);
  691. $response = str_replace("\n", "", $response);
  692. $uuid = str_replace("+OK ", "", $response);
  693. }
  694. fclose($fp);
  695. //add message to show in the browser
  696. message::add($text['confirm-sent']." ".$response);
  697. }
  698. }
  699. //redirect the browser
  700. if (!$included && is_uuid($fax_uuid)) {
  701. if ($_SESSION['fax_queue']['enabled']['boolean']) {
  702. //header("Location: ".PROJECT_PATH."/app/fax_queue/fax_queue.php?id=".$fax_uuid);
  703. header("Location: ".PROJECT_PATH."fax.php");
  704. }
  705. else {
  706. header("Location: fax_files.php?id=".$fax_uuid."&box=sent");
  707. //header("Location: fax_outbox.php?id=".$fax_uuid);
  708. }
  709. exit;
  710. }
  711. } //end upload and send fax
  712. //show content in the browser
  713. if (!$included) {
  714. //retrieve current user's assigned groups (uuids)
  715. foreach ($_SESSION['groups'] as $group_data) {
  716. $user_group_uuids[] = $group_data['group_uuid'];
  717. }
  718. //add user's uuid to group uuid list to include private (non-shared) contacts
  719. $user_group_uuids[] = $_SESSION["user_uuid"];
  720. $sql = "select ";
  721. $sql .= "c.contact_organization, ";
  722. $sql .= "c.contact_name_given, ";
  723. $sql .= "c.contact_name_family, ";
  724. $sql .= "c.contact_nickname, ";
  725. $sql .= "cp.phone_number ";
  726. $sql .= "from ";
  727. $sql .= "v_contacts as c, ";
  728. $sql .= "v_contact_phones as cp ";
  729. $sql .= "where ";
  730. $sql .= "c.contact_uuid = cp.contact_uuid ";
  731. $sql .= "and c.domain_uuid = :domain_uuid ";
  732. $sql .= "and cp.domain_uuid = :domain_uuid ";
  733. $sql .= "and cp.phone_type_fax = 1 ";
  734. $sql .= "and cp.phone_number is not null ";
  735. $sql .= "and cp.phone_number <> '' ";
  736. if ($_SESSION['contact']['permissions']['boolean'] == "true") {
  737. if (is_array($user_group_uuids) && @sizeof($user_group_uuids) != 0) {
  738. //only show contacts assigned to current user's group(s) and those not assigned to any group
  739. $sql .= "and (";
  740. $sql .= " c.contact_uuid in ( ";
  741. $sql .= " select contact_uuid from v_contact_groups ";
  742. $sql .= " where (";
  743. foreach ($user_group_uuids as $index => $user_group_uuid) {
  744. $sql .= $or;
  745. $sql .= " group_uuid = :group_uuid_".$index." ";
  746. $parameters['group_uuid_'.$index] = $user_group_uuid;
  747. $or = " or ";
  748. }
  749. unset($user_group_uuids, $index, $user_group_uuid, $or);
  750. $sql .= " ) ";
  751. $sql .= " and domain_uuid = :domain_uuid ";
  752. $sql .= " ) ";
  753. $sql .= " or ";
  754. $sql .= " c.contact_uuid not in ( ";
  755. $sql .= " select contact_uuid from v_contact_groups ";
  756. $sql .= " where domain_uuid = :domain_uuid ";
  757. $sql .= " ) ";
  758. $sql .= ") ";
  759. }
  760. }
  761. $parameters['domain_uuid'] = $_SESSION['domain_uuid'];
  762. $database = new database;
  763. $contacts = $database->select($sql, $parameters, 'all');
  764. unset($sql, $parameters, $row);
  765. //build the contact labels
  766. if (is_array($contacts) && @sizeof($contacts) != 0) {
  767. foreach ($contacts as &$row) {
  768. if ($row['contact_organization'] != '') {
  769. $contact_option_label = $row['contact_organization'];
  770. }
  771. if ($row['contact_name_given'] != '' || $row['contact_name_family'] != '' || $row['contact_nickname'] != '') {
  772. $contact_option_label .= ($row['contact_organization'] != '') ? "," : null;
  773. $contact_option_label .= ($row['contact_name_given'] != '') ? (($row['contact_organization'] != '') ? " " : null).$row['contact_name_given'] : null;
  774. $contact_option_label .= ($row['contact_name_family'] != '') ? (($row['contact_organization'] != '' || $row['contact_name_given'] != '') ? " " : null).$row['contact_name_family'] : null;
  775. $contact_option_label .= ($row['contact_nickname'] != '') ? (($row['contact_organization'] != '' || $row['contact_name_given'] != '' || $row['contact_name_family'] != '') ? " (".$row['contact_nickname'].")" : $row['contact_nickname']) : null;
  776. }
  777. $contact_option_value_recipient = $contact_option_label;
  778. $contact_option_value_faxnumber = $row['phone_number'];
  779. $contact_option_label .= " ".escape(format_phone($row['phone_number']));
  780. $contact_labels[] = $contact_option_label;
  781. $contact_values[] = $contact_option_value_faxnumber."|".$contact_option_value_recipient;
  782. unset($contact_option_label);
  783. }
  784. if (is_array($contact_labels)) {
  785. //sort by name(s)
  786. asort($contact_labels, SORT_NATURAL);
  787. }
  788. }
  789. //create token
  790. $object = new token;
  791. $token = $object->create($_SERVER['PHP_SELF']);
  792. //show the header
  793. $document['title'] = $text['title-new_fax'];
  794. require_once "resources/header.php";
  795. //javascript to toggle input/select boxes, add fax numbers
  796. echo "<script language='JavaScript' type='text/javascript' src='".PROJECT_PATH."/resources/javascript/reset_file_input.js'></script>\n";
  797. echo "<script language='JavaScript' type='text/javascript'>";
  798. echo " function toggle(field) {";
  799. echo " if (field == 'fax_recipient') {";
  800. echo " document.getElementById('fax_recipient_select').selectedIndex = 0;";
  801. echo " $('#fax_recipient_select').toggle();";
  802. echo " $('#fax_recipient').toggle();";
  803. echo " if ($('#fax_recipient').is(':visible')) { $('#fax_recipient').trigger('focus'); } else { $('#fax_recipient_select').trigger('focus'); }";
  804. echo " }";
  805. echo " }";
  806. echo " function contact_load(obj_sel) {";
  807. echo " obj_sel.style.display='none';";
  808. echo " document.getElementById('fax_recipient').style.display='';";
  809. echo " var selected_option_value = obj_sel.options[obj_sel.selectedIndex].value;";
  810. echo " var selected_option_values = selected_option_value.split('|', 2);";
  811. echo " document.getElementById('fax_recipient').value = selected_option_values[1];";
  812. echo " document.getElementById('fax_number').value = selected_option_values[0];";
  813. echo " $('#fax_recipient').css({width: '50%'});";
  814. echo " $('#fax_number').css({width: '120px'});";
  815. echo " }";
  816. echo " function list_selected_files(file_input_number) {";
  817. echo " var inp = document.getElementById('fax_files_'+file_input_number);";
  818. echo " var files_selected = [];";
  819. echo " for (var i = 0; i < inp.files.length; ++i) {";
  820. echo " var file_name = inp.files.item(i).name;";
  821. echo " files_selected.push(file_name);";
  822. echo " }";
  823. echo " document.getElementById('file_list_'+file_input_number).innerHTML = '';";
  824. echo " if (files_selected.length > 1) {";
  825. echo " document.getElementById('file_list_'+file_input_number).innerHTML = '<strong>".$text['label-selected']."</strong>: ';";
  826. echo " document.getElementById('file_list_'+file_input_number).innerHTML += files_selected.join(', ');";
  827. echo " document.getElementById('file_list_'+file_input_number).innerHTML += '<br />';";
  828. echo " }";
  829. echo " }";
  830. echo " function add_fax_number() {\n";
  831. echo " var newdiv = document.createElement('div');\n";
  832. echo " newdiv.innerHTML = \"<input type='text' name='fax_numbers[]' class='formfld' style='width: 150px; min-width: 150px; max-width: 150px; margin-top: 3px;' maxlength='25'>\";";
  833. echo " document.getElementById('fax_numbers').appendChild(newdiv);";
  834. echo " }\n";
  835. echo "</script>";
  836. //show the content
  837. echo "<form method='post' name='frm' id='frm' enctype='multipart/form-data'>\n";
  838. echo "<div class='action_bar' id='action_bar'>\n";
  839. echo " <div class='heading'><b>".$text['header-new_fax']."</b></div>\n";
  840. echo " <div class='actions'>\n";
  841. echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'id'=>'btn_back','style'=>'margin-right: 15px;','link'=>'fax.php']);
  842. echo button::create(['type'=>'submit','label'=>$text['button-preview'],'icon'=>'eye','name'=>'submit','value'=>'preview']);
  843. echo button::create(['type'=>'submit','label'=>$text['button-send'],'icon'=>'paper-plane','id'=>'btn_save','name'=>'submit','value'=>'send','style'=>'margin-left: 15px;']);
  844. echo " </div>\n";
  845. echo " <div style='clear: both;'></div>\n";
  846. echo "</div>\n";
  847. echo $text['description-2']." ".(permission_exists('fax_extension_view_domain') ? $text['description-3'] : null)."\n";
  848. echo "<br /><br />\n";
  849. echo "<table width='100%' border='0' cellspacing='0' cellpadding='0'>\n";
  850. echo "<tr>\n";
  851. echo "<td class='vncell' valign='top' align='left' nowrap>\n";
  852. echo " ".$text['label-fax-header']."\n";
  853. echo "</td>\n";
  854. echo "<td class='vtable' align='left'>\n";
  855. echo " <input type='text' name='fax_header' class='formfld' style='' value='".$_SESSION['fax']['cover_header']['text']."'>\n";
  856. echo " <br />\n";
  857. echo " ".$text['description-fax-header']."\n";
  858. echo "</td>\n";
  859. echo "</tr>\n";
  860. echo "<tr>\n";
  861. echo "<td class='vncell' valign='top' align='left' nowrap>\n";
  862. echo " ".$text['label-fax-sender']."\n";
  863. echo "</td>\n";
  864. echo "<td class='vtable' align='left'>\n";
  865. echo " <input type='text' name='fax_sender' class='formfld' style='' value='".escape($fax_caller_id_name)."'>\n";
  866. echo " <br />\n";
  867. echo " ".$text['description-fax-sender']."\n";
  868. echo "</td>\n";
  869. echo "</tr>\n";
  870. echo "<tr>\n";
  871. echo "<td class='vncell' valign='top' align='left' nowrap>\n";
  872. echo " ".$text['label-fax-recipient']."\n";
  873. echo "</td>\n";
  874. echo "<td class='vtable' align='left'>\n";
  875. if (is_array($contacts) && @sizeof($contacts) != 0) {
  876. echo " <select class='formfld' style='display: none;' id='fax_recipient_select' onchange='contact_load(this);'>\n";
  877. echo " <option value=''></option>\n";
  878. if (is_array($contact_labels) && @sizeof($contact_labels) != 0) {
  879. foreach ($contact_labels as $index => $contact_label) {
  880. echo " <option value=\"".escape($contact_values[$index])."\">".$contact_label."</option>\n";
  881. }
  882. }
  883. echo " </select>\n";
  884. }
  885. echo " <input type='text' name='fax_recipient' id='fax_recipient' class='formfld' style='max-width: 250px;' value=''>\n";
  886. if (is_array($contacts)) {
  887. echo " <input type='button' id='btn_toggle_recipient' class='btn' name='' alt='".$text['button-back']."' value='&#9665;' onclick=\"toggle('fax_recipient');\">\n";
  888. }
  889. echo " <br />\n";
  890. echo " ".$text['description-fax-recipient']."\n";
  891. echo "</td>\n";
  892. echo "</tr>\n";
  893. echo "<tr>\n";
  894. echo "<td class='vncellreq' valign='top' align='left' nowrap>\n";
  895. echo " ".$text['label-fax-number']."\n";
  896. echo "</td>\n";
  897. echo "<td class='vtable' align='left'>\n";
  898. echo " <table cellpadding='0' cellspacing='0' border='0'>";
  899. echo " <tr>";
  900. echo " <td id='fax_numbers'>";
  901. echo " <input type='text' name='fax_numbers[]' id='fax_number' class='formfld' style='width: 150px; min-width: 150px; max-width: 150px;' maxlength='25'>\n";
  902. echo " </td>";
  903. echo " <td style='vertical-align: bottom;'>";
  904. echo " <a href='javascript:void(0);' onclick='add_fax_number();'>$v_link_label_add</a>";
  905. echo " </td>";
  906. echo " </tr>";
  907. echo " </table>";
  908. echo " ".$text['description-fax-number']."\n";
  909. echo "</td>\n";
  910. echo "</tr>\n";
  911. echo "<tr>\n";
  912. echo "<td class='vncell' valign='top' align='left' nowrap>\n";
  913. echo " ".$text['label-fax_files']."\n";
  914. echo "</td>\n";
  915. echo "<td class='vtable' align='left'>\n";
  916. for ($f = 1; $f <= 3; $f++) {
  917. echo " <span id='fax_file_".$f."' ".(($f > 1) ? "style='display: none;'" : null).">";
  918. echo " <input name='fax_files[]' id='fax_files_".$f."' type='file' class='formfld fileinput' style='margin-right: 3px; ".(($f > 1) ? "margin-top: 3px;" : null)."' onchange=\"".(($f < 3) ? "document.getElementById('fax_file_".($f+1)."').style.display='';" : null)." list_selected_files(".$f.");\" multiple='multiple'>";
  919. echo button::create(['type'=>'button','label'=>$text['button-clear'],'icon'=>$_SESSION['theme']['button_icon_reset'],'onclick'=>"reset_file_input('fax_files_".$f."'); document.getElementById('file_list_".$f."').innerHTML='';"]);
  920. echo "<br />";
  921. echo " <span id='file_list_".$f."'></span>";
  922. echo " </span>\n";
  923. }
  924. echo " ".$text['description-fax_files']."\n";
  925. echo "</td>\n";
  926. echo "</tr>\n";
  927. echo "<tr>\n";
  928. echo "<td class='vncell' valign='top' align='left' nowrap>\n";
  929. echo " ".$text['label-fax-resolution']."\n";
  930. echo "</td>\n";
  931. echo "<td class='vtable' align='left'>\n";
  932. echo " <select name='fax_resolution' class='formfld'>\n";
  933. echo " <option value='normal' ".(($_SESSION['fax']['resolution']['text'] == 'normal') ? 'selected' : null).">".$text['option-fax-resolution-normal']."</option>\n";
  934. echo " <option value='fine' ".(($_SESSION['fax']['resolution']['text'] == 'fine') ? 'selected' : null).">".$text['option-fax-resolution-fine']."</option>\n";
  935. echo " <option value='superfine' ".(($_SESSION['fax']['resolution']['text'] == 'superfine') ? 'selected' : null).">".$text['option-fax-resolution-superfine']."</option>\n";
  936. echo " </select>\n";
  937. echo " <br />\n";
  938. echo " ".$text['description-fax-resolution']."\n";
  939. echo "</td>\n";
  940. echo "</tr>\n";
  941. echo "<tr>\n";
  942. echo "<td class='vncell' valign='top' align='left' nowrap>\n";
  943. echo " ".$text['label-fax-page-size']."\n";
  944. echo "</td>\n";
  945. echo "<td class='vtable' align='left'>\n";
  946. echo " <select name='fax_page_size' class='formfld'>\n";
  947. echo " <option value='letter' ".(($_SESSION['fax']['page_size']['text'] == 'letter') ? 'selected' : null).">Letter</option>\n";
  948. echo " <option value='legal' ".(($_SESSION['fax']['page_size']['text'] == 'legal') ? 'selected' : null).">Legal</option>\n";
  949. echo " <option value='a4' ".(($_SESSION['fax']['page_size']['text'] == 'a4') ? 'selected' : null).">A4</option>\n";
  950. echo " </select>\n";
  951. echo " <br />\n";
  952. echo " ".$text['description-fax-page-size']."\n";
  953. echo "</td>\n";
  954. echo "</tr>\n";
  955. if (permission_exists('fax_subject')) {
  956. echo "<tr>\n";
  957. echo "<td class='vncell' valign='top' align='left' nowrap>\n";
  958. echo " ".$text['label-fax-subject']."\n";
  959. echo "</td>\n";
  960. echo "<td class='vtable' align='left'>\n";
  961. echo " <input type='text' name='fax_subject' class='formfld' style='' value=''>\n";
  962. echo " <br />\n";
  963. echo " ".$text['description-fax-subject']."\n";
  964. echo "</td>\n";
  965. echo "</tr>\n";
  966. }
  967. if (permission_exists('fax_message')) {
  968. echo "<tr>\n";
  969. echo "<td class='vncell' valign='top' align='left' nowrap>\n";
  970. echo " ".$text['label-fax-message']."\n";
  971. echo "</td>\n";
  972. echo "<td class='vtable' align='left'>\n";
  973. echo " <textarea type='text' name='fax_message' class='formfld' style='width: 65%; height: 175px;'></textarea>\n";
  974. echo "<br />\n";
  975. echo " ".$text['description-fax-message']."\n";
  976. echo "</td>\n";
  977. echo "</tr>\n";
  978. }
  979. if (permission_exists('fax_footer')) {
  980. echo "<tr>\n";
  981. echo "<td class='vncell' valign='top' align='left' nowrap>\n";
  982. echo " ".$text['label-fax-footer']."\n";
  983. echo "</td>\n";
  984. echo "<td class='vtable' align='left'>\n";
  985. echo " <textarea type='text' name='fax_footer' class='formfld' style='width: 65%; height: 100px;'>".$_SESSION['fax']['cover_footer']['text']."</textarea>\n";
  986. echo " <br />\n";
  987. echo " ".$text['description-fax-footer']."\n";
  988. echo "</td>\n";
  989. echo "</tr>\n";
  990. }
  991. echo "</table>";
  992. echo "<br /><br />\n";
  993. echo "<input type='hidden' name='fax_caller_id_name' value='".escape($fax_caller_id_name)."'>\n";
  994. echo "<input type='hidden' name='fax_caller_id_number' value='".escape($fax_caller_id_number)."'>\n";
  995. echo "<input type='hidden' name='fax_extension' value='".escape($fax_extension)."'>\n";
  996. echo "<input type='hidden' name='id' value='".escape($fax_uuid)."'>\n";
  997. echo "<input type='hidden' name='action' value='send'>\n";
  998. echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
  999. echo "</form>\n";
  1000. //show the footer
  1001. require_once "resources/footer.php";
  1002. }
  1003. // used for initial element alignment during pdf generation
  1004. /*
  1005. function showgrid($pdf) {
  1006. // generate a grid for placement
  1007. for ($x=0; $x<=8.5; $x+=0.1) {
  1008. for ($y=0; $y<=11; $y+=0.1) {
  1009. $pdf->SetTextColor(0,0,0);
  1010. $pdf->SetFont("courier", "", 3);
  1011. $pdf->Text($x-0.01,$y-0.01,".");
  1012. }
  1013. }
  1014. for ($x=0; $x<=9; $x+=1) {
  1015. for ($y=0; $y<=11; $y+=1) {
  1016. $pdf->SetTextColor(255,0,0);
  1017. $pdf->SetFont("times", "", 10);
  1018. $pdf->Text($x-.02,$y-.01,".");
  1019. $pdf->SetFont("courier", "", 4);
  1020. $pdf->Text($x+0.01,$y+0.035,$x.",".$y);
  1021. }
  1022. }
  1023. }
  1024. */
  1025. ?>