MSFN Forum: A Link Checker script - MSFN Forum

Jump to content



Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

A Link Checker script Rate Topic: -----

#1 User is offline   Brandon W 

  • Group: Members
  • Posts: 3
  • Joined: 22-March 08

Posted 22 March 2008 - 10:51 PM

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.


#2 User is offline   Brandon W 

  • Group: Members
  • Posts: 3
  • Joined: 22-March 08

Posted 30 March 2008 - 03:30 AM

Anyone?

#3 User is offline   Chozo4 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 392
  • Joined: 31-July 05

Posted 02 April 2008 - 04:14 AM

PHP :: Scripts and Programs :: Link Checking
http://www.hotscripts.com/PHP/Scripts_and_...king/index.html

#4 User is offline   mecablaze 

  • Group: Banned
  • Posts: 7
  • Joined: 20-August 08

Posted 26 August 2008 - 07:23 AM

I normally use cURL of fopen to test if a link (url) is valid. Try this script.
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.

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users



All trademarks mentioned on this page are the property of their respective owners
Copyright © 2001 - 2011 msfn.org
Privacy Policy