<?php
	session_start(); 
	require_once('../../../../ru/update/2.55/ls_admin/inc/conn.php');
	require_once('../../../../ru/update/2.55/ls_admin/inc/constant.php');
	require_once('../../../../ru/update/2.55/ls_admin/inc/ls_syscode.php');
	require_once('../../../../ru/update/2.55/ls_admin/inc/check.php');
	$opendb=new mydb();
	$opertb=new mytb();
	require_once('../../../../ru/update/2.55/ls_admin/inc/char_set.php');

	$nowNum=$_GET['nowNum'];
	$selectcate=$_GET['selectcate'];
	
	if ($_GET['ls_msg']=="")
	{
		$ls_msg="下载管理操作";
	}	
	else
	{
		$ls_msg=$_GET['ls_msg'];	
	}
		$ls=$_GET['ls'];
		$id=$_GET['id'];
		
	$opertb->table="ls_download";
	$opertb->id=$id;
	switch ($ls)
	{
		case "up":
			$ls_msg=$opertb->up($nowNum);
			break;

		case "down":
			$ls_msg=$opertb->down($nowNum);
			break;
			
	 	case "unenable":
			$ls_msg=$opertb->unenable();
			break; 
			
		case "enable":
			$ls_msg=$opertb->enable();
			break;
			
		case "del":
			$ls_msg=$opertb->delwfile($downloadFolders,"","downloadName");
			break;

	}
	               
			$download_sql="SELECT distinct(cateName) FROM ls_download  where enable=1  and cateName!='' order by cateName asc";//count the error by searchtype
			$download_query=$opendb->query($download_sql);
			//$news_rows2=mysql_fetch_assoc($download_query);
			//if($selectcate=="" ){$selectcate="";}
			/*{$selectcate=$news_rows2['functionName'];}  //如果不存在 $selectcate 就选第一个
			$download_query=$opendb->query($download_sql);  //返回第一条记录 */
			

			?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<link href="../../../../ru/update/2.55/ls_admin/css/admin.css" rel="stylesheet" type="text/css">
		<script language="JavaScript" src="../../../../ru/update/2.55/ls_admin/js/ls.js"></script>
		<title>无标题文档</title>
	</head>
 <body>
	<table width="96%" border="0" align="center" cellpadding="1" cellspacing="1" bgcolor="#6396d6">
			<tr>
				<td height="18" background="../../../../ru/update/2.55/ls_admin/images/admin_bg.gif"><div align="center"><font color="#ffffff"><strong>下载管理</strong></font></div>
				</td>
			</tr>
			<tr>
				<td height="213" valign="top" bgcolor="#dee7ff"><br>
					<form name="del" method="Post" action="../../../../ru/update/2.55/ls_admin/delall.php?&amp;selectcate=<?=$selectcate?>" onSubmit="return ConfirmDel();">
					<table border="0" width="90%" align="center">
						<tr>
							<td style="border-bottom:1px solid #FFF;">提示：<font color="#FF0000"><?php echo $ls_msg; ?></font></td>
							<td align="right" style="border-bottom:1px solid #FFF;">&nbsp;</td>
						</tr>
					</table><br>
					<?php
					// 获取当前页数
							if( isset($_GET['page']) ){
							   $page = intval( $_GET['page'] );
							}
							else{
							   $page = 1;
							}
							// 每页数量
							$PageSize = $PageNum;
							
							// 获取总数据量
							/********************************************************************************/
							
								$sql = "select * from ls_download where cateName='$selectcate' order by Num desc";
								$result=$opendb->query($sql);
							
							/********************************************************************************/
							// 获取总数据量
							
							$row = mysql_num_rows($result);
							$amount = $row;
							
							// 记算总共有多少页
							if( $amount ){
							   if( $amount < $PageSize ){ $page_count = 1; }			   //如果总数据量小于$PageSize，那么只有一页
							   if( $amount % $PageSize ){								  //取总数据量除以每页数的余数
								   $page_count = (int)($amount / $PageSize) + 1;		   //如果有余数，则页数等于总数据量除以每页数的结果取整再加一
							   }else{
								   $page_count = $amount / $PageSize;					  //如果没有余数，则页数等于总数据量除以每页数的结果
							   }
							}
							else{
							   $page_count = 0;
							}
							
							// 翻页链接
							$page_string = '';
								
							if( $page == 1 ){
							   $page_string .= '首页 | 上一页 |';
							}
							else{
							   $page_string .= '<a href=?page=1><u><font color=\"#0000FF\">首页</font></u></a> | <a href=?page='.($page-1).'><u><font color=\"#0000FF\">上一页</font></u></a> | ';
							}
							if( ($page == $page_count) || ($page_count == 0) ){
							   $page_string .= ' 下一页 | 尾页';
							}
							else{
							   $page_string .= ' <a href=?page='.($page+1).'><u><font color=\"#0000FF\">下一页</font></u></a> | <a href=?page='.$page_count.'><u><font color=\"#0000FF\">尾页</font></u></a>';
							}
								 $page_string .= " &nbsp;&nbsp;页次：<font color='#FF0000'><b>".$page."</b></font>/<b>".$page_count."</b>页";
								 $page_string .= " &nbsp;&nbsp;<b>".$PageSize."</b>个下载每页";
								 
							$ls_msg2="下载管理 >> 所有下载";
					?>
				<table border="0" width="90%" align="center">


						<tr>
						  <td>
                          
                           <?
						   if($selectcate=="")
								{echo "<a href='?selectcate=".$selectcate."'><span style=\"color:#930\" >无分类</span></a> | ";}
								else
								{echo "<a href='?selectcate='><span style=\"\" >无分类</span></a> | ";}
								
                          while($news_rows2=mysql_fetch_assoc($download_query))
		  					{
								if($selectcate==$news_rows2['cateName'])
								{echo "<a href='?selectcate=".$news_rows2['cateName']."'><span style=\"color:#930\" >".$news_rows2['cateName']."</span></a> | ";}
								else
								{echo "<a href='?selectcate=".$news_rows2['cateName']."'>".$news_rows2['cateName']."</a> | ";}
								
							}
						  ?>
                          </td>
						  <td><span style="border-bottom:1px solid #FFF;"><img src="../../../../ru/update/2.55/ls_admin/images/shao.gif" />&nbsp;<a href="../../../../ru/update/2.55/ls_admin/adddownload.php?selectcate=<?=$selectcate?>"><u>添加下载</u></a></span></td>
		          </tr>
						<tr>
							<td width="92%"><?php echo $ls_msg2; ?></td>
							<td width="8%" align="right">共 <b><?php echo $row; ?></b> 个</td>
						</tr>
					 </table>
					 <table width="90%" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
						<tr bgcolor="#B9DAFF">
							<td align="center" height="35" width="25">选中</td>
							<td align="center" width="111">类别</td>
							<td align="center" width="477">标题</td>
							<td align="center" width="59">大小</td>
							<td align="center" colspan="2">排序</td>
							<td align="center" colspan="2">操作</td>
							<td align="center" width="77">允许</td>
						</tr>
						<?php
							$news_sql="select * from ls_download where cateName='$selectcate' order by Num desc limit ". ($page-1)*$PageSize .",".$PageSize." ";	
							$news_query=$opendb->query($news_sql);
							$news_nums=mysql_num_rows($news_query); 
						
							$i=1;
							while($news_rows=mysql_fetch_assoc($news_query))
										 			 {
							?>
							<tr bgcolor='#f4f4f4'
												onMouseOver=
							 	this.style.backgroundColor='#CCFFCC' 
							onMouseOut=
							 	this.style.backgroundColor='#f4f4f4' 
							>
								<td align='center'>
									<input name='select_id<?=$i?>' type='checkbox' onclick="unselectall()" id="select_id" value='<?=$news_rows['ID']?>'>
								</td>
								<td style='padding-left:10px;'><?=$news_rows['cateName']?></td>
								<td style='padding-left:10px;'>
                                <?
								$name=substr($news_rows['downloadName'],-3);
							//echo $name;
							switch ($name)
							{
								case "doc":
									echo "<a href=\"../".$downloadFolders."/".$news_rows['downloadName']."\" title=\"查看\">";
									echo "<img src='images/doc.gif' border='0'>";
									echo "</a>";
									break;
								case "xls":
									echo "<a href=\"../".$downloadFolders."/".$news_rows['downloadName']."\" title=\"查看\">";
									echo "<img src='images/xls.gif' border='0'>";
									echo "</a>";
									break;
								case "rar":
									echo "<a href=\"../".$downloadFolders."/".$news_rows['downloadName']."\" title=\"查看\" >";
									echo "<img src='images/rar.gif' border='0'>";
									echo "</a>";
									break;
							}	
							 echo 		$news_rows['downloadTitle'];
							 ?>
								</td>
									<td style='padding-left:10px;'>
									 <?=$news_rows['downloadSize']?>
									K </td>
								<td width="17" align='center'> 												   												 												<? if($i!=1)
							{  ?>
									<a href='../../../../ru/update/2.55/ls_admin/?page=<?=$page?>&amp;id=<?=$news_rows['ID']?>&amp;nowNum=<?=$news_rows['Num']?>&amp;ls=up&amp;selectcate=<?=$selectcate?>' title='向上移动'><img src='../../../../ru/update/2.55/ls_admin/images/up.gif' border='0'></a>		
                                                            
                                <?	} ?>
							  </td>
								<td width="17" align='center'> 
								<?	 if($i!=$news_nums)
							{  ?>
								<a href='../../../../ru/update/2.55/ls_admin/?page=<?=$page?>&amp;id=<?=$news_rows['ID']?>&amp;nowNum=<?=$news_rows['Num']?>&amp;ls=down&amp;selectcate=<?=$selectcate?>' title='向下移动'><img src='../../../../ru/update/2.55/ls_admin/images/down.gif' border='0'></a>	  
								<?	}  ?>
							  </td>												
									<td width="16" align='center'> 
									<a href='../../../../ru/update/2.55/ls_admin/modidownload.php?page=<?=$page?>&amp;id=<?=$news_rows['ID']?>&amp;selectcate=<?=$selectcate?>' title='编辑'><img src='../../../../ru/update/2.55/ls_admin/images/b_edit.png' border='0'></a>
							  </td>
								<td width="16" align='center'> 
									<a href='../../../../ru/update/2.55/ls_admin/?page=<?=$page?>&amp;id=<?=$news_rows['ID']?>&amp;ls=del&amp;?selectcate=<?=$selectcate?>' onclick='return ConfirmDelSubCate();' title='删除'><img src='../../../../ru/update/2.55/ls_admin/images/b_drop.png' border='0'></a>
							  </td>
								<td align='center'>
											  		<? 
							  if($news_rows['enable']==1)
								{
									echo "<a href='?page=$page&id=".$news_rows['ID']."&ls=unenable&selectcate=".$selectcate."' title='显示'><img src='images/enable.gif' border='0'></a>";
								}
							  if($news_rows['enable']==0)
							  	{
									echo "<a href='?page=$page&id=".$news_rows['ID']."&ls=enable&selectcate=".$selectcate."' title='不显示'><img src='images/unenable.gif' border='0'></a>";
								}
								?>				
								</td>
								 </tr>
								<?  
								 $i++;
								 }
								 ?>
									<tr bgcolor="#B9DAFF">
									<td colspan='9' align='center' height='25'>
									<?=$page_string?>
									  </td>
									 </tr>
					
					</table>
					<br>
					<table width="90%" border="0" align="center" cellpadding="3" cellspacing="1" >
					<tr >
							<td height="30" colspan="8" style="padding-left:6px;">
								<input name="chkAll" type="checkbox" id="chkAll" onclick=CheckAll(this.form) value="checkbox"> 
								选中所有下载 
							  <input name="submit" type='submit' value='删除选定的下载'>
								<input name="Action" type="hidden" id="Action" value="downDel">
							  </td>
						</tr>
					</table>
					<br />
                  </form>
				</td>
			</tr>
	</table>
 </body>
</html>