From cbd974a89e7114fbcfa389f4860e3d13f1be1634 Mon Sep 17 00:00:00 2001 From: Mark Crane Date: Fri, 24 Apr 2015 20:55:53 +0000 Subject: [PATCH] Move app/xmpp as an optional application in dev/apps. --- app/xmpp/README | 3 - app/xmpp/app_config.php | 148 ---------- app/xmpp/app_languages.php | 483 --------------------------------- app/xmpp/app_menu.php | 16 -- app/xmpp/client_template.php | 53 ---- app/xmpp/db_create.php | 51 ---- app/xmpp/errors.php | 28 -- app/xmpp/profile_delete.php | 95 ------- app/xmpp/profile_edit.php | 277 ------------------- app/xmpp/profile_list.php | 70 ----- app/xmpp/root.php | 50 ---- app/xmpp/update_complete.php | 10 - app/xmpp/xmpp.php | 100 ------- app/xmpp/xmpp_profile_edit.php | 244 ----------------- 14 files changed, 1628 deletions(-) delete mode 100644 app/xmpp/README delete mode 100644 app/xmpp/app_config.php delete mode 100644 app/xmpp/app_languages.php delete mode 100644 app/xmpp/app_menu.php delete mode 100644 app/xmpp/client_template.php delete mode 100644 app/xmpp/db_create.php delete mode 100644 app/xmpp/errors.php delete mode 100644 app/xmpp/profile_delete.php delete mode 100644 app/xmpp/profile_edit.php delete mode 100644 app/xmpp/profile_list.php delete mode 100644 app/xmpp/root.php delete mode 100644 app/xmpp/update_complete.php delete mode 100644 app/xmpp/xmpp.php delete mode 100644 app/xmpp/xmpp_profile_edit.php diff --git a/app/xmpp/README b/app/xmpp/README deleted file mode 100644 index c8629b0513..0000000000 --- a/app/xmpp/README +++ /dev/null @@ -1,3 +0,0 @@ -This Module brought to you by the Letters Ken Rice - -See the Wiki for more information. diff --git a/app/xmpp/app_config.php b/app/xmpp/app_config.php deleted file mode 100644 index 8702dce4aa..0000000000 --- a/app/xmpp/app_config.php +++ /dev/null @@ -1,148 +0,0 @@ - \ No newline at end of file diff --git a/app/xmpp/app_languages.php b/app/xmpp/app_languages.php deleted file mode 100644 index 1c4f4194ff..0000000000 --- a/app/xmpp/app_languages.php +++ /dev/null @@ -1,483 +0,0 @@ - \ No newline at end of file diff --git a/app/xmpp/app_menu.php b/app/xmpp/app_menu.php deleted file mode 100644 index 2d52f2c3a7..0000000000 --- a/app/xmpp/app_menu.php +++ /dev/null @@ -1,16 +0,0 @@ - \ No newline at end of file diff --git a/app/xmpp/client_template.php b/app/xmpp/client_template.php deleted file mode 100644 index 1e5427938a..0000000000 --- a/app/xmpp/client_template.php +++ /dev/null @@ -1,53 +0,0 @@ - - Portions created by the Initial Developer are Copyright (C) 2008-2012 - the Initial Developer. All Rights Reserved. - - Contributor(s): - Ken Rice - Mark J Crane -*/ -function make_xmpp_xml($input) { - $xml_out .= "\n"; - $xml_out .= " \n"; - $xml_out .= sprintf(" \n", $input['profile_name']); - $xml_out .= sprintf(" \n", $input['profile_username']); - $xml_out .= sprintf(" \n", $input['profile_password']); - $xml_out .= sprintf(" \n", $input['dialplan']); - $xml_out .= sprintf(" \n", $input['context']); - $xml_out .= " \n"; - $xml_out .= sprintf(" \n", $input['rtp_ip']); - $xml_out .= sprintf(" \n", $input['ext_rtp_ip']); - $xml_out .= sprintf(" \n", $input['auto_login']); - $xml_out .= sprintf(" \n", $input['sasl_type']); - $xml_out .= sprintf(" \n", $input['xmpp_server']); - $xml_out .= sprintf(" \n", $input['tls_enable']); - $xml_out .= sprintf(" \n", $input['use_rtp_timer']); - $xml_out .= sprintf(" \n", $input['default_exten']); - $xml_out .= sprintf(" \n", $input['vad']); - $xml_out .= sprintf(" \n", $input['candidate_acl']); - $xml_out .= sprintf(" \n", $input['local_network_acl']); - $xml_out .= " \n"; - $xml_out .= "\n"; - - return $xml_out; -} - -?> \ No newline at end of file diff --git a/app/xmpp/db_create.php b/app/xmpp/db_create.php deleted file mode 100644 index d2bb5f24ff..0000000000 --- a/app/xmpp/db_create.php +++ /dev/null @@ -1,51 +0,0 @@ - - Portions created by the Initial Developer are Copyright (C) 2008-2012 - the Initial Developer. All Rights Reserved. - - Contributor(s): - Ken Rice - Mark J Crane -*/ -function sql_tables($db_type) { - $x = 0; - - include "app_config.php"; - $sql = ""; - - foreach ($apps[$x]['db'] as $new_db) { - $sql .= "CREATE TABLE " . $new_db['table'] . " (\n"; - $fcount = 0; - foreach ($new_db['fields'] as $field) { - if ($fcount > 0 ) { $sql .= ",\n"; } - $sql .= $field['name'] . " "; - if (is_array($field['type'])) { - $sql .= $field['type'][$db_type]; - } else { - $sql .= $field['type']; - } - $fcount++; - } - $sql .= ");\n\n"; - } - - return $sql; -} -?> diff --git a/app/xmpp/errors.php b/app/xmpp/errors.php deleted file mode 100644 index 9891c2df6b..0000000000 --- a/app/xmpp/errors.php +++ /dev/null @@ -1,28 +0,0 @@ - - Portions created by the Initial Developer are Copyright (C) 2008-2012 - the Initial Developer. All Rights Reserved. - - Contributor(s): - Ken Rice - Mark J Crane -*/ -echo "
".$error."
\n"; -?> diff --git a/app/xmpp/profile_delete.php b/app/xmpp/profile_delete.php deleted file mode 100644 index 0310e65824..0000000000 --- a/app/xmpp/profile_delete.php +++ /dev/null @@ -1,95 +0,0 @@ - - Portions created by the Initial Developer are Copyright (C) 2008-2012 - the Initial Developer. All Rights Reserved. - - Contributor(s): - Ken Rice - Mark J Crane -*/ -include "root.php"; -require_once "resources/require.php"; -require_once "resources/check_auth.php"; -if (permission_exists('xmpp_delete')) { - //access granted -} -else { - echo "access denied"; - exit; -} - -//add multi-lingual support - $language = new text; - $text = $language->get(); - - -$domain_name = $_SESSION['domains'][$domain_uuid]['domain_name']; - -$profile_id = $_REQUEST['id']; - -$sql = ""; -$sql .= "select * from v_xmpp "; -$sql .= "where domain_uuid = '$domain_uuid' "; -$sql .= "and xmpp_profile_uuid = '$profile_id' "; -$prep_statement = $db->prepare(check_sql($sql)); -$prep_statement->execute(); - -$x = 0; -$result = $prep_statement->fetchAll(PDO::FETCH_NAMED); -foreach ($result as &$row) { - $profiles_array[$x] = $row; - $x++; -} - -$profile = $profiles_array[0]; -unset ($prep_statement); - -$sql = "delete from v_xmpp "; -$sql .= "where domain_uuid = '$domain_uuid' "; -$sql .= "and xmpp_profile_uuid = '$profile_id' "; -$db->exec(check_sql($sql)); - -$filename = $_SESSION['switch']['conf']['dir'] . "/jingle_profiles/" . "v_" . $domain_name . "_" . - preg_replace("/[^A-Za-z0-9]/", "", $profile['profile_name']) . "_" . $profile_id . ".xml"; - -unlink($filename); - -$fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']); -if ($fp) { - //reload the XML Configs - $tmp_cmd = 'api reloadxml'; - $response = event_socket_request($fp, $tmp_cmd); - unset($tmp_cmd); - - //tell mod_dingaling to reload is config - $tmp_cmd = 'api dingaling reload'; - $response = event_socket_request($fp, $tmp_cmd); - unset($tmp_cmd); - - //close the connection - fclose($fp); -} - -$action = "delete"; - -include "update_complete.php"; - -?> diff --git a/app/xmpp/profile_edit.php b/app/xmpp/profile_edit.php deleted file mode 100644 index df4350e6e2..0000000000 --- a/app/xmpp/profile_edit.php +++ /dev/null @@ -1,277 +0,0 @@ - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - -
- - -
-
- '> - '> -
-
-
-
-
- : - - -
- -
- : - - -
- -
- : - - -
- -
- : - - -
- -
- : - - -
- -
- : - - -
- -
-
- - - - - -
  - -
