
<?php
	require_once('inc/conn.php');
	require_once('inc/constant.php');
	require_once('inc/ls_syscode.php');
	$opendb=new mydb();
	$opertb=new mytb();
	//$cleartable="ls_products,ls_news,ls_message,ls_article,ls_singlepages,ls_download,ls_video";
	$gentable="workshop,certificate,quality,packing,revolvingpics,rd,brand,management,history";
	$cleartable="ls_products,ls_news,ls_message,ls_article,ls_singlepages,ls_download,ls_video";

	$Actionarr=explode(",",$cleartable);

	
	for($j=0;$j<count($Actionarr); $j++)
	{
	
	$Action=trim($Actionarr[$j]);
	//var_dump($Actionarr,$Action);
//	if(strpos($gentable ,$Action)!==false)$_GET['gen']=$Action; else $_GET['gen']="";
	
	switch ($Action){
		
		
		case "ls_products":	//删除产品
				$clear_sql="select * from ls_products where productName like '%-tt-%' ";
				$clear_query=$opendb->query($clear_sql);
				$clear_num=mysql_num_rows($clear_query);
				for($i=0;$i<$clear_num; $i++){	
					$cate_myrows=mysql_fetch_assoc($clear_query);		
					$id=$cate_myrows['ID'];
					if ($id!=""){
						//获取文件目录
						
						$products_sql="select * from ls_products where ID=".$id." ";
						$products_query=$opendb->query($products_sql);
						$products_rows=mysql_fetch_assoc($products_query);
						 
						$thisProductsFloder=getproductfolder($products_rows['productID']);
						$Bigpicsrc="../".$thisProductsFloder."/".$BigFoldersProducts."/".$products_rows['productPic'];
						$Smallpicsrc="../".$thisProductsFloder."/".$SmallFoldersProducts."/".$products_rows['productPic'];
						$Bigpicsrc1="../".$thisProductsFloder."/".$BigFoldersProducts;
						$Smallpicsrc1="../".$thisProductsFloder."/".$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 "products $clear_num 已清空 <br/>";

		  break;	
		  
		 case "ls_functioncates"://删除新闻、博客、常见问题分类
				$clear_sql="select * from ls_functioncates where cateName like '%-tt-%' ";
				$clear_query=$opendb->query($clear_sql);
				$clear_num=mysql_num_rows($clear_query);
				for($i=0;$i<$clear_num; $i++){	
					$cate_myrows=mysql_fetch_assoc($clear_query);		
					$id=$cate_myrows['ID'];	
					{
						 $del_sql="delete from ls_functioncates where ID=".$id."";
						//echo $del_sql."<br>";
						$del_query=$opendb->query($del_sql);
					}
				}
 
	
		 echo "ls_functioncates 新闻、博客、常见问题分类 $clear_num 已清空 <br/>";
		 break;

		 
		 case "ls_news": //删除新闻、常见问题、博客
				$clear_sql="select * from ls_news where newsTitle like '%-tt-%' ";
				$clear_query=$opendb->query($clear_sql);
				$clear_num=mysql_num_rows($clear_query);
				for($i=0;$i<$clear_num; $i++){	
					$cate_myrows=mysql_fetch_assoc($clear_query);		
					$id=$cate_myrows['ID'];	
					{
						 $del_sql="delete from ls_news where ID=".$id."";
						//echo $del_sql."<br>";
						$del_query=$opendb->query($del_sql);
					}
				}
 
				  echo " news 已清空 $clear_num 条  <br/>";
				
				break;	
				
 			 case "ls_article": //删除文章
				$clear_sql="select * from ls_article where articleTitle like '%-tt-%' ";
				$clear_query=$opendb->query($clear_sql);
				$clear_num=mysql_num_rows($clear_query);
				for($i=0;$i<$clear_num; $i++){	
					$cate_myrows=mysql_fetch_assoc($clear_query);		
					$id=$cate_myrows['ID'];	
						{
						 		$del_sql="delete from ls_article where ID=".$id."";
				   			//echo $del_sql."<br>";
				   			$del_query=$opendb->query($del_sql);
				   		}
				   	 
				   	}
				  echo " ls_article 已清空 $clear_num 条  <br/>";
		   			
				 	break;	
			 	
			 case "ls_singlepages": //删除文章
			 
				$clear_sql="select * from ls_singlepages where pageTitle like '%-tt-%' ";
				$clear_query=$opendb->query($clear_sql);
				$clear_num=mysql_num_rows($clear_query);
				for($i=0;$i<$clear_num; $i++){	
					$cate_myrows=mysql_fetch_assoc($clear_query);		
					$id=$cate_myrows['ID'];	
					{
						 		$del_sql="delete from ls_singlepages where ID=".$id."";
				   			//echo $del_sql."<br>";
				   				$del_query=$opendb->query($del_sql);
				   			}
				   	  		 
				   	}
					  echo " ls_singlepages 已清空 $clear_num 条  <br/>";
	   			
				 	break;	
			
			
		 case "ls_download"://删除下载
		 	 $opertb->table="ls_download";
				$clear_sql="select * from ls_download where downloadTitle like '%-tt-%' ";
				$clear_query=$opendb->query($clear_sql);
				$clear_num=mysql_num_rows($clear_query);
				for($i=0;$i<$clear_num; $i++){	
					$cate_myrows=mysql_fetch_assoc($clear_query);		
					$id=$cate_myrows['ID'];	
						{
							 

							$opertb->id=$id;
							$ls_msg=$opertb->delwfile($downloadFolders,"","downloadName");
						
						}
				}
				 echo " ls_download 已清空 $clear_num 条, 上传文件已删除  <br/>";
				
				break;	
				
		 
				
		case "ls_video"://删除视频 videoName
		
		 	 $opertb->table="ls_video";
				$clear_sql="select * from ls_video where videoName like '%-tt-%' ";
				$clear_query=$opendb->query($clear_sql);
				$clear_num=mysql_num_rows($clear_query);
				for($i=0;$i<$clear_num; $i++){	
					$cate_myrows=mysql_fetch_assoc($clear_query);		
					$id=$cate_myrows['ID'];	
						{
							 

							$opertb->id=$id;
							$ls_msg=$opertb->delwfile($downloadFolders,"","videoFile");
						
						}
				}
				 echo " ls_video 已清空 $clear_num 条, 上传视频已删除  <br/>";
				
				break;	
				

			
		case "ls_pro_feedback"://删除反馈 requirement
			
			 
				$clear_sql="select * from ls_pro_feedback where requirement like '%-tt-%' ";
				$clear_query=$opendb->query($clear_sql);
				$clear_num=mysql_num_rows($clear_query);
				for($i=0;$i<$clear_num; $i++){	
					$cate_myrows=mysql_fetch_assoc($clear_query);		
					$id=$cate_myrows['ID'];	
					{
						 		$del_sql="delete from ls_pro_feedback where ID=".$id."";
				   			//echo $del_sql."<br>";
				   				$del_query=$opendb->query($del_sql);
				   			}
				   	  		 
				   	}
			  echo " ls_pro_feedback 已清空 $clear_num 条  <br/>";
	   			
			break;	
			
			
			 

		case "ls_problem"://删除老的常见问题
	
			echo "products 已清空 <br/>";
		 	break;
			
			
		case "ls_log"://删除全部log
				$clear_sql="select * from ls_log where  1 ";
				$clear_query=$opendb->query($clear_sql);
				$clear_num=mysql_num_rows($clear_query);
				for($i=0;$i<$clear_num; $i++){	
					$cate_myrows=mysql_fetch_assoc($clear_query);		
					$id=$cate_myrows['ID'];	
					{
						 		$del_sql="delete from ls_pro_feedback where ID=".$id."";
				   			//echo $del_sql."<br>";
				   				$del_query=$opendb->query($del_sql);
				   			}
				   	  		 
				   	}
			  
	
			echo "ls_log 已清空 $clear_num 条 <br/>";
		 	break;
			
		case "ls_motif"://删除车间图片
				
				$clear_sql="select * from ls_motif  where motifText like '%-tt-%'  ";
				$clear_query=$opendb->query($clear_sql);
				$clear_num=mysql_num_rows($clear_query);
				for($i=0;$i<$clear_num; $i++){	
					$cate_myrows=mysql_fetch_assoc($clear_query);		
					$id=$cate_myrows['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 "ls_motif 已清空 $clear_num 条 <br/>";
				
				break;

		}

	} // end for
	
	
	$Actionarr=explode(",",$gentable);

	
	for($j=0;$j<count($Actionarr); $j++)
	{
	
		$Action=trim($Actionarr[$j]);
		$_GET['gen']=$Action;
		require('generalpicrequire.php');  //通用图片文件开关语句
		echo $generalTable."- table";
		if(mysql_num_rows($opendb->query("SHOW TABLES LIKE '".$generalTable."' "))==1)  // 表是否存在
		{
				$opertb->table=$generalTable;
				$clear_sql="select * from  ".$generalTable."  where $generalpicsTitle like '%-tt-%'  ";
				$clear_query=$opendb->query($clear_sql);
				$clear_num=mysql_num_rows($clear_query);
				for($i=0;$i<$clear_num; $i++){	
					$cate_myrows=mysql_fetch_assoc($clear_query);		
					$id=$cate_myrows['ID'];	
					$opertb->id=$id;
					 
					$ls_msg=$opertb->delwfile($folder1,$folder2,$generalpicsPic);
				}
				echo $Action." 已清空 $clear_num 条 <br/>";
		}
			
	}
	?>
	    <link href="css/style2.css" rel="stylesheet"  type="text/css"/>
