Browse Source

2.5.3

master
skycaiji 2 years ago
parent
commit
c2d86c6604
  1. 1
      LICENSE
  2. 6
      README.md
  3. 5
      public/static/css/admin.css
  4. 2
      public/static/js/admin.js
  5. 2
      public/static/js/admin/collected.js
  6. 2
      public/static/js/admin/collector.js
  7. 1
      public/static/js/admin/index.js
  8. 14
      public/static/js/admin/release.js
  9. 7
      public/static/js/admin/tasks.js
  10. 2
      public/static/js/langs/zh-cn.js
  11. 42
      vendor/skycaiji/app/admin/controller/Backstage.php
  12. 27
      vendor/skycaiji/app/admin/controller/Collected.php
  13. 2
      vendor/skycaiji/app/admin/controller/Index.php
  14. 71
      vendor/skycaiji/app/admin/controller/Release.php
  15. 52
      vendor/skycaiji/app/admin/controller/Task.php
  16. 9
      vendor/skycaiji/app/admin/event/CpatternColl.php
  17. 178
      vendor/skycaiji/app/admin/event/Rtoapi.php
  18. 3
      vendor/skycaiji/app/admin/lang/zh-cn.php
  19. 4
      vendor/skycaiji/app/admin/model/Collector.php
  20. 31
      vendor/skycaiji/app/admin/model/Release.php
  21. 6
      vendor/skycaiji/app/admin/view/backstage/index.html
  22. 33
      vendor/skycaiji/app/admin/view/collected/list.html
  23. 5
      vendor/skycaiji/app/admin/view/cpattern/process_module.html
  24. 4
      vendor/skycaiji/app/admin/view/proxy/add.html
  25. 4
      vendor/skycaiji/app/admin/view/proxy/groups.html
  26. 396
      vendor/skycaiji/app/admin/view/release/set.html
  27. 66
      vendor/skycaiji/app/admin/view/release/toapiApp.html
  28. 4
      vendor/skycaiji/app/admin/view/setting/page_render.html
  29. 5
      vendor/skycaiji/app/admin/view/task/list_folder.html
  30. 12
      vendor/skycaiji/app/admin/view/task/list_footer.html
  31. 18
      vendor/skycaiji/app/admin/view/task/list_list.html
  32. 4
      vendor/skycaiji/app/common.php
  33. 43
      vendor/skycaiji/app/extend/util/ChromeSocket.php
  34. 6
      vendor/skycaiji/app/extend/util/Funcs.php
  35. 15
      vendor/skycaiji/app/extend/util/Param.php
  36. 2
      vendor/skycaiji/app/install/data/check_db
  37. 2
      vendor/skycaiji/app/install/data/check_file

1
LICENSE

@ -0,0 +1 @@
使用协议:https://www.skycaiji.com/licenses

6
readme.txt → README.md

