Page 1 of 3 123 LastLast
Results 1 to 10 of 21

Thread: webserver connection check

  1. #1
    Join Date
    Apr 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Talking webserver connection check

    Hi guys,

    Is it possible to:
    after pressing a button on a website witch is redirecting to a new site,
    before redirecting to the new site, first check if the website is available,
    if not available >> do not try to redirect to the new site.

    Just a method to see if the web server (or website) is available before trying to download it.

    if possible >> how?

    thanks!

  2. #2
    Join Date
    Jul 2006
    Location
    just north of Boston, MA
    Posts
    1,806
    Thanks
    13
    Thanked 72 Times in 72 Posts

    Default

    umm that is basically asking it to connect 2 times?

  3. #3
    Join Date
    May 2006
    Location
    Sydney, Australia - Near the coast.
    Posts
    1,995
    Thanks
    0
    Thanked 8 Times in 7 Posts

    Default

    You could use PHP to do that, but definitely not JavaScript.
    Peter - alotofstuffhere[dot]com - Email Me - Donate via PayPal - Got spare hardware? Donate 'em to me :) Just send me a PM.
    Currently: enjoying the early holidays :)
    Read before posting: FAQ | What you CAN'T do with JavaScript | Form Rules | Thread Title Naming Guide

  4. #4
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Actually, it can be done with Javascript. It shouldn't be, but it can.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  5. #5
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default

    first check if the website is available,
    How can that be done with JavaScript?

    file_exists works with PHP, that's the only plausible way of doing it.
    - Mike

  6. #6
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    How can that be done with JavaScript?
    If you have the address of an image on that site:
    Code:
    var im = document.createElement("img");
    im.src = "http://www.someothersite.com/images/image.png";
    im.onload = function() {
      // The server is up.
    };
    im.onerror = function() {
      // The connection timed out, the server
      // isn't up (or there was a problem
      // accessing the image requested).
    };
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  7. #7
    Join Date
    Aug 2005
    Posts
    971
    Thanks
    0
    Thanked 0 Times in 0 Posts

  8. #8
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Not necessarily... just because the host is up, doesn't mean the webserver is. mburt is right, fsockopen() or file_exists() (the latter requires url_fopen enabled) are the better choices.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  9. #9
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default

    (the latter requires url_fopen enabled)
    I swear. Every person who's ever been on the PHP forum has asked some sort of question involving this, at least ONCE.

    Just a note for someone who's about to ask:
    It's a command in your php.ini which is either, off or on. If it is on, it allows you to basically "connect" to other sites' data. If it's off, you're royally screwed.
    - Mike

  10. #10
    Join Date
    Jun 2006
    Location
    Acton Ontario Canada.
    Posts
    677
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default

    What reasons would there be for turning it off?
    - Ryan "Boxxertrumps" Trumpa
    Come back once it validates: HTML, CSS, JS.

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
  •