<?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、盘锦网络事业部保留此软件的法律追究权利
'**************************************************************************************************
*/
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;
			$editor->BasePath='../../edit';
			$editor->Height=465;
			$editor->Width=650;
			$editor->AutoSave=false;
			
			$S_ID=SafeRequest("S_ID","get");
			if(!IsNum($S_ID)) die("参数传输错误！");
			$sql="select * from s_tempart 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=2 ";
				$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=2 ";
				$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 type="text" name="S_Remark" value="<?php echo $row["S_Remark"]; ?>" size="50" />
                  </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_Source" value="<?php echo $row["S_Source"]; ?>" 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">文章介绍：</td>
                    <td width="866"  align="left" bgcolor="#FFFFFF" class="td_border">					<?php
                      $editor->Create();
					  ?></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;
			$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_tempart 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_tempart where S_Status=0 Order by S_ID desc",30);
		break;
    case 'inflow':
		$ui->mlist("select * from s_tempart where S_Status=1 Order by S_ID desc",30);
		break;
    case 'search':
		$key=SafeRequest("key","get");
		$ui->mlist("select * from s_tempart 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_tempart 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_Remark,S_Content,S_Pic,S_ClassID,S_Author,S_AddTime,S_Topic from s_tempart 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(!IsNul($row['S_Name'])){
			echo "&nbsp;&nbsp;<font color=red>".$row['S_Name']."</font>的数据不完整不能入库<br/>";
			$sqlstatus="update s_tempart set S_Status=2 where S_ID=$S_IDArr[$i]";
			$db->query($sqlstatus);
		}
		else{
			
			//开始入库前判断
			//判断数据是否相同
			$sql2="select S_Name from s_article where S_Name='".$row['S_Name']."'";		
			$row2=$db->getRow($sql2);
			if($row2['S_Name']){	
				//判断数据是否相同
				echo "<font color=red>&nbsp;&nbsp;".$row['S_Name']."</font>数据空中已有这条新闻，已采集完成！<br/>";
				$sqlstatus="update s_tempart set S_Status=1 where S_ID=".$row['S_ID']."";
				$db->query($sqlstatus);

		
			}
			else{//直接添加
				$sql3="Insert s_article (S_Name,S_Remark,S_Pic,S_ClassID,S_Author,S_Content,S_Source,S_AddTime,S_Topic) values ('".$row['S_Name']."','".$row['S_Remark']."','".$row['S_Pic']."',".$row['S_ClassID'].",'".$row['S_Author']."','".$row['S_Content']."','".$row['S_Source']."','".$row['S_AddTime']."','".$row['S_Topic']."')";
				if($db->query($sql3)){
					echo "<font color=red>&nbsp;&nbsp;".$row['S_Name']."</font>数据库中没有记录，已采集完成！<br/>";
					$sqlstatus="update s_tempart 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_tempart 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=2';}</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_Remark,S_Content,S_Pic,S_ClassID,S_Author,S_AddTime,S_Topic from s_tempart  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(!IsNul($row['S_Name'])){
			echo "&nbsp;&nbsp;<font color=red>".$row['S_Name']."</font>的数据不完整不能入库<br/>";
			$sqlstatus="update s_tempart set S_Status=2 where S_ID=$S_IDArr[$i]";
			$db->query($sqlstatus);
		}
		else{
			
			//开始入库前判断
			//判断数据是否相同
			$sql2="select S_Name from s_article where S_Name='".$row['S_Name']."'";		
			$row2=$db->getRow($sql2);
			if($row2['S_Name']){	
				//判断数据是否相同
				echo "<font color=red>&nbsp;&nbsp;".$row['S_Name']."</font>数据空中已有这条新闻，已采集完成！<br/>";
				$sqlstatus="update s_tempart set S_Status=1 where S_ID=".$row['S_ID']."";
				$db->query($sqlstatus);

		
			}
			else{//直接添加
				$sql3="Insert s_article (S_Name,S_Remark,S_Pic,S_ClassID,S_Author,S_Content,S_Source,S_AddTime,S_Topic) values ('".$row['S_Name']."','".$row['S_Remark']."','".$row['S_Pic']."',".$row['S_ClassID'].",'".$row['S_Author']."','".$row['S_Content']."','".$row['S_Source']."','".$row['S_AddTime']."','".$row['S_Topic']."')";
				if($db->query($sql3)){
					echo "<font color=red>&nbsp;&nbsp;".$row['S_Name']."</font>数据库中没有记录，已采集完成！<br/>";
					$sqlstatus="update s_tempart 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_tempart 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_tempart ";
	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_tempart 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_Remark,S_Content,S_Pic,S_ClassID,S_Author,S_AddTime,S_Topic from s_tempart 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(!IsNul($row['S_Name'])){
			echo "&nbsp;&nbsp;<font color=red>".$row['S_Name']."</font>的数据不完整不能入库<br/>";
			$sqlstatus="update s_tempart set S_Status=2 where S_ID=$S_IDArr[$i]";
			$db->query($sqlstatus);
		}
		else{
			
			//开始入库前判断
			//判断数据是否相同
			$sql2="select S_Name from s_article where S_Name='".$row['S_Name']."'";		
			$row2=$db->getRow($sql2);
			if($row2['S_Name']){	
				//判断数据是否相同
				echo "<font color=red>&nbsp;&nbsp;".$row['S_Name']."</font>数据空中已有这条新闻，已采集完成！<br/>";
				$sqlstatus="update s_tempart set S_Status=1 where S_ID=".$row['S_ID']."";
				$db->query($sqlstatus);

		
			}
			else{//直接添加
				$sql3="Insert s_article (S_Name,S_Remark,S_Pic,S_ClassID,S_Author,S_Content,S_Source,S_AddTime,S_Topic,S_Keywords) values ('".$row['S_Name']."','".$row['S_Remark']."','".$row['S_Pic']."',".$row['S_ClassID'].",'".$row['S_Author']."','".$row['S_Content']."','".$row['S_Source']."','".$row['S_AddTime']."','".$row['S_Topic']."','".$S_Keywords."')";
				if($db->query($sql3)){
					echo "<font color=red>&nbsp;&nbsp;".$row['S_Name']."</font>数据库中没有记录，已采集完成！<br/>";
					$sqlstatus="update s_tempart 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_tempart 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_tempart 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_Remark,S_Content,S_Pic,S_ClassID,S_Author,S_AddTime from s_tempart where S_ID=$S_IDArr[$i]";
		
		$row=$db->getRow($sql);
		if(!IsNul($row['S_Name'])){
			echo "&nbsp;&nbsp;<font color=red>".$row['S_Name']."</font>的数据不完整不能入库<br/>";
			$sqlstatus="update s_tempart set S_Status=2 where S_ID=$S_IDArr[$i]";
			$db->query($sqlstatus);
		}
		else{
			
			//开始入库前判断
			//判断数据是否相同
			$sql2="select S_Name from s_article where S_Name='".$row['S_Name']."'";		
			$row2=$db->getRow($sql2);
			if($row2['S_Name']){	
				//判断数据是否相同
				echo "<font color=red>&nbsp;&nbsp;".$row['S_Name']."</font>数据空中已有这条新闻，已采集完成！<br/>";
				$sqlstatus="update s_tempart set S_Status=1 where S_ID=".$row['S_ID']."";
				$db->query($sqlstatus);

		
			}
			else{//直接添加
				$sql3="Insert s_article (S_Name,S_Remark,S_Pic,S_ClassID,S_Author,S_Content,S_Source,S_AddTime,S_Topic) values ('".$row['S_Name']."','".$row['S_Remark']."','".$row['S_Pic']."',".$row['S_ClassID'].",'".$row['S_Author']."','".$row['S_Content']."','".$row['S_Source']."','".$row['S_AddTime']."','".$row['S_Topic']."')";
				if($db->query($sql3)){
					echo "<font color=red>&nbsp;&nbsp;".$row['S_Name']."</font>数据库中没有记录，已采集完成！<br/>";
					$sqlstatus="update s_tempart 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_tempart set S_Status=3 where S_ID=".$row['S_ID']."";
					$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_Source = SafeRequest("S_Source","post");
		$S_AddTime =date('Y-m-d H:i:s');
		//判断
		$sql="update s_tempart 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_Source='".$S_Source."',S_AddTime='".$S_AddTime."',S_Pic='".$S_Pic."' where S_ID=".$S_ID."";
		//die($sql);
		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>
