<?php
	require_once('inc/conn.php');
	require_once('inc/constant.php');
	require_once('inc/ls_syscode.php');
	$opendb=new mydb();
	$opertb=new mytb();
	$Action=$_POST['Action'];
	require_once('generalpicrequire.php');  //通用图片文件开关语句

	switch ($Action){
		case "proDel":	//删除产品
				for($i=1;$i<$PageNum; $i++){			
					$id=$_POST['selectid'.$i];
					if ($id!=""){
						//获取文件目录
						$cate_sql="select productID from ls_products where ID=".$id." "; 
						$cate_sql="select subcateID from ls_products where ID=(".$cate_sql.")";
						$cate_sql="select midcateID  from ls_products where ID=(".$cate_sql.")";
						$cate_sql="select * from ls_products where ID=(".$cate_sql.")";
						$cate_query=$opendb->query($cate_sql);
						$cate_myrows=mysql_fetch_assoc($cate_query);
						$pathFoldersProducts="../".$cate_myrows['cateFolders'];
						
						$midcate_sql="select productID from ls_products where ID=".$id." "; 
						$midcate_sql="select subcateID from ls_products where ID=(".$midcate_sql.")";
						$midcate_sql="select * from ls_products where ID=(".$midcate_sql.")";
						$midcate_query=$opendb->query($midcate_sql);
						$midcate_myrows=mysql_fetch_assoc($midcate_query);
						$pathFoldersProducts=$pathFoldersProducts."/".$midcate_myrows['midcateFolders'];
						
						$subcate_sql="select productID from ls_products where ID=".$id." "; 
						$subcate_sql="select * from ls_products where ID=(".$subcate_sql.")";
						$subcate_query=$opendb->query($subcate_sql);
						$subcate_myrows=mysql_fetch_assoc($subcate_query);
						$pathFoldersProducts=$pathFoldersProducts."/".$subcate_myrows['subcateFolders'];
						
						$products_sql="select * from ls_products where ID=".$id." ";
						$products_query=$opendb->query($products_sql);
						$products_rows=mysql_fetch_assoc($products_query);
						
						$Bigpicsrc=$pathFoldersProducts."/".$BigFoldersProducts."/".$products_rows['productPic'];
						$Smallpicsrc=$pathFoldersProducts."/".$SmallFoldersProducts."/".$products_rows['productPic'];
						$Bigpicsrc1=$pathFoldersProducts."/".$BigFoldersProducts;
						$Smallpicsrc1=$pathFoldersProducts."/".$SmallFoldersProducts;
						
						//删除文件
						//echo $Bigpicsrc."<br>".$Smallpicsrc."<br>";
						unlink($Bigpicsrc);
						unlink($Smallpicsrc);
						rmdir($Bigpicsrc1);
						rmdir($Smallpicsrc1);
						$del_sql="delete from ls_products where ID=".$id;
						$del_query=$opendb->query($del_sql);
					}
					echo "<script>location='products.php';</script>";
			  }
		  break;	
		 
		 case "newsDel": //删除新闻
			  for($i=1;$i< $NewPageNum;$i++)
					{			
						$id=$_POST['select_id'.$i];
						if ($id!="")
						{
							$del_sql="delete from ls_news where ID=".$id."";
						//echo $del_sql."<br>";
						$del_query=$opendb->query($del_sql);
					}
				  echo "<script>location='news.php';</script>";
				}
				
				break;	
				
		case "blogDel": //删除博客
			  for($i=1;$i< $NewPageNum;$i++)
					{			
						$id=$_POST['select_id'.$i];
						if ($id!="")
						{
							$del_sql="delete from ls_news where ID=".$id."";
						//echo $del_sql."<br>";
						$del_query=$opendb->query($del_sql);
					}
				  echo "<script>location='blog.php';</script>";
				}
				
				break;	
				 
		 case "faqDel": //删除常见问题
			  for($i=1;$i< $NewPageNum;$i++)
					{			
						$id=$_POST['select_id'.$i];
						if ($id!="")
						{
							$del_sql="delete from ls_news where ID=".$id."";
						//echo $del_sql."<br>";
						$del_query=$opendb->query($del_sql);
					}
				  echo "<script>location='faq.php';</script>";
				}
				
				break;	
			 
			 case "articleMessage": //删除留言
				  for($i=1;$i< $PageNum;$i++)
						{			
							$id=$_POST['select_id'.$i];
							if ($id!="")
							{
						 		$del_sql="delete from ls_message where ID=".$id."";
				   			//echo $del_sql."<br>";
				   			$del_query=$opendb->query($del_sql);
				   		}
				   	  echo "<script>location='managemessage.php';</script>";
				   	}
		   			
				 	break;	
					

			 case "articleDel": //删除文章
				  for($i=1;$i< $PageNum;$i++)
						{			
							$id=$_POST['select_id'.$i];
							if ($id!="")
							{
						 		$del_sql="delete from ls_article where ID=".$id."";
				   			//echo $del_sql."<br>";
				   			$del_query=$opendb->query($del_sql);
				   		}
				   	  echo "<script>location='managearticle.php';</script>";
				   	}
		   			
				 	break;	
			 	
			 case "singleDel": //删除文章
			 
				  for($i=1;$i< $PageNum;$i++)
						{			
							$id=$_POST['select_id'.$i];
							if ($id!="")
							{
						 		$del_sql="delete from ls_singlepages where ID=".$id."";
				   			//echo $del_sql."<br>";
				   				$del_query=$opendb->query($del_sql);
				   			}
				   	  		echo "<script>location='singlepage.php';</script>";
				   	}
		   			
				 	break;	
			
			
		 case "downDel"://删除下载
		 	 $opertb->table="ls_download";
			 for($i=1;$i< $PageNum;$i++)
					{			
						$id=$_POST['select_id'.$i];
						if ($id!="")
						{
							$opertb->id=$id;
							$ls_msg=$opertb->delwfile($downloadFolders,"downloadName");
						
						}
				  echo "<script>location='download.php';</script>";
				}
				
				break;	
				
		 
		 case "motifDel"://删除车间图片
				
				for($i=1;$i< $PageNum;$i++)
				{
						$id=$_POST['select_id'.$i];
						if ($id!="")
						{
						$select_sql="select * from ls_motif where ID=".$id."";
						$select_query=$opendb->query($select_sql);
						$select_myrows=mysql_fetch_assoc($select_query);
						//获取文件目录
						$Bigpicsrc="../".$MotifFolders."/".$BigFoldersProducts."/".$select_myrows['motifPic'];
							//$Smallpicsrc="../".$MotifShopFolders."/".$SmallFoldersProducts."/".$select_myrows['workshopPic'];
							//删除文件
							unlink($Bigpicsrc);
							//unlink($Smallpicsrc);
						$del_sql="delete from ls_motif where ID=".$id."";
							//echo $del_sql;
						$del_query=$opendb->query($del_sql);
						
					}
				  echo "<script>location='motif.php';</script>";
				}
				
				break;
				
		case "divioDel"://删除车间图片
		
			$select_sql = "select * from ls_video";
			$select_query = $opendb->query($select_sql);
			while($select_value = mysql_fetch_array($select_query)){
				
				$id=$_POST['select_id'.$select_value['ID']];
				if ($id!=""){
					$update_sql=sprintf("update ls_video set videoBool=%s where ID=%s",
						GetSQLValueString(1, "int"),
						GetSQLValueString($select_value['ID'], "int")
					);
					//echo $del_sql;
				}else{
					$update_sql=sprintf("update ls_video set videoBool=%s where ID=%s",
						GetSQLValueString(0, "int"),
						GetSQLValueString($select_value['ID'], "int")
					);
				}
				$updata_query=$opendb->query($update_sql);
				
			}
			echo "<script>location='video.php';</script>";
				
			break;
		 
		 case $gen."Del"://删除车间等图片
				$opertb->table=$generalTable;
				for($i=1;$i< $PageNum;$i++)
					{			
						$id=$_POST['select_id'.$i];
						
						if ($id!="")
						{
							$opertb->id=$id;
							$ls_msg=$opertb->delwfile($folder1,$folder2,$generalpicsPic);
							
						
					}
				  echo "<script>location='generalpics.php?gen=".$gen."';</script>";
				}
				
				break;
				
			

	}
?>