您好,欢迎访问一九零五行业门户网

模拟 OICQ 的实现思路和核心程序(一) 转 --建议加入精华区

程序|精华
文章来源:php 世纪网
根据许多网友需求,特地把我站的这个模拟 oicq 的在线聊天的东西献给大家!
1 用户必须注册登陆,在数据库 userinfo 里面保存如下几个字段
name 不用问了,这是登陆用的用户名,必须唯一
password 登陆密码
nickname 用户昵称,也就是显示的名字
face 存放着用户头像的编号,比如 01,代表 /images/face/01.gif 头像文件
onlinestatus 用户是否在线的标志,在用户登陆的时候设置为 1
currentdate 用户最后访问/更新的时间,用于判断用户是否在线
聊天纪录 forumtalk 的结构为
create table forumtalk (
id int(11) not null auto_increment,
sender varchar(20) not null,
receiver varchar(20) not null,
date int(11) default '0' not null,
readsign tinyint(4) default '0' not null,
body varchar(200) not null,
primary key (id),
unique id_2 (id),
key id (id)
);
其中 sender 是发送人的 name
receiver 是接受人的 name
date 是发言的时间
readsign 发言是否已经阅读过
body 发言内容
2 显示在线用户的头像
$onlineresult = mysql_query(select name,nickname,face,entertimes from userinfo where onlinestatus=1 and currentdate >.(date(u)-120));
$onlinenumber = mysql_num_rows($onlineresult);
echo 欢迎光临,共有:.$onlinenumber.位朋友在线,按头像发短信息:;
for($i=0;$i{
if(!$onlineuser = mysql_fetch_array($onlineresult))break;
echo if($name == $onlineuser['name'])echo border=1 ;
echo title='代号:.$onlineuser['name'].\n昵称:.$onlineuser['nickname'].\n来访:.$onlineuser['entertimes'].'>;
}
?>
其中的 onclick 用于弹出发送消息的对话窗口,大家可以在网页的源代码里面看到
其它类似信息

推荐信息