本文整理汇总了PHP中checkSubnetPermission函数的典型用法代码示例。如果您正苦于以下问题:PHP checkSubnetPermission函数的具体用法?PHP checkSubnetPermission怎么用?PHP checkSubnetPermission使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了checkSubnetPermission函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: printToolsSubnets
/**
* Print subnets structure
*/
function printToolsSubnets($subnets, $custom)
{
$html = array();
$rootId = 0;
# root is 0
# remove all not permitted!
foreach ($subnets as $k => $s) {
$permission = checkSubnetPermission($s['id']);
if ($permission == "0") {
unset($subnets[$k]);
}
}
if (sizeof($subnets) > 0) {
foreach ($subnets as $item) {
$children[$item['masterSubnetId']][] = $item;
}
}
# loop will be false if the root has no children (i.e., an empty menu!)
$loop = !empty($children[$rootId]);
# initializing $parent as the root
$parent = $rootId;
$parent_stack = array();
# display selected subnet as opened
if (isset($_GET['subnetId'])) {
$allParents = getAllParents($_GET['subnetId']);
}
# return table content (tr and td's)
while ($loop && (($option = each($children[$parent])) || $parent > $rootId)) {
# repeat
$repeat = str_repeat(" - ", count($parent_stack));
# dashes
if (count($parent_stack) == 0) {
$dash = "";
} else {
$dash = "-";
}
if (count($parent_stack) == 0) {
$margin = "0px";
$padding = "0px";
} else {
# padding
$padding = "10px";
# margin
$margin = count($parent_stack) * 10 - 10;
$margin = $margin * 2;
$margin = $margin . "px";
}
# count levels
$count = count($parent_stack) + 1;
# get subnet details
# get VLAN
$vlan = subnetGetVLANdetailsById($option['value']['vlanId']);
$vlan = $vlan['number'];
if (empty($vlan) || $vlan == "0") {
$vlan = "";
}
# no VLAN
# description
if (strlen($option['value']['description']) == 0) {
$description = "/";
} else {
$description = $option['value']['description'];
}
# description
# requests
if ($option['value']['allowRequests'] == 1) {
$requests = "<i class='fa fa-gray fa-check'></i>";
} else {
$requests = "";
}
# request disabled
# hosts check
if ($option['value']['pingSubnet'] == 1) {
$pCheck = "<i class='fa fa-gray fa-check'></i>";
} else {
$pCheck = "";
}
# ping check disabled
# print table line
if (strlen($option['value']['subnet']) > 0) {
$html[] = "<tr>";
# folder
if ($option['value']['isFolder'] == 1) {
$html[] = "\t<td class='level{$count}'><span class='structure' style='padding-left:{$padding}; margin-left:{$margin};'></span><i class='fa fa-sfolder fa-folder-open'></i> <a href='" . create_link("folder", $option['value']['sectionId'], $option['value']['id']) . "'>{$description}</a></td>";
$html[] = "\t<td class='level{$count}'><span class='structure' style='padding-left:{$padding}; margin-left:{$margin};'></span><i class='fa fa-sfolder fa-folder-open'></i> {$description}</td>";
} else {
if ($count == 1) {
$html[] = "\t<td class='level{$count}'><span class='structure' style='padding-left:{$padding}; margin-left:{$margin};'></span><i class='fa fa-gray fa-folder-open-o'></i><a href='" . create_link("subnets", $option['value']['sectionId'], $option['value']['id']) . "'> " . transform2long($option['value']['subnet']) . "/" . $option['value']['mask'] . "</a></td>";
$html[] = "\t<td class='level{$count}'><span class='structure' style='padding-left:{$padding}; margin-left:{$margin};'></span><i class='fa fa-gray fa-folder-open-o'></i> {$description}</td>";
} else {
# last?
if (!empty($children[$option['value']['id']])) {
$html[] = "\t<td class='level{$count}'><span class='structure' style='padding-left:{$padding}; margin-left:{$margin};'></span><i class='fa fa-folder-open-o'></i><a href='" . create_link("subnets", $option['value']['sectionId'], $option['value']['id']) . "'> " . transform2long($option['value']['subnet']) . "/" . $option['value']['mask'] . "</a></td>";
$html[] = "\t<td class='level{$count}'><span class='structure' style='padding-left:{$padding}; margin-left:{$margin};'></span><i class='fa fa-folder-open-o'></i> {$description}</td>";
} else {
$html[] = "\t<td class='level{$count}'><span class='structure' style='padding-left:{$padding}; margin-left:{$margin};'></span><i class='fa fa-angle-right'></i><a href='" . create_link("subnets", $option['value']['sectionId'], $option['value']['id']) . "'> " . transform2long($option['value']['subnet']) . "/" . $option['value']['mask'] . "</a></td>";
$html[] = "\t<td class='level{$count}'><span class='structure' style='padding-left:{$padding}; margin-left:{$margin};'></span><i class='fa fa-angle-right'></i> {$description}</td>";
//.........这里部分代码省略.........
示例2: isUserAuthenticated
/*
* Discover new hosts with ping
*******************************/
/* required functions */
require_once '../../../functions/functions.php';
/* verify that user is logged in */
isUserAuthenticated(true);
/* filter input */
$_POST = filter_user_input($_POST, true, true, false);
/* subnet Id must be a integer */
if (!is_numeric($_POST['subnetId']) || $_POST['subnetId'] == 0) {
die("<div class='alert alert-danger'>Invalid subnetId!</div>");
}
/* verify that user has write permissions for subnet */
$subnetPerm = checkSubnetPermission($_POST['subnetId']);
if ($subnetPerm < 2) {
die('<div class="alert alert-danger">' . _('You do not have permissions to modify hosts in this subnet') . '!</div>');
}
# verify post
CheckReferrer();
# ok, lets get results form post array!
foreach ($_POST as $key => $line) {
// IP address
if (substr($key, 0, 2) == "ip") {
$res[substr($key, 2)]['ip_addr'] = $line;
}
// description
if (substr($key, 0, 11) == "description") {
$res[substr($key, 11)]['description'] = $line;
}
示例3: printSubnets
/**
* Print subnets structure
*/
function printSubnets($subnets, $actions = true, $vrf = "0", $custom = array())
{
$html = array();
$rootId = 0;
# root is 0
if (sizeof($subnets) > 0) {
foreach ($subnets as $item) {
$children[$item['masterSubnetId']][] = $item;
}
}
# loop will be false if the root has no children (i.e., an empty menu!)
$loop = !empty($children[$rootId]);
# initializing $parent as the root
$parent = $rootId;
$parent_stack = array();
# display selected subnet as opened
if (isset($_REQUEST['subnetId'])) {
$allParents = getAllParents($_REQUEST['subnetId']);
}
# return table content (tr and td's)
while ($loop && (($option = each($children[$parent])) || $parent > $rootId)) {
# repeat
$repeat = str_repeat(" - ", count($parent_stack));
# dashes
if (count($parent_stack) == 0) {
$dash = "";
} else {
$dash = "-";
}
if (count($parent_stack) == 0) {
$margin = "0px";
$padding = "0px";
} else {
# padding
$padding = "10px";
# margin
$margin = count($parent_stack) * 10 - 10;
$margin = $margin * 2;
$margin = $margin . "px";
}
# count levels
$count = count($parent_stack) + 1;
# get subnet details
# get VLAN
$vlan = subnetGetVLANdetailsById($option['value']['vlanId']);
$vlan = $vlan['number'];
if (empty($vlan) || $vlan == "0") {
$vlan = "";
}
# no VLAN
# description
if (strlen($option['value']['description']) == 0) {
$description = "/";
} else {
$description = $option['value']['description'];
}
# description
# requests
if ($option['value']['allowRequests'] == 1) {
$requests = "<i class='fa fa-gray fa-check'></i>";
} else {
$requests = "";
}
# request disabled
# hosts check
if ($option['value']['pingSubnet'] == 1) {
$pCheck = "<i class='fa fa-gray fa-check'></i>";
} else {
$pCheck = "";
}
# ping check disabled
#vrf
if ($vrf == "1") {
# get VRF details
if ($option['value']['vrfId'] != "0" && $option['value']['vrfId'] != "NULL") {
$vrfTmp = getVRFDetailsById($option['value']['vrfId']);
$vrfText = $vrfTmp['name'];
} else {
$vrfText = "";
}
}
# print table line
if (strlen($option['value']['subnet']) > 0) {
// verify permission
$permission = checkSubnetPermission($option['value']['id']);
// print item
if ($permission != 0) {
$html[] = "<tr>";
# which level?
if ($count == 1) {
# is folder?
if ($option['value']['isFolder'] == 1) {
$html[] = "\t<td class='level{$count}'><span class='structure' style='padding-left:{$padding}; margin-left:{$margin};'></span><i class='fa fa-sfolder fa-pad-right-3 fa-folder-open'></i> <a href='folder/" . $option['value']['sectionId'] . "/" . $option['value']['id'] . "/'> {$description}</a></td>";
$html[] = "\t<td class='level{$count}'><span class='structure' style='padding-left:{$padding}; margin-left:{$margin};'></span><i class='fa fa-sfolder fa-pad-right-3 fa-folder-open'></i> {$description}</td>";
} else {
# last?
if (!empty($children[$option['value']['id']])) {
//.........这里部分代码省略.........
示例4: foreach
<?php
# only print if some hosts exist
if (sizeof($subnetHost) > 0) {
?>
<script type="text/javascript">
$(function () {
var data = [
<?php
if (sizeof($subnetHost) > 0) {
$m = 0;
foreach ($subnetHost as $subnet) {
if ($m < $slimit) {
# verify user access
$sp = checkSubnetPermission($subnet['id']);
if ($sp != "0") {
$subnet['subnet'] = long2ip($subnet['subnet']);
$subnet['descriptionLong'] = $subnet['description'];
# set percentage because of localisation
$subnet['percentage'] = str_replace(",", ".", $subnet['percentage']);
$subnet['percentage'] = $subnet['percentage'];
# odd/even if more than 5 items
if (sizeof($subnetHost) > 5) {
if ($m & 1) {
print "['|<br>" . addslashes($subnet[description]) . "', {$subnet['percentage']}, '" . addslashes($subnet[descriptionLong]) . " ({$subnet['subnet']}/{$subnet['mask']})'],";
} else {
print "['" . addslashes($subnet[description]) . "', {$subnet['percentage']}, '" . addslashes($subnet[descriptionLong]) . " ({$subnet['subnet']}/{$subnet['mask']})'],";
}
} else {
print "['" . addslashes($subnet[description]) . "', {$subnet['percentage']}, '" . addslashes($subnet[descriptionLong]) . " ({$subnet['subnet']}/{$subnet['mask']})'],";
示例5: CheckReferrer
/* include required scripts */
require_once '../../functions/functions.php';
/* check referer and requested with */
CheckReferrer();
/* get posted values */
$subnetId = $_POST['subnetId'];
$action = $_POST['action'];
$id = $_POST['id'];
/* set subnet -> for adding new only */
$subnet = getSubnetDetailsById($subnetId);
$subnet2 = $subnet;
$subnet = transform2long($subnet['subnet']) . "/" . $subnet['mask'];
/* verify that user is logged in */
isUserAuthenticated(false);
/* verify that user has write access */
$subnetPerm = checkSubnetPermission($subnetId);
if ($subnetPerm < 2) {
print '<div class="pHeader">Edit IP address</div>';
print '<div class="pContent">';
print '<div class="alert alert-danger">' . _('Cannot edit IP address details') . '! <br>' . _('You do not have write access for this network') . '!</div>';
print '</div>';
print '<div class="pFooter"><button class="btn btn-sm btn-default hidePopups">' . _('Cancel') . '</button></div>';
die;
}
/**
*
* if action is not add then fetch current details
*
* otherwise format the $ip field
*
*/
示例6: checkSubnetPermission
<?php
/*
* Print resize subnet
*********************/
/* required functions */
require_once '../../functions/functions.php';
/* verify that user has write permissions for subnet */
$subnetPerm = checkSubnetPermission($_REQUEST['subnetId']);
if ($subnetPerm < 3) {
die('<div class="alert alert-danger">' . _('You do not have permissions to resize subnet') . '!</div>');
}
/* verify post */
CheckReferrer();
# get old subnet details
$subnetOld = getSubnetDetailsById($_POST['subnetId']);
# get all site settings
$settings = getAllSettings();
/* get section details */
$section = getSectionDetailsById($subnetOld['sectionId']);
/*
* now we need to check each host against new subnet
*/
$ipaddresses = getIpAddressesBySubnetIdSort($_POST['subnetId'], "ip_addr", "asc");
# get all IP addresses
foreach ($ipaddresses as $ip) {
# check against new subnet
$error = VerifyIpAddress(transform2long($ip['ip_addr']), transform2long($subnetOld['subnet']) . "/" . $_POST['newMask']);
if (!$error) {
} else {
$errors[] = $error;
示例7: _
print "</tbody>";
# collapsed div with details
print "<tbody id='content-switch-{$m}'>";
# headers
print "<tr>";
print "\t<th>" . _('IP address') . "</th>";
print "\t<th>" . _('Port') . "</th>";
print "\t<th>" . _('Subnet') . "</th>";
print "\t<th colspan='2'>" . _('Description') . "</th>";
print "\t<th>" . _('Hostname') . "</th>";
print "\t<th>" . _('Owner') . "</th>";
print "</tr>";
# IP addresses
foreach ($ipaddresses as $ip) {
# check permission
$permission = checkSubnetPermission($ip['subnetId']);
if ($permission != "0") {
# get subnet details for belonging IP
$subnet = getSubnetDetails($ip['subnetId']);
# get section details
$section = getSectionDetailsById($subnet['sectionId']);
# print
print "<tr>";
print "\t<td class='ip'>" . transform2long($ip['ip_addr']) . "/{$subnet['mask']}</td>";
print "\t<td class='port'>{$ip['port']}</td>";
print "\t<td class='subnet'><a href='/subnets/{$section['id']}/{$subnet['id']}/'>{$subnet['description']}</a></td>";
print "\t<td class='description'>{$ip['description']}</td>";
# print info button for hover
print "<td class='note'>";
if (!empty($ip['note'])) {
$ip['note'] = str_replace("\n", "<br>", $ip['note']);
示例8: getSectionDetailsById
$change = 'change';
}
/* get section details */
$section = getSectionDetailsById($vlan['sectionId']);
/* check if it is master */
if (!isset($vlan['masterSubnetId'])) {
$masterSubnet = true;
} else {
if ($vlan['masterSubnetId'] == 0 || empty($vlan['masterSubnetId'])) {
$masterSubnet = true;
} else {
$masterSubnet = false;
}
}
# check permission
$permission = checkSubnetPermission($vlan['subnetId']);
if ($permission != "0") {
print "<tr class='{$change}'>";
/* print first 3 only if change happened! */
if ($change == "change") {
print ' <td>' . $vlan['number'] . '</td>' . "\n";
print ' <td>' . $vlan['name'] . '</td>' . "\n";
print ' <td>' . $vlan['description'] . '</td>' . "\n";
} else {
print '<td></td>';
print '<td></td>';
print '<td></td>';
}
if ($vlan['subnetId'] != null) {
# subnet
print " <td><a href='subnets/{$section['id']}/{$vlan['subnetId']}/'>" . transform2long($vlan['subnet']) . "/{$vlan['mask']}</a></td>";
示例9: calculateSubnetDetails
$calculate = calculateSubnetDetails(gmp_strval($ipCount), $slave['mask'], $slave['subnet']);
print ' <td class="small hidden-xs hidden-sm">' . $calculate['used'] . '/' . $calculate['maxhosts'] . '</td>' . "\n";
print ' <td class="small hidden-xs hidden-sm">' . $calculate['freehosts_percent'] . '</td>';
# add to sum if IPv4
if (IdentifyAddress($slave['subnet']) == "IPv4") {
$usedSum = $usedSum + $calculate['used'];
$allSum = $allSum + $calculate['maxhosts'];
}
# allow requests
if ($slave['allowRequests'] == 1) {
print '<td class="allowRequests small hidden-xs hidden-sm"><i class="fa fa-gray fa-check"></i></td>';
} else {
print '<td class="allowRequests small hidden-xs hidden-sm"><i class="fa fa-gray fa-check"></i></td>';
}
# edit
$subnetPerm = checkSubnetPermission($slave['id']);
if ($subnetPerm == 3) {
print "\t<td class='actions'>";
print "\t<div class='btn-group'>";
print "\t\t<button class='btn btn-xs btn-default editSubnet' data-action='edit' data-subnetid='" . $slave['id'] . "' data-sectionid='" . $slave['sectionId'] . "'><i class='fa fa-gray fa fa-pencil'></i></button>";
print "\t\t<button class='btn btn-xs btn-default showSubnetPerm' data-action='show' data-subnetid='" . $slave['id'] . "' data-sectionid='" . $slave['sectionId'] . "'><i class='fa fa-gray fa fa-tasks'></i></button>";
print "\t\t<button class='btn btn-xs btn-default editSubnet' data-action='delete' data-subnetid='" . $slave['id'] . "' data-sectionid='" . $slave['sectionId'] . "'><i class='fa fa-gray fa fa-times'></i></button>";
print "\t</div>";
print " </td>";
} else {
print "\t<td class='actions'>";
print "\t<div class='btn-group'>";
print "\t\t<button class='btn btn-xs btn-default disabled'><i class='fa fa-gray fa fa-pencil'></i></button>";
print "\t\t<button class='btn btn-xs btn-default disabled'><i class='fa fa-gray fa fa-tasks'></i></button>";
print "\t\t<button class='btn btn-xs btn-default disabled'><i class='fa fa-gray fa fa-times'></i></button>";
print "\t</div>";
示例10: die
die('<div class="alert alert-danger">' . _("Invalid ID") . '</div>');
}
# get IP address details
$ip = getIpAddrDetailsById($_GET['ipaddrid']);
$subnet = getSubnetDetailsById($_GET['subnetId']);
$section = getSectionDetailsById($_GET['section']);
# get all selected fields for IP print
$setFieldsTemp = getSelectedIPaddrFields();
// format them to array!
$setFields = explode(";", $setFieldsTemp);
# get all custom fields
$myFields = getCustomFields('ipaddresses');
# set ping statuses
$statuses = explode(";", $settings['pingStatus']);
# permissions
$permission = checkSubnetPermission($_GET['subnetId']);
# section permissions
$permissionsSection = checkSectionPermission($_GET['section']);
# if 0 die
if ($permission == "0") {
die("<div class='alert alert-danger'>" . _('You do not have permission to access this network') . "!</div>");
}
# reformat empty fields
foreach ($ip as $k => $i) {
if (strlen($i) == 0) {
$ip[$k] = "/";
}
}
#header
print "<h4>" . _('IP address details') . "</h4><hr>";
# back
示例11: printSubnets
/**
* Print subnets structure
*/
function printSubnets($subnets, $actions = true, $vrf = "0", $custom = array())
{
$html = array();
$rootId = 0;
# root is 0
if (sizeof($subnets) > 0) {
foreach ($subnets as $item) {
$children[$item['masterSubnetId']][] = $item;
}
}
# loop will be false if the root has no children (i.e., an empty menu!)
$loop = !empty($children[$rootId]);
# initializing $parent as the root
$parent = $rootId;
$parent_stack = array();
# display selected subnet as opened
if (isset($_REQUEST['subnetId'])) {
$allParents = getAllParents($_REQUEST['subnetId']);
}
# return table content (tr and td's)
while ($loop && (($option = each($children[$parent])) || $parent > $rootId)) {
# repeat
$repeat = str_repeat(" - ", count($parent_stack));
# dashes
if (count($parent_stack) == 0) {
$dash = "";
} else {
$dash = "-";
}
if (count($parent_stack) == 0) {
$margin = "0px";
$padding = "0px";
} else {
# padding
$padding = "10px";
# margin
$margin = count($parent_stack) * 10 - 10;
$margin = $margin * 2;
$margin = $margin . "px";
}
# count levels
$count = count($parent_stack) + 1;
# get subnet details
# get VLAN
$vlan = subnetGetVLANdetailsById($option['value']['vlanId']);
$vlan = $vlan['number'];
if (empty($vlan) || $vlan == "0") {
$vlan = "";
}
# no VLAN
# description
if (strlen($option['value']['description']) == 0) {
$description = "/";
} else {
$description = $option['value']['description'];
}
# description
# requests
if ($option['value']['allowRequests'] == 1) {
$requests = _("enabled");
} else {
$requests = "";
}
# request disabled
# hosts check
if ($option['value']['pingSubnet'] == 1) {
$pCheck = _("enabled");
} else {
$pCheck = "";
}
# ping check disabled
#vrf
if ($vrf == "1") {
# get VRF details
if ($option['value']['vrfId'] != "0" && $option['value']['vrfId'] != "NULL") {
$vrfTmp = getVRFDetailsById($option['value']['vrfId']);
$vrfText = $vrfTmp['name'];
} else {
$vrfText = "";
}
}
// <eNovance>
// count the number of free and offline hosts
$ipaddresses = getIpAddressesBySubnetId($option['value']['id']);
$reservedHosts = 0;
foreach ($ipaddresses as $ip) {
if ($ip['state'] == "2") {
$reservedHosts += 1;
}
}
$subnetDetails = calculateSubnetDetails(count($ipaddresses), $option['value']['mask'], $option['value']['subnet']);
$freeHosts = $subnetDetails['freehosts'];
// </eNovance>
# print table line
if (strlen($option['value']['subnet']) > 0) {
// verify permission
$permission = checkSubnetPermission($option['value']['id']);
//.........这里部分代码省略.........
示例12: foreach
}
# actions
print '<th class="actions"></th>';
?>
</tr>
<!-- IP addresses -->
<?php
/* if no result print nothing found */
if (sizeof($result) > 0) {
$m = 0;
//for section change
/* print content */
foreach ($result as $line) {
# check permission
$permission = checkSubnetPermission($line['subnetId']);
if ($permission != "0") {
//get the Subnet details
$subnet = getSubnetDetailsById($line['subnetId']);
//get vlan number
$vlan = subnetGetVLANDetailsById($subnet['vlanId']);
//get section
$section = getSectionDetailsById($subnet['sectionId']);
//detect section change and print headers
if ($result[$m]['subnetId'] != $result[$m - 1]['subnetId']) {
print '<tr>' . "\n";
print ' <th colspan="' . $colSpan . '">' . $section['name'] . ' :: <a href="' . create_link("subnets", $subnet['sectionId'], $subnet['id']) . '" style="font-weight:300">' . $subnet['description'] . ' (' . transform2long($subnet['subnet']) . '/' . $subnet['mask'] . ')</a></th>' . "\n";
print '</tr>';
}
$m++;
$stateClass = "";