<?php
/*
'**************************************************************************************************
' 软件名称: 搜一次 Content Management System
' 版本编号: Version 1.X
' 官方网站: http://www.syccms.com
' 官方论坛：http://bbs.syccms.com
' 版权所有: 搜一次运营团队
' 法律顾问: 杭州市元茂律师事务所 严飞律师
' 郑重声明:
'    1、任何个人或组织不得在未经授权的情况下删除、修改、拷贝本软件及其他副本上一切关于版权的信息；
'    2、搜一次网络事业部保留此软件的法律追究权利
'**************************************************************************************************
*/
include "admin_loginstate.php";
include "../include/conn.php";
include "../include/function.php";
include "admin_version.php";
include "../include/userset.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" />
<title>影片管理</title>
<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" type="text/javascript" src="js/jquery.js"></script>
<script language="javascript" type="text/javascript" src="js/video.js"></script>
<script language="javascript" src="js/alerts.js"></script>
<script language="javascript">
$(document).ready(function(){
	$("#addvideo").click(function(){
		var S_Name=$("#S_Name").val();
		var S_ClassID=$("#S_ClassID").val();
		var S_Remark=$("#S_Remark").val();
		var S_Source=$("#S_Source1").val();
		var S_Vdata1=$("#S_Vdata1").val();
	$("#S_Name").css("border-color","#666 #ccc #ccc #666");
	$("#SClassID").text("");
	$("#SSource").text("");
	$("#S_Vdata1").css("border-color","#666 #ccc #ccc #666");
	if(S_Name==""){
		$("#S_Name").css("border","1px solid red");
		$("#SClassID").text("出错了，请填写视频名称！").css("color","red");
		jAlert("出错了，请填写视频名称！","操作提示");
		
		return false;
		}
	else if(S_ClassID=="0"){
		$("#SClassID").text("请选择视频分类！").css("color","red");
		jAlert("出错了，请选择视频分类！","操作提示");
		return false;
		}
	else if(S_Source==""){
		$("#SSource").text("请选择播放源").css("color","red");
		jAlert("出错了，请选择播放源！","操作提示");
		return false;}
	else if(S_Vdata1==""){
		$("#S_Vdata1").css("border","1px solid red");
		$("#S_Vdata1").focus();
		jAlert("出错了，请填写播放地址！","操作提示");
		return false;}

	});
	$("#showvideo1").click(function (){
	window.location='?action=listbylz';
	});
	$("#showvideo2").click(function(){
	window.location='admin_Video.asp?action=listbylz';
	});
	$("#showvideo3").click(function (){
	window.location='admin_Video.asp?action=listbylz&types=unclass';
	});
	$("#S_IsEnd").click(function(){
			var remark=$("#remarkbak").val();				 
			if($(this).attr("checked")==true){
				if(remark==""){
					$("#S_Remark").val("完结");
				}
				else{
					$("#S_Remark").val(remark);
					}
			}
			else{
				$("#S_Remark").val("全集");
				}

		 });
	
	$("#btn_editall").click(function(){
		jConfirm('您确定要执行操作吗?', '操作提示', function(r) {
				if(r==true){formb.submit();}
				});
	 });
	
	$("#delallsel4").click(function(){
		$("#ClassIDs").show();
		$("#TopicID").hide();
		$("#deltypes").hide();
	})
	
	$("#delallsel5").click(function(){
		$("#ClassIDs").hide();
		$("#TopicID").show();
		$("#deltypes").hide();
	})
	
	$("#delallsel1").click(function(){
		$("#ClassIDs").hide();
		$("#TopicID").hide();
		$("#deltypes").show();
	})
	
	$("#delallsel6").click(function(){
		$("#ClassIDs").hide();
		$("#TopicID").hide();
		$("#deltypes").hide();
	})
	
});

function del(id,url){
	jConfirm('您确定要删除该视频吗?', '操作提示', function(r) {
		if(r==true){
			window.location='?action=del&S_ID='+id+'&url='+url;
			}
				});
		
		}
function RemoveData(pid){
		jConfirm('确定移除本组视频数据吗?', '操作提示', function(r) {
				if(r==true){
					$('#'+pid).remove();
					}
				});
	}	
	
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function chgclass(id,cid){
	$.get("js/ajaxfun.php?action=chgclasslist&id="+id+"&cid="+cid+"&sid=1&idddd=<?php echo rand(1111,9999)?>",function(R){
			$("#class_"+id).html(R);												
			})
	}
	
function savechgclass(cid,id){
	$.get("js/ajaxfun.php?action=savecls&id="+id+"&cid="+cid+"&sid=1",function(R){
				$("#class_"+id).html(R);													  
			});
	}
</script>
   

</head>

