<?
include_once("inc/config.php");
include_once("inc/ftbbsdbclass.php");
include_once("inc/publicfun.php");
include_once("conn.php");
include_once("checkuser.php");
include_once("bbsuser.php");

$clubuser_id=intval(get_cookie('clubuser_id'));
$username=get_cookie('username');
$postuser=ftbbs_request($_GET["postuser"]);
$accepter=ftbbs_request($_GET["accepter"]);
$agree=$_GET["agree"];
if ($agree=="Y"){
   $sql="select * from {$tablepre}haoyou where userid='".$clubuser_id."' and haoyouname='".$postuser."'";
   $rs=mysql_query($sql);
   $row = mysql_fetch_array($rs);
   $numrows = mysql_num_rows($rs);
   if ($numrows!=0){
   echo "<script language='javascript'>";
   echo "history.go(-1);</script>";
   exit;
   }
   else{
   $strsql="insert into {$tablepre}haoyou (userid,haoyouname,groupname,addtime) values('$clubuser_id','$postuser','我的好友','$getnow')";
   mysql_query($strsql);
   }
}
else{
   $sql="select clubuser_id from {$tablepre}clubuser where clubuser_name='".$postuser."'";
   $rs=mysql_query($sql);
   $row = mysql_fetch_array($rs);
   $clubuser_id=$row["clubuser_id"];
   mysql_query("delete from {$tablepre}haoyou where haoyouname='".$accepter."' and userid='".$clubuser_id."'");
   mysql_query("delete from {$tablepre}sms where id='".$id."'");
}
$db->close(); 
$returnurl=$_SERVER["HTTP_REFERER"];
header("Location:".$returnurl);
?>