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.

184 lines
6.2 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) 2021
  17. the Initial Developer. All Rights Reserved.
  18. Contributor(s):
  19. Mark J Crane <markjcrane@fusionpbx.com>
  20. */
  21. //includes
  22. include "root.php";
  23. require_once "resources/require.php";
  24. require_once "resources/check_auth.php";
  25. require_once "resources/paging.php";
  26. //check permissions
  27. if (permission_exists('fax_extension_view')) {
  28. //access granted
  29. }
  30. else {
  31. echo "access denied";
  32. exit;
  33. }
  34. //add multi-lingual support
  35. $language = new text;
  36. $text = $language->get();
  37. //create token
  38. $object = new token;
  39. $token = $object->create($_SERVER['PHP_SELF']);
  40. //get fax extensions
  41. if (is_uuid($_REQUEST["id"])) {
  42. $fax_uuid = $_REQUEST["id"];
  43. if (permission_exists('fax_extension_view_domain')) {
  44. //show all fax extensions
  45. $sql = "select fax_name, fax_extension from v_fax ";
  46. $sql .= "where domain_uuid = :domain_uuid ";
  47. $sql .= "and fax_uuid = :fax_uuid ";
  48. $parameters['domain_uuid'] = $_SESSION['domain_uuid'];
  49. $parameters['fax_uuid'] = $fax_uuid;
  50. }
  51. else {
  52. //show only assigned fax extensions
  53. $sql = "select fax_name, fax_extension from v_fax as f, v_fax_users as u ";
  54. $sql .= "where f.fax_uuid = u.fax_uuid ";
  55. $sql .= "and f.domain_uuid = :domain_uuid ";
  56. $sql .= "and f.fax_uuid = :fax_uuid ";
  57. $sql .= "and u.user_uuid = :user_uuid ";
  58. $parameters['domain_uuid'] = $_SESSION['domain_uuid'];
  59. $parameters['fax_uuid'] = $fax_uuid;
  60. $parameters['user_uuid'] = $_SESSION['user_uuid'];
  61. }
  62. $database = new database;
  63. $row = $database->select($sql, $parameters, 'row');
  64. if (is_array($row) && @sizeof($row) != 0) {
  65. //set database fields as variables
  66. $fax_name = $row["fax_name"];
  67. $fax_extension = $row["fax_extension"];
  68. }
  69. else {
  70. if (!permission_exists('fax_extension_view_domain')) {
  71. echo "access denied";
  72. exit;
  73. }
  74. }
  75. unset($sql, $parameters, $row);
  76. }
  77. $sql = "select * from v_fax_files ";
  78. $sql .= "where fax_uuid = :fax_uuid ";
  79. $sql .= "and domain_uuid = :domain_uuid ";
  80. $sql .= "and fax_mode = 'tx' ";
  81. $parameters['fax_uuid'] = $_REQUEST["id"];
  82. $parameters['domain_uuid'] = $_SESSION['domain_uuid'];
  83. $database = new database;
  84. $fax_files = $database->select($sql, $parameters, 'all');
  85. unset($sql, $parameters);
  86. //check if currently sending a fax
  87. $switch_cmd = 'show channels as json';
  88. //create the event socket connection
  89. $fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);
  90. //send the event socket command and get the array
  91. if ($fp) {
  92. $json = trim(event_socket_request($fp, 'api '.$switch_cmd));
  93. $results = json_decode($json, "true");
  94. }
  95. //additional includes
  96. $document['title'] = 'Fax Outbox';
  97. require_once "resources/header.php";
  98. //show the content
  99. echo "<div class='action_bar' id='action_bar'>\n";
  100. echo " <div class='heading'><b>Fax Outbox</b></div>\n";
  101. echo " <div style='clear: both;'></div>\n";
  102. echo "</div>\n";
  103. echo "Show active faxes that are currently sending.\n";
  104. echo "<br /><br />\n";
  105. //echo "<form id='form_list' method='post'>\n";
  106. echo "<form id='form_list' onsubmit='' method='post'>\n";
  107. echo " <input type='hidden' id='action' name='action' value=''>\n";
  108. echo " <input type='hidden' name='search' value=\"".escape($search)."\">\n";
  109. //echo " <input type='hidden' id='my_id' name='my_id' value='' />";
  110. echo " <table class='list'>\n";
  111. echo " <tr class='list-header'>\n";
  112. echo " <th>Destination</th>";
  113. echo " <th>Status</th>";
  114. echo " <th>Preview</th>";
  115. echo " <th>Path</th>";
  116. echo " </tr>\n";
  117. //loop through the faxes
  118. if (isset($results["rows"])) {
  119. if (is_array($results["rows"]) && @sizeof($results["rows"]) != 0) {
  120. $x = 0;
  121. foreach ($results["rows"] as $row) {
  122. $file = basename($row['application_data']);
  123. if (strtolower(substr($file, -3)) == "tif" || strtolower(substr($file, -3)) == "pdf") {
  124. $file_name = substr($file, 0, (strlen($file) -4));
  125. }
  126. if (strlen($row['fax_base64']) <= 0) {
  127. echo " <tr class='list-row' >\n";
  128. echo " <td>".escape($row['dest'])."</td>";
  129. echo " <td>Sending...</td>";
  130. echo " <td>\n";
  131. echo " <a href='/app/fax/fax_files.php?id=".urlencode($_REQUEST["id"])."&a=download&type=fax_sent&t=bin&ext=".urlencode($fax_extension)."&filename=".urlencode($file_name).".tif'>Fax PDF - ".urlencode($file_name)."</a>\n";
  132. echo " </td>\n";
  133. echo " <td>".escape($row['application_data'])."</td>";
  134. echo " </tr>\n";
  135. }
  136. $x++;
  137. }
  138. }
  139. }
  140. echo " </table>\n";
  141. echo " <br />\n";
  142. echo " <input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
  143. echo "</form>\n";
  144. echo "<span id='output'></span>\n";
  145. echo "<script type='text/javascript'>\n";
  146. echo " function AutoRefresh( t ) { setTimeout('location.reload(true);', t); }";
  147. echo " AutoRefresh(10000);";
  148. echo "</script>\n";
  149. //$my_id = $_SESSION['/var/lib/freeswitch/storage/fax/'.$_SESSION['domain_name'].'/'.$fax_extension.'/temp'];
  150. //if (file_exists('/var/lib/freeswitch/storage/fax/'.$_SESSION['domain_name'].'/'.$fax_extension.'/temp/'.$my_id.'.tif')) {
  151. // rename('/var/lib/freeswitch/storage/fax/'.$_SESSION['domain_name'].'/'.$fax_extension.'/temp/'.$my_id.'.tif', '/var/lib/freeswitch/storage/fax/'.$_SESSION['domain_name'].'/'.$fax_extension.'/sent/'.$my_id.'.tif');
  152. //}
  153. //if (file_exists('/var/lib/freeswitch/storage/fax/'.$_SESSION['domain_name'].'/'.$fax_extension.'/temp/'.$my_id.'.pdf')) {
  154. // rename('/var/lib/freeswitch/storage/fax/'.$_SESSION['domain_name'].'/'.$fax_extension.'/temp/'.$my_id.'.pdf', '/var/lib/freeswitch/storage/fax/'.$_SESSION['domain_name'].'/'.$fax_extension.'/sent/'.$my_id.'.pdf');
  155. //}
  156. //include the footer
  157. require_once "resources/footer.php";
  158. ?>