⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 readmessage.php

📁 Download you own three BR
💻 PHP
字号:
<?php
session_start();
include "../functions/class_mysql.php";
include "include/functions.php";
$db->select_db("baysoftchat");
timer();
//
//验证用户身份。
//
//if(!verifyMember(session_id(),$_COOKIE["NickName"]))
//{
//	echo "parent.location.href=\"notice.php?id=".not_login."\"";
//	exit;
//}
//if(!$db->connect())
//{
//	echo "alert('数据库连接失败!')";
//}
$sql = "select * from `messages` where (`to_user` = '".$_COOKIE["NickName"]."' or `private`=0) and `id` > {$_GET["messageid"]} and `from_user` != '{$_COOKIE["NickName"]}'  order by `id` asc";
$tm = time();
$db->query("update `onlinelist` set `activetime` = '{$tm}' where `username` = '{$_COOKIE["NickName"]}'");
$result = $db->query($sql);
$totalRows = $db->num_rows($result);
if(mysql_error())
{
	$db->query("repair table `messages`");
}
$readedRows = 0;
while($rows = $db->fetch_array($result))
{
	echo 'writeMessage("'.nl2br(addslashes($rows["content"])).'","'.$rows["from_user"].'","'.$rows["to_user"].'","'.$rows["time"].'","'.$rows["title"].'","'.$rows["saycolor"].'","'.$rows["namecolor"].'","'.$rows["private"].'","'.$rows["type"].'","'.$rows["event"].'","'.$rows["face"].'");';
	$readedRows ++;
	if($readedRows==$totalRows)
		echo "messageid=".$rows["id"].";";
}
/**************************解决一段时间没有更新时间的用户,因为该用户可能已经掉线了--*/
$leaveTime = 60;      //每一分钟清除一次用户
$clearTime = time()-60;
$microtime = explode(" ",microtime());
$microtime = $microtime[0]+$microtime[1];
if(($microtime-$db->result($db->query("select `value` from `config` where `name` = 'check_online'"),0,"value"))>$leaveTime)
{
	$db->query("update `config` set `value` = '".$microtime."' where `name` = 'check_online'");
	$clearResult = $db->query("select `username`,`roomid` from `onlinelist` where `activetime` < {$clearTime}");
	if($clearTotalRows = $db->num_rows($clearResult))
	{
		while($clearRow = $db->fetch_array($clearResult))
		{
			$db->query("delete from `onlinelist` where `username` = '{$clearRow["username"]}'");
			if($db->affectedrows())
			{
				$message = array("private"=>"","event"=>"","from_user"=>"","type"=>"","roomid"=>"","content"=>"","to_user"=>"","title"=>"","namecolor"=>"","saycolor"=>"","face"=>"");
				$message["event"] = msg_leave;
				$message["from_user"] = $clearRow["username"];
				$message["type"] = type_system;
				$message["roomid"] = $clearRow["roomid"];
				addMessage($message,$db);
			}
		}
	}
}
//echo "showDebug('".timer()."','".$db->querynumbers()."');";
$db->close();
?>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -