<?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 "../../../include/userset.php";

@set_time_limit(0);

?>

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

<title>舞曲管理</title>

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

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

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

<script language="javascript" >

 $(document).ready(function(){

	$("#ChkAll").click(function(){

		if($(this).attr("checked")==true){

			$("input[id='S_ID']").each(function(){

				$(this).attr("checked",true);									 

			})							

		}else{

			$("input[id='S_ID']").each(function(){

				$(this).attr("checked",false);									 

			})							

		}

	})



   $("#go1").click(function(){

	if($("input[@type=checkbox]:checked").size()==0){

       		jAlert('请选择你要操作的数据！','操作提示');

       		return false;

    	}

	document.formb.submit();

   })



	$("#go3").click(function(){

		document.formb.action="?action=save&sel=3";

		document.formb.submit();

	})



	$("#go2").click(function(){

		document.formb.action="?action=save&sel=1";

		document.formb.submit();

	})



	$("#delsel").click(function(){

	if($("input[@type=checkbox]:checked").size()==0){

       		jAlert('请选择你要操作的数据！','操作提示');

       		return false;

    	}

		document.formb.action="?action=delsel";

		document.formb.submit();

	})

	

	$("#delall").click(function(){

		document.formb.action="?action=delall";

		document.formb.submit();

	})

})

	function searchshow(){

		var key=$("#searchname").val();

		window.location="?action=search&key="+key;

	}

</script>

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

</head>

<body>

<?php

