2015-08-13 07:09:07 +02:00
|
|
|
<?php
|
2018-06-04 02:02:41 +02:00
|
|
|
/*
|
|
|
|
|
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>
|
2019-09-07 02:27:51 +02:00
|
|
|
Portions created by the Initial Developer are Copyright (C) 2019
|
2018-06-04 02:02:41 +02:00
|
|
|
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";
|
2020-02-07 19:13:34 +01:00
|
|
|
require_once "resources/paging.php";
|
2018-06-04 02:02:41 +02:00
|
|
|
|
|
|
|
|
//check permissions
|
2019-07-02 01:30:03 +02:00
|
|
|
if (!permission_exists('access_control_node_view')) {
|
2019-09-07 02:27:51 +02:00
|
|
|
echo "access denied";
|
|
|
|
|
exit;
|
2018-06-04 02:02:41 +02:00
|
|
|
}
|
2015-08-13 07:09:07 +02:00
|
|
|
|
2020-02-07 19:13:34 +01:00
|
|
|
//get the http post data
|
|
|
|
|
if ($_POST['action'] != '') {
|
|
|
|
|
$action = $_POST['action'];
|
|
|
|
|
$access_control_uuid = $_POST['access_control_uuid'];
|
|
|
|
|
$access_control_nodes = $_POST['access_control_nodes'];
|
|
|
|
|
|
|
|
|
|
//process the http post data by action
|
|
|
|
|
if (is_array($access_control_nodes) && @sizeof($access_control_nodes) != 0) {
|
|
|
|
|
switch ($action) {
|
|
|
|
|
case 'delete':
|
|
|
|
|
if (permission_exists('access_control_node_delete')) {
|
|
|
|
|
$obj = new access_controls;
|
|
|
|
|
$obj->delete_nodes($access_control_nodes);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//redirect
|
|
|
|
|
header('Location: access_control_edit.php?id='.urlencode($access_control_uuid));
|
|
|
|
|
exit;
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-21 08:52:40 +01:00
|
|
|
//add multi-lingual support
|
|
|
|
|
$language = new text;
|
|
|
|
|
$text = $language->get();
|
|
|
|
|
|
2015-08-13 07:09:07 +02:00
|
|
|
//get variables used to control the order
|
2019-07-02 01:30:03 +02:00
|
|
|
$order_by = $_GET["order_by"];
|
|
|
|
|
$order = $_GET["order"];
|
2019-05-28 04:07:05 +02:00
|
|
|
|
2018-06-30 03:19:52 +02:00
|
|
|
//prepare to page the results
|
2019-07-02 01:30:03 +02:00
|
|
|
$sql = "select count(*) from v_access_control_nodes ";
|
2019-05-28 04:07:05 +02:00
|
|
|
$sql .= "where access_control_uuid = :access_control_uuid ";
|
|
|
|
|
$parameters['access_control_uuid'] = $access_control_uuid;
|
|
|
|
|
$database = new database;
|
|
|
|
|
$num_rows = $database->select($sql, $parameters, 'column');
|
2015-08-13 07:09:07 +02:00
|
|
|
|
2018-06-30 03:19:52 +02:00
|
|
|
//prepare to page the results
|
|
|
|
|
$rows_per_page = ($_SESSION['domain']['paging']['numeric'] != '') ? $_SESSION['domain']['paging']['numeric'] : 50;
|
2018-06-30 03:31:42 +02:00
|
|
|
$param = "&id=".escape($access_control_uuid);
|
2019-12-19 04:14:20 +01:00
|
|
|
if (isset($_GET['page'])) {
|
|
|
|
|
$page = $_GET['page'];
|
|
|
|
|
if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; }
|
2020-02-07 19:13:34 +01:00
|
|
|
list($paging_controls, $rows_per_page) = paging($num_rows, $param, $rows_per_page);
|
2019-12-19 04:14:20 +01:00
|
|
|
$offset = $rows_per_page * $page;
|
|
|
|
|
}
|
2018-06-30 03:19:52 +02:00
|
|
|
|
|
|
|
|
//get the list
|
|
|
|
|
$sql = "select * from v_access_control_nodes ";
|
2019-05-28 04:07:05 +02:00
|
|
|
$sql .= "where access_control_uuid = :access_control_uuid ";
|
2019-07-02 01:30:03 +02:00
|
|
|
$sql .= order_by($order_by, $order);
|
|
|
|
|
$sql .= limit_offset($rows_per_page, $offset);
|
2019-05-28 04:07:05 +02:00
|
|
|
$parameters['access_control_uuid'] = $access_control_uuid;
|
2019-07-02 01:30:03 +02:00
|
|
|
$database = new database;
|
|
|
|
|
$access_control_nodes = $database->select($sql, $parameters);
|
2018-06-30 03:19:52 +02:00
|
|
|
|
2020-02-07 19:13:34 +01:00
|
|
|
//create token
|
|
|
|
|
$object = new token;
|
|
|
|
|
$token = $object->create('/app/access_controls/access_control_nodes.php');
|
|
|
|
|
|
|
|
|
|
//show the content
|
|
|
|
|
echo "<form id='form_list' method='post' action='access_control_nodes.php'>\n";
|
|
|
|
|
echo "<input type='hidden' name='action' id='action' value=''>\n";
|
|
|
|
|
echo "<input type='hidden' name='access_control_uuid' value='".escape($access_control_uuid)."'>\n";
|
|
|
|
|
|
|
|
|
|
echo "<div class='action_bar' id='action_bar_sub'>\n";
|
|
|
|
|
echo " <div class='heading'><b id='heading_sub'>".$text['title-access_control_nodes']." (".$num_rows.")</b></div>\n";
|
|
|
|
|
echo " <div class='actions'>\n";
|
|
|
|
|
echo button::create(['type'=>'button','id'=>'action_bar_sub_button_back','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'collapse'=>'hide-xs','style'=>'margin-right: 15px; display: none;','link'=>'access_controls.php']);
|
|
|
|
|
if (permission_exists('access_control_node_add')) {
|
|
|
|
|
echo button::create(['type'=>'button','label'=>$text['button-add'],'icon'=>$_SESSION['theme']['button_icon_add'],'collapse'=>'hide-xs','link'=>'access_control_node_edit.php?access_control_uuid='.urlencode($_GET['id'])]);
|
|
|
|
|
}
|
|
|
|
|
if (permission_exists('access_control_node_delete') && $access_control_nodes) {
|
|
|
|
|
echo button::create(['type'=>'button','label'=>$text['button-delete'],'icon'=>$_SESSION['theme']['button_icon_delete'],'collapse'=>'hide-xs','onclick'=>"if (confirm('".$text['confirm-delete']."')) { list_action_set('delete'); list_form_submit('form_list'); } else { this.blur(); return false; }"]);
|
|
|
|
|
}
|
|
|
|
|
echo " </div>\n";
|
|
|
|
|
echo " <div style='clear: both;'></div>\n";
|
|
|
|
|
echo "</div>\n";
|
2015-08-13 07:09:07 +02:00
|
|
|
|
2020-02-07 19:13:34 +01:00
|
|
|
echo "<table class='list'>\n";
|
|
|
|
|
echo "<tr class='list-header'>\n";
|
|
|
|
|
if (permission_exists('access_control_node_delete')) {
|
|
|
|
|
echo " <th class='checkbox'>\n";
|
|
|
|
|
echo " <input type='checkbox' id='checkbox_all' name='checkbox_all' onclick='list_all_toggle();' ".($access_control_nodes ?: "style='visibility: hidden;'").">\n";
|
|
|
|
|
echo " </th>\n";
|
|
|
|
|
}
|
2015-08-13 07:09:07 +02:00
|
|
|
echo th_order_by('node_type', $text['label-node_type'], $order_by, $order);
|
|
|
|
|
echo th_order_by('node_cidr', $text['label-node_cidr'], $order_by, $order);
|
|
|
|
|
echo th_order_by('node_domain', $text['label-node_domain'], $order_by, $order);
|
2020-02-07 19:13:34 +01:00
|
|
|
echo th_order_by('node_description', $text['label-node_description'], $order_by, $order, null, "class='hide-sm-dn'");
|
|
|
|
|
if (permission_exists('access_control_node_edit') && $_SESSION['theme']['list_row_edit_button']['boolean'] == 'true') {
|
|
|
|
|
echo " <td class='action-button'> </td>\n";
|
2015-08-13 07:09:07 +02:00
|
|
|
}
|
2020-02-07 19:13:34 +01:00
|
|
|
echo "</tr>\n";
|
2015-08-13 07:09:07 +02:00
|
|
|
|
2020-02-07 19:13:34 +01:00
|
|
|
if (is_array($access_control_nodes) && @sizeof($access_control_nodes) != 0) {
|
|
|
|
|
$x = 0;
|
|
|
|
|
foreach ($access_control_nodes as $row) {
|
2015-08-13 07:09:07 +02:00
|
|
|
if (permission_exists('access_control_node_edit')) {
|
2020-02-07 19:13:34 +01:00
|
|
|
$list_row_url = 'access_control_node_edit.php?access_control_uuid='.urlencode($row['access_control_uuid'])."&id=".urlencode($row['access_control_node_uuid']);
|
|
|
|
|
}
|
|
|
|
|
echo "<tr class='list-row' href='".$list_row_url."'>\n";
|
|
|
|
|
if (permission_exists('access_control_node_delete')) {
|
|
|
|
|
echo " <td class='checkbox'>\n";
|
|
|
|
|
echo " <input type='checkbox' name='access_control_nodes[$x][checked]' id='checkbox_".$x."' value='true' onclick=\"if (!this.checked) { document.getElementById('checkbox_all').checked = false; }\">\n";
|
|
|
|
|
echo " <input type='hidden' name='access_control_nodes[$x][uuid]' value='".escape($row['access_control_node_uuid'])."' />\n";
|
|
|
|
|
echo " </td>\n";
|
2015-08-13 07:09:07 +02:00
|
|
|
}
|
2020-02-07 19:13:34 +01:00
|
|
|
echo " <td>".escape($row['node_type'])." </td>\n";
|
|
|
|
|
echo " <td>\n";
|
2015-08-13 07:09:07 +02:00
|
|
|
if (permission_exists('access_control_node_edit')) {
|
2020-02-07 19:13:34 +01:00
|
|
|
echo " <a href='".$list_row_url."' title=\"".$text['button-edit']."\">".escape($row['node_cidr'])."</a>\n";
|
2015-08-13 07:09:07 +02:00
|
|
|
}
|
2020-02-07 19:13:34 +01:00
|
|
|
else {
|
|
|
|
|
echo " ".escape($row['node_cidr']);
|
2015-08-13 07:09:07 +02:00
|
|
|
}
|
|
|
|
|
echo " </td>\n";
|
2020-02-07 19:13:34 +01:00
|
|
|
echo " <td>".escape($row['node_domain'])." </td>\n";
|
|
|
|
|
echo " <td class='description overflow hide-sm-dn'>".escape($row['node_description'])." </td>\n";
|
|
|
|
|
if (permission_exists('access_control_node_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";
|
|
|
|
|
}
|
2015-08-13 07:09:07 +02:00
|
|
|
echo "</tr>\n";
|
2020-02-07 19:13:34 +01:00
|
|
|
$x++;
|
|
|
|
|
}
|
|
|
|
|
unset($access_control_nodes);
|
|
|
|
|
}
|
2015-08-13 07:09:07 +02:00
|
|
|
|
2019-07-02 01:30:03 +02:00
|
|
|
echo "</table>\n";
|
|
|
|
|
echo "<br />\n";
|
2020-02-07 19:13:34 +01:00
|
|
|
|
|
|
|
|
echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
|
|
|
|
|
echo "</form>\n";
|
|
|
|
|
|
|
|
|
|
//make sub action bar sticky
|
|
|
|
|
echo "<script>\n";
|
|
|
|
|
|
|
|
|
|
echo " window.addEventListener('scroll', function(){\n";
|
|
|
|
|
echo " action_bar_scroll('action_bar_sub', 270, heading_modify, heading_restore);\n";
|
|
|
|
|
echo " }, false);\n";
|
|
|
|
|
|
|
|
|
|
echo " function heading_modify() {\n";
|
|
|
|
|
echo " document.getElementById('heading_sub').innerHTML = \"".$text['title-access_control'].' '.$text['title-access_control_nodes']." (".$num_rows.")\";\n";
|
|
|
|
|
echo " document.getElementById('action_bar_sub_button_back').style.display = 'inline-block';\n";
|
|
|
|
|
echo " }\n";
|
|
|
|
|
|
|
|
|
|
echo " function heading_restore() {\n";
|
|
|
|
|
echo " document.getElementById('heading_sub').innerHTML = \"".$text['title-access_control_nodes']." (".$num_rows.")\";\n";
|
|
|
|
|
echo " document.getElementById('action_bar_sub_button_back').style.display = 'none';\n";
|
|
|
|
|
echo " }\n";
|
|
|
|
|
|
|
|
|
|
echo "</script>\n";
|
2015-08-13 07:09:07 +02:00
|
|
|
|
|
|
|
|
//include the footer
|
|
|
|
|
require_once "resources/footer.php";
|
2018-06-30 03:19:52 +02:00
|
|
|
|
2020-02-07 19:13:34 +01:00
|
|
|
?>
|