<!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="css/admin.css" rel="stylesheet" type="text/css">

<?php
	session_start(); 
	require_once('inc/conn.php');
	require_once('inc/constant.php');
	require_once('inc/ls_syscode.php');
	require_once('inc/check.php');
	$opendb=new mydb();
	require_once('inc/char_set.php');
	$timeflag=time();
	$profilename="../sitemap/sitemap".$timeflag.".xml";
	$profilename1="../sitemap.xml"; //sitemap.xml
	$ls=$_GET['ls'];
	
	if($ls=="clear"){
		$clearsql="delete  from ls_writefiles where 1 ";
		$writefile_query=$opendb->query($clearsql);
		echo "<br/>  网站地图已清空，请 生成整站 -> 生成产品页 ";exit;
	}
	$procontent='<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:news="http://www.google.com/schemas/sitemap-news/0.9"
xmlns:xhtml="http://www.w3.org/1999/xhtml"
xmlns:mobile="http://www.google.com/schemas/sitemap-mobile/1.0"
xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">';
	$procontent1=$procontent;
	
	$writefilesql="select * from ls_writefiles where 1 ";
	$writefile_query=$opendb->query($writefilesql);
	while($writefile_rows=mysql_fetch_assoc($writefile_query)){
		  $procontent0='
<url>
<loc>'.$writefile_rows["url"].'</loc>
<lastmod>'.$writefile_rows["lastmod"].'</lastmod>
<changefreq>'.$writefile_rows["changefreq"].'</changefreq>
</url>
';
		if($writefile_rows['submited']==1) $procontent1.=$procontent0; else { $procontent.=$procontent0;$procontent1.=$procontent0;} //已发布、未发布 写入完整sitemap，否则写入新发布
		
	}

$procontent.="</urlset>";
$procontent1.="</urlset>";

	$handle   = fopen($profilename,"w"); //打开文件指针，
	$handle1   = fopen($profilename1,"w"); //打开完整sitemap


	
?>
<!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="css/admin.css" rel="stylesheet" type="text/css">
<link rel="stylesheet" href="css/style2.css" />
<script language="JavaScript" src="js/ls.js"></script>
<title><?=$china?> - <?=$ls?></title>
<style>
button{ padding:5px 15px;}
input { font-size:14px;
    padding: 5px 15px;
    border-radius: 5px;
    border: #00c0ef 1px solid;
    cursor: pointer;
    background-color: #00c0ef;
    color: #fff;
</style>
</head>
<body>
<table width="100%" border="0" align="center" cellpadding="1" cellspacing="1">
	<tr>
        <td height="18" style="border-bottom:2px solid #00c0ef; padding-bottom:5px;"><div align="center"><font color="#3c8dbc" style="font-size:16px;">网页生成</font></div>
				</td>
	</tr>
	<tr><td><br/>
<?
	 
	
/*	 if (!fwrite ($handle,$procontent))
	{  //将信息写入文件
		  if($ls_debug)  echo "".$profilename."失败！";
	} 
	else
	{
		echo "生成网站地图 <a href='".$profilename."' target='_blank'>".$profilename."</a><br/>";
		echo "<br>";
		fclose ($handle); //关闭指针

		$pingurl="google.com/ping?sitemap=".$_SERVER['HTTP_HOST']."/".str_replace("../","",$profilename)." ";  // ping 提交
		$writefilesql="update ls_writefiles set submited=1 where  submited=0 ";
		$writefile_query=$opendb->query($writefilesql);
		echo $pingurl;
		 
	}
*/    
	if (!fwrite ($handle1,$procontent1))
	{  //将信息写入文件
		  if($ls_debug)  echo "".$profilename1."失败！";
	} 
	else
	{
		  echo "<br/><br/>已生成网站地图 <a href='".$profilename1."' target='_blank'>".$profilename1."</a>。   <a href='ls_xmlsitmap.php?ls=clear'  >清空网站地图</a>，清空后请 生成整站 -> 生成产品页";
		  echo "<br><br/><a href='".$_SERVER["HTTP_REFERER"]."'>返回</a>";
		fclose ($handle1); //关闭指针
     }

?>	
	</td>
	</tr>
	</table>
</body>
</html>