SystemPer(5);

	class ui_video{

		public function editdata(){

			global $db;

			global $editor;

			$playadd=playadd(4);

			$editor->BasePath='../../../images/edit';

			$editor->Height=465;

			$editor->Width=650;

			$editor->AutoSave=false;

			

			$playadd=playadd(4);

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

			if(!IsNum($S_ID)) die("参数传输错误！");

			$sql="select * from s_zhuangbi where S_ID=$S_ID";

			if($row=$db->Getrow($sql)){

				}

			else{

				die("读取数据错误");

				}

			$editor->Value=	$row['S_Content'];	

?>

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

            <form method="post" name="formb" action="?action=editsave&amp;s_id=<?php echo $S_ID; ?>" >

                <tr>

                  <td colspan="2" class="td_title" height="30">&nbsp;修改采集舞曲</td>

                </tr>

                <tr>

                    <td width="119" height="30" align="right" bgcolor="#FFFFFF" class="td_border">舞曲名称：&nbsp;</td>

                    <td width="866"  align="left" bgcolor="#FFFFFF" class="td_border"><input type="text" name="S_Name" value="<?php echo $row["S_Name"]; ?>" size="50" />

                    <font color="#FF0000">＊</font></td>

                </tr>

				                

                <tr>

                    <td width="119" height="30" align="right" bgcolor="#FFFFFF" class="td_border">舞曲分类：&nbsp;</td>

                  <td width="866"  align="left" bgcolor="#FFFFFF" class="td_border"><select name="S_ClassID" id="S_ClassID">

              <?php

              	$sqlclass="select * from s_class where S_SystemID=1 ";

				$results=$db->query($sqlclass);

				if($results){

					while ($row3=$db->fetch_array($results)){

						if($row['S_ClassID']==$row3['S_ID']){

							echo "<option value='".$row3['S_ID']."' selected='selected'>".$row3['S_Name']."</option>";

							}

						else{

							echo "<option value='".$row3['S_ID']."' >".$row3['S_Name']."</option>";

							}	

						

						}

					}

			  ?>	 

				</select>

                      <font color="#FF0000">＊</font>                 &nbsp;所属专题：

                 <select name="S_Topic" id="S_Topic">

                                  <option value="0">暂无舞曲专题</option>

                                  <?php

              	$sqlclass="select * from s_topic where S_SystemID=1 ";

				$results=$db->query($sqlclass);

				if($results){

					while ($row3=$db->fetch_array($results)){

						if($row['S_Topic']==$row3['S_ID']){

							echo "<option value='".$row3['S_ID']."' selected='selected' >".$row3['S_Name']."</option>";

							}

						else{

							echo "<option value='".$row3['S_ID']."' >".$row3['S_Name']."</option>";

							}	

					

						}

					}

			  

			  ?>

                      </select></td>

                </tr>

                <tr>

                  <td width="119" height="30" align="right" bgcolor="#FFFFFF" class="td_border">舞曲图片：&nbsp;</td>

                  <td width="866"  align="left" bgcolor="#FFFFFF" class="td_border"><input name="S_Pic" type="text" id="S_Pic" value="<?php echo $row["S_Pic"]; ?>" size="50" />

                    <font color="#FF0000">＊</font></td>

                </tr>

                <tr>

                    <td width="119" height="30" align="right" bgcolor="#FFFFFF" class="td_border">舞曲歌手：&nbsp;</td>

                  <td width="866"  align="left" bgcolor="#FFFFFF" class="td_border"><input type="text" name="S_Author" value="<?php echo $row["S_Author"]; ?>" size="50" />

                      <font color="#FF0000">＊</font></td>

                </tr>



                

                <tr>

                    <td width="119" height="30" align="right" bgcolor="#FFFFFF" class="td_border">舞曲地区：&nbsp;</td>

                    <td width="866"  align="left" bgcolor="#FFFFFF" class="td_border"><select name="S_Area">

                                <?php

                                if($row['S_Area']!=""){

									echo "<option value=".$row['S_Area'].">".$row['S_Area']."</option>";

									}

								?>

                                  	<option value="未知">选择地区</option>

                <?php

              	$sqlclass="select * from s_area ";

				$results=$db->query($sqlclass);

				if($results){

					while ($row3=$db->fetch_array($results)){

						if($area==$row3['S_AreaName']){

							echo "<option value='".$row3['S_AreaName']."' selected='selected'>".$row3['S_AreaName']."</option>";

							}

						else{

							echo "<option value='".$row3['S_AreaName']."' >".$row3['S_AreaName']."</option>";

							}	

						

						}

					}

			  ?>

                  </select>

                 &nbsp; 舞曲语言：

                  <select name="S_Language" id="S_Language" >

	<?php

    if($lan!=""){

        echo "<option value=$lan>$lan</option>";

        }

    ?>

  <option value="未知">选择语言</option>

                <?php

              	$sqlclass="select * from s_area ";

				$results=$db->query($sqlclass);

				if($results){

					while ($row3=$db->fetch_array($results)){

						if($row['S_Language']==$row3['S_Language']){

							echo "<option value='".$row3['S_Language']."' selected='selected'>".$row3['S_Language']."</option>";

							}

						else{

							echo "<option value='".$row3['S_Language']."' >".$row3['S_Language']."</option>";

							}	

					

						}

					}

			  ?>                  </select>

                 &nbsp; 发行年份：

                 <input id="S_Year" name="S_Year" size="8" value="<?php echo $row['S_Year'];?>">

                  </strong></strong></td>

                </tr>

							  <tr>

								<td height="30" colspan="2" class="td_border">

                               		<div id="playarea">

                                    <?php

																			

											$data=ReplaceStr($row['S_VData'],"#","\r\n");

									?>

                                        			<table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">

                                                        <tr>

                                                            <td width="119" height="30" class="td_border">

                                                                &nbsp;播放来源：</td>

                                                            <td width="866" class="td_border">

                                                            <select name="S_Source" id="S_Source">

                                                              <option value=''>暂无数据</option>

                                                              <?php echo playselect($playadd,$row['S_Source']);?>

                                                            </select>

                                                            &nbsp;服务器组:

                                                            <select name="S_Server" id="S_Server">

                                                              <option value="0">服务器组</option>

                                                              <?php echo getAddPath($row['S_AddPath']);?>

                                                            </select>                                                            

                                                            <font color="#FF0000">＊</font>&nbsp;</td>

                                                        </tr>

                                                        <tr>

                                                            <td width="119" class="td_border">&nbsp;数据地址：</td>

                                                            <td  align="left"><textarea name="S_Vdata" id="S_Vdata" cols="85" rows="8"><?php echo $data; ?></textarea>

                                                            <font color="#FF0000">＊</font></td>

                                                      </tr>



                                                    </table>	

         											

                                	</div>                                </td>

							  </tr>

                <tr>

                    <td width="119" height="30" align="right" bgcolor="#FFFFFF" class="td_border">&nbsp;</td>

                    <td width="866"  align="center" bgcolor="#FFFFFF" class="td_border"><input name="submit1" type="submit" class="rb1" value=" 完 成 "  /></td>

                </tr>

              </form>

          </table>      

        </div>

    </div>

</div>        

<?php				

			}

		public function mlist($sql,$size){

			global $db;

			$playadd=playadd(4);

			$Arr=getpagerow($sql,$size);//sql,每页显示条数

			$result=$db->query($Arr[2]);

			$videonum=$db->num_rows($result);

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

?>

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

          <form method="post" name="formb" id="formb" action="?action=save&amp;sel=2" >

                <tr>

                  <td height="30" colspan="4" bgcolor="#FFFFFF" class="td_title">&nbsp;<a href="admin_inflow.php?action=inflow">已入库数据</a>　＞＞　<a href="admin_inflow.php?action=unflow">未入库数据</a>　＞＞　<a href="admin_inflow.php">所有数据</a></td>

                  <td colspan="6" bgcolor="#FFFFFF" class="td_title">关健字搜索：<span >

                    <input type="text" name="searchname" id="searchname" />

                    <input name="button" type="button" class="rb1" onclick="searchshow()" value="搜 索"/>

                  </span></td>

                </tr>

                <tr>

                  <td height="30" bgcolor="#FFFFFF" class="td_border">编号</td>

                  <td width="183"  align="center" bgcolor="#FFFFFF" class="td_border">舞曲名称</td>

                  <td width="72" align="center"  bgcolor="#FFFFFF" class="td_border">入库状态</td>

                    <td width="73" align="center" bgcolor="#FFFFFF" class="td_border">播放类型</td>

                    <td width="101" align="center" bgcolor="#FFFFFF" class="td_border">栏目分类</td>

                    <td width="191" align="center" bgcolor="#FFFFFF" class="td_border">采集站点</td>

                     <td width="149" align="center" bgcolor="#FFFFFF" class="td_border">添加时间</td>

                    <td colspan="3" align="center" bgcolor="#FFFFFF" class="td_border">操 作</td>

                </tr>

                       <?php

					   if($videonum==0) echo "

							<tr>

                            	<td colspan=\"8\" class=\"td_border\" height=\"30\" align=center><b>暂无舞曲,请添加</b></td>

                            </tr>";

                       if($result){

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

					   ?> 

                        

                      <td height="30" class="td_border" width="94" align="left"><input type="checkbox" name="S_ID[]" value="<?php echo $row['S_ID'];?>"  class="checkbox" id="S_ID"/><?php echo $row['S_ID'];?></td>

                        <td width="183" align="centent" class="td_border"><?php echo $row['S_Name'];?></td>

                      <td width="72" align="center" class="td_border"><?php 

					  if($row['S_Status']=='1'){ 

					  	echo "<font color='green'>已入库</font>";

						}elseif($row['S_Status']=='2'){

							echo "<font color=red>数据不完整</font>";

						}elseif($row['S_Status']=='3'){

							echo "<font color=red>入库失败</font>";

						}else{ 

						echo "未入库";} ?></td>

                        <td width="73" align="center" class="td_border"><?php echo $row["S_Source"] ?></td>

                        <td width="101" align="center" class="td_border">

								<?php

                                	$res=$db->getrow("select S_Name from s_class where S_ID=".$row['S_ClassID']."");

									if($res){

										echo $res['S_Name'];

										}

									else{

										echo "暂无分类";

										}	

								?>

						</td>

                      <td width="191" class="td_border"> &nbsp;<?php echo $row["S_Url"];?></td>

                      <td width="149" align="center" class="td_border"><?php 

								if(date("Y-m-d",strtotime($row['S_AddTime']))==date('Y-m-d')){

									echo "<font color=red>".date("Y-m-d",strtotime($row['S_AddTime']))."</font>";

									}

								else{

									echo date("Y-m-d",strtotime($row['S_AddTime']));

									}

									?></td>

                        

                        <td width="77" align="center"  class="td_border"><a href="?action=edit&amp;S_ID=<?php echo $row['S_ID'];?>">编辑</a> <a href="?action=del&amp;S_ID=<?php echo $row['S_ID'];?>" onclick="" >删除</a></td>

                    </tr>

   <?php

                         							   

		 }

	 }

?>

            </form>

              <tr>

              	<td headers="30" align="left" class="td_border"><input type="checkbox" name="ChkAll" id="ChkAll"  class="checkbox"/>&nbsp;&nbsp;全 选</td>

                <td height="30" colspan="12" align="left" class="td_border">&nbsp;&nbsp;<input name="go1" type="button" class="rb1" id="go1" value="入库所选数据" />

                &nbsp;&nbsp;<input name="go2" type="button" class="rb1" id="go2" value="入库所有数据" />

                &nbsp;&nbsp;

                <input name="go3" type="button" class="rb1" id="go3" value="入库当天数据" />

                &nbsp;&nbsp;<input name="delsel" type="button" class="rb1" id="delsel" value="删除所选数据" />

                &nbsp;&nbsp;<input name="delall" type="button" class="rb1" id="delall" value="删除全部数据" /></td>

              </tr>

              <tr>

              	

                <td height="30" colspan="12" align="right" class="td_border"><?php echo $Arr[0];?></td>

              </tr>

          </table>

			</div>

		</div>

    </div>          

<?			

			}			

		}