@ -1,4 +1,6 @@
将本压缩包上传至您的服务器,如果根目录有站点建议放在子目录里,解压后打开浏览器输入您的服务器域名或ip地址(存放在子目录则加上子目录的名称)进入安装界面。
使用手册:https://www.skycaiji.com/manual
安装协议:https://www.skycaiji.com/licenses
入门手册:[https://www.skycaiji.com/manual](https://www.skycaiji.com/manual)
使用协议:[https://www.skycaiji.com/licenses](https://www.skycaiji.com/licenses)

5
public/static/css/admin.css

@ -64,7 +64,7 @@ div.in-line-mg{display:inline;margin-right:5px;}
.table-responsive .table:last-child{margin-bottom:0;}
.table-responsive .table input.form-control{min-width:150px;}
.table-responsive .table textarea.form-control{min-width:150px;}
.table-responsive .table select.form-control{min-width:70px;}
.table-responsive .table select.form-control{min-width:90px;}
.icon-info-tips{font-size:12px;cursor:pointer;color:#bbb;}
.icon-info-tips:hover{color:#3c8dbc;}
@ -435,6 +435,7 @@ table.table thead .sorting_desc:after {
}
/**/
#cms_bind em{color:red;}
#toapi_app_params em{color:red;}
/*my store*/
.nav-tabs-color li.active{border-top-color:#3c8dbc!important;}
@ -623,4 +624,6 @@ footer.footer-end{display:none;}
.c-p-url-web-form td:first-child,.c-p-url-web-header td:first-child{width:auto;}
.p-m-api-table td:first-child,.p-m-api-header-table td:first-child{width:auto;}
.toapi-param-table td:first-child,.toapi-header-table td:first-child{width:auto;}
.list-footer .form-control{width:100%!important;}
}

2
public/static/js/admin.js

@ -41,7 +41,7 @@ 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)},complete:function(xhr,status){setFuncVal()}})}}}
function tipsPluginFunc(module){var tips='';if(module=='process'){tips='<p>如需扩展系统函数,请在根目录/data/config.php中添加配置:</p>'+"<p>'EXTEND_PROCESS_FUNC'=&gt;array('PHP函数名'=&gt;'描述')</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'=&gt;array('PHP函数名'=&gt;'描述')</p>"+'<p>如需扩展插件函数,可创建<a href="'+ulink('develop/func?module=processIf')+'" target="_blank">函数插件</a></p>'}else if(module=='downloadImg'||module=='contentSign'){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字符串,根节点名称使用###表示,子节点名称使用.分隔,例如:a.b.c</p>';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)}}
closeFuncs.push(function(){if(!collectorEchoMsg.close_non_stop){collectorEchoMsg.stop_all()}});options.close_func=closeFuncs;windowIframe(title,'',options);$('#myModal #myModalIframe').hide();$('#myModal #win_cem_interval_btn').bind('click',function(){collectorEchoMsg.set_interval($('#win_cem_interval').val())});var runUrl=ulink(uri,uriVals);ajaxOpen({type:'get',url:runUrl,dataType:'json',async:!0,success:function(data){if(data.code==1){var processes=data.data?data.data:{};var collectorKey=processes.collector_key?processes.collector_key:'';var processKeys=isObject(processes.process_keys)?processes.process_keys:[];var processNum=processKeys.length;if(!collectorKey||processNum<=0){return}

2
public/static/js/admin/collected.js

@ -8,7 +8,7 @@
|--------------------------------------------------------------------------
*/
'use strict';function CollectedClass(){}
CollectedClass.prototype={constructor:CollectedClass,init_list:function(){$('#list_table .delete').bind('click',function(){var obj=$(this);confirmRight(window.tpl_lang.confirm_delete,function(){ajaxOpen({type:"GET",url:obj.attr('url'),dataType:"json",success:function(data){data.code==1?toastr.success(data.msg):toastr.error(data.msg);if(data.code==1){obj.parents('tr').eq(0).remove()}}})})});$('#deleteall').bind('click',function(){var obj=$(this);confirmRight(window.tpl_lang.confirm_delete,function(){ajaxOpen({type:"POST",url:ulink('collected/op?op=deleteall'),dataType:"json",data:$('#form_list').serialize(),success:function(data){data.code==1?toastr.success(data.msg):toastr.error(data.msg);window.setTimeout("window.location.reload();",2500)}})})});$('#btn_clear_error').bind('click',function(){windowModal('清理失败的数据',ulink('collected/clearError'))})},chart_init:function(){$('#chart_date [data-chart-op]').bind('click',function(){if(!$('#chart_date').attr('data-chart-tpl')){$('#chart_date').attr('data-chart-tpl',$('#chart_date .chart-box').prop('outerHTML'))}
CollectedClass.prototype={constructor:CollectedClass,init_list:function(){$('#list_table .delete').bind('click',function(){var obj=$(this);confirmRight(window.tpl_lang.confirm_delete,function(){ajaxOpen({type:"GET",url:obj.attr('url'),dataType:"json",success:function(data){data.code==1?toastr.success(data.msg):toastr.error(data.msg);if(data.code==1){obj.parents('tr').eq(0).remove()}}})})});$('#deleteall').bind('click',function(){var obj=$(this);confirmRight(window.tpl_lang.confirm_delete,function(){ajaxOpen({type:"POST",url:ulink('collected/op?op=deleteall'),dataType:"json",data:$('#form_list').serialize(),success:function(data){data.code==1?toastr.success(data.msg):toastr.error(data.msg);window.setTimeout("window.location.reload();",2500)}})})});$('#btn_clear_error').bind('click',function(){windowModal('清理失败的数据',ulink('collected/clearError'))});$.datetimepicker.setLocale('zh');$('#form_search input[name="begin"],#form_search input[name="end"]').datetimepicker()},chart_init:function(){$('#chart_date [data-chart-op]').bind('click',function(){if(!$('#chart_date').attr('data-chart-tpl')){$('#chart_date').attr('data-chart-tpl',$('#chart_date .chart-box').prop('outerHTML'))}
$('#chart_date .nav-tabs>li').removeClass('active');$(this).parents('li').eq(0).addClass('active');$('#chart_date .chart-loading').show();$('#chart_date .chart-canvas').remove();var chartOp=$(this).attr('data-chart-op');ajaxOpen({type:"GET",url:ulink('collected/chartOp?op='+chartOp),dataType:"json",success:function(data){var chartData={labels:[],datasets:[{label:"发布成功",data:[],backgroundColor:'rgba(54, 162, 235, 0.2)',borderColor:'rgba(54, 162, 235, 1)',borderWidth:1,},{label:"发布失败",data:[],backgroundColor:'rgba(255, 99, 132, 0.2)',borderColor:'rgba(255, 99, 132, 1)',borderWidth:1,}]};if(data.code==1&&data.data){var nameData=data.data.name;var successData=data.data.success;var failedData=data.data.failed;if(nameData){for(var i in nameData){chartData.labels.push(nameData[i]);chartData.datasets[0].data.push(successData[i]?successData[i]:0);chartData.datasets[1].data.push(failedData[i]?failedData[i]:0)}}}
$('#chart_date .chart-box').html($('#chart_date').attr('data-chart-tpl'));$('#chart_date .chart-loading').hide();var chart=$("#chart_date .chart-canvas").get(0).getContext("2d");chart=new Chart(chart,{type:'line',data:chartData,options:{maintainAspectRatio:!1,tooltips:{mode:'index',intersect:!1,}}});chart.canvas.parentNode.style.height='300px'}})});$('#chart_date [data-chart-op="today"]').trigger('click');ajaxOpen({type:"GET",url:ulink('collected/chartOp?op=release'),dataType:"json",success:function(data){var chartData={labels:[],datasets:[{label:"发布成功",data:[],backgroundColor:'rgba(54, 162, 235, 0.2)',borderColor:'rgba(54, 162, 235, 1)',pointBackgroundColor:'rgba(54, 162, 235, 0.2)',pointBorderColor:'rgba(54, 162, 235, 1)',borderWidth:1,},{label:"发布失败",data:[],backgroundColor:'rgba(255, 99, 132, 0.2)',borderColor:'rgba(255, 99, 132, 1)',pointBackgroundColor:'rgba(255, 99, 132, 0.2)',pointBorderColor:'rgba(255, 99, 132, 1)',borderWidth:1,}]};if(data.code==1&&data.data){var nameData=data.data.name;var successData=data.data.success;var failedData=data.data.failed;if(nameData){for(var i in nameData){chartData.labels.push(nameData[i]);chartData.datasets[0].data.push(successData[i]?successData[i]:0);chartData.datasets[1].data.push(failedData[i]?failedData[i]:0)}}
$('#chart_release .chart-loading').hide();$('#chart_release .chart-canvas').show();var chart=$("#chart_release .chart-canvas").get(0).getContext("2d");chart=new Chart(chart,{type:'radar',data:chartData,options:{maintainAspectRatio:!1,tooltips:{mode:'index',intersect:!1,}}});chart.canvas.parentNode.style.height='300px'}}});ajaxOpen({type:"GET",url:ulink('collected/chartOp?op=task'),dataType:"json",success:function(data){var chartData={labels:[],datasets:[{label:"采集数量",data:[],backgroundColor:'rgba(54, 162, 235, 0.2)',}]};if(data.code==1&&data.data){var nameData=data.data.name;var totalData=data.data.total;if(nameData){for(var i in nameData){if(nameData[i]&&totalData[i]){chartData.labels.push(nameData[i]);chartData.datasets[0].data.push(totalData[i])}}}

2
public/static/js/admin/collector.js

@ -187,7 +187,7 @@ $($_o.processBox+' .process-add').bind('click',function(){var module=$($_o.proce
$($_o.processForm).on('click','.p-m-html-tags a[data-val]',function(){var tag=$(this).attr('data-val');var moduleHtml=$(this).parents('.p-m-html-tags').eq(0).attr('module-html');var tagsObj=$(this).parents('section').eq(0).find('input[data-process="html:'+moduleHtml+'"]');var tags=tagsObj.val()+','+tag;tags=tags.replace(/(^,+)|(,+$)/,'');tagsObj.val(tags)});$($_o.processForm).on('change','[data-process="insert:insert_loc"]',function(){var helpEle=$(this).siblings('.help-block');if($(this).val()=='rand'){helpEle.show()}else{helpEle.hide()}});inputSelectCustom(null,null,{box:$_o.processForm,slt:'[data-process="translate:translate_from"]',ipt:'[data-process="translate:translate_from_custom"]'});inputSelectCustom(null,null,{box:$_o.processForm,slt:'[data-process="translate:translate_to"]',ipt:'[data-process="translate:translate_to_custom"]'});$_o.txt_insert_field($_o.processForm,'.p-m-func-field',function(sltObj){return $(sltObj).parents('section').eq(0).find('[data-process="func:func_param"]')});$($_o.processForm).on('click','.p-m-if-add',function(){var ifTable=$(this).parents('section').eq(0).find('.p-m-if-table');ifTable.append('<tr>'+ifTable.attr('data-tpl')+'</tr>')});$($_o.processForm).on('click','.p-m-if-del',function(){var tr=$(this).parents('tr').eq(0);confirmRight('确定删除?',function(){tr.remove()})});$($_o.processForm).on('change','[data-process="if:if_cond:"]',function(){var ifCond=$(this).val();var ifTr=$(this).parents('tr').eq(0);var ifTd=ifTr.find('.p-m-if-val').eq(0);var ifVal=ifTd.find('[data-process="if:if_val:"]').eq(0);var ifValInfo={name:ifVal.attr('name'),val:ifVal.val(),process:ifVal.attr('data-process')};var ifValType='def';if(ifCond=='func'){ifValType='func'}else if(ifCond.indexOf('time_')>-1){ifValType='time'}
ifTd.find('.p-m-if-val-def,.p-m-if-val-time,.p-m-if-val-func').hide();ifTd.find('[data-process="if:if_val:"]').removeAttr('name').removeAttr('data-process');var ifValBox=ifTd.find('.p-m-if-val-'+ifValType);var ifValEle=ifValBox.find('.p-m-if-val-ele');ifValEle.attr('name',ifValInfo.name).attr('data-process',ifValInfo.process).val(ifValInfo.val);ifValBox.show();if(ifValType=='func'){$_o.load_if_func(ifTd,null)}});$($_o.processForm).on('change','.p-m-if-val-time-date select',function(){$(this).parents('tr').eq(0).find('[data-process="if:if_val:"]').val($(this).val())});$($_o.processForm).on('click','.p-m-if-val-func-info',function(){tipsPluginFunc('processIf')});$_o.txt_insert_field($_o.processForm,'.p-m-if-val-func-field select',function(sltObj){return $(sltObj).parents('td').eq(0).find('[data-process="if:if_val:"]')});$($_o.processForm).on('click','.p-m-if-info',function(){var tips='<p>执行顺序:从上至下判断,逻辑符“并且”的优先级高于“或者”</p>'+'<p>例如(字母表示条件):</p>'+'<p>a &amp;&amp; b || c &amp;&amp; d &amp;&amp; e || f || g &amp;&amp; h &amp;&amp; i &amp;&amp; j 等同于</p>'+'<p>(a &amp;&amp; b) || (c &amp;&amp; d &amp;&amp; e) || f || (g &amp;&amp; h &amp;&amp; i &amp;&amp; j)</p>'+'<p>括号中的条件都为真时才是真否则为假,整条语句中任意一个括号的结果为真最终结果为真,都为假最终结果为假</p>';confirmRight({msg:tips,yes:'确定',width:500,textAlign:'left'})});$($_o.processForm).on('click','.p-m-api-add',function(){var apiTable=$(this).parents('section').eq(0).find('.p-m-api-table table');apiTable.find('tbody').append('<tr>'+apiTable.attr('data-tpl')+'</tr>')});$($_o.processForm).on('click','.p-m-api-del',function(){var tr=$(this).parents('tr').eq(0);tr.remove()});inputSelectCustom(null,null,{box:$_o.processForm,slt:'[data-process="api:api_charset"]',ipt:'[data-process="api:api_charset_custom"]'});inputSelectCustom(null,null,{box:$_o.processForm,slt:'[data-process="api:api_encode"]',ipt:'[data-process="api:api_encode_custom"]'});$($_o.processForm).on('change','[data-process="api:api_params:val:"],[data-process="api:api_headers:val:"]',function(){var isHeader=!1;if($(this).attr('data-process')=='api:api_headers:val:'){isHeader=!0}
var val=$(this).val();var tdObj=$(this).parents('td').eq(0);var iptObj=tdObj.find('[data-process="api:'+(isHeader?'api_headers':'api_params')+':addon:"]');var sltObj=tdObj.find('.p-m-api-'+(isHeader?'header':'val')+'-field');iptObj.hide();sltObj.hide();if(val=='time'||val=='custom'){if(val=='time'){iptObj.attr('placeholder','默认格式:Y-m-d H:i:s')}else if(val=='custom'){iptObj.attr('placeholder','输入任何内容');sltObj.css('display','table-cell')}
iptObj.show()}});$_o.txt_insert_field($_o.processForm,'.p-m-api-val-field select',function(sltObj){return $(sltObj).parents('td').eq(0).find('[data-process="api:api_params:addon:"]')});$_o.txt_insert_field($_o.processForm,'.p-m-api-header-field select',function(sltObj){return $(sltObj).parents('td').eq(0).find('[data-process="api:api_headers:addon:"]')});$($_o.processForm).on('click','.p-m-api-header-add',function(){var apiHdTable=$(this).parents('section').eq(0).find('.p-m-api-header-table table');apiHdTable.find('tbody').append('<tr>'+apiHdTable.attr('data-tpl')+'</tr>')});$($_o.processForm).on('click','.p-m-api-header-del',function(){var tr=$(this).parents('tr').eq(0);tr.remove()});$($_o.processForm).on('change','[data-process="api:api_type"]',function(){var obj=$(this).parents('section').eq(0).find('.p-m-api-content-type');if($(this).val()=='post'){obj.show()}else{obj.hide()}});$($_o.processForm).on('change','[data-process="api:api_json_arr"]',function(){var ipt=$(this).parent().find('[data-process="api:api_json_implode"]');if($(this).val()=='implode'){ipt.show()}else{ipt.hide()}});$($_o.processForm).on('click','.sign-wildcard',function(){var toObj=$(this).parent().siblings('[data-process="replace:replace_from"]');cpWildcard(toObj)});$($_o.processForm).on('click','.c-p-process-title',function(){var panelTitle=$(this).parents('.panel').eq(0).find('.panel-title-title');if(panelTitle.find('input').is(':visible')){panelTitle.find('*').show();panelTitle.find('input').hide()}else{panelTitle.find('*').hide();panelTitle.find('input').show()}});(function(processForm,processBox){$(processForm).on('click','.c-p-process-clone',function(){var panelObj=$(this).parents('.panel[data-name^="process"]').eq(0);var formEle=document.createElement('form');$(formEle).append(panelObj.clone());$(panelObj).find('[name^="process"]').each(function(index){var processEle=$(formEle).find('[name^="process"]').eq(index);if($(this).is('input:radio')||$(this).is('input:checkbox')){processEle.prop('checked',$(this).is(':checked'))}else{processEle.val($(this).val())}});confirmRight({msg:'拷贝或复制数据处理',yes:'复制',no:'拷贝',close:!0},function(){ajaxOpen({type:'POST',dataType:'json',url:ulink('cpattern/clone_process'),data:$(formEle).serialize(),success:function(data){if(data.code==1){$_o.processForm=processForm;$_o.processBox=processBox;$_o.add(data.data);toastr.success(data.msg)}}})},function(){ajaxOpen({type:'POST',dataType:'json',url:ulink('cpattern/clone_process?op=copy'),data:$(formEle).serialize(),success:function(data){if(data.code==1){toastr.success(data.msg)}}})})})})($_o.processForm,$_o.processBox);$($_o.processForm).on('click','.c-p-process-del',function(){$_o.del(this)});eleExchange($_o.processForm+' .c-p-process-accordion','.panel-title-ops .icon-drag-move','.panel');if(processData){for(var i in processData){if(processData[i]){$_o.add(processData[i])}}}
iptObj.show()}});$_o.txt_insert_field($_o.processForm,'.p-m-api-val-field select',function(sltObj){return $(sltObj).parents('td').eq(0).find('[data-process="api:api_params:addon:"]')});$_o.txt_insert_field($_o.processForm,'.p-m-api-header-field select',function(sltObj){return $(sltObj).parents('td').eq(0).find('[data-process="api:api_headers:addon:"]')});$($_o.processForm).on('click','.p-m-api-header-add',function(){var apiHdTable=$(this).parents('section').eq(0).find('.p-m-api-header-table table');apiHdTable.find('tbody').append('<tr>'+apiHdTable.attr('data-tpl')+'</tr>')});$($_o.processForm).on('click','.p-m-api-header-del',function(){var tr=$(this).parents('tr').eq(0);tr.remove()});$($_o.processForm).on('change','[data-process="api:api_type"]',function(){var obj=$(this).parents('section').eq(0).find('.p-m-api-content-type');if($(this).val()=='post'){obj.show()}else{obj.hide()}});$($_o.processForm).on('change','[data-process="api:api_json_arr"]',function(){var ipt=$(this).parent().find('.p-m-api-json-implode');if($(this).val()=='implode'){ipt.show()}else{ipt.hide()}});$($_o.processForm).on('click','.sign-wildcard',function(){var toObj=$(this).parent().siblings('[data-process="replace:replace_from"]');cpWildcard(toObj)});$($_o.processForm).on('click','.c-p-process-title',function(){var panelTitle=$(this).parents('.panel').eq(0).find('.panel-title-title');if(panelTitle.find('input').is(':visible')){panelTitle.find('*').show();panelTitle.find('input').hide()}else{panelTitle.find('*').hide();panelTitle.find('input').show()}});(function(processForm,processBox){$(processForm).on('click','.c-p-process-clone',function(){var panelObj=$(this).parents('.panel[data-name^="process"]').eq(0);var formEle=document.createElement('form');$(formEle).append(panelObj.clone());$(panelObj).find('[name^="process"]').each(function(index){var processEle=$(formEle).find('[name^="process"]').eq(index);if($(this).is('input:radio')||$(this).is('input:checkbox')){processEle.prop('checked',$(this).is(':checked'))}else{processEle.val($(this).val())}});confirmRight({msg:'拷贝或复制数据处理',yes:'复制',no:'拷贝',close:!0},function(){ajaxOpen({type:'POST',dataType:'json',url:ulink('cpattern/clone_process'),data:$(formEle).serialize(),success:function(data){if(data.code==1){$_o.processForm=processForm;$_o.processBox=processBox;$_o.add(data.data);toastr.success(data.msg)}}})},function(){ajaxOpen({type:'POST',dataType:'json',url:ulink('cpattern/clone_process?op=copy'),data:$(formEle).serialize(),success:function(data){if(data.code==1){toastr.success(data.msg)}}})})})})($_o.processForm,$_o.processBox);$($_o.processForm).on('click','.c-p-process-del',function(){$_o.del(this)});eleExchange($_o.processForm+' .c-p-process-accordion','.panel-title-ops .icon-drag-move','.panel');if(processData){for(var i in processData){if(processData[i]){$_o.add(processData[i])}}}
$($_o.processForm).prop('inited',1)},add_sub:function(){var $_o=this;ajaxOpen({type:'POST',dataType:'json',url:$($_o.processForm).attr('action'),data:$($_o.processForm).serialize(),success:function(data){if(data.code==1){$('#myModal').modal('hide');if(data.data&&data.data.objid){$($_o.$_cp.formid+' #'+data.data.objid).find('input[name="config[field_process][]"]').val(data.data.process_json?url_base64encode(data.data.process_json):'');var ptitle='';var processData=data.data.process;if(processData){ptitle=[];for(var i in processData){ptitle.push(window.tpl_lang['process_module_'+processData[i].module]+(processData[i].title?(':'+processData[i].title):''))}
ptitle=ptitle.join(' / ')}
if(processData&&ptitle){$($_o.$_cp.formid+' #'+data.data.objid).find('.field-process').addClass('exist-process').attr('title',ptitle)}else{$($_o.$_cp.formid+' #'+data.data.objid).find('.field-process').removeClass('exist-process').attr('title','')}}}else{toastr.error(data.msg)}},error:function(data){toastr.error(data)}});return!1},del:function(obj){var $_o=this;confirmRight('是否删除?',function(){$(obj).parents('.panel').eq(0).remove()})},load_if_func:function(box,setVal){var $_o=this;loadPluginFunc({module:'processIf',boxObj:box,funcObj:'[data-process="if:if_addon:func:"]',paramObj:'[data-process="if:if_val:"]',funcVal:setVal,cache:!0})},add:function(params){var $_o=this;params=params?params:{};if(!params.module){toastr.error('请选择处理方式');return!1}

1
public/static/js/admin/index.js

@ -16,6 +16,7 @@ if(data.is_new_admin_index){$('#refresh_admin_index').trigger('click')}}else{$('
if(data.phpCliVersion){$('#php_cli_version').show().find('span').html(data.phpCliVersion)}
if(data.pageRenderInvalid){list.push('<a href="'+ulink('setting/page_render')+'" target="_blank">页面渲染</a>')}
if(list.length>0){list=list.join(' , ');$('#invalid_list').find('[data-box]').html(list);$('#invalid_list').fadeIn()}
if(data.repairTables){$('#repair_tables').find('[data-box]').html(data.repairTables);$('#repair_tables').fadeIn();$('#repair_tables button').bind('click',function(){windowModal('正在修复表...',ulink('backstage/repairTables'),{ajax:{type:'post',data:{'tables':data.repairTables}}})})}
if(data.tongji){for(var i in data.tongji){$('#data_'+i).text(data.tongji[i])}}}}})});function UpgradeZipClass(size,blocks){this.size=size?toInt(size):0;this.blocks=blocks?toInt(blocks):0;this.nextBlockNo=0;this.existBlocks=0}
UpgradeZipClass.prototype={constructor:UpgradeZipClass,down_zip:function(blockNo){var $_o=this;blockNo=toInt(blockNo);$_o.nextBlockNo=0;var url=ulink('upgrade/downZip?block_no='+blockNo);ajaxOpen({type:'get',dataType:'json',url:url,success:function(data){if(data.code==1){var dataData=data.data;$_o.nextBlockNo=toInt(dataData.next_block_no);$_o.existBlocks=toInt(dataData.exist_blocks);var existSize=toInt(dataData.exist_size);existSize=existSize/(1024*1024);existSize=Math.floor(existSize*100)/100;$('#op_upgrade').find('.size').text(existSize+'MB')}else{$('#upgrade_error').show();if(data.msg){$('#upgrade_error').append(data.msg+"\r\n")}else{$('#upgrade_error').append('下载失败:压缩包文件块'+(blockNo+1)+"\r\n")}}},error:function(){$('#upgrade_error').show();$('#upgrade_error').append('下载失败:压缩包文件块'+(blockNo+1)+"\r\n")},complete:function(){if($_o.existBlocks>=$_o.blocks){$_o.down_complete()}else{if($_o.nextBlockNo>0){$_o.down_zip($_o.nextBlockNo)}else{$('#op_upgrade').removeAttr('upgrading').html('请刷新界面重新下载失败的文件!')}}}})},down_complete:function(){$('#op_upgrade').html('正在更新文件...');ajaxOpen({type:'get',dataType:'json',url:ulink('upgrade/downZipComplete?'+urlUsertoken()),success:function(data){if(data.code==1){$('#op_upgrade').html('更新成功')}else{$('#op_upgrade').html('更新失败')}}})}}
function UpgradeClass(fileList){this.fileList=fileList;this.fileNum=fileList?fileList.length:0;this.downNum=0}

14
public/static/js/admin/release.js

@ -9,14 +9,14 @@
*/
'use strict';function ReleaseClass(formid,releid){this.formid='#'+formid;this.releid=releid}
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));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})}});$('#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()});inputSelectCustom('#rele_module_toapi [name="toapi[charset]"]','toapi[charset_custom]');inputSelectCustom('#rele_module_toapi [name="toapi[encode]"]','toapi[encode_custom]');inputSelectCustom(null,null,{box:'#rele_module_toapi',slt:'[name="toapi[param_val][]"]',ipt:'[name="toapi[param_addon][]"]'});$('#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()});inputSelectCustom(null,null,{box:'#rele_module_toapi',slt:'[name="toapi[header_val][]"]',ipt:'[name="toapi[header_addon][]"]'});$('#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')}
var settings=getFormAjaxSettings($(this));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_app_url_field').bind('change',function(){var val=$(this).val();$(this).val('');insertAtCaret($('#rele_module_toapi [name="toapi[app_url]"]'),val)});$('#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])}
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[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])}}
if(config.param_name){config.param_val=config.param_val?config.param_val:{};config.param_addon=config.param_addon?config.param_addon:{};for(var i in config.param_name){var pname=config.param_name[i]?config.param_name[i]:'';var pval=config.param_val[i]?config.param_val[i]:'';var paddon=config.param_addon[i]?config.param_addon[i]:'';$_o.toapi_add_param({name:pname,val:pval,addon:paddon},i)}}
if(config.header_name){config.header_val=config.header_val?config.header_val:{};config.header_addon=config.header_addon?config.header_addon:{};for(var i in config.header_name){var hname=config.header_name[i]?config.header_name[i]:'';var hval=config.header_val[i]?config.header_val[i]:'';var haddon=config.header_addon[i]?config.header_addon[i]:'';$_o.toapi_add_header({name:hname,val:hval,addon:haddon},i)}}
$($_o.formid+' [name="toapi[interval]"]').val(toInt(config.interval));$($_o.formid+' [name="toapi[wait]"]').val(toInt(config.wait));$($_o.formid+' [name="toapi[retry]"]').val(toInt(config.retry))}}}},cms_detect:function(){var $_o=this;$('#cms_list').html('').addClass('loading');ajaxOpen({type:'get',url:ulink("release/cmsDetect"),dataType:'json',success:function(data){$('#cms_list').removeClass('loading');if(data.code==1){var html='<p>点击选择CMS</p>';for(var x in data.data){var list=data.data[x];html+='<label>'+x+'</label><ul>';for(var y in list){html+='<li><a href="javascript:;" path="'+list[y]+'">'+list[y]+'</a></li>'}
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])}}
if(config.param_name){config.param_val=config.param_val?config.param_val:{};for(var i in config.param_name){var pname=config.param_name[i]?config.param_name[i]:'';var pval=config.param_val[i]?config.param_val[i]:'';$_o.toapi_add_param({name:pname,val:pval},i)}}
if(config.header_name){config.header_val=config.header_val?config.header_val:{};for(var i in config.header_name){var hname=config.header_name[i]?config.header_name[i]:'';var hval=config.header_val[i]?config.header_val[i]:'';$_o.toapi_add_header({name:hname,val:hval},i)}}
$($_o.formid+' [name="toapi[app_url]"]').val(config.app_url);config.interval=toInt(config.interval);config.wait=toInt(config.wait);config.retry=toInt(config.retry);$($_o.formid+' [name="toapi[interval]"]').val(config.interval);$($_o.formid+' [name="toapi[wait]"]').val(config.wait);$($_o.formid+' [name="toapi[retry]"]').val(config.retry);$(document).ready(function(){$('#toapi_tab a[href="#toapi_tab_'+config.module+'"]').tab('show').trigger('click');if(config.interval>0||config.wait>0||config.retry>0){showPanelCollapse('#panel_toapi')}})}}}},cms_detect:function(){var $_o=this;$('#cms_list').html('').addClass('loading');ajaxOpen({type:'get',url:ulink("release/cmsDetect"),dataType:'json',success:function(data){$('#cms_list').removeClass('loading');if(data.code==1){var html='<p>点击选择CMS</p>';for(var x in data.data){var list=data.data[x];html+='<label>'+x+'</label><ul>';for(var y in list){html+='<li><a href="javascript:;" path="'+list[y]+'">'+list[y]+'</a></li>'}
html+='</ul>'}
$('#cms_list').html(html)}else{$('#cms_list').html(data.msg)}}})},cms_bind:function(config){var $_o=this;$('#cms_bind').html('').addClass('loading');var postData=$($_o.formid).serialize();if(config&&config.cms&&config.cms.app){postData='cms[app]='+encodeURIComponent(config.cms.app)+'&'+postData}
ajaxOpen({type:'post',url:ulink("release/cmsBind"),dataType:'html',data:postData,success:function(data,textStatus,request){$('#cms_bind').removeClass('loading').show();if((/application\/json/i).test(request.getResponseHeader('Content-Type'))){data=jQuery.parseJSON(data);$('#cms_bind').html('<b style="color:red;">'+data.msg+'</b>')}else{$('#cms_bind').html(data);if(config&&config.cms_app){if(config.cms_app.param){for(var f in config.cms_app.param){var paramEle=$('#cms_bind').find('[name="cms_app[param]['+f+']"]');if(paramEle.is('select')){paramEle.val(config.cms_app.param[f]).trigger('change')}else if(paramEle.is('input:radio')){$('#cms_bind').find('[name="cms_app[param]['+f+']"][value="'+config.cms_app.param[f]+'"]').prop('checked','checked')}else{paramEle.val(config.cms_app.param[f])}}
@ -31,7 +31,7 @@ if(isObject(dbTable.sequence)){for(var sk in dbTable.sequence){$(tBoxId).find('[
eleExchange(tBoxId+' .db-table-bind-where','.db-table-bind-where-move','tbody tr')}}}},db_table_bind_where_add:function(curObj,whereData){var key=$(curObj).parents('[id^="db_table_t_"]').eq(0).attr('data-key');this.db_table_bind_op_add('where',key,whereData)},db_table_bind_query_add:function(curObj,queryData){var key=$(curObj).parents('[id^="db_table_t_"]').eq(0).attr('data-key');this.db_table_bind_op_add('query',key,queryData)},db_table_bind_op_add:function(opType,key,opData){if(opType&&key){var boxObj=$('#db_table_bind_list').find('#db_table_t_'+key);if(boxObj.length>0){var opTypeClass='.db-table-bind-'+opType;var tbBox=boxObj.find(opTypeClass);if(tbBox.length>0){var tpl=tbBox.find(opTypeClass+'-tpl').clone();tpl.removeClass('db-table-bind-'+opType+'-tpl');if(isObject(opData)){for(var dk in opData){tpl.find('[data-name="['+opType+']['+dk+'][]"]').val(opData[dk])}}
tpl.find('[data-name]').each(function(){$(this).attr('name','db_tables['+key+']'+$(this).attr('data-name'));$(this).removeAttr('data-name')});tbBox.find('tbody').append(tpl)}}}},db_connect:function(op){op=op?op:'';var $_o=this;$('#db_tab_config .rele-db-error').html('').addClass('loading');ajaxOpen({type:'post',url:ulink("release/dbConnect?op="+op),timeout:10000,dataType:'json',data:$($_o.formid).serialize(),success:function(data){if(data.code==1){if(op=='db_names'){modal('选择数据库',data.msg)}else{$('#db_tab_config .rele-db-error').css('color','green').html(data.msg)}}else{toastr.error(data.msg);$('#db_tab_config .rele-db-error').css('color','red').html(data.msg)}},complete:function(XMLHttpRequest,status){$('#db_tab_config .rele-db-error').removeClass('loading');if(status=='timeout'){$('#db_tab_config .rele-db-error').css('color','red').html('数据库连接超时')}}})},toapi_add_param:function(param,index){var $_o=this;var paramTable=$('#rele_module_toapi').find('.toapi-param-table table');if(!paramTable.attr('data-tpl')){var paramTpl=$('#rele_module_toapi').find('.toapi-param-tpl');paramTable.attr('data-tpl',paramTpl.html());paramTpl.remove()}
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:'').trigger('change');curTr.find('[name="toapi[param_addon][]"]').val(param.addon?param.addon:'')},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()}
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:'').trigger('change');curTr.find('[name="toapi[header_addon][]"]').val(header.addon?header.addon:'')},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));  }
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}}

