php模拟OICQ的实现思路和核心程序

依据广大网络老铁需要,专门把自家站的那个宪章 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$onlinenumber;$i++){if(!$onlineuser = mysql_fetch_array($onlineresult))break;echo a onClick=MM_openBrWindow(shortalk.php?talkto=.$onlineuser[Name].,.$onlineuser[Name].,width=300,height=250)img src=images/face/.$onlineuser[Face]..gif width=20 height=20 ;if($name == $onlineuser[Name])echo border=1 ;echo  title=代号:.$onlineuser[Name]./n昵称:.$onlineuser[NickName]./n来访:.$onlineuser[EnterTimes]./a;}?

内部的 onClick
用于弹出发送消息的对话窗口,大家能够在网页的源代码里面见到

3 在线客商的音讯扫描和创新

在网页中央银行使内置框架来调用扫描和翻新程序,那行也能在网页源代码里面来看!

iframe name=flush src=userflush.php width=0 height=0 frameborder=0 scrolling=NO marginwidth=0 marginheight=0 hspace=0 vspace=0/iframe

4 消息扫描和翻新程序 userflush.php

?session_start();mysql_connect(localhost,,);mysql_select_db(php2000);$delaytime=0;// 查找新的发言$query = select * from forumtalk where readsign=0 and receiver=$name;$result = mysql_query($query);if( mysql_num_rows($result)  0){// 读取和显示弹出窗口$msg = mysql_fetch_array($result);$numberfriend = $msg[id];echo script language=javascriptwindow.open(shortalk.php?action=viewtalknumber=$numberfriend,_blank,width=300,height=250)/script;}// 设置当前用户的最新时间标志,表示它在线mysql_query(update userinfo set currentdate=.date(U). where name=$name);// 设置刷新时间间隔为15秒echo meta  content=15;url=userflush.php;?

5 闲聊新闻的发送、阅读和复苏程序 – shortalk.php

?require(require.php); // 判断用户是否合法在线的公用程序?htmlheadtitle短信息/titlemeta  content=text/html; charset=gb2312style type=text/csstd {font-size:9pt}/stylescript language=Javascript!--function docheck() {if (document.sendmsg.replymessage.value==) {alert(缺少内容:需要输入您的留言内容);document.sendmsg.replymessage.focus();return(false);}return (true);}function MM_openBrWindow(theURL,winName,features) { //v2.0window.open(theURL,winName,features);}//--/script/headbody bgcolor=#DDDDFFleftmargin=0 topmargin=0 background=phpchat_images/cloudtile.jpg?if($action == view){$tmp = mysql_fetch_array(mysql_query(select sender,body,date from forumtalk where id=$talknumber and receiver=$name));$msg = $tmp[body];$message = ereg_replace(,/r/n,$msg);mysql_query(update forumtalk set readsign=1 where id=$talknumber);$sendernickname = mysql_fetch_row(mysql_query(select nickname from userinfo where name=.$tmp[sender].));?table width=300 border=0 cellspacing=0 cellpadding=0 height=200 bgcolor=f0f0f0trtd colspan=2 height=20 bgcolor=99cc99 align=center查看短信息/td/trtrtd colspan=2 height=20?echo date(m月d日 h:i,$tmp[date]). .$sendernickname[0]? 给你[?echo $name?]留言:/td/trform name=viewtalk action=shortalk.php method=postinput type=hidden name=talkto value=?echo $tmp[sender]?input type=hidden name=action value=sendinput type=hidden name=talknumber value=?print($talknumber)?tr align=centertd colspan=2 height=146 valign=toptextarea name=textfield cols=40 rows=11 readonly?print($message)?/textarea/td/trtrtd colspan=2 align=centerinput type=submit name=toreply value=回复留言 Entera href=# onClick=MM_openBrWindow(memberviewtalk.php?talkto=?echo $tmp[sender]?,viewtalk,scrollbars=yes)聊天纪录/a /td/tr/form/tablescript language=Javascriptdocument.viewtalk.toreply.focus();/script?}else if ($action == sendbegin){$replymessage = ereg_replace(/r/n,,$replymessage);$replymessage = ereg_replace(,,$replymessage);$replymessage = ereg_replace(,,$replymessage);$replymessage = substr($replymessage,0,2000);mysql_query(insert into forumtalk (sender,receiver,body,date) values ($name,$talkto,$replymessage,.date(U).));print(script language=javascriptwindow.close()/script);}else{?table width=300 border=0 cellspacing=0 cellpadding=0 height=200 bgcolor=f0f0f0form name=sendmsg action=shortalk.php method=post OnSubmit=return(docheck());input type=hidden name=action value=sendbegintr align=centertd colspan=2 height=20 bgcolor=99cc99发送短信息/td/trtr align=centertd colspan=2 height=20发言对象:select name=talkto?$result = mysql_query(select name,nickname from userinfo where onlinestatus=1);while($msg=mysql_fetch_array($result)){if($msg[name]==$talkto)echo option value=.$msg[name]. selected.$msg[nickname]./option/n;elseecho option value=.$msg[name]..$msg[nickname]./option/n;}?/select请短于500字符 /td/trtr align=centertd colspan=2 height=146 valign=toptextarea name=replymessage cols=40 rows=9/textarea/td/trtr align=centertd colspan=4?if($talknumber != ){print(input type=button name=review value=查看前一留言 Alt+P accesskey=p onClick=javascript:history.go(-1));}?input type=submit name=reply value=开始新的发送留言 Alt+S accesskey=sa href=# onClick=MM_openBrWindow(memberviewtalk.php?talkto=?echo $talkto?,viewtalk,scrollbars=yes)聊天纪录/a/td/tr/form/tablescript language=Javascriptdocument.sendmsg.replymessage.focus();/script?}?/body/html
You can leave a response, or trackback from your own site.

Leave a Reply

网站地图xml地图