Browse Source

initial clone

master
i am da real crt yes 3 months ago
commit
5da3596a48
  1. 49
      .htaccess
  2. 11
      .project
  3. 91
      app/aastra/app_config.php
  4. 458
      app/access_controls/access_control_edit.php
  5. 249
      app/access_controls/access_controls.php
  6. 122
      app/access_controls/app_config.php
  7. 144
      app/access_controls/app_defaults.php
  8. 466
      app/access_controls/app_languages.php
  9. 30
      app/access_controls/app_menu.php
  10. 292
      app/access_controls/resources/classes/access_controls.php
  11. 90
      app/access_controls/root.php
  12. 198
      app/azure/resources/classes/azure.php
  13. 103
      app/basic_operator_panel/app_config.php
  14. 424
      app/basic_operator_panel/app_languages.php
  15. 30
      app/basic_operator_panel/app_menu.php
  16. 195
      app/basic_operator_panel/autocomplete.php
  17. 124
      app/basic_operator_panel/exec.php
  18. 599
      app/basic_operator_panel/index.php
  19. 257
      app/basic_operator_panel/resources/classes/basic_operator_panel.php
  20. 678
      app/basic_operator_panel/resources/content.php
  21. BIN
      app/basic_operator_panel/resources/images/eavesdrop.png
  22. BIN
      app/basic_operator_panel/resources/images/inbound.png
  23. BIN
      app/basic_operator_panel/resources/images/keypad_call.png
  24. BIN
      app/basic_operator_panel/resources/images/keypad_transfer.png
  25. BIN
      app/basic_operator_panel/resources/images/kill.png
  26. BIN
      app/basic_operator_panel/resources/images/outbound.png
  27. BIN
      app/basic_operator_panel/resources/images/record.png
  28. BIN
      app/basic_operator_panel/resources/images/recording.png
  29. BIN
      app/basic_operator_panel/resources/images/refresh_active.gif
  30. BIN
      app/basic_operator_panel/resources/images/refresh_paused.png
  31. BIN
      app/basic_operator_panel/resources/images/status_available.png
  32. BIN
      app/basic_operator_panel/resources/images/status_available_on_demand.png
  33. BIN
      app/basic_operator_panel/resources/images/status_do_not_disturb.png
  34. BIN
      app/basic_operator_panel/resources/images/status_logged_out.png
  35. BIN
      app/basic_operator_panel/resources/images/status_on_break.png
  36. 90
      app/basic_operator_panel/resources/root.php
  37. 90
      app/basic_operator_panel/root.php
  38. 97
      app/bridges/app_config.php
  39. 257
      app/bridges/app_languages.php
  40. 21
      app/bridges/app_menu.php
  41. 261
      app/bridges/bridge_edit.php
  42. 265
      app/bridges/bridges.php
  43. 270
      app/bridges/resources/classes/bridges.php
  44. 90
      app/bridges/root.php
  45. 170
      app/call_block/app_config.php
  46. 51
      app/call_block/app_defaults.php
  47. 965
      app/call_block/app_languages.php
  48. 33
      app/call_block/app_menu.php
  49. 335
      app/call_block/call_block.php
  50. 730
      app/call_block/call_block_edit.php
  51. 436
      app/call_block/resources/classes/call_block.php
  52. 90
      app/call_block/root.php
  53. 194
      app/call_broadcast/app_config.php
  54. 824
      app/call_broadcast/app_languages.php
  55. 31
      app/call_broadcast/app_menu.php
  56. 251
      app/call_broadcast/call_broadcast.php
  57. 700
      app/call_broadcast/call_broadcast_edit.php
  58. 252
      app/call_broadcast/call_broadcast_send.php
  59. 64
      app/call_broadcast/call_broadcast_stop.php
  60. 167
      app/call_broadcast/resources/classes/call_broadcast.php
  61. 90
      app/call_broadcast/root.php
  62. 3
      app/call_broadcast/sample.csv
  63. 44
      app/call_center_active/app_config.php
  64. 865
      app/call_center_active/app_languages.php
  65. 31
      app/call_center_active/app_menu.php
  66. 152
      app/call_center_active/call_center_active.php
  67. 389
      app/call_center_active/call_center_active_inc.php
  68. 148
      app/call_center_active/call_center_exec.php
  69. 160
      app/call_center_active/call_center_queue.php
  70. 90
      app/call_center_active/root.php
  71. 500
      app/call_centers/app_config.php
  72. 178
      app/call_centers/app_defaults.php
  73. 3050
      app/call_centers/app_languages.php
  74. 58
      app/call_centers/app_menu.php
  75. 624
      app/call_centers/call_center_agent_edit.php
  76. 431
      app/call_centers/call_center_agent_status.php
  77. 274
      app/call_centers/call_center_agents.php
  78. 1324
      app/call_centers/call_center_queue_edit.php
  79. 287
      app/call_centers/call_center_queues.php
  80. 89
      app/call_centers/cmd.php
  81. 640
      app/call_centers/resources/classes/call_center.php
  82. 209
      app/call_centers/resources/dashboard/call_center_agents.php
  83. 14
      app/call_centers/resources/dashboard/config.php
  84. 90
      app/call_centers/root.php
  85. 201
      app/call_flows/app_config.php
  86. 38
      app/call_flows/app_defaults.php
  87. 739
      app/call_flows/app_languages.php
  88. 31
      app/call_flows/app_menu.php
  89. 732
      app/call_flows/call_flow_edit.php
  90. 303
      app/call_flows/call_flows.php
  91. 425
      app/call_flows/resources/classes/call_flows.php
  92. 90
      app/call_flows/root.php
  93. 84
      app/call_forward/app_config.php
  94. 31
      app/call_forward/app_defaults.php
  95. 970
      app/call_forward/app_languages.php
  96. 33
      app/call_forward/app_menu.php
  97. 407
      app/call_forward/call_forward.php
  98. 756
      app/call_forward/call_forward_edit.php
  99. 279
      app/call_forward/resources/classes/call_forward.php
  100. 293
      app/call_forward/resources/classes/do_not_disturb.php

49
.htaccess

@ -0,0 +1,49 @@
RewriteEngine On
#REST api
RewriteRule ^(.*)/api/(.*)$ $1/api/index.php?rewrite_uri=$2 [QSA]
# $mac or $mac.cfg/xml
RewriteRule ^.*([A-Fa-f0-9]{12})(?:\.xml|\.cfg)?$ app/provision/index.php?mac=$1 [QSA]
# $m:a:c or $m:a:c.cfg/xml
RewriteRule ^.*((?:[A-Fa-f0-9]{2}[:-]){5}[A-Fa-f0-9]{2})(?:\.xml|\.cfg)?$ app/provision/index.php?mac=$1 [QSA]
# kt*-$mac.xml
RewriteRule ^kt.*?-([A-Fa-f0-9]{12})\.xml$ app/provision/index.php?mac=$1 [QSA]
# cfg-$mac.xml
RewriteRule ^.*cfg([A-Fa-f0-9]{12})\.xml$ app/provision/index.php?mac=$1 [QSA]
#Snom m3
RewriteRule ^m3/settings/([A-Fa-f0-9]{12})(?:\.cfg)?$ app/provision/index.php?mac=$1 [QSA]
#Grandstream
RewriteRule ^.*/cfg([A-Fa-f0-9]{12})(?:\.xml|\.cfg)?$ app/provision/?mac=$1 [QSA]
#Yealink and Polycom
RewriteRule ^.*/([A-Fa-f0-9]{12})(?:\.xml|\.cfg)?$ app/provision/index.php?mac=$1 [QSA]
#Polycom
RewriteRule ^provision/000000000000.cfg$ app/provision/?mac=$1&file={$mac}.cfg [QSA]
RewriteRule ^provision/features.cfg$ app/provision/?mac=$1&file=features.cfg [QSA]
RewriteRule ^provision/([A-Fa-f0-9]{12})-sip.cfg$ app/provision/?mac=$1&file=sip.cfg [QSA]
RewriteRule ^provision/([A-Fa-f0-9]{12})-phone.cfg$ app/provision/?mac=$1 [QSA]
RewriteRule ^provision/([A-Fa-f0-9]{12})-registration.cfg$ app/provision/?mac=$1&file={$mac}-registration.cfg [QSA]
RewriteRule ^provision/([A-Fa-f0-9]{12})-site.cfg$ app/provision/?mac=$1&file=site.cfg [QSA]
RewriteRule ^provision/([A-Fa-f0-9]{12})-web.cfg$ app/provision/?mac=$1&file=web.cfg [QSA]
RewriteRule ^provision/([A-Fa-f0-9]{12})-directory.xml$ app/provision/?mac=$1&file=directory.xml [QSA]
#Escene
RewriteRule ^.*/([0-9]{1,11})_Extern.xml$ app/provision/?ext=$1&file={$mac}_extern.xml [QSA]
RewriteRule ^.*/([0-9]{1,11})_Phonebook.xml$ app/provision/?ext=$1&file={$mac}_phonebook.xml [QSA]
#Aastra
RewriteRule ^provision/aastra.cfg$ app/provision/index.php?file=aastra.cfg [QSA]
Options -Indexes
#PHP settings
php_value upload_max_filesize 25M
php_value post_max_size 35M
php_value memory_limit 512M

