<?php

/*

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

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

' 版本编号: hshxsdj 2.0

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

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

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

' 郑重声明:

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

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

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

*/

include "../../../include/conn.php";

include "../../../include/function.php";

include "../../admin_version.php";

include "../../admin_loginstate.php";

include "fun.php";

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

$id=SafeRequest("s_id","get");

switch($action){

	case 'exp':

		main($id);

		break;

	case 'imp':

		imp();

		break;

	case 'save':

		save();

		break;

	case 'upload':

		upload();

		break;

	default:

		main($id);

	}	

 function save(){

	 $content=SafeRequest("content","post");

	 $sname=SafeRequest("sname","post");

	 fwrite(fopen("rule/".$sname.".txt","wb"),$content);

	 die("<script>window.location='admin_rulesave.php?sname=$sname'</script>");

	 }

	 

function upload(){

	global $db;

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

	if($mode=='1'){

		$fileType=array('text','txt');

		$maxSize=800; //单位：KB

		if(!in_array(substr($_FILES['file1']['name'],-3,3),$fileType)) die("<script>alert('不允许上传该类型的文件！-808');history.back();</script>");

		if(strpos($_FILES['file1']['type'],'text')===false) die("<script>alert('不允许上传该类型的文件！');history.back();</script>");	

		if($_FILES['file1']['size']> $maxSize*1024) die( "<script>alert('文件过大！');history.back();</script>");

		if($_FILES['file1']['error'] !=0) die("<script>alert('未知错误，文件上传失败！');history.back();</script>");

		$filename="rule/".date("YmdHis").".txt";

		if(function_exists('move_uploaded_file')){

			move_uploaded_file($_FILES['file1']['tmp_name'],$filename);

			dealRule($filename);

			echo "上传成功!!";

			}

		else{

			@copy($_FILES['file1']['tmp_name'],$filename);

			dealRule($filename);		

			echo "上传成功!!";

		}	

		}

	 else{

		$text=SafeRequest("content","post");

		$S_Name=getContent($text,"<s_name>","</s_name>",1);

		$S_Url=getContent($text,"<s_url>","</s_url>",1);

		$S_Code=getContent($text,"<s_code>","</s_code>",1);

		$S_AutoPageMode=getContent($text,"<s_autopagemode>","</s_autopagemode>",1);

		

		$S_SourceMode=getContent($text,"<s_sourcemode>","</s_sourcemode>",1);

		$S_SourceName=getContent($text,"<s_sourcename>","</s_sourcename>",1);

		$S_SourceGo=getContent($text,"<s_sourcego>","</s_sourcego>",1);

		$S_SourceEnd=getContent($text,"<s_sourceend>","</s_sourceend>",1);

		

		$S_Page=getContent($text,"<s_page>","</s_page>",1);

		$S_UrlStr=getContent($text,"<s_urlstr>","</s_urlstr>",1);

		$S_PageGo=getContent($text,"<s_pagego>","</s_pagego>",1);

		$S_PageEnd=getContent($text,"<s_pageend>","</s_pageend>",1);

		$S_Order=getContent($text,"<s_order>","</s_order>",1);

		$S_AutoSave=getContent($text,"<s_autosave>","</s_autosave>",1);

		$S_SavePic=getContent($text,"<s_savepic>","</s_savepic>",1);

		$S_Safe=getContent($text,"<s_safe>","</s_safe>",1);

		$S_ListGo=getContent($text,"<s_listgo>","</s_listgo>",1);

		$S_ListEnd=getContent($text,"<s_listend>","</s_listend>",1);

		$S_LinkGo=getContent($text,"<s_linkgo>","</s_linkgo>",1);

		$S_LinkEnd=getContent($text,"<s_linkend>","</s_linkend>",1);

		$S_ArtNameGo=getContent($text,"<s_artnamego>","</s_artnamego>",1);

		$S_ArtNameEnd=getContent($text,"<s_artnameend>","</s_artnameend>",1); 

		$S_RemarkGo=getContent($text,"<s_remarkgo>","</s_remarkgo>",1); 

		$S_RemarkEnd=getContent($text,"<s_remarkend>","</s_remarkend>",1);

		$S_AuthorName=getContent($text,"<s_authorname>","</s_authorname>",1);

		$S_AuthorMode=getContent($text,"<s_authormode>","</s_authormode>",1);

		$S_AuthorGo=getContent($text,"<s_authorgo>","</s_authorgo>",1); 

		$S_AuthorEnd=getContent($text,"<s_authorend>","</s_authorend>",1); 

		

		$S_PicGo=getContent($text,"<s_picgo>","</s_picgo>",1); 

		$S_PicEnd=getContent($text,"<s_picend>","</s_picend>",1); 

		$S_ClassMode=getContent($text,"<s_classmode>","</s_classmode>",1);

		$S_ClassID=getContent($text,"<s_classid>","</s_classid>",1);

		$S_ClassGo=getContent($text,"<s_classgo>","</s_classgo>",1);

		$S_ClassEnd=getContent($text,"<s_classend>","</s_classend>",1);

		$S_ContentGo=getContent($text,"<s_contentgo>","</s_contentgo>",1);

		$S_ContentEnd=getContent($text,"<s_contentend>","</s_contentend>",1);

		

		$S_PageMode=getContent($text,"<s_pagemode>","</s_pagemode>",1);

		$S_PlayUrlGo=getContent($text,"<s_playurlgo>","</s_playurlgo>",1);

		$S_PlayUrlEnd=getContent($text,"<s_playurlend>","</s_playurlend>",1);

		$S_Replace=getContent($text,"<s_replace>","</s_replace>",1);

		$S_AddTime=date("Y-m-d H:i:s");	



 		$sql="INSERT INTO `s_acustom` (

`S_Name` ,`S_Url` ,`S_Code` ,`S_SourceGo`,`S_SourceEnd` ,`S_SourceMode` ,`S_SourceName` ,`S_Page` ,`S_AutoPageMode` ,`S_UrlStr` ,`S_PageGo` ,`S_PageEnd` ,`S_Order` ,`S_AutoSave` ,`S_SavePic` ,`S_Safe` ,`S_ListGo` ,`S_ListEnd` ,`S_LinkGo` ,`S_LinkEnd` ,`S_ArtNameGo` ,`S_ArtNameEnd` ,`S_RemarkGo` ,`S_RemarkEnd` ,`S_AuthorMode` ,`S_AuthorName` ,`S_AuthorGo` ,`S_AuthorEnd` ,`S_PicGo` ,`S_PageMode` ,`S_PageUrlGo` ,`S_PageUrlEnd` ,`S_PageListGo` ,`S_PageListEnd` ,`S_PicEnd` ,`S_ClassMode` ,`S_ClassID` ,`S_ClassGo` ,`S_ClassEnd` ,`S_ContentGo` ,`S_ContentEnd` ,`S_AddTime` ,`S_Replace` )VALUES ('$S_Name', '$S_Url', '$S_Code', '$S_SourceGo','$S_SourceEnd', '$S_SourceMode', '$S_SourceName', '$S_Page', '$S_AutoPageMode', '$S_UrlStr', '$S_PageGo', '$S_PageEnd', '$S_Order' , '$S_AutoSave', '$S_SavePic', '$S_Safe', '$S_ListGo', '$S_ListEnd', '$S_LinkGo', '$S_LinkEnd', '$S_ArtNameGo', '$S_ArtNameEnd', '$S_RemarkGo', '$S_RemarkEnd', '$S_AuthorMode', '$S_AuthorName', '$S_AuthorGo', '$S_AuthorEnd', '$S_PicGo', '$S_PageMode', '$S_PageUrlGo', '$S_PageUrlEnd', '$S_PageListGo', '$S_PageListEnd', '$S_PicEnd', '$S_ClassMode', '$S_ClassID', '$S_ClassGo', '$S_ClassEnd', '$S_ContentGo', '$S_ContentEnd', '$S_AddTime', '$S_Replace'

);";



		   if($db->query($sql)){

	 		 echo("规则数据导入成功");

	 		 }

 			else{

			 echo("规则数据导入失败");

	 			}	

		}	 

	 }	 



