Exemplo n.º 1
0
if (!empty($_REQUEST['myip'])) {
    $given_ip = $_REQUEST['myip'];
} elseif (!empty($_REQUEST['ip'])) {
    $given_ip = $_REQUEST['ip'];
}
// Look for tag tograb the IP we coming from
if ($given_ip == "whatismyip") {
    $given_ip = $_SERVER['REMOTE_ADDR'];
}
// Finally get save version of the IP
$ip = safe($given_ip);
// Check its ok...
if (!valid_ip_address($ip)) {
    return status_exit('dnserr');
} else {
    $type = valid_ip_address($ip);
}
if (!strlen($hostname)) {
    return status_exit('notfqdn');
}
$user_query = "\n\tSELECT\n\t\tusers.id\n\tFROM\n\t\tusers, perm_templ, perm_templ_items, perm_items\n\tWHERE\n\t\tusers.username = '******'\n\t\tAND users.password = '******'\n\t\tAND users.active = 1\n\t\tAND perm_templ.id = users.perm_templ\n\t\tAND perm_templ_items.templ_id = perm_templ.id\n\t\tAND perm_items.id = perm_templ_items.perm_id\n\t\tAND (\n\t\t\t\tperm_items.name = 'zone_content_edit_own'\n\t\t\t\tOR perm_items.name = 'zone_content_edit_others'\n\t\t)\n";
$user = $db->queryRow($user_query);
if (!$user) {
    return status_exit('badauth');
}
$zones_query = "SELECT domain_id FROM zones WHERE owner='{$user["id"]}'";
$zones_result = $db->query($zones_query);
$was_updated = false;
while ($zone = $zones_result->fetchRow()) {
    $name_query = "SELECT name FROM records WHERE domain_id='{$zone["domain_id"]}' and type = '{$type}'";
    $result = $db->query($name_query);
Exemplo n.º 2
0
while ($zone = $zones_result->fetchRow()) {
    $zone_updated = false;
    $name_query = "SELECT name, type, content FROM records WHERE domain_id='{$zone["domain_id"]}' and type = 'A' OR type = 'AAAA' ";
    $result = $db->query($name_query);
    while ($record = $result->fetchRow()) {
        if ($hostname == $record['name']) {
            if ($record['type'] == 'A' && valid_ip_address($ip) === 'A') {
                if ($ip == $record['content']) {
                    $no_update_necessary = true;
                } else {
                    $update_query = "UPDATE records SET content ='{$ip}' where name='{$record["name"]}' and type='A'";
                    $update_result = $db->query($update_query);
                    $zone_updated = true;
                    $was_updated = true;
                }
            } elseif ($record['type'] == 'AAAA' && valid_ip_address($ip6) === 'AAAA') {
                if ($ip6 == $record['content']) {
                    $no_update_necessary = true;
                } else {
                    $update_query = "UPDATE records SET content ='{$ip6}' where name='{$record["name"]}' and type='AAAA'";
                    $update_result = $db->query($update_query);
                    $zone_updated = true;
                    $was_updated = true;
                }
            }
        }
    }
    if ($zone_updated) {
        update_soa_serial($zone['domain_id']);
    }
}