我已经在我的网站上安装了彗星聊天现在的问题是我不知道如何配置我的数据库以匹配这个值,如果有人知道如何为彗星聊天配置自定义 php 站点,这将是一个很大的帮助,或者只是帮助我阅读了脚本以正确配置我的数据库
define('DB_SERVER','localhost');
define('DB_PORT','3306');
define('DB_USERNAME','xxx_admin');
define('DB_PASSWORD','xxx');
define('DB_NAME','xxx_database');
define('TABLE_PREFIX','');
define('DB_USERTABLE', 'users');
define('DB_USERTABLE_NAME', 'chat_user');
define('DB_USERTABLE_USERID', 'cometchat_user');
define('DB_USERTABLE_LASTACTIVITY', 'lastactivity');
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/* FUNCTIONS */
function getUserID() {
$userid = 0; // Return 0 if user is not logged in
if (!empty($_SESSION['userid'])) {
$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."friends join ".TABLE_PREFIX.DB_USERTABLE."
on ".TABLE_PREFIX."friends.toid = ".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."friends.fromid = '".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."users.".DB_USERTABLE_NAME." username, ".TABLE_PREFIX."users.".DB_USERTABLE_LASTACTIVITY." lastactivity, ".TABLE_PREFIX.DB_USERTABLE.".username link, (select storage_path from ".TABLE_PREFIX."storage_files where parent_file_id is null and file_id = ".TABLE_PREFIX.DB_USERTABLE.".photo_id) avatar, cometchat_status.message, cometchat_status.status from ".TABLE_PREFIX."users left join cometchat_status on ".TABLE_PREFIX."users.user_id = cometchat_status.userid where ".TABLE_PREFIX."users.user_id = '".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 ".TABLE_PREFIX."users.status message, cometchat_status.status from ".TABLE_PREFIX."users left join cometchat_status on ".TABLE_PREFIX."users.user_id = cometchat_status.userid where ".TABLE_PREFIX."users.user_id = '".mysql_real_escape_string($userid)."'");
return $sql;
}
function getLink($link) {
return BASE_URL."../profile/".$link;
}
function getAvatar($image) {
if (is_file(dirname(dirname(__FILE__))."/".$image)) {
return BASE_URL."../".$image;
} else {
return BASE_URL."../application/modules/User/externals/images/nophoto_user_thumb_icon.png";
}
}
function getTimeStamp() {
return time();
}
function processTime($time) {
return $time;
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/* HOOKS */
function hooks_statusupdate($userid,$statusmessage) {
$sql = ("update ".TABLE_PREFIX."users set status = '".mysql_real_escape_string($statusmessage)."', status_date = '".date("Y-m-d H:i:s",getTimeStamp())."' where user_id = '".mysql_real_escape_string($userid)."'");
$query = mysql_query($sql);
}
function hooks_forcefriends() {
}
function hooks_activityupdate($userid,$status) {
}
function hooks_message($userid,$unsanitizedmessage) {
}