标题: @功能求助………
时间: 2015-08-27
<?php
session_start();
$bt="回复帖子";
include("../top.php");
include("../conn.php");
include_once("../function.php");
$sid = sqlstr($_COOKIE['dl']);
$uin=mysql_fetch_array(mysql_query("select * from user where sid='$sid'"));
$id=$uin['id'];
$nick=$uin['nick'];
if(!$uin){
header("Location:../login.php");
exit;
}
$tid=sqlstr($_GET['tid']);
$hftime=time();
$hftxt=$_POST["hftxt"];
$text=htmlspecialchars($_POST["hftxt"]);
$txt=sqlstr(nl2br($text));
if($txt==Null){
echo '<br/><font color="red">很无语啊:</font><br/>你什么都不写,你想表达什么呢?写一点吧。<br/><br/><br/>';
}elseif(mb_strlen($txt,'utf-8')>50){
echo "回复字数不能大于50哦,唯爱时光装不下啦~ <br/><br/><br/>";
}else{
if($_SESSION['hf']!=$txt){
$_SESSION['hf']="${txt}";
$hf="UPDATE tie SET hf=hf+1 WHERE tid='$tid'";
mysql_query($hf,$conn);
$rss=mysql_query("INSERT INTO hf(hid,hftxt,uid,tid,hftime) VALUES ('','$text','$id','$tid','$hftime')");
if($rss){
$hftxt=preg_replace("!(@|@)([\\x{4e00}-\\x{9fa5}A-Za-z0-9_\\-]{1,})(\x20| |<|\xC2\xA0|\r|\n|\x03|\t|,|\\?|\\!|:|;|,|。|?|!|:|;|、|…|$)!ue","'@\\2 \\3'",$hftxt);
if (preg_match('/@/', $hftxt)){
$ei = explode('@', $hftxt);
$num = count($ei);
$num = $num - 1;
for ($i = 1; $i <= $num; $i++) {
$eii = explode(',', $ei[$i]);
$eii = explode(' ', $ei[$i]);
$row=mysql_query("SELECT * FROM user WHERE nick='$eii[0]'");
$row=$row['0'];
if(is_array($row)){
$time=time();
mysql_query("INSERT INTO ait(atid, kan,fnick,time,nick,tzid) VALUES ('', '0', '$eii[0]', '$time', '$nick', '$time')");
}
}}
}
header("Location:read.php?tid=$tid");
exit;
}else{
echo "<br/><br/><font color='red'>不可重复回复。</font><br/> <br/><a href='index.php'>返回首页</a><br/><br/> ";
}
}
?>
<?php
include('../foot.php');
foot_staring();
?>
『回复列表(30|显示机器人聊天)』
/*
*入库(被艾特用户名提取)
*$content->帖子内容
*$postid->帖子详情
*$userid->用户详情
*
*/
function ait($content,$titlename,$text,$username,$postid,$title,$url,$db_name){
$content=preg_replace("!(@|@)([\\x{4e00}-\\x{9fa5}A-Za-z0-9_\\-]{1,})(\x20| |<|\xC2\xA0|\r|\n|\x03|\t|,|\\?|\\!|:|;|,|。|?|!|:|;|、|…|$)!ue","'@\\2 \\3'",$content);
if (preg_match('/@/', $content)){
$ei = explode('@', $content);
$num = count($ei);
$num = $num - 1;
for ($i = 1; $i <= $num; $i++) {
$eii = explode(',', $ei[$i]);
$eii = explode(' ', $ei[$i]);
//print_r($eii);
//echo $eii[0].'<br />';
$sql=mysql_query("SELECT * FROM `user` WHERE `name` LIKE '$eii[0]'");
$c=mysql_num_rows($sql);
if($c=='1'&&isset($username[id])){
$time=time();
mysql_query("INSERT INTO `$db_name`.`ait` (`id`, `aitid`, `taid`, `title`, `titlename`, `text`, `url`, `time`) VALUES (NULL, '$username[name]', '$eii[0]', '$title', '$titlename', '$text', '$url', '$time')");
}
}}
}
<?php
session_start();
$bt="回复帖子";
include("../top.php");
include("../conn.php");
include_once("../function.php");
$sid = sqlstr($_COOKIE['dl']);
$uin=mysql_fetch_array(mysql_query("select * from user where sid='$sid'"));
$id=$uin['id'];
$nick=$uin['nick'];
if(!$uin){
header("Location:../login.php");
exit;
}
$tid=sqlstr($_GET['tid']);
$hftime=time();
$hftxt=$_POST["hftxt"];
$hftxt=preg_replace("!(@|@)([\\x{4e00}-\\x{9fa5}A-Za-z0-9_\\-]{1,})(\x20| |<|\xC2\xA0|\r|\n|\x03|\t|,|\\?|\\!|:|;|,|。|?|!|:|;|、|…|$)!ue","'@\\2 \\3'",$hftxt);
if (preg_match('/@/', $hftxt)){
$ei = explode('@', $hftxt);
$num = count($ei);
$num = $num - 1;
for ($i = 1; $i <= $num; $i++) {
$eii = explode(',', $ei[$i]);
$eii = explode(' ', $ei[$i]);
$sql['0']=mysql_query("SELECT * FROM user WHERE nick='$eii[0]'");
$sql=$sql['0'];
if($sql){
mysql_query("INSERT INTO ait(atid,kan,fnick,time,nick,tzid,hftxt) VALUES ('','0','$eii[0]','$hftime','$nick','$tid','$hftxt')");
}else{
echo '
该用户不存在!
';
}
}
}
$text=htmlspecialchars($_POST["hftxt"]);
$txt=sqlstr(nl2br($text));
if($txt==Null){
echo '<br/><font color="red">很无语啊:</font><br/>你什么都不写,你想表达什么呢?写一点吧。<br/><br/><br/>';
}elseif(mb_strlen($txt,'utf-8')>50){
echo "回复字数不能大于50哦,唯爱时光装不下啦~ <br/><br/><br/>";
}else{
if($_SESSION['hf']!=$txt){
$_SESSION['hf']="${txt}";
$hf="UPDATE tie SET hf=hf+1 WHERE tid='$tid'";
mysql_query($hf,$conn);
$rss=mysql_query("INSERT INTO hf(hid,hftxt,uid,tid,hftime) VALUES ('','$text','$id','$tid','$hftime')");
header("Location:read.php?tid=$tid");
exit;
}else{
echo "<br/><br/><font color='red'>不可重复回复。</font><br/> <br/><a href='index.php'>返回首页</a><br/><br/> ";
}
}
?>
<?php
include('../foot.php');
foot_staring();
?>
<script language="javascript" type="text/javascript">
function atAdd(uid) {
var nr = document.getElementsByName("nr")[0];
nr.value += "@"+uid+",";
}
</script>
<a href="#" onclick="atAdd('晨梦');return false">@Ta</a>
<textarea name="nr"></textarea><br/>