Pagina 2 di 2 primaprima 1 2
Visualizzazione dei risultati da 11 a 12 su 12

Discussione: script whois problema

  1. #11
    preciso il mio problema

    ho una pagina in php che controlla la stato dei suffissi .it, com ecc ecc. la pagina doveva rispondere 200 se libero e il who is se occupato. naturalmente non funziona xche in entrambi i risultati lo script whois da le info. se disponibile lo script carica le info dal nic dicendo che il dominio è disponibile mentre se occupato mi da il whois. in questo modo non posso differenziare else if.

    ho notato nello script del who is
    var $STAT = array(-1=>"error",0=>"ready",1=>"ok");

    lo script è composto da sample1.php
    <?
    if(isSet($query)) {
    include("main.whois");
    $whois = new Whois($query);
    $result = $whois->Lookup();
    echo "Risultato per il dominio $query :

    ";
    if(isSet($whois->Query["errstr"])) {
    echo "Errors:
    ".implode($whois->Query["errstr"],"<");
    }
    if($output=="object") {
    include("utils.whois");
    $utils = new utils;
    $utils->showObject($result);
    } else {
    if(!empty($result["rawdata"])) {
    echo implode($result["rawdata"],"\n");
    } else { echo ""; }
    }
    }
    ?>


    e main.whois

    <?
    /*

    class Whois {

    var $VERSION;
    var $CODE_VERSION = "2.2-3";
    var $NSI_REGISTRY = "whois.nsiregistry.net";
    var $NSI_REGISTRAR = "whois.networksolutions.com";
    var $PORT = 43;
    var $RETRY = 0; // maximum number of retries on connect
    var $SLEEP = 2;
    var $BUFFER = 0; // read buffer size, 0 means char by char

    var $STAT = array(-1=>"error",0=>"ready",1=>"ok");

    var $Query = array(
    "tld"=>"",
    "type"=>"domain",
    "string"=>"",
    "status",
    "server"
    );

    #
    # these are hacks. In a perfect world we don't need these
    # but here we are nonetheless...
    #
    var $HACKS = array(
    "nsi_force_dom"=>1, # force "dom" keyword
    "nsi_referral_loop"=>0, # set if nsiregistry gives wrong whois server for netsol
    "wrong_netsol_whois"=> "rs.internic.net",
    "real_netsol_whois"=> "whois.networksolutions.com",
    "cx_is_broken"=>1 # whois.nic.cx hangs forever
    );

    #
    # $DATA is our list of servers and handlers as listed in servers.whois
    #
    var $DATA = array();

    function Whois ($query="") {
    require("servers.whois");
    $this->VERSION=sprintf("Whois2.php v%s:%s", $this->CODE_VERSION,
    $this->DATA_VERSION);
    if(isSet($query)) {
    $this->Query["string"]=strtolower($query);
    $tld=$this->GetTld($this->Query["string"]);
    if($tld) {
    $this->Query["server"]=$this->DATA[$tld][0];
    if(isSet($this->DATA[$tld][1])) {
    $handler=$this->DATA[$tld][1];
    $this->Query["file"]=sprintf("%s.whois",$handler);
    $this->Query["handler"]=$handler;
    }
    $this->Query["tld"]=$tld;
    } else {
    $this->Query["status"]=-1;
    $this->Query["errstr"][]=$this->Query["string"].
    " domain is not supported";
    unset($this->Query["server"]);
    }
    } else {
    $this->Query["server"]=$this->NSI_REGISTRY;
    }

    }


    // open a socket to the whois server
    // defaults to whois.internic.net if an alternate is not passed
    // returns: a pointer on success, sets $this->ERROR on fail
    function Connect () {
    if(!isSet($this->Query["server"])) { return(-1); }
    $server = $this->Query["server"];
    $retry = 0;
    while($retry <= $this->RETRY):
    $this->$Query["status"]="ready";
    $ptr = fsockopen($server, $this->PORT);
    if($ptr>0):
    $this->$Query["status"]="ok";
    return($ptr);
    else:
    $this->$Query["status"]="error";
    $retry++;
    sleep($this->SLEEP);
    endif;
    endwhile;
    return(-1);
    }

    function Process ($result) {
    $old_val = error_reporting(OFF);
    $HANDLER_FLAG = sprintf("__%s_HANDLER__", strtoupper($this->Query["handler"]));
    if(!defined($HANDLER_FLAG)) { include($this->Query["file"]); }
    error_reporting($old_val);
    if(!defined($HANDLER_FLAG)) {
    $this->Query["errstr"][]="Can't find ".$this->Query["tld"]." handler: ".$this->Query["file"];
    } else {
    $object = $this->Query["handler"];
    $handler = new $object($result, $this->Query);
    if(isSet($handler->Query["errstr"])) {
    $this->Query["errstr"][]=$handler->Query["errstr"];
    }

    return($handler->result);
    }

    return($result);
    }

    function Lookup ($query="") {
    $string = !empty($query) ? $query : $this->Query["string"];
    if($this->HACKS["cx_is_broken"] && $this->Query["tld"]=="cx") {
    $this->Query["errstr"][]=".cx doesn't work. Turn off HACKS[\"cx_is_broken\"] if ".$this->Query["server"]." finally got fixed.";
    return("");
    }
    $ptr=$this->Connect();
    if(empty($this->Query["server"])) { return(false); }
    if($ptr!=-1){
    if(($this->Query["server"]==$this->NSI_REGISTRY
    || $this->Query["server"]==$this->NSI_REGISTRAR)
    && $this->HACKS["nsi_force_dom"]) {
    fputs($ptr, sprintf("dom %s\r\n", trim($string)));
    } else {
    fputs($ptr, sprintf("%s\r\n", trim($string)));
    }
    while(!feof($ptr)) {
    if($this->BUFFER) {
    $output[]=fgets($ptr, $this->BUFFER);
    } else {
    $r.=fgetc($ptr);
    }
    }

    if(!$this->BUFFER) { $output = explode("\n", $r); }
    unset($output[count($output)-1]);
    if(isSet($this->result["rawdata"])) {
    $result = $output;
    } else {
    $result["rawdata"] = $output;
    }
    if(isSet($this->DATA[$this->Query["tld"]][1])) {
    $result = $this->Process($result);
    }
    return($result);
    } else {
    $this->Query["status"]=-1;
    $this->Query["errstr"][]="Connect failed to: ".$this->Query["server"];
    return(array());
    }

    }

    function GetTld ($domain) {
    // unfortunately the only reliable way to do this is
    // to blow through the entire server/tld list
    reset($this->DATA);
    while(list($tld, $param)=each($this->DATA)) {
    if(eregi("\.$tld$", $domain)) {
    if(!empty($curr_match)) {
    // FIXME: we assume we'll never support a 3rd
    // level registry. If we do, this breaks.
    $curr_match = strchr($tld,".") ?
    $tld : $curr_match;
    }
    else { $curr_match = $tld; }
    }
    }
    return($curr_match);
    }

    }


    ?>


    dovrei trovare un modo per riportare su sample1.php il risultato se occupato 0 se libero 1

    chi mi aiuta?


  2. #12
    preciso il mio problema

    ho una pagina in php che controlla la stato dei suffissi .it, com ecc ecc. la pagina doveva rispondere 200 se libero e il who is se occupato. naturalmente non funziona xche in entrambi i risultati lo script whois da le info. se disponibile lo script carica le info dal nic dicendo che il dominio è disponibile mentre se occupato mi da il whois. in questo modo non posso differenziare else if.

    ho notato nello script del who is
    var $STAT = array(-1=>"error",0=>"ready",1=>"ok");

    lo script è composto da sample1.php
    <?
    if(isSet($query)) {
    include("main.whois");
    $whois = new Whois($query);
    $result = $whois->Lookup();
    echo "Risultato per il dominio $query :

    ";
    if(isSet($whois->Query["errstr"])) {
    echo "Errors:
    ".implode($whois->Query["errstr"],"<");
    }
    if($output=="object") {
    include("utils.whois");
    $utils = new utils;
    $utils->showObject($result);
    } else {
    if(!empty($result["rawdata"])) {
    echo implode($result["rawdata"],"\n");
    } else { echo ""; }
    }
    }
    ?>


    e main.whois

    <?
    /*

    class Whois {

    var $VERSION;
    var $CODE_VERSION = "2.2-3";
    var $NSI_REGISTRY = "whois.nsiregistry.net";
    var $NSI_REGISTRAR = "whois.networksolutions.com";
    var $PORT = 43;
    var $RETRY = 0; // maximum number of retries on connect
    var $SLEEP = 2;
    var $BUFFER = 0; // read buffer size, 0 means char by char

    var $STAT = array(-1=>"error",0=>"ready",1=>"ok");

    var $Query = array(
    "tld"=>"",
    "type"=>"domain",
    "string"=>"",
    "status",
    "server"
    );

    #
    # these are hacks. In a perfect world we don't need these
    # but here we are nonetheless...
    #
    var $HACKS = array(
    "nsi_force_dom"=>1, # force "dom" keyword
    "nsi_referral_loop"=>0, # set if nsiregistry gives wrong whois server for netsol
    "wrong_netsol_whois"=> "rs.internic.net",
    "real_netsol_whois"=> "whois.networksolutions.com",
    "cx_is_broken"=>1 # whois.nic.cx hangs forever
    );

    #
    # $DATA is our list of servers and handlers as listed in servers.whois
    #
    var $DATA = array();

    function Whois ($query="") {
    require("servers.whois");
    $this->VERSION=sprintf("Whois2.php v%s:%s", $this->CODE_VERSION,
    $this->DATA_VERSION);
    if(isSet($query)) {
    $this->Query["string"]=strtolower($query);
    $tld=$this->GetTld($this->Query["string"]);
    if($tld) {
    $this->Query["server"]=$this->DATA[$tld][0];
    if(isSet($this->DATA[$tld][1])) {
    $handler=$this->DATA[$tld][1];
    $this->Query["file"]=sprintf("%s.whois",$handler);
    $this->Query["handler"]=$handler;
    }
    $this->Query["tld"]=$tld;
    } else {
    $this->Query["status"]=-1;
    $this->Query["errstr"][]=$this->Query["string"].
    " domain is not supported";
    unset($this->Query["server"]);
    }
    } else {
    $this->Query["server"]=$this->NSI_REGISTRY;
    }

    }


    // open a socket to the whois server
    // defaults to whois.internic.net if an alternate is not passed
    // returns: a pointer on success, sets $this->ERROR on fail
    function Connect () {
    if(!isSet($this->Query["server"])) { return(-1); }
    $server = $this->Query["server"];
    $retry = 0;
    while($retry <= $this->RETRY):
    $this->$Query["status"]="ready";
    $ptr = fsockopen($server, $this->PORT);
    if($ptr>0):
    $this->$Query["status"]="ok";
    return($ptr);
    else:
    $this->$Query["status"]="error";
    $retry++;
    sleep($this->SLEEP);
    endif;
    endwhile;
    return(-1);
    }

    function Process ($result) {
    $old_val = error_reporting(OFF);
    $HANDLER_FLAG = sprintf("__%s_HANDLER__", strtoupper($this->Query["handler"]));
    if(!defined($HANDLER_FLAG)) { include($this->Query["file"]); }
    error_reporting($old_val);
    if(!defined($HANDLER_FLAG)) {
    $this->Query["errstr"][]="Can't find ".$this->Query["tld"]." handler: ".$this->Query["file"];
    } else {
    $object = $this->Query["handler"];
    $handler = new $object($result, $this->Query);
    if(isSet($handler->Query["errstr"])) {
    $this->Query["errstr"][]=$handler->Query["errstr"];
    }

    return($handler->result);
    }

    return($result);
    }

    function Lookup ($query="") {
    $string = !empty($query) ? $query : $this->Query["string"];
    if($this->HACKS["cx_is_broken"] && $this->Query["tld"]=="cx") {
    $this->Query["errstr"][]=".cx doesn't work. Turn off HACKS[\"cx_is_broken\"] if ".$this->Query["server"]." finally got fixed.";
    return("");
    }
    $ptr=$this->Connect();
    if(empty($this->Query["server"])) { return(false); }
    if($ptr!=-1){
    if(($this->Query["server"]==$this->NSI_REGISTRY
    || $this->Query["server"]==$this->NSI_REGISTRAR)
    && $this->HACKS["nsi_force_dom"]) {
    fputs($ptr, sprintf("dom %s\r\n", trim($string)));
    } else {
    fputs($ptr, sprintf("%s\r\n", trim($string)));
    }
    while(!feof($ptr)) {
    if($this->BUFFER) {
    $output[]=fgets($ptr, $this->BUFFER);
    } else {
    $r.=fgetc($ptr);
    }
    }

    if(!$this->BUFFER) { $output = explode("\n", $r); }
    unset($output[count($output)-1]);
    if(isSet($this->result["rawdata"])) {
    $result = $output;
    } else {
    $result["rawdata"] = $output;
    }
    if(isSet($this->DATA[$this->Query["tld"]][1])) {
    $result = $this->Process($result);
    }
    return($result);
    } else {
    $this->Query["status"]=-1;
    $this->Query["errstr"][]="Connect failed to: ".$this->Query["server"];
    return(array());
    }

    }

    function GetTld ($domain) {
    // unfortunately the only reliable way to do this is
    // to blow through the entire server/tld list
    reset($this->DATA);
    while(list($tld, $param)=each($this->DATA)) {
    if(eregi("\.$tld$", $domain)) {
    if(!empty($curr_match)) {
    // FIXME: we assume we'll never support a 3rd
    // level registry. If we do, this breaks.
    $curr_match = strchr($tld,".") ?
    $tld : $curr_match;
    }
    else { $curr_match = $tld; }
    }
    }
    return($curr_match);
    }

    }


    ?>


    dovrei trovare un modo per riportare su sample1.php il risultato se occupato 0 se libero 1

    chi mi aiuta?


Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2026 vBulletin Solutions, Inc. All rights reserved.