SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Evangelist mad-onion's Avatar
    Join Date
    Aug 2000
    Location
    Land of the long white cloud
    Posts
    556
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have this code...
    $rawoutput="";
    $ns = fsockopen("whois.internic.net",43);
    @fputs($ns,"$domainname.$ext\n");
    while(!@feof($ns)){
    $rawoutput.= fgets($ns,128);
    }
    @fclose($ns);

    It is part of a loop, and is dead slow... Is there anyway it can be optimised, perhpas not having to connect each time

    TIA
    SiteOptions >> Services :: Products :: Contact
    Developers of PHP, C++, Visual Basic, MySQL, and more!

  2. #2
    SitePoint Zealot
    Join Date
    Jun 2000
    Posts
    165
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    How's it going?


    Can you give a little more info. please? - answer depends on context. When you say it's part of a loop, does this mean you are trying to check several domain names, or is the loop for other stuff?


    Cheers,

    Jason

  3. #3
    SitePoint Evangelist mad-onion's Avatar
    Join Date
    Aug 2000
    Location
    Land of the long white cloud
    Posts
    556
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry, here goes the entire loop.
    And yes the array domainnames contains multiple domains like
    $domainnames=array("sitepoint.com", "helloworld.net");
    It works....it would just be nice if it could be a little faster :-)

    Code:
    while (list(, $domainname) = each ($domainnames)) {
    
    
    
                            if($ext){
    
                            $rawoutput="";
                            $ns = fsockopen("whois.internic.net",43);
                            @fputs($ns,"$domainname\n");
                                                    while(!@feof($ns)){
                                                    $rawoutput.= fgets($ns,128);
                                                    }
                            @fclose($ns);
                                         if(!ereg("No match for", $rawoutput)){
                                                       if($taken!="yes"){
                                                        echo str_replace("<domain>", $domainname.".".$ext, $domain_taken);
                                                       }
                                         }else{
                                         $lower=strtolower($domainname);
                                         $temp=str_replace("<reg>", 'https://secure.onlineaccess.net/cart/?ID=3d2bcaad195394ac8318234622f80e58&lookup=OK&domain='.$lower.'&root='.$ext.'&submit=Search', $domain_available);
    
    
    
                                                        echo str_replace("<domain>", $domainname.".".$ext, $temp);
                                         }
                            
    
                  }
    SiteOptions >> Services :: Products :: Contact
    Developers of PHP, C++, Visual Basic, MySQL, and more!

  4. #4
    SitePoint Zealot
    Join Date
    Jun 2000
    Posts
    165
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hello again,


    I believe ereg is quite slow in comparison to php's 'direct' functions, I'd use 'strstr' instead, for such a simple maneouver. This should speed things up a little. Then if you just store it quickly (see $status) instead of all the str_replaces......


    i.e. if (strstr($rawoutput, "no match for")):
    $status[$index] = "Available";

    else:
    $status[$index] = "Not Available";

    e.t.c............then u can just loop through again and echo the $status[$index]


    ...this will eliminate much of your code.



    I hope this help's mad-one..........


    Cheers,

    Jason


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •