index.php 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  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) 2008-2023
  17. the Initial Developer. All Rights Reserved.
  18. Contributor(s):
  19. Mark J Crane <[email protected]>
  20. KonradSC <[email protected]>
  21. */
  22. //includes files
  23. require_once dirname(__DIR__, 2) . "/resources/require.php";
  24. require_once "resources/check_auth.php";
  25. //check permissions
  26. if (permission_exists('sessiontalk_view')) {
  27. //access granted
  28. }
  29. else {
  30. echo "access denied";
  31. exit;
  32. }
  33. //add multi-lingual support
  34. $language = new text;
  35. $text = $language->get();
  36. //verify the id is as uuid then set as a variable
  37. if (is_uuid($_GET['id'])) {
  38. $extension_uuid = $_GET['id'];
  39. }
  40. //get the extension(s)
  41. if (permission_exists('extension_edit')) {
  42. //admin user
  43. $sql = "SELECT e.extension_uuid, e.extension, e.description, u.api_key, e.number_alias ";
  44. $sql .= "FROM v_extensions AS e, v_extension_users AS eu, v_users AS u ";
  45. $sql .= "WHERE e.domain_uuid = :domain_uuid ";
  46. $sql .= "AND e.enabled = 'true' ";
  47. $sql .= "AND e.extension_uuid = eu.extension_uuid ";
  48. $sql .= "AND eu.user_uuid = u.user_uuid ";
  49. $sql .= "order by e.extension asc ";
  50. }
  51. else {
  52. //normal user
  53. $sql = "SELECT e.extension_uuid, e.extension, e.description, u.api_key, e.number_alias ";
  54. $sql .= "FROM v_extensions AS e, v_extension_users AS eu, v_users AS u ";
  55. $sql .= "WHERE e.domain_uuid = :domain_uuid ";
  56. $sql .= "AND eu.user_uuid = :user_uuid ";
  57. $sql .= "AND e.extension_uuid = eu.extension_uuid ";
  58. $sql .= "AND eu.user_uuid = u.user_uuid ";
  59. $sql .= "order by e.extension asc ";
  60. $parameters['user_uuid'] = $_SESSION['user']['user_uuid'];
  61. }
  62. $parameters['domain_uuid'] = $_SESSION['domain_uuid'];
  63. $database = new database;
  64. $extensions = $database->select($sql, $parameters, 'all');
  65. //echo $sql;
  66. //exit;
  67. unset($sql, $parameters);
  68. if (is_uuid($extension_uuid) && is_array($extensions) && @sizeof($extensions) != 0) {
  69. //loop through get selected extension
  70. if (is_array($extensions) && @sizeof($extensions) != 0) {
  71. foreach ($extensions as $extension) {
  72. if ($extension['extension_uuid'] == $extension_uuid) {
  73. $field = $extension;
  74. break;
  75. }
  76. }
  77. }
  78. //get the username
  79. $username = $field['extension'];
  80. if (isset($field['number_alias']) && strlen($field['number_alias']) > 0) {
  81. $username = $field['number_alias'];
  82. }
  83. $qr_content = "scsc:". $username . "@" . $_SESSION['domain_name'] . ":". $field['api_key'] . ":" . $_SESSION['provision']['sessiontalk_provider_id']['text'];
  84. }
  85. //debian
  86. //apt install qrencode
  87. //include the header
  88. $document['title'] = $text['title-sessiontalk'];
  89. require_once "resources/header.php";
  90. //show the content
  91. echo "<form name='frm' id='frm' method='get'>\n";
  92. echo "<div class='action_bar' id='action_bar'>\n";
  93. echo " <div class='heading'><b>".$text['title-sessiontalk']."</b></div>\n";
  94. echo " <div class='actions'>\n";
  95. echo " <a href='https://play.google.com/store/apps/details?id=co.froute.sessioncloud' target='_blank'><img src='/app/sessiontalk/resources/images/google_play.png' style='width: auto; height: 30px;' /></a>";
  96. echo " <a href='https://apps.apple.com/us/app/sessioncloud-sip-softphone/id1065327562' target='_blank'><img src='/app/sessiontalk/resources/images/apple_app_store.png' style='width: auto; height: 30px;' /></a>";
  97. echo " </div>\n";
  98. echo " <div style='clear: both;'></div>\n";
  99. echo "</div>\n";
  100. echo $text['title_description-sessiontalk']."\n";
  101. echo "<br /><br />\n";
  102. //echo $qr_content; //debug
  103. echo "<div style='text-align: center; white-space: nowrap; margin: 10px 0 40px 0;'>";
  104. echo $text['label-extension']."<br />\n";
  105. echo "<select name='id' class='formfld' onchange='this.form.submit();'>\n";
  106. echo " <option value='' >".$text['label-select']."...</option>\n";
  107. if (is_array($extensions) && @sizeof($extensions) != 0) {
  108. foreach ($extensions as $row) {
  109. $selected = $row['extension_uuid'] == $extension_uuid ? "selected='selected'" : null;
  110. echo " <option value='".escape($row['extension_uuid'])."' ".$selected.">".escape($row['extension'])." ".escape($row['number_alias'])." ".escape($row['description'])."</option>\n";
  111. }
  112. }
  113. echo "</select>\n";
  114. echo "</div>\n";
  115. echo "</form>\n";
  116. echo "<br>\n";
  117. //stream the file
  118. if (is_uuid($extension_uuid)) {
  119. $html_link = "scsc:?username=". $username . "@" . $_SESSION['domain_name'] . ":". $_SESSION['provision']['sessiontalk_provider_id']['text']."%26password=".$field['api_key'];
  120. $html_link = html_entity_decode( $html_link, ENT_QUOTES, 'UTF-8' );
  121. //Windows 10
  122. echo "<div class='action_bar' id='action_bar_2'>\n";
  123. echo " <div class='heading'><b>".$text['header-windows_10']."</b></div>\n";
  124. echo " <div style='clear: both;'></div>\n";
  125. echo "</div>\n";
  126. echo "<div>\n";
  127. echo " ".$text['description-step_1']."\n";
  128. echo " <a href='ms-appinstaller:?source=https://windows-softphone.s3.eu-west-2.amazonaws.com/sessioncloud.appinstaller&activationUri=".$html_link."'>".$text['description-windows_10']."</a>\n";
  129. echo " <br/>\n";
  130. echo " <br/>\n";
  131. echo " ".$text['description-step_2']."<a href='".PROJECT_PATH."/app/sessiontalk/sessiontalk_directory.php'>".$text['description-windows_10_directory']."</a>\n";
  132. echo "</div>\n";
  133. echo "<br>\n";
  134. echo "<br>\n";
  135. //Mobile
  136. echo "<div class='action_bar' id='action_bar'>\n";
  137. echo " <div class='heading'><b>".$text['header-mobile']."</b></div>\n";
  138. echo " <div style='clear: both;'></div>\n";
  139. echo "</div>\n";
  140. echo "<div>\n";
  141. echo " ".$text['description-step_1_mobile']."\n";
  142. echo " <br>\n";
  143. echo " <br>\n";
  144. echo " ".$text['description-step_2_mobile']."\n";
  145. echo "</div>\n";
  146. require_once 'resources/qr_code/QRErrorCorrectLevel.php';
  147. require_once 'resources/qr_code/QRCode.php';
  148. require_once 'resources/qr_code/QRCodeImage.php';
  149. $qr_content = html_entity_decode( $qr_content, ENT_QUOTES, 'UTF-8' );
  150. try {
  151. $code = new QRCode (- 1, QRErrorCorrectLevel::H);
  152. $code->addData($qr_content);
  153. $code->make();
  154. $img = new QRCodeImage ($code, $width=420, $height=420, $quality=50);
  155. $img->draw();
  156. $image = $img->getImage();
  157. $img->finish();
  158. }
  159. catch (Exception $error) {
  160. echo $error;
  161. }
  162. }
  163. //html image
  164. if (is_uuid($extension_uuid)) {
  165. echo "<img src=\"data:image/jpeg;base64,".base64_encode($image)."\" style='margin-top: 30px; padding: 5px; background: white; max-width: 100%;'>\n";
  166. }
  167. //add the footer
  168. require_once "resources/footer.php";
  169. ?>