<?php

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

/**
 * This function returns the user ID of the logged in user on your site.  Technical support will not
 * help you with this for stand-alone installations.  You must purchase the professional installation
 * if you are having trouble.
 *
 * @return the user ID of the logged in user
 */
function getUserID() {
	global $current_user;
    get_currentuserinfo();

	$userid = 0;
	
	if (!empty($current_user->ID)) {
		$userid = $current_user->ID;
	}

	return $userid;
}

/**
 * This function returns the SQL statement for the buddylist of the user.  You should retrieve
 * all ONLINE friends that the user is friends with.  Do not retrieve offline users.  You can use
 * global $online_timeout to get the online timeout.
 * ex: AND (arrowchat_status.session_time + 60 + ".$online_timeout.") > ".time()." 
 *
 * @param userid the user ID of the person receiving the buddylist
 * @param the time of the buddylist request
 * @return the SQL statement to retrieve the user's friend list
 */
function getFriendsList($userid,$time) {
	global $online_timeout;
	
	$sql = ("SELECT DISTINCT ".TABLE_PREFIX.DB_USERTABLE.".".DB_USERTABLE_USERID." userid, ".TABLE_PREFIX.DB_USERTABLE.".".DB_USERTABLE_NAME." username, arrowchat_status.session_time lastactivity, ".TABLE_PREFIX.DB_USERTABLE.".".DB_USERTABLE_AVATAR." avatar, ".TABLE_PREFIX.DB_USERTABLE.".".DB_USERTABLE_USERID." link, arrowchat_status.message, arrowchat_status.status 
		FROM ".TABLE_PREFIX.DB_USERTABLE." 
		JOIN arrowchat_status 
			ON ".TABLE_PREFIX.DB_USERTABLE.".".DB_USERTABLE_USERID." = arrowchat_status.userid 
		WHERE ('".time()."'-arrowchat_status.session_time - 60 < '".$online_timeout."') 
			AND ".TABLE_PREFIX.DB_USERTABLE.".".DB_USERTABLE_USERID." <> '".$userid."' 
		ORDER BY ".TABLE_PREFIX.DB_USERTABLE.".".DB_USERTABLE_NAME." ASC");
	
	return $sql; 
}

/**
 * This function returns the SQL statement to get the user details of a specific user.  You should
 * get the user's ID, username, last activity time in unix, link to their profile, avatar, and status.
 *
 * @param userid the user ID to get the details of
 * @return the SQL statement to retrieve the user's defaults
 */
function getUserDetails($userid) {
	$sql = ("SELECT ".TABLE_PREFIX.DB_USERTABLE.".".DB_USERTABLE_USERID." userid, ".TABLE_PREFIX.DB_USERTABLE.".".DB_USERTABLE_NAME." username, arrowchat_status.session_time lastactivity,  ".TABLE_PREFIX.DB_USERTABLE.".".DB_USERTABLE_USERID." link,  ".TABLE_PREFIX.DB_USERTABLE.".".DB_USERTABLE_AVATAR." avatar, arrowchat_status.message, arrowchat_status.status 
		FROM ".TABLE_PREFIX.DB_USERTABLE." 
		LEFT JOIN arrowchat_status 
			ON ".TABLE_PREFIX.DB_USERTABLE.".".DB_USERTABLE_USERID." = arrowchat_status.userid 
		WHERE ".TABLE_PREFIX.DB_USERTABLE.".".DB_USERTABLE_USERID." = '".mysql_real_escape_string($userid)."'");
	return $sql;
}

/**
 * This function returns the profile link of the specified user ID.
 *
 * @param userid the user ID to get the profile link of
 * @return the link of the user ID's profile
 */
function getLink($link, $user_id) {
    return '';
}

/**
 * This function returns the URL of the avatar of the specified user ID.
 *
 * @param userid the user ID of the user
 * @param image if the image includes more than just a user ID, this param is passed
 * in from the avatar row in the buddylist and get user details functions.
 * @return the link of the user ID's profile
 */
function getAvatar($image, $user_id) {
	return"http://www.gravatar.com/avatar/".md5($image)."?d=identicon";
}

/**
 * This function returns the name of the logged in user.  You should not need to
 * change this function.
 *
 * @param userid the user ID of the user
 * @return the name of the user
 */
function getLoggedInUser($userid) { 
    $loggedInUser = "Guest";

    $sql = ("SELECT ".DB_USERTABLE_NAME." name 
		FROM ".TABLE_PREFIX.DB_USERTABLE." 
		WHERE ".DB_USERTABLE_USERID." = '".mysql_real_escape_string($userid)."'");  
    $result = mysql_query($sql); 
    if ($result && mysql_num_rows($result) > 0)  {
        $row = mysql_fetch_assoc($result); 
		$loggedInUser = $row['name']; 
    }

    $pieces = explode(" ", $loggedInUser);

    return $pieces[0]; 
} 

?>