我正在CakePHP Framework 2x中实现 CMR应用程序。在该应用程序中,我需要在线文本聊天,音频聊天,屏幕共享和视频聊天。经过相当长的搜索,我最终决定使用 CometChat 5.0 白金版。工作进展:
实际上现在我在使用Applicaton时遇到了问题。为了解决我搜索谷歌的问题,但没有一个地方可以告诉我:
现在它正确显示聊天栏托盘,但是我必须一直看到错误或警报“ 请登录以使用聊天 ” ,我开始知道ChometChat应该知道要启动的登录用户信息,但它似乎只能通过会话或其他地方得到它,我可能应该知道。如果你认为我有任何整合问题,我在这里发布一些代码,你可以看到它自己:(integeration.php)
高级设置:
define('SET_SESSION_NAME',''); // Session name
define('DO_NOT_START_SESSION','1'); // Set to 1 if you have already started the session
define('DO_NOT_DESTROY_SESSION','0'); // Set to 1 if you do not want to destroy session on logout
define('SWITCH_ENABLED','1');
define('INCLUDE_JQUERY','1');
define('FORCE_MAGIC_QUOTES','0');
数据库配置:
define('DB_SERVER', 'localhost' );
define('DB_PORT', "3306" );
define('DB_USERNAME', 'root' );
define('DB_PASSWORD', '' );
define('DB_NAME', 'cakechat' );
define('TABLE_PREFIX', "" );
define('DB_USERTABLE', "users" );
define('DB_USERTABLE_USERID', "id" );
define('DB_USERTABLE_NAME', "username" );
define('DB_AVATARTABLE', " " );
define('DB_AVATARFIELD', " CONCAT(".TABLE_PREFIX.DB_USERTABLE.".".DB_USERTABLE_USERID." ,CONCAT('/',".TABLE_PREFIX.DB_USERTABLE.".user_photo))" );
define('DB_USERTABLE_LASTACTIVITY', "user_lastactive");
功能1:
function getUserID() {
$userid = 0;
if (!empty($_SESSION['basedata']) && $_SESSION['basedata'] != 'null') {
$_REQUEST['basedata'] = $_SESSION['basedata'];
}
if (!empty($_REQUEST['basedata'])) {
$userid = $_REQUEST['basedata'];
}
if (!empty($_COOKIE['se_auth_token'])) {
$sql = ("select session_auth_user_id from ".TABLE_PREFIX."session_auth where session_auth_key = '".mysql_real_escape_string($_COOKIE['se_auth_token'])."'");
$query = mysql_query($sql);
$session = mysql_fetch_array($query);
$userid = $session['session_auth_user_id'];
}
return $userid;
}
我唯一的要求:请分享任何参考链接或走访,以使事情正确和功能,任何小小的努力,将受到高度赞赏。 提前致谢!
答案 0 :(得分:0)
user_photo确保您在localhost上安装了Red5以使用视频,音频和屏幕共享功能, 并且您使用的是localhost作为VPS。
在integration.php(E:\ xampp \ htdocs \ project \ app \ webroot \ cometchat)文件中使用此配置:
define('DB_SERVER', $config->default['host']);
define('DB_PORT', '3306');
define('DB_USERNAME', $config->default['login']);
define('DB_PASSWORD', $config->default['password']);
define('DB_NAME', $config->default['database']);
define('TABLE_PREFIX', $config->default['prefix']);
define('DB_USERTABLE', "users");
define('DB_USERTABLE_USERID', "id" );
define('DB_USERTABLE_NAME', "username");
define('DB_AVATARTABLE', " ");
define('DB_AVATARFIELD', " ".TABLE_PREFIX.DB_USERTABLE.".user_photo ");
并在function getAvatar()
function getAvatar($image) {
if ($image) {
return '../'.$image;
} else {
return '../img/no-image.jpg';
}
}
答案 1 :(得分:0)
将此添加到您的getUserID()函数:
/*
if (!empty($_SESSION['Auth']['User']['id'])) {
$userid = $_SESSION['Auth']['User']['id'];
}
*/
function getUserID() {
$userid = 0;
if (!empty($_SESSION['basedata']) && $_SESSION['basedata'] != 'null') {
$_REQUEST['basedata'] = $_SESSION['basedata'];
}
if (!empty($_REQUEST['basedata'])) {
$userid = $_REQUEST['basedata'];
}
if (!empty($_COOKIE['se_auth_token'])) {
$sql = ("select session_auth_user_id from ".TABLE_PREFIX."session_auth where session_auth_key = '".mysql_real_escape_string($_COOKIE['se_auth_token'])."'");
$query = mysql_query($sql);
$session = mysql_fetch_array($query);
$userid = $session['session_auth_user_id'];
}
if (!empty($_SESSION['Auth']['User']['id'])) {
$userid = $_SESSION['Auth']['User']['id'];/*pass logged in user id here, which is stored in your session variable*/
}
return $userid;
}