11
.project

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>fusionbpx</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
</buildSpec>
<natures>
</natures>
</projectDescription>

91
app/aastra/app_config.php

@ -0,0 +1,91 @@
<?php
//application details
$apps[$x]['name'] = "Aastra";
$apps[$x]['uuid'] = "c3b13bbc-3015-4c09-87e8-416749b29f66";
$apps[$x]['category'] = "Vendor";
$apps[$x]['subcategory'] = "";
$apps[$x]['version'] = "1.0";
$apps[$x]['license'] = "Mozilla Public License 1.1";
$apps[$x]['url'] = "http://www.fusionpbx.com";
$apps[$x]['description']['en-us'] = "";
$apps[$x]['description']['en-gb'] = "";
$apps[$x]['description']['ar-eg'] = "";
$apps[$x]['description']['de-at'] = "";
$apps[$x]['description']['de-ch'] = "";
$apps[$x]['description']['de-de'] = "";
$apps[$x]['description']['es-cl'] = "";
$apps[$x]['description']['es-mx'] = "";
$apps[$x]['description']['fr-ca'] = "";
$apps[$x]['description']['fr-fr'] = "";
$apps[$x]['description']['he-il'] = "";
$apps[$x]['description']['it-it'] = "";
$apps[$x]['description']['nl-nl'] = "";
$apps[$x]['description']['pl-pl'] = "";
$apps[$x]['description']['pt-br'] = "";
$apps[$x]['description']['pt-pt'] = "";
$apps[$x]['description']['ro-ro'] = "";
$apps[$x]['description']['ru-ru'] = "";
$apps[$x]['description']['sv-se'] = "";
$apps[$x]['description']['uk-ua'] = "";
//default settings
$y=0;
$apps[$x]['default_settings'][$y]['default_setting_uuid'] = "c471163a-12fa-11e8-b642-0ed5f89f718b";
$apps[$x]['default_settings'][$y]['default_setting_category'] = "provision";
$apps[$x]['default_settings'][$y]['default_setting_subcategory'] = "aastra_gmt_offset";
$apps[$x]['default_settings'][$y]['default_setting_name'] = "numeric";
$apps[$x]['default_settings'][$y]['default_setting_value'] = "0";
$apps[$x]['default_settings'][$y]['default_setting_enabled'] = "true";
$apps[$x]['default_settings'][$y]['default_setting_description'] = "Aastra timezone offset in minutes (e.g. 300 = GMT-5 = Eastern Standard Time)";
$y++;
$apps[$x]['default_settings'][$y]['default_setting_uuid'] = "c47117a2-12fa-11e8-b642-0ed5f89f718b";
$apps[$x]['default_settings'][$y]['default_setting_category'] = "provision";
$apps[$x]['default_settings'][$y]['default_setting_subcategory'] = "aastra_time_format";
$apps[$x]['default_settings'][$y]['default_setting_name'] = "numeric";
$apps[$x]['default_settings'][$y]['default_setting_value'] = "0";
$apps[$x]['default_settings'][$y]['default_setting_enabled'] = "true";
$apps[$x]['default_settings'][$y]['default_setting_description'] = "Aastra clock format";
$y++;
$apps[$x]['default_settings'][$y]['default_setting_uuid'] = "c47119aa-12fa-11e8-b642-0ed5f89f718b";
$apps[$x]['default_settings'][$y]['default_setting_category'] = "provision";
$apps[$x]['default_settings'][$y]['default_setting_subcategory'] = "aastra_date_format";
$apps[$x]['default_settings'][$y]['default_setting_name'] = "numeric";
$apps[$x]['default_settings'][$y]['default_setting_value'] = "0";
$apps[$x]['default_settings'][$y]['default_setting_enabled'] = "true";
$apps[$x]['default_settings'][$y]['default_setting_description'] = "Aastra date format";
$y++;
$apps[$x]['default_settings'][$y]['default_setting_uuid'] = "b31b1423-a04c-4b4a-9c55-a0b3791642c3";
$apps[$x]['default_settings'][$y]['default_setting_category'] = "provision";
$apps[$x]['default_settings'][$y]['default_setting_subcategory'] = "aastra_ptime";
$apps[$x]['default_settings'][$y]['default_setting_name'] = "numeric";
$apps[$x]['default_settings'][$y]['default_setting_value'] = "20";
$apps[$x]['default_settings'][$y]['default_setting_enabled'] = "true";
$apps[$x]['default_settings'][$y]['default_setting_description'] = "Set Aastra ptime";
$y++;
$apps[$x]['default_settings'][$y]['default_setting_uuid'] = "8b676397-2cf7-45de-a7ec-f3ceb7d529e3";
$apps[$x]['default_settings'][$y]['default_setting_category'] = "provision";
$apps[$x]['default_settings'][$y]['default_setting_subcategory'] = "aastra_silence_suppression";
$apps[$x]['default_settings'][$y]['default_setting_name'] = "numeric";
$apps[$x]['default_settings'][$y]['default_setting_value'] = "0";
$apps[$x]['default_settings'][$y]['default_setting_enabled'] = "true";
$apps[$x]['default_settings'][$y]['default_setting_description'] = "Enable Aastra codec silence suppression (on / off)";
$y++;
$apps[$x]['default_settings'][$y]['default_setting_uuid'] = "1455b1b0-68ec-400d-be84-1d1132aea72f";
$apps[$x]['default_settings'][$y]['default_setting_category'] = "provision";
$apps[$x]['default_settings'][$y]['default_setting_subcategory'] = "aastra_zone_minutes";
$apps[$x]['default_settings'][$y]['default_setting_name'] = "numeric";
$apps[$x]['default_settings'][$y]['default_setting_value'] = "0";
$apps[$x]['default_settings'][$y]['default_setting_enabled'] = "true";
$apps[$x]['default_settings'][$y]['default_setting_description'] = "Offset in minutes from GMT, 300 = GMT-5 = Eastern Standard Time, -120 = GMT+2 = Eastern European Time";
$y++;
$apps[$x]['default_settings'][$y]['default_setting_uuid'] = "c90e804a-d2bb-431a-ace8-5c69e140c539";
$apps[$x]['default_settings'][$y]['default_setting_category'] = "provision";
$apps[$x]['default_settings'][$y]['default_setting_subcategory'] = "aastra_sip_silence_suppression";
$apps[$x]['default_settings'][$y]['default_setting_name'] = "numeric";
$apps[$x]['default_settings'][$y]['default_setting_value'] = "0";
$apps[$x]['default_settings'][$y]['default_setting_enabled'] = "true";
$apps[$x]['default_settings'][$y]['default_setting_description'] = "Aastra SIP silence suppression - silence suppression: deactivated (0), activated (1); enabled on G.711 with CN(RFC3389) or G.729AB";
$y++;
?>

458
app/access_controls/access_control_edit.php

