<?php 
require "../Run.php";
require "view/listadmin.view.php";
$css='
<style type="text/css">
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
	min-width:320px;
}
.f_sub {
	font-family: "微软雅黑";
	background-color: #efefef;
	padding-top: 5px;
	padding-bottom: 5px;
	padding-left: 10px;
}
.f_list{
	list-style:none;
	margin:0px;
	padding:0px;
	}
.f_list li {
	height:50px;
	border-bottom:1px solid #ccc;
	background-color:#FFF;
	}
.left{
	height:50px;
	width:50px;
	}
.right{

	height:50px;
	}
.right a{
	float:left;
	width:100%;
	}
.f_list li img {
	margin:5px;
	width:40px;
	height:40px;
	border :none;
	}
.f_list li h2{
	margin:0px;
	padding:0px;
	font-size:17px;
	margin-top:5px;
	color:#222;
	
	}
.f_list li h3{
	
	padding:0px;
	margin:0px;
	clear:both;
	font-size:14px;
	color:#ccc;
	margin-bottom:5px;
	}
table.top_bar{
	clear:both;
	height:40px;
	width:100%;
	line-height:40px;
	}
table.top_bar tr td.left{
	width:80px;
	height:40px;
	text-align:center;
	}
table.top_bar tr td.right{
	width:80px;
	height:40px;
	text-align:center;
	}
table.topbar tr td.center {
	text-align:center;
	}
#my_f_sel{
	height:30px;
	width:160px;
	border:1px solid #328cc9;
	text-align:center;
	clear:both;
	line-height:30px;
	}
#my_f_sel tr td{
	width:50%;
	}
#sell{
	background-color:#328cc9}
</style>'.$css;
if($login!=1){
die("拦截非法操作");
}
echo head('好友管理').'<link href="../style/css/myf.css" rel="stylesheet" type="text/css" /><body>';
$type=$_GET['type'];
if($type=='del'){
$result = mysql_query("DELETE FROM myfgro WHERE id='{$_GET['id']}' AND siteid='{$wapid}'");
	 echo '<div class="subtitle">删除分组</div>';
	 echo '<div class="tip">';
	 if($result && mysql_affected_rows()>0){
	 echo '成功删除';
	 }else{
     echo "删除失败";
	 }
}elseif($type=='mod'){
if($_POST['mod']=='yes'){
$sql="UPDATE myfgro SET name='{$_POST['groname']}',xuhao='{$_POST['groxuhao']}' WHERE id='{$_GET['id']}'";
   $result = mysql_query($sql);
	if($result && mysql_affected_rows()>0){
	echo "<div class=\"tip\">修改成功</div>";
    }else{
    echo "<div class=\"tip\">修改失败</div>";
    }
   }
   echo '<form method="post" action="?type=mod&id='.$_GET['id'].'&">';
   echo '<input value="'.$name.'" type="text" name="groname"><br>';
   echo '<input value="'.$name.'" type="text" name="groxuhao"><br>';
   echo '<input value="yes" type="hidden" name="mod">';
   echo '<input type="submit" value="提交修改"><br>';
   echo '</form>';
}elseif($type=='add'){
    if($_POST['add']=='yes'){
	if($_POST['groname']!=NULL){
	$xuhao = myflistadmin2($id,$siteid)+1;
    $content = htmlspecialchars($_POST['groname'], ENT_QUOTES); 
	$add_sql="INSERT INTO myfgro(name,xuhao,userid,siteid)VALUES
	('{$content}','{$xuhao}','{$id}','{$wapid}')";
	$article=mysql_query($add_sql);
    if($article && mysql_affected_rows()>0){
	   echo '<div class="tip">添加分组成功</div>';
	  }else{
	     echo '<div class="tip">添加分组失败</div>';
	    }
	  }else{
	  echo '<div class="tip">分组名称不能为空</div>';
	  }
	  }
	  require "view/add.view.php";
      echo '<div class="mylink"><a href="?sid='.$sid_info.'">分组管理</a>';
      echo '<br><a href="myfirend.php?sid='.$sid_info.'">我的好友</a></div>';


}else{
echo '<table class="top_nav_bar" border="0" cellpadding="0" cellspacing="0"><tr><td class="left"><a href="myfriend.php?">返回</a></td><td class="center" style="text-align:center">分组管理</td><td class="right"><a href="?type=add">添加</a></td></tr></table></div>';
echo myflistadmin($id,$wapid);
}
echo '</body></html>';



?>