<?php

/*

'**************************************************************************************************

' 软件名称: 黑色幻想舞曲管理系统CMS2.0

' 版本编号: hshxsdj 2.0

' 官方网站: http://www.hshxs.com

' 官方论坛：http://bbs.hshxs.com

' 版权所有: 黑色幻想开发团队    噬己翼(QQ:532917920)

' 郑重声明:

'    1、任何个人或组织不得在未经授权的情况下删除、修改、拷贝本软件及其他副本上一切关于版权的信息；

'    2、黑色幻想网络事业部保留此软件的法律追究权利

'**************************************************************************************************

*/


include "../../include/label.php";

include "../admin_loginstate.php";

?>

<!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=gb2312" />

<link type="text/css" href="../images/style.css" rel="stylesheet" />

<link type="text/css" href="../images/alerts.css" rel="stylesheet" media="screen">

<script type="text/javascript" language="javascript">var tentpath='<?php echo S_SitePath?>';</script>

<script language="javascript" src="../js/jquery.js"></script>

<script language="javascript" src="../js/alerts.js"></script>

</head>

<body>

<?php

SystemPer(11);

$SelID=SafeRequest("SelID","get");



switch($SelID){

	case '1':

		$CNumber=SafeRequest("CNumber1","post");

		Span_BaiduMap($CNumber);

		break;

	case '2':

		$CNumber=SafeRequest("CNumber2","post");

		Span_GoogleMap($CNumber);

		break;

	case '3':

		$CNumber=SafeRequest("CNumber3","post");

		Span_RssMap($CNumber);

		break;

	}

function XmlURL($ID,$ClassID){

		$xmlurl=S_SiteDomain.LinkUrl("s_video",$ClassID,1,$ID);

		return $xmlurl;

	}	

function Span_BaiduMap($CNumber){

	global $db;

	if(!IsNum($CNumber)){$CNumber=100;}

	if(stristr(strtolower(S_SiteDomain),'http://')){

		$SiteDomain=S_SiteDomain;

		}

	else{

		$SiteDomain="http://".S_SiteDomain;

		}	

	$Content="<?xml version=\"1.0\" encoding=\"GBK\" ?>\r\n

					<document>\r\n

					<webSite>".$SiteDomain."</webSite>\r\n

					<webMaster>".S_SiteName."</webMaster>

					<updatePeri>1800</updatePeri>\r\n";	

	$sql="Select * from s_video order by S_ID desc limit ".$CNumber."";

	$result=$db->query($sql);

	if($result){

		while($row=$db->fetch_array($result)){

			$Content.="<item>\r\n

			<title>".xmlEscape($row['S_Name'])."</title>\r\n";

			$Content.="<link>".XmlURL($row['S_ID'],$row['S_ClassID'])."</link>\r\n";

			$Content.="<text>".xmlEscape(cnsubstr($row['S_Content'],200))."</text>\r\n";

			//if(substr($row['S_Pic'],0,-3)='jpg' or substr($row['S_Pic'],0,-3)='gif' or substr($row['S_Pic'],0,-3)='png' or substr($row['S_Pic'],0,-3)='bmp'){

			//if(stristr(strtolower($row['S_Pic']),'http://')){

				//$Content.="<image>".$row['S_Pic']."</image>\r\n";

				//}

			//else{

				//$Content.= "<image>".$SiteDomain."/".S_Vimgfolder."/".$row['S_Pic']."</image>\r\n";

				//}

				//}	

			$Content.="<keywords>".xmlEscape($row['S_Name'].",".$row['S_Author'])."</keywords>\r\n

							  <author>".S_SiteName."</author>\r\n

							  <source>".S_SiteName."</source>\r\n

							  <pubDate>".$row['S_AddTime']."</pubDate>\r\n

							  </item>\r\n";

			}

		$Content.="</document>\r\n";

		$Folder="baiduxml.xml";

		$Folder1=$Folder;

		echo "<font style=font-size:12pt;><a href=\"../../".$Folder1."\" target=\"_blank\">".S_SiteDomain.S_SitePath.$Folder1."</a> 生成完毕<br>";

	 	fwrite(fopen("../../".$Folder,"wb"),$Content);

		echo "<br/><a href=\"http://news.baidu.com/newsop.html\" target=\"_blank\">http://news.baidu.com/newsop.html</a>请通过提交</font>";

		

		}

	}

	



