Exemplo n.º 1
0
        if ($k == sizeof($resolve_config['subnets'])) {
            $query[] = '`subnetId` = "' . $subnetId . '" ';
        } else {
            $query[] = '`subnetId` = "' . $subnetId . '" or ';
        }
    }
    # get ony ip's with empty DNS
    if ($resolve_config['emptyonly'] == 1) {
        $query[] = ' and `dns_name` like "" ';
    }
    $query[] = 'order by `ip_addr` ASC;';
    //join
    $query = implode("\n", $query);
}
# fetch records
$ipaddresses = $Database->getObjectsQuery($query);
# try to update dns records
foreach ($ipaddresses as $ip) {
    # fetch subnet
    $subnet = $Subnets->fetch_subnet("id", $ip->subnetId);
    $nsid = $subnet === false ? false : $subnet->nameserverId;
    # try to resolve
    $hostname = $DNS->resolve_address($ip->ip_addr, null, true, $nsid);
    # update if change
    if ($hostname['name'] != $Subnets->transform_to_dotted($ip->ip_addr)) {
        # values
        $values = array("dns_name" => $hostname['name'], "id" => $ip->id);
        # execute
        if (!$Admin->object_modify("ipaddresses", "edit", "id", $values)) {
            $Result->show_cli("Failed to update address " . $Subnets->transform_to_dotted($ip->ip_addr));
        }