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


PHP Addresses::address_type_type_to_index方法代码示例

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


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

示例1: array

}
# Parse file
$outFile = $Tools->parse_import_file($filetype, $subnet, $custom_address_fields);
# Fetch all devices
$devices = $Tools->fetch_all_objects("devices", "hostname");
# cnt
$edit = 0;
$add = 0;
$invalid_lines = array();
$errors = 0;
# import each value
foreach ($outFile as $k => $line) {
    // if not error
    if ($line['class'] != "danger" || $line['class'] == "danger" && @$_POST['ignoreError'] == "1") {
        // reformat IP state from name to id
        $line[1] = $Addresses->address_type_type_to_index($line[1]);
        // reformat device from name to id
        if (strlen($line[7]) > 0) {
            if ($devices !== false) {
                foreach ($devices as $d) {
                    if ($d->hostname == $line[7]) {
                        $line[7] = $d->id;
                    }
                }
            } else {
                $line[7] = 0;
            }
        } else {
            $line[7] = 0;
        }
        // set action
开发者ID:routenull0,项目名称:phpipam,代码行数:31,代码来源:import-file.php

示例2: explode

# cnt
$edit = 0;
$add = 0;
$errors = 0;
# import each value
foreach ($outFile as $k => $line) {
    // explode it to array for verifications
    $lineArr = explode(",", $line);
    // 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
开发者ID:julsoj,项目名称:phpipam,代码行数:31,代码来源:import-file.php

示例3: explode

    }
} else {
    $Result->show('danger', _("Invalid file type"), true);
}
# import each value
foreach ($outFile as $k => $line) {
    // explode it to array for verifications
    $lineArr = explode(",", $line);
    // 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
        $devices = $Tools->fetch_devices();
        foreach ($devices as $d) {
            if ($d->hostname == $lineArr[6]) {
                $lineArr[6] = $d->id;
            }
        }
        // insert
        $ret = $Addresses->import_address_from_csv($lineArr, $_POST['subnetId']);
        if (!is_bool($ret) && strlen($ret) > 0) {
            $errors[] = $ret;
            $failed = true;
        } elseif ($ret === false) {
            $failed = true;
        }
开发者ID:netbuild,项目名称:phpipam,代码行数:31,代码来源:import-file.php


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