Avatar billede mekaniker Nybegynder
18. juli 2003 - 09:34 Der er 4 kommentarer og
1 løsning

Tilføjelse til whois script

Jeg har fundet dette script, som virker perfekt, hvis man bare vælger et domæne. Jeg har prøvet at udbygge det med en løkke så man kunne teste alle domæner på en gang.
Jeg får desværre en fejl, som jeg ikke kan gennemskue, så jeg tænkte om der var nogle, der kunne hjæpe mig med at rette den.

---------------------------------------------------------
Fejl:
Notice: Array to string conversion in G:\Websites\php\dom\2\topdog_whois.php on line 304
The template file into which to print the results either does not exist or is not writeable
please correct this if you are the webmaster of this site
The script can not continue exiting......

----------------------------------------------------------
Form:
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<form method="post" action="topdog_whois.php">
    <input type="text" name="domain">
    <select size="1" name="ext">
    <option value="alt">Alle Domæner</option>
    <option value="dk">.dk</option>
    <option value="com">.com</option>
    <option value="net">.net</option>
    <option value="org">.org</option>
    <option value="co.uk">.co.uk</option>
    <option value="info">.info</option>
    <option value="biz">.biz</option>
   
    </select>
    <input type="hidden" name="option" value="check">
    <input type="submit" value="check it">
    </form>
</body>
</html>

----------------------------------------------------------
Script:
<?
/*
AUTHOR
This script is written by and copyright
Andrew Colins Kissa
www: www.topdog-software.com
email: webmaster@topdog-software.com

LICENCE
THIS CODE HAS NO WARRANTY AND IS DISTRIBUTED UNDER THE GNU LICENCE I CANNOT BE
HELD LIABLE FOR ANY LOSSES THAT YOU MAY INCURE BY EITHER DIRECTLY OR OTHERWISE
BY USING THIS SCRIPT.

INSTALLATION
SEE THE INSTALLATION.TXT FILE

VERSION 3  2003- 05 -20
THIS UPGRADED TO SUPPORT GLOBALS OF SERVERS
BETTER DISPLAY IN THE TEMPLATE
UPDATES TO .ORG DOMAIN WHOIS NOW TRANSFERED TO whois.publicinterestregistry.net
THANKS TO CHRIS graphic@ev1.net FOR POINTING OUT THE CHANGE TO ME SHOULD YOU FIND
A PARTICULER WHOIS SERVER NOT WORKING PLEASE POST THAT ON THE FORUM FOR ME TO
MAKE GLOBAL CHANGES FOR THE BENEFIT OF EVERY ONE --

VERSION 2
THIS IS THE TOTALLY REWRITTEN VERSION WHICH HAS BEEN UPGRADED TO INCLUDE
1.SUPPORT FOR THE NEW REFERAL WHOIS SYSTEM.
2.ACCESS CONTROL TO AVOID BANDWIDTH THEFT
3.CHECKS FOR EXISTENCE OF TEMPLATE
4.RETURN OF FULL WHOIS DETAILS
5.REMOVAL OF ALL INTERPRETAIONS OF MATTS WHOIS
6.RENAMED TO TOPDOG DOMAIN CHECK AND WHOIS SCRIPT FROM UGANDA DOMAIN CHECK AND WHOIS
THIS TO REFLECT OVERWHELMING INTREST FROM USERS OF INTERNATIONAL TLD's

WEBSITE ADDRESS
VISIT US @ www.TOPDOG-SOFTWARE.COM FOR MORE FREE SCRIPTS AND CUSTOM CODING IN PHP
AND PERL WHILE THERE VISIT OUR FORUM AND TELL US OF HOW WHE CAN MAKE THIS SCRIPT
BETTER OR GIVE IDEAS OF NEW SCRIPTS YOU WOULD LIKE TO SEE ON OUR SITE (feedback)

SUPPORT
SHOULD YOU REQUIRE SUPPORT FOR THIS SCRIPT PLEASE TRY CHECKING OR POSTING YOUR
QUERIES ON THE OUR SUPPORT FORUM @ www.topdog-software.com/forum/ BEFORE EMAILING
ME BECAUSE I RECIEVE MANY EMAILS FROM DIFFERENT USERS ASKING SIMILAR QUESTIONS
SO IF YOU POST IT ON THE BOARD AND I ANSWER IT OTHER USERS CAN USE THAT TO SOLVE
THEIR QUERIES IN THE FUTURE. By the way if you dont know anything about scripts
dont dispair we can setup custom scripts for you at a minimal fee.

Do not change the server definitions unless you know what you are doing should you
require to implement new extentions then check with iana to find out the registerer
of the extention you want then find out the address of their whois server and the
string it returns if a record is not found. You can the create a new entry under the
server definitions to reflect this. You will the have to edit the if block in the
main program to reflect the new extention you have added.
*/

