模擬OICQ的實現思路和核心程序(三)

5 聊天信息的發送、閱讀和回復程序 – shortalk.php(做為現在的主流開發語言)

<?
require(“require.php(做為現在的主流開發語言)“); // 判斷用戶是否合法在線的公用程序
?>
<html>
<head>
<title>短信息</title>
<meta http-equiv=”Content-Type” content=”text/html; charset=gb2312″>
<style type=”text/css”>
td {font-size:9pt}
</style>
<script 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.0
window.open(theURL,winName,features);
}
//–>
</script>
</head>

<body bgcolor=”#DDDDFF”leftmargin=”0″ topmargin=”0″ background=”php(做為現在的主流開發語言)chat_images/cloudtile.jpg”>
<?
if($action == “view”)
{
$tmp = MySQL(和PHP搭配之最佳組合)_fetch_array(MySQL(和PHP搭配之最佳組合)_query(“select sender,body,date from forumtalk where id=$talknumber and receiver=$name”));
$msg = $tmp[body];
$message = ereg_replace(“
“,”
“,$msg);
MySQL(和PHP搭配之最佳組合)_query(“update forumtalk set readsign=1 where id=$talknumber”);
$sendernickname = MySQL(和PHP搭配之最佳組合)_fetch_row(MySQL(和PHP搭配之最佳組合)_query(“select nickname from userinfo where name=”.$tmp[sender].””));
?>
<table width=”300″ border=”0″ cellspacing=”0″ cellpadding=”0″ height=”200″ bgcolor=”f0f0f0″>
<tr>
<td colspan=”2″ height=”20″ bgcolor=”99cc99″ align=”center”>查看短信息</td>
</tr>
<tr>
<td colspan=”2″ height=”20″><?echo date(“m月d日 h:i”,$tmp[date]).” “.$sendernickname[0]?> 給你[<?echo $name?>]留言:</td>
</tr>
<form name=viewtalk action=shortalk.php(做為現在的主流開發語言) method=post>
<input type=hidden name=talkto value=<?echo $tmp[sender]?>>
<input type=hidden name=action value=send>
<input 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>
</tr>
<tr>
<td colspan=”2″ align=”center”>
<input type=”submit” name=”toreply” value=”回復留言 Enter”>
<a href=”#” onClick=”MM_openBrWindow(memberviewtalk.php(做為現在的主流開發語言)?talkto=<?echo $tmp[sender]?>,viewtalk,scrollbars=yes)”>聊天紀錄</a> </td>
</tr>
</form>
</table>
<script language=”Javascript”>
document.viewtalk.toreply.focus();
</script>
<?
}
else if ($action == “sendbegin”)
{
$replymessage = ereg_replace(”
“,”
“,$replymessage);
$replymessage = ereg_replace(“>”,”>”,$replymessage);
$replymessage = ereg_replace(“<“,”<“,$replymessage);
$replymessage = substr($replymessage,0,2000);
MySQL(和PHP搭配之最佳組合)_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=sendbegin>

發佈留言