<?php

// !!!!!!!!!!!!!!  ICQ IS NO LONGER WORKING  !!!!!!!!!!!!

// ICQ and YAHOO messenger status TEXT/IMAGE/SOUND/MOVIE indicator

// I was looking for years such a script. After discovering the PHP I decided to do it myself.
// The principe is quite simple. ICQ and Yahoo give only GIF image status indicator to their
// users. The PHP4 script collects the image status indicator given by ICQ and YAHOO then  
// compares it with the online, offline and disabled known images. Then it returns the status in
// TEXT mode, collectable under variable by Flash 4 (given by a "status=" variable), or in IMAGE
// mode with all image or sound formats SVG, SWF, JPG, PNG, GIF, MOV, RAM (this way you can
// play a sound or a talking phrase to indicate your online status). You can specify the image file
// or on your website by relative url /folder/images/my_image  or by an absolute URL with the
// HTTP or FTP or whatever method http://anothersite/images/onlineimage  Otherwise the
// default ICQ and  YAHOO images will be used.  Have fun ! Mike P. (Paris, France)


// This is my first PHP script. Feel free to send your comments or thanks messages to :
// Mail info@lashampoo.com / My ICQ number 9702290 / My site http://www.lashampoo.com

//
//
// Variables used :     icq=YOUR_ICQ#
//                   or yahoo=YOUR_YAHOO_ID
//
//                      &mode=text ( default if not specified )
//                   or &mode=image ( followed by &on=PATH/URL_TO_YOUR ONLINE_IMAGE
//                                                &off=PATH/URL_TO_YOUR OFFLINE_IMAGE
//                                                &dis=PATH/URL_TO_YOUR DISABLED_IMAGE )
//
// With ICQ, call your script using this syntax :
// STATUS.php3?icq=YOUR_ICQ#&mode=image&on=ONLINEIMAGE&off=OFFLINEIMAGE&dis=DISABLEDIMAGE


// SECURITY TIPS : to avoid people from using your script for their own purpose (with their
// ICQ or YAHOO account) you should lock your variables in this script and stop calling them
// with the GET fonction. Just fill out the variable ICQ and/or YAHOO below, and/or the other
// variables. Don't forget to remove de // sign in front of the locked variables to activate
// the desired variables.
//
//
// To lock variables fill out the fields beetween "" and remove the // sign in front.
//
// icq="YOUR_ICQ#";
// yahoo="YOUR_YAHOO_ID";
// mode="image";
// on="path/to/your/online_image";
// off="path/to/your/offline_image";
// dis="path/to/your/disabled_image";



// Retain some compatibility backwards like.
if( ini_get("register_globals"))
    {
        
extract($HTTP_POST_VARS);
        
extract($HTTP_GET_VARS);    
    }


//
//
// If the ICQ variable is found then configure images and URL detection for ICQ
if ($icq) {

// Configure default ONLINE/OFFLINE/DISABLED/ERROR ICQ images if none given
if ($on == "") { $on "http://www.icq.com/images/status/online-7.gif"; }
if (
$off == "") { $off "http://www.icq.com/images/status/offline-7.gif"; }
if (
$dis == "") { $dis "http://www.icq.com/images/status/disabled-7.gif"; }

// Configure the known ICQ images to compare with...
$states = array( 236=>"offline"421=>"disabled"69=>"online"2=>"invalid ICQ number"); 
$images= array( 236=>"$off"421=>"$dis"69=>"$on"2=>"http://icq.com/icons/alert.red.gif");

// Then collect the GIF status image on the ICQ website
$myfile=file("http://web.icq.com/whitepages/online/1,,,00.gif?icq=$icq&img=1");
//$myfile=file("http://wwp.icq.com/scripts/online.dll?icq=$icq&img=1");
}

//
//
// If the YAHOO variable is found then configure images and URL detection for YAHOO
elseif ($yahoo) {

// Configure default ONLINE/OFFLINE YAHOO images if none given
if ($on == "") { $on "http://us.i1.yimg.com/us.yimg.com/i/mesg/online1.gif"; }
if (
$off == "") { $off "http://us.i1.yimg.com/us.yimg.com/i/mesg/offline1.gif"; }

// Configure the known YAHOO images to compare with...
$states = array( 21=>"offline"178=>"online" ); 
$images= array( 21=>"$off"178=>"$on" );

// Then collect the GIF status image on the YAHOO website
$myfile=file("http://opi.yahoo.com/online?u=$yahoo&m=g&t=1"); }


//
//
// If none YAHOO or ICQ variable found then display an error message and quit
else { header("Content-type: text/plain"); header("Cache-Control: no-cache");
ECHO 
"Something is missing : you forgot YOUR_ICQ# or YOUR_YAHOO_ID#

FEATURES :      icq=YOUR_ICQ#
           or yahoo=YOUR_YAHOO_ID#

              &mode=text  ( default if not specified )
           or &mode=image ( followed by &on=PATH/URL_TO_YOUR/ONLINE_IMAGE
                                       &off=PATH/URL_TO_YOUR/OFFLINE_IMAGE
                                       &dis=PATH/URL_TO_YOUR/DISABLED_IMAGE )

For example, with ICQ, call your script using this syntax :
http://$_SERVER
[HTTP_HOST]$_SERVER[SCRIPT_NAME]?icq=YOUR_ICQ#&mode=image
"
; exit; }



//
//
// If IMAGE mode is ON then :
// Display the proper image with its HEADER and prevent from caching by proxy
if ($mode == "image") { $url=$images[strlen($myfile[0])]; 

// Handles the proper URL if the URL refers to a file with a relative path
if (!ereg("://",$url)) { $url="http://$HTTP_HOST$SCRIPT_NAME$url"
$thisscript=preg_replace('|(.*)\/([0-9a-zA-Z%.]*)|''\2'$SCRIPT_FILENAME);
$url=ereg_replace($thisscript,"",$url); } header("Cache-Control: no-cache"); 
header("Location: $url");  exit; }


//
//
// Otherwise TEXT mode is ON (by default) and display the status text
else { header("Content-type: text/plain"); header("Cache-Control: no-cache");
$status=$states[strlen($myfile[0])]; print("status=$status"); }


?>