Help - Search - Members - Calendar
Full Version: A Link Checker script
MSFN Forums > Coding, Scripting and Servers > Web Development (HTML, Java, PHP, ASP, XML, etc.)

   
Google Internet Forums Unattended CD/DVD Guide
Brandon W
Well I am looking at making a link checker script for my forums. I see there are many around but I don't know how to make the one. So has anyone please got a script I can look at to test it? Please I need this ASAP.
Brandon W
Anyone?
Chozo4
PHP :: Scripts and Programs :: Link Checking
http://www.hotscripts.com/PHP/Scripts_and_...king/index.html
mecablaze
I normally use cURL of fopen to test if a link (url) is valid. Try this script.
CODE
function validURL($url) {
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
    curl_setopt($ch, CURLOPT_BUFFERSIZE, 8192);
    curl_setopt($ch, CURLOPT_TIMEOUT, 5);
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
    $output = curl_exec($ch);
    $info = curl_getinfo($ch);
    curl_close($ch);

    @$components = parse_url($url);
    
    if ( $info["http_code"] == 200 ) {
        return true;
    } else {
        if ( $components["scheme"] == "ftp" && $info["http_code"] >= 200 && $info["http_code"] < 300 ) {
            return true;
        }
        return false;
    }
}


Works with http(s) and ftp protocols. Have fun.
Google Internet Forums Unattended CD/DVD Guide
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.