當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Subnets::verify_subnet_resize方法代碼示例

本文整理匯總了PHP中Subnets::verify_subnet_resize方法的典型用法代碼示例。如果您正苦於以下問題:PHP Subnets::verify_subnet_resize方法的具體用法?PHP Subnets::verify_subnet_resize怎麽用?PHP Subnets::verify_subnet_resize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Subnets的用法示例。


在下文中一共展示了Subnets::verify_subnet_resize方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: Result

$Result = new Result();
# verify that user is logged in
$User->check_user_session();
# validate csrf cookie
$_POST['csrf_cookie'] == $_SESSION['csrf_cookie'] ?: $Result->show("danger", _("Invalid CSRF cookie"), true);
# ID must be numeric
if (!is_numeric($_POST['subnetId'])) {
    $Result->show("danger", _("Invalid ID"), true);
}
# verify that user has write permissions for subnet
if ($Subnets->check_permission($User->user, $_POST['subnetId']) < 3) {
    $Result->show("danger", _('You do not have permissions to resize subnet') . '!', true);
}
# fetch old subnet details and set new
$subnet_old = (array) $Subnets->fetch_subnet(null, $_POST['subnetId']);
# verify resizing
$Subnets->verify_subnet_resize($subnet_old['subnet'], $_POST['newMask'], $subnet_old['id'], $subnet_old['vrfId'], $subnet_old['masterSubnetId'], $subnet_old['mask'], $subnet_old['sectionId']);
# we need to recalculate subnet address if needed
if ($subnet_old['mask'] < $_POST['newMask']) {
    $subnet_new['subnet'] = $subnet_old['subnet'];
} else {
    $new_boundaries = $Subnets->get_network_boundaries($Subnets->transform_address($subnet_old['subnet'], "dotted"), $_POST['newMask']);
    $subnet_new['subnet'] = $Subnets->transform_address($new_boundaries['network'], "decimal");
}
# set update values
$values = array("id" => $_POST['subnetId'], "subnet" => $subnet_new['subnet'], "mask" => $_POST['newMask']);
if (!$Subnets->modify_subnet("resize", $values)) {
    $Result->show("danger", _("Error resizing subnet") . "!", true);
} else {
    $Result->show("success", _("Subnet resized successfully") . "!", true);
}
開發者ID:mwodz,項目名稱:phpipam,代碼行數:31,代碼來源:resize-save.php


注:本文中的Subnets::verify_subnet_resize方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。