当前位置: 首页>>代码示例>>PHP>>正文


PHP Addresses::address_exists方法代码示例

本文整理汇总了PHP中Addresses::address_exists方法的典型用法代码示例。如果您正苦于以下问题:PHP Addresses::address_exists方法的具体用法?PHP Addresses::address_exists怎么用?PHP Addresses::address_exists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Addresses的用法示例。


在下文中一共展示了Addresses::address_exists方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1:

             }
         }
     }
     # validate and normalize MAC address
     if ($action !== "delete") {
         if (strlen(@$address['mac']) > 0) {
             if ($User->validate_mac($address['mac']) === false) {
                 $errors[] = _('Invalid MAC address') . "!";
             } else {
                 $address['mac'] = $User->reformat_mac_address($address['mac'], 1);
             }
         }
     }
     # modify action - if delete ok, dynamically reset add / edit -> if IP already exists set edit
     if ($action != "delete") {
         $address['action'] = $Addresses->address_exists($m, $address['subnetId']) === true ? "edit" : "add";
     }
     # if it fails set error log
     if (!$Addresses->modify_address($address, false)) {
         $errors[] = _('Cannot') . ' ' . $address['action'] . ' ' . _('IP address') . ' ' . $Addresses->transform_to_dotted($m);
     }
     # next IP
     $m = gmp_strval(gmp_add($m, 1));
 }
 # print errors if they exist
 if (isset($errors)) {
     $log = $Result->array_to_log($errors);
     $Result->show("danger", $log, false);
     $Log->write("IP address modification", "'Error {$action} range {$address['start']} - {$address['stop']}<br> {$log}", 2);
 } else {
     # reset IP for mailing
开发者ID:routenull0,项目名称:phpipam,代码行数:31,代码来源:address-modify-submit.php

示例2: unset

 // array size must be at least 9
 if (sizeof($lineArr) < 9) {
     $errors[] = "Line {$k} is invalid";
     unset($outFile[$k]);
     //wrong line, unset!
 } else {
     // reformat IP state
     $lineArr[1] = $Addresses->address_type_type_to_index($lineArr[1]);
     // reformat device from name to id
     foreach ($devices as $d) {
         if ($d->hostname == $lineArr[6]) {
             $lineArr[6] = $d->id;
         }
     }
     // set action
     if ($id = $Addresses->address_exists($lineArr[0], $_POST['subnetId'], false)) {
         $action = "edit";
     } else {
         $action = "add";
     }
     // set insert / update values
     $address_insert = array("action" => $action, "subnetId" => $_POST['subnetId'], "ip_addr" => $lineArr[0], "state" => $Addresses->address_type_type_to_index($lineArr[1]), "description" => $lineArr[2], "dns_name" => $lineArr[3], "mac" => $lineArr[4], "owner" => $lineArr[5], "switch" => $lineArr[6], "port" => $lineArr[7], "note" => $lineArr[8]);
     // add id
     if ($action == "edit") {
         $address_insert["id"] = $id;
     }
     // insert
     if ($Addresses->modify_address($address_insert) === false) {
         $errors++;
     } else {
         if ($action == "edit") {
开发者ID:julsoj,项目名称:phpipam,代码行数:31,代码来源:import-file.php

示例3: foreach

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;
    }
    // dns name
    if (substr($key, 0, 8) == "dns_name") {
        $res[substr($key, 8)]['dns_name'] = $line;
    }
    //verify that it is not already in table!
    if (substr($key, 0, 2) == "ip") {
        if ($Addresses->address_exists($line, $_POST['subnetId']) === true) {
            $Result->show("danger", "IP address {$line} already exists!", true);
        }
    }
}
# insert entries
if (sizeof($res) > 0) {
    $errors = 0;
    foreach ($res as $r) {
        # set insert values
        $values = array("ip_addr" => $Subnets->transform_to_decimal($r['ip_addr']), "dns_name" => $r['dns_name'], "subnetId" => $_POST['subnetId'], "description" => $r['description'], "lastSeen" => date("Y-m-d H:i:s"));
        # insert
        if (!$Admin->object_modify("ipaddresses", "add", "id", $values)) {
            $Result->show("danger", "Failed to import entry " . $r['ip_addr'], false);
            $errors++;
        }
开发者ID:rtd,项目名称:phpipam,代码行数:31,代码来源:subnet-scan-icmp-result.php

示例4: array

    //set reject values
    $values = array("id" => $_POST['requestId'], "processed" => 1, "accepted" => 0, "adminComment" => @$_POST['adminComment']);
    if (!$Admin->object_modify("requests", "edit", "id", $values)) {
        $Result->show("danger", _("Failed to reject IP request"), true);
    } else {
        $Result->show("success", _("Request has beed rejected"), false);
    }
    # send mail
    $Tools->ip_request_send_mail("reject", $_POST);
} else {
    // fetch subnet
    $subnet_temp = $Addresses->transform_to_dotted($subnet['subnet']) . "/" . $subnet['mask'];
    //verify IP and subnet
    $Addresses->verify_address($Addresses->transform_address($_POST['ip_addr'], "dotted"), $subnet_temp, false, true);
    //check if already existing and die
    if ($Addresses->address_exists($Addresses->transform_address($_POST['ip_addr'], "decimal"), $subnet['id'])) {
        $Result->show("danger", _('IP address already exists'), true);
    }
    //insert to ipaddresses table
    $values = array("action" => "add", "ip_addr" => $Addresses->transform_address($_POST['ip_addr'], "decimal"), "subnetId" => $_POST['subnetId'], "description" => @$_POST['description'], "dns_name" => @$_POST['dns_name'], "mac" => @$_POST['mac'], "owner" => @$_POST['owner'], "state" => @$_POST['state'], "switch" => @$_POST['switch'], "port" => @$_POST['port'], "note" => @$_POST['note']);
    if (!$Addresses->modify_address($values)) {
        $Result->show("danger", _("Failed to create IP address"), true);
    }
    //accept message
    $values2 = array("id" => $_POST['requestId'], "processed" => 1, "accepted" => 1, "adminComment" => $comment);
    if (!$Admin->object_modify("requests", "edit", "id", $values2)) {
        $Result->show("danger", _("Cannot confirm IP address"), true);
    } else {
        $Result->show("success", _("IP request accepted/rejected"), false);
    }
    # send mail
开发者ID:routenull0,项目名称:phpipam,代码行数:31,代码来源:edit-result.php

示例5: provided

//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'];
    }
} else {
    // fetch first free
    $ip_address = $Addresses->transform_to_dotted($Addresses->get_first_available_address($request['subnetId'], $Subnets));
}
// false
if ($ip_address === false) {
    $ip_address = "";
    $errmsg = "No IP addresses available in requested subnet";
开发者ID:martinsv,项目名称:phpipam,代码行数:31,代码来源:edit.php


注:本文中的Addresses::address_exists方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。