User Name
Password

Go Back   Planetarion Forums > Non Planetarion Discussions > Programming and Discussion

Reply
Thread Tools Display Modes
Unread 2 Nov 2003, 12:56   #1
Gayle29uk
Bitch
 
Join Date: Jun 2002
Location: North Yorkshire
Posts: 3,848
Gayle29uk is just really niceGayle29uk is just really niceGayle29uk is just really niceGayle29uk is just really nice
PHP ping

Ok, head hurts

Has anyone any idea how to ping an IP address from a PHP script? I seem to be looking at raw sockets and I don't like that much at all


P.S. Any answers involving exec() or similar will result in me screaming at you incoherently.
__________________
ACHTUNG!!!
Das machine is nicht fur gefingerpoken und mittengrabben. Ist easy
schnappen der springenwerk, blowenfusen und corkenpoppen mit
spitzensparken. Ist nicht fur gewerken by das dummkopfen. Das
rubbernecken sightseeren keepen hands in das pockets. Relaxen und vatch
das blinkenlights!!!
Gayle29uk is offline   Reply With Quote
Unread 2 Nov 2003, 13:37   #2
Gayle29uk
Bitch
 
Join Date: Jun 2002
Location: North Yorkshire
Posts: 3,848
Gayle29uk is just really niceGayle29uk is just really niceGayle29uk is just really niceGayle29uk is just really nice
Re: PHP ping

I tried playing with raw sockets and discovered that crappy webhost doesn't allow them

Bleugh.
__________________
ACHTUNG!!!
Das machine is nicht fur gefingerpoken und mittengrabben. Ist easy
schnappen der springenwerk, blowenfusen und corkenpoppen mit
spitzensparken. Ist nicht fur gewerken by das dummkopfen. Das
rubbernecken sightseeren keepen hands in das pockets. Relaxen und vatch
das blinkenlights!!!
Gayle29uk is offline   Reply With Quote
Unread 2 Nov 2003, 13:40   #3
inf
Banned
 
Join Date: Dec 2000
Location: autogenic misery
Posts: 872
inf is an unknown quantity at this point
Re: PHP ping

google is your friend
inf is offline   Reply With Quote
Unread 2 Nov 2003, 13:45   #4
Gayle29uk
Bitch
 
Join Date: Jun 2002
Location: North Yorkshire
Posts: 3,848
Gayle29uk is just really niceGayle29uk is just really niceGayle29uk is just really niceGayle29uk is just really nice
Re: PHP ping

Quote:
Originally Posted by inf
Google has many many links to scripts using exec() or similar and parsing the resulting output string.

I wanted to do it natively and the only link I found used raw sockets which my webhost doesn't allow and I don't know of any other way of doing it
__________________
ACHTUNG!!!
Das machine is nicht fur gefingerpoken und mittengrabben. Ist easy
schnappen der springenwerk, blowenfusen und corkenpoppen mit
spitzensparken. Ist nicht fur gewerken by das dummkopfen. Das
rubbernecken sightseeren keepen hands in das pockets. Relaxen und vatch
das blinkenlights!!!
Gayle29uk is offline   Reply With Quote
Unread 2 Nov 2003, 13:54   #5
pablissimo
Henry Kelly
 
pablissimo's Avatar
 
Join Date: Apr 2000
Posts: 7,374
pablissimo has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.pablissimo has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.pablissimo has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.pablissimo has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.pablissimo has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.pablissimo has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.pablissimo has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.pablissimo has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.pablissimo has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.pablissimo has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.pablissimo has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.
Re: PHP ping

Try connecting to the host as if it were a webpage or similar using the standard file IO functions and timing how long it takes, it might be a bodged effort if there's no other way. Then deduct some small percentage to take into account any target system overhead that may have existed.

Can't think of another way without using sockets.
__________________
You're now playing ketchup
pablissimo is offline   Reply With Quote
Unread 2 Nov 2003, 14:44   #6
Gayle29uk
Bitch
 
Join Date: Jun 2002
Location: North Yorkshire
Posts: 3,848
Gayle29uk is just really niceGayle29uk is just really niceGayle29uk is just really niceGayle29uk is just really nice
Re: PHP ping

Quote:
Originally Posted by pablissimo
Try connecting to the host as if it were a webpage or similar using the standard file IO functions
That's what I'm doing as a bodge job. I'm not really bothered about the ping time, I just want to know it's replying.

However, I may alter this so it opens a telnet connection to the remote router as a comms check. That would work as well as a ping
__________________
ACHTUNG!!!
Das machine is nicht fur gefingerpoken und mittengrabben. Ist easy
schnappen der springenwerk, blowenfusen und corkenpoppen mit
spitzensparken. Ist nicht fur gewerken by das dummkopfen. Das
rubbernecken sightseeren keepen hands in das pockets. Relaxen und vatch
das blinkenlights!!!
Gayle29uk is offline   Reply With Quote
Unread 3 Nov 2003, 18:31   #7
BuddhistPunk
Registered User
 
