<?php
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");

$userid=intval(get_cookie('clubuser_id'));
$ftblog_old=ftbbs_request($_POST["ftblog_old"]);
$ftblog=ftbbs_request($_POST["ftblog"]);
$nav=$_GET["nav"];
$userip=GetUserIP();
if ($nav=="b"){
   $blogphoto=0;
   $n="博客分类";
}
else{
   $blogphoto=1;
   $n="相册";
}

if ($ftblog_old!=""){
   $sql="update {$tablepre}ftblog_type set blogtype='".$ftblog."' where blogtype='".$ftblog_old."' and blogphoto=".$blogphoto;
   mysql_query($sql);
   $sql="update {$tablepre}ftbbs_upload set photo_name='".$ftblog."' where photo_name='".$ftblog_old."' and clubuser_id=".$userid;
   mysql_query($sql);
}

if ($_POST["act"]=="y"){
   if ($ftblog==""){
   	   echo "<SCRIPT language=JavaScript>alert('分类不能为空！');history.go(-1);</script>" ;       
       exit;
   }
   $sql="select * from {$tablepre}ftblog_type where blogtype='".$ftblog."' and userid=".$userid." and blogphoto=".$blogphoto." order by id desc";
   $rs=mysql_query($sql);
   $myrow = mysql_fetch_array($rs);
   $numrows = mysql_num_rows($rs);
   if ($numrows==0){
   $str="insert into {$tablepre}ftblog_type(userid,blogtype,blogphoto,qs,userip) values('".$userid."','".$ftblog."','".$blogphoto."',0,'".$userip."')";
   mysql_query($str);
   }
   else{
	echo "<SCRIPT language=JavaScript>alert('你添加的分类已存在！');history.go(-1);</script>";       
    exit;
   }
}
include_once("memberinfo.php");
?>
<html><head><meta http-equiv=content-type content="text/html; charset=utf-8>">
<title><?=$username?>的日志管理中心</title>
<link rel="stylesheet" type="text/css" href="<?=$cssfile?>">
</head>
<script language="javascript" src="js/publicfun.js"></script>
<body>
<center>
<?
include_once("usernav.php");
if ($nav=="b"){
include_once("bokerhead.php");
}
elseif ($nav=="a"){
include_once("photohead.php");
}
?>
<div class="stage">
<table width="100%" border="0" cellspacing="0" cellpadding="0" id="layout">
<tr>
<td valign="top" class="c2t3">
<div id="mod_profile" class="mod" rel="drag">
<?
include_once("usercalog.php");
?>
</div>
</td>
<td valign="top" class="c2t1">
<div id="m_blog" class="modbox">
              <table width="100%"  border="0" cellspacing="0" cellpadding="0">
<form name="form1" method=post action="" onsubmit="return chkForm(this)">                
<tr valign="top"> 
                  <td height="50" colspan="5" class=new14 valign="middle"> 
                    <div align="left">
                      
                        &nbsp;请输入你的<?=$n?>名称: 
                        <input name="ftblog" type="text" class="text" />
                        <input name="Submit" type="Submit" class="button" value="创建<?=$n?>" />
                        <input name="act" type="Hidden" id="act2" value="y">
						<input name="nav" type="Hidden" value=<?=$nav?>>
						<input name="blogphoto" type="Hidden" value=<?=$blogphoto?>>
                      
                    </div></td>
                </tr>
