|
|
|
|
![]() ![]() |
May 12 2005, 07:30 PM
Post
#1
|
|
|
Super Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 386 Joined: 10-August 04 From: United States Member No.: 761 |
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! |
|
|
|
May 12 2005, 07:53 PM
Post
#2
|
|
|
Desperately seeking "any key" to continue... ![]() Group: Admin Posts: 3,467 Joined: 23-April 05 From: Trap17 storage box Member No.: 6,042 |
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.
CODE @echo off cls echo Testing connection to forum... echo. ping www.trap17.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. |
|
|
|
May 13 2005, 01:06 AM
Post
#3
|
|
|
Super Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 362 Joined: 2-March 05 From: The Netherlands Member No.: 4,097 |
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: CODE 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 |
|
|
|
May 24 2005, 02:52 AM
Post
#4
|
|
|
Privileged Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 874 Joined: 30-July 04 Member No.: 246 |
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 Trap17 does or not. Oh, and BuffaloHELP, Windows batch scripting isn't PHP. |
|
|
|
May 29 2005, 02:14 PM
Post
#5
|
|
|
Privileged Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 618 Joined: 30-October 04 From: Philippines Member No.: 2,049 |
Try this:
CODE <?php
ini_set("default_socket_timeout","05"); set_time_limit(5); $f=fopen("http://www.somesite.com","r"); $r=fread($f,1000); fclose($f); if(strlen($r)>1) { echo("<b>Online</b>"); }else { echo("<b>Offline</b>"); } ?> |
|
|
|
Jul 30 2008, 03:02 PM
Post
#6
|
|
|
Trap Double Mocha Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 2,360 Joined: 21-September 07 Member No.: 50,369 |
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 |
|
|
|
Aug 28 2008, 10:38 AM
Post
#7
|
|
|
Trap Double Mocha Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 2,360 Joined: 21-September 07 Member No.: 50,369 |
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. |
|
|
|
![]() ![]() |
Similar Topics
|
Lo-Fi Version | Time is now: 5th September 2008 - 08:42 AM |