Join Date: Apr 2002
Location: Leeds, but looking for a way to escape
Posts: 128
BuddhistPunk is an unknown quantity at this point
Re: PHP ping

Are you sitting comfortably?

http://code.blitzaffe.com/php.php#icmpping
__________________
SELECT everything FROM everywhere WHERE something = something_else;
> 42
BuddhistPunk is offline   Reply With Quote
Unread 3 Nov 2003, 18:40   #8
pablissimo
Henry Kelly
 
pablissimo's Avatar
 
Join Date: Apr 2000
Posts: 7,374
pablissimo has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.pablissimo has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.pablissimo has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.pablissimo has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.pablissimo has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.pablissimo has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.pablissimo has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.pablissimo has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.pablissimo has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.pablissimo has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.pablissimo has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.
Re: PHP ping

Quote:
Originally Posted by BuddhistPunk
Are you sitting comfortably?

http://code.blitzaffe.com/php.php#icmpping
Quote:
Originally Posted by that website
Note that access to raw sockets requires root access, so this script also requires root access - rendering it more or less useles for web applications
Quote:
Originally Posted by Gayle29uk
and the only link I found used raw sockets which my webhost doesn't allow
__________________
You're now playing ketchup
pablissimo is offline   Reply With Quote
Unread 3 Nov 2003, 18:53   #9
Gayle29uk
Bitch
 
Join Date: Jun 2002
Location: North Yorkshire
Posts: 3,848
Gayle29uk is just really niceGayle29uk is just really niceGayle29uk is just really niceGayle29uk is just really nice
Re: PHP ping

Quote:
Originally Posted by pablissimo
<observant>
Yup, that's the one
__________________
ACHTUNG!!!
Das machine is nicht fur gefingerpoken und mittengrabben. Ist easy
schnappen der springenwerk, blowenfusen und corkenpoppen mit
spitzensparken. Ist nicht fur gewerken by das dummkopfen. Das
rubbernecken sightseeren keepen hands in das pockets. Relaxen und vatch
das blinkenlights!!!
Gayle29uk is offline   Reply With Quote
Unread 3 Nov 2003, 21:19   #10
inf
Banned
 
Join Date: Dec 2000
Location: autogenic misery
Posts: 872
inf is an unknown quantity at this point
Re: PHP ping

google is your friend
inf is offline   Reply With Quote
Unread 4 Nov 2003, 01:31   #11
pablissimo
Henry Kelly
 
pablissimo's Avatar
 
Join Date: Apr 2000
Posts: 7,374
pablissimo has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.pablissimo has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.pablissimo has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.pablissimo has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.pablissimo has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.pablissimo has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.pablissimo has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.pablissimo has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.pablissimo has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.pablissimo has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.pablissimo has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.
Re: PHP ping

That... wasn't useful at all.

Of the ones I found on Google, most used some variation of exec, some used raw sockets, and one

Code:
<?php 
    function ping($host) 
    { 
        $ip = gethostbyname($host); 
        $ping = `ping -c 1 -q $ip`; 
        $res = '1 packets transmitted, 1 packets recieved'; 
        if(strpos($ping, $res)) 
            return true; 
        else 
            return false; 
    } 
?>
Doesn't actually appear to do...anything of value

ps Google is inf's friend
__________________
You're now playing ketchup

Last edited by pablissimo; 4 Nov 2003 at 01:41.
pablissimo is offline   Reply With Quote
Unread 4 Nov 2003, 13:25   #12
CjC
Throwing Shapes
 
CjC's Avatar
 
Join Date: Apr 2000
Posts: 797
CjC has a brilliant futureCjC has a brilliant futureCjC has a brilliant futureCjC has a brilliant futureCjC has a brilliant futureCjC has a brilliant futureCjC has a brilliant futureCjC has a brilliant futureCjC has a brilliant futureCjC has a brilliant futureCjC has a brilliant future
Re: PHP ping

dont these scripts rely on two things?

1) What type of Web Server it is (IIS/Apache etc.. Linux/Windows or whatever) and
2) Whether or not the host actually allows ICMP packets to be sent from the webserver.
__________________
Time is an Illusion, Lunchtime doubly so.
CjC is offline   Reply With Quote
Unread 4 Nov 2003, 13:40   #13
pablissimo
Henry Kelly
 
pablissimo's Avatar
 
Join Date: Apr 2000
Posts: 7,374
pablissimo has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.pablissimo has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.pablissimo has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.pablissimo has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.pablissimo has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.pablissimo has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.pablissimo has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.pablissimo has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.pablissimo has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.pablissimo has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.pablissimo has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.
Re: PHP ping

...yes
__________________
You're now playing ketchup
pablissimo is offline   Reply With Quote
Unread 4 Nov 2003, 18:07   #14
Gayle29uk
Bitch
 
Join Date: Jun 2002
Location: North Yorkshire
Posts: 3,848
Gayle29uk is just really niceGayle29uk is just really niceGayle29uk is just really niceGayle29uk is just really nice
Re: PHP ping

Quote:
Originally Posted by pablissimo
Of the ones I found on Google, most used some variation of exec, some used raw sockets, and one

