<?php
/* Nulled by Wizzywig */
/***********تعريب***********/
/**          saher        **/
/**  منتديات شباب وصبايا  **/
/**   www.shababtop.com   **/
/**  saher1986@live.com   **/
/***************************/

// ########################## INCLUDE BACK-END ###########################
include_once ('data_core.php');

// ########################### INITILIZATION #############################
$response 	= array();
$messages 	= array();
$buddyList 	= array();
$time 		= time();

// ###################### START BUDDY LIST RECEIVE #######################
if ($userid != 0) {

	$sql = getFriendsList($userid,$time);
	$result = mysql_query($sql);

	while ($chat = mysql_fetch_array($result)) {
	
		if ($chat['userid'] != $userid) {

			if ((($time-$chat['lastactivity']) < $online_timeout) && $chat['status'] != 'invisible' && $chat['status'] != 'offline') {
				if ($chat['status'] != 'busy' && $chat['status'] != 'away') {
					$chat['status'] = 'available';
				}
			} else {
				$chat['status'] = 'offline';
			}

			if ($chat['message'] == null) {
				$chat['message'] = $status[$chat['status']];
			}
			
			$link = getLink($chat['link'], $chat['userid']);
			$avatar = getAvatar($chat['avatar'], $chat['userid']);

			if (!empty($chat['username'])) {
				$buddyList[] = array('id' => $chat['userid'], 'n' => $chat['username'], 's' => $chat['status'], 'm' => $chat['message'], 'a' => $avatar, 'l' => $link);
			}
		}
	}

	$response['buddylist'] = $buddyList;
}

header('Content-type: application/json; charset=utf-8');
echo json_encode($response);
exit;

?>