provision.php 3.3 KB

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