@ -0,0 +1,458 @@
<?php
/*
FusionPBX
Version: MPL 1.1
The contents of this file are subject to the Mozilla Public License Version
1.1 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the
License.
The Original Code is FusionPBX
The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2018 - 2022
the Initial Developer. All Rights Reserved.
*/
//includes
require_once "root.php";
require_once "resources/require.php";
require_once "resources/check_auth.php";
//check permissions
if (permission_exists('access_control_add') || permission_exists('access_control_edit')) {
//access granted
}
else {
echo "access denied";
exit;
}
//add multi-lingual support
$language = new text;
$text = $language->get();
//action add or update
if (is_uuid($_REQUEST["id"])) {
$action = "update";
$access_control_uuid = $_REQUEST["id"];
$id = $_REQUEST["id"];
}
else {
$action = "add";
}
//get http post variables and set them to php variables
if (is_array($_POST) && @sizeof($_POST) != 0) {
$access_control_name = $_POST["access_control_name"];
$access_control_default = $_POST["access_control_default"];
$access_control_nodes = $_POST["access_control_nodes"];
$access_control_description = $_POST["access_control_description"];
}
//process the user data and save it to the database
if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
//enforce valid data
if ($access_control_name == 'providers' || $access_control_name == 'domains') {
$access_control_default = 'deny';
}
if ($access_control_default != 'allow' && $access_control_default != 'deny') {
$access_control_default = 'deny';
}
//validate the token
$token = new token;
if (!$token->validate($_SERVER['PHP_SELF'])) {
message::add($text['message-invalid_token'],'negative');
header('Location: access_controls.php');
exit;
}
//process the http post data by submitted action
if ($_POST['action'] != '' && strlen($_POST['action']) > 0) {
//prepare the array(s)
$x = 0;
foreach ($_POST['access_control_nodes'] as $row) {
if (is_uuid($row['access_control_uuid']) && $row['checked'] === 'true') {
$array['access_controls'][$x]['checked'] = $row['checked'];
$array['access_controls'][$x]['access_control_nodes'][]['access_control_node_uuid'] = $row['access_control_node_uuid'];
$x++;
}
}
//send the array to the database class
switch ($_POST['action']) {
case 'copy':
if (permission_exists('access_control_add')) {
$obj = new database;
$obj->copy($array);
}
break;
case 'delete':
if (permission_exists('access_control_delete')) {
$obj = new database;
$obj->delete($array);
}
break;
case 'toggle':
if (permission_exists('access_control_update')) {
$obj = new database;
$obj->toggle($array);
}
break;
}
//clear the cache, reloadacl and redirect the user
if (in_array($_POST['action'], array('copy', 'delete', 'toggle'))) {
//clear the cache
$cache = new cache;
$cache->delete("configuration:acl.conf");
//create the event socket connection
$fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);
if ($fp) {
event_socket_request($fp, "api reloadacl");
}
//redirect the user
header('Location: access_control_edit.php?id='.$id);
exit;
}
}
//check for all required data
$msg = '';
if (strlen($access_control_name) == 0) { $msg .= $text['message-required']." ".$text['label-access_control_name']."<br>\n"; }
if (strlen($access_control_default) == 0) { $msg .= $text['message-required']." ".$text['label-access_control_default']."<br>\n"; }
//if (strlen($access_control_nodes) == 0) { $msg .= $text['message-required']." ".$text['label-access_control_nodes']."<br>\n"; }
//if (strlen($access_control_description) == 0) { $msg .= $text['message-required']." ".$text['label-access_control_description']."<br>\n"; }
if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) {
require_once "resources/header.php";
require_once "resources/persist_form_var.php";
echo "<div align='center'>\n";
echo "<table><tr><td>\n";
echo $msg."<br />";
echo "</td></tr></table>\n";
persistformvar($_POST);
echo "</div>\n";
require_once "resources/footer.php";
return;
}
//add the access_control_uuid
if (!is_uuid($_POST["access_control_uuid"])) {
$access_control_uuid = uuid();
}
//prepare the array
$array['access_controls'][0]['access_control_uuid'] = $access_control_uuid;
$array['access_controls'][0]['access_control_name'] = $access_control_name;
$array['access_controls'][0]['access_control_default'] = $access_control_default;
$array['access_controls'][0]['access_control_description'] = $access_control_description;
$y = 0;
if (is_array($access_control_nodes)) {
foreach ($access_control_nodes as $row) {
//validate the data
if (!is_uuid($row["access_control_node_uuid"])) { continue; }
if ($row["node_type"] != 'allow' && $row["node_type"] != 'deny') { continue; }
if (isset($row["node_cidr"]) && $row["node_cidr"] != '') {
$cidr_array = explode("/", str_replace("\\", "/", $row["node_cidr"]));
if (filter_var($cidr_array[0], FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) {
if (isset($cidr_array[1]) && is_numeric($cidr_array[1])) {
//valid IPv4 address and cidr notation
$node_cidr = $row["node_cidr"];
}
else {
//valid IPv4 address add the missing cidr notation
$node_cidr = $row["node_cidr"].'/32';
}
}
elseif(filter_var($cidr_array[0], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
//valid IPv6 address
$node_cidr = $row["node_cidr"];
}
//if the cidr is provided ignore the domain.
$row["node_domain"] = '';
}
//build the sub array
$array['access_controls'][0]['access_control_nodes'][$y]['access_control_node_uuid'] = $row["access_control_node_uuid"];
$array['access_controls'][0]['access_control_nodes'][$y]['node_type'] = $row["node_type"];
$array['access_controls'][0]['access_control_nodes'][$y]['node_cidr'] = $node_cidr;
$array['access_controls'][0]['access_control_nodes'][$y]['node_domain'] = $row["node_domain"];
$array['access_controls'][0]['access_control_nodes'][$y]['node_description'] = $row["node_description"];
$y++;
//unset values
unset($cidr_array, $node_cidr);
}
}
//save the data
if (is_array($array)) {
$database = new database;
$database->app_name = 'access controls';
$database->app_uuid = '1416a250-f6e1-4edc-91a6-5c9b883638fd';
$database->save($array);
}
//clear the cache
$cache = new cache;
$cache->delete("configuration:acl.conf");
//create the event socket connection
$fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);
if ($fp) {
event_socket_request($fp, "api reloadacl");
}
//redirect the user
if (isset($action)) {
if ($action == "add") {
$_SESSION["message"] = $text['message-add'];
}
if ($action == "update") {
$_SESSION["message"] = $text['message-update'];
}
//header('Location: access_controls.php');
header('Location: access_control_edit.php?id='.urlencode($access_control_uuid));
return;
}
}
//pre-populate the form
if (is_array($_GET) && $_POST["persistformvar"] != "true") {
$sql = "select * from v_access_controls ";
$sql .= "where access_control_uuid = :access_control_uuid ";
$parameters['access_control_uuid'] = $access_control_uuid;
$database = new database;
$row = $database->select($sql, $parameters, 'row');
if (is_array($row) && @sizeof($row) != 0) {
$access_control_name = $row["access_control_name"];
$access_control_default = $row["access_control_default"];
$access_control_description = $row["access_control_description"];
}
unset($sql, $parameters, $row);
}
//get the child data
if (is_uuid($access_control_uuid)) {
$sql = "select * from v_access_control_nodes ";
$sql .= "where access_control_uuid = :access_control_uuid ";
$sql .= "order by node_cidr asc";
$parameters['access_control_uuid'] = $access_control_uuid;
$database = new database;
$access_control_nodes = $database->select($sql, $parameters, 'all');
unset ($sql, $parameters);
}
//add the $access_control_node_uuid
if (!is_uuid($access_control_node_uuid)) {
$access_control_node_uuid = uuid();
}
//add an empty row
if (is_array($access_control_nodes) && @sizeof($access_control_nodes) != 0) {
$x = count($access_control_nodes);
}
else {
$access_control_nodes = array();
$x = 0;
}
$access_control_nodes[$x]['access_control_uuid'] = $access_control_uuid;
$access_control_nodes[$x]['access_control_node_uuid'] = uuid();
$access_control_nodes[$x]['node_type'] = '';
$access_control_nodes[$x]['node_cidr'] = '';
$access_control_nodes[$x]['node_domain'] = '';
$access_control_nodes[$x]['node_description'] = '';
//create token
$object = new token;
$token = $object->create($_SERVER['PHP_SELF']);
//show the header
$document['title'] = $text['title-access_control'];
require_once "resources/header.php";
//show the content
echo "<form name='frm' id='frm' method='post'>\n";
echo "<input class='formfld' type='hidden' name='access_control_uuid' value='".escape($access_control_uuid)."'>\n";
echo "<div class='action_bar' id='action_bar'>\n";
echo " <div class='heading'><b>".$text['title-access_control']."</b></div>\n";
echo " <div class='actions'>\n";
echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'id'=>'btn_back','collapse'=>'hide-xs','style'=>'margin-right: 15px;','link'=>'access_controls.php']);
if ($action == 'update') {
if (permission_exists('access_control_node_add')) {
echo button::create(['type'=>'button','label'=>$text['button-copy'],'icon'=>$_SESSION['theme']['button_icon_copy'],'id'=>'btn_copy','name'=>'btn_copy','style'=>'display: none;','onclick'=>"modal_open('modal-copy','btn_copy');"]);
}
if (permission_exists('access_control_node_delete')) {
echo button::create(['type'=>'button','label'=>$text['button-delete'],'icon'=>$_SESSION['theme']['button_icon_delete'],'id'=>'btn_delete','name'=>'btn_delete','style'=>'display: none; margin-right: 15px;','onclick'=>"modal_open('modal-delete','btn_delete');"]);
}
}
echo button::create(['type'=>'submit','label'=>$text['button-save'],'icon'=>$_SESSION['theme']['button_icon_save'],'id'=>'btn_save','collapse'=>'hide-xs']);
echo " </div>\n";
echo " <div style='clear: both;'></div>\n";
echo "</div>\n";
echo $text['title_description-access_controls']."\n";
echo "<br /><br />\n";
if ($action == 'update') {
if (permission_exists('access_control_add')) {
echo modal::create(['id'=>'modal-copy','type'=>'copy','actions'=>button::create(['type'=>'submit','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_copy','style'=>'float: right; margin-left: 15px;','collapse'=>'never','name'=>'action','value'=>'copy','onclick'=>"modal_close();"])]);
}
if (permission_exists('access_control_delete')) {
echo modal::create(['id'=>'modal-delete','type'=>'delete','actions'=>button::create(['type'=>'submit','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_delete','style'=>'float: right; margin-left: 15px;','collapse'=>'never','name'=>'action','value'=>'delete','onclick'=>"modal_close();"])]);
}
}
if ($action == 'update') {
if (permission_exists('access_control_add')) {
echo modal::create(['id'=>'modal-copy','type'=>'copy','actions'=>button::create(['type'=>'submit','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_copy','style'=>'float: right; margin-left: 15px;','collapse'=>'never','name'=>'action','value'=>'copy','onclick'=>"modal_close();"])]);
}
if (permission_exists('access_control_delete')) {
echo modal::create(['id'=>'modal-delete','type'=>'delete','actions'=>button::create(['type'=>'submit','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_delete','style'=>'float: right; margin-left: 15px;','collapse'=>'never','name'=>'action','value'=>'delete','onclick'=>"modal_close();"])]);
}
}
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo "<tr>\n";
echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-access_control_name']."\n";
echo "</td>\n";
echo "<td class='vtable' style='position: relative;' align='left'>\n";
echo " <input class='formfld' type='text' name='access_control_name' maxlength='255' value='".escape($access_control_name)."'>\n";
echo "<br />\n";
echo $text['description-access_control_name']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-access_control_default']."\n";
echo "</td>\n";
echo "<td class='vtable' style='position: relative;' align='left'>\n";
echo " <select class='formfld' name='access_control_default'>\n";
echo " <option value=''></option>\n";
if ($access_control_default == "allow") {
echo " <option value='allow' selected='selected'>".$text['label-allow']."</option>\n";
}
else {
echo " <option value='allow'>".$text['label-allow']."</option>\n";
}
if ($access_control_default == "deny") {
echo " <option value='deny' selected='selected'>".$text['label-deny']."</option>\n";
}
else {
echo " <option value='deny'>".$text['label-deny']."</option>\n";
}
echo " </select>\n";
echo "<br />\n";
echo $text['description-access_control_default']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-access_control_nodes']."\n";
echo "</td>\n";
echo "<td class='vtable' style='position: relative;' align='left'>\n";
echo " <table>\n";
echo " <tr>\n";
echo " <th class='vtablereq'>".$text['label-node_type']."</th>\n";
echo " <td class='vtable'>".$text['label-node_cidr']."</td>\n";
echo " <td class='vtable'>".$text['label-node_domain']."</td>\n";
echo " <td class='vtable'>".$text['label-node_description']."</td>\n";
if (is_array($access_control_nodes) && @sizeof($access_control_nodes) > 1 && permission_exists('access_control_node_delete')) {
echo " <td class='vtable edit_delete_checkbox_all' onmouseover=\"swap_display('delete_label_details', 'delete_toggle_details');\" onmouseout=\"swap_display('delete_label_details', 'delete_toggle_details');\">\n";
echo " <span id='delete_label_details'>".$text['label-action']."</span>\n";
echo " <span id='delete_toggle_details'><input type='checkbox' id='checkbox_all_details' name='checkbox_all' onclick=\"edit_all_toggle('details'); checkbox_on_change(this);\"></span>\n";
echo " </td>\n";
}
echo " </tr>\n";
$x = 0;
foreach($access_control_nodes as $row) {
echo " <tr>\n";
echo " <input type='hidden' name='access_control_nodes[$x][access_control_uuid]' value=\"".escape($row["access_control_uuid"])."\">\n";
echo " <input type='hidden' name='access_control_nodes[$x][access_control_node_uuid]' value=\"".escape($row["access_control_node_uuid"])."\">\n";
echo " <td class='formfld'>\n";
echo " <select class='formfld' name='access_control_nodes[$x][node_type]'>\n";
echo " <option value=''></option>\n";
if ($row['node_type'] == "allow") {
echo " <option value='allow' selected='selected'>".$text['label-allow']."</option>\n";
}
else {
echo " <option value='allow'>".$text['label-allow']."</option>\n";
}
if ($row['node_type'] == "deny") {
echo " <option value='deny' selected='selected'>".$text['label-deny']."</option>\n";
}
else {
echo " <option value='deny'>".$text['label-deny']."</option>\n";
}
echo " </select>\n";
echo " </td>\n";
echo " <td class='formfld'>\n";
echo " <input class='formfld' type='text' name='access_control_nodes[$x][node_cidr]' maxlength='255' value=\"".escape($row["node_cidr"])."\">\n";
echo " </td>\n";
echo " <td class='formfld'>\n";
echo " <input class='formfld' type='text' name='access_control_nodes[$x][node_domain]' maxlength='255' value=\"".escape($row["node_domain"])."\">\n";
echo " </td>\n";
echo " <td class='formfld'>\n";
echo " <input class='formfld' type='text' name='access_control_nodes[$x][node_description]' maxlength='255' value=\"".escape($row["node_description"])."\">\n";
echo " </td>\n";
if (is_array($access_control_nodes) && @sizeof($access_control_nodes) > 1 && permission_exists('access_control_node_delete')) {
if (is_uuid($row['access_control_node_uuid'])) {
echo " <td class='vtable' style='text-align: center; padding-bottom: 3px;'>\n";
echo " <input type='checkbox' name='access_control_nodes[".$x."][checked]' value='true' class='chk_delete checkbox_details' onclick=\"checkbox_on_change(this);\">\n";
echo " </td>\n";
}
else {
echo " <td></td>\n";
}
}
echo " </tr>\n";
$x++;
}
echo " </table>\n";
echo "<br />\n";
echo $text['description-node_description']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-access_control_description']."\n";
echo "</td>\n";
echo "<td class='vtable' style='position: relative;' align='left'>\n";
echo " <input class='formfld' type='text' name='access_control_description' maxlength='255' value='".escape($access_control_description)."'>\n";
echo "<br />\n";
echo $text['description-access_control_description']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "</table>";
echo "<br /><br />";
echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
echo "</form>";
//include the footer
require_once "resources/footer.php";
?>

