Click here to Skip to main content
15,868,049 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am required to change ip adress everytime this function gets executed I am trying this code below .But I am completly confused.How can I do this

What I have tried:

function getData($domainName, $ext)
{
    $proxy = array(
        1 => array(
            '88.255.101.247',
            '8080'
        ),
        2 => array(
            '176.53.2.122',
            '8080'
        ),
        3 => array(
            '37.123.96.237',
            '8080'
        )
    );
    shuffle($proxy);
    $servers = array(
        "biz" => "whois.neulevel.biz",
        "com" => "whois.internic.net",
        "us" => "whois.nic.us",
        "info" => "whois.nic.info",
        "name" => "whois.nic.name",
        "net" => "whois.internic.net",
        "tv" => "whois.nic.tv",
        "ru" => "whois.ripn.net",
        "org" => "whois.pir.org",
        "com.tr" => "whois.nic.tr",
        "gen.tr" => "whois.nic.tr",
        "web.tr" => "whois.nic.tr",
        "k12.tr" => "whois.nic.tr",
        "org.tr" => "whois.nic.tr"
    );
    $serverName = trim($servers[$ext]);
    $fullName = $domainName . "." . $ext;
    $curl=curl_init();
    curl_setopt($curl, CURLOPT_URL, $serverName);
    curl_setopt($curl, CURLOPT_PORT, 43);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($curl, CURLOPT_TIMEOUT, 5);
    curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $fullName . "\r\n");
    curl_setopt($curl, CURLOPT_PROXY, $proxy[0][0]);
    curl_setopt($curl, CURLOPT_PROXYPORT, $proxy[0][1]);
    curl_setopt($curl, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
    $result = curl_exec($curl);
    curl_close($curl);
    print_r($result);
  }
  $veri = getData( "google", "com");
  echo htmlspecialchars($veri);
Posted
Updated 11-Apr-19 0:45am

1 solution

You function getData does not return anything, instead it does a print_r() call.
You may try return $result; instead.
 
Share this answer
 
Comments
Member 3722539 12-Apr-19 7:45am    
thank you but It still returns nothing
phil.o 12-Apr-19 11:04am    
I'm sorry to read that.
So now, you will have to begin debugging your code. Here[^] you may find a huge list of resources about it.
Debugging is an important part of development, and one which is quite interesting actually. It allows you to observe the contents of variables, so you can figure out why you get a different result from what you expected.
For example here a good idea would be to check the contents of the $result variable, to see what has been returned by curl.
What does the print_r($result); display by the way?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900