Results 1 to 2 of 2

Thread: Help me with this code

  1. #1
    weirdnessme is offline Newbie Net Builder
    Join Date
    Mar 2009
    Posts
    286
    Blog Entries
    1
    Thanks
    19
    Thanked 31 Times in 30 Posts

    Help me with this code

    Hi ,

    I actually coded a php to check for backlink on all the sites listed on my Proxy List Site .

    I even used usleep to get over the time limit set by server people , but still the script would stop working after few checks

    Here is the link you can see :

    Backlink Checker

    The code for same is :

    PHP Code:
        <?php

        $mydomain 
    "http://youcanhide.com"// Set this to your domain

       
    $list file_get_contents("new.txt");
        
    $urls explode ("\n"$list);

        echo 
    "<B>Checking back links to $mydomain....</B><P><FONT SIZE=-1>";

        foreach (
    $urls as $url) {
    echo 
    date('h:i:s') . "<br />";

    //sleep for 10 seconds
    usleep(2000000);

    //start again
    echo date('h:i:s');

        if (
    strlen ($url)) {
        echo 
    $url "<B><FONT COLOR=";
        if (
    strpos (file_get_contents($url), $mydomain) != FALSE) {
        echo 
    "GREEN> Found";
        } else {
        echo 
    "RED> Missing";
        }
        echo 
    "</FONT></B><BR>";
        }
        }
        echo 
    "</FONT>";

        
    ?>
    New.txt is written with the help of another php file which connects to DB and writes the details to new.txt

    Please look into code and help me & also tell me how to add to avoid for a site which is down so it doesnt stop my script?

    Regards,
    Harshit


  2. #2
    Keldorn's Avatar
    Keldorn is offline Net Builder
    Join Date
    Dec 2008
    Location
    Canada
    Posts
    400
    Thanks
    21
    Thanked 60 Times in 52 Posts
    Yeah I had this trouble, what happened was sometimes it would hit a dead link and wouldn't resolve, and it would make the script die.
    You should do this will cURL and set the timeout like 10 seconds
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT,10);
    curl_setopt($ch, CURLOPT_TIMEOUT,10);

    instead of strpos use preg_match with a regural expression,

    Code:
    if(!preg_match('#<a[^>]+href\s*=\s*(["\\\']?)http://(?:www\.)?example\.com#i', $website_html)){
    
    echo "This is bad!";
    
    }
    Submit new proxies -

Similar Threads

  1. What is a Bar Code Reader ?
    By Digital in forum Tech-Talk
    Replies: 4
    Last Post: 8 November, 2012, 19:34 PM
  2. Do you code your designs?
    By Farrhad A in forum Web Design
    Replies: 22
    Last Post: 30 November, 2011, 10:59 AM
  3. where i should paste this code?
    By garfish in forum Programming
    Replies: 4
    Last Post: 9 April, 2010, 08:39 AM
  4. WP code change help Please.
    By Sami4u in forum Wordpress
    Replies: 13
    Last Post: 3 April, 2010, 19:27 PM
  5. Help figure this code out???
    By ProxySites.ca in forum Web Proxies
    Replies: 0
    Last Post: 17 December, 2009, 19:27 PM

Tags for this Thread

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
  •