provision.php 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. Copyright (C) 2008-2023 All Rights Reserved.
  17. Contributor(s):
  18. Mark J Crane <[email protected]>
  19. KonradSC <[email protected]>
  20. */
  21. //includes files
  22. require_once dirname(__DIR__, 2) . "/resources/require.php";
  23. $session_password = $_REQUEST['password'];
  24. if (strlen($session_password) > 0) {
  25. unset($_REQUEST['password']);
  26. header("Location: provision.php?username=".$_REQUEST['username']."&key=".$session_password."&deviceId=".$_REQUEST['deviceId']);
  27. exit;
  28. }
  29. //check permissions
  30. require_once "resources/check_auth.php";
  31. if (permission_exists('sessiontalk_view')) {
  32. //access granted
  33. }
  34. else {
  35. echo "access denied";
  36. exit;
  37. }
  38. //add multi-lingual support
  39. $language = new text;
  40. $text = $language->get();
  41. $transport = $_SESSION['provision']['sessiontalk_transport']['text'];
  42. $srtp = $_SESSION['provision']['sessiontalk_srtp']['text'];
  43. $username_part = explode('@', $_GET['username']);
  44. $extension = $username_part[0];
  45. $domain_name = $username_part[1];
  46. $domain_part = explode('.', $domain_name);
  47. $sub_domain = $domain_part[0];
  48. $sql = "SELECT distinct extension, display_name, effective_caller_id_name, outbound_caller_id_number, v_extensions.password ";
  49. $sql .= " FROM v_extension_users, v_extensions, v_users,v_device_lines AS l, v_devices AS d ";
  50. $sql .= " WHERE ((l.user_id = extension) ";
  51. $sql .= " AND (v_users.user_uuid = v_extension_users.user_uuid) ";
  52. $sql .= " AND (v_extensions.extension_uuid = v_extension_users.extension_uuid) ";
  53. $sql .= " AND (v_extensions.domain_uuid = :domain_uuid) ";
  54. $sql .= " AND (l.user_id=extension) ";
  55. $sql .= " AND (l.device_uuid = d.device_uuid) ";
  56. $sql .= " AND (v_users.user_uuid = :user_uuid) ";
  57. $sql .= " AND (d.domain_uuid = :domain_uuid)) ";
  58. $sql .= " ORDER BY extension asc";
  59. $parameters['domain_uuid'] = $_SESSION["domain_uuid"];
  60. $parameters['user_uuid'] = $_SESSION['user_uuid'];
  61. $database = new database;
  62. $row = $database->select($sql, $parameters, 'row');
  63. $account_array['sipusername'] = $row['extension'];
  64. $account_array['sippassword'] = $row['password'];
  65. $account_array['subdomain'] = $sub_domain;
  66. $account_array['authusername'] = $row['extension'];
  67. $account_array['transport'] = $transport;
  68. $account_array['srtp'] = $srtp;
  69. $account_array['messaging'] = "Disabled";
  70. $account_array['video'] = "Disabled";
  71. $account_array['callrecording'] = "Disabled";
  72. $settings['update'] = "false";
  73. $settings['errmsg'] = "Contact Support";
  74. $settings['sipaccounts'][0] = $account_array;
  75. header('Content-Type: application/json');
  76. print_r(json_encode($settings));
  77. ?>