</form>
                <tr> 
                  <td height="1" colspan="5" bgcolor="#336699" class=new14><spacer height="1" type="block"></td>
                </tr>
                <tr id="t1"  style="display:none"> 
                  <td height="25" colspan="5" class=new14> <fieldset>
                    <legend>修改“<span id="oldgroupname" style="color:red"></span>”<?=$n?>名称:</legend>
                    <table width="100%"  border="0" align="center" cellpadding="3" cellspacing="1">
                      <tr> 
                        <td colspan="2"><form name="form2" method=post action="" onsubmit="return chkForm(this)">
                            <div align="center"> 
                              <input name="ftblog" type="text" class="text" id="ftblog" />
                              <input name="Submit" type="submit" class="button" value="修 改" />
                              <input name="cannel" type="reset" id="cannel" value="取 消" class="button" onclick="closechk()">
                              <input type="Hidden" name="ftblog_old">
							  <input name="nav" type="Hidden" value=<%=nav%>>
                              (注意:只能是中文,英文或数字) </div>
                          </form></td>
                      </tr>
                    </table>
                    </fieldset></td>
                </tr>
                <tr> 
                  <td width="57%" height="25"> <div align="left"><strong>&nbsp;<?=$n?>名称</strong></div></td>
                  <td width="12%">
<div align="center">改名</div></td>
                  <td width="19%">
<div align="center">权限</div></td>
                  <td width="12%"><div align="center">删除</div></td>
                </tr>
                <tr> 
                  <td height="1" colspan="5" background="blogimages/dotbg.gif"><spacer height="1" type="block"></td>
                </tr>
<?
$sql="select * from {$tablepre}ftblog_type where userid=".$userid." and blogphoto=".$blogphoto." order by indate desc";
$rsx=mysql_query($sql);
$row = mysql_fetch_array($rsx);
$numrows = mysql_num_rows($rsx);
if ($numrows!=0){
do{
   $sign=$row["sign"];
   if ($nav=="a"){
   $url="<a href=photomanage.php?id=".$row["id"]."&photo_name=".$row["blogtype"].">".$row["blogtype"]."</a>";
   }else{
   $url="<a href=blogcenter.php?blogtypeid=".$row["id"].">".$row["blogtype"]."</a>";
   }		  
?>
                <tr> 
                  <td height="25"><div class="opt">&nbsp;<?=$url?></div></td>
                  <td height="25" align="center"><div class="opt"><a href="#" onclick="chk('<?=$row["blogtype"]?>')">改名</a></div></td>
                  <td height="25" align="center">
				  <div class="opt">
				  <? if ($nav=="b"){?>
				  <? if ($sign==1){?><a href="op.php?id=<?=$row["id"]?>&sign=0&act=qs&photo_name=<?=$row["blogtype"]?>&nav=<?=$nav?>"><font color=red>隐藏</font></a><? }else{?><a href="op.php?id=<?=$row["id"]?>&sign=1&act=qs&photo_name=<?=$row["blogtype"]?>&nav=<?=$nav?>">显示</a><? }?></a>
				  <? }else{?>
				  <a href="op.php?id=<?=$row["id"]?>&sign=0&act=qs&photo_name=<?=$row["blogtype"]?>&nav=<?=$nav?>"><? if ($sign==0){?><font color=red>公开</font><? }else{?>公开<? }?></a>
				  <a href="op.php?id=<?=$row["id"]?>&sign=1&act=qs&photo_name=<?=$row["blogtype"]?>&nav=<?=$nav?>"><? if ($sign==1){?><font color=red>隐藏</font><? }else{?>隐藏<? }?></a>
				  <a onClick=pwd('<?=$row["id"]?>','<?=$userid?>','<?=$row["blogtype"]?>') href="#"><? if ($sign==2){?><font color=red>已加密</font><? }else{?>未加密<? }?></a>				  
				  <? }?>
				  </div></td>
                  <td height="25" align="center"><div class="opt"><a href="op.php?id=<?=$row["id"]?>&act=del&nav=<?=$nav?>">删除</a></div></td>
                </tr>
                <tr> 
                  <td height="1" colspan="5" background="../blogimages/dotbg.gif"><spacer height="1" type="block"></td>
                </tr>
<?
   }
   while ($row = mysql_fetch_array($rsx));
}
?>
              </table>
              <br>
            </div>
</td>
</tr></table>
</div>
</div>
<br><center>
<?
include_once("tail.php");
?>
  </center>
</center>
</body>
</html>