-
- -
- : - - -
- -
- : - - '> -
- -
- '> -
- '> -
-

-
diff --git a/app/xmpp/profile_list.php b/app/xmpp/profile_list.php deleted file mode 100644 index 1b9f885691..0000000000 --- a/app/xmpp/profile_list.php +++ /dev/null @@ -1,70 +0,0 @@ - - - - -

- -
-
- - - - - - - - - - - - > - - - - - - - - - - - -
- - '> - -
- '> -      - ' alt=''>' onclick="return confirm('')" alt=''> -
- - '> - -
-

\ No newline at end of file diff --git a/app/xmpp/root.php b/app/xmpp/root.php deleted file mode 100644 index 3d662fd043..0000000000 --- a/app/xmpp/root.php +++ /dev/null @@ -1,50 +0,0 @@ - - Portions created by the Initial Developer are Copyright (C) 2008-2012 - the Initial Developer. All Rights Reserved. - - Contributor(s): - Mark J Crane -*/ - -// make sure the PATH_SEPARATOR is defined - if (!defined("PATH_SEPARATOR")) { - if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } - } - -// make sure the document_root is set - $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); - //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; - //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; - //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; - -// if the project directory exists then add it to the include path otherwise add the document root to the include path - if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); - } - else { - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); - } - -?> diff --git a/app/xmpp/update_complete.php b/app/xmpp/update_complete.php deleted file mode 100644 index 6ffc3aa778..0000000000 --- a/app/xmpp/update_complete.php +++ /dev/null @@ -1,10 +0,0 @@ - \ No newline at end of file diff --git a/app/xmpp/xmpp.php b/app/xmpp/xmpp.php deleted file mode 100644 index 366c9d3077..0000000000 --- a/app/xmpp/xmpp.php +++ /dev/null @@ -1,100 +0,0 @@ - - Portions created by the Initial Developer are Copyright (C) 2008-2012 - the Initial Developer. All Rights Reserved. - - Contributor(s): - Ken Rice - Mark J Crane -*/ -include "root.php"; -require_once "resources/require.php"; -require_once "resources/check_auth.php"; -if (permission_exists('xmpp_view')) { - //access granted -} -else { - echo "access denied"; - exit; -} - -//add multi-lingual support - $language = new text; - $text = $language->get(); - - -require_once "resources/header.php"; -$document['title'] = $text['title-xmpp']; - -require_once "resources/paging.php"; - -//connect to event socket -$fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']); -if ($fp) { - if (strlen($_GET["a"]) > 0) { - if ($_GET["a"] == "reload") { - $cmd = 'api dingaling reload'; - $response = trim(event_socket_request($fp, $cmd)); - $msg = 'Reload:
'.$response.'
'; - } - } -} - -if (!function_exists('switch_dingaling_status')) { - function switch_dingaling_status($fp, $profile_username, $result_type = 'xml') { - $fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']); - $cmd = 'api dingaling status'; - $response = trim(event_socket_request($fp, $cmd)); - $response = explode("\n", $response); - $x = 0; - foreach ($response as $row) { - if ($x > 1) { - $dingaling = explode("|", $row); - if ($profile_username == trim($dingaling[0])) { - return trim($dingaling[1]); - } - } - $x++; - } - } -} - -//get a list of the xmpp accounts -$sql = "select * from v_xmpp "; -$sql .= "where domain_uuid = '$domain_uuid' "; -$prep_statement = $db->prepare(check_sql($sql)); -$prep_statement->execute(); -$x = 0; -$result = $prep_statement->fetchAll(PDO::FETCH_NAMED); -foreach ($result as &$row) { - $profiles_array[$x] = $row; - $profiles_array[$x]['status'] = switch_dingaling_status($fp, $row['username'].'/talk'); - $x++; -} -unset ($prep_statement); - -//include the view -include "profile_list.php"; - -//include the footer -require_once "resources/footer.php"; - -?> \ No newline at end of file diff --git a/app/xmpp/xmpp_profile_edit.php b/app/xmpp/xmpp_profile_edit.php deleted file mode 100644 index a2192ec623..0000000000 --- a/app/xmpp/xmpp_profile_edit.php +++ /dev/null @@ -1,244 +0,0 @@ - - Portions created by the Initial Developer are Copyright (C) 2008-2012 - the Initial Developer. All Rights Reserved. - - Contributor(s): - Ken Rice - Mark J Crane - Luis Daniel Lucio Quiroz -*/ - -include "root.php"; -require_once "resources/require.php"; -require_once "resources/check_auth.php"; - -if (permission_exists('xmpp_add') || permission_exists('xmpp_edit')) { - //access granted -} -else { - echo "access denied"; - exit; -} - -//add multi-lingual support - $language = new text; - $text = $language->get(); - -//add or update the database -if (isset($_REQUEST["id"])) { - $action = "update"; - $profile_id = check_str($_REQUEST["id"]); -} else { - $action = "add"; -} - -if ($action == "update") { - $document['title'] = $text['title-xmpp-edit']; -} -else if ($action == "add") { - $document['title'] = $text['title-xmpp-add']; -} - -$domain_name = $_SESSION['domains'][$_SESSION['domain_uuid']]['domain_name']; - -if ($action == "update") { - $sql = ""; - $sql .= "select * from v_xmpp "; - $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; - $sql .= "and xmpp_profile_uuid = '$profile_id' "; - $prep_statement = $db->prepare(check_sql($sql)); - $prep_statement->execute(); - - $x = 0; - $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); - foreach ($result as &$row) { - $profiles_array[$x] = $row; - $x++; - } - - $profile = $profiles_array[0]; - unset ($prep_statement); - $profile['profile_username'] = $profile['username']; - $profile['profile_password'] = $profile['password']; -} else { - $profile['dialplan'] = "XML"; - $profile['context'] = $_SESSION['domain_name']; - $profile['rtp_ip'] = '$${local_ip_v4}'; - $profile['ext_rtp_ip'] = '$${external_rtp_ip}'; - $profile['auto_login'] = "true"; - $profile['sasl_type'] = "md5"; - $profile['tls_enable'] = "true"; - $profile['use_rtp_timer'] = "true"; - $profile['vad'] = "none"; - $profile['candidate_acl'] = "wan.auto"; - $profile['local_network_acl'] = "localnet.auto"; -} - -if ((!isset($_REQUEST['submit'])) || ($_REQUEST['submit'] != $text['button-save'])) { - // If we arent saving a Profile Display the form. - require_once "resources/header.php"; - include "profile_edit.php"; - require_once "resources/footer.php"; - exit; -} - -foreach ($_REQUEST as $field => $data){ - $request[$field] = check_str($data); -} - - -// check the data -$error = ""; -if (strlen($request['profile_name']) < 1) $error .= $text['message-required'].$text['label-profile_name']."
\n"; -if (strlen($request['profile_username']) < 1) $error .= $text['message-required'].$text['label-username']."
\n"; -if (strlen($request['profile_password']) < 1) $error .= $text['message-required'].$text['label-password']."
\n"; -if (strlen($request['default_exten']) < 1) $error .= $text['message-required'].$text['label-default_exten']."
\n"; -if (strlen($error) > 0) { - include "errors.php"; - $profile = $request; - require_once "resources/header.php"; - include "profile_edit.php"; - require_once "resources/footer.php"; - exit; -} - -// Save New Entry -if ($action == "add" && permission_exists('xmpp_add')) { - $xmpp_profile_uuid = uuid(); - $sql = ""; - $sql .= "insert into v_xmpp ("; - $sql .= "domain_uuid, "; - $sql .= "xmpp_profile_uuid, "; - $sql .= "profile_name, "; - $sql .= "username, "; - $sql .= "password, "; - $sql .= "dialplan, "; - $sql .= "context, "; - $sql .= "rtp_ip, "; - $sql .= "ext_rtp_ip, "; - $sql .= "auto_login, "; - $sql .= "sasl_type, "; - $sql .= "xmpp_server, "; - $sql .= "tls_enable, "; - $sql .= "use_rtp_timer, "; - $sql .= "default_exten, "; - $sql .= "vad, "; - $sql .= "avatar, "; - $sql .= "candidate_acl, "; - $sql .= "local_network_acl, "; - $sql .= "description, "; - $sql .= "enabled "; - $sql .= ") values ("; - $sql .= "'" . $_SESSION['domain_uuid'] . "', "; - $sql .= "'" . $xmpp_profile_uuid . "', "; - $sql .= "'" . $request['profile_name'] . "', "; - $sql .= "'" . $request['profile_username'] . "', "; - $sql .= "'" . $request['profile_password'] . "', "; - $sql .= "'" . $request['dialplan'] . "', "; - if (if_group("superadmin") && $request['context']) { - $sql .= "'" . $request['context'] . "', "; - } - else { - $sql .= "'" . $_SESSION['context'] . "', "; - } - $sql .= "'" . $request['rtp_ip'] . "', "; - $sql .= "'" . $request['ext_rtp_ip'] . "', "; - $sql .= "'" . $request['auto_login'] . "', "; - $sql .= "'" . $request['sasl_type'] . "', "; - $sql .= "'" . $request['xmpp_server'] . "', "; - $sql .= "'" . $request['tls_enable'] . "', "; - $sql .= "'" . $request['use_rtp_timer'] . "', "; - $sql .= "'" . $request['default_exten'] . "', "; - $sql .= "'" . $request['vad'] . "', "; - $sql .= "'" . $request['avatar'] . "', "; - $sql .= "'" . $request['candidate_acl'] . "', "; - $sql .= "'" . $request['local_network_acl'] . "', "; - $sql .= "'" . $request['description'] . "', "; - $sql .= "'" . $request['enabled'] . "' "; - $sql .= ") "; - $db->exec(check_sql($sql)); - -} -elseif ($action == "update" && permission_exists('xmpp_edit')) { - $sql = ""; - $sql .= "UPDATE v_xmpp SET "; - $sql .= "profile_name = '" . $request['profile_name'] . "', "; - $sql .= "username = '" . $request['profile_username'] . "', "; - $sql .= "password = '" . $request['profile_password'] . "', "; - $sql .= "dialplan = '" . $request['dialplan'] . "', "; - if (if_group("superadmin") && $request['context']) { - $sql .= "context = '" . $request['context'] . "', "; - } - else { - $sql .= "context = '" . $_SESSION["context"] . "', "; - } - $sql .= "rtp_ip = '" . $request['rtp_ip'] . "', "; - $sql .= "ext_rtp_ip = '" . $request['ext_rtp_ip'] . "', "; - $sql .= "auto_login = '" . $request['auto_login'] . "', "; - $sql .= "sasl_type = '" . $request['sasl_type'] . "', "; - $sql .= "xmpp_server = '" . $request['xmpp_server'] . "', "; - $sql .= "tls_enable = '" . $request['tls_enable'] . "', "; - $sql .= "use_rtp_timer = '" . $request['use_rtp_timer'] . "', "; - $sql .= "default_exten = '" . $request['default_exten'] . "', "; - $sql .= "vad = '" . $request['vad'] . "', "; - $sql .= "avatar = '" . $request['avatar'] . "', "; - $sql .= "candidate_acl = '" . $request['candidate_acl'] . "', "; - $sql .= "local_network_acl = '" . $request['local_network_acl'] . "', "; - $sql .= "description = '" . $request['description'] . "', "; - $sql .= "enabled = '" . $request['enabled'] . "' "; - $sql .= "where xmpp_profile_uuid = '" . $request['id'] . "' "; - $db->exec(check_sql($sql)); - $xmpp_profile_uuid = $request['id']; -} - -if ($request['enabled'] == "true") { - //prepare the xml - include "client_template.php"; - $xml = make_xmpp_xml($request); - - //write the xml - $filename = $_SESSION['switch']['conf']['dir'] . "/jingle_profiles/" . "v_" . $_SESSION['domain_name'] . "_" . preg_replace("/[^A-Za-z0-9]/", "", $request['profile_name']) . "_" . $xmpp_profile_uuid . ".xml"; - $fh = fopen($filename,"w") or die("Unable to open the file"); - fwrite($fh, $xml); - unset($file_name); - fclose($fh); -} - -$fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']); -if ($fp) { - //reload the XML Configs - $tmp_cmd = 'api reloadxml'; - $response = event_socket_request($fp, $tmp_cmd); - unset($tmp_cmd); - - //Tell mod_dingaling to reload is config - $tmp_cmd = 'api dingaling reload'; - $response = event_socket_request($fp, $tmp_cmd); - unset($tmp_cmd); - - //close the connection - fclose($fp); -} - -include "update_complete.php"; - -?>