<?php

/*

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

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

' 版本编号: hshxsdj 2.0

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

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

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

' 郑重声明:

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

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

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

*/


require_once("../../include/config.inc.php");

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

include "../admin_loginstate.php";

@set_time_limit(0);

?>

<?php

SystemPer(11);

if(S_Webmode==1){die("<font color=red>当前网站为动态模式,不能生成!!</font>");}

$Sel=SafeRequest("sel","get");

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

if($Sel=="single"){

	$ClassID=SafeRequest("cid","get");

	$Mark_Text=SpanVideoShow($ID);

	$spanurl=LinkUrl("s_video",$ClassID,1,$ID);

	$spanurl=substr($spanurl,strlen(S_SitePath));

	spandir($spanurl);

	fwrite(fopen("../../".$spanurl,"wb"),$Mark_Text);

	die("ok");

}

?>

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

$sql="select * from s_video where S_ID=".$ID."";

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

if(!IsNul($row['S_Templay']))  $row['S_Templay']="play.html";

if($Sel=="today" or $Sel=="sday"){

	if(file_exists(_CHSHDJ_ROOT_.S_Templateurl.$row['S_Templay'])){	

		if($Sel=="sday"){

			$sday=SafeRequest("sdayv","auto");

			$s_title=$sday."天前舞曲";

			$sql="select * from s_video 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_video 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:30px;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=SpanVideoShow($row['S_ID']);

			$spanurl=LinkUrl("s_video",$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."&sdayv=".$sday."&pages=".($Arr[5]+1)."';}</script>";

				}

			else{

				echo "&nbsp;<font style=font-size:10pt;><b>恭喜你！".$s_title."全部舞曲内容全部生成完毕．．．</b></font><script language='javascript'>setTimeout('ReadGo();',2000);function ReadGo(){location.href='admin_makehtml.php?action=main';}</script>";

				}

		}

	}

	else{

		die("出错了，".$row['S_Templay']."模板文件不存在！");

	}	

	die();

	}

//生成当天舞曲结束	

$ClassID=SafeRequest("ClassIDs","post");

if($ClassID==""){

$ClassID=SafeRequest("ClassIDs","get");

}

if(!IsNum($ClassID)){die("参数错误!");}

if($ClassID=='0'){

	if(file_exists(_CHSHDJ_ROOT_.S_Templateurl.$row['S_Templay'])){		

		$sql="select * from s_video 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:30px;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=SpanVideoShow($row['S_ID']);

			$spanurl=LinkUrl("s_video",$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='?ClassIDs=0&pages=".($Arr[5]+1)."';}</script>";

				}

			else{

				echo "&nbsp;<font style=font-size:10pt;><b>恭喜你!全部舞曲内容全部生成完毕．．．</b></font><script language='javascript'>setTimeout('ReadGo();',2000);function ReadGo(){location.href='admin_makehtml.php?action=main';}</script>";

				}

		}

	}

	else{

		die("出错了，".$row['S_Templay']."模板文件不存在！");

		}	

	

	}

else{

	if(file_exists(_CHSHDJ_ROOT_.S_Templateurl.$row['S_Templay'])){

		$sqlstr="select S_Name from s_class where S_ID=".$ClassID."";

		$res=$db->getrow($sqlstr);

		

		$sql="select * from s_video 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:30px;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=SpanVideoShow($row['S_ID']);

			$spanurl=LinkUrl("s_video",$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='?ClassIDs=".$ClassID."&pages=".($Arr[5]+1)."';}</script>";

				}

			else{

				echo "&nbsp;<font style=font-size:10pt;><b>恭喜你!全部舞曲生成完毕．．．</b></font><script language='javascript'>setTimeout('ReadGo();',2000);function ReadGo(){location.href='admin_makehtml.php?action=main';}</script>";

				}

		}

	}

	else{

		die("出错了，".$row['S_Templay']."模板文件不存在！");

		}	

	}

function PlayFormSel($Url,$PlayForm,$AddPath,$ID){

	if($AddPath!=0 && $AddPath!=""){

		$server=GetAddPath($AddPath);

		}

	else{

		$server="";

		}

	$playurl=$server.$Url;

	$Mark_Text=@file_get_contents("../../js/player/play.html");

	$Mark_Text=ReplaceStr($Mark_Text,'$playshow$',@file_get_contents("../../js/player/".$PlayForm.".html"));

	if($PlayForm!="mp3" && $PlayForm!="cmp" && $PlayForm!="dj95"){

	$Mark_Text=ReplaceStr($Mark_Text,'$width$',S_PlayspWidth);

	$Mark_Text=ReplaceStr($Mark_Text,'$height$',S_PlayspHeight);

		}

	else{

	$Mark_Text=ReplaceStr($Mark_Text,'$width$',S_PlayWidth);

	$Mark_Text=ReplaceStr($Mark_Text,'$height$',S_PlayHeight);

		}

	$Mark_Text=ReplaceStr($Mark_Text,'$s_adloadtime$',S_AdLoadTime);

	$Mark_Text=ReplaceStr($Mark_Text,'$uid$',S_UID);

	$Mark_Text=ReplaceStr($Mark_Text,'{chshdjcms:path}',S_SitePath);

	$Mark_Text=ReplaceStr($Mark_Text,'{chshdjcms:webname}',S_SiteName);

	$Mark_Text=ReplaceStr($Mark_Text,'$spurl$',"".$Url."");

	$Mark_Text=ReplaceStr($Mark_Text,'$url$',"".S_SitePath."include/playurl.php?id=".$ID."");

	return $Mark_Text;

	}	

function GetAddPath($ID){

	global $db;

	$sql="select S_ID,S_AddPath from s_pathip where S_ID=".$ID;

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

	if($row){

              $addpath=$row['S_AddPath'];

        }else{

              $addpath="";

        }

	return $addpath;

}

?>