$Admin = new Admin($Database, false); $Subnets = new Subnets($Database); $Addresses = new Addresses($Database); $Result = new Result(); # verify that user is logged in $User->check_user_session(); # create csrf token $csrf = $User->create_csrf_cookie(); # id must be numeric if (!is_numeric($_POST['subnetId'])) { $Result->show("danger", _("Invalid ID"), true, true); } # get subnet details $subnet = $Subnets->fetch_subnet(null, $_POST['subnetId']); # verify that user has write permissions for subnet $subnetPerm = $Subnets->check_permission($User->user, $subnet->id); if ($subnetPerm < 3) { $Result->show("danger", _('You do not have permissions to resize subnet') . '!', true, true); } ?> <!-- header --> <div class="pHeader"><?php print _('Truncate subnet'); ?> </div> <!-- content --> <div class="pContent"> <table class="table table-noborder table-condensed">
# subnet-related variables $subnet = (array) $Subnets->fetch_subnet(null, $_POST['subnetId']); //subnet details $subnet_detailed = $Subnets->get_network_boundaries($subnet['subnet'], $subnet['mask']); //set network boundaries $slaves = $Subnets->has_slaves($subnet['id']) ? true : false; //check if subnet has slaves and set slaves flag true/false # fetch all addresses - sorted if ($slaves) { $addresses = $Addresses->fetch_subnet_addresses_recursive($subnet['id'], false, $sort['field'], $sort['direction']); $slave_subnets = (array) $Subnets->fetch_subnet_slaves($subnet['id']); } else { $addresses = $Addresses->fetch_subnet_addresses($subnet['id'], $sort['field'], $sort['direction']); } # set permissions $subnet_permission = $Subnets->check_permission($User->user, $subnet['id']); } # We need DNS object $DNS = new DNS($Database, $User->settings); /* verifications */ # checks if (sizeof($subnet) == 0) { $Result->show("danger", _('Subnet does not exist'), true); } //subnet doesnt exist if ($subnet_permission == 0) { $Result->show("danger", _('You do not have permission to access this network'), true); } //not allowed to access if (!is_numeric($_REQUEST['subnetId'])) { $Result->show("danger", _('Invalid ID'), true);
$_POST = $User->strip_input_tags($_POST); # validate action $Admin->validate_action($_POST['action'], true); # ID must be numeric if ($_POST['action'] != "add") { if (!is_numeric($_POST['subnetId'])) { $Result->show("danger", _("Invalid ID"), true, true); } } # verify that user has permissions to add subnet if ($_POST['action'] == "add") { if ($Sections->check_permission($User->user, $_POST['sectionId']) != 3) { $Result->show("danger", _('You do not have permissions to add new subnet in this section') . "!", true, true); } } else { if ($Subnets->check_permission($User->user, $_POST['subnetId']) != 3) { $Result->show("danger", _('You do not have permissions to add edit/delete this subnet') . "!", true, true); } } # we are editing or deleting existing subnet, get old details if ($_POST['action'] != "add") { $folder_old_details = (array) $Subnets->fetch_subnet(null, $_POST['subnetId']); } else { # for selecting master subnet if added from subnet details! if (strlen($_POST['subnetId']) > 0) { $subnet_old_temp = (array) $Subnets->fetch_subnet(null, $_POST['subnetId']); $subnet_old_details['masterSubnetId'] = @$subnet_old_temp['id']; // same master subnet ID for nested $subnet_old_details['vlanId'] = @$subnet_old_temp['vlanId']; // same default vlan for nested $subnet_old_details['vrfId'] = @$subnet_old_temp['vrfId'];
print "\t<th>" . _('User') . "</th>"; print "\t<th>" . _('Type') . "</th>"; print "\t<th>" . _('Object') . "</th>"; print "\t<th>" . _('Date') . "</th>"; print "\t<th class='hidden-xs'>" . _('Change') . "</th>"; print "</tr>"; # logs $pc = 0; //print count foreach ($clogs as $l) { # cast $l = (array) $l; if ($pc < 5) { # permissions if ($l['ctype'] == "subnet") { $permission = $Subnets->check_permission($User->user, $l['tid']); } elseif ($l['ctype'] == "ip_addr") { $permission = $Subnets->check_permission($User->user, $l['subnetId']); } elseif ($l['ctype'] == "section") { $permission = $Sections->check_permission($User->user, $l['sectionId']); } else { $permission = 0; } # if 0 ignore if ($permission > 0) { # format diff $changelog = str_replace("\r\n", "<br>", $l['cdiff']); $changelog = str_replace("\n", "<br>", $changelog); $changelog = array_filter(explode("<br>", $changelog)); $diff = array(); foreach ($changelog as $c) {
} # generate firewall address object name $firewallZoneSettings = json_decode($User->settings->firewallZoneSettings, true); if ($firewallZoneSettings->autogen == 'on') { if ($address['action'] == 'add') { $address['firewallAddressObject'] = $Zones->generate_address_object($address['subnetId'], $address['dns_name']); } else { if ($_POST['firewallAddressObject']) { $address['firewallAddressObject'] = $_POST['firewallAddressObject']; } else { $address['firewallAddressObject'] = NULL; } } } # set and check permissions $subnet_permission = $Subnets->check_permission($User->user, $address['subnetId']); $subnet_permission > 1 ?: $Result->show("danger", _('Cannot edit IP address'), true); # fetch subnet $subnet = (array) $Subnets->fetch_subnet(null, $address['subnetId']); if (@$_POST['verifydatabase'] !== "yes") { sizeof($subnet) > 0 ?: $Result->show("danger", _("Invalid subnet"), true); } # replace empty fields with nulls $address = $Addresses->reformat_empty_array_fields($address, null); # custom fields and checks $custom_fields = $Tools->fetch_custom_fields('ipaddresses'); if (sizeof($custom_fields) > 0) { foreach ($custom_fields as $field) { # replace possible ___ back to spaces! $field['nameTest'] = str_replace(" ", "___", $field['name']); if (isset($address[$field['nameTest']])) {
#is_numeric($_POST['subnetId']) ?: $Result->show("danger", _("Invalid ID"), true, true, false, true); #if(is_numeric($id)) { # strlen($id)!=0 ?: $Result->show("danger", _("Invalid ID"), true, true, false, true); # fetch address # $address = (array) $Addresses->fetch_address(null, $id); #} // from adding new IP, validate #else { # $validate = $Subnets->identify_address ($_POST['id'])=="IPv4" ? filter_var($_POST['id'], FILTER_VALIDATE_IP) : filter_var($_POST['id'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6); # if ($validate===false) { $Result->show("danger", _("Invalid IP address"), true, true, false, true); } # else { # $address['ip'] = $id; # } #} # set and check permissions $subnet_permission = $Subnets->check_permission($User->user, $_POST['subnetId']); $subnet_permission > 2 ?: $Result->show("danger", _('Cannot edit IP address details') . '! <br>' . _('You do not have write access for this network'), true, true); ?> <!-- header --> <div class="pHeader"><?php print _('Show Individual IP Info'); ?> </div> <!-- content --> <div class="pContent"> <?php print "<table class='ipaddress_subnet table table-noborder table-condensed' style='margin-top:10px;'>"; print "<tr>"; print "\t<th>" . _('Hostname') . "</th>";
} } ?> <th style="width:5px;"></th> </tr> <?php $m = 0; //to count success subnets because of permissions /** subnet results **/ if (sizeof($result_subnets) > 0) { # loop foreach ($result_subnets as $line) { # cast $line = (array) $line; # check permission $subnet_permission = $Subnets->check_permission($User->user, $line['id']); if ($subnet_permission > 0) { $m++; //get section details $section = (array) $Sections->fetch_section(null, $line['sectionId']); //get vlan number $vlan = (array) $Tools->fetch_object("vlans", "vlanId", $line['vlanId']); //format requests $line['allowRequests'] = $line['allowRequests'] == 1 ? "enabled" : "disabled"; //format master subnet if ($line['masterSubnetId'] == 0) { $master_text = "/"; } else { $master_subnet = (array) $Subnets->fetch_subnet(null, $line['masterSubnetId']); # folder? if ($master_subnet['isFolder'] == 1) {
/** * Returns list of recipients to get new * * @access private * @param bool|mixed $subnetId * @return array|bool */ private function ip_request_get_mail_recipients($subnetId = false) { // fetch all users with mailNotify $notification_users = $this->fetch_multiple_objects("users", "mailNotify", "Yes", "id", true); // recipients array $recipients = array(); // any ? if ($notification_users !== false) { // if subnetId is set check who has permissions if (isset($subnetId)) { foreach ($notification_users as $u) { // inti object $Subnets = new Subnets($this->Database); //check permissions $subnet_permission = $Subnets->check_permission($u, $subnetId); // if 3 than add if ($subnet_permission == 3) { $recipients[] = $u; } } } else { foreach ($notification_users as $u) { if ($u->role == "Administrator") { $recipients[] = $u; } } } return sizeof($recipients) > 0 ? $recipients : false; } else { return false; } }
$Addresses = new Addresses($Database); $Subnets = new Subnets($Database); $Tools = new Tools($Database); $Result = new Result(); # verify that user is logged in $User->check_user_session(); # fetch request $request = $Admin->fetch_object("requests", "id", $_POST['requestId']); //fail if ($request === false) { $Result->show("danger", _("Request does not exist"), true, true); } else { $request = (array) $request; } # verify permissions if ($Subnets->check_permission($User->user, $request['subnetId']) != 3) { $Result->show("danger", _('You do not have permissions to process this request') . "!", true, true); } # set IP address # if provided (requested from logged in user) check if already in use, if it is warn and set next free # else get next free if (strlen($request['ip_addr']) > 0) { // check if it exists if ($Addresses->address_exists($request['ip_addr'], $request['subnetId'])) { $errmsg = "Requested IP address ({$request['ip_addr']}) already used. First available address automatically provided."; $errmsg_class = "warning"; //fetch first free $ip_address = $Addresses->transform_to_dotted($Addresses->get_first_available_address($request['subnetId'], $Subnets)); } else { $ip_address = $request['ip_addr']; }
$height = 350; $slimit = 5; # and print title print "<div class='container'>"; print "<h4 style='margin-top:40px;'>{$widget->wtitle}</h4><hr>"; print "</div>"; } if ($User->settings->enableThreshold == "1") { # get thresholded subnets $threshold_subnets = $Subnets->fetch_threshold_subnets(1000); # any found ? if ($threshold_subnets !== false) { # loop foreach ($threshold_subnets as $s) { # check permission of user $sp = $Subnets->check_permission($User->user, $s->id); if ($sp != "0") { $out[] = $s; } } } } # disabled if ($User->settings->enableThreshold != "1") { print "<hr>"; print "<blockquote style='margin-top:20px;margin-left:20px;'>"; print "<p>" . _("Threshold module disabled") . "</p>"; print "<small>" . _("You can enable threshold module under settings") . "</small>"; print "</blockquote>"; } elseif ($threshold_subnets === false) { print "<hr>";