/**
 * int main() for debugging
 */
function debug_connection()
{
    // Don't show warnings here since then we would just have the same messages two times
    error_reporting(0);
    /*
     * Check if dns to database is resolving correctly
     */
    $db_ips = check_dns();
    /**
     * Check if port to database is open
     * Check all databases in case this resolves to multiple ones
     */
    if (!empty($db_ips)) {
        $result = check_open_ports($db_ips);
    }
    /**
     * If mysql is running try to determine what went wrong
     */
    if ($result) {
        check_mysql_connection($db_ips[0], DB_USER, DB_PASSWORD, DB_NAME);
    }
}
Exemple #2
0
    }
    foreach ($dns_servers as $dns_server) {
        echo "\n" . $dns_server . ' (' . gethostbyaddr($dns_server) . ") AXFR {$domain}\n";
        $result = NULL;
        $r = new Net_DNS2_Resolver(array('nameservers' => array($dns_server)));
        try {
            $result = $r->query($domain, 'AXFR');
        } catch (Net_DNS2_Exception $e) {
            echo "::query() failed: ", $e->getMessage(), "\n";
        }
        if ($result) {
            foreach ($result->answer as $rr) {
                if (preg_match('/ IN NS /i', $rr) && !preg_match("/^{$domain}/i", $rr)) {
                    echo "{$rr}\n";
                    $ns = rtrim(reset(explode(' ', $rr)), '.');
                    array_push($todo, $ns);
                } else {
                    echo "{$rr}\n";
                }
            }
        }
    }
    $todo = array_unique($todo);
    return $todo;
}
foreach ($todo as $domain_axfr) {
    check_dns($domain_axfr);
}
?>
 
function check_prot($host, $port, $key, $dns_solve, $ping)
{
    global $red, $green;
    //ping以外の確認
    foreach ($port as $prot => $num) {
        //pingが失敗した場合は各プロトコルを赤にする
        if ($ping != 0) {
            $value[$prot] = $red;
        } else {
            //pingが成功したからDNSとその他のチェック
            if ($prot == "dns") {
                $value[$prot] = check_dns($host, $dns_solve, $ping);
            } else {
                $value[$prot] = check_tcp($host, $num);
            }
            //dns以外の閉じる
        }
        //ping成功時の閉じる
    }
    //foreachの閉じる
    return $value;
}
{
    $dns = dns_get_record($host, DNS_ANY);
    return $dns;
}
$i = 0;
function prepare_data($array)
{
    if (!is_array($array)) {
        return "<error>";
    } else {
        $str = array();
        foreach ($array as $item) {
            if (isset($item['ip'])) {
                $str[] = $item['ip'];
            }
            if (isset($item['target'])) {
                $str[] = $item['target'];
            }
        }
        return join("\t", $str);
    }
}
foreach ($zones[1] as $zone) {
    if (strlen($zone) > 3) {
        $info = check_dns($zone);
        $str = $zone . " " . prepare_data($info) . "\n";
        file_put_contents("/php/includes/dns.log", $str, FILE_APPEND);
        echo $i . " " . $str;
        $i++;
    }
}