mirror of https://gitee.com/zorlan/skycaiji
parent
b219706db2
commit
f5af21e5ef
|
@ -18,30 +18,8 @@ class Init{
|
|||
|
||||
$curController=strtolower(request()->controller());
|
||||
if('store'==$curController){
|
||||
|
||||
$httpOrigin=strtolower(request()->server('HTTP_ORIGIN'));
|
||||
$httpOrigin=rtrim($httpOrigin,'/');
|
||||
|
||||
$allowOrigin='';
|
||||
if(in_array($httpOrigin,config('allow_origins'))){
|
||||
|
||||
$allowOrigin=$httpOrigin;
|
||||
}else{
|
||||
|
||||
if(model('Provider')->where(array('domain'=>$httpOrigin,'enable'=>1))->count()>0){
|
||||
|
||||
$allowOrigin=$httpOrigin;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
header('Access-Control-Allow-Origin:'.$allowOrigin);
|
||||
|
||||
header('Access-Control-Allow-Credentials:true');
|
||||
|
||||
header('Access-Control-Allow-Methods:POST,GET');
|
||||
|
||||
|
||||
|
||||
controller('Store','controller')->_checkCors(true);
|
||||
}
|
||||
/*自动登录*/
|
||||
$muser=model('User');
|
||||
|
|
|
@ -42,9 +42,16 @@ class Api extends BaseController{
|
|||
}
|
||||
define('IS_COLLECTING', 1);
|
||||
$mcache=CacheModel::getInstance();
|
||||
if($mcache->getCache('auto_collecting')){
|
||||
|
||||
$this->error('有任务正在自动采集');
|
||||
$autoCacheData=$mcache->getCache('auto_collecting');
|
||||
if($autoCacheData){
|
||||
|
||||
|
||||
if((time()-intval($autoCacheData['dateline']))>60*($GLOBALS['_sc']['c']['caiji']['interval']+15)){
|
||||
|
||||
}else{
|
||||
|
||||
$this->error('有任务正在自动采集');
|
||||
}
|
||||
}
|
||||
$mcache->setCache('auto_collecting',1);
|
||||
register_shutdown_function('remove_auto_collecting');
|
||||
|
|
|
@ -183,6 +183,10 @@ class Cpattern extends BaseController {
|
|||
case 'list':if(empty($field['list']))$this->error('随机抽取不能为空!');break;
|
||||
case 'extract':if(empty($field['extract']))$this->error('请选择字段!');break;
|
||||
case 'merge':if(empty($field['merge']))$this->error('字段组合不能为空!');break;
|
||||
case 'sign':
|
||||
if($field['source']=='source_url')$this->error('抱歉,起始页无法使用'.lang('field_module_sign'));
|
||||
if(empty($field['sign']))$this->error('请输入'.lang('field_module_sign'));
|
||||
break;
|
||||
}
|
||||
|
||||
$modules = array (
|
||||
|
@ -196,7 +200,8 @@ class Cpattern extends BaseController {
|
|||
'time' => array ('time_format','time_start','time_end','time_stamp'),
|
||||
'list' => 'list',
|
||||
'extract' =>array('extract','extract_module','extract_rule','extract_xpath','extract_xpath_attr','extract_xpath_attr_custom','extract_json','extract_json_arr','extract_json_arr_implode'),
|
||||
'merge' => 'merge'
|
||||
'merge' => 'merge',
|
||||
'sign' => 'sign'
|
||||
);
|
||||
$returnField=array('name'=>$field['name'],'source'=>$field['source'],'module'=>$field['module']);
|
||||
|
||||
|
@ -212,7 +217,25 @@ class Cpattern extends BaseController {
|
|||
$field=input('field','','url_b64decode');
|
||||
$objid=input('objid');
|
||||
$field=$field?json_decode($field,true):array();
|
||||
if(!is_array($field)){
|
||||
$field=array();
|
||||
}
|
||||
$field['time_format']=$field['time_format']?$field['time_format']:'[年]/[月]/[日] [时]:[分]';
|
||||
|
||||
|
||||
$sortField=array();
|
||||
foreach(array('source','module') as $k){
|
||||
if(isset($field[$k])){
|
||||
$sortField[$k]=$field[$k];
|
||||
unset($field[$k]);
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($field as $k=>$v){
|
||||
$sortField[$k]=$v;
|
||||
}
|
||||
$field=$sortField;
|
||||
|
||||
$this->assign('field',$field);
|
||||
$this->assign('objid',$objid);
|
||||
return $this->fetch();
|
||||
|
@ -340,7 +363,7 @@ class Cpattern extends BaseController {
|
|||
|
||||
$this->success('',null,array('level_url'=>$level_url,'objid'=>$objid));
|
||||
}else{
|
||||
$level_url=input('level_url','','url_b64decode');
|
||||
$level_url=input('level_url','','url_b64decode');
|
||||
$objid=input('objid');
|
||||
$level_url=$level_url?json_decode($level_url,true):array();
|
||||
$this->assign('level_url',$level_url);
|
||||
|
@ -392,8 +415,7 @@ class Cpattern extends BaseController {
|
|||
|
||||
$op=input('op');
|
||||
$taskData=model('Task')->getById($eCpattern->collector['task_id']);
|
||||
|
||||
model('Task')->loadConfig($taskData['config']);
|
||||
model('Task')->loadConfig($taskData);
|
||||
|
||||
$GLOBALS['_sc']['p_nav']=breadcrumb(array(array('url'=>url('Collector/set?task_id='.$taskData['id']),'title'=>lang('task').lang('separator').$taskData['name']),array('url'=>url('Cpattern/test&op='.$op.'&coll_id='.$coll_id),'title'=>'测试')));
|
||||
|
||||
|
@ -440,17 +462,41 @@ class Cpattern extends BaseController {
|
|||
|
||||
$input_urls=array();
|
||||
foreach ($eCpattern->config['new_field_list'] as $field){
|
||||
if('source_url'==strtolower($field['field']['source'])){
|
||||
|
||||
$input_urls['source_url']=input('source_url');
|
||||
$input_urls['source_url']=$input_urls['source_url']?$input_urls['source_url']:'';
|
||||
if(empty($field['field']['source'])){
|
||||
|
||||
if($field['field']['module']=='sign'){
|
||||
if(empty($eCpattern->config['level_urls'])){
|
||||
$input_urls['source_url']=input('source_url','');
|
||||
}else{
|
||||
|
||||
$endLevelNum=count($eCpattern->config['level_urls']);
|
||||
$endLevel=$eCpattern->config['level_urls'][$endLevelNum-1];
|
||||
$input_urls['level_url'][$endLevelNum]=array('level'=>$endLevelNum,'name'=>$endLevel['name'],'url'=>input('level_'.$endLevelNum));
|
||||
}
|
||||
}
|
||||
}elseif('source_url'==strtolower($field['field']['source'])){
|
||||
|
||||
$input_urls['source_url']=input('source_url','');
|
||||
}elseif(preg_match('/level_url:/i', $field['field']['source'])){
|
||||
|
||||
foreach($eCpattern->config['level_urls'] as $levIx=>$levVal){
|
||||
if($field['field']['source']==('level_url:'.$levVal['name'])){
|
||||
|
||||
$level=$levIx+1;
|
||||
$input_urls['level_url'][$level]=array('level'=>$level,'name'=>$levVal['name'],'url'=>input('level_'.$level));
|
||||
if($field['field']['source']==('level_url:'.$levVal['name'])){
|
||||
|
||||
$level=$levIx+1;
|
||||
if($field['field']['module']=='sign'){
|
||||
|
||||
if($level==1){
|
||||
|
||||
$input_urls['source_url']=input('source_url','');
|
||||
}else{
|
||||
|
||||
$prevLevel=$level-1;
|
||||
$input_urls['level_url'][$prevLevel]=array('level'=>$prevLevel,'name'=>$eCpattern->config['level_urls'][$prevLevel-1]['name'],'url'=>input('level_'.$prevLevel));
|
||||
}
|
||||
}else{
|
||||
|
||||
$input_urls['level_url'][$level]=array('level'=>$level,'name'=>$levVal['name'],'url'=>input('level_'.$level));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -489,6 +535,50 @@ class Cpattern extends BaseController {
|
|||
}
|
||||
}
|
||||
|
||||
$signLevels=array();
|
||||
$signCont=false;
|
||||
foreach($eCpattern->config['new_field_list'] as $fieldConfig){
|
||||
if($fieldConfig['field']['module']=='sign'){
|
||||
|
||||
if(empty($fieldConfig['field']['source'])){
|
||||
$signCont=true;
|
||||
}elseif(preg_match('/^level_url:(.*+)$/i', $fieldConfig['field']['source'],$levelName)){
|
||||
|
||||
$levelName=$levelName[1];
|
||||
$signLevels[$levelName]=$levelName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!empty($signLevels)){
|
||||
|
||||
foreach ($eCpattern->config['level_urls'] as $k=>$v){
|
||||
if(in_array($v['name'],$signLevels)){
|
||||
if($k==0){
|
||||
|
||||
$eCpattern->getLevelUrls($eCpattern->cur_source_url,$k+1,true);
|
||||
}else{
|
||||
|
||||
$prevLevelUrl=$eCpattern->config['level_urls'][$k-1];
|
||||
$eCpattern->getLevelUrls($eCpattern->cur_level_urls[$prevLevelUrl['name']],$k+1,true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($signCont){
|
||||
|
||||
if(empty($eCpattern->config['level_urls'])){
|
||||
|
||||
$eCpattern->getContUrls($eCpattern->cur_source_url);
|
||||
}else{
|
||||
|
||||
$endLevelNum=count($eCpattern->config['level_urls']);
|
||||
$endLevel=$eCpattern->config['level_urls'][$endLevelNum-1];
|
||||
$eCpattern->getContUrls($eCpattern->cur_level_urls[$endLevel['name']]);
|
||||
}
|
||||
}
|
||||
|
||||
$val_list=$eCpattern->getFields($cont_url);
|
||||
if(empty($eCpattern->first_loop_field)){
|
||||
|
||||
|
@ -509,7 +599,7 @@ class Cpattern extends BaseController {
|
|||
foreach ($eCpattern->exclude_cont_urls[$md5Url] as $k=>$v){
|
||||
$num+=count((array)$v);
|
||||
}
|
||||
$msg='通过数据处理排除了'.$num.'条数据';
|
||||
$msg='通过数据处理筛除了'.$num.'条数据';
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,39 @@ namespace skycaiji\admin\controller;
|
|||
use skycaiji\admin\model\FuncApp;
|
||||
class Mystore extends BaseController {
|
||||
public function indexAction(){
|
||||
$this->redirect('Mystore/rule');
|
||||
$this->redirect('Mystore/store');
|
||||
}
|
||||
public function storeAction(){
|
||||
$url=input('url','','strip_tags');
|
||||
if(!empty($url)&&!is_official_url($url)){
|
||||
|
||||
$provData=model('Provider')->where('url',$url)->find();
|
||||
if(empty($provData)){
|
||||
$this->error($url.' 平台未添加');
|
||||
}
|
||||
if(empty($provData['enable'])){
|
||||
$this->error($url.' 已设置为拒绝访问');
|
||||
}
|
||||
$url=$provData['url'];
|
||||
|
||||
$url.=strpos($url, '?')===false?'?':'&';
|
||||
$url.='clientinfo='.urlencode($GLOBALS['_sc']['clientinfo']);
|
||||
|
||||
$this->assign('provData',$provData);
|
||||
}
|
||||
if(empty($url)){
|
||||
$url='https://www.skycaiji.com/store';
|
||||
}
|
||||
|
||||
if(!empty($url)){
|
||||
|
||||
}
|
||||
|
||||
$GLOBALS['_sc']['p_name']=lang('store');
|
||||
$GLOBALS['_sc']['p_nav']=breadcrumb(array(array('url'=>url('Mystore/store'),'title'=>lang('store'))));
|
||||
|
||||
$this->assign('url',$url);
|
||||
return $this->fetch();
|
||||
}
|
||||
public function ruleAction(){
|
||||
$mrule=model('Rule');
|
||||
|
|
|
@ -236,7 +236,7 @@ class Release extends BaseController{
|
|||
$this->echo_msg(lang('task_error_empty_task'));
|
||||
exit();
|
||||
}
|
||||
model('Task')->loadConfig($taskData['config']);
|
||||
model('Task')->loadConfig($taskData);
|
||||
|
||||
$collData=model('Collector')->where(array('task_id'=>$taskData['id'],'module'=>$taskData['module']))->find();
|
||||
if(empty($collData)){
|
||||
|
|
|
@ -139,7 +139,7 @@ class Setting extends BaseController {
|
|||
if($config['img_name']=='custom'){
|
||||
|
||||
if(empty($config['name_custom_path'])){
|
||||
$this->error('请输入图片名称自定义目录');
|
||||
$this->error('请输入图片名称自定义路径');
|
||||
}
|
||||
if(!$checkNamePath['success']){
|
||||
$this->error($checkNamePath['msg']);
|
||||
|
@ -151,6 +151,19 @@ class Setting extends BaseController {
|
|||
}
|
||||
}
|
||||
|
||||
$checkNameName=$mconfig->check_img_name_name($config['name_custom_name']);
|
||||
if($config['img_name']=='custom'){
|
||||
|
||||
if(!empty($config['name_custom_name'])&&!$checkNameName['success']){
|
||||
$this->error($checkNameName['msg']);
|
||||
}
|
||||
}else{
|
||||
|
||||
if(!$checkNameName['success']){
|
||||
$config['name_custom_name']='';
|
||||
}
|
||||
}
|
||||
|
||||
$mconfig->setConfig('download_img',$config);
|
||||
|
||||
$this->success(lang('op_success'),'Setting/download_img');
|
||||
|
|
|
@ -17,51 +17,14 @@ class Store extends BaseController {
|
|||
if(empty($GLOBALS['_sc']['user'])){
|
||||
$this->dispatchJump(false,lang('user_error_is_not_admin'),url('Admin/Index/index',null,null,true));
|
||||
}else{
|
||||
|
||||
if(request()->isAjax()){
|
||||
|
||||
$token=$this->_getToken();
|
||||
if(empty($token)){
|
||||
$token=md5(request()->server('HTTP_ORIGIN').date('Y-m-d H:i:s',time()).rand(1,1000000));
|
||||
session('store_token',array('token'=>$token,time=>time()));
|
||||
}
|
||||
$this->dispatchJump(true,$token);
|
||||
}else{
|
||||
$this->dispatchJump(false,'无效的操作!');
|
||||
$token=$this->_getToken();
|
||||
if(empty($token)){
|
||||
$token=md5(request()->server('HTTP_ORIGIN').date('Y-m-d H:i:s',time()).rand(1,1000000));
|
||||
session('store_token',array('token'=>$token,time=>time()));
|
||||
}
|
||||
}
|
||||
}
|
||||
public function indexAction(){
|
||||
$url=input('url','','strip_tags');
|
||||
if(!empty($url)&&!is_official_url($url)){
|
||||
|
||||
$provData=model('Provider')->where('url',$url)->find();
|
||||
if(empty($provData)){
|
||||
$this->error($url.' 平台未添加');
|
||||
}
|
||||
if(empty($provData['enable'])){
|
||||
$this->error($url.' 已设置为拒绝访问');
|
||||
}
|
||||
$url=$provData['url'];
|
||||
|
||||
$url.=strpos($url, '?')===false?'?':'&';
|
||||
$url.='clientinfo='.urlencode($GLOBALS['_sc']['clientinfo']);
|
||||
|
||||
$this->assign('provData',$provData);
|
||||
$this->dispatchJump(true,$token);
|
||||
}
|
||||
if(empty($url)){
|
||||
$url='https://www.skycaiji.com/store';
|
||||
}
|
||||
|
||||
if(!empty($url)){
|
||||
|
||||
}
|
||||
|
||||
$GLOBALS['_sc']['p_name']=lang('store');
|
||||
$GLOBALS['_sc']['p_nav']=breadcrumb(array(array('url'=>url('Store/index'),'title'=>lang('store'))));
|
||||
|
||||
$this->assign('url',$url);
|
||||
return $this->fetch();
|
||||
}
|
||||
/*安装规则*/
|
||||
public function installRuleAction(){
|
||||
|
@ -252,21 +215,19 @@ class Store extends BaseController {
|
|||
}
|
||||
/*站点验证*/
|
||||
public function siteCertificationAction(){
|
||||
if(request()->isAjax()){
|
||||
$op=input('op');
|
||||
if($op=='set_key'){
|
||||
|
||||
$key=input('post.key');
|
||||
if(empty($key)){
|
||||
$this->dispatchJump(false,'密钥错误');
|
||||
}
|
||||
cache('site_certification',array('key'=>$key,'time'=>NOW_TIME));
|
||||
$this->dispatchJump(true);
|
||||
}else{
|
||||
$this->dispatchJump(false,'操作错误!');
|
||||
$this->_checkRequest();
|
||||
|
||||
$op=input('op');
|
||||
if($op=='set_key'){
|
||||
|
||||
$key=input('post.key');
|
||||
if(empty($key)){
|
||||
$this->dispatchJump(false,'密钥错误');
|
||||
}
|
||||
cache('site_certification',array('key'=>$key,'time'=>NOW_TIME));
|
||||
$this->dispatchJump(true);
|
||||
}else{
|
||||
$this->dispatchJump(false,'无效的操作!');
|
||||
$this->dispatchJump(false,'错误操作!');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -334,28 +295,16 @@ class Store extends BaseController {
|
|||
/*验证请求源*/
|
||||
protected function _checkRequest(){
|
||||
|
||||
$token=input('token');
|
||||
|
||||
$token=request()->server('HTTP_X_STORE_TOKEN');
|
||||
$sessionToken=$this->_getToken();
|
||||
if(empty($token)||empty($sessionToken)||$token!=$sessionToken){
|
||||
$this->dispatchJump(false,'token验证失败,请刷新页面或清除缓存');
|
||||
}
|
||||
|
||||
if(!request()->isAjax()){
|
||||
|
||||
$origin=strtolower(request()->server('HTTP_ORIGIN'));
|
||||
$origin=rtrim($origin,'/');
|
||||
if(empty($origin)){
|
||||
$this->dispatchJump(false,'未知来源');
|
||||
}
|
||||
|
||||
$provData=model('Provider')->where(array('domain'=>$origin))->find();
|
||||
if(empty($provData)){
|
||||
$this->dispatchJump(false,'未知的第三方来源:'.$origin);
|
||||
}elseif($provData['enable']!=1){
|
||||
$this->dispatchJump(false,'未受信任的第三方来源:'.$origin);
|
||||
}
|
||||
}
|
||||
$this->_checkCors(false);
|
||||
}
|
||||
|
||||
protected function _getToken(){
|
||||
$storeToken=session('store_token');
|
||||
$token=null;
|
||||
|
@ -366,4 +315,82 @@ class Store extends BaseController {
|
|||
}
|
||||
return $token;
|
||||
}
|
||||
|
||||
|
||||
public function _checkCors($openCorsHeader=true){
|
||||
$action=request()->action();
|
||||
if($action=='update'){
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
$httpOrigin=strtolower(request()->server('HTTP_ORIGIN'));
|
||||
if(empty($httpOrigin)){
|
||||
$httpOrigin='';
|
||||
}else{
|
||||
if(preg_match('/^\w+\:\/\//', $httpOrigin)){
|
||||
$httpOrigin=rtrim($httpOrigin,'/');
|
||||
}else{
|
||||
|
||||
$httpOrigin='';
|
||||
}
|
||||
}
|
||||
|
||||
$isAllowOrigin=false;
|
||||
|
||||
$provData=null;
|
||||
|
||||
if(!empty($httpOrigin)){
|
||||
if(in_array($httpOrigin,config('allow_origins'))){
|
||||
|
||||
$isAllowOrigin=true;
|
||||
}else{
|
||||
|
||||
$provData=model('Provider')->where(array('domain'=>$httpOrigin))->find();
|
||||
if(!empty($provData)&&$provData['enable']==1){
|
||||
|
||||
$isAllowOrigin=true;
|
||||
}
|
||||
}
|
||||
if($isAllowOrigin&&$openCorsHeader){
|
||||
|
||||
|
||||
header('Access-Control-Allow-Origin:'.$httpOrigin);
|
||||
|
||||
header('Access-Control-Allow-Credentials:true');
|
||||
|
||||
header('Access-Control-Allow-Methods:POST,GET');
|
||||
|
||||
header('Access-Control-Allow-Headers:X-Requested-With,X-Store-Token,Content-Type');
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
$httpWith=request()->server('HTTP_X_REQUESTED_WITH');
|
||||
if(empty($httpWith)||strtolower($httpWith)!='xmlhttprequest'){
|
||||
|
||||
$this->dispatchJump(false,'不是ajax请求');
|
||||
}
|
||||
|
||||
if(empty($httpOrigin)){
|
||||
|
||||
$this->dispatchJump(false,'未知来源');
|
||||
}else{
|
||||
|
||||
if(!$isAllowOrigin){
|
||||
|
||||
if(empty($provData)){
|
||||
|
||||
$this->dispatchJump(false,'未知的第三方来源:'.$httpOrigin);
|
||||
}else{
|
||||
|
||||
$this->dispatchJump(false,'未受信任的第三方来源:'.$httpOrigin);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -290,8 +290,22 @@ class Task extends BaseController {
|
|||
$GLOBALS['_sc']['p_name']=lang('task_edit').':'.$taskData['name'];
|
||||
$GLOBALS['_sc']['p_nav']=breadcrumb(array(array('url'=>url('Task/list'),'title'=>lang('task_list')),array('url'=>url('Task/edit?id='.$taskData['id']),'title'=>$taskData['name'])));
|
||||
|
||||
$fieldList=array();
|
||||
$collData=model('Collector')->where(array('task_id'=>$taskData['id']))->find();
|
||||
if(!empty($collData)&&!empty($collData['config'])){
|
||||
$collData['config']=unserialize($collData['config']);
|
||||
if(is_array($collData['config'])&&is_array($collData['config']['field_list'])){
|
||||
foreach($collData['config']['field_list'] as $v){
|
||||
$fieldList[]=$v['name'];
|
||||
}
|
||||
$fieldList=array_unique($fieldList);
|
||||
$fieldList=array_filter($fieldList);
|
||||
}
|
||||
}
|
||||
|
||||
$this->assign('tgSelect',$tgSelect);
|
||||
$this->assign('taskData',$taskData);
|
||||
$this->assign('fieldList',$fieldList);
|
||||
if(request()->isAjax()){
|
||||
return view('add_ajax');
|
||||
}else{
|
||||
|
@ -557,7 +571,7 @@ class Task extends BaseController {
|
|||
exit();
|
||||
}
|
||||
$taskData['config']=unserialize($taskData['config']);
|
||||
model('Task')->loadConfig($taskData['config']);
|
||||
model('Task')->loadConfig($taskData);
|
||||
|
||||
$mcoll=model('Collector');
|
||||
$collData=$mcoll->where(array('task_id'=>$taskData['id'],'module'=>$taskData['module']))->find();
|
||||
|
@ -682,7 +696,7 @@ class Task extends BaseController {
|
|||
|
||||
$taskData['config']=unserialize($taskData['config']);
|
||||
|
||||
$mtask->loadConfig($taskData['config']);
|
||||
$mtask->loadConfig($taskData);
|
||||
|
||||
$acoll='\\skycaiji\\admin\\event\\C'.strtolower($collData['module']);
|
||||
$acoll=new $acoll();
|
||||
|
|
|
@ -162,62 +162,106 @@ abstract class Collector extends \skycaiji\admin\controller\BaseController {
|
|||
}
|
||||
/**
|
||||
* 匹配根目录
|
||||
* @param unknown $url
|
||||
* @param unknown $html
|
||||
* @param string $url 完整的网址
|
||||
* @param string $html 页面源码
|
||||
* @return Ambigous <NULL, string>
|
||||
*/
|
||||
public function match_base_url($url,$html){
|
||||
|
||||
if(preg_match('/<base[^<>]*href=[\'\"](?P<base>[^\<\>\"\']*?)[\'\"]/i', $html,$base_url)){
|
||||
$base_url=$base_url['base'];
|
||||
if(!empty($html)&&preg_match('/<base\b[^<>]*\bhref\s*=\s*[\'\"](?P<base>[^\'\"]*)[\'\"]/i',$html,$base_url)){
|
||||
$base_url=$base_url['base'];
|
||||
if(!preg_match('/^\w+\:\/\//', $base_url)){
|
||||
|
||||
$urlBase=$this->match_base_url($url, null);
|
||||
$urlDomain=$this->match_domain_url($url);
|
||||
$base_url=$this->create_complete_url($base_url, $urlBase, $urlDomain);
|
||||
}
|
||||
}else{
|
||||
|
||||
$base_url=preg_replace('/[\#\?][^\/]*$/', '', $url);
|
||||
|
||||
if(preg_match('/^\w+\:\/\/([\w\-]+\.){1,}[\w]+\/.+/',$base_url)&&preg_match('/\.[a-z]+$/i', $base_url)){
|
||||
|
||||
$base_url=preg_replace('/\/[^\/]*\.[a-z]+$/', '', $base_url);
|
||||
}
|
||||
$base_url=preg_replace('/[\#\?].*$/', '', $url);
|
||||
}
|
||||
if(!preg_match('/\/$/', $base_url)){
|
||||
|
||||
|
||||
if(preg_match('/(^\w+\:\/\/[^\/]+)(.*$)/',$base_url,$mbase)){
|
||||
|
||||
$mbase[2]=preg_replace('/[^\/]+$/', '', $mbase[2]);
|
||||
$base_url=$mbase[1].$mbase[2];
|
||||
}
|
||||
}
|
||||
$base_url=rtrim($base_url,'/');
|
||||
|
||||
|
||||
return $base_url?$base_url:null;
|
||||
}
|
||||
/**
|
||||
* 匹配域名
|
||||
* @param unknown $url
|
||||
* @return Ambigous <NULL, string>
|
||||
* @param string $url 完整的网址
|
||||
* @return NULL|string
|
||||
*/
|
||||
public function match_domain_url($url){
|
||||
|
||||
if(preg_match('/^\w+\:\/\/([\w\-]+\.){1,}[\w]+/', $url,$domain_url)){
|
||||
$domain_url=null;
|
||||
if(preg_match('/^\w+\:\/\/([\w\-]+\.){1,}[\w]+/',$url,$domain_url)){
|
||||
$domain_url=rtrim($domain_url[0],'/');
|
||||
}else{
|
||||
$domain_url=null;
|
||||
}
|
||||
return $domain_url?$domain_url:null;
|
||||
return empty($domain_url)?null:$domain_url;
|
||||
}
|
||||
/**
|
||||
* 生成完整网址
|
||||
* @param $url 要填充的网址
|
||||
* @param $base_url 根目录网址
|
||||
* @param $domain_url 域名
|
||||
* @param string $url 要填充的网址
|
||||
* @param string $base_url 根目录网址
|
||||
* @param string $domain_url 域名
|
||||
*/
|
||||
public function create_complete_url($url,$base_url,$domain_url){
|
||||
static $base_domain=array();
|
||||
|
||||
if(preg_match('/^\w+\:\/\//', $url)){
|
||||
|
||||
return $url;
|
||||
}elseif(strpos($url,'//')===0){
|
||||
|
||||
$url='https:'.$url;
|
||||
$url=(stripos($base_url, 'https://')===0?'https:':'http:').$url;
|
||||
}elseif(strpos($url,'/')===0){
|
||||
|
||||
$url=$domain_url.'/'.ltrim($url,'/');
|
||||
}elseif(stripos($url,'javascript')===0||stripos($url,'#')===0){
|
||||
$curDomain='';
|
||||
if($base_url){
|
||||
$baseMd5=md5($base_url);
|
||||
if(!isset($base_domain[$baseMd5])){
|
||||
$base_domain[$baseMd5]=$this->match_domain_url($base_url);
|
||||
}
|
||||
$curDomain=$base_domain[$baseMd5];
|
||||
}
|
||||
$curDomain=empty($curDomain)?rtrim($domain_url,'/'):$curDomain;
|
||||
$url=$curDomain.'/'.ltrim($url,'/');
|
||||
}elseif(stripos($url,'javascript')===0||stripos($url,'#')===0||$url==''){
|
||||
|
||||
$url='';
|
||||
}elseif(!preg_match('/^\w+\:\/\//', $url)){
|
||||
|
||||
$url=$base_url.'/'.ltrim($url,'/');
|
||||
}
|
||||
|
||||
if(!empty($url)&&preg_match('/\/(\.){1,2}\//', $url)){
|
||||
|
||||
if(preg_match('/(^\w+\:\/\/(?:[\w\-]+\.){1,}[\w]+\/)([^\?\#]+)(.*$)/',$url,$murl)){
|
||||
|
||||
$paths=explode('/', $murl[2]);
|
||||
$newPaths=array();
|
||||
foreach ($paths as $k=>$v){
|
||||
if($v=='..'){
|
||||
|
||||
array_pop($newPaths);
|
||||
}elseif($v!='.'){
|
||||
|
||||
$newPaths[]=$v;
|
||||
}
|
||||
}
|
||||
$url=$murl[1].implode('/', $newPaths).$murl[3];
|
||||
}
|
||||
}
|
||||
|
||||
return $url;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -383,7 +383,7 @@ class Cpattern extends CpatternBase{
|
|||
$newConfig['reg_source_cont_url']=str_replace ( '(*)', '[\s\S]*?', $newConfig['reg_source_cont_url'] );
|
||||
}else{
|
||||
|
||||
$newConfig['reg_source_cont_url']='\bhref=[\'\"](?P<match>[^\'\"\<\>]+?)[\'\"]';
|
||||
$newConfig['reg_source_cont_url']='\bhref\s*=\s*[\'\"](?P<match>[^\'\"]*)[\'\"]';
|
||||
}
|
||||
|
||||
$config['url_merge']=$this->set_merge_default($newConfig['reg_source_cont_url'], $config['url_merge']);
|
||||
|
@ -440,7 +440,7 @@ class Cpattern extends CpatternBase{
|
|||
$luv['reg_url']=str_replace ( '(*)', '[\s\S]*?', $luv['reg_url'] );
|
||||
}else{
|
||||
|
||||
$luv['reg_url']='\bhref=[\'\"](?P<match>[^\'\"\<\>]+?)[\'\"]';
|
||||
$luv['reg_url']='\bhref\s*=\s*[\'\"](?P<match>[^\'\"]*)[\'\"]';
|
||||
}
|
||||
|
||||
$luv['url_merge']=$this->set_merge_default($luv['reg_url'], $luv['url_merge']);
|
||||
|
@ -824,13 +824,13 @@ class Cpattern extends CpatternBase{
|
|||
}
|
||||
if(!empty($paging_area)){
|
||||
|
||||
|
||||
|
||||
if(!empty($this->config['paging']['url_complete'])){
|
||||
|
||||
$paging_area=preg_replace_callback('/(?<=\bhref\=[\'\"])([^\'\"]*)(?=[\'\"])/i',function($matche_p_a) use ($base_url,$domain_url){
|
||||
$paging_area=preg_replace_callback('/(\bhref\s*=\s*[\'\"])([^\'\"]*)([\'\"])/i',function($matche_p_a) use ($base_url,$domain_url){
|
||||
|
||||
return \skycaiji\admin\event\Cpattern::create_complete_url($matche_p_a[1], $base_url, $domain_url);
|
||||
$matche_p_a[2]=\skycaiji\admin\event\Cpattern::create_complete_url($matche_p_a[2], $base_url, $domain_url);
|
||||
return $matche_p_a[1].$matche_p_a[2].$matche_p_a[3];
|
||||
},$paging_area);
|
||||
}
|
||||
|
||||
|
@ -905,7 +905,7 @@ class Cpattern extends CpatternBase{
|
|||
$field_params=$field_config['field'];
|
||||
$module=strtolower($field_params['module']);
|
||||
|
||||
if(!empty($field_params['source'])&&in_array($module, array('rule','xpath','json','auto'))){
|
||||
if(!empty($field_params['source'])&&in_array($module, array('rule','xpath','json','auto','sign'))){
|
||||
|
||||
$field_source_url='';
|
||||
$source_echo_msg='——采集';
|
||||
|
@ -1025,6 +1025,9 @@ class Cpattern extends CpatternBase{
|
|||
}
|
||||
}elseif(in_array($module,$fieldArr2)){
|
||||
$val=$this->$field_func($field_params,$html,$cur_url);
|
||||
}elseif($module=='sign'){
|
||||
|
||||
$val=$this->$field_func($field_params,empty($cont_url)?$cur_url:$cont_url);
|
||||
}else{
|
||||
$val=$this->$field_func($field_params,$html);
|
||||
}
|
||||
|
@ -1053,11 +1056,11 @@ class Cpattern extends CpatternBase{
|
|||
$loopIndex=$is_loop?$v_k:-1;
|
||||
if(!empty($field_process)){
|
||||
|
||||
$val=$this->process_field($val,$field_process,$cur_url_md5,$loopIndex,$cont_url_md5);
|
||||
$val=$this->process_field($field_name,$val,$field_process,$cur_url_md5,$loopIndex,$cont_url_md5);
|
||||
}
|
||||
if(!empty($this->config['common_process'])){
|
||||
|
||||
$val=$this->process_field($val,$this->config['common_process'],$cur_url_md5,$loopIndex,$cont_url_md5);
|
||||
$val=$this->process_field($field_name,$val,$this->config['common_process'],$cur_url_md5,$loopIndex,$cont_url_md5);
|
||||
}
|
||||
if(isset($this->exclude_cont_urls[$cont_url_md5][$cur_url_md5])){
|
||||
|
||||
|
@ -1101,12 +1104,14 @@ class Cpattern extends CpatternBase{
|
|||
}
|
||||
|
||||
|
||||
$val=preg_replace_callback('/(?<=\bhref\=[\'\"])([^\'\"]*)(?=[\'\"])/i',function($matche) use ($base_url,$domain_url){
|
||||
$val=preg_replace_callback('/(\bhref\s*=\s*[\'\"])([^\'\"]*)([\'\"])/i',function($matche) use ($base_url,$domain_url){
|
||||
|
||||
return \skycaiji\admin\event\Cpattern::create_complete_url($matche[1], $base_url, $domain_url);
|
||||
$matche[2]=\skycaiji\admin\event\Cpattern::create_complete_url($matche[2], $base_url, $domain_url);
|
||||
return $matche[1].$matche[2].$matche[3];
|
||||
},$val);
|
||||
$val=preg_replace_callback('/(?<=\bsrc\=[\'\"])([^\'\"]*)(?=[\'\"])/i',function($matche) use ($base_url,$domain_url){
|
||||
return \skycaiji\admin\event\Cpattern::create_complete_url($matche[1], $base_url, $domain_url);
|
||||
$val=preg_replace_callback('/(\bsrc\s*=\s*[\'\"])([^\'\"]*)([\'\"])/i',function($matche) use ($base_url,$domain_url){
|
||||
$matche[2]=\skycaiji\admin\event\Cpattern::create_complete_url($matche[2], $base_url, $domain_url);
|
||||
return $matche[1].$matche[2].$matche[3];
|
||||
},$val);
|
||||
|
||||
if($is_loop){
|
||||
|
@ -1123,7 +1128,7 @@ class Cpattern extends CpatternBase{
|
|||
if(!empty($GLOBALS['_sc']['c']['download_img']['download_img'])&&!empty($val)){
|
||||
|
||||
$valImgs=array();
|
||||
if(preg_match_all('/<img[^<>]*\bsrc=[\'\"]*(\w+\:\/\/[^\'\"\s]+)[\'\"]*/i',$val,$imgUrls)){
|
||||
if(preg_match_all('/<img\b[^<>]*\bsrc\s*=\s*[\'\"](\w+\:\/\/[^\'\"]+?)[\'\"]/i',$val,$imgUrls)){
|
||||
|
||||
$valImgs=is_array($imgUrls[1])?$imgUrls[1]:array();
|
||||
}
|
||||
|
@ -1228,6 +1233,16 @@ class Cpattern extends CpatternBase{
|
|||
|
||||
return '';
|
||||
}
|
||||
$urlMd5=md5($cont_url);
|
||||
|
||||
|
||||
if(!isset($this->cur_source_signs['relation_url'])){
|
||||
$this->cur_source_signs['relation_url']=array();
|
||||
}
|
||||
if(!isset($this->cur_source_signs['relation_url'][$urlMd5])){
|
||||
$this->cur_source_signs['relation_url'][$urlMd5]=array();
|
||||
}
|
||||
|
||||
|
||||
if(empty($relation_url['page'])){
|
||||
|
||||
|
@ -1237,9 +1252,12 @@ class Cpattern extends CpatternBase{
|
|||
|
||||
return '';
|
||||
}
|
||||
$relationUrl=$this->rule_match_urls($relation_url, $html);
|
||||
$relationUrlsMatches=$this->rule_match_urls($relation_url, $html,false,true);
|
||||
$relationUrl=$relationUrlsMatches['urls'];
|
||||
$relationUrl=(is_array($relationUrl)&&!empty($relationUrl))?reset($relationUrl):'';
|
||||
$this->relation_url_list[$cont_url][$name]=$relationUrl;
|
||||
|
||||
$this->cur_source_signs['relation_url'][$urlMd5][$name]=$relationUrlsMatches['matches'][md5($relationUrl)];
|
||||
}else{
|
||||
$relationUrl=$this->relation_url_list[$cont_url][$name];
|
||||
}
|
||||
|
@ -1281,9 +1299,12 @@ class Cpattern extends CpatternBase{
|
|||
|
||||
return '';
|
||||
}
|
||||
$relationUrl=$this->rule_match_urls($this->config['new_relation_urls'][$contPage], $html);
|
||||
$relationUrlsMatches=$this->rule_match_urls($this->config['new_relation_urls'][$contPage], $html,false,true);
|
||||
$relationUrl=$relationUrlsMatches['urls'];
|
||||
$relationUrl=(is_array($relationUrl)&&!empty($relationUrl))?reset($relationUrl):'';
|
||||
$this->relation_url_list[$cont_url][$contPage]=$relationUrl;
|
||||
|
||||
$this->cur_source_signs['relation_url'][$urlMd5][$contPage]=$relationUrlsMatches['matches'][md5($relationUrl)];
|
||||
}else{
|
||||
$relationUrl=$this->relation_url_list[$cont_url][$contPage];
|
||||
}
|
||||
|
@ -1305,10 +1326,12 @@ class Cpattern extends CpatternBase{
|
|||
|
||||
return '';
|
||||
}
|
||||
$relationUrl=$this->rule_match_urls($this->config['new_relation_urls'][$page],$relationHtml);
|
||||
$relationUrlsMatches=$this->rule_match_urls($this->config['new_relation_urls'][$page],$relationHtml,false,true);
|
||||
$relationUrl=$relationUrlsMatches['urls'];
|
||||
$relationUrl=(is_array($relationUrl)&&!empty($relationUrl))?reset($relationUrl):'';
|
||||
|
||||
$this->relation_url_list[$cont_url][$page]=$relationUrl;
|
||||
|
||||
$this->cur_source_signs['relation_url'][$urlMd5][$page]=$relationUrlsMatches['matches'][md5($relationUrl)];
|
||||
}else{
|
||||
$relationUrl=$this->relation_url_list[$cont_url][$page];
|
||||
}
|
||||
|
@ -1454,8 +1477,19 @@ class Cpattern extends CpatternBase{
|
|||
|
||||
/*统一:获取网址列表*/
|
||||
public function _get_urls($source_url,$config,$is_level=false){
|
||||
$is_level=$is_level?'多级':'';
|
||||
|
||||
$sourceType=$is_level?'level_url':'';
|
||||
$sourceName=$sourceType?$config['name']:'';
|
||||
|
||||
$is_level=$is_level?'多级':'';
|
||||
|
||||
|
||||
if(!isset($this->cur_source_signs[$sourceType])){
|
||||
$this->cur_source_signs[$sourceType]=array();
|
||||
}
|
||||
if(!isset($this->cur_source_signs[$sourceType][$sourceName])){
|
||||
$this->cur_source_signs[$sourceType][$sourceName]=array();
|
||||
}
|
||||
|
||||
$html=$this->get_html($source_url);
|
||||
if(empty($html)){
|
||||
return $this->error($is_level.'页面为空');
|
||||
|
@ -1468,7 +1502,9 @@ class Cpattern extends CpatternBase{
|
|||
return $this->error("未提取到{$is_level}区域内容!");
|
||||
}
|
||||
|
||||
$cont_urls=$this->rule_match_urls($config, $html);
|
||||
$contUrlsMatches=$this->rule_match_urls($config, $html,false,true);
|
||||
|
||||
$cont_urls=$contUrlsMatches['urls'];
|
||||
$cont_urls1=array();
|
||||
|
||||
|
||||
|
@ -1488,7 +1524,13 @@ class Cpattern extends CpatternBase{
|
|||
foreach ($cont_urls as $cont_url){
|
||||
if(!$op_not_complete){
|
||||
|
||||
$cont_url=$this->create_complete_url($cont_url, $base_url, $domain_url);
|
||||
$oldContMd5=md5($cont_url);
|
||||
$cont_url=$this->create_complete_url($cont_url, $base_url, $domain_url);
|
||||
$newContMd5=md5($cont_url);
|
||||
if($oldContMd5!=$newContMd5){
|
||||
|
||||
$contUrlsMatches['matches'][$newContMd5]=$contUrlsMatches['matches'][$oldContMd5];
|
||||
}
|
||||
}
|
||||
if(!empty($config['url_must'])){
|
||||
|
||||
|
@ -1518,6 +1560,17 @@ class Cpattern extends CpatternBase{
|
|||
if(empty($cont_urls)){
|
||||
return $this->error("未获取到".($is_level?$is_level:'内容')."网址!");
|
||||
}else{
|
||||
|
||||
$contUrlsMd5=array();
|
||||
foreach ($cont_urls as $k=>$v){
|
||||
$contUrlsMd5[]=md5($v);
|
||||
}
|
||||
foreach ($contUrlsMatches['matches'] as $k=>$v){
|
||||
if(!in_array($k,$contUrlsMd5)){
|
||||
unset($contUrlsMatches['matches'][$k]);
|
||||
}
|
||||
}
|
||||
|
||||
if(!empty($this->config['url_reverse'])){
|
||||
|
||||
$cont_urls=array_reverse($cont_urls);
|
||||
|
@ -1536,12 +1589,18 @@ class Cpattern extends CpatternBase{
|
|||
|
||||
$postParams=implode('&', $postParams);
|
||||
foreach ($cont_urls as $k=>$v){
|
||||
$vMd5=md5($v);
|
||||
$v.=strpos($v,'?')===false?'?':'&';
|
||||
$v.=$postParams;
|
||||
$cont_urls[$k]=$v;
|
||||
|
||||
$contUrlsMatches['matches'][md5($v)]=$contUrlsMatches['matches'][$vMd5];
|
||||
unset($contUrlsMatches['matches'][$vMd5]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->cur_source_signs[$sourceType][$sourceName]=$contUrlsMatches['matches'];
|
||||
return array_values($cont_urls);
|
||||
}
|
||||
}
|
||||
|
@ -1778,6 +1837,19 @@ class Cpattern extends CpatternBase{
|
|||
$field_vals_list=$this->getFields($cont_url);
|
||||
|
||||
$is_loop=empty($this->first_loop_field)?false:true;
|
||||
$loopExcludeNum=0;
|
||||
if($is_loop){
|
||||
|
||||
if(isset($this->exclude_cont_urls[$md5_cont_url])){
|
||||
|
||||
$loopExcludeNum=0;
|
||||
foreach($this->exclude_cont_urls[$md5_cont_url] as $k=>$v){
|
||||
|
||||
$loopExcludeNum+=count((array)$v);
|
||||
}
|
||||
$this->echo_msg($echo_str.'通过数据处理筛除了'.$loopExcludeNum.'条数据','black');
|
||||
}
|
||||
}
|
||||
if(!empty($field_vals_list)){
|
||||
$is_real_time=false;
|
||||
if(!empty($GLOBALS['_sc']['c']['caiji']['real_time'])&&!empty($GLOBALS['_sc']['real_time_release'])){
|
||||
|
@ -1808,19 +1880,9 @@ class Cpattern extends CpatternBase{
|
|||
$this->echo_msg($echo_str.'已过滤'.count((array)$loop_exists_urls).'条重复数据','black');
|
||||
}
|
||||
}
|
||||
if(isset($this->exclude_cont_urls[$md5_cont_url])){
|
||||
|
||||
$excludeNum=0;
|
||||
foreach($this->exclude_cont_urls[$md5_cont_url] as $k=>$v){
|
||||
|
||||
$excludeNum+=count((array)$v);
|
||||
}
|
||||
|
||||
$this->echo_msg($echo_str.'通过数据处理排除了'.$excludeNum.'条数据','black');
|
||||
}
|
||||
$field_vals_list=array_values($field_vals_list);
|
||||
}
|
||||
|
||||
|
||||
foreach ($field_vals_list as $field_vals){
|
||||
$collected_error='';
|
||||
$collected_data=array('url'=>$cont_url,'fields'=>$field_vals);
|
||||
|
@ -1879,7 +1941,7 @@ class Cpattern extends CpatternBase{
|
|||
|
||||
|
||||
controller('ReleaseBase','event')->record_collected(
|
||||
$cont_url,array('id'=>1,'target'=>'','desc'=>'循环入库'),array('task_id'=>$this->collector['task_id'],'module'=>$this->release['module']),null,false
|
||||
$cont_url,array('id'=>1,'target'=>'','desc'=>'循环入库'.($loopExcludeNum>0?(',数据处理筛除了'.$loopExcludeNum.'条数据'):'')),array('task_id'=>$this->collector['task_id'],'module'=>$this->release['module']),null,false
|
||||
);
|
||||
}
|
||||
}else{
|
||||
|
|
|
@ -30,6 +30,7 @@ class CpatternBase extends Collector{
|
|||
public $used_paging_urls=array();
|
||||
public $cur_level_urls=array();
|
||||
public $cur_source_url='';
|
||||
public $cur_source_signs=array();
|
||||
public $html_cache_list=array();
|
||||
public $show_opened_tools=false;
|
||||
|
||||
|
@ -86,105 +87,162 @@ class CpatternBase extends Collector{
|
|||
* @param array $config 配置参数
|
||||
* @param string $html 源码
|
||||
* @param bool $whole 完全匹配模式
|
||||
* @param bool $returnMatch 返回匹配到的数据
|
||||
*
|
||||
*/
|
||||
public function rule_match_urls($config,$html,$whole=false){
|
||||
$cont_urls=array();
|
||||
if(!empty($config['reg_url'])&&!empty($config['url_merge'])){
|
||||
|
||||
$sign_match=$this->sign_addslashes(cp_sign('match','(?P<num>\d*)'));
|
||||
if(preg_match_all('/'.$sign_match.'/i', $config['url_merge'],$match_signs)){
|
||||
|
||||
$url_merge=true;
|
||||
if(empty($config['reg_url_module'])){
|
||||
|
||||
if(preg_match('/\(\?P<match\d*>/i', $config['reg_url'])){
|
||||
|
||||
if(preg_match_all('/'.$config['reg_url'].'/i',$html,$cont_urls,PREG_SET_ORDER)){
|
||||
if($config['url_merge']==cp_sign('match')){
|
||||
|
||||
$url_merge=false;
|
||||
foreach ($cont_urls as $k=>$v){
|
||||
$cont_urls[$k]=$v['match'];
|
||||
}
|
||||
}
|
||||
}else{
|
||||
$cont_urls=array();
|
||||
}
|
||||
}else{
|
||||
|
||||
if($whole){
|
||||
|
||||
if(preg_match_all('/'.$config['reg_url'].'/i',$html,$cont_urls)){
|
||||
$cont_urls=$cont_urls[0];
|
||||
|
||||
if($config['url_merge']==cp_sign('match')){
|
||||
|
||||
$url_merge=false;
|
||||
}else{
|
||||
|
||||
foreach ($cont_urls as $k=>$v){
|
||||
$cont_urls[$k]=array(
|
||||
'match'=>$v
|
||||
);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
$cont_urls=array();
|
||||
}
|
||||
}
|
||||
}
|
||||
}elseif(in_array($config['reg_url_module'],array('xpath','json'))){
|
||||
|
||||
if('xpath'==$config['reg_url_module']){
|
||||
|
||||
$cont_urls=$this->rule_module_xpath_data ( array (
|
||||
'xpath' => $config['reg_url'],
|
||||
'xpath_attr' => 'href',
|
||||
'xpath_multi'=>true,
|
||||
'xpath_multi_type'=>'loop'
|
||||
),$html);
|
||||
$cont_urls=is_array($cont_urls)?$cont_urls:array();
|
||||
}elseif('json'==$config['reg_url_module']){
|
||||
|
||||
$cont_urls=$this->rule_module_json_data(array('json'=>$config['reg_url'],'json_arr'=>'_original_'),$html);
|
||||
if(empty($cont_urls)){
|
||||
$cont_urls=array();
|
||||
}elseif(!is_array($cont_urls)){
|
||||
$cont_urls=array($cont_urls);
|
||||
}
|
||||
}
|
||||
|
||||
if($config['url_merge']==cp_sign('match')){
|
||||
|
||||
$url_merge=false;
|
||||
}else{
|
||||
|
||||
foreach ($cont_urls as $k=>$v){
|
||||
$cont_urls[$k]=array(
|
||||
'match'=>$v
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($url_merge){
|
||||
|
||||
foreach ($cont_urls as $k=>$v){
|
||||
$re_match=array();
|
||||
foreach($match_signs['num'] as $ms_k=>$ms_v){
|
||||
|
||||
$re_match[$ms_k]=$v['match'.$ms_v];
|
||||
}
|
||||
|
||||
$cont_urls[$k]=str_replace($match_signs[0], $re_match, $config['url_merge']);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$cont_urls=is_array($cont_urls)?array_unique($cont_urls):array();
|
||||
$cont_urls=array_values($cont_urls);
|
||||
return $cont_urls;
|
||||
public function rule_match_urls($config,$html,$whole=false,$returnMatch=false){
|
||||
$cont_urls=array();
|
||||
$cont_urls_matches=array();
|
||||
if(!empty($config['reg_url'])&&!empty($config['url_merge'])){
|
||||
|
||||
$sign_match=$this->sign_addslashes(cp_sign('match','(?P<num>\d*)'));
|
||||
if(preg_match_all('/'.$sign_match.'/i', $config['url_merge'],$match_signs)){
|
||||
|
||||
$url_merge=true;
|
||||
if(empty($config['reg_url_module'])){
|
||||
|
||||
if(preg_match('/\(\?P<match\d*>/i', $config['reg_url'])){
|
||||
|
||||
if(preg_match_all('/'.$config['reg_url'].'/i',$html,$cont_urls,PREG_SET_ORDER)){
|
||||
if($config['url_merge']==cp_sign('match')){
|
||||
|
||||
if($returnMatch){
|
||||
|
||||
$cont_urls_matches=$cont_urls;
|
||||
}
|
||||
$url_merge=false;
|
||||
foreach ($cont_urls as $k=>$v){
|
||||
$cont_urls[$k]=$v['match'];
|
||||
}
|
||||
}else{
|
||||
if($returnMatch){
|
||||
|
||||
$cont_urls_matches=$cont_urls;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
$cont_urls=array();
|
||||
}
|
||||
}else{
|
||||
|
||||
if($whole){
|
||||
|
||||
if(preg_match_all('/'.$config['reg_url'].'/i',$html,$cont_urls)){
|
||||
$cont_urls=$cont_urls[0];
|
||||
|
||||
if($config['url_merge']==cp_sign('match')){
|
||||
|
||||
$url_merge=false;
|
||||
if($returnMatch){
|
||||
|
||||
foreach ($cont_urls as $k=>$v){
|
||||
$cont_urls_matches[$k]=array(
|
||||
'match'=>$v
|
||||
);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
|
||||
foreach ($cont_urls as $k=>$v){
|
||||
$cont_urls[$k]=array(
|
||||
'match'=>$v
|
||||
);
|
||||
}
|
||||
if($returnMatch){
|
||||
|
||||
$cont_urls_matches=$cont_urls;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
$cont_urls=array();
|
||||
}
|
||||
}
|
||||
}
|
||||
}elseif(in_array($config['reg_url_module'],array('xpath','json'))){
|
||||
|
||||
if('xpath'==$config['reg_url_module']){
|
||||
|
||||
$cont_urls=$this->rule_module_xpath_data ( array (
|
||||
'xpath' => $config['reg_url'],
|
||||
'xpath_attr' => 'href',
|
||||
'xpath_multi'=>true,
|
||||
'xpath_multi_type'=>'loop'
|
||||
),$html);
|
||||
$cont_urls=is_array($cont_urls)?$cont_urls:array();
|
||||
}elseif('json'==$config['reg_url_module']){
|
||||
|
||||
$cont_urls=$this->rule_module_json_data(array('json'=>$config['reg_url'],'json_arr'=>'_original_'),$html);
|
||||
if(empty($cont_urls)){
|
||||
$cont_urls=array();
|
||||
}elseif(!is_array($cont_urls)){
|
||||
$cont_urls=array($cont_urls);
|
||||
}
|
||||
}
|
||||
|
||||
if($config['url_merge']==cp_sign('match')){
|
||||
|
||||
$url_merge=false;
|
||||
if($returnMatch){
|
||||
|
||||
foreach ($cont_urls as $k=>$v){
|
||||
$cont_urls_matches[$k]=array(
|
||||
'match'=>$v
|
||||
);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
|
||||
foreach ($cont_urls as $k=>$v){
|
||||
$cont_urls[$k]=array(
|
||||
'match'=>$v
|
||||
);
|
||||
}
|
||||
if($returnMatch){
|
||||
|
||||
$cont_urls_matches=$cont_urls;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($url_merge){
|
||||
|
||||
foreach ($cont_urls as $k=>$v){
|
||||
$re_match=array();
|
||||
foreach($match_signs['num'] as $ms_k=>$ms_v){
|
||||
|
||||
$re_match[$ms_k]=$v['match'.$ms_v];
|
||||
}
|
||||
|
||||
$cont_urls[$k]=str_replace($match_signs[0], $re_match, $config['url_merge']);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($returnMatch){
|
||||
|
||||
$return=array('urls'=>array(),'matches'=>array());
|
||||
foreach($cont_urls as $k=>$v){
|
||||
if(in_array($v, $return['urls'])){
|
||||
continue;
|
||||
}
|
||||
$return['urls'][]=$v;
|
||||
foreach ($cont_urls_matches[$k] as $kk=>$kv){
|
||||
|
||||
if(stripos($kk,'match')!==0){
|
||||
unset($cont_urls_matches[$k][$kk]);
|
||||
}
|
||||
}
|
||||
$return['matches'][md5($v)]=$cont_urls_matches[$k];
|
||||
}
|
||||
return $return;
|
||||
}else{
|
||||
|
||||
$cont_urls=is_array($cont_urls)?array_unique($cont_urls):array();
|
||||
$cont_urls=array_values($cont_urls);
|
||||
return $cont_urls;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -399,13 +457,14 @@ class CpatternBase extends Collector{
|
|||
}
|
||||
|
||||
/*自动获取*/
|
||||
public function field_module_auto($field_params,&$html,$cur_url){
|
||||
public function field_module_auto($field_params,$html,$cur_url){
|
||||
switch (strtolower($field_params['auto'])){
|
||||
case 'title':$val=$this->get_title($html);break;
|
||||
case 'content':$val=$this->get_content($html);break;
|
||||
case 'keywords':$val=$this->get_keywords($html);break;
|
||||
case 'description':$val=$this->get_description($html);break;
|
||||
case 'url':$val=$cur_url;break;
|
||||
case 'html':$val=$html;break;
|
||||
}
|
||||
return $val;
|
||||
}
|
||||
|
@ -580,7 +639,7 @@ class CpatternBase extends Collector{
|
|||
if(!empty($extract_field_val['img'])){
|
||||
$val=reset($extract_field_val['img']);
|
||||
}else{
|
||||
if(preg_match('/<img[^<>]*\bsrc=[\'\"](?P<url>[^\'\"]+?)[\'\"]/i',$field_html,$cover)){
|
||||
if(preg_match('/<img\b[^<>]*\bsrc\s*=\s*[\'\"](?P<url>[^\'\"]+?)[\'\"]/i',$field_html,$cover)){
|
||||
$cover=$cover['url'];
|
||||
$cover=$this->create_complete_url($cover, $base_url, $domain_url);
|
||||
$val=$cover;
|
||||
|
@ -621,6 +680,52 @@ class CpatternBase extends Collector{
|
|||
}
|
||||
return $val;
|
||||
}
|
||||
|
||||
public function field_module_sign($field_params,$cont_url){
|
||||
$val='';
|
||||
$urlMd5=md5($cont_url);
|
||||
$sourceType=$field_params['source'];
|
||||
$sourceName='';
|
||||
if(preg_match('/^(level_url|relation_url):(.+)$/i', $sourceType,$sourceType)){
|
||||
$sourceName=$sourceType[2];
|
||||
$sourceType=$sourceType[1];
|
||||
}else{
|
||||
$sourceType='';
|
||||
$sourceName='';
|
||||
}
|
||||
|
||||
if(!empty($field_params['sign'])&&!empty($this->cur_source_signs[$sourceType])){
|
||||
$matches=null;
|
||||
if(empty($sourceType)){
|
||||
|
||||
$matches=$this->cur_source_signs[$sourceType][$sourceName][$urlMd5];
|
||||
}elseif($sourceType=='level_url'){
|
||||
|
||||
if(!empty($this->cur_level_urls[$sourceName])){
|
||||
$matches=$this->cur_source_signs[$sourceType][$sourceName][md5($this->cur_level_urls[$sourceName])];
|
||||
}else{
|
||||
$matches=null;
|
||||
}
|
||||
}elseif($sourceType=='relation_url'){
|
||||
|
||||
$matches=$this->cur_source_signs[$sourceType][$urlMd5][$sourceName];
|
||||
}
|
||||
if(!empty($matches)){
|
||||
$sign_match=$this->sign_addslashes(cp_sign('match','(?P<num>\d*)'));
|
||||
if(preg_match_all('/'.$sign_match.'/i', $field_params['sign'],$match_signs)){
|
||||
|
||||
$re_match=array();
|
||||
foreach($match_signs['num'] as $ms_k=>$ms_v){
|
||||
$re_match[$ms_k]=$matches['match'.$ms_v];
|
||||
}
|
||||
|
||||
$val=str_replace($match_signs[0], $re_match, $field_params['sign']);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $val;
|
||||
}
|
||||
|
||||
/*数据处理方法*/
|
||||
public function process_f_html($fieldVal,$params){
|
||||
$htmlAllow=array_filter(explode(',',$params['html_allow']));
|
||||
|
@ -738,7 +843,7 @@ class CpatternBase extends Collector{
|
|||
}
|
||||
return $fieldVal;
|
||||
}
|
||||
public function process_f_filter($fieldVal,$params,$curUrlMd5,$loopIndex,$contUrlMd5){
|
||||
public function process_f_filter($fieldVal,$params,$curUrlMd5,$loopIndex,$contUrlMd5,$fieldName=''){
|
||||
static $key_list=array();
|
||||
if(!empty($params['filter_list'])){
|
||||
$listMd5=md5($params['filter_list']);
|
||||
|
@ -773,13 +878,13 @@ class CpatternBase extends Collector{
|
|||
|
||||
if(empty($this->first_loop_field)){
|
||||
|
||||
$this->exclude_cont_urls[$contUrlMd5][$curUrlMd5]='filter:'.$filterStr;
|
||||
$this->exclude_cont_urls[$contUrlMd5][$curUrlMd5]=json_encode(array('field'=>$fieldName,'type'=>'filter','filter'=>$filterStr));
|
||||
}else{
|
||||
|
||||
if(!isset($this->exclude_cont_urls[$contUrlMd5][$curUrlMd5])){
|
||||
$this->exclude_cont_urls[$contUrlMd5][$curUrlMd5]=array();
|
||||
}
|
||||
$this->exclude_cont_urls[$contUrlMd5][$curUrlMd5][$loopIndex]='filter:'.$filterStr;
|
||||
$this->exclude_cont_urls[$contUrlMd5][$curUrlMd5][$loopIndex]=json_encode(array('field'=>$fieldName,'type'=>'filter','filter'=>$filterStr));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -815,13 +920,13 @@ class CpatternBase extends Collector{
|
|||
|
||||
if(empty($this->first_loop_field)){
|
||||
|
||||
$this->exclude_cont_urls[$contUrlMd5][$curUrlMd5]='filter:';
|
||||
$this->exclude_cont_urls[$contUrlMd5][$curUrlMd5]=json_encode(array('field'=>$fieldName,'type'=>'filter','filter'=>''));
|
||||
}else{
|
||||
|
||||
if(!isset($this->exclude_cont_urls[$contUrlMd5][$curUrlMd5])){
|
||||
$this->exclude_cont_urls[$contUrlMd5][$curUrlMd5]=array();
|
||||
}
|
||||
$this->exclude_cont_urls[$contUrlMd5][$curUrlMd5][$loopIndex]='filter:';
|
||||
$this->exclude_cont_urls[$contUrlMd5][$curUrlMd5][$loopIndex]=json_encode(array('field'=>$fieldName,'type'=>'filter','filter'=>''));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -832,130 +937,136 @@ class CpatternBase extends Collector{
|
|||
}
|
||||
return $fieldVal;
|
||||
}
|
||||
public function process_f_if($fieldVal,$params,$curUrlMd5,$loopIndex,$contUrlMd5){
|
||||
public function process_f_if($fieldVal,$params,$curUrlMd5,$loopIndex,$contUrlMd5,$fieldName=''){
|
||||
static $func_list=array();
|
||||
|
||||
if(is_array($params['if_logic'])&&!empty($params['if_logic'])){
|
||||
|
||||
$resultOr=array();
|
||||
$resultAnd=array();
|
||||
$ifOrList=array();
|
||||
$ifAndList=array();
|
||||
|
||||
foreach($params['if_logic'] as $ifk=>$iflv){
|
||||
if(empty($iflv)||empty($params['if_cond'][$ifk])){
|
||||
|
||||
continue;
|
||||
}
|
||||
$ifVal=$params['if_val'][$ifk];
|
||||
$ifCond=$params['if_cond'][$ifk];
|
||||
$result=false;
|
||||
switch($ifCond){
|
||||
case 'regexp':
|
||||
if(preg_match('/'.$ifVal.'/', $fieldVal)){
|
||||
$result=true;
|
||||
}
|
||||
break;
|
||||
case 'func':
|
||||
$funcName=$params['if_addon']['func'][$ifk];
|
||||
$isTurn=$params['if_addon']['turn'][$ifk];
|
||||
$isTurn=$isTurn?true:false;
|
||||
|
||||
$result=$this->execute_plugin_func('processIf', $funcName, $fieldVal, $ifVal);
|
||||
$result=$result?true:false;
|
||||
if($isTurn){
|
||||
$result=$result?false:true;
|
||||
}
|
||||
|
||||
break;
|
||||
case 'has':$result=stripos($fieldVal,$ifVal)!==false?true:false;break;
|
||||
case 'nhas':$result=stripos($fieldVal,$ifVal)===false?true:false;break;
|
||||
case 'eq':$result=$fieldVal==$ifVal?true:false;break;
|
||||
case 'neq':$result=$fieldVal!=$ifVal?true:false;break;
|
||||
case 'heq':$result=$fieldVal===$ifVal?true:false;break;
|
||||
case 'nheq':$result=$fieldVal!==$ifVal?true:false;break;
|
||||
case 'gt':$result=$fieldVal>$ifVal?true:false;break;
|
||||
case 'egt':$result=$fieldVal>=$ifVal?true:false;break;
|
||||
case 'lt':$result=$fieldVal<$ifVal?true:false;break;
|
||||
case 'elt':$result=$fieldVal<=$ifVal?true:false;break;
|
||||
case 'time_eq':
|
||||
case 'time_egt':
|
||||
case 'time_elt':
|
||||
$fieldTime=is_numeric($fieldVal)?$fieldVal:strtotime($fieldVal);
|
||||
$valTime=is_numeric($ifVal)?$ifVal:strtotime($ifVal);
|
||||
if($ifCond=='time_eq'){
|
||||
|
||||
$result=$fieldTime==$valTime?true:false;
|
||||
}elseif($ifCond=='time_egt'){
|
||||
|
||||
$result=$fieldTime>=$valTime?true:false;
|
||||
}elseif($ifCond=='time_elt'){
|
||||
|
||||
$result=$fieldTime<=$valTime?true:false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if('or'==$iflv){
|
||||
if(!empty($resultAnd)){
|
||||
|
||||
$resultOr[]=$resultAnd;
|
||||
}
|
||||
$resultAnd=array();
|
||||
$resultOr[]=$result;
|
||||
}elseif('and'==$iflv){
|
||||
|
||||
$resultAnd[]=$result;
|
||||
}
|
||||
if('or'==$iflv){
|
||||
if(!empty($ifAndList)){
|
||||
|
||||
$ifOrList[]=$ifAndList;
|
||||
}
|
||||
$ifAndList=array();
|
||||
$ifAndList[]=$ifk;
|
||||
}elseif('and'==$iflv){
|
||||
|
||||
$ifAndList[]=$ifk;
|
||||
}
|
||||
}
|
||||
if(!empty($resultAnd)){
|
||||
|
||||
$resultOr[]=$resultAnd;
|
||||
if(!empty($ifAndList)){
|
||||
|
||||
$ifOrList[]=$ifAndList;
|
||||
}
|
||||
if(is_array($resultOr)&&!empty($resultOr)){
|
||||
$isTrue=false;
|
||||
foreach ($resultOr as $results){
|
||||
if(is_array($results)){
|
||||
|
||||
$andResult=true;
|
||||
foreach ($results as $result){
|
||||
if(!$result){
|
||||
|
||||
$andResult=false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
$results=$andResult;
|
||||
}
|
||||
if($results){
|
||||
|
||||
$isTrue=true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$exclude='';
|
||||
|
||||
switch ($params['if_type']){
|
||||
case '1':$exclude=$isTrue?'':'if:1';break;
|
||||
case '2':$exclude=$isTrue?'if:2':'';break;
|
||||
case '3':$exclude=!$isTrue?'':'if:3';break;
|
||||
case '4':$exclude=!$isTrue?'if:4':'';break;
|
||||
}
|
||||
|
||||
if($exclude){
|
||||
|
||||
if(!isset($this->exclude_cont_urls[$contUrlMd5])){
|
||||
$this->exclude_cont_urls[$contUrlMd5]=array();
|
||||
}
|
||||
|
||||
if(empty($this->first_loop_field)){
|
||||
|
||||
$this->exclude_cont_urls[$contUrlMd5][$curUrlMd5]=$exclude;
|
||||
}else{
|
||||
|
||||
if(!isset($this->exclude_cont_urls[$contUrlMd5][$curUrlMd5])){
|
||||
$this->exclude_cont_urls[$contUrlMd5][$curUrlMd5]=array();
|
||||
}
|
||||
$this->exclude_cont_urls[$contUrlMd5][$curUrlMd5][$loopIndex]=$exclude;
|
||||
}
|
||||
}
|
||||
if(is_array($ifOrList)&&!empty($ifOrList)){
|
||||
$isTrue=false;
|
||||
$breakCond='';
|
||||
|
||||
foreach ($ifOrList as $ifAndList){
|
||||
$ifAndResult=true;
|
||||
foreach ($ifAndList as $ifIndex){
|
||||
$ifLogic=$params['if_logic'][$ifIndex];
|
||||
$ifCond=$params['if_cond'][$ifIndex];
|
||||
if(empty($ifLogic)||empty($ifCond)){
|
||||
|
||||
continue;
|
||||
}
|
||||
$ifVal=$params['if_val'][$ifIndex];
|
||||
$result=false;
|
||||
$breakCond=lang('p_m_if_c_'.$ifCond).':'.$ifVal;
|
||||
switch($ifCond){
|
||||
case 'regexp':
|
||||
if(preg_match('/'.$ifVal.'/', $fieldVal)){
|
||||
$result=true;
|
||||
}
|
||||
break;
|
||||
case 'func':
|
||||
$funcName=$params['if_addon']['func'][$ifIndex];
|
||||
$isTurn=$params['if_addon']['turn'][$ifIndex];
|
||||
$isTurn=$isTurn?true:false;
|
||||
|
||||
$result=$this->execute_plugin_func('processIf', $funcName, $fieldVal, $ifVal);
|
||||
$result=$result?true:false;
|
||||
if($isTurn){
|
||||
$result=$result?false:true;
|
||||
}
|
||||
$breakCond=lang('p_m_if_c_'.$ifCond).':'.$funcName.($isTurn?'取反':'');
|
||||
break;
|
||||
case 'has':$result=stripos($fieldVal,$ifVal)!==false?true:false;break;
|
||||
case 'nhas':$result=stripos($fieldVal,$ifVal)===false?true:false;break;
|
||||
case 'eq':$result=$fieldVal==$ifVal?true:false;break;
|
||||
case 'neq':$result=$fieldVal!=$ifVal?true:false;break;
|
||||
case 'heq':$result=$fieldVal===$ifVal?true:false;break;
|
||||
case 'nheq':$result=$fieldVal!==$ifVal?true:false;break;
|
||||
case 'gt':$result=$fieldVal>$ifVal?true:false;break;
|
||||
case 'egt':$result=$fieldVal>=$ifVal?true:false;break;
|
||||
case 'lt':$result=$fieldVal<$ifVal?true:false;break;
|
||||
case 'elt':$result=$fieldVal<=$ifVal?true:false;break;
|
||||
case 'time_eq':
|
||||
case 'time_egt':
|
||||
case 'time_elt':
|
||||
$fieldTime=is_numeric($fieldVal)?$fieldVal:strtotime($fieldVal);
|
||||
$valTime=is_numeric($ifVal)?$ifVal:strtotime($ifVal);
|
||||
if($ifCond=='time_eq'){
|
||||
|
||||
$result=$fieldTime==$valTime?true:false;
|
||||
}elseif($ifCond=='time_egt'){
|
||||
|
||||
$result=$fieldTime>=$valTime?true:false;
|
||||
}elseif($ifCond=='time_elt'){
|
||||
|
||||
$result=$fieldTime<=$valTime?true:false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if(!$result){
|
||||
|
||||
$ifAndResult=false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if($ifAndResult){
|
||||
|
||||
$isTrue=true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$exclude=null;
|
||||
|
||||
switch ($params['if_type']){
|
||||
case '1':$exclude=$isTrue?null:array('if'=>'1');break;
|
||||
case '2':$exclude=$isTrue?array('if'=>'2'):null;break;
|
||||
case '3':$exclude=!$isTrue?null:array('if'=>'3');break;
|
||||
case '4':$exclude=!$isTrue?array('if'=>'4'):null;break;
|
||||
}
|
||||
|
||||
if(!empty($exclude)){
|
||||
$exclude['type']='if';
|
||||
$exclude['field']=$fieldName;
|
||||
$exclude['cond']=$breakCond;
|
||||
$exclude=json_encode($exclude);
|
||||
|
||||
if(!isset($this->exclude_cont_urls[$contUrlMd5])){
|
||||
$this->exclude_cont_urls[$contUrlMd5]=array();
|
||||
}
|
||||
|
||||
if(empty($this->first_loop_field)){
|
||||
|
||||
$this->exclude_cont_urls[$contUrlMd5][$curUrlMd5]=$exclude;
|
||||
}else{
|
||||
|
||||
if(!isset($this->exclude_cont_urls[$contUrlMd5][$curUrlMd5])){
|
||||
$this->exclude_cont_urls[$contUrlMd5][$curUrlMd5]=array();
|
||||
}
|
||||
$this->exclude_cont_urls[$contUrlMd5][$curUrlMd5][$loopIndex]=$exclude;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $fieldVal;
|
||||
|
@ -1015,11 +1126,11 @@ class CpatternBase extends Collector{
|
|||
return $fieldVal;
|
||||
}
|
||||
/*数据处理*/
|
||||
public function process_field($fieldVal,$process,$curUrlMd5,$loopIndex,$contUrlMd5){
|
||||
public function process_field($fieldName,$fieldVal,$process,$curUrlMd5,$loopIndex,$contUrlMd5){
|
||||
if(empty($process)){
|
||||
return $fieldVal;
|
||||
}
|
||||
static $funcs=array('func','filter','if');
|
||||
static $condFuncs=array('filter','if');
|
||||
foreach ($process as $params){
|
||||
|
||||
if(empty($this->first_loop_field)){
|
||||
|
@ -1035,8 +1146,11 @@ class CpatternBase extends Collector{
|
|||
}
|
||||
$funcName='process_f_'.$params['module'];
|
||||
if(method_exists($this, $funcName)){
|
||||
if(in_array($params['module'],$funcs)){
|
||||
$fieldVal=$this->$funcName($fieldVal,$params,$curUrlMd5,$loopIndex,$contUrlMd5);
|
||||
if(in_array($params['module'],$condFuncs)){
|
||||
|
||||
$fieldVal=$this->$funcName($fieldVal,$params,$curUrlMd5,$loopIndex,$contUrlMd5,$fieldName);
|
||||
}elseif($params['module']=='func'){
|
||||
$fieldVal=$this->$funcName($fieldVal,$params,$curUrlMd5,$loopIndex,$contUrlMd5);
|
||||
}else{
|
||||
$fieldVal=$this->$funcName($fieldVal,$params);
|
||||
}
|
||||
|
@ -1166,35 +1280,40 @@ class CpatternBase extends Collector{
|
|||
}
|
||||
/*排除内容网址的提示信息*/
|
||||
public function exclude_url_msg($val){
|
||||
$val=explode(':', $val);
|
||||
$type='';
|
||||
if(is_array($val)){
|
||||
$type=$val[0];
|
||||
$val=$val[1];
|
||||
}else{
|
||||
$type=$val;
|
||||
$val='';
|
||||
}
|
||||
try{
|
||||
$val=json_decode($val,true);
|
||||
}catch (\Exception $ex){
|
||||
$val=array();
|
||||
}
|
||||
if(!is_array($val)){
|
||||
$val=array();
|
||||
}
|
||||
$type=$val['type'];
|
||||
$msg='排除网址';
|
||||
if($type=='filter'){
|
||||
|
||||
if(empty($val)){
|
||||
$msg='关键词过滤';
|
||||
if(empty($val['filter'])){
|
||||
$msg='字段:'.$val['field'].'»关键词过滤:未检测到关键词';
|
||||
}else{
|
||||
$msg='关键词过滤:'.$val;
|
||||
$msg='字段:'.$val['field'].'»关键词过滤:'.$val['filter'];
|
||||
}
|
||||
}elseif($type=='if'){
|
||||
$msg='条件';
|
||||
$msg='字段:'.$val['field'].'»条件';
|
||||
|
||||
switch ($val){
|
||||
switch ($val['if']){
|
||||
case '1':$msg.='假';break;
|
||||
case '2':$msg.='真';break;
|
||||
case '3':$msg.='假';break;
|
||||
case '4':$msg.='真';break;
|
||||
}
|
||||
if(lang('?p_m_if_'.$val)){
|
||||
$msg.=':'.lang('p_m_if_'.$val);
|
||||
$msg.='(';
|
||||
if(lang('?p_m_if_'.$val['if'])){
|
||||
$msg.=lang('p_m_if_'.$val['if']);
|
||||
}
|
||||
if(!empty($val['cond'])){
|
||||
$msg.='»'.$val['cond'];
|
||||
}
|
||||
$msg.=')';
|
||||
}
|
||||
return $msg;
|
||||
}
|
||||
|
@ -1531,12 +1650,14 @@ class CpatternBase extends Collector{
|
|||
|
||||
$base_url=$this->match_base_url($url, $html);
|
||||
$domain_url=$this->match_domain_url($url, $html);
|
||||
$html=preg_replace_callback('/(?<=\bhref\=[\'\"])([^\'\"]*)(?=[\'\"])/i',function($matche) use ($base_url,$domain_url){
|
||||
$html=preg_replace_callback('/(\bhref\s*=\s*[\'\"])([^\'\"]*)([\'\"])/i',function($matche) use ($base_url,$domain_url){
|
||||
|
||||
return \skycaiji\admin\event\Cpattern::create_complete_url($matche[1], $base_url, $domain_url);
|
||||
$matche[2]=\skycaiji\admin\event\Cpattern::create_complete_url($matche[2], $base_url, $domain_url);
|
||||
return $matche[1].$matche[2].$matche[3];
|
||||
},$html);
|
||||
$html=preg_replace_callback('/(?<=\bsrc\=[\'\"])([^\'\"]*)(?=[\'\"])/i',function($matche) use ($base_url,$domain_url){
|
||||
return \skycaiji\admin\event\Cpattern::create_complete_url($matche[1], $base_url, $domain_url);
|
||||
$html=preg_replace_callback('/(\bsrc\s*=\s*[\'\"])([^\'\"]*)([\'\"])/i',function($matche) use ($base_url,$domain_url){
|
||||
$matche[2]=\skycaiji\admin\event\Cpattern::create_complete_url($matche[2], $base_url, $domain_url);
|
||||
return $matche[1].$matche[2].$matche[3];
|
||||
},$html);
|
||||
}
|
||||
if($openCache){
|
||||
|
|
|
@ -70,10 +70,10 @@ class Rcms extends Release{
|
|||
$this->rele_cms_list[$releCms]->init(null,$this->release);
|
||||
}
|
||||
$releCms=$this->rele_cms_list[$releCms];
|
||||
|
||||
$addedNum=0;
|
||||
|
||||
foreach ($collFieldsList as $collFieldsKey=>$collFields){
|
||||
$this->init_download_img($this->task,$collFields['fields']);
|
||||
$return=$releCms->runExport($collFields['fields']);
|
||||
if($return['id']>0){
|
||||
$addedNum++;
|
||||
|
|
|
@ -74,6 +74,7 @@ class Rdb extends Release{
|
|||
$contTitle=$collFields['title'];
|
||||
$contUrl=$collFields['url'];
|
||||
$collFields=$collFields['fields'];
|
||||
$this->init_download_img($this->task,$collFields);
|
||||
$tableFields=array();
|
||||
foreach ($this->config['db_table']['field'] as $tbName=>$tbFields){
|
||||
foreach ($tbFields as $tbField=>$fieldVal){
|
||||
|
|
|
@ -84,6 +84,7 @@ class Rdiy extends Release{
|
|||
$releDiy->db()->startTrans();
|
||||
$errorMsg=false;
|
||||
$contUrl=$collFields['url'];
|
||||
$this->init_download_img($this->task,$collFields['fields']);
|
||||
try {
|
||||
$return=$releDiy->runExport($contUrl,$collFields['fields']);
|
||||
if(empty($return)){
|
||||
|
|
|
@ -183,8 +183,17 @@ class ReleaseBase extends \skycaiji\admin\controller\BaseController{
|
|||
}
|
||||
}elseif('custom'==$imgname){
|
||||
|
||||
$imgname=model('Config')->convert_img_name_path($GLOBALS['_sc']['c']['download_img']['name_custom_path'],$url);
|
||||
$imgname.='/'.$key.'.'.$prop;
|
||||
$customPath=$GLOBALS['_sc']['c']['download_img']['name_custom_path'];
|
||||
if(isset($GLOBALS['_sc']['c']['download_img']['_name_custom_path'])){
|
||||
$customPath=$GLOBALS['_sc']['c']['download_img']['_name_custom_path'];
|
||||
}
|
||||
$customName=$GLOBALS['_sc']['c']['download_img']['name_custom_name'];
|
||||
if(isset($GLOBALS['_sc']['c']['download_img']['_name_custom_name'])){
|
||||
$customName=$GLOBALS['_sc']['c']['download_img']['_name_custom_name'];
|
||||
}
|
||||
$customPath=model('Config')->convert_img_name_path($customPath,$url);
|
||||
$customName=model('Config')->convert_img_name_name($customName,$url);
|
||||
$imgname=$customPath.'/'.$customName.'.'.$prop;
|
||||
$filename=$img_path.$imgname;
|
||||
$isExists=file_exists($filename);
|
||||
}else{
|
||||
|
@ -231,7 +240,6 @@ class ReleaseBase extends \skycaiji\admin\controller\BaseController{
|
|||
}
|
||||
|
||||
$imgCode=get_html($url,$headers,$options,'utf-8');
|
||||
|
||||
if(!empty($imgCode)){
|
||||
|
||||
if(write_dir_file($filename,$imgCode)){
|
||||
|
@ -240,7 +248,7 @@ class ReleaseBase extends \skycaiji\admin\controller\BaseController{
|
|||
}
|
||||
|
||||
}catch (\Exception $ex){
|
||||
|
||||
|
||||
}
|
||||
}else{
|
||||
|
||||
|
@ -300,5 +308,79 @@ class ReleaseBase extends \skycaiji\admin\controller\BaseController{
|
|||
public function write_file($filename,$data){
|
||||
return write_dir_file($filename,$data);
|
||||
}
|
||||
|
||||
public function init_download_img($taskData,$collFields){
|
||||
if(!empty($GLOBALS['_sc']['c']['download_img']['download_img'])&&$GLOBALS['_sc']['c']['download_img']['img_name']=='custom'){
|
||||
|
||||
if(empty($taskData)){
|
||||
$taskData=array();
|
||||
}
|
||||
if(empty($collFields)){
|
||||
$collFields=array();
|
||||
}
|
||||
|
||||
$name_custom_path=$GLOBALS['_sc']['c']['download_img']['name_custom_path'];
|
||||
$check=model('Config')->check_img_name_path($name_custom_path);
|
||||
if($check['success']){
|
||||
$name_custom_path=$this->_convert_img_params($name_custom_path, $taskData, $collFields);
|
||||
}else{
|
||||
$name_custom_path='temp';
|
||||
}
|
||||
|
||||
$GLOBALS['_sc']['c']['download_img']['_name_custom_path']=$name_custom_path;
|
||||
|
||||
|
||||
$name_custom_name=$GLOBALS['_sc']['c']['download_img']['name_custom_name'];
|
||||
$check=model('Config')->check_img_name_name($name_custom_name);
|
||||
if($check['success']){
|
||||
$name_custom_name=$this->_convert_img_params($name_custom_name, $taskData, $collFields);
|
||||
}else{
|
||||
$name_custom_name='';
|
||||
}
|
||||
|
||||
$GLOBALS['_sc']['c']['download_img']['_name_custom_name']=$name_custom_name;
|
||||
}else{
|
||||
|
||||
unset($GLOBALS['_sc']['c']['download_img']['_name_custom_path']);
|
||||
unset($GLOBALS['_sc']['c']['download_img']['_name_custom_name']);
|
||||
}
|
||||
}
|
||||
|
||||
private function _convert_img_params($str,$taskData,$collFields){
|
||||
if(empty($taskData)){
|
||||
$taskData=array();
|
||||
}
|
||||
if(empty($collFields)){
|
||||
$collFields=array();
|
||||
}
|
||||
|
||||
$customParams=array(
|
||||
'[任务名]'=>$taskData['name'],
|
||||
'[任务ID]'=>$taskData['id']
|
||||
);
|
||||
|
||||
if(preg_match_all('/\[([^\[\]]+?)\]/', $str,$mparams)){
|
||||
for($i=0;$i<count($mparams[0]);$i++){
|
||||
$param=$mparams[0][$i];
|
||||
if(preg_match('/^字段\:(.*)$/u',$mparams[1][$i],$mfield)){
|
||||
$customParams[$param]=$collFields[$mfield[1]]['value'];
|
||||
}
|
||||
}
|
||||
foreach ($customParams as $k=>$v){
|
||||
|
||||
$v=preg_replace('/[\/\s\r\n\~\`\!\@\#\$\%\^\&\*\(\)\+\=\{\}\[\]\|\\\\:\;\"\'\<\>\,\?]+/', '_', $v);
|
||||
if(mb_strlen($v,'utf-8')>100){
|
||||
|
||||
$v=mb_substr($v,0,100,'utf-8');
|
||||
}
|
||||
$v=preg_replace('/\_{2,}/', '_', $v);
|
||||
$v=trim($v,'_');
|
||||
$customParams[$k]=$v;
|
||||
}
|
||||
$str=str_replace(array_keys($customParams),$customParams,$str);
|
||||
}
|
||||
|
||||
return $str;
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -79,7 +79,8 @@ class Rfile extends Release {
|
|||
|
||||
$addedNum=0;
|
||||
foreach ($collFieldsList as $collFieldsKey=>$collFields){
|
||||
|
||||
|
||||
$this->init_download_img($this->task,$collFields['fields']);
|
||||
$addedNum++;
|
||||
$curRow=$rowNum+$addedNum;
|
||||
$collFields['fields']=is_array($collFields['fields'])?array_values($collFields['fields']):array();
|
||||
|
|
|
@ -84,6 +84,7 @@ class Rtoapi extends Release{
|
|||
$contTitle=$collFields['title'];
|
||||
$contUrl=$collFields['url'];
|
||||
$collFields=$collFields['fields'];
|
||||
$this->init_download_img($this->task,$collFields);
|
||||
|
||||
$params=array();
|
||||
if(is_array($this->config['toapi']['param_name'])){
|
||||
|
|
|
@ -156,6 +156,7 @@ return array(
|
|||
'field_module_json'=>'JSON提取',
|
||||
'field_module_merge'=>'字段组合',
|
||||
'field_module_extract'=>'字段提取',
|
||||
'field_module_sign'=>'[内容]标签',
|
||||
|
||||
'process_module_html'=>'html标签过滤',
|
||||
'process_module_replace'=>'内容替换',
|
||||
|
@ -172,6 +173,24 @@ return array(
|
|||
'p_m_if_2'=>'满足条件不采集',
|
||||
'p_m_if_3'=>'不满足条件采集',
|
||||
'p_m_if_4'=>'不满足条件不采集',
|
||||
|
||||
|
||||
'p_m_if_c_has'=>'包含',
|
||||
'p_m_if_c_nhas'=>'不包含',
|
||||
'p_m_if_c_eq'=>'等于',
|
||||
'p_m_if_c_neq'=>'不等于',
|
||||
'p_m_if_c_heq'=>'恒等于',
|
||||
'p_m_if_c_nheq'=>'不恒等于',
|
||||
'p_m_if_c_gt'=>'大于',
|
||||
'p_m_if_c_egt'=>'大于等于',
|
||||
'p_m_if_c_lt'=>'小于',
|
||||
'p_m_if_c_elt'=>'小于等于',
|
||||
'p_m_if_c_time_eq'=>'时间等于',
|
||||
'p_m_if_c_time_egt'=>'时间大于等于',
|
||||
'p_m_if_c_time_elt'=>'时间小于等于',
|
||||
'p_m_if_c_regexp'=>'正则表达式',
|
||||
'p_m_if_c_func'=>'使用函数',
|
||||
|
||||
|
||||
'rele_set'=>'发布设置',
|
||||
'rele_error_detect_null'=>'没有检测到本地CMS程序,您可以手动绑定数据',
|
||||
|
|
|
@ -137,49 +137,111 @@ class Config extends BaseModel {
|
|||
|
||||
public function check_img_name_path($path){
|
||||
static $check_list=array();
|
||||
if(!isset($check_list[$path])){
|
||||
$pathMd5=md5($path);
|
||||
if(!isset($check_list[$pathMd5])){
|
||||
$return=array('success'=>false,'msg'=>'');
|
||||
if(!empty($path)){
|
||||
if(!preg_match('/^(\w+|\-|\/|(\[(年|月|日|时|前两位|后两位)\]))+$/u',$path)){
|
||||
$return['msg']='图片名称自定义目录只能输入字母、数字、- 、/ 或 标签';
|
||||
if(!preg_match('/^(\w+|\-|\/|(\[(年|月|日|时|分|秒|前两位|后两位|任务名|任务ID)\])|(\[字段\:[^\/\[\]]+?\]))+$/u',$path)){
|
||||
$return['msg']='图片名称自定义路径只能输入字母、数字、下划线、/ 或 使用标签';
|
||||
}else{
|
||||
if(preg_match('/^\/+$/', $path)){
|
||||
$return['msg']='图片名称自定义目录不能只由/组成';
|
||||
$return['msg']='图片名称自定义路径不能只由/组成';
|
||||
}else{
|
||||
$return['success']=true;
|
||||
}
|
||||
}
|
||||
}
|
||||
$check_list[$path]=$return;
|
||||
$check_list[$pathMd5]=$return;
|
||||
}else{
|
||||
$return=$check_list[$path];
|
||||
$return=$check_list[$pathMd5];
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
public function convert_img_name_path($path,$url){
|
||||
$check=$this->check_img_name_path($path);
|
||||
if($check['success']){
|
||||
$md5=md5($url);
|
||||
static $tags=array('[年]','[月]','[日]','[时]','[前两位]','[后两位]');
|
||||
$tagsRe=array(
|
||||
date('Y',NOW_TIME),
|
||||
date('m',NOW_TIME),
|
||||
date('d',NOW_TIME),
|
||||
date('H',NOW_TIME),
|
||||
substr($md5,0,2),
|
||||
substr($md5,-2,2),
|
||||
);
|
||||
$path=preg_replace('/\/{2,}/', '/', $path);
|
||||
$path=str_replace($tags, $tagsRe, $path);
|
||||
$path=trim($path,'/');
|
||||
}else{
|
||||
$path='temp';
|
||||
if(!empty($path)){
|
||||
$md5=md5($url);
|
||||
static $tags=array('[年]','[月]','[日]','[时]','[分]','[秒]','[前两位]','[后两位]');
|
||||
$tagsRe=array(
|
||||
date('Y',NOW_TIME),
|
||||
date('m',NOW_TIME),
|
||||
date('d',NOW_TIME),
|
||||
date('H',NOW_TIME),
|
||||
date('i',NOW_TIME),
|
||||
date('s',NOW_TIME),
|
||||
substr($md5,0,2),
|
||||
substr($md5,-2,2),
|
||||
);
|
||||
$path=str_replace($tags, $tagsRe, $path);
|
||||
$path=preg_replace('/[\s\r\n\~\`\!\@\#\$\%\^\&\*\(\)\+\=\{\}\[\]\|\\\\:\;\"\'\<\>\,\?]+/', '_', $path);
|
||||
$path=preg_replace('/\_{2,}/', '_', $path);
|
||||
$path=preg_replace('/\/{2,}/', '/', $path);
|
||||
$path=trim($path,'_');
|
||||
$path=trim($path,'/');
|
||||
}
|
||||
if(empty($path)){
|
||||
$path='temp';
|
||||
}
|
||||
return $path;
|
||||
}
|
||||
|
||||
|
||||
public function check_img_name_name($name){
|
||||
static $check_list=array();
|
||||
$nameMd5=md5($name);
|
||||
if(!isset($check_list[$nameMd5])){
|
||||
$return=array('success'=>false,'msg'=>'');
|
||||
if(!empty($name)){
|
||||
if(!preg_match('/^(\w+|\-|(\[(年|月|日|时|分|秒|前两位|后两位|任务名|任务ID|图片网址MD5码|图片原名)\])|(\[字段\:[^\/\[\]]+?\]))+$/u',$name)){
|
||||
$return['msg']='图片名称自定义名称只能输入字母、数字、下划线 或 使用标签';
|
||||
}else{
|
||||
$return['success']=true;
|
||||
}
|
||||
}
|
||||
$check_list[$nameMd5]=$return;
|
||||
}else{
|
||||
$return=$check_list[$nameMd5];
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
public function convert_img_name_name($name,$url){
|
||||
$md5=md5($url);
|
||||
if(!empty($name)){
|
||||
$urlname='';
|
||||
if(preg_match('/([^\/]+?)\./', $url,$urlname)){
|
||||
$urlname=$urlname[1];
|
||||
}else{
|
||||
$urlname='';
|
||||
}
|
||||
if(empty($urlname)){
|
||||
|
||||
$urlname=$md5;
|
||||
}
|
||||
|
||||
static $tags=array('[年]','[月]','[日]','[时]','[分]','[秒]','[前两位]','[后两位]','[图片网址MD5码]','[图片原名]');
|
||||
$tagsRe=array(
|
||||
date('Y',NOW_TIME),
|
||||
date('m',NOW_TIME),
|
||||
date('d',NOW_TIME),
|
||||
date('H',NOW_TIME),
|
||||
date('i',NOW_TIME),
|
||||
date('s',NOW_TIME),
|
||||
substr($md5,0,2),
|
||||
substr($md5,-2,2),
|
||||
$md5,
|
||||
$urlname
|
||||
);
|
||||
$name=str_replace($tags, $tagsRe, $name);
|
||||
$name=preg_replace('/[\/\s\r\n\~\`\!\@\#\$\%\^\&\*\(\)\+\=\{\}\[\]\|\\\\:\;\"\'\<\>\,\?]+/', '_', $name);
|
||||
$name=preg_replace('/\_{2,}/', '_', $name);
|
||||
$name=trim($name,'_');
|
||||
}
|
||||
if(empty($name)){
|
||||
$name=$md5;
|
||||
}
|
||||
return $name;
|
||||
}
|
||||
|
||||
public function get_img_config_from_caiji($caijiConfig){
|
||||
$config=array();
|
||||
|
|
|
@ -11,7 +11,8 @@
|
|||
|
||||
namespace skycaiji\admin\model;
|
||||
class Task extends BaseModel{
|
||||
public function loadConfig($config){
|
||||
public function loadConfig($taskData){
|
||||
$config=$taskData['config'];
|
||||
if(empty($config)){
|
||||
$config=array();
|
||||
}
|
||||
|
@ -19,6 +20,9 @@ class Task extends BaseModel{
|
|||
|
||||
$config=unserialize($config);
|
||||
}
|
||||
if(!is_array($config)){
|
||||
$config=array();
|
||||
}
|
||||
|
||||
static $global_config=null;
|
||||
if(!isset($global_config)){
|
||||
|
@ -48,9 +52,17 @@ class Task extends BaseModel{
|
|||
}else{
|
||||
$GLOBALS['_sc']['c']['proxy']['open']=0;
|
||||
}
|
||||
|
||||
$GLOBALS['_sc']['c']['download_img']['img_path']=empty($config['img_path'])?$global_config['download_img']['img_path']:$config['img_path'];
|
||||
$GLOBALS['_sc']['c']['download_img']['img_url']=empty($config['img_url'])?$global_config['download_img']['img_url']:$config['img_url'];
|
||||
|
||||
static $imgParams=array('img_path','img_url','img_name','name_custom_path','name_custom_name');
|
||||
foreach ($imgParams as $imgParam){
|
||||
|
||||
$GLOBALS['_sc']['c']['download_img'][$imgParam]=empty($config[$imgParam])?$global_config['download_img'][$imgParam]:$config[$imgParam];
|
||||
}
|
||||
if(empty($config['img_name'])){
|
||||
|
||||
$GLOBALS['_sc']['c']['download_img']['name_custom_path']=$global_config['download_img']['name_custom_path'];
|
||||
$GLOBALS['_sc']['c']['download_img']['name_custom_name']=$global_config['download_img']['name_custom_name'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
{/if}
|
||||
{if !empty($provData)}
|
||||
<dt>平台</dt>
|
||||
<dd><a href="{:url('admin/store/index?url='.urlencode($provData['url']))}">第三方平台</a></dd>
|
||||
<dd><a href="{:url('admin/mystore/store?url='.urlencode($provData['url']))}">第三方平台</a></dd>
|
||||
{elseif !empty($appData['config']['website'])}
|
||||
<dt>网站</dt>
|
||||
<dd><a href="{$appData['config']['website']}" target="_blank">作者网站</a></dd>
|
||||
|
|
|
@ -18,8 +18,8 @@
|
|||
<th width="60" class="chk">{$Think.lang.select}</th>
|
||||
<th class="url">源网址</th>
|
||||
<th>已发布至</th>
|
||||
<th>发布方式</th>
|
||||
<th>任务名</th>
|
||||
<th>发布方式</th>
|
||||
<th>添加时间</th>
|
||||
<th>{$Think.lang.op}</th>
|
||||
</tr>
|
||||
|
@ -36,8 +36,8 @@
|
|||
{$item['target']} {$item['desc']?$item['desc']:''}
|
||||
{/if}
|
||||
</td>
|
||||
<td>{:lang('collected_rele_'.$item['release'])}</td>
|
||||
<td><a href="{:url('Admin/Task/edit?id='.$item['task_id'])}" target="_blank">{$taskList[$item['task_id']]}</a></td>
|
||||
<td>{:lang('collected_rele_'.$item['release'])}</td>
|
||||
<td>{:date('Y-m-d H:i:s',$item['addtime'])}</td>
|
||||
<td><a href="javascript:;" url="{:url('Collected/op?op=delete&id='.$item['id'])}" class="delete">删除</a></td>
|
||||
</tr>
|
||||
|
|
|
@ -31,5 +31,5 @@
|
|||
</script>
|
||||
</div>
|
||||
{else /}
|
||||
没有规则,请进入<a href="{:url('Store/index')}">云平台</a>下载
|
||||
没有规则,请进入<a href="{:url('Mystore/store')}">云平台</a>下载
|
||||
{/if}
|
|
@ -86,7 +86,7 @@
|
|||
</span>
|
||||
</a>
|
||||
<ul class="treeview-menu">
|
||||
<li><a href="{:url('Admin/Store/index')}"><i class="fa fa-circle-o"></i> 云平台</a></li>
|
||||
<li><a href="{:url('Admin/Mystore/store')}"><i class="fa fa-circle-o"></i> 云平台</a></li>
|
||||
<li><a href="{:url('Admin/Provider/list')}"><i class="fa fa-circle-o"></i> 第三方</a></li>
|
||||
<li class="treeview menu-open">
|
||||
<a href="#"><i class="fa fa-circle-o"></i> 已下载
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<div class="input-group-btn c-p-field-source" title="选择数据源">
|
||||
<select name="field[source]" class="form-control slt-field-source">
|
||||
<optgroup label="选择数据源">
|
||||
<option value="">默认页</option>
|
||||
<option value="">内容页</option>
|
||||
<option value="source_url">起始页</option>
|
||||
</optgroup>
|
||||
</select>
|
||||
|
@ -22,6 +22,7 @@
|
|||
<option value="xpath">{$Think.lang.field_module_xpath}</option>
|
||||
<option value="json">{$Think.lang.field_module_json}</option>
|
||||
<option value="auto">{$Think.lang.field_module_auto}</option>
|
||||
<option value="sign">{$Think.lang.field_module_sign}</option>
|
||||
<optgroup label="数据生成">
|
||||
<option value="words">{$Think.lang.field_module_words}</option>
|
||||
<option value="num">{$Think.lang.field_module_num}</option>
|
||||
|
@ -82,15 +83,18 @@
|
|||
<label class="radio-inline">
|
||||
<input type="radio" name="field[auto]" value="url">页面网址
|
||||
</label>
|
||||
<label class="radio-inline">
|
||||
<input type="radio" name="field[auto]" value="html">源码
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="c-p-field-module" module="xpath" style="display:none;">
|
||||
<div class="form-group">
|
||||
<label>规则:</label>
|
||||
<label>规则</label>
|
||||
<textarea name="field[xpath]" class="form-control" rows="3">{$field['xpath']}</textarea>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>属性:</label>
|
||||
<label>属性</label>
|
||||
<select name="field[xpath_attr]" class="form-control">
|
||||
<option value="">无</option>
|
||||
<option value="innerHtml">innerHtml</option>
|
||||
|
@ -249,6 +253,13 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="c-p-field-module" module="sign" style="display:none;">
|
||||
<div class="form-group">
|
||||
<textarea name="field[sign]" class="form-control" rows="3" placeholder="填入数据源“提取网址规则”中的{:cp_sign('match')}标签">{$field['sign']}</textarea>
|
||||
<div id="c_p_field_sign_list" style="margin-top:5px;"></div>
|
||||
<p class="help-block"></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group form-group-sm">
|
||||
|
|
|
@ -88,6 +88,22 @@
|
|||
<div class="form-group form-group-sm">
|
||||
<button type="submit" class="btn btn-primary btn-block">确定</button>
|
||||
</div>
|
||||
<div class="panel panel-default panel-sign-field">
|
||||
<div class="panel-heading">
|
||||
<div class="panel-title">
|
||||
<a data-toggle="collapse" href="#c_p_sign_field_level_url">将{:cp_sign('match')}添加为字段</a>
|
||||
<a href="javascript:;" class="glyphicon glyphicon-plus add-level-field" data-val="" title="添加"></a>
|
||||
</div>
|
||||
</div>
|
||||
<div id="c_p_sign_field_level_url" class="panel-collapse collapse">
|
||||
<div class="panel-body">
|
||||
<div class="form-group">
|
||||
<div class="c-p-sign-field-list"></div>
|
||||
<p class="help-block">将“提取网址规则”中的{:cp_sign('match')}标签添加为字段</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<script type="text/javascript">
|
||||
{if condition="$level_url"}
|
||||
|
|
|
@ -68,6 +68,7 @@
|
|||
<div class="radio"><label><input type="radio" data-process="filter:filter_pass" value="2" /> 检测到关键词不采集该条数据</label></div>
|
||||
<div class="radio"><label><input type="radio" data-process="filter:filter_pass" value="3" /> 未检测到关键词将该字段值设为空</label></div>
|
||||
<div class="radio"><label><input type="radio" data-process="filter:filter_pass" value="4" /> 未检测到关键词不采集该条数据</label></div>
|
||||
<p class="help-block">检测到关键词:包含任意一个关键词即可触发<br>未检测到关键词:所有关键词都不包含即触发,只要包含任意一个关键词就不会触发</p>
|
||||
</div>
|
||||
<div class="c-p-process-module" module="if">
|
||||
<section>
|
||||
|
@ -87,13 +88,13 @@
|
|||
</div>
|
||||
<div class="form-group">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-hover p-m-if-table">
|
||||
<table class="table table-hover p-m-if-table" style="margin-bottom:0;">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="min-width:95px;">逻辑</th>
|
||||
<th style="min-width:150px;">条件</th>
|
||||
<th style="min-width:200px;">值</th>
|
||||
<th></th>
|
||||
<th style="max-width:90px;"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
@ -106,21 +107,21 @@
|
|||
</td>
|
||||
<td>
|
||||
<select data-process="if:if_cond:" class="form-control">
|
||||
<option value="has">包含</option>
|
||||
<option value="nhas">不包含</option>
|
||||
<option value="eq">等于</option>
|
||||
<option value="neq">不等于</option>
|
||||
<option value="heq">恒等于</option>
|
||||
<option value="nheq">不恒等于</option>
|
||||
<option value="gt">大于</option>
|
||||
<option value="egt">大于等于</option>
|
||||
<option value="lt">小于</option>
|
||||
<option value="elt">小于等于</option>
|
||||
<option value="time_eq">时间等于</option>
|
||||
<option value="time_egt">时间大于等于</option>
|
||||
<option value="time_elt">时间小于等于</option>
|
||||
<option value="regexp">正则表达式</option>
|
||||
<option value="func">使用函数</option>
|
||||
<option value="has">{$Think.lang.p_m_if_c_has}</option>
|
||||
<option value="nhas">{$Think.lang.p_m_if_c_nhas}</option>
|
||||
<option value="eq">{$Think.lang.p_m_if_c_eq}</option>
|
||||
<option value="neq">{$Think.lang.p_m_if_c_neq}</option>
|
||||
<option value="heq">{$Think.lang.p_m_if_c_heq}</option>
|
||||
<option value="nheq">{$Think.lang.p_m_if_c_nheq}</option>
|
||||
<option value="gt">{$Think.lang.p_m_if_c_gt}</option>
|
||||
<option value="egt">{$Think.lang.p_m_if_c_egt}</option>
|
||||
<option value="lt">{$Think.lang.p_m_if_c_lt}</option>
|
||||
<option value="elt">{$Think.lang.p_m_if_c_elt}</option>
|
||||
<option value="time_eq">{$Think.lang.p_m_if_c_time_eq}</option>
|
||||
<option value="time_egt">{$Think.lang.p_m_if_c_time_egt}</option>
|
||||
<option value="time_elt">{$Think.lang.p_m_if_c_time_elt}</option>
|
||||
<option value="regexp">{$Think.lang.p_m_if_c_regexp}</option>
|
||||
<option value="func">{$Think.lang.p_m_if_c_func}</option>
|
||||
</select>
|
||||
</td>
|
||||
<td>
|
||||
|
@ -178,12 +179,21 @@
|
|||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<a href="javascript:;" class="glyphicon glyphicon-remove p-m-if-del" style="margin-top:8px;"></a>
|
||||
<td style="padding:0;padding-top:10px;">
|
||||
<a href="javascript:;" class="glyphicon glyphicon-arrow-up" style="font-size:11px;"></a>
|
||||
<a href="javascript:;" class="glyphicon glyphicon-arrow-down" style="font-size:11px;"></a>
|
||||
<a href="javascript:;" class="glyphicon glyphicon-remove p-m-if-del" style="font-size:11px;"></a>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<p class="help-block">
|
||||
执行顺序:从上至下判断,逻辑符“并且”的优先级高于“或者”<br>
|
||||
例如(字母表示条件):<br>
|
||||
a && b || c && d && e || f || g && h && i && j 等价于<br>
|
||||
(a && b) || (c && d && e) || f || (g && h && i && j)<br>
|
||||
从左到右执行, 括号中的条件都为真时才是真否则为假,整条语句中任意一个括号的结果为真最终结果为真,都为假最终结果为假
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
|
|
@ -75,6 +75,22 @@
|
|||
<div class="form-group form-group-sm">
|
||||
<button type="submit" class="btn btn-primary btn-block">确定</button>
|
||||
</div>
|
||||
<div class="panel panel-default panel-sign-field">
|
||||
<div class="panel-heading">
|
||||
<div class="panel-title">
|
||||
<a data-toggle="collapse" href="#c_p_sign_field_relation_url">将{:cp_sign('match')}添加为字段</a>
|
||||
<a href="javascript:;" class="glyphicon glyphicon-plus add-relation-field" data-val="" title="添加"></a>
|
||||
</div>
|
||||
</div>
|
||||
<div id="c_p_sign_field_relation_url" class="panel-collapse collapse">
|
||||
<div class="panel-body">
|
||||
<div class="form-group">
|
||||
<div class="c-p-sign-field-list"></div>
|
||||
<p class="help-block">将“提取网址规则”中的{:cp_sign('match')}标签添加为字段</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<script type="text/javascript">
|
||||
{if condition="$relation_url"}
|
||||
|
|
|
@ -74,14 +74,14 @@
|
|||
</div>
|
||||
<div id="coll_pattern_request_headers" class="panel-collapse collapse">
|
||||
<div class="panel-body">
|
||||
<div class="form-group">
|
||||
<div class="form-group" style="margin-bottom:0;">
|
||||
<label class="control-label">开启</label>
|
||||
<div class="input-group">
|
||||
<label class="radio-inline"><input type="radio" name="config[request_headers][open]" value="1"> 是</label>
|
||||
<label class="radio-inline"><input type="radio" name="config[request_headers][open]" value="0"> 否</label>
|
||||
</div>
|
||||
</div>
|
||||
<div id="c_p_request_headers_open" style="display:none;">
|
||||
<div id="c_p_request_headers_open" style="display:none;margin-top:15px;">
|
||||
<div class="form-group">
|
||||
<label class="control-label">UserAgent 浏览器标识</label>
|
||||
<div class="input-group">
|
||||
|
@ -110,13 +110,10 @@
|
|||
<label class="control-label">Referer 来源网址</label>
|
||||
<input type="text" class="form-control" name="config[request_headers][referer]">
|
||||
</div>
|
||||
<div class="h-title">
|
||||
<label class="control-label">自定义</label>
|
||||
<a href="javascript:;" class="glyphicon glyphicon-plus add-request-header" title="添加"></a>
|
||||
</div>
|
||||
<div class="">
|
||||
<div class="form-group">
|
||||
<label class="control-label">自定义 <a href="javascript:;" class="glyphicon glyphicon-plus add-request-header" title="添加" style="font-size:12px;"></a></label>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-bordered c-p-request-headers">
|
||||
<table class="table c-p-request-headers" style="margin-bottom:0;">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="col-xs-4">名称</th>
|
||||
|
@ -185,7 +182,7 @@
|
|||
<a href="javascript:;" class="glyphicon glyphicon-plus add-level-url" title="添加"></a>
|
||||
</div>
|
||||
<div class="table-responsive">
|
||||
<table id="c_p_level_urls" class="table table-hover">
|
||||
<table id="c_p_level_urls" class="table table-hover" style="margin-bottom:0;">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>级别</th>
|
||||
|
@ -288,6 +285,13 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label">将{:cp_sign('match')}添加为字段 <a href="javascript:;" class="glyphicon glyphicon-plus add-link-field" data-val="" title="添加" style="font-size:12px;"></a></label>
|
||||
<div id="c_p_sign_field_link">
|
||||
<div class="c-p-sign-field-list"></div>
|
||||
</div>
|
||||
<p class="help-block">将“提取网址规则”中的{:cp_sign('match')}标签添加为字段</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -318,7 +322,7 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="panel panel-default">
|
||||
<div class="panel panel-default" style="margin-bottom:0;">
|
||||
<div class="panel-heading">
|
||||
<h4 class="panel-title">
|
||||
<a data-toggle="collapse" href="#coll_pattern_link_post" class="collapsed" aria-expanded="false">POST模式</a>
|
||||
|
@ -335,9 +339,9 @@
|
|||
<p class="help-block">开启后内容页网址中的get参数将以post形式提交</p>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label">附加参数 <a href="javascript:;" class="glyphicon glyphicon-plus add-url-post" title="添加"></a></label>
|
||||
<label class="control-label">附加参数 <a href="javascript:;" class="glyphicon glyphicon-plus add-url-post" title="添加" style="font-size:12px;"></a></label>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-hover c-p-url-posts">
|
||||
<table class="table table-hover c-p-url-posts" style="margin-bottom:0;">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="col-xs-4">名称</th>
|
||||
|
@ -371,7 +375,7 @@
|
|||
<a href="javascript:;" class="glyphicon glyphicon-plus add-relation-url" title="添加"></a>
|
||||
</div>
|
||||
<div class="table-responsive">
|
||||
<table id="c_p_relation_urls" class="table table-hover">
|
||||
<table id="c_p_relation_urls" class="table table-hover" style="margin-bottom:0;">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>名称</th>
|
||||
|
@ -411,7 +415,7 @@
|
|||
<a href="javascript:;" onclick="c_pattern.add_default_fields()" style="float:right;font-weight:normal;">添加默认</a>
|
||||
</div>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-hover c-p-field-list" style="margin-bottom:10px;">
|
||||
<table class="table table-hover c-p-field-list" style="margin-bottom:0px;">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>字段</th>
|
||||
|
@ -438,11 +442,11 @@
|
|||
</div>
|
||||
<div id="coll_pattern_process" class="panel-collapse collapse">
|
||||
<div class="panel-body">
|
||||
<div class="h-title">
|
||||
<div class="h-title" style="border-bottom:0;">
|
||||
<label class="control-label">通用数据处理</label>
|
||||
<a href="javascript:;" class="glyphicon glyphicon-plus add-process" title="添加"></a>
|
||||
</div>
|
||||
<div class="panel-group c-p-process-accordion">
|
||||
<div class="panel-group c-p-process-accordion" style="margin-bottom:0;">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -455,14 +459,14 @@
|
|||
</div>
|
||||
<div id="coll_pattern_paging" class="panel-collapse collapse">
|
||||
<div class="panel-body">
|
||||
<div class="form-group">
|
||||
<div class="form-group" style="margin-bottom:0;">
|
||||
<label class="control-label">开启分页</label>
|
||||
<div class="input-group">
|
||||
<label class="radio-inline"><input type="radio" name="config[paging][open]" value="1"> 是</label>
|
||||
<label class="radio-inline"><input type="radio" name="config[paging][open]" value="0"> 否</label>
|
||||
</div>
|
||||
</div>
|
||||
<div id="c_p_paging_open" style="display:none;">
|
||||
<div id="c_p_paging_open" style="display:none;margin-top:15px;">
|
||||
<div class="form-group">
|
||||
<label class="control-label">
|
||||
分页内容字段
|
||||
|
@ -595,9 +599,9 @@
|
|||
<td><a href="javascript:;" class="name" data-val=""></a></td>
|
||||
<td>
|
||||
<input type="hidden" data-name="config[level_urls][]" />
|
||||
<a href="javascript:;" class="delete">删除</a>
|
||||
<a href="javascript:;" class="glyphicon glyphicon-arrow-up" style="font-size:12px;"></a>
|
||||
<a href="javascript:;" class="glyphicon glyphicon-arrow-down" style="font-size:12px;"></a>
|
||||
<a href="javascript:;" class="glyphicon glyphicon-remove delete" style="font-size:12px;"></a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="coll_tpl_relation_url">
|
||||
|
@ -605,15 +609,15 @@
|
|||
<td class="page"></td>
|
||||
<td>
|
||||
<input type="hidden" data-name="config[relation_urls][]" />
|
||||
<a href="javascript:;" class="delete">删除</a>
|
||||
<a href="javascript:;" class="glyphicon glyphicon-arrow-up" style="font-size:12px;"></a>
|
||||
<a href="javascript:;" class="glyphicon glyphicon-arrow-down" style="font-size:12px;"></a>
|
||||
<a href="javascript:;" class="glyphicon glyphicon-remove delete" style="font-size:12px;"></a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="coll_tpl_field">
|
||||
<td class="field-name" data-val=""></td>
|
||||
<td class="field-source"></td>
|
||||
<td class="field-module"></td>
|
||||
<td class="field-source" data-val=""></td>
|
||||
<td class="field-module" data-val=""></td>
|
||||
<td>
|
||||
<input type="hidden" data-name="config[field_list][]" />
|
||||
<input type="hidden" data-name="config[field_process][]" />
|
||||
|
@ -633,7 +637,7 @@
|
|||
<a data-toggle="collapse" style="color:inherit;"></a>
|
||||
<input type="text" style="display:none;border-radius:2px;border:1px solid #ccc;line-height:16px;margin-left:2px;padding:1px 1px 1px 2px;" />
|
||||
</div>
|
||||
<div style="float:right;">
|
||||
<div class="panel-title-ops" style="float:right;">
|
||||
<a href="javascript:;" class="glyphicon glyphicon-tags" title="标题"></a>
|
||||
<a href="javascript:;" class="glyphicon glyphicon-arrow-up"></a>
|
||||
<a href="javascript:;" class="glyphicon glyphicon-arrow-down"></a>
|
||||
|
@ -646,6 +650,10 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="coll_tpl_sign_field" class="c-p-sign-field">
|
||||
<a href="javascript:;" class="field" data-val="" data-source="" title=""></a>
|
||||
<em class="glyphicon glyphicon-remove-circle delete" data-val=""></em>
|
||||
</div>
|
||||
</div>
|
||||
<link href="__PUBLIC__/static/css/jquery.datetimepicker.css" rel="stylesheet">
|
||||
<script type="text/javascript" src="__PUBLIC__/static/js/jquery.datetimepicker.js"></script>
|
||||
|
|
|
@ -32,26 +32,26 @@
|
|||
{if condition="!empty($input_urls)"}
|
||||
<div id="win_get_fields_input">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">有字段绑定了以下数据源,请输入网址</div>
|
||||
<div class="panel-heading">有字段需要从以下数据源抓取页面,请输入网址</div>
|
||||
<div class="panel-body">
|
||||
{if condition="isset($input_urls['source_url'])"}
|
||||
{if condition="isset($input_urls['source_url'])"}
|
||||
<div class="form-group">
|
||||
<div class="input-group">
|
||||
<div class="input-group-addon">起始页</div>
|
||||
<input type="text" name="source_url" class="form-control" value="{$input_urls['source_url']}" />
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
{if condition="is_array($input_urls['level_url'])"}
|
||||
{foreach $input_urls['level_url'] as $level_url}
|
||||
<div class="form-group">
|
||||
<div class="input-group">
|
||||
<div class="input-group-addon">多级页:{$level_url['name']}</div>
|
||||
<input type="text" name="level_{$level_url['level']}" class="form-control" value="{$level_url['url']}" />
|
||||
</div>
|
||||
</div>
|
||||
{/foreach}
|
||||
{/if}
|
||||
{/if}
|
||||
{if condition="is_array($input_urls['level_url'])"}
|
||||
{foreach $input_urls['level_url'] as $level_url}
|
||||
<div class="form-group">
|
||||
<div class="input-group">
|
||||
<div class="input-group-addon">多级页:{$level_url['name']}</div>
|
||||
<input type="text" name="level_{$level_url['level']}" class="form-control" value="{$level_url['url']}" />
|
||||
</div>
|
||||
</div>
|
||||
{/foreach}
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -65,22 +65,27 @@
|
|||
'use strict';//严格模式
|
||||
//预览
|
||||
function win_test_view(id){
|
||||
$('#ifm_test_view').remove();//删除旧的
|
||||
var html=$('#'+id).val();
|
||||
html=html.replace(/<script[^<>]*>[\s\S]*?<\/script>/ig,'');//去掉脚本代码
|
||||
html=html.replace(/<meta[^<>]*charset[^<>]*>/i,'');//去掉编码
|
||||
var ifm='<iframe id="ifm_test_view" style="width:100%;border:1px solid #ccc;"></iframe>';
|
||||
$('#'+id).after(ifm);
|
||||
$('#ifm_test_view').bind('load',function(){
|
||||
if($("#ifm_test_view").contents().find('body').html().length<=0){
|
||||
//火狐浏览器需要重新赋值
|
||||
$("#ifm_test_view").contents().find('body').html(html);
|
||||
}
|
||||
var iframeObj = document.getElementById('ifm_test_view');
|
||||
var height=(iframeObj.Document?iframeObj.Document.body.scrollHeight:iframeObj.contentDocument.body.offsetHeight);
|
||||
$('#ifm_test_view').attr('height',height+'px');
|
||||
});
|
||||
$("#ifm_test_view").contents().find('body').html(html);
|
||||
if($('#'+id).next().attr('id')=='ifm_test_view'){
|
||||
//折叠
|
||||
$('#ifm_test_view').remove();
|
||||
}else{
|
||||
$('#ifm_test_view').remove();//删除旧的
|
||||
var html=$('#'+id).val();
|
||||
html=html.replace(/<script[^<>]*>[\s\S]*?<\/script>/ig,'');//去掉脚本代码
|
||||
html=html.replace(/<meta[^<>]*charset[^<>]*>/i,'');//去掉编码
|
||||
var ifm='<iframe id="ifm_test_view" style="width:100%;border:1px solid #ccc;"></iframe>';
|
||||
$('#'+id).after(ifm);
|
||||
$('#ifm_test_view').bind('load',function(){
|
||||
if($("#ifm_test_view").contents().find('body').html().length<=0){
|
||||
//火狐浏览器需要重新赋值
|
||||
$("#ifm_test_view").contents().find('body').html(html);
|
||||
}
|
||||
var iframeObj = document.getElementById('ifm_test_view');
|
||||
var height=(iframeObj.Document?iframeObj.Document.body.scrollHeight:iframeObj.contentDocument.body.offsetHeight);
|
||||
$('#ifm_test_view').attr('height',height+'px');
|
||||
});
|
||||
$("#ifm_test_view").contents().find('body').html(html);
|
||||
}
|
||||
}
|
||||
|
||||
//分析网页
|
||||
|
@ -155,10 +160,33 @@ $('#win_test_cont_url button.test-sub').bind('click',function(){
|
|||
});
|
||||
}else{
|
||||
if(testOp=='get_fields'){
|
||||
//附加数据源网址
|
||||
$('#win_get_fields_input').find('input').each(function(){
|
||||
//附加数据源网址
|
||||
url+='&'+$(this).attr('name')+'='+encodeURIComponent($(this).val());
|
||||
});
|
||||
//表格标题左右拉伸
|
||||
window.win_test_table_thead_mousedown=null;//点击初始
|
||||
var thEle='.table-test-loop thead th';
|
||||
$('#win_test_cont_url').off('mousedown',thEle).on('mousedown',thEle,function(e){
|
||||
$(this).css('background','#f1f1f1');
|
||||
window.win_test_table_thead_mousedown={
|
||||
table_width:$('#win_test_cont_url .table-test-loop').width(),
|
||||
th_width:$(this).width(),
|
||||
page_x:e.pageX
|
||||
};
|
||||
$(this).off('mousemove').bind('mousemove',function(e){
|
||||
var def=window.win_test_table_thead_mousedown;
|
||||
if(def){
|
||||
var moveWidth=e.pageX-def.page_x;
|
||||
$("#win_test_cont_url .table-test-loop").width(def.table_width+moveWidth);
|
||||
$(this).width(def.th_width+moveWidth);
|
||||
}
|
||||
});
|
||||
$(this).off('mouseout mouseup').bind('mouseout mouseup',function(e){
|
||||
$(this).css('background','');
|
||||
window.win_test_table_thead_mousedown=null;//结束
|
||||
});
|
||||
});
|
||||
}
|
||||
$.ajax({
|
||||
type:'get',
|
||||
|
@ -211,6 +239,7 @@ $('#win_test_cont_url button.test-sub').bind('click',function(){
|
|||
//检测到html代码
|
||||
browse='<a href="javascript:;" onclick="win_test_view(\''+eleId+'\')">预览</a>';
|
||||
}
|
||||
vals[f]=vals[f].replace(/\</g,'<').replace(/\>/g,'>');//编码
|
||||
html+='<label>'+f+':</label>'+browse+'<textarea id="'+eleId+'" class="form-control">'+vals[f]+'</textarea><br>';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
</div>
|
||||
<script type="text/javascript">
|
||||
'use strict';//严格模式
|
||||
var max_num=5;//测试时最多显示数量
|
||||
var max_num=3;//测试时最多显示数量
|
||||
var url_ajax_requests=new Array();//ajax对象
|
||||
$(document).ready(function(){
|
||||
$('#test_source_urls .source_url').each(function(index){
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
{extend name="common:main" /}
|
||||
{block name="cssjs"}
|
||||
<script src="__PUBLIC__/static/js/admin/store.js?{$Think.config.html_v}"></script>
|
||||
{/block}
|
||||
{block name="content"}
|
||||
<div class="box">
|
||||
<div class="box-body">
|
||||
{if condition="!empty($collectRules)"}
|
||||
<div class="page-header"><span class="glyphicon glyphicon-th-list"></span> <a href="{:url('Mystore/rule')}">采集规则</a><i class="ph-more"><a href="{:url('Mystore/rule')}">更多 ></a></i></div>
|
||||
{foreach name="collectRules" item="rule"}
|
||||
<div class="col-xs-6 col-sm-4"><a href="https://www.skycaiji.com/collect/rule/detail?id={$rule['store_id']}" class="store-detail">{$rule['name']}</a></div>
|
||||
{/foreach}
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
storeClass.init_my();
|
||||
</script>
|
||||
{/block}
|
|
@ -20,5 +20,5 @@
|
|||
</script>
|
||||
</div>
|
||||
{else /}
|
||||
您没有规则,请进入<a href="{:url('Store/index')}">云平台</a>下载
|
||||
您没有规则,请进入<a href="{:url('Mystore/store')}">云平台</a>下载
|
||||
{/if}
|
|
@ -0,0 +1,10 @@
|
|||
{extend name="common:main" /}
|
||||
{block name="cssjs"}
|
||||
<link rel="stylesheet" href="__PUBLIC__/static/css/store.css?{$Think.config.html_v}" />
|
||||
<script src="__PUBLIC__/static/js/admin/store.js?{$Think.config.html_v}"></script>
|
||||
{/block}
|
||||
{block name="content"}
|
||||
<div class="iframe-loading"><div class="loading"> </div>页面加载中...</div>
|
||||
<iframe data-store-url="{$url}" data-provider-url="{$provData['url']}" id="iframe_main" class="iframe-main" width="100%" height="100%" frameborder="0" scrolling="yes"></iframe>
|
||||
<script type="text/javascript">storeClass.init_iframe();</script>
|
||||
{/block}
|
|
@ -36,7 +36,7 @@
|
|||
</select>
|
||||
<div id="img_name_custom" style="margin-top:5px;display:none;">
|
||||
<div class="input-group">
|
||||
<span class="input-group-addon">目录</span>
|
||||
<span class="input-group-addon">路径</span>
|
||||
<input type="text" name="name_custom_path" class="form-control" value="{$imgConfig['name_custom_path']}" />
|
||||
<span class="input-group-addon" style="border-left:0;border-right:0;">名称</span>
|
||||
<select name="name_custom_name" class="form-control">
|
||||
|
@ -48,9 +48,13 @@
|
|||
<a href="javascript:;" data-val="[月]">[月]</a>
|
||||
<a href="javascript:;" data-val="[日]">[日]</a>
|
||||
<a href="javascript:;" data-val="[时]">[时]</a>
|
||||
<a href="javascript:;" data-val="[分]">[分]</a>
|
||||
<a href="javascript:;" data-val="[秒]">[秒]</a>
|
||||
<a href="javascript:;" data-val="[前两位]" title="图片网址MD5码的前两位">[前两位]</a>
|
||||
<a href="javascript:;" data-val="[后两位]" title="图片网址MD5码的后两位">[后两位]</a>
|
||||
用/分隔子目录
|
||||
<a href="javascript:;" data-val="[任务名]">[任务名]</a>
|
||||
<a href="javascript:;" data-val="[任务ID]">[任务ID]</a>
|
||||
用/分隔子目录,如需调用字段可在任务的更多设置中编辑
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
{extend name="common:main" /}
|
||||
{block name="cssjs"}
|
||||
<link rel="stylesheet" href="__PUBLIC__/static/css/store.css?{$Think.config.html_v}" />
|
||||
<script src="__PUBLIC__/static/js/admin/store.js?{$Think.config.html_v}"></script>
|
||||
{/block}
|
||||
{block name="content"}
|
||||
<div class="iframe-loading"><div class="loading"> </div>页面加载中...</div>
|
||||
<iframe data-store-url="{$url}" data-provider-url="{$provData['url']}" id="iframe_main" class="iframe-main" width="100%" height="100%" frameborder="0" scrolling="yes"></iframe>
|
||||
<script type="text/javascript">storeClass.init_iframe();</script>
|
||||
{/block}
|
|
@ -90,11 +90,95 @@
|
|||
</div>
|
||||
<div class="form-group">
|
||||
<label>图片保存目录(绝对路径)</label>
|
||||
<input type="text" name="config[img_path]" class="form-control" placeholder="默认设置" value="{$taskData['config']['img_path']}">
|
||||
<input type="text" name="config[img_path]" class="form-control" placeholder="默认设置">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>图片链接地址(绝对地址)</label>
|
||||
<input type="text" name="config[img_url]" class="form-control" placeholder="默认设置">
|
||||
<input type="text" name="config[img_url]" class="form-control" placeholder="默认设置">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>图片名称</label>
|
||||
<select name="config[img_name]" class="form-control">
|
||||
<option value="">默认设置</option>
|
||||
<option value="time">按时间生成(方便日期归类)</option>
|
||||
<option value="url">按网址生成(防止重复下载)</option>
|
||||
<option value="custom">自定义</option>
|
||||
</select>
|
||||
<div id="config_img_name_custom" style="margin-top:5px;display:none;">
|
||||
<p class="help-block" style="margin-bottom:5px;font-size:12px;">注意:字段值的长度限制100字内(超出自动截取),字段值中任何特殊字符都会被替换成下划线,自定义路径或名称太长都可能导致图片保存失败</p>
|
||||
<div style="width:100%;">
|
||||
<div style="width:50%;float:left">
|
||||
<div class="input-group">
|
||||
<input type="text" name="config[name_custom_path]" class="form-control" placeholder="路径,默认设置" autocomplete="off" />
|
||||
<div class="input-group-addon" style="border-left:0;border-right:0;font-weight:bold;">/</div>
|
||||
</div>
|
||||
<div class="help-block name-custom-path">
|
||||
<div class="dropup" style="display:inline;">
|
||||
<a class="dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
系统
|
||||
<span class="caret"></span>
|
||||
</a>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a href="javascript:;" data-val="[年]">[年]</a></li>
|
||||
<li><a href="javascript:;" data-val="[月]">[月]</a></li>
|
||||
<li><a href="javascript:;" data-val="[日]">[日]</a></li>
|
||||
<li><a href="javascript:;" data-val="[时]">[时]</a></li>
|
||||
<li><a href="javascript:;" data-val="[分]">[分]</a></li>
|
||||
<li><a href="javascript:;" data-val="[秒]">[秒]</a></li>
|
||||
<li><a href="javascript:;" data-val="[前两位]" title="图片网址MD5码的前两位">[前两位]</a></li>
|
||||
<li><a href="javascript:;" data-val="[后两位]" title="图片网址MD5码的后两位">[后两位]</a></li>
|
||||
<li><a href="javascript:;" data-val="[任务名]">[任务名]</a></li>
|
||||
<li><a href="javascript:;" data-val="[任务ID]">[任务ID]</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="dropup" style="display:inline;">
|
||||
<a class="dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
采集器字段
|
||||
<span class="caret"></span>
|
||||
</a>
|
||||
<ul class="dropdown-menu name-custom-path-fields">
|
||||
<li><a href="javascript:;">没有字段,请先配置采集器设置!</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
用/分隔子目录
|
||||
</div>
|
||||
</div>
|
||||
<div style="width:50%;float:left">
|
||||
<input type="text" name="config[name_custom_name]" class="form-control" placeholder="名称,默认设置" autocomplete="off" />
|
||||
<div class="help-block name-custom-name">
|
||||
<div class="dropup" style="display:inline;">
|
||||
<a class="dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
系统
|
||||
<span class="caret"></span>
|
||||
</a>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a href="javascript:;" data-val="[图片网址MD5码]">[图片网址MD5码]</a></li>
|
||||
<li><a href="javascript:;" data-val="[图片原名]">[图片原名]</a></li>
|
||||
<li><a href="javascript:;" data-val="[年]">[年]</a></li>
|
||||
<li><a href="javascript:;" data-val="[月]">[月]</a></li>
|
||||
<li><a href="javascript:;" data-val="[日]">[日]</a></li>
|
||||
<li><a href="javascript:;" data-val="[时]">[时]</a></li>
|
||||
<li><a href="javascript:;" data-val="[分]">[分]</a></li>
|
||||
<li><a href="javascript:;" data-val="[秒]">[秒]</a></li>
|
||||
<li><a href="javascript:;" data-val="[前两位]" title="图片网址MD5码的前两位">[前两位]</a></li>
|
||||
<li><a href="javascript:;" data-val="[后两位]" title="图片网址MD5码的后两位">[后两位]</a></li>
|
||||
<li><a href="javascript:;" data-val="[任务名]">[任务名]</a></li>
|
||||
<li><a href="javascript:;" data-val="[任务ID]">[任务ID]</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="dropup" style="display:inline;">
|
||||
<a class="dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
采集器字段
|
||||
<span class="caret"></span>
|
||||
</a>
|
||||
<ul class="dropdown-menu name-custom-name-fields">
|
||||
<li><a href="javascript:;">没有字段,请先配置采集器设置!</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -105,38 +189,6 @@
|
|||
</form>
|
||||
|
||||
<script type="text/javascript">
|
||||
{if condition="!empty($taskData)"}
|
||||
$('#form_item select[name="tg_id"]').val("{$taskData['tg_id']|intval}");
|
||||
$('#form_item select[name="auto"]').val("{$taskData['auto']|intval}");
|
||||
$('#form_item select[name="module"]').val("{$taskData['module']}");
|
||||
$('#form_item input[name="auto"][value="{$taskData["auto"]|intval}"]').prop('checked','checked');
|
||||
$('#form_item [name="config[download_img]"][value="{$taskData["config"]["download_img"]}"]').prop('checked','checked');
|
||||
$('#form_item [name="config[proxy]"][value="{$taskData["config"]["proxy"]}"]').prop('checked','checked');
|
||||
|
||||
var task_config={:json_encode($taskData["config"])};
|
||||
for(var i in task_config){
|
||||
if(task_config[i]){
|
||||
$('#task_config').addClass('in');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$('#form_item [name="config[img_url]"]').val(task_config.img_url);
|
||||
|
||||
{/if}
|
||||
//模块显示导入
|
||||
$('#form_item select[name="module"]').bind('change',function(){
|
||||
if($(this).val()!='pattern'){
|
||||
$('#btn_import_rule').parents('.input-group-btn').hide();
|
||||
}else{
|
||||
$('#btn_import_rule').parents('.input-group-btn').show();
|
||||
}
|
||||
});
|
||||
//导入本地规则
|
||||
$('#form_item [name="rule_file"]').bind('change',function(){
|
||||
import_rule('file',$(this).val());
|
||||
$(this).parents('.dropdown').removeClass('open');
|
||||
});
|
||||
//导入规则
|
||||
function import_rule(ruleId,ruleName){
|
||||
$('#form_item input[name="rule_id"]').val(ruleId);
|
||||
|
@ -153,4 +205,75 @@ function import_task(id,name){
|
|||
$('#btn_import_task').text('导入任务:'+name);
|
||||
$('#myModal').modal('hide');
|
||||
}
|
||||
|
||||
(function(){
|
||||
//模块显示导入
|
||||
$('#form_item select[name="module"]').bind('change',function(){
|
||||
if($(this).val()!='pattern'){
|
||||
$('#btn_import_rule').parents('.input-group-btn').hide();
|
||||
}else{
|
||||
$('#btn_import_rule').parents('.input-group-btn').show();
|
||||
}
|
||||
});
|
||||
//导入本地规则
|
||||
$('#form_item [name="rule_file"]').bind('change',function(){
|
||||
import_rule('file',$(this).val());
|
||||
$(this).parents('.dropdown').removeClass('open');
|
||||
});
|
||||
//图片名称自定义
|
||||
$('#form_item [name="config[img_name]"]').bind('change',function(){
|
||||
if($(this).val()=='custom'){
|
||||
$('#config_img_name_custom').show();
|
||||
}else{
|
||||
$('#config_img_name_custom').hide();
|
||||
}
|
||||
});
|
||||
$('#config_img_name_custom').on('click','.name-custom-path a[data-val]',function(){
|
||||
insertAtCaret($('[name="config[name_custom_path]"]'),$(this).attr('data-val'));
|
||||
});
|
||||
$('#config_img_name_custom').on('click','.name-custom-name a[data-val]',function(){
|
||||
insertAtCaret($('[name="config[name_custom_name]"]'),$(this).attr('data-val'));
|
||||
});
|
||||
})();
|
||||
|
||||
{if condition="!empty($taskData)"}
|
||||
(function(){
|
||||
$('#form_item select[name="tg_id"]').val("{$taskData['tg_id']|intval}");
|
||||
$('#form_item select[name="auto"]').val("{$taskData['auto']|intval}");
|
||||
$('#form_item select[name="module"]').val("{$taskData['module']}");
|
||||
$('#form_item input[name="auto"][value="{$taskData["auto"]|intval}"]').prop('checked','checked');
|
||||
$('#form_item [name="config[download_img]"][value="{$taskData["config"]["download_img"]}"]').prop('checked','checked');
|
||||
$('#form_item [name="config[proxy]"][value="{$taskData["config"]["proxy"]}"]').prop('checked','checked');
|
||||
|
||||
var task_config={:json_encode($taskData["config"])};
|
||||
for(var i in task_config){
|
||||
if(task_config[i]){
|
||||
$('#task_config').addClass('in');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//图片设置
|
||||
$('#form_item [name="config[img_path]"]').val(task_config.img_path);
|
||||
$('#form_item [name="config[img_url]"]').val(task_config.img_url);
|
||||
|
||||
$('#form_item [name="config[img_name]"]').val(task_config.img_name).trigger('change');
|
||||
$('#form_item [name="config[name_custom_path]"]').val(task_config.name_custom_path);
|
||||
$('#form_item [name="config[name_custom_name]"]').val(task_config.name_custom_name);
|
||||
|
||||
|
||||
//图片自定义插入字段
|
||||
var field_list={:json_encode($fieldList)};
|
||||
if(field_list&&field_list.length>0){
|
||||
$('#config_img_name_custom .name-custom-path-fields').html('');//清空
|
||||
$('#config_img_name_custom .name-custom-name-fields').html('');//清空
|
||||
for(var i in field_list){
|
||||
var fieldHtml='[字段:'+field_list[i]+']';
|
||||
fieldHtml='<li><a href="javascript:;" data-val="'+fieldHtml+'">'+fieldHtml+'</a></li>';
|
||||
$('#config_img_name_custom .name-custom-path-fields').append(fieldHtml);
|
||||
$('#config_img_name_custom .name-custom-name-fields').append(fieldHtml);
|
||||
}
|
||||
}
|
||||
})();
|
||||
{/if}
|
||||
</script>
|
|
@ -27,7 +27,7 @@
|
|||
{if empty($taskList)}
|
||||
<tr>
|
||||
<td colspan="8" style="text-align:center;">
|
||||
<p class="help-block">没有任务,创建<a href="{:url('Task/add')}">新任务</a>或进入<a href="{:url('Store/index')}">云平台</a>下载规则</p>
|
||||
<p class="help-block">没有任务,创建<a href="{:url('Task/add')}">新任务</a>或进入<a href="{:url('Mystore/store')}">云平台</a>下载规则</p>
|
||||
</td>
|
||||
</tr>
|
||||
{else/}
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
*/
|
||||
|
||||
|
||||
define('SKYCAIJI_VERSION', '2.3.2');
|
||||
define('SKYCAIJI_VERSION', '2.3.3');
|
||||
define('NOW_TIME', time());
|
||||
\think\Loader::addNamespace('plugin', realpath(ROOT_PATH.'plugin'));
|
||||
\think\Loader::addNamespace('util',realpath(APP_PATH.'extend/util'));
|
||||
|
|
|
@ -245,7 +245,7 @@ return [
|
|||
/**********************************自定义配置*********************************************/
|
||||
'cli_cache_config'=>array('view_replace_str','root_path','app_path','apps_path','plugin_path','root_url','root_website'),//cli模式下需要缓存的配置,否则会失效引起程序bug
|
||||
|
||||
'html_v'=>'20200501',//css和js版本
|
||||
'html_v'=>'20200720',//css和js版本
|
||||
|
||||
'root_path'=>realpath(ROOT_PATH),//根目录
|
||||
'app_path'=>realpath(APP_PATH),//skycaijiApp目录
|
||||
|
|
|
@ -32,6 +32,11 @@ class Index extends BaseController{
|
|||
|
||||
/*环境检测*/
|
||||
public function step1Action(){
|
||||
try{
|
||||
clear_dir(config('root_path').'/runtime');
|
||||
}catch(\Exception $ex){
|
||||
|
||||
}
|
||||
|
||||
$LocSystem=new \skycaiji\install\event\LocSystem();
|
||||
$setting=$LocSystem->environment();
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -178,6 +178,38 @@ table.datatable thead .sorting_desc:after {
|
|||
z-index: 999;
|
||||
background:#fff;
|
||||
}
|
||||
/*[内容]标签字段*/
|
||||
.panel-sign-field{
|
||||
margin-bottom:5px;
|
||||
}
|
||||
.panel-sign-field .panel-heading{padding-top:6px;padding-bottom:6px;}
|
||||
.panel-sign-field .panel-title{font-size:14px;}
|
||||
.panel-sign-field .panel-title a.glyphicon{font-size:12px;vertical-align:text-top;color:#3c8dbc;}
|
||||
.c-p-sign-field-list{
|
||||
widht:auto;
|
||||
overflow:hidden;
|
||||
}
|
||||
.c-p-sign-field{
|
||||
font-size:14px;
|
||||
font-weight:normal;
|
||||
padding: 3px 6px;
|
||||
text-decoration: none;
|
||||
border-bottom: none;
|
||||
color: #3B6268;
|
||||
border: 1px #ccc solid;
|
||||
margin:7px 15px 7px 0;
|
||||
position:relative;
|
||||
float:left;
|
||||
}
|
||||
.c-p-sign-field .delete{
|
||||
font-style: normal;
|
||||
display: block;
|
||||
position: absolute;
|
||||
top: -7px;
|
||||
right: -5px;
|
||||
z-index: 999;
|
||||
background:#fff;
|
||||
}
|
||||
/*采集器字段*/
|
||||
.c-p-field-list .field-name{color:#3c8dbc;cursor:pointer;}
|
||||
.c-p-field-list .exist-process{color:green;}
|
||||
|
@ -228,6 +260,7 @@ table.datatable thead .sorting_desc:after {
|
|||
.p-m-if-func{margin-bottom:-1px;}
|
||||
.p-m-if-func>a.input-group-addon{border-left:0;}
|
||||
.p-m-if-func>.input-group-btn>select{border-left:0;width:auto;padding:0;padding-left:5px;text-align:center;}
|
||||
|
||||
/*发布设置*/
|
||||
.rele-db-error{margin-top:10px;color:red;font-weight:bold;}
|
||||
.table-db-table-bind{padding:0;margin-bottom:0;border:0;}
|
||||
|
@ -339,7 +372,15 @@ table.datatable thead .sorting_desc:after {
|
|||
|
||||
.proxy-api-list .p-api-title{width:90%;float:left;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;}
|
||||
/**/
|
||||
.table-test-loop thead{background:#F5F5F5;}
|
||||
.table-test-loop thead{background:#fafafa;}
|
||||
.table-test-loop thead th{
|
||||
cursor:w-resize;
|
||||
-moz-user-select:none;
|
||||
-webkit-user-select:none;
|
||||
-ms-user-select:none;
|
||||
-khtml-user-select:none;
|
||||
user-select:none;
|
||||
}
|
||||
.table-test-loop input{border:0;overflow:hidden;width:100%;min-width:150px;}
|
||||
|
||||
|
||||
|
|
|
@ -23,8 +23,10 @@ list=null;while((list=reP.exec($(toObj).val()))!=null){var num=parseInt(list[1])
|
|||
if(options.group){sign=group}
|
||||
sign=sign.replace('{:num}',max+1);insertAtCaret($(toObj),sign)}}
|
||||
function cpMatchN(fromObj,toObj,options){if(!options){options={}}
|
||||
var sign=window.tpl_lang.sign_match;var txt=$(fromObj).val();var reP=new RegExp("\\(\\?<content(\\d*)>.*?\\)",'g');txt=txt.replace(reP,sign.replace('{:num}',"$1"));var reSign=new RegExp(sign.replace('{:num}','(\\d*)').replace('[','\\[').replace(']','\\]'),'g');var list=null;var hasSign=!1;while((list=reSign.exec(txt))!=null){hasSign=!0;var each=list[0];if($(toObj).val().indexOf(each)<0){insertAtCaret($(toObj),each)}}
|
||||
if(!hasSign){if(options.def){sign=sign.replace('{:num}','');if($(toObj).val().indexOf(sign)<0){insertAtCaret($(toObj),sign)}}}}
|
||||
var sign=window.tpl_lang.sign_match;var rule='';if(fromObj){rule=$(fromObj).val()}else if(options.rule){rule=options.rule}
|
||||
var reP=new RegExp("\\(\\?<content(\\d*)>.*?\\)",'g');rule=rule.replace(reP,sign.replace('{:num}',"$1"));var reSign=new RegExp(sign.replace('{:num}','(\\d*)').replace('[','\\[').replace(']','\\]'),'g');var list=null;var hasSign=!1;var returnList=new Array();while((list=reSign.exec(rule))!=null){hasSign=!0;var each=list[0];if(!toObj){returnList.push(each)}else if($(toObj).is('select')){if($(toObj).find('option[value="'+each+'"]').length<=0){$(toObj).append('<option value="'+each+'">'+each+'</option>')}}else{if($(toObj).val().indexOf(each)<0){insertAtCaret($(toObj),each)}}}
|
||||
if(!hasSign){if(options.def){sign=sign.replace('{:num}','');if(!toObj){returnList.push(sign)}else if($(toObj).is('select')){if($(toObj).find('option[value="'+sign+'"]').length<=0){$(toObj).append('<option value="'+sign+'">'+sign+'</option>')}}else{if($(toObj).val().indexOf(sign)<0){insertAtCaret($(toObj),sign)}}}}
|
||||
if(!toObj){return returnList}}
|
||||
function cpWildcard(toObj,options){if(!options){options={}}
|
||||
var wildcard=window.tpl_lang.sign_wildcard;if(options.only){if($(toObj).val().indexOf(wildcard)<0){insertAtCaret($(toObj),wildcard)}}else{insertAtCaret($(toObj),wildcard)}}
|
||||
function windowStore(title,url,options){if(!options){options={}}
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -8,5 +8,5 @@
|
|||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
'use strict';function ProviderClass(){}
|
||||
ProviderClass.prototype={constructor:ProviderClass,list_init:function(){$('#form_list').on('click','.delete',function(){var tr=$(this).parents('tr[data-id]');var id=tr.attr('data-id');confirmRight('确定删除?',function(){$.ajax({type:'GET',url:ulink('Provider/delete?id='+id),dataType:'json',success:function(data){if(data.code){tr.remove();toastr.success('删除成功')}else{toastr.error(data.msg)}}})})});$('#form_list').on('click','.comment',function(){var url=$(this).parents('tr[data-url]').attr('data-url');url='https://www.skycaiji.com/provider?url='+encodeURIComponent(url);windowStore('评价',url,{lg:1});return!1});$('#form_list').on('click','.edit',function(){var id=$(this).parents('tr[data-id]').attr('data-id');windowModal('编辑',ulink('provider/save?id='+id));return!1});$('#form_list').on('click','.store',function(){var url=$(this).parents('tr[data-url]').attr('data-url');window.location.href=ulink('Store/index?url='+encodeURIComponent(url));return!1});$('#form_list').on('click','.enable',function(){var obj=$(this);var id=$(this).parents('tr[data-id]').attr('data-id');var enable=$(this).attr('data-val');enable=(enable==1)?0:1;$.ajax({type:'GET',url:ulink('Provider/enable?id='+id+'&enable='+enable),dataType:'json',success:function(data){if(data.code){obj.attr('data-val',enable?1:0);obj.text(enable?'允许':'拒绝');obj.css('color',(enable?'green':'red'))}else{toastr.error(data.msg)}}})});$('#btn_add').bind('click',function(){windowModal('添加',ulink('provider/save'));return!1})},load:function(data){var fid='#win_form_provider';if(data){$(fid).find('[name="url"]').val(data.url);$(fid).find('[name="title"]').val(data.title);$(fid).find('[name="sort"]').val(data.sort);$(fid).find('[name="enable"][value="'+data.enable+'"]').prop('checked','checked')}}}
|
||||
ProviderClass.prototype={constructor:ProviderClass,list_init:function(){$('#form_list').on('click','.delete',function(){var tr=$(this).parents('tr[data-id]');var id=tr.attr('data-id');confirmRight('确定删除?',function(){$.ajax({type:'GET',url:ulink('Provider/delete?id='+id),dataType:'json',success:function(data){if(data.code){tr.remove();toastr.success('删除成功')}else{toastr.error(data.msg)}}})})});$('#form_list').on('click','.comment',function(){var url=$(this).parents('tr[data-url]').attr('data-url');url='https://www.skycaiji.com/provider?url='+encodeURIComponent(url);windowStore('评价',url,{lg:1});return!1});$('#form_list').on('click','.edit',function(){var id=$(this).parents('tr[data-id]').attr('data-id');windowModal('编辑',ulink('provider/save?id='+id));return!1});$('#form_list').on('click','.store',function(){var url=$(this).parents('tr[data-url]').attr('data-url');window.location.href=ulink('Mystore/store?url='+encodeURIComponent(url));return!1});$('#form_list').on('click','.enable',function(){var obj=$(this);var id=$(this).parents('tr[data-id]').attr('data-id');var enable=$(this).attr('data-val');enable=(enable==1)?0:1;$.ajax({type:'GET',url:ulink('Provider/enable?id='+id+'&enable='+enable),dataType:'json',success:function(data){if(data.code){obj.attr('data-val',enable?1:0);obj.text(enable?'允许':'拒绝');obj.css('color',(enable?'green':'red'))}else{toastr.error(data.msg)}}})});$('#btn_add').bind('click',function(){windowModal('添加',ulink('provider/save'));return!1})},load:function(data){var fid='#win_form_provider';if(data){$(fid).find('[name="url"]').val(data.url);$(fid).find('[name="title"]').val(data.title);$(fid).find('[name="sort"]').val(data.sort);$(fid).find('[name="enable"][value="'+data.enable+'"]').prop('checked','checked')}}}
|
||||
var providerClass=new ProviderClass()
|
|
@ -21,7 +21,7 @@ return!0;else return!1}
|
|||
function modal(title,body,options){if(!options){options={}}
|
||||
if(document.getElementById('myModal')){$('#myModal').off();$('#myModal').modal('hide');$('#myModal').remove()}
|
||||
if(!document.getElementById('myModal')){var modal='<div class="modal '+(options.lg?' bs-example-modal-lg':'')+' myModal" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"><div class="modal-dialog'+(options.lg?' modal-lg':'')+'"><div class="modal-content">'+'<div class="modal-header"><button type="button" class="close" data-dismiss="modal" aria-hidden="true" style="font-size:24px;">×</button><h4 class="modal-title" id="myModalLabel"></h4></div><div class="modal-body" '+(options.bodyStyle?options.bodyStyle:'')+'></div>'+'<div class="modal-footer"><button type="button" class="close" data-dismiss="modal" aria-hidden="true">'+tpl_lang.close+'</button></div></div></div></div>';$('body').append(modal)}
|
||||
$('#myModal .modal-title').html(title);$('#myModal .modal-body').html(body);$('#myModal').modal('show')}
|
||||
$('#myModal .modal-title').html(title);$('#myModal .modal-body').html(body);$('#myModal').modal('show');$('#myModal').on('hidden.bs.modal',function(e){if(options.hidden_func&&typeof(options.hidden_func)=='function'){options.hidden_func()}})}
|
||||
function htmlIsJson(html){if((/^\{(.+\:.+,*){1,}\}$/).test(html)||(/^\[(.+,*)+\]$/).test(html)){return!0}else{return!1}}
|
||||
function windowModal(title,url,options){if(!options){options={}}
|
||||
modal(title,'<img src="'+window.site_config.pub+'/static/images/loading.gif" />',options);var ajaxSet={type:'get',url:url,success:function(data){if(htmlIsJson(data)){$('#myModal').modal('hide');ajaxDataMsg(data)}else{modal(title,data,options)}},dataType:'html'};if(options.ajax){ajaxSet=$.extend(ajaxSet,options.ajax)}
|
||||
|
@ -32,7 +32,9 @@ function ajaxDataMsg(data){if(typeof data=='string'){data=eval('('+data+')')}
|
|||
if(data.code==1){toastr.success(data.msg)}else{toastr.error(data.msg)}
|
||||
if(data.url){setTimeout("window.location.href='"+data.url+"';",2500)}}
|
||||
function checkall(obj,chkName){var status=$(obj).is(":checked")?true:!1;$("input[name='"+chkName+"']:checkbox").prop('checked',status)}
|
||||
function url_base64encode(str){str=Base64.encode(str);str=str.replace('+','-').replace('/','_').replace('=','');return str}
|
||||
function url_base64encode(str){str=Base64.encode(str);str=str.replace(/\+/g,'-').replace(/\//g,'_').replace(/\=/g,'');return str}
|
||||
function url_base64decode(str){str=str.replace(/\-/g,'+').replace(/\_/g,'/');var mod4=str.length%4;if(mod4){str+=('====').substr(mod4)}
|
||||
str=Base64.decode(str);return str}
|
||||
function generateUUID(){var d=new Date().getTime();var uuid='xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g,function(c){var r=(d+Math.random()*16)%16|0;d=Math.floor(d/16);return(c=='x'?r:(r&0x7|0x8)).toString(16)});return uuid}
|
||||
function refreshVerify(obj){var src=$(obj).attr('src');if(src.indexOf('version')>0){src=src.replace(/([\?\&]version\=)[\.\d]+/i,"$1"+Math.random())}else{src+=(src.indexOf('?')>-1?'&':'?')+'version='+Math.random()}
|
||||
$(obj).attr('src',src)}
|
||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue