<?php
/*
	[CYASK] (C)2009 Cyask.com
	Revision: 3.2
	Date: 2009-1-19
	Author: zhaoshunyao
	QQ: 240508015
*/

if(!defined('IN_CYASK'))
{
        exit('Access Denied');
}
if(!$admin_login)
{
	header("location:admin.php?admin_action=login&backaction=$_GET[admin_action]");
}
if($_GET['admin_action']=='collect_list')
{
	if(!$_GET['page']) $_GET['page']=1;
	$pagerow=20;
	if($_GET['sortname'] && $_GET['username'])
	{
		$query=$dblink->query("SELECT count(*) FROM {$tablepre}collect WHERE username='$_GET[username]' AND sortname='$_GET[sortname]'"); 
		$qcount=$dblink->result($query,0);
		$pagecount=ceil($qcount/$pagerow);
		if ($_GET['page']>$pagecount) $_GET['page']=1;
		$start=($_GET['page']-1)*$pagerow;
		$query=$dblink->query("SELECT * FROM {$tablepre}collect WHERE username='$_GET[username]' AND sortname='$_GET[sortname]' ORDER BY collecttime desc limit $start,$pagerow");
	}
	else
	{
		$query=$dblink->query("SELECT count(*) FROM {$tablepre}collect"); 
		$qcount=$dblink->result($query,0);
		$pagecount=ceil($qcount/$pagerow);
		if ($_GET['page']>$pagecount) $_GET['page']=1;
		$start=($_GET['page']-1)*$pagerow;
		$query=$dblink->query("SELECT * FROM {$tablepre}collect ORDER BY collecttime desc limit $start,$pagerow");
	}
	admin_header();
?>
<script type="text/JavaScript">
function disQstate(s)
{ 
	switch (s)
	{
		case 0:var op="<font color=#8b0000>私藏</font>";break;
		case 1:var op="<font color=#006400>共享</font>";break;
		default: var op="未知";
	}
	document.write(op);
}
function disCtype(s)
{ 
	switch (s)
	{
		case 1:var op="<font color=#8b0000>问题收藏</font>";break;
		case 2:var op="<font color=#006400>网址收藏</font>";break;
		default: var op="未知";
	}
	document.write(op);
}
</script>
<table cellspacing="1" cellpadding="0" width="800" align="center" class="tableborder">
<tr><td>
	<table border="0" cellspacing="0" cellpadding="4" width="100%">
	<tr class="header"><td height=23>用户收藏&nbsp;(<?php echo $qcount;?>)</td></tr>
	<tr bgcolor="#f8f8f8"><td>
		<table border="1" bordercolor="#cccccc" cellspacing="0" cellpadding="0" width="100%">
		<tr bgcolor="#f8f8f8">
		<td width=400 height=26 align=center>标题</td>
		<td width=100 align=center>用户名</td>
		<td width=100 align=center>收藏类别</td>
		<td width=50 align=center>属性</td>
		<td width=100 align=center>收藏时间</td>
		<td width=50 align=center>删除</td>
		</tr>
		<?php
		while($row=$dblink->fetch_array($query))
		{
		?>
		<tr bgcolor="#ffffff">
		<td width=400 height=26 align=left><a href="#" title="<?php echo $row['title'];?>"><?php echo $row['title'];?></a></td>
		<td width=100 align=center><a href="member.php?username=<?php echo $row['username'];?>" target="_blank"><?php echo $row['username'];?></a></td>
		<td width=100 align=center><script language="JavaScript">disCtype(<?php echo $row['ctype'];?>);</script></td>
		<td width=50 align=center><script language="JavaScript">disQstate(<?php echo $row['public'];?>);</script></td>
		<td width=100 align=center><?php echo date("y-m-d H",$row['collecttime']);?></td>
		<td width=50 align=center><a href="admin.php?admin_action=collect_del&id=<?php echo $row['id'];?>&backaction=<?php echo $_GET['admin_action'];?>&page=<?php echo $_GET['page'];?>" onclick="if( !deleteit() ) return false;">删除</a></td>
		</tr>
		<?php
		}
		?>
		<tr bgcolor="#F8F8F8" height=30><td colspan="6" align="center">
		<font color="#000080">第<?php echo $_GET[page];?>页/共<?php echo $pagecount;?>页</font>
		<a href="admin.php?admin_action=<?php echo $admin_action;?>&page=1">首页</a>
       <?php
		if($pagecount>1)
		{
			$start = floor($_GET['page']/10)*10;
			$end = $start+9;
			if($start<1)
			{
				$start=1;
			}
			if($end>$pagecount)
			{
				$end=$pagecount;
			}
			for($i=$start; $i<=$end; $i++)
			{
				if($_GET['page']==$i)
				{
					echo '&nbsp;<font color=red>'.$i.'</font>';
				}
				else
				{
					echo '<a href="admin.php?admin_action='.$admin_action.'&page='.$i.'">&nbsp;['.$i.']</a>';          
				}
			}
		}
	 ?>                                                                                                                                                                                                                                                                                                                                                                                                               
     <a href="admin.php?admin_action=<?php echo $admin_action;?>&page=<?php echo $pagecount;?>">尾页</a>
		</td></tr>
		</table>
	</td></tr>
	</table>
</td></tr>
</table>
<?php
	admin_footer();
	exit();
}
elseif($_GET['admin_action']=='collect_share')
{
	if(!$_GET['page']) $_GET['page']=1;
	$pagerow=20;
	
	$query=$dblink->query("SELECT count(*) FROM {$tablepre}collect WHERE public=1"); 
	$collectcount=$dblink->result($query,0);
	$pagecount=ceil($collectcount/$pagerow);
	if ($_GET['page']>$pagecount) $_GET['page']=1;
	$start=($_GET['page']-1)*$pagerow;
	$query=$dblink->query("SELECT * FROM {$tablepre}collect WHERE public=1 ORDER BY collecttime desc limit $start,$pagerow");

	admin_header();
?>
<script type="text/JavaScript">
function disQstate(s)
{ 
	switch (s)
	{
		case 0:var op="<font color=#8b0000>私藏</font>";break;
		case 1:var op="<font color=#006400>共享</font>";break;
		default: var op="未知";
	}
	document.write(op);
}
function disCtype(s)
{ 
	switch (s)
	{
		case 1:var op="<font color=#8b0000>问题收藏</font>";break;
		case 2:var op="<font color=#006400>网址收藏</font>";break;
		default: var op="未知";
	}
	document.write(op);
}
</script>
<table cellspacing="1" cellpadding="0" width="800" align="center" class="tableborder">
<tr><td>
	<table border="0" cellspacing="0" cellpadding="4" width="100%">
	<tr class="header"><td height=23>共享收藏&nbsp;(<?php echo $collectcount;?>)</td></tr>
	<tr bgcolor="#f8f8f8"><td>
		<table border="1" bordercolor="#cccccc" cellspacing="0" cellpadding="0" width="100%">
		<tr bgcolor="#f8f8f8">
		<td width=400 height=26 align=center>标题</td>
		<td width=100 align=center>用户名</td>
		<td width=100 align=center>收藏类别</td>
		<td width=50 align=center>属性</td>
		<td width=100 align=center>收藏时间</td>
		<td width=50 align=center>删除</td>
		</tr>
		<?php
		while($row=$dblink->fetch_array($query))
		{
		?>
		<tr bgcolor="#ffffff">
		<td width=400 height=26 align=left><a href="#" title="<?php echo $row['title'];?>"><?php echo $row['title'];?></a></td>
		<td width=100 align=center><a href="member.php?username=<?php echo $row['username'];?>" target="_blank"><?php echo $row['username'];?></a></td>
		<td width=100 align=center><script language="JavaScript">disCtype(<?php echo $row['ctype'];?>);</script></td>
		<td width=50 align=center><script language="JavaScript">disQstate(<?php echo $row['public'];?>);</script></td>
		<td width=100 align=center><?php echo date("y-m-d H",$row['collecttime']);?></td>
		<td width=50 align=center><a href="admin.php?admin_action=collect_del&id=<?php echo $row['id'];?>&backaction=<?php echo $_GET['admin_action'];?>&page=<?php echo $_GET['page'];?>" onclick="if( !deleteit() ) return false;">删除</a></td>
		</tr>
		<?php
		}
		?>
		<tr bgcolor="#F8F8F8" height=30><td colspan="6" align="center">
		<font color="#000080">第<?php echo $_GET[page];?>页/共<?php echo $pagecount;?>页</font>
		<a href="admin.php?admin_action=<?php echo $admin_action;?>&page=1">首页</a>
       <?php
		if($pagecount>1)
		{
			$start = floor($_GET['page']/10)*10;
			$end = $start+9;
			if($start<1)
			{
				$start=1;
			}
			if($end>$pagecount)
			{
				$end=$pagecount;
			}
			for($i=$start; $i<=$end; $i++)
			{
				if($_GET['page']==$i)
				{
					echo '&nbsp;<font color=red>'.$i.'</font>';
				}
				else
				{
					echo '<a href="admin.php?admin_action='.$admin_action.'&page='.$i.'">&nbsp;['.$i.']</a>';          
				}
			}
		}
	 ?>                                                                                                                                                                                                                                                                                                                                                                                                               
     <a href="admin.php?admin_action=<?php echo $admin_action;?>&page=<?php echo $pagecount;?>">尾页</a>
		</td></tr>
		</table>
	</td></tr>
	</table>
</td></tr>
</table>
<?php
	admin_footer();
	exit();
}
elseif($_GET['admin_action']=='collect_hidden')
{
	if(!$_GET['page']) $_GET['page']=1;
	$pagerow=20;
	
	$query=$dblink->query("SELECT count(*) FROM {$tablepre}collect WHERE public=0"); 
	$collectcount=$dblink->result($query,0);
	$pagecount=ceil($collectcount/$pagerow);
	if ($_GET['page']>$pagecount) $_GET['page']=1;
	$start=($_GET['page']-1)*$pagerow;
	$query=$dblink->query("SELECT * FROM {$tablepre}collect WHERE public=0 ORDER BY collecttime desc limit $start,$pagerow");

	admin_header();
?>
<script type="text/JavaScript">
function disQstate(s)
{ 
	switch (s)
	{
		case 0:var op="<font color=#8b0000>私藏</font>";break;
		case 1:var op="<font color=#006400>共享</font>";break;
		default: var op="未知";
	}
	document.write(op);
}
function disCtype(s)
{ 
	switch (s)
	{
		case 1:var op="<font color=#8b0000>问题收藏</font>";break;
		case 2:var op="<font color=#006400>网址收藏</font>";break;
		default: var op="未知";
	}
	document.write(op);
}
</script>
<table cellspacing="1" cellpadding="0" width="800" align="center" class="tableborder">
<tr><td>
	<table border="0" cellspacing="0" cellpadding="4" width="100%">
	<tr class="header"><td height=23>私有收藏&nbsp;(<?php echo $collectcount;?>)</td></tr>
	<tr bgcolor="#f8f8f8"><td>
		<table border="1" bordercolor="#cccccc" cellspacing="0" cellpadding="0" width="100%">
		<tr bgcolor="#f8f8f8">
		<td width=400 height=26 align=center>标题</td>
		<td width=100 align=center>用户名</td>
		<td width=100 align=center>收藏类别</td>
		<td width=50 align=center>属性</td>
		<td width=100 align=center>收藏时间</td>
		<td width=50 align=center>删除</td>
		</tr>
		<?php
		while($row=$dblink->fetch_array($query))
		{
		?>
		<tr bgcolor="#ffffff">
		<td width=400 height=26 align=left><a href="#" title="<?php echo $row['title'];?>"><?php echo $row['title'];?></a></td>
		<td width=100 align=center><a href="member.php?username=<?php echo $row['username'];?>" target="_blank"><?php echo $row['username'];?></a></td>
		<td width=100 align=center><script language="JavaScript">disCtype(<?php echo $row['ctype'];?>);</script></td>
		<td width=50 align=center><script language="JavaScript">disQstate(<?php echo $row['public'];?>);</script></td>
		<td width=100 align=center><?php echo date("y-m-d H",$row['collecttime']);?></td>
		<td width=50 align=center><a href="admin.php?admin_action=collect_del&id=<?php echo $row['id'];?>&backaction=<?php echo $_GET['admin_action'];?>&page=<?php echo $_GET['page'];?>" onclick="if( !deleteit() ) return false;">删除</a></td>
		</tr>
		<?php
		}
		?>
		<tr bgcolor="#F8F8F8" height=30><td colspan="6" align="center">
		<font color="#000080">第<?php echo $_GET[page];?>页/共<?php echo $pagecount;?>页</font>
		<a href="admin.php?admin_action=<?php echo $admin_action;?>&page=1">首页</a>
       <?php
		if($pagecount>1)
		{
			$start = floor($_GET['page']/10)*10;
			$end = $start+9;
			if($start<1)
			{
				$start=1;
			}
			if($end>$pagecount)
			{
				$end=$pagecount;
			}
			for($i=$start; $i<=$end; $i++)
			{
				if($_GET['page']==$i)
				{
					echo '&nbsp;<font color=red>'.$i.'</font>';
				}
				else
				{
					echo '<a href="admin.php?admin_action='.$admin_action.'&page='.$i.'">&nbsp;['.$i.']</a>';          
				}
			}
		}
	 ?>                                                                                                                                                                                                                                                                                                                                                                                                               
     <a href="admin.php?admin_action=<?php echo $admin_action;?>&page=<?php echo $pagecount;?>">尾页</a>
		</td></tr>
		</table>
	</td></tr>
	</table>
</td></tr>
</table>
<?php
	admin_footer();
	exit();
}
elseif($admin_action=='collect_edit_submit')
{
	$dblink->query("UPDATE {$tablepre}collect SET tag='$_GET[tag]',orderid='$_GET[orderid]' WHERE tid='$_GET[tid]'");
	header("location:admin.php?admin_action=collect_sort");
}
elseif($admin_action=='collect_del')
{
	$dblink->query("DELETE FROM $tablepre"."collect WHERE id=$_GET[id]");	
	header("location:admin.php?admin_action=collect_list");
}
else
{
	echo 'collect manage error';
}
?>