function dealRule($file){

	global $db;

	if(file_exists($file)){

		$text=file_get_contents($file);

		$text=addslashes($text);

		$S_Name=getContent($text,"<s_name>","</s_name>",1);

		$S_Url=getContent($text,"<s_url>","</s_url>",1);

		$S_Code=getContent($text,"<s_code>","</s_code>",1);

		$S_AutoPageMode=getContent($text,"<s_autopagemode>","</s_autopagemode>",1);

		

		$S_SourceMode=getContent($text,"<s_sourcemode>","</s_sourcemode>",1);

		$S_SourceName=getContent($text,"<s_sourcename>","</s_sourcename>",1);

		$S_SourceGo=getContent($text,"<s_sourcego>","</s_sourcego>",1);

		$S_SourceEnd=getContent($text,"<s_sourceend>","</s_sourceend>",1);

		

		$S_Page=getContent($text,"<s_page>","</s_page>",1);

		$S_UrlStr=getContent($text,"<s_urlstr>","</s_urlstr>",1);

		$S_PageGo=getContent($text,"<s_pagego>","</s_pagego>",1);

		$S_PageEnd=getContent($text,"<s_pageend>","</s_pageend>",1);

		$S_Order=getContent($text,"<s_order>","</s_order>",1);

		$S_AutoSave=getContent($text,"<s_autosave>","</s_autosave>",1);

		$S_SavePic=getContent($text,"<s_savepic>","</s_savepic>",1);

		$S_Safe=getContent($text,"<s_safe>","</s_safe>",1);

		$S_ListGo=getContent($text,"<s_listgo>","</s_listgo>",1);

		$S_ListEnd=getContent($text,"<s_listend>","</s_listend>",1);

		$S_LinkGo=getContent($text,"<s_linkgo>","</s_linkgo>",1);

		$S_LinkEnd=getContent($text,"<s_linkend>","</s_linkend>",1);

		$S_ArtNameGo=getContent($text,"<s_artnamego>","</s_artnamego>",1);

		$S_ArtNameEnd=getContent($text,"<s_artnameend>","</s_artnameend>",1); 

		$S_RemarkGo=getContent($text,"<s_remarkgo>","</s_remarkgo>",1); 

		$S_RemarkEnd=getContent($text,"<s_remarkend>","</s_remarkend>",1);

		$S_AuthorName=getContent($text,"<s_authorname>","</s_authorname>",1);

		$S_AuthorMode=getContent($text,"<s_authormode>","</s_authormode>",1);

		$S_AuthorGo=getContent($text,"<s_authorgo>","</s_authorgo>",1); 

		$S_AuthorEnd=getContent($text,"<s_authorend>","</s_authorend>",1); 

		

		$S_PicGo=getContent($text,"<s_picgo>","</s_picgo>",1); 

		$S_PicEnd=getContent($text,"<s_picend>","</s_picend>",1); 

		$S_ClassMode=getContent($text,"<s_classmode>","</s_classmode>",1);

		$S_ClassID=getContent($text,"<s_classid>","</s_classid>",1);

		$S_ClassGo=getContent($text,"<s_classgo>","</s_classgo>",1);

		$S_ClassEnd=getContent($text,"<s_classend>","</s_classend>",1);

		$S_ContentGo=getContent($text,"<s_contentgo>","</s_contentgo>",1);

		$S_ContentEnd=getContent($text,"<s_contentend>","</s_contentend>",1);

		

		$S_PageMode=getContent($text,"<s_pagemode>","</s_pagemode>",1);

		$S_PageUrlGo=getContent($text,"<s_pageurlgo>","</s_pageurlgo>",1);

		$S_PageUrlEnd=getContent($text,"<s_pageurlend>","</s_pageurlend>",1);

		$S_Replace=getContent($text,"<s_replace>","</s_replace>",1);

		$S_AddTime=date("Y-m-d H:i:s");	

 		$sql="INSERT INTO `s_acustom` (

`S_Name` ,`S_Url` ,`S_Code` ,`S_SourceGo`,`S_SourceEnd` ,`S_SourceMode` ,`S_SourceName` ,`S_Page` ,`S_AutoPageMode` ,`S_UrlStr` ,`S_PageGo` ,`S_PageEnd` ,`S_Order` ,`S_AutoSave` ,`S_SavePic` ,`S_Safe` ,`S_ListGo` ,`S_ListEnd` ,`S_LinkGo` ,`S_LinkEnd` ,`S_ArtNameGo` ,`S_ArtNameEnd` ,`S_RemarkGo` ,`S_RemarkEnd` ,`S_AuthorMode` ,`S_AuthorName` ,`S_AuthorGo` ,`S_AuthorEnd` ,`S_PicGo` ,`S_PageMode` ,`S_PageUrlGo` ,`S_PageUrlEnd` ,`S_PageListGo` ,`S_PageListEnd` ,`S_PicEnd` ,`S_ClassMode` ,`S_ClassID` ,`S_ClassGo` ,`S_ClassEnd` ,`S_ContentGo` ,`S_ContentEnd` ,`S_AddTime` ,`S_Replace` )VALUES ('$S_Name', '$S_Url', '$S_Code', '$S_SourceGo','$S_SourceEnd', '$S_SourceMode', '$S_SourceName', '$S_Page', '$S_AutoPageMode', '$S_UrlStr', '$S_PageGo', '$S_PageEnd', '$S_Order' , '$S_AutoSave', '$S_SavePic', '$S_Safe', '$S_ListGo', '$S_ListEnd', '$S_LinkGo', '$S_LinkEnd', '$S_ArtNameGo', '$S_ArtNameEnd', '$S_RemarkGo', '$S_RemarkEnd', '$S_AuthorMode', '$S_AuthorName', '$S_AuthorGo', '$S_AuthorEnd', '$S_PicGo', '$S_PageMode', '$S_PageUrlGo', '$S_PageUrlEnd', '', '', '$S_PicEnd', '$S_ClassMode', '$S_ClassID', '$S_ClassGo', '$S_ClassEnd', '$S_ContentGo', '$S_ContentEnd', '$S_AddTime', '$S_Replace'

);";

		   if($db->query($sql)){

	 		 echo("规则数据导入成功");

	 		 }

 			else{

			 echo("规则数据导入失败");

	 			}	

		}

	}

