<?php
//Header("content-type: application/x-javascript");
//$serverIP=$_SERVER['REMOTE_ADDR'];
//Just copy and paste these code into your page and change the bold text into yours ...
class Yahoo {
	//function ymstatus($yahooid, $img_ol_path, $img_off_path, $title) {
	function ymstatus($yahooid) {
	//function ymstatus('nd_helpdesk', 'yahoo/nguyenduong_online.gif', 'yahoo/nguyenduong_offline.gif', 'nd_helpdesk') {
		$yahoo_url = "http://opi.yahoo.com/online?u={$yahooid}&m=a&t=1";
		if (ini_get('allow_url_fopen')) {
			error_reporting(0);
			$yahoo = file_get_contents($yahoo_url);
		} elseif(function_exists('curl_init')) {
			$ch = curl_init($yahoo_url);
			curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
			curl_setopt ($ch, CURLOPT_HEADER, 0);
			$yahoo = curl_exec($ch);
			curl_close($ch);
		}
		$yahoo = trim($yahoo);
		if(empty($yahoo)) {
			/* Maybe failed connection.*/
			//$imgsrc = $img_off_path;
			return 'off';
		} elseif($yahoo == "01") {
			//$imgsrc = $img_ol_path;
			return 'on';
		} elseif($yahoo == "00") {
			//$imgsrc = $img_off_path;
			return 'off';
		} else {
			/* We don't know what happen but we'll use offline button anyway. */
			//$imgsrc = $img_off_path;
			return 'off';
		}
	//echo '<div style="float:left; width:141px; color:#999999; margin-right: 0px; margin-left:0px; margin-top: 5px; margin-bottom: 3px;"> <a href="ymsgr:sendim?' . $yahooid . '" title="' . $title . '">';
	//    echo '<img src="' . $imgsrc . '" alt="' . $title . '"  border="0px" " /></a></div>';
	//return $imgsrc;
	}
}
$ys = new Yahoo();
// assign a temporary id, we will 
//use ernie id because he's always online
//$yid = 'nd_helpdesk';
  $ystatus = $ys->ymstatus('nd_helpdesk');
//ymstatus('nd_helpdesk', 'yahoo/nguyenduong_online.gif', 'yahoo/nguyenduong_offline.gif', 'nd_helpdesk');
//echo ymstatus('nd_helpdesk', 'yahoo/nguyenduong_online.gif', 'yahoo/nguyenduong_offline.gif', 'nd_helpdesk');
//echo ymstatus('nd_helpdesk', 'yahoo/nguyenduong_online.gif', 'yahoo/nguyenduong_offline.gif', 'nd_helpdesk');
//echo "document.write(\"{ymstatus('nd_helpdesk', 'yahoo/nguyenduong_online.gif', 'yahoo/nguyenduong_offline.gif', 'nd_helpdesk') }\")";
//$yah = echo "document.write(\"ymstatus('nd_helpdesk', 'yahoo/nguyenduong_online.gif', 'yahoo/nguyenduong_offline.gif', 'nd_helpdesk') \")";
//print $yah;
//print {ymstatus('nd_helpdesk', 'yahoo/nguyenduong_online.gif', 'yahoo/nguyenduong_offline.gif', 'nd_helpdesk')};
?>
