Jump to content
xisto Community
ill

I.p. Ping Online Or Offline

Recommended Posts

Does anyone know of a script that will tell people if an IP is online or offline? Like it will ping it like every fifteen minutes or so and will display an online or offline image accordingly. Or at least it supports images, text is fine I guess, but I'd rather it use images.Any help on this will be appreciated! Thanks!

Share this post


Link to post
Share on other sites

Okay, I am an ancient programmer so I am giving you something that you would laugh at. I believe creating a batch file would be the best at this point. Since batch file would take the minimum CPU resource. Then you can have your Windows scheduler to activate it every 15 minutes. Save it as whatever.bat in any directory.
 



@echo offclsecho Testing connection to forum...
echo.ping https://forums.xisto.com/ -n 20
cls
echo Testing connection to mysite...
echo.ping www.MYSITE.domain/ -n 20
EXIT

Basically, this will open a DOS command window and run its course, then it will EXIT (close the screen). The -n 20 denotes that it will ping 20 times. You can change to whatever number you'd like. Don't forget to replace/add "mysite" with the domain you'd like to ping. For further extensions, type ping /? from your command line.

I hope this helps.
Cheers.



Share this post


Link to post
Share on other sites

if(!mysql_connect(what_ip?)){
?>
<img src="offline.gif">
<?
}
else {
?>
<img src="online.gif">
<?
}
?>

its based on a simple code that i use to check and show if my forums are online:

if(!mysql_connect(localhost, ***, ***)){?><img src="http://online.trap17.com/images/status_offline.gif" border="0" height="14"><?}else {?><img src="http://online.trap17.com/images/status_online.gif" border="0" height="14"><?}?>

I dont know if it works with an ip instead of localhost tho, and im not sure if it has to select a db and pass.

Also, if you want to get a whole list of members to be checked, you could use a db for it, selecting $username and $ip from the db for example:

mysql_connect('localhost','db_name','db_password') or die("could not connect to db");
$username= "mysql_query('select username from table')";
$ip= "mysql_query('select ip from table')";

if($username=!$ip){ echo "username doesnt match the ip"; }
else{
$connect= mysql_connect($ip);}
if(!$connect){
echo "<img src=\"offline.gif\">";}
else{ echo "<img src=\"online.gif\">";}

something like that? im a newbie php coder so sorry if it is all wrong :P

Share this post


Link to post
Share on other sites

Hmm, to ping an IP address from scratch, you would have to harness the ICMP (see RFC792). I suppose it could be done in PHP, but it is quite complex, and due to the nature of the language (it isn't really intended for such purposes), it could get quite resource intensive.

Another, more realistic option would be to use the system() function in PHP to execute a PING command and capture the output. I've never actually used it for this specific purpose myself, so I don't know how well it would work. Not all servers allow this though, due to security issues - I don't know if Xisto does or not.

Oh, and BuffaloHELP, Windows batch scripting isn't PHP.

Share this post


Link to post
Share on other sites

Me too

I.p. Ping Online Or Offline

 

Yea I need this too, if anyone can find it please email me at phillip_bm_gibson@hotmail.Com

 

I need it on my website

So if my ip address (computer) is on my site will say

 

Online !

 

And vice versa

 

Offline ! Thanks , Phil

 

-reply by phillip

 

----------admin reply--------

 

you can use PHP exec() function to ping your own home IP. The ping will execute on Server and it will send out put back to your program.

 

-shree

Share this post


Link to post
Share on other sites

online/offline image via javascript

I.p. Ping Online Or Offline

 

How do I do this with either html or javascript?

 

Link [online or offline image] (depending on IF address.Com is online or not)

 

I want to have a list of links with an online OR offline image next to

Each link, depending on the current online/offline status of that link.

 

-reply by Th3Eagle

 

-ADMIN REPLY-

 

You can achieve this using PHP.

 

There are functions to :-

 

1. Ping A Website.

2. Get a page from a website and scan for contents to check if everything is OK.

3. You can also check FTP, EMAIL etc. and other services of a website.

 

Search the web for PHP Website monitoring script.

Share this post


Link to post
Share on other sites

online/offline image via html

I.p. Ping Online Or Offline

 

I found a little know bit of html code that will do what I was wanting

 

 

<img onerror="this.src='offline.gif/';" src="serveraddress.com/online.Gif;
Will first try to load online.Gif from http://www.serveraddress.com/

Then IF online.Gif is NOT available, it will load offline.Gif

From the same folder that the webpage is located (local in my case)

 

No javascript, or PHP needed :)

 

 

-reply by Th3Eagle

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.