provider_setup.php 5.5 KB

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