249
app/access_controls/access_controls.php

@ -0,0 +1,249 @@
<?php
/*
FusionPBX
Version: MPL 1.1
The contents of this file are subject to the Mozilla Public License Version
1.1 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the
License.
The Original Code is FusionPBX
The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2018 - 2020
the Initial Developer. All Rights Reserved.
Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com>
*/
//includes
require_once "root.php";
require_once "resources/require.php";
require_once "resources/check_auth.php";
//check permissions
if (permission_exists('access_control_view')) {
//access granted
}
else {
echo "access denied";
exit;
}
//add multi-lingual support
$language = new text;
$text = $language->get();
//get the http post data
if (is_array($_POST['access_controls'])) {
$action = $_POST['action'];
$search = $_POST['search'];
$access_controls = $_POST['access_controls'];
}
//process the http post data by action
if ($action != '' && is_array($access_controls) && @sizeof($access_controls) != 0) {
//validate the token
$token = new token;
if (!$token->validate($_SERVER['PHP_SELF'])) {
message::add($text['message-invalid_token'],'negative');
header('Location: access_controls.php');
exit;
}
//prepare the array
foreach($access_controls as $row) {
$array['access_controls'][$x]['checked'] = $row['checked'];
$array['access_controls'][$x]['access_control_uuid'] = $row['access_control_uuid'];
$x++;
}
//prepare the database object
$database = new database;
$database->app_name = 'access_controls';
$database->app_uuid = '1416a250-f6e1-4edc-91a6-5c9b883638fd';
//send the array to the database class
switch ($action) {
case 'copy':
if (permission_exists('access_control_add')) {
$database->copy($array);
}
break;
case 'toggle':
if (permission_exists('access_control_edit')) {
$database->toggle($array);
}
break;
case 'delete':
if (permission_exists('access_control_delete')) {
$database->delete($array);
}
break;
}
//redirect the user
header('Location: access_controls.php'.($search != '' ? '?search='.urlencode($search) : null));
exit;
}
//get order and order by
$order_by = $_GET["order_by"];
$order = $_GET["order"];
//add the search
if (isset($_GET["search"])) {
$search = strtolower($_GET["search"]);
$parameters['search'] = '%'.$search.'%';
}
//get the count
$sql = "select count(access_control_uuid) ";
$sql .= "from v_access_controls ";
if (isset($_GET["search"])) {
$sql .= "where (";
$sql .= " lower(access_control_name) like :search ";
$sql .= " or lower(access_control_default) like :search ";
$sql .= " or lower(access_control_description) like :search ";
$sql .= ") ";
}
$database = new database;
$num_rows = $database->select($sql, $parameters, 'column');
//get the list
$sql = "select ";
$sql .= "access_control_uuid, ";
$sql .= "access_control_name, ";
$sql .= "access_control_default, ";
$sql .= "access_control_description ";
$sql .= "from v_access_controls ";
if (isset($_GET["search"])) {
$sql .= "where (";
$sql .= " lower(access_control_name) like :search ";
$sql .= " or lower(access_control_default) like :search ";
$sql .= " or lower(access_control_description) like :search ";
$sql .= ") ";
}
$sql .= order_by($order_by, $order, 'access_control_name', 'asc');
$sql .= limit_offset($rows_per_page, $offset);
$database = new database;
$access_controls = $database->select($sql, $parameters, 'all');
unset($sql, $parameters);
//create token
$object = new token;
$token = $object->create($_SERVER['PHP_SELF']);
//additional includes
$document['title'] = $text['title-access_controls'];
require_once "resources/header.php";
//show the content
echo "<div class='action_bar' id='action_bar'>\n";
echo " <div class='heading'><b>".$text['title-access_controls']." (".$num_rows.")</b></div>\n";
echo " <div class='actions'>\n";
if (permission_exists('access_control_add')) {
echo button::create(['type'=>'button','label'=>$text['button-add'],'icon'=>$_SESSION['theme']['button_icon_add'],'id'=>'btn_add','name'=>'btn_add','link'=>'access_control_edit.php']);
}
if (permission_exists('access_control_add') && $access_controls) {
echo button::create(['type'=>'button','label'=>$text['button-copy'],'icon'=>$_SESSION['theme']['button_icon_copy'],'id'=>'btn_copy','name'=>'btn_copy','style'=>'display:none;','onclick'=>"modal_open('modal-copy','btn_copy');"]);
}
if (permission_exists('access_control_delete') && $access_controls) {
echo button::create(['type'=>'button','label'=>$text['button-delete'],'icon'=>$_SESSION['theme']['button_icon_delete'],'id'=>'btn_delete','name'=>'btn_delete','style'=>'display:none;','onclick'=>"modal_open('modal-delete','btn_delete');"]);
}
echo "<form id='form_search' class='inline' method='get'>\n";
echo "<input type='text' class='txt list-search' name='search' id='search' value=\"".escape($search)."\" placeholder=\"".$text['label-search']."\" onkeydown=''>";
echo button::create(['label'=>$text['button-search'],'icon'=>$_SESSION['theme']['button_icon_search'],'type'=>'submit','id'=>'btn_search']);
//echo button::create(['label'=>$text['button-reset'],'icon'=>$_SESSION['theme']['button_icon_reset'],'type'=>'button','id'=>'btn_reset','link'=>'access_controls.php','style'=>($search == '' ? 'display: none;' : null)]);
if ($paging_controls_mini != '') {
echo "<span style='margin-left: 15px;'>".$paging_controls_mini."</span>\n";
}
echo " </form>\n";
echo " </div>\n";
echo " <div style='clear: both;'></div>\n";
echo "</div>\n";
if (permission_exists('access_control_add') && $access_controls) {
echo modal::create(['id'=>'modal-copy','type'=>'copy','actions'=>button::create(['type'=>'button','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_copy','style'=>'float: right; margin-left: 15px;','collapse'=>'never','onclick'=>"modal_close(); list_action_set('copy'); list_form_submit('form_list');"])]);
}
if (permission_exists('access_control_delete') && $access_controls) {
echo modal::create(['id'=>'modal-delete','type'=>'delete','actions'=>button::create(['type'=>'button','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_delete','style'=>'float: right; margin-left: 15px;','collapse'=>'never','onclick'=>"modal_close(); list_action_set('delete'); list_form_submit('form_list');"])]);
}
echo $text['title_description-access_controls']."\n";
echo "<br /><br />\n";
echo "<form id='form_list' method='post'>\n";
echo "<input type='hidden' id='action' name='action' value=''>\n";
echo "<input type='hidden' name='search' value=\"".escape($search)."\">\n";
echo "<table class='list'>\n";
echo "<tr class='list-header'>\n";
if (permission_exists('access_control_add') || permission_exists('access_control_edit') || permission_exists('access_control_delete')) {
echo " <th class='checkbox'>\n";
echo " <input type='checkbox' id='checkbox_all' name='checkbox_all' onclick='list_all_toggle(); checkbox_on_change(this);' ".($access_controls ?: "style='visibility: hidden;'").">\n";
echo " </th>\n";
}
echo th_order_by('access_control_name', $text['label-access_control_name'], $order_by, $order);
echo th_order_by('access_control_default', $text['label-access_control_default'], $order_by, $order);
echo " <th class='hide-sm-dn'>".$text['label-access_control_description']."</th>\n";
if (permission_exists('access_control_edit') && $_SESSION['theme']['list_row_edit_button']['boolean'] == 'true') {
echo " <td class='action-button'>&nbsp;</td>\n";
}
echo "</tr>\n";
if (is_array($access_controls) && @sizeof($access_controls) != 0) {
$x = 0;
foreach ($access_controls as $row) {
if (permission_exists('access_control_edit')) {
$list_row_url = "access_control_edit.php?id=".urlencode($row['access_control_uuid']);
}
echo "<tr class='list-row' href='".$list_row_url."'>\n";
if (permission_exists('access_control_add') || permission_exists('access_control_edit') || permission_exists('access_control_delete')) {
echo " <td class='checkbox'>\n";
echo " <input type='checkbox' name='access_controls[$x][checked]' id='checkbox_".$x."' value='true' onclick=\"checkbox_on_change(this); if (!this.checked) { document.getElementById('checkbox_all').checked = false; }\">\n";
echo " <input type='hidden' name='access_controls[$x][access_control_uuid]' value='".escape($row['access_control_uuid'])."' />\n";
echo " </td>\n";
}
echo " <td>\n";
if (permission_exists('access_control_edit')) {
echo " <a href='".$list_row_url."' title=\"".$text['button-edit']."\">".escape($row['access_control_name'])."</a>\n";
}
else {
echo " ".escape($row['access_control_name']);
}
echo " </td>\n";
echo " <td>".escape($row['access_control_default'])."</td>\n";
echo " <td class='description overflow hide-sm-dn'>".escape($row['access_control_description'])."</td>\n";
if (permission_exists('access_control_edit') && $_SESSION['theme']['list_row_edit_button']['boolean'] == 'true') {
echo " <td class='action-button'>\n";
echo button::create(['type'=>'button','title'=>$text['button-edit'],'icon'=>$_SESSION['theme']['button_icon_edit'],'link'=>$list_row_url]);
echo " </td>\n";
}
echo "</tr>\n";
$x++;
}
unset($access_controls);
}
echo "</table>\n";
echo "<br />\n";
echo "<div align='center'>".$paging_controls."</div>\n";
echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
echo "</form>\n";
//include the footer
require_once "resources/footer.php";
?>

