phone.php 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  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 <[email protected]>
  16. Portions created by the Initial Developer are Copyright (C) 2024
  17. the Initial Developer. All Rights Reserved.
  18. Contributor(s):
  19. Mark J Crane <[email protected]>
  20. */
  21. //includes files
  22. require_once dirname(__DIR__, 2) . "/resources/require.php";
  23. require_once 'resources/pdo.php';
  24. require_once "resources/check_auth.php";
  25. //check permissions
  26. if (!permission_exists('phone_view')) {
  27. echo "access denied";
  28. exit;
  29. }
  30. //add multi-lingual support
  31. $language = new text;
  32. $text = $language->get();
  33. //get user_uuid and domain_uuid
  34. $user_uuid = $_SESSION['user_uuid'];
  35. $domain_uuid = $_SESSION["domain_uuid"];
  36. //add the settings object
  37. $settings = new settings(["domain_uuid" => $domain_uuid, "user_uuid" => $user_uuid]);
  38. $theme_title = $settings->get('theme', 'title', '');
  39. $search_enabled = $settings->get('phone', 'search_enabled', 'true');
  40. $search_domain = $settings->get('phone', 'search_domain', $_SESSION['domain_name']);
  41. $search_path = $settings->get('phone', 'search_path', '/core/contacts/contacts.php');
  42. $search_parameter = $settings->get('phone', 'search_parameter', 'search');
  43. $search_target = $settings->get('phone', 'search_target', '');
  44. $search_width = $settings->get('phone', 'search_width', '');
  45. $search_height = $settings->get('phone', 'search_height', '');
  46. //get the user ID
  47. $sql = "SELECT d.domain_name,e.extension,e.password FROM ";
  48. $sql .= "v_extension_users as t, v_extensions as e, v_users as u, v_domains as d ";
  49. $sql .= "WHERE u.user_uuid = t.user_uuid ";
  50. $sql .= "AND e.extension_uuid = t.extension_uuid ";
  51. $sql .= "AND e.domain_uuid = d.domain_uuid ";
  52. $sql .= "AND u.user_uuid = '" . $user_uuid . "' ";
  53. $sql .= "AND e.domain_uuid = '" . $domain_uuid . "' LIMIT 1";
  54. $prep_statement = $db->prepare($sql);
  55. if ($prep_statement) {
  56. $prep_statement->execute();
  57. $row = $prep_statement->fetch(PDO::FETCH_ASSOC);
  58. $domain_name = $row['domain_name'];
  59. $user_extension = $row['extension'];
  60. $user_password = $row['password'];
  61. }
  62. //set the title
  63. $document['title'] = $text['title-phone'];
  64. //send the content
  65. echo "<html>\n";
  66. echo "<head>\n";
  67. echo " <title>".$text['title-phone']." - ".escape($theme_title)."</title>\n";
  68. echo " <meta charset='utf-8'>\n";
  69. echo " <meta http-equiv='Content-Type' content='text/html; charset=UTF-8'>\n";
  70. echo " <meta http-equiv='X-UA-Compatible' content='IE=edge'>\n";
  71. echo " <meta name='viewport' content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no' />\n";
  72. echo " <meta name='robots' content='noindex, nofollow, noarchive' />\n";
  73. echo " <link rel='stylesheet' type='text/css' href='".PROJECT_PATH."/resources/fontawesome/css/all.min.css.php'>\n";
  74. echo " <link rel='stylesheet' type='text/css' href='resources/styles.css'>\n";
  75. echo " <script language='JavaScript' type='text/javascript'>window.FontAwesomeConfig = { autoReplaceSvg: false }</script>\n";
  76. echo " <script language='JavaScript' type='text/javascript' src='resources/sip-0.7.8.js'></script>\n";
  77. echo "</head>\n";
  78. echo "<body>\n";
  79. //define the video tag
  80. echo " <div>\n";
  81. echo " <div style='position: absolute;'><video id='remote_video' width='640' height='480' style='display: none;'></video></div>\n";
  82. echo " <div style='position: absolute; display: none;'><video id='local_video' width='160' height='120' style='display: none;'></video></div>\n";
  83. echo " </div>\n";
  84. //define the audio ringtone
  85. echo " <audio id='ringtone' preload='auto'>\n";
  86. echo " <source src='resources/ringtones/ringtone.mp3' type='audio/mpeg' loop='loop' />\n";
  87. echo " </audio>\n";
  88. //audio or video objects need to be initialized before phone.js
  89. echo " <script language='JavaScript' type='text/javascript'>";
  90. require 'resources/phone.js';
  91. echo " </script>\n";
  92. //define the dialpad control
  93. echo " <div class='dialpad' id='dialpad'>\n";
  94. echo " <input type='text' class='destination' id='destination' name='destination' onkeypress=\"event.preventDefault();\"/>\n";
  95. echo " <div class='dialpad_wrapper'>\n";
  96. echo " <div class='dialpad_box' onclick=\"digit_add('1');\"><strong>1</strong><br><sup>&nbsp;</sup></div>\n";
  97. echo " <div class='dialpad_box' onclick=\"digit_add('2');\"><strong>2</strong><br><sup>ABC</sup></div>\n";
  98. echo " <div class='dialpad_box' onclick=\"digit_add('3');\"><strong>3</strong><br><sup>DEF</sup></div>\n";
  99. echo " <div class='dialpad_box' onclick=\"digit_add('4');\"><strong>4</strong><br><sup>GHI</sup></div>\n";
  100. echo " <div class='dialpad_box' onclick=\"digit_add('5');\"><strong>5</strong><br><sup>JKL</sup></div>\n";
  101. echo " <div class='dialpad_box' onclick=\"digit_add('6');\"><strong>6</strong><br><sup>MNO</sup></div>\n";
  102. echo " <div class='dialpad_box' onclick=\"digit_add('7');\"><strong>7</strong><br><sup>PQRS</sup></div>\n";
  103. echo " <div class='dialpad_box' onclick=\"digit_add('8');\"><strong>8</strong><br><sup>TUV</sup></div>\n";
  104. echo " <div class='dialpad_box' onclick=\"digit_add('9');\"><strong>9</strong><br><sup>WXYZ</sup></div>\n";
  105. echo " <div class='dialpad_box' onclick=\"digit_add('*');\" style='margin-bottom: 8px; padding-top: 20px; padding-bottom: 0;'><strong>*</strong></div>\n";
  106. echo " <div class='dialpad_box' onclick=\"digit_add('0');\" style='margin-bottom: 8px; padding-top: 15px; padding-bottom: 5px;'><strong>0</strong></div>\n";
  107. echo " <div class='dialpad_box' onclick=\"digit_add('#');\" style='margin-bottom: 8px; padding-top: 15px; padding-bottom: 5px;'><strong>#</strong></div>\n";
  108. echo " <div class='dialpad_box clear' onclick='digit_clear();' title=\"".$text['label-clear']."\"><i class='fas fa-times'></i><br><sup>".$text['label-clear']."</sup></div>\n";
  109. echo " <div class='dialpad_box call' onclick='send();' title=\"".$text['label-call']."\"><i class='fa-solid fa-phone'></i><br><sup>".$text['label-call']."</sup></div>\n";
  110. echo " <div class='dialpad_box delete' onclick='digit_delete();' title=\"".$text['label-delete']."\"><i class='fas fa-chevron-left'></i><br><sup>".$text['label-delete']."</sup></div>\n";
  111. echo " </div>\n";
  112. echo " </div>\n";
  113. //define the ringing control
  114. echo " <div class='dialpad' id='ringing' style='display: none;'>\n";
  115. echo " <div class='caller_id ringing' id='ringing_caller_id'></div>\n";
  116. echo " <div class='dialpad_wrapper' style='grid-template-columns: 50% 50%;'>\n";
  117. echo " <div class='dialpad_box' id='decline' onclick='hangup();' style='background-color: #ba0000;'><i class='fas fa-phone-slash' title=\"".$text['label-decline']."\"></i><br><sup>".$text['label-decline']."</sup></div>\n";
  118. echo " <div class='dialpad_box' id='answer' onclick='answer();' style='background-color: #147e00;'><i class='fas fa-phone' title=\"".$text['label-answer']."\"></i><br><sup>".$text['label-answer']."</sup></div>\n";
  119. echo " </div>\n";
  120. echo " </div>\n";
  121. //define the active call control
  122. echo " <div class='dialpad' id='active' style='display: none;'>\n";
  123. echo " <div class='caller_id' id='active_caller_id'></div>\n";
  124. echo " <div id='answer_time' class='answer_time'>00:00:00</div>\n";
  125. echo " <div class='dialpad_wrapper'>\n";
  126. echo " <div class='dialpad_box mute' id='mute_audio' onclick='mute_audio();'><i class='fas fa-microphone' title=\"".$text['label-mute']."\"></i><br><sup>".$text['label-mute']."</sup></div>\n";
  127. echo " <div class='dialpad_box' id='unmute_audio' style='color: #ba0000; display: none;' onclick='unmute_audio();'><i class='fas fa-microphone-slash' title=\"".$text['label-unmute']."\"></i><br><sup>".$text['label-unmute']."</sup></div>\n";
  128. echo " <div class='dialpad_box' id='hangup' onclick='hangup();' style='background-color: #ba0000;'><i class='fas fa-phone-slash' title=\"".$text['label-end']."\"></i><br><sup>".$text['label-end']."</sup></div>\n";
  129. echo " <div class='dialpad_box hold' id='hold' onclick='hold();'><i class='fas fa-pause' title=\"".$text['label-hold']."\"></i><br><sup>".$text['label-hold']."</sup></div>\n";
  130. echo " <div class='dialpad_box' id='unhold' style='color: #1ba800; display: none;' onclick='unhold();'><i class='fas fa-play' title=\"".$text['label-resume']."\"></i><br><sup>".$text['label-resume']."</sup></div>\n";
  131. echo " <div class='dialpad_box' id='mute_video' style='display: none;' onclick='mute_video();'>&nbsp;</div>\n";
  132. echo " <div class='dialpad_box' id='umute_video' style='display: none;' onclick='unmute_video();'>&nbsp;</div>\n";
  133. echo " </div>\n";
  134. echo " </div>\n";
  135. echo "</body>\n";
  136. echo "</html>\n";
  137. ?>