$_POST['ffield'] = null; $_POST['fval'] = null; } else { //format posted values! $tmp = explode("|", $_POST['direction']); $sort['field'] = $tmp[0]; $sort['direction'] = $tmp[1]; if ($sort['direction'] == "asc") { $sort['directionNext'] = "desc"; } else { $sort['directionNext'] = "asc"; } } # filter devices or fetch print all? $filter = isset($_POST['ffield']) ? true : false; $devices = $Tools->fetch_devices($_POST['ffield'], $_POST['fval'], $sort['field'], $sort['direction']); $device_types = $Tools->fetch_all_objects("deviceTypes", "tid"); # get custom fields $custom_fields = $Tools->fetch_custom_fields('devices'); # get hidden fields */ $hidden_fields = json_decode($User->settings->hiddenCustomFields, true); $hidden_fields = is_array(@$hidden_fields['devices']) ? $hidden_fields['devices'] : array(); # sort icons if ($sort['direction'] == 'asc') { $icon = "<i class='fa fa-angle-down'></i> "; } else { $icon = "<i class='fa fa-angle-up'></i> "; } # title print "<h4>" . _('List of network devices') . "</h4>"; print "<hr>";
//custom if (sizeof($custom_fields) > 0) { foreach ($custom_fields as $myField) { //set temp name - replace space with three ___ $myField['nameTemp'] = str_replace(" ", "___", $myField['name']); if (isset($_GET[$myField['nameTemp']]) && $_GET[$myField['nameTemp']] == "on") { $worksheet->write($lineCount, $rowCount, $myField['name'], $format_title); $rowCount++; } } } $lineCount++; //we need to reformat state! $ip_types = $Addresses->addresses_types_fetch(); //fetch devices and reorder $devices = $Tools->fetch_devices(); foreach ($devices as $d) { $devices_indexed[$d->id] = $d; } //write all IP addresses foreach ($addresses as $ip) { $ip = (array) $ip; //reset row count $rowCount = 0; //change switch ID to name $ip['switch'] = is_null($ip['switch']) || strlen($ip['switch']) == 0 ? "" : $devices_indexed[$ip['switch']]->hostname; if (isset($_GET['ip_addr']) && $_GET['ip_addr'] == "on") { $worksheet->write($lineCount, $rowCount, $Subnets->transform_address($ip['ip_addr'], "dotted"), $format_left); $rowCount++; } if (isset($_GET['state']) && $_GET['state'] == "on") {
# validate $_POST['id'] values if (!preg_match('/^[0-9]+$/i', $_POST['id'])) { $Result->show("danger", _("Invalid ID. Do not manipulate the POST values!"), true); } # validate $_POST['action'] values if ($_POST['action'] != 'add' && $_POST['action'] != 'edit' && $_POST['action'] != 'delete') { $Result->show("danger", _("Invalid action. Do not manipulate the POST values!"), true); } # disable edit on delete $readonly = $_POST['action'] == "delete" ? "disabled" : ""; # fetch all firewall zones $firewallZones = $Zones->get_zones(); # fetch settings $firewallZoneSettings = json_decode($User->settings->firewallZoneSettings, true); # fetch all devices $devices = $Tools->fetch_devices('type', $firewallZoneSettings['deviceType']); # fetch old mapping if ($_POST['action'] != 'add') { $mapping = $Zones->get_zone_mapping($_POST['id']); } ?> <!-- header --> <div class="pHeader"><?php print _('Add a mapping between a firewall device and a firewall zone'); ?> </div> <!-- content --> <div class="pContent"> <!-- form --> <form id="mappingEdit">