v_php_service.php 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  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 (permission_exists('php_service_view')) {
  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. /*
  34. function pkg_is_service_running($servicename)
  35. {
  36. exec("/bin/ps ax | awk '{ print $5 }'", $psout);
  37. array_shift($psout);
  38. foreach($psout as $line) {
  39. $ps[] = trim(array_pop(explode(' ', array_pop(explode('/', $line)))));
  40. }
  41. if(is_service_running($servicename, $ps) or is_process_running($servicename) ) {
  42. return true;
  43. }
  44. else {
  45. return false;
  46. }
  47. }
  48. */
  49. $order_by = $_GET["order_by"];
  50. $order = $_GET["order"];
  51. //show the content
  52. echo "<div align='center'>";
  53. echo "<table width='100%' border='0' cellpadding='0' cellspacing='2'>\n";
  54. echo "<tr class='border'>\n";
  55. echo " <td align=\"center\">\n";
  56. echo " <br>";
  57. echo "<table width='100%' border='0'>\n";
  58. echo "<tr>\n";
  59. echo "<td width='50%' nowrap='nowrap' align='left'><b>PHP Service</b></td>\n";
  60. echo "<td width='50%'>&nbsp;</td>\n";
  61. echo "</tr>\n";
  62. echo "<tr>\n";
  63. echo "<td colspan='2' align='left'>\n";
  64. echo "Manages multiple dynamic and customizable services. There are many possible uses including alerts, ssh access control, scheduling commands to run, and many others uses that are yet to be discovered.<br /><br />\n";
  65. echo "</td>\n";
  66. echo "</tr>\n";
  67. echo "</tr></table>\n";
  68. $sql = "";
  69. $sql .= " select * from v_php_services ";
  70. $sql .= " where domain_uuid = '$domain_uuid' ";
  71. if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; }
  72. $prep_statement = $db->prepare(check_sql($sql));
  73. $prep_statement->execute();
  74. $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
  75. $num_rows = count($result);
  76. unset ($prep_statement, $result, $sql);
  77. $rows_per_page = 10;
  78. $param = "";
  79. $page = $_GET['page'];
  80. if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; }
  81. list($paging_controls, $rows_per_page, $var_3) = paging($num_rows, $param, $rows_per_page);
  82. $offset = $rows_per_page * $page;
  83. $sql = "";
  84. $sql .= " select * from v_php_services ";
  85. $sql .= " where domain_uuid = '$domain_uuid' ";
  86. if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; }
  87. $sql .= " limit $rows_per_page offset $offset ";
  88. $prep_statement = $db->prepare(check_sql($sql));
  89. $prep_statement->execute();
  90. $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
  91. $result_count = count($result);
  92. unset ($prep_statement, $sql);
  93. $c = 0;
  94. $row_style["0"] = "row_style0";
  95. $row_style["1"] = "row_style1";
  96. echo "<div align='center'>\n";
  97. echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
  98. echo "<tr>\n";
  99. echo th_order_by('service_name', 'Name', $order_by, $order);
  100. //echo th_order_by('service_group', 'Group', $order_by, $order);
  101. echo th_order_by('service_enabled', 'Enabled', $order_by, $order);
  102. echo th_order_by('service_description', 'Description', $order_by, $order);
  103. echo "<td align='right' width='42'>\n";
  104. if (permission_exists('php_service_add')) {
  105. echo " <a href='v_php_service_edit.php' alt='add'>$v_link_label_add</a>\n";
  106. }
  107. echo "</td>\n";
  108. echo "<tr>\n";
  109. if ($result_count == 0) {
  110. //no results
  111. }
  112. else { //received results
  113. foreach($result as $row) {
  114. echo "<tr >\n";
  115. echo " <td valign='top' class='".$row_style[$c]."'>".$row[service_name]."</td>\n";
  116. //echo " <td valign='top' class='".$row_style[$c]."'>".$row[service_group]."</td>\n";
  117. echo " <td valign='top' class='".$row_style[$c]."'>".$row[service_enabled]."</td>\n";
  118. echo " <td valign='top' class='row_stylebg'>".$row[service_description]."&nbsp;</td>\n";
  119. echo " <td valign='top' align='right'>\n";
  120. if (permission_exists('php_service_edit')) {
  121. echo " <a href='v_php_service_edit.php?id=".$row[php_service_uuid]."' alt='edit'>$v_link_label_edit</a>\n";
  122. }
  123. if (permission_exists('php_service_delete')) {
  124. echo " <a href='v_php_service_delete.php?id=".$row[php_service_uuid]."' alt='delete' onclick=\"return confirm('Do you really want to delete this?')\">$v_link_label_delete</a>\n";
  125. }
  126. echo " </td>\n";
  127. echo "</tr>\n";
  128. if ($c==0) { $c=1; } else { $c=0; }
  129. } //end foreach
  130. unset($sql, $result, $row_count);
  131. } //end if results
  132. echo "<tr>\n";
  133. echo "<td colspan='5' align='left'>\n";
  134. echo " <table width='100%' cellpadding='0' cellspacing='0'>\n";
  135. echo " <tr>\n";
  136. echo " <td width='33.3%' nowrap>&nbsp;</td>\n";
  137. echo " <td width='33.3%' align='center' nowrap>$paging_controls</td>\n";
  138. echo " <td width='33.3%' align='right'>\n";
  139. if (permission_exists('php_service_add')) {
  140. echo " <a href='v_php_service_edit.php' alt='add'>$v_link_label_add</a>\n";
  141. }
  142. echo " </td>\n";
  143. echo " </tr>\n";
  144. echo " </table>\n";
  145. echo "</td>\n";
  146. echo "</tr>\n";
  147. echo "</table>";
  148. echo "</div>";
  149. echo "<br><br>";
  150. echo "<br><br>";
  151. echo "</td>";
  152. echo "</tr>";
  153. echo "</table>";
  154. echo "</div>";
  155. echo "<br><br>";
  156. //show the footer
  157. require_once "resources/footer.php";
  158. ?>