<body>
<?php
	class ui_video{
		public $classarray;
			function __construct(){
				$sql="select S_ID,S_Name from s_class where S_SystemID=1";
				$resultclass=mysql_query($sql);
				$classarray=array();
				while($rowclass=mysql_fetch_assoc($resultclass)){
					$classarray[$rowclass['S_ID']]=$rowclass['S_Name'];
				}
				$this->classarray=$classarray;
			}
		public function editdata($Arr,$url){
			global $db;
			$playadd=playadd(1);

						$name=$Arr[0];
						$color=$Arr[1];
						$author=$Arr[2];
						$direct=$Arr[3];
						$pic=$Arr[4];
						$reco=$Arr[5];
						$hits=$Arr[6];
						$hide=$Arr[7];
						$key=$Arr[8];
						$remark=$Arr[9];
						$content=$Arr[10];
						$isend=$Arr[11];
						$source=$Arr[12];
						$vdata=$Arr[13];
						$year=$Arr[14];
						$lan=$Arr[15];
						$topic=$Arr[16];
						$class=$Arr[17];
						$area=$Arr[18];
						$path=$Arr[19];
						$S_PurView=$Arr[20];		
			//图片保存路径session
			$_SESSION['imgtypes']="video";
			
			function __construct(){
			}
?>
<script charset="utf-8" src="edit/kindeditor/kindeditor.js"></script>
<script charset="utf-8" src="edit/kindeditor/lang/zh_CN.js"></script>
<script type="text/javascript">
KindEditor.ready(function(K) {
	K.create('#S_Content', {
		resizeType : 2,
		allowPreviewEmoticons : false,
		uploadJson: 'edit/upload.kindeditor.php',
		formatUploadUrl : false,
		allowFileManager : false,
		fillDescAfterUploadImage : true,
		//allowImageUpload : true,
		items : [
			'source', ,'|', 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline',
			'removeformat', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist',
			'insertunorderedlist', '|', 'image', 'link', 'unlink'],
		extraFileUploadParams : {
			module : 'vod',
			type : 'pic'
		},
		afterChange : function() {
			K('#str_count').html(this.count());
		}
	});
	
	K.ctrl(document.body, 'Z', function() {
		document.forms['form1'].submit();
	});
	//取色器开始
	var colorpicker;
	var colorpickerid = K('#colorpicker');
	colorpickerid.bind('click', function(e) {
		e.stopPropagation();
		if (colorpicker) {
			colorpicker.remove();
			colorpicker = null;
			return;
		}
		var colorpickerPos = colorpickerid.pos();
		colorpicker = K.colorpicker({
			colors : [["#FF0000","#E56600","#FF9900","#64451D","#DFC5A4","#FFE500"],["#009900","#006600","#99BB00","#B8D100","#60D978","#00D5FF"],["#337FE5","#003399","#4C33E5","#9933E5","#CC33E5","#EE33EE"],["#FFFFFF","#CCCCCC","#999999","#666666","#333333","#000000"]],
			x : colorpickerPos.x,
			y : colorpickerPos.y + colorpickerid.height(),
			z : 19811214,
			selectedColor : 'default',
			noColor : '无颜色',
			click : function(color) {
				colorpickerid.val(color);
				colorpicker.remove();
				colorpicker = null;
			}
		});
	});
	K(document).click(function() {
		if (colorpicker) {
			colorpicker.remove();
			colorpicker = null;
		}
	});
	//图片上传开始
	var editor = K.editor({
		uploadJson: 'edit/upload.kindeditor.php',
		formatUploadUrl : false,
		extraFileUploadParams : {
			module : 'vod',
			type : 'logo'
		}
	});
	K('#image3').click(function() {
		editor.loadPlugin('image', function() {
			editor.plugin.imageDialog({
				showRemote : false,
				imageUrl : K('#url3').val(),
				clickFn : function(url, title, width, height, border, align) {
					K('#url3').val(url);
					editor.hideDialog();
				}
			});
		});
	});
});
</script>

<div class="r_main">
	<div class="r_content">
		<div class="r_content_1">
			<form action="<?php echo $url?>" method="post" name="form1">
			<input name="lasturl"  type="hidden" value="<?php echo urlencode($_SERVER['HTTP_REFERER']); ?>">
				<table width="100%" border="0" cellpadding="0" cellspacing="0"  class="tb_style">	
							  <tr>
                                <td colspan="3" class="td_title">&nbsp;视频数据&nbsp;&nbsp;[提示：按ctrl + Z可以快速提交保存]</td>
                              </tr>
                              
							  <tr>
								
								<td width="11%"  height="30" class="td_border">&nbsp;视频名称：
							        &nbsp;&nbsp;</td>
							    <td width="89%" class="td_border"><input type="text" name="S_Name" id="S_Name" value="<?php echo $name?>" size="35" />
                                  <font color="#FF0000">＊</font>
                                  颜色：
								  <input type="text" name="S_Color" size="10" value="<?php echo $color;?>" id="colorpicker" />
&nbsp;&nbsp;视频分类：
<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($class==$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><label id="SClassID"></label></td>
							  </tr>
							  <tr>
							    <td  height="30" class="td_border">&nbsp;视频状态：</td>
							    <td class="td_border"><input name="S_Remark" type="text" id="S_Remark" value="<?php if(!IsNul($remark)){echo "全集";}else{echo $remark;}?>" size="35" />
                                <input type="hidden" name="remarkbak" id="remarkbak" value="<?php echo $remark?>"><input type="checkbox" name="S_IsEnd" class="checkbox" id="S_IsEnd"  value="1" <?php if($isend==1){echo "checked";}?>/>
							      是否连载&nbsp;<font color="#FF0000"> ＊如:"连载至X集"或"完结"</font>
							      <label id="S_ClassID"></label></td>
						      </tr>
							  <tr>
								
								<td width="11%" height="30" class="td_border">&nbsp;视频演员：</td>
							    <td height="30" class="td_border"><input name="S_Author" type="text" id="S_Author" value="<?php echo $author?>" size="35">
                                  <input type="checkbox" name="edittime" class="checkbox" id="edittime"   value="1" checked="checked"/>
更新时间</td>
							  </tr>
							  <tr>
								<td width="11%" height="30" class="td_border">&nbsp;图片地址：</td>
							    <td height="30" class="td_border">
								<input type="text" name="S_Pic" id="url3" value="<?php echo $pic?>" size="35" /> <input type="button" id="image3" value="选择图片" /></td>
							  </tr>
							  
							  <tr>
							    <td width="11%" height="30" class="td_border">&nbsp;推荐星级：</td>
						        <td height="30" class="td_border">
<select name="S_Reco" id="S_Reco" style=" color:#FF0000; " >
                                  <option value="0" <?php if($reco==0){echo "selected";}?>>取消</option>
                                  <option value="1" <?php if($reco==1){echo "selected";}?>>一星</option>
                                  <option value="2" <?php if($reco==2){echo "selected";}?>>二星</option>
                                  <option value="3" <?php if($reco==3){echo "selected";}?>>三星</option>
								  <option value="4" <?php if($reco==4){echo "selected";}?>>四星</option>
                                  <option value="5" <?php if($reco==5){echo "selected";}?>>五星</option>
</select>
&nbsp;&nbsp;&nbsp;&nbsp;视频人气：
<input type="text" name="S_Hits" id="S_Hits" value="<?php if(!IsNum($hits)){$hits=0;}?><?php echo $hits?>"  size="5" onkeyup="this.value=this.value.replace(/[^\d]/g,'')" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))"/></td>
							  </tr>
							  <tr>
							    <td height="30" class="td_border">&nbsp;视频导演：</td>
							    <td height="30" class="td_border"><input name="S_Direct" type="text" id="S_Direct" size="35" value="<?php echo $direct?>"/></td>
						      </tr>
						
							  <tr>
								
								<td width="11%" height="30" class="td_border">&nbsp;所属地区：</td>
							    <td height="30" class="td_border"><select name="S_Area" id="S_Area" >
                                <?php
                                if($area!=""){
									echo "<option value=$area>$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($lan==$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 $year?>"></td>
							  </tr>
							  
							  <tr>
							    <td width="11%" height="30" class="td_border">&nbsp;所属专题：</td>
						        <td height="30" class="td_border">
              <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($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="11%" height="30" class="td_border">&nbsp;浏览权限：</td>
						        <td height="30" class="td_border">
								<input type="checkbox" name="S_PurView[]" value="0" class="checkbox" <?php isselect($S_PurView,0)?><?php if(empty($S_PurView)){echo "checked"; }?>/>
								游客浏览&nbsp;&nbsp;
								<?php
								$numbers=0;
								$sqlug="select * from s_usersgroup";
								$resultug=$db->query($sqlug);
								if($resultug){
								while($rowug=$db->fetch_array($resultug)){
                                ?>
								<input type="checkbox" name="S_PurView[]" class="checkbox" value="<?php echo $rowug["S_ID"];?>" <?php isselect($S_PurView,$rowug["S_ID"])?>/><?php echo $rowug["S_Name"];?>&nbsp;&nbsp;<?php
								$numbers=$numbers+1;
								if($numbers%6==0){echo("<br/>");}
								}
								}
								?>                     
                               &nbsp; <font color="#FF0000">&nbsp;＊
                               <?php if(S_VipFun==0){echo "已关闭会员功能";}else{echo "已开启会员功能";}?></font>
                               </td>
                              </tr>

							  <tr>
								
								<td width="11%" height="30" class="td_border">&nbsp;视频标签：</td>
							    <td height="30" class="td_border"><input name="S_Keywords" type="text" id="S_Keywords" size="50" value="<?php echo $key?>"/>
						        <br />
						        <font color="#FF0000">＊ 注意：每个标签关健词可以使用&quot;逗号,空格,|,下划线,&quot;来隔开</font></td>
							  </tr>
							  

						
							  <tr>
								<td height="30" colspan="2" class="td_border">
                               		<div id="playarea">
                                    <?php
                                    	$playarr=explode('$$',$source);
										$dataarr=explode('$$$',$vdata);
										$patharr=explode('$',$path);
										for($P=0;$P<count($playarr);$P++){
											$dataarr[$P]=ReplaceStr($dataarr[$P],"#","\r\n");
									?>
                                        			<table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" id="<?php echo ($P+1)?>">
                                                        <tr>
                                                            <td width="11%" height="30" class="td_border">
                                                                &nbsp;播放来源<?php echo ($P+1)?>：</td>
                                                            <td width="89%" class="td_border">
                                                            <select name="S_Source[]" id="S_Source<?php echo ($P+1)?>">
                                                              <option value=''>暂无数据</option>
                                                              <?php echo playselect($playadd,$playarr[$P]);?>
                                                            </select>
                                                            &nbsp;服务器组:
                                                            <select name="S_Server[]" id="S_Server<?php echo ($P+1)?>">
                                                              <option value="0">服务器组</option>
                                                              <?php echo getAddPath($patharr[$P]);?>
                                                            </select>                                                            
                                                            <font color="#FF0000">＊</font>&nbsp;<?php if($P!=0){?><input type="button" value="移除本组数据" class="rb1" onclick="RemoveData(<?php echo ($P+1)?>)"><?php }?> </td>
                                                        </tr>
                                                        <tr>
                                                            <td width="11%" class="td_border">&nbsp;数据地址<?php echo ($P+1)?>：<br />
                                                             &nbsp;<input type='button' value='校正' title='校正右侧文本框中的数据格式' class='rb1' name="reg" id="<?php echo ($P+1)?>"/></td>
                                                            <td  align="left"><textarea name="S_Vdata[]" id="S_Vdata<?php echo ($P+1)?>" cols="85" rows="8"><?php echo $dataarr[$P]?></textarea>
                                                            <font color="#FF0000">＊</font></td>
                                                      </tr>
														<?php if($P==(count($dataarr)-1)){?>
                                                        	<tr id="btn_addpaly<?php echo $P?>"><td height="30"  colspan="2"  class="td_border">&nbsp;<img onClick="appendplay(<?php echo ($P+1)?>,escape('<?php echo ReplaceStr(playselect($playadd,""),"'","\\'")?>'),0,'<?php echo ReplaceStr(getAddPath(""),"'","\\'")?>')"  name="btn_addpaly" src="images/add.png" id="btn_addplay"  style="cursor:pointer" alt="添加"/></td>
                                                        	</tr>
                                                           

                                                        <?php }?>
                                                    </table>	
                                           <?php
                                           			}
										   ?>         											
                                	</div>                                </td>
							  </tr>

							  <tr>
								<td class="td_border">&nbsp;&nbsp;影片介绍：</td>
							    <td class="td_border"><p></p>
								<textarea rows="15" cols="103" id="S_Content" name="S_Content"><?php echo $content;?></textarea>
								<p>您当前输入了<span id="str_count"></span>字符</p>
								</td>
							  </tr>
							  
							  <tr>
								
								<td height="40" colspan="2" align="center" class="td_border"> &nbsp;
								  <input type="submit" name="Submit" value="确定提交"class="rb1"  id="addvideo"/>
								  &nbsp;&nbsp; <input type="reset" name="reset" value="清除重置" class="rb1"/></td>
							  </tr>
					  </table>
							</form>  
                      		</div>
	</div>
</div>
<?php			
			}
		
		function main($sql,$size){
			global $db;
			$playadd=playadd(1);
			$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">
          <form name="form1" id="form1" method="post">
            <table class="tb_style" border="0"  cellspacing="0" cellpadding="0" >
                <tr>
                  <td class="td_title">&nbsp;视频数据管理&nbsp;[共有<span id="vpicnum" style="color:red;"><img src="images/loading2.gif"></span>张远程图片]&nbsp;&nbsp;[<a href="admin_downpic.php?sid=1"><font color="#FF0000">保存到本地</font></a>]</td>
                </tr>
            </table>
    				 <table class="tb_style" border="0" cellspacing="0" cellpadding="0">
                    <tr>
                      <td height="30" width="70">&nbsp; 关键字:</td>
                      <td align="center" width="150">&nbsp;<input name="keyword" type="text" id="keyword" value=""  onkeydown="event.keyCode==13 && $('#search').click();"/></td>
                      <td align="center" width="70">&nbsp;<input name="搜索" type="button" id="search" value="搜索" class="rb1"  /></td>
                      <td>&nbsp;

                      <select  onchange="MM_jumpMenu('self',this,0)">
                             <option value="admin_video.php">查看分类</option>
             <?php
              	$sqlclass="SELECT * FROM S_class WHERE S_SystemID=1 ";
				$results=$db->query($sqlclass);
				if($results){
					while ($row3=$db->fetch_array($results)){
						echo "<option value='?action=listbycs&S_ID=".$row3['S_ID']."' >".$row3['S_Name']."</option>";
						}
					}
			  
			  ?>             
                      </select>
                       &nbsp;&nbsp;&nbsp;
                       <select  onchange="MM_jumpMenu('self',this,0)">
                            <option value="admin_video.php">播放来源</option>
                            <?php echo playselect2($playadd,"")?>
       				    </select>                      
                       &nbsp;&nbsp;&nbsp;
                       <select  onchange="MM_jumpMenu('self',this,0)">
                            <option value="admin_video.php">查看专题</option>
              <?php
              	$sqlclass="select * from s_topic where S_SystemID=1 ";
				//$results=$db->query($sqlclass);
				$results=@mysql_query($sqlclass) or mysql_error();
				if($results){
					//while ($row3=$db->fetch_array($results)){
					while($row3=@mysql_fetch_assoc($results)){
					echo "<option value='?action=listbytopic&S_ID=".$row3['S_ID']."' >".$row3['S_Name']."</option>";
						}
					}
			  
			  ?>	
            </select>
                       &nbsp;                       
                         <!--<input type="button" id="showvideo1" name="showvideo1" value="查看连载" class="rb1"/>-->
&nbsp;	</td>
                      </tr>
                  </table>
          </form>

				<table width="100%" border="0" cellpadding="0" cellspacing="0"  class="tb_style" >
				  <form method="post" name="formb" action="?action=delall" >
				  <tr>
					<td width="80" height="30" bgcolor="#FFFFFF" class="td_btop3">&nbsp;编号
                    	<?php if($action=="listidup"){?>
                       			 <a href="?action=listiddown"><img src="images/down.gif" border="0" alt="点击按ID升序排列"></a>
                        <?php	}
							else{
						?>
								<a href="?action=listidup"><img src="images/up.gif" border="0" alt="点击按ID升序排列"></a>
						<?php		}?>                    </td>
					<td width="225"  align="center" bgcolor="#FFFFFF" class="td_btop3">视频标题</td>
					<td width="73" align="center"  bgcolor="#FFFFFF" class="td_btop3">人气 
                    	<?php if($action=="listbyhits"){?>
                        <a href="?action=listbyhitsa"><img src="images/up.gif" border="0" alt="点击按人气排序"></a>
                        <?php }else{?>
                         <a href="?action=listbyhits"><img src="images/down.gif" border="0" alt="点击按人气排序"></a>
                        <?php }?>        			</td>
					<td width="110" align="center" bgcolor="#FFFFFF" class="td_btop3">播放来源</td>
					<td width="123" align="center" bgcolor="#FFFFFF" class="td_btop3">视频分类</td>
					<td width="41" align="center" bgcolor="#FFFFFF" class="td_btop3">专题</td>
					<td width="93"  align="center" bgcolor="#FFFFFF" class="td_btop3">推荐星级
                    <?php if($action=="listbyreco"){?>
                    	<a href="?action=listbyrecoa"><img src="images/up.gif" border="0" alt="点击按星级排序"></a>
                    <?php }else{?>
                    	<a href="?action=listbyreco"><img src="images/down.gif" border="0" alt="点击按星级排序"></a>
                    <?php }?>                    </td>
					<td width="113" align="center"  bgcolor="#FFFFFF" class="td_btop3">更新时间
                    <?php if($action=="listbytime"){?>
                    	<a href="?action=listbytimea"><img src="images/up.gif" border="0" alt="点击按星级排序"></a>
                    <?php }else{?>
                    	<a href="?action=listbytime"><img src="images/down.gif" border="0" alt="点击按星级排序"></a>
                    <?php }?>                    </td>
                    <td width="82" align="center" bgcolor="#FFFFFF" class="td_btop3">操 作</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)){
					   ?>  
							<tr>
							  <td height="30" class="td_border" width="80">&nbsp;<label><input type="checkbox" name="S_ID[]" value="<?php echo $row['S_ID']?>" class="checkbox" id="S_ID"/><?php echo $row['S_ID']?></label>、</td>
								<td width="225" align="left" class="td_border">
                                <?php if(SafeRequest("action","get")=="listbysc"){
									$row['S_Name']=ReplaceStr($row['S_Name'],SafeRequest("keyword","get"),"<font color=red>".SafeRequest("keyword","get")."</font>");
									}
									?>
								<a href="<?php echo LinkUrl("s_video",$row['S_ClassID'],1,$row['S_ID'])?>" target="_blank"><font color="<?php echo $row['S_Color']?>"><?php echo $row['S_Name']?></font></a>
                                <?php if($action!="listdel" and $action!="listtmp"){?>
								<?php echo SpanShow("s_video",$row['S_ClassID'],1,$row['S_ID'],"mark/admin_spanvideoshow.php?sel=single")?>
                                <?php }?>
                               <span id="remark_<?php echo $row['S_ID']?>" onclick="window.location='?action=listbylz'" style="cursor:pointer;"> <?php if(IsNul($row['S_Remark'])){echo "<font color=red>[".$row['S_Remark']."]</font>";}?></span>
                               <span id="remarksel" r_id="<?php echo $row['S_ID']?>" style="cursor:hand;"><img src="images/lz.gif"></span>                                </td>
								<td width="73" align="center" class="td_border"><?php echo $row['S_Hits']?></td>
								<td width="90" align="center" class="td_border"><?php echo playaddshow($playadd,$row['S_Source'])?></td>
                                <td width="123" align="center" class="td_border">
                                <span id="class_<?php echo $row['S_ID']?>">
								<?php
									echo $this->classarray[$row['S_ClassID']];
								?><img src="images/edit.gif" onclick="chgclass(<?php echo $row['S_ID']?>,<?php echo $row['S_ClassID']?>)" style="cursor:pointer"></span>								</td>
								<td width="41" align="center" class="td_border"><div id="ss<?php echo $row['S_ID']?>"><span id="topicsel" s_id="<?php echo $row['S_ID']?>" topicid="<?php echo $row['S_Topic']?>" style="cursor:hand;">&nbsp;
							  <?php
                                	if($row['S_Topic']!=0){
										echo "<img src='images/topicyes.gif'>";
										}
									else{
										echo "<img src='images/topicno.gif'>";
										}	
								?></span></div></td>
							  <td width="93" align="center" class="td_border" id="S_Reco<?php echo $row['S_ID']?>"><script language="javascript">ShowStar(<?php echo $row['S_Reco']?>,<?php echo $row['S_ID']?>)</script></td>
								<td width="133" align="center" class="td_border">&nbsp;<?php 
								if(date("Y-m-d",strtotime($row['S_AddTime']))==date('Y-m-d')){
									echo "<font color=red>".date("Y-m-d H:i",strtotime($row['S_AddTime']))."</font>";
									}
								else{
									echo date("Y-m-d H:i",strtotime($row['S_AddTime']));
									}	
								?> </td>
                                <td width="82" align="center"  class="td_border"><A href="?action=editdata&S_ID=<?php echo $row['S_ID']?>">编辑</a>&nbsp; <a style="cursor:pointer;" onclick="del(<?php echo $row['S_ID']?>,'<?php echo urlencode($_SERVER["HTTP_HOST"].$_SERVER["PHP_SELF"]."?".$_SERVER["QUERY_STRING"]) ;?>')" >删除</a></td>
                            </tr>
   <?php
                         							   
		 }
	 }