//SERVER DEFINITIONS
//com, net TLD
$intserver="whois.crsnic.net";
$intnomatch="No match for";
//org TLD
$orgserver="whois.publicinterestregistry.net";
$orgnomatch="NOT FOUND";
//co.uk TLD
$ukserver="whois.nic.uk";
$uknomatch="No match";
//biz TLD
$bizserver="whois.nic.biz";
$biznomatch="Not found";
//info TLD
$infoserver="whois.opensrs.net";
$infonomatch="Not Found";
//DK TLD
$dkserver="whois.dk-hostmaster.dk";
$dknomatch="No entries found";
//END SERVER DEFINITIONS


//THIS SECTION SHOULD BE CUSTOMISED BY YOU TO REFLECT YOUR SITE
$template = "whois.html";          //this is the page where the results will be displayed
                                    //this page must contain this "<!--DOMAIN RESULTS-->"
                                    //where ever you want the results to be displayed

$registerlink = "signup.php";      //this is the page a user is taken to if they want to
                                    //register the domain name from you or your affiliate
                                    //it should be a script preferably because this script
                                    //will pass it the $domain variable using the get method
                                    //for example signup.php?domain=topdog-software.com
                                   
$restrict = 0;                      //set to 0 if you dont want to restrict access
                                    //set to 1 if you want to restrict access remeber to
                                    //change $REFERERS below to reflect your site.

$REFERERS = array('topdog-software.com', 'www.topdog-software.com');
                                    //These are the domains allowed to access the script
                                    //if you decide to restrict access

//NO NEED TO CHANGE ANY THING BELOW  IT WILL WORK JUST FINE DONT SAY I DIDN'T WARN YOU
//Main script area--->
//Register globals off upgrade - 2003-05-20
if ($_SERVER['REQUEST_METHOD'] == 'GET'){
    $domain = $_GET['domain'];
    $ext = $_GET['ext'];
    $option = $_GET['option'];
}else{
    $domain = $_POST['domain'];
    $ext = $_POST['ext'];
    $option = $_POST['option'];
}

       
if($restrict ==1){
    check_referer();
}
    //check the lenth & xters of the domain name
    namecheck($domain);
    //check domain zone
