function getWhois(){
     //Fetch the WHOIS data if the WHOIS variable is currently empty
     if ( !isset($this->whois) ){
         $whois = new Whois();
         $text = $whois->Lookup($this->getDomain());
         $this->whois = implode("\r\n",$text['rawdata']);
         return $text;
     }
     //Return the whois
     return $this->whois;
 }
Beispiel #2
0
function get_whois($ip)
{
    require_once JPATH_ADMINISTRATOR . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_bfstop' . DIRECTORY_SEPARATOR . 'helpers' . DIRECTORY_SEPARATOR . 'phpwhois' . DIRECTORY_SEPARATOR . 'whois.main.php';
    require_once JPATH_ADMINISTRATOR . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_bfstop' . DIRECTORY_SEPARATOR . 'helpers' . DIRECTORY_SEPARATOR . 'phpwhois' . DIRECTORY_SEPARATOR . 'whois.utils.php';
    $whois = new Whois();
    $whois->non_icann = true;
    $result = $whois->Lookup($ip);
    $winfo = '';
    if (!empty($result['rawdata'])) {
        $utils = new utils();
        return $utils->showHTML($result);
    } else {
        if (isset($whois->Query['errstr'])) {
            $winfo = implode("\n<br></br>", $whois->Query['errstr']);
        } else {
            $winfo = 'Unexpected error';
        }
    }
    return $winfo;
}
function whoissave_perform($familysite)
{
    $GLOBALS["Q"] = new mysql_squid_builder();
    include_once dirname(__FILE__) . '/ressources/whois/whois.main.php';
    $domain = $familysite;
    $FamilySite = $GLOBALS["Q"]->GetFamilySites($domain);
    $whois = new Whois();
    writelogs("->Lookup({$domain})", __FUNCTION__, __FILE__, __LINE__);
    $result = $whois->Lookup($domain);
    if (!is_array($result)) {
        writelogs("->Lookup({$FamilySite})", __FUNCTION__, __FILE__, __LINE__);
        $result = $whois->Lookup($FamilySite);
    }
    if (!is_array($result)) {
        writelogs("Not an array....", __FUNCTION__, __FILE__, __LINE__);
        return;
    }
    $whoisdatas = addslashes(serialize($result));
    writelogs("{$whoisdatas}", __FUNCTION__, __FILE__, __LINE__);
    $sql = "SELECT familysite FROM `visited_sites` WHERE familysite='{$Familysite}'";
    $ligne = mysql_fetch_array($GLOBALS["Q"]->QUERY_SQL($sql));
    if ($ligne["familysite"] == null) {
        $sql = "UPDATE visited_sites SET whois='{$whoisdatas}' WHERE familysite='{$FamilySite}'";
    } else {
        $sql = "UPDATE visited_sites SET whois='{$whoisdatas}' WHERE sitename='{$domain}'";
    }
    $GLOBALS["Q"]->QUERY_SQL($sql);
    if (!$GLOBALS["Q"]->ok) {
        writelogs("{$sql}:{$GLOBALS["Q"]->mysql_error}", __FUNCTION__, __FILE__, __LINE__);
        echo "{$GLOBALS["Q"]->mysql_error}\n";
        return;
    }
}
    function render_tab1()
    {
        global $aio_wp_security;
        ?>

        <h2><?php 
        _e('WHOIS Lookup Information', 'aiowpsecurity');
        ?>
</h2>
        <div class="aio_blue_box">
            <?php 
        echo '<p>' . __('This feature allows you to look up more detailed information about an IP address or domain name by querying the WHOIS API.', 'aiowpsecurity') . '
            </p>';
        ?>

        </div>

        <div class="postbox">
        <h3><label for="title"><?php 
        _e('Perform a WHOIS Lookup for an IP or Domain Name', 'aiowpsecurity');
        ?>
</label></h3>
        <div class="inside">
            <form action="" method="POST">
                <?php 
        wp_nonce_field('aiowpsec-whois-lookup-nonce');
        ?>

                <table class="form-table">
                <tr valign="top">
                    <th scope="row"><?php 
        _e('Enter IP Address or Domain Name', 'aiowpsecurity');
        ?>
:</th>
                    <td><input type="text" size="20" name="aiowps_whois_lookup_field" value="<?php 
        //echo $aio_wp_security->configs->get_value('aiowps_whois_lookup_field');
        ?>
" />
                    <span class="description"><?php 
        _e('Enter an IP address or domain name. Example: 111.11.12.13 OR some-domain-name.com', 'aiowpsecurity');
        ?>
</span>
                    </td> 
                </tr>
                </table>
                <input type="submit" name="aiowps_whois_lookup" value="<?php 
        _e('Perform IP or Domain Lookup', 'aiowpsecurity');
        ?>
" class="button-primary ip-domain-lookup" />
            </form>
        </div></div>
    <?php 
        if (isset($_POST['aiowps_whois_lookup'])) {
            $nonce = $_REQUEST['_wpnonce'];
            if (!wp_verify_nonce($nonce, 'aiowpsec-whois-lookup-nonce')) {
                $aio_wp_security->debug_logger->log_debug("Nonce check failed on WHOIS lookup!", 4);
                die("Nonce check failed on WHOIS lookup!");
            }
            require_once AIO_WP_SECURITY_LIB_PATH . '/whois/whois.main.php';
            require_once AIO_WP_SECURITY_LIB_PATH . '/whois/whois.utils.php';
            $input_val = trim($_POST['aiowps_whois_lookup_field']);
            if (filter_var($input_val, FILTER_VALIDATE_IP) || filter_var(gethostbyname($input_val), FILTER_VALIDATE_IP)) {
                //$info_msg_string = '<p class="aio_info_with_icon">'.sprintf( __('WHOIS lookup successfully completed. Please see the results below:', 'aiowpsecurity')).'</p>';
                //echo ($info_msg_string);
                $this->show_msg_updated(__('WHOIS lookup successfully completed. Please see the results below:', 'aiowpsecurity'));
                $whois = new Whois();
                $result = $whois->Lookup($input_val);
                if (!empty($result['rawdata'])) {
                    $utils = new utils();
                    $winfo = $utils->showHTML($result);
                    echo $winfo;
                }
            } else {
                $this->show_msg_error(__('You have entered an incorrectly formatted IP address or domain name. Please try again.', 'aiowpsecurity'));
            }
        }
    }
