Location: PHPKode > scripts > Simple Yahoo Status Checker > simpleYahooStatusChecker/php/classes/checkUser.class.php
<?php

class checkUser {
	
	private $serviceURL  = null;
	
	private $servicePort = null;
	
	private $msnServer   = null;
	
	private $msnPort     = null;
	
	public $username     = null;
	
	public $checkService = null;
	
	public $errorMsg     = null;
	
	public $status       = null;
	
	public $response     = null;
	
	public $avatarLink   = null;
	
	public function checkUserStatus () {
		$this->getStatus();
	}
	
	private function setStatus ($status) {
		return $this->status = $status;
	}
	
	private function setAvatar ($avatarLink) {
		return $this->avatarLink = $avatarLink;
	}
	
	private function getStatus () {
		switch ($this->checkService) {
			case 'yahoo' : {
				$this->serviceURL = 'http://opi.yahoo.com/online?u='.$this->username.'&m=k&t=1';
				$ch = curl_init($this->serviceURL);
			    curl_setopt($ch, CURLOPT_URL, $this->serviceURL);
			    curl_setopt($ch, CURLOPT_HEADER, 0);
			
			    ob_start();
			    curl_exec($ch);
			    $content = ob_get_contents();
			    curl_close($ch);
			    ob_get_clean();
			
			    if (trim(strtolower(strip_tags($content))) != 'user not specified.') {
			    	if ($content == 00) {
			    		$this->setStatus('Offline');
			    	}
			    	if ($content == 01) {
			    		$this->setStatus('Online');
			    	}
			    }
			    $this->setAvatar('http://img.msg.yahoo.com/avatar.php?yids='.$this->username);
			    $this->setResponse();
			    break;
			}
		}
	}
	
	private function setResponse () {
		switch ($this->checkService) {
			case 'yahoo': {
				$this->response = '
				<table width="320" border="0" cellpadding="0" cellspacing="8" align="center">
				<tr>
			        <td colspan="2" align="left">';
					if($this->errorMsg != null) {
						$this->response .= '<font class="userStatus">'.$this->errorMsg.'</font>';
					}
					else {
						$this->response .= '<font class="userStatus">The user <b><u>'.$this->username.'</u></b> is '.$this->status.'</font></td>';
			        }
			    $this->response .= '
			    </tr>
			    <tr>
			        <td><img src="'.$this->avatarLink.'" class="avatar" /></td>
			        <td align="left" class="text">
			          	<img src="images/arrow.gif" border="0" align="absmiddle"/> add <a href="ymsgr:addfriend?'.$this->username.'" class="link">'.$this->username.'</a> to friend list<br />
			            <img src="images/arrow.gif" border="0" align="absmiddle"/> send a message to <a href="ymsgr:sendim?'.$this->username.'" class="link">'.$this->username.'</a><br />
			            <img src="images/arrow.gif" border="0" align="absmiddle"/> view <a href="http://profiles.yahoo.com/'.$this->username.'" target="_blank" class="link">'.$this->username.'</a>\'s profile<br>
			            <img src="images/arrow.gif" border="0" align="absmiddle"/> curtesy of <a href="http://insanityville.com"  class="link">InsanityVille.com</a>
			        </td>
			    </tr>
			    </table>';
				break;
			}
		}
		return false;
	}
	
	private function setErrorMsg ($errorMsg) {
		return $this->errorMsg = $errorMsg;
	}
}
?>
Return current item: Simple Yahoo Status Checker