profile_delete.php 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <?php
  2. /* $Id$ */
  3. /*
  4. FusionPBX
  5. Version: MPL 1.1
  6. The contents of this file are subject to the Mozilla Public License Version
  7. 1.1 (the "License"); you may not use this file except in compliance with
  8. the License. You may obtain a copy of the License at
  9. http://www.mozilla.org/MPL/
  10. Software distributed under the License is distributed on an "AS IS" basis,
  11. WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  12. for the specific language governing rights and limitations under the
  13. License.
  14. The Original Code is FusionPBX
  15. The Initial Developer of the Original Code is
  16. Mark J Crane <[email protected]>
  17. Portions created by the Initial Developer are Copyright (C) 2008-2012
  18. the Initial Developer. All Rights Reserved.
  19. Contributor(s):
  20. Ken Rice <[email protected]>
  21. Mark J Crane <[email protected]>
  22. */
  23. include "root.php";
  24. require_once "resources/require.php";
  25. require_once "resources/check_auth.php";
  26. if (permission_exists('xmpp_delete')) {
  27. //access granted
  28. }
  29. else {
  30. echo "access denied";
  31. exit;
  32. }
  33. //add multi-lingual support
  34. $language = new text;
  35. $text = $language->get();
  36. $domain_name = $_SESSION['domains'][$domain_uuid]['domain_name'];
  37. $profile_id = $_REQUEST['id'];
  38. $sql = "";
  39. $sql .= "select * from v_xmpp ";
  40. $sql .= "where domain_uuid = '$domain_uuid' ";
  41. $sql .= "and xmpp_profile_uuid = '$profile_id' ";
  42. $prep_statement = $db->prepare(check_sql($sql));
  43. $prep_statement->execute();
  44. $x = 0;
  45. $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
  46. foreach ($result as &$row) {
  47. $profiles_array[$x] = $row;
  48. $x++;
  49. }
  50. $profile = $profiles_array[0];
  51. unset ($prep_statement);
  52. $sql = "delete from v_xmpp ";
  53. $sql .= "where domain_uuid = '$domain_uuid' ";
  54. $sql .= "and xmpp_profile_uuid = '$profile_id' ";
  55. $db->exec(check_sql($sql));
  56. $filename = $_SESSION['switch']['conf']['dir'] . "/jingle_profiles/" . "v_" . $domain_name . "_" .
  57. preg_replace("/[^A-Za-z0-9]/", "", $profile['profile_name']) . "_" . $profile_id . ".xml";
  58. unlink($filename);
  59. $fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);
  60. if ($fp) {
  61. //reload the XML Configs
  62. $tmp_cmd = 'api reloadxml';
  63. $response = event_socket_request($fp, $tmp_cmd);
  64. unset($tmp_cmd);
  65. //tell mod_dingaling to reload is config
  66. $tmp_cmd = 'api dingaling reload';
  67. $response = event_socket_request($fp, $tmp_cmd);
  68. unset($tmp_cmd);
  69. //close the connection
  70. fclose($fp);
  71. }
  72. $action = "delete";
  73. include "update_complete.php";
  74. ?>