<?php
/*
'**************************************************************************************************
' 软件名称: 盘锦DJ舞曲网CMS Content Management PjRen.Net
' 版本编号: Version 2.5
' 盘锦舞曲: http://www.pj57.com
' 官方网站: http://www.pjren.net
' 小说网站: http://www.hx39.com
' 0427DJ网: http://www.0427dj.net
' 官方论坛: http://www.tianjiazhen.com
' 版权所有: 盘锦舞曲开发团队    盘锦人(QQ:814006710)
' 郑重声明:
'    1、任何个人或组织不得在未经授权的情况下删除、修改、拷贝本软件及其他副本上一切关于版权的信息；
'    2、盘锦网络事业部保留此软件的法律追究权利
'**************************************************************************************************
*/
require_once("../../include/config.inc.php");
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);
if(S_Webmode==1){die("<font color=red>当前网站为动态模式,不能生成!!</font>");}
$Sel=SafeRequest("sel","get");
if($Sel=="single"){
	$ID=SafeRequest("id","get");
	$ClassID=SafeRequest("cid","get");
	$Mark_Text=SpanArticleShow($ID);
	$spanurl=LinkUrl("s_article",$ClassID,1,$ID);
	$spanurl=substr($spanurl,strlen(S_SitePath));
	spandir($spanurl);
	fwrite(fopen("../../".$spanurl,"wb"),$Mark_Text);
	die("ok");	
	}
if($Sel=="today" or $Sel=="sday"){
	if(file_exists("../../".S_Templateurl."artshow.html")){	
		if($Sel=="sday"){
			$sday=SafeRequest("sdaya","auto");
			$s_title=$sday."天前文章";
			$sql="select * from s_article where S_IsHide=0 and S_ClassID<>0 and DATEDIFF(DATE(S_AddTime),'".date('Y-m-d')."')>=-$sday order by S_ID desc";
			}
		else{
			$sday=1;
			$s_title="当天文章";
			$sql="select * from s_article where S_IsHide=0 and S_ClassID<>0 and DATEDIFF(DATE(S_AddTime),'".date('Y-m-d')."')=0 order by S_ID desc";
			}		
		$Arr=spanpage($sql,S_Createpre);		
		echo("<div style=' width:100%; background: #F9FBFD; border-top:4px solid #DEEFFA; border-bottom:1px solid #DEEFFA;color:#008EBD; font-size:10pt; height:30px; line-height:40px;font-weight:bold; margin:0 auto;'>&nbsp;正在开始生成".$s_title."第<font style='color:red; font-size:16px; font-style:italic'>".$Arr[5]."</font>页数据，共<font style='color:red; font-size:16px; font-style:italic'>".$Arr[6]."</font>页</div>");
		$result=$db->query($Arr[2]);
		if($result){
			while($row=$db->fetch_array($result)){
			$Mark_Text=SpanArticleShow($row['S_ID']);
			$Mark_Text.="<script type='text/javascript' language='javascript' src='".S_SitePath."user/userded.php?id=".$row['S_ID']."'></script>";
			$spanurl=LinkUrl("s_article",$row['S_ClassID'],1,$row['S_ID']);
			$spanurl=substr($spanurl,strlen(S_SitePath));
			spandir($spanurl);
		 	fwrite(fopen("../../".$spanurl,"wb"),$Mark_Text);
	 	    echo "&nbsp;<font style=font-size:10pt;>生成新闻:<font color=red>".$row['S_Name']."</font>成功:<a href=../../".$spanurl." target=_blank>".$spanurl."</a></font><br/>";				
			}
			if($Arr[5]<$Arr[6]){
			echo "<br/>&nbsp;<font style=font-size:10pt;><b>暂停".S_StopTime."秒后继续生成．．．</b></font><script language='javascript'>setTimeout('ReadGo();',".(S_StopTime*1000).");function ReadGo(){location.href='?sel=".$Sel."&sdaya=".$sday."&pages=".($Arr[5]+1)."';}</script>";
				}
			else{
				echo "&nbsp;<font style=font-size:10pt;><b>恭喜你！".$s_title."全部新闻内容生成完毕．．．</b></font>";
				}
		}
	}
	else{
		die("出错了，模板文件不存在！");
	}	
	die();
	}
