Pagina 1 di 2 1 2 ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 12

Discussione: script whois problema

  1. #1

    script whois problema

    Salve ho realizzato un script per il controllo dei domini ma come al solito non funge o quasi.

    ho una pagina in php che controlla la stato dei suffissi .it, com ecc se libero scrive in html 200 se occupato fa il whois dello stesso. su una seconda pagina in asp ho scritto il seguente codice


    <%
    ' Dominio da controllare
    dominio = Request.QueryString("dominio")

    ' URL da richiamare
    url = "http://www.xxxxxx/whois/sample.php?query=" & dominio & "." & rs(2) & ""

    ' creiamo l'oggetto XMLHTTP
    Set XMLHTTP = Server.CreateObject("Microsoft.XMLHTTP")
    XMLHTTP.Open "GET", url, false

    ' inviamo la richiesta
    XMLHTTP.Send (strPost)

    ' codice di risposta del server
    status = xmlhttp.responseText

    ' codice di stato
    if status = 200 then
    ' testo della risposta
    Response.Write "risulta libero procedi con l'acquisto <a href=carrello.asp?spazio=dominio&mb=0&numero=1&gua d=" & rs(1) & "&nome=" & dominio & "&estenzione=" & rs(2) & "&prodotto=" & rs(0) & "><img border=0 src=imghome/acquista.gif><a>"
    Else
    Response.Write "non è disponibile se sei il proprietario puoi <a href=trasferisci.asp>trasferirlo<a> o puoi selezionare le estenzioni libere elencate qui sotto!"
    End If

    ' un po' di pulizia
    Set XMLHTTP = Nothing
    %>


    il problema è che lo status non viene letto e mi da sempre dominio occupato dove sbaglio?

  2. #2
    Utente di HTML.it L'avatar di salvod
    Registrato dal
    Feb 2002
    Messaggi
    314
    codice:
    status = xmlhttp.responseText
    in questo modo in status nn avrai lo stato della richiesta ma il codice html della pagina

  3. #3
    quindi sbaglio stringa. cosa posso inserire?

    lo script che controlla il whois è il seguente

    <?
    if(isSet($query)) {
    include("main.whois");
    $whois = new Whois($query);
    $result = $whois->Lookup();

    if(isSet($whois->Query["errstr"])) {
    echo "0";}
    if($output=="object") {
    include("utils.whois");
    $utils = new utils;
    $utils->showObject($result);
    } else {
    if(!empty($result["rawdata"])) {
    echo "200";
    } else { echo ""; }
    }
    }
    ?>

    in teoria la pagina html dovrebbe essere vuota cosi o sbaglio?

  4. #4
    Moderatore di ASP e MS Server L'avatar di Roby_72
    Registrato dal
    Aug 2001
    Messaggi
    19,563
    codice:
    if CINT(xmlHTTP.Status) = 200 then 
    
    ...
    Roby

  5. #5
    Utente di HTML.it L'avatar di salvod
    Registrato dal
    Feb 2002
    Messaggi
    314
    scusa.. nn si era capito bene.. tu quindi fai un doppio passaggio!! io credevo che la richiesta XMLHTTP la facevi direttamente verso l'url che dovevi controllare...

    le cose che puoi fare adesso sono 2:

    1) nn passi dallo script php che fa il whois e fai:
    codice:
    <%
    ' Dominio da controllare
    dominio = Request.QueryString("dominio")
    
    ' URL da richiamare
    url = "http://www.xxxxxx/whois/sample.php?query=" & dominio & "." & rs(2) & ""
    
    ' creiamo l'oggetto XMLHTTP
    Set XMLHTTP = Server.CreateObject("Microsoft.XMLHTTP")
    XMLHTTP.Open "GET", url, false
    
    ' inviamo la richiesta
    XMLHTTP.Send (strPost)
    
    ' codice di stato
    if XMLHTTP.status = 200 then
    ' testo della risposta
    Response.Write "risulta libero procedi con l'acquisto <a href=carrello.asp?spazio=dominio&mb=0&numero=1&guad=" & rs(1) & "&nome=" & dominio & "&estenzione=" & rs(2) & "&prodotto=" & rs(0) & "><img border=0 src=imghome/acquista.gif><a>"
    Else
    Response.Write "non è disponibile se sei il proprietario puoi <a href=trasferisci.asp>trasferirlo<a> o puoi selezionare le estenzioni libere elencate qui sotto!"
    End If
    
    ' un po' di pulizia
    Set XMLHTTP = Nothing
    %>
    2) fai come facevi prima solo che devi stare attento che oltre a il 200 il codice php non stampi altro e che comunque è una stringa e non un numero


  6. #6
    grazie mille per le indicazioni. ma non credo che riesca a risolvere il problema. il primo script che mi hai segnalato lo avevo gia realizzato ma sono stato costretto a scartallo perche succede che se il dominio non punta per vari motivi (per esempio appena registrato) il server non da come status 200 ma in teoria non è registrabile.

    per la seconda opz la pagina stampa solo 200 su explorer ma sembra che carichi altro come faccio a vedere quello che in teoria riporta
    status = xmlhttp.responseText

    una terza opz ma non conosco il php e nel codice

    <?
    if(isSet($query)) {
    include("main.whois");
    $whois = new Whois($query);
    $result = $whois->Lookup();

    if(isSet($whois->Query["errstr"])) {
    echo "0";}
    if($output=="object") {
    include("utils.whois");
    $utils = new utils;
    $utils->showObject($result);
    } else {
    if(!empty($result["rawdata"])) {
    echo "200";
    } else { echo ""; }
    }
    }
    ?>

    se il dominio è libero lo giro su una pagina non esistente magari con un redirect interno. in quel caso il server non risponde e quindi passa la stringa.

  7. #7
    Utente di HTML.it L'avatar di salvod
    Registrato dal
    Feb 2002
    Messaggi
    314
    con un Response.Write(status) e vedi ke stampa, se ho cpt bene quello ke volevi dire

  8. #8
    ok. ho capito il problema. non posso effettuare un else if perche 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 visto il codice che sto utilizzando ho notato che il codice in questo caso php mi da il seguente risultato
    var $STAT = array(-1=>"error",0=>"ready",1=>"ok");
    se risco a riportare queste impostazioni sulla pagina sample1.php posso risolvere il problema
    la pagina sample ho in include su main.whois
    :::::::::::::::::::::::::::::::::::::::::::::
    <?
    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 ""; }
    }
    }
    ?>

    :::::::::::::::::::::::::::::::::::::::::::::::::: :
    vi inserisco anche il main.whois

    :::::::::::::::::::::::::::::::::::::::::::::::::: ::
    <?
    /*
    Whois2.php PHP classes to conduct whois queries

    Copyright (C)1999,2000 easyDNS Technologies Inc. & Mark Jeftovic

    Maintained by Mark Jeftovic <markjr@easydns.com>

    For the most recent version of this package:

    http://www.easydns.com/~markjr/whois2/

    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.
    */

    /* main.whois 2.2-3 mark jeftovic 2000/08/07 */

    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);
    }

    }


    ?>

  9. #9

    per i mod

    è possibile girare il post sulla sezione php? visto che ora si parla di php. ho posso creare un nuovo post?

  10. #10

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 © 2025 vBulletin Solutions, Inc. All rights reserved.