7
public/static/js/admin/tasks.js

@ -11,9 +11,10 @@
var taskid=tasksOpClass.get_task_id(this);if(taskid>0){var $_o=$(this);var url=ulink('task/op?op=auto&auto=_auto_&id=_id_',{'_auto_':auto,'_id_':taskid});ajaxOpen({type:'GET',url:url,success:function(data){if(data.code==1){$_o.attr('data-val',auto);$_o.prop('title','');$_o.html(tips[0]);$_o.css('color',tips[1])}},dataType:'json'})}});var loadedFunc=function(){$('#myModal .modal-footer .close').html('关闭采集').prop('title','关闭并结束任务').addClass('btn btn-primary').removeClass('close');var btnBackstage=$('<button type="button" class="btn btn-default btn-backstage" data-dismiss="modal" title="关闭并在后台继续运行">后台运行</button>');btnBackstage.bind('click',function(){collectorEchoMsg.close_non_stop=!0});$('#myModal .modal-footer').prepend(btnBackstage)};$('table.datatable').on('click','.caiji',function(){var taskid=tasksOpClass.get_task_id(this);collectorWindow('任务采集','admin/task/collect?id=_id_',{'_id_':taskid},{loaded_func:loadedFunc,lg:1})});$('table.datatable').on('click','.caiji-batch',function(){var taskids=[];$('input[name="batch[]"]:checked').each(function(){taskids.push($(this).val())});collectorWindow('批量采集','admin/task/collectBatch?ids=_ids_',{'_ids_':taskids.join(',')},{loaded_func:loadedFunc,lg:1})});$('table.datatable').on('click','.houtai',function(){var taskid=tasksOpClass.get_task_id(this);tasksOpClass.backstage_collect(taskid)});$('table.datatable').on('click','.houtai-batch',function(){var taskids=[];$('input[name="batch[]"]:checked').each(function(){taskids.push($(this).val())});tasksOpClass.backstage_collect(taskids)});$('table.datatable thead th[data-order]').bind('click',function(){var order=$(this).attr('data-order');if(!order){return!1}
var className=$(this).prop('class');var sort='desc';if(className=='sorting_desc'){sort='asc'}
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="5"></td></tr>'}}
if(data.data.taskList){var datalist=data.data.taskList;for(var i in datalist){var item=datalist[i];var auto=toInt(item.auto);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>'+'&nbsp;<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('collector/set?task_id='+item.id)+'">规则</a></li>'+' <li class="sep">|</li> <li><a href="'+ulink('release/set?task_id='+item.id)+'">发布</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="5"></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(',')}
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>'+'&nbsp;<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})}
ajaxOpen({type:'GET',url:url,async:!0,timeout:3000,dataType:'html'});toastr.success('已添加到后台运行');winBackstageTask.count(1000)},}

