SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Evangelist
    Join Date
    Oct 2000
    Posts
    430
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    I was wondering if anyone could give me some advise on a small link checking script I wish to create.

    Basically all my external links will go via a redirection script.
    Along with redirecting the user to the correct site, I wish it to check to see if the link is working correctly.

    My simplified idea for doing this would along these lines:

    $SiteName = "http://site-to-go-to.com";
    $fp = fopen ($SiteName, "r");
    if(!fp){
    $fp2 = fopen (/Broken_link_file.htm, "a");
    $Message = $SiteName . $HTTP_REFERER;
    fwrite ($fp2, $Message );
    fclose($fp2);
    }
    fclose($fp);

    Now, as far as I can see this should make it really easy to find out if any of my sites links are broken, as I just have to check the "broken links file" to find details of the link and the page its on.

    However, I have several concerns:

    Firstly the operation needs to be very quick, - Is there any way to make sure that it doesn't take an age trying to open the link?

    If the link can't be opened I believe PHP will through out an error message "cannot open file". Obviously I don't want this, so how can I stop it.

    Lastly I'm no PHP wiz, so I would welcome your thoughts as to how to improve the above, or possible problems.

  2. #2
    SitePoint Evangelist
    Join Date
    Oct 2000
    Posts
    430
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Anyone got any thoughts or ideas on this??

    file_exists(); ??


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
  •