Code:
<?php 
    function ping($host) 
    { 
        $ip = gethostbyname($host); 
        $ping = `ping -c 1 -q $ip`; 
        $res = '1 packets transmitted, 1 packets recieved'; 
        if(strpos($ping, $res)) 
            return true; 
        else 
            return false; 
    } 
?>
Doesn't actually appear to do...anything of value
Enclosing a command in backticks (``) executes it as a shell command and returns the output
__________________
ACHTUNG!!!
Das machine is nicht fur gefingerpoken und mittengrabben. Ist easy
schnappen der springenwerk, blowenfusen und corkenpoppen mit
spitzensparken. Ist nicht fur gewerken by das dummkopfen. Das
rubbernecken sightseeren keepen hands in das pockets. Relaxen und vatch
das blinkenlights!!!
Gayle29uk is offline   Reply With Quote
Unread 4 Nov 2003, 18:12   #15
pablissimo
Henry Kelly
 
pablissimo's Avatar
 
Join Date: Apr 2000
Posts: 7,374
pablissimo has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.pablissimo has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.pablissimo has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.pablissimo has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.pablissimo has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.pablissimo has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.pablissimo has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.pablissimo has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.pablissimo has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.pablissimo has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.pablissimo has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.
Re: PHP ping

Quote:
Originally Posted by Gayle29uk
Enclosing a command in backticks (``) executes it as a shell command and returns the output
You learn something every day.

So how would you make a string that corresponds to a command but you don't want evaluated? Escape 'everything'?
__________________
You're now playing ketchup
pablissimo is offline   Reply With Quote
Unread 5 Nov 2003, 20:36   #16
queball
Ball
 
queball's Avatar
 
Join Date: Oct 2001
Posts: 4,410
queball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so little
Re: PHP ping

What are you looking for? A way to send raw packets even though you're explicitly not allowed to? There is a reason /bin/ping has to be SUID on a usual unixy setup, even if I personally don't think the reasons are very good. What you are asking is simply not allowed by the security model.

(You could use a seperate ping-daemon thing if the original post is a trick question.)
__________________
#linux
queball is offline   Reply With Quote
Unread 5 Nov 2003, 21:13   #17
W
Gubbish
 
Join Date: Sep 2000
Location: #FoW
Posts: 2,323
W is a jewel in the roughW is a jewel in the roughW is a jewel in the rough
Re: PHP ping

Quote:
Originally Posted by pablissimo
You learn something every day.

So how would you make a string that corresponds to a command but you don't want evaluated? Escape 'everything'?
Backticks (`) are different from single quotes (') and double quotes (")
__________________
Gubble gubble gubble gubble
W is offline   Reply With Quote
Unread 5 Nov 2003, 21:20   #18
pablissimo
Henry Kelly
 
pablissimo's Avatar
 
Join Date: Apr 2000
Posts: 7,374
pablissimo has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.pablissimo has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.pablissimo has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.pablissimo has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.pablissimo has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.pablissimo has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.pablissimo has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.pablissimo has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.pablissimo has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.pablissimo has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.pablissimo has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.
Re: PHP ping

Ohhh backticks

I was reading them as single quotes =((
__________________
You're now playing ketchup
pablissimo is offline   Reply With Quote
Unread 5 Nov 2003, 21:33   #19
Gayle29uk
Bitch
 
Join Date: Jun 2002
Location: North Yorkshire
Posts: 3,848
Gayle29uk is just really niceGayle29uk is just really niceGayle29uk is just really niceGayle29uk is just really nice
Re: PHP ping

Quote:
Originally Posted by queball
What are you looking for? A way to send raw packets even though you're explicitly not allowed to? There is a reason /bin/ping has to be SUID on a usual unixy setup, even if I personally don't think the reasons are very good. What you are asking is simply not allowed by the security model.

(You could use a seperate ping-daemon thing if the original post is a trick question.)
I wanted to ping a remote server to see if it was up or not. Instead I've implemented it in a little more detail and it now uses fsockopen() to open a socket to hostort which lets me monitor specific services instead of just whether as host is up or not.
__________________
ACHTUNG!!!
Das machine is nicht fur gefingerpoken und mittengrabben. Ist easy
schnappen der springenwerk, blowenfusen und corkenpoppen mit
spitzensparken. Ist nicht fur gewerken by das dummkopfen. Das
rubbernecken sightseeren keepen hands in das pockets. Relaxen und vatch
das blinkenlights!!!
Gayle29uk is offline   Reply With Quote
Reply


Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Need some simple and usefull tips for making a site with PHP Structural Integrity Programming and Discussion 12 6 Feb 2003 13:50
Two FreeBSD questions: Locate and PHP Mong Hardware and Tech Support 4 11 Dec 2002 11:06
php and windows Ragnarak Programming and Discussion 14 28 Nov 2002 14:34
advatages java compared to php wu_trax Programming and Discussion 59 20 Nov 2002 02:51


All times are GMT +1. The time now is 19:14.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2002 - 2018