//生成当天新闻结束	
$ClassID=SafeRequest("NewsClassIDs","post");
if($ClassID==""){
$ClassID=SafeRequest("NewsClassIDs","get");
}
if(!IsNum($ClassID)){die("参数错误!");}
if($ClassID=='0'){
	if(file_exists(_CHSHDJ_ROOT_.S_Templateurl."artshow.html")){		
		$sql="select * from s_article where S_IsHide=0 and S_ClassID<>0";
		$Arr=spanpage($sql,S_Createpre);		
		echo("<div style=' width:100%; background: #F9FBFD; border-top:4px solid #DEEFFA; border-bottom:1px solid #DEEFFA;color:#008EBD; font-size:10pt; height:30px; line-height:40px;font-weight:bold; margin:0 auto;'>&nbsp;正在开始生成第<font style='color:red; font-size:16px; font-style:italic'>".$Arr[5]."</font>页数据，共<font style='color:red; font-size:16px; font-style:italic'>".$Arr[6]."</font>页</div>");
		$result=$db->query($Arr[2]);
		if($result){
			while($row=$db->fetch_array($result)){
			$Mark_Text=SpanArticleShow($row['S_ID']);
			$Mark_Text.="<script type='text/javascript' language='javascript' src='".S_SitePath."user/userded.php?id=".$row['S_ID']."'></script>";
			$spanurl=LinkUrl("s_article",$row['S_ClassID'],1,$row['S_ID']);
			$spanurl=substr($spanurl,strlen(S_SitePath));
			spandir($spanurl);
		 	fwrite(fopen("../../".$spanurl,"wb"),$Mark_Text);
	 	    echo "&nbsp;<font style=font-size:10pt;>生成新闻:<font color=red>".$row['S_Name']."</font>成功:<a href=../../".$spanurl." target=_blank>".$spanurl."</a></font><br/>";				
			}
			if($Arr[5]<$Arr[6]){
			echo "<br/>&nbsp;<font style=font-size:10pt;><b>暂停".S_StopTime."秒后继续生成．．．</b></font><script language='javascript'>setTimeout('ReadGo();',".(S_StopTime*1000).");function ReadGo(){location.href='?NewsClassIDs=0&pages=".($Arr[5]+1)."';}</script>";
				}
			else{
				echo "&nbsp;<font style=font-size:10pt;><b>恭喜你!全部新闻内容生成完毕．．．</b></font>";
				}
		}
	}
	else{
		die("出错了，模板文件不存在！");
		}	
	
	}
else{
	if(file_exists(_CHSHDJ_ROOT_.S_Templateurl."artshow.html")){
		$sqlstr="select S_Name from s_class where S_ID=".$ClassID."";
		$res=$db->getrow($sqlstr);
		
		$sql="select * from s_article where S_IsHide=0 and S_ClassID=".$ClassID."";
		$Arr=spanpage($sql,S_Createpre);		
		echo("<div style=' width:100%; background: #F9FBFD; border-top:4px solid #DEEFFA; border-bottom:1px solid #DEEFFA;color:#008EBD; font-size:10pt; height:30px; line-height:40px;font-weight:bold; margin:0 auto;'>&nbsp;正在开始生成<font style='color:red; font-size:16px; font-style:italic'>".$res['S_Name']."</font>分类的第<font style='color:red; font-size:16px; font-style:italic'>".$Arr[5]."</font>页数据，共<font style='color:red; font-size:16px; font-style:italic'>".$Arr[6]."</font>页</div>");
		$result=$db->query($Arr[2]);
		if($result){
			while($row=$db->fetch_array($result)){
			$Mark_Text=SpanArticleShow($row['S_ID']);
			$Mark_Text.="<script type='text/javascript' language='javascript' src='".S_SitePath."user/userded.php?id=".$row['S_ID']."'></script>";
			$spanurl=LinkUrl("s_article",$row['S_ClassID'],1,$row['S_ID']);
			$spanurl=substr($spanurl,strlen(S_SitePath));
			spandir($spanurl);
		 	fwrite(fopen("../../".$spanurl,"wb"),$Mark_Text);
	 	    echo "&nbsp;<font style=font-size:10pt;>生成新闻:<font color=red>".$row['S_Name']."</font>成功:<a href=../../".$spanurl." target=_blank>".$spanurl."</a></font><br/>";				
			}
			if($Arr[5]<$Arr[6]){
			echo "<br/>&nbsp;<font style=font-size:10pt;>暂停".S_StopTime."秒后继续生成．．．</font><script language='javascript'>setTimeout('ReadGo();',".(S_StopTime*1000).");function ReadGo(){location.href='?NewsClassIDs=".$ClassID."&pages=".($Arr[5]+1)."';}</script>";
				}
			else{
				echo "&nbsp;<font style=font-size:10pt;><b>恭喜你！全部新闻内容全部生成完毕．．．</b></font>";
				}
		}
	}
	else{
		die("出错了，模板文件不存在！");
		}	
	}
?>