</form>
<script>function check(){if(document.chat.chatmsg.value==''){;alert('请输入聊天信息!');return false;}return true;}</script>
";
}
//保存说话
if ($action=="save")
{
if ($_POST['chatmsg']!="") {
save_chat($_POST['chatmsg'], $_SESSION['username'], $_POST['usercolor']);
}
header("location:".SCRIPT."?action=say");
}
//显示聊天记录
if ($action=="show")
{
echo "<body style='font-size:12px' onload='scrollit()'>";
echo "<META HTTP-EQUIV=REFRESH CONTENT='".REF_TIME.";URL=".SCRIPT."?action=show'>";
if (file_exists(CHAT_NOTE)) {
$chat_msg = @file_get_contents(CHAT_NOTE);
echo $chat_msg;
} else {
echo "目前没有人说话";
}
}
//退出聊天室
if ($action=="logoff")
{
unset($_SESSION['username']);
session_destroy();
header("location:".SCRIPT);
}
/* 基本函数 */
//保存聊天记录函数
function save_chat($msg, $user, $color)
{
if (!$fp = fopen(CHAT_NOTE, "a+")) {
die('创建聊天记录文件失败, 请检查是否有权限.');
}
$msg = htmlspecialchars($msg);
$msg = preg_replace('/([http|ftp:\/\/])*([a-zA-])+\.([a-zA-Z0-9_-])+\.([a-zA-Z0-9_-])+(a-zA-Z0-9_)*/', '<a href=../../\\0 target=_blank>\\0</a>', $msg);
$msg = preg_replace('/([a-zA-Z0-9_\.])+@([a-zA-Z0-9-])+\.([a-zA-Z0-9-]{2,4})+/', '<a href=mailto:\\0>\\0<
| 对此文章发表了评论 |
