Log in

View Full Version : PHP ping results



boxxertrumps
11-13-2006, 10:44 PM
is this right?

<?php
$ping1 = system("ping -n 2 services.****irc.net");
$ping2 = system("ping -n 2 ecstasy.****irc.net");
$ping3 = system("ping -n 2 oxycontin.****irc.net");
$ping4 = system("ping -n 2 hydrocodone.****irc.net");

echo $ping1;
echo '<hr />';
echo $ping2;
echo '<hr />';
echo $ping3;
echo '<hr />';
echo $ping4;

?>

simple ping script that i wrote using bits of this code...
http://www.theworldsend.net/ping_src.php
Enjoy...

Edit....
and i didnt know you could use php with images...
http://www.thepregnancytester.com/image.php?dad_title=Michael%20Jackson&NAME=Gandalf%20The%20Gray&kn=Andrew%20Justin%20Jackson&LBS=12&OZS=3
dynamically created birth certificate....only a spoof though...

Acey99
11-14-2006, 12:18 AM
What exactly is this for?

and you know that may only work on a Nix box ?

if Ping is enabled as well as the stuff for System
both can be disabled.

boxxertrumps
11-14-2006, 02:03 AM
its for my freind that runs a couple irc/http servers,
and he wants to have a page with the admin for each
and their ping time, so that ones with really high traffic
people wont use. and it will also show if the server is
up or not (timeout)

back to the main question, is there anything wrong with the code?

ItsMeOnly
11-14-2006, 04:24 PM
Basically nothing's wrong, however the script will "hang" when you have DNS problems. After that I see you even took simple precautions about adding some unwanted "attributes" to ping command, however on form validation only (the regex you use is insufficient).

boxxertrumps
11-14-2006, 06:29 PM
so i would have a better chance of success with using the IP address instead... and what unwanted attributes?

Twey
11-14-2006, 08:33 PM
$register_globals = (bool) ini_get('register_gobals');Don't code for register_globals, even conditionally. $_GET, $_POST, and $_REQUEST still work even if register_globals is enabled, and you should use them instead.
$host= preg_replace ("/[^A-Za-z0-9.-]/","",$host);
$count= preg_replace ("/[^0-9.]/","",$count);Instead of this, try shell_escape (http://www.php.net/shell-escape)().
system("killall ping");// kill all ping processes in case there are some stalled ones or use echo 'ping' to execute ping without shellPointless. If this code is reached, the ping has already ended :p

boxxertrumps
11-14-2006, 09:34 PM
i have no clue what you just said....
its very confusing for a php noob like me....