The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Scripts (php) slow to perform lookups

Discussion in 'General Discussion' started by n3tph4t, Jun 17, 2007.

  1. n3tph4t

    n3tph4t Active Member

    Joined:
    Jan 31, 2004
    Messages:
    39
    Likes Received:
    0
    Trophy Points:
    6
    I am running a couple of scripts which need to resolve hostnames as part of their operation.
    Initially I had my resolv.conf set up poorly and this meant that even lookups performing ping were slow. I have changed this and these are now much faster.

    My scripts however are still slow. I am using sockets for these scripts and so I guess my question is....does PHP(/apache?) use a different list when resolving a hostname.
    Either way, can you point me in a direction it may be worth me looking at?

    My script is basically:
    Code:
    function GooglePageRank($url){ 
        $arr = parse_url($url); 
        $url = $arr['host']; 
        $url="info:".$url; $ch=GoogleCSum($url,0xE6359A60); 
        $host="toolbarqueries.google.com"; $hostip=gethostbyname($host); 
        $query ="GET /search?client=navclient-auto&ch=6".$ch."&ie=UTF-8&oe=UTF-8&features=Rank&q=".rawurlencode($url)." HTTP/1.0\r\n"; 
        $query.="Host: $host\r\n"; $rank=-1; 
        $query.="User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)\r\n"; 
        $query.="Connection: Close\r\n\r\n"; 
        $fp=fsockopen($hostip,80,$errno,$errstr,30); 
        if ($fp) 
        { fputs($fp,$query); $data=""; while (!feof($fp)) $data.=fgets($fp,4096); fclose($fp); 
        $data=explode("\n",$data); 
        foreach ($data as $line) 
        if (!is_bool(strpos($line,"Rank_1"))) 
        { $rank=explode(":",trim($line)); $rank=$rank[2]; break; } } 
        return $rank; 
    } 
    
    Thank in advance
     
  2. n3tph4t

    n3tph4t Active Member

    Joined:
    Jan 31, 2004
    Messages:
    39
    Likes Received:
    0
    Trophy Points:
    6
    bump :) thanks
     
    #2 n3tph4t, Jun 17, 2007
    Last edited: Jun 18, 2007
  3. eNetHosts

    eNetHosts Well-Known Member

    Joined:
    Apr 21, 2007
    Messages:
    195
    Likes Received:
    0
    Trophy Points:
    16
    Why copy the whole lot of you post? When you just had to post reply "bump" :( hmm anyway...

    If someone can help they'll find you post a bump won't get you any further :)
     
  4. n3tph4t

    n3tph4t Active Member

    Joined:
    Jan 31, 2004
    Messages:
    39
    Likes Received:
    0
    Trophy Points:
    6
    I wasn't deliberate, I am used to quoting when I post on lots of forums so it was out of habit (now removed).

    I'm not sure what you are trying to say with your second sentence:

    "If someone can help they'll find you post a bump won't get you any further :)"

    ?!
     
  5. acegames

    acegames Member

    Joined:
    Oct 5, 2005
    Messages:
    14
    Likes Received:
    0
    Trophy Points:
    1
    Sorry to bump an old post but im experiencing the same problem , did you resolve this ?
     
Loading...

Share This Page