<?php
# Name: PHP版程氏专集CMS管理系统 v3.0
# Author: 程氏<web@chshcms.com> [QQ:848769359]
# Homepage:http://www.chshcms.cn/
include_once("../../lib/cs_label.php");
include_once("../loginstate.php");
SystemPer('8_1');

        global $db;
        $ac=CS_Request("ac");
        if(CS_Webmode!=3 && $ac=="")  exit(Msg_Error('网站运行模式为动态，不能生成!','javascript:history.go(-1);'));
?>
<!doctype html>
<html>
<head>
<meta charset=utf-8>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<title>chshdjcms management</title>
<link href="../res/css/admin_style.css" rel="stylesheet" />
<script language="javascript" src="../res/js/jquery.js"></script>
</head>
<body>
<div class="wrap">
<div class="h_a">生成选项&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="html.php"><font color=#026E12>返回</font></a></div>
<div class="table_full">
	<table width="100%" class="J_check_wrap">
		<col width="100%" />
<?php
if($ac=='rss'){
	if(stristr(strtolower(CS_WebUrl),'http://')){
		$WebUrl=CS_WebUrl;
	}else{
		$WebUrl="http://".CS_WebUrl;
	}
	$Content="<?xml version=\"1.0\" encoding=\"GBK\" ?>\r\n
				<rss version='2.0'\r\n>
				<channel>\r\n
				<title><![CDATA[".CS_WebName."]]></title>\r\n
				<description><![CDATA[".CS_WebName."]]></description>\r\n
				<link>".$WebUrl."</link>\r\n
				<language>zh-cn</language>\r\n
				<docs>".CS_WebName."</docs>\r\n
				<generator>Rss Powered By ".$WebUrl."</generator>\r\n
				<image>\r\n
					<url>".$WebUrl."/skins/index/images/logo.gif</url>\r\n
				</image>\r\n";
	$sql="Select * from ".Getdbname('dance')." order by CS_ID desc limit 100";
	$result=$db->query($sql);
	if($result){
		while($row=$db->fetch_array($result)){
			$Content.="<item>\r\n
						<title><![CDATA[".xmlEscape($row["CS_Name"])."]]></title>\r\n
						<link>".$WebUrl.LinkUrl('play','dance','id',$row['CS_CID'],$row['CS_ID'])."</link>\r\n
						<author>".xmlEscape($row["CS_Singer"])."</author>\r\n
						<pubDate>".$row['CS_AddTime']."</pubDate>\r\n
						<description><![CDATA[".xmlEscape(cnsubstr($row['CS_Content'],200))."]]></description>\r\n
					   </item>\r\n";
		}
	        $Content.="</channel></rss>\r\n";
	 	if(write_file("../../map/rssxml.xml", $Content)){  //生成
		          echo "<tr><td><font style=font-size:12pt;><a href=\"../../map/rssxml.xml\" target=\"_blank\">rssxml.xml</a> Rss文档生成完毕<br></td></tr>";
                }else{
                          exit("<tr><td>&nbsp;&nbsp;<font style=font-size:10pt;>Rss文档失败,请检查网站跟目录是否有写入权限!</font></td></tr>");
                }
	}
}elseif($ac=='baidu'){
	if(stristr(strtolower(CS_WebUrl),'http://')){
		$WebUrl=CS_WebUrl;
	}else{
		$WebUrl="http://".CS_WebUrl;
	}
	$Content="<?xml version=\"1.0\" encoding=\"GBK\" ?>\r\n
					<document>\r\n
					<webSite>".$WebUrl."</webSite>\r\n
					<webMaster>".CS_WebName."</webMaster>
					<updatePeri>1800</updatePeri>\r\n";	
	$sql="Select * from ".Getdbname('dance')." order by CS_ID desc limit 100";
	$result=$db->query($sql);
	if($result){
		while($row=$db->fetch_array($result)){
			$Content.="<item>\r\n
			<title>".xmlEscape($row['CS_Name'])."</title>\r\n";
			$Content.="<link>".$WebUrl.LinkUrl('play','dance','id',$row['CS_CID'],$row['CS_ID'])."</link>\r\n";
			$Content.="<text>".xmlEscape(cnsubstr($row['CS_Content'],200))."</text>\r\n";
			$Content.="<keywords>".xmlEscape($row['CS_Name'].",".$row['CS_Singer'])."</keywords>\r\n
							  <author>".$row['CS_Singer']."</author>\r\n
							  <source>".CS_WebName."</source>\r\n
							  <pubDate>".$row['CS_AddTime']."</pubDate>\r\n
							  </item>\r\n";
		}
		$Content.="</document>\r\n";
	 	if(write_file("../../map/baiduxml.xml", $Content)){  //生成
		          echo "<tr><td><font style=font-size:12pt;><a href=\"../../map/baiduxml.xml\" target=\"_blank\">baiduxml.xml</a> 生成完毕<br></td></tr>";
		          echo "<tr><td><a href=\"http://news.baidu.com/newsop.html\" target=\"_blank\">http://news.baidu.com/newsop.html</a>请通过提交</font></td></tr>";
                }else{
                          exit("<tr><td>&nbsp;&nbsp;<font style=font-size:10pt;>百度地图生成失败,请检查网站跟目录是否有写入权限!</font></td></tr>");
                }
	}

}elseif($ac=='guge'){
	if(stristr(strtolower(CS_WebUrl),'http://')){
		$WebUrl=CS_WebUrl;
	}else{
		$WebUrl="http://".CS_WebUrl;
	}
	$Content="<?xml version=\"1.0\" encoding=\"GBK\" ?>\r\n
			   <urlset xmlns=\"http://www.google.com/schemas/sitemap/0.84\">\r\n
			  	<url>\r\n
				<loc>".$WebUrl."</loc>\r\n
				</url>\r\n";
	$sql="Select * from ".Getdbname('dance')." order by CS_ID desc limit 100";
	$result=$db->query($sql);
	if($result){
		while($row=$db->fetch_array($result)){
			$Content.="<url>\r\n
			<loc>".$WebUrl.LinkUrl('play','dance','id',$row['CS_CID'],$row['CS_ID'])." </loc>\r\n";
			$Content.="<lastmod>".date("Y-m-d",strtotime($row['CS_AddTime']))."</lastmod>\r\n";
			$Content.="</url>";
		}
	        $Content.="</urlset>\r\n";
	 	if(write_file("../../map/googlexml.xml", $Content)){  //生成
		          echo "<tr><td><font style=font-size:12pt;><a href=\"../../map/googlexml.xml\" target=\"_blank\">googlexml.xml</a> 生成完毕<br></td></tr>";
		          echo "<tr><td><a href=\"http://www.google.com/webmasters/tools/\" target=\"_blank\">http://www.google.com/webmasters/tools/</a>请通过提交</font></td></tr>";
                }else{
                          exit("<tr><td>&nbsp;&nbsp;<font style=font-size:10pt;>谷歌地图生成失败,请检查网站跟目录是否有写入权限!</font></td></tr>");
                }
	}
}else{
	if(file_exists(_CSDJ_ROOT_.CS_Templateurl."cs-index.html")){
	      $Mark_Text=GetTemp("cs-index.html",0);
	      if(write_file("../../index.html", $Mark_Text)){  //生成
                 exit("<tr><td>&nbsp;&nbsp;<font style=font-size:10pt;>网站首页已成功生成．．．,&nbsp;&nbsp;<a href=".CS_WebPath."index.html target=_blank>index.html</a></font></td></tr>");
              }else{
                 exit("<tr><td>&nbsp;&nbsp;<font style=font-size:10pt;>网站首页生成失败,请检查网站跟目录是否有写入权限!</font></td></tr>");
              }
	}else{
		exit("<tr><td>&nbsp;&nbsp;<font style=font-size:10pt;>出错了，首页模板文件不存在！</font></td></tr>");
	}	
}

function xmlEscape($str){
	$str=CS_ReplaceStr($str,"&","&amp;");
	$str=CS_ReplaceStr($str,"'","&apos;");
	$str=CS_ReplaceStr($str,'"',"&quot;");
	$str=CS_ReplaceStr($str,">","&gt;");
	$str=CS_ReplaceStr($str,"<","&lt;");
	return $str;
}
?>
</table>
</div>
</div>
</body>
</html>