Beispiel #5
0
 } else {
     $output = '';
 }
 include_once 'src/whois.main.php';
 include_once 'src/whois.utils.php';
 $whois = new Whois();
 // Set to true if you want to allow proxy requests
 $allowproxy = false;
 // get faster but less acurate results
 $whois->deep_whois = empty($_GET['fast']);
 // To use special whois servers (see README)
 //$whois->UseServer('uk','whois.nic.uk:1043?{hname} {ip} {query}');
 //$whois->UseServer('au','whois-check.ausregistry.net.au');
 // Comment the following line to disable support for non ICANN tld's
 $whois->non_icann = true;
 $result = $whois->Lookup($query);
 $resout = str_replace('{query}', $query, $resout);
 $winfo = '';
 switch ($output) {
     case 'object':
         if ($whois->Query['status'] < 0) {
             $winfo = implode($whois->Query['errstr'], "\n<br></br>");
         } else {
             $utils = new utils();
             $winfo = $utils->showObject($result);
         }
         break;
     case 'nice':
         if (!empty($result['rawdata'])) {
             $utils = new utils();
             $winfo = $utils->showHTML($result);
Beispiel #6
0
function signup_ip_ban($user_ip, $comment)
{
    global $THIS_BASEPATH, $CURUSER, $TABLE_PREFIX, $DBDT;
    $include = $THIS_BASEPATH . "/whois/whois.main.php";
    if (@file_exists($include)) {
        include_once $include;
        $whois = new Whois();
        $result = $whois->Lookup($user_ip);
        $iplist = explode("-", preg_replace("/\\ /", "", $result["regrinfo"]["network"]["inetnum"]));
        if (!$iplist[1]) {
            // The IP address is listed in CIDR form eg 127.0/16 etc.
            $iplist = cidr_decode($result["regrinfo"]["network"]["inetnum"]);
        }
        $found = @mysqli_fetch_assoc(@mysqli_query($GLOBALS["___mysqli_ston"], "SELECT `id` FROM `{$TABLE_PREFIX}signup_ip_block` WHERE `first_ip`=INET_ATON('{$iplist['0']}') AND `last_ip`=INET_ATON('{$iplist['1']}')"));
        if (!$found) {
            // Create a new record
            $query = "INSERT INTO `{$TABLE_PREFIX}signup_ip_block` ";
            $query .= "SET `first_ip`=INET_ATON('{$iplist['0']}'), ";
            $query .= "`last_ip`=INET_ATON('{$iplist['1']}'), ";
            $query .= "`added`=UNIX_TIMESTAMP(), ";
            $query .= "`addedby`='" . $CURUSER["username"] . "', ";
            $query .= "`comment`='" . mysqli_real_escape_string($DBDT, $comment) . "'";
            @mysqli_query($GLOBALS["___mysqli_ston"], $query);
        } else {
            // Update the timestamp on the pre-existing record to extend the ban.
            @mysqli_query($GLOBALS["___mysqli_ston"], "UPDATE `{$TABLE_PREFIX}signup_ip_block` SET `added`=UNIX_TIMESTAMP(), `addedby`='" . $CURUSER["username"] . "' WHERE `id`=" . $found["id"]);
        }
    } else {
        // They don't have the required PHPWhois files so do nothing and exit the function
        return;
    }
}
Beispiel #7
0
Copyright (C)1999,2005 easyDNS Technologies Inc. & Mark Jeftovic

Maintained by David Saez

For the most recent version of this package visit:

http://www.phpwhois.org

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
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, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
*/
include 'whois.main.php';
if (isset($argv[1])) {
    $domain = $argv[1];
} else {
    $domain = 'example.com';
}
$whois = new Whois();
$result = $whois->Lookup($domain);
print_r($result);
 public static function ajax_whois_callback()
 {
     if (!class_exists('Whois')) {
         require_once 'whois/whois.main.php';
     }
     $val = trim($_POST['val']);
     $val = preg_replace('/[^a-zA-Z0-9\\.\\-]+/', '', $val);
     $whois = new Whois();
     $result = $whois->Lookup($val);
     return array('ok' => 1, 'result' => $result);
 }
Beispiel #9
0
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    //donation historie DT end
    $userdetailtpl->set("userdetail_last_ip", $row["cip"] . "&nbsp;&nbsp;&nbsp;<a href=index.php?page=iplog&id={$id}><img src=images/icon_ip.gif border=0></a>");
    // Start - Whois check by Petr1fied
    include_once "whois/whois.main.php";
    $whois = new Whois();
    $result = $whois->Lookup($row["cip"]);
    $output = "<pre>";
    $i = 0;
    while ($i < count($result["rawdata"])) {
        $i++;
        $output .= $result["rawdata"][$i] . "<br />";
    }
    $output .= "</pre>";
    $userdetailtpl->set("userdetail_whois", $output);
    // End - Whois check by Petr1fied
    $userdetailtpl->set("userdetail_level_admin", $row["level"]);
    $userdetailtpl->set("userdetail_colspan", "2");
} else {
    $userdetailtpl->set("userdetail_level", $row["level"]);
    $userdetailtpl->set("userdetail_colspan", "0");
}
function getwhois($domain, $tld)
{
    $override = apply_filters('pre_getwhois', false, $domain, $tld);
    if ($override !== false) {
        return $override;
    }
    if (empty($domain)) {
        $domain = nebula_url_components('sld');
        //Default value is current domain
    }
    if (empty($tld)) {
        $tld = nebula_url_components('tld');
        //Default value is current domain
    }
    require_once get_template_directory() . "/includes/libs/class-whois.php";
    $whois = new Whois();
    if (!$whois->ValidDomain($domain . '.' . $tld)) {
        return 'Sorry, "' . $domain . '.' . $tld . '" is not valid or not supported.';
    }
    if ($whois->Lookup($domain . '.' . $tld)) {
        return $whois->GetData(1);
    } else {
        return 'A WHOIS error occurred.';
    }
}
Beispiel #11
0
function visited_sites_whois()
{
    $unix = new unix();
    if (!$GLOBALS["FORCE"]) {
        $timefile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".time";
        $timeOfFile = $unix->file_time_min($timefile);
        if ($timeOfFile < 520) {
            return;
        }
        @unlink($timefile);
        @file_put_contents($timefile, time());
    }
    $t1 = time();
    $sql = "SELECT familysite FROM visited_sites WHERE whois IS NULL AND `familysite`!='ipaddr' AND LENGTH(familysite)>0";
    $results = $GLOBALS["Q"]->QUERY_SQL($sql);
    if (!$GLOBALS["Q"]->ok) {
        stats_admin_events(0, $q->mysql_error, null, __FILE__, __LINE__);
        return;
    }
    $num_rows = mysql_num_rows($results);
    stats_admin_events(2, "visited_sites -> whois -> {$num_rows} rows", null, __FILE__, __LINE__);
    if ($num_rows == 0) {
        if ($GLOBALS["VERBOSE"]) {
            echo "No datas `{$sql}`" . __FUNCTION__ . " " . __LINE__ . "\n";
        }
        return;
    }
    $c = 0;
    $f = 0;
    $already = array();
    $MinutesFile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".minutes";
    @unlink($MinutesFile);
    @file_put_contents($MinutesFile, time());
    $D = 0;
    while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
        $D++;
        $domain = $ligne["familysite"];
        if (strpos($domain, ".") == 0) {
            continue;
        }
        if (!isset($already[$domain])) {
            $whois = new Whois();
            $result = $whois->Lookup($domain);
            $already[$domain] = $result;
            $c++;
        } else {
            continue;
        }
        if (!is_array($result)) {
            if ($GLOBALS["VERBOSE"]) {
                echo "{$domain} no results...\n";
                $f++;
                continue;
            }
        }
        $whoisdatas = addslashes(serialize($result));
        $TimeLoop = $unix->file_time_min($MinutesFile);
        if ($TimeLoop > 4) {
            if (count($ROWS_visited_sites_prefix) > 0) {
                $GLOBALS["Q"]->QUERY_SQL($ROWS_visited_sites_prefix . @implode(",", $ROWS_visited_sites_catz));
                $ROWS_visited_sites_catz = array();
            }
            stats_admin_events(2, "{$D}/{$num_rows} rows", null, __FILE__, __LINE__);
            if (SquidStatisticsTasksOverTime()) {
                stats_admin_events(1, "Statistics overtime... Aborting", null, __FILE__, __LINE__);
                return;
            }
            @unlink($MinutesFile);
            @file_put_contents($MinutesFile, time());
        }
        if ($GLOBALS["VERBOSE"]) {
            echo "update {$domain} width " . strlen($whoisdatas) . " bytes\n";
        }
        $sql = "UPDATE visited_sites SET whois='{$whoisdatas}' WHERE familysite='{$domain}'";
        $GLOBALS["Q"]->QUERY_SQL($sql);
        if (!$GLOBALS["Q"]->ok) {
            echo "{$GLOBALS["Q"]->mysql_error}\n";
            return;
        }
    }
    if ($c > 0) {
        $unix = new unix();
        $took = $unix->distanceOfTimeInWords($t1, time());
        stats_admin_events(2, "WHOIS: {$c} visisted websites informations updated {$f} failed, {$took}", null, __FILE__, __LINE__, "visited");
    }
}
 public static function ajax_whois_callback()
 {
     require_once 'whois/whois.main.php';
     $val = trim($_POST['val']);
     $whois = new Whois();
     $result = $whois->Lookup($val);
     return array('ok' => 1, 'result' => $result);
 }
