<?php
/*
'**************************************************************************************************
' 软件名称: 搜一次 Content Management System
' 版本编号: Version 1.X
' 官方网站: http://www.yixiu.cc
' 官方论坛：http://bbs.yixiu.cc
' 版权所有: 搜一次运营团队
' 郑重声明:
'    1、任何个人或组织不得在未经授权的情况下删除、修改、拷贝本软件及其他副本上一切关于版权的信息；
'    2、搜一次网络事业部保留此软件的法律追究权利
' @author YGH 2012-12-13
'**************************************************************************************************
*/
include "../../admin_loginstate.php";
include "../../../include/conn.php";
include "../../../include/function.php";
include "../../admin_version.php";

$data = array (
  'id' => 0,'name' => '','targeturl' => '','charset' => 1,'player' => 'qvod','collecturl' => '','collecttype' => 2,'type' => 0,'pictype' => 0,'list' => '','listhref' => '','title' => '','state' => '','class' => '','direct' => '','author' => '','area' => '','language' => '','year' => '','pic' => '','content' => '','playmode' => 1,'playrange' => '','webplayurl' => '','urlmode' => 0,'playurl' => '','urlreplace' => '','contentreplace' => '','finish' => '','collecttime' => '',
);

if (isset($_GET['edit'])) {
	$id = intval($_GET['edit']);
	$data = $db->getAll('select * from s_vodrule where id='.$id);
	if ($data) {
		$data = $data[0];
		$data['bintype'] = str_split(strrev(str_pad(decbin($data['type']),3,0,STR_PAD_LEFT)));
	}	
}

$class = getClassInfo(1);
$area = getAreaInfo();

?>
<!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  href="../../images/style.css" rel="stylesheet" type="text/css" />
<link type="text/css" href="../../images/alerts.css" rel="stylesheet" media="screen" />
<title>自定义采集</title>
<script type="text/javascript" src="../../js/base.js"></script>
<script type="text/javascript" src="../../js/jquery.js"></script>
<script type="text/javascript">
$(function(){
	$('textarea').focus(function(){
		$(this).offsetParent('table').find('textarea').css({'height':'73px', 'border':'1px #ccc solid'});
		$(this).css('border', '1px #FF0000 solid');
		// 最小高度
		var minHeight = 73; 
		h = this.scrollHeight; 
		h = h > minHeight ? h : minHeight; 
		$(this).css('height', h + 'px');
	});
});
</script>
</head>

