存档

文章标签 ‘聊天室’

php在线聊天程序主页面代码

2015年3月14日 没有评论

<?php
require_once(“../config/config.all.php”);
$me=$_GET[“me”];$with=$_GET[“with”];
$membersrs=$db->query_first(“select emailconfirm,phoneconfirm,idcardconfirm,permitconfirm,ifshop,phone,tel,truename,email from members where isvalid=1 and username='”.$with.”‘ limit 1″);
$shoprs=$db->query_first(“select youxiaoqi,name,type,productn,togon,grade,logo from usershop where isvalid=1 and username='”.$with.”‘ limit 1″);
?>
<div id=”chatnav”>快速导航:<a href=”/” target=”_blank”>网站首页</a><a href=”/shop/shop.html” target=”_blank”>同城店铺</a><a href=”/shop/product.html” target=”_blank”>同城产品</a><a href=”/shequ/” target=”_blank”>同城社区</a><a href=”/info/” target=”_blank”>分类信息</a><a href=”/bmfw/” target=”_blank”>便民服务</a><a href=”/users/” target=”_blank”>个人管理中心</a><a href=”/reg/loginout.html” class=”loginout”>退出登录</a></div>
<div class=”con”>
<div class=”title”>尊敬的&nbsp;<span><?php echo $me;?></span>,您正在与&nbsp;<a style=”text-decoration:underline;” href=”http://<?php echo $with;?>.baidu.cn/” target=”_blank”><?php echo $shoprs[“name”];?></a>&nbsp;的店 主&nbsp;<span><?php echo $with;?></span>&nbsp;聊天<span class=”rightspan”><img src=”/img/wrong.gif” />关闭对话</span></div>
<div class=”showmsg allborder”>
<div class=”msg_chat” id=”msg_chat”><ul style=”padding-bottom:15px;” id=”msg_ul”></ul></div>
<div class=”msg_shop”>
<div id=”withshopmsg”>
<?php if($shoprs){?>
<!–店铺内容–>
<div class=”shopicon”><a title=”点击访问:<?php echo $shoprs[“name”];?>” href=”http://<?php echo $with;?>.baidu.cn/” target=”_blank”><img src=”/<?php echo getthumb($shoprs[“logo”],”_140x100″);?>” /></a></div>
<div class=”shopicon_bottom”>
所有者:<a href=”http://<?php echo $with;?>.baidu.cn/sindex.html” target=”_blank”><?php echo $with;?></a><br />
店铺名称:<a href=”http://<?php echo $with;?>.baidu.cn/sindex.html” target=”_blank”><?php echo $shoprs[“name”];?></a><br />
产品数:<a title=”<?php echo $with;?> 一共发布了 <?php echo $shoprs[“productn”];?> 个产品” href=”http://<?php echo $with;?>.baidu.cn/stogo.html” target=”_blank” style=”text-decoration:underline;color:#f60″><?php echo $shoprs[“productn”];?>个</a><br />
发布团购:<a title=”<?php echo $with;?> 一共发布了 <?php echo $shoprs[“togon”];?> 次团购活动” href=”http://<?php echo $with;?>.baidu.cn/stogo.html” target=”_blank” style=”text-decoration:underline;color:#f60″><?php echo $shoprs[“togon”];?>次</a><br />
用户认证:<?php if($membersrs[“emailconfirm”]){echo ‘<img src=”/shop/img/rz_youxiang.gif” title=”该用户已经通过邮箱验证” />’;}?>&nbsp;<?php if($membersrs[“phoneconfirm”]){echo ‘<img title=”该用户已经通过手机验证” src=”/shop/img/rz_shouji.gif” />’;}?>&nbsp;<?php if($membersrs[“idcardconfirm”]){echo ‘<img src=”/shop/img/rz_sfz.gif” title=”该用户已经通过身份证验证” />’;}?>&nbsp;<?php if($membersrs[“permitconfirm”]){echo ‘<img src=”/shop/img/rz_zhizhao.gif” title=”该用户已经通过营业执照验证” />’;}?><br />
信用等级:<?php echo getgrade($shoprs[“grade”]);?><br />
用户邮箱:<?php echo $membersrs[“email”];?><br />
联系电话:<?php echo $membersrs[“phone”]?$membersrs[“phone”]membersrs[“tel”];?>
</div>
<?php }else {?>
<div class=”nonemineshop”>对方还未开通店铺</div>
<?php }?>
</div>
<div id=”myshopmsg” style=”display:none”>
<?php
$shoprs_mine=$db->query_first(“select name,type,productn,togon,grade,logo from usershop where isvalid=1 and username='”.$me.”‘ limit 1″);
if($shoprs_mine){
$membersrs_mine=$db->query_first(“select emailconfirm,phoneconfirm,idcardconfirm,permitconfirm,ifshop,phone,tel,truename,email from members where isvalid=1 and  username='”.$me.”‘ limit 1″);
?>
<div class=”shopicon”><a title=”点击访问:<?php echo $shoprs_mine[“name”];?>” href=”http://<?php echo $me;?>.baidu.cn/” target=”_blank”><img src=”/<?php echo getthumb($shoprs_mine[“logo”],”_140x100″);?>” /></a></div>
<div class=”shopicon_bottom”>
所有者:<a href=”http://<?php echo $me;?>.baidu.cn/sindex.html” target=”_blank”><?php echo $me;?></a><br />
店铺名称:<a href=”http://<?php echo $me;?>.baidu.cn/sindex.html” target=”_blank”><?php echo $shoprs_mine[“name”];?></a><br />
产品数:<a title=”<?php echo $me;?> 一共发布了 <?php echo $shoprs_mine[“togon”];?> 个产品” href=”http://<?php echo $me;?>.baidu.cn/sproduct.html” target=”_blank” style=”text-decoration:underline;color:#f60″><?php echo $shoprs_mine[“productn”];?>个</a><br />
发布团购:<a title=”<?php echo $me;?> 一共发布了 <?php echo $shoprs_mine[“togon”];?> 次团购活动” href=”http://<?php echo $me;?>.baidu.cn/stogo.html” target=”_blank” style=”text-decoration:underline;color:#f60″><?php echo $shoprs_mine[“togon”];?>次</a><br />
用户认证:<?php if($membersrs_mine[“emailconfirm”]){echo ‘<img src=”/shop/img/rz_youxiang.gif” title=”该用户已经通过邮箱验证” />’;}?>&nbsp;<?php if($membersrs_mine[“phoneconfirm”]){echo ‘<img title=”该用户已经通过手机验证” src=”/shop/img/rz_shouji.gif” />’;}?>&nbsp;<?php if($membersrs_mine[“idcardconfirm”]){echo ‘<img src=”/shop/img/rz_sfz.gif” title=”该用户已经通过身份证验证” />’;}?>&nbsp;<?php if($membersrs_mine[“permitconfirm”]){echo ‘<img src=”/shop/img/rz_zhizhao.gif” title=”该用户已经通过营业执照验证” />’;}?><br />
信用等级:<?php echo getgrade($shoprs_mine[“grade”]);?><br />
用户邮箱:<?php echo $membersrs_mine[“email”];?><br />
联系电话:<?php echo $membersrs_mine[“phone”]?$membersrs_mine[“phone”]membersrs_mine[“tel”];?>
</div>
<?php }else {?>
<div class=”nonemineshop”>您还未开通店铺,<a href=”/users/openshop.php#shopdiff” target=”_blank”>点击开通店铺</a></div>
<?php }?>
</div>
<div id=”shopbutton”><span>查看我自己店铺的信息</span></div>
</div>
</div>
<div class=”sendmsg allborder” style=”position:relative;”>
<div id=”facediv”>
<span style=”color:red;cursor:pointer;”>关闭表情</span>
<div class=”faceborder”><ul id=”facedd”></ul></div>
</div>
<div class=”snav”>
<div id=”tips”>您还可以输入500个字符</div>
<div id=”upimg”></div>
&nbsp;&nbsp;<a href=”javascript:ajax_addface();void(0);”><img src=”/chat/img/bq.gif” title=”增加表情” /></a>&nbsp;&nbsp;<a href=”javascript:void(0);shake(‘normal’);”><img title=”给对方发送抖动” src=”/chat/img/shake.gif” /></a>&nbsp;&nbsp;<a href=”javascript:upimg();void(0);”><img title=”给对方发送图片” src=”/chat/img/sendimg.gif” /></a>&nbsp;&nbsp;<a href=”javascript:dovoice()”><img title=”关闭消息声音提示” id=”voiceimg” src=”/chat/img/closevoice.gif” /></a>&nbsp;&nbsp;<a href=”###” title=”保存聊天记录”><img src=”/chat/img/savelog.gif” /></a>
</div>
<div class=”scontent”><textarea name=”” id=”content” title=”请在此输入您想要说的话,并按 Ctrl+Enter 发送消息”>请在此输入您想要说的话,并按 Ctrl+Enter 发送消息</textarea></div>
</div>
<div class=”button”>
<ul>
<li><img src=”/chat/img/sendbutton.gif” style=”cursor:pointer;” /></li>
<li><div id=”inputtips”></div></li>
<li style=”color:#026ffe;padding-top:8px;”>&nbsp;提示:您可以按&nbsp;Ctrl+Enter&nbsp;快速发送消息</li>
</ul>
</div>
</div>
<div id=”ajax_div”></div>
<embed src=”/chat/img/newmsg.wav” autostart=”false” loop=”false” id=”voice” style=”display:none;”>
<embed src=”/chat/img/shake.wav” autostart=”false” loop=”false” id=”shake_voice” style=”display:none;”>

 

php聊天室获取对方和自己的消息源码

//获取聊天消息
case “getchat”:

$me=$_GET[“me”];
$with=$_GET[“with”];

$me_uid=getuser_id_name($me,”username”);
$with_uid=getuser_id_name($with,”username”);

if($me_uid && $with_uid){
//操作请求人输入状态
$isinputing=$_GET[“isinputing”];
if($isinputing==”yes”) $isinputing=1;
if($isinputing==”no”) $isinputing=0;

//获取抖动
$withshake=$_GET[“withshake”];
if($withshake==”yes”) $withshake=1;
if($withshake==”no”) $withshake=0;

@mysql_query(“update chat_online set iswriting=$isinputing,isshaking=$withshake where fromid=$me_uid and fromname=’$me’ and toid=$with_uid and toname=’$with’ limit 1”);

//获取聊天人输入状态,之后通过值返回
$with_input_shakingrs=$db->query_first(“select iswriting,isshaking from chat_online where fromid=$with_uid and fromname=’$with’ and toid=$me_uid and toname=’$me’ limit 1”);

$db->query(“select id,posttime,txt from chat_msg where fromid=$with_uid and fromname=’$with’ and toid=$me_uid and toname=’$me’ and isread=0″);
$restr=”;
while($db->next_record()){
$restr.='<li><div class=”notme”>’.$with.’&nbsp;’.date(“H:i:s”,$db->f(“posttime”)).'</div><div class=”msg_content”>’.$db->f(“txt”).'</div></li>’;
$chatidstr.=$db->f(“id”).”,”;
}
@mysql_query(“update chat_msg set isread=1 where id in (“.substr($chatidstr,0,strlen($chatidstr)-1).”)”);

if($restr) $restr.=”&getchat”;
if($with_input_shakingrs[“iswriting”]==1) $restr.=”&isinputing”;
if($with_input_shakingrs[“isshaking”]==1) $restr.=”&withshake”;
echo $restr.”&addinnerHTML”;
}
break;

//发送聊天消息
case “sendchat”:
$me=$_GET[“me”];
$with=$_GET[“with”];
$me_uid=getuser_id_name($me,”username”);
$with_uid=getuser_id_name($with,”username”);

//将图片替换,为介绍服务器资源,已经在前台js中替换之后传值到ajax
//$value=preg_replace(“/\[img\]face([0-9]+)\[\/img\]/is”,”<img src=’face/$1.gif’ />”,$value);
$value=magicstr($value);//因为前台已经使用nl2br
//考虑到发送消息的安全和正确显示,去掉消息中的部分js代码
$replace_arr=array(“<script>”,”</script>”,”insert”,”update”,”delete”,”select”);
$value=str_replace($replace_arr,””,$value);

if($me_uid && $with_uid){
$posttime=$actime_header;
if(!$db->query(“insert into chat_msg set fromid=$me_uid,fromname=’$me’,toid=$with_uid,toname=’$with’,posttime=$posttime,txt=’$value'”)){
$restr='<li><div class=”me”>’.$me.’&nbsp;’.date(“H:i:s”,$posttime).'</div><div class=”msg_content”><span style=”color:red;”>对不起,消息发送失败,请刷新页面重试</span></div>< /li>’;
echo $restr.”&addinnerHTML”;
}
}
break;

 

 

// JavaScript Document
javascript实现无刷新网页客服效果,当然是和ajax结合的,这里为了安全,只放出js文件,其它文件自留
function $id(id){ return document.getElementById(id)}
window.onerror=function(){return true;}
window.onload=function (){
//聊天窗口打开自动最大化
window.moveTo(0,0);
if(document.all) top.window.resizeTo(screen.availWidth,screen.availHeight);
else if(document.layers||document.getElementById){
if(top.window.outerHeight<screen.availHeight||top.window.outerWidth<screen.availWidth){
top.window.outerHeight = screen.availHeight;top.window.outerWidth = screen.availWidth;}
}
$id(“chatbox”).style.marginTop=(document.documentElement.clientHeight-570)/2+”px”
ajax(“chatbox”,”/inc/ajax.php?act=getchatbox&me=”+me+”&with=”+withwho,0,”<img src=’/img/loading.gif’ class=’loadingimg_all’ />”)
}
function isIE(){
if(window.navigator.appName==”Microsoft Internet Explorer”) return true;
else return false;
}
//关闭窗口时提示
window.onclose=closewin;
function closewin(){
if(confirm(‘确定关闭当前聊天窗口吗?关闭窗口后,您本次的聊天记录将清空\n建议您手动保存本次聊天记录’)) window.opener = null;window.close();
}
function add_zero(n){
if(n<10) return “0”+n
else return n;
}
/**获取当前时间**/
function get_time(ymd) {
var date=new Date();
var year=””,month=””,dayte=””,hour=””,minute=””,second=””;
year=date.getYear();
month=date.getMonth()+1;
dayte=date.getDate();
hour=add_zero(date.getHours());
minute=add_zero(date.getMinutes());
second=add_zero(date.getSeconds());
if(ymd) return year+”_”+month+”_”+dayte;
else return hour+”:”+minute+”:”+second;
}
function changechat_scroll(){
var divheight
if($id(“msg_ul”).scrollHeight>314) $id(“msg_chat”).scrollTop=$id(“msg_ul”).scrollHeight-270
}
//发送消息
function send(){
//正则替换表情图片和换行
var value=$id(“content”).value
value = value.replace(/\n/g,”<br>”);
value = value.replace(/\[img]face/g,”<img src=’/chat/face/”);
value = value.replace(/\[\/img]/g,”.gif’ />”);
if(value==’请在此输入您想要说的话,并按 Ctrl+Enter 发送消息’ || value==”) {alert(‘对不起,发送内容不能为空!’);$id(“content”).focus();$id(“content”).value=”;}
else {
if($id(“tips”).innerHTML.indexOf(“超出”)!=-1) {alert(“对不起,您输入的字符超出了500字符限制”);$id(“content”).focus();return false}
/*替换输入的链接,注意的是,截取到空格的时候自动停止*/
var urlstr=”;
var url_input_start=value.indexOf(“http://”)
if(url_input_start!=-1){
for(i=url_input_start;i<value.length;i++){
var cutstr=value.substr(i,1);
if(cutstr==”<“) break;
var cutstr_asc=Math.abs(cutstr.charCodeAt(0));
if(cutstr_asc>127 || cutstr_asc==32) break;//汉字和空格自动退出
urlstr+=cutstr;
}
value=value.replace(urlstr,”<a href='”+urlstr+”‘ target=’_blank’>”+urlstr+”</a>”)
}
//以下为替换字符,防止提交非法字符
var alertstr=”
if(value.indexOf(“delete”)!=-1) {value=value.replace(“delete”,””);alertstr+=’delete,’;}
if(value.indexOf(“update”)!=-1) {value=value.replace(“update”,””);alertstr+=’update,’;}
if(value.indexOf(“insert”)!=-1) {value=value.replace(“insert”,””);alertstr+=’insert,’;}
if(value.indexOf(“select”)!=-1) {value=value.replace(“select”,””);alertstr+=’select,’;}
if(value.indexOf(“script”)!=-1) {value=value.replace(“script”,””);alertstr+=’script,’;}
$id(“inputtips”).style.display=”none”
if(alertstr!=”) alertstr=”<div class=’allborder’ style=’margin-left:10px;padding:5px;background:url(/chat/img/body.gif); color:red’>您刚才发送消息中:”+alertstr+”已经被屏蔽</div>”;
$id(“msg_ul”).innerHTML=$id(“msg_ul”).innerHTML+'<li><div class=”me”>’+me+’ ‘+get_time()+'</div><div class=”msg_content”>’+value+'</div>’+alertstr+'</li>’
ajax(“ajax_div”,”/inc/ajax.php?act=sendchat&me=”+me+”&with=”+withwho,encodeURI(value))
changechat_scroll();$id(“content”).value=”;$id(“content”).focus();
}
}
function change_with_input_statu(ac){
if(ac==”yes”) {$id(“inputtips”).style.display=”block”;$id(“inputtips”).innerHTML=withwho+” 正在输入文字”;}
if(ac==”not”) $id(“inputtips”).style.display=”none”
}
//防止恶意多次抖动,声明变量
var stop_shake_time=0
var withshake=”no”//此变量为抖动对方请求变量

//获取消息的时候同样提交本地是否在输入,还要获取对方是否在输入
//其中提交本地是否在输入,通过提交本地输入框的值,获取则通过服务器端返回值
var first_inputvalue=”
var isinputing=”no”//默认输入状态为假
function getmsg(){
stop_shake_time++
if($id(“content”).value!=first_inputvalue){
//说明本地在输入
first_inputvalue=$id(“content”).value;isinputing=”yes”
}
else isinputing=”no”
//msg_ul为显示内容的ul_id
ajax(“msg_ul”,”/inc/ajax.php?act=getchat&withshake=”+withshake+”&isinputing=”+isinputing+”&me=”+me+”&with=”+withwho,0)
if(withshake==”yes”) withshake=”no”
}
//一秒自动获取对方发送的消息
window.setInterval(“getmsg()”,1000)
function ajax_addface(){
$id(‘facediv’).style.display=’block’;
if($id(‘facedd’).innerHTML==”) ajax(“facedd”,”/inc/ajax.php?act=getface”,0,”<img src=’/img/loading.gif’ class=’loadingimg’ />”)
}
//增加表情函数
function addface(n){
if($id(“content”).value==’请在此输入您想要说的话,并按 Ctrl+Enter 发送消息’) $id(“content”).value=”
$id(“content”).value=$id(“content”).value+”

“;$id(“facediv”).style.display=”none”;$id(“content”).focus();
}
//单击页面其它部分将表情和tips提示框隐藏
function hides(event){
event= event || window.event;
srcobj=event.target || event.srcElement;
if(srcobj.tagName!=”IMG”) $id(“facediv”).style.display=”none”
if(srcobj.tagName==”BODY”) $id(“upimg”).style.display=”none”
if(srcobj.tagName==”TEXTAREA”) $id(“upimg”).style.display=”none”
}
document.onclick=hides

function isKeyTrigger(e,keyCode){
var argv = isKeyTrigger.arguments;
var argc = isKeyTrigger.arguments.length;
var bCtrl = false;
if(argc > 2){
bCtrl = argv[2];
}
var bAlt = false;
if(argc > 3){
bAlt = argv[3];
}
var nav4 = window.Event ? true : false;
if(typeof e == ‘undefined’) {
e = event;
}
if( bCtrl &&
!((typeof e.ctrlKey != ‘undefined’) ?
e.ctrlKey : e.modifiers & Event.CONTROL_MASK > 0)){
return false;
}
if( bAlt &&
!((typeof e.altKey != ‘undefined’) ?
e.altKey : e.modifiers & Event.ALT_MASK > 0)){
return false;
}
var whichCode = 0;
if (nav4) whichCode = e.which;
else if (e.type == “keypress” || e.type == “keydown”)
whichCode = e.keyCode;
else whichCode = e.button;
return (whichCode == keyCode);
}
//结合以上函数兼容ff实现ctrl+enter发送消息
function ctrlEnter(e){
var ie =navigator.appName==”Microsoft Internet Explorer”?true:false;
if(ie){
if(event.ctrlKey && window.event.keyCode==13){send();}
}else{
if(isKeyTrigger(e,13,true)){send();}
}
}
var voice_first=”open”
//操作声音提示
function dovoice(){
if(voice_first==”open”)    {$id(“voiceimg”).src=”/chat/img/openvoice.gif”;$id(“voiceimg”).title=”开启 消息声音提示”;voice_first=”close”    }
else {$id(“voiceimg”).src=”/chat/img/closevoice.gif”;$id(“voiceimg”).title=”关闭消息声音提示”;voice_first=”open”}
}
function playvoice(){if(voice_first==”open” && isIE()) $id(“voice”).play();}
var last_shake_time
var first_marginLeft=(document.documentElement.clientWidth-750)/2
var first_marginTop=(document.documentElement.clientHeight-570)/2
var shake_timer
var shake_move_watch=0
var diff_shake_timer
function diff_shake(){
var diff_shake_time=stop_shake_time-last_shake_time
$id(“tips”).innerHTML=”<span style=’color:red;’>对不起,多次发送抖动时间间隔必须大于5秒</span>,<span style=’color:blue;’>”+(6-diff_shake_time)+”秒后您可以再次发送</span>”
diff_shake_timer=setTimeout(“diff_shake()”,1000)
if(5-diff_shake_time<0) {
clearTimeout(diff_shake_timer)
$id(“tips”).innerHTML=”您现在可以向对方发送抖动了”
}
}
var shake_act
function shake_move(){
if(shake_move_watch==0){
//播放声音,只播放一次
if(voice_first==”open” && isIE()) $id(“shake_voice”).play();
for(k=1;k<15;k++){$id(“chatbox”).style.marginTop=first_marginTop-k+”px”}
}
if(shake_move_watch==1){
for(k=14;k>=0;k–){$id(“chatbox”).style.marginTop=first_marginTop-k+”px”;$id(“chatbox”).style.marginLeft=first_marginLeft-(10-k)+”px”    }
}
if(shake_move_watch==2){
for(k=14;k>=0;k–){$id(“chatbox”).style.marginTop=first_marginTop-k+”px”;$id(“chatbox”).style.marginLeft=first_marginLeft-(10-k)+”px”    }
}
if(shake_move_watch==3){
for(k=1;k<=15;k++){$id(“chatbox”).style.marginTop=first_marginTop-(10-k)+”px”;$id(“chatbox”).style.marginLeft=first_marginLeft+k+”px”
}
}
if(shake_move_watch==4){
for(k=14;k>=0;k–){$id(“chatbox”).style.marginLeft=first_marginLeft+k+”px”}
}
if(shake_move_watch==5){$id(“chatbox”).style.marginTop=first_marginTop+”px”;$id(“chatbox”).style.marginLeft=first_marginLeft+”px”}
shake_timer=setTimeout(“shake_move()”,10)
shake_move_watch++
if(shake_move_watch==6) {
shake_move_watch=0;if(shake_act==”normal”) withshake=”yes”
clearTimeout(shake_timer);last_shake_time=stop_shake_time
}
}
function shake(act){
shake_act=act
var diff_shake_time=stop_shake_time-last_shake_time
if(diff_shake_time<5) {$id(“tips”).style.display=”block”;diff_shake()}
else shake_move()
}
function check_input(){
/*提示信息设置*/
$id(“tips”).style.display=”block”
var obj_value=$id(‘content’).value
var tollen=500
var nowlen=0
for(i=0;i<obj_value.length;i++){
if(obj_value.charCodeAt(i)>127) nowlen+=3
else nowlen+=1
}
var caninputlen=tollen-nowlen
if(caninputlen<=0) $id(“tips”).innerHTML=”<span style=’color:red’>您已经超出500字符输入显示,当前您输入了:”+nowlen+”个字符</span>”;
else $id(“tips”).innerHTML=”您还可以输入”+caninputlen+”个字符”;
}

function navover(who,act){
if(act==”over”) who.style.cssText=”border:1px solid #7fcce5;”
if(act==”out”) who.style.cssText=”border:none”
}

function upimg(){
$id(“upimg”).style.display=”block”
$id(“upimg”).innerHTML='<iframe name=”” src=”/chat/upimg.php?me=’+me+’&with=’+withwho+'” frameborder=”0″ width=”100%” height=”100%”></iframe>’
}
var isinputing_re
function processReqChange(){
var ready=req.readyState;
var data=null;
document.getElementById(name_str).style.display=”block”
if (ready==READY_STATE_COMPLETE){
data=req.responseText;
data_arr=data.split(‘<script>’);
if(data_arr[0]!=”){
//获取对方输入状态
if(data_arr[0].indexOf(“&isinputing”)!=-1){
isinputing_re=”yes”;data_arr[0]=data_arr[0].replace(“&isinputing”,””);
}
else isinputing_re=”not”
//获取对方抖动请求
if(data_arr[0].indexOf(“&withshake”)!=-1){
shake(‘request’);data_arr[0]=data_arr[0].replace(“&withshake”,””);
}
//判断是否重复增加
if(data_arr[0].indexOf(“&addinnerHTML”)!=-1) {
data=data_arr[0].replace(“&addinnerHTML”,””);
if(data!=”) {
//获取消息提取声音
if(data.indexOf(“&getchat”)!=-1){
playvoice();var isgetchat=”yes”;data=data.replace(“&getchat”,””);
}
document.getElementById(name_str).innerHTML=document.getElementById(name_str).innerHTML+data;
//获取消息是自动改变滚动条高度
if(isgetchat==”yes”) changechat_scroll()
}
}
else  document.getElementById(name_str).innerHTML=data_arr[0];
change_with_input_statu(isinputing_re)//因为是ajax获取聊天框,此函数必须放在输出后
}
if(data_arr[1]) eval(data_arr[1]);
result=true;
}
else {
if(notready_inner){document.getElementById(name_str).innerHTML=notready_inner;notready_inner=”}
}
}
function showmyshop(act){
if(act==”open”){
$id(“withshopmsg”).style.display=”none”;$id(“myshopmsg”).style.display=”block”
$id(“shopbutton”).innerHTML='<span style=”color:black;”>查看对方店铺信息</span>’
}
else {
$id(“withshopmsg”).style.display=”block”;$id(“myshopmsg”).style.display=”none”
$id(“shopbutton”).innerHTML='<span>查看我自己店铺的信息</span>’
}
}
function savemsg(){
var sdefault_html='<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”><html xmlns=”http://www.w3.org/1999/xhtml”><head><meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ /><title>聊天记录</title><base href=”http://www.s2c.cn/” /><link href=”/chat/img/css.css” rel=”stylesheet” /></head><body><div class=”msg_chat”><ul style=”padding-bottom:15px;”>’
//取得id=tb的表格的HTML代码.
var strHTML = $id(“msg_chat”).innerHTML; var winSave = window.open();
winSave.document.open (“text/html”,”utf8″); winSave.document.write (sdefault_html+strHTML+”</ul></div></body></html>”);
winSave.document.execCommand (“SaveAs”,true,me+”_”+withwho+”_”+get_time(true)+”_聊天记录.htm”); winSave.close();
}

分类: php学习 标签:
css.php