Help me with my php code please.

Discussion in 'PHP' started by korfezli1966, Jul 21, 2013.

  1. #1
    Hi all,

    I wrote a php file, which pulls content from a website and adss it to my wordpress website. Because of "every 10 minutes" cronjob (i think) the source website banned the ip address of my host.

    After that the people suggested me to purchase premium proxy addresses and it will be ok. After I modified my code with all this proxy ips etc. it worked on the host of one of my friend. But it does not work on my host. Any idea what can cause this problem? for example, this code below also works on the host which one of my friend has, but it does not work on my host. What should i do on this point? What do you suggest? thanks (below is a sample code, which is actually the main part of my codes. But still it works on another host but not on mine. Is there a problem with my host do you think? What / how should i ask my host provider what the problem is with my host?)

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <?php
    include("wp-load.php");
    include("wp-config.php");
    set_time_limit(0);
    //Fonksiyonlar
    function cek($url)
    {
    $ch = curl_init();
    $timeout = 5;
    curl_setopt($ch,CURLOPT_URL,$url);
    curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
    curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
    curl_setopt($ch, CURLOPT_REFERER, "googlebot");
    curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 0);
    curl_setopt($ch, CURLOPT_PROXY, "[U]proxyipaddresscomeshere[/U]");
    curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)");
    $data = curl_exec($ch);
    curl_close($ch);
    return $data;
    }
    echo cek("[U]thewebsiteurlthatipullthecontentcomeshere[/U]"); ?>
    PHP:
     
    korfezli1966, Jul 21, 2013 IP
  2. Vernard

    Vernard Member

    Messages:
    92
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    48
    #2
    Is there a particular error? Have you asked your host if you have CURL enabled on your account? if not, that's what I'd recommend. if they don't provide CURL then I suggest switching hosts.
     
    Vernard, Jul 21, 2013 IP
  3. korfezli1966

    korfezli1966 Well-Known Member

    Messages:
    289
    Likes Received:
    3
    Best Answers:
    1
    Trophy Points:
    165
    Digital Goods:
    1
    #3
    actually I am using justhost, and until 2-3 before all my codes just worked without a problem. then i looked at it with a test.php file, and i saw that the ip address of my host is banned from the source website.

    then i tried to pull the content via proxy ip, but no success. There is no error on the screen, it is just blank screen.

    thanks for help.
     
    korfezli1966, Jul 21, 2013 IP
  4. Vernard

    Vernard Member

    Messages:
    92
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    48
    #4
    You've confirmed that the proxy is indeed working before testing it via PHP?
     
    Vernard, Jul 21, 2013 IP
  5. korfezli1966

    korfezli1966 Well-Known Member

    Messages:
    289
    Likes Received:
    3
    Best Answers:
    1
    Trophy Points:
    165
    Digital Goods:
    1
    #5
    yeah, i tested it. i am sure that the proxy is working. I mean I and one of my friend tested it at the same time, on hist host it just worked and on my host it didn't. I mean we also tried different ip adresses as proxy, but same result. On his host it is working and on y host it is not.
     
    korfezli1966, Jul 21, 2013 IP