The [b]getUserID()[/b] function is used to return the logged in user's ID. Depending on how you have programmed your site, you will have to find out the user ID.
I need to replace this with jcow code so each function can work with my site if anyone can help i ll be grateful. I have sent mail to staff members but till now got no answer.
[code]function getUserID() {
$userid = 0;
global $config;
$cookie = $config['Misc']['cookieprefix'].'sessionhash';
if (!empty($_COOKIE[$cookie])) {
$sql = ("select userid from ".TABLE_PREFIX."session where sessionhash = '".mysql_real_escape_string($_COOKIE[$cookie])."'");
$query = mysql_query($sql);
$session = mysql_fetch_array($query);
$userid = $session['userid'];
}
$cookie = $config['Misc']['cookieprefix'].'_sessionhash';
if (!empty($_COOKIE[$cookie])) {
$sql = ("select userid from ".TABLE_PREFIX."session where sessionhash = '".mysql_real_escape_string($_COOKIE[$cookie])."'");
$query = mysql_query($sql);
$session = mysql_fetch_array($query);
$userid = $session['userid'];
}
return $userid;
}
function getFriendsList($userid,$time) {
$sql = ("select DISTINCT ".TABLE_PREFIX.DB_USERTABLE.".".DB_USERTABLE_USERID." userid, ".TABLE_PREFIX.DB_USERTABLE.".".DB_USERTABLE_NAME." username, ".TABLE_PREFIX.DB_USERTABLE.".".DB_USERTABLE_LASTACTIVITY." lastactivity, ".TABLE_PREFIX.DB_USERTABLE.".".DB_USERTABLE_USERID." avatar, ".TABLE_PREFIX.DB_USERTABLE.".".DB_USERTABLE_USERID." link, cometchat_status.message, cometchat_status.status from ".TABLE_PREFIX."userlist join ".TABLE_PREFIX.DB_USERTABLE." on ".TABLE_PREFIX."userlist.relationid = ".TABLE_PREFIX.DB_USERTABLE.".".DB_USERTABLE_USERID." left join cometchat_status on ".TABLE_PREFIX.DB_USERTABLE.".".DB_USERTABLE_USERID." = cometchat_status.userid where ".TABLE_PREFIX."userlist.friend = 'yes' and ".TABLE_PREFIX."userlist.userid = '".mysql_real_escape_string($userid)."' order by username asc");
return $sql;
}
function getUserDetails($userid) {
$sql = ("select ".TABLE_PREFIX.DB_USERTABLE.".".DB_USERTABLE_USERID." userid, ".TABLE_PREFIX.DB_USERTABLE.".".DB_USERTABLE_NAME." username, ".TABLE_PREFIX.DB_USERTABLE.".".DB_USERTABLE_LASTACTIVITY." lastactivity, ".TABLE_PREFIX.DB_USERTABLE.".".DB_USERTABLE_USERID." link, ".TABLE_PREFIX.DB_USERTABLE.".".DB_USERTABLE_USERID." avatar, cometchat_status.message, cometchat_status.status from ".TABLE_PREFIX.DB_USERTABLE." left join cometchat_status on ".TABLE_PREFIX.DB_USERTABLE.".".DB_USERTABLE_USERID." = cometchat_status.userid where ".TABLE_PREFIX.DB_USERTABLE.".".DB_USERTABLE_USERID." = '".mysql_real_escape_string($userid)."'");
return $sql;
}
function updateLastActivity($userid) {
$sql = ("update ".TABLE_PREFIX.DB_USERTABLE." set ".DB_USERTABLE_LASTACTIVITY." = '".getTimeStamp()."' where ".DB_USERTABLE_USERID." = '".mysql_real_escape_string($userid)."'");
return $sql;
}
function getUserStatus($userid) {
$sql = ("select cometchat_status.message, cometchat_status.status from cometchat_status where userid = '".mysql_real_escape_string($userid)."'");
return $sql;
}
function getLink($link) {
return "./member.php?u=".$link;
}
function getAvatar($image) {
return "./index.php?u=".$image;
}[/code] |