if ($ext == "alt")
    {
    $punkt = array("dk", "com", "net", "org", "co.uk", "info", "biz");
    for($i=0; $i < sizeof($punkt);$i++)
        {
        $ext = $punkt[$i];
   
        if($ext=="co.uk"){
            //uk settings
            $server=$ukserver;
            $nomatch=$uknomatch;
        }
        if($ext=="com"||$ext=="net"){
            //int settings
            $server=$intserver;
            $nomatch=$intnomatch;
        }
        if($ext=="org"){
            $server=$orgserver;
            $nomatch=$orgnomatch;
        }
        if($ext=="biz"){
            //biz settings
            $server=$bizserver;
            $nomatch=$biznomatch;
        }
        if($ext=="info"){
            //info settings
            $server=$infoserver;
            $nomatch=$infonomatch;
        }
        if($ext=="dk"){
            //info settings
            $server=$dkserver;
            $nomatch=$dknomatch;
        }
       
       
        if($option=="check"){
            $layout = check_domain($domain,$ext);
            print_results($layout);
        }
        if($option=="whois"){
            whois($domain,$ext);
        }
        }
}
else
{
if($ext=="co.uk"){
        //uk settings
        $server=$ukserver;
        $nomatch=$uknomatch;
    }
    if($ext=="com"||$ext=="net"){
        //int settings
        $server=$intserver;
        $nomatch=$intnomatch;
    }
    if($ext=="org"){
        $server=$orgserver;
        $nomatch=$orgnomatch;
    }
    if($ext=="biz"){
        //biz settings
        $server=$bizserver;
        $nomatch=$biznomatch;
    }
    if($ext=="info"){
        //info settings
        $server=$infoserver;
        $nomatch=$infonomatch;
    }
    if($ext=="dk"){
        //info settings
        $server=$dkserver;
        $nomatch=$dknomatch;
    }
   
   
    if($option=="check"){
        $layout = check_domain($domain,$ext);
        print_results($layout);
    }
    if($option=="whois"){
        whois($domain,$ext);
    }
    }
//end main script area---->

//<------------------------------------functions-------------------------------->
function check_domain($domain,$ext)
{
    global $nomatch,$server;
    $output="";
    if(($sc = fsockopen($server,43))==false){echo"The script could not connect to whois server : $server";exit;}
    fputs($sc,"$domain.$ext\n");
    while(!feof($sc)){$output.=fgets($sc,128);}
    fclose($sc);
    //compare what has been returned by the server
    if (eregi($nomatch,$output)){
        return 0;
    }else{
        return 1;
    }
}