122
app/access_controls/app_config.php

@ -0,0 +1,122 @@
<?php
//application details
$apps[$x]['name'] = "Access Controls";
$apps[$x]['uuid'] = "1416a250-f6e1-4edc-91a6-5c9b883638fd";
$apps[$x]['category'] = "";
$apps[$x]['subcategory'] = "";
$apps[$x]['version'] = "1.0";
$apps[$x]['license'] = "Mozilla Public License 1.1";
$apps[$x]['url'] = "http://www.fusionpbx.com";
$apps[$x]['description']['en-us'] = "Manage access control lists";
$apps[$x]['description']['en-gb'] = "Manage access control lists";
$apps[$x]['description']['ar-eg'] = "";
$apps[$x]['description']['de-at'] = "Zugriffssteuerungslisten verwalten";
$apps[$x]['description']['de-ch'] = "";
$apps[$x]['description']['de-de'] = "Zugriffssteuerungslisten verwalten";
$apps[$x]['description']['es-cl'] = "";
$apps[$x]['description']['es-mx'] = "";
$apps[$x]['description']['fr-ca'] = "Gérer les listes de contrôle d'accès";
$apps[$x]['description']['fr-fr'] = "Gérer les listes de contrôle d'accès";
$apps[$x]['description']['he-il'] = "";
$apps[$x]['description']['it-it'] = "";
$apps[$x]['description']['nl-nl'] = "Beheer toegangs controle lijsten";
$apps[$x]['description']['pl-pl'] = "";
$apps[$x]['description']['pt-br'] = "";
$apps[$x]['description']['pt-pt'] = "";
$apps[$x]['description']['ro-ro'] = "";
$apps[$x]['description']['ru-ru'] = "";
$apps[$x]['description']['sv-se'] = "";
$apps[$x]['description']['uk-ua'] = "";
//permission details
$y=0;
$apps[$x]['permissions'][$y]['name'] = "access_control_view";
$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
$y++;
$apps[$x]['permissions'][$y]['name'] = "access_control_add";
$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
$y++;
$apps[$x]['permissions'][$y]['name'] = "access_control_edit";
$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
$y++;
$apps[$x]['permissions'][$y]['name'] = "access_control_delete";
$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
$y++;
$apps[$x]['permissions'][$y]['name'] = "access_control_node_view";
$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
$y++;
$apps[$x]['permissions'][$y]['name'] = "access_control_node_add";
$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
$y++;
$apps[$x]['permissions'][$y]['name'] = "access_control_node_edit";
$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
$y++;
$apps[$x]['permissions'][$y]['name'] = "access_control_node_delete";
$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
$y++;
//cache details
$apps[$x]['cache']['key'] = "configuration.acl.conf";
//schema details
$y=0;
$apps[$x]['db'][$y]['table']['name'] = "v_access_controls";
$apps[$x]['db'][$y]['table']['parent'] = "";
$z=0;
$apps[$x]['db'][$y]['fields'][$z]['name'] = "access_control_uuid";
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = "uuid";
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = "text";
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = "char(36)";
$apps[$x]['db'][$y]['fields'][$z]['key']['type'] = "primary";
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = "access_control_name";
$apps[$x]['db'][$y]['fields'][$z]['type'] = "text";
$apps[$x]['db'][$y]['fields'][$z]['search'] = 'true';
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "Enter the name.";
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = "access_control_default";
$apps[$x]['db'][$y]['fields'][$z]['type'] = "text";
$apps[$x]['db'][$y]['fields'][$z]['search'] = 'true';
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "Select the default type.";
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = "access_control_description";
$apps[$x]['db'][$y]['fields'][$z]['type'] = "text";
$apps[$x]['db'][$y]['fields'][$z]['search'] = 'true';
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "Enter the description";
$y++;
$apps[$x]['db'][$y]['table']['name'] = "v_access_control_nodes";
$apps[$x]['db'][$y]['table']['parent'] = "v_access_controls";
$z=0;
$apps[$x]['db'][$y]['fields'][$z]['name'] = "access_control_node_uuid";
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = "uuid";
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = "text";
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = "char(36)";
$apps[$x]['db'][$y]['fields'][$z]['key']['type'] = "primary";
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = "access_control_uuid";
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = "uuid";
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = "text";
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = "char(36)";
$apps[$x]['db'][$y]['fields'][$z]['key']['type'] = "foreign";
$apps[$x]['db'][$y]['fields'][$z]['key']['reference']['table'] = "v_access_controls";
$apps[$x]['db'][$y]['fields'][$z]['key']['reference']['field'] = "access_control_uuid";
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = "node_type";
$apps[$x]['db'][$y]['fields'][$z]['type'] = "text";
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "Select the type.";
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = "node_cidr";
$apps[$x]['db'][$y]['fields'][$z]['type'] = "text";
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "Enter the IP CIDR range.";
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = "node_domain";
$apps[$x]['db'][$y]['fields'][$z]['type'] = "text";
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "Enter the domain.";
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = "node_description";
$apps[$x]['db'][$y]['fields'][$z]['type'] = "text";
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "Enter the description.";
?>