include_once('../../../images/edit/sinaEditor.class.php');

$editor=new sinaEditor('gently_editor');		

$ui=new ui_video;

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

switch ($action){

	case 'main':

		$ui->mlist("select * from s_zhuangbi order by S_ID desc",30);

		break;

	case 'edit':

		$ui->editdata();

		break;

	case 'editsave':

		editSave();

		break;

	case 'del':

		del();

		break;

	case 'delall':

		delall();

		break;

    case 'unflow':

		$ui->mlist("select * from s_zhuangbi where S_Status=0 Order by S_ID desc",30);

		break;

    case 'inflow':

		$ui->mlist("select * from s_zhuangbi where S_Status=1 Order by S_ID desc",30);

		break;

    case 'search':

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

		$ui->mlist("select * from s_zhuangbi where S_Name like '%".$key."%'",30);

		break;

    case 'save':

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

		switch($sel){

			case '2':

				SelIn();

				break;

			case '1':

				SelAll();

				break;

			case '3':

				SelDay();

				break;

			case '4':

				SelNow();

				break;

				

		}

		break;

	case 'delsel':

		DelSel();

		break;

	default:

		$ui->mlist("select * from s_zhuangbi order by S_ID desc",30);

		break;		

	}



function SelNow(){

	global $db;

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

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

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

	if(!IsNul($pages)) $pages=1;

	$sql="select S_ID,S_Name,S_Source,S_VData,S_IsEnd,S_Remark,S_Language,S_Area,S_Year,S_Content,S_Pic,S_ClassID,S_Direct,S_Author,S_AddTime,S_AddPath from s_zhuangbi where S_Url='$url' Order by S_ID desc";

	$size=20;

	$Arr=getpagerow($sql,$size);//sql,每页显示条数

	$result=$db->query($Arr[2]);

	 if($result){

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

			//------------

			if($row['S_IsEnd']==""){$row['S_IsEnd']=0;}

			if($row['S_Area']==""){$row['S_Area']="未知";}

			if($row['S_Language']==""){$row['S_Language']="未知";}

			if($row['S_Year']==""){$row['S_Year']="未知";}	

		if(!IsNul($row['S_Name']) or !IsNul($row['S_Source']) or !IsNul($row['S_VData'])){

			echo "&nbsp;&nbsp;<font color=red>".$row['S_Name']."</font>的数据不完整不能入库<br/>";

			$sqlstatus="update s_zhuangbi set S_Status=2 where S_ID=$S_IDArr[$i]";

			$db->query($sqlstatus);

		}

		else{

			

			//开始入库前判断

			//判断数据是否相同

			$sql2="select S_ID,S_Name,S_Source,S_VData from s_video where S_Name='".$row['S_Name']."'";		

			$row2=$db->getRow($sql2);

			if($row2['S_Name']){	

				//判断数据是否相同

				if($row2['S_Source']==$row['S_Source'] && $row['S_VData']==$row2['S_VData']){

					echo "&nbsp;&nbsp;<font color=red>".$row2['S_Name']."</font>数据相同,暂不需要更新<br/>";

					$sqlstatus="update s_zhuangbi set S_Status=1 where S_ID=$S_IDArr[$i]";

					$db->query($sqlstatus);		

					}

				else{

					//判断追加数据还是更新数据

					if(stristr($row2['S_Source'],$row['S_Source'])){//更新数据

						$Temp_Source=explode('$$',$row['S_Source']);

						$Temp_Data=explode('$$$',$row['S_VData']);

						for($k=0;$k<count($Temp_Source);$k++){

							if($Temp_Source[$k]==$row['S_Source']){

								$Temp_VData[$k]=$row['S_VData'];

								 }							

							}

						$R_VData=join("$$$",$Temp_VData);

						$S_Source=$row2['S_Source'];

						$S_VData=$R_VData;

						}

					else{//追加

						$S_Source=$row2['S_Source'].'$$'.$row['S_Source'];

						$S_VData=$row2['S_VData'].'$$$'.$row['S_VData'];

						}	

					//执行入库更新处理

						 $sql="update s_video set S_Remark='".$S_VData."',S_ClassID=".$row['S_ClassID'].",S_Author='".$row['S_Author']."',S_Content='".$row['S_Content']."',S_IsEnd=".$row['S_IsEnd'].",S_Source='".$S_Source."',S_Vdata='".$S_VData."',S_Year='".$row['S_Year']."',S_Area='".$row['S_Area']."',S_Language='".$row['S_Language']."',S_Direct='admin',S_AddTime='".$row['S_AddTime']."',S_AddPath='".$row['S_AddPath']."',S_Templay='".$row['S_Remark']."' where S_ID=".$row2['S_ID']."";

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

							 echo "&nbsp;&nbsp;<font color=red>".$row['S_Name']."&nbsp;".$row['S_Remark']."</font>&nbsp;&nbsp;数据有变动，数据已更新完成！<br>";

							$sqlstatus="update s_zhuangbi set S_Status=1 where S_ID=".$row['S_ID']."";

							$db->query($sqlstatus);	

								 }

						  else{

							 echo "&nbsp;&nbsp;<font color=red>".$row['S_Name']."&nbsp;".$row['S_Remark']."</font>&nbsp;&nbsp;数据有变动，但数据更新失败！<br>";

							$sqlstatus="update s_zhuangbi set S_Status=3 where S_ID=".$row['S_ID']."";

							$db->query($sqlstatus);							

						  }

						unset($Temp_Source);

						unset($Temp_Data);

					}



		

			}

			else{//直接添加

				$sql3="Insert s_video (S_Name,S_Remark,S_Pic,S_ClassID,S_Author,S_Content,S_Direct,S_IsEnd,S_Source,S_VData,S_Year,S_Area,S_Language,S_AddTime,S_AddPath,S_Templay) values ('".$row['S_Name']."','".$row['S_VData']."','".$row['S_Pic']."',".$row['S_ClassID'].",'".$row['S_Author']."','".$row['S_Content']."','admin',".$row['S_IsEnd'].",'".$row['S_Source']."','".$row['S_VData']."','".$row['S_Year']."','".$row['S_Area']."','".$row['S_Language']."','".$row['S_AddTime']."','".$row['S_AddPath']."','".$row['S_Remark']."')";

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

					echo "<font color=red>&nbsp;&nbsp;".$row['S_Name']."</font>数据库中没有记录，已采集完成！<br/>";

					$sqlstatus="update s_zhuangbi set S_Status=1 where S_ID=".$row['S_ID']."";

					$db->query($sqlstatus);

						}

				else{

					echo "<font color=red>&nbsp;&nbsp;".$row['S_Name']."</font>数据库中没有记录，但入库失败！<br/>";

					$sqlstatus="update s_zhuangbi set S_Status=3 where S_ID=".$row['S_ID']."";

					$db->query($sqlstatus);

					}

	

			}

		}

			//-----------------

			}

	if($pages>=$Arr[3]){

		if($ispic=='1'){

			die("&nbsp;&nbsp;恭喜,采集的舞曲已经入库完毕!&nbsp;暂停3秒开始同步图片!<script language='javascript'>setTimeout('ReadGo();',3000);function ReadGo(){location.href='../../admin_downpic.php?sid=1';}</script>");

			}

		else{

			die("&nbsp;&nbsp;恭喜,采集的舞曲已经入库完毕!");

			}			

		}

	else{

		die("&nbsp;&nbsp;采集的舞曲第".$pages."页入库完毕，暂停3秒继续下一页.<script language='javascript'>setTimeout('ReadGo();',3000);function ReadGo(){location.href='?action=save&sel=4&url=".$url."&pages=".($pages+1)."&ispic=".$ispic."';}</script>");

		}

	 }	

	}



function SelAll(){

	global $db;

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

	if(!IsNul($pages)) $pages=1;

	$sql="select S_ID,S_Name,S_Source,S_VData,S_IsEnd,S_Remark,S_Language,S_Area,S_Year,S_Content,S_Pic,S_ClassID,S_Direct,S_Author,S_AddTime,S_AddPath from s_zhuangbi  Order by S_ID desc";

	$size=20;

	$Arr=getpagerow($sql,$size);//sql,每页显示条数

	$result=$db->query($Arr[2]);

	 if($result){

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

			//------------

			if($row['S_IsEnd']==""){$row['S_IsEnd']=0;}

			if($row['S_Area']==""){$row['S_Area']="未知";}

			if($row['S_Language']==""){$row['S_Language']="未知";}

			if($row['S_Year']==""){$row['S_Year']="未知";}	

		if(!IsNul($row['S_Name']) or !IsNul($row['S_Source']) or !IsNul($row['S_VData'])){

			echo "&nbsp;&nbsp;<font color=red>".$row['S_Name']."</font>的数据不完整不能入库<br/>";

			$sqlstatus="update s_zhuangbi set S_Status=2 where S_ID=".$row['S_ID']."";

			$db->query($sqlstatus);

		}

		else{

			

			//开始入库前判断

			//判断数据是否相同

			$sql2="select S_ID,S_Name,S_Source,S_VData from s_video where S_Name='".$row['S_Name']."'";		

			$row2=$db->getRow($sql2);

			if($row2['S_Name']){	

				//判断数据是否相同

				if($row2['S_Source']==$row['S_Source'] && $row['S_VData']==$row2['S_VData']){

					echo "&nbsp;&nbsp;<font color=red>".$row2['S_Name']."</font>数据相同,暂不需要更新<br/>";

					$sqlstatus="update s_zhuangbi set S_Status=1 where S_ID==".$row['S_ID']."";

					$db->query($sqlstatus);		

					}

				else{

					//判断追加数据还是更新数据

					if(stristr($row2['S_Source'],$row['S_Source'])){//更新数据

						$Temp_Source=explode('$$',$row['S_Source']);

						$Temp_Data=explode('$$$',$row['S_VData']);

						for($k=0;$k<count($Temp_Source);$k++){

							if($Temp_Source[$k]==$row['S_Source']){

								$Temp_VData[$k]=$row['S_VData'];

								 }							

							}

						$R_VData=join("$$$",$Temp_VData);

						$S_Source=$row2['S_Source'];

						$S_VData=$R_VData;

						}

					else{//追加

						$S_Source=$row2['S_Source'].'$$'.$row['S_Source'];

						$S_VData=$row2['S_VData'].'$$$'.$row['S_VData'];

						}	

					//执行入库更新处理

						 $sql="update s_video set S_Remark='".$S_VData."',S_ClassID=".$row['S_ClassID'].",S_Author='".$row['S_Author']."',S_Content='".$row['S_Content']."',S_IsEnd=".$row['S_IsEnd'].",S_Source='".$S_Source."',S_Vdata='".$S_VData."',S_Year='".$row['S_Year']."',S_Area='".$row['S_Area']."',S_Language='".$row['S_Language']."',S_Direct='admin',S_AddTime='".$row['S_AddTime']."',S_AddPath='".$row['S_AddPath']."',S_Templay='".$row['S_Remark']."' where S_ID=".$row2['S_ID']."";

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

							 echo "&nbsp;&nbsp;<font color=red>".$row['S_Name']."&nbsp;".$row['S_Remark']."</font>&nbsp;&nbsp;数据有变动，数据已更新完成！<br>";

							$sqlstatus="update s_zhuangbi set S_Status=1 where S_ID=".$row['S_ID']."";

							$db->query($sqlstatus);	

								 }

						  else{

							 echo "&nbsp;&nbsp;<font color=red>".$row['S_Name']."&nbsp;".$row['S_Remark']."</font>&nbsp;&nbsp;数据有变动，但数据更新失败！<br>";

							$sqlstatus="update s_zhuangbi set S_Status=3 where S_ID=".$row['S_ID']."";

							$db->query($sqlstatus);							

						  }

						unset($Temp_Source);

						unset($Temp_Data);

					}



		

			}

			else{//直接添加

				$sql3="Insert s_video (S_Name,S_Remark,S_Pic,S_ClassID,S_Author,S_Content,S_Direct,S_IsEnd,S_Source,S_VData,S_Year,S_Area,S_Language,S_AddTime,S_AddPath,S_Templay) values ('".$row['S_Name']."','".$row['S_VData']."','".$row['S_Pic']."',".$row['S_ClassID'].",'".$row['S_Author']."','".$row['S_Content']."','admin',".$row['S_IsEnd'].",'".$row['S_Source']."','".$row['S_VData']."','".$row['S_Year']."','".$row['S_Area']."','".$row['S_Language']."','".$row['S_AddTime']."','".$row['S_AddPath']."','".$row['S_Remark']."')";

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

					echo "<font color=red>&nbsp;&nbsp;".$row['S_Name']."</font>数据库中没有记录，已采集完成！<br/>";

					$sqlstatus="update s_zhuangbi set S_Status=1 where S_ID=".$row['S_ID']."";

					$db->query($sqlstatus);

						}

				else{

					echo "<font color=red>&nbsp;&nbsp;".$row['S_Name']."</font>数据库中没有记录，但入库失败！<br/>";

					$sqlstatus="update s_zhuangbi set S_Status=3 where S_ID=".$row['S_ID']."";

					$db->query($sqlstatus);

					}

	

			}

		}

			//-----------------

			}

	if($pages>=$Arr[3]){

		die("&nbsp;&nbsp;恭喜,全部采集舞曲已经入库完毕!");

		}

	else{

		die("&nbsp;&nbsp;采集舞曲第$pages页入库完毕，暂停3秒继续下一页.<script language='javascript'>setTimeout('ReadGo();',3000);function ReadGo(){location.href='?action=save&sel=3&pages=".($pages+1)."';}</script>");

		}

	 }	

}



function delall(){

	global $db;

	$sql="delete from s_zhuangbi ";

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

		die("<script>jAlert('采集舞曲删除成功!!','操作提示',function(R){window.location='admin_inflow.php';})</script>");

	}

	else{

		die("<script>jAlert('采集舞曲删除失败!!','操作提示',function(R){window.location='admin_inflow.php';})</script>");

	}

}



function DelSel(){

	global $db;

	$S_ID=RequestBox("S_ID","post");

	$sql="delete from s_zhuangbi where S_ID in ($S_ID)";

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

		die("<script>jAlert('采集舞曲删除成功!!','操作提示',function(R){window.location='admin_inflow.php';})</script>");

		}

	else{

		die("<script>jAlert('采集舞曲删除失败!!','操作提示',function(R){window.location='admin_inflow.php';})</script>");

	}

}



function SelDay(){

	global $db;

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

	if(!IsNul($pages)) $pages=1;

	$sql="select S_ID,S_Name,S_Source,S_VData,S_IsEnd,S_Remark,S_Language,S_Area,S_Year,S_Content,S_Pic,S_ClassID,S_Direct,S_Author,S_AddTime,S_AddPath from s_zhuangbi where DATEDIFF(DATE(S_AddTime),'".date('Y-m-d')."')=0 Order by S_ID desc";

	$size=20;

	$Arr=getpagerow($sql,$size);//sql,每页显示条数

	$result=$db->query($Arr[2]);

	 if($result){

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

			//------------

			if($row['S_IsEnd']==""){$row['S_IsEnd']=0;}

			if($row['S_Area']==""){$row['S_Area']="未知";}

			if($row['S_Language']==""){$row['S_Language']="未知";}

			if($row['S_Year']==""){$row['S_Year']="未知";}	

		if(!IsNul($row['S_Name']) or !IsNul($row['S_Source']) or !IsNul($row['S_VData'])){

			echo "&nbsp;&nbsp;<font color=red>".$row['S_Name']."</font>的数据不完整不能入库<br/>";

			$sqlstatus="update s_zhuangbi set S_Status=2 where S_ID='".$row['S_ID']."'";

			$db->query($sqlstatus);

		}

		else{

			

			//开始入库前判断

			//判断数据是否相同

			$sql2="select S_ID,S_Name,S_Source,S_VData from s_video where S_Name='".$row['S_Name']."'";		

			$row2=$db->getRow($sql2);

			if($row2['S_Name']){	

				//判断数据是否相同

				if($row2['S_Source']==$row['S_Source'] && $row['S_VData']==$row2['S_VData']){

					echo "&nbsp;&nbsp;<font color=red>".$row2['S_Name']."</font>数据相同,暂不需要更新<br/>";

					$sqlstatus="update s_zhuangbi set S_Status=1 where S_ID='".$row['S_ID']."'";

					$db->query($sqlstatus);		

					}

				else{

					//判断追加数据还是更新数据

					if(stristr($row2['S_Source'],$row['S_Source'])){//更新数据

						$Temp_Source=explode('$$',$row['S_Source']);

						$Temp_Data=explode('$$$',$row['S_VData']);

						for($k=0;$k<count($Temp_Source);$k++){

							if($Temp_Source[$k]==$row['S_Source']){

								$Temp_VData[$k]=$row['S_VData'];

								 }							

							}

						$R_VData=join("$$$",$Temp_VData);

						$S_Source=$row2['S_Source'];

						$S_VData=$R_VData;

						}

					else{//追加

						$S_Source=$row2['S_Source'].'$$'.$row['S_Source'];

						$S_VData=$row2['S_VData'].'$$$'.$row['S_VData'];

						}	

					//执行入库更新处理

						 $sql="update s_video set S_Remark='".$S_VData."',S_ClassID=".$row['S_ClassID'].",S_Author='".$row['S_Author']."',S_Content='".$row['S_Content']."',S_IsEnd=".$row['S_IsEnd'].",S_Source='".$S_Source."',S_Vdata='".$S_VData."',S_Year='".$row['S_Year']."',S_Area='".$row['S_Area']."',S_Language='".$row['S_Language']."',S_Direct='admin',S_AddTime='".$row['S_AddTime']."',S_AddPath='".$row['S_AddPath']."',S_Templay='".$row['S_Remark']."' where S_ID=".$row2['S_ID']."";

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

							 echo "&nbsp;&nbsp;<font color=red>".$row['S_Name']."&nbsp;".$row['S_Remark']."</font>&nbsp;&nbsp;数据有变动，数据已更新完成！<br>";

							$sqlstatus="update s_zhuangbi set S_Status=1 where S_ID=".$row['S_ID']."";

							$db->query($sqlstatus);	

								 }

						  else{

							 echo "&nbsp;&nbsp;<font color=red>".$row['S_Name']."&nbsp;".$row['S_Remark']."</font>&nbsp;&nbsp;数据有变动，但数据更新失败！<br>";

							$sqlstatus="update s_zhuangbi set S_Status=3 where S_ID=".$row['S_ID']."";

							$db->query($sqlstatus);							

						  }

						unset($Temp_Source);

						unset($Temp_Data);

					}



		

			}

			else{//直接添加

				$sql3="Insert s_video (S_Name,S_Remark,S_Pic,S_ClassID,S_Author,S_Content,S_Direct,S_IsEnd,S_Source,S_VData,S_Year,S_Area,S_Language,S_AddTime,S_AddPath,S_Templay) values ('".$row['S_Name']."','".$row['S_VData']."','".$row['S_Pic']."',".$row['S_ClassID'].",'".$row['S_Author']."','".$row['S_Content']."','admin',".$row['S_IsEnd'].",'".$row['S_Source']."','".$row['S_VData']."','".$row['S_Year']."','".$row['S_Area']."','".$row['S_Language']."','".$row['S_AddTime']."','".$row['S_AddPath']."','".$row['S_Remark']."')";

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

					echo "<font color=red>&nbsp;&nbsp;".$row['S_Name']."</font>数据库中没有记录，已采集完成！<br/>";

					$sqlstatus="update s_zhuangbi set S_Status=1 where S_ID=".$row['S_ID']."";

					$db->query($sqlstatus);

						}

				else{

					echo "<font color=red>&nbsp;&nbsp;".$row['S_Name']."</font>数据库中没有记录，但入库失败！<br/>";

					$sqlstatus="update s_zhuangbi set S_Status=3 where S_ID=".$row['S_ID']."";

					$db->query($sqlstatus);

					}

	

			}

		}

			//-----------------

			}

	if($pages>=$Arr[3]){

		die("&nbsp;&nbsp;恭喜,当天舞曲已经入库完毕!");

		}

	else{

		die("&nbsp;&nbsp;当天采集舞曲第$pages页入库完毕，暂停3秒继续下一页.<script language='javascript'>setTimeout('ReadGo();',3000);function ReadGo(){location.href='?action=save&sel=3&pages=".($pages+1)."';}</script>");

		}

	 }

}