function whois($domain,$ext)
{  global $template,$server;
    if(($sc = fsockopen($server,43))==false){
        if(($sc = fsockopen($server,43))==false){
            echo"There is a temporary service disruption Please again try later";
            exit;
        }
    }
    if($ext=="com"||$ext=="net"){
        //
        fputs($sc, "$domain.$ext\n");
        while(!feof($sc)){
            $temp = fgets($sc,128);
            if(ereg("Whois Server:", $temp)) {
                $server = str_replace("Whois Server: ", "", $temp);
                $server = trim($server);
            }
        }
        fclose($sc);
        if(($sc = fsockopen($server,43))==false){
            echo"There is a temporary service disruption Please try later";
            exit;
        }
    }

    $output="";
    fputs($sc,"$domain.$ext\n");
    while(!feof($sc)){$output.=fgets($sc,128);}
    fclose($sc);
    //print
    if(!is_file($template)){
        print"The template file into which to print the results either does not exist
        or is not writable<br>
        please correct this if you are the webmaster of this site<br>
        The script can not continue exiting......";
        exit;
    }
    $template = file ($template);
    $numtlines = count ($template);
    $line = 0;
    while (! stristr ($template[$line], "<!--DOMAIN RESULTS-->") && $line < $numtlines) {
    echo $template[$line];
    $line++;
    }
    $line++;
    print  "<div align=\"center\">";
    print  "<table width=\"100%\" border=\"0\" cellPadding=2 class=font1l>";
    print  "<tr><td><b>Domain whois query information for \"$domain.$ext\"</b></td></tr>";
    print  "<tr><td><hr></td></tr><br>";
    print  "<tr><td>";
    $output= explode("\n",$output);
    foreach ($output as $value){
            print "$value<br>\n";
    }
    print "</td></tr></table>";
    print "</div>";
    print "<br>";
    print "<center><font class=font1csm>search powered by <a href=\"http://www.topdog-software.com/scripts.php\">topdog whois scripts</a></font></center>";
    while ($line < $numtlines) {
    echo $template[$line];
    $line++;
  }

}
//function to check referer
function check_referer () {
    global $REFERERS, $HTTP_REFERER;
    if ($HTTP_REFERER != "")
        while (list($val, $ref) = each($REFERERS))
        if (preg_match("/^http:\/\/$ref/", $HTTP_REFERER))
        return;
    print("Access denied to: $HTTP_REFERER<br>Please dont link to this script <a href=\"scripts.php\">download</a> a copy
        and set it up on your site.<br> This is due to bandwidth usage ... leeching and Data mining");
        exit;
}
//Function to print the results into your template
function print_results($layout)
{
    global $template,$registerlink,$domain,$ext;
    if(!is_file($template)){
        print"The template file into which to print the results either does not exist or is
        not writeable<br>
        please correct this if you are the webmaster of this site<br>
        The script can not continue exiting......";
        exit;
    }
    $template = file ($template);
    $numtlines = count ($template);    //Number of lines in the template
    $line = 0;
    while (! stristr ($template[$line], "<!--DOMAIN RESULTS-->") && $line < $numtlines) {
    echo $template[$line];
    $line++;
    }
    if($layout==0){
        $line++;
        print  "<table width=\"100%\" border=\"1\" cellPadding=2 class=font1l>";
        print  "<tr><td><b>Domain query Results for \"$domain.$ext\"</b></td></tr>";
        print  "<tr><td><hr></td></tr>";
        print  "<tr><td>The domain is available <a href=\"$registerlink?domain=$domain.$ext\">register</a> it now</td></tr>";
        print  "</table>";
    }
    if($layout==1){
        $line++;
        print  "<table width=\"100%\" border=\"1\" cellPadding=2 class=font1l>";
        print     "<tr><td><b>Domain query Results for \"$domain.$ext\"</b><br></td></tr>";
        print  "<tr><td><hr></td></tr>";
        print  "<tr><td><b>The domain is already taken <a href=\"topdog_whois.php?domain=$domain&ext=$ext&option=whois\">Check</a> the whois information<br></td></tr>";
        print  "<tr><td>Check another domain name <a href=\"java script:history.back()\">here</a></td></tr>";
        print  "</table>";
    }
    while ($line < $numtlines) {
    echo $template[$line];
    $line++;
  }
}
//This checks the name for invaild characters
function namecheck($domain)
{
    if($domain==""){echo"You must enter a domain to be checked<br>\n";
    echo"Click <a href=\"java script:history.back()\">here</a> to go back"; exit;}
    if(strlen($domain)< 3){echo"Dom&aelig;net: <b>$domain</b> er for kort"; exit;}
    if(strlen($domain)>57){echo"Dom&aelig;net: <b>$domain</b> er for langt"; exit;}
    if(@ereg("^-|-$",$domain)){echo"Domains cannot begin or end with a hypen"; exit;}
    if(!ereg("([a-z]|[A-Z]|[0-9]|-){".strlen($domain)."}",$domain))
    {echo"Der er ulovlige karaktere i dom&aelig;nenavnet:"; exit;}

}
//<--------------------------------end functions------------------------------------>

?>
Avatar billede TRoXa Novice
18. juli 2003 - 11:38 #1
Det eneste du skal gøre er at oprette en fil der hedder whois.html

Så virker det :)
Avatar billede mekaniker Nybegynder
18. juli 2003 - 15:02 #2
Jeg har lavet filen whois.html og det virker også fint hvis den bare skal tjekke en extension, men ikke min udvidelse til alle extensions.
Avatar billede nielle Nybegynder
18. juli 2003 - 15:24 #3
Lytter lige med.
Avatar billede TRoXa Novice
18. juli 2003 - 15:38 #4
så er det problem løst

Nede i bunden af filen står der i en funktion print_results

    if(!is_file($template)){
        print"The template file into which to print the results either does not exist or is
        not writeable<br>
        please correct this if you are the webmaster of this site<br>
        The script can not continue exiting......";
        exit;
    }
det skal du bare slette .. så virker det :)
Avatar billede mekaniker Nybegynder
06. august 2003 - 16:11 #5
Tak for hjælpen, det virkede perfekt
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Vi tilbyder markedets bedste kurser inden for webudvikling

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester