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

迷离忧伤7

迷离忧伤7

2016-02-19 16:41

人生本是一个不断学习的过程,在这个过程中,图老师就是你们的好帮手,下面分享的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

(本文来源于图老师网站,更多请访问https://m.tulaoshi.com/webkaifa/)

  receiver 是接受人的 Name

  date 是发言的时间

  readsign 发言是否已经阅读过

(本文来源于图老师网站,更多请访问https://m.tulaoshi.com/webkaifa/)

  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=view&talknumber=$numberfriend','_blank','width=300,height=250')/script";}// 设置当前用户的最新时间标志,表示它在线mysql_query("update userinfo set currentdate=".date("U")." where name='$name'");// 设置刷新时间间隔为15秒echo "meta http-equiv='refresh' content='15;url=userflush.php'";?
 

  5 聊天信息的发送、阅读和回复程序 - shortalk.php

  

?require("require.php"); // 判断用户是否合法在线的公用程序?htmlheadtitle短信息/titlemeta http-equiv="Content-Type" content="text/html; charset=gb2312"style type="text/css"td {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="#DDDDFF"leftmargin="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("","rn",$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="f0f0f0"trtd 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="center"td colspan="2" height="146" valign="top"textarea name="textfield" cols="40" rows="11" readonly?print($message)?/textarea/td/trtrtd colspan="2" align="center"input type="submit" name="toreply" value="回复留言 Enter"a href="http://cms.ddvip.com/index.php#" onClick="MM_openBrWindow('memberviewtalk.php?talkto=?echo $tmp['sender']?','viewtalk','scrollbars=yes')"聊天纪录/a /td/tr/form/tablescript language="Javascript"document.viewtalk.toreply.focus();/script?}else if ($action == "sendbegin"){$replymessage = ereg_replace("rn","",$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='javascript'window.close()/script");}else{?table width="300" border="0" cellspacing="0" cellpadding="0" height="200" bgcolor="f0f0f0"form name=sendmsg action=shortalk.php method=post OnSubmit=return(docheck());input type=hidden name=action value=sendbegintr align="center"td colspan="2" height="20" bgcolor="99cc99"发送短信息/td/trtr align="center"td 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']."/optionn";elseecho "option value='".$msg['name']."'".$msg['nickname']."/optionn";}?/select请短于500字符 /td/trtr align="center"td colspan="2" height="146" valign="top"textarea name="replymessage" cols="40" rows="9"/textarea/td/trtr align="center"td 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='s'a href="http://cms.ddvip.com/index.php#" onClick="MM_openBrWindow('memberviewtalk.php?talkto=?echo $talkto?','viewtalk','scrollbars=yes')"聊天纪录/a/td/tr/form/tablescript language="Javascript"document.sendmsg.replymessage.focus();/script?}?/body/html

展开更多 50%)
分享

猜你喜欢

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

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

模拟OICQ的实现思路和核心程序(三)

PHP
模拟OICQ的实现思路和核心程序(三)

s8lol主宰符文怎么配

英雄联盟 网络游戏
s8lol主宰符文怎么配

模拟OICQ的实现思路和核心程序(一)

PHP
模拟OICQ的实现思路和核心程序(一)

模拟OICQ的实现思路和核心程序(二)

PHP
模拟OICQ的实现思路和核心程序(二)

lol偷钱流符文搭配推荐

英雄联盟 网络游戏
lol偷钱流符文搭配推荐

PHP文件上传的具体思路及实现

PHP
PHP文件上传的具体思路及实现

搜索引擎核心技术(PHP编程思路) --[1]

Web开发
搜索引擎核心技术(PHP编程思路) --[1]

lolAD刺客新符文搭配推荐

英雄联盟
lolAD刺客新符文搭配推荐

VxD编程入门教程(2)

VxD编程入门教程(2)

php基类 调试类 错误类

php基类 调试类 错误类
下拉加载更多内容 ↓