function Span_GoogleMap($CNumber){

	global $db;

	if(!IsNum($CNumber)){$CNumber=100;}

	if(stristr(strtolower(S_SiteDomain),'http://')){

		$SiteDomain=S_SiteDomain;

		}

	else{

		$SiteDomain="http://".S_SiteDomain;

		}	





	$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>".$SiteDomain."</loc>\r\n

				</url>\r\n";

	$sql="Select * from s_video order by S_ID desc limit ".$CNumber."";

	$result=$db->query($sql);

	if($result){

		while($row=$db->fetch_array($result)){

			$Content.="<url>\r\n

			<loc>".XmlURL($row['S_ID'],$row['S_ClassID'])." </loc>\r\n";

			$Content.="<lastmod>".date("Y-m-d",strtotime($row['S_AddTime']))."</lastmod>\r\n";

			$Content.="</url>";	

		}

	}



	$Content.="</urlset>\r\n";

	$Folder="googlexml.xml";

	echo "<font style=font-size:12pt;><a href=\"../../".$Folder."\" target=\"_blank\">".S_SiteDomain.S_SitePath.$Folder."</a> 生成完毕<br>";

	 fwrite(fopen("../../".$Folder,"wb"),$Content);

	echo "<br/><a href=\"http://www.google.com/webmasters/tools/\" target=\"_blank\">http://www.google.com/webmasters/tools/</a>请通过提交</font>";



}



function Span_RssMap($CNumber){

	global $db;

	if(!IsNum($CNumber)){$CNumber=100;}

	

	if(stristr(strtolower(S_SiteDomain),'http://')){

		$SiteDomain=S_SiteDomain;

		}

	else{

		$SiteDomain="http://".S_SiteDomain;

		}	

	$Content="<?xml version=\"1.0\" encoding=\"GBK\" ?>\r\n

				<rss version='2.0'\r\n>

				<channel>\r\n

				<title><![CDATA[".S_SiteName."]]></title>\r\n

				<description><![CDATA[".S_SiteName."]]></description>\r\n

				<link>".$SiteDomain."</link>\r\n

				<language>zh-cn</language>\r\n

				<docs>".S_SiteName."</docs>\r\n

				<generator>Rss Powered By ".$SiteDomain."</generator>\r\n

				<image>\r\n

					<url>".$SiteDomain."/images/logo.gif</url>\r\n

				</image>\r\n";

	$sql="Select * from s_video order by S_ID desc limit ".$CNumber."";

	$result=$db->query($sql);

	if($result){

		while($row=$db->fetch_array($result)){

			$Content.="<item>\r\n

						<title><![CDATA[".xmlEscape($row["S_Name"])."]]></title>\r\n

						<link>".XmlURL($row['S_ID'],$row["S_ClassID"])."</link>\r\n

						<author>".xmlEscape($row["S_Author"])."</author>\r\n

						<pubDate>".$row['S_AddTime']."</pubDate>\r\n

						<description><![CDATA[".xmlEscape(cnsubstr($row['S_Content'],200))."]]></description>\r\n

					   </item>\r\n";

		}

	}

	$Content.="</channel></rss>\r\n";

	$Folder="rssxml.xml";

	 fwrite(fopen("../../".$Folder,"wb"),$Content);

	echo "<font style=font-size:12pt;><a href=\"../../".$Folder."\" target=\"_blank\">".S_SiteDomain.S_SitePath.$Folder."</a> 生成完毕<br>";

	echo "<br/>Rss文档全部生成完毕．．．</font>";

}



function xmlEscape($str){

	$str=ReplaceStr($str,"&","&amp;");

	$str=ReplaceStr($str,"'","&apos;");

	$str=ReplaceStr($str,'"',"&quot;");

	$str=ReplaceStr($str,">","&gt;");

	$str=ReplaceStr($str,"<","&lt;");

	return $str;

	}

?>