Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 300067
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T06:52:49+00:00 2026-05-12T06:52:49+00:00

The website is http://www.ipalaces.org/support/ The code I use for the status indicators is <img

  • 0

The website is http://www.ipalaces.org/support/

The code I use for the status indicators is

<img src="http://big.oscar.aol.com/imperialpalaces?on_url=http://www.ipalaces.org/support/widget/status_green.gif&off_url=http://www.ipalaces.org/support/widget/status_offline.gif">

which is a neat thing that big.oscar.aol.com lets you do, it redirects it to whatever image you have set for the on_url if they are online, and same for off_url for offline. However, I want to use this in an if statement in PHP or javascript to display different things. Currently I am using this:

function getaim($screenname) {
        $ch     = curl_init();
        $url    = "http://big.oscar.aol.com/$screenname?on_url=true&off_url=false";
        curl_setopt($ch, CURLOPT_URL,$url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
        // added to fix php 5.1.6 issue:
        curl_setopt($ch, CURLOPT_HEADER, 1);
        $result = curl_exec($ch);
        curl_close($ch);

        if(eregi("true",$result)) {
            return true;
        } else {
            return false;
        }
}

If (getaim("ImperialPalaces")) { print "Online"; } else { print "Offline"; }

The problem with this code is that for some reason, at random times it can take up to 12 seconds for it to actually retrieve the results. Whereas the standard img trick is almost instant.

Is there a known issue with curl? Is there a faster way?

I’ve seen someone try to read the .src of the img tag and do an if statement like that, but I couldnt get it to work.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T06:52:50+00:00Added an answer on May 12, 2026 at 6:52 am

    To avoid waiting for a dozen seconds when things are not doing OK, you can set a couple more options, like (see curl_setopt) :

    • CURLOPT_CONNECTTIMEOUT : The number of seconds to wait while trying to connect. Use 0 to wait indefinitely.
      • setting it to a couple of seconds would be enough
    • CURLOPT_TIMEOUT : The maximum number of seconds to allow cURL functions to execute.
      • same for this one
    • CURLOPT_DNS_CACHE_TIMEOUT : The number of seconds to keep DNS entries in memory. This option is set to 120 (2 minutes) by default.
      • You could probably set this to a higher value

    If users of your website generally stay on it for more than only one or two pages, it might be interesting to store that information in $_SESSION, and only fetch it once in a while.

    For instance, you could fetch it only if the value stored in session has been fetched more than 5 minutes ago. It would probably save a couple of calls 🙂


    One other way might be to do that on the client-side :

    • fetch the image with the <img> tag
    • in case of “online”, use an image that loads OK
      • plug a handler on the “load” even of the image, to replace it with some text
    • in case of “offline”, use an image that is in 404
      • plug a handler on the “error” even of the image, to replace it with some text

    That’s not very nice (it’s kind of “hacky”, in the wrong way), but it should work 😉

    Your image would be like this :

    <div id="arround-1">
        <img id="img-1" src="http://big.oscar.aol.com/imperialpalaces?on_url=http://www.ipalaces.org/support/widget/status_green.gif&amp;off_url=http://this.is-a-404-error.com"
            onload="replace_img_status(1, 1);"
            onerror="replace_img_status(1, 0);"
        />
    </div>
    

    You see that, if the user is connected, the <img> finally leads to an image that exists ; so, the “load” even will be fired.

    And, in the case the user is not connected, the <img> will finally lead to an image that doesn’t exist (it’s giving a 404 error) ; so, the “error” event will be fired.

    You now have to take care of those two cases, with something like this :

    <script type="text/javascript">
        var replace_img_status = function (num, status) {
            var div = document.getElementById('arround-' + num);
            if (div) {
                if (status == 1) {
                    div.innerHTML = 'Online';
                } else {
                    div.innerHTML = 'Offline';
                }
            }
        };
    </script>
    

    If status is 1, we display “Online”, and, in the other case (“error”), we display “Offline” 🙂

    But, even is it seems to be working, I don’t really like that solution ^^

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just created a website ( http://www.kalif.ca ) for my business. When I load
I'm working on a website: http://www.ourbridalsongs.com and am trying to implement a hover type
I have come across this website: http://www.fetchak.com/ie-css3/ It seems to work when I enter
please take a look at the following website: http://www.solidcamxpress.co.uk/ If you look at it
I want to create an FAQ page like the one on this website http://www.microsoft.com/windows/windows-7/faq.aspx
I am developing a website for a Curling Club in France. When you open
I'm trying to code my navigation on my portfolio and am looking for a
I have been looking through the documentation for the API and not sure if
I'm developing an ecommerce store using MVC and it will feature various health food
I am using two panels at the top of my web page that drop

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.