<body>
<div class="r_main">
	<div class="r_content">
		<div class="r_content_1">
			<form name="form2" action="rulesave.php?action=<?php if($data['id']==0):?>add<?php else: ?>save<?php endif; ?>&page=2" method="post">
				<input type="hidden" name="id" value="<?php echo intval($_GET['id']);?>" />
				<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0"  class="tb_style" >
					<tr>
						<td height="30" colspan="2" bgcolor="#FFFFFF" class="td_title">&nbsp;添加采集规则&nbsp;１. 设置基本参数及列表连接设置 <font color="red">2. 采集内容与影片地址设置</font> 3. 完成并采集测试</td>
					</tr>
					<tr>
						<td width="126" height="30" align="right" bgcolor="#FFFFFF" class="td_border">视频名称正则代码：&nbsp;</td>
						<td width="617"  align="left" bgcolor="#FFFFFF" class="td_border">&nbsp;
							<textarea name="title" id="S_title" cols="70" rows="4"><?php echo $data['title'];?></textarea>
							<a href="javascript:insertAtCursor(document.getElementById('S_title'),'{$内容}')">{$内容}</a></td>
					</tr>
					<tr>
						<td width="126" height="30" align="right" bgcolor="#FFFFFF" class="td_border">视频状态正则代码：&nbsp;</td>
						<td width="617"  align="left" bgcolor="#FFFFFF" class="td_border">&nbsp;
							<textarea name="state" id="S_state" cols="70" rows="4"><?php echo $data['state'];?></textarea><a href="javascript:insertAtCursor(document.getElementById('S_state'),'{$内容}')">{$内容}</a></td>
					</tr>
					<tr><?php $isnumClass = is_numeric($data['class']) ? 1 : 0;?>
						<td width="126" height="30" align="right" bgcolor="#FFFFFF" class="td_border">视频分类采集设置：&nbsp;</td>
						<td width="617"  align="left" bgcolor="#FFFFFF" class="td_border">&nbsp;
							<input type="radio" name="classMode" value="0"  class="radio"<?php if($isnumClass):?> checked="checked"<?php endif;?> onclick="document.getElementById('s_classid0').style.display='';document.getElementById('s_classid1').style.display='none';" />
							固定分类&nbsp;&nbsp;&nbsp;&nbsp;
							<input type="radio" name="classMode" value="1"  class="radio"<?php if(!$isnumClass):?> checked="checked"<?php endif;?> onclick="document.getElementById('s_classid1').style.display='';document.getElementById('s_classid0').style.display='none';"/>
							自动转换</td>
					</tr>
					<tr id="s_classid0"<?php if(!$isnumClass):?> style="display:none;"<?php endif;?>>
						<td width="126" height="30" align="right" bgcolor="#FFFFFF" class="td_border">固定视频分类选择：&nbsp;</td>
						<td width="617"  align="left" bgcolor="#FFFFFF" class="td_border">&nbsp;
							<select name="class1">
								<?php foreach ($class as $key=>$value) {?><option value="<?php echo $key;?>"<?php if($data['class']==$key):?> selected="selected"<?php endif;?>><?php echo $value;?></option><?php }?>
							</select></td>
					</tr>
					<tr id="s_classid1"<?php if($isnumClass):?> style="display:none;"<?php endif;?>>
						<td width="126" height="30" align="right" bgcolor="#FFFFFF" class="td_border">视频分类正则代码：&nbsp;</td>
						<td width="617"  align="left" bgcolor="#FFFFFF" class="td_border">&nbsp;
							<textarea name="class2" id="S_class2" cols="70" rows="4"><?php echo $data['class'];?></textarea><a href="javascript:insertAtCursor(document.getElementById('S_class2'),'{$内容}')">{$内容}</a></td>
					</tr>
					<tr><?php $isnumArea = strpos($data['area'],'{$内容}')===false ? 1 : 0;?>
						<td width="126" height="30" align="right" bgcolor="#FFFFFF" class="td_border">视频地区采集设置：&nbsp;</td>
						<td width="617"  align="left" bgcolor="#FFFFFF" class="td_border">&nbsp;
							<input type="radio" name="areaMode" value="0" class="radio"<?php if($isnumArea):?> checked="checked"<?php endif;?> onclick="document.getElementById('s_areamode0').style.display='';document.getElementById('s_areamode1').style.display='none';" />
							固定地区&nbsp;&nbsp;&nbsp;&nbsp;
							<input type="radio" name="areaMode" value="1" class="radio"<?php if(!$isnumArea):?> checked="checked"<?php endif;?> onclick="document.getElementById('s_areamode1').style.display='';document.getElementById('s_areamode0').style.display='none';" />
							采集地区 </td>
					</tr>
					<tr id="s_areamode0"<?php if(!$isnumArea):?> style="display:none;"<?php endif;?>>
						<td width="126" height="30" align="right" bgcolor="#FFFFFF" class="td_border">固定视频地区选择：&nbsp;</td>
						<td width="617"  align="left" bgcolor="#FFFFFF" class="td_border">&nbsp;
							<select name="area1">
								<?php foreach ($area as $key=>$value) {?><option value="<?php echo $key;?>"<?php echo $value['area'];?>"<?php if($data['area']==$value['area']):?> selected="selected"<?php endif;?>><?php echo $value['area'];?></option><?php }?>
							</select></td>
					</tr>
					<tr id="s_areamode1"<?php if($isnumArea):?> style="display:none;"<?php endif;?>>
						<td width="126" height="30" align="right" bgcolor="#FFFFFF" class="td_border">视频地区正则代码：&nbsp;</td>
						<td width="617"  align="left" bgcolor="#FFFFFF" class="td_border">&nbsp;
							<textarea name="area2" id="S_area2" cols="70" rows="4"><?php echo $data['area'];?></textarea><a href="javascript:insertAtCursor(document.getElementById('S_area2'),'{$内容}')">{$内容}</a></td>
					</tr>
					<tr><?php $isnumLanguage = strpos($data['language'],'{$内容}')===false ? 1 : 0;?>
						<td width="126" height="30" align="right" bgcolor="#FFFFFF" class="td_border">视频语言要集设置：&nbsp;</td>
						<td width="617"  align="left" bgcolor="#FFFFFF" class="td_border">&nbsp;
							<input type="radio" name="languageMode" value="0"  class="radio"<?php if($isnumLanguage):?> checked="checked"<?php endif;?> onclick="document.getElementById('s_language0').style.display='';document.getElementById('s_language1').style.display='none';" />
							固定语言&nbsp;&nbsp;&nbsp;&nbsp;
							<input type="radio" name="languageMode" value="1" class="radio"<?php if(!$isnumLanguage):?> checked="checked"<?php endif;?> onclick="document.getElementById('s_language1').style.display='';document.getElementById('s_language0').style.display='none';" />
							采集语言</td>
					</tr>
					<tr id="s_language0"<?php if(!$isnumLanguage):?> style="display:none;"<?php endif;?>>
						<td width="126" height="30" align="right" bgcolor="#FFFFFF" class="td_border">固定视频语言选择：&nbsp;</td>
						<td width="617" align="left" bgcolor="#FFFFFF" class="td_border">&nbsp;
							<select name="language1">
								<?php foreach ($area as $key=>$value) {?><option value="<?php echo $value['language'];?>"<?php if($data['language']==$value['language']):?> selected="selected"<?php endif;?>><?php echo $value['language'];?></option><?php }?>
							</select></td>
					</tr>
					<tr id="s_language1"<?php if($isnumLanguage):?> style="display:none;"<?php endif;?>>
						<td width="126" height="30" align="right" bgcolor="#FFFFFF" class="td_border">视频语言正则代码：&nbsp;</td>
						<td width="617"  align="left" bgcolor="#FFFFFF" class="td_border">&nbsp;
							<textarea name="language2" id="S_language2" cols="70" rows="4"><?php echo $data['language'];?></textarea><a href="javascript:insertAtCursor(document.getElementById('S_language2'),'{$内容}')">{$内容}</a></td>
					</tr>
					<tr>
						<td width="126" height="30" align="right" bgcolor="#FFFFFF" class="td_border">视频导演正则代码：&nbsp;</td>
						<td width="617"  align="left" bgcolor="#FFFFFF" class="td_border">&nbsp;
							<textarea name="direct" id="S_direct" cols="70" rows="4"><?php echo $data['direct'];?></textarea><a href="javascript:insertAtCursor(document.getElementById('S_direct'),'{$内容}')">{$内容}</a></td>
					</tr>
					<tr>
						<td width="126" height="30" align="right" bgcolor="#FFFFFF" class="td_border">视频演员正则代码：&nbsp;</td>
						<td width="617"  align="left" bgcolor="#FFFFFF" class="td_border">&nbsp;
							<textarea name="author" id="S_author" cols="70" rows="4"><?php echo $data['author'];?></textarea><a href="javascript:insertAtCursor(document.getElementById('S_author'),'{$内容}')">{$内容}</a></td>
					</tr>
					<tr>
						<td width="126" height="30" align="right" bgcolor="#FFFFFF" class="td_border">发行年份正则代码：&nbsp;</td>
						<td width="617"  align="left" bgcolor="#FFFFFF" class="td_border">&nbsp;
							<textarea name="year" id="S_year" cols="70" rows="4"><?php echo $data['year'];?></textarea><a href="javascript:insertAtCursor(document.getElementById('S_year'),'{$内容}')">{$内容}</a></td>
					</tr>
					<?php if(isset($_GET['pictype']) && $_GET['pictype']==1):?>
					<?php else: ?>
					<tr>
						<td width="126" height="30" align="right" bgcolor="#FFFFFF" class="td_border">视频图片正则代码：&nbsp;</td>
						<td width="617"  align="left" bgcolor="#FFFFFF" class="td_border">&nbsp;
							<textarea name="pic" id="S_pic" cols="70" rows="4"><?php echo $data['pic'];?></textarea><a href="javascript:insertAtCursor(document.getElementById('S_pic'),'{$内容}')">{$内容}</a></td>
					</tr><?php endif;?>
					<tr>
						<td width="126" height="30" align="right" bgcolor="#FFFFFF" class="td_border">视频介绍正则代码：&nbsp;</td>
						<td width="617"  align="left" bgcolor="#FFFFFF" class="td_border">&nbsp;
							<textarea name="content" id="S_content" cols="70" rows="4"><?php echo $data['content'];?></textarea><a href="javascript:insertAtCursor(document.getElementById('S_content'),'{$内容}')">{$内容}</a></td>
					</tr>
					<tr>
						<td width="126" height="30" align="right" bgcolor="#FFFFFF" class="td_border">视频地址范围正则代码：&nbsp;</td>
						<td width="617"  align="left" bgcolor="#FFFFFF" class="td_border">&nbsp;
							<textarea name="playrange" id="S_playrange" cols="70" rows="4"><?php echo $data['playrange'];?></textarea><a href="javascript:insertAtCursor(document.getElementById('S_playrange'),'{$内容}')">{$内容}</a></td>
					</tr>
					<tr>
						<td width="126" height="30" align="right" bgcolor="#FFFFFF" class="td_border">视频地址采集模式：&nbsp;</td>
						<td width="617"  align="left" bgcolor="#FFFFFF" class="td_border">&nbsp;
							<input type="radio" name="playmode" value="1" class="radio"<?php if($data['playmode']==1):?> checked="checked"<?php endif;?> onclick="javascript:$('.playmode1').hide();" />
							内容页采集视频地址&nbsp;&nbsp;&nbsp;&nbsp;
							<input type="radio" name="playmode" value="2" class="radio"<?php if($data['playmode']==2):?> checked="checked"<?php endif;?> onclick="javascript:$('.playmode1').show();" />
							播放页采集视频地址</td>
					</tr>
					<tr class="playmode1"<?php if($data['playmode']==1):?> style="display:none;"<?php endif;?>>
						<td width="126" height="30" align="right" bgcolor="#FFFFFF" class="td_border" id="s_playurlgo">播放页链接正则代码：&nbsp;</td>
						<td width="617"  align="left" bgcolor="#FFFFFF" class="td_border">&nbsp;
							<textarea name="webplayurl" id="S_webplayurl" cols="70" rows="4"></textarea>
							<a href="javascript:insertAtCursor(document.getElementById('S_webplayurl'),'{$内容}')">{$内容}</a>
							<a href="javascript:insertAtCursor(document.getElementById('S_webplayurl'),'{$过滤}')">{$过滤}</a></td>
					</tr>
					<tr class="playmode1"<?php if($data['playmode']==1):?> style="display:none;"<?php endif;?>>
						<td width="126" height="30" align="right" bgcolor="#FFFFFF" class="td_border">特殊播放链接处理：&nbsp;</td>
						<td width="617"  align="left" bgcolor="#FFFFFF" class="td_border">&nbsp;
							<input type="radio" name="urlMode" value="0" class="radio"<?php if($data['urlmode']==0):?> checked="checked"<?php endif;?> onclick="javascript:$('#s_add1').hide();" />
							不作设置&nbsp;&nbsp;&nbsp;&nbsp;
							<input type="radio" name="urlMode" value="1" class="radio"<?php if($data['urlmode']==1):?> checked="checked"<?php endif;?> onclick="javascript:$('#s_add1').show();" />
							替换地址<br /></td>
					</tr>
					<tr>
						<td id="s_add0" colspan="2" height="0" class=""></td>
					</tr>
					<tr id="s_add1" class="playmode1" <?php if($data['playmode']==1 || $data['urlmode']==0):?> style="display:none;"<?php endif;?>>
						<td width="126" height="30" align="right" bgcolor="#FFFFFF" class="td_border">要替换的地址内容：&nbsp;</td>
						<td width="617"  align="left" bgcolor="#FFFFFF" class="td_border">&nbsp;<font color="red">&nbsp;有些获取到的web页链接地址需要特别处理:<br />
							&nbsp;&nbsp;获取到的链接地址：1234567890
							&nbsp;&nbsp;&nbsp;&nbsp;希望获取到的地址：play.php?id=1234567890<br />
							&nbsp;&nbsp;可以在下方填写为：play.php?id={$变量}</font><br />
							&nbsp;
							<textarea name="urlreplace" cols="70" rows="4"><?php echo $data['urlreplace'];?></textarea></td>
					</tr>
					<tr>
						<td width="126" height="30" align="right" bgcolor="#FFFFFF" class="td_border">视频地址正则代码：&nbsp;</td>
						<td width="617"  align="left" bgcolor="#FFFFFF" class="td_border">&nbsp;
							<textarea name="playurl" id="S_playurl" cols="70" rows="4"><?php echo $data['playurl'];?></textarea>
							<a href="javascript:insertAtCursor(document.getElementById('S_playurl'),'{$内容}')">{$内容}</a>
							<!--<a href="javascript:insertAtCursor(document.getElementById('S_playurl'),'{$过滤}')">{$过滤}</a>--></td>
					</tr>
					<tr>
						<td width="126" height="35" align="right" bgcolor="#FFFFFF" class="td_border">&nbsp;视频采集内容替换：&nbsp;</td>
						<td width="617"  align="left" bgcolor="#FFFFFF" class="td_border">&nbsp;
							<textarea name="contentreplace" id="S_replace" cols="70" rows="4"><?php echo $data['contentreplace'];?></textarea>
							<br />
							<span style="color:red">&nbsp; 格式：被替换的内容@@替换为的内容，每行为一个多个替换请以回车键换行，可使用&nbsp;&nbsp;[变量]&nbsp;&nbsp;标签&nbsp;<br>
							&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></td>
					</tr>
					<tr>
						<td height="30" bgcolor="#FFFFFF" class="td_border" align="center">&nbsp;</td>
						<td height="30" bgcolor="#FFFFFF" class="td_border" ><input name="botton4" type="button" class="rb1"  onclick="history.go(-1);" value="返回上一步"/>
							&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
							<input name="submit1" type="submit" class="rb1" value="保存采集规则"  /></td>
					</tr>
					<tr>
						<td height="30" bgcolor="#FFFFFF" class="td_border" colspan="2">&nbsp;</td>
					</tr>
				</table>
			</form>
		</div>
	</div>
</div>
<?php require_once("../../admin_bottom.php");?>      
</body>
</html>