index.php 6.9 KB

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