?> 
				  <tr>
					<td height="30" colspan="10" align="left" class="td_border">&nbsp;<input type="checkbox" name="ChkAll" id="ChkAll" ids="S_ID"  class="checkbox"/>
全选
 &nbsp;&nbsp;
 <input type="radio" name="DelALLSel" id="delallsel1" checked="checked" class="radio" value="1">
 批量删除
 <select class="select" name="deltypes" id="deltypes">
 <?php if($action=="listdel"){?>
 	<option  value="2">还原数据</option>
 <?php }
 else{?>
   	<option  value="3">放入回收站</option>
 <?php }?>   
    <option value="6">直接删除</option>
 </select>
 <input type="radio" name="DelALLSel" id="delallsel4" value="4" class="radio"/>
批量分类
<select name="ClassIDs" id="ClassIDs" style="display:none;">
              <?php
              	$sqlclass="select * from s_class where S_SystemID=1 ";
				$results=$db->query($sqlclass);
				if($results){
					while ($row3=$db->fetch_array($results)){
					echo "<option value='".$row3['S_ID']."' >".$row3['S_Name']."</option>";
						}
					}
			  
			  ?>	
</select>
<input type="radio" name="DelALLSel" id="delallsel5"  value="5" class="radio"/>
批量专题
<select name="TopicID" id="TopicID" style="display:none;">
              <?php
              	$sqlclass="select * from s_topic where S_SystemID=1 ";
				$results=$db->query($sqlclass);
				if($results){
					while ($row3=$db->fetch_array($results)){
					echo "<option value='".$row3['S_ID']."' >".$row3['S_Name']."</option>";
						}
					}
			  
			  ?>	
