5 聊天信息的发送、阅读和回复程序 - shortalk.php
1<html>
2<head>
3<title>短信息</title>
4<meta content="text/html; charset=utf-8" http-equiv="Content-Type"/>
5<style type="text/css">
6td {font-size:9pt}
7</style>
8<script language="Javascript">
9<!--
10function docheck() {
11if (document.sendmsg.replymessage.value=="") {
12alert("缺少内容:需要输入您的留言内容");
13document.sendmsg.replymessage.focus();
14return(false);
15}
16return (true);
17}
18
19function MM_openBrWindow(theURL,winName,features) { //v2.0
20window.open(theURL,winName,features);
21}
22//-->
23</script>
24</head>
25<body background="phpchat_images/cloudtile.jpg" bgcolor="#DDDDFF" leftmargin="0" topmargin="0">
26<?
27if($action == "view")
28{
29$tmp = mysql_fetch_array(mysql_query("select sender,body,date from forumtalk where id=$talknumber and receiver='$name'"));
30$msg = $tmp['body'];
31$message = ereg_replace("
32","\r\n",$msg);
33mysql_query("update forumtalk set readsign=1 where id=$talknumber");
34$sendernickname = mysql_fetch_row(mysql_query("select nickname from userinfo where name='".$tmp['sender']."'"));
35?>
36<table bgcolor="f0f0f0" border="0" cellpadding="0" cellspacing="0" height="200" width="300">
37<tr>
38<td align="center" bgcolor="99cc99" colspan="2" height="20">查看短信息</td>
39</tr>
40<tr>
41<td colspan="2" height="20"><?echo date("m月d日 h:i",$tmp['date'])." ".$sendernickname[0]?> 给你[<?echo $name?>]留言:</td>
42</tr>
43<form action="shortalk.php" method="post" name="viewtalk">
44<input $tmp['sender']?="" name="talkto" type="hidden" value="<?echo"/>>
45<input name="action" type="hidden" value="send"/>
46<input name="talknumber" type="hidden" value="<?print($talknumber)?"/>>
47<tr align="center">
48<td colspan="2" height="146" valign="top">
49<textarea cols="40" name="textfield" readonly="" rows="11"><?print($message)?></textarea>
50</td>
51</tr>
52<tr>
53<td align="center" colspan="2">
54<input name="toreply" type="submit" value="回复留言 Enter"/>
55<a href="#" onclick="MM_openBrWindow('memberviewtalk.php?talkto=<?echo $tmp['sender']?>','viewtalk','scrollbars=yes')">聊天纪录</a> </td>
56</tr>
57</form>
58</table>
59<script language="Javascript">
60document.viewtalk.toreply.focus();
61</script>
62<?
63}
64else if ($action == "sendbegin")
65{
66$replymessage = ereg_replace("\r\n","
67",$replymessage);
68$replymessage = ereg_replace(">",">",$replymessage);
69$replymessage = ereg_replace("<","<",$replymessage);
70$replymessage = substr($replymessage,0,2000);
71mysql_query("insert into forumtalk (sender,receiver,body,date) values ('$name','$talkto','$replymessage',".date("U").")");
72print("<script language="javascript">window.close()</script>");
73}
74else
75{
76?>
77<table bgcolor="f0f0f0" border="0" cellpadding="0" cellspacing="0" height="200" width="300">
78<form action="shortalk.php" method="post" name="sendmsg" onsubmit="return(docheck());">
79<input name="action" type="hidden" value="sendbegin"/>
80<tr align="center">
81<td bgcolor="99cc99" colspan="2" height="20">发送短信息</td>
82</tr>
83<tr align="center">
84<td colspan="2" height="20">发言对象:
85<select name="talkto">
86<?
87$result = mysql_query("select name,nickname from userinfo where onlinestatus=1");
88while($msg=mysql_fetch_array($result))
89{
90if($msg['name']==$talkto)
91echo "<option value='".$msg['name']."' selected>".$msg['nickname']."\n";
92else
93echo "<option name']."'="" value='".$msg['>".$msg['nickname']."</option>\n";
94}
95?>
96</select>
97请短于500字符 </td>
98</tr>
99<tr align="center">
100<td colspan="2" height="146" valign="top">
101<textarea cols="40" name="replymessage" rows="9"></textarea>
102</td>
103</tr>
104<tr align="center">
105<td colspan="4">
106<?
107if($talknumber != "")
108{
109print("<input type=button name=review value='查看前一留言 Alt+P' accesskey='p' onClick='javascript:history.go(-1)'>");
110}
111?>
112<input accesskey="s" name="reply" type="submit" value="开始新的发送留言 Alt+S"/>
113<a href="#" onclick="MM_openBrWindow('memberviewtalk.php?talkto=<?echo $talkto?>','viewtalk','scrollbars=yes')">聊天纪录</a></td>
114</tr>
115</form>
116</table>
117<script language="Javascript">
118document.sendmsg.replymessage.focus();
119</script>
120<?
121}
122?>
123</body>
124</html>