Beispiel #13
0
<?php

include "whois/main.whois";
$whois = new Whois($_GET['query']);
$result = $whois->Lookup();
echo "<pre>";
for ($i = 0; $i < count($result[rawdata]); $i++) {
    $row = each($result[rawdata]);
    echo $row["value"] . "\n";
}
echo "</pre>";
Beispiel #14
0
/**
* Validate domain exists
*
* @param $domain - domain to check
* @param $return host - if true, will return the host name
* $return bool or host string
*/
function verifyDomain($h, $domain, $return_host = true)
{
    // from http://stackoverflow.com/questions/1755144/how-to-validate-domain-name-in-php
    if (!filter_var(gethostbyname($domain), FILTER_VALIDATE_IP) && !filter_var(gethostbyname($domain), FILTER_VALIDATE_URL)) {
        $h->messages[$h->lang('global_functions_error_message_no_such_domain')] = "red";
        return false;
    }
    if ($return_host) {
        $parsed_url = parse_url($domain, PHP_URL_HOST);
        // if it came in just as the domain, we will return that as, otherwise, it will be false
        if (!$parsed_url) {
            $parsed_url = $domain;
        }
        $check = is_ip($parsed_url);
        $host = $parsed_url;
        if (!$check) {
            $host = !$host ? domain($host) : domain($domain);
        }
        // this function doesn't work so good - kludge
        if (substr($host, 0, 1) == '.') {
            $host = substr($host, 1);
        }
        // we don't need to verify ourselves
        if ($host == SITEURL) {
            return $host;
        }
        // from http://sourceforge.net/projects/phpwhois/?source=dlp
        //include(EXTENSIONS . 'phpwhois/whois.main.php');
        $whois = new Whois();
        $whois->deep_whois = false;
        $result = $whois->Lookup($host, false);
        if (isset($result['regrinfo']['registered']) && $result['regrinfo']['registered'] == 'yes') {
            // if host starts with www, we will remove
            if (substr(strtolower($host), 0, 4) === 'www.') {
                $host = substr($host, 4);
            }
            return $host;
        }
        $h->messages[$h->lang('global_functions_error_message_no_such_domain')] = "red";
        return false;
    }
    return true;
}
function GetPageInfos($sitename)
{
    include_once dirname(__FILE__) . "/ressources/class.html2text.inc";
    if (strpos(" {$sitename}", "http") == 0) {
        $sitename = "http://{$sitename}";
    }
    echo "{$sitename}\n";
    $curl = new ccurl("{$sitename}");
    $curl->NoHTTP_POST = true;
    if (!$curl->get()) {
        echo "{$sitename} -> error: \n" . $curl->error . "\n";
        return;
    }
    $datas = explode("\n", $curl->data);
    while (list($num, $ligne) = each($datas)) {
        if (preg_match("#^Location:\\s+(.+)#", $ligne, $re)) {
            return GetPageInfos($re[1]);
        }
    }
    if (preg_match("#<head>(.*?)</head>#is", $curl->data, $re)) {
        $HEAD = utf8_encode($re[1]);
    }
    if (preg_match("#<body.*?>(.*?)</body>#is", $curl->data, $re)) {
        $BODY = utf8_encode($re[1]);
    }
    if (preg_match("#<title>(.*?)</title>#is", $HEAD, $re)) {
        $TITLE = $re[1];
    }
    if (preg_match_all("#http.*?:\\/\\/(.+?)[\\/\\s\"]+#is", $curl->data, $re)) {
        while (list($num, $ligne) = each($re[1])) {
            if (preg_match("#^www\\.(.*)#", $ligne, $Z)) {
                $ligne = $Z[1];
            }
            $SUBSITES[$ligne] = true;
        }
        while (list($num, $ligne) = each($SUBSITES)) {
            $sitenames[] = $num;
        }
    }
    if (preg_match("#<meta name=.*?description.*?content=(.+?)>#is", $HEAD, $re)) {
        $re[1] = str_replace('"', "", $re[1]);
        $array["DESCRIPTION"] = $re[1];
    }
    if (preg_match("#<meta name=.*?keywords.*?content=(.+?)>#is", $HEAD, $re)) {
        $re[1] = str_replace('"', "", $re[1]);
        $array["KEYWORDS"] = $re[1];
    }
    $array["TITLE"] = $TITLE;
    while (list($num, $ligne) = each($sitenames)) {
        $array["SITENAMES"][$ligne] = $ligne;
    }
    // http://www.chuggnutt.com/html2text
    $h2t = new html2text($BODY);
    $text = $h2t->get_text();
    while (list($num, $ligne) = each($h2t->_link_array)) {
        if (trim($ligne) == null) {
            continue;
        }
        $array["URIS"][] = $ligne;
    }
    $array["TEXT"] = $h2t->_TEXT;
    include_once dirname(__FILE__) . '/ressources/whois/whois.main.php';
    $whois = new Whois();
    $array["WHOIS"] = $whois->Lookup($sitename);
    return unserialize($array);
}
 public function lookup()
 {
     $view = $this->getView();
     $request = $this->getPageRequest();
     $query = $request->getParameter('q');
     $view->contenttype = View::CTYPE_JSON;
     $view->mode = View::MODE_AJAX;
     $view->record = false;
     $result = Whois::Lookup($query);
     $view->jsondata = ['query' => $query, 'ip' => $result->getIP(), 'network' => $result->getNetwork(), 'organization' => $result->getOrganization(), 'country' => $result->getCountry(), 'country_name' => $result->getCountryName(), 'flag_sm' => $result->getCountryIcon('20x20'), 'flag_lg' => $result->getCountryIcon('100x100')];
 }