2
public/static/js/langs/zh-cn.js

File diff suppressed because one or more lines are too long

42
vendor/skycaiji/app/admin/controller/Backstage.php vendored

@ -12,6 +12,7 @@
namespace skycaiji\admin\controller;
use skycaiji\admin\model\CacheModel;
use think\db\Query;
class Backstage extends BaseController{
public function indexAction(){
$runInfo=array();
@ -170,6 +171,7 @@ class Backstage extends BaseController{
$info=array(
'pageRenderInvalid'=>false,
'phpInvalid'=>false,
'repairTables'=>'',
);
try{
@ -233,6 +235,32 @@ class Backstage extends BaseController{
$tongji['task_auto']=model('Task')->where('`auto`>0')->count();
$tongji['task_other']=model('Task')->where('`auto`=0')->count();
$info['tongji']=$tongji;
$dbName=config('database.database');
$dbTables=db()->getConnection()->getTables($dbName);
if(!empty($dbTables)){
$dbTables1=array();
foreach ($dbTables as $k=>$v){
$v=strtolower($v);
if(stripos($v,config('database.prefix'))!==false){
$dbTables1[$v]=$v;
}
}
$dbTables=$dbTables1;
$checkList=db()->query('check table '.implode(',',$dbTables));
$dbTables=array();
foreach ($checkList as $v){
if(is_array($v)&&$v['Msg_type']&&strtolower($v['Msg_type'])=='error'){
$v['Table']=preg_replace('/^'.$dbName.'\./i', '', $v['Table']);
$dbTables[$v['Table']]=$v['Table'];
}
}
if($dbTables){
$info['repairTables']=implode(',',$dbTables);
}
}
}catch (\Exception $ex){
}
@ -240,6 +268,20 @@ class Backstage extends BaseController{
$this->success('','',$info);
}
public function repairTablesAction(){
if(request()->isPost()){
$tables=input('tables','');
$tables=explode(',', $tables);
$tables=array_unique($tables);
$tables=array_values($tables);
if($tables){
db()->query('repair table '.implode(',', $tables));
$this->success('修复完成','backstage/index');
}
}
$this->error('修复失败');
}
/*检测更新*/
public function newVersionAction(){
\util\Funcs::close_session();

27
vendor/skycaiji/app/admin/controller/Collected.php vendored

@ -11,6 +11,8 @@
namespace skycaiji\admin\controller;
use skycaiji\admin\model\CacheModel;
class Collected extends BaseController {
public function listAction(){
$taskName=input('task_name');
@ -36,12 +38,35 @@ class Collected extends BaseController {
if(!empty($taskId)){
$taskData=$mtask->where('id',$taskId)->find();
if(!empty($taskData)){
$search['task_name']=$taskData['name'];
$navTips='任务:'.$taskData['name'];
$cond['task_id']=$taskData['id'];
}
}
}
$search['num']=input('num/d',200);
$search['begin']=input('begin','');
$search['end']=input('end','');
if($search['begin']&&$search['end']){
$cond['addtime']=array('between',array(strtotime($search['begin']),strtotime($search['end'])));
}elseif($search['begin']){
$cond['addtime']=array('>=',strtotime($search['begin']));
}elseif($search['end']){
$cond['addtime']=array('<=',strtotime($search['end']));
}
$mcache=CacheModel::getInstance();
$search['num']=input('num/d');
if($search['num']<=0){
$search['num']=$mcache->getCache('action_collected_list_num','data');
$search['num']=intval($search['num']);
if($search['num']<=0){
$search['num']=200;
}
}
$mcache->setCache('action_collected_list_num',$search['num']);
$search['url']=input('url','','trim');
if(!empty($search['url'])){
$cond['url']=array('like','%'.addslashes($search['url']).'%');

2
vendor/skycaiji/app/admin/controller/Index.php vendored

@ -556,7 +556,7 @@ class Index extends CollectController{
private function _collect_check_key(){
if(is_empty(session('user_login'))){
if(!\util\Param::exist_temp_cahce_key(input('key'))){
if(!\util\Param::exist_cache_key(input('key'))){
return false;
}

71
vendor/skycaiji/app/admin/controller/Release.php vendored

@ -482,4 +482,75 @@ class Release extends CollectController{
$msg=lang('rele_error_db').str_replace('Unknown database', lang('error_unknown_database'), $msg);
return $msg;
}
public function toapiAppAction(){
$taskId=input('task_id/d',0);
$mtask=model('Task');
$mrele=model('Release');
$taskData=$mtask->getById($taskId);
$appApi=null;
$appParams=null;
$releData=$mrele->where(array('task_id'=>$taskData['id']))->find();
if(!empty($releData)){
$config=$mrele->compatible_config($releData['config']);
if(!empty($config['toapi'])&&$config['toapi']['module']=='app'){
$appApi=$config['toapi']['app_api'];
if($appApi){
$appApi=base64_decode($appApi);
$appApi=json_decode($appApi,true);
}
$appParams=$config['toapi']['app_params'];
}
}
if(request()->isPost()){
$appUrl=input('app_url','','trim');
if(empty($appUrl)){
$this->error('请输入接口地址');
}
$appApi=get_html($appUrl,[],[],'utf-8');
if(!empty($appApi)){
$appApi=json_decode($appApi,true);
}
init_array($appApi);
if(empty($appApi)){
$this->error('接口读取失败');
}
if(empty($appApi['code'])){
$this->error($appApi['msg']?:'接口错误');
}
$appApi=$appApi['data'];
}
init_array($appApi);
init_array($appParams);
if(!empty($appApi)){
$appApiParams=$appApi['params'];
init_array($appApiParams);
if(empty($appParams)){
foreach ($appApiParams as $pk=>$pv){
$pv=$pv['default'];
if(!empty($pv)||is_numeric($pv)){
$appParams[$pk]=$pv;
}
}
}
$releBase=new \skycaiji\admin\event\ReleaseBase();
$collFields=$releBase->get_coll_fields($taskData['id'],$taskData['module']);
$this->assign('collFields',$collFields);
$this->assign('appApi',base64_encode(json_encode($appApi)));
$this->assign('appApiParams',$appApiParams);
$this->assign('appParams',$appParams);
return $this->fetch('toapiApp');
}
}
}

52
vendor/skycaiji/app/admin/controller/Task.php vendored

@ -75,11 +75,22 @@ class Task extends CollectController {
$orderBy=empty($orderKey)?'sort desc':($orderKey.' '.$sortBy);
$search['num']=input('num/d');
if($search['num']<=0){
$search['num']=$mcache->getCache('action_task_list_num','data');
$search['num']=intval($search['num']);
if($search['num']<=0){
$search['num']=30;
}
}
$mcache->setCache('action_task_list_num',$search['num']);
$search['tg_id']=input('tg_id');
$search['name']=input('name');
$search['module']=input('module');
$search['show']='list';
$limit=20;
$limit=$search['num'];
$cond=array();
if(!empty($search['name'])){
$cond['name']=array('like','%'.addslashes($search['name']).'%');
@ -125,9 +136,10 @@ class Task extends CollectController {
$this->assign('tgList',$tkTgList);
}
}
$taskList=$this->_set_timer_infos($taskList);
$taskList=$this->_set_tasks($taskList);
$this->assign('taskList',$taskList);
$this->assign('pagenav',$pagenav);
$this->assign('todayDate',date('Y-m-d',time()));
$tgSelect=$mtaskgroup->getLevelSelect();
$tgSelect=preg_replace('/<select[^<>]*>/i', "$0<option value=''>".lang('all')."</option>", $tgSelect);
$this->assign('tgSelect',$tgSelect);
@ -168,7 +180,7 @@ class Task extends CollectController {
$tv['caijitime']=$tv['caijitime']>0?date('Y-m-d H:i',$tv['caijitime']):'无';
$taskList[$tk]=$tv;
}
$taskList=$this->_set_timer_infos($taskList);
$taskList=$this->_set_tasks($taskList);
$this->assign('taskList',$taskList);
$this->success('','',array('tgList'=>$subTgList,'taskList'=>$taskList));
}else{
@ -192,11 +204,14 @@ class Task extends CollectController {
$this->success('','');
}
private function _set_timer_infos($taskList){
private function _set_tasks($taskList){
if($taskList){
$mtask=model('Task');
$tids=array();
$timerTids=array();
foreach ($taskList as $v){
$tids[$v['id']]=$v['id'];
if($mtask->auto_is_timer($v['auto'])){
$timerTids[$v['id']]=$v['id'];
@ -217,10 +232,37 @@ class Task extends CollectController {
}
}
}
$mcollected=model('Collected');
$todayTime=strtotime(date('Y-m-d',time()));
foreach ($taskList as $k=>$v){
$taskId=$v['id'];
if(empty($taskId)){
continue;
}
$collected=array();
$collected['today']=$mcollected->where(array('task_id'=>array('=',$taskId),'addtime'=>array('>',$todayTime)))->count();
$collected['total']=$mcollected->where('task_id',$taskId)->count();
$v['_collected_info']=$collected;
$taskList[$k]=$v;
}
$mrele=model('Release');
if($tids){
$releModules=$mrele->where('task_id','in',$tids)->column('module','task_id');
foreach ($taskList as $k=>$v){
if($releModules[$v['id']]){
$v['_rele_module']=lang('rele_module_'.$releModules[$v['id']]);
}
if(empty($v['_rele_module'])){
$v['_rele_module']='';
}
$taskList[$k]=$v;
}
}
}
return $taskList;
}
public function saveAction(){
$mtask=model('Task');
$taskData=null;

9
vendor/skycaiji/app/admin/event/CpatternColl.php vendored

@ -1115,7 +1115,7 @@ class CpatternColl extends CpatternBase{
$encode=$this->config['encode'];
}
$encode=strtolower($encode);
$encode=isset($encode)?strtolower($encode):'';
return $encode;
}
@ -1508,7 +1508,12 @@ class CpatternColl extends CpatternBase{
$chromeSocket->websocket(null);
$htmlInfo=$chromeSocket->getRenderHtml($url,$headers,$options,$charset,$postData,true);
}catch (\Exception $ex){
$this->echo_error('页面渲染失败:'.$ex->getMessage().' 请检查<a href="'.url('setting/page_render').'" target="_blank">渲染设置</a>');
$ex='页面渲染失败:'.$ex->getMessage().' 请检查<a href="'.url('setting/page_render').'" target="_blank">渲染设置</a>';
if(!is_empty(g_sc_c('proxy','open'))){
$ex.=' <a href="'.url('setting/proxy').'" target="_blank">代理设置</a>';
}
$this->echo_error($ex);
return null;
}
}else{

178
vendor/skycaiji/app/admin/event/Rtoapi.php vendored

@ -19,14 +19,19 @@ class Rtoapi extends Release{
*/
public function setConfig($config){
$toapi=input('toapi/a',array(),'trim');
if(empty($toapi['url'])){
$this->error('请输入接口地址');
if($toapi['module']=='app'){
if(empty($toapi['app_url'])){
$this->error('请输入接口地址');
}
}else{
if(empty($toapi['url'])){
$this->error('请输入接口地址');
}
}
$toapi['param_name']=is_array($toapi['param_name'])?$toapi['param_name']:array();
$toapi['param_val']=is_array($toapi['param_val'])?$toapi['param_val']:array();
$toapi['param_addon']=is_array($toapi['param_addon'])?$toapi['param_addon']:array();
if(is_array($toapi['param_name'])){
$toapi['param_name']=\util\Funcs::array_array_map('trim', $toapi['param_name']);
foreach ($toapi['param_name'] as $k=>$v){
@ -34,14 +39,12 @@ class Rtoapi extends Release{
unset($toapi['param_name'][$k]);
unset($toapi['param_val'][$k]);
unset($toapi['param_addon'][$k]);
}
}
}
$toapi['header_name']=is_array($toapi['header_name'])?$toapi['header_name']:array();
$toapi['header_val']=is_array($toapi['header_val'])?$toapi['header_val']:array();
$toapi['header_addon']=is_array($toapi['header_addon'])?$toapi['header_addon']:array();
if(is_array($toapi['header_name'])){
$toapi['header_name']=\util\Funcs::array_array_map('trim', $toapi['header_name']);
foreach($toapi['header_name'] as $k=>$v){
@ -49,7 +52,6 @@ class Rtoapi extends Release{
unset($toapi['header_name'][$k]);
unset($toapi['header_val'][$k]);
unset($toapi['header_addon'][$k]);
}
}
}
@ -60,58 +62,47 @@ class Rtoapi extends Release{
$config['toapi']=$toapi;
return $config;
}
/*导出数据*/
public function export($collFieldsList,$options=null){
$addedNum=0;
if(empty($this->config['toapi']['url'])){
$this->echo_msg('接口地址为空');
}else{
$testToapi=input('?test_toapi');
$apiUrlMd5=md5($this->config['toapi']['url']);
$apiUrl='';
if(!isset($this->url_list[$apiUrlMd5])){
$apiUrl=$this->config['toapi']['url'];
if(strpos($apiUrl, '/')===0){
$apiUrl=config('root_website').$apiUrl;
}elseif(!preg_match('/^\w+\:\/\//', $apiUrl)){
$apiUrl='http://'.$apiUrl;
}
$this->url_list[$apiUrlMd5]=$apiUrl;
}else{
$apiUrl=$this->url_list[$apiUrlMd5];
/*导出数据*/
public function export($collFieldsList,$options=null){
$apiUrl='';
$apiConfig=array();
$paramVals=array();
$headerVals=array();
if($this->config['toapi']['module']=='app'){
$apiUrl=$this->config['toapi']['app_url'];
$appApi=$this->config['toapi']['app_api'];
if(!empty($appApi)){
$appApi=base64_decode($appApi);
$appApi=$appApi?json_decode($appApi,true):'';
}
$apiResponse=$this->config['toapi']['response'];
$apiResponse=is_array($apiResponse)?$apiResponse:array();
init_array($appApi);
$apiConfig['type']=$appApi['type']?:'post';
$apiConfig['charset']=$appApi['charset']?:'';
$apiConfig['encode']=$appApi['encode']?:'';
$apiConfig['response']=is_array($appApi['response'])?$appApi['response']:array();
$apiResponse['id']=$apiResponse['id']?:'id';
$apiResponse['target']=$apiResponse['target']?:'target';
$apiResponse['desc']=$apiResponse['desc']?:'desc';
$apiResponse['error']=$apiResponse['error']?:'error';
$paramVals=$this->config['toapi']['app_params'];
$headerVals=is_array($appApi['headers'])?$appApi['headers']:array();
$apiCharset=$this->config['toapi']['charset'];
if($apiCharset=='custom'){
$apiCharset=$this->config['toapi']['charset_custom'];
if($appApi['content_type']){
$headerVals['content-type']=$appApi['content_type'];
}
if(empty($apiCharset)){
$apiCharset='utf-8';
}
$curlopts=array();
}else{
$apiEncode=$this->config['toapi']['encode'];
if($apiEncode=='custom'){
$apiEncode=$this->config['toapi']['encode_custom'];
$apiUrl=$this->config['toapi']['url'];
$apiConfig['type']=$this->config['toapi']['type']?:'';
$apiConfig['charset']=$this->config['toapi']['charset'];
if($apiConfig['charset']=='custom'){
$apiConfig['charset']=$this->config['toapi']['charset_custom'];
}
if($apiEncode){
$curlopts[CURLOPT_ENCODING]=$apiEncode;
$apiConfig['encode']=$this->config['toapi']['encode'];
if($apiConfig['encode']=='custom'){
$apiConfig['encode']=$this->config['toapi']['encode_custom'];
}
$paramVals=array();
$paramFields=array();
if(is_array($this->config['toapi']['param_name'])){
foreach($this->config['toapi']['param_name'] as $k=>$v){
@ -120,19 +111,9 @@ class Rtoapi extends Release{
continue;
}
$paramVals[$v]=$this->config['toapi']['param_val'][$k];
if($paramVals[$v]=='custom'){
$paramVals[$v]=$this->config['toapi']['param_addon'][$k];
}elseif(preg_match('/^field\:(.+)$/ui',$paramVals[$v],$mField)){
$paramVals[$v]='';
$paramFields[$v]=$mField[1];
}
}
}
$headerVals=array();
$headerFields=array();
if($this->config['toapi']['content_type']){
$headerVals['content-type']=$this->config['toapi']['content_type'];
@ -145,15 +126,51 @@ class Rtoapi extends Release{
continue;
}
$headerVals[$v]=$this->config['toapi']['header_val'][$k];
if($headerVals[$v]=='custom'){
}
}
}
return $this->_export($collFieldsList,$options,$apiUrl,$apiConfig,$paramVals,$headerVals);
}
private function _export($collFieldsList,$options,$url,$apiConfig,$paramVals,$headerVals){
$addedNum=0;
if(empty($url)){
$this->echo_msg('接口地址为空');
}else{
$testToapi=input('?test_toapi');
$headerVals[$v]=$this->config['toapi']['header_addon'][$k];
}elseif(preg_match('/^field\:(.+)$/ui',$headerVals[$v],$mField)){
init_array($paramVals);
init_array($headerVals);
$headerVals[$v]='';
$headerFields[$v]=$mField[1];
}
$apiUrlMd5=md5($url);
$apiUrl='';
if(!isset($this->url_list[$apiUrlMd5])){
$apiUrl=$url;
if(strpos($apiUrl, '/')===0){
$apiUrl=config('root_website').$apiUrl;
}elseif(!preg_match('/^\w+\:\/\//', $apiUrl)){
$apiUrl='http://'.$apiUrl;
}
$this->url_list[$apiUrlMd5]=$apiUrl;
}else{
$apiUrl=$this->url_list[$apiUrlMd5];
}
$apiResponse=is_array($apiConfig['response'])?$apiConfig['response']:array();
$apiResponse['id']=$apiResponse['id']?:'id';
$apiResponse['target']=$apiResponse['target']?:'target';
$apiResponse['desc']=$apiResponse['desc']?:'desc';
$apiResponse['error']=$apiResponse['error']?:'error';
$apiCharset=$apiConfig['charset'];
if(empty($apiCharset)){
$apiCharset='utf-8';
}
$curlopts=array();
if(!empty($apiConfig['encode'])){
$curlopts[CURLOPT_ENCODING]=$apiConfig['encode'];
}
$retryWait=intval($this->config['toapi']['wait']);
@ -165,15 +182,10 @@ class Rtoapi extends Release{
$collFields=$collFields['fields'];
$this->init_download_img($this->task,$collFields);
$postData=$paramVals;
if(!empty($paramFields)){
$postData=$this->_replace_fields($paramVals,$collFields);
$url=$this->_replace_fields($apiUrl,$collFields);
foreach ($paramFields as $k=>$v){
$postData[$k]=$this->get_field_val($collFields[$v]);
}
}
$url=$apiUrl;
if($this->config['toapi']['type']=='post'){
if($apiConfig['type']=='post'){
$postData=is_array($postData)?$postData:'';
}else{
@ -182,13 +194,7 @@ class Rtoapi extends Release{
$postData=null;
}
$headerData=$headerVals;
if(!empty($headerFields)){
foreach ($headerFields as $k=>$v){
$headerData[$k]=$this->get_field_val($collFields[$v]);
}
}
$headerData=$this->_replace_fields($headerVals,$collFields);
$retryCur=0;
do{
@ -243,5 +249,19 @@ class Rtoapi extends Release{
}
return $addedNum;
}
private function _replace_fields($data,$collFields){
if(is_array($data)){
foreach ($data as $k=>$v){
$data[$k]=$this->_replace_fields($v,$collFields);
}
}else{
$data=preg_replace_callback('/\[\x{91c7}\x{96c6}\x{5b57}\x{6bb5}\:(.+?)\]/u',function($match)use($collFields){
$match=$match[1];
return $this->get_field_val($collFields[$match]);
},$data);
}
return $data;
}
}
?>

3
vendor/skycaiji/app/admin/lang/zh-cn.php vendored

@ -114,7 +114,8 @@ return array(
'task_auto_1'=>'循环',
'task_auto_2'=>'定时',
'task_addtime'=>'添加时间',
'task_caijitime'=>'采集时间',
'task_caijitime'=>'采集时间',
'task_collected'=>'采集量',
'task_edit_collector'=>'下一步:编辑采集器',
'task_root'=>'根目录',
'task_loading'=>'正在载入数据',

4
vendor/skycaiji/app/admin/model/Collector.php vendored

@ -268,7 +268,7 @@ class Collector extends \skycaiji\common\model\BaseModel{
}else{
$url=url('admin/index/auto_collect',null,false,true);
}
$url.=(strpos($url, '?')===false?'?':'&').'backstage_run=1&key='.\util\Param::set_temp_cahce_key('auto_collect');
$url.=(strpos($url, '?')===false?'?':'&').'backstage_run=1&key='.\util\Param::set_cache_key('auto_collect');
get_html($url,null,array('timeout'=>3));
}catch(\Exception $ex){}
}
@ -345,7 +345,7 @@ class Collector extends \skycaiji\common\model\BaseModel{
$chList=array();
foreach ($processes as $pkey=>$ptids){
$allParams=array(
'key'=>\util\Param::set_temp_cahce_key('collect_process'),
'key'=>\util\Param::set_cache_key('collect_process'),
'collector_process'=>$collectorKey.'-'.$pkey,
);
if(isset($collectNum)){

31
vendor/skycaiji/app/admin/model/Release.php vendored

@ -72,6 +72,37 @@ class Release extends \skycaiji\common\model\BaseModel{
unset($config['db_table']);
$config['db_tables']=$dbTables;
}
if(is_array($config['toapi'])){
if(is_array($config['toapi']['param_addon'])&&!empty($config['toapi']['param_addon'])){
init_array($config['toapi']['param_val']);
foreach ($config['toapi']['param_val'] as $k=>$v){
if($v=='custom'){
$v=$config['toapi']['param_addon'][$k];
}elseif(preg_match('/^field\:(.+)$/ui',$v,$mField)){
$v='[采集字段:'.$mField[1].']';
}
$config['toapi']['param_val'][$k]=$v;
}
}
if(is_array($config['toapi']['header_addon'])&&!empty($config['toapi']['header_addon'])){
init_array($config['toapi']['header_val']);
foreach ($config['toapi']['header_val'] as $k=>$v){
if($v=='custom'){
$v=$config['toapi']['header_addon'][$k];
}elseif(preg_match('/^field\:(.+)$/ui',$v,$mField)){
$v='[采集字段:'.$mField[1].']';
}
$config['toapi']['header_val'][$k]=$v;
}
}
}
return $config;
}

6
vendor/skycaiji/app/admin/view/backstage/index.html vendored

@ -146,6 +146,12 @@
功能失效:<div data-box="1" style="display:inline;"></div>
</div>
</div>
<div id="repair_tables" style="display:none;word-break:break-all;">
<div class="alert alert-danger">
需要修复的表:<div data-box="1"></div>
<button type="button" class="btn btn-warning" style="margin-top:5px;">开始修复</button>
</div>
</div>
<div class="box box-default">
<div class="box-header with-border">

33
vendor/skycaiji/app/admin/view/collected/list.html vendored

@ -1,5 +1,7 @@
{extend name="common:main" /}
{block name="cssjs"}
<link href="__PUBLIC__/static/css/jquery.datetimepicker.css?{$Think.config.html_v}" rel="stylesheet">
<script type="text/javascript" src="__PUBLIC__/static/js/jquery.datetimepicker.js?{$Think.config.html_v}"></script>
<script type="text/javascript" src="__PUBLIC__/static/js/admin/collected.js?{$Think.config.html_v}"></script>
{/block}
{block name="content"}
@ -78,29 +80,36 @@
</select>
</div>
<div class="form-group form-group-sm">
<label>发布方式</label>
<select name="release" class="form-control">
<option value="">全部</option>
{foreach name="Think.config.release_modules" item="rele_module"}
<option value="{$rele_module}">{:lang('collected_rele_'.$rele_module)}</option>
{/foreach}
</select>
<label>任务名</label>
<input type="text" style="width:135px;" name="task_name" class="form-control" value="{$search['task_name']}" placeholder="模糊搜索,默认全部">
</div>
<div class="form-group form-group-sm">
<label>网址</label>
<input type="text" name="url" class="form-control" value="{$search['url']}" placeholder="模糊搜索,默认全部">
</div>
<div class="form-group form-group-sm">
<label>任务名</label>
<input type="text" name="task_name" class="form-control" value="{$search['task_name']}" placeholder="模糊搜索,默认全部">
<input type="text" style="width:135px;" name="url" class="form-control" value="{$search['url']}" placeholder="模糊搜索,默认全部">
</div>
<div class="form-group form-group-sm">
<label>状态</label>
<select name="status" class="form-control">
<option value="">全部</option>
<option value="1">发布成功</option>
<option value="2">发布失败</option>
</select>
</div>
<div class="form-group form-group-sm">
<label>发布方式</label>
<select name="release" class="form-control">
<option value="">全部</option>
{foreach name="Think.config.release_modules" item="rele_module"}
<option value="{$rele_module}">{:lang('collected_rele_'.$rele_module)}</option>
{/foreach}
</select>
</div>
<div class="form-group form-group-sm">
<label>时间范围</label>
<input type="text" style="width:125px;" name="begin" class="form-control" value="{$search['begin']?:''}" placeholder="开始时间" autocomplete="off" />
<label>-</label>
<input type="text" style="width:125px;" name="end" class="form-control" value="{$search['end']?:''}" placeholder="结束时间" autocomplete="off" />
</div>
<button type="submit" class="btn btn-default btn-sm">{$Think.lang.search}</button>
</form>
</div>

5
vendor/skycaiji/app/admin/view/cpattern/process_module.html vendored

@ -457,7 +457,10 @@
<option value="jsonencode">json编码</option>
<option value="serialize">序列化</option>
</select>
<textarea data-process="api:api_json_implode" class="form-control" rows="1" placeholder="输入分隔符" style="margin-top:5px;"></textarea>
<div class="input-group p-m-api-json-implode" style="margin-top:5px;">
<textarea data-process="api:api_json_implode" class="form-control" rows="1" placeholder="输入分隔符"></textarea>
<div class="input-group-addon" style="padding-left:9px;padding-right:9px;"><span title="提示信息" class="glyphicon glyphicon-info-sign icon-info-tips" onclick="cpDelimiterTips()"></span></div>
</div>
</div>
<div class="form-group">
<label>调用间隔(毫秒,1000毫秒=1秒)</label>

4
vendor/skycaiji/app/admin/view/proxy/add.html vendored

@ -1,6 +1,6 @@
<form id="win_form_proxy_add" method="post" action="{:url('admin/proxy/add')}">
{:html_usertoken()}
<div class="table-responsive">
<div class="table-responsive" style="margin-bottom:15px;">
<table class="table table-hover datatable proxy-ip-list">
<thead>
<tr>
@ -37,7 +37,7 @@
</tbody>
</table>
</div>
<div class="form-group">
<div>
<button type="submit" class="btn btn-primary btn-block">提交</button>
</div>
</form>

4
vendor/skycaiji/app/admin/view/proxy/groups.html vendored

@ -1,6 +1,6 @@
<form id="win_form_proxy_groups" method="post" action="{:url('proxy/groups')}" ajax-submit="true">
{:html_usertoken()}
<div class="table-responsive">
<div class="table-responsive" style="margin-bottom:15px;">
<table class="table table-hover datatable proxy-group-list">
<thead>
<tr>
@ -26,7 +26,7 @@
</tbody>
</table>
</div>
<div class="form-group">
<div>
<button type="submit" class="btn btn-primary btn-block">提交</button>
</div>
</form>

396
vendor/skycaiji/app/admin/view/release/set.html vendored

@ -242,192 +242,234 @@
</div>
</div>
<div class="rele-module" id="rele_module_toapi" module="toapi" style="display:none;">
<div class="box box-default">
<div class="box-body">
<div class="form-group">
<label>接口地址</label>
<input type="text" name="toapi[url]" class="form-control" />
<p class="help-block">/开头自动补全为{:config('root_website')}/</p>
</div>
<div class="form-group">
<label>网页编码</label>
<div class="input-group input-select-custom">
<div class="input-group-btn">
<select name="toapi[charset]" class="form-control">
<option value="">utf-8</option>
<option value="gbk">gbk</option>
<option value="gb2312">gb2312</option>
<option value="custom">自定义</option>
<input type="hidden" name="toapi[module]" value="">
<ul id="toapi_tab" class="nav nav-tabs">
<li class="active"><a href="#toapi_tab_" data-toggle="tab" data-module="">自定义</a></li>
<li><a href="#toapi_tab_app" data-toggle="tab" data-module="app">一键导入</a></li>
<li style="float:right"><a href="{:\\skycaiji\\admin\\model\\Provider::create_store_url(null,'client/go/toapi')}" target="_blank">远程接口大全</a></li>
</ul>
<div id="toapi_tab_content" class="tab-content" style="margin-top:-1px">
<div class="tab-pane in active" id="toapi_tab_">
<div class="panel panel-default">
<div class="panel-body">
<div class="form-group">
<label>接口地址</label>
<input type="text" name="toapi[url]" class="form-control" />
<p class="help-block">/开头自动补全为{:config('root_website')}/</p>
</div>
<div class="form-group">
<label>网页编码</label>
<div class="input-group input-select-custom">
<div class="input-group-btn">
<select name="toapi[charset]" class="form-control">
<option value="">utf-8</option>
<option value="gbk">gbk</option>
<option value="gb2312">gb2312</option>
<option value="custom">自定义</option>
</select>
</div>
<input type="text" class="form-control" name="toapi[charset_custom]">
</div>
</div>
<div class="form-group">
<label>内容解压缩</label>
<div class="input-group input-select-custom">
<div class="input-group-btn">
<select name="toapi[encode]" class="form-control">
<option value="">系统默认</option>
<option value="gzip">gzip</option>
<option value="br">br</option>
<option value="compress">compress</option>
<option value="deflate">deflate</option>
<option value="identity">identity</option>
<option value="custom">自定义</option>
</select>
</div>
<input type="text" class="form-control" name="toapi[encode_custom]">
</div>
</div>
<div class="form-group">
<label>请求方式</label>
<select name="toapi[type]" class="form-control">
<option value="post">POST</option>
<option value="">GET</option>
</select>
</div>
<input type="text" class="form-control" name="toapi[charset_custom]">
</div>
</div>
<div class="form-group">
<label>内容解压缩</label>
<div class="input-group input-select-custom">
<div class="input-group-btn">
<select name="toapi[encode]" class="form-control">
<option value="">系统默认</option>
<option value="gzip">gzip</option>
<option value="br">br</option>
<option value="compress">compress</option>
<option value="deflate">deflate</option>
<option value="identity">identity</option>
<option value="custom">自定义</option>
<div class="form-group toapi-content-type">
<label>POST数据类型 <a href="javascript:;" class="glyphicon glyphicon-info-sign icon-info-tips" onclick="tipsCurlPost()"></a></label>
<select name="toapi[content_type]" class="form-control">
<option value="">默认表单数据:application/x-www-form-urlencoded</option>
<option value="application/json">JSON数组:application/json</option>
<option value="multipart/form-data">表单上传:multipart/form-data</option>
</select>
</div>
<input type="text" class="form-control" name="toapi[encode_custom]">
<div class="form-group">
<label>发送数据</label>
<a href="javascript:;" class="glyphicon glyphicon-plus toapi-add-param" title="添加"></a>
<div class="toapi-param-table">
<table class="table table-bordered table-hover">
<thead>
<tr>
<td>名称</td>
<td></td>
<td>删除</td>
</tr>
</thead>
<tbody>
<tr class="toapi-param-tpl" style="display:none;">
<td>
<input type="text" name="toapi[param_name][]" class="form-control" autocomplete="off" />
</td>
<td>
<div class="input-group toapi-txt-field">
<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>
<ul class="dropdown-menu dropdown-menu-right">
{if !empty($collFields)}
{foreach $collFields as $v}
<li><a href="javascript:;" data-val="[采集字段:{$v}]">采集字段:{$v}</a></li>
{/foreach}
{/if}
</ul>
</div>
</div>
</td>
<td>
<a href="javascript:;" class="glyphicon glyphicon-remove toapi-del-param" style="margin-top:8px;"></a>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="form-group">
<label>请求头信息</label>
<a href="javascript:;" class="glyphicon glyphicon-plus toapi-add-header" title="添加"></a>
<div class="toapi-header-table">
<table class="table table-bordered table-hover">
<thead>
<tr>
<td>名称</td>
<td></td>
<td>删除</td>
</tr>
</thead>
<tbody>
<tr class="toapi-header-tpl" style="display:none;">
<td>
<input type="text" name="toapi[header_name][]" class="form-control" autocomplete="off" />
</td>
<td>
<div class="input-group toapi-txt-field">
<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>
<ul class="dropdown-menu dropdown-menu-right">
{if !empty($collFields)}
{foreach $collFields as $v}
<li><a href="javascript:;" data-val="[采集字段:{$v}]">采集字段:{$v}</a></li>
{/foreach}
{/if}
</ul>
</div>
</div>
</td>
<td>
<a href="javascript:;" class="glyphicon glyphicon-remove toapi-del-header" style="margin-top:8px;"></a>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="form-group">
<div>
<label>响应状态</label>
<small style="margin-left:5px;color:#999;">接口必须返回json格式的数组用来记录数据入库的状态,否则会标记为失败</small>
</div>
<div class="table-responsive">
<table class="table table-hover" style="margin-bottom:0;">
<thead>
<tr>
<td style="width:150px;">名称</td>
<td>绑定响应的json数组健名</td>
</tr>
</thead>
<tbody>
<tr>
<td>id(编号)</td>
<td><input type="text" name="toapi[response][id]" class="form-control" placeholder="默认:id,表示入库返回的自增id或入库状态" /></td>
</tr>
<tr>
<td>target(位置)</td>
<td><input type="text" name="toapi[response][target]" class="form-control" placeholder="默认:target,记录入库的数据位置(发布的网址等)" /></td>
</tr>
<tr>
<td>desc(描述)</td>
<td><input type="text" name="toapi[response][desc]" class="form-control" placeholder="默认:desc,记录入库的数据位置附加信息" /></td>
</tr>
<tr>
<td>error(错误)</td>
<td><input type="text" name="toapi[response][error]" class="form-control" placeholder="默认:error,记录入库失败的错误信息" /></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
<div class="form-group">
<label>请求方式</label>
<select name="toapi[type]" class="form-control">
<option value="post">POST</option>
<option value="">GET</option>
</select>
</div>
<div class="form-group toapi-content-type">
<label>POST数据类型 <a href="javascript:;" class="glyphicon glyphicon-info-sign icon-info-tips" onclick="tipsCurlPost()"></a></label>
<select name="toapi[content_type]" class="form-control">
<option value="">默认表单数据:application/x-www-form-urlencoded</option>
<option value="application/json">JSON数组:application/json</option>
<option value="multipart/form-data">表单上传:multipart/form-data</option>
</select>
</div>
<div class="form-group">
<label>发送数据</label>
<a href="javascript:;" class="glyphicon glyphicon-plus toapi-add-param" title="添加"></a>
<div class="table-responsive toapi-param-table">
<table class="table table-bordered table-hover">
<thead>
<tr>
<td>名称</td>
<td></td>
<td>删除</td>
</tr>
</thead>
<tbody>
<tr class="toapi-param-tpl" style="display:none;">
<td>
<input type="text" name="toapi[param_name][]" class="form-control">
</td>
<td>
<div class="input-group input-select-custom">
<div class="input-group-btn">
<select name="toapi[param_val][]" class="form-control">
<option value=""></option>
{if !empty($collFields)}
{foreach $collFields as $v}
<option value="field:{$v}">采集字段:{$v}</option>
{/foreach}
{/if}
<option value="custom">自定义</option>
</select>
</div>
<input type="text" name="toapi[param_addon][]" class="form-control">
</div>
</td>
<td>
<a href="javascript:;" class="glyphicon glyphicon-remove toapi-del-param" style="margin-top:8px;"></a>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="form-group">
<label>请求头信息</label>
<a href="javascript:;" class="glyphicon glyphicon-plus toapi-add-header" title="添加"></a>
<div class="table-responsive toapi-header-table">
<table class="table table-bordered table-hover">
<thead>
<tr>
<td>名称</td>
<td></td>
<td>删除</td>
</tr>
</thead>
<tbody>
<tr class="toapi-header-tpl" style="display:none;">
<td>
<input type="text" name="toapi[header_name][]" class="form-control">
</td>
<td>
<div class="input-group input-select-custom">
<div class="input-group-btn">
<select name="toapi[header_val][]" class="form-control">
<option value=""></option>
{if !empty($collFields)}
{foreach $collFields as $v}
<option value="field:{$v}">采集字段:{$v}</option>
{/foreach}
{/if}
<option value="custom">自定义</option>
</select>
</div>
<input type="text" name="toapi[header_addon][]" class="form-control">
</div>
</td>
<td>
<a href="javascript:;" class="glyphicon glyphicon-remove toapi-del-header" style="margin-top:8px;"></a>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="form-group">
<div>
<label>响应状态</label>
<small style="margin-left:5px;color:#999;">接口必须返回json格式的数组用来记录数据入库的状态,否则会标记为失败</small>
</div>
<div class="table-responsive">
<table class="table table-hover" style="margin-bottom:0;">
<thead>
<tr>
<td style="width:150px;">名称</td>
<td>绑定响应的json数组健名</td>
</tr>
</thead>
<tbody>
<tr>
<td>id(编号)</td>
<td><input type="text" name="toapi[response][id]" class="form-control" placeholder="默认:id,表示入库返回的自增id或入库状态" /></td>
</tr>
<tr>
<td>target(位置)</td>
<td><input type="text" name="toapi[response][target]" class="form-control" placeholder="默认:target,记录入库的数据位置(发布的网址等)" /></td>
</tr>
<tr>
<td>desc(描述)</td>
<td><input type="text" name="toapi[response][desc]" class="form-control" placeholder="默认:desc,记录入库的数据位置附加信息" /></td>
</tr>
<tr>
<td>error(错误)</td>
<td><input type="text" name="toapi[response][error]" class="form-control" placeholder="默认:error,记录入库失败的错误信息" /></td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="tab-pane" id="toapi_tab_app">
<div class="panel panel-default">
<div class="panel-body">
<div class="form-group">
<label>接口地址</label>
<div class="input-group">
<input type="text" name="toapi[app_url]" class="form-control" autocomplete="off" />
<div class="input-group-btn"><button class="btn btn-default" type="button" id="btn_toapi_app">一键导入</button></div>
</div>
<div class="help-block">
/开头自动补全为{:config('root_website')}/
<select id="toapi_app_url_field" style="color:#333;margin-left:5px;border:0;width:80px;cursor:pointer;">
<option value="">插入字段</option>
{if !empty($collFields)}
{foreach $collFields as $v}
<option value="[采集字段:{$v}]">采集字段:{$v}</option>
{/foreach}
{/if}
</select>
</div>
</div>
</div>
</div>
<div class="form-group">
<label>调用间隔(毫秒,1000毫秒=1秒)</label>
<input type="number" name="toapi[interval]" class="form-control">
<p class="help-block">发布间隔时间</p>
</div>
<div class="form-group">
<label>失败等待(秒)</label>
<input type="number" name="toapi[wait]" class="form-control">
<p class="help-block">发布失败,等待一段时间再继续</p>
</div>
<div class="form-group">
<label>失败重试</label>
<input type="number" name="toapi[retry]" class="form-control">
<p class="help-block">发布失败重试次数,留空或0表示不重试</p>
</div>
<div id="toapi_app_params"></div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title"><a data-toggle="collapse" href="#panel_toapi" aria-expanded="false" class="collapsed">更多设置</a></h4>
</div>
<div class="panel-collapse collapse" id="panel_toapi">
<div class="panel-body">
<div class="form-group">
<label>调用间隔(毫秒,1000毫秒=1秒)</label>
<input type="number" name="toapi[interval]" class="form-control">
<p class="help-block">发布间隔时间</p>
</div>
<div class="form-group">
<label>失败等待(秒)</label>
<input type="number" name="toapi[wait]" class="form-control">
<p class="help-block">发布失败,等待一段时间再继续</p>
</div>
<div class="form-group">
<label>失败重试</label>
<input type="number" name="toapi[retry]" class="form-control">
<p class="help-block">发布失败重试次数,留空或0表示不重试</p>
</div>
</div>
</div>
</div>
</div>
<div class="rele-module" id="rele_module_diy" module="diy" style="display:none;">
<input type="hidden" name="diy[type]" value="app">

66
vendor/skycaiji/app/admin/view/release/toapiApp.html vendored

@ -0,0 +1,66 @@
<input type="hidden" name="toapi[app_api]" value="{$appApi}" />
<div class="box box-primary">
<div class="box-body">
<table class="table">
<thead>
<tr>
<th>参数名称</th>
<th>参数数据</th>
</tr>
</thead>
<tbody>
{foreach $appApiParams as $pk=>$pv}
{php}$pvOption=is_array($pv['option'])?$pv['option']:array();{/php}
<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 !empty($pvOption)}
{foreach $pvOption as $pvOk=>$pvOv}
<label class="radio-inline"><input type="radio" name="toapi[app_params][{$pk}]" value="{$pvOk}">{$pvOv}</label>
{/foreach}
{else/}
<label class="radio-inline"><input type="radio" name="toapi[app_params][{$pk}]" value="1"></label>
<label class="radio-inline"><input type="radio" name="toapi[app_params][{$pk}]" value="0"></label>
{/if}
{elseif $pv['tag']=='checkbox'}
{if !empty($pvOption)}
{foreach $pvOption as $pvOk=>$pvOv}
<label class="checkbox-inline"><input type="checkbox" name="toapi[app_params][{$pk}][]" value="{$pvOk}">{$pvOv}</label>
{/foreach}
{/if}
{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-btn">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">字段 <span class="caret"></span></button>
<ul class="dropdown-menu dropdown-menu-right">
{if !empty($collFields)}
{foreach $collFields as $v}
<li><a href="javascript:;" data-val="[采集字段:{$v}]">采集字段:{$v}</a></li>
{/foreach}
{/if}
</ul>
</div>
</div>
{/if}
</td>
</tr>
{/foreach}
</tbody>
</table>
</div>
</div>
<script type="text/javascript">
releaseClass.toapi_app_load({$appParams|json_encode});
</script>

4
vendor/skycaiji/app/admin/view/setting/page_render.html vendored

@ -58,10 +58,10 @@
<div class="input-group">
<span class="input-group-addon"></span>
<input type="number" name="chrome[wait_end_ms]" class="form-control" placeholder="默认500" value="{$config['chrome']['wait_end_ms']?:''}" />
<span class="input-group-addon brl_0 brr_0">毫秒内网络连接个数不超过</span>
<span class="input-group-addon brl_0 brr_0">毫秒内网络连接个数不超过</span>
<input type="number" name="chrome[wait_end_num]" class="form-control" placeholder="默认2" value="{$config['chrome']['wait_end_num']?:''}" />
</div>
<p class="help-block">在执行“页面渲染动作»等待页面完全渲染”时根据该条件判断页面(包括所有资源及ajax请求)是否渲染完毕</p>
<p class="help-block">在执行“任务采集器设置»执行页面渲染»页面渲染动作»等待页面完全渲染”时根据该条件判断页面(包括所有资源及ajax请求)是否渲染完毕</p>
</div>
</div>
<div class="form-group">

5
vendor/skycaiji/app/admin/view/task/list_folder.html vendored

@ -10,7 +10,7 @@
<input type="hidden" name="show" value="folder" />
<input type="hidden" name="op" value="saveall" />
<div class="table-responsive" style="border:0;">
<table id="task_list_folder" class="table table-bordered table-hover datatable">
<table id="task_list_folder" class="table table-hover datatable">
<thead>
<tr>
<th>{$Think.lang.task_name}</th>
@ -18,6 +18,7 @@
<th>{$Think.lang.task_auto}</th>
<th>{$Think.lang.task_addtime}</th>
<th>{$Think.lang.task_caijitime}</th>
<th>{$Think.lang.task_collected}</th>
<th>{$Think.lang.op}</th>
</tr>
</thead>
@ -37,7 +38,7 @@
<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>
</td>
<td colspan="2">
<td colspan="3">
<label class="checkbox-inline chk-inline">
<input type="checkbox" onclick="checkall(this,'batch[]')" />
全选

12
vendor/skycaiji/app/admin/view/task/list_footer.html vendored

@ -2,6 +2,17 @@
<form id="form_search_task" method="post" action="{:url('task/list')}" class="form-inline">
{:html_usertoken()}
<input type="hidden" name="show" value="list" />
<div class="form-group form-group-sm">
<label>每页显示</label>
<select name="num" class="form-control">
<option value="30">30</option>
<option value="50">50</option>
<option value="100">100</option>
<option value="150">150</option>
<option value="200">200</option>
<option value="300">300</option>
</select>
</div>
<div class="form-group form-group-sm">
<label>{$Think.lang.task_tg}</label>
{$tgSelect}
@ -24,6 +35,7 @@
</div>
{if $search}
<script type="text/javascript">
$('#form_search_task [name="num"]').val("{$search['num']}");
$('#form_search_task [name="tg_id"]').val("{$search['tg_id']}");
$('#form_search_task [name="module"]').val("{$search['module']}");
</script>

18
vendor/skycaiji/app/admin/view/task/list_list.html vendored

@ -20,6 +20,7 @@
<th class="sorting{$orderClass['auto']}" data-order="auto" title="{$orderSort['auto']}" style="min-width:90px;">{$Think.lang.task_auto}</th>
<th class="sorting{$orderClass['addtime']}" data-order="addtime" title="{$orderSort['addtime']}">{$Think.lang.task_addtime}</th>
<th class="sorting{$orderClass['caijitime']}" data-order="caijitime" title="{$orderSort['caijitime']}">{$Think.lang.task_caijitime}</th>
<th>{$Think.lang.task_collected}</th>
<th>{$Think.lang.op}</th>
</tr>
</thead>
@ -49,11 +50,22 @@
<li><a href="javascript:;" class="houtai">后台</a></li>
</ul>
</td>
<td>
{if is_array($item['_collected_info'])}
<ul class="in-line">
<li>今日<a href="{:url('collected/list?task_id='.$item['id'].'&begin='.$todayDate)}" target="_blank">{$item['_collected_info']['today']}</a></li>
<li class="sep">|</li>
<li>总共<a href="{:url('collected/list?task_id='.$item['id'])}" target="_blank">{$item['_collected_info']['total']}</a></li>
</ul>
{else/}
{/if}
</td>
<td>
<ul class="in-line">
<li><a href="{:url('collector/set?task_id='.$item['id'])}">规则</a></li>
<li class="sep">|</li>
<li><a href="{:url('release/set?task_id='.$item['id'])}">发布</a></li>
<li><a href="{:url('release/set?task_id='.$item['id'])}" title="{$item['_rele_module']?:''}">发布</a></li>
<li class="sep">|</li>
<li><a href="javascript:;" class="delete">{$Think.lang.delete}</a></li>
</ul>
@ -68,7 +80,7 @@
<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>
</td>
<td colspan="2">
<td colspan="3">
<label class="checkbox-inline chk-inline">
<input type="checkbox" onclick="checkall(this,'batch[]')" />
全选
@ -82,7 +94,7 @@
</tr>
{if condition="!empty($pagenav)"}
<tr>
<td colspan="7">{$pagenav}</td>
<td colspan="8">{$pagenav}</td>
</tr>
{/if}
</tfoot>

4
vendor/skycaiji/app/common.php vendored

@ -10,7 +10,7 @@
*/
define('SKYCAIJI_VERSION', '2.5.2');
define('SKYCAIJI_VERSION', '2.5.3');
\think\Loader::addNamespace('plugin', realpath(SKYCAIJI_PATH.'plugin'));
\think\Loader::addNamespace('util',realpath(APP_PATH.'extend/util'));
@ -250,7 +250,7 @@ function get_html($url,$headers=array(),$options=array(),$fromEncode='auto',$pos
$postDataJson=array();
foreach ($postData as $k=>$v){
if(strpos($v,'{')===0||strpos($v,'[')===0){
if(!is_array($v)&&(strpos($v,'{')===0||strpos($v,'[')===0)){
$vJson=\util\Funcs::convert_html2json($v);
if(!empty($vJson)){

43
vendor/skycaiji/app/extend/util/ChromeSocket.php vendored

@ -25,7 +25,7 @@ class ChromeSocket{
protected $tabId;
protected $isProxy=false;
protected $startTime=0;
static protected $passType=array('Stylesheet'=>1,'Image'=>1,'Media'=>1,'Font'=>1);
static protected $passType=array('Image'=>1,'Media'=>1,'Font'=>1);
public function __construct($host,$port,$timeout=30,$filename='',$options=array()){
if($host){
@ -436,14 +436,15 @@ class ChromeSocket{
if($rdType=='val'){
$rdContent=addslashes($rdContent);
$expression='(function(){'
.'var skycaijiXpathEle=document.evaluate("'.$rdElement.'",document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue;'
.'skycaijiXpathEle.value="'.$rdContent.'";'
.'var scjEle=document.evaluate("'.$rdElement.'",document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue;'
.'scjEle.value="'.$rdContent.'";'
.'})();';
}elseif($rdType=='click'){
$expression='(function(){'
.'var skycaijiXpathEle=document.evaluate("'.$rdElement.'",document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue;'
.'skycaijiXpathEle.click();'
.'})();';
.'var scjEle=document.evaluate("'.$rdElement.'",document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue;'
.'if(scjEle.tagName&&scjEle.tagName.toLowerCase()=="a"){scjEle.target="_self";}'
.'var scjForms=document.getElementsByTagName("form");if(scjForms.length>0){for(var i in scjForms){scjForms[i].target="_self";}}'
.'scjEle.click();})();';
}
if($expression){
$sendData=$this->send('Runtime.evaluate',array('expression'=>$expression));
@ -539,16 +540,18 @@ class ChromeSocket{
$result=$data;
break;
}
if($data['method']=='Fetch.requestPaused'){
if(!empty(self::$passType)){
if($data['method']=='Fetch.requestPaused'){
$dataParams=is_array($data['params'])?$data['params']:array();
$dataParams=is_array($data['params'])?$data['params']:array();
$fParams=array('requestId'=>$dataParams['requestId']);
if(isset(self::$passType[$dataParams['resourceType']])){
$fParams['errorReason']='Aborted';
$this->send('Fetch.failRequest',$fParams);
}else{
$this->send('Fetch.continueRequest',$fParams);
$fParams=array('requestId'=>$dataParams['requestId']);
if(isset(self::$passType[$dataParams['resourceType']])){
$fParams['errorReason']='Aborted';
$this->send('Fetch.failRequest',$fParams);
}else{
$this->send('Fetch.continueRequest',$fParams);
}
}
}
if($returnAll){
@ -585,8 +588,20 @@ class ChromeSocket{
$this->websocket($verData['webSocketDebuggerUrl']);
$sendData=$this->send('Target.createBrowserContext',array('proxyServer'=>$proxyServer));
$data=$this->receiveById($sendData['id'],false);
if(!is_array($data)){
$data=array();
}
if(!is_array($data['result'])){
$data['result']=array();
}
$sendData=$this->send('Target.createTarget',array('url'=>'about:blank','browserContextId'=>$data['result']['browserContextId']));
$data=$this->receiveById($sendData['id'],false);
if(!is_array($data)){
$data=array();
}
if(!is_array($data['result'])){
$data['result']=array();
}
$tabId=$data['result']['targetId'];
}else{

6
vendor/skycaiji/app/extend/util/Funcs.php vendored

@ -321,11 +321,9 @@ class Funcs{
$params=\util\Funcs::convert_charset($params,'utf-8',$charset);
}
foreach ($params as $k=>$v){
$params[$k]=$k.'='.rawurlencode($v);
}
$params=http_build_query($params);
$url.=strpos($url, '?')===false?'?':'&';
$url.=implode('&', $params);
$url.=$params;
}
return $url;
}

15
vendor/skycaiji/app/extend/util/Param.php vendored

@ -12,6 +12,8 @@
/*全局参数,集中管理*/
namespace util;
use think\Cache;
class Param{
private static function set_define($name){
if(!defined($name)){
@ -63,20 +65,17 @@ class Param{
return \skycaiji\admin\model\CacheModel::getInstance()->getCache('proc_open_exec_key', 'data');
}
public static function set_temp_cahce_key($prefix=null){
public static function set_cache_key($prefix=null){
$key=\util\Funcs::uniqid($prefix);
\skycaiji\admin\model\CacheModel::getInstance('temp')->setCache($key, 1);
Cache::set('key_'.$key, '1');
return $key;
}
public static function exist_temp_cahce_key($key){
public static function exist_cache_key($key){
$exist=false;
if($key){
$mcache=\skycaiji\admin\model\CacheModel::getInstance('temp');
$count=$mcache->getCount($key);
if($count>0){
$mcache->deleteCache($key);
$val=Cache::pull('key_'.$key);
if(!empty($val)){
$exist=true;
}
}

2
vendor/skycaiji/app/install/data/check_db vendored

File diff suppressed because one or more lines are too long

2
vendor/skycaiji/app/install/data/check_file vendored

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save