?>

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

<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>

<title>舞曲自定义采集规则导出</title>

</head>

<body>

<?php

SystemPer(5);

function imp(){

	global $db;

	echo "<div class=\"r_main\">

	<div class=\"r_content\">

		<div class=\"r_content_1\">

			<table width=\"100%\" border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\"  class=\"tb_style\" >

					<tr>

					  <td height=\"30\"  bgcolor=\"#FFFFFF\" class=\"td_title\" >&nbsp;采集规则导入</td>

				  </tr>

				  	<tr>

						<td height=\"30\"  bgcolor=\"#FFFFFF\" class=\"td_border\" >

							&nbsp;导入方式:<input type=radio class=radio name=mode checked onclick=\"javascript:document.getElementById('mode1').style.display='';document.getElementById('mode2').style.display='none';\">方式①<input type=radio class=radio name=mode onclick=\"javascript:document.getElementById('mode2').style.display='';document.getElementById('mode1').style.display='none';\">方式②

						</td>

					</tr>

					<tr id=mode1>

						<td height=\"30\"  bgcolor=\"#FFFFFF\" class=\"td_border\"  >

						<form enctype=\"multipart/form-data\" action=\"?action=upload&mode=1\" name=\"uploadform\" method=\"post\">&nbsp;

						<input type=\"file\" name= \"file1\" >

  						<input name=\"action\" type=\"hidden\" value=\"upload\" />

						<input type=\"submit\" value=\"上传规则\">

						</form>

						</td>

					</tr>

					<tr id=mode2 style=\"display:none;\">

						<form name=from2 action=\"?action=upload&mode=2\" method=post>

						<td>

						<textarea name=content rows=20 cols=120 style=\"font-family: Arial, Helvetica, sans-serif;\"></textarea>

						<br/>

						<input type=submit value=\"导入采集规则\" class=rb1>

						</td>

						</form>

					</tr>

			</table>	

        </div>

    </div>

</div>";	

	}

	

function main($sid){

	global $db;

	$sql="select * from s_acustom where S_ID=$sid";

	$row=$db->getRow($sql);

	if($row){

		$rule="<s_name>".$row["S_Name"]."</s_name>\r\n";

		$rule.="<s_url>".$row["S_Url"]."</s_url>\r\n";

		$rule.="<s_code>".$row["S_Code"]."</s_code>\r\n";

		$rule.="<s_autopagemode>".$row["S_AutoPageMode"]."</s_autopagemode>\r\n";

		$rule.="<s_sourcemode>".$row["S_SourceMode"]."</s_sourcemode>\r\n";

		$rule.="<s_sourcename>".$row["S_SourceName"]."</s_sourcename>\r\n";

		

		$rule.="<s_sourcego>".$row["S_SourceGo"]."</s_sourcego>\r\n";

		$rule.="<s_sourceend>".$row["S_SourceEnd"]."</s_sourceend>\r\n";

		

		$rule.="<s_page>".$row["S_Page"]."</s_page>\r\n";		

		$rule.="<s_urlstr>".$row["S_UrlStr"]."</s_urlstr>\r\n";

		$rule.="<s_pagego>".$row["S_PageGo"]."</s_pagego>\r\n";

		$rule.="<s_pageend>".$row["S_PageEnd"]."</s_pageend>\r\n";

		$rule.="<s_order>".$row["S_Order"]."</s_order>\r\n";

		$rule.="<s_autosave>".$row["S_AutoSave"]."</s_autosave>\r\n";

		$rule.="<s_safe>".$row["S_Safe"]."</s_safe>\r\n";		

		$rule.="<s_savepic>".$row["S_SavePic"]."</s_savepic>\r\n";

		$rule.="<s_listgo>".$row["S_ListGo"]."</s_listgo>\r\n";

		$rule.="<s_listend>".$row["S_ListEnd"]."</s_listend>\r\n";

		$rule.="<s_linkgo>".$row["S_LinkGo"]."</s_linkgo>\r\n";

		$rule.="<s_linkend>".$row["S_LinkEnd"]."</s_linkend>\r\n";

		$rule.="<s_artnamego>".$row["S_ArtNameGo"]."</s_artnamego>\r\n";	

		$rule.="<s_artnameend>".$row["S_ArtNameEnd"]."</s_artnameend>\r\n";

		

		$rule.="<s_remarkgo>".$row["S_RemarkGo"]."</s_remarkgo>\r\n";	

		$rule.="<s_remarkend>".$row["S_RemarkEnd"]."</s_remarkend>\r\n";

		$rule.="<s_classmode>".$row["S_ClassMode"]."</s_classmode>\r\n";

		$rule.="<s_classid>".$row["S_ClassID"]."</s_classid>\r\n";					

		$rule.="<s_classgo>".$row["S_ClassGo"]."</s_classgo>\r\n";

		$rule.="<s_classend>".$row["S_ClassEnd"]."</s_classend>\r\n";

		

		$rule.="<s_authormode>".$row["S_AuthorMode"]."</s_authormode>\r\n";

		$rule.="<s_authorname>".$row["S_AuthorName"]."</s_authorname>\r\n";

		$rule.="<s_authorgo>".$row["S_AuthorGo"]."</s_authorgo>\r\n";

		$rule.="<s_authorend>".$row["S_AuthorEnd"]."</s_authorend>\r\n";

		

		$rule.="<s_picgo>".$row["S_PicGo"]."</s_picgo>\r\n";

		$rule.="<s_picend>".$row["S_PicEnd"]."</s_picend>\r\n";

		$rule.="<s_contentgo>".$row["S_ContentGo"]."</s_contentgo>\r\n";

		$rule.="<s_contentend>".$row["S_ContentEnd"]."</s_contentend>\r\n";

		

		$rule.="<s_pagemode>".$row["S_PageMode"]."</s_pagemode>\r\n";

		$rule.="<s_pageurlgo>".$row["S_PageUrlGo"]."</s_pageurlgo>\r\n";

		$rule.="<s_pageurlend>".$row["S_PageUrlEnd"]."</s_pageurlend>\r\n";

		$rule.="<s_replace>".$row["S_Replace"]."</s_replace>\r\n";				

		}



	echo "<div class=\"r_main\">

	<div class=\"r_content\">

		<div class=\"r_content_1\">

			<form name=\"form1\" action=\"?action=save\" method=\"post\">

			<table width=\"100%\" border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\"  class=\"tb_style\" >

					<tr>

					  <td height=\"30\"  bgcolor=\"#FFFFFF\" class=\"td_title\">&nbsp;".$row["S_Name"]."采集规则<input type=hidden value=\"".$row["S_Name"]."\" name=sname></td>

				  </tr>

				  	<tr>

						<td height=\"30\"  bgcolor=\"#FFFFFF\" class=\"td_border\">

					<textarea name=content rows=20 cols=120 style=\"font-family: Arial, Helvetica, sans-serif;\">$rule</textarea>

						</td>

					</tr>

					<tr>

						<td height=\"30\"  bgcolor=\"#FFFFFF\" class=\"td_border\"><input type=submit class=rb1 value=\"规则另存为\"></td>

					</tr>

			</table>	

			</form>

        </div>

    </div>

</div>";

	}



  



?> 

       

</body>

</html>

