xmpp.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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_view')) {
  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. require_once "resources/header.php";
  37. $document['title'] = $text['title-xmpp'];
  38. require_once "resources/paging.php";
  39. //connect to event socket
  40. $fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);
  41. if ($fp) {
  42. if (strlen($_GET["a"]) > 0) {
  43. if ($_GET["a"] == "reload") {
  44. $cmd = 'api dingaling reload';
  45. $response = trim(event_socket_request($fp, $cmd));
  46. $msg = '<strong>Reload:</strong><pre>'.$response.'</pre>';
  47. }
  48. }
  49. }
  50. if (!function_exists('switch_dingaling_status')) {
  51. function switch_dingaling_status($fp, $profile_username, $result_type = 'xml') {
  52. $fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);
  53. $cmd = 'api dingaling status';
  54. $response = trim(event_socket_request($fp, $cmd));
  55. $response = explode("\n", $response);
  56. $x = 0;
  57. foreach ($response as $row) {
  58. if ($x > 1) {
  59. $dingaling = explode("|", $row);
  60. if ($profile_username == trim($dingaling[0])) {
  61. return trim($dingaling[1]);
  62. }
  63. }
  64. $x++;
  65. }
  66. }
  67. }
  68. //get a list of the xmpp accounts
  69. $sql = "select * from v_xmpp ";
  70. $sql .= "where domain_uuid = '$domain_uuid' ";
  71. $prep_statement = $db->prepare(check_sql($sql));
  72. $prep_statement->execute();
  73. $x = 0;
  74. $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
  75. foreach ($result as &$row) {
  76. $profiles_array[$x] = $row;
  77. $profiles_array[$x]['status'] = switch_dingaling_status($fp, $row['username'].'/talk');
  78. $x++;
  79. }
  80. unset ($prep_statement);
  81. //include the view
  82. include "profile_list.php";
  83. //include the footer
  84. require_once "resources/footer.php";
  85. ?>