<?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,'bintype'=>0,'pictype' => 0,'list' => '','listhref' => '','title' => '','state' => '','class' => '','direct' => '','author' => '','area' => '','language' => '','year' => '','pic' => '','content' => '','playmode' => '','playrange' => '','webplayurl' => '','urlmode' => '','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)));
	}	
}

$playxml = playadd();array_pop($playxml);
$playxml = playselect($playxml,$data['player']);

?><!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" />
<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(){
	showpage(<?php echo $data['collecttype'];?>,'<?php echo $data['collecturl'];?>');
	$('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');
	});
	
});
function showpage(id,str){
	var content = '';
	var str = (str)? str : $('#collecturl').val();
	str = str ? str : '';
	switch(id){
		case 1:
			content = '<input name="collecturl" type="text" id="collecturl" value="'+str+'" style="width:318px; height:20px;"/> <font color=#FF0000>＊</font><span id="getinfo"></span>';
		break;
		case 2:
			content = '<input name="collecturl" type="text" id="collecturl" value="'+str+'" style="width:318px; height:20px;"/>&nbsp;&nbsp;分类页参数&nbsp;&nbsp;<span style="color:red;">{$ID}</span><br>&nbsp;<font color=#FF0000>标准格式：http://www.xxxxxx.com/list/{$ID}.html</font>';
		break;
		case 3:
			content = '<textarea name="collecturl" id="collecturl" cols="60" rows="5">'+(str.replace(/,/g,"\r\n"))+'</textarea><br/><font color=#FF0000>＊ 每行为一个分类页地址,请用回车键换行！</font>';
		break;
		case 4:
			content = '<input name="collecturl" id="collecturl" type="text" value="'+str+'" style="width:318px; height:20px;"/> <font color=#FF0000>＊</font>&nbsp;&nbsp;内容页参数&nbsp;&nbsp;<span style="color:red;">{$ID}</span><br>&nbsp;<font color=#FF0000>标准格式：http://www.xxxxxx.com/view/{$ID}.html</font>';
		break;
	}
	$('#showpage').html(content);
}
</script>
</head>
<body>
<div class="r_main">
	<div class="r_content">
		<div class="r_content_1">
			<form action="rulesave.php?action=<?php if($data['id']==0):?>add<?php else: ?>save<?php endif; ?>&page=1" name="form1" method="post">
			<?php if($data['id']!=0):?><input type="hidden" name="id" value="<?php echo $data['id'];?>" /><?php endif;?>
				<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">１. 设置基本参数及列表连接设置</font> 2. 采集内容与影片地址设置  3. 完成并采集测试</td>
					</tr>
					<tr>
						<td width="146" height="35" align="right" bgcolor="#FFFFFF" class="td_border">采集规则名称：&nbsp;</td>
						<td width="793"  align="left" bgcolor="#FFFFFF" class="td_border"><input name="name" type="text"  size="50" value="<?php echo $data['name'];?>" id="S_Name"/>
							<font color="#FF0000">＊</font></td>
					</tr>
					<tr>
						<td height="35" align="right" bgcolor="#FFFFFF" class="td_border">采集站点网址：&nbsp;</td>
						<td align="left" bgcolor="#FFFFFF" class="td_border"><input name="targeturl" type="text" value="<?php echo $data['targeturl'];?>" size="50" id="S_Url" />
							<font color="#FF0000"> ＊ 很重要，当获取到的图片或其它相对地址时，将用这个网址补齐</font></td>
					</tr>
					<tr>
						<td height="35" align="right" bgcolor="#FFFFFF" class="td_border">目标网页编码：&nbsp;</td>
						<td align="left" bgcolor="#FFFFFF" class="td_border"><select name="charset" id="S_Code">
								<option value="1"<?php if ($data['charset']==1): ?> selected="selected" <?php endif;?>>GB2312</option>
								<option value="2"<?php if ($data['charset']==2): ?> selected="selected" <?php endif;?>>UTF-8</option>
							</select>
							<font color=#FF0000>＊</font></td>
					</tr>
					<tr>
						<td height="35" align="right" bgcolor="#FFFFFF" class="td_border">采集播放类型：&nbsp;</td>
						<td align="left" bgcolor="#FFFFFF" class="td_border"><select name="player" id="S_Source">
								<?php echo $playxml;?>
							</select>
							&nbsp; </td>
					</tr>
					<tr>
						<td height="35" align="right" bgcolor="#FFFFFF" class="td_border">采集分页设置：&nbsp;</td>
						<td align="left" bgcolor="#FFFFFF" class="td_border">
							<input type="radio" name="collecttype" class="radio" value="1" onclick="showpage(1);" <?php if($data['collecttype']==1): ?> checked="checked"<?php endif;?> />
							指定分类页&nbsp;
							<input type="radio" name="collecttype" class="radio" value="2" onclick="showpage(2);" <?php if($data['collecttype']==2): ?> checked="checked"<?php endif;?> />
							自动分类页&nbsp;
							<input type="radio" name="collecttype" class="radio" value="3" onclick="showpage(3);" <?php if($data['collecttype']==3): ?> checked="checked"<?php endif;?> />
							批量分类页&nbsp;
							<input type="radio" name="collecttype" class="radio" value="4" onclick="showpage(4);" <?php if($data['collecttype']==4): ?> checked="checked"<?php endif;?> />
							直接采集内容页</td>
					</tr>
					<tr>
						<td height="35" align="right" bgcolor="#FFFFFF" class="td_border" id="pagetitle">采集页面网址：&nbsp;</td>
						<td  align="left" bgcolor="#FFFFFF" class="td_border" id="pagevalue"><span id="showpage"></span></td>
					</tr>
					<tr>
						<td height="35" align="right" bgcolor="#FFFFFF" class="td_border">采集功能选项：&nbsp;</td>
						<td align="left" bgcolor="#FFFFFF" class="td_border"><input type="checkbox" name="type[]" value="1"  class="checkbox"<?php if($data['bintype'][0]==1):?> checked="checked"<?php endif;?> />
							是否倒序采集&nbsp;&nbsp;&nbsp;
							<input type="checkbox" value="2" name="type[]" class="checkbox"<?php if($data['bintype'][1]==1):?> checked="checked"<?php endif;?>  />
							采集完毕自动入库&nbsp;&nbsp;
							<input type="checkbox" value="4" name="type[]" class="checkbox"<?php if($data['bintype'][2]==1):?> checked="checked"<?php endif;?> />
							入库完毕自动下载图片</td>
					</tr>
					<tr>
						<td height="30" align="right" bgcolor="#FFFFFF" class="td_border">&nbsp;视频列表范围设置：&nbsp;</td>
						<td align="left" bgcolor="#FFFFFF" class="td_border">
							<textarea name="list" id="list" cols="70" rows="4"><?php echo $data['list'];?></textarea>
							<a href="javascript:insertAtCursor(document.getElementById('list'),'{$内容}')">{$内容}</a>
						</td>
					</tr>
					<tr>
						<td height="30" align="right" bgcolor="#FFFFFF" class="td_border">&nbsp;视频链接正则设置：&nbsp;</td>
						<td align="left" bgcolor="#FFFFFF" class="td_border">
							<textarea name="listhref" id="listhref" cols="70" rows="4"><?php echo $data['listhref'];?></textarea>
							<a href="javascript:insertAtCursor(document.getElementById('listhref'),'{$内容}')">{$内容}</a>
							<a href="javascript:insertAtCursor(document.getElementById('listhref'),'{$过滤}')">{$过滤}</a>
						</td>
					</tr>
					<!--<tr>
						<td height="35" align="right" bgcolor="#FFFFFF" class="td_border">图片采集选项：&nbsp;</td>
						<td align="left" bgcolor="#FFFFFF" class="td_border">
							<input type="radio" name="pictype" value="0" onclick="document.getElementById('pictype2').style.display='none';" <?php if($data['pictype']==0):?> checked="checked"<?php endif;?> />
							从内容页获取图片&nbsp;&nbsp;&nbsp;
							<input type="radio" value="1" name="pictype" onclick="document.getElementById('pictype2').style.display='';" <?php if($data['pictype']==1):?> checked="checked"<?php endif;?> />
							从列表页获取图片&nbsp;&nbsp;
					</tr>
					<tr id="pictype2"<?php if($data['pictype']==0):?> style="display:none;"<?php endif;?>>
						<td height="30" align="right" bgcolor="#FFFFFF" class="td_border">&nbsp;图片正则获取设置：&nbsp;</td>
						<td align="left" bgcolor="#FFFFFF" class="td_border">
							<textarea name="pic" id="S_pic" cols="70" rows="4"><?php if($data['pictype']==1){ echo $data['pic']; }?></textarea>
							<a href="javascript:insertAtCursor(document.getElementById('S_pic'),'{$内容}')">{$内容}</a>
							<a href="javascript:insertAtCursor(document.getElementById('S_pic'),'{$过滤}')">{$过滤}</a>
						</td>
					</tr>-->
					<tr>
						<td height="40" bgcolor="#FFFFFF" class="td_border">&nbsp;</td>
						<td height="30" bgcolor="#FFFFFF" class="td_border"><input name="submit" type="submit" class="rb1" id="step1"   value="继续下一步"/></td>
					</tr>
				</table>
			</form>
		</div>
	</div>
</div>
<?php require_once("../../admin_bottom.php");?>      
</body>
</html>