Forum Moderators: coopster

Message Too Old, No Replies

Need some sort of pinger script?

pinging

         

Michallinis

9:01 am on May 22, 2008 (gmt 0)

10+ Year Member



Sometimes these sites I like to go to close their registration. So I wanted to run a script on my server that will ping their registration URL until the error code is gone, which would then mean its open for registration. Does anyone know of a script that can do this?

dublinmike

10:42 am on May 22, 2008 (gmt 0)

10+ Year Member



Hi there,

If you want to check whether a site is up, you can use a function like this:


function site_is_up($domain)
{
if(@fsockopen ($domain, 80, $errno, $errstr, 1)===FALSE) return false;
return true;
}

If the site is always up but sometimes it takes registrations, sometimes not, you could use

file_get_contents($url)
to retrieve the contents of the file and then search for a particular word that would indicate the page's status, e.g.


if(strpos(file_get_contents($url_to_check),'Registration now open')!==FALSE)
{
print "Registrations are now open";
}

Michallinis

12:44 am on May 23, 2008 (gmt 0)

10+ Year Member



So I can just put the url where the $domain is and save this as a .php file and it will work?

dublinmike

10:53 am on May 23, 2008 (gmt 0)

10+ Year Member



That function will just check to see if there is any response from the server. Put the function in a PHP file as is and then call the function using something like:


if(site_is_up('www.myremotesite.com'))
{
print 'MyRemoteSite is available';
}

If there's always going to be a positive response from the server but registrations aren't necessarily going to be open, the second implementation will be necessary.