<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" >

<?php
	//清理非demo的全部数据及图片  , 清理 log feedback stastic 
	require_once('_approot.php');
	$opertb=new mytb();
	
	if( !$ls_local){  $ls_msg.= "网上不执行"; exit;} //网上不删除
	//$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,ls_internal,ls_links, ls_motif,ls_pro_feedback,ls_config"; // 
	$TRUNCATEtable="ls_log,ls_statistics,ls_writefiles,ls_keywords,ls_select_id,ls_ftplog,ls_pro_feedback,ls_propic,ls_prospec"; //本地删除
	

	$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 1 ";
				$clear_query=$opendb->query($clear_sql);
				$clear_num=mysqli_num_rows($clear_query);
				for($i=0;$i<$clear_num; $i++){	
					$cate_myrows=mysqli_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=mysqli_fetch_assoc($products_query);
						 
						$thisProductsFloder=trim(getproductfolder($products_rows['productID']));
						if($thisProductsFloder=="") continue;
						$Bigpicsrc1="../".$thisProductsFloder ;
						deldir($Bigpicsrc1);
						$del_sql="delete from ls_products where ID=".$id;
						$del_query=$opendb->query($del_sql);
					}
			  }
			  $ls_msg.= "ls_products $clear_num 已清空 <br/>";

		  break;	
		  
		 case "ls_functioncates"://删除新闻、博客、常见问题分类
				$clear_sql="select * from ls_functioncates where cateName !='news' and cateName !='blog'  and cateName !='faq'  "; 
				$clear_query=$opendb->query($clear_sql);
				$clear_num=mysqli_num_rows($clear_query);
				for($i=0;$i<$clear_num; $i++){	
					$cate_myrows=mysqli_fetch_assoc($clear_query);	
					//删除文件夹、模板
					$tpl=$cate_myrows['typeurl'];
					$tplshow=str_replace(".","show.",$tpl);
					if(file_exists("../Templates1/".$tpl)) 
						if(!unlink("../Templates1/".$tpl)) $ls_msg.=$tpl."模板删除错误! "; else $ls_msg.=$tpl."模板已删除! ";//复制模板
					if(file_exists("../Templates1/".$tplshow)) 
						if(!unlink("../Templates1/".$tplshow)) $ls_msg.=$tplshow."模板删除错误! "; else $ls_msg.=$tplshow."模板已删除! ";//复制模板
					$folder="../".$cate_myrows['folder'];
					if(deldir($folder)) $ls_msg.=$folder."及其下面文件已删除! ";	
					
					$id=$cate_myrows['ID'];	
					{
						 $del_sql="delete from ls_functioncates where ID=".$id."";
						//$ls_msg.= $del_sql."<br>";
						$del_query=$opendb->query($del_sql);
					}
				}
 
	
		 $ls_msg.= "ls_functioncates 新闻、博客、常见问题意外分类 $clear_num 已清空 <br/>";
		 break;

		 
		 case "ls_news": //删除新闻、常见问题、博客
				$clear_sql="select * from ls_news where 1 ";
				$clear_query=$opendb->query($clear_sql);
				$clear_num=mysqli_num_rows($clear_query);
				for($i=0;$i<$clear_num; $i++){	
					$cate_myrows=mysqli_fetch_assoc($clear_query);		
					$id=$cate_myrows['ID'];	
					{
						 $del_sql="delete from ls_news where ID=".$id."";
						//$ls_msg.= $del_sql."<br>";
						$del_query=$opendb->query($del_sql);
					}
				}
 
				  $ls_msg.= "ls_news 已清空 $clear_num 条  <br/>";
				
				break;	
				
 			 case "ls_article": //删除文章
				$clear_sql="select * from ls_article where 1 ";
				$clear_query=$opendb->query($clear_sql);
				$clear_num=mysqli_num_rows($clear_query);
				for($i=0;$i<$clear_num; $i++){	
					$cate_myrows=mysqli_fetch_assoc($clear_query);		
					
					$tpl="../Templates1/".$cate_myrows['static_tpl'];
					if(file_exists($tpl)&& trim($cate_myrows['static_tpl'])!="single_page.html" ) 
						if(!unlink($tpl)) $ls_msg.=" 模板".$tpl."删除错误，";  
						else $ls_msg.=" 模板".$tpl."已删除，"; //删除模板
					
					$id=$cate_myrows['ID'];	
						{
						 	$del_sql="delete from ls_article where ID=".$id."";
				   			//$ls_msg.= $del_sql."<br>";
				   			$del_query=$opendb->query($del_sql);
				   		}
				   	 
				   	}
				  $ls_msg.= " ls_article 已清空 $clear_num 条  <br/>";
		   			
				 	break;	
			 	
			 case "ls_singlepages": //删除文章
			 
				$clear_sql="select * from ls_singlepages where 1 ";
				$clear_query=$opendb->query($clear_sql);
				$clear_num=mysqli_num_rows($clear_query);
				for($i=0;$i<$clear_num; $i++){	
					$cate_myrows=mysqli_fetch_assoc($clear_query);	
					//删除模板
					
					$id=$cate_myrows['ID'];	
					{
						 		$del_sql="delete from ls_singlepages where ID=".$id."";
				   			//$ls_msg.= $del_sql."<br>";
				   				$del_query=$opendb->query($del_sql);
				   			}
				   	  		 
				   	}
					  $ls_msg.= " ls_singlepages 已清空 $clear_num 条  <br/>";
	   			
				 	break;	
			
			
		 case "ls_download"://删除下载
		 	 $opertb->table="ls_download";
				$clear_sql="select * from ls_download where 1 ";
				$clear_query=$opendb->query($clear_sql);
				$clear_num=mysqli_num_rows($clear_query);
				for($i=0;$i<$clear_num; $i++){	
					$cate_myrows=mysqli_fetch_assoc($clear_query);		
					$id=$cate_myrows['ID'];	
						{
							$opertb->id=$id;
							if($downloadFolders=="") continue;
							$ls_msg.=$opertb->delwfile($downloadFolders,"","downloadName");
						}
				}
				 $ls_msg.= " ls_download 已清空 $clear_num 条, 上传文件已删除  <br/>";
				
				break;	
				
		 
				
		case "ls_video"://删除视频 videoName
		
		 	 $opertb->table="ls_video";
				$clear_sql="select * from ls_video where  1 ";
				$clear_query=$opendb->query($clear_sql);
				$clear_num=mysqli_num_rows($clear_query);
				for($i=0;$i<$clear_num; $i++){	
					$cate_myrows=mysqli_fetch_assoc($clear_query);		
					$id=$cate_myrows['ID'];	
						{
							$opertb->id=$id;
							if($downloadFolders=="") continue;
							$ls_msg.=$opertb->delwfile($downloadFolders,"","videoFile");
						}
				}
				 $ls_msg.= " ls_video 已清空 $clear_num 条, 上传视频已删除  <br/>";
				
				break;	
			
		case "ls_pro_feedback"://删除反馈 requirement
				$clear_sql="select * from ls_pro_feedback where 1 ";
				$clear_query=$opendb->query($clear_sql);
				$clear_num=mysqli_num_rows($clear_query);
				for($i=0;$i<$clear_num; $i++){	
					$cate_myrows=mysqli_fetch_assoc($clear_query);		
					$id=$cate_myrows['ID'];	
					{
						 		$del_sql="delete from ls_pro_feedback where ID=".$id."";
				   			//$ls_msg.= $del_sql."<br>";
				   				$del_query=$opendb->query($del_sql);
				   			}
				   	  		 
				   	}
			  $ls_msg.= " ls_pro_feedback 已清空 $clear_num 条  <br/>";
	   			
			break;	

		case "ls_internal"://删除老的常见问题
				$clear_sql="select * from ls_internal where 1 ";
				$clear_query=$opendb->query($clear_sql);
				$clear_num=mysqli_num_rows($clear_query);
				for($i=0;$i<$clear_num; $i++){	
					$cate_myrows=mysqli_fetch_assoc($clear_query);		
					$id=$cate_myrows['ID'];	
					{
						 		$del_sql="delete from ls_pro_feedback where ID=".$id."";
				   			//$ls_msg.= $del_sql."<br>";
				   				$del_query=$opendb->query($del_sql);
				   			}
				   	  		 
				   	}
			  $ls_msg.= " ls_internal 已清空 $clear_num 条  <br/>";		 
		 	break;
			
		case "ls_motif"://主题图片
				
				$clear_sql="select * from ls_motif  where 1  ";
				$clear_query=$opendb->query($clear_sql);
				$clear_num=mysqli_num_rows($clear_query);
				for($i=0;$i<$clear_num; $i++){	
					$cate_myrows=mysqli_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=mysqli_fetch_assoc($select_query);
						//获取文件目录
						$Bigpicsrc="../".$MotifFolders."/".$BigFoldersProducts."/".$select_myrows['motifPic'];
							//$Smallpicsrc="../".$MotifShopFolders."/".$SmallFoldersProducts."/".$select_myrows['workshopPic'];
						//删除文件
						
						if(file_exists($Bigpicsrc))		unlink($Bigpicsrc);
						//unlink($Smallpicsrc);
						$del_sql="delete from ls_motif where ID=".$id."";
							//$ls_msg.= $del_sql;
						$del_query=$opendb->query($del_sql);
						
					}
				}
				$ls_msg.= "ls_motif 已清空 $clear_num 条 <br/>";
				
				break;

		case "ls_links"://友情链接
				
				$clear_sql="select * from ls_links  where 1 ";
				$clear_query=$opendb->query($clear_sql);
				$clear_num=mysqli_num_rows($clear_query);
				for($i=0;$i<$clear_num; $i++){	
					$cate_myrows=mysqli_fetch_assoc($clear_query);		
					$id=$cate_myrows['ID'];	
						{
						$select_sql="select * from ls_links where ID=".$id."";
						$select_query=$opendb->query($select_sql);
						$select_myrows=mysqli_fetch_assoc($select_query);
						$del_sql="delete from ls_links where ID=".$id."";
							//$ls_msg.= $del_sql;
						$del_query=$opendb->query($del_sql);
						
					}
				}
				break;
				
		case "ls_config"://友情链接
				
				$clear_sql="select * from ls_config  where 1 ";
				$clear_query=$opendb->query($clear_sql);
				$clear_num=mysqli_num_rows($clear_query);
				for($i=0;$i<$clear_num; $i++){	
					$cate_myrows=mysqli_fetch_assoc($clear_query);		
					$id=$cate_myrows['ID'];	
						{
						$select_sql="select * from ls_links where ID=".$id."";
						$select_query=$opendb->query($select_sql);
						$select_myrows=mysqli_fetch_assoc($select_query);
						$del_sql="delete from ls_links where ID=".$id."";
							//$ls_msg.= $del_sql;
						$del_query=$opendb->query($del_sql);
						
					}
				}
				$select_sql="INSERT INTO `ls_config` (`ID`, `companyNameCn`, `companyName`, `manager`, `siteKeywords`, `siteDescription`, `address`, `tel`, `tel2`, `tel3`, `tel4`, `fax`, `email`, `email2`, `email3`, `email4`, `feedbackEmail`, `MSN`, `MSN2`, `MSN3`, `MSN4`, `website`, `skype`, `skype2`, `skype3`, `skype4`, `feedback`, `aboutus`, `aboutLenght`, `notice`, `contact`, `ICP`, `bottomMenu`, `facebook`, `twitter`, `linkedin`, `google`, `pinterest`, `youtube`, `company_logo`, `qr_data`, `templates`, `qq`, `people`, `language`, `statistics`, `onlines`, `maps`, `share`, `onlinechart`, `shield`, `indexPassword`, `htaccess`, `robot`, `statisticsUrl`, `statisticsName`, `statisticsPsd`, `onlinechartUrl`, `onlinechartName`, `onlinechartPsd`, `shieldIP`, `copyright`) VALUES (NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'Templates1', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '11000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL)"; //插入保留
				$select_query=$opendb->query($select_sql);
				
				$ls_msg.= "ls_links 已清空 $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');  //通用图片文件开关语句
		//$ls_msg.= $generalTable."- table";
		if(mysqli_num_rows($opendb->query("SHOW TABLES LIKE '".$generalTable."' "))==1)  // 表是否存在
		{
				$opertb->table=$generalTable;
				$clear_sql="select * from  ".$generalTable."  where 1  ";
				$clear_query=$opendb->query($clear_sql);
				$clear_num=mysqli_num_rows($clear_query);
				for($i=0;$i<$clear_num; $i++){	
					$cate_myrows=mysqli_fetch_assoc($clear_query);		
					$id=$cate_myrows['ID'];	
					$opertb->id=$id;
					 
					$ls_msg.=$opertb->delwfile($folder1,$folder2,$generalpicsPic);
				}
				$ls_msg.=  $generalTable." 已清空 $clear_num 条 <br/>";
		}
			
	}
	
	
//--------------

		if(!(strpos($_SERVER["SERVER_ADDR"],"192.168.2")===false)||!(strpos($_SERVER["SERVER_ADDR"],"::1")===false)){ //网上不删 

		$Actionarr=explode(",",$TRUNCATEtable);
		for($j=0;$j<count($Actionarr); $j++)
		{
		
			$Action=trim($Actionarr[$j]);
			//$ls_msg.= $Action."- table";
			if(mysqli_num_rows($opendb->query("SHOW TABLES LIKE '".$Action."' "))==1)  // 表是否存在
			{
					$clear_sql="DELETE FROM ".$Action." WHERE 1   ";
					$clear_query=$opendb->query($clear_sql);
					$ls_msg.= $Action." 已清空 $clear_num 条 <br/>";
			}
				
		}
	}
	$ls_msg.=  "<br/>相关文件已删除。 <br/>";
	?>
<!doctype html>
<html>
<head>
<link href="css/style2.css" rel="stylesheet"  type="text/css"/>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<?php echo $ls_msg;
?>