144
app/access_controls/app_defaults.php

@ -0,0 +1,144 @@
<?php
/*
FusionPBX
Version: MPL 1.1
The contents of this file are subject to the Mozilla Public License Version
1.1 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the
License.
The Original Code is FusionPBX
The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2016 - 2022
the Initial Developer. All Rights Reserved.
Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com>
*/
//if the number of rows is 0 then read the acl xml into the database
if ($domains_processed == 1) {
//add the access control list to the database
$sql = "select count(*) from v_access_controls ";
$database = new database;
$num_rows = $database->select($sql, null, 'column');
if ($num_rows == 0) {
//set the directory
$xml_dir = $_SESSION["switch"]["conf"]["dir"].'/autoload_configs';
$xml_file = $xml_dir."/acl.conf.xml";
$xml_file_alt = $_SERVER["DOCUMENT_ROOT"].'/'.PROJECT_PATH.'/resources/templates/conf/autoload_configs/acl.conf';
//load the xml and save it into an array
if (file_exists($xml_file)) {
$xml_string = file_get_contents($xml_file);
}
elseif (file_exists($xml_file_alt)) {
$xml_string = file_get_contents(xml_file_alt);
}
else {
$xml_string = "<configuration name=\"acl.conf\" description=\"Network Lists\">\n";
$xml_string .= " <network-lists>\n";
$xml_string .= " <list name=\"rfc1918\" default=\"deny\">\n";
$xml_string .= " <node type=\"allow\" cidr=\"10.0.0.0/8\"/>\n";
$xml_string .= " <node type=\"allow\" cidr=\"172.16.0.0/12\"/>\n";
$xml_string .= " <node type=\"allow\" cidr=\"192.168.0.0/16\"/>\n";
$xml_string .= " </list>\n";
$xml_string .= " <list name=\"providers\" default=\"deny\">\n";
//$xml_string .= " <node type=\"allow\" domain=\"".$_SESSION['domain_name']."\"/>\n";
$xml_string .= " </list>\n";
$xml_string .= " </network-lists>\n";
$xml_string .= "</configuration>\n";
}
$xml_object = simplexml_load_string($xml_string);
$json = json_encode($xml_object);
$conf_array = json_decode($json, true);
//process the array
foreach($conf_array['network-lists']['list'] as $list) {
//get the attributes
$access_control_name = $list['@attributes']['name'];
$access_control_default = $list['@attributes']['default'];
//insert the name, description
$access_control_uuid = uuid();
$array['access_controls'][0]['access_control_uuid'] = $access_control_uuid;
$array['access_controls'][0]['access_control_name'] = $access_control_name;
$array['access_controls'][0]['access_control_default'] = $access_control_default;
$p = new permissions;
$p->add('access_control_add', 'temp');
$database = new database;
$database->app_name = 'access_controls';
$database->app_uuid = '1416a250-f6e1-4edc-91a6-5c9b883638fd';
$database->save($array, false);
unset($array);
$p->delete('access_control_add', 'temp');
//normalize the array - needed because the array is inconsistent when there is only one row vs multiple
if (strlen($list['node']['@attributes']['type']) > 0) {
$list['node'][]['@attributes'] = $list['node']['@attributes'];
unset($list['node']['@attributes']);
}
//add the nodes
foreach ($list['node'] as $row) {
//get the name and value pair
$node_type = $row['@attributes']['type'];
$node_cidr = $row['@attributes']['cidr'];
$node_domain = $row['@attributes']['domain'];
$node_description = $row['@attributes']['description'];
//replace $${domain}
if (strlen($node_domain) > 0) {
$node_domain = str_replace("\$\${domain}", $domain_name, $node_domain);
}
//add the profile settings into the database
$access_control_node_uuid = uuid();
$array['access_control_nodes'][0]['access_control_node_uuid'] = $access_control_node_uuid;
$array['access_control_nodes'][0]['access_control_uuid'] = $access_control_uuid;
$array['access_control_nodes'][0]['node_type'] = $node_type;
$array['access_control_nodes'][0]['node_cidr'] = $node_cidr;
$array['access_control_nodes'][0]['node_domain'] = $node_domain;
$array['access_control_nodes'][0]['node_description'] = $node_description;
$p = new permissions;
$p->add('access_control_node_add', 'temp');
$database = new database;
$database->app_name = 'access_controls';
$database->app_uuid = '1416a250-f6e1-4edc-91a6-5c9b883638fd';
$database->save($array, false);
unset($array);
$p->delete('access_control_node_add', 'temp');
}
}
//rename the file
if (file_exists($xml_dir.'/acl.conf.xml')) {
rename($xml_dir.'/acl.conf.xml', $xml_dir.'/acl.conf');
}
}
unset($sql, $num_rows);
//remove orphaned access control nodes
$sql = "delete from v_access_control_nodes ";
$sql .= "where access_control_uuid not in ( ";
$sql .= " select access_control_uuid from v_access_controls ";
$sql .= ")";
$database = new database;
$database->execute($sql, null);
unset($sql);
}
?>

