MikeJ Posted April 21, 2004 Posted April 21, 2004 (edited) I wanted something a little more stable than OSI, and I wanted support for BitWise, so I wrote my own script. Plus it was a good excercise in learning PHP. Currently supports ICQ, AIM, Yahoo, and BitWise. Does not support MSN, may never support MSN because they don't provide any easy way of checking status (other than an MSN bot which is not the most reliable). I don't really use MSN either. The goal of this script was to be fast (for minimal effect for forum sigs and web pages)... so it caches the result for 2 minutes (so the change in state can take up to 2 minutes) and when it attempts to get the status from the offical servers, it will timeout after 5 seconds and deliver an offline status (instead of hanging). This is pretty much as polished as it's gonna be for awhile probably. I'm pretty new to PHP so I don't claim it to be quality code. This isn't quite plug and play either (requires phpCache and cURL). If anyone finds it useful or has suggestions for improvements, I wouldn't mind hearing from ya. <http://biggorilla.com/tools/imstatus.phps> ><?php /* Instant Messenger Status v1.0 - Allow use of custom status icons Copyright (C) 2004 Michael Jones - mike@biggorilla.com This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. <http://www.gnu.org/licenses/gpl.txt> ----- Requires phpCache <http://www.0x00.org/php/phpCache/> Comment out the line "ob_end_flush();" in phpCache.inc so that headers don't get sent prematurely (Line 249 in phpCache v1.4) Depending on your environment, you may also want to change CACHE_DIR. Requires PHP to have cURL support compiled in. Check your PHP configuration. <http://curl.haxx.se/> ----- Usage: http://******/imstatus.php?<imtype>=<user>&on=<url>&off=<url> Online and Offline images are optional (specify location for default images below) Aim status requires an aimon.txt and aimoff.txt with 01 and 00 with no newline (echo -n 01 > aimon.txt) for simplicity (I wanted to be able to cache a result). */ ini_set("display_errors","0"); // Set to 1 for debugging $imgurl = "http://******/images/imstatus/"; // Location of default images include("phpCache/phpCache.inc"); // Change to location of phpCache.inc file function get_status($url) { $res = curl_init(); curl_setopt($res, CURLOPT_URL, $url); curl_setopt($res, CURLOPT_HEADER, 0); curl_setopt($res, CURLOPT_TIMEOUT, 5); curl_setopt($res, CURLOPT_RETURNTRANSFER, 1); curl_setopt($res, CURLOPT_FOLLOWLOCATION, 1); return curl_exec($res); curl_close($res); } if ($yahoo) { if (!$on) $on = $imgurl."yahooonline.gif"; if (!$off) $off = $imgurl."yahoooffline.gif"; if (!($et=cache_all(120))) { $status = get_status("http://opi.yahoo.com/online?u=$yahoo&m=t&t=1"); cache_variable("status"); endcache(); } if ($status == "01") { header("Location: $on"); } else { header("Location: $off"); } } elseif ($aim) { if (!$on) $on = $imgurl."aimonline.gif"; if (!$off) $off = $imgurl."aimoffline.gif"; if (!($et=cache_all(120))) { $status = get_status("http://big.oscar.aol.com/$aim?on_url={$imgurl}aimon.txt&off_url={$imgurl}aimoff.txt"); cache_variable("status"); endcache(); } if ($status == "01") { header("Location: $on"); } else { header("Location: $off"); } } elseif ($icq) { if (!$on) $on = $imgurl."icqonline.gif"; if (!$off) $off = $imgurl."icqoffline.gif"; if (!($et=cache_all(120))) { $image = get_status("http://status.icq.com/online.gif?icq=$icq&img=5"); $status = crc32($image); cache_variable("status"); endcache(); } switch ($status) { case "-1418424622": // Online header("Location: $on"); break; default: // Offline or Error header("Location: $off"); } } elseif ($bitwise) { if (!$on) $on = $imgurl."bwonline.gif"; if (!$off) $off = $imgurl."bwoffline.gif"; if (!($et=cache_all(120))) { $image = get_status("http://www.bitwisecommunications.com/users/webBug.php?id=$bitwise"); $status = crc32($image); cache_variable("status"); endcache(); } // CRC values based on text-only Bitwise status icons (see your BW online preferences) switch ($status) { case "-1496083650": // Online case "-1796816539": // Away header("Location: $on"); break; default: // Offline or Error header("Location: $off"); } } ?> Edited April 21, 2004 by TCH-MikeJ Quote
MikeJ Posted April 21, 2004 Author Posted April 21, 2004 (edited) Btw, I should mention that if you are hosted on a shared hosting account and you post on a lot of high volume boards, this might not be the best tool for you to install. I've recieved close to 23,000 hits to it this month alone just from the TCH forums and I'm the only one with it in my sig. Edited April 21, 2004 by TCH-MikeJ Quote
anmool Posted November 14, 2008 Posted November 14, 2008 Thank you very much TCH-Mike. I have implemented this script in Status Checker Script. It is great IM status checker script, but i think, most of the time server is down? Quote
TCH-Bruce Posted November 14, 2008 Posted November 14, 2008 Welcome to the forums anmool Yes, you are correct about it being down a lot. Also, this post is now 4 years old. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.