Arrowchat is one of the powerful tool for chatting between users or friends of website,
There’s a easy installation options for many CMS like wordpress, joomla and drupal but they provide a file integration.php for core installation also,
You can find this file in “includes” Folder.
You need to change in 3 functions :
- get_online_list
- get_link
- get_avatar
get_online_list :
This function is important because it shows list of online users
function get_online_list($userid, $time) { global $db; 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 . " != '" . $db->escape_string($userid) . "' ORDER BY " . TABLE_PREFIX . DB_USERTABLE . "." . DB_USERTABLE_NAME . " ASC "); return $sql; }
Above is the original function provided by arrowchat, You’ve to just modify query nothing else Check above example :
function get_online_list($userid, $time) { global $db; 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 . " != '" . $db->escape_string($userid) . "' AND (users.user_id IN(SELECT friends.request FROM friends WHERE friends.friend='".$db->escape_string($userid)."' AND friends.status='1') OR users.user_id IN(SELECT friends.friend FROM friends WHERE friends.request='".$db->escape_string($userid)."' AND friends.status='1')) ORDER BY " . TABLE_PREFIX . DB_USERTABLE . "." . DB_USERTABLE_NAME . " ASC "); return $sql; }
get_link :
This function is also important, its hyperlink (Profile Link) on name of online users
Original Function :
function get_link($link, $user_id) { global $base_url; return $base_url . '../users.php?id=' . $link; }
Modified Example :
function get_link($link, $user_id) { global $base_url; $q = mysql_query("SELECT `username` FROM `users` WHERE `user_id`='".$user_id."'"); if(mysql_num_rows($q)>0){ $d = mysql_fetch_array($q); } return $base_url . '../member/profile/view/' . $d[0]; }
get_avatar :
This function is also important because it shows avatar (Profile Pics) of users while chatting :
Original Function :
function get_avatar($image, $user_id) { global $base_url; if (is_file(dirname(dirname(dirname(__FILE__))) . '/images/' . $image . '.gif')) { return $base_url . '../images/' . $image . '.gif'; } else { return $base_url . AC_FOLDER_ADMIN . "/images/img-no-avatar.gif"; } }
Modified Example :
function get_avatar($image, $user_id) { global $base_url; if (!empty($image)) { return "http://yourdomain.com/userfiles/" . $image; } else { return $base_url . AC_FOLDER_ADMIN . "/images/img-no-avatar.gif"; } }
Recent Comments