mirror of https://gitee.com/zorlan/skycaiji
parent
db0810fceb
commit
281acc380f
|
@ -1,3 +1,3 @@
|
|||
*.js linguist-language=php
|
||||
*.js linguist-language=php
|
||||
*.css linguist-language=php
|
||||
*.html linguist-language=php
|
|
@ -1,4 +1,4 @@
|
|||
将本压缩包上传至您的服务器,如果根目录有站点建议放在子目录里,解压后打开浏览器输入您的服务器域名或ip地址(存放在子目录则加上子目录的名称)进入安装界面。
|
||||
将本压缩包上传至您的服务器,如果根目录有站点建议放在子目录里,解压后打开浏览器输入您的服务器域名或ip地址(存放在子目录则加上子目录的名称)进入安装界面。
|
||||
|
||||
|
||||
入门手册:[https://www.skycaiji.com/manual](https://www.skycaiji.com/manual)
|
||||
|
|
|
@ -205,7 +205,7 @@ abstract class BaseCms extends \skycaiji\admin\event\ReleaseBase{
|
|||
$tag=strtolower($paramVal['tag']);//html标签
|
||||
$func=null;//函数
|
||||
$options=array();//选项
|
||||
if(preg_match('/^function\:(.*)$/i', $paramVal['option'],$func)){
|
||||
if(is_string($paramVal['option'])&&preg_match('/^function\:(.*)$/i',$paramVal['option'],$func)){
|
||||
//函数名
|
||||
$func=trim($func[1]);
|
||||
}elseif(!empty($paramVal['option'])){
|
||||
|
@ -226,7 +226,7 @@ abstract class BaseCms extends \skycaiji\admin\event\ReleaseBase{
|
|||
}
|
||||
}
|
||||
if('select'==$tag){
|
||||
$html.='<select name="_cms_app_param_" class="form-control"><option value="">不选择</option>';
|
||||
$html.='<div class="input-group input-select-custom"><div class="input-group-btn"><select name="_cms_app_param_" class="form-control"><option value="">不选择</option>';
|
||||
if(!empty($func)){
|
||||
//调用函数
|
||||
if(method_exists($this, $func)){
|
||||
|
@ -247,8 +247,8 @@ abstract class BaseCms extends \skycaiji\admin\event\ReleaseBase{
|
|||
$html.="<option value=\"{$optionKey}\">{$optionVal}</option>";
|
||||
}
|
||||
}
|
||||
$html.='<option value="custom:">自定义内容</option></select>'
|
||||
.'<input class="form-control" style="display:none;" name="cms_app[custom]['.$paramKey.']" />';
|
||||
$html.='<option value="custom:">自定义</option></select></div>'
|
||||
.'<input class="form-control" style="display:none;" name="cms_app[custom]['.$paramKey.']" /></div>';
|
||||
}elseif(in_array($tag,array('input','text','number'))){
|
||||
$html.='<input type="'.($tag=='input'?'text':$tag).'" name="_cms_app_param_" class="form-control" value="" />';
|
||||
}elseif('radio'==$tag){
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
transition:none!important;
|
||||
}
|
||||
/*全局*/
|
||||
.modal-body .form-group:last-child{margin-bottom:0;}
|
||||
.modal-body .form-group:last-child>button[type="submit"]{margin-bottom:-15px;}
|
||||
.modal-body .form-group .help-block:last-child{margin-bottom:0;}
|
||||
|
||||
.panel .form-group:last-child{margin-bottom:0;}
|
||||
|
@ -36,8 +36,13 @@
|
|||
|
||||
.label-custom-opened{font-weight:normal;background-color:#dedede;color:#555;}
|
||||
|
||||
.plugin-func-refresh{font-size:12px;}
|
||||
|
||||
.brl_0{border-left:0;}
|
||||
.brr_0{border-right:0;}
|
||||
|
||||
.pdb_0{padding-bottom:0;}
|
||||
|
||||
.h-title{
|
||||
color: #666;
|
||||
font-weight: bold;
|
||||
|
@ -312,6 +317,23 @@ table.table thead .sorting_desc:after {
|
|||
|
||||
.form-inline label{font-weight:normal;}
|
||||
|
||||
.c-p-field-list td .field-process{vertical-align:middle;}
|
||||
.c-p-field-list td .glyphicon.icon-drag-move{font-size:12px;vertical-align:middle;}
|
||||
.c-p-field-list td .glyphicon.field-clone{font-size:12px;top:0.3px;vertical-align:middle;}
|
||||
.c-p-field-list td .glyphicon.field-del{font-size:12px;top:1.1px;vertical-align:middle;}
|
||||
|
||||
#coll_tab_content td .glyphicon.icon-drag-move{font-size:12px;vertical-align:middle;}
|
||||
#coll_tab_content td .glyphicon.clone{font-size:12px;top:0.3px;vertical-align:middle;}
|
||||
#coll_tab_content td .glyphicon.delete{font-size:12px;top:1.1px;vertical-align:middle;}
|
||||
|
||||
.c-p-process-accordion .panel-heading .glyphicon.c-p-process-title{font-size:11px;vertical-align:middle;}
|
||||
.c-p-process-accordion .panel-heading .glyphicon.icon-drag-move{font-size:12px;vertical-align:middle;}
|
||||
.c-p-process-accordion .panel-heading .glyphicon.c-p-process-clone{font-size:12px;top:0.3px;vertical-align:middle;}
|
||||
.c-p-process-accordion .panel-heading .glyphicon.c-p-process-del{font-size:12px;top:1.1px;vertical-align:middle;}
|
||||
.c-p-process-accordion .panel-heading .panel-title-title{float:left;}
|
||||
.c-p-process-accordion .panel-heading .panel-title-title input{display:none;border-radius:2px;border:1px solid #ccc;line-height:14px;font-size:12px;margin-left:5px;padding:1px 1px 1px 2px;}
|
||||
.c-p-process-accordion .panel-heading .panel-title-ops{float:right;line-height:19px;}
|
||||
|
||||
|
||||
#task_list_folder .taskgroup-opened .icon-folder-pre:before{content:"\2212"}
|
||||
#task_list_folder .taskgroup-opened .icon-folder:before{content:"\e118"}
|
||||
|
@ -339,12 +361,10 @@ table.table thead .sorting_desc:after {
|
|||
.iga-rt1 .op li{display:none;}
|
||||
|
||||
.nav-save-rule{float:right!important;}
|
||||
.nav-save-rule .dropdown-menu li a{padding-top:5px;padding-bottom:5px;}
|
||||
/*数据处理*/
|
||||
.form-control-slt{width:30px!important;text-align:center;}
|
||||
.form-control-slt select.form-control{min-width:20px!important;width:20px!important;height:30px!important;float:none!important;border:0!important;padding:0!important;margin:0!important;text-indent:-20px!important;}
|
||||
|
||||
.c-p-process-accordion .panel-heading .glyphicon{font-size:12px;}
|
||||
.p-m-func-field{display:inline;width:80px;border:0;cursor:pointer;margin:0;padding:0;height:auto;color:#555;}
|
||||
|
||||
.p-m-api-val-field,.p-m-api-header-field{display:none;margin-left:-1px;padding:0;}
|
||||
|
@ -359,8 +379,9 @@ table.table thead .sorting_desc:after {
|
|||
.p-m-html-tags a span{margin-right:2px;color:#999;}
|
||||
.p-m-if-val-func{position:relative;}
|
||||
.p-m-if-val-func a.input-group-addon{border-left:0;}
|
||||
.p-m-if-val-func .input-group-btn>select{border-left:0;width:auto;padding:0;padding-left:5px;text-align:center;}
|
||||
.p-m-if-val-func .input-group-btn>select{margin-left:-1px;width:auto;padding:0;padding-left:5px;text-align:center;}
|
||||
.p-m-if-op{width:70px;padding:15px 0 0 8px!important;font-size:11px;}
|
||||
.p-m-if-add{font-size:12px;}
|
||||
|
||||
.p-m-download-op{display:none;margin-top:15px;}
|
||||
/*发布设置*/
|
||||
|
@ -388,6 +409,18 @@ table.table thead .sorting_desc:after {
|
|||
.toapi-param-table td:last-child,.toapi-header-table td:last-child{width:50px;text-align:center;}
|
||||
|
||||
#toapi_resp_module_help .help-block{display:none;margin:0;}
|
||||
|
||||
.toapi-app-table table tr td{height:50px;vertical-align:middle!important;}
|
||||
.toapi-field-txt>.input-group-addon{padding:0;}
|
||||
.toapi-field-txt>.input-group-addon a.dropdown-toggle{border-color:#fff;padding:6px 12px;color:#666;}
|
||||
.toapi-field-txt>.input-group-addon a.dropdown-toggle:hover{color:#000;}
|
||||
.toapi-field-txt>.input-group-addon a.dropdown-toggle .caret{margin-top:-2px;}
|
||||
|
||||
.toapi-field-slt select.form-control{min-width:120px!important;margin-right:-1px;min-height:34px;max-height:90px;}
|
||||
.toapi-field-slt textarea.form-control{height:90px;}
|
||||
.toapi-field-slt input.form-control,.toapi-field-slt textarea.form-control,.toapi-field-slt .input-group-addon{display:none!important;}
|
||||
|
||||
.toapi-field-slt-txt input.form-control,.toapi-field-slt-txt textarea.form-control,.toapi-field-slt-txt .input-group-addon{display:table-cell!important;}
|
||||
/*步骤条*/
|
||||
.steps-bar{width:100%;overflow:hidden;color:#999;}
|
||||
.steps-bar a{color:#999;}
|
||||
|
@ -465,6 +498,8 @@ table.table thead .sorting_desc:after {
|
|||
}
|
||||
/**/
|
||||
#cms_bind em{color:red;}
|
||||
#cms_bind .box{margin-bottom:0;}
|
||||
#cms_bind .table{margin-bottom:0;}
|
||||
#toapi_app_params em{color:red;}
|
||||
|
||||
/*my store*/
|
||||
|
@ -605,6 +640,11 @@ footer.footer-end{display:none;}
|
|||
.db-table-bind-signs .dropdown-menu table{margin:0;}
|
||||
}
|
||||
|
||||
@media (min-width: 900px) {
|
||||
.toapi-app-table .table tr td:FIRST-CHILD{width:200px;white-space:nowrap;padding-right:10px;}
|
||||
#cms_bind .table tr td:FIRST-CHILD{width:200px;white-space:nowrap;padding-right:10px;}
|
||||
}
|
||||
|
||||
@media (min-width: 768px) {
|
||||
.c-p-url-web-form,.c-p-url-web-header{overflow:inherit;} /*table-responsive设置overflow:inherit;可正常显示dropdown-menu*/
|
||||
}
|
||||
|
@ -649,7 +689,9 @@ footer.footer-end{display:none;}
|
|||
.c-p-source-tab>li>a{padding:5px 7px;border:solid 1px #ddd;text-align:center;}
|
||||
.c-p-source-tab>li.active>a{border-radius:3px;border-bottom-color:#ddd!important;background-color:#efefef!important;}
|
||||
|
||||
.mobile-input-group{width:100%;}
|
||||
.mobile-input-group>.input-group-addon{display:table-caption;width:100%;background:#fafafa;margin-bottom:5px;border-right:1px solid #ccc;}
|
||||
.mobile-input-group1>.input-group-addon{display:block;}
|
||||
/*自适应第一个td宽度*/
|
||||
.c-p-request-headers td:first-child,.c-p-request-headers-img td:first-child{width:auto;}
|
||||
.c-p-url-web-form td:first-child,.c-p-url-web-header td:first-child{width:auto;}
|
||||
|
|
|
@ -79,8 +79,8 @@
|
|||
#skycaiji_tips .skycaiji-close {
|
||||
cursor: pointer;
|
||||
position: absolute;
|
||||
font-size: 20px;
|
||||
top: -25px;
|
||||
font-size: 25px;
|
||||
top: -30px;
|
||||
right: 1px;
|
||||
font-weight:bold;
|
||||
z-index: 9999999;
|
||||
|
|
|
@ -11,8 +11,8 @@
|
|||
var menuOpts={};if(bodyWidth>767){if(cpConfig.mini==1){$('body').addClass('sidebar-collapse').addClass('sidebar-mini')}
|
||||
if(cpConfig.narrow==1){$('body').addClass('layout-boxed')}
|
||||
menuOpts={};if(window.navigator.userAgent.indexOf('MSIE')>-1){menuOpts={animationSpeed:0}}}else{menuOpts={animationSpeed:0}}
|
||||
$('.sidebar-menu').tree(menuOpts);$(document).ready(function(){$('#treeview_skins').bind('click',function(){if($('#sidebar_skins').html().length<=0){admincpOp.skins()}});if(bodyWidth>767){if(cpConfig.mini==1){$('#chk_sidebar_mini').prop('checked','checked')}
|
||||
$('#chk_sidebar_mini').bind('click',function(){var setMini=$(this).is(':checked')?1:0;admincpOp.config('mini',setMini,function(){if(setMini){$('body').addClass('sidebar-collapse').addClass('sidebar-mini')}else{$('body').removeClass('sidebar-collapse').removeClass('sidebar-mini')}})});$('.sidebar-toggle[data-toggle="push-menu"]').bind('click',function(){$('body').addClass('sidebar-mini')});if(cpConfig.narrow==1){$('#chk_sidebar_narrow').prop('checked','checked')}
|
||||
$('.sidebar-menu').tree(menuOpts);$(document).ready(function(){$('#treeview_skins').bind('click',function(){if($('#sidebar_skins').html().length<=0){admincpOp.skins()}});if(bodyWidth>767){if(cpConfig.mini==1){$('#chk_sidebar_mini').prop('checked',!0)}
|
||||
$('#chk_sidebar_mini').bind('click',function(){var setMini=$(this).is(':checked')?1:0;admincpOp.config('mini',setMini,function(){if(setMini){$('body').addClass('sidebar-collapse').addClass('sidebar-mini')}else{$('body').removeClass('sidebar-collapse').removeClass('sidebar-mini')}})});$('.sidebar-toggle[data-toggle="push-menu"]').bind('click',function(){$('body').addClass('sidebar-mini')});if(cpConfig.narrow==1){$('#chk_sidebar_narrow').prop('checked',!0)}
|
||||
$('#chk_sidebar_narrow').bind('click',function(){var setNarrow=$(this).is(':checked')?1:0;admincpOp.config('narrow',setNarrow,function(){if(setNarrow){$('body').addClass('layout-boxed')}else{$('body').removeClass('layout-boxed')}})})}else{$('#chk_sidebar_mini').parents('li').eq(0).hide();$('#chk_sidebar_narrow').parents('li').eq(0).hide()}
|
||||
if($('#menu_backstage_task').length>0){$('#menu_backstage_task').bind('click',function(){windowModal('采集任务',ulink('admin/backstage/backstageTask'),{lg:1})});winBackstageTask.count()}})},config:function(op,val,successFunc){ajaxOpen({type:'post',url:ulink('backstage/admincp'),data:{op:op,val:val},success:function(data){if(successFunc&&typeof(successFunc)=='function'){successFunc()}}})},skins:function(){var skinList={'blue':{'name':window.tpl_lang.skin_blue,'top_l_style':'background:#367fa9','top_r_class':'bg-light-blue','left_style':'background: #222d32','right_style':'background: #f4f5f7'},'black':{'name':window.tpl_lang.skin_black,'top_style':'box-shadow: 0 0 2px rgba(0,0,0,0.1)','top_l_style':'background: #fefefe','top_r_style':'background: #fefefe','left_style':'background: #222','right_style':'background: #f4f5f7'},'purple':{'name':window.tpl_lang.skin_purple,'top_l_class':'bg-purple-active','top_r_class':'bg-purple','left_style':'background: #222d32','right_style':'background: #f4f5f7'},'green':{'name':window.tpl_lang.skin_green,'top_l_class':'bg-green-active','top_r_class':'bg-green','left_style':'background: #222d32','right_style':'background: #f4f5f7'},'red':{'name':window.tpl_lang.skin_red,'top_l_class':'bg-red-active','top_r_class':'bg-red','left_style':'background: #222d32','right_style':'background: #f4f5f7'},'yellow':{'name':window.tpl_lang.skin_yellow,'top_l_class':'bg-yellow-active','top_r_class':'bg-yellow','left_style':'background: #222d32','right_style':'background: #f4f5f7'},'blue-light':{'name':window.tpl_lang.skin_blue_light,'top_l_style':'background: #367fa9','top_r_class':'bg-light-blue','left_style':'background: #f9fafc"','right_style':'background: #f4f5f7'},'black-light':{'name':window.tpl_lang.skin_black_light,'top_style':'box-shadow: 0 0 2px rgba(0,0,0,0.1)','top_l_style':'background: #fefefe','top_r_style':'background: #fefefe','left_style':'background: #f9fafc','right_style':'background: #f4f5f7'},'purple-light':{'name':window.tpl_lang.skin_purple_light,'top_l_class':'bg-purple-active','top_r_class':'bg-purple','left_style':'background: #f9fafc','right_style':'background: #f4f5f7'},'green-light':{'name':window.tpl_lang.skin_green_light,'top_l_class':'bg-green-active','top_r_class':'bg-green','left_style':'background: #f9fafc','right_style':'background: #f4f5f7'},'red-light':{'name':window.tpl_lang.skin_red_light,'top_l_class':'bg-red-active','top_r_class':'bg-red','left_style':'background: #f9fafc','right_style':'background: #f4f5f7'},'yellow-light':{'name':window.tpl_lang.skin_yellow_light,'top_l_class':'bg-yellow-active','top_r_class':'bg-yellow','left_style':'background: #f9fafc','right_style':'background: #f4f5f7'},};var html='<ul class="list-unstyled clearfix">';for(var skin in skinList){var skinSet=skinList[skin];html+='<li style="float:left; width: 33.33333%; padding: 5px;">'+'<a href="javascript:void(0)" data-skin="skin-'+skin+'" style="display: block; box-shadow: 0 0 3px rgba(0,0,0,0.4)" class="clearfix full-opacity-hover">'+'<div style="'+(skinSet.top_style?skinSet.top_style:'')+'">'+'<span style="display:block; width: 20%; float: left; height: 7px; '+(skinSet.top_l_style?skinSet.top_l_style:'')+'" class="'+(skinSet.top_l_class?skinSet.top_l_class:'')+'"></span>'+'<span class="'+(skinSet.top_r_class?skinSet.top_r_class:'')+'" style="display:block; width: 80%; float: left; height: 7px; '+(skinSet.top_r_style?skinSet.top_r_style:'')+'"></span></div>'+'<div><span style="display:block; width: 20%; float: left; height: 20px; '+(skinSet.left_style?skinSet.left_style:'')+'"></span><span style="display:block; width: 80%; float: left; height: 20px; '+(skinSet.right_style?skinSet.right_style:'')+'"></span>'+'</div>'+'</a>'+'<p class="text-center no-margin">'+skinSet.name+'</p>';+'</li>'}
|
||||
html+='</ul>';$('#sidebar_skins').html(html);$('#sidebar_skins li a[data-skin]').bind('click',function(){var skin=$(this).attr('data-skin');admincpOp.config('skin',skin,function(){for(var i in skinList){i='skin-'+i;$('body').removeClass(i)}
|
||||
|
@ -30,18 +30,21 @@ windowIframe(title,'',options)}(function(data){if(data){$('#myModal .modal-foote
|
|||
function cpEasyBrowser(url,pageSource,inputUrls){pageSource=pageSource?pageSource:'';inputUrls=inputUrls?inputUrls:{};var data={type:'browser_url',page_source:pageSource,test_url:url,input_urls:inputUrls};data=JSON.stringify(data);window.top.postMessage(data,'*')}
|
||||
function cpBrowserUrl(collId,pageSource,testUrl,inputedUrls){inputedUrls=inputedUrls?inputedUrls:{};var url='cpattern_test/browser?coll_id=_collid_&page_source=_source_&test_url=_url_';if(inputedUrls){for(var i in inputedUrls){url+='&'+i+'='+encodeURIComponent(inputedUrls[i])}}
|
||||
url=ulink(url,{'_collid_':collId,'_source_':pageSource,'_url_':testUrl});return url}
|
||||
var pluginFuncOp={load:function(params){params=params?params:{};var boxObj=$(params.boxObj);var funcObj=boxObj.find(params.funcObj);var paramObj=params.paramObj?boxObj.find(params.paramObj):null;var funcVal=params.funcVal?params.funcVal:'';var winCacheName='win_cache_plugin_func_'+params.module;if(paramObj&¶mObj.length>0){if(!funcObj.attr('data-change-pla')){funcObj.attr('data-change-pla',1);funcObj.bind('change',function(){var reStrFunc=function(str){if(str){var regLineR=new RegExp("\\\\r",'g');var regLineN=new RegExp("\\\\n",'g');str=str.replace(regLineR,"\r").replace(regLineN,"\n")}else{str=''}
|
||||
var pluginFuncOp={load:function(params){params=params?params:{};var cacheParams=params;var boxObj=$(params.boxObj);var funcObj=boxObj.find(params.funcObj);var paramObj=params.paramObj?boxObj.find(params.paramObj):null;var funcVal=params.funcVal?params.funcVal:'';var winCacheName='win_cache_plugin_func_'+params.module;boxObj.find('.plugin-func-refresh').off('click').bind('click',function(){window[winCacheName]=null;funcObj.removeAttr('data-is-loaded');funcObj.find('[data-is-func]').remove();cacheParams.show_refresh=1;pluginFuncOp.load(cacheParams);return!1});if(paramObj&¶mObj.length>0){if(!funcObj.attr('data-change-pla')){funcObj.attr('data-change-pla',1);funcObj.bind('change',function(){var reStrFunc=function(str){if(str){var regLineR=new RegExp("\\\\r",'g');var regLineN=new RegExp("\\\\n",'g');str=str.replace(regLineR,"\r").replace(regLineN,"\n")}else{str=''}
|
||||
return str};paramObj=boxObj.find(params.paramObj);var placeholder=paramObj.attr('data-placeholder');placeholder=reStrFunc(placeholder);if($(this).val()){var sltOption=$(this).find('option:selected');var funcPrams=sltOption.attr('data-params');funcPrams=funcPrams?funcPrams:'';var funcComment=sltOption.attr('data-comment');funcComment=funcComment?funcComment:'';if(funcPrams||funcComment){if(funcPrams){placeholder+="\r\n函数参数:"+reStrFunc(funcPrams)}
|
||||
if(funcComment){placeholder+="\r\n函数注释:"+reStrFunc(funcComment)}}}
|
||||
var rows=3;if(placeholder){var regLine=new RegExp("[\\r\\n]+",'g');var matchLine=placeholder.split(regLine);if(matchLine&&typeof(matchLine)=='object'){rows=parseInt(matchLine.length)+1}}
|
||||
if(rows>8){rows=8}
|
||||
if(rows<3){rows=3}
|
||||
paramObj.attr('placeholder',placeholder).attr('rows',rows)})}}
|
||||
var setFuncVal=function(){funcObj.val(funcVal).trigger('change')};if(funcObj.attr('data-is-loaded')){setFuncVal()}else{if(params.cache&&window[winCacheName]){funcObj.attr('data-is-loaded',1).append(window[winCacheName]);setFuncVal()}else{var funcUrl=ulink('collector/plugin_func?module=_module_',{'_module_':params.module});ajaxOpen({type:'GET',dataType:'json',url:funcUrl,async:params.cache?false:!0,success:function(data){if(funcObj.attr('data-is-loaded')){setFuncVal()}else{funcObj.attr('data-is-loaded',1);if(data.code==1){var html='';var apps=data.data;if(apps&&typeof(apps)=='object'){for(var app in apps){var appData=apps[app];appData=appData?appData:{};var methods=appData.methods;if(methods){html+='<optgroup label="'+htmlspecialchars(appData.name+'('+app+')')+'">';for(var m in methods){var mMethod=methods[m];mMethod=mMethod?mMethod:{};html+='<option value="'+app+':'+m+'" data-params="'+(mMethod.params?mMethod.params:'')+'" data-comment="'+(mMethod.comment?mMethod.comment:'')+'">'+m+':'+(mMethod.comment_cut?mMethod.comment_cut:'')+'</option>'}
|
||||
var setFuncVal=function(){funcObj.val(funcVal).trigger('change')};var optEptObj=funcObj.find('option[value=""]');if(optEptObj.length<=0){optEptObj=null}
|
||||
if(funcObj.attr('data-is-loaded')){setFuncVal()}else{if(params.cache&&window[winCacheName]){funcObj.attr('data-is-loaded',1);if(optEptObj){optEptObj.after(window[winCacheName])}else{funcObj.append(window[winCacheName])}
|
||||
setFuncVal()}else{var funcUrl=ulink('collector/plugin_func?module=_module_',{'_module_':params.module});ajaxOpen({type:'GET',dataType:'json',url:funcUrl,async:params.cache?false:!0,success:function(data){if(funcObj.attr('data-is-loaded')){setFuncVal()}else{funcObj.attr('data-is-loaded',1);if(data.code==1){var html='';var apps=data.data;if(apps&&typeof(apps)=='object'){for(var app in apps){var appData=apps[app];appData=appData?appData:{};var methods=appData.methods;if(methods){html+='<optgroup label="'+htmlspecialchars(appData.name+'('+app+')')+'" data-is-func="1">';for(var m in methods){var mMethod=methods[m];mMethod=mMethod?mMethod:{};html+='<option value="'+app+':'+m+'" data-params="'+(mMethod.params?mMethod.params:'')+'" data-comment="'+(mMethod.comment?mMethod.comment:'')+'">'+m+':'+(mMethod.comment_cut?mMethod.comment_cut:'')+'</option>'}
|
||||
html+='</optgroup>'}}}
|
||||
funcObj.append(html);if(params.cache){window[winCacheName]=html}}}},error:function(xhr,status,error){funcObj.removeAttr('data-is-loaded');toastr.error('函数插件载入失败:'+status+' '+error+' <a href="'+funcUrl+'" target="_blank" style="color:#ddd;">查看详细</a>')},complete:function(xhr,status){setFuncVal()}})}}},addHtml:function(params,loadParams){if(!isObject(params)){params={}}
|
||||
var funcData=isObject(params.funcData)?params.funcData:{};var funcName=params.funcName?params.funcName:'';var funcParamName=params.funcParamName?params.funcParamName:'';var tplId=params.tplId?params.tplId:'';tplId='#'+tplId;var listId=params.listId?params.listId:'';listId='#'+listId;var funcId=params.funcId?params.funcId:'';var html=$(tplId).html();html=$(html);var randId=generateUUID();funcName=funcName.replace('{id}',randId);funcParamName=funcParamName.replace('{id}',randId);funcId=funcId.replace('{id}',randId);html.find('[data-func-a]').attr('href','#'+funcId).html('使用函数'+(funcData.func?(':'+funcData.func):''));html.find('[data-func-panel]').attr('id',funcId);html.find('[data-func-func]').attr('name',funcName);html.find('[data-func-func-param]').attr('name',funcParamName).val(funcData.func_param?funcData.func_param:'');$(listId).append(html);if(!isObject(loadParams)){loadParams={}}
|
||||
loadParams.funcObj='[name="'+funcName+'"]';loadParams.paramObj='[name="'+funcParamName+'"]';loadParams.funcVal=funcData.func;pluginFuncOp.load(loadParams)},initHtml:function(listObj){$(listObj).on('click','a[data-func-insert]',function(){var val=$(this).attr('data-func-insert');if(val){var obj=$(this).parents('[data-func-box]').eq(0).find('textarea[data-func-func-param]');insertAtCaret(obj,obj.val()?("\r\n"+val):val)}});$(listObj).on('click','a[data-func-remove]',function(){var curObj=$(this);confirmRight('确定删除?',function(){curObj.parents('[data-func-box]').eq(0).remove()})});eleExchange(listObj,'a[data-func-move]','[data-func-box]')},tips:function(module){var tips='';if(module=='process'){tips='<p>如需扩展系统函数,请在根目录/data/config.php中添加配置:</p>'+"<p>'EXTEND_PROCESS_FUNC'=>array('PHP函数名'=>'描述')</p>"+'<p>如需扩展插件函数,可创建<a href="'+ulink('develop/func?module=process')+'" target="_blank">函数插件</a></p>'}else if(module=='processIf'){tips='<p>选择函数,取反可获取函数结果的相反值</p>'+'<p>默认将当前字段作为参数传入,如需传入多个参数,一行一个值,可输入任何内容或调用字段</p>'+'<p>请按函数传参,否则运行出错!</p>'+'<p>如需扩展系统函数,请在根目录/data/config.php中添加配置:</p>'+"<p>'EXTEND_PROCESS_IF'=>array('PHP函数名'=>'描述')</p>"+'<p>如需扩展插件函数,可创建<a href="'+ulink('develop/func?module=processIf')+'" target="_blank">函数插件</a></p>'}else if(module=='downloadImg'||module=='downloadFile'||module=='contentSign'){window.open(ulink('develop/func?module='+module));return!1}
|
||||
if(optEptObj){optEptObj.after(html)}else{funcObj.append(html)}
|
||||
if(params.cache){window[winCacheName]=html}}}
|
||||
if(params.show_refresh){toastr.success('已刷新')}},error:function(xhr,status,error){funcObj.removeAttr('data-is-loaded');toastr.error('函数插件载入失败:'+status+' '+error+' <a href="'+funcUrl+'" target="_blank" style="color:#ddd;">查看详细</a>')},complete:function(xhr,status){setFuncVal()}})}}},addHtml:function(params,module){if(!isObject(params)){params={}}
|
||||
var funcData=isObject(params.funcData)?params.funcData:{};var funcName=params.funcName?params.funcName:'';var funcParamName=params.funcParamName?params.funcParamName:'';var tplId=params.tplId?params.tplId:'';tplId='#'+tplId;var listId=params.listId?params.listId:'';listId='#'+listId;var funcId=params.funcId?params.funcId:'';var html=$(tplId).html();html=$(html);var randId=generateUUID();funcName=funcName.replace('{id}',randId);funcParamName=funcParamName.replace('{id}',randId);funcId=funcId.replace('{id}',randId);html.find('[data-func-a]').attr('href','#'+funcId).html('使用函数'+(funcData.func?(':'+funcData.func):''));html.find('[data-func-panel]').attr('id',funcId);html.find('[data-func-func]').attr('name',funcName);html.find('[data-func-func-param]').attr('name',funcParamName).val(funcData.func_param?funcData.func_param:'');$(listId).append(html);var loadParams={'boxObj':funcId?$('#'+funcId):html.find('[data-func-panel]'),'module':module,'funcObj':'[name="'+funcName+'"]','paramObj':'[name="'+funcParamName+'"]','funcVal':funcData.func};pluginFuncOp.load(loadParams)},initHtml:function(listObj){$(listObj).on('click','a[data-func-insert]',function(){var val=$(this).attr('data-func-insert');if(val){var obj=$(this).parents('[data-func-box]').eq(0).find('textarea[data-func-func-param]');insertAtCaret(obj,obj.val()?("\r\n"+val):val)}});$(listObj).on('click','a[data-func-remove]',function(){var curObj=$(this);confirmRight('确定删除?',function(){curObj.parents('[data-func-box]').eq(0).remove()})});eleExchange(listObj,'a[data-func-move]','[data-func-box]')},tips:function(module){var tips='';if(module=='process'||module=='contentSign'){tips='<p>如需扩展系统函数,请在根目录/data/config.php中添加配置:</p>'+"<p>'EXTEND_PROCESS_FUNC'=>array('PHP函数名'=>'描述')</p>"+'<p>如需扩展插件函数,可创建<a href="'+ulink('develop/func?module='+module)+'" target="_blank">函数插件</a></p>'}else if(module=='processIf'){tips='<p>选择函数,取反可获取函数结果的相反值</p>'+'<p>默认将当前字段作为参数传入,如需传入多个参数,一行一个值,可输入任何内容或调用字段</p>'+'<p>请按函数传参,否则运行出错!</p>'+'<p>如需扩展系统函数,请在根目录/data/config.php中添加配置:</p>'+"<p>'EXTEND_PROCESS_IF'=>array('PHP函数名'=>'描述')</p>"+'<p>如需扩展插件函数,可创建<a href="'+ulink('develop/func?module=processIf')+'" target="_blank">函数插件</a></p>'}else if(module=='downloadImg'||module=='downloadFile'){window.open(ulink('develop/func?module='+module));return!1}
|
||||
confirmRight({msg:tips,yes:'确定',width:500,textAlign:'left'})}};function tipsCurlPost(){var tips='<p>表单数据:模拟form表单输入的数据</p><p>表单上传:模拟form表单输入并上传的数据</p>'+'<p>JSON数组:以json格式发送数据,可在“发送数据”的“值”中直接输入json字符串。在“名称”中填入json数组键名,根节点名称使用###表示,子节点名称使用.分隔,例如:a.b.c</p>';confirmRight({msg:tips,yes:'确定',width:500,textAlign:'left'})}
|
||||
function collectorWindow(title,uri,uriVals,options){options=options?options:{};options.backdrop_static=1;title=isNull(title)?'':title;title+='<div class="loading-sm" style="margin-left:5px;"></div>';window.win_collector_window_params={title:title,uri:uri,uriVals:uriVals,options:options};windowModal(title,ulink('admin/collector/echo_msg?op=run'),{lg:options.lg})}
|
||||
var collectorEchoMsg={config:{},processes:{},close_non_stop:!1,end_set_timeout:null,run:function(config){collectorEchoMsg.config=isObject(config)?config:{};collectorEchoMsg.processes={};collectorEchoMsg.close_non_stop=!1;var winParams=window.win_collector_window_params;winParams=isObject(winParams)?winParams:{};var uri=winParams.uri?winParams.uri:'';var uriVals=isObject(winParams.uriVals)?winParams.uriVals:{};var options=isObject(winParams.options)?winParams.options:{};var winProcessBox=$('#myModal #win_cem_process_box').clone();if(uri){var title=winParams.title+'<small style="margin-left:10px;">日志读取间隔<input type="number" class="form-control input-sm" style="display:inline;width:40px;height:20px;padding:1px 2px 1px 2px;margin:0px 3px 0px 3px;" id="win_cem_interval" value="'+collectorEchoMsg.get_interval()+'" />秒<button type="button" class="btn btn-default btn-xs" id="win_cem_interval_btn" style="margin-left:3px;">保存</button>';var closeFuncs=new Array();if(!isNull(options.close_func)){if(isObject(options.close_func)){closeFuncs=options.close_func}else{closeFuncs.push(options.close_func)}}
|
||||
|
@ -85,5 +88,5 @@ var sign=window.tpl_lang.sign_match;var rule='';if(fromObj){rule=$(fromObj).val(
|
|||
var reP=new RegExp("\\(\\?<(?:content|nr)(\\w*)>.*?\\)",'g');rule=rule.replace(reP,sign.replace('{:id}',"$1"));var regSign=new RegExp(sign.replace('{:id}','(\\w*)').replace('[','\\[').replace(']','\\]'),'g');var list=null;var hasSign=!1;var returnList=new Array();while((list=regSign.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('{:id}','');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}},wildcard:function(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)}},tips:function(isPage,isPn){var tips='<p>1、规则中的特殊字符:<b>^$.*+|?[]{}()</b> 必须加上“\\”才能转义为字符,否则会识别为正则符号</p><p>2、[内容]标签的标识可由数字、字母及下划线组成</p>';if(isPage){if(isPn){tips+='<p>3、分页[内容]标签不可全局调用,只能在当前分页中调用</p>'}else{tips+='<p>3、页面级别:多级页 > 多级页子页 > 内容页 > 关联页 > 关联页子页</p>';tips+='<p>4、[内容]标签可全局调用,但只能调用比自己级别高的页面中的标签,即内容页可调用多级页中的标签而不能调用关联页中的标签</p>';tips+='<p>5、同一页面中有相同标识的[内容]标签时,后面的标签会覆盖前面的同名标签。不同页面中有相同标识的[内容]标签时,低级别页面会覆盖高级别页面中的同名标签</p>'}}
|
||||
confirmRight({msg:tips,yes:'确定',width:500,textAlign:'left'})}}
|
||||
var wildcard=window.tpl_lang.sign_wildcard;if(options.only){if($(toObj).val().indexOf(wildcard)<0){insertAtCaret($(toObj),wildcard)}}else{insertAtCaret($(toObj),wildcard)}},tips:function(isPage,isPn){isPage=isPage==1?true:!1;isPn=isPn==1?true:!1;var tips='<p>1、规则中的特殊字符:<b>^$.*+|?[]{}()</b> 必须加上“\\”才能转义为字符,否则会识别为正则符号</p><p>2、[内容]标签的标识可由数字、字母及下划线组成</p>';if(isPage){if(isPn){tips+='<p>3、分页[内容]标签不可全局调用,只能在当前分页中调用</p>'}else{tips+='<p>3、页面级别:多级页 > 多级页子页 > 内容页 > 关联页 > 关联页子页</p>';tips+='<p>4、[内容]标签可全局调用,但只能调用比自己级别高的页面中的标签,即内容页可调用多级页中的标签而不能调用关联页中的标签</p>';tips+='<p>5、同一页面中有相同标识的[内容]标签时,后面的标签会覆盖前面的同名标签。不同页面中有相同标识的[内容]标签时,低级别页面会覆盖高级别页面中的同名标签</p>'}}
|
||||
confirmRight({msg:tips,yes:'确定',width:500,textAlign:'left'})},tool_tips:function(){var tips='<p>规则中的特殊字符:<b>^$.*+|?[]{}()</b> 必须加上“\\”才能转义为字符,否则会识别为正则符号</p>';confirmRight({msg:tips,yes:'确定',width:500,textAlign:'left'})}}
|
|
@ -15,7 +15,7 @@ if(!isObject(dataRenderer)){dataRenderer={}}
|
|||
var hasUrlWeb=!1;for(var i in dataUrlWeb){hasUrlWeb=!0}
|
||||
var hasRenderer=!1;for(var i in dataRenderer){hasRenderer=!0}
|
||||
this.cpUrlWeb.page_load('test',dataUrlWeb);this.cpRenderer.page_load('test',dataRenderer);var urlWebForm=$('.c-p-url-web-form').parents('.form-group').eq(0);var urlWebBox=urlWebForm.parents('.panel[id]').eq(0);if(hasUrlWeb){urlWebBox=urlWebBox.find('.panel-body').eq(0);urlWebBox.html(urlWebForm)}else{urlWebBox.hide()}
|
||||
var rendererList=$('.c-p-url-renderer-list').parents('.form-group').eq(0);var rendererBox=rendererList.parents('.panel[id]').eq(0);if(hasRenderer){rendererBox=rendererBox.find('.panel-body').eq(0);rendererBox.html(rendererList)}else{rendererBox.hide()}},load:function(config){var $_o=this;if(config){$(this.formid+' [name="config[charset_custom]"]').val(config.charset_custom);$(this.formid+' [name="config[charset]"]').val(config.charset).trigger('change');$(this.formid+' [name="config[encode_custom]"]').val(config.encode_custom);$(this.formid+' [name="config[encode]"]').val(config.encode).trigger('change');$(this.formid+' [name="config[url_complete]"][value="'+toInt(config.url_complete)+'"]').prop('checked',!0);$(this.formid+' [name="config[url_reverse]"][value="'+toInt(config.url_reverse)+'"]').prop('checked',!0);$(this.formid+' [name="config[page_render]"][value="'+toInt(config.page_render)+'"]').prop('checked',!0).trigger('click');$(this.formid+' [name="config[url_repeat]"][value="'+toInt(config.url_repeat)+'"]').prop('checked',!0);$(this.formid+' [name="config[url_no_name]"][value="'+toInt(config.url_no_name)+'"]').prop('checked',!0);$(this.formid+' [name="config[url_encode]"][value="'+toInt(config.url_encode)+'"]').prop('checked',!0);if(config.regexp_flags){for(var i in config.regexp_flags){$(this.formid).find('[name="config[regexp_flags][]"][value="'+config.regexp_flags[i]+'"]').prop('checked',!0)}}
|
||||
var rendererList=$('.c-p-url-renderer-list').parents('.form-group').eq(0);var rendererBox=rendererList.parents('.panel[id]').eq(0);if(hasRenderer){rendererBox=rendererBox.find('.panel-body').eq(0);rendererBox.html(rendererList)}else{rendererBox.hide()}},load:function(config){var $_o=this;if(config){$(this.formid+' [name="config[charset_custom]"]').val(config.charset_custom);$(this.formid+' [name="config[charset]"]').val(config.charset).trigger('change');$(this.formid+' [name="config[encode_custom]"]').val(config.encode_custom);$(this.formid+' [name="config[encode]"]').val(config.encode).trigger('change');$(this.formid+' [name="config[url_complete]"][value="'+toInt(config.url_complete)+'"]').prop('checked',!0);$(this.formid+' [name="config[url_order]"][value="'+config.url_order+'"]').prop('checked',!0);$(this.formid+' [name="config[page_render]"][value="'+toInt(config.page_render)+'"]').prop('checked',!0).trigger('click');$(this.formid+' [name="config[url_repeat]"][value="'+toInt(config.url_repeat)+'"]').prop('checked',!0);$(this.formid+' [name="config[url_no_name]"][value="'+toInt(config.url_no_name)+'"]').prop('checked',!0);$(this.formid+' [name="config[url_encode]"][value="'+toInt(config.url_encode)+'"]').prop('checked',!0);if(config.regexp_flags){for(var i in config.regexp_flags){$(this.formid).find('[name="config[regexp_flags][]"][value="'+config.regexp_flags[i]+'"]').prop('checked',!0)}}
|
||||
if(isObject(config.front_urls)){for(var i in config.front_urls){$_o.cpFrontUrl.add(null,config.front_urls[i])}
|
||||
showPanelCollapse('#coll_pattern_front_url')}
|
||||
if(config.source_url){var source_url_html_list='';var sourceParams={get:1};for(var i in config.source_url){sourceParams.source_url=config.source_url[i];source_url_html_list+=this.source_op('add',sourceParams)}
|
||||
|
@ -174,7 +174,7 @@ if(hasField){toastr.error('该字段已存在!');return!1}}
|
|||
ajaxOpen({type:'POST',dataType:'json',url:$(formObj).attr('action'),data:$(formObj).serialize(),success:function(data){if(data.code==1){$('#myModal').modal('hide');$_o.field_op(pageType,'add',data.data)}else{toastr.error(data.msg)}},error:function(data){toastr.error(data)}});return!1}}}
|
||||
function CpField(cpClass){this.$_cp=cpClass;this.formObj='#form_field'}
|
||||
CpField.prototype={constructor:CpField,init:function(fieldData){var $_o=this;var sourceOptions=$_o.$_cp.page_source_options(!1);if(sourceOptions){$($_o.formObj+' select[name="field[source]"]').html(sourceOptions)}
|
||||
$($_o.formObj+' select[name="field[source]"]').bind('change',function(){var fsource=$(this).val();fsource=fsource.split(':');var pageType=fsource[0]?fsource[0]:'url';var pageName=fsource[1]?fsource[1]:'';var pageVars=$_o.$_cp.get_page_vars(pageType);var boxId=pageVars.boxId;var namePre=pageVars.namePre;var formId=pageVars.formId;var pageSigns=[];if(pageType=='source_url'||pageType=='url'){var urlConfig={};var noDefSign=!1;if(pageType=='source_url'){urlConfig.area='';urlConfig.url_rule='';noDefSign=!0}else{urlConfig.area=$(formId+' [name="'+namePre+'[area]"]').val();urlConfig.url_rule=$(formId+' [name="'+namePre+'[url_rule]"]').val()}
|
||||
$($_o.formObj+' select[name="field[source]"]').bind('change',function(){var fsource=$(this).val();fsource=fsource?fsource.split(':'):[];var pageType=fsource[0]?fsource[0]:'url';var pageName=fsource[1]?fsource[1]:'';var pageVars=$_o.$_cp.get_page_vars(pageType);var boxId=pageVars.boxId;var namePre=pageVars.namePre;var formId=pageVars.formId;var pageSigns=[];if(pageType=='source_url'||pageType=='url'){var urlConfig={};var noDefSign=!1;if(pageType=='source_url'){urlConfig.area='';urlConfig.url_rule='';noDefSign=!0}else{urlConfig.area=$(formId+' [name="'+namePre+'[area]"]').val();urlConfig.url_rule=$(formId+' [name="'+namePre+'[url_rule]"]').val()}
|
||||
urlConfig.content_signs=$_o.$_cp.get_content_signs(formId+' [name="'+namePre+'[content_signs][]"]');pageSigns=$_o.$_cp.page_signs(urlConfig,!1,noDefSign)}else if(pageName){var pageConfig=$('#c_p_'+pageType+'s .name[data-val="'+pageName+'"]').parents('tr[id^="'+pageType+'_"]').eq(0).find('[name="config['+pageType+'s][]"]').val();pageConfig=decode_urlbase2json(pageConfig);if(pageConfig){var noDefSign=pageType=='front_url'?true:!1;pageSigns=$_o.$_cp.page_signs(pageConfig,!1,noDefSign)}}
|
||||
var signListId=$_o.formObj+' #c_p_field_sign_list';$(signListId).html('');var signKeys={area:'区域规则',url:'网址规则',content:'提取内容'};var signInKeys={area:['url','content'],url:['content'],content:null};for(var signKey in signKeys){var curPageSigns=pageSigns[signKey];if(isObject(curPageSigns)&&curPageSigns.length>0){var signHtml='<div style="margin-bottom:5px;">'+signKeys[signKey]+':';var signInKey=signInKeys[signKey];for(var cpsi in curPageSigns){var curSign=curPageSigns[cpsi];var curSignExist=!1;if(isObject(signInKey)){for(var siki in signInKey){var pageInSigns=pageSigns[signInKey[siki]];if(isObject(pageInSigns)&&pageInSigns.indexOf(curSign)>-1){curSignExist=!0;break}}}
|
||||
if(curSignExist){signHtml+='<span style="margin-right:7px;color:#999;" title="被覆盖">'+curSign+'</span>'}else{signHtml+='<a href="javascript:;" style="margin-right:7px;" data-val="'+curSign+'">'+curSign+'</a>'}}
|
||||
|
@ -244,7 +244,7 @@ $($_o.formObj).bind('submit',function(){$_o.add_sub();return!1});if(!isObject(pa
|
|||
if(!isObject(pageConfig[namePre])){pageConfig[namePre]={}}
|
||||
$_o.curPageType=pageType;$_o.curPageConfig=pageConfig;if($_o.$_cp.page_is_list($_o.curPageType)){$('#myModal').on('hidden.bs.modal',function(e){if($_o.$_cp.page_is_list($_o.curPageType)){var curPageVars=$_o.$_cp.get_page_vars($_o.curPageType);var namePre=curPageVars.namePre;var options={'ajax_scroll_top':window.modal_scroll_top,lg:1,ajax:{type:'post',data:{}}};options.ajax.data.objid=$_o.curPageConfig.objid;options.ajax.data[namePre]=encode_json2urlbase($_o.curPageConfig[namePre]);windowModal('编辑'+curPageVars.title+'规则',ulink('cpattern/'+$_o.curPageType),options)}})}
|
||||
$($_o.formObj+' select[name="content_sign[module]"]').bind('change',function(){$($_o.formObj+' .c-p-content-sign-module').hide();$($_o.formObj+' .c-p-content-sign-module[data-module="'+$(this).val()+'"]').show()});$($_o.formObj+' #c_p_content_sign_add_func').bind('click',function(){$_o.add_func(null)});pluginFuncOp.initHtml($_o.formObj+' #c_p_content_sign_funcs');cpRuleModuleInit($_o.formObj,'content_sign','');if(contentSign){$($_o.formObj+' [name="objid"]').attr('data-identity',contentSign.identity);for(var i in contentSign){var csEle=$($_o.formObj+' [name="content_sign['+i+']"]');if(csEle.is('input:text')){csEle.val(contentSign[i])}else if(csEle.is('select')){csEle.val(contentSign[i]).trigger("change")}}
|
||||
cpRuleModuleLoad($_o.formObj,'content_sign','',contentSign);if(isObject(contentSign.funcs)){for(var i in contentSign.funcs){$_o.add_func(contentSign.funcs[i])}}}},add_func:function(contentSignFunc){var $_o=this;pluginFuncOp.addHtml({funcData:contentSignFunc,funcName:'content_sign[funcs][{id}][func]',funcParamName:'content_sign[funcs][{id}][func_param]',tplId:'c_p_content_sign_tpl_func',listId:'c_p_content_sign_funcs',funcId:'c_p_content_sign_func_{id}'},{module:'contentSign',boxObj:$_o.formObj})},add_sub:function(){var $_o=this;ajaxOpen({type:'POST',dataType:'json',url:$($_o.formObj).attr('action'),data:$($_o.formObj).serialize(),success:function(data){if(data.code==1){data=data.data;if(data&&data.content_sign){var contentSign=data.content_sign;if($_o.$_cp.page_is_list($_o.curPageType)){var namePre=$_o.$_cp.get_page_vars($_o.curPageType,'namePre');var pageTypeConfig=$_o.curPageConfig[namePre];if(!isObject(pageTypeConfig.content_signs)){pageTypeConfig.content_signs=[]}
|
||||
cpRuleModuleLoad($_o.formObj,'content_sign','',contentSign);if(isObject(contentSign.funcs)){for(var i in contentSign.funcs){$_o.add_func(contentSign.funcs[i])}}}},add_func:function(contentSignFunc){var $_o=this;pluginFuncOp.addHtml({funcData:contentSignFunc,funcName:'content_sign[funcs][{id}][func]',funcParamName:'content_sign[funcs][{id}][func_param]',tplId:'c_p_content_sign_tpl_func',listId:'c_p_content_sign_funcs',funcId:'c_p_content_sign_func_{id}'},'contentSign')},add_sub:function(){var $_o=this;ajaxOpen({type:'POST',dataType:'json',url:$($_o.formObj).attr('action'),data:$($_o.formObj).serialize(),success:function(data){if(data.code==1){data=data.data;if(data&&data.content_sign){var contentSign=data.content_sign;if($_o.$_cp.page_is_list($_o.curPageType)){var namePre=$_o.$_cp.get_page_vars($_o.curPageType,'namePre');var pageTypeConfig=$_o.curPageConfig[namePre];if(!isObject(pageTypeConfig.content_signs)){pageTypeConfig.content_signs=[]}
|
||||
contentSign._objid=data.objid;pageTypeConfig.content_signs.push(contentSign);$_o.curPageConfig[namePre]=pageTypeConfig}else{$_o.page_add($_o.curPageType,data.objid,contentSign)}}
|
||||
$('#myModal').modal('hide')}else{toastr.error(data.msg)}},error:function(data){toastr.error(data)}});return!1}}
|
||||
function cpRuleModuleInit(boxId,name,namePre){namePre=namePre?namePre:'';var isProcess=(name=='data-process')?true:!1;if(isProcess){$(boxId).on('change','[data-process="'+namePre+'rule_multi"]',function(){var prt=$(this).parents('.p-m-api-rule-module').eq(0);if($(this).is(':checked')){prt.find('.p-m-api-rule-multi-str').show()}else{prt.find('.p-m-api-rule-multi-str').hide()}});inputSelectCustom(null,null,{box:boxId,slt:'[data-process="'+namePre+'xpath_attr"]',ipt:'[data-process="'+namePre+'xpath_attr_custom"]'});$(boxId).on('change','[data-process="'+namePre+'xpath_multi"]',function(){var prt=$(this).parents('.p-m-api-rule-module').eq(0);if($(this).is(':checked')){prt.find('.p-m-api-xpath-multi-str').show()}else{prt.find('.p-m-api-xpath-multi-str').hide()}});$(boxId).on('change','select[data-process="'+namePre+'json_arr"]',function(){var prt=$(this).parents('.p-m-api-rule-module').eq(0);if($(this).val()=='implode'){prt.find('.p-m-api-json-arr-implode').show()}else{prt.find('.p-m-api-json-arr-implode').hide()}});$(boxId).on('click','a[data-rule-sign]',function(){var prt=$(this).parents('.p-m-api-rule-module').eq(0);var obj=prt.find('[data-process="'+namePre+'rule"]');var ruleSign=$(this).attr('data-rule-sign');if(ruleSign=='sign_wildcard'){ruleInsertSign.wildcard(obj)}else if(ruleSign=='sign_match'){ruleInsertSign.match(obj)}else if(ruleSign=='sign_group'){ruleInsertSign.match(obj,{group:1})}else if(ruleSign=='sign_match_n'){var ruleMerge=prt.find('[data-process="'+namePre+'rule_merge"]');ruleInsertSign.matchN(obj,ruleMerge,{def:1})}})}else{$(boxId+' [name="'+name+'['+namePre+'rule_multi]"]').bind('change',function(){if($(this).is(':checked')){$(boxId+' #c_p_'+name+'_'+namePre+'rule_multi_str').show()}else{$(boxId+' #c_p_'+name+'_'+namePre+'rule_multi_str').hide()}});inputSelectCustom(boxId+' select[name="'+name+'['+namePre+'xpath_attr]"]',name+'['+namePre+'xpath_attr_custom]');$(boxId+' [name="'+name+'['+namePre+'xpath_multi]"]').bind('change',function(){if($(this).is(':checked')){$(boxId+' #c_p_'+name+'_'+namePre+'xpath_multi_str').show()}else{$(boxId+' #c_p_'+name+'_'+namePre+'xpath_multi_str').hide()}});$(boxId+' select[name="'+name+'['+namePre+'json_arr]"]').bind('change',function(){if($(this).val()=='implode'){$(boxId+' #c_p_'+name+'_'+namePre+'json_arr_implode').show()}else{$(boxId+' #c_p_'+name+'_'+namePre+'json_arr_implode').hide()}})}}
|
||||
|
|
|
@ -7,41 +7,54 @@
|
|||
| 使用协议 https://www.skycaiji.com/licenses
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
'use strict';function SkycaijiCpatternBrowser(){this.consoleId='#skycaiji_console';this.bdNum=0;this.bdNumMax=11}
|
||||
SkycaijiCpatternBrowser.prototype={constructor:SkycaijiCpatternBrowser,init:function(configTips){var $_o=this;$('#skycaiji_wrapper').attr('skycaiji-console',$($_o.consoleId).prop('outerHTML'));$('#skycaiji_tpl').remove();$('body').append('<textarea id="skycaiji_tpl" style="display:none;"></textarea>');$('#skycaiji_tpl').val($('#skycaiji_wrapper').prop("outerHTML"));$('#skycaiji_wrapper').remove();$('*').removeAttr('onclick').unbind('click').bind('click',function(){var tagName=$(this).prop('tagName').toLowerCase();if(tagName=='body'||tagName=='html'){return!1}
|
||||
$(this).data('skycaiji-click',$(this).data('skycaiji-click')?0:1);var xpaths=$_o.get_xpaths(this,!1);if(!xpaths.listXpath){var xpaths1=$_o.get_xpaths(this,!0);xpaths1.xpath=xpaths.xpath;xpaths=xpaths1}
|
||||
$($_o.consoleId).remove();$('#skycaiji_wrapper').append($('#skycaiji_wrapper').attr('skycaiji-console'));$($_o.consoleId).show();if(xpaths.xpath){$($_o.consoleId).find('[skycaiji-id="xpath"]').val(xpaths.xpath);if(!xpaths.listXpath){$_o.show_xpath_ele($($_o.consoleId+' [skycaiji-id="show-xpath"]'),xpaths.xpath,$(this).data('skycaiji-click'))}}
|
||||
if(xpaths.listXpath){$($_o.consoleId+' [skycaiji-id="listXpath"]').val(xpaths.listXpath);$($_o.consoleId+' [skycaiji-id="listXpath"]').parents('.skycaiji-block').eq(0).show();$($_o.consoleId+' [skycaiji-id="box-listXpath"]').removeClass('skycaiji-b-c-i');if(xpaths.listXpaths&&xpaths.listXpaths.length>1){var lxSlt=$($_o.consoleId+' [skycaiji-id="listXpaths"]');var sltOptions='';for(var i=xpaths.listXpaths.length-1;i>=0;i--){var lxOption=document.createElement('option');lxOption.value=xpaths.listXpaths[i];lxOption.text=xpaths.listXpaths[i];lxSlt.append(lxOption)}
|
||||
lxSlt.val(xpaths.listXpath);$($_o.consoleId+' [skycaiji-id="box-listXpath"]').addClass('skycaiji-b-c-i');lxSlt.show()}
|
||||
$_o.show_xpath_ele($($_o.consoleId+' [skycaiji-id="show-listXpath"]'),xpaths.listXpath,$(this).data('skycaiji-click'))}else{$($_o.consoleId+' [skycaiji-id="listXpath"]').parents('.skycaiji-block').eq(0).hide()}
|
||||
return!1});$('*').bind('mouseenter',function(e){$(this).addClass('skycaiji_bg')});$('*').bind('mouseout',function(){$(this).removeClass('skycaiji_bg')});$('body').on('mouseover','#skycaiji_tips',function(){$(this).stop().fadeIn().css('box-shadow','2px 2px 2px #999')});$('body').on('mouseleave','#skycaiji_tips',function(){if($(this).find('.skycaiji-close').length<=0){$(this).fadeOut(3000)}});$('body').on('click','#skycaiji_tips .skycaiji-close',function(){$('#skycaiji_tips').hide()});$('body').on('click',$_o.consoleId+' .skycaiji-close',function(){$($_o.consoleId).hide()});$('body').on('click',$_o.consoleId+' [skycaiji-id="show-xpath"]',function(){$_o.show_xpath_ele(this,$($_o.consoleId+' [skycaiji-id="xpath"]').val())});$('body').on('click',$_o.consoleId+' [skycaiji-id="show-listXpath"]',function(){$_o.show_xpath_ele(this,$($_o.consoleId+' [skycaiji-id="listXpath"]').val())});$('body').on('click',$_o.consoleId+' [skycaiji-id="xpath"]',function(){$_o.copy_val(this)});$('body').on('click',$_o.consoleId+' [skycaiji-id="listXpath"]',function(){$_o.copy_val(this)});$('body').on('change',$_o.consoleId+' [skycaiji-id="listXpaths"]',function(){var val=$(this).val();if(val){$($_o.consoleId+' [skycaiji-id="listXpath"]').val(val)}});$('body').on('click',$_o.consoleId+' [skycaiji-id="obj-clear"]',function(){$_o.clear_skycaiji_style()});$('body').on('click',$_o.consoleId+' [skycaiji-id="obj-parent"]',function(){var xpath=$($_o.consoleId+' [skycaiji-id="xpath"]').val();var csspath=$_o.xpath2csspath(xpath);if($(csspath).parent().length>0){$(csspath).parent().eq(0).click()}else{$_o.tips('没有了',1500)}});$('body').on('click',$_o.consoleId+' [skycaiji-id="obj-child"]',function(){var xpath=$($_o.consoleId+' [skycaiji-id="xpath"]').val();var csspath=$_o.xpath2csspath(xpath);if($(csspath).children().length>0){$(csspath).children().eq(0).click()}else{$_o.tips('没有了',1500)}});$('body').on('click',$_o.consoleId+' [skycaiji-id="obj-prop"]',function(){var xpath=$($_o.consoleId+' [skycaiji-id="xpath"]').val();var csspath=$_o.xpath2csspath(xpath);var props=['outerHtml','innerHtml','text','value','id','class','name','href','src','title','alt'];var propVals={};if($(csspath).length>0){for(var i in props){var prop=props[i];var propVal='';if(prop=='innerHtml'||prop=='outerHtml'){if(prop=='innerHtml'){propVal=$(csspath).html()}else{propVal=$(csspath).prop('outerHTML')}
|
||||
propVal=propVal?propVal:'';var regClass=/(class\s*=\s*[\'\"][^\'\"]*?)\s*skycaiji[\w+\-]*/i;var mclass=null;while(mclass=propVal.match(regClass)){propVal=propVal.replace(regClass,mclass[1])}
|
||||
propVal=propVal.replace(/\s*class\s*=\s*[\'\"]\s*[\'\"]/ig,'')}else if(prop=='text'){propVal=$(csspath).text()}else if(prop=='value'){propVal=$(csspath).val()}else if(prop=='class'){propVal=$(csspath).prop('class');propVal=propVal.replace(/\s*skycaiji[\w+\-]*/ig,'').replace(/(^\s*)|(\s*$)/g,'')}else if(prop=='src'||prop=='href'){propVal=$(csspath).attr(prop)}else{propVal=$(csspath).prop(prop)}
|
||||
'use strict';function SkycaijiCpatternBrowser(){this.consoleId='#skycaiji_console';this.bdNum=0;this.bdNumMax=11;this.htmlTxt='';this.htmlObj=null}
|
||||
SkycaijiCpatternBrowser.prototype={constructor:SkycaijiCpatternBrowser,init:function(configTips){var $_o=this;$_o.htmlTxt=$('#skycaiji_browser_html').val();$_o.htmlTxt=$_o.htmlTxt?$_o.htmlTxt:'';$_o.htmlTxt=$_o.htmlTxt.replace(/\>\;/g,'>').replace(/\<\;/g,'<').replace(/\&\;/g,'&');$_o.htmlObj=$($_o.htmlTxt);$('#skycaiji_wrapper').attr('skycaiji-console',$($_o.consoleId).prop('outerHTML'));$('#skycaiji_tpl').remove();$('body').append('<textarea id="skycaiji_tpl" style="display:none;"></textarea>');$('#skycaiji_tpl').val($('#skycaiji_wrapper').prop("outerHTML"));$('#skycaiji_wrapper').remove();$('*').removeAttr('onclick').unbind('click').bind('click',function(){var tagName=$(this).prop('tagName').toLowerCase();if(tagName=='body'||tagName=='html'){return!1}
|
||||
$(this).data('skycaiji-click',$(this).data('skycaiji-click')?0:1);var xpaths={};var listXpaths={};var getXpaths=$_o.get_xpaths(this,!1,!1);var getXpaths1=$_o.get_xpaths(this,!1,!0);var getXpaths2=$_o.get_xpaths(this,!0,!0);var xpathTips=['[精确] ','[正常] ','[模糊] '];if(getXpaths.xpath){xpaths[getXpaths.xpath]=xpathTips[0]+getXpaths.xpath}
|
||||
if(getXpaths1.xpath){xpaths[getXpaths1.xpath]=xpathTips[1]+getXpaths1.xpath}
|
||||
if(getXpaths2.xpath){xpaths[getXpaths2.xpath]=xpathTips[2]+getXpaths2.xpath}
|
||||
if(!getXpaths.listXpath){getXpaths.listXpath=getXpaths1.listXpath;if(!getXpaths.listXpath){getXpaths.listXpath=getXpaths2.listXpath}}
|
||||
var getListXpaths=[getXpaths.listXpaths,getXpaths1.listXpaths,getXpaths2.listXpaths];for(var i in getListXpaths){if(getListXpaths[i]&&getListXpaths[i].length>0){for(var ii in getListXpaths[i]){if(getListXpaths[i][ii]){listXpaths[getListXpaths[i][ii]]=xpathTips[i]+getListXpaths[i][ii]}}}}
|
||||
$($_o.consoleId).remove();$('#skycaiji_wrapper').append($('#skycaiji_wrapper').attr('skycaiji-console'));$($_o.consoleId).show();if(getXpaths.xpath){$($_o.consoleId).find('[skycaiji-id="xpath"]').val(getXpaths.xpath);$($_o.consoleId+' [skycaiji-id="xpath"]').parents('.skycaiji-block').eq(0).show();$($_o.consoleId+' [skycaiji-id="box-xpath"]').removeClass('skycaiji-b-c-i');var sltXpaths=$($_o.consoleId+' [skycaiji-id="xpaths"]');var showSlt=!1;for(var i in xpaths){var sltOpt=document.createElement('option');sltOpt.value=i;sltOpt.text=xpaths[i];sltXpaths.append(sltOpt);if(i!=getXpaths.xpath){showSlt=!0}}
|
||||
if(showSlt){sltXpaths.val(getXpaths.xpath);$($_o.consoleId+' [skycaiji-id="box-xpath"]').addClass('skycaiji-b-c-i');sltXpaths.show()}else{sltXpaths.hide()}
|
||||
if(!xpaths.listXpath){$_o.show_xpath_ele('show-xpath',getXpaths.xpath,this)}}
|
||||
if(getXpaths.listXpath){$($_o.consoleId+' [skycaiji-id="listXpath"]').val(getXpaths.listXpath);$($_o.consoleId+' [skycaiji-id="listXpath"]').parents('.skycaiji-block').eq(0).show();$($_o.consoleId+' [skycaiji-id="box-listXpath"]').removeClass('skycaiji-b-c-i');var sltLxs=$($_o.consoleId+' [skycaiji-id="listXpaths"]');var showSlt=!1;for(var i in listXpaths){var sltOpt=document.createElement('option');sltOpt.value=i;sltOpt.text=listXpaths[i];sltLxs.append(sltOpt);if(i!=getXpaths.listXpath){showSlt=!0}}
|
||||
if(showSlt){sltLxs.val(getXpaths.listXpath);$($_o.consoleId+' [skycaiji-id="box-listXpath"]').addClass('skycaiji-b-c-i');sltLxs.show()}else{sltLxs.hide()}
|
||||
$_o.show_xpath_ele('show-listXpath',getXpaths.listXpath,this)}else{$($_o.consoleId+' [skycaiji-id="listXpath"]').parents('.skycaiji-block').eq(0).hide()}
|
||||
return!1});$('*').bind('mouseenter',function(e){$(this).addClass('skycaiji_bg')});$('*').bind('mouseout',function(){$(this).removeClass('skycaiji_bg')});$('body').on('mouseover','#skycaiji_tips',function(){$(this).stop().fadeIn().css('box-shadow','2px 2px 2px #999')});$('body').on('mouseleave','#skycaiji_tips',function(){if($(this).find('.skycaiji-close').length<=0){$(this).fadeOut(3000)}});$('body').on('click','#skycaiji_tips .skycaiji-close',function(){$('#skycaiji_tips').hide()});$('body').on('click',$_o.consoleId+' .skycaiji-close',function(){$($_o.consoleId).hide()});$('body').on('click',$_o.consoleId+' [skycaiji-id="show-xpath"]',function(){$_o.show_xpath_ele('show-xpath',$($_o.consoleId+' [skycaiji-id="xpath"]').val())});$('body').on('click',$_o.consoleId+' [skycaiji-id="show-listXpath"]',function(){$_o.show_xpath_ele('show-listXpath',$($_o.consoleId+' [skycaiji-id="listXpath"]').val())});$('body').on('click',$_o.consoleId+' [skycaiji-id="xpath"]',function(){$_o.copy_val(this)});$('body').on('change',$_o.consoleId+' [skycaiji-id="xpaths"]',function(){var val=$(this).val();if(val){$($_o.consoleId+' [skycaiji-id="xpath"]').val(val);$_o.show_xpath_ele('show-xpath',$($_o.consoleId+' [skycaiji-id="xpath"]').val(),null,1)}});$('body').on('click',$_o.consoleId+' [skycaiji-id="listXpath"]',function(){$_o.copy_val(this)});$('body').on('change',$_o.consoleId+' [skycaiji-id="listXpaths"]',function(){var val=$(this).val();if(val){$($_o.consoleId+' [skycaiji-id="listXpath"]').val(val);$_o.show_xpath_ele('show-listXpath',$($_o.consoleId+' [skycaiji-id="listXpath"]').val(),null,1)}});$('body').on('click',$_o.consoleId+' [skycaiji-id="obj-clear"]',function(){$_o.clear_skycaiji_style();$_o.xpath_btn_status('show-xpath',1);$_o.xpath_btn_status('show-listXpath',1)});$('body').on('click',$_o.consoleId+' [skycaiji-id="obj-parent"]',function(){var xpath=$($_o.consoleId+' [skycaiji-id="xpath"]').val();var csspath=$_o.xpath2csspath(xpath);if($(csspath).parent().length>0){$(csspath).parent().eq(0).click()}else{$_o.tips('没有了',1500)}});$('body').on('click',$_o.consoleId+' [skycaiji-id="obj-child"]',function(){var xpath=$($_o.consoleId+' [skycaiji-id="xpath"]').val();var csspath=$_o.xpath2csspath(xpath);if($(csspath).children().length>0){$(csspath).children().eq(0).click()}else{$_o.tips('没有了',1500)}});$('body').on('click',$_o.consoleId+' [skycaiji-id="obj-prop"]',function(){var xpath=$($_o.consoleId+' [skycaiji-id="xpath"]').val();var csspath=$_o.xpath2csspath(xpath);var props=['outerHtml','innerHtml','text','value'];var propVals={};var curObj=$(csspath).attr('skycaiji-no');curObj=curObj?$_o.htmlObj.find('[skycaiji-no="'+curObj+'"]'):null;if(curObj&&curObj.length>0){for(var i in props){var prop=props[i];var propVal='';if(prop=='innerHtml'||prop=='outerHtml'){if(prop=='innerHtml'){propVal=curObj.html()}else{propVal=curObj.prop('outerHTML')}
|
||||
propVal=propVal?propVal:'';propVal=propVal.replace(/ skycaiji-no=\"[^\"]*\"/ig,'')}else if(prop=='text'){propVal=curObj.text()}else if(prop=='value'){propVal=curObj.val()}else{propVal=curObj.prop(prop)}
|
||||
propVal=propVal?propVal:'';propVals[prop]=propVal}
|
||||
$.each($(csspath)[0].attributes,function(){if(typeof(propVals[this.name])=='undefined'||propVals[this.name]==null){propVals[this.name]=this.value?this.value:''}});if(propVals){var html='';for(var i in propVals){if(propVals[i]){html+='<tr><td width="100px;">'+i+'</td><td><textarea rowspan="2">'+propVals[i]+'</textarea></td></tr>'}}
|
||||
var attrVals=$_o.ele_attrs(curObj);for(var i in attrVals){propVals[i]=attrVals[i]}
|
||||
if(propVals){var html='';for(var i in propVals){if(propVals[i]){html+='<tr><td width="100px;">'+i+'</td><td><textarea rowspan="2">'+$_o.htmlspecialchars(propVals[i])+'</textarea></td></tr>'}}
|
||||
if(html){html='<table>'+html+'</table>'}
|
||||
if(html){$_o.tips(html,3000,'skycaiji_tips_html',1)}else{$_o.tips('没有属性',1500)}}}});$('body').append($('#skycaiji_tpl').val());$('#skycaiji_wrapper').show();var html='所见即所得,已过滤所有脚本!<br>';if(configTips&&typeof(configTips)=='object'){var htmlUnset='';if(configTips.unset&&typeof(configTips.unset)=='object'){for(var i in configTips.unset){htmlUnset+='<li>'+configTips.unset[i]+'</li>'}
|
||||
htmlUnset=htmlUnset?('建议设置:<ul>'+htmlUnset+'</ul>'):''}
|
||||
var htmlSetted='';if(configTips.setted&&typeof(configTips.setted)=='object'){for(var i in configTips.setted){htmlSetted+='<li>'+configTips.setted[i]+'</li>'}
|
||||
htmlSetted=htmlSetted?('已设置:<ul>'+htmlSetted+'</ul>'):''}
|
||||
html=html+htmlUnset+htmlSetted}
|
||||
$_o.tips(html,3000,'skycaiji_tips_list')},get_xpaths:function(element,noId){var $_o=this;var listXpath='';var maxEleNum=1;var xpath=$_o.ele_xpath(element,noId);xpath=xpath.split('/');var listXpaths=[];for(var i=(xpath.length-1);i>=0;i--){if(!xpath[i]){continue}
|
||||
var parentXpath=xpath.slice(0,i+1);parentXpath[i]=parentXpath[i].replace(/\[\d+\]/,'');parentXpath=parentXpath.join('/');var subXpath=xpath.slice(i+1);subXpath=subXpath.join('/');var parentCsspath=$_o.xpath2csspath(parentXpath);var subCsspath=$_o.xpath2csspath(subXpath);var eleNum=0;if(subCsspath){var curIndex=-1;$(parentCsspath).each(function(){curIndex++;var curCsspath=parentCsspath+':eq('+curIndex+')>'+subCsspath;eleNum+=parseInt($(curCsspath).length)})}else{eleNum+=parseInt($(parentCsspath).length)}
|
||||
$_o.tips(html,3000,'skycaiji_tips_list')},get_xpaths:function(element,noId,noClass){var $_o=this;var listXpath='';var maxEleNum=1;var xpath=$_o.ele_xpath(element,noId,noClass);xpath=xpath.split('/');var listXpaths=[];for(var i=(xpath.length-1);i>=0;i--){if(!xpath[i]){continue}
|
||||
var parentXpath=xpath.slice(0,i+1);parentXpath[i]=parentXpath[i].replace(/\[\d+\]/,'');parentXpath=parentXpath.join('/');var subXpath=xpath.slice(i+1);subXpath=subXpath.join('/');var parentCsspath=$_o.xpath2csspath(parentXpath);var subCsspath=$_o.xpath2csspath(subXpath);var eleNum=0;if(subCsspath){var curIndex=-1;$(parentCsspath).each(function(){curIndex++;var curCsspath=parentCsspath+':eq('+curIndex+')>'+subCsspath;eleNum+=$_o.toInt($(curCsspath).length)})}else{eleNum+=$_o.toInt($(parentCsspath).length)}
|
||||
if(eleNum>maxEleNum){maxEleNum=eleNum;listXpath=parentXpath+(subXpath?('/'+subXpath):'');listXpaths.push(listXpath)}}
|
||||
return{'xpath':xpath.join('/'),'listXpath':listXpath,'listXpaths':listXpaths}},ele_xpath:function(ele,noId){if(!noId&&$(ele).prop('id')){return'//*[@id="'+$(ele).prop('id')+'"]'}
|
||||
return{'xpath':xpath.join('/'),'listXpath':listXpath,'listXpaths':listXpaths}},ele_xpath:function(ele,noId,noClass){var $_o=this;if(!noId&&$(ele).prop('id')){return'//*[@id="'+$(ele).prop('id')+'"]'}
|
||||
var tagName=$(ele).prop('tagName').toLowerCase();if(tagName=='body'){return'/html/body'}
|
||||
if(!tagName){return''}
|
||||
var nodes=$(ele).parent().children(tagName);var index=$(nodes).index(ele);index=parseInt(index)+1;return this.ele_xpath($(ele).parent(),noId)+'/'+tagName+'['+index+']'},xpath2csspath:function(xpath){if(!xpath){return''}
|
||||
xpath=xpath.replace(/\/\//g,' ');xpath=xpath.replace(/\//g,'>');xpath=xpath.replace(/\[([^@].*?)\]/ig,function(match,index){index=parseInt(index)-1;return':eq('+index+')'});xpath=xpath.replace(/\@/g,'');xpath=xpath.replace(/^\s+|\s+$/gm,'');return xpath},show_xpath_ele:function(obj,xpath,isShow){if(!xpath){return}
|
||||
var eleAttrs=$_o.ele_attrs(ele);var eleName='';var eleClass='';if(!noId){eleName=eleAttrs.name?eleAttrs.name:''}
|
||||
if(!noClass){eleClass=eleAttrs['class']?eleAttrs['class']:''}
|
||||
var index=0;var nodes=$(ele).parent().children(tagName+(eleClass?$_o.class_attr2css(eleClass):'')+(eleName?('[name="'+eleName+'"]'):''));if(nodes.length>1){index=$(nodes).index(ele);index=$_o.toInt(index)+1}
|
||||
index=index>0?('['+index+']'):'';eleClass=eleClass?('[@class="'+eleClass+'"]'):'';eleName=eleName?('[@name="'+eleName+'"]'):'';return this.ele_xpath($(ele).parent(),noId,noClass)+'/'+tagName+eleClass+eleName+index},ele_attrs:function(ele){var $_o=this;var attrVals={};if(ele){var scjNo=$(ele).attr('skycaiji-no');if(scjNo){var regTag=new RegExp('(<\\w+[^<>]*?) skycaiji-no="'+scjNo+'"([^<>]*>)');var tagHtml=regTag.exec($_o.htmlTxt);tagHtml=tagHtml?(tagHtml[1]+tagHtml[2]):'';if(tagHtml){$.each($(tagHtml)[0].attributes,function(){if(typeof(attrVals[this.name])=='undefined'||attrVals[this.name]==null){attrVals[this.name]=this.value?this.value:''}})}}}
|
||||
return attrVals},xpath2csspath:function(xpath){var $_o=this;if(!xpath){return''}
|
||||
xpath=xpath.replace(/\/\//g,' ');xpath=xpath.replace(/\//g,'>');xpath=xpath.replace(/\[([^@].*?)\]/ig,function(match,match1){match1=$_o.toInt(match1)-1;return':eq('+match1+')'});xpath=xpath.replace(/\@/g,'');xpath=xpath.replace(/^\s+|\s+$/gm,'');xpath=xpath.replace(/\[\s*class\s*\=\s*[\'\"]([^\'\"]*)[\'\"]\s*\]/ig,function(match,match1){return $_o.class_attr2css(match1)});return xpath},class_attr2css:function(classAttr){var cssQuery='';if(classAttr){classAttr=classAttr.replace('/[\s\r\n]+/g',' ').split(' ');for(var i in classAttr){if(classAttr[i]){cssQuery+='.'+classAttr[i]}}}
|
||||
return cssQuery},show_xpath_ele:function(btnId,xpath,clickObj,isShow){if(!xpath){return}
|
||||
var $_o=this;xpath=xpath.split('/');var reg=/^((?!(html|body))\w)+$/;var ix=-1;for(var i=(xpath.length-1);i>=0;i--){if(reg.test(xpath[i])){ix=i;break}}
|
||||
if(typeof isShow=='undefined'||isShow==null){isShow=$(obj).attr('data-val')==1?true:!1}else{isShow=parseInt(isShow);isShow=isShow==1?true:!1}
|
||||
if(!isShow){if(clickObj){isShow=$(clickObj).data('skycaiji-click')}}
|
||||
if(typeof isShow=='undefined'||isShow==null){isShow=$($_o.consoleId+' [skycaiji-id="'+btnId+'"]').attr('data-val')==1?true:!1}else{isShow=$_o.toInt(isShow);isShow=isShow==1?true:!1}
|
||||
if(isShow){if($_o.bdNum>=$_o.bdNumMax){$_o.bdNum=0}
|
||||
$_o.bdNum+=1}
|
||||
var bdAll='skycaiji_bd';for(var i=1;i<=$_o.bdNumMax;i++){bdAll+=' skycaiji_bd'+i}
|
||||
if(ix>-1){var parentXpath=xpath.slice(0,ix+1);parentXpath=parentXpath.join('/');var subXpath=xpath.slice(ix+1);subXpath=subXpath.join('/');var parentCsspath=$_o.xpath2csspath(parentXpath);var subCsspath=$_o.xpath2csspath(subXpath);if(subCsspath){var curIndex=-1;$(parentCsspath).each(function(){curIndex++;var curCsspath=parentCsspath+':eq('+curIndex+')>'+subCsspath;$(curCsspath).removeClass(bdAll);if(isShow){$(curCsspath).addClass('skycaiji_bd skycaiji_bd'+$_o.bdNum)}})}else{$(parentCsspath).removeClass(bdAll);if(isShow){$(parentCsspath).addClass('skycaiji_bd skycaiji_bd'+$_o.bdNum)}}}else{var csspath=$_o.xpath2csspath(xpath.join('/'));$(csspath).removeClass(bdAll);if(isShow){$(csspath).addClass('skycaiji_bd skycaiji_bd'+$_o.bdNum)}}
|
||||
$(obj).attr('data-val',isShow?0:1);$(obj).text(isShow?'取消':'显示')},tips:function(msg,time,addClass,close){time=parseInt(time);time=time>0?time:3000;if(addClass){$('#skycaiji_tips').addClass(addClass)}else{$('#skycaiji_tips').prop('class','')}
|
||||
$_o.xpath_btn_status(btnId,isShow?0:1)},xpath_btn_status:function(btnId,status){$(this.consoleId+' [skycaiji-id="'+btnId+'"]').attr('data-val',status?1:0).text(status?'显示':'取消')},tips:function(msg,time,addClass,close){var $_o=this;time=$_o.toInt(time);time=time>0?time:3000;if(addClass){$('#skycaiji_tips').addClass(addClass)}else{$('#skycaiji_tips').prop('class','')}
|
||||
if(close){msg='<div class="skycaiji-close">关闭</div>'+msg}
|
||||
$('#skycaiji_tips').stop().css('opacity','1.0').html(msg).show();if(!close){$('#skycaiji_tips').fadeOut(time)}},clear_skycaiji_style:function(){var $_o=this;$('*').removeClass('skycaiji_bg');$('*').removeClass('skycaiji_bd');for(var i=1;i<=$_o.bdNumMax;i++){$('*').removeClass('skycaiji_bd'+i)}},copy_val:function(obj){var $_o=this;var val=$(obj).val();if(val){$(obj).select();window.document.execCommand('Copy')}
|
||||
$_o.tips('复制成功!',1500)},htmlspecialchars:function(str){if(str){str=str.replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>').replace(/"/g,'"').replace(/'/g,''')}
|
||||
return str}}
|
||||
$_o.tips('复制成功!',1500)},htmlspecialchars:function(str){if(str&&typeof(str)=='string'){str=str.replace(/\&/g,'&').replace(/\</g,'<').replace(/\>/g,'>').replace(/\"/g,'"').replace(/\'/g,''')}
|
||||
return str},toInt:function(val){val=val?val:0;val=parseInt(val);if(isNaN(val)){val=0}
|
||||
return val}}
|
||||
var skycaijiCB=new SkycaijiCpatternBrowser()
|
|
@ -8,8 +8,8 @@
|
|||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
'use strict';function CpTestSourceUrls(collId,maxNum,sourceIsUrl,hasLevels){this.coll_id=collId;this.max_num=maxNum;this.source_is_url=sourceIsUrl;this.has_levels=hasLevels;this.box_id='#win_test_source_urls';this.url_ajax_requests=new Array()}
|
||||
CpTestSourceUrls.prototype={constructor:CpTestSourceUrls,init:function(){var $_o=this;$('#myModal').on('hide.bs.modal',function(e){if($_o&&$_o.url_ajax_requests){for(var i in $_o.url_ajax_requests){$_o.url_ajax_requests[i].abort()}}});$($_o.box_id).on('click','.set-test-num .set-num-btn',function(){var testNum=$($_o.box_id+' .set-test-num').find('.set-num').val();ajaxOpen({type:'get',dataType:'json',url:ulink('cpattern_test/level_num'),data:{num:testNum},async:!0,success:function(data){toastr.success(data.msg)}})});$($_o.box_id).on('click','.cont_ceshi',function(){var curUrl=$(this).attr('data-url');var test_url=ulink('cpattern_test/test_url?coll_id=_collid_&test_url=_url_',{'_collid_':$_o.coll_id,'_url_':curUrl});var urls={};$(this).parents('.source_url').each(function(){var surl=$(this).attr('data-url');if(surl){if($(this).attr('data-level')){urls['level_'+$(this).attr('data-level')]=surl}else{urls.source_url=surl}}});if(urls){for(var i in urls){test_url+='&'+i+'='+encodeURIComponent(urls[i])}}
|
||||
window.open(test_url,'_blank')});$($_o.box_id).on('click','.cont_element',function(){var urls={};$(this).parents('.source_url').each(function(){var surl=$(this).attr('data-url');if(surl){if($(this).attr('data-level')){urls['level_'+$(this).attr('data-level')]=surl}else{urls.source_url=surl}}});if((/\beasymode\s*\=/i).test(window.self.location.href)&&window.top){cpEasyBrowser($(this).attr('data-url'),'url',urls)}else{var testUrl=$(this).attr('data-url');var browserUrl=cpBrowserUrl($_o.coll_id,'url',testUrl,urls);window.open(browserUrl,'_blank')}});$($_o.box_id).on('click','.cont_urls_num a',function(){var status=$(this).attr('status');if(status==1){$(this).html('[展开]');$(this).attr('status',0);$(this).parents('.cont_urls_num').eq(0).siblings('.cont_urls_list').hide()}else{$(this).html('[收起]');$(this).attr('status',1);$(this).parents('.cont_urls_num').eq(0).siblings('.cont_urls_list').show()}});$($_o.box_id+' .source_url').each(function(index){if(!$_o.source_is_url){var source_url=$(this).attr('data-url');if($_o.has_levels){$($_o.box_id+' .set-test-num').show().find('.set-num').val($_o.max_num);if(index<$_o.max_num){$_o.get_cont_urls(source_url,$(this),1)}}else{$_o.get_cont_urls(source_url,$(this),0)}}})},get_cont_urls:function(source_url,curObj,level,parentUrl,parentLevel){parentUrl=parentUrl?parentUrl:'';parentLevel=parentLevel?parentLevel:'';var $_o=this;if(source_url){curObj.children('.cont_urls_list').html('<div class="loading-sm"></div>').show();var url=ulink('cpattern_test/cont_urls?coll_id=_collid_',{'_collid_':$_o.coll_id});var url_ajax_request=ajaxOpen({type:'post',url:url,data:{source_url:source_url,level:level,parent_url:parentUrl,parent_level:parentLevel,},dataType:'json',async:!0,success:function(data){if(data.code==1){data=data.data?data.data:{};var urls=data.urls;var urlMsgLinks=data.urlMsgLinks;if(!isObject(urlMsgLinks)){urlMsgLinks={}}
|
||||
CpTestSourceUrls.prototype={constructor:CpTestSourceUrls,init:function(){var $_o=this;$('#myModal').on('hide.bs.modal',function(e){if($_o&&$_o.url_ajax_requests){for(var i in $_o.url_ajax_requests){$_o.url_ajax_requests[i].abort()}}});$($_o.box_id).on('click','.set-test-num .set-num-btn',function(){var testNum=$($_o.box_id+' .set-test-num').find('.set-num').val();ajaxOpen({type:'get',dataType:'json',url:ulink('cpattern_test/level_num'),data:{num:testNum},async:!0,success:function(data){toastr.success(data.msg)}})});$($_o.box_id).on('click','.cont_ceshi',function(){var curUrl=$(this).attr('data-url');var test_url=ulink('cpattern_test/test_url?coll_id=_collid_&test_url=_url_',{'_collid_':$_o.coll_id,'_url_':curUrl});var urls={};$(this).parents('.source_url').each(function(){var surl=$(this).attr('data-url');if(surl){if($(this).attr('data-level')){urls['level'+$(this).attr('data-level')+'_url']=surl}else{urls.source_url=surl}}});if(urls){for(var i in urls){test_url+='&'+i+'='+encodeURIComponent(urls[i])}}
|
||||
window.open(test_url,'_blank')});$($_o.box_id).on('click','.cont_element',function(){var urls={};$(this).parents('.source_url').each(function(){var surl=$(this).attr('data-url');if(surl){if($(this).attr('data-level')){urls['level'+$(this).attr('data-level')+'_url']=surl}else{urls.source_url=surl}}});if((/\beasymode\s*\=/i).test(window.self.location.href)&&window.top){cpEasyBrowser($(this).attr('data-url'),'url',urls)}else{var testUrl=$(this).attr('data-url');var browserUrl=cpBrowserUrl($_o.coll_id,'url',testUrl,urls);window.open(browserUrl,'_blank')}});$($_o.box_id).on('click','.cont_urls_num a',function(){var status=$(this).attr('status');if(status==1){$(this).html('[展开]');$(this).attr('status',0);$(this).parents('.cont_urls_num').eq(0).siblings('.cont_urls_list').hide()}else{$(this).html('[收起]');$(this).attr('status',1);$(this).parents('.cont_urls_num').eq(0).siblings('.cont_urls_list').show()}});$($_o.box_id+' .source_url').each(function(index){if(!$_o.source_is_url){var source_url=$(this).attr('data-url');if($_o.has_levels){$($_o.box_id+' .set-test-num').show().find('.set-num').val($_o.max_num);if(index<$_o.max_num){$_o.get_cont_urls(source_url,$(this),1)}}else{$_o.get_cont_urls(source_url,$(this),0)}}})},get_cont_urls:function(source_url,curObj,level,parentUrl,parentLevel){parentUrl=parentUrl?parentUrl:'';parentLevel=parentLevel?parentLevel:'';var $_o=this;if(source_url){curObj.children('.cont_urls_list').html('<div class="loading-sm"></div>').show();var url=ulink('cpattern_test/cont_urls?coll_id=_collid_',{'_collid_':$_o.coll_id});var url_ajax_request=ajaxOpen({type:'post',url:url,data:{source_url:source_url,level:level,parent_url:parentUrl,parent_level:parentLevel,},dataType:'json',async:!0,success:function(data){if(data.code==1){data=data.data?data.data:{};var urls=data.urls;var urlMsgLinks=data.urlMsgLinks;if(!isObject(urlMsgLinks)){urlMsgLinks={}}
|
||||
var list='<ul style="list-style-type:'+(level>0?'decimal':'square')+';padding-left:15px;white-space:normal;overflow-x:scroll;">';if(level>0){for(var i in urls){var urlMsgLink=urlMsgLinks[urls[i]];urlMsgLink=urlMsgLink?urlMsgLink:'';urls[i]=htmlspecialchars(urls[i]);if(i<$_o.max_num){list+='<li class="source_url" data-url="'+urls[i]+'" data-level="'+level+'"><p><b>抓取第'+level+'级页面 “'+data.levelName+'”:</b>'+data.levelOpened+urls[i]+urlMsgLink+'</p><p class="cont_urls_num"></p><div class="cont_urls_list"></div></li>'}}
|
||||
list+='</ul>';curObj.children('.cont_urls_list').html(list).show();curObj.children('.cont_urls_num').html('获取到'+urls.length+'条网址'+(urls.length>$_o.max_num?'(只测试前'+$_o.max_num+'条)':'')+' <a href="javascript:;" status="1">[收起]</a>');curObj.children('.cont_urls_list').find('.source_url').each(function(){var obj=$(this);$_o.get_cont_urls(obj.attr('data-url'),obj,data.nextLevel,data.sourceUrl,data.level)})}else{for(var i in urls){var urlMsgLink=urlMsgLinks[urls[i]];urlMsgLink=urlMsgLink?urlMsgLink:'';urls[i]=htmlspecialchars(urls[i]);list+='<li>[<a href="javascript:;" class="cont_ceshi" data-url="'+urls[i]+'">测试</a>] '+'[<a href="javascript:;" class="cont_element" data-url="'+urls[i]+'">分析</a>] '+data.urlOpened+urls[i]+urlMsgLink+'</li>'}
|
||||
list+='</ul>';curObj.children('.cont_urls_list').html(list).hide();curObj.children('.cont_urls_num').html('获取到'+urls.length+'条网址 <a href="javascript:;" status="0">[展开]</a>')}}else{curObj.children('.cont_urls_list').html('<span style="color:red">'+data.msg+'</span>').show()}}});$_o.url_ajax_requests.push(url_ajax_request)}}}
|
||||
|
@ -21,25 +21,27 @@ var pageOpenedObj=$('#win_input_urls').find('#input_url_page_opened');if(pageOpe
|
|||
execVarFuncs(func)}})},init:function(){var $_o=this;$($_o.box_id+' .dropdown-menu a[data-test]').bind('click',function(){$_o.abort_test();var btnObj=$(this).parents('.dropdown-menu').eq(0).siblings('button.dropdown-toggle').eq(0);var testName=$(this).attr('data-test');btnObj.attr('data-test',testName);btnObj.find('.test-tips').text($(this).attr('data-title'));if(testName=='get_html'||testName=='get_browser'||testName=='get_signs'||testName=='get_pagination'){$($_o.box_id+' [name="test_url"]').attr('placeholder','输入网址');$($_o.box_id+' .test-page-sources').show()}else{$($_o.box_id+' [name="test_url"]').attr('placeholder','输入内容页网址');$($_o.box_id+' .test-page-sources').hide()}
|
||||
$($_o.box_id+' .field-vals').html('');$_o.test=testName;if(testName=='get_signs'){$('#win_test_signs').show()}else{$('#win_test_signs').hide()}
|
||||
if(testName=='get_pagination'){$('#win_test_pagination').show()}else{$('#win_test_pagination').hide()}
|
||||
$_o.load_input_url()});$($_o.box_id+' [name="page_source"]').bind('change',function(){$_o.abort_test();$_o.load_input_url()});$($_o.box_id).off('click','[data-test-code]').on('click','[data-test-code]',function(){var objId='#'+$(this).attr('data-test-code');visualizeData('<pre>'+htmlspecialchars($(objId).val())+'</pre>')});$($_o.box_id).off('click','[data-test-visualize]').on('click','[data-test-visualize]',function(){var objId='#'+$(this).attr('data-test-visualize');visualizeData($(objId).val())});$($_o.box_id+' button.test-sub').bind('click',function(){$_o.abort_test();var testOp=$($_o.box_id+' button.dropdown-toggle').attr('data-test');testOp=testOp?testOp:'get_fields';$_o.test_async=testOp=='get_browser'?false:!0;$_o.load_input_url(function(){var test_url=$($_o.box_id+' input[name="test_url"]').val();var page_source=$($_o.box_id+' [name="page_source"]').val();if(!test_url){toastr.error('请输入网址')}else{$($_o.box_id+' .field-vals').html('<div class="loading"></div>');var url=ulink('cpattern_test/_op_?coll_id=_collid_&page_source=_source_&test_url=_url_',{'_op_':testOp,'_source_':page_source,'_collid_':$_o.coll_id,'_url_':test_url});$('#win_input_urls').find('[name]').each(function(){url+='&'+$(this).attr('name')+'='+encodeURIComponent($(this).val())});if(testOp=='get_html'){$_o.ajax({type:'get',url:url,dataType:'html',success:function(data){if(dataIsJson(data)){var json=eval('('+data+')');if(json.msg){$($_o.box_id+' .field-vals').html(json.msg)}else{var html='<label>源码:</label><textarea class="form-control" rows="5">'+data+'</textarea><label style="margin-top:15px;">JSON解析:</label><div id="win_json_tree"></div>';$($_o.box_id+' .field-vals').html(html);var jsonTreeFunc=function(){window.tool_json_tree.treeId='#win_json_tree';window.tool_json_tree.load(data)};if(window.tool_json_tree){jsonTreeFunc()}else{$.getScript(window.site_config.pub+'/static/js/admin/tool_json_tree.js',jsonTreeFunc)}}}else{var eleId=generateUUID();data=data.replace(/\</g,'<').replace(/\>/g,'>');var html='<label>源码:</label> <a href="javascript:;" data-test-visualize="'+eleId+'">预览</a><span style="margin-left:5px;margin-right:5px;">/</span><a href="javascript:;" data-test-browser="1">分析网页</a><textarea id="'+eleId+'" class="form-control" rows="20">'+data+'</textarea>';$($_o.box_id+' .field-vals').html(html);$($_o.box_id).find('[data-test-browser]').bind('click',function(){var pageSource=$($_o.box_id+' [name="page_source"]').val();var testUrl=$($_o.box_id+' input[name="test_url"]').val();var inputedUrls={};$('#win_input_urls').find('[name]').each(function(){inputedUrls[$(this).attr('name')]=$(this).val()});var browserUrl=cpBrowserUrl($_o.coll_id,pageSource,testUrl,inputedUrls);window.open(browserUrl,'_blank')})}}})}else{if(testOp=='get_signs'){if($('#win_test_signs').find('[name="signs_cur_all"]').is(':checked')){url+='&signs_cur_all=1'}}else if(testOp=='get_pagination'){url+='&pagination_type='+$('#win_test_pagination').find('[name="pagination_type"]:checked').val()}
|
||||
$_o.ajax({type:'get',url:url,dataType:'json',async:$_o.test_async,success:function(data){if(data.code==1){var html='';if(testOp=='get_pagination'){var pnType=data.data.pagination_type;var pnUrls=data.data.urls;var pnUrlMsgLinks=data.data.pn_links;if(!isObject(pnUrlMsgLinks)){pnUrlMsgLinks={}}
|
||||
$_o.load_input_url()});$($_o.box_id+' [name="page_source"]').bind('change',function(){$_o.abort_test();$_o.load_input_url()});$($_o.box_id).off('click','[data-test-code]').on('click','[data-test-code]',function(){var objId='#'+$(this).attr('data-test-code');visualizeData('<pre>'+htmlspecialchars($(objId).val())+'</pre>')});$($_o.box_id).off('click','[data-test-visualize]').on('click','[data-test-visualize]',function(){var objId='#'+$(this).attr('data-test-visualize');visualizeData($(objId).val())});$($_o.box_id+' button.test-sub').bind('click',function(){$_o.abort_test();var testOp=$($_o.box_id+' button.dropdown-toggle').attr('data-test');testOp=testOp?testOp:'get_fields';$_o.test_async=testOp=='get_browser'?false:!0;$_o.load_input_url(function(){var test_url=$($_o.box_id+' input[name="test_url"]').val();var page_source=$($_o.box_id+' [name="page_source"]').val();if(!test_url){toastr.error('请输入网址')}else{$($_o.box_id+' .field-vals').html('<div class="loading"></div>');$($_o.box_id+' .echo-msg-box').hide();var url=ulink('cpattern_test/_op_?coll_id=_collid_&page_source=_source_&test_url=_url_',{'_op_':testOp,'_source_':page_source,'_collid_':$_o.coll_id,'_url_':test_url});$('#win_input_urls').find('[name]').each(function(){url+='&'+$(this).attr('name')+'='+encodeURIComponent($(this).val())});if(testOp=='get_html'){$_o.ajax({type:'get',url:url,dataType:'html',success:function(data){$($_o.box_id+' .field-vals').html('');data=data?data:'';if(dataIsJson(data)){var json=JSON.parse(data);$($_o.box_id+' .field-vals').html(json.msg?json.msg:'')}else{data=data.replace(' ','');if(dataIsJson(data)){var html='<label>源码:</label><textarea class="form-control" rows="5">'+htmlspecialchars(data)+'</textarea><label style="margin-top:15px;">JSON解析:</label><div id="win_json_tree"></div>';$($_o.box_id+' .field-vals').html(html);var jsonTreeFunc=function(){window.tool_json_tree.treeId='#win_json_tree';window.tool_json_tree.load(data)};if(window.tool_json_tree){jsonTreeFunc()}else{$.getScript(window.site_config.pub+'/static/js/admin/tool_json_tree.js',jsonTreeFunc)}}else{var eleId=generateUUID();data=htmlspecialchars(data);var html='<label>源码:</label> <a href="javascript:;" data-test-visualize="'+eleId+'">预览</a><span style="margin-left:5px;margin-right:5px;">/</span><a href="javascript:;" data-test-browser="1">分析网页</a><textarea id="'+eleId+'" class="form-control" rows="20">'+data+'</textarea>';$($_o.box_id+' .field-vals').html(html);$($_o.box_id).find('[data-test-browser]').bind('click',function(){var pageSource=$($_o.box_id+' [name="page_source"]').val();var testUrl=$($_o.box_id+' input[name="test_url"]').val();var inputedUrls={};$('#win_input_urls').find('[name]').each(function(){inputedUrls[$(this).attr('name')]=$(this).val()});var browserUrl=cpBrowserUrl($_o.coll_id,pageSource,testUrl,inputedUrls);window.open(browserUrl,'_blank')})}}}})}else{if(testOp=='get_signs'){if($('#win_test_signs').find('[name="signs_cur_all"]').is(':checked')){url+='&signs_cur_all=1'}}else if(testOp=='get_pagination'){url+='&pagination_type='+$('#win_test_pagination').find('[name="pagination_type"]:checked').val()}
|
||||
$_o.ajax({type:'get',url:url,dataType:'html',async:$_o.test_async,success:function(data){$($_o.box_id+' .field-vals').html('');data=data?data:'';if(data.indexOf('<!--[echo_msg]-->')>-1){var echoMsg='';data=data.replace(/<\!--\[echo_msg\]-->([\s\S]*?)<\!--\[\/echo_msg\]-->/ig,function(match,match1){echoMsg+=match1;return''});if(echoMsg){$($_o.box_id+' .echo-msg-box').show().find('.panel-body').html(echoMsg)}}
|
||||
if(dataIsJson(data)){data=JSON.parse(data)}else{data={}}
|
||||
if(data.code==1){var html='';if(testOp=='get_pagination'){var pnType=data.data.pagination_type;var pnUrls=data.data.urls;var pnUrlMsgLinks=data.data.pn_links;if(!isObject(pnUrlMsgLinks)){pnUrlMsgLinks={}}
|
||||
if(!pnType){html='<div class="page-header"><b>成功抓取到分页链接</b></div><ul>';for(var i in pnUrls){html+='<li>'+pnUrls[i]+(pnUrlMsgLinks[pnUrls[i]]?pnUrlMsgLinks[pnUrls[i]]:'')+'</li>'}
|
||||
html+='</ul>'}else if(pnType=='next'){html='<div class="page-header"><b>成功抓取到分页链接</b>';if(pnUrls.length>=10){html+='(测试时最多抓取到第10个分页)'}
|
||||
html+='</div><ul>';for(var i in pnUrls){var pnUrl=pnUrls[i];html+='<li>当前页:'+pnUrl.cur+(pnUrlMsgLinks[pnUrl.cur]?pnUrlMsgLinks[pnUrl.cur]:'')+'<br>抓取到的分页:'+pnUrl.next+(pnUrlMsgLinks[pnUrl.next]?pnUrlMsgLinks[pnUrl.next]:'')+'</li>'}
|
||||
html+='</ul><div class="page-header"><b>循环抓取到的分页链接</b></div><ul>';for(var i in pnUrls){var pnUrl=pnUrls[i];html+='<li>'+pnUrl.next+(pnUrlMsgLinks[pnUrl.next]?pnUrlMsgLinks[pnUrl.next]:'')+'</li>'}
|
||||
html+='</ul>'}}else if(testOp=='get_fields'){if(data.msg){toastr.success(data.msg)}
|
||||
var valList=data.data.val_list;valList=valList?valList:[];if(valList.length>1){var loopTable=data.data.loop_table;loopTable=isNull(loopTable)?{}:loopTable;html+='<div class="table-responsive"><table class="table table-bordered table-hover table-test-loop"><thead><tr><td></td>';var fields=valList[0];for(var f in fields){var loopTableTh=isNull(loopTable[f])?{}:loopTable[f];var divStyle=isNull(loopTableTh.width)?'':(' style="width:'+parseInt(loopTableTh.width)+'px;"');html+='<th data-val="'+f+'"><div'+divStyle+'>'+f+'</div></th>'}
|
||||
html+='</tr></thead><tbody>';var curNum=0;for(var i in valList){curNum++;var vals=valList[i];html+='<tr><td>'+curNum+'</td>';for(var f in vals){var val=vals[f]?vals[f]:'';if(val){if(dataIsJson(val)||dataIsHtml(val)){var eleId=generateUUID();html+='<td class="view-box"><input type="text" value="'+(val.replace(/"/g,'"'))+'" id="'+eleId+'" class="view-ipt" /> <a class="glyphicon glyphicon-eye-open view-btn" href="javascript:;" data-test-visualize="'+eleId+'"></a></td>'}else{html+='<td><input type="text" value="'+(val.replace(/"/g,'"'))+'" /></td>'}}else{html+='<td></td>'}}
|
||||
html+='</tr></thead><tbody>';var curNum=0;for(var i in valList){curNum++;var vals=valList[i];html+='<tr><td>'+curNum+'</td>';for(var f in vals){var val=vals[f]?vals[f]:'';if(val){if(dataIsJson(val)||dataIsHtml(val)){var eleId=generateUUID();html+='<td class="view-box"><input type="text" value="'+htmlspecialchars(val)+'" id="'+eleId+'" class="view-ipt" /> <a class="glyphicon glyphicon-eye-open view-btn" href="javascript:;" data-test-visualize="'+eleId+'"></a></td>'}else{html+='<td><input type="text" value="'+htmlspecialchars(val)+'" /></td>'}}else{html+='<td></td>'}}
|
||||
html+='</tr>'}
|
||||
html+='</tbody>'}else if(valList.length==1){var vals=valList[0];for(var f in vals){vals[f]=vals[f]?vals[f]:'';var browse='';var eleId=generateUUID();if(dataIsJson(vals[f])||dataIsHtml(vals[f])){browse='<a href="javascript:;" data-test-visualize="'+eleId+'">预览</a>'}
|
||||
vals[f]=vals[f].replace(/\</g,'<').replace(/\>/g,'>');html+='<div style="margin-bottom:10px;"><label>'+f+':</label>'+browse+'<textarea id="'+eleId+'" class="form-control" rows="4">'+vals[f]+'</textarea></div>'}}else{toastr.error('没有抓取到数据')}}else if(testOp=='get_relation_urls'){html='<div class="page-header"><b>关联页网址</b></div><ul>';for(var i in data.data){html+='<li>'+i+':'+data.data[i]+'</li>'}
|
||||
vals[f]=htmlspecialchars(vals[f]);html+='<div style="margin-bottom:10px;"><label>'+f+':</label>'+browse+'<textarea id="'+eleId+'" class="form-control" rows="4">'+vals[f]+'</textarea></div>'}}else{toastr.error('没有抓取到数据')}}else if(testOp=='get_relation_urls'){html='<div class="page-header"><b>关联页网址</b></div><ul>';for(var i in data.data){html+='<li>'+i+':'+data.data[i]+'</li>'}
|
||||
html+='</ul>'}else if(testOp=='get_signs'){var pageSource=$($_o.box_id+' [name="page_source"]').val();html+='<table class="table table-bordered table-hover"><thead><tr><th>页面</th><th>区域规则</th><th>网址规则</th><th>提取内容</th></tr></thead><tbody>';var dataArr=data.data;if(dataArr.cur){html+=$_o.get_signs_html(dataArr.cur)}
|
||||
if(isObject(dataArr.list)&&dataArr.list.length>0){html+='<tr><td colspan="4">'+data.msg+'</td></tr>';for(var i in dataArr.list){html+=$_o.get_signs_html(dataArr.list[i])}}
|
||||
html+='</tbody></table>'}else if(testOp=='get_browser'){html='正在执行操作...';if(data.url){window.location.href=data.url}}
|
||||
$($_o.box_id+' .field-vals').html(html);if(testOp=='get_fields'){$($_o.box_id).find('.table-test-loop thead th div').bind('mousedown',function(e){$(this).css('background','#f1f1f1');window.win_test_table_thead_mousedown={table_width:$($_o.box_id+' .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;$(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;if(e.type=='mouseup'){var width=$(this).width();var field=$(this).parents('th').eq(0).attr('data-val');if(width<100){width=100;$(this).width(width)}
|
||||
$_o.ajax({type:'get',url:ulink('cpattern_test/loop_table?coll_id=_collid_&field=_field_&width=_width_',{'_collid_':$_o.coll_id,'_field_':field,'_width_':width}),dataType:'json',success:function(data){}})}})})}}else{$($_o.box_id+' .field-vals').html(data.msg)}},error:function(jqXHR,textStatus,errorThrown){if(textStatus!='abort'){toastr.error('抓取失败');var ifm='<iframe id="ifm_test_error" style="width:100%;border:1px solid #ddd;"></iframe>';$($_o.box_id+' .field-vals').html(ifm);var iframeObj=document.getElementById('ifm_test_error');$(iframeObj).contents().find('body').html(jqXHR.responseText);var height=(iframeObj.Document?iframeObj.Document.body.scrollHeight:iframeObj.contentDocument.body.offsetHeight);$(iframeObj).attr('height',height+'px')}}})}}})});$($_o.box_id+' input[name="test_url"]').bind('keyup',function(event){if(event.keyCode=="13"){$($_o.box_id+' button.test-sub').trigger("click")}});$($_o.box_id+' .dropdown-menu a[data-test="'+$_o.test+'"]').trigger('click');if($_o.test=='get_fields'){if($($_o.box_id+' input[name="test_url"]').val().length>0){$($_o.box_id+' button.test-sub').trigger("click")}}
|
||||
if($_o.page_source){$($_o.box_id+' [name="page_source"]').val($_o.page_source).trigger('change')}},get_signs_html:function(match){var html='<tr><td>'+match.name+'</td>';var signKeys=['area','url','content'];for(var ski in signKeys){var signKey=signKeys[ski];html+='<td>';var signsHtml='';if(isObject(match[signKey])){for(var sign in match[signKey]){var eleId=generateUUID();var val=match[signKey][sign];val=val?val:'';sign=sign.replace(/^match/,'[内容')+']';if(dataIsJson(val)||dataIsHtml(val)){sign+=' <a href="javascript:;" data-test-visualize="'+eleId+'">预览</a> <a href="javascript:;" data-test-code="'+eleId+'">代码</a>'}
|
||||
val=val.replace(/\</g,'<').replace(/\>/g,'>');signsHtml+='<div style="margin-bottom:5px;"><div style="margin-bottom:5px;">'+sign+'</div><textarea id="'+eleId+'" class="form-control" rows="2" style="resize:none">'+val+'</textarea></div>'}}
|
||||
val=htmlspecialchars(val);signsHtml+='<div style="margin-bottom:5px;"><div style="margin-bottom:5px;">'+sign+'</div><textarea id="'+eleId+'" class="form-control" rows="2" style="resize:none">'+val+'</textarea></div>'}}
|
||||
if(!signsHtml){signsHtml='无'}
|
||||
html+=signsHtml+'</td>'}
|
||||
return html}}
|
||||
|
|
|
@ -9,9 +9,9 @@
|
|||
*/
|
||||
'use strict';function ReleaseClass(formid,releid){this.formid='#'+formid;this.releid=releid;this.curFocusResIpt=''}
|
||||
ReleaseClass.prototype={constructor:ReleaseClass,init:function(){var $_o=this;$($_o.formid).bind('submit',function(){var module=$($_o.formid+' select[name="module"]').val();if(module=='diy'&&$_o.has_diy_editor()){var diyCode=editorCodeIfr('#diy_editor_ifr',{'get_value':1});if(diyCode){$($_o.formid+' [name="diy[code]"]').val(diyCode)}}
|
||||
var settings=getFormAjaxSettings($(this));settings.data={'_post_data_':settings.data};ajaxOpen(settings);return!1});$($_o.formid+' select[name="module"]').bind('change',function(){var module=$(this).val();$($_o.formid+' .rele-module').hide();$($_o.formid+' .rele-module[module="'+module+'"]').show()});$('#btn_import_release').bind('click',function(){windowModal('导入配置会覆盖当前任务的发布设置,且不可恢复',ulink('release/import'))});$('#rele_module_cms .btn-cms-detect').bind('click',function(){$_o.cms_detect()});$('#rele_module_cms .btn-cms-bind').bind('click',function(){$_o.cms_bind()});$('#rele_module_cms').on('change','select[name="cms[app]"]',function(){var cmsApp=$(this).val();$_o.cms_bind({cms:{app:cmsApp}})});$('#cms_list').on('click','li a',function(){var path=$(this).attr('path');if(path){$($_o.formid+' [name="cms[path]"]').val(path);$('#cms_tab a[href="#cms_tab_bind"]').tab('show');$_o.cms_bind()}});$('#rele_module_cms').on('change','select[name^="cms_app[param]"]',function(){var cusName=$(this).attr('name').replace('cms_app[param]','cms_app[custom]');if($(this).val()=='custom:'){$('input[name="'+cusName+'"]').show()}else{$('input[name="'+cusName+'"]').hide()}});$('#db_tab_config .dm-db-charset li span').bind('click',function(){var charset=$(this).attr('data-val');charset=charset?charset:'';$('#db_tab_config [name="db[charset]"]').val(charset)});$('#db_tab_config .btn-db-names').bind('click',function(){$_o.db_connect('db_names')});$('#db_tab_config .btn-db-connect').bind('click',function(){$_o.db_connect()});$('#rele_module_file').on('click','.btn-file-rand-path',function(){var randStr=$_o.rand_str(10);$($_o.formid+' [name="file[path]"]').val(randStr)});$('#rele_module_api').on('click','.btn-api-rand-url',function(){var randStr=$_o.rand_str(10);$($_o.formid+' [name="api[url]"]').val(randStr)});$('#diy_tab').on('click','[data-type]',function(){var type=$(this).attr('data-type');$($_o.formid+' [name="diy[type]"]').val(type);if(type=='code'&&$_o.has_diy_editor()){var diyCode=$($_o.formid+' [name="diy[code]"]').val();diyCode=diyCode?diyCode:'';editorCodeIfr('#diy_editor_ifr',{'set_value':diyCode})}});$('#toapi_tab').on('click','[data-module]',function(){var module=$(this).attr('data-module');$($_o.formid+' [name="toapi[module]"]').val(module)});$('#rele_module_toapi').on('change','[name="toapi[type]"]',function(){if($(this).val()=='post'){$('#rele_module_toapi .toapi-content-type').show()}else{$('#rele_module_toapi .toapi-content-type').hide()}});$('#rele_module_toapi').on('click','.toapi-add-param',function(){$_o.toapi_add_param(null,null)});$('#rele_module_toapi').on('click','.toapi-del-param',function(){$(this).parents('tr').eq(0).remove()});$('#rele_module_toapi').on('click','.toapi-txt-field a[data-val]',function(){insertAtCaret($(this).parents('.toapi-txt-field').eq(0).find('input:text').eq(0),$(this).attr('data-val'))});inputSelectCustom('#rele_module_toapi [name="toapi[charset]"]','toapi[charset_custom]');inputSelectCustom('#rele_module_toapi [name="toapi[encode]"]','toapi[encode_custom]');$('#rele_module_toapi').on('click','.toapi-add-header',function(){$_o.toapi_add_header(null,null)});$('#rele_module_toapi').on('click','.toapi-del-header',function(){$(this).parents('tr').eq(0).remove()});$('#toapi_url_field').bind('change',function(){var val=$(this).val();$(this).val('');insertAtCaret($('#rele_module_toapi [name="toapi[url]"]'),val)});$('#toapi_app_url_field').bind('change',function(){var val=$(this).val();$(this).val('');insertAtCaret($('#rele_module_toapi [name="toapi[app_url]"]'),val)});$($_o.formid).find('[name="toapi[response][module]"]').bind('change',function(){var module=$(this).val();var resNames=['id','target','desc','error'];for(var i in resNames){var obj=$($_o.formid).find('[name="toapi[response]['+resNames[i]+']"]');var objPh=obj.attr('data-placeholder');if(!module){objPh+=',默认:'+resNames[i]}
|
||||
obj.attr('placeholder',objPh);$('#toapi_resp_module_help').find('[data-module]').hide();$('#toapi_resp_module_help').find('[data-module="'+module+'"]').show()}});$($_o.formid).find('input[name^="toapi[response]"]').bind('focus',function(){$_o.curFocusResIpt=$(this).attr('name')});$('#toapi_resp_module_help').find('[data-rule-sign]').bind('click',function(){var curName=$_o.curFocusResIpt?$_o.curFocusResIpt:'toapi[response][id]';var ruleSign=$(this).attr('data-rule-sign');if(ruleSign=='sign_wildcard'){ruleInsertSign.wildcard('[name="'+curName+'"]')}else if(ruleSign=='sign_match'){ruleInsertSign.match('[name="'+curName+'"]')}else if(ruleSign=='sign_group'){ruleInsertSign.match('[name="'+curName+'"]',{group:1})}});$('#btn_toapi_app').bind('click',function(){$('#toapi_app_params').html('<div class="loading" style="margin-bottom:20px;"></div>');ajaxOpen({type:'post',url:ulink("release/toapiApp"),data:{'task_id':$($_o.formid+' [name="task_id"]').val(),'app_url':$('#rele_module_toapi [name="toapi[app_url]"]').val()},success:function(data){$('#toapi_app_params').html('');if(dataIsJson(data)){ajaxDataMsg(data)}else{$('#toapi_app_params').html(data)}},error:function(){$('#toapi_app_params').html('')}})});$('#toapi_tab a[href="#toapi_tab_app"]').bind('click',function(){ajaxOpen({type:'get',url:ulink("release/toapiApp?task_id=_id_",{'_id_':$($_o.formid+' [name="task_id"]').val()}),success:function(data){if(dataIsJson(data)){ajaxDataMsg(data)}else{$('#toapi_app_params').html(data)}}})});$('#btn_rele_test').bind('click',function(){collectorWindow('测试','admin/release/test?id='+$_o.releid,null,{lg:1})})},load:function(data){var $_o=this;if(data.module){$($_o.formid+' select[name="module"]').val(data.module).trigger('change')}
|
||||
if(data.config){if('cms'==data.module){$_o.cms_bind(data.config);$(document).ready(function(){$('#cms_tab a[href="#cms_tab_bind"]').tab('show')})}else if('db'==data.module){$_o.db_bind(data.config)}else if('file'==data.module){if(data.config.file){$($_o.formid+' [name="file[path]"]').val(data.config.file.path);$($_o.formid+' [name="file[type]"]').each(function(){if($(this).val()==data.config.file.type){$(this).prop('checked',!0)}});$($_o.formid+' [name="file[txt_implode]"]').val(data.config.file.txt_implode);if(data.config.file.hide_fields){for(var fi in data.config.file.hide_fields){$($_o.formid+' [name="file[hide_fields][]"][value="'+data.config.file.hide_fields[fi]+'"]').prop('checked',!0)}}}}else if('api'==data.module){if(data.config.api){$($_o.formid+' [name="api[url]"]').val(data.config.api.url);$($_o.formid+' [name="api[cache_time]"]').val(data.config.api.cache_time);if(data.config.api.hide_fields){for(var fi in data.config.api.hide_fields){$($_o.formid+' [name="api[hide_fields][]"][value="'+data.config.api.hide_fields[fi]+'"]').prop('checked',!0)}}}}else if('diy'==data.module){if(data.config.diy){$(document).ready(function(){$('#diy_tab a[href="#diy_tab_'+data.config.diy.type+'"]').tab('show').trigger('click');for(var i in data.config.diy){$($_o.formid+' [name="diy['+i+']"]').val(data.config.diy[i])}
|
||||
var settings=getFormAjaxSettings($(this));settings.data={'_post_data_':settings.data};ajaxOpen(settings);return!1});$($_o.formid+' select[name="module"]').bind('change',function(){var module=$(this).val();$($_o.formid+' .rele-module').hide();$($_o.formid+' .rele-module[module="'+module+'"]').show()});$('#rele_module_cms .btn-cms-detect').bind('click',function(){$_o.cms_detect()});$('#rele_module_cms .btn-cms-bind').bind('click',function(){$_o.cms_bind()});$('#rele_module_cms').on('change','select[name="cms[app]"]',function(){var cmsApp=$(this).val();$_o.cms_bind({cms:{app:cmsApp}})});$('#cms_list').on('click','li a',function(){var path=$(this).attr('path');if(path){$($_o.formid+' [name="cms[path]"]').val(path);$('#cms_tab a[href="#cms_tab_bind"]').tab('show');$_o.cms_bind()}});inputSelectCustom(null,null,{box:'#rele_module_cms',slt:'select[name^="cms_app[param]"]',ipt:'input[name^="cms_app[custom]"]'},'custom:');$('#db_tab_config .dm-db-charset li span').bind('click',function(){var charset=$(this).attr('data-val');charset=charset?charset:'';$('#db_tab_config [name="db[charset]"]').val(charset)});$('#db_tab_config .btn-db-names').bind('click',function(){$_o.db_connect('db_names')});$('#db_tab_config .btn-db-connect').bind('click',function(){$_o.db_connect()});$('#rele_module_file').on('click','.btn-file-rand-path',function(){var randStr=$_o.rand_str(10);$($_o.formid+' [name="file[path]"]').val(randStr)});$('#rele_module_api').on('click','.btn-api-rand-url',function(){var randStr=$_o.rand_str(10);$($_o.formid+' [name="api[key]"]').val(randStr)});$('#diy_tab').on('click','[data-type]',function(){var type=$(this).attr('data-type');$($_o.formid+' [name="diy[type]"]').val(type);if(type=='code'&&$_o.has_diy_editor()){var diyCode=$($_o.formid+' [name="diy[code]"]').val();diyCode=diyCode?diyCode:'';editorCodeIfr('#diy_editor_ifr',{'set_value':diyCode})}});$('#toapi_tab').on('click','[data-module]',function(){var module=$(this).attr('data-module');$($_o.formid+' [name="toapi[module]"]').val(module)});$('#rele_module_toapi').on('change','[name="toapi[type]"]',function(){if($(this).val()=='post'){$('#rele_module_toapi .toapi-content-type').show()}else{$('#rele_module_toapi .toapi-content-type').hide()}});$('#rele_module_toapi').on('click','.toapi-add-param',function(){$_o.toapi_add_param(null,null)});$('#rele_module_toapi').on('click','.toapi-del-param',function(){$(this).parents('tr').eq(0).remove()});$('#rele_module_toapi').on('click','.toapi-field-txt a[data-val]',function(){insertAtCaret($(this).parents('.toapi-field-txt').eq(0).find('input:text,textarea').eq(0),$(this).attr('data-val'))});inputSelectCustom('#rele_module_toapi [name="toapi[charset]"]','toapi[charset_custom]');inputSelectCustom('#rele_module_toapi [name="toapi[encode]"]','toapi[encode_custom]');$('#rele_module_toapi').on('click','.toapi-add-header',function(){$_o.toapi_add_header(null,null)});$('#rele_module_toapi').on('click','.toapi-del-header',function(){$(this).parents('tr').eq(0).remove()});$('#toapi_url_field').bind('change',function(){var val=$(this).val();$(this).val('');insertAtCaret($('#rele_module_toapi [name="toapi[url]"]'),val)});$('#toapi_app_url_field').bind('change',function(){var val=$(this).val();$(this).val('');insertAtCaret($('#rele_module_toapi [name="toapi[app_url]"]'),val)});$($_o.formid).find('[name="toapi[response][module]"]').bind('change',function(){var module=$(this).val();var resNames=['id','target','desc','error'];for(var i in resNames){var obj=$($_o.formid).find('[name="toapi[response]['+resNames[i]+']"]');var objPh=obj.attr('data-placeholder');if(!module){objPh+=',默认:'+resNames[i]}
|
||||
obj.attr('placeholder',objPh);$('#toapi_resp_module_help').find('[data-module]').hide();$('#toapi_resp_module_help').find('[data-module="'+module+'"]').show()}});$($_o.formid).find('input[name^="toapi[response]"]').bind('focus',function(){$_o.curFocusResIpt=$(this).attr('name')});$('#toapi_resp_module_help').find('[data-rule-sign]').bind('click',function(){var curName=$_o.curFocusResIpt?$_o.curFocusResIpt:'toapi[response][id]';var ruleSign=$(this).attr('data-rule-sign');if(ruleSign=='sign_wildcard'){ruleInsertSign.wildcard('[name="'+curName+'"]')}else if(ruleSign=='sign_match'){ruleInsertSign.match('[name="'+curName+'"]')}else if(ruleSign=='sign_group'){ruleInsertSign.match('[name="'+curName+'"]',{group:1})}});$('#btn_toapi_app').bind('click',function(){$('#toapi_app_params').html('<div class="loading" style="margin-bottom:20px;"></div>');ajaxOpen({type:'post',url:ulink("release/toapiApp"),data:{'task_id':$($_o.formid+' [name="task_id"]').val(),'app_url':$('#rele_module_toapi [name="toapi[app_url]"]').val()},success:function(data){$('#toapi_app_params').html('');if(dataIsJson(data)){var html=data.data?data.data.html:'';if(html){modal('<b>'+data.msg+'<b>',html)}else{ajaxDataMsg(data)}}else{$('#toapi_app_params').html(data)}},error:function(){$('#toapi_app_params').html('')}})});$('#toapi_tab a[href="#toapi_tab_app"]').bind('click',function(){ajaxOpen({type:'get',url:ulink("release/toapiApp?task_id=_id_",{'_id_':$($_o.formid+' [name="task_id"]').val()}),success:function(data){if(dataIsJson(data)){ajaxDataMsg(data)}else{$('#toapi_app_params').html(data)}}})});$('#btn_rele_test').bind('click',function(){collectorWindow('测试','admin/release/test?id='+$_o.releid,null,{lg:1})})},load:function(data){var $_o=this;if(data.module){$($_o.formid+' select[name="module"]').val(data.module).trigger('change')}
|
||||
if(data.config){if('cms'==data.module){$_o.cms_bind(data.config);$(document).ready(function(){$('#cms_tab a[href="#cms_tab_bind"]').tab('show')})}else if('db'==data.module){$_o.db_bind(data.config)}else if('file'==data.module){if(data.config.file){$($_o.formid+' [name="file[path]"]').val(data.config.file.path);$($_o.formid+' [name="file[type]"]').each(function(){if($(this).val()==data.config.file.type){$(this).prop('checked',!0)}});$($_o.formid+' [name="file[txt_implode]"]').val(data.config.file.txt_implode);$($_o.formid+' [name="file[max_line]"]').val(toInt(data.config.file.max_line));if(data.config.file.hide_fields){for(var fi in data.config.file.hide_fields){$($_o.formid+' [name="file[hide_fields][]"][value="'+data.config.file.hide_fields[fi]+'"]').prop('checked',!0)}}}}else if('api'==data.module){if(data.config.api){$($_o.formid+' [name="api[key]"]').val(data.config.api.key);$($_o.formid+' [name="api[cache_time]"]').val(data.config.api.cache_time);if(data.config.api.hide_fields){for(var fi in data.config.api.hide_fields){$($_o.formid+' [name="api[hide_fields][]"][value="'+data.config.api.hide_fields[fi]+'"]').prop('checked',!0)}}}}else if('diy'==data.module){if(data.config.diy){$(document).ready(function(){$('#diy_tab a[href="#diy_tab_'+data.config.diy.type+'"]').tab('show').trigger('click');for(var i in data.config.diy){$($_o.formid+' [name="diy['+i+']"]').val(data.config.diy[i])}
|
||||
if(data.config.diy.app){var appName=data.config.diy.app;if(appName.length>1){appName=appName.substr(0,1).toUpperCase()+appName.substr(1).toLowerCase()}else{appName=appName.toUpperCase()}
|
||||
$($_o.formid+' [name="diy[app]"]').parent().find('.diy-app-name').text(appName+'.php');$($_o.formid+' [name="diy[app]"]').parent().find('.diy-app-editor').show().find('.btn_diy_editor').attr('href',ulink('develop/editor?type=release&module=diy&app=_app_',{'_app_':appName}))}
|
||||
if($_o.has_diy_editor()&&data.config.diy.code){editorCodeIfr('#diy_editor_ifr',{'set_value':data.config.diy.code})}})}}else if('toapi'==data.module){var config=data.config.toapi;if(config){$($_o.formid+' [name="toapi[module]"]').val(config.module);$($_o.formid+' [name="toapi[url]"]').val(config.url);$($_o.formid+' [name="toapi[type]"]').val(config.type).trigger('change');$($_o.formid+' [name="toapi[content_type]"]').val(config.content_type);$($_o.formid+' [name="toapi[charset_custom]"]').val(config.charset_custom);$($_o.formid+' [name="toapi[charset]"]').val(config.charset).trigger('change');$($_o.formid+' [name="toapi[encode_custom]"]').val(config.encode_custom);$($_o.formid+' [name="toapi[encode]"]').val(config.encode).trigger('change');if(config.response){for(var i in config.response){$($_o.formid+' [name="toapi[response]['+i+']"]').val(config.response[i])}}
|
||||
|
@ -34,5 +34,8 @@ tpl.find('[data-name]').each(function(){$(this).attr('name','db_tables['+key+']'
|
|||
param=param?param:{};if(!index){index=generateUUID()}
|
||||
paramTable.find('tbody').append('<tr data-param-id="'+index+'">'+paramTable.attr('data-tpl')+'</tr>');var curTr=paramTable.find('[data-param-id="'+index+'"]');curTr.find('[name="toapi[param_name][]"]').val(param.name?param.name:'');curTr.find('[name="toapi[param_val][]"]').val(param.val?param.val:'')},toapi_add_header:function(header,index){var $_o=this;var headerTable=$('#rele_module_toapi').find('.toapi-header-table table');if(!headerTable.attr('data-tpl')){var headerTpl=$('#rele_module_toapi').find('.toapi-header-tpl');headerTable.attr('data-tpl',headerTpl.html());headerTpl.remove()}
|
||||
header=header?header:{};if(!index){index=generateUUID()}
|
||||
headerTable.find('tbody').append('<tr data-header-id="'+index+'">'+headerTable.attr('data-tpl')+'</tr>');var curTr=headerTable.find('[data-header-id="'+index+'"]');curTr.find('[name="toapi[header_name][]"]').val(header.name?header.name:'');curTr.find('[name="toapi[header_val][]"]').val(header.val?header.val:'')},toapi_app_load:function(appParams){if(isObject(appParams)){for(var key in appParams){var val=appParams[key];if(isObject(val)){for(var i in val){$('#toapi_app_params').find('[name="toapi[app_params]['+key+'][]"][value="'+val[i]+'"]').prop('checked',!0)}}else{var curObj=$('#toapi_app_params').find('[name="toapi[app_params]['+key+']"]');if(curObj.is('input:radio')){$('#toapi_app_params').find('[name="toapi[app_params]['+key+']"][value="'+val+'"]').prop('checked',!0)}else{curObj.val(val)}}}}},rand_str:function(len){var chars='ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678'; var maxPos=chars.length; var str=''; for(var i=0;i<len;i++){ str+=chars.charAt(Math.floor(Math.random()*maxPos)); }
|
||||
return str},import_rele:function(id,name){var $_o=this;$($_o.formid+' input[name="release_id"]').val(id);$('#btn_import_release').text('导入配置:'+name);$('#myModal').modal('hide')},has_diy_editor:function(){return $('#diy_editor_ifr').length>0?true:!1}}
|
||||
headerTable.find('tbody').append('<tr data-header-id="'+index+'">'+headerTable.attr('data-tpl')+'</tr>');var curTr=headerTable.find('[data-header-id="'+index+'"]');curTr.find('[name="toapi[header_name][]"]').val(header.name?header.name:'');curTr.find('[name="toapi[header_val][]"]').val(header.val?header.val:'')},toapi_app_load:function(appParams,appCustomParams){$('#toapi_app_params').off('change','select[name^="toapi[app_params]"]').on('change','select[name^="toapi[app_params]"]',function(){var val=$(this).val();var prt=$(this).parents('.toapi-field-txt').eq(0);var custom=!1;if(isObject(val)){custom=val.indexOf('@skycaiji_custom')>-1?true:!1}else{custom=(val=='@skycaiji_custom')?true:!1}
|
||||
if(custom){prt.addClass('toapi-field-slt-txt')}else{prt.removeClass('toapi-field-slt-txt')}});if(isObject(appParams)){appCustomParams=isObject(appCustomParams)?appCustomParams:{};for(var key in appParams){var val=appParams[key];if(isObject(val)){var curObjs=$('#toapi_app_params').find('[name="toapi[app_params]['+key+'][]"]');if(curObjs.is('select')){curObjs.find('option').each(function(){if(val.indexOf($(this).val())>-1){$(this).prop('selected',!0)}});curObjs.trigger('change')}else{curObjs.each(function(){if(val.indexOf($(this).val())>-1){$(this).prop('checked',!0)}})}}else{var curObj=$('#toapi_app_params').find('[name="toapi[app_params]['+key+']"]');if(curObj.is('input:radio')){$('#toapi_app_params').find('[name="toapi[app_params]['+key+']"][value="'+val+'"]').prop('checked',!0)}else{curObj.val(val)}
|
||||
if(curObj.is('select')){curObj.trigger('change')}}
|
||||
if(appCustomParams[key]){$('#toapi_app_params').find('[name="toapi[app_custom_params]['+key+']"]').val(appCustomParams[key])}}}},rand_str:function(len){var chars='ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678'; var maxPos=chars.length; var str=''; for(var i=0;i<len;i++){ str+=chars.charAt(Math.floor(Math.random()*maxPos)); }
|
||||
return str},import_rele:function(releaseImport,name){var $_o=this;$($_o.formid+' input[name="release_import"]').val(releaseImport);$('#btn_import_release').html('导入配置:'+name+'<a href="javascript:;" class="glyphicon glyphicon-remove delete" style="font-size:12px;margin-left:5px;"></a>');$('#btn_import_release .delete').bind('click',function(){$($_o.formid+' input[name="release_import"]').val('');$('#btn_import_release').html('导入配置 <span class="caret"></span>')});$('#myModal').modal('hide')},has_diy_editor:function(){return $('#diy_editor_ifr').length>0?true:!1}}
|
|
@ -12,9 +12,10 @@ SettingClass.prototype={constructor:SettingClass,caiji_init:function(caijiConfig
|
|||
$($_o.caijiForm+' [name="robots"][value="'+toInt(caijiConfig.robots)+'"]').prop('checked',!0);$($_o.caijiForm+' [name="auto"][value="'+toInt(caijiConfig.auto)+'"]').trigger("click");$($_o.caijiForm+' [name="run"]').val(caijiConfig.run?caijiConfig.run:'backstage').trigger("change");$($_o.caijiForm+' [name="api"][value="'+toInt(caijiConfig.api)+'"]').trigger("click");$($_o.caijiForm+' [name="server"]').trigger("change");$($_o.caijiForm+' [name="same_url"][value="'+toInt(caijiConfig.same_url)+'"]').prop('checked',!0);$($_o.caijiForm+' [name="same_title"][value="'+toInt(caijiConfig.same_title)+'"]').prop('checked',!0);$($_o.caijiForm+' [name="same_content"][value="'+toInt(caijiConfig.same_content)+'"]').prop('checked',!0);$($_o.caijiForm+' [name="real_time"][value="'+toInt(caijiConfig.real_time)+'"]').prop('checked',!0);if(caijiConfig.server=='swoole'){$('#test_swoole_restart').show()}
|
||||
ajaxOpen({dataType:'json',url:ulink('setting/caiji_check'),async:!0,success:function(data){data=data.data?data.data:{};if(data.error){if(data.server=='cli'){$('#error_server_php').html(data.error).show()}else if(data.server=='swoole'){$('#error_server_swoole').html(data.error).show()}}}})},down_img_init:function(imgConfig){var $_o=this;imgConfig=imgConfig?imgConfig:{};$($_o.downImgForm+' [name="download_img"]').bind('click',function(){if($(this).val()==1){$('.content-wrapper').removeClass('wrapper-not-enable')}else{$('.content-wrapper').addClass('wrapper-not-enable')}});$($_o.downImgForm+' [name="img_name"]').bind('change',function(){if($(this).val()=='custom'){$('#img_name_custom').show()}else{$('#img_name_custom').hide()}});inputSelectCustom($_o.downImgForm+' [name="charset"]','charset_custom');$($_o.downImgForm).on('click','.name-custom-path a[data-val]',function(){insertAtCaret($('[name="name_custom_path"]'),$(this).attr('data-val'))});$($_o.downImgForm+' #add_img_func').bind('click',function(){$_o.add_img_func(null)});pluginFuncOp.initHtml($_o.downImgForm+' #img_funcs');for(var i in imgConfig){var ele=$($_o.downImgForm).find('[name="'+i+'"]').eq(0);if(ele.length>0&&!ele.is('input:radio')){ele.val(imgConfig[i])}}
|
||||
if(imgConfig.img_funcs){for(var i in imgConfig.img_funcs){$_o.add_img_func(imgConfig.img_funcs[i])}}
|
||||
$($_o.downImgForm+' [name="download_img"][value="'+toInt(imgConfig.download_img)+'"]').trigger("click");$($_o.downImgForm+' [name="data_image"][value="'+toInt(imgConfig.data_image)+'"]').trigger("click");$($_o.downImgForm+' [name="img_name"]').trigger("change");$($_o.downImgForm+' [name="charset"]').trigger("change");$($_o.downImgForm+' [name="img_watermark"][value="'+toInt(imgConfig.img_watermark)+'"]').trigger("click");if(imgConfig.img_wm_logo){$('#img_wm_logo_show').attr('src',window.site_config.root+imgConfig.img_wm_logo+'?'+(new Date().getTime())).show()}},add_img_func:function(funcData){var $_o=this;pluginFuncOp.addHtml({funcData:funcData,funcName:'img_funcs[{id}][func]',funcParamName:'img_funcs[{id}][func_param]',tplId:'img_tpl_func',listId:'img_funcs',funcId:'img_func_{id}'},{module:'downloadImg',boxObj:$_o.downImgForm})},down_file_init:function(fileConfig){var $_o=this;fileConfig=fileConfig?fileConfig:{};$($_o.downFileForm+' [name="download_file"]').bind('click',function(){if($(this).val()==1){$('.content-wrapper').removeClass('wrapper-not-enable')}else{$('.content-wrapper').addClass('wrapper-not-enable')}});$($_o.downFileForm+' [name="file_name"]').bind('change',function(){if($(this).val()=='custom'){$('#file_name_custom').show()}else{$('#file_name_custom').hide()}});inputSelectCustom($_o.downFileForm+' [name="charset"]','charset_custom');$($_o.downFileForm).on('click','.name-custom-path a[data-val]',function(){insertAtCaret($('[name="name_custom_path"]'),$(this).attr('data-val'))});$($_o.downFileForm+' #add_file_func').bind('click',function(){$_o.add_file_func(null)});pluginFuncOp.initHtml($_o.downFileForm+' #file_funcs');for(var i in fileConfig){var ele=$($_o.downFileForm).find('[name="'+i+'"]').eq(0);if(ele.length>0&&!ele.is('input:radio')){ele.val(fileConfig[i])}}
|
||||
$($_o.downImgForm+' [name="download_img"][value="'+toInt(imgConfig.download_img)+'"]').trigger("click");$($_o.downImgForm+' [name="data_image"][value="'+toInt(imgConfig.data_image)+'"]').trigger("click");$($_o.downImgForm+' [name="url_real"][value="'+toInt(imgConfig.url_real)+'"]').trigger("click");$($_o.downImgForm+' [name="img_name"]').trigger("change");$($_o.downImgForm+' [name="charset"]').trigger("change");$($_o.downImgForm+' [name="img_watermark"][value="'+toInt(imgConfig.img_watermark)+'"]').trigger("click");if(imgConfig.img_wm_logo){$('#img_wm_logo_show').attr('src',window.site_config.root+imgConfig.img_wm_logo+'?'+(new Date().getTime())).show()}},add_img_func:function(funcData){var $_o=this;pluginFuncOp.addHtml({funcData:funcData,funcName:'img_funcs[{id}][func]',funcParamName:'img_funcs[{id}][func_param]',tplId:'img_tpl_func',listId:'img_funcs',funcId:'img_func_{id}'},'downloadImg')},down_file_init:function(fileConfig){var $_o=this;fileConfig=fileConfig?fileConfig:{};$($_o.downFileForm+' [name="download_file"]').bind('click',function(){if($(this).val()==1){$('.content-wrapper').removeClass('wrapper-not-enable')}else{$('.content-wrapper').addClass('wrapper-not-enable')}});$($_o.downFileForm+' [name="file_name"]').bind('change',function(){if($(this).val()=='custom'){$('#file_name_custom').show()}else{$('#file_name_custom').hide()}});inputSelectCustom($_o.downFileForm+' [name="charset"]','charset_custom');$($_o.downFileForm).on('click','.name-custom-path a[data-val]',function(){insertAtCaret($('[name="name_custom_path"]'),$(this).attr('data-val'))});$($_o.downFileForm+' #add_file_func').bind('click',function(){$_o.add_file_func(null)});pluginFuncOp.initHtml($_o.downFileForm+' #file_funcs');for(var i in fileConfig){var ele=$($_o.downFileForm).find('[name="'+i+'"]').eq(0);if(ele.length>0&&!ele.is('input:radio')){ele.val(fileConfig[i])}}
|
||||
if(fileConfig.file_funcs){for(var i in fileConfig.file_funcs){$_o.add_file_func(fileConfig.file_funcs[i])}}
|
||||
$($_o.downFileForm+' [name="download_file"][value="'+toInt(fileConfig.download_file)+'"]').trigger("click");$($_o.downFileForm+' [name="file_name"]').trigger("change");$($_o.downFileForm+' [name="charset"]').trigger("change")},add_file_func:function(funcData){var $_o=this;pluginFuncOp.addHtml({funcData:funcData,funcName:'file_funcs[{id}][func]',funcParamName:'file_funcs[{id}][func_param]',tplId:'file_tpl_func',listId:'file_funcs',funcId:'file_func_{id}'},{module:'downloadFile',boxObj:$_o.downFileForm})},page_render_init:function(renderConfig){var $_o=this;renderConfig=renderConfig?renderConfig:{};$($_o.pageRenderForm+' [name="tool"]').bind('change',function(){var tool=$(this).val();$('[id^="render_tool_"]').hide();if(tool){$('#render_tool_'+tool).show()}});$('#btn_chrome_test').bind('click',function(){ajax_check_userpwd({type:'POST',dataType:'json',url:ulink('setting/chrome_test'),data:$($_o.pageRenderForm).serialize(),beforeSend:function(){$('#btn_chrome_test').text('测试中...').attr('disabled',!0)},success:function(data){if(data.code==1){toastr.success(data.msg)}else{var warning=!1;if(data.msg.indexOf(':WARNING')>-1){warning=!0;if(data.msg.indexOf(':ERROR')>-1){warning=!1}}
|
||||
if(warning){toastr.warning(data.msg)}else{toastr.error(data.msg)}}},complete:function(){$('#btn_chrome_test').text('测试').removeAttr('disabled')}})});$($_o.pageRenderForm).bind('submit',function(){var formObj=$(this);var settings=getFormAjaxSettings(formObj);settings.complete=function(){formObj.find('button[type="submit"]').removeAttr('disabled')};ajax_check_userpwd(settings);return!1});$('#btn_chrome_clean').bind('click',function(){confirmRight('确定清理?',function(){windowModal('正在清理...',ulink('setting/chrome_clean'))})});$('#btn_chrome_restart').bind('click',function(){confirmRight('确定重启?',function(){windowModal('正在重启...',ulink('setting/chrome_restart'))})});$($_o.pageRenderForm+' [name="tool"]').val(renderConfig.tool).trigger('change')},translate_init:function(transConfig){var $_o=this;transConfig=transConfig?transConfig:{};$($_o.transForm+' [name="open"]').bind('click',function(){if($(this).val()==1){$('.content-wrapper').removeClass('wrapper-not-enable')}else{$('.content-wrapper').addClass('wrapper-not-enable')}});$($_o.transForm+' [name="api"]').bind('change',function(){$('[id^="api_"]').hide();$('#api_'+$(this).val()).show()});$($_o.transForm+' [name="open"][value="'+toInt(transConfig.open)+'"]').trigger('click');$($_o.transForm+' [name="api"]').val(transConfig.api).trigger("change");$($_o.transForm+' [name="pass_html"][value="'+toInt(transConfig.pass_html)+'"]').trigger('click')},site_init:function(siteConfig){var $_o=this;siteConfig=siteConfig?siteConfig:{};siteConfig.login=siteConfig.login?siteConfig.login:{};$($_o.siteForm+' [name="verifycode"]').bind('click',function(){if($(this).val()==1){$('#verifycode_len').show()}else{$('#verifycode_len').hide()}});$($_o.siteForm+' [name="login[limit]"]').bind('click',function(){if($(this).val()==1){$('#login_limit').show()}else{$('#login_limit').hide()}});$($_o.siteForm+' #btn_timezone').bind('click',function(){var nowTime=new Date();var offset=nowTime.getTimezoneOffset()/60;ajaxOpen({type:'post',url:ulink("setting/site_timezone"),data:{time:nowTime.getTime(),offset:offset},dataType:'json',success:function(data){if(data.code==1){if(data.data&&data.data.timezone){if($($_o.siteForm+' [name="timezone"]').find('option[value="'+data.data.timezone+'"]').length>0){$($_o.siteForm+' [name="timezone"]').val(data.data.timezone)}else{toastr.error('自动调整失败,请手动选择!')}}}else{if(data.msg){toastr.error(data.msg)}}}})});$($_o.siteForm+' [name="verifycode"][value="'+toInt(siteConfig.verifycode)+'"]').prop('checked','checked').trigger('click');$($_o.siteForm+' [name="hidehome"][value="'+toInt(siteConfig.hidehome)+'"]').prop('checked','checked');$($_o.siteForm+' [name="closelog"][value="'+toInt(siteConfig.closelog)+'"]').prop('checked','checked');$($_o.siteForm+' [name="dblong"][value="'+toInt(siteConfig.dblong)+'"]').prop('checked','checked');$($_o.siteForm+' [name="login[limit]"][value="'+toInt(siteConfig.login.limit)+'"]').prop('checked','checked').trigger('click');$($_o.siteForm+' [name="closetrans"][value="'+toInt(siteConfig.closetrans)+'"]').prop('checked','checked');$($_o.siteForm+' [name="timezone"]').val(siteConfig.timezone)},email_init:function(emailConfig){var $_o=this;emailConfig=emailConfig?emailConfig:{};$('#btn_test').bind('click',function(){$($_o.emailForm+' [name="is_test"]').val(1);$($_o.emailForm).submit()});$($_o.emailForm+' button[type="submit"]').bind('click',function(){$($_o.emailForm+' [name="is_test"]').val(0)});$($_o.emailForm+' [name="type"][value="'+emailConfig.type+'"]').prop('checked','checked')},store_init:function(storeConfig){var $_o=this;storeConfig=storeConfig?storeConfig:{};$($_o.storeForm).bind('submit',function(){var obj=$(this);ajaxOpen({type:'post',url:obj.attr('action'),dataType:'json',data:obj.serialize(),success:function(data){if(data.code==1){ajaxDataMsg(data)}else{if(data.msg){toastr.error(data.msg)}
|
||||
$($_o.downFileForm+' [name="download_file"][value="'+toInt(fileConfig.download_file)+'"]').trigger("click");$($_o.downFileForm+' [name="url_real"][value="'+toInt(fileConfig.url_real)+'"]').trigger("click");$($_o.downFileForm+' [name="file_name"]').trigger("change");$($_o.downFileForm+' [name="charset"]').trigger("change")},add_file_func:function(funcData){var $_o=this;pluginFuncOp.addHtml({funcData:funcData,funcName:'file_funcs[{id}][func]',funcParamName:'file_funcs[{id}][func_param]',tplId:'file_tpl_func',listId:'file_funcs',funcId:'file_func_{id}'},'downloadFile')},page_render_init:function(renderConfig){var $_o=this;renderConfig=renderConfig?renderConfig:{};$($_o.pageRenderForm+' [name="tool"]').bind('change',function(){var tool=$(this).val();$($_o.pageRenderForm+' [id^="render_tool_"]').hide();if(tool){$($_o.pageRenderForm+' #render_tool_'+tool).show()}});$($_o.pageRenderForm+' [name="chrome[server]"]').bind('click',function(){if(!$(this).val()){$($_o.pageRenderForm+' [data-chrome-server=""]').show()}else{$($_o.pageRenderForm+' [data-chrome-server=""]').hide()}});$('#btn_chrome_test').bind('click',function(){ajax_check_userpwd({type:'POST',dataType:'json',url:ulink('setting/chrome_test'),data:$($_o.pageRenderForm).serialize(),beforeSend:function(){$('#btn_chrome_test').text('测试中...').attr('disabled',!0)},success:function(data){if(data.code==1){toastr.success(data.msg)}else{var warning=!1;if(data.msg.indexOf(':WARNING')>-1){warning=!0;if(data.msg.indexOf(':ERROR')>-1){warning=!1}}
|
||||
if(warning){toastr.warning(data.msg)}else{toastr.error(data.msg)}}},complete:function(){$('#btn_chrome_test').text('测试').removeAttr('disabled')}})});$($_o.pageRenderForm).bind('submit',function(){var formObj=$(this);var settings=getFormAjaxSettings(formObj);settings.complete=function(){formObj.find('button[type="submit"]').removeAttr('disabled')};ajax_check_userpwd(settings);return!1});$('#btn_chrome_clean').bind('click',function(){confirmRight('确定清理?',function(){windowModal('正在清理...',ulink('setting/chrome_clean'))})});$('#btn_chrome_restart').bind('click',function(){confirmRight('确定重启?',function(){windowModal('正在重启...',ulink('setting/chrome_restart'))})});$($_o.pageRenderForm+' [name="tool"]').val(renderConfig.tool).trigger('change');if(renderConfig.chrome){$($_o.pageRenderForm+' [name="chrome[server]"][value="'+renderConfig.chrome.server+'"]').prop('checked','checked').trigger('click')}},translate_init:function(transConfig){var $_o=this;transConfig=transConfig?transConfig:{};$($_o.transForm+' [name="open"]').bind('click',function(){if($(this).val()==1){$('.content-wrapper').removeClass('wrapper-not-enable')}else{$('.content-wrapper').addClass('wrapper-not-enable')}});$($_o.transForm+' [name="api"]').bind('change',function(){$('[id^="api_"]').hide();$('#api_'+$(this).val()).show()});$($_o.transForm+' [name="open"][value="'+toInt(transConfig.open)+'"]').trigger('click');$($_o.transForm+' [name="api"]').val(transConfig.api).trigger("change");$($_o.transForm+' [name="pass_html"][value="'+toInt(transConfig.pass_html)+'"]').trigger('click')},site_init:function(siteConfig){var $_o=this;siteConfig=siteConfig?siteConfig:{};siteConfig.login=siteConfig.login?siteConfig.login:{};$($_o.siteForm+' [name="verifycode"]').bind('click',function(){if($(this).val()==1){$('#verifycode_len').show()}else{$('#verifycode_len').hide()}});$($_o.siteForm+' [name="login[limit]"]').bind('click',function(){if($(this).val()==1){$('#login_limit').show()}else{$('#login_limit').hide()}});$($_o.siteForm+' #btn_timezone').bind('click',function(){var nowTime=new Date();var offset=nowTime.getTimezoneOffset()/60;ajaxOpen({type:'post',url:ulink("setting/site_timezone"),data:{time:nowTime.getTime(),offset:offset},dataType:'json',success:function(data){if(data.code==1){if(data.data&&data.data.timezone){if($($_o.siteForm+' [name="timezone"]').find('option[value="'+data.data.timezone+'"]').length>0){$($_o.siteForm+' [name="timezone"]').val(data.data.timezone)}else{toastr.error('自动调整失败,请手动选择!')}}}else{if(data.msg){toastr.error(data.msg)}}}})});$($_o.siteForm+' [name="verifycode"][value="'+toInt(siteConfig.verifycode)+'"]').prop('checked','checked').trigger('click');$($_o.siteForm+' [name="hidehome"][value="'+toInt(siteConfig.hidehome)+'"]').prop('checked','checked');$($_o.siteForm+' [name="closelog"][value="'+toInt(siteConfig.closelog)+'"]').prop('checked','checked');$($_o.siteForm+' [name="dblong"][value="'+toInt(siteConfig.dblong)+'"]').prop('checked','checked');$($_o.siteForm+' [name="login[limit]"][value="'+toInt(siteConfig.login.limit)+'"]').prop('checked','checked').trigger('click');$($_o.siteForm+' [name="closetrans"][value="'+toInt(siteConfig.closetrans)+'"]').prop('checked','checked');$($_o.siteForm+' [name="timezone"]').val(siteConfig.timezone)},email_init:function(emailConfig){var $_o=this;emailConfig=emailConfig?emailConfig:{};$('#btn_test').bind('click',function(){$($_o.emailForm+' [name="is_test"]').val(1);$($_o.emailForm).submit()});$($_o.emailForm+' button[type="submit"]').bind('click',function(){$($_o.emailForm+' [name="is_test"]').val(0)});$($_o.emailForm).bind('submit',function(){var settings=getFormAjaxSettings($(this));var isTest=$($_o.emailForm+' [name="is_test"]').val();if(isTest>0){$('#btn_test').html('正在测试...');$('#btn_test').attr('disabled',!0);settings.complete=function(){$('#btn_test').html('测试').attr('disabled',!1)}}
|
||||
ajaxOpen(settings);return!1});$($_o.emailForm+' [name="caiji[open]"]').bind('click',function(){if($(this).val()==1){$('#caiji_open').show()}else{$('#caiji_open').hide()}});$($_o.emailForm+' [name="type"][value="'+emailConfig.type+'"]').prop('checked','checked');var caiji=emailConfig.caiji;if(caiji){$($_o.emailForm+' [name="caiji[open]"][value="'+toInt(caiji.open)+'"]').prop('checked',!0).trigger('click');$($_o.emailForm+' [name="caiji[is_auto]"][value="'+toInt(caiji.is_auto)+'"]').prop('checked',!0);$($_o.emailForm+' [name="caiji[failed_interval]"]').val(toInt(caiji.failed_interval));$($_o.emailForm+' [name="caiji[failed_num]"]').val(toInt(caiji.failed_num));$($_o.emailForm+' [name="caiji[report_interval]"]').val(toInt(caiji.report_interval));$($_o.emailForm+' [name="caiji[email]"]').val(caiji.email)}},store_init:function(storeConfig){var $_o=this;storeConfig=storeConfig?storeConfig:{};$($_o.storeForm).bind('submit',function(){var obj=$(this);ajaxOpen({type:'post',url:obj.attr('action'),dataType:'json',data:obj.serialize(),success:function(data){if(data.code==1){ajaxDataMsg(data)}else{if(data.msg){toastr.error(data.msg)}
|
||||
var data=data.data;if(data&&data.same_as_pwd){confirmRight(data.same_as_pwd,function(){obj.find('[name="same_as_pwd"]').val(1);obj.trigger('submit')})}}}});return!1});$('#provider_authkeys_iframe').bind('load',function(){var mainheight=$(this).contents().find('body').height()+1;$(this).height(mainheight)})}}
|
||||
var settingClass=new SettingClass()
|
|
@ -7,21 +7,21 @@
|
|||
| 使用协议 https://www.skycaiji.com/licenses
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
'use strict';var taskOpClass={import_rule:function(ruleId,ruleName){$('#form_item input[name="rule_id"]').val(ruleId);$('#btn_import_rule').text('导入规则:'+ruleName);if(ruleId=='file'){var settings=getFormAjaxSettings($('#form_item'));settings.url=ulink('task/import_rule_file');settings.beforeSend=null;settings.error=null;settings.success=function(data){data.url='';if(data.msg){ajaxDataMsg(data)}
|
||||
$('#import_rule_file_plugins').hide().find('.plugins-info').html('');var dataData=data.data;if(isObject(dataData)){if(isObject(dataData.show_plugins)){var html='<input type="hidden" name="upload_addon[ignore_plugin]" value="1" />';for(var app in dataData.show_plugins){html+='<div class="checkbox"><label><input type="checkbox" name="upload_addon[plugins][]" value="'+app+'">'+dataData.show_plugins[app]+'</label></div>'}
|
||||
$('#import_rule_file_plugins').show().find('.plugins-info').html(html)}}};ajaxOpen(settings)}else{$('#form_item [name="rule_file"]').val('')}
|
||||
$('#myModal').modal('hide')},import_task:function(id,name){$('#form_item input[name="task_id"]').val(id);$('#btn_import_task').text('导入任务:'+name);$('#myModal').modal('hide')},task_init: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 select[name="auto"]').bind('change',function(){var val=$(this).val();val=toInt(val);if(val==2){$('#config_task_timer').show()}else{$('#config_task_timer').hide()}
|
||||
if(val>0){$('#config_task_auto_tips').show()}else{$('#config_task_auto_tips').hide()}});$('select[id^="task_timer_"]').bind('change',function(){var name=$(this).attr('data-name');if(name){var val=$(this).val();val=val?val.join(','):'';$('#form_item [name="'+name+'"]').val(val)}});$('#form_item [name="rule_file"]').bind('change',function(){taskOpClass.import_rule('file',$(this).val());$(this).parents('.dropdown').removeClass('open')});$('#form_item [name="config[proxy]"]').bind('click',function(){var open=!1;var val=$(this).val();if(val=='y'){open=!0}else if($(this).attr('data-global')){open=!0}
|
||||
'use strict';var taskOpClass={import_rule:function(ruleImport,ruleName){$('#form_item input[name="rule_import"]').val(ruleImport);$('#btn_import_rule').html('导入规则:'+ruleName+'<a href="javascript:;" class="glyphicon glyphicon-remove delete" style="font-size:12px;margin-left:5px;"></a>');$('#btn_import_rule .delete').bind('click',function(){$('#form_item input[name="rule_import"]').val('');$('#btn_import_rule').html('导入规则 <span class="caret"></span>')});$('#myModal').modal('hide')},import_task:function(id,name){$('#form_item input[name="task_id"]').val(id);$('#btn_import_task').text('导入任务:'+name);$('#myModal').modal('hide')},task_init: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 select[name="auto"]').bind('change',function(){var val=$(this).val();val=toInt(val);if(val==2){$('#config_task_timer').show()}else{$('#config_task_timer').hide()}
|
||||
if(val>0){$('#config_task_auto_tips').show()}else{$('#config_task_auto_tips').hide()}});$('select[id^="task_timer_"]').bind('change',function(){var name=$(this).attr('data-name');if(name){var val=$(this).val();val=val?val.join(','):'';$('#form_item [name="'+name+'"]').val(val)}});$('#form_item .btn-rand-single-key').bind('click',function(){var chars='ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678'; var maxPos=chars.length; var str=''; for(var i=0;i<10;i++){ str+=chars.charAt(Math.floor(Math.random()*maxPos)); }
|
||||
$('#form_item [name="config[single][key]"]').val(str)});$('#form_item [name="config[proxy]"]').bind('click',function(){var open=!1;var val=$(this).val();if(val=='y'){open=!0}else if($(this).attr('data-global')){open=!0}
|
||||
if(open){$('#config_proxy').removeClass('box-not-enable')}else{$('#config_proxy').addClass('box-not-enable')}});var downFunc=function(isImg){var type=isImg?'img':'file';$('#form_item [name="config[download_'+type+']"]').bind('click',function(){var open=!1;var val=$(this).val();if(val=='y'){open=!0}else if($(this).attr('data-global')){open=!0}
|
||||
if(open){$('#config_download_'+type).removeClass('box-not-enable')}else{$('#config_download_'+type).addClass('box-not-enable')}});$('#form_item [name="config['+type+'_name]"]').bind('change',function(){var val=$(this).val();if(val=='custom'){$('#config_'+type+'_name_custom').show()}else{$('#config_'+type+'_name_custom').hide()}});var nameType=isImg?'name':'file';$('#config_'+type+'_name_custom').on('click','.'+nameType+'-custom-path a[data-val]',function(){insertAtCaret($('[name="config['+nameType+'_custom_path]"]'),$(this).attr('data-val'))});$('#config_'+type+'_name_custom').on('click','.'+nameType+'-custom-name a[data-val]',function(){insertAtCaret($('[name="config['+nameType+'_custom_name]"]'),$(this).attr('data-val'))});$('#form_item [name="config['+type+'_funcs_open]"]').bind('click',function(){if($(this).val()=='n'){$('#config_'+type+'_funcs_open').hide()}else{$('#config_'+type+'_funcs_open').show()}});$('#form_item #add_config_'+type+'_func').bind('click',function(){if(isImg){taskOpClass.add_config_img_func(null)}else{taskOpClass.add_config_file_func(null)}});pluginFuncOp.initHtml('#config_'+type+'_funcs')};downFunc(!0);downFunc(!1);$('#form_item [name="config[img_watermark]"]').bind('click',function(){var open=!1;var val=$(this).val();if(val=='y'){open=!0}else if($(this).attr('data-global')){open=!0}
|
||||
if(open){$('#config_img_watermark').show()}else{$('#config_img_watermark').hide()}});$('#img_wm_logo_show a').bind('click',function(){var obj=$(this);confirmRight('删除后恢复使用全局设置logo,是否继续?',function(){$('#form_item [name="config[img_wm_logo]"]').val('');taskOpClass.show_img_wm_logo()})})},task_load:function(taskData,fieldList){taskOpClass.task_init();$('#form_item').find('[name^="config"]').each(function(){if($(this).is('input:radio')){if(!$(this).val()){$(this).prop('checked','checked').trigger('click')}}else if($(this).is('select')){$(this).val('').trigger('change')}});if(taskData){$('#form_item select[name="tg_id"]').val(toInt(taskData.tg_id));$('#form_item select[name="module"]').val(taskData.module);$('#form_item select[name="auto"]').val(toInt(taskData.auto)).trigger('change');var task_timer=taskData._task_timer;if(task_timer){var timerNames=['month','day','hour','minute'];for(var i in timerNames){var timerName=timerNames[i];var timerData=task_timer[timerName];if(!timerData||typeof(timerData)!='object'){timerData=[]}
|
||||
if(open){$('#config_img_watermark').show()}else{$('#config_img_watermark').hide()}});$('#img_wm_logo_show a').bind('click',function(){var obj=$(this);confirmRight('删除后恢复使用全局设置logo,是否继续?',function(){$('#form_item [name="config[img_wm_logo]"]').val('');taskOpClass.show_img_wm_logo()})})},task_load:function(taskData,fieldList){taskOpClass.task_init();$('#form_item').find('[name^="config"]').each(function(){if($(this).is('input:radio')){if(!$(this).val()){$(this).prop('checked',!0).trigger('click')}}else if($(this).is('select')){$(this).val('').trigger('change')}});if(taskData){$('#form_item select[name="tg_id"]').val(toInt(taskData.tg_id));$('#form_item select[name="module"]').val(taskData.module);$('#form_item select[name="auto"]').val(toInt(taskData.auto)).trigger('change');var task_timer=taskData._task_timer;if(task_timer){var timerNames=['month','day','hour','minute'];for(var i in timerNames){var timerName=timerNames[i];var timerData=task_timer[timerName];if(!timerData||typeof(timerData)!='object'){timerData=[]}
|
||||
if(timerData.length>0){$('#form_item [name="task_timer['+timerName+']"]').val(timerData.join(','));for(var ii in timerData){$('#task_timer_'+timerName).find('option[value="'+timerData[ii]+'"]').prop('selected','selected')}}else{$('#task_timer_'+timerName).find('option[value=""]').prop('selected','selected')}}}
|
||||
var task_config=taskData.config;var showConfig=!1;if(task_config){for(var i in task_config){if((isObject(task_config[i])&&task_config[i].length>0)||(!isObject(task_config[i])&&task_config[i])){showConfig=!0;break}}
|
||||
var imgFuncs=isObject(task_config.img_funcs)?task_config.img_funcs:[];var fileFuncs=isObject(task_config.file_funcs)?task_config.file_funcs:[];for(var i in task_config){var ele=$('#form_item').find('[name="config['+i+']"]').eq(0);if(ele.length>0){if(ele.is('input:radio')){$('#form_item').find('[name="config['+i+']"][value="'+task_config[i]+'"]').prop('checked','checked').trigger('click')}else{ele.val(task_config[i]);if(ele.is('select')){ele.trigger('change')}}}}
|
||||
var task_config=taskData.config;var showConfig=!1;if(task_config){var otherConfig=task_config.other;var singleConfig=task_config.single;delete task_config.other;delete task_config.single;if(otherConfig){$('#form_item').find('[name="config[other][timer_again]"][value="'+toInt(otherConfig.timer_again)+'"]').prop('checked',!0)}
|
||||
if(singleConfig){singleConfig.open=toInt(singleConfig.open);$('#form_item').find('[name="config[single][open]"][value="'+singleConfig.open+'"]').prop('checked',!0);$('#form_item').find('[name="config[single][always]"][value="'+toInt(singleConfig.always)+'"]').prop('checked',!0);$('#form_item').find('[name="config[single][key]"]').val(singleConfig.key);if(singleConfig.open>0){showPanelCollapse('#task_single')}}
|
||||
for(var i in task_config){if((isObject(task_config[i])&&task_config[i].length>0)||(!isObject(task_config[i])&&task_config[i])){showConfig=!0;break}}
|
||||
var imgFuncs=isObject(task_config.img_funcs)?task_config.img_funcs:[];var fileFuncs=isObject(task_config.file_funcs)?task_config.file_funcs:[];for(var i in task_config){var ele=$('#form_item').find('[name="config['+i+']"]').eq(0);if(ele.length>0){if(ele.is('input:radio')){$('#form_item').find('[name="config['+i+']"][value="'+task_config[i]+'"]').prop('checked',!0).trigger('click')}else{ele.val(task_config[i]);if(ele.is('select')){ele.trigger('change')}}}}
|
||||
for(var i in imgFuncs){taskOpClass.add_config_img_func(imgFuncs[i])}
|
||||
for(var i in fileFuncs){taskOpClass.add_config_file_func(fileFuncs[i])}}
|
||||
if(taskData._show_config||showConfig){showPanelCollapse('#task_config')}
|
||||
if(fieldList&&fieldList.length>0){$('#config_img_name_custom .name-custom-path-fields').html('');$('#config_img_name_custom .name-custom-name-fields').html('');$('#config_file_name_custom .file-custom-path-fields').html('');$('#config_file_name_custom .file-custom-name-fields').html('');for(var i in fieldList){var fieldHtml='[字段:'+fieldList[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);$('#config_file_name_custom .file-custom-path-fields').append(fieldHtml);$('#config_file_name_custom .file-custom-name-fields').append(fieldHtml)}}}
|
||||
taskOpClass.show_img_wm_logo()},show_img_wm_logo:function(){var isGlobal=!1;var imgWmLogo=$('#form_item [name="config[img_wm_logo]"]').val();if(!imgWmLogo){isGlobal=!0;imgWmLogo=$('#img_wm_logo_show').attr('data-global')}
|
||||
$('#img_wm_logo_show').hide();var imgObj=$('#img_wm_logo_show img');imgObj.attr('src','');if(imgWmLogo){imgWmLogo=window.site_config.root+imgWmLogo;imgObj.attr('src',imgWmLogo+'?'+(new Date().getTime()));if(isGlobal){$('#img_wm_logo_show p.help-block').show();$('#img_wm_logo_show a.glyphicon-remove').hide()}else{$('#img_wm_logo_show p.help-block').hide();$('#img_wm_logo_show a.glyphicon-remove').show()}
|
||||
$('#img_wm_logo_show').show()}},add_config_img_func:function(funcData){pluginFuncOp.addHtml({funcData:funcData,funcName:'config[img_funcs][{id}][func]',funcParamName:'config[img_funcs][{id}][func_param]',tplId:'config_img_tpl_func',listId:'config_img_funcs',funcId:'config_img_func_{id}'},{module:'downloadImg',boxObj:'#form_item'})},add_config_file_func:function(funcData){pluginFuncOp.addHtml({funcData:funcData,funcName:'config[file_funcs][{id}][func]',funcParamName:'config[file_funcs][{id}][func_param]',tplId:'config_file_tpl_func',listId:'config_file_funcs',funcId:'config_file_func_{id}'},{module:'downloadFile',boxObj:'#form_item'})}}
|
||||
$('#img_wm_logo_show').show()}},add_config_img_func:function(funcData){pluginFuncOp.addHtml({funcData:funcData,funcName:'config[img_funcs][{id}][func]',funcParamName:'config[img_funcs][{id}][func_param]',tplId:'config_img_tpl_func',listId:'config_img_funcs',funcId:'config_img_func_{id}'},'downloadImg')},add_config_file_func:function(funcData){pluginFuncOp.addHtml({funcData:funcData,funcName:'config[file_funcs][{id}][func]',funcParamName:'config[file_funcs][{id}][func_param]',tplId:'config_file_tpl_func',listId:'config_file_funcs',funcId:'config_file_func_{id}'},'downloadFile')}}
|
|
@ -13,7 +13,7 @@ var className=$(this).prop('class');var sort='desc';if(className=='sorting_desc'
|
|||
window.location.href=ulink('task/list?show=list&order='+order+'&sort='+sort);return!1})},init_folder:function(openedTgIds){tasksOpClass.init_common();$('#task_list_folder').on('click','.taskgroup',function(){tasksOpClass.open_folder($(this).parents('tr').eq(0).attr('data-tgid'))});tasksOpClass.open_folder('0',function(){if(isObject(openedTgIds)){for(var i in openedTgIds){tasksOpClass.open_folder(openedTgIds[i])}}})},open_folder:function(tgid,successFunc){var trBox=$('#task_list_folder').find('tr[data-tgid="'+tgid+'"]').eq(0);var tgObj=trBox.find('.taskgroup');var tgLevel=trBox.attr('data-level');var loadingImg='<div class="'+(tgLevel>0?'loading-sm':'loading')+'"></div>';var opened=tgObj.hasClass('taskgroup-opened')?true:!1;var childs=$('#task_list_folder tr[data-parent-tgid="'+tgid+'"]');childs.css('display',(opened?'none':'table-row'));childs.each(function(){var cTgid=$(this).attr('data-tgid');var cOpened=$(this).hasClass('taskgroup-opened')?true:!1;if(cTgid){if(opened){$('#task_list_folder tr[data-parent-tgid="'+cTgid+'"]').css('display','none')}else{$('#task_list_folder tr[data-parent-tgid="'+cTgid+'"]').css('display',cOpened?'table-row':'none')}}});if(opened){tgObj.removeClass('taskgroup-opened');ajaxOpen({type:"GET",url:ulink('task/tgClose?tg_id=_tgid_',{'_tgid_':tgid}),dataType:"json",success:function(data){}})}else{tgObj.addClass('taskgroup-opened');if(trBox.attr('data-setted')!=1){tgObj.parents('td').eq(0).append(loadingImg);ajaxOpen({type:"GET",url:ulink('task/tgOpen?tg_id=_tgid_',{'_tgid_':tgid}),dataType:"json",success:function(data){if(tgLevel>0){tgObj.siblings('.loading-sm').remove()}else{trBox.hide()}
|
||||
tgLevel=parseInt(tgLevel);var leftSpace=tgLevel>0?('padding-left:'+tgLevel*25+'px;'):'';var html='';if(data.code==1){if(isNull(data.data)){html=null}else{var html='';if(data.data.tgList){var datalist=data.data.tgList;for(var i in datalist){html+='<tr data-level="'+(tgLevel+1)+'" data-parent-tgid="'+tgid+'" data-tgid="'+datalist[i].id+'"><td style="'+leftSpace+'"><a href="javascript:;" class="taskgroup"> <span class="glyphicon icon-folder-pre"></span> <span class="glyphicon icon-folder"></span> '+datalist[i].name+' </a></td><td colspan="6"></td></tr>'}}
|
||||
if(data.data.taskList){var todayDate=new Date();todayDate=todayDate.getFullYear()+'-'+(todayDate.getMonth()+1)+'-'+todayDate.getDate();var datalist=data.data.taskList;for(var i in datalist){var item=datalist[i];var auto=toInt(item.auto);if(!isObject(item._collected_info)){item._collected_info={}}
|
||||
html+='<tr data-parent-tgid="'+tgid+'" data-task-id="'+item.id+'"></td><td style="'+leftSpace+'">'+'<a href="'+ulink('task/save?id='+item.id)+'" class="edit">'+item.name+'</a></td><td class="sort"><input type="text" name="newsort['+item.id+']" class="form-control" value="'+item.sort+'" autocomplete="off" /></td>'+'<td><a href="javascript:;" class="auto" data-val="'+auto+'" style="color:'+(auto>0?'green':'red')+';" title="'+(item._timer_info?item._timer_info:'')+'">'+(window.tpl_lang['task_auto_'+auto])+'</a></td>'+'<td>'+item.addtime+'</td><td><label class="checkbox-inline chk-inline"><input type="checkbox" name="batch[]" value="'+item.id+'" /> '+item.caijitime+'</label>'+' <ul class="in-line"><li><a href="javascript:;" class="caiji">'+window.tpl_lang.caiji+'</a></li>'+' <li class="sep">|</li> <li><a href="javascript:;" class="houtai">后台</a></li></ul>'+'</td><td><ul class="in-line"><li>今日<a href="'+ulink('collected/list?task_id='+item.id+'&begin='+todayDate)+'" target="_blank">'+toInt(item._collected_info.today)+'</a>条</li>'+' <li class="sep">|</li> <li>总共<a href="'+ulink('collected/list?task_id='+item.id)+'" target="_blank">'+toInt(item._collected_info.total)+'</a>条</li></ul>'+'</td><td><ul class="in-line"><li><a href="'+ulink('collector/set?task_id='+item.id)+'">规则</a></li>'+' <li class="sep">|</li> <li><a href="'+ulink('release/set?task_id='+item.id)+'" title="'+(item._rele_module?item._rele_module:'')+'">发布</a></li>'+' <li class="sep">|</li> <li><a href="javascript:;" class="delete">'+window.tpl_lang.delete+'</a></li></ul></td></tr>'}}}}else{html=null}
|
||||
html+='<tr data-parent-tgid="'+tgid+'" data-task-id="'+item.id+'"></td><td style="'+leftSpace+'">'+'<a href="'+ulink('task/set?id='+item.id)+'" class="edit">'+item.name+'</a></td><td class="sort"><input type="text" name="newsort['+item.id+']" class="form-control" value="'+item.sort+'" autocomplete="off" /></td>'+'<td><a href="javascript:;" class="auto" data-val="'+auto+'" style="color:'+(auto>0?'green':'red')+';" title="'+(item._timer_info?item._timer_info:'')+'">'+(window.tpl_lang['task_auto_'+auto])+'</a></td>'+'<td>'+item.addtime+'</td><td><label class="checkbox-inline chk-inline"><input type="checkbox" name="batch[]" value="'+item.id+'" /> '+item.caijitime+'</label>'+' <ul class="in-line"><li><a href="javascript:;" class="caiji">'+window.tpl_lang.caiji+'</a></li>'+' <li class="sep">|</li> <li><a href="javascript:;" class="houtai">后台</a></li></ul>'+'</td><td><ul class="in-line"><li>今日<a href="'+ulink('collected/list?task_id='+item.id+'&begin='+todayDate)+'" target="_blank">'+toInt(item._collected_info.today)+'</a>条</li>'+' <li class="sep">|</li> <li>总共<a href="'+ulink('collected/list?task_id='+item.id)+'" target="_blank">'+toInt(item._collected_info.total)+'</a>条</li></ul>'+'</td><td><ul class="in-line"><li><a href="'+ulink('collector/set?task_id='+item.id)+'">规则</a></li>'+' <li class="sep">|</li> <li><a href="'+ulink('release/set?task_id='+item.id)+'" title="'+(item._rele_module?item._rele_module:'')+'">发布</a></li>'+' <li class="sep">|</li> <li><a href="javascript:;" class="delete">'+window.tpl_lang.delete+'</a></li></ul></td></tr>'}}}}else{html=null}
|
||||
html=isNull(html)?('<tr data-parent-tgid="'+tgid+'"><td style="'+leftSpace+'">'+window.tpl_lang.task_none_data+'</td><td colspan="6"></td></tr>'):html;trBox.attr('data-setted',1);trBox.after(html);if(successFunc&&typeof(successFunc)=='function'){successFunc()}}})}}},click_backstage_time:{},backstage_collect:function(ids){var isBatch=!1;if(isObject(ids)){isBatch=!0;ids=ids.join(',')}
|
||||
if(!tasksOpClass.click_backstage_time[ids]){tasksOpClass.click_backstage_time[ids]=(new Date()).getTime()}else{if((new Date()).getTime()-tasksOpClass.click_backstage_time[ids]<=3000){return!1}else{tasksOpClass.click_backstage_time[ids]=(new Date()).getTime()}}
|
||||
var url='';if(isBatch){url=ulink('admin/task/collectBatch?ids=_ids_&backstage_run=1',{'_ids_':ids})}else{url=ulink('admin/task/collect?id=_id_&backstage_run=1',{'_id_':ids})}
|
||||
|
|
|
@ -12,6 +12,6 @@ ToolJsonTree.prototype={constructor:ToolJsonTree,load:function(data){var $_o=thi
|
|||
html+='</ul>';$($_o.treeId+' .tool-json-tree').html(html)}}else{$($_o.treeId).html('未获取到JSON数组')}
|
||||
$($_o.treeId).on('click','.tree',function(){if($(this).hasClass('glyphicon-triangle-bottom')){$(this).removeClass('glyphicon-triangle-bottom');$(this).addClass('glyphicon-triangle-right');var hasSub=!1;$(this).siblings('ul').children('li').each(function(){var subTree=$(this).find('.tree').eq(0);if(subTree.length>0){subTree.removeClass('glyphicon-triangle-bottom').addClass('glyphicon-triangle-right').siblings('ul').hide();hasSub=!0}});$(this).siblings('ul').hide()}else{$(this).removeClass('glyphicon-triangle-right');$(this).addClass('glyphicon-triangle-bottom');$(this).siblings('ul').show();$(this).siblings('ul').children('li').each(function(){$(this).find('.tree').eq(0).removeClass('glyphicon-triangle-right').addClass('glyphicon-triangle-bottom').siblings('ul').show()})}})},node:function(node,list){var $_o=this;var html='<li>';var isList=!1;if(list){if(typeof(list)=='object'&&!$.isEmptyObject(list)){isList=!0}}
|
||||
if(isList){html+='<span class="glyphicon glyphicon-triangle-bottom tree"></span><span class="node">'+node+'</span><ul>';for(var i in list){html+=$_o.node(i,list[i])}
|
||||
html+='</ul>'}else{html+='<span class="node">'+node+': </span>';if(dataIsJson(list)||dataIsHtml(list)){var eleId='txt_'+generateUUID();list=list.replace(/\</g,'<').replace(/\>/g,'>');html+='<span class="val"><a href="javascript:;" data-tree-visualize="'+eleId+'">预览</a></span><div class="text"><textarea id="'+eleId+'" rows="3">'+list+'</textarea></div>'}else if(typeof(list)!='object'){html+='<span class="val">'+list+'</span>'}}
|
||||
html+='</ul>'}else{html+='<span class="node">'+node+': </span>';if(dataIsJson(list)||dataIsHtml(list)){var eleId='txt_'+generateUUID();list=htmlspecialchars(list);html+='<span class="val"><a href="javascript:;" data-tree-visualize="'+eleId+'">预览</a></span><div class="text"><textarea id="'+eleId+'" rows="3">'+list+'</textarea></div>'}else if(typeof(list)!='object'){html+='<span class="val">'+htmlspecialchars(list)+'</span>'}}
|
||||
html+='</li>';return html}}
|
||||
window.tool_json_tree=new ToolJsonTree()
|
|
@ -12,7 +12,8 @@ if(data.code==1){if(data.msg){toastr.success(data.msg)}
|
|||
formObj.find('.verify-img').trigger('click')}else{if(data.msg){toastr.error(data.msg)}}
|
||||
var dataData=isNull(data.data)?{}:data.data;if(dataData.js){eval(dataData.js)}},error:function(data){formObj.find('button[type="submit"]').removeAttr('disabled');toastr.error(data)}};if(formObj.attr('enctype')&&formObj.attr('enctype').toLowerCase()=='multipart/form-data'){var formData=new FormData(formObj[0]);settings.data=formData;settings.contentType=!1;settings.processData=!1}else{settings.data=formObj.serialize()}
|
||||
return settings}
|
||||
function htmlspecialchars(str){str=str.replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>').replace(/"/g,'"').replace(/'/g,''');return str}
|
||||
function htmlspecialchars(str){if(str&&typeof(str)=='string'){str=str.replace(/\&/g,'&').replace(/\</g,'<').replace(/\>/g,'>').replace(/\"/g,'"').replace(/\'/g,''')}
|
||||
return str}
|
||||
function setCookie(c_name,value,expiredays){var exdate=new Date();exdate.setDate(exdate.getDate()+expiredays);document.cookie=c_name+"="+escape(value)+((expiredays==null)?"":";expires="+exdate.toGMTString())+';path='+(window.site_config?(window.site_config.root?window.site_config.root:'/'):'/')}
|
||||
function getCookie(c_name){if(document.cookie.length>0){var c_start=document.cookie.indexOf(c_name+"=");if(c_start!=-1){c_start=c_start+c_name.length+1;var c_end=document.cookie.indexOf(";",c_start);if(c_end==-1)c_end=document.cookie.length;return unescape(document.cookie.substring(c_start,c_end))}}
|
||||
return""}
|
||||
|
@ -38,7 +39,7 @@ var win_ajax_request=ajaxOpen(ajaxSet);$('#myModal').on('hidden.bs.modal',functi
|
|||
function windowIframe(title,url,options){if(!options){options={}}
|
||||
options.full_height=1;modal(title,'<div class="loading" style="margin:10px;"></div>',options);var ifrHtml='<iframe id="myModalIframe" '+(url?(' src="'+url+'"'):'')+' width="100%" height="100%" frameborder="0" scrolling="yes"></iframe>';$('#myModal iframe').remove();$('#myModal .modal-body').html(ifrHtml);$('#myModal iframe').bind('load',function(){$('#myModal').attr('data-iframe-loaded',1);execVarFuncs(options.ifr_loaded_func)});$('#myModal').on('hidden.bs.modal',function(e){$('#myModal iframe').remove();execVarFuncs(options.close_func)});execVarFuncs(options.loaded_func)}
|
||||
function execVarFuncs(funcs){if(!isNull(funcs)){if(typeof(funcs)=='function'){funcs()}else if(typeof(funcs)=='object'){for(var i in funcs){var func=funcs[i];if(typeof(func)=='function'){func()}}}}}
|
||||
function ajaxDataMsg(data){if(typeof data=='string'){data=eval('('+data+')')}
|
||||
function ajaxDataMsg(data){if(typeof data=='string'){data=JSON.parse(data)}
|
||||
if(data.code==1){toastr.success(data.msg)}else{toastr.error(data.msg)}
|
||||
if(data.url){window.setTimeout("window.location.href='"+data.url+"';",2000)}}
|
||||
function checkall(obj,chkName){var status=$(obj).is(":checked")?true:!1;$("input[name='"+chkName+"']:checkbox").prop('checked',status)}
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -48,7 +48,7 @@ function trim_input_process($formName,$data=null){
|
|||
$data=input($formName,array(),null);
|
||||
}
|
||||
init_array($data);
|
||||
static $passModules=array('substr','insert','replace');
|
||||
static $passModules=array('substr','insert','replace','batch');
|
||||
foreach ($data as $k=>$v){
|
||||
init_array($v);
|
||||
if(isset($v['title'])){
|
||||
|
|
|
@ -13,22 +13,125 @@ namespace skycaiji\admin\controller;
|
|||
|
||||
class Api extends CollectController{
|
||||
/*任务api发布*/
|
||||
public function taskAction(){
|
||||
public function taskAction(){
|
||||
header('Content-type:text/json');
|
||||
\util\Param::set_task_close_echo();
|
||||
$taskId=input('id/d',0);
|
||||
$apiKey=input('key');
|
||||
$mrele=model('Release');
|
||||
$keyIsOk=false;
|
||||
$keyIsUrl=false;
|
||||
$releData=$mrele->where(array('task_id'=>$taskId))->find();
|
||||
if(!empty($releData)){
|
||||
$releData['config']=$mrele->compatible_config($releData['config']);
|
||||
$apiConfig=$releData['config']['api'];
|
||||
init_array($apiConfig);
|
||||
if(!empty($apiKey)){
|
||||
if(isset($apiConfig['url'])){
|
||||
|
||||
if($apiKey==$apiConfig['url']){
|
||||
$keyIsOk=true;
|
||||
}
|
||||
}elseif($apiKey==md5($apiConfig['key'])){
|
||||
$keyIsOk=true;
|
||||
}
|
||||
}
|
||||
if(isset($apiConfig['url'])){
|
||||
$keyIsUrl=true;
|
||||
}
|
||||
}
|
||||
if($keyIsUrl){
|
||||
set_g_sc('api_task_key_is_url', true);
|
||||
}
|
||||
if(!$keyIsOk){
|
||||
if($keyIsUrl){
|
||||
json(array('error'=>'密钥错误'))->send();
|
||||
}else{
|
||||
$this->_json('密钥错误');
|
||||
}
|
||||
}
|
||||
\util\Param::set_task_api_response();
|
||||
|
||||
register_shutdown_function(function(){
|
||||
\skycaiji\admin\model\Task::collecting_remove_all();
|
||||
|
||||
$taskIds=g_sc('backstage_task_ids');
|
||||
if(!empty($taskIds)&&is_array($taskIds)){
|
||||
\skycaiji\admin\model\CacheModel::getInstance('backstage_task')->db()->strict(false)->where('cname','in',$taskIds)->update(array('ctype'=>1,'data'=>time()));
|
||||
}
|
||||
});
|
||||
$this->collect_tasks($taskId, null, true);
|
||||
}
|
||||
/*任务单页采集*/
|
||||
public function singleAction(){
|
||||
\util\Param::set_task_close_echo();
|
||||
$taskId=input('id/d',0);
|
||||
$apiurl=input('apiurl');
|
||||
$mrele=model('Release');
|
||||
$releData=$mrele->where(array('task_id'=>$taskId))->find();
|
||||
if(empty($releData)){
|
||||
json(array('error'=>'没有发布设置!'))->send();
|
||||
}
|
||||
$releData['config']=$mrele->compatible_config($releData['config']);
|
||||
if($apiurl!=$releData['config']['api']['url']){
|
||||
json(array('error'=>'api地址错误!'))->send();
|
||||
}
|
||||
\util\Param::set_task_api_response();
|
||||
header('Content-type:text/json');
|
||||
$this->collect_tasks($taskId, null, true);
|
||||
\util\Param::set_collector_single();
|
||||
$taskId=input('id/d',0);
|
||||
$key=input('key');
|
||||
|
||||
$mtask=model('Task');
|
||||
$mcoll=model('Collector');
|
||||
$mrele=model('Release');
|
||||
$taskData=$mtask->getById($taskId);
|
||||
if(empty($taskData)){
|
||||
$this->_json(lang('task_error_empty_task'));
|
||||
}
|
||||
|
||||
$singleConfig=$taskData['config']['single'];
|
||||
init_array($singleConfig);
|
||||
if(empty($singleConfig['open'])){
|
||||
$this->_json('未开启单页采集模式');
|
||||
}
|
||||
if($singleConfig['key']){
|
||||
if($key!=md5($singleConfig['key'])){
|
||||
$this->_json('接口密钥错误');
|
||||
}
|
||||
}
|
||||
$taskTips='任务:'.$taskData['name'].' » ';
|
||||
if(empty($taskData['module'])){
|
||||
|
||||
$this->_json($taskTips.lang('task_error_null_module'));
|
||||
}
|
||||
if(!in_array($taskData['module'],config('allow_coll_modules'))){
|
||||
|
||||
$this->_json($taskTips.lang('coll_error_invalid_module'));
|
||||
}
|
||||
$collData=$mcoll->where(array('task_id'=>$taskData['id'],'module'=>$taskData['module']))->find();
|
||||
if(empty($collData)){
|
||||
|
||||
$this->_json($taskTips.lang('coll_error_empty_coll'));
|
||||
}
|
||||
$collData=$collData->toArray();
|
||||
$mtask->loadConfig($taskData);
|
||||
$acoll='\\skycaiji\\admin\\event\\C'.strtolower($collData['module']).'Single';
|
||||
$acoll=new $acoll();
|
||||
$acoll->init($collData);
|
||||
$releData=$mrele->where(array('task_id'=>$taskData['id']))->find();
|
||||
$arele=null;
|
||||
if($releData){
|
||||
|
||||
$releData=$releData->toArray();
|
||||
if($releData['module']&&$releData['module']!='api'){
|
||||
|
||||
$arele='\\skycaiji\\admin\\event\\R'.strtolower($releData['module']);
|
||||
$arele=new $arele();
|
||||
$arele->init($releData);
|
||||
$GLOBALS['_sc']['real_time_release']=&$arele;
|
||||
}
|
||||
}
|
||||
$fieldData=$acoll->collectSingle($singleConfig);
|
||||
init_array($fieldData);
|
||||
if($fieldData['collected']&&$arele&&is_empty(g_sc_c('caiji','real_time'))){
|
||||
|
||||
$arele->doExport($fieldData['collected']);
|
||||
}
|
||||
if(empty($fieldData['data'])){
|
||||
$msg=g_sc('collect_echo_msg_txt');
|
||||
$msg=strip_tags($msg);
|
||||
$this->_json($msg);
|
||||
}else{
|
||||
$this->_json('',1,$fieldData['data']);
|
||||
}
|
||||
}
|
||||
|
||||
/*api触发任务采集*/
|
||||
|
@ -174,4 +277,10 @@ class Api extends CollectController{
|
|||
|
||||
return json($updateResult);
|
||||
}
|
||||
|
||||
private function _json($msg='',$code=0,$data=array()){
|
||||
init_array($data);
|
||||
$result=array('code'=>$code,'msg'=>$msg,'data'=>$data);
|
||||
json($result)->send();
|
||||
}
|
||||
}
|
|
@ -471,7 +471,7 @@ class Backstage extends BaseController{
|
|||
if($collStatus=='none'){
|
||||
$taskStatus='已断开';
|
||||
}elseif($collStatus=='unlock'){
|
||||
$taskStatus='运行中断';
|
||||
$taskStatus='运行中断'.(g_sc_c('caiji','server')?'':(strtolower($_SERVER['SERVER_SOFTWARE']).'超时'));
|
||||
}
|
||||
}
|
||||
}else{
|
||||
|
@ -509,7 +509,7 @@ class Backstage extends BaseController{
|
|||
if($collStatus=='none'){
|
||||
$taskStatus='已断开';
|
||||
}elseif($collStatus=='unlock'){
|
||||
$taskStatus='运行中断';
|
||||
$taskStatus='运行中断'.(g_sc_c('caiji','server')?'':(strtolower($_SERVER['SERVER_SOFTWARE']).'超时'));
|
||||
}
|
||||
}
|
||||
}else{
|
||||
|
|
|
@ -19,35 +19,40 @@ class CollectController extends \skycaiji\admin\controller\BaseController{
|
|||
$echo=false;
|
||||
}
|
||||
if($echo){
|
||||
$logFilename=\skycaiji\admin\model\Collector::echo_msg_filename();
|
||||
if(!empty($logFilename)){
|
||||
if(!isset(self::$echo_msg_head)){
|
||||
self::$echo_msg_head=true;
|
||||
|
||||
if(file_exists($logFilename)){
|
||||
if(!is_empty(g_sc('is_test_echo_msg'))){
|
||||
|
||||
echo '<!--[echo_msg]-->'.$this->_echo_msg_str($strArgs,$color,$end_str,$div_style).'<!--[/echo_msg]-->';
|
||||
}else{
|
||||
$logFilename=\skycaiji\admin\model\Collector::echo_msg_filename();
|
||||
if(!empty($logFilename)){
|
||||
if(!isset(self::$echo_msg_head)){
|
||||
self::$echo_msg_head=true;
|
||||
|
||||
unlink($logFilename);
|
||||
}
|
||||
if(!file_exists($logFilename)){
|
||||
if(file_exists($logFilename)){
|
||||
|
||||
unlink($logFilename);
|
||||
}
|
||||
if(!file_exists($logFilename)){
|
||||
|
||||
write_dir_file($logFilename,'');
|
||||
}
|
||||
|
||||
write_dir_file($logFilename,'');
|
||||
try {
|
||||
register_shutdown_function(array($this,'echo_msg_end'));
|
||||
}catch (\Exception $ex){}
|
||||
|
||||
$cssJs='<!DOCTYPE html><style type="text/css">'
|
||||
.'body{padding:0;margin:10px;font-size:13px;color:#000;line-height:16px;}p{padding:0;margin:0;}'
|
||||
.'a{color:#aaa;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}'
|
||||
.'.echo-msg-clear{width:100%;overflow:hidden;clear:both;}'
|
||||
.'.echo-msg-lt{float:left;}'
|
||||
.'.echo-msg-lurl{float:left;margin-right:3px;height:16px;max-width:70%;}'
|
||||
.'@media(max-width:767px){.echo-msg-lurl{max-width:100%;}}'
|
||||
.'</style>';
|
||||
$this->_echo_msg_write($cssJs, $logFilename);
|
||||
}
|
||||
|
||||
try {
|
||||
register_shutdown_function(array($this,'echo_msg_end'));
|
||||
}catch (\Exception $ex){}
|
||||
|
||||
$cssJs='<!DOCTYPE html><style type="text/css">'
|
||||
.'body{padding:0;margin:10px;font-size:13px;color:#000;line-height:16px;}p{padding:0;margin:0;}'
|
||||
.'a{color:#aaa;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}'
|
||||
.'.echo-msg-clear{width:100%;overflow:hidden;clear:both;}'
|
||||
.'.echo-msg-lt{float:left;}'
|
||||
.'.echo-msg-lurl{float:left;margin-right:3px;height:16px;max-width:70%;}'
|
||||
.'@media(max-width:767px){.echo-msg-lurl{max-width:100%;}}'
|
||||
.'</style>';
|
||||
$this->_echo_msg_write($cssJs, $logFilename);
|
||||
$this->_echo_msg_write($this->_echo_msg_str($strArgs,$color,$end_str,$div_style), $logFilename);
|
||||
}
|
||||
$this->_echo_msg_write($this->_echo_msg_str($strArgs,$color,$end_str,$div_style), $logFilename);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -197,7 +202,7 @@ class CollectController extends \skycaiji\admin\controller\BaseController{
|
|||
|
||||
return $this->_collect_echo_end($isBatch, $taskTips.lang('coll_error_empty_coll'));
|
||||
}
|
||||
if(empty($releData)){
|
||||
if(empty($releData)||empty($releData['module'])){
|
||||
|
||||
return $this->_collect_echo_end($isBatch, $taskTips.lang('rele_error_empty_rele'));
|
||||
}
|
||||
|
@ -205,7 +210,6 @@ class CollectController extends \skycaiji\admin\controller\BaseController{
|
|||
$releData=$releData->toArray();
|
||||
$mtask->loadConfig($taskData);
|
||||
$taskData['caijitime']=intval($taskData['caijitime']);
|
||||
|
||||
$acoll='\\skycaiji\\admin\\event\\C'.strtolower($collData['module']);
|
||||
$acoll=new $acoll();
|
||||
$acoll->init($collData);
|
||||
|
@ -240,7 +244,7 @@ class CollectController extends \skycaiji\admin\controller\BaseController{
|
|||
if(g_sc_c('caiji','interval')>0){
|
||||
$waitTime=(60*g_sc_c('caiji','interval'))-abs($curTime-$taskData['caijitime']);
|
||||
if($waitTime>0){
|
||||
$msg=sprintf('%s再次采集需等待%s <a href="%s" target="_blank">设置运行间隔</a>',$taskTips,\skycaiji\admin\model\Config::wait_time_tips($waitTime),url('admin/task/save?show_config=1&id='.$taskData['id']));
|
||||
$msg=sprintf('%s再次采集需等待%s <a href="%s" target="_blank">设置采集运行间隔</a>',$taskTips,\skycaiji\admin\model\Config::wait_time_tips($waitTime),url('admin/task/set?show_config=1&id='.$taskData['id']));
|
||||
return $this->_collect_echo_end($isBatch,$msg,$releIsApi);
|
||||
}
|
||||
}
|
||||
|
@ -353,7 +357,11 @@ class CollectController extends \skycaiji\admin\controller\BaseController{
|
|||
|
||||
if(\util\Param::is_task_api_response()){
|
||||
|
||||
json(array('error'=>$msg))->send();
|
||||
if(!is_empty(g_sc('api_task_key_is_url'))){
|
||||
json(array('error'=>$msg))->send();
|
||||
}else{
|
||||
json(array('code'=>0,'msg'=>$msg,'data'=>[]))->send();
|
||||
}
|
||||
}
|
||||
}else{
|
||||
$this->echo_msg_exit($msg,'orange');
|
||||
|
|
|
@ -101,7 +101,7 @@ class Collected extends BaseController {
|
|||
$taskIds=array();
|
||||
foreach ($dataList as $itemK=>$item){
|
||||
$taskIds[$item['task_id']]=$item['task_id'];
|
||||
if(preg_match('/^\w+\:\/\//', $item['target'])){
|
||||
if(\util\Funcs::is_right_url($item['target'])){
|
||||
|
||||
$dataList[$itemK]['target']='<a href="'.$item['target'].'" target="_blank">'.$item['target'].'</a>';
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
namespace skycaiji\admin\controller;
|
||||
use skycaiji\admin\model\CacheModel;
|
||||
use skycaiji\admin\model\FuncApp;
|
||||
use util\Encrypt;
|
||||
|
||||
class Collector extends BaseController {
|
||||
public function indexAction(){
|
||||
|
@ -100,7 +101,7 @@ class Collector extends BaseController {
|
|||
$this->set_html_tags(
|
||||
'任务:'.$taskData['name'].'_'.lang('coll_set'),
|
||||
$htmlTagName,
|
||||
breadcrumb(array(array('url'=>url('task/save?id='.$taskData['id']),'title'=>lang('task').lang('separator').$taskData['name']),array('url'=>url('collector/set?task_id='.$taskData['id']),'title'=>lang('coll_set'))))
|
||||
breadcrumb(array(array('url'=>url('task/set?id='.$taskData['id']),'title'=>lang('task').lang('separator').$taskData['name']),array('url'=>url('collector/set?task_id='.$taskData['id']),'title'=>lang('coll_set'))))
|
||||
);
|
||||
|
||||
$this->assign('collData',$collData);
|
||||
|
@ -157,152 +158,144 @@ class Collector extends BaseController {
|
|||
}
|
||||
/*导出规则*/
|
||||
public function exportAction(){
|
||||
$coll_id=input('coll_id/d',0);
|
||||
|
||||
$mcoll=model('Collector');
|
||||
$collData=$mcoll->where(array('id'=>$coll_id))->find();
|
||||
if(empty($collData)){
|
||||
$this->error(lang('coll_error_empty_coll'));
|
||||
}
|
||||
$config=unserialize($collData['config']?:'');
|
||||
if(empty($config)){
|
||||
$this->error('规则不存在');
|
||||
}
|
||||
$taskData=model('Task')->getById($collData['task_id']);
|
||||
$name=$collData['name']?$collData['name']:$taskData['name'];
|
||||
$module=strtolower($collData['module']);
|
||||
|
||||
set_time_limit(600);
|
||||
$collector=array(
|
||||
'name'=>$name,
|
||||
'module'=>$module,
|
||||
'config'=>serialize($config),
|
||||
);
|
||||
$exportName='规则_'.$name;
|
||||
$exportTxt='/*skycaiji-collector-start*/'.base64_encode(serialize($collector)).'/*skycaiji-collector-end*/';
|
||||
|
||||
|
||||
$funcList=array('contentSign'=>array(),'process'=>array(),'processIf'=>array());
|
||||
|
||||
$contentSignFuncPages=array('front_urls','source_url','level_urls','url','relation_urls');
|
||||
foreach ($contentSignFuncPages as $page){
|
||||
$pageConfigList=array();
|
||||
if($page=='source_url'){
|
||||
$taskId=input('task_id/d',0);
|
||||
$mtask=model('Task');
|
||||
$mcoll=model('Collector');
|
||||
$taskData=$mtask->getById($taskId);
|
||||
$collData=$mcoll->where(array('task_id'=>$taskData['id'],'module'=>$taskData['module']))->find();
|
||||
if(empty($collData)){
|
||||
$this->error(lang('coll_error_empty_coll'));
|
||||
}
|
||||
$config=unserialize($collData['config']?:'');
|
||||
if(empty($config)){
|
||||
$this->error('规则不存在');
|
||||
}
|
||||
|
||||
$funcList=array('contentSign'=>array(),'process'=>array(),'processIf'=>array());
|
||||
|
||||
$contentSignFuncPages=array('front_urls','source_url','level_urls','url','relation_urls');
|
||||
foreach ($contentSignFuncPages as $page){
|
||||
$pageConfigList=array();
|
||||
if($page=='source_url'){
|
||||
|
||||
$pageConfigList=array(
|
||||
$config['source_config']
|
||||
);
|
||||
}elseif($page=='url'){
|
||||
|
||||
$pageConfigList=array(
|
||||
$config
|
||||
);
|
||||
}else{
|
||||
$pageConfigList=$config[$page];
|
||||
}
|
||||
if(is_array($pageConfigList)){
|
||||
foreach ($pageConfigList as $pageConfig){
|
||||
if(is_array($pageConfig['content_signs'])){
|
||||
foreach ($pageConfig['content_signs'] as $v){
|
||||
if(is_array($v)&&$v['func']){
|
||||
$funcList['contentSign'][$v['func']]=$v['func'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$processList=is_array($config['field_process'])?$config['field_process']:array();
|
||||
if(is_array($config['common_process'])){
|
||||
|
||||
$processList[]=$config['common_process'];
|
||||
}
|
||||
if($processList){
|
||||
foreach ($processList as $process){
|
||||
if(is_array($process)){
|
||||
foreach ($process as $v){
|
||||
if(is_array($v)){
|
||||
if($v['module']=='func'){
|
||||
$funcList['process'][$v['func_name']]=$v['func_name'];
|
||||
}elseif($v['module']=='if'){
|
||||
if(is_array($v['if_addon'])&&is_array($v['if_addon']['func'])){
|
||||
$funcList['processIf']=array_merge($funcList['processIf'],$v['if_addon']['func']);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$hasPlugin=false;
|
||||
foreach ($funcList as $funcModule=>$funcs){
|
||||
if(is_array($funcs)){
|
||||
foreach ($funcs as $k=>$v){
|
||||
if($v&&strpos($v,':')!==false){
|
||||
|
||||
$hasPlugin=true;
|
||||
$v=explode(':', $v);
|
||||
$v=$v[0];
|
||||
$funcs[$k]=$v;
|
||||
}else{
|
||||
|
||||
unset($funcs[$k]);
|
||||
}
|
||||
}
|
||||
$funcs=array_unique($funcs);
|
||||
$funcs=array_values($funcs);
|
||||
$funcList[$funcModule]=$funcs;
|
||||
}
|
||||
}
|
||||
|
||||
if(request()->isPost()){
|
||||
$pwd=input('pwd','','trim');
|
||||
$module=strtolower($collData['module']);
|
||||
$exportName=$collData['name']?$collData['name']:$taskData['name'];
|
||||
$collector=array(
|
||||
'name'=>$exportName,
|
||||
'module'=>$module,
|
||||
'config'=>serialize($config),
|
||||
);
|
||||
$exportTxt=base64_encode(serialize($collector));
|
||||
if(!empty($pwd)){
|
||||
|
||||
$pageConfigList=array(
|
||||
$config['source_config']
|
||||
);
|
||||
}elseif($page=='url'){
|
||||
|
||||
$pageConfigList=array(
|
||||
$config
|
||||
);
|
||||
}else{
|
||||
$pageConfigList=$config[$page];
|
||||
$edClass=new \util\EncryptDecrypt();
|
||||
$exportTxt=$edClass->encrypt(array('data'=>$exportTxt,'pwd'=>$pwd));
|
||||
$exportTxt=base64_encode(serialize($exportTxt));
|
||||
}
|
||||
if(is_array($pageConfigList)){
|
||||
foreach ($pageConfigList as $pageConfig){
|
||||
if(is_array($pageConfig['content_signs'])){
|
||||
foreach ($pageConfig['content_signs'] as $v){
|
||||
if(is_array($v)&&$v['func']){
|
||||
$funcList['contentSign'][$v['func']]=$v['func'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$processList=is_array($config['field_process'])?$config['field_process']:array();
|
||||
if(is_array($config['common_process'])){
|
||||
|
||||
$processList[]=$config['common_process'];
|
||||
}
|
||||
if($processList){
|
||||
foreach ($processList as $process){
|
||||
if(is_array($process)){
|
||||
foreach ($process as $v){
|
||||
if(is_array($v)){
|
||||
if($v['module']=='func'){
|
||||
$funcList['process'][$v['func_name']]=$v['func_name'];
|
||||
}elseif($v['module']=='if'){
|
||||
if(is_array($v['if_addon'])&&is_array($v['if_addon']['func'])){
|
||||
$funcList['processIf']=array_merge($funcList['processIf'],$v['if_addon']['func']);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$hasFunc=false;
|
||||
foreach ($funcList as $funcModule=>$funcs){
|
||||
if(is_array($funcs)){
|
||||
foreach ($funcs as $k=>$v){
|
||||
if($v&&strpos($v,':')!==false){
|
||||
|
||||
$hasFunc=true;
|
||||
$v=explode(':', $v);
|
||||
$v=$v[0];
|
||||
$funcs[$k]=$v;
|
||||
}else{
|
||||
|
||||
unset($funcs[$k]);
|
||||
}
|
||||
}
|
||||
$funcs=array_unique($funcs);
|
||||
$funcs=array_values($funcs);
|
||||
$funcList[$funcModule]=$funcs;
|
||||
}
|
||||
}
|
||||
|
||||
if($hasFunc){
|
||||
$exportTxt='/*skycaiji-collector-start*/'.$exportTxt.'/*skycaiji-collector-end*/';
|
||||
|
||||
if(!input('?export_func')){
|
||||
if($hasPlugin){
|
||||
|
||||
$tips='导出规则';
|
||||
$this->set_html_tags($tips,$tips,breadcrumb(array($tips)));
|
||||
$this->assign('coll_id',$coll_id);
|
||||
return $this->fetch();
|
||||
}else{
|
||||
$export_func=input('export_func/d');
|
||||
if($export_func&&is_array($funcList)){
|
||||
$export_plugin=input('export_plugin/d');
|
||||
if($export_plugin&&is_array($funcList)){
|
||||
|
||||
$exportName.='(含插件)';
|
||||
$exportName.='.含插件';
|
||||
foreach ($funcList as $funcModule=>$funcs){
|
||||
if(is_array($funcs)){
|
||||
foreach ($funcs as $func){
|
||||
$pluginData=controller('admin/Develop','controller')->get_plugin_data('func',$func);
|
||||
$pluginData=controller('admin/Develop','controller')->_export_plugin_data('func',$funcModule,$func,$pwd);
|
||||
if(empty($pluginData['success'])){
|
||||
$tips=model('FuncApp')->get_func_module_val($funcModule,'name').'函数:'.$func.' » ';
|
||||
$this->error($tips.$pluginData['msg']);
|
||||
$this->error($pluginData['msg']);
|
||||
}
|
||||
$pluginData=$pluginData['plugin'];
|
||||
$exportTxt.="\r\n".'/*skycaiji-plugin-start*/'.base64_encode(serialize($pluginData)).'/*skycaiji-plugin-end*/';
|
||||
$exportTxt.="\r\n".$pluginData['plugin_txt'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ob_start();
|
||||
header("Expires: 0" );
|
||||
header("Pragma:public" );
|
||||
header("Cache-Control:must-revalidate,post-check=0,pre-check=0" );
|
||||
header("Cache-Control:public");
|
||||
header("Content-Type:application/octet-stream" );
|
||||
|
||||
header("Content-transfer-encoding: binary");
|
||||
header("Accept-Length: " .mb_strlen($exportTxt));
|
||||
if (preg_match("/MSIE/i", $_SERVER["HTTP_USER_AGENT"])) {
|
||||
header('Content-Disposition: attachment; filename="'.urlencode($exportName).'.scj"');
|
||||
$exportName.=($pwd?'.加密':'').'.规则';
|
||||
\util\Tools::browser_export_scj($exportName, $exportTxt);
|
||||
}else{
|
||||
header('Content-Disposition: attachment; filename="'.$exportName.'.scj"');
|
||||
$this->set_html_tags(
|
||||
'导出规则',
|
||||
'导出规则至本地',
|
||||
breadcrumb(array(array('url'=>url('task/set?id='.$taskData['id']),'title'=>lang('task').lang('separator').$taskData['name']),array('url'=>url('collector/set?task_id='.$taskData['id']),'title'=>lang('coll_set'))))
|
||||
);
|
||||
$this->assign('task_id',$taskId);
|
||||
$this->assign('hasPlugin',$hasPlugin);
|
||||
return $this->fetch();
|
||||
}
|
||||
echo $exportTxt;
|
||||
ob_end_flush();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -181,7 +181,7 @@ 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(empty($field['sign']))$this->error('请输入'.lang('field_module_sign'));
|
||||
break;
|
||||
|
@ -288,14 +288,14 @@ class Cpattern extends BaseController {
|
|||
|
||||
if(is_empty(g_sc_c('download_img','download_img'))){
|
||||
if(!empty($taskData['config']['download_img'])){
|
||||
$downImgUrl=url('task/save?id='.$taskId);
|
||||
$downImgUrl=url('task/set?id='.$taskId);
|
||||
}
|
||||
}else{
|
||||
$downImgUrl='';
|
||||
}
|
||||
if(is_empty(g_sc_c('download_file','download_file'))){
|
||||
if(!empty($taskData['config']['download_file'])){
|
||||
$downFileUrl=url('task/save?id='.$taskId);
|
||||
$downFileUrl=url('task/set?id='.$taskId);
|
||||
}
|
||||
}else{
|
||||
$downFileUrl='';
|
||||
|
@ -303,7 +303,7 @@ class Cpattern extends BaseController {
|
|||
|
||||
if(is_empty(g_sc_c('translate','open'))){
|
||||
if(!empty($taskData['config']['translate'])){
|
||||
$transUrl=url('task/save?id='.$taskId);
|
||||
$transUrl=url('task/set?id='.$taskId);
|
||||
}
|
||||
}else{
|
||||
$transUrl='';
|
||||
|
@ -427,10 +427,6 @@ class Cpattern extends BaseController {
|
|||
$this->error('请输入网址');
|
||||
}
|
||||
|
||||
if(!preg_match('/^\w+\:\/\/[^\r\n]+/i',$front_url['url'])){
|
||||
$this->error('请输入正确的网址格式');
|
||||
}
|
||||
|
||||
$front_url['use_cookie']=intval($front_url['use_cookie']);
|
||||
$front_url['use_cookie_img']=intval($front_url['use_cookie_img']);
|
||||
$front_url['use_cookie_file']=intval($front_url['use_cookie_file']);
|
||||
|
|
|
@ -17,7 +17,7 @@ class CpatternTest extends BaseController {
|
|||
public $eCpattern=null;
|
||||
public function __construct($request = null){
|
||||
parent::__construct($request);
|
||||
$this->eCpattern= new \skycaiji\admin\event\Cpattern();
|
||||
$this->eCpattern= new \skycaiji\admin\event\CpatternSingle();
|
||||
}
|
||||
/*浏览器*/
|
||||
public function browserAction(){
|
||||
|
@ -407,66 +407,12 @@ class CpatternTest extends BaseController {
|
|||
$input_urls=array();
|
||||
|
||||
if($test=='get_fields'){
|
||||
|
||||
if(is_array($this->eCpattern->config['new_field_list'])){
|
||||
foreach ($this->eCpattern->config['new_field_list'] as $field){
|
||||
list($fPageType,$fPageName)=$this->eCpattern->page_source_split($field['field']['source']);
|
||||
if(empty($fPageType)){
|
||||
|
||||
if($field['field']['module']=='sign'){
|
||||
|
||||
if(empty($this->eCpattern->config['level_urls'])){
|
||||
$input_urls['source_url']=$inputedUrls['source_url'];
|
||||
}else{
|
||||
|
||||
$endLevelNum=count($this->eCpattern->config['level_urls']);
|
||||
$endLevel=$this->eCpattern->config['level_urls'][$endLevelNum-1];
|
||||
$input_urls['level_url'][$endLevelNum]=array('level'=>$endLevelNum,'name'=>$endLevel['name'],'url'=>$inputedUrls['level_'.$endLevelNum]);
|
||||
}
|
||||
}
|
||||
}elseif('source_url'==$fPageType){
|
||||
|
||||
$input_urls['source_url']=$inputedUrls['source_url'];
|
||||
}elseif('level_url'==$fPageType){
|
||||
|
||||
if(is_array($this->eCpattern->config['level_urls'])){
|
||||
foreach($this->eCpattern->config['level_urls'] as $levIx=>$levVal){
|
||||
if($field['field']['source']==$this->eCpattern->page_source_merge('level_url',$levVal['name'])){
|
||||
|
||||
$level=$levIx+1;
|
||||
if($field['field']['module']=='sign'){
|
||||
|
||||
if($level==1){
|
||||
|
||||
$input_urls['source_url']=$inputedUrls['source_url'];
|
||||
}else{
|
||||
|
||||
$prevLevel=$level-1;
|
||||
$input_urls['level_url'][$prevLevel]=array('level'=>$prevLevel,'name'=>$this->eCpattern->get_config('level_urls',$prevLevel-1,'name'),'url'=>$inputedUrls['level_'.$prevLevel]);
|
||||
}
|
||||
}
|
||||
|
||||
$input_urls['level_url'][$level]=array('level'=>$level,'name'=>$levVal['name'],'url'=>$inputedUrls['level_'.$level]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}elseif('relation_url'==$fPageType){
|
||||
|
||||
$this->_page_input_urls(true,'relation_url',$fPageName,$inputedUrls,$input_urls);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$pageSigns=$this->eCpattern->parent_page_signs($pageType,$pageName,'url_web');
|
||||
$this->_page_signs_input_urls(true,true,$pageSigns,$inputedUrls,$input_urls);
|
||||
$pageSigns=$this->eCpattern->parent_page_signs($pageType,$pageName,'renderer');
|
||||
$this->_page_signs_input_urls(true,true,$pageSigns,$inputedUrls,$input_urls);
|
||||
$input_urls=$this->eCpattern->single_get_input_urls($inputedUrls, $input_urls);
|
||||
}elseif($test=='get_html'||$test=='get_browser'){
|
||||
|
||||
if(!empty($pageType)){
|
||||
|
||||
$this->_page_input_urls($pageType=='url'?true:false,$pageType,$pageName,$inputedUrls,$input_urls);
|
||||
$this->eCpattern->single_input_urls($pageType=='url'?true:false,$pageType,$pageName,$inputedUrls,$input_urls);
|
||||
}
|
||||
}elseif($test=='get_signs'){
|
||||
if(empty($pageType)){
|
||||
|
@ -477,15 +423,15 @@ class CpatternTest extends BaseController {
|
|||
foreach($this->eCpattern->config['level_urls'] as $levIx=>$levVal){
|
||||
|
||||
$level=$levIx+1;
|
||||
$input_urls['level_url'][$level]=array('level'=>$level,'name'=>$levVal['name'],'url'=>$inputedUrls['level_'.$level]);
|
||||
$input_urls['level_url'][$level]=array('level'=>$level,'name'=>$levVal['name'],'url'=>$inputedUrls['level'.$level.'_url']);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
|
||||
$this->_page_input_urls($pageType=='url'?true:false,$pageType,$pageName,$inputedUrls,$input_urls);
|
||||
$this->eCpattern->single_input_urls($pageType=='url'?true:false,$pageType,$pageName,$inputedUrls,$input_urls);
|
||||
if(input('?signs_cur_all')){
|
||||
|
||||
$prevPageSource=$this->_input_parent_page($pageType=='url'?true:false,$pageType,$pageName);
|
||||
$prevPageSource=$this->eCpattern->single_parent_page($pageType=='url'?true:false,$pageType,$pageName);
|
||||
if($prevPageSource){
|
||||
|
||||
list($prevPageType,$prevPageName)=$this->eCpattern->page_source_split($prevPageSource);
|
||||
|
@ -494,7 +440,7 @@ class CpatternTest extends BaseController {
|
|||
foreach ($this->eCpattern->config['level_urls'] as $k=>$v){
|
||||
if($v['name']==$prevPageName){
|
||||
$curLevelNum=$k+1;
|
||||
$input_urls['level_url'][$curLevelNum]=array('level'=>$curLevelNum,'name'=>$v['name'],'url'=>$inputedUrls['level_'.$curLevelNum]);
|
||||
$input_urls['level_url'][$curLevelNum]=array('level'=>$curLevelNum,'name'=>$v['name'],'url'=>$inputedUrls['level'.$curLevelNum.'_url']);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -503,33 +449,34 @@ class CpatternTest extends BaseController {
|
|||
$input_urls[$prevPageType]=$inputedUrls[$prevPageType]?$inputedUrls[$prevPageType]:'';
|
||||
}
|
||||
|
||||
$this->_page_input_urls($prevPageType=='url'?true:false,$prevPageType,$prevPageName,$inputedUrls,$input_urls);
|
||||
$this->eCpattern->single_input_urls($prevPageType=='url'?true:false,$prevPageType,$prevPageName,$inputedUrls,$input_urls);
|
||||
}
|
||||
}
|
||||
}
|
||||
}elseif($test=='get_relation_urls'){
|
||||
|
||||
$this->_page_input_urls(true,'url','',$inputedUrls,$input_urls);
|
||||
$this->eCpattern->single_input_urls(true,'url','',$inputedUrls,$input_urls);
|
||||
if(is_array($this->eCpattern->config['relation_urls'])){
|
||||
foreach ($this->eCpattern->config['relation_urls'] as $relationUrl){
|
||||
$this->_page_input_urls(true,'relation_url',$relationUrl['name'],$inputedUrls,$input_urls);
|
||||
$this->eCpattern->single_input_urls(true,'relation_url',$relationUrl['name'],$inputedUrls,$input_urls);
|
||||
}
|
||||
}
|
||||
}elseif($test=='get_pagination'){
|
||||
|
||||
$this->_page_input_urls($pageType=='url'?true:false,$pageType,$pageName,$inputedUrls,$input_urls);
|
||||
$this->eCpattern->single_input_urls($pageType=='url'?true:false,$pageType,$pageName,$inputedUrls,$input_urls);
|
||||
}
|
||||
|
||||
$this->_input_urls_parent($pageType=='url'?true:false, $input_urls, $inputedUrls, $input_urls);
|
||||
|
||||
if(is_array($input_urls['level_url'])){
|
||||
if($test!='get_fields'){
|
||||
|
||||
ksort($input_urls['level_url']);
|
||||
}
|
||||
|
||||
if($this->eCpattern->source_is_url()){
|
||||
|
||||
unset($input_urls['source_url']);
|
||||
$this->eCpattern->single_urls_parent($pageType=='url'?true:false, $input_urls, $inputedUrls, $input_urls);
|
||||
if(is_array($input_urls['level_url'])){
|
||||
|
||||
ksort($input_urls['level_url']);
|
||||
}
|
||||
if($this->eCpattern->source_is_url()){
|
||||
|
||||
unset($input_urls['source_url']);
|
||||
}
|
||||
}
|
||||
|
||||
$pageOpenedList=array();
|
||||
|
@ -552,186 +499,8 @@ class CpatternTest extends BaseController {
|
|||
return $this->fetch('cpattern:test_input_url');
|
||||
}
|
||||
|
||||
|
||||
private function _page_input_urls($isContUrl,$pageType,$pageName,$inputedUrls,&$input_urls){
|
||||
$pageSigns=$this->eCpattern->parent_page_signs($pageType,$pageName);
|
||||
$this->_page_signs_input_urls($isContUrl,false,$pageSigns,$inputedUrls,$input_urls);
|
||||
$pageSigns=$this->eCpattern->parent_page_signs($pageType,$pageName,'url_web');
|
||||
$this->_page_signs_input_urls($isContUrl,true,$pageSigns,$inputedUrls,$input_urls);
|
||||
$pageSigns=$this->eCpattern->parent_page_signs($pageType,$pageName,'renderer');
|
||||
$this->_page_signs_input_urls($isContUrl,true,$pageSigns,$inputedUrls,$input_urls);
|
||||
}
|
||||
|
||||
|
||||
private function _page_signs_input_urls($isContUrl,$inPageConfig,$pageSigns,$inputedUrls,&$input_urls){
|
||||
$iptUrls=array();
|
||||
if(!empty($pageSigns)){
|
||||
if($inPageConfig){
|
||||
|
||||
if(!empty($pageSigns['cur'])&&(!empty($pageSigns['cur']['url'])||!empty($pageSigns['cur']['area']))){
|
||||
|
||||
$prevPageSource=$this->_input_parent_page($isContUrl, $pageSigns['cur']['page_type'], $pageSigns['cur']['page_name']);
|
||||
if($prevPageSource){
|
||||
|
||||
list($prevPageType,$prevPageName)=$this->eCpattern->page_source_split($prevPageSource);
|
||||
if($prevPageType=='level_url'){
|
||||
if(is_array($this->eCpattern->config['level_urls'])){
|
||||
foreach ($this->eCpattern->config['level_urls'] as $k=>$v){
|
||||
if($v['name']==$prevPageName){
|
||||
$curLevelNum=$k+1;
|
||||
$iptUrls['level_url'][$curLevelNum]=array('level'=>$curLevelNum,'name'=>$v['name'],'url'=>$inputedUrls['level_'.$curLevelNum]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
$iptUrls[$prevPageType]=$inputedUrls[$prevPageType]?$inputedUrls[$prevPageType]:'';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(!empty($pageSigns['source_url'])&&is_array($pageSigns['source_url'])){
|
||||
if(!empty($pageSigns['source_url']['content'])){
|
||||
|
||||
$iptUrls['source_url']=$inputedUrls['source_url']?$inputedUrls['source_url']:'';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(!empty($pageSigns['level_url'])&&is_array($pageSigns['level_url'])){
|
||||
|
||||
$signLevels=array_keys($pageSigns['level_url']);
|
||||
if(is_array($this->eCpattern->config['level_urls'])){
|
||||
foreach ($this->eCpattern->config['level_urls'] as $levIx=>$levVal){
|
||||
|
||||
|
||||
$level=$levIx+1;
|
||||
if(in_array($levVal['name'],$signLevels)){
|
||||
|
||||
if($level==1){
|
||||
|
||||
$iptUrls['source_url']=$inputedUrls['source_url']?$inputedUrls['source_url']:'';
|
||||
}else{
|
||||
|
||||
$prevLevel=$level-1;
|
||||
$iptUrls['level_url'][$prevLevel]=array('level'=>$prevLevel,'name'=>$this->eCpattern->get_config('level_urls',$prevLevel-1,'name'),'url'=>$inputedUrls['level_'.$prevLevel]);
|
||||
}
|
||||
|
||||
$iptUrls['level_url'][$level]=array('level'=>$level,'name'=>$levVal['name'],'url'=>$inputedUrls['level_'.$level]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!$isContUrl){
|
||||
|
||||
if(!empty($pageSigns['url'])||(!empty($pageSigns['relation_url'])&&is_array($pageSigns['relation_url']))){
|
||||
|
||||
$iptUrls['url']=$inputedUrls['url']?$inputedUrls['url']:'';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($iptUrls['source_url'])){
|
||||
$input_urls['source_url']=$iptUrls['source_url'];
|
||||
}
|
||||
if(is_array($iptUrls['level_url'])){
|
||||
foreach ($iptUrls['level_url'] as $k=>$v){
|
||||
$input_urls['level_url'][$k]=$v;
|
||||
}
|
||||
}
|
||||
if(isset($iptUrls['url'])){
|
||||
$input_urls['url']=$iptUrls['url'];
|
||||
}
|
||||
|
||||
return $iptUrls;
|
||||
}
|
||||
|
||||
|
||||
private function _input_urls_parent($isContUrl,$curInputUrls,$inputedUrls,&$input_urls){
|
||||
$levelNames=array();
|
||||
if(is_array($curInputUrls)&&is_array($curInputUrls['level_url'])){
|
||||
foreach ($curInputUrls['level_url'] as $v){
|
||||
$levelNames[$v['name']]=$v['name'];
|
||||
}
|
||||
}
|
||||
if($levelNames){
|
||||
foreach ($levelNames as $levelName){
|
||||
$mergeTypes=array(''=>false,'url_web'=>true,'renderer'=>true);
|
||||
foreach ($mergeTypes as $mtk=>$mtv){
|
||||
$pageSigns=$this->eCpattern->parent_page_signs('level_url',$levelName,$mtk);
|
||||
$iptUrls=$this->_page_signs_input_urls($isContUrl,$mtv,$pageSigns,$inputedUrls,$input_urls);
|
||||
if(is_array($iptUrls['level_url'])){
|
||||
|
||||
foreach ($iptUrls['level_url'] as $k=>$v){
|
||||
if(isset($input_urls['level_url'][$k])){
|
||||
unset($iptUrls['level_url'][$k]);
|
||||
}
|
||||
}
|
||||
if(!empty($iptUrls['level_url'])){
|
||||
$this->_input_urls_parent($isContUrl,$iptUrls, $inputedUrls, $input_urls);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private function _input_parent_page($isContUrl,$pageType,$pageName){
|
||||
$prevPageType='';
|
||||
$prevPageName='';
|
||||
|
||||
if($pageType=='url'){
|
||||
|
||||
if(empty($this->eCpattern->config['level_urls'])){
|
||||
|
||||
$prevPageType='source_url';
|
||||
$prevPageName='';
|
||||
}else{
|
||||
|
||||
$endLevelNum=count($this->eCpattern->config['level_urls']);
|
||||
$prevPageType='level_url';
|
||||
$prevPageName=$this->eCpattern->config['level_urls'][$endLevelNum-1]['name'];
|
||||
}
|
||||
}elseif($pageType=='level_url'){
|
||||
|
||||
$prevLevelNum=-1;
|
||||
$prevLevel=null;
|
||||
if(is_array($this->eCpattern->config['level_urls'])){
|
||||
foreach ($this->eCpattern->config['level_urls'] as $k=>$v){
|
||||
$prevLevelNum=$k;
|
||||
if($v['name']==$pageName){
|
||||
|
||||
break;
|
||||
}
|
||||
$prevLevel=$v;
|
||||
}
|
||||
}
|
||||
if($prevLevelNum>-1){
|
||||
if($prevLevelNum==0){
|
||||
|
||||
$prevPageType='source_url';
|
||||
$prevPageName='';
|
||||
}else{
|
||||
|
||||
$prevPageType='level_url';
|
||||
$prevPageName=$prevLevel['name'];
|
||||
}
|
||||
}
|
||||
}elseif($pageType=='relation_url'){
|
||||
|
||||
if(!$isContUrl){
|
||||
|
||||
$prevPageType='url';
|
||||
$prevPageName='';
|
||||
}
|
||||
}
|
||||
return $this->eCpattern->page_source_merge($prevPageType, $prevPageName);
|
||||
}
|
||||
|
||||
public function get_fieldsAction(){
|
||||
set_g_sc('is_test_echo_msg', 1);
|
||||
$collData=$this->_test_init();
|
||||
$this->_get_test_content('get_fields',$collData);
|
||||
}
|
||||
|
@ -758,7 +527,7 @@ class CpatternTest extends BaseController {
|
|||
$collData=$this->_test_init();
|
||||
|
||||
$test_url=input('test_url','','trim');
|
||||
if($test_url&&!preg_match('/^\w+\:\/\//',$test_url)){
|
||||
if(!\util\Funcs::is_right_url($test_url)){
|
||||
|
||||
$test_url='http://'.$test_url;
|
||||
}
|
||||
|
@ -785,8 +554,8 @@ class CpatternTest extends BaseController {
|
|||
if(!empty($pageType)){
|
||||
|
||||
$input_urls=array();
|
||||
$this->_page_input_urls($pageType=='url'?true:false,$pageType,$pageName,$inputedUrls,$input_urls);
|
||||
$this->_input_urls_parent($pageType=='url'?true:false, $input_urls, $inputedUrls, $input_urls);
|
||||
$this->eCpattern->single_input_urls($pageType=='url'?true:false,$pageType,$pageName,$inputedUrls,$input_urls);
|
||||
$this->eCpattern->single_urls_parent($pageType=='url'?true:false, $input_urls, $inputedUrls, $input_urls);
|
||||
|
||||
if(isset($input_urls['source_url'])&&empty($input_urls['source_url'])){
|
||||
$this->error('请输入起始页',$errorUrl);
|
||||
|
@ -812,6 +581,16 @@ class CpatternTest extends BaseController {
|
|||
|
||||
$html=\util\Funcs::html_clear_js($html);
|
||||
|
||||
|
||||
$scjNames=array();
|
||||
$html=preg_replace_callback('/(<[a-zA-Z]+\b[^<>]*)(>)/', function($match)use(&$scjNames){
|
||||
do{
|
||||
$scjName=\util\Funcs::uniqid();
|
||||
}while($scjNames[$scjName]);
|
||||
$scjNames[$scjName]=1;
|
||||
return $match[1].' skycaiji-no="'.$scjName.'"'.$match[2];
|
||||
}, $html);
|
||||
|
||||
$configUnset=array();
|
||||
$configSetted=array();
|
||||
if(!$this->eCpattern->get_config('url_complete')){
|
||||
|
@ -824,10 +603,13 @@ class CpatternTest extends BaseController {
|
|||
$configSetted[]='代理';
|
||||
}
|
||||
|
||||
$htmlTxt=str_replace(array('&','<','>'), array('&','<','>'), $html);
|
||||
|
||||
header("Content-type:text/html;charset=utf-8");
|
||||
|
||||
$this->assign('configTips',array('setted'=>$configSetted,'unset'=>$configUnset));
|
||||
$this->assign('html',$html);
|
||||
$this->assign('htmlTxt',$htmlTxt);
|
||||
return $this->fetch('cpattern:browser');
|
||||
}else{
|
||||
|
||||
|
@ -838,21 +620,11 @@ class CpatternTest extends BaseController {
|
|||
}
|
||||
}
|
||||
private function _get_test_content($testName,$collData){
|
||||
|
||||
$test_url=input('test_url','','trim');
|
||||
if(empty($test_url)){
|
||||
$this->error('请输入网址');
|
||||
}
|
||||
if(!preg_match('/^\w+\:\/\//',$test_url)){
|
||||
|
||||
$test_url='http://'.$test_url;
|
||||
}
|
||||
|
||||
$pageSource=input('page_source','url');
|
||||
|
||||
$pageType='';
|
||||
$pageName='';
|
||||
|
||||
$pageSource=input('page_source','url');
|
||||
if(in_array($testName,array('get_html','get_browser','get_signs','get_pagination'))){
|
||||
|
||||
list($pageType,$pageName)=$this->eCpattern->page_source_split($pageSource);
|
||||
|
@ -862,111 +634,22 @@ class CpatternTest extends BaseController {
|
|||
$pageName='';
|
||||
}
|
||||
|
||||
|
||||
if($pageType=='front_url'){
|
||||
$this->eCpattern->cur_front_urls[$pageName]=$test_url;
|
||||
$this->eCpattern->collFrontUrls(true);
|
||||
}elseif($pageType=='source_url'){
|
||||
$this->eCpattern->cur_source_url=$test_url;
|
||||
}elseif($pageType=='level_url'){
|
||||
$this->eCpattern->cur_level_urls[$pageName]=$test_url;
|
||||
}elseif($pageType=='url'){
|
||||
$this->eCpattern->cur_cont_url=$test_url;
|
||||
}
|
||||
|
||||
if(input('?source_url')){
|
||||
|
||||
$this->eCpattern->cur_source_url=input('source_url','','trim');
|
||||
if(empty($this->eCpattern->cur_source_url)){
|
||||
$this->error('请输入起始页');
|
||||
}
|
||||
}
|
||||
$inputLevels=array();
|
||||
foreach (input('param.') as $k=>$v){
|
||||
|
||||
if(preg_match('/^level_(\d+)$/',$k,$mLevel)){
|
||||
if(preg_match('/^level(\d+)_url$/',$k,$mLevel)){
|
||||
|
||||
$mLevel=intval($mLevel[1])-1;
|
||||
$mLevel=intval($mLevel[1]);
|
||||
$inputLevels[$mLevel]=input($k,'','trim');
|
||||
}
|
||||
}
|
||||
ksort($inputLevels);
|
||||
foreach ($inputLevels as $k=>$v){
|
||||
$levelName=$this->eCpattern->get_config('level_urls',$k,'name');
|
||||
$this->eCpattern->cur_level_urls[$levelName]=$v;
|
||||
if(empty($v)){
|
||||
$this->error('请输入多级页:'.$levelName);
|
||||
}
|
||||
}
|
||||
if(input('?url')){
|
||||
|
||||
$this->eCpattern->cur_cont_url=input('url','','trim');
|
||||
if(empty($this->eCpattern->cur_cont_url)){
|
||||
$this->error('请输入内容页');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(!empty($this->eCpattern->cur_source_url)){
|
||||
|
||||
|
||||
if($pageType!='front_url'&&$pageType!='source_url'){
|
||||
if(empty($this->eCpattern->config['level_urls'])){
|
||||
|
||||
$this->eCpattern->getContUrls($this->eCpattern->cur_source_url,false);
|
||||
}else{
|
||||
|
||||
$this->eCpattern->getLevelUrls($this->eCpattern->cur_source_url,1,false);
|
||||
}
|
||||
}
|
||||
|
||||
$this->eCpattern->get_page_html($this->eCpattern->cur_source_url, 'source_url', '');
|
||||
}
|
||||
if(!empty($this->eCpattern->cur_level_urls)){
|
||||
|
||||
|
||||
$levelIsEnd=false;
|
||||
$levelCurNum=0;
|
||||
$levelCount=count($this->eCpattern->config['level_urls']);
|
||||
foreach ($this->eCpattern->config['level_urls'] as $k=>$v){
|
||||
$levelCurNum++;
|
||||
if(isset($this->eCpattern->cur_level_urls[$v['name']])){
|
||||
if($k==0){
|
||||
|
||||
if($this->eCpattern->cur_source_url){
|
||||
$this->eCpattern->getLevelUrls($this->eCpattern->cur_source_url,$k+1,false);
|
||||
}
|
||||
}else{
|
||||
|
||||
$prevLevelUrl=$this->eCpattern->config['level_urls'][$k-1];
|
||||
if($this->eCpattern->cur_level_urls[$prevLevelUrl['name']]){
|
||||
$this->eCpattern->getLevelUrls($this->eCpattern->cur_level_urls[$prevLevelUrl['name']],$k+1,false);
|
||||
}
|
||||
}
|
||||
|
||||
$this->eCpattern->get_page_html($this->eCpattern->cur_level_urls[$v['name']], 'level_url', $v['name']);
|
||||
}
|
||||
if($levelCurNum==$levelCount){
|
||||
$levelIsEnd=true;
|
||||
}
|
||||
|
||||
if($pageType=='level_url'&&$pageName==$v['name']){
|
||||
break;
|
||||
}
|
||||
}
|
||||
if($levelIsEnd){
|
||||
|
||||
$endLevel=$this->eCpattern->config['level_urls'][$levelCount-1];
|
||||
if(isset($this->eCpattern->cur_level_urls[$endLevel['name']])){
|
||||
if($pageType!='level_url'||$pageName!=$endLevel['name']){
|
||||
|
||||
$this->eCpattern->getContUrls($this->eCpattern->cur_level_urls[$endLevel['name']],false);
|
||||
|
||||
$this->eCpattern->get_page_html($this->eCpattern->cur_level_urls[$endLevel['name']], 'level_url', $endLevel['name']);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->eCpattern->loadSingle(
|
||||
$pageType,$pageName,$test_url,
|
||||
input('?source_url')?input('source_url','','trim'):null,
|
||||
$inputLevels,
|
||||
input('?url')?input('url','','trim'):null
|
||||
);
|
||||
|
||||
if('get_fields'==$testName){
|
||||
$val_list=$this->eCpattern->getFields($test_url);
|
||||
|
@ -1205,7 +888,7 @@ class CpatternTest extends BaseController {
|
|||
exit('未抓取到源码'.$errorMsg);
|
||||
}else{
|
||||
|
||||
exit($htmlInfo['html']);
|
||||
exit(' '.$htmlInfo['html']);
|
||||
}
|
||||
}elseif('get_browser'==$testName){
|
||||
|
||||
|
|
|
@ -90,7 +90,7 @@ class Develop extends BaseController {
|
|||
$params[$k]=json_decode(url_b64decode($v),true);
|
||||
}
|
||||
|
||||
$this->create_cms_app(array('name'=>$name,'app'=>$appName), $params,$is_edit);
|
||||
$this->_create_cms_app(array('name'=>$name,'app'=>$appName), $params,$is_edit);
|
||||
|
||||
}else{
|
||||
$appName=input('app','');
|
||||
|
@ -221,7 +221,7 @@ class Develop extends BaseController {
|
|||
}
|
||||
}
|
||||
/*创建cms发布插件*/
|
||||
public function create_cms_app($appData,$params,$is_edit=false){
|
||||
private function _create_cms_app($appData,$params,$is_edit=false){
|
||||
if(!preg_match('/^[a-z][a-z0-9]*$/i', $appData['app'])){
|
||||
$this->error('插件名错误!');
|
||||
}
|
||||
|
@ -813,136 +813,27 @@ EOF;
|
|||
|
||||
/*导出插件*/
|
||||
public function exportAction(){
|
||||
$type=input('type');
|
||||
$app=input('app');
|
||||
|
||||
$pluginData=$this->get_plugin_data($type,$app);
|
||||
if(empty($pluginData['success'])){
|
||||
$this->error($pluginData['msg']);
|
||||
}
|
||||
$pluginData=$pluginData['plugin'];
|
||||
|
||||
set_time_limit(600);
|
||||
$txt='/*skycaiji-plugin-start*/'.base64_encode(serialize($pluginData)).'/*skycaiji-plugin-end*/';
|
||||
$name=$pluginData['app'];
|
||||
ob_start();
|
||||
header("Expires: 0" );
|
||||
header("Pragma:public" );
|
||||
header("Cache-Control:must-revalidate,post-check=0,pre-check=0" );
|
||||
header("Cache-Control:public");
|
||||
header("Content-Type:application/octet-stream" );
|
||||
|
||||
header("Content-transfer-encoding: binary");
|
||||
header("Accept-Length: " .mb_strlen($txt));
|
||||
if (preg_match("/MSIE/i", $_SERVER["HTTP_USER_AGENT"])) {
|
||||
header('Content-Disposition: attachment; filename="'.urlencode($name).'.scj"');
|
||||
}else{
|
||||
header('Content-Disposition: attachment; filename="'.$name.'.scj"');
|
||||
}
|
||||
echo $txt;
|
||||
ob_end_flush();
|
||||
}
|
||||
|
||||
public function get_plugin_data($type,$app){
|
||||
$mapp=null;
|
||||
if($type=='release'){
|
||||
$mapp=model('ReleaseApp');
|
||||
}elseif($type=='func'){
|
||||
$mapp=model('FuncApp');
|
||||
}else{
|
||||
return return_result('类型错误');
|
||||
}
|
||||
if(empty($app)){
|
||||
return return_result('app标识错误');
|
||||
}
|
||||
$pluginDb=$mapp->where('app',$app)->find();
|
||||
if(empty($pluginDb)){
|
||||
return return_result('插件不存在');
|
||||
}
|
||||
|
||||
$pluginData=array(
|
||||
'app'=>$pluginDb['app'],
|
||||
'name'=>$pluginDb['name'],
|
||||
'type'=>$type,
|
||||
'module'=>$pluginDb['module'],
|
||||
'uptime'=>$pluginDb['uptime'],
|
||||
'store_url'=>''
|
||||
);
|
||||
|
||||
if(!empty($pluginDb['provider_id'])){
|
||||
|
||||
$mprov=model('Provider');
|
||||
$provData=$mprov->where('id',$pluginDb['provider_id'])->find();
|
||||
$pluginData['store_url']=\skycaiji\admin\model\Provider::create_store_url($provData['url'],'client/addon/plugin',array('app'=>$pluginDb['app']));
|
||||
}
|
||||
|
||||
if(empty($pluginData['name'])){
|
||||
return return_result('插件名称为空');
|
||||
}
|
||||
if(empty($pluginData['module'])){
|
||||
return return_result('插件模块为空');
|
||||
}
|
||||
$appFile=config('plugin_path').'/'.$type.'/'.$pluginDb['module'].'/'.$pluginData['app'].'.php';
|
||||
if($type=='release'){
|
||||
$appTpl=config('plugin_path').'/'.$type.'/view/'.$pluginDb['module'].'/'.$pluginData['app'].'.html';
|
||||
if(file_exists($appTpl)){
|
||||
|
||||
$appTpl=file_get_contents($appTpl);
|
||||
$pluginData['tpl']=base64_encode($appTpl);
|
||||
}
|
||||
}
|
||||
if(file_exists($appFile)){
|
||||
|
||||
$appFile=file_get_contents($appFile);
|
||||
$pluginData['code']=base64_encode($appFile);
|
||||
}
|
||||
if(empty($pluginData['code'])){
|
||||
return return_result('插件文件不存在');
|
||||
}
|
||||
|
||||
return return_result('',true,array('plugin'=>$pluginData));
|
||||
}
|
||||
|
||||
public function _format_array($arr,$headStr=''){
|
||||
if(is_array($arr)){
|
||||
$arr=var_export($arr,true);
|
||||
}
|
||||
$arr=preg_replace_callback('/^\s*/m', function($matches) use ($headStr){
|
||||
|
||||
$returnStr="\t";
|
||||
for($i=0;$i<(strlen($matches[0])/2);$i++){
|
||||
$returnStr.="\t";
|
||||
}
|
||||
return $headStr.$returnStr;
|
||||
}, $arr);
|
||||
$arr=preg_replace('/\s+array\s*\(/i', 'array(', $arr);
|
||||
return $arr;
|
||||
}
|
||||
|
||||
public function _copy_files($fromPath,$toPath){
|
||||
if(empty($fromPath)||empty($toPath)){
|
||||
return false;
|
||||
}
|
||||
if(is_dir($fromPath)){
|
||||
|
||||
$fileList=scandir($fromPath);
|
||||
foreach( $fileList as $file ){
|
||||
if('.'== $file || '..' == $file){
|
||||
continue;
|
||||
}
|
||||
$fileName=$fromPath.'/'.$file;
|
||||
if(!file_exists($fileName)){
|
||||
continue;
|
||||
}
|
||||
$toFile=$toPath.'/'.$file;
|
||||
if(is_dir( $fileName )){
|
||||
mkdir($toFile,0777,true);
|
||||
$this->_copy_files($fileName, $toFile);
|
||||
}elseif(is_file($fileName)){
|
||||
write_dir_file($toFile,file_get_contents($fileName));
|
||||
}
|
||||
}
|
||||
}
|
||||
$type=input('type');
|
||||
$module=input('module');
|
||||
$app=input('app');
|
||||
if(request()->isPost()){
|
||||
$pwd=input('pwd','','trim');
|
||||
$pluginData=$this->_export_plugin_data($type, $module, $app, $pwd);
|
||||
if(empty($pluginData['success'])){
|
||||
$this->error($pluginData['msg']);
|
||||
}
|
||||
\util\Tools::browser_export_scj($app.($pwd?'.加密':'').'.插件', $pluginData['plugin_txt']);
|
||||
}else{
|
||||
$this->set_html_tags(
|
||||
'导出插件',
|
||||
'导出插件至本地',
|
||||
breadcrumb(array('导出插件'))
|
||||
);
|
||||
$this->assign('type',$type);
|
||||
$this->assign('module',$module);
|
||||
$this->assign('app',$app);
|
||||
return $this->fetch();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -1168,4 +1059,152 @@ EOF;
|
|||
return $this->fetch('plugin_skycaiji_method');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private function _get_plugin_data($type,$app){
|
||||
$mapp=null;
|
||||
if($type=='release'){
|
||||
$mapp=model('ReleaseApp');
|
||||
}elseif($type=='func'){
|
||||
$mapp=model('FuncApp');
|
||||
}else{
|
||||
return return_result('类型错误');
|
||||
}
|
||||
if(empty($app)){
|
||||
return return_result('app标识错误');
|
||||
}
|
||||
$pluginDb=$mapp->where('app',$app)->find();
|
||||
if(empty($pluginDb)){
|
||||
return return_result('插件不存在');
|
||||
}
|
||||
|
||||
$pluginData=array(
|
||||
'app'=>$pluginDb['app'],
|
||||
'name'=>$pluginDb['name'],
|
||||
'type'=>$type,
|
||||
'module'=>$pluginDb['module'],
|
||||
'uptime'=>$pluginDb['uptime'],
|
||||
'store_url'=>''
|
||||
);
|
||||
|
||||
if(!empty($pluginDb['provider_id'])){
|
||||
|
||||
$mprov=model('Provider');
|
||||
$provData=$mprov->where('id',$pluginDb['provider_id'])->find();
|
||||
$pluginData['store_url']=\skycaiji\admin\model\Provider::create_store_url($provData['url'],'client/addon/plugin',array('app'=>$pluginDb['app']));
|
||||
}
|
||||
|
||||
if(empty($pluginData['name'])){
|
||||
return return_result('插件名称为空');
|
||||
}
|
||||
if(empty($pluginData['module'])){
|
||||
return return_result('插件模块为空');
|
||||
}
|
||||
$appFile=config('plugin_path').'/'.$type.'/'.$pluginDb['module'].'/'.$pluginData['app'].'.php';
|
||||
if($type=='release'){
|
||||
$appTpl=config('plugin_path').'/'.$type.'/view/'.$pluginDb['module'].'/'.$pluginData['app'].'.html';
|
||||
if(file_exists($appTpl)){
|
||||
|
||||
$appTpl=file_get_contents($appTpl);
|
||||
$pluginData['tpl']=base64_encode($appTpl);
|
||||
}
|
||||
}
|
||||
if(file_exists($appFile)){
|
||||
|
||||
$appFile=file_get_contents($appFile);
|
||||
$pluginData['code']=base64_encode($appFile);
|
||||
}
|
||||
if(empty($pluginData['code'])){
|
||||
return return_result('插件文件不存在');
|
||||
}
|
||||
|
||||
return return_result('',true,array('plugin'=>$pluginData));
|
||||
}
|
||||
|
||||
public function _export_plugin_data($type,$module,$app,$pwd){
|
||||
$reuslt=return_result('');
|
||||
if($type=='release'&&$module=='diy'){
|
||||
|
||||
$pluginResult=return_result('');
|
||||
if(!model('ReleaseApp')->appFileExists($app,'diy')){
|
||||
$pluginResult['msg']='插件不存在';
|
||||
}else{
|
||||
$pluginResult['success']=1;
|
||||
$pluginResult['plugin']=array(
|
||||
'app'=>$app,
|
||||
'type'=>'release',
|
||||
'module'=>'diy',
|
||||
'code'=>'',
|
||||
);
|
||||
$filename=model('ReleaseApp')->appFileName($app,'diy');
|
||||
$pluginResult['plugin']['code']=file_get_contents($filename);
|
||||
$pluginResult['plugin']['code']=base64_encode($pluginResult['plugin']['code']);
|
||||
}
|
||||
}else{
|
||||
$pluginResult=$this->_get_plugin_data($type,$app);
|
||||
}
|
||||
|
||||
if(empty($pluginResult['success'])){
|
||||
if($type=='release'){
|
||||
$reuslt['msg']=lang('rele_m_name_'.$module).'发布插件:'.$app;
|
||||
}elseif($type=='func'){
|
||||
$reuslt['msg']=model('FuncApp')->get_func_module_val($module,'name').'函数插件:'.$app;
|
||||
}
|
||||
$reuslt['msg'].=' » '.$pluginResult['msg'];
|
||||
}else{
|
||||
$pluginResult=$pluginResult['plugin'];
|
||||
$pluginResult=base64_encode(serialize($pluginResult));
|
||||
if(!empty($pwd)){
|
||||
|
||||
$edClass=new \util\EncryptDecrypt();
|
||||
$pluginResult=$edClass->encrypt(array('data'=>$pluginResult,'pwd'=>$pwd));
|
||||
$pluginResult=base64_encode(serialize($pluginResult));
|
||||
}
|
||||
$reuslt['success']=true;
|
||||
$reuslt['plugin_txt']='/*skycaiji-plugin-start*/'.$pluginResult.'/*skycaiji-plugin-end*/';
|
||||
}
|
||||
return $reuslt;
|
||||
}
|
||||
|
||||
private function _format_array($arr,$headStr=''){
|
||||
if(is_array($arr)){
|
||||
$arr=var_export($arr,true);
|
||||
}
|
||||
$arr=preg_replace_callback('/^\s*/m', function($matches) use ($headStr){
|
||||
|
||||
$returnStr="\t";
|
||||
for($i=0;$i<(strlen($matches[0])/2);$i++){
|
||||
$returnStr.="\t";
|
||||
}
|
||||
return $headStr.$returnStr;
|
||||
}, $arr);
|
||||
$arr=preg_replace('/\s+array\s*\(/i', 'array(', $arr);
|
||||
return $arr;
|
||||
}
|
||||
|
||||
private function _copy_files($fromPath,$toPath){
|
||||
if(empty($fromPath)||empty($toPath)){
|
||||
return false;
|
||||
}
|
||||
if(is_dir($fromPath)){
|
||||
|
||||
$fileList=scandir($fromPath);
|
||||
foreach( $fileList as $file ){
|
||||
if('.'== $file || '..' == $file){
|
||||
continue;
|
||||
}
|
||||
$fileName=$fromPath.'/'.$file;
|
||||
if(!file_exists($fileName)){
|
||||
continue;
|
||||
}
|
||||
$toFile=$toPath.'/'.$file;
|
||||
if(is_dir( $fileName )){
|
||||
mkdir($toFile,0777,true);
|
||||
$this->_copy_files($fileName, $toFile);
|
||||
}elseif(is_file($fileName)){
|
||||
write_dir_file($toFile,file_get_contents($fileName));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -335,7 +335,7 @@ class Mystore extends BaseController {
|
|||
|
||||
$mapp=model('App');
|
||||
$mprov=model('Provider');
|
||||
$dbApps=$mapp->order('uptime desc')->paginate(20);
|
||||
$dbApps=$mapp->order('uptime desc')->paginate(20,false,paginate_auto_config());
|
||||
$pagenav=$dbApps->render();
|
||||
$dbApps=$dbApps->all();
|
||||
$dbApps1=array();
|
||||
|
@ -669,8 +669,11 @@ class Mystore extends BaseController {
|
|||
/*导入*/
|
||||
public function uploadAction(){
|
||||
$type=input('type','');
|
||||
$typeIsRule=$type=='rule'?true:false;
|
||||
$typeName=$typeIsRule?'规则':'插件';
|
||||
$type=$type?:'plugin';
|
||||
$fromTask=input('from_task','');
|
||||
$types=array('rule'=>'规则','plugin'=>'插件','release'=>'发布设置');
|
||||
$typeIsPlugin=$type=='plugin'?true:false;
|
||||
$typeName=$types[$type];
|
||||
if(request()->isPost()){
|
||||
if(g_sc_c('site','verifycode')){
|
||||
|
||||
|
@ -680,16 +683,53 @@ class Mystore extends BaseController {
|
|||
$this->error($check['msg']);
|
||||
}
|
||||
}
|
||||
$result=$this->_upload_addon($typeIsRule,'upload_file',true,true);
|
||||
|
||||
$result=$this->_upload_addon($type,$fromTask?false:true,true);
|
||||
$url=$result['url']?$result['url']:'';
|
||||
|
||||
$data=array();
|
||||
if($result['show_plugins']){
|
||||
if($result['show_ipt_pwd']){
|
||||
|
||||
$data['js']='win_upload_ipt_pwd();';
|
||||
}elseif($result['show_plugins']){
|
||||
|
||||
$data['js']='win_upload_plugins('.json_encode($result['show_plugins']).');';
|
||||
}elseif($result['show_replace']){
|
||||
|
||||
$data['js']="confirmRight('插件已存在,是否覆盖?',win_upload_replace);";
|
||||
}elseif($result['show_rule_data']){
|
||||
|
||||
if($fromTask){
|
||||
|
||||
$ruleData=$result['rule_data'];
|
||||
init_array($ruleData);
|
||||
if($ruleData){
|
||||
|
||||
$name='文件';
|
||||
$name.=$ruleData['name']?(' » '.$ruleData['name']):'';
|
||||
$name=addslashes($name);
|
||||
$ruleData=base64_encode(serialize($ruleData));
|
||||
$ruleData=addslashes($ruleData);
|
||||
$data['js']=sprintf("taskOpClass.import_rule('%s','%s')",'file:'.$ruleData,$name);
|
||||
}else{
|
||||
$this->error('没有规则');
|
||||
}
|
||||
}
|
||||
}elseif($result['show_release_data']){
|
||||
|
||||
$releData=$result['release_data'];
|
||||
init_array($releData);
|
||||
if($releData){
|
||||
|
||||
$name='文件';
|
||||
$name.=$releData['name']?(' » '.$releData['name']):'';
|
||||
$name=addslashes($name);
|
||||
$releData=base64_encode(serialize($releData));
|
||||
$releData=addslashes($releData);
|
||||
$data['js']=sprintf("releaseClass.import_rele('%s','%s')",'file:'.$releData,$name);
|
||||
}else{
|
||||
$this->error('没有发布设置');
|
||||
}
|
||||
}
|
||||
if($result['success']){
|
||||
$this->success($result['msg'],$url,$data);
|
||||
|
@ -698,165 +738,252 @@ class Mystore extends BaseController {
|
|||
}
|
||||
}else{
|
||||
$this->assign('type',$type);
|
||||
$this->assign('typeIsRule',$typeIsRule);
|
||||
$this->assign('typeIsPlugin',$typeIsPlugin);
|
||||
$this->assign('typeName',$typeName);
|
||||
$this->assign('fromTask',$fromTask);
|
||||
return $this->fetch();
|
||||
}
|
||||
}
|
||||
|
||||
private function _safe_unserialize($code){
|
||||
$code=base64_decode(trim($code));
|
||||
if(preg_match('/\bO\:\d+\:[\'\"][^\'\"]+?[\'\"]/',$code)){
|
||||
|
||||
$this->error('错误的文件');
|
||||
private function _safe_unserialize($code,$base64Decode=true){
|
||||
if($code){
|
||||
$code=trim($code);
|
||||
if($base64Decode){
|
||||
$code=base64_decode($code);
|
||||
}
|
||||
if(preg_match('/\bO\:\d+\:[\'\"][^\'\"]+?[\'\"]/',$code)){
|
||||
|
||||
throw new \Exception('错误的文件');
|
||||
}
|
||||
$code=unserialize($code);
|
||||
}
|
||||
$code=unserialize($code);
|
||||
return $code;
|
||||
}
|
||||
|
||||
public function _upload_addon($typeIsRule,$formFileName,$installRule,$installPlugin){
|
||||
$typeName=$typeIsRule?'规则':'插件';
|
||||
$file=$_FILES[$formFileName];
|
||||
if(empty($file)||empty($file['tmp_name'])){
|
||||
return return_result('请选择'.$typeName.'文件');
|
||||
}
|
||||
$fileTxt=file_get_contents($file['tmp_name']);
|
||||
|
||||
|
||||
$pluginDataList=array();
|
||||
if(preg_match_all('/\/\*skycaiji-plugin-start\*\/(?P<data>[\s\S]+?)\/\*skycaiji-plugin-end\*\//i',$fileTxt,$fileMatches)){
|
||||
foreach ($fileMatches['data'] as $k=>$v){
|
||||
$v=$v?:'';
|
||||
$v=$this->_safe_unserialize($v);
|
||||
if($v['type']&&$v['app']){
|
||||
$pluginDataList[$v['type'].':'.$v['app']]=$v;
|
||||
}
|
||||
}
|
||||
}
|
||||
$ruleData=null;
|
||||
if($typeIsRule){
|
||||
|
||||
if(preg_match('/\/\*skycaiji-collector-start\*\/(?P<data>[\s\S]+?)\/\*skycaiji-collector-end\*\//i',$fileTxt,$fileMatch)){
|
||||
$ruleData=$this->_safe_unserialize($fileMatch['data']);
|
||||
}
|
||||
if(empty($ruleData)||!is_array($ruleData)){
|
||||
return return_result('不是规则文件');
|
||||
}
|
||||
}else{
|
||||
|
||||
if(empty($pluginDataList)||!is_array($pluginDataList)){
|
||||
return return_result('不是插件文件');
|
||||
}
|
||||
}
|
||||
$uploadedPlugin=false;
|
||||
|
||||
if(!empty($pluginDataList)&&is_array($pluginDataList)){
|
||||
if($typeIsRule||count($pluginDataList)>1){
|
||||
|
||||
$uploadAddon=input('upload_addon/a',array());
|
||||
$uploadAddon=is_array($uploadAddon)?$uploadAddon:array();
|
||||
$uploadPlugins=is_array($uploadAddon['plugins'])?$uploadAddon['plugins']:array();
|
||||
if(empty($uploadPlugins)){
|
||||
|
||||
if(!$typeIsRule||!$uploadAddon['ignore_plugin']){
|
||||
|
||||
$pluginList=array();
|
||||
foreach ($pluginDataList as $pluginData){
|
||||
$pluginTitle='';
|
||||
$mapp=null;
|
||||
if($pluginData['type']=='release'){
|
||||
$mapp=model('ReleaseApp');
|
||||
$pluginTitle='发布插件 » ';
|
||||
}elseif($pluginData['type']=='func'){
|
||||
$mapp=model('FuncApp');
|
||||
$pluginTitle='函数插件:'.$mapp->get_func_module_val($pluginData['module'],'name').' » ';
|
||||
}else{
|
||||
continue;
|
||||
}
|
||||
$pluginTitle.=$pluginData['name'].'('.$pluginData['app'].')';
|
||||
if($mapp->where('app',$pluginData['app'])->count()>0){
|
||||
$pluginTitle='[已有] '.$pluginTitle;
|
||||
}
|
||||
$pluginList[$pluginData['type'].':'.$pluginData['app']]=$pluginTitle;
|
||||
}
|
||||
return return_result('',false,array('show_plugins'=>$pluginList));
|
||||
}
|
||||
}else{
|
||||
|
||||
if($installPlugin){
|
||||
$pluginType='';
|
||||
foreach ($uploadPlugins as $plugin){
|
||||
$pluginData=$pluginDataList[$plugin];
|
||||
if(empty($pluginData)){
|
||||
continue;
|
||||
}
|
||||
$pluginTitle='';
|
||||
$pluginType=$pluginData['type'];
|
||||
if($pluginType=='release'){
|
||||
$pluginTitle='发布插件:';
|
||||
}elseif($pluginType=='func'){
|
||||
$pluginTitle='函数插件:';
|
||||
}else{
|
||||
continue;
|
||||
}
|
||||
$pluginTitle.=$pluginData['name'].'('.$pluginData['app'].')';
|
||||
$result=controller('admin/Store')->_install_plugin($pluginData);
|
||||
if(!$result['success']){
|
||||
return return_result($pluginTitle.' » '.($result['msg']?$result['msg']:'失败'));
|
||||
}
|
||||
$uploadedPlugin=true;
|
||||
}
|
||||
if(!$typeIsRule){
|
||||
return return_result('导入成功',true,array('url'=>'mystore/'.($pluginType.'App')));
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
|
||||
if($installPlugin){
|
||||
$pluginData=reset($pluginDataList);
|
||||
$mapp=null;
|
||||
if($pluginData['type']=='release'){
|
||||
$mapp=model('ReleaseApp');
|
||||
}elseif($pluginData['type']=='func'){
|
||||
$mapp=model('FuncApp');
|
||||
}else{
|
||||
return return_result('插件类型错误');
|
||||
}
|
||||
if(!input('replace')){
|
||||
|
||||
if($mapp->where('app',$pluginData['app'])->count()>0){
|
||||
|
||||
return return_result('',false,array('show_replace'=>1));
|
||||
}
|
||||
}
|
||||
|
||||
$result=controller('admin/Store')->_install_plugin($pluginData);
|
||||
|
||||
if($result['success']){
|
||||
return return_result('成功导入插件:'.$pluginData['app'],true,array('url'=>'mystore/'.$pluginData['type'].'App'));
|
||||
}else{
|
||||
return return_result($result['msg']);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if($typeIsRule){
|
||||
if($installRule){
|
||||
|
||||
$ruleData['type']='collect';
|
||||
$ruleData['config']=base64_encode($ruleData['config']);
|
||||
$result=controller('admin/Store')->_install_rule($ruleData,0,true);
|
||||
if($result['success']){
|
||||
return return_result('成功导入规则'.($uploadedPlugin?'及包含的插件':'').':'.$ruleData['name'],true,array('url'=>'mystore/rule'));
|
||||
}else{
|
||||
return return_result($result['msg']);
|
||||
}
|
||||
}else{
|
||||
|
||||
return return_result('',true,array('ruleData'=>$ruleData));
|
||||
}
|
||||
}
|
||||
private function _upload_decrypt($pwd,&$data){
|
||||
if(isset($data['encrypt_version'])){
|
||||
if(empty($pwd)){
|
||||
return return_result('请输入密码',false,array('show_ipt_pwd'=>1));
|
||||
}else{
|
||||
|
||||
$edClass=new \util\EncryptDecrypt($data['encrypt_version'],$data['skycaiji_version']);
|
||||
$data=$edClass->decrypt(array('data'=>$data['data'],'pwd'=>$pwd));
|
||||
$data=$this->_safe_unserialize($data);
|
||||
if(empty($data)){
|
||||
return return_result('密码错误');
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private function _upload_addon($type,$installRule,$installPlugin){
|
||||
try{
|
||||
$types=array('rule'=>'规则','plugin'=>'插件','release'=>'发布设置');
|
||||
$typeName=$types[$type];
|
||||
$typeIsPlugin=$type=='plugin'?true:false;
|
||||
|
||||
$uploadAddon=input('upload_addon/a',array());
|
||||
init_array($uploadAddon);
|
||||
|
||||
$file=$_FILES['upload_file'];
|
||||
if(empty($file)||empty($file['tmp_name'])){
|
||||
return return_result('请选择'.$typeName.'文件');
|
||||
}
|
||||
|
||||
$uploadPwd=$uploadAddon['pwd'];
|
||||
|
||||
$fileTxt=file_get_contents($file['tmp_name']);
|
||||
|
||||
|
||||
$pluginDataList=array();
|
||||
if(preg_match_all('/\/\*skycaiji-plugin-start\*\/(?P<data>[\s\S]+?)\/\*skycaiji-plugin-end\*\//i',$fileTxt,$fileMatches)){
|
||||
foreach ($fileMatches['data'] as $k=>$v){
|
||||
$v=$v?:'';
|
||||
$v=$this->_safe_unserialize($v);
|
||||
if($v&&is_array($v)){
|
||||
$returnResult=$this->_upload_decrypt($uploadPwd,$v);
|
||||
if($returnResult){
|
||||
return $returnResult;
|
||||
}
|
||||
if($v['type']&&$v['app']){
|
||||
$pluginDataList[$v['type'].':'.$v['module'].':'.$v['app']]=$v;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$typeData=null;
|
||||
|
||||
if($typeIsPlugin){
|
||||
|
||||
if(empty($pluginDataList)||!is_array($pluginDataList)){
|
||||
return return_result('不是插件文件');
|
||||
}
|
||||
}else{
|
||||
if($type=='rule'){
|
||||
|
||||
if(preg_match('/\/\*skycaiji-collector-start\*\/(?P<data>[\s\S]+?)\/\*skycaiji-collector-end\*\//i',$fileTxt,$fileMatch)){
|
||||
$typeData=$this->_safe_unserialize($fileMatch['data']);
|
||||
}
|
||||
}elseif($type=='release'){
|
||||
|
||||
if(preg_match('/\/\*skycaiji-release-start\*\/(?P<data>[\s\S]+?)\/\*skycaiji-release-end\*\//i',$fileTxt,$fileMatch)){
|
||||
$typeData=$this->_safe_unserialize($fileMatch['data']);
|
||||
}
|
||||
}
|
||||
if($typeData&&is_array($typeData)){
|
||||
$returnResult=$this->_upload_decrypt($uploadPwd,$typeData);
|
||||
if($returnResult){
|
||||
return $returnResult;
|
||||
}
|
||||
}
|
||||
if(empty($typeData)||!is_array($typeData)){
|
||||
return return_result('不是'.$typeName.'文件');
|
||||
}
|
||||
|
||||
$typeData['config']=$this->_safe_unserialize($typeData['config'],false);
|
||||
$typeData['config']=serialize($typeData['config']);
|
||||
}
|
||||
$uploadedPlugin=false;
|
||||
|
||||
if(!empty($pluginDataList)&&is_array($pluginDataList)){
|
||||
if(!$typeIsPlugin||count($pluginDataList)>1){
|
||||
|
||||
$uploadPlugins=is_array($uploadAddon['plugins'])?$uploadAddon['plugins']:array();
|
||||
if(empty($uploadPlugins)){
|
||||
|
||||
if($typeIsPlugin||!$uploadAddon['ignore_plugin']){
|
||||
|
||||
$pluginList=array();
|
||||
foreach ($pluginDataList as $pluginData){
|
||||
$isReleDiy=false;
|
||||
$pluginTitle='';
|
||||
$mapp=null;
|
||||
if($pluginData['type']=='release'){
|
||||
$mapp=model('ReleaseApp');
|
||||
$isReleDiy=$pluginData['module']=='diy'?true:false;
|
||||
$pluginTitle.=lang('rele_m_name_'.$pluginData['module']).'发布插件 » ';
|
||||
}elseif($pluginData['type']=='func'){
|
||||
$mapp=model('FuncApp');
|
||||
$pluginTitle='函数插件:'.$mapp->get_func_module_val($pluginData['module'],'name').' » ';
|
||||
}else{
|
||||
continue;
|
||||
}
|
||||
if($isReleDiy){
|
||||
|
||||
$pluginTitle.=$pluginData['app'];
|
||||
if($mapp->appFileExists($pluginData['app'],'diy')){
|
||||
$pluginTitle='[已有] '.$pluginTitle;
|
||||
}
|
||||
}else{
|
||||
$pluginTitle.=$pluginData['name'].'('.$pluginData['app'].')';
|
||||
if($mapp->where('app',$pluginData['app'])->count()>0){
|
||||
$pluginTitle='[已有] '.$pluginTitle;
|
||||
}
|
||||
}
|
||||
$pluginList[$pluginData['type'].':'.$pluginData['module'].':'.$pluginData['app']]=$pluginTitle;
|
||||
}
|
||||
return return_result('',false,array('show_plugins'=>$pluginList));
|
||||
}
|
||||
}else{
|
||||
|
||||
if($installPlugin){
|
||||
$pluginType='';
|
||||
foreach ($uploadPlugins as $plugin){
|
||||
$pluginData=$pluginDataList[$plugin];
|
||||
if(empty($pluginData)){
|
||||
continue;
|
||||
}
|
||||
$isReleDiy=false;
|
||||
$pluginTitle='';
|
||||
$pluginType=$pluginData['type'];
|
||||
if($pluginType=='release'){
|
||||
$pluginTitle.=lang('rele_m_name_'.$pluginData['module']).'发布插件:';
|
||||
$isReleDiy=$pluginData['module']=='diy'?true:false;
|
||||
}elseif($pluginType=='func'){
|
||||
$pluginTitle='函数插件:';
|
||||
}else{
|
||||
continue;
|
||||
}
|
||||
if($isReleDiy){
|
||||
|
||||
$pluginTitle.=$pluginData['app'];
|
||||
$pluginData['code']=base64_decode($pluginData['code']);
|
||||
$pluginFile=model('ReleaseApp')->appFileName($pluginData['app'],'diy');
|
||||
if(!write_dir_file($pluginFile, $pluginData['code'])){
|
||||
return return_result($pluginTitle.' » 导入失败');
|
||||
}
|
||||
}else{
|
||||
$pluginTitle.=$pluginData['name'].'('.$pluginData['app'].')';
|
||||
$result=controller('admin/Store')->_install_plugin($pluginData);
|
||||
if(!$result['success']){
|
||||
return return_result($pluginTitle.' » '.($result['msg']?$result['msg']:'失败'));
|
||||
}
|
||||
}
|
||||
$uploadedPlugin=true;
|
||||
}
|
||||
if($typeIsPlugin){
|
||||
return return_result('导入成功',true,array('url'=>'mystore/'.($pluginType.'App')));
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
|
||||
if($installPlugin){
|
||||
$pluginData=reset($pluginDataList);
|
||||
$mapp=null;
|
||||
if($pluginData['type']=='release'){
|
||||
$mapp=model('ReleaseApp');
|
||||
}elseif($pluginData['type']=='func'){
|
||||
$mapp=model('FuncApp');
|
||||
}else{
|
||||
return return_result('插件类型错误');
|
||||
}
|
||||
if(!input('replace')){
|
||||
|
||||
if($mapp->where('app',$pluginData['app'])->count()>0){
|
||||
|
||||
return return_result('',false,array('show_replace'=>1));
|
||||
}
|
||||
}
|
||||
|
||||
$result=controller('admin/Store')->_install_plugin($pluginData);
|
||||
|
||||
if($result['success']){
|
||||
return return_result('成功导入插件:'.$pluginData['app'],true,array('url'=>'mystore/'.$pluginData['type'].'App'));
|
||||
}else{
|
||||
return return_result($result['msg']);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!$typeIsPlugin){
|
||||
|
||||
if($type=='rule'){
|
||||
|
||||
if($installRule){
|
||||
|
||||
$typeData['type']='collect';
|
||||
$typeData['config']=base64_encode($typeData['config']);
|
||||
$result=controller('admin/Store')->_install_rule($typeData,0,true);
|
||||
if($result['success']){
|
||||
return return_result('成功导入规则'.($uploadedPlugin?'及包含的插件':'').':'.$typeData['name'],true,array('url'=>'mystore/rule'));
|
||||
}else{
|
||||
return return_result($result['msg']);
|
||||
}
|
||||
}else{
|
||||
|
||||
return return_result('',true,array('show_rule_data'=>1,'rule_data'=>$typeData));
|
||||
}
|
||||
}elseif($type=='release'){
|
||||
|
||||
return return_result('',true,array('show_release_data'=>1,'release_data'=>$typeData));
|
||||
}
|
||||
}
|
||||
}catch (\Exception $ex){
|
||||
return return_result($ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -17,13 +17,12 @@ class Release extends CollectController{
|
|||
/*发布设置*/
|
||||
public function setAction(){
|
||||
$taskId=input('task_id/d',0);
|
||||
$releaseId=input('release_id/d',0);
|
||||
|
||||
$releaseImport=input('release_import','','trim');
|
||||
if(request()->isPost()){
|
||||
|
||||
\util\UnmaxPost::init_post_data('_post_data_');
|
||||
$taskId=\util\UnmaxPost::val('task_id/d',0);
|
||||
$releaseId=\util\UnmaxPost::val('release_id/d',0);
|
||||
$releaseImport=\util\UnmaxPost::val('release_import','','trim');
|
||||
}
|
||||
|
||||
$mtask=model('Task');
|
||||
|
@ -35,23 +34,36 @@ class Release extends CollectController{
|
|||
$releData=$mrele->where(array('task_id'=>$taskData['id']))->find();
|
||||
if(request()->isPost()){
|
||||
$newData=array('task_id'=>$taskData['id'],'addtime'=>time(),'config'=>array());
|
||||
if($releaseId>0){
|
||||
if($releaseImport){
|
||||
|
||||
$importRele=$mrele->where(array('id'=>$releaseId))->find();
|
||||
$newData['module']=$importRele['module'];
|
||||
$newData['config']=$importRele['config'];
|
||||
list($releImportType,$releImporVal)=explode(':',$releaseImport,2);
|
||||
$releImportType=strtolower($releImportType);
|
||||
$releImporVal=$releImporVal?:'';
|
||||
if($releImportType=='release'){
|
||||
|
||||
$releImporVal=intval($releImporVal);
|
||||
$importRele=$mrele->where(array('id'=>$releImporVal))->find();
|
||||
$newData['module']=$importRele['module'];
|
||||
$newData['config']=$importRele['config'];
|
||||
}elseif($releImportType=='file'){
|
||||
|
||||
$releImporVal=unserialize(base64_decode($releImporVal));
|
||||
init_array($releImporVal);
|
||||
$newData['module']=$releImporVal['module'];
|
||||
$newData['config']=$releImporVal['config'];
|
||||
}
|
||||
}else{
|
||||
|
||||
$newData['module']=\util\UnmaxPost::val('module','','strtolower');
|
||||
if(empty($newData['module'])){
|
||||
$this->error(lang('rele_error_null_module'));
|
||||
if(!empty($newData['module'])){
|
||||
$releObj=controller('admin/R'.$newData['module'],'event');
|
||||
$newData['config']=$releObj->setConfig($newData['config']);
|
||||
$newData['config']=serialize($newData['config']);
|
||||
}
|
||||
$releObj=controller('admin/R'.$newData['module'],'event');
|
||||
$newData['config']=$releObj->setConfig($newData['config']);
|
||||
$newData['config']=serialize($newData['config']);
|
||||
}
|
||||
if(empty($newData['module'])){
|
||||
$this->error(lang('rele_error_null_module'));
|
||||
|
||||
|
||||
}
|
||||
|
||||
if(empty($releData)){
|
||||
|
@ -72,7 +84,7 @@ class Release extends CollectController{
|
|||
$this->set_html_tags(
|
||||
'任务:'.$taskData['name'].'_'.lang('rele_set'),
|
||||
lang('rele_set'),
|
||||
breadcrumb(array(array('url'=>url('task/save?id='.$taskData['id']),'title'=>lang('task').lang('separator').$taskData['name']),array('url'=>url('release/set?task_id='.$taskData['id']),'title'=>lang('rele_set'))))
|
||||
breadcrumb(array(array('url'=>url('task/set?id='.$taskData['id']),'title'=>lang('task').lang('separator').$taskData['name']),array('url'=>url('release/set?task_id='.$taskData['id']),'title'=>lang('rele_set'))))
|
||||
);
|
||||
|
||||
$this->assign('taskData',$taskData);
|
||||
|
@ -130,6 +142,84 @@ class Release extends CollectController{
|
|||
$this->assign('releList',$releList);
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
/*导出设置*/
|
||||
public function exportAction(){
|
||||
$taskId=input('task_id/d',0);
|
||||
$mtask=model('Task');
|
||||
$mrele=model('Release');
|
||||
$taskData=$mtask->getById($taskId);
|
||||
$releData=$mrele->where(array('task_id'=>$taskData['id']))->find();
|
||||
if(empty($releData)){
|
||||
$this->error('发布设置不存在');
|
||||
}
|
||||
$config=unserialize($releData['config']?:'');
|
||||
if(empty($config)){
|
||||
$this->error('发布设置不存在');
|
||||
}
|
||||
|
||||
$hasPlugin=array();
|
||||
if($config['cms']&&$config['cms']['app']){
|
||||
$hasPlugin['cms']=$config['cms']['app'];
|
||||
}
|
||||
if($config['diy']&&$config['diy']['app']){
|
||||
$hasPlugin['diy']=$config['diy']['app'];
|
||||
}
|
||||
|
||||
if(request()->isPost()){
|
||||
$pwd=input('pwd','','trim');
|
||||
$exportName=$releData['name']?:$taskData['name'];
|
||||
$release=array(
|
||||
'name'=>$exportName,
|
||||
'module'=>$releData['module'],
|
||||
'config'=>serialize($config),
|
||||
);
|
||||
$exportTxt=base64_encode(serialize($release));
|
||||
if(!empty($pwd)){
|
||||
|
||||
$edClass=new \util\EncryptDecrypt();
|
||||
$exportTxt=$edClass->encrypt(array('data'=>$exportTxt,'pwd'=>$pwd));
|
||||
$exportTxt=base64_encode(serialize($exportTxt));
|
||||
}
|
||||
$exportTxt='/*skycaiji-release-start*/'.$exportTxt.'/*skycaiji-release-end*/';
|
||||
|
||||
if(input('export_plugin')){
|
||||
|
||||
if($hasPlugin){
|
||||
$exportName.='.含插件';
|
||||
if($hasPlugin['cms']){
|
||||
|
||||
$pluginData=controller('admin/Develop','controller')->_export_plugin_data('release','cms',$hasPlugin['cms'],$pwd);
|
||||
if(empty($pluginData['success'])){
|
||||
$this->error($pluginData['msg']);
|
||||
}
|
||||
$exportTxt.="\r\n".$pluginData['plugin_txt'];
|
||||
}
|
||||
if($hasPlugin['diy']){
|
||||
|
||||
$pluginData=controller('admin/Develop','controller')->_export_plugin_data('release','diy',$hasPlugin['diy'],$pwd);
|
||||
if(empty($pluginData['success'])){
|
||||
$this->error($pluginData['msg']);
|
||||
}
|
||||
$exportTxt.="\r\n".$pluginData['plugin_txt'];
|
||||
}
|
||||
}
|
||||
}
|
||||
$exportName.=($pwd?'.加密':'').'.发布';
|
||||
\util\Tools::browser_export_scj($exportName, $exportTxt);
|
||||
}else{
|
||||
$this->set_html_tags(
|
||||
'导出发布设置',
|
||||
'导出发布设置至本地',
|
||||
breadcrumb(array(array('url'=>url('task/set?id='.$taskData['id']),'title'=>lang('task').lang('separator').$taskData['name']),array('url'=>url('release/set?task_id='.$taskData['id']),'title'=>lang('rele_set'))))
|
||||
);
|
||||
$this->assign('task_id',$taskId);
|
||||
$this->assign('hasPlugin',$hasPlugin);
|
||||
return $this->fetch();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*检测cms信息*/
|
||||
public function cmsDetectAction(){
|
||||
$acms=controller('admin/Rcms','event');
|
||||
|
@ -493,6 +583,7 @@ class Release extends CollectController{
|
|||
|
||||
$appApi=null;
|
||||
$appParams=null;
|
||||
$appCustomParams=array();
|
||||
$releData=$mrele->where(array('task_id'=>$taskData['id']))->find();
|
||||
if(!empty($releData)){
|
||||
|
||||
|
@ -505,6 +596,7 @@ class Release extends CollectController{
|
|||
$appApi=json_decode($appApi,true);
|
||||
}
|
||||
$appParams=$config['toapi']['app_params'];
|
||||
$appCustomParams=$config['toapi']['app_custom_params'];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -514,22 +606,34 @@ class Release extends CollectController{
|
|||
if(empty($appUrl)){
|
||||
$this->error('请输入接口地址');
|
||||
}
|
||||
$appApi=get_html($appUrl,[],[],'utf-8');
|
||||
if(!empty($appApi)){
|
||||
$appApi=json_decode($appApi,true);
|
||||
$apiHtml=get_html($appUrl,[],[],'utf-8');
|
||||
if(!empty($apiHtml)){
|
||||
$appApi=json_decode($apiHtml,true);
|
||||
}
|
||||
init_array($appApi);
|
||||
$apiError='';
|
||||
if(empty($appApi)){
|
||||
$this->error('接口读取失败');
|
||||
$apiError='接口读取失败';
|
||||
}elseif(empty($appApi['code'])){
|
||||
$apiError=$appApi['msg']?:'接口错误';
|
||||
}
|
||||
if(empty($appApi['code'])){
|
||||
$this->error($appApi['msg']?:'接口错误');
|
||||
if($apiError){
|
||||
if($apiHtml){
|
||||
$this->assign('apiError',$apiError);
|
||||
$this->assign('apiHtml',$apiHtml);
|
||||
$apiHtml=$this->fetch('toapiHtml')->getContent();
|
||||
$apiHtml=array('html'=>$apiHtml);
|
||||
}else{
|
||||
$apiHtml=array();
|
||||
}
|
||||
$this->error($apiError,'',$apiHtml);
|
||||
}
|
||||
$appApi=$appApi['data'];
|
||||
}
|
||||
|
||||
init_array($appApi);
|
||||
init_array($appParams);
|
||||
init_array($appCustomParams);
|
||||
|
||||
if(!empty($appApi)){
|
||||
|
||||
|
@ -552,6 +656,7 @@ class Release extends CollectController{
|
|||
$this->assign('appApi',base64_encode(json_encode($appApi)));
|
||||
$this->assign('appApiParams',$appApiParams);
|
||||
$this->assign('appParams',$appParams);
|
||||
$this->assign('appCustomParams',$appCustomParams);
|
||||
return $this->fetch('toapiApp');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -260,6 +260,7 @@ class Setting extends BaseController {
|
|||
|
||||
$config['download_img']=input('download_img/d',0);
|
||||
$config['data_image']=input('data_image/d',0);
|
||||
$config['url_real']=input('url_real/d',0);
|
||||
$config['interval_img']=input('interval_img/d',0);
|
||||
|
||||
$config['img_timeout']=input('img_timeout/d',0);
|
||||
|
@ -411,6 +412,7 @@ class Setting extends BaseController {
|
|||
$config=array();
|
||||
|
||||
$config['download_file']=input('download_file/d',0);
|
||||
$config['url_real']=input('url_real/d',0);
|
||||
$config['file_interval']=input('file_interval/d',0);
|
||||
|
||||
$config['file_timeout']=input('file_timeout/d',0);
|
||||
|
@ -662,6 +664,21 @@ class Setting extends BaseController {
|
|||
$config['port']=input('port');
|
||||
$config['type']=input('type');
|
||||
|
||||
$config['caiji']=input('caiji/a',array());
|
||||
foreach (array('open','is_auto','failed_num','failed_interval','report_interval') as $k){
|
||||
$config['caiji'][$k]=intval($config['caiji'][$k]);
|
||||
}
|
||||
|
||||
|
||||
foreach (array('email','smtp','port') as $k){
|
||||
if(empty($config[$k])){
|
||||
$this->error('请输入'.lang('set_email_'.$k));
|
||||
}
|
||||
}
|
||||
if(!preg_match('/[\w\-]+\@[\w\-\.]+/i', $config['email'])){
|
||||
$this->error(lang('set_email_email').'格式错误');
|
||||
}
|
||||
|
||||
if($is_test){
|
||||
|
||||
$return=\util\Tools::send_mail($config, $config['email'], $config['sender'],lang('set_email_test_subject'),lang('set_email_test_body'));
|
||||
|
@ -671,6 +688,9 @@ class Setting extends BaseController {
|
|||
$this->error($return,'');
|
||||
}
|
||||
}else{
|
||||
if(!empty($config['caiji']['email'])&&!preg_match('/[\w\-]+\@[\w\-\.]+/i', $config['caiji']['email'])){
|
||||
$this->error('收件邮箱格式错误');
|
||||
}
|
||||
$mconfig->setConfig('email',$config);
|
||||
$this->success(lang('op_success'),'setting/email');
|
||||
}
|
||||
|
@ -679,7 +699,7 @@ class Setting extends BaseController {
|
|||
lang('setting_email'),
|
||||
lang('setting_email'),
|
||||
breadcrumb(array(array('url'=>url('setting/email'),'title'=>lang('setting_email'))))
|
||||
);
|
||||
);
|
||||
$emailConfig=$mconfig->getConfig('email','data');
|
||||
init_array($emailConfig);
|
||||
$this->assign('emailConfig',$emailConfig);
|
||||
|
@ -720,7 +740,10 @@ class Setting extends BaseController {
|
|||
|
||||
$chromeSocket=$this->_chrome_socket($config);
|
||||
$toolIsOpen=$chromeSocket?$chromeSocket->hostIsOpen():false;
|
||||
$serverIsLocal=$chromeSocket?$chromeSocket->serverIsLocal():false;
|
||||
|
||||
$this->assign('toolIsOpen',$toolIsOpen);
|
||||
$this->assign('serverIsLocal',$serverIsLocal);
|
||||
|
||||
return $this->fetch('page_render');
|
||||
}
|
||||
|
@ -760,6 +783,25 @@ class Setting extends BaseController {
|
|||
}
|
||||
}
|
||||
|
||||
if(in_array('all', $types)||in_array('table', $types)){
|
||||
|
||||
$tables=config('database.prefix').'cache';
|
||||
$passTables=array($tables,$tables.'_backstage_task',$tables.'_collecting');
|
||||
$tables=db()->query("show tables like '{$tables}%';");
|
||||
if($tables&&is_array($tables)){
|
||||
foreach ($tables as $table){
|
||||
if($table&&is_array($table)){
|
||||
foreach ($table as $v){
|
||||
if(!in_array($v, $passTables)){
|
||||
|
||||
db()->table($v)->where('1=1')->delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($clearPageRender&&(in_array('all', $types)||in_array('page_render', $types))){
|
||||
|
||||
$this->_clear_page_render();
|
||||
|
@ -852,10 +894,8 @@ class Setting extends BaseController {
|
|||
}
|
||||
if($info['error']){
|
||||
$this->error($info['error']);
|
||||
}elseif($info['output']){
|
||||
$this->success('测试成功:'.$info['output']);
|
||||
}else{
|
||||
$this->success('测试成功');
|
||||
$this->success('测试成功,请保存配置以便生效'.($info['output']?(','.$info['output']):''));
|
||||
}
|
||||
}elseif($info['error']){
|
||||
$this->error($info['error']);
|
||||
|
|
|
@ -263,7 +263,7 @@ class Task extends CollectController {
|
|||
}
|
||||
return $taskList;
|
||||
}
|
||||
public function saveAction(){
|
||||
public function setAction(){
|
||||
$mtask=model('Task');
|
||||
$taskData=null;
|
||||
$id=input('id/d',0);
|
||||
|
@ -287,7 +287,7 @@ class Task extends CollectController {
|
|||
$newData['config']['img_url']=input('config.img_url','','trim');
|
||||
}
|
||||
$newData['sort']=min(intval($newData['sort']),999999);
|
||||
$newData['config']=$this->_save_config($newData['config']);
|
||||
$newData['config']=$this->_set_config($newData['config']);
|
||||
$newData['config']=serialize($newData['config']);
|
||||
$taskTimerData=$newData['task_timer'];
|
||||
unset($newData['task_timer']);
|
||||
|
@ -334,9 +334,9 @@ class Task extends CollectController {
|
|||
}
|
||||
}
|
||||
|
||||
$this->_save_common($taskData, $taskTimerData);
|
||||
$this->_set_common($taskData, $taskTimerData);
|
||||
|
||||
$this->success(lang('op_success'),input('referer','','trim')?input('referer','','trim'):('task/save?id='.$tid));
|
||||
$this->success(lang('op_success'),input('referer','','trim')?input('referer','','trim'):('task/set?id='.$tid));
|
||||
}else{
|
||||
$this->error(lang('op_failed'));
|
||||
}
|
||||
|
@ -353,21 +353,22 @@ class Task extends CollectController {
|
|||
if($mtask->strict(false)->where(array('id'=>intval($taskData['id'])))->update($newData)>=0){
|
||||
$taskData=$mtask->getById($taskData['id']);
|
||||
|
||||
$this->_save_common($taskData, $taskTimerData);
|
||||
$this->_set_common($taskData, $taskTimerData);
|
||||
|
||||
$this->success(lang('op_success'),'task/save?id='.$taskData['id']);
|
||||
$this->success(lang('op_success'),'task/set?id='.$taskData['id']);
|
||||
}else{
|
||||
$this->error(lang('op_failed'));
|
||||
}
|
||||
}
|
||||
}else{
|
||||
$tipsSingle='';
|
||||
$mtaskgroup=model('Taskgroup');
|
||||
$tgSelect=$mtaskgroup->getLevelSelect();
|
||||
if($isAdd){
|
||||
$this->set_html_tags(
|
||||
lang('task_add'),
|
||||
lang('task_add'),
|
||||
breadcrumb(array(array('url'=>url('task/list'),'title'=>lang('task_list')),array('url'=>url('task/save'),'title'=>lang('task_add'))))
|
||||
breadcrumb(array(array('url'=>url('task/list'),'title'=>lang('task_list')),array('url'=>url('task/set'),'title'=>lang('task_add'))))
|
||||
);
|
||||
}else{
|
||||
if(input('?show_config')){
|
||||
|
@ -378,20 +379,54 @@ class Task extends CollectController {
|
|||
$this->set_html_tags(
|
||||
'任务:'.$taskData['name'],
|
||||
lang('task_edit').':'.$taskData['name'].'(id:'.$taskData['id'].')',
|
||||
breadcrumb(array(array('url'=>url('task/list'),'title'=>lang('task_list')),array('url'=>url('task/save?id='.$taskData['id']),'title'=>$taskData['name'])))
|
||||
breadcrumb(array(array('url'=>url('task/list'),'title'=>lang('task_list')),array('url'=>url('task/set?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){
|
||||
if(!empty($collData)){
|
||||
|
||||
$collConfig=unserialize($collData['config']?:'');
|
||||
if(is_array($collConfig)&&is_array($collConfig['field_list'])){
|
||||
foreach($collConfig['field_list'] as $v){
|
||||
$fieldList[]=$v['name'];
|
||||
}
|
||||
$fieldList=array_unique($fieldList);
|
||||
$fieldList=array_filter($fieldList);
|
||||
}
|
||||
$singleConfig=$taskData['config']['single'];
|
||||
if($singleConfig&&$singleConfig['open']){
|
||||
$tipsSingle=',单页采集模式中不使用';
|
||||
|
||||
$eCpattern=new \skycaiji\admin\event\CpatternSingle();
|
||||
$eCpattern->init($collData);
|
||||
$singleIptUrls=$eCpattern->single_get_input_urls(array(), $input_urls);
|
||||
|
||||
$singleApiUrl=array('url'=>'<b>内容页网址</b>');
|
||||
$singleIptMore=false;
|
||||
if(isset($singleIptUrls['source_url'])){
|
||||
|
||||
$singleApiUrl['source_url']='<b>起始页网址</b>';
|
||||
$singleIptMore=true;
|
||||
}
|
||||
if(is_array($singleIptUrls['level_url'])){
|
||||
foreach ($singleIptUrls['level_url'] as $level_url){
|
||||
$singleApiUrl['level'.$level_url['level'].'_url']='<b>多级页“'.$level_url['name'].'”网址</b>';
|
||||
$singleIptMore=true;
|
||||
}
|
||||
}
|
||||
foreach ($singleApiUrl as $k=>$v){
|
||||
$singleApiUrl[$k]=$k.'='.$v;
|
||||
}
|
||||
|
||||
$singleKey=$singleConfig['key']?('/'.md5($singleConfig['key'])):'';
|
||||
|
||||
$singleApiUrl=htmlspecialchars(config('root_website').'/?s=/api_single/'.$taskData['id'].$singleKey.'&').implode('&', $singleApiUrl);
|
||||
|
||||
$this->assign('singleApiUrl',$singleApiUrl);
|
||||
$this->assign('singleIptMore',$singleIptMore);
|
||||
}
|
||||
|
||||
}
|
||||
$mtimer=model('TaskTimer');
|
||||
$timerData=$mtimer->getTimer($taskData['id']);
|
||||
|
@ -400,6 +435,7 @@ class Task extends CollectController {
|
|||
$timerInfo=$timerInfo?('<br><b>定时:</b>'.$timerInfo):'';
|
||||
|
||||
$this->assign('taskData',$taskData);
|
||||
$this->assign('collData',$collData);
|
||||
$this->assign('timerInfo',$timerInfo);
|
||||
$this->assign('fieldList',$fieldList);
|
||||
}
|
||||
|
@ -454,34 +490,22 @@ class Task extends CollectController {
|
|||
$this->assign('gConfig',$gConfig);
|
||||
$this->assign('tgSelect',$tgSelect);
|
||||
$this->assign('numGtG',$numGtG);
|
||||
$this->assign('tipsSingle',$tipsSingle);
|
||||
|
||||
$this->assign('proxyGroups',model('ProxyGroup')->getAll());
|
||||
if(request()->isAjax()){
|
||||
return view('save_ajax');
|
||||
return view('set_ajax');
|
||||
}else{
|
||||
return $this->fetch('save');
|
||||
return $this->fetch('set');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function import_rule_fileAction(){
|
||||
if(request()->isPost()){
|
||||
$result=controller('admin/Mystore')->_upload_addon(true,'rule_file',false,false);
|
||||
if($result['success']){
|
||||
$this->success($result['msg'],'',$result);
|
||||
}else{
|
||||
$this->error($result['msg'],'',$result);
|
||||
}
|
||||
}else{
|
||||
$this->error();
|
||||
}
|
||||
}
|
||||
|
||||
private function _save_common($taskData,$taskTimerData){
|
||||
private function _set_common($taskData,$taskTimerData){
|
||||
|
||||
$ruleId=input('rule_id');
|
||||
if(!empty($taskData)&&!empty($ruleId)){
|
||||
$this->_import_rule($taskData, $ruleId);
|
||||
$ruleImport=input('rule_import','','trim');
|
||||
if(!empty($taskData)&&!empty($ruleImport)){
|
||||
$this->_import_rule($taskData,$ruleImport);
|
||||
}
|
||||
|
||||
model('TaskTimer')->addTimer($taskData['id'],$taskTimerData);
|
||||
|
@ -494,7 +518,7 @@ class Task extends CollectController {
|
|||
}
|
||||
}
|
||||
|
||||
private function _save_config($config=array()){
|
||||
private function _set_config($config=array()){
|
||||
|
||||
$config=is_array($config)?$config:array();
|
||||
$config['num']=empty($config['num'])?'':$config['num'];
|
||||
|
@ -621,41 +645,38 @@ class Task extends CollectController {
|
|||
return $config;
|
||||
}
|
||||
|
||||
private function _import_rule($taskData,$ruleId){
|
||||
private function _import_rule($taskData,$ruleImport){
|
||||
$mtask=model('Task');
|
||||
$mrule=model('Rule');
|
||||
$mcoll=model('Collector');
|
||||
|
||||
list($ruleType,$ruleId)=explode(':', $ruleId);
|
||||
$ruleId=intval($ruleId);
|
||||
list($ruleType,$ruleVal)=explode(':',$ruleImport,2);
|
||||
$ruleType=strtolower($ruleType);
|
||||
$ruleVal=$ruleVal?:'';
|
||||
if(!empty($taskData)){
|
||||
$name=null;
|
||||
$module=null;
|
||||
$config=null;
|
||||
if('rule'==$ruleType){
|
||||
|
||||
$ruleData=$mrule->getById($ruleId);
|
||||
$ruleVal=intval($ruleVal);
|
||||
$ruleData=$mrule->getById($ruleVal);
|
||||
}elseif('collector'==$ruleType){
|
||||
|
||||
$ruleData=$mcoll->getById($ruleId);
|
||||
|
||||
$ruleVal=intval($ruleVal);
|
||||
$ruleData=$mcoll->getById($ruleVal);
|
||||
}elseif('file'==$ruleType){
|
||||
|
||||
$result=controller('admin/Mystore')->_upload_addon(true,'rule_file',false,true);
|
||||
if(!$result['success']){
|
||||
$this->error($result['msg'],'task/save?id='.$taskData['id']);
|
||||
}else{
|
||||
$ruleData=$result['ruleData'];
|
||||
}
|
||||
|
||||
$ruleData=unserialize(base64_decode($ruleVal));
|
||||
init_array($ruleData);
|
||||
}
|
||||
|
||||
if(!empty($ruleData)){
|
||||
$name=$ruleData['name'];
|
||||
$module=$ruleData['module'];
|
||||
$config=$ruleData['config'];
|
||||
}
|
||||
|
||||
$referer=input('referer','','trim')?input('referer','','trim'):('task/save?id='.$taskData['id']);
|
||||
$referer=input('referer','','trim')?input('referer','','trim'):('task/set?id='.$taskData['id']);
|
||||
|
||||
if(empty($module)||(strcasecmp($module, $taskData['module'])!==0)){
|
||||
$this->error('导入的规则模块错误',$referer);
|
||||
|
|
|
@ -20,7 +20,6 @@ class CollectBase extends \skycaiji\admin\controller\CollectController {
|
|||
return null;
|
||||
}else{
|
||||
$url=$url?$url:'';
|
||||
|
||||
$msg=$this->_echo_msg_str($msg,'red');
|
||||
$txt=g_sc('collect_echo_msg_txt');
|
||||
$txt=$txt?($txt."\r\n".$msg):$msg;
|
||||
|
@ -32,7 +31,6 @@ class CollectBase extends \skycaiji\admin\controller\CollectController {
|
|||
if($this->is_collecting()){
|
||||
parent::echo_msg($strArgs,$color,$echo,$end_str,$div_style);
|
||||
}else{
|
||||
|
||||
$msg=$this->_echo_msg_str($strArgs,$color,$end_str,$div_style);
|
||||
$txt=g_sc('collect_echo_msg_txt');
|
||||
$txt=$txt?($txt."\r\n".$msg):$msg;
|
||||
|
@ -103,7 +101,7 @@ class CollectBase extends \skycaiji\admin\controller\CollectController {
|
|||
if($stop){
|
||||
$this->echo_msg('已终止运行');
|
||||
$this->echo_msg_end();
|
||||
exit();
|
||||
throw new \Exception('[exception_exit_collect]');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,8 +15,6 @@ class Cpattern extends CpatternEvent{
|
|||
/*处理post配置*/
|
||||
public function setConfig($config){
|
||||
$config['url_complete']=intval($config['url_complete']);
|
||||
|
||||
$config['url_reverse']=intval($config['url_reverse']);
|
||||
$config['page_render']=intval($config['page_render']);
|
||||
$config['url_repeat']=intval($config['url_repeat']);
|
||||
$config['url_no_name']=intval($config['url_no_name']);
|
||||
|
@ -42,7 +40,7 @@ class Cpattern extends CpatternEvent{
|
|||
foreach ($config['front_urls'] as $k=>$v){
|
||||
$v=json_decode(url_b64decode($v),true);
|
||||
$v=$this->page_set_config('front_url',$v);
|
||||
if(!preg_match('/^\w+\:\/\/[^\r\n]+/i', $v['url'])){
|
||||
if(empty($v['url'])){
|
||||
unset($config['front_urls'][$k]);
|
||||
}else{
|
||||
$config['front_urls'][$k]=$v;
|
||||
|
@ -638,7 +636,7 @@ class Cpattern extends CpatternEvent{
|
|||
}
|
||||
if($count_db_used>0){
|
||||
$sourceWaitTime=$source_interval-max($time_interval_list);
|
||||
$this->echo_msg(array('起始页过滤了%s条已采集网址,再次采集需等待%s <a href="%s" target="_blank">设置运行间隔</a>',$count_db_used,\skycaiji\admin\model\Config::wait_time_tips($sourceWaitTime),url('admin/task/save?show_config=1&id='.$this->collector['task_id'])),'black');
|
||||
$this->echo_msg(array('已采集起始页网址%s条,再次采集需等待%s <a href="%s" target="_blank">设置采集运行间隔</a>',$count_db_used,\skycaiji\admin\model\Config::wait_time_tips($sourceWaitTime),url('admin/task/set?show_config=1&id='.$this->collector['task_id'])),'black');
|
||||
if(count($this->original_source_urls)<=count($this->used_source_urls)){
|
||||
$this->echo_msg('所有起始页采集完毕','green');
|
||||
return 'completed';
|
||||
|
@ -773,31 +771,7 @@ class Cpattern extends CpatternEvent{
|
|||
$htmlInfo=$this->get_page_html($frontUrl,'front_url',$fuv['name'],false,true);
|
||||
if($fuv['use_cookie']||$fuv['use_cookie_img']||$fuv['use_cookie_file']){
|
||||
|
||||
$mUseCookie=array();
|
||||
if($htmlInfo['header']){
|
||||
if(preg_match_all('/^\s*cookie\s*\:([^\r\n]+);/im', $htmlInfo['header'], $mcookies)){
|
||||
|
||||
foreach ($mcookies[1] as $mcv){
|
||||
if(preg_match_all('/([^\;]+?)\=([^\;]*)/',$mcv,$mcookie)){
|
||||
foreach ($mcookie[1] as $k=>$v){
|
||||
$v=trim($v);
|
||||
if($v){
|
||||
$mUseCookie[$v]=$mcookie[2][$k];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(preg_match_all('/\bset\-cookie\s*\:([^\;]+?)\=([^\;]*)/i', $htmlInfo['header'], $mcookies)){
|
||||
|
||||
foreach ($mcookies[1] as $k=>$v){
|
||||
$v=trim($v);
|
||||
if($v){
|
||||
$mUseCookie[$v]=$mcookies[2][$k];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$mUseCookie=\util\Funcs::get_cookies_from_header($htmlInfo['header']);
|
||||
if($fuv['use_cookie']){
|
||||
$gUseCookie=\util\Param::get_gsc_use_cookie();
|
||||
init_array($gUseCookie);
|
||||
|
@ -1759,10 +1733,15 @@ class Cpattern extends CpatternEvent{
|
|||
unset($contUrlsMatches['matches'][$k]);
|
||||
}
|
||||
}
|
||||
|
||||
if(!empty($this->config['url_reverse'])){
|
||||
if(!empty($this->config['url_order'])){
|
||||
|
||||
$cont_urls=array_reverse($cont_urls);
|
||||
if('shuffle'==$this->config['url_order']){
|
||||
|
||||
shuffle($cont_urls);
|
||||
}elseif('reverse'==$this->config['url_order']){
|
||||
|
||||
$cont_urls=array_reverse($cont_urls);
|
||||
}
|
||||
}
|
||||
|
||||
$this->page_url_matches[$pageType][$pageName]=$contUrlsMatches['matches'];
|
||||
|
@ -1810,9 +1789,7 @@ class Cpattern extends CpatternEvent{
|
|||
|
||||
$level=max(1,$level);
|
||||
$level_str='';
|
||||
for($i=1;$i<$level;$i++){
|
||||
|
||||
}
|
||||
|
||||
$next_level_str=$level_str;
|
||||
if($level<=1){
|
||||
|
||||
|
@ -1866,7 +1843,7 @@ class Cpattern extends CpatternEvent{
|
|||
}
|
||||
if($count_db_used>0){
|
||||
$levelWaitTime=$level_interval-max($time_interval_list);
|
||||
$this->echo_msg(array('%s过滤了%s条已采集网址,再次采集需等待%s <a href="%s" target="_blank">设置运行间隔</a>',$level_str.$level_name,$count_db_used,\skycaiji\admin\model\Config::wait_time_tips($levelWaitTime),url('admin/task/save?show_config=1&id='.$this->collector['task_id'])),'black');
|
||||
$this->echo_msg(array('已采集%s网址%s条,再次采集需等待%s <a href="%s" target="_blank">设置采集运行间隔</a>',$level_str.$level_name,$count_db_used,\skycaiji\admin\model\Config::wait_time_tips($levelWaitTime),url('admin/task/set?show_config=1&id='.$this->collector['task_id'])),'black');
|
||||
if(count($level_urls)<=$count_db_used){
|
||||
$this->echo_msg(array('%s网址采集完毕!',$level_str.$level_name),'green',true,$end_echo);
|
||||
return 'completed';
|
||||
|
@ -1933,6 +1910,7 @@ class Cpattern extends CpatternEvent{
|
|||
if(count($this->collected_field_list)>=$this->collect_num){
|
||||
|
||||
if($cur_level_i<count((array)$level_data['urls'])){
|
||||
|
||||
$finished_source=false;
|
||||
}
|
||||
$forBreak=true;
|
||||
|
@ -1971,6 +1949,7 @@ class Cpattern extends CpatternEvent{
|
|||
}
|
||||
$this->echo_msg('','',true,$end_echo);
|
||||
}
|
||||
|
||||
/*采集字段列表*/
|
||||
public function _collect_fields($echo_str=''){
|
||||
$mcollected=model('Collected');
|
||||
|
@ -1979,6 +1958,8 @@ class Cpattern extends CpatternEvent{
|
|||
$mcacheCont=CacheModel::getInstance('cont_url');
|
||||
$pageOpened=$this->page_opened_tips('url');
|
||||
|
||||
$url_repeat=$this->config['url_repeat']?true:false;
|
||||
|
||||
|
||||
foreach ($this->cont_urls_list as $cont_key=>$cont_urls){
|
||||
$source_type=0;
|
||||
|
@ -1989,17 +1970,19 @@ class Cpattern extends CpatternEvent{
|
|||
}else{
|
||||
$source_type=1;
|
||||
}
|
||||
|
||||
if($source_type==2){
|
||||
if(array_key_exists($cont_key,$this->used_level_urls)){
|
||||
|
||||
continue;
|
||||
}
|
||||
}else{
|
||||
if(array_key_exists($cont_key,$this->used_source_urls)){
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if($cont_key){
|
||||
if($source_type==2){
|
||||
if(array_key_exists($cont_key,$this->used_level_urls)){
|
||||
|
||||
continue;
|
||||
}
|
||||
}else{
|
||||
if(array_key_exists($cont_key,$this->used_source_urls)){
|
||||
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$finished_cont=true;
|
||||
|
@ -2011,22 +1994,21 @@ class Cpattern extends CpatternEvent{
|
|||
|
||||
continue;
|
||||
}
|
||||
if($this->config['url_repeat']||$mcollected->collGetNumByUrl($cont_url)<=0){
|
||||
|
||||
if(!empty($this->collected_field_list)){
|
||||
if($url_repeat||$mcollected->collGetNumByUrl($cont_url)<=0){
|
||||
|
||||
if(!empty($this->collected_field_list)){
|
||||
|
||||
$millisecond=g_sc_c('caiji','interval_html');
|
||||
if($millisecond>0){
|
||||
$this->collect_sleep($millisecond,true,true);
|
||||
|
||||
if(!$this->config['url_repeat']&&$mcollected->collGetNumByUrl($cont_url)>0){
|
||||
if(!$url_repeat&&$mcollected->collGetNumByUrl($cont_url)>0){
|
||||
$this->echo_msg(array('已采集过网址:<a href="%s" target="_blank">%s</a>',$cont_url,$cont_url),'black');
|
||||
$this->used_cont_urls[$md5_cont_url]=1;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($mcacheCont->getCount($md5_cont_url)>0){
|
||||
|
||||
$this->used_cont_urls[$md5_cont_url]=1;
|
||||
|
@ -2034,141 +2016,14 @@ class Cpattern extends CpatternEvent{
|
|||
continue;
|
||||
}
|
||||
$mcacheCont->setCache($md5_cont_url, 1);
|
||||
|
||||
$this->echo_url_msg(array('%s采集内容页',$echo_str),$cont_url,$pageOpened);
|
||||
$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(array('%s通过数据处理筛除了%s条数据',$echo_str,$loopExcludeNum),'black');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$this->collect_stopped($this->collector['task_id']);
|
||||
|
||||
if(!empty($field_vals_list)){
|
||||
$is_real_time=false;
|
||||
if(!is_empty(g_sc_c('caiji','real_time'))&&!is_empty(g_sc('real_time_release'))){
|
||||
|
||||
$is_real_time=true;
|
||||
}
|
||||
if(!$is_loop){
|
||||
|
||||
$field_vals_list=array($field_vals_list);
|
||||
}else{
|
||||
|
||||
|
||||
$loop_cont_urls=array();
|
||||
foreach ($field_vals_list as $k=>$field_vals){
|
||||
$loop_cont_urls[$k]=$cont_url.'#'.md5(serialize($field_vals));
|
||||
}
|
||||
if(!empty($loop_cont_urls)){
|
||||
$loop_exists_urls=$mcollected->collGetUrlByUrl($loop_cont_urls);
|
||||
if(!empty($loop_exists_urls)){
|
||||
|
||||
$loop_exists_urls=array_flip($loop_exists_urls);
|
||||
foreach ($loop_cont_urls as $k=>$loop_cont_url){
|
||||
if(isset($loop_exists_urls[$loop_cont_url])){
|
||||
|
||||
unset($field_vals_list[$k]);
|
||||
}
|
||||
}
|
||||
$this->echo_msg(array('%s已过滤%s条重复数据',$echo_str,count((array)$loop_exists_urls)),'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);
|
||||
if($is_loop){
|
||||
|
||||
$collected_data['url'].='#'.md5(serialize($field_vals));
|
||||
}else{
|
||||
|
||||
if(isset($this->exclude_cont_urls[$md5_cont_url])){
|
||||
|
||||
$collected_error=reset($this->exclude_cont_urls[$md5_cont_url]);
|
||||
$collected_error=$this->exclude_url_msg($collected_error);
|
||||
}
|
||||
}
|
||||
if(empty($collected_error)){
|
||||
if(!empty($this->config['field_title'])){
|
||||
|
||||
$collected_data['title']=$field_vals[$this->config['field_title']]['value'];
|
||||
if(!empty($collected_data['title'])){
|
||||
|
||||
if($mcollected->collGetNumByTitle($collected_data['title'])>0){
|
||||
|
||||
$collected_error='标题重复:'.mb_substr($collected_data['title'],0,300,'utf-8');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(empty($collected_error)){
|
||||
if(!empty($this->config['field_content'])){
|
||||
|
||||
$collected_data['content']=array();
|
||||
foreach($this->config['field_content'] as $fcField){
|
||||
$collected_data['content'][$fcField]=$field_vals[$fcField]['value'];
|
||||
}
|
||||
if(!empty($collected_data['content'])){
|
||||
|
||||
ksort($collected_data['content']);
|
||||
$collected_data['content']=implode("\r\n", $collected_data['content']);
|
||||
if($mcollected->collGetNumByContent($collected_data['content'])>0){
|
||||
|
||||
$collected_error='内容重复';
|
||||
}
|
||||
}else{
|
||||
$collected_data['content']='';
|
||||
}
|
||||
}
|
||||
}
|
||||
if(empty($collected_error)){
|
||||
|
||||
if($is_real_time){
|
||||
|
||||
|
||||
g_sc('real_time_release')->doExport(array($collected_data));
|
||||
|
||||
unset($collected_data['fields']);
|
||||
unset($collected_data['title']);
|
||||
}
|
||||
|
||||
$this->collected_field_list[]=$collected_data;
|
||||
}else{
|
||||
|
||||
if(!$this->config['url_repeat']){
|
||||
|
||||
controller('ReleaseBase','event')->record_collected($collected_data['url'],
|
||||
array('id'=>0,'error'=>$collected_error),array('task_id'=>$this->collector['task_id'],'module'=>$this->release['module'])
|
||||
);
|
||||
}else{
|
||||
|
||||
$this->echo_msg(array('%s',$collected_error));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($is_loop){
|
||||
|
||||
|
||||
controller('ReleaseBase','event')->record_collected(
|
||||
$cont_url,array('id'=>1,'target'=>'','desc'=>'循环入库'.($loopExcludeNum>0?(',数据处理筛除了'.$loopExcludeNum.'条数据'):'')),array('task_id'=>$this->collector['task_id'],'module'=>$this->release['module']),null,false
|
||||
);
|
||||
}
|
||||
$this->_collect_fields_vals($echo_str, $cont_url, $md5_cont_url, $field_vals_list, $url_repeat);
|
||||
}else{
|
||||
|
||||
$this->echo_msg(array('已采集过网址:<a href="%s" target="_blank">%s</a>',$cont_url,$cont_url),'black');
|
||||
|
@ -2190,21 +2045,23 @@ class Cpattern extends CpatternEvent{
|
|||
|
||||
if($finished_cont){
|
||||
|
||||
if($source_type==1){
|
||||
|
||||
$mcacheSource->setCache(md5($cont_key),$cont_key);
|
||||
}elseif($source_type==2){
|
||||
|
||||
$mcacheLevel->setCache(md5($cont_key),$cont_key);
|
||||
}
|
||||
|
||||
if($source_type==2){
|
||||
|
||||
$this->used_level_urls[$cont_key]=1;
|
||||
}else{
|
||||
|
||||
$this->used_source_urls[$cont_key]=1;
|
||||
}
|
||||
if($cont_key){
|
||||
if($source_type==1){
|
||||
|
||||
$mcacheSource->setCache(md5($cont_key),$cont_key);
|
||||
}elseif($source_type==2){
|
||||
|
||||
$mcacheLevel->setCache(md5($cont_key),$cont_key);
|
||||
}
|
||||
|
||||
if($source_type==2){
|
||||
|
||||
$this->used_level_urls[$cont_key]=1;
|
||||
}else{
|
||||
|
||||
$this->used_source_urls[$cont_key]=1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($this->collect_num>0&&count($this->collected_field_list)>=$this->collect_num){
|
||||
|
@ -2212,5 +2069,134 @@ class Cpattern extends CpatternEvent{
|
|||
}
|
||||
}
|
||||
}
|
||||
public function _collect_fields_vals($echo_str,$cont_url,$md5_cont_url,&$field_vals_list,$url_repeat){
|
||||
$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(array('%s通过数据处理筛除了%s条数据',$echo_str,$loopExcludeNum),'black');
|
||||
}
|
||||
}
|
||||
$mcollected=model('Collected');
|
||||
if(!empty($field_vals_list)){
|
||||
if(!$is_loop){
|
||||
|
||||
$field_vals_list=array($field_vals_list);
|
||||
}else{
|
||||
|
||||
|
||||
$loop_cont_urls=array();
|
||||
foreach ($field_vals_list as $k=>$field_vals){
|
||||
$loop_cont_urls[$k]=$cont_url.'#'.md5(serialize($field_vals));
|
||||
}
|
||||
if(!empty($loop_cont_urls)){
|
||||
$loop_exists_urls=$mcollected->collGetUrlByUrl($loop_cont_urls);
|
||||
if(!empty($loop_exists_urls)){
|
||||
|
||||
$loop_exists_urls=array_flip($loop_exists_urls);
|
||||
foreach ($loop_cont_urls as $k=>$loop_cont_url){
|
||||
if(isset($loop_exists_urls[$loop_cont_url])){
|
||||
|
||||
unset($field_vals_list[$k]);
|
||||
}
|
||||
}
|
||||
$this->echo_msg(array('%s已过滤%s条重复数据',$echo_str,count((array)$loop_exists_urls)),'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);
|
||||
if($is_loop){
|
||||
|
||||
$collected_data['url'].='#'.md5(serialize($field_vals));
|
||||
}else{
|
||||
|
||||
if(isset($this->exclude_cont_urls[$md5_cont_url])){
|
||||
|
||||
$collected_error=reset($this->exclude_cont_urls[$md5_cont_url]);
|
||||
$collected_error=$this->exclude_url_msg($collected_error);
|
||||
}
|
||||
}
|
||||
if(empty($collected_error)){
|
||||
if(!empty($this->config['field_title'])){
|
||||
|
||||
$collected_data['title']=$field_vals[$this->config['field_title']]['value'];
|
||||
if(!empty($collected_data['title'])){
|
||||
|
||||
if($mcollected->collGetNumByTitle($collected_data['title'])>0){
|
||||
|
||||
$collected_error='标题重复:'.mb_substr($collected_data['title'],0,300,'utf-8');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(empty($collected_error)){
|
||||
if(!empty($this->config['field_content'])){
|
||||
|
||||
$collected_data['content']=array();
|
||||
foreach($this->config['field_content'] as $fcField){
|
||||
$collected_data['content'][$fcField]=$field_vals[$fcField]['value'];
|
||||
}
|
||||
if(!empty($collected_data['content'])){
|
||||
|
||||
ksort($collected_data['content']);
|
||||
$collected_data['content']=implode("\r\n", $collected_data['content']);
|
||||
if($mcollected->collGetNumByContent($collected_data['content'])>0){
|
||||
|
||||
$collected_error='内容重复';
|
||||
}
|
||||
}else{
|
||||
$collected_data['content']='';
|
||||
}
|
||||
}
|
||||
}
|
||||
if(empty($collected_error)){
|
||||
|
||||
if(!is_empty(g_sc_c('caiji','real_time'))){
|
||||
|
||||
|
||||
$rtRele=g_sc('real_time_release');
|
||||
if($rtRele){
|
||||
$rtRele->doExport(array($collected_data));
|
||||
unset($collected_data['fields']);
|
||||
unset($collected_data['title']);
|
||||
}
|
||||
}
|
||||
|
||||
$this->collected_field_list[]=$collected_data;
|
||||
}else{
|
||||
|
||||
if(!$url_repeat){
|
||||
|
||||
controller('ReleaseBase','event')->record_collected(
|
||||
$collected_data['url'],
|
||||
array('id'=>0,'error'=>$collected_error),array('task_id'=>$this->collector['task_id'],'module'=>$this->release['module'])
|
||||
);
|
||||
}else{
|
||||
|
||||
$this->echo_msg(array('%s',$collected_error));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($is_loop){
|
||||
|
||||
|
||||
controller('ReleaseBase','event')->record_collected(
|
||||
$cont_url,array('id'=>1,'target'=>'','desc'=>'循环入库'.($loopExcludeNum>0?(',数据处理筛除了'.$loopExcludeNum.'条数据'):'')),array('task_id'=>$this->collector['task_id'],'module'=>$this->release['module']),null,false
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -1786,6 +1786,11 @@ class CpatternColl extends CpatternBase{
|
|||
$retryParams=array(0=>$url,1=>$postData,2=>$headers,3=>$charset,4=>$otherConfig,5=>$returnInfo);
|
||||
}
|
||||
|
||||
if(!\util\Funcs::is_right_url($url)){
|
||||
$this->echo_error('网址缺少http(s)前缀:'.htmlspecialchars($url));
|
||||
return null;
|
||||
}
|
||||
|
||||
$pageOpened='';
|
||||
if(isset($postData)&&$postData!==false){
|
||||
|
||||
|
@ -1860,7 +1865,7 @@ class CpatternColl extends CpatternBase{
|
|||
$ex='页面渲染失败:'.$ex->getMessage().' 请检查<a href="'.url('setting/page_render').'" target="_blank">渲染设置</a>';
|
||||
if(!is_empty(g_sc_c('proxy','open'))){
|
||||
|
||||
$ex.=' <a href="'.(is_empty(g_sc('c_original','proxy','open'))?url('admin/task/save&id='.$this->collector['task_id']):url('setting/proxy')).'" target="_blank">代理设置</a>';
|
||||
$ex.=' <a href="'.(is_empty(g_sc('c_original','proxy','open'))?url('admin/task/set?id='.$this->collector['task_id']):url('setting/proxy')).'" target="_blank">代理设置</a>';
|
||||
}
|
||||
$this->echo_error($ex);
|
||||
return null;
|
||||
|
@ -1884,7 +1889,7 @@ class CpatternColl extends CpatternBase{
|
|||
}
|
||||
init_array($htmlInfo);
|
||||
$html=$htmlInfo['html'];
|
||||
if(empty($html)||!$htmlInfo['ok']){
|
||||
if((empty($html)&&empty($options['return_head']))||!$htmlInfo['ok']){
|
||||
|
||||
if(!empty($proxyDbIp)){
|
||||
$this->echo_msg(array('代理IP:%s',$proxyDbIp['ip']),'black',true,'','display:inline;margin-right:5px;');
|
||||
|
@ -1915,7 +1920,7 @@ class CpatternColl extends CpatternBase{
|
|||
}
|
||||
$retryCur=0;
|
||||
|
||||
if($this->config['url_complete']){
|
||||
if($this->config['url_complete']&&$html){
|
||||
|
||||
$url_info=$this->match_url_info($url,$html);
|
||||
|
||||
|
|
|
@ -221,6 +221,19 @@ class CpatternEvent extends CpatternColl{
|
|||
case 'description':$val=\util\HtmlParse::getDescription($html);break;
|
||||
case 'url':$val=$cur_url;break;
|
||||
case 'header':$val=trim($htmlInfo['header']);break;
|
||||
case 'cookie':
|
||||
$cookie=\util\Funcs::get_cookies_from_header($htmlInfo['header'],true);
|
||||
if(empty($cookie)){
|
||||
|
||||
$cookie=\util\Param::get_gsc_use_cookie('',true);
|
||||
if(empty($cookie)){
|
||||
|
||||
$headers=$this->config_params['headers']['page'];
|
||||
$cookie=is_array($headers)?$headers['cookie']:'';
|
||||
}
|
||||
}
|
||||
$val=$cookie;
|
||||
break;
|
||||
case 'html':$val=$html;break;
|
||||
}
|
||||
return $val;
|
||||
|
@ -381,7 +394,7 @@ class CpatternEvent extends CpatternColl{
|
|||
|
||||
return preg_replace('/'.$params['replace_from'].'/ui',$params['replace_to'], $fieldVal);
|
||||
}
|
||||
public function process_f_tool($fieldVal,$params){
|
||||
public function process_f_tool($fieldVal,$params,$fieldName=''){
|
||||
|
||||
if(in_array('format', $params['tool_list'])){
|
||||
|
||||
|
@ -396,23 +409,9 @@ class CpatternEvent extends CpatternColl{
|
|||
|
||||
$this->field_url_complete=false;
|
||||
}
|
||||
if(in_array('vedio_url', $params['tool_list'])){
|
||||
|
||||
$urls=array();
|
||||
if(preg_match_all('/<(object|embed|source)\b[^<>]+>/i',$fieldVal,$murls)){
|
||||
foreach ($murls[0] as $k=>$v){
|
||||
if(preg_match('/\b'.($murls[1][$k]=='object'?'data':'src').'\s*=[\'\"]([^\r\n]+?)[\'\"]/i',$v,$murl)){
|
||||
$urls[]=$murl[1];
|
||||
}
|
||||
}
|
||||
$urls=array_unique($urls);
|
||||
$urls=array_filter($urls);
|
||||
$urls=array_values($urls);
|
||||
}
|
||||
$fieldVal=implode("\r\n",$urls);
|
||||
}
|
||||
if(in_array('url_real', $params['tool_list'])){
|
||||
|
||||
|
||||
$headers=null;
|
||||
if(in_array('vedio_url', $params['tool_list'])||in_array('url_real', $params['tool_list'])){
|
||||
$headers=$this->config_params['headers']['page'];
|
||||
init_array($headers);
|
||||
$useCookie=\util\Param::get_gsc_use_cookie('',true);
|
||||
|
@ -421,9 +420,37 @@ class CpatternEvent extends CpatternColl{
|
|||
unset($headers['cookie']);
|
||||
$headers['cookie']=$useCookie;
|
||||
}
|
||||
$fieldVal=preg_replace_callback('/\bhttp[s]{0,1}\:\/\/[^\'\"\s]+/i',function($murl)use($headers){
|
||||
}
|
||||
|
||||
if(in_array('vedio_url', $params['tool_list'])){
|
||||
|
||||
$urls=$this->_process_f_tool_vdourl($fieldVal);
|
||||
if(empty($urls)){
|
||||
|
||||
if(preg_match_all('/<[i]{0,1}frame\b[^<>]*\bsrc\s*=[\'\"\s]*([^\'\"\s]+)[\'\"\s]*/',$fieldVal,$mfurls)){
|
||||
$mfurls=\util\Tools::clear_src_urls($mfurls[1]);
|
||||
$this->echo_msg(array('正在数据处理:%s » 工具箱:提取音视频网址',$fieldName),'black');
|
||||
foreach ($mfurls as $furl){
|
||||
$fhtml=$this->get_html($furl,false,$headers);
|
||||
$fvurls=$this->_process_f_tool_vdourl($fhtml);
|
||||
if($fvurls){
|
||||
$urls=array_merge($urls,$fvurls);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$fieldVal=$urls?implode("\r\n",$urls):'';
|
||||
}
|
||||
if(in_array('url_real', $params['tool_list'])){
|
||||
|
||||
$msgEchoed=false;
|
||||
$fieldVal=preg_replace_callback('/\bhttp[s]{0,1}\:\/\/[^\'\"\s]+/i',function($murl)use($headers,$fieldName,&$msgEchoed){
|
||||
if(!$msgEchoed){
|
||||
$msgEchoed=true;
|
||||
$this->echo_msg(array('正在数据处理:%s » 工具箱:网址真实地址',$fieldName),'black');
|
||||
}
|
||||
$murl=$murl[0];
|
||||
$urlInfo=$this->get_html($murl,false,$headers,null,array('return_head'=>1,'return_info'=>1,'curlopts'=>array(CURLOPT_CONNECTTIMEOUT=>5)),true);
|
||||
$urlInfo=$this->get_html($murl,false,$headers,null,array('return_head'=>1,'return_info'=>1),true);
|
||||
if(is_array($urlInfo)&&is_array($urlInfo['info'])&&$urlInfo['info']['url']){
|
||||
$murl=$urlInfo['info']['url'];
|
||||
}
|
||||
|
@ -432,6 +459,22 @@ class CpatternEvent extends CpatternColl{
|
|||
}
|
||||
return $fieldVal;
|
||||
}
|
||||
|
||||
private function _process_f_tool_vdourl($str){
|
||||
$urls=array();
|
||||
if($str&&preg_match_all('/<(video|object|embed|source)\b[^<>]+>/i',$str,$murls)){
|
||||
foreach ($murls[0] as $k=>$v){
|
||||
$tag=strtolower($murls[1][$k]);
|
||||
if(preg_match('/\b'.($tag=='object'?'data':'src').'\s*=[\'\"\s]*([^\'\"\s]+)[\'\"\s]*/i',$v,$murl)){
|
||||
$urls[]=\util\Tools::clear_src_urls($murl[1]);
|
||||
}
|
||||
}
|
||||
$urls=array_unique($urls);
|
||||
$urls=array_filter($urls);
|
||||
$urls=array_values($urls);
|
||||
}
|
||||
return $urls;
|
||||
}
|
||||
public function process_f_download($fieldVal,$params,$curUrlMd5,$loopIndex,$contUrlMd5,$fieldName=''){
|
||||
if($params['download_op']=='is_img'){
|
||||
|
||||
|
@ -613,7 +656,7 @@ class CpatternEvent extends CpatternColl{
|
|||
$batch_to=array();
|
||||
foreach ($mlist as $k=>$v){
|
||||
$v=explode($sign,$v,2);
|
||||
if(is_array($v)&&count($v)==2&&!empty($v[0])&&!empty($v[1])){
|
||||
if(is_array($v)&&count($v)==2&&!is_empty($v[0],true)){
|
||||
|
||||
$batch_re[]=$v[0];
|
||||
$batch_to[]=$v[1];
|
||||
|
@ -893,13 +936,11 @@ class CpatternEvent extends CpatternColl{
|
|||
$url=$params['api_url'];
|
||||
$htmlInfo=null;
|
||||
if(!empty($url)){
|
||||
$isLoc=false;
|
||||
if(!preg_match('/^\w+\:\/\//', $url)&&strpos($url, '/')===0){
|
||||
if(strpos($url, '/')===0){
|
||||
|
||||
$isLoc=true;
|
||||
$url=config('root_website').$url;
|
||||
}
|
||||
if(preg_match('/^\w+\:\/\//', $url)){
|
||||
if(\util\Funcs::is_right_url($url)){
|
||||
|
||||
|
||||
$charset=$params['api_charset'];
|
||||
|
@ -919,8 +960,7 @@ class CpatternEvent extends CpatternColl{
|
|||
$curlopts[CURLOPT_ENCODING]=$encode;
|
||||
}
|
||||
|
||||
|
||||
$url=$this->_replace_insert_fields($url, $curUrlMd5, $loopIndex);
|
||||
$url=$this->_replace_insert_fields($url,$fieldVal,$curUrlMd5,$loopIndex);
|
||||
$url=\util\Funcs::url_auto_encode($url, $charset);
|
||||
|
||||
|
||||
|
@ -939,7 +979,7 @@ class CpatternEvent extends CpatternColl{
|
|||
case 'field':$val=$fieldVal;break;
|
||||
case 'timestamp':$val=time();break;
|
||||
case 'time':$addon=$addon?$addon:'Y-m-d H:i:s';$val=date($addon,time());break;
|
||||
case 'custom':$val=$this->_replace_insert_fields($addon, $curUrlMd5, $loopIndex);break;
|
||||
case 'custom':$val=$this->_replace_insert_fields($addon,$fieldVal,$curUrlMd5,$loopIndex);break;
|
||||
}
|
||||
$postData[$v]=$val;
|
||||
}
|
||||
|
@ -960,7 +1000,7 @@ class CpatternEvent extends CpatternColl{
|
|||
case 'field':$val=$fieldVal;break;
|
||||
case 'timestamp':$val=time();break;
|
||||
case 'time':$addon=$addon?$addon:'Y-m-d H:i:s';$val=date($addon,time());break;
|
||||
case 'custom':$val=$this->_replace_insert_fields($addon, $curUrlMd5, $loopIndex);break;
|
||||
case 'custom':$val=$this->_replace_insert_fields($addon,$fieldVal,$curUrlMd5,$loopIndex);break;
|
||||
}
|
||||
$headers[$v]=$val;
|
||||
}
|
||||
|
@ -979,8 +1019,8 @@ class CpatternEvent extends CpatternColl{
|
|||
$url=\util\Funcs::url_params_charset($url,$postData,$charset);
|
||||
$postData=null;
|
||||
}
|
||||
|
||||
$htmlInfo=get_html($url,$headers,array('curlopts'=>$curlopts),$charset,$postData,true);
|
||||
$this->echo_msg(array('正在数据处理:%s » <a href="%s" target="_blank">调用接口</a>',$fieldName,$url),'black');
|
||||
$htmlInfo=get_html($url,$headers,array('timeout'=>60,'curlopts'=>$curlopts),$charset,$postData,true);
|
||||
$this->collect_sleep($params['api_interval'],true);
|
||||
if(!empty($htmlInfo['ok'])){
|
||||
|
||||
|
@ -1030,6 +1070,7 @@ class CpatternEvent extends CpatternColl{
|
|||
return $fieldVal;
|
||||
}
|
||||
static $conds=array('filter','if','func','api','download');
|
||||
static $fnConds=array('translate','tool');
|
||||
foreach ($process as $params){
|
||||
|
||||
if(empty($this->first_loop_field)){
|
||||
|
@ -1048,7 +1089,7 @@ class CpatternEvent extends CpatternColl{
|
|||
if(in_array($params['module'],$conds)){
|
||||
|
||||
$fieldVal=$this->$funcName($fieldVal,$params,$curUrlMd5,$loopIndex,$contUrlMd5,$fieldName);
|
||||
}elseif($params['module']=='translate'){
|
||||
}elseif(in_array($params['module'],$fnConds)){
|
||||
$fieldVal=$this->$funcName($fieldVal,$params,$fieldName);
|
||||
}else{
|
||||
$fieldVal=$this->$funcName($fieldVal,$params);
|
||||
|
@ -1190,9 +1231,10 @@ class CpatternEvent extends CpatternColl{
|
|||
}
|
||||
return $fieldVals;
|
||||
}
|
||||
private function _replace_insert_fields($paramsStr,$curUrlMd5,$loopIndex){
|
||||
private function _replace_insert_fields($paramsStr,$defaultVal,$curUrlMd5,$loopIndex){
|
||||
$fieldRule='/\[\x{5b57}\x{6bb5}\:(.+?)\]/u';
|
||||
return \util\Funcs::txt_replace_params(false, false, $paramsStr, '', $fieldRule, $this->_get_insert_fields($paramsStr, $curUrlMd5, $loopIndex));
|
||||
$fieldVals=$this->_get_insert_fields($paramsStr, $curUrlMd5, $loopIndex);
|
||||
return \util\Funcs::txt_replace_params(false, false, $paramsStr, $defaultVal, $fieldRule, $fieldVals);
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -0,0 +1,460 @@
|
|||
<?php
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| SkyCaiji (蓝天采集器)
|
||||
|--------------------------------------------------------------------------
|
||||
| Copyright (c) 2018 https://www.skycaiji.com All rights reserved.
|
||||
|--------------------------------------------------------------------------
|
||||
| 使用协议 https://www.skycaiji.com/licenses
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
namespace skycaiji\admin\event;
|
||||
use skycaiji\admin\model\CacheModel;
|
||||
/*单页采集模式*/
|
||||
class CpatternSingle extends Cpattern{
|
||||
public function echo_error($msg = '', $url = null, $data = array(), $wait = 3, array $header = []){
|
||||
if($this->is_collecting()){
|
||||
|
||||
$this->echo_msg($msg,'red');
|
||||
return null;
|
||||
}else{
|
||||
$url=$url?$url:'';
|
||||
$msg=$this->_echo_msg_str($msg,'red');
|
||||
$txt=g_sc('collect_echo_msg_txt');
|
||||
$txt=$txt?($txt."\r\n".$msg):$msg;
|
||||
if(\util\Param::is_collector_single()){
|
||||
|
||||
$txt=strip_tags($txt);
|
||||
json(array('code'=>0,'msg'=>$txt,'data'=>[]))->send();
|
||||
}else{
|
||||
parent::error($txt,$url,$data,$wait,$header);
|
||||
}
|
||||
}
|
||||
}
|
||||
public function collectSingle($singleConfig){
|
||||
init_array($singleConfig);
|
||||
$curUrl=input('url','','trim');
|
||||
if($curUrl&&!\util\Funcs::is_right_url($curUrl)){
|
||||
$curUrl='http://'.$curUrl;
|
||||
}
|
||||
$mcollected=model('Collected');
|
||||
$isCollected=$mcollected->collGetNumByUrl($curUrl)>0?true:false;
|
||||
$urlRepeat=$this->config['url_repeat'];
|
||||
$field_vals_list=null;
|
||||
if($singleConfig['always']||$urlRepeat||!$isCollected){
|
||||
|
||||
$sourceUrl=input('?source_url')?input('source_url','','trim'):null;
|
||||
if($sourceUrl&&!\util\Funcs::is_right_url($sourceUrl)){
|
||||
$sourceUrl='http://'.$sourceUrl;
|
||||
}
|
||||
$inputLevels=array();
|
||||
foreach (input('param.') as $k=>$v){
|
||||
|
||||
if(preg_match('/^level(\d+)_url$/',$k,$mLevel)){
|
||||
|
||||
$mLevel=intval($mLevel[1]);
|
||||
$inputLevels[$mLevel]=input($k,'','trim');
|
||||
if($inputLevels[$mLevel]&&!\util\Funcs::is_right_url($inputLevels[$mLevel])){
|
||||
$inputLevels[$mLevel]='http://'.$inputLevels[$mLevel];
|
||||
}
|
||||
}
|
||||
}
|
||||
$mcollected=model('Collected');
|
||||
|
||||
set_g_sc('collect_task_id',$this->collector['task_id']);
|
||||
set_g_sc(['c','caiji','interval'],0);
|
||||
set_g_sc(['c','caiji','interval_html'],0);
|
||||
$this->collect_num=0;
|
||||
$this->collected_field_list=array();
|
||||
|
||||
$this->collFrontUrls();
|
||||
$this->loadSingle('url', '', $curUrl, $sourceUrl, $inputLevels, null);
|
||||
|
||||
$field_vals_list=$this->getFields($curUrl);
|
||||
if($urlRepeat||!$isCollected){
|
||||
|
||||
$this->_collect_fields_vals('', $curUrl, md5($curUrl), $field_vals_list, $urlRepeat);
|
||||
}else{
|
||||
if(empty($this->first_loop_field)){
|
||||
|
||||
$field_vals_list=array($field_vals_list);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
|
||||
$this->echo_msg(array('已采集过网址:<a href="%s" target="_blank">%s</a>',$cont_url,$cont_url),'black');
|
||||
}
|
||||
|
||||
return array('data'=>$field_vals_list,'collected'=>$this->collected_field_list);
|
||||
}
|
||||
|
||||
public function loadSingle($pageType,$pageName,$curUrl,$sourceUrl,$levelUrls,$contUrl){
|
||||
|
||||
if(empty($curUrl)){
|
||||
$this->echo_error('请输入网址');
|
||||
}
|
||||
if(!\util\Funcs::is_right_url($curUrl)){
|
||||
$curUrl='http://'.$curUrl;
|
||||
}
|
||||
|
||||
|
||||
if($pageType=='front_url'){
|
||||
$this->cur_front_urls[$pageName]=$curUrl;
|
||||
$this->collFrontUrls(true);
|
||||
}elseif($pageType=='source_url'){
|
||||
$this->cur_source_url=$curUrl;
|
||||
}elseif($pageType=='level_url'){
|
||||
$this->cur_level_urls[$pageName]=$curUrl;
|
||||
}elseif($pageType=='url'){
|
||||
$this->cur_cont_url=$curUrl;
|
||||
}
|
||||
|
||||
if(isset($sourceUrl)){
|
||||
|
||||
|
||||
$this->cur_source_url=$sourceUrl;
|
||||
if(empty($this->cur_source_url)){
|
||||
$this->echo_error('请输入起始页');
|
||||
}
|
||||
}
|
||||
if($levelUrls){
|
||||
init_array($levelUrls);
|
||||
|
||||
ksort($levelUrls);
|
||||
foreach ($levelUrls as $k=>$v){
|
||||
$levelName=$this->get_config('level_urls',$k-1,'name');
|
||||
$this->cur_level_urls[$levelName]=$v;
|
||||
if(empty($v)){
|
||||
$this->echo_error('请输入多级页:'.$levelName);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(isset($contUrl)){
|
||||
|
||||
|
||||
$this->cur_cont_url=$contUrl;
|
||||
if(empty($this->cur_cont_url)){
|
||||
$this->echo_error('请输入内容页');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(!empty($this->cur_source_url)){
|
||||
|
||||
|
||||
if($pageType!='front_url'&&$pageType!='source_url'){
|
||||
if(empty($this->config['level_urls'])){
|
||||
|
||||
$this->getContUrls($this->cur_source_url,false);
|
||||
}else{
|
||||
|
||||
$this->getLevelUrls($this->cur_source_url,1,false);
|
||||
}
|
||||
}
|
||||
|
||||
$this->get_page_html($this->cur_source_url, 'source_url', '');
|
||||
}
|
||||
if(!empty($this->cur_level_urls)){
|
||||
|
||||
|
||||
$levelIsEnd=false;
|
||||
$levelCurNum=0;
|
||||
$levelCount=count($this->config['level_urls']);
|
||||
foreach ($this->config['level_urls'] as $k=>$v){
|
||||
$levelCurNum++;
|
||||
if(isset($this->cur_level_urls[$v['name']])){
|
||||
if($k==0){
|
||||
|
||||
if($this->cur_source_url){
|
||||
$this->getLevelUrls($this->cur_source_url,$k+1,false);
|
||||
}
|
||||
}else{
|
||||
|
||||
$prevLevelUrl=$this->config['level_urls'][$k-1];
|
||||
if($this->cur_level_urls[$prevLevelUrl['name']]){
|
||||
$this->getLevelUrls($this->cur_level_urls[$prevLevelUrl['name']],$k+1,false);
|
||||
}
|
||||
}
|
||||
|
||||
$this->get_page_html($this->cur_level_urls[$v['name']], 'level_url', $v['name']);
|
||||
}
|
||||
if($levelCurNum==$levelCount){
|
||||
$levelIsEnd=true;
|
||||
}
|
||||
|
||||
if($pageType=='level_url'&&$pageName==$v['name']){
|
||||
break;
|
||||
}
|
||||
}
|
||||
if($levelIsEnd){
|
||||
|
||||
$endLevel=$this->config['level_urls'][$levelCount-1];
|
||||
if(isset($this->cur_level_urls[$endLevel['name']])){
|
||||
if($pageType!='level_url'||$pageName!=$endLevel['name']){
|
||||
|
||||
$this->getContUrls($this->cur_level_urls[$endLevel['name']],false);
|
||||
|
||||
$this->get_page_html($this->cur_level_urls[$endLevel['name']], 'level_url', $endLevel['name']);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function single_input_urls($isContUrl,$pageType,$pageName,$inputedUrls,&$input_urls){
|
||||
$pageSigns=$this->parent_page_signs($pageType,$pageName);
|
||||
$this->single_signs_input_urls($isContUrl,false,$pageSigns,$inputedUrls,$input_urls);
|
||||
$pageSigns=$this->parent_page_signs($pageType,$pageName,'url_web');
|
||||
$this->single_signs_input_urls($isContUrl,true,$pageSigns,$inputedUrls,$input_urls);
|
||||
$pageSigns=$this->parent_page_signs($pageType,$pageName,'renderer');
|
||||
$this->single_signs_input_urls($isContUrl,true,$pageSigns,$inputedUrls,$input_urls);
|
||||
}
|
||||
|
||||
|
||||
public function single_signs_input_urls($isContUrl,$inPageConfig,$pageSigns,$inputedUrls,&$input_urls){
|
||||
$iptUrls=array();
|
||||
if(!empty($pageSigns)){
|
||||
if($inPageConfig){
|
||||
|
||||
if(!empty($pageSigns['cur'])&&(!empty($pageSigns['cur']['url'])||!empty($pageSigns['cur']['area']))){
|
||||
|
||||
$prevPageSource=$this->single_parent_page($isContUrl, $pageSigns['cur']['page_type'], $pageSigns['cur']['page_name']);
|
||||
if($prevPageSource){
|
||||
|
||||
list($prevPageType,$prevPageName)=$this->page_source_split($prevPageSource);
|
||||
if($prevPageType=='level_url'){
|
||||
if(is_array($this->config['level_urls'])){
|
||||
foreach ($this->config['level_urls'] as $k=>$v){
|
||||
if($v['name']==$prevPageName){
|
||||
$curLevelNum=$k+1;
|
||||
$iptUrls['level_url'][$curLevelNum]=array('level'=>$curLevelNum,'name'=>$v['name'],'url'=>$inputedUrls['level'.$curLevelNum.'_url']);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
$iptUrls[$prevPageType]=$inputedUrls[$prevPageType]?$inputedUrls[$prevPageType]:'';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(!empty($pageSigns['source_url'])&&is_array($pageSigns['source_url'])){
|
||||
if(!empty($pageSigns['source_url']['content'])){
|
||||
|
||||
$iptUrls['source_url']=$inputedUrls['source_url']?$inputedUrls['source_url']:'';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(!empty($pageSigns['level_url'])&&is_array($pageSigns['level_url'])){
|
||||
|
||||
$signLevels=array_keys($pageSigns['level_url']);
|
||||
if(is_array($this->config['level_urls'])){
|
||||
foreach ($this->config['level_urls'] as $levIx=>$levVal){
|
||||
|
||||
|
||||
$level=$levIx+1;
|
||||
if(in_array($levVal['name'],$signLevels)){
|
||||
|
||||
if($level==1){
|
||||
|
||||
$iptUrls['source_url']=$inputedUrls['source_url']?$inputedUrls['source_url']:'';
|
||||
}else{
|
||||
|
||||
$prevLevel=$level-1;
|
||||
$iptUrls['level_url'][$prevLevel]=array('level'=>$prevLevel,'name'=>$this->get_config('level_urls',$prevLevel-1,'name'),'url'=>$inputedUrls['level'.$prevLevel.'_url']);
|
||||
}
|
||||
|
||||
$iptUrls['level_url'][$level]=array('level'=>$level,'name'=>$levVal['name'],'url'=>$inputedUrls['level'.$level.'_url']);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!$isContUrl){
|
||||
|
||||
if(!empty($pageSigns['url'])||(!empty($pageSigns['relation_url'])&&is_array($pageSigns['relation_url']))){
|
||||
|
||||
$iptUrls['url']=$inputedUrls['url']?$inputedUrls['url']:'';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($iptUrls['source_url'])){
|
||||
$input_urls['source_url']=$iptUrls['source_url'];
|
||||
}
|
||||
if(is_array($iptUrls['level_url'])){
|
||||
foreach ($iptUrls['level_url'] as $k=>$v){
|
||||
$input_urls['level_url'][$k]=$v;
|
||||
}
|
||||
}
|
||||
if(isset($iptUrls['url'])){
|
||||
$input_urls['url']=$iptUrls['url'];
|
||||
}
|
||||
|
||||
return $iptUrls;
|
||||
}
|
||||
|
||||
|
||||
public function single_urls_parent($isContUrl,$curInputUrls,$inputedUrls,&$input_urls){
|
||||
$levelNames=array();
|
||||
if(is_array($curInputUrls)&&is_array($curInputUrls['level_url'])){
|
||||
foreach ($curInputUrls['level_url'] as $v){
|
||||
$levelNames[$v['name']]=$v['name'];
|
||||
}
|
||||
}
|
||||
if($levelNames){
|
||||
foreach ($levelNames as $levelName){
|
||||
$mergeTypes=array(''=>false,'url_web'=>true,'renderer'=>true);
|
||||
foreach ($mergeTypes as $mtk=>$mtv){
|
||||
$pageSigns=$this->parent_page_signs('level_url',$levelName,$mtk);
|
||||
$iptUrls=$this->single_signs_input_urls($isContUrl,$mtv,$pageSigns,$inputedUrls,$input_urls);
|
||||
if(is_array($iptUrls['level_url'])){
|
||||
|
||||
foreach ($iptUrls['level_url'] as $k=>$v){
|
||||
if(isset($input_urls['level_url'][$k])){
|
||||
unset($iptUrls['level_url'][$k]);
|
||||
}
|
||||
}
|
||||
if(!empty($iptUrls['level_url'])){
|
||||
$this->single_urls_parent($isContUrl,$iptUrls, $inputedUrls, $input_urls);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function single_parent_page($isContUrl,$pageType,$pageName){
|
||||
$prevPageType='';
|
||||
$prevPageName='';
|
||||
|
||||
if($pageType=='url'){
|
||||
|
||||
if(empty($this->config['level_urls'])){
|
||||
|
||||
$prevPageType='source_url';
|
||||
$prevPageName='';
|
||||
}else{
|
||||
|
||||
$endLevelNum=count($this->config['level_urls']);
|
||||
$prevPageType='level_url';
|
||||
$prevPageName=$this->config['level_urls'][$endLevelNum-1]['name'];
|
||||
}
|
||||
}elseif($pageType=='level_url'){
|
||||
|
||||
$prevLevelNum=-1;
|
||||
$prevLevel=null;
|
||||
if(is_array($this->config['level_urls'])){
|
||||
foreach ($this->config['level_urls'] as $k=>$v){
|
||||
$prevLevelNum=$k;
|
||||
if($v['name']==$pageName){
|
||||
|
||||
break;
|
||||
}
|
||||
$prevLevel=$v;
|
||||
}
|
||||
}
|
||||
if($prevLevelNum>-1){
|
||||
if($prevLevelNum==0){
|
||||
|
||||
$prevPageType='source_url';
|
||||
$prevPageName='';
|
||||
}else{
|
||||
|
||||
$prevPageType='level_url';
|
||||
$prevPageName=$prevLevel['name'];
|
||||
}
|
||||
}
|
||||
}elseif($pageType=='relation_url'){
|
||||
|
||||
if(!$isContUrl){
|
||||
|
||||
$prevPageType='url';
|
||||
$prevPageName='';
|
||||
}
|
||||
}
|
||||
return $this->page_source_merge($prevPageType, $prevPageName);
|
||||
}
|
||||
|
||||
public function single_get_input_urls($inputedUrls,$input_urls){
|
||||
init_array($inputedUrls);
|
||||
if(empty($inputedUrls['source_url'])){
|
||||
|
||||
$inputedUrls['source_url']='';
|
||||
}
|
||||
|
||||
|
||||
if(is_array($this->config['new_field_list'])){
|
||||
foreach ($this->config['new_field_list'] as $field){
|
||||
list($fPageType,$fPageName)=$this->page_source_split($field['field']['source']);
|
||||
if(empty($fPageType)){
|
||||
|
||||
if($field['field']['module']=='sign'){
|
||||
|
||||
if(empty($this->config['level_urls'])){
|
||||
$input_urls['source_url']=$inputedUrls['source_url'];
|
||||
}else{
|
||||
|
||||
$endLevelNum=count($this->config['level_urls']);
|
||||
$endLevel=$this->config['level_urls'][$endLevelNum-1];
|
||||
$input_urls['level_url'][$endLevelNum]=array('level'=>$endLevelNum,'name'=>$endLevel['name'],'url'=>$inputedUrls['level'.$endLevelNum.'_url']);
|
||||
}
|
||||
}
|
||||
}elseif('source_url'==$fPageType){
|
||||
|
||||
$input_urls['source_url']=$inputedUrls['source_url'];
|
||||
}elseif('level_url'==$fPageType){
|
||||
|
||||
if(is_array($this->config['level_urls'])){
|
||||
foreach($this->config['level_urls'] as $levIx=>$levVal){
|
||||
if($field['field']['source']==$this->page_source_merge('level_url',$levVal['name'])){
|
||||
|
||||
$level=$levIx+1;
|
||||
if($field['field']['module']=='sign'){
|
||||
|
||||
if($level==1){
|
||||
|
||||
$input_urls['source_url']=$inputedUrls['source_url'];
|
||||
}else{
|
||||
|
||||
$prevLevel=$level-1;
|
||||
$input_urls['level_url'][$prevLevel]=array('level'=>$prevLevel,'name'=>$this->get_config('level_urls',$prevLevel-1,'name'),'url'=>$inputedUrls['level'.$prevLevel.'_url']);
|
||||
}
|
||||
}
|
||||
|
||||
$input_urls['level_url'][$level]=array('level'=>$level,'name'=>$levVal['name'],'url'=>$inputedUrls['level'.$level.'_url']);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}elseif('relation_url'==$fPageType){
|
||||
|
||||
$this->single_input_urls(true,'relation_url',$fPageName,$inputedUrls,$input_urls);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$pageSigns=$this->parent_page_signs('url','','url_web');
|
||||
$this->single_signs_input_urls(true,true,$pageSigns,$inputedUrls,$input_urls);
|
||||
$pageSigns=$this->parent_page_signs('url','','renderer');
|
||||
$this->single_signs_input_urls(true,true,$pageSigns,$inputedUrls,$input_urls);
|
||||
|
||||
$this->single_urls_parent(true, $input_urls, $inputedUrls, $input_urls);
|
||||
if(is_array($input_urls['level_url'])){
|
||||
|
||||
ksort($input_urls['level_url']);
|
||||
}
|
||||
if($this->source_is_url()){
|
||||
|
||||
unset($input_urls['source_url']);
|
||||
}
|
||||
|
||||
return $input_urls;
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -18,14 +18,10 @@ class Rapi extends Release{
|
|||
*/
|
||||
public function setConfig($config){
|
||||
$api=\util\UnmaxPost::val('api/a',array());
|
||||
$api['url']=trim($api['url'],'\/\\');
|
||||
$api['cache_time']=intval($api['cache_time']);
|
||||
$api['hide_fields']=is_array($api['hide_fields'])?$api['hide_fields']:array();
|
||||
if(empty($api['url'])){
|
||||
$this->error('请输入api地址');
|
||||
}
|
||||
if(!preg_match('/^[a-zA-Z0-9\-\_]+$/i', $api['url'])){
|
||||
$this->error('api地址只能由字母、数字、下划线组成');
|
||||
if(empty($api['key'])){
|
||||
$this->error('请输入API密钥');
|
||||
}
|
||||
$config['api']=$api;
|
||||
return $config;
|
||||
|
@ -88,7 +84,11 @@ class Rapi extends Release{
|
|||
public function json_exit($collFieldsList){
|
||||
if(\util\Param::is_task_api_response()){
|
||||
|
||||
json($collFieldsList)->send();
|
||||
if(!is_empty(g_sc('api_task_key_is_url'))){
|
||||
json($collFieldsList)->send();
|
||||
}else{
|
||||
json(array('code'=>1,'msg'=>'','data'=>$collFieldsList))->send();
|
||||
}
|
||||
}else{
|
||||
$html='<form id="win_form_preview" method="post" target="_blank" action="'.url('tool/preview_data').'">'.html_usertoken()
|
||||
.'<p>生成API返回的数据 <a href="javascript:;" onclick="document.getElementById(\'win_form_preview\').submit();">预览</a></p>'
|
||||
|
|
|
@ -14,6 +14,11 @@ use skycaiji\admin\model\CacheModel;
|
|||
class ReleaseBase extends CollectBase{
|
||||
/*已采集记录*/
|
||||
public function record_collected($url,$returnData,$release,$insertData=null,$echo=true){
|
||||
$returnData['id']=isset($returnData['id'])?$returnData['id']:0;
|
||||
$returnData['target']=isset($returnData['target'])?$returnData['target']:'';
|
||||
$returnData['desc']=isset($returnData['desc'])?$returnData['desc']:'';
|
||||
$returnData['error']=isset($returnData['error'])?$returnData['error']:'';
|
||||
|
||||
if($returnData['id']>0){
|
||||
|
||||
$title='';
|
||||
|
@ -241,6 +246,34 @@ class ReleaseBase extends CollectBase{
|
|||
}
|
||||
$key=md5($url);
|
||||
if(!isset($this->cache_img_list[$key])){
|
||||
|
||||
$headers=array();
|
||||
$useCookieImg=\util\Param::get_gsc_use_cookie('img',true);
|
||||
if(!is_empty(g_sc('task_img_headers'))){
|
||||
|
||||
$headers=g_sc('task_img_headers');
|
||||
if(!is_array($headers)){
|
||||
$headers=array();
|
||||
}
|
||||
}
|
||||
if(!empty($useCookieImg)){
|
||||
|
||||
unset($headers['cookie']);
|
||||
$headers['cookie']=$useCookieImg;
|
||||
}
|
||||
|
||||
|
||||
if(!is_empty(g_sc_c('download_img','img_timeout'))){
|
||||
|
||||
$options['timeout']=g_sc_c('download_img','img_timeout');
|
||||
}else{
|
||||
$options['timeout']=300;
|
||||
}
|
||||
if(!is_empty(g_sc_c('download_img','img_max'))){
|
||||
|
||||
$options['max_bytes']=intval(g_sc_c('download_img','img_max'))*1024*1024;
|
||||
}
|
||||
|
||||
|
||||
$prop='';
|
||||
$dataImageCode='';
|
||||
|
@ -254,6 +287,23 @@ class ReleaseBase extends CollectBase{
|
|||
}
|
||||
}else{
|
||||
|
||||
if(!is_empty(g_sc_c('download_img','url_real'))){
|
||||
|
||||
$realOptions=$options;
|
||||
$realOptions['return_head']=true;
|
||||
$realOptions['return_info']=true;
|
||||
$imgCodeInfo=get_html($url,$headers,$realOptions,'utf-8',null,true);
|
||||
if(!empty($imgCodeInfo['ok'])){
|
||||
unset($options['max_bytes']);
|
||||
if($imgCodeInfo['info']&&$imgCodeInfo['info']['url']){
|
||||
|
||||
|
||||
$url=$imgCodeInfo['info']['url'];
|
||||
}
|
||||
}else{
|
||||
return $this->_down_retry($proxyDbIp, $originalUrl, $retryCur, $retryMax, $imgCodeInfo, true);
|
||||
}
|
||||
}
|
||||
$prop=\util\Funcs::get_url_suffix($url);
|
||||
}
|
||||
if(!in_array($prop, $imgSuffixes)){
|
||||
|
@ -324,32 +374,6 @@ class ReleaseBase extends CollectBase{
|
|||
}else{
|
||||
|
||||
try {
|
||||
$headers=array();
|
||||
$useCookieImg=\util\Param::get_gsc_use_cookie('img',true);
|
||||
if(!is_empty(g_sc('task_img_headers'))){
|
||||
|
||||
$headers=g_sc('task_img_headers');
|
||||
if(!is_array($headers)){
|
||||
$headers=array();
|
||||
}
|
||||
}
|
||||
if(!empty($useCookieImg)){
|
||||
|
||||
unset($headers['cookie']);
|
||||
$headers['cookie']=$useCookieImg;
|
||||
}
|
||||
|
||||
if(!is_empty(g_sc_c('download_img','img_timeout'))){
|
||||
|
||||
$options['timeout']=g_sc_c('download_img','img_timeout');
|
||||
}else{
|
||||
$options['timeout']=300;
|
||||
}
|
||||
if(!is_empty(g_sc_c('download_img','img_max'))){
|
||||
|
||||
$options['max_bytes']=intval(g_sc_c('download_img','img_max'))*1024*1024;
|
||||
}
|
||||
|
||||
$imgCodeInfo=get_html($url,$headers,$options,'utf-8',null,true);
|
||||
if(!empty($imgCodeInfo['ok'])){
|
||||
|
||||
|
@ -573,18 +597,22 @@ class ReleaseBase extends CollectBase{
|
|||
|
||||
$options['max_bytes']=intval(g_sc_c('download_file','file_max'))*1024*1024;
|
||||
}
|
||||
$getRealUrl=g_sc_c('download_file','url_real');
|
||||
|
||||
$prop=\util\Funcs::get_url_suffix($url);
|
||||
|
||||
static $urlProps=array('htm','html','php','asp','jsp');
|
||||
if(in_array($prop, $urlProps)||empty($prop)){
|
||||
$getRealUrl=true;
|
||||
}
|
||||
if($getRealUrl){
|
||||
|
||||
$options['return_info']=true;
|
||||
$options['return_head']=true;
|
||||
$fileCodeInfo=get_html($url,$headers,$options,'utf-8',null,true);
|
||||
$realOptions=$options;
|
||||
$realOptions['return_head']=true;
|
||||
$realOptions['return_info']=true;
|
||||
$fileCodeInfo=get_html($url,$headers,$realOptions,'utf-8',null,true);
|
||||
if(!empty($fileCodeInfo['ok'])){
|
||||
unset($options['max_bytes']);
|
||||
if($fileCodeInfo['info']['url']){
|
||||
if($fileCodeInfo['info']&&$fileCodeInfo['info']['url']){
|
||||
|
||||
|
||||
$url=$fileCodeInfo['info']['url'];
|
||||
|
@ -640,7 +668,6 @@ class ReleaseBase extends CollectBase{
|
|||
if(!$isExists){
|
||||
|
||||
try {
|
||||
unset($options['return_head']);
|
||||
$options['return_info']=true;
|
||||
$fileCodeInfo=get_html($url,$headers,$options,'utf-8',null,true);
|
||||
if(!empty($fileCodeInfo['ok'])){
|
||||
|
|
|
@ -18,7 +18,8 @@ class Rfile extends Release {
|
|||
*/
|
||||
public function setConfig($config){
|
||||
$file=\util\UnmaxPost::val('file/a',array());
|
||||
$file['path']=trim($file['path'],'\/\\');
|
||||
$file['path']=trim($file['path'],'\/\\');
|
||||
$file['max_line']=intval($file['max_line']);
|
||||
$file['hide_fields']=is_array($file['hide_fields'])?$file['hide_fields']:array();
|
||||
if(empty($file['path'])){
|
||||
$this->error('请输入文件存放目录');
|
||||
|
@ -34,117 +35,237 @@ class Rfile extends Release {
|
|||
}
|
||||
/*导出数据*/
|
||||
public function export($collFieldsList,$options=null){
|
||||
if(!in_array($this->config['file']['type'],array('xlsx','xls','txt'))){
|
||||
return $this->echo_msg_return(array('不支持的文件格式:%s',$this->config['file']['type']));
|
||||
$filetype=$this->config['file']['type'];
|
||||
if(!in_array($filetype,array('xlsx','xls','txt'))){
|
||||
return $this->echo_msg_return(array('不支持的文件格式:%s',$filetype));
|
||||
}
|
||||
|
||||
$hideFields=$this->config['file']['hide_fields'];
|
||||
|
||||
$filepath=config('root_path').'/data/'.$this->config['file']['path'].'/'.$this->release['task_id'];
|
||||
$filename=date('Y-m-d',time()).'.'.$this->config['file']['type'];
|
||||
$filename=$filepath.'/'.$filename;
|
||||
$filename=date('Y-m-d',time());
|
||||
$fileno=0;
|
||||
$filefull='';
|
||||
|
||||
$maxLine=$this->config['file']['max_line'];
|
||||
$maxLine=intval($maxLine);
|
||||
if($maxLine>0){
|
||||
|
||||
if(is_dir($filepath)){
|
||||
$fileList=scandir($filepath);
|
||||
if(!empty($fileList)){
|
||||
foreach( $fileList as $file ){
|
||||
if('.' != $file && '..' != $file ){
|
||||
$file=explode('.', $file);
|
||||
if($file[1]==$filetype){
|
||||
|
||||
if($file[0]==$filename){
|
||||
$fileno=0;
|
||||
}elseif(strpos($file[0], $filename.'_')===0){
|
||||
$filenoCur=str_replace($filename.'_', '', $file[0]);
|
||||
$fileno=max($fileno,intval($filenoCur));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$addedNum=0;
|
||||
$lineNum=0;
|
||||
$curNum=0;
|
||||
|
||||
$excelType=array('xlsx'=>'Excel2007','xls'=>'Excel5');
|
||||
if(!empty($excelType[$this->config['file']['type']])){
|
||||
if(!empty($excelType[$filetype])){
|
||||
|
||||
$excelType=$excelType[$this->config['file']['type']];
|
||||
$excelType=$excelType[$filetype];
|
||||
if(empty($excelType)){
|
||||
return $this->echo_msg_return('错误的文件格式');
|
||||
}
|
||||
|
||||
if(!file_exists($filename)){
|
||||
$firstFields=reset($collFieldsList);
|
||||
$phpExcel=null;
|
||||
foreach ($collFieldsList as $collFieldsKey=>$collFields){
|
||||
if($curNum<=0){
|
||||
do{
|
||||
if($phpExcel){
|
||||
|
||||
$phpExcel->disconnectWorksheets();
|
||||
unset($phpExcel);
|
||||
}
|
||||
$isMaxLine=false;
|
||||
$filefull=$this->_file_fullname($filepath, $filename, $fileno, $filetype);
|
||||
if(!file_exists($filefull)){
|
||||
|
||||
$this->_create_excel($filefull,$excelType,$firstFields);
|
||||
}
|
||||
if(file_exists($filefull)){
|
||||
|
||||
$objReader = \PHPExcel_IOFactory::createReader($excelType);
|
||||
$phpExcel = $objReader->load($filefull);
|
||||
$phpExcel->setActiveSheetIndex(0);
|
||||
$lineNum=$phpExcel->getSheet(0)->getHighestRow();
|
||||
$lineNum=intval($lineNum);
|
||||
if($maxLine>0&&$lineNum>$maxLine){
|
||||
|
||||
$isMaxLine=true;
|
||||
}
|
||||
}else{
|
||||
$lineNum=0;
|
||||
}
|
||||
if($isMaxLine){
|
||||
$fileno++;
|
||||
}
|
||||
}while($isMaxLine);
|
||||
|
||||
$filefull=realpath($filefull);
|
||||
if(empty($filefull)){
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$addedNum++;
|
||||
$curNum++;
|
||||
$lineNum++;
|
||||
|
||||
write_dir_file( $filename, null);
|
||||
$newPhpExcel=new \PHPExcel();
|
||||
|
||||
$this->init_download_config($this->task,$collFields['fields']);
|
||||
$this->hide_coll_fields($hideFields, $collFields);
|
||||
|
||||
$sheet1 = new \PHPExcel_Worksheet($newPhpExcel, 'Sheet1');
|
||||
$newPhpExcel->addSheet($sheet1);
|
||||
$newPhpExcel->setActiveSheetIndex(0);
|
||||
|
||||
$firstFields=reset($collFieldsList);
|
||||
$this->hide_coll_fields($hideFields, $firstFields);
|
||||
$firstFields=array_keys($firstFields['fields']);
|
||||
foreach ($firstFields as $k=>$v){
|
||||
$newPhpExcel->getActiveSheet()->setCellValue(chr(65+$k).'1',$v);
|
||||
$collFields['fields']=is_array($collFields['fields'])?array_values($collFields['fields']):array();
|
||||
foreach ($collFields['fields'] as $k=>$v){
|
||||
$phpExcel->getActiveSheet()->setCellValue(chr(65+$k).$lineNum,$this->get_field_val($v));
|
||||
}
|
||||
$this->record_collected($collFields['url'], array('id'=>1,'target'=>$filefull,'desc'=>'行:'.$lineNum), $this->release,array('title'=>$collFields['title'],'content'=>$collFields['content']));
|
||||
|
||||
unset($collFieldsList[$collFieldsKey]['fields']);
|
||||
|
||||
|
||||
if($maxLine>0&&$lineNum>$maxLine){
|
||||
|
||||
$fileno++;
|
||||
$curNum=0;
|
||||
|
||||
$objWriter = \PHPExcel_IOFactory::createWriter($phpExcel,$excelType);
|
||||
$objWriter->save($filefull);
|
||||
|
||||
$phpExcel->disconnectWorksheets();
|
||||
unset($phpExcel);
|
||||
}
|
||||
$newWriter = \PHPExcel_IOFactory::createWriter($newPhpExcel,$excelType);
|
||||
$newWriter->save($filename);
|
||||
unset($newWriter);
|
||||
unset($newPhpExcel);
|
||||
}
|
||||
$filename=realpath($filename);
|
||||
if($filename){
|
||||
$objReader = \PHPExcel_IOFactory::createReader($excelType);
|
||||
$phpExcel = $objReader->load($filename);
|
||||
$phpExcel->setActiveSheetIndex(0);
|
||||
$rowNum=$phpExcel->getSheet(0)->getHighestRow();
|
||||
$rowNum=intval($rowNum);
|
||||
|
||||
foreach ($collFieldsList as $collFieldsKey=>$collFields){
|
||||
|
||||
$this->init_download_config($this->task,$collFields['fields']);
|
||||
$this->hide_coll_fields($hideFields, $collFields);
|
||||
$addedNum++;
|
||||
$curRow=$rowNum+$addedNum;
|
||||
$collFields['fields']=is_array($collFields['fields'])?array_values($collFields['fields']):array();
|
||||
foreach ($collFields['fields'] as $k=>$v){
|
||||
$phpExcel->getActiveSheet()->setCellValue(chr(65+$k).$curRow,$this->get_field_val($v));
|
||||
}
|
||||
$this->record_collected($collFields['url'], array('id'=>1,'target'=>$filename,'desc'=>'行:'.$curRow), $this->release,array('title'=>$collFields['title'],'content'=>$collFields['content']));
|
||||
|
||||
unset($collFieldsList[$collFieldsKey]['fields']);
|
||||
}
|
||||
$objWriter = \PHPExcel_IOFactory::createWriter($phpExcel,$excelType);
|
||||
$objWriter->save($filename);
|
||||
if($phpExcel){
|
||||
|
||||
$objWriter = \PHPExcel_IOFactory::createWriter($phpExcel,$excelType);
|
||||
$objWriter->save($filefull);
|
||||
}
|
||||
}elseif('txt'==$this->config['file']['type']){
|
||||
}elseif('txt'==$filetype){
|
||||
|
||||
$txtLine=0;
|
||||
if(file_exists($filename)){
|
||||
|
||||
$fpTxt=fopen($filename,'r');
|
||||
while(!feof($fpTxt)) {
|
||||
|
||||
if(($fpData=fread($fpTxt,1024*1024*2))!=false){
|
||||
foreach ($collFieldsList as $collFieldsKey=>$collFields){
|
||||
if($curNum<=0){
|
||||
do{
|
||||
$isMaxLine=false;
|
||||
$filefull=$this->_file_fullname($filepath, $filename, $fileno, $filetype);
|
||||
if(file_exists($filefull)){
|
||||
|
||||
$lineNum=$this->_txt_line($filefull);
|
||||
if($maxLine>0&&$lineNum>=$maxLine){
|
||||
|
||||
$isMaxLine=true;
|
||||
}
|
||||
}else{
|
||||
|
||||
write_dir_file( $filefull, '');
|
||||
$lineNum=0;
|
||||
}
|
||||
if($isMaxLine){
|
||||
$fileno++;
|
||||
}
|
||||
}while($isMaxLine);
|
||||
|
||||
$filefull=realpath($filefull);
|
||||
if(empty($filefull)){
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$addedNum++;
|
||||
$curNum++;
|
||||
|
||||
|
||||
$this->init_download_config($this->task,$collFields['fields']);
|
||||
$this->hide_coll_fields($hideFields, $collFields);
|
||||
|
||||
$fieldVals=array();
|
||||
foreach ($collFields['fields'] as $k=>$v){
|
||||
$fieldVal=str_replace(array("\r","\n"), array('\r','\n'), $this->get_field_val($v));
|
||||
if(empty($this->config['file']['txt_implode'])){
|
||||
|
||||
$txtLine+=substr_count($fpData,"\r\n");
|
||||
$fieldVal=str_replace("\t", ' ', $fieldVal);
|
||||
}
|
||||
$fieldVals[]=$fieldVal;
|
||||
}
|
||||
$fieldVals=implode($this->config['file']['txt_implode']?$this->config['file']['txt_implode']:"\t", $fieldVals);
|
||||
if(write_dir_file($filefull,$fieldVals."\r\n",FILE_APPEND)){
|
||||
|
||||
$lineNum++;
|
||||
$this->record_collected($collFields['url'], array('id'=>1,'target'=>$filefull,'desc'=>'行:'.$lineNum), $this->release,array('title'=>$collFields['title'],'content'=>$collFields['content']));
|
||||
}
|
||||
fclose($fpTxt);
|
||||
}else{
|
||||
|
||||
write_dir_file( $filename, '');
|
||||
}
|
||||
$filename=realpath($filename);
|
||||
if($filename){
|
||||
|
||||
foreach ($collFieldsList as $collFieldsKey=>$collFields){
|
||||
|
||||
$this->init_download_config($this->task,$collFields['fields']);
|
||||
$this->hide_coll_fields($hideFields, $collFields);
|
||||
$addedNum++;
|
||||
$fieldVals=array();
|
||||
foreach ($collFields['fields'] as $k=>$v){
|
||||
$fieldVal=str_replace(array("\r","\n"), array('\r','\n'), $this->get_field_val($v));
|
||||
if(empty($this->config['file']['txt_implode'])){
|
||||
|
||||
$fieldVal=str_replace("\t", ' ', $fieldVal);
|
||||
}
|
||||
$fieldVals[]=$fieldVal;
|
||||
}
|
||||
$fieldVals=implode($this->config['file']['txt_implode']?$this->config['file']['txt_implode']:"\t", $fieldVals);
|
||||
if(write_dir_file($filename,$fieldVals."\r\n",FILE_APPEND)){
|
||||
|
||||
$txtLine++;
|
||||
$this->record_collected($collFields['url'], array('id'=>1,'target'=>$filename,'desc'=>'行:'.$txtLine), $this->release,array('title'=>$collFields['title'],'content'=>$collFields['content']));
|
||||
}
|
||||
|
||||
unset($collFieldsList[$collFieldsKey]['fields']);
|
||||
}
|
||||
unset($collFieldsList[$collFieldsKey]['fields']);
|
||||
|
||||
|
||||
if($maxLine>0&&$lineNum>=$maxLine){
|
||||
|
||||
$fileno++;
|
||||
$curNum=0;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $addedNum;
|
||||
}
|
||||
|
||||
private function _file_fullname($filepath,$filename,$fileno,$filetype){
|
||||
$fileno=intval($fileno);
|
||||
$filefull=$filepath.'/'.$filename.($fileno>0?('_'.$fileno):'').'.'.$filetype;
|
||||
return $filefull;
|
||||
}
|
||||
|
||||
private function _create_excel($filefull,$excelType,$firstFields){
|
||||
if(!file_exists($filefull)){
|
||||
|
||||
write_dir_file( $filefull, null);
|
||||
$newPhpExcel=new \PHPExcel();
|
||||
|
||||
$sheet1 = new \PHPExcel_Worksheet($newPhpExcel, 'Sheet1');
|
||||
$newPhpExcel->addSheet($sheet1);
|
||||
$newPhpExcel->setActiveSheetIndex(0);
|
||||
|
||||
$this->hide_coll_fields($this->config['file']['hide_fields'], $firstFields);
|
||||
$firstFields=array_keys($firstFields['fields']);
|
||||
foreach ($firstFields as $k=>$v){
|
||||
$newPhpExcel->getActiveSheet()->setCellValue(chr(65+$k).'1',$v);
|
||||
}
|
||||
$newWriter = \PHPExcel_IOFactory::createWriter($newPhpExcel,$excelType);
|
||||
$newWriter->save($filefull);
|
||||
$newPhpExcel->disconnectWorksheets();
|
||||
unset($newPhpExcel);
|
||||
unset($newWriter);
|
||||
}
|
||||
}
|
||||
|
||||
private function _txt_line($filefull){
|
||||
|
||||
$txtLine=0;
|
||||
$fpTxt=fopen($filefull,'r');
|
||||
while(!feof($fpTxt)) {
|
||||
|
||||
if(($fpData=fread($fpTxt,1024*1024*2))!=false){
|
||||
|
||||
$txtLine+=substr_count($fpData,"\r\n");
|
||||
}
|
||||
}
|
||||
fclose($fpTxt);
|
||||
return $txtLine;
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -83,13 +83,47 @@ class Rtoapi extends Release{
|
|||
$apiConfig['charset']=$appApi['charset']?:'';
|
||||
$apiConfig['encode']=$appApi['encode']?:'';
|
||||
$apiConfig['response']=is_array($appApi['response'])?$appApi['response']:array();
|
||||
|
||||
$paramVals=$this->config['toapi']['app_params'];
|
||||
$headerVals=is_array($appApi['headers'])?$appApi['headers']:array();
|
||||
|
||||
if($appApi['content_type']){
|
||||
$headerVals['content-type']=$appApi['content_type'];
|
||||
}
|
||||
|
||||
$paramVals=$this->config['toapi']['app_params'];
|
||||
$appCustomParams=$this->config['toapi']['app_custom_params'];
|
||||
|
||||
if($appCustomParams&&is_array($appCustomParams)){
|
||||
|
||||
foreach($appCustomParams as $k=>$v){
|
||||
if($paramVals[$k]){
|
||||
|
||||
if(is_array($paramVals[$k])){
|
||||
|
||||
$paramCustomIndex=array_search('@skycaiji_custom',$paramVals[$k]);
|
||||
if(!is_empty($paramCustomIndex,true)){
|
||||
|
||||
unset($paramVals[$k][$paramCustomIndex]);
|
||||
$paramVals[$k]=array_values($paramVals[$k]);
|
||||
static $appCustomList=array();
|
||||
$vk=md5($v);
|
||||
if(!isset($appCustomList[$vk])){
|
||||
if(preg_match_all('/[^\r\n]+/',$v,$vm)){
|
||||
$appCustomList[$vk]=$vm[0];
|
||||
}else{
|
||||
$appCustomList[$vk]=array();
|
||||
}
|
||||
}
|
||||
$paramVals[$k]=array_merge($paramVals[$k],$appCustomList[$vk]);
|
||||
}
|
||||
}else{
|
||||
if($paramVals[$k]=='@skycaiji_custom'){
|
||||
|
||||
$paramVals[$k]=$v;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
|
||||
$apiUrl=$this->config['toapi']['url'];
|
||||
|
@ -210,7 +244,7 @@ class Rtoapi extends Release{
|
|||
$retryCur=0;
|
||||
do{
|
||||
$doWhile=false;
|
||||
$htmlInfo=get_html($url,$headerData,array('return_body'=>1,'curlopts'=>$curlopts),$apiCharset,$postData,true);
|
||||
$htmlInfo=get_html($url,$headerData,array('timeout'=>60,'return_body'=>1,'curlopts'=>$curlopts),$apiCharset,$postData,true);
|
||||
init_array($htmlInfo);
|
||||
$html=$htmlInfo['html']?:'';
|
||||
$this->collect_sleep($this->config['toapi']['interval'],true);
|
||||
|
@ -254,9 +288,9 @@ class Rtoapi extends Release{
|
|||
}
|
||||
}
|
||||
}
|
||||
if(!is_empty($apiResponse['id'],true)&&$html&&!is_empty($returnData['id'],true)){
|
||||
if(!is_empty($apiResponse['id'],true)&&$html&&isset($returnData['id'])){
|
||||
|
||||
if($returnData['id']>0){
|
||||
if($returnData['id']&&$returnData['id']>0){
|
||||
$addedNum++;
|
||||
if($returnData['id']>1&&empty($returnData['target'])){
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ return array(
|
|||
'tips_sign_group_global'=>'捕获组:(?<nr标识>[\s\S]*?),匹配正则并保存为[内容]标签以供全局调用',
|
||||
|
||||
'tips_regular'=>'可使用正则表达式',
|
||||
'tips_export_ipt_pwd'=>'加密文件并且导入时需要输入该密码(请牢记密码否则无法解密),默认无密码不加密',
|
||||
|
||||
'setting'=>'设置',
|
||||
'setting_site'=>'站点设置',
|
||||
|
@ -33,7 +34,7 @@ return array(
|
|||
'set_caiji_num'=>'最大采集数量',
|
||||
'set_caiji_timeout'=>'最大执行时间',
|
||||
|
||||
'setting_email'=>'邮件发送设置',
|
||||
'setting_email'=>'邮件设置',
|
||||
'set_email_sender'=>'发件人名称',
|
||||
'set_email_email'=>'发件人邮箱账号',
|
||||
'set_email_pwd'=>'发件人邮箱密码',
|
||||
|
@ -235,6 +236,9 @@ return array(
|
|||
'rele_module_toapi'=>'调用接口',
|
||||
'rele_module_file'=>'文件存储',
|
||||
'rele_module_diy'=>'自定义插件',
|
||||
'rele_m_name_cms'=>'CMS',
|
||||
'rele_m_name_diy'=>'自定义',
|
||||
|
||||
'rele_btn_detect'=>'开始检测',
|
||||
'rele_cms_path'=>'CMS路径',
|
||||
|
||||
|
|
|
@ -33,6 +33,11 @@ class Collector extends \skycaiji\common\model\BaseModel{
|
|||
$config=array();
|
||||
}
|
||||
|
||||
if(isset($config['url_reverse'])){
|
||||
|
||||
$config['url_order']=$config['url_reverse']?'reverse':'';
|
||||
}
|
||||
|
||||
if(!isset($config['area'])){
|
||||
|
||||
if(!empty($config['area_start'])||!empty($config['area_end'])) {
|
||||
|
|
|
@ -304,22 +304,26 @@ class Config extends \skycaiji\common\model\Config {
|
|||
}else{
|
||||
$info=\util\Tools::cli_command_exec('collect cli --url_params '.base64_encode(json_encode(array('op'=>'php'))),$phpFile,array('showInfo'=>'all','closeProc'=>true));
|
||||
init_array($info);
|
||||
$output=trim($info['output']);
|
||||
$info['error']=trim($info['error']);
|
||||
$info['output']=array();
|
||||
if($output&&preg_match('/\{[\s\S]+\}/i',$output,$mjson)){
|
||||
|
||||
$info['output']=json_decode($mjson[0],true);
|
||||
}
|
||||
init_array($info['output']);
|
||||
if(empty($info['output'])){
|
||||
|
||||
$result['msg']=$info['error']?$info['error']:($output?$output:'php无效');
|
||||
if(empty($info)){
|
||||
$result['msg']='执行失败,请检查web服务器是否拥有执行命令的权限';
|
||||
}else{
|
||||
$result['success']=true;
|
||||
$result['ver']=$info['output']['ver'];
|
||||
$result['swoole']=$info['output']['swoole'];
|
||||
$result['msg_ver']='php v'.$result['ver'];
|
||||
$output=trim($info['output']);
|
||||
$info['error']=trim($info['error']);
|
||||
$info['output']=array();
|
||||
if($output&&preg_match('/\{[\s\S]+\}/i',$output,$mjson)){
|
||||
|
||||
$info['output']=json_decode($mjson[0],true);
|
||||
}
|
||||
init_array($info['output']);
|
||||
if(empty($info['output'])){
|
||||
|
||||
$result['msg']=$info['error']?$info['error']:($output?$output:'php无效');
|
||||
}else{
|
||||
$result['success']=true;
|
||||
$result['ver']=$info['output']['ver'];
|
||||
$result['swoole']=$info['output']['swoole'];
|
||||
$result['msg_ver']='php v'.$result['ver'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,6 +36,8 @@ class FuncApp extends \skycaiji\common\model\BaseModel{
|
|||
'contentSign'=>array(
|
||||
'name'=>'内容标签',
|
||||
'loc'=>'任务»采集器设置»页面配置»提取内容标签»使用函数',
|
||||
'config'=>'allow_process_func',
|
||||
'extend'=>'EXTEND_PROCESS_FUNC',
|
||||
)
|
||||
);
|
||||
public function __construct($data = []){
|
||||
|
|
|
@ -103,6 +103,13 @@ class Release extends \skycaiji\common\model\BaseModel{
|
|||
}
|
||||
}
|
||||
}
|
||||
if(is_array($config['api'])){
|
||||
|
||||
if(isset($config['api']['url'])){
|
||||
$config['api']['key']=$config['api']['url'];
|
||||
}
|
||||
}
|
||||
|
||||
return $config;
|
||||
}
|
||||
|
||||
|
|
|
@ -227,7 +227,113 @@ class Task extends \skycaiji\common\model\BaseModel{
|
|||
}
|
||||
|
||||
public function set_backstage_end($taskId){
|
||||
\skycaiji\admin\model\CacheModel::getInstance('backstage_task')->db()->strict(false)->where('cname',$taskId)->update(array('ctype'=>1,'data'=>time()));
|
||||
\skycaiji\admin\model\CacheModel::getInstance('backstage_task')->db()->strict(false)->where('cname',$taskId)->update(array('ctype'=>1,'data'=>time()));
|
||||
|
||||
$mconfig=model('Config');
|
||||
$emailConfig=$mconfig->getConfig('email','data');
|
||||
if(!empty($emailConfig)){
|
||||
init_array($emailConfig);
|
||||
$caijiConfig=$emailConfig['caiji'];
|
||||
init_array($caijiConfig);
|
||||
if(!empty($caijiConfig)&&$caijiConfig['open']){
|
||||
|
||||
$toEmail=$caijiConfig['email']?:$emailConfig['email'];
|
||||
if(empty($caijiConfig['is_auto'])||!is_empty(input('collect_auto'))){
|
||||
|
||||
$mcacheEmail=\skycaiji\admin\model\CacheModel::getInstance('email');
|
||||
$mcollected=model('Collected');
|
||||
$mtask=model('Task');
|
||||
$timeNow=time();
|
||||
$todayTime=strtotime(date('Y-m-d',$timeNow));
|
||||
if($taskId>0&&!empty($caijiConfig['failed_num'])&&$caijiConfig['failed_num']>0){
|
||||
|
||||
$failedInterval=intval($caijiConfig['failed_interval'])*60;
|
||||
$taskKey='failed_task_'.$taskId;
|
||||
$taskLastTime=$mcacheEmail->getCache($taskKey,'data');
|
||||
$taskLastTime=intval($taskLastTime);
|
||||
if($taskLastTime<=0){
|
||||
|
||||
$taskLastTime=$todayTime;
|
||||
}
|
||||
if($taskLastTime>0&&(abs($timeNow-$taskLastTime)>$failedInterval)){
|
||||
|
||||
|
||||
$taskFailedNum=$mcollected->where(array('task_id'=>$taskId,'addtime'=>array('GT',$taskLastTime),'error'=>array('<>','')))->count();
|
||||
if($taskFailedNum>0&&$taskFailedNum>$caijiConfig['failed_num']){
|
||||
|
||||
$mcacheEmail->setCache($taskKey,$timeNow);
|
||||
$taskName=$mtask->where('id',$taskId)->value('name');
|
||||
\util\Tools::send_mail(
|
||||
$emailConfig, $toEmail, $emailConfig['sender'],
|
||||
sprintf('任务%d在 %s 至 %s 失败了%d次',$taskId,date('m-d H:i:s',$taskLastTime),date('m-d H:i:s',$timeNow),$taskFailedNum),
|
||||
sprintf('<a href="%s" target="_blank">查看任务"%s"失败详细</a>',url('admin/collected/list?status=2&task_id='.$taskId,'',false,true),$taskName)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$reportInterval=intval($caijiConfig['report_interval'])*60;
|
||||
if($reportInterval>0){
|
||||
|
||||
$reportKey='caiji_report_time';
|
||||
$reportLastTime=$mcacheEmail->getCache($reportKey,'data');
|
||||
$reportLastTime=intval($reportLastTime);
|
||||
if($reportLastTime<=0){
|
||||
|
||||
$reportLastTime=$todayTime;
|
||||
}
|
||||
if($reportLastTime>0&&(abs($timeNow-$reportLastTime)>$reportInterval)){
|
||||
|
||||
$mcacheEmail->setCache($reportKey,$timeNow);
|
||||
$report=array(
|
||||
'today_success'=>0,'today_error'=>0,'today_tasks'=>array(),
|
||||
'total_success'=>$mcollected->where("`target` <> ''")->count(),
|
||||
'total_error'=>$mcollected->where("`error` <> ''")->count(),
|
||||
'task_auto'=>$mtask->where('`auto`>0')->count(),
|
||||
'task_other'=>$mtask->where('`auto`=0')->count(),
|
||||
'caijitime'=>$mtask->where('`auto`>0')->max('caijitime'),
|
||||
'autotime'=>CacheModel::getInstance()->getCache('collect_backstage_time','data'),
|
||||
);
|
||||
$todaySuccess=$mcollected->field('task_id,count(task_id)')->where(array('addtime'=>array('GT',$todayTime),'target'=>array('<>','')))->group('task_id')->column('count(task_id)','task_id');
|
||||
$todayError=$mcollected->field('task_id,count(task_id)')->where(array('addtime'=>array('GT',$todayTime),'error'=>array('<>','')))->group('task_id')->column('count(task_id)','task_id');
|
||||
|
||||
if($todaySuccess){
|
||||
$report['today_success']=array_sum($todaySuccess);
|
||||
foreach ($todaySuccess as $k=>$v){
|
||||
init_array($report['today_tasks'][$k]);
|
||||
$report['today_tasks'][$k]['success']=$v;
|
||||
}
|
||||
}
|
||||
if($todayError){
|
||||
$report['today_error']=array_sum($todayError);
|
||||
foreach ($todayError as $k=>$v){
|
||||
init_array($report['today_tasks'][$k]);
|
||||
$report['today_tasks'][$k]['error']=$v;
|
||||
}
|
||||
}
|
||||
if($report['today_tasks']){
|
||||
|
||||
$taskNames=$mtask->where('id','in',array_keys($report['today_tasks']))->column('name','id');
|
||||
if($taskNames){
|
||||
|
||||
foreach ($taskNames as $k=>$v){
|
||||
$report['today_tasks'][$k]['name']=$v;
|
||||
}
|
||||
}
|
||||
unset($taskNames);
|
||||
}
|
||||
$report=view('task/caiji_report_email',array('report'=>$report))->getContent();
|
||||
\util\Tools::send_mail(
|
||||
$emailConfig, $toEmail, $emailConfig['sender'],
|
||||
date('Y-m-d H:i:s',$timeNow).' 采集报表',
|
||||
$report
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function auto_is_timer($auto){
|
||||
|
|
|
@ -30,18 +30,48 @@ class TaskTimer extends \skycaiji\common\model\BaseModel{
|
|||
}
|
||||
}
|
||||
}
|
||||
$this->where('task_id',$taskId)->delete();
|
||||
$this->where('task_id',$taskId)->delete();
|
||||
$this->setCache($taskId, null);
|
||||
if($list){
|
||||
$this->saveAll($list);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function getTimer($taskId){
|
||||
$timers=$this->where('task_id',$taskId)->select();
|
||||
$data=$this->_convert_timer($timers);
|
||||
public function getTimer($taskId,$toInt=false){
|
||||
$timers=$this->getCache($taskId);
|
||||
if(!is_array($timers)){
|
||||
|
||||
$timers=$this->db()->where('task_id',$taskId)->select();
|
||||
$timers=$timers?collection($timers)->toArray():array();
|
||||
$this->setCache($taskId,$timers);
|
||||
}
|
||||
$data=$this->_convert_timer($timers,$toInt);
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function setCache($taskId,$data){
|
||||
$key='tasktimer_'.$taskId;
|
||||
$mcache=CacheModel::getInstance('');
|
||||
if(!isset($data)||$data===null){
|
||||
|
||||
$mcache->deleteCache($key);
|
||||
}else{
|
||||
$mcache->setCache($key,$data);
|
||||
}
|
||||
}
|
||||
public function getCache($taskId){
|
||||
$key='tasktimer_'.$taskId;
|
||||
$cache=CacheModel::getInstance('')->getCache($key);
|
||||
if($cache&&abs(time()-$cache['dateline'])<3600*24){
|
||||
|
||||
$cache=$cache['data'];
|
||||
}else{
|
||||
$cache=null;
|
||||
}
|
||||
return $cache;
|
||||
}
|
||||
|
||||
public function getTimers($taskIds){
|
||||
$timers=$this->where(array('task_id'=>array('in',$taskIds)))->select();
|
||||
$list=array();
|
||||
|
@ -57,7 +87,7 @@ class TaskTimer extends \skycaiji\common\model\BaseModel{
|
|||
}
|
||||
return $list;
|
||||
}
|
||||
private function _convert_timer($timers){
|
||||
private function _convert_timer($timers,$toInt=false){
|
||||
$timer=array();
|
||||
foreach ($timers as $v){
|
||||
$name=$v['name'];
|
||||
|
@ -77,6 +107,20 @@ class TaskTimer extends \skycaiji\common\model\BaseModel{
|
|||
if(!empty($v)){
|
||||
$isAll=false;
|
||||
}
|
||||
if($toInt){
|
||||
|
||||
if($k=='day'){
|
||||
foreach ($v as $vk=>$vv){
|
||||
if(strpos($vv, 'w')!==0){
|
||||
|
||||
$vv=intval($vv);
|
||||
}
|
||||
$v[$vk]=$vv;
|
||||
}
|
||||
}else{
|
||||
$v=array_map('intval', $v);
|
||||
}
|
||||
}
|
||||
$timer[$k]=$v;
|
||||
}
|
||||
if($isAll){
|
||||
|
@ -127,7 +171,7 @@ class TaskTimer extends \skycaiji\common\model\BaseModel{
|
|||
$data=array('is_timer'=>false,'is_trigger'=>false);
|
||||
if($taskData&&model('Task')->auto_is_timer($taskData['auto'])){
|
||||
|
||||
$timer=$this->getTimer($taskData['id']);
|
||||
$timer=$this->getTimer($taskData['id'],true);
|
||||
if(empty($timer)){
|
||||
|
||||
$data['is_timer']=false;
|
||||
|
@ -136,22 +180,25 @@ class TaskTimer extends \skycaiji\common\model\BaseModel{
|
|||
$trigger=true;
|
||||
$data['is_timer']=true;
|
||||
$rangMinute=1;
|
||||
$endTime=$timeNow?$timeNow:time();
|
||||
$timeNow=$timeNow?$timeNow:time();
|
||||
$endTime=$timeNow;
|
||||
$startTime=$endTime-60*$rangMinute;
|
||||
$startDate=array(
|
||||
'month'=>date('m',$startTime),
|
||||
'day'=>date('d',$startTime),
|
||||
'hour'=>date('H',$startTime),
|
||||
'week'=>'w'.date('N',$startTime),
|
||||
'minute'=>date('i',$startTime),
|
||||
);
|
||||
$startDate=array_map('intval', $startDate);
|
||||
$startDate['week']='w'.date('N',$startTime);
|
||||
$endDate=array(
|
||||
'month'=>date('m',$endTime),
|
||||
'day'=>date('d',$endTime),
|
||||
'hour'=>date('H',$endTime),
|
||||
'week'=>'w'.date('N',$endTime),
|
||||
'minute'=>date('i',$endTime),
|
||||
);
|
||||
$endDate=array_map('intval', $endDate);
|
||||
$endDate['week']='w'.date('N',$endTime);
|
||||
if($startDate['month']!=$endDate['month']||$startDate['day']!=$endDate['day']||$startDate['hour']!=$endDate['hour']){
|
||||
|
||||
$startDate['minute_range']=array($startDate['minute'],60);
|
||||
|
@ -191,6 +238,91 @@ class TaskTimer extends \skycaiji\common\model\BaseModel{
|
|||
break;
|
||||
}
|
||||
}
|
||||
if(!$trigger&&$taskData['caijitime']>0&&$taskData['config']&&$taskData['config']['other']&&$taskData['config']['other']['timer_again']){
|
||||
|
||||
$timerWeeks=array();
|
||||
if($timer['day']){
|
||||
foreach($timer['day'] as $k=>$v){
|
||||
if(strpos($v,'w')===0){
|
||||
|
||||
$timerWeeks[]=$v;
|
||||
unset($timer['day'][$k]);
|
||||
}
|
||||
}
|
||||
}
|
||||
$timerWeeks=array_values($timerWeeks);
|
||||
$timer['day']=array_values($timer['day']);
|
||||
|
||||
$nowDate=array(
|
||||
'year'=>date('Y',$timeNow),
|
||||
'month'=>date('m',$timeNow),
|
||||
'day'=>date('d',$timeNow),
|
||||
'hour'=>date('H',$timeNow),
|
||||
'minute'=>date('i',$timeNow),
|
||||
);
|
||||
$nowDate=array_map('intval', $nowDate);
|
||||
$lastDate=array();
|
||||
$lastDateKeys=array('month','day','hour','minute');
|
||||
for($i=0;$i<count($lastDateKeys);$i++){
|
||||
$ldKey=$lastDateKeys[$i];
|
||||
$isLtNow=false;
|
||||
|
||||
if($timer[$ldKey]){
|
||||
foreach($timer[$ldKey] as $tmv){
|
||||
$isLtNow=$tmv;
|
||||
if($tmv>=$nowDate[$ldKey]){
|
||||
|
||||
$isLtNow=false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
$lastDate[$ldKey]=$isLtNow?$isLtNow:$nowDate[$ldKey];
|
||||
if($ldKey=='month'&&!empty($timerWeeks)){
|
||||
|
||||
$timerDays=date('t',strtotime($nowDate['year'].'-'.$lastDate['month']));
|
||||
$timerDays=intval($timerDays);
|
||||
for($tdi=1;$tdi<=$timerDays;$tdi++){
|
||||
if(!in_array($tdi,$timer['day'])&&in_array('w'.date('N',strtotime($nowDate['year'].'-'.$nowDate['month'].'-'.$tdi)),$timerWeeks)){
|
||||
|
||||
$timer['day'][]=$tdi;
|
||||
}
|
||||
}
|
||||
sort($timer['day']);
|
||||
}
|
||||
$ldKeys=array_slice($lastDateKeys,$i+1);
|
||||
if($isLtNow){
|
||||
if($ldKeys){
|
||||
$maxDef=array('month'=>12,'day'=>31,'hour'=>23,'minute'=>59);
|
||||
foreach ($ldKeys as $ldk){
|
||||
|
||||
$lastDate[$ldk]=$timer[$ldk]?max($timer[$ldk]):$maxDef[$ldk];
|
||||
}
|
||||
}
|
||||
break;
|
||||
}else{
|
||||
if($ldKeys){
|
||||
foreach ($ldKeys as $ldk){
|
||||
|
||||
$lastDate[$ldk]=$nowDate[$ldk];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$maxDay=date('t',strtotime($nowDate['year'].'-'.$lastDate['month']));
|
||||
if($lastDate['day']>$maxDay){
|
||||
$lastDate['day']=$maxDay;
|
||||
}
|
||||
|
||||
$lastDate=sprintf('%d-%d-%d %d:%d',$nowDate['year'],$lastDate['month'],$lastDate['day'],$lastDate['hour'],$lastDate['minute']);
|
||||
|
||||
if($taskData['caijitime']<strtotime($lastDate)){
|
||||
|
||||
$trigger=true;
|
||||
}
|
||||
}
|
||||
$data['is_trigger']=$trigger;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,11 +2,26 @@
|
|||
{block name="cssjs"}
|
||||
{/block}
|
||||
{block name="content"}
|
||||
<script type="text/javascript">
|
||||
confirmRight('规则中包含插件,是否一同导出?',function(){
|
||||
window.location.href=ulink('collector/export?coll_id=_cid_&export_func=1',{'_cid_':'{$coll_id}'});
|
||||
},function(){
|
||||
window.location.href=ulink('collector/export?coll_id=_cid_&export_func=0',{'_cid_':'{$coll_id}'});
|
||||
});
|
||||
</script>
|
||||
<form method="post" role="form" action="{:url('collector/export')}">
|
||||
<div class="box box-default">
|
||||
<div class="box-body" style="padding-bottom:0;">
|
||||
{:html_usertoken()}
|
||||
<input type="hidden" name="task_id" value="{$task_id}" />
|
||||
<div class="form-group">
|
||||
<label>设置密码</label>
|
||||
<input type="text" class="form-control" name="pwd" placeholder="选填" autocomplete="off" />
|
||||
<p class="help-block">{$Think.lang.tips_export_ipt_pwd}</p>
|
||||
</div>
|
||||
{if !empty($hasPlugin)}
|
||||
<div class="form-group">
|
||||
<label>导出插件</label>
|
||||
<div class="input-group">
|
||||
<label class="checkbox-inline"><input type="checkbox" name="export_plugin" value="1" /> 规则中包含插件,是否一同导出?</label>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary btn-block">确定导出</button>
|
||||
</form>
|
||||
{/block}
|
|
@ -4,7 +4,7 @@
|
|||
{foreach name="collList" item="coll"}
|
||||
{php}
|
||||
if(!empty($taskNames[$coll['task_id']])){
|
||||
$collTitle='任务规则:'.$taskNames[$coll['task_id']];
|
||||
$collTitle=$taskNames[$coll['task_id']];
|
||||
}else{
|
||||
$collTitle='采集器:'.$coll['name'];
|
||||
}
|
||||
|
@ -17,10 +17,13 @@
|
|||
{/foreach}
|
||||
</ul>
|
||||
{$pagenav}
|
||||
<script type="text/javascript">
|
||||
|
||||
<script type="text/javascript">
|
||||
'use strict';
|
||||
(function(){
|
||||
$('#window_colls #coll_list li a').bind('click',function(){
|
||||
var id=$(this).attr('data-id');
|
||||
var name=$(this).attr('data-title');
|
||||
var name='任务 » '+$(this).attr('data-title');
|
||||
taskOpClass.import_rule('collector:'+id,name);
|
||||
});
|
||||
$('#window_colls .pagination').addClass('pagination-sm');
|
||||
|
@ -28,7 +31,9 @@
|
|||
windowModal('导入规则',$(this).attr('href'));
|
||||
return false;
|
||||
});
|
||||
</script>
|
||||
})();
|
||||
</script>
|
||||
|
||||
</div>
|
||||
{else /}
|
||||
没有规则,请进入<a href="{:url('mystore/store')}">云平台</a>下载
|
||||
|
|
|
@ -64,7 +64,7 @@
|
|||
</a>
|
||||
<ul class="treeview-menu">
|
||||
<li><a href="{:url('admin/task/list')}"><i class="fa fa-circle-o"></i> {$Think.lang.task_list}</a></li>
|
||||
<li><a href="{:url('admin/task/save')}"><i class="fa fa-circle-o"></i> {$Think.lang.task_add}</a></li>
|
||||
<li><a href="{:url('admin/task/set')}"><i class="fa fa-circle-o"></i> {$Think.lang.task_add}</a></li>
|
||||
<li class="treeview{$curMenu['taskgroup']}">
|
||||
<a href="#"><i class="fa fa-circle-o"></i> {$Think.lang.taskgroup}
|
||||
<span class="pull-right-container">
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
{$html}
|
||||
<textarea id="skycaiji_browser_html" style="display:none;">{$htmlTxt}</textarea>
|
||||
<!-- 以下为蓝天采集器代码 -->
|
||||
<link rel="stylesheet" href="{:config('root_website')}/public/static/css/cpattern_browser.css?{$Think.config.html_v}">
|
||||
<script type="text/javascript" src="{:config('root_website')}/public/jquery/jquery.min.js?{$Think.config.html_v}"></script>
|
||||
|
@ -14,11 +15,16 @@
|
|||
<em class="skycaiji-close" title="关闭">×</em>
|
||||
<div class="skycaiji-block">
|
||||
<span class="skycaiji-b-l">当前元素的xpath:</span>
|
||||
<div class="skycaiji-b-c"><input skycaiji-id="xpath" /></div>
|
||||
<div class="skycaiji-b-c">
|
||||
<div skycaiji-id="box-xpath"><input skycaiji-id="xpath" /></div>
|
||||
<select skycaiji-id="xpaths" style="display:none;">
|
||||
<option value="">请选择</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="skycaiji-b-r">
|
||||
<div style="display:inline;"><a href="javascript:;" skycaiji-id="show-xpath" data-val="1">显示</a> /</div>
|
||||
<div style="display:inline;"><a href="javascript:;" title="当前元素的所有属性" skycaiji-id="obj-prop">属性</a> /</div>
|
||||
<div style="display:inline;"><a href="javascript:;" title="清理界面" skycaiji-id="obj-clear">清理</a> /</div>
|
||||
<div style="display:inline;"><a href="javascript:;" title="当前元素的所有属性" skycaiji-id="obj-prop">属性</a> /</div>
|
||||
<div style="display:inline;"><a href="javascript:;" title="当前元素的父元素" skycaiji-id="obj-parent">父元素</a> /</div>
|
||||
<div style="display:inline;"><a href="javascript:;" title="当前元素的子元素" skycaiji-id="obj-child">子元素</a></div>
|
||||
</div>
|
||||
|
|
|
@ -52,8 +52,19 @@
|
|||
<div class="panel-body">
|
||||
<div class="form-group">
|
||||
<label>函数名</label>
|
||||
<a href="javascript:;" class="fa fa-refresh plugin-func-refresh" title="刷新"></a>
|
||||
<select class="form-control" data-func-func="1">
|
||||
<option value="">不使用</option>
|
||||
<optgroup label="系统函数">
|
||||
{foreach $Think.config.allow_process_func as $k=>$v}
|
||||
<option value="{$k}">{$k}:{$v}</option>
|
||||
{/foreach}
|
||||
{if is_array($Think.config.EXTEND_PROCESS_FUNC)}
|
||||
{foreach $Think.config.EXTEND_PROCESS_FUNC as $k=>$v}
|
||||
<option value="{$k}">{$k}:{$v}</option>
|
||||
{/foreach}
|
||||
{/if}
|
||||
</optgroup>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
|
|
|
@ -45,26 +45,29 @@
|
|||
<div class="c-p-field-module" module="auto" style="display:none;">
|
||||
<div class="form-group" style="text-align:center;">
|
||||
<p>自动提取页面中的内容:</p>
|
||||
<label class="radio-inline">
|
||||
<label class="radio-inline" style="margin-left:0px;">
|
||||
<input type="radio" name="field[auto]" value="title">标题
|
||||
</label>
|
||||
<label class="radio-inline">
|
||||
<label class="radio-inline" style="margin-left:5px;">
|
||||
<input type="radio" name="field[auto]" value="content">正文
|
||||
</label>
|
||||
<label class="radio-inline">
|
||||
<label class="radio-inline" style="margin-left:5px;">
|
||||
<input type="radio" name="field[auto]" value="keywords">keywords
|
||||
</label>
|
||||
<label class="radio-inline">
|
||||
<label class="radio-inline" style="margin-left:5px;">
|
||||
<input type="radio" name="field[auto]" value="description">description
|
||||
</label>
|
||||
<label class="radio-inline">
|
||||
<input type="radio" name="field[auto]" value="url">页面网址
|
||||
<label class="radio-inline" style="margin-left:5px;">
|
||||
<input type="radio" name="field[auto]" value="url">网址
|
||||
</label>
|
||||
<label class="radio-inline">
|
||||
<label class="radio-inline" style="margin-left:5px;">
|
||||
<input type="radio" name="field[auto]" value="html">源码
|
||||
</label>
|
||||
<label class="radio-inline" style="margin-left:5px;">
|
||||
<input type="radio" name="field[auto]" value="header">头信息
|
||||
</label>
|
||||
<label class="radio-inline">
|
||||
<input type="radio" name="field[auto]" value="html">源码
|
||||
<label class="radio-inline" style="margin-left:5px;">
|
||||
<input type="radio" name="field[auto]" value="cookie">cookie
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -62,6 +62,7 @@
|
|||
<div class="input-group-addon iga-rt">
|
||||
<a href="javascript:;" title="{$Think.lang.tips_sign_wildcard}" class="blk c-p-process-sign-wildcard">{$Think.lang.sign_wildcard}</a>
|
||||
<span title="{$Think.lang.tips_regular}" class="blk">正则</span>
|
||||
<a href="javascript:;" title="提示信息" class="glyphicon glyphicon-info-sign icon-info-tips" onclick="ruleInsertSign.tool_tips()"></a>
|
||||
</div>
|
||||
</div>
|
||||
<p style="margin:5px 0;">替换成</p>
|
||||
|
@ -187,6 +188,9 @@
|
|||
<option value="1">取反</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="input-group-addon" style="padding:0;min-width:31px;width:31px;border-left:0;">
|
||||
<a href="javascript:;" class="fa fa-refresh icon-info-tips plugin-func-refresh" title="刷新"></a>
|
||||
</div>
|
||||
<div class="input-group-addon" style="padding:0;min-width:31px;width:31px;">
|
||||
<a href="javascript:;" class="glyphicon glyphicon-info-sign icon-info-tips p-m-if-val-func-info"></a>
|
||||
</div>
|
||||
|
@ -257,7 +261,7 @@
|
|||
<label><input type="checkbox" data-process="tool:tool_list" value="format" />清除文本格式(去除html元素所有样式,如:id、class、style等)</label>
|
||||
<label><input type="checkbox" data-process="tool:tool_list" value="url_not_complete" />禁止补全网址</label>
|
||||
<label title="将网址替换成重定向后的真实地址"><input type="checkbox" data-process="tool:tool_list" value="url_real" />网址真实地址</label>
|
||||
<label title="从播放器中提取出音视频网址,如提取不到可开启“页面渲染”功能再尝试"><input type="checkbox" data-process="tool:tool_list" value="vedio_url" />提取音视频网址</label>
|
||||
<label title="从html中提取出音视频网址,建议字段的值是渲染后的html"><input type="checkbox" data-process="tool:tool_list" value="vedio_url" />提取音视频网址</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="c-p-process-module" module="download">
|
||||
|
@ -362,6 +366,7 @@
|
|||
<section>
|
||||
<div class="form-group">
|
||||
<label>PHP函数名</label>
|
||||
<a href="javascript:;" class="fa fa-refresh plugin-func-refresh" title="刷新"></a>
|
||||
<select data-process="func:func_name" class="form-control">
|
||||
<option value="">--请选择--</option>
|
||||
<optgroup label="系统函数">
|
||||
|
|
|
@ -5,10 +5,7 @@
|
|||
<li{$curTab['coll_pattern_field']}><a href="#coll_pattern_field" data-toggle="tab" aria-expanded="{$curTab['coll_pattern_field']?'true':'false'}">获取内容</a></li>
|
||||
{if condition="!empty($collData)"}
|
||||
<li class="dropdown nav-save-rule">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">另存为 <span class="caret"></span></a>
|
||||
<ul class="dropdown-menu dropdown-menu-right">
|
||||
<li><a href="{:url('collector/export?coll_id='.$collData['id'])}" target="_blank">导出至本地</a></li>
|
||||
</ul>
|
||||
<a href="{:url('collector/export?task_id='.$collData['task_id'])}" target="_blank">另存为</a>
|
||||
</li>
|
||||
{/if}
|
||||
</ul>
|
||||
|
@ -85,12 +82,13 @@
|
|||
<p class="help-block">通常情况下网址中有锚点(#)和无锚点解析出的内容是相同的,为避免采集到重复内容可去除网址锚点</p>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label">倒序采集</label>
|
||||
<label class="control-label">网址采集顺序</label>
|
||||
<div class="input-group">
|
||||
<label class="radio-inline"><input type="radio" name="config[url_reverse]" value="1"> 是</label>
|
||||
<label class="radio-inline"><input type="radio" name="config[url_reverse]" value="0" checked="checked"> 否</label>
|
||||
<label class="radio-inline"><input type="radio" name="config[url_order]" value="shuffle"> 乱序</label>
|
||||
<label class="radio-inline"><input type="radio" name="config[url_order]" value="reverse"> 倒序</label>
|
||||
<label class="radio-inline"><input type="radio" name="config[url_order]" value="" checked="checked"> 正常</label>
|
||||
</div>
|
||||
<p class="help-block">以相反的顺序采集内容页网址</p>
|
||||
<p class="help-block">以哪种顺序采集内容页网址,默认按正常顺序采集</p>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label">页面渲染</label>
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
<div style="display:inline;"><a href="javascript:;" title="{$Think.lang.tips_sign_match_global}" onclick="ruleInsertSign.match('[name=\'{$_tpl_name}[area]\']',{zimu:{$_tpl_match_global?1:0}})">{:cp_sign('match')}</a></div>
|
||||
<div>
|
||||
<div style="display:inline;"><a href="javascript:;" title="{$Think.lang.tips_sign_group_global}" onclick="ruleInsertSign.match('[name=\'{$_tpl_name}[area]\']',{group:1,zimu:{$_tpl_match_global?1:0}})">捕获组</a></div>
|
||||
<div style="display:inline;"><a href="javascript:;" title="提示信息" class="glyphicon glyphicon-info-sign icon-info-tips" onclick="ruleInsertSign.tips({$_tpl_match_global?1:''},{$_tpl_is_pagination?1:''})"></a></div>
|
||||
<div style="display:inline;"><a href="javascript:;" title="提示信息" class="glyphicon glyphicon-info-sign icon-info-tips" onclick="ruleInsertSign.tips({$_tpl_match_global?1:0},{$_tpl_is_pagination?1:0})"></a></div>
|
||||
</div>
|
||||
</li>
|
||||
<li data-module="xpath">xpath语法</li>
|
||||
|
@ -101,7 +101,7 @@
|
|||
<div style="display:inline;"><a href="javascript:;" title="{$Think.lang.tips_sign_match_global}" onclick="ruleInsertSign.match('[name=\'{$_tpl_name}[url_rule]\']',{zimu:{$_tpl_match_global?1:0}})">{:cp_sign('match')}</a></div>
|
||||
<div>
|
||||
<div style="display:inline;"><a href="javascript:;" title="{$Think.lang.tips_sign_group_global}" onclick="ruleInsertSign.match('[name=\'{$_tpl_name}[url_rule]\']',{group:1,zimu:{$_tpl_match_global?1:0}})">捕获组</a></div>
|
||||
<div style="display:inline;"><a href="javascript:;" title="提示信息" class="glyphicon glyphicon-info-sign icon-info-tips" onclick="ruleInsertSign.tips({$_tpl_match_global?1:''},{$_tpl_is_pagination?1:''})"></a></div>
|
||||
<div style="display:inline;"><a href="javascript:;" title="提示信息" class="glyphicon glyphicon-info-sign icon-info-tips" onclick="ruleInsertSign.tips({$_tpl_match_global?1:0},{$_tpl_is_pagination?1:0})"></a></div>
|
||||
</div>
|
||||
</li>
|
||||
<li data-module="xpath">xpath语法</li>
|
||||
|
|
|
@ -91,9 +91,9 @@
|
|||
<td class="sign"><input type="text" class="form-control signs" readonly="true" /></td>
|
||||
<td>
|
||||
<input type="hidden" data-name="config[front_urls][]" />
|
||||
<a href="javascript:;" class="glyphicon icon-drag-move" title="移动" style="font-size:12px;"></a>
|
||||
<a href="javascript:;" class="glyphicon glyphicon-copy clone" title="复制" style="font-size:12px;top:0.5px;"></a>
|
||||
<a href="javascript:;" class="glyphicon glyphicon-remove delete" title="删除" style="font-size:12px;"></a>
|
||||
<a href="javascript:;" class="glyphicon icon-drag-move" title="移动"></a>
|
||||
<a href="javascript:;" class="glyphicon glyphicon-copy clone" title="复制"></a>
|
||||
<a href="javascript:;" class="glyphicon glyphicon-remove delete" title="删除"></a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="coll_tpl_level_url">
|
||||
|
@ -102,9 +102,9 @@
|
|||
<td class="sign"><input type="text" class="form-control signs" readonly="true" /></td>
|
||||
<td>
|
||||
<input type="hidden" data-name="config[level_urls][]" />
|
||||
<a href="javascript:;" class="glyphicon icon-drag-move" title="移动" style="font-size:12px;"></a>
|
||||
<a href="javascript:;" class="glyphicon glyphicon-copy clone" title="复制" style="font-size:12px;top:0.5px;"></a>
|
||||
<a href="javascript:;" class="glyphicon glyphicon-remove delete" title="删除" style="font-size:12px;"></a>
|
||||
<a href="javascript:;" class="glyphicon icon-drag-move" title="移动"></a>
|
||||
<a href="javascript:;" class="glyphicon glyphicon-copy clone" title="复制"></a>
|
||||
<a href="javascript:;" class="glyphicon glyphicon-remove delete" title="删除"></a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="coll_tpl_relation_url">
|
||||
|
@ -113,9 +113,9 @@
|
|||
<td class="sign"><input type="text" class="form-control signs" readonly="true" /></td>
|
||||
<td>
|
||||
<input type="hidden" data-name="config[relation_urls][]" />
|
||||
<a href="javascript:;" class="glyphicon icon-drag-move" title="移动" style="font-size:12px;"></a>
|
||||
<a href="javascript:;" class="glyphicon glyphicon-copy clone" title="复制" style="font-size:12px;top:0.5px;"></a>
|
||||
<a href="javascript:;" class="glyphicon glyphicon-remove delete" title="删除" style="font-size:12px;"></a>
|
||||
<a href="javascript:;" class="glyphicon icon-drag-move" title="移动"></a>
|
||||
<a href="javascript:;" class="glyphicon glyphicon-copy clone" title="复制"></a>
|
||||
<a href="javascript:;" class="glyphicon glyphicon-remove delete" title="删除"></a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="coll_tpl_field">
|
||||
|
@ -126,9 +126,9 @@
|
|||
<input type="hidden" data-name="config[field_list][]" />
|
||||
<input type="hidden" data-name="config[field_process][]" />
|
||||
<a href="javascript:;" class="field-process">数据处理</a>
|
||||
<a href="javascript:;" class="glyphicon icon-drag-move" title="移动" style="font-size:12px;"></a>
|
||||
<a href="javascript:;" class="glyphicon glyphicon-copy field-clone" title="复制" style="font-size:12px;top:0.5px;"></a>
|
||||
<a href="javascript:;" class="glyphicon glyphicon-remove field-del" title="删除" style="font-size:12px;"></a>
|
||||
<a href="javascript:;" class="glyphicon icon-drag-move" title="移动"></a>
|
||||
<a href="javascript:;" class="glyphicon glyphicon-copy field-clone" title="复制"></a>
|
||||
<a href="javascript:;" class="glyphicon glyphicon-remove field-del" title="删除"></a>
|
||||
</td>
|
||||
<td><label class="radio-inline"><input type="radio" data-name="config[field_title]">绑定</label></td>
|
||||
<td><label class="checkbox-inline"><input type="checkbox" data-name="config[field_content][]">绑定</label></td>
|
||||
|
@ -155,15 +155,15 @@
|
|||
<div id="coll_tpl_process" class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<div class="panel-title" style="font-size:14px;overflow:hidden;">
|
||||
<a data-toggle="collapse" style="float:left;"></a>
|
||||
<div class="panel-title-title" style="float:left;">
|
||||
<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;" />
|
||||
<a href="javascript:;" data-toggle="collapse" style="float:left;"></a>
|
||||
<div class="panel-title-title">
|
||||
<a href="javascript:;" data-toggle="collapse" style="color:inherit;"></a>
|
||||
<input type="text" />
|
||||
</div>
|
||||
<div class="panel-title-ops" style="float:right;">
|
||||
<div class="panel-title-ops">
|
||||
<a href="javascript:;" class="glyphicon glyphicon-tag c-p-process-title" title="标题"></a>
|
||||
<a href="javascript:;" class="glyphicon icon-drag-move" title="移动"></a>
|
||||
<a href="javascript:;" class="glyphicon glyphicon-copy c-p-process-clone" title="复制" style="top:0.5px;"></a>
|
||||
<a href="javascript:;" class="glyphicon glyphicon-copy c-p-process-clone" title="复制"></a>
|
||||
<a href="javascript:;" class="glyphicon glyphicon-remove c-p-process-del" title="删除"></a>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
<div class="form-group">
|
||||
<div class="input-group input-group-sm">
|
||||
<div class="input-group-addon">多级页:{$level_url['name']}</div>
|
||||
<input type="text" name="level_{$level_url['level']}" class="form-control" value="{$level_url['url']?htmlspecialchars($level_url['url']):''}" />
|
||||
<input type="text" name="level{$level_url['level']}_url" class="form-control" value="{$level_url['url']?htmlspecialchars($level_url['url']):''}" />
|
||||
{if $pageOpenedList['level_url'][$level_url['name']]}
|
||||
<div class="input-group-addon">{$pageOpenedList['level_url'][$level_url['name']]}</div>
|
||||
{/if}
|
||||
|
|
|
@ -45,6 +45,15 @@ body>.wrapper>.content-wrapper{transition:none;}
|
|||
<input type="hidden" name="url_params" value="{$urlParams}" />
|
||||
<div id="win_input_urls" style="display:none;"></div>
|
||||
<div class="field-vals"></div>
|
||||
<div class="panel panel-default echo-msg-box" style="display:none;margin-top:20px;margin-bottom:5px;">
|
||||
<div class="panel-heading">
|
||||
<h4 class="panel-title"><a data-toggle="collapse" href="#win_test_echo_msg_box" aria-expanded="false" class="collapsed">插件中 \plugin\skycaiji::output 输出的内容</a></h4>
|
||||
</div>
|
||||
<div class="panel-collapse collapse" id="win_test_echo_msg_box">
|
||||
<div class="panel-body">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
'use strict';//严格模式
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
{extend name="common:main" /}
|
||||
{block name="cssjs"}
|
||||
{/block}
|
||||
{block name="content"}
|
||||
<form method="post" role="form" action="{:url('develop/export')}">
|
||||
<div class="box box-default">
|
||||
<div class="box-body" style="padding-bottom:0;">
|
||||
{:html_usertoken()}
|
||||
<input type="hidden" name="type" value="{$type}" />
|
||||
<input type="hidden" name="app" value="{$app}" />
|
||||
<input type="hidden" name="module" value="{$module}" />
|
||||
<div class="form-group">
|
||||
<label class="control-label">设置密码</label>
|
||||
<input type="text" class="form-control" name="pwd" placeholder="选填" autocomplete="off" />
|
||||
<p class="help-block">{$Think.lang.tips_export_ipt_pwd}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary btn-block">确定导出</button>
|
||||
</form>
|
||||
{/block}
|
|
@ -15,12 +15,7 @@
|
|||
请在 {$funcClass['filename']} 文件中编辑代码 或者 <a href="{:url('develop/editor?type=func&app='.$app)}"><b>使用插件编辑器</b></a>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="dropdown">
|
||||
<button type="button" class="btn btn-default btn-block dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">插件另存为 <span class="caret"></span></button>
|
||||
<ul class="dropdown-menu" style="width:100%;text-align:center;background:#f4f4f4;">
|
||||
<li><a href="{:url('admin/develop/export?type=func&app='.$funcClass['app'])}" target="_blank">导出至本地</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<a href="{:url('admin/develop/export?type=func&module='.$funcClass['module'].'&app='.$funcClass['app'])}" class="btn btn-default btn-block" target="_blank">插件另存为</a>
|
||||
</div>
|
||||
{/if}
|
||||
<div class="form-group">
|
||||
|
|
|
@ -19,12 +19,7 @@
|
|||
请在 {$config['app_file']} 文件中编辑代码 或者 <a href="{:url('develop/editor?type=release&app='.$appName)}"><b>使用插件编辑器</b></a>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="dropdown">
|
||||
<button type="button" class="btn btn-default btn-block dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">插件另存为 <span class="caret"></span></button>
|
||||
<ul class="dropdown-menu" style="width:100%;text-align:center;background:#f4f4f4;">
|
||||
<li><a href="{:url('admin/develop/export?type=release&app='.$config['app'])}" target="_blank">导出至本地</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<a href="{:url('admin/develop/export?type=release&module=cms&app='.$config['app'])}" class="btn btn-default btn-block" target="_blank">插件另存为</a>
|
||||
</div>
|
||||
{/if}
|
||||
{/if}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<script src="__PUBLIC__/static/js/admin/app.js?{$Think.config.html_v}"></script>
|
||||
{/block}
|
||||
{block name="content"}
|
||||
<div class="nav-tabs-custom">
|
||||
<div class="nav-tabs-custom" style="margin-bottom:15px;">
|
||||
<div class="tab-content">
|
||||
<div class="tab-pane active">
|
||||
<div class="table-responsive">
|
||||
|
@ -94,6 +94,7 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<a href="{:url('develop/app')}" class="btn btn-primary">开发一个</a>
|
||||
<script type="text/javascript">
|
||||
appClass.init_list();
|
||||
</script>
|
||||
|
|
|
@ -6,10 +6,13 @@
|
|||
{/foreach}
|
||||
</ul>
|
||||
{$pagenav}
|
||||
<script type="text/javascript">
|
||||
|
||||
<script type="text/javascript">
|
||||
'use strict';
|
||||
(function(){
|
||||
$('#window_rules #rule_list li a').bind('click',function(){
|
||||
var id=$(this).attr('data-id');
|
||||
var name=$(this).attr('data-title');
|
||||
var name='已下载 » '+$(this).attr('data-title');
|
||||
taskOpClass.import_rule('rule:'+id,name);
|
||||
});
|
||||
$('#window_rules .pagination').addClass('pagination-sm');
|
||||
|
@ -17,7 +20,9 @@
|
|||
windowModal('导入规则',$(this).attr('href'));
|
||||
return false;
|
||||
});
|
||||
</script>
|
||||
})();
|
||||
</script>
|
||||
|
||||
</div>
|
||||
{else /}
|
||||
您没有规则,请进入<a href="{:url('mystore/store')}">云平台</a>下载
|
||||
|
|
|
@ -2,15 +2,19 @@
|
|||
{:html_usertoken()}
|
||||
<input name="type" type="hidden" value="{$type}" />
|
||||
<input name="replace" type="hidden" value="" />
|
||||
<input name="from_task" type="hidden" value="{$fromTask}" />
|
||||
<div class="form-group">
|
||||
<label>{$typeName}文件</label>
|
||||
<input type="file" name="upload_file" class="form-control" style="padding:4px 0 0 4px; background:#efefef;">
|
||||
</div>
|
||||
<div class="form-group plugins-box" style="display:none;">
|
||||
<label style="margin-bottom:0;">检测到文件中包含{$typeIsRule?'':'多个'}插件,{$typeIsRule?'可':'请'}选择需要导入的插件(导入后会覆盖已有插件)</label>
|
||||
<div class="plugins-info"></div>
|
||||
<div class="form-group upload-ipt-pwd" style="display:none;">
|
||||
<label>输入密码</label>
|
||||
<input type="text" name="upload_addon[pwd]" class="form-control" placeholder="该文件已加密,请输入密码">
|
||||
</div>
|
||||
<div class="form-group upload-plugins" style="display:none;">
|
||||
<label style="margin-bottom:0;">检测到文件中包含{$typeIsPlugin?'多个':''}插件,{$typeIsPlugin?'请':'可'}选择需要导入的插件(导入后会覆盖已有插件)</label>
|
||||
<div class="upload-plugins-info"></div>
|
||||
</div>
|
||||
|
||||
{if condition="g_sc_c('site','verifycode')"}
|
||||
<div class="form-group">
|
||||
<label>{$Think.lang.verifycode}</label>
|
||||
|
@ -25,11 +29,15 @@
|
|||
</div>
|
||||
</form>
|
||||
<script type="text/javascript">
|
||||
'use strict';
|
||||
function win_upload_replace(){
|
||||
//替换
|
||||
$('#win_form_upload').find('[name="replace"]').val(1);
|
||||
$('#win_form_upload').submit();
|
||||
}
|
||||
function win_upload_ipt_pwd(){
|
||||
$('#win_form_upload .upload-ipt-pwd').show();
|
||||
}
|
||||
function win_upload_plugins(plugins){
|
||||
//选择插件
|
||||
if(isObject(plugins)){
|
||||
|
@ -37,7 +45,7 @@ function win_upload_plugins(plugins){
|
|||
for(var app in plugins){
|
||||
html+='<div class="checkbox"><label><input type="checkbox" name="upload_addon[plugins][]" value="'+app+'">'+plugins[app]+'</label></div>'
|
||||
}
|
||||
$('#win_form_upload .plugins-box').show().find('.plugins-info').html(html);
|
||||
$('#win_form_upload .upload-plugins').show().find('.upload-plugins-info').html(html);
|
||||
}
|
||||
}
|
||||
</script>
|
|
@ -0,0 +1,27 @@
|
|||
{extend name="common:main" /}
|
||||
{block name="cssjs"}
|
||||
{/block}
|
||||
{block name="content"}
|
||||
<form method="post" role="form" action="{:url('release/export')}">
|
||||
<div class="box box-default">
|
||||
<div class="box-body" style="padding-bottom:0;">
|
||||
{:html_usertoken()}
|
||||
<input type="hidden" name="task_id" value="{$task_id}" />
|
||||
<div class="form-group">
|
||||
<label>设置密码</label>
|
||||
<input type="text" class="form-control" name="pwd" placeholder="选填" autocomplete="off" />
|
||||
<p class="help-block">{$Think.lang.tips_export_ipt_pwd}</p>
|
||||
</div>
|
||||
{if !empty($hasPlugin)}
|
||||
<div class="form-group">
|
||||
<label>导出插件</label>
|
||||
<div class="input-group">
|
||||
<label class="checkbox-inline"><input type="checkbox" name="export_plugin" value="1" /> 设置中包含插件,是否一同导出?</label>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary btn-block">确定导出</button>
|
||||
</form>
|
||||
{/block}
|
|
@ -4,7 +4,7 @@
|
|||
{foreach name="releList" item="rele"}
|
||||
{php}
|
||||
if(!empty($taskNames[$rele['task_id']])){
|
||||
$releTitle='任务:'.$taskNames[$rele['task_id']];
|
||||
$releTitle=$taskNames[$rele['task_id']];
|
||||
}else{
|
||||
$releTitle='发布:'.$rele['name'];
|
||||
}
|
||||
|
@ -17,18 +17,23 @@
|
|||
{/foreach}
|
||||
</ul>
|
||||
{$pagenav}
|
||||
<script type="text/javascript">
|
||||
|
||||
<script type="text/javascript">
|
||||
'use strict';
|
||||
(function(){
|
||||
$('#window_reles #rele_list li a').bind('click',function(){
|
||||
var id=$(this).attr('data-id');
|
||||
var name=$(this).attr('data-title');
|
||||
releaseClass.import_rele(id,name);
|
||||
var name='任务 » '+$(this).attr('data-title');
|
||||
releaseClass.import_rele('release:'+id,name);
|
||||
});
|
||||
$('#window_reles .pagination').addClass('pagination-sm');
|
||||
$('#window_reles .pagination a').bind('click',function(){
|
||||
windowModal('导入规则',$(this).attr('href'));
|
||||
return false;
|
||||
});
|
||||
</script>
|
||||
})();
|
||||
</script>
|
||||
|
||||
</div>
|
||||
{else /}
|
||||
没有发布设置
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
<form id="form_rele" class="form-item" method="post" action="{:url('release/set')}">
|
||||
{:html_usertoken()}
|
||||
<input type="hidden" name="task_id" value="{$taskData['id']}" />
|
||||
<input type="hidden" name="release_id" value="" />
|
||||
<input type="hidden" name="release_import" value="" />
|
||||
<div class="form-group">
|
||||
<div class="input-group">
|
||||
<label class="input-group-addon">{$Think.lang.rele_module}</label>
|
||||
|
@ -16,7 +16,19 @@
|
|||
<option value="{$rele_module}">{:lang('rele_module_'.$rele_module)}</option>
|
||||
{/foreach}
|
||||
</select>
|
||||
<div class="input-group-btn"><button class="btn btn-default" type="button" id="btn_import_release">导入配置</button></div>
|
||||
<div class="input-group-btn dropdown">
|
||||
<button class="btn btn-default dropdown-toggle" type="button" id="btn_import_release" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
导入配置 <span class="caret"></span>
|
||||
</button>
|
||||
<ul class="dropdown-menu dropdown-menu-right" aria-labelledby="btn_import_release">
|
||||
<li><a href="javascript:;" onclick="windowModal('导入配置会覆盖当前任务的发布设置,且不可恢复','{:url("release/import")}');">其它任务设置</a></li>
|
||||
<li><a href="javascript:;" onclick="windowModal('导入配置会覆盖当前任务的发布设置,且不可恢复','{:url("mystore/upload?type=release&from_task=1")}');">导入文件</a></li>
|
||||
{if !empty($releData)}
|
||||
<li role="separator" class="divider"></li>
|
||||
<li><a href="{:url('release/export?task_id='.$releData['task_id'])}" target="_blank">另存为</a></li>
|
||||
{/if}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="rele-module" id="rele_module_cms" module="cms" style="display:none;">
|
||||
|
@ -164,29 +176,24 @@
|
|||
</div>
|
||||
<div class="form-group">
|
||||
<label>文件格式</label>
|
||||
<div class="row">
|
||||
<div class="col-sm-4" style="padding-top:7px;">
|
||||
<label class="radio-inline">
|
||||
<input type="radio" name="file[type]" value="xlsx"> Excel2007(.xlsx格式)
|
||||
</label>
|
||||
<div class="input-group mobile-input-group mobile-input-group1">
|
||||
<div class="input-group-addon">
|
||||
<label class="radio-inline"><input type="radio" name="file[type]" value="xlsx"> Excel2007(.xlsx格式)</label>
|
||||
</div>
|
||||
<div class="col-sm-4" style="padding-top:7px;">
|
||||
<label class="radio-inline">
|
||||
<input type="radio" name="file[type]" value="xls"> Excel2003(.xls格式)
|
||||
</label>
|
||||
<div class="input-group-addon brr_0">
|
||||
<label class="radio-inline"><input type="radio" name="file[type]" value="xls"> Excel2003(.xls格式)</label>
|
||||
</div>
|
||||
<div class="col-sm-4">
|
||||
<div class="input-group">
|
||||
<div class="input-group-addon" style="border:0;padding-left:0;">
|
||||
<label class="radio-inline">
|
||||
<input type="radio" name="file[type]" value="txt"> txt文本,字段分隔符
|
||||
</label>
|
||||
</div>
|
||||
<input type="text" class="form-control" name="file[txt_implode]" placeholder="默认制表符" />
|
||||
</div>
|
||||
<div class="input-group-addon brr_0">
|
||||
<label class="radio-inline"><input type="radio" name="file[type]" value="txt"> txt文本,字段分隔符</label>
|
||||
</div>
|
||||
<input type="text" class="form-control" name="file[txt_implode]" placeholder="默认制表符" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>文件最大行数</label>
|
||||
<input name="file[max_line]" type="number" class="form-control" value="" />
|
||||
<p class="help-block">文件超过最大行数时创建新的文件并自动编号,填0表示不限制</p>
|
||||
</div>
|
||||
{if !empty($collFields)}
|
||||
<div class="form-group">
|
||||
<label>隐藏采集字段</label>
|
||||
|
@ -205,19 +212,18 @@
|
|||
<div class="box box-default">
|
||||
<div class="box-body">
|
||||
<div class="form-group">
|
||||
<label>api地址</label>
|
||||
<div class="input-group mobile-input-group">
|
||||
<div class="input-group-addon">{$apiRootUrl}/api_task/{$taskData['id']}/</div>
|
||||
<input type="text" class="form-control" name="api[url]" placeholder="请输入字符串" />
|
||||
<label>API密钥</label>
|
||||
<div class="input-group">
|
||||
<input type="text" class="form-control" name="api[key]" placeholder="请输入字符串" autocomplete="off" />
|
||||
<div class="input-group-btn">
|
||||
<button type="button" class="btn btn-default btn-api-rand-url">随机字符串</button>
|
||||
</div>
|
||||
</div>
|
||||
<p class="help-block">
|
||||
请务必输入一个复杂的字符串以防止他人破解api下载数据!
|
||||
<br />
|
||||
{if condition="!empty($releData['config']['api']['url'])"}
|
||||
API网址:<a href="{$apiRootUrl}/api_task/{$taskData['id']}/{$releData['config']['api']['url']}" target="_blank">{$apiRootUrl}/api_task/{$taskData['id']}/{$releData['config']['api']['url']}</a>
|
||||
设置一个密钥增加API安全性
|
||||
{if !empty($releData['config']['api'])}
|
||||
{php}$apiKeyStr=isset($releData['config']['api']['url'])?$releData['config']['api']['url']:md5($releData['config']['api']['key']);{/php}
|
||||
,API网址:<a href="{$apiRootUrl}/api_task/{$taskData['id']}/{$apiKeyStr}" target="_blank">{$apiRootUrl}/api_task/{$taskData['id']}/{$apiKeyStr}</a>
|
||||
{/if}
|
||||
</p>
|
||||
</div>
|
||||
|
@ -331,10 +337,10 @@
|
|||
<input type="text" name="toapi[param_name][]" class="form-control" autocomplete="off" />
|
||||
</td>
|
||||
<td>
|
||||
<div class="input-group toapi-txt-field">
|
||||
<div class="input-group toapi-field-txt">
|
||||
<input type="text" name="toapi[param_val][]" class="form-control" autocomplete="off" />
|
||||
<div class="input-group-btn">
|
||||
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">字段 <span class="caret"></span></button>
|
||||
<div class="input-group-addon">
|
||||
<a href="javascript:;" class="dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">字段 <span class="caret"></span></a>
|
||||
<ul class="dropdown-menu dropdown-menu-right">
|
||||
{if !empty($collFields)}
|
||||
{foreach $collFields as $v}
|
||||
|
@ -371,10 +377,10 @@
|
|||
<input type="text" name="toapi[header_name][]" class="form-control" autocomplete="off" />
|
||||
</td>
|
||||
<td>
|
||||
<div class="input-group toapi-txt-field">
|
||||
<div class="input-group toapi-field-txt">
|
||||
<input type="text" name="toapi[header_val][]" class="form-control" autocomplete="off" />
|
||||
<div class="input-group-btn">
|
||||
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">字段 <span class="caret"></span></button>
|
||||
<div class="input-group-addon">
|
||||
<a href="javascript:;" class="dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">字段 <span class="caret"></span></a>
|
||||
<ul class="dropdown-menu dropdown-menu-right">
|
||||
{if !empty($collFields)}
|
||||
{foreach $collFields as $v}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<input type="hidden" name="toapi[app_api]" value="{$appApi}" />
|
||||
<div class="box box-primary">
|
||||
<div class="box-body">
|
||||
<table class="table">
|
||||
<div class="box-body table-responsive toapi-app-table">
|
||||
<table class="table table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>参数名称</th>
|
||||
|
@ -14,15 +14,7 @@
|
|||
<tr>
|
||||
<td>{if !empty($pv['required'])}<em>*</em> {/if}{$pv['name']}</td>
|
||||
<td>
|
||||
{if $pv['tag']=='select'}
|
||||
<select name="toapi[app_params][{$pk}]" class="form-control">
|
||||
{if !empty($pvOption)}
|
||||
{foreach $pvOption as $pvOk=>$pvOv}
|
||||
<option value="{$pvOk}">{$pvOv}</option>
|
||||
{/foreach}
|
||||
{/if}
|
||||
</select>
|
||||
{elseif $pv['tag']=='radio'}
|
||||
{if $pv['tag']=='radio'}
|
||||
{if !empty($pvOption)}
|
||||
{foreach $pvOption as $pvOk=>$pvOv}
|
||||
<label class="radio-inline"><input type="radio" name="toapi[app_params][{$pk}]" value="{$pvOk}">{$pvOv}</label>
|
||||
|
@ -40,10 +32,30 @@
|
|||
{elseif $pv['tag']=='number'}
|
||||
<input type="number" name="toapi[app_params][{$pk}]" class="form-control" autocomplete="off" />
|
||||
{else/}
|
||||
<div class="input-group toapi-txt-field">
|
||||
<input type="text" name="toapi[app_params][{$pk}]" class="form-control" autocomplete="off" />
|
||||
<div class="input-group toapi-field-txt{if $pv['tag']=='select'||$pv['tag']=='selects'} toapi-field-slt{/if}">
|
||||
{if $pv['tag']=='select'||$pv['tag']=='selects'}
|
||||
<div class="input-group-btn">
|
||||
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">字段 <span class="caret"></span></button>
|
||||
<select name="toapi[app_params][{$pk}]{if $pv['tag']=='selects'}[]{/if}" class="form-control"{if $pv['tag']=='selects'} multiple="multiple"{/if}>
|
||||
{if !empty($pvOption)}
|
||||
{foreach $pvOption as $pvOk=>$pvOv}
|
||||
<option value="{$pvOk}">{$pvOv}</option>
|
||||
{/foreach}
|
||||
{/if}
|
||||
<option value="@skycaiji_custom">自定义内容</option>
|
||||
</select>
|
||||
</div>
|
||||
{if $pv['tag']=='selects'}
|
||||
<textarea name="toapi[app_custom_params][{$pk}]" class="form-control" placeholder="自定义内容,一行一个值 可以按住 Ctrl 多选"></textarea>
|
||||
{else/}
|
||||
<input type="text" name="toapi[app_custom_params][{$pk}]" class="form-control" autocomplete="off" placeholder="自定义内容" />
|
||||
{/if}
|
||||
{elseif $pv['tag']=='textarea'}
|
||||
<textarea name="toapi[app_params][{$pk}]" class="form-control"></textarea>
|
||||
{else/}
|
||||
<input type="text" name="toapi[app_params][{$pk}]" class="form-control" autocomplete="off" />
|
||||
{/if}
|
||||
<div class="input-group-addon">
|
||||
<a href="javascript:;" class="dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">字段 <span class="caret"></span></a>
|
||||
<ul class="dropdown-menu dropdown-menu-right">
|
||||
{if !empty($collFields)}
|
||||
{foreach $collFields as $v}
|
||||
|
@ -62,5 +74,5 @@
|
|||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
releaseClass.toapi_app_load({$appParams|json_encode});
|
||||
releaseClass.toapi_app_load({$appParams|json_encode},{$appCustomParams|json_encode});
|
||||
</script>
|
|
@ -0,0 +1,9 @@
|
|||
<form method="post" action="{:url('tool/preview_data')}" target="_blank">
|
||||
{:html_usertoken()}
|
||||
<div class="form-group">
|
||||
<textarea name="data" class="form-control" rows="20">{$apiHtml|htmlspecialchars}</textarea>
|
||||
</div>
|
||||
<div class="form-group form-group-sm">
|
||||
<button type="submit" class="btn btn-default btn-block">解析</button>
|
||||
</div>
|
||||
</form>
|
|
@ -130,7 +130,7 @@
|
|||
<div class="form-group">
|
||||
<label>{$Think.lang.set_caiji_interval}(分钟)</label>
|
||||
<input type="number" name="interval" class="form-control" />
|
||||
<p class="help-block">采集完毕隔多久再次运行,可轮询目标的数据更新且有效减轻服务器压力,强烈建议设置时间!留空或0表示不限制(采集量大会造成服务器过载)</p>
|
||||
<p class="help-block">采集完毕隔多久再次运行,可轮询目标(起始页、多级页)的数据更新且有效减轻服务器压力,强烈建议设置时间!留空或0表示不限制(采集量大会造成服务器过载)</p>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>{$Think.lang.set_caiji_timeout}(分钟)</label>
|
||||
|
|
|
@ -2,11 +2,12 @@
|
|||
{:html_usertoken()}
|
||||
<div class="well" style="text-align:center;">
|
||||
<label class="checkbox-inline"><input type="checkbox" name="types[]" value="all"> 所有</label>
|
||||
<label class="checkbox-inline"><input type="checkbox" name="types[]" value="system" checked="checked"> 系统缓存</label>
|
||||
<label class="checkbox-inline"><input type="checkbox" name="types[]" value="data"> 数据缓存</label>
|
||||
<label class="checkbox-inline" title="系统日志、临时文件等"><input type="checkbox" name="types[]" value="system" checked="checked"> 系统缓存</label>
|
||||
<label class="checkbox-inline" title="采集运行时产生的文件"><input type="checkbox" name="types[]" value="data"> 数据缓存</label>
|
||||
{if $clearPageRender}
|
||||
<label class="checkbox-inline"><input type="checkbox" name="types[]" value="page_render"> 渲染工具缓存</label>
|
||||
<label class="checkbox-inline" title="渲染工具的内存数据"><input type="checkbox" name="types[]" value="page_render"> 渲染工具缓存</label>
|
||||
{/if}
|
||||
<label class="checkbox-inline" title="数据库中cache前缀表数据"><input type="checkbox" name="types[]" value="table"> 表缓存</label>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary btn-block">清理</button>
|
||||
</form>
|
|
@ -22,6 +22,14 @@
|
|||
<input type="number" name="file_interval" class="form-control" />
|
||||
<p class="help-block">可防止下载太快造成目标网站响应超时或宕机,留空或0表示不限制</p>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>读取文件真实地址</label>
|
||||
<div class="input-group">
|
||||
<label class="radio-inline"><input type="radio" name="url_real" value="1">是</label>
|
||||
<label class="radio-inline"><input type="radio" name="url_real" value="0" checked="checked">否</label>
|
||||
</div>
|
||||
<p class="help-block">读取文件网址重定向后的真实地址</p>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>文件保存目录(绝对路径)</label>
|
||||
<input type="text" name="file_path" class="form-control" placeholder="默认:{:config('root_path')}{:DS}data{:DS}files" />
|
||||
|
|
|
@ -16,7 +16,9 @@
|
|||
<div class="panel-collapse collapse" data-func-panel="1">
|
||||
<div class="panel-body">
|
||||
<div class="form-group">
|
||||
<label>函数名</label> <select class="form-control" data-func-func="1">
|
||||
<label>函数名</label>
|
||||
<a href="javascript:;" class="fa fa-refresh plugin-func-refresh" title="刷新"></a>
|
||||
<select class="form-control" data-func-func="1">
|
||||
<option value="">不使用</option>
|
||||
</select>
|
||||
</div>
|
||||
|
|
|
@ -30,7 +30,14 @@
|
|||
</div>
|
||||
<p class="help-block">将<img src="data:image/*;base64">非url形式的编码数据保存为图片</p>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>读取图片真实地址</label>
|
||||
<div class="input-group">
|
||||
<label class="radio-inline"><input type="radio" name="url_real" value="1">是</label>
|
||||
<label class="radio-inline"><input type="radio" name="url_real" value="0" checked="checked">否</label>
|
||||
</div>
|
||||
<p class="help-block">读取图片网址重定向后的真实地址</p>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>图片保存目录(绝对路径)</label>
|
||||
<input type="text" name="img_path" class="form-control" placeholder="默认:{:config('root_path')}{:DS}data{:DS}images" />
|
||||
|
@ -93,7 +100,7 @@
|
|||
<div class="form-group">
|
||||
<label>扩展图片后缀</label>
|
||||
<input type="text" name="more_suffix" class="form-control" placeholder="选填" />
|
||||
<p class="help-block">默认识别后缀 jpg, jpeg, gif, png, bmp,未知后缀名自动保存为jpg格式,如需支持其他格式图片请输入后缀名(多个用逗号分隔)</p>
|
||||
<p class="help-block">默认识别后缀 jpg, jpeg, gif, png, bmp, webp, wbmp,未知后缀名自动保存为jpg格式,如需支持其他格式图片请输入后缀名(多个用逗号分隔)</p>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>下载超时(秒)</label>
|
||||
|
|
|
@ -16,7 +16,9 @@
|
|||
<div class="panel-collapse collapse" data-func-panel="1">
|
||||
<div class="panel-body">
|
||||
<div class="form-group">
|
||||
<label>函数名</label> <select class="form-control" data-func-func="1">
|
||||
<label>函数名</label>
|
||||
<a href="javascript:;" class="fa fa-refresh plugin-func-refresh" title="刷新"></a>
|
||||
<select class="form-control" data-func-func="1">
|
||||
<option value="">不使用</option>
|
||||
</select>
|
||||
</div>
|
||||
|
|
|
@ -3,48 +3,90 @@
|
|||
<script src="__PUBLIC__/static/js/admin/setting.js?{$Think.config.html_v}"></script>
|
||||
{/block}
|
||||
{block name="content"}
|
||||
<form id="form_set" method="post" role="form" action="{:url('admin/setting/email')}">
|
||||
<div class="box box-default">
|
||||
<div class="box-body">
|
||||
<form id="form_set" method="post" ajax-submit="true" role="form" action="{:url('admin/setting/email')}">
|
||||
{:html_usertoken()}
|
||||
<input type="hidden" name="is_test" value="" />
|
||||
<div class="form-group">
|
||||
<label>{$Think.lang.set_email_sender}</label>
|
||||
<input type="text" name="sender" class="form-control" value="{$emailConfig['sender']}">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>{$Think.lang.set_email_email}</label>
|
||||
<input type="text" name="email" class="form-control" value="{$emailConfig['email']}">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>{$Think.lang.set_email_pwd}</label>
|
||||
<input type="password" name="pwd" class="form-control" autocomplete="off" value="{$emailConfig['pwd']}">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>{$Think.lang.set_email_smtp}</label>
|
||||
<input type="text" name="smtp" class="form-control" value="{$emailConfig['smtp']}">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>{$Think.lang.set_email_port}</label>
|
||||
<input type="text" name="port" class="form-control" value="{$emailConfig['port']}">
|
||||
<p class="help-block">{$Think.lang.set_email_port_tips}</p>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>{$Think.lang.set_email_type}</label>
|
||||
<div class="radio">
|
||||
<label><input type="radio" name="type" value="tls">tls</label>
|
||||
<label><input type="radio" name="type" value="ssl">ssl</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<button type="button" id="btn_test" class="btn btn-default">{$Think.lang.test}</button>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<button type="submit" class="btn btn-primary btn-block">{$Think.lang.save}</button>
|
||||
</div>
|
||||
</form>
|
||||
<input type="hidden" name="is_test" value="" />
|
||||
<div class="form-group">
|
||||
<label>{$Think.lang.set_email_sender}</label>
|
||||
<input type="text" name="sender" class="form-control" value="{$emailConfig['sender']}">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>{$Think.lang.set_email_email}</label>
|
||||
<input type="text" name="email" class="form-control" value="{$emailConfig['email']}">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>{$Think.lang.set_email_pwd}</label>
|
||||
<input type="password" name="pwd" class="form-control" autocomplete="off" value="{$emailConfig['pwd']}">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>{$Think.lang.set_email_smtp}</label>
|
||||
<input type="text" name="smtp" class="form-control" value="{$emailConfig['smtp']}">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>{$Think.lang.set_email_port}</label>
|
||||
<input type="text" name="port" class="form-control" value="{$emailConfig['port']}">
|
||||
<p class="help-block">{$Think.lang.set_email_port_tips}</p>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>{$Think.lang.set_email_type}</label>
|
||||
<div class="input-group">
|
||||
<label class="radio-inline"><input type="radio" name="type" value="tls">tls</label>
|
||||
<label class="radio-inline"><input type="radio" name="type" value="ssl">ssl</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group" style="margin-bottom:5px;">
|
||||
<button type="button" id="btn_test" class="btn btn-default btn-block">{$Think.lang.test}</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-collapse collapse in">
|
||||
<div class="panel-body">
|
||||
<div class="form-group" style="margin-bottom:0;">
|
||||
<label>采集提醒设置</label>
|
||||
<div class="input-group">
|
||||
<label class="radio-inline"><input type="radio" name="caiji[open]" value="1">是</label>
|
||||
<label class="radio-inline"><input type="radio" name="caiji[open]" value="0">否</label>
|
||||
</div>
|
||||
</div>
|
||||
<div id="caiji_open" style="display:none;margin-top:15px;">
|
||||
<div class="form-group">
|
||||
<label>仅限自动采集</label>
|
||||
<div class="input-group">
|
||||
<label class="radio-inline"><input type="radio" name="caiji[is_auto]" value="1">是</label>
|
||||
<label class="radio-inline"><input type="radio" name="caiji[is_auto]" value="0">否</label>
|
||||
</div>
|
||||
<p class="help-block">只有在自动采集任务时才发送提醒</p>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>任务失败次数</label>
|
||||
<input type="number" name="caiji[failed_num]" class="form-control" value="">
|
||||
<p class="help-block">任务失败多少次发送提醒,每次提醒后都会重新计算失败次数,留空或0表示不提醒</p>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>失败提醒间隔(分钟)</label>
|
||||
<input type="number" name="caiji[failed_interval]" class="form-control" value="">
|
||||
<p class="help-block">每隔多少分钟提醒一次,留空或0表示没有间隔</p>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>发送报表间隔(分钟)</label>
|
||||
<input type="number" name="caiji[report_interval]" class="form-control" value="">
|
||||
<p class="help-block">每隔多少分钟发送一次采集汇总报表,留空或0表示不发送</p>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>收件邮箱</label>
|
||||
<input type="text" name="caiji[email]" class="form-control" value="" placeholder="默认使用{$Think.lang.set_email_email}接收邮件">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<button type="submit" class="btn btn-primary btn-block">{$Think.lang.save}</button>
|
||||
</div>
|
||||
</form>
|
||||
<script type="text/javascript">
|
||||
settingClass.email_init({$emailConfig|json_encode});
|
||||
</script>
|
||||
|
|
|
@ -12,7 +12,9 @@
|
|||
<div class="alert alert-success" role="alert">
|
||||
渲染工具正在运行!
|
||||
<button type="button" id="btn_chrome_clean" class="btn btn-sm btn-success" style="margin-left:5px;">清理渲染工具缓存</button>
|
||||
{if $serverIsLocal}
|
||||
<button type="button" id="btn_chrome_restart" class="btn btn-sm btn-success" style="margin-left:5px;">重启渲染工具</button>
|
||||
{/if}
|
||||
</div>
|
||||
{else /}
|
||||
<div class="alert alert-warning" role="alert">渲染工具服务器未开启,请检查配置是否正确!确认无误后点击保存</div>
|
||||
|
@ -28,8 +30,14 @@
|
|||
</select>
|
||||
</div>
|
||||
<div id="render_tool_chrome" style="display:none;">
|
||||
<p class="help-block">请在服务器中安装浏览器</p>
|
||||
<div class="form-group">
|
||||
<label>浏览器环境</label>
|
||||
<div class="input-group">
|
||||
<label class="radio-inline"><input type="radio" name="chrome[server]" value="" checked="checked">本地安装</label>
|
||||
<label class="radio-inline"><input type="radio" name="chrome[server]" value="remote">远程调用</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group" data-chrome-server="">
|
||||
<label>浏览器文件路径或者环境变量名</label>
|
||||
<div class="input-group">
|
||||
<input type="text" class="form-control" name="chrome[filename]" placeholder="默认环境变量名chrome" value="{$config['chrome']['filename']}" />
|
||||
|
@ -48,7 +56,7 @@
|
|||
<input type="text" name="chrome[port]" class="form-control" placeholder="默认9222" value="{$config['chrome']['port']}" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="form-group" data-chrome-server="">
|
||||
<label>用户配置目录</label>
|
||||
<input type="text" name="chrome[user_data_dir]" class="form-control" placeholder="选填" value="{$config['chrome']['user_data_dir']}" />
|
||||
<p class="help-block">自定义浏览器存储用户配置文件的目录</p>
|
||||
|
|
|
@ -0,0 +1,52 @@
|
|||
<table style="border:0;margin-bottom:10px;white-space:nowrap;text-align:left;">
|
||||
<tr>
|
||||
<th style="padding:0 5px;">今日成功</th>
|
||||
<th style="padding:0 5px;">今日失败</th>
|
||||
<th style="padding:0 5px;">总成功数</th>
|
||||
<th style="padding:0 5px;">总失败数</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding:0 5px;">{$report['today_success']}条</td>
|
||||
<td style="padding:0 5px;">{$report['today_error']}条</td>
|
||||
<td style="padding:0 5px;">{$report['total_success']}条</td>
|
||||
<td style="padding:0 5px;">{$report['total_error']}条</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table style="border:0;margin-bottom:10px;white-space:nowrap;text-align:left;">
|
||||
<tr>
|
||||
<th style="padding:0 5px;">自动任务</th>
|
||||
<th style="padding:0 5px;">手动任务</th>
|
||||
{if $report['caijitime']}
|
||||
<th style="padding:0 5px;">最近采集</th>
|
||||
{/if}
|
||||
<th style="padding:0 5px;">自动触发</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding:0 5px;">{$report['task_auto']}个</td>
|
||||
<td style="padding:0 5px;">{$report['task_other']}个</td>
|
||||
{if $report['caijitime']}
|
||||
<td style="padding:0 5px;">{:date('Y-m-d H:i:s',$report['caijitime'])}</td>
|
||||
{/if}
|
||||
<td style="padding:0 5px;">{$report['autotime']?date('Y-m-d H:i:s',$report['autotime']):'无'}</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
{if $report['today_tasks']}
|
||||
<table style="border:0;margin-bottom:10px;white-space:nowrap;text-align:left;">
|
||||
<tr>
|
||||
<th style="padding:0 5px;">ID</th>
|
||||
<th style="padding:0 5px;">任务名</th>
|
||||
<th style="padding:0 5px;">今日成功</th>
|
||||
<th style="padding:0 5px;">今日失败</th>
|
||||
</tr>
|
||||
{foreach $report['today_tasks'] as $k=>$v}
|
||||
<tr>
|
||||
<td style="padding:0 5px;">{$k}</td>
|
||||
<td style="padding:0 5px;">{$v['name']}</td>
|
||||
<td style="padding:0 5px;">{$v['success']|intval}条</td>
|
||||
<td style="padding:0 5px;">{$v['error']|intval}条</td>
|
||||
</tr>
|
||||
{/foreach}
|
||||
</table>
|
||||
{/if}
|
|
@ -36,7 +36,7 @@
|
|||
<tr>
|
||||
<td colspan="4">
|
||||
<button type="submit" class="btn btn-default">{$Think.lang.save}</button>
|
||||
<a href="{:url('task/save')}" class="btn btn-primary">{$Think.lang.task_add}</a>
|
||||
<a href="{:url('task/set')}" class="btn btn-primary">{$Think.lang.task_add}</a>
|
||||
</td>
|
||||
<td colspan="3">
|
||||
<label class="checkbox-inline chk-inline">
|
||||
|
|
|
@ -28,14 +28,14 @@
|
|||
{if empty($taskList)}
|
||||
<tr>
|
||||
<td colspan="7" style="text-align:center;">
|
||||
<p class="help-block">没有任务,创建<a href="{:url('task/save')}">新任务</a>或进入<a href="{:url('mystore/store')}">云平台</a>下载规则</p>
|
||||
<p class="help-block">没有任务,创建<a href="{:url('task/set')}">新任务</a>或进入<a href="{:url('mystore/store')}">云平台</a>下载规则</p>
|
||||
</td>
|
||||
</tr>
|
||||
{else/}
|
||||
{foreach name="taskList" item="item"}
|
||||
<tr data-task-id="{$item['id']}">
|
||||
<td class="sort"><input type="text" name="newsort[{$item['id']}]" class="form-control" value="{$item['sort']}" autocomplete="off" /></td>
|
||||
<td><a href="{:url('task/save?id='.$item['id'])}">{$item['name']}</a></td>
|
||||
<td><a href="{:url('task/set?id='.$item['id'])}">{$item['name']}</a></td>
|
||||
<td><a href="{:url('task/list?show=list&tg_id='.$item['tg_id'])}">{$tgList[$item['tg_id']]?$tgList[$item['tg_id']]:lang($item['tg_id']?'deleted':'none')}</a></td>
|
||||
<td><a href="javascript:;" class="auto" data-val={$item['auto']} style="color:{$item['auto']>0?'green':'red'}" title="{$item['_timer_info']?$item['_timer_info']:''}">{:lang('task_auto_'.$item['auto'])}</a></td>
|
||||
<td>{$item['addtime']|date='Y-m-d',###}</td>
|
||||
|
@ -78,7 +78,7 @@
|
|||
<tr>
|
||||
<td colspan="5">
|
||||
<button type="submit" class="btn btn-default">{$Think.lang.save}</button>
|
||||
<a href="{:url('task/save')}" class="btn btn-primary">{$Think.lang.task_add}</a>
|
||||
<a href="{:url('task/set')}" class="btn btn-primary">{$Think.lang.task_add}</a>
|
||||
</td>
|
||||
<td colspan="3">
|
||||
<label class="checkbox-inline chk-inline">
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
{extend name="common:main" /}
|
||||
{block name="cssjs"}
|
||||
{/block}
|
||||
{block name="content"}
|
||||
{include file="task:set_form" /}
|
||||
{include file="task:stepsbar" /}
|
||||
{/block}
|
|
@ -0,0 +1,3 @@
|
|||
<div class="">
|
||||
{include file="task:set_form" /}
|
||||
</div>
|
|
@ -0,0 +1,613 @@
|
|||
<form id="form_item" method="post" ajax-submit="true" enctype="multipart/form-data" action="{:url('task/set')}">
|
||||
{:html_usertoken()}
|
||||
<div class="box box-default">
|
||||
<div class="box-body" style="padding-bottom:0;">
|
||||
{if condition="$taskData"}
|
||||
<input type="hidden" name="id" value="{$taskData['id']}" />
|
||||
{/if}
|
||||
<input type="hidden" name="task_id" value="" />
|
||||
<input type="hidden" name="rule_import" value="" />
|
||||
<div class="form-group">
|
||||
<label>{$Think.lang.task_name}</label>
|
||||
{if condition="$taskData"}
|
||||
<input name="name" class="form-control" value="{$taskData['name']}">
|
||||
{else/}
|
||||
<div class="input-group">
|
||||
<input name="name" class="form-control" value="">
|
||||
<div class="input-group-btn"><button class="btn btn-default" onclick="windowModal('复制一个任务的所有设置','{:url("task/import")}');" type="button" id="btn_import_task">导入任务</button></div>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>{$Think.lang.task_tg}</label>
|
||||
{$tgSelect}
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>{$Think.lang.task_sort}</label>
|
||||
<input type="number" class="form-control" name="sort" autocomplete="off" value="{$taskData?intval($taskData['sort']):0}" />
|
||||
<p class="help-block">{$Think.lang.task_sort_help}</p>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>{$Think.lang.task_module}</label>
|
||||
<div class="input-group" style="width:100%;">
|
||||
<select name="module" class="form-control">
|
||||
{foreach name="Think.config.allow_coll_modules" item="cmodule"}
|
||||
<option value="{$cmodule}">{:lang('task_module_'.$cmodule)}</option>
|
||||
{/foreach}
|
||||
</select>
|
||||
<div class="input-group-btn dropdown">
|
||||
<button class="btn btn-default dropdown-toggle" type="button" id="btn_import_rule" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
导入规则 <span class="caret"></span>
|
||||
</button>
|
||||
<ul class="dropdown-menu dropdown-menu-right dropdown-import-rule" aria-labelledby="btn_import_rule">
|
||||
<li><a href="javascript:;" onclick="windowModal('导入规则会覆盖该任务的采集器设置,且不可恢复','{:url("mystore/rule?tpl=task&type=collect")}');">已下载规则</a></li>
|
||||
<li><a href="javascript:;" onclick="windowModal('导入规则会覆盖该任务的采集器设置,且不可恢复','{:url("collector/list?module=pattern&tpl=task")}');">其它任务的规则</a></li>
|
||||
<li><a href="javascript:;" onclick="windowModal('导入规则会覆盖该任务的采集器设置,且不可恢复','{:url("mystore/upload?type=rule&from_task=1")}');">导入规则文件</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>{$Think.lang.task_auto}</label>
|
||||
<select name="auto" class="form-control">
|
||||
<option value="0">关闭</option>
|
||||
<option value="1">循环采集(采集完后间隔一段时间再次运行)</option>
|
||||
<option value="2">定时采集(指定时间运行采集)</option>
|
||||
</select>
|
||||
{if is_empty(g_sc_c('caiji','auto'))}
|
||||
<p class="help-block" id="config_task_auto_tips" style="display:none;">需要全局<a href="{:url('setting/caiji')}" target="_blank">开启自动采集</a>该功能才会生效</p>
|
||||
{/if}
|
||||
</div>
|
||||
<div id="config_task_timer" style="display:none;">
|
||||
<input type="hidden" name="task_timer[month]" value="" />
|
||||
<input type="hidden" name="task_timer[day]" value="" />
|
||||
<input type="hidden" name="task_timer[hour]" value="" />
|
||||
<input type="hidden" name="task_timer[minute]" value="" />
|
||||
<div class="form-group">
|
||||
<div style="padding:0 15px 0 15px;">
|
||||
<div class="row">
|
||||
<div class="col-sm-3 col-xs-6" style="padding:0;">
|
||||
<div class="input-group">
|
||||
<span class="input-group-addon" style="background:#f4f4f4;">月份</span>
|
||||
<select id="task_timer_month" data-name="task_timer[month]" class="form-control" multiple="multiple" size="4">
|
||||
<option value="">全部</option>
|
||||
<option value="1">一月</option>
|
||||
<option value="2">二月</option>
|
||||
<option value="3">三月</option>
|
||||
<option value="4">四月</option>
|
||||
<option value="5">五月</option>
|
||||
<option value="6">六月</option>
|
||||
<option value="7">七月</option>
|
||||
<option value="8">八月</option>
|
||||
<option value="9">九月</option>
|
||||
<option value="10">十月</option>
|
||||
<option value="11">十一月</option>
|
||||
<option value="12">十二月</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-3 col-xs-6" style="padding:0;">
|
||||
<div class="input-group">
|
||||
<span class="input-group-addon" style="background:#f4f4f4;">日期</span>
|
||||
<select id="task_timer_day" data-name="task_timer[day]" class="form-control" multiple="multiple" size="4">
|
||||
<option value="">全部</option>
|
||||
{for start="1" end="32"}
|
||||
<option value="{$i}">{$i} 日</option>
|
||||
{/for}
|
||||
<option value="w1">周一</option>
|
||||
<option value="w2">周二</option>
|
||||
<option value="w3">周三</option>
|
||||
<option value="w4">周四</option>
|
||||
<option value="w5">周五</option>
|
||||
<option value="w6">周六</option>
|
||||
<option value="w7">周日</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-3 col-xs-6" style="padding:0;">
|
||||
<div class="input-group">
|
||||
<span class="input-group-addon" style="background:#f4f4f4;">小时</span>
|
||||
<select id="task_timer_hour" data-name="task_timer[hour]" class="form-control" multiple="multiple" size="4">
|
||||
<option value="">全部</option>
|
||||
{for start="0" end="24"}
|
||||
<option value="{:sprintf('%02d',$i)}">{:sprintf('%02d',$i)} 时</option>
|
||||
{/for}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-3 col-xs-6" style="padding:0;">
|
||||
<div class="input-group">
|
||||
<span class="input-group-addon" style="background:#f4f4f4;">分钟</span>
|
||||
<select id="task_timer_minute" data-name="task_timer[minute]" class="form-control" multiple="multiple" size="4">
|
||||
<option value="">全部</option>
|
||||
{for start="0" end="60"}
|
||||
<option value="{:sprintf('%02d',$i)}">{:sprintf('%02d',$i)} 分</option>
|
||||
{/for}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<p class="help-block" style="word-wrap:break-word;"><b>多选:</b>Windows按住Ctrl多选,Mac按住command多选 {$timerInfo}</p>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>执行未触发定时</label>
|
||||
<div class="input-group">
|
||||
<label class="radio-inline"><input type="radio" name="config[other][timer_again]" value="1" /> 是</label>
|
||||
<label class="radio-inline"><input type="radio" name="config[other][timer_again]" value="0" checked="checked" /> 否</label>
|
||||
</div>
|
||||
<p class="help-block">某些情况(访问触发)不能精准执行定时,该选项允许执行上个未成功触发的定时</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h4 class="panel-title">
|
||||
<a data-toggle="collapse" href="#task_single" aria-expanded="false">单页采集模式</a>
|
||||
</h4>
|
||||
</div>
|
||||
<div id="task_single" class="panel-collapse collapse">
|
||||
<div class="panel-body">
|
||||
{if empty($taskData)}
|
||||
请先保存任务
|
||||
{else/}
|
||||
{if empty($collData)}
|
||||
<a href="{:url('collector/set?task_id='.$taskData['id'])}">请先配置采集器设置</a>
|
||||
{else/}
|
||||
<div class="form-group">
|
||||
<label>开启</label>
|
||||
<div class="input-group">
|
||||
<label class="radio-inline"><input type="radio" name="config[single][open]" value="1">是</label>
|
||||
<label class="radio-inline"><input type="radio" name="config[single][open]" value="0" checked="checked">否</label>
|
||||
</div>
|
||||
<p class="help-block">
|
||||
允许通过访问接口方式传入网址参数采集单个页面<br>该模式仅在web中运行,会受web服务器运行时长影响,如遇采集中断需修改web服务器的超时时间
|
||||
</p>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>总是返回数据</label>
|
||||
<div class="input-group">
|
||||
<label class="radio-inline"><input type="radio" name="config[single][always]" value="1">是</label>
|
||||
<label class="radio-inline"><input type="radio" name="config[single][always]" value="0" checked="checked">否</label>
|
||||
</div>
|
||||
<p class="help-block">
|
||||
无论是否发布数据总是允许采集并返回数据(不会重复发布)
|
||||
</p>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>接口密钥</label>
|
||||
<div class="input-group">
|
||||
<input type="text" name="config[single][key]" class="form-control" placeholder="选填" />
|
||||
<div class="input-group-btn">
|
||||
<button type="button" class="btn btn-default btn-rand-single-key">随机字符串</button>
|
||||
</div>
|
||||
</div>
|
||||
<p class="help-block">设置一个密钥增加接口安全性</p>
|
||||
</div>
|
||||
|
||||
{if !empty($singleApiUrl)}
|
||||
<div class="form-group">
|
||||
<label>访问接口</label>
|
||||
<div>{$singleApiUrl}</div>
|
||||
<p class="help-block">
|
||||
传入的网址参数必须经过url编码
|
||||
{if !empty($singleIptMore)}
|
||||
<br>内容页网址必填,其他网址选填(输入其他网址是因为内容N或字段调用了该页面)为确保数据完整性建议全部填写
|
||||
{/if}
|
||||
</p>
|
||||
</div>
|
||||
{/if}
|
||||
{/if}
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h4 class="panel-title">
|
||||
<a data-toggle="collapse" href="#task_config" aria-expanded="false">更多设置</a>
|
||||
</h4>
|
||||
</div>
|
||||
<div id="task_config" class="panel-collapse collapse">
|
||||
<div class="panel-body">
|
||||
<p class="help-block">以下选项受<a href="{:url('setting/caiji')}" target="_blank">采集设置</a>影响</p>
|
||||
<div class="form-group">
|
||||
<label>{$Think.lang.set_caiji_num}</label>
|
||||
<input type="number" name="config[num]" class="form-control" placeholder="全局设置:{$gConfig['num']}" />
|
||||
<p class="help-block">该任务每次采集的数据量,不能超过采集设置中的“{$Think.lang.set_caiji_num}”,留空使用全局设置{$tipsSingle}
|
||||
{if $numGtG}<br/>注意:当前数量超过全局设置的数量,实际最大采集数量为:{$gConfig['num']}{/if}
|
||||
</p>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>{$Think.lang.set_caiji_interval}(分钟)</label>
|
||||
<input type="number" name="config[num_interval]" class="form-control" placeholder="全局设置:{$gConfig['num_interval']}" />
|
||||
<p class="help-block">留空使用全局设置,可设为0{$tipsSingle}</p>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>页面抓取间隔(毫秒,1000毫秒=1秒)</label>
|
||||
<input type="number" name="config[num_interval_html]" class="form-control" placeholder="全局设置:{$gConfig['num_interval_html']}" />
|
||||
<p class="help-block">留空使用全局设置,可设为0</p>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>不同任务采集同一网址</label>
|
||||
<div class="input-group">
|
||||
<label class="radio-inline"><input type="radio" name="config[same_url]" value="" checked="checked">
|
||||
全局设置:{$gConfig['same_url']}
|
||||
</label>
|
||||
<label class="radio-inline"><input type="radio" name="config[same_url]" value="y">允许</label>
|
||||
<label class="radio-inline"><input type="radio" name="config[same_url]" value="n">过滤</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>不同任务采集同一标题</label>
|
||||
<div class="input-group">
|
||||
<label class="radio-inline"><input type="radio" name="config[same_title]" value="" checked="checked">
|
||||
全局设置:{$gConfig['same_title']}
|
||||
</label>
|
||||
<label class="radio-inline"><input type="radio" name="config[same_title]" value="y">允许</label>
|
||||
<label class="radio-inline"><input type="radio" name="config[same_title]" value="n">过滤</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>不同任务采集相同内容</label>
|
||||
<div class="input-group">
|
||||
<label class="radio-inline"><input type="radio" name="config[same_content]" value="" checked="checked">
|
||||
全局设置:{$gConfig['same_content']}
|
||||
</label>
|
||||
<label class="radio-inline"><input type="radio" name="config[same_content]" value="y">允许</label>
|
||||
<label class="radio-inline"><input type="radio" name="config[same_content]" value="n">过滤</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>实时发布数据</label>
|
||||
<div class="input-group">
|
||||
<label class="radio-inline"><input type="radio" name="config[real_time]" value="" checked="checked">
|
||||
全局设置:{$gConfig['real_time']}
|
||||
</label>
|
||||
<label class="radio-inline"><input type="radio" name="config[real_time]" value="y">是</label>
|
||||
<label class="radio-inline"><input type="radio" name="config[real_time]" value="n">否</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>使用翻译</label>
|
||||
<div class="input-group">
|
||||
<label class="radio-inline"><input type="radio" name="config[translate]" value="" checked="checked">
|
||||
全局设置:{$gConfig['translate']?'是':'否'}
|
||||
</label>
|
||||
<label class="radio-inline"><input type="radio" name="config[translate]" value="y">是</label>
|
||||
<label class="radio-inline"><input type="radio" name="config[translate]" value="n">否</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="panel-body{$gConfig['proxy']?'':' box-not-enable'}" id="config_proxy" style="border-top:solid 1px #ddd;">
|
||||
<div class="form-group" style="margin-bottom:0;">
|
||||
<label>使用代理</label>
|
||||
<div class="input-group">
|
||||
<label class="radio-inline"><input type="radio" name="config[proxy]" value="" data-global="{$gConfig['proxy']}" checked="checked">
|
||||
全局设置:{$gConfig['proxy']?'是':'否'}
|
||||
</label>
|
||||
<label class="radio-inline"><input type="radio" name="config[proxy]" value="y">是</label>
|
||||
<label class="radio-inline"><input type="radio" name="config[proxy]" value="n">否</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="box-enable-wrapper">
|
||||
<div class="form-group">
|
||||
<label>使用分组IP</label>
|
||||
<select name="config[proxy_group_id]" class="form-control">
|
||||
<option value="">全局设置:{$gConfig['proxy_group_id']}</option>
|
||||
<option value="0">全部</option>
|
||||
{foreach $proxyGroups as $proxyGroup}
|
||||
<option value="{$proxyGroup['id']}">{$proxyGroup['name']}</option>
|
||||
{/foreach}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="panel-body{$gConfig['download_img']?'':' box-not-enable'}" id="config_download_img" style="border-top:solid 1px #ddd;">
|
||||
<div class="form-group" style="margin-bottom:0;">
|
||||
<label>图片本地化</label>
|
||||
<div class="input-group">
|
||||
<label class="radio-inline"><input type="radio" name="config[download_img]" value="" data-global="{$gConfig['download_img']}" checked="checked">
|
||||
全局设置:{$gConfig['download_img']?'是':'否'}
|
||||
</label>
|
||||
<label class="radio-inline"><input type="radio" name="config[download_img]" value="y">是</label>
|
||||
<label class="radio-inline"><input type="radio" name="config[download_img]" value="n">否</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="box-enable-wrapper">
|
||||
<div class="form-group">
|
||||
<label>图片下载间隔(毫秒,1000毫秒=1秒)</label>
|
||||
<input type="number" name="config[num_interval_img]" class="form-control" placeholder="全局设置:{$gConfig['num_interval_img']}" />
|
||||
<p class="help-block">留空使用全局设置,可设为0</p>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>图片保存目录(绝对路径)</label>
|
||||
<input type="text" name="config[img_path]" class="form-control" placeholder="全局设置:{$gConfig['img_path']}">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>图片链接地址(绝对地址)</label>
|
||||
<input type="text" name="config[img_url]" class="form-control" placeholder="全局设置:{$gConfig['img_url']}">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>图片名称</label>
|
||||
<select name="config[img_name]" class="form-control">
|
||||
<option value="">全局设置:{:lang('down_file_name_'.$gConfig['img_name'])}</option>
|
||||
<option value="url">{$Think.lang.down_file_name_url}</option>
|
||||
<option value="time">{$Think.lang.down_file_name_time}</option>
|
||||
<option value="custom">{$Think.lang.down_file_name_custom}</option>
|
||||
</select>
|
||||
<div id="config_img_name_custom" style="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="路径,全局设置:{$gConfig['name_custom_path']}" 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="名称,全局设置:{$gConfig['name_custom_name']}" 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 style="clear:both;height:0;"> </div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>图片加水印</label>
|
||||
<div class="input-group">
|
||||
<label class="radio-inline"><input type="radio" name="config[img_watermark]" value="" data-global="{$gConfig['img_watermark']}" checked="checked">
|
||||
全局设置:{$gConfig['img_watermark']?'是':'否'}
|
||||
</label>
|
||||
<label class="radio-inline"><input type="radio" name="config[img_watermark]" value="y">是</label>
|
||||
<label class="radio-inline"><input type="radio" name="config[img_watermark]" value="n">否</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group" id="config_img_watermark" style="{$gConfig['img_watermark']?'':'display:none;'}">
|
||||
<div class="form-group">
|
||||
<label>水印logo</label>
|
||||
<div class="input-group">
|
||||
<span class="input-group-addon">logo</span>
|
||||
<input type="file" name="img_wm_logo_upload" class="form-control" />
|
||||
<span class="input-group-addon brl_0 brr_0">下边距</span>
|
||||
<input type="number" name="config[img_wm_bottom]" class="form-control" placeholder="全局设置:{$gConfig['img_wm_bottom']}" />
|
||||
<span class="input-group-addon brl_0 brr_0">右边距</span>
|
||||
<input type="number" name="config[img_wm_right]" class="form-control" placeholder="全局设置:{$gConfig['img_wm_right']}" />
|
||||
<span class="input-group-addon brl_0 brr_0">透明度</span>
|
||||
<input type="number" name="config[img_wm_opacity]" class="form-control" placeholder="全局设置:{$gConfig['img_wm_opacity']}" />
|
||||
</div>
|
||||
<p class="help-block">留空使用全局设置</p>
|
||||
<input type="hidden" name="config[img_wm_logo]" class="form-control" />
|
||||
<div id="img_wm_logo_show" data-global="{$gConfig['img_wm_logo']}" style="display:none;">
|
||||
<p class="help-block">默认使用全局设置logo</p>
|
||||
<div>
|
||||
<img src="" style="max-width:300px;border:solid 1px #ccc;" />
|
||||
<a href="javascript:;" class="glyphicon glyphicon-remove" style="display:none;font-size:20px;margin:10px;"></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>使用函数</label>
|
||||
<div class="input-group">
|
||||
<label class="radio-inline"><input type="radio" name="config[img_funcs_open]" value="" checked="checked">
|
||||
全局设置:{$gConfig['img_funcs']?('存在'.count($gConfig['img_funcs']).'个函数'):'无函数'}
|
||||
</label>
|
||||
<label class="radio-inline"><input type="radio" name="config[img_funcs_open]" value="y">自定义</label>
|
||||
<label class="radio-inline"><input type="radio" name="config[img_funcs_open]" value="n">不使用</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group" id="config_img_funcs_open">
|
||||
<label>添加函数</label>
|
||||
<a href="javascript:;" class="glyphicon glyphicon-plus" id="add_config_img_func" title="添加"></a>
|
||||
<div class="panel-group ui-sortable" id="config_img_funcs" style="margin-bottom:0;">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="panel-body{$gConfig['download_file']?'':' box-not-enable'}" id="config_download_file" style="border-top:solid 1px #ddd;">
|
||||
<div class="form-group" style="margin-bottom:0;">
|
||||
<label>文件本地化</label>
|
||||
<div class="input-group">
|
||||
<label class="radio-inline"><input type="radio" name="config[download_file]" value="" data-global="{$gConfig['download_file']}" checked="checked">
|
||||
全局设置:{$gConfig['download_file']?'是':'否'}
|
||||
</label>
|
||||
<label class="radio-inline"><input type="radio" name="config[download_file]" value="y">是</label>
|
||||
<label class="radio-inline"><input type="radio" name="config[download_file]" value="n">否</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="box-enable-wrapper">
|
||||
<div class="form-group">
|
||||
<label>文件下载间隔(毫秒,1000毫秒=1秒)</label>
|
||||
<input type="number" name="config[file_interval]" class="form-control" placeholder="全局设置:{$gConfig['file_interval']}" />
|
||||
<p class="help-block">留空使用全局设置,可设为0</p>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>文件保存目录(绝对路径)</label>
|
||||
<input type="text" name="config[file_path]" class="form-control" placeholder="全局设置:{$gConfig['file_path']}">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>文件链接地址(绝对地址)</label>
|
||||
<input type="text" name="config[file_url]" class="form-control" placeholder="全局设置:{$gConfig['file_url']}">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>文件名称</label>
|
||||
<select name="config[file_name]" class="form-control">
|
||||
<option value="">全局设置:{:lang('down_file_name_'.$gConfig['file_name'])}</option>
|
||||
<option value="url">{$Think.lang.down_file_name_url}</option>
|
||||
<option value="time">{$Think.lang.down_file_name_time}</option>
|
||||
<option value="custom">{$Think.lang.down_file_name_custom}</option>
|
||||
</select>
|
||||
<div id="config_file_name_custom" style="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[file_custom_path]" class="form-control" placeholder="路径,全局设置:{$gConfig['file_custom_path']}" autocomplete="off" />
|
||||
<div class="input-group-addon" style="border-left:0;border-right:0;font-weight:bold;">/</div>
|
||||
</div>
|
||||
<div class="help-block file-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 file-custom-path-fields">
|
||||
<li><a href="javascript:;">没有字段,请先配置采集器设置!</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
用/分隔子目录
|
||||
</div>
|
||||
</div>
|
||||
<div style="width:50%;float:left">
|
||||
<input type="text" name="config[file_custom_name]" class="form-control" placeholder="名称,全局设置:{$gConfig['file_custom_name']}" autocomplete="off" />
|
||||
<div class="help-block file-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 file-custom-name-fields">
|
||||
<li><a href="javascript:;">没有字段,请先配置采集器设置!</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div style="clear:both;height:0;"> </div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>使用函数</label>
|
||||
<div class="input-group">
|
||||
<label class="radio-inline"><input type="radio" name="config[file_funcs_open]" value="" checked="checked">
|
||||
全局设置:{$gConfig['file_funcs']?('存在'.count($gConfig['file_funcs']).'个函数'):'无函数'}
|
||||
</label>
|
||||
<label class="radio-inline"><input type="radio" name="config[file_funcs_open]" value="y">自定义</label>
|
||||
<label class="radio-inline"><input type="radio" name="config[file_funcs_open]" value="n">不使用</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group" id="config_file_funcs_open">
|
||||
<label>添加函数</label>
|
||||
<a href="javascript:;" class="glyphicon glyphicon-plus" id="add_config_file_func" title="添加"></a>
|
||||
<div class="panel-group ui-sortable" id="config_file_funcs" style="margin-bottom:0;">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<button type="submit" class="btn btn-primary btn-block">{$Think.lang.save}</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
{include file="setting:download_img_func" func_tpl_id="config_img_tpl_func" func_list_id="config_img_funcs" /}
|
||||
{include file="setting:download_file_func" func_tpl_id="config_file_tpl_func" func_list_id="config_file_funcs" /}
|
||||
|
||||
{php}$nTaskData=is_array($taskData)?json_encode($taskData):'null';$nFieldList=is_array($fieldList)?json_encode($fieldList):'null';{/php}
|
||||
<script src="__PUBLIC__/static/js/admin/task.js?{$Think.config.html_v}"></script>
|
||||
<script type="text/javascript">
|
||||
taskOpClass.task_load({$nTaskData},{$nFieldList});
|
||||
</script>
|
|
@ -2,9 +2,9 @@
|
|||
<div class="steps-bar">
|
||||
<div class="step current">
|
||||
<div class="each">
|
||||
<a href="{:url('task/save?id='.$tplTaskId)}" class="round">1</a>
|
||||
<a href="{:url('task/set?id='.$tplTaskId)}" class="round">1</a>
|
||||
</div>
|
||||
<div class="info"><a href="{:url('task/save?id='.$tplTaskId)}">{$Think.lang.task_set_task}</a></div>
|
||||
<div class="info"><a href="{:url('task/set?id='.$tplTaskId)}">{$Think.lang.task_set_task}</a></div>
|
||||
</div>
|
||||
<div class="step{$tplCurCtl['Collector']}{$tplCurCtl['Release']}">
|
||||
<div class="each">
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
*/
|
||||
|
||||
|
||||
define('SKYCAIJI_VERSION', '2.6.1');
|
||||
define('SKYCAIJI_VERSION', '2.6.2');
|
||||
\think\Loader::addNamespace('plugin', realpath(SKYCAIJI_PATH.'plugin'));
|
||||
\think\Loader::addNamespace('util',realpath(APP_PATH.'extend/util'));
|
||||
|
||||
|
@ -239,8 +239,7 @@ function get_html($url,$headers=array(),$options=array(),$fromEncode='auto',$pos
|
|||
$headers=$curlHeaders;
|
||||
unset($curlHeaders);
|
||||
|
||||
if(!preg_match('/^\w+\:\/\//', $url)){
|
||||
|
||||
if(!\util\Funcs::is_right_url($url)){
|
||||
$url='http://'.$url;
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ class CommonHandle extends \think\exception\Handle {
|
|||
{
|
||||
if(\util\Param::is_collector_collecting()&&IS_CLI){
|
||||
|
||||
\util\Tools::collect_output(strip_tags($e->getMessage()));
|
||||
$this->_collect_output($e);
|
||||
}else{
|
||||
parent::renderForConsole($output,$e);
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ class CommonHandle extends \think\exception\Handle {
|
|||
protected function renderHttpException(\think\exception\HttpException $e){
|
||||
if(\util\Param::is_collector_collecting()){
|
||||
|
||||
\util\Tools::collect_output(strip_tags($e->getMessage()));
|
||||
$this->_collect_output($e);
|
||||
}else{
|
||||
return parent::renderHttpException($e);
|
||||
}
|
||||
|
@ -34,10 +34,17 @@ class CommonHandle extends \think\exception\Handle {
|
|||
protected function convertExceptionToResponse(\Exception $exception){
|
||||
if(\util\Param::is_collector_collecting()){
|
||||
|
||||
\util\Tools::collect_output(strip_tags($exception->getMessage()));
|
||||
$this->_collect_output($e);
|
||||
}else{
|
||||
return parent::convertExceptionToResponse($exception);
|
||||
}
|
||||
}
|
||||
private function _collect_output($exception){
|
||||
$msg=$exception?strip_tags($exception->getMessage()):'';
|
||||
if(strpos($msg,'[exception_exit_collect]')===false){
|
||||
|
||||
\util\Tools::collect_output($msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -158,7 +158,7 @@ return [
|
|||
|
||||
'log' => [
|
||||
// 日志记录方式,内置 file socket 支持扩展
|
||||
'type' => '\util\Log',//使用自定义的日志驱动
|
||||
'type' => 'File',
|
||||
// 日志保存目录
|
||||
'path' => LOG_PATH,
|
||||
// 日志记录级别
|
||||
|
@ -257,14 +257,30 @@ return [
|
|||
'strtolower'=>'全部小写',
|
||||
'strtoupper'=>'全部大写',
|
||||
'ucfirst'=>'首字母大写',
|
||||
'ucwords'=>'每个单词首字母大写',
|
||||
'base64_encode'=>'编码',
|
||||
'md5'=>'加密',
|
||||
'ucwords'=>'每个单词首字母大写',
|
||||
'base64_encode'=>'base64加密',
|
||||
'base64_decode'=>'base64解密',
|
||||
'json_encode'=>'json编码',
|
||||
'json_decode'=>'json解码',
|
||||
'md5'=>'md5加密',
|
||||
'sha1'=>'sha1加密',
|
||||
'hash'=>'hash加密',
|
||||
'crypt'=>'crypt加密',
|
||||
'htmlspecialchars'=>'预定义的字符转换为HTML实体',
|
||||
'htmlspecialchars_decode'=>'把预定义的HTML实体转换为字符',
|
||||
'htmlentities'=>'把字符转换为HTML实体',
|
||||
'html_entity_decode'=>'把HTML实体转换为字符',
|
||||
'urlencode'=>'编码URL字符串',
|
||||
'urldecode'=>'解码URL字符串',
|
||||
'rawurlencode'=>'编码URL字符串(RFC3986)',
|
||||
'rawurldecode'=>'解码URL字符串(RFC3986)',
|
||||
),//数据处理允许的函数
|
||||
|
||||
'allow_process_if'=>array(
|
||||
'empty'=>'是空值',
|
||||
'is_numeric'=>'是数字',
|
||||
'is_int'=>'是整数',
|
||||
'is_float'=>'是浮点数',
|
||||
),//数据处理>条件判断允许的函数
|
||||
/*******************************************************************************/
|
||||
];
|
||||
|
|
|
@ -61,14 +61,20 @@ class ChromeSocket{
|
|||
}
|
||||
|
||||
public function openHost(){
|
||||
if(!in_array(strtolower($this->host),array('localhost','127.0.0.1','0.0.0.0'))){
|
||||
if($this->serverIsLocal()){
|
||||
|
||||
return;
|
||||
$return=self::execHeadless($this->filename,$this->port,$this->options,false);
|
||||
if(!empty($return['error'])){
|
||||
throw new \Exception($return['error']);
|
||||
}
|
||||
}
|
||||
$return=self::execHeadless($this->filename,$this->port,$this->options,false);
|
||||
if(!empty($return['error'])){
|
||||
throw new \Exception($return['error']);
|
||||
}
|
||||
|
||||
public function serverIsLocal(){
|
||||
if($this->options['server']=='remote'){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function execHeadless($filename,$port,$options,$isTest){
|
||||
|
@ -198,7 +204,7 @@ class ChromeSocket{
|
|||
$this->send('Fetch.continueRequest',$fParams);
|
||||
}
|
||||
if($returnInfo){
|
||||
if($dataParams['request']&&$dataParams['request']['url']==$locUrl){
|
||||
if($dataParams['request']&&$locUrl==($dataParams['request']['url'].($dataParams['request']['urlFragment']?:''))){
|
||||
|
||||
|
||||
$htmlInfo['code']=intval($dataParams['responseStatusCode']);
|
||||
|
@ -269,6 +275,15 @@ class ChromeSocket{
|
|||
|
||||
$url='http://'.$url;
|
||||
}
|
||||
|
||||
if(stripos($url,'&')!==false){
|
||||
|
||||
if(!preg_match('/\&[^\;\&]+?\=/', $url)){
|
||||
|
||||
$url=str_ireplace('&', '&', $url);
|
||||
}
|
||||
}
|
||||
|
||||
if(!is_array($headers)){
|
||||
$headers=array();
|
||||
}
|
||||
|
@ -664,11 +679,14 @@ class ChromeSocket{
|
|||
}
|
||||
|
||||
public function closeBrowser(){
|
||||
$verData=$this->getVersion();
|
||||
if(!empty($verData)&&!empty($verData['webSocketDebuggerUrl'])){
|
||||
if($this->serverIsLocal()){
|
||||
|
||||
$this->websocket($verData['webSocketDebuggerUrl']);
|
||||
$this->send('Browser.close');
|
||||
$verData=$this->getVersion();
|
||||
if(!empty($verData)&&!empty($verData['webSocketDebuggerUrl'])){
|
||||
|
||||
$this->websocket($verData['webSocketDebuggerUrl']);
|
||||
$this->send('Browser.close');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,6 +48,14 @@ class Curl{
|
|||
$options=$rOptions;
|
||||
$postData=$rPostData;
|
||||
|
||||
if(stripos($url,'&')!==false){
|
||||
|
||||
if(!preg_match('/\&[^\;\&]+?\=/', $url)){
|
||||
|
||||
$url=str_ireplace('&', '&', $url);
|
||||
}
|
||||
}
|
||||
|
||||
$instance=self::init();
|
||||
|
||||
$isPost=false;
|
||||
|
@ -76,6 +84,8 @@ class Curl{
|
|||
curl_setopt ( $ch, CURLOPT_FOLLOWLOCATION, 1 );
|
||||
curl_setopt ( $ch, CURLOPT_HEADER, 1 );
|
||||
curl_setopt ( $ch, CURLOPT_AUTOREFERER, 1 );
|
||||
curl_setopt ( $ch, CURLOPT_ENCODING, '' );
|
||||
|
||||
if($options['nobody']){
|
||||
|
||||
curl_setopt($ch, CURLOPT_NOBODY, true);
|
||||
|
|
|
@ -0,0 +1,61 @@
|
|||
<?php
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| SkyCaiji (蓝天采集器)
|
||||
|--------------------------------------------------------------------------
|
||||
| Copyright (c) 2018 https://www.skycaiji.com All rights reserved.
|
||||
|--------------------------------------------------------------------------
|
||||
| 使用协议 https://www.skycaiji.com/licenses
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
namespace util;
|
||||
|
||||
class EncryptDecrypt{
|
||||
protected $version='';
|
||||
protected $skycaiji='';
|
||||
public function __construct($version=null,$skycaiji=null){
|
||||
$this->version=$version?$version:'1';
|
||||
$this->skycaiji=$skycaiji?$skycaiji:SKYCAIJI_VERSION;
|
||||
}
|
||||
protected function checkError($isEncrypt,$method){
|
||||
$name=$isEncrypt?'加密':'解密';
|
||||
if(!extension_loaded('openssl')){
|
||||
throw new \Exception($name.'需要php开启openssl扩展');
|
||||
}
|
||||
if(!method_exists($this,$method)){
|
||||
throw new \Exception($name.'失败!请使用 v'.$this->skycaiji.' 及以上版本的采集器');
|
||||
}
|
||||
}
|
||||
|
||||
public function encrypt($params){
|
||||
$method='encrypt_v'.$this->version;
|
||||
$this->checkError(true, $method);
|
||||
if(!is_array($params)){
|
||||
$params=array();
|
||||
}
|
||||
$data=$this->$method($params);
|
||||
return array(
|
||||
'encrypt_version'=>$this->version,
|
||||
'skycaiji_version'=>$this->skycaiji,
|
||||
'data'=>$data
|
||||
);
|
||||
}
|
||||
protected function encrypt_v1($params){
|
||||
return openssl_encrypt($params['data'], 'AES-256-CBC', $params['pwd'],0,'skycaiji');
|
||||
}
|
||||
|
||||
public function decrypt($params){
|
||||
$method='decrypt_v'.$this->version;
|
||||
$this->checkError(false, $method);
|
||||
if(!is_array($params)){
|
||||
$params=array();
|
||||
}
|
||||
return $this->$method($params);
|
||||
}
|
||||
protected function decrypt_v1($params){
|
||||
return openssl_decrypt($params['data'], 'AES-256-CBC', $params['pwd'],0,'skycaiji');
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
|
@ -481,6 +481,69 @@ class Funcs{
|
|||
}
|
||||
return $url;
|
||||
}
|
||||
|
||||
public static function txt_auto_url_encode($txt,$charset){
|
||||
if(!preg_match('/\%[a-z0-9A-Z]{2}/',$txt)){
|
||||
|
||||
$txt=\util\Funcs::convert_charset($txt,'utf-8',$charset);
|
||||
$txt=rawurlencode($txt);
|
||||
}else{
|
||||
|
||||
$txt=preg_replace_callback('/[^\w\-\_\.\~\+]+/',function($match){
|
||||
$match=$match[0];
|
||||
$match=\util\Funcs::convert_charset($match,'utf-8',$charset);
|
||||
$match=rawurlencode($match);
|
||||
return $match;
|
||||
},$txt);
|
||||
}
|
||||
return $txt;
|
||||
}
|
||||
|
||||
public static function is_right_url($url){
|
||||
if($url&&preg_match('/^\w+\:\/\//', $url)){
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static function get_cookies_from_header($header,$convert2str=false){
|
||||
$cookies=array();
|
||||
if($header){
|
||||
if(preg_match_all('/^\s*cookie\s*\:([^\r\n]+);/im', $header, $mcookies)){
|
||||
|
||||
foreach ($mcookies[1] as $mcv){
|
||||
if(preg_match_all('/([^\;]+?)\=([^\;]*)/',$mcv,$mcookie)){
|
||||
foreach ($mcookie[1] as $k=>$v){
|
||||
$v=trim($v);
|
||||
if($v){
|
||||
$cookies[$v]=$mcookie[2][$k];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(preg_match_all('/\bset\-cookie\s*\:([^\;]+?)\=([^\;]*)/i', $header, $mcookies)){
|
||||
|
||||
foreach ($mcookies[1] as $k=>$v){
|
||||
$v=trim($v);
|
||||
if($v){
|
||||
$cookies[$v]=$mcookies[2][$k];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if($convert2str&&$cookies){
|
||||
|
||||
$cookie=array();
|
||||
foreach ($cookies as $k=>$v){
|
||||
$cookie[]=$k.'='.$v;
|
||||
}
|
||||
$cookie=implode(';', $cookie);
|
||||
$cookies=$cookie;
|
||||
}
|
||||
return $cookies;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
|
@ -38,6 +38,14 @@ class Param{
|
|||
return self::defined('COLLECTOR_COLLECTING');
|
||||
}
|
||||
|
||||
|
||||
public static function set_collector_single(){
|
||||
self::set_define('COLLECTOR_SINGLE');
|
||||
}
|
||||
public static function is_collector_single(){
|
||||
return self::defined('COLLECTOR_SINGLE');
|
||||
}
|
||||
|
||||
public static function set_task_api_response(){
|
||||
self::set_define('TASK_API_RESPONSE_JSON');
|
||||
}
|
||||
|
|
|
@ -292,7 +292,11 @@ class SwooleSocket{
|
|||
public function wsShutdown($ws){
|
||||
$ws->shutdown();
|
||||
$this->killProcess(getmypid(),SIGTERM,10);
|
||||
exit();
|
||||
$this->wsExit();
|
||||
}
|
||||
|
||||
public function wsExit(){
|
||||
throw new \Exception('[exception_exit_collect]');
|
||||
}
|
||||
|
||||
protected $wsTimer;
|
||||
|
@ -326,7 +330,7 @@ class SwooleSocket{
|
|||
$data=json_decode(base64_decode($data),true);
|
||||
$data=$this->commonWsOn($data,$ws,true);
|
||||
$response->end();
|
||||
exit();
|
||||
$this->wsExit();
|
||||
}
|
||||
protected function commonWsOn($data,$ws,$isRequest=false){
|
||||
init_array($data);
|
||||
|
@ -357,7 +361,7 @@ class SwooleSocket{
|
|||
|
||||
$this->wsShutdown($ws);
|
||||
}else{
|
||||
$ws->reboot();
|
||||
$ws->reload();
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
@ -390,7 +394,7 @@ class SwooleSocket{
|
|||
|
||||
|
||||
|
||||
exit();
|
||||
$this->wsExit();
|
||||
}
|
||||
protected function ws_m_auto_backstage($data,$ws){
|
||||
$rootUrl=\think\Config::get('root_website').'/index.php?s=';
|
||||
|
@ -429,7 +433,7 @@ class SwooleSocket{
|
|||
|
||||
|
||||
|
||||
exit();
|
||||
$this->wsExit();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -133,34 +133,50 @@ class Tools{
|
|||
* @return boolean
|
||||
*/
|
||||
public static function send_mail($emailConfig,$to, $name, $subject = '', $body = '', $attachment = null){
|
||||
set_time_limit(60);
|
||||
|
||||
$mail = new \PHPMailer();
|
||||
|
||||
|
||||
$mail->isSMTP();
|
||||
$mail->Host = $emailConfig['smtp'];
|
||||
$mail->SMTPAuth = true;
|
||||
$mail->Username = $emailConfig['email'];
|
||||
$mail->Password = $emailConfig['pwd'];
|
||||
$mail->SMTPSecure = empty($emailConfig['type'])?'tls':$emailConfig['type'];
|
||||
$mail->Port = $emailConfig['port'];
|
||||
|
||||
$mail->setFrom($emailConfig['email'], $emailConfig['sender']);
|
||||
$mail->addAddress($to, $name);
|
||||
|
||||
$mail->isHTML(true);
|
||||
|
||||
$mail->Subject = $subject;
|
||||
$mail->Body = $body;
|
||||
$mail->AltBody = '';
|
||||
|
||||
if(is_array($attachment)){
|
||||
foreach ($attachment as $file){
|
||||
is_file($file) && $mail->AddAttachment($file);
|
||||
$error='';
|
||||
init_array($emailConfig);
|
||||
foreach (array('email','smtp','port') as $k){
|
||||
if(empty($emailConfig[$k])){
|
||||
$error=lang('set_email_'.$k).'不能为空';
|
||||
}
|
||||
}
|
||||
return $mail->Send() ? true : $mail->ErrorInfo;
|
||||
if(empty($error)){
|
||||
try{
|
||||
$mail = new \PHPMailer();
|
||||
|
||||
|
||||
$mail->isSMTP();
|
||||
$mail->CharSet='UTF-8';
|
||||
$mail->Host = $emailConfig['smtp'];
|
||||
$mail->SMTPAuth = true;
|
||||
$mail->Username = $emailConfig['email'];
|
||||
$mail->Password = $emailConfig['pwd'];
|
||||
$mail->SMTPSecure = empty($emailConfig['type'])?'tls':$emailConfig['type'];
|
||||
$mail->Port = $emailConfig['port'];
|
||||
|
||||
$mail->setFrom($emailConfig['email'], $emailConfig['sender']);
|
||||
$mail->addAddress($to, $name);
|
||||
|
||||
$mail->isHTML(true);
|
||||
|
||||
$mail->Subject = $subject;
|
||||
$mail->Body = $body;
|
||||
$mail->AltBody = '';
|
||||
|
||||
if(is_array($attachment)){
|
||||
foreach ($attachment as $file){
|
||||
is_file($file) && $mail->AddAttachment($file);
|
||||
}
|
||||
}
|
||||
}catch(\Exception $ex){
|
||||
$error=$ex->getMessage();
|
||||
}
|
||||
}
|
||||
if(empty($error)){
|
||||
return $mail->Send() ? true : $mail->ErrorInfo;
|
||||
}else{
|
||||
return $error;
|
||||
}
|
||||
}
|
||||
|
||||
public static function cp_page_tpl_vars($pageType){
|
||||
|
@ -752,5 +768,41 @@ class Tools{
|
|||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
public static function clear_src_urls($urls){
|
||||
if(is_array($urls)){
|
||||
foreach ($urls as $k=>$v){
|
||||
$v=trim($v);
|
||||
$v=trim($v,'\'" ');
|
||||
$v=trim($v);
|
||||
$urls[$k]=$v;
|
||||
}
|
||||
}else{
|
||||
$urls=trim($urls);
|
||||
$urls=trim($urls,'\'" ');
|
||||
$urls=trim($urls);
|
||||
}
|
||||
return $urls;
|
||||
}
|
||||
|
||||
public static function browser_export_scj($name,$txt){
|
||||
set_time_limit(600);
|
||||
ob_start();
|
||||
header("Expires: 0" );
|
||||
header("Pragma:public" );
|
||||
header("Cache-Control:must-revalidate,post-check=0,pre-check=0" );
|
||||
header("Cache-Control:public");
|
||||
header("Content-Type:application/octet-stream" );
|
||||
|
||||
header("Content-transfer-encoding: binary");
|
||||
header("Content-Length: " .mb_strlen($txt));
|
||||
if (preg_match("/MSIE/i", $_SERVER["HTTP_USER_AGENT"])) {
|
||||
header('Content-Disposition: attachment; filename="'.urlencode($name).'.txt"');
|
||||
}else{
|
||||
header('Content-Disposition: attachment; filename="'.$name.'.txt"');
|
||||
}
|
||||
echo $txt;
|
||||
ob_end_flush();
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -0,0 +1,50 @@
|
|||
<?php
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| SkyCaiji (蓝天采集器)
|
||||
|--------------------------------------------------------------------------
|
||||
| Copyright (c) 2018 https://www.skycaiji.com All rights reserved.
|
||||
|--------------------------------------------------------------------------
|
||||
| 使用协议 https://www.skycaiji.com/licenses
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
namespace util;
|
||||
class Tp{
|
||||
|
||||
public static function filter_log_msg($msg){
|
||||
static $passList=array(
|
||||
'未定义','Undefined array key','Undefined variable','Undefined index',
|
||||
'A session had already been started','DOMDocument::loadHTML',
|
||||
'MySQL server has gone away',"Error reading result set's header",
|
||||
'The /e modifier is deprecated',
|
||||
'Invalid argument supplied for foreach',
|
||||
'CURLOPT_FOLLOWLOCATION',
|
||||
'open_basedir restriction in effect',
|
||||
']unlink(',']rmdir(',
|
||||
'[exception_exit_collect]',
|
||||
);
|
||||
static $passListLower=null;
|
||||
if(!isset($passListLower)){
|
||||
$passListLower=$passList;
|
||||
if(IS_CLI){
|
||||
$passListLower[]='session_start()';
|
||||
}
|
||||
$passListLower=array_map('strtolower', $passListLower);
|
||||
}
|
||||
if($msg){
|
||||
$msg=strtolower($msg);
|
||||
foreach ($passListLower as $passStr){
|
||||
|
||||
if($passStr&&strpos($msg, $passStr)!==false){
|
||||
|
||||
$msg='';
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $msg?false:true;
|
||||
}
|
||||
}
|
||||
?>
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -0,0 +1 @@
|
|||
<?php echo strip_tags($message);?>
|
|
@ -1,5 +1,6 @@
|
|||
<?php
|
||||
return [
|
||||
'api_task/:id/:apiurl'=>['admin/api/task',[],['id'=>'\d+','apiurl'=>'[^\/]+']],
|
||||
'api_task/:id/[:key]'=>['admin/api/task',[],['id'=>'\d+','key'=>'[^\/]*']],
|
||||
'api_single/:id/[:key]'=>['admin/api/single',[],['id'=>'\d+','key'=>'[^\/]*']],
|
||||
'api_caiji'=>'admin/api/caiji',
|
||||
];
|
||||
|
|
|
@ -33,32 +33,32 @@ class Log
|
|||
const NOTICE = 'notice';
|
||||
const ALERT = 'alert';
|
||||
const DEBUG = 'debug';
|
||||
|
||||
|
||||
/**
|
||||
* @var array 日志信息
|
||||
*/
|
||||
protected static $log = [];
|
||||
|
||||
|
||||
/**
|
||||
* @var array 配置参数
|
||||
*/
|
||||
protected static $config = [];
|
||||
|
||||
|
||||
/**
|
||||
* @var array 日志类型
|
||||
*/
|
||||
protected static $type = ['log', 'error', 'info', 'sql', 'notice', 'alert', 'debug'];
|
||||
|
||||
|
||||
/**
|
||||
* @var log\driver\File|log\driver\Test|log\driver\Socket 日志写入驱动
|
||||
*/
|
||||
protected static $driver;
|
||||
|
||||
|
||||
/**
|
||||
* @var string 当前日志授权 key
|
||||
*/
|
||||
protected static $key;
|
||||
|
||||
|
||||
/**
|
||||
* 日志初始化
|
||||
* @access public
|
||||
|
@ -69,20 +69,20 @@ class Log
|
|||
{
|
||||
$type = isset($config['type']) ? $config['type'] : 'File';
|
||||
$class = false !== strpos($type, '\\') ? $type : '\\think\\log\\driver\\' . ucwords($type);
|
||||
|
||||
|
||||
self::$config = $config;
|
||||
unset($config['type']);
|
||||
|
||||
|
||||
if (class_exists($class)) {
|
||||
self::$driver = new $class($config);
|
||||
} else {
|
||||
throw new ClassNotFoundException('class not exists:' . $class, $class);
|
||||
}
|
||||
|
||||
|
||||
// 记录初始化信息
|
||||
App::$debug && Log::record('[ LOG ] INIT ' . $type, 'info');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取日志信息
|
||||
* @access public
|
||||
|
@ -93,7 +93,7 @@ class Log
|
|||
{
|
||||
return $type ? self::$log[$type] : self::$log;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 记录调试信息
|
||||
* @access public
|
||||
|
@ -103,12 +103,15 @@ class Log
|
|||
*/
|
||||
public static function record($msg, $type = 'log')
|
||||
{
|
||||
self::$log[$type][] = $msg;
|
||||
|
||||
// 命令行下面日志写入改进
|
||||
IS_CLI && self::save();
|
||||
//[修改]过滤信息
|
||||
if(!\util\Tp::filter_log_msg($msg)){
|
||||
self::$log[$type][] = $msg;
|
||||
|
||||
// 命令行下面日志写入改进
|
||||
IS_CLI && self::save();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 清空日志信息
|
||||
* @access public
|
||||
|
@ -118,7 +121,7 @@ class Log
|
|||
{
|
||||
self::$log = [];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 设置当前日志记录的授权 key
|
||||
* @access public
|
||||
|
@ -129,7 +132,7 @@ class Log
|
|||
{
|
||||
self::$key = $key;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 检查日志写入权限
|
||||
* @access public
|
||||
|
@ -140,7 +143,7 @@ class Log
|
|||
{
|
||||
return !self::$key || empty($config['allow_key']) || in_array(self::$key, $config['allow_key']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 保存调试信息
|
||||
* @access public
|
||||
|
@ -152,14 +155,14 @@ class Log
|
|||
if (empty(self::$log)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
is_null(self::$driver) && self::init(Config::get('log'));
|
||||
|
||||
|
||||
// 检测日志写入权限
|
||||
if (!self::check(self::$config)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if (empty(self::$config['level'])) {
|
||||
// 获取全部日志
|
||||
$log = self::$log;
|
||||
|
@ -175,16 +178,16 @@ class Log
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($result = self::$driver->save($log, true)) {
|
||||
self::$log = [];
|
||||
}
|
||||
|
||||
|
||||
Hook::listen('log_write_done', $log);
|
||||
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 实时写入日志信息 并支持行为
|
||||
* @access public
|
||||
|
@ -196,28 +199,28 @@ class Log
|
|||
public static function write($msg, $type = 'log', $force = false)
|
||||
{
|
||||
$log = self::$log;
|
||||
|
||||
|
||||
// 如果不是强制写入,而且信息类型不在可记录的类别中则直接返回 false 不做记录
|
||||
if (true !== $force && !empty(self::$config['level']) && !in_array($type, self::$config['level'])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// 封装日志信息
|
||||
$log[$type][] = $msg;
|
||||
|
||||
|
||||
// 监听 log_write
|
||||
Hook::listen('log_write', $log);
|
||||
|
||||
|
||||
is_null(self::$driver) && self::init(Config::get('log'));
|
||||
|
||||
|
||||
// 写入日志
|
||||
if ($result = self::$driver->save($log, false)) {
|
||||
self::$log = [];
|
||||
}
|
||||
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 静态方法调用
|
||||
* @access public
|
||||
|
@ -229,9 +232,9 @@ class Log
|
|||
{
|
||||
if (in_array($method, self::$type)) {
|
||||
array_push($args, $method);
|
||||
|
||||
|
||||
call_user_func_array('\\think\\Log::record', $args);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue