Exemplo n.º 1
0
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
require_once "inc/toolkit.inc.php";
include_once "inc/header.inc.php";
$master_ip = "-1";
if (isset($_GET['master_ip']) && (is_valid_ipv4($_GET['master_ip']) || is_valid_ipv6($_GET['master_ip']))) {
    $master_ip = $_GET['master_ip'];
}
$confirm = "-1";
if (isset($_GET['confirm']) && v_num($_GET['confirm'])) {
    $confirm = $_GET['confirm'];
}
if ($master_ip == "-1") {
    error(ERR_INV_INPUT);
} else {
    verify_permission('supermaster_edit') ? $perm_sm_edit = "1" : ($perm_sm_edit = "0");
    if ($perm_sm_edit == "0") {
        error(ERR_PERM_DEL_SM);
    } else {
        $info = get_supermaster_info_from_ip($master_ip);
        echo "     <h2>" . _('Delete supermaster') . " \"" . $master_ip . "\"</h2>\n";
Exemplo n.º 2
0
/** Check if Supermaster IP Address and NS Name combo exists
 *
 * @param string $master_ip Supermaster IP Address
 * @param string $ns_name Supermaster NS Name
 *
 * @return boolean true if exists, false otherwise
 */
function supermaster_ip_name_exists($master_ip, $ns_name)
{
    global $db;
    if ((is_valid_ipv4($master_ip) || is_valid_ipv6($master_ip)) && is_valid_hostname_fqdn($ns_name, 0)) {
        $result = $db->queryOne("SELECT ip FROM supermasters WHERE ip = " . $db->quote($master_ip, 'text') . " AND nameserver = " . $db->quote($ns_name, 'text'));
        return $result ? true : false;
    } else {
        error(sprintf(ERR_INV_ARGC, "supermaster_exists", "No or no valid IPv4 or IPv6 address given."));
    }
}
function are_multipe_valid_ips($ips)
{
    // multiple master NS-records are permitted and must be separated by ,
    // eg. "192.0.0.1, 192.0.0.2, 2001:1::1"
    $are_valid = false;
    $multiple_ips = explode(",", $ips);
    if (is_array($multiple_ips)) {
        foreach ($multiple_ips as $m_ip) {
            $trimmed_ip = trim($m_ip);
            if (is_valid_ipv4($trimmed_ip, false) || is_valid_ipv6($trimmed_ip, true)) {
                $are_valid = true;
            } else {
                // as soon there is an invalid ip-addr
                // exit and return false
                echo "hin:={$trimmed_ip}=";
                return false;
            }
        }
    } elseif (is_valid_ipv4($ips) || is_valid_ipv6($ips)) {
        $are_valid = true;
    }
    if ($are_valid) {
        return true;
    } else {
        return false;
    }
}
Exemplo n.º 4
0
    $master = $_POST['slave_master'];
}
$type = "SLAVE";
/*
 Check permissions
*/
do_hook('verify_permission', 'zone_slave_add') ? $zone_slave_add = "1" : ($zone_slave_add = "0");
do_hook('verify_permission', 'user_view_others') ? $perm_view_others = "1" : ($perm_view_others = "0");
if (isset($_POST['submit']) && $zone_slave_add == "1") {
    if (!is_valid_hostname_fqdn($zone, 0)) {
        error(ERR_DNS_HOSTNAME);
    } elseif ($dns_third_level_check && get_domain_level($zone) > 2 && domain_exists(get_second_level_domain($zone))) {
        error(ERR_DOMAIN_EXISTS);
    } elseif (domain_exists($zone) || record_name_exists($zone)) {
        error(ERR_DOMAIN_EXISTS);
    } elseif (!is_valid_ipv4($master, false) && !is_valid_ipv6($master)) {
        error(ERR_DNS_IP);
    } else {
        if (add_domain($zone, $owner, $type, $master, 'none')) {
            success("<a href=\"edit.php?id=" . get_zone_id_from_name($zone) . "\">" . SUC_ZONE_ADD . '</a>');
            log_info(sprintf('client_ip:%s user:%s operation:add_zone zone:%s zone_type:SLAVE zone_master:%s', $_SERVER['REMOTE_ADDR'], $_SESSION["userlogin"], $zone, $master, $zone_template));
            unset($zone, $owner, $webip, $mailip, $empty, $type, $master);
        }
    }
}
if ($zone_slave_add != "1") {
    error(ERR_PERM_ADD_ZONE_SLAVE);
} else {
    echo "     <h2>" . _('Add slave zone') . "</h2>\n";
    $users = do_hook('show_users');
    echo "     <form method=\"post\" action=\"add_zone_slave.php\">\n";
Exemplo n.º 5
0
function change_zone_slave_master($zone_id, $ip_slave_master)
{
    global $db;
    if (is_numeric($zone_id)) {
        if (is_valid_ipv4($ip_slave_master) || is_valid_ipv6($ip_slave_master)) {
            $result = $db->query("UPDATE domains SET master = " . $db->quote($ip_slave_master, 'text') . " WHERE id = " . $db->quote($zone_id, 'integer'));
        } else {
            error(sprintf(ERR_INV_ARGC, "change_domain_ip_slave_master", "This is not a valid IPv4 or IPv6 address: {$ip_slave_master}"));
        }
    } else {
        error(sprintf(ERR_INV_ARG, "change_domain_type", "no or no valid zoneid given"));
    }
}
Exemplo n.º 6
0
<?php

require 'wersja.inc';
define("dirpath", dirname($_SERVER["SCRIPT_FILENAME"]) . '/');
define("webpath", 'http://' . $_SERVER['SERVER_ADDR'] . ':' . $_SERVER['SERVER_PORT'] . dirname($_SERVER['PHP_SELF']) . '/');
define("imgpath", dirpath . 'image/');
function is_valid_ipv4($ips)
{
    return preg_match('/\\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.' . '(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.' . '(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.' . '(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\b/', $ips) !== 0;
}
$ip = shell_exec("/sbin/ifconfig | grep 'inetd '| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print \$1}'");
if (is_valid_ipv4($ip) == 0) {
    $ip = shell_exec("/sbin/ifconfig | grep 'inet addr:' | grep -v '127.0.0.1' | cut -d: -f2 | cut -d' ' -f1");
    if (is_valid_ipv4($ip) == 0) {
        $ip = "ADRES-IP";
    }
}
$adresip = 'http://' . trim($ip) . ':' . $_SERVER['SERVER_PORT'] . dirname($_SERVER['PHP_SELF']) . '/ustawienia.php';
echo '<?xml version="1.0" encoding="UTF-8" ?>' . "\n";
echo '<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
<mediaDisplay name="onePartView" backgroundColor="0:0:0" showHeader="no" showDefaultInfo="no">

<image redraw="no" offsetXPC="20" offsetYPC="15" widthPC="15" heightPC="26">' . dirpath . 'plims.png</image>

<text redraw="no" offsetXPC="40" offsetYPC="17" fontSize="24" widthPC="20" heightPC="7" backgroundColor="-1:-1:-1" foregroundColor="70:140:210" align="left">PLIMS ' . WERSJA . '</text>

<text redraw="no" offsetXPC="40" offsetYPC="27" fontSize="15" widthPC="16" heightPC="5" backgroundColor="-1:-1:-1" foregroundColor="70:140:210" align="left">Programowanie:</text>

<text redraw="no" offsetXPC="57" offsetYPC="27" fontSize="15" widthPC="25" heightPC="5" backgroundColor="-1:-1:-1" foregroundColor="0:255:210" align="left">mikka, Xury &amp; dobosz23</text>

<text redraw="no" offsetXPC="40" offsetYPC="34" fontSize="15" widthPC="16" heightPC="5" backgroundColor="-1:-1:-1" foregroundColor="70:140:210" align="left">Grafika:</text>
Exemplo n.º 7
0
function validate_input($zid, $type, &$content, &$name, &$prio, &$ttl)
{
    $zone = get_zone_name_from_id($zid);
    // TODO check for return
    if (!preg_match("/{$zone}\$/i", $name)) {
        if (isset($name) && $name != "") {
            $name = $name . "." . $zone;
        } else {
            $name = $zone;
        }
    }
    switch ($type) {
        case "A":
            if (!is_valid_ipv4($content)) {
                return false;
            }
            if (!is_valid_hostname_fqdn($name, 1)) {
                return false;
            }
            break;
        case "AAAA":
            if (!is_valid_ipv6($content)) {
                return false;
            }
            if (!is_valid_hostname_fqdn($name, 1)) {
                return false;
            }
            break;
        case "CNAME":
            if (!is_valid_rr_cname_name($name)) {
                return false;
            }
            if (!is_valid_hostname_fqdn($name, 1)) {
                return false;
            }
            if (!is_valid_hostname_fqdn($content, 0)) {
                return false;
            }
            break;
        case "HINFO":
            if (!is_valid_rr_hinfo_content($content)) {
                return false;
            }
            if (!is_valid_hostname_fqdn($name, 1)) {
                return false;
            }
            break;
        case "MX":
            if (!is_valid_hostname_fqdn($content, 0)) {
                return false;
            }
            if (!is_valid_hostname_fqdn($name, 1)) {
                return false;
            }
            if (!is_valid_non_alias_target($content)) {
                return false;
            }
            break;
        case "NS":
            if (!is_valid_hostname_fqdn($content, 0)) {
                return false;
            }
            if (!is_valid_hostname_fqdn($name, 1)) {
                return false;
            }
            if (!is_valid_non_alias_target($content)) {
                return false;
            }
            break;
        case "PTR":
            if (!is_valid_hostname_fqdn($content, 0)) {
                return false;
            }
            if (!is_valid_hostname_fqdn($name, 1)) {
                return false;
            }
            break;
        case "SOA":
            if (!is_valid_rr_soa_name($name, $zone)) {
                return false;
            }
            if (!is_valid_hostname_fqdn($name, 1)) {
                return false;
            }
            if (!is_valid_rr_soa_content($content)) {
                return false;
            }
            break;
        case "SRV":
            if (!is_valid_rr_srv_name($name)) {
                return false;
            }
            if (!is_valid_rr_srv_content($content)) {
                return false;
            }
            break;
        case "TXT":
            if (!is_valid_printable($name)) {
                return false;
            }
            if (!is_valid_printable($content)) {
                return false;
            }
            break;
        case "MBOXFW":
        case "NAPTR":
        case "SPF":
        case "SSHFP":
        case "URL":
            // These types are supported by PowerDNS, but there is not
            // yet code for validation. Validation needs to be added
            // for these types. One Day Real Soon Now. [tm]
            break;
        default:
            error(ERR_DNS_RR_TYPE);
            return false;
    }
    if (!is_valid_rr_prio($prio, $type)) {
        return false;
    }
    if (!is_valid_rr_ttl($ttl)) {
        return false;
    }
    return true;
}
Exemplo n.º 8
0
} else {
    $mailip = "";
}
if (isset($_POST['empty'])) {
    $empty = $_POST['empty'];
}
verify_permission('zone_master_add') ? $zone_master_add = "1" : ($zone_master_add = "0");
if (isset($_POST['submit']) && $zone_master_add == "1") {
    // Boy. I will be happy when I have found the time to replace
    // this "template wanabee" code with something that is really
    // worth to be called "templating". Whoever wrote this should
    // be... should be... how can I say this politicaly correct?
    // 20080303/RZ
    if (!$empty) {
        $empty = 0;
        if (!eregi('in-addr.arpa', $domain) && (!is_valid_ipv4($webip) || !is_valid_ipv4($mailip))) {
            error(_('IP address of web- or mailserver is invalid.'));
            $error = "1";
        }
    }
    if (!$error) {
        if (!is_valid_hostname_fqdn($domain, 0)) {
            error(ERR_DOMAIN_INVALID);
            $error = "1";
        } elseif (domain_exists($domain)) {
            error(ERR_DOMAIN_EXISTS);
            $error = "1";
        } else {
            if (add_domain($domain, $owner, $webip, $mailip, $empty, $dom_type, '')) {
                success(SUC_ZONE_ADD);
                unset($domain, $owner, $webip, $mailip, $empty, $dom_type);