provider_setup.php 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  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) 2023-2025
  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/check_auth.php";
  24. //check permissions
  25. if (!permission_exists('provider_add')) {
  26. echo "access denied";
  27. exit;
  28. }
  29. //add multi-lingual support
  30. $language = new text;
  31. $text = $language->get();
  32. //connect to the database
  33. $database = database::new();
  34. //get the provider
  35. if (isset($_GET['id'])) {
  36. //get the provider id
  37. $id = $_GET['id'];
  38. //add the provider
  39. $provider = new providers;
  40. $provider->id = $id;
  41. $provider->setup();
  42. //set the add message
  43. message::add($text['message-add']);
  44. //redirect the user
  45. header("Location: providers.php");
  46. return;
  47. }
  48. //provider selection
  49. $provider_list = glob($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/app/*/resources/providers/settings.php");
  50. foreach ($provider_list as $setting_path) {
  51. include($setting_path);
  52. }
  53. //installed providers
  54. $sql = "select provider_uuid from v_providers ";
  55. $database_providers = $database->select($sql, null, 'all');
  56. //loop through installed providers
  57. $x = 0;
  58. foreach ($array['providers'] as $row) {
  59. foreach ($database_providers as $field) {
  60. if ($row['provider_uuid'] == $field['provider_uuid']) {
  61. $array['providers'][$x]['provider_installed'] = 'true';
  62. }
  63. }
  64. $x++;
  65. }
  66. unset($sql);
  67. //include header
  68. $document['title'] = $text['title-providers'];
  69. require_once "resources/header.php";
  70. //show the content
  71. echo "<div class='action_bar' id='action_bar'>\n";
  72. echo " <div class='heading'><b>".$text['title-providers']."</b></div>\n";
  73. echo " <div class='actions'>\n";
  74. echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$settings->get('theme','button_icon_back'),'id'=>'btn_back','link'=>'providers.php'.(!empty($page) && is_numeric($page) ? '?page='.$page : null)]);
  75. echo " </div>\n";
  76. echo " <div style='clear: both;'></div>\n";
  77. echo "</div>\n";
  78. //providers
  79. echo "<div class='card'>\n";
  80. foreach ($array['providers'] as $row) {
  81. echo "<div class='row'>\n";
  82. echo " <div class='col-sm-4' style='padding-top: 0px;'>\n";
  83. echo " <br><br>\n";
  84. if (file_exists($_SERVER["PROJECT_ROOT"]."/app/providers/resources/images/".$row['provider_name'].".png")) {
  85. echo " <a href='".$row['provider_website']."' target='_blank'>\n";
  86. echo " <img src='/app/providers/resources/images/".$row['provider_name'].".png' style='width: 200px;' class='center-block img-responsive'><br>\n";
  87. echo " </a>\n";
  88. }
  89. else {
  90. echo " <h2>".$row['provider_name']."</h2>\n";
  91. }
  92. echo " </div>\n";
  93. echo " <div class='col-sm-8' style='padding-top: 0px;'>\n";
  94. echo " <br><br>\n";
  95. echo " <strong>".escape($text['label-features'] ?? '')."</strong><br>\n";
  96. echo " ".escape($row['provider_description'] ?? '')."\n";
  97. echo " <br><br>\n";
  98. echo " <strong>".$text['label-region']."</strong><br>\n";
  99. echo " ".escape($row['provider_region'] ?? '')."\n";
  100. echo " <br><br>\n";
  101. //echo " <strong>".$text['label-about']."</strong><br>\n";
  102. //echo " ".$row['provider_about']."\n";
  103. //echo " <br><br>\n";
  104. if (isset($row['provider_website']) && strlen($row['provider_website']) > 0) {
  105. echo " <a href='".$row['provider_website']."' target='_blank'><button type=\"button\" class=\"btn btn-success\">".$text['button-website']."</button></a>\n";
  106. }
  107. //echo " <a href='http://skye.tel/fusion-pricing' target='_blank'><button type=\"button\" class=\"btn btn-success\">".$text['button-pricing']."</button></a>\n";
  108. if (isset($row['provider_signup']) && strlen($row['provider_signup']) > 0) {
  109. echo " <a href='".$row['provider_signup']."' target='_blank'><button type=\"button\" class=\"btn btn-primary\">".$text['button-signup']."</button></a>\n";
  110. }
  111. if (!empty($row['provider_installed']) && $row['provider_installed'] == 'true') {
  112. echo " <a href=\"#\" onclick=\"\"><button type=\"button\" class=\"btn btn-success\">".$text['label-installed']."</button></a>\n";
  113. //echo " <a href=\"provider_delete.php?provider_uuid=".$row['provider_uuid']."\" onclick=\"return confirm(".$text['confirm-delete'].")\"><button type=\"button\" class=\"btn btn-danger\">".$text['button-remove']."</button></a>\n";
  114. }
  115. else {
  116. echo " <a href=\"provider_setup.php?id=".md5($row['provider_name'])."\" onclick=\"return confirm(".$text['confirm-setup'].")\"><button type=\"button\" class=\"btn btn-success\">".$text['button-setup']."</button></a>\n";
  117. //echo " <button type=\"button\" onclick=\"window.location='provider_setup.php?provider=skyetel'\" class=\"btn btn-primary\">".$text['button-setup']."</button>\n";
  118. }
  119. echo " </div>\n";
  120. echo "</div>\n";
  121. echo "<div style='clear: both;'></div>\n";
  122. echo "<br/><br/><hr /><br/>\n";
  123. }
  124. echo "</div>\n";
  125. echo "<br><br>\n";
  126. echo "<hr>\n";
  127. echo "<br>\n";
  128. //include the footer
  129. require_once "resources/footer.php";