SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Addict RapidGaming's Avatar
    Join Date
    Sep 2003
    Location
    UK
    Posts
    204
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Ping a site (up or down)

    I'd like to ping $url and either return TRUE or FALSE (meaning up or down). We could also do it as if(...) { echo 'up'; } else { echo 'down'; }

    Any ideas please?

  2. #2
    Can we go to a 48 hour day?
    Join Date
    May 2002
    Location
    MI
    Posts
    906
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just a side note, but make sure you can ping the site. A lot of people are setting up their firewalls to not respond to them anymore.
    mitechie.com
    "Techies just think a little differently
    ...at least that is what they keep telling me."

  3. #3
    Prolific Blogger silver trophy Technosailor's Avatar
    Join Date
    Jun 2001
    Location
    Before These Crowded Streets
    Posts
    9,446
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
      $cmd "ping $$ip";
      if((`
    $cmd) === true)
        {
        # true
        }
      else
        {
        # true
        } 
    Aaron Brazell
    Technosailor



  4. #4
    SitePoint Addict RapidGaming's Avatar
    Join Date
    Sep 2003
    Location
    UK
    Posts
    204
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I see. Thanks. This is for an "uptime monitor" I'm trying to develop so people would register their addresses anyway.

  5. #5
    SitePoint Zealot vbthanks's Avatar
    Join Date
    May 2001
    Location
    Sydney
    Posts
    170
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    duece868 is right - ping will not work most times. Try this...
    PHP Code:
    $server = @implode(''file($fileURL)); 
    Upload a txt file to the $fileURL containing the text 'Online'.
    PHP Code:
    if ($server != "Online") {
    $server "Offline";
    $serverError 1;

    I was working on exactly this last week
    Mike
    "You know what you know - but that's all you know!"

  6. #6
    PHP manual bot bronze trophy Gaheris's Avatar
    Join Date
    Oct 2003
    Location
    Germany
    Posts
    2,195
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You could try to connect to the server with fsockopen.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •