servers.php 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  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-2012
  17. the Initial Developer. All Rights Reserved.
  18. Contributor(s):
  19. Mark J Crane <[email protected]>
  20. */
  21. require_once "root.php";
  22. require_once "resources/require.php";
  23. require_once "resources/check_auth.php";
  24. if (if_group("admin") || if_group("superadmin")) {
  25. //access granted
  26. }
  27. else {
  28. echo "access denied";
  29. exit;
  30. }
  31. require_once "resources/header.php";
  32. require_once "resources/paging.php";
  33. //get variables used to control the order
  34. $order_by = $_GET["order_by"];
  35. $order = $_GET["order"];
  36. //show the content
  37. echo "<div align='center'>";
  38. echo "<table width='100%' border='0' cellpadding='0' cellspacing='2'>\n";
  39. echo "<tr class='border'>\n";
  40. echo " <td align=\"center\">\n";
  41. echo " <br />";
  42. echo "<table width='100%' border='0'>\n";
  43. echo " <tr>\n";
  44. echo " <td width='50%' nowrap><b>Servers</b></td>\n";
  45. echo " <td width='50%' align='right'>&nbsp;</td>\n";
  46. echo " </tr>\n";
  47. echo " <tr>\n";
  48. echo " <td colspan='2'>\n";
  49. echo " Servers Settings<br /><br />\n";
  50. echo " </td>\n";
  51. echo " </tr>\n";
  52. echo "</table>\n";
  53. //prepare to page the results
  54. $sql = " select count(*) as num_rows from v_servers ";
  55. $sql .= " where domain_uuid = '$domain_uuid' ";
  56. if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; }
  57. $prep_statement = $db->prepare($sql);
  58. if ($prep_statement) {
  59. $prep_statement->execute();
  60. $row = $prep_statement->fetch(PDO::FETCH_ASSOC);
  61. if ($row['num_rows'] > 0) {
  62. $num_rows = $row['num_rows'];
  63. }
  64. else {
  65. $num_rows = '0';
  66. }
  67. }
  68. //prepare to page the results
  69. $rows_per_page = 10;
  70. $param = "";
  71. $page = $_GET['page'];
  72. if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; }
  73. list($paging_controls, $rows_per_page, $var3) = paging($num_rows, $param, $rows_per_page);
  74. $offset = $rows_per_page * $page;
  75. //get the list
  76. $sql = "select * from v_servers ";
  77. $sql .= "where domain_uuid = '$domain_uuid' ";
  78. if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; }
  79. $sql .= "limit $rows_per_page offset $offset ";
  80. $prep_statement = $db->prepare(check_sql($sql));
  81. $prep_statement->execute();
  82. $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
  83. $result_count = count($result);
  84. unset ($prep_statement, $sql);
  85. $c = 0;
  86. $row_style["0"] = "row_style0";
  87. $row_style["1"] = "row_style1";
  88. echo "<div align='center'>\n";
  89. echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
  90. echo "<tr>\n";
  91. echo th_order_by('server_name', 'Server Name', $order_by, $order);
  92. echo th_order_by('server_description', 'Description', $order_by, $order);
  93. echo "<td align='right' width='42'>\n";
  94. echo " <a href='servers_edit.php' alt='add'>$v_link_label_add</a>\n";
  95. echo "</td>\n";
  96. echo "<tr>\n";
  97. if ($result_count > 0) {
  98. foreach($result as $row) {
  99. //print_r( $row );
  100. echo "<tr >\n";
  101. echo " <td valign='top' class='".$row_style[$c]."'>".$row['server_name']."&nbsp;</td>\n";
  102. echo " <td valign='top' class='".$row_style[$c]."'>".$row['server_description']."&nbsp;</td>\n";
  103. echo " <td valign='top' align='right'>\n";
  104. echo " <a href='servers_edit.php?id=".$row[server_uuid]."' alt='edit'>$v_link_label_edit</a>\n";
  105. echo " <a href='servers_delete.php?id=".$row[server_uuid]."' alt='delete' onclick=\"return confirm('Do you really want to delete this?')\">$v_link_label_delete</a>\n";
  106. echo " </td>\n";
  107. echo "</tr>\n";
  108. if ($c==0) { $c=1; } else { $c=0; }
  109. } //end foreach
  110. unset($sql, $result, $row_count);
  111. } //end if results
  112. echo "<tr>\n";
  113. echo "<td colspan='3' align='left'>\n";
  114. echo " <table width='100%' cellpadding='0' cellspacing='0'>\n";
  115. echo " <tr>\n";
  116. echo " <td width='33.3%' nowrap>&nbsp;</td>\n";
  117. echo " <td width='33.3%' align='center' nowrap>$paging_controls</td>\n";
  118. echo " <td width='33.3%' align='right'>\n";
  119. echo " <a href='servers_edit.php' alt='add'>$v_link_label_add</a>\n";
  120. echo " </td>\n";
  121. echo " </tr>\n";
  122. echo " </table>\n";
  123. echo "</td>\n";
  124. echo "</tr>\n";
  125. echo "</table>";
  126. echo "</div>";
  127. echo "<br /><br />";
  128. echo "<br /><br />";
  129. echo "</td>";
  130. echo "</tr>";
  131. echo "</table>";
  132. echo "</div>";
  133. echo "<br /><br />";
  134. //include the footer
  135. require_once "resources/footer.php";
  136. ?>