</select>
<?php if(S_Webmode==0 and $action<>"listdel"){?>
<input type="radio" name="DelALLSel" id="delallsel6"  value="6" class="radio"/>
批量生成&nbsp;&nbsp;
<?php }?>
<input type="button" name="submit1" value="执行操作"  class="rb1" id="btn_editall"/>
<input id="showlist" name="showlist" type="text" value="" style="visibility:hidden"/>
<input id="actiontypes" name="actiontypes" value="<?php echo urlencode($_SERVER['QUERY_STRING']);?>" type="hidden">
&nbsp;</td>
				    </tr>
				  </form>
			  	  <tr>
				    <td height="30" colspan="10" align="right" class="td_border"><?php echo $Arr[0];?></td>
			      </tr>
			  </table>
	  </div>
	</div>
</div>
<script language="javascript">$.get("js/ajaxfun.php?action=getpicnum&sid=1",function(R){$("#vpicnum").html(R);})</script>
<?php			
			}
		}

$ui=new ui_video;
$action=SafeRequest("action","get");
switch($action){
	case 'main':
		$ui->main("select S_Name,S_ID,S_Source,S_AddTime,S_Hits,S_ClassID,S_Remark,S_Reco,S_Topic from s_video where S_IsHide=0 and S_ClassID<>0 order by S_AddTime desc",30);
		break;
	case 'delall':
		delall();
		break;
	case 'listdel':
		listdel();
		break;
	case 'listbysc':
		search();
		break;
	case 'listtmp':
		listtmp();
		break;
	case 'add':
		add();
		break;
	case 'saveadd':
		saveadd();
		break;
	case 'editdata':
		editdata();
		break;
	case 'saveedit':
		saveedit();
		break;
	case 'del':
		del();
		break;
	case 'listbycs':
		listbycs();
		break;
	case 'listbylz':
		listbylz();
		break;
	case 'listbytopic':
		listbytopic();
		break;
	case 'listidup':
		listidup();
		break;
	case 'listbyhits':
		listbyhits();
		break;
	case 'listbyreco':
		listbyreco();
		break;
	case 'listbyrecoa':
		listbyrecoa();
		break;
	case 'listbytime':
		listbytime();
		break;
	case 'listbytimea':
		listbytimea();
		break;
	case 'check':
		check();
		break;
	case 'orderbyplay':
		orderbyplay();
		break;
	default:
		$ui->main("select S_Name,S_Color,S_ID,S_Source,S_AddTime,S_Hits,S_ClassID,S_Remark,S_Reco,S_Topic from s_video  where S_IsHide=0 and S_ClassID<>0 order by S_AddTime desc",30);
		break;
	}
	
	function orderbyplay(){
		global $ui;
		$source=SafeRequest("source","get");
		$ui->main("select S_Name,S_Color,S_ID,S_Source,S_AddTime,S_Hits,S_ClassID,S_Remark,S_Reco,S_Topic from s_video  where S_IsHide=0 and S_ClassID<>0 and S_Source Like '%".$source."%' order by S_ID desc",30);
		}
	
	function listtmp(){
		global $ui;
		$ui->main("select S_Name,S_Color,S_ID,S_Source,S_AddTime,S_Hits,S_ClassID,S_Remark,S_Reco,S_Topic from s_video  where  S_IsHide<>1 and S_ClassID=0 order by S_AddTime desc",30);						
		}
	//时间
	function listbytime(){
		global $ui;
		$ui->main("select S_Name,S_Color,S_ID,S_Source,S_AddTime,S_Hits,S_ClassID,S_Remark,S_Reco,S_Topic from s_video  where  S_IsHide=0 and S_ClassID<>0 order by S_AddTime desc",30);				
		}
	function listbytimea(){
		global $ui;
		$ui->main("select S_Name,S_Color,S_ID,S_Source,S_AddTime,S_Hits,S_ClassID,S_Remark,S_Reco,S_Topic from s_video  where  S_IsHide=0 and S_ClassID<>0 order by S_AddTime asc",30);				
		}	
	
	//星级
	function listbyreco(){
		global $ui;
		$ui->main("select S_Name,S_Color,S_ID,S_Source,S_AddTime,S_Hits,S_ClassID,S_Remark,S_Reco,S_Topic from s_video  where  S_IsHide=0 and S_ClassID<>0 order by S_Reco desc",30);		
		}
	function listbyrecoa(){
		global $ui;
		$ui->main("select S_Name,S_Color,S_ID,S_Source,S_AddTime,S_Hits,S_ClassID,S_Remark,S_Reco,S_Topic from s_video  where S_IsHide=0 and S_ClassID<>0 order by S_Reco asc",30);		
		}	
	//人气
	function listbyhits(){
		global $ui;
		$ui->main("select S_Name,S_Color,S_ID,S_Source,S_AddTime,S_Hits,S_ClassID,S_Remark,S_Reco,S_Topic from s_video  where S_IsHide=0 and S_ClassID<>0 order by S_Hits desc",30);
		}
	function listbyhitsa(){
		global $ui;
		$ui->main("select S_Name,S_Color,S_ID,S_Source,S_AddTime,S_Hits,S_ClassID,S_Remark,S_Reco,S_Topic from s_video  where  S_IsHide=0 and S_ClassID<>0 order by S_Hits asc",30);		
		}	
	//id升序
	function listidup(){
		global $ui;
		$ui->main("select S_Name,S_Color,S_ID,S_Source,S_AddTime,S_Hits,S_ClassID,S_Remark,S_Reco,S_Topic from s_video  where S_IsHide=0 and S_ClassID<>0 order by S_ID asc",30);
		}
	//连载
	function listbylz(){
		global $ui;
		$ui->main("select S_Name,S_Color,S_ID,S_Source,S_AddTime,S_Hits,S_ClassID,S_Remark,S_Reco,S_Topic from s_video  where S_IsEnd=1 and S_IsHide=0 and S_ClassID<>0 order by S_ID desc",30);
		}	
	//查询专题
	function listbytopic(){
		global $ui;
		$S_ID=SafeRequest("S_ID","get");
		$ui->main("select * from s_video where S_Topic=".$S_ID." and S_ClassID<>0 and S_IsHide=0 order by S_ID desc",30);
		}
	
	//查询分类
	function listbycs(){
		global $ui;
		$S_ID=SafeRequest("S_ID","get");
		$ui->main("select S_Name,S_Color,S_ID,S_Source,S_AddTime,S_Hits,S_ClassID,S_Remark,S_Reco,S_Topic from s_video where S_ClassID=$S_ID order by S_AddTime desc",30);
		//$ui->main("select * from s_video where S_ClassID in (Select S_ID from S_Class where S_FatherID=$S_ID) or S_ClassID=$S_ID order by S_ID desc",30);
		}
	function check(){
		global $ui;
		$ui->main("select S_Name,S_Color,S_ID,S_Source,S_AddTime,S_Hits,S_ClassID,S_Remark,S_Reco,S_Topic from s_video where S_Name in (select S_Name from s_video group by S_Name having count(*)>1) order by S_Name asc",30);		
		}
		
	function del(){
		global $db;
		$S_ID=SafeRequest("S_ID","get");
		$LastUrl=SafeRequest("url","get");
		if(substr(strtolower($LastUrl),0,7)!="http://"){
			$LastUrl="http://".$LastUrl; 
		}
		//---->删除图片
		$sql="select S_Pic from s_video where S_ID='".$S_ID."'";
			$result=mysql_query($sql) or die('查询错误');
			$row=mysql_fetch_assoc($result);
			$picurl=$row['S_Pic'];
			$pos=stripos($picurl,'http://');
		if($pos==0){
		}else{
			$picurl='../images/'.S_Vimgfolder.'/'.$picurl;
			if(file_exists($picurl)){
				unlink($picurl);
			}
		}
		//<----
		$sql="delete from s_video where S_ID='".$S_ID."'";
		$clsid=$db->Getrow("select S_ClassID from s_video where S_ID=".$S_ID."");
		if($db->query($sql)){
			if(S_Webmode==0){
				$fileurl=LinkUrl("s_video",$clsid['S_ClassID'],1,$S_ID);
				$fileurl="../".substr($fileurl,strlen(S_SitePath));
				if(file_exists($fileurl)){
					unlink($fileurl);
					}	
				}
			die("<script>jAlert('删除视频数据以及图片成功!','操作提示',function(R){window.location='".$LastUrl."';})</script>");
			}
		else{
			die("<script>jAlert('视频删除失败','操作提示',function(R){window.location='admin_video.php';})</script>");
			}	
		}
	//编辑
	function editdata(){
		global $ui;
		global $db;
		$S_ID=SafeRequest("S_ID","get");
		$sql="Select * from s_video where S_ID=".$S_ID."";
		if($row=$db->Getrow($sql)){
			$Arr=array($row['S_Name'],$row['S_Color'],$row['S_Author'],$row['S_Direct'],$row['S_Pic'],$row['S_Reco'],$row['S_Hits'],$row['S_IsHide'],$row['S_Keywords'],$row['S_Remark'],$row['S_Content'],$row['S_IsEnd'],$row['S_Source'],$row['S_VData'],$row['S_Year'],$row['S_Language'],$row['S_Topic'],$row['S_ClassID'],$row['S_Area'],$row['S_AddPath'],$row['S_PurView']);
			}
		$ui->editdata($Arr,"?action=saveedit&S_ID=".$S_ID."");

		}
	//保存编辑
	function saveedit(){
		global $db;
		$S_ID=SafeRequest("S_ID","get");
		$LastUrl=urldecode(SafeRequest("lasturl","post"));
		$S_Name = SafeRequest("S_Name","post");
		$S_Color = SafeRequest("S_Color","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("S_Content","post");
		$S_Reco = SafeRequest("S_Reco","post");
		$S_IsEnd = SafeRequest("S_IsEnd","post");
		$S_Source = RequestBox("S_Source");
		$S_Vdata = RequestBox("S_Vdata");
		$S_Year = SafeRequest("S_Year","post");
		$S_Area = SafeRequest("S_Area","post");
		$S_Language = SafeRequest("S_Language","post");
		$S_Server=RequestBox("S_Server");
		$S_Hits = SafeRequest("S_Hits","post");
		$S_AddTime =date('Y-m-d H:i:s');
		$S_Direct = SafeRequest("S_Direct","post");
		$S_Keywords1 = SafeRequest("S_Keywords","post");
		$S_PurView = RequestBox("S_PurView");
		$S_EditTime=SafeRequest("edittime","post");
		//判断
		if(!$S_IsEnd){$S_IsEnd=0;}
		if(!IsNul($S_Year)){$S_Year="未知";}
		if(!IsNum($S_Hits)){$S_Hits=0;}
		//处理视频地址和来源
		$tempsource="";
		$tempdata="";
		$SourceArr=explode(",",$S_Source);
		$VDataArr=explode(",",$S_Vdata);
		$ServerArr=explode(",",$S_Server);
		$S_Server=implode('$',$ServerArr);
		for($i=0;$i<count($SourceArr);$i++){
			if(!IsNul($SourceArr[$i])){
				if($i==(count($SourceArr)-1)){$tempsource.='未知';}else{$tempsource.='未知$$';}	
				}
			else{
				if($i==(count($SourceArr)-1)){$tempsource.=$SourceArr[$i];}else{$tempsource.=$SourceArr[$i].'$$';}	
				}
				
			if(!IsNul($VDataArr[$i])){
				if($i==(count($VDataArr)-1)){$tempdata.='无数据';}else{$VdataArr[$i]=ReplaceStr($VdataArr[$i],chr(13).chr(10),"#");$tempdata.='无数据$$$';}	
				}
			else{
				if($i==(count($VDataArr)-1)){$VDataArr[$i]=ReplaceStr($VDataArr[$i],chr(13).chr(10),"#");$tempdata.=$VDataArr[$i];}else{$VDataArr[$i]=ReplaceStr($VDataArr[$i],chr(13).chr(10),"#");$tempdata.=$VDataArr[$i].'$$$';}	
				}	
		}
		$S_Source=$tempsource;
		$S_Vdata=$tempdata;
		if($S_EditTime=='1'){
			$sql="update s_video set S_Name='".$S_Name."',S_Color='".$S_Color."',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_Reco=".$S_Reco.",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_Hits=".$S_Hits.",S_Direct='".$S_Direct."',S_Keywords='".$S_Keywords1."',S_AddTime='".$S_AddTime."',S_AddPath='".$S_Server."',S_PurView='".$S_PurView."' where S_ID=".$S_ID."";
		}else{
			$sql="update s_video set S_Name='".$S_Name."',S_Color='".$S_Color."',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_Reco=".$S_Reco.",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_Hits=".$S_Hits.",S_Direct='".$S_Direct."',S_Keywords='".$S_Keywords1."',S_AddPath='".$S_Server."',S_PurView='".$S_PurView."' where S_ID=".$S_ID."";
			}
		if($db->query($sql)){
			//如果存在缓存，则清理尝试清理缓存
			$huancunurl='../cache/'.md5(md5("c_".$S_ID."_"));
			if(file_exists($huancunurl)){
				unlink($huancunurl);
			}
			//获取分类ID
			$sqlc="select S_ClassID from s_video where S_ID=$S_ID Order by S_ID desc";
			$crow=$db->getrow($sqlc);
			$Url="mark/admin_spanvideoshow.php?sel=single";					
			echo "<script>spango(".$S_ID.",\"".$Url."&cid=".$crow['S_ClassID']."\");</script>";
			die("<script>window.location='".$LastUrl."'</script>");
			}
		else{
			die("<script>jAlert('视频编辑失败','操作提示',function(R){history.back();})</script>");
			}
	}
	
	// 添加视频
	function add(){
		global $ui;
		$Arr=array("","","","","","","","","","","","","","","","","","","","","");
		$ui->editdata($Arr,"?action=saveadd");
		}
	//执行保存
	function saveadd(){
		global $db;
		$S_Name = SafeRequest("S_Name","post");
		$S_Color = SafeRequest("S_Color","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_Reco = SafeRequest("S_Reco","post");
		$S_IsEnd = SafeRequest("S_IsEnd","post");
		$S_Source = RequestBox("S_Source");
		$S_Vdata = RequestBox("S_Vdata");
		$S_Year = SafeRequest("S_Year","post");
		$S_Area = SafeRequest("S_Area","post");
		$S_Language = SafeRequest("S_Language","post");
		$S_Server=RequestBox("S_Server");
		$S_Hits = SafeRequest("S_Hits","post");
		$S_AddTime =date('Y-m-d H:i:s');
		$S_Direct = SafeRequest("S_Direct","post");
		$S_Keywords1 = SafeRequest("S_Keywords","post");
		$S_PurView = RequestBox("S_PurView");
		//判断 
		if(!$S_IsEnd){$S_IsEnd=0;}
		if(!IsNul($S_Year)){$S_Year="未知";}
		if(!IsNum($S_Hits)){$S_Hits=0;}
		
		//处理视频地址和来源
		$tempsource="";
		$tempdata="";
		$SourceArr=explode(",",$S_Source);
		$VDataArr=explode(",",$S_Vdata);
		$ServerArr=explode(",",$S_Server);
		$S_Server=implode('$',$ServerArr);
		for($i=0;$i<count($SourceArr);$i++){
				if(!IsNul($SourceArr[$i])){
				if($i==(count($SourceArr)-1)){$tempsource.='未知';}else{$tempsource.='未知$$';}	
				}
			else{
				if($i==(count($SourceArr)-1)){$tempsource.=$SourceArr[$i];}else{$tempsource.=$SourceArr[$i].'$$';}	
				}
				
			if(!IsNul($VDataArr[$i])){
				if($i==(count($VDataArr)-1)){$tempdata.='$$$';}else{$VDataArr[$i]=ReplaceStr($VDataArr[$i],chr(13).chr(10),"#");$tempdata.='无数据$$$';}	
				}
			else{
				if($i==(count($VDataArr)-1)){$VDataArr[$i]=ReplaceStr($VDataArr[$i],chr(13).chr(10),"#");$tempdata.=$VDataArr[$i];}else{$VDataArr[$i]=ReplaceStr($VDataArr[$i],chr(13).chr(10),"#");$tempdata.=$VDataArr[$i].'$$$';}	
				}	
		}
		$S_Source=$tempsource;
		$S_Vdata=$tempdata;
		
		$sql="Insert s_video (S_Name,S_Color,S_Remark,S_ClassID,S_Topic,S_Pic,S_Author,S_Content,S_Reco,S_IsEnd,S_Source,S_Vdata,S_Year,S_Area,S_Language,S_Hits,S_Direct,S_Keywords,S_AddTime,S_AddPath,S_PurView) values ('".$S_Name."','".$S_Color."','".$S_Remark."',".$S_ClassID.",".$S_Topic.",'".$S_Pic."','".$S_Author."','".$S_ConTent."',".$S_Reco.",".$S_IsEnd.",'".$S_Source."','".$S_Vdata."','".$S_Year."','".$S_Area."','".$S_Language."',".$S_Hits.",'".$S_Direct."','".$S_Keywords1."','".$S_AddTime."','".$S_Server."','".$S_PurView."')";
		if($db->query($sql)){
			die("<script>window.location='admin_video.php'</script>");
			}
		else{
			die("<script>jAlert('视频添加失败','操作提示',function(R){history.back();})</script>");
			}	
		}
	
	//搜索
	function search(){
		global $ui;	
		$key=SafeRequest("keyword","get");
		$key=convert_encoding($key, 'GBK','UTF-8');
		$sql="select * from s_video where  S_Name like '%".$key."%' or S_Author like '%".$key."%'";
		$ui->main($sql,20);
		}
		
	//回收站
	function listdel(){
		global $ui;
		$ui->main("select * from s_video  where S_IsHide=1 ",30);
		}
	
	function delall(){
		global $db;
		$types=urldecode(SafeRequest("actiontypes","post"));
		$showlist=SafeRequest("showlist","post");
		$S_ID=RequestBox("S_ID");
		$S_ID1=RequestBox("S_ID");
		$DelALLSel=SafeRequest("DelALLSel","post");
		if($S_ID=="0"){
			echo "<script>jAlert('请选择要操作的数据?','操作提示',function(R){history.back();})</script>";
			die();
			}
		$Arr=explode(',',$S_ID);
		switch($DelALLSel){
			case '1':
				$DelType=SafeRequest("deltypes","post");
				if($DelType==2){
					for($i=0;$i<count($Arr);$i++){
						$sql="update s_video set S_IsHide=0 where S_ID=".$Arr[$i]."";
						$db->query($sql);
						}
					die("<script>jAlert('数据还原成功了！','操作提示',function(R){window.location='?".$types."';})</script>");
					}
				elseif($DelType==3){
					for($i=0;$i<count($Arr);$i++){
						$sql="update s_video set S_IsHide=1 where S_ID=".$Arr[$i]."";
						$db->query($sql);
						}
					die("<script>jAlert('数据已放入回收站！','操作提示',function(R){window.location='?".$types."';})</script>");						 					}
				else{
					for($i=0;$i<count($Arr);$i++){
						$clsid=$db->getRow("select S_ClassID from s_video where S_ID=".$Arr[$i]."");
						if(S_Webmode==0){
							$fileurl=LinkUrl("s_video",$clsid['S_ClassID'],1,$Arr[$i]);
							$fileurl="../".substr($fileurl,strlen(S_SitePath));
							if(file_exists($fileurl)){
								unlink($fileurl);
							}	
						}
						//---->删除图片
						$sql="select S_Pic from s_video where S_ID='".$Arr[$i]."'";
							$result=mysql_query($sql) or die('查询错误');
							$row=mysql_fetch_assoc($result);
							$picurl=$row['S_Pic'];
							$pos=stripos($picurl,'http://');
						if($pos==FALSE || $pos!=0){
							$picurl='../images/'.S_Vimgfolder.'/'.$picurl;
							if(file_exists($picurl)){
								unlink($picurl);
							}
						}
						//<----
						$sql="delete from s_video where S_ID=".$Arr[$i]."";
						$db->query($sql);
					}
					die('<script type="text/javascript">alert("删除图片成功!\r\n\r\n数据删除成功");window.location="?'.$types.'";</script>');
					/*die("<script>jAlert('数据删除成功!','操作提示',function(R){window.location='?".$types."';})</script>");	*/					 					}	
				break;
			case '4':
				$ClassIDs=SafeRequest("ClassIDs","post");
					for($i=0;$i<count($Arr);$i++){
						$sql="update s_video set S_ClassID=".$ClassIDs." where S_ID=".$Arr[$i]."";
						$db->query($sql);
						}
				die("<script>jAlert('数据转移分类成功!！','操作提示',function(R){window.location='?".$types."';})</script>");
				break;
			case '5':
				$TopicID=SafeRequest("TopicID","post");
					for($i=0;$i<count($Arr);$i++){
						$sql="update s_video set S_Topic=".$TopicID." where S_ID=".$Arr[$i]."";
						$db->query($sql);
						}
				die("<script>jAlert('数据转移专题成功!！','操作提示',function(R){window.location='?".$types."';})</script>");
				break;
			case '6':
				$S_ID=RequestBox("S_ID");
				for($i=0;$i<count($Arr);$i++){
					//获取分类ID
					$sqlc="select S_ClassID from s_video where S_ID=$Arr[$i] Order by S_ID desc";
					$crow=$db->getrow($sqlc);
					$Url="mark/admin_spanvideoshow.php?sel=single";					
					echo "<script>spango(".$Arr[$i].",\"".$Url."&cid=".$crow['S_ClassID']."\");</script>";
					}
				die("<script>jAlert('数据批量生成成功!！','操作提示',function(R){window.location='?".$types."';})</script>");	
				break;
			}
		}
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;	  
	}	
	
	function isselect($S_PurView,$values){
		if(($S_PurView=="0")||($S_PurView=="")){
			
		}
		else{
			$S_PurViewarr=explode(",",$S_PurView);
			for($i=0;$i<count($S_PurViewarr);$i++){
				if($S_PurViewarr[$i]==$values){
					echo("checked");
				}
			}
		}
	}
?>
<?php include "admin_bottom.php"; ?>
</body>
</html>