function del(){

	global $db;

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

	$sql="delete from s_zhuangbi where S_ID=$S_ID";

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

		die("<script>window.location='admin_inflow.php'</script>");

		}

	else{

		die("<script>jAlert('数据删除失败!','操作提示',function(R){history.go(-1);})</script>");

	}



}



function SelIn(){

	global $db;

	$S_IDs=RequestBox("S_ID");

	//die($S_IDs);

	$S_IDArr=explode(',',$S_IDs);

	for($i=0;$i<count($S_IDArr);$i++){

		$sql="select S_ID,S_Name,S_Source,S_VData,S_IsEnd,S_Remark,S_Language,S_Area,S_Year,S_Content,S_Pic,S_ClassID,S_Direct,S_Author,S_AddTime,S_AddPath from s_zhuangbi where S_ID=$S_IDArr[$i]";

		

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

		if($row['S_IsEnd']==""){$row['S_IsEnd']=0;}

		if($row['S_Area']==""){$row['S_Area']="未知";}

		if($row['S_Language']==""){$row['S_Language']="未知";}

		if($row['S_Year']==""){$row['S_Year']="未知";}

		if(!IsNul($row['S_Name']) or !IsNul($row['S_Source']) or !IsNul($row['S_VData'])){

			echo "&nbsp;&nbsp;<font color=red>".$row['S_Name']."</font>的数据不完整不能入库<br/>";

			$sqlstatus="update s_zhuangbi set S_Status=2 where S_ID=$S_IDArr[$i]";

			$db->query($sqlstatus);

		}

		else{

			

			//开始入库前判断

			//判断数据是否相同

			$sql2="select S_ID,S_Name,S_Source,S_VData from s_video where S_Name='".$row['S_Name']."'";		

			$row2=$db->getRow($sql2);

			if($row2['S_Name']){	

				//判断数据是否相同

				if($row2['S_Source']==$row['S_Source'] && $row['S_VData']==$row2['S_VData']){

					echo "&nbsp;&nbsp;<font color=red>".$row2['S_Name']."</font>数据相同,暂不需要更新<br/>";

					$sqlstatus="update s_zhuangbi set S_Status=1 where S_ID=$S_IDArr[$i]";

					$db->query($sqlstatus);							

					}

				else{

					//判断追加数据还是更新数据

					if(stristr($row2['S_Source'],$row['S_Source'])){//更新数据

						$Temp_Source=explode('$$',$row['S_Source']);

						$Temp_Data=explode('$$$',$row['S_VData']);

						for($k=0;$k<count($Temp_Source);$k++){

							if($Temp_Source[$k]==$row['S_Source']){

								$Temp_VData[$k]=$row['S_VData'];

								 }							

							}

						$R_VData=join("$$$",$Temp_VData);

						$S_Source=$row2['S_Source'];

						$S_VData=$R_VData;

						}

					else{//追加

						$S_Source=$row2['S_Source'].'$$'.$row['S_Source'];

						$S_VData=$row2['S_VData'].'$$$'.$row['S_VData'];

						}	

					//执行入库更新处理

						 $sql="update s_video set S_Remark='".$S_VData."',S_ClassID=".$row['S_ClassID'].",S_Author='".$row['S_Author']."',S_Content='".$row['S_Content']."',S_IsEnd=".$row['S_IsEnd'].",S_Source='".$S_Source."',S_Vdata='".$S_VData."',S_Year='".$row['S_Year']."',S_Area='".$row['S_Area']."',S_Language='".$row['S_Language']."',S_Direct='admin',S_AddTime='".$row['S_AddTime']."',S_AddPath='".$row['S_AddPath']."',S_Templay='".$row['S_Remark']."' where S_ID='".$row2['S_ID']."'";

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

							 echo "&nbsp;&nbsp;<font color=red>".$row['S_Name']."&nbsp;".$row['S_Remark']."</font>&nbsp;&nbsp;数据有变动，数据已更新完成！<br>";

							$sqlstatus="update s_zhuangbi set S_Status=1 where S_ID=$S_IDArr[$i]";

							$db->query($sqlstatus);	

								 }

						  else{

							 echo "&nbsp;&nbsp;<font color=red>".$row['S_Name']."&nbsp;".$row['S_Remark']."</font>&nbsp;&nbsp;数据有变动，数据已更新失败！<br>";

							$sqlstatus="update s_zhuangbi set S_Status=3 where S_ID=$S_IDArr[$i]";

							$db->query($sqlstatus);							

						  }

						unset($Temp_Source);

						unset($Temp_Data);

					}



		

			}

			else{//直接添加

				$sql3="Insert s_video (S_Name,S_Remark,S_Pic,S_ClassID,S_Author,S_Content,S_Direct,S_IsEnd,S_Source,S_VData,S_Year,S_Area,S_Language,S_AddTime,S_AddPath,S_Templay) values ('".$row['S_Name']."','".$row['S_VData']."','".$row['S_Pic']."',".$row['S_ClassID'].",'".$row['S_Author']."','".$row['S_Content']."','admin',".$row['S_IsEnd'].",'".$row['S_Source']."','".$row['S_VData']."','".$row['S_Year']."','".$row['S_Area']."','".$row['S_Language']."','".$row['S_AddTime']."','".$row['S_AddPath']."','".$row['S_Remark']."')";

				

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

					echo "<font color=red>&nbsp;&nbsp;".$row['S_Name']."</font>数据库中没有记录，已采集完成！<br/>";

					$sqlstatus="update s_zhuangbi set S_Status=1 where S_ID=$S_IDArr[$i]";

					$db->query($sqlstatus);

						}

				else{

					echo "<font color=red>&nbsp;&nbsp;".$row['S_Name']."</font>数据库中没有记录，但入库失败！<br/>";

					$sqlstatus="update s_zhuangbi set S_Status=3 where S_ID=$S_IDArr[$i]";

					$db->query($sqlstatus);

					}

	

			}

		}

	}



}

