v_php_service_delete.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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_delete')) {
  25. //access granted
  26. }
  27. else {
  28. echo "access denied";
  29. exit;
  30. }
  31. if (count($_GET)>0) {
  32. $id = check_str($_GET["id"]);
  33. }
  34. if (strlen($id)>0) {
  35. $sql = "";
  36. $sql .= "select * from v_php_services ";
  37. $sql .= "where domain_uuid = '$domain_uuid' ";
  38. $sql .= "and php_service_uuid = '$id' ";
  39. $prep_statement = $db->prepare(check_sql($sql));
  40. $prep_statement->execute();
  41. $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
  42. foreach ($result as &$row) {
  43. $service_name = $row["service_name"];
  44. $tmp_service_name = str_replace(" ", "_", $service_name);
  45. break; //limit to 1 row
  46. }
  47. unset ($prep_statement, $result, $row);
  48. //delete the php service file
  49. unlink($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/secure/php_service_'.$tmp_service_name.'.php');
  50. //delete the start up script
  51. unlink($startup_script_dir.'/php_service_'.$tmp_service_name.'.sh');
  52. //delete the pid file
  53. unlink($tmp_dir.'/php_service_'.$tmp_service_name.'.pid');
  54. $sql = "";
  55. $sql .= "delete from v_php_services ";
  56. $sql .= "where domain_uuid = '$domain_uuid' ";
  57. $sql .= "and php_service_uuid = '$id' ";
  58. $prep_statement = $db->prepare(check_sql($sql));
  59. $prep_statement->execute();
  60. unset($sql);
  61. }
  62. require_once "resources/header.php";
  63. echo "<meta http-equiv=\"refresh\" content=\"2;url=v_php_service.php\">\n";
  64. echo "<div align='center'>\n";
  65. echo "Delete Complete\n";
  66. echo "</div>\n";
  67. require_once "resources/footer.php";
  68. return;
  69. ?>