466
app/access_controls/app_languages.php

@ -0,0 +1,466 @@
<?php
#This file was last reorganized on 19th of September 2017 08:54:24 AM UTC
$text['title-access_controls']['en-us'] = "Access Controls";
$text['title-access_controls']['en-gb'] = "Access Controls";
$text['title-access_controls']['ar-eg'] = "عناصر التحكم في الوصول";
$text['title-access_controls']['de-at'] = " Zugriffskontrolle"; //copied from de-de
$text['title-access_controls']['de-ch'] = " Zugriffskontrolle"; //copied from de-de
$text['title-access_controls']['de-de'] = " Zugriffskontrolle";
$text['title-access_controls']['es-cl'] = "Controles de acceso";
$text['title-access_controls']['es-mx'] = "Controles de acceso"; //copied from es-cl
$text['title-access_controls']['fr-ca'] = "Contrôle d'accès"; //copied from fr-fr
$text['title-access_controls']['fr-fr'] = "Contrôle d'accès";
$text['title-access_controls']['he-il'] = "בקרת גישה";
$text['title-access_controls']['it-it'] = "Controllo Accessi";
$text['title-access_controls']['nl-nl'] = "Toegangs Controle";
$text['title-access_controls']['pl-pl'] = "Kontrola dostępu";
$text['title-access_controls']['pt-br'] = "Controles de Acesso"; //copied from pt-pt
$text['title-access_controls']['pt-pt'] = "Controles de Acesso";
$text['title-access_controls']['ro-ro'] = "Controale de acces";
$text['title-access_controls']['ru-ru'] = "Контроль доступа";
$text['title-access_controls']['sv-se'] = "Åtkomstkontroll";
$text['title-access_controls']['uk-ua'] = "контроль доступу";
$text['title-access_control_nodes']['en-us'] = "Nodes";
$text['title-access_control_nodes']['en-gb'] = "Nodes";
$text['title-access_control_nodes']['ar-eg'] = "العقد";
$text['title-access_control_nodes']['de-at'] = "Knoten"; //copied from de-de
$text['title-access_control_nodes']['de-ch'] = "Knoten"; //copied from de-de
$text['title-access_control_nodes']['de-de'] = "Knoten";
$text['title-access_control_nodes']['es-cl'] = "Nodos";
$text['title-access_control_nodes']['es-mx'] = "Nodos"; //copied from es-cl
$text['title-access_control_nodes']['fr-ca'] = " nœuds"; //copied from fr-fr
$text['title-access_control_nodes']['fr-fr'] = " nœuds";
$text['title-access_control_nodes']['he-il'] = "בלוטות";
$text['title-access_control_nodes']['it-it'] = "Nodi";
$text['title-access_control_nodes']['nl-nl'] = "Knooppunten";
$text['title-access_control_nodes']['pl-pl'] = "węzły";
$text['title-access_control_nodes']['pt-br'] = "Nodes";
$text['title-access_control_nodes']['pt-pt'] = " Nodes";
$text['title-access_control_nodes']['ro-ro'] = "Noduri";
$text['title-access_control_nodes']['ru-ru'] = "Узлы";
$text['title-access_control_nodes']['sv-se'] = "Noder";
$text['title-access_control_nodes']['uk-ua'] = "вузли";
$text['title-access_control_node']['en-us'] = "Node";
$text['title-access_control_node']['en-gb'] = "Node";
$text['title-access_control_node']['ar-eg'] = "العقدة";
$text['title-access_control_node']['de-at'] = "Netzknoten"; //copied from de-de
$text['title-access_control_node']['de-ch'] = "Netzknoten"; //copied from de-de
$text['title-access_control_node']['de-de'] = "Netzknoten";
$text['title-access_control_node']['es-cl'] = "Nodo";
$text['title-access_control_node']['es-mx'] = "Nodo"; //copied from es-cl
$text['title-access_control_node']['fr-ca'] = " noeud"; //copied from fr-fr
$text['title-access_control_node']['fr-fr'] = " noeud";
$text['title-access_control_node']['he-il'] = "צומת";
$text['title-access_control_node']['it-it'] = "Nodo";
$text['title-access_control_node']['nl-nl'] = "Knooppunt";
$text['title-access_control_node']['pl-pl'] = "węzeł";
$text['title-access_control_node']['pt-br'] = ""; //copied from pt-pt
$text['title-access_control_node']['pt-pt'] = "";
$text['title-access_control_node']['ro-ro'] = "Nod";
$text['title-access_control_node']['ru-ru'] = "Узел";
$text['title-access_control_node']['sv-se'] = "Nod";
$text['title-access_control_node']['uk-ua'] = "вузол";
$text['title-access_control']['en-us'] = "Access Control";
$text['title-access_control']['en-gb'] = "Access Control";
$text['title-access_control']['ar-eg'] = "التحكم في الوصول";
$text['title-access_control']['de-at'] = " Zugangskontrolle"; //copied from de-de
$text['title-access_control']['de-ch'] = " Zugangskontrolle"; //copied from de-de
$text['title-access_control']['de-de'] = " Zugangskontrolle";
$text['title-access_control']['es-cl'] = "Control de acceso";
$text['title-access_control']['es-mx'] = "Control de acceso"; //copied from es-cl
$text['title-access_control']['fr-ca'] = "Contrôle d'accès"; //copied from fr-fr
$text['title-access_control']['fr-fr'] = "Contrôle d'accès";
$text['title-access_control']['he-il'] = "בקרת גישה";
$text['title-access_control']['it-it'] = "Controllo Accesso";
$text['title-access_control']['nl-nl'] = "Toegangs Controle";
$text['title-access_control']['pl-pl'] = "Kontrola dostępu";
$text['title-access_control']['pt-br'] = "Controle de acesso"; //copied from pt-pt
$text['title-access_control']['pt-pt'] = "Controle de acesso";
$text['title-access_control']['ro-ro'] = "Controlul accesului";
$text['title-access_control']['ru-ru'] = "Управление доступом";
$text['title-access_control']['sv-se'] = "Åtkomstkontroll";
$text['title-access_control']['uk-ua'] = "Управління доступом";
$text['title_description-access_controls']['en-us'] = "Access control list can allow or deny ranges of IP addresses.";
$text['title_description-access_controls']['en-gb'] = "Access control list can allow or deny ranges of IP addresses.";
$text['title_description-access_controls']['ar-eg'] = "قائمة التحكم بالوصول يمكن السماح أو الرفض نطاقات العناوين.";
$text['title_description-access_controls']['de-at'] = " Die Zugriffskontrollliste kann Bereiche von IP Adressen zulassen oder ablehnen."; //copied from de-de
$text['title_description-access_controls']['de-ch'] = " Die Zugriffskontrollliste kann Bereiche von IP Adressen zulassen oder ablehnen."; //copied from de-de
$text['title_description-access_controls']['de-de'] = " Die Zugriffskontrollliste kann Bereiche von IP Adressen zulassen oder ablehnen.";
$text['title_description-access_controls']['es-cl'] = " Lista de control de acceso puede permitir o denegar los rangos de direcciones IP.";
$text['title_description-access_controls']['es-mx'] = " Lista de control de acceso puede permitir o denegar los rangos de direcciones IP."; //copied from es-cl
$text['title_description-access_controls']['fr-ca'] = " Liste de contrôle d'accès peut autoriser ou refuser des plages d'adresses IP."; //copied from fr-fr
$text['title_description-access_controls']['fr-fr'] = " Liste de contrôle d'accès peut autoriser ou refuser des plages d'adresses IP.";
$text['title_description-access_controls']['he-il'] = " רשימת בקרת גישה יכולה לאפשר או למנוע טווחים של כתובות IP.";
$text['title_description-access_controls']['it-it'] = "Le liste per il controllo di accesso permettono o negano l'accesso a range di IP.";
$text['title_description-access_controls']['nl-nl'] = "Toegang Controle lijst kan IP adres reeks toestaan of verbieden.";
$text['title_description-access_controls']['pl-pl'] = "Lista kontroli dostępu może umożliwić lub zablokować zakresy adresów IP.";
$text['title_description-access_controls']['pt-br'] = "Lista de controle de acesso pode permitir ou negar intervalos de endereços IP."; //copied from pt-pt
$text['title_description-access_controls']['pt-pt'] = "Lista de controle de acesso pode permitir ou negar intervalos de endereços IP.";
$text['title_description-access_controls']['ro-ro'] = "Lista de control al accesului poate permite sau refuza intervale de adrese IP.";
$text['title_description-access_controls']['ru-ru'] = "Контроль доступа может разрешить или запретить диапазоны IP адресов.";
$text['title_description-access_controls']['sv-se'] = "Åtkomstkontrollista kan tillåta eller neka intervall av IP-adresser.";
$text['title_description-access_controls']['uk-ua'] = "Список контролю доступу може дозволити або заборонити діапазони IP-адрес.";
$text['label-node_type']['en-us'] = "Type";
$text['label-node_type']['en-gb'] = "Type";
$text['label-node_type']['ar-eg'] = "اكتب";
$text['label-node_type']['de-at'] = "Art"; //copied from de-de
$text['label-node_type']['de-ch'] = "Art"; //copied from de-de
$text['label-node_type']['de-de'] = "Art";
$text['label-node_type']['es-cl'] = "Escribe";
$text['label-node_type']['es-mx'] = "Escribe"; //copied from es-cl
$text['label-node_type']['fr-ca'] = "Type"; //copied from fr-fr
$text['label-node_type']['fr-fr'] = "Type";
$text['label-node_type']['he-il'] = "סוג";
$text['label-node_type']['it-it'] = "Tipo";
$text['label-node_type']['nl-nl'] = "Type";
$text['label-node_type']['pl-pl'] = "typ";
$text['label-node_type']['pt-br'] = "Tipo"; //copied from pt-pt
$text['label-node_type']['pt-pt'] = "Tipo";
$text['label-node_type']['ro-ro'] = "Tip";
$text['label-node_type']['ru-ru'] = "Тип";
$text['label-node_type']['sv-se'] = "Typ";
$text['label-node_type']['uk-ua'] = "Тип";
$text['label-node_domain']['en-us'] = "Domain";
$text['label-node_domain']['en-gb'] = "Domain";
$text['label-node_domain']['ar-eg'] = "مجال";
$text['label-node_domain']['de-at'] = " Domäne"; //copied from de-de
$text['label-node_domain']['de-ch'] = " Domäne"; //copied from de-de
$text['label-node_domain']['de-de'] = " Domäne";
$text['label-node_domain']['es-cl'] = "Dominio";
$text['label-node_domain']['es-mx'] = "Dominio"; //copied from es-cl
$text['label-node_domain']['fr-ca'] = "Domaine"; //copied from fr-fr
$text['label-node_domain']['fr-fr'] = "Domaine";
$text['label-node_domain']['he-il'] = "תחום";
$text['label-node_domain']['it-it'] = "Dominio";
$text['label-node_domain']['nl-nl'] = "Domein";
$text['label-node_domain']['pl-pl'] = "domeny";
$text['label-node_domain']['pt-br'] = "Domínio"; //copied from pt-pt
$text['label-node_domain']['pt-pt'] = "Domínio";
$text['label-node_domain']['ro-ro'] = "Domeniu";
$text['label-node_domain']['ru-ru'] = "Домен";
$text['label-node_domain']['sv-se'] = "Domän";
$text['label-node_domain']['uk-ua'] = "домен";
$text['label-node_description']['en-us'] = "Description";
$text['label-node_description']['en-gb'] = "Description";
$text['label-node_description']['ar-eg'] = "وصف";
$text['label-node_description']['de-at'] = "Beschreibung"; //copied from de-de
$text['label-node_description']['de-ch'] = "Beschreibung"; //copied from de-de
$text['label-node_description']['de-de'] = "Beschreibung";
$text['label-node_description']['es-cl'] = "Descripción";
$text['label-node_description']['es-mx'] = "Descripción"; //copied from es-cl
$text['label-node_description']['fr-ca'] = "Description"; //copied from fr-fr
$text['label-node_description']['fr-fr'] = "Description";
$text['label-node_description']['he-il'] = "תיאור";
$text['label-node_description']['it-it'] = "Descrizione";
$text['label-node_description']['nl-nl'] = "Beschrijving";
$text['label-node_description']['pl-pl'] = "opis";
$text['label-node_description']['pt-br'] = "Descrição"; //copied from pt-pt
$text['label-node_description']['pt-pt'] = "Descrição";
$text['label-node_description']['ro-ro'] = "Descriere";
$text['label-node_description']['ru-ru'] = "Описание";
$text['label-node_description']['sv-se'] = "Beskrivning";
$text['label-node_description']['uk-ua'] = "опис";
$text['label-node_cidr']['en-us'] = "CIDR";
$text['label-node_cidr']['en-gb'] = "CIDR";
$text['label-node_cidr']['ar-eg'] = "CIDR";
$text['label-node_cidr']['de-at'] = "CIDR"; //copied from de-de
$text['label-node_cidr']['de-ch'] = "CIDR"; //copied from de-de
$text['label-node_cidr']['de-de'] = "CIDR";
$text['label-node_cidr']['es-cl'] = "CIDR";
$text['label-node_cidr']['es-mx'] = "CIDR"; //copied from es-cl
$text['label-node_cidr']['fr-ca'] = "CIDR"; //copied from fr-fr
$text['label-node_cidr']['fr-fr'] = "CIDR";
$text['label-node_cidr']['he-il'] = "CIDR";
$text['label-node_cidr']['it-it'] = "CIDR";
$text['label-node_cidr']['nl-nl'] = "CIDR";
$text['label-node_cidr']['pl-pl'] = "CIDR";
$text['label-node_cidr']['pt-br'] = "CIDR"; //copied from pt-pt
$text['label-node_cidr']['pt-pt'] = "CIDR";
$text['label-node_cidr']['ro-ro'] = "CIDR";
$text['label-node_cidr']['ru-ru'] = "CIDR";
$text['label-node_cidr']['sv-se'] = "CIDR";
$text['label-node_cidr']['uk-ua'] = "CIDR";
$text['label-deny']['en-us'] = "deny";
$text['label-deny']['en-gb'] = "deny";
$text['label-deny']['ar-eg'] = "تنكر";
$text['label-deny']['de-at'] = " verbieten"; //copied from de-de
$text['label-deny']['de-ch'] = " verbieten"; //copied from de-de
$text['label-deny']['de-de'] = " verbieten";
$text['label-deny']['es-cl'] = "Negar";
$text['label-deny']['es-mx'] = "Negar"; //copied from es-cl
$text['label-deny']['fr-ca'] = " nier"; //copied from fr-fr
$text['label-deny']['fr-fr'] = " nier";
$text['label-deny']['he-il'] = "להכחיש";