Tuesday, 06 January 2009
   
Home arrow Tutorial  
 
Home
Supporto
Contattaci
Categorie Script
RSS Media Grabber Video & Foto Divertenti Storie di Vita (Flash) Video: Ricerca & Download Script Download Video Nazioni in Vendita Script per Sondaggi Host per File wap Script Creazione SlideShow Script PhotoCube Script "Make Confessions" Script Spartiti Chitarra Crea Smile Personalizzati URL Brevi & Sottodomini Script Gioco Hot Or Not Metti il Tuo Testo Sulle Img Host & Watermark Img Salva i Tuoi Preferiti Online Componenti Joomla Script a Basso Costo
Partners
StileGames
Php Tutorial
 
 
   
 
Verifying a URL Print E-mail

Learn how to see if a URL is valid. and still alive or if it's a 404 Not Found

 


Problem:

You have a thousands of links just randomly lying around from back in the day and you want to only put the ones up which still exist, and not the ones which don't exist anymore, what do you do?

Answer:

Not a problem bub, just use the power of PHP by using the fsockopen() function to check and see if the site is up and you'll be set:

<?
$up = @fsockopen("www.spoono.com", 80, $errno, $errstr, 30);
if($up)
{
echo "<a xhref=\"http://www.spoono.com\">Spoono</a>";
}
else
{
echo "<a xhref=\"http://www.spoono.com\">Spoono's Dead!! :(</a>";
}
?>

The code is fairly simple and easy to follow. The fsockopen() function actually tries to connect a socket to the listed site. The first parameter listed "www.spoono.com" would be the URL of the website you want to check. It is important that you do not put http:// in front of the URL or else the script does not work. The second parameter, 80, would be the port, which should just be left alone. The next two parameters are just standard PHP errors, and the last one, 30, is the amount of time to wait in seconds before assuming its a timeout. The next few lines checks to see if the connection went through and if it did then put the link up. Again, an easy and useful script.


Well, that's all folks. Not too tough was it? Well thats it folks. I hope it works out for you and if it doesn't, post on the board and we'll try to help you out.

 

Credit: www.spoono.com 





Reddit!Del.icio.us!Facebook!Slashdot!Netscape!Technorati!StumbleUpon!Newsvine!Furl!Yahoo!Ma.gnolia!Free social bookmarking plugins and extensions for Joomla! websites!
 
< Prev   Next >
 
Se trovi uno dei nostri operatori online, contattalo prima di comprare per usufruire di uno sconto!
Servizi
Controlla PageRank
Richiedi un Preventivo
Script Gratuiti
Installazione Script
Blog Backlinks
Login Form
Prodotti Scontati
Script Video e Foto Divertenti
Script Video e Foto Divertenti
$69.00
$59.00
You Save: $10.00
Add to Cart
 
Copyrighted © 2006 phppod.com