function editSave(){

	

		global $db;

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

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

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

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

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

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

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

		$S_ConTent = SafeRequest("gently_editor","post");

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

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

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

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

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

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

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

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

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

		//判断

		if(!$S_IsEnd){$S_IsEnd=0;}

		if(!IsNul($S_Year)){$S_Year="未知";}

		$S_Vdata=ReplaceStr($S_Vdata,chr(13).chr(10),'#');

		$sql="update s_zhuangbi set S_Name='".$S_Name."',S_Remark='".$S_Remark."',S_ClassID=".$S_ClassID.",S_Topic=".$S_Topic.",S_Pic='".$S_Pic."',S_Author='".$S_Author."',S_Content='".$S_ConTent."',S_IsEnd=".$S_IsEnd.",S_Source='".$S_Source."',S_Vdata='".$S_Vdata."',S_Year='".$S_Year."',S_Area='".$S_Area."',S_Language='".$S_Language."',S_Direct='admin',S_AddTime='".$S_AddTime."',S_AddPath='".$S_Server."' where S_ID=".$S_ID."";

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

			die("<script>window.location='admin_inflow.php'</script>");

			}

		else{

			die("<script>jAlert('采集舞曲编辑失败','操作提示',function(R){history.back();})</script>");

			}

	}



function getAddPath($path){

	global $db;

	$serverstr="";

	$sqlserver="select S_ID,S_Name from `s_pathip`";

	$resultserver=$db->query($sqlserver);

	  if($resultserver){

		  while($rowserver=$db->fetch_array($resultserver)){

			  if($path==$rowserver['S_ID']){

			  $serverstr.="<option value='".$rowserver['S_ID']."' selected='selected'>".$rowserver['S_Name']."</option>";

			  }

			  else{

			  $serverstr.="<option value='".$rowserver['S_ID']."'>".$rowserver['S_Name']."</option>";	

				  }	

			  }

		  }

	return $serverstr;	  

	}

	





?>	

</body>

</html>

