Current location: Hot Scripts Forums » Programming Languages » PHP » check the existance of website using php

check the existance of website using php

Reply
  #1 (permalink)  
Old 02-21-08, 06:42 AM
suru_epn suru_epn is offline
New Member
 
Join Date: Dec 2007
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
check the existance of website using php

Hi dear friends,

How to check whether the website address i have enterd is existing in the web


Not javascript validation....


Please help me

__________________
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 02-21-08, 08:56 AM
UnrealEd's Avatar
UnrealEd UnrealEd is offline
Community VIP
 
Join Date: May 2005
Location: Antwerp, Belgium
Posts: 2,724
Thanks: 0
Thanked 0 Times in 0 Posts
I used a small script that attempts to connect to the website through a socket. I simply set the default timeout of the access-attempt to 10 seconds, and when the timeout was reached, I stated the url as invalid:
PHP Code:
/**
 * Checks if the entered url links to a valid website. 
 * A valid website is one that responses within a timelimit of <code>$seconds</code>
 *
 * @param string The url that need to be checked
 * @param integer The number of seconds before a timeout occurs. default=10
 * @return boolean True if the website responded, false otherwise
*/
function isValidWebsite ($url$seconds=NULL) {
  
$realUrl preg_replace ('#https?:\/{2}([^\/\\]+).*?#s''\\1'$url);
  
$seconds is_null ($seconds)? 10 $seconds;
  return 
fsockopen ($realUrl80$errNo$errStr$seconds);

There might be some easier ways, but this one has worked fine for me
__________________
"Good judgement comes from experience, and experience comes from bad judgement." - Fred Brooks

If you want to add me on any IM, pm me first
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 02-22-08, 02:49 AM
suru_epn suru_epn is offline
New Member
 
Join Date: Dec 2007
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Spin hey thanks man..

thank u man....

its working fine...

__________________
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
100 ways to get more traffic jorokolarov The Lounge 12 12-06-07 07:20 PM
Playing Music in website using PHP raji20 PHP 6 02-01-07 12:24 AM
Upgrading my site to PHP? ExoticCarSite Job Offers & Assistance 3 04-24-05 05:47 AM
Website protection in PHP danrhodes1987 PHP 12 04-19-05 05:25 PM
PHP: check data transfer on certain directories? Agum PHP 7 12-30-03 03:58 AM


All times are GMT -5